diff -Nru cppad-2018.00.00.0/appveyor.yml cppad-2019.02.00.0/appveyor.yml --- cppad-2018.00.00.0/appveyor.yml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/appveyor.yml 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,41 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# +# build platform, i.e. x86, x64, Any CPU. This setting is optional. +platform: + - x64 + +# msys2 environment +environment: + matrix: + - HOST_ARCH_ARG: --host=x86_64-w64-mingw32 + ADD_PATH: /mingw64/bin + +# scripts that run after cloning repository +install: + - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-x86_64-cmake" + +# +# run custom scripts instead of automatic MSBuild +build_script: + - C:\msys64\usr\bin\bash -lc " + cd $APPVEYOR_BUILD_FOLDER; + export PATH=$PATH:$ADD_PATH; + bin/appveyor.sh + " +# +notifications: + - provider: Email + to: + - bradbell@seanet.com + on_build_success: true + on_build_failure: true diff -Nru cppad-2018.00.00.0/batch_edit.sed cppad-2019.02.00.0/batch_edit.sed --- cppad-2018.00.00.0/batch_edit.sed 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/batch_edit.sed 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,31 @@ +# ---------------------------------------------------------------------------- +# None of the lists below can have white space or a dollar sign in an entry. +# +# list of directories that are added to the repository by batch_edit.sh +# new_directories=' +# ' +# list of files that are deleted by batch_edit.sh +# delete_files=' +# ' +# List of files that are not edited by the sed commands in this file +# (with the possible exception of the extra_seds commands). +# The files in bin/devel.sh ignore_files are automatically in this list. +# ignore_files=' +# ' +# list of files and or directories that are moved to new names +# move_paths=' +# ' +# list of sed commands that map old file and directory names to new names. +# The characters @s, @d, @n get converted to a space, dollar sign, new line. +# move_seds=' +# ' +# list of files that get edited by the extra_seds command +# extra_files=' +# ' +# list of sed commands that are applied to the extra files, +# after the other sed commands in this file. +# The characters @s, @d, @n get converted to a space, dollar sign, new line. +# extra_seds=' +# ' +# ---------------------------------------------------------------------------- +# Put other sed commands below here and without # at start of line diff -Nru cppad-2018.00.00.0/bin/appveyor.sh cppad-2019.02.00.0/bin/appveyor.sh --- cppad-2018.00.00.0/bin/appveyor.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/bin/appveyor.sh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,35 @@ +#! /bin/bash -e +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +if [ $0 != "bin/appveyor.sh" ] +then + echo 'bin/appveyor.sh: must be executed from its parent directory' + exit 1 +fi +# ----------------------------------------------------------------------------- +# bash function that echos and executes a command +echo_eval() { + echo $* + eval $* +} +# ----------------------------------------------------------------------------- +echo_eval mkdir build +echo_eval cd build +echo_eval cmake \ + -G '"Unix Makefiles"' \ + -D CMAKE_C_COMPILER=gcc \ + -D CMAKE_CXX_COMPILER=g++ \ + .. +echo_eval make check +# ----------------------------------------------------------------------------- +echo 'bin/appveyor.sh: OK' +exit 0 diff -Nru cppad-2018.00.00.0/bin/autotools.sh cppad-2019.02.00.0/bin/autotools.sh --- cppad-2018.00.00.0/bin/autotools.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/autotools.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ #! /bin/bash -e # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # build script for use with autotools install # ----------------------------------------------------------------------------- @@ -21,550 +22,217 @@ EIGEN_DIR=$HOME/prefix/eigen FADBAD_DIR=$HOME/prefix/fadbad IPOPT_DIR=$HOME/prefix/ipopt -# version type is one of "trunk" or "stable" -version_type="stable" +# ----------------------------------------------------------------------------- +# bash function that echos and executes a command +echo_eval() { + echo $* + eval $* +} # ----------------------------------------------------------------------------- if [ $0 != "bin/autotools.sh" ] then - echo "bin/autotools.sh: must be executed in the directory that contians it" - exit 1 + echo "bin/autotools.sh: must be executed in the directory that contians it" + exit 1 fi -if [ "$2" != "" ] +if [ "$1" != 'automake' ] && [ "$1" != 'configure' ] && [ "$1" != 'test' ] then - # when running multiple options, start by removing old log files - touch junk.log - list=`ls *.log` - for log in $list - do - echo "rm $log" - rm $log - done - # - # run multiple options in order - for option in $* - do - echo "==============================================================" - echo "begin: bin/autotools.sh $option" - bin/autotools.sh $option - done - echo "==============================================================" - exit 0 + echo "$1 is not a valid option" +cat << EOF +usage: bin/autotools.sh option + +where option is one of the following: +automake: run the tools required by autoconf and automake. +configure:run the configure script in the build directory. +test: build and run the tests using the autotools. +EOF + exit 1 fi +option="$1" # ----------------------------------------------------------------------------- if [ ! -e build ] then - echo "mkdir build" - mkdir build -fi -# ----------------------------------------------------------------------------- -# 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` -# -# Version of cppad that corresponds to today. -if [ "$version_type" == "trunk" ] -then - version=`bin/version.sh get` -else - 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-|'` + echo_eval mkdir build fi +log_dir=`pwd` +log_file="$option.log" +version=`version.sh get` # # Files are created by the configure command and copied to the source tree configure_file_list=" - cppad/configure.hpp + include/cppad/configure.hpp " # ----------------------------------------------------------------------------- -# change version to current date -if [ "$1" = "version" ] +if [ "$option" = "automake" ] then - echo 'bin/version.sh check' - bin/version.sh check - # - echo "OK: bin/autotools.sh version" - exit 0 -fi -# ----------------------------------------------------------------------------- -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'` - auto_output=" - depcomp - install-sh - missing - configure - config.guess - config.sub - $makefile_in - " - missing="" - for name in $auto_output - do - if [ ! -e $name ] - then - if [ "$missing" != "" ] - then - missing="$missing, $name" - else - missing="$name" - fi - else - # force remake of files - rm "$name" - fi - done - if [ "$missing" != "" ] - then - echo "The following files:" - echo " $missing" - echo "are not in subversion repository." - echo "Check them in when this command is done completes." - fi - # - echo "aclocal" - aclocal - # - echo "skipping libtoolize" - # echo "libtoolize -c -f -i" - # if ! libtoolize -c -f -i - # then - # exit 1 - # fi - # - echo "autoconf" - autoconf - # - echo "automake --add-missing" - automake --add-missing - # - link_list="missing install-sh depcomp config.sub config.guess" - for name in $link_list - do - if [ -h "$name" ] - then - echo "Converting $name from a link to a regular file" - # - echo "cp $name $name.$$" - cp $name $name.$$ - # - echo "mv $name.$$ $name" - mv $name.$$ $name - fi - done - # - echo "OK: bin/autotools.sh automake" - exit 0 + # 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'` + auto_output=" + depcomp + install-sh + missing + configure + config.guess + config.sub + $makefile_in + " + missing="" + for name in $auto_output + do + if [ ! -e $name ] + then + if [ "$missing" != "" ] + then + missing="$missing, $name" + else + missing="$name" + fi + else + # force remake of files + rm "$name" + fi + done + if [ "$missing" != "" ] + then + echo "The following files:" + echo " $missing" + echo "are not in subversion repository." + echo "Check them in when this command is done completes." + fi + # + echo_eval aclocal + # + echo "skipping libtoolize" + # echo "libtoolize -c -f -i" + # if ! libtoolize -c -f -i + # then + # exit 1 + # fi + # + echo_eval autoconf + # + echo_eval automake --add-missing + # + link_list="missing install-sh depcomp config.sub config.guess" + for name in $link_list + do + if [ -h "$name" ] + then + echo "Converting $name from a link to a regular file" + # + echo_eval cp $name $name.$$ + # + echo_eval mv $name.$$ $name + fi + done + # + echo "OK: bin/autotools.sh automake" + exit 0 fi # ----------------------------------------------------------------------------- # configure -if [ "$1" == "configure" ] +if [ "$option" == "configure" ] then - log_dir=`pwd` - log_file="$1.log" - # - echo "cd build" - cd build - # - dir_list=" - --prefix=$CPPAD_DIR - " - if [ -e $BOOST_DIR/include/boost ] - then - dir_list="$dir_list BOOST_DIR=$BOOST_DIR" -#_build_test_only: if [ ! -e $EIGEN_DIR/include/Eigen ] -#_build_test_only: then -#_build_test_only: dir_list="$dir_list --with-boostvector" -#_build_test_only: fi - fi - if [ -e $EIGEN_DIR/include/Eigen ] - then - 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 - FADBAD_DIR=$FADBAD_DIR" - fi - if [ -e $IPOPT_DIR/include/coin/IpIpoptApplication.hpp ] - then - dir_list="$dir_list - IPOPT_DIR=$IPOPT_DIR" - fi - # 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" - # - dir_list=`echo $dir_list | sed -e 's|\t\t*| |g'` - cxx_flags="-Wall -ansi -pedantic-errors -std=c++11 -Wshadow" - cxx_flags="$cxx_flags -isystem $EIGEN_DIR/include" + # + echo_eval cd build + # + dir_list=" + --prefix=$CPPAD_DIR + " + testvector='cppadvector' + if [ -e $BOOST_DIR/include/boost ] + then + dir_list="$dir_list BOOST_DIR=$BOOST_DIR" + testvector='boostvector' + fi + if [ -e $EIGEN_DIR/include/Eigen ] + then + dir_list="$dir_list EIGEN_DIR=$EIGEN_DIR" + testvector='eigenvector' + fi + if [ -e $FADBAD_DIR/include/FADBAD++ ] + then + dir_list="$dir_list FADBAD_DIR=$FADBAD_DIR" + fi + if [ -e $IPOPT_DIR/include/coin/IpIpoptApplication.hpp ] + then + dir_list="$dir_list IPOPT_DIR=$IPOPT_DIR" + fi + cxx_flags="-Wall -ansi -pedantic-errors -std=c++11 -Wshadow -DNDEBUG -O2" + cxx_flags="$cxx_flags -isystem $EIGEN_DIR/include" cat << EOF ../configure > $log_file \\ $dir_list \\ CXX_FLAGS=\"$cxx_flags\" \\ -$special_types OPENMP_FLAGS=-fopenmp \\ ---with-Documentation +OPENMP_FLAGS=-fopenmp \\ +--with-$testvector EOF - # - ../configure > $log_dir/$log_file \ - $dir_list \ - CXX_FLAGS="$cxx_flags" \ - $special_types OPENMP_FLAGS=-fopenmp \ - --with-Documentation - # - for file in $configure_file_list - do - echo "cp $file ../$file" - cp $file ../$file - done - # - echo "OK: bin/autotools.sh configure" - exit 0 -fi -# ----------------------------------------------------------------------------- -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' - then - echo "Missing comment expected in doc.omh" - exit 1 - fi - echo "sed -i.save doc.omh ..." - sed -i.save doc.omh \ - -e '/This comment is used to remove the table below/,/$tend/d' - # - if [ -e doc ] - then - echo "rm -r doc" - rm -r doc - fi - # - echo "bin/run_omhelp.sh xml" - if ! bin/run_omhelp.sh xml - then - echo "mv doc.omh.save doc.omh" - mv doc.omh.save doc.omh - exit 1 - fi - # - echo "mv doc.omh.save doc.omh" - mv doc.omh.save doc.omh - # No longer run these because tested when bin/package.sh is run. - # Run automated checking of file names in original source directory - # 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 - # do - # echo "bin/$check" - # bin/$check - # done - # ---------------------------------------------------------------------- - # Things to do in the build directory - # ---------------------------------------------------------------------- - echo "cd build" - cd build - # - if [ -e cppad-$version ] - then - echo "rm -rf cppad-$version" - rm -rf cppad-$version - fi - for file in cppad-*.tgz - do - if [ -e $file ] - then - echo "rm $file" - rm $file - fi - done - # - echo "make dist" - make dist - # - if [ ! -e cppad-$version.tar.gz ] - then - echo "cppad-$version.tar.gz does not exist" - echo "perhaps version is out of date" - # - exit 1 - fi - # change *.tgz to *.epl.tgz - echo "mv cppad-$version.tar.gz cppad-$version.epl.tgz" - mv cppad-$version.tar.gz cppad-$version.epl.tgz - # - echo "OK: bin/autotools.sh dist" - exit 0 -fi -# ----------------------------------------------------------------------------- -# omhelp comes after dist because dist only includes one help output -if [ "$1" = "omhelp" ] -then - if ! grep < doc.omh > /dev/null \ - 'This comment is used to remove the table below' - then - echo "doc.omh is missing a table." - echo "Try re-running bin/autotools.sh configure." - fi - for flag in "printable" "" - do - # Run xml after htm so that index.htm points to cppad.xml - # (see run_omhelp.sh). - for ext in htm xml - do - echo "bin/run_omhelp.sh $ext $flag" - bin/run_omhelp.sh $ext $flag - done - done - # - echo "OK: bin/autotools.sh omhelp" - exit 0 -fi -# ----------------------------------------------------------------------------- -if [ "$1" = "doxygen" ] -then - echo "bin/run_doxygen.sh" - bin/run_doxygen.sh - # - echo "OK: bin/autotools.sh doxygen" - exit 0 -fi -# ----------------------------------------------------------------------------- -if [ "$1" = "gpl" ] -then - # create GPL licensed version - echo "bin/gpl_license.sh cppad-$version build build" - bin/gpl_license.sh cppad-$version build build - # - echo "OK: bin/autotools.sh gpl" - exit 0 -fi -# ----------------------------------------------------------------------------- -if [ "$1" = "copy2doc" ] -then - for ext in epl gpl - do - echo "cp build/cppad-$version.$ext.tgz doc/cppad-$version.$ext.tgz" - cp build/cppad-$version.$ext.tgz doc/cppad-$version.$ext.tgz - done - # - echo "cp -r doxydoc doc/doxydoc" - cp -r doxydoc doc/doxydoc - # - echo "cp *.log doc" - cp *.log doc - # - echo "OK: bin/autotools.sh copy2doc" - exit 0 + # + ../configure > $log_dir/$log_file \ + $dir_list \ + CXX_FLAGS="$cxx_flags" \ + OPENMP_FLAGS=-fopenmp \ + --with-$testvector + # + for file in $configure_file_list + do + echo_eval cp $file ../$file + done + # + echo "OK: bin/autotools.sh configure" + exit 0 +fi +# ----------------------------------------------------------------------------- +if [ "$option" = "test" ] +then + echo "date >> $log_file" + date >> $log_dir/$log_file + # ----------------------------------------------------------------------- + # build/cppad-$version.tgz + bin/package.sh --no_doc + # -------------------------------------------------------------- + echo_eval cd build + # + # create distribution directory + echo_eval tar -xzf cppad-$version.tgz + # + # change into distribution directory + echo_eval cd cppad-$version + # + echo "bin/autotools.sh configure >> $log_file" + bin/autotools.sh configure >> $log_dir/$log_file + # + # ---------------------------------------------------------------------- + echo_eval cd build + make_log="$log_dir/make_test.log" + # + # build and run all the tests + echo "make test >& make_test.log" + make test >& $make_log + # + if grep ': *warning: .*tmpnam.*is dangerous' $make_log > /dev/null + then + grep ': *warning: .*tmpnam.*is dangerous' $make_log | head -1 + fi + echo "cat make_test.log >> $log_file" + cat $make_log >> $log_dir/$log_file + # + sed -i $make_log -e '/: *warning: .*tmpnam.*is dangerous/d' + if grep ': *warning:' $make_log + then + echo "There are warnings in make_test.log" + exit 1 + fi + echo "rm make_test.log" + rm $make_log + # -------------------------------------------------------------------- + echo "date >> $log_file" + date >> $log_dir/$log_file + # + echo "OK: bin/autotools.sh test" + exit 0 fi -# ----------------------------------------------------------------------------- -if [ "$1" == "all" ] -then - list=" - version - automake - configure - dist - omhelp - doxygen - gpl - copy2doc - " - if [ "$version_type" != "trunk" ] - then - # only use the help built during the bin/autotools.sh dist command - list=`echo $list | sed -e 's|omhelp||'` - fi - echo "bin/autotools.sh $list" - bin/autotools.sh $list - echo "OK: bin/autotools.sh all" - exit 0 -fi -# ----------------------------------------------------------------------------- -if [ "$1" = "test" ] -then - log_dir=`pwd` - log_file="build_test.log" - # -------------------------------------------------------------- - # Things to do in the distribution directory - # -------------------------------------------------------------- - # - # start log for this test - echo "date > $log_file" - date > $log_dir/$log_file - # ---------------------------------------------------------------------- - # Things to do in the build directory - # ---------------------------------------------------------------------- - echo "cd build" - echo "cd build" >> $log_dir/$log_file - cd build - # - # erase old distribution directory - if [ -e cppad-$version ] - then - echo "rm -rf cppad-$version" - echo "rm -rf cppad-$version" >> $log_dir/$log_file - rm -rf cppad-$version - fi - # - # create distribution directory - echo "tar -xzf cppad-$version.epl.tgz" - echo "tar -xzf cppad-$version.epl.tgz" >> $log_dir/$log_file - tar -xzf cppad-$version.epl.tgz - # - # ---------------------------------------------------------------------- - # Things to do in the build/disribution directory - # ---------------------------------------------------------------------- - echo "cd cppad-$version" - echo "cd cppad-$version" >> $log_dir/$log_file - cd cppad-$version - # - # build_test_only configuration - echo "sed -i -e 's|^#_build_test_only:||' bin/autotools.sh" - sed -i -e 's|^#_build_test_only:||' bin/autotools.sh - # - echo "bin/autotools.sh configure >> $log_file" - bin/autotools.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 - # - # Developer documentation no longer works for autotools install - # test developer documentation - # echo "bin/autotools.sh doxygen >> $log_file" - # bin/autotools.sh doxygen >> $log_dir/$log_file - # - # ---------------------------------------------------------------------- - # Things to do in the build/disribution/build directory - # ---------------------------------------------------------------------- - echo "cd build" - echo "cd build" >> $log_dir/$log_file - cd build - # - 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 -#! /bin/bash -e -case "\$1" in - - OK) - grep OK $dir/make_test.log - exit 0 - ;; - - All) - grep All $dir/make_test.log - exit 0 - ;; - - tail) - tail $dir/make_test.log - exit 0 - ;; - - follow) - tail -f $dir/make_test.log - exit 0 - ;; - - file) - echo "$dir/make_test.log" - exit 0 - ;; - - *) - echo "usage: ../temp.sh option" - echo "where option is one of following: OK, All, tail, follow, file." - exit 1 -esac -EOF - chmod +x $log_dir/../temp.sh - # - # build and run all the tests - echo "make test >& make_test.log" - make test >& make_test.log - # - echo "rm ../temp.sh" - rm $log_dir/../temp.sh - # - echo "cat make_test.log >> $log_file" - cat make_test.log >> $log_dir/$log_file - # - # ignore warning in eigen (that has been reported) - if grep ': *warning:' make_test.log - then - echo "There are warnings in $dir/make_test.log" - exit 1 - fi - # -------------------------------------------------------------------- - echo "cd ../../.." - cd ../../.. - # end the build_test.log file with the date and time - echo "date >> $log_file" - date >> $log_dir/$log_file - # - echo "No errors or warnings found; see build_test.log." - # - echo "OK: bin/autotools.sh test" - exit 0 -fi -# ----------------------------------------------------------------------------- -# report bin/autotools.sh usage error -if [ "$1" != "" ] -then - echo "$1 is not a valid option" -fi -# -if [ "$version_type" == "trunk" ] -then - all_cases="run all the options above in order" -else - all_cases="run all the options above in order with exception of omhelp" -fi -cat << EOF -usage: bin/autotools.sh option_1 option_2 ... - -options requires -------- -------- -version: set version in AUTHORS, configure.ac, configure, ... -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 -doxygen: build developer documentation in doxydoc/*. configure -gpl: create build/*.gpl.zip and build/*.epl.zip. dist -copy2doc: copy logs, tarballs & doxygen output into doc directory. dist,doxygen - -all: $all_cases -test: use tarball to make test and put result in build_test.log. dist -EOF -# -exit 1 diff -Nru cppad-2018.00.00.0/bin/batch_edit.sh cppad-2019.02.00.0/bin/batch_edit.sh --- cppad-2018.00.00.0/bin/batch_edit.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/batch_edit.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,131 +0,0 @@ -#! /bin/bash -e -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. -# ----------------------------------------------------------------------------- -# Plan for batch edit of all files: -# 1. Do not update copyright date when do this edit -# 2. Remove an svn Id commands. -# 3. "included in the COPYING file" -> "included in the epl-v10.txt file" -# 4. Remove all omhelp index commands. -# 5. Change: $code $srcfile ...$$ $$ -> $srcfile ... $$ -# 6. Convert tabs to spaces. -# 7. Change CPPAD_TESTVECTOR to a template type (see Eigen entry in wishlist). -# 8. Change : B^n to \B{R}^n and other simuilar uses of B as a space. -# 9. Change Vector -> Vector for T = Base, Size, Bool (T != Set) -# ----------------------------------------------------------------------------- -spell_list=' -' -revert_list=' -' -move_list=' - cppad/core/reverse_subgraph.hpp - example/sparse/reverse_subgraph.cpp -' -move_sed='s|reverse_subgraph|subgraph_reverse|' -# -cat << EOF > junk.sed -s|reverse_subgraph|subgraph_reverse| -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 -# --------------------------------------------------------------------------- -list_all=`bin/ls_files.sh | sed \ - -e '/^compile$/d' \ - -e '/^config\.guess$/d' \ - -e '/^config\.sub$/d' \ - -e '/^configure$/d' \ - -e '/^depcomp$/d' \ - -e '/^epl-v10.txt$/d' \ - -e '/^gpl-v10.txt$/d' \ - -e '/^makefile.in$/d' \ - -e '/\/makefile.in$/d' \ - -e '/^missing$/d'` -edit_list='' -for file in $list_all -do - if [ "$file" != 'bin/batch_edit.sh' ] - then - sed -f junk.sed $file > junk.$$ - if ! diff $file junk.$$ > /dev/null - then - echo_eval sed -f junk.sed -i $file - edit_list="$edit_list $file" - fi - fi -done -if [ -e junk.$$ ] -then - rm junk.$$ -fi -# ---------------------------------------------------------------------------- -for word in $spell_list -do -# -cat << EOF > junk.sed -/\$spell\$/! b skip -:loop -/\$\\\$/b check -N -b loop -# -: check -/$word/b skip -s/\$spell/&\\n\\t$word/ -# -: skip -EOF - for file in $edit_list - do - echo_eval sed -f junk.sed -i $file - done -done -# ---------------------------------------------------------------------------- -for old in $move_list -do - new=`echo $old | sed -e "$move_sed"` - if [ -e "$new" ] - then - rm -r "$new" - fi - dir=`echo $new | sed -e 's|/[^/]*$||'` - if [ "$dir" != "$new" ] && [ ! -e "$dir" ] - then - echo_eval mkdir $dir - fi - 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 -# ---------------------------------------------------------------------------- -for file in $revert_list -do - echo_eval git checkout $file -done -# ---------------------------------------------------------------------------- -cp $HOME/trash/batch_edit.sh bin/batch_edit.sh -echo "$0: OK" -exit 0 diff -Nru cppad-2018.00.00.0/bin/check_addon.sh cppad-2019.02.00.0/bin/check_addon.sh --- cppad-2018.00.00.0/bin/check_addon.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_addon.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,56 +1,56 @@ #! /bin/bash -e -# $Id$ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ "$0" != 'bin/check_addon.sh' ] then - echo "bin/check_addon: must be executed from its parent directory" - exit 1 + echo "bin/check_addon: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- addon_list=' - CG - PY - TMB - MIXED + CG + PY + TMB + MIXED ' grep_cmd='' for addon in $addon_list do - if [ "$grep_cmd" == '' ] - then - grep_cmd="CPPAD_${addon}_" - else - grep_cmd="$grep_cmd|CPPAD_${addon}_" - fi + if [ "$grep_cmd" == '' ] + then + grep_cmd="CPPAD_${addon}_" + else + grep_cmd="$grep_cmd|CPPAD_${addon}_" + fi done # echo "Checking soruce code for names reserved for addon packages" echo "-------------------------------------------------------" ok="yes" -file_list=`bin/ls_files.sh` +file_list=`git ls-files` for file in $file_list do - if grep -E $grep_cmd $file > /dev/null - then - echo "$file containts $grep_cmd" - ok="no" - fi + if grep -E $grep_cmd $file > /dev/null + then + echo "$file containts $grep_cmd" + ok="no" + fi done echo "-------------------------------------------------------" if [ "$ok" = "no" ] then - echo 'bin/check_if.sh: Error' - exit 1 + echo 'bin/check_if.sh: Error' + exit 1 else - echo 'bin/check_if.sh: OK' - exit 0 + echo 'bin/check_if.sh: OK' + exit 0 fi diff -Nru cppad-2018.00.00.0/bin/check_all.sh cppad-2019.02.00.0/bin/check_all.sh --- cppad-2018.00.00.0/bin/check_all.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_all.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,194 +1,282 @@ #! /bin/bash -e # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ "$0" != 'bin/check_all.sh' ] then - echo "bin/check_all.sh: must be executed from its parent directory" - exit 1 + echo "bin/check_all.sh: must be executed from its parent directory" + exit 1 fi debug_all='no' if [ "$1" != '' ] then - debug_all='yes' - if [ "$1" != 'debug_all' ] - then - echo 'usage: bin/check_all.sh [debug_all]' - exit 1 - fi + debug_all='yes' + if [ "$1" != 'debug_all' ] + then + echo 'usage: bin/check_all.sh [debug_all]' + exit 1 + fi fi +# ----------------------------------------------------------------------------- +# bash function that echos and executes a command +echo_eval() { + echo $* + eval $* +} +# ----------------------------------------------------------------------------- +check_all_warn() { +cat << EOF > check_all.$$ +# Lines that describe where error is +/^In file included from/d +/: note:/d +# +# Ipopt has sign conversion warnings +/\/coin\/.*-Wsign-conversion/d +# +# Adolc has multiple types of conversion warnings +/\/adolc\/.*-W[a-z-]*conversion/d +/\/adolc\/.*-Wshorten-64-to-32/d +# +# Lines describing the error begin with space +/^ /d +# +# Lines summarizing results +/^[0-9]* warnings generated/d +EOF + sed $top_srcdir/check_all.err -f check_all.$$ > $top_srcdir/check_all.warn + rm check_all.$$ +} +# ----------------------------------------------------------------------------- echo_log_eval() { - echo $* - echo $* >> $top_srcdir/check_all.log - echo $* > $top_srcdir/check_all.err - if ! eval $* >> $top_srcdir/check_all.log 2>> $top_srcdir/check_all.err - then - cat $top_srcdir/check_all.err - echo 'Error: see check_all.log' - exit 1 - fi - count=`wc -l $top_srcdir/check_all.err | sed -e 's|\([0-9]*\) .*|\1|'` - if [ "$count" != '1' ] - then - cat "$top_srcdir/check_all.err" - echo 'Warning: see check_all.err' - exit 1 - fi - rm $top_srcdir/check_all.err -} -log_eval() { - echo $* >> $top_srcdir/check_all.log - if ! eval $* >> $top_srcdir/check_all.log - then - echo "Error: check check_all.log" - exit 1 - fi + echo $* + echo $* >> $top_srcdir/check_all.log + if ! eval $* >> $top_srcdir/check_all.log 2> $top_srcdir/check_all.err + then + tail $top_srcdir/check_all.err + echo 'Error: see check_all.err, check_all.log' + exit 1 + fi + check_all_warn + count=`wc -l $top_srcdir/check_all.warn | sed -e 's|^\([0-9]*\) .*|\1|'` + if [ "$count" != '0' ] + then + head "$top_srcdir/check_all.warn" + echo 'Warning: see check_all.warn, check_all.log' + exit 1 + fi + rm $top_srcdir/check_all.warn $top_srcdir/check_all.err } -if [ -e check_all.log ] -then - echo "rm check_all.log" - rm check_all.log -fi +echo_log() { + echo $* + echo $* >> $top_srcdir/check_all.log +} +random_01() { + set +e + eval random_01_$1="`expr $RANDOM % 2`" + set -e +} +# ----------------------------------------------------------------------------- +# start new check_all.log +date > check_all.log 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() { - program_list=`echo "$program_list" | sed -e 's| *\([^ ]*\) *\(.*\)|\2 \1|'` - program=`echo "$program_list" | sed -e 's| *\([^ ]*\).*|\1|'` + program_list=`echo "$program_list" | sed -e 's| *\([^ ]*\) *\(.*\)|\2 \1|'` + program=`echo "$program_list" | sed -e 's| *\([^ ]*\).*|\1|'` } # --------------------------------------------------------------------------- if [ -e "$HOME/prefix/cppad" ] then - echo_log_eval rm -r $HOME/prefix/cppad + echo_log_eval rm -r $HOME/prefix/cppad fi # --------------------------------------------------------------------------- +version=`version.sh get` +tarball="cppad-$version.tgz" +# --------------------------------------------------------------------------- +random_01 compiler +if [ "$random_01_compiler" == '0' ] +then + compiler='default' +else + compiler='--clang' +fi +random_01 standard +if [ "$random_01_standard" == '0' ] +then + standard='--c++98 --no_adolc --no_sacado' +else + standard='--c++11' +fi +# +if [ "$debug_all" == 'yes' ] +then + package_vector='--cppad_vector' + debug_which='--debug_all' +else + random_01 debug_which + if [ "$random_01_debug_which" == '0' ] + then + debug_which='--debug_even' + else + debug_which='--debug_odd' + fi + # + random_01 package_vector + if [ "$random_01_package_vector" == '0' ] + then + package_vector='--boost_vector' + else + package_vector='--eigen_vector' + fi +fi +cat << EOF +tarball = $tarball +compiler = $compiler +standard = $standard +debug_which = $debug_which +package_vector = $package_vector +EOF +cat << EOF >> $top_srcdir/check_all.log +tarball = $tarball +compiler = $compiler +standard = $standard +debug_which = $debug_which +package_vector = $package_vector +EOF +if [ "$compiler" == 'default' ] +then + compiler='' +fi +if [ "$standard" == '--c++11' ] +then + standard='' # default for run_cmake.sh +fi +# --------------------------------------------------------------------------- +# Run automated checks for the form bin/check_*.sh with a few exceptions. +list=`ls bin/check_* | sed \ + -e '/check_all.sh/d' \ + -e '/check_jenkins.sh/d' \ + -e '/check_svn_dist.sh/d'` +# ~/devel/check_copyright.sh not included in batch_edit branch +for check in $list +do + echo_log_eval $check +done +# --------------------------------------------------------------------------- # Create package to run test in -echo "bin/package.sh" -bin/package.sh +echo_log_eval bin/package.sh # ----------------------------------------------------------------------------- # choose which tarball to use for testing -skip='' -version=`bin/version.sh get` echo_log_eval cd build -list=( `ls cppad-$version.*.tgz` ) -if [ "${#list[@]}" == '1' ] -then - tarball="${list[0]}" - skip="$skip other_tarball" -else - tarball="${list[$random_zero_one]}" -fi echo_log_eval rm -rf cppad-$version echo_log_eval tar -xzf $tarball echo_log_eval cd cppad-$version # ----------------------------------------------------------------------------- -if [ "$debug_all" == 'yes' ] -then - echo_log_eval bin/run_cmake.sh --cppad_vector --debug_all -elif [ "$random_zero_one" == '0' ] -then - echo_log_eval bin/run_cmake.sh --boost_vector --debug_odd -else - echo_log_eval bin/run_cmake.sh --eigen_vector --debug_even -fi +echo_log_eval bin/run_cmake.sh $compiler $standard $debug_which $package_vector echo_log_eval cd build # ----------------------------------------------------------------------------- echo_log_eval make check # ----------------------------------------------------------------------------- +skip='' for package in adolc eigen ipopt fadbad sacado do - dir=$HOME/prefix/$package - if [ ! -d "$dir" ] - then - skip="$skip $package" - fi + dir=$HOME/prefix/$package + if [ ! -d "$dir" ] + then + skip="$skip $package" + elif echo $standard | grep "no_$package" > /dev/null + then + skip="$skip $package" + fi done # # extra speed tests not run with option specified for option in onetape colpack optimize atomic memory boolsparsity do - echo_eval speed/cppad/speed_cppad correct 432 $option + echo_eval speed/cppad/speed_cppad correct 432 $option done -echo_eval speed/adolc/speed_adolc correct 432 onetape -echo_eval speed/adolc/speed_adolc sparse_jacobian 432 onetape colpack -echo_eval speed/adolc/speed_adolc sparse_hessian 432 onetape colpack +if ! echo "$skip" | grep 'adolc' > /dev/null +then + echo_eval speed/adolc/speed_adolc correct 432 onetape + echo_eval speed/adolc/speed_adolc sparse_jacobian 432 onetape colpack + echo_eval speed/adolc/speed_adolc sparse_hessian 432 onetape colpack +fi # # ---------------------------------------------------------------------------- # extra multi_thread tests program_list='' for threading in bthread openmp pthread do - program="example/multi_thread/${threading}" - program="$program/example_multi_thread_${threading}" - if [ ! -e $program ] - then - skip="$skip $program" - else - program_list="$program_list $program" - # - # fast cases, test for all programs - echo_log_eval ./$program a11c - echo_log_eval ./$program simple_ad - echo_log_eval ./$program team_example - fi + program="example/multi_thread/${threading}" + program="$program/example_multi_thread_${threading}" + if [ ! -e $program ] + then + skip="$skip $program" + else + program_list="$program_list $program" + # + # fast cases, test for all programs + echo_log_eval ./$program a11c + echo_log_eval ./$program simple_ad + echo_log_eval ./$program team_example + fi done if [ "$program_list" != '' ] then - # test_time=1,max_thread=4,mega_sum=1 - next_program - echo_log_eval ./$program harmonic 1 4 1 - # - # test_time=1,max_thread=4,num_solve=100 - next_program - echo_log_eval ./$program multi_atomic 1 4 100 - # - # test_time=2,max_thread=4,num_zero=20,num_sub=30,num_sum=50,use_ad=true - next_program - echo_log_eval ./$program multi_newton 2 4 20 30 50 true - # + # test_time=1,max_thread=4,mega_sum=1 + next_program + echo_log_eval ./$program harmonic 1 4 1 + # + # test_time=1,max_thread=4,num_solve=100 + next_program + echo_log_eval ./$program multi_atomic 1 4 100 + # + # test_time=1,max_thread=4,num_solve=100 + next_program + echo_log_eval ./$program checkpoint 1 4 100 + # + # test_time=2,max_thread=4,num_zero=20,num_sub=30,num_sum=50,use_ad=true + next_program + echo_log_eval ./$program multi_newton 2 4 20 30 50 true + # fi # # print_for test program='example/print_for/example_print_for' if [ ! -e "$program" ] then - skip="$skip $program" + skip="$skip $program" else - echo_log_eval $program - $program | sed -e '/^Test passes/,$d' > junk.1.$$ - $program | 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" - else - echo_log_eval echo "print_for: Error" - exit 1 - fi + echo_log_eval $program + $program | sed -e '/^Test passes/,$d' > junk.1.$$ + $program | 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" + else + echo_log_eval echo "print_for: Error" + exit 1 + fi fi # echo_log_eval make install # +date >> $top_srcdir/check_all.log if [ "$skip" != '' ] then - echo_log_eval echo "check_all.sh: skip = $skip" - exit 1 + echo_log_eval echo "check_all.sh: skip = $skip" + exit 1 fi # ---------------------------------------------------------------------------- echo "$0: OK" >> $top_srcdir/check_all.log diff -Nru cppad-2018.00.00.0/bin/check_copyright.sh cppad-2019.02.00.0/bin/check_copyright.sh --- cppad-2018.00.00.0/bin/check_copyright.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_copyright.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -#! /bin/bash -e -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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' \ - -e '/^.gitignore$/d' \ - -e '/^authors$/d' \ - -e '/^readme.md$/d' \ - -e '/^COPYING$/d' \ - -e '/^compile$/d' \ - -e '/^config.guess$/d' \ - -e '/^config.sub$/d' \ - -e '/^configure$/d' \ - -e '/\/check_copyright.sh$/d' \ - -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-17 Bradley M. Bell/ -s/Copyright (C) \\([0-9]*\\)-20[0-9][0-9] Bradley M. Bell/Copyright (C) \\1-17 Bradley M. Bell/ -EOF -ok=true -for file in $list -do - if [ -e $file ] - then - if ! grep 'Copyright (C) [0-9]*-[0-9][0-9]' $file > /dev/null - then - echo "Cannot find copyright message in $file" - exit 1 - fi - 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-2018.00.00.0/bin/check_define.sh cppad-2019.02.00.0/bin/check_define.sh --- cppad-2018.00.00.0/bin/check_define.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_define.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,70 +1,88 @@ #! /bin/bash -e -# $Id: check_define.sh 3783 2016-01-21 20:14:22Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- -if [ $0 != "bin/check_define.sh" ] +if [ $0 != 'bin/check_define.sh' ] then - echo "bin/check_define.sh: must be executed from its parent directory" - exit 1 + echo 'bin/check_define.sh: must be executed from its parent directory' + exit 1 fi +for temp_file in check_define.1 check_define.2 check_define.3 +do + if [ -e $temp_file ] + then + echo "bin/check_define.sh: $temp_file exists" + exit 0 + fi +done # ----------------------------------------------------------------------------- -echo "Check '# define' versus '# undef' names and check for addon names" +echo 'Check '# define' versus '# undef' names and check for addon names' echo '-----------------------------------------------------------------------' -cmd_list='define undef' +file_list=`git ls-files '*.hpp' '*.in' | + sed -n -e '/^include\/cppad\//p'` add_on_list='CG PY TMB MIXED' -file_list=`bin/ls_files.sh | sed -n \ - -e '/^cppad\/.*\.hpp$/p' \ - -e '/^cppad\/.*\.hpp\.in$/p'` # -add_on_error='false' +# preprocessor symbol that may or may not be defined by user +echo 'CPPAD_DEBUG_AND_RELEASE' > check_define.1 +# for file in $file_list do - for cmd in $cmd_list - do - if [ ! -e $file.in ] - then - sed -n -e "/^# *$cmd /p" $file | \ - sed -e "s/^# *$cmd *\([A-Za-z0-9_]*\).*/\1/" >> tmp.$$ - fi - if [ "$cmd" == 'define' ] - then - sed -e '/_HPP$/d' -i tmp.$$ - fi - sort -u tmp.$$ > $cmd.$$ - rm tmp.$$ - done - for add_on in $add_on_list - do - if grep "CPPAD_${add_on}_" $file - then - add_on_error='true' - fi - done + include_guard=`echo $file | sed \ + -e 's|^include/||' \ + -e 's|\.in||' \ + -e 's|/|_|g' \ + -e 's|\.hpp|_hpp|' \ + | tr [a-z] [A-Z] + ` + # define + if [ ! -e $file.in ] + then + sed -n -e "/^# *define /p" $file | sed \ + -e "/^# *define *$include_guard/d" \ + -e '/^# define NOMINMAX/d' \ + -e "s/^# *define *\([A-Za-z0-9_]*\).*/\1/" >> check_define.1 + fi + # undef + if [ ! -e $file.in ] + then + sed -n -e "/^# *undef /p" $file | sed \ + -e "s/^# *undef *\([A-Za-z0-9_]*\).*/\1/" >> check_define.2 + fi + # add_on + for add_on in $add_on_list + do + if grep "CPPAD_${add_on}_" $file + then + add_on_error='true' + fi + done done -if [ "$add_on_error" == 'true' ] +# sort lists +for file in check_define.1 check_define.2 +do + sort -u $file > check_define.3 + mv check_define.3 $file +done +if ! diff check_define.1 check_define.2 then -echo '-----------------------------------------------------------------------' - echo 'check_define.sh: Error: add_on preprocessor symbol found' - rm undef.$$ - rm define.$$ - exit 1 + echo 'check_define.sh: Error: defines and undefs do not match' + rm check_define.1 check_define.2 + exit 1 fi -if ! diff define.$$ undef.$$ +rm check_define.1 check_define.2 +echo '-----------------------------------------------------------------------' +if [ "$add_on_error" == 'true' ] then - echo 'check_define.sh: Error: defines and undefs do not match' - rm undef.$$ - rm define.$$ - exit 1 + echo 'check_define.sh: Error: add_on preprocessor symbol found' + exit 1 fi -echo '-----------------------------------------------------------------------' -rm undef.$$ -rm define.$$ +echo 'check_define.sh: OK' exit 0 diff -Nru cppad-2018.00.00.0/bin/check_deprecated.sh cppad-2019.02.00.0/bin/check_deprecated.sh --- cppad-2018.00.00.0/bin/check_deprecated.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_deprecated.sh 2019-01-31 12:35:17.000000000 +0000 @@ -2,64 +2,65 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { - echo $* - eval $* + echo $* + eval $* } # ----------------------------------------------------------------------------- if [ "$0" != "bin/check_deprecated.sh" ] then - echo "bin/check_deprecated.sh: must be executed from its parent directory" - exit 1 + echo "bin/check_deprecated.sh: must be executed from its parent directory" + exit 1 fi if [ "$#" != '0' ] then - echo 'usage: bin/check_deprecated.sh.sh' - exit 1 + echo 'usage: bin/check_deprecated.sh.sh' + exit 1 fi # ----------------------------------------------------------------------------- file_list=`git ls-files example speed | sed -e '/example\/deprecated\//d'` # ----------------------------------------------------------------------------- # deprecated functions with not arugments list_just_name=' - CPPAD_TRACK_ - CPPAD_TEST_VECTOR - CppADCreateUnaryBool - CppADCreateDiscrete - zdouble - colpack.star + CPPAD_TRACK_ + CPPAD_TEST_VECTOR + CppADCreateUnaryBool + CppADCreateDiscrete + zdouble + colpack.star ' list_namespace=' - omp_alloc - cppad_ipopt + omp_alloc + cppad_ipopt ' template_name=' - epsilon + epsilon ' list_no_argument=' - Order - Memory - Size - taylor_size - use_VecAD - size_taylor - capacity_taylor - CompareChange - memory_leak + Order + Memory + Size + taylor_size + use_VecAD + size_taylor + capacity_taylor + CompareChange + memory_leak ' list_one_argument=' - nan - Dependent - omp_max_thread - memory_leak + nan + Dependent + omp_max_thread + memory_leak ' list_two_argument=' ' @@ -67,71 +68,71 @@ ' for file in $file_list do - for name in $list_just_name - do - if grep "$name" $file > /dev/null - then - echo "$name is deprecated and appreas in $file" - exit 1 - fi - done - for name in $list_namespace - do - if grep "[^a-zA-Z_]$name::" $file > /dev/null - then - echo "$name:: is deprecated and appreas in $file" - exit 1 - fi - done - for name in $list_namespace - do - if grep "using *$name[^a-zA-Z_]" $file > /dev/null - then - echo "using $name is deprecated and appreas in $file" - exit 1 - fi - done - for name in $template_name - do - if grep "[^a-zA-Z_]$name *< *[a-zA-Z_][a-zA-Z_]* *>" $file > /dev/null - then - echo "$name is deprecated and appreas in $file" - exit 1 - fi - done - for fun in $list_no_argument - do - if grep "[^a-zA-Z_]$fun *( *)" $file > /dev/null - then - echo "$fun() is deprecated and appreas in $file" - exit 1 - fi - done - for fun in $list_one_argument - do - if sed -e "s|bool *$fun(void)||" $file | \ - grep "[^a-zA-Z_]$fun *( *[a-zA-Z_0-9.][a-zA-Z_0-9.]* *)" > /dev/null - then - echo "$fun(arg1) is deprecated and appreas in $file" - exit 1 - fi - done - for fun in $list_two_argument - do - if grep "[^a-zA-Z_]$fun *([^,)]*,[^,)]*)" $file > /dev/null - then - echo "$fun(arg1,arg2) is deprecated and appreas in $file" - exit 1 - fi - done - for fun in $list_three_argument - do - if grep "[^a-zA-Z_]$fun *([^,)]*,[^,)]*,[^,)]*)" $file > /dev/null - then - echo "$fun(arg1,arg2,arg3) is deprecated and appreas in $file" - exit 1 - fi - done + for name in $list_just_name + do + if grep "$name" $file > /dev/null + then + echo "$name is deprecated and appreas in $file" + exit 1 + fi + done + for name in $list_namespace + do + if grep "[^a-zA-Z_]$name::" $file > /dev/null + then + echo "$name:: is deprecated and appreas in $file" + exit 1 + fi + done + for name in $list_namespace + do + if grep "using *$name[^a-zA-Z_]" $file > /dev/null + then + echo "using $name is deprecated and appreas in $file" + exit 1 + fi + done + for name in $template_name + do + if grep "[^a-zA-Z_]$name *< *[a-zA-Z_][a-zA-Z_]* *>" $file > /dev/null + then + echo "$name is deprecated and appreas in $file" + exit 1 + fi + done + for fun in $list_no_argument + do + if grep "[^a-zA-Z_]$fun *( *)" $file > /dev/null + then + echo "$fun() is deprecated and appreas in $file" + exit 1 + fi + done + for fun in $list_one_argument + do + if sed -e "s|bool *$fun(void)||" $file | \ + grep "[^a-zA-Z_]$fun *( *[a-zA-Z_0-9.][a-zA-Z_0-9.]* *)" > /dev/null + then + echo "$fun(arg1) is deprecated and appreas in $file" + exit 1 + fi + done + for fun in $list_two_argument + do + if grep "[^a-zA-Z_]$fun *([^,)]*,[^,)]*)" $file > /dev/null + then + echo "$fun(arg1,arg2) is deprecated and appreas in $file" + exit 1 + fi + done + for fun in $list_three_argument + do + if grep "[^a-zA-Z_]$fun *([^,)]*,[^,)]*,[^,)]*)" $file > /dev/null + then + echo "$fun(arg1,arg2,arg3) is deprecated and appreas in $file" + exit 1 + fi + done done # ----------------------------------------------------------------------------- echo 'bin/check_deprecated.sh: OK' diff -Nru cppad-2018.00.00.0/bin/check_doxygen.sh cppad-2019.02.00.0/bin/check_doxygen.sh --- cppad-2018.00.00.0/bin/check_doxygen.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_doxygen.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,25 @@ #! /bin/bash -e -# $Id: check_doxygen.sh 3853 2016-12-14 14:40:11Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ ! -e "bin/check_doxygen.sh" ] then - echo "bin/check_doxygen.sh: must be executed from its parent directory" - exit 1 + echo "bin/check_doxygen.sh: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- if ! bin/run_doxygen.sh then - echo 'check_doxygen.sh: Error' - exit 1 + echo 'check_doxygen.sh: Error' + exit 1 fi echo 'check_doxygen.sh: OK' exit 0 diff -Nru cppad-2018.00.00.0/bin/check_example.sh cppad-2019.02.00.0/bin/check_example.sh --- cppad-2018.00.00.0/bin/check_example.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_example.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,61 +1,62 @@ #! /bin/bash -e # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ ! -e "bin/check_example.sh" ] then - echo "bin/check_example.sh: must be executed from its parent directory" - exit 1 + echo "bin/check_example.sh: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- echo "Checking that all examples are in omh/example_list.omh" echo "-------------------------------------------------------" -file_list=`bin/ls_files.sh | sed -n \ - -e '/^example\/deprecated\//d' \ - -e '/^example\//p'` +file_list=`git ls-files | sed -n \ + -e '/^example\/deprecated\//d' \ + -e '/^example\//p'` # sed < omh/example_list.omh > check_example.$$ \ - -n -e '/\$begin ListAllExamples\$\$/,/\$end/p' + -n -e '/\$begin ListAllExamples\$\$/,/\$end/p' # # Make sure all example names are of the form *.cpp or *.hpp check=`sed -n -e '/$rref [0-9a-zA-Z_]*\.[hc]pp/d' \ - -e '/$rref/p' check_example.$$` + -e '/$rref/p' check_example.$$` if [ "$check" != '' ] then - echo $check - echo 'Not all examples are for *.hpp or *.cpp files' - exit 1 + echo $check + echo 'Not all examples are for *.hpp or *.cpp files' + exit 1 fi ok="yes" for file in $file_list do - # only files in example directory with $begin *.cpp or *.hpp - # e.g., example/multi_thread/harmonic.omh has $begin harmonic.cpp$$ in it - name=`grep '$begin *[0-9a-zA-Z_]*\.[hc]pp' $file | - sed -e 's/.*$begin *//' -e 's/ *$$.*//'` - if [ "$name" != "" ] - then - if ! grep "$name" check_example.$$ > /dev/null - then - echo "$name is missing from omh/example_list.omh" - ok="no" - fi - fi + # only files in example directory with $begin *.cpp or *.hpp + # e.g., example/multi_thread/harmonic.omh has $begin harmonic.cpp$$ in it + name=`grep '$begin *[0-9a-zA-Z_]*\.[hc]pp' $file | + sed -e 's/.*$begin *//' -e 's/ *$$.*//'` + if [ "$name" != "" ] + then + if ! grep "$name" check_example.$$ > /dev/null + then + echo "$name is missing from omh/example_list.omh" + ok="no" + fi + fi done rm check_example.$$ echo "-------------------------------------------------------" if [ "$ok" = "yes" ] then - echo "Ok: nothing is between the two dashed lines above" + echo "Ok: nothing is between the two dashed lines above" exit 0 else - echo "Error: nothing should be between the two dashed lines above" - exit 1 + echo "Error: nothing should be between the two dashed lines above" + exit 1 fi diff -Nru cppad-2018.00.00.0/bin/check_if.sh cppad-2019.02.00.0/bin/check_if.sh --- cppad-2018.00.00.0/bin/check_if.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_if.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,19 @@ #! /bin/bash -e -# $Id: check_if.sh 3781 2016-01-18 16:16:22Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ "$0" != 'bin/check_if.sh' ] then - echo "bin/check_if: must be executed from its parent directory" - exit 1 + echo "bin/check_if: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- # CppAD uses preprocessor '# if 0' comment blocks for temporary changes @@ -21,31 +21,31 @@ echo "Checking for '# if 0' and '# if NDEBUG' commands in source code" echo "-------------------------------------------------------" ok="yes" -list=`bin/ls_files.sh | sed -n \ - -e '/\.cpp$/p' \ - -e '/\.hpp$/p' \ - -e '/\.hpp.in$/p'` +list=`git ls-files | sed -n \ + -e '/\.cpp$/p' \ + -e '/\.hpp$/p' \ + -e '/\.hpp.in$/p'` for file in $list do - if grep '^# *if *0 *$' $file > /dev/null - then - # CppAD uses /* comment */ for all its block commnets - echo "$file has an '# if 0' preprocessor command" - ok="no" - fi - if grep '^# *if *NDEBUG *$' $file > /dev/null - then - # This should probably be # ifndef NDEBUG ? - echo "$file has an '# if NDEBUG' preprocessor command" - ok="no" - fi + if grep '^# *if *0 *$' $file > /dev/null + then + # CppAD uses /* comment */ for all its block commnets + echo "$file has an '# if 0' preprocessor command" + ok="no" + fi + if grep '^# *if *NDEBUG *$' $file > /dev/null + then + # This should probably be # ifndef NDEBUG ? + echo "$file has an '# if NDEBUG' preprocessor command" + ok="no" + fi done echo "-------------------------------------------------------" if [ "$ok" = "no" ] then - echo 'bin/check_if.sh: Error' - exit 1 + echo 'bin/check_if.sh: Error' + exit 1 else - echo 'bin/check_if.sh: OK' - exit 0 + echo 'bin/check_if.sh: OK' + exit 0 fi diff -Nru cppad-2018.00.00.0/bin/check_include_def.sh cppad-2019.02.00.0/bin/check_include_def.sh --- cppad-2018.00.00.0/bin/check_include_def.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_include_def.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,55 +1,57 @@ #! /bin/bash -e -# $Id: check_include_def.sh 3826 2016-07-17 15:25:25Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ ! -e "bin/check_include_def.sh" ] then - echo "bin/check_include_def.sh: must be executed from its parent directory" - exit 1 + echo "bin/check_include_def.sh: must be executed from its parent directory" + exit 1 fi # --------------------------------------------------------------------------- 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/ls_files.sh | sed -n -e '/^cppad\/deprecated\//d' -e '/\.hpp$/p'` +list=`git ls-files | sed -n -e '/\.hpp$/p'` different='no' for file_name in $list do - dir=`echo $file_name | sed -e 's|/[^/]*$||'` - name=`echo $file_name | sed -e 's|^.*/||'` - first_dir=`echo $dir | sed -e 's|/.*||'` - # - macro_name=`sed -n -e '/^# *ifndef *CPPAD_[0-9A-Z_]*_HPP$/p' $file_name | \ - sed -e 's|^# *ifndef *||'` - check=`echo $file_name | tr [a-zA-Z/.] [A-Za-z__]` - # - if [ "$first_dir" != 'cppad' ] - then - check="CPPAD_$check" - fi - # - if [ "$macro_name" != "$check" ] - then - echo " file_name=$file_name" - echo "macro_name=$macro_name" - different='yes' - fi + dir=`echo $file_name | sed -e 's|/[^/]*$||'` + name=`echo $file_name | sed -e 's|^.*/||'` + first_dir=`echo $dir | sed -e 's|/.*||'` + # + macro_name=`sed -n -e '/^# *ifndef *CPPAD_[0-9A-Z_]*_HPP$/p' $file_name | \ + sed -e 's|^# *ifndef *||'` + check=`echo $file_name | tr [a-zA-Z/.] [A-Za-z__]` + # + if [ "$first_dir" == 'include' ] + then + check=`echo $check | sed -e 's|INCLUDE_||'` + else + check="CPPAD_$check" + fi + # + if [ "$macro_name" != "$check" ] + then + echo " file_name=$file_name" + echo "macro_name=$macro_name" + different='yes' + fi done # echo "-------------------------------------------------------------------" if [ $different = 'yes' ] then - echo "Error: nothing should be between the two dashed lines above" - exit 1 + echo "Error: nothing should be between the two dashed lines above" + exit 1 else - echo "Ok: nothing is between the two dashed lines above" - exit 0 + echo "Ok: nothing is between the two dashed lines above" + exit 0 fi diff -Nru cppad-2018.00.00.0/bin/check_include_file.sh cppad-2019.02.00.0/bin/check_include_file.sh --- cppad-2018.00.00.0/bin/check_include_file.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_include_file.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ #! /bin/bash -e # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ ! -e "bin/check_include_file.sh" ] then - msg="must be executed from its parent directory" - echo "bin/check_include_file.sh: $msg" - exit 1 + msg="must be executed from its parent directory" + echo "bin/check_include_file.sh: $msg" + exit 1 fi # ----------------------------------------------------------------------------- # @@ -21,79 +22,81 @@ echo "-------------------------------------------------------------------" if [ -e check_include_file.1.$$ ] then - echo "bin/check_include_file.sh: unexpected check_include_file.1.$$" - exit 1 + echo "bin/check_include_file.sh: unexpected check_include_file.1.$$" + exit 1 fi -list=`bin/ls_files.sh | sed -n \ - -e '/\.cpp$/p' \ - -e '/\.hpp$/p'` +list=`git ls-files | sed -n \ + -e '/\.cpp$/p' \ + -e '/\.hpp$/p'` for file in $list do - sed -n -e '/^# *include *> check_include_file.1.$$ + sed -n -e '/^# *include *> check_include_file.1.$$ done # cat check_include_file.1.$$ | \ - sed -e 's%[^<]*<%%' -e 's%>.*$%%' | \ - sort -u > check_include_file.2.$$ + sed -e 's%[^<]*<%%' -e 's%>.*$%%' | \ + sort -u > check_include_file.2.$$ # # The following files should never be included: -# cppad/local/prototype_op.hpp -# cppad/local/optimize/define_prototype.hpp +# cppad/local/prototype_op.hpp +# cppad/local/optimize/define_prototype.hpp # All other files should. # # The files cppad/configure.hpp and cppad/local/is_pod.hpp -# are not in git repository (build during configuration) -bin/ls_files.sh | sed -n -e '/cppad\/.*\.hpp$/p' | \ - sed \ - -e '1,1s|^|cppad/configure.hpp\n|' \ - -e '1,1s|^|cppad/local/is_pod.hpp\n|' \ - -e '/cppad\/local\/prototype_op.hpp/d' \ - -e '/cppad\/local\/optimize\/define_prototype.hpp/d' \ - -e '/cppad\/example\/eigen_plugin.hpp/d' | \ - sort -u > check_include_file.3.$$ +# are not in git repository (they are built during configuration) +git ls-files | sed -n -e '/include\/cppad\/.*\.hpp$/p' | \ + sed \ + -e '1,1s|^|include/cppad/configure.hpp\n|' \ + -e '1,1s|^|include/cppad/local/is_pod.hpp\n|' \ + -e '/include\/cppad\/local\/prototype_op.hpp/d' \ + -e '/include\/cppad\/local\/optimize\/define_prototype.hpp/d' \ + -e '/include\/cppad\/example\/eigen_plugin.hpp/d' | \ + sed -e 's|^include/||' | \ + sort -u > check_include_file.3.$$ # different='no' if ! diff check_include_file.2.$$ check_include_file.3.$$ > /dev/null then - found='no' - different='yes' - for file in `cat check_include_file.2.$$` - do - if ! grep "$file" check_include_file.3.$$ > /dev/null - then - found='yes' - echo "The included file $file is unknown to git." - echo 'Perhaps it needs to be added ?' - fi - done - for file in `cat check_include_file.3.$$` - do - if ! grep "$file" check_include_file.2.$$ > /dev/null - then - found='yes' - echo "The included $file is no longer included." - echo 'Perhaps it needs to be git deleted ?' - fi - done - if [ "$found" == 'no' ] - then - echo 'bin/check_include_file.sh: Cannot find reason for difference' - echo 'Improve this script.' - exit 1 - fi + found='no' + different='yes' + for file in `cat check_include_file.2.$$` + do + if ! grep "$file" check_include_file.3.$$ > /dev/null + then + found='yes' + echo "The file include/$file is unknown to git." + echo 'Perhaps it needs to be added with the command' + echo " git add include/$file" + fi + done + for file in `cat check_include_file.3.$$` + do + if ! grep "$file" check_include_file.2.$$ > /dev/null + then + found='yes' + echo "The included $file is no longer included." + echo 'Perhaps it needs to be git deleted ?' + fi + done + if [ "$found" == 'no' ] + then + echo 'bin/check_include_file.sh: Cannot find reason for difference' + echo 'Improve this script.' + exit 1 + fi fi for index in 1 2 3 do - rm check_include_file.$index.$$ + rm check_include_file.$index.$$ done # echo "-------------------------------------------------------------------" if [ $different = "yes" ] then - echo "Error: nothing should be between the two dashed lines above" - exit 1 + echo "Error: nothing should be between the two dashed lines above" + exit 1 else - echo "Ok: nothing is between the two dashed lines above" - exit 0 + echo "Ok: nothing is between the two dashed lines above" + exit 0 fi diff -Nru cppad-2018.00.00.0/bin/check_jenkins.sh cppad-2019.02.00.0/bin/check_jenkins.sh --- cppad-2018.00.00.0/bin/check_jenkins.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_jenkins.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -#! /bin/bash -e -# $Id: check_jenkins.sh 3788 2016-02-09 15:50:06Z bradbell $ -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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/check_jenkins.sh" ] -then - echo "bin/check_jenkins.sh: must be executed from its parent directory" - exit 1 -fi -# ----------------------------------------------------------------------------- -# bash function that echos and executes a command -echo_eval() { - echo $* - eval $* -} -# ----------------------------------------------------------------------------- -repository="https://projects.coin-or.org/svn/CppAD" -if [ ! -e build ] -then - echo_eval mkdir build -fi -echo_eval cd build -# ---------------------------------------------------------------------------- -if [ ! -e 'jenkins' ] -then - echo_eval svn checkout $repository/trunk jenkins -fi -echo_eval cd jenkins -echo_eval svn update -# ---------------------------------------------------------------------------- -echo_eval bin/jenkins.sh -# ---------------------------------------------------------------------------- -echo "$0: OK" -exit 0 diff -Nru cppad-2018.00.00.0/bin/check_makefile.sh cppad-2019.02.00.0/bin/check_makefile.sh --- cppad-2018.00.00.0/bin/check_makefile.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_makefile.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ -#! /bin/bash -e -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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/check_makefile.sh" ] -then - echo "bin/check_makefile.sh: must be executed from its parent directory" - exit 1 -fi -# ----------------------------------------------------------------------------- -echo 'Checking if any makfile.in has changed' -bin/autotools.sh automake >& /dev/null -list=`git ls-files '*/makefile.in'` -ok='yes' -for file in $list -do - diff=`git diff -- $file` - if [ "$diff" != '' ] - then - echo "git add $file" - git add $file - ok='no' - fi -done -if [ "$ok" == 'no' ] -then - echo '*/makefile.in has changed.' - exit 1 -fi -# ----------------------------------------------------------------------------- -echo "Checking include files listed in makefile.am" -echo "-------------------------------------------------------" -bin/ls_files.sh | sed -n -e '/cppad\/.*\.hpp$/p' \ - > check_makefile.1.$$ -sort -u check_makefile.1.$$ > check_makefile.2.$$ -# -sed < makefile.am -n \ - -e '/^nobase_myinclude_HEADERS *=/,/^# End nobase_myinclude_HEADERS/p' | \ - sed \ - -e '/nobase_myinclude_HEADERS/d' \ - -e 's/^\t//' \ - -e 's/ *\\$//' \ - -e 's/ *$//' \ - -e '/^$/d' | - sort > check_makefile.3.$$ -# -if diff check_makefile.2.$$ check_makefile.3.$$ -then - ok="yes" -else - ok="no" -fi -rm check_makefile.*.$$ -echo "-------------------------------------------------------" -if [ "$ok" = "no" ] -then - echo "Error: nothing should be between the two dashed lines above" - exit 1 -fi -# ----------------------------------------------------------------------------- -echo "Checking debugging flags in all makefile.am files." -echo "-------------------------------------------------------" -list=`bin/ls_files.sh | sed -n -e '/\/makefile.am$/p'` -ok="yes" -for file in $list -do - case $file in - ( makefile.am | work/* | svn_dist/* ) - ;; - - (example/multi_thread/makefile.am) - ;; - - (speed/example/makefile.am) - if grep '\-DNDEBUG' $file > /dev/null - then - echo "-DNDEBUG flag appears in $file" - ok="no" - fi - if ! grep '\-g' $file > /dev/null - then - echo "-g flag does not appear in in $file" - ok="no" - fi - ;; - - (test_more/makefile.am) - sed -e '/ndebug/d' < $file > bin/check_makefile.$$ - if grep '\-DNDEBUG' bin/check_makefile.$$ > /dev/null - then - echo "-DNDEBUG flag appears in $file" - ok="no" - fi - if ! grep '\-g' $file > /dev/null - then - echo "-g flag does not appear in in $file" - ok="no" - fi - rm bin/check_makefile.$$ - ;; - - (speed/[^/]*/makefile.am | cppad_ipopt/speed/makefile.am) - if ! grep '^[^#]*-DNDEBUG' $file > /dev/null - then - echo "Optimization flag is not defined in $file" - ok="no" - fi - if ! grep '^#.*-g' $file > /dev/null - then - echo "Debug flag is not commented out in $file" - ok="no" - fi - ;; - - (test_more/compare_c/makefile.am) - if ! grep '^[^#]*-DNDEBUG' $file > /dev/null - then - echo "Optimization flag is not defined in $file" - ok="no" - fi - if ! grep '^#.*-g' $file > /dev/null - then - echo "Debug flag is not commented out in $file" - ok="no" - fi - ;; - - *) - if grep '\-DNDEBUG' $file > /dev/null - then - echo "-DNDEBUG flag appears in $file" - ok="no" - fi - if ! grep '\-g' $file > /dev/null - then - echo "-g flag does not appear in in $file" - ok="no" - fi - ;; - esac -done -echo "-------------------------------------------------------" -if [ "$ok" = "yes" ] -then - echo "Ok: nothing is between the two dashed lines above" - exit 0 -else - echo "Error: nothing should be between the two dashed lines above" - exit 1 -fi diff -Nru cppad-2018.00.00.0/bin/check_op_code.sh cppad-2019.02.00.0/bin/check_op_code.sh --- cppad-2018.00.00.0/bin/check_op_code.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_op_code.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,92 +1,93 @@ #! /bin/bash -e -# $Id: check_op_code.sh 3768 2015-12-28 18:58:35Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ ! -e "bin/check_op_code.sh" ] then - echo "bin/check_op_code.sh: must be executed from its parent directory" - exit 1 + echo "bin/check_op_code.sh: must be executed from its parent directory" + exit 1 fi echo "bin/check_op_code.sh: checking that op codes are in alphabetical order:" +file='include/cppad/local/op_code.hpp' # --------------------------------------------------------------------------- # 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/,/^ NumberOp /p' $file | sed \ + -e '/^enum/d' \ + -e '/^ NumberOp /d' \ + -e 's/^[ ]*//' \ + -e 's/Op[, ].*//' \ + -e '/^\/\//d' > op_code.1.$$ # -sort --ignore-case bin/op_code.1.$$ > bin/op_code.2.$$ -if ! diff bin/op_code.1.$$ bin/op_code.2.$$ +sort --ignore-case op_code.1.$$ > op_code.2.$$ +if ! diff op_code.1.$$ op_code.2.$$ then - echo "check_op_code.sh: enum list is not in alphabetical order" - rm bin/op_code.*.$$ - exit 1 + echo "check_op_code.sh: enum list is not in alphabetical order" + rm op_code.*.$$ + exit 1 fi # ----------------------------------------------------------------------------- # check NumArgTable -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.$$ +sed -n -e '/NumArgTable\[\]/,/^[ ]*};/p' $file | \ + sed \ + -e '/NumArgTable\[\]/d' \ + -e '/NumberOp.*not used/d' \ + -e '/^[ ]*};/d' \ + -e 's|^[ ]*[0-9],* *// *||' \ + -e 's|Op.*||' \ + > op_code.3.$$ # -if ! diff bin/op_code.1.$$ bin/op_code.3.$$ +if ! diff op_code.1.$$ op_code.3.$$ then - echo "check_op_code.sh: NumArgTable list is not in alphabetical order" - rm bin/op_code.*.$$ - exit 1 + echo "check_op_code.sh: NumArgTable list is not in alphabetical order" + rm op_code.*.$$ + exit 1 fi # ----------------------------------------------------------------------------- # check NumResTable (last line of NumResTable is not used) -sed -n -e '/NumResTable\[\]/,/^[ \t]*};/p' cppad/local/op_code.hpp | \ - sed \ - -e '/NumResTable\[\]/d' \ - -e '/^[ \t]*};/d' \ - -e '/NumberOp.*not used/d' \ - -e 's|^[ \t]*[0-9],* *// *||' \ - -e 's|Op.*||' \ - > bin/op_code.4.$$ +sed -n -e '/NumResTable\[\]/,/^[ ]*};/p' $file | \ + sed \ + -e '/NumResTable\[\]/d' \ + -e '/^[ ]*};/d' \ + -e '/NumberOp.*not used/d' \ + -e 's|^[ ]*[0-9],* *// *||' \ + -e 's|Op.*||' \ + > op_code.4.$$ # -if ! diff bin/op_code.1.$$ bin/op_code.4.$$ +if ! diff op_code.1.$$ op_code.4.$$ then - echo "check_op_code.sh: NumResTable list is not in alphabetical order" - echo "(or missing last line)" - rm bin/op_code.*.$$ - exit 1 + echo "check_op_code.sh: NumResTable list is not in alphabetical order" + echo "(or missing last line)" + rm op_code.*.$$ + exit 1 fi # ----------------------------------------------------------------------------- # check OpNameTable -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.$$ +sed -n -e '/const char \*OpNameTable\[\]/,/^[ ]*};/p' $file | \ + sed \ + -e '/OpNameTable\[\]/d' \ + -e '/"Number".*not used/d' \ + -e '/^[ ]*};/d' \ + -e 's|^[ ]*"||' \ + -e 's|".*||' \ + > op_code.5.$$ # -if ! diff bin/op_code.1.$$ bin/op_code.5.$$ +if ! diff op_code.1.$$ op_code.5.$$ then - echo "check_op_code.sh: OpName list is not in alphabetical order" - rm bin/op_code.*.$$ - exit 1 + echo "check_op_code.sh: OpName list is not in alphabetical order" + rm op_code.*.$$ + exit 1 fi # ----------------------------------------------------------------------------- # clean up -rm bin/op_code.*.$$ +rm op_code.*.$$ # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 diff -Nru cppad-2018.00.00.0/bin/check_replace.sh cppad-2019.02.00.0/bin/check_replace.sh --- cppad-2018.00.00.0/bin/check_replace.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_replace.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,44 +1,44 @@ #! /bin/bash -e -# $Id: check_replace.sh 3853 2016-12-14 14:40:11Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ $0 != "bin/check_replace.sh" ] then - echo "bin/check_replace.sh: must be executed from its parent directory" - exit 1 + echo "bin/check_replace.sh: must be executed from its parent directory" + exit 1 fi check_replace() { - define_file="cppad/local/$1" - replace_file="cppad/local/$2" - new_file="cppad/local/$2.$$" - bin/replace_html.py $define_file $replace_file $new_file - if ! diff $replace_file $new_file > /dev/null - then - cat << EOF + define_file="include/cppad/local/$1" + replace_file="include/cppad/local/$2" + new_file="include/cppad/local/$2.$$" + bin/replace_html.py $define_file $replace_file $new_file + if ! diff $replace_file $new_file > /dev/null + then + cat << EOF check_replace.sh: Error: The replacement text in $replace_file does not match its definition in $define_file. Execute the following command to fix this: - mv $new_file $replace_file + mv $new_file $replace_file EOF - exit 1 - fi - rm $new_file + exit 1 + fi + rm $new_file } # ----------------------------------------------------------------------------- # files with definitions and replacemnet in same file check_replace cond_op.hpp cond_op.hpp check_replace load_op.hpp load_op.hpp check_replace store_op.hpp store_op.hpp -check_replace forward0sweep.hpp forward1sweep.hpp +check_replace sweep/forward0.hpp sweep/forward1.hpp # ----------------------------------------------------------------------------- echo "replace_html.sh: OK" exit 0 diff -Nru cppad-2018.00.00.0/bin/check_srcfile.sh cppad-2019.02.00.0/bin/check_srcfile.sh --- cppad-2018.00.00.0/bin/check_srcfile.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_srcfile.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,27 @@ #! /bin/bash -e # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ ! -e "bin/check_srcfile.sh" ] then - echo "bin/check_srcfile.sh: must be executed from its parent directory" - exit 1 + echo "bin/check_srcfile.sh: must be executed from its parent directory" + exit 1 fi cat << EOF > junk.sed /\$srcfile[^a-z]/! b skip N -s/^#[ \\t]// -s/^[ \\t]// -s/\\n#[ \\t]// -s/\\n[ \\t]// +s/^# *// +s/^ *// +s/\\n# *// +s/\\n *// s/\$srcfile%// s/%.*// p @@ -28,72 +29,71 @@ EOF special_case=' bin/check_srcfile.sh -bin/package.sh -cppad/core/cond_exp.hpp +include/cppad/core/cond_exp.hpp introduction/exp_2.omh introduction/exp_eps.omh omh/appendix/license.omh -bin/batch_edit.sh +batch_edit.sed ' # ----------------------------------------------------------------------------- # Make sure that OMhelp srcfile commands refer to same file as command echo "Checking that OMhelp srcfile commands include from file they appear in." echo "----------------------------------------------------------------------" -list=`bin/ls_files.sh` +list=`git ls-files` different="no" for file in $list do - special='no' - for name in $special_case - do - if [ "$file" == "$name" ] - then - special='yes' - fi - done - # - bad_reference='' - reference_list=`sed -n -f junk.sed $file` - if [ "$special" == 'no' ] && [ "$reference_list" != '' ] - then - for reference in $reference_list - do - if [ "$reference" != "$file" ] - then - bad_reference="$reference" - fi - done - fi - # - ext=`echo $file | sed -e 's|.*\.||'` - if [ "$bad_reference" != '' ] && [ "$ext" == 'omh' ] - then - 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 - bad_reference='' - fi - file_root=`echo $file | sed -e 's|.*/||' -e 's|\.omh|.hpp|'` - if [ "$file_root" == "$ref_root" ] - then - bad_reference='' - fi - fi - # - if [ "$bad_reference" != '' ] - then - echo "\$srcfile in $file references" - echo "$bad_reference" - different="yes" - fi + special='no' + for name in $special_case + do + if [ "$file" == "$name" ] + then + special='yes' + fi + done + # + bad_reference='' + reference_list=`sed -n -f junk.sed $file` + if [ "$special" == 'no' ] && [ "$reference_list" != '' ] + then + for reference in $reference_list + do + if [ "$reference" != "$file" ] + then + bad_reference="$reference" + fi + done + fi + # + ext=`echo $file | sed -e 's|.*\.||'` + if [ "$bad_reference" != '' ] && [ "$ext" == 'omh' ] + then + 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 + bad_reference='' + fi + file_root=`echo $file | sed -e 's|.*/||' -e 's|\.omh|.hpp|'` + if [ "$file_root" == "$ref_root" ] + then + bad_reference='' + fi + fi + # + if [ "$bad_reference" != '' ] + then + echo "\$srcfile in $file references" + echo "$bad_reference" + different="yes" + fi done echo "-------------------------------------------------------------------" if [ $different = "yes" ] then - echo "Error: nothing should be between the two dashed lines above" - exit 1 + echo "Error: nothing should be between the two dashed lines above" + exit 1 else - echo "OK: nothing is between the two dashed lines above" - exit 0 + echo "OK: nothing is between the two dashed lines above" + exit 0 fi diff -Nru cppad-2018.00.00.0/bin/check_svn_dist.sh cppad-2019.02.00.0/bin/check_svn_dist.sh --- cppad-2018.00.00.0/bin/check_svn_dist.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_svn_dist.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -#! /bin/bash -e -# $Id: check_svn_dist.sh 3921 2017-05-14 15:26:14Z bradbell $ -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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/check_svn_dist.sh" ] -then - echo "bin/check_svn_dist.sh: must be executed from its parent directory" - exit 1 -fi -# ----------------------------------------------------------------------------- -log_dir=`pwd` -script="bin/check_svn_dist.sh" -repository="https://projects.coin-or.org/svn/CppAD" -branch=`pwd | sed -e 's|.*/CppAD/||' -e 's|.*/cppad/||'` -if [ -e "svn_dist" ] -then - echo "rm -rf svn_dist" - rm -rf svn_dist -fi -# ---------------------------------------------------------------------------- -echo "svn checkout $repository/$branch svn_dist" -svn checkout $repository/$branch svn_dist -# ---------------------------------------------------------------------------- -# Things to do in the svn_dist directory -# ---------------------------------------------------------------------- -echo "cd svn_dist" -cd svn_dist -# -echo "bin/autotools.sh configure" -if ! bin/autotools.sh configure -then - echo "$script: error durring bin/autotools.sh configure in ./svn_dist" - exit 1 -fi -# -# ---------------------------------------------------------------------- -# Things to do in the svn_dist/work directory -# ---------------------------------------------------------------------- -echo "cd work" -cd work -# -echo "$script: make test >& svn_dist.log" -echo "The following will give details of progress of command above" -echo " tail -f svn_dist.log" -make test >& $log_dir/svn_dist.log -# -if grep 'warning:' $log_dir/svn_dist.log -then - echo "$script: Stopping because there are warnings in svn_dist.log" - exit 1 -fi -# -echo "cat test.log >> svn_dist.log" -cat test.log >> $log_dir/svn_dist.log -# -echo "OK: $script, results are in svn_dist.log" diff -Nru cppad-2018.00.00.0/bin/check_svn_id.sh cppad-2019.02.00.0/bin/check_svn_id.sh --- cppad-2018.00.00.0/bin/check_svn_id.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_svn_id.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -#! /bin/bash -e -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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/check_svn_id.sh" ] -then - echo "bin/check_svn_id.sh: must be executed from its parent directory" - exit 1 -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' \ - -e '/^.gitignore$/d' \ - -e '/\/makefile.in$/d' \ - -e '/bin\/check_svn_id.sh$/d' \ - -e '/authors/d' \ - -e '/COPYING/d' | - sort -u` -ok="yes" -for file in $list -do - if [ -e $file ] - then - sed $file -e '/$Id.*\$/d' > check_svn_id.$$ - if ! diff $file check_svn_id.$$ > /dev/null - then - echo '----------------------------------------------------' - echo "check_svn_id.sh: automatic changes to $file:" - if diff $file check_svn_id.$$ - then - echo 'bin/check_svn_id.sh: program error' - rm check_svn_id.$$ - exit 1 - fi - ok='no' - if [ -x $file ] - then - mv check_svn_id.$$ $file - chmod +x $file - else - mv check_svn_id.$$ $file - fi - fi - fi -done -if [ -e check_svn_id.$$ ] -then - rm check_svn_id.$$ -fi -if [ "$ok" == 'no' ] -then - exit 1 -fi -# ---------------------------------------------------------------------------- -echo "$0: OK" -exit 0 diff -Nru cppad-2018.00.00.0/bin/check_tab.sh cppad-2019.02.00.0/bin/check_tab.sh --- cppad-2018.00.00.0/bin/check_tab.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_tab.sh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,49 @@ +#! /bin/bash -e +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +if [ "$0" != 'bin/check_tab.sh' ] +then + echo "bin/check_tab: must be executed from its parent directory" + exit 1 +fi +echo "-------------------------------------------------------" +ok='yes' +file_list=`git ls-files | sed \ + -e '/makefile[.]am$/d' \ + -e '/makefile[.]in$/d' \ + -e '/^batch_edit.sed$/d' \ + -e '/^coin.png$/d' \ + -e '/^configure$/d' \ + -e '/^compile$/d' \ + -e '/^config.guess$/d' \ + -e '/^config.sub$/d' \ + -e '/^depcomp$/d' \ + -e '/^install-sh$/d' \ + -e '/^uw_copy_040507.html/d' \ +` +tab=$'\t' +for file in $file_list +do + if grep $'\t' $file > /dev/null + then + echo $file + ok='no' + fi +done +echo "-------------------------------------------------------" +if [ "$ok" = 'no' ] +then + echo 'bin/check_tab.sh: The files above contain tabs' + exit 1 +fi +echo 'bin/check_if.sh: OK' +exit 0 diff -Nru cppad-2018.00.00.0/bin/check_tempfile.sh cppad-2019.02.00.0/bin/check_tempfile.sh --- cppad-2018.00.00.0/bin/check_tempfile.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_tempfile.sh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,33 @@ +#! /bin/bash -e +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +if [ ! -e "bin/check_tempfile.sh" ] +then + echo "bin/check_tempfile.sh: must be executed from its parent directory" + exit 1 +fi +# ----------------------------------------------------------------------------- +list=`ls | sed -n -e '/^new.[0-9]*$/d' -e '/\.[0-9]*$/p'` +if [ "$list" != '' ] +then + echo 'Use following command to remove temporary files:' + cmd='rm ' + for file in $list + do + cmd="$cmd $file" + done + echo " $cmd" + echo 'check_tempfile.sh: Error' + exit 1 +fi +echo 'check_tempfile.sh: OK' +exit 0 diff -Nru cppad-2018.00.00.0/bin/check_user_def.sh cppad-2019.02.00.0/bin/check_user_def.sh --- cppad-2018.00.00.0/bin/check_user_def.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/check_user_def.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,63 +1,64 @@ #! /bin/bash -e -# $Id$ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ $0 != "bin/check_user_def.sh" ] then - echo "bin/check_user_def.sh: must be executed from its parent directory" - exit 1 + 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'` +file_list=`git grep -l '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" + 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 + 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 +undef_file='include/cppad/core/undef.hpp' 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/core/undef.hpp > /dev/null - then - ok='true' - fi - if grep "$symbol *in deprecated api" cppad/core/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/core/undef.hpp" - exit 1 - fi + symbol=`echo $symbol_file | sed -e 's|:.*||'` + file=`echo $symbol_file | sed -e 's|.*:||'` + ok='false' + if grep "$symbol *in user api" $undef_file > /dev/null + then + ok='true' + fi + if grep "$symbol *in deprecated api" $undef_file > /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 $undef_file" + exit 1 + fi done echo '-----------------------------------------------------------------------' echo "check_user_def.sh: OK" diff -Nru cppad-2018.00.00.0/bin/colpack.sh cppad-2019.02.00.0/bin/colpack.sh --- cppad-2018.00.00.0/bin/colpack.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/colpack.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,37 @@ #! /bin/bash -e -# $Id: colpack.sh 3768 2015-12-28 18:58:35Z bradbell $ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- 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 - color_variant="COLUMN_PARTIAL_DISTANCE_TWO" + color_variant="COLUMN_PARTIAL_DISTANCE_TWO" else - color_variant="ROW_PARTIAL_DISTANCE_TWO" + color_variant="ROW_PARTIAL_DISTANCE_TWO" fi # ---------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { - echo $* - eval $* + echo $* + eval $* } # ----------------------------------------------- if [ ! -e 'build/colpack' ] then - echo_eval mkdir -p build/colpack + echo_eval mkdir -p build/colpack fi echo 'create: build/colpack/colpack.cpp' cat<< EOF > build/colpack/colpack.cpp @@ -31,123 +41,123 @@ #include "ColPackHeaders.h" int main() -{ size_t i, j, k; +{ size_t i, j, k; - using std::cout; - using std::endl; + using std::cout; + using std::endl; - //* 32x9 matrix - size_t i_RowCount = 32; - size_t i_ColumnCount = 9; - size_t i_MaxNonZerosInRows = 3; - - // JP[32][9] - std::vector JP(i_RowCount); - unsigned int n_data = i_RowCount * (i_MaxNonZerosInRows + 1); - std::vector JP_memory(n_data); - for(i = 0; i < i_RowCount; i++) - JP[i] = JP_memory.data() + i * (i_MaxNonZerosInRows + 1); - // - JP[0][0] = 0; - JP[1][0] = 1; JP[1][1] = 0; - JP[2][0] = 1; JP[2][1] = 1; - JP[3][0] = 1; JP[3][1] = 2; - JP[4][0] = 1; JP[4][1] = 0; - JP[5][0] = 3; JP[5][1] = 0; JP[5][2] = 1; JP[5][3] = 3; - JP[6][0] = 3; JP[6][1] = 1; JP[6][2] = 2; JP[6][3] = 4; - JP[7][0] = 2; JP[7][1] = 2; JP[7][2] = 5; - JP[8][0] = 1; JP[8][1] = 3; - JP[9][0] = 3; JP[9][1] = 3; JP[9][2] = 4; JP[9][3] = 6; - JP[10][0] = 3; JP[10][1] = 4; JP[10][2] = 5; JP[10][3] = 7; - JP[11][0] = 2; JP[11][1] = 5; JP[11][2] = 8; - JP[12][0] = 1; JP[12][1] = 6; - JP[13][0] = 2; JP[13][1] = 6; JP[13][2] = 7; - JP[14][0] = 2; JP[14][1] = 7; JP[14][2] = 8; - JP[15][0] = 1; JP[15][1] = 8; - JP[16][0] = 1; JP[16][1] = 0; - JP[17][0] = 2; JP[17][1] = 0; JP[17][2] = 1; - JP[18][0] = 2; JP[18][1] = 1; JP[18][2] = 2; - JP[19][0] = 1; JP[19][1] = 2; - JP[20][0] = 2; JP[20][1] = 0; JP[20][2] = 3; - JP[21][0] = 3; JP[21][1] = 1; JP[21][2] = 3; JP[21][3] = 4; - JP[22][0] = 3; JP[22][1] = 2; JP[22][2] = 4; JP[22][3] = 5; - JP[23][0] = 1; JP[23][1] = 5; - JP[24][0] = 2; JP[24][1] = 3; JP[24][2] = 6; - JP[25][0] = 3; JP[25][1] = 4; JP[25][2] = 6; JP[25][3] = 7; - JP[26][0] = 3; JP[26][1] = 5; JP[26][2] = 7; JP[26][3] = 8; - JP[27][0] = 1; JP[27][1] = 8; - JP[28][0] = 1; JP[28][1] = 6; - JP[29][0] = 1; JP[29][1] = 7; - JP[30][0] = 1; JP[30][1] = 8; - JP[31][0] = 0; - cout << endl << "Sparsity pattern of Jacobian:" << endl; - cout << " "; - for(k = 0; k < 9; k++) - cout << setw(3) << k; - cout << endl; - for(i = 0; i < i_RowCount; i++) - { cout << setw(3) << i << ":"; - k = 0; - for (j = 1; j <= (int) JP[i][0]; j++) - { while(k < JP[i][j]) - { cout << setw(3) << 0; - k++; - } - cout << setw(3) << 1; - k++; - } - while(k < 9) - { cout << setw(3) << 0; - k++; - } - cout << endl; - } - - - // 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 - // of the bipartite graph with the specified ordering - g.PartialDistanceTwoColoring( - "SMALLEST_LAST", "$color_variant" - ); - g.PrintColumnPartialColors(); - g.PrintColumnPartialColoringMetrics(); - - // Step 3: From the coloring information, create and return seed matrix - int ip1_SeedRowCount; - int ip1_SeedColumnCount; - double** RSeed = - g.GetSeedMatrix(&ip1_SeedRowCount, &ip1_SeedColumnCount); - int rows = ip1_SeedRowCount; - int cols = ip1_SeedColumnCount; - cout << "Seed matrix: (" << rows << "," << cols << ")" << endl; - cout << " "; - for(j = 0; j < cols; j++) - cout << setw(3) << j; - cout << endl; - for(i = 0; i < rows; i++) - { cout << setw(3) << i << ":"; - for(j = 0; j < cols; j++) - cout << setw(3) << int(RSeed[i][j]); - cout << endl; - } + //* 32x9 matrix + size_t i_RowCount = 32; + size_t i_ColumnCount = 9; + size_t i_MaxNonZerosInRows = 3; + + // JP[32][9] + std::vector JP(i_RowCount); + unsigned int n_data = i_RowCount * (i_MaxNonZerosInRows + 1); + std::vector JP_memory(n_data); + for(i = 0; i < i_RowCount; i++) + JP[i] = JP_memory.data() + i * (i_MaxNonZerosInRows + 1); + // + JP[0][0] = 0; + JP[1][0] = 1; JP[1][1] = 0; + JP[2][0] = 1; JP[2][1] = 1; + JP[3][0] = 1; JP[3][1] = 2; + JP[4][0] = 1; JP[4][1] = 0; + JP[5][0] = 3; JP[5][1] = 0; JP[5][2] = 1; JP[5][3] = 3; + JP[6][0] = 3; JP[6][1] = 1; JP[6][2] = 2; JP[6][3] = 4; + JP[7][0] = 2; JP[7][1] = 2; JP[7][2] = 5; + JP[8][0] = 1; JP[8][1] = 3; + JP[9][0] = 3; JP[9][1] = 3; JP[9][2] = 4; JP[9][3] = 6; + JP[10][0] = 3; JP[10][1] = 4; JP[10][2] = 5; JP[10][3] = 7; + JP[11][0] = 2; JP[11][1] = 5; JP[11][2] = 8; + JP[12][0] = 1; JP[12][1] = 6; + JP[13][0] = 2; JP[13][1] = 6; JP[13][2] = 7; + JP[14][0] = 2; JP[14][1] = 7; JP[14][2] = 8; + JP[15][0] = 1; JP[15][1] = 8; + JP[16][0] = 1; JP[16][1] = 0; + JP[17][0] = 2; JP[17][1] = 0; JP[17][2] = 1; + JP[18][0] = 2; JP[18][1] = 1; JP[18][2] = 2; + JP[19][0] = 1; JP[19][1] = 2; + JP[20][0] = 2; JP[20][1] = 0; JP[20][2] = 3; + JP[21][0] = 3; JP[21][1] = 1; JP[21][2] = 3; JP[21][3] = 4; + JP[22][0] = 3; JP[22][1] = 2; JP[22][2] = 4; JP[22][3] = 5; + JP[23][0] = 1; JP[23][1] = 5; + JP[24][0] = 2; JP[24][1] = 3; JP[24][2] = 6; + JP[25][0] = 3; JP[25][1] = 4; JP[25][2] = 6; JP[25][3] = 7; + JP[26][0] = 3; JP[26][1] = 5; JP[26][2] = 7; JP[26][3] = 8; + JP[27][0] = 1; JP[27][1] = 8; + JP[28][0] = 1; JP[28][1] = 6; + JP[29][0] = 1; JP[29][1] = 7; + JP[30][0] = 1; JP[30][1] = 8; + JP[31][0] = 0; + cout << endl << "Sparsity pattern of Jacobian:" << endl; + cout << " "; + for(k = 0; k < 9; k++) + cout << setw(3) << k; + cout << endl; + for(i = 0; i < i_RowCount; i++) + { cout << setw(3) << i << ":"; + k = 0; + for (j = 1; j <= (int) JP[i][0]; j++) + { while(k < JP[i][j]) + { cout << setw(3) << 0; + k++; + } + cout << setw(3) << 1; + k++; + } + while(k < 9) + { cout << setw(3) << 0; + k++; + } + cout << endl; + } + + + // 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 + // of the bipartite graph with the specified ordering + g.PartialDistanceTwoColoring( + "SMALLEST_LAST", "$color_variant" + ); + g.PrintColumnPartialColors(); + g.PrintColumnPartialColoringMetrics(); + + // Step 3: From the coloring information, create and return seed matrix + int ip1_SeedRowCount; + int ip1_SeedColumnCount; + double** RSeed = + g.GetSeedMatrix(&ip1_SeedRowCount, &ip1_SeedColumnCount); + int rows = ip1_SeedRowCount; + int cols = ip1_SeedColumnCount; + cout << "Seed matrix: (" << rows << "," << cols << ")" << endl; + cout << " "; + for(j = 0; j < cols; j++) + cout << setw(3) << j; + cout << endl; + for(i = 0; i < rows; i++) + { cout << setw(3) << i << ":"; + for(j = 0; j < cols; j++) + cout << setw(3) << int(RSeed[i][j]); + cout << endl; + } - return 0; + return 0; } EOF # ---------------------------------------------------------------------------- echo_eval cd build/colpack echo_eval g++ colpack.cpp \ - -I$HOME/prefix/colpack/include/ColPack \ - -L$HOME/prefix/colpack/lib64 \ - -l ColPack \ - -o colpack + -I$HOME/prefix/colpack/include/ColPack \ + -L$HOME/prefix/colpack/lib64 \ + -l ColPack \ + -o colpack # echo_eval valgrind --leak-check=yes ./colpack # ---------------------------------------------------------------------------- diff -Nru cppad-2018.00.00.0/bin/cygwin_package.sh cppad-2019.02.00.0/bin/cygwin_package.sh --- cppad-2018.00.00.0/bin/cygwin_package.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/cygwin_package.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,549 +0,0 @@ -#! /bin/bash -e -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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/cygwin_package.sh" ] -then - echo "bin/cygwin_package.sh: must be executed from its parent directory" - exit 1 -fi -# ----------------------------------------------------------------------------- -# experimental script for cygwin packaging of CppAD -# -# version and release number -# -# begin fresh cygwin_package directory -# -if [ -e cygwin_package ] -then - echo "rm -r cygwin_package" - if ! rm -r cygwin_package - then - exit 1 - fi -fi -# -# determine the most recent version in the Download directory -# -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 - echo "change: f'(3) -> y'(3)" - echo "change: example/get_started -> get_started" - echo "change: get_started.cpp.htm -> getstarted.cpp.htm" - echo "change: get_started.cpp.xml -> getstarted.cpp.xml" -fi -release="1" -if [ ! -e "/cygdrive/c/Download/cppad-$version.gpl.tgz" ] -then - echo "Error determining the version number, cannot find" - echo "/cygdrive/c/Download/cppad-$version.gpl.tgz" - exit 1 -fi -# -# extract the gpl version of the distribution -# -file="/cygdrive/c/Download/cppad-$version.gpl.tgz" -if [ ! -e $file ] -then - exit 1 -fi -if [ -e cppad-$version ] -then - echo "rm -r cppad-$version" - if ! rm -r cppad-$version - then - echo "Cannot remove old cppad-$version directory." - fi -fi -echo "tar -xzf $file" -if ! tar -xzf $file -then - echo "Cannot create new cppad-$version directory." - exit 1 -fi -# -# make a copy of the distribution in the cygwin_package sub-directory -# -echo "mkdir cygwin_package" -mkdir cygwin_package -echo "cp -r cppad-$version cygwin_package/cppad-$version-$release" -if ! cp -r cppad-$version cygwin_package/cppad-$version-$release -then - exit 1 -fi -# -# change into the cygwin_package sub-directory and stay there -# -echo "cd cygwin_package" -if ! cd cygwin_package -then - exit 1 -fi -# -# Create the setup.hint file ---------------------------------------------- -# -cat > setup.hint << EOF -# To test the source or binary distribution, copy the source distribution file -# cppad-$version-$release/example/get_started/get_started.cpp -# to a temporary directory and execute the commands -# g++ get_started.cpp -o get_started.exe -# ./get_started -# the resulting output should be -# f'(3) computed by CppAD = 142 -# -# Requires a standard compliant C++ compiler; e.g., gcc-g++. -requires: gcc-g++ -# -category: Math -# -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 -are supported. See the documentation for this version - ( /usr/share/doc/cppad-$version-$release/cppad.htm ) -or the CppAD home page - ( http://http://www.coin-or.org/CppAD/ ) -for more details." -EOF -# -# Create the source distribution ------------------------------------------ -# -# Create the cygwin README file -# -bin_doc="/usr/share/doc/cppad-$version-$release" -src_doc="/usr/src/cppad-$version-$release/doc" -web_doc="http://www.coin-or.org/CppAD/Doc" -readme_file="cppad-$version-$release/README" -# -echo "create: $readme_file" -# -cat > $readme_file << EOF -CppAD for cygwin version number $version release number $release. - -http://www.coin-or.org/CppAD -This is the CppAD home page. - -cppad@list.coin-or.org -This mailing list is used for CppAD discussion and bug reporting. You must -first join the mailing list using its general information page - http://list.coin-or.org/mailman/listinfo/CppAD -(this avoids having spam on the mailing list). - -DOC -We use DOC below for the directories that contains the CppAD documentation. -Source distribution this version, DOC = cppad-$version-$release/doc -Binary this version (post install), DOC = $bin_doc -Source this version (post install), DOC = $src_doc -The documentation of most recent version, DOC = $web_doc - -DOC/*.htm -Files in the DOC directory with with the .htm extension -represent mathematics using LaTex; for example see DOC/poly.htm. - -DOC/*.xml -Files in the DOC directory with with the .xml extension -represent mathematics using LaTex; for example see DOC/poly.xml. - -DOC/(cppad.xml or cppad.htm) -Is the top (root) of the documentation tree for CppAD. - -DOC/(get_started.cpp.xml or get_started.cpp.htm) -Contains an example for getting started using CppAD. - -DOC/(introduction.xml or introduction.htm) -Contains an introduction by example to Algorithmic Differentiation. - -DOC/(whats_new.xml or whats_new.htm) -Contains a list of changes and additions to CppAD in reverse order by date. - -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). -EOF -# -# change configure.ac -# -echo "Begin: modify configure.ac and files that depend on it." -echo "sed < cppad-$version-$release/configure.ac > configure.ac \\" -echo " -e '/dnl cygwin begin delete:/,/dnl cygwin end delete:/d' \\" -echo " -e 's/dnl cygwin replace: *//'" -# -if ! sed < cppad-$version-$release/configure.ac > configure.ac \ - -e '/dnl cygwin begin delete:/,/dnl cygwin end delete:/d' \ - -e 's/dnl cygwin replace: *//' -then - exit 1 -fi -# -if ! mv configure.ac cppad-$version-$release/configure.ac -then - exit 1 -fi -if ! cd cppad-$version-$release -then - exit 1 -fi -if ! aclocal -then - exit 1 -fi -if ! autoheader -then - exit 1 -fi -if ! autoconf -then - exit 1 -fi -if ! automake --add-missing -then - exit 1 -fi -# directory created by commands above and not in distribution -echo "rm -r autom4te.cache" -if ! rm -r autom4te.cache -then - exit 1 -fi -if ! cd .. -then - exit 1 -fi -echo "End: modify configure.ac and files that depend on it." -# -# create the cppad-$version.patch file -# -diff -N -r -u -p \ - ../cppad-$version cppad-$version-$release > cppad-$version.patch -# -# create the cppad-$version-$release/CYGWIN-PATCHES sub-directory -# -echo "mkdir cppad-$version-$release/CYGWIN-PATCHES" -if ! mkdir cppad-$version-$release/CYGWIN-PATCHES -then - exit 1 -fi -if ! cp $readme_file cppad-$version-$release/CYGWIN-PATCHES/cppad.README -then - exit 1 -fi -if ! cp setup.hint cppad-$version-$release/CYGWIN-PATCHES -then - exit 1 -fi -if ! cp cppad-$version.patch cppad-$version-$release/CYGWIN-PATCHES -then - exit 1 -fi -# -# create cppad-$version-$release-src.tar.bz2 -# -echo "tar -cf cppad-$version-$release-src.tar cppad-$version-$release" -if ! tar -cf cppad-$version-$release-src.tar cppad-$version-$release -then - exit 1 -fi -echo "bzip2 -z -f cppad-$version-$release-src.tar" -if ! bzip2 -z -f cppad-$version-$release-src.tar -then - exit 1 -fi -# -# Create the binary distribution ------------------------------------------ -# -# create the usr/include/cppad directory -# -echo "mkdir usr/include" -mkdir usr -mkdir usr/include -# -echo "cp -r cppad-$version-$release/cppad usr/include/cppad" -if ! cp -r cppad-$version-$release/cppad usr/include/cppad -then - exit 1 -fi -chmod 644 usr/include/cppad/*.hpp -chmod 644 usr/include/cppad/local/*.hpp -chmod 755 usr/include/cppad -chmod 755 usr/include/cppad/local -# -# create the usr/share/doc/cppad-$version directory -# -echo "mkdir usr/share/doc" -mkdir usr/share -mkdir usr/share/doc -# -echo "cp -r cppad-$version-$release/doc usr/share/doc/cppad-$version" -if ! cp -r cppad-$version-$release/doc usr/share/doc/cppad-$version -then - exit 1 -fi -chmod 644 usr/share/doc/cppad-$version/* -chmod 755 usr/share/doc/cppad-$version -# -# create the usr/share/doc/Cygwin/cppad-$version-$release.README -# -echo "mkdir usr/share/doc/Cygwin" -if ! mkdir usr/share/doc/Cygwin -then - exit -fi -if ! cp $readme_file usr/share/doc/Cygwin/cppad-$version-$release.README -then - exit 1 -fi -# -# create cppad-$version-$release.tar.bz2 -# -echo "tar -cf cppad-$version-$release.tar usr" -if ! tar -cf cppad-$version-$release.tar usr -then - exit 1 -fi -echo "bzip2 -z -f cppad-$version-$release.tar" -if ! bzip2 -z -f cppad-$version-$release.tar -then - exit 1 -fi -# -# Test source install -------------------------------------------------------- -# -echo "Begin: test if source install" -if [ -e /usr/include/cppad ] -then - echo "rm -r /usr/include/cppad" - if ! rm -r /usr/include/cppad - then - exit 1 - fi -fi -if [ -e /usr/share/doc/cppad-* ] -then - echo "rm -rf /usr/share/doc/cppad-*" - if ! rm -rf /usr/share/doc/cppad-* - then - exit 1 - fi -fi -mkdir test_src -echo "cd test_src" -if ! cd test_src -then - exit 1 -fi -echo "cp ../cppad-$version-$release-src.tar.bz2 ." -if ! cp ../cppad-$version-$release-src.tar.bz2 . -then - exit 1 -fi -echo "bunzip2 cppad-$version-$release-src.tar.bz2" -if ! bunzip2 cppad-$version-$release-src.tar.bz2 -then - exit 1 -fi -echo "tar -xf cppad-$version-$release-src.tar" -if ! tar -xf cppad-$version-$release-src.tar -then - exit 1 -fi -echo "cd cppad-$version-$release" -if ! cd cppad-$version-$release -then - exit 1 -fi -echo "./configure" -if ! ./configure -then - exit 1 -fi -echo "make install" -if ! make install -then - exit 1 -fi -echo "cd ../.." -if ! cd ../.. -then - exit 1 -fi -dir="test_src/cppad-$version-$release/example/get_started" -echo "cp $dir/get_started.cpp ." -if ! cp $dir/get_started.cpp . -then - exit 1 -fi -if ! g++ get_started.cpp -o get_started.exe -then - exit 1 -fi -echo "./get_started > get_started.out" -./get_started > get_started.out -echo "f'(3) computed by CppAD = 142" > get_started.chk -if ! diff get_started.out get_started.chk -then - echo "error in get_started output" - exit 1 -fi -file_list=" - cppad - get_started.cpp - introduction - whats_new - installunix -" -ext_list=" - htm - xml -" -for file in $file_list -do - for ext in $ext_list - do - full_name=/usr/share/doc/cppad-$version/$file.$ext - if [ ! -e "$full_name" ] - then - echo "cannot find $full_name" - exit 1 - fi - done -done -echo "End: test if source install" -# -# Test binary install -------------------------------------------------------- -# -echo "Begin: test if binary install" -if [ -e /usr/include/cppad ] -then - echo "rm -r /usr/include/cppad" - if ! rm -r /usr/include/cppad - then - exit 1 - fi -fi -if [ -e /usr/share/doc/cppad-* ] -then - echo "rm -rf /usr/share/doc/cppad-*" - if ! rm -rf /usr/share/doc/cppad-* - then - exit 1 - fi -fi -mkdir test_bin -echo "cd test_bin" -if ! cd test_bin -then - exit 1 -fi -echo "cp ../cppad-$version-$release.tar.bz2 ." -if ! cp ../cppad-$version-$release.tar.bz2 . -then - exit 1 -fi -echo "bunzip2 cppad-$version-$release.tar.bz2" -if ! bunzip2 cppad-$version-$release.tar.bz2 -then - exit 1 -fi -echo "tar -xf cppad-$version-$release.tar" -if ! tar -xf cppad-$version-$release.tar -then - exit 1 -fi -echo "cp -r usr/include/cppad /usr/include/cppad" -if ! cp -r usr/include/cppad /usr/include/cppad -then - exit 1 -fi -echo "cp -r usr/share/doc/cppad-$version /usr/share/doc/cppad-$version" -if ! cp -r usr/share/doc/cppad-$version /usr/share/doc/cppad-$version -then - exit 1 -fi -echo "cd .." -if ! cd .. -then - exit 1 -fi -if ! rm get_started.exe -then - exit 1 -fi -if ! g++ get_started.cpp -o get_started.exe -then - exit 1 -fi -echo "./get_started > get_started.out" -./get_started > get_started.out -echo "f'(3) computed by CppAD = 142" > get_started.chk -if ! diff get_started.out get_started.chk -then - echo "error in get_started output" - exit 1 -fi -file_list=" - cppad - get_started.cpp - introduction - whats_new - installunix -" -ext_list=" - htm - xml -" -for file in $file_list -do - for ext in $ext_list - do - full_name=/usr/share/doc/cppad-$version/$file.$ext - if [ ! -e "$full_name" ] - then - echo "cannot find $full_name" - exit 1 - fi - done -done -echo "End: test if binary install" -# -# Clean up ------------------------------------------------------------------ -# -echo "cd .." -if ! cd .. -then - exit 1 -fi -list=" - cppad-$version-$release - usr - cppad-$version.patch - test_src - test_bin -" -for dir in $list -do - echo "rm -r cygwin_package/$dir" - if ! rm -r cygwin_package/$dir - then - exit 1 - fi -done -echo "rm cygwin_package/get_started.*" -if ! rm cygwin_package/get_started.* -then - exit 1 -fi -# -# ---------------------------------------------------------------------------- -# Done -echo bin/"cygwin_package.sh: passed all its tests" -exit 0 diff -Nru cppad-2018.00.00.0/bin/deprecate_xam.sh cppad-2019.02.00.0/bin/deprecate_xam.sh --- cppad-2018.00.00.0/bin/deprecate_xam.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/bin/deprecate_xam.sh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,79 @@ +#! /bin/bash -e +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +if [ "$0" != 'bin/deprecate_xam.sh' ] +then + echo 'bin/deprecate_xam.sh: must be executed from its parent directory' + exit 1 +fi +if [ "$1" == '' ] +then + echo 'bin/deprecate_xam.sh file' + echo 'where file is an example file that is to be deprecated' + exit 1 +fi +old_file="$1" +ext=`echo $old_file | sed -e 's|.*\.||'` +if [ $ext != 'cpp' ] +then + echo 'bin/depreate_xam.sh: file name does not end in .cpp' + exit 1 +fi +dir=`echo $old_file | sed -e 's|/.*||'` +if [ $dir != 'example' ] +then + echo 'bin/depreate_xam.sh: file name does not start with example/' + exit 1 +fi +# ----------------------------------------------------------------------------- +# move file +root_name=`echo $old_file | sed -e 's|.*/||' -e 's|\.cpp$||'` +new_dir="test_more/deprecated" +new_file="$new_dir/$root_name.cpp" +echo "$omh_name" +if [ -e $new_file ] +then + git reset -- $new_file $old_file + rm $new_file + git checkout $old_file +fi +echo_eval git mv $old_file $new_file +# ----------------------------------------------------------------------------- +# change old directory +old_dir=`echo $old_file | sed -e 's|/[^/]*$||'` +old_program=`echo $old_dir | sed -e 's|.*/||'` +git checkout $old_dir/CMakeLists.txt +sed -i $old_dir/CMakeLists.txt -e "/$root_name.cpp/d" +git checkout $old_dir/makefile.am +sed -i $old_dir/makefile.am -e "/$root_name.cpp/d" +git checkout $old_dir/$old_program.cpp +sed -i $old_dir/$old_program.cpp -e "/$root_name/d" +# ----------------------------------------------------------------------------- +# change new directory +git checkout $new_dir/CMakeLists.txt +sed -i $new_dir/CMakeLists.txt \ + -e "s|deprecated.cpp|&\\n $root_name.cpp|" +git checkout $new_dir/makefile.am +sed -i $new_dir/makefile.am \ + -e "s|deprecated.cpp.*|&\\n\\t$root_name.cpp \\\\|" +git checkout $new_dir/deprecated.cpp +sed -i $new_dir/deprecated.cpp \ + -e "s|bool old_mat_mul.*|&\\nextern bool $root_name(void);|" \ + -e "s|Run( old_mat_mul.*|&\\n Run( $root_name, \"$root_name\" );|" +# ----------------------------------------------------------------------------- +# file omhelp links +omh_name=`grep '$begin' $new_file | sed -e 's|$begin ||' -e 's|\$\$.*||'` +git checkout omh/example_list.omh +sed -i omh/example_list.omh -e "/$omh_name/d" +# ----------------------------------------------------------------------------- +echo 'bin/deprecate_xam.sh: OK' +exit 0 diff -Nru cppad-2018.00.00.0/bin/devel.sh cppad-2019.02.00.0/bin/devel.sh --- cppad-2018.00.00.0/bin/devel.sh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/bin/devel.sh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,31 @@ +#! /bin/bash -e +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# configuration file for tools in ~/devel. +# +# web address linked by run_omhelp.sh to the Home icon on each page. +image_link='https://coin-or.github.io/CppAD' +echo "image_link=$image_link" +# +# special files, for this repository, that the devel tools should ignore +ignore_files=' + coin.png + + makefile.in + authors + COPYING + compile + config.guess + config.sub + configure +' +echo "ignore_files=$ignore_files" diff -Nru cppad-2018.00.00.0/bin/dir_copy.sh cppad-2019.02.00.0/bin/dir_copy.sh --- cppad-2018.00.00.0/bin/dir_copy.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/dir_copy.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -#! /bin/bash -e -# $Id: dir_copy.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/dir_copy.sh" ] -then - echo "bin/dir_copy.sh: must be executed from its parent directory" - exit 1 -fi -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," - echo " direction: 'to' or 'from', and dir is a directory." - exit 1 -fi -if [ "$2" != 'from' ] && [ "$2" != 'to' ] -then - echo "bin/dir_copy.sh: invalid direction=$2" - exit 1 -fi -if [ "$2" == 'to' ] && [ ! -e "$1" ] -then - echo "bin/dir_copy.sh: can't find file_list=$1" - exit 1 -fi -if [ "$2" == 'from' ] && [ ! -e "$3/$1" ] -then - echo "bin/dir_copy.sh: can't find file_list=$3/$1" - exit 1 -fi -file_list="$1" -direction="$2" -directory="$3" -# ----------------------------------------------------------------------------- -# -if [ "$direction" == 'to' ] -then - if [ -e "$directory" ] - then - echo "bin/dir_copy.sh $file_list $direction directory=$directory" - echo "the directory already exists, remove it first." - exit 1 - fi - echo "mkdir $directory" - mkdir $directory - # - list=`cat $file_list` - for path in $list - do - sub_dir=`echo $path | sed -e 's|[^/]*$||' -e 's|/$||'` - file=`echo $path | sed -e 's|^.*/||'` - if [ ! -d "$directory/$sub_dir" ] - then - echo "mkdir -p $directory/$sub_dir" - mkdir -p $directory/$sub_dir - fi - echo "cp $path $directory/$path" - cp $path $directory/$path - done - echo "cp $file_list $directory/$file_list" - cp $file_list $directory/$file_list -else - list=`cat $directory/$file_list` - for path in $list - do - echo "cp $directory/$path $path" - cp $directory/$path $path - done -fi -# ---------------------------------------------------------------------------- -echo "$0: OK" -exit 0 diff -Nru cppad-2018.00.00.0/bin/doxyfile.sh cppad-2019.02.00.0/bin/doxyfile.sh --- cppad-2018.00.00.0/bin/doxyfile.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/doxyfile.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,26 @@ #! /bin/bash -e -# $Id: doxyfile.sh 3991 2017-12-08 14:50:56Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ ! -e "bin/doxyfile.sh" ] then - echo "bin/doxyfile.sh: must be executed from its parent directory" - exit 1 + echo "bin/doxyfile.sh: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- if [ "$3" == "" ] then - echo "usage: bin/doxyfile.sh version error_file output_directory" - echo "creates the doxygen configuration file ./doxyfile" - exit 1 + echo "usage: bin/doxyfile.sh version error_file output_directory" + echo "creates the doxygen configuration file ./doxyfile" + exit 1 fi version="$1" error_file="$2" @@ -29,7 +29,7 @@ # convert multi-line assignments to single line assignments. echo "doxygen -g doxyfile > /dev/null" doxygen -g doxyfile > /dev/null -cat << EOF > bin/doxyfile.$$ +cat << EOF > doxyfile.$$ /^[A-Z_]* *=.*\\\\$/! b end : loop N @@ -39,14 +39,14 @@ # :end EOF -sed -i doxyfile -f bin/doxyfile.$$ +sed -i doxyfile -f doxyfile.$$ # ----------------------------------------------------------------------------- -include_directory_list=`find cppad -type d | tr '\n' ' ' ` +include_directory_list=`find include/cppad -type d | tr '\n' ' ' ` # ----------------------------------------------------------------------------- # 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.$$ +echo "create doxyfile.$$" +cat << EOF > doxyfile.$$ ALWAYS_DETAILED_SEC = YES BUILTIN_STL_SUPPORT = YES ENABLE_PREPROCESSING = YES @@ -89,18 +89,17 @@ WARN_NO_PARAMDOC = YES EOF sed \ - -e 's/\t/ /g' \ - -e 's/^/s|^\\(/' \ - -e 's/ *=/ *=\\).*|\\1/' \ - -e 's/$/|/' \ - -i bin/doxyfile.$$ + -e 's/^/s|^\\(/' \ + -e 's/ *=/ *=\\).*|\\1/' \ + -e 's/$/|/' \ + -i doxyfile.$$ # # -echo "sed -f bin/doxyfile.$$ -i doxyfile" -sed -f bin/doxyfile.$$ -i doxyfile +echo "sed -f doxyfile.$$ -i doxyfile" +sed -f doxyfile.$$ -i doxyfile # -echo "rm bin/doxyfile.$$" -rm bin/doxyfile.$$ +echo "rm doxyfile.$$" +rm doxyfile.$$ # ---------------------------------------------------------------------------- echo "$0: OK" exit 0 diff -Nru cppad-2018.00.00.0/bin/epl_html2txt.py cppad-2019.02.00.0/bin/epl_html2txt.py --- cppad-2018.00.00.0/bin/epl_html2txt.py 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/epl_html2txt.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -#! /usr/bin/python -# $Id: epl_html2txt.py 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. -# ----------------------------------------------------------------------------- -# -import re # see http://docs.python.org/library/re.html -# -------------------------------------------------------------------------- -def remove_simple_cmd(cmd_start, cmd_end, text_in) : - pattern = '(.*?)' + cmd_start + '(.*?)' + cmd_end - pattern = re.compile(pattern, re.DOTALL) - text_out = '' - start = 0 - while start < len(text_in): - match = pattern.search(text_in, start) - if match == None : - text_out += text_in[start:-1] - start = len(text_in) - else : - text_out += match.group(1) + match.group(2) - start = match.end(0) - return text_out -# -------------------------------------------------------------------------- -def remove_cmd_indent_text(cmd_start, cmd_end, text_in) : - pattern = '(.*?)' + cmd_start + '(.*?)' + cmd_end - pattern = re.compile(pattern, re.DOTALL) - text_out = '' - start = 0 - while start < len(text_in): - match = pattern.search(text_in, start) - if match == None : - text_out += text_in[start:-1] - start = len(text_in) - else : - text_out += match.group(1) + '\t' - text_out += re.sub('\n', '\n\t', match.group(2) ) - start = match.end(0) - return text_out -# -------------------------------------------------------------------------- -# -file_in = open('epl-v10.html', 'rb') -data_in = file_in.read() -# -------------------------------------------------------------------------- -# Extract body -pattern = '(.*)' -match = re.search(pattern, data_in, re.DOTALL) -text = match.group(1) -# -------------------------------------------------------------------------- -text = remove_simple_cmd('', '', text) -text = remove_simple_cmd('

', '

', text) -text = remove_simple_cmd('

', '

', text) -text = remove_cmd_indent_text('

', '

', text) -# -------------------------------------------------------------------------- -data_out = text -file_out = open('epl-v10.txt', 'wb') -file_out.write(data_out) -file_out.close() - diff -Nru cppad-2018.00.00.0/bin/get_adolc.sh cppad-2019.02.00.0/bin/get_adolc.sh --- cppad-2018.00.00.0/bin/get_adolc.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/get_adolc.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,21 @@ #! /bin/bash -e -# $Id: get_adolc.sh 3730 2015-09-23 15:56:53Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # $begin get_adolc.sh$$ $newlinech #$$ # $spell -# tgz -# Adolc -# gz -# CppAD +# tgz +# Adolc +# gz +# CppAD # $$ # # $section Download and Install Adolc in Build Directory$$ @@ -54,58 +54,54 @@ # ----------------------------------------------------------------------------- if [ $0 != "bin/get_adolc.sh" ] then - echo "bin/get_adolc.sh: must be executed from its parent directory" - exit 1 + echo "bin/get_adolc.sh: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { - echo $* - eval $* + echo $* + eval $* } # ----------------------------------------------------------------------------- echo 'Download adolc to build/external and install it to build/prefix' -# ADOL-C verison 2.5.2 results in: -# adouble.h:74: error: 'badouble::badouble()' is protected -# It apprears that newer versions of adolc assume some c++11 features; see -# http://list.coin-or.org/pipermail/adol-c/2014-December/001023.html -version='2.4.1' +version='2.6.3' # assumes c++11 or higher web_page="http://www.coin-or.org/download/source/ADOL-C" 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 + echo "$installed_flag exists: Skipping get_adolc.sh" + exit 0 fi # -------------------------------------------------------------------------- if [ -e /usr/lib64 ] then - libdir='lib64' + libdir='lib64' else - libdir='lib' + libdir='lib' fi # ----------------------------------------------------------------------------- if [ ! -d build/external ] then - echo_eval mkdir -p build/external + echo_eval mkdir -p build/external fi echo_eval cd build/external # ----------------------------------------------------------------------------- if [ ! -e "ADOL-C-$version.tgz" ] then - echo_eval wget --no-check-certificate $web_page/ADOL-C-$version.tgz + echo_eval wget --no-check-certificate $web_page/ADOL-C-$version.tgz fi # ----------------------------------------------------------------------------- if [ -e "$prefix/include/adolc" ] then - echo_eval rm -r "$prefix/include/adolc" + echo_eval rm -r "$prefix/include/adolc" fi # ----------------------------------------------------------------------------- if [ ! -e ADOL-C-$version ] then - echo_eval tar -xzf ADOL-C-$version.tgz + echo_eval tar -xzf ADOL-C-$version.tgz fi echo_eval cd ADOL-C-$version # ----------------------------------------------------------------------------- @@ -113,21 +109,21 @@ # ----------------------------------------------------------------------------- if which autoconf >& /dev/null then - echo_eval autoreconf --install --force + echo_eval autoreconf --install --force fi # ----------------------------------------------------------------------------- if [ ! -e build ] then - echo_eval mkdir build + echo_eval mkdir build fi echo_eval cd build # ----------------------------------------------------------------------------- flags="--prefix=$prefix --with-colpack=$prefix --libdir=$prefix/$libdir" if [ "$system" == 'cygwin' ] then - flags="$flags --enable-static --disable-shared" + flags="$flags --enable-static --disable-shared" else - flags="$flags --enable-static --enable-shared" + flags="$flags --enable-static --enable-shared" fi # echo_eval ../configure $flags diff -Nru cppad-2018.00.00.0/bin/get_colpack.sh cppad-2019.02.00.0/bin/get_colpack.sh --- cppad-2018.00.00.0/bin/get_colpack.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/get_colpack.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,21 @@ #! /bin/bash -e -# $Id: get_colpack.sh 3834 2016-09-30 03:42:56Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # $begin get_colpack.sh$$ $newlinech #$$ # $spell -# colpack -# gz -# Col -# CppAD +# colpack +# gz +# Col +# CppAD # $$ # # $section Download and Install ColPack in Build Directory$$ @@ -50,14 +50,14 @@ # ----------------------------------------------------------------------------- if [ $0 != "bin/get_colpack.sh" ] then - echo "bin/get_colpack.sh: must be executed from its parent directory" - exit 1 + echo "bin/get_colpack.sh: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { - echo $* - eval $* + echo $* + eval $* } # ----------------------------------------------------------------------------- echo 'Download colpack to build/external and install it to build/prefix' @@ -68,54 +68,57 @@ installed_flag="build/external/colpack-${version}.installed" if [ -e "$installed_flag" ] then - echo "$installed_flag exists: Skipping get_colpack.sh" - exit 0 + echo "$installed_flag exists: Skipping get_colpack.sh" + exit 0 fi # -------------------------------------------------------------------------- if [ -e /usr/lib64 ] then - libdir='lib64' + libdir='lib64' else - libdir='lib' + libdir='lib' fi # ----------------------------------------------------------------------------- if [ ! -d build/external ] then - echo_eval mkdir -p build/external + echo_eval mkdir -p build/external fi echo_eval cd build/external # ----------------------------------------------------------------------------- if [ ! -e "ColPack-$version.tar.gz" ] then - echo_eval curl $web_page/v$version -o ColPack-$version.tar.gz + echo_eval curl $web_page/v$version -o ColPack-$version.tar.gz fi # ----------------------------------------------------------------------------- if [ ! -e ColPack-$version ] then - echo_eval tar -xzf ColPack-$version.tar.gz + echo_eval tar -xzf ColPack-$version.tar.gz + # + # patch source: newline missing at end of file in verions 1.0.10 + sed -i ColPack-$version/Recovery/RecoveryCore.h -e '$,$ s|$|\n|' fi echo_eval cd ColPack-$version # ----------------------------------------------------------------------------- if which autoconf >& /dev/null then - echo_eval libtoolize - echo_eval autoreconf --install --force + echo_eval libtoolize + echo_eval autoreconf --install --force fi # ----------------------------------------------------------------------------- # system_name=`uname | sed -e 's|\(......\).*|\1|'` if [ "$system_name" == 'CYGWIN' ] then - lib_type='--enable-static --disable-shared' - echo_eval ls -l ./configure - echo_eval chmod +x ./configure + lib_type='--enable-static --disable-shared' + echo_eval ls -l ./configure + echo_eval chmod +x ./configure else - lib_type='--enable-static --enable-shared' + lib_type='--enable-static --enable-shared' fi echo_eval ./configure \ - --prefix=$prefix \ - --libdir=$prefix/$libdir \ - $lib_type + --prefix=$prefix \ + --libdir=$prefix/$libdir \ + $lib_type # echo_eval make install # ----------------------------------------------------------------------------- diff -Nru cppad-2018.00.00.0/bin/get_eigen.sh cppad-2019.02.00.0/bin/get_eigen.sh --- cppad-2018.00.00.0/bin/get_eigen.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/get_eigen.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,20 +1,20 @@ #! /bin/bash -e -# $Id: get_eigen.sh 3918 2017-05-13 16:22:41Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # $begin get_eigen.sh$$ $newlinech #$$ # $spell -# gz -# Eigen -# CppAD +# gz +# Eigen +# CppAD # $$ # # $section Download and Install Eigen in Build Directory$$ @@ -49,14 +49,14 @@ # ----------------------------------------------------------------------------- if [ $0 != "bin/get_eigen.sh" ] then - echo "bin/get_eigen.sh: must be executed from its parent directory" - exit 1 + echo "bin/get_eigen.sh: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { - echo $* - eval $* + echo $* + eval $* } # ----------------------------------------------------------------------------- echo 'Download eigen to build/external and install it to build/prefix' @@ -67,16 +67,16 @@ installed_flag="build/external/eigen-${version}.installed" if [ -e "$installed_flag" ] then - echo "$installed_flag exists: Skipping get_eigen.sh" - exit 0 + echo "$installed_flag exists: Skipping get_eigen.sh" + exit 0 fi # ----------------------------------------------------------------------------- # determine which version of cmake to use cmake --version | sed -n \ - -e 's|[^0-9]*|.|g ' \ - -e 's|\.\([0-9]*\)\.\([0-9]*\).*|\1 * 10 + \2|' \ - -e '1,1p' \ - | bc > get_ipopt.$$ + -e 's|[^0-9]*|.|g ' \ + -e 's|\.\([0-9]*\)\.\([0-9]*\).*|\1 * 10 + \2|' \ + -e '1,1p' \ + | bc > get_ipopt.$$ cmake_version=`cat get_ipopt.$$` rm get_ipopt.$$ echo "cmake_version=$cmake_version" @@ -84,53 +84,53 @@ cmake_program='' if [ "$cmake_version" -ge '28' ] then - cmake_program='cmake' + cmake_program='cmake' else - for cmake_version in 28 29 - do - if which cmake$cmake_version >& /dev/null - then - cmake_program="cmake$cmake_version" - fi - done + for cmake_version in 28 29 + do + if which cmake$cmake_version >& /dev/null + then + cmake_program="cmake$cmake_version" + fi + done fi if [ "$cmake_program" == '' ] then - echo 'cannot find a verison of cmake that is 2.8 or higher' - exit 1 + echo 'cannot find a verison of cmake that is 2.8 or higher' + exit 1 fi # ----------------------------------------------------------------------------- if [ ! -d build/external ] then - echo_eval mkdir -p build/external + echo_eval mkdir -p build/external fi echo_eval cd build/external # ----------------------------------------------------------------------------- if [ ! -e "eigen-$version.tar.gz" ] then - echo_eval wget --no-check-certificate $web_page/$version.tar.gz - echo_eval mv $version.tar.gz eigen-$version.tar.gz + echo_eval wget --no-check-certificate $web_page/$version.tar.gz + echo_eval mv $version.tar.gz eigen-$version.tar.gz fi # ----------------------------------------------------------------------------- if [ -e eigen-eigen-* ] then - echo_eval rm -r eigen-eigen-* + echo_eval rm -r eigen-eigen-* fi if [ -e "$prefix/include/Eigen" ] then - echo_eval rm "$prefix/include/Eigen" + echo_eval rm "$prefix/include/Eigen" fi if [ ! -e eigen-$version ] then - echo_eval tar -xzf eigen-$version.tar.gz - git_name=`ls | grep eigen-eigen` - echo_eval mv $git_name eigen-$version + echo_eval tar -xzf eigen-$version.tar.gz + git_name=`ls | grep eigen-eigen` + echo_eval mv $git_name eigen-$version fi # ----------------------------------------------------------------------------- echo_eval cd eigen-$version if [ ! -e build ] then - echo_eval mkdir build + echo_eval mkdir build fi echo_eval cd build echo_eval $cmake_program .. -DCMAKE_INSTALL_PREFIX=$prefix diff -Nru cppad-2018.00.00.0/bin/get_fadbad.sh cppad-2019.02.00.0/bin/get_fadbad.sh --- cppad-2018.00.00.0/bin/get_fadbad.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/get_fadbad.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,19 @@ #! /bin/bash -e -# $Id: get_fadbad.sh 3730 2015-09-23 15:56:53Z 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. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # $begin get_fadbad.sh$$ $newlinech #$$ # $spell -# Fadbad -# CppAD +# Fadbad +# CppAD # $$ # # $section Download and Install Fadbad in Build Directory$$ @@ -45,14 +45,14 @@ # ----------------------------------------------------------------------------- if [ $0 != "bin/get_fadbad.sh" ] then - echo "bin/get_fadbad.sh: must be executed from its parent directory" - exit 1 + echo "bin/get_fadbad.sh: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { - echo $* - eval $* + echo $* + eval $* } # ----------------------------------------------------------------------------- echo 'Download fadbad to build/external and install it to build/prefix' @@ -63,32 +63,32 @@ installed_flag="build/external/fadbad-${version}.installed" if [ -e "$installed_flag" ] then - echo "$installed_flag exists: Skipping get_fadbad.sh" - exit 0 + echo "$installed_flag exists: Skipping get_fadbad.sh" + exit 0 fi # ----------------------------------------------------------------------------- if [ ! -d build/external ] then - echo_eval mkdir -p build/external + echo_eval mkdir -p build/external fi echo_eval cd build/external # ----------------------------------------------------------------------------- if [ ! -e "FADBAD++-$version.tar.gz" ] then - echo_eval wget --no-check-certificate $web_page/FADBAD++-$version.tar.gz + echo_eval wget --no-check-certificate $web_page/FADBAD++-$version.tar.gz fi if [ -e "FADBAD++" ] then - echo_eval rm -r FADBAD++ + echo_eval rm -r FADBAD++ fi echo_eval tar -xzf FADBAD++-$version.tar.gz if [ ! -e "$prefix/include" ] then - echo_eval mkdir -p "$prefix/include" + echo_eval mkdir -p "$prefix/include" fi if [ -e "$prefix/include/FADBAD++" ] then - echo_eval rm -r "$prefix/include/FADBAD++" + echo_eval rm -r "$prefix/include/FADBAD++" fi echo_eval cp -r FADBAD++ "$prefix/include/FADBAD++" # ----------------------------------------------------------------------------- diff -Nru cppad-2018.00.00.0/bin/get_ipopt.sh cppad-2019.02.00.0/bin/get_ipopt.sh --- cppad-2018.00.00.0/bin/get_ipopt.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/get_ipopt.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,20 +1,20 @@ #! /bin/bash -e -# $Id: get_ipopt.sh 3838 2016-10-10 04:24:30Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # $begin get_ipopt.sh$$ $newlinech #$$ # $spell -# tgz -# Ipopt -# CppAD +# tgz +# Ipopt +# CppAD # $$ # # $section Download and Install Ipopt in Build Directory$$ @@ -52,14 +52,14 @@ # ----------------------------------------------------------------------------- if [ $0 != "bin/get_ipopt.sh" ] then - echo "bin/get_ipopt.sh: must be executed from its parent directory" - exit 1 + echo "bin/get_ipopt.sh: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { - echo $* - eval $* + echo $* + eval $* } # ----------------------------------------------------------------------------- echo 'Download ipopt to build/external and install it to build/prefix' @@ -70,59 +70,59 @@ installed_flag="build/external/ipopt-${version}.installed" if [ -e "$installed_flag" ] then - echo "$installed_flag exists: Skipping get_ipopt.sh" - exit 0 + echo "$installed_flag exists: Skipping get_ipopt.sh" + exit 0 fi # ----------------------------------------------------------------------------- if [ ! -d build/external ] then - echo_eval mkdir -p build/external + echo_eval mkdir -p build/external fi echo_eval cd build/external # ----------------------------------------------------------------------------- if [ ! -e "Ipopt-$version.tgz" ] then - echo_eval wget --no-check-certificate "$web_page/Ipopt-$version.tgz" + echo_eval wget --no-check-certificate "$web_page/Ipopt-$version.tgz" fi if [ ! -e "Ipopt-$version" ] then - echo_eval tar -xzf Ipopt-$version.tgz + echo_eval tar -xzf Ipopt-$version.tgz fi echo_eval cd "Ipopt-$version" # ----------------------------------------------------------------------------- for file in ThirdParty/Blas/get.Blas ThirdParty/Lapack/get.Lapack do - sed -e 's|ftp:\(\/\/www.netlib.org\/\)|http:\1|' \ - -i $file + sed -e 's|ftp:\(\/\/www.netlib.org\/\)|http:\1|' \ + -i $file done # ----------------------------------------------------------------------------- if [ -e ThirdParty/HSL ] then - echo_eval rm -rf ThirdParty/HSL + echo_eval rm -rf ThirdParty/HSL fi for package in Blas Lapack Metis Mumps do - if [ ! -e "ThirdParty/$package/get.$package.done" ] - then - echo_eval cd ThirdParty/$package - echo_eval "./get.$package" - echo_eval touch "get.$package.done" - echo_eval cd ../.. - fi + if [ ! -e "ThirdParty/$package/get.$package.done" ] + then + echo_eval cd ThirdParty/$package + echo_eval "./get.$package" + echo_eval touch "get.$package.done" + echo_eval cd ../.. + fi done # ----------------------------------------------------------------------------- if [ -e /usr/lib64 ] then - libdir='lib64' + libdir='lib64' else - libdir='lib' + libdir='lib' fi export PKG_CONFIG_PATH="$prefix/$libdir/pkgconfig" echo_eval ./configure \ - --enable-debug \ - --prefix="$prefix" \ - --libdir="$prefix/$libdir" \ - coin_skip_warn_cxxflags='yes' + --enable-debug \ + --prefix="$prefix" \ + --libdir="$prefix/$libdir" \ + coin_skip_warn_cxxflags='yes' echo_eval make install # ----------------------------------------------------------------------------- echo_eval touch $cppad_dir/$installed_flag diff -Nru cppad-2018.00.00.0/bin/get_sacado.sh cppad-2019.02.00.0/bin/get_sacado.sh --- cppad-2018.00.00.0/bin/get_sacado.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/get_sacado.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,21 @@ #! /bin/bash -e -# $Id: get_sacado.sh 3945 2017-06-03 02:07:53Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # $begin get_sacado.sh$$ $newlinech #$$ # $spell -# trilinos -# gz -# Sacado -# CppAD +# trilinos +# gz +# Sacado +# CppAD # $$ # # $section Download and Install Sacado in Build Directory$$ @@ -53,14 +53,14 @@ # ----------------------------------------------------------------------------- if [ $0 != "bin/get_sacado.sh" ] then - echo "bin/get_sacado.sh: must be executed from its parent directory" - exit 1 + echo "bin/get_sacado.sh: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { - echo $* - eval $* + echo $* + eval $* } # ----------------------------------------------------------------------------- echo 'Download sacado to build/external and install it to build/prefix' @@ -72,16 +72,16 @@ installed_flag="build/external/trilinos-${version}.installed" if [ -e "$installed_flag" ] then - echo "$installed_flag exists: Skipping get_sacado.sh" - exit 0 + echo "$installed_flag exists: Skipping get_sacado.sh" + exit 0 fi # ----------------------------------------------------------------------------- # determine which version of cmake to use cmake --version | sed -n \ - -e 's|[^0-9]*|.|g ' \ - -e 's|\.\([0-9]*\)\.\([0-9]*\).*|\1 * 10 + \2|' \ - -e '1,1p' \ - | bc > get_sacado.$$ + -e 's|[^0-9]*|.|g ' \ + -e 's|\.\([0-9]*\)\.\([0-9]*\).*|\1 * 10 + \2|' \ + -e '1,1p' \ + | bc > get_sacado.$$ cmake_version=`cat get_sacado.$$` rm get_sacado.$$ echo "cmake_version=$cmake_version" @@ -89,106 +89,106 @@ cmake_program='' if [ "$cmake_version" -ge '27' ] then - cmake_program='cmake' + cmake_program='cmake' else - for cmake_version in 27 28 29 - do - if which cmake$cmake_version >& /dev/null - then - cmake_program="cmake$cmake_version" - fi - done + for cmake_version in 27 28 29 + do + if which cmake$cmake_version >& /dev/null + then + cmake_program="cmake$cmake_version" + fi + done fi if [ "$cmake_program" == '' ] then - echo 'cannot find a verison of cmake that is 2.7 or higher' - exit 1 + echo 'cannot find a verison of cmake that is 2.7 or higher' + exit 1 fi # ----------------------------------------------------------------------------- # libdir if [ -e /usr/lib64 ] then - libdir='lib64' + libdir='lib64' else - libdir='lib' + libdir='lib' fi # ----------------------------------------------------------------------------- # check if we have a local copy of coin lapack and blas libraries installed coin_lapack_blas='no' if [ -e build/prefix/$libdir/libcoinlapack.a ] then - if [ -e build/prefix/$libdir/libcoinblas.a ] - then - coin_lapack_blas='yes' - fi + if [ -e build/prefix/$libdir/libcoinblas.a ] + then + coin_lapack_blas='yes' + fi fi echo "coin_lapack_blas=$coin_lapack_blas" # ----------------------------------------------------------------------------- # change into build/external directory if [ ! -d build/external ] then - echo_eval mkdir -p build/external + echo_eval mkdir -p build/external fi echo_eval cd build/external # ----------------------------------------------------------------------------- # create the trilions source directory and change into it if [ ! -e "$trilinos_dir.tar.gz" ] then - echo_eval wget --no-check-certificate $web_page/$trilinos_dir.tar.gz + echo_eval wget --no-check-certificate $web_page/$trilinos_dir.tar.gz fi for package in Sacado Teuchos Trilinois do - echo_eval rm -rf $prefix/include/$package* + echo_eval rm -rf $prefix/include/$package* done if [ ! -e "$trilinos_dir" ] then - 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 - # ------------------------------------------------------------------------ + 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 $trilinos_dir # ----------------------------------------------------------------------------- # change into build sub-directory if [ ! -e build ] then - echo_eval mkdir build + echo_eval mkdir build fi echo_eval cd build # ----------------------------------------------------------------------------- # cmake command and install if [ "$coin_lapack_blas" == 'yes' ] then - echo_eval $cmake_program \ - -D CMAKE_BUILD_TYPE:STRING=RELEASE \ - -D Trilinos_ENABLE_Sacado:BOOL=ON \ - -D Sacado_ENABLE_TESTS:BOOL=OFF \ - -D CMAKE_INSTALL_PREFIX:PATH=$prefix \ - -D Trilinos_INSTALL_LIB_DIR=$prefix/$libdir \ - -D LAPACK_LIBRARY_NAMES:STRING=coinlapack \ - -D BLAS_LIBRARY_NAMES:STRING=coinblas \ - -D LAPACK_LIBRARY_DIRS:STRING=../prefix/$libdir \ - -D BLAS_LIBRARY_DIRS:STRING=../prefix/$libdir \ - ../ + echo_eval $cmake_program \ + -D CMAKE_BUILD_TYPE:STRING=RELEASE \ + -D Trilinos_ENABLE_Sacado:BOOL=ON \ + -D Sacado_ENABLE_TESTS:BOOL=OFF \ + -D CMAKE_INSTALL_PREFIX:PATH=$prefix \ + -D Trilinos_INSTALL_LIB_DIR=$prefix/$libdir \ + -D LAPACK_LIBRARY_NAMES:STRING=coinlapack \ + -D BLAS_LIBRARY_NAMES:STRING=coinblas \ + -D LAPACK_LIBRARY_DIRS:STRING=../prefix/$libdir \ + -D BLAS_LIBRARY_DIRS:STRING=../prefix/$libdir \ + ../ else - echo_eval $cmake_program \ - -D CMAKE_BUILD_TYPE:STRING=RELEASE \ - -D Trilinos_ENABLE_Sacado:BOOL=ON \ - -D Sacado_ENABLE_TESTS:BOOL=OFF \ - -D CMAKE_INSTALL_PREFIX:PATH=$prefix \ - -D Trilinos_INSTALL_LIB_DIR=$prefix/$libdir \ - ../ + echo_eval $cmake_program \ + -D CMAKE_BUILD_TYPE:STRING=RELEASE \ + -D Trilinos_ENABLE_Sacado:BOOL=ON \ + -D Sacado_ENABLE_TESTS:BOOL=OFF \ + -D CMAKE_INSTALL_PREFIX:PATH=$prefix \ + -D Trilinos_INSTALL_LIB_DIR=$prefix/$libdir \ + ../ fi echo_eval make install # ----------------------------------------------------------------------------- diff -Nru cppad-2018.00.00.0/bin/jenkins.sh cppad-2019.02.00.0/bin/jenkins.sh --- cppad-2018.00.00.0/bin/jenkins.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/jenkins.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,190 +0,0 @@ -#! /bin/bash -e -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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/jenkins.sh" ] -then - echo "bin/jenkins.sh: must be executed from its parent directory" - exit 1 -fi -if [ "$1" != '' ] -then - echo 'bin/jenkins.sh no longer has any arguments' - exit 1 -fi -# ----------------------------------------------------------------------------- -# distribution directory corresponding to this version of CppAD -trunk_dir=`pwd` -# ----------------------------------------------------------------------------- -# bash function that echos and executes a command -echo_eval() { - echo $* - eval $* -} -# Bash function that logs stdout, stderr, and executes a command. -# In the special case where this is an echo command, -# it just redirects the output to the log file. -log_eval() { - if [ "$1" == 'echo' ] - then - shift - if ! echo $* >> $trunk_dir/jenkins.log - then - echo_eval cat $trunk_dir/jenkins.log - echo_eval cat $trunk_dir/jenkins.err - exit 1 - fi - else - echo $* >> $trunk_dir/jenkins.log - echo $* >> $trunk_dir/jenkins.err - echo $* "1>> jenkins.log 2>> jenkins.err" - if ! eval $* 1>> $trunk_dir/jenkins.log 2>> $trunk_dir/jenkins.err - then - echo_eval cat $trunk_dir/jenkins.log - echo_eval cat $trunk_dir/jenkins.err - exit 1 - fi - fi -} -for ext in log err -do - if [ -e "$trunk_dir/jenkins.$ext" ] - then - echo_eval rm $trunk_dir/jenkins.$ext - fi -done -# -------------------------------------------------------------------------- -if [ -e /usr/lib64 ] -then - libdir='lib64' -else - libdir='lib' -fi -# ----------------------------------------------------------------------- -g++ --version -# ----------------------------------------------------------------------- -# 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 -# ------------------------------------------------------------------- -# Commented out because autotools build no longer supports sacado. -# -# 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 -# ------------------------------------------------------------------- -# something is wrong with the jenkins system or the autotools -pushd build/prefix/$libdir -for ver in 0 1 2 -do - for name in adolc ColPack - do - if [ -e "lib$name.so" ] && [ ! -e "lib$name.so.$ver" ] - then - log_eval ln -s lib$name.so lib$name.so.$ver - fi - done -done -popd -# ------------------------------------------------------------------- -system_name=`uname | sed -e 's|\(......\).*|\1|'` -if [ "$system_name" == 'CYGWIN' ] -then - export PATH="$trunk_dir/build/prefix/bin:$PATH" -else - export LD_LIBRARY_PATH="$trunk_dir/build/prefix/$libdir" -fi -# ----------------------------------------------------------------------- -# Use trunk_dir/build/autotools to build and test CppAD (no reuse) -echo_eval cd build -echo_eval rm -rf autotools -echo_eval mkdir autotools -echo_eval cd autotools -# -# configure cppad to use all the packages above -if which rpm >& /dev/null -then - build_type=`rpm --eval %{_host}` - build_type="--build=$build_type" -else - build_type='' -fi -# -# Commented out because autotools build no longer supports sacado. -# SACADO_DIR="$trunk_dir/build/prefix" \\ -# -cat << EOF -$trunk_dir/configure \\ - $build_type \\ - --disable-silent-rules \\ - ADOLC_DIR="$trunk_dir/build/prefix" \\ - EIGEN_DIR="$trunk_dir/build/prefix" \\ - IPOPT_DIR="$trunk_dir/build/prefix" \\ - FADBAD_DIR="$trunk_dir/build/prefix" \\ - CXX_FLAGS='-Wall -std=c++11' \\ - OPENMP_FLAGS=-fopenmp \\ - 1>> jenkins.log 2>> jenkins.err -EOF -if ! $trunk_dir/configure $build_type \ - --disable-silent-rules \ - ADOLC_DIR="$trunk_dir/build/prefix" \ - EIGEN_DIR="$trunk_dir/build/prefix" \ - IPOPT_DIR="$trunk_dir/build/prefix" \ - FADBAD_DIR="$trunk_dir/build/prefix" \ - CXX_FLAGS='-Wall -std=c++11' \ - OPENMP_FLAGS=-fopenmp \ - 1>> $trunk_dir/jenkins.log 2>> $trunk_dir/jenkins.err -then - echo "Error during configure command. Here is config.log file:" - echo "--------------------------------------------------------" - cat config.log - exit 1 -fi -# -# copy configure.hpp to source directory -log_eval cp cppad/configure.hpp $trunk_dir/cppad/configure.hpp -# -# compile the tests -log_eval make check -# -# run the tests -log_eval echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" -log_eval ls -l "$trunk_dir/build/prefix/$libdir" -log_eval make test -# -# print the test results on the console -echo 'copy make test output to console' -sed -n -e '/^make test$/,$p' $trunk_dir/jenkins.log -# -# make it here without an error exit -echo "jenkins.sh: OK" diff -Nru cppad-2018.00.00.0/bin/ls_files.sh cppad-2019.02.00.0/bin/ls_files.sh --- cppad-2018.00.00.0/bin/ls_files.sh 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/bin/ls_files.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -#! /bin/bash -e -# $Id$ -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. -# ----------------------------------------------------------------------------- -# list files in repository (not deleted) -# ----------------------------------------------------------------------------- -if [ $0 != "bin/ls_files.sh" ] -then - echo "bin/ls_files.sh: must be executed from its parent directory" - exit 1 -fi -# ----------------------------------------------------------------------------- -list=`git ls-files` -git ls-files -d > list_files.$$ -for file in $list -do - if ! grep "$file" list_files.$$ > /dev/null - then - echo $file - fi -done -rm list_files.$$ -# ---------------------------------------------------------------------------- -exit 0 diff -Nru cppad-2018.00.00.0/bin/new_file.sh cppad-2019.02.00.0/bin/new_file.sh --- cppad-2018.00.00.0/bin/new_file.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/new_file.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ -#! /bin/bash -eu -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 $* -} -if [ "$0" != "bin/new_file.sh" ] -then - echo "bin/new_file.sh: must be executed from its parent directory" - exit 1 -fi -# ----------------------------------------------------------------------------- -if [ "$#" != '1' ] -then - echo "bin/new_file.sh: file_name" - exit 1 -fi -file_name="$1" -if [ -e "$file_name" ] -then - echo "$file_name already exists" - exit 1 -fi -ext=`echo $file_name | sed -e 's/[^.]*\.//'` -if [ "$ext" == '' ] || [ "$ext" == "$file_name" ] -then - echo 'bin/new_file.sh: file_name does not have an extension' - exit 1 -fi -# -# ----------------------------------------------------------------------------- -case $ext in - # ------------------------------------------------------------------------- - hpp | hpp.in ) - dir=`echo $file_name | sed -e 's|/.*||'` - if [ "$dir" != 'cppad' ] || [ "$file_name" == 'cppad' ] - then - echo 'new_file.sh: file_name does not begin with cppad/' - exit 1 - fi - upper_name=`echo $file_name | tr [a-z./] [A-Z__]` - cat << EOF > $file_name -# ifndef $upper_name -# define $upper_name -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -# endif -EOF - ;; - # ------------------------------------------------------------------------- - cpp | cpp.in ) - cat << EOF > $file_name -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -EOF - ;; - # ------------------------------------------------------------------------- - cmake | txt ) - cat << EOF > $file_name -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. -# ----------------------------------------------------------------------------- -EOF - ;; - # ------------------------------------------------------------------------- - omh | omh.in ) - root_name=`echo $file_name | sed -e 's|.*/||' -e 's|\.omh.*||'` - cat << EOF > $file_name -------------------------------------------------------------------------------- - CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 $root_name\$\$ -\$spell -\$\$ - -\$section \$\$ - -\$end -EOF - ;; - # ------------------------------------------------------------------------- - sh | sh.in ) - dir=`echo $file_name | sed -e 's|/.*||'` - if [ "$dir" != 'bin' ] || [ "$file_name" == 'bin' ] - then - echo 'new_file.sh: file_name does not begin with bin/' - exit 1 - fi - cat << EOF > $file_name -#! /bin/bash -eu -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 \$* -} -# ----------------------------------------------------------------------------- -if [ "\$0" != "$file_name" ] -then - echo "$file_name: must be executed from its parent directory" - exit 1 -fi -if [ "\$#" != '?' ] -then - echo 'usage: $file_name.sh ?' -fi -# ----------------------------------------------------------------------------- -REPLACE THIS LINE, AND ? ABOVE, BY THE CODE FOR THIS SCRIPT. -# ----------------------------------------------------------------------------- -echo '$file_name: OK' -exit 0 -EOF - echo_eval chmod +x $file_name - ;; - - *) - echo bin/"new_file.sh: extension $ext is not yet supported" - exit 1 -esac -# ----------------------------------------------------------------------------- -echo_eval git add $file_name -echo 'bin/new_file.sh: OK' -exit 0 diff -Nru cppad-2018.00.00.0/bin/new_release.sh cppad-2019.02.00.0/bin/new_release.sh --- cppad-2018.00.00.0/bin/new_release.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/new_release.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,164 +1,124 @@ #! /bin/bash -e # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- -svn_repo="https://projects.coin-or.org/svn/CppAD" -stable_version="20180000" # start each stable_version at yyyy0000 +stable_version="20190200" # start each stable_version at yyyymm00 release='0' # first release for each stable version is 0 # ----------------------------------------------------------------------------- if [ "$0" != 'bin/new_release.sh' ] then - echo "bin/new_release.sh: must be executed from its parent directory" - exit 1 + echo "bin/new_release.sh: must be executed from its parent directory" + exit 1 fi # bash function that echos and executes a command echo_eval() { - echo $* - eval $* + echo $* + eval $* } # ----------------------------------------------------------------------------- +# Check that release version does not already exist +# +if git tag --list | grep "$stable_version.$release" +then + echo 'This git reference tag already exists. Delete old version ?' + echo " git tag -d $stable_version.$release" + echo " git push --delete origin $stable_version.$release" + exit 1 +fi +# ----------------------------------------------------------------------------- # master # ----------------------------------------------------------------------------- # -git checkout master branch=`git branch | grep '^\*'` if [ "$branch" != '* master' ] then - echo 'new_release.sh: cannot checkout master branch' - exit 1 + echo 'new_release.sh: cannot checkout master branch' + exit 1 fi -# Make sure version is up to date -bin/version.sh date > /dev/null -bin/version.sh copy > /dev/null # # Make sure no uncommitted changes list=`git status -s` if [ "$list" != '' ] then - echo "new_release.sh: 'git status -s' is not empty (for master branch)" - echo 'You must commit or abort changes before proceeding.' - exit 1 + echo "new_release.sh: 'git status -s' is not empty (for master branch)" + echo 'You must commit or abort changes before proceeding.' + exit 1 fi # local hash code for master local_hash=`git show-ref master | \ - grep "refs/heads/$stable_branch" | \ - sed -e "s| *refs/heads/$stable_branch||"` + grep "refs/heads/$stable_branch" | \ + sed -e "s| *refs/heads/$stable_branch||"` # # remote hash code remote_hash=`git show-ref master | \ - grep "refs/remotes/origin/$stable_branch" | \ - sed -e "s| *refs/remotes/origin/$stable_branch||"` + grep "refs/remotes/origin/$stable_branch" | \ + sed -e "s| *refs/remotes/origin/$stable_branch||"` # if [ "$local_hash" != "$remote_hash" ] then - echo 'new_release.sh: local and remote for master differ' - echo "local $stable_branch: $local_hash" - echo "remote $stable_branch: $remote_hash" - echo 'try: git push' - exit 1 + echo 'new_release.sh: local and remote for master differ' + echo "local $stable_branch: $local_hash" + echo "remote $stable_branch: $remote_hash" + echo 'try: git push' + exit 1 fi # ============================================================================= # stable branch # ============================================================================= -# Make sure local, remote and svn hash codes agree for this stable branch +# Make sure local and remote hash codes agree for this stable branch stable_branch=stable/$stable_version # # local hash code local_hash=`git show-ref $stable_branch | \ - grep "refs/heads/$stable_branch" | \ - sed -e "s| *refs/heads/$stable_branch||"` + grep "refs/heads/$stable_branch" | \ + sed -e "s| *refs/heads/$stable_branch||"` # # remote hash code remote_hash=`git show-ref $stable_branch | \ - grep "refs/remotes/origin/$stable_branch" | \ - sed -e "s| *refs/remotes/origin/$stable_branch||"` -# -# svn hash code -svn_hash='' -if svn info $svn_repo/$stable_branch >& /dev/null -then - svn_hash=`svn log $svn_repo/$stable_branch --limit 100 | \ - grep 'end *hash *code:' | head -1 | sed -e 's|end *hash *code: *||'` -fi + grep "refs/remotes/origin/$stable_branch" | \ + sed -e "s| *refs/remotes/origin/$stable_branch||"` # if [ "$local_hash" == '' ] && [ "$remote_hash" == '' ] then - echo "new_release.sh: $stable_branch does not exist" - echo "Use following command to create it ?" - echo " git checkout -b $stable_branch master" - exit 1 + echo "new_release.sh: $stable_branch does not exist" + echo "Use following command to create it ?" + echo " git checkout -b $stable_branch master" + echo " version.sh set $stable_version.$release" + echo ' version.sh copy' + echo 'Then run tests. Then commit changes.' + exit 1 fi if [ "$local_hash" == '' ] && [ "$remote_hash" != '' ] then - echo "new_release.sh: local $stable_branch does not exist." - echo " git checkout -b $stable_branch origin/$stable_branch" - exit 1 + echo "new_release.sh: local $stable_branch does not exist." + echo " git checkout -b $stable_branch origin/$stable_branch" + exit 1 fi # if [ "$remote_hash" == '' ] then - echo "new_release.sh: remote $stable_branch does not exist ?" - echo " git push origin $stable_branch" - exit 1 -fi -if [ "$svn_hash" == '' ] -then - echo "new_release.sh: svn $stable_branch does not exist." - echo "Make sure master and $stable_branch have same hash code," - echo 'then follow instructions below for push and then svn copy ?' - echo ' bin/push_git2svn.py trunk' - echo " svn copy $svn_repo/trunk \\" - echo " $svn_repo/$stable_branch" - echo "log message: Create $stable_branch from trunk at revision ?" - exit 1 + echo "new_release.sh: remote $stable_branch does not exist ?" + echo " git push origin $stable_branch" + exit 1 fi # # check local == remote if [ "$local_hash" != "$remote_hash" ] then - echo 'new_release.sh: local and remote differ for this branch' - echo "local $stable_branch: $local_hash" - echo "remote $stable_branch: $remote_hash" - echo "try: git checkout $stable_branch" - echo ' git push' - exit 1 -fi -# -# check remote == svn -if [ "$svn_hash" != "$remote_hash" ] -then - echo 'new_release.sh: remote and svn differ for this branch' - echo "remote $stable_branch: $remote_hash" - echo "svn $stable_branch: $svn_hash" - echo 'Execute the following command ?' - echo " bin/push_git2svn.py $stable_branch" - exit 1 -fi -# ----------------------------------------------------------------------------- -# Check that release version does not already exist -# -if svn list $svn_repo/releases | grep "$stable_version.$release" -then - echo "$svn_repo/releases/$stable_version.$release" - echo 'already exists. Change the assignment' - echo " release=$release" - echo 'in bin/new_release.sh to a higher release number ?' - exit 1 -fi -# -if git tag --list | grep "$stable_version.$release" -then - echo 'This git reference tag already exists. Delete old version ?' - echo " git tag -d $stable_version.$release" - echo " git push --delete origin $stable_version.$release" - exit 1 + echo 'new_release.sh: local and remote differ for this branch' + echo "local $stable_branch: $local_hash" + echo "remote $stable_branch: $remote_hash" + echo "try: git checkout $stable_branch" + echo ' git push' + exit 1 fi # ============================================================================= # stable branch @@ -167,80 +127,47 @@ branch=`git branch | grep '^\*' | sed -e 's|^\* *||'` if [ "$branch" != "$stable_branch" ] then - echo_eval git checkout $stable_branch -fi -# ----------------------------------------------------------------------------- -# make sure check_copyright.sh changes date to current, not previous, year -yy=`date +%y` -if ! grep "\\\\1-$yy *Bradley M. Bell" bin/check_copyright.sh > /dev/null -then - echo "new_release.sh: bin/check_copyright end date is not $yy" - echo "Fix it and then commit changes in $stable_version" - exit 1 + echo_eval git checkout $stable_branch fi # ----------------------------------------------------------------------------- -check_one=`bin/version.sh get` +check_one=`version.sh get` check_two=`grep "cppad-$stable_version\.$release" doc.omh \ - | sed -e 's|cppad-\([0-9.]*\):.*|\1|'` + | sed -e 's|cppad-\([0-9.]*\):.*|\1|'` if [ "$check_one" != "$check_two" ] then - echo 'bin/new_release.sh: version number is not correct ?' - echo " bin/version.sh set $stable_version.$release" - echo ' bin/version.sh check' - echo 'Then commit the changes.' - exit 1 + echo 'bin/new_release.sh: version number is not correct ?' + echo " version.sh set $stable_version.$release" + echo ' version.sh copy' + echo ' version.sh check' + echo 'Then commit the changes.' + exit 1 fi # ----------------------------------------------------------------------------- # Make sure that autotools version of makfiles is up to current version. -# Starting with 2018 will need to change command to bin/autotools.sh automake. -./build.sh automake +bin/autotools.sh automake list=`git status -s` if [ "$list" != '' ] then - echo "new_release.sh: 'git status -s' is not empty" - echo 'stable branch autotools install not up to current version' - echo 'commit the local changes.' - exit 1 + echo "new_release.sh: 'git status -s' is not empty" + echo 'stable branch autotools install not up to current version' + echo 'commit the local changes.' + exit 1 fi # ----------------------------------------------------------------------------- read -p 'All checks have passed. More testing or commit release [t/c] ?' \ - response + response if [ "$response" != 'c' ] then - echo 'Exiting for more testing of stable branch' - exit 1 + echo 'Exiting for more testing of stable branch' + exit 1 fi # ----------------------------------------------------------------------------- # tag this release # -echo_eval git tag -a \ - -m \"corresponds $svn_repo/releases/$stable_version.$release\" \ - $stable_version.$release +echo_eval git tag -a -m "created by bin/new_release.sh" \ + $stable_version.$release # echo_eval git push origin $stable_version.$release -# ----------------------------------------------------------------------------- -msg="Creating releases/$stable_version.$release" -rep_stable="$svn_repo/$stable_branch" -rep_release="$svn_repo/releases/$stable_version.$release" -echo_eval svn copy $rep_stable $rep_release -m \"$msg\" -# ----------------------------------------------------------------------------- -if [ ! -e build ] -then - echo_eval mkdir -p build -fi -echo_eval cd build -echo_eval svn checkout $svn_repo/conf conf -# -echo_eval cd conf -# -msg="Update stable and release numbers in projDesc.xml" -echo 'Settting stable and advance release in build/conf/projDesc.xml.' -sed -i projDesc.xml \ --e "/^ *> $top_srcdir/package.log - if ! eval $* >> $top_srcdir/package.log - then - echo "Error: check package.log" - exit 1 - fi -} -log_eval() { - echo $* >> $top_srcdir/package.log - if ! eval $* >> $top_srcdir/package.log - then - echo "Error: check package.log" - exit 1 - fi +include_doc='yes' +if [ "$1" != '' ] +then + if [ "$1" == '--no_doc' ] + then + include_doc='no' + else + echo 'usage: bin/package.sh [--no_doc]' + exit 1 + fi +fi +if [ "$include_doc" == 'yes' ] +then + if ! git show-ref origin/gh-pages >& /dev/null + then + echo 'bin/package.sh: git cannot find origin/gh-pages branch' + echo 'use the following command to fetch it:' + echo ' git fetch origin gh-pages' + exit 1 + fi +fi +echo_eval() { + echo $* + eval $* } -if [ -e package.log ] +# ----------------------------------------------------------------------------- +src_dir=`pwd` +version=`sed -n -e '/^SET( *cppad_version *"[0-9.]*"/p' CMakeLists.txt | \ + sed -e 's|.*"\([^"]*\)".*|\1|'` +date=`echo $version | sed -e 's|\.[0-9]*$||'` +# ----------------------------------------------------------------------------- +# doc +if [ -e 'doc' ] then - echo "rm package.log" - rm package.log + echo_eval rm -r doc fi -top_srcdir=`pwd` -# ---------------------------------------------------------------------------- -# Remove old packages and corresponding directories -echo_eval rm -rf build/cppad-* -# ---------------------------------------------------------------------------- -this_license=`\ - grep '$verbatim%' omh/appendix/license.omh | sed -e 's|$verbatim%\(...\).*|\1|'` -if [ "$this_license" == 'epl' ] -then - remove_list='gpl-3.0.txt bin/gpl_license.sh' -elif [ "$this_license" == 'gpl' ] -then - remove_list='epl-v10.txt epl-v10.html bin/gpl_license.sh' -else - echo 'bin/package.sh: cannot find license in omh/appendix/license.omh' - exit 1 +cat << EOF > $src_dir/package.$$ +/^commit/! b end +N +N +N +N +/version $date/! b end +s|\\nAuthor:.*|| +s|commit *|| +p +: end +EOF +# ----------------------------------------------------------------------------- +if [ "$include_doc" == 'yes' ] +then + # + # use gh-pages if they exist for this version + git_hash=`git log origin/gh-pages | sed -n -f $src_dir/package.$$ | head -1` + if [ "$git_hash" != '' ] + then + echo 'create ./doc' + mkdir doc + list=`git ls-tree --name-only $git_hash:doc` + for file in $list + do + git show $git_hash:doc/$file > doc/$file + done + elif which run_omhelp.sh > /dev/null + then + # omhelp is available, so build documentation for this version + echo_eval run_omhelp.sh doc + else +cat << EOF +Cannot find gh-pages documentation for this version: $version +and cannot find run_omhelp.sh on this system. + +If you wish to skip the documentation for this system use +bin/package.sh --no_doc. Otherwise, use the following steps: + +1. Use 'git log origin/gh-pages' to see which versions have docuimentation. + +2. Pick a version number and search for 'Advance to' for that version number +in output of 'git log master' and note the for that commit. + +3. Use 'git checkout ' to check the source code for that version. + +4. Use 'git show master:bin/package.sh > bin/package.sh' to get the most +recent version of bin/package.sh + +5. Re-run bin/package.sh" +EOF + rm package.$$ + exit 1 + fi fi -# ---------------------------------------------------------------------------- -## Version number check has been moved to end of git_commit.sh -## -## if this is the master, set version to today -## (This has been moved to git_commit.sh) -#branch=`git branch | grep '^\*' | sed -e 's|^\* *||'` -#if [ "$branch" == 'master' ] -#then -# bin/version.sh set -#fi -# -# make sure that version number is the same in all files -echo_log_eval bin/version.sh check -# -# Get version number and make sure all copies agree -version=`bin/version.sh get` -echo_log_eval bin/version.sh get -# ---------------------------------------------------------------------------- -# Run automated checks for the form bin/check_*.sh with a few exceptions. -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 $check -done -# ---------------------------------------------------------------------------- -# Check for doxygen errors -echo_log_eval bin/run_doxygen.sh -# ---------------------------------------------------------------------------- -# Create the package directory -package_dir="build/cppad-$version" -echo_log_eval mkdir -p $package_dir # ----------------------------------------------------------------------------- -# Source file that are coppied to the package directory -file_list=`bin/ls_files.sh` -# -# Copy the files, creating sub-directories when necessary -echo_log_eval echo "copy files to $package_dir" -for file in $file_list $other_files -do - sub_dir=`echo $file | sed -e 's|\(.*\)/[^/]*$|\1|'` - if [ "$sub_dir" != "$file" ] - then - if [ ! -e "$package_dir/$sub_dir" ] - then - log_eval mkdir -p $package_dir/$sub_dir - fi - fi - log_eval cp $file $package_dir/$file -done -echo_log_eval echo "remove certain files from $package_dir" -for file in $remove_list -do - if [ -e $package_dir/$file ] - then - echo_log_eval rm $package_dir/$file - fi -done -# ---------------------------------------------------------------------------- -# build the xml version of documentation for this distribution -echo_log_eval cd $package_dir -# -# 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' -then - echo "Missing comment expected in doc.omh" - exit 1 -fi -echo_log_eval echo "sed -i.save doc.omh ..." -sed -i.save doc.omh \ - -e '/This comment is used to remove the table below/,/$tend/d' -# -# This command creates omhelp.xml.log in current directory (and says so) -echo_log_eval echo "bin/run_omhelp.sh xml" -if ! bin/run_omhelp.sh xml -then - echo_log_eval cp omhelp.xml.log $top_srcdir/omhelp.xml.log - exit 1 -fi -# Copy the log to the directory where the package.sh command was executed -echo_log_eval cp omhelp.xml.log $top_srcdir/omhelp.xml.log -# Restore the original doc.omh -echo_log_eval mv doc.omh.save doc.omh +# change_list +cat << EOF > $src_dir/package.$$ +/^.gitignore\$/d +/^authors\$/d +/^bin\\/colpack.sh\$/d +/^coin.png\$/d +/^compile\$/d +/^config.guess\$/d +/^config.sub\$/d +/^configure\$/d +/^depcomp\$/d +/^install-sh\$/d +/^missing\$/d +/^uw_copy_040507.html\$/d +EOF +change_list=`git ls-files | sed -f $src_dir/package.$$` +rm $src_dir/package.$$ # ---------------------------------------------------------------------------- -# change back to the package parent directory and create the tarball -echo_log_eval cd .. -echo_log_eval tar -czf cppad-$version.$this_license.tgz cppad-$version -# ---------------------------------------------------------------------------- -# create gpl version of package -echo_log_eval cd $top_srcdir -if [ -e 'bin/gpl_license.sh' ] -then - if [ "$this_license" != 'epl' ] - then - echo 'package.sh: bin/gpl_license.sh found in gpl verison of source.' - exit 1 - fi - echo_log_eval bin/gpl_license.sh cppad-$version build build +# clean up old results +if [ ! -e 'build' ] +then + echo_eval mkdir build fi -# ---------------------------------------------------------------------------- -echo "$0: OK" +echo_eval rm -rf build/cppad-* +echo_eval mkdir build/cppad-$version +# ----------------------------------------------------------------------------- +# cppad-$version.tgz +git ls-files -z | xargs -0 tar -czf build/cppad-$version/tar.tgz +# ----------------------------------------------------------------------------- +# cppad-$version.tgz +echo "create build/cppad-$version.tgz" +cd build/cppad-$version +tar -xzf tar.tgz +rm tar.tgz +if [ "$include_doc" == 'yes' ] +then + cp -r ../../doc doc +fi +cd .. +tar --create cppad-$version --gzip --file=cppad-$version.tgz +rm -r cppad-$version +# --------------------------------------------------------------------------- +echo 'package.sh: OK' exit 0 diff -Nru cppad-2018.00.00.0/bin/proj_desc.py cppad-2019.02.00.0/bin/proj_desc.py --- cppad-2018.00.00.0/bin/proj_desc.py 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/proj_desc.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ -#! /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-2018.00.00.0/bin/push_git2svn.py cppad-2019.02.00.0/bin/push_git2svn.py --- cppad-2018.00.00.0/bin/push_git2svn.py 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/push_git2svn.py 2019-01-31 12:35:17.000000000 +0000 @@ -2,13 +2,13 @@ # $Id # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. # -# 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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- from __future__ import print_function # ----------------------------------------------------------------------------- @@ -23,15 +23,15 @@ usage = '\tbin/push_git2svn.py svn_branch_path\n' narg = len(sys.argv) if sys.argv[0] != 'bin/push_git2svn.py' : - msg = 'bin/push_git2svn.py must be executed from its parent directory' - sys.exit(usage + msg) + msg = 'bin/push_git2svn.py must be executed from its parent directory' + sys.exit(usage + msg) if narg != 2 : - msg = 'expected 1 but found ' + str(narg-1) + ' command line arguments' - sys.exit(usage + msg) + msg = 'expected 1 but found ' + str(narg-1) + ' command line arguments' + sys.exit(usage + msg) svn_branch_path = sys.argv[1] if svn_branch_path == 'master' : - msg = 'trunk is the svn_branch_path for the master branch' - sys.exit(usage + msg) + msg = 'trunk is the svn_branch_path for the master branch' + sys.exit(usage + msg) # ----------------------------------------------------------------------------- # some settings svn_repository = 'https://projects.coin-or.org/svn/CppAD' @@ -40,54 +40,54 @@ # ----------------------------------------------------------------------------- # some simple functions def pause(question, choice_list) : - response='' - while not response in choice_list : - print(question, end='') - response = sys.stdin.readline() - if response.endswith('\n') : - response = response[:-1] - return response + response='' + while not response in choice_list : + print(question, end='') + response = sys.stdin.readline() + if response.endswith('\n') : + response = response[:-1] + return response # def system(cmd) : - try : - output = subprocess.check_output( - cmd, - stderr=subprocess.STDOUT, - shell=True - ) - except subprocess.CalledProcessError as info : - msg = info.output - msg += '\nbin/push_git2svn.py exiting because command above failed' - sys.exit(cmd + '\n\n' + msg) - return output + try : + output = subprocess.check_output( + cmd, + stderr=subprocess.STDOUT, + shell=True + ) + except subprocess.CalledProcessError as info : + msg = info.output + msg += '\nbin/push_git2svn.py exiting because command above failed' + sys.exit(cmd + '\n\n' + msg) + return output def print_system(cmd) : - print(cmd) - try : - output = subprocess.check_output( - cmd, - stderr=subprocess.STDOUT, - shell=True - ) - except subprocess.CalledProcessError as info : - msg = info.output - msg += '\nbin/push_git2svn.py exiting because command above failed' - sys.exit(msg) - return output + print(cmd) + try : + output = subprocess.check_output( + cmd, + stderr=subprocess.STDOUT, + shell=True + ) + except subprocess.CalledProcessError as info : + msg = info.output + msg += '\nbin/push_git2svn.py exiting because command above failed' + sys.exit(msg) + return output def ignore_data(data) : - id_pattern = re.compile(r'^.*\$Id.*$', re.MULTILINE) - data = re.sub(id_pattern, '', data) - return data + id_pattern = re.compile(r'^.*\$Id.*$', re.MULTILINE) + data = re.sub(id_pattern, '', data) + return data # ----------------------------------------------------------------------------- # determine git_branch_name if svn_branch_path == 'trunk' : - git_branch_name = 'master' - git_branch_path = svn_branch_path + git_branch_name = 'master' + git_branch_path = svn_branch_path elif svn_branch_path.startswith('branches/') : - git_branch_name = svn_branch_path[len('branches/'):] - git_branch_path = svn_branch_path + git_branch_name = svn_branch_path[len('branches/'):] + git_branch_path = svn_branch_path else : - git_branch_name = svn_branch_path - git_branch_path = 'branches/' + svn_branch_path + git_branch_name = svn_branch_path + git_branch_path = 'branches/' + svn_branch_path # ----------------------------------------------------------------------------- # hash code for the git branch cmd = 'git show-ref origin/' + git_branch_name @@ -97,13 +97,13 @@ # ----------------------------------------------------------------------------- # make sure work directory exists if not os.path.isdir(work_directory) : - os.makedirs(work_directory) + os.makedirs(work_directory) # ----------------------------------------------------------------------------- # checkout svn version of directory svn_directory = work_directory + '/svn' if os.path.isdir(svn_directory) : - cmd = 'rm -rf ' + svn_directory - print_system(cmd) + cmd = 'rm -rf ' + svn_directory + print_system(cmd) cmd = 'svn checkout ' cmd += svn_repository + '/' + svn_branch_path + ' ' + svn_directory print_system(cmd) @@ -119,15 +119,15 @@ hash_pattern = re.compile('\nend hash code: *([0-9a-f]+)') match = re.search(hash_pattern, svn_log) if match : - svn_hash_code = match.group(1) + svn_hash_code = match.group(1) else : - svn_hash_code = None + svn_hash_code = None # ----------------------------------------------------------------------------- # export the git verison of the directory git_directory = work_directory + '/git' if os.path.isdir(git_directory) : - cmd = 'rm -rf ' + git_directory - print_system(cmd) + cmd = 'rm -rf ' + git_directory + print_system(cmd) cmd = 'svn export ' cmd += git_repository + '/' + git_branch_path + ' ' + git_directory print_system(cmd) @@ -137,147 +137,147 @@ 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) - svn_file_list.append( local_name ) + 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) + svn_file_list.append( local_name ) # 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 ) + 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_file_list=[] for name in git_file_list : - if not name in svn_file_list : - created_file_list.append(name) + if not name in svn_file_list : + created_file_list.append(name) # deleted_file_list=[] for name in svn_file_list : - if not name in git_file_list : - deleted_file_list.append(name) + if not name in git_file_list : + 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) + 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) + if not name in git_dir_list : + deleted_dir_list.append(name) # ----------------------------------------------------------------------------- # automated svn commands # for git_dir in created_dir_list : - cmd = 'svn mkdir ' + svn_directory + '/' + git_dir - print_system(cmd) + cmd = 'svn mkdir ' + svn_directory + '/' + git_dir + print_system(cmd) # for git_file in created_file_list : - # the original file that was copied to the git_file - original_file = None - # - # extract the directory that git_file is located in - pattern = re.compile(r'.*/([^/]*)') - git_local = re.sub(pattern, r'\1', git_file) - # - for svn_file in deleted_file_list : - svn_local = re.sub(pattern, r'\1', svn_file) - if svn_local == git_local : - original_file = svn_file - # - git_f = open(git_directory + '/' + git_file, 'rb') - git_data = git_f.read() - git_f.close() - git_data = ignore_data(git_data) - # - 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 = ignore_data(svn_data) - # - if svn_data == git_data : - original_file = svn_file - if original_file == None : - cmd = 'cp ' + git_directory + '/' + git_file + ' \\\n\t' - cmd += svn_directory + '/' + git_file - system(cmd) - cmd = 'svn add ' + svn_directory + '/' + git_file - print_system(cmd) - else : - # remove original file from deleted file list - ind = deleted_file_list.index( original_file ) - del deleted_file_list[ind] - # copy original file to new file name - cmd = 'svn move ' + svn_directory + '/' + original_file + ' \\\n\t' - cmd += svn_directory + '/' + git_file - print_system(cmd) - # replace by the git version for this file - cmd = 'cp ' + git_directory + '/' + git_file + ' \\\n\t' - cmd += svn_directory + '/' + git_file - system(cmd) - found = True + # the original file that was copied to the git_file + original_file = None + # + # extract the directory that git_file is located in + pattern = re.compile(r'.*/([^/]*)') + git_local = re.sub(pattern, r'\1', git_file) + # + for svn_file in deleted_file_list : + svn_local = re.sub(pattern, r'\1', svn_file) + if svn_local == git_local : + original_file = svn_file + # + git_f = open(git_directory + '/' + git_file, 'rb') + git_data = git_f.read() + git_f.close() + git_data = ignore_data(git_data) + # + 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 = ignore_data(svn_data) + # + if svn_data == git_data : + original_file = svn_file + if original_file == None : + cmd = 'cp ' + git_directory + '/' + git_file + ' \\\n\t' + cmd += svn_directory + '/' + git_file + system(cmd) + cmd = 'svn add ' + svn_directory + '/' + git_file + print_system(cmd) + else : + # remove original file from deleted file list + ind = deleted_file_list.index( original_file ) + del deleted_file_list[ind] + # copy original file to new file name + cmd = 'svn move ' + svn_directory + '/' + original_file + ' \\\n\t' + cmd += svn_directory + '/' + git_file + print_system(cmd) + # replace by the git version for this file + cmd = 'cp ' + git_directory + '/' + git_file + ' \\\n\t' + cmd += svn_directory + '/' + git_file + system(cmd) + found = True # 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 - print_system(cmd) + svn_file_path = svn_directory + '/' + svn_file + if os.path.isfile(svn_file_path) : + cmd = 'svn delete --force ' + svn_file_path + print_system(cmd) # for git_file in git_file_list : - do_cp = True - 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 = ignore_data(git_data) - # - svn_f = open(svn_directory + '/' + git_file, 'rb') - svn_data = svn_f.read() - svn_f.close() - 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 - system(cmd) + do_cp = True + 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 = ignore_data(git_data) + # + svn_f = open(svn_directory + '/' + git_file, 'rb') + svn_data = svn_f.read() + svn_f.close() + 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 + system(cmd) # for svn_dir in deleted_dir_list : - cmd = 'svn rm ' + svn_directory + '/' + svn_dir - print_system(cmd) + cmd = 'svn rm ' + svn_directory + '/' + svn_dir + print_system(cmd) # ----------------------------------------------------------------------------- data = 'merge to branch: ' + svn_branch_path + '\n' data += 'from repository: ' + git_repository + '\n' if svn_hash_code != None : - data += 'start hash code: ' + svn_hash_code + '\n' + data += 'start hash code: ' + svn_hash_code + '\n' else : - data += 'start hash code: missing\n' + data += 'start hash code: missing\n' data += 'end hash code: ' + git_hash_code + '\n\n' if svn_hash_code != None : - sed_cmd = "sed -e '/" + svn_hash_code + "/,$d'" - cmd = 'git log origin/' + git_branch_name + ' | ' + sed_cmd - output = system(cmd) - data += output + sed_cmd = "sed -e '/" + svn_hash_code + "/,$d'" + cmd = 'git log origin/' + git_branch_name + ' | ' + sed_cmd + output = system(cmd) + data += output log_f = open( svn_directory + '/push_git2svn.log' , 'wb') log_f.write(data) log_f.close() @@ -287,8 +287,8 @@ msg += 'If these changes are OK, execute the command:\n\t' msg += 'svn commit --file push_git2svn.log\n' if svn_hash_code != None : - msg += 'You should inspect and possibly edit push_git2svn.log' + msg += 'You should inspect and possibly edit push_git2svn.log' else : - msg += 'The start hash code could not be automatically determined.\n' - msg += 'You should edit push_git2svn.log to describe the changes.' + msg += 'The start hash code could not be automatically determined.\n' + msg += 'You should edit push_git2svn.log to describe the changes.' print(msg) diff -Nru cppad-2018.00.00.0/bin/reduce_index.py cppad-2019.02.00.0/bin/reduce_index.py --- cppad-2018.00.00.0/bin/reduce_index.py 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/reduce_index.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ -#! /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-2018.00.00.0/bin/reduce_index.sh cppad-2019.02.00.0/bin/reduce_index.sh --- cppad-2018.00.00.0/bin/reduce_index.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/reduce_index.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -#! /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-2018.00.00.0/bin/replace_html.py cppad-2019.02.00.0/bin/replace_html.py --- cppad-2018.00.00.0/bin/replace_html.py 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/replace_html.py 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,22 @@ #! /bin/python -# $Id: replace_html.py 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. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- import sys import os import re # ----------------------------------------------------------------------------- if sys.argv[0] != 'bin/replace_html.py' : - msg = 'bin/replace_html.py: must be executed from its parent directory' - sys.exit(msg) + msg = 'bin/replace_html.py: must be executed from its parent directory' + sys.exit(msg) # usage = '''\nusage: replace_html.py define_file replace_file new_file where @@ -25,32 +25,32 @@ new_file: is a copy of replace file with the replacements. The definitions are specified by: - source + source where name is any unique name, with no spaces ' ', for the replacement text and source is the replacement text. The replacement positions are specified by: - desination + desination where name refers to a defined replacement text and destination is the text that is replaced. ''' narg = len(sys.argv) if narg != 4 : - msg = '\nExpected 3 but found ' + str(narg-1) + ' command line arguments.' - sys.exit(usage + msg) + msg = '\nExpected 3 but found ' + str(narg-1) + ' command line arguments.' + sys.exit(usage + msg) define_file = sys.argv[1] replace_file = sys.argv[2] new_file = sys.argv[3] # ----------------------------------------------------------------------------- if not os.path.exists(define_file) : - msg = 'bin/replace_html.py: cannot find define_file = ' + define_file - sys.exit(msg) + msg = 'bin/replace_html.py: cannot find define_file = ' + define_file + sys.exit(msg) if not os.path.exists(replace_file) : - msg = 'bin/replace_html.py: cannot find replace_file = ' + replace_file - sys.exit(msg) + msg = 'bin/replace_html.py: cannot find replace_file = ' + replace_file + sys.exit(msg) if os.path.exists(new_file) : - msg = 'bin/replace_html.py: cannot overwrite new_file ' + new_file - sys.exit(msg) + msg = 'bin/replace_html.py: cannot overwrite new_file ' + new_file + sys.exit(msg) f_in = open(define_file, 'rb') define_data = f_in.read() f_in.close() @@ -64,56 +64,56 @@ p_end = re.compile('') start = 0 while start < len(define_data) : - rest = define_data[start : ] - next_define = p_define.search(rest) - if next_define == None : - start = len(define_data) - else : - name = next_define.group(1) - if name in define : - msg = 'bin/replace_html.py: file = ' + define_file - msg += '\ncontains two defintions for name = ' + name - sys.exit(msg) - rest = rest[ next_define.end() : ] - # - next_end = p_end.search(rest) - source = rest [ 0 : next_end.start() ] - define[name] = source - start += next_define.end() + next_end.end() - if name != next_end.group(1) : - msg = 'bin/replace_html.py: file = ' + define_file - msg += '\ndefine name = ' + name - msg += ', end name = ' + next_end.group(1) - sys.exit(msg) + rest = define_data[start : ] + next_define = p_define.search(rest) + if next_define == None : + start = len(define_data) + else : + name = next_define.group(1) + if name in define : + msg = 'bin/replace_html.py: file = ' + define_file + msg += '\ncontains two defintions for name = ' + name + sys.exit(msg) + rest = rest[ next_define.end() : ] + # + next_end = p_end.search(rest) + source = rest [ 0 : next_end.start() ] + define[name] = source + start += next_define.end() + next_end.end() + if name != next_end.group(1) : + msg = 'bin/replace_html.py: file = ' + define_file + msg += '\ndefine name = ' + name + msg += ', end name = ' + next_end.group(1) + sys.exit(msg) # ----------------------------------------------------------------------------- # create new_data: a string with the replacements made new_data = '' p_replace = re.compile('') start = 0 while start < len(replace_data) : - rest = replace_data[start : ] - next_replace = p_replace.search(rest) - if next_replace == None : - new_data += rest - start = len(replace_data) - else : - name = next_replace.group(1) - if name not in define : - msg = 'bin/replace_html.py: file = ' + define_file - msg += '\ncontains no defintions for name = ' + name - sys.exit(msg) - new_data += rest[0 : next_replace.end() ] - new_data += define[name] - # - rest = rest[ next_replace.end() : ] - next_end = p_end.search(rest) - new_data += rest[ next_end.start() : next_end.end() ] - start += next_replace.end() + next_end.end() - if name != next_end.group(1) : - msg = 'bin/replace_html.py: file = ' + replace_file - msg += '\nreplace name = ' + name - msg += ', end name = ' + next_end.group(1) - sys.exit(msg) + rest = replace_data[start : ] + next_replace = p_replace.search(rest) + if next_replace == None : + new_data += rest + start = len(replace_data) + else : + name = next_replace.group(1) + if name not in define : + msg = 'bin/replace_html.py: file = ' + define_file + msg += '\ncontains no defintions for name = ' + name + sys.exit(msg) + new_data += rest[0 : next_replace.end() ] + new_data += define[name] + # + rest = rest[ next_replace.end() : ] + next_end = p_end.search(rest) + new_data += rest[ next_end.start() : next_end.end() ] + start += next_replace.end() + next_end.end() + if name != next_end.group(1) : + msg = 'bin/replace_html.py: file = ' + replace_file + msg += '\nreplace name = ' + name + msg += ', end name = ' + next_end.group(1) + sys.exit(msg) # ----------------------------------------------------------------------------- f_out = open(new_file, 'wb') f_out.write(new_data) diff -Nru cppad-2018.00.00.0/bin/run_cmake.sh cppad-2019.02.00.0/bin/run_cmake.sh --- cppad-2018.00.00.0/bin/run_cmake.sh 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/bin/run_cmake.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,30 +1,33 @@ #! /bin/bash -e # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ ! -e "bin/run_cmake.sh" ] then - echo "bin/run_cmake.sh: must be executed from its parent directory" - exit 1 + echo "bin/run_cmake.sh: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { - echo $* - eval $* + echo $* + eval $* } # ----------------------------------------------------------------------------- +addr_t_size_t='no' verbose='no' standard='c++11' profile_speed='no' clang='no' +no_adolc='no' no_colpack='no' no_eigen='no' no_ipopt='no' @@ -33,114 +36,143 @@ debug_which='debug_all' while [ "$1" != "" ] do - if [ "$1" == '--help' ] - then - cat << EOF + if [ "$1" == '--help' ] + then + cat << EOF usage: bin/run_cmake.sh: \\ - [--help] \\ - [--verbose] \\ - [--c++98] \\ - [--profile_speed] \\ - [--callgrind] \\ - [--clang ] \\ - [--no_colpack] \\ - [--no_eigen] \\ - [--no_ipopt] \\ - [--no_documentation] \\ - [--_vector] \\ - [--debug_] + [--help] \\ + [--addr_t_size_t] \\ + [--verbose] \\ + [--c++98] \\ + [--profile_speed] \\ + [--callgrind] \\ + [--clang ] \\ + [--no_adolc] \\ + [--no_colpack] \\ + [--no_eigen] \\ + [--no_ipopt] \\ + [--no_sacado] \\ + [--no_documentation] \\ + [--_vector] \\ + [--debug_] The --help option just prints this message and exits. The value above must be one of: cppad, boost, or eigen. The value must be one of: odd, even, all, none. EOF - exit 0 - fi - case "$1" in - - --verbose) - verbose='yes' - ;; - - --c++98) - standard='c++98' - ;; - - --profile_speed) - profile_speed='yes' - ;; - - --callgrind) - callgrind='yes' - ;; - - --clang) - clang='yes' - ;; - - --no_colpack) - no_colpack='yes' - ;; - - --no_eigen) - no_eigen='yes' - ;; - - --no_ipopt) - no_ipopt='yes' - ;; - - --no_documentation) - no_documentation='yes' - ;; - - --cppad_vector) - testvector='cppad' - ;; - - --boost_vector) - testvector='boost' - ;; - - --eigen_vector) - testvector='eigen' - ;; - - --debug_odd) - debug_which='debug_odd' - ;; - - --debug_even) - debug_which='debug_even' - ;; - - --debug_all) - debug_which='debug_all' - ;; - - --debug_none) - debug_which='debug_none' - ;; - - *) - echo "$1 is an invalid option, try bin/run_cmake.sh --help" - exit 1 - esac - shift + exit 0 + fi + case "$1" in + + --addr_t_size_t) + addr_t_size_t='yes' + ;; + + --verbose) + verbose='yes' + ;; + + --c++98) + standard='c++98' + ;; + + --profile_speed) + profile_speed='yes' + ;; + + --callgrind) + callgrind='yes' + ;; + + --clang) + clang='yes' + ;; + + --no_adolc) + no_adolc='yes' + ;; + + --no_colpack) + no_colpack='yes' + ;; + + --no_eigen) + no_eigen='yes' + ;; + + --no_ipopt) + no_ipopt='yes' + ;; + + --no_sacado) + no_sacado='yes' + ;; + + --no_documentation) + no_documentation='yes' + ;; + + --cppad_vector) + testvector='cppad' + ;; + + --boost_vector) + testvector='boost' + ;; + + --eigen_vector) + testvector='eigen' + ;; + + --debug_odd) + debug_which='debug_odd' + ;; + + --debug_even) + debug_which='debug_even' + ;; + + --debug_all) + debug_which='debug_all' + ;; + + --debug_none) + debug_which='debug_none' + ;; + + *) + echo "$1 is an invalid option, try bin/run_cmake.sh --help" + exit 1 + esac + shift done # --------------------------------------------------------------------------- +if [ "$standard" == 'c++98' ] +then + if [ "$no_adolc" == 'no' ] + then + echo 'run_cmake.sh: --no_adolc required when --c++98 present' + exit 1 + fi + if [ "$no_sacado" == 'no' ] + then + echo 'run_cmake.sh: --no_sacado required when --c++98 present' + exit 1 + fi +fi +# --------------------------------------------------------------------------- if [ ! -e build ] then - echo_eval mkdir build + echo_eval mkdir build fi echo_eval cd build if [ -e CMakeCache.txt ] then - echo_eval rm CMakeCache.txt + echo_eval rm CMakeCache.txt fi if [ -e CMakeFiles ] then - echo_eval rm -r CMakeFiles + echo_eval rm -r CMakeFiles fi # --------------------------------------------------------------------------- # clean all variables in cmake cache @@ -148,8 +180,8 @@ # if [ "$verbose" == 'yes' ] then - # echo each command that make executes - cmake_args="$cmake_args -D CMAKE_VERBOSE_MAKEFILE=YES" + # echo each command that make executes + cmake_args="$cmake_args -D CMAKE_VERBOSE_MAKEFILE=YES" fi # ----------------------------------------------------------------------------- # cppad_prefix @@ -158,85 +190,100 @@ # cmake_install_includedirs if [ -d '/usr/include' ] then - cmake_args="$cmake_args -D cmake_install_includedirs=include" + cmake_args="$cmake_args -D cmake_install_includedirs=include" fi # # cmake_install_datadir if [ -d '/usr/share' ] then - cmake_args="$cmake_args -D cmake_install_datadir=share" + 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" + cmake_args="$cmake_args -D cmake_install_docdir=share/doc" fi # # cmake_install_libdirs if [ -d '/usr/lib64' ] then - cmake_args="$cmake_args -D cmake_install_libdirs='lib64;lib'" + cmake_args="$cmake_args -D cmake_install_libdirs='lib64;lib'" elif [ -d '/usr/lib' ] then - cmake_args="$cmake_args -D cmake_install_libdirs='lib;lib64'" + cmake_args="$cmake_args -D cmake_install_libdirs='lib;lib64'" fi # # {package}_prefix -package_list='fadbad adolc sacado' +package_list='fadbad' +if [ "$no_adolc" == 'no' ] +then + package_list="$package_list adolc" +fi if [ "$no_colpack" == 'no' ] then - package_list="$package_list colpack" + package_list="$package_list colpack" fi if [ "$no_eigen" == 'no' ] then - package_list="$package_list eigen" + package_list="$package_list eigen" fi if [ "$no_ipopt" == 'no' ] then - package_list="$package_list ipopt" + package_list="$package_list ipopt" +fi +if [ "$no_sacado" == 'no' ] +then + package_list="$package_list sacado" fi for package in $package_list do - dir=$HOME/prefix/$package - if [ -d "$dir" ] - then - cmake_args="$cmake_args -D ${package}_prefix=$dir" - fi + dir=$HOME/prefix/$package + if [ -d "$dir" ] + then + cmake_args="$cmake_args -D ${package}_prefix=$dir" + fi done # # cppad_cxx_flags -cppad_cxx_flags="-Wall -pedantic-errors -std=$standard -Wshadow -Wconversion" +cppad_cxx_flags="-Wall -pedantic-errors -std=$standard -Wshadow" +cppad_cxx_flags="$cppad_cxx_flags -Wfloat-conversion -Wconversion" if [ "$callgrind" == 'yes' ] then - if [ "$debug_which" != 'debug_none' ] - then - echo 'run_cmake.sh: --callgrind requires --debug_none' - exit 1 - fi - cppad_cxx_flags="$cppad_cxx_flags -g" + if [ "$debug_which" != 'debug_none' ] + then + echo 'run_cmake.sh: --callgrind requires --debug_none' + exit 1 + fi + cppad_cxx_flags="$cppad_cxx_flags -g" fi cmake_args="$cmake_args -D cppad_cxx_flags='$cppad_cxx_flags'" # # clang if [ "$clang" == 'yes' ] then - cmake_args="$cmake_args -D CMAKE_C_COMPILER=clang" - cmake_args="$cmake_args -D CMAKE_CXX_COMPILER=clang++" + cmake_args="$cmake_args -D CMAKE_C_COMPILER=clang" + 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" + cmake_args="$cmake_args -D cppad_profile_flag=-pg" fi # # simple options cmake_args="$cmake_args -D cppad_testvector=$testvector" cmake_args="$cmake_args -D cppad_debug_which=$debug_which" -cmake_args="$cmake_args -D cppad_tape_id_type='int32_t'" -cmake_args="$cmake_args -D cppad_tape_addr_type=int32_t" cmake_args="$cmake_args -D cppad_max_num_threads=48" +if [ "$addr_t_size_t" == 'yes' ] +then + cmake_args="$cmake_args -D cppad_tape_id_type='size_t'" + cmake_args="$cmake_args -D cppad_tape_addr_type=size_t" +else + cmake_args="$cmake_args -D cppad_tape_id_type='int32_t'" + cmake_args="$cmake_args -D cppad_tape_addr_type=int32_t" +fi # echo_eval cmake $cmake_args .. # diff -Nru cppad-2018.00.00.0/bin/run_doxygen.sh cppad-2019.02.00.0/bin/run_doxygen.sh --- cppad-2018.00.00.0/bin/run_doxygen.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/run_doxygen.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,19 @@ #! /bin/bash -e -# $Id: run_doxygen.sh 3853 2016-12-14 14:40:11Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ $0 != 'bin/run_doxygen.sh' ] then - echo 'bin/run_doxygen.sh: must be executed from its parent directory' - exit 1 + echo 'bin/run_doxygen.sh: must be executed from its parent directory' + exit 1 fi echo_eval() { echo $* @@ -21,15 +21,15 @@ } # ----------------------------------------------------------------------------- # run doxygen -version=`bin/version.sh get` +version=`version.sh get` error_file='doxygen.err' output_directory='doxydoc' for name in doxyfile $error_file $output_directory do - if [ -e $name ] - then - echo_eval rm -r $name - fi + if [ -e $name ] + then + echo_eval rm -r $name + fi done echo_eval mkdir doxydoc echo_eval bin/doxyfile.sh $version $error_file $output_directory @@ -40,28 +40,28 @@ # check for warnings and errors # doxygen_version=`doxygen --version | - sed -e 's|\.|*100+|' -e 's|\.|*10+|' -e 's|\..*||'` + sed -e 's|\.|*100+|' -e 's|\.|*10+|' -e 's|\..*||'` let doxygen_version=$doxygen_version if (( $doxygen_version <= 155 )) then - doxygen_version=`doxygen --version` - echo "doxygen version $doxygen_version is <= 1.5.6" - echo "Hence it is to old to check for warnings or errors." - exit 0 + doxygen_version=`doxygen --version` + echo "doxygen version $doxygen_version is <= 1.5.6" + echo "Hence it is to old to check for warnings or errors." + exit 0 fi if (( $doxygen_version == 163 )) then - doxygen_version=`doxygen --version` - echo "doxygen version $doxygen_version is == 1.6.3" - echo "Hence it has a problem with warnings about missing # defines;" - echo "see http://comments.gmane.org/gmane.text.doxygen.general/8594" - exit 0 + doxygen_version=`doxygen --version` + echo "doxygen version $doxygen_version is == 1.6.3" + echo "Hence it has a problem with warnings about missing # defines;" + echo "see http://comments.gmane.org/gmane.text.doxygen.general/8594" + exit 0 fi list=`head doxygen.err` if [ "$list" == "" ] then - echo 'run_doxygen.sh OK' - exit 0 + echo 'run_doxygen.sh OK' + exit 0 fi echo 'bin/run_doxygen.sh: Doxygen errors or warnings; see doxygen.err' echo 'run_doxygen.sh: Error' diff -Nru cppad-2018.00.00.0/bin/run_omhelp.sh cppad-2019.02.00.0/bin/run_omhelp.sh --- cppad-2018.00.00.0/bin/run_omhelp.sh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/bin/run_omhelp.sh 2019-01-31 12:35:17.000000000 +0000 @@ -2,23 +2,24 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- if [ ! -e "bin/run_omhelp.sh" ] then - echo "bin/run_omhelp.sh: must be executed from its parent directory" - exit 1 + echo "bin/run_omhelp.sh: must be executed from its parent directory" + exit 1 fi # ----------------------------------------------------------------------------- # bash function that echos and executes a command echo_eval() { - echo $* - eval $* + echo $* + eval $* } # ----------------------------------------------------------------------------- clean='no' @@ -27,51 +28,51 @@ printable='no' while [ "$1" != '' ] do - case "$1" in + case "$1" in - clean) - clean='yes' - ;; + clean) + clean='yes' + ;; - htm) - htm='yes' - ;; + htm) + htm='yes' + ;; - xml) - xml='yes' - ;; + xml) + xml='yes' + ;; - printable) - printable='yes' - ;; + printable) + printable='yes' + ;; - *) - echo "$1 is not a valid bin/run_omhelp.sh option" - exit 1 - esac - shift + *) + echo "$1 is not a valid bin/run_omhelp.sh option" + exit 1 + esac + shift done if [ "$htm" == "$xml" ] then - echo 'usage: bin/run_omhelp.sh [clean] [htm] [xml] [printable]' - echo 'order does not matter and htm or xml is present (but not both).' - exit 1 + echo 'usage: bin/run_omhelp.sh [clean] [htm] [xml] [printable]' + echo 'order does not matter and htm or xml is present (but not both).' + exit 1 fi if [ "$htm" == 'yes' ] then - ext='htm' + ext='htm' else - ext='xml' + ext='xml' fi # ----------------------------------------------------------------------------- if [ "$clean" == 'yes' ] then - echo_eval rm -rf doc + echo_eval rm -rf doc fi # if [ ! -e doc ] then - echo_eval mkdir doc + echo_eval mkdir doc fi echo_eval cd doc # ----------------------------------------------------------------------------- @@ -80,39 +81,39 @@ # if [ "$ext" == "xml" ] then - cmd="$cmd -xml" + cmd="$cmd -xml" fi if [ $printable == 'yes' ] then - cmd="$cmd -printable" + cmd="$cmd -printable" fi echo "$cmd >& omhelp.$ext.log" if ! $cmd >& ../omhelp.$ext.log then - cat ../omhelp.$ext.log - echo "OMhelp could not build doc/*.$ext documentation." - grep "^OMhelp Error:" ../omhelp.$ext.log - exit 1 + cat ../omhelp.$ext.log + echo "OMhelp could not build doc/*.$ext documentation." + grep "^OMhelp Error:" ../omhelp.$ext.log + exit 1 fi if grep "^OMhelp Warning:" ../omhelp.$ext.log then - echo "See the complete warning messages in omhelp.$ext.log." - exit 1 + echo "See the complete warning messages in omhelp.$ext.log." + exit 1 fi if [ "$printable" == 'yes' ] then - root_name='_printable' + root_name='_printable' else - root_name='cppad' + root_name='cppad' fi if [ ! -e "$root_name.$ext" ] then - echo "run_omhelp.sh: Can't make $root_name.$ext the default page." - exit 1 + echo "run_omhelp.sh: Can't make $root_name.$ext the default page." + exit 1 fi if [ -e 'index.htm' ] then - echo_eval rm index.htm + echo_eval rm index.htm fi cat << EOF > index.html - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -a11c_bthread.cpp - -

-
A Simple Boost Thread Example and Test
-
-Purpose -
-This example just demonstrates Boost threads and does not use CppAD at all. - -
-
-Source Code - - -

-# include <boost/thread.hpp>
-# include <limits>
-# include <cmath>
-# include <cassert>
-# define NUMBER_THREADS 4
-
-namespace { // Begin empty namespace
-     class worker_t
-     {
-     private:
-          int    n_;
-          float* a_;
-          float* b_;
-     public:
-          void setup(size_t n, float* a, float* b)
-          {     n_ = static_cast<int>(n);
-               a_ = a;
-               b_ = b;
-          }
-          // Beginning of Example A.1.1.1c of OpenMP 2.5 standard document
-          void a1(int n, float *a, float *b)
-          {     int i;
-               // for some reason this function is missing on some systems
-               // assert( bthread_is_multithreaded_np() > 0 );
-               for(i = 1; i < n; i++)
-                    b[i] = (a[i] + a[i-1]) / 2.0f;
-               return;
-          }
-          // End of Example A.1.1.1c of OpenMP 2.5 standard document
-          void operator()()
-          {     a1(n_, a_, b_); }
-     };
-}
-
-bool a11c(void)
-{     bool ok = true;
-
-     // Test setup
-     size_t i, j, n_total = 10;
-     float *a = new float[n_total];
-     float *b = new float[n_total];
-     for(i = 0; i < n_total; i++)
-          a[i] = float(i);
-
-     // number of threads
-     size_t number_threads = NUMBER_THREADS;
-
-     // set of workers
-     worker_t worker[NUMBER_THREADS];
-     // threads for each worker
-     boost::thread* bthread[NUMBER_THREADS];
-
-     // Break the work up into sub work for each thread
-     size_t  n     = n_total / number_threads;
-     size_t  n_tmp = n;
-     float*  a_tmp = a;
-     float*  b_tmp = b;
-     worker[0].setup(n_tmp, a_tmp, b_tmp);
-     for(j = 1; j < number_threads; j++)
-     {     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);
-
-          // create this thread
-          bthread[j] = new boost::thread(worker[j]);
-     }
-
-     // do this threads protion of the work
-     worker[0]();
-
-     // wait for other threads to finish
-     for(j = 1; j < number_threads; j++)
-     {     bthread[j]->join();
-          delete bthread[j];
-     }
-
-     // check the result
-     float eps = 100.f * std::numeric_limits<float>::epsilon();
-     for(i = 1; i < n ; i++)
-          ok &= std::fabs( (2. * b[i] - a[i] - a[i-1]) / b[i] ) <= eps;
-
-     delete [] a;
-     delete [] b;
-
-     return ok;
-}
-
-
Input File: example/multi_thread/bthread/a11c_bthread.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_a11c_bthread.cpp_xml.js cppad-2019.02.00.0/doc/_a11c_bthread.cpp_xml.js --- cppad-2018.00.00.0/doc/_a11c_bthread.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_a11c_bthread.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'a11c_bthread.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down1 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_current0 = [ -'a11c_bthread.cpp.xml#Purpose', -'a11c_bthread.cpp.xml#Source Code' -]; -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-2018.00.00.0/doc/a11c_openmp.cpp.xml cppad-2019.02.00.0/doc/a11c_openmp.cpp.xml --- cppad-2018.00.00.0/doc/a11c_openmp.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/a11c_openmp.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,154 +0,0 @@ - - - -A Simple OpenMP Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -a11c_openmp.cpp - -

-
A Simple OpenMP Example and Test
-
-Purpose -
-This example just demonstrates OpenMP and does not use CppAD at all. - -
-
-Source Code - - -

-# include <omp.h>
-# include <limits>
-# include <cmath>
-# include <cassert>
-# define NUMBER_THREADS 4
-
-namespace {
-     // Beginning of Example A.1.1.1c of OpenMP 2.5 standard document ---------
-     void a1(int n, float *a, float *b)
-     {     int i;
-     # 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]) / float(2);
-          }
-     }
-     // End of Example A.1.1.1c of OpenMP 2.5 standard document ---------------
-}
-bool a11c(void)
-{     bool ok = true;
-
-     // Test setup
-     int i, n = 1000;
-     float *a = new float[n];
-     float *b = new float[n];
-     for(i = 0; i < n; i++)
-          a[i] = float(i);
-
-     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
-
-     a1(n, a, b);
-
-     // check the result
-     float eps = float(100) * std::numeric_limits<float>::epsilon();
-     for(i = 1; i < n ; i++)
-          ok &= std::fabs( (float(2) * b[i] - a[i] - a[i-1]) / b[i] ) <= eps;
-
-     delete [] a;
-     delete [] b;
-
-     return ok;
-}
-
-
Input File: example/multi_thread/openmp/a11c_openmp.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_a11c_openmp.cpp_xml.js cppad-2019.02.00.0/doc/_a11c_openmp.cpp_xml.js --- cppad-2018.00.00.0/doc/_a11c_openmp.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_a11c_openmp.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'a11c_openmp.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down1 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_current0 = [ -'a11c_openmp.cpp.xml#Purpose', -'a11c_openmp.cpp.xml#Source Code' -]; -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-2018.00.00.0/doc/a11c_pthread.cpp.xml cppad-2019.02.00.0/doc/a11c_pthread.cpp.xml --- cppad-2018.00.00.0/doc/a11c_pthread.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/a11c_pthread.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,208 +0,0 @@ - - - -A Simple Parallel Pthread Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -a11c_pthread.cpp - -

-
A Simple Parallel Pthread Example and Test
-
-Purpose -
-This example just demonstrates pthreads and does not use CppAD at all. - -
-
-Source Code - - -

-# include <pthread.h>
-# include <limits>
-# include <cmath>
-# include <cassert>
-
-// define CPPAD_NULPTR
-# include <cppad/configure.hpp>
-# if CPPAD_USE_CPLUSPLUS_2011
-# define CPPAD_NULL nullptr
-# else
-# define CPPAD_NULL 0
-# endif
-//
-# define NUMBER_THREADS 4
-
-# ifdef NDEBUG
-# define CHECK_ZERO(expression) expression
-# else
-# define CHECK_ZERO(expression) assert( expression == 0 );
-# endif
-namespace {
-     // Beginning of Example A.1.1.1c of OpenMP 2.5 standard document ---------
-     void a1(int n, float *a, float *b)
-     {     int i;
-          // for some reason this function is missing on some systems
-          // assert( pthread_is_multithreaded_np() > 0 );
-          for(i = 1; i < n; i++)
-               b[i] = (a[i] + a[i-1]) / 2.0f;
-          return;
-     }
-     // End of Example A.1.1.1c of OpenMP 2.5 standard document ---------------
-     struct start_arg { int  n; float* a; float* b; };
-     void* start_routine(void* arg_vptr)
-     {     start_arg* arg = static_cast<start_arg*>( arg_vptr );
-          a1(arg->n, arg->a, arg->b);
-
-          void* no_status = CPPAD_NULL;
-          pthread_exit(no_status);
-
-          return no_status;
-     }
-}
-
-bool a11c(void)
-{     bool ok = true;
-
-     // Test setup
-     int i, j, n_total = 10;
-     float *a = new float[n_total];
-     float *b = new float[n_total];
-     for(i = 0; i < n_total; i++)
-          a[i] = float(i);
-
-     // number of threads
-     int n_thread = NUMBER_THREADS;
-     // the threads
-     pthread_t thread[NUMBER_THREADS];
-     // arguments to start_routine
-     struct start_arg arg[NUMBER_THREADS];
-     // attr
-     pthread_attr_t attr;
-     CHECK_ZERO( pthread_attr_init( &attr ) );
-     CHECK_ZERO( pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE) );
-     //
-     // Break the work up into sub work for each thread
-     int n = n_total / n_thread;
-     arg[0].n = n;
-     arg[0].a = a;
-     arg[0].b = b;
-     for(j = 1; j < n_thread; j++)
-     {     arg[j].n = n + 1;
-          arg[j].a = arg[j-1].a + n - 1;
-          arg[j].b = arg[j-1].b + n - 1;
-          if( j == (n_thread - 1) )
-               arg[j].n = n_total - j * n + 1;
-     }
-     for(j = 0; j < n_thread; j++)
-     {     // inform each thread of which block it is working on
-          void* arg_vptr = static_cast<void*>( &arg[j] );
-          CHECK_ZERO( pthread_create(
-               &thread[j], &attr, start_routine, arg_vptr
-          ) );
-     }
-     for(j = 0; j < n_thread; j++)
-     {     void* no_status = CPPAD_NULL;
-          CHECK_ZERO( pthread_join(thread[j], &no_status) );
-     }
-
-     // check the result
-     float eps = 100.0f * std::numeric_limits<float>::epsilon();
-     for(i = 1; i < n ; i++)
-          ok &= std::fabs( (2. * b[i] - a[i] - a[i-1]) / b[i] ) <= eps;
-
-     delete [] a;
-     delete [] b;
-
-     return ok;
-}
-
-
Input File: example/multi_thread/pthread/a11c_pthread.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_a11c_pthread.cpp_xml.js cppad-2019.02.00.0/doc/_a11c_pthread.cpp_xml.js --- cppad-2018.00.00.0/doc/_a11c_pthread.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_a11c_pthread.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'a11c_pthread.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down1 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_current0 = [ -'a11c_pthread.cpp.xml#Purpose', -'a11c_pthread.cpp.xml#Source Code' -]; -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-2018.00.00.0/doc/abort_recording.cpp.xml cppad-2019.02.00.0/doc/abort_recording.cpp.xml --- cppad-2018.00.00.0/doc/abort_recording.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/abort_recording.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,147 +0,0 @@ - - - -Abort Current Recording: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -abort_recording.cppHeadings

- - - -
Abort Current Recording: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <limits>
-
-bool abort_recording(void)
-{     bool ok = true;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-
-     using CppAD::AD;
-
-     try
-     {     // domain space vector
-          size_t n = 1;
-          CPPAD_TESTVECTOR(AD<double>) x(n);
-          x[0]     = 0.;
-
-          // declare independent variables and start tape recording
-          CppAD::Independent(x);
-
-          // simulate an error during calculation of y and the execution
-          // stream was aborted
-          throw 1;
-     }
-     catch (int e)
-     {     ok &= (e == 1);
-
-          // do this incase throw occured after the call to Independent
-          // (for case above this is known, but in general it is unknown)
-          AD<double>::abort_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<double>) x(n);
-     x[0]      = x0;
-     CppAD::Independent(x);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = 2 * x[0];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // forward computation of partials w.r.t. x[0]
-     CPPAD_TESTVECTOR(double) dx(n);
-     CPPAD_TESTVECTOR(double) dy(m);
-     dx[0] = 1.;
-     dy    = f.Forward(1, dx);
-     ok   &= CppAD::NearEqual(dy[0], 2., eps, eps);
-
-     return ok;
-}
-
-
Input File: example/general/abort_recording.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_abort_recording.cpp_xml.js cppad-2019.02.00.0/doc/_abort_recording.cpp_xml.js --- cppad-2018.00.00.0/doc/_abort_recording.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abort_recording.cpp_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', -'adfun.xml', -'record_adfun.xml', -'abort_recording.xml', -'abort_recording.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'independent.xml', -'funconstruct.xml', -'dependent.xml', -'abort_recording.xml', -'seq_property.xml' -]; -var list_down1 = [ -'abort_recording.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-2018.00.00.0/doc/abort_recording.xml cppad-2019.02.00.0/doc/abort_recording.xml --- cppad-2018.00.00.0/doc/abort_recording.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/abort_recording.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ - - - -Abort Recording of an Operation Sequence - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Abort Recording of an Operation Sequence
-
-Syntax - -
- -AD<Base>::abort_recording() - - -
-
-Purpose -
-Sometimes it is necessary to abort the recording of an operation sequence -that started with a call of the form - -
-     Independent(
x)
-
-If such a recording is currently in progress, -abort_recording will stop the recording and delete the -corresponding information. -Otherwise, abort_recording has no effect. - - -
-
-Example -
-The file -abort_recording.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/abort_recording.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_abort_recording_xml.js cppad-2019.02.00.0/doc/_abort_recording_xml.js --- cppad-2018.00.00.0/doc/_abort_recording_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abort_recording_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', -'adfun.xml', -'record_adfun.xml', -'abort_recording.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'independent.xml', -'funconstruct.xml', -'dependent.xml', -'abort_recording.xml', -'seq_property.xml' -]; -var list_down0 = [ -'abort_recording.cpp.xml' -]; -var list_current0 = [ -'abort_recording.xml#Syntax', -'abort_recording.xml#Purpose', -'abort_recording.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-2018.00.00.0/doc/abs_eval.cpp.xml cppad-2019.02.00.0/doc/abs_eval.cpp.xml --- cppad-2018.00.00.0/doc/abs_eval.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_eval.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,263 +0,0 @@ - - - -abs_eval: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -abs_eval.cpp - -

- - - -
abs_eval: Example and Test
-
-Purpose -
-The function - - -f -: -R - -3 - - -R - - - - defined by - - -f -( -x -0 - -, -x -1 - -, -x -2 - -) -= -| -x -0 - -+ -x -1 - -| -+ -| -x -1 - -+ -x -2 - -| - - -is affine, except for its absolute value terms. -For this case, the abs_normal approximation should be equal -to the function itself. - -
-
-Source - -

-# include <cppad/cppad.hpp>
-# include "abs_eval.hpp"
-
-namespace {
-     CPPAD_TESTVECTOR(double) join(
-          const CPPAD_TESTVECTOR(double)& x ,
-          const CPPAD_TESTVECTOR(double)& u )
-     {     size_t n = x.size();
-          size_t s = u.size();
-          CPPAD_TESTVECTOR(double) xu(n + s);
-          for(size_t j = 0; j < n; j++)
-               xu[j] = x[j];
-          for(size_t j = 0; j < s; j++)
-               xu[n + j] = u[j];
-          return xu;
-     }
-}
-bool abs_eval(void)
-{     bool ok = true;
-     //
-     using CppAD::AD;
-     using CppAD::ADFun;
-     //
-     typedef CPPAD_TESTVECTOR(double)       d_vector;
-     typedef CPPAD_TESTVECTOR( AD<double> ) ad_vector;
-     //
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     //
-     size_t n = 3; // size of x
-     size_t m = 1; // size of y
-     size_t s = 2; // number of absolute value terms
-     //
-     // record the function f(x)
-     ad_vector ad_x(n), ad_y(m);
-     for(size_t j = 0; j < n; j++)
-          ad_x[j] = double(j + 1);
-     Independent( ad_x );
-     // for this example, we ensure first absolute value is | x_0 + x_1 |
-     AD<double> ad_0 = abs( ad_x[0] + ad_x[1] );
-     // and second absolute value is | x_1 + x_2 |
-     AD<double> ad_1 = abs( ad_x[1] + ad_x[2] );
-     ad_y[0]         = ad_0 + ad_1;
-     ADFun<double> f(ad_x, ad_y);
-
-     // create its abs_normal representation in g, a
-     ADFun<double> g, a;
-     f.abs_normal_fun(g, a);
-
-     // check dimension of domain and range space for g
-     ok &= g.Domain() == n + s;
-     ok &= g.Range()  == m + s;
-
-     // check dimension of domain and range space for a
-     ok &= a.Domain() == n;
-     ok &= a.Range()  == s;
-
-     // --------------------------------------------------------------------
-     // Choose a point x_hat
-     d_vector x_hat(n);
-     for(size_t j = 0; j < n; j++)
-          x_hat[j] = double(j - 1);
-
-     // value of a_hat = a(x_hat)
-     d_vector a_hat = a.Forward(0, x_hat);
-
-     // (x_hat, a_hat)
-     d_vector xu_hat = join(x_hat, a_hat);
-
-     // value of g[ x_hat, a_hat ]
-     d_vector g_hat = g.Forward(0, xu_hat);
-
-     // Jacobian of g[ x_hat, a_hat ]
-     d_vector g_jac = g.Jacobian(xu_hat);
-
-     // value of delta_x
-     d_vector delta_x(n);
-     delta_x[0] =  1.0;
-     delta_x[1] = -2.0;
-     delta_x[2] = +2.0;
-
-     // value of x
-     d_vector x(n);
-     for(size_t j = 0; j < n; j++)
-          x[j] = x_hat[j] + delta_x[j];
-
-     // value of f(x)
-     d_vector y = f.Forward(0, x);
-
-     // value of g_tilde
-     d_vector g_tilde = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_x);
-
-     // should be equal because f is affine, except for abs terms
-     ok &= CppAD::NearEqual(y[0], g_tilde[0], eps99, eps99);
-
-     return ok;
-}
- -
Input File: example/abs_normal/abs_eval.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_abs_eval.cpp_xml.js cppad-2019.02.00.0/doc/_abs_eval.cpp_xml.js --- cppad-2018.00.00.0/doc/_abs_eval.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_eval.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'abs_eval.xml', -'abs_eval.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'abs_eval.cpp.xml', -'abs_eval.hpp.xml' -]; -var list_current0 = [ -'abs_eval.cpp.xml#Purpose', -'abs_eval.cpp.xml#Source' -]; -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-2018.00.00.0/doc/abs_eval.hpp.xml cppad-2019.02.00.0/doc/abs_eval.hpp.xml --- cppad-2018.00.00.0/doc/abs_eval.hpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_eval.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,181 +0,0 @@ - - - -abs_eval Source Code - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -abs_eval.hppHeadings

-
abs_eval Source Code
-
namespace CppAD { // BEGIN_CPPAD_NAMESPACE
-// BEGIN PROTOTYPE
-template <class Vector>
-Vector abs_eval(
-     size_t        n       ,
-     size_t        m       ,
-     size_t        s       ,
-     const Vector& g_hat   ,
-     const Vector& g_jac   ,
-     const Vector& delta_x )
-// END PROTOTYPE
-{     using std::fabs;
-     //
-     CPPAD_ASSERT_KNOWN(
-          size_t(delta_x.size()) == n,
-          "abs_eval: size of delta_x not equal to n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(g_hat.size()) == m + s,
-          "abs_eval: size of g_hat not equal to m + s"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(g_jac.size()) == (m + s) * (n + s),
-          "abs_eval: size of g_jac not equal to (m + s)*(n + s)"
-     );
-# ifndef NDEBUG
-     // Check that partial_u z(x, u) is strictly lower triangular
-     for(size_t i = 0; i < s; i++)
-     {     for(size_t j = i; j < s; j++)
-          {     // index in g_jac of partial of z_i w.r.t u_j
-               // (note that g_jac has n + s elements in each row)
-               size_t index = (m + i) * (n + s) + (n + j);
-               CPPAD_ASSERT_KNOWN(
-                    g_jac[index] == 0.0,
-                    "abs_eval: partial z_i w.r.t u_j non-zero for i <= j"
-               );
-          }
-     }
-# endif
-     // return value
-     Vector g_tilde(m + s);
-     //
-     // compute z_tilde, the last s components of g_tilde
-     for(size_t i = 0; i < s; i++)
-     {     // start at z_hat_i
-          g_tilde[m + i] = g_hat[m + i];
-          // contribution for change x
-          for(size_t j = 0; j < n; j++)
-          {     // index in g_jac of partial of z_i w.r.t x_j
-               size_t index = (m + i) * (n + s) + j;
-               // add contribution for delta_x_j to z_tilde_i
-               g_tilde[m + i] += g_jac[index] * delta_x[j];
-          }
-          // contribution for change in u_j for j < i
-          for(size_t j = 0; j < i; j++)
-          {     // approixmation for change in absolute value
-               double delta_a_j = fabs(g_tilde[m + j]) - fabs(g_hat[m + j]);
-               // index in g_jac of partial of z_i w.r.t u_j
-               size_t index = (m + i) * (n + s) + n + j;
-               // add constribution for delta_a_j to s_tilde_i
-               g_tilde[m + i] += g_jac[index] * delta_a_j;
-          }
-     }
-     //
-     // compute y_tilde, the first m components of g_tilde
-     for(size_t i = 0; i < m; i++)
-     {     // start at y_hat_i
-          g_tilde[i] = g_hat[i];
-          // contribution for change x
-          for(size_t j = 0; j < n; j++)
-          {     // index in g_jac of partial of y_i w.r.t x_j
-               size_t index = i * (n + s) + j;
-               // add contribution for delta_x_j to y_tilde_i
-               g_tilde[i] += g_jac[index] * delta_x[j];
-          }
-          // contribution for change in u_j
-          for(size_t j = 0; j < s; j++)
-          {     // approximation for change in absolute value
-               double delta_a_j = fabs(g_tilde[m + j]) - fabs(g_hat[m + j]);
-               // index in g_jac of partial of y_i w.r.t u_j
-               size_t index = i * (n + s) + n + j;
-               // add constribution for delta_a_j to s_tilde_i
-               g_tilde[i] += g_jac[index] * delta_a_j;
-          }
-     }
-     return g_tilde;
-}
-} // END_CPPAD_NAMESPACE
- -
Input File: example/abs_normal/abs_eval.omh - - - diff -Nru cppad-2018.00.00.0/doc/_abs_eval.hpp_xml.js cppad-2019.02.00.0/doc/_abs_eval.hpp_xml.js --- cppad-2018.00.00.0/doc/_abs_eval.hpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_eval.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'abs_eval.xml', -'abs_eval.hpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'abs_eval.cpp.xml', -'abs_eval.hpp.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-2018.00.00.0/doc/abs_eval.xml cppad-2019.02.00.0/doc/abs_eval.xml --- cppad-2018.00.00.0/doc/abs_eval.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_eval.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,414 +0,0 @@ - - - -abs_normal: Evaluate First Order Approximation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - -
abs_normal: Evaluate First Order Approximation
-
-Syntax - -
- -g_tilde = abs_eval(nmsg_hatg_jacdelta_x) - - -
-
-Prototype - -

-template <class Vector>
-Vector abs_eval(
-     size_t        n       ,
-     size_t        m       ,
-     size_t        s       ,
-     const Vector& g_hat   ,
-     const Vector& g_jac   ,
-     const Vector& delta_x )
-
-Source -
-This following is a link to the source code for this example: -abs_eval.hpp -. - -
-
-Purpose -
-Given a current that abs-normal representation at a point - - -x - -^ - -R - -n - - - -, -and a - -Δ -x - -R - -n - - - -, -this routine evaluates the abs-normal -approximation for f(x) - -where - -x -= -x - -^ -+ -Δ -x - - -. - -
-
-Vector -
-The type -Vector - is a -simple vector with elements of type double. - -
-
-f -
-We use the notation -f - for the original function; see -f -. - -
-
-n -
-This is the dimension of the domain space for -f -; see -n -. - -
-
-m -
-This is the dimension of the range space for -f -; see -m -. - -
-
-s -
-This is the number of absolute value terms in -f -; see - -
-
-g -
-We use the notation -g - for the abs-normal representation of -f -; -see g -. - -
-
-g_hat -
-This vector has size -m + s - and is the value of - -g(x, u) - at - -x -= -x - -^ - - - and - -u -= -a -( -x - -^ -) - - -. - -
-
-g_jac -
-This vector has size -(m + s) * (n + s) - and is the Jacobian of - - -g -( -x -, -u -) - - - at - -x -= -x - -^ - - - and - -u -= -a -( -x - -^ -) - - -. - -
-
-delta_x -
-This vector has size -n - and is the difference - - -Δ -x -= -x -- -x - -^ - - -, -where - -x - - - is the point that we are approximating - -f -( -x -) - - -. - -
-
-g_tilde -
-This vector has size -m + s - and is a the -first order approximation for -g - -that corresponds to the point - - -x -= -x - -^ -+ -Δ -x - - - and - -u -= -a -( -x -) - - -. - - -
-
-Example -
-The file abs_eval.cpp - contains an example and test of -abs_eval. -It returns true if the test passes and false otherwise. - - -
Input File: example/abs_normal/abs_eval.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_abs_eval_xml.js cppad-2019.02.00.0/doc/_abs_eval_xml.js --- cppad-2018.00.00.0/doc/_abs_eval_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_eval_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'abs_eval.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down0 = [ -'abs_eval.cpp.xml', -'abs_eval.hpp.xml' -]; -var list_current0 = [ -'abs_eval.xml#Syntax', -'abs_eval.xml#Prototype', -'abs_eval.xml#Source', -'abs_eval.xml#Purpose', -'abs_eval.xml#Vector', -'abs_eval.xml#f', -'abs_eval.xml#n', -'abs_eval.xml#m', -'abs_eval.xml#s', -'abs_eval.xml#g', -'abs_eval.xml#g_hat', -'abs_eval.xml#g_jac', -'abs_eval.xml#delta_x', -'abs_eval.xml#g_tilde', -'abs_eval.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-2018.00.00.0/doc/abs_get_started.cpp.xml cppad-2019.02.00.0/doc/abs_get_started.cpp.xml --- cppad-2018.00.00.0/doc/abs_get_started.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_get_started.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,418 +0,0 @@ - - - -abs_normal Getting Started: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -abs_get_started.cpp - -

- - -
abs_normal Getting Started: Example and Test
-
-Purpose -
-Creates an abs_normal - representation - -g - - - for the function - - -f -: -R - -3 - - -R - - - - defined by - - -f -( -x -0 - -, -x -1 - -, -x -2 - -) -= -| -x -0 - -+ -x -1 - -| -+ -| -x -1 - -+ -x -2 - -| - - -The corresponding -g - - -: -R - -5 - - -R - -3 - - - - is -given by - - - -g -0 - -( -x -0 - -, -x -1 - -, -x -2 - -, -u -0 - -, -u -1 - -) - -= - -u -0 - -+ -u -1 - - -= - -y -0 - -( -x -, -u -) - -g -1 - -( -x -0 - -, -x -1 - -, -x -2 - -, -u -0 - -, -u -1 - -) - -= - -x -0 - -+ -x -1 - - -= - -z -0 - -( -x -, -u -) - -g -1 - -( -x -0 - -, -x -1 - -, -x -2 - -, -u -0 - -, -u -1 - -) - -= - -x -1 - -+ -x -2 - - -= - -z -1 - -( -x -, -u -) - - - -
-Source - -

-# include <cppad/cppad.hpp>
-namespace {
-     CPPAD_TESTVECTOR(double) join(
-          const CPPAD_TESTVECTOR(double)& x ,
-          const CPPAD_TESTVECTOR(double)& u )
-     {     size_t n = x.size();
-          size_t s = u.size();
-          CPPAD_TESTVECTOR(double) xu(n + s);
-          for(size_t j = 0; j < n; j++)
-               xu[j] = x[j];
-          for(size_t j = 0; j < s; j++)
-               xu[n + j] = u[j];
-          return xu;
-     }
-}
-bool get_started(void)
-{     bool ok = true;
-     //
-     using CppAD::AD;
-     using CppAD::ADFun;
-     //
-     size_t n = 3; // size of x
-     size_t m = 1; // size of y
-     size_t s = 2; // size of u and z
-     //
-     // record the function f(x)
-     CPPAD_TESTVECTOR( AD<double> ) ax(n), ay(m);
-     for(size_t j = 0; j < n; j++)
-          ax[j] = double(j + 1);
-     Independent( ax );
-     // for this example, we ensure first absolute value is | x_0 + x_1 |
-     AD<double> a0 = abs( ax[0] + ax[1] );
-     // and second absolute value is | x_1 + x_2 |
-     AD<double> a1 = abs( ax[1] + ax[2] );
-     ay[0]         = a0 + a1;
-     ADFun<double> f(ax, ay);
-
-     // create its abs_normal representation in g, a
-     ADFun<double> g, a;
-     f.abs_normal_fun(g, a);
-
-     // check dimension of domain and range space for g
-     ok &= g.Domain() == n + s;
-     ok &= g.Range() == m + s;
-
-     // check dimension of domain and range space for a
-     ok &= a.Domain() == n;
-     ok &= a.Range() == s;
-
-     // --------------------------------------------------------------------
-     // a(x) has all the operations used to compute f(x), but the sum of the
-     // absolute values is not needed for a(x), so optimize it out.
-     size_t n_op = f.size_op();
-     ok         &= a.size_op() == n_op;
-     a.optimize();
-     ok         &= a.size_op() < n_op;
-
-     // --------------------------------------------------------------------
-     // zero order forward mode calculation using g(x, u)
-     CPPAD_TESTVECTOR(double) x(n), u(s), xu(n+s), yz(m+s);
-     for(size_t j = 0; j < n; j++)
-          x[j] = double(j + 2);
-     for(size_t j = 0; j < s; j++)
-          u[j] = double(j + n + 2);
-     xu = join(x, u);
-     yz = g.Forward(0, xu);
-
-     // check y_0(x, u)
-     double y0 = u[0] + u[1];
-     ok       &= y0 == yz[0];
-
-     // check z_0 (x, u)
-     double z0 = x[0] + x[1];
-     ok       &= z0 == yz[1];
-
-     // check z_1 (x, u)
-     double z1 = x[1] + x[2];
-     ok       &= z1 == yz[2];
-
-
-     // --------------------------------------------------------------------
-     // check that y(x, a(x) ) == f(x)
-     CPPAD_TESTVECTOR(double) y(m);
-     y  = f.Forward(0, x);  // y  = f(x)
-     u  = a.Forward(0, x);  // u  = a(x)
-     xu = join(x, u);       // xu = ( x, a(x) )
-     yz = g.Forward(0, xu); // yz = ( y(x, a(x)), z(x, a(x)) )
-     ok &= yz[0] == y[0];
-
-     return ok;
-}
- -
Input File: example/abs_normal/get_started.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_abs_get_started.cpp_xml.js cppad-2019.02.00.0/doc/_abs_get_started.cpp_xml.js --- cppad-2018.00.00.0/doc/_abs_get_started.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_get_started.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'abs_normal_fun.xml', -'abs_get_started.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'abs_get_started.cpp.xml' -]; -var list_current0 = [ -'abs_get_started.cpp.xml#Purpose', -'abs_get_started.cpp.xml#Source' -]; -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-2018.00.00.0/doc/abs_min_linear.cpp.xml cppad-2019.02.00.0/doc/abs_min_linear.cpp.xml --- cppad-2018.00.00.0/doc/abs_min_linear.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_min_linear.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,379 +0,0 @@ - - - -abs_min_linear: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -abs_min_linear.cpp - -

- - -
abs_min_linear: Example and Test
-
-Purpose -
-The function - - -f -: -R - -3 - - -R - - - - defined by - - - -f -( -x -0 - -, -x -1 - -) - -= - -| -d -0 - -- -x -0 - -| -+ -| -d -1 - -- -x -0 - -| -+ -| -d -2 - -- -x -0 - -| - - -+ - -| -d -3 - -- -x -1 - -| -+ -| -d -4 - -- -x -1 - -| -+ -| -d -5 - -- -x -1 - -| - - - - -is affine, except for its absolute value terms. -For this case, the abs_normal approximation should be equal -to the function itself. -In addition, the function is convex and -abs_min_linear - should find its global minimizer. -The minimizer of this function is - - -x -0 - -= -median - -( -d -0 - -, -d -1 - -, -d -2 - -) - - - -and - - -x -1 - -= -median - -( -d -3 - -, -d -4 - -, -d -5 - -) - - - - -
-
-Source - -

-# include <cppad/cppad.hpp>
-# include "abs_min_linear.hpp"
-
-namespace {
-     CPPAD_TESTVECTOR(double) join(
-          const CPPAD_TESTVECTOR(double)& x ,
-          const CPPAD_TESTVECTOR(double)& u )
-     {     size_t n = x.size();
-          size_t s = u.size();
-          CPPAD_TESTVECTOR(double) xu(n + s);
-          for(size_t j = 0; j < n; j++)
-               xu[j] = x[j];
-          for(size_t j = 0; j < s; j++)
-               xu[n + j] = u[j];
-          return xu;
-     }
-}
-bool abs_min_linear(void)
-{     bool ok = true;
-     //
-     using CppAD::AD;
-     using CppAD::ADFun;
-     //
-     typedef CPPAD_TESTVECTOR(size_t)       s_vector;
-     typedef CPPAD_TESTVECTOR(double)       d_vector;
-     typedef CPPAD_TESTVECTOR( AD<double> ) ad_vector;
-     //
-     size_t dpx   = 3;          // number of data points per x variable
-     size_t level = 0;          // level of tracing
-     size_t n     = 2;          // size of x
-     size_t m     = 1;          // size of y
-     size_t s     = dpx * n;    // number of data points and absolute values
-     // data points
-     d_vector  data(s);
-     for(size_t i = 0; i < s; i++)
-          data[i] = double(s - i) + 5.0 - double(i % 2) / 2.0;
-     //
-     // record the function f(x)
-     ad_vector ad_x(n), ad_y(m);
-     for(size_t j = 0; j < n; j++)
-          ad_x[j] = double(j + 1);
-     Independent( ad_x );
-     AD<double> sum = 0.0;
-     for(size_t j = 0; j < n; j++)
-          for(size_t k = 0; k < dpx; k++)
-               sum += abs( data[j * dpx + k] - ad_x[j] );
-     ad_y[0] = sum;
-     ADFun<double> f(ad_x, ad_y);
-
-     // create its abs_normal representation in g, a
-     ADFun<double> g, a;
-     f.abs_normal_fun(g, a);
-
-     // check dimension of domain and range space for g
-     ok &= g.Domain() == n + s;
-     ok &= g.Range()  == m + s;
-
-     // check dimension of domain and range space for a
-     ok &= a.Domain() == n;
-     ok &= a.Range()  == s;
-
-     // --------------------------------------------------------------------
-     // Choose a point x_hat
-     d_vector x_hat(n);
-     for(size_t j = 0; j < n; j++)
-          x_hat[j] = double(0.0);
-
-     // value of a_hat = a(x_hat)
-     d_vector a_hat = a.Forward(0, x_hat);
-
-     // (x_hat, a_hat)
-     d_vector xu_hat = join(x_hat, a_hat);
-
-     // value of g[ x_hat, a_hat ]
-     d_vector g_hat = g.Forward(0, xu_hat);
-
-     // Jacobian of g[ x_hat, a_hat ]
-     d_vector g_jac = g.Jacobian(xu_hat);
-
-     // trust region bound (make large enough to include solutuion)
-     d_vector bound(n);
-     for(size_t j = 0; j < n; j++)
-          bound[j] = 10.0;
-
-     // convergence criteria
-     d_vector epsilon(2);
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     epsilon[0]   = eps99;
-     epsilon[1]   = eps99;
-
-     // maximum number of iterations
-     s_vector maxitr(2);
-     maxitr[0] = 10; // maximum number of abs_min_linear iterations
-     maxitr[1] = 35; // maximum number of qp_interior iterations
-
-     // minimize the approxiamtion for f, which is equal to f because
-     // f is affine, except for absolute value terms
-     d_vector delta_x(n);
-     ok &= CppAD::abs_min_linear(
-          level, n, m, s, g_hat, g_jac, bound, epsilon, maxitr, delta_x
-     );
-
-     // number of data points per variable is odd
-     ok &= dpx % 2 == 1;
-
-     // check that the solution is the median of the corresponding data`
-     for(size_t j = 0; j < n; j++)
-     {     // data[j * dpx + 0] , ... , data[j * dpx + dpx - 1] corresponds to x[j]
-          // the median of this data has index j * dpx + dpx / 2
-          size_t j_median = j * dpx + (dpx / 2);
-          //
-          ok &= CppAD::NearEqual( delta_x[j], data[j_median], eps99, eps99 );
-     }
-
-     return ok;
-}
- -
Input File: example/abs_normal/abs_min_linear.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_abs_min_linear.cpp_xml.js cppad-2019.02.00.0/doc/_abs_min_linear.cpp_xml.js --- cppad-2018.00.00.0/doc/_abs_min_linear.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_min_linear.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'abs_min_linear.xml', -'abs_min_linear.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'abs_min_linear.cpp.xml', -'abs_min_linear.hpp.xml' -]; -var list_current0 = [ -'abs_min_linear.cpp.xml#Purpose', -'abs_min_linear.cpp.xml#Source' -]; -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-2018.00.00.0/doc/abs_min_linear.hpp.xml cppad-2019.02.00.0/doc/abs_min_linear.hpp.xml --- cppad-2018.00.00.0/doc/abs_min_linear.hpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_min_linear.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,331 +0,0 @@ - - - -abs_min_linear Source Code - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -abs_min_linear.hppHeadings

-
abs_min_linear Source Code
-
namespace CppAD { // BEGIN_CPPAD_NAMESPACE
-
-// BEGIN PROTOTYPE
-template <class DblVector, class SizeVector>
-bool abs_min_linear(
-     size_t            level   ,
-     size_t            n       ,
-     size_t            m       ,
-     size_t            s       ,
-     const DblVector&  g_hat   ,
-     const DblVector&  g_jac   ,
-     const DblVector&  bound   ,
-     const DblVector&  epsilon ,
-     const SizeVector& maxitr  ,
-     DblVector&        delta_x )
-// END PROTOTYPE
-{     using std::fabs;
-     bool ok    = true;
-     double inf = std::numeric_limits<double>::infinity();
-     //
-     CPPAD_ASSERT_KNOWN(
-          level <= 4,
-          "abs_min_linear: level is not less that or equal 4"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(epsilon.size()) == 2,
-          "abs_min_linear: size of epsilon not equal to 2"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(maxitr.size()) == 2,
-          "abs_min_linear: size of maxitr not equal to 2"
-     );
-     CPPAD_ASSERT_KNOWN(
-          m == 1,
-          "abs_min_linear: m is not equal to 1"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(delta_x.size()) == n,
-          "abs_min_linear: size of delta_x not equal to n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(bound.size()) == n,
-          "abs_min_linear: size of bound not equal to n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(g_hat.size()) == m + s,
-          "abs_min_linear: size of g_hat not equal to m + s"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(g_jac.size()) == (m + s) * (n + s),
-          "abs_min_linear: size of g_jac not equal to (m + s)*(n + s)"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(bound.size()) == n,
-          "abs_min_linear: size of bound is not equal to n"
-     );
-     if( level > 0 )
-     {     std::cout << "start abs_min_linear\n";
-          CppAD::abs_print_mat("bound", n, 1, bound);
-          CppAD::abs_print_mat("g_hat", m + s, 1, g_hat);
-          CppAD::abs_print_mat("g_jac", m + s, n + s, g_jac);
-
-     }
-     // partial y(x, u) w.r.t x (J in reference)
-     DblVector py_px(n);
-     for(size_t j = 0; j < n; j++)
-          py_px[ j ] = g_jac[ j ];
-     //
-     // partial y(x, u) w.r.t u (Y in reference)
-     DblVector py_pu(s);
-     for(size_t j = 0; j < s; j++)
-          py_pu[ j ] = g_jac[ n + j ];
-     //
-     // partial z(x, u) w.r.t x (Z in reference)
-     DblVector pz_px(s * n);
-     for(size_t i = 0; i < s; i++)
-     {     for(size_t j = 0; j < n; j++)
-          {     pz_px[ i * n + j ] = g_jac[ (n + s) * (i + m) + j ];
-          }
-     }
-     // partial z(x, u) w.r.t u (L in reference)
-     DblVector pz_pu(s * s);
-     for(size_t i = 0; i < s; i++)
-     {     for(size_t j = 0; j < s; j++)
-          {     pz_pu[ i * s + j ] = g_jac[ (n + s) * (i + m) + n + j ];
-          }
-     }
-     // initailize delta_x
-     for(size_t j = 0; j < n; j++)
-          delta_x[j] = 0.0;
-     //
-     // value of approximation for g(x, u) at current delta_x
-     DblVector g_tilde = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_x);
-     //
-     // value of sigma at delta_x = 0; i.e., sign( z(x, u) )
-     CppAD::vector<double> sigma(s);
-     for(size_t i = 0; i < s; i++)
-          sigma[i] = CppAD::sign( g_tilde[m + i] );
-     //
-     // current set of cutting planes
-     DblVector C(maxitr[0] * n), c(maxitr[0]);
-     //
-     //
-     size_t n_plane = 0;
-     for(size_t itr = 0; itr < maxitr[0]; itr++)
-     {
-          // Equation (5), Propostion 3.1 of reference
-          // dy_dx = py_px + py_pu * Sigma * (I - pz_pu * Sigma)^-1 * pz_px
-          //
-          // tmp_ss = I - pz_pu * Sigma
-          DblVector tmp_ss(s * s);
-          for(size_t i = 0; i < s; i++)
-          {     for(size_t j = 0; j < s; j++)
-                    tmp_ss[i * s + j] = - pz_pu[i * s + j] * sigma[j];
-               tmp_ss[i * s + i] += 1.0;
-          }
-          // tmp_sn = (I - pz_pu * Sigma)^-1 * pz_px
-          double logdet;
-          DblVector tmp_sn(s * n);
-          LuSolve(s, n, tmp_ss, pz_px, tmp_sn, logdet);
-          //
-          // tmp_sn = Sigma * (I - pz_pu * Sigma)^-1 * pz_px
-          for(size_t i = 0; i < s; i++)
-          {     for(size_t j = 0; j < n; j++)
-                    tmp_sn[i * n + j] *= sigma[i];
-          }
-          // dy_dx = py_px + py_pu * Sigma * (I - pz_pu * Sigma)^-1 * pz_px
-          DblVector dy_dx(n);
-          for(size_t j = 0; j < n; j++)
-          {     dy_dx[j] = py_px[j];
-               for(size_t k = 0; k < s; k++)
-                    dy_dx[j] += py_pu[k] * tmp_sn[ k * n + j];
-          }
-          //
-          // check for case where derivative of hyperplane is zero
-          // (in convex case, this is the minimizer)
-          bool near_zero = true;
-          for(size_t j = 0; j < n; j++)
-               near_zero &= std::fabs( dy_dx[j] ) < epsilon[1];
-          if( near_zero )
-          {     if( level > 0 )
-                    std::cout << "end abs_min_linear: local derivative near zero\n";
-               return true;
-          }
-
-          // value of hyperplane at delta_x
-          double plane_at_zero = g_tilde[0];
-          // value of hyperplane at 0
-          for(size_t j = 0; j < n; j++)
-               plane_at_zero -= dy_dx[j] * delta_x[j];
-          //
-          // add a cutting plane with value g_tilde[0] at delta_x
-          // and derivative dy_dx
-          c[n_plane] = plane_at_zero;
-          for(size_t j = 0; j < n; j++)
-               C[n_plane * n + j] = dy_dx[j];
-          ++n_plane;
-          //
-          // variables for cutting plane problem are (dx, w)
-          // c[i] + C[i,:]*dx <= w
-          DblVector b_box(n_plane), A_box(n_plane * (n + 1));
-          for(size_t i = 0; i < n_plane; i++)
-          {     b_box[i] = c[i];
-               for(size_t j = 0; j < n; j++)
-                    A_box[i * (n+1) + j] = C[i * n + j];
-               A_box[i *(n+1) + n] = -1.0;
-          }
-          // w is the objective
-          DblVector c_box(n + 1);
-          for(size_t i = 0; i < size_t(c_box.size()); i++)
-               c_box[i] = 0.0;
-          c_box[n] = 1.0;
-          //
-          // d_box
-          DblVector d_box(n+1);
-          for(size_t j = 0; j < n; j++)
-               d_box[j] = bound[j];
-          d_box[n] = inf;
-          //
-          // solve the cutting plane problem
-          DblVector xout_box(n + 1);
-          size_t level_box = 0;
-          if( level > 0 )
-               level_box = level - 1;
-          ok &= CppAD::lp_box(
-               level_box,
-               A_box,
-               b_box,
-               c_box,
-               d_box,
-               maxitr[1],
-               xout_box
-          );
-          if( ! ok )
-          {     if( level > 0 )
-               {     CppAD::abs_print_mat("delta_x", n, 1, delta_x);
-                    std::cout << "end abs_min_linear: lp_box failed\n";
-               }
-               return false;
-          }
-          //
-          // check for convergence
-          double max_diff = 0.0;
-          for(size_t j = 0; j < n; j++)
-          {     double diff = delta_x[j] - xout_box[j];
-               max_diff    = std::max( max_diff, std::fabs(diff) );
-          }
-          //
-          // check for descent in value of approximation objective
-          DblVector delta_new(n);
-          for(size_t j = 0; j < n; j++)
-               delta_new[j] = xout_box[j];
-          DblVector g_new = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_new);
-          if( level > 0 )
-          {     std::cout << "itr = " << itr << ", max_diff = " << max_diff
-                    << ", y_cur = " << g_tilde[0] << ", y_new = " << g_new[0]
-                    << "\n";
-               CppAD::abs_print_mat("delta_new", n, 1, delta_new);
-          }
-          //
-          g_tilde = g_new;
-          delta_x = delta_new;
-          //
-          // value of sigma at new delta_x; i.e., sign( z(x, u) )
-          for(size_t i = 0; i < s; i++)
-               sigma[i] = CppAD::sign( g_tilde[m + i] );
-          //
-          if( max_diff < epsilon[0] )
-          {     if( level > 0 )
-                    std::cout << "end abs_min_linear: change in delta_x near zero\n";
-               return true;
-          }
-     }
-     if( level > 0 )
-          std::cout << "end abs_min_linear: maximum number of iterations exceeded\n";
-     return false;
-}
-} // END_CPPAD_NAMESPACE
- -
Input File: example/abs_normal/abs_min_linear.omh - - - diff -Nru cppad-2018.00.00.0/doc/_abs_min_linear.hpp_xml.js cppad-2019.02.00.0/doc/_abs_min_linear.hpp_xml.js --- cppad-2018.00.00.0/doc/_abs_min_linear.hpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_min_linear.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'abs_min_linear.xml', -'abs_min_linear.hpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'abs_min_linear.cpp.xml', -'abs_min_linear.hpp.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-2018.00.00.0/doc/abs_min_linear.xml cppad-2019.02.00.0/doc/abs_min_linear.xml --- cppad-2018.00.00.0/doc/abs_min_linear.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_min_linear.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,850 +0,0 @@ - - - -abs_normal: Minimize a Linear Abs-normal Approximation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
abs_normal: Minimize a Linear Abs-normal Approximation
-
-Syntax - -
- -ok = abs_min_linear(
-     
levelnms,
-     
g_hatg_jacboundepsilonmaxitrdelta_x
-)
- - -
-
-Prototype - -

-template <class DblVector, class SizeVector>
-bool abs_min_linear(
-     size_t            level   ,
-     size_t            n       ,
-     size_t            m       ,
-     size_t            s       ,
-     const DblVector&  g_hat   ,
-     const DblVector&  g_jac   ,
-     const DblVector&  bound   ,
-     const DblVector&  epsilon ,
-     const SizeVector& maxitr  ,
-     DblVector&        delta_x )
-
-Source -
-This following is a link to the source code for this example: -abs_min_linear.hpp -. - -
-
-Purpose -
-We are given a point - -x - -^ - -R - -n - - - - and -use the notation - -f - -˜ -( -x -) - - - for the abs-normal -approximation for f(x) - -near - -x - -^ - - -. -We are also given a vector - -b - -R - -+ -n - - - -. -This routine solves the problem - - - -minimize - - -f - -˜ -( -x -) - -w -. -r -. -t - - -x - -R - -n - - -subject - -to - - -| -x -j - -- -x - -^ -j - -| - -b -j - - -j -= -0 -, - -, -n --1 - - - -
-DblVector -
-is a SimpleVector - class with elements of type double. - -
-
-SizeVector -
-is a SimpleVector - class with elements of type size_t. - -
-
-f -
-We use the notation -f - for the original function; see -f -. - -
-
-level -
-This value is less that or equal 4. -If -level == 0 -, -no tracing of the optimization is printed. -If -level >= 1 -, -a trace of each iteration of abs_min_linear is printed. -If -level >= 2 -, -a trace of the lp_box - sub-problem is printed. -If -level >= 3 -, -a trace of the objective and primal variables - -x - - - are printed -at each simplex_method - iteration. -If -level == 4 -, -the simplex tableau is printed at each simplex iteration. - -
-
-n -
-This is the dimension of the domain space for -f -; see -n -. - -
-
-m -
-This is the dimension of the range space for -f -; see -m -. This must be one so that - -f - - - -is an objective function. - -
-
-s -
-This is the number of absolute value terms in -f -; see -s -. - -
-
-g -
-We use the notation -g - for the abs-normal representation of -f -; -see g -. - -
-
-g_hat -
-This vector has size -m + s - and is the value of - -g(x, u) - at - -x -= -x - -^ - - - and - -u -= -a -( -x - -^ -) - - -. - -
-
-g_jac -
-This vector has size -(m + s) * (n + s) - and is the Jacobian of - - -g -( -x -, -u -) - - - at - -x -= -x - -^ - - - and - -u -= -a -( -x - -^ -) - - -. - -
-
-bound -
-This vector has size -n - -and we denote its value by - -b - -R - -n - - - -. -The trust region is defined as the set of - -x - - - such that - - -| -x -j - -- -x - -^ -j - -| - -b -j - - - -for - -j -= -0 -, - -, -n --1 - - -, -where - -x - - - is the point that we are approximating - -f -( -x -) - - -. - - -
-
-epsilon -
-The value -epsilon[0] - is convergence criteria in terms -of the infinity norm of the difference of -delta_x - -between iterations. -The value -epsilon[1] - is convergence criteria in terms -of the derivative of the objective; i.e., - -f - -˜ -( -x -) - - -. - -
-
-maxitr -
-This is a vector with size 2. -The value -maxitr[0] - is the maximum number of -abs_min_linear iterations to try before giving up on convergence. -The value -maxitr[1] - is the maximum number of iterations in -the simplex_method - sub-problems. - -
-
-delta_x -
-This vector - -Δ -x - - - has size -n -. -The input value of its elements does not matter. -Upon return, -the approximate minimizer of - -f - -˜ -( -x -) - - - -with respect to the trust region -is - -x -= -x - -^ -+ -Δ -x - - -. - -
-
-Method - - -
-
-sigma -
-We use the notation - - -σ -( -x -) -= -sign - -( -z -[ -x -, -a -( -x -) -] -) - - -where -a(x) - and -z(x, u) - -are as defined in the abs-normal representation of - -f -( -x -) - - -. - -
-
-Cutting Planes -
-At each iteration, -we are given affine functions - -p -k - -( -x -) - - - -such that - -p -k - -( -x -k - -) -= -f - -˜ -( -x -k - -) - - - and - - -p -k -( -1 -) - - -( -x -k - -) - - - is the derivative - - -f - -˜ -( -1 -) - - -( -x -k - -) - - - -corresponding to - -σ -( -x -k - -) - - -. - -
-
-Iteration -
-At iteration - -k - - -, we solve the problem - - - -minimize - - -max -{ -p -k - -( -x -) - -: - -k -= -0 -, - -, -K --1 -} - -w -. -r -. -t - - -x - -subject - -to - - -- -b - -x - -+ -b - - - -The solution is the new point - -x -K - - - - -at which the new affine approximation - - -p -K - -( -x -) - - - is constructed. -This process is iterated until the difference - - -x -K - -- -x -K --1 - - - - - is small enough. - - - -
-
-Example -
-The file abs_min_linear.cpp - contains an example and test of -abs_min_linear. -It returns true if the test passes and false otherwise. - - -
Input File: example/abs_normal/abs_min_linear.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_abs_min_linear_xml.js cppad-2019.02.00.0/doc/_abs_min_linear_xml.js --- cppad-2018.00.00.0/doc/_abs_min_linear_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_min_linear_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'abs_min_linear.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down0 = [ -'abs_min_linear.cpp.xml', -'abs_min_linear.hpp.xml' -]; -var list_current0 = [ -'abs_min_linear.xml#Syntax', -'abs_min_linear.xml#Prototype', -'abs_min_linear.xml#Source', -'abs_min_linear.xml#Purpose', -'abs_min_linear.xml#DblVector', -'abs_min_linear.xml#SizeVector', -'abs_min_linear.xml#f', -'abs_min_linear.xml#level', -'abs_min_linear.xml#n', -'abs_min_linear.xml#m', -'abs_min_linear.xml#s', -'abs_min_linear.xml#g', -'abs_min_linear.xml#g_hat', -'abs_min_linear.xml#g_jac', -'abs_min_linear.xml#bound', -'abs_min_linear.xml#epsilon', -'abs_min_linear.xml#maxitr', -'abs_min_linear.xml#delta_x', -'abs_min_linear.xml#Method', -'abs_min_linear.xml#Method.sigma', -'abs_min_linear.xml#Method.Cutting Planes', -'abs_min_linear.xml#Method.Iteration', -'abs_min_linear.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-2018.00.00.0/doc/abs_min_quad.cpp.xml cppad-2019.02.00.0/doc/abs_min_quad.cpp.xml --- cppad-2018.00.00.0/doc/abs_min_quad.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_min_quad.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,305 +0,0 @@ - - - -abs_min_quad: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -abs_min_quad.cpp - -

- - -
abs_min_quad: Example and Test
-
-Purpose -
-The function - - -f -: -R - -3 - - -R - - - - defined by - - -f -( -x -0 - -, -x -1 - -) -= -( -x -0 -2 - -+ -x -1 -2 - -) -/ -2 -+ -| -x -0 - -- -5 -| -+ -| -x -1 - -+ -5 -| - - -For this case, the abs_min_quad - object should be equal -to the function itself. -In addition, the function is convex and -abs_min_quad - should find its global minimizer. -The minimizer of this function is - - -x -0 - -= -1 - - -, - -x -1 - -= --1 - - -. - -
-
-Source - -

-# include <cppad/cppad.hpp>
-# include "abs_min_quad.hpp"
-
-namespace {
-     CPPAD_TESTVECTOR(double) join(
-          const CPPAD_TESTVECTOR(double)& x ,
-          const CPPAD_TESTVECTOR(double)& u )
-     {     size_t n = x.size();
-          size_t s = u.size();
-          CPPAD_TESTVECTOR(double) xu(n + s);
-          for(size_t j = 0; j < n; j++)
-               xu[j] = x[j];
-          for(size_t j = 0; j < s; j++)
-               xu[n + j] = u[j];
-          return xu;
-     }
-}
-bool abs_min_quad(void)
-{     bool ok = true;
-     //
-     using CppAD::AD;
-     using CppAD::ADFun;
-     //
-     typedef CPPAD_TESTVECTOR(size_t)       s_vector;
-     typedef CPPAD_TESTVECTOR(double)       d_vector;
-     typedef CPPAD_TESTVECTOR( AD<double> ) ad_vector;
-     //
-     size_t level = 0;     // level of tracing
-     size_t n     = 2;     // size of x
-     size_t m     = 1;     // size of y
-     size_t s     = 2 ;    // number of data points and absolute values
-     //
-     // record the function f(x)
-     ad_vector ad_x(n), ad_y(m);
-     for(size_t j = 0; j < n; j++)
-          ad_x[j] = double(j + 1);
-     Independent( ad_x );
-     AD<double> sum = 0.0;
-     sum += ad_x[0] * ad_x[0] / 2.0 + abs( ad_x[0] - 5 );
-     sum += ad_x[1] * ad_x[1] / 2.0 + abs( ad_x[1] + 5 );
-     ad_y[0] = sum;
-     ADFun<double> f(ad_x, ad_y);
-
-     // create its abs_normal representation in g, a
-     ADFun<double> g, a;
-     f.abs_normal_fun(g, a);
-
-     // check dimension of domain and range space for g
-     ok &= g.Domain() == n + s;
-     ok &= g.Range()  == m + s;
-
-     // check dimension of domain and range space for a
-     ok &= a.Domain() == n;
-     ok &= a.Range()  == s;
-
-     // --------------------------------------------------------------------
-     // Choose the point x_hat = 0
-     d_vector x_hat(n);
-     for(size_t j = 0; j < n; j++)
-          x_hat[j] = 0.0;
-
-     // value of a_hat = a(x_hat)
-     d_vector a_hat = a.Forward(0, x_hat);
-
-     // (x_hat, a_hat)
-     d_vector xu_hat = join(x_hat, a_hat);
-
-     // value of g[ x_hat, a_hat ]
-     d_vector g_hat = g.Forward(0, xu_hat);
-
-     // Jacobian of g[ x_hat, a_hat ]
-     d_vector g_jac = g.Jacobian(xu_hat);
-
-     // trust region bound
-     d_vector bound(n);
-     for(size_t j = 0; j < n; j++)
-          bound[j] = 10.0;
-
-     // convergence criteria
-     d_vector epsilon(2);
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     epsilon[0]   = eps99;
-     epsilon[1]   = eps99;
-
-     // maximum number of iterations
-     s_vector maxitr(2);
-     maxitr[0] = 10; // maximum number of abs_min_quad iterations
-     maxitr[1] = 35; // maximum number of qp_interior iterations
-
-     // set Hessian equal to identity matrix I
-     d_vector hessian(n * n);
-     for(size_t i = 0; i < n; i++)
-     {     for(size_t j = 0; j < n; j++)
-               hessian[i * n + j] = 0.0;
-          hessian[i * n + i] = 1.0;
-     }
-
-     // minimize the approxiamtion for f (which is equal to f for this case)
-     d_vector delta_x(n);
-     ok &= CppAD::abs_min_quad(
-          level, n, m, s,
-          g_hat, g_jac, hessian, bound, epsilon, maxitr, delta_x
-     );
-
-     // check that the solution
-     ok &= CppAD::NearEqual( delta_x[0], +1.0, eps99, eps99 );
-     ok &= CppAD::NearEqual( delta_x[1], -1.0, eps99, eps99 );
-
-     return ok;
-}
- -
Input File: example/abs_normal/abs_min_quad.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_abs_min_quad.cpp_xml.js cppad-2019.02.00.0/doc/_abs_min_quad.cpp_xml.js --- cppad-2018.00.00.0/doc/_abs_min_quad.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_min_quad.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'abs_min_quad.xml', -'abs_min_quad.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'abs_min_quad.cpp.xml', -'abs_min_quad.hpp.xml' -]; -var list_current0 = [ -'abs_min_quad.cpp.xml#Purpose', -'abs_min_quad.cpp.xml#Source' -]; -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-2018.00.00.0/doc/abs_min_quad.hpp.xml cppad-2019.02.00.0/doc/abs_min_quad.hpp.xml --- cppad-2018.00.00.0/doc/abs_min_quad.hpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_min_quad.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,384 +0,0 @@ - - - -abs_min_quad Source Code - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -abs_min_quad.hppHeadings

-
abs_min_quad Source Code
-
namespace CppAD { // BEGIN_CPPAD_NAMESPACE
-
-// BEGIN PROTOTYPE
-template <class DblVector, class SizeVector>
-bool abs_min_quad(
-     size_t            level   ,
-     size_t            n       ,
-     size_t            m       ,
-     size_t            s       ,
-     const DblVector&  g_hat   ,
-     const DblVector&  g_jac   ,
-     const DblVector&  hessian ,
-     const DblVector&  bound   ,
-     const DblVector&  epsilon ,
-     const SizeVector& maxitr  ,
-     DblVector&        delta_x )
-// END PROTOTYPE
-{     using std::fabs;
-     bool ok    = true;
-     double inf = std::numeric_limits<double>::infinity();
-     //
-     CPPAD_ASSERT_KNOWN(
-          level <= 4,
-          "abs_min_quad: level is not less that or equal 3"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(epsilon.size()) == 2,
-          "abs_min_quad: size of epsilon not equal to 2"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(maxitr.size()) == 2,
-          "abs_min_quad: size of maxitr not equal to 2"
-     );
-     CPPAD_ASSERT_KNOWN(
-          m == 1,
-          "abs_min_quad: m is not equal to 1"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(delta_x.size()) == n,
-          "abs_min_quad: size of delta_x not equal to n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(bound.size()) == n,
-          "abs_min_quad: size of bound not equal to n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(g_hat.size()) == m + s,
-          "abs_min_quad: size of g_hat not equal to m + s"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(g_jac.size()) == (m + s) * (n + s),
-          "abs_min_quad: size of g_jac not equal to (m + s)*(n + s)"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(hessian.size()) == n * n,
-          "abs_min_quad: size of hessian not equal to n * n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(bound.size()) == n,
-          "abs_min_quad: size of bound is not equal to n"
-     );
-     if( level > 0 )
-     {     std::cout << "start abs_min_quad\n";
-          CppAD::abs_print_mat("g_hat", m + s, 1, g_hat);
-          CppAD::abs_print_mat("g_jac", m + s, n + s, g_jac);
-          CppAD::abs_print_mat("hessian", n, n, hessian);
-          CppAD::abs_print_mat("bound", n, 1, bound);
-     }
-     // partial y(x, u) w.r.t x (J in reference)
-     DblVector py_px(n);
-     for(size_t j = 0; j < n; j++)
-          py_px[ j ] = g_jac[ j ];
-     //
-     // partial y(x, u) w.r.t u (Y in reference)
-     DblVector py_pu(s);
-     for(size_t j = 0; j < s; j++)
-          py_pu[ j ] = g_jac[ n + j ];
-     //
-     // partial z(x, u) w.r.t x (Z in reference)
-     DblVector pz_px(s * n);
-     for(size_t i = 0; i < s; i++)
-     {     for(size_t j = 0; j < n; j++)
-          {     pz_px[ i * n + j ] = g_jac[ (n + s) * (i + m) + j ];
-          }
-     }
-     // partial z(x, u) w.r.t u (L in reference)
-     DblVector pz_pu(s * s);
-     for(size_t i = 0; i < s; i++)
-     {     for(size_t j = 0; j < s; j++)
-          {     pz_pu[ i * s + j ] = g_jac[ (n + s) * (i + m) + n + j ];
-          }
-     }
-     // initailize delta_x
-     for(size_t j = 0; j < n; j++)
-          delta_x[j] = 0.0;
-     //
-     // current set of cutting planes
-     DblVector C(maxitr[0] * n), c(maxitr[0]);
-     //
-     // value of abs-normal approximation at x_hat + delta_x
-     DblVector g_tilde = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_x);
-     //
-     // value of sigma at delta_x = 0; i.e., sign( z(x, u) )
-     CppAD::vector<double> sigma(s);
-     for(size_t i = 0; i < s; i++)
-          sigma[i] = CppAD::sign( g_tilde[m + i] );
-     //
-     // initial value of the objective
-     double obj_cur =  g_tilde[0];
-     //
-     // initial number of cutting planes
-     size_t n_plane = 0;
-     //
-     if( level > 0 )
-     {     std::cout << "obj = " << obj_cur << "\n";
-          CppAD::abs_print_mat("delta_x", n, 1, delta_x);
-     }
-     for(size_t itr = 0; itr < maxitr[0]; itr++)
-     {
-          // Equation (5), Propostion 3.1 of reference
-          // dy_dx = py_px + py_pu * Sigma * (I - pz_pu * Sigma)^-1 * pz_px
-          //
-          // tmp_ss = I - pz_pu * Sigma
-          DblVector tmp_ss(s * s);
-          for(size_t i = 0; i < s; i++)
-          {     for(size_t j = 0; j < s; j++)
-                    tmp_ss[i * s + j] = - pz_pu[i * s + j] * sigma[j];
-               tmp_ss[i * s + i] += 1.0;
-          }
-          // tmp_sn = (I - pz_pu * Sigma)^-1 * pz_px
-          double logdet;
-          DblVector tmp_sn(s * n);
-          LuSolve(s, n, tmp_ss, pz_px, tmp_sn, logdet);
-          //
-          // tmp_sn = Sigma * (I - pz_pu * Sigma)^-1 * pz_px
-          for(size_t i = 0; i < s; i++)
-          {     for(size_t j = 0; j < n; j++)
-                    tmp_sn[i * n + j] *= sigma[i];
-          }
-          // dy_dx = py_px + py_pu * Sigma * (I - pz_pu * Sigma)^-1 * pz_px
-          DblVector dy_dx(n);
-          for(size_t j = 0; j < n; j++)
-          {     dy_dx[j] = py_px[j];
-               for(size_t k = 0; k < s; k++)
-                    dy_dx[j] += py_pu[k] * tmp_sn[ k * n + j];
-          }
-          //
-          // compute derivative of the quadratic term
-          DblVector dq_dx(n);
-          for(size_t j = 0; j < n; j++)
-          {     dq_dx[j] = 0.0;
-               for(size_t i = 0; i < n; i++)
-                    dq_dx[j] += delta_x[i] * hessian[i * n + j];
-          }
-          //
-          // check for case where derivative of objective is zero
-          // (in convex case, this is the minimizer)
-          bool near_zero = true;
-          for(size_t j = 0; j < n; j++)
-               near_zero &= std::fabs( dq_dx[j] + dy_dx[j] ) < epsilon[1];
-          if( near_zero )
-          {     if( level > 0 )
-                    std::cout << "end abs_min_quad: local derivative near zero\n";
-               return true;
-          }
-          // value of hyperplane at delta_x
-          double plane_at_zero = g_tilde[0];
-          //
-          // value of hyperplane at 0
-          for(size_t j = 0; j < n; j++)
-               plane_at_zero -= dy_dx[j] * delta_x[j];
-          //
-          // add a cutting plane with value g_tilde[0] at delta_x
-          // and derivative dy_dx
-          c[n_plane] = plane_at_zero;
-          for(size_t j = 0; j < n; j++)
-               C[n_plane * n + j] = dy_dx[j];
-          ++n_plane;
-          //
-          // variables for cutting plane problem are (dx, w)
-          // c[i] + C[i,:] * dx <= w
-          DblVector c_box(n_plane), C_box(n_plane * (n + 1));
-          for(size_t i = 0; i < n_plane; i++)
-          {     c_box[i] = c[i];
-               for(size_t j = 0; j < n; j++)
-                    C_box[i * (n+1) + j] = C[i * n + j];
-               C_box[i * (n+1) + n] = -1.0;
-          }
-          //
-          // w is the objective
-          DblVector g_box(n + 1);
-          for(size_t i = 0; i < size_t(c_box.size()); i++)
-               g_box[i] = 0.0;
-          g_box[n] = 1.0;
-          //
-          // a_box, b_box
-          DblVector a_box(n+1), b_box(n+1);
-          for(size_t j = 0; j < n; j++)
-          {     a_box[j] = - bound[j];
-               b_box[j] = + bound[j];
-          }
-          a_box[n] = - inf;
-          b_box[n] = + inf;
-          //
-          // initial delta_x in qp_box is zero
-          DblVector xin_box(n + 1);
-          for(size_t j = 0; j < n; j++)
-               xin_box[j] = 0.0;
-          // initial w in qp_box is 1 + max_i c[i]
-          xin_box[n] = 1.0 + c_box[0];
-          for(size_t i = 1; i < n_plane; i++)
-               xin_box[n] = std::max( xin_box[n], 1.0 + c_box[i] );
-          //
-          DblVector hessian_box( (n+1) * (n+1) );
-          for(size_t i = 0; i < n+1; i++)
-          {     for(size_t j = 0; j < n+1; j++)
-               {     if( i == n || j == n )
-                         hessian_box[i * (n+1) + j] = 0.0;
-                    else
-                         hessian_box[i * (n+1) + j] = hessian[i * n + j];
-               }
-          }
-          //
-          // solve the cutting plane problem
-          DblVector xout_box(n + 1);
-          size_t level_box = 0;
-          if( level > 0 )
-               level_box = level - 1;
-          ok &= CppAD::qp_box(
-               level_box,
-               a_box,
-               b_box,
-               c_box,
-               C_box,
-               g_box,
-               hessian_box,
-               epsilon[1],
-               maxitr[1],
-               xin_box,
-               xout_box
-          );
-          if( ! ok )
-          {     if( level > 0 )
-               {     CppAD::abs_print_mat("delta_x", n, 1, delta_x);
-                    std::cout << "end abs_min_quad: qp_box failed\n";
-               }
-               return false;
-          }
-          DblVector delta_new(n);
-          for(size_t j = 0; j < n; j++)
-               delta_new[j] = xout_box[j];
-          //
-          // check for convergence
-          double max_diff = 0.0;
-          for(size_t j = 0; j < n; j++)
-          {     double diff = delta_x[j] - delta_new[j];
-               max_diff    = std::max( max_diff, std::fabs(diff) );
-          }
-          //
-          // new value of the objective
-          DblVector g_new   = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_new);
-          double    obj_new = g_new[0];
-          for(size_t i = 0; i < n; i++)
-          {     for(size_t j = 0; j < n; j++)
-                    obj_new += delta_new[i] * hessian[i * n + j] * delta_new[j];
-          }
-          g_tilde = g_new;
-          obj_cur = obj_new;
-          delta_x = delta_new;
-          //
-          if( level > 0 )
-          {     std::cout << "itr = " << itr << ", max_diff = " << max_diff
-                    << ", obj_cur = " << obj_cur << "\n";
-               CppAD::abs_print_mat("delta_x", n, 1, delta_x);
-          }
-          //
-          // value of sigma at new delta_x; i.e., sign( z(x, u) )
-          for(size_t i = 0; i < s; i++)
-               sigma[i] = CppAD::sign( g_tilde[m + i] );
-          //
-          if( max_diff < epsilon[0] )
-          {     if( level > 0 )
-                    std::cout << "end abs_min_quad: change in delta_x near zero\n";
-               return true;
-          }
-     }
-     if( level > 0 )
-          std::cout << "end abs_min_quad: maximum number of iterations exceeded\n";
-     return false;
-}
-} // END_CPPAD_NAMESPACE
- -
Input File: example/abs_normal/abs_min_quad.omh - - - diff -Nru cppad-2018.00.00.0/doc/_abs_min_quad.hpp_xml.js cppad-2019.02.00.0/doc/_abs_min_quad.hpp_xml.js --- cppad-2018.00.00.0/doc/_abs_min_quad.hpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_min_quad.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'abs_min_quad.xml', -'abs_min_quad.hpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'abs_min_quad.cpp.xml', -'abs_min_quad.hpp.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-2018.00.00.0/doc/abs_min_quad.xml cppad-2019.02.00.0/doc/abs_min_quad.xml --- cppad-2018.00.00.0/doc/abs_min_quad.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_min_quad.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,874 +0,0 @@ - - - -abs_normal: Minimize a Linear Abs-normal Approximation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
abs_normal: Minimize a Linear Abs-normal Approximation
-
-Syntax - -
- -ok = abs_min_quad(
-     
levelnms,
-     
g_hatg_jachessianboundepsilonmaxitrdelta_x
-)
- - -
-
-Prototype - -

-template <class DblVector, class SizeVector>
-bool abs_min_quad(
-     size_t            level   ,
-     size_t            n       ,
-     size_t            m       ,
-     size_t            s       ,
-     const DblVector&  g_hat   ,
-     const DblVector&  g_jac   ,
-     const DblVector&  hessian ,
-     const DblVector&  bound   ,
-     const DblVector&  epsilon ,
-     const SizeVector& maxitr  ,
-     DblVector&        delta_x )
-
-Source -
-This following is a link to the source code for this example: -abs_min_quad.hpp -. - -
-
-Purpose -
-We are given a point - -x - -^ - -R - -n - - - - and -use the notation - -f - -˜ -( -x -) - - - for the abs-normal -approximation for f(x) - -near - -x - -^ - - -. -We are also given a vector - -b - -R - -+ -n - - - - -and a positive definite matrix - -H - -R - -n -× -n - - - - -. -This routine solves the problem - - - -minimize - - -Δ -x -T - -H -Δ -x -/ -2 -+ -f - -˜ -( -x - -^ -+ -Δ -x -) - -w -. -r -. -t - - -Δ -x - -R - -n - - -subject - -to - - -| -Δ -x -j - -| - -b -j - - -j -= -0 -, - -, -n --1 - - - -
-DblVector -
-is a SimpleVector - class with elements of type double. - -
-
-SizeVector -
-is a SimpleVector - class with elements of type size_t. - -
-
-f -
-We use the notation -f - for the original function; see -f -. - -
-
-level -
-This value is less that or equal 3. -If -level == 0 -, -no tracing of the optimization is printed. -If -level >= 1 -, -a trace of each iteration of abs_min_quad is printed. -If -level >= 2 -, -a trace of the qp_box - sub-problem is printed. -If -level >= 3 -, -a trace of the qp_interior - sub-problem is printed. - -
-
-n -
-This is the dimension of the domain space for -f -; see -n -. - -
-
-m -
-This is the dimension of the range space for -f -; see -m -. This must be one so that - -f - - - -is an objective function. - -
-
-s -
-This is the number of absolute value terms in -f -; see -s -. - -
-
-g -
-We use the notation -g - for the abs-normal representation of -f -; -see g -. - -
-
-g_hat -
-This vector has size -m + s - and is the value of - -g(x, u) - at - -x -= -x - -^ - - - and - -u -= -a -( -x - -^ -) - - -. - -
-
-g_jac -
-This vector has size -(m + s) * (n + s) - and is the Jacobian of - - -g -( -x -, -u -) - - - at - -x -= -x - -^ - - - and - -u -= -a -( -x - -^ -) - - -. - -
-
-hessian -
-This vector has size -n * n -. -It is a row-major - representation -of the matrix - -H - -R - -n -× -n - - - - -. - -
-
-bound -
-This vector has size -n - and is the vector - -b - -R - -n - - - -. -The trust region is defined as the set of - -Δ -x - - - such that - - -| -Δ -x -| - -b -j - - - -for - -j -= -0 -, - -, -n --1 - - -. - -
-
-epsilon -
-The value -epsilon[0] - is convergence criteria in terms -of the infinity norm of the difference of -delta_x - -between iterations. -The value -epsilon[1] - is convergence criteria in terms -of the derivative of the objective; i.e. - - -Δ -x -T - -H -Δ -x -/ -2 -+ -f - -˜ -( -x - -^ -+ -Δ -x -) - - -
-maxitr -
-This is a vector with size 2. -The value -maxitr[0] - is the maximum number of -abs_min_quad iterations to try before giving up on convergence. -The value -maxitr[1] - is the maximum number of iterations in -the qp_interior - sub-problems. - -
-
-delta_x -
-This vector - -Δ -x - - - has size -n -. -The input value of its elements does not matter. -Upon return, -the approximate minimizer of the objective with respect to the trust region. - -
-
-Method - - -
-
-sigma -
-We use the notation - - -σ -( -x -) -= -sign - -( -z -[ -x -, -a -( -x -) -] -) - - -where -a(x) - and -z(x, u) - -are as defined in the abs-normal representation of - -f -( -x -) - - -. - -
-
-Cutting Planes -
-At each iteration, -we are given affine functions - -p -k - -( -x -) - - - -such that - -p -k - -( -x -k - -) -= -f - -˜ -( -x -k - -) - - - and - - -p -k -( -1 -) - - -( -x -k - -) - - - is the derivative - -f - -˜ -( -1 -) - - -( -x -k - -) - - - -corresponding to - -σ -( -x -k - -) - - -. - -
-
-Iteration -
-At iteration - -k - - -, we solve the problem - - - -minimize - - -Δ -x -T - -H -Δ -x -/ -2 -+ -max -{ -p -k - -( -x - -^ -+ -Δ -x -) - -: - -k -= -0 -, - -, -K --1 -} - -w -. -r -. -t - - -Δ -x - -subject - -to - - -- -b - -Δ -x - -+ -b - - - -The solution is the new point - -x -K - - - - -at which the new affine approximation - - -p -K - -( -x -) - - - is constructed. -This process is iterated until the difference - - -x -K - -- -x -K --1 - - - - - is small enough. - - - -
-
-Example -
-The file abs_min_quad.cpp - contains an example and test of -abs_min_quad. -It returns true if the test passes and false otherwise. - - -
Input File: example/abs_normal/abs_min_quad.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_abs_min_quad_xml.js cppad-2019.02.00.0/doc/_abs_min_quad_xml.js --- cppad-2018.00.00.0/doc/_abs_min_quad_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_min_quad_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', -'adfun.xml', -'abs_normal.xml', -'abs_min_quad.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down0 = [ -'abs_min_quad.cpp.xml', -'abs_min_quad.hpp.xml' -]; -var list_current0 = [ -'abs_min_quad.xml#Syntax', -'abs_min_quad.xml#Prototype', -'abs_min_quad.xml#Source', -'abs_min_quad.xml#Purpose', -'abs_min_quad.xml#DblVector', -'abs_min_quad.xml#SizeVector', -'abs_min_quad.xml#f', -'abs_min_quad.xml#level', -'abs_min_quad.xml#n', -'abs_min_quad.xml#m', -'abs_min_quad.xml#s', -'abs_min_quad.xml#g', -'abs_min_quad.xml#g_hat', -'abs_min_quad.xml#g_jac', -'abs_min_quad.xml#hessian', -'abs_min_quad.xml#bound', -'abs_min_quad.xml#epsilon', -'abs_min_quad.xml#maxitr', -'abs_min_quad.xml#delta_x', -'abs_min_quad.xml#Method', -'abs_min_quad.xml#Method.sigma', -'abs_min_quad.xml#Method.Cutting Planes', -'abs_min_quad.xml#Method.Iteration', -'abs_min_quad.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-2018.00.00.0/doc/abs_normal_fun.xml cppad-2019.02.00.0/doc/abs_normal_fun.xml --- cppad-2018.00.00.0/doc/abs_normal_fun.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_normal_fun.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1972 +0,0 @@ - - - -Create An Abs-normal Representation of a Function - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Create An Abs-normal Representation of a Function
-
-Syntax - -
- -f.abs_normal_fun(ga) - - -
-
-f -
-The object -f - has prototype - -
-     const ADFun<
Base>& f
-
-It represents a function - -f -: -R - -n - - -R - -m - - - -. -We assume that the only non-smooth terms in the representation are -absolute value functions and use - -s - -Z - -+ - - - - -to represent the number of these terms. - -
-
-n -
-We use -n - to denote the dimension of the domain space for -f -. - -
-
-m -
-We use -m - to denote the dimension of the range space for -f -. - -
-
-s -
-We use -s - to denote the number of absolute value terms in -f -. - - -
-
-a -
-The object -a - has prototype - -
-     ADFun<
Basea
-
-The initial function representation in -a - is lost. -Upon return it represents the result of the absolute terms - - -a -: -R - -n - - -R - -s - - - -; see - -a -( -x -) - - - defined below. -Note that -a - is constructed by copying -f - -and then changing the dependent variables. There may -be many calculations in this representation that are not necessary -and can be removed using - -
-     
a.optimize()
-
-This optimization is not done automatically by abs_normal_fun -because it may take a significant amount of time. - -
-
-zeta -
-Let - -ζ -0 - -( -x -) - - - -denote the argument for the first absolute value term in - -f -( -x -) - - -, - - -ζ -1 - -( -x -, -| -ζ -0 - -( -x -) -| -) - - - for the second term, and so on. - -
-
-a(x) -
-For - -i -= -0 -, - -, -s --1 - - - - define - - -a -i - -( -x -) -= -| -ζ -i - -( -x -, -a -0 - -( -x -) -, - -, -a -i --1 - - -( -x -) -) -| - - -This defines - -a -: -R - -n - - -R - -s - - - -. - -
-
-g -
-The object -g - has prototype - -
-     ADFun<
Baseg
-
-The initial function representation in -g - is lost. -Upon return it represents the smooth function - - -g -: -R - -n -+ -s - - - -R - -m -+ -s - - - - - is defined by - - -g -( -x -, -u -) -= -[ -y -( -x -, -u -) - -z -( -x -, -u -) - -] - - -were - -y -( -x -, -u -) - - - and - -z -( -x -, -u -) - - - are defined below. - -
-
-z(x, u) -
-Define the smooth function - - -z -: -R - -n -+ -s - - - -R - -s - - - - by - - -z -i - -( -x -, -u -) -= -ζ -i - -( -x -, -u -0 - -, - -, -u -i --1 - - -) - - -Note that the partial of - -z -i - - - - with respect to - -u -j - - - - is zero -for - -j - -i - - -. - -
-
-y(x, u) -
-There is a smooth function - - -y -: -R - -n -+ -s - - - -R - -m - - - - -such that - -y -( -x -, -u -) -= -f -( -x -) - - - whenever - -u -= -a -( -x -) - - -. - -
-
-Affine Approximation -
-We define the affine approximations - - - -y -[ -x - -^ -] -( -x -, -u -) - -= - -y -( -x - -^ -, -a -( -x - -^ -) -) -+ - -x - -y -( -x - -^ -, -a -( -x - -^ -) -) -( -x -- -x - -^ -) -+ - -u - -y -( -x - -^ -, -a -( -x - -^ -) -) -( -u -- -a -( -x - -^ -) -) - -z -[ -x - -^ -] -( -x -, -u -) - -= - -z -( -x - -^ -, -a -( -x - -^ -) -) -+ - -x - -z -( -x - -^ -, -a -( -x - -^ -) -) -( -x -- -x - -^ -) -+ - -u - -z -( -x - -^ -, -a -( -x - -^ -) -) -( -u -- -a -( -x - -^ -) -) - - - -It follows that - - - -y -( -x -, -u -) - -= - -y -[ -x - -^ -] -( -x -, -u -) -+ -o -( -x -- -x - -^ -, -u -- -a -( -x - -^ -) -) - -z -( -x -, -u -) - -= - -z -[ -x - -^ -] -( -x -, -u -) -+ -o -( -x -- -x - -^ -, -u -- -a -( -x - -^ -) -) - - - -
-Abs-normal Approximation - - -
-
-Approximating a(x) -
-The function - -a -( -x -) - - - is not smooth, but it is equal to - - -| -z -( -x -, -u -) -| - - - when - -u -= -a -( -x -) - - -. -Furthermore - - -z -[ -x - -^ -] -( -x -, -u -) -= -z -( -x - -^ -, -a -( -x - -^ -) -) -+ - -x - -z -( -x - -^ -, -a -( -x - -^ -) -) -( -x -- -x - -^ -) -+ - -u - -z -( -x - -^ -, -a -( -x - -^ -) -) -( -u -- -a -( -x - -^ -) -) - - -The partial of - -z -i - - - - with respect to - -u -j - - - - is zero -for - -j - -i - - -. It follows that - - -z -i - -[ -x - -^ -] -( -x -, -u -) -= -z -i - -( -x - -^ -, -a -( -x - -^ -) -) -+ - -x - -z -i - -( -x - -^ -, -a -( -x - -^ -) -) -( -x -- -x - -^ -) -+ - -j -< -i - - - -u -( -j -) - - -z -i - -( -x - -^ -, -a -( -x - -^ -) -) -( -u -j - -- -a -j - -( -x - -^ -) -) - - -Considering the case - -i -= -0 - - - we define - - -a -0 - -[ -x - -^ -] -( -x -) -= -| -z -0 - -[ -x - -^ -] -( -x -, -u -) -| -= -|z -0 - -( -x - -^ -, -a -( -x - -^ -) -) -+ - -x - -z -0 - -( -x - -^ -, -a -( -x - -^ -) -) -( -x -- -x - -^ -) -| - - -It follows that - - -a -0 - -( -x -) -= -a -0 - -[ -x - -^ -] -( -x -) -+ -o -( -x -- -x - -^ -) - - -In general, we define - -a -i - -[ -x - -^ -] - - - using - - -a -j - -[ -x - -^ -] - - - for - -j -< -i - - - as follows: - - -a -i - -[ -x - -^ -] -( -x -) -= -|z -i - -( -x - -^ -, -a -( -x - -^ -) -) -+ - -x - -z -i - -( -x - -^ -, -a -( -x - -^ -) -) -( -x -- -x - -^ -) -+ - -j -< -i - - - -u -( -j -) - - -z -i - -( -x - -^ -, -a -( -x - -^ -) -) -( -a -j - -[ -x - -^ -] -( -x -) -- -a -j - -( -x - -^ -) -) -| - - -It follows that - - -a -( -x -) -= -a -[ -x - -^ -] -( -x -) -+ -o -( -x -- -x - -^ -) - - -Note that in the case where - -z -( -x -, -u -) - - - and - -y -( -x -, -u -) - - - are -affine, - - -a -[ -x - -^ -] -( -x -) -= -a -( -x -) - - -
-Approximating f(x) - - - -f -( -x -) -= -y -( -x -, -a -( -x -) -) -= -y -[ -x - -^ -] -( -x -, -a -[ -x - -^ -] -( -x -) -) -+ -o -( -Δ -x -) - - -
-Correspondence to Literature -
-Using the notation - - -Z -= - -x - -z -( -x - -^ -, -u - -^ -) - - -, - - -L -= - -u - -z -( -x - -^ -, -u - -^ -) - - -, - - -J -= - -x - -y -( -x - -^ -, -u - -^ -) - - -, - - -Y -= - -u - -y -( -x - -^ -, -u - -^ -) - - -, -the approximation for - -z - - - and - -y - - - are - - - -z -[ -x - -^ -] -( -x -, -u -) - -= - -z -( -x - -^ -, -a -( -x - -^ -) -) -+ -Z -( -x -- -x - -^ -) -+ -L -( -u -- -a -( -x - -^ -) -) - -y -[ -x - -^ -] -( -x -, -u -) - -= - -y -( -x - -^ -, -a -( -x - -^ -) -) -+ -J -( -x -- -x - -^ -) -+ -Y -( -u -- -a -( -x - -^ -) -) - - - -Moving the terms with - -x - -^ - - - together, we have - - - -z -[ -x - -^ -] -( -x -, -u -) - -= - -z -( -x - -^ -, -a -( -x - -^ -) -) -- -Z -x - -^ -- -L -a -( -x - -^ -) -+ -Z -x -+ -L -u - -y -[ -x - -^ -] -( -x -, -u -) - -= - -y -( -x - -^ -, -a -( -x - -^ -) -) -- -J -x - -^ -- -Y -a -( -x - -^ -) -+ -J -x -+ -Y -u - - - -Using the notation - - -c -= -z -( -x - -^ -, -u - -^ -) -- -Z -x - -^ -- -L -u - -^ - - -, - - -b -= -y -( -x - -^ -, -u - -^ -) -- -J -x - -^ -- -Y -u - -^ - - -, -we have - - - -z -[ -x - -^ -] -( -x -, -u -) - -= - -c -+ -Z -x -+ -L -u - -y -[ -x - -^ -] -( -x -, -u -) - -= - -b -+ -J -x -+ -Y -u - - - -Considering the affine case, where the approximations are exact, -and choosing - -u -= -a -( -x -) -= -| -z -( -x -, -u -) -| - - -, we obtain - - - -z -( -x -, -a -( -x -) -) - -= - -c -+ -Z -x -+ -L -| -z -( -x -, -a -( -x -) -) -| - -y -( -x -, -a -( -x -) -) - -= - -b -+ -J -x -+ -Y -| -z -( -x -, -a -( -x -) -) -| - - - -This is Equation (2) of the -reference -. - - -
-
-Example -
-The file abs_get_started.cpp - contains -an example and test using this operation. - - -
Input File: cppad/core/abs_normal_fun.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_abs_normal_fun_xml.js cppad-2019.02.00.0/doc/_abs_normal_fun_xml.js --- cppad-2018.00.00.0/doc/_abs_normal_fun_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_normal_fun_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'abs_normal_fun.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down0 = [ -'abs_get_started.cpp.xml' -]; -var list_current0 = [ -'abs_normal_fun.xml#Syntax', -'abs_normal_fun.xml#f', -'abs_normal_fun.xml#f.n', -'abs_normal_fun.xml#f.m', -'abs_normal_fun.xml#f.s', -'abs_normal_fun.xml#a', -'abs_normal_fun.xml#a.zeta', -'abs_normal_fun.xml#a.a(x)', -'abs_normal_fun.xml#g', -'abs_normal_fun.xml#g.z(x, u)', -'abs_normal_fun.xml#g.y(x, u)', -'abs_normal_fun.xml#Affine Approximation', -'abs_normal_fun.xml#Abs-normal Approximation', -'abs_normal_fun.xml#Abs-normal Approximation.Approximating a(x)', -'abs_normal_fun.xml#Abs-normal Approximation.Approximating f(x)', -'abs_normal_fun.xml#Correspondence to Literature', -'abs_normal_fun.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-2018.00.00.0/doc/abs_normal.xml cppad-2019.02.00.0/doc/abs_normal.xml --- cppad-2018.00.00.0/doc/abs_normal.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_normal.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ - - - -Abs-normal Representation of Non-Smooth Functions - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Abs-normal Representation of Non-Smooth Functions
-
-Reference -
-Andreas Griewank, Jens-Uwe Bernt, Manuel Radons, Tom Streubel, -Solving piecewise linear systems in abs-normal form, -Linear Algebra and its Applications, -vol. 471 (2015), pages 500-530. - -
-
-Contents -
- -
abs_normal_funCreate An Abs-normal Representation of a Function
abs_print_matabs_normal: Print a Vector or Matrix
abs_evalabs_normal: Evaluate First Order Approximation
simplex_methodabs_normal: Solve a Linear Program Using Simplex Method
lp_boxabs_normal: Solve a Linear Program With Box Constraints
abs_min_linearabs_normal: Minimize a Linear Abs-normal Approximation
min_nso_linearNon-Smooth Optimization Using Abs-normal Linear Approximations
qp_interiorSolve a Quadratic Program Using Interior Point Method
qp_boxabs_normal: Solve a Quadratic Program With Box Constraints
abs_min_quadabs_normal: Minimize a Linear Abs-normal Approximation
min_nso_quadNon-Smooth Optimization Using Abs-normal Quadratic Approximations
-
Input File: example/abs_normal/abs_normal.omh - - - diff -Nru cppad-2018.00.00.0/doc/_abs_normal_xml.js cppad-2019.02.00.0/doc/_abs_normal_xml.js --- cppad-2018.00.00.0/doc/_abs_normal_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_normal_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', -'adfun.xml', -'abs_normal.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down0 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_current0 = [ -'abs_normal.xml#Reference', -'abs_normal.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-2018.00.00.0/doc/abs_print_mat.xml cppad-2019.02.00.0/doc/abs_print_mat.xml --- cppad-2018.00.00.0/doc/abs_print_mat.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs_print_mat.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,181 +0,0 @@ - - - -abs_normal: Print a Vector or Matrix - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -abs_print_mat - -

-
abs_normal: Print a Vector or Matrix
-
-Syntax - -
- -abs_print_mat(namenrncmat) - - -
-
-Prototype - -

-template <class Vector>
-void abs_print_mat(
-     const std::string& name ,
-     size_t             nr   ,
-     size_t             nc   ,
-     const Vector&      mat  )
-
-Purpose -
-This routine is used by the abs_normal - examples to print -vectors and matrices. -A new-line is printed at the end of this output. - -
-
-name -
-This is a name that is printed before the vector or matrix. - -
-
-nr -
-This is the number of rows in the matrix. Use -nr = 1 - for -row vectors. - -
-
-nc -
-This is the number of columns in the matrix. Use -nc = 1 - for -column vectors. - -
-
-mat -
-This is a -row-major - representation -of the matrix (hence a SimpleVector -). -The syntax - -
-     std::cout << 
mat[i]
-
-must output the i-th element of the simple vector -mat -. - - -
Input File: example/abs_normal/abs_print_mat.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_abs_print_mat_xml.js cppad-2019.02.00.0/doc/_abs_print_mat_xml.js --- cppad-2018.00.00.0/doc/_abs_print_mat_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_print_mat_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'abs_print_mat.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_current0 = [ -'abs_print_mat.xml#Syntax', -'abs_print_mat.xml#Prototype', -'abs_print_mat.xml#Purpose', -'abs_print_mat.xml#name', -'abs_print_mat.xml#nr', -'abs_print_mat.xml#nc', -'abs_print_mat.xml#mat' -]; -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-2018.00.00.0/doc/abs.xml cppad-2019.02.00.0/doc/abs.xml --- cppad-2018.00.00.0/doc/abs.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/abs.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,235 +0,0 @@ - - - -AD Absolute Value Functions: abs, fabs - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
AD Absolute Value Functions: abs, fabs
-
-Syntax - -
- -y = abs(x)
-
- -y = fabs(x) - - -
-
-x, y -
-See the possible types - -for a unary standard math function. - -
-
-Atomic -
-In the case where -x - is an AD type, -this is an atomic operation -. - -
-
-Complex Types -
-The functions abs and -fabs - -are not defined for the base types -std::complex<float> or std::complex<double> -because the complex abs function is not complex differentiable -(see complex types faq -). - -
-
-Derivative -
-CppAD defines the derivative of the abs function is -the sign - function; i.e., - - -abs - -( -1 -) - - -( -x -) -= -sign - -( -x -) -= -{ -+ -1 - -if - - -x -> -0 - -0 - -if - - -x -= -0 - --1 - -if - - -x -< -0 - - - - -The result for -x == 0 - used to be a directional derivative. - -
-
-Example - -
-The file -fabs.cpp - -contains an example and test of this function. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/abs.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_abs_xml.js cppad-2019.02.00.0/doc/_abs_xml.js --- cppad-2018.00.00.0/doc/_abs_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_abs_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +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', -'unary_standard_math.xml', -'abs.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 = [ -'fabs.cpp.xml' -]; -var list_current0 = [ -'abs.xml#Syntax', -'abs.xml#x, y', -'abs.xml#Atomic', -'abs.xml#Complex Types', -'abs.xml#Derivative', -'abs.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-2018.00.00.0/doc/acos.cpp.xml cppad-2019.02.00.0/doc/acos.cpp.xml --- cppad-2018.00.00.0/doc/acos.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/acos.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ - - - -The AD acos Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -acos.cppHeadings

- - - -
The AD acos Function: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool acos(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> cos_of_x0 = CppAD::cos(x[0]);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::acos(cos_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 acos
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero] = cos_of_x0;
-     AD<double> result = CppAD::acos(v[zero]);
-     ok     &= NearEqual(result, x0, eps, eps);
-
-     return ok;
-}
-
-
-
Input File: example/general/acos.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_acos.cpp_xml.js cppad-2019.02.00.0/doc/_acos.cpp_xml.js --- cppad-2018.00.00.0/doc/_acos.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_acos.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'acos.xml', -'acos.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 = [ -'acos.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-2018.00.00.0/doc/acos_forward.xml cppad-2019.02.00.0/doc/acos_forward.xml --- cppad-2018.00.00.0/doc/acos_forward.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/acos_forward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,832 +0,0 @@ - - - -Inverse Cosine and Hyperbolic Cosine Forward Mode Theory - - - - - - - - - - - - - - - - -
- -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/appendix/theory/acos_forward.omh - - - diff -Nru cppad-2018.00.00.0/doc/_acos_forward_xml.js cppad-2019.02.00.0/doc/_acos_forward_xml.js --- cppad-2018.00.00.0/doc/_acos_forward_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_acos_forward_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', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'acos_forward.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/acosh.cpp.xml cppad-2019.02.00.0/doc/acosh.cpp.xml --- cppad-2018.00.00.0/doc/acosh.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/acosh.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ - - - -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/general/acosh.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_acosh.cpp_xml.js cppad-2019.02.00.0/doc/_acosh.cpp_xml.js --- cppad-2018.00.00.0/doc/_acosh.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_acosh.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'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-2018.00.00.0/doc/acosh.xml cppad-2019.02.00.0/doc/acosh.xml --- cppad-2018.00.00.0/doc/acosh.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/acosh.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,202 +0,0 @@ - - - -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/core/acosh.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_acosh_xml.js cppad-2019.02.00.0/doc/_acosh_xml.js --- cppad-2018.00.00.0/doc/_acosh_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_acosh_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +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', -'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-2018.00.00.0/doc/acos_reverse.xml cppad-2019.02.00.0/doc/acos_reverse.xml --- cppad-2018.00.00.0/doc/acos_reverse.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/acos_reverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1634 +0,0 @@ - - - -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/appendix/theory/acos_reverse.omh - - - diff -Nru cppad-2018.00.00.0/doc/_acos_reverse_xml.js cppad-2019.02.00.0/doc/_acos_reverse_xml.js --- cppad-2018.00.00.0/doc/_acos_reverse_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_acos_reverse_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', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'acos_reverse.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/acos.xml cppad-2019.02.00.0/doc/acos.xml --- cppad-2018.00.00.0/doc/acos.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/acos.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ - - - -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_acos_xml.js cppad-2019.02.00.0/doc/_acos_xml.js --- cppad-2018.00.00.0/doc/_acos_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_acos_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'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-2018.00.00.0/doc/ad_assign.cpp.xml cppad-2019.02.00.0/doc/ad_assign.cpp.xml --- cppad-2018.00.00.0/doc/ad_assign.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad_assign.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ - - - -AD Assignment: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ad_assign.cppHeadings

- - - -
AD Assignment: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool ad_assign(void)
-{     bool ok = true;   // initialize test result flag
-     using CppAD::AD;  // so can use AD in place of CppAD::AD
-
-     // assignment to base value
-     AD<double> a;
-     a = 1.;
-     ok &= a == 1.;
-
-     // assignment to a value that converts to the base type
-     a = 2;
-     ok &= a == 2.;
-
-     // assignment to an AD<Base>
-     AD<double> b(3.);
-     a = b;
-     ok &= a == 3.;
-
-     // assignment to an VecAD<Base> element
-     CppAD::VecAD<double> v(1);
-     v[0] = 4.;
-     a = v[0];
-     ok &= a == 4.;
-
-     return ok;
-}
-
-
Input File: example/general/ad_assign.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_assign.cpp_xml.js cppad-2019.02.00.0/doc/_ad_assign.cpp_xml.js --- cppad-2018.00.00.0/doc/_ad_assign.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_assign.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'ad_assign.xml', -'ad_assign.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 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down1 = [ -'ad_assign.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-2018.00.00.0/doc/ad_assign.xml cppad-2019.02.00.0/doc/ad_assign.xml --- cppad-2018.00.00.0/doc/ad_assign.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad_assign.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,161 +0,0 @@ - - - -AD Assignment Operator - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
AD Assignment Operator
-
-Syntax - -
- -y = x - - -
-
-Purpose -
-Assigns the value in -x - to the object -y -. -In either case, - -
-
-x -
-The argument -x - has prototype - -
-     const 
Type &x
-
-where -Type - is - -VecAD<Base>::reference -, - -AD<Base> -, - -Base -, -or any type that has an implicit constructor of the form - -Base(x) -. - -
-
-y -
-The target -y - has prototype - -
-     AD<
Basey
-
-
-Example - -
-The file ad_assign.cpp - contain examples and tests of these operations. -It test returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/ad_assign.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_assign_xml.js cppad-2019.02.00.0/doc/_ad_assign_xml.js --- cppad-2018.00.00.0/doc/_ad_assign_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_assign_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'ad_assign.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 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down0 = [ -'ad_assign.cpp.xml' -]; -var list_current0 = [ -'ad_assign.xml#Syntax', -'ad_assign.xml#Purpose', -'ad_assign.xml#x', -'ad_assign.xml#y', -'ad_assign.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-2018.00.00.0/doc/ad_binary.xml cppad-2019.02.00.0/doc/ad_binary.xml --- cppad-2018.00.00.0/doc/ad_binary.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad_binary.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,546 +0,0 @@ - - - -AD Binary Arithmetic Operators - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
AD Binary Arithmetic Operators
-
-Syntax - -
- -z = x Op y - - -
-
-Purpose -
-Performs arithmetic operations where either -x - or -y - -has type - -AD<Base> - or -VecAD<Base>::reference -. - -
-
-Op -
-The operator -Op - is one of the following - -
- -Op - Meaning
- -+ - -z - is -x - plus -y -
- -- - -z - is -x - minus -y -
- -* - -z - is -x - times -y -
- -/ - -z - is -x - divided by -y - -
-
-Base -
-The type -Base - is determined by the operand that -has type -AD<Base> - or -VecAD<Base>::reference -. - -
-
-x -
-The operand -x - has the following prototype - -
-     const 
Type &x
-
-where -Type - is - -VecAD<Base>::reference -, - -AD<Base> -, - -Base -, or -double. - -
-
-y -
-The operand -y - has the following prototype - -
-     const 
Type &y
-
-where -Type - is - -VecAD<Base>::reference -, - -AD<Base> -, - -Base -, or -double. - - -
-
-z -
-The result -z - has the following prototype - -
-     
Type z
-
-where -Type - is - -AD<Base> -. - -
-
-Operation Sequence -
-This is an atomic - -AD of Base - operation -and hence it is part of the current -AD of -Base - -operation sequence -. - - - -
-
-Example -
-The following files contain examples and tests of these functions. -Each test returns true if it succeeds and false otherwise. - - - - - -
- -add.cpp -AD Binary Addition: Example and Test
- -sub.cpp -AD Binary Subtraction: Example and Test
- -mul.cpp -AD Binary Multiplication: Example and Test
- -div.cpp -AD Binary Division: Example and Test
- -
-
-Derivative -
-If - -f - - - and - -g - - - are -Base functions - - -
-
-Addition - - - - -[ -f -( -x -) -+ -g -( -x -) -] - - -x - - -= - -f -( -x -) - - -x - - -+ - -g -( -x -) - - -x - - - - -
-Subtraction - - - - -[ -f -( -x -) -- -g -( -x -) -] - - -x - - -= - -f -( -x -) - - -x - - -- - -g -( -x -) - - -x - - - - -
-Multiplication - - - - -[ -f -( -x -) -* -g -( -x -) -] - - -x - - -= -g -( -x -) -* - -f -( -x -) - - -x - - -+ -f -( -x -) -* - -g -( -x -) - - -x - - - - -
-Division - - - - -[ -f -( -x -) -/ -g -( -x -) -] - - -x - - -= -[ -1 -/ -g -( -x -) -] -* - -f -( -x -) - - -x - - -- -[ -f -( -x -) -/ -g -( -x -) -2 - -] -* - -g -( -x -) - - -x - - - - - -
Input File: cppad/core/ad_binary.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_binary_xml.js cppad-2019.02.00.0/doc/_ad_binary_xml.js --- cppad-2018.00.00.0/doc/_ad_binary_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_binary_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +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', -'arithmetic.xml', -'ad_binary.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down0 = [ -'add.cpp.xml', -'sub.cpp.xml', -'mul.cpp.xml', -'div.cpp.xml' -]; -var list_current0 = [ -'ad_binary.xml#Syntax', -'ad_binary.xml#Purpose', -'ad_binary.xml#Op', -'ad_binary.xml#Base', -'ad_binary.xml#x', -'ad_binary.xml#y', -'ad_binary.xml#z', -'ad_binary.xml#Operation Sequence', -'ad_binary.xml#Example', -'ad_binary.xml#Derivative', -'ad_binary.xml#Derivative.Addition', -'ad_binary.xml#Derivative.Subtraction', -'ad_binary.xml#Derivative.Multiplication', -'ad_binary.xml#Derivative.Division' -]; -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-2018.00.00.0/doc/ad_ctor.cpp.xml cppad-2019.02.00.0/doc/ad_ctor.cpp.xml --- cppad-2018.00.00.0/doc/ad_ctor.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad_ctor.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ - - - -AD Constructors: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ad_ctor.cppHeadings

- - - -
AD Constructors: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool ad_ctor(void)
-{     bool ok = true;   // initialize test result flag
-     using CppAD::AD;  // so can use AD in place of CppAD::AD
-
-     // default constructor
-     AD<double> a;
-     a = 0.;
-     ok &= a == 0.;
-
-     // constructor from base type
-     AD<double> b(1.);
-     ok &= b == 1.;
-
-     // constructor from another type that converts to the base type
-     AD<double> c(2);
-     ok &= c == 2.;
-
-     // constructor from AD<Base>
-     AD<double> d(c);
-     ok &= d == 2.;
-
-     // constructor from a VecAD<Base> element
-     CppAD::VecAD<double> v(1);
-     v[0] = 3.;
-     AD<double> e( v[0] );
-     ok &= e == 3.;
-
-     return ok;
-}
-
-
-
Input File: example/general/ad_ctor.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_ctor.cpp_xml.js cppad-2019.02.00.0/doc/_ad_ctor.cpp_xml.js --- cppad-2018.00.00.0/doc/_ad_ctor.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_ctor.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'ad_ctor.xml', -'ad_ctor.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 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down1 = [ -'ad_ctor.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-2018.00.00.0/doc/ad_ctor.xml cppad-2019.02.00.0/doc/ad_ctor.xml --- cppad-2018.00.00.0/doc/ad_ctor.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad_ctor.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ - - - -AD Constructors - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
AD Constructors
-
-Syntax - -
- -AD<Basey()
-
- -AD<Basey(x)
-
-
-Purpose -
-creates a new -AD<Base> - object -y - -and initializes its value as equal to -x -. - -
-
-x - - -
-
-implicit -
-There is an implicit constructor where -x - has one of the following -prototypes: - -
-     const 
Base&        x
-     const VecAD<
Base>& x
-
-
-explicit -
-There is an explicit constructor where -x - has prototype - -
-     const 
Type&        x
-
-for any type that has an explicit constructor of the form - -Base(x) -. - -
-
-y -
-The target -y - has prototype - -
-     AD<
Basey
-
-
-Example - -
-The files ad_ctor.cpp - contain examples and tests of these operations. -It test returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/ad_ctor.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_ctor_xml.js cppad-2019.02.00.0/doc/_ad_ctor_xml.js --- cppad-2018.00.00.0/doc/_ad_ctor_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_ctor_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'ad_ctor.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 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down0 = [ -'ad_ctor.cpp.xml' -]; -var list_current0 = [ -'ad_ctor.xml#Syntax', -'ad_ctor.xml#Purpose', -'ad_ctor.xml#x', -'ad_ctor.xml#x.implicit', -'ad_ctor.xml#x.explicit', -'ad_ctor.xml#y', -'ad_ctor.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-2018.00.00.0/doc/add.cpp.xml cppad-2019.02.00.0/doc/add.cpp.xml --- cppad-2018.00.00.0/doc/add.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/add.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ - - - -AD Binary Addition: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -add.cppHeadings

-
AD Binary Addition: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool Add(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * 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);
-
-     // some binary addition operations
-     AD<double> a = x[0] + 1.; // AD<double> + double
-     AD<double> b = a    + 2;  // AD<double> + int
-     AD<double> c = 3.   + b;  // double     + AD<double>
-     AD<double> d = 4    + c;  // int        + AD<double>
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = d + x[0];          // AD<double> + AD<double>
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0] , 2. * x0 + 10, eps99, eps99);
-
-     // forward computation of partials 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], 2., eps99, eps99);
-
-     // 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], 2., eps99, eps99);
-
-     // use a VecAD<Base>::reference object with addition
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero] = a;
-     AD<double> result = v[zero] + 2;
-     ok     &= (result == b);
-
-     return ok;
-}
-
-
-
Input File: example/general/add.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_add.cpp_xml.js cppad-2019.02.00.0/doc/_add.cpp_xml.js --- cppad-2018.00.00.0/doc/_add.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_add.cpp_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', -'ad.xml', -'advalued.xml', -'arithmetic.xml', -'ad_binary.xml', -'add.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down1 = [ -'add.cpp.xml', -'sub.cpp.xml', -'mul.cpp.xml', -'div.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-2018.00.00.0/doc/addeq.cpp.xml cppad-2019.02.00.0/doc/addeq.cpp.xml --- cppad-2018.00.00.0/doc/addeq.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/addeq.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ - - - -AD Compound Assignment Addition: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -AddEq.cppHeadings

-
AD Compound Assignment Addition: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool AddEq(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t  n = 1;
-     double x0 = .5;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0]      = x0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     // range space vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = x[0];         // initial value
-     y[0] += 2;           // AD<double> += int
-     y[0] += 4.;          // AD<double> += double
-     y[1] = y[0] += x[0]; // use the result of a compound assignment
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0] , x0+2.+4.+x0, eps99, eps99);
-     ok &= NearEqual(y[1] ,        y[0], eps99, eps99);
-
-     // forward computation of partials 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], 2., eps99, eps99);
-     ok   &= NearEqual(dy[1], 2., eps99, eps99);
-
-     // reverse computation of derivative of y[0]
-     CPPAD_TESTVECTOR(double)  w(m);
-     CPPAD_TESTVECTOR(double) dw(n);
-     w[0]  = 1.;
-     w[1]  = 0.;
-     dw    = f.Reverse(1, w);
-     ok   &= NearEqual(dw[0], 2., eps99, eps99);
-
-     // use a VecAD<Base>::reference object with computed addition
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     AD<double> result = 1;
-     v[zero] = 2;
-     result += v[zero];
-     ok     &= (result == 3);
-
-     return ok;
-}
-
-
-
Input File: example/general/add_eq.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_addeq.cpp_xml.js cppad-2019.02.00.0/doc/_addeq.cpp_xml.js --- cppad-2018.00.00.0/doc/_addeq.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_addeq.cpp_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', -'ad.xml', -'advalued.xml', -'arithmetic.xml', -'compound_assign.xml', -'addeq.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down1 = [ -'addeq.cpp.xml', -'sub_eq.cpp.xml', -'mul_eq.cpp.xml', -'div_eq.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-2018.00.00.0/doc/addon.xml cppad-2019.02.00.0/doc/addon.xml --- cppad-2018.00.00.0/doc/addon.xml 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/addon.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,236 +0,0 @@ - - - -CppAD Addons - - - - - - - - - - - - - - - -
- -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 - -
- -tmb - - - adcomp - - An R Interface to CppAD with Random Effects Modeling Utilities -
- -cg - - - CppADCodeGen - - C++ Source Code Generation of CppAD Derivative Calculations -
- -mixed - - - cppad_mixed - - A C++ Interface to Random Effects Laplace Approximation -
- -swig - - - cppad_swig - - A C++ AD Library with a Swig Interface to Perl, Octave, and Python -
- -py - - - pycppad - - A Python Interface to CppAD -
-
-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/appendix/addon.omh - - - diff -Nru cppad-2018.00.00.0/doc/_addon_xml.js cppad-2019.02.00.0/doc/_addon_xml.js --- cppad-2018.00.00.0/doc/_addon_xml.js 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/_addon_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -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', -'directory.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-2018.00.00.0/doc/ad_fun.cpp.xml cppad-2019.02.00.0/doc/ad_fun.cpp.xml --- cppad-2018.00.00.0/doc/ad_fun.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad_fun.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,203 +0,0 @@ - - - -Creating Your Own Interface to an ADFun Object - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ad_fun.cppHeadings

-
Creating Your Own Interface to an ADFun Object
-

-# include <cppad/cppad.hpp>
-
-namespace {
-
-     // This class is an example of a different interface to an AD function object
-     template <class Base>
-     class my_ad_fun {
-
-     private:
-          CppAD::ADFun<Base> 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<Base> except that no zero
-          // order forward sweep is done. Note Hessian and Jacobian do
-          // their own zero order forward mode sweep.
-          template <class ADvector>
-          my_ad_fun(const ADvector& x, const ADvector& y)
-          {     f.Dependent(x, y); }
-
-          // same as ADFun<Base>::Jacobian
-          template <class VectorBase>
-          VectorBase jacobian(const VectorBase& x)
-          {     return f.Jacobian(x); }
-
-          // same as ADFun<Base>::Hessian
-             template <typename VectorBase>
-          VectorBase hessian(const VectorBase &x, const VectorBase &w)
-          {     return f.Hessian(x, w); }
-     };
-
-} // End empty namespace
-
-bool ad_fun(void)
-{     // This example is similar to example/jacobian.cpp, except that it
-     // uses my_ad_fun instead of ADFun.
-
-     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     using CppAD::exp;
-     using CppAD::sin;
-     using CppAD::cos;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>)  X(n);
-     X[0] = 1.;
-     X[1] = 2.;
-
-     // declare independent variables and starting recording
-     CppAD::Independent(X);
-
-     // a calculation between the domain and range values
-     AD<double> Square = X[0] * X[0];
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>)  Y(m);
-     Y[0] = Square * exp( X[1] );
-     Y[1] = Square * sin( X[1] );
-     Y[2] = Square * cos( X[1] );
-
-     // create f: X -> Y and stop tape recording
-     my_ad_fun<double> f(X, Y);
-
-     // new value for the independent variable vector
-     CPPAD_TESTVECTOR(double) x(n);
-     x[0] = 2.;
-     x[1] = 1.;
-
-     // compute the derivative at this x
-     CPPAD_TESTVECTOR(double) jac( m * n );
-     jac = f.jacobian(x);
-
-     /*
-     F'(x) = [ 2 * x[0] * exp(x[1]) ,  x[0] * x[0] * exp(x[1]) ]
-             [ 2 * x[0] * sin(x[1]) ,  x[0] * x[0] * cos(x[1]) ]
-             [ 2 * x[0] * cos(x[1]) , -x[0] * x[0] * sin(x[i]) ]
-     */
-     ok &=  NearEqual( 2.*x[0]*exp(x[1]), jac[0*n+0], eps99, eps99);
-     ok &=  NearEqual( 2.*x[0]*sin(x[1]), jac[1*n+0], eps99, eps99);
-     ok &=  NearEqual( 2.*x[0]*cos(x[1]), jac[2*n+0], eps99, eps99);
-
-     ok &=  NearEqual( x[0] * x[0] *exp(x[1]), jac[0*n+1], eps99, eps99);
-     ok &=  NearEqual( x[0] * x[0] *cos(x[1]), jac[1*n+1], eps99, eps99);
-     ok &=  NearEqual(-x[0] * x[0] *sin(x[1]), jac[2*n+1], eps99, eps99);
-
-     return ok;
-}
-
-
-
-
Input File: example/general/ad_fun.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_fun.cpp_xml.js cppad-2019.02.00.0/doc/_ad_fun.cpp_xml.js --- cppad-2018.00.00.0/doc/_ad_fun.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_fun.cpp_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', -'example.xml', -'general.xml', -'ad_fun.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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' -]; -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-2018.00.00.0/doc/adfun.xml cppad-2019.02.00.0/doc/adfun.xml --- cppad-2018.00.00.0/doc/adfun.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/adfun.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ - - - -ADFun Objects - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -

-
ADFun Objects
-
-Purpose -
-An AD of -Base - -operation sequence - -is stored in an ADFun object by its FunConstruct -. -The ADFun object can then be used to calculate function values, -derivative values, and other values related to the corresponding function. - -
-
-Contents -
- -
record_adfunCreate an ADFun Object (Record an Operation Sequence)
driversFirst and Second Order Derivatives: Easy Drivers
ForwardForward Mode
ReverseReverse Mode
sparsity_patternCalculating Sparsity Patterns
sparse_derivativeCalculating Sparse Derivatives
optimizeOptimize an ADFun Object Tape
abs_normalAbs-normal Representation of Non-Smooth Functions
FunCheckCheck an ADFun Sequence of Operations
check_for_nanCheck an ADFun Object For Nan Results
-
Input File: cppad/core/ad_fun.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_adfun_xml.js cppad-2019.02.00.0/doc/_adfun_xml.js --- cppad-2018.00.00.0/doc/_adfun_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_adfun_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_current0 = [ -'adfun.xml#Purpose', -'adfun.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_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-2018.00.00.0/doc/ad_in_c.cpp.xml cppad-2019.02.00.0/doc/ad_in_c.cpp.xml --- cppad-2018.00.00.0/doc/ad_in_c.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad_in_c.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,551 +0,0 @@ - - - -Example and Test Linking CppAD to Languages Other than C++ - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ad_in_c.cppHeadings

-
Example and Test Linking CppAD to Languages Other than C++
-
# include <cstdio>
-# include <cppad/cppad.hpp>
-# include <list>
-
-namespace { // Begin empty namespace *****************************************
-
-/*
-void debug_print(const char *label, double d)
-{     using std::printf;
-
-     unsigned char *byte = reinterpret_cast<unsigned char *>(&d);
-     size_t n_byte = sizeof(d);
-     printf("%s", label);
-     for(size_t i = 0; i < n_byte; i++)
-          printf("%x", byte[i]);
-     printf("\n");
-}
-*/
-
-// type in C corresponding to an AD<double> object
-typedef struct { void*  p_void; } cad;
-
-// type in C corresponding to a an ADFun<double>
-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,
-     op_exp, op_log,  op_sin,  op_sinh, op_sqrt
-} cad_unary_op;
-
-// --------------------------------------------------------------------------
-// helper code not intended for use by C code  ------------------------------
-using CppAD::AD;
-using CppAD::ADFun;
-using CppAD::vector;
-using CppAD::NearEqual;
-
-void cad2vector(size_t n, cad* p_cad, vector< AD<double> >& v)
-{     assert( n == v.size() );
-     for(size_t j = 0; j < n; j++)
-     {     AD<double>* p_ad =
-               reinterpret_cast< AD<double>* > (p_cad[j].p_void);
-          v[j] = *p_ad;
-     }
-}
-
-void vector2cad(size_t n, vector< AD<double> >& v, cad* p_cad)
-{     assert( n == v.size() );
-     for(size_t j = 0; j < n; j++)
-     {     AD<double>* p_ad =
-               reinterpret_cast< AD<double>* > (p_cad[j].p_void);
-          *p_ad = v[j];
-     }
-}
-
-void double2vector(size_t n, double* p_dbl, vector<double>& v)
-{     assert( n == v.size() );
-     for(size_t j = 0; j < n; j++)
-          v[j] = p_dbl[j];
-}
-
-void vector2double(size_t n, vector<double>& v, double *p_dbl)
-{     assert( n == v.size() );
-     for(size_t j = 0; j < n; j++)
-          p_dbl[j] = v[j];
-}
-
-std::list<void*> allocated;
-# ifdef NDEBUG
-inline void push_allocated(void *p)
-{ }
-inline void pop_allocated(void *p)
-{ }
-# else
-inline void push_allocated(void *p)
-{     assert( p != 0 );
-     allocated.push_front(p);
-}
-inline void pop_allocated(void *p)
-{     std::list<void*>::iterator i;
-     for(i = allocated.begin(); i != allocated.end(); ++i)
-     {     if( *i == p )
-          {     allocated.erase(i);
-               return;
-          }
-     }
-     assert( 0 );
-}
-
-# endif
-// --------------------------------------------------------------------------
-// Here is the code that links C to CppAD. You will have to add more
-// functions and operators to make a complete language link.
-//
-extern "C"
-bool cad_near_equal(double x, double y)
-{     double eps = 10. * std::numeric_limits<double>::epsilon();
-     return NearEqual(x, y, eps, 0.);
-}
-
-// 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"
-void cad_new_ad(cad *p_cad, double value)
-{     // make sure pointer is not currently allocated
-     assert( p_cad->p_void == 0 );
-
-     AD<double>* p_ad   = new AD<double>(value);
-     p_cad->p_void      = reinterpret_cast<void*>(p_ad);
-
-     // put in list of allocate pointers
-     push_allocated( p_cad->p_void );
-}
-
-// 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"
-void cad_del_ad(cad* p_cad)
-{     // make sure that p_cad has been allocated
-     pop_allocated( p_cad->p_void );
-
-     AD<double>* p_ad   = reinterpret_cast< AD<double>* >( p_cad->p_void );
-     delete p_ad;
-
-     // special value for pointers that are not allocated
-     p_cad->p_void = 0;
-}
-
-// extract the value from a C++ AD object
-// extern "C"
-double cad_value(cad* p_cad)
-{     AD<double>* p_ad = reinterpret_cast< AD<double>* > (p_cad->p_void);
-     return Value( Var2Par(*p_ad) );
-}
-
-// preform a C AD unary operation
-extern "C"
-void cad_unary(cad_unary_op op, cad* p_operand, cad* p_result)
-{     AD<double> *operand, *result;
-     result  = reinterpret_cast< AD<double>* > (p_result->p_void);
-     operand = reinterpret_cast< AD<double>* > (p_operand->p_void);
-     switch(op)
-     {
-          case op_abs:
-          *result = fabs( *operand );
-          break;
-
-          case op_acos:
-          *result = acos( *operand );
-          break;
-
-          case op_asin:
-          *result = asin( *operand );
-          break;
-
-          case op_atan:
-          *result = atan( *operand );
-          break;
-
-          case op_cos:
-          *result = cos( *operand );
-          break;
-
-          case op_cosh:
-          *result = cosh( *operand );
-          break;
-
-          case op_exp:
-          *result = exp( *operand );
-          break;
-
-          case op_log:
-          *result = log( *operand );
-          break;
-
-          case op_sin:
-          *result = sin( *operand );
-          break;
-
-          case op_sinh:
-          *result = sinh( *operand );
-          break;
-
-          case op_sqrt:
-          *result = sqrt( *operand );
-          break;
-
-          default:
-          // not a unary operator
-          assert(0);
-          break;
-
-     }
-     return;
-}
-
-// 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<double> *result, *left, *right;
-     result = reinterpret_cast< AD<double>* > (p_result->p_void);
-     left   = reinterpret_cast< AD<double>* > (p_left->p_void);
-     right  = reinterpret_cast< AD<double>* > (p_right->p_void);
-     assert( result != 0 );
-     assert( left != 0 );
-     assert( right != 0 );
-
-     switch(op)
-     {     case op_add:
-          *result         = *left + (*right);
-          break;
-
-          case op_sub:
-          *result         = *left - (*right);
-          break;
-
-          case op_mul:
-          *result         = *left * (*right);
-          break;
-
-          case op_div:
-          *result         = *left / (*right);
-          break;
-
-          default:
-          // not a binary operator
-          assert(0);
-     }
-     return;
-}
-
-// declare the independent variables in C++
-extern "C"
-void cad_independent(size_t n, cad* px_cad)
-{     vector< AD<double> > x(n);
-     cad2vector(n, px_cad, x);
-     CppAD::Independent(x);
-     vector2cad(n, x, px_cad);
-}
-
-// create an ADFun object in C++
-extern "C"
-cad_fun cad_new_fun(size_t n, size_t m, cad* px_cad, cad* py_cad)
-{     cad_fun fun;
-
-     ADFun<double>* p_adfun = new ADFun<double>;
-     vector< AD<double> > x(n);
-     vector< AD<double> > y(m);
-     cad2vector(n, px_cad, x);
-     cad2vector(m, py_cad, y);
-     p_adfun->Dependent(x, y);
-
-     fun.p_void = reinterpret_cast<void*>( p_adfun );
-
-     // put in list of allocate pointers
-     push_allocated( fun.p_void );
-
-     return fun;
-}
-
-// delete an AD function object in C
-extern "C"
-void cad_del_fun(cad_fun *fun)
-{     // make sure this pointer has been allocated
-     pop_allocated( fun->p_void );
-
-     ADFun<double>* p_adfun
-          = reinterpret_cast< ADFun<double>* > (fun->p_void);
-     delete p_adfun;
-
-     // special value for pointers that are not allocated
-     fun->p_void = 0;
-}
-
-// evaluate the Jacobian corresponding to a function object
-extern "C"
-void cad_jacobian(cad_fun fun,
-     size_t n, size_t m, double* px, double* pjac )
-{     assert( fun.p_void != 0 );
-
-     ADFun<double>* p_adfun =
-          reinterpret_cast< ADFun<double>* >(fun.p_void);
-     vector<double> x(n), jac(n * m);
-
-     double2vector(n, px, x);
-     jac = p_adfun->Jacobian(x);
-     vector2double(n * m, jac, pjac);
-}
-
-// forward mode
-extern "C"
-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<double>* p_adfun =
-          reinterpret_cast< ADFun<double>* >(fun.p_void);
-     vector<double> x(n), y(m);
-
-     double2vector(n, px, x);
-     y = p_adfun->Forward(order, x);
-     vector2double(m, y, py);
-}
-
-// check that allocated list has been completely freed
-extern "C"
-bool cad_allocated_empty(void)
-{     return allocated.empty();
-}
-
-} // End empty namespace ****************************************************
-
-# include <math.h> // used to check results in c code below
-
-# define N 2       // number of independent variables in example
-# define M 5       // number of dependent variables in example
-
-// -------------------------------------------------------------------------
-// Here is the C code that uses the CppAD link above
-bool ad_in_c(void)
-{     // This routine is intentionally coded as if it were written in C
-     // as an example of how you can link C, and other languages to CppAD
-     bool ok = true;
-
-     // x vector of AD objects in C
-     double value;
-     size_t j, n = N;
-     cad X[N];
-     for(j = 0; j < n; j++)
-     {     value       = (double) (j+1) / (double) n;
-          X[j].p_void = 0;
-          cad_new_ad(X + j, value);
-     }
-
-     // y vector of AD objects in C
-     size_t i, m = M;
-     cad Y[M];
-     for(i = 0; i < m; i++)
-     {     value       = 0.; // required, but not used
-          Y[i].p_void = 0;
-          cad_new_ad(Y + i, value);
-     }
-
-     // declare X as the independent variable vector
-     cad_independent(n, X);
-
-     // y[0] = x[0] + x[1]
-     cad_binary(op_add, X+0, X+1, Y+0);
-     ok &= cad_near_equal( cad_value(Y+0), cad_value(X+0)+cad_value(X+1) );
-
-     // y[1] = x[0] - x[1]
-     cad_binary(op_sub, X+0, X+1, Y+1);
-     ok &= cad_near_equal( cad_value(Y+1), cad_value(X+0)-cad_value(X+1) );
-
-     // y[2] = x[0] * x[1]
-     cad_binary(op_mul, X+0, X+1, Y+2);
-     ok &= cad_near_equal( cad_value(Y+2), cad_value(X+0)*cad_value(X+1) );
-
-     // y[3] = x[0] * x[1]
-     cad_binary(op_div, X+0, X+1, Y+3);
-     ok &= cad_near_equal( cad_value(Y+3), cad_value(X+0)/cad_value(X+1) );
-
-     // y[4] = sin(x[0]) + asin(sin(x[0]))
-     cad sin_x0 = { 0 };       // initialize p_void as zero
-     cad_new_ad( &sin_x0, 0.);
-     cad_unary(op_sin, X+0, &sin_x0);
-     ok &= cad_near_equal(cad_value(&sin_x0), sin(cad_value(X+0)) );
-
-     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),
-          asin( cad_value(&sin_x0) )
-     );
-
-     cad_binary(op_add, &sin_x0, &asin_sin_x0, Y+4);
-     ok &= cad_near_equal(
-          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);
-
-     // now use the function object
-     double x[N], jac[N * M];
-     x[0] = 1.;
-     x[1] = .5;
-
-     // compute the Jacobian
-     cad_jacobian(f, n, m, x, jac);
-
-     // check the Jacobian values
-     size_t k = 0;
-     // partial y[0] w.r.t. x[0]
-     ok &= cad_near_equal(jac[k++], 1.);
-     // partial y[0] w.r.t. x[1]
-     ok &= cad_near_equal(jac[k++], 1.);
-     // partial y[1] w.r.t. x[0]
-     ok &= cad_near_equal(jac[k++], 1.);
-     // partial y[1] w.r.t. x[1]
-     ok &= cad_near_equal(jac[k++], -1.);
-     // partial y[2] w.r.t. x[0]
-     ok &= cad_near_equal(jac[k++], x[1]);
-     // partial y[2] w.r.t. x[1]
-     ok &= cad_near_equal(jac[k++], x[0]);
-     // partial y[3] w.r.t. x[0]
-     ok &= cad_near_equal(jac[k++], 1./x[1]);
-     // partial y[3] w.r.t. x[1]
-     ok &= cad_near_equal(jac[k++], -x[0]/(x[1]*x[1]));
-     // partial y[4] w.r.t x[0]
-     ok &= cad_near_equal(jac[k++],  cos(x[0]) + 1.);
-     // partial y[4] w.r.t x[1]
-     ok &= cad_near_equal(jac[k++],  0.);
-
-     // evaluate the function f at a different x
-     size_t order = 0;
-     double y[M];
-     x[0] = .5;
-     x[1] = 1.;
-     cad_forward(f, order, n, m, x, y);
-
-     // check the function values
-     ok &= cad_near_equal(y[0] , x[0] + x[1] );
-     ok &= cad_near_equal(y[1] , x[0] - x[1] );
-     ok &= cad_near_equal(y[2] , x[0] * x[1] );
-     ok &= cad_near_equal(y[3] , x[0] / x[1] );
-     ok &= cad_near_equal(y[4] , sin(x[0]) + asin(sin(x[0])) );
-
-     // delete All C++ copies of the AD objects
-     cad_del_fun( &f );
-     cad_del_ad( &sin_x0 );
-     cad_del_ad( &asin_sin_x0 );
-     for(j = 0; j < n; j++)
-          cad_del_ad(X + j);
-     for(i = 0; i < m; i++)
-          cad_del_ad(Y + i);
-
-     ok     &= cad_allocated_empty();
-     return ok;
-}
-
-
-
Input File: example/general/ad_in_c.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_in_c.cpp_xml.js cppad-2019.02.00.0/doc/_ad_in_c.cpp_xml.js --- cppad-2018.00.00.0/doc/_ad_in_c.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_in_c.cpp_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', -'example.xml', -'general.xml', -'ad_in_c.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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' -]; -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-2018.00.00.0/doc/ad_input.cpp.xml cppad-2019.02.00.0/doc/ad_input.cpp.xml --- cppad-2018.00.00.0/doc/ad_input.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad_input.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ - - - -AD Output Operator: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ad_input.cppHeadings

- - - -
AD Output Operator: Example and Test
-

-# include <cppad/cppad.hpp>
-
-# include <sstream>  // std::istringstream
-# include <string>   // std::string
-
-bool ad_input(void)
-{     bool ok = true;
-
-     // create the input string stream is.
-     std::string str ("123 456");
-     std::istringstream is(str);
-
-     // start and AD<double> recording
-     CPPAD_TESTVECTOR( CppAD::AD<double> ) x(1), y(1);
-     x[0] = 1.0;
-     CppAD::Independent(x);
-     CppAD::AD<double> z = x[0];
-     ok &= Variable(z);
-
-     // 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
-     CppAD::ADFun<double> f(x, y);
-
-     return ok;
-}
-
-
Input File: example/general/ad_input.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_input.cpp_xml.js cppad-2019.02.00.0/doc/_ad_input.cpp_xml.js --- cppad-2018.00.00.0/doc/_ad_input.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_input.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -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_input.xml', -'ad_input.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 = [ -'value.xml', -'integer.xml', -'ad_to_string.xml', -'ad_input.xml', -'ad_output.xml', -'printfor.xml', -'var2par.xml' -]; -var list_down1 = [ -'ad_input.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-2018.00.00.0/doc/ad_input.xml cppad-2019.02.00.0/doc/ad_input.xml --- cppad-2018.00.00.0/doc/ad_input.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad_input.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,227 +0,0 @@ - - - -AD Output Stream Operator - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - -
AD Output Stream Operator
-
-Syntax - -
- -is >> x - - - -
-
-Purpose -
-Sets -x - to a parameter - -with value -b - corresponding to - -
-     
is >> b
-
-where -b - is a -Base - object. -It is assumed that this -Base - input operation returns -a reference to -is -. - -
-
-is -
-The operand -is - has prototype - -
-     std::istream& 
is
-
-
-x -
-The operand -x - has one of the following prototypes - -
-     AD<
Base>&               x
-
-
-Result -
-The result of this operation can be used as a reference to -is -. -For example, if the operand -y - has prototype - -
-     AD<
Basey
-
-then the syntax - -
-     
is >> x >> y
-
-will first read the -Base - value of -x - from -is -, -and then read the -Base - value to -y -. - -
-
-Operation Sequence -
-The result of this operation is not an -AD of Base - object. -Thus it will not be recorded as part of an -AD of -Base - -operation sequence -. - -
-
-Example - -
-The file -ad_input.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/ad_io.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_input_xml.js cppad-2019.02.00.0/doc/_ad_input_xml.js --- cppad-2018.00.00.0/doc/_ad_input_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_input_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -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_input.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_down0 = [ -'ad_input.cpp.xml' -]; -var list_current0 = [ -'ad_input.xml#Syntax', -'ad_input.xml#Purpose', -'ad_input.xml#is', -'ad_input.xml#x', -'ad_input.xml#Result', -'ad_input.xml#Operation Sequence', -'ad_input.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-2018.00.00.0/doc/adolc_alloc_mat.xml cppad-2019.02.00.0/doc/adolc_alloc_mat.xml --- cppad-2018.00.00.0/doc/adolc_alloc_mat.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/adolc_alloc_mat.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,156 +0,0 @@ - - - -Adolc Test Utility: Allocate and Free Memory For a Matrix - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -adolc_alloc_mat - -

-
Adolc Test Utility: Allocate and Free Memory For a Matrix
-
-Syntax - -
- -mat = adolc_alloc_mat(mn)
-
- -adolc_free_mat(mat)
-
-
-Purpose -
-Use the thread_alloc - memory allocator to allocate and free -memory that can be used as a matrix with the Adolc package. - -
-
-m -
-Is the number of rows in the matrix. - -
-
-n -
-Is the number of columns in the matrix. - -
-
-mat -
-Is the matrix. -To be specific, -between a call to adolc_alloc_mat, -and the corresponding call to adolc_free_mat, -for -i = 0 , ... , m-1 - -and -j = 0 , ... , n-1 -, - -mat[i][j] - is the element in row -i - -and column -j -. - - -
Input File: speed/adolc/alloc_mat.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_adolc_alloc_mat_xml.js cppad-2019.02.00.0/doc/_adolc_alloc_mat_xml.js --- cppad-2018.00.00.0/doc/_adolc_alloc_mat_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_adolc_alloc_mat_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_adolc.xml', -'adolc_alloc_mat.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'adolc_det_minor.cpp.xml', -'adolc_det_lu.cpp.xml', -'adolc_mat_mul.cpp.xml', -'adolc_ode.cpp.xml', -'adolc_poly.cpp.xml', -'adolc_sparse_hessian.cpp.xml', -'adolc_sparse_jacobian.cpp.xml', -'adolc_alloc_mat.xml' -]; -var list_current0 = [ -'adolc_alloc_mat.xml#Syntax', -'adolc_alloc_mat.xml#Purpose', -'adolc_alloc_mat.xml#m', -'adolc_alloc_mat.xml#n', -'adolc_alloc_mat.xml#mat' -]; -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-2018.00.00.0/doc/adolc_det_lu.cpp.xml cppad-2019.02.00.0/doc/adolc_det_lu.cpp.xml --- cppad-2018.00.00.0/doc/adolc_det_lu.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/adolc_det_lu.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,208 +0,0 @@ - - - -Adolc Speed: Gradient of Determinant Using Lu Factorization - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -adolc_det_lu.cpp - -

-
Adolc Speed: Gradient of Determinant Using Lu Factorization
-
-Specifications -
-See link_det_lu -. - -
-
-Implementation - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <adolc/adolc.h>
-
-# include <cppad/speed/det_by_lu.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/utility/track_new_del.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_det_lu(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &matrix   ,
-     CppAD::vector<double>     &gradient )
-{
-     // speed test global option values
-     if( global_option["onetape"] || global_option["atomic"] )
-          return false;
-     if( global_option["memory"] || global_option["optimize"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-     int tag  = 0;         // tape identifier
-     int keep = 1;         // keep forward mode results in buffer
-     int m    = 1;         // number of dependent variables
-     int n    = size*size; // number of independent variables
-     double f;             // function value
-     int j;                // temporary index
-
-     // set up for thread_alloc memory allocator (fast and checks for leaks)
-     using CppAD::thread_alloc; // the allocator
-     size_t size_min;           // requested number of elements
-     size_t size_out;           // capacity of an allocation
-
-     // object for computing determinant
-     typedef adouble            ADScalar;
-     typedef ADScalar*          ADVector;
-     CppAD::det_by_lu<ADScalar> Det(size);
-
-     // AD value of determinant
-     ADScalar   detA;
-
-     // AD version of matrix
-     size_min    = n;
-     ADVector A  = thread_alloc::create_array<ADScalar>(size_min, size_out);
-
-     // vectors of reverse mode weights
-     size_min    = m;
-     double* u   = thread_alloc::create_array<double>(size_min, size_out);
-     u[0] = 1.;
-
-     // vector with matrix value
-     size_min     = n;
-     double* mat  = thread_alloc::create_array<double>(size_min, size_out);
-
-     // vector to receive gradient result
-     size_min     = n;
-     double* grad = thread_alloc::create_array<double>(size_min, size_out);
-     // ------------------------------------------------------
-     while(repeat--)
-     {     // get the next matrix
-          CppAD::uniform_01(n, mat);
-
-          // declare independent variables
-          trace_on(tag, keep);
-          for(j = 0; j < n; j++)
-               A[j] <<= mat[j];
-
-          // AD computation of the determinant
-          detA = Det(A);
-
-          // create function object f : A -> detA
-          detA >>= f;
-          trace_off();
-
-          // evaluate and return gradient using reverse mode
-          fos_reverse(tag, m, n, u, grad);
-     }
-     // ------------------------------------------------------
-
-     // return matrix and gradient
-     for(j = 0; j < n; j++)
-     {     matrix[j] = mat[j];
-          gradient[j] = grad[j];
-     }
-     // tear down
-     thread_alloc::delete_array(grad);
-     thread_alloc::delete_array(mat);
-     thread_alloc::delete_array(u);
-     thread_alloc::delete_array(A);
-
-     return true;
-}
- -
Input File: speed/adolc/det_lu.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_adolc_det_lu.cpp_xml.js cppad-2019.02.00.0/doc/_adolc_det_lu.cpp_xml.js --- cppad-2018.00.00.0/doc/_adolc_det_lu.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_adolc_det_lu.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_adolc.xml', -'adolc_det_lu.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'adolc_det_minor.cpp.xml', -'adolc_det_lu.cpp.xml', -'adolc_mat_mul.cpp.xml', -'adolc_ode.cpp.xml', -'adolc_poly.cpp.xml', -'adolc_sparse_hessian.cpp.xml', -'adolc_sparse_jacobian.cpp.xml', -'adolc_alloc_mat.xml' -]; -var list_current0 = [ -'adolc_det_lu.cpp.xml#Specifications', -'adolc_det_lu.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/adolc_det_minor.cpp.xml cppad-2019.02.00.0/doc/adolc_det_minor.cpp.xml --- cppad-2018.00.00.0/doc/adolc_det_minor.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/adolc_det_minor.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,234 +0,0 @@ - - - -Adolc Speed: Gradient of Determinant by Minor Expansion - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -adolc_det_minor.cpp - -

-
Adolc Speed: Gradient of Determinant by Minor Expansion
-
-Specifications -
-See link_det_minor -. - -
-
-Implementation - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <adolc/adolc.h>
-# include <cppad/utility/vector.hpp>
-# include <cppad/speed/det_by_minor.hpp>
-# include <cppad/speed/uniform_01.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_det_minor(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &matrix   ,
-     CppAD::vector<double>     &gradient )
-{
-     // speed test global option values
-     if( global_option["atomic"] )
-          return false;
-     if( global_option["memory"] || global_option["optimize"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-     typedef adouble    ADScalar;
-     typedef ADScalar*  ADVector;
-
-     int tag  = 0;         // tape identifier
-     int m    = 1;         // number of dependent variables
-     int n    = size*size; // number of independent variables
-     double f;             // function value
-     int j;                // temporary index
-
-     // set up for thread_alloc memory allocator (fast and checks for leaks)
-     using CppAD::thread_alloc; // the allocator
-     size_t capacity;           // capacity of an allocation
-
-     // object for computing determinant
-     CppAD::det_by_minor<ADScalar> Det(size);
-
-     // AD value of determinant
-     ADScalar   detA;
-
-     // AD version of matrix
-     ADVector A   = thread_alloc::create_array<ADScalar>(size_t(n), capacity);
-
-     // vectors of reverse mode weights
-     double* u    = thread_alloc::create_array<double>(size_t(m), capacity);
-     u[0] = 1.;
-
-     // vector with matrix value
-     double* mat  = thread_alloc::create_array<double>(size_t(n), capacity);
-
-     // vector to receive gradient result
-     double* grad = thread_alloc::create_array<double>(size_t(n), capacity);
-
-     // ----------------------------------------------------------------------
-     if( ! global_option["onetape"] ) while(repeat--)
-     {     // choose a matrix
-          CppAD::uniform_01(n, mat);
-
-          // declare independent variables
-          int keep = 1; // keep forward mode results
-          trace_on(tag, keep);
-          for(j = 0; j < n; j++)
-               A[j] <<= mat[j];
-
-          // AD computation of the determinant
-          detA = Det(A);
-
-          // create function object f : A -> detA
-          detA >>= f;
-          trace_off();
-
-          // evaluate and return gradient using reverse mode
-          fos_reverse(tag, m, n, u, grad);
-     }
-     else
-     {
-          // choose a matrix
-          CppAD::uniform_01(n, mat);
-
-          // declare independent variables
-          int keep = 0; // do not keep forward mode results in buffer
-          trace_on(tag, keep);
-          for(j = 0; j < n; j++)
-               A[j] <<= mat[j];
-
-          // AD computation of the determinant
-          detA = Det(A);
-
-          // create function object f : A -> detA
-          detA >>= f;
-          trace_off();
-
-          while(repeat--)
-          {     // get the next matrix
-               CppAD::uniform_01(n, mat);
-
-               // evaluate the determinant at the new matrix value
-               keep = 1; // keep this forward mode result
-               zos_forward(tag, m, n, keep, mat, &f);
-
-               // evaluate and return gradient using reverse mode
-               fos_reverse(tag, m, n, u, grad);
-          }
-     }
-     // --------------------------------------------------------------------
-
-     // return matrix and gradient
-     for(j = 0; j < n; j++)
-     {     matrix[j] = mat[j];
-          gradient[j] = grad[j];
-     }
-
-     // tear down
-     thread_alloc::delete_array(grad);
-     thread_alloc::delete_array(mat);
-     thread_alloc::delete_array(u);
-     thread_alloc::delete_array(A);
-     return true;
-}
- -
Input File: speed/adolc/det_minor.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_adolc_det_minor.cpp_xml.js cppad-2019.02.00.0/doc/_adolc_det_minor.cpp_xml.js --- cppad-2018.00.00.0/doc/_adolc_det_minor.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_adolc_det_minor.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_adolc.xml', -'adolc_det_minor.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'adolc_det_minor.cpp.xml', -'adolc_det_lu.cpp.xml', -'adolc_mat_mul.cpp.xml', -'adolc_ode.cpp.xml', -'adolc_poly.cpp.xml', -'adolc_sparse_hessian.cpp.xml', -'adolc_sparse_jacobian.cpp.xml', -'adolc_alloc_mat.xml' -]; -var list_current0 = [ -'adolc_det_minor.cpp.xml#Specifications', -'adolc_det_minor.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/adolc_mat_mul.cpp.xml cppad-2019.02.00.0/doc/adolc_mat_mul.cpp.xml --- cppad-2018.00.00.0/doc/adolc_mat_mul.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/adolc_mat_mul.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,238 +0,0 @@ - - - -Adolc Speed: Matrix Multiplication - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -adolc_mat_mul.cpp - -

-
Adolc Speed: Matrix Multiplication
-
-Specifications -
-See link_mat_mul -. - -
-
-Implementation - - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <adolc/adolc.h>
-# include <cppad/utility/vector.hpp>
-# include <cppad/speed/mat_sum_sq.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/utility/vector.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_mat_mul(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     CppAD::vector<double>&           x        ,
-     CppAD::vector<double>&           z        ,
-     CppAD::vector<double>&           dz       )
-{
-     // speed test global option values
-     if( global_option["memory"] || global_option["atomic"] || global_option["optimize"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-     typedef adouble    ADScalar;
-     typedef ADScalar*  ADVector;
-
-     int tag  = 0;         // tape identifier
-     int m    = 1;         // number of dependent variables
-     int n    = size*size; // number of independent variables
-     double f;             // function value
-     int j;                // temporary index
-
-     // set up for thread_alloc memory allocator (fast and checks for leaks)
-     using CppAD::thread_alloc; // the allocator
-     size_t capacity;           // capacity of an allocation
-
-     // AD domain space vector
-     ADVector X = thread_alloc::create_array<ADScalar>(size_t(n), capacity);
-
-     // Product matrix
-     ADVector Y = thread_alloc::create_array<ADScalar>(size_t(n), capacity);
-
-     // AD range space vector
-     ADVector Z = thread_alloc::create_array<ADScalar>(size_t(m), capacity);
-
-     // vector with matrix value
-     double* mat = thread_alloc::create_array<double>(size_t(n), capacity);
-
-     // vector of reverse mode weights
-     double* u  = thread_alloc::create_array<double>(size_t(m), capacity);
-     u[0] = 1.;
-
-     // gradient
-     double* grad = thread_alloc::create_array<double>(size_t(n), capacity);
-
-     // ----------------------------------------------------------------------
-     if( ! global_option["onetape"] ) while(repeat--)
-     {     // choose a matrix
-          CppAD::uniform_01(n, mat);
-
-          // declare independent variables
-          int keep = 1; // keep forward mode results
-          trace_on(tag, keep);
-          for(j = 0; j < n; j++)
-               X[j] <<= mat[j];
-
-          // do computations
-          CppAD::mat_sum_sq(size, X, Y, Z);
-
-          // create function object f : X -> Z
-          Z[0] >>= f;
-          trace_off();
-
-          // evaluate and return gradient using reverse mode
-          fos_reverse(tag, m, n, u, grad);
-     }
-     else
-     {     // choose a matrix
-          CppAD::uniform_01(n, mat);
-
-          // declare independent variables
-          int keep = 0; // do not keep forward mode results
-          trace_on(tag, keep);
-          for(j = 0; j < n; j++)
-               X[j] <<= mat[j];
-
-          // do computations
-          CppAD::mat_sum_sq(size, X, Y, Z);
-
-          // create function object f : X -> Z
-          Z[0] >>= f;
-          trace_off();
-
-          while(repeat--)
-          {     // choose a matrix
-               CppAD::uniform_01(n, mat);
-
-               // evaluate the determinant at the new matrix value
-               keep = 1; // keep this forward mode result
-               zos_forward(tag, m, n, keep, mat, &f);
-
-               // evaluate and return gradient using reverse mode
-               fos_reverse(tag, m, n, u, grad);
-          }
-     }
-     // return function, matrix, and gradient
-     z[0] = f;
-     for(j = 0; j < n; j++)
-     {     x[j]  = mat[j];
-          dz[j] = grad[j];
-     }
-
-     // tear down
-     thread_alloc::delete_array(X);
-     thread_alloc::delete_array(Y);
-     thread_alloc::delete_array(Z);
-     thread_alloc::delete_array(mat);
-     thread_alloc::delete_array(u);
-     thread_alloc::delete_array(grad);
-
-     return true;
-}
-
-
- -
Input File: speed/adolc/mat_mul.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_adolc_mat_mul.cpp_xml.js cppad-2019.02.00.0/doc/_adolc_mat_mul.cpp_xml.js --- cppad-2018.00.00.0/doc/_adolc_mat_mul.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_adolc_mat_mul.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_adolc.xml', -'adolc_mat_mul.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'adolc_det_minor.cpp.xml', -'adolc_det_lu.cpp.xml', -'adolc_mat_mul.cpp.xml', -'adolc_ode.cpp.xml', -'adolc_poly.cpp.xml', -'adolc_sparse_hessian.cpp.xml', -'adolc_sparse_jacobian.cpp.xml', -'adolc_alloc_mat.xml' -]; -var list_current0 = [ -'adolc_mat_mul.cpp.xml#Specifications', -'adolc_mat_mul.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/adolc_ode.cpp.xml cppad-2019.02.00.0/doc/adolc_ode.cpp.xml --- cppad-2018.00.00.0/doc/adolc_ode.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/adolc_ode.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,232 +0,0 @@ - - - -Adolc Speed: Ode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -adolc_ode.cpp - -

-
Adolc Speed: Ode
-
-Specifications -
-See link_ode -. - -
-
-Implementation - - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <adolc/adolc.h>
-
-# include <cppad/utility/vector.hpp>
-# include <cppad/speed/ode_evaluate.hpp>
-# include <cppad/speed/uniform_01.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_ode(
-     size_t                     size       ,
-     size_t                     repeat     ,
-     CppAD::vector<double>      &x         ,
-     CppAD::vector<double>      &jac
-)
-{
-     // speed test global option values
-     if( global_option["atomic"] )
-          return false;
-     if( global_option["memory"] || global_option["optimize"] )
-          return false;
-     // -------------------------------------------------------------
-     // setup
-     assert( x.size() == size );
-     assert( jac.size() == size * size );
-
-     typedef CppAD::vector<adouble> ADVector;
-     typedef CppAD::vector<double>  DblVector;
-
-     size_t i, j;
-     int tag    = 0;       // tape identifier
-     int keep   = 0;       // do not keep forward mode results
-     size_t p   = 0;       // use ode to calculate function values
-     size_t n   = size;    // number of independent variables
-     size_t m   = n;       // number of dependent variables
-     ADVector  X(n), Y(m); // independent and dependent variables
-     DblVector f(m);       // function value
-
-     // set up for thread_alloc memory allocator (fast and checks for leaks)
-     using CppAD::thread_alloc; // the allocator
-     size_t size_min;           // requested number of elements
-     size_t size_out;           // capacity of an allocation
-
-     // raw memory for use with adolc
-     size_min = n;
-     double *x_raw   = thread_alloc::create_array<double>(size_min, size_out);
-     size_min = m * n;
-     double *jac_raw = thread_alloc::create_array<double>(size_min, size_out);
-     size_min = m;
-     double **jac_ptr = thread_alloc::create_array<double*>(size_min, size_out);
-     for(i = 0; i < m; i++)
-          jac_ptr[i] = jac_raw + i * n;
-
-     // -------------------------------------------------------------
-     if( ! global_option["onetape"] ) while(repeat--)
-     {     // choose next x value
-          uniform_01(n, x);
-
-          // declare independent variables
-          trace_on(tag, keep);
-          for(j = 0; j < n; j++)
-               X[j] <<= x[j];
-
-          // evaluate function
-          CppAD::ode_evaluate(X, p, Y);
-
-          // create function object f : X -> Y
-          for(i = 0; i < m; i++)
-               Y[i] >>= f[i];
-          trace_off();
-
-          // evaluate the Jacobian
-          for(j = 0; j < n; j++)
-               x_raw[j] = x[j];
-          jacobian(tag, m, n, x_raw, jac_ptr);
-     }
-     else
-     {     // choose next x value
-          uniform_01(n, x);
-
-          // declare independent variables
-          trace_on(tag, keep);
-          for(j = 0; j < n; j++)
-               X[j] <<= x[j];
-
-          // evaluate function
-          CppAD::ode_evaluate(X, p, Y);
-
-          // create function object f : X -> Y
-          for(i = 0; i < m; i++)
-               Y[i] >>= f[i];
-          trace_off();
-
-          while(repeat--)
-          {     // get next argument value
-               uniform_01(n, x);
-               for(j = 0; j < n; j++)
-                    x_raw[j] = x[j];
-
-               // evaluate jacobian
-               jacobian(tag, m, n, x_raw, jac_ptr);
-          }
-     }
-     // convert return value to a simple vector
-     for(i = 0; i < m; i++)
-     {     for(j = 0; j < n; j++)
-               jac[i * n + j] = jac_ptr[i][j];
-     }
-     // ----------------------------------------------------------------------
-     // tear down
-     thread_alloc::delete_array(x_raw);
-     thread_alloc::delete_array(jac_raw);
-     thread_alloc::delete_array(jac_ptr);
-
-     return true;
-}
- -
Input File: speed/adolc/ode.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_adolc_ode.cpp_xml.js cppad-2019.02.00.0/doc/_adolc_ode.cpp_xml.js --- cppad-2018.00.00.0/doc/_adolc_ode.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_adolc_ode.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_adolc.xml', -'adolc_ode.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'adolc_det_minor.cpp.xml', -'adolc_det_lu.cpp.xml', -'adolc_mat_mul.cpp.xml', -'adolc_ode.cpp.xml', -'adolc_poly.cpp.xml', -'adolc_sparse_hessian.cpp.xml', -'adolc_sparse_jacobian.cpp.xml', -'adolc_alloc_mat.xml' -]; -var list_current0 = [ -'adolc_ode.cpp.xml#Specifications', -'adolc_ode.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/adolc_poly.cpp.xml cppad-2019.02.00.0/doc/adolc_poly.cpp.xml --- cppad-2018.00.00.0/doc/adolc_poly.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/adolc_poly.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,236 +0,0 @@ - - - -Adolc Speed: Second Derivative of a Polynomial - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -adolc_poly.cpp - -

-
Adolc Speed: Second Derivative of a Polynomial
-
-Specifications -
-See link_poly -. - -
-
-Implementation - - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <vector>
-# include <adolc/adolc.h>
-
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/utility/poly.hpp>
-# include <cppad/utility/vector.hpp>
-# include <cppad/utility/thread_alloc.hpp>
-# include "adolc_alloc_mat.hpp"
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_poly(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &a        ,  // coefficients of polynomial
-     CppAD::vector<double>     &z        ,  // polynomial argument value
-     CppAD::vector<double>     &ddp      )  // second derivative w.r.t z
-{
-     if( global_option["atomic"] )
-          return false;
-     if( global_option["memory"] || global_option["optimize"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-     size_t i;
-     int tag  = 0;  // tape identifier
-     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
-     double f;      // function value
-
-     // set up for thread_alloc memory allocator (fast and checks for leaks)
-     using CppAD::thread_alloc; // the allocator
-     size_t capacity;           // capacity of an allocation
-
-     // choose a vector of polynomial coefficients
-     CppAD::uniform_01(size, a);
-
-     // AD copy of the polynomial coefficients
-     std::vector<adouble> A(size);
-     for(i = 0; i < size; i++)
-          A[i] = a[i];
-
-     // domain and range space AD values
-     adouble Z, P;
-
-     // allocate arguments to hos_forward
-     double* x0 = thread_alloc::create_array<double>(size_t(n), capacity);
-     double* y0 = thread_alloc::create_array<double>(size_t(m), capacity);
-     double** x = adolc_alloc_mat(size_t(n), size_t(d));
-     double** y = adolc_alloc_mat(size_t(m), size_t(d));
-
-     // Taylor coefficient for argument
-     x[0][0] = 1.;  // first order
-     x[0][1] = 0.;  // second order
-
-     // ----------------------------------------------------------------------
-     if( ! global_option["onetape"] ) while(repeat--)
-     {     // choose an argument value
-          CppAD::uniform_01(1, z);
-
-          // declare independent variables
-          trace_on(tag, keep);
-          Z <<= z[0];
-
-          // AD computation of the function value
-          P = CppAD::Poly(0, A, Z);
-
-          // create function object f : Z -> P
-          P >>= f;
-          trace_off();
-
-          // set the argument value
-          x0[0] = z[0];
-
-          // evaluate the polynomial at the new argument value
-          hos_forward(tag, m, n, d, keep, x0, x, y0, y);
-
-          // second derivative is twice second order Taylor coef
-          ddp[0] = 2. * y[0][1];
-     }
-     else
-     {
-          // choose an argument value
-          CppAD::uniform_01(1, z);
-
-          // declare independent variables
-          trace_on(tag, keep);
-          Z <<= z[0];
-
-          // AD computation of the function value
-          P = CppAD::Poly(0, A, Z);
-
-          // create function object f : Z -> P
-          P >>= f;
-          trace_off();
-
-          while(repeat--)
-          {     // get the next argument value
-               CppAD::uniform_01(1, z);
-               x0[0] = z[0];
-
-               // evaluate the polynomial at the new argument value
-               hos_forward(tag, m, n, d, keep, x0, x, y0, y);
-
-               // second derivative is twice second order Taylor coef
-               ddp[0] = 2. * y[0][1];
-          }
-     }
-     // ------------------------------------------------------
-     // tear down
-     adolc_free_mat(x);
-     adolc_free_mat(y);
-     thread_alloc::delete_array(x0);
-     thread_alloc::delete_array(y0);
-
-     return true;
-}
- -
Input File: speed/adolc/poly.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_adolc_poly.cpp_xml.js cppad-2019.02.00.0/doc/_adolc_poly.cpp_xml.js --- cppad-2018.00.00.0/doc/_adolc_poly.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_adolc_poly.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_adolc.xml', -'adolc_poly.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'adolc_det_minor.cpp.xml', -'adolc_det_lu.cpp.xml', -'adolc_mat_mul.cpp.xml', -'adolc_ode.cpp.xml', -'adolc_poly.cpp.xml', -'adolc_sparse_hessian.cpp.xml', -'adolc_sparse_jacobian.cpp.xml', -'adolc_alloc_mat.xml' -]; -var list_current0 = [ -'adolc_poly.cpp.xml#Specifications', -'adolc_poly.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/adolc_prefix.xml cppad-2019.02.00.0/doc/adolc_prefix.xml --- cppad-2018.00.00.0/doc/adolc_prefix.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/adolc_prefix.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,271 +0,0 @@ - - - -Including the ADOL-C Examples and Tests - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - -
Including the ADOL-C Examples and Tests
-
-Purpose -
-CppAD includes examples and tests that can use the AD package -ADOL-C -. -The includes speed comparison with other AD packages; see -speed_adolc -. -It also includes examples that combine ADOL-C with -CppAD; see - - - - -
- -base_adolc.hpp -Enable use of AD<Base> where Base is Adolc's adouble Type
- -mul_level_adolc.cpp -Using Adolc with Multiple Levels of Taping: Example and Test
- -mul_level_adolc_ode.cpp -Taylor's Ode Solver: A Multi-Level Adolc Example and Test
- -
-
-adolc_prefix -
-If ADOL-C is installed on your system, you can -specify a value for its install -adolc_prefix - on the -cmake - command line. -The value of -adolc_prefix - must be such that, -for one of the directories -dir - in -cmake_install_includedirs -, - -
-     
adolc_prefix/dir/adolc/adouble.h
-
-is a valid way to reference to the include file adouble.h; -Note that CppAD assumes ADOL-C has been configured with -its sparse matrix computations enabled; i.e, using - -
-     --with-colpack=
adolc_prefix
-
-In other words ColPack is installed and -with the same prefix as ACOL-C; see -get_colpack.sh -. - -
-
-Examples -
-If you include -adolc_prefix - on the cmake - command line, -you will be able to run the ADOL-C examples listed above -by executing the following commands starting in the -distribution directory -: - -
-     cd build/example
-     make check_example
-
-If you do this, -you will see an indication that the examples -mul_level_adolc and mul_level_adolc_ode -have passed their correctness check. - -
-
-Speed Tests -
-If you include -adolc_prefix - on the cmake - command line, -you will be able to run the ADOL-C speed correctness tests -by executing the following commands starting in the -distribution directory -: - -
-     cd build/speed/adolc
-     make check_speed_adolc
-
-After executing make check_speed_adolc, -you can run a specific ADOL-C speed tests -by executing the command ./speed_adolc; -see speed_main - for the meaning of the command line -options to this program. - -
-
-Unix -
-If you are using Unix, -you may have to add - -adolc_prefix - to LD_LIBRARY_PATH. -For example, if you use the bash shell to run your programs, -you could include - -
-     LD_LIBRARY_PATH=
adolc_prefix/lib:${LD_LIBRARY_PATH}
-     export LD_LIBRARY_PATH
-
-in your $HOME/.bashrc file. - -
-
-Cygwin -
-If you are using Cygwin, -you may have to add to following lines to the file -.bashrc in your home directory: - -
-     PATH=
adolc_prefix/bin:${PATH}
-     export PATH
-
-in order for ADOL-C to run properly. -If -adolc_prefix - 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_prefix -. - - -
-
-get_adolc -
-If you are using Unix, you can download and install -a copy of Adolc using get_adolc.sh -. -The corresponding -adolc_prefix - would be -build/prefix. - - -
Input File: omh/install/adolc_prefix.omh - - - diff -Nru cppad-2018.00.00.0/doc/_adolc_prefix_xml.js cppad-2019.02.00.0/doc/_adolc_prefix_xml.js --- cppad-2018.00.00.0/doc/_adolc_prefix_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_adolc_prefix_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', -'install.xml', -'cmake.xml', -'adolc_prefix.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 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.xml' -]; -var list_down1 = [ -'adolc_prefix.xml', -'colpack_prefix.xml', -'eigen_prefix.xml', -'fadbad_prefix.xml', -'ipopt_prefix.xml', -'sacado_prefix.xml', -'cppad_testvector.xml' -]; -var list_down0 = [ -'get_adolc.sh.xml' -]; -var list_current0 = [ -'adolc_prefix.xml#Purpose', -'adolc_prefix.xml#adolc_prefix', -'adolc_prefix.xml#Examples', -'adolc_prefix.xml#Speed Tests', -'adolc_prefix.xml#Unix', -'adolc_prefix.xml#Cygwin', -'adolc_prefix.xml#get_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_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-2018.00.00.0/doc/adolc_sparse_hessian.cpp.xml cppad-2019.02.00.0/doc/adolc_sparse_hessian.cpp.xml --- cppad-2018.00.00.0/doc/adolc_sparse_hessian.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/adolc_sparse_hessian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,283 +0,0 @@ - - - -Adolc Speed: Sparse Hessian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -adolc_sparse_hessian.cpp - -

-
Adolc Speed: Sparse Hessian
-
-Specifications -
-See link_sparse_hessian -. - -
-
-Implementation - - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <adolc/adolc.h>
-# include <adolc/adolc_sparse.h>
-# include <cppad/utility/vector.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/utility/thread_alloc.hpp>
-# include <cppad/speed/sparse_hes_fun.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_sparse_hessian(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     const CppAD::vector<size_t>&     row      ,
-     const CppAD::vector<size_t>&     col      ,
-     CppAD::vector<double>&           x_return ,
-     CppAD::vector<double>&           hessian  ,
-     size_t&                          n_sweep )
-{
-     if( global_option["atomic"] || (! global_option["colpack"]) )
-          return false;
-     if( global_option["memory"] || global_option["optimize"] || global_option["boolsparsity"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-     typedef unsigned int*    SizeVector;
-     typedef double*          DblVector;
-     typedef adouble          ADScalar;
-     typedef ADScalar*        ADVector;
-
-
-     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
-
-     // setup for thread_alloc memory allocator (fast and checks for leaks)
-     using CppAD::thread_alloc; // the allocator
-     size_t capacity;           // capacity of an allocation
-
-     // tape identifier
-     int tag  = 0;
-     // AD domain space vector
-     ADVector a_x = thread_alloc::create_array<ADScalar>(n, capacity);
-     // AD range space vector
-     ADVector a_y = thread_alloc::create_array<ADScalar>(m, capacity);
-     // double argument value
-     DblVector x = thread_alloc::create_array<double>(n, capacity);
-     // double function value
-     double f;
-
-     // options that control sparse_hess
-     int        options[2];
-     options[0] = 0; // safe mode
-     options[1] = 0; // indirect recovery
-
-     // structure that holds some of the work done by sparse_hess
-     int        nnz;                   // number of non-zero values
-     SizeVector rind   = CPPAD_NULL;   // row indices
-     SizeVector cind   = CPPAD_NULL;   // column indices
-     DblVector  values = CPPAD_NULL;   // Hessian values
-
-     // ----------------------------------------------------------------------
-     if( ! global_option["onetape"] ) while(repeat--)
-     {     // choose a value for x
-          CppAD::uniform_01(n, x);
-
-          // declare independent variables
-          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)
-          CppAD::sparse_hes_fun<ADScalar>(n, a_x, row, col, order, a_y);
-
-          // create function object f : x -> y
-          a_y[0] >>= f;
-          trace_off();
-
-          // is this a repeat call with the same sparsity pattern
-          int same_pattern = 0;
-
-          // calculate the hessian at this x
-          rind   = CPPAD_NULL;
-          cind   = CPPAD_NULL;
-          values = CPPAD_NULL;
-          sparse_hess(tag, int(n),
-               same_pattern, x, &nnz, &rind, &cind, &values, options
-          );
-          // 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
-          free(rind);
-          free(cind);
-          free(values);
-     }
-     else
-     {     // choose a value for x
-          CppAD::uniform_01(n, x);
-
-          // declare independent variables
-          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)
-          CppAD::sparse_hes_fun<ADScalar>(n, a_x, row, col, order, a_y);
-
-          // create function object f : x -> y
-          a_y[0] >>= f;
-          trace_off();
-
-          // is this a repeat call at the same argument
-          int same_pattern = 0;
-
-          while(repeat--)
-          {     // choose a value for x
-               CppAD::uniform_01(n, x);
-
-               // calculate the hessian at this x
-               sparse_hess(tag, int(n),
-                    same_pattern, x, &nnz, &rind, &cind, &values, options
-               );
-               same_pattern = 1;
-          }
-          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
-     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);
-     thread_alloc::delete_array(x);
-     return true;
-
-}
- -
Input File: speed/adolc/sparse_hessian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_adolc_sparse_hessian.cpp_xml.js cppad-2019.02.00.0/doc/_adolc_sparse_hessian.cpp_xml.js --- cppad-2018.00.00.0/doc/_adolc_sparse_hessian.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_adolc_sparse_hessian.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_adolc.xml', -'adolc_sparse_hessian.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'adolc_det_minor.cpp.xml', -'adolc_det_lu.cpp.xml', -'adolc_mat_mul.cpp.xml', -'adolc_ode.cpp.xml', -'adolc_poly.cpp.xml', -'adolc_sparse_hessian.cpp.xml', -'adolc_sparse_jacobian.cpp.xml', -'adolc_alloc_mat.xml' -]; -var list_current0 = [ -'adolc_sparse_hessian.cpp.xml#Specifications', -'adolc_sparse_hessian.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/adolc_sparse_jacobian.cpp.xml cppad-2019.02.00.0/doc/adolc_sparse_jacobian.cpp.xml --- cppad-2018.00.00.0/doc/adolc_sparse_jacobian.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/adolc_sparse_jacobian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,290 +0,0 @@ - - - -adolc Speed: Sparse Jacobian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -adolc_sparse_jacobian.cpp - -

-
adolc Speed: Sparse Jacobian
-
-Specifications -
-See link_sparse_jacobian -. - -
-
-Implementation - - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <adolc/adolc.h>
-# include <adolc/adolc_sparse.h>
-# include <cppad/utility/vector.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/speed/sparse_jac_fun.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_sparse_jacobian(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     size_t                           m        ,
-     const CppAD::vector<size_t>&     row      ,
-     const CppAD::vector<size_t>&     col      ,
-           CppAD::vector<double>&     x_return ,
-           CppAD::vector<double>&     jacobian ,
-           size_t&                    n_sweep  )
-{
-     if( global_option["atomic"] || (! global_option["colpack"]) )
-          return false;
-     if( global_option["memory"] || global_option["optimize"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-     typedef unsigned int*    SizeVector;
-     typedef double*          DblVector;
-     typedef adouble          ADScalar;
-     typedef ADScalar*        ADVector;
-
-     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)
-     using CppAD::thread_alloc; // the allocator
-     size_t capacity;           // capacity of an allocation
-
-     // tape identifier
-     int tag  = 0;
-     // AD domain space vector
-     ADVector a_x = thread_alloc::create_array<ADScalar>(n, capacity);
-     // AD range space vector
-     ADVector a_y = thread_alloc::create_array<ADScalar>(m, capacity);
-     // argument value in double
-     DblVector x = thread_alloc::create_array<double>(n, capacity);
-     // function value in double
-     DblVector y = thread_alloc::create_array<double>(m, capacity);
-
-
-     // options that control sparse_jac
-     int        options[4];
-     if( global_option["boolsparsity"] )
-          options[0] = 1;  // sparsity by propagation of bit pattern
-     else
-          options[0] = 0;  // sparsity pattern by index domains
-     options[1] = 0; // (0 = safe mode, 1 = tight mode)
-     options[2] = 0; // see changing to -1 and back to 0 below
-     options[3] = 0; // (0 = column compression, 1 = row compression)
-
-     // structure that holds some of the work done by sparse_jac
-     int        nnz;                   // number of non-zero values
-     SizeVector rind   = CPPAD_NULL;   // row indices
-     SizeVector cind   = CPPAD_NULL;   // column indices
-     DblVector  values = CPPAD_NULL;   // Jacobian values
-
-     // choose a value for x
-     CppAD::uniform_01(n, x);
-
-     // declare independent variables
-     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)
-     CppAD::sparse_jac_fun<ADScalar>(m, n, a_x, row, col, order, a_y);
-
-     // create function object f : x -> y
-     for(i = 0; i < m; i++)
-          a_y[i] >>= y[i];
-     trace_off();
-
-     // 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),
-          same_pattern, x, &nnz, &rind, &cind, &values, options
-     );
-     options[2]       = 0;
-     // ----------------------------------------------------------------------
-     if( ! global_option["onetape"] ) while(repeat--)
-     {     // choose a value for x
-          CppAD::uniform_01(n, x);
-
-          // declare independent variables
-          trace_on(tag, keep);
-          for(j = 0; j < n; j++)
-               a_x[j] <<= x[j];
-
-          // AD computation of f (x)
-          CppAD::sparse_jac_fun<ADScalar>(m, n, a_x, row, col, order, a_y);
-
-          // create function object f : x -> y
-          for(i = 0; i < m; i++)
-               a_y[i] >>= y[i];
-          trace_off();
-
-          // is this a repeat call with the same sparsity pattern
-          same_pattern = 0;
-
-          // calculate the jacobian at this x
-          rind   = CPPAD_NULL;
-          cind   = CPPAD_NULL;
-          values = CPPAD_NULL;
-          sparse_jac(tag, int(m), int(n),
-               same_pattern, x, &nnz, &rind, &cind, &values, options
-          );
-          // 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);
-          free(cind);
-          free(values);
-     }
-     else
-     {     while(repeat--)
-          {     // choose a value for x
-               CppAD::uniform_01(n, x);
-
-               // calculate the jacobian at this x
-               sparse_jac(tag, int(m), int(n),
-                    same_pattern, x, &nnz, &rind, &cind, &values, options
-               );
-               same_pattern = 1;
-          }
-          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);
-          free(cind);
-          free(values);
-     }
-     // --------------------------------------------------------------------
-     // return argument
-     for(j = 0; j < n; j++)
-          x_return[j] = x[j];
-
-     // tear down
-     thread_alloc::delete_array(a_x);
-     thread_alloc::delete_array(a_y);
-     thread_alloc::delete_array(x);
-     thread_alloc::delete_array(y);
-     return true;
-}
- -
Input File: speed/adolc/sparse_jacobian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_adolc_sparse_jacobian.cpp_xml.js cppad-2019.02.00.0/doc/_adolc_sparse_jacobian.cpp_xml.js --- cppad-2018.00.00.0/doc/_adolc_sparse_jacobian.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_adolc_sparse_jacobian.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_adolc.xml', -'adolc_sparse_jacobian.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'adolc_det_minor.cpp.xml', -'adolc_det_lu.cpp.xml', -'adolc_mat_mul.cpp.xml', -'adolc_ode.cpp.xml', -'adolc_poly.cpp.xml', -'adolc_sparse_hessian.cpp.xml', -'adolc_sparse_jacobian.cpp.xml', -'adolc_alloc_mat.xml' -]; -var list_current0 = [ -'adolc_sparse_jacobian.cpp.xml#Specifications', -'adolc_sparse_jacobian.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/ad_output.cpp.xml cppad-2019.02.00.0/doc/ad_output.cpp.xml --- cppad-2018.00.00.0/doc/ad_output.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad_output.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,130 +0,0 @@ - - - -AD Output Operator: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ad_output.cppHeadings

-
AD Output Operator: Example and Test
-

-# include <cppad/cppad.hpp>
-
-# include <sstream>  // std::ostringstream
-# include <string>   // std::string
-# include <iomanip>  // std::setprecision, setw, setfill, right
-
-namespace {
-     template <class S>
-     void set_ostream(S &os)
-     {     os
-          << std::setprecision(4) // 4 digits of precision
-          << std::setw(6)         // 6 characters per field
-          << std::setfill(' ')    // fill with spaces
-          << std::right;          // adjust value to the right
-     }
-}
-
-bool ad_output(void)
-{     bool ok = true;
-
-     // This output stream is an ostringstream for testing purposes.
-     // You can use << with other types of streams; i.e., std::cout.
-     std::ostringstream stream;
-
-     // ouput an AD<double> object
-     CppAD::AD<double>  pi = 4. * atan(1.); // 3.1415926536
-     set_ostream(stream);
-     stream << pi;
-
-     // ouput a VecAD<double>::reference object
-     CppAD::VecAD<double> v(1);
-     CppAD::AD<double> zero(0);
-     v[zero]   = exp(1.);                  // 2.7182818285
-     set_ostream(stream);
-     stream << v[zero];
-
-     // convert output from stream to string
-     std::string str = stream.str();
-
-     // check the output
-     ok      &= (str == " 3.142 2.718");
-
-     return ok;
-}
-
-
Input File: example/general/ad_output.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_output.cpp_xml.js cppad-2019.02.00.0/doc/_ad_output.cpp_xml.js --- cppad-2018.00.00.0/doc/_ad_output.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_output.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -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_output.xml', -'ad_output.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 = [ -'value.xml', -'integer.xml', -'ad_to_string.xml', -'ad_input.xml', -'ad_output.xml', -'printfor.xml', -'var2par.xml' -]; -var list_down1 = [ -'ad_output.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-2018.00.00.0/doc/ad_output.xml cppad-2019.02.00.0/doc/ad_output.xml --- cppad-2018.00.00.0/doc/ad_output.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad_output.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,226 +0,0 @@ - - - -AD Output Stream Operator - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - -
AD Output Stream Operator
-
-Syntax - -
- -os << x - - - -
-
-Purpose -
-Writes the -Base - value, corresponding to -x -, -to the output stream -os -. - -
-
-Assumption -
-If -b - is a -Base - object, - -
-     
os << b
-
-returns a reference to -os -. - -
-
-os -
-The operand -os - has prototype - -
-     std::ostream& 
os
-
-
-x -
-The operand -x - has one of the following prototypes - -
-     const AD<
Base>&               x
-     const VecAD<
Base>::reference& x
-
-
-Result -
-The result of this operation can be used as a reference to -os -. -For example, if the operand -y - has prototype - -
-     AD<
Basey
-
-then the syntax - -
-     
os << x << y
-
-will output the value corresponding to -x - -followed by the value corresponding to -y -. - -
-
-Operation Sequence -
-The result of this operation is not an -AD of Base - object. -Thus it will not be recorded as part of an -AD of -Base - -operation sequence -. - -
-
-Example - -
-The file -ad_output.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/ad_io.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_output_xml.js cppad-2019.02.00.0/doc/_ad_output_xml.js --- cppad-2018.00.00.0/doc/_ad_output_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_output_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -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_output.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_down0 = [ -'ad_output.cpp.xml' -]; -var list_current0 = [ -'ad_output.xml#Syntax', -'ad_output.xml#Purpose', -'ad_output.xml#Assumption', -'ad_output.xml#os', -'ad_output.xml#x', -'ad_output.xml#Result', -'ad_output.xml#Operation Sequence', -'ad_output.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-2018.00.00.0/doc/ad_to_string.xml cppad-2019.02.00.0/doc/ad_to_string.xml --- cppad-2018.00.00.0/doc/ad_to_string.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad_to_string.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,166 +0,0 @@ - - - -Convert An AD or Base Type to String - - - - - - - - - - - - - - - - -
- -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/core/ad_to_string.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_to_string_xml.js cppad-2019.02.00.0/doc/_ad_to_string_xml.js --- cppad-2018.00.00.0/doc/_ad_to_string_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_to_string_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', -'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-2018.00.00.0/doc/advalued.xml cppad-2019.02.00.0/doc/advalued.xml --- cppad-2018.00.00.0/doc/advalued.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/advalued.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ - - - -AD Valued Operations and Functions - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
AD Valued Operations and Functions
-
-Contents -
- -
ArithmeticAD Arithmetic Operators and Compound Assignments
unary_standard_mathThe Unary Standard Math Functions
binary_mathThe Binary Math Functions
CondExpAD Conditional Expressions
DiscreteDiscrete AD Functions
numeric_limitsNumeric Limits For an AD and Base Types
atomicAtomic AD Functions
-
Input File: cppad/core/ad_valued.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_advalued_xml.js cppad-2019.02.00.0/doc/_advalued_xml.js --- cppad-2018.00.00.0/doc/_advalued_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_advalued_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +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' -]; -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 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down0 = [ -'arithmetic.xml', -'unary_standard_math.xml', -'binary_math.xml', -'condexp.xml', -'discrete.xml', -'numeric_limits.xml', -'atomic.xml' -]; -var list_current0 = [ -'advalued.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-2018.00.00.0/doc/ad.xml cppad-2019.02.00.0/doc/ad.xml --- cppad-2018.00.00.0/doc/ad.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/ad.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ - - - -AD Objects - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -

-
AD Objects
-
-Purpose -
-The sections listed below describe the operations -that are available to AD of Base - objects. -These objects are used to tape - -an AD of -Base - -operation sequence -. -This operation sequence can -be transferred to an ADFun - object where it -can be used to evaluate the corresponding -function and derivative values. - -
-
-Base Type Requirements -
-The -Base - requirements are provided by the CppAD package -for the following base types: -float, -double, -std::complex<float>, -std::complex<double>. -Otherwise, see base_require -. - - -
-
-Contents -
- -
ad_ctorAD Constructors
ad_assignAD Assignment Operator
ConvertConversion and I/O of AD Objects
ADValuedAD Valued Operations and Functions
BoolValuedBool Valued Operations and Functions with AD Arguments
VecADAD Vectors that Record Index Operations
base_requireAD<Base> Requirements for a CppAD Base Type
-
Input File: cppad/core/user_ad.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ad_xml.js cppad-2019.02.00.0/doc/_ad_xml.js --- cppad-2018.00.00.0/doc/_ad_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ad_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.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 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_current0 = [ -'ad.xml#Purpose', -'ad.xml#Base Type Requirements', -'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_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-2018.00.00.0/doc/appendix.xml cppad-2019.02.00.0/doc/appendix.xml --- cppad-2018.00.00.0/doc/appendix.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/appendix.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ - - - -Appendix - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -

-
Appendix
-
-Contents -
- -
FaqFrequently Asked Questions and Answers
directoryDirectory Structure
TheoryThe Theory of Derivative Calculations
glossaryGlossary
BibBibliography
wish_listThe CppAD Wish List
whats_newChanges and Additions to CppAD
deprecatedCppAD Deprecated API Features
compare_cCompare Speed of C and C++
numeric_adSome Numerical AD Utilities
addonCppAD Addons
LicenseYour License for the CppAD Software
-
Input File: omh/appendix.omh - - - diff -Nru cppad-2018.00.00.0/doc/_appendix_xml.js cppad-2019.02.00.0/doc/_appendix_xml.js --- cppad-2018.00.00.0/doc/_appendix_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_appendix_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.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 = [ -'faq.xml', -'directory.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 = [ -'appendix.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_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-2018.00.00.0/doc/arithmetic.xml cppad-2019.02.00.0/doc/arithmetic.xml --- cppad-2018.00.00.0/doc/arithmetic.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/arithmetic.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ - - - -AD Arithmetic Operators and Compound Assignments - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
AD Arithmetic Operators and Compound Assignments
-
-Contents -
- -
UnaryPlusAD Unary Plus Operator
UnaryMinusAD Unary Minus Operator
ad_binaryAD Binary Arithmetic Operators
compound_assignAD Compound Assignment Operators
-
Input File: cppad/core/arithmetic.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_arithmetic_xml.js cppad-2019.02.00.0/doc/_arithmetic_xml.js --- cppad-2018.00.00.0/doc/_arithmetic_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_arithmetic_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', -'ad.xml', -'advalued.xml', -'arithmetic.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_current0 = [ -'arithmetic.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-2018.00.00.0/doc/asin.cpp.xml cppad-2019.02.00.0/doc/asin.cpp.xml --- cppad-2018.00.00.0/doc/asin.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/asin.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,159 +0,0 @@ - - - -The AD asin Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -asin.cppHeadings

-
The AD asin Function: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool asin(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> sin_of_x0 = CppAD::sin(x[0]);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::asin(sin_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 asin
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero] = sin_of_x0;
-     AD<double> result = CppAD::asin(v[zero]);
-     ok     &= NearEqual(result, x0, eps, eps);
-
-     return ok;
-}
-
-
-
Input File: example/general/asin.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_asin.cpp_xml.js cppad-2019.02.00.0/doc/_asin.cpp_xml.js --- cppad-2018.00.00.0/doc/_asin.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_asin.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'asin.xml', -'asin.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 = [ -'asin.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-2018.00.00.0/doc/asin_forward.xml cppad-2019.02.00.0/doc/asin_forward.xml --- cppad-2018.00.00.0/doc/asin_forward.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/asin_forward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,814 +0,0 @@ - - - -Inverse Sine and Hyperbolic Sine Forward Mode Theory - - - - - - - - - - - - - - - - -
- -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/appendix/theory/asin_forward.omh - - - diff -Nru cppad-2018.00.00.0/doc/_asin_forward_xml.js cppad-2019.02.00.0/doc/_asin_forward_xml.js --- cppad-2018.00.00.0/doc/_asin_forward_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_asin_forward_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', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'asin_forward.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/asinh.cpp.xml cppad-2019.02.00.0/doc/asinh.cpp.xml --- cppad-2018.00.00.0/doc/asinh.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/asinh.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ - - - -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/general/asinh.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_asinh.cpp_xml.js cppad-2019.02.00.0/doc/_asinh.cpp_xml.js --- cppad-2018.00.00.0/doc/_asinh.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_asinh.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'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-2018.00.00.0/doc/asinh.xml cppad-2019.02.00.0/doc/asinh.xml --- cppad-2018.00.00.0/doc/asinh.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/asinh.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,202 +0,0 @@ - - - -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/core/asinh.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_asinh_xml.js cppad-2019.02.00.0/doc/_asinh_xml.js --- cppad-2018.00.00.0/doc/_asinh_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_asinh_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +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', -'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-2018.00.00.0/doc/asin_reverse.xml cppad-2019.02.00.0/doc/asin_reverse.xml --- cppad-2018.00.00.0/doc/asin_reverse.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/asin_reverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1625 +0,0 @@ - - - -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/appendix/theory/asin_reverse.omh - - - diff -Nru cppad-2018.00.00.0/doc/_asin_reverse_xml.js cppad-2019.02.00.0/doc/_asin_reverse_xml.js --- cppad-2018.00.00.0/doc/_asin_reverse_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_asin_reverse_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', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'asin_reverse.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/asin.xml cppad-2019.02.00.0/doc/asin.xml --- cppad-2018.00.00.0/doc/asin.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/asin.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,190 +0,0 @@ - - - -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_asin_xml.js cppad-2019.02.00.0/doc/_asin_xml.js --- cppad-2018.00.00.0/doc/_asin_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_asin_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'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-2018.00.00.0/doc/atan2.cpp.xml cppad-2019.02.00.0/doc/atan2.cpp.xml --- cppad-2018.00.00.0/doc/atan2.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atan2.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ - - - -The AD atan2 Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atan2.cppHeadings

- - - -
The AD atan2 Function: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool atan2(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * 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> sin_of_x0 = CppAD::sin(x[0]);
-     AD<double> cos_of_x0 = CppAD::cos(x[0]);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::atan2(sin_of_x0, cos_of_x0);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0] , x0, eps99, eps99);
-
-     // 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., eps99, eps99);
-
-     // 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., eps99, eps99);
-
-     // use a VecAD<Base>::reference object with atan2
-     CppAD::VecAD<double> v(2);
-     AD<double> zero(0);
-     AD<double> one(1);
-     v[zero]           = sin_of_x0;
-     v[one]            = cos_of_x0;
-     AD<double> result = CppAD::atan2(v[zero], v[one]);
-     ok               &= NearEqual(result, x0, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/atan2.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atan2.cpp_xml.js cppad-2019.02.00.0/doc/_atan2.cpp_xml.js --- cppad-2018.00.00.0/doc/_atan2.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atan2.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +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', -'binary_math.xml', -'atan2.xml', -'atan2.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 = [ -'atan2.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-2018.00.00.0/doc/atan2.xml cppad-2019.02.00.0/doc/atan2.xml --- cppad-2018.00.00.0/doc/atan2.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atan2.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,234 +0,0 @@ - - - -AD Two Argument Inverse Tangent Function - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
AD Two Argument Inverse Tangent Function
-
-Syntax - -
- -theta = atan2(yx) - - - -
-
-Purpose -
-Determines an angle - -θ - -[ -- -π -, -+ -π -] - - - -such that - - - -sin -( -θ -) - -= - -y -/ -x -2 - -+ -y -2 - - - - -cos -( -θ -) - -= - -x -/ -x -2 - -+ -y -2 - - - - - - -
-y -
-The argument -y - has one of the following prototypes - -
-     const AD<
Base>               &y
-     const VecAD<
Base>::reference &y
-
-
-x -
-The argument -x - has one of the following prototypes - -
-     const AD<
Base>               &x
-     const VecAD<
Base>::reference &x
-
-
-theta -
-The result -theta - has prototype - -
-     AD<
Basetheta
-
-
-Operation Sequence -
-The AD of -Base - -operation sequence used to calculate -theta - is -independent - -of -x - and -y -. - -
-
-Example - -
-The file -atan2.cpp - -contains an example and test of this function. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/atan2.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atan2_xml.js cppad-2019.02.00.0/doc/_atan2_xml.js --- cppad-2018.00.00.0/doc/_atan2_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atan2_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +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', -'binary_math.xml', -'atan2.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 = [ -'atan2.cpp.xml' -]; -var list_current0 = [ -'atan2.xml#Syntax', -'atan2.xml#Purpose', -'atan2.xml#y', -'atan2.xml#x', -'atan2.xml#theta', -'atan2.xml#Operation Sequence', -'atan2.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-2018.00.00.0/doc/atan.cpp.xml cppad-2019.02.00.0/doc/atan.cpp.xml --- cppad-2018.00.00.0/doc/atan.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atan.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ - - - -The AD atan Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atan.cppHeadings

-
The AD atan Function: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool atan(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * 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> tan_of_x0 = CppAD::tan(x[0]);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::atan(tan_of_x0);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0] , x0, eps99, eps99);
-
-     // 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., eps99, eps99);
-
-     // 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., eps99, eps99);
-
-     // use a VecAD<Base>::reference object with atan
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero] = tan_of_x0;
-     AD<double> result = CppAD::atan(v[zero]);
-     ok     &= NearEqual(result, x0, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/atan.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atan.cpp_xml.js cppad-2019.02.00.0/doc/_atan.cpp_xml.js --- cppad-2018.00.00.0/doc/_atan.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atan.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'atan.xml', -'atan.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 = [ -'atan.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-2018.00.00.0/doc/atan_forward.xml cppad-2019.02.00.0/doc/atan_forward.xml --- cppad-2018.00.00.0/doc/atan_forward.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/atan_forward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,646 +0,0 @@ - - - -Inverse Tangent and Hyperbolic Tangent Forward Mode Theory - - - - - - - - - - - - - - - - -
- -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/appendix/theory/atan_forward.omh - - - diff -Nru cppad-2018.00.00.0/doc/_atan_forward_xml.js cppad-2019.02.00.0/doc/_atan_forward_xml.js --- cppad-2018.00.00.0/doc/_atan_forward_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atan_forward_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', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'atan_forward.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/atanh.cpp.xml cppad-2019.02.00.0/doc/atanh.cpp.xml --- cppad-2018.00.00.0/doc/atanh.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atanh.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ - - - -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/general/atanh.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atanh.cpp_xml.js cppad-2019.02.00.0/doc/_atanh.cpp_xml.js --- cppad-2018.00.00.0/doc/_atanh.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atanh.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'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-2018.00.00.0/doc/atanh.xml cppad-2019.02.00.0/doc/atanh.xml --- cppad-2018.00.00.0/doc/atanh.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atanh.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,207 +0,0 @@ - - - -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/core/atanh.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atanh_xml.js cppad-2019.02.00.0/doc/_atanh_xml.js --- cppad-2018.00.00.0/doc/_atanh_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atanh_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +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', -'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-2018.00.00.0/doc/atan_reverse.xml cppad-2019.02.00.0/doc/atan_reverse.xml --- cppad-2018.00.00.0/doc/atan_reverse.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/atan_reverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1373 +0,0 @@ - - - -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/appendix/theory/atan_reverse.omh - - - diff -Nru cppad-2018.00.00.0/doc/_atan_reverse_xml.js cppad-2019.02.00.0/doc/_atan_reverse_xml.js --- cppad-2018.00.00.0/doc/_atan_reverse_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atan_reverse_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', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'atan_reverse.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/atan.xml cppad-2019.02.00.0/doc/atan.xml --- cppad-2018.00.00.0/doc/atan.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atan.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,187 +0,0 @@ - - - -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atan_xml.js cppad-2019.02.00.0/doc/_atan_xml.js --- cppad-2018.00.00.0/doc/_atan_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atan_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'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-2018.00.00.0/doc/atomic_afun.xml cppad-2019.02.00.0/doc/atomic_afun.xml --- cppad-2018.00.00.0/doc/atomic_afun.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_afun.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,250 +0,0 @@ - - - -Using AD Version of Atomic Function - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_afun - -

- - - - -
Using AD Version of Atomic Function
-
-Syntax - -
- -afun(axay) - - -
-
-Purpose -
-Given -ax -, -this call computes the corresponding value of -ay -. -If -AD<Base> - operations are being recorded, -it enters the computation as an atomic operation in the recording; -see start recording -. - -
-
-ADVector -
-The type -ADVector - must be a -simple vector class - with elements of type - -AD<Base> -; see Base -. - -
-
-afun -
-is a atomic_user - object -and this -afun - function call is implemented by the -atomic_base - class. - -
-
-ax -
-This argument has prototype - -
-     const 
ADVectorax
-
-and size must be equal to -n -. -It specifies vector - -x - -B -n - - - - -at which an -AD<Base> - version of - - -y -= -f -( -x -) - - - is to be evaluated; see -Base -. - -
-
-ay -
-This argument has prototype - -
-     
ADVectoray
-
-and size must be equal to -m -. -The input values of its elements -are not specified (must not matter). -Upon return, it is an -AD<Base> - version of - - -y -= -f -( -x -) - - -. - -
-
-Examples -
-The following files contain example uses of -the AD version of atomic functions during recording: -get_started.cpp -, -norm_sq.cpp -, -reciprocal.cpp -, -tangent.cpp -, -mat_mul.cpp -. - - -
Input File: cppad/core/atomic_base.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_afun_xml.js cppad-2019.02.00.0/doc/_atomic_afun_xml.js --- cppad-2018.00.00.0/doc/_atomic_afun_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_afun_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_afun.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_current0 = [ -'atomic_afun.xml#Syntax', -'atomic_afun.xml#Purpose', -'atomic_afun.xml#ADVector', -'atomic_afun.xml#afun', -'atomic_afun.xml#ax', -'atomic_afun.xml#ay', -'atomic_afun.xml#Examples' -]; -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-2018.00.00.0/doc/atomic_base_clear.xml cppad-2019.02.00.0/doc/atomic_base_clear.xml --- cppad-2018.00.00.0/doc/atomic_base_clear.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_base_clear.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,153 +0,0 @@ - - - -Free Static Variables - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_base_clear - -

- - - -
Free Static Variables
-
-Syntax - -
- -atomic_base<Base>::clear() - - -
-
-Purpose -
-Each atomic_base objects holds onto work space in order to -avoid repeated memory allocation calls and thereby increase speed -(until it is deleted). -If an the atomic_base object is global or static because, -the it does not get deleted. -This is a problem when using -thread_alloc free_all - -to check that all allocated memory has been freed. -Calling this clear function will free all the -memory currently being held onto by the - -atomic_base<Base> - class. - -
-
-Future Use -
-If there is future use of an atomic_base object, -after a call to clear, -the work space will be reallocated and held onto. - -
-
-Restriction -
-This routine cannot be called -while in parallel - execution mode. - - -
Input File: cppad/core/atomic_base.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_base_clear_xml.js cppad-2019.02.00.0/doc/_atomic_base_clear_xml.js --- cppad-2018.00.00.0/doc/_atomic_base_clear_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_base_clear_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', -'ad.xml', -'advalued.xml', -'atomic.xml', -'atomic_base.xml', -'atomic_base_clear.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_current0 = [ -'atomic_base_clear.xml#Syntax', -'atomic_base_clear.xml#Purpose', -'atomic_base_clear.xml#Future Use', -'atomic_base_clear.xml#Restriction' -]; -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-2018.00.00.0/doc/atomic_base.xml cppad-2019.02.00.0/doc/atomic_base.xml --- cppad-2018.00.00.0/doc/atomic_base.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_base.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,284 +0,0 @@ - - - -User Defined Atomic AD Functions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
User Defined Atomic AD Functions
-
-Syntax - - -
- -
-
atomic_user afun(ctor_arg_list)
-
afun(axay)
-
ok = afun.forward(pqvxvytxty)
-
ok = afun.reverse(qtxtypxpy)
-
ok = afun.for_sparse_jac(qrs)
-
ok = afun.rev_sparse_jac(qrs)
-
ok = afun.for_sparse_hes(vxrsh)
-
ok = afun.rev_sparse_hes(vxstqruv)
-atomic_base<
Base>::clear()
- - -
-
-Purpose -
-In some cases, the user knows how to compute derivatives of a function - - -y -= -f -( -x -) - -where - - -f -: -B -n - - -B -m - - - -more efficiently than by coding it using -AD<Base> - -atomic - operations -and letting CppAD do the rest. -In this case -atomic_base<Base> - can use -the user code for - -f -( -x -) - - -, and its derivatives, -as -AD<Base> - atomic operations. - -
-
-Virtual Functions -
-User defined derivatives are implemented by defining the -following virtual functions in the -base_atomic - class: -forward -, -reverse -, -for_sparse_jac -, -rev_sparse_jac -, and -rev_sparse_hes -. -These virtual functions have a default implementation -that returns -ok == false -. -The forward function, -for the case -q == 0 -, must be implemented. -Otherwise, only those functions -required by the your calculations need to be implemented. -For example, - -forward - for the case -q == 2 - can just return - -ok == false - unless you require -forward mode calculation of second derivatives. - -
-
-Contents -
- -
atomic_ctorAtomic Function Constructor
atomic_optionSet Atomic Function Options
atomic_afunUsing AD Version of Atomic Function
atomic_forwardAtomic Forward Mode
atomic_reverseAtomic Reverse Mode
atomic_for_sparse_jacAtomic Forward Jacobian Sparsity Patterns
atomic_rev_sparse_jacAtomic Reverse Jacobian Sparsity Patterns
atomic_for_sparse_hesAtomic Forward Hessian Sparsity Patterns
atomic_rev_sparse_hesAtomic Reverse Hessian Sparsity Patterns
atomic_base_clearFree Static Variables
atomic_get_started.cppGetting Started with Atomic Operations: Example and Test
atomic_norm_sq.cppAtomic Euclidean Norm Squared: Example and Test
atomic_reciprocal.cppReciprocal as an Atomic Operation: Example and Test
atomic_set_sparsity.cppAtomic Sparsity with Set Patterns: Example and Test
atomic_tangent.cppTan and Tanh as User Atomic Operations: Example and Test
atomic_eigen_mat_mul.cppAtomic Eigen Matrix Multiply: Example and Test
atomic_eigen_mat_inv.cppAtomic Eigen Matrix Inverse: Example and Test
atomic_eigen_cholesky.cppAtomic Eigen Cholesky Factorization: Example and Test
atomic_mat_mul.cppUser Atomic Matrix Multiply: Example and Test

-Examples - - -
-
-Getting Started -
-The file atomic_get_started.cpp - contains an example and test -that shows the minimal amount of information required to create -a user defined atomic operation. - -
-
-Scalar Function -
-The file atomic_reciprocal.cpp - contains an example and test -where the user provides the code for computing derivatives. -This example is simple because the domain and range are scalars. - -
-
-Vector Range -
-The file atomic_tangent.cpp - contains another example -where the user provides the code for computing derivatives. -This example is more complex because the range has two components. - -
-
-Hessian Sparsity Patterns -
-The file atomic_rev_sparse_hes.cpp - contains an minimal example -where the user provides the code for computing Hessian sparsity patterns. - -
-
-General Case -
-The file atomic_mat_mul.cpp - contains a more general example -where the user provides the code for computing derivatives. -This example is more complex because both the domain and range -dimensions are arbitrary. - - -
Input File: omh/atomic_base.omh - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_base_xml.js cppad-2019.02.00.0/doc/_atomic_base_xml.js --- cppad-2018.00.00.0/doc/_atomic_base_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_base_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +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', -'atomic.xml', -'atomic_base.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 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down0 = [ -'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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_current0 = [ -'atomic_base.xml#Syntax', -'atomic_base.xml#Purpose', -'atomic_base.xml#Virtual Functions', -'atomic_base.xml#Contents', -'atomic_base.xml#Examples', -'atomic_base.xml#Examples.Getting Started', -'atomic_base.xml#Examples.Scalar Function', -'atomic_base.xml#Examples.Vector Range', -'atomic_base.xml#Examples.Hessian Sparsity Patterns', -'atomic_base.xml#General Case' -]; -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-2018.00.00.0/doc/atomic_ctor.xml cppad-2019.02.00.0/doc/atomic_ctor.xml --- cppad-2018.00.00.0/doc/atomic_ctor.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_ctor.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,301 +0,0 @@ - - - -Atomic Function Constructor - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_ctor - -

- - - -
Atomic Function Constructor
-
-Syntax - -
- -atomic_user afun(ctor_arg_list)
-
- -atomic_base<Base>(namesparsity)
-
-
-atomic_user - - -
-
-ctor_arg_list -
-Is a list of arguments for the -atomic_user - constructor. - -
-
-afun -
-The object -afun - must stay in scope for as long -as the corresponding atomic function is used. -This includes use by any ADFun<Base> - that -has this -atomic_user - operation in its -operation sequence -. - -
-
-Implementation -
-The user defined -atomic_user - class is a publicly derived class of - -atomic_base<Base> -. -It should be declared as follows: - -
-     class 
atomic_user : public CppAD::atomic_base<Base> {
-     public:
-          
atomic_user(ctor_arg_list) : atomic_base<Base>(namesparsity)
-     
...
-     };
-
-where -... - -denotes the rest of the implementation of the derived class. -This includes completing the constructor and -all the virtual functions that have their -atomic_base implementations replaced by - -atomic_user - implementations. - -
-
-atomic_base - - -
-
-Restrictions -
-The atomic_base constructor cannot be called in -parallel - mode. - -
-
-Base -
-The template parameter determines the - -Base - type for this -AD<Base> - atomic operation. - -
-
-name -
-This atomic_base constructor argument has the following prototype - -
-     const std::string& 
name
-
-It is the name for this atomic function and is used for error reporting. -The suggested value for -name - is -afun - or -atomic_user -, -i.e., the name of the corresponding atomic object or class. - -
-
-sparsity -
-This atomic_base constructor argument has prototype - -
-     atomic_base<
Base>::option_enum sparsity
-
-The current -sparsity - for an atomic_base object -determines which type of sparsity patterns it uses -and its value is one of the following: - -
- - -sparsity - - sparsity patterns
- - -atomic_base<Base>::pack_sparsity_enum -    - - vectorBool - -
- - -atomic_base<Base>::bool_sparsity_enum -    - - vector -<bool> -
- - -atomic_base<Base>::set_sparsity_enum -    - - vector -<std::set<std::size_t> > -
-There is a default value for -sparsity - if it is not -included in the constructor (which may be either the bool or set option). - -
-
-Example - - -
-
-Define Constructor -
-The following is an example of a user atomic function constructor definitions: -get_started.cpp -. - -
-
-Use Constructor -
-The following is an example using a user atomic function constructor: -get_started.cpp -. - - -
Input File: cppad/core/atomic_base.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_ctor_xml.js cppad-2019.02.00.0/doc/_atomic_ctor_xml.js --- cppad-2018.00.00.0/doc/_atomic_ctor_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_ctor_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_ctor.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_current0 = [ -'atomic_ctor.xml#Syntax', -'atomic_ctor.xml#atomic_user', -'atomic_ctor.xml#atomic_user.ctor_arg_list', -'atomic_ctor.xml#atomic_user.afun', -'atomic_ctor.xml#atomic_user.Implementation', -'atomic_ctor.xml#atomic_base', -'atomic_ctor.xml#atomic_base.Restrictions', -'atomic_ctor.xml#atomic_base.Base', -'atomic_ctor.xml#atomic_base.name', -'atomic_ctor.xml#atomic_base.sparsity', -'atomic_ctor.xml#Example', -'atomic_ctor.xml#Example.Define Constructor', -'atomic_ctor.xml#Example.Use Constructor' -]; -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-2018.00.00.0/doc/atomic_eigen_cholesky.cpp.xml cppad-2019.02.00.0/doc/atomic_eigen_cholesky.cpp.xml --- cppad-2018.00.00.0/doc/atomic_eigen_cholesky.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_eigen_cholesky.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,424 +0,0 @@ - - - -Atomic Eigen Cholesky Factorization: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Atomic Eigen Cholesky Factorization: Example and Test
-
-Description -
-The ADFun - function object -f - for this example is - - -f -( -x -) -= -chol - -( -x -0 - - -x -1 - - -x -1 - - -x -2 - - -) -= -1 - -x -0 - - - - - -( -x -0 - - -0 - -x -1 - - -x -0 - -x -2 - -- -x -1 - -x -1 - - - - -) - - -where the matrix is positive definite; i.e., - - -x -0 - -> -0 - - -, - -x -2 - -> -0 - - - and - - -x -0 - -x -2 - -- -x -1 - -x -1 - -> -0 - - -. - -
-
-Contents -
- -
cholesky_theoryAD Theory for Cholesky Factorization
atomic_eigen_cholesky.hppAtomic Eigen Cholesky Factorization Class

-Use Atomic Function - -
# include <cppad/cppad.hpp>
-# include <cppad/example/eigen_cholesky.hpp>
-
-
-bool eigen_cholesky(void)
-{
-     typedef double scalar;
-     typedef typename atomic_eigen_cholesky<scalar>::ad_scalar ad_scalar;
-     typedef typename atomic_eigen_cholesky<scalar>::ad_matrix ad_matrix;
-     //
-     bool ok    = true;
-     scalar eps = 10. * std::numeric_limits<scalar>::epsilon();
-     using CppAD::NearEqual;
-     //
-
-Constructor - -
     // -------------------------------------------------------------------
-     // object that computes cholesky factor of a matrix
-     atomic_eigen_cholesky<scalar> cholesky;
-     // -------------------------------------------------------------------
-     // declare independent variable vector x
-     size_t n = 3;
-     CPPAD_TESTVECTOR(ad_scalar) ad_x(n);
-     ad_x[0] = 2.0;
-     ad_x[1] = 0.5;
-     ad_x[2] = 3.0;
-     CppAD::Independent(ad_x);
-     // -------------------------------------------------------------------
-     // A = [ x[0]  x[1] ]
-     //     [ x[1]  x[2] ]
-     size_t nr  = 2;
-     ad_matrix ad_A(nr, nr);
-     ad_A(0, 0) = ad_x[0];
-     ad_A(1, 0) = ad_x[1];
-     ad_A(0, 1) = ad_x[1];
-     ad_A(1, 1) = ad_x[2];
-     // -------------------------------------------------------------------
-     // use atomic operation to L such that A = L * L^T
-     ad_matrix ad_L = cholesky.op(ad_A);
-     // -------------------------------------------------------------------
-     // declare the dependent variable vector y
-     size_t m = 3;
-     CPPAD_TESTVECTOR(ad_scalar) ad_y(m);
-     ad_y[0] = ad_L(0, 0);
-     ad_y[1] = ad_L(1, 0);
-     ad_y[2] = ad_L(1, 1);
-     CppAD::ADFun<scalar> f(ad_x, ad_y);
-     // -------------------------------------------------------------------
-     // check zero order forward mode
-     CPPAD_TESTVECTOR(scalar) x(n), y(m);
-     x[0] = 2.0;
-     x[1] = 0.5;
-     x[2] = 5.0;
-     y   = f.Forward(0, x);
-     scalar check;
-     check = std::sqrt( x[0] );
-     ok   &= NearEqual(y[0], check, eps, eps);
-     check = x[1] / std::sqrt( x[0] );
-     ok   &= NearEqual(y[1], check, eps, eps);
-     check = std::sqrt( x[2] - x[1] * x[1] / x[0] );
-     ok   &= NearEqual(y[2], check, eps, eps);
-     // -------------------------------------------------------------------
-     // check first order forward mode
-     CPPAD_TESTVECTOR(scalar) x1(n), y1(m);
-     //
-     // partial w.r.t. x[0]
-     x1[0] = 1.0;
-     x1[1] = 0.0;
-     x1[2] = 0.0;
-     //
-     y1    = f.Forward(1, x1);
-     check = 1.0 / (2.0 * std::sqrt( x[0] ) );
-     ok   &= NearEqual(y1[0], check, eps, eps);
-     //
-     check = - x[1] / (2.0 * x[0] * std::sqrt( x[0] ) );
-     ok   &= NearEqual(y1[1], check, eps, eps);
-     //
-     check = std::sqrt( x[2] - x[1] * x[1] / x[0] );
-     check = x[1] * x[1] / (x[0] * x[0] * 2.0 * check);
-     ok   &= NearEqual(y1[2], check, eps, eps);
-     //
-     // partial w.r.t. x[1]
-     x1[0] = 0.0;
-     x1[1] = 1.0;
-     x1[2] = 0.0;
-     //
-     y1    = f.Forward(1, x1);
-     ok   &= NearEqual(y1[0], 0.0, eps, eps);
-     //
-     check = 1.0 / std::sqrt( x[0] );
-     ok   &= NearEqual(y1[1], check, eps, eps);
-     //
-     check = std::sqrt( x[2] - x[1] * x[1] / x[0] );
-     check = - 2.0 * x[1] / (2.0 * check * x[0] );
-     ok   &= NearEqual(y1[2], check, eps, eps);
-     //
-     // partial w.r.t. x[2]
-     x1[0] = 0.0;
-     x1[1] = 0.0;
-     x1[2] = 1.0;
-     //
-     y1    = f.Forward(1, x1);
-     ok   &= NearEqual(y1[0], 0.0, eps, eps);
-     ok   &= NearEqual(y1[1], 0.0, eps, eps);
-     //
-     check = std::sqrt( x[2] - x[1] * x[1] / x[0] );
-     check = 1.0 / (2.0 * check);
-     ok   &= NearEqual(y1[2], check, eps, eps);
-     // -------------------------------------------------------------------
-     // check second order forward mode
-     CPPAD_TESTVECTOR(scalar) x2(n), y2(m);
-     //
-     // second partial w.r.t x[2]
-     x2[0] = 0.0;
-     x2[1] = 0.0;
-     x2[2] = 0.0;
-     y2    = f.Forward(2, x2);
-     ok   &= NearEqual(y2[0], 0.0, eps, eps);
-     ok   &= NearEqual(y2[1], 0.0, eps, eps);
-     //
-     check = std::sqrt( x[2] - x[1] * x[1] / x[0] );  // funciton value
-     check = - 1.0 / ( 4.0 * check * check * check ); // second derivative
-     check = 0.5 * check;                             // taylor coefficient
-     ok   &= NearEqual(y2[2], check, eps, eps);
-     // -------------------------------------------------------------------
-     // check first order reverse mode
-     CPPAD_TESTVECTOR(scalar) w(m), d1w(n);
-     w[0] = 0.0;
-     w[1] = 0.0;
-     w[2] = 1.0;
-     d1w  = f.Reverse(1, w);
-     //
-     // partial of f[2] w.r.t x[0]
-     scalar f2    = std::sqrt( x[2] - x[1] * x[1] / x[0] );
-     scalar f2_x0 = x[1] * x[1] / (2.0 * f2 * x[0] * x[0] );
-     ok          &= NearEqual(d1w[0], f2_x0, eps, eps);
-     //
-     // partial of f[2] w.r.t x[1]
-     scalar f2_x1 = - x[1] / (f2 * x[0] );
-     ok          &= NearEqual(d1w[1], f2_x1, eps, eps);
-     //
-     // partial of f[2] w.r.t x[2]
-     scalar f2_x2 = 1.0 / (2.0 * f2 );
-     ok          &= NearEqual(d1w[2], f2_x2, eps, eps);
-     // -------------------------------------------------------------------
-     // check second order reverse mode
-     CPPAD_TESTVECTOR(scalar) d2w(2 * n);
-     d2w  = f.Reverse(2, w);
-     //
-     // check first order results
-     ok &= NearEqual(d2w[0 * 2 + 0], f2_x0, eps, eps);
-     ok &= NearEqual(d2w[1 * 2 + 0], f2_x1, eps, eps);
-     ok &= NearEqual(d2w[2 * 2 + 0], f2_x2, eps, eps);
-     //
-     // check second order results
-     scalar f2_x2_x0 = - 0.5 * f2_x0 / (f2 * f2 );
-     ok             &= NearEqual(d2w[0 * 2 + 1], f2_x2_x0, eps, eps);
-     scalar f2_x2_x1 = - 0.5 * f2_x1 / (f2 * f2 );
-     ok             &= NearEqual(d2w[1 * 2 + 1], f2_x2_x1, eps, eps);
-     scalar f2_x2_x2 = - 0.5 * f2_x2 / (f2 * f2 );
-     ok             &= NearEqual(d2w[2 * 2 + 1], f2_x2_x2, eps, eps);
-     // -------------------------------------------------------------------
-     // check third order reverse mode
-     CPPAD_TESTVECTOR(scalar) d3w(3 * n);
-     d3w  = f.Reverse(3, w);
-     //
-     // check first order results
-     ok &= NearEqual(d3w[0 * 3 + 0], f2_x0, eps, eps);
-     ok &= NearEqual(d3w[1 * 3 + 0], f2_x1, eps, eps);
-     ok &= NearEqual(d3w[2 * 3 + 0], f2_x2, eps, eps);
-     //
-     // check second order results
-     ok             &= NearEqual(d3w[0 * 3 + 1], f2_x2_x0, eps, eps);
-     ok             &= NearEqual(d3w[1 * 3 + 1], f2_x2_x1, eps, eps);
-     ok             &= NearEqual(d3w[2 * 3 + 1], f2_x2_x2, eps, eps);
-     // -------------------------------------------------------------------
-     scalar f2_x2_x2_x0 = - 0.5 * f2_x2_x0 / (f2 * f2);
-     f2_x2_x2_x0 += f2_x2 * f2_x0 / (f2 * f2 * f2);
-     ok          &= NearEqual(d3w[0 * 3 + 2], 0.5 * f2_x2_x2_x0, eps, eps);
-     scalar f2_x2_x2_x1 = - 0.5 * f2_x2_x1 / (f2 * f2);
-     f2_x2_x2_x1 += f2_x2 * f2_x1 / (f2 * f2 * f2);
-     ok          &= NearEqual(d3w[1 * 3 + 2], 0.5 * f2_x2_x2_x1, eps, eps);
-     scalar f2_x2_x2_x2 = - 0.5 * f2_x2_x2 / (f2 * f2);
-     f2_x2_x2_x2 += f2_x2 * f2_x2 / (f2 * f2 * f2);
-     ok          &= NearEqual(d3w[2 * 3 + 2], 0.5 * f2_x2_x2_x2, eps, eps);
-     return ok;
-}
- -
Input File: example/atomic/eigen_cholesky.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_eigen_cholesky.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_eigen_cholesky.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_eigen_cholesky.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_eigen_cholesky.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_eigen_cholesky.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down0 = [ -'cholesky_theory.xml', -'atomic_eigen_cholesky.hpp.xml' -]; -var list_current0 = [ -'atomic_eigen_cholesky.cpp.xml#Description', -'atomic_eigen_cholesky.cpp.xml#Contents', -'atomic_eigen_cholesky.cpp.xml#Use Atomic Function', -'atomic_eigen_cholesky.cpp.xml#Use Atomic Function.Constructor' -]; -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-2018.00.00.0/doc/atomic_eigen_cholesky.hpp.xml cppad-2019.02.00.0/doc/atomic_eigen_cholesky.hpp.xml --- cppad-2018.00.00.0/doc/atomic_eigen_cholesky.hpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_eigen_cholesky.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,500 +0,0 @@ - - - -Atomic Eigen Cholesky Factorization Class - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_eigen_cholesky.hpp - -

-
Atomic Eigen Cholesky Factorization Class
-
-Purpose -
-Construct an atomic operation that computes a lower triangular matrix - - -L - - - such that - -L -L -T - - -= -A - - - -for any positive integer - -p - - - -and symmetric positive definite matrix - -A - -R - -p -× -p - - - - -. - -
-
-Start Class Definition - -
# include <cppad/cppad.hpp>
-# include <Eigen/Dense>
-
-
-Public - - -
-
-Types - -
namespace { // BEGIN_EMPTY_NAMESPACE
-
-template <class Base>
-class atomic_eigen_cholesky : public CppAD::atomic_base<Base> {
-public:
-     // -----------------------------------------------------------
-     // type of elements during calculation of derivatives
-     typedef Base              scalar;
-     // type of elements during taping
-     typedef CppAD::AD<scalar> ad_scalar;
-     //
-     // type of matrix during calculation of derivatives
-     typedef Eigen::Matrix<
-          scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>        matrix;
-     // type of matrix during taping
-     typedef Eigen::Matrix<
-          ad_scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ad_matrix;
-     //
-     // lower triangular scalar matrix
-     typedef Eigen::TriangularView<matrix, Eigen::Lower>             lower_view;
-
-Constructor - -
     // constructor
-     atomic_eigen_cholesky(void) : CppAD::atomic_base<Base>(
-          "atom_eigen_cholesky"                             ,
-          CppAD::atomic_base<Base>::set_sparsity_enum
-     )
-     { }
-
-op - -
     // use atomic operation to invert an AD matrix
-     ad_matrix op(const ad_matrix& arg)
-     {     size_t nr = size_t( arg.rows() );
-          size_t ny = ( (nr + 1 ) * nr ) / 2;
-          size_t nx = 1 + ny;
-          assert( nr == size_t( arg.cols() ) );
-          // -------------------------------------------------------------------
-          // packed version of arg
-          CPPAD_TESTVECTOR(ad_scalar) packed_arg(nx);
-          size_t index = 0;
-          packed_arg[index++] = ad_scalar( nr );
-          // lower triangle of symmetric matrix A
-          for(size_t i = 0; i < nr; i++)
-          {     for(size_t j = 0; j <= i; j++)
-                    packed_arg[index++] = arg(i, j);
-          }
-          assert( index == nx );
-          // -------------------------------------------------------------------
-          // packed version of result = arg^{-1}.
-          // This is an atomic_base function call that CppAD uses to
-          // store the atomic operation on the tape.
-          CPPAD_TESTVECTOR(ad_scalar) packed_result(ny);
-          (*this)(packed_arg, packed_result);
-          // -------------------------------------------------------------------
-          // unpack result matrix L
-          ad_matrix result = ad_matrix::Zero(nr, nr);
-          index = 0;
-          for(size_t i = 0; i < nr; i++)
-          {     for(size_t j = 0; j <= i; j++)
-                    result(i, j) = packed_result[index++];
-          }
-          return result;
-     }
-
-Private - - -
-
-Variables - -
private:
-     // -------------------------------------------------------------
-     // one forward mode vector of matrices for argument and result
-     CppAD::vector<matrix> f_arg_, f_result_;
-     // one reverse mode vector of matrices for argument and result
-     CppAD::vector<matrix> r_arg_, r_result_;
-     // -------------------------------------------------------------
-
-forward - -
     // forward mode routine called by CppAD
-     virtual bool forward(
-          // lowest order Taylor coefficient we are evaluating
-          size_t                          p ,
-          // highest order Taylor coefficient we are evaluating
-          size_t                          q ,
-          // which components of x are variables
-          const CppAD::vector<bool>&      vx ,
-          // which components of y are variables
-          CppAD::vector<bool>&            vy ,
-          // tx [ j * (q+1) + k ] is x_j^k
-          const CppAD::vector<scalar>&    tx ,
-          // ty [ i * (q+1) + k ] is y_i^k
-          CppAD::vector<scalar>&          ty
-     )
-     {     size_t n_order = q + 1;
-          size_t nr      = size_t( CppAD::Integer( tx[ 0 * n_order + 0 ] ) );
-          size_t ny      = ((nr + 1) * nr) / 2;
-# ifndef NDEBUG
-          size_t nx      = 1 + ny;
-# endif
-          assert( vx.size() == 0 || nx == vx.size() );
-          assert( vx.size() == 0 || ny == vy.size() );
-          assert( nx * n_order == tx.size() );
-          assert( ny * n_order == ty.size() );
-          //
-          // -------------------------------------------------------------------
-          // make sure f_arg_ and f_result_ are large enough
-          assert( f_arg_.size() == f_result_.size() );
-          if( f_arg_.size() < n_order )
-          {     f_arg_.resize(n_order);
-               f_result_.resize(n_order);
-               //
-               for(size_t k = 0; k < n_order; k++)
-               {     f_arg_[k].resize(nr, nr);
-                    f_result_[k].resize(nr, nr);
-               }
-          }
-          // -------------------------------------------------------------------
-          // unpack tx into f_arg_
-          for(size_t k = 0; k < n_order; k++)
-          {     size_t index = 1;
-               // unpack arg values for this order
-               for(size_t i = 0; i < nr; i++)
-               {     for(size_t j = 0; j <= i; j++)
-                    {     f_arg_[k](i, j) = tx[ index * n_order + k ];
-                         f_arg_[k](j, i) = f_arg_[k](i, j);
-                         index++;
-                    }
-               }
-          }
-          // -------------------------------------------------------------------
-          // result for each order
-          // (we could avoid recalculting f_result_[k] for k=0,...,p-1)
-          //
-          Eigen::LLT<matrix> cholesky(f_arg_[0]);
-          f_result_[0]   = cholesky.matrixL();
-          lower_view L_0 = f_result_[0].template triangularView<Eigen::Lower>();
-          for(size_t k = 1; k < n_order; k++)
-          {     // initialize sum as A_k
-               matrix f_sum = f_arg_[k];
-               // compute A_k - B_k
-               for(size_t ell = 1; ell < k; ell++)
-                    f_sum -= f_result_[ell] * f_result_[k-ell].transpose();
-               // compute L_0^{-1} * (A_k - B_k) * L_0^{-T}
-               matrix temp = L_0.template solve<Eigen::OnTheLeft>(f_sum);
-               temp   = L_0.transpose().template solve<Eigen::OnTheRight>(temp);
-               // divide the diagonal by 2
-               for(size_t i = 0; i < nr; i++)
-                    temp(i, i) /= scalar(2.0);
-               // L_k = L_0 * low[ L_0^{-1} * (A_k - B_k) * L_0^{-T} ]
-               lower_view view = temp.template triangularView<Eigen::Lower>();
-               f_result_[k] = f_result_[0] * view;
-          }
-          // -------------------------------------------------------------------
-          // pack result_ into ty
-          for(size_t k = 0; k < n_order; k++)
-          {     size_t index = 0;
-               for(size_t i = 0; i < nr; i++)
-               {     for(size_t j = 0; j <= i; j++)
-                    {     ty[ index * n_order + k ] = f_result_[k](i, j);
-                         index++;
-                    }
-               }
-          }
-          // -------------------------------------------------------------------
-          // check if we are computing vy
-          if( vx.size() == 0 )
-               return true;
-          // ------------------------------------------------------------------
-          // This is a very dumb algorithm that over estimates which
-          // elements of the inverse are variables (which is not efficient).
-          bool var = false;
-          for(size_t i = 0; i < ny; i++)
-               var |= vx[1 + i];
-          for(size_t i = 0; i < ny; i++)
-               vy[i] = var;
-          //
-          return true;
-     }
-
-reverse - -
     // reverse mode routine called by CppAD
-     virtual bool reverse(
-          // highest order Taylor coefficient that we are computing derivative of
-          size_t                     q ,
-          // forward mode Taylor coefficients for x variables
-          const CppAD::vector<double>&     tx ,
-          // forward mode Taylor coefficients for y variables
-          const CppAD::vector<double>&     ty ,
-          // upon return, derivative of G[ F[ {x_j^k} ] ] w.r.t {x_j^k}
-          CppAD::vector<double>&           px ,
-          // derivative of G[ {y_i^k} ] w.r.t. {y_i^k}
-          const CppAD::vector<double>&     py
-     )
-     {     size_t n_order = q + 1;
-          size_t nr = size_t( CppAD::Integer( tx[ 0 * n_order + 0 ] ) );
-# ifndef NDEBUG
-          size_t ny = ( (nr + 1 ) * nr ) / 2;
-          size_t nx = 1 + ny;
-# endif
-          //
-          assert( nx * n_order == tx.size() );
-          assert( ny * n_order == ty.size() );
-          assert( px.size()    == tx.size() );
-          assert( py.size()    == ty.size() );
-          // -------------------------------------------------------------------
-          // make sure f_arg_ is large enough
-          assert( f_arg_.size() == f_result_.size() );
-          // must have previous run forward with order >= n_order
-          assert( f_arg_.size() >= n_order );
-          // -------------------------------------------------------------------
-          // make sure r_arg_, r_result_ are large enough
-          assert( r_arg_.size() == r_result_.size() );
-          if( r_arg_.size() < n_order )
-          {     r_arg_.resize(n_order);
-               r_result_.resize(n_order);
-               //
-               for(size_t k = 0; k < n_order; k++)
-               {     r_arg_[k].resize(nr, nr);
-                    r_result_[k].resize(nr, nr);
-               }
-          }
-          // -------------------------------------------------------------------
-          // unpack tx into f_arg_
-          for(size_t k = 0; k < n_order; k++)
-          {     size_t index = 1;
-               // unpack arg values for this order
-               for(size_t i = 0; i < nr; i++)
-               {     for(size_t j = 0; j <= i; j++)
-                    {     f_arg_[k](i, j) = tx[ index * n_order + k ];
-                         f_arg_[k](j, i) = f_arg_[k](i, j);
-                         index++;
-                    }
-               }
-          }
-          // -------------------------------------------------------------------
-          // unpack py into r_result_
-          for(size_t k = 0; k < n_order; k++)
-          {     r_result_[k] = matrix::Zero(nr, nr);
-               size_t index = 0;
-               for(size_t i = 0; i < nr; i++)
-               {     for(size_t j = 0; j <= i; j++)
-                    {     r_result_[k](i, j) = py[ index * n_order + k ];
-                         index++;
-                    }
-               }
-          }
-          // -------------------------------------------------------------------
-          // initialize r_arg_ as zero
-          for(size_t k = 0; k < n_order; k++)
-               r_arg_[k]   = matrix::Zero(nr, nr);
-          // -------------------------------------------------------------------
-          // matrix reverse mode calculation
-          lower_view L_0 = f_result_[0].template triangularView<Eigen::Lower>();
-          //
-          for(size_t k1 = n_order; k1 > 1; k1--)
-          {     size_t k = k1 - 1;
-               //
-               // L_0^T * bar{L}_k
-               matrix tmp1 = L_0.transpose() * r_result_[k];
-               //
-               //low[ L_0^T * bar{L}_k ]
-               for(size_t i = 0; i < nr; i++)
-                    tmp1(i, i) /= scalar(2.0);
-               matrix tmp2 = tmp1.template triangularView<Eigen::Lower>();
-               //
-               // L_0^{-T} low[ L_0^T * bar{L}_k ]
-               tmp1 = L_0.transpose().template solve<Eigen::OnTheLeft>( tmp2 );
-               //
-               // M_k = L_0^{-T} * low[ L_0^T * bar{L}_k ]^{T} L_0^{-1}
-               matrix M_k = L_0.transpose().template
-                    solve<Eigen::OnTheLeft>( tmp1.transpose() );
-               //
-               // remove L_k and compute bar{B}_k
-               matrix barB_k = scalar(0.5) * ( M_k + M_k.transpose() );
-               r_arg_[k]    += barB_k;
-               barB_k        = scalar(-1.0) * barB_k;
-               //
-               // 2.0 * lower( bar{B}_k L_k )
-               matrix temp = scalar(2.0) * barB_k * f_result_[k];
-               temp        = temp.template triangularView<Eigen::Lower>();
-               //
-               // remove C_k
-               r_result_[0] += temp;
-               //
-               // remove B_k
-               for(size_t ell = 1; ell < k; ell++)
-               {     // bar{L}_ell = 2 * lower( \bar{B}_k * L_{k-ell} )
-                    temp = scalar(2.0) * barB_k * f_result_[k-ell];
-                    r_result_[ell] += temp.template triangularView<Eigen::Lower>();
-               }
-          }
-          // M_0 = L_0^{-T} * low[ L_0^T * bar{L}_0 ]^{T} L_0^{-1}
-          matrix M_0 = L_0.transpose() * r_result_[0];
-          for(size_t i = 0; i < nr; i++)
-               M_0(i, i) /= scalar(2.0);
-          M_0 = M_0.template triangularView<Eigen::Lower>();
-          M_0 = L_0.template solve<Eigen::OnTheRight>( M_0 );
-          M_0 = L_0.transpose().template solve<Eigen::OnTheLeft>( M_0 );
-          // remove L_0
-          r_arg_[0] += scalar(0.5) * ( M_0 + M_0.transpose() );
-          // -------------------------------------------------------------------
-          // pack r_arg into px
-          // note that only the lower triangle of barA_k is stored in px
-          for(size_t k = 0; k < n_order; k++)
-          {     size_t index = 0;
-               px[ index * n_order + k ] = 0.0;
-               index++;
-               for(size_t i = 0; i < nr; i++)
-               {     for(size_t j = 0; j < i; j++)
-                    {     px[ index * n_order + k ] = 2.0 * r_arg_[k](i, j);
-                         index++;
-                    }
-                    px[ index * n_order + k] = r_arg_[k](i, i);
-                    index++;
-               }
-          }
-          // -------------------------------------------------------------------
-          return true;
-     }
-
-End Class Definition - -

-}; // End of atomic_eigen_cholesky class
-
-}  // END_EMPTY_NAMESPACE
-
- -
Input File: cppad/example/eigen_cholesky.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_eigen_cholesky.hpp_xml.js cppad-2019.02.00.0/doc/_atomic_eigen_cholesky.hpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_eigen_cholesky.hpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_eigen_cholesky.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_eigen_cholesky.hpp.xml' -]; -var list_down3 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down2 = [ -'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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down1 = [ -'cholesky_theory.xml', -'atomic_eigen_cholesky.hpp.xml' -]; -var list_current0 = [ -'atomic_eigen_cholesky.hpp.xml#Purpose', -'atomic_eigen_cholesky.hpp.xml#Start Class Definition', -'atomic_eigen_cholesky.hpp.xml#Public', -'atomic_eigen_cholesky.hpp.xml#Public.Types', -'atomic_eigen_cholesky.hpp.xml#Public.Constructor', -'atomic_eigen_cholesky.hpp.xml#Public.op', -'atomic_eigen_cholesky.hpp.xml#Private', -'atomic_eigen_cholesky.hpp.xml#Private.Variables', -'atomic_eigen_cholesky.hpp.xml#Private.forward', -'atomic_eigen_cholesky.hpp.xml#Private.reverse', -'atomic_eigen_cholesky.hpp.xml#End Class Definition' -]; -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-2018.00.00.0/doc/atomic_eigen_mat_inv.cpp.xml cppad-2019.02.00.0/doc/atomic_eigen_mat_inv.cpp.xml --- cppad-2018.00.00.0/doc/atomic_eigen_mat_inv.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_eigen_mat_inv.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,312 +0,0 @@ - - - -Atomic Eigen Matrix Inverse: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Atomic Eigen Matrix Inverse: Example and Test
-
-Description -
-The ADFun - function object -f - for this example is - - -f -( -x -) -= -( -x -0 - - -0 - -0 - -x -1 - - -) --1 - - -( -0 - -x -2 - - -) -= -( -0 - -x -2 - -/ -x -1 - -) - -) - - -
-Class Definition -
-This example uses the file atomic_eigen_mat_inv.hpp - -which defines matrix multiply as a atomic_base - operation. - - - -
-
-Use Atomic Function - -
# include <cppad/cppad.hpp>
-# include <cppad/example/eigen_mat_inv.hpp>
-# include <cppad/example/eigen_mat_mul.hpp>
-
-
-bool eigen_mat_inv(void)
-{
-     typedef double                                            scalar;
-     typedef CppAD::AD<scalar>                                 ad_scalar;
-     typedef typename atomic_eigen_mat_inv<scalar>::ad_matrix  ad_matrix;
-     //
-     bool ok    = true;
-     scalar eps = 10. * std::numeric_limits<scalar>::epsilon();
-     using CppAD::NearEqual;
-     //
-
-Constructor - -
     // -------------------------------------------------------------------
-     // object that multiplies matrices
-     atomic_eigen_mat_mul<scalar> mat_mul;
-     // -------------------------------------------------------------------
-     // object that computes inverse of a square matrix
-     atomic_eigen_mat_inv<scalar> mat_inv;
-     // -------------------------------------------------------------------
-     // declare independent variable vector x
-     size_t n = 3;
-     CPPAD_TESTVECTOR(ad_scalar) ad_x(n);
-     for(size_t j = 0; j < n; j++)
-          ad_x[j] = ad_scalar(j + 1);
-     CppAD::Independent(ad_x);
-     // -------------------------------------------------------------------
-     // left = [ x[0]  0    ]
-     //        [ 0     x[1] ]
-     size_t nr_left  = 2;
-     ad_matrix ad_left(nr_left, nr_left);
-     ad_left(0, 0) = ad_x[0];
-     ad_left(0, 1) = ad_scalar(0.0);
-     ad_left(1, 0) = ad_scalar(0.0);
-     ad_left(1, 1) = ad_x[1];
-     // -------------------------------------------------------------------
-     // right = [ 0 , x[2] ]^T
-     size_t nc_right = 1;
-     ad_matrix ad_right(nr_left, nc_right);
-     ad_right(0, 0) = ad_scalar(0.0);
-     ad_right(1, 0) = ad_x[2];
-     // -------------------------------------------------------------------
-     // use atomic operation to compute left^{-1}
-     ad_matrix ad_left_inv = mat_inv.op(ad_left);
-     // use atomic operation to multiply left^{-1} * right
-     ad_matrix ad_result   = mat_mul.op(ad_left_inv, ad_right);
-     // -------------------------------------------------------------------
-     // declare the dependent variable vector y
-     size_t m = 2;
-     CPPAD_TESTVECTOR(ad_scalar) ad_y(2);
-     for(size_t i = 0; i < m; i++)
-          ad_y[i] = ad_result(i, 0);
-     CppAD::ADFun<scalar> f(ad_x, ad_y);
-     // -------------------------------------------------------------------
-     // check zero order forward mode
-     CPPAD_TESTVECTOR(scalar) x(n), y(m);
-     for(size_t i = 0; i < n; i++)
-          x[i] = scalar(i + 2);
-     y   = f.Forward(0, x);
-     ok &= NearEqual(y[0], 0.0,          eps, eps);
-     ok &= NearEqual(y[1], x[2] / x[1],  eps, eps);
-     // -------------------------------------------------------------------
-     // check first order forward mode
-     CPPAD_TESTVECTOR(scalar) x1(n), y1(m);
-     x1[0] = 1.0;
-     x1[1] = 0.0;
-     x1[2] = 0.0;
-     y1    = f.Forward(1, x1);
-     ok   &= NearEqual(y1[0], 0.0,        eps, eps);
-     ok   &= NearEqual(y1[1], 0.0,        eps, eps);
-     x1[0] = 0.0;
-     x1[1] = 0.0;
-     x1[2] = 1.0;
-     y1    = f.Forward(1, x1);
-     ok   &= NearEqual(y1[0], 0.0,        eps, eps);
-     ok   &= NearEqual(y1[1], 1.0 / x[1], eps, eps);
-     x1[0] = 0.0;
-     x1[1] = 1.0;
-     x1[2] = 0.0;
-     y1    = f.Forward(1, x1);
-     ok   &= NearEqual(y1[0], 0.0,                  eps, eps);
-     ok   &= NearEqual(y1[1], - x[2] / (x[1]*x[1]), eps, eps);
-     // -------------------------------------------------------------------
-     // check second order forward mode
-     CPPAD_TESTVECTOR(scalar) x2(n), y2(m);
-     x2[0] = 0.0;
-     x2[1] = 0.0;
-     x2[2] = 0.0;
-     scalar  f1_x1_x1 = 2.0 * x[2] / (x[1] * x[1] * x[1] );
-     y2    = f.Forward(2, x2);
-     ok   &= NearEqual(y2[0], 0.0,            eps, eps);
-     ok   &= NearEqual(y2[1], f1_x1_x1 / 2.0, eps, eps);
-     // -------------------------------------------------------------------
-     // check first order reverse
-     CPPAD_TESTVECTOR(scalar) w(m), d1w(n);
-     w[0] = 1.0;
-     w[1] = 0.0;
-     d1w  = f.Reverse(1, w);
-     ok  &= NearEqual(d1w[0], 0.0, eps, eps);
-     ok  &= NearEqual(d1w[1], 0.0, eps, eps);
-     ok  &= NearEqual(d1w[2], 0.0, eps, eps);
-     w[0] = 0.0;
-     w[1] = 1.0;
-     d1w  = f.Reverse(1, w);
-     ok  &= NearEqual(d1w[0], 0.0,                  eps, eps);
-     ok  &= NearEqual(d1w[1], - x[2] / (x[1]*x[1]), eps, eps);
-     ok  &= NearEqual(d1w[2], 1.0 / x[1],           eps, eps);
-     // -------------------------------------------------------------------
-     // check second order reverse
-     CPPAD_TESTVECTOR(scalar) d2w(2 * n);
-     d2w  = f.Reverse(2, w);
-     // partial f_1 w.r.t x_0
-     ok  &= NearEqual(d2w[0 * 2 + 0], 0.0,                  eps, eps);
-     // partial f_1 w.r.t x_1
-     ok  &= NearEqual(d2w[1 * 2 + 0], - x[2] / (x[1]*x[1]), eps, eps);
-     // partial f_1 w.r.t x_2
-     ok  &= NearEqual(d2w[2 * 2 + 0], 1.0 / x[1],           eps, eps);
-     // partial f_1 w.r.t x_1, x_0
-     ok  &= NearEqual(d2w[0 * 2 + 1], 0.0,                  eps, eps);
-     // partial f_1 w.r.t x_1, x_1
-     ok  &= NearEqual(d2w[1 * 2 + 1], f1_x1_x1,             eps, eps);
-     // partial f_1 w.r.t x_1, x_2
-     ok  &= NearEqual(d2w[2 * 2 + 1], - 1.0 / (x[1]*x[1]),  eps, eps);
-     // -------------------------------------------------------------------
-     return ok;
-}
- -
Input File: example/atomic/eigen_mat_inv.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_eigen_mat_inv.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_eigen_mat_inv.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_eigen_mat_inv.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_eigen_mat_inv.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_eigen_mat_inv.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down0 = [ -'atomic_eigen_mat_inv.hpp.xml' -]; -var list_current0 = [ -'atomic_eigen_mat_inv.cpp.xml#Description', -'atomic_eigen_mat_inv.cpp.xml#Class Definition', -'atomic_eigen_mat_inv.cpp.xml#Use Atomic Function', -'atomic_eigen_mat_inv.cpp.xml#Use Atomic Function.Constructor' -]; -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-2018.00.00.0/doc/atomic_eigen_mat_inv.hpp.xml cppad-2019.02.00.0/doc/atomic_eigen_mat_inv.hpp.xml --- cppad-2018.00.00.0/doc/atomic_eigen_mat_inv.hpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_eigen_mat_inv.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1274 +0,0 @@ - - - -Atomic Eigen Matrix Inversion Class - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_eigen_mat_inv.hpp - -

-
Atomic Eigen Matrix Inversion Class
-
-Purpose -
-Construct an atomic operation that computes the matrix inverse - - -R -= -A --1 - - - - - -for any positive integer - -p - - - -and invertible matrix - -A - -R - -p -× -p - - - - -. - -
-
-Matrix Dimensions -
-This example puts the matrix dimension - -p - - - -in the atomic function arguments, -instead of the constructor -, -so it can be different for different calls to the atomic function. - -
-
-Theory - - -
-
-Forward -
-The zero order forward mode Taylor coefficient is give by - - -R -0 - -= -A -0 --1 - - - - -For - -k -= -1 -, - - - -, -the k-th order Taylor coefficient of - -A -R - - - is given by - - -0 -= - - -= -0 - -k - -A - - -R -k -- - - - - - -Solving for - -R -k - - - - in terms of the coefficients -for - -A - - - and the lower order coefficients for - -R - - - we have - - -R -k - -= -- -R -0 - -( - -= -1 - -k - -A - - -R -k -- - - - -) - - -Furthermore, once we have - -R -k - - - - we can compute the sum using - - -A -0 - -R -k - -= -- -( - -= -1 - -k - -A - - -R -k -- - - - -) - - -
-Product of Three Matrices -
-Suppose - -E - -¯ - - - is the derivative of the -scalar value function - -s -( -E -) - - - with respect to - -E - - -; i.e., - - -E - -¯ -i -, -j - - -= - -s - - -E -i -, -j - - - - - - -Also suppose that - -t - - - is a scalar valued argument and - - -E -( -t -) -= -B -( -t -) -C -( -t -) -D -( -t -) - - -It follows that - - -E -' -( -t -) -= -B -' -( -t -) -C -( -t -) -D -( -t -) -+ -B -( -t -) -C -' -( -t -) -D -( -t -) -+ -B -( -t -) -C -( -t -) -D -' -( -t -) - - - - -( -s - -E -) -' -( -t -) -= -tr - -[ -E - -¯ -T - - -E -' -( -t -) -] - - - - -= -tr - -[ -E - -¯ -T - - -B -' -( -t -) -C -( -t -) -D -( -t -) -] -+ -tr - -[ -E - -¯ -T - - -B -( -t -) -C -' -( -t -) -D -( -t -) -] -+ -tr - -[ -E - -¯ -T - - -B -( -t -) -C -( -t -) -D -' -( -t -) -] - - - - -= -tr - -[ -B -( -t -) -D -( -t -) -E - -¯ -T - - -B -' -( -t -) -] -+ -tr - -[ -D -( -t -) -E - -¯ -T - - -B -( -t -) -C -' -( -t -) -] -+ -tr - -[ -E - -¯ -T - - -B -( -t -) -C -( -t -) -D -' -( -t -) -] - - - - -B - -¯ -= -E - -¯ -( -C -D -) -T - - - -, - -C - -¯ -= -B -T - - -E - -¯ -D -T - - - -, - -D - -¯ -= -( -B -C -) -T - - -E - -¯ - - -
-Reverse -
-For - -k -> -0 - - -, reverse mode -eliminates - -R -k - - - - and expresses the function values - - -s - - - in terms of the coefficients of - -A - - - -and the lower order coefficients of - -R - - -. -The effect on - -R - -¯ -0 - - - - -(of eliminating - -R -k - - - -) is - - -R - -¯ -0 - -= -R - -¯ -0 - -- -R - -¯ -k - -( - -= -1 - -k - -A - - -R -k -- - - - -) -T - - -= -R - -¯ -0 - -+ -R - -¯ -k - -( -A -0 - -R -k - -) -T - - - - -For - - -= -1 -, - -, -k - - -, -the effect on - -R - -¯ -k -- - - - - - - and - -A - - - - - -(of eliminating - -R -k - - - -) is - - -A - -¯ - - -= -A - -¯ - - -- -R -0 -T - - -R - -¯ -k - -R -k -- - - -T - - - - - - -R - -¯ -k -- - - - -= -R - -¯ -k -- - - - -- -( -R -0 - -A - - -) -T - - -R - -¯ -k - - - -We note that - - -R -0 - -' -( -t -) -A -0 - -( -t -) -+ -R -0 - -( -t -) -A -0 - -' -( -t -) -= -0 - - - - -R -0 - -' -( -t -) -= -- -R -0 - -( -t -) -A -0 - -' -( -t -) -R -0 - -( -t -) - - -The reverse mode formula that eliminates - -R -0 - - - - is - - -A - -¯ -0 - -= -A - -¯ -0 - -- -R -0 -T - - -R - -¯ -0 - -R -0 -T - - - - -
-Start Class Definition - -
# include <cppad/cppad.hpp>
-# include <Eigen/Core>
-# include <Eigen/LU>
-
-
-
-Public - - -
-
-Types - -
namespace { // BEGIN_EMPTY_NAMESPACE
-
-template <class Base>
-class atomic_eigen_mat_inv : public CppAD::atomic_base<Base> {
-public:
-     // -----------------------------------------------------------
-     // type of elements during calculation of derivatives
-     typedef Base              scalar;
-     // type of elements during taping
-     typedef CppAD::AD<scalar> ad_scalar;
-     // type of matrix during calculation of derivatives
-     typedef Eigen::Matrix<
-          scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>     matrix;
-     // type of matrix during taping
-     typedef Eigen::Matrix<
-          ad_scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ad_matrix;
-
-Constructor - -
     // constructor
-     atomic_eigen_mat_inv(void) : CppAD::atomic_base<Base>(
-          "atom_eigen_mat_inv"                             ,
-          CppAD::atomic_base<Base>::set_sparsity_enum
-     )
-     { }
-
-op - -
     // use atomic operation to invert an AD matrix
-     ad_matrix op(const ad_matrix& arg)
-     {     size_t nr = size_t( arg.rows() );
-          size_t ny = nr * nr;
-          size_t nx = 1 + ny;
-          assert( nr == size_t( arg.cols() ) );
-          // -------------------------------------------------------------------
-          // packed version of arg
-          CPPAD_TESTVECTOR(ad_scalar) packed_arg(nx);
-          packed_arg[0] = ad_scalar( nr );
-          for(size_t i = 0; i < ny; i++)
-               packed_arg[1 + i] = arg.data()[i];
-          // -------------------------------------------------------------------
-          // packed version of result = arg^{-1}.
-          // This is an atomic_base function call that CppAD uses to
-          // store the atomic operation on the tape.
-          CPPAD_TESTVECTOR(ad_scalar) packed_result(ny);
-          (*this)(packed_arg, packed_result);
-          // -------------------------------------------------------------------
-          // unpack result matrix
-          ad_matrix result(nr, nr);
-          for(size_t i = 0; i < ny; i++)
-               result.data()[i] = packed_result[i];
-          return result;
-     }
-
-Private - - -
-
-Variables - -
private:
-     // -------------------------------------------------------------
-     // one forward mode vector of matrices for argument and result
-     CppAD::vector<matrix> f_arg_, f_result_;
-     // one reverse mode vector of matrices for argument and result
-     CppAD::vector<matrix> r_arg_, r_result_;
-     // -------------------------------------------------------------
-
-forward - -
     // forward mode routine called by CppAD
-     virtual bool forward(
-          // lowest order Taylor coefficient we are evaluating
-          size_t                          p ,
-          // highest order Taylor coefficient we are evaluating
-          size_t                          q ,
-          // which components of x are variables
-          const CppAD::vector<bool>&      vx ,
-          // which components of y are variables
-          CppAD::vector<bool>&            vy ,
-          // tx [ j * (q+1) + k ] is x_j^k
-          const CppAD::vector<scalar>&    tx ,
-          // ty [ i * (q+1) + k ] is y_i^k
-          CppAD::vector<scalar>&          ty
-     )
-     {     size_t n_order = q + 1;
-          size_t nr      = size_t( CppAD::Integer( tx[ 0 * n_order + 0 ] ) );
-          size_t ny      = nr * nr;
-# ifndef NDEBUG
-          size_t nx      = 1 + ny;
-# endif
-          assert( vx.size() == 0 || nx == vx.size() );
-          assert( vx.size() == 0 || ny == vy.size() );
-          assert( nx * n_order == tx.size() );
-          assert( ny * n_order == ty.size() );
-          //
-          // -------------------------------------------------------------------
-          // make sure f_arg_ and f_result_ are large enough
-          assert( f_arg_.size() == f_result_.size() );
-          if( f_arg_.size() < n_order )
-          {     f_arg_.resize(n_order);
-               f_result_.resize(n_order);
-               //
-               for(size_t k = 0; k < n_order; k++)
-               {     f_arg_[k].resize(nr, nr);
-                    f_result_[k].resize(nr, nr);
-               }
-          }
-          // -------------------------------------------------------------------
-          // unpack tx into f_arg_
-          for(size_t k = 0; k < n_order; k++)
-          {     // unpack arg values for this order
-               for(size_t i = 0; i < ny; i++)
-                    f_arg_[k].data()[i] = tx[ (1 + i) * n_order + k ];
-          }
-          // -------------------------------------------------------------------
-          // result for each order
-          // (we could avoid recalculting f_result_[k] for k=0,...,p-1)
-          //
-          f_result_[0] = f_arg_[0].inverse();
-          for(size_t k = 1; k < n_order; k++)
-          {     // initialize sum
-               matrix f_sum = matrix::Zero(nr, nr);
-               // compute sum
-               for(size_t ell = 1; ell <= k; ell++)
-                    f_sum -= f_arg_[ell] * f_result_[k-ell];
-               // result_[k] = arg_[0]^{-1} * sum_
-               f_result_[k] = f_result_[0] * f_sum;
-          }
-          // -------------------------------------------------------------------
-          // pack result_ into ty
-          for(size_t k = 0; k < n_order; k++)
-          {     for(size_t i = 0; i < ny; i++)
-                    ty[ i * n_order + k ] = f_result_[k].data()[i];
-          }
-          // -------------------------------------------------------------------
-          // check if we are computing vy
-          if( vx.size() == 0 )
-               return true;
-          // ------------------------------------------------------------------
-          // This is a very dumb algorithm that over estimates which
-          // elements of the inverse are variables (which is not efficient).
-          bool var = false;
-          for(size_t i = 0; i < ny; i++)
-               var |= vx[1 + i];
-          for(size_t i = 0; i < ny; i++)
-               vy[i] = var;
-          return true;
-     }
-
-reverse - -
     // reverse mode routine called by CppAD
-     virtual bool reverse(
-          // highest order Taylor coefficient that we are computing derivative of
-          size_t                     q ,
-          // forward mode Taylor coefficients for x variables
-          const CppAD::vector<double>&     tx ,
-          // forward mode Taylor coefficients for y variables
-          const CppAD::vector<double>&     ty ,
-          // upon return, derivative of G[ F[ {x_j^k} ] ] w.r.t {x_j^k}
-          CppAD::vector<double>&           px ,
-          // derivative of G[ {y_i^k} ] w.r.t. {y_i^k}
-          const CppAD::vector<double>&     py
-     )
-     {     size_t n_order = q + 1;
-          size_t nr      = size_t( CppAD::Integer( tx[ 0 * n_order + 0 ] ) );
-          size_t ny      = nr * nr;
-# ifndef NDEBUG
-          size_t nx      = 1 + ny;
-# endif
-          //
-          assert( nx * n_order == tx.size() );
-          assert( ny * n_order == ty.size() );
-          assert( px.size()    == tx.size() );
-          assert( py.size()    == ty.size() );
-          // -------------------------------------------------------------------
-          // make sure f_arg_ is large enough
-          assert( f_arg_.size() == f_result_.size() );
-          // must have previous run forward with order >= n_order
-          assert( f_arg_.size() >= n_order );
-          // -------------------------------------------------------------------
-          // make sure r_arg_, r_result_ are large enough
-          assert( r_arg_.size() == r_result_.size() );
-          if( r_arg_.size() < n_order )
-          {     r_arg_.resize(n_order);
-               r_result_.resize(n_order);
-               //
-               for(size_t k = 0; k < n_order; k++)
-               {     r_arg_[k].resize(nr, nr);
-                    r_result_[k].resize(nr, nr);
-               }
-          }
-          // -------------------------------------------------------------------
-          // unpack tx into f_arg_
-          for(size_t k = 0; k < n_order; k++)
-          {     // unpack arg values for this order
-               for(size_t i = 0; i < ny; i++)
-                    f_arg_[k].data()[i] = tx[ (1 + i) * n_order + k ];
-          }
-          // -------------------------------------------------------------------
-          // unpack py into r_result_
-          for(size_t k = 0; k < n_order; k++)
-          {     for(size_t i = 0; i < ny; i++)
-                    r_result_[k].data()[i] = py[ i * n_order + k ];
-          }
-          // -------------------------------------------------------------------
-          // initialize r_arg_ as zero
-          for(size_t k = 0; k < n_order; k++)
-               r_arg_[k]   = matrix::Zero(nr, nr);
-          // -------------------------------------------------------------------
-          // matrix reverse mode calculation
-          //
-          for(size_t k1 = n_order; k1 > 1; k1--)
-          {     size_t k = k1 - 1;
-               // bar{R}_0 = bar{R}_0 + bar{R}_k (A_0 R_k)^T
-               r_result_[0] +=
-               r_result_[k] * f_result_[k].transpose() * f_arg_[0].transpose();
-               //
-               for(size_t ell = 1; ell <= k; ell++)
-               {     // bar{A}_l = bar{A}_l - R_0^T bar{R}_k R_{k-l}^T
-                    r_arg_[ell] -= f_result_[0].transpose()
-                         * r_result_[k] * f_result_[k-ell].transpose();
-                    // bar{R}_{k-l} = bar{R}_{k-1} - (R_0 A_l)^T bar{R}_k
-                    r_result_[k-ell] -= f_arg_[ell].transpose()
-                         * f_result_[0].transpose() * r_result_[k];
-               }
-          }
-          r_arg_[0] -=
-          f_result_[0].transpose() * r_result_[0] * f_result_[0].transpose();
-          // -------------------------------------------------------------------
-          // pack r_arg into px
-          for(size_t k = 0; k < n_order; k++)
-          {     for(size_t i = 0; i < ny; i++)
-                    px[ (1 + i) * n_order + k ] = r_arg_[k].data()[i];
-          }
-          //
-          return true;
-     }
-
-End Class Definition - -

-}; // End of atomic_eigen_mat_inv class
-
-}  // END_EMPTY_NAMESPACE
-
- -
Input File: cppad/example/eigen_mat_inv.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_eigen_mat_inv.hpp_xml.js cppad-2019.02.00.0/doc/_atomic_eigen_mat_inv.hpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_eigen_mat_inv.hpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_eigen_mat_inv.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_mat_inv.hpp.xml' -]; -var list_down3 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down2 = [ -'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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down1 = [ -'atomic_eigen_mat_inv.hpp.xml' -]; -var list_current0 = [ -'atomic_eigen_mat_inv.hpp.xml#Purpose', -'atomic_eigen_mat_inv.hpp.xml#Matrix Dimensions', -'atomic_eigen_mat_inv.hpp.xml#Theory', -'atomic_eigen_mat_inv.hpp.xml#Theory.Forward', -'atomic_eigen_mat_inv.hpp.xml#Theory.Product of Three Matrices', -'atomic_eigen_mat_inv.hpp.xml#Theory.Reverse', -'atomic_eigen_mat_inv.hpp.xml#Start Class Definition', -'atomic_eigen_mat_inv.hpp.xml#Public', -'atomic_eigen_mat_inv.hpp.xml#Public.Types', -'atomic_eigen_mat_inv.hpp.xml#Public.Constructor', -'atomic_eigen_mat_inv.hpp.xml#Public.op', -'atomic_eigen_mat_inv.hpp.xml#Private', -'atomic_eigen_mat_inv.hpp.xml#Private.Variables', -'atomic_eigen_mat_inv.hpp.xml#Private.forward', -'atomic_eigen_mat_inv.hpp.xml#Private.reverse', -'atomic_eigen_mat_inv.hpp.xml#End Class Definition' -]; -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-2018.00.00.0/doc/atomic_eigen_mat_mul.cpp.xml cppad-2019.02.00.0/doc/atomic_eigen_mat_mul.cpp.xml --- cppad-2018.00.00.0/doc/atomic_eigen_mat_mul.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_eigen_mat_mul.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,374 +0,0 @@ - - - -Atomic Eigen Matrix Multiply: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Atomic Eigen Matrix Multiply: Example and Test
-
-Description -
-The ADFun - function object -f - for this example is - - -f -( -x -) -= -( -0 - -0 - -1 - -2 - -x -0 - - -x -1 - - -) -( -x -0 - - -x -1 - - -) -= -( -0 - -x -0 - -+ -2 -x -1 - - -x -0 - -x -0 - -+ -x -1 - -x -1 - -) - -) - - -
-Class Definition -
-This example uses the file atomic_eigen_mat_mul.hpp - -which defines matrix multiply as a atomic_base - operation. - - - -
-
-Use Atomic Function - -
# include <cppad/cppad.hpp>
-# include <cppad/example/eigen_mat_mul.hpp>
-
-bool eigen_mat_mul(void)
-{     //
-     typedef double                                            scalar;
-     typedef CppAD::AD<scalar>                                 ad_scalar;
-     typedef typename atomic_eigen_mat_mul<scalar>::ad_matrix  ad_matrix;
-     //
-     bool ok    = true;
-     scalar eps = 10. * std::numeric_limits<scalar>::epsilon();
-     using CppAD::NearEqual;
-     //
-
-Constructor - -
     // -------------------------------------------------------------------
-     // object that multiplies arbitrary matrices
-     atomic_eigen_mat_mul<scalar> mat_mul;
-     // -------------------------------------------------------------------
-     // declare independent variable vector x
-     size_t n = 2;
-     CPPAD_TESTVECTOR(ad_scalar) ad_x(n);
-     for(size_t j = 0; j < n; j++)
-          ad_x[j] = ad_scalar(j);
-     CppAD::Independent(ad_x);
-     // -------------------------------------------------------------------
-     //        [ 0     0    ]
-     // left = [ 1     2    ]
-     //        [ x[0]  x[1] ]
-     size_t nr_left  = 3;
-     size_t n_middle   = 2;
-     ad_matrix ad_left(nr_left, n_middle);
-     ad_left(0, 0) = ad_scalar(0.0);
-     ad_left(0, 1) = ad_scalar(0.0);
-     ad_left(1, 0) = ad_scalar(1.0);
-     ad_left(1, 1) = ad_scalar(2.0);
-     ad_left(2, 0) = ad_x[0];
-     ad_left(2, 1) = ad_x[1];
-     // -------------------------------------------------------------------
-     // right = [ x[0] , x[1] ]^T
-     size_t nc_right = 1;
-     ad_matrix ad_right(n_middle, nc_right);
-     ad_right(0, 0) = ad_x[0];
-     ad_right(1, 0) = ad_x[1];
-     // -------------------------------------------------------------------
-     // use atomic operation to multiply left * right
-     ad_matrix ad_result = mat_mul.op(ad_left, ad_right);
-     // -------------------------------------------------------------------
-     // check that first component of result is a parameter
-     // and the other components are varaibles.
-     ok &= Parameter( ad_result(0, 0) );
-     ok &= Variable(  ad_result(1, 0) );
-     ok &= Variable(  ad_result(2, 0) );
-     // -------------------------------------------------------------------
-     // declare the dependent variable vector y
-     size_t m = 3;
-     CPPAD_TESTVECTOR(ad_scalar) ad_y(m);
-     for(size_t i = 0; i < m; i++)
-          ad_y[i] = ad_result(i, 0);
-     CppAD::ADFun<scalar> f(ad_x, ad_y);
-     // -------------------------------------------------------------------
-     // check zero order forward mode
-     CPPAD_TESTVECTOR(scalar) x(n), y(m);
-     for(size_t i = 0; i < n; i++)
-          x[i] = scalar(i + 2);
-     y   = f.Forward(0, x);
-     ok &= NearEqual(y[0], 0.0,                       eps, eps);
-     ok &= NearEqual(y[1], x[0] + 2.0 * x[1],         eps, eps);
-     ok &= NearEqual(y[2], x[0] * x[0] + x[1] * x[1], eps, eps);
-     // -------------------------------------------------------------------
-     // check first order forward mode
-     CPPAD_TESTVECTOR(scalar) x1(n), y1(m);
-     x1[0] = 1.0;
-     x1[1] = 0.0;
-     y1    = f.Forward(1, x1);
-     ok   &= NearEqual(y1[0], 0.0,        eps, eps);
-     ok   &= NearEqual(y1[1], 1.0,        eps, eps);
-     ok   &= NearEqual(y1[2], 2.0 * x[0], eps, eps);
-     x1[0] = 0.0;
-     x1[1] = 1.0;
-     y1    = f.Forward(1, x1);
-     ok   &= NearEqual(y1[0], 0.0,        eps, eps);
-     ok   &= NearEqual(y1[1], 2.0,        eps, eps);
-     ok   &= NearEqual(y1[2], 2.0 * x[1], eps, eps);
-     // -------------------------------------------------------------------
-     // check second order forward mode
-     CPPAD_TESTVECTOR(scalar) x2(n), y2(m);
-     x2[0] = 0.0;
-     x2[1] = 0.0;
-     y2    = f.Forward(2, x2);
-     ok   &= NearEqual(y2[0], 0.0, eps, eps);
-     ok   &= NearEqual(y2[1], 0.0, eps, eps);
-     ok   &= NearEqual(y2[2], 1.0, eps, eps); // 1/2 * f_1''(x)
-     // -------------------------------------------------------------------
-     // check first order reverse mode
-     CPPAD_TESTVECTOR(scalar) w(m), d1w(n);
-     w[0]  = 0.0;
-     w[1]  = 1.0;
-     w[2]  = 0.0;
-     d1w   = f.Reverse(1, w);
-     ok   &= NearEqual(d1w[0], 1.0, eps, eps);
-     ok   &= NearEqual(d1w[1], 2.0, eps, eps);
-     w[0]  = 0.0;
-     w[1]  = 0.0;
-     w[2]  = 1.0;
-     d1w   = f.Reverse(1, w);
-     ok   &= NearEqual(d1w[0], 2.0 * x[0], eps, eps);
-     ok   &= NearEqual(d1w[1], 2.0 * x[1], eps, eps);
-     // -------------------------------------------------------------------
-     // check second order reverse mode
-     CPPAD_TESTVECTOR(scalar) d2w(2 * n);
-     d2w   = f.Reverse(2, w);
-     // partial f_2 w.r.t. x_0
-     ok   &= NearEqual(d2w[0 * 2 + 0], 2.0 * x[0], eps, eps);
-     // partial f_2 w.r.t  x_1
-     ok   &= NearEqual(d2w[1 * 2 + 0], 2.0 * x[1], eps, eps);
-     // partial f_2 w.r.t x_1, x_0
-     ok   &= NearEqual(d2w[0 * 2 + 1], 0.0,        eps, eps);
-     // partial f_2 w.r.t x_1, x_1
-     ok   &= NearEqual(d2w[1 * 2 + 1], 2.0,        eps, eps);
-     // -------------------------------------------------------------------
-     // check forward Jacobian sparsity
-     CPPAD_TESTVECTOR( std::set<size_t> ) r(n), s(m);
-     std::set<size_t> check_set;
-     for(size_t j = 0; j < n; j++)
-          r[j].insert(j);
-     s      = f.ForSparseJac(n, r);
-     check_set.clear();
-     ok    &= s[0] == check_set;
-     check_set.insert(0);
-     check_set.insert(1);
-     ok    &= s[1] == check_set;
-     ok    &= s[2] == check_set;
-     // -------------------------------------------------------------------
-     // check reverse Jacobian sparsity
-     r.resize(m);
-     for(size_t i = 0; i < m; i++)
-          r[i].insert(i);
-     s  = f.RevSparseJac(m, r);
-     check_set.clear();
-     ok    &= s[0] == check_set;
-     check_set.insert(0);
-     check_set.insert(1);
-     ok    &= s[1] == check_set;
-     ok    &= s[2] == check_set;
-     // -------------------------------------------------------------------
-     // check forward Hessian sparsity for f_2 (x)
-     CPPAD_TESTVECTOR( std::set<size_t> ) r2(1), s2(1), h(n);
-     for(size_t j = 0; j < n; j++)
-          r2[0].insert(j);
-     s2[0].clear();
-     s2[0].insert(2);
-     h = f.ForSparseHes(r2, s2);
-     check_set.clear();
-     check_set.insert(0);
-     ok &= h[0] == check_set;
-     check_set.clear();
-     check_set.insert(1);
-     ok &= h[1] == check_set;
-     // -------------------------------------------------------------------
-     // check reverse Hessian sparsity for f_2 (x)
-     CPPAD_TESTVECTOR( std::set<size_t> ) s3(1);
-     s3[0].clear();
-     s3[0].insert(2);
-     h = f.RevSparseHes(n, s3);
-     check_set.clear();
-     check_set.insert(0);
-     ok &= h[0] == check_set;
-     check_set.clear();
-     check_set.insert(1);
-     ok &= h[1] == check_set;
-     // -------------------------------------------------------------------
-     return ok;
-}
- -
Input File: example/atomic/eigen_mat_mul.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_eigen_mat_mul.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_eigen_mat_mul.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_eigen_mat_mul.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_eigen_mat_mul.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_eigen_mat_mul.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down0 = [ -'atomic_eigen_mat_mul.hpp.xml' -]; -var list_current0 = [ -'atomic_eigen_mat_mul.cpp.xml#Description', -'atomic_eigen_mat_mul.cpp.xml#Class Definition', -'atomic_eigen_mat_mul.cpp.xml#Use Atomic Function', -'atomic_eigen_mat_mul.cpp.xml#Use Atomic Function.Constructor' -]; -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-2018.00.00.0/doc/atomic_eigen_mat_mul.hpp.xml cppad-2019.02.00.0/doc/atomic_eigen_mat_mul.hpp.xml --- cppad-2018.00.00.0/doc/atomic_eigen_mat_mul.hpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_eigen_mat_mul.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1167 +0,0 @@ - - - -Atomic Eigen Matrix Multiply Class - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_eigen_mat_mul.hpp - -

-
Atomic Eigen Matrix Multiply Class
-
-See Also - -
-atomic_mat_mul.hpp - - -
-
-Purpose -
-Construct an atomic operation that computes the matrix product, - - -R -= -A -× -B - - - -for any positive integers - -r - - -, - -m - - -, - -c - - -, -and any - -A - -R - -r -× -m - - - - -, - - -B - -R - -m -× -c - - - - -. - -
-
-Matrix Dimensions -
-This example puts the matrix dimensions in the atomic function arguments, -instead of the constructor -, so that they can -be different for different calls to the atomic function. -These dimensions are: - -
- - -nr_left - - - number of rows in the left matrix; i.e, - -r - - -
- - -n_middle - - - rows in the left matrix and columns in right; i.e, - -m - - -
- - -nc_right - - - number of columns in the right matrix; i.e., - -c - - - -
-
-Theory - - -
-
-Forward -
-For - -k -= -0 -, - - - -, the k-th order Taylor coefficient - - -R -k - - - - is given by - - -R -k - -= - - -= -0 - -k - - -A - - -B -k -- - - - - - -
-Product of Two Matrices -
-Suppose - -E - -¯ - - - is the derivative of the -scalar value function - -s -( -E -) - - - with respect to - -E - - -; i.e., - - -E - -¯ -i -, -j - - -= - -s - - -E -i -, -j - - - - - - -Also suppose that - -t - - - is a scalar valued argument and - - -E -( -t -) -= -C -( -t -) -D -( -t -) - - -It follows that - - -E -' -( -t -) -= -C -' -( -t -) -D -( -t -) -+ -C -( -t -) -D -' -( -t -) - - - - -( -s - -E -) -' -( -t -) -= -tr - -[ -E - -¯ -T - - -E -' -( -t -) -] - - - - -= -tr - -[ -E - -¯ -T - - -C -' -( -t -) -D -( -t -) -] -+ -tr - -[ -E - -¯ -T - - -C -( -t -) -D -' -( -t -) -] - - - - -= -tr - -[ -D -( -t -) -E - -¯ -T - - -C -' -( -t -) -] -+ -tr - -[ -E - -¯ -T - - -C -( -t -) -D -' -( -t -) -] - - - - -C - -¯ -= -E - -¯ -D -T - - - -, - -D - -¯ -= -C -T - - -E - -¯ - - -
-Reverse -
-Reverse mode eliminates - -R -k - - - - as follows: -for - - -= -0 -, - -, -k --1 - - -, - - -A - -¯ - - -= -A - -¯ - - -+ -R - -¯ -k - -B -k -- - - -T - - - - - - -B - -¯ -k -- - - - -= -B - -¯ -k -- - - - -+ -A - -T - - -R - -¯ -k - - - -
-Start Class Definition - -
# include <cppad/cppad.hpp>
-# include <Eigen/Core>
-
-
-Public - - -
-
-Types - -
namespace { // BEGIN_EMPTY_NAMESPACE
-
-template <class Base>
-class atomic_eigen_mat_mul : public CppAD::atomic_base<Base> {
-public:
-     // -----------------------------------------------------------
-     // type of elements during calculation of derivatives
-     typedef Base              scalar;
-     // type of elements during taping
-     typedef CppAD::AD<scalar> ad_scalar;
-     // type of matrix during calculation of derivatives
-     typedef Eigen::Matrix<
-          scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>     matrix;
-     // type of matrix during taping
-     typedef Eigen::Matrix<
-          ad_scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ad_matrix;
-
-Constructor - -
     // constructor
-     atomic_eigen_mat_mul(void) : CppAD::atomic_base<Base>(
-          "atom_eigen_mat_mul"                             ,
-          CppAD::atomic_base<Base>::set_sparsity_enum
-     )
-     { }
-
-op - -
     // use atomic operation to multiply two AD matrices
-     ad_matrix op(
-          const ad_matrix&              left    ,
-          const ad_matrix&              right   )
-     {     size_t  nr_left   = size_t( left.rows() );
-          size_t  n_middle  = size_t( left.cols() );
-          size_t  nc_right  = size_t( right.cols() );
-          assert( n_middle  == size_t( right.rows() )  );
-          size_t  nx      = 3 + (nr_left + nc_right) * n_middle;
-          size_t  ny      = nr_left * nc_right;
-          size_t n_left   = nr_left * n_middle;
-          size_t n_right  = n_middle * nc_right;
-          size_t n_result = nr_left * nc_right;
-          //
-          assert( 3 + n_left + n_right == nx );
-          assert( n_result == ny );
-          // -----------------------------------------------------------------
-          // packed version of left and right
-          CPPAD_TESTVECTOR(ad_scalar) packed_arg(nx);
-          //
-          packed_arg[0] = ad_scalar( nr_left );
-          packed_arg[1] = ad_scalar( n_middle );
-          packed_arg[2] = ad_scalar( nc_right );
-          for(size_t i = 0; i < n_left; i++)
-               packed_arg[3 + i] = left.data()[i];
-          for(size_t i = 0; i < n_right; i++)
-               packed_arg[ 3 + n_left + i ] = right.data()[i];
-          // ------------------------------------------------------------------
-          // Packed version of result = left * right.
-          // This as an atomic_base funciton call that CppAD uses
-          // to store the atomic operation on the tape.
-          CPPAD_TESTVECTOR(ad_scalar) packed_result(ny);
-          (*this)(packed_arg, packed_result);
-          // ------------------------------------------------------------------
-          // unpack result matrix
-          ad_matrix result(nr_left, nc_right);
-          for(size_t i = 0; i < n_result; i++)
-               result.data()[i] = packed_result[ i ];
-          //
-          return result;
-     }
-
-Private - - -
-
-Variables - -
private:
-     // -------------------------------------------------------------
-     // one forward mode vector of matrices for left, right, and result
-     CppAD::vector<matrix> f_left_, f_right_, f_result_;
-     // one reverse mode vector of matrices for left, right, and result
-     CppAD::vector<matrix> r_left_, r_right_, r_result_;
-     // -------------------------------------------------------------
-
-forward - -
     // forward mode routine called by CppAD
-     virtual bool forward(
-          // lowest order Taylor coefficient we are evaluating
-          size_t                          p ,
-          // highest order Taylor coefficient we are evaluating
-          size_t                          q ,
-          // which components of x are variables
-          const CppAD::vector<bool>&      vx ,
-          // which components of y are variables
-          CppAD::vector<bool>&            vy ,
-          // tx [ 3 + j * (q+1) + k ] is x_j^k
-          const CppAD::vector<scalar>&    tx ,
-          // ty [ i * (q+1) + k ] is y_i^k
-          CppAD::vector<scalar>&          ty
-     )
-     {     size_t n_order  = q + 1;
-          size_t nr_left  = size_t( CppAD::Integer( tx[ 0 * n_order + 0 ] ) );
-          size_t n_middle = size_t( CppAD::Integer( tx[ 1 * n_order + 0 ] ) );
-          size_t nc_right = size_t( CppAD::Integer( tx[ 2 * n_order + 0 ] ) );
-# ifndef NDEBUG
-          size_t  nx        = 3 + (nr_left + nc_right) * n_middle;
-          size_t  ny        = nr_left * nc_right;
-# endif
-          //
-          assert( vx.size() == 0 || nx == vx.size() );
-          assert( vx.size() == 0 || ny == vy.size() );
-          assert( nx * n_order == tx.size() );
-          assert( ny * n_order == ty.size() );
-          //
-          size_t n_left   = nr_left * n_middle;
-          size_t n_right  = n_middle * nc_right;
-          size_t n_result = nr_left * nc_right;
-          assert( 3 + n_left + n_right == nx );
-          assert( n_result == ny );
-          //
-          // -------------------------------------------------------------------
-          // make sure f_left_, f_right_, and f_result_ are large enough
-          assert( f_left_.size() == f_right_.size() );
-          assert( f_left_.size() == f_result_.size() );
-          if( f_left_.size() < n_order )
-          {     f_left_.resize(n_order);
-               f_right_.resize(n_order);
-               f_result_.resize(n_order);
-               //
-               for(size_t k = 0; k < n_order; k++)
-               {     f_left_[k].resize(nr_left, n_middle);
-                    f_right_[k].resize(n_middle, nc_right);
-                    f_result_[k].resize(nr_left, nc_right);
-               }
-          }
-          // -------------------------------------------------------------------
-          // unpack tx into f_left and f_right
-          for(size_t k = 0; k < n_order; k++)
-          {     // unpack left values for this order
-               for(size_t i = 0; i < n_left; i++)
-                    f_left_[k].data()[i] = tx[ (3 + i) * n_order + k ];
-               //
-               // unpack right values for this order
-               for(size_t i = 0; i < n_right; i++)
-                    f_right_[k].data()[i] = tx[ ( 3 + n_left + i) * n_order + k ];
-          }
-          // -------------------------------------------------------------------
-          // result for each order
-          // (we could avoid recalculting f_result_[k] for k=0,...,p-1)
-          for(size_t k = 0; k < n_order; k++)
-          {     // result[k] = sum_ell left[ell] * right[k-ell]
-               f_result_[k] = matrix::Zero(nr_left, nc_right);
-               for(size_t ell = 0; ell <= k; ell++)
-                    f_result_[k] += f_left_[ell] * f_right_[k-ell];
-          }
-          // -------------------------------------------------------------------
-          // pack result_ into ty
-          for(size_t k = 0; k < n_order; k++)
-          {     for(size_t i = 0; i < n_result; i++)
-                    ty[ i * n_order + k ] = f_result_[k].data()[i];
-          }
-          // ------------------------------------------------------------------
-          // check if we are computing vy
-          if( vx.size() == 0 )
-               return true;
-          // ------------------------------------------------------------------
-          // compute variable information for y; i.e., vy
-          // (note that the constant zero times a variable is a constant)
-          scalar zero(0.0);
-          assert( n_order == 1 );
-          for(size_t i = 0; i < nr_left; i++)
-          {     for(size_t j = 0; j < nc_right; j++)
-               {     bool var = false;
-                    for(size_t ell = 0; ell < n_middle; ell++)
-                    {     // left information
-                         size_t index   = 3 + i * n_middle + ell;
-                         bool var_left  = vx[index];
-                         bool nz_left   = var_left | (f_left_[0](i, ell) != zero);
-                         // right information
-                         index          = 3 + n_left + ell * nc_right + j;
-                         bool var_right = vx[index];
-                         bool nz_right  = var_right | (f_right_[0](ell, j) != zero);
-                         // effect of result
-                         var |= var_left & nz_right;
-                         var |= nz_left  & var_right;
-                    }
-                    size_t index = i * nc_right + j;
-                    vy[index]    = var;
-               }
-          }
-          return true;
-     }
-
-reverse - -
     // reverse mode routine called by CppAD
-     virtual bool reverse(
-          // highest order Taylor coefficient that we are computing derivative of
-          size_t                     q ,
-          // forward mode Taylor coefficients for x variables
-          const CppAD::vector<double>&     tx ,
-          // forward mode Taylor coefficients for y variables
-          const CppAD::vector<double>&     ty ,
-          // upon return, derivative of G[ F[ {x_j^k} ] ] w.r.t {x_j^k}
-          CppAD::vector<double>&           px ,
-          // derivative of G[ {y_i^k} ] w.r.t. {y_i^k}
-          const CppAD::vector<double>&     py
-     )
-     {     size_t n_order  = q + 1;
-          size_t nr_left  = size_t( CppAD::Integer( tx[ 0 * n_order + 0 ] ) );
-          size_t n_middle = size_t( CppAD::Integer( tx[ 1 * n_order + 0 ] ) );
-          size_t nc_right = size_t( CppAD::Integer( tx[ 2 * n_order + 0 ] ) );
-# ifndef NDEBUG
-          size_t  nx        = 3 + (nr_left + nc_right) * n_middle;
-          size_t  ny        = nr_left * nc_right;
-# endif
-          //
-          assert( nx * n_order == tx.size() );
-          assert( ny * n_order == ty.size() );
-          assert( px.size() == tx.size() );
-          assert( py.size() == ty.size() );
-          //
-          size_t n_left   = nr_left * n_middle;
-          size_t n_right  = n_middle * nc_right;
-          size_t n_result = nr_left * nc_right;
-          assert( 3 + n_left + n_right == nx );
-          assert( n_result == ny );
-          // -------------------------------------------------------------------
-          // make sure f_left_, f_right_ are large enough
-          assert( f_left_.size() == f_right_.size() );
-          assert( f_left_.size() == f_result_.size() );
-          // must have previous run forward with order >= n_order
-          assert( f_left_.size() >= n_order );
-          // -------------------------------------------------------------------
-          // make sure r_left_, r_right_, and r_result_ are large enough
-          assert( r_left_.size() == r_right_.size() );
-          assert( r_left_.size() == r_result_.size() );
-          if( r_left_.size() < n_order )
-          {     r_left_.resize(n_order);
-               r_right_.resize(n_order);
-               r_result_.resize(n_order);
-               //
-               for(size_t k = 0; k < n_order; k++)
-               {     r_left_[k].resize(nr_left, n_middle);
-                    r_right_[k].resize(n_middle, nc_right);
-                    r_result_[k].resize(nr_left, nc_right);
-               }
-          }
-          // -------------------------------------------------------------------
-          // unpack tx into f_left and f_right
-          for(size_t k = 0; k < n_order; k++)
-          {     // unpack left values for this order
-               for(size_t i = 0; i < n_left; i++)
-                    f_left_[k].data()[i] = tx[ (3 + i) * n_order + k ];
-               //
-               // unpack right values for this order
-               for(size_t i = 0; i < n_right; i++)
-                    f_right_[k].data()[i] = tx[ (3 + n_left + i) * n_order + k ];
-          }
-          // -------------------------------------------------------------------
-          // unpack py into r_result_
-          for(size_t k = 0; k < n_order; k++)
-          {     for(size_t i = 0; i < n_result; i++)
-                    r_result_[k].data()[i] = py[ i * n_order + k ];
-          }
-          // -------------------------------------------------------------------
-          // initialize r_left_ and r_right_ as zero
-          for(size_t k = 0; k < n_order; k++)
-          {     r_left_[k]   = matrix::Zero(nr_left, n_middle);
-               r_right_[k]  = matrix::Zero(n_middle, nc_right);
-          }
-          // -------------------------------------------------------------------
-          // matrix reverse mode calculation
-          for(size_t k1 = n_order; k1 > 0; k1--)
-          {     size_t k = k1 - 1;
-               for(size_t ell = 0; ell <= k; ell++)
-               {     // nr x nm       = nr x nc      * nc * nm
-                    r_left_[ell]    += r_result_[k] * f_right_[k-ell].transpose();
-                    // nm x nc       = nm x nr * nr * nc
-                    r_right_[k-ell] += f_left_[ell].transpose() * r_result_[k];
-               }
-          }
-          // -------------------------------------------------------------------
-          // pack r_left and r_right int px
-          for(size_t k = 0; k < n_order; k++)
-          {     // dimensions are integer constants
-               px[ 0 * n_order + k ] = 0.0;
-               px[ 1 * n_order + k ] = 0.0;
-               px[ 2 * n_order + k ] = 0.0;
-               //
-               // pack left values for this order
-               for(size_t i = 0; i < n_left; i++)
-                    px[ (3 + i) * n_order + k ] = r_left_[k].data()[i];
-               //
-               // pack right values for this order
-               for(size_t i = 0; i < n_right; i++)
-                    px[ (3 + i + n_left) * n_order + k] = r_right_[k].data()[i];
-          }
-          //
-          return true;
-     }
-
-for_sparse_jac - -
     // forward Jacobian sparsity routine called by CppAD
-     virtual bool for_sparse_jac(
-          // number of columns in the matrix R
-          size_t                                       q ,
-          // sparsity pattern for the matrix R
-          const CppAD::vector< std::set<size_t> >&     r ,
-          // sparsity pattern for the matrix S = f'(x) * R
-          CppAD::vector< std::set<size_t> >&           s ,
-          const CppAD::vector<Base>&                   x )
-     {
-          size_t nr_left  = size_t( CppAD::Integer( x[0] ) );
-          size_t n_middle = size_t( CppAD::Integer( x[1] ) );
-          size_t nc_right = size_t( CppAD::Integer( x[2] ) );
-# ifndef NDEBUG
-          size_t  nx        = 3 + (nr_left + nc_right) * n_middle;
-          size_t  ny        = nr_left * nc_right;
-# endif
-          //
-          assert( nx == r.size() );
-          assert( ny == s.size() );
-          //
-          size_t n_left = nr_left * n_middle;
-          for(size_t i = 0; i < nr_left; i++)
-          {     for(size_t j = 0; j < nc_right; j++)
-               {     // pack index for entry (i, j) in result
-                    size_t i_result = i * nc_right + j;
-                    s[i_result].clear();
-                    for(size_t ell = 0; ell < n_middle; ell++)
-                    {     // pack index for entry (i, ell) in left
-                         size_t i_left  = 3 + i * n_middle + ell;
-                         // pack index for entry (ell, j) in right
-                         size_t i_right = 3 + n_left + ell * nc_right + j;
-                         // check if result of for this product is alwasy zero
-                         // note that x is nan for commponents that are variables
-                         bool zero = x[i_left] == Base(0.0) || x[i_right] == Base(0);
-                         if( ! zero )
-                         {     s[i_result] =
-                                   CppAD::set_union(s[i_result], r[i_left] );
-                              s[i_result] =
-                                   CppAD::set_union(s[i_result], r[i_right] );
-                         }
-                    }
-               }
-          }
-          return true;
-     }
-
-rev_sparse_jac - -
     // reverse Jacobian sparsity routine called by CppAD
-     virtual bool rev_sparse_jac(
-          // number of columns in the matrix R^T
-          size_t                                      q  ,
-          // sparsity pattern for the matrix R^T
-          const CppAD::vector< std::set<size_t> >&    rt ,
-          // sparsoity pattern for the matrix S^T = f'(x)^T * R^T
-          CppAD::vector< std::set<size_t> >&          st ,
-          const CppAD::vector<Base>&                   x )
-     {
-          size_t nr_left  = size_t( CppAD::Integer( x[0] ) );
-          size_t n_middle = size_t( CppAD::Integer( x[1] ) );
-          size_t nc_right = size_t( CppAD::Integer( x[2] ) );
-          size_t  nx        = 3 + (nr_left + nc_right) * n_middle;
-# ifndef NDEBUG
-          size_t  ny        = nr_left * nc_right;
-# endif
-          //
-          assert( nx == st.size() );
-          assert( ny == rt.size() );
-          //
-          // initialize S^T as empty
-          for(size_t i = 0; i < nx; i++)
-               st[i].clear();
-
-          // sparsity for S(x)^T = f'(x)^T * R^T
-          size_t n_left = nr_left * n_middle;
-          for(size_t i = 0; i < nr_left; i++)
-          {     for(size_t j = 0; j < nc_right; j++)
-               {     // pack index for entry (i, j) in result
-                    size_t i_result = i * nc_right + j;
-                    st[i_result].clear();
-                    for(size_t ell = 0; ell < n_middle; ell++)
-                    {     // pack index for entry (i, ell) in left
-                         size_t i_left  = 3 + i * n_middle + ell;
-                         // pack index for entry (ell, j) in right
-                         size_t i_right = 3 + n_left + ell * nc_right + j;
-                         //
-                         st[i_left]  = CppAD::set_union(st[i_left],  rt[i_result]);
-                         st[i_right] = CppAD::set_union(st[i_right], rt[i_result]);
-                    }
-               }
-          }
-          return true;
-     }
-
-for_sparse_hes - -
     virtual bool for_sparse_hes(
-          // which components of x are variables for this call
-          const CppAD::vector<bool>&                   vx,
-          // sparsity pattern for the diagonal of R
-          const CppAD::vector<bool>&                   r ,
-          // sparsity pattern for the vector S
-          const CppAD::vector<bool>&                   s ,
-          // sparsity patternfor the Hessian H(x)
-          CppAD::vector< std::set<size_t> >&           h ,
-          const CppAD::vector<Base>&                   x )
-     {
-          size_t nr_left  = size_t( CppAD::Integer( x[0] ) );
-          size_t n_middle = size_t( CppAD::Integer( x[1] ) );
-          size_t nc_right = size_t( CppAD::Integer( x[2] ) );
-          size_t  nx        = 3 + (nr_left + nc_right) * n_middle;
-# ifndef NDEBUG
-          size_t  ny        = nr_left * nc_right;
-# endif
-          //
-          assert( vx.size() == nx );
-          assert( r.size()  == nx );
-          assert( s.size()  == ny );
-          assert( h.size()  == nx );
-          //
-          // initilize h as empty
-          for(size_t i = 0; i < nx; i++)
-               h[i].clear();
-          //
-          size_t n_left = nr_left * n_middle;
-          for(size_t i = 0; i < nr_left; i++)
-          {     for(size_t j = 0; j < nc_right; j++)
-               {     // pack index for entry (i, j) in result
-                    size_t i_result = i * nc_right + j;
-                    if( s[i_result] )
-                    {     for(size_t ell = 0; ell < n_middle; ell++)
-                         {     // pack index for entry (i, ell) in left
-                              size_t i_left  = 3 + i * n_middle + ell;
-                              // pack index for entry (ell, j) in right
-                              size_t i_right = 3 + n_left + ell * nc_right + j;
-                              if( r[i_left] & r[i_right] )
-                              {     h[i_left].insert(i_right);
-                                   h[i_right].insert(i_left);
-                              }
-                         }
-                    }
-               }
-          }
-          return true;
-     }
-
-rev_sparse_hes - -
     // reverse Hessian sparsity routine called by CppAD
-     virtual bool rev_sparse_hes(
-          // which components of x are variables for this call
-          const CppAD::vector<bool>&                   vx,
-          // sparsity pattern for S(x) = g'[f(x)]
-          const CppAD::vector<bool>&                   s ,
-          // sparsity pattern for d/dx g[f(x)] = S(x) * f'(x)
-          CppAD::vector<bool>&                         t ,
-          // number of columns in R, U(x), and V(x)
-          size_t                                       q ,
-          // sparsity pattern for R
-          const CppAD::vector< std::set<size_t> >&     r ,
-          // sparsity pattern for U(x) = g^{(2)} [ f(x) ] * f'(x) * R
-          const CppAD::vector< std::set<size_t> >&     u ,
-          // sparsity pattern for
-          // V(x) = f'(x)^T * U(x) + sum_{i=0}^{m-1} S_i(x) f_i^{(2)} (x) * R
-          CppAD::vector< std::set<size_t> >&           v ,
-          // parameters as integers
-          const CppAD::vector<Base>&                   x )
-     {
-          size_t nr_left  = size_t( CppAD::Integer( x[0] ) );
-          size_t n_middle = size_t( CppAD::Integer( x[1] ) );
-          size_t nc_right = size_t( CppAD::Integer( x[2] ) );
-          size_t  nx        = 3 + (nr_left + nc_right) * n_middle;
-# ifndef NDEBUG
-          size_t  ny        = nr_left * nc_right;
-# endif
-          //
-          assert( vx.size() == nx );
-          assert( s.size()  == ny );
-          assert( t.size()  == nx );
-          assert( r.size()  == nx );
-          assert( v.size()  == nx );
-          //
-          // initilaize return sparsity patterns as false
-          for(size_t j = 0; j < nx; j++)
-          {     t[j] = false;
-               v[j].clear();
-          }
-          //
-          size_t n_left = nr_left * n_middle;
-          for(size_t i = 0; i < nr_left; i++)
-          {     for(size_t j = 0; j < nc_right; j++)
-               {     // pack index for entry (i, j) in result
-                    size_t i_result = i * nc_right + j;
-                    for(size_t ell = 0; ell < n_middle; ell++)
-                    {     // pack index for entry (i, ell) in left
-                         size_t i_left  = 3 + i * n_middle + ell;
-                         // pack index for entry (ell, j) in right
-                         size_t i_right = 3 + n_left + ell * nc_right + j;
-                         //
-                         // back propagate T(x) = S(x) * f'(x).
-                         t[i_left]  |= bool( s[i_result] );
-                         t[i_right] |= bool( s[i_result] );
-                         //
-                         // V(x) = f'(x)^T * U(x) +  sum_i S_i(x) * f_i''(x) * R
-                         // U(x)   = g''[ f(x) ] * f'(x) * R
-                         // S_i(x) = g_i'[ f(x) ]
-                         //
-                         // back propagate f'(x)^T * U(x)
-                         v[i_left]  = CppAD::set_union(v[i_left],  u[i_result] );
-                         v[i_right] = CppAD::set_union(v[i_right], u[i_result] );
-                         //
-                         // back propagate S_i(x) * f_i''(x) * R
-                         // (here is where we use vx to check for cross terms)
-                         if( s[i_result] & vx[i_left] & vx[i_right] )
-                         {     v[i_left]  = CppAD::set_union(v[i_left],  r[i_right] );
-                              v[i_right] = CppAD::set_union(v[i_right], r[i_left]  );
-                         }
-                    }
-               }
-          }
-          return true;
-     }
-
-End Class Definition - -

-}; // End of atomic_eigen_mat_mul class
-
-}  // END_EMPTY_NAMESPACE
-
- -
Input File: cppad/example/eigen_mat_mul.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_eigen_mat_mul.hpp_xml.js cppad-2019.02.00.0/doc/_atomic_eigen_mat_mul.hpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_eigen_mat_mul.hpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_eigen_mat_mul.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_mul.hpp.xml' -]; -var list_down3 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down2 = [ -'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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down1 = [ -'atomic_eigen_mat_mul.hpp.xml' -]; -var list_current0 = [ -'atomic_eigen_mat_mul.hpp.xml#See Also', -'atomic_eigen_mat_mul.hpp.xml#Purpose', -'atomic_eigen_mat_mul.hpp.xml#Matrix Dimensions', -'atomic_eigen_mat_mul.hpp.xml#Theory', -'atomic_eigen_mat_mul.hpp.xml#Theory.Forward', -'atomic_eigen_mat_mul.hpp.xml#Theory.Product of Two Matrices', -'atomic_eigen_mat_mul.hpp.xml#Theory.Reverse', -'atomic_eigen_mat_mul.hpp.xml#Start Class Definition', -'atomic_eigen_mat_mul.hpp.xml#Public', -'atomic_eigen_mat_mul.hpp.xml#Public.Types', -'atomic_eigen_mat_mul.hpp.xml#Public.Constructor', -'atomic_eigen_mat_mul.hpp.xml#Public.op', -'atomic_eigen_mat_mul.hpp.xml#Private', -'atomic_eigen_mat_mul.hpp.xml#Private.Variables', -'atomic_eigen_mat_mul.hpp.xml#Private.forward', -'atomic_eigen_mat_mul.hpp.xml#Private.reverse', -'atomic_eigen_mat_mul.hpp.xml#Private.for_sparse_jac', -'atomic_eigen_mat_mul.hpp.xml#Private.rev_sparse_jac', -'atomic_eigen_mat_mul.hpp.xml#Private.for_sparse_hes', -'atomic_eigen_mat_mul.hpp.xml#Private.rev_sparse_hes', -'atomic_eigen_mat_mul.hpp.xml#End Class Definition' -]; -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-2018.00.00.0/doc/atomic_for_sparse_hes.cpp.xml cppad-2019.02.00.0/doc/atomic_for_sparse_hes.cpp.xml --- cppad-2018.00.00.0/doc/atomic_for_sparse_hes.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_for_sparse_hes.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,505 +0,0 @@ - - - -Atomic Forward Hessian Sparsity: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_for_sparse_hes.cpp - -

-
Atomic Forward Hessian Sparsity: Example and Test
-
-Purpose -
-This example demonstrates calculation of the forward Hessian sparsity pattern -for an atomic operation. - -
-
-function -
-For this example, the atomic function - - -f -: -R - -3 - - -R - -2 - - - - is defined by - - -f -( -x -) -= -( -x -2 - -* -x -2 - - -x -0 - -* -x -1 - - -) - - -The Hessians of the component functions are - - -f -0 -( -2 -) - - -( -x -) -= -( -0 - -0 - -0 - -0 - -0 - -0 - -0 - -0 - -2 - -) - -, - -f -1 -( -2 -) - - -( -x -) -= -( -0 - -1 - -0 - -1 - -0 - -0 - -0 - -0 - -0 - -) - - -
-Start Class Definition - -
# include <cppad/cppad.hpp>
-namespace {          // isolate items below to this file
-using CppAD::vector; // abbreviate as vector
-//
-class atomic_for_sparse_hes : public CppAD::atomic_base<double> {
-
-Constructor - -
public:
-     // constructor (could use const char* for name)
-     atomic_for_sparse_hes(const std::string& name) :
-     // this example only uses pack sparsity patterns
-     CppAD::atomic_base<double>(name, pack_sparsity_enum)
-     { }
-private:
-
-forward - -
     // forward mode routine called by CppAD
-     virtual bool forward(
-          size_t                    p ,
-          size_t                    q ,
-          const vector<bool>&      vx ,
-          vector<bool>&            vy ,
-          const vector<double>&    tx ,
-          vector<double>&          ty
-     )
-     {
-# ifndef NDEBUG
-          size_t n = tx.size() / (q + 1);
-          size_t m = ty.size() / (q + 1);
-# endif
-          assert( n == 3 );
-          assert( m == 2 );
-
-          // return flag
-          bool ok = q == 0;
-          if( ! ok )
-               return ok;
-
-          // check for defining variable information
-          // This case must always be implemented
-          if( vx.size() > 0 )
-          {     vy[0] = vx[0];
-               vy[1] = vx[0] || vy[0];
-          }
-
-          // Order zero forward mode.
-          // This case must always be implemented
-          // f(x) = [ x_0 * x_0 ]
-          //        [ x_0 * x_1 ]
-          assert( p <= 0 );
-          if( p <= 0 )
-          {     ty[0] = tx[2] * tx[2];
-               ty[1] = tx[0] * tx[1];
-          }
-          return ok;
-     }
-
-for_sparse_jac - -
     // forward Jacobian sparsity routine called by CppAD
-     virtual bool for_sparse_jac(
-          size_t                     q ,
-          const CppAD::vectorBool&   r ,
-          CppAD::vectorBool&         s ,
-          const vector<double>&      x )
-     {     // This function needed because we are using ForSparseHes
-          // with afun.option( CppAD::atomic_base<double>::pack_sparsity_enum )
-# ifndef NDEBUG
-          size_t n = r.size() / q;
-          size_t m = s.size() / q;
-# endif
-          assert( x.size() == n );
-          assert( n == 3 );
-          assert( m == 2 );
-
-
-          // f'(x) = [   0,   0, 2 x_2 ]
-          //         [ x_1, x_0,     0 ]
-
-          // sparsity for first row of S(x) = f'(x) * R
-          size_t i = 0;
-          for(size_t j = 0; j < q; j++)
-               s[ i * q + j ] = r[ 2 * q + j ];
-
-          // sparsity for second row of S(x) = f'(x) * R
-          i = 1;
-          for(size_t j = 0; j < q; j++)
-               s[ i * q + j ] = r[ 0 * q + j ] | r[ 1 * q + j];
-
-          return true;
-     }
-
-rev_sparse_jac - -
     // reverse Jacobian sparsity routine called by CppAD
-     virtual bool rev_sparse_jac(
-          size_t                     q  ,
-          const CppAD::vectorBool&   rt ,
-          CppAD::vectorBool&         st ,
-          const vector<double>&      x  )
-     {     // This function needed because we are using ForSparseHes
-          // with afun.option( CppAD::atomic_base<double>::pack_sparsity_enum )
-# ifndef NDEBUG
-          size_t m = rt.size() / q;
-          size_t n = st.size() / q;
-# endif
-          assert( x.size() == n );
-          assert( n == 3 );
-          assert( m == 2 );
-
-          //           [     0,  x_1 ]
-          // f'(x)^T = [     0,  x_0 ]
-          //           [ 2 x_2,    0 ]
-
-          // sparsity for first row of S(x)^T = f'(x)^T * R^T
-          size_t i = 0;
-          for(size_t j = 0; j < q; j++)
-               st[ i * q + j ] = rt[ 1 * q + j ];
-
-          // sparsity for second row of S(x)^T = f'(x)^T * R^T
-          i = 1;
-          for(size_t j = 0; j < q; j++)
-               st[ i * q + j ] = rt[ 1 * q + j ];
-
-          // sparsity for third row of S(x)^T = f'(x)^T * R^T
-          i = 2;
-          for(size_t j = 0; j < q; j++)
-               st[ i * q + j ] = rt[ 0 * q + j ];
-
-          return true;
-     }
-
-for_sparse_hes - -
     // forward Hessian sparsity routine called by CppAD
-     virtual bool for_sparse_hes(
-          const vector<bool>&   vx,
-          const vector<bool>&   r ,
-          const vector<bool>&   s ,
-          CppAD::vectorBool&    h ,
-          const vector<double>& x )
-     {     // This function needed because we are using RevSparseHes
-          // with afun.option( CppAD::atomic_base<double>::pack_sparsity_enum )
-          size_t n = r.size();
-# ifndef NDEBUG
-          size_t m = s.size();
-# endif
-          assert( x.size() == n );
-          assert( n == 3 );
-          assert( m == 2 );
-          assert( h.size() == n * n );
-
-          //            [ 0 , 0 , 0 ]                  [ 0 , 1 , 0 ]
-          // f_0''(x) = [ 0 , 0 , 0 ]  f_1^{(2)} (x) = [ 1 , 0 , 0 ]
-          //            [ 0 , 0 , 2 ]                  [ 0 , 0 , 0 ]
-
-          // initial entire matrix as false
-          for(size_t i = 0; i < n * n; i++)
-               h[i] = false;
-
-          // component (2, 2)
-          h[ 2 * n + 2 ] = s[0] & r[2];
-
-          // components (1, 0) and (0, 1)
-          h[ 1 * n + 0 ] = s[1] & r[0] & r[1];
-          h[ 0 * n + 1 ] = s[1] & r[0] & r[1];
-
-          return true;
-     }
-}; // End of atomic_for_sparse_hes class
-
-Use Atomic Function - -
bool use_atomic_for_sparse_hes(bool x_1_variable)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-     //
-     // Create the atomic for_sparse_hes object
-     atomic_for_sparse_hes afun("atomic_for_sparse_hes");
-     //
-     // Create the function f(u)
-     //
-     // domain space vector
-     size_t n  = 3;
-     double x_0 = 1.00;
-     double x_1 = 2.00;
-     double x_2 = 3.00;
-     vector< AD<double> > au(n);
-     au[0] = x_0;
-     au[1] = x_1;
-     au[2] = x_2;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(au);
-
-     // range space vector
-     size_t m = 2;
-     vector< AD<double> > ay(m);
-
-     // call user function
-     vector< AD<double> > ax(n);
-     ax[0] = au[0];
-     ax[2] = au[2];
-     if( x_1_variable )
-          ax[1] = au[1];
-     else
-          ax[1] = x_1;
-     afun(ax, ay);          // y = [ x_2 * x_2 ,  x_0 * x_1 ]^T
-
-     // create f: u -> y and stop tape recording
-     CppAD::ADFun<double> f;
-     f.Dependent (au, ay);  // f(u) = y
-     //
-     // check function value
-     double check = x_2 * x_2;
-     ok &= NearEqual( Value(ay[0]) , check,  eps, eps);
-     check = x_0 * x_1;
-     ok &= NearEqual( Value(ay[1]) , check,  eps, eps);
-
-     // check zero order forward mode
-     size_t q;
-     vector<double> xq(n), yq(m);
-     q     = 0;
-     xq[0] = x_0;
-     xq[1] = x_1;
-     xq[2] = x_2;
-     yq    = f.Forward(q, xq);
-     check = x_2 * x_2;
-     ok &= NearEqual(yq[0] , check,  eps, eps);
-     check = x_0 * x_1;
-     ok &= NearEqual(yq[1] , check,  eps, eps);
-
-     // forward sparse Hessian
-     CppAD::vectorBool r(n), s(m), h(n * n);
-     for(size_t j = 0; j < n; j++)
-          r[j] = true;
-     for(size_t i = 0; i < m; i++)
-          s[i] = true;
-     h = f.ForSparseHes(r, s);
-
-     // check result
-     CppAD::vectorBool check_h(n * n);
-     for(size_t i = 0; i < n * n; i++)
-          check_h[i] = false;
-     check_h[ 2 * n + 2 ] = true;
-     if( x_1_variable )
-     {     check_h[0 * n + 1] = true;
-          check_h[1 * n + 0] = true;
-     }
-     for(size_t i = 0; i < n * n; i++)
-          ok &= h[ i ] == check_h[ i ];
-     //
-     return ok;
-}
-}  // End empty namespace
-
-Test with x_1 Both a Variable and a Parameter - -
bool for_sparse_hes(void)
-{     bool ok = true;
-     // test with x_1 a variable
-     ok     &= use_atomic_for_sparse_hes(true);
-     // test with x_1 a parameter
-     ok     &= use_atomic_for_sparse_hes(false);
-     return ok;
-}
- -
Input File: example/atomic/for_sparse_hes.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_for_sparse_hes.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_for_sparse_hes.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_for_sparse_hes.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_for_sparse_hes.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_for_sparse_hes.xml', -'atomic_for_sparse_hes.cpp.xml' -]; -var list_down3 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down2 = [ -'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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down1 = [ -'atomic_for_sparse_hes.cpp.xml' -]; -var list_current0 = [ -'atomic_for_sparse_hes.cpp.xml#Purpose', -'atomic_for_sparse_hes.cpp.xml#function', -'atomic_for_sparse_hes.cpp.xml#Start Class Definition', -'atomic_for_sparse_hes.cpp.xml#Constructor', -'atomic_for_sparse_hes.cpp.xml#forward', -'atomic_for_sparse_hes.cpp.xml#for_sparse_jac', -'atomic_for_sparse_hes.cpp.xml#rev_sparse_jac', -'atomic_for_sparse_hes.cpp.xml#for_sparse_hes', -'atomic_for_sparse_hes.cpp.xml#Use Atomic Function', -'atomic_for_sparse_hes.cpp.xml#Test with x_1 Both a Variable and a Parameter' -]; -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-2018.00.00.0/doc/atomic_for_sparse_hes.xml cppad-2019.02.00.0/doc/atomic_for_sparse_hes.xml --- cppad-2018.00.00.0/doc/atomic_for_sparse_hes.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_for_sparse_hes.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,384 +0,0 @@ - - - -Atomic Forward Hessian Sparsity Patterns - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Atomic Forward Hessian Sparsity Patterns
-
-Syntax - -
- -ok = afun.for_sparse_hes(vxrshx) - - -
-
-Deprecated 2016-06-27 - -
- -ok = afun.for_sparse_hes(vxrsh) - - -
-
-Purpose -
-This function is used by ForSparseHes - to compute -Hessian sparsity patterns. -If you are using ForSparseHes -, -one of the versions of this -virtual function must be defined by the -atomic_user - class. -
-
-
Given a sparsity pattern - for -a diagonal matrix - -R - -B -n -× -n - - - - -, and -a row vector - -S - -B -1 -× -m - - - - -, -this routine computes the sparsity pattern for - - -H -( -x -) -= -R -T - - -· -( -S -· -f -) -( -2 -) - - -( -x -) -· -R - - -
-Implementation -
-If you are using and ForSparseHes -, -this virtual function must be defined by the -atomic_user - class. - -
-
-vx -
-The argument -vx - has prototype - -
-     const CppAD:vector<bool>& 
vx
-
- -vx.size() == n -, and -for - -j -= -0 -, - -, -n --1 - - -, - -vx[j] - is true if and only if - -ax[j] - is a variable - -in the corresponding call to - -
-     
afun(axay)
-
-
-r -
-This argument has prototype - -
-     const CppAD:vector<bool>& 
r
-
-and is a atomic_sparsity - pattern for -the diagonal of - -R - -B -n -× -n - - - - -. - -
-
-s -
-The argument -s - has prototype - -
-     const CppAD:vector<bool>& 
s
-
-and its size is -m -. -It is a sparsity pattern for - -S - -B -1 -× -m - - - - -. - -
-
-h -
-This argument has prototype - -
-     
atomic_sparsityh
-
-The input value of its elements -are not specified (must not matter). -Upon return, -h - is a -atomic_sparsity - pattern for - - -H -( -x -) - -B -n -× -n - - - - - which is defined above. - -
-
-x - -
-The argument has prototype - -
-     const CppAD::vector<
Base>& x
-
-and size is equal to the -n -. -This is the Value - value corresponding to the parameters in the -vector ax - (when the atomic function was called). -To be specific, if - -
-     if( Parameter(
ax[i]) == true )
-          
x[i] = Value( ax[i] );
-     else
-          
x[i] = CppAD::numeric_limits<Base>::quiet_NaN();
-
-The version of this function with out the -x - argument is deprecated; -i.e., you should include the argument even if you do not use it. - - -
-
-Examples -
-The file atomic_for_sparse_hes.cpp - contains an example and test -that uses this routine. -It returns true if the test passes and false if it fails. - - -
Input File: cppad/core/atomic_base.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_for_sparse_hes_xml.js cppad-2019.02.00.0/doc/_atomic_for_sparse_hes_xml.js --- cppad-2018.00.00.0/doc/_atomic_for_sparse_hes_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_for_sparse_hes_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_for_sparse_hes.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down0 = [ -'atomic_for_sparse_hes.cpp.xml' -]; -var list_current0 = [ -'atomic_for_sparse_hes.xml#Syntax', -'atomic_for_sparse_hes.xml#Deprecated 2016-06-27', -'atomic_for_sparse_hes.xml#Purpose', -'atomic_for_sparse_hes.xml#Implementation', -'atomic_for_sparse_hes.xml#Implementation.vx', -'atomic_for_sparse_hes.xml#Implementation.r', -'atomic_for_sparse_hes.xml#Implementation.s', -'atomic_for_sparse_hes.xml#Implementation.h', -'atomic_for_sparse_hes.xml#Implementation.x', -'atomic_for_sparse_hes.xml#Examples' -]; -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-2018.00.00.0/doc/atomic_for_sparse_jac.cpp.xml cppad-2019.02.00.0/doc/atomic_for_sparse_jac.cpp.xml --- cppad-2018.00.00.0/doc/atomic_for_sparse_jac.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_for_sparse_jac.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,390 +0,0 @@ - - - -Atomic Forward Jacobian Sparsity: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_for_sparse_jac.cpp - -

-
Atomic Forward Jacobian Sparsity: Example and Test
-
-Purpose -
-This example demonstrates calculation of the forward Jacobian sparsity pattern -for an atomic operation. - -
-
-function -
-For this example, the atomic function - - -f -: -R - -3 - - -R - -2 - - - - is defined by - - -f -( -x -) -= -( -x -2 - -* -x -2 - - -x -0 - -* -x -1 - - -) - - -The corresponding Jacobian is - - -f -( -1 -) - - -( -x -) -= -( -0 - -0 - -2 -x -2 - - -x -1 - - -x -0 - - -0 - -) - - -
-Start Class Definition - -
# include <cppad/cppad.hpp>
-namespace {          // isolate items below to this file
-using CppAD::vector; // abbreviate as vector
-//
-class atomic_for_sparse_jac : public CppAD::atomic_base<double> {
-
-Constructor - -
public:
-     // constructor (could use const char* for name)
-     atomic_for_sparse_jac(const std::string& name) :
-     // this example only uses pack sparsty patterns
-     CppAD::atomic_base<double>(name, pack_sparsity_enum)
-     { }
-private:
-
-forward - -
     // forward mode routine called by CppAD
-     virtual bool forward(
-          size_t                    p ,
-          size_t                    q ,
-          const vector<bool>&      vx ,
-          vector<bool>&            vy ,
-          const vector<double>&    tx ,
-          vector<double>&          ty
-     )
-     {
-# ifndef NDEBUG
-          size_t n = tx.size() / (q + 1);
-          size_t m = ty.size() / (q + 1);
-# endif
-          assert( n == 3 );
-          assert( m == 2 );
-
-          // return flag
-          bool ok = q == 0;
-          if( ! ok )
-               return ok;
-
-          // check for defining variable information
-          // This case must always be implemented
-          if( vx.size() > 0 )
-          {     vy[0] = vx[2];
-               vy[1] = vx[0] || vx[1];
-          }
-
-          // Order zero forward mode.
-          // This case must always be implemented
-          // f(x) = [ x_2 * x_2 ]
-          //        [ x_0 * x_1 ]
-          assert( p <= 0 );
-          if( p <= 0 )
-          {     ty[0] = tx[2] * tx[2];
-               ty[1] = tx[0] * tx[1];
-          }
-          return ok;
-     }
-
-for_sparse_jac - -
     // forward Jacobian sparsity routine called by CppAD
-     virtual bool for_sparse_jac(
-          size_t                     q ,
-          const CppAD::vectorBool&   r ,
-          CppAD::vectorBool&         s ,
-          const vector<double>&      x )
-     {     // This function needed because we are using ForSparseJac
-          // with afun.option( CppAD::atomic_base<double>::pack_sparsity_enum )
-# ifndef NDEBUG
-          size_t n = r.size() / q;
-          size_t m = s.size() / q;
-# endif
-          assert( x.size() == n );
-          assert( n == 3 );
-          assert( m == 2 );
-
-          // f'(x) = [   0,   0, 2 x_2 ]
-          //         [ x_1, x_0,     0 ]
-
-          // sparsity for first row of S(x) = f'(x) * R
-          size_t i = 0;
-          for(size_t j = 0; j < q; j++)
-               s[ i * q + j ] = r[ 2 * q + j ];
-
-          // sparsity for second row of S(x) = f'(x) * R
-          i = 1;
-          for(size_t j = 0; j < q; j++)
-               s[ i * q + j ] = r[ 0 * q + j ] | r[ 1 * q + j];
-
-          return true;
-     }
-}; // End of atomic_for_sparse_jac class
-
-Use Atomic Function - -
bool use_atomic_for_sparse_jac(bool x_1_variable)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-     //
-     // Create the atomic for_sparse_jac object
-     atomic_for_sparse_jac afun("atomic_for_sparse_jac");
-     //
-     // Create the function f(u)
-     //
-     // domain space vector
-     size_t n  = 3;
-     double x_0 = 1.00;
-     double x_1 = 2.00;
-     double x_2 = 3.00;
-     vector< AD<double> > au(n);
-     au[0] = x_0;
-     au[1] = x_1;
-     au[2] = x_2;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(au);
-
-     // range space vector
-     size_t m = 2;
-     vector< AD<double> > ay(m);
-
-     // call user function
-     vector< AD<double> > ax(n);
-     ax[0] = au[0];
-     ax[2] = au[2];
-     if( x_1_variable )
-          ax[1] = au[1];
-     else
-          ax[1] = x_1;
-     afun(ax, ay);          // y = [ x_2 * x_2 ,  x_0 * x_1 ]^T
-
-     // create f: u -> y and stop tape recording
-     CppAD::ADFun<double> f;
-     f.Dependent (au, ay);  // f(u) = y
-     //
-     // check function value
-     double check = x_2 * x_2;
-     ok &= NearEqual( Value(ay[0]) , check,  eps, eps);
-     check = x_0 * x_1;
-     ok &= NearEqual( Value(ay[1]) , check,  eps, eps);
-
-     // check zero order forward mode
-     size_t q;
-     vector<double> xq(n), yq(m);
-     q     = 0;
-     xq[0] = x_0;
-     xq[1] = x_1;
-     xq[2] = x_2;
-     yq    = f.Forward(q, xq);
-     check = x_2 * x_2;
-     ok &= NearEqual(yq[0] , check,  eps, eps);
-     check = x_0 * x_1;
-     ok &= NearEqual(yq[1] , check,  eps, eps);
-
-     // forward sparse Jacobian
-     CppAD::vectorBool r(n * n), s(m * n);
-     // r = identity matrix
-     for(size_t i = 0; i < n; i++)
-          for(size_t j = 0; j < n; j++)
-               r[ i * n + j] = i == j;
-     s = f.ForSparseJac(n, r);
-
-     // check result
-     CppAD::vectorBool check_s(m * n);
-     check_s[ 0 * n + 0 ] = false;
-     check_s[ 0 * n + 1 ] = false;
-     check_s[ 0 * n + 2 ] = true;
-     check_s[ 1 * n + 0 ] = true;
-     check_s[ 1 * n + 1 ] = x_1_variable;
-     check_s[ 1 * n + 2 ] = false;
-     //
-     for(size_t i = 0; i < m * n; i++)
-          ok &= s[ i ] == check_s[ i ];
-     //
-     return ok;
-}
-}  // End empty namespace
-
-Test with x_1 Both a Variable and a Parameter - -
bool for_sparse_jac(void)
-{     bool ok = true;
-     // test with x_1 a variable
-     ok     &= use_atomic_for_sparse_jac(true);
-     // test with x_1 a parameter
-     ok     &= use_atomic_for_sparse_jac(false);
-     return ok;
-}
- -
Input File: example/atomic/for_sparse_jac.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_for_sparse_jac.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_for_sparse_jac.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_for_sparse_jac.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_for_sparse_jac.cpp_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', -'atomic.xml', -'atomic_base.xml', -'atomic_for_sparse_jac.xml', -'atomic_for_sparse_jac.cpp.xml' -]; -var list_down3 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down2 = [ -'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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down1 = [ -'atomic_for_sparse_jac.cpp.xml' -]; -var list_current0 = [ -'atomic_for_sparse_jac.cpp.xml#Purpose', -'atomic_for_sparse_jac.cpp.xml#function', -'atomic_for_sparse_jac.cpp.xml#Start Class Definition', -'atomic_for_sparse_jac.cpp.xml#Constructor', -'atomic_for_sparse_jac.cpp.xml#forward', -'atomic_for_sparse_jac.cpp.xml#for_sparse_jac', -'atomic_for_sparse_jac.cpp.xml#Use Atomic Function', -'atomic_for_sparse_jac.cpp.xml#Test with x_1 Both a Variable and a Parameter' -]; -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-2018.00.00.0/doc/atomic_for_sparse_jac.xml cppad-2019.02.00.0/doc/atomic_for_sparse_jac.xml --- cppad-2018.00.00.0/doc/atomic_for_sparse_jac.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_for_sparse_jac.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,383 +0,0 @@ - - - -Atomic Forward Jacobian Sparsity Patterns - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Atomic Forward Jacobian Sparsity Patterns
-
-Syntax - -
- -ok = afun.for_sparse_jac(qrsx)
-
-
-Deprecated 2016-06-27 - -
- -ok = afun.for_sparse_jac(qrs)
-
-
-Purpose -
-This function is used by ForSparseJac - to compute -Jacobian sparsity patterns. -For a fixed matrix - -R - -B -n -× -q - - - - -, -the Jacobian of - -f -( -x -+ -R -* -u -) - - - with respect to - -u - -B -q - - - - is - - -S -( -x -) -= -f -( -1 -) - - -( -x -) -* -R - - -Given a sparsity pattern - for - -R - - -, -for_sparse_jac computes a sparsity pattern for - -S -( -x -) - - -. - -
-
-Implementation -
-If you are using -ForSparseJac -, -ForSparseHes -, or -RevSparseHes -, -one of the versions of this -virtual function must be defined by the -atomic_user - class. - -
-
-q -
-The argument -q - has prototype - -
-     size_t 
q
-
-It specifies the number of columns in - - -R - -B -n -× -q - - - - - and the Jacobian - - -S -( -x -) - -B -m -× -q - - - - -. - -
-
-r -
-This argument has prototype - -
-     const 
atomic_sparsityr
-
-and is a atomic_sparsity - pattern for - - -R - -B -n -× -q - - - - -. - -
-
-s -
-This argument has prototype - -
-     
atomic_sparsitys
-
-The input values of its elements -are not specified (must not matter). -Upon return, -s - is a -atomic_sparsity - pattern for - - -S -( -x -) - -B -m -× -q - - - - -. - -
-
-x - -
-The argument has prototype - -
-     const CppAD::vector<
Base>& x
-
-and size is equal to the -n -. -This is the Value - value corresponding to the parameters in the -vector ax - (when the atomic function was called). -To be specific, if - -
-     if( Parameter(
ax[i]) == true )
-          
x[i] = Value( ax[i] );
-     else
-          
x[i] = CppAD::numeric_limits<Base>::quiet_NaN();
-
-The version of this function with out the -x - argument is deprecated; -i.e., you should include the argument even if you do not use it. - -
-
-ok -
-The return value -ok - has prototype - -
-     bool 
ok
-
-If it is true, the corresponding evaluation succeeded, -otherwise it failed. - - -
-
-Examples -
-The file atomic_for_sparse_jac.cpp - contains an example and test -that uses this routine. -It returns true if the test passes and false if it fails. - - -
Input File: cppad/core/atomic_base.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_for_sparse_jac_xml.js cppad-2019.02.00.0/doc/_atomic_for_sparse_jac_xml.js --- cppad-2018.00.00.0/doc/_atomic_for_sparse_jac_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_for_sparse_jac_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_for_sparse_jac.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down0 = [ -'atomic_for_sparse_jac.cpp.xml' -]; -var list_current0 = [ -'atomic_for_sparse_jac.xml#Syntax', -'atomic_for_sparse_jac.xml#Deprecated 2016-06-27', -'atomic_for_sparse_jac.xml#Purpose', -'atomic_for_sparse_jac.xml#Implementation', -'atomic_for_sparse_jac.xml#Implementation.q', -'atomic_for_sparse_jac.xml#Implementation.r', -'atomic_for_sparse_jac.xml#Implementation.s', -'atomic_for_sparse_jac.xml#Implementation.x', -'atomic_for_sparse_jac.xml#ok', -'atomic_for_sparse_jac.xml#Examples' -]; -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-2018.00.00.0/doc/atomic_forward.cpp.xml cppad-2019.02.00.0/doc/atomic_forward.cpp.xml --- cppad-2018.00.00.0/doc/atomic_forward.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_forward.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,506 +0,0 @@ - - - -Atomic Forward: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_forward.cpp - -

- - - -
Atomic Forward: Example and Test
-
-Purpose -
-This example demonstrates forward mode derivative calculation -using an atomic operation. - -
-
-function -
-For this example, the atomic function - - -f -: -R - -3 - - -R - -2 - - - - is defined by - - -f -( -x -) -= -( -x -2 - -* -x -2 - - -x -0 - -* -x -1 - - -) - - -The corresponding Jacobian is - - -f -( -1 -) - - -( -x -) -= -( -0 - -0 - -2 -x -2 - - -x -1 - - -x -0 - - -0 - -) - - -The Hessians of the component functions are - - -f -0 -( -2 -) - - -( -x -) -= -( -0 - -0 - -0 - -0 - -0 - -0 - -0 - -0 - -2 - -) - -, - -f -1 -( -2 -) - - -( -x -) -= -( -0 - -1 - -0 - -1 - -0 - -0 - -0 - -0 - -0 - -) - - -
-Start Class Definition - -
# include <cppad/cppad.hpp>
-namespace {          // isolate items below to this file
-using CppAD::vector; // abbreviate as vector
-//
-class atomic_forward : public CppAD::atomic_base<double> {
-
-Constructor - -
public:
-     // constructor (could use const char* for name)
-     atomic_forward(const std::string& name) :
-     // this example does not use sparsity patterns
-     CppAD::atomic_base<double>(name)
-     { }
-private:
-
-forward - -
     // forward mode routine called by CppAD
-     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 q1 = q + 1;
-# ifndef NDEBUG
-          size_t n = tx.size() / q1;
-          size_t m = ty.size() / q1;
-# endif
-          assert( n == 3 );
-          assert( m == 2 );
-          assert( p <= q );
-
-          // this example only implements up to second order forward mode
-          bool ok = q <= 2;
-          if( ! ok )
-               return ok;
-
-          // check for defining variable information
-          // This case must always be implemented
-          if( vx.size() > 0 )
-          {     vy[0] = vx[2];
-               vy[1] = vx[0] || vx[1];
-          }
-          // ------------------------------------------------------------------
-          // Zero forward mode.
-          // This case must always be implemented
-          // f(x) = [ x_2 * x_2 ]
-          //        [ x_0 * x_1 ]
-          // y^0  = f( x^0 )
-          if( p <= 0 )
-          {     // y_0^0 = x_2^0 * x_2^0
-               ty[0 * q1 + 0] = tx[2 * q1 + 0] * tx[2 * q1 + 0];
-               // y_1^0 = x_0^0 * x_1^0
-               ty[1 * q1 + 0] = tx[0 * q1 + 0] * tx[1 * q1 + 0];
-          }
-          if( q <= 0 )
-               return ok;
-          // ------------------------------------------------------------------
-          // First order one forward mode.
-          // This case is needed if first order forward mode is used.
-          // f'(x) = [   0,   0, 2 * x_2 ]
-          //         [ x_1, x_0,       0 ]
-          // y^1 =  f'(x^0) * x^1
-          if( p <= 1 )
-          {     // y_0^1 = 2 * x_2^0 * x_2^1
-               ty[0 * q1 + 1] = 2.0 * tx[2 * q1 + 0] * tx[2 * q1 + 1];
-               // y_1^1 = x_1^0 * x_0^1 + x_0^0 * x_1^1
-               ty[1 * q1 + 1]  = tx[1 * q1 + 0] * tx[0 * q1 + 1];
-               ty[1 * q1 + 1] += tx[0 * q1 + 0] * tx[1 * q1 + 1];
-          }
-          if( q <= 1 )
-               return ok;
-          // ------------------------------------------------------------------
-          // Second order forward mode.
-          // This case is neede if second order forwrd mode is used.
-          // f'(x) = [   0,   0, 2 x_2 ]
-          //         [ x_1, x_0,     0 ]
-          //
-          //            [ 0 , 0 , 0 ]                  [ 0 , 1 , 0 ]
-          // f_0''(x) = [ 0 , 0 , 0 ]  f_1^{(2)} (x) = [ 1 , 0 , 0 ]
-          //            [ 0 , 0 , 2 ]                  [ 0 , 0 , 0 ]
-          //
-          //  y_0^2 = x^1 * f_0''( x^0 ) x^1 / 2! + f_0'( x^0 ) x^2
-          //        = ( x_2^1 * 2.0 * x_2^1 ) / 2!
-          //        + 2.0 * x_2^0 * x_2^2
-          ty[0 * q1 + 2]  = tx[2 * q1 + 1] * tx[2 * q1 + 1];
-          ty[0 * q1 + 2] += 2.0 * tx[2 * q + 0] * tx[2 * q1 + 2];
-          //
-          //  y_1^2 = x^1 * f_1''( x^0 ) x^1 / 2! + f_1'( x^0 ) x^2
-          //        = ( x_1^1 * x_0^1 + x_0^1 * x_1^1) / 2
-          //        + x_1^0 * x_0^2 + x_0^0 + x_1^2
-          ty[1 * q1 + 2]  = tx[1 * q1 + 1] * tx[0 * q1 + 1];
-          ty[1 * q1 + 2] += tx[1 * q1 + 0] * tx[0 * q1 + 2];
-          ty[1 * q1 + 2] += tx[0 * q1 + 0] * tx[1 * q1 + 2];
-          // ------------------------------------------------------------------
-          return ok;
-     }
-};
-}  // End empty namespace
-
-Use Atomic Function - -
bool forward(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-     //
-     // Create the atomic_forward object
-     atomic_forward afun("atomic_forward");
-     //
-     // Create the function f(u)
-     //
-     // domain space vector
-     size_t n  = 3;
-     double x_0 = 1.00;
-     double x_1 = 2.00;
-     double x_2 = 3.00;
-     vector< AD<double> > au(n);
-     au[0] = x_0;
-     au[1] = x_1;
-     au[2] = x_2;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(au);
-
-     // range space vector
-     size_t m = 2;
-     vector< AD<double> > ay(m);
-
-     // call user function
-     vector< AD<double> > ax = au;
-     afun(ax, ay);
-
-     // create f: u -> y and stop tape recording
-     CppAD::ADFun<double> f;
-     f.Dependent (au, ay);  // y = f(u)
-     //
-     // check function value
-     double check = x_2 * x_2;
-     ok &= NearEqual( Value(ay[0]) , check,  eps, eps);
-     check = x_0 * x_1;
-     ok &= NearEqual( Value(ay[1]) , check,  eps, eps);
-
-     // --------------------------------------------------------------------
-     // zero order forward
-     //
-     vector<double> x0(n), y0(m);
-     x0[0] = x_0;
-     x0[1] = x_1;
-     x0[2] = x_2;
-     y0   = f.Forward(0, x0);
-     check = x_2 * x_2;
-     ok &= NearEqual(y0[0] , check,  eps, eps);
-     check = x_0 * x_1;
-     ok &= NearEqual(y0[1] , check,  eps, eps);
-     // --------------------------------------------------------------------
-     // first order forward
-     //
-     // value of Jacobian of f
-     double check_jac[] = {
-          0.0, 0.0, 2.0 * x_2,
-          x_1, x_0,       0.0
-     };
-     vector<double> x1(n), y1(m);
-     // check first order forward mode
-     for(size_t j = 0; j < n; j++)
-          x1[j] = 0.0;
-     for(size_t j = 0; j < n; j++)
-     {     // compute partial in j-th component direction
-          x1[j] = 1.0;
-          y1    = f.Forward(1, x1);
-          x1[j] = 0.0;
-          // check this direction
-          for(size_t i = 0; i < m; i++)
-               ok &= NearEqual(y1[i], check_jac[i * n + j], eps, eps);
-     }
-     // --------------------------------------------------------------------
-     // second order forward
-     //
-     // value of Hessian of f_0
-     double check_hes_0[] = {
-          0.0, 0.0, 0.0,
-          0.0, 0.0, 0.0,
-          0.0, 0.0, 2.0
-     };
-     //
-     // value of Hessian of f_1
-     double check_hes_1[] = {
-          0.0, 1.0, 0.0,
-          1.0, 0.0, 0.0,
-          0.0, 0.0, 0.0
-     };
-     vector<double> x2(n), y2(m);
-     for(size_t j = 0; j < n; j++)
-          x2[j] = 0.0;
-     // compute diagonal elements of the Hessian
-     for(size_t j = 0; j < n; j++)
-     {     // first order forward in j-th direction
-          x1[j] = 1.0;
-          f.Forward(1, x1);
-          y2 = f.Forward(2, x2);
-          // check this element of Hessian diagonal
-          ok &= NearEqual(y2[0], check_hes_0[j * n + j] / 2.0, eps, eps);
-          ok &= NearEqual(y2[1], check_hes_1[j * n + j] / 2.0, eps, eps);
-          //
-          for(size_t k = 0; k < n; k++) if( k != j )
-          {     x1[k] = 1.0;
-               f.Forward(1, x1);
-               y2 = f.Forward(2, x2);
-               //
-               // y2 = (H_jj + H_kk + H_jk + H_kj) / 2.0
-               // y2 = (H_jj + H_kk) / 2.0 + H_jk
-               //
-               double H_jj = check_hes_0[j * n + j];
-               double H_kk = check_hes_0[k * n + k];
-               double H_jk = y2[0] - (H_kk + H_jj) / 2.0;
-               ok &= NearEqual(H_jk, check_hes_0[j * n + k], eps, eps);
-               //
-               H_jj = check_hes_1[j * n + j];
-               H_kk = check_hes_1[k * n + k];
-               H_jk = y2[1] - (H_kk + H_jj) / 2.0;
-               ok &= NearEqual(H_jk, check_hes_1[j * n + k], eps, eps);
-               //
-               x1[k] = 0.0;
-          }
-          x1[j] = 0.0;
-     }
-     // --------------------------------------------------------------------
-     return ok;
-}
- -
Input File: example/atomic/forward.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_forward.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_forward.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_forward.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_forward.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_forward.xml', -'atomic_forward.cpp.xml' -]; -var list_down3 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down2 = [ -'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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down1 = [ -'atomic_forward.cpp.xml' -]; -var list_current0 = [ -'atomic_forward.cpp.xml#Purpose', -'atomic_forward.cpp.xml#function', -'atomic_forward.cpp.xml#Start Class Definition', -'atomic_forward.cpp.xml#Constructor', -'atomic_forward.cpp.xml#forward', -'atomic_forward.cpp.xml#Use Atomic Function' -]; -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-2018.00.00.0/doc/atomic_forward.xml cppad-2019.02.00.0/doc/atomic_forward.xml --- cppad-2018.00.00.0/doc/atomic_forward.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_forward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1061 +0,0 @@ - - - -Atomic Forward Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Atomic Forward Mode
-
-Syntax - -
- -ok = afun.forward(pqvxvytxty) - - -
-
-Purpose -
-This virtual function is used by atomic_afun - -to evaluate function values. -It is also used buy forward - -to compute function vales and derivatives. - -
-
-Implementation -
-This virtual function must be defined by the -atomic_user - class. -It can just return -ok == false - -(and not compute anything) for values -of -q > 0 - that are greater than those used by your -forward - mode calculations. - -
-
-p -
-The argument -p - has prototype - -
-     size_t 
p
-
-It specifies the lowest order Taylor coefficient that we are evaluating. -During calls to atomic_afun -, -p == 0 -. - -
-
-q -
-The argument -q - has prototype - -
-     size_t 
q
-
-It specifies the highest order Taylor coefficient that we are evaluating. -During calls to atomic_afun -, -q == 0 -. - -
-
-vx -
-The forward argument -vx - has prototype - -
-     const CppAD::vector<bool>& 
vx
-
-The case -vx.size() > 0 - only occurs while evaluating a call to -atomic_afun -. -In this case, - -p == q == 0 -, - -vx.size() == n -, and -for - -j -= -0 -, - -, -n --1 - - -, - -vx[j] - is true if and only if - -ax[j] - is a variable - -in the corresponding call to - -
-     
afun(axay)
-
-If -vx.size() == 0 -, -then -vy.size() == 0 - and neither of these vectors -should be used. - -
-
-vy -
-The forward argument -vy - has prototype - -
-     CppAD::vector<bool>& 
vy
-
-If -vy.size() == 0 -, it should not be used. -Otherwise, - -q == 0 - and -vy.size() == m -. -The input values of the elements of -vy - -are not specified (must not matter). -Upon return, for - -j -= -0 -, - -, -m --1 - - -, - -vy[i] - is true if and only if - -ay[i] - is a variable -(CppAD uses -vy - to reduce the necessary computations). - -
-
-tx -
-The argument -tx - has prototype - -
-     const CppAD::vector<
Base>& tx
-
-and -tx.size() == (q+1)*n -. -For - -j -= -0 -, - -, -n --1 - - - and - -k -= -0 -, - -, -q - - -, -we use the Taylor coefficient notation - - - -x -j -k - - -= - -tx -[ -j -* -( -q -+ -1 -) -+ -k -] - -X -j - -( -t -) - -= - -x -j -0 - -+ -x -j -1 - -t -1 - -+ - -+ -x -j -q - -t -q - - - - -Note that superscripts represent an index for - -x -j -k - - - - -and an exponent for - -t -k - - - -. -Also note that the Taylor coefficients for - -X -( -t -) - - - correspond -to the derivatives of - -X -( -t -) - - - at - -t -= -0 - - - in the following way: - - -x -j -k - -= -1 - -k -! - - -X -j -( -k -) - - -( -0 -) - - -
-ty -
-The argument -ty - has prototype - -
-     CppAD::vector<
Base>& ty
-
-and -tx.size() == (q+1)*m -. -Upon return, -For - -i -= -0 -, - -, -m --1 - - - and - -k -= -0 -, - -, -q - - -, - - - -Y -i - -( -t -) - -= - -f -i - -[ -X -( -t -) -] - -Y -i - -( -t -) - -= - -y -i -0 - -+ -y -i -1 - -t -1 - -+ - -+ -y -i -q - -t -q - -+ -o -( -t -q - -) - -ty -[ -i -* -( -q -+ -1 -) -+ -k -] - -= - -y -i -k - - - - -where - -o -( -t -q - -) -/ -t -q - - -0 - - - as - -t - -0 - - -. -Note that superscripts represent an index for - -y -j -k - - - - -and an exponent for - -t -k - - - -. -Also note that the Taylor coefficients for - -Y -( -t -) - - - correspond -to the derivatives of - -Y -( -t -) - - - at - -t -= -0 - - - in the following way: - - -y -j -k - -= -1 - -k -! - - -Y -j -( -k -) - - -( -0 -) - - -If - -p -> -0 - - -, -for - -i -= -0 -, - -, -m --1 - - - and - -k -= -0 -, - -, -p --1 - - -, -the input of -ty - satisfies - - -ty -[ -i -* -( -q -+ -1 -) -+ -k -] -= -y -i -k - - - -and hence the corresponding elements need not be recalculated. - -
-
-ok -
-If the required results are calculated, -ok - should be true. -Otherwise, it should be false. - -
-
-Discussion -
-For example, suppose that -q == 2 -, -and you know how to compute the function - -f -( -x -) - - -, -its first derivative - -f -( -1 -) - - -( -x -) - - -, -and it component wise Hessian - -f -i -( -2 -) - - -( -x -) - - -. -Then you can compute -ty - using the following formulas: - - - -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 -2 - - -= - -1 - -2 -! - - -Y -( -2 -) - - -( -0 -) - - -= - -1 - -2 - - -X -( -1 -) - - -( -0 -) -T - - -f -i -( -2 -) - - -( -x -0 - -) -X -( -1 -) - - -( -0 -) -+ -1 - -2 - - -f -i -( -1 -) - - -( -x -0 - -) -X -( -2 -) - - -( -0 -) - - -= - -1 - -2 - - -( -x -1 - -) -T - - -f -i -( -2 -) - - -( -x -0 - -) -x -1 - -+ -f -i -( -1 -) - - -( -x -0 - -) -x -2 - - - - -For - -i -= -0 -, - -, -m --1 - - -, and - -k -= -0 -, -1 -, -2 - - -, - - -ty -[ -i -* -( -q -+ -1 -) -+ -k -] -= -y -i -k - - - -
-Examples -
-The file atomic_forward.cpp - contains an example and test -that uses this routine. -It returns true if the test passes and false if it fails. - - -
Input File: cppad/core/atomic_base.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_forward_xml.js cppad-2019.02.00.0/doc/_atomic_forward_xml.js --- cppad-2018.00.00.0/doc/_atomic_forward_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_forward_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_forward.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down0 = [ -'atomic_forward.cpp.xml' -]; -var list_current0 = [ -'atomic_forward.xml#Syntax', -'atomic_forward.xml#Purpose', -'atomic_forward.xml#Implementation', -'atomic_forward.xml#p', -'atomic_forward.xml#q', -'atomic_forward.xml#vx', -'atomic_forward.xml#vy', -'atomic_forward.xml#tx', -'atomic_forward.xml#ty', -'atomic_forward.xml#ok', -'atomic_forward.xml#Discussion', -'atomic_forward.xml#Examples' -]; -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-2018.00.00.0/doc/atomic_get_started.cpp.xml cppad-2019.02.00.0/doc/atomic_get_started.cpp.xml --- cppad-2018.00.00.0/doc/atomic_get_started.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_get_started.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,244 +0,0 @@ - - - -Getting Started with Atomic Operations: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_get_started.cpp - -

-
Getting Started with Atomic Operations: Example and Test
-
-Purpose -
-This example demonstrates the minimal amount of information -necessary for a atomic_base - operation. - - - -
-
-Start Class Definition - -
# include <cppad/cppad.hpp>
-namespace {          // isolate items below to this file
-using CppAD::vector; // abbreviate as vector
-class atomic_get_started : public CppAD::atomic_base<double> {
-
-Constructor - -
public:
-     // constructor (could use const char* for name)
-     atomic_get_started(const std::string& name) :
-     // this example does not use any sparsity patterns
-     CppAD::atomic_base<double>(name)
-     { }
-private:
-
-forward - -
     // forward mode routine called by CppAD
-     virtual bool forward(
-          size_t                    p ,
-          size_t                    q ,
-          const vector<bool>&      vx ,
-                vector<bool>&      vy ,
-          const vector<double>&    tx ,
-                vector<double>&    ty
-     )
-     {
-# ifndef NDEBUG
-          size_t n = tx.size() / (q + 1);
-          size_t m = ty.size() / (q + 1);
-# endif
-          assert( n == 1 );
-          assert( m == 1 );
-
-          // return flag
-          bool ok = q == 0;
-          if( ! ok )
-               return ok;
-
-          // check for defining variable information
-          // This case must always be implemented
-          if( vx.size() > 0 )
-               vy[0] = vx[0];
-
-          // Order zero forward mode.
-          // This case must always be implemented
-          // y^0 = f( x^0 ) = 1 / x^0
-          double f = 1. / tx[0];
-          if( p <= 0 )
-               ty[0] = f;
-          return ok;
-     }
-
-End Class Definition - -

-}; // End of atomic_get_started class
-}  // End empty namespace
-
-
-Use Atomic Function - -
bool get_started(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-
-Constructor - -

-     // Create the atomic get_started object
-     atomic_get_started afun("atomic_get_started");
-
-
-Recording - -
     // Create the function f(x)
-     //
-     // domain space vector
-     size_t n  = 1;
-     double  x0 = 0.5;
-     vector< AD<double> > ax(n);
-     ax[0]     = x0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     vector< AD<double> > ay(m);
-
-     // call user function and store get_started(x) in au[0]
-     vector< AD<double> > au(m);
-     afun(ax, au);        // u = 1 / x
-
-     // now use AD division to invert to invert the operation
-     ay[0] = 1.0 / au[0]; // y = 1 / u = x
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f;
-     f.Dependent (ax, ay);  // f(x) = x
-
-forward - -
     // check function value
-     double check = x0;
-     ok &= NearEqual( Value(ay[0]) , check,  eps, eps);
-
-     // check zero order forward mode
-     size_t q;
-     vector<double> 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);
-
-     return ok;
-}
- -
Input File: example/atomic/get_started.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_get_started.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_get_started.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_get_started.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_get_started.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_get_started.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_current0 = [ -'atomic_get_started.cpp.xml#Purpose', -'atomic_get_started.cpp.xml#Start Class Definition', -'atomic_get_started.cpp.xml#Constructor', -'atomic_get_started.cpp.xml#forward', -'atomic_get_started.cpp.xml#End Class Definition', -'atomic_get_started.cpp.xml#Use Atomic Function', -'atomic_get_started.cpp.xml#Use Atomic Function.Constructor', -'atomic_get_started.cpp.xml#Use Atomic Function.Recording', -'atomic_get_started.cpp.xml#Use Atomic Function.forward' -]; -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-2018.00.00.0/doc/atomic_mat_mul.cpp.xml cppad-2019.02.00.0/doc/atomic_mat_mul.cpp.xml --- cppad-2018.00.00.0/doc/atomic_mat_mul.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_mat_mul.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,385 +0,0 @@ - - - -User Atomic Matrix Multiply: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
User Atomic Matrix Multiply: Example and Test
-
-See Also - -
-atomic_eigen_mat_mul.cpp - - - - -
-
-Class Definition -
-This example uses the file atomic_mat_mul.hpp - -which defines matrix multiply as a atomic_base - operation. - - - -
-
-Use Atomic Function - -
# include <cppad/cppad.hpp>
-# include <cppad/example/mat_mul.hpp>
-
-bool mat_mul(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::vector;
-     size_t i, j;
-
-Constructor - -

-     // -------------------------------------------------------------------
-     // object that multiplies  2 x 2  matrices
-     atomic_mat_mul afun;
-
-
-Recording - -
     // start recording with four independent varables
-     size_t n = 4;
-     vector<double> x(n);
-     vector< AD<double> > ax(n);
-     for(j = 0; j < n; j++)
-          ax[j] = x[j] = double(j + 1);
-     CppAD::Independent(ax);
-
-     // ------------------------------------------------------------------
-     size_t nr_left = 2;
-     size_t n_middle  = 2;
-     size_t nc_right = 2;
-     vector< AD<double> > atom_x(3 + (nr_left + nc_right) * n_middle );
-
-     // matrix dimensions
-     atom_x[0] = AD<double>( nr_left );
-     atom_x[1] = AD<double>( n_middle );
-     atom_x[2] = AD<double>( nc_right );
-
-     // left matrix
-     atom_x[3] = ax[0];  // left[0, 0] = x0
-     atom_x[4] = ax[1];  // left[0, 1] = x1
-     atom_x[5] = 5.;     // left[1, 0] = 5
-     atom_x[6] = 6.;     // left[1, 1] = 6
-
-     // right matix
-     atom_x[7] = ax[2];  // right[0, 0] = x2
-     atom_x[8] = 7.;     // right[0, 1] = 7
-     atom_x[9] = ax[3];  // right[1, 0] = x3
-     atom_x[10] = 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 ]
-     */
-     vector< AD<double> > atom_y(nr_left * nc_right);
-     afun(atom_x, atom_y);
-
-     ok &= (atom_y[0] == x[0]*x[2] + x[1]*x[3]) & Variable(atom_y[0]);
-     ok &= (atom_y[1] == x[0]*7.   + x[1]*8.  ) & Variable(atom_y[1]);
-     ok &= (atom_y[2] ==   5.*x[2] +   6.*x[3]) & Variable(atom_y[2]);
-     ok &= (atom_y[3] ==   5.*7.   +   6.*8.  ) & Parameter(atom_y[3]);
-
-     // ------------------------------------------------------------------
-     // define the function g : x -> atom_y
-     // g(x) = [ x0*x2 + x1*x3 , x0*7 + x1*8 , 5*x2  + 6*x3  , 5*7 + 6*8 ]^T
-     CppAD::ADFun<double> g(ax, atom_y);
-
-forward - -
     // Test zero order forward mode evaluation of g(x)
-     size_t m = atom_y.size();
-     vector<double> y(m);
-     for(j = 0; j <  n; j++)
-          x[j] = double(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<double> dx(n), dy(m);
-     for(j = 0; j <  n; j++)
-          dx[j] = double(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<double> ddx(n), ddy(m);
-     for(j = 0; j <  n; 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.;
-
-reverse - -
     // Test second order reverse mode
-     CppAD::vector<double> w(m), dw(2 * n);
-     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.;
-
-option - -
     //----------------------------------------------------------------------
-     // Test both the boolean and set sparsity at the atomic level
-     for(size_t sparse_index = 0; sparse_index < 2; sparse_index++)
-     {     if( sparse_index == 0 )
-               afun.option( CppAD::atomic_base<double>::bool_sparsity_enum );
-          else     afun.option( CppAD::atomic_base<double>::set_sparsity_enum );
-
-for_sparse_jac - -
     // Test forward Jacobian sparsity pattern
-     /*
-     g(x) = [ x0*x2 + x1*x3 , x0*7 + x1*8 , 5*x2  + 6*x3  , 5*7 + 6*8 ]^T
-     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<size_t> > r(n), s(m);
-     for(j = 0; j <  n; j++)
-     {     assert( r[j].empty() );
-          r[j].insert(j);
-     }
-     s = g.ForSparseJac(n, r);
-     for(j = 0; j <  n; 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();
-
-rev_sparse_jac - -
     // Test reverse Jacobian sparsity pattern
-     for(i = 0; i <  m; i++)
-     {     s[i].clear();
-          s[i].insert(i);
-     }
-     r = g.RevSparseJac(m, s);
-     for(j = 0; j <  n ; 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();
-
-rev_sparse_hes - -
     /* 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<size_t> > h(n), t(1);
-     t[0].clear();
-     t[0].insert(0);
-     h = g.RevSparseHes(n, t);
-     size_t check[] = {2, 3, 0, 1};
-     for(j = 0; j <  n; 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 < n; j++)
-               t[0].insert(j);
-     h = g.RevSparseHes(n, t);
-     for(j = 0; j <  n; j++)
-     {     // h[j] = { }
-          for(i = 0; i < n; i++)
-               ok &= h[j].find(i) == h[j].end();
-     }
-
-     //-----------------------------------------------------------------
-     } // end for(size_t sparse_index  ...
-     //-----------------------------------------------------------------
-
-     return ok;
-}
- -
Input File: example/atomic/mat_mul.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_mat_mul.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_mat_mul.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_mat_mul.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_mat_mul.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_mat_mul.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down0 = [ -'atomic_mat_mul.hpp.xml' -]; -var list_current0 = [ -'atomic_mat_mul.cpp.xml#See Also', -'atomic_mat_mul.cpp.xml#Class Definition', -'atomic_mat_mul.cpp.xml#Use Atomic Function', -'atomic_mat_mul.cpp.xml#Use Atomic Function.Constructor', -'atomic_mat_mul.cpp.xml#Use Atomic Function.Recording', -'atomic_mat_mul.cpp.xml#Use Atomic Function.forward', -'atomic_mat_mul.cpp.xml#Use Atomic Function.reverse', -'atomic_mat_mul.cpp.xml#Use Atomic Function.option', -'atomic_mat_mul.cpp.xml#Use Atomic Function.for_sparse_jac', -'atomic_mat_mul.cpp.xml#Use Atomic Function.rev_sparse_jac', -'atomic_mat_mul.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-2018.00.00.0/doc/atomic_mat_mul.hpp.xml cppad-2019.02.00.0/doc/atomic_mat_mul.hpp.xml --- cppad-2018.00.00.0/doc/atomic_mat_mul.hpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_mat_mul.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,794 +0,0 @@ - - - -Matrix Multiply as an Atomic Operation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_mat_mul.hpp - -

-
Matrix Multiply as an Atomic Operation
-
-See Also - -
-atomic_eigen_mat_mul.hpp - - -
-
-Matrix Dimensions -
-This example puts the matrix dimensions in the atomic function arguments, -instead of the constructor -, so that they can -be different for different calls to the atomic function. -These dimensions are: - -
- - -nr_left - - number of rows in the left matrix
- - -n_middle - - rows in the left matrix and columns in right
- - -nc_right - - number of columns in the right matrix -
-
-Start Class Definition - -
# include <cppad/cppad.hpp>
-namespace { // Begin empty namespace
-using CppAD::vector;
-//
-using CppAD::set_union;
-//
-// matrix result = left * right
-class atomic_mat_mul : public CppAD::atomic_base<double> {
-
-Constructor - -
public:
-     // ---------------------------------------------------------------------
-     // constructor
-     atomic_mat_mul(void) : CppAD::atomic_base<double>("mat_mul")
-     { }
-private:
-
-Left Operand Element Index -
-Index in the Taylor coefficient matrix -tx - of a left matrix element. -
     size_t left(
-          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 nr_left  , // rows in left matrix
-          size_t n_middle , // rows in left and columns in right
-          size_t nc_right ) // columns in right matrix
-     {     assert( i < nr_left );
-          assert( j < n_middle );
-          return (3 + i * n_middle + j) * nk + k;
-     }
-
-Right Operand Element Index -
-Index in the Taylor coefficient matrix -tx - of a right matrix element. -
     size_t right(
-          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 nr_left  , // rows in left matrix
-          size_t n_middle , // rows in left and columns in right
-          size_t nc_right ) // columns in right matrix
-     {     assert( i < n_middle );
-          assert( j < nc_right );
-          size_t offset = 3 + nr_left * n_middle;
-          return (offset + i * nc_right + j) * nk + k;
-     }
-
-Result Element Index -
-Index in the Taylor coefficient matrix -ty - of a result matrix element. -
     size_t result(
-          size_t i        , // result matrix row index
-          size_t j        , // result matrix column index
-          size_t k        , // Taylor coeffocient order
-          size_t nk       , // number of Taylor coefficients in ty
-          size_t nr_left  , // rows in left matrix
-          size_t n_middle , // rows in left and columns in right
-          size_t nc_right ) // columns in right matrix
-     {     assert( i < nr_left  );
-          assert( j < nc_right );
-          return (i * nc_right + j) * nk + k;
-     }
-
-Forward Matrix Multiply -
-Forward mode multiply Taylor coefficients in -tx - and sum into - -ty - (for one pair of left and right orders) -
     void forward_multiply(
-          size_t                 k_left   , // order for left coefficients
-          size_t                 k_right  , // order for right coefficients
-          const vector<double>&  tx       , // domain space Taylor coefficients
-                vector<double>&  ty       , // range space Taylor coefficients
-          size_t                 nr_left  , // rows in left matrix
-          size_t                 n_middle , // rows in left and columns in right
-          size_t                 nc_right ) // columns in right matrix
-     {
-          size_t nx       = 3 + (nr_left + nc_right) * n_middle;
-          size_t nk       = tx.size() / nx;
-# ifndef NDEBUG
-          size_t ny       = nr_left * nc_right;
-          assert( nk == ty.size() / ny );
-# endif
-          //
-          size_t k_result = k_left + k_right;
-          assert( k_result < nk );
-          //
-          for(size_t i = 0; i < nr_left; i++)
-          {     for(size_t j = 0; j < nc_right; j++)
-               {     double sum = 0.0;
-                    for(size_t ell = 0; ell < n_middle; ell++)
-                    {     size_t i_left  = left(
-                              i, ell, k_left, nk, nr_left, n_middle, nc_right
-                         );
-                         size_t i_right = right(
-                              ell, j,  k_right, nk, nr_left, n_middle, nc_right
-                         );
-                         sum           += tx[i_left] * tx[i_right];
-                    }
-                    size_t i_result = result(
-                         i, j, k_result, nk, nr_left, n_middle, nc_right
-                    );
-                    ty[i_result]   += sum;
-               }
-          }
-     }
-
-Reverse Matrix Multiply -
-Reverse mode partials of Taylor coefficients and sum into -px - -(for one pair of left and right orders) -
     void reverse_multiply(
-          size_t                 k_left  , // order for left coefficients
-          size_t                 k_right , // order for right coefficients
-          const vector<double>&  tx      , // domain space Taylor coefficients
-          const vector<double>&  ty      , // range space Taylor coefficients
-                vector<double>&  px      , // partials w.r.t. tx
-          const vector<double>&  py      , // partials w.r.t. ty
-          size_t                 nr_left  , // rows in left matrix
-          size_t                 n_middle , // rows in left and columns in right
-          size_t                 nc_right ) // columns in right matrix
-     {
-          size_t nx       = 3 + (nr_left + nc_right) * n_middle;
-          size_t nk       = tx.size() / nx;
-# ifndef NDEBUG
-          size_t ny       = nr_left * nc_right;
-          assert( nk == ty.size() / ny );
-# endif
-          assert( tx.size() == px.size() );
-          assert( ty.size() == py.size() );
-          //
-          size_t k_result = k_left + k_right;
-          assert( k_result < nk );
-          //
-          for(size_t i = 0; i < nr_left; i++)
-          {     for(size_t j = 0; j < nc_right; j++)
-               {     size_t i_result = result(
-                         i, j, k_result, nk, nr_left, n_middle, nc_right
-                    );
-                    for(size_t ell = 0; ell < n_middle; ell++)
-                    {     size_t i_left  = left(
-                              i, ell, k_left, nk, nr_left, n_middle, nc_right
-                         );
-                         size_t i_right = right(
-                              ell, j,  k_right, nk, nr_left, n_middle, nc_right
-                         );
-                         // sum        += tx[i_left] * tx[i_right];
-                         px[i_left]    += tx[i_right] * py[i_result];
-                         px[i_right]   += tx[i_left]  * py[i_result];
-                    }
-               }
-          }
-          return;
-     }
-
-forward -
-Routine called by CppAD during Forward - mode. -
     virtual bool forward(
-          size_t                    q ,
-          size_t                    p ,
-          const vector<bool>&      vx ,
-                vector<bool>&      vy ,
-          const vector<double>&    tx ,
-                vector<double>&    ty
-     )
-     {     size_t n_order  = p + 1;
-          size_t nr_left  = size_t( tx[ 0 * n_order + 0 ] );
-          size_t n_middle = size_t( tx[ 1 * n_order + 0 ] );
-          size_t nc_right = size_t( tx[ 2 * n_order + 0 ] );
-# ifndef NDEBUG
-          size_t nx       = 3 + (nr_left + nc_right) * n_middle;
-          size_t ny       = nr_left * nc_right;
-# endif
-          assert( vx.size() == 0 || nx == vx.size() );
-          assert( vx.size() == 0 || ny == vy.size() );
-          assert( nx * n_order == tx.size() );
-          assert( ny * n_order == ty.size() );
-          size_t i, j, ell;
-
-          // check if we are computing vy information
-          if( vx.size() > 0 )
-          {     size_t nk = 1;
-               size_t k  = 0;
-               for(i = 0; i < nr_left; i++)
-               {     for(j = 0; j < nc_right; j++)
-                    {     bool var = false;
-                         for(ell = 0; ell < n_middle; ell++)
-                         {     size_t i_left  = left(
-                                   i, ell, k, nk, nr_left, n_middle, nc_right
-                              );
-                              size_t i_right = right(
-                                   ell, j, k, nk, nr_left, n_middle, nc_right
-                              );
-                              bool   nz_left = vx[i_left] |(tx[i_left]  != 0.);
-                              bool  nz_right = vx[i_right]|(tx[i_right] != 0.);
-                              // if not multiplying by the constant zero
-                              if( nz_left & nz_right )
-                                        var |= bool(vx[i_left]) | bool(vx[i_right]);
-                         }
-                         size_t i_result = result(
-                              i, j, k, nk, nr_left, n_middle, nc_right
-                         );
-                         vy[i_result] = var;
-                    }
-               }
-          }
-
-          // initialize result as zero
-          size_t k;
-          for(i = 0; i < nr_left; i++)
-          {     for(j = 0; j < nc_right; j++)
-               {     for(k = q; k <= p; k++)
-                    {     size_t i_result = result(
-                              i, j, k, n_order, nr_left, n_middle, nc_right
-                         );
-                         ty[i_result] = 0.0;
-                    }
-               }
-          }
-          for(k = q; k <= p; k++)
-          {     // sum the produces that result in order k
-               for(ell = 0; ell <= k; ell++)
-                    forward_multiply(
-                         ell, k - ell, tx, ty, nr_left, n_middle, nc_right
-                    );
-          }
-
-          // all orders are implented, so always return true
-          return true;
-     }
-
-reverse -
-Routine called by CppAD during Reverse - mode. -
     virtual bool reverse(
-          size_t                     p ,
-          const vector<double>&     tx ,
-          const vector<double>&     ty ,
-                vector<double>&     px ,
-          const vector<double>&     py
-     )
-     {     size_t n_order  = p + 1;
-          size_t nr_left  = size_t( tx[ 0 * n_order + 0 ] );
-          size_t n_middle = size_t( tx[ 1 * n_order + 0 ] );
-          size_t nc_right = size_t( tx[ 2 * n_order + 0 ] );
-# ifndef NDEBUG
-          size_t nx       = 3 + (nr_left + nc_right) * n_middle;
-          size_t ny       = nr_left * nc_right;
-# endif
-          assert( nx * n_order == tx.size() );
-          assert( ny * n_order == ty.size() );
-          assert( px.size() == tx.size() );
-          assert( py.size() == ty.size() );
-
-          // initialize summation
-          for(size_t i = 0; i < px.size(); i++)
-               px[i] = 0.0;
-
-          // number of orders to differentiate
-          size_t k = n_order;
-          while(k--)
-          {     // differentiate the produces that result in order k
-               for(size_t ell = 0; ell <= k; ell++)
-                    reverse_multiply(
-                         ell, k - ell, tx, ty, px, py, nr_left, n_middle, nc_right
-                    );
-          }
-
-          // all orders are implented, so always return true
-          return true;
-     }
-
-for_sparse_jac -
-Routines called by CppAD during ForSparseJac -. -
     // boolean sparsity patterns
-     virtual bool for_sparse_jac(
-          size_t                                q ,
-          const vector<bool>&                   r ,
-                vector<bool>&                   s ,
-          const vector<double>&                 x )
-     {
-          size_t nr_left  = size_t( CppAD::Integer( x[0] ) );
-          size_t n_middle = size_t( CppAD::Integer( x[1] ) );
-          size_t nc_right = size_t( CppAD::Integer( x[2] ) );
-# ifndef NDEBUG
-          size_t  nx      = 3 + (nr_left + nc_right) * n_middle;
-          size_t  ny      = nr_left * nc_right;
-# endif
-          assert( nx     == x.size() );
-          assert( nx * q == r.size() );
-          assert( ny * q == s.size() );
-          size_t p;
-
-          // sparsity for S(x) = f'(x) * R
-          size_t nk = 1;
-          size_t k  = 0;
-          for(size_t i = 0; i < nr_left; i++)
-          {     for(size_t j = 0; j < nc_right; j++)
-               {     size_t i_result = result(
-                         i, j, k, nk, nr_left, n_middle, nc_right
-                    );
-                    for(p = 0; p < q; p++)
-                         s[i_result * q + p] = false;
-                    for(size_t ell = 0; ell < n_middle; ell++)
-                    {     size_t i_left  = left(
-                              i, ell, k, nk, nr_left, n_middle, nc_right
-                         );
-                         size_t i_right = right(
-                              ell, j, k, nk, nr_left, n_middle, nc_right
-                         );
-                         for(p = 0; p < 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 ] );
-                         }
-                    }
-               }
-          }
-          return true;
-     }
-     // set sparsity patterns
-     virtual bool for_sparse_jac(
-          size_t                                q ,
-          const vector< std::set<size_t> >&     r ,
-                vector< std::set<size_t> >&     s ,
-          const vector<double>&                 x )
-     {
-          size_t nr_left  = size_t( CppAD::Integer( x[0] ) );
-          size_t n_middle = size_t( CppAD::Integer( x[1] ) );
-          size_t nc_right = size_t( CppAD::Integer( x[2] ) );
-# ifndef NDEBUG
-          size_t  nx      = 3 + (nr_left + nc_right) * n_middle;
-          size_t  ny      = nr_left * nc_right;
-# endif
-          assert( nx == x.size() );
-          assert( nx == r.size() );
-          assert( ny == s.size() );
-
-          // sparsity for S(x) = f'(x) * R
-          size_t nk = 1;
-          size_t k  = 0;
-          for(size_t i = 0; i < nr_left; i++)
-          {     for(size_t j = 0; j < nc_right; j++)
-               {     size_t i_result = result(
-                         i, j, k, nk, nr_left, n_middle, nc_right
-                    );
-                    s[i_result].clear();
-                    for(size_t ell = 0; ell < n_middle; ell++)
-                    {     size_t i_left  = left(
-                              i, ell, k, nk, nr_left, n_middle, nc_right
-                         );
-                         size_t i_right = right(
-                              ell, j, k, nk, nr_left, n_middle, nc_right
-                         );
-                         //
-                         s[i_result] = set_union(s[i_result], r[i_left] );
-                         s[i_result] = set_union(s[i_result], r[i_right] );
-                    }
-               }
-          }
-          return true;
-     }
-
-rev_sparse_jac -
-Routines called by CppAD during RevSparseJac -. -
     // boolean sparsity patterns
-     virtual bool rev_sparse_jac(
-          size_t                                q ,
-          const vector<bool>&                  rt ,
-                vector<bool>&                  st ,
-          const vector<double>&                 x )
-     {
-          size_t nr_left  = size_t( CppAD::Integer( x[0] ) );
-          size_t n_middle = size_t( CppAD::Integer( x[1] ) );
-          size_t nc_right = size_t( CppAD::Integer( x[2] ) );
-          size_t  nx      = 3 + (nr_left + nc_right) * n_middle;
-# ifndef NDEBUG
-          size_t  ny      = nr_left * nc_right;
-# endif
-          assert( nx     == x.size() );
-          assert( nx * q == st.size() );
-          assert( ny * q == rt.size() );
-          size_t i, j, p;
-
-          // initialize
-          for(i = 0; i < nx; i++)
-          {     for(p = 0; p < q; p++)
-                    st[ i * q + p ] = false;
-          }
-
-          // sparsity for S(x)^T = f'(x)^T * R^T
-          size_t nk = 1;
-          size_t k  = 0;
-          for(i = 0; i < nr_left; i++)
-          {     for(j = 0; j < nc_right; j++)
-               {     size_t i_result = result(
-                         i, j, k, nk, nr_left, n_middle, nc_right
-                    );
-                    for(size_t ell = 0; ell < n_middle; ell++)
-                    {     size_t i_left  = left(
-                              i, ell, k, nk, nr_left, n_middle, nc_right
-                         );
-                         size_t i_right = right(
-                              ell, j, k, nk, nr_left, n_middle, nc_right
-                         );
-                         for(p = 0; p < q; p++)
-                         {     st[i_left * q + p] |= bool( rt[i_result * q + p] );
-                              st[i_right* q + p] |= bool( rt[i_result * q + p] );
-                         }
-                    }
-               }
-          }
-          return true;
-     }
-     // set sparsity patterns
-     virtual bool rev_sparse_jac(
-          size_t                                q ,
-          const vector< std::set<size_t> >&    rt ,
-                vector< std::set<size_t> >&    st ,
-          const vector<double>&                 x )
-     {
-          size_t nr_left  = size_t( CppAD::Integer( x[0] ) );
-          size_t n_middle = size_t( CppAD::Integer( x[1] ) );
-          size_t nc_right = size_t( CppAD::Integer( x[2] ) );
-          size_t  nx      = 3 + (nr_left + nc_right) * n_middle;
-# ifndef NDEBUG
-          size_t  ny        = nr_left * nc_right;
-# endif
-          assert( nx == x.size() );
-          assert( nx == st.size() );
-          assert( ny == rt.size() );
-          size_t i, j;
-
-          // initialize
-          for(i = 0; i < nx; i++)
-               st[i].clear();
-
-          // sparsity for S(x)^T = f'(x)^T * R^T
-          size_t nk = 1;
-          size_t k  = 0;
-          for(i = 0; i < nr_left; i++)
-          {     for(j = 0; j < nc_right; j++)
-               {     size_t i_result = result(
-                         i, j, k, nk, nr_left, n_middle, nc_right
-                    );
-                    for(size_t ell = 0; ell < n_middle; ell++)
-                    {     size_t i_left  = left(
-                              i, ell, k, nk, nr_left, n_middle, nc_right
-                         );
-                         size_t i_right = right(
-                              ell, j, k, nk, nr_left, n_middle, nc_right
-                         );
-                         //
-                         st[i_left]  = set_union(st[i_left],  rt[i_result]);
-                         st[i_right] = set_union(st[i_right], rt[i_result]);
-                    }
-               }
-          }
-          return true;
-     }
-
-rev_sparse_hes -
-Routines called by RevSparseHes -. -
     // set sparsity patterns
-     virtual bool rev_sparse_hes(
-          const vector<bool>&                   vx,
-          const vector<bool>&                   s ,
-                vector<bool>&                   t ,
-          size_t                                q ,
-          const vector< std::set<size_t> >&     r ,
-          const vector< std::set<size_t> >&     u ,
-                vector< std::set<size_t> >&     v ,
-          const vector<double>&                 x )
-     {
-          size_t nr_left  = size_t( CppAD::Integer( x[0] ) );
-          size_t n_middle = size_t( CppAD::Integer( x[1] ) );
-          size_t nc_right = size_t( CppAD::Integer( x[2] ) );
-          size_t  nx        = 3 + (nr_left + nc_right) * n_middle;
-# ifndef NDEBUG
-          size_t  ny        = nr_left * nc_right;
-# endif
-          assert( x.size()  == nx );
-          assert( vx.size() == nx );
-          assert( t.size()  == nx );
-          assert( r.size()  == nx );
-          assert( v.size()  == nx );
-          assert( s.size()  == ny );
-          assert( u.size()  == ny );
-          //
-          size_t i, j;
-          //
-          // initilaize sparsity patterns as false
-          for(j = 0; j < nx; j++)
-          {     t[j] = false;
-               v[j].clear();
-          }
-          size_t nk = 1;
-          size_t k  = 0;
-          for(i = 0; i < nr_left; i++)
-          {     for(j = 0; j < nc_right; j++)
-               {     size_t i_result = result(
-                         i, j, k, nk, nr_left, n_middle, nc_right
-                    );
-                    for(size_t ell = 0; ell < n_middle; ell++)
-                    {     size_t i_left  = left(
-                              i, ell, k, nk, nr_left, n_middle, nc_right
-                         );
-                         size_t i_right = right(
-                              ell, j, k, nk, nr_left, n_middle, nc_right
-                         );
-                         //
-                         // Compute sparsity for T(x) = S(x) * f'(x).
-                         // We need not use vx with f'(x) back propagation.
-                         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
-                         // 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)
-                         v[i_left]  = set_union(v[i_left],  u[i_result] );
-                         v[i_right] = set_union(v[i_right], u[i_result] );
-
-                         // 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] )
-                         {     v[i_left]  = set_union(v[i_left],  r[i_right] );
-                              v[i_right] = set_union(v[i_right], r[i_left]  );
-                         }
-                    }
-               }
-          }
-          return true;
-     }
-     // bool sparsity
-     virtual bool rev_sparse_hes(
-          const vector<bool>&                   vx,
-          const vector<bool>&                   s ,
-                vector<bool>&                   t ,
-          size_t                                q ,
-          const vector<bool>&                   r ,
-          const vector<bool>&                   u ,
-                vector<bool>&                   v ,
-          const vector<double>&                 x )
-     {
-          size_t nr_left  = size_t( CppAD::Integer( x[0] ) );
-          size_t n_middle = size_t( CppAD::Integer( x[1] ) );
-          size_t nc_right = size_t( CppAD::Integer( x[2] ) );
-          size_t  nx        = 3 + (nr_left + nc_right) * n_middle;
-# ifndef NDEBUG
-          size_t  ny        = nr_left * nc_right;
-# endif
-          assert( x.size()  == nx );
-          assert( vx.size() == nx );
-          assert( t.size()  == nx );
-          assert( r.size()  == nx * q );
-          assert( v.size()  == nx * q );
-          assert( s.size()  == ny );
-          assert( u.size()  == ny * q );
-          size_t i, j, p;
-          //
-          // initilaize sparsity patterns as false
-          for(j = 0; j < nx; j++)
-          {     t[j] = false;
-               for(p = 0; p < q; p++)
-                    v[j * q + p] = false;
-          }
-          size_t nk = 1;
-          size_t k  = 0;
-          for(i = 0; i < nr_left; i++)
-          {     for(j = 0; j < nc_right; j++)
-               {     size_t i_result = result(
-                         i, j, k, nk, nr_left, n_middle, nc_right
-                    );
-                    for(size_t ell = 0; ell < n_middle; ell++)
-                    {     size_t i_left  = left(
-                              i, ell, k, nk, nr_left, n_middle, nc_right
-                         );
-                         size_t i_right = right(
-                              ell, j, k, nk, nr_left, n_middle, nc_right
-                         );
-                         //
-                         // Compute sparsity for T(x) = S(x) * f'(x).
-                         // We so not need to use vx with f'(x) propagation.
-                         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
-                         // 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] |= 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]  |= bool( r[i_right * q + p] );
-                                   v[i_right * q + p] |= bool( r[i_left * q + p] );
-                              }
-                         }
-                    }
-               }
-          }
-          return true;
-     }
-
-End Class Definition - -

-}; // End of mat_mul class
-}  // End empty namespace
-
- -
Input File: cppad/example/mat_mul.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_mat_mul.hpp_xml.js cppad-2019.02.00.0/doc/_atomic_mat_mul.hpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_mat_mul.hpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_mat_mul.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_mat_mul.cpp.xml', -'atomic_mat_mul.hpp.xml' -]; -var list_down3 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down2 = [ -'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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down1 = [ -'atomic_mat_mul.hpp.xml' -]; -var list_current0 = [ -'atomic_mat_mul.hpp.xml#See Also', -'atomic_mat_mul.hpp.xml#Matrix Dimensions', -'atomic_mat_mul.hpp.xml#Start Class Definition', -'atomic_mat_mul.hpp.xml#Constructor', -'atomic_mat_mul.hpp.xml#Left Operand Element Index', -'atomic_mat_mul.hpp.xml#Right Operand Element Index', -'atomic_mat_mul.hpp.xml#Result Element Index', -'atomic_mat_mul.hpp.xml#Forward Matrix Multiply', -'atomic_mat_mul.hpp.xml#Reverse Matrix Multiply', -'atomic_mat_mul.hpp.xml#forward', -'atomic_mat_mul.hpp.xml#reverse', -'atomic_mat_mul.hpp.xml#for_sparse_jac', -'atomic_mat_mul.hpp.xml#rev_sparse_jac', -'atomic_mat_mul.hpp.xml#rev_sparse_hes', -'atomic_mat_mul.hpp.xml#End Class Definition' -]; -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-2018.00.00.0/doc/atomic_mul_level.cpp.xml cppad-2019.02.00.0/doc/atomic_mul_level.cpp.xml --- cppad-2018.00.00.0/doc/atomic_mul_level.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_mul_level.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,189 +0,0 @@ - - - -Atomic Operations and Multiple-Levels of AD: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_mul_level.cpp - -

-
Atomic Operations and Multiple-Levels of AD: Example and Test
-
-Discussion -
-One can use checkpoint - or atomic_base - to code -an -AD<Base> - operation as atomic. -This means that derivative computations that use the type -Base - -will call the corresponding atomic_base member functions. -On the other hand, if -Base - is -AD<Other> - the -operations recorded at the -Base - level will not be atomic. -This is demonstrated in this example. - - -

-# include <cppad/cppad.hpp>
-
-namespace {
-     using CppAD::AD;
-     typedef AD<double>                      a1double;
-     typedef AD<a1double>                    a2double;
-     typedef CPPAD_TESTVECTOR(a1double)      a1vector;
-     typedef CPPAD_TESTVECTOR(a2double)      a2vector;
-
-     void f_algo(const a2vector& x, a2vector& y)
-     {     size_t n = x.size();
-          y[0] = 0.0;
-          for(size_t j = 1; j < n; j++)
-               y[0] += x[j-1] * x[j];
-          return;
-     }
-}
-//
-bool mul_level(void)
-{     bool ok = true;
-     using CppAD::checkpoint;
-     using CppAD::ADFun;
-     using CppAD::Independent;
-
-     // domain dimension for this problem
-     size_t n = 10;
-     size_t m = 1;
-
-     // checkpoint version of the function F(x)
-     a2vector a2x(n), a2y(m);
-     for(size_t j = 0; j < n; j++)
-          a2x[j] = a2double(j + 1);
-     //
-     // could also use bool_sparsity_enum or set_sparsity_enum
-     checkpoint<a1double> atom_f("atom_f", f_algo, a2x, a2y);
-     //
-     // Record a version of y = f(x) without checkpointing
-     Independent(a2x);
-     f_algo(a2x, a2y);
-     ADFun<a1double> check_not(a2x, a2y);
-     //
-     // number of variables in a tape of f_algo that does not use checkpointing
-     size_t size_not = check_not.size_var();
-     //
-     // Record a version of y = f(x) with checkpointing
-     Independent(a2x);
-     atom_f(a2x, a2y);
-     ADFun<a1double> check_yes(a2x, a2y);
-     //
-     // f_algo is represented by one atomic operation in this tape
-     ok &= check_yes.size_var() < size_not;
-     //
-     // now record operations at a1double level
-     a1vector a1x(n), a1y(m);
-     for(size_t j = 0; j < n; j++)
-          a1x[j] = a1double(j + 1);
-     //
-     // without checkpointing
-     Independent(a1x);
-     a1y = check_not.Forward(0, a1x);
-     ADFun<double> with_not(a1x, a1y);
-     //
-     // should have the same size
-     ok &= with_not.size_var() == size_not;
-     //
-     // with checkpointing
-     Independent(a1x);
-     a1y = check_yes.Forward(0, a1x);
-     ADFun<double> with_yes(a1x, a1y);
-     //
-     // f_algo is nolonger represented by one atomic operation in this tape
-     ok &= with_yes.size_var() == size_not;
-     //
-     return ok;
-}
-
-
Input File: example/atomic/mul_level.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_mul_level.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_mul_level.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_mul_level.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_mul_level.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +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', -'atomic.xml', -'checkpoint.xml', -'atomic_mul_level.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 = [ -'checkpoint.cpp.xml', -'atomic_mul_level.cpp.xml', -'checkpoint_ode.cpp.xml', -'checkpoint_extended_ode.cpp.xml' -]; -var list_current0 = [ -'atomic_mul_level.cpp.xml#Discussion' -]; -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-2018.00.00.0/doc/atomic_norm_sq.cpp.xml cppad-2019.02.00.0/doc/atomic_norm_sq.cpp.xml --- cppad-2018.00.00.0/doc/atomic_norm_sq.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_norm_sq.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,530 +0,0 @@ - - - -Atomic Euclidean Norm Squared: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_norm_sq.cpp - -

-
Atomic Euclidean Norm Squared: Example and Test
-
-Theory -
-This example demonstrates using atomic_base - -to define the operation - - -f -: -R - -n - - -R - -m - - - - where - - -n -= -2 - - -, - -m -= -1 - - -, where - - -f -( -x -) -= -x -0 -2 - -+ -x -1 -2 - - - -
-sparsity -
-This example only uses bool sparsity patterns. - - - -
-
-Start Class Definition - -
# include <cppad/cppad.hpp>
-namespace {           // isolate items below to this file
-using CppAD::vector;  // abbreviate as vector
-//
-class atomic_norm_sq : public CppAD::atomic_base<double> {
-
-Constructor - -
public:
-     // constructor (could use const char* for name)
-     atomic_norm_sq(const std::string& name) :
-     // this example only uses boolean sparsity patterns
-     CppAD::atomic_base<double>(name, atomic_base<double>::bool_sparsity_enum)
-     { }
-private:
-
-forward - -
     // forward mode routine called by CppAD
-     virtual bool forward(
-          size_t                    p ,
-          size_t                    q ,
-          const vector<bool>&      vx ,
-                vector<bool>&      vy ,
-          const vector<double>&    tx ,
-                vector<double>&    ty
-     )
-     {
-# ifndef NDEBUG
-          size_t n = tx.size() / (q+1);
-          size_t m = ty.size() / (q+1);
-# endif
-          assert( n == 2 );
-          assert( m == 1 );
-          assert( p <= q );
-
-          // return flag
-          bool ok = q <= 1;
-
-          // Variable information must always be implemented.
-          // y_0 is a variable if and only if x_0 or x_1 is a variable.
-          if( vx.size() > 0 )
-               vy[0] = vx[0] | vx[1];
-
-          // Order zero forward mode must always be implemented.
-          // 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 )
-          if( p <= 0 )
-               ty[0] = f;   // y_0^0
-          if( q <= 0 )
-               return ok;
-          assert( vx.size() == 0 );
-
-          // Order one forward mode.
-          // This case needed if first order forward mode is used.
-          // y^1 = f'( x^0 ) x^1
-          double x_01 = tx[ 0*(q+1) + 1];   // x_0^1
-          double x_11 = tx[ 1*(q+1) + 1];   // x_1^1
-          double fp_0 = 2.0 * x_00;         // partial f w.r.t x_0^0
-          double fp_1 = 2.0 * x_10;         // partial f w.r.t x_1^0
-          if( p <= 1 )
-               ty[1] = fp_0 * x_01 + fp_1 * x_11; // f'( x^0 ) * x^1
-          if( q <= 1 )
-               return ok;
-
-          // Assume we are not using forward mode with order > 1
-          assert( ! ok );
-          return ok;
-     }
-
-reverse - -
     // reverse mode routine called by CppAD
-     virtual bool reverse(
-          size_t                    q ,
-          const vector<double>&    tx ,
-          const vector<double>&    ty ,
-                vector<double>&    px ,
-          const vector<double>&    py
-     )
-     {
-# ifndef NDEBUG
-          size_t n = tx.size() / (q+1);
-          size_t m = ty.size() / (q+1);
-# endif
-          assert( px.size() == n * (q+1) );
-          assert( py.size() == m * (q+1) );
-          assert( n == 2 );
-          assert( m == 1 );
-          bool ok = q <= 1;
-
-          double fp_0, fp_1;
-          switch(q)
-          {     case 0:
-               // This case needed if first order reverse mode is used
-               // F ( {x} ) = f( x^0 ) = y^0
-               fp_0  =  2.0 * tx[0];  // partial F w.r.t. x_0^0
-               fp_1  =  2.0 * tx[1];  // partial F w.r.t. x_0^1
-               px[0] = py[0] * fp_0;; // partial G w.r.t. x_0^0
-               px[1] = py[0] * fp_1;; // partial G w.r.t. x_0^1
-               assert(ok);
-               break;
-
-               default:
-               // Assume we are not using reverse with order > 1 (q > 0)
-               assert(!ok);
-          }
-          return ok;
-     }
-
-for_sparse_jac - -
     // forward Jacobian bool sparsity routine called by CppAD
-     virtual bool for_sparse_jac(
-          size_t                                p ,
-          const vector<bool>&                   r ,
-                vector<bool>&                   s ,
-          const vector<double>&                 x )
-     {     // This function needed if using f.ForSparseJac
-          size_t n = r.size() / p;
-# ifndef NDEBUG
-          size_t m = s.size() / p;
-# endif
-          assert( n == x.size() );
-          assert( n == 2 );
-          assert( m == 1 );
-
-          // 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++)
-               {     // Visual Studio 2013 generates warning without bool below
-                    s[j] |= bool( r[i * p + j] );
-               }
-          }
-          return true;
-     }
-
-rev_sparse_jac - -
     // reverse Jacobian bool sparsity routine called by CppAD
-     virtual bool rev_sparse_jac(
-          size_t                                p  ,
-          const vector<bool>&                   rt ,
-                vector<bool>&                   st ,
-          const vector<double>&                 x  )
-     {     // This function needed if using RevSparseJac or optimize
-          size_t n = st.size() / p;
-# ifndef NDEBUG
-          size_t m = rt.size() / p;
-# endif
-          assert( n == x.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
-          for(size_t j = 0; j < p; j++)
-               for(size_t i = 0; i < n; i++)
-                    st[i * p + j] = rt[j];
-
-          return true;
-     }
-
-rev_sparse_hes - -
     // reverse Hessian bool sparsity routine called by CppAD
-     virtual bool rev_sparse_hes(
-          const vector<bool>&                   vx,
-          const vector<bool>&                   s ,
-                vector<bool>&                   t ,
-          size_t                                p ,
-          const vector<bool>&                   r ,
-          const vector<bool>&                   u ,
-                vector<bool>&                   v ,
-          const vector<double>&                 x )
-     {     // This function needed if using RevSparseHes
-# ifndef NDEBUG
-          size_t m = s.size();
-# endif
-          size_t n = t.size();
-          assert( x.size() == n );
-          assert( r.size() == n * p );
-          assert( u.size() == m * p );
-          assert( v.size() == n * p );
-          assert( n == 2 );
-          assert( m == 1 );
-
-          // 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)
-          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)
-
-          // back propagate the sparsity for U
-          size_t j;
-          for(j = 0; j < p; j++)
-               for(size_t i = 0; i < n; i++)
-                    v[ i * p + j] = u[j];
-
-          // include forward Jacobian sparsity in Hessian sparsity
-          // sparsity for g'(y) * f''(x) * R  (Note f''(x) has same sparsity
-          // as the identity matrix)
-          if( s[0] )
-          {     for(j = 0; j < p; j++)
-                    for(size_t i = 0; i < n; i++)
-                    {     // Visual Studio 2013 generates warning without bool below
-                         v[ i * p + j] |= bool( r[ i * p + j] );
-                    }
-          }
-
-          return true;
-     }
-
-End Class Definition - -

-}; // End of atomic_norm_sq class
-}  // End empty namespace
-
-
-Use Atomic Function - -
bool norm_sq(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-
-Constructor - -

-     // --------------------------------------------------------------------
-     // Create the atomic reciprocal object
-     atomic_norm_sq afun("atomic_norm_sq");
-
-
-Recording - -
     // Create the function f(x)
-     //
-     // domain space vector
-     size_t  n  = 2;
-     double  x0 = 0.25;
-     double  x1 = 0.75;
-     vector< AD<double> > ax(n);
-     ax[0]      = x0;
-     ax[1]      = x1;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     vector< AD<double> > ay(m);
-
-     // 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<double> f;
-     f.Dependent (ax, ay);
-
-forward - -
     // check function value
-     double check = x0 * x0 + x1 * x1;
-     ok &= NearEqual( Value(ay[0]) , check,  eps, eps);
-
-     // check zero order forward mode
-     size_t q;
-     vector<double> x_q(n), y_q(m);
-     q      = 0;
-     x_q[0] = x0;
-     x_q[1] = x1;
-     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] = 0.3;
-     x_q[1] = 0.7;
-     y_q    = f.Forward(q, x_q);
-     check  = 2.0 * x0 * x_q[0] + 2.0 * x1 * x_q[1];
-     ok &= NearEqual(y_q[0] , check,  eps, eps);
-
-reverse - -
     // first order reverse mode
-     q     = 1;
-     vector<double> w(m), dw(n * q);
-     w[0]  = 1.;
-     dw    = f.Reverse(q, w);
-     check = 2.0 * x0;
-     ok &= NearEqual(dw[0] , check,  eps, eps);
-     check = 2.0 * x1;
-     ok &= NearEqual(dw[1] , check,  eps, eps);
-
-for_sparse_jac - -
     // forward mode sparstiy pattern
-     size_t p = n;
-     CppAD::vectorBool r1(n * p), s1(m * p);
-     r1[0] = true;  r1[1] = false; // sparsity pattern identity
-     r1[2] = false; r1[3] = true;
-     //
-     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]
-
-rev_sparse_jac - -
     // 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]
-     ok  &= r2[1] == true;  // f[0] depends on x[1]
-
-rev_sparse_hes - -
     // 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;  // 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;
-}
- -
Input File: example/atomic/norm_sq.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_norm_sq.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_norm_sq.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_norm_sq.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_norm_sq.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_norm_sq.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_current0 = [ -'atomic_norm_sq.cpp.xml#Theory', -'atomic_norm_sq.cpp.xml#sparsity', -'atomic_norm_sq.cpp.xml#Start Class Definition', -'atomic_norm_sq.cpp.xml#Constructor', -'atomic_norm_sq.cpp.xml#forward', -'atomic_norm_sq.cpp.xml#reverse', -'atomic_norm_sq.cpp.xml#for_sparse_jac', -'atomic_norm_sq.cpp.xml#rev_sparse_jac', -'atomic_norm_sq.cpp.xml#rev_sparse_hes', -'atomic_norm_sq.cpp.xml#End Class Definition', -'atomic_norm_sq.cpp.xml#Use Atomic Function', -'atomic_norm_sq.cpp.xml#Use Atomic Function.Constructor', -'atomic_norm_sq.cpp.xml#Use Atomic Function.Recording', -'atomic_norm_sq.cpp.xml#Use Atomic Function.forward', -'atomic_norm_sq.cpp.xml#Use Atomic Function.reverse', -'atomic_norm_sq.cpp.xml#Use Atomic Function.for_sparse_jac', -'atomic_norm_sq.cpp.xml#Use Atomic Function.rev_sparse_jac', -'atomic_norm_sq.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-2018.00.00.0/doc/atomic_option.xml cppad-2019.02.00.0/doc/atomic_option.xml --- cppad-2018.00.00.0/doc/atomic_option.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_option.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,273 +0,0 @@ - - - -Set Atomic Function Options - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_option - -

- - - -
Set Atomic Function Options
-
-Syntax - -
- -afun.option(option_value) - -These settings do not apply to individual -afun - calls, -but rather all subsequent uses of the corresponding atomic operation -in an ADFun - object. - -
-
-atomic_sparsity -
-Note that, if you use optimize -, these sparsity patterns are used -to determine the dependency - relationship between -argument and result variables. - -
-
-pack_sparsity_enum -
-If -option_value - is -atomic_base<Base>::pack_sparsity_enum -, -then the type used by -afun - for -sparsity patterns -, -(after the option is set) will be - -
-     typedef CppAD::vectorBool 
atomic_sparsity
-
-If -r - is a sparsity pattern -for a matrix - -R - -B -p -× -q - - - - -: - -r.size() == p * q -. - -
-
-bool_sparsity_enum -
-If -option_value - is -atomic_base<Base>::bool_sparsity_enum -, -then the type used by -afun - for -sparsity patterns -, -(after the option is set) will be - -
-     typedef CppAD::vector<bool> 
atomic_sparsity
-
-If -r - is a sparsity pattern -for a matrix - -R - -B -p -× -q - - - - -: - -r.size() == p * q -. - -
-
-set_sparsity_enum -
-If -option_value - is -atomic_base<Base>::set_sparsity_enum -, -then the type used by -afun - for -sparsity patterns -, -(after the option is set) will be - -
-     typedef CppAD::vector< std::set<size_t> > 
atomic_sparsity
-
-If -r - is a sparsity pattern -for a matrix - -R - -B -p -× -q - - - - -: - -r.size() == p -, and for - -i -= -0 -, - -, -p --1 - - -, -the elements of -r[i] - are between zero and - -q --1 - - - inclusive. - - -
Input File: cppad/core/atomic_base.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_option_xml.js cppad-2019.02.00.0/doc/_atomic_option_xml.js --- cppad-2018.00.00.0/doc/_atomic_option_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_option_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_option.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_current0 = [ -'atomic_option.xml#Syntax', -'atomic_option.xml#atomic_sparsity', -'atomic_option.xml#atomic_sparsity.pack_sparsity_enum', -'atomic_option.xml#atomic_sparsity.bool_sparsity_enum', -'atomic_option.xml#atomic_sparsity.set_sparsity_enum' -]; -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-2018.00.00.0/doc/atomic_reciprocal.cpp.xml cppad-2019.02.00.0/doc/atomic_reciprocal.cpp.xml --- cppad-2018.00.00.0/doc/atomic_reciprocal.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_reciprocal.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,548 +0,0 @@ - - - -Reciprocal as an Atomic Operation: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_reciprocal.cpp - -

-
Reciprocal as an Atomic Operation: Example and Test
-
-Theory -
-This example demonstrates using atomic_base - -to define the operation - - -f -: -R - -n - - -R - -m - - - - where - - -n -= -1 - - -, - -m -= -1 - - -, and - -f -( -x -) -= -1 -/ -x - - -. - -
-
-sparsity -
-This example only uses set sparsity patterns. - - - -
-
-Start Class Definition - -
# include <cppad/cppad.hpp>
-namespace {           // isolate items below to this file
-using CppAD::vector;  // abbreviate as vector
-//
-// a utility to compute the union of two sets.
-using CppAD::set_union;
-//
-class atomic_reciprocal : public CppAD::atomic_base<double> {
-
-Constructor - -
public:
-     // constructor (could use const char* for name)
-     atomic_reciprocal(const std::string& name) :
-     // this exmaple only uses set sparsity patterns
-     CppAD::atomic_base<double>(name, atomic_base<double>::set_sparsity_enum)
-     { }
-private:
-
-forward - -
     // forward mode routine called by CppAD
-     virtual bool forward(
-          size_t                    p ,
-          size_t                    q ,
-          const vector<bool>&      vx ,
-                vector<bool>&      vy ,
-          const vector<double>&    tx ,
-                vector<double>&    ty
-     )
-     {
-# ifndef NDEBUG
-          size_t n = tx.size() / (q + 1);
-          size_t m = ty.size() / (q + 1);
-# endif
-          assert( n == 1 );
-          assert( m == 1 );
-          assert( p <= q );
-
-          // return flag
-          bool ok = q <= 2;
-
-          // check for defining variable information
-          // This case must always be implemented
-          if( vx.size() > 0 )
-               vy[0] = vx[0];
-
-          // Order zero forward mode.
-          // This case must always be implemented
-          // y^0 = f( x^0 ) = 1 / x^0
-          double f = 1. / tx[0];
-          if( p <= 0 )
-               ty[0] = f;
-          if( q <= 0 )
-               return ok;
-          assert( vx.size() == 0 );
-
-          // Order one forward mode.
-          // This case needed if first order forward mode is used.
-          // y^1 = f'( x^0 ) x^1
-          double fp = - f / tx[0];
-          if( p <= 1 )
-               ty[1] = fp * tx[1];
-          if( q <= 1 )
-               return ok;
-
-          // Order two forward mode.
-          // This case needed if second order forward mode is used.
-          // 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
-          double fpp  = - 2.0 * fp / tx[0];
-          ty[2] = tx[1] * fpp * tx[1] / 2.0 + fp * tx[2];
-          if( q <= 2 )
-               return ok;
-
-          // Assume we are not using forward mode with order > 2
-          assert( ! ok );
-          return ok;
-     }
-
-reverse - -
     // reverse mode routine called by CppAD
-     virtual bool reverse(
-          size_t                    q ,
-          const vector<double>&    tx ,
-          const vector<double>&    ty ,
-                vector<double>&    px ,
-          const vector<double>&    py
-     )
-     {
-# ifndef NDEBUG
-          size_t n = tx.size() / (q + 1);
-          size_t m = ty.size() / (q + 1);
-# endif
-          assert( px.size() == n * (q + 1) );
-          assert( py.size() == m * (q + 1) );
-          assert( n == 1 );
-          assert( m == 1 );
-          bool ok = q <= 2;
-
-          double f, fp, fpp, fppp;
-          switch(q)
-          {     case 0:
-               // This case 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;;
-               assert(ok);
-               break;
-
-               case 1:
-               // This case 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;
-               assert(ok);
-               break;
-
-               case 2:
-               // This 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;
-               assert(ok);
-               break;
-
-               default:
-               assert(!ok);
-          }
-          return ok;
-     }
-
-for_sparse_jac - -
     // forward Jacobian set sparsity routine called by CppAD
-     virtual bool for_sparse_jac(
-          size_t                                p ,
-          const vector< std::set<size_t> >&     r ,
-                vector< std::set<size_t> >&     s ,
-          const vector<double>&                 x )
-     {     // This function needed if using f.ForSparseJac
-# ifndef NDEBUG
-          size_t n = r.size();
-          size_t m = s.size();
-# endif
-          assert( n == x.size() );
-          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;
-     }
-
-rev_sparse_jac - -
     // reverse Jacobian set sparsity routine called by CppAD
-     virtual bool rev_sparse_jac(
-          size_t                                p  ,
-          const vector< std::set<size_t> >&     rt ,
-                vector< std::set<size_t> >&     st ,
-          const vector<double>&                 x  )
-     {     // This function needed if using RevSparseJac or optimize
-# ifndef NDEBUG
-          size_t n = st.size();
-          size_t m = rt.size();
-# endif
-          assert( n == x.size() );
-          assert( n == 1 );
-          assert( m == 1 );
-
-          // sparsity for S(x)^T = f'(x)^T * R^T is same as sparsity for R^T
-          st[0] = rt[0];
-
-          return true;
-     }
-
-rev_sparse_hes - -
     // reverse Hessian set sparsity routine called by CppAD
-     virtual bool rev_sparse_hes(
-          const vector<bool>&                   vx,
-          const vector<bool>&                   s ,
-                vector<bool>&                   t ,
-          size_t                                p ,
-          const vector< std::set<size_t> >&     r ,
-          const vector< std::set<size_t> >&     u ,
-                vector< std::set<size_t> >&     v ,
-          const vector<double>&                 x )
-     {     // This function needed if using RevSparseHes
-# ifndef NDEBUG
-          size_t n = vx.size();
-          size_t m = s.size();
-# endif
-          assert( x.size() == n );
-          assert( t.size() == n );
-          assert( r.size() == n );
-          assert( u.size() == m );
-          assert( v.size() == n );
-          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;
-          v[0] = u[0];
-
-          // include forward Jacobian sparsity in Hessian sparsity
-          // (note sparsty for f''(x) * R same as for R)
-          if( s[0] )
-               v[0] = set_union(v[0], r[0] );
-
-          return true;
-     }
-
-End Class Definition - -

-}; // End of atomic_reciprocal class
-}  // End empty namespace
-
-
-Use Atomic Function - -
bool reciprocal(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-
-Constructor - -

-     // --------------------------------------------------------------------
-     // Create the atomic reciprocal object
-     atomic_reciprocal afun("atomic_reciprocal");
-
-
-Recording - -
     // Create the function f(x)
-     //
-     // domain space vector
-     size_t n  = 1;
-     double  x0 = 0.5;
-     vector< AD<double> > ax(n);
-     ax[0]     = x0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     vector< AD<double> > ay(m);
-
-     // call user function and store reciprocal(x) in au[0]
-     vector< AD<double> > au(m);
-     afun(ax, au);        // u = 1 / x
-
-     // now use AD division to invert to invert the operation
-     ay[0] = 1.0 / au[0]; // y = 1 / u = x
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f;
-     f.Dependent (ax, ay);  // f(x) = x
-
-forward - -
     // check function value
-     double check = x0;
-     ok &= NearEqual( Value(ay[0]) , check,  eps, eps);
-
-     // check zero order forward mode
-     size_t q;
-     vector<double> 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);
-
-reverse - -
     // third order reverse mode
-     q     = 3;
-     vector<double> 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);
-
-for_sparse_jac - -
     // 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]
-
-rev_sparse_jac - -
     // 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]
-
-rev_sparse_hes - -
     // 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
-     //
-     return ok;
-}
- -
Input File: example/atomic/reciprocal.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_reciprocal.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_reciprocal.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_reciprocal.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_reciprocal.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_reciprocal.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_current0 = [ -'atomic_reciprocal.cpp.xml#Theory', -'atomic_reciprocal.cpp.xml#sparsity', -'atomic_reciprocal.cpp.xml#Start Class Definition', -'atomic_reciprocal.cpp.xml#Constructor', -'atomic_reciprocal.cpp.xml#forward', -'atomic_reciprocal.cpp.xml#reverse', -'atomic_reciprocal.cpp.xml#for_sparse_jac', -'atomic_reciprocal.cpp.xml#rev_sparse_jac', -'atomic_reciprocal.cpp.xml#rev_sparse_hes', -'atomic_reciprocal.cpp.xml#End Class Definition', -'atomic_reciprocal.cpp.xml#Use Atomic Function', -'atomic_reciprocal.cpp.xml#Use Atomic Function.Constructor', -'atomic_reciprocal.cpp.xml#Use Atomic Function.Recording', -'atomic_reciprocal.cpp.xml#Use Atomic Function.forward', -'atomic_reciprocal.cpp.xml#Use Atomic Function.reverse', -'atomic_reciprocal.cpp.xml#Use Atomic Function.for_sparse_jac', -'atomic_reciprocal.cpp.xml#Use Atomic Function.rev_sparse_jac', -'atomic_reciprocal.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-2018.00.00.0/doc/atomic_reverse.cpp.xml cppad-2019.02.00.0/doc/atomic_reverse.cpp.xml --- cppad-2018.00.00.0/doc/atomic_reverse.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_reverse.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,555 +0,0 @@ - - - -Atomic Reverse: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_reverse.cpp - -

-
Atomic Reverse: Example and Test
-
-Purpose -
-This example demonstrates reverse mode derivative calculation -using an atomic operation. - -
-
-function -
-For this example, the atomic function - - -f -: -R - -3 - - -R - -2 - - - - is defined by - - -f -( -x -) -= -( -x -2 - -* -x -2 - - -x -0 - -* -x -1 - - -) - - -The corresponding Jacobian is - - -f -( -1 -) - - -( -x -) -= -( -0 - -0 - -2 -x -2 - - -x -1 - - -x -0 - - -0 - -) - - -The Hessians of the component functions are - - -f -0 -( -2 -) - - -( -x -) -= -( -0 - -0 - -0 - -0 - -0 - -0 - -0 - -0 - -2 - -) - -, - -f -1 -( -2 -) - - -( -x -) -= -( -0 - -1 - -0 - -1 - -0 - -0 - -0 - -0 - -0 - -) - - -
-Start Class Definition - -
# include <cppad/cppad.hpp>
-namespace {          // isolate items below to this file
-using CppAD::vector; // abbreviate as vector
-//
-class atomic_reverse : public CppAD::atomic_base<double> {
-
-Constructor - -
public:
-     // constructor (could use const char* for name)
-     atomic_reverse(const std::string& name) :
-     // this example does not use sparsity patterns
-     CppAD::atomic_base<double>(name)
-     { }
-private:
-
-forward - -
     // forward mode routine called by CppAD
-     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 q1 = q + 1;
-# ifndef NDEBUG
-          size_t n = tx.size() / q1;
-          size_t m = ty.size() / q1;
-# endif
-          assert( n == 3 );
-          assert( m == 2 );
-          assert( p <= q );
-
-          // this example only implements up to first order forward mode
-          bool ok = q <= 1;
-          if( ! ok )
-               return ok;
-
-          // check for defining variable information
-          // This case must always be implemented
-          if( vx.size() > 0 )
-          {     vy[0] = vx[2];
-               vy[1] = vx[0] || vx[1];
-          }
-          // ------------------------------------------------------------------
-          // Zero forward mode.
-          // This case must always be implemented
-          // f(x) = [ x_2 * x_2 ]
-          //        [ x_0 * x_1 ]
-          // y^0  = f( x^0 )
-          if( p <= 0 )
-          {     // y_0^0 = x_2^0 * x_2^0
-               ty[0 * q1 + 0] = tx[2 * q1 + 0] * tx[2 * q1 + 0];
-               // y_1^0 = x_0^0 * x_1^0
-               ty[1 * q1 + 0] = tx[0 * q1 + 0] * tx[1 * q1 + 0];
-          }
-          if( q <= 0 )
-               return ok;
-          // ------------------------------------------------------------------
-          // First order one forward mode.
-          // This case is needed if first order forward mode is used.
-          // f'(x) = [   0,   0, 2 * x_2 ]
-          //         [ x_1, x_0,       0 ]
-          // y^1 =  f'(x^0) * x^1
-          if( p <= 1 )
-          {     // y_0^1 = 2 * x_2^0 * x_2^1
-               ty[0 * q1 + 1] = 2.0 * tx[2 * q1 + 0] * tx[2 * q1 + 1];
-
-               // y_1^1 = x_1^0 * x_0^1 + x_0^0 * x_1^1
-               ty[1 * q1 + 1]  = tx[1 * q1 + 0] * tx[0 * q1 + 1];
-               ty[1 * q1 + 1] += tx[0 * q1 + 0] * tx[1 * q1 + 1];
-          }
-          return ok;
-     }
-
-reverse - -
     // reverse mode routine called by CppAD
-     virtual bool reverse(
-          size_t                   q ,
-          const vector<double>&    tx ,
-          const vector<double>&    ty ,
-          vector<double>&          px ,
-          const vector<double>&    py
-     )
-     {
-          size_t q1 = q + 1;
-          size_t n = tx.size() / q1;
-# ifndef NDEBUG
-          size_t m = ty.size() / q1;
-# endif
-          assert( n == 3 );
-          assert( m == 2 );
-
-          // this example only implements up to second order reverse mode
-          bool ok = q1 <= 2;
-          if( ! ok )
-               return ok;
-          //
-          // initalize summation as zero
-          for(size_t j = 0; j < n; j++)
-               for(size_t k = 0; k < q; k++)
-                    px[j * q1 + k] = 0.0;
-          //
-          if( q1 == 2 )
-          {     // --------------------------------------------------------------
-               // Second order reverse first compute partials of first order
-               // We use the notation pf_ij^k for partial of F_i^1 w.r.t. x_j^k
-               //
-               // y_0^1    = 2 * x_2^0 * x_2^1
-               // pf_02^0  = 2 * x_2^1
-               // pf_02^1  = 2 * x_2^0
-               //
-               // y_1^1    = x_1^0 * x_0^1 + x_0^0 * x_1^1
-               // pf_10^0  = x_1^1
-               // pf_11^0  = x_0^1
-               // pf_10^1  = x_1^0
-               // pf_11^1  = x_0^0
-               //
-               // px_0^0 += py_0^1 * pf_00^0 + py_1^1 * pf_10^0
-               //        += py_1^1 * x_1^1
-               px[0 * q1 + 0] += py[1 * q1 + 1] * tx[1 * q1 + 1];
-               //
-               // px_0^1 += py_0^1 * pf_00^1 + py_1^1 * pf_10^1
-               //        += py_1^1 * x_1^0
-               px[0 * q1 + 1] += py[1 * q1 + 1] * tx[1 * q1 + 0];
-               //
-               // px_1^0 += py_0^1 * pf_01^0 + py_1^1 * pf_11^0
-               //        += py_1^1 * x_0^1
-               px[1 * q1 + 0] += py[1 * q1 + 1] * tx[0 * q1 + 1];
-               //
-               // px_1^1 += py_0^1 * pf_01^1 + py_1^1 * pf_11^1
-               //        += py_1^1 * x_0^0
-               px[1 * q1 + 1] += py[1 * q1 + 1] * tx[0 * q1 + 0];
-               //
-               // px_2^0 += py_0^1 * pf_02^0 + py_1^1 * pf_12^0
-               //        += py_0^1 * 2 * x_2^1
-               px[2 * q1 + 0] += py[0 * q1 + 1] * 2.0 * tx[2 * q1 + 1];
-               //
-               // px_2^1 += py_0^1 * pf_02^1 + py_1^1 * pf_12^1
-               //        += py_0^1 * 2 * x_2^0
-               px[2 * q1 + 1] += py[0 * q1 + 1] * 2.0 * tx[2 * q1 + 0];
-          }
-          // --------------------------------------------------------------
-          // First order reverse computes partials of zero order coefficients
-          // We use the notation pf_ij for partial of F_i^0 w.r.t. x_j^0
-          //
-          // y_0^0 = x_2^0 * x_2^0
-          // pf_00 = 0,     pf_01 = 0,  pf_02 = 2 * x_2^0
-          //
-          // y_1^0 = x_0^0 * x_1^0
-          // pf_10 = x_1^0, pf_11 = x_0^0,  pf_12 = 0
-          //
-          // px_0^0 += py_0^0 * pf_00 + py_1^0 * pf_10
-          //        += py_1^0 * x_1^0
-          px[0 * q1 + 0] += py[1 * q1 + 0] * tx[1 * q1 + 0];
-          //
-          // px_1^0 += py_1^0 * pf_01 + py_1^0 * pf_11
-          //        += py_1^0 * x_0^0
-          px[1 * q1 + 0] += py[1 * q1 + 0] * tx[0 * q1 + 0];
-          //
-          // px_2^0 += py_1^0 * pf_02 + py_1^0 * pf_12
-          //        += py_0^0 * 2.0 * x_2^0
-          px[2 * q1 + 0] += py[0 * q1 + 0] * 2.0 * tx[2 * q1 + 0];
-          // --------------------------------------------------------------
-          return ok;
-     }
-};
-}  // End empty namespace
-
-Use Atomic Function - -
bool reverse(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-     //
-     // Create the atomic_reverse object
-     atomic_reverse afun("atomic_reverse");
-     //
-     // Create the function f(u)
-     //
-     // domain space vector
-     size_t n  = 3;
-     double x_0 = 1.00;
-     double x_1 = 2.00;
-     double x_2 = 3.00;
-     vector< AD<double> > au(n);
-     au[0] = x_0;
-     au[1] = x_1;
-     au[2] = x_2;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(au);
-
-     // range space vector
-     size_t m = 2;
-     vector< AD<double> > ay(m);
-
-     // call user function
-     vector< AD<double> > ax = au;
-     afun(ax, ay);
-
-     // create f: u -> y and stop tape recording
-     CppAD::ADFun<double> f;
-     f.Dependent (au, ay);  // y = f(u)
-     //
-     // check function value
-     double check = x_2 * x_2;
-     ok &= NearEqual( Value(ay[0]) , check,  eps, eps);
-     check = x_0 * x_1;
-     ok &= NearEqual( Value(ay[1]) , check,  eps, eps);
-
-     // --------------------------------------------------------------------
-     // zero order forward
-     //
-     vector<double> x0(n), y0(m);
-     x0[0] = x_0;
-     x0[1] = x_1;
-     x0[2] = x_2;
-     y0   = f.Forward(0, x0);
-     check = x_2 * x_2;
-     ok &= NearEqual(y0[0] , check,  eps, eps);
-     check = x_0 * x_1;
-     ok &= NearEqual(y0[1] , check,  eps, eps);
-     // --------------------------------------------------------------------
-     // first order reverse
-     //
-     // value of Jacobian of f
-     double check_jac[] = {
-          0.0, 0.0, 2.0 * x_2,
-          x_1, x_0,       0.0
-     };
-     vector<double> w(m), dw(n);
-     //
-     // check derivative of f_0 (x)
-     for(size_t i = 0; i < m; i++)
-     {     w[i]   = 1.0;
-          w[1-i] = 0.0;
-          dw = f.Reverse(1, w);
-          for(size_t j = 0; j < n; j++)
-          {     // compute partial in j-th component direction
-               ok &= NearEqual(dw[j], check_jac[i * n + j], eps, eps);
-          }
-     }
-     // --------------------------------------------------------------------
-     // second order reverse
-     //
-     // value of Hessian of f_0
-     double check_hes_0[] = {
-          0.0, 0.0, 0.0,
-          0.0, 0.0, 0.0,
-          0.0, 0.0, 2.0
-     };
-     //
-     // value of Hessian of f_1
-     double check_hes_1[] = {
-          0.0, 1.0, 0.0,
-          1.0, 0.0, 0.0,
-          0.0, 0.0, 0.0
-     };
-     vector<double> x1(n), dw2( 2 * n );
-     for(size_t j = 0; j < n; j++)
-     {     for(size_t j1 = 0; j1 < n; j1++)
-               x1[j1] = 0.0;
-          x1[j] = 1.0;
-          // first order forward
-          f.Forward(1, x1);
-          w[0] = 1.0;
-          w[1] = 0.0;
-          dw2  = f.Reverse(2, w);
-          for(size_t i = 0; i < n; i++)
-               ok &= NearEqual(dw2[i * 2 + 1], check_hes_0[i * n + j], eps, eps);
-          w[0] = 0.0;
-          w[1] = 1.0;
-          dw2  = f.Reverse(2, w);
-          for(size_t i = 0; i < n; i++)
-               ok &= NearEqual(dw2[i * 2 + 1], check_hes_1[i * n + j], eps, eps);
-     }
-     // --------------------------------------------------------------------
-     return ok;
-}
- -
Input File: example/atomic/reverse.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_reverse.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_reverse.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_reverse.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_reverse.cpp_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', -'ad.xml', -'advalued.xml', -'atomic.xml', -'atomic_base.xml', -'atomic_reverse.xml', -'atomic_reverse.cpp.xml' -]; -var list_down3 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down2 = [ -'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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down1 = [ -'atomic_reverse.cpp.xml' -]; -var list_current0 = [ -'atomic_reverse.cpp.xml#Purpose', -'atomic_reverse.cpp.xml#function', -'atomic_reverse.cpp.xml#Start Class Definition', -'atomic_reverse.cpp.xml#Constructor', -'atomic_reverse.cpp.xml#forward', -'atomic_reverse.cpp.xml#reverse', -'atomic_reverse.cpp.xml#Use Atomic Function' -]; -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-2018.00.00.0/doc/atomic_reverse.xml cppad-2019.02.00.0/doc/atomic_reverse.xml --- cppad-2018.00.00.0/doc/atomic_reverse.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_reverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1174 +0,0 @@ - - - -Atomic Reverse Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Atomic Reverse Mode
-
-Syntax - -
- -ok = afun.reverse(qtxtypxpy) - - -
-
-Purpose -
-This function is used by reverse - -to compute derivatives. - -
-
-Implementation -
-If you are using -reverse - mode, -this virtual function must be defined by the -atomic_user - class. -It can just return -ok == false - -(and not compute anything) for values -of -q - that are greater than those used by your -reverse - mode calculations. - -
-
-q -
-The argument -q - has prototype - -
-     size_t 
q
-
-It specifies the highest order Taylor coefficient that -computing the derivative of. - -
-
-tx -
-The argument -tx - has prototype - -
-     const CppAD::vector<
Base>& tx
-
-and -tx.size() == (q+1)*n -. -For - -j -= -0 -, - -, -n --1 - - - and - -k -= -0 -, - -, -q - - -, -we use the Taylor coefficient notation - - - -x -j -k - - -= - -tx -[ -j -* -( -q -+ -1 -) -+ -k -] - -X -j - -( -t -) - -= - -x -j -0 - -+ -x -j -1 - -t -1 - -+ - -+ -x -j -q - -t -q - - - - -Note that superscripts represent an index for - -x -j -k - - - - -and an exponent for - -t -k - - - -. -Also note that the Taylor coefficients for - -X -( -t -) - - - correspond -to the derivatives of - -X -( -t -) - - - at - -t -= -0 - - - in the following way: - - -x -j -k - -= -1 - -k -! - - -X -j -( -k -) - - -( -0 -) - - -
-ty -
-The argument -ty - has prototype - -
-     const CppAD::vector<
Base>& ty
-
-and -tx.size() == (q+1)*m -. -For - -i -= -0 -, - -, -m --1 - - - and - -k -= -0 -, - -, -q - - -, -we use the Taylor coefficient notation - - - -Y -i - -( -t -) - -= - -f -i - -[ -X -( -t -) -] - -Y -i - -( -t -) - -= - -y -i -0 - -+ -y -i -1 - -t -1 - -+ - -+ -y -i -q - -t -q - -+ -o -( -t -q - -) - -y -i -k - - -= - -ty -[ -i -* -( -q -+ -1 -) -+ -k -] - - - -where - -o -( -t -q - -) -/ -t -q - - -0 - - - as - -t - -0 - - -. -Note that superscripts represent an index for - -y -j -k - - - - -and an exponent for - -t -k - - - -. -Also note that the Taylor coefficients for - -Y -( -t -) - - - correspond -to the derivatives of - -Y -( -t -) - - - at - -t -= -0 - - - in the following way: - - -y -j -k - -= -1 - -k -! - - -Y -j -( -k -) - - -( -0 -) - - -
-F -
-We use the notation - -{ -x -j -k - -} - -B -n -× -( -q -+ -1 -) - - - - - for - - -{ -x -j -k - - -: - -j -= -0 -, - -, -n --1 -, -k -= -0 -, - -, -q -} - - -We use the notation - -{ -y -i -k - -} - -B -m -× -( -q -+ -1 -) - - - - - for - - -{ -y -i -k - - -: - -i -= -0 -, - -, -m --1 -, -k -= -0 -, - -, -q -} - - -We define the function - - -F -: -B -n -× -( -q -+ -1 -) - - - -B -m -× -( -q -+ -1 -) - - - - - by - - -y -i -k - -= -F -i -k - -[ -{ -x -j -k - -} -] - - -Note that - - -F -i -0 - -( -{ -x -j -k - -} -) -= -f -i - -( -X -( -0 -) -) -= -f -i - -( -x -0 - -) - - -We also note that - - -F -i - - -( -{ -x -j -k - -} -) - - - is a function of - - -x -0 - -, - -, -x - - - - - -and is determined by the derivatives of - -f -i - -( -x -) - - - -up to order - - - - -. - - -
-
-G, H -
-We use - -G -: -B -m -× -( -q -+ -1 -) - - - -B - - - -to denote an arbitrary scalar valued function of - -{ -y -i -k - -} - - -. -We use - -H -: -B -n -× -( -q -+ -1 -) - - - -B - - - -defined by - - -H -( -{ -x -j -k - -} -) -= -G -[ -F -( -{ -x -j -k - -} -) -] - - -
-py -
-The argument -py - has prototype - -
-     const CppAD::vector<
Base>& py
-
-and -py.size() == m * (q+1) -. -For - -i -= -0 -, - -, -m --1 - - -, - -k -= -0 -, - -, -q - - -, - - -py -[ -i -* -( -q -+ -1 -) -+ -k -] -= - -G -/ - -y -i -k - - - -
-px -
-The -px - has prototype - -
-     CppAD::vector<
Base>& px
-
-and -px.size() == n * (q+1) -. -The input values of the elements of -px - -are not specified (must not matter). -Upon return, -for - -j -= -0 -, - -, -n --1 - - - and - - -= -0 -, - -, -q - - -, - - - -px -[ -j -* -( -q -+ -1 -) -+ - -] - -= - - -H -/ - -x -j - - - - -= - -( - -G -/ - -{ -y -i -k - -} -) -· -( - -{ -y -i -k - -} -/ - -x -j - - -) - - -= - - -k -= -0 - -q - - -i -= -0 - -m --1 - - -( - -G -/ - -y -i -k - -) -( - -y -i -k - -/ - -x -j - - -) - - -= - - -k -= - - -q - - -i -= -0 - -m --1 - - -py -[ -i -* -( -q -+ -1 -) -+ -k -] -( - -F -i -k - -/ - -x -j - - -) - - - -Note that we have used the fact that for - -k -< - - - -, - - - -F -i -k - -/ - -x -j - - -= -0 - - -. - -
-
-ok -
-The return value -ok - has prototype - -
-     bool 
ok
-
-If it is true, the corresponding evaluation succeeded, -otherwise it failed. - - -
-
-Examples -
-The file atomic_reverse.cpp - contains an example and test -that uses this routine. -It returns true if the test passes and false if it fails. - - -
Input File: cppad/core/atomic_base.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_reverse_xml.js cppad-2019.02.00.0/doc/_atomic_reverse_xml.js --- cppad-2018.00.00.0/doc/_atomic_reverse_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_reverse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_reverse.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down0 = [ -'atomic_reverse.cpp.xml' -]; -var list_current0 = [ -'atomic_reverse.xml#Syntax', -'atomic_reverse.xml#Purpose', -'atomic_reverse.xml#Implementation', -'atomic_reverse.xml#q', -'atomic_reverse.xml#tx', -'atomic_reverse.xml#ty', -'atomic_reverse.xml#F', -'atomic_reverse.xml#G, H', -'atomic_reverse.xml#py', -'atomic_reverse.xml#py.px', -'atomic_reverse.xml#ok', -'atomic_reverse.xml#Examples' -]; -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-2018.00.00.0/doc/atomic_rev_sparse_hes.cpp.xml cppad-2019.02.00.0/doc/atomic_rev_sparse_hes.cpp.xml --- cppad-2018.00.00.0/doc/atomic_rev_sparse_hes.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_rev_sparse_hes.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,533 +0,0 @@ - - - -Atomic Reverse Hessian Sparsity: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_rev_sparse_hes.cpp - -

-
Atomic Reverse Hessian Sparsity: Example and Test
-
-Purpose -
-This example demonstrates calculation of the reverse Hessian sparsity pattern -for an atomic operation. - -
-
-function -
-For this example, the atomic function - - -f -: -R - -3 - - -R - -2 - - - - is defined by - - -f -( -x -) -= -( -x -2 - -* -x -2 - - -x -0 - -* -x -1 - - -) - - -The Hessians of the component functions are - - -f -0 -( -2 -) - - -( -x -) -= -( -0 - -0 - -0 - -0 - -0 - -0 - -0 - -0 - -2 - -) - -, - -f -1 -( -2 -) - - -( -x -) -= -( -0 - -1 - -0 - -1 - -0 - -0 - -0 - -0 - -0 - -) - - -
-Start Class Definition - -
# include <cppad/cppad.hpp>
-namespace {          // isolate items below to this file
-using CppAD::vector; // abbreviate as vector
-//
-class atomic_rev_sparse_hes : public CppAD::atomic_base<double> {
-
-Constructor - -
public:
-     // constructor (could use const char* for name)
-     atomic_rev_sparse_hes(const std::string& name) :
-     // this example only uses pack sparsity patterns
-     CppAD::atomic_base<double>(name, pack_sparsity_enum)
-     { }
-private:
-
-forward - -
     // forward mode routine called by CppAD
-     virtual bool forward(
-          size_t                    p ,
-          size_t                    q ,
-          const vector<bool>&      vx ,
-          vector<bool>&            vy ,
-          const vector<double>&    tx ,
-          vector<double>&          ty
-     )
-     {
-# ifndef NDEBUG
-          size_t n = tx.size() / (q + 1);
-          size_t m = ty.size() / (q + 1);
-# endif
-          assert( n == 3 );
-          assert( m == 2 );
-
-          // return flag
-          bool ok = q == 0;
-          if( ! ok )
-               return ok;
-
-          // check for defining variable information
-          // This case must always be implemented
-          if( vx.size() > 0 )
-          {     vy[0] = vx[0];
-               vy[1] = vx[0] || vy[0];
-          }
-
-          // Order zero forward mode.
-          // This case must always be implemented
-          // f(x) = [ x_0 * x_0 ]
-          //        [ x_0 * x_1 ]
-          assert( p <= 0 );
-          if( p <= 0 )
-          {     ty[0] = tx[2] * tx[2];
-               ty[1] = tx[0] * tx[1];
-          }
-          return ok;
-     }
-
-for_sparse_jac - -
     // forward Jacobian sparsity routine called by CppAD
-     virtual bool for_sparse_jac(
-          size_t                     q ,
-          const CppAD::vectorBool&   r ,
-          CppAD::vectorBool&         s ,
-          const vector<double>&      x )
-     {     // This function needed because we are using ForSparseHes
-          // with afun.option( CppAD::atomic_base<double>::pack_sparsity_enum )
-# ifndef NDEBUG
-          size_t n = r.size() / q;
-          size_t m = s.size() / q;
-# endif
-          assert( n == x.size() );
-          assert( n == 3 );
-          assert( m == 2 );
-
-
-          // f'(x) = [   0,   0, 2 x_2 ]
-          //         [ x_1, x_0,     0 ]
-
-          // sparsity for first row of S(x) = f'(x) * R
-          size_t i = 0;
-          for(size_t j = 0; j < q; j++)
-               s[ i * q + j ] = r[ 2 * q + j ];
-
-          // sparsity for second row of S(x) = f'(x) * R
-          i = 1;
-          for(size_t j = 0; j < q; j++)
-               s[ i * q + j ] = r[ 0 * q + j ] | r[ 1 * q + j];
-
-          return true;
-     }
-
-rev_sparse_jac - -
     // reverse Jacobian sparsity routine called by CppAD
-     virtual bool rev_sparse_jac(
-          size_t                     q  ,
-          const CppAD::vectorBool&   rt ,
-          CppAD::vectorBool&         st ,
-          const vector<double>&      x  )
-     {     // This function needed because we are using ForSparseHes
-          // with afun.option( CppAD::atomic_base<double>::pack_sparsity_enum )
-# ifndef NDEBUG
-          size_t m = rt.size() / q;
-          size_t n = st.size() / q;
-# endif
-          assert( n == x.size() );
-          assert( n == 3 );
-          assert( m == 2 );
-
-          //           [     0,  x_1 ]
-          // f'(x)^T = [     0,  x_0 ]
-          //           [ 2 x_2,    0 ]
-
-          // sparsity for first row of S(x)^T = f'(x)^T * R^T
-          size_t i = 0;
-          for(size_t j = 0; j < q; j++)
-               st[ i * q + j ] = rt[ 1 * q + j ];
-
-          // sparsity for second row of S(x)^T = f'(x)^T * R^T
-          i = 1;
-          for(size_t j = 0; j < q; j++)
-               st[ i * q + j ] = rt[ 1 * q + j ];
-
-          // sparsity for third row of S(x)^T = f'(x)^T * R^T
-          i = 2;
-          for(size_t j = 0; j < q; j++)
-               st[ i * q + j ] = rt[ 0 * q + j ];
-
-          return true;
-     }
-
-rev_sparse_hes - -
     // reverse Hessian sparsity routine called by CppAD
-     virtual bool rev_sparse_hes(
-          const vector<bool>&                   vx,
-          const vector<bool>&                   s ,
-          vector<bool>&                         t ,
-          size_t                                q ,
-          const CppAD::vectorBool&              r ,
-          const CppAD::vectorBool&              u ,
-          CppAD::vectorBool&                    v ,
-          const vector<double>&                 x )
-     {     // This function needed because we are using RevSparseHes
-          // with afun.option( CppAD::atomic_base<double>::pack_sparsity_enum )
-# ifndef NDEBUG
-          size_t m = s.size();
-          size_t n = t.size();
-# endif
-          assert( x.size() == n );
-          assert( r.size() == n * q );
-          assert( u.size() == m * q );
-          assert( v.size() == n * q );
-          assert( n == 3 );
-          assert( m == 2 );
-          //
-          // f'(x) = [   0,   0, 2 x_2 ]
-          //         [ x_1, x_0,     0 ]
-          //
-          //            [ 0 , 0 , 0 ]                  [ 0 , 1 , 0 ]
-          // f_0''(x) = [ 0 , 0 , 0 ]  f_1^{(2)} (x) = [ 1 , 0 , 0 ]
-          //            [ 0 , 0 , 2 ]                  [ 0 , 0 , 0 ]
-          // ------------------------------------------------------------------
-          // sparsity pattern for row vector T(x) = S(x) * f'(x)
-          t[0] = s[1];
-          t[1] = s[1];
-          t[2] = s[0];
-          // ------------------------------------------------------------------
-          // sparsity pattern for W(x) = f'(x)^T * U(x)
-          for(size_t j = 0; j < q; j++)
-          {     v[ 0 * q + j ] = u[ 1 * q + j ];
-               v[ 1 * q + j ] = u[ 1 * q + j ];
-               v[ 2 * q + j ] = u[ 0 * q + j ];
-          }
-          // ------------------------------------------------------------------
-          // sparsity pattern for Q(x) = W(x) + S_0 (x) * f_0^{(2)} (x) * R
-          if( s[0] )
-          {     for(size_t j = 0; j < q; j++)
-               {     // cannot use |= with vectorBool
-                    v[ 2 * q + j ] = bool(v[ 2 * q + j ]) | bool(r[ 2 * q + j ]);
-               }
-          }
-          // ------------------------------------------------------------------
-          // sparsity pattern for V(x) = Q(x) + S_1 (x) * f_1^{(2)} (x) * R
-          if( s[1] )
-          {     for(size_t j = 0; j < q; j++)
-               {     // cannot use |= with vectorBool
-                    v[ 0 * q + j ] = bool(v[ 0 * q + j ]) | bool(r[ 1 * q + j ]);
-                    v[ 1 * q + j ] = bool(v[ 1 * q + j ]) | bool(r[ 0 * q + j ]);
-               }
-          }
-          return true;
-     }
-}; // End of atomic_rev_sparse_hes class
-
-Use Atomic Function - -
bool use_atomic_rev_sparse_hes(bool x_1_variable)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-     //
-     // Create the atomic rev_sparse_hes object
-     atomic_rev_sparse_hes afun("atomic_rev_sparse_hes");
-     //
-     // Create the function f(u)
-     //
-     // domain space vector
-     size_t n  = 3;
-     double x_0 = 1.00;
-     double x_1 = 2.00;
-     double x_2 = 3.00;
-     vector< AD<double> > au(n);
-     au[0] = x_0;
-     au[1] = x_1;
-     au[2] = x_2;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(au);
-
-     // range space vector
-     size_t m = 2;
-     vector< AD<double> > ay(m);
-
-     // call user function
-     vector< AD<double> > ax(n);
-     ax[0] = au[0];
-     ax[2] = au[2];
-     if( x_1_variable )
-          ax[1] = au[1];
-     else
-          ax[1] = x_1;
-     afun(ax, ay);          // y = [ x_2 * x_2 ,  x_0 * x_1 ]^T
-
-     // create f: u -> y and stop tape recording
-     CppAD::ADFun<double> f;
-     f.Dependent (au, ay);  // f(u) = y
-     //
-     // check function value
-     double check = x_2 * x_2;
-     ok &= NearEqual( Value(ay[0]) , check,  eps, eps);
-     check = x_0 * x_1;
-     ok &= NearEqual( Value(ay[1]) , check,  eps, eps);
-
-     // check zero order forward mode
-     size_t q;
-     vector<double> xq(n), yq(m);
-     q     = 0;
-     xq[0] = x_0;
-     xq[1] = x_1;
-     xq[2] = x_2;
-     yq    = f.Forward(q, xq);
-     check = x_2 * x_2;
-     ok &= NearEqual(yq[0] , check,  eps, eps);
-     check = x_0 * x_1;
-     ok &= NearEqual(yq[1] , check,  eps, eps);
-
-     // reverse sparse Hessian
-     CppAD::vectorBool r(n * n), s(m), h(n * n);
-     for(size_t i = 0; i < n; i++)
-     {     for(size_t j = 0; j < n; j++)
-               r[i * n + j] = i == j;
-     }
-     for(size_t i = 0; i < m; i++)
-          s[i] = true;
-     f.ForSparseJac(n, r);
-     h = f.RevSparseHes(n, s);
-
-     // check result
-     CppAD::vectorBool check_h(n * n);
-     for(size_t i = 0; i < n * n; i++)
-          check_h[i] = false;
-     check_h[ 2 * n + 2 ] = true;
-     if( x_1_variable )
-     {     check_h[0 * n + 1] = true;
-          check_h[1 * n + 0] = true;
-     }
-     for(size_t i = 0; i < n * n; i++)
-          ok &= h[ i ] == check_h[ i ];
-     //
-     return ok;
-}
-}  // End empty namespace
-
-Test with x_1 Both a Variable and a Parameter - -
bool rev_sparse_hes(void)
-{     bool ok = true;
-     // test with x_1 a variable
-     ok     &= use_atomic_rev_sparse_hes(true);
-     // test with x_1 a parameter
-     ok     &= use_atomic_rev_sparse_hes(false);
-     return ok;
-}
- -
Input File: example/atomic/rev_sparse_hes.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_rev_sparse_hes.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_rev_sparse_hes.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_rev_sparse_hes.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_rev_sparse_hes.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_rev_sparse_hes.xml', -'atomic_rev_sparse_hes.cpp.xml' -]; -var list_down3 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down2 = [ -'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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down1 = [ -'atomic_rev_sparse_hes.cpp.xml' -]; -var list_current0 = [ -'atomic_rev_sparse_hes.cpp.xml#Purpose', -'atomic_rev_sparse_hes.cpp.xml#function', -'atomic_rev_sparse_hes.cpp.xml#Start Class Definition', -'atomic_rev_sparse_hes.cpp.xml#Constructor', -'atomic_rev_sparse_hes.cpp.xml#forward', -'atomic_rev_sparse_hes.cpp.xml#for_sparse_jac', -'atomic_rev_sparse_hes.cpp.xml#rev_sparse_jac', -'atomic_rev_sparse_hes.cpp.xml#rev_sparse_hes', -'atomic_rev_sparse_hes.cpp.xml#Use Atomic Function', -'atomic_rev_sparse_hes.cpp.xml#Test with x_1 Both a Variable and a Parameter' -]; -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-2018.00.00.0/doc/atomic_rev_sparse_hes.xml cppad-2019.02.00.0/doc/atomic_rev_sparse_hes.xml --- cppad-2018.00.00.0/doc/atomic_rev_sparse_hes.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_rev_sparse_hes.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,879 +0,0 @@ - - - -Atomic Reverse Hessian Sparsity Patterns - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Atomic Reverse Hessian Sparsity Patterns
-
-Syntax - -
- -ok = afun.rev_sparse_hes(vxstqruvx) - - -
-
-Deprecated 2016-06-27 - -
- -ok = afun.rev_sparse_hes(vxstqruv) - - -
-
-Purpose -
-This function is used by RevSparseHes - to compute -Hessian sparsity patterns. -If you are using RevSparseHes - to compute -one of the versions of this -virtual function muse be defined by the -atomic_user - class. -
-
-
There is an unspecified scalar valued function - - -g -: -B -m - - -B - - -. -Given a sparsity pattern - for - - -R - -B -n -× -q - - - - -, -and information about the function - -z -= -g -( -y -) - - -, -this routine computes the sparsity pattern for - - -V -( -x -) -= -( -g - -f -) -( -2 -) - - -( -x -) -R - - -
-Implementation -
-If you are using and RevSparseHes -, -this virtual function must be defined by the -atomic_user - class. - -
-
-vx -
-The argument -vx - has prototype - -
-     const CppAD:vector<bool>& 
vx
-
- -vx.size() == n -, and -for - -j -= -0 -, - -, -n --1 - - -, - -vx[j] - is true if and only if - -ax[j] - is a variable - -in the corresponding call to - -
-     
afun(axay)
-
-
-s -
-The argument -s - has prototype - -
-     const CppAD:vector<bool>& 
s
-
-and its size is -m -. -It is a sparsity pattern for - - -S -( -x -) -= -g -( -1 -) - - -[ -f -( -x -) -] - -B -1 -× -m - - - - -. - -
-
-t -
-This argument has prototype - -
-     CppAD:vector<bool>& 
t
-
-and its size is -m -. -The input values of its elements -are not specified (must not matter). -Upon return, -t - is a -sparsity pattern for - - -T -( -x -) - -B -1 -× -n - - - - - where - - -T -( -x -) -= -( -g - -f -) -( -1 -) - - -( -x -) -= -S -( -x -) -* -f -( -1 -) - - -( -x -) - - -
-q -
-The argument -q - has prototype - -
-     size_t 
q
-
-It specifies the number of columns in - - -R - -B -n -× -q - - - - -, - - -U -( -x -) - -B -m -× -q - - - - -, and - - -V -( -x -) - -B -n -× -q - - - - -. - -
-
-r -
-This argument has prototype - -
-     const 
atomic_sparsityr
-
-and is a atomic_sparsity - pattern for - - -R - -B -n -× -q - - - - -. - -
-
-u -
-This argument has prototype - -
-     const 
atomic_sparsityu
-
-and is a atomic_sparsity - pattern for - - -U -( -x -) - -B -m -× -q - - - - - which is defined by - - - -U -( -x -) - -= - -{ - -u - -{ - -y - -g -[ -y -+ -f -( -1 -) - - -( -x -) -R -u -] -} -y -= -f -( -x -) - - -} -u -= -0 - - - - -= - - -u - -{ -g -( -1 -) - - -[ -f -( -x -) -+ -f -( -1 -) - - -( -x -) -R -u -] -} -u -= -0 - - - - -= - -g -( -2 -) - - -[ -f -( -x -) -] -f -( -1 -) - - -( -x -) -R - - - -
-v -
-This argument has prototype - -
-     
atomic_sparsityv
-
-The input value of its elements -are not specified (must not matter). -Upon return, -v - is a -atomic_sparsity - pattern for - - -V -( -x -) - -B -n -× -q - - - - - which is defined by - - - -V -( -x -) - -= - - -u - -[ - -x - -( -g - -f -) -( -x -+ -R -u -) -] -u -= -0 - - - - -= - - -u - -[ -( -g - -f -) -( -1 -) - - -( -x -+ -R -u -) -] -u -= -0 - - - - -= - -( -g - -f -) -( -2 -) - - -( -x -) -R - - -= - -f -( -1 -) - - -( -x -) -T - - -g -( -2 -) - - -[ -f -( -x -) -] -f -( -1 -) - - -( -x -) -R -+ - -i -= -1 - -m - -g -i -( -1 -) - - -[ -f -( -x -) -] - -f -i -( -2 -) - - -( -x -) -R - - -= - -f -( -1 -) - - -( -x -) -T - - -U -( -x -) -+ - -i -= -1 - -m - -S -i - -( -x -) - -f -i -( -2 -) - - -( -x -) -R - - - -
-x - -
-The argument has prototype - -
-     const CppAD::vector<
Base>& x
-
-and size is equal to the -n -. -This is the Value - value corresponding to the parameters in the -vector ax - (when the atomic function was called). -To be specific, if - -
-     if( Parameter(
ax[i]) == true )
-          
x[i] = Value( ax[i] );
-     else
-          
x[i] = CppAD::numeric_limits<Base>::quiet_NaN();
-
-The version of this function with out the -x - argument is deprecated; -i.e., you should include the argument even if you do not use it. - - -
-
-Examples -
-The file atomic_rev_sparse_hes.cpp - contains an example and test -that uses this routine. -It returns true if the test passes and false if it fails. - - -
Input File: cppad/core/atomic_base.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_rev_sparse_hes_xml.js cppad-2019.02.00.0/doc/_atomic_rev_sparse_hes_xml.js --- cppad-2018.00.00.0/doc/_atomic_rev_sparse_hes_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_rev_sparse_hes_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_rev_sparse_hes.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down0 = [ -'atomic_rev_sparse_hes.cpp.xml' -]; -var list_current0 = [ -'atomic_rev_sparse_hes.xml#Syntax', -'atomic_rev_sparse_hes.xml#Deprecated 2016-06-27', -'atomic_rev_sparse_hes.xml#Purpose', -'atomic_rev_sparse_hes.xml#Implementation', -'atomic_rev_sparse_hes.xml#Implementation.vx', -'atomic_rev_sparse_hes.xml#Implementation.s', -'atomic_rev_sparse_hes.xml#Implementation.t', -'atomic_rev_sparse_hes.xml#Implementation.q', -'atomic_rev_sparse_hes.xml#Implementation.r', -'atomic_rev_sparse_hes.xml#u', -'atomic_rev_sparse_hes.xml#u.v', -'atomic_rev_sparse_hes.xml#u.x', -'atomic_rev_sparse_hes.xml#Examples' -]; -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-2018.00.00.0/doc/atomic_rev_sparse_jac.cpp.xml cppad-2019.02.00.0/doc/atomic_rev_sparse_jac.cpp.xml --- cppad-2018.00.00.0/doc/atomic_rev_sparse_jac.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_rev_sparse_jac.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,396 +0,0 @@ - - - -Atomic Reverse Jacobian Sparsity: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_rev_sparse_jac.cpp - -

-
Atomic Reverse Jacobian Sparsity: Example and Test
-
-Purpose -
-This example demonstrates calculation of the -reverse Jacobians sparsity pattern for an atomic operation. - -
-
-function -
-For this example, the atomic function - - -f -: -R - -3 - - -R - -2 - - - - is defined by - - -f -( -x -) -= -( -x -2 - -* -x -2 - - -x -0 - -* -x -1 - - -) - - -The corresponding Jacobian is - - -f -( -1 -) - - -( -x -) -= -( -0 - -0 - -2 -x -2 - - -x -1 - - -x -0 - - -0 - -) - - -
-Start Class Definition - -
# include <cppad/cppad.hpp>
-namespace {          // isolate items below to this file
-using CppAD::vector; // abbreviate as vector
-//
-class atomic_rev_sparse_jac : public CppAD::atomic_base<double> {
-
-Constructor - -
public:
-     // constructor (could use const char* for name)
-     atomic_rev_sparse_jac(const std::string& name) :
-     // this example only uses pack sparsity patterns
-     CppAD::atomic_base<double>(name, pack_sparsity_enum)
-     { }
-private:
-
-forward - -
     // forward mode routine called by CppAD
-     virtual bool forward(
-          size_t                    p ,
-          size_t                    q ,
-          const vector<bool>&      vx ,
-          vector<bool>&            vy ,
-          const vector<double>&    tx ,
-          vector<double>&          ty
-     )
-     {
-# ifndef NDEBUG
-          size_t n = tx.size() / (q + 1);
-          size_t m = ty.size() / (q + 1);
-# endif
-          assert( n == 3 );
-          assert( m == 2 );
-
-          // return flag
-          bool ok = q == 0;
-          if( ! ok )
-               return ok;
-
-          // check for defining variable information
-          // This case must always be implemented
-          if( vx.size() > 0 )
-          {     vy[0] = vx[0];
-               vy[1] = vx[0] || vy[0];
-          }
-
-          // Order zero forward mode.
-          // This case must always be implemented
-          // f(x) = [ x_0 * x_0 ]
-          //        [ x_0 * x_1 ]
-          assert( p <= 0 );
-          if( p <= 0 )
-          {     ty[0] = tx[2] * tx[2];
-               ty[1] = tx[0] * tx[1];
-          }
-          return ok;
-     }
-
-rev_sparse_jac - -
     // reverse Jacobian sparsity routine called by CppAD
-     virtual bool rev_sparse_jac(
-          size_t                     q  ,
-          const CppAD::vectorBool&   rt ,
-          CppAD::vectorBool&         st ,
-          const vector<double>&      x  )
-     {     // This function needed because we are using RevSparseHes
-          // with afun.option( CppAD::atomic_base<double>::pack_sparsity_enum )
-# ifndef NDEBUG
-          size_t m = rt.size() / q;
-          size_t n = st.size() / q;
-# endif
-          assert( n == x.size() );
-          assert( n == 3 );
-          assert( m == 2 );
-
-          //           [     0,  x_1 ]
-          // f'(x)^T = [     0,  x_0 ]
-          //           [ 2 x_2,    0 ]
-
-          // sparsity for first row of S(x)^T = f'(x)^T * R^T
-          size_t i = 0;
-          for(size_t j = 0; j < q; j++)
-               st[ i * q + j ] = rt[ 1 * q + j ];
-
-          // sparsity for second row of S(x)^T = f'(x)^T * R^T
-          i = 1;
-          for(size_t j = 0; j < q; j++)
-               st[ i * q + j ] = rt[ 1 * q + j ];
-
-          // sparsity for third row of S(x)^T = f'(x)^T * R^T
-          i = 2;
-          for(size_t j = 0; j < q; j++)
-               st[ i * q + j ] = rt[ 0 * q + j ];
-
-          return true;
-     }
-}; // End of atomic_rev_sparse_jac class
-
-Use Atomic Function - -
bool use_atomic_rev_sparse_jac(bool x_1_variable)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-     //
-     // Create the atomic rev_sparse_jac object
-     atomic_rev_sparse_jac afun("atomic_rev_sparse_jac");
-     //
-     // Create the function f(u)
-     //
-     // domain space vector
-     size_t n  = 3;
-     double x_0 = 1.00;
-     double x_1 = 2.00;
-     double x_2 = 3.00;
-     vector< AD<double> > au(n);
-     au[0] = x_0;
-     au[1] = x_1;
-     au[2] = x_2;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(au);
-
-     // range space vector
-     size_t m = 2;
-     vector< AD<double> > ay(m);
-
-     // call user function
-     vector< AD<double> > ax(n);
-     ax[0] = au[0];
-     ax[2] = au[2];
-     if( x_1_variable )
-          ax[1] = au[1];
-     else
-          ax[1] = x_1;
-     afun(ax, ay);          // y = [ x_2 * x_2 ,  x_0 * x_1 ]^T
-
-     // create f: u -> y and stop tape recording
-     CppAD::ADFun<double> f;
-     f.Dependent (au, ay);  // f(u) = y
-     //
-     // check function value
-     double check = x_2 * x_2;
-     ok &= NearEqual( Value(ay[0]) , check,  eps, eps);
-     check = x_0 * x_1;
-     ok &= NearEqual( Value(ay[1]) , check,  eps, eps);
-
-     // check zero order forward mode
-     size_t q;
-     vector<double> xq(n), yq(m);
-     q     = 0;
-     xq[0] = x_0;
-     xq[1] = x_1;
-     xq[2] = x_2;
-     yq    = f.Forward(q, xq);
-     check = x_2 * x_2;
-     ok &= NearEqual(yq[0] , check,  eps, eps);
-     check = x_0 * x_1;
-     ok &= NearEqual(yq[1] , check,  eps, eps);
-
-     // forward sparse Jacobian
-     CppAD::vectorBool r(m * m), s(m * n);
-     // r = identity matrix
-     for(size_t i = 0; i < m; i++)
-          for(size_t j = 0; j < m; j++)
-               r[ i * m + j] = i == j;
-     s = f.RevSparseJac(m, r);
-
-     // check result
-     CppAD::vectorBool check_s(m * n);
-     check_s[ 0 * n + 0 ] = false;
-     check_s[ 0 * n + 1 ] = false;
-     check_s[ 0 * n + 2 ] = true;
-     check_s[ 1 * n + 0 ] = true;
-     check_s[ 1 * n + 1 ] = x_1_variable;
-     check_s[ 1 * n + 2 ] = false;
-     //
-     for(size_t i = 0; i < m * n; i++)
-          ok &= s[ i ] == check_s[ i ];
-     //
-     return ok;
-}
-}  // End empty namespace
-
-Test with x_1 Both a Variable and a Parameter - -
bool rev_sparse_jac(void)
-{     bool ok = true;
-     // test with x_1 a variable
-     ok     &= use_atomic_rev_sparse_jac(true);
-     // test with x_1 a parameter
-     ok     &= use_atomic_rev_sparse_jac(false);
-     return ok;
-}
- -
Input File: example/atomic/rev_sparse_jac.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_rev_sparse_jac.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_rev_sparse_jac.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_rev_sparse_jac.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_rev_sparse_jac.cpp_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', -'atomic.xml', -'atomic_base.xml', -'atomic_rev_sparse_jac.xml', -'atomic_rev_sparse_jac.cpp.xml' -]; -var list_down3 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down2 = [ -'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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down1 = [ -'atomic_rev_sparse_jac.cpp.xml' -]; -var list_current0 = [ -'atomic_rev_sparse_jac.cpp.xml#Purpose', -'atomic_rev_sparse_jac.cpp.xml#function', -'atomic_rev_sparse_jac.cpp.xml#Start Class Definition', -'atomic_rev_sparse_jac.cpp.xml#Constructor', -'atomic_rev_sparse_jac.cpp.xml#forward', -'atomic_rev_sparse_jac.cpp.xml#rev_sparse_jac', -'atomic_rev_sparse_jac.cpp.xml#Use Atomic Function', -'atomic_rev_sparse_jac.cpp.xml#Test with x_1 Both a Variable and a Parameter' -]; -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-2018.00.00.0/doc/atomic_rev_sparse_jac.xml cppad-2019.02.00.0/doc/atomic_rev_sparse_jac.xml --- cppad-2018.00.00.0/doc/atomic_rev_sparse_jac.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_rev_sparse_jac.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,393 +0,0 @@ - - - -Atomic Reverse Jacobian Sparsity Patterns - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Atomic Reverse Jacobian Sparsity Patterns
-
-Syntax - -
- -ok = afun.rev_sparse_jac(qrtstx)
-
-
-Deprecated 2016-06-27 - -
- -ok = afun.rev_sparse_jac(qrtst)
-
-
-Purpose -
-This function is used by -RevSparseJac - to compute -Jacobian sparsity patterns. -If you are using RevSparseJac -, -one of the versions of this -virtual function must be defined by the -atomic_user - class. -
-
-
For a fixed matrix - -R - -B -q -× -m - - - - -, -the Jacobian of - -R -* -f -( -x -) - - - with respect to - -x - -B -n - - - - is - - -S -( -x -) -= -R -* -f -( -1 -) - - -( -x -) - - -Given a sparsity pattern - for - -R - - -, -rev_sparse_jac computes a sparsity pattern for - -S -( -x -) - - -. - -
-
-Implementation -
-If you are using -RevSparseJac - or ForSparseHes -, -this virtual function must be defined by the -atomic_user - class. - -
-
-q -
-The argument -q - has prototype - -
-     size_t 
q
-
-It specifies the number of rows in - - -R - -B -q -× -m - - - - - and the Jacobian - - -S -( -x -) - -B -q -× -n - - - - -. - -
-
-rt -
-This argument has prototype - -
-     const 
atomic_sparsityrt
-
-and is a -atomic_sparsity - pattern for - - -R -T - - - -B -m -× -q - - - - -. - -
-
-st -
-This argument has prototype - -
-     
atomic_sparsityst
-
-The input value of its elements -are not specified (must not matter). -Upon return, -s - is a -atomic_sparsity - pattern for - - -S -( -x -) -T - - - -B -n -× -q - - - - -. - -
-
-x - -
-The argument has prototype - -
-     const CppAD::vector<
Base>& x
-
-and size is equal to the -n -. -This is the Value - corresponding to the parameters in the -vector ax - (when the atomic function was called). -To be specific, if - -
-     if( Parameter(
ax[i]) == true )
-          
x[i] = Value( ax[i] );
-     else
-          
x[i] = CppAD::numeric_limits<Base>::quiet_NaN();
-
-The version of this function with out the -x - argument is deprecated; -i.e., you should include the argument even if you do not use it. - -
-
-ok -
-The return value -ok - has prototype - -
-     bool 
ok
-
-If it is true, the corresponding evaluation succeeded, -otherwise it failed. - - -
-
-Examples -
-The file atomic_rev_sparse_jac.cpp - contains an example and test -that uses this routine. -It returns true if the test passes and false if it fails. - - -
Input File: cppad/core/atomic_base.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_rev_sparse_jac_xml.js cppad-2019.02.00.0/doc/_atomic_rev_sparse_jac_xml.js --- cppad-2018.00.00.0/doc/_atomic_rev_sparse_jac_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_rev_sparse_jac_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_rev_sparse_jac.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down0 = [ -'atomic_rev_sparse_jac.cpp.xml' -]; -var list_current0 = [ -'atomic_rev_sparse_jac.xml#Syntax', -'atomic_rev_sparse_jac.xml#Deprecated 2016-06-27', -'atomic_rev_sparse_jac.xml#Purpose', -'atomic_rev_sparse_jac.xml#Implementation', -'atomic_rev_sparse_jac.xml#Implementation.q', -'atomic_rev_sparse_jac.xml#Implementation.rt', -'atomic_rev_sparse_jac.xml#Implementation.st', -'atomic_rev_sparse_jac.xml#Implementation.x', -'atomic_rev_sparse_jac.xml#ok', -'atomic_rev_sparse_jac.xml#Examples' -]; -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-2018.00.00.0/doc/atomic_set_sparsity.cpp.xml cppad-2019.02.00.0/doc/atomic_set_sparsity.cpp.xml --- cppad-2018.00.00.0/doc/atomic_set_sparsity.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_set_sparsity.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,483 +0,0 @@ - - - -Atomic Sparsity with Set Patterns: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_set_sparsity.cpp - -

-
Atomic Sparsity with Set Patterns: Example and Test
-
-function -
-For this example, the atomic function - - -f -: -R - -3 - - -R - -2 - - - - is defined by - - -f -( -x -) -= -( -x -2 - - -x -0 - -* -x -1 - - -) - - -
-set_sparsity_enum -
-This example only uses set sparsity patterns. - - - -
-
-Start Class Definition - -
# include <cppad/cppad.hpp>
-namespace {   // isolate items below to this file
-using   CppAD::vector;                          // vector
-typedef vector< std::set<size_t> > set_vector;  // atomic_sparsity
-//
-// a utility to compute the union of two sets.
-using CppAD::set_union;
-//
-class atomic_set_sparsity : public CppAD::atomic_base<double> {
-
-Constructor - -
public:
-     // constructor
-     atomic_set_sparsity(const std::string& name) :
-     // this exampel only uses set sparsity patterns
-     CppAD::atomic_base<double>(name, set_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);
-# ifndef NDEBUG
-          size_t m = ty.size() / (q + 1);
-# endif
-          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 set_vector&               r ,
-          set_vector&                     s ,
-          const vector<double>&           x )
-     {     // This function needed if using f.ForSparseJac
-# ifndef NDEBUG
-          size_t n = r.size();
-          size_t m = s.size();
-# endif
-          assert( n == x.size() );
-          assert( n == 3 );
-          assert( m == 2 );
-
-          // sparsity for S(x) = f'(x) * R  = [ 0,   0, 1 ] * R
-          s[0] = r[2];
-          // s[1] = union(r[0], r[1])
-          s[1] = set_union(r[0], r[1]);
-          //
-          return true;
-     }
-
-rev_sparse_jac - -
     virtual bool rev_sparse_jac(
-          size_t                                p  ,
-          const set_vector&                     rt ,
-          set_vector&                           st ,
-          const vector<double>&                 x  )
-     {     // This function needed if using RevSparseJac or optimize
-# ifndef NDEBUG
-          size_t n = st.size();
-          size_t m = rt.size();
-# endif
-          assert( n == x.size() );
-          assert( n == 3 );
-          assert( m == 2 );
-
-          //                                       [ 0, x1 ]
-          // sparsity for S(x)^T = f'(x)^T * R^T = [ 0, x0 ] * R^T
-          //                                       [ 1, 0  ]
-          st[0] = rt[1];
-          st[1] = rt[1];
-          st[2] = rt[0];
-          return true;
-     }
-
-for_sparse_hes - -
     virtual bool for_sparse_hes(
-          const vector<bool>&                   vx,
-          const vector<bool>&                   r ,
-          const vector<bool>&                   s ,
-          set_vector&                           h ,
-          const vector<double>&                 x )
-     {
-          size_t n = r.size();
-# ifndef NDEBUG
-          size_t m = s.size();
-# endif
-          assert( x.size() == n );
-          assert( h.size() == n );
-          assert( n == 3 );
-          assert( m == 2 );
-
-          // initialize h as empty
-          for(size_t i = 0; i < n; i++)
-               h[i].clear();
-
-          // only f_1 has a non-zero hessian
-          if( ! s[1] )
-               return true;
-
-          // only the cross term between x[0] and x[1] is non-zero
-          if( ! ( r[0] & r[1] ) )
-               return true;
-
-          // set the possibly non-zero terms in the hessian
-          h[0].insert(1);
-          h[1].insert(0);
-
-          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 set_vector&                     r ,
-          const set_vector&                     u ,
-          set_vector&                           v ,
-          const vector<double>&                 x )
-     {     // This function needed if using RevSparseHes
-# ifndef NDEBUG
-          size_t m = s.size();
-          size_t n = t.size();
-# endif
-          assert( x.size() == n );
-          assert( r.size() == n );
-          assert( u.size() == m );
-          assert( v.size() == n );
-          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 W(x) = f'(x)^T * U(x) = [ 0, x0 ] * U(x)
-          //                                      [ 1, 0  ]
-          v[0] = u[1];
-          v[1] = u[1];
-          v[2] = u[0];
-          //
-          //                                      [ 0, 1, 0 ]
-          // sparsity for V(x) = W(x) + S_1 (x) * [ 1, 0, 0 ] * R
-          //                                      [ 0, 0, 0 ]
-          if( s[1] )
-          {     // v[0] = union( v[0], r[1] )
-               v[0] = set_union(v[0], r[1]);
-               // v[1] = union( v[1], r[0] )
-               v[1] = set_union(v[1], r[0]);
-          }
-          return true;
-     }
-
-End Class Definition - -

-}; // End of atomic_set_sparsity class
-}  // End empty namespace
-
-
-Test Atomic Function - -
bool set_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_set_sparsity afun("atomic_set_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);
-
-for_sparse_jac - -
     // correct Jacobian result
-     set_vector check_s(m);
-     check_s[0].insert(2);
-     check_s[1].insert(0);
-     check_s[1].insert(1);
-     // compute and test forward mode
-     {     set_vector r(n), s(m);
-          for(size_t i = 0; i < n; i++)
-               r[i].insert(i);
-          s = f.ForSparseJac(n, r);
-          for(size_t i = 0; i < m; i++)
-               ok &= s[i] == check_s[i];
-     }
-
-rev_sparse_jac - -
     // compute and test reverse mode
-     {     set_vector r(m), s(m);
-          for(size_t i = 0; i < m; i++)
-               r[i].insert(i);
-          s = f.RevSparseJac(m, r);
-          for(size_t i = 0; i < m; i++)
-               ok &= s[i] == check_s[i];
-     }
-
-for_sparse_hes - -
     // correct Hessian result
-     set_vector check_h(n);
-     check_h[0].insert(1);
-     check_h[1].insert(0);
-     // compute and test forward mode
-     {     set_vector r(1), s(1), h(n);
-          for(size_t i = 0; i < m; i++)
-               s[0].insert(i);
-          for(size_t j = 0; j < n; j++)
-               r[0].insert(j);
-          h = f.ForSparseHes(r, s);
-          for(size_t i = 0; i < n; i++)
-               ok &= h[i] == check_h[i];
-     }
-
-rev_sparse_hes -
-Note the previous call to ForSparseJac above -stored its results in -f -. -
     // compute and test reverse mode
-     {     set_vector s(1), h(n);
-          for(size_t i = 0; i < m; i++)
-               s[0].insert(i);
-          h = f.RevSparseHes(n, s);
-          for(size_t i = 0; i < n; i++)
-               ok &= h[i] == check_h[i];
-     }
-
-Test Result - -

-     return ok;
-}
-
- -
Input File: example/atomic/set_sparsity.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_set_sparsity.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_set_sparsity.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_set_sparsity.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_set_sparsity.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_set_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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_current0 = [ -'atomic_set_sparsity.cpp.xml#function', -'atomic_set_sparsity.cpp.xml#set_sparsity_enum', -'atomic_set_sparsity.cpp.xml#Start Class Definition', -'atomic_set_sparsity.cpp.xml#Constructor', -'atomic_set_sparsity.cpp.xml#forward', -'atomic_set_sparsity.cpp.xml#for_sparse_jac', -'atomic_set_sparsity.cpp.xml#rev_sparse_jac', -'atomic_set_sparsity.cpp.xml#for_sparse_hes', -'atomic_set_sparsity.cpp.xml#rev_sparse_hes', -'atomic_set_sparsity.cpp.xml#End Class Definition', -'atomic_set_sparsity.cpp.xml#Test Atomic Function', -'atomic_set_sparsity.cpp.xml#Test Atomic Function.Constructor', -'atomic_set_sparsity.cpp.xml#Test Atomic Function.Recording', -'atomic_set_sparsity.cpp.xml#Test Atomic Function.for_sparse_jac', -'atomic_set_sparsity.cpp.xml#Test Atomic Function.rev_sparse_jac', -'atomic_set_sparsity.cpp.xml#Test Atomic Function.for_sparse_hes', -'atomic_set_sparsity.cpp.xml#Test Atomic Function.rev_sparse_hes', -'atomic_set_sparsity.cpp.xml#Test Atomic Function.Test Result' -]; -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-2018.00.00.0/doc/atomic_tangent.cpp.xml cppad-2019.02.00.0/doc/atomic_tangent.cpp.xml --- cppad-2018.00.00.0/doc/atomic_tangent.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic_tangent.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,641 +0,0 @@ - - - -Tan and Tanh as User Atomic Operations: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -atomic_tangent.cpp - -

-
Tan and Tanh as User Atomic Operations: Example and Test
-
-Theory -
-The code below uses the tan_forward - and tan_reverse - -to implement the tangent and hyperbolic tangent -functions as user atomic operations. - -
-
-sparsity -
-This atomic operation can use both set and bool sparsity patterns. - - - -
-
-Start Class Definition - -
# include <cppad/cppad.hpp>
-namespace { // Begin empty namespace
-using CppAD::vector;
-//
-// a utility to compute the union of two sets.
-using CppAD::set_union;
-//
-class atomic_tangent : public CppAD::atomic_base<float> {
-
-Constructor - -
private:
-     const bool hyperbolic_; // is this hyperbolic tangent
-public:
-     // constructor
-     atomic_tangent(const char* name, bool hyperbolic)
-     : CppAD::atomic_base<float>(name),
-     hyperbolic_(hyperbolic)
-     { }
-private:
-
-forward - -
     // forward mode routine called by CppAD
-     bool forward(
-          size_t                    p ,
-          size_t                    q ,
-          const vector<bool>&      vx ,
-                vector<bool>&     vzy ,
-          const vector<float>&     tx ,
-                vector<float>&    tzy
-     )
-     {     size_t q1 = q + 1;
-# ifndef NDEBUG
-          size_t n  = tx.size()  / q1;
-          size_t m  = tzy.size() / q1;
-# endif
-          assert( n == 1 );
-          assert( m == 2 );
-          assert( p <= q );
-          size_t j, k;
-
-          // check if this is during the call to old_tan(id, ax, ay)
-          if( vx.size() > 0 )
-          {     // set variable flag for both y an z
-               vzy[0] = vx[0];
-               vzy[1] = vx[0];
-          }
-
-          if( p == 0 )
-          {     // z^{(0)} = tan( x^{(0)} ) or tanh( x^{(0)} )
-               if( hyperbolic_ )
-                    tzy[0] = float( tanh( tx[0] ) );
-               else     tzy[0] = float( tan( tx[0] ) );
-
-               // y^{(0)} = z^{(0)} * z^{(0)}
-               tzy[q1 + 0] = tzy[0] * tzy[0];
-
-               p++;
-          }
-          for(j = p; j <= q; j++)
-          {     float j_inv = 1.f / float(j);
-               if( hyperbolic_ )
-                    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[q1 + j-k] * float(k) * j_inv;
-
-               // y^{(j)} = sum_{k=0}^j z^{(k)} z^{(j-k)}
-               tzy[q1 + j] = 0.;
-               for(k = 0; k <= j; k++)
-                    tzy[q1 + j] += tzy[k] * tzy[j-k];
-          }
-
-          // All orders are implemented and there are no possible errors
-          return true;
-     }
-
-reverse - -
     // reverse mode routine called by CppAD
-     virtual bool reverse(
-          size_t                    q ,
-          const vector<float>&     tx ,
-          const vector<float>&    tzy ,
-                vector<float>&     px ,
-          const vector<float>&    pzy
-     )
-     {     size_t q1 = q + 1;
-# ifndef NDEBUG
-          size_t n  = tx.size()  / q1;
-          size_t m  = tzy.size() / q1;
-# endif
-          assert( px.size()  == n * q1 );
-          assert( pzy.size() == m * q1 );
-          assert( n == 1 );
-          assert( m == 2 );
-
-          size_t j, k;
-
-          // copy because partials w.r.t. y and z need to change
-          vector<float> qzy = pzy;
-
-          // initialize accumultion of reverse mode partials
-          for(k = 0; k < q1; k++)
-               px[k] = 0.;
-
-          // eliminate positive orders
-          for(j = q; j > 0; j--)
-          {     float j_inv = 1.f / float(j);
-               if( hyperbolic_ )
-                    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[q1 + j-k] * float(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] * float(k) * j_inv;
-
-               // 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;
-          }
-
-          // eliminate order zero
-          if( hyperbolic_ )
-               px[0] += qzy[0] * (1.f - tzy[q1 + 0]);
-          else
-               px[0] += qzy[0] * (1.f + tzy[q1 + 0]);
-
-          return true;
-     }
-
-for_sparse_jac - -
     // forward Jacobian sparsity routine called by CppAD
-     virtual bool for_sparse_jac(
-          size_t                                p ,
-          const vector<bool>&                   r ,
-                vector<bool>&                   s ,
-          const vector<float>&                  x )
-     {
-# ifndef NDEBUG
-          size_t n = r.size() / p;
-          size_t m = s.size() / p;
-# endif
-          assert( n == x.size() );
-          assert( n == 1 );
-          assert( m == 2 );
-
-          // sparsity for S(x) = f'(x) * R
-          for(size_t j = 0; j < p; j++)
-          {     s[0 * p + j] = r[j];
-               s[1 * p + j] = r[j];
-          }
-
-          return true;
-     }
-     // forward Jacobian sparsity routine called by CppAD
-     virtual bool for_sparse_jac(
-          size_t                                p ,
-          const vector< std::set<size_t> >&     r ,
-                vector< std::set<size_t> >&     s ,
-          const vector<float>&                  x )
-     {
-# ifndef NDEBUG
-          size_t n = r.size();
-          size_t m = s.size();
-# endif
-          assert( n == x.size() );
-          assert( n == 1 );
-          assert( m == 2 );
-
-          // sparsity for S(x) = f'(x) * R
-          s[0] = r[0];
-          s[1] = r[0];
-
-          return true;
-     }
-
-rev_sparse_jac - -
     // reverse Jacobian sparsity routine called by CppAD
-     virtual bool rev_sparse_jac(
-          size_t                                p ,
-          const vector<bool>&                  rt ,
-                vector<bool>&                  st ,
-          const vector<float>&                  x )
-     {
-# ifndef NDEBUG
-          size_t n = st.size() / p;
-          size_t m = rt.size() / p;
-# endif
-          assert( n == 1 );
-          assert( m == 2 );
-          assert( n == x.size() );
-
-          // sparsity for S(x)^T = f'(x)^T * R^T
-          for(size_t j = 0; j < p; j++)
-               st[j] = rt[0 * p + j] | rt[1 * p + j];
-
-          return true;
-     }
-     // reverse Jacobian sparsity routine called by CppAD
-     virtual bool rev_sparse_jac(
-          size_t                                p ,
-          const vector< std::set<size_t> >&    rt ,
-                vector< std::set<size_t> >&    st ,
-          const vector<float>&                  x )
-     {
-# ifndef NDEBUG
-          size_t n = st.size();
-          size_t m = rt.size();
-# endif
-          assert( n == 1 );
-          assert( m == 2 );
-          assert( n == x.size() );
-
-          // sparsity for S(x)^T = f'(x)^T * R^T
-          st[0] = set_union(rt[0], rt[1]);
-          return true;
-     }
-
-rev_sparse_hes - -
     // reverse Hessian sparsity routine called by CppAD
-     virtual bool rev_sparse_hes(
-          const vector<bool>&                   vx,
-          const vector<bool>&                   s ,
-                vector<bool>&                   t ,
-          size_t                                p ,
-          const vector<bool>&                   r ,
-          const vector<bool>&                   u ,
-                vector<bool>&                   v ,
-          const vector<float>&                  x )
-     {
-# ifndef NDEBUG
-          size_t m = s.size();
-          size_t n = t.size();
-# endif
-          assert( x.size() == n );
-          assert( r.size() == n * p );
-          assert( u.size() == m * p );
-          assert( v.size() == n * p );
-          assert( n == 1 );
-          assert( m == 2 );
-
-          // 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)
-          t[0] =  s[0] | s[1];
-
-          // 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;
-          size_t j;
-          for(j = 0; j < p; j++)
-               v[j] = u[ 0 * p + j ] | u[ 1 * p + j ];
-
-          // include forward Jacobian sparsity in Hessian sparsity
-          // (note sparsty for f''(x) * R same as for R)
-          if( s[0] | s[1] )
-          {     for(j = 0; j < p; j++)
-               {     // Visual Studio 2013 generates warning without bool below
-                    v[j] |= bool( r[j] );
-               }
-          }
-
-          return true;
-     }
-     // reverse Hessian sparsity routine called by CppAD
-     virtual bool rev_sparse_hes(
-          const vector<bool>&                   vx,
-          const vector<bool>&                   s ,
-                vector<bool>&                   t ,
-          size_t                                p ,
-          const vector< std::set<size_t> >&     r ,
-          const vector< std::set<size_t> >&     u ,
-                vector< std::set<size_t> >&     v ,
-          const vector<float>&                  x )
-     {
-# ifndef NDEBUG
-          size_t m = s.size();
-          size_t n = t.size();
-# endif
-          assert( x.size() == n );
-          assert( r.size() == n );
-          assert( u.size() == m );
-          assert( v.size() == n );
-          assert( n == 1 );
-          assert( m == 2 );
-
-          // 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)
-          t[0] =  s[0] | s[1];
-
-          // 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] = set_union(u[0], u[1]);
-
-          // include forward Jacobian sparsity in Hessian sparsity
-          // (note sparsty for f''(x) * R same as for R)
-          if( s[0] | s[1] )
-               v[0] = set_union(v[0], r[0]);
-
-          return true;
-     }
-
-End Class Definition - -

-}; // End of atomic_tangent class
-}  // End empty namespace
-
-
-Use Atomic Function - -
bool tangent(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     float eps = 10.f * CppAD::numeric_limits<float>::epsilon();
-
-Constructor - -

-     // --------------------------------------------------------------------
-     // Creater a tan and tanh object
-     atomic_tangent my_tan("my_tan", false), my_tanh("my_tanh", true);
-
-
-Recording - -
     // domain space vector
-     size_t n  = 1;
-     float  x0 = 0.5;
-     CppAD::vector< AD<float> > 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<float> > af(m);
-
-     // temporary vector for computations
-     // (my_tan and my_tanh computes tan or tanh and its square)
-     CppAD::vector< AD<float> > az(2);
-
-     // call atomic tan function and store tan(x) in f[0] (ignore tan(x)^2)
-     my_tan(ax, az);
-     af[0] = az[0];
-
-     // call atomic tanh function and store tanh(x) in f[1] (ignore tanh(x)^2)
-     my_tanh(ax, az);
-     af[1] = az[0];
-
-     // put a constant in f[2] = tanh(1.) (for sparsity pattern testing)
-     CppAD::vector< AD<float> > one(1);
-     one[0] = 1.;
-     my_tanh(one, az);
-     af[2] = az[0];
-
-     // create f: x -> f and stop tape recording
-     CppAD::ADFun<float> F;
-     F.Dependent(ax, af);
-
-forward - -
     // 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<float> 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<float> dx(n), df(m);
-     dx[0] = 1.;
-     df    = F.Forward(1, dx);
-
-reverse - -
     // compute derivative of tan - tanh using reverse mode
-     CppAD::vector<float> 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<float> ddx(n), ddf(m);
-     ddx[0] = 0.;
-     ddf    = F.Forward(2, ddx);
-
-     // compute second derivative of tan - tanh using reverse mode
-     CppAD::vector<float> 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);
-
-for_sparse_jac - -
     // 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]
-
-rev_sparse_jac - -
     // 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]
-
-rev_sparse_hes - -
     // 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
-
-Large x Values - -
     // check tanh results for a large value of x
-     x[0]  = std::numeric_limits<float>::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);
-
-     return ok;
-}
- -
Input File: example/atomic/tangent.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_tangent.cpp_xml.js cppad-2019.02.00.0/doc/_atomic_tangent.cpp_xml.js --- cppad-2018.00.00.0/doc/_atomic_tangent.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_tangent.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_tangent.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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_current0 = [ -'atomic_tangent.cpp.xml#Theory', -'atomic_tangent.cpp.xml#sparsity', -'atomic_tangent.cpp.xml#Start Class Definition', -'atomic_tangent.cpp.xml#Constructor', -'atomic_tangent.cpp.xml#forward', -'atomic_tangent.cpp.xml#reverse', -'atomic_tangent.cpp.xml#for_sparse_jac', -'atomic_tangent.cpp.xml#rev_sparse_jac', -'atomic_tangent.cpp.xml#rev_sparse_hes', -'atomic_tangent.cpp.xml#End Class Definition', -'atomic_tangent.cpp.xml#Use Atomic Function', -'atomic_tangent.cpp.xml#Use Atomic Function.Constructor', -'atomic_tangent.cpp.xml#Use Atomic Function.Recording', -'atomic_tangent.cpp.xml#Use Atomic Function.forward', -'atomic_tangent.cpp.xml#Use Atomic Function.reverse', -'atomic_tangent.cpp.xml#Use Atomic Function.for_sparse_jac', -'atomic_tangent.cpp.xml#Use Atomic Function.rev_sparse_jac', -'atomic_tangent.cpp.xml#Use Atomic Function.rev_sparse_hes', -'atomic_tangent.cpp.xml#Use Atomic Function.Large x Values' -]; -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-2018.00.00.0/doc/atomic.xml cppad-2019.02.00.0/doc/atomic.xml --- cppad-2018.00.00.0/doc/atomic.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/atomic.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ - - - -Atomic AD Functions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Atomic AD Functions
-
-Contents -
- -
checkpointCheckpointing Functions
atomic_baseUser Defined Atomic AD Functions
-
Input File: omh/atomic.omh - - - diff -Nru cppad-2018.00.00.0/doc/_atomic_xml.js cppad-2019.02.00.0/doc/_atomic_xml.js --- cppad-2018.00.00.0/doc/_atomic_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_atomic_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', -'atomic.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 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_current0 = [ -'atomic.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-2018.00.00.0/doc/autotools.xml cppad-2019.02.00.0/doc/autotools.xml --- cppad-2018.00.00.0/doc/autotools.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/autotools.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,714 +0,0 @@ - - - -Autotools Unix Test and Installation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -autotools - -

-
Autotools Unix Test and Installation
-
-Deprecated 2012-12-26 -
-This install procedure has 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. -We refer to the corresponding -distribution directory - as - -dist_dir -. - -
-
-Build Directory -
-Create the directory -dist_dir/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                      \
-     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 above is replaced values that you choose -(see discussion below). - -
-
-make -
-The following command, in the build directory, -copies the file configure.hpp from -the build to the source directory and then builds -some object libraries that are used by the tests: - -
-     make
-
-
-Examples and Tests -
-Once you have executed the make command, -you can run the correctness and speed tests. -The following command will build and run all the correctness and speed tests. -
 
-     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 - -
-     ./speed_profile 
test seed option_list
-
-see speed_main - for the meaning of the command line -arguments to this program. -After you have run a profiling speed test, -you can then obtain the profiling results with - -
-     gprof -b speed_profile
-
-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 speed_profile | 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-
yyyymmdd
-
-where -yyyymmdd - is the year, month, and day corresponding -to the version of CppAD. - -
-
---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-yyyymmdd
-
-(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-yyyymmdd/cppad.htm
-
-
---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 -. - -
-
-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-
yyyymmdd
-
-
-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/autotools.omh - - - diff -Nru cppad-2018.00.00.0/doc/_autotools_xml.js cppad-2019.02.00.0/doc/_autotools_xml.js --- cppad-2018.00.00.0/doc/_autotools_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_autotools_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'autotools.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', -'directory.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', -'autotools.xml' -]; -var list_current0 = [ -'autotools.xml#Deprecated 2012-12-26', -'autotools.xml#Distribution Directory', -'autotools.xml#Build Directory', -'autotools.xml#Configure', -'autotools.xml#make', -'autotools.xml#make.Examples and Tests', -'autotools.xml#Profiling CppAD', -'autotools.xml#prefix_dir', -'autotools.xml#--with-Documentation', -'autotools.xml#--with-testvector', -'autotools.xml#max_num_threads', -'autotools.xml#cxx_flags', -'autotools.xml#openmp_flags', -'autotools.xml#postfix_dir', -'autotools.xml#adolc_dir', -'autotools.xml#adolc_dir.Linux', -'autotools.xml#adolc_dir.Cygwin', -'autotools.xml#boost_dir', -'autotools.xml#eigen_dir', -'autotools.xml#fadbad_dir', -'autotools.xml#ipopt_dir', -'autotools.xml#sacado_dir', -'autotools.xml#tape_addr_type', -'autotools.xml#tape_id_type', -'autotools.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_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-2018.00.00.0/doc/azmul.cpp.xml cppad-2019.02.00.0/doc/azmul.cpp.xml --- cppad-2018.00.00.0/doc/azmul.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/azmul.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ - - - -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/general/azmul.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_azmul.cpp_xml.js cppad-2019.02.00.0/doc/_azmul.cpp_xml.js --- cppad-2018.00.00.0/doc/_azmul.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_azmul.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +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', -'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-2018.00.00.0/doc/azmul.xml cppad-2019.02.00.0/doc/azmul.xml --- cppad-2018.00.00.0/doc/azmul.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/azmul.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,227 +0,0 @@ - - - -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/core/azmul.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_azmul_xml.js cppad-2019.02.00.0/doc/_azmul_xml.js --- cppad-2018.00.00.0/doc/_azmul_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_azmul_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', -'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-2018.00.00.0/doc/base_adolc.hpp.xml cppad-2019.02.00.0/doc/base_adolc.hpp.xml --- cppad-2018.00.00.0/doc/base_adolc.hpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_adolc.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,438 +0,0 @@ - - - -Enable use of AD<Base> where Base is Adolc's adouble Type - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - -
Enable use of AD<Base> where Base is Adolc's adouble Type
-
-Syntax - -
- -# include <cppad/example/base_adolc.hpp>
-
-
-Example -
-The file mul_level_adolc.cpp - contains an example use of -Adolc's adouble type for a CppAD -Base - type. -It returns true if it succeeds and false otherwise. -The file mul_level_adolc_ode.cpp - contains a more realistic -(and complex) example. - -
-
-Include Files -
-This file base_adolc.hpp requires adouble to be defined. -In addition, it is included before <cppad/cppad.hpp>, -but it needs to include parts of CppAD that are used by this file. -This is done with the following include commands: -

-# include <adolc/adolc.h>
-# include <cppad/base_require.hpp>
-
-
-CondExpOp -
-The type adouble supports a conditional assignment function -with the syntax - -
-     condassign(
abcd)
-
-which evaluates to - -
-     
a = (b > 0) ? c : d;
-
-This enables one to include conditionals in the recording of -adouble operations and later evaluation for different -values of the independent variables -(in the same spirit as the CppAD CondExp - function). -
namespace CppAD {
-     inline adouble CondExpOp(
-          enum  CppAD::CompareOp     cop ,
-          const adouble            &left ,
-          const adouble           &right ,
-          const adouble        &trueCase ,
-          const adouble       &falseCase )
-     {     adouble result;
-          switch( cop )
-          {
-               case CompareLt: // left < right
-               condassign(result, right - left, trueCase, falseCase);
-               break;
-
-               case CompareLe: // left <= right
-               condassign(result, left - right, falseCase, trueCase);
-               break;
-
-               case CompareEq: // left == right
-               condassign(result, left - right, falseCase, trueCase);
-               condassign(result, right - left, falseCase, result);
-               break;
-
-               case CompareGe: // left >= right
-               condassign(result, right - left, falseCase, trueCase);
-               break;
-
-               case CompareGt: // left > right
-               condassign(result, left - right, trueCase, falseCase);
-               break;
-               default:
-               CppAD::ErrorHandler::Call(
-                    true     , __LINE__ , __FILE__ ,
-                    "CppAD::CondExp",
-                    "Error: for unknown reason."
-               );
-               result = trueCase;
-          }
-          return result;
-     }
-}
-
-CondExpRel -
-The CPPAD_COND_EXP_REL - macro invocation -

-namespace CppAD {
-     CPPAD_COND_EXP_REL(adouble)
-}
-
-
-EqualOpSeq -
-The Adolc user interface does not specify a way to determine if -two adouble variables correspond to the same operations sequence. -Make EqualOpSeq an error if it gets used: -
namespace CppAD {
-     inline bool EqualOpSeq(const adouble &x, const adouble &y)
-     {     CppAD::ErrorHandler::Call(
-               true     , __LINE__ , __FILE__ ,
-               "CppAD::EqualOpSeq(x, y)",
-               "Error: adouble does not support EqualOpSeq."
-          );
-          return false;
-     }
-}
-
-Identical -
-The Adolc user interface does not specify a way to determine if an -adouble depends on the independent variables. -To be safe (but slow) return false in all the cases below. -
namespace CppAD {
-     inline bool IdenticalPar(const adouble &x)
-     {     return false; }
-     inline bool IdenticalZero(const adouble &x)
-     {     return false; }
-     inline bool IdenticalOne(const adouble &x)
-     {     return false; }
-     inline bool IdenticalEqualPar(const adouble &x, const adouble &y)
-     {     return false; }
-}
-
-Integer - -

-     inline int Integer(const adouble &x)
-     {    return static_cast<int>( x.getValue() ); }
-
-
-azmul - -

-namespace CppAD {
-     CPPAD_AZMUL( adouble )
-}
-
-
-Ordered - -
namespace CppAD {
-     inline bool GreaterThanZero(const adouble &x)
-     {    return (x > 0); }
-     inline bool GreaterThanOrZero(const adouble &x)
-     {    return (x >= 0); }
-     inline bool LessThanZero(const adouble &x)
-     {    return (x < 0); }
-     inline bool LessThanOrZero(const adouble &x)
-     {    return (x <= 0); }
-     inline bool abs_geq(const adouble& x, const adouble& y)
-     {     return fabs(x) >= fabs(y); }
-}
-
-Unary Standard Math -
-The following required - functions -are defined by the Adolc package for the adouble base case: -
-
acos, -asin, -atan, -cos, -cosh, -exp, -fabs, -log, -sin, -sinh, -sqrt, -tan. - -
-
-erf, asinh, acosh, atanh, expm1, log1p -
-If the -erf, asinh, acosh, atanh, expm1, log1p -, -functions are supported by the compiler, -they must also be supported by a -Base - type; -The adolc package does not support these functions so make -their use an error: -
namespace CppAD {
-# 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
-}
-
-sign -
-This required - function is defined using the -codassign function so that its adouble operation sequence -does not depend on the value of -x -. -
namespace CppAD {
-     inline adouble sign(const adouble& x)
-     {     adouble s_plus, s_minus, half(.5);
-          // set s_plus to sign(x)/2,  except for case x == 0, s_plus = -.5
-          condassign(s_plus,  +x, -half, +half);
-          // set s_minus to -sign(x)/2, except for case x == 0, s_minus = -.5
-          condassign(s_minus, -x, -half, +half);
-          // set s to sign(x)
-          return s_plus - s_minus;
-     }
-}
-
-abs -
-This required - function uses the adolc fabs -function: -
namespace CppAD {
-     inline adouble abs(const adouble& x)
-     {     return fabs(x); }
-}
-
-pow -
-This required - function -is defined by the Adolc package for the adouble base case. - -
-
-numeric_limits -
-The following defines the CppAD numeric_limits - -for the type adouble: -

-namespace CppAD {
-     CPPAD_NUMERIC_LIMITS(double, adouble)
-}
-
-
-to_string -
-The following defines the CppAD to_string - function -for the type adouble: -
namespace CppAD {
-     template <> struct to_string_struct<adouble>
-     {     std::string operator()(const adouble& x)
-          {     std::stringstream os;
-               int n_digits = 1 + std::numeric_limits<double>::digits10;
-               os << std::setprecision(n_digits);
-               os << x.value();
-               return os.str();
-          }
-     };
-}
-
-hash_code -
-It appears that an adouble object can have fields -that are not initialized. -This results in a valgrind error when these fields are used by the -default - hashing function. -For this reason, the adouble class overrides the default definition. -
namespace CppAD {
-     inline unsigned short hash_code(const adouble& x)
-     {     unsigned short code = 0;
-          double value = x.value();
-          if( value == 0.0 )
-               return code;
-          double log_x = std::log( fabs( value ) );
-          // assume log( std::numeric_limits<double>::max() ) is near 700
-          code = static_cast<unsigned short>(
-               (CPPAD_HASH_TABLE_SIZE / 700 + 1) * log_x
-          );
-          code = code % CPPAD_HASH_TABLE_SIZE;
-          return code;
-     }
-}
-Note that after the hash codes match, the -Identical - function will be used -to make sure two values are the same and one can replace the other. -A more sophisticated implementation of the Identical function -would detect which adouble values depend on the -adouble independent variables (and hence can change). - - - -
Input File: cppad/example/base_adolc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_base_adolc.hpp_xml.js cppad-2019.02.00.0/doc/_base_adolc.hpp_xml.js --- cppad-2018.00.00.0/doc/_base_adolc.hpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_adolc.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -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_example.xml', -'base_adolc.hpp.xml' -]; -var list_down3 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down2 = [ -'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_hash.xml', -'base_example.xml' -]; -var list_down1 = [ -'base_alloc.hpp.xml', -'base_require.cpp.xml', -'base_adolc.hpp.xml', -'base_float.hpp.xml', -'base_double.hpp.xml', -'base_complex.hpp.xml' -]; -var list_down0 = [ -'mul_level_adolc.cpp.xml' -]; -var list_current0 = [ -'base_adolc.hpp.xml#Syntax', -'base_adolc.hpp.xml#Example', -'base_adolc.hpp.xml#Include Files', -'base_adolc.hpp.xml#CondExpOp', -'base_adolc.hpp.xml#CondExpRel', -'base_adolc.hpp.xml#EqualOpSeq', -'base_adolc.hpp.xml#Identical', -'base_adolc.hpp.xml#Integer', -'base_adolc.hpp.xml#azmul', -'base_adolc.hpp.xml#Ordered', -'base_adolc.hpp.xml#Unary Standard Math', -'base_adolc.hpp.xml#erf, asinh, acosh, atanh, expm1, log1p', -'base_adolc.hpp.xml#sign', -'base_adolc.hpp.xml#abs', -'base_adolc.hpp.xml#pow', -'base_adolc.hpp.xml#numeric_limits', -'base_adolc.hpp.xml#to_string', -'base_adolc.hpp.xml#hash_code' -]; -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-2018.00.00.0/doc/base_alloc.hpp.xml cppad-2019.02.00.0/doc/base_alloc.hpp.xml --- cppad-2018.00.00.0/doc/base_alloc.hpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_alloc.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,481 +0,0 @@ - - - -Example AD<Base> Where Base Constructor Allocates Memory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -base_alloc.hpp - -

-
Example AD<Base> Where Base Constructor Allocates Memory
-
-Purpose -
-Demonstrate use of -AD<Base> - -where memory is allocated for each element of the type -Base -. -In addition, this is a complete example where all the -required Base - type -operations are defined (as apposed to other examples where -some of the operations for the Base type are already defined). - -
-
-Include File -
-This file uses some of the definitions in base_require - -and thread_alloc -. -

-# include <cppad/base_require.hpp>
-# include <cppad/utility/thread_alloc.hpp>
-
-
-Compound Assignment Macro -
-This macro is used for the -base_alloc compound assignment operators; to be specific, -used with -op  - equal to -+=, --=, -*=, -/=. -

-# define BASE_ALLOC_ASSIGN_OPERATOR(op) \
-     void operator op (const base_alloc& x) \
-     {     *ptrdbl_ op *x.ptrdbl_; }
-
-
-Binary Operator Macro -
-This macro is used for the -base_alloc binary operators (as member functions); to be specific, -used with -op  - equal to -+, --, -*, -/. -
# define BASE_ALLOC_BINARY_OPERATOR(op) const \
-     base_alloc operator op (const base_alloc& x) const \
-     {     base_alloc result; \
-          double   dbl = *ptrdbl_; \
-          double x_dbl = *x.ptrdbl_; \
-          *result.ptrdbl_ = dbl op x_dbl; \
-          return result; \
-     }
-
-Boolean Operator Macro -
-This macro can be used for the -base_alloc binary operators that have a -bool result; to be specific, -used with -op  - equal to -==, -!=, -<, -<=, ->=, and ->, -
# define BASE_ALLOC_BOOL_OPERATOR(op) const \
-     bool operator op (const base_alloc& x) const \
-     {     double   dbl = *ptrdbl_; \
-          double x_dbl = *x.ptrdbl_; \
-          return dbl op x_dbl; \
-     }
-
-Class Definition -
-The following example class -defines the necessary base_member - functions. -It is made more complicated by storing a pointer to a double -instead of the double value itself. -

-class base_alloc {
-public:
-     double* ptrdbl_;
-
-     base_alloc(void)
-     {     size_t cap;
-          void* v  = CppAD::thread_alloc::get_memory(sizeof(double), cap);
-          ptrdbl_  = static_cast<double*>(v);
-     }
-     base_alloc(double dbl)
-     {     size_t cap;
-          void *v  = CppAD::thread_alloc::get_memory(sizeof(double), cap);
-          ptrdbl_  = static_cast<double*>(v);
-          *ptrdbl_ = dbl;
-     }
-     base_alloc(const base_alloc& x)
-     {     size_t cap;
-          void *v  = CppAD::thread_alloc::get_memory(sizeof(double), cap);
-          ptrdbl_  = static_cast<double*>(v);
-          *ptrdbl_ = *x.ptrdbl_;
-     }
-     ~base_alloc(void)
-     {     void* v  = static_cast<void*>(ptrdbl_);
-          CppAD::thread_alloc::return_memory(v);
-     }
-     base_alloc operator-(void) const
-     {     base_alloc result;
-          *result.ptrdbl_ = - *ptrdbl_;
-          return result;
-     }
-     base_alloc operator+(void) const
-     {     return *this; }
-     void operator=(const base_alloc& x)
-     {     *ptrdbl_ = *x.ptrdbl_; }
-     BASE_ALLOC_ASSIGN_OPERATOR(+=)
-     BASE_ALLOC_ASSIGN_OPERATOR(-=)
-     BASE_ALLOC_ASSIGN_OPERATOR(*=)
-     BASE_ALLOC_ASSIGN_OPERATOR(/=)
-     BASE_ALLOC_BINARY_OPERATOR(+)
-     BASE_ALLOC_BINARY_OPERATOR(-)
-     BASE_ALLOC_BINARY_OPERATOR(*)
-     BASE_ALLOC_BINARY_OPERATOR(/)
-     BASE_ALLOC_BOOL_OPERATOR(==)
-     BASE_ALLOC_BOOL_OPERATOR(!=)
-     // The <= operator is not necessary for the base type requirements
-     // (needed so we can use NearEqual with base_alloc arguments).
-     BASE_ALLOC_BOOL_OPERATOR(<=)
-};
-
-CondExpOp -
-The type base_alloc does not use CondExp - operations. -Hence its CondExpOp function is defined by -
namespace CppAD {
-     inline base_alloc CondExpOp(
-          enum CompareOp     cop          ,
-          const base_alloc&       left         ,
-          const base_alloc&       right        ,
-          const base_alloc&       exp_if_true  ,
-          const base_alloc&       exp_if_false )
-     {     // not used
-          assert(false);
-
-          // to void compiler error
-          return base_alloc();
-     }
-}
-
-CondExpRel -
-The CPPAD_COND_EXP_REL - macro invocation -

-namespace CppAD {
-     CPPAD_COND_EXP_REL(base_alloc)
-}
-
-uses CondExpOp above to -define -CondExpRel - for base_alloc arguments -and -Rel - equal to -Lt, Le, Eq, Ge, and Gt. - -
-
-EqualOpSeq -
-The type base_alloc is simple (in this respect) and so we define -
namespace CppAD {
-     inline bool EqualOpSeq(const base_alloc& x, const base_alloc& y)
-     {     return *x.ptrdbl_ == *y.ptrdbl_; }
-}
-
-Identical -
-The type base_alloc is simple (in this respect) and so we define -
namespace CppAD {
-     inline bool IdenticalPar(const base_alloc& x)
-     {     return true; }
-     inline bool IdenticalZero(const base_alloc& x)
-     {     return (*x.ptrdbl_ == 0.0); }
-     inline bool IdenticalOne(const base_alloc& x)
-     {     return (*x.ptrdbl_ == 1.0); }
-     inline bool IdenticalEqualPar(const base_alloc& x, const base_alloc& y)
-     {     return (*x.ptrdbl_ == *y.ptrdbl_); }
-}
-
-Output Operator - -
namespace CppAD {
-     std::ostream& operator << (std::ostream &os, const base_alloc& x)
-     {     os << *x.ptrdbl_;
-          return os;
-     }
-}
-
-Integer - -
namespace CppAD {
-     inline int Integer(const base_alloc& x)
-     {     return static_cast<int>(*x.ptrdbl_); }
-}
-
-azmul - -

-namespace CppAD {
-     CPPAD_AZMUL( base_alloc )
-}
-
-
-Ordered -
-The base_alloc type supports ordered comparisons -
namespace CppAD {
-     inline bool GreaterThanZero(const base_alloc& x)
-     {     return *x.ptrdbl_ > 0.0; }
-     inline bool GreaterThanOrZero(const base_alloc& x)
-     {     return *x.ptrdbl_ >= 0.0; }
-     inline bool LessThanZero(const base_alloc& x)
-     {     return *x.ptrdbl_ < 0.0; }
-     inline bool LessThanOrZero(const base_alloc& x)
-     {     return *x.ptrdbl_ <= 0.f; }
-     inline bool abs_geq(const base_alloc& x, const base_alloc& y)
-     {     return std::fabs(*x.ptrdbl_) >= std::fabs(*y.ptrdbl_); }
-}
-
-Unary Standard Math -
-The macro -CPPAD_STANDARD_MATH_UNARY - -would not work with the type base_alloc so we define -a special macro for this type: -

-# define BASE_ALLOC_STD_MATH(fun) \
-     inline base_alloc fun (const base_alloc& x) \
-     { return   std::fun(*x.ptrdbl_); }
-
-The following invocations of the macro above define the -unary standard math - functions -(except for abs): -
namespace CppAD {
-     BASE_ALLOC_STD_MATH(acos)
-     BASE_ALLOC_STD_MATH(asin)
-     BASE_ALLOC_STD_MATH(atan)
-     BASE_ALLOC_STD_MATH(cos)
-     BASE_ALLOC_STD_MATH(cosh)
-     BASE_ALLOC_STD_MATH(exp)
-     BASE_ALLOC_STD_MATH(fabs)
-     BASE_ALLOC_STD_MATH(log)
-     BASE_ALLOC_STD_MATH(log10)
-     BASE_ALLOC_STD_MATH(sin)
-     BASE_ALLOC_STD_MATH(sinh)
-     BASE_ALLOC_STD_MATH(sqrt)
-     BASE_ALLOC_STD_MATH(tan)
-     BASE_ALLOC_STD_MATH(tanh)
-}
-The absolute value function is special because it std name is -fabs -
namespace CppAD {
-     inline base_alloc abs(const base_alloc& x)
-     {     return fabs(x); }
-}
-
-erf, asinh, acosh, atanh, expm1, log1p -
-The following defines the -erf, asinh, acosh, atanh, expm1, log1p - functions -required by AD<base_alloc>: -
# 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
-
-sign -
-The following defines the CppAD::sign function that -is required to use AD<base_alloc>: -
namespace CppAD {
-     inline base_alloc sign(const base_alloc& x)
-     {     if( *x.ptrdbl_ > 0.0 )
-               return 1.0;
-          if( *x.ptrdbl_ == 0.0 )
-               return 0.0;
-          return -1.0;
-     }
-}
-
-pow -
-The following defines a CppAD::pow function that -is required to use AD<base_alloc>: -
namespace CppAD {
-     inline base_alloc pow(const base_alloc& x, const base_alloc& y)
-     { return std::pow(*x.ptrdbl_, *y.ptrdbl_); }
-}
-
-numeric_limits -
-The following defines the CppAD numeric_limits - -for the type base_alloc: -

-namespace CppAD {
-     CPPAD_NUMERIC_LIMITS(double, base_alloc)
-}
-
-
-to_string -
-The following defines the CppAD to_string - function -for the type base_alloc: -

-namespace CppAD {
-     CPPAD_TO_STRING(base_alloc)
-}
-
-
-hash_code -
-The default - hashing function does -not work well for this case because two different pointers can -have the same value. -
namespace CppAD {
-     inline unsigned short hash_code(const base_alloc& x)
-     {     unsigned short code = 0;
-          if( *x.ptrdbl_ == 0.0 )
-               return code;
-          double log_x = log( std::fabs( *x.ptrdbl_ ) );
-          // assume log( std::numeric_limits<double>::max() ) is near 700
-          code = static_cast<unsigned short>(
-               (CPPAD_HASH_TABLE_SIZE / 700 + 1) * log_x
-          );
-          code = code % CPPAD_HASH_TABLE_SIZE;
-          return code;
-     }
-}
- -
Input File: example/general/base_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_base_alloc.hpp_xml.js cppad-2019.02.00.0/doc/_base_alloc.hpp_xml.js --- cppad-2018.00.00.0/doc/_base_alloc.hpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_alloc.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -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_example.xml', -'base_alloc.hpp.xml' -]; -var list_down3 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down2 = [ -'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_hash.xml', -'base_example.xml' -]; -var list_down1 = [ -'base_alloc.hpp.xml', -'base_require.cpp.xml', -'base_adolc.hpp.xml', -'base_float.hpp.xml', -'base_double.hpp.xml', -'base_complex.hpp.xml' -]; -var list_current0 = [ -'base_alloc.hpp.xml#Purpose', -'base_alloc.hpp.xml#Include File', -'base_alloc.hpp.xml#Compound Assignment Macro', -'base_alloc.hpp.xml#Binary Operator Macro', -'base_alloc.hpp.xml#Boolean Operator Macro', -'base_alloc.hpp.xml#Class Definition', -'base_alloc.hpp.xml#CondExpOp', -'base_alloc.hpp.xml#CondExpRel', -'base_alloc.hpp.xml#EqualOpSeq', -'base_alloc.hpp.xml#Identical', -'base_alloc.hpp.xml#Output Operator', -'base_alloc.hpp.xml#Integer', -'base_alloc.hpp.xml#azmul', -'base_alloc.hpp.xml#Ordered', -'base_alloc.hpp.xml#Unary Standard Math', -'base_alloc.hpp.xml#erf, asinh, acosh, atanh, expm1, log1p', -'base_alloc.hpp.xml#sign', -'base_alloc.hpp.xml#pow', -'base_alloc.hpp.xml#numeric_limits', -'base_alloc.hpp.xml#to_string', -'base_alloc.hpp.xml#hash_code' -]; -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-2018.00.00.0/doc/base_complex.hpp.xml cppad-2019.02.00.0/doc/base_complex.hpp.xml --- cppad-2018.00.00.0/doc/base_complex.hpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_complex.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,356 +0,0 @@ - - - -Enable use of AD<Base> where Base is std::complex<double> - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - -
Enable use of AD<Base> where Base is std::complex<double>
-
-Example -
-The file complex_poly.cpp - contains an example use of -std::complex<double> type for a CppAD -Base - type. -It returns true if it succeeds and false otherwise. - -
-
-Include Order -
-This file is included before <cppad/cppad.hpp> -so it is necessary to define the error handler -in addition to including -base_require.hpp - -
# include <limits>
-# include <complex>
-# include <cppad/base_require.hpp>
-# include <cppad/core/cppad_assert.hpp>
-
-CondExpOp -
-The type std::complex<double> does not supports the -<, <=, ==, >=, and > operators; see -not ordered -. -Hence its CondExpOp function is defined by -
namespace CppAD {
-     inline std::complex<double> CondExpOp(
-          enum CppAD::CompareOp      cop        ,
-          const std::complex<double> &left      ,
-          const std::complex<double> &right     ,
-          const std::complex<double> &trueCase  ,
-          const std::complex<double> &falseCase )
-     {     CppAD::ErrorHandler::Call(
-               true     , __LINE__ , __FILE__ ,
-               "std::complex<float> CondExpOp(...)",
-               "Error: cannot use CondExp with a complex type"
-          );
-          return std::complex<double>(0);
-     }
-}
-
-CondExpRel -
-The CPPAD_COND_EXP_REL - macro invocation -

-namespace CppAD {
-     CPPAD_COND_EXP_REL( std::complex<double> )
-}
-
-used CondExpOp above to -define -CondExpRel - for std::complex<double> arguments -and -Rel - equal to -Lt, Le, Eq, Ge, and Gt. - -
-
-EqualOpSeq -
-Complex numbers do not carry operation sequence information. -Thus they are equal in this sense if and only if there values are equal. -
namespace CppAD {
-     inline bool EqualOpSeq(
-          const std::complex<double> &x ,
-          const std::complex<double> &y )
-     {     return x == y;
-     }
-}
-
-Identical -
-Complex numbers do not carry operation sequence information. -Thus they are all parameters so the identical functions just check values. -
namespace CppAD {
-     inline bool IdenticalPar(const std::complex<double> &x)
-     {     return true; }
-     inline bool IdenticalZero(const std::complex<double> &x)
-     {     return (x == std::complex<double>(0., 0.) ); }
-     inline bool IdenticalOne(const std::complex<double> &x)
-     {     return (x == std::complex<double>(1., 0.) ); }
-     inline bool IdenticalEqualPar(
-          const std::complex<double> &x, const std::complex<double> &y)
-     {     return (x == y); }
-}
-
-Ordered -
-Complex types do not support comparison operators, -
# undef  CPPAD_USER_MACRO
-# define CPPAD_USER_MACRO(Fun)                                     \
-inline bool Fun(const std::complex<double>& x)                     \
-{      CppAD::ErrorHandler::Call(                                  \
-               true     , __LINE__ , __FILE__ ,                    \
-               #Fun"(x)",                                          \
-               "Error: cannot use " #Fun " with x complex<double> " \
-       );                                                          \
-       return false;                                               \
-}
-namespace CppAD {
-     CPPAD_USER_MACRO(LessThanZero)
-     CPPAD_USER_MACRO(LessThanOrZero)
-     CPPAD_USER_MACRO(GreaterThanOrZero)
-     CPPAD_USER_MACRO(GreaterThanZero)
-     inline bool abs_geq(
-          const std::complex<double>& x ,
-          const std::complex<double>& y )
-     {     return std::abs(x) >= std::abs(y); }
-}
-
-Integer -
-The implementation of this function must agree -with the CppAD user specifications for complex arguments to the -Integer - function: -
namespace CppAD {
-     inline int Integer(const std::complex<double> &x)
-     {     return static_cast<int>( x.real() ); }
-}
-
-azmul - -

-namespace CppAD {
-     CPPAD_AZMUL( std::complex<double> )
-}
-
-
-isnan -
-The gcc 4.1.1 complier defines the function - -
-     int std::complex<double>::isnan( std::complex<double> 
z )
-
-(which is not specified in the C++ 1998 standard ISO/IEC 14882). -This causes an ambiguity between the function above and the CppAD -isnan - template function. -We avoid this ambiguity by defining a non-template version of -this function in the CppAD namespace. -
namespace CppAD {
-     inline bool isnan(const std::complex<double>& z)
-     {     return (z != z);
-     }
-}
-
-Valid Unary Math -
-The following macro invocations define the standard unary -math functions that are valid with complex arguments and are -required to use AD< std::complex<double> >. -
namespace CppAD {
-     CPPAD_STANDARD_MATH_UNARY(std::complex<double>, cos)
-     CPPAD_STANDARD_MATH_UNARY(std::complex<double>, cosh)
-     CPPAD_STANDARD_MATH_UNARY(std::complex<double>, exp)
-     CPPAD_STANDARD_MATH_UNARY(std::complex<double>, log)
-     CPPAD_STANDARD_MATH_UNARY(std::complex<double>, sin)
-     CPPAD_STANDARD_MATH_UNARY(std::complex<double>, sinh)
-     CPPAD_STANDARD_MATH_UNARY(std::complex<double>, sqrt)
-}
-
-Invalid Unary Math -
-The following macro definition and invocations define the standard unary -math functions that are invalid with complex arguments and are -required to use AD< std::complex<double> >. -
# undef  CPPAD_USER_MACRO
-# define CPPAD_USER_MACRO(Fun)                                     \
-inline std::complex<double> Fun(const std::complex<double>& x)     \
-{      CppAD::ErrorHandler::Call(                                  \
-               true     , __LINE__ , __FILE__ ,                    \
-               #Fun"(x)",                                          \
-               "Error: cannot use " #Fun " with x complex<double> " \
-       );                                                          \
-       return std::complex<double>(0);                             \
-}
-namespace CppAD {
-     CPPAD_USER_MACRO(abs)
-     CPPAD_USER_MACRO(fabs)
-     CPPAD_USER_MACRO(acos)
-     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
-}
-
-pow -
-The following defines a CppAD::pow function that -is required to use AD< std::complex<double> >: -
namespace CppAD {
-     inline std::complex<double> pow(
-          const std::complex<double> &x ,
-          const std::complex<double> &y )
-     {     return std::pow(x, y); }
-}
-
-numeric_limits -
-The following defines the CppAD numeric_limits - -for the type std::complex<double>: -

-namespace CppAD {
-     CPPAD_NUMERIC_LIMITS(double, std::complex<double>)
-}
-
-
-to_string -
-The following defines the function CppAD to_string - -for the type std::complex<double>: -

-namespace CppAD {
-     CPPAD_TO_STRING(std::complex<double>)
-}
-
- -
Input File: cppad/core/base_complex.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_base_complex.hpp_xml.js cppad-2019.02.00.0/doc/_base_complex.hpp_xml.js --- cppad-2018.00.00.0/doc/_base_complex.hpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_complex.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -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_example.xml', -'base_complex.hpp.xml' -]; -var list_down3 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down2 = [ -'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_hash.xml', -'base_example.xml' -]; -var list_down1 = [ -'base_alloc.hpp.xml', -'base_require.cpp.xml', -'base_adolc.hpp.xml', -'base_float.hpp.xml', -'base_double.hpp.xml', -'base_complex.hpp.xml' -]; -var list_down0 = [ -'complex_poly.cpp.xml' -]; -var list_current0 = [ -'base_complex.hpp.xml#Example', -'base_complex.hpp.xml#Include Order', -'base_complex.hpp.xml#CondExpOp', -'base_complex.hpp.xml#CondExpRel', -'base_complex.hpp.xml#EqualOpSeq', -'base_complex.hpp.xml#Identical', -'base_complex.hpp.xml#Ordered', -'base_complex.hpp.xml#Integer', -'base_complex.hpp.xml#azmul', -'base_complex.hpp.xml#isnan', -'base_complex.hpp.xml#Valid Unary Math', -'base_complex.hpp.xml#Invalid Unary Math', -'base_complex.hpp.xml#pow', -'base_complex.hpp.xml#numeric_limits', -'base_complex.hpp.xml#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-2018.00.00.0/doc/base_cond_exp.xml cppad-2019.02.00.0/doc/base_cond_exp.xml --- cppad-2018.00.00.0/doc/base_cond_exp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_cond_exp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,258 +0,0 @@ - - - -Base Type Requirements for Conditional Expressions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -base_cond_exp - -

- - - -
Base Type Requirements for Conditional Expressions
-
-Purpose -
-These definitions are required by the user's code to support the - -AD<Base> - type for CondExp - operations: - -
-
-CompareOp -
-The following enum type is used in the specifications below: -
 
-namespace CppAD {
-     // The conditional expression operator enum type
-     enum CompareOp
-     {    CompareLt, // less than
-          CompareLe, // less than or equal
-          CompareEq, // equal
-          CompareGe, // greater than or equal
-          CompareGt, // greater than
-          CompareNe  // not equal
-     };
-}
-
-
-CondExpTemplate -
-The type -Base - must support the syntax - -
-     
result = CppAD::CondExpOp(
-          
copleftrightexp_if_trueexp_if_false
-     )
-
-which computes implements the corresponding CondExp - -function when the result has prototype - -
-     
Base result
-
-The argument -cop - has prototype - -
-     enum CppAD::CompareOp 
cop
-
-The other arguments have the prototype - -
-     const 
Base&  left
-     const 
Base&  right
-     const 
Base&  exp_if_true
-     const 
Base&  exp_if_false
-
-
-Ordered Type -
-If -Base - is a relatively simple type -that supports -<, <=, ==, >=, and > operators -its CondExpOp function can be defined by - -
-namespace CppAD {
-     inline 
Base CondExpOp(
-     enum CppAD::CompareOp  cop            ,
-     const 
Base           &left          ,
-     const 
Base           &right         ,
-     const 
Base           &exp_if_true   ,
-     const 
Base           &exp_if_false  )
-     {    return CondExpTemplate(
-               cop, left, right, trueCase, falseCase);
-     }
-}
-
-For example, see -double CondExpOp -. -For an example of and implementation of CondExpOp with -a more involved -Base - type see -adolc CondExpOp -. - - -
-
-Not Ordered -
-If the type -Base - does not support ordering, -the CondExpOp function does not make sense. -In this case one might (but need not) define CondExpOp as follows: - -
-namespace CppAD {
-     inline 
Base CondExpOp(
-     enum CompareOp cop           ,
-     const 
Base   &left         ,
-     const 
Base   &right        ,
-     const 
Base   &exp_if_true  ,
-     const 
Base   &exp_if_false )
-     {    // attempt to use CondExp with a 
Base argument
-          assert(0);
-          return 
Base(0);
-     }
-}
-
-For example, see -complex CondExpOp -. - -
-
-CondExpRel -
-The macro invocation - -
-     CPPAD_COND_EXP_REL(
Base)
-
-uses CondExpOp above to define the following functions - -
-     CondExpLt(
leftrightexp_if_trueexp_if_false)
-     CondExpLe(
leftrightexp_if_trueexp_if_false)
-     CondExpEq(
leftrightexp_if_trueexp_if_false)
-     CondExpGe(
leftrightexp_if_trueexp_if_false)
-     CondExpGt(
leftrightexp_if_trueexp_if_false)
-
-where the arguments have type -Base -. -This should be done inside of the CppAD namespace. -For example, see -base_alloc -. - - -
Input File: cppad/core/base_cond_exp.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_base_cond_exp_xml.js cppad-2019.02.00.0/doc/_base_cond_exp_xml.js --- cppad-2018.00.00.0/doc/_base_cond_exp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_cond_exp_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', -'base_require.xml', -'base_cond_exp.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_hash.xml', -'base_example.xml' -]; -var list_current0 = [ -'base_cond_exp.xml#Purpose', -'base_cond_exp.xml#CompareOp', -'base_cond_exp.xml#CondExpTemplate', -'base_cond_exp.xml#CondExpTemplate.Ordered Type', -'base_cond_exp.xml#CondExpTemplate.Not Ordered', -'base_cond_exp.xml#CondExpRel' -]; -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-2018.00.00.0/doc/base_double.hpp.xml cppad-2019.02.00.0/doc/base_double.hpp.xml --- cppad-2018.00.00.0/doc/base_double.hpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_double.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,294 +0,0 @@ - - - -Enable use of AD<Base> where Base is double - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -base_double.hpp - -

- - - - -
Enable use of AD<Base> where Base is double
-
-CondExpOp -
-The type double is a relatively simple type that supports -<, <=, ==, >=, and > operators; see -ordered type -. -Hence its CondExpOp function is defined by -
namespace CppAD {
-     inline double CondExpOp(
-          enum CompareOp     cop          ,
-          const double&       left         ,
-          const double&       right        ,
-          const double&       exp_if_true  ,
-          const double&       exp_if_false )
-     {     return CondExpTemplate(cop, left, right, exp_if_true, exp_if_false);
-     }
-}
-
-CondExpRel -
-The CPPAD_COND_EXP_REL - macro invocation -

-namespace CppAD {
-     CPPAD_COND_EXP_REL(double)
-}
-
-uses CondExpOp above to -define -CondExpRel - for double arguments -and -Rel - equal to -Lt, Le, Eq, Ge, and Gt. - -
-
-EqualOpSeq -
-The type double is simple (in this respect) and so we define -
namespace CppAD {
-     inline bool EqualOpSeq(const double& x, const double& y)
-     {     return x == y; }
-}
-
-Identical -
-The type double is simple (in this respect) and so we define -
namespace CppAD {
-     inline bool IdenticalPar(const double& x)
-     {     return true; }
-     inline bool IdenticalZero(const double& x)
-     {     return (x == 0.); }
-     inline bool IdenticalOne(const double& x)
-     {     return (x == 1.); }
-     inline bool IdenticalEqualPar(const double& x, const double& y)
-     {     return (x == y); }
-}
-
-Integer - -
namespace CppAD {
-     inline int Integer(const double& x)
-     {     return static_cast<int>(x); }
-}
-
-azmul - -

-namespace CppAD {
-     CPPAD_AZMUL( double )
-}
-
-
-Ordered -
-The double type supports ordered comparisons -
namespace CppAD {
-     inline bool GreaterThanZero(const double& x)
-     {     return x > 0.; }
-     inline bool GreaterThanOrZero(const double& x)
-     {     return x >= 0.; }
-     inline bool LessThanZero(const double& x)
-     {     return x < 0.; }
-     inline bool LessThanOrZero(const double& x)
-     {     return x <= 0.; }
-     inline bool abs_geq(const double& x, const double& y)
-     {     return std::fabs(x) >= std::fabs(y); }
-}
-
-Unary Standard Math -
-The following macro invocations import the double versions of -the unary standard math functions into the CppAD namespace. -Importing avoids ambiguity errors when using both the -CppAD and std namespaces. -Note this also defines the float - -versions of these functions. -
namespace CppAD {
-     using std::acos;
-     using std::asin;
-     using std::atan;
-     using std::cos;
-     using std::cosh;
-     using std::exp;
-     using std::fabs;
-     using std::log;
-     using std::log10;
-     using std::sin;
-     using std::sinh;
-     using std::sqrt;
-     using std::tan;
-     using std::tanh;
-# if CPPAD_USE_CPLUSPLUS_2011
-     using std::erf;
-     using std::asinh;
-     using std::acosh;
-     using std::atanh;
-     using std::expm1;
-     using std::log1p;
-# endif
-}
-The absolute value function is special because its std name is -fabs -
namespace CppAD {
-     inline double abs(const double& x)
-     {     return std::fabs(x); }
-}
-
-sign -
-The following defines the CppAD::sign function that -is required to use AD<double>: -
namespace CppAD {
-     inline double sign(const double& x)
-     {     if( x > 0. )
-               return 1.;
-          if( x == 0. )
-               return 0.;
-          return -1.;
-     }
-}
-
-pow -
-The following defines a CppAD::pow function that -is required to use AD<double>. -As with the unary standard math functions, -this has the exact same signature as std::pow, -so use it instead of defining another function. -

-namespace CppAD {
-     using std::pow;
-}
-
-
-numeric_limits -
-The following defines the CppAD numeric_limits - -for the type double: -

-namespace CppAD {
-     CPPAD_NUMERIC_LIMITS(double, double)
-}
-
-
-to_string -
-There is no need to define to_string for double -because it is defined by including cppad/utility/to_string.hpp; -see to_string -. -See base_complex.hpp - for an example where -it is necessary to define to_string for a -Base - type. - - -
Input File: cppad/core/base_double.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_base_double.hpp_xml.js cppad-2019.02.00.0/doc/_base_double.hpp_xml.js --- cppad-2018.00.00.0/doc/_base_double.hpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_double.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -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_example.xml', -'base_double.hpp.xml' -]; -var list_down3 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down2 = [ -'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_hash.xml', -'base_example.xml' -]; -var list_down1 = [ -'base_alloc.hpp.xml', -'base_require.cpp.xml', -'base_adolc.hpp.xml', -'base_float.hpp.xml', -'base_double.hpp.xml', -'base_complex.hpp.xml' -]; -var list_current0 = [ -'base_double.hpp.xml#CondExpOp', -'base_double.hpp.xml#CondExpRel', -'base_double.hpp.xml#EqualOpSeq', -'base_double.hpp.xml#Identical', -'base_double.hpp.xml#Integer', -'base_double.hpp.xml#azmul', -'base_double.hpp.xml#Ordered', -'base_double.hpp.xml#Unary Standard Math', -'base_double.hpp.xml#sign', -'base_double.hpp.xml#pow', -'base_double.hpp.xml#numeric_limits', -'base_double.hpp.xml#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-2018.00.00.0/doc/base_example.xml cppad-2019.02.00.0/doc/base_example.xml --- cppad-2018.00.00.0/doc/base_example.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_example.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ - - - -Example AD Base Types That are not AD<OtherBase> - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - -
Example AD Base Types That are not AD<OtherBase>
-
-Contents -
- -
Input File: omh/base_require/base_example.omh - - - diff -Nru cppad-2018.00.00.0/doc/_base_example_xml.js cppad-2019.02.00.0/doc/_base_example_xml.js --- cppad-2018.00.00.0/doc/_base_example_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_example_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -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_example.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_hash.xml', -'base_example.xml' -]; -var list_down0 = [ -'base_alloc.hpp.xml', -'base_require.cpp.xml', -'base_adolc.hpp.xml', -'base_float.hpp.xml', -'base_double.hpp.xml', -'base_complex.hpp.xml' -]; -var list_current0 = [ -'base_example.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-2018.00.00.0/doc/base_float.hpp.xml cppad-2019.02.00.0/doc/base_float.hpp.xml --- cppad-2018.00.00.0/doc/base_float.hpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_float.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,291 +0,0 @@ - - - -Enable use of AD<Base> where Base is float - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -base_float.hpp - -

-
Enable use of AD<Base> where Base is float
-
-CondExpOp -
-The type float is a relatively simple type that supports -<, <=, ==, >=, and > operators; see -ordered type -. -Hence its CondExpOp function is defined by -
namespace CppAD {
-     inline float CondExpOp(
-          enum CompareOp     cop          ,
-          const float&       left         ,
-          const float&       right        ,
-          const float&       exp_if_true  ,
-          const float&       exp_if_false )
-     {     return CondExpTemplate(cop, left, right, exp_if_true, exp_if_false);
-     }
-}
-
-CondExpRel -
-The CPPAD_COND_EXP_REL - macro invocation -

-namespace CppAD {
-     CPPAD_COND_EXP_REL(float)
-}
-
-uses CondExpOp above to -define -CondExpRel - for float arguments -and -Rel - equal to -Lt, Le, Eq, Ge, and Gt. - -
-
-EqualOpSeq -
-The type float is simple (in this respect) and so we define -
namespace CppAD {
-     inline bool EqualOpSeq(const float& x, const float& y)
-     {     return x == y; }
-}
-
-Identical -
-The type float is simple (in this respect) and so we define -
namespace CppAD {
-     inline bool IdenticalPar(const float& x)
-     {     return true; }
-     inline bool IdenticalZero(const float& x)
-     {     return (x == 0.f); }
-     inline bool IdenticalOne(const float& x)
-     {     return (x == 1.f); }
-     inline bool IdenticalEqualPar(const float& x, const float& y)
-     {     return (x == y); }
-}
-
-Integer - -
namespace CppAD {
-     inline int Integer(const float& x)
-     {     return static_cast<int>(x); }
-}
-
-azmul - -

-namespace CppAD {
-     CPPAD_AZMUL( float )
-}
-
-
-Ordered -
-The float type supports ordered comparisons -
namespace CppAD {
-     inline bool GreaterThanZero(const float& x)
-     {     return x > 0.f; }
-     inline bool GreaterThanOrZero(const float& x)
-     {     return x >= 0.f; }
-     inline bool LessThanZero(const float& x)
-     {     return x < 0.f; }
-     inline bool LessThanOrZero(const float& x)
-     {     return x <= 0.f; }
-     inline bool abs_geq(const float& x, const float& y)
-     {     return std::fabs(x) >= std::fabs(y); }
-}
-
-Unary Standard Math -
-The following macro invocations import the float versions of -the unary standard math functions into the CppAD namespace. -Importing avoids ambiguity errors when using both the -CppAD and std namespaces. -Note this also defines the double - -versions of these functions. -
namespace CppAD {
-     using std::acos;
-     using std::asin;
-     using std::atan;
-     using std::cos;
-     using std::cosh;
-     using std::exp;
-     using std::fabs;
-     using std::log;
-     using std::log10;
-     using std::sin;
-     using std::sinh;
-     using std::sqrt;
-     using std::tan;
-     using std::tanh;
-# if CPPAD_USE_CPLUSPLUS_2011
-     using std::erf;
-     using std::asinh;
-     using std::acosh;
-     using std::atanh;
-     using std::expm1;
-     using std::log1p;
-# endif
-}
-
-The absolute value function is special because its std name is -fabs -
namespace CppAD {
-     inline float abs(const float& x)
-     {     return std::fabs(x); }
-}
-
-sign -
-The following defines the CppAD::sign function that -is required to use AD<float>: -
namespace CppAD {
-     inline float sign(const float& x)
-     {     if( x > 0.f )
-               return 1.f;
-          if( x == 0.f )
-               return 0.f;
-          return -1.f;
-     }
-}
-
-pow -
-The following defines a CppAD::pow function that -is required to use AD<float>. -As with the unary standard math functions, -this has the exact same signature as std::pow, -so use it instead of defining another function. -

-namespace CppAD {
-     using std::pow;
-}
-
-
-numeric_limits -
-The following defines the CppAD numeric_limits - -for the type float: -

-namespace CppAD {
-     CPPAD_NUMERIC_LIMITS(float, float)
-}
-
-
-to_string -
-There is no need to define to_string for float -because it is defined by including cppad/utility/to_string.hpp; -see to_string -. -See base_complex.hpp - for an example where -it is necessary to define to_string for a -Base - type. - - -
Input File: cppad/core/base_float.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_base_float.hpp_xml.js cppad-2019.02.00.0/doc/_base_float.hpp_xml.js --- cppad-2018.00.00.0/doc/_base_float.hpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_float.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -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_example.xml', -'base_float.hpp.xml' -]; -var list_down3 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down2 = [ -'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_hash.xml', -'base_example.xml' -]; -var list_down1 = [ -'base_alloc.hpp.xml', -'base_require.cpp.xml', -'base_adolc.hpp.xml', -'base_float.hpp.xml', -'base_double.hpp.xml', -'base_complex.hpp.xml' -]; -var list_current0 = [ -'base_float.hpp.xml#CondExpOp', -'base_float.hpp.xml#CondExpRel', -'base_float.hpp.xml#EqualOpSeq', -'base_float.hpp.xml#Identical', -'base_float.hpp.xml#Integer', -'base_float.hpp.xml#azmul', -'base_float.hpp.xml#Ordered', -'base_float.hpp.xml#Unary Standard Math', -'base_float.hpp.xml#sign', -'base_float.hpp.xml#pow', -'base_float.hpp.xml#numeric_limits', -'base_float.hpp.xml#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-2018.00.00.0/doc/base_hash.xml cppad-2019.02.00.0/doc/base_hash.xml --- cppad-2018.00.00.0/doc/base_hash.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_hash.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,194 +0,0 @@ - - - -Base Type Requirements for Hash Coding Values - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -base_hash - -

-
Base Type Requirements for Hash Coding Values
-
-Syntax - -
- -code = hash_code(x) - - -
-
-Purpose -
-CppAD uses a table of -Base - type values when recording - -AD<Base> - operations. -A hashing function is used to reduce number of values stored in this table; -for example, it is not necessary to store the value 3.0 every -time it is used as a parameter -. - -
-
-Default -
-The default hashing function works with the set of bits that correspond -to a -Base - value. -In most cases this works well, but in some cases -it does not. For example, in the -base_adolc.hpp - case, an adouble value can have -fields that are not initialized and valgrind reported an error -when these are used to form the hash code. - -
-
-x -
-This argument has prototype - -
-     const 
Basex
-
-It is the value we are forming a hash code for. - -
-
-code -
-The return value -code - has prototype - -
-     unsigned short 
code
-
-It is the hash code corresponding to -x -. This intention is the -commonly used values will have different hash codes. -The hash code must satisfy - -
-     
code < CPPAD_HASH_TABLE_SIZE
-
-so that it is a valid index into the hash code table. - -
-
-inline -
-If you define this function, it should declare it to be inline, -so that you do not get multiple definitions from different compilation units. - -
-
-Example -
-See the base_alloc hash_code - -and the adouble hash_code -. - - -
Input File: cppad/core/base_hash.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_base_hash_xml.js cppad-2019.02.00.0/doc/_base_hash_xml.js --- cppad-2018.00.00.0/doc/_base_hash_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_hash_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', -'ad.xml', -'base_require.xml', -'base_hash.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_hash.xml', -'base_example.xml' -]; -var list_current0 = [ -'base_hash.xml#Syntax', -'base_hash.xml#Purpose', -'base_hash.xml#Default', -'base_hash.xml#x', -'base_hash.xml#code', -'base_hash.xml#inline', -'base_hash.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-2018.00.00.0/doc/base_identical.xml cppad-2019.02.00.0/doc/base_identical.xml --- cppad-2018.00.00.0/doc/base_identical.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_identical.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,348 +0,0 @@ - - - -Base Type Requirements for Identically Equal Comparisons - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -base_identical - -

- - - -
Base Type Requirements for Identically Equal Comparisons
-
-EqualOpSeq -
-If function EqualOpSeq - is used with -arguments of type -AD<Base> -, -the type -Base - must support the syntax - -
-     
b = CppAD::EqualOpSeq(uv)
-
-This should return true if and only if - -u - is identically equal to -v - -and it makes no different which one is used. -The arguments -u - and -v - have prototype - -
-     const 
Baseu
-     const 
Basev
-
-The return value -b - has prototype - -
-     bool 
b
-
-
-The Simple Case -
-If -Base - is a relatively simple type, -the EqualOpSeq function can be defined by - -
-namespace CppAD {
-     inline 
Base EqualOpSeq(const Base& u, const Base& v)
-     {    return u == v; }
-}
-
-For example, see -base_alloc -. - -
-
-More Complicated Cases -
-The variables - -u - and -v - are not identically equal in the following case -(which CppAD automatically defines EqualOpSeq for): -The type -Base - is -AD<double> -, - -x[0] = x[1] = 1. -, -then independent - is used to make -x - the independent -variable vector, -and then -u = x[0] -, -v = x[1] -, -Note that during a future Forward - calculation, - -u - and -v - could correspond to different values. -For example, see -adolc EqualOpSeq -. - -
-
-Identical - - -
-
-IdenticalPar -
-A -Base - is a parameter - -when used in an -AD<Base> - operation sequence. -It is however still possible for a parameter to change its value. -For example, -the -Base - value -u - is not identically a parameter -equal in the following case -(which CppAD automatically defines IdenticalPar for): -The type -Base - is -AD<double> -, - -x[0] = 1. -, -then independent - is used to make -x - the independent -variable vector, -and then -u = x[0] -, -Note that during a future Forward - calculation, - -u - could correspond to different values. - -
-
-Prototypes -
-The argument -u - has prototype - -
-     const 
Base u
-
-If it is present, the argument -v - has prototype - -
-     const 
Base v
-
-The result -b - has prototype - -
-     bool 
b
-
-
-Identical Functions -
-The type -Base - must support the following functions -(in the CppAD namespace): - -
- -Syntax - Result -
- - -b = IdenticalPar(u) -    - - the -Base - value will always be the same -
- - -b = IdenticalZero(u) -    - - -u - equals zero and -IdenticalPar(u) - -
- - -b = IdenticalOne(u) -    - - -u - equals one and -IdenticalPar(u) - -
- - -b = IdenticalEqualPar(uv) -    - - -u - equals -v -, - -IdenticalPar(u) - and - -IdenticalPar(v) - -
-
-Examples -
-See -base_alloc -. - - -
Input File: omh/base_require/base_identical.omh - - - diff -Nru cppad-2018.00.00.0/doc/_base_identical_xml.js cppad-2019.02.00.0/doc/_base_identical_xml.js --- cppad-2018.00.00.0/doc/_base_identical_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_identical_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -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_identical.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_hash.xml', -'base_example.xml' -]; -var list_current0 = [ -'base_identical.xml#EqualOpSeq', -'base_identical.xml#EqualOpSeq.The Simple Case', -'base_identical.xml#EqualOpSeq.More Complicated Cases', -'base_identical.xml#Identical', -'base_identical.xml#Identical.IdenticalPar', -'base_identical.xml#Identical.Prototypes', -'base_identical.xml#Identical.Identical Functions', -'base_identical.xml#Identical.Examples' -]; -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-2018.00.00.0/doc/base_limits.xml cppad-2019.02.00.0/doc/base_limits.xml --- cppad-2018.00.00.0/doc/base_limits.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_limits.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,165 +0,0 @@ - - - -Base Type Requirements for Numeric Limits - - - - - - - - - - - - - - - - -
- -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() ); }\
-     static const int digits10 = std::numeric_limits<Other>::digits10;\
-};
- -
Input File: cppad/core/base_limits.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_base_limits_xml.js cppad-2019.02.00.0/doc/_base_limits_xml.js --- cppad-2018.00.00.0/doc/_base_limits_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_limits_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -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_hash.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-2018.00.00.0/doc/base_member.xml cppad-2019.02.00.0/doc/base_member.xml --- cppad-2018.00.00.0/doc/base_member.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_member.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,267 +0,0 @@ - - - -Required Base Class Member Functions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -base_member - -

-
Required Base Class Member Functions
-
-Notation - - -
- -Symbol - Meaning
- - -Base - - - The base type corresponding to -AD<Base> - -
- - -b - - - An object of type bool -
- - -d - - - An object of type double -
- - -x - - - An object of type -const Base& - -
- - -y - - - An object of type -const Base& - -
- - -z - - - An object of type -Base - -
- -
-
-Default Constructor - -
- -Base z - - -
-
-Double Constructor - -
- -Base z(d) - - -
-
-Copy Constructor - -
- -Base z(x) - - -
-
-Unary Operators -
-For op equal to -+, -- -the following operation must be supported: - -
-     
z = op x
- - -
-
-Assignment Operators -
-For -op - equal to - -= -, -+=, --=, -*=, and -/= the following operation must be supported: - -
-     
z op x
- - -
-
-Binary Operators -
-For -op - equal to -+, --, -*, and -/ the following operation must be supported: - -
-     
z = x op y
- - -
-
-Bool Operators -
-For -op - equal to -==, -!=, -<=, -the following operation must be supported: - -
-     
b = x op y
- - -
-
-Example -
-See the heading Class Definition in -base_alloc -. - - -
Input File: omh/base_require/base_member.omh - - - diff -Nru cppad-2018.00.00.0/doc/_base_member_xml.js cppad-2019.02.00.0/doc/_base_member_xml.js --- cppad-2018.00.00.0/doc/_base_member_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_member_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -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_member.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_hash.xml', -'base_example.xml' -]; -var list_current0 = [ -'base_member.xml#Notation', -'base_member.xml#Default Constructor', -'base_member.xml#Double Constructor', -'base_member.xml#Copy Constructor', -'base_member.xml#Unary Operators', -'base_member.xml#Assignment Operators', -'base_member.xml#Binary Operators', -'base_member.xml#Bool Operators', -'base_member.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-2018.00.00.0/doc/base_ordered.xml cppad-2019.02.00.0/doc/base_ordered.xml --- cppad-2018.00.00.0/doc/base_ordered.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_ordered.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,247 +0,0 @@ - - - -Base Type Requirements for Ordered Comparisons - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -base_ordered - -

- - - -
Base Type Requirements for Ordered Comparisons
-
-Purpose -
-The following operations -(in the CppAD namespace) are required to use the type - -AD<Base> -: - - -
- -Syntax - Result -
- - -b = GreaterThanZero(x) -    - - - -x -> -0 - - - -
- - -b = GreaterThanOrZero(x) -    - - - -x - -0 - - - -
- - -b = LessThanZero(x) -    - - - -x -< -0 - - - -
- - -b = LessThanOrZero(x) -    - - - -x - -0 - - - -
- - -b = abs_geq(xy) -    - - - -| -x -| - -| -y -| - - -. -
-where the arguments and return value have the prototypes - -
-     const 
Basex
-     const 
Basey
-     bool  
      b
-
-
-Ordered Type -
-If the type -Base - supports ordered operations, -these functions should have their corresponding definitions. -For example, - -
-namespace CppAD {
-     inline bool GreaterThanZero(const 
Base &x)
-     {    return (x > 0);
-     }
-}
-
-The other functions would replace > by the corresponding operator. -For example, see -base_alloc -. - - -
-
-Not Ordered -
-If the type -Base - does not support ordering, -one might (but need not) define GreaterThanZero as follows: - -
-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 -complex Ordered -. - - -
Input File: omh/base_require/base_ordered.omh - - - diff -Nru cppad-2018.00.00.0/doc/_base_ordered_xml.js cppad-2019.02.00.0/doc/_base_ordered_xml.js --- cppad-2018.00.00.0/doc/_base_ordered_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_ordered_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', -'base_require.xml', -'base_ordered.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_hash.xml', -'base_example.xml' -]; -var list_current0 = [ -'base_ordered.xml#Purpose', -'base_ordered.xml#Ordered Type', -'base_ordered.xml#Not Ordered' -]; -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-2018.00.00.0/doc/base_require.cpp.xml cppad-2019.02.00.0/doc/base_require.cpp.xml --- cppad-2018.00.00.0/doc/base_require.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_require.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ - - - -Using a User Defined AD Base Type: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -base_require.cpp - -

-
Using a User Defined AD Base Type: Example and Test
-
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include "base_alloc.hpp"
-# include <cppad/cppad.hpp>
-
-bool base_require(void)
-{     bool ok = true;
-     using CppAD::thread_alloc;
-     typedef CppAD::AD<base_alloc> ad_base_alloc;
-
-     // check the amount of memory inuse by this thread (thread zero)
-     size_t thread = thread_alloc::thread_num();
-     ok &= thread == 0;
-
-     // y = x^2
-     size_t n = 1, m = 1;
-     CPPAD_TESTVECTOR(ad_base_alloc) a_x(n), a_y(m);
-     a_x[0] = ad_base_alloc(1.);
-     CppAD::Independent(a_x);
-     a_y[0] = a_x[0] * a_x[0];
-     CppAD::ADFun<base_alloc> f(a_x, a_y);
-
-     // check function value f(x) = x^2
-     CPPAD_TESTVECTOR(base_alloc) x(n), y(m);
-     base_alloc eps =
-          base_alloc(100.) * CppAD::numeric_limits<base_alloc>::epsilon();
-     x[0] = base_alloc(3.);
-     y    = f.Forward(0, x);
-     ok  &= CppAD::NearEqual(y[0], x[0] * x[0], eps, eps);
-
-     // check derivative value f'(x) = 2 * x
-     CPPAD_TESTVECTOR(base_alloc) dy(m * n);
-     dy   = f.Jacobian(x);
-     ok  &= CppAD::NearEqual(dy[0], base_alloc(2.) * x[0], eps, eps);
-
-     return ok;
-}
-
Purpose -
-The type base_alloc, defined in base_alloc.hpp -, -meets the requirements specified by base_require - -for -Base - in -AD<Base> -. -The program below is an example use of -AD<base_alloc> -. - - -
Input File: example/general/base_require.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_base_require.cpp_xml.js cppad-2019.02.00.0/doc/_base_require.cpp_xml.js --- cppad-2018.00.00.0/doc/_base_require.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_require.cpp_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', -'ad.xml', -'base_require.xml', -'base_example.xml', -'base_require.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 = [ -'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_hash.xml', -'base_example.xml' -]; -var list_down1 = [ -'base_alloc.hpp.xml', -'base_require.cpp.xml', -'base_adolc.hpp.xml', -'base_float.hpp.xml', -'base_double.hpp.xml', -'base_complex.hpp.xml' -]; -var list_current0 = [ -'base_require.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-2018.00.00.0/doc/base_require.xml cppad-2019.02.00.0/doc/base_require.xml --- cppad-2018.00.00.0/doc/base_require.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_require.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,279 +0,0 @@ - - - -AD<Base> Requirements for a CppAD Base Type - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
AD<Base> Requirements for a CppAD Base Type
-
-Syntax - -
-# include <cppad/base_require.hpp>
- -
-
-Purpose -
-This section lists the requirements for the type - -Base - so that the type -AD<Base> - can be used. - -
-
-API Warning -
-Defining a CppAD -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 base_require in the -current whats_new - section for these changes. - -
-
-Standard Base Types -
-In the case where -Base - is -float, -double, -std::complex<float>, -std::complex<double>, -or -AD<Other> -, -these requirements are provided by including the file -cppad/cppad.hpp. - -
-
-Include Order -
-If you are linking a non-standard base type to CppAD, -you must first include the file cppad/base_require.hpp, -then provide the specifications below, -and then include the file cppad/cppad.hpp. - -
-
-Numeric Type -
-The type -Base - must support all the operations for a -NumericType -. - -
-
-Output Operator -
-The type -Base - must support the syntax - -
-     
os << x
-
-where -os - is an std::ostream& -and -x - is a const base_alloc&. -For example, see -base_alloc -. - -
-
-Integer -
-The type -Base - must support the syntax - -
-     
i = CppAD::Integer(x)
-
-which converts -x - to an int. -The argument -x - has prototype - -
-     const 
Basex
-
-and the return value -i - has prototype - -
-     int 
i
-
-
-Suggestion -
-In many cases, the -Base - version of the Integer function -can be defined by - -
-namespace CppAD {
-     inline int Integer(const 
Base& x)
-     {    return static_cast<int>(x); }
-}
-
-For example, see -base_float - and -base_alloc -. - -
-
-Absolute Zero, azmul -
-The type -Base - must support the syntax - -
-     
z = azmul(xy)
-
-see; azmul -. -The following preprocessor macro invocation suffices -(for most -Base - types): - -
-namespace CppAD {
-     CPPAD_AZMUL(
Base)
-}
-
-where the macro is defined by -
# 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;     \
-    }
-
-Contents -
- -
base_memberRequired Base Class Member Functions
base_cond_expBase Type Requirements for Conditional Expressions
base_identicalBase Type Requirements for Identically Equal Comparisons
base_orderedBase Type Requirements for Ordered Comparisons
base_std_mathBase Type Requirements for Standard Math Functions
base_limitsBase Type Requirements for Numeric Limits
base_to_stringExtending to_string To Another Floating Point Type
base_hashBase Type Requirements for Hash Coding Values
base_exampleExample AD Base Types That are not AD<OtherBase>
-
Input File: cppad/base_require.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_base_require_xml.js cppad-2019.02.00.0/doc/_base_require_xml.js --- cppad-2018.00.00.0/doc/_base_require_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_require_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -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' -]; -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 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down0 = [ -'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_hash.xml', -'base_example.xml' -]; -var list_current0 = [ -'base_require.xml#Syntax', -'base_require.xml#Purpose', -'base_require.xml#API Warning', -'base_require.xml#Standard Base Types', -'base_require.xml#Include Order', -'base_require.xml#Numeric Type', -'base_require.xml#Output Operator', -'base_require.xml#Integer', -'base_require.xml#Integer.Suggestion', -'base_require.xml#Absolute Zero, azmul', -'base_require.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-2018.00.00.0/doc/base_std_math.xml cppad-2019.02.00.0/doc/base_std_math.xml --- cppad-2018.00.00.0/doc/base_std_math.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_std_math.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,406 +0,0 @@ - - - -Base Type Requirements for Standard Math Functions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -base_std_math - -

- - - -
Base Type Requirements for Standard Math Functions
-
-Purpose -
-These definitions are required for the user's code to use the type - -AD<Base> -: - -
-
-Unary Standard Math -
-The type -Base - must support the following functions -unary standard math functions (in the CppAD namespace): - -
- -Syntax - Result -
- - -y = abs(x) - - absolute value
- - -y = acos(x) - - inverse cosine
- - -y = asin(x) - - inverse sine
- - -y = atan(x) - - inverse tangent
- - -y = cos(x) - - cosine
- - -y = cosh(x) - - hyperbolic cosine
- - -y = exp(x) - - exponential
- - -y = fabs(x) - - absolute value
- - -y = log(x) - - natural logarithm
- - -y = sin(x) - - sine
- - -y = sinh(x) - - hyperbolic sine
- - -y = sqrt(x) - - square root
- - -y = tan(x) - - tangent -
-where the arguments and return value have the prototypes - -
-     const 
Basex
-     
Base        y
-
-For example, -base_alloc -, - - -
-
-CPPAD_STANDARD_MATH_UNARY -
-The macro invocation, within the CppAD namespace, - -
-     CPPAD_STANDARD_MATH_UNARY(
BaseFun)
-
-defines the syntax - -
-     
y = CppAD::Fun(x)
-
-This macro uses the functions -std::Fun - which -must be defined and have the same prototype as -CppAD::Fun -. -For example, -float -. - -
-
-erf, asinh, acosh, atanh, expm1, log1p -
-If this preprocessor symbol -CPPAD_USE_CPLUSPLUS_2011 is true (1), -when compiling for c++11, the type -double is supported for the functions listed below. -In this case, the type -Base - must also support these functions: - -
- -Syntax - Result -
- - -y = erf(x) - - error function
- - -y = asinh(x) - - inverse hyperbolic sin
- - -y = acosh(x) - - inverse hyperbolic cosine
- - -y = atanh(x) - - inverse hyperbolic tangent
- - -y = expm1(x) - - exponential of x minus one
- - -y = log1p(x) - - logarithm of one plus x -
-where the arguments and return value have the prototypes - -
-     const 
Basex
-     
Base        y
-
-
-sign -
-The type -Base - must support the syntax - -
-     
y = CppAD::sign(x)
-
-which computes - - -y -= -{ -+ -1 - -if - - -x -> -0 - -0 - -if - - -x -= -0 - --1 - -if - - -x -< -0 - - - - -where -x - and -y - have the same prototype as above. -For example, see -base_alloc -. -Note that, if ordered comparisons are not defined for the type -Base -, -the code sign function should generate an assert if it is used; see -complex invalid unary math -. - -
-
-pow -
-The type -Base - must support the syntax - -
-     
z = CppAD::pow(xy)
-
-which computes - -z -= -x -y - - - -. -The arguments -x - and -y - have prototypes - -
-     const 
Basex
-     const 
Basey
-
-and the return value -z - has prototype - -
-     
Base z
-
-For example, see -base_alloc -. - - -
-
-isnan -
-If -Base - defines the isnan function, -you may also have to provide a definition in the CppAD namespace -(to avoid a function ambiguity). -For example, see -base_complex -. - - - -
Input File: cppad/core/base_std_math.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_base_std_math_xml.js cppad-2019.02.00.0/doc/_base_std_math_xml.js --- cppad-2018.00.00.0/doc/_base_std_math_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_std_math_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', -'ad.xml', -'base_require.xml', -'base_std_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 = [ -'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_hash.xml', -'base_example.xml' -]; -var list_current0 = [ -'base_std_math.xml#Purpose', -'base_std_math.xml#Unary Standard Math', -'base_std_math.xml#CPPAD_STANDARD_MATH_UNARY', -'base_std_math.xml#erf, asinh, acosh, atanh, expm1, log1p', -'base_std_math.xml#sign', -'base_std_math.xml#pow', -'base_std_math.xml#isnan' -]; -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-2018.00.00.0/doc/base_to_string.xml cppad-2019.02.00.0/doc/base_to_string.xml --- cppad-2018.00.00.0/doc/base_to_string.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/base_to_string.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ - - - -Extending to_string To Another Floating Point Type - - - - - - - - - - - - - - - - -
- -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;\
-          int n_digits = 1 + CppAD::numeric_limits<Base>::digits10; \
-          os << std::setprecision(n_digits);\
-          os << value;\
-          return os.str();\
-     }\
-};
- -
Input File: cppad/core/base_to_string.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_base_to_string_xml.js cppad-2019.02.00.0/doc/_base_to_string_xml.js --- cppad-2018.00.00.0/doc/_base_to_string_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_base_to_string_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -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_hash.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-2018.00.00.0/doc/bender_quad.cpp.xml cppad-2019.02.00.0/doc/bender_quad.cpp.xml --- cppad-2018.00.00.0/doc/bender_quad.cpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/bender_quad.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,496 +0,0 @@ - - - -BenderQuad: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -bender_quad.cppHeadings

- - - -
BenderQuad: Example and Test
-Define - - -F -: -R - -× -R - - -R - - - - by - - -F -( -x -, -y -) -= -1 - -2 - - - -i -= -1 - -N - -[ -y -* -sin -( -x -* -t -i - -) -- -z -i - -] -2 - - - -where - -z - -R - -N - - - - is a fixed vector. -It follows that - - - - -y - -F -( -x -, -y -) - -= - - -i -= -1 - -N - -[ -y -* -sin -( -x -* -t -i - -) -- -z -i - -] -sin -( -x -* -t -i - -) - - -y - - -y - -F -( -x -, -y -) - -= - - -i -= -1 - -N - -sin -( -x -t -i - -) -2 - - - - -Furthermore if we define - -Y -( -x -) - - - -as the argmin of - -F -( -x -, -y -) - - - with respect to - -y - - -, - - - -Y -( -x -) - -= - -y -- -[ - -y - - -y - -F -( -x -, -y -) -] --1 - - - -y - -F -[ -x -, -y -] - - -= - - -i -= -1 - -N - -z -i - -sin -( -x -t -i - -) -/ - -i -= -1 - -N - -z -i - -sin -( -x -* -t -i - -) -2 - - - - -

-# include <cppad/cppad.hpp>
-
-namespace {
-     using CppAD::AD;
-     typedef CPPAD_TESTVECTOR(double)         BAvector;
-     typedef CPPAD_TESTVECTOR(AD<double>)   ADvector;
-
-     class Fun {
-     private:
-          BAvector t_; // measurement times
-          BAvector z_; // measurement values
-     public:
-          // constructor
-          Fun(const BAvector &t, const BAvector &z)
-          : t_(t), z_(z)
-          { }
-          // Fun.f(x, y) = F(x, y)
-          ADvector f(const ADvector &x, const ADvector &y)
-          {     size_t i;
-               size_t N = size_t(z_.size());
-
-               ADvector F(1);
-               F[0] = 0.;
-
-               AD<double> residual;
-               for(i = 0; i < N; i++)
-               {     residual = y[0] * sin( x[0] * t_[i] ) - z_[i];
-                    F[0]    += .5 * residual * residual;
-               }
-               return F;
-          }
-          // Fun.h(x, y) = H(x, y) = F_y (x, y)
-          ADvector h(const ADvector &x, const BAvector &y)
-          {     size_t i;
-               size_t N = size_t(z_.size());
-
-               ADvector fy(1);
-               fy[0] = 0.;
-
-               AD<double> residual;
-               for(i = 0; i < N; i++)
-               {     residual = y[0] * sin( x[0] * t_[i] ) - z_[i];
-                    fy[0]   += residual * sin( x[0] * t_[i] );
-               }
-               return fy;
-          }
-          // 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 ADvector &H )
-          {     size_t i;
-               size_t N = size_t(z_.size());
-
-               ADvector Dy(1);
-               AD<double> fyy = 0.;
-
-               for(i = 0; i < N; i++)
-               {     fyy += sin( x[0] * t_[i] ) * sin( x[0] * t_[i] );
-               }
-               Dy[0] = - H[0] / fyy;
-
-               return Dy;
-          }
-     };
-
-     // Used to test calculation of Hessian of G
-     AD<double> G(const ADvector& x, const BAvector& t, const BAvector& z)
-     {     // compute Y(x)
-          AD<double> numerator = 0.;
-          AD<double> denominator = 0.;
-          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] );
-          }
-          AD<double> y = numerator / denominator;
-
-          // V(x) = F[x, Y(x)]
-          AD<double> sum = 0;
-          for(k = 0; k < size_t(t.size()); k++)
-          {     AD<double> residual = y * sin( x[0] * t[k] ) - z[k];
-               sum += .5 * residual * residual;
-          }
-          return sum;
-     }
-}
-
-bool BenderQuad(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-
-     // temporary indices
-     size_t i, j;
-
-     // x space vector
-     size_t n = 1;
-     BAvector x(n);
-     x[0] = 2. * 3.141592653;
-
-     // y space vector
-     size_t m = 1;
-     BAvector y(m);
-     y[0] = 1.;
-
-     // t and z vectors
-     size_t N = 10;
-     BAvector t(N);
-     BAvector z(N);
-     for(i = 0; i < N; i++)
-     {     t[i] = double(i) / double(N);       // time of measurement
-          z[i] = y[0] * sin( x[0] * t[i] );   // data without noise
-     }
-
-     // construct the function object
-     Fun fun(t, z);
-
-     // evaluate the G(x), G'(x) and G''(x)
-     BAvector g(1), gx(n), gxx(n * n);
-     CppAD::BenderQuad(x, y, fun, g, gx, gxx);
-
-
-     // create ADFun object Gfun corresponding to G(x)
-     ADvector a_x(n), a_g(1);
-     for(j = 0; j < n; j++)
-          a_x[j] = x[j];
-     Independent(a_x);
-     a_g[0] = G(a_x, t, z);
-     CppAD::ADFun<double> Gfun(a_x, a_g);
-
-     // accuracy for checks
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-
-     // check Jacobian
-     BAvector check_gx = Gfun.Jacobian(x);
-     for(j = 0; j < n; j++)
-          ok &= NearEqual(gx[j], check_gx[j], eps, eps);
-
-     // check Hessian
-     BAvector check_gxx = Gfun.Hessian(x, 0);
-     for(j = 0; j < n*n; j++)
-          ok &= NearEqual(gxx[j], check_gxx[j], eps, eps);
-
-     return ok;
-}
-
-
-
Input File: example/general/bender_quad.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_bender_quad.cpp_xml.js cppad-2019.02.00.0/doc/_bender_quad.cpp_xml.js --- cppad-2018.00.00.0/doc/_bender_quad.cpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_bender_quad.cpp_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', -'numeric_ad.xml', -'benderquad.xml', -'bender_quad.cpp.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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 = [ -'benderquad.xml', -'opt_val_hes.xml', -'luratio.xml' -]; -var list_down1 = [ -'bender_quad.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-2018.00.00.0/doc/benderquad.xml cppad-2019.02.00.0/doc/benderquad.xml --- cppad-2018.00.00.0/doc/benderquad.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/benderquad.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,984 +0,0 @@ - - - -Computing Jacobian and Hessian of Bender's Reduced Objective - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Computing Jacobian and Hessian of Bender's Reduced Objective
-
-Syntax - -
- -
-# include <cppad/cppad.hpp>
-BenderQuad(
xyfunggxgxx)
- - -
-
-See Also - -
-opt_val_hes - - -
-
-Problem -
-The type ADvector - cannot be determined -form the arguments above -(currently the type -ADvector - must be - -CPPAD_TESTVECTOR(Base) -.) -This will be corrected in the future by requiring -Fun - -to define -Fun::vector_type - which will specify the -type -ADvector -. - -
-
-Purpose -
-We are given the optimization problem - - - -minimize - - -F -( -x -, -y -) - -w -. -r -. -t -. - - -( -x -, -y -) - -R - -n - -× -R - -m - - - - -that is convex with respect to - -y - - -. -In addition, we are given a set of equations - -H -( -x -, -y -) - - - -such that - - -H -[ -x -, -Y -( -x -) -] -= -0 - - - - - -F -y - -[ -x -, -Y -( -x -) -] -= -0 - - -(In fact, it is often the case that - -H -( -x -, -y -) -= -F -y - -( -x -, -y -) - - -.) -Furthermore, it is easy to calculate a Newton step for these equations; i.e., - - -dy -= -- -[ - -y - -H -( -x -, -y -) -] --1 - - -H -( -x -, -y -) - - -The purpose of this routine is to compute the -value, Jacobian, and Hessian of the reduced objective function - - -G -( -x -) -= -F -[ -x -, -Y -( -x -) -] - - -Note that if only the value and Jacobian are needed, they can be -computed more quickly using the relations - - -G -( -1 -) - - -( -x -) -= - -x - -F -[ -x -, -Y -( -x -) -] - - -
-x -
-The BenderQuad argument -x - has prototype - -
-     const 
BAvector &x
-
-(see BAvector - below) -and its size must be equal to -n -. -It specifies the point at which we evaluating -the reduced objective function and its derivatives. - - -
-
-y -
-The BenderQuad argument -y - has prototype - -
-     const 
BAvector &y
-
-and its size must be equal to -m -. -It must be equal to - -Y -( -x -) - - -; i.e., -it must solve the problem in - -y - - - for this given value of - -x - - - - - - -minimize - - -F -( -x -, -y -) - -w -. -r -. -t -. - - -y - -R - -m - - - - -
-fun -
-The BenderQuad object -fun - -must support the member functions listed below. -The -AD<Base> - arguments will be variables for -a tape created by a call to Independent - from BenderQuad -(hence they can not be combined with variables corresponding to a -different tape). - -
-
-fun.f -
-The BenderQuad argument -fun - supports the syntax - -
-     
f = fun.f(xy)
-
-The -fun.f - argument -x - has prototype - -
-     const 
ADvector &x
-
-(see ADvector - below) -and its size must be equal to -n -. -The -fun.f - argument -y - has prototype - -
-     const 
ADvector &y
-
-and its size must be equal to -m -. -The -fun.f - result -f - has prototype - -
-     
ADvector f
-
-and its size must be equal to one. -The value of -f - is - - -f -= -F -( -x -, -y -) - - -. - -
-
-fun.h -
-The BenderQuad argument -fun - supports the syntax - -
-     
h = fun.h(xy)
-
-The -fun.h - argument -x - has prototype - -
-     const 
ADvector &x
-
-and its size must be equal to -n -. -The -fun.h - argument -y - has prototype - -
-     const 
BAvector &y
-
-and its size must be equal to -m -. -The -fun.h - result -h - has prototype - -
-     
ADvector h
-
-and its size must be equal to -m -. -The value of -h - is - - -h -= -H -( -x -, -y -) - - -. - -
-
-fun.dy -
-The BenderQuad argument -fun - supports the syntax - -
-     
dy = fun.dy(xyh)
-
-
x
-
-The -fun.dy - argument -x - has prototype - -
-     const 
BAvector &x
-
-and its size must be equal to -n -. -Its value will be exactly equal to the BenderQuad argument - -x - and values depending on it can be stored as private objects -in -f - and need not be recalculated. - -
-
-
y
-
-The -fun.dy - argument -y - has prototype - -
-     const 
BAvector &y
-
-and its size must be equal to -m -. -Its value will be exactly equal to the BenderQuad argument - -y - and values depending on it can be stored as private objects -in -f - and need not be recalculated. - -
-
-
h
-
-The -fun.dy - argument -h - has prototype - -
-     const 
ADvector &h
-
-and its size must be equal to -m -. - -
-
-
dy
-
-The -fun.dy - result -dy - has prototype - -
-     
ADvector dy
-
-and its size must be equal to -m -. -The return value -dy - is given by - - -dy -= -- -[ - -y - -H -( -x -, -y -) -] --1 - - -h - - -Note that if -h - is equal to - -H -( -x -, -y -) - - -, - - -dy - - - is the Newton step for finding a zero -of - -H -( -x -, -y -) - - - with respect to - -y - - -; -i.e., - - -y -+ -dy - - - is an approximate solution for the equation - - -H -( -x -, -y -+ -dy -) -= -0 - - -. - -
-
-g -
-The argument -g - has prototype - -
-     
BAvector &g
-
-and has size one. -The input value of its element does not matter. -On output, -it contains the value of - -G -( -x -) - - -; i.e., - - -g -[ -0 -] -= -G -( -x -) - - -
-gx -
-The argument -gx - has prototype - -
-     
BAvector &gx
-
-and has size - -n - - -. -The input values of its elements do not matter. -On output, -it contains the Jacobian of - -G -( -x -) - - -; i.e., -for - -j -= -0 -, - -, -n --1 - - -, - - -gx -[ -j -] -= -G -( -1 -) - - -( -x -) -j - - - -
-gxx -
-The argument -gx - has prototype - -
-     
BAvector &gxx
-
-and has size - -n -× -n - - -. -The input values of its elements do not matter. -On output, -it contains the Hessian of - -G -( -x -) - - -; i.e., -for - -i -= -0 -, - -, -n --1 - - -, and - - -j -= -0 -, - -, -n --1 - - -, - - -gxx -[ -i -* -n -+ -j -] -= -G -( -2 -) - - -( -x -) -i -, -j - - - - -
-BAvector -
-The type -BAvector - must be a -SimpleVector - class. -We use -Base - to refer to the type of the elements of - -BAvector -; i.e., - -
-     
BAvector::value_type
-
-
-ADvector -
-The type -ADvector - must be a -SimpleVector - class with elements of type - -AD<Base> -; i.e., - -
-     
ADvector::value_type
-
-must be the same type as - -
-     AD< 
BAvector::value_type >
-
-. - - -
-
-Example - -
-The file -bender_quad.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - - -
Input File: cppad/core/bender_quad.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_benderquad_xml.js cppad-2019.02.00.0/doc/_benderquad_xml.js --- cppad-2018.00.00.0/doc/_benderquad_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_benderquad_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -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', -'benderquad.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', -'directory.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 = [ -'benderquad.xml', -'opt_val_hes.xml', -'luratio.xml' -]; -var list_down0 = [ -'bender_quad.cpp.xml' -]; -var list_current0 = [ -'benderquad.xml#Syntax', -'benderquad.xml#See Also', -'benderquad.xml#Problem', -'benderquad.xml#Purpose', -'benderquad.xml#x', -'benderquad.xml#y', -'benderquad.xml#fun', -'benderquad.xml#fun.fun.f', -'benderquad.xml#fun.fun.h', -'benderquad.xml#fun.fun.dy', -'benderquad.xml#g', -'benderquad.xml#gx', -'benderquad.xml#gxx', -'benderquad.xml#BAvector', -'benderquad.xml#ADvector', -'benderquad.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-2018.00.00.0/doc/bib.xml cppad-2019.02.00.0/doc/bib.xml --- cppad-2018.00.00.0/doc/bib.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/bib.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ - - - -Bibliography - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -Bib - -

- - - -
Bibliography
-
-Abramowitz and Stegun -
-Handbook of Mathematical Functions, -Dover, New York. - -
-
-The C++ Programming Language -
-Bjarne Stroustrup, -The C++ Programming Language, -Special ed., -AT&T, 2000 - -
-
-Evaluating Derivatives -
-Evaluating Derivatives: Principles and Techniques of -Algorithmic Differentiation, -Andreas Griewank, -SIAM, -Philadelphia, -2000 - - - -
-
-Numerical Recipes -
-Numerical Recipes in Fortran: -The Art of Scientific Computing, -Second Edition, -William H. Press, -William T. Vetterling, -Saul, A. Teukolsky, -Brian R. Flannery, -Cambridge University Press, -1992 - -
-
-Shampine, L.F. -
-Implementation of Rosenbrock Methods, -ACM Transactions on Mathematical Software, -Vol. 8, -No. 2, -June 1982. - - - -
Input File: omh/appendix/bib.omh - - - diff -Nru cppad-2018.00.00.0/doc/_bib_xml.js cppad-2019.02.00.0/doc/_bib_xml.js --- cppad-2018.00.00.0/doc/_bib_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_bib_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'bib.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', -'directory.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 = [ -'bib.xml#Abramowitz and Stegun', -'bib.xml#The C++ Programming Language', -'bib.xml#Evaluating Derivatives', -'bib.xml#Numerical Recipes', -'bib.xml#Shampine, L.F.' -]; -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-2018.00.00.0/doc/binary_math.xml cppad-2019.02.00.0/doc/binary_math.xml --- cppad-2018.00.00.0/doc/binary_math.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/binary_math.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ - - - -The Binary Math Functions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
The Binary Math Functions
-
-Contents -
- -
atan2AD Two Argument Inverse Tangent Function
powThe AD Power Function
azmulAbsolute Zero Multiplication
-
Input File: cppad/core/standard_math.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_binary_math_xml.js cppad-2019.02.00.0/doc/_binary_math_xml.js --- cppad-2018.00.00.0/doc/_binary_math_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_binary_math_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +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', -'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-2018.00.00.0/doc/bool_fun.cpp.xml cppad-2019.02.00.0/doc/bool_fun.cpp.xml --- cppad-2018.00.00.0/doc/bool_fun.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/bool_fun.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ - - - -AD Boolean Functions: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -bool_fun.cppHeadings

- - - -
AD Boolean Functions: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <complex>
-
-
-// define abbreviation for double precision complex
-typedef std::complex<double> Complex;
-
-namespace {
-     // a unary bool function with Complex argument
-     static bool IsReal(const Complex &x)
-     {     return x.imag() == 0.; }
-
-     // a binary bool function with Complex arguments
-     static bool AbsGeq(const Complex &x, const Complex &y)
-     {     double axsq = x.real() * x.real() + x.imag() * x.imag();
-          double aysq = y.real() * y.real() + y.imag() * y.imag();
-
-          return axsq >= aysq;
-     }
-
-     // Create version of IsReal with AD<Complex> argument
-     // inside of namespace and outside of any other function.
-     CPPAD_BOOL_UNARY(Complex, IsReal)
-
-     // Create version of AbsGeq with AD<Complex> arguments
-     // inside of namespace and outside of any other function.
-     CPPAD_BOOL_BINARY(Complex, AbsGeq)
-
-}
-bool BoolFun(void)
-{     bool ok = true;
-
-     CppAD::AD<Complex> x = Complex(1.,  0.);
-     CppAD::AD<Complex> y = Complex(1.,  1.);
-
-     ok &= IsReal(x);
-     ok &= ! AbsGeq(x, y);
-
-     return ok;
-}
-
-
-
Input File: example/general/bool_fun.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_bool_fun.cpp_xml.js cppad-2019.02.00.0/doc/_bool_fun.cpp_xml.js --- cppad-2018.00.00.0/doc/_bool_fun.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_bool_fun.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'boolvalued.xml', -'boolfun.xml', -'bool_fun.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 = [ -'compare.xml', -'nearequalext.xml', -'boolfun.xml', -'parvar.xml', -'equalopseq.xml' -]; -var list_down1 = [ -'bool_fun.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-2018.00.00.0/doc/boolfun.xml cppad-2019.02.00.0/doc/boolfun.xml --- cppad-2018.00.00.0/doc/boolfun.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/boolfun.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,340 +0,0 @@ - - - -AD Boolean Functions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
AD Boolean Functions
-
-Syntax - -
- -CPPAD_BOOL_UNARY(Baseunary_name)
-
- -b = unary_name(u)
-
- -b = unary_name(x)
-
- -CPPAD_BOOL_BINARY(Basebinary_name)
-
- -b = binary_name(uv)
-
- -b = binary_name(xy) - - - -
-
-Purpose -
-Create a bool valued function that has -AD<Base> - arguments. - -
-
-unary_name -
-This is the name of the bool valued function with one argument -(as it is used in the source code). -The user must provide a version of -unary_name - where -the argument has type -Base -. -CppAD uses this to create a version of -unary_name - where the -argument has type -AD<Base> -. - -
-
-u -
-The argument -u - has prototype - -
-     const 
Base &u
-
-It is the value at which the user provided version of -unary_name - -is to be evaluated. -It is also used for the first argument to the -user provided version of -binary_name -. - -
-
-x -
-The argument -x - has prototype - -
-     const AD<
Base> &x
-
-It is the value at which the CppAD provided version of -unary_name - -is to be evaluated. -It is also used for the first argument to the -CppAD provided version of -binary_name -. - -
-
-b -
-The result -b - has prototype - -
-     bool 
b
-
-
-Create Unary -
-The preprocessor macro invocation - -
-     CPPAD_BOOL_UNARY(
Baseunary_name)
-
-defines the version of -unary_name - with a -AD<Base> - -argument. -This can with in a namespace -(not the CppAD namespace) -but must be outside of any routine. - -
-
-binary_name -
-This is the name of the bool valued function with two arguments -(as it is used in the source code). -The user must provide a version of -binary_name - where -the arguments have type -Base -. -CppAD uses this to create a version of -binary_name - where the -arguments have type -AD<Base> -. - -
-
-v -
-The argument -v - has prototype - -
-     const 
Base &v
-
-It is the second argument to -the user provided version of -binary_name -. - -
-
-y -
-The argument -x - has prototype - -
-     const AD<
Base> &y
-
-It is the second argument to -the CppAD provided version of -binary_name -. - -
-
-Create Binary -
-The preprocessor macro invocation - -
-     CPPAD_BOOL_BINARY(
Basebinary_name)
-
-defines the version of -binary_name - with -AD<Base> - -arguments. -This can with in a namespace -(not the CppAD namespace) -but must be outside of any routine. - - -
-
-Operation Sequence -
-The result of this operation is not an -AD of Base - object. -Thus it will not be recorded as part of an -AD of -Base - -operation sequence -. - -
-
-Example - -
-The file -bool_fun.cpp - -contains an example and test of these operations. -It returns true if it succeeds and false otherwise. - -
-
-Deprecated 2007-07-31 -
-The preprocessor symbols CppADCreateUnaryBool -and CppADCreateBinaryBool are defined to be the same as -CPPAD_BOOL_UNARY and CPPAD_BOOL_BINARY respectively -(but their use is deprecated). - - -
Input File: cppad/core/bool_fun.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_boolfun_xml.js cppad-2019.02.00.0/doc/_boolfun_xml.js --- cppad-2018.00.00.0/doc/_boolfun_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_boolfun_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'boolvalued.xml', -'boolfun.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 = [ -'compare.xml', -'nearequalext.xml', -'boolfun.xml', -'parvar.xml', -'equalopseq.xml' -]; -var list_down0 = [ -'bool_fun.cpp.xml' -]; -var list_current0 = [ -'boolfun.xml#Syntax', -'boolfun.xml#Purpose', -'boolfun.xml#unary_name', -'boolfun.xml#u', -'boolfun.xml#x', -'boolfun.xml#b', -'boolfun.xml#Create Unary', -'boolfun.xml#binary_name', -'boolfun.xml#v', -'boolfun.xml#y', -'boolfun.xml#Create Binary', -'boolfun.xml#Operation Sequence', -'boolfun.xml#Example', -'boolfun.xml#Deprecated 2007-07-31' -]; -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-2018.00.00.0/doc/boolvalued.xml cppad-2019.02.00.0/doc/boolvalued.xml --- cppad-2018.00.00.0/doc/boolvalued.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/boolvalued.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ - - - -Bool Valued Operations and Functions with AD Arguments - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -Headings

-
Bool Valued Operations and Functions with AD Arguments
- - - - - - -
-Compare -AD Binary Comparison Operators
-NearEqualExt -Compare AD and Base Objects for Nearly Equal
-BoolFun -AD Boolean Functions
-ParVar -Is an AD Object a Parameter or Variable
-EqualOpSeq -Check if Two Value are Identically Equal
-
- -
Input File: cppad/core/bool_valued.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_boolvalued_xml.js cppad-2019.02.00.0/doc/_boolvalued_xml.js --- cppad-2018.00.00.0/doc/_boolvalued_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_boolvalued_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'boolvalued.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 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down0 = [ -'compare.xml', -'nearequalext.xml', -'boolfun.xml', -'parvar.xml', -'equalopseq.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_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-2018.00.00.0/doc/capacity_order.cpp.xml cppad-2019.02.00.0/doc/capacity_order.cpp.xml --- cppad-2018.00.00.0/doc/capacity_order.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/capacity_order.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,184 +0,0 @@ - - - -Controlling Taylor Coefficient Memory Allocation: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -capacity_order.cppHeadings

- - - -
Controlling Taylor Coefficient Memory Allocation: Example and Test
-
# include <cppad/cppad.hpp>
-
-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<double>) 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
-          // 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<double> f;
-          f.Dependent(ax, ay);
-
-          // check that this is master thread
-          size_t thread = thread_alloc::thread_num();
-          ok           &= thread == 0; // this should be master thread
-
-          // The highest order forward mode calculation below is first order.
-          // This corresponds to two Taylor coefficient per variable,direction
-          // (orders zero and one). Preallocate memory for speed.
-          size_t inuse  = thread_alloc::inuse(thread);
-          f.capacity_order(2);
-          ok &= thread_alloc::inuse(thread) > inuse;
-
-          // zero order forward mode
-          CPPAD_TESTVECTOR(double) x(n), y(m);
-          x[0] = 0.5;
-          y    = f.Forward(0, x);
-          double eps = 10. * CppAD::numeric_limits<double>::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;
-     }
-}
-bool capacity_order(void)
-{     bool ok = true;
-     using CppAD::thread_alloc;
-
-     // original amount of memory inuse
-     size_t thread = thread_alloc::thread_num();
-     ok           &= thread == 0; // this should be master thread
-     size_t inuse  = thread_alloc::inuse(thread);
-
-     // do test in separate routine so all objects are destroyed
-     ok &= test();
-
-     // 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);
-
-     return ok;
-}
-
-
-
Input File: example/general/capacity_order.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_capacity_order.cpp_xml.js cppad-2019.02.00.0/doc/_capacity_order.cpp_xml.js --- cppad-2018.00.00.0/doc/_capacity_order.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_capacity_order.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'capacity_order.xml', -'capacity_order.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_down1 = [ -'capacity_order.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-2018.00.00.0/doc/capacity_order.xml cppad-2019.02.00.0/doc/capacity_order.xml --- cppad-2018.00.00.0/doc/capacity_order.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/capacity_order.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,285 +0,0 @@ - - - -Controlling Taylor Coefficients Memory Allocation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Controlling Taylor Coefficients Memory Allocation
-
-Syntax - -
- -f.capacity_order(c) - - -
-
-See Also - -
-seq_property - - -
-
-Purpose -
-The Taylor coefficients calculated by Forward - mode calculations -are retained in an ADFun - object for subsequent use during -Reverse - mode and higher order Forward mode calculations. -For example, a call to Forward - with the syntax - -
-        
yq = f.Forward(qxq)
-
-where -q > 0 - and -xq.size() == f.Domain() -, -uses the lower order Taylor coefficients and -computes the q-th order Taylor coefficients for all -the variables in the operation sequence corresponding to -f -. -The capacity_order operation allows you to control that -amount of memory that is retained by an AD function object -(to hold Forward results for subsequent calculations). - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-
-c -
-The argument -c - has prototype - -
-     size_t 
c
-
-It specifies the number of Taylor coefficient orders that are allocated -in the AD operation sequence corresponding to -f -. - -
-
-Pre-Allocating Memory -
-If you plan to make calls to Forward with the maximum value of - -q - equal to -Q -, -it should be faster to pre-allocate memory for these calls using - -
-     
f.capacity_order(c)
-
-with -c - equal to - -Q -+ -1 - - -. -If you do no do this, Forward will automatically allocate memory -and will copy the results to a larger buffer, when necessary. -
-
-
Note that each call to Dependent - frees the old memory -connected to the function object and sets the corresponding -taylor capacity to zero. - -
-
-Freeing Memory -
-If you no longer need the Taylor coefficients of order -q - -and higher (that are stored in -f -), -you can reduce the memory allocated to -f - using - -
-     
f.capacity_order(c)
-
-with -c - equal to -q -. -Note that, if ta_hold_memory - is true, this memory is not actually -returned to the system, but rather held for future use by the same thread. - -
-
-Original State -
-If -f - is constructed - with the syntax - -
-     ADFun<
Basef(xy)
-
-, -there is an implicit call to forward_zero - with -xq - equal to -the value of the -independent variables - -when the AD operation sequence was recorded. -This corresponds to -c == 1 -. - - -
-
-Example -
-The file -capacity_order.cpp - -contains an example and test of these operations. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/capacity_order.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_capacity_order_xml.js cppad-2019.02.00.0/doc/_capacity_order_xml.js --- cppad-2018.00.00.0/doc/_capacity_order_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_capacity_order_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'capacity_order.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_down0 = [ -'capacity_order.cpp.xml' -]; -var list_current0 = [ -'capacity_order.xml#Syntax', -'capacity_order.xml#Syntax.See Also', -'capacity_order.xml#Purpose', -'capacity_order.xml#f', -'capacity_order.xml#c', -'capacity_order.xml#c.Pre-Allocating Memory', -'capacity_order.xml#c.Freeing Memory', -'capacity_order.xml#Original State', -'capacity_order.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-2018.00.00.0/doc/change_param.cpp.xml cppad-2019.02.00.0/doc/change_param.cpp.xml --- cppad-2018.00.00.0/doc/change_param.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/change_param.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,220 +0,0 @@ - - - -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/general/change_param.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_change_param.cpp_xml.js cppad-2019.02.00.0/doc/_change_param.cpp_xml.js --- cppad-2018.00.00.0/doc/_change_param.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_change_param.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +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_param.cpp.xml' -]; -var list_down3 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.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-2018.00.00.0/doc/check_for_nan.cpp.xml cppad-2019.02.00.0/doc/check_for_nan.cpp.xml --- cppad-2018.00.00.0/doc/check_for_nan.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/check_for_nan.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,185 +0,0 @@ - - - -ADFun Checking For Nan: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -check_for_nan.cppHeadings

- - -
ADFun Checking For Nan: Example and Test
-
# include <cppad/cppad.hpp>
-# include <cctype>
-
-namespace {
-     void myhandler(
-          bool known       ,
-          int  line        ,
-          const char *file ,
-          const char *exp  ,
-          const char *msg  )
-     {     // error handler must not return, so throw an exception
-          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<double>::epsilon();
-
-     // replace the default CppAD error handler
-     CppAD::ErrorHandler info(myhandler);
-
-     CPPAD_TESTVECTOR(AD<double>) ax(2), ay(2);
-     ax[0] = 2.0;
-     ax[1] = 1.0;
-     CppAD::Independent(ax);
-     ay[0] = sqrt( ax[0] );
-     ay[1] = sqrt( ax[1] );
-     CppAD::ADFun<double> f(ax, ay);
-
-     CPPAD_TESTVECTOR(double) x(2), y(2);
-     x[0] = 2.0;
-     x[1] = -1.0;
-
-     // use try / catch because this causes an exception
-     // (assuming that NDEBUG is not defined)
-     f.check_for_nan(true);
-     try {
-          y = f.Forward(0, x);
-
-# ifndef NDEBUG
-          // When compiled with NDEBUG defined,
-          // CppAD does not spend time checking for nan.
-          ok = false;
-# endif
-     }
-     catch(std::string msg)
-     {
-          // 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 variable 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<double> 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 &= CppAD::NearEqual(y[0], std::sqrt(x[0]), eps, eps);
-     ok &= CppAD::isnan( y[1] );
-
-     return ok;
-}
-
-
-
Input File: example/general/check_for_nan.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_check_for_nan.cpp_xml.js cppad-2019.02.00.0/doc/_check_for_nan.cpp_xml.js --- cppad-2018.00.00.0/doc/_check_for_nan.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_check_for_nan.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'check_for_nan.xml', -'check_for_nan.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'check_for_nan.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-2018.00.00.0/doc/check_for_nan.xml cppad-2019.02.00.0/doc/check_for_nan.xml --- cppad-2018.00.00.0/doc/check_for_nan.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/check_for_nan.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,295 +0,0 @@ - - - -Check an ADFun Object For Nan Results - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Check an ADFun Object For Nan Results
-
-Syntax - -
- -f.check_for_nan(b)
-
- -b = f.check_for_nan()
-
- -get_check_for_nan(vecfile)
-
-
-Debugging -
-If NDEBUG is not defined, and -the result of a forward - or reverse - -calculation contains a nan -, -CppAD can halt with an error message. - -
-
-f -
-For the syntax where -b - is an argument, - -f - has prototype - -
-     ADFun<
Basef
-
-(see -ADFun<Base> - constructor -). -For the syntax where -b - is the result, - -f - has prototype - -
-     const ADFun<
Basef
-
-
-b -
-This argument or result has prototype - -
-     bool 
b
-
-Future calls to -f.Forward - will (will not) check for nan. -depending on if -b - is true (false). - -
-
-Default -
-The value for this setting after construction of -f -) is true. -The value of this setting is not affected by calling -Dependent - for this function object. - -
-
-Error Message -
-If this error is detected during zero order forward mode, -the values of the independent variables that resulted in the 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 nan. - -
-
-vector_size -
-The error message with contain the text - -vector_size = vector_size - followed the newline character -'\n'. -The value of -vector_size - is the number of elements -in the independent vector. - -
-
-file_name -
-The error message with contain the text - -file_name = file_name - followed the newline character -'\n'. -The value of -file_name - is the name of the temporary file -that contains the dependent variable values. - -
-
-index -
-The error message will contain the text - -index = index - followed by the newline character '\n'. -The value of -index - is the lowest dependent variable index -that has the value nan. - -
-
-get_check_for_nan -
-This routine can be used to get the independent variable -values that result in a nan. - -
-
-vec -
-This argument has prototype - -
-     CppAD::vector<
Base>& vec
-
-It size must be equal to the corresponding value of -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 Independent -, -that resulted in the nan. -(Note that the call to Independent uses an vector with elements -of type -AD<Base> - and -vec - has elements of type - -Base -.) - -
-
-file -
-This argument has prototype - -
-     const std::string& 
file
-
-It must be the value of -file_name - -in the corresponding error message. - -
-
-Example - -
-The file -check_for_nan.cpp - -contains an example and test of these operations. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/check_for_nan.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_check_for_nan_xml.js cppad-2019.02.00.0/doc/_check_for_nan_xml.js --- cppad-2018.00.00.0/doc/_check_for_nan_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_check_for_nan_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'check_for_nan.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down0 = [ -'check_for_nan.cpp.xml' -]; -var list_current0 = [ -'check_for_nan.xml#Syntax', -'check_for_nan.xml#Debugging', -'check_for_nan.xml#f', -'check_for_nan.xml#b', -'check_for_nan.xml#Default', -'check_for_nan.xml#Error Message', -'check_for_nan.xml#Error Message.vector_size', -'check_for_nan.xml#Error Message.file_name', -'check_for_nan.xml#Error Message.index', -'check_for_nan.xml#get_check_for_nan', -'check_for_nan.xml#get_check_for_nan.vec', -'check_for_nan.xml#get_check_for_nan.file', -'check_for_nan.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-2018.00.00.0/doc/check_numeric_type.cpp.xml cppad-2019.02.00.0/doc/check_numeric_type.cpp.xml --- cppad-2018.00.00.0/doc/check_numeric_type.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/check_numeric_type.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,278 +0,0 @@ - - - -The CheckNumericType Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -check_numeric_type.cppHeadings

- - -
The CheckNumericType Function: Example and Test
-

-# include <cppad/utility/check_numeric_type.hpp>
-# include <cppad/utility/near_equal.hpp>
-
-
-// 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
-
-     // -------------------------------------------------------------------
-     class MyType {
-     private:
-          double d;
-     public:
-          // constructor from void
-          MyType(void) : d(0.)
-          { }
-          // constructor from an int
-          MyType(int d_) : d(d_)
-          { }
-          // copy constuctor
-          MyType(const MyType &x)
-          {     d = x.d; }
-          // assignment operator
-          void operator = (const MyType &x)
-          {     d = x.d; }
-          // member function that converts to double
-          double Double(void) const
-          {     return d; }
-# if CppADMyTypeOmit != 1
-          // unary plus
-          MyType operator + (void) const
-          {     MyType x;
-               x.d =  d;
-               return x;
-          }
-# endif
-# if CppADMyTypeOmit != 2
-          // unary plus
-          MyType operator - (void) const
-          {     MyType x;
-               x.d = - d;
-               return x;
-          }
-# endif
-# if CppADMyTypeOmit != 3
-          // binary addition
-          MyType operator + (const MyType &x) const
-          {     MyType y;
-               y.d = d + x.d ;
-               return y;
-          }
-# endif
-# if CppADMyTypeOmit != 4
-          // binary subtraction
-          MyType operator - (const MyType &x) const
-          {     MyType y;
-               y.d = d - x.d ;
-               return y;
-          }
-# endif
-# if CppADMyTypeOmit != 5
-          // binary multiplication
-          MyType operator * (const MyType &x) const
-          {     MyType y;
-               y.d = d * x.d ;
-               return y;
-          }
-# endif
-# if CppADMyTypeOmit != 6
-          // binary division
-          MyType operator / (const MyType &x) const
-          {     MyType y;
-               y.d = d / x.d ;
-               return y;
-          }
-# endif
-# if CppADMyTypeOmit != 7
-          // compound assignment addition
-          void operator += (const MyType &x)
-          {     d += x.d; }
-# endif
-# if CppADMyTypeOmit != 8
-          // compound assignment subtraction
-          void operator -= (const MyType &x)
-          {     d -= x.d; }
-# endif
-# if CppADMyTypeOmit != 9
-          // compound assignment multiplication
-          void operator *= (const MyType &x)
-          {     d *= x.d; }
-# endif
-# if CppADMyTypeOmit != 10
-          // compound assignment division
-          void operator /= (const MyType &x)
-          {     d /= x.d; }
-# endif
-     };
-     // -------------------------------------------------------------------
-     /*
-     Solve: A[0] * x[0] + A[1] * x[1] = b[0]
-            A[2] * x[0] + A[3] * x[1] = b[1]
-     */
-     template <class NumericType>
-     void Solve(NumericType *A, NumericType *x, NumericType *b)
-     {
-          // make sure NumericType satisfies its conditions
-          CppAD::CheckNumericType<NumericType>();
-
-          // copy b to x
-          x[0] = b[0];
-          x[1] = b[1];
-
-          // copy A to work space
-          NumericType W[4];
-          W[0] = A[0];
-          W[1] = A[1];
-          W[2] = A[2];
-          W[3] = A[3];
-
-          // divide first row by W(1,1)
-          W[1] /= W[0];
-          x[0] /= W[0];
-          W[0] = NumericType(1);
-
-          // subtract W(2,1) times first row from second row
-          W[3] -= W[2] * W[1];
-          x[1] -= W[2] * x[0];
-          W[2] = NumericType(0);
-
-          // divide second row by W(2, 2)
-          x[1] /= W[3];
-          W[3]  = NumericType(1);
-
-          // use first row to solve for x[0]
-          x[0] -= W[1] * x[1];
-     }
-} // End Empty namespace
-
-bool CheckNumericType(void)
-{     bool ok  = true;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     MyType A[4];
-     A[0] = MyType(1); A[1] = MyType(2);
-     A[2] = MyType(3); A[3] = MyType(4);
-
-     MyType b[2];
-     b[0] = MyType(1);
-     b[1] = MyType(2);
-
-     MyType x[2];
-     Solve(A, x, b);
-
-     MyType sum;
-     sum = A[0] * x[0] + A[1] * x[1];
-     ok &= NearEqual(sum.Double(), b[0].Double(), eps99, eps99);
-
-     sum = A[2] * x[0] + A[3] * x[1];
-     ok &= NearEqual(sum.Double(), b[1].Double(), eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/utility/check_numeric_type.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_check_numeric_type.cpp_xml.js cppad-2019.02.00.0/doc/_check_numeric_type.cpp_xml.js --- cppad-2018.00.00.0/doc/_check_numeric_type.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_check_numeric_type.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'checknumerictype.xml', -'check_numeric_type.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'check_numeric_type.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-2018.00.00.0/doc/checknumerictype.xml cppad-2019.02.00.0/doc/checknumerictype.xml --- cppad-2018.00.00.0/doc/checknumerictype.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/checknumerictype.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ - - - -Check NumericType Class Concept - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Check NumericType Class Concept
-
-Syntax - -
- -# include <cppad/utility/check_numeric_type.hpp>
-
- -CheckNumericType<NumericType>() - - - -
-
-Purpose -
-The syntax - -
-     CheckNumericType<
NumericType>()
-
-preforms compile and run time checks that the type specified -by -NumericType - satisfies all the requirements for -a NumericType - class. -If a requirement is not satisfied, -a an error message makes it clear what condition is not satisfied. - -
-
-Include -
-The file cppad/check_numeric_type.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest -if the CppAD include files. - -
-
-Parallel Mode -
-The routine thread_alloc::parallel_setup - -must be called before it -can be used in parallel - mode. - -
-
-Example - -
-The file 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. - - -
Input File: cppad/utility/check_numeric_type.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_checknumerictype_xml.js cppad-2019.02.00.0/doc/_checknumerictype_xml.js --- cppad-2018.00.00.0/doc/_checknumerictype_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_checknumerictype_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'checknumerictype.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'check_numeric_type.cpp.xml' -]; -var list_current0 = [ -'checknumerictype.xml#Syntax', -'checknumerictype.xml#Purpose', -'checknumerictype.xml#Include', -'checknumerictype.xml#Parallel Mode', -'checknumerictype.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-2018.00.00.0/doc/checkpoint.cpp.xml cppad-2019.02.00.0/doc/checkpoint.cpp.xml --- cppad-2018.00.00.0/doc/checkpoint.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/checkpoint.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,344 +0,0 @@ - - - -Simple Checkpointing: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -checkpoint.cpp - -

- - - -
Simple Checkpointing: Example and Test
-
-Purpose -
-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 -for this example there are only two. -The functions - - -F -: -R - -2 - - -R - -2 - - - - -and - - -G -: -R - -2 - - -R - -2 - - - - -defined by - - -F -( -y -) -= -( -y -0 - -+ -y -0 - -+ -y -0 - - -y -1 - -+ -y -1 - -+ -y -1 - - -) - -, - -G -( -x -) -= -( -x -0 - -· -x -0 - -· -x -0 - - -x -1 - -· -x -1 - -· -x -1 - - -) - - -

-# include <cppad/cppad.hpp>
-
-namespace {
-     using CppAD::AD;
-     typedef CPPAD_TESTVECTOR(AD<double>)            ADVector;
-     typedef CppAD::atomic_base<double>::option_enum option_enum;
-
-     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 < 3; k++)
-          {     y[0] *= x[0];
-               y[1] *= x[1];
-          }
-          return;
-     }
-     bool test_case(
-          option_enum f_sparsity, option_enum g_sparsity, bool optimize )
-     {     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<double>::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<double> atom_f("atom_f", f_algo, ax, ay, f_sparsity);
-          checkpoint<double> 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<double> 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<double> check_yes(ax, az);
-
-          // checkpointing should use fewer operations
-          ok &= check_yes.size_var() < check_not.size_var();
-
-          // this does not really save space because 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 / double(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));
-          for(i = 0; i < m * (q + 1); i++)
-               w[i] = 1.0 / double(i + 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<size_t> > 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<size_t> > 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 &= r_not[i] == r_yes[i];
-
-
-          // compare reverse mode Hessian sparsity patterns
-          CppAD::vector< std::set<size_t> > 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;
-
-     // different types of sparsity
-     option_enum pack_sparsity = CppAD::atomic_base<double>::pack_sparsity_enum;
-     option_enum bool_sparsity = CppAD::atomic_base<double>::bool_sparsity_enum;
-     option_enum set_sparsity  = CppAD::atomic_base<double>::set_sparsity_enum;
-
-     // test some different cases
-     ok &= test_case(pack_sparsity, pack_sparsity, true);
-     ok &= test_case(pack_sparsity, bool_sparsity, false);
-     ok &= test_case(bool_sparsity, set_sparsity,  true);
-     ok &= test_case(set_sparsity,  set_sparsity,  false);
-
-     return ok;
-}
-
-
Input File: example/atomic/checkpoint.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_checkpoint.cpp_xml.js cppad-2019.02.00.0/doc/_checkpoint.cpp_xml.js --- cppad-2018.00.00.0/doc/_checkpoint.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_checkpoint.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +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', -'atomic.xml', -'checkpoint.xml', -'checkpoint.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 = [ -'checkpoint.cpp.xml', -'atomic_mul_level.cpp.xml', -'checkpoint_ode.cpp.xml', -'checkpoint_extended_ode.cpp.xml' -]; -var list_current0 = [ -'checkpoint.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-2018.00.00.0/doc/checkpoint_extended_ode.cpp.xml cppad-2019.02.00.0/doc/checkpoint_extended_ode.cpp.xml --- cppad-2018.00.00.0/doc/checkpoint_extended_ode.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/checkpoint_extended_ode.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,958 +0,0 @@ - - - -Checkpointing an Extended ODE Solver: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -checkpoint_extended_ode.cpp - -

-
Checkpointing an Extended ODE Solver: Example and Test
-
-See Also - -
-checkpoint_ode.cpp -, -atomic_mul_level.cpp -. - - -
-
-Discussion -
-Suppose that we wish to extend an ODE to include derivatives with respect -to some parameter in the ODE. In addition, suppose we wish to -differentiate a function that depends on these derivatives. -Applying checkpointing to at the second level of AD would not work; -see atomic_mul_level.cpp - -In this example we show how one can do this by -checkpointing an extended ODE solver. - -
-
-Problem -
-We consider the initial value problem with parameter - -x - - - defined by, - - -z -( -0 -, -x -) -= -z -0 - -( -x -) - - -, - - - -t - -z -( -t -, -x -) -= -h -[ -x -, -z -( -t -, -x -) -] - - -Note that if - -t - - - needs to be in the equation, one can define -the first component of - -z -( -t -, -x -) - - - to be equal to - -t - - -. - -
-
-ODE Solver -
-For this example, we consider the Fourth order Runge-Kutta ODE solver. -Given an approximation solution at time - -t -k - - - - denoted by - - -z - -˜ -k - -( -x -) - - -, and - -Δ -t -= -t -k -+ -1 - - -- -t -k - - - -, -it defines the approximation solution - -z - -˜ -k -+ -1 - - -( -x -) - - - -at time - -t -k -+ -1 - - - - - by - - - -h -1 - - -= - -h -[ -x -, -z - -˜ -k - -( -x -) -] - -h -2 - - -= - -h -[ -x -, -z - -˜ -k - -( -x -) -+ -Δ -t - -h -1 - -/ -2 -] - -h -3 - - -= - -h -[ -x -, -z - -˜ -k - -( -x -) -+ -Δ -t - -h -2 - -/ -2 -] - -h -4 - - -= - -h -[ -x -, -z - -˜ -k - -( -x -) -+ -Δ -t - -h -3 - -] - -z - -˜ -k -+ -1 - - -( -x -) - -= - -z - -˜ -k - -( -x -) -+ -Δ -t - -( -h -1 - -+ -2 -h -2 - -+ -2 -h -3 - -+ -h -4 - -) -/ -6 - - - -If - -z - -˜ -k - -( -x -) -= -z -k - -( -x -) - - -, then - - -z - -˜ -k -+ -1 - - -( -x -) -= -z -k -+ -1 - - -( -x -) -+ -O -( -Δ -t -5 - -) - - -, then -Other ODE solvers can use a similar method to the one used below. - -
-
-ODE -
-For this example the ODE is defined by - - -z -( -0 -, -x -) -= -0 - - - and - - -h -[ -x -, -z -( -t -, -x -) -] -= -( -x -0 - - -x -1 - -z -0 - -( -t -, -x -) - - - -x -n --1 - - -z -n --2 - - -( -t -, -x -) - -) -= -( - -t - -z -0 - -( -t -, -x -) - - -t - -z -1 - -( -t -, -x -) - - - - -t - -z -n --1 - - -( -t -, -x -) - -) - - -
-Solution -
-The solution of the ODE for this example, -which is used to check the results, -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 - - -z -( -t -, -x -) -= -( -x -0 - -t - -x -1 - -x -0 - -t -2 - -/ -2 - - - -x -n --1 - - -x -n --2 - - - -x -0 - -t -n - -/ -n -! - -) - - -

-# include <cppad/cppad.hpp>
-
-namespace {
-     using CppAD::AD;
-     typedef AD<double>                     a1double;
-     typedef AD<a1double>                   a2double;
-     //
-     typedef CPPAD_TESTVECTOR(   double )   a0vector;
-     typedef CPPAD_TESTVECTOR( a1double )   a1vector;
-     typedef CPPAD_TESTVECTOR( a2double )   a2vector;
-     //
-     // set once by main and kept that way
-     double delta_t_ = std::numeric_limits<double>::quiet_NaN();
-     size_t n_       = 0;
-     //
-     // The function h( x , y)
-     template <class FloatVector>
-     FloatVector h(const FloatVector& x, const FloatVector& y)
-     {     assert( size_t( x.size() ) == n_ );
-          assert( size_t( y.size() ) == n_ );
-          FloatVector result(n_);
-          result[0] = x[0];
-          for(size_t i = 1; i < n_; i++)
-               result[i] = x[i] * y[i-1];
-          return result;
-     }
-
-     // The 4-th Order Runge-Kutta Step
-     template <class FloatVector>
-     FloatVector Runge4(const FloatVector& x, const FloatVector& z0
-     )
-     {     assert( size_t( x.size() ) == n_ );
-          assert( size_t( z0.size() ) == n_ );
-          //
-          typedef typename FloatVector::value_type Float;
-          //
-          Float  dt = Float(delta_t_);
-          size_t m  = z0.size();
-          //
-          FloatVector h1(m), h2(m), h3(m), h4(m), result(m);
-          h1 = h( x, z0 );
-          //
-          for(size_t i = 0; i < m; i++)
-               h2[i] = z0[i] + dt * h1[i] / 2.0;
-          h2 = h( x, h2 );
-          //
-          for(size_t i = 0; i < m; i++)
-               h3[i] = z0[i] + dt * h2[i] / 2.0;
-          h3 = h( x, h3 );
-          //
-          for(size_t i = 0; i < m; i++)
-               h4[i] = z0[i] + dt * h3[i];
-          h4 = h( x, h4 );
-          //
-          for(size_t i = 0; i < m; i++)
-          {     Float dz = dt * ( h1[i] + 2.0*h2[i] + 2.0*h3[i] + h4[i] ) / 6.0;
-               result[i] = z0[i] + dz;
-          }
-          return result;
-     }
-
-     // Derivative of 4-th Order Runge-Kutta Step w.r.t x
-     a1vector Runge4_x(const a1vector& x, const a1vector& z0)
-     {     assert( size_t( x.size() ) == n_ );
-          assert( size_t( z0.size() ) == n_ );
-          //
-          a2vector ax(n_);
-          for(size_t j = 0; j < n_; j++)
-               ax[j] = x[j];
-          //
-          a2vector az0(n_);
-          for(size_t i = 0; i < n_; i++)
-               az0[i] = z0[i];
-          //
-          CppAD::Independent(ax);
-          a2vector az(n_);
-          az = Runge4(ax, az0);
-          CppAD::ADFun<a1double> f(ax, az);
-          //
-          a1vector result =  f.Jacobian(x);
-          //
-          return result;
-     }
-
-     // Derivative of 4-th Order Runge-Kutta Step w.r.t z0
-     a1vector Runge4_z0(const a1vector& x, const a1vector& z0)
-     {     assert( size_t( x.size()  ) == n_ );
-          assert( size_t( z0.size() ) == n_ );
-          //
-          a2vector ax(n_);
-          for(size_t j = 0; j < n_; j++)
-               ax[j] = x[j];
-          //
-          a2vector az0(n_);
-          for(size_t i = 0; i < n_; i++)
-               az0[i] = z0[i];
-          //
-          CppAD::Independent(az0);
-          a2vector az(n_);
-          az = Runge4(ax, az0);
-          CppAD::ADFun<a1double> f(az0, az);
-          //
-          a1vector result =  f.Jacobian(z0);
-          //
-          return result;
-     }
-
-     // pack an extended ode vector
-     template <class FloatVector>
-     void pack(
-          FloatVector&         extended_ode ,
-          const FloatVector&   x            ,
-          const FloatVector&   z            ,
-          const FloatVector&   z_x          )
-     {     assert( size_t( extended_ode.size() ) == n_ + n_ + n_ * n_ );
-          assert( size_t( x.size()            ) == n_                );
-          assert( size_t( z.size()            ) == n_                );
-          assert( size_t( z_x.size()          ) == n_ * n_           );
-          //
-          size_t offset = 0;
-          for(size_t i = 0; i < n_; i++)
-               extended_ode[offset + i] = x[i];
-          offset += n_;
-          for(size_t i = 0; i < n_; i++)
-               extended_ode[offset + i] = z[i];
-          offset += n_;
-          for(size_t i = 0; i < n_; i++)
-          {     for(size_t j = 0; j < n_; j++)
-               {     // partial of z_i (t , x ) w.r.t x_j
-                    extended_ode[offset + i * n_ + j] = z_x[i * n_ + j];
-               }
-          }
-     }
-
-     // unpack an extended ode vector
-     template <class FloatVector>
-     void unpack(
-          const FloatVector&         extended_ode ,
-          FloatVector&               x            ,
-          FloatVector&               z            ,
-          FloatVector&               z_x          )
-     {     assert( size_t( extended_ode.size() ) == n_ + n_ + n_ * n_ );
-          assert( size_t( x.size()            ) == n_                );
-          assert( size_t( z.size()            ) == n_                );
-          assert( size_t( z_x.size()          ) == n_ * n_           );
-          //
-          size_t offset = 0;
-          for(size_t i = 0; i < n_; i++)
-               x[i] = extended_ode[offset + i];
-          offset += n_;
-          for(size_t i = 0; i < n_; i++)
-               z[i] = extended_ode[offset + i];
-          offset += n_;
-          for(size_t i = 0; i < n_; i++)
-          {     for(size_t j = 0; j < n_; j++)
-               {     // partial of z_i (t , x ) w.r.t x_j
-                    z_x[i * n_ + j] = extended_ode[offset + i * n_ + j];
-               }
-          }
-     }
-
-     // Algorithm that advances the partial of z(t, x) w.r.t x
-     void ext_ode_algo(const a1vector& ext_ode_in, a1vector& ext_ode_out)
-     {     assert( size_t( ext_ode_in.size()  ) == n_ + n_ + n_ * n_ );
-          assert( size_t( ext_ode_out.size() ) == n_ + n_ + n_ * n_ );
-          //
-          // initial extended ode information
-          a1vector x(n_), z0(n_), z0_x(n_ * n_);
-          unpack(ext_ode_in, x, z0, z0_x);
-          //
-          // advance z(t, x)
-          a1vector z1 = Runge4(x, z0);
-          //
-          // partial of z1 w.r.t. x
-          a1vector z1_x = Runge4_x(x, z0);
-          //
-          // partial of z1 w.r.t. z0
-          a1vector z1_z0 = Runge4_z0(x, z0);
-          //
-          // total derivative of z1 w.r.t x
-          for(size_t i = 0; i < n_; i++)
-          {     for(size_t j = 0; j < n_; j++)
-               {     a1double sum = 0.0;
-                    for(size_t k = 0; k < n_; k++)
-                         sum += z1_z0 [ i * n_ + k ] * z0_x [ k * n_ + j ];
-                    z1_x[ i * n_ + j] += sum;
-               }
-          }
-          //
-          // final extended ode information
-          pack(ext_ode_out, x, z1, z1_x);
-          //
-          return;
-     }
-}
-//
-bool extended_ode(void)
-{     bool ok = true;
-     using CppAD::NearEqual;
-     double eps = std::numeric_limits<double>::epsilon();
-     //
-     // number of terms in the differential equation
-     n_ = 6;
-     //
-     // step size for the differentiail equation
-     size_t n_step = 10;
-     double T      = 1.0;
-     delta_t_ = T / double(n_step);
-     //
-     // set parameter value and initial value of the extended ode
-     a1vector ax(n_), az0(n_), az0_x(n_ * n_);
-     for(size_t i = 0; i < n_; i++)
-     {     ax[i]  = a1double(i + 1);
-          az0[i] = a1double(0);
-          for(size_t j = 0; j < n_; j++)
-               az0_x[ i * n_ + j ] = 0.0;
-     }
-     //
-     // pack into extended ode information input vector
-     size_t n_ext = n_ + n_ + n_ * n_;
-     a1vector aext_ode_in(n_ext);
-     pack(aext_ode_in, ax, az0, az0_x);
-     //
-     // create checkpoint version of the algorithm
-     a1vector aext_ode_out(n_ext);
-     CppAD::checkpoint<double> ext_ode_check(
-          "ext_ode", ext_ode_algo, aext_ode_in, aext_ode_out
-     );
-     //
-     // set the independent variables for recording
-     CppAD::Independent( ax );
-     //
-     // repack to get dependence on ax
-     pack(aext_ode_in, ax, az0, az0_x);
-     //
-     // Now run the checkpoint algorithm n_step times
-     for(size_t k = 0; k < n_step; k++)
-     {     ext_ode_check(aext_ode_in, aext_ode_out);
-          aext_ode_in = aext_ode_out;
-     }
-     //
-     // Unpack the results (must use ax1 so do not overwrite ax)
-     a1vector ax1(n_), az1(n_), az1_x(n_ * n_);
-     unpack(aext_ode_out, ax1, az1, az1_x);
-     //
-     // We could record a complicated funciton of x and z_x(T, x) in f,
-     // but make this example simpler we record x -> z_x(T, x).
-     CppAD::ADFun<double> f(ax, az1_x);
-     //
-     // check function values
-     a0vector x(n_), z1(n_), z1_x(n_ * n_);
-     for(size_t j = 0; j < n_; j++)
-          x[j] = double(j + 1);
-     z1_x = f.Forward(0, x);
-     //
-     // use z(t, x) for checking solution
-     z1[0] = x[0] * T;
-     for(size_t i = 1; i < n_; i++)
-          z1[i] = x[i] * T * z1[i-1] / double(i+1);
-     //
-     // expected accuracy for each component of of z(t, x)
-     a0vector acc(n_);
-     for(size_t i = 0; i < n_; i++)
-     {     if( i < 4 )
-          {     // Runge-Kutta methos is exact for this case
-               acc[i] = 10. * eps;
-          }
-          else
-          {     acc[i] = 1.0;
-               for(size_t k = 0; k < 5; k++)
-                         acc[i] *= x[k] * delta_t_;
-          }
-     }
-     // check z1(T, x)
-     for(size_t i = 0; i < n_; i++)
-     {     for(size_t j = 0; j < n_; j++)
-          {     // check partial of z1_i w.r.t x_j
-               double check = 0.0;
-               if( j <= i )
-                    check = z1[i] / x[j];
-               ok &= NearEqual(z1_x[ i * n_ + j ] , check, acc[i], acc[i]);
-          }
-     }
-     //
-     // Now use f to compute a derivative. For this 'simple' example it is
-     // the derivative with respect to x of the
-     // parital with respect to x[n-1] of z_{n-1} (t , x)
-     a0vector w(n_ * n_), dw(n_);
-     for(size_t i = 0; i < n_; i++)
-     {     for(size_t j = 0; j < n_; j++)
-          {     w[ i * n_ + j ] = 0.0;
-               if( i == n_ - 1 && j == n_ - 1 )
-                    w[ i * n_ + j ] = 1.0;
-          }
-     }
-     dw = f.Reverse(1, w);
-     for(size_t j = 0; j < n_; j++)
-     {     double check = 0.0;
-          if( j < n_ - 1 )
-               check = z1[n_ - 1] / ( x[n_ - 1] * x[j] );
-          ok &= NearEqual(dw[j] , check, acc[n_-1], acc[n_-1]);
-     }
-     //
-     return ok;
-}
-
-
Input File: example/atomic/extended_ode.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_checkpoint_extended_ode.cpp_xml.js cppad-2019.02.00.0/doc/_checkpoint_extended_ode.cpp_xml.js --- cppad-2018.00.00.0/doc/_checkpoint_extended_ode.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_checkpoint_extended_ode.cpp_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', -'ad.xml', -'advalued.xml', -'atomic.xml', -'checkpoint.xml', -'checkpoint_extended_ode.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 = [ -'checkpoint.cpp.xml', -'atomic_mul_level.cpp.xml', -'checkpoint_ode.cpp.xml', -'checkpoint_extended_ode.cpp.xml' -]; -var list_current0 = [ -'checkpoint_extended_ode.cpp.xml#See Also', -'checkpoint_extended_ode.cpp.xml#Discussion', -'checkpoint_extended_ode.cpp.xml#Problem', -'checkpoint_extended_ode.cpp.xml#ODE Solver', -'checkpoint_extended_ode.cpp.xml#ODE', -'checkpoint_extended_ode.cpp.xml#Solution' -]; -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-2018.00.00.0/doc/checkpoint_ode.cpp.xml cppad-2019.02.00.0/doc/checkpoint_ode.cpp.xml --- cppad-2018.00.00.0/doc/checkpoint_ode.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/checkpoint_ode.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,855 +0,0 @@ - - - -Checkpointing an ODE Solver: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -checkpoint_ode.cpp - -

-
Checkpointing an ODE Solver: Example and Test
-
-See Also - -
-checkpoint_extended_ode.cpp -, - -
-
-Purpose -
-In this example we checkpoint - one step of an ODE solver. - -
-
-Problem -
-We consider the initial value problem with parameter - -x - - - defined by, - - -z -( -0 -, -x -) -= -z -0 - -( -x -) - - -, - - - -t - -z -( -t -, -x -) -= -h -[ -x -, -z -( -t -, -x -) -] - - -Note that if - -t - - - needs to be in the equation, one can define -the first component of - -z -( -t -, -x -) - - - to be equal to - -t - - -. - -
-
-ODE Solver -
-For this example, we consider the Fourth order Runge-Kutta ODE solver. -Given an approximation solution at time - -t -k - - - - denoted by - - -z - -˜ -k - -( -x -) - - -, and - -Δ -t -= -t -k -+ -1 - - -- -t -k - - - -, -it defines the approximation solution - -z - -˜ -k -+ -1 - - -( -x -) - - - -at time - -t -k -+ -1 - - - - - by - - - -h -1 - - -= - -h -[ -x -, -z - -˜ -k - -( -x -) -] - -h -2 - - -= - -h -[ -x -, -z - -˜ -k - -( -x -) -+ -Δ -t - -h -1 - -/ -2 -] - -h -3 - - -= - -h -[ -x -, -z - -˜ -k - -( -x -) -+ -Δ -t - -h -2 - -/ -2 -] - -h -4 - - -= - -h -[ -x -, -z - -˜ -k - -( -x -) -+ -Δ -t - -h -3 - -] - -z - -˜ -k -+ -1 - - -( -x -) - -= - -z - -˜ -k - -( -x -) -+ -Δ -t - -( -h -1 - -+ -2 -h -2 - -+ -2 -h -3 - -+ -h -4 - -) -/ -6 - - - -If - -z - -˜ -k - -( -x -) -= -z -k - -( -x -) - - -, - - -z - -˜ -k -+ -1 - - -( -x -) -= -z -k -+ -1 - - -( -x -) -+ -O -( -Δ -t -5 - -) - - -. -Other ODE solvers can use a similar method to the one used below. - -
-
-ODE -
-For this example the ODE is defined by - - -z -( -0 -, -x -) -= -0 - - - and - - -h -[ -x -, -z -( -t -, -x -) -] -= -( -x -0 - - -x -1 - -z -0 - -( -t -, -x -) - - - -x -n --1 - - -z -n --2 - - -( -t -, -x -) - -) -= -( - -t - -z -0 - -( -t -, -x -) - - -t - -z -1 - -( -t -, -x -) - - - - -t - -z -n --1 - - -( -t -, -x -) - -) - - -
-Solution -
-The solution of the ODE for this example, -which is used to check the results, -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 - - -z -( -t -, -x -) -= -( -x -0 - -t - -x -1 - -x -0 - -t -2 - -/ -2 - - - -x -n --1 - - -x -n --2 - - - -x -0 - -t -n - -/ -n -! - -) - - -

-# include <cppad/cppad.hpp>
-
-namespace {
-     using CppAD::AD;
-     typedef AD<double>                     a1double;
-     typedef AD<a1double>                   a2double;
-     //
-     typedef CPPAD_TESTVECTOR(   double )   a0vector;
-     typedef CPPAD_TESTVECTOR( a1double )   a1vector;
-     typedef CPPAD_TESTVECTOR( a2double )   a2vector;
-     //
-     // set once by main and kept that way
-     double delta_t_ = std::numeric_limits<double>::quiet_NaN();
-     size_t n_       = 0;
-     //
-     // The function h( x , y)
-     template <class FloatVector>
-     FloatVector h(const FloatVector& x, const FloatVector& y)
-     {     assert( size_t( x.size() ) == n_ );
-          assert( size_t( y.size() ) == n_ );
-          FloatVector result(n_);
-          result[0] = x[0];
-          for(size_t i = 1; i < n_; i++)
-               result[i] = x[i] * y[i-1];
-          return result;
-     }
-
-     // The 4-th Order Runge-Kutta Step
-     template <class FloatVector>
-     FloatVector Runge4(const FloatVector& x, const FloatVector& z0
-     )
-     {     assert( size_t( x.size() ) == n_ );
-          assert( size_t( z0.size() ) == n_ );
-          //
-          typedef typename FloatVector::value_type Float;
-          //
-          Float  dt = Float(delta_t_);
-          size_t m  = z0.size();
-          //
-          FloatVector h1(m), h2(m), h3(m), h4(m), result(m);
-          h1 = h( x, z0 );
-          //
-          for(size_t i = 0; i < m; i++)
-               h2[i] = z0[i] + dt * h1[i] / 2.0;
-          h2 = h( x, h2 );
-          //
-          for(size_t i = 0; i < m; i++)
-               h3[i] = z0[i] + dt * h2[i] / 2.0;
-          h3 = h( x, h3 );
-          //
-          for(size_t i = 0; i < m; i++)
-               h4[i] = z0[i] + dt * h3[i];
-          h4 = h( x, h4 );
-          //
-          for(size_t i = 0; i < m; i++)
-          {     Float dz = dt * ( h1[i] + 2.0*h2[i] + 2.0*h3[i] + h4[i] ) / 6.0;
-               result[i] = z0[i] + dz;
-          }
-          return result;
-     }
-
-     // pack x and z into an ode_info vector
-     template <class FloatVector>
-     void pack(
-          FloatVector&         ode_info ,
-          const FloatVector&   x        ,
-          const FloatVector&   z        )
-     {     assert( size_t( ode_info.size() ) == n_ + n_ );
-          assert( size_t( x.size()        ) == n_      );
-          assert( size_t( z.size()        ) == n_      );
-          //
-          size_t offset = 0;
-          for(size_t i = 0; i < n_; i++)
-               ode_info[offset + i] = x[i];
-          offset += n_;
-          for(size_t i = 0; i < n_; i++)
-               ode_info[offset + i] = z[i];
-     }
-
-     // unpack an ode_info vector
-     template <class FloatVector>
-     void unpack(
-          const FloatVector&         ode_info ,
-          FloatVector&               x        ,
-          FloatVector&               z        )
-     {     assert( size_t( ode_info.size() ) == n_ + n_ );
-          assert( size_t( x.size()        ) == n_      );
-          assert( size_t( z.size()        ) == n_      );
-          //
-          size_t offset = 0;
-          for(size_t i = 0; i < n_; i++)
-               x[i] = ode_info[offset + i];
-          offset += n_;
-          for(size_t i = 0; i < n_; i++)
-               z[i] = ode_info[offset + i];
-     }
-
-     // Algorithm that z(t, x)
-     void ode_algo(const a1vector& ode_info_in, a1vector& ode_info_out)
-     {     assert( size_t( ode_info_in.size()  ) == n_ + n_ );
-          assert( size_t( ode_info_out.size() ) == n_ + n_ );
-          //
-          // initial ode information
-          a1vector x(n_), z0(n_);
-          unpack(ode_info_in, x, z0);
-          //
-          // advance z(t, x)
-          a1vector z1 = Runge4(x, z0);
-          //
-          // final ode information
-          pack(ode_info_out, x, z1);
-          //
-          return;
-     }
-}
-//
-bool ode(void)
-{     bool ok = true;
-     using CppAD::NearEqual;
-     double eps = std::numeric_limits<double>::epsilon();
-     //
-     // number of terms in the differential equation
-     n_ = 6;
-     //
-     // step size for the differentiail equation
-     size_t n_step = 10;
-     double T      = 1.0;
-     delta_t_ = T / double(n_step);
-     //
-     // set parameter value and initial value of the ode
-     a1vector ax(n_), az0(n_);
-     for(size_t i = 0; i < n_; i++)
-     {     ax[i]  = a1double(i + 1);
-          az0[i] = a1double(0);
-     }
-     //
-     // pack ode information input vector
-     a1vector ode_info_in(2 * n_);
-     pack(ode_info_in, ax, az0);
-     //
-     // create checkpoint version of the algorithm
-     a1vector ode_info_out(2 * n_);
-     CppAD::checkpoint<double> ode_check(
-          "ode", ode_algo, ode_info_in, ode_info_out
-     );
-     //
-     // set the independent variables for recording
-     CppAD::Independent( ax );
-     //
-     // repack to get dependence on ax
-     pack(ode_info_in, ax, az0);
-     //
-     // Now run the checkpoint algorithm n_step times
-     for(size_t k = 0; k < n_step; k++)
-     {     ode_check(ode_info_in, ode_info_out);
-          ode_info_in = ode_info_out;
-     }
-     //
-     // Unpack the results (must use ax1 so do not overwrite ax)
-     a1vector ax1(n_), az1(n_);
-     unpack(ode_info_out, ax1, az1);
-     //
-     // We could record a complicated funciton of x and z(T, x) in f,
-     // but make this example simpler we record x -> z(T, x).
-     CppAD::ADFun<double> f(ax, az1);
-     //
-     // check function values
-     a0vector x(n_), z1(n_);
-     for(size_t j = 0; j < n_; j++)
-          x[j] = double(j + 1);
-     z1 = f.Forward(0, x);
-     //
-     // separate calculation of z(t, x)
-     a0vector check_z1(n_);
-     check_z1[0] = x[0] * T;
-     for(size_t i = 1; i < n_; i++)
-          check_z1[i] = x[i] * T * check_z1[i-1] / double(i+1);
-     //
-     // expected accuracy for each component of of z(t, x)
-     a0vector acc(n_);
-     for(size_t i = 0; i < n_; i++)
-     {     if( i < 4 )
-          {     // Runge-Kutta methos is exact for this case
-               acc[i] = 10. * eps;
-          }
-          else
-          {     acc[i] = 1.0;
-               for(size_t k = 0; k < 5; k++)
-                         acc[i] *= x[k] * delta_t_;
-          }
-     }
-     // check z1(T, x)
-     for(size_t i = 0; i < n_; i++)
-          ok &= NearEqual(z1[i] , check_z1[i], acc[i], acc[i]);
-     //
-     // Now use f to compute a derivative. For this 'simple' example it is
-     // the derivative of z_{n-1} (T, x) respect to x of the
-     a0vector w(n_), dw(n_);
-     for(size_t i = 0; i < n_; i++)
-     {     w[i] = 0.0;
-          if( i == n_ - 1 )
-               w[i] = 1.0;
-     }
-     dw = f.Reverse(1, w);
-     for(size_t j = 0; j < n_; j++)
-     {     double check = z1[n_ - 1] / x[j];
-          ok &= NearEqual(dw[j] , check, 100.*eps, 100.*eps);
-     }
-     //
-     return ok;
-}
-
-
Input File: example/atomic/ode.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_checkpoint_ode.cpp_xml.js cppad-2019.02.00.0/doc/_checkpoint_ode.cpp_xml.js --- cppad-2018.00.00.0/doc/_checkpoint_ode.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_checkpoint_ode.cpp_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', -'ad.xml', -'advalued.xml', -'atomic.xml', -'checkpoint.xml', -'checkpoint_ode.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 = [ -'checkpoint.cpp.xml', -'atomic_mul_level.cpp.xml', -'checkpoint_ode.cpp.xml', -'checkpoint_extended_ode.cpp.xml' -]; -var list_current0 = [ -'checkpoint_ode.cpp.xml#See Also', -'checkpoint_ode.cpp.xml#Purpose', -'checkpoint_ode.cpp.xml#Problem', -'checkpoint_ode.cpp.xml#ODE Solver', -'checkpoint_ode.cpp.xml#ODE', -'checkpoint_ode.cpp.xml#Solution' -]; -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-2018.00.00.0/doc/checkpoint.xml cppad-2019.02.00.0/doc/checkpoint.xml --- cppad-2018.00.00.0/doc/checkpoint.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/checkpoint.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,590 +0,0 @@ - - - -Checkpointing Functions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Checkpointing Functions
-
-Syntax - -
- -checkpoint<Baseatom_fun(
-     
namealgoaxaysparsityoptimize
-)
-
sv = atom_fun.size_var()
-
atom_fun.option(option_value)
-
algo(axay)
-
atom_fun(axay)
-checkpoint<
Base>::clear()
- - -
-
-See Also - -
-reverse_checkpoint.cpp - - -
-
-Purpose - - -
-
-Reduce Memory -
-You can reduce the size of the tape and memory required for AD by -checkpointing functions of the form - -y -= -f -( -x -) - - - where - - -f -: -B -n - - -B -m - - - -. - -
-
-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 - -f -( -x -) - - - -may depend on its independent variables. - -
-
-Repeating Forward -
-Normally, CppAD store forward - mode results until they freed -using capacity_order - or the corresponding ADFun - object is -deleted. This is not true for checkpoint functions because a checkpoint -function may be used repeatedly with different arguments in the same tape. -Thus, forward mode results are recomputed each time a checkpoint function -is used during a forward or reverse mode sweep. - -
-
-Restriction -
-The operation sequence - -representing - -f -( -x -) - - - cannot depend on the value of - -x - - -. -The approach in the reverse_checkpoint.cpp - example case be applied -when the operation sequence depends on - -x - - -. - -
-
- -
-If -Base - is an AD type, it is possible to record -Base - -operations. -Note that -atom_fun - will treat -algo - as an atomic -operation while recording -AD<Base> - operations, but not while -recording -Base - operations. -See the atomic_mul_level.cpp - example. - - -
-
-Method -
-The checkpoint class is derived from atomic_base -and makes this easy. -It implements all the atomic_base -virtual functions - -and hence its source code cppad/core/checkpoint.hpp -provides an example implementation of atomic_base -. -The difference is that checkpoint.hpp uses AD -instead of user provided derivatives. - -
-
-constructor -
-The syntax for the checkpoint constructor is - -
-     checkpoint<
Baseatom_fun(namealgoaxay)
-
-
  1. This constructor cannot be called in parallel - mode. -
  2. - -You cannot currently be recording - -AD<Base> - operations when the constructor is called. -
  3. - -This object -atom_fun - must not be destructed for as long -as any -ADFun<Base> - object uses its atomic operation. -
  4. - -This class is implemented as a derived class of -atomic_base - and hence -some of its error message will refer to atomic_base. -
- - -
-
-Base -
-The type -Base - specifies the base type for AD operations. - -
-
-ADVector -
-The type -ADVector - must be a -simple vector class - with elements of type - -AD<Base> -. - -
-
-name -
-This -checkpoint - constructor argument has prototype - -
-     const char* 
name
-
-It is the name used for error reporting. -The suggested value for -name - is -atom_fun -; i.e., -the same name as used for the object being constructed. - -
-
-ax -
-This argument has prototype - -
-     const 
ADVectorax
-
-and size must be equal to -n -. -It specifies vector - -x - -B -n - - - - -at which an -AD<Base> - version of - - -y -= -f -( -x -) - - - is to be evaluated. - -
-
-ay -
-This argument has prototype - -
-     
ADVectoray
-
-Its input size must be equal to -m - and does not change. -The input values of its elements do not matter. -Upon return, it is an -AD<Base> - version of - - -y -= -f -( -x -) - - -. - -
-
-sparsity -
-This argument has prototype - -
-     atomic_base<
Base>::option_enum sparsity
-
-It specifies sparsity - -in the atomic_base constructor and must be either - -atomic_base<Base>::pack_sparsity_enum -, - -atomic_base<Base>::bool_sparsity_enum -, or - -atomic_base<Base>::set_sparsity_enum -. -This argument is optional and its default value is unspecified. - -
-
-optimize -
-This argument has prototype - -
-     bool 
optimize
-
-It specifies if the recording corresponding to the atomic function -should be optimized -. -One expects to use a checkpoint function many times, so it should -be worth the time to optimize its operation sequence. -For debugging purposes, it may be useful to use the -original operation sequence (before optimization) -because it corresponds more closely to -algo -. -This argument is optional and its default value is true. - - -
-
-size_var -
-This size_var member function return value has prototype - -
-     size_t 
sv
-
-It is the size_var - for the - -ADFun<Base> - object is used to store the operation sequence -corresponding to -algo -. - -
-
-option -
-The option syntax can be used to set the type of sparsity -pattern used by -atom_fun -. -This is an -atomic_base<Base> - function and its documentation -can be found at atomic_option -. - -
-
-algo -
-The type of -algo - is arbitrary, except for the fact that -the syntax - -
-     
algo(axay)
-
-must evaluate the function - -y -= -f -( -x -) - - - using - -AD<Base> - operations. -In addition, we assume that the -operation sequence - -does not depend on the value of -ax -. - -
-
-atom_fun -
-Given -ax - it computes the corresponding value of -ay - -using the operation sequence corresponding to -algo -. -If -AD<Base> - operations are being recorded, -it enters the computation as single operation in the recording -see start recording -. -(Currently each use of -atom_fun - actually corresponds to - -m+n+2 - operations and creates -m - new variables, -but this is not part of the CppAD specifications and my change.) - -
-
-clear -
-The atomic_base class holds onto static work space in order to -increase speed by avoiding system memory allocation calls. -This call makes to work space available - to -for other uses by the same thread. -This should be called when you are done using the -user atomic functions for a specific value of -Base -. - -
-
-Restriction -
-The clear routine cannot be called -while in parallel - execution mode. - - -
-
-Example -
-The file checkpoint.cpp - contains an example and test -of these operations. -It returns true if it succeeds and false if it fails. - - -
Input File: cppad/core/checkpoint.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_checkpoint_xml.js cppad-2019.02.00.0/doc/_checkpoint_xml.js --- cppad-2018.00.00.0/doc/_checkpoint_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_checkpoint_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +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', -'atomic.xml', -'checkpoint.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 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down0 = [ -'checkpoint.cpp.xml', -'atomic_mul_level.cpp.xml', -'checkpoint_ode.cpp.xml', -'checkpoint_extended_ode.cpp.xml' -]; -var list_current0 = [ -'checkpoint.xml#Syntax', -'checkpoint.xml#See Also', -'checkpoint.xml#Purpose', -'checkpoint.xml#Purpose.Reduce Memory', -'checkpoint.xml#Purpose.Faster Recording', -'checkpoint.xml#Purpose.Repeating Forward', -'checkpoint.xml#Purpose.Restriction', -'checkpoint.xml#Purpose.Multiple Level AD', -'checkpoint.xml#Method', -'checkpoint.xml#constructor', -'checkpoint.xml#Base', -'checkpoint.xml#ADVector', -'checkpoint.xml#name', -'checkpoint.xml#ax', -'checkpoint.xml#ay', -'checkpoint.xml#sparsity', -'checkpoint.xml#optimize', -'checkpoint.xml#size_var', -'checkpoint.xml#option', -'checkpoint.xml#algo', -'checkpoint.xml#atom_fun', -'checkpoint.xml#clear', -'checkpoint.xml#clear.Restriction', -'checkpoint.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-2018.00.00.0/doc/check_simple_vector.cpp.xml cppad-2019.02.00.0/doc/check_simple_vector.cpp.xml --- cppad-2018.00.00.0/doc/check_simple_vector.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/check_simple_vector.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,267 +0,0 @@ - - - -The CheckSimpleVector Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -check_simple_vector.cppHeadings

- - -
The CheckSimpleVector Function: Example and Test
-

-# include <cppad/utility/vector.hpp>
-# include <cppad/utility/check_simple_vector.hpp>
-# include <iostream>
-
-
-// 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
-
-// -------------------------------------------------------------------------
-
-// example class used for non-constant elements (different from Scalar)
-template <class Scalar>
-class MyElement {
-private:
-     Scalar *element;
-public:
-     // element constructor
-     MyElement(Scalar *e)
-     {     element = e; }
-     // an example element assignment that returns void
-     void operator = (const Scalar &s)
-     {     *element = s; }
-     // conversion to Scalar
-     operator Scalar() const
-     {     return *element; }
-};
-
-
-// example simple vector class
-template <class Scalar>
-class MyVector {
-private:
-     size_t length;
-     Scalar * data;
-public:
-
-# if CppADMyVectorOmit != 1
-     // type of the elements in the vector
-     typedef Scalar value_type;
-# endif
-# if CppADMyVectorOmit != 2
-     // default constructor
-     inline MyVector(void) : length(0) , data(0)
-     { }
-# endif
-# if CppADMyVectorOmit != 3
-     // constructor with a specified size
-     inline MyVector(size_t n) : length(n)
-     {     if( length == 0 )
-               data = 0;
-          else     data = new Scalar[length];
-     }
-# endif
-# if CppADMyVectorOmit != 4
-     // copy constructor
-     inline MyVector(const MyVector &x) : length(x.length)
-     {     size_t i;
-          if( length == 0 )
-               data = 0;
-          else     data = new Scalar[length];
-
-          for(i = 0; i < length; i++)
-               data[i] = x.data[i];
-     }
-# endif
-# if CppADMyVectorOmit != 4
-# if CppADMyVectorOmit != 7
-     // destructor (it is not safe to delete the pointer in cases 4 and 7)
-     ~MyVector(void)
-     {     delete [] data; }
-# endif
-# endif
-# if CppADMyVectorOmit != 5
-     // size function
-     inline size_t size(void) const
-     {     return length; }
-# endif
-# if CppADMyVectorOmit != 6
-     // resize function
-     inline void resize(size_t n)
-     {     if( length > 0 )
-               delete [] data;
-          length = n;
-          if( length > 0 )
-               data = new Scalar[length];
-          else     data = 0;
-     }
-# endif
-# if CppADMyVectorOmit != 7
-     // assignment operator
-     inline MyVector & operator=(const MyVector &x)
-     {     size_t i;
-          for(i = 0; i < length; i++)
-               data[i] = x.data[i];
-          return *this;
-     }
-# endif
-# if CppADMyVectorOmit != 8
-     // non-constant element access
-     MyElement<Scalar> operator[](size_t i)
-     {     return data + i; }
-# endif
-# if CppADMyVectorOmit != 9
-     // constant element access
-     const Scalar & operator[](size_t i) const
-     {     return data[i]; }
-# endif
-};
-// -------------------------------------------------------------------------
-
-/*
-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 <class Scalar, class Vector>
-     Vector Sscal(const Scalar &a, const Vector &v)
-     {
-          // invoke CheckSimpleVector function
-          CppAD::CheckSimpleVector<Scalar, Vector>();
-
-          size_t n = v.size();
-          Vector r(n);
-
-          size_t i;
-          for(i = 0; i < n; i++)
-               r[i] = a * v[i];
-
-          return r;
-     }
-}
-
-bool CheckSimpleVector(void)
-{     bool ok  = true;
-     using CppAD::vector;
-
-     // --------------------------------------------------------
-     // If you change double to float in the next statement,
-     // CheckSimpleVector will generate an error message at compile time.
-     double a = 3.;
-     // --------------------------------------------------------
-
-     size_t n = 2;
-     MyVector<double> v(n);
-     v[0]     = 1.;
-     v[1]     = 2.;
-     MyVector<double> r = Sscal(a, v);
-     ok      &= (r[0] == 3.);
-     ok      &= (r[1] == 6.);
-
-     return ok;
-}
-
-
-
Input File: example/utility/check_simple_vector.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_check_simple_vector.cpp_xml.js cppad-2019.02.00.0/doc/_check_simple_vector.cpp_xml.js --- cppad-2018.00.00.0/doc/_check_simple_vector.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_check_simple_vector.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'checksimplevector.xml', -'check_simple_vector.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'check_simple_vector.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-2018.00.00.0/doc/checksimplevector.xml cppad-2019.02.00.0/doc/checksimplevector.xml --- cppad-2018.00.00.0/doc/checksimplevector.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/checksimplevector.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,251 +0,0 @@ - - - -Check Simple Vector Concept - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Check Simple Vector Concept
-
-Syntax - -
- -# include <cppad/utility/check_simple_vector.hpp>
-
- -CheckSimpleVector<ScalarVector>() - -
-
-CheckSimpleVector<ScalarVector>(xy) - - - -
-
-Purpose -
-Preforms compile and run time checks that the type specified -by -Vector - satisfies all the requirements for -a SimpleVector - class with -elements of type - - -Scalar -. -If a requirement is not satisfied, -a an error message makes it clear what condition is not satisfied. - -
-
-x, y -
-If the arguments -x - and -y - are present, -they have prototype - -
-     const 
Scalarx
-     const 
Scalary
-
-In addition, the check - -
-     
x == x
-
-will return the boolean value true, and - -
-     
x == y
-
-will return false. - -
-
-Restrictions -
-If the arguments -x - and -y - are not present, -the following extra assumption is made by CheckSimpleVector: -If -x - is a -Scalar - object - -
-     
x = 0
-     
y = 1
-
-assigns values to the objects -x - and -y -. -In addition, - -x == x - would return the boolean value true and - -x == y - would return false. - -
-
-Include -
-The file cppad/check_simple_vector.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest -if the CppAD include files. - -
-
-Parallel Mode -
-The routine thread_alloc::parallel_setup - -must be called before it -can be used in parallel - mode. - -
-
-Example - -
-The file check_simple_vector.cpp - -contains an example and test of this function where -S - -is the same as -T -. -It returns true, if it succeeds an false otherwise. -The comments in this example suggest a way to change the example -so -S - is not the same as -T -. - - -
Input File: cppad/utility/check_simple_vector.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_checksimplevector_xml.js cppad-2019.02.00.0/doc/_checksimplevector_xml.js --- cppad-2018.00.00.0/doc/_checksimplevector_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_checksimplevector_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'checksimplevector.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'check_simple_vector.cpp.xml' -]; -var list_current0 = [ -'checksimplevector.xml#Syntax', -'checksimplevector.xml#Purpose', -'checksimplevector.xml#x, y', -'checksimplevector.xml#Restrictions', -'checksimplevector.xml#Include', -'checksimplevector.xml#Parallel Mode', -'checksimplevector.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-2018.00.00.0/doc/cholesky_theory.xml cppad-2019.02.00.0/doc/cholesky_theory.xml --- cppad-2018.00.00.0/doc/cholesky_theory.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/cholesky_theory.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,2680 +0,0 @@ - - - -AD Theory for Cholesky Factorization - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cholesky_theory - -

-
AD Theory for Cholesky Factorization
-
-Reference -
-See section 3.6 of -Sebastian F. Walter's Ph.D. thesis, - -Structured Higher-Order Algorithmic Differentiation -in the Forward and Reverse Mode -with Application in Optimum Experimental Design -, -Humboldt-Universitat zu Berlin, -2011. - - -
-
-Notation - - -
-
-Cholesky Factor -
-We are given a positive definite symmetric matrix - - -A - -R - -n -× -n - - - - - -and a Cholesky factorization - - -A -= -L -L -T - - - - -where - -L - -R - -n -× -n - - - - - is lower triangular. - -
-
-Taylor Coefficient -
-The matrix - -A - - - is a function of a scalar argument - - -t - - -. -For - -k -= -0 -, - -, -K - - -, we use - -A -k - - - - for the -corresponding Taylor coefficients; i.e., - - -A -( -t -) -= -o -( -t -K - -) -+ - -k -= -0 - -K - -A -k - -t -k - - - -where - -o -( -t -K - -) -/ -t -K - - -0 - - - as - -t - -0 - - -. -We use a similar notation for - -L -( -t -) - - -. - -
-
-Lower Triangular Part -
-For a square matrix - -C - - -, - - -lower - -( -C -) - - - is the lower triangular part of - -C - - -, - - -diag - -( -C -) - - - is the diagonal matrix with the same diagonal as - - -C - - - and - - -low - -( -C -) -= -lower - -( -C -) -- -1 - -2 - - -diag - -( -C -) - - -
-Forward Mode -
-For Taylor coefficient order - -k -= -0 -, - -, -K - - - -the coefficients - - -A -k - - -R - -n -× -n - - - - -, and -satisfy the equation - - -A -k - -= - - -= -0 - -k - -L - - -L -k -- - - -T - - - - -In the case where - -k -= -0 - - -, the - - -A -0 - -= -L -0 - -L -0 -T - - - - -The value of - -L -0 - - - - can be computed using the Cholesky factorization. -In the case where - -k -> -0 - - -, - - -A -k - -= -L -k - -L -0 -T - - -+ -L -0 - -L -k -T - - -+ -B -k - - - -where - - -B -k - -= - - -= -1 - -k --1 - - -L - - -L -k -- - - -T - - - - -Note that - -B -k - - - - is defined in terms of Taylor coefficients -of - -L -( -t -) - - - that have order less than - -k - - -. -We also note that - - -L -0 --1 - - -( -A -k - -- -B -k - -) -L -0 -- -T - - -= -L -0 --1 - - -L -k - -+ -L -k -T - - -L -0 -- -T - - - - -The first matrix on the right hand side is lower triangular, -the second is upper triangular, -and the diagonals are equal. -It follows that - - -L -0 --1 - - -L -k - -= -low - -[ -L -0 --1 - - -( -A -k - -- -B -k - -) -L -0 -- -T - - -] - - - - -L -k - -= -L -0 - -low - -[ -L -0 --1 - - -( -A -k - -- -B -k - -) -L -0 -- -T - - -] - - -This expresses - -L -k - - - - in term of the -Taylor coefficients of - -A -( -t -) - - - and the lower order coefficients -of - -L -( -t -) - - -. - -
-
-Lemma 1 -
-We use the notation - -C - -˙ - - - for the derivative of a matrix -valued function - -C -( -s -) - - - with respect to a scalar argument - -s - - -. -We use the notation - -S - -¯ - - - and - -L - -¯ - - - for the -partial derivative of a scalar value function - -F - -¯ -( -S -, -L -) - - - -with respect to a symmetric matrix - -S - - - and -an lower triangular matrix - -L - - -. -Define the scalar valued function - - -F - -^ -( -C -) -= -F - -¯ -[ -S -, -L - -^ -( -S -) -] - - -We use - -S - -^ - - - for the total derivative of - -F - -^ - - - with -respect to - -S - - -. -Suppose that - -L - -^ -( -S -) - - - is such that - - -L - -˙ -= -L -0 - -low - -( -L -0 --1 - - -S - -˙ -L -0 -- -T - - -) - - -for any - -S -( -s -) - - -. It follows that - - -S - -^ -= -S - -¯ -+ -1 - -2 - - -( -M -+ -M -T - - -) - - -where - - -M -= -L -0 -- -T - - -low - -( -L -0 -T - - -L - -¯ -) -T - - -L -0 --1 - - - - -
-Proof - - - - -s - -F - -^ -[ -S -( -s -) -, -L -( -s -) -] -= -tr - -( -S - -¯ -T - - -S - -˙ -) -+ -tr - -( -L - -¯ -T - - -L - -˙ -) - - - - -tr - -( -L - -¯ -T - - -L - -˙ -) -= -tr - -[ -L - -¯ -T - - -L -0 - -low - -( -L -0 --1 - - -S - -˙ -L -0 -- -T - - -) -] - - - - -= -tr - -[ -low - -( -L -0 --1 - - -S - -˙ -L -0 -- -T - - -) -T - - -L -0 -T - - -L - -¯ -] - - - - -= -tr - -[ -L -0 --1 - - -S - -˙ -L -0 -- -T - - -low - -( -L -0 -T - - -L - -¯ -) -] - - - - -= -tr - -[ -L -0 -- -T - - -low - -( -L -0 -T - - -L - -¯ -) -L -0 --1 - - -S - -˙ -] - - - - - -s - -F - -^ -[ -S -( -s -) -, -L -( -s -) -] -= -tr - -( -S - -¯ -T - - -S - -˙ -) -+ -tr - -[ -L -0 -- -T - - -low - -( -L -0 -T - - -L - -¯ -) -L -0 --1 - - -S - -˙ -] - - -We now consider the - -( -i -, -j -) - - - component function, -for a symmetric matrix - -S -( -s -) - - -, -defined by - - -S -k -, - - - -( -s -) -= -{ -1 - -if - - -k -= -i - -and - - - -= -j - -1 - -if - - -k -= -j - -and - - - -= -i - -0 - -otherwise - - -} - - -This shows that the formula in the lemma is correct for - - -S - -^ -i -, -j - - - - - and - -S - -^ -j -, -i - - - - -. -This completes the proof because the component - -( -i -, -j -) - - - was arbitrary. - -
-
-Lemma 2 -
-We use the same assumptions as in Lemma 1 except that the -matrix - -S - - - is lower triangular (instead of symmetric). -It follows that - - -S - -^ -= -S - -¯ -+ -lower - -( -M -) - - -where - - -M -= -L -0 -- -T - - -low - -( -L -0 -T - - -L - -¯ -) -T - - -L -0 --1 - - - - -The proof of this lemma is identical to Lemma 2 except that component function -is defined by - - -S -k -, - - - -( -s -) -= -{ -1 - -if - - -k -= -i - -and - - - -= -j - -0 - -otherwise - - -} - - -
-Reverse Mode - - -
-
-Case k = 0 -
-For the case - -k -= -0 - - -, - - -A - -˙ -0 - -= -L - -˙ -0 - -L -0 -T - - -+ -L -0 - -L - -˙ -0 -T - - - - - - -L -0 --1 - - -A - -˙ -0 - -L -0 -- -T - - -= -L -0 --1 - - -L - -˙ -0 - -+ -L - -˙ -0 -T - - -L -0 -- -T - - - - - - -low - -( -L -0 --1 - - -A - -˙ -0 - -L -0 -- -T - - -) -= -L -0 --1 - - -L - -˙ -0 - - - - - -L - -˙ -0 - -= -L -0 - -low - -( -L -0 --1 - - -A - -˙ -0 - -L -0 -- -T - - -) - - -It follows from Lemma 1 that - - -A - -¯ -0 - -= - -+ - - -1 - -2 - - -( -M -+ -M -T - - -) - - -where - - -M -= -L -0 -- -T - - -low - -( -L -0 -T - - -L - -¯ -0 - -) -T - - -L -0 --1 - - - - -and - -A - -¯ -0 - - - - is the partial before and after -is before and after - -L -0 - - - - is removed from the scalar function -dependency. - -
-
-Case k > 0 -
-In the case where - -k -> -0 - - -, - - -A -k - -= -L -k - -L -0 -T - - -+ -L -0 - -L -k -T - - -+ -B -k - - - -where - -B -k - - - - is defined in terms of Taylor coefficients -of - -L -( -t -) - - - that have order less than - -k - - -. -It follows that - - -L - -˙ -k - -L -0 -T - - -+ -L -0 - -L - -˙ -k -T - - -= -A - -˙ -k - -- -B - -˙ -k - -- -L - -˙ -0 - -L -k -T - - -- -L -k - -L - -˙ -0 -T - - - - - - -L -0 --1 - - -L - -˙ -k - -+ -L - -˙ -k -T - - -L -0 -- -T - - -= -L -0 --1 - - -( -A - -˙ -k - -- -B - -˙ -k - -- -L - -˙ -0 - -L -k -T - - -- -L -k - -L - -˙ -0 -T - - -) -L -0 -- -T - - - - - - -L -0 --1 - - -L - -˙ -k - -= -low - -[ -L -0 --1 - - -( -A - -˙ -k - -- -B - -˙ -k - -- -L - -˙ -0 - -L -k -T - - -- -L -k - -L - -˙ -0 -T - - -) -L -0 -- -T - - -] - - - - -L - -˙ -k - -= -L -0 - -low - -[ -L -0 --1 - - -( -A - -˙ -k - -- -B - -˙ -k - -- -L - -˙ -0 - -L -k -T - - -- -L -k - -L - -˙ -0 -T - - -) -L -0 -- -T - - -] - - -The matrix - -A -k - - - - is symmetric, it follows that - - -A - -¯ -k - -= - -+ - - -1 - -2 - - -( -M -k - -+ -M -k -T - - -) - - -where - - -M -k - -= -L -0 -- -T - - -low - -( -L -0 -T - - -L - -¯ -k - -) -T - - -L -0 --1 - - - - -The matrix - -B -k - - - - is also symmetric, hence - - -B - -¯ -k - -= -- - -1 - -2 - - -( -M -k - -+ -M -k -T - - -) - - -We define the symmetric matrix - -C -k - -( -s -) - - - by - - -C - -˙ -k - -= -L - -˙ -0 - -L -k -T - - -+ -L -k - -L - -˙ -0 -T - - - - -and remove the dependency on - -C -k - - - - with - - -tr - -( -C - -¯ -k -T - - -C - -˙ -k - -) -= -tr - -( -B - -¯ -k -T - - -C - -˙ -k - -) -= -tr - -( -B - -¯ -k -T - - -L - -˙ -0 - -L -k -T - - -) -+ -tr - -( -B - -¯ -k -T - - -L -k - -L - -˙ -0 -T - - -) - - - - -= -tr - -( -L -k -T - - -B - -¯ -k -T - - -L - -˙ -0 - -) -+ -tr - -( -L -k -T - - -B - -¯ -k - -L - -˙ -0 - -) - - - - -= -tr - -[ -L -k -T - - -( -B - -¯ -k - -+ -B - -¯ -k -T - - -) -L - -˙ -0 - -] - - -Thus, removing - -C -k - - - - from the dependency results in the -following update to - -L - -¯ -0 - - - -: - - -L - -¯ -0 - -= - -+ - - -lower - -[ -( -B - -¯ -k - -+ -B - -¯ -k -T - - -) -L -k - -] - - -which is the same as - - -L - -¯ -0 - -= - -+ - - -2 - -lower - -[ -B - -¯ -k - -L -k - -] - - -We still need to remove - -B -k - - - - from the dependency. -It follows from its definition that - - -B - -˙ -k - -= - - -= -1 - -k --1 - - -L - -˙ - - -L -k -- - - -T - - -+ -L - - -L - -˙ -k -- - - -T - - - - - - -tr - -( -B - -¯ -k -T - - -B - -˙ -k - -) -= - - -= -1 - -k --1 - - -tr - -( -B - -¯ -k -T - - -L - -˙ - - -L -k -- - - -T - - -) -+ -tr - -( -B - -¯ -k -T - - -L - - -L - -˙ -k -- - - -T - - -) - - - - -= - - -= -1 - -k --1 - - -tr - -( -L -k -- - - -T - - -B - -¯ -k -T - - -L - -˙ - - -) -+ - - -= -1 - -k --1 - - -tr - -( -L - -T - - -B - -¯ -k - -L - -˙ -k -- - - - -) - - -We now use the fact that - -B - -¯ -k - - - - is symmetric to conclude - - -tr - -( -B - -¯ -k -T - - -B - -˙ -k - -) -= -2 - - -= -1 - -k --1 - - -tr - -( -L -k -- - - -T - - -B - -¯ -k -T - - -L - -˙ - - -) - - -Each of the - -L - -˙ - - - - - matrices is lower triangular. -Thus, removing - -B -k - - - - from the dependency results in the following -update for - - -= -1 -, - -, -k --1 - - -: - - -L - -¯ - - -= - -+ - - -2 - -lower - -( -B - -¯ -k - -L -k -- - - - -) - - - -
Input File: omh/appendix/theory/cholesky.omh - - - diff -Nru cppad-2018.00.00.0/doc/_cholesky_theory_xml.js cppad-2019.02.00.0/doc/_cholesky_theory_xml.js --- cppad-2018.00.00.0/doc/_cholesky_theory_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cholesky_theory_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +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', -'atomic.xml', -'atomic_base.xml', -'atomic_eigen_cholesky.cpp.xml', -'cholesky_theory.xml' -]; -var list_down3 = [ -'checkpoint.xml', -'atomic_base.xml' -]; -var list_down2 = [ -'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_for_sparse_hes.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_set_sparsity.cpp.xml', -'atomic_tangent.cpp.xml', -'atomic_eigen_mat_mul.cpp.xml', -'atomic_eigen_mat_inv.cpp.xml', -'atomic_eigen_cholesky.cpp.xml', -'atomic_mat_mul.cpp.xml' -]; -var list_down1 = [ -'cholesky_theory.xml', -'atomic_eigen_cholesky.hpp.xml' -]; -var list_current0 = [ -'cholesky_theory.xml#Reference', -'cholesky_theory.xml#Notation', -'cholesky_theory.xml#Notation.Cholesky Factor', -'cholesky_theory.xml#Notation.Taylor Coefficient', -'cholesky_theory.xml#Notation.Lower Triangular Part', -'cholesky_theory.xml#Forward Mode', -'cholesky_theory.xml#Lemma 1', -'cholesky_theory.xml#Lemma 1.Proof', -'cholesky_theory.xml#Lemma 2', -'cholesky_theory.xml#Reverse Mode', -'cholesky_theory.xml#Reverse Mode.Case k = 0', -'cholesky_theory.xml#Reverse Mode.Case k > 0' -]; -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]; -} Binary files /tmp/tmpTwBTkM/UyeeZ_oWm3/cppad-2018.00.00.0/doc/_closeblue.gif and /tmp/tmpTwBTkM/C6x_sNH1xf/cppad-2019.02.00.0/doc/_closeblue.gif differ Binary files /tmp/tmpTwBTkM/UyeeZ_oWm3/cppad-2018.00.00.0/doc/_close.gif and /tmp/tmpTwBTkM/C6x_sNH1xf/cppad-2019.02.00.0/doc/_close.gif differ diff -Nru cppad-2018.00.00.0/doc/cmake_check.xml cppad-2019.02.00.0/doc/cmake_check.xml --- cppad-2018.00.00.0/doc/cmake_check.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/cmake_check.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,187 +0,0 @@ - - - -Checking the CppAD Examples and Tests - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -cmake_check - -

- - - -
Checking the CppAD Examples and Tests
-
-Purpose -
-After you configure your system with the -cmake command - you -can run the CppAD example and tests to make sure that -CppAD functions properly on your system. - - -
-
-Check All -
-In the build subdirectory of the -distribution directory - -execute the command -
 
-     make check
-
-This will build and run all of the tests that are support -by your system and the cmake - command options. - -
-
-Windows -
-If you created nmake makefiles, you will have -to use nmake instead of make in the commands -above and below; see -windows file extraction and testing -. - -
-
-Subsets of make check -
-In unix, you can determine which subsets of make check are available -by putting the output of the cmake command - -in a file (called -cmake.out - below) and executing: - -
-     grep 'make check.*available' 
cmake.out
-
-
-First Level -
-The first level of subsets of make check are described below: - -
- -Command - - Description -
- -make check_introduction - - the Introduction - functions -
- -make check_example - - the normal example - functions plus some deprecated - examples. -
- -make check_test_more - - correctness tests that are not examples -
- -make check_speed - - correctness for single thread speed - tests -
- -make check_cppad_ipopt - - the deprecated cppad_ipopt_nlp - speed and correctness tests -
- -
-Note that make check_example_multi_thread is used for the -multi-threading - speed tests. - - - -
Input File: omh/install/cmake_check.omh - - - diff -Nru cppad-2018.00.00.0/doc/_cmake_check_xml.js cppad-2019.02.00.0/doc/_cmake_check_xml.js --- cppad-2018.00.00.0/doc/_cmake_check_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cmake_check_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +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_check.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' -]; -var list_current0 = [ -'cmake_check.xml#Purpose', -'cmake_check.xml#Check All', -'cmake_check.xml#Check All.Windows', -'cmake_check.xml#Subsets of make check', -'cmake_check.xml#First Level' -]; -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-2018.00.00.0/doc/cmake.xml cppad-2019.02.00.0/doc/cmake.xml --- cppad-2018.00.00.0/doc/cmake.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/cmake.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,652 +0,0 @@ - - - -Using CMake to Configure CppAD - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - - -
Using CMake to Configure CppAD
-
-The CMake Program -
-The -cmake - -program enables one to create a single set of scripts, -called CMakeLists.txt, -that can be used to test and install a program on Unix, Microsoft, or -Apple operating systems. -For example, one can use it to automatically generate Microsoft project files. - -
-
-CMake Command -
-The command below assumes that cmake is in your execution -path with version greater than or equal 2.8. -If not, you can put the path to the version of cmake -in font the command. -Only the cmake command and the path to the distribution directory -(.. 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. - -
-
-Build Directory -
-Create a build subdirectory of the -distribution directory -, -change into the build directory, -and execute the following command: - -
-cmake 
                                                                     \
-    -D CMAKE_VERBOSE_MAKEFILE=
cmake_verbose_makefile                       \
-    -G 
generator                                                           \
-     \
-    -D cppad_prefix=
cppad_prefix                                           \
-    -D cppad_postfix=
cppad_postfix                                         \
-     \
-    -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_tape_id_type=
cppad_tape_id_type                               \
-    -D cppad_tape_addr_type=
cppad_tape_addr_type                           \
-    -D cppad_debug_which=
cppad_debug_which                                 \
-    -D cppad_deprecated=
cppad_deprecated                                   \
-    \
-    ..
-
-
-make check -
-Important information about the CppAD configuration is output -by this command. If you have the grep program, -and store the output in cmake.log, you can get a list of -all the test options with the command: -
 
-     grep 'make check' cmake.log
-
-
-cmake_verbose_makefile -
-This value should be either YES or NO. -The default value, when it is not present, is NO. -If it is YES, then the output of the 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. - -
-
-generator -
-The CMake program is capable of generating different kinds of files. -Below is a table with a few of the possible files - -
- - -generator - - Description
- -"Unix Makefiles" - make files for unix operating system
- -"NMake Makefiles" - make files for Visual Studio -
-Other generator choices are available; see the cmake -generators - documentation. - -
-
-cppad_prefix -
-This is the top level absolute path below which -all of the CppAD files are installed by the command - -
-     make install
-
-For example, -if -cppad_prefix - is /usr, - -cmake_install_includedirs - is include, and - -cppad_postfix - is not specified, -the file cppad.hpp is installed in the location - -
-     /usr/include/cppad/cppad.hpp
-
-The default value for -cppad_prefix - is /usr. - -
-
-cppad_postfix -
-This is the bottom level relative path below which -all of the CppAD files are installed. -For example, -if -cppad_prefix - is /usr, - -cmake_install_includedirs - is include, and - -cppad_postfix - is coin, -the file cppad.hpp is installed in the location - -
-     /usr/include/coin/cppad/cppad.hpp
-
-The default value for -cppad_postfix - is empty; i.e, -there is no bottom level relative directory for the installed files. - - -
-
-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 -cppad_prefix - is /usr, - -cmake_install_includedirs - is include, and - -cppad_postfix - is not specified, -the file cppad.hpp is installed in the location - -
-     /usr/include/cppad/cppad.hpp
-
-The default value for this directory list is include. - - -
-
-cmake_install_libdirs -
-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 -cppad_prefix - is /usr, - -cmake_install_libdirs - is lib, - -cppad_postfix - is not specified, -and -ipopt_prefix - is specified, -the file libcppad_ipopt.a is installed in the location - -
-     /usr/lib/libcppad_ipopt.a
-
-The default value for this directory list is lib. - -
-
-cmake_install_datadir -
-This is the middle level relative path below which -the CppAD data files are installed. -For example, -if -cppad_prefix - is /usr, - -cmake_install_datadir - is share, and - -cppad_postfix - is not specified, -the pkgconfig - file cppad.pc is installed in the location - -
-     /usr/share/pkgconfig/cppad.pc
-
-The default value for -cmake_install_datadir - is share. - -
-
-cmake_install_docdir -
-This is the middle level relative path below which -the CppAD documentation files are installed. -For example, -if -cppad_prefix - is /usr, - -cmake_install_docdir - is share/doc, and - -cppad_postfix - is not specified, -the file cppad.xml is installed in the location - -
-     /usr/share/doc/cppad/cppad.xml
-
-There is no default value for -cmake_install_docdir -. -If it is not specified, the documentation files are not installed. - -
-
-package_prefix -
-Each of these packages corresponds to optional CppAD examples, -that can be compiled and tested if the corresponding prefix is provided: - - - - - - - -
- -adolc_prefix -Including the ADOL-C Examples and Tests
- -colpack_prefix -Including the ColPack Sparsity Calculations
- -eigen_prefix -Including the Eigen Examples and Tests
- -fadbad_prefix -Including the FADBAD Speed Tests
- -ipopt_prefix -Including the cppad_ipopt Library and Tests
- -sacado_prefix -Including the Sacado Speed Tests
- -
-
-cppad_cxx_flags -
-This specifies the addition compiler flags -that are used when compiling the CppAD examples and tests. -The default value for these flags is the empty string "". -These flags must be valid for the C++ compiler -on your system. -For example, if you are using g++ you could specify -
 
-     -D cppad_cxx_flags="-Wall -ansi -pedantic-errors -std=c++11 -Wshadow"
-
-
-C++11 -
-In order for the compiler to take advantage of features that are new in C++11, -the -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., _MSC_VER is defined). - -
-
-debug and release -
-The CppAD examples and tests decide which files to compile for debugging -and which to compile for release. Hence debug and release flags should -not be included in -cppad_cxx_flags -. -See also the -CPPAD_DEBUG_AND_RELEASE - -compiler flag (which should not be included in -cppad_cxx_flags -). - -
-
-cppad_profile_flag -
-This specifies an addition compiler and link flag that is used -for profiling - the speed tests. -A profile version of the speed test is only build when this argument -is present. - -
-
-Eigen and Fadbad -
-The packages -eigen - and fadbad - -currently generate a lot of shadowed variable warnings. -If the -Wshadow flag is present, it is automatically removed when -compiling examples and test that use these packages. - -
-
-cppad_testvector -
-See Choosing the CppAD Test Vector Template Class. - -
-
-cppad_max_num_threads -
-The value -cppad_max_num_threads - -must be greater than or equal to four; i.e., - -max_num_threads >= 4 -. -The current default value for -cppad_max_num_threads - is 48, -but it may change in future versions of CppAD. -The value -cppad_max_num_threads - in turn specifies -the default value for the preprocessor symbol -CPPAD_MAX_NUM_THREADS -. - -
-
-cppad_tape_id_type -
-The type -cppad_tape_id_type - -is used for identifying different tapes. -The valid values for this type are -unsigned char, -unsigned short int, -unsigned int, and -size_t. -The smaller the value of -sizeof(cppad_tape_id_type) -, -the less memory is used. -On the other hand, the value - -
-     std::numeric_limits<
cppad_tape_id_type>::max()
-
-must be larger than the maximum number of tapes used by one thread times -CPPAD_MAX_NUM_THREADS -. - -
-
-cstdint -
-If all of the following cstdint types are defined, -they can also be used as the value of -cppad_tape_addr_type -: -uint8_t, -uint16_t, -uint32_t, -uint64_t. - -
-
-cppad_tape_addr_type -
-The type -cppad_tape_addr_type - -is used for address in the AD recordings (tapes). -The valid values for this argument are -unsigned char, -unsigned short int, -unsigned int, -size_t. -The smaller the value of -sizeof(cppad_tape_addr_type) -, -the less memory is used. -On the other hand, the value - -
-     std::numeric_limits<
cppad_tape_addr_type>::max()
-
-must be larger than any of the following: -size_op -, -size_op_arg -, -size_par -, -size_text -, -size_VecAD -. - -
-
-cstdint -
-If all of the following cstdint types are defined, -they can also be used as the value of -cppad_tape_addr_type -: -uint8_t, -uint16_t, -uint32_t, -uint64_t. - -
-
-cppad_debug_which -
-All of the CppAD examples and test can optionally be tested -in debug or release mode (see exception below). -This option controls which mode is chosen for the corresponding files. -The value -cppad_debug_which - be one of the following: -debug_even, debug_odd, debug_all, debug_none. -If it is debug_even (debug_odd), -files with an even (old) index in a list for each case will be compiled -in debug mode. The remaining files will be compiled in release mode. -If it is debug_all (debug_none), -all the files will be compiled in debug (release) mode. -If -cppad_debug_which - does not appear on the command line, -the default value debug_all is used. - -
-
-Exception -
-The test corresponding to make cppad_ipopt_speed -always get complied in release more (to avoid the extra time -it would take to run in debug mode). -Note that this test corresponds a deprecated interface; see -cppad_ipopt_nlp -. - -
-
-cppad_deprecated -
-The default value for -cppad_deprecated - is NO -(the value YES is not currently being used). - - - - - -
Input File: omh/install/cmake.omh - - - diff -Nru cppad-2018.00.00.0/doc/_cmake_xml.js cppad-2019.02.00.0/doc/_cmake_xml.js --- cppad-2018.00.00.0/doc/_cmake_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cmake_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +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' -]; -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' -]; -var list_down0 = [ -'adolc_prefix.xml', -'colpack_prefix.xml', -'eigen_prefix.xml', -'fadbad_prefix.xml', -'ipopt_prefix.xml', -'sacado_prefix.xml', -'cppad_testvector.xml' -]; -var list_current0 = [ -'cmake.xml#The CMake Program', -'cmake.xml#CMake Command', -'cmake.xml#CMake Command.Build Directory', -'cmake.xml#make check', -'cmake.xml#cmake_verbose_makefile', -'cmake.xml#generator', -'cmake.xml#cppad_prefix', -'cmake.xml#cppad_postfix', -'cmake.xml#cmake_install_includedirs', -'cmake.xml#cmake_install_libdirs', -'cmake.xml#cmake_install_datadir', -'cmake.xml#cmake_install_docdir', -'cmake.xml#package_prefix', -'cmake.xml#cppad_cxx_flags', -'cmake.xml#cppad_cxx_flags.C++11', -'cmake.xml#cppad_cxx_flags.debug and release', -'cmake.xml#cppad_profile_flag', -'cmake.xml#cppad_profile_flag.Eigen and Fadbad', -'cmake.xml#cppad_testvector', -'cmake.xml#cppad_max_num_threads', -'cmake.xml#cppad_tape_id_type', -'cmake.xml#cppad_tape_id_type.cstdint', -'cmake.xml#cppad_tape_addr_type', -'cmake.xml#cppad_tape_addr_type.cstdint', -'cmake.xml#cppad_debug_which', -'cmake.xml#cppad_debug_which.Exception', -'cmake.xml#cppad_deprecated' -]; -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-2018.00.00.0/doc/colpack_hes.cpp.xml cppad-2019.02.00.0/doc/colpack_hes.cpp.xml --- cppad-2018.00.00.0/doc/colpack_hes.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/colpack_hes.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,226 +0,0 @@ - - - -ColPack: Sparse Hessian Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -colpack_hes.cppHeadings

-
ColPack: Sparse Hessian 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;
-     typedef CppAD::sparse_rc<i_vector>              sparsity;
-     typedef CppAD::sparse_rcv<i_vector, d_vector>   sparse_matrix;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-     //
-     // domain space vector
-     size_t n = 5;
-     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);
-
-     // 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(size_t 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(size_t 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(size_t 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 ]
-     */
-     // Normally one would use CppAD to compute sparsity pattern, but for this
-     // example we set it directly
-     size_t nr  = n;
-     size_t nc  = n;
-     size_t nnz = n + 2 * (n - 1);
-     sparsity pattern(nr, nc, nnz);
-     for(size_t k = 0; k < n; k++)
-     {     size_t r = k;
-          size_t c = k;
-          pattern.set(k, r, c);
-     }
-     for(size_t i = 1; i < n; i++)
-     {     size_t k = n + 2 * (i - 1);
-          size_t r = i;
-          size_t c = 0;
-          pattern.set(k,   r, c);
-          pattern.set(k+1, c, r);
-     }
-
-     // subset of elements to compute
-     // (only compute lower traingle)
-     nnz = n + (n - 1);
-     sparsity lower_triangle(nr, nc, nnz);
-     d_vector check(nnz);
-     for(size_t k = 0; k < n; k++)
-     {     size_t r = k;
-          size_t c = k;
-          lower_triangle.set(k, r, c);
-          check[k] = 2.0 * x[k];
-          if( k > 0 )
-               check[k] += x[0];
-     }
-     for(size_t j = 1; j < n; j++)
-     {     size_t k = n + (j - 1);
-          size_t r = 0;
-          size_t c = j;
-          lower_triangle.set(k, r, c);
-          check[k] = x[c];
-     }
-     sparse_matrix subset( lower_triangle );
-
-     // check results for both CppAD and Colpack
-     for(size_t i_method = 0; i_method < 4; i_method++)
-     {     // coloring method
-          std::string coloring;
-          switch(i_method)
-          {     case 0:
-               coloring = "cppad.symmetric";
-               break;
-
-               case 1:
-               coloring = "cppad.general";
-               break;
-
-               case 2:
-               coloring = "colpack.symmetric";
-               break;
-
-               case 3:
-               coloring = "colpack.general";
-               break;
-          }
-          //
-          // compute Hessian
-          CppAD::sparse_hes_work work;
-          d_vector w(m);
-          w[0] = 1.0;
-          size_t n_sweep = f.sparse_hes(
-               x, w, subset, pattern, coloring, work
-          );
-          //
-          // check result
-          const d_vector& hes( subset.val() );
-          for(size_t k = 0; k < nnz; k++)
-               ok &= NearEqual(check[k], hes[k], eps, eps);
-          if(
-               coloring == "cppad.symmetric"
-          ||     coloring == "colpack.symmetric"
-          )
-               ok &= n_sweep == 2;
-          else
-               ok &= n_sweep == 5;
-     }
-
-     return ok;
-}
-
-
Input File: example/sparse/colpack_hes.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_colpack_hes.cpp_xml.js cppad-2019.02.00.0/doc/_colpack_hes.cpp_xml.js --- cppad-2018.00.00.0/doc/_colpack_hes.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_colpack_hes.cpp_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', -'install.xml', -'cmake.xml', -'colpack_prefix.xml', -'colpack_hes.cpp.xml' -]; -var list_down3 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.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_jacobian.cpp.xml', -'colpack_hes.cpp.xml', -'colpack_hessian.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-2018.00.00.0/doc/colpack_hessian.cpp.xml cppad-2019.02.00.0/doc/colpack_hessian.cpp.xml --- cppad-2018.00.00.0/doc/colpack_hessian.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/colpack_hessian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,227 +0,0 @@ - - - -ColPack: Sparse Hessian Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -colpack_hessian.cppHeadings

-
ColPack: Sparse Hessian Example and Test
-

-# include <cppad/cppad.hpp>
-bool colpack_hessian(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 lower triangle
-                    if( j <= i )
-                    {     row.push_back(i);
-                         col.push_back(j);
-                    }
-               }
-          }
-     }
-     size_t K = row.size();
-     d_vector hes(K);
-
-     // default coloring method is cppad.symmetric
-     CppAD::sparse_hessian_work work;
-     ok &= work.color_method == "cppad.symmetric";
-
-     // contrast and check results for both CppAD and Colpack
-     for(size_t i_method = 0; i_method < 4; i_method++)
-     {     // empty work structure
-          switch(i_method)
-          {     case 0:
-               work.color_method = "cppad.symmetric";
-               break;
-
-               case 1:
-               work.color_method = "cppad.general";
-               break;
-
-               case 2:
-               work.color_method = "colpack.symmetric";
-               break;
-
-               case 3:
-               work.color_method = "colpack.general";
-               break;
-          }
-
-          // 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.symmetric"
-          ||     work.color_method == "colpack.symmetric"
-          )
-               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/sparse/colpack_hessian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_colpack_hessian.cpp_xml.js cppad-2019.02.00.0/doc/_colpack_hessian.cpp_xml.js --- cppad-2018.00.00.0/doc/_colpack_hessian.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_colpack_hessian.cpp_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', -'install.xml', -'cmake.xml', -'colpack_prefix.xml', -'colpack_hessian.cpp.xml' -]; -var list_down3 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.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_jacobian.cpp.xml', -'colpack_hes.cpp.xml', -'colpack_hessian.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-2018.00.00.0/doc/colpack_jac.cpp.xml cppad-2019.02.00.0/doc/colpack_jac.cpp.xml --- cppad-2018.00.00.0/doc/colpack_jac.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/colpack_jac.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,189 +0,0 @@ - - - -ColPack: Sparse Jacobian Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -colpack_jac.cppHeadings

- - - -
ColPack: Sparse Jacobian 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;
-     typedef CppAD::sparse_rc<i_vector>              sparsity;
-     typedef CppAD::sparse_rcv<i_vector, d_vector>   sparse_matrix;
-
-     // domain space vector
-     size_t n = 4;
-     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);
-
-     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(size_t j = 0; j < n; j++)
-          x[j] = double(j);
-
-     /*
-           [ 1 1 0 0  ]
-     jac = [ 0 0 1 1  ]
-           [ 1 1 1 x_3]
-     */
-     // Normally one would use CppAD to compute sparsity pattern, but for this
-     // example we set it directly
-     size_t nr  = m;
-     size_t nc  = n;
-     size_t nnz = 8;
-     sparsity pattern(nr, nc, nnz);
-     d_vector check(nnz);
-     for(size_t k = 0; k < nnz; k++)
-     {     size_t r, c;
-          if( k < 2 )
-          {     r = 0;
-               c = k;
-          }
-          else if( k < 4 )
-          {     r = 1;
-               c = k;
-          }
-          else
-          {     r = 2;
-               c = k - 4;
-          }
-          pattern.set(k, r, c);
-          if( k == nnz - 1 )
-               check[k] = x[3];
-          else
-               check[k] = 1.0;
-     }
-
-     // using row and column indices to compute non-zero in rows 1 and 2
-     sparse_matrix subset( pattern );
-
-     // check results for both CppAD and Colpack
-     for(size_t i_method = 0; i_method < 4; i_method++)
-     {     // coloring method
-          std::string coloring;
-          if( i_method % 2 == 0 )
-               coloring = "cppad";
-          else
-               coloring = "colpack";
-          //
-          CppAD::sparse_jac_work work;
-          size_t group_max = 1;
-          if( i_method / 2 == 0 )
-          {     size_t n_sweep = f.sparse_jac_for(
-                    group_max, x, subset, pattern, coloring, work
-               );
-               ok &= n_sweep == 4;
-          }
-          else
-          {     size_t n_sweep = f.sparse_jac_rev(
-                    x, subset, pattern, coloring, work
-               );
-               ok &= n_sweep == 2;
-          }
-          const d_vector& hes( subset.val() );
-          for(size_t k = 0; k < nnz; k++)
-               ok &= check[k] == hes[k];
-     }
-     return ok;
-}
-
-
Input File: example/sparse/colpack_jac.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_colpack_jac.cpp_xml.js cppad-2019.02.00.0/doc/_colpack_jac.cpp_xml.js --- cppad-2018.00.00.0/doc/_colpack_jac.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_colpack_jac.cpp_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', -'install.xml', -'cmake.xml', -'colpack_prefix.xml', -'colpack_jac.cpp.xml' -]; -var list_down3 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.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_jacobian.cpp.xml', -'colpack_hes.cpp.xml', -'colpack_hessian.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-2018.00.00.0/doc/colpack_jacobian.cpp.xml cppad-2019.02.00.0/doc/colpack_jacobian.cpp.xml --- cppad-2018.00.00.0/doc/colpack_jacobian.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/colpack_jacobian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,177 +0,0 @@ - - - -ColPack: Sparse Jacobian Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -colpack_jacobian.cppHeadings

-
ColPack: Sparse Jacobian Example and Test
-

-# include <cppad/cppad.hpp>
-bool colpack_jacobian(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/sparse/colpack_jacobian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_colpack_jacobian.cpp_xml.js cppad-2019.02.00.0/doc/_colpack_jacobian.cpp_xml.js --- cppad-2018.00.00.0/doc/_colpack_jacobian.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_colpack_jacobian.cpp_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', -'install.xml', -'cmake.xml', -'colpack_prefix.xml', -'colpack_jacobian.cpp.xml' -]; -var list_down3 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.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_jacobian.cpp.xml', -'colpack_hes.cpp.xml', -'colpack_hessian.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-2018.00.00.0/doc/colpack_prefix.xml cppad-2019.02.00.0/doc/colpack_prefix.xml --- cppad-2018.00.00.0/doc/colpack_prefix.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/colpack_prefix.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ - - - -Including the ColPack Sparsity Calculations - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - -
Including the ColPack Sparsity Calculations
-
-Purpose -
-If you specify a -colpack_prefix - on the -cmake command - line, -the CppAD sparse_jacobian - calculations use the -ColPack - package. - -
-
-colpack_prefix -
-If ColPack is installed on your system, you can -specify a value for its install -colpack_prefix - on the -cmake - command line. -The value of -colpack_prefix - must be such that, -for one of the directories -dir - in -cmake_install_includedirs -, - -
-     
colpack_prefix/dir/ColPack/ColPackHeaders.h
-
-is a valid way to reference to the include file ColPackHeaders.h. - -
-
-cppad_lib -
-The ColPack header files has a - -
-     using namespace std
-
-at the global level. -For this reason, CppAD does not include these files. -It is therefore necessary to link the object library cppad_lib -when using ColPack. - - -
-
-Example -
-The file colpack_jac.cpp - (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. - -
-
-get_colpack -
-If you are using Unix, you can download and install -a copy of ColPack using get_colpack.sh -. -The corresponding -colpack_prefix - would be -build/prefix. - - -
Input File: omh/install/colpack_prefix.omh - - - diff -Nru cppad-2018.00.00.0/doc/_colpack_prefix_xml.js cppad-2019.02.00.0/doc/_colpack_prefix_xml.js --- cppad-2018.00.00.0/doc/_colpack_prefix_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_colpack_prefix_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', -'cmake.xml', -'colpack_prefix.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 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.xml' -]; -var list_down1 = [ -'adolc_prefix.xml', -'colpack_prefix.xml', -'eigen_prefix.xml', -'fadbad_prefix.xml', -'ipopt_prefix.xml', -'sacado_prefix.xml', -'cppad_testvector.xml' -]; -var list_down0 = [ -'colpack_jac.cpp.xml', -'colpack_jacobian.cpp.xml', -'colpack_hes.cpp.xml', -'colpack_hessian.cpp.xml', -'get_colpack.sh.xml' -]; -var list_current0 = [ -'colpack_prefix.xml#Purpose', -'colpack_prefix.xml#colpack_prefix', -'colpack_prefix.xml#cppad_lib', -'colpack_prefix.xml#Example', -'colpack_prefix.xml#get_colpack' -]; -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-2018.00.00.0/doc/compare_change.cpp.xml cppad-2019.02.00.0/doc/compare_change.cpp.xml --- cppad-2018.00.00.0/doc/compare_change.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/compare_change.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,249 +0,0 @@ - - - -CompareChange and Re-Tape: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -compare_change.cppHeadings

- - - -
CompareChange and Re-Tape: Example and Test
-

-# include <cppad/cppad.hpp>
-
-namespace { // put this function in the empty namespace
-     template <typename Type>
-     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;
-     }
-     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 compare_change(void)
-{     bool ok = true;
-     using CppAD::AD;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 3.;
-     ax[1] = 4.;
-
-     // 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] = Minimum(ax[0], ax[1]);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // set count to one (not necessry because is its default value)
-     f.compare_change_count(1);
-
-     // 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.compare_change_number() == 0);
-     ok  &= (f.compare_change_op_index() == 0);
-
-     // 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.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<double>::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<double>::abort_recording();
-          }
-     }
-# ifdef CPPAD_DEBUG_AND_RELEASE
-     if( missed_error )
-     {     // This routine is compiled for debugging, but the routine that checks
-          // operator indices was compiled for release.
-          missed_error = false;
-          AD<double>::abort_recording();
-     }
-# endif
-     ok &= ! missed_error;
-
-     // 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);
-
-     // 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.compare_change_number()   == 0);
-     ok  &= (f.compare_change_op_index() == 0);
-
-     return ok;
-}
-
-
-
-
Input File: example/general/compare_change.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_compare_change.cpp_xml.js cppad-2019.02.00.0/doc/_compare_change.cpp_xml.js --- cppad-2018.00.00.0/doc/_compare_change.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_compare_change.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'compare_change.xml', -'compare_change.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_down1 = [ -'compare_change.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-2018.00.00.0/doc/compare_change.xml cppad-2019.02.00.0/doc/compare_change.xml --- cppad-2018.00.00.0/doc/compare_change.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/compare_change.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,415 +0,0 @@ - - - -Comparison Changes Between Taping and Zero Order Forward - - - - - - - - - - - - - - - - -
- -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-2018.00.00.0/doc/comparechange.xml cppad-2019.02.00.0/doc/comparechange.xml --- cppad-2018.00.00.0/doc/comparechange.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/comparechange.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,244 +0,0 @@ - - - -Comparison Changes During Zero Order Forward Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -CompareChange - -

- - - -
Comparison Changes During Zero Order Forward Mode
-
-Syntax - -
- -c = f.CompareChange() - -
-
See Also -FunCheck - - -
-
-Deprecated 2015-01-20 -
-This routine has been deprecated, use compare_change - -instead. - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -This function may be not agree with the algorithm that was used -to create the corresponding -AD of -Base - -operation sequence - -because of changes in AD -comparison - results. -The CompareChange function can be used to detect these changes. - -
-
-f -
-The object -f - has prototype - -
-     const ADFun<
Basef
-
-
-c -
-The result -c - has prototype - -
-     size_t 
c
-
-It is the number of - -AD<Base> - comparison - -operations, -corresponding to the previous call to Forward - - -
-     
f.Forward(0, x)
-
-that have a different result from -when -F - was created by taping an algorithm. - -
-
-Discussion -
-If -c - is not zero, -the boolean values resulting from some of the -comparison operations - corresponding to -x - -are different from when the -AD of -Base - -operation sequence - was created. -In this case, you may want to re-tape the algorithm with the -independent variables - -equal to the values in -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 forward_zero -. -If the functions values have not changed (see FunCheck -) -it may not be worth re-taping a new AD operation sequence. - - - -
Input File: omh/appendix/deprecated/compare_change.omh - - - diff -Nru cppad-2018.00.00.0/doc/_compare_change_xml.js cppad-2019.02.00.0/doc/_compare_change_xml.js --- cppad-2018.00.00.0/doc/_compare_change_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_compare_change_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'compare_change.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_down0 = [ -'compare_change.cpp.xml' -]; -var list_current0 = [ -'compare_change.xml#Syntax', -'compare_change.xml#Purpose', -'compare_change.xml#f', -'compare_change.xml#count', -'compare_change.xml#count.Speed', -'compare_change.xml#number', -'compare_change.xml#number.Discussion', -'compare_change.xml#op_index', -'compare_change.xml#op_index.Purpose', -'compare_change.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-2018.00.00.0/doc/_comparechange_xml.js cppad-2019.02.00.0/doc/_comparechange_xml.js --- cppad-2018.00.00.0/doc/_comparechange_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_comparechange_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'comparechange.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', -'directory.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', -'autotools.xml' -]; -var list_current0 = [ -'comparechange.xml#Syntax', -'comparechange.xml#Deprecated 2015-01-20', -'comparechange.xml#Purpose', -'comparechange.xml#f', -'comparechange.xml#c', -'comparechange.xml#Discussion' -]; -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-2018.00.00.0/doc/compare.cpp.xml cppad-2019.02.00.0/doc/compare.cpp.xml --- cppad-2018.00.00.0/doc/compare.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/compare.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ - - - -AD Binary Comparison Operators: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -compare.cppHeadings

- - - -
AD Binary Comparison Operators: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool Compare(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // declare independent variables and start tape recording
-     size_t n  = 2;
-     double x0 = 0.5;
-     double x1 = 1.5;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0]      = x0;
-     x[1]      = x1;
-     CppAD::Independent(x);
-
-     // some binary comparision operations
-     AD<double> p;
-     if( x[0] < x[1] )
-          p = x[0];   // values in x choose this case
-     else     p = x[1];
-     if( x[0] <= x[1] )
-          p *= x[0];  // values in x choose this case
-     else     p *= x[1];
-     if( x[0] >  x[1] )
-          p *= x[0];
-     else     p *= x[1];  // values in x choose this case
-     if( x[0] >= x[1] )
-          p *= x[0];
-     else     p *= x[1];  // values in x choose this case
-     if( x[0] == x[1] )
-          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];
-
-     // dependent variable vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = p;
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0] , x0*x0*x1*x1*x1*x0, eps99, eps99);
-
-     // forward computation of partials w.r.t. x[0]
-     CPPAD_TESTVECTOR(double) dx(n);
-     CPPAD_TESTVECTOR(double) dy(m);
-     dx[0] = 1.;
-     dx[1] = 0.;
-     dy    = f.Forward(1, dx);
-     ok   &= NearEqual(dy[0], 3.*x0*x0*x1*x1*x1, eps99, eps99);
-
-     // forward computation of partials w.r.t. x[1]
-     dx[0] = 0.;
-     dx[1] = 1.;
-     dy    = f.Forward(1, dx);
-     ok   &= NearEqual(dy[0], 3.*x0*x0*x1*x1*x0, eps99, eps99);
-
-     // 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], 3.*x0*x0*x1*x1*x1, eps99, eps99);
-     ok   &= NearEqual(dw[1], 3.*x0*x0*x1*x1*x0, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/compare.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_compare.cpp_xml.js cppad-2019.02.00.0/doc/_compare.cpp_xml.js --- cppad-2018.00.00.0/doc/_compare.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_compare.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'boolvalued.xml', -'compare.xml', -'compare.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 = [ -'compare.xml', -'nearequalext.xml', -'boolfun.xml', -'parvar.xml', -'equalopseq.xml' -]; -var list_down1 = [ -'compare.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-2018.00.00.0/doc/compare_c.xml cppad-2019.02.00.0/doc/compare_c.xml --- cppad-2018.00.00.0/doc/compare_c.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/compare_c.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ - - - -Compare Speed of C and C++ - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Compare Speed of C and C++
-
-Syntax - -
- -test_more/compare_c/det_by_minor_c
-
- -test_more/compare_c/det_by_minor_cpp - - -
-
-Purpose -
-Compares the speed of the exact same source code compiled -using C versus C++. - -
-
-Contents -
- -
det_of_minor_cDeterminant of a Minor
det_by_minor_cCompute Determinant using Expansion by Minors
uniform_01_cSimulate a [0,1] Uniform Random Variate
correct_det_by_minor_cCorrectness Test of det_by_minor Routine
repeat_det_by_minor_cRepeat det_by_minor Routine A Specified Number of Times
elapsed_seconds_cReturns Elapsed Number of Seconds
time_det_by_minor_cDetermine Amount of Time to Execute det_by_minor
main_compare_cMain Program For Comparing C and C++ Speed
-
Input File: test_more/compare_c/CMakeLists.txt - - - diff -Nru cppad-2018.00.00.0/doc/_compare_c_xml.js cppad-2019.02.00.0/doc/_compare_c_xml.js --- cppad-2018.00.00.0/doc/_compare_c_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_compare_c_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', -'appendix.xml', -'compare_c.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', -'directory.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 = [ -'det_of_minor_c.xml', -'det_by_minor_c.xml', -'uniform_01_c.xml', -'correct_det_by_minor_c.xml', -'repeat_det_by_minor_c.xml', -'elapsed_seconds_c.xml', -'time_det_by_minor_c.xml', -'main_compare_c.xml' -]; -var list_current0 = [ -'compare_c.xml#Syntax', -'compare_c.xml#Purpose', -'compare_c.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-2018.00.00.0/doc/compare.xml cppad-2019.02.00.0/doc/compare.xml --- cppad-2018.00.00.0/doc/compare.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/compare.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,316 +0,0 @@ - - - -AD Binary Comparison Operators - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
AD Binary Comparison Operators
-
-Syntax - - -
- -b = x Op y - - - -
-
-Purpose -
-Compares two operands where one of the operands is an - -AD<Base> - object. -The comparison has the same interpretation as for -the -Base - type. - - -
-
-Op -
-The operator -Op - is one of the following: - -
- -Op   - Meaning
- -< - is -x - less than -y -
- -<= - is -x - less than or equal -y -
- -> - is -x - greater than -y -
- ->= - is -x - greater than or equal -y -
- -== - is -x - equal to -y -
- -!= - is -x - not equal to -y - -
-
-x -
-The operand -x - has prototype - -
-     const 
Type &x
-
-where -Type - is -AD<Base> -, -Base -, or int. - -
-
-y -
-The operand -y - has prototype - -
-     const 
Type &y
-
-where -Type - is -AD<Base> -, -Base -, or int. - -
-
-b -
-The result -b - has type - -
-     bool 
b
-
-
-Operation Sequence -
-The result of this operation is a bool value -(not an AD of Base - object). -Thus it will not be recorded as part of an -AD of -Base - -operation sequence -. -
-
-
For example, suppose - -x - and -y - are -AD<Base> - objects, -the tape corresponding to -AD<Base> - is recording, - -b - is true, -and the subsequent code is - -
-     if( 
b )
-          
y = cos(x);
-     else 
y = sin(x);
-
-only the assignment -y = cos(x) - is recorded on the tape -(if -x - is a parameter -, -nothing is recorded). -The CompareChange - function can yield -some information about changes in comparison operation results. -You can use CondExp - to obtain comparison operations -that depends on the -independent variable - -values with out re-taping the AD sequence of operations. - -
-
-Assumptions -
-If one of the -Op - operators listed above -is used with an -AD<Base> - object, -it is assumed that the same operator is supported by the base type - -Base -. - -
-
-Example - -
-The file -compare.cpp - -contains an example and test of these operations. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/compare.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_compare_xml.js cppad-2019.02.00.0/doc/_compare_xml.js --- cppad-2018.00.00.0/doc/_compare_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_compare_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'boolvalued.xml', -'compare.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 = [ -'compare.xml', -'nearequalext.xml', -'boolfun.xml', -'parvar.xml', -'equalopseq.xml' -]; -var list_down0 = [ -'compare.cpp.xml' -]; -var list_current0 = [ -'compare.xml#Syntax', -'compare.xml#Purpose', -'compare.xml#Op', -'compare.xml#x', -'compare.xml#y', -'compare.xml#b', -'compare.xml#Operation Sequence', -'compare.xml#Assumptions', -'compare.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-2018.00.00.0/doc/complex_poly.cpp.xml cppad-2019.02.00.0/doc/complex_poly.cpp.xml --- cppad-2018.00.00.0/doc/complex_poly.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/complex_poly.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,152 +0,0 @@ - - - -Complex Polynomial: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -complex_poly.cpp - -

-
Complex Polynomial: Example and Test
-
-Poly -
-Select this link to view specifications for Poly -: - - -
// Complex examples should supppress conversion warnings
-# include <cppad/wno_conversion.hpp>
-
-# include <cppad/cppad.hpp>
-# include <complex>
-
-bool complex_poly(void)
-{     bool ok    = true;
-     size_t deg = 4;
-
-     using CppAD::AD;
-     using CppAD::Poly;
-     typedef std::complex<double> Complex;
-
-     // polynomial coefficients
-     CPPAD_TESTVECTOR( Complex )   a   (deg + 1); // coefficients for p(z)
-     CPPAD_TESTVECTOR(AD<Complex>) A   (deg + 1);
-     size_t i;
-     for(i = 0; i <= deg; i++)
-          A[i] = a[i] = Complex(double(i), double(i));
-
-     // independent variable vector
-     CPPAD_TESTVECTOR(AD<Complex>) Z(1);
-     Complex z = Complex(1., 2.);
-     Z[0]      = z;
-     Independent(Z);
-
-     // dependent variable vector and indices
-     CPPAD_TESTVECTOR(AD<Complex>) P(1);
-
-     // dependent variable values
-     P[0] = Poly(0, A, Z[0]);
-
-     // create f: Z -> P and vectors used for derivative calculations
-     CppAD::ADFun<Complex> f(Z, P);
-     CPPAD_TESTVECTOR(Complex) v( f.Domain() );
-     CPPAD_TESTVECTOR(Complex) w( f.Range() );
-
-     // check first derivative w.r.t z
-     v[0]      = 1.;
-     w         = f.Forward(1, v);
-     Complex p = Poly(1, a, z);
-     ok &= ( w[0]  == p );
-
-     // second derivative w.r.t z is 2 times its second order Taylor coeff
-     v[0] = 0.;
-     w    = f.Forward(2, v);
-     p    = Poly(2, a, z);
-     ok &= ( 2. * w[0]  == p );
-
-     return ok;
-}
-
-
-
Input File: example/general/complex_poly.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_complex_poly.cpp_xml.js cppad-2019.02.00.0/doc/_complex_poly.cpp_xml.js --- cppad-2018.00.00.0/doc/_complex_poly.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_complex_poly.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -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_example.xml', -'base_complex.hpp.xml', -'complex_poly.cpp.xml' -]; -var list_down3 = [ -'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_hash.xml', -'base_example.xml' -]; -var list_down2 = [ -'base_alloc.hpp.xml', -'base_require.cpp.xml', -'base_adolc.hpp.xml', -'base_float.hpp.xml', -'base_double.hpp.xml', -'base_complex.hpp.xml' -]; -var list_down1 = [ -'complex_poly.cpp.xml' -]; -var list_current0 = [ -'complex_poly.cpp.xml#Poly' -]; -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-2018.00.00.0/doc/compound_assign.xml cppad-2019.02.00.0/doc/compound_assign.xml --- cppad-2018.00.00.0/doc/compound_assign.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/compound_assign.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,537 +0,0 @@ - - - -AD Compound Assignment Operators - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
AD Compound Assignment Operators
-
-Syntax - -
- -x Op y - - -
-
-Purpose -
-Performs compound assignment operations -where either -x - has type - -AD<Base> -. - -
-
-Op -
-The operator -Op - is one of the following - -
- -Op - Meaning
- -+= - -x - is assigned -x - plus -y -
- --= - -x - is assigned -x - minus -y -
- -*= - -x - is assigned -x - times -y -
- -/= - -x - is assigned -x - divided by -y - -
-
-Base -
-The type -Base - is determined by the operand -x -. - -
-
-x -
-The operand -x - has the following prototype - -
-     AD<
Base> &x
-
-
-y -
-The operand -y - has the following prototype - -
-     const 
Type &y
-
-where -Type - is - -VecAD<Base>::reference -, - -AD<Base> -, - -Base -, or -double. - -
-
-Result -
-The result of this assignment -can be used as a reference to -x -. -For example, if -z - has the following type - -
-     AD<
Basez
-
-then the syntax - -
-     
z = x += y
-
-will compute -x - plus -y - -and then assign this value to both -x - and -z -. - - -
-
-Operation Sequence -
-This is an atomic - -AD of Base - operation -and hence it is part of the current -AD of -Base - -operation sequence -. - - - -
-
-Example -
-The following files contain examples and tests of these functions. -Each test returns true if it succeeds and false otherwise. - - - - - -
- -AddEq.cpp -AD Compound Assignment Addition: Example and Test
- -sub_eq.cpp -AD Compound Assignment Subtraction: Example and Test
- -mul_eq.cpp -AD Compound Assignment Multiplication: Example and Test
- -div_eq.cpp -AD Compound Assignment Division: Example and Test
- -
-
-Derivative -
-If - -f - - - and - -g - - - are -Base functions - - -
-
-Addition - - - - -[ -f -( -x -) -+ -g -( -x -) -] - - -x - - -= - -f -( -x -) - - -x - - -+ - -g -( -x -) - - -x - - - - -
-Subtraction - - - - -[ -f -( -x -) -- -g -( -x -) -] - - -x - - -= - -f -( -x -) - - -x - - -- - -g -( -x -) - - -x - - - - -
-Multiplication - - - - -[ -f -( -x -) -* -g -( -x -) -] - - -x - - -= -g -( -x -) -* - -f -( -x -) - - -x - - -+ -f -( -x -) -* - -g -( -x -) - - -x - - - - -
-Division - - - - -[ -f -( -x -) -/ -g -( -x -) -] - - -x - - -= -[ -1 -/ -g -( -x -) -] -* - -f -( -x -) - - -x - - -- -[ -f -( -x -) -/ -g -( -x -) -2 - -] -* - -g -( -x -) - - -x - - - - - -
Input File: cppad/core/compound_assign.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_compound_assign_xml.js cppad-2019.02.00.0/doc/_compound_assign_xml.js --- cppad-2018.00.00.0/doc/_compound_assign_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_compound_assign_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +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', -'arithmetic.xml', -'compound_assign.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down0 = [ -'addeq.cpp.xml', -'sub_eq.cpp.xml', -'mul_eq.cpp.xml', -'div_eq.cpp.xml' -]; -var list_current0 = [ -'compound_assign.xml#Syntax', -'compound_assign.xml#Purpose', -'compound_assign.xml#Op', -'compound_assign.xml#Base', -'compound_assign.xml#x', -'compound_assign.xml#y', -'compound_assign.xml#Result', -'compound_assign.xml#Operation Sequence', -'compound_assign.xml#Example', -'compound_assign.xml#Derivative', -'compound_assign.xml#Derivative.Addition', -'compound_assign.xml#Derivative.Subtraction', -'compound_assign.xml#Derivative.Multiplication', -'compound_assign.xml#Derivative.Division' -]; -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-2018.00.00.0/doc/cond_exp.cpp.xml cppad-2019.02.00.0/doc/cond_exp.cpp.xml --- cppad-2018.00.00.0/doc/cond_exp.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/cond_exp.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,269 +0,0 @@ - - - -Conditional Expressions: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cond_exp.cpp - -

-
Conditional Expressions: Example and Test
-
-See Also - -
-optimize_conditional_skip.cpp - - - -
-
-Description -
-Use CondExp to compute - - -f -( -x -) -= - -j -= -0 - -m --1 - - -x -j - -log -( -x -j - -) - - -and its derivative at various argument values -( where - -x -j - - -0 - - - ) -with out having to re-tape; i.e., -using only one ADFun - object. -Note that - -x -j - -log -( -x -j - -) - -0 - - - -as - -x -j - - -0 - - - and -we need to handle the case - -x -j - -= -0 - - - -in a special way to avoid multiplying zero by infinity. - - -

-# include <cppad/cppad.hpp>
-# include <limits>
-
-bool CondExp(void)
-{     bool ok = true;
-
-     using CppAD::isnan;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     using CppAD::log;
-     double eps  = 100. * CppAD::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n = 5;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     size_t j;
-     for(j = 0; j < n; j++)
-          ax[j] = 1.;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(ax);
-
-     AD<double> asum  = 0.;
-     AD<double> azero = 0.;
-     for(j = 0; j < n; j++)
-     {     // if x_j > 0, add x_j * log( x_j ) to the sum
-          asum += CppAD::CondExpGt(ax[j], azero, ax[j] * log(ax[j]), azero);
-     }
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = asum;
-
-     // create f: x -> ay and stop tape recording
-     CppAD::ADFun<double> 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) 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);
-          check += x[j] * log( x[j] );
-     }
-
-     // function value
-     y  = f.Forward(0, x);
-     ok &= NearEqual(y[0], check, eps, eps);
-
-     // compute derivative of y[0]
-     w[0] = 1.;
-     dw   = f.Reverse(1, w);
-     for(j = 0; j < n; j++)
-          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
-     y   = f.Forward(0, x);
-     ok &= NearEqual(y[0], check, eps, eps);
-
-     // check derivative of y[0]
-     f.check_for_nan(false);
-     w[0] = 1.;
-     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);
-          else
-          {     // Note that in case where dw has type AD<double> 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;
-}
-
-
Input File: example/general/cond_exp.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_cond_exp.cpp_xml.js cppad-2019.02.00.0/doc/_cond_exp.cpp_xml.js --- cppad-2018.00.00.0/doc/_cond_exp.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cond_exp.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +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', -'condexp.xml', -'cond_exp.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 = [ -'cond_exp.cpp.xml' -]; -var list_current0 = [ -'cond_exp.cpp.xml#See Also', -'cond_exp.cpp.xml#Description' -]; -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-2018.00.00.0/doc/condexp.xml cppad-2019.02.00.0/doc/condexp.xml --- cppad-2018.00.00.0/doc/condexp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/condexp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,376 +0,0 @@ - - - -AD Conditional Expressions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
AD Conditional Expressions
-
-Syntax - -
- -result = CondExpRel(leftrightif_trueif_false) - - - -
-
-Purpose -
-Record, -as part of an AD of -Base - -operation sequence -, -the conditional result - -
-     if( 
left Cop right )
-          
result = if_true
-     else 
result = if_false
-
-The relational -Rel - and comparison operator -Cop - -above have the following correspondence: - -
-     
Rel   Lt   Le   Eq   Ge   Gt
-     
Cop    <   <=   ==   >=   >
-
-If -f - is the ADFun - object corresponding to the -AD operation sequence, -the assignment choice for -result - -in an AD conditional expression is made each time -f.Forward - is used to evaluate the zero order Taylor -coefficients with new values for the -independent variables -. -This is in contrast to the AD comparison operators - -which are boolean valued and not included in the AD operation sequence. - -
-
-Rel -
-In the syntax above, the relation -Rel - represents one of the following -two characters: Lt, Le, Eq, Ge, Gt. -As in the table above, - -Rel - determines which comparison operator -Cop - is used -when comparing -left - and -right -. - -
-
-Type -
-These functions are defined in the CppAD namespace for arguments of - -Type - is float , double, or any type of the form - -AD<Base> -. -(Note that all four arguments must have the same type.) - -
-
-left -
-The argument -left - has prototype - -
-     const 
Typeleft
-
-It specifies the value for the left side of the comparison operator. - -
-
-right -
-The argument -right - has prototype - -
-     const 
Typeright
-
-It specifies the value for the right side of the comparison operator. - -
-
-if_true -
-The argument -if_true - has prototype - -
-     const 
Typeif_true
-
-It specifies the return value if the result of the comparison is true. - -
-
-if_false -
-The argument -if_false - has prototype - -
-     const 
Typeif_false
-
-It specifies the return value if the result of the comparison is false. - -
-
-result -
-The -result - has prototype - -
-     
Typeif_false
-
-
-Optimize -
-The optimize - method will optimize conditional expressions -in the following way: -During zero order forward mode -, -once the value of the -left - and -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. -This optimization is done for the rest of zero order forward mode -as well as forward and reverse derivatives calculations. - -
-
-Deprecate 2005-08-07 -
-Previous versions of CppAD used - -
-     CondExp(
flagif_trueif_false)
-
-for the same meaning as - -
-     CondExpGt(
flagType(0), if_trueif_false)
-
-Use of CondExp is deprecated, but continues to be supported. - -
-
-Operation Sequence -
-This is an AD of -Base - -atomic operation - -and hence is part of the current -AD of -Base - -operation sequence -. - - -
-
-Example - - -
-
-Test - -
-The file -cond_exp.cpp - -contains an example and test of this function. -It returns true if it succeeds and false otherwise. - -
-
-Atan2 -
-The following implementation of the -AD atan2 - function is a more complex -example of using conditional expressions: - -
template <class Base>
-AD<Base> atan2 (const AD<Base> &y, const AD<Base> &x)
-{     AD<Base> alpha;
-     AD<Base> beta;
-     AD<Base> theta;
-
-     AD<Base> zero(0.);
-     AD<Base> pi2(2. * atan(1.));
-     AD<Base> pi(2. * pi2);
-
-     AD<Base> ax = fabs(x);
-     AD<Base> ay = fabs(y);
-
-     // if( ax > ay )
-     //     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 = CondExpLe(x, zero, pi - theta, theta);  // use of CondExp
-
-     // if( y <= 0 )
-     //     theta = - theta;
-     theta = CondExpLe(y, zero, -theta, theta);      // use of CondExp
-
-     return theta;
-}
-
-
Input File: cppad/core/cond_exp.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_condexp_xml.js cppad-2019.02.00.0/doc/_condexp_xml.js --- cppad-2018.00.00.0/doc/_condexp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_condexp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +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', -'condexp.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 = [ -'cond_exp.cpp.xml' -]; -var list_current0 = [ -'condexp.xml#Syntax', -'condexp.xml#Purpose', -'condexp.xml#Rel', -'condexp.xml#Type', -'condexp.xml#left', -'condexp.xml#right', -'condexp.xml#if_true', -'condexp.xml#if_false', -'condexp.xml#result', -'condexp.xml#Optimize', -'condexp.xml#Deprecate 2005-08-07', -'condexp.xml#Operation Sequence', -'condexp.xml#Example', -'condexp.xml#Test', -'condexp.xml#Atan2' -]; -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-2018.00.00.0/doc/conj_grad.cpp.xml cppad-2019.02.00.0/doc/conj_grad.cpp.xml --- cppad-2018.00.00.0/doc/conj_grad.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/conj_grad.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,731 +0,0 @@ - - - -Differentiate Conjugate Gradient Algorithm: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -conj_grad.cpp - -

-
Differentiate Conjugate Gradient Algorithm: Example and Test
-
-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 -for the conjugate gradient algorithm. - -
-
-Algorithm -
-Given a positive definite matrix - -A - -R - -n -× -n - - - - -, -a vector - -b - -R - -n - - - -, -and tolerance - -ε - - -, -the conjugate gradient algorithm finds an - -x - -R - -n - - - - -such that - - -A -x -- -b - -2 - -/ -n - -ε -2 - - - - -(or it terminates at a specified maximum number of iterations). - -
  1. -Input: -
    -
    The matrix - -A - -R - -n -× -n - - - - -, -the vector - -b - -R - -n - - - -, -a tolerance - -ε - -0 - - -, -a maximum number of iterations - -m - - -, -and the initial approximate solution - -x -0 - - -R - -n - - - - -(can use zero for - -x -0 - - - -). - -
  2. - -Initialize: -
    -
    - -g -0 - -= -A -* -x -0 - -- -b - - -, - - -d -0 - -= -- -g -0 - - - -, - - -s -0 - -= -( -g -0 - -) -T - - -g -0 - - - -, - - -k -= -0 - - -. - -
  3. - -Convergence Check: -
    -
    if - -k -= -m - - - or - -s -k - -/ -n - - -< -ε - - -, -return - -k - - - as the number of iterations and - -x -k - - - - -as the approximate solution. - -
  4. - -Next - -x - - -: -
    -
    - -μ -k -+ -1 - - -= -s -k - -/ -[ -( -d -k - -) -T - - -A -d -k - -] - - -, - - -x -k -+ -1 - - -= -x -k - -+ -μ -k -+ -1 - - -d -k - - - -. - -
  5. - -Next - -g - - -: -
    -
    - -g -k -+ -1 - - -= -g -k - -+ -μ -k -+ -1 - - -A -d -k - - - -, - - -s -k -+ -1 - - -= -( -g -k -+ -1 - - -) -T - - -g -k -+ -1 - - - - -. - -
  6. - -Next - -d - - -: -
    -
    - -d -k -+ -1 - - -= -- -g -k - -+ -( -s -k -+ -1 - - -/ -s -k - -) -d -k - - - -. - -
  7. - -Iterate: -
    -
    - -k -= -k -+ -1 - - -, -goto Convergence Check. -
- - - -
# include <cppad/cppad.hpp>
-# include <cstdlib>
-# include <cmath>
-
-namespace { // Begin empty namespace
-     using CppAD::AD;
-
-     // 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 <class Vector> // a simple vector class
-     void mat_mul(size_t n, const Vector& a, const Vector& b, Vector& c)
-     {     typedef typename Vector::value_type scalar;
-
-          size_t m, p;
-          m = a.size() / n;
-          p = b.size() / n;
-
-          assert( m * n == a.size() );
-          assert( n * p == b.size() );
-          assert( m * p == c.size() );
-
-          size_t i, j, k, ij;
-          for(i = 0; i < m; i++)
-          {     for(j = 0; j < p; j++)
-               {     ij    = i * p + j;
-                    c[ij] = scalar(0);
-                    for(k = 0; k < n; k++)
-                         c[ij] = c[ij] + a[i * m + k] * b[k * p + j];
-               }
-          }
-          return;
-     }
-
-     // Solve A * x == b to tolerance epsilon or terminate at m interations.
-     template <class Vector> // a simple vector class
-     size_t conjugate_gradient(
-          size_t         m       , // input
-          double         epsilon , // input
-          const Vector&  A       , // input
-          const Vector&  b       , // input
-          Vector&        x       ) // input / output
-     {     typedef typename Vector::value_type scalar;
-          scalar mu, s_previous;
-          size_t i, k;
-
-          size_t n = x.size();
-          assert( A.size() == n * n );
-          assert( b.size() == n );
-
-          Vector g(n), d(n), s(1), Ad(n), dAd(1);
-
-          // g = A * x
-          mat_mul(n, A, x, g);
-          for(i = 0; i < n; i++)
-          {     // g = A * x - b
-               g[i] = g[i] - b[i];
-
-               // d = - g
-               d[i] = -g[i];
-          }
-          // s = g^T * g
-          mat_mul(n, g, g, s);
-
-          for(k = 0; k < m; k++)
-          {     s_previous = s[0];
-               if( s_previous < epsilon )
-                    return k;
-
-               // Ad = A * d
-               mat_mul(n, A, d, Ad);
-
-               // dAd = d^T * A * d
-               mat_mul(n, d, Ad, dAd);
-
-               // mu = s / d^T * A * d
-               mu = s_previous / dAd[0];
-
-               // 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];
-               }
-
-               // s = g^T * g
-               mat_mul(n, g, g, s);
-
-               // d = - g + (s / s_previous) * d
-               for(i = 0; i < n; i++)
-                    d[i] = - g[i] + ( s[0] / s_previous) * d[i];
-          }
-          return m;
-     }
-
-} // End empty namespace
-
-bool conj_grad(void)
-{     bool ok = true;
-
-     // ----------------------------------------------------------------------
-     // Setup
-     // ----------------------------------------------------------------------
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     using CppAD::vector;
-     using std::cout;
-     using std::endl;
-     size_t i, j;
-
-
-     // size of the vectors
-     size_t n  = 40;
-     vector<double> D(n * n), Dt(n * n), A(n * n), x(n), b(n), c(n);
-     vector< AD<double> > a_A(n * n), a_x(n), a_b(n);
-
-     // D = diagonally dominant matrix
-     // c = vector of ones
-     for(i = 0; i < n; i++)
-     {     c[i] = 1.;
-          double sum = 0;
-          for(j = 0; j < n; j++) if( i != j )
-          {     D[ i * n + j ] = std::rand() / double(RAND_MAX);
-               Dt[j * n + i ] = D[i * n + j ];
-               sum           += D[i * n + j ];
-          }
-          Dt[ i * n + i ] = D[ i * n + i ] = sum * 1.1;
-     }
-
-     // A = D^T * D
-     mat_mul(n, Dt, D, A);
-
-     // b = D^T * c
-     mat_mul(n, Dt, c, b);
-
-     // copy from double to AD<double>
-     for(i = 0; i < n; i++)
-     {     a_b[i] = b[i];
-          for(j = 0; j < n; j++)
-               a_A[ i * n + j ] = A[ i * n + j ];
-     }
-
-     // ---------------------------------------------------------------------
-     // Record the function f : b -> x
-     // ---------------------------------------------------------------------
-     // Make b the independent variable vector
-     Independent(a_b);
-
-     // Solve A * x = b using conjugate gradient method
-     double epsilon = 1e-7;
-     for(i = 0; i < n; i++)
-               a_x[i] = AD<double>(0);
-     size_t m = n + 1;
-     size_t k = conjugate_gradient(m, epsilon, a_A, a_b, a_x);
-
-     // create f_cg: b -> x and stop tape recording
-     CppAD::ADFun<double> f(a_b, a_x);
-
-     // ---------------------------------------------------------------------
-     // Check for correctness
-     // ---------------------------------------------------------------------
-
-     // conjugate gradient should converge with in n iterations
-     ok &= (k <= n);
-
-     // accuracy to which we expect values to agree
-     double delta = 10. * epsilon * std::sqrt( double(n) );
-
-     // copy x from AD<double> to double
-     for(i = 0; i < n; i++)
-          x[i] = Value( a_x[i] );
-
-     // check c = A * x
-     mat_mul(n, A, x, c);
-     for(i = 0; i < n; i++)
-          ok &= NearEqual(c[i] , b[i],  delta , delta);
-
-     // forward computation of partials w.r.t. b[0]
-     vector<double> db(n), dx(n);
-     for(j = 0; j < n; j++)
-          db[j] = 0.;
-     db[0] = 1.;
-
-     // check db = A * dx
-     delta = 5. * delta;
-     dx = f.Forward(1, db);
-     mat_mul(n, A, dx, c);
-     for(i = 0; i < n; i++)
-          ok   &= NearEqual(c[i], db[i], delta, delta);
-
-     return ok;
-}
-
-
-
Input File: example/sparse/conj_grad.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_conj_grad.cpp_xml.js cppad-2019.02.00.0/doc/_conj_grad.cpp_xml.js --- cppad-2018.00.00.0/doc/_conj_grad.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_conj_grad.cpp_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', -'example.xml', -'general.xml', -'conj_grad.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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_current0 = [ -'conj_grad.cpp.xml#Purpose', -'conj_grad.cpp.xml#Algorithm' -]; -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-2018.00.00.0/doc/_contents.js cppad-2019.02.00.0/doc/_contents.js --- cppad-2018.00.00.0/doc/_contents.js 2018-01-01 08:32:40.000000000 +0000 +++ cppad-2019.02.00.0/doc/_contents.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -var Cookie = document.cookie; -var Open = ''; -var SectionCount = 695 ; -var ImagesInitialized = false; -Children = new Array(); -Initialize(); - -function Initialize() -{ var i; - - if( Cookie.length == 10 + SectionCount ) - Open = Cookie.substring(9, 10 + SectionCount); - else - { Open = '_T'; - for(i = 2; i <= SectionCount; i++) - Open = Open + 'F'; - } - for (i = 1; i <= SectionCount; i++) - { - var child = document.getElementById('children'+i); - Children[i] = child; - if( child != null ) - { if( Open.charAt(i) == 'T' ) - child.style.display = ''; // visible - else child.style.display = 'none'; // invisible - } - } -} -function InitializeImages() -{ // would like to do this during initialization - // but image variable seems to come out null then - - for (i = 1; i <= SectionCount; i++) - { - if( Children[i] != null ) - { var image = document.images['folder'+i]; - if( Open.charAt(i) == 'T' ) - image.src = '_open.gif'; - else image.src = '_close.gif'; - } - } - ImagesInitialized = true; -} - -// select a folder -function Select(index) -{ - if( ! ImagesInitialized ) - InitializeImages(); - - // cannot be null becasue is visible - var child = Children[index]; - var image = document.images['folder'+index]; - - if( child.style.display == 'none' ) - { image.src = '_openblue.gif'; - child.style.display = ''; - Open = Open.substring(0, index) - + 'T' + Open.substring(index, SectionCount); - } - else - { image.src = '_closeblue.gif'; - child.style.display = 'none'; - Open = Open.substring(0, index) - + 'F' + Open.substring(index, SectionCount); - } - document.cookie = 'contents=' + Open; -} - -// high light a folder -function MouseOver(index) -{ - if( ! ImagesInitialized ) - InitializeImages(); - - // cannot be null becasue is visible - var child = Children[index]; - var image = document.images['folder'+index]; - - if( child.style.display == '' ) - image.src = '_openblue.gif'; - else image.src = '_closeblue.gif'; -} - -// remove high lighting -function MouseOut(index) -{ - if( ! ImagesInitialized ) - InitializeImages(); - - // cannot be null becasue is visible - var child = Children[index]; - var image = document.images['folder'+index]; - - if( child.style.display == '' ) - image.src = '_open.gif'; - else image.src = '_close.gif'; -} diff -Nru cppad-2018.00.00.0/doc/_contents_xml.htm cppad-2019.02.00.0/doc/_contents_xml.htm --- cppad-2018.00.00.0/doc/_contents_xml.htm 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_contents_xml.htm 1970-01-01 00:00:00.000000000 +0000 @@ -1,3287 +0,0 @@ - - -Table of Contents - - - - - - - - - - - - - -
- -Prev -Next - - - - - - -_contentsHeadings

-
-Table of Contents -
- -
-cppad-20180000.0: A Package for Differentiation of C++ Algorithms - - -
cppad-20180000.0: A Package for Differentiation of C++ Algorithms - -
    Table of Contents - -
     -CppAD Download, Test, and Install Instructions - - -
    CppAD Download, Test, and Install Instructions - -
        Download The CppAD Source Code - -
         -Using CMake to Configure CppAD - - -
        Using CMake to Configure CppAD - -
             -Including the ADOL-C Examples and Tests - - -
            Including the ADOL-C Examples and Tests - -
                Download and Install Adolc in Build Directory -
- -
             -Including the ColPack Sparsity Calculations - - -
            Including the ColPack Sparsity Calculations - -
                ColPack: Sparse Jacobian Example and Test - -
                ColPack: Sparse Jacobian Example and Test - -
                ColPack: Sparse Hessian Example and Test - -
                ColPack: Sparse Hessian Example and Test - -
                Download and Install ColPack in Build Directory -
- -
             -Including the Eigen Examples and Tests - - -
            Including the Eigen Examples and Tests - -
                Download and Install Eigen in Build Directory -
- -
             -Including the FADBAD Speed Tests - - -
            Including the FADBAD Speed Tests - -
                Download and Install Fadbad in Build Directory -
- -
             -Including the cppad_ipopt Library and Tests - - -
            Including the cppad_ipopt Library and Tests - -
                Download and Install Ipopt in Build Directory -
- -
             -Including the Sacado Speed Tests - - -
            Including the Sacado Speed Tests - -
                Download and Install Sacado in Build Directory -
- -
            Choosing the CppAD Test Vector Template Class -
- -
        Checking the CppAD Examples and Tests - -
        CppAD pkg-config Files -
- -
     -An Introduction by Example to Algorithmic Differentiation - - -
    An Introduction by Example to Algorithmic Differentiation - -
         -Second Order Exponential Approximation - - -
        Second Order Exponential Approximation - -
            exp_2: Implementation - -
            exp_2: Test - -
             -exp_2: Operation Sequence and Zero Order Forward Mode - - -
            exp_2: Operation Sequence and Zero Order Forward Mode - -
                exp_2: Verify Zero Order Forward Sweep -
- -
             -exp_2: First Order Forward Mode - - -
            exp_2: First Order Forward Mode - -
                exp_2: Verify First Order Forward Sweep -
- -
             -exp_2: First Order Reverse Mode - - -
            exp_2: First Order Reverse Mode - -
                exp_2: Verify First Order Reverse Sweep -
- -
             -exp_2: Second Order Forward Mode - - -
            exp_2: Second Order Forward Mode - -
                exp_2: Verify Second Order Forward Sweep -
- -
             -exp_2: Second Order Reverse Mode - - -
            exp_2: Second Order Reverse Mode - -
                exp_2: Verify Second Order Reverse Sweep -
- -
            exp_2: CppAD Forward and Reverse Sweeps -
- -
         -An Epsilon Accurate Exponential Approximation - - -
        An Epsilon Accurate Exponential Approximation - -
            exp_eps: Implementation - -
            exp_eps: Test of exp_eps - -
             -exp_eps: Operation Sequence and Zero Order Forward Sweep - - -
            exp_eps: Operation Sequence and Zero Order Forward Sweep - -
                exp_eps: Verify Zero Order Forward Sweep -
- -
             -exp_eps: First Order Forward Sweep - - -
            exp_eps: First Order Forward Sweep - -
                exp_eps: Verify First Order Forward Sweep -
- -
             -exp_eps: First Order Reverse Sweep - - -
            exp_eps: First Order Reverse Sweep - -
                exp_eps: Verify First Order Reverse Sweep -
- -
             -exp_eps: Second Order Forward Mode - - -
            exp_eps: Second Order Forward Mode - -
                exp_eps: Verify Second Order Forward Sweep -
- -
             -exp_eps: Second Order Reverse Sweep - - -
            exp_eps: Second Order Reverse Sweep - -
                exp_eps: Verify Second Order Reverse Sweep -
- -
            exp_eps: CppAD Forward and Reverse Sweeps -
- -
        Correctness Tests For Exponential Approximation in Introduction -
- -
     -AD Objects - - -
    AD Objects - -
         -AD Constructors - - -
        AD Constructors - -
            AD Constructors: Example and Test -
- -
         -AD Assignment Operator - - -
        AD Assignment Operator - -
            AD Assignment: Example and Test -
- -
         -Conversion and I/O of AD Objects - - -
        Conversion and I/O of AD Objects - -
             -Convert From an AD Type to its Base Type - - -
            Convert From an AD Type to its Base Type - -
                Convert From AD to its Base Type: Example and Test -
- -
             -Convert From AD to Integer - - -
            Convert From AD to Integer - -
                Convert From AD to Integer: Example and Test -
- -
            Convert An AD or Base Type to String - -
             -AD Output Stream Operator - - -
            AD Output Stream Operator - -
                AD Output Operator: Example and Test -
- -
             -AD Output Stream Operator - - -
            AD Output Stream Operator - -
                AD Output Operator: Example and Test -
- -
             -Printing AD Values During Forward Mode - - -
            Printing AD Values During Forward Mode - -
                Printing During Forward Mode: Example and Test - -
                Print During Zero Order Forward Mode: Example and Test -
- -
             -Convert an AD Variable to a Parameter - - -
            Convert an AD Variable to a Parameter - -
                Convert an AD Variable to a Parameter: Example and Test -
-
- -
         -AD Valued Operations and Functions - - -
        AD Valued Operations and Functions - -
             -AD Arithmetic Operators and Compound Assignments - - -
            AD Arithmetic Operators and Compound Assignments - -
                 -AD Unary Plus Operator - - -
                AD Unary Plus Operator - -
                    AD Unary Plus Operator: Example and Test -
- -
                 -AD Unary Minus Operator - - -
                AD Unary Minus Operator - -
                    AD Unary Minus Operator: Example and Test -
- -
                 -AD Binary Arithmetic Operators - - -
                AD Binary Arithmetic Operators - -
                    AD Binary Addition: Example and Test - -
                    AD Binary Subtraction: Example and Test - -
                    AD Binary Multiplication: Example and Test - -
                    AD Binary Division: Example and Test -
- -
                 -AD Compound Assignment Operators - - -
                AD Compound Assignment Operators - -
                    AD Compound Assignment Addition: Example and Test - -
                    AD Compound Assignment Subtraction: Example and Test - -
                    AD Compound Assignment Multiplication: Example and Test - -
                    AD Compound Assignment Division: Example and Test -
-
- -
             -The Unary Standard Math Functions - - -
            The Unary Standard Math Functions - -
                 -Inverse Sine Function: acos - - -
                Inverse Sine Function: acos - -
                    The AD acos Function: Example and Test -
- -
                 -Inverse Sine Function: asin - - -
                Inverse Sine Function: asin - -
                    The AD asin Function: Example and Test -
- -
                 -Inverse Tangent Function: atan - - -
                Inverse Tangent Function: atan - -
                    The AD atan Function: Example and Test -
- -
                 -The Cosine Function: cos - - -
                The Cosine Function: cos - -
                    The AD cos Function: Example and Test -
- -
                 -The Hyperbolic Cosine Function: cosh - - -
                The Hyperbolic Cosine Function: cosh - -
                    The AD cosh Function: Example and Test -
- -
                 -The Exponential Function: exp - - -
                The Exponential Function: exp - -
                    The AD exp Function: Example and Test -
- -
                 -The Exponential Function: log - - -
                The Exponential Function: log - -
                    The AD log Function: Example and Test -
- -
                 -The Base 10 Logarithm Function: log10 - - -
                The Base 10 Logarithm Function: log10 - -
                    The AD log10 Function: Example and Test -
- -
                 -The Sine Function: sin - - -
                The Sine Function: sin - -
                    The AD sin Function: Example and Test -
- -
                 -The Hyperbolic Sine Function: sinh - - -
                The Hyperbolic Sine Function: sinh - -
                    The AD sinh Function: Example and Test -
- -
                 -The Square Root Function: sqrt - - -
                The Square Root Function: sqrt - -
                    The AD sqrt Function: Example and Test -
- -
                 -The Tangent Function: tan - - -
                The Tangent Function: tan - -
                    The AD tan Function: Example and Test -
- -
                 -The Hyperbolic Tangent Function: tanh - - -
                The Hyperbolic Tangent Function: tanh - -
                    The AD tanh Function: Example and Test -
- -
                 -AD Absolute Value Functions: abs, fabs - - -
                AD Absolute Value Functions: abs, fabs - -
                    AD Absolute Value Function: Example and Test -
- -
                 -The Inverse Hyperbolic Cosine Function: acosh - - -
                The Inverse Hyperbolic Cosine Function: acosh - -
                    The AD acosh Function: Example and Test -
- -
                 -The Inverse Hyperbolic Sine Function: asinh - - -
                The Inverse Hyperbolic Sine Function: asinh - -
                    The AD asinh Function: Example and Test -
- -
                 -The Inverse Hyperbolic Tangent Function: atanh - - -
                The Inverse Hyperbolic Tangent Function: atanh - -
                    The AD atanh Function: Example and Test -
- -
                 -The Error Function - - -
                The Error Function - -
                    The AD erf Function: Example and Test -
- -
                 -The Exponential Function Minus One: expm1 - - -
                The Exponential Function Minus One: expm1 - -
                    The AD exp Function: Example and Test -
- -
                 -The Logarithm of One Plus Argument: log1p - - -
                The Logarithm of One Plus Argument: log1p - -
                    The AD log1p Function: Example and Test -
- -
                 -The Sign: sign - - -
                The Sign: sign - -
                    Sign Function: Example and Test -
-
- -
             -The Binary Math Functions - - -
            The Binary Math Functions - -
                 -AD Two Argument Inverse Tangent Function - - -
                AD Two Argument Inverse Tangent Function - -
                    The AD atan2 Function: Example and Test -
- -
                 -The AD Power Function - - -
                The AD Power Function - -
                    The AD Power Function: Example and Test -
- -
                 -Absolute Zero Multiplication - - -
                Absolute Zero Multiplication - -
                    AD Absolute Zero Multiplication: Example and Test -
-
- -
             -AD Conditional Expressions - - -
            AD Conditional Expressions - -
                Conditional Expressions: Example and Test -
- -
             -Discrete AD Functions - - -
            Discrete AD Functions - -
                Taping Array Index Operation: Example and Test - -
                Interpolation With Out Retaping: Example and Test - -
                Interpolation With Retaping: Example and Test -
- -
             -Numeric Limits For an AD and Base Types - - -
            Numeric Limits For an AD and Base Types - -
                Numeric Limits: Example and Test -
- -
             -Atomic AD Functions - - -
            Atomic AD Functions - -
                 -Checkpointing Functions - - -
                Checkpointing Functions - -
                    Simple Checkpointing: Example and Test - -
                    Atomic Operations and Multiple-Levels of AD: Example and Test - -
                    Checkpointing an ODE Solver: Example and Test - -
                    Checkpointing an Extended ODE Solver: Example and Test -
- -
                 -User Defined Atomic AD Functions - - -
                User Defined Atomic AD Functions - -
                    Atomic Function Constructor - -
                    Set Atomic Function Options - -
                    Using AD Version of Atomic Function - -
                     -Atomic Forward Mode - - -
                    Atomic Forward Mode - -
                        Atomic Forward: Example and Test -
- -
                     -Atomic Reverse Mode - - -
                    Atomic Reverse Mode - -
                        Atomic Reverse: Example and Test -
- -
                     -Atomic Forward Jacobian Sparsity Patterns - - -
                    Atomic Forward Jacobian Sparsity Patterns - -
                        Atomic Forward Jacobian Sparsity: Example and Test -
- -
                     -Atomic Reverse Jacobian Sparsity Patterns - - -
                    Atomic Reverse Jacobian Sparsity Patterns - -
                        Atomic Reverse Jacobian Sparsity: Example and Test -
- -
                     -Atomic Forward Hessian Sparsity Patterns - - -
                    Atomic Forward Hessian Sparsity Patterns - -
                        Atomic Forward Hessian Sparsity: Example and Test -
- -
                     -Atomic Reverse Hessian Sparsity Patterns - - -
                    Atomic Reverse Hessian Sparsity Patterns - -
                        Atomic Reverse Hessian Sparsity: Example and Test -
- -
                    Free Static Variables - -
                    Getting Started with Atomic Operations: Example and Test - -
                    Atomic Euclidean Norm Squared: Example and Test - -
                    Reciprocal as an Atomic Operation: Example and Test - -
                    Atomic Sparsity with Set Patterns: Example and Test - -
                    Tan and Tanh as User Atomic Operations: Example and Test - -
                     -Atomic Eigen Matrix Multiply: Example and Test - - -
                    Atomic Eigen Matrix Multiply: Example and Test - -
                        Atomic Eigen Matrix Multiply Class -
- -
                     -Atomic Eigen Matrix Inverse: Example and Test - - -
                    Atomic Eigen Matrix Inverse: Example and Test - -
                        Atomic Eigen Matrix Inversion Class -
- -
                     -Atomic Eigen Cholesky Factorization: Example and Test - - -
                    Atomic Eigen Cholesky Factorization: Example and Test - -
                        AD Theory for Cholesky Factorization - -
                        Atomic Eigen Cholesky Factorization Class -
- -
                     -User Atomic Matrix Multiply: Example and Test - - -
                    User Atomic Matrix Multiply: Example and Test - -
                        Matrix Multiply as an Atomic Operation -
-
-
-
- -
         -Bool Valued Operations and Functions with AD Arguments - - -
        Bool Valued Operations and Functions with AD Arguments - -
             -AD Binary Comparison Operators - - -
            AD Binary Comparison Operators - -
                AD Binary Comparison Operators: Example and Test -
- -
             -Compare AD and Base Objects for Nearly Equal - - -
            Compare AD and Base Objects for Nearly Equal - -
                Compare AD with Base Objects: Example and Test -
- -
             -AD Boolean Functions - - -
            AD Boolean Functions - -
                AD Boolean Functions: Example and Test -
- -
             -Is an AD Object a Parameter or Variable - - -
            Is an AD Object a Parameter or Variable - -
                AD Parameter and Variable Functions: Example and Test -
- -
             -Check if Two Value are Identically Equal - - -
            Check if Two Value are Identically Equal - -
                EqualOpSeq: Example and Test -
-
- -
         -AD Vectors that Record Index Operations - - -
        AD Vectors that Record Index Operations - -
            AD Vectors that Record Index Operations: Example and Test -
- -
         -AD<Base> Requirements for a CppAD Base Type - - -
        AD<Base> Requirements for a CppAD Base Type - -
            Required Base Class Member Functions - -
            Base Type Requirements for Conditional Expressions - -
            Base Type Requirements for Identically Equal Comparisons - -
            Base Type Requirements for Ordered Comparisons - -
            Base Type Requirements for Standard Math Functions - -
            Base Type Requirements for Numeric Limits - -
            Extending to_string To Another Floating Point Type - -
            Base Type Requirements for Hash Coding Values - -
             -Example AD Base Types That are not AD<OtherBase> - - -
            Example AD Base Types That are not AD<OtherBase> - -
                Example AD<Base> Where Base Constructor Allocates Memory - -
                Using a User Defined AD Base Type: Example and Test - -
                 -Enable use of AD<Base> where Base is Adolc's adouble Type - - -
                Enable use of AD<Base> where Base is Adolc's adouble Type - -
                    Using Adolc with Multiple Levels of Taping: Example and Test -
- -
                Enable use of AD<Base> where Base is float - -
                Enable use of AD<Base> where Base is double - -
                 -Enable use of AD<Base> where Base is std::complex<double> - - -
                Enable use of AD<Base> where Base is std::complex<double> - -
                    Complex Polynomial: Example and Test -
-
-
-
- -
     -ADFun Objects - - -
    ADFun Objects - -
         -Create an ADFun Object (Record an Operation Sequence) - - -
        Create an ADFun Object (Record an Operation Sequence) - -
             -Declare Independent Variables and Start Recording - - -
            Declare Independent Variables and Start Recording - -
                Independent and ADFun Constructor: Example and Test -
- -
             -Construct an ADFun Object and Stop Recording - - -
            Construct an ADFun Object and Stop Recording - -
                ADFun Assignment: Example and Test -
- -
            Stop Recording and Store Operation Sequence - -
             -Abort Recording of an Operation Sequence - - -
            Abort Recording of an Operation Sequence - -
                Abort Current Recording: Example and Test -
- -
             -ADFun Sequence Properties - - -
            ADFun Sequence Properties - -
                ADFun Sequence Properties: Example and Test -
-
- -
         -First and Second Order Derivatives: Easy Drivers - - -
        First and Second Order Derivatives: Easy Drivers - -
             -Jacobian: Driver Routine - - -
            Jacobian: Driver Routine - -
                Jacobian: Example and Test -
- -
             -Hessian: Easy Driver - - -
            Hessian: Easy Driver - -
                Hessian: Example and Test - -
                Hessian of Lagrangian and ADFun Default Constructor: Example and Test -
- -
             -First Order Partial Derivative: Driver Routine - - -
            First Order Partial Derivative: Driver Routine - -
                First Order Partial Driver: Example and Test -
- -
             -First Order Derivative: Driver Routine - - -
            First Order Derivative: Driver Routine - -
                First Order Derivative Driver: Example and Test -
- -
             -Forward Mode Second Partial Derivative Driver - - -
            Forward Mode Second Partial Derivative Driver - -
                Subset of Second Order Partials: Example and Test -
- -
             -Reverse Mode Second Partial Derivative Driver - - -
            Reverse Mode Second Partial Derivative Driver - -
                Second Partials Reverse Driver: Example and Test -
-
- -
         -Forward Mode - - -
        Forward Mode - -
            Zero Order Forward Mode: Function Values - -
            First Order Forward Mode: Derivative Values - -
            Second Order Forward Mode: Derivative Values - -
             -Multiple Order Forward Mode - - -
            Multiple Order Forward Mode - -
                Forward Mode: Example and Test - -
                Forward Mode: Example and Test of Multiple Orders -
- -
             -Multiple Directions Forward Mode - - -
            Multiple Directions Forward Mode - -
                Forward Mode: Example and Test of Multiple Directions -
- -
            Number Taylor Coefficient Orders Currently Stored - -
             -Comparison Changes Between Taping and Zero Order Forward - - -
            Comparison Changes Between Taping and Zero Order Forward - -
                CompareChange and Re-Tape: Example and Test -
- -
             -Controlling Taylor Coefficients Memory Allocation - - -
            Controlling Taylor Coefficients Memory Allocation - -
                Controlling Taylor Coefficient Memory Allocation: Example and Test -
- -
             -Number of Variables that Can be Skipped - - -
            Number of Variables that Can be Skipped - -
                Number of Variables That Can be Skipped: Example and Test -
-
- -
         -Reverse Mode - - -
        Reverse Mode - -
             -First Order Reverse Mode - - -
            First Order Reverse Mode - -
                First Order Reverse Mode: Example and Test -
- -
             -Second Order Reverse Mode - - -
            Second Order Reverse Mode - -
                Second Order Reverse ModeExample and Test - -
                Hessian Times Direction: Example and Test -
- -
             -Any Order Reverse Mode - - -
            Any Order Reverse Mode - -
                Third Order Reverse Mode: Example and Test - -
                Reverse Mode General Case (Checkpointing): Example and Test -
- -
             -Reverse Mode Using Subgraphs - - -
            Reverse Mode Using Subgraphs - -
                Computing Reverse Mode on Subgraphs: Example and Test -
-
- -
         -Calculating Sparsity Patterns - - -
        Calculating Sparsity Patterns - -
             -Forward Mode Jacobian Sparsity Patterns - - -
            Forward Mode Jacobian Sparsity Patterns - -
                Forward Mode Jacobian Sparsity: Example and Test -
- -
             -Jacobian Sparsity Pattern: Forward Mode - - -
            Jacobian Sparsity Pattern: Forward Mode - -
                Forward Mode Jacobian Sparsity: Example and Test -
- -
             -Reverse Mode Jacobian Sparsity Patterns - - -
            Reverse Mode Jacobian Sparsity Patterns - -
                Reverse Mode Jacobian Sparsity: Example and Test -
- -
             -Jacobian Sparsity Pattern: Reverse Mode - - -
            Jacobian Sparsity Pattern: Reverse Mode - -
                Reverse Mode Jacobian Sparsity: Example and Test -
- -
             -Reverse Mode Hessian Sparsity Patterns - - -
            Reverse Mode Hessian Sparsity Patterns - -
                Reverse Mode Hessian Sparsity: Example and Test -
- -
             -Hessian Sparsity Pattern: Reverse Mode - - -
            Hessian Sparsity Pattern: Reverse Mode - -
                Reverse Mode Hessian Sparsity: Example and Test - -
                Sparsity Patterns For a Subset of Variables: Example and Test -
- -
             -Forward Mode Hessian Sparsity Patterns - - -
            Forward Mode Hessian Sparsity Patterns - -
                Forward Mode Hessian Sparsity: Example and Test -
- -
             -Hessian Sparsity Pattern: Forward Mode - - -
            Hessian Sparsity Pattern: Forward Mode - -
                Forward Mode Hessian Sparsity: Example and Test -
- -
            Computing Dependency: Example and Test - -
            Preferred Sparsity Patterns: Row and Column Indices: Example and Test - -
             -Subgraph Dependency Sparsity Patterns - - -
            Subgraph Dependency Sparsity Patterns - -
                Subgraph Dependency Sparsity Patterns: Example and Test -
-
- -
         -Calculating Sparse Derivatives - - -
        Calculating Sparse Derivatives - -
             -Computing Sparse Jacobians - - -
            Computing Sparse Jacobians - -
                Computing Sparse Jacobian Using Forward Mode: Example and Test - -
                Computing Sparse Jacobian Using Reverse Mode: Example and Test -
- -
             -Sparse Jacobian - - -
            Sparse Jacobian - -
                Sparse Jacobian: Example and Test -
- -
             -Computing Sparse Hessians - - -
            Computing Sparse Hessians - -
                Computing Sparse Hessian: Example and Test -
- -
             -Sparse Hessian - - -
            Sparse Hessian - -
                Sparse Hessian: Example and Test - -
                Computing Sparse Hessian for a Subset of Variables - -
                Subset of a Sparse Hessian: Example and Test -
- -
             -Compute Sparse Jacobians Using Subgraphs - - -
            Compute Sparse Jacobians Using Subgraphs - -
                Computing Sparse Jacobian Using Reverse Mode: Example and Test - -
                Sparse Hessian Using Subgraphs and Jacobian: Example and Test -
-
- -
         -Optimize an ADFun Object Tape - - -
        Optimize an ADFun Object Tape - -
            Example Optimization and Forward Activity Analysis - -
            Example Optimization and Reverse Activity Analysis - -
            Example Optimization and Comparison Operators - -
            Example Optimization and Print Forward Operators - -
            Example Optimization and Conditional Expressions - -
            Example Optimization and Nested Conditional Expressions - -
            Example Optimization and Cumulative Sum Operations -
- -
         -Abs-normal Representation of Non-Smooth Functions - - -
        Abs-normal Representation of Non-Smooth Functions - -
             -Create An Abs-normal Representation of a Function - - -
            Create An Abs-normal Representation of a Function - -
                abs_normal Getting Started: Example and Test -
- -
            abs_normal: Print a Vector or Matrix - -
             -abs_normal: Evaluate First Order Approximation - - -
            abs_normal: Evaluate First Order Approximation - -
                abs_eval: Example and Test - -
                abs_eval Source Code -
- -
             -abs_normal: Solve a Linear Program Using Simplex Method - - -
            abs_normal: Solve a Linear Program Using Simplex Method - -
                abs_normal simplex_method: Example and Test - -
                simplex_method Source Code -
- -
             -abs_normal: Solve a Linear Program With Box Constraints - - -
            abs_normal: Solve a Linear Program With Box Constraints - -
                abs_normal lp_box: Example and Test - -
                lp_box Source Code -
- -
             -abs_normal: Minimize a Linear Abs-normal Approximation - - -
            abs_normal: Minimize a Linear Abs-normal Approximation - -
                abs_min_linear: Example and Test - -
                abs_min_linear Source Code -
- -
             -Non-Smooth Optimization Using Abs-normal Linear Approximations - - -
            Non-Smooth Optimization Using Abs-normal Linear Approximations - -
                abs_normal min_nso_linear: Example and Test - -
                min_nso_linear Source Code -
- -
             -Solve a Quadratic Program Using Interior Point Method - - -
            Solve a Quadratic Program Using Interior Point Method - -
                abs_normal qp_interior: Example and Test - -
                qp_interior Source Code -
- -
             -abs_normal: Solve a Quadratic Program With Box Constraints - - -
            abs_normal: Solve a Quadratic Program With Box Constraints - -
                abs_normal qp_box: Example and Test - -
                qp_box Source Code -
- -
             -abs_normal: Minimize a Linear Abs-normal Approximation - - -
            abs_normal: Minimize a Linear Abs-normal Approximation - -
                abs_min_quad: Example and Test - -
                abs_min_quad Source Code -
- -
             -Non-Smooth Optimization Using Abs-normal Quadratic Approximations - - -
            Non-Smooth Optimization Using Abs-normal Quadratic Approximations - -
                abs_normal min_nso_quad: Example and Test - -
                min_nso_quad Source Code -
-
- -
         -Check an ADFun Sequence of Operations - - -
        Check an ADFun Sequence of Operations - -
            ADFun Check and Re-Tape: Example and Test -
- -
         -Check an ADFun Object For Nan Results - - -
        Check an ADFun Object For Nan Results - -
            ADFun Checking For Nan: Example and Test -
-
- -
    CppAD API Preprocessor Symbols - -
     -Using CppAD in a Multi-Threading Environment - - -
    Using CppAD in a Multi-Threading Environment - -
        Enable AD Calculations During Parallel Mode - -
         -Run Multi-Threading Examples and Speed Tests - - -
        Run Multi-Threading Examples and Speed Tests - -
            A Simple OpenMP Example and Test - -
            A Simple Boost Thread Example and Test - -
            A Simple Parallel Pthread Example and Test - -
            A Simple OpenMP AD: Example and Test - -
            A Simple Boost Threading AD: Example and Test - -
            A Simple pthread AD: Example and Test - -
            Using a Team of AD Threads: Example and Test - -
             -Multi-Threading Harmonic Summation Example / Test - - -
            Multi-Threading Harmonic Summation Example / Test - -
                Common Variables Used by Multi-threading Sum of 1/i - -
                Set Up Multi-threading Sum of 1/i - -
                Do One Thread's Work for Sum of 1/i - -
                Take Down Multi-threading Sum of 1/i - -
                Multi-Threaded Implementation of Summation of 1/i - -
                Timing Test of Multi-Threaded Summation of 1/i -
- -
             -Multi-Threading User Atomic Example / Test - - -
            Multi-Threading User Atomic Example / Test - -
                Defines a User Atomic Operation that Computes Square Root - -
                Multi-Threaded User Atomic Common Information - -
                Multi-Threaded User Atomic Set Up - -
                Multi-Threaded User Atomic Worker - -
                Multi-Threaded User Atomic Take Down - -
                Run Multi-Threaded User Atomic Calculation - -
                Timing Test for Multi-Threaded User Atomic Calculation -
- -
             -Multi-Threaded Newton Method Example / Test - - -
            Multi-Threaded Newton Method Example / Test - -
                Common Variables use by Multi-Threaded Newton Method - -
                Set Up Multi-Threaded Newton Method - -
                Do One Thread's Work for Multi-Threaded Newton Method - -
                Take Down Multi-threaded Newton Method - -
                A Multi-Threaded Newton's Method - -
                Timing Test of Multi-Threaded Newton Method -
- -
             -Specifications for A Team of AD Threads - - -
            Specifications for A Team of AD Threads - -
                OpenMP Implementation of a Team of AD Threads - -
                Boost Thread Implementation of a Team of AD Threads - -
                Pthread Implementation of a Team of AD Threads -
-
-
- -
     -Some General Purpose Utilities - - -
    Some General Purpose Utilities - -
         -Replacing the CppAD Error Handler - - -
        Replacing the CppAD Error Handler - -
            Replacing The CppAD Error Handler: Example and Test - -
            CppAD Assertions During Execution -
- -
         -Determine if Two Values Are Nearly Equal - - -
        Determine if Two Values Are Nearly Equal - -
            NearEqual Function: Example and Test -
- -
         -Run One Speed Test and Return Results - - -
        Run One Speed Test and Return Results - -
            speed_test: Example and test -
- -
         -Run One Speed Test and Print Results - - -
        Run One Speed Test and Print Results - -
            Example Use of SpeedTest -
- -
         -Determine Amount of Time to Execute a Test - - -
        Determine Amount of Time to Execute a Test - -
             -Returns Elapsed Number of Seconds - - -
            Returns Elapsed Number of Seconds - -
                Elapsed Seconds: Example and Test -
- -
            time_test: Example and test -
- -
        Object that Runs a Group of Tests - -
         -Definition of a Numeric Type - - -
        Definition of a Numeric Type - -
            The NumericType: Example and Test -
- -
         -Check NumericType Class Concept - - -
        Check NumericType Class Concept - -
            The CheckNumericType Function: Example and Test -
- -
         -Definition of a Simple Vector - - -
        Definition of a Simple Vector - -
            Simple Vector Template Class: Example and Test -
- -
         -Check Simple Vector Concept - - -
        Check Simple Vector Concept - -
            The CheckSimpleVector Function: Example and Test -
- -
         -Obtain Nan or Determine if a Value is Nan - - -
        Obtain Nan or Determine if a Value is Nan - -
            nan: Example and Test -
- -
         -The Integer Power Function - - -
        The Integer Power Function - -
            The Pow Integer Exponent: Example and Test -
- -
         -Evaluate a Polynomial or its Derivative - - -
        Evaluate a Polynomial or its Derivative - -
            Polynomial Evaluation: Example and Test - -
            Source: Poly -
- -
         -Compute Determinants and Solve Equations by LU Factorization - - -
        Compute Determinants and Solve Equations by LU Factorization - -
             -Compute Determinant and Solve Linear Equations - - -
            Compute Determinant and Solve Linear Equations - -
                LuSolve With Complex Arguments: Example and Test - -
                Source: LuSolve -
- -
             -LU Factorization of A Square Matrix - - -
            LU Factorization of A Square Matrix - -
                LuFactor: Example and Test - -
                Source: LuFactor -
- -
             -Invert an LU Factored Equation - - -
            Invert an LU Factored Equation - -
                LuInvert: Example and Test - -
                Source: LuInvert -
-
- -
         -One DimensionalRomberg Integration - - -
        One DimensionalRomberg Integration - -
            One Dimensional Romberg Integration: Example and Test -
- -
         -Multi-dimensional Romberg Integration - - -
        Multi-dimensional Romberg Integration - -
            One Dimensional Romberg Integration: Example and Test -
- -
         -An Embedded 4th and 5th Order Runge-Kutta ODE Solver - - -
        An Embedded 4th and 5th Order Runge-Kutta ODE Solver - -
            Runge45: Example and Test - -
            Runge45: Example and Test -
- -
         -A 3rd and 4th Order Rosenbrock ODE Solver - - -
        A 3rd and 4th Order Rosenbrock ODE Solver - -
            Rosen34: Example and Test -
- -
         -An Error Controller for ODE Solvers - - -
        An Error Controller for ODE Solvers - -
            OdeErrControl: Example and Test - -
            OdeErrControl: Example and Test Using Maxabs Argument -
- -
         -An Arbitrary Order Gear Method - - -
        An Arbitrary Order Gear Method - -
            OdeGear: Example and Test -
- -
         -An Error Controller for Gear's Ode Solvers - - -
        An Error Controller for Gear's Ode Solvers - -
            OdeGearControl: Example and Test -
- -
         -The CppAD::vector Template Class - - -
        The CppAD::vector Template Class - -
            CppAD::vector Template Class: Example and Test - -
            CppAD::vectorBool Class: Example and Test -
- -
         -A Fast Multi-Threading Memory Allocator - - -
        A Fast Multi-Threading Memory Allocator - -
            Fast Multi-Threading Memory Allocator: Example and Test - -
            Setup thread_alloc For Use in Multi-Threading Environment - -
            Get Number of Threads - -
            Is The Current Execution in Parallel Mode - -
            Get the Current Thread Number - -
            Get At Least A Specified Amount of Memory - -
            Return Memory to thread_alloc - -
            Free Memory Currently Available for Quick Use by a Thread - -
            Control When Thread Alloc Retains Memory For Future Use - -
            Amount of Memory a Thread is Currently Using - -
            Amount of Memory Available for Quick Use by a Thread - -
            Allocate An Array and Call Default Constructor for its Elements - -
            Deallocate An Array and Call Destructor for its Elements - -
            Free All Memory That Was Allocated for Use by thread_alloc -
- -
         -Returns Indices that Sort a Vector - - -
        Returns Indices that Sort a Vector - -
            Index Sort: Example and Test -
- -
         -Convert Certain Types to a String - - -
        Convert Certain Types to a String - -
            to_string: Example and Test -
- -
         -Union of Standard Sets - - -
        Union of Standard Sets - -
            Set Union: Example and Test -
- -
         -Row and Column Index Sparsity Patterns - - -
        Row and Column Index Sparsity Patterns - -
            sparse_rc: Example and Test -
- -
         -Sparse Matrix Row, Column, Value Representation - - -
        Sparse Matrix Row, Column, Value Representation - -
            sparse_rcv: Example and Test -
-
- -
     -Use Ipopt to Solve a Nonlinear Programming Problem - - -
    Use Ipopt to Solve a Nonlinear Programming Problem - -
        Nonlinear Programming Using CppAD and Ipopt: Example and Test - -
        Nonlinear Programming Retaping: Example and Test - -
        ODE Inverse Problem Definitions: Source Code -
- -
     -Examples - - -
    Examples - -
        Getting Started Using CppAD to Compute Derivatives - -
         -General Examples - - -
        General Examples - -
            Creating Your Own Interface to an ADFun Object - -
            Example and Test Linking CppAD to Languages Other than C++ - -
            Differentiate Conjugate Gradient Algorithm: Example and Test - -
             -Enable Use of Eigen Linear Algebra Package with CppAD - - -
            Enable Use of Eigen Linear Algebra Package with CppAD - -
                Source Code for eigen_plugin.hpp - -
                Using Eigen Arrays: Example and Test - -
                Using Eigen To Compute Determinant: Example and Test -
- -
            Gradient of Determinant Using Expansion by Minors: Example and Test - -
            Gradient of Determinant Using LU Factorization: Example and Test - -
            Interfacing to C: Example and Test - -
            Gradient of Determinant Using Expansion by Minors: Example and Test - -
            Gradient of Determinant Using Lu Factorization: Example and Test - -
             -Using Multiple Levels of AD - - -
            Using Multiple Levels of AD - -
                Multiple Level of AD: Example and Test - -
                Computing a Jacobian With Constants that Change -
- -
            A Stiff Ode: Example and Test - -
            Taylor's Ode Solver: A Multi-Level AD Example and Test - -
            Taylor's Ode Solver: A Multi-Level Adolc Example and Test - -
            Taylor's Ode Solver: An Example and Test - -
            Example Differentiating a Stack Machine Interpreter -
- -
         -Utility Routines used by CppAD Examples - - -
        Utility Routines used by CppAD Examples - -
            CppAD Examples and Tests - -
            Run the Speed Examples - -
             -Lu Factor and Solve with Recorded Pivoting - - -
            Lu Factor and Solve with Recorded Pivoting - -
                Lu Factor and Solve With Recorded Pivoting: Example and Test -
-
- -
        List All (Except Deprecated) CppAD Examples - -
        Using The CppAD Test Vector Template Class - -
        Suppress Suspect Implicit Conversion Warnings -
- -
     -Speed Test an Operator Overloading AD Package - - -
    Speed Test an Operator Overloading AD Package - -
         -Running the Speed Test Program - - -
        Running the Speed Test Program - -
            Speed Testing Gradient of Determinant Using Lu Factorization - -
            Speed Testing Gradient of Determinant by Minor Expansion - -
            Speed Testing Derivative of Matrix Multiply - -
            Speed Testing the Jacobian of Ode Solution - -
            Speed Testing Second Derivative of a Polynomial - -
            Speed Testing Sparse Hessian - -
            Speed Testing Sparse Jacobian - -
            Microsoft Version of Elapsed Number of Seconds -
- -
         -Speed Testing Utilities - - -
        Speed Testing Utilities - -
             -Determinant Using Expansion by Lu Factorization - - -
            Determinant Using Expansion by Lu Factorization - -
                Determinant Using Lu Factorization: Example and Test - -
                Source: det_by_lu -
- -
             -Determinant of a Minor - - -
            Determinant of a Minor - -
                Determinant of a Minor: Example and Test - -
                Source: det_of_minor -
- -
             -Determinant Using Expansion by Minors - - -
            Determinant Using Expansion by Minors - -
                Determinant Using Expansion by Minors: Example and Test - -
                Source: det_by_minor -
- -
             -Check Determinant of 3 by 3 matrix - - -
            Check Determinant of 3 by 3 matrix - -
                Source: det_33 -
- -
             -Check Gradient of Determinant of 3 by 3 matrix - - -
            Check Gradient of Determinant of 3 by 3 matrix - -
                Source: det_grad_33 -
- -
             -Sum Elements of a Matrix Times Itself - - -
            Sum Elements of a Matrix Times Itself - -
                Sum of the Elements of the Square of a Matrix: Example and Test - -
                Source: mat_sum_sq -
- -
             -Evaluate a Function Defined in Terms of an ODE - - -
            Evaluate a Function Defined in Terms of an ODE - -
                ode_evaluate: Example and test - -
                Source: ode_evaluate -
- -
             -Evaluate a Function That Has a Sparse Jacobian - - -
            Evaluate a Function That Has a Sparse Jacobian - -
                sparse_jac_fun: Example and test - -
                Source: sparse_jac_fun -
- -
             -Evaluate a Function That Has a Sparse Hessian - - -
            Evaluate a Function That Has a Sparse Hessian - -
                sparse_hes_fun: Example and test - -
                Source: sparse_hes_fun -
- -
             -Simulate a [0,1] Uniform Random Variate - - -
            Simulate a [0,1] Uniform Random Variate - -
                Source: uniform_01 -
-
- -
         -Speed Test of Functions in Double - - -
        Speed Test of Functions in Double - -
            Double Speed: Determinant by Minor Expansion - -
            Double Speed: Determinant Using Lu Factorization - -
            CppAD Speed: Matrix Multiplication (Double Version) - -
            Double Speed: Ode Solution - -
            Double Speed: Evaluate a Polynomial - -
            Double Speed: Sparse Hessian - -
            Double Speed: Sparse Jacobian -
- -
         -Speed Test of Derivatives Using Adolc - - -
        Speed Test of Derivatives Using Adolc - -
            Adolc Speed: Gradient of Determinant by Minor Expansion - -
            Adolc Speed: Gradient of Determinant Using Lu Factorization - -
            Adolc Speed: Matrix Multiplication - -
            Adolc Speed: Ode - -
            Adolc Speed: Second Derivative of a Polynomial - -
            Adolc Speed: Sparse Hessian - -
            adolc Speed: Sparse Jacobian - -
            Adolc Test Utility: Allocate and Free Memory For a Matrix -
- -
         -Speed Test Derivatives Using CppAD - - -
        Speed Test Derivatives Using CppAD - -
            CppAD Speed: Gradient of Determinant by Minor Expansion - -
            CppAD Speed: Gradient of Determinant Using Lu Factorization - -
            CppAD Speed, Matrix Multiplication - -
            CppAD Speed: Gradient of Ode Solution - -
            CppAD Speed: Second Derivative of a Polynomial - -
            CppAD Speed: Sparse Hessian - -
            CppAD Speed: Sparse Jacobian -
- -
         -Speed Test Derivatives Using Fadbad - - -
        Speed Test Derivatives Using Fadbad - -
            Fadbad Speed: Gradient of Determinant by Minor Expansion - -
            Fadbad Speed: Gradient of Determinant Using Lu Factorization - -
            Fadbad Speed: Matrix Multiplication - -
            Fadbad Speed: Ode - -
            Fadbad Speed: Second Derivative of a Polynomial - -
            Fadbad Speed: Sparse Hessian - -
            fadbad Speed: sparse_jacobian -
- -
         -Speed Test Derivatives Using Sacado - - -
        Speed Test Derivatives Using Sacado - -
            Sacado Speed: Gradient of Determinant by Minor Expansion - -
            Sacado Speed: Gradient of Determinant Using Lu Factorization - -
            Sacado Speed: Matrix Multiplication - -
            Sacado Speed: Gradient of Ode Solution - -
            Sacado Speed: Second Derivative of a Polynomial - -
            Sacado Speed: Sparse Hessian - -
            sacado Speed: sparse_jacobian -
-
- -
     -Appendix - - -
    Appendix - -
        Frequently Asked Questions and Answers - -
        Directory Structure - -
         -The Theory of Derivative Calculations - - -
        The Theory of Derivative Calculations - -
             -The Theory of Forward Mode - - -
            The Theory of Forward Mode - -
                Exponential Function Forward Mode Theory - -
                Logarithm Function Forward Mode Theory - -
                Square Root Function Forward Mode Theory - -
                Trigonometric and Hyperbolic Sine and Cosine Forward Theory - -
                Inverse Tangent and Hyperbolic Tangent Forward Mode Theory - -
                Inverse Sine and Hyperbolic Sine Forward Mode Theory - -
                Inverse Cosine and Hyperbolic Cosine Forward Mode Theory - -
                Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory - -
                Error Function Forward Taylor Polynomial Theory -
- -
             -The Theory of Reverse Mode - - -
            The Theory of Reverse Mode - -
                Exponential Function Reverse Mode Theory - -
                Logarithm Function Reverse Mode Theory - -
                Square Root Function Reverse Mode Theory - -
                Trigonometric and Hyperbolic Sine and Cosine Reverse Theory - -
                Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory - -
                Inverse Sine and Hyperbolic Sine Reverse Mode Theory - -
                Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory - -
                Tangent and Hyperbolic Tangent Reverse Mode Theory - -
                Error Function Reverse Mode Theory -
- -
            An Important Reverse Mode Identity -
- -
        Glossary - -
        Bibliography - -
        The CppAD Wish List - -
         -Changes and Additions to CppAD - - -
        Changes and Additions to CppAD - -
            Changes and Additions to CppAD During 2017 - -
            Changes and Additions to CppAD During 2016 - -
            CppAD Changes and Additions During 2015 - -
            CppAD Changes and Additions During 2014 - -
            CppAD Changes and Additions During 2013 - -
            CppAD Changes and Additions During 2012 - -
            Changes and Additions to CppAD During 2011 - -
            Changes and Additions to CppAD During 2010 - -
            Changes and Additions to CppAD During 2009 - -
            Changes and Additions to CppAD During 2008 - -
            Changes and Additions to CppAD During 2007 - -
            Changes and Additions to CppAD During 2006 - -
            Changes and Additions to CppAD During 2005 - -
            Changes and Additions to CppAD During 2004 - -
            Changes and Additions to CppAD During 2003 -
- -
         -CppAD Deprecated API Features - - -
        CppAD Deprecated API Features - -
            Deprecated Include Files - -
            ADFun Object Deprecated Member Functions - -
            Comparison Changes During Zero Order Forward Mode - -
            OpenMP Parallel Setup - -
             -Routines That Track Use of New and Delete - - -
            Routines That Track Use of New and Delete - -
                Tracking Use of New and Delete: Example and Test -
- -
             -A Quick OpenMP Memory Allocator Used by CppAD - - -
            A Quick OpenMP Memory Allocator Used by CppAD - -
                Set and Get Maximum Number of Threads for omp_alloc Allocator - -
                Is The Current Execution in OpenMP Parallel Mode - -
                Get the Current OpenMP Thread Number - -
                Get At Least A Specified Amount of Memory - -
                Return Memory to omp_alloc - -
                Free Memory Currently Available for Quick Use by a Thread - -
                Amount of Memory a Thread is Currently Using - -
                Amount of Memory Available for Quick Use by a Thread - -
                Allocate Memory and Create A Raw Array - -
                Return A Raw Array to The Available Memory for a Thread - -
                Check If A Memory Allocation is Efficient for Another Use - -
                Set Maximum Number of Threads for omp_alloc Allocator - -
                OpenMP Memory Allocator: Example and Test -
- -
            Memory Leak Detection - -
            Machine Epsilon For AD Types - -
            Choosing The Vector Testing Template Class - -
             -Nonlinear Programming Using the CppAD Interface to Ipopt - - -
            Nonlinear Programming Using the CppAD Interface to Ipopt - -
                Nonlinear Programming Using CppAD and Ipopt: Example and Test - -
                 -Example Simultaneous Solution of Forward and Inverse Problem - - -
                Example Simultaneous Solution of Forward and Inverse Problem - -
                     -An ODE Inverse Problem Example - - -
                    An ODE Inverse Problem Example - -
                        ODE Inverse Problem Definitions: Source Code -
- -
                     -ODE Fitting Using Simple Representation - - -
                    ODE Fitting Using Simple Representation - -
                        ODE Fitting Using Simple Representation -
- -
                     -ODE Fitting Using Fast Representation - - -
                    ODE Fitting Using Fast Representation - -
                        ODE Fitting Using Fast Representation -
- -
                    Driver for Running the Ipopt ODE Example - -
                    Correctness Check for Both Simple and Fast Representations -
- -
                Speed Test for Both Simple and Fast Representations -
- -
             -User Defined Atomic AD Functions - - -
            User Defined Atomic AD Functions - -
                Old Atomic Operation Reciprocal: Example and Test - -
                Using AD to Compute Atomic Function Derivatives - -
                Using AD to Compute Atomic Function Derivatives - -
                Old Tan and Tanh as User Atomic Operations: Example and Test - -
                 -Old Matrix Multiply as a User Atomic Operation: Example and Test - - -
                Old Matrix Multiply as a User Atomic Operation: Example and Test - -
                    Define Matrix Multiply as a User Atomic Operation -
-
- -
             -zdouble: An AD Base Type With Absolute Zero - - -
            zdouble: An AD Base Type With Absolute Zero - -
                zdouble: Example and Test -
- -
            Autotools Unix Test and Installation -
- -
         -Compare Speed of C and C++ - - -
        Compare Speed of C and C++ - -
            Determinant of a Minor - -
            Compute Determinant using Expansion by Minors - -
            Simulate a [0,1] Uniform Random Variate - -
            Correctness Test of det_by_minor Routine - -
            Repeat det_by_minor Routine A Specified Number of Times - -
            Returns Elapsed Number of Seconds - -
            Determine Amount of Time to Execute det_by_minor - -
            Main Program For Comparing C and C++ Speed -
- -
         -Some Numerical AD Utilities - - -
        Some Numerical AD Utilities - -
             -Computing Jacobian and Hessian of Bender's Reduced Objective - - -
            Computing Jacobian and Hessian of Bender's Reduced Objective - -
                BenderQuad: Example and Test -
- -
             -Jacobian and Hessian of Optimal Values - - -
            Jacobian and Hessian of Optimal Values - -
                opt_val_hes: Example and Test -
- -
             -LU Factorization of A Square Matrix and Stability Calculation - - -
            LU Factorization of A Square Matrix and Stability Calculation - -
                LuRatio: Example and Test -
-
- -
        CppAD Addons - -
        Your License for the CppAD Software -
- -
    Alphabetic Listing of Cross Reference Tags - -
    Keyword Index - -
    Search This Web Site - -
    External Internet References -
- - - - diff -Nru cppad-2018.00.00.0/doc/__contents_xml.js cppad-2019.02.00.0/doc/__contents_xml.js --- cppad-2018.00.00.0/doc/__contents_xml.js 2018-01-01 08:32:40.000000000 +0000 +++ cppad-2019.02.00.0/doc/__contents_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'_contents_xml.htm' -]; -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' -]; -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-2018.00.00.0/doc/convert.xml cppad-2019.02.00.0/doc/convert.xml --- cppad-2018.00.00.0/doc/convert.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/convert.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ - - - -Conversion and I/O of AD Objects - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -Headings

-
Conversion and I/O of AD Objects
- - - - - - -
-Value -Convert From an AD Type to its Base Type
-Integer -Convert From AD to Integer
-ad_output -AD Output Stream Operator
-PrintFor -Printing AD Values During Forward Mode
-Var2Par -Convert an AD Variable to a Parameter
-
- -
Input File: cppad/core/convert.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_convert_xml.js cppad-2019.02.00.0/doc/_convert_xml.js --- cppad-2018.00.00.0/doc/_convert_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_convert_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'convert.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 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down0 = [ -'value.xml', -'integer.xml', -'ad_to_string.xml', -'ad_input.xml', -'ad_output.xml', -'printfor.xml', -'var2par.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_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-2018.00.00.0/doc/correct_det_by_minor_c.xml cppad-2019.02.00.0/doc/correct_det_by_minor_c.xml --- cppad-2018.00.00.0/doc/correct_det_by_minor_c.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/correct_det_by_minor_c.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,153 +0,0 @@ - - - -Correctness Test of det_by_minor Routine - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -correct_det_by_minor_c - -

-
Correctness Test of det_by_minor Routine
-
-Syntax - -
- -flag = correct_det_by_minor() - - -
-
-flag -
-The return value has prototype - -
-     bool 
flag
-
-It value is 1 if the test passes and 0 otherwise. - - - - -
-
-Source Code - -
bool correct_det_by_minor(void)
-{     double a[9], det, check;
-
-     random_seed(123);
-     uniform_01(9, a);
-
-     /* compute determinant using expansion by minors */
-     det = det_by_minor(a, 3);
-
-     /* use expansion by minors to hand code the determinant  */
-     check = 0.;
-     check += a[0] * ( a[4] * a[8] - a[5] * a[7] );
-     check -= a[1] * ( a[3] * a[8] - a[5] * a[6] );
-     check += a[2] * ( a[3] * a[7] - a[4] * a[6] );
-
-     double eps99 = 99.0 * DBL_EPSILON;
-     if( fabs(det / check - 1.0) < eps99 )
-          return true;
-     return false;
-}
- -
Input File: test_more/compare_c/det_by_minor.c - - - diff -Nru cppad-2018.00.00.0/doc/_correct_det_by_minor_c_xml.js cppad-2019.02.00.0/doc/_correct_det_by_minor_c_xml.js --- cppad-2018.00.00.0/doc/_correct_det_by_minor_c_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_correct_det_by_minor_c_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', -'appendix.xml', -'compare_c.xml', -'correct_det_by_minor_c.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', -'directory.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 = [ -'det_of_minor_c.xml', -'det_by_minor_c.xml', -'uniform_01_c.xml', -'correct_det_by_minor_c.xml', -'repeat_det_by_minor_c.xml', -'elapsed_seconds_c.xml', -'time_det_by_minor_c.xml', -'main_compare_c.xml' -]; -var list_current0 = [ -'correct_det_by_minor_c.xml#Syntax', -'correct_det_by_minor_c.xml#flag', -'correct_det_by_minor_c.xml#Source Code' -]; -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-2018.00.00.0/doc/cos.cpp.xml cppad-2019.02.00.0/doc/cos.cpp.xml --- cppad-2018.00.00.0/doc/cos.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/cos.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ - - - -The AD cos Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cos.cppHeadings

-
The AD cos Function: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cmath>
-
-bool Cos(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * 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);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::cos(x[0]);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     double check = std::cos(x0);
-     ok &= NearEqual(y[0] , check, eps99, eps99);
-
-     // 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::sin(x0);
-     ok   &= NearEqual(dy[0], check, eps99, eps99);
-
-     // 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, eps99, eps99);
-
-     // use a VecAD<Base>::reference object with cos
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero]           = x0;
-     AD<double> result = CppAD::cos(v[zero]);
-     check = std::cos(x0);
-     ok   &= NearEqual(result, check, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/cos.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_cos.cpp_xml.js cppad-2019.02.00.0/doc/_cos.cpp_xml.js --- cppad-2018.00.00.0/doc/_cos.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cos.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'cos.xml', -'cos.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 = [ -'cos.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-2018.00.00.0/doc/cosh.cpp.xml cppad-2019.02.00.0/doc/cosh.cpp.xml --- cppad-2018.00.00.0/doc/cosh.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/cosh.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ - - - -The AD cosh Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cosh.cppHeadings

-
The AD cosh Function: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cmath>
-
-bool Cosh(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * 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);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::cosh(x[0]);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     double check = std::cosh(x0);
-     ok &= NearEqual(y[0] , check, eps99, eps99);
-
-     // 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::sinh(x0);
-     ok   &= NearEqual(dy[0], check, eps99, eps99);
-
-     // 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, eps99, eps99);
-
-     // use a VecAD<Base>::reference object with cosh
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero]           = x0;
-     AD<double> result = CppAD::cosh(v[zero]);
-     check = std::cosh(x0);
-     ok   &= NearEqual(result, check, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/cosh.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_cosh.cpp_xml.js cppad-2019.02.00.0/doc/_cosh.cpp_xml.js --- cppad-2018.00.00.0/doc/_cosh.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cosh.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'cosh.xml', -'cosh.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 = [ -'cosh.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-2018.00.00.0/doc/cosh.xml cppad-2019.02.00.0/doc/cosh.xml --- cppad-2018.00.00.0/doc/cosh.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/cosh.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ - - - -The Hyperbolic Cosine Function: cosh - - - - - - - - - - - - - - - - -
- -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_cosh_xml.js cppad-2019.02.00.0/doc/_cosh_xml.js --- cppad-2018.00.00.0/doc/_cosh_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cosh_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'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-2018.00.00.0/doc/cos.xml cppad-2019.02.00.0/doc/cos.xml --- cppad-2018.00.00.0/doc/cos.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/cos.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,183 +0,0 @@ - - - -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_cos_xml.js cppad-2019.02.00.0/doc/_cos_xml.js --- cppad-2018.00.00.0/doc/_cos_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cos_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'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-2018.00.00.0/doc/cppad_assert.xml cppad-2019.02.00.0/doc/cppad_assert.xml --- cppad-2018.00.00.0/doc/cppad_assert.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_assert.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,218 +0,0 @@ - - - -CppAD Assertions During Execution - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cppad_assert - -

-
CppAD Assertions During Execution
-
-Syntax - -
- -CPPAD_ASSERT_KNOWN(expmsg)
-
- -CPPAD_ASSERT_UNKNOWN(exp) - - - -
-
-Purpose -
-These CppAD macros are used to detect and report errors. -They are documented here because they correspond to the C++ -source code that the error is reported at. - -
-
-NDEBUG -
-If the preprocessor symbol -NDEBUG - is defined, -these macros do nothing; i.e., they are optimized out. - -
-
-Restriction -
-The CppAD user should not uses these macros. -You can however write your own macros that do not begin with CPPAD -and that call the CppAD error handler -. - -
-
-Known -
-The 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. - -
-
-Unknown -
-The 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 -occurred; for example, the user may have written past the end -of an allocated array. - -
-
-Exp -
-The argument -exp - is a C++ source code expression -that results in a bool value that should be true. -If it is false, an error has occurred. -This expression may be execute any number of times -(including zero times) so it must have not side effects. - -
-
-Msg -
-The argument -msg - has prototype - -
-     const char *
msg
-
-and contains a '\0' terminated character string. -This string is a description of the error -corresponding to -exp - being false. - -
-
-Error Handler -
-These macros use the -CppAD error handler - to report errors. -This error handler can be replaced by the user. - - -
Input File: cppad/core/cppad_assert.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_assert_xml.js cppad-2019.02.00.0/doc/_cppad_assert_xml.js --- cppad-2018.00.00.0/doc/_cppad_assert_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_assert_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'errorhandler.xml', -'cppad_assert.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'error_handler.cpp.xml', -'cppad_assert.xml' -]; -var list_current0 = [ -'cppad_assert.xml#Syntax', -'cppad_assert.xml#Purpose', -'cppad_assert.xml#NDEBUG', -'cppad_assert.xml#Restriction', -'cppad_assert.xml#Known', -'cppad_assert.xml#Unknown', -'cppad_assert.xml#Exp', -'cppad_assert.xml#Msg', -'cppad_assert.xml#Error Handler' -]; -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-2018.00.00.0/doc/cppad_det_lu.cpp.xml cppad-2019.02.00.0/doc/cppad_det_lu.cpp.xml --- cppad-2018.00.00.0/doc/cppad_det_lu.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_det_lu.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,187 +0,0 @@ - - - -CppAD Speed: Gradient of Determinant Using Lu Factorization - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cppad_det_lu.cpp - -

-
CppAD Speed: Gradient of Determinant Using Lu Factorization
-
-Specifications -
-See link_det_lu -. - -
-
-Implementation - -
# include <cppad/speed/det_by_lu.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/cppad.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_det_lu(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     CppAD::vector<double>           &matrix   ,
-     CppAD::vector<double>           &gradient )
-{
-     // --------------------------------------------------------------------
-     // check global options
-     const char* valid[] = { "memory", "optimize"};
-     size_t n_valid = sizeof(valid) / sizeof(valid[0]);
-     typedef std::map<std::string, bool>::iterator iterator;
-     //
-     for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr)
-     {     if( itr->second )
-          {     bool ok = false;
-               for(size_t i = 0; i < n_valid; i++)
-                    ok |= itr->first == valid[i];
-               if( ! ok )
-                    return false;
-          }
-     }
-     // --------------------------------------------------------------------
-
-     // optimization options: no conditional skips or compare operators
-     std::string options="no_compare_op";
-     // -----------------------------------------------------
-     // setup
-     typedef CppAD::AD<double>           ADScalar;
-     typedef CppAD::vector<ADScalar>     ADVector;
-     CppAD::det_by_lu<ADScalar>          Det(size);
-
-     size_t i;               // temporary index
-     size_t m = 1;           // number of dependent variables
-     size_t n = size * size; // number of independent variables
-     ADVector   A(n);        // AD domain space vector
-     ADVector   detA(m);     // AD range space vector
-     CppAD::ADFun<double> f; // AD function object
-
-     // vectors of reverse mode weights
-     CppAD::vector<double> w(1);
-     w[0] = 1.;
-
-     // ------------------------------------------------------
-     while(repeat--)
-     {     // get the next matrix
-          CppAD::uniform_01(n, matrix);
-          for( i = 0; i < n; 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_option["optimize"] )
-               f.optimize(options);
-
-          // skip comparison operators
-          f.compare_change_count(0);
-
-          // evaluate and return gradient using reverse mode
-          f.Forward(0, matrix);
-          gradient = f.Reverse(1, w);
-     }
-     return true;
-}
- -
Input File: speed/cppad/det_lu.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_det_lu.cpp_xml.js cppad-2019.02.00.0/doc/_cppad_det_lu.cpp_xml.js --- cppad-2018.00.00.0/doc/_cppad_det_lu.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_det_lu.cpp_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', -'speed.xml', -'speed_cppad.xml', -'cppad_det_lu.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'cppad_det_minor.cpp.xml', -'cppad_det_lu.cpp.xml', -'cppad_mat_mul.cpp.xml', -'cppad_ode.cpp.xml', -'cppad_poly.cpp.xml', -'cppad_sparse_hessian.cpp.xml', -'cppad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'cppad_det_lu.cpp.xml#Specifications', -'cppad_det_lu.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/cppad_det_minor.cpp.xml cppad-2019.02.00.0/doc/cppad_det_minor.cpp.xml --- cppad-2018.00.00.0/doc/cppad_det_minor.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_det_minor.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,229 +0,0 @@ - - - -CppAD Speed: Gradient of Determinant by Minor Expansion - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cppad_det_minor.cpp - -

-
CppAD Speed: Gradient of Determinant by Minor Expansion
-
-Specifications -
-See link_det_minor -. - -
-
-Implementation - -
# include <cppad/cppad.hpp>
-# include <cppad/speed/det_by_minor.hpp>
-# include <cppad/speed/uniform_01.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_det_minor(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &matrix   ,
-     CppAD::vector<double>     &gradient )
-{
-     // --------------------------------------------------------------------
-     // check global options
-     const char* valid[] = { "memory", "onetape", "optimize"};
-     size_t n_valid = sizeof(valid) / sizeof(valid[0]);
-     typedef std::map<std::string, bool>::iterator iterator;
-     //
-     for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr)
-     {     if( itr->second )
-          {     bool ok = false;
-               for(size_t i = 0; i < n_valid; i++)
-                    ok |= itr->first == valid[i];
-               if( ! ok )
-                    return false;
-          }
-     }
-     // --------------------------------------------------------------------
-
-     // optimization options: no conditional skips or compare operators
-     std::string options="no_compare_op";
-     // -----------------------------------------------------
-     // setup
-
-     // object for computing determinant
-     typedef CppAD::AD<double>       ADScalar;
-     typedef CppAD::vector<ADScalar> ADVector;
-     CppAD::det_by_minor<ADScalar>   Det(size);
-
-     size_t i;               // temporary index
-     size_t m = 1;           // number of dependent variables
-     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
-     CppAD::vector<double> w(1);
-     w[0] = 1.;
-
-     // the AD function object
-     CppAD::ADFun<double> f;
-
-     // ---------------------------------------------------------------------
-     if( ! global_option["onetape"] ) while(repeat--)
-     {
-          // choose a matrix
-          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_option["optimize"] )
-               f.optimize(options);
-
-          // 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);
-     }
-     else
-     {
-          // choose a matrix
-          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_option["optimize"] )
-               f.optimize(options);
-
-          // 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);
-          }
-     }
-     return true;
-}
- -
Input File: speed/cppad/det_minor.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_det_minor.cpp_xml.js cppad-2019.02.00.0/doc/_cppad_det_minor.cpp_xml.js --- cppad-2018.00.00.0/doc/_cppad_det_minor.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_det_minor.cpp_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', -'speed.xml', -'speed_cppad.xml', -'cppad_det_minor.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'cppad_det_minor.cpp.xml', -'cppad_det_lu.cpp.xml', -'cppad_mat_mul.cpp.xml', -'cppad_ode.cpp.xml', -'cppad_poly.cpp.xml', -'cppad_sparse_hessian.cpp.xml', -'cppad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'cppad_det_minor.cpp.xml#Specifications', -'cppad_det_minor.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/cppad_eigen.hpp.xml cppad-2019.02.00.0/doc/cppad_eigen.hpp.xml --- cppad-2018.00.00.0/doc/cppad_eigen.hpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_eigen.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,245 +0,0 @@ - - - -Enable Use of Eigen Linear Algebra Package with CppAD - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Enable Use of Eigen Linear Algebra Package with CppAD
-
-Syntax - -
- -# include <cppad/example/cppad_eigen.hpp> - - - -
-
-Purpose -
-Enables the use of the eigen - -linear algebra package with the type -AD<Base> -; see -custom scalar types -. - -
-
-Example -
-The files eigen_array.cpp - and eigen_det.cpp - -contain an example and test of this include file. -They return true if they succeed and false otherwise. - -
-
-Include Files -
-The file cppad_eigen.hpp includes both -<cppad/cppad.hpp> and <Eigen/Core>. -The file eigen_plugin.hpp - defines value_type -in the Eigen matrix class so its vectors are -simple vectors - -(not necessary for eigen-3.3.3 and later). -

-# define EIGEN_MATRIXBASE_PLUGIN <cppad/example/eigen_plugin.hpp>
-# include <Eigen/Core>
-# include <cppad/cppad.hpp>
-
-
-Eigen NumTraits -
-Eigen needs the following definitions to work properly -with -AD<Base> - scalars: -
namespace Eigen {
-     template <class Base> struct NumTraits< CppAD::AD<Base> >
-     {     // type that corresponds to the real part of an AD<Base> value
-          typedef CppAD::AD<Base>   Real;
-          // type for AD<Base> operations that result in non-integer values
-          typedef CppAD::AD<Base>   NonInteger;
-          //  type to use for numeric literals such as "2" or "0.5".
-          typedef CppAD::AD<Base>   Literal;
-          // type for nested value inside an AD<Base> expression tree
-          typedef CppAD::AD<Base>   Nested;
-
-          enum {
-               // does not support complex Base types
-               IsComplex             = 0 ,
-               // does not support integer Base types
-               IsInteger             = 0 ,
-               // only support signed Base types
-               IsSigned              = 1 ,
-               // must initialize an AD<Base> object
-               RequireInitialization = 1 ,
-               // computational cost of the corresponding operations
-               ReadCost              = 1 ,
-               AddCost               = 2 ,
-               MulCost               = 2
-          };
-
-          // machine epsilon with type of real part of x
-          // (use assumption that Base is not complex)
-          static CppAD::AD<Base> epsilon(void)
-          {     return CppAD::numeric_limits< CppAD::AD<Base> >::epsilon(); }
-
-          // relaxed version of machine epsilon for comparison of different
-          // operations that should result in the same value
-          static CppAD::AD<Base> dummy_precision(void)
-          {     return 100. *
-                    CppAD::numeric_limits< CppAD::AD<Base> >::epsilon();
-          }
-
-          // minimum normalized positive value
-          static CppAD::AD<Base> lowest(void)
-          {     return CppAD::numeric_limits< CppAD::AD<Base> >::min(); }
-
-          // maximum finite value
-          static CppAD::AD<Base> highest(void)
-          {     return CppAD::numeric_limits< CppAD::AD<Base> >::max(); }
-
-          // number of decimal digits that can be represented without change.
-          static int digits10(void)
-          {     return CppAD::numeric_limits< CppAD::AD<Base> >::digits10; }
-     };
-}
-
-CppAD Namespace -
-Eigen also needs the following definitions to work properly -with -AD<Base> - scalars: -
namespace CppAD {
-          // functions that return references
-          template <class Base> const AD<Base>& conj(const AD<Base>& x)
-          {     return x; }
-          template <class Base> const AD<Base>& real(const AD<Base>& x)
-          {     return x; }
-
-          // functions that return values (note abs is defined by cppad.hpp)
-          template <class Base> AD<Base> imag(const AD<Base>& x)
-          {     return CppAD::AD<Base>(0.); }
-          template <class Base> AD<Base> abs2(const AD<Base>& x)
-          {     return x * x; }
-}
-
- -
Input File: cppad/example/cppad_eigen.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_eigen.hpp_xml.js cppad-2019.02.00.0/doc/_cppad_eigen.hpp_xml.js --- cppad-2018.00.00.0/doc/_cppad_eigen.hpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_eigen.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +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', -'cppad_eigen.hpp.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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_down0 = [ -'eigen_plugin.hpp.xml', -'eigen_array.cpp.xml', -'eigen_det.cpp.xml' -]; -var list_current0 = [ -'cppad_eigen.hpp.xml#Syntax', -'cppad_eigen.hpp.xml#Purpose', -'cppad_eigen.hpp.xml#Example', -'cppad_eigen.hpp.xml#Include Files', -'cppad_eigen.hpp.xml#Eigen NumTraits', -'cppad_eigen.hpp.xml#CppAD 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_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-2018.00.00.0/doc/cppad_ipopt_nlp.xml cppad-2019.02.00.0/doc/cppad_ipopt_nlp.xml --- cppad-2018.00.00.0/doc/cppad_ipopt_nlp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_ipopt_nlp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,2114 +0,0 @@ - - - -Nonlinear Programming Using the CppAD Interface to Ipopt - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Nonlinear Programming Using the CppAD Interface to Ipopt
-
-Deprecated 2012-11-28 -
-This interface to Ipopt is deprecated, use ipopt_solve - instead. - -
-
-Syntax - -
- -# include "cppad_ipopt_nlp.hpp"
-
- -cppad_ipopt_solution solution;
-
- -cppad_ipopt_nlp cppad_nlp(
-     
nmx_ix_lx_ug_lg_u, &fg_info, &solution
-)
- - -
-export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:
ipopt_library_paths
- - -
-
-Purpose -
-The class cppad_ipopt_nlp is used to solve nonlinear programming -problems of the form - - - -minimize - - -f -( -x -) - -subject - -to - - -g -l - - -g -( -x -) - -g -u - - - -x -l - - -x - -x -u - - - - -This is done using -Ipopt - -optimizer and -CppAD - -Algorithmic Differentiation package. - -
-
-cppad_ipopt namespace -
-All of the declarations for these routines -are in the cppad_ipopt namespace -(not the CppAD namespace). -For example; SizeVector - below -actually denotes the type cppad_ipopt::SizeVector. - -
-
-ipopt_library_paths -
-If you are linking to a shared version of the Ipopt library, -you may have to add some paths the LD_LIBRARY_PATH -shell variable using the export command in the syntax above. -For example, if the file the ipopt library is - -
-     
ipopt_prefix/lib64/libipopt.a
-
-you will need to add the corresponding directory; e.g., - -
-     export LD_LIBRARY_PATH="
ipopt_prefix/lib64:$LD_LIBRARY_PATH"
-
-see ipopt_prefix -. - -
-
-fg(x) -
-The function - -fg -: -R - -n - - -R - -m -+ -1 - - - - - is defined by - - - -fg -0 - -( -x -) - -= - -f -( -x -) - -fg -1 - -( -x -) - -= - -g -0 - -( -x -) - - - - - -fg -m - -( -x -) - -= - -g -m --1 - - -( -x -) - - - -
-Index Vector -
-We define an -index vector - as a vector of non-negative integers -for which none of the values are equal; i.e., -it is both a vector and a set. -If - -I - - - is an index vector - -| -I -| - - - is used to denote the -number of elements in - -I - - - and - - -I - - - - is used -to denote the value of the maximum element in - -I - - -. - -
-
-Projection -
-Given an index vector - -J - - - and a positive integer - -n - - - -where - -n -> - -J - - - -, we use - -J - -n - - - for -the mapping - -( -J - -n -) -: -R - -n - - -R - -| -J -| - - - - - defined by - - -[ -J - -n -] -( -x -) -j - -= -x -J -( -j -) - - - - -for - -j -= -0 -, - -| -J -| -- -1 - - -. - -
-
-Injection -
-Given an index vector - -I - - - and a positive integer - -m - - - -where - -m -> - -I - - - -, we use - -m - -I - - - for -the mapping - -( -m - -I -) -: -R - -| -I -| - - - -R - -m - - - - defined by - - -[ -m - -I -] -( -y -) -i - -= -{ -y -k - - -if - - -i -= -I -( -k -) - -for - -some - - -k - -{ -0 -, - -, -| -I -| --1 -} - -0 - -otherwise - - - - - -
-Representation -
-In many applications, each of the component functions of - -fg -( -x -) - - - -only depend on a few of the components of - -x - - -. -In this case, expressing - -fg -( -x -) - - - in terms of simpler functions -with fewer arguments can greatly reduce the amount of work required -to compute its derivatives. -
-
-
We use the functions - - -r -k - -: -R - -q -( -k -) - - - -R - -p -( -k -) - - - - - -for - -k -= -0 -, - -, -K - - - to express our -representation of - -fg -( -x -) - - - in terms of simpler functions -as follows - - -fg -( -x -) -= - -k -= -0 - -K --1 - - - - - -= -0 - -L -( -k -) -- -1 - - -[ -( -m -+ -1 -) - -I -k -, - - - -] - - - -r -k - - - - -[ -J -k -, - - - - -n -] - -( -x -) - - -where - - - - - represents function composition, -for - -k -= -0 -, - -, -K -- -1 - - -, and - - -= -0 -, - -, -L -( -k -) - - -, - - -I -k -, - - - - - - and - -J -k -, - - - - - - are index vectors with - - -| -J -k -, - - - -| -= -q -( -k -) - - -, - - - -J -k -, - - - - -< -n - - -, - - -| -I -k -, - - - -| -= -p -( -k -) - - -, and - - - -I -k -, - - - - - -m - - -. - -
-
-Simple Representation -
-In the simple representation, - - -r -0 - -( -x -) -= -fg -( -x -) - - -, - - -K -= -1 - - -, - - -q -( -0 -) -= -n - - -, - - -p -( -0 -) -= -m -+ -1 - - -, - - -L -( -0 -) -= -1 - - -, - - -I -0 -, -0 - - -= -( -0 -, - -, -m -) - - -, -and - -J -0 -, -0 - - -= -( -0 -, - -, -n --1 -) - - -. - -
-
-SizeVector -
-The type -SizeVector - is defined by the - -cppad_ipopt_nlp.hpp - include file to be a -SimpleVector - class with elements of type -size_t. - -
-
-NumberVector -
-The type -NumberVector - is defined by the - -cppad_ipopt_nlp.hpp - include file to be a -SimpleVector - class with elements of type -Ipopt::Number. - -
-
-ADNumber -
-The type -ADNumber - is defined by the - -cppad_ipopt_nlp.hpp - include file to be a -an AD type that can be used to compute derivatives. - -
-
-ADVector -
-The type -ADVector - is defined by the - -cppad_ipopt_nlp.hpp - include file to be a -SimpleVector - class with elements of type -ADNumber. - -
-
-n -
-The argument -n - has prototype - -
-     size_t 
n
-
-It specifies the dimension of the argument space; -i.e., - -x - -R - -n - - - -. - -
-
-m -
-The argument -m - has prototype - -
-     size_t 
m
-
-It specifies the dimension of the range space for - -g - - -; -i.e., - -g -: -R - -n - - -R - -m - - - -. - -
-
-x_i -
-The argument -x_i - has prototype - -
-     const NumberVector& 
x_i
-
-and its size is equal to - -n - - -. -It specifies the initial point where Ipopt starts the optimization process. - -
-
-x_l -
-The argument -x_l - has prototype - -
-     const NumberVector& 
x_l
-
-and its size is equal to - -n - - -. -It specifies the lower limits for the argument in the optimization problem; -i.e., - -x -l - - - -. - -
-
-x_u -
-The argument -x_u - has prototype - -
-     const NumberVector& 
x_u
-
-and its size is equal to - -n - - -. -It specifies the upper limits for the argument in the optimization problem; -i.e., - -x -u - - - -. - -
-
-g_l -
-The argument -g_l - has prototype - -
-     const NumberVector& 
g_l
-
-and its size is equal to - -m - - -. -It specifies the lower limits for the constraints in the optimization problem; -i.e., - -g -l - - - -. - -
-
-g_u -
-The argument -g_u - has prototype - -
-     const NumberVector& 
g_u
-
-and its size is equal to - -n - - -. -It specifies the upper limits for the constraints in the optimization problem; -i.e., - -g -u - - - -. - -
-
-fg_info -
-The argument -fg_info - has prototype - -
-     
FG_info fg_info
-
-where the class -FG_info - is derived from the -base class cppad_ipopt_fg_info. -Certain virtual member functions of -fg_info - are used to -compute the value of - -fg -( -x -) - - -. -The specifications for these member functions are given below: - -
-
-fg_info.number_functions -
-This member function has prototype - -
-     virtual size_t cppad_ipopt_fg_info::number_functions(void)
-
-If -K - has type size_t, the syntax - -
-     
K = fg_info.number_functions()
-
-sets -K - to the number of functions used in the -representation of - -fg -( -x -) - - -; i.e., - -K - - - in -the representation - above. -
-
-
The cppad_ipopt_fg_info implementation of this function -corresponds to the simple representation mentioned above; i.e. - -K = 1 -. - -
-
-fg_info.eval_r -
-This member function has the prototype - -
-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 -derived class -FG_info -. -
-
-
This function computes the value of - -r -k - -( -u -) - - - -used in the representation - -for - -fg -( -x -) - - -. -If -k - in - -{ -0 -, - -, -K --1 -} - - - has type size_t, - -u - is an ADVector of size -q(k) - -and -r - is an ADVector of size -p(k) - -the syntax - -
-     
r = fg_info.eval_r(ku)
-
-set -r - to the vector - -r -k - -( -u -) - - -. - -
-
-fg_info.retape -
-This member function has the prototype - -
-     virtual bool cppad_ipopt_fg_info::retape(size_t 
k)
-
-If -k - in - -{ -0 -, - -, -K --1 -} - - - has type size_t, -and -retape - has type bool, -the syntax - -
-        
retape = fg_info.retape(k)
-
-sets -retape - to true or false. -If -retape - is true, -cppad_ipopt_nlp will retape the operation sequence -corresponding to - -r -k - -( -u -) - - - for -every value of -u -. -An cppad_ipopt_nlp object -should use much less memory and run faster if -retape - is false. -You can test both the true and false cases to make sure -the operation sequence does not depend on -u -. -
-
-
The cppad_ipopt_fg_info implementation of this function -sets -retape - to true -(while slower it is also safer to always retape). - -
-
-fg_info.domain_size -
-This member function has prototype - -
-     virtual size_t cppad_ipopt_fg_info::domain_size(size_t 
k)
-
-If -k - in - -{ -0 -, - -, -K --1 -} - - - has type size_t, -and -q - has type size_t, the syntax - -
-     
q = fg_info.domain_size(k)
-
-sets -q - to the dimension of the domain space for - -r -k - -( -u -) - - -; -i.e., - -q -( -k -) - - - in -the representation - above. - -
-
-
The cppad_ipopt_h_base implementation of this function -corresponds to the simple representation mentioned above; i.e., - - -q -= -n - - -. - -
-
-fg_info.range_size -
-This member function has prototype - -
-     virtual size_t cppad_ipopt_fg_info::range_size(size_t 
k)
-
-If -k - in - -{ -0 -, - -, -K --1 -} - - - has type size_t, -and -p - has type size_t, the syntax - -
-     
p = fg_info.range_size(k)
-
-sets -p - to the dimension of the range space for - -r -k - -( -u -) - - -; -i.e., - -p -( -k -) - - - in -the representation - above. -
-
-
The cppad_ipopt_h_base implementation of this function -corresponds to the simple representation mentioned above; i.e., - - -p -= -m -+ -1 - - -. - -
-
-fg_info.number_terms -
-This member function has prototype - -
-     virtual size_t cppad_ipopt_fg_info::number_terms(size_t 
k)
-
-If -k - in - -{ -0 -, - -, -K --1 -} - - - has type size_t, -and -L - has type size_t, the syntax - -
-     
L = fg_info.number_terms(k)
-
-sets -L - to the number of terms in representation -for this value of -k -; -i.e., - -L -( -k -) - - - in -the representation - above. -
-
-
The cppad_ipopt_h_base implementation of this function -corresponds to the simple representation mentioned above; i.e., - - -L -= -1 - - -. - -
-
-fg_info.index -
-This member function has prototype - -
-     virtual void cppad_ipopt_fg_info::index(
-          size_t 
k, size_t ell, SizeVector& I, SizeVector& J
-     )
-
-The argument - -
-     k
-
-has type -size_t - -and is a value between zero and - -K --1 - - - inclusive. -The argument - -
-     ell
-
-has type -size_t - -and is a value between zero and - -L -( -k -) --1 - - - inclusive. -The argument - -
-     I
-
-is a SimpleVector - with elements -of type size_t and size greater than or equal to - -p -( -k -) - - -. -The input value of the elements of -I - does not matter. -The output value of -the first - -p -( -k -) - - - elements of -I - -must be the corresponding elements of - -I -k -, -ell - - - - - -in the representation - above. -The argument - -
-     J
-
-is a SimpleVector - with elements -of type size_t and size greater than or equal to - -q -( -k -) - - -. -The input value of the elements of -J - does not matter. -The output value of -the first - -q -( -k -) - - - elements of -J - -must be the corresponding elements of - -J -k -, -ell - - - - - -in the representation - above. -
-
-
The cppad_ipopt_h_base implementation of this function -corresponds to the simple representation mentioned above; i.e., -for - -i -= -0 -, - -, -m - - -, - -I[i] = i -, -and for - -j -= -0 -, - -, -n --1 - - -, - -J[j] = j -. - -
-
-solution -
-After the optimization process is completed, -solution - contains -the following information: - -
-
-status -
-The -status - field of -solution - has prototype - -
-     cppad_ipopt_solution::solution_status 
solution.status
-
-It is the final Ipopt status for the optimizer. -Here is a list of the possible values for the status: - - -
- - -status - - Meaning -
- -not_defined - -The optimizer did not return a final status to this cppad_ipopt_nlp -object. -
- -unknown - -The status returned by the optimizer is not defined in the Ipopt -documentation for finalize_solution. -
- -success - -Algorithm terminated successfully at a point satisfying the convergence -tolerances (see Ipopt options). -
- -maxiter_exceeded - -The maximum number of iterations was exceeded (see Ipopt options). -
- -stop_at_tiny_step - -Algorithm terminated because progress was very slow. -
- -stop_at_acceptable_point - -Algorithm stopped at a point that was converged, -not to the 'desired' tolerances, but to 'acceptable' tolerances -(see Ipopt options). -
- -local_infeasibility - -Algorithm converged to a non-feasible point -(problem may have no solution). -
- -user_requested_stop - -This return value should not happen. -
- -diverging_iterates - -It the iterates are diverging. -
- -restoration_failure - -Restoration phase failed, algorithm doesn't know how to proceed. -
- -error_in_step_computation - -An unrecoverable error occurred while Ipopt tried to -compute the search direction. -
- -invalid_number_detected - -Algorithm received an invalid number (such as nan or inf) -from the users function -fg_info.eval - or from the CppAD evaluations -of its derivatives -(see the Ipopt option check_derivatives_for_naninf). -
- -internal_error - -An unknown Ipopt internal error occurred. -Contact the Ipopt authors through the mailing list. -
-
-x -
-The x field of -solution - has prototype - -
-     NumberVector 
solution.x
-
-and its size is equal to - -n - - -. -It is the final - -x - - - value for the optimizer. - -
-
-z_l -
-The z_l field of -solution - has prototype - -
-     NumberVector 
solution.z_l
-
-and its size is equal to - -n - - -. -It is the final Lagrange multipliers for the -lower bounds on - -x - - -. - -
-
-z_u -
-The z_u field of -solution - has prototype - -
-     NumberVector 
solution.z_u
-
-and its size is equal to - -n - - -. -It is the final Lagrange multipliers for the -upper bounds on - -x - - -. - -
-
-g -
-The g field of -solution - has prototype - -
-     NumberVector 
solution.g
-
-and its size is equal to - -m - - -. -It is the final value for the constraint function - -g -( -x -) - - -. - -
-
-lambda -
-The lambda field of -solution - has prototype - -
-     NumberVector 
solution.lambda
-
-and its size is equal to - -m - - -. -It is the final value for the -Lagrange multipliers corresponding to the constraint function. - -
-
-obj_value -
-The obj_value field of -solution - has prototype - -
-     Number 
solution.obj_value
-
-It is the final value of the objective function - -f -( -x -) - - -. - - - - -
-
-Example -
-The file -ipopt_nlp_get_started.cpp - is an example and test of -cppad_ipopt_nlp that uses the -simple representation -. -It returns true if it succeeds and false otherwise. -The section ipopt_nlp_ode - discusses an example that -uses a more complex representation. - -
-
-Wish List -
-This is a list of possible future improvements to -cppad_ipopt_nlp that would require changed to the user interface: -
  1. -The routine -fg_info.eval_r(ku) - should also support - -NumberVector - for the type of the argument u -(this would certainly be more efficient when - -fg_info.retape(k) - is true and - -L -( -k -) -> -1 - - -). -It could be an option for the user to provide this as well as -the necessary ADVector definition. -
  2. - -There should a Discrete - routine that the user can call -to determine the value of - - - - - during the evaluation of - -fg_info.eval_r(ku) -. -This way data, which does not affect the derivative values, -can be included in the function recording and evaluation. -
- - - -
Input File: cppad_ipopt/src/cppad_ipopt_nlp.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_ipopt_nlp_xml.js cppad-2019.02.00.0/doc/_cppad_ipopt_nlp_xml.js --- cppad-2018.00.00.0/doc/_cppad_ipopt_nlp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_ipopt_nlp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'cppad_ipopt_nlp.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', -'directory.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', -'autotools.xml' -]; -var list_down0 = [ -'ipopt_nlp_get_started.cpp.xml', -'ipopt_nlp_ode.xml', -'ipopt_ode_speed.cpp.xml' -]; -var list_current0 = [ -'cppad_ipopt_nlp.xml#Deprecated 2012-11-28', -'cppad_ipopt_nlp.xml#Syntax', -'cppad_ipopt_nlp.xml#Purpose', -'cppad_ipopt_nlp.xml#cppad_ipopt namespace', -'cppad_ipopt_nlp.xml#ipopt_library_paths', -'cppad_ipopt_nlp.xml#fg(x)', -'cppad_ipopt_nlp.xml#fg(x).Index Vector', -'cppad_ipopt_nlp.xml#fg(x).Projection', -'cppad_ipopt_nlp.xml#fg(x).Injection', -'cppad_ipopt_nlp.xml#fg(x).Representation', -'cppad_ipopt_nlp.xml#Simple Representation', -'cppad_ipopt_nlp.xml#SizeVector', -'cppad_ipopt_nlp.xml#NumberVector', -'cppad_ipopt_nlp.xml#ADNumber', -'cppad_ipopt_nlp.xml#ADVector', -'cppad_ipopt_nlp.xml#n', -'cppad_ipopt_nlp.xml#m', -'cppad_ipopt_nlp.xml#x_i', -'cppad_ipopt_nlp.xml#x_l', -'cppad_ipopt_nlp.xml#x_u', -'cppad_ipopt_nlp.xml#g_l', -'cppad_ipopt_nlp.xml#g_u', -'cppad_ipopt_nlp.xml#fg_info', -'cppad_ipopt_nlp.xml#fg_info.fg_info.number_functions', -'cppad_ipopt_nlp.xml#fg_info.fg_info.eval_r', -'cppad_ipopt_nlp.xml#fg_info.fg_info.retape', -'cppad_ipopt_nlp.xml#fg_info.fg_info.domain_size', -'cppad_ipopt_nlp.xml#fg_info.fg_info.range_size', -'cppad_ipopt_nlp.xml#fg_info.fg_info.number_terms', -'cppad_ipopt_nlp.xml#fg_info.fg_info.index', -'cppad_ipopt_nlp.xml#solution', -'cppad_ipopt_nlp.xml#solution.status', -'cppad_ipopt_nlp.xml#solution.x', -'cppad_ipopt_nlp.xml#solution.z_l', -'cppad_ipopt_nlp.xml#solution.z_u', -'cppad_ipopt_nlp.xml#solution.g', -'cppad_ipopt_nlp.xml#solution.lambda', -'cppad_ipopt_nlp.xml#solution.obj_value', -'cppad_ipopt_nlp.xml#Example', -'cppad_ipopt_nlp.xml#Wish List' -]; -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-2018.00.00.0/doc/cppad_mat_mul.cpp.xml cppad-2019.02.00.0/doc/cppad_mat_mul.cpp.xml --- cppad-2018.00.00.0/doc/cppad_mat_mul.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_mat_mul.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,260 +0,0 @@ - - - -CppAD Speed, Matrix Multiplication - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cppad_mat_mul.cpp - -

-
CppAD Speed, Matrix Multiplication
-
-Specifications -
-See link_mat_mul -. - -
-
-Implementation - - -
# include <cppad/cppad.hpp>
-# include <cppad/speed/mat_sum_sq.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/example/mat_mul.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_mat_mul(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     CppAD::vector<double>&           x        ,
-     CppAD::vector<double>&           z        ,
-     CppAD::vector<double>&           dz
-)
-{
-     // --------------------------------------------------------------------
-     // check global options
-     const char* valid[] = { "memory", "onetape", "optimize", "atomic"};
-     size_t n_valid = sizeof(valid) / sizeof(valid[0]);
-     typedef std::map<std::string, bool>::iterator iterator;
-     //
-     for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr)
-     {     if( itr->second )
-          {     bool ok = false;
-               for(size_t i = 0; i < n_valid; i++)
-                    ok |= itr->first == valid[i];
-               if( ! ok )
-                    return false;
-          }
-     }
-     // --------------------------------------------------------------------
-     // optimization options: no conditional skips or compare operators
-     std::string options="no_compare_op";
-     // -----------------------------------------------------
-     // setup
-     typedef CppAD::AD<double>           ADScalar;
-     typedef CppAD::vector<ADScalar>     ADVector;
-
-     size_t j;               // temporary index
-     size_t m = 1;           // number of dependent variables
-     size_t n = size * size; // number of independent variables
-     ADVector   X(n);        // AD domain space vector
-     ADVector   Y(n);        // Store product matrix
-     ADVector   Z(m);        // AD range space vector
-     CppAD::ADFun<double> f; // AD function object
-
-     // vectors of reverse mode weights
-     CppAD::vector<double> w(1);
-     w[0] = 1.;
-
-     // user atomic information
-     CppAD::vector<ADScalar> ax(3 + 2 * n), ay(n);
-     atomic_mat_mul atom_mul;
-     //
-     if( global_option["boolsparsity"] )
-          atom_mul.option( CppAD::atomic_base<double>::pack_sparsity_enum );
-     else
-          atom_mul.option( CppAD::atomic_base<double>::set_sparsity_enum );
-     // ------------------------------------------------------
-     if( ! global_option["onetape"] ) while(repeat--)
-     {     // get the next matrix
-          CppAD::uniform_01(n, x);
-          for( j = 0; j < n; j++)
-               X[j] = x[j];
-
-          // declare independent variables
-          Independent(X);
-
-          // do computations
-          if( ! global_option["atomic"] )
-               mat_sum_sq(size, X, Y, Z);
-          else
-          {     ax[0] = ADScalar( size ); // number of rows in left matrix
-               ax[1] = ADScalar( size ); // rows in left and columns in right
-               ax[2] = ADScalar( size ); // number of columns in right matrix
-               for(j = 0; j < n; j++)
-               {     ax[3 + j]     = X[j];
-                    ax[3 + n + j] = X[j];
-               }
-               // Y = X * X
-               atom_mul(ax, ay);
-               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_option["optimize"] )
-               f.optimize(options);
-
-          // 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);
-     }
-     else
-     {     // get a next matrix
-          CppAD::uniform_01(n, x);
-          for(j = 0; j < n; j++)
-               X[j] = x[j];
-
-          // declare independent variables
-          Independent(X);
-
-          // do computations
-          if( ! global_option["atomic"] )
-               mat_sum_sq(size, X, Y, Z);
-          else
-          {     for(j = 0; j < n; j++)
-               {     ax[j]   = X[j];
-                    ax[j+n] = X[j];
-               }
-               // Y = X * X
-               atom_mul(ax, ay);
-               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_option["optimize"] )
-               f.optimize(options);
-
-          // skip comparison operators
-          f.compare_change_count(0);
-
-          while(repeat--)
-          {     // get a next matrix
-               CppAD::uniform_01(n, x);
-
-               // evaluate and return gradient using reverse mode
-               z  = f.Forward(0, x);
-               dz = f.Reverse(1, w);
-          }
-     }
-     // --------------------------------------------------------------------
-     // Free temporary work space (any future atomic_mat_mul constructors
-     // would create new temporary work space.)
-     CppAD::user_atomic<double>::clear();
-
-     return true;
-}
- -
Input File: speed/cppad/mat_mul.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_mat_mul.cpp_xml.js cppad-2019.02.00.0/doc/_cppad_mat_mul.cpp_xml.js --- cppad-2018.00.00.0/doc/_cppad_mat_mul.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_mat_mul.cpp_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', -'speed.xml', -'speed_cppad.xml', -'cppad_mat_mul.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'cppad_det_minor.cpp.xml', -'cppad_det_lu.cpp.xml', -'cppad_mat_mul.cpp.xml', -'cppad_ode.cpp.xml', -'cppad_poly.cpp.xml', -'cppad_sparse_hessian.cpp.xml', -'cppad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'cppad_mat_mul.cpp.xml#Specifications', -'cppad_mat_mul.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/cppad_ode.cpp.xml cppad-2019.02.00.0/doc/cppad_ode.cpp.xml --- cppad-2018.00.00.0/doc/cppad_ode.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_ode.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,215 +0,0 @@ - - - -CppAD Speed: Gradient of Ode Solution - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cppad_ode.cpp - -

-
CppAD Speed: Gradient of Ode Solution
-
-Specifications -
-See link_ode -. - -
-
-Implementation - - -
# include <cppad/cppad.hpp>
-# include <cppad/speed/ode_evaluate.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cassert>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_ode(
-     size_t                     size       ,
-     size_t                     repeat     ,
-     CppAD::vector<double>      &x         ,
-     CppAD::vector<double>      &jacobian
-)
-{
-     // --------------------------------------------------------------------
-     // check global options
-     const char* valid[] = { "memory", "onetape", "optimize"};
-     size_t n_valid = sizeof(valid) / sizeof(valid[0]);
-     typedef std::map<std::string, bool>::iterator iterator;
-     //
-     for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr)
-     {     if( itr->second )
-          {     bool ok = false;
-               for(size_t i = 0; i < n_valid; i++)
-                    ok |= itr->first == valid[i];
-               if( ! ok )
-                    return false;
-          }
-     }
-     // --------------------------------------------------------------------
-     // optimization options: no conditional skips or compare operators
-     std::string options="no_compare_op";
-     // --------------------------------------------------------------------
-     // setup
-     assert( x.size() == size );
-     assert( jacobian.size() == size * size );
-
-     typedef CppAD::AD<double>       ADScalar;
-     typedef CppAD::vector<ADScalar> ADVector;
-
-     size_t j;
-     size_t p = 0;              // use ode to calculate function values
-     size_t n = size;           // number of independent variables
-     size_t m = n;              // number of dependent variables
-     ADVector  X(n), Y(m);      // independent and dependent variables
-     CppAD::ADFun<double>  f;   // AD function
-
-     // -------------------------------------------------------------
-     if( ! global_option["onetape"] ) while(repeat--)
-     {     // choose next x value
-          uniform_01(n, x);
-          for(j = 0; j < n; j++)
-               X[j] = x[j];
-
-          // declare the independent variable vector
-          Independent(X);
-
-          // evaluate function
-          CppAD::ode_evaluate(X, p, Y);
-
-          // create function object f : X -> Y
-          f.Dependent(X, Y);
-
-          if( global_option["optimize"] )
-               f.optimize(options);
-
-          // skip comparison operators
-          f.compare_change_count(0);
-
-          jacobian = f.Jacobian(x);
-     }
-     else
-     {     // an x value
-          uniform_01(n, x);
-          for(j = 0; j < n; j++)
-               X[j] = x[j];
-
-          // declare the independent variable vector
-          Independent(X);
-
-          // evaluate function
-          CppAD::ode_evaluate(X, p, Y);
-
-          // create function object f : X -> Y
-          f.Dependent(X, Y);
-
-          if( global_option["optimize"] )
-               f.optimize(options);
-
-          // skip comparison operators
-          f.compare_change_count(0);
-
-          while(repeat--)
-          {     // get next argument value
-               uniform_01(n, x);
-
-               // evaluate jacobian
-               jacobian = f.Jacobian(x);
-          }
-     }
-     return true;
-}
- -
Input File: speed/cppad/ode.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_ode.cpp_xml.js cppad-2019.02.00.0/doc/_cppad_ode.cpp_xml.js --- cppad-2018.00.00.0/doc/_cppad_ode.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_ode.cpp_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', -'speed.xml', -'speed_cppad.xml', -'cppad_ode.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'cppad_det_minor.cpp.xml', -'cppad_det_lu.cpp.xml', -'cppad_mat_mul.cpp.xml', -'cppad_ode.cpp.xml', -'cppad_poly.cpp.xml', -'cppad_sparse_hessian.cpp.xml', -'cppad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'cppad_ode.cpp.xml#Specifications', -'cppad_ode.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/cppad_poly.cpp.xml cppad-2019.02.00.0/doc/cppad_poly.cpp.xml --- cppad-2018.00.00.0/doc/cppad_poly.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_poly.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,245 +0,0 @@ - - - -CppAD Speed: Second Derivative of a Polynomial - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cppad_poly.cpp - -

-
CppAD Speed: Second Derivative of a Polynomial
-
-Specifications -
-See link_poly -. - -
-
-Implementation - - -
# include <cppad/cppad.hpp>
-# include <cppad/speed/uniform_01.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_poly(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &a        ,  // coefficients of polynomial
-     CppAD::vector<double>     &z        ,  // polynomial argument value
-     CppAD::vector<double>     &ddp      )  // second derivative w.r.t z
-{
-     // --------------------------------------------------------------------
-     // check global options
-     const char* valid[] = { "memory", "onetape", "optimize"};
-     size_t n_valid = sizeof(valid) / sizeof(valid[0]);
-     typedef std::map<std::string, bool>::iterator iterator;
-     //
-     for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr)
-     {     if( itr->second )
-          {     bool ok = false;
-               for(size_t i = 0; i < n_valid; i++)
-                    ok |= itr->first == valid[i];
-               if( ! ok )
-                    return false;
-          }
-     }
-     // --------------------------------------------------------------------
-     // optimization options: no conditional skips or compare operators
-     std::string options="no_compare_op";
-     // -----------------------------------------------------
-     // setup
-     typedef CppAD::AD<double>     ADScalar;
-     typedef CppAD::vector<ADScalar> ADVector;
-
-     size_t i;      // temporary index
-     size_t m = 1;  // number of dependent variables
-     size_t n = 1;  // number of independent variables
-     ADVector Z(n); // AD domain space vector
-     ADVector P(m); // AD range space vector
-
-     // choose the polynomial coefficients
-     CppAD::uniform_01(size, a);
-
-     // AD copy of the polynomial coefficients
-     ADVector A(size);
-     for(i = 0; i < size; i++)
-          A[i] = a[i];
-
-     // forward mode first and second differentials
-     CppAD::vector<double> p(1), dp(1), dz(1), ddz(1);
-     dz[0]  = 1.;
-     ddz[0] = 0.;
-
-     // AD function object
-     CppAD::ADFun<double> f;
-
-     // --------------------------------------------------------------------
-     if( ! global_option["onetape"] ) while(repeat--)
-     {
-          // choose an argument value
-          CppAD::uniform_01(1, z);
-          Z[0] = z[0];
-
-          // declare independent variables
-          Independent(Z);
-
-          // AD computation of the function value
-          P[0] = CppAD::Poly(0, A, Z[0]);
-
-          // create function object f : A -> detA
-          f.Dependent(Z, P);
-
-          if( global_option["optimize"] )
-               f.optimize(options);
-
-          // skip comparison operators
-          f.compare_change_count(0);
-
-          // pre-allocate memory for three forward mode calculations
-          f.capacity_order(3);
-
-          // evaluate the polynomial
-          p = f.Forward(0, z);
-
-          // evaluate first order Taylor coefficient
-          dp = f.Forward(1, dz);
-
-          // second derivative is twice second order Taylor coef
-          ddp     = f.Forward(2, ddz);
-          ddp[0] *= 2.;
-     }
-     else
-     {
-          // choose an argument value
-          CppAD::uniform_01(1, z);
-          Z[0] = z[0];
-
-          // declare independent variables
-          Independent(Z);
-
-          // AD computation of the function value
-          P[0] = CppAD::Poly(0, A, Z[0]);
-
-          // create function object f : A -> detA
-          f.Dependent(Z, P);
-
-          if( global_option["optimize"] )
-               f.optimize(options);
-
-          // skip comparison operators
-          f.compare_change_count(0);
-
-          while(repeat--)
-          {     // sufficient memory is allocated by second repetition
-
-               // get the next argument value
-               CppAD::uniform_01(1, z);
-
-               // evaluate the polynomial at the new argument value
-               p = f.Forward(0, z);
-
-               // evaluate first order Taylor coefficient
-               dp = f.Forward(1, dz);
-
-               // second derivative is twice second order Taylor coef
-               ddp     = f.Forward(2, ddz);
-               ddp[0] *= 2.;
-          }
-     }
-     return true;
-}
- -
Input File: speed/cppad/poly.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_poly.cpp_xml.js cppad-2019.02.00.0/doc/_cppad_poly.cpp_xml.js --- cppad-2018.00.00.0/doc/_cppad_poly.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_poly.cpp_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', -'speed.xml', -'speed_cppad.xml', -'cppad_poly.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'cppad_det_minor.cpp.xml', -'cppad_det_lu.cpp.xml', -'cppad_mat_mul.cpp.xml', -'cppad_ode.cpp.xml', -'cppad_poly.cpp.xml', -'cppad_sparse_hessian.cpp.xml', -'cppad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'cppad_poly.cpp.xml#Specifications', -'cppad_poly.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/cppad_sparse_hessian.cpp.xml cppad-2019.02.00.0/doc/cppad_sparse_hessian.cpp.xml --- cppad-2018.00.00.0/doc/cppad_sparse_hessian.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_sparse_hessian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,450 +0,0 @@ - - - -CppAD Speed: Sparse Hessian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cppad_sparse_hessian.cpp - -

-
CppAD Speed: Sparse Hessian
-
-Specifications -
-See link_sparse_hessian -. - -
-
-Implementation - - -
# include <cppad/cppad.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/speed/sparse_hes_fun.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-namespace {
-     // typedefs
-     using CppAD::vector;
-     typedef CppAD::AD<double>                     a1double;
-     typedef CppAD::AD<a1double>                   a2double;
-     typedef vector<bool>                          b_vector;
-     typedef vector<size_t>                        s_vector;
-     typedef vector<double>                        d_vector;
-     typedef vector<a1double>                      a1vector;
-     typedef vector<a2double>                      a2vector;
-     typedef CppAD::sparse_rc<s_vector>            sparsity_pattern;
-     typedef CppAD::sparse_rcv<s_vector, d_vector> sparse_matrix;
-     // ------------------------------------------------------------------------
-     void create_fun(
-          const d_vector&             x        ,
-          const s_vector&             row      ,
-          const s_vector&             col      ,
-          CppAD::ADFun<double>&       fun      )
-     {
-          // initialize a1double version of independent variables
-          size_t n = x.size();
-          a1vector a1x(n);
-          for(size_t j = 0; j < n; j++)
-               a1x[j] = x[j];
-          //
-          // optimization options
-          std::string optimize_options="no_compare_op";
-          //
-          // order of derivative in sparse_hes_fun
-          size_t order = 0;
-          //
-          if( ! global_option["hes2jac"] )
-          {
-               // declare independent variables
-               Independent(a1x);
-               //
-               // AD computation of y
-               a1vector a1y(1);
-               CppAD::sparse_hes_fun<a1double>(n, a1x, row, col, order, a1y);
-               //
-               // create function object f : X -> Y
-               fun.Dependent(a1x, a1y);
-               //
-               if( global_option["optimize"] )
-                    fun.optimize(optimize_options);
-               //
-               // skip comparison operators
-               fun.compare_change_count(0);
-               //
-               // fun corresonds to f(x)
-               return;
-          }
-          // declare independent variables for f(x)
-          a2vector a2x(n);
-          for(size_t j = 0; j < n; j++)
-               a2x[j] = a1x[j];
-          Independent(a2x);
-          //
-          // a2double computation of y
-          a2vector a2y(1);
-          CppAD::sparse_hes_fun<a2double>(n, a2x, row, col, order, a2y);
-          //
-          // create function object corresponding to y = f(x)
-          CppAD::ADFun<a1double> a1f;
-          a1f.Dependent(a2x, a2y);
-          //
-          // declare independent variables for g(x)
-          Independent(a1x);
-          //
-          // a1double computation of z
-          a1vector a1w(1), a1z(n);
-          a1w[0] = 1.0;
-          a1f.Forward(0, a1x);
-          a1z = a1f.Reverse(1, a1w);
-          //
-          // create function object z = g(x) = f'(x)
-          fun.Dependent(a1x, a1z);
-          //
-          if( global_option["optimize"] )
-               fun.optimize(optimize_options);
-          //
-          // skip comparison operators
-          fun.compare_change_count(0);
-          //
-          // fun corresonds to g(x)
-          return;
-     }
-     // ------------------------------------------------------------------------
-     void calc_sparsity(
-          sparsity_pattern&      sparsity ,
-          CppAD::ADFun<double>&  fun      )
-     {
-          size_t n = fun.Domain();
-          size_t m = fun.Range();
-          //
-          bool transpose     = false;
-          //
-          if( global_option["subsparsity"] )
-          {     CPPAD_ASSERT_UNKNOWN( global_option["hes2jac"] )
-               CPPAD_ASSERT_UNKNOWN( n == m );
-               b_vector select_domain(n), select_range(m);
-               for(size_t j = 0; j < n; ++j)
-                    select_domain[j] = true;
-               for(size_t i = 0; i < m; ++i)
-                    select_range[i] = true;
-               //
-               // fun corresponds to g(x)
-               fun.subgraph_sparsity(
-                    select_domain, select_range, transpose, sparsity
-               );
-               return;
-          }
-          bool dependency    = false;
-          bool reverse       = global_option["revsparsity"];
-          bool internal_bool = global_option["boolsparsity"];
-          //
-          if( ! global_option["hes2jac"] )
-          {     // fun corresponds to f(x)
-               //
-               CPPAD_ASSERT_UNKNOWN( m == 1 );
-               //
-               b_vector select_range(m);
-               select_range[0] = true;
-               //
-               if( reverse )
-               {     sparsity_pattern identity;
-                    identity.resize(n, n, n);
-                    for(size_t k = 0; k < n; k++)
-                         identity.set(k, k, k);
-                    fun.for_jac_sparsity(
-                         identity, transpose, dependency, internal_bool, sparsity
-                    );
-                    fun.rev_hes_sparsity(
-                         select_range, transpose, internal_bool, sparsity
-                    );
-               }
-               else
-               {     b_vector select_domain(n);
-                    for(size_t j = 0; j < n; j++)
-                         select_domain[j] = true;
-                    fun.for_hes_sparsity(
-                         select_domain, select_range, internal_bool, sparsity
-                    );
-               }
-               return;
-          }
-          // fun correspnds to g(x)
-          CPPAD_ASSERT_UNKNOWN( m == n );
-          //
-          // sparsity pattern for identity matrix
-          sparsity_pattern eye;
-          eye.resize(n, n, n);
-          for(size_t k = 0; k < n; k++)
-               eye.set(k, k, k);
-          //
-          if( reverse )
-          {     fun.rev_jac_sparsity(
-                    eye, transpose, dependency, internal_bool, sparsity
-               );
-          }
-          else
-          {     fun.for_jac_sparsity(
-                    eye, transpose, dependency, internal_bool, sparsity
-               );
-          }
-          return;
-     }
-     // ------------------------------------------------------------------------
-     size_t calc_hessian(
-          d_vector&               hessian  ,
-          const d_vector&         x        ,
-          sparse_matrix&          subset   ,
-          const sparsity_pattern& sparsity ,
-          CppAD::sparse_jac_work& jac_work ,
-          CppAD::sparse_hes_work& hes_work ,
-          CppAD::ADFun<double>&   fun      )
-     {     size_t n_sweep;
-          //
-          if( ! global_option["hes2jac"] )
-          {     // fun corresponds to f(x)
-               //
-               // coloring method
-               std::string coloring = "cppad.symmetric";
-# if CPPAD_HAS_COLPACK
-               if( global_option["colpack"] )
-                    coloring = "colpack.symmetric";
-# endif
-               // only one function component
-               d_vector w(1);
-               w[0] = 1.0;
-               //
-               // compute hessian
-               n_sweep = fun.sparse_hes(
-                    x, w, subset, sparsity, coloring, hes_work
-               );
-          }
-          else
-          {     // fun corresponds to g(x)
-               //
-               if( global_option["subgraph"] )
-               {     fun.subgraph_jac_rev(x, subset);
-                    n_sweep = 0;
-               }
-               else
-               {
-                    //
-                    // coloring method
-                    std::string coloring = "cppad";
-# if CPPAD_HAS_COLPACK
-                    if( global_option["colpack"] )
-                         coloring = "colpack";
-# endif
-                    size_t group_max = 1;
-                    n_sweep = fun.sparse_jac_for(
-                         group_max, x, subset, sparsity, coloring, jac_work
-                    );
-               }
-          }
-          // return result
-          const d_vector& val( subset.val() );
-          size_t nnz = subset.nnz();
-          for(size_t k = 0; k < nnz; k++)
-               hessian[k] = val[k];
-          //
-          return n_sweep;
-     }
-}
-
-bool link_sparse_hessian(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     const CppAD::vector<size_t>&     row      ,
-     const CppAD::vector<size_t>&     col      ,
-     CppAD::vector<double>&           x        ,
-     CppAD::vector<double>&           hessian  ,
-     size_t&                          n_sweep  )
-{
-     // --------------------------------------------------------------------
-     // check global options
-     const char* valid[] = {
-          "memory", "onetape", "optimize", "hes2jac", "subgraph",
-# if CPPAD_HAS_COLPACK
-          "boolsparsity", "revsparsity", "subsparsity", "colpack"
-# else
-          "boolsparsity", "revsparsity"
-# endif
-     };
-     size_t n_valid = sizeof(valid) / sizeof(valid[0]);
-     typedef std::map<std::string, bool>::iterator iterator;
-     //
-     for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr)
-     {     if( itr->second )
-          {     bool ok = false;
-               for(size_t i = 0; i < n_valid; i++)
-                    ok |= itr->first == valid[i];
-               if( ! ok )
-                    return false;
-          }
-     }
-     if( global_option["subsparsity"] )
-     {     if( global_option["boolsparsity"] || global_option["revsparsity"] )
-               return false;
-          if( ! global_option["hes2jac"] )
-               return false;
-     }
-     if( global_option["subgraph"] )
-     {     if( ! global_option["hes2jac"] )
-               return false;
-     }
-     // -----------------------------------------------------------------------
-     // setup
-     size_t n = size;          // number of independent variables
-     CppAD::ADFun<double> fun; // AD function object used to calculate Hessian
-     //
-     // declare sparsity pattern
-     sparsity_pattern sparsity;
-     //
-     // declare subset where Hessian is evaluated
-     sparsity_pattern subset_pattern;
-     size_t nr  = n;
-     size_t nc  = n;
-     size_t nnz = row.size();
-     subset_pattern.resize(nr, nc, nnz);
-     for(size_t k = 0; k < nnz; k++)
-          subset_pattern.set(k, row[k], col[k]);
-     sparse_matrix subset( subset_pattern );
-     //
-     // structures that holds some of the work done by sparse_jac, sparse_hes
-     CppAD::sparse_jac_work jac_work;
-     CppAD::sparse_hes_work hes_work;
-
-     // -----------------------------------------------------------------------
-     if( ! global_option["onetape"] ) while(repeat--)
-     {     // choose a value for x
-          CppAD::uniform_01(n, x);
-          //
-          // create f(x)
-          create_fun(x, row, col, fun);
-          //
-          // calculate the sparsity pattern for Hessian of f(x)
-          calc_sparsity(sparsity, fun);
-          //
-          // calculate the Hessian at this x
-          jac_work.clear(); // wihtout work from previous calculation
-          hes_work.clear();
-          n_sweep = calc_hessian(
-               hessian, x, subset, sparsity, jac_work, hes_work, fun
-          );
-     }
-     else
-     {     // choose a value for x
-          CppAD::uniform_01(n, x);
-          //
-          // create f(x)
-          create_fun(x, row, col, fun);
-          //
-          // calculate the sparsity pattern for Hessian of f(x)
-          calc_sparsity(sparsity, fun);
-          //
-          while(repeat--)
-          {     // choose a value for x
-               CppAD::uniform_01(n, x);
-               //
-               // calculate this Hessian at this x
-               n_sweep = calc_hessian(
-                    hessian, x, subset, sparsity, jac_work, hes_work, fun
-               );
-          }
-     }
-     return true;
-}
- -
Input File: speed/cppad/sparse_hessian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_sparse_hessian.cpp_xml.js cppad-2019.02.00.0/doc/_cppad_sparse_hessian.cpp_xml.js --- cppad-2018.00.00.0/doc/_cppad_sparse_hessian.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_sparse_hessian.cpp_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', -'speed.xml', -'speed_cppad.xml', -'cppad_sparse_hessian.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'cppad_det_minor.cpp.xml', -'cppad_det_lu.cpp.xml', -'cppad_mat_mul.cpp.xml', -'cppad_ode.cpp.xml', -'cppad_poly.cpp.xml', -'cppad_sparse_hessian.cpp.xml', -'cppad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'cppad_sparse_hessian.cpp.xml#Specifications', -'cppad_sparse_hessian.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/cppad_sparse_jacobian.cpp.xml cppad-2019.02.00.0/doc/cppad_sparse_jacobian.cpp.xml --- cppad-2018.00.00.0/doc/cppad_sparse_jacobian.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_sparse_jacobian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,334 +0,0 @@ - - - -CppAD Speed: Sparse Jacobian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cppad_sparse_jacobian.cpp - -

-
CppAD Speed: Sparse Jacobian
-
-Specifications -
-See link_sparse_jacobian -. - -
-
-Implementation - - -
# include <cppad/cppad.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/speed/sparse_jac_fun.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-namespace {
-     using CppAD::vector;
-     typedef vector<size_t>  s_vector;
-     typedef vector<bool>    b_vector;
-
-     void calc_sparsity(
-          CppAD::sparse_rc<s_vector>& sparsity ,
-          CppAD::ADFun<double>&       f        )
-     {     bool reverse       = global_option["revsparsity"];
-          bool transpose     = false;
-          bool internal_bool = global_option["boolsparsity"];
-          bool dependency    = false;
-          bool subgraph      = global_option["subsparsity"];
-          size_t n = f.Domain();
-          size_t m = f.Range();
-          if( subgraph )
-          {     b_vector select_domain(n), select_range(m);
-               for(size_t j = 0; j < n; ++j)
-                    select_domain[j] = true;
-               for(size_t i = 0; i < m; ++i)
-                    select_range[i] = true;
-               f.subgraph_sparsity(
-                    select_domain, select_range, transpose, sparsity
-               );
-          }
-          else
-          {     size_t q = n;
-               if( reverse )
-                    q = m;
-               //
-               CppAD::sparse_rc<s_vector> identity;
-               identity.resize(q, q, q);
-               for(size_t k = 0; k < q; k++)
-                    identity.set(k, k, k);
-               //
-               if( reverse )
-               {     f.rev_jac_sparsity(
-                         identity, transpose, dependency, internal_bool, sparsity
-                    );
-               }
-               else
-               {     f.for_jac_sparsity(
-                         identity, transpose, dependency, internal_bool, sparsity
-                    );
-               }
-          }
-     }
-}
-
-bool link_sparse_jacobian(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     size_t                           m        ,
-     const CppAD::vector<size_t>&     row      ,
-     const CppAD::vector<size_t>&     col      ,
-           CppAD::vector<double>&     x        ,
-           CppAD::vector<double>&     jacobian ,
-           size_t&                    n_sweep  )
-{
-     // --------------------------------------------------------------------
-     // check global options
-     const char* valid[] = {
-          "memory", "onetape", "optimize", "subgraph",
-# if CPPAD_HAS_COLPACK
-          "boolsparsity", "revsparsity", "subsparsity", "colpack"
-# else
-          "boolsparsity", "revsparsity", "subsparsity"
-# endif
-     };
-     size_t n_valid = sizeof(valid) / sizeof(valid[0]);
-     typedef std::map<std::string, bool>::iterator iterator;
-     //
-     for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr)
-     {     if( itr->second )
-          {     bool ok = false;
-               for(size_t i = 0; i < n_valid; i++)
-                    ok |= itr->first == valid[i];
-               if( ! ok )
-                    return false;
-          }
-     }
-     if( global_option["subsparsity"] )
-     {     if( global_option["boolsparisty"] || global_option["revsparsity"] )
-               return false;
-     }
-     // ---------------------------------------------------------------------
-     // optimization options: no conditional skips or compare operators
-     std::string options="no_compare_op";
-     // -----------------------------------------------------
-     // setup
-     typedef CppAD::AD<double>    a_double;
-     typedef vector<double>       d_vector;
-     typedef vector<a_double>     ad_vector;
-     //
-     size_t order = 0;         // derivative order corresponding to function
-     size_t n     = size;      // number of independent variables
-     ad_vector  a_x(n);        // AD domain space vector
-     ad_vector  a_y(m);        // AD range space vector y = f(x)
-     CppAD::ADFun<double> f;   // AD function object
-     //
-     // declare sparsity pattern
-     CppAD::sparse_rc<s_vector>  sparsity;
-     //
-     // declare subset where Jacobian is evaluated
-     CppAD::sparse_rc<s_vector> subset_pattern;
-     size_t nr  = m;
-     size_t nc  = n;
-     size_t nnz = row.size();
-     subset_pattern.resize(nr, nc, nnz);
-     for(size_t k = 0; k < nnz; k++)
-          subset_pattern.set(k, row[k], col[k]);
-     CppAD::sparse_rcv<s_vector, d_vector> subset( subset_pattern );
-     const d_vector& subset_val( subset.val() );
-     //
-     // coloring method
-     std::string coloring = "cppad";
-# if CPPAD_HAS_COLPACK
-     if( global_option["colpack"] )
-          coloring = "colpack";
-# endif
-     //
-     // maximum number of colors at once
-     size_t group_max = 25;
-     // ------------------------------------------------------
-     if( ! global_option["onetape"] ) while(repeat--)
-     {     // choose a value for x
-          CppAD::uniform_01(n, x);
-          for(size_t j = 0; j < n; j++)
-               a_x[j] = x[j];
-          //
-          // declare independent variables
-          Independent(a_x);
-          //
-          // AD computation of f(x)
-          CppAD::sparse_jac_fun<a_double>(m, n, a_x, row, col, order, a_y);
-          //
-          // create function object f : X -> Y
-          f.Dependent(a_x, a_y);
-          //
-          if( global_option["optimize"] )
-               f.optimize(options);
-          //
-          // skip comparison operators
-          f.compare_change_count(0);
-          //
-          // calculate the Jacobian sparsity pattern for this function
-          calc_sparsity(sparsity, f);
-          //
-          if( global_option["subgraph"] )
-          {     // user reverse mode becasue forward not yet implemented
-               f.subgraph_jac_rev(x, subset);
-               n_sweep = 0;
-          }
-          else
-          {     // structure that holds some of the work done by sparse_jac_for
-               CppAD::sparse_jac_work work;
-               //
-               // calculate the Jacobian at this x
-               // (use forward mode because m > n ?)
-               n_sweep = f.sparse_jac_for(
-                    group_max, x, subset, sparsity, coloring, work
-               );
-          }
-          for(size_t k = 0; k < nnz; k++)
-               jacobian[k] = subset_val[k];
-     }
-     else
-     {     // choose a value for x
-          CppAD::uniform_01(n, x);
-          for(size_t j = 0; j < n; j++)
-               a_x[j] = x[j];
-          //
-          // declare independent variables
-          Independent(a_x);
-          //
-          // AD computation of f(x)
-          CppAD::sparse_jac_fun<a_double>(m, n, a_x, row, col, order, a_y);
-          //
-          // create function object f : X -> Y
-          f.Dependent(a_x, a_y);
-          //
-          if( global_option["optimize"] )
-               f.optimize(options);
-          //
-          // skip comparison operators
-          f.compare_change_count(0);
-          //
-          // calculate the Jacobian sparsity pattern for this function
-          calc_sparsity(sparsity, f);
-          //
-          // structure that holds some of the work done by sparse_jac_for
-          CppAD::sparse_jac_work work;
-          //
-          while(repeat--)
-          {     // choose a value for x
-               CppAD::uniform_01(n, x);
-               //
-               // calculate the Jacobian at this x
-               if( global_option["subgraph"] )
-               {     // user reverse mode becasue forward not yet implemented
-                    f.subgraph_jac_rev(x, subset);
-                    n_sweep = 0;
-               }
-               else
-               {     // (use forward mode because m > n ?)
-                    n_sweep = f.sparse_jac_for(
-                         group_max, x, subset, sparsity, coloring, work
-                    );
-               }
-               for(size_t k = 0; k < nnz; k++)
-                    jacobian[k] = subset_val[k];
-          }
-     }
-     return true;
-}
- -
Input File: speed/cppad/sparse_jacobian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_sparse_jacobian.cpp_xml.js cppad-2019.02.00.0/doc/_cppad_sparse_jacobian.cpp_xml.js --- cppad-2018.00.00.0/doc/_cppad_sparse_jacobian.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_sparse_jacobian.cpp_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', -'speed.xml', -'speed_cppad.xml', -'cppad_sparse_jacobian.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'cppad_det_minor.cpp.xml', -'cppad_det_lu.cpp.xml', -'cppad_mat_mul.cpp.xml', -'cppad_ode.cpp.xml', -'cppad_poly.cpp.xml', -'cppad_sparse_hessian.cpp.xml', -'cppad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'cppad_sparse_jacobian.cpp.xml#Specifications', -'cppad_sparse_jacobian.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/cppad_testvector.xml cppad-2019.02.00.0/doc/cppad_testvector.xml --- cppad-2018.00.00.0/doc/cppad_testvector.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_testvector.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,177 +0,0 @@ - - - -Choosing the CppAD Test Vector Template Class - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cppad_testvector - -

- - - -
Choosing the CppAD Test Vector Template Class
-
-Purpose -
-The value -cppad_testvector - -in the cmake command - must be one of the -following: -boost, cppad, eigen, or std. -It specifies which type of vector is corresponds to the template class -CPPAD_TESTVECTOR - -which is used for many of the CppAD examples and tests. - -
-
-std -
-If -cppad_testvector - is -std -, -the std::vector template class is used to define -CPPAD_TESTVECTOR. - -
-
-cppad -
-If -cppad_testvector - is -cppad -, -the cppad_vector - template class is used to define -CPPAD_TESTVECTOR. - -
-
-boost -
-If -cppad_testvector - is -boost -, -boost ublas vector - -template class is used to define -CPPAD_TESTVECTOR. -In this case, the -cmake FindBoost - -module must be able to automatically figure out where Boost is installed. - -
-
-eigen -
-If -cppad_testvector - is -eigen -, -one of the eigen template classes is used to define -CPPAD_TESTVECTOR. -In this case, -eigen_prefix - must be specified on the cmake command line. - - - -
Input File: omh/install/testvector.omh - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_testvector_xml.js cppad-2019.02.00.0/doc/_cppad_testvector_xml.js --- cppad-2018.00.00.0/doc/_cppad_testvector_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_testvector_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', -'install.xml', -'cmake.xml', -'cppad_testvector.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 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.xml' -]; -var list_down1 = [ -'adolc_prefix.xml', -'colpack_prefix.xml', -'eigen_prefix.xml', -'fadbad_prefix.xml', -'ipopt_prefix.xml', -'sacado_prefix.xml', -'cppad_testvector.xml' -]; -var list_current0 = [ -'cppad_testvector.xml#Purpose', -'cppad_testvector.xml#std', -'cppad_testvector.xml#cppad', -'cppad_testvector.xml#boost', -'cppad_testvector.xml#eigen' -]; -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-2018.00.00.0/doc/cppad_vector.cpp.xml cppad-2019.02.00.0/doc/cppad_vector.cpp.xml --- cppad-2018.00.00.0/doc/cppad_vector.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_vector.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,198 +0,0 @@ - - - -CppAD::vector Template Class: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -cppad_vector.cppHeadings

-
CppAD::vector Template Class: Example and Test
-

-# include <cppad/utility/vector.hpp>
-# include <cppad/utility/check_simple_vector.hpp>
-# include <sstream> // sstream and string are used to test output operation
-# include <string>
-
-bool CppAD_vector(void)
-{     bool ok = true;
-     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<Type> >();
-
-     vector<Type> x;          // default constructor
-     ok &= (x.size() == 0);
-
-     x.resize(2);             // resize and set element assignment
-     ok &= (x.size() == 2);
-     x[0] = Type(1);
-     x[1] = Type(2);
-
-     vector<Type> y(2);       // sizing constructor
-     ok &= (y.size() == 2);
-
-     const vector<Type> z(x); // copy constructor and const element access
-     ok &= (z.size() == 2);
-     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(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= "{ 1, 2 }";
-     std::string        str;
-     std::ostringstream buf;
-     buf << z;
-     str = buf.str();
-     ok &= (str == correct);
-
-     // test resize(1), resize(0), capacity, and clear
-     size_t i = x.capacity();
-     ok      &= i >= 2;
-     x.resize(1);
-     ok      &= x[0] == Type(1);
-     ok      &= i == x.capacity();
-     x.resize(0);
-     ok      &= i == x.capacity();
-     x.clear();
-     ok      &= 0 == x.capacity();
-
-     // test of push_back scalar and capacity
-     size_t N = 100;
-     for(i = 0; i < N; i++)
-     {     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();
-     }
-     for(i = 0; i < N; i++)
-          ok &= ( x[i] == Type(i) );
-
-     // test of data
-     Type* data = x.data();
-     for(i = 0; i < N; i++)
-     {     ok &= data[i] == Type(i);
-          data[i] = Type(N - i);
-          ok &= x[i] == Type(N - i);
-     }
-
-     // test of push_vector
-     x.push_vector(x);
-     ok &= (x.size() == 2 * N);
-     for(i = 0; i < N; i++)
-     {     ok &= x[i] == Type(N - i);
-          ok &= x[i+N] == Type(N - i);
-     }
-
-
-     return ok;
-}
-
-
-
Input File: example/utility/cppad_vector.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_vector.cpp_xml.js cppad-2019.02.00.0/doc/_cppad_vector.cpp_xml.js --- cppad-2018.00.00.0/doc/_cppad_vector.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_vector.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'cppad_vector.xml', -'cppad_vector.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'cppad_vector.cpp.xml', -'vector_bool.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-2018.00.00.0/doc/cppad_vector.xml cppad-2019.02.00.0/doc/cppad_vector.xml --- cppad-2018.00.00.0/doc/cppad_vector.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad_vector.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,671 +0,0 @@ - - - -The CppAD::vector Template Class - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
The CppAD::vector Template Class
-
-Syntax - -
- -# include <cppad/utility/vector.hpp> - - -
-
-Description -
-The include file cppad/vector.hpp defines the -vector template class CppAD::vector. -This is a SimpleVector - template class and in addition -it has the features listed below: - -
-
-Include -
-The file cppad/vector.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest of the -CppAD include files. - -
-
-capacity -
-If -x - is a -CppAD::vector<Scalar> -, -and -cap - is a size_t object, - -
-     
cap = x.capacity()
-
-set -cap - to the number of -Scalar - objects that -could fit in the memory currently allocated for -x -. -Note that - -
-     
x.size() <= x.capacity()
-
-
-Assignment -
-If -x - and -y - are - -CppAD::vector<Scalar> - objects, - -
-     
y = x
-
-has all the properties listed for a -simple vector assignment - -plus the following: - -
-
-Check Size -
-The CppAD::vector template class will check that -the size of -x - is either zero or the size of -y - -before doing the assignment. -If this is not the case, CppAD::vector will use -ErrorHandler - -to generate an appropriate error report. -Allowing for assignment to a vector with size zero makes the following -code work: - -
-     CppAD::vector<
Scalary;
-     
y = x;
-
-
-Return Reference -
-A reference to the vector -y - is returned. -An example use of this reference is in multiple assignments of the form - -
-     
z = y = x
-
-
-Move Semantics -
-If the C++ compiler supports move semantic rvalues using the && -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. - -
-
-Element Access -
-If -x - is a -CppAD::vector<Scalar> - object -and -i - has type size_t, - -
-     
x[i]
-
-has all the properties listed for a -simple vector element access - -plus the following: -
-
-
The object -x[i] - has type -Scalar - -(is not possibly a different type that can be converted to -Scalar -). -
-
-
If -i - is not less than the size of the -x -, -CppAD::vector will use -ErrorHandler - -to generate an appropriate error report. - -
-
-push_back -
-If -x - is a -CppAD::vector<Scalar> - object -with size equal to -n - and - -s - has type -Scalar -, - -
-     
x.push_back(s)
-
-extends the vector -x - so that its new size is -n - plus one -and -x[n] - is equal to -s - -(equal in the sense of the -Scalar - assignment operator). - -
-
-push_vector -
-If -x - is a -CppAD::vector<Scalar> - object -with size equal to -n - and - -v - is a simple vector - -with elements of type -Scalar - and size -m -, - -
-     
x.push_vector(v)
-
-extends the vector -x - so that its new size is -n+m - -and -x[n + i] - is equal to -v[i] - -for -i = 1 , ... , m-1 - -(equal in the sense of the -Scalar - assignment operator). - -
-
-Output -
-If -x - is a -CppAD::vector<Scalar> - object -and -os - is an std::ostream, -and the operation - -
-     
os << x
-
-will output the vector -x - to the standard -output stream -os -. -The elements of -x - are enclosed at the beginning by a -{ character, -they are separated by , characters, -and they are enclosed at the end by } character. -It is assumed by this operation that if -e - -is an object with type -Scalar -, - -
-     
os << e
-
-will output the value -e - to the standard -output stream -os -. - -
-
-resize -
-The call -x.resize(n) - set the size of -x - equal to - -n -. -If -n <= x.capacity() -, -no memory is freed or allocated, the capacity of -x - does not change, -and the data in -x - is preserved. -If -n > x.capacity() -, -new memory is allocated and the data in -x - is lost -(not copied to the new memory location). - -
-
-clear -
-All memory allocated for the vector is freed -and both its size and capacity are set to zero. -This can be useful when using very large vectors -and when checking for memory leaks (and there are global vectors) -see the memory - discussion. - -
-
-data -
-If -x - is a -CppAD::vector<Scalar> - object - -
-     
x.data()
-
-returns a pointer to a -Scalar - object such that for - -0 <= i < x.size() -, - -x[i] - and -x.data()[i] - -are the same -Scalar - object. -If -x - is const, the pointer is const. -If -x.capacity() - is zero, the value of the pointer is not defined. -The pointer may no longer be valid after the following operations on - -x -: -its destructor, -clear, -resize, -push_back, -push_vector, -assignment to another vector when original size of -x - is zero. - -
-
-vectorBool -
-The file <cppad/vector.hpp> also defines the class -CppAD::vectorBool. -This has the same specifications as CppAD::vector<bool> -with the following exceptions: - -
-
-Memory -
-The class vectorBool conserves on memory -(on the other hand, CppAD::vector<bool> is expected to be faster -than vectorBool). - -
-
-bit_per_unit -
-The static function call - -
-     
s = vectorBool::bit_per_unit()
-
-returns the size_t value -s - -which is equal to the number of boolean values (bits) that are -packed into one operational unit. -For example, a logical or -acts on this many boolean values with one operation. - -
-
-data -
-The data - function is not supported by -vectorBool. - -
-
-Output -
-The CppAD::vectorBool output operator -prints each boolean value as -a 0 for false, -a 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 {, } and with no separating commas or spaces. - -
-
-Element Type -
-If -x - has type vectorBool -and -i - has type size_t, -the element access value -x[i] - has an unspecified type, -referred to here as -elementType -, that supports the following -operations: - -
  1. - -elementType - can be converted to bool; e.g. -the following syntax is supported: - -
    -     static_cast<bool>( 
    x[i] )
    -
    -
  2. - -elementType - supports the assignment operator = where the -right hand side is a bool or an -elementType - object; e.g., -if -y - has type bool, the following syntax is supported: - -
    -     
    x[i] = y
    -
    -
  3. -The result of an assignment to an -elementType - -also has type -elementType -. -Thus, if -z - has type bool, the following syntax is supported: - -
    -     
    z = x[i] = y
    -
    -
-
-Memory and Parallel Mode -
-These vectors use the multi-threaded fast memory allocator -thread_alloc -: - -
  1. -The routine parallel_setup - must -be called before these vectors can be used -in parallel -. -
  2. - -Using these vectors affects the amount of memory -in_use - and available -. -
  3. - -Calling clear -, -makes the corresponding memory available (though thread_alloc) -to the current thread. -
  4. - -Available memory -can then be completely freed using free_available -. -
- - -
-
-Example - -
-The files -cppad_vector.cpp - and -vector_bool.cpp - each -contain an example and test of this template class. -They return true if they succeed and false otherwise. - -
-
-Exercise -
-Create and run a program that contains the following code: -
 
-     CppAD::vector<double> x(3);
-     size_t i;
-     for(i = 0; i < 3; i++)
-          x[i] = 4. - i;
-     std::cout << "x = " << x << std::endl;
-
- -
Input File: cppad/utility/vector.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_vector_xml.js cppad-2019.02.00.0/doc/_cppad_vector_xml.js --- cppad-2018.00.00.0/doc/_cppad_vector_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_vector_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'cppad_vector.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'cppad_vector.cpp.xml', -'vector_bool.cpp.xml' -]; -var list_current0 = [ -'cppad_vector.xml#Syntax', -'cppad_vector.xml#Description', -'cppad_vector.xml#Include', -'cppad_vector.xml#capacity', -'cppad_vector.xml#Assignment', -'cppad_vector.xml#Assignment.Check Size', -'cppad_vector.xml#Assignment.Return Reference', -'cppad_vector.xml#Assignment.Move Semantics', -'cppad_vector.xml#Element Access', -'cppad_vector.xml#push_back', -'cppad_vector.xml#push_vector', -'cppad_vector.xml#Output', -'cppad_vector.xml#resize', -'cppad_vector.xml#clear', -'cppad_vector.xml#data', -'cppad_vector.xml#vectorBool', -'cppad_vector.xml#vectorBool.Memory', -'cppad_vector.xml#vectorBool.bit_per_unit', -'cppad_vector.xml#vectorBool.data', -'cppad_vector.xml#vectorBool.Output', -'cppad_vector.xml#vectorBool.Element Type', -'cppad_vector.xml#Memory and Parallel Mode', -'cppad_vector.xml#Example', -'cppad_vector.xml#Exercise' -]; -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-2018.00.00.0/doc/cppad.xml cppad-2019.02.00.0/doc/cppad.xml --- cppad-2018.00.00.0/doc/cppad.xml 2018-01-01 08:32:40.000000000 +0000 +++ cppad-2019.02.00.0/doc/cppad.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,264 +0,0 @@ - - - -cppad-20180000.0: A Package for Differentiation of C++ Algorithms - - - - - - - - - - - - - -
- -PrevNext - - - - - - - - -

-, - - -
cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-
-Syntax - -
-# include <cppad/cppad.hpp>
- -
-
-Introduction -
-We refer to the -step by step conversion from an algorithm that computes function values -to an algorithm that computes derivative values -as Algorithmic Differentiation -(often referred to as 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 -wikipedia -. -The web site -autodiff.org - -is dedicated to research about, and promoting the use of, AD. - -
  1. -CppAD - -uses operator overloading to compute derivatives of algorithms defined in C++. -It is distributed by the -COIN-OR Foundation - -with the Eclipse Public License -EPL-1.0 - -or the GNU General Public License -GPL-3.0 -. -Testing and installation is supported for Unix, Microsoft, and Apple -operating systems. -Extensive user and developer documentation is included. - -
  2. - -An AD of Base -operation sequence - -is stored as an -AD function object - -which can evaluate function values and derivatives. -Arbitrary order -forward - and reverse - -mode derivative calculations -can be preformed on the operation sequence. -Logical comparisons can be included in an operation sequence -using AD conditional expressions -. -Evaluation of user defined unary -discrete functions - can also be included -in the sequence of operations; i.e., -functions that depend on the -independent variables - -but which have identically zero derivatives -(e.g., a step function). - -
  3. - -Derivatives of functions that are defined in terms of other derivatives -can be computed using multiple levels of AD; -see mul_level.cpp - for a simple example -and mul_level_ode.cpp - for a more realistic example. -To this end, CppAD can also be used with other AD types; for example see -mul_level_adolc_ode.cpp -. - -
  4. - -A set of programs for doing speed - comparisons between -Adolc -, -CppAD, -Fadbad -, -and -Sacado - -are included. - - -
  5. - -Includes a set of C++ utilities - that are useful -for general operator overloaded numerical method. -Allows for replacement of the -testvector - -template vector class which is used for extensive testing; -for example, you can do your testing with the -uBlas - -template vector class. - -
  6. - -See whats_new - for a list of recent extensions and bug fixes. - -
- - -You can find out about other algorithmic differentiation tools -and about algorithmic differentiation in general at the following web sites: -wikipedia -, -autodiff.org -. - -
-
-Example -
-The file -get_started.cpp - -contains an example and test of using CppAD to compute -the derivative of a polynomial. -There are many other -examples -. - -
-
-Include File -
-The following include directive -
-     # include <cppad/cppad.hpp>
-
includes the CppAD package for the rest of the current compilation unit. - -
-
-Preprocessor Symbols -
-All the preprocessor - symbols used by CppAD begin with eight -CppAD or CPPAD_. - -
-
-Namespace -
-All of the functions and objects defined by CppAD are in the -CppAD namespace; for example, you can access the AD - types as -
-     size_t n = 2;
-     CppAD::vector< CppAD::AD<
Base> > x(n)
-
You can abbreviate access to one object or function a using -command of the form -
-     using CppAD::AD
-     CppAD::vector< AD<
Base> > x(n)
-
You can abbreviate access to all CppAD objects and functions -with a command of the form -
-     using namespace CppAD
-     vector< AD<
Base> > x(n)
-
If you include other namespaces in a similar manner, -this can cause naming conflicts. - - -
-
-Contents -
- -
_contentsTable of Contents
InstallCppAD Download, Test, and Install Instructions
IntroductionAn Introduction by Example to Algorithmic Differentiation
ADAD Objects
ADFunADFun Objects
preprocessorCppAD API Preprocessor Symbols
multi_threadUsing CppAD in a Multi-Threading Environment
utilitySome General Purpose Utilities
ipopt_solveUse Ipopt to Solve a Nonlinear Programming Problem
ExampleExamples
speedSpeed Test an Operator Overloading AD Package
AppendixAppendix
_referenceAlphabetic Listing of Cross Reference Tags
_indexKeyword Index
_searchSearch This Web Site
_externalExternal Internet References
-
Input File: doc.omh - - - diff -Nru cppad-2018.00.00.0/doc/_cppad_xml.js cppad-2019.02.00.0/doc/_cppad_xml.js --- cppad-2018.00.00.0/doc/_cppad_xml.js 2018-01-01 08:32:40.000000000 +0000 +++ cppad-2019.02.00.0/doc/_cppad_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml' -]; -var list_down0 = [ -'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_current0 = [ -'cppad.xml#Syntax', -'cppad.xml#Introduction', -'cppad.xml#Example', -'cppad.xml#Include File', -'cppad.xml#Preprocessor Symbols', -'cppad.xml#Namespace', -'cppad.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_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-2018.00.00.0/doc/dependency.cpp.xml cppad-2019.02.00.0/doc/dependency.cpp.xml --- cppad-2018.00.00.0/doc/dependency.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/dependency.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,301 +0,0 @@ - - - -Computing Dependency: Example and Test - - - - - - - - - - - - - - - - -
- -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 patterns. - -
-
-Computation -
-The -dependency - argument to -for_jac_sparsity - 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;
-     typedef CPPAD_TESTVECTOR(size_t)     SizeVector;
-     typedef CppAD::sparse_rc<SizeVector> sparsity;
-
-     // 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);
-     // Note that ay[m1 - j] depends on ax[j]
-     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);
-
-     // sparsity pattern for n by n identity matrix
-     size_t nr  = n;
-     size_t nc  = n;
-     size_t nnz = n;
-     sparsity pattern_in(nr, nc, nnz);
-     for(size_t k = 0; k < nnz; k++)
-     {     size_t r = k;
-          size_t c = k;
-          pattern_in.set(k, r, c);
-     }
-
-     // compute dependency pattern
-     bool transpose     = false;
-     bool dependency    = true;  // would transpose dependency pattern
-     bool internal_bool = true;  // does not affect result
-     sparsity pattern_out;
-     f.for_jac_sparsity(
-          pattern_in, transpose, dependency, internal_bool, pattern_out
-     );
-     const SizeVector& row( pattern_out.row() );
-     const SizeVector& col( pattern_out.col() );
-     SizeVector col_major = pattern_out.col_major();
-
-     // check result
-     ok &= pattern_out.nr()  == n;
-     ok &= pattern_out.nc()  == n;
-     ok &= pattern_out.nnz() == n;
-     for(size_t k = 0; k < n; k++)
-     {     ok &= row[ col_major[k] ] == m1 - k;
-          ok &= col[ col_major[k] ] == k;
-     }
-     // -----------------------------------------------------------
-     // 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);
-     }
-     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/sparse/dependency.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_dependency.cpp_xml.js cppad-2019.02.00.0/doc/_dependency.cpp_xml.js --- cppad-2018.00.00.0/doc/_dependency.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_dependency.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparsity_pattern.xml', -'dependency.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_current0 = [ -'dependency.cpp.xml#Discussion', -'dependency.cpp.xml#Dependency Pattern', -'dependency.cpp.xml#Computation' -]; -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-2018.00.00.0/doc/dependent.xml cppad-2019.02.00.0/doc/dependent.xml --- cppad-2018.00.00.0/doc/dependent.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/dependent.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,321 +0,0 @@ - - - -Stop Recording and Store Operation Sequence - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -Dependent - -

-
Stop Recording and Store Operation Sequence
-
-Syntax - -
- -f.Dependent(xy) - - -
-
-Purpose -
-Stop recording and the AD of -Base - -operation sequence - -that started with the call - -
-     Independent(
x)
-
-and store the operation sequence in -f -. -The operation sequence defines an -AD function - - - -F -: -B -n - - -B -m - - - -where - -B - - - is the space corresponding to objects of type -Base -. -The value - -n - - - is the dimension of the -domain - space for the operation sequence. -The value - -m - - - is the dimension of the -range - space for the operation sequence -(which is determined by the size of -y -). - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-The AD of -Base - operation sequence is stored in -f -; i.e., -it becomes the operation sequence corresponding to -f -. -If a previous operation sequence was stored in -f -, -it is deleted. - -
-
-x -
-The argument -x - -must be the vector argument in a previous call to -Independent -. -Neither its size, or any of its values, are allowed to change -between calling - -
-     Independent(
x)
-
-and - -
-     
f.Dependent(xy)
-
-. - -
-
-y -
-The vector -y - has prototype - -
-     const 
ADvector &y
-
-(see ADvector - below). -The length of -y - must be greater than zero -and is the dimension of the range space for -f -. - -
-
-ADvector -
-The type -ADvector - must be a SimpleVector - class with -elements of type - - -AD<Base> -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Taping -
-The tape, -that was created when -Independent(x) - was called, -will stop recording. -The AD operation sequence will be transferred from -the tape to the object -f - and the tape will then be deleted. - -
-
-Forward -
-No Forward - calculation is preformed during this operation. -Thus, directly after this operation, - -
-     
f.size_order()
-
-is zero (see size_order -). - -
-
-Parallel Mode -
-The call to Independent, -and the corresponding call to - -
-     ADFun<
Basefxy)
-
-or - -
-     
f.Dependent( xy)
-
-or abort_recording -, -must be preformed by the same thread; i.e., -thread_alloc::thread_num - must be the same. - -
-
-Example -
-The file -fun_check.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/dependent.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_dependent_xml.js cppad-2019.02.00.0/doc/_dependent_xml.js --- cppad-2018.00.00.0/doc/_dependent_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_dependent_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'record_adfun.xml', -'dependent.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'independent.xml', -'funconstruct.xml', -'dependent.xml', -'abort_recording.xml', -'seq_property.xml' -]; -var list_current0 = [ -'dependent.xml#Syntax', -'dependent.xml#Purpose', -'dependent.xml#f', -'dependent.xml#x', -'dependent.xml#y', -'dependent.xml#ADvector', -'dependent.xml#Taping', -'dependent.xml#Forward', -'dependent.xml#Parallel Mode', -'dependent.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-2018.00.00.0/doc/deprecated.xml cppad-2019.02.00.0/doc/deprecated.xml --- cppad-2018.00.00.0/doc/deprecated.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/deprecated.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,166 +0,0 @@ - - - -CppAD Deprecated API Features - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - -
CppAD Deprecated API Features
-
-Contents -
- -
include_deprecatedDeprecated Include Files
FunDeprecatedADFun Object Deprecated Member Functions
CompareChangeComparison Changes During Zero Order Forward Mode
omp_max_threadOpenMP Parallel Setup
TrackNewDelRoutines That Track Use of New and Delete
omp_allocA Quick OpenMP Memory Allocator Used by CppAD
memory_leakMemory Leak Detection
epsilonMachine Epsilon For AD Types
test_vectorChoosing The Vector Testing Template Class
cppad_ipopt_nlpNonlinear Programming Using the CppAD Interface to Ipopt
old_atomicUser Defined Atomic AD Functions
zdoublezdouble: An AD Base Type With Absolute Zero
autotoolsAutotools Unix Test and Installation

-Name Changes - - -
- -CppADCreateUnaryBool - - - AD Boolean Functions -
- -CppADCreateDiscrete - - - Discrete AD Functions -
- -nan(zero) - - -nan(zero) - -
- -colpack.star coloring - see -sparse_hes - -and -sparse_hessian - - -
-
-Atomic Functions -
-The following are links to deprecated atomic_base - interfaces: -for_sparse_jac -, -rev_sparse_jac -, -for_sparse_hes -, -rev_sparse_hes -. - - - -
Input File: omh/appendix/deprecated/deprecated.omh - - - diff -Nru cppad-2018.00.00.0/doc/_deprecated_xml.js cppad-2019.02.00.0/doc/_deprecated_xml.js --- cppad-2018.00.00.0/doc/_deprecated_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_deprecated_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', -'deprecated.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', -'directory.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 = [ -'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', -'autotools.xml' -]; -var list_current0 = [ -'deprecated.xml#Contents', -'deprecated.xml#Name Changes', -'deprecated.xml#Atomic Functions' -]; -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-2018.00.00.0/doc/det_33.hpp.xml cppad-2019.02.00.0/doc/det_33.hpp.xml --- cppad-2018.00.00.0/doc/det_33.hpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_33.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ - - - -Source: det_33 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -det_33.hppHeadings

- - - -
Source: det_33
-# ifndef CPPAD_DET_33_HPP -
-
# define CPPAD_DET_33_HPP - -
# include <cppad/utility/near_equal.hpp>
-namespace CppAD {
-template <class Vector>
-     bool det_33(const Vector &x, const Vector &d)
-     {     bool ok = true;
-          double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-          // use expansion by minors to compute the determinant by hand
-          double check = 0.;
-          check += x[0] * ( x[4] * x[8] - x[5] * x[7] );
-          check -= x[1] * ( x[3] * x[8] - x[5] * x[6] );
-          check += x[2] * ( x[3] * x[7] - x[4] * x[6] );
-
-          ok &= CppAD::NearEqual(check, d[0], eps99, eps99);
-
-          return ok;
-     }
-}
-# endif -
- - -
Input File: omh/det_33_hpp.omh - - - diff -Nru cppad-2018.00.00.0/doc/_det_33.hpp_xml.js cppad-2019.02.00.0/doc/_det_33.hpp_xml.js --- cppad-2018.00.00.0/doc/_det_33.hpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_33.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_33.xml', -'det_33.hpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'det_33.hpp.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-2018.00.00.0/doc/det_33.xml cppad-2019.02.00.0/doc/det_33.xml --- cppad-2018.00.00.0/doc/det_33.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_33.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,259 +0,0 @@ - - - -Check Determinant of 3 by 3 matrix - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Check Determinant of 3 by 3 matrix
-
-Syntax - -
- -# include <cppad/speed/det_33.hpp>
-
- -ok = det_33(xd) - - -
-
-Purpose -
-This routine can be used to check a method for computing -the determinant of a matrix. - -
-
-Inclusion -
-The template function det_33 is defined in the CppAD -namespace by including -the file cppad/speed/det_33.hpp -(relative to the CppAD distribution directory). - -
-
-x -
-The argument -x - has prototype - -
-     const 
Vector &x
-
-. -It contains the elements of the matrix - -X - - - in row major order; i.e., - - -X -i -, -j - - -= -x -[ -i -* -3 -+ -j -] - - -
-d -
-The argument -d - has prototype - -
-     const 
Vector &d
-
-. -It is tested to see if -d[0] - it is equal to - -det -( -X -) - - -. - -
-
-Vector -
-If -y - is a -Vector - object, -it must support the syntax - -
-     
y[i]
-
-where -i - has type size_t with value less than 9. -This must return a double value corresponding to the i-th -element of the vector -y -. -This is the only requirement of the type -Vector -. -(Note that only the first element of the vector -d - is used.) - -
-
-ok -
-The return value -ok - has prototype - -
-     bool 
ok
-
-It is true, if the determinant -d[0] - -passes the test and false otherwise. - - - -
-
-Source Code -
-The file -det_33.hpp - -contains the source code for this template function. - - -
Input File: cppad/speed/det_33.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_det_33_xml.js cppad-2019.02.00.0/doc/_det_33_xml.js --- cppad-2018.00.00.0/doc/_det_33_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_33_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_33.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down0 = [ -'det_33.hpp.xml' -]; -var list_current0 = [ -'det_33.xml#Syntax', -'det_33.xml#Purpose', -'det_33.xml#Inclusion', -'det_33.xml#x', -'det_33.xml#d', -'det_33.xml#Vector', -'det_33.xml#ok', -'det_33.xml#Source Code' -]; -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-2018.00.00.0/doc/det_by_lu.cpp.xml cppad-2019.02.00.0/doc/det_by_lu.cpp.xml --- cppad-2018.00.00.0/doc/det_by_lu.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_by_lu.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,130 +0,0 @@ - - - -Determinant Using Lu Factorization: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -det_by_lu.cppHeadings

- - - -
Determinant Using Lu Factorization: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cppad/speed/det_by_lu.hpp>
-
-bool det_by_lu()
-{     bool ok = true;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // dimension of the matrix
-     size_t n = 3;
-
-     // construct the determinat object
-     CppAD::det_by_lu<double> Det(n);
-
-     double  a[] = {
-          1., 2., 3.,  // a[0] a[1] a[2]
-          3., 2., 1.,  // a[3] a[4] a[5]
-          2., 1., 2.   // a[6] a[7] a[8]
-     };
-     CPPAD_TESTVECTOR(double) A(9);
-     size_t i;
-     for(i = 0; i < 9; i++)
-          A[i] = a[i];
-
-
-     // evaluate the determinant
-     double det = Det(A);
-
-     double check;
-     check = a[0]*(a[4]*a[8] - a[5]*a[7])
-           - a[1]*(a[3]*a[8] - a[5]*a[6])
-           + a[2]*(a[3]*a[7] - a[4]*a[6]);
-
-     ok = CppAD::NearEqual(det, check, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: speed/example/det_by_lu.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_det_by_lu.cpp_xml.js cppad-2019.02.00.0/doc/_det_by_lu.cpp_xml.js --- cppad-2018.00.00.0/doc/_det_by_lu.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_by_lu.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_by_lu.xml', -'det_by_lu.cpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'det_by_lu.cpp.xml', -'det_by_lu.hpp.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-2018.00.00.0/doc/det_by_lu.hpp.xml cppad-2019.02.00.0/doc/det_by_lu.hpp.xml --- cppad-2018.00.00.0/doc/det_by_lu.hpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_by_lu.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,152 +0,0 @@ - - - -Source: det_by_lu - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -det_by_lu.hppHeadings

-
Source: det_by_lu
-# ifndef CPPAD_DET_BY_LU_HPP -
-
# define CPPAD_DET_BY_LU_HPP - -
# include <cppad/utility/vector.hpp>
-# include <cppad/utility/lu_solve.hpp>
-
-// BEGIN CppAD namespace
-namespace CppAD {
-
-template <class Scalar>
-class det_by_lu {
-private:
-     const size_t m_;
-     const size_t n_;
-     CppAD::vector<Scalar> A_;
-     CppAD::vector<Scalar> B_;
-     CppAD::vector<Scalar> X_;
-public:
-     det_by_lu(size_t n) : m_(0), n_(n), A_(n * n)
-     {     }
-
-     template <class Vector>
-     inline Scalar operator()(const Vector &x)
-     {
-
-          Scalar       logdet;
-          Scalar       det;
-          int          signdet;
-          size_t       i;
-
-          // 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
-          // point operation sequence very simple.
-          if( signdet == 0 )
-               det = 0;
-          else     det =  Scalar( signdet ) * exp( logdet );
-*/
-
-          // convert to determinant
-          det     = Scalar( signdet ) * exp( logdet );
-
-# ifdef FADBAD
-          // Fadbad requires tempories to be set to constants
-          for(i = 0; i < n_ * n_; i++)
-               A_[i] = 0;
-# endif
-
-          return det;
-     }
-};
-} // END CppAD namespace
-# endif -
- - -
Input File: omh/det_by_lu_hpp.omh - - - diff -Nru cppad-2018.00.00.0/doc/_det_by_lu.hpp_xml.js cppad-2019.02.00.0/doc/_det_by_lu.hpp_xml.js --- cppad-2018.00.00.0/doc/_det_by_lu.hpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_by_lu.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_by_lu.xml', -'det_by_lu.hpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'det_by_lu.cpp.xml', -'det_by_lu.hpp.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-2018.00.00.0/doc/det_by_lu.xml cppad-2019.02.00.0/doc/det_by_lu.xml --- cppad-2018.00.00.0/doc/det_by_lu.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_by_lu.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,351 +0,0 @@ - - - -Determinant Using Expansion by Lu Factorization - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Determinant Using Expansion by Lu Factorization
-
-Syntax - -
- -# include <cppad/speed/det_by_lu.hpp>
-
- -det_by_lu<Scalardet(n)
-
- -d = det(a)
-
-
-Inclusion -
-The template class det_by_lu is defined in the CppAD -namespace by including -the file cppad/speed/det_by_lu.hpp -(relative to the CppAD distribution directory). - -
-
-Constructor -
-The syntax - -
-     det_by_lu<
Scalardet(n)
-
-constructs the object -det - which can be used for -evaluating the determinant of -n - by -n - matrices -using LU factorization. - -
-
-Scalar -
-The type -Scalar - can be any -NumericType - - -
-
-n -
-The argument -n - has prototype - -
-     size_t 
n
-
-
-det -
-The syntax - -
-     
d = det(a)
-
-returns the determinant of the matrix - -A - - - using LU factorization. - -
-
-a -
-The argument -a - has prototype - -
-     const 
Vector &a
-
-It must be a -Vector - with length - -n -* -n - - - and with -It must be a -Vector - with length - -n -* -n - - - and with -elements of type -Scalar -. -The elements of the - -n -× -n - - - matrix - -A - - - are defined, -for - -i -= -0 -, - -, -n --1 - - - and - -j -= -0 -, - -, -n --1 - - -, by - - -A -i -, -j - - -= -a -[ -i -* -m -+ -j -] - - -
-d -
-The return value -d - has prototype - -
-     
Scalar d
-
-
-Vector -
-If -y - is a -Vector - object, -it must support the syntax - -
-     
y[i]
-
-where -i - has type size_t with value less than - -n -* -n - - -. -This must return a -Scalar - value corresponding to the i-th -element of the vector -y -. -This is the only requirement of the type -Vector -. - - - - -
-
-Example -
-The file -det_by_lu.cpp - -contains an example and test of det_by_lu.hpp. -It returns true if it succeeds and false otherwise. - -
-
-Source Code -
-The file -det_by_lu.hpp - -contains the source for this template function. - - - -
Input File: cppad/speed/det_by_lu.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_det_by_lu_xml.js cppad-2019.02.00.0/doc/_det_by_lu_xml.js --- cppad-2018.00.00.0/doc/_det_by_lu_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_by_lu_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_by_lu.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down0 = [ -'det_by_lu.cpp.xml', -'det_by_lu.hpp.xml' -]; -var list_current0 = [ -'det_by_lu.xml#Syntax', -'det_by_lu.xml#Inclusion', -'det_by_lu.xml#Constructor', -'det_by_lu.xml#Scalar', -'det_by_lu.xml#n', -'det_by_lu.xml#det', -'det_by_lu.xml#det.a', -'det_by_lu.xml#det.d', -'det_by_lu.xml#Vector', -'det_by_lu.xml#Example', -'det_by_lu.xml#Source Code' -]; -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-2018.00.00.0/doc/det_by_minor.cpp.xml cppad-2019.02.00.0/doc/det_by_minor.cpp.xml --- cppad-2018.00.00.0/doc/det_by_minor.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_by_minor.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,129 +0,0 @@ - - - -Determinant Using Expansion by Minors: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -det_by_minor.cppHeadings

- - - -
Determinant Using Expansion by Minors: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cppad/speed/det_by_minor.hpp>
-
-bool det_by_minor()
-{     bool ok = true;
-
-     // dimension of the matrix
-     size_t n = 3;
-
-     // construct the determinat object
-     CppAD::det_by_minor<double> Det(n);
-
-     double  a[] = {
-          1., 2., 3.,  // a[0] a[1] a[2]
-          3., 2., 1.,  // a[3] a[4] a[5]
-          2., 1., 2.   // a[6] a[7] a[8]
-     };
-     CPPAD_TESTVECTOR(double) A(9);
-     size_t i;
-     for(i = 0; i < 9; i++)
-          A[i] = a[i];
-
-
-     // evaluate the determinant
-     double det = Det(A);
-
-     double check;
-     check = a[0]*(a[4]*a[8] - a[5]*a[7])
-           - a[1]*(a[3]*a[8] - a[5]*a[6])
-           + a[2]*(a[3]*a[7] - a[4]*a[6]);
-
-     ok = det == check;
-
-     return ok;
-}
-
-
-
Input File: speed/example/det_by_minor.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_det_by_minor.cpp_xml.js cppad-2019.02.00.0/doc/_det_by_minor.cpp_xml.js --- cppad-2018.00.00.0/doc/_det_by_minor.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_by_minor.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_by_minor.xml', -'det_by_minor.cpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'det_by_minor.cpp.xml', -'det_by_minor.hpp.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-2018.00.00.0/doc/det_by_minor_c.xml cppad-2019.02.00.0/doc/det_by_minor_c.xml --- cppad-2018.00.00.0/doc/det_by_minor_c.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_by_minor_c.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,309 +0,0 @@ - - - -Compute Determinant using Expansion by Minors - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -det_by_minor_c - -

-
Compute Determinant using Expansion by Minors
-
-Syntax - -
- -d = det_by_minor(an) - - -
-
-Purpose -
-returns the determinant of the matrix - -A - - - -using expansion by minors. -The elements of the - -n -× -n - - - minor - -M - - - -of the matrix - -A - - - are defined, -for - -i -= -0 -, - -, -n --1 - - - and - -j -= -0 -, - -, -n --1 - - -, by - - -M -i -, -j - - -= -A -i -, -j - - - - -
-a -
-The argument -a - has prototype - -
-     const double* 
a
-
-and is a vector with size - -m -* -m - - -. -The elements of the - -m -× -m - - - matrix - -A - - - are defined, -for - -i -= -0 -, - -, -m --1 - - - and - -j -= -0 -, - -, -m --1 - - -, by - - -A -i -, -j - - -= -a -[ -i -* -m -+ -j -] - - -
-m -
-The argument -m - has prototype - -
-     size_t 
m
-
-and is the number of rows (and columns) in the square matrix - -A - - -. - - - - -
-
-Source Code - -
double det_by_minor(double* a, size_t m)
-{     size_t *r, *c, i;
-     double value;
-
-     r = (size_t*) malloc( (m+1) * sizeof(size_t) );
-     c = (size_t*) malloc( (m+1) * sizeof(size_t) );
-
-     assert(m <= 100);
-     for(i = 0; i < m; i++)
-     {     r[i] = i+1;
-          c[i] = i+1;
-     }
-     r[m] = 0;
-     c[m] = 0;
-
-     value = det_of_minor(a, m, m, r, c);
-
-     free(r);
-     free(c);
-     return value;
-}
- -
Input File: test_more/compare_c/det_by_minor.c - - - diff -Nru cppad-2018.00.00.0/doc/_det_by_minor_c_xml.js cppad-2019.02.00.0/doc/_det_by_minor_c_xml.js --- cppad-2018.00.00.0/doc/_det_by_minor_c_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_by_minor_c_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'compare_c.xml', -'det_by_minor_c.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', -'directory.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 = [ -'det_of_minor_c.xml', -'det_by_minor_c.xml', -'uniform_01_c.xml', -'correct_det_by_minor_c.xml', -'repeat_det_by_minor_c.xml', -'elapsed_seconds_c.xml', -'time_det_by_minor_c.xml', -'main_compare_c.xml' -]; -var list_current0 = [ -'det_by_minor_c.xml#Syntax', -'det_by_minor_c.xml#Purpose', -'det_by_minor_c.xml#a', -'det_by_minor_c.xml#m', -'det_by_minor_c.xml#Source Code' -]; -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-2018.00.00.0/doc/det_by_minor.hpp.xml cppad-2019.02.00.0/doc/det_by_minor.hpp.xml --- cppad-2018.00.00.0/doc/det_by_minor.hpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_by_minor.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ - - - -Source: det_by_minor - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -det_by_minor.hppHeadings

-
Source: det_by_minor
-# ifndef CPPAD_DET_BY_MINOR_HPP -
-
# define CPPAD_DET_BY_MINOR_HPP - -
# include <cppad/speed/det_of_minor.hpp>
-# include <vector>
-
-// BEGIN CppAD namespace
-namespace CppAD {
-
-template <class Scalar>
-class det_by_minor {
-private:
-     size_t              m_;
-
-     // made mutable because modified and then restored
-     mutable std::vector<size_t> r_;
-     mutable std::vector<size_t> c_;
-
-     // make mutable because its value does not matter
-     mutable std::vector<Scalar> a_;
-public:
-     det_by_minor(size_t m) : m_(m) , r_(m + 1) , c_(m + 1), a_(m * m)
-     {
-          size_t i;
-
-          // values for r and c that correspond to entire matrix
-          for(i = 0; i < m; i++)
-          {     r_[i] = i+1;
-               c_[i] = i+1;
-          }
-          r_[m] = 0;
-          c_[m] = 0;
-     }
-
-     template <class Vector>
-     inline Scalar operator()(const Vector &x) const
-     {     size_t i = m_ * m_;
-          while(i--)
-               a_[i] = x[i];
-          return det_of_minor(a_, m_, m_, r_, c_);
-     }
-
-};
-
-} // END CppAD namespace
-# endif -
- - -
Input File: omh/det_by_minor_hpp.omh - - - diff -Nru cppad-2018.00.00.0/doc/_det_by_minor.hpp_xml.js cppad-2019.02.00.0/doc/_det_by_minor.hpp_xml.js --- cppad-2018.00.00.0/doc/_det_by_minor.hpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_by_minor.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_by_minor.xml', -'det_by_minor.hpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'det_by_minor.cpp.xml', -'det_by_minor.hpp.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-2018.00.00.0/doc/det_by_minor.xml cppad-2019.02.00.0/doc/det_by_minor.xml --- cppad-2018.00.00.0/doc/det_by_minor.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_by_minor.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,349 +0,0 @@ - - - -Determinant Using Expansion by Minors - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Determinant Using Expansion by Minors
-
-Syntax - -
- -# include <cppad/speed/det_by_minor.hpp>
-
- -det_by_minor<Scalardet(n)
-
- -d = det(a)
-
-
-Inclusion -
-The template class det_by_minor is defined in the CppAD -namespace by including -the file cppad/speed/det_by_minor.hpp -(relative to the CppAD distribution directory). - -
-
-Constructor -
-The syntax - -
-     det_by_minor<
Scalardet(n)
-
-constructs the object -det - which can be used for -evaluating the determinant of -n - by -n - matrices -using expansion by minors. - -
-
-Scalar -
-The type -Scalar - must satisfy the same conditions -as in the function det_of_minor -. - -
-
-n -
-The argument -n - has prototype - -
-     size_t 
n
-
-
-det -
-The syntax - -
-     
d = det(a)
-
-returns the determinant of the matrix -A - using expansion by minors. - -
-
-a -
-The argument -a - has prototype - -
-     const 
Vector &a
-
-It must be a -Vector - with length - -n -* -n - - - and with -elements of type -Scalar -. -The elements of the - -n -× -n - - - matrix - -A - - - are defined, -for - -i -= -0 -, - -, -n --1 - - - and - -j -= -0 -, - -, -n --1 - - -, by - - -A -i -, -j - - -= -a -[ -i -* -m -+ -j -] - - -
-d -
-The return value -d - has prototype - -
-     
Scalar d
-
-It is equal to the determinant of - -A - - -. - -
-
-Vector -
-If -y - is a -Vector - object, -it must support the syntax - -
-     
y[i]
-
-where -i - has type size_t with value less than - -n -* -n - - -. -This must return a -Scalar - value corresponding to the i-th -element of the vector -y -. -This is the only requirement of the type -Vector -. - - - - -
-
-Example -
-The file -det_by_minor.cpp - -contains an example and test of det_by_minor.hpp. -It returns true if it succeeds and false otherwise. - -
-
-Source Code -
-The file -det_by_minor.hpp - -contains the source for this template function. - - - -
Input File: cppad/speed/det_by_minor.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_det_by_minor_xml.js cppad-2019.02.00.0/doc/_det_by_minor_xml.js --- cppad-2018.00.00.0/doc/_det_by_minor_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_by_minor_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_by_minor.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down0 = [ -'det_by_minor.cpp.xml', -'det_by_minor.hpp.xml' -]; -var list_current0 = [ -'det_by_minor.xml#Syntax', -'det_by_minor.xml#Inclusion', -'det_by_minor.xml#Constructor', -'det_by_minor.xml#Scalar', -'det_by_minor.xml#n', -'det_by_minor.xml#det', -'det_by_minor.xml#det.a', -'det_by_minor.xml#det.d', -'det_by_minor.xml#Vector', -'det_by_minor.xml#Example', -'det_by_minor.xml#Source Code' -]; -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-2018.00.00.0/doc/det_grad_33.hpp.xml cppad-2019.02.00.0/doc/det_grad_33.hpp.xml --- cppad-2018.00.00.0/doc/det_grad_33.hpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_grad_33.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ - - - -Source: det_grad_33 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -det_grad_33.hppHeadings

- - - -
Source: det_grad_33
-# ifndef CPPAD_DET_GRAD_33_HPP -
-
# define CPPAD_DET_GRAD_33_HPP - -
# include <limits>
-# include <cppad/utility/near_equal.hpp>
-namespace CppAD {
-template <class Vector>
-     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<double>::epsilon() );
-
-          // use expansion by minors to compute the derivative by hand
-          double check[9];
-          check[0] = + ( x[4] * x[8] - x[5] * x[7] );
-          check[1] = - ( x[3] * x[8] - x[5] * x[6] );
-          check[2] = + ( x[3] * x[7] - x[4] * x[6] );
-          //
-          check[3] = - ( x[1] * x[8] - x[2] * x[7] );
-          check[4] = + ( x[0] * x[8] - x[2] * x[6] );
-          check[5] = - ( x[0] * x[7] - x[1] * x[6] );
-          //
-          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] );
-          //
-          for(size_t i = 0; i < 3 * 3; i++)
-               ok &= CppAD::NearEqual(check[i], g[i], eps, eps);
-
-          return ok;
-     }
-}
-# endif -
- - -
Input File: omh/det_grad_33_hpp.omh - - - diff -Nru cppad-2018.00.00.0/doc/_det_grad_33.hpp_xml.js cppad-2019.02.00.0/doc/_det_grad_33.hpp_xml.js --- cppad-2018.00.00.0/doc/_det_grad_33.hpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_grad_33.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_grad_33.xml', -'det_grad_33.hpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'det_grad_33.hpp.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-2018.00.00.0/doc/det_grad_33.xml cppad-2019.02.00.0/doc/det_grad_33.xml --- cppad-2018.00.00.0/doc/det_grad_33.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_grad_33.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,281 +0,0 @@ - - - -Check Gradient of Determinant of 3 by 3 matrix - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Check Gradient of Determinant of 3 by 3 matrix
-
-Syntax - -
- -# include <cppad/speed/det_grad_33.hpp>
-
- -ok = det_grad_33(xg) - - -
-
-Purpose -
-This routine can be used to check a method for computing the -gradient of the determinant of a matrix. - -
-
-Inclusion -
-The template function det_grad_33 is defined in the CppAD -namespace by including -the file cppad/speed/det_grad_33.hpp -(relative to the CppAD distribution directory). - -
-
-x -
-The argument -x - has prototype - -
-     const 
Vector &x
-
-. -It contains the elements of the matrix - -X - - - in row major order; i.e., - - -X -i -, -j - - -= -x -[ -i -* -3 -+ -j -] - - -
-g -
-The argument -g - has prototype - -
-     const 
Vector &g
-
-. -It contains the elements of the gradient of - - -det -( -X -) - - - in row major order; i.e., - - - -det -( -X -) - - -X -( -i -, -j -) - - -= -g -[ -i -* -3 -+ -j -] - - -
-Vector -
-If -y - is a -Vector - object, -it must support the syntax - -
-     
y[i]
-
-where -i - has type size_t with value less than 9. -This must return a double value corresponding to the i-th -element of the vector -y -. -This is the only requirement of the type -Vector -. - -
-
-ok -
-The return value -ok - has prototype - -
-     bool 
ok
-
-It is true, if the gradient -g - -passes the test and false otherwise. - - - -
-
-Source Code -
-The file -det_grad_33.hpp - -contains the source code for this template function. - - -
Input File: cppad/speed/det_grad_33.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_det_grad_33_xml.js cppad-2019.02.00.0/doc/_det_grad_33_xml.js --- cppad-2018.00.00.0/doc/_det_grad_33_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_grad_33_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_grad_33.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down0 = [ -'det_grad_33.hpp.xml' -]; -var list_current0 = [ -'det_grad_33.xml#Syntax', -'det_grad_33.xml#Purpose', -'det_grad_33.xml#Inclusion', -'det_grad_33.xml#x', -'det_grad_33.xml#g', -'det_grad_33.xml#Vector', -'det_grad_33.xml#ok', -'det_grad_33.xml#Source Code' -]; -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-2018.00.00.0/doc/det_of_minor.cpp.xml cppad-2019.02.00.0/doc/det_of_minor.cpp.xml --- cppad-2018.00.00.0/doc/det_of_minor.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_of_minor.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ - - - -Determinant of a Minor: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -det_of_minor.cppHeadings

- - - -
Determinant of a Minor: Example and Test
-
# include <vector>
-# include <cstddef>
-# include <cppad/speed/det_of_minor.hpp>
-
-bool det_of_minor()
-{     bool   ok = true;
-     size_t i;
-
-     // dimension of the matrix A
-     size_t m = 3;
-     // index vectors set so minor is the entire matrix A
-     std::vector<size_t> r(m + 1);
-     std::vector<size_t> c(m + 1);
-     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.,
-          2., 1., 2.
-     };
-     // construct vector a with the values of the matrix A
-     std::vector<double> a(data, data + 9);
-
-     // evaluate the determinant of A
-     size_t n   = m; // minor has same dimension as A
-     double det = CppAD::det_of_minor(a, m, n, r, c);
-
-     // check the value of the determinant of A
-     ok &= (det == (double) (1*(2*2-1*1) - 2*(3*2-1*2) + 3*(3*1-2*2)) );
-
-     // 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
-     n   = m - 1; // dimension of the minor
-     det = CppAD::det_of_minor(a, m, m-1, r, c);
-
-     // check the value of the determinant of the minor
-     ok &= (det == (double) (3*2-1*2) );
-
-     return ok;
-}
-
-
Input File: speed/example/det_of_minor.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_det_of_minor.cpp_xml.js cppad-2019.02.00.0/doc/_det_of_minor.cpp_xml.js --- cppad-2018.00.00.0/doc/_det_of_minor.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_of_minor.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_of_minor.xml', -'det_of_minor.cpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'det_of_minor.cpp.xml', -'det_of_minor.hpp.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-2018.00.00.0/doc/det_of_minor_c.xml cppad-2019.02.00.0/doc/det_of_minor_c.xml --- cppad-2018.00.00.0/doc/det_of_minor_c.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_of_minor_c.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,735 +0,0 @@ - - - -Determinant of a Minor - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -det_of_minor_c - -

-
Determinant of a Minor
-
-Syntax - -
- -d = det_of_minor(amnrc) - - -
-
-Purpose -
-returns the determinant of a minor of the matrix - -A - - - -using expansion by minors. -The elements of the - -n -× -n - - - minor - -M - - - -of the matrix - -A - - - are defined, -for - -i -= -0 -, - -, -n --1 - - - and - -j -= -0 -, - -, -n --1 - - -, by - - -M -i -, -j - - -= -A -R -( -i -) -, -C -( -j -) - - - - -where the functions - - -R -( -i -) - - - is defined by the argument r - and - - -C -( -j -) - - - is defined by the argument c -. -
-
-
This function -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 -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. - -
-
-Determinant of A -
-If the following conditions hold, the minor is the -entire matrix - -A - - - and hence det_of_minor -will return the determinant of - -A - - -: - -
  1. - - -n -= -m - - -. -
  2. - -for - -i -= -0 -, - -, -m --1 - - -, - -r -[ -i -] -= -i -+ -1 - - -, -and - -r -[ -m -] -= -0 - - -. -
  3. - -for - -j -= -0 -, - -, -m --1 - - -, - -c -[ -j -] -= -j -+ -1 - - -, -and - -c -[ -m -] -= -0 - - -. -
- - -
-
-a -
-The argument -a - has prototype - -
-     const double* 
a
-
-and is a vector with size - -m -* -m - - -. -The elements of the - -m -× -m - - - matrix - -A - - - are defined, -for - -i -= -0 -, - -, -m --1 - - - and - -j -= -0 -, - -, -m --1 - - -, by - - -A -i -, -j - - -= -a -[ -i -* -m -+ -j -] - - -
-m -
-The argument -m - has prototype - -
-     size_t 
m
-
-and is the size of the square matrix - -A - - -. - -
-
-n -
-The argument -n - has prototype - -
-     size_t 
n
-
-and is the size of the square minor - -M - - -. - -
-
-r -
-The argument -r - has prototype - -
-     size_t* 
r
-
-and is a vector with - -m -+ -1 - - - elements. -This vector defines the function - -R -( -i -) - - - -which specifies the rows of the minor - -M - - -. -To be specific, the function - -R -( -i -) - - - -for - -i -= -0 -, - -, -n --1 - - - is defined by - - - -R -( -0 -) - -= - -r -[ -m -] - -R -( -i -+ -1 -) - -= - -r -[ -R -( -i -) -] - - - -All the elements of -r - must have value -less than or equal -m -. -The elements of vector -r - are modified during the computation, -and restored to their original value before the return from -det_of_minor. - -
-
-c -
-The argument -c - has prototype - -
-     size_t* 
c
-
-and is a vector with - -m -+ -1 - - - elements -This vector defines the function - -C -( -i -) - - - -which specifies the rows of the minor - -M - - -. -To be specific, the function - -C -( -i -) - - - -for - -j -= -0 -, - -, -n --1 - - - is defined by - - - -C -( -0 -) - -= - -c -[ -m -] - -C -( -j -+ -1 -) - -= - -c -[ -C -( -j -) -] - - - -All the elements of -c - must have value -less than or equal -m -. -The elements of vector -c - are modified during the computation, -and restored to their original value before the return from -det_of_minor. - -
-
-d -
-The result -d - has prototype - -
-     double 
d
-
-and is equal to the determinant of the minor - -M - - -. - - -
-
-Source Code - -
double det_of_minor(
-     const double*        a  ,
-     size_t               m  ,
-     size_t               n  ,
-     size_t*              r  ,
-     size_t*              c  )
-{     size_t R0, Cj, Cj1, j;
-     double detM, M0j, detS;
-     int s;
-
-     R0 = r[m]; /* R(0) */
-     Cj = c[m]; /* C(j)    (case j = 0) */
-     Cj1 = m;   /* C(j-1)  (case j = 0) */
-
-     /* check for 1 by 1 case */
-     if( n == 1 ) return a[ R0 * m + Cj ];
-
-     /* initialize determinant of the minor M */
-     detM = 0.;
-
-     /* initialize sign of factor for neat sub-minor */
-     s = 1;
-
-     /* remove row with index 0 in M from all the sub-minors of M */
-     r[m] = r[R0];
-
-     /* for each column of M */
-     for(j = 0; j < n; j++)
-     {     /* element with index (0,j) in the minor M */
-          M0j = a[ R0 * m + Cj ];
-
-          /* remove column with index j in M to form next sub-minor S of M */
-          c[Cj1] = c[Cj];
-
-          /* compute determinant of the current sub-minor S */
-          detS = det_of_minor(a, m, n - 1, r, c);
-
-          /* restore column Cj to representation of M as a minor of A */
-          c[Cj1] = Cj;
-
-          /* include this sub-minor term in the summation */
-          if( s > 0 )
-               detM = detM + M0j * detS;
-          else     detM = detM - M0j * detS;
-
-          /* advance to neat column of M */
-          Cj1 = Cj;
-          Cj  = c[Cj];
-          s   = - s;
-     }
-
-     /* restore row zero to the minor representation for M */
-     r[m] = R0;
-
-     /* return the determinant of the minor M */
-     return detM;
-}
- -
Input File: test_more/compare_c/det_by_minor.c - - - diff -Nru cppad-2018.00.00.0/doc/_det_of_minor_c_xml.js cppad-2019.02.00.0/doc/_det_of_minor_c_xml.js --- cppad-2018.00.00.0/doc/_det_of_minor_c_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_of_minor_c_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'compare_c.xml', -'det_of_minor_c.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', -'directory.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 = [ -'det_of_minor_c.xml', -'det_by_minor_c.xml', -'uniform_01_c.xml', -'correct_det_by_minor_c.xml', -'repeat_det_by_minor_c.xml', -'elapsed_seconds_c.xml', -'time_det_by_minor_c.xml', -'main_compare_c.xml' -]; -var list_current0 = [ -'det_of_minor_c.xml#Syntax', -'det_of_minor_c.xml#Purpose', -'det_of_minor_c.xml#Determinant of A', -'det_of_minor_c.xml#a', -'det_of_minor_c.xml#m', -'det_of_minor_c.xml#n', -'det_of_minor_c.xml#r', -'det_of_minor_c.xml#c', -'det_of_minor_c.xml#d', -'det_of_minor_c.xml#Source Code' -]; -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-2018.00.00.0/doc/det_of_minor.hpp.xml cppad-2019.02.00.0/doc/det_of_minor.hpp.xml --- cppad-2018.00.00.0/doc/det_of_minor.hpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_of_minor.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,156 +0,0 @@ - - - -Source: det_of_minor - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -det_of_minor.hppHeadings

-
Source: det_of_minor
-# ifndef CPPAD_DET_OF_MINOR_HPP -
-
# define CPPAD_DET_OF_MINOR_HPP - -
# include <vector>
-# include <cstddef>
-
-namespace CppAD { // BEGIN CppAD namespace
-template <class Scalar>
-Scalar det_of_minor(
-     const std::vector<Scalar>& a  ,
-     size_t                     m  ,
-     size_t                     n  ,
-     std::vector<size_t>&       r  ,
-     std::vector<size_t>&       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)
-
-     // check for 1 by 1 case
-     if( n == 1 ) return a[ R0 * m + Cj ];
-
-     // initialize determinant of the minor M
-     Scalar detM = Scalar(0);
-
-     // initialize sign of factor for next sub-minor
-     int s = 1;
-
-     // remove row with index 0 in M from all the sub-minors of M
-     r[m] = r[R0];
-
-     // for each column of M
-     for(size_t j = 0; j < n; j++)
-     {     // element with index (0,j) in the minor M
-          Scalar M0j = a[ R0 * m + Cj ];
-
-          // remove column with index j in M to form next sub-minor S of M
-          c[Cj1] = c[Cj];
-
-          // compute determinant of the current sub-minor S
-          Scalar detS = det_of_minor(a, m, n - 1, r, c);
-
-          // restore column Cj to represenation of M as a minor of A
-          c[Cj1] = Cj;
-
-          // include this sub-minor term in the summation
-          if( s > 0 )
-               detM = detM + M0j * detS;
-          else     detM = detM - M0j * detS;
-
-          // advance to next column of M
-          Cj1 = Cj;
-          Cj  = c[Cj];
-          s   = - s;
-     }
-
-     // restore row zero to the minor representation for M
-     r[m] = R0;
-
-     // return the determinant of the minor M
-     return detM;
-}
-} // END CppAD namespace
-# endif -
- - -
Input File: omh/det_of_minor_hpp.omh - - - diff -Nru cppad-2018.00.00.0/doc/_det_of_minor.hpp_xml.js cppad-2019.02.00.0/doc/_det_of_minor.hpp_xml.js --- cppad-2018.00.00.0/doc/_det_of_minor.hpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_of_minor.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_of_minor.xml', -'det_of_minor.hpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'det_of_minor.cpp.xml', -'det_of_minor.hpp.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-2018.00.00.0/doc/det_of_minor.xml cppad-2019.02.00.0/doc/det_of_minor.xml --- cppad-2018.00.00.0/doc/det_of_minor.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/det_of_minor.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,820 +0,0 @@ - - - -Determinant of a Minor - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - -
Determinant of a Minor
-
-Syntax - -
- -# include <cppad/speed/det_of_minor.hpp>
-
- -d = det_of_minor(amnrc) - - - -
-
-Inclusion -
-The template function det_of_minor is defined in the CppAD -namespace by including -the file cppad/speed/det_of_minor.hpp -(relative to the CppAD distribution directory). - -
-
-Purpose -
-This template function -returns the determinant of a minor of the matrix - -A - - - -using expansion by minors. -The elements of the - -n -× -n - - - minor - -M - - - -of the matrix - -A - - - are defined, -for - -i -= -0 -, - -, -n --1 - - - and - -j -= -0 -, - -, -n --1 - - -, by - - -M -i -, -j - - -= -A -R -( -i -) -, -C -( -j -) - - - - -where the functions - - -R -( -i -) - - - is defined by the argument r - and - - -C -( -j -) - - - is defined by the argument c -. -
-
-
This template function -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 -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. - -
-
-Determinant of A -
-If the following conditions hold, the minor is the -entire matrix - -A - - - and hence det_of_minor -will return the determinant of - -A - - -: - -
  1. - - -n -= -m - - -. -
  2. - -for - -i -= -0 -, - -, -m --1 - - -, - -r -[ -i -] -= -i -+ -1 - - -, -and - -r -[ -m -] -= -0 - - -. -
  3. - -for - -j -= -0 -, - -, -m --1 - - -, - -c -[ -j -] -= -j -+ -1 - - -, -and - -c -[ -m -] -= -0 - - -. -
- - -
-
-a -
-The argument -a - has prototype - -
-     const std::vector<
Scalar>& a
-
-and is a vector with size - -m -* -m - - - -(see description of Scalar - below). -The elements of the - -m -× -m - - - matrix - -A - - - are defined, -for - -i -= -0 -, - -, -m --1 - - - and - -j -= -0 -, - -, -m --1 - - -, by - - -A -i -, -j - - -= -a -[ -i -* -m -+ -j -] - - -
-m -
-The argument -m - has prototype - -
-     size_t 
m
-
-and is the number of rows (and columns) in the square matrix - -A - - -. - -
-
-n -
-The argument -n - has prototype - -
-     size_t 
n
-
-and is the number of rows (and columns) in the square minor - -M - - -. - -
-
-r -
-The argument -r - has prototype - -
-     std::vector<size_t>& 
r
-
-and is a vector with - -m -+ -1 - - - elements. -This vector defines the function - -R -( -i -) - - - -which specifies the rows of the minor - -M - - -. -To be specific, the function - -R -( -i -) - - - -for - -i -= -0 -, - -, -n --1 - - - is defined by - - - -R -( -0 -) - -= - -r -[ -m -] - -R -( -i -+ -1 -) - -= - -r -[ -R -( -i -) -] - - - -All the elements of -r - must have value -less than or equal -m -. -The elements of vector -r - are modified during the computation, -and restored to their original value before the return from -det_of_minor. - -
-
-c -
-The argument -c - has prototype - -
-     std::vector<size_t>& 
c
-
-and is a vector with - -m -+ -1 - - - elements -This vector defines the function - -C -( -i -) - - - -which specifies the rows of the minor - -M - - -. -To be specific, the function - -C -( -i -) - - - -for - -j -= -0 -, - -, -n --1 - - - is defined by - - - -C -( -0 -) - -= - -c -[ -m -] - -C -( -j -+ -1 -) - -= - -c -[ -C -( -j -) -] - - - -All the elements of -c - must have value -less than or equal -m -. -The elements of vector -c - are modified during the computation, -and restored to their original value before the return from -det_of_minor. - -
-
-d -
-The result -d - has prototype - -
-     
Scalar d
-
-and is equal to the determinant of the minor - -M - - -. - -
-
-Scalar -
-If -x - and -y - are objects of type -Scalar - -and -i - is an object of type int, -the -Scalar - must support the following operations: - -
- -Syntax - - Description - - Result Type -
- - -Scalar x - - - default constructor for -Scalar - object. -
- - -x = i - - - set value of -x - to current value of -i - -
- - -x = y - - - set value of -x - to current value of -y - -
- - -x + y - - - value of -x - plus -y - - - -Scalar - -
- - -x - y - - - value of -x - minus -y - - - -Scalar - -
- - -x * y - - - value of -x - times value of -y - - - -Scalar - -
-
-Example -
-The file -det_of_minor.cpp - -contains an example and test of det_of_minor.hpp. -It returns true if it succeeds and false otherwise. - -
-
-Source Code -
-The file -det_of_minor.hpp - -contains the source for this template function. - - - -
Input File: cppad/speed/det_of_minor.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_det_of_minor_xml.js cppad-2019.02.00.0/doc/_det_of_minor_xml.js --- cppad-2018.00.00.0/doc/_det_of_minor_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_det_of_minor_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'det_of_minor.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down0 = [ -'det_of_minor.cpp.xml', -'det_of_minor.hpp.xml' -]; -var list_current0 = [ -'det_of_minor.xml#Syntax', -'det_of_minor.xml#Inclusion', -'det_of_minor.xml#Purpose', -'det_of_minor.xml#Determinant of A', -'det_of_minor.xml#a', -'det_of_minor.xml#m', -'det_of_minor.xml#n', -'det_of_minor.xml#r', -'det_of_minor.xml#c', -'det_of_minor.xml#d', -'det_of_minor.xml#Scalar', -'det_of_minor.xml#Example', -'det_of_minor.xml#Source Code' -]; -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-2018.00.00.0/doc/directory.xml cppad-2019.02.00.0/doc/directory.xml --- cppad-2018.00.00.0/doc/directory.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/directory.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,244 +0,0 @@ - - - -Directory Structure - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -directory - -

- - - -
Directory Structure
-A brief description of each of the CppAD directories is provided below: - -
-
-Distribution Directory -
-The following table lists the sub-directories of the -distribution directory -: - -
- -bin - - Scripts used for CppAD development. -
- -bug - - Used to create a simple CppAD bug report or test. -
- -build - - Used to build the libraries, examples, and tests. -
- -cppad - - The CppAD include directory. -
- -cppad_ipopt - - Example and tests for the deprecated cppad_ipopt library. -
- -cppad_lib - - Source code corresponding to the CppAD library. -
- -doc - - The program bin/run_omhelp.sh puts the user documentation here. -
- -doxydoc - - The program bin/run_doxygen.sh puts its developer documentation here. -
- -example - - Source code for the CppAD examples. -
- -introduction - - Source code for the CppAD introduction. -
- -omh - - Contains files that are only used for documentation. -
- -pkgconfig - - Contains the CppAD pkg-config information. -
- -speed - - The CppAD speed tests. -
- -test_more - - Tests that are not part of the documentation. -
-
-Example Directory -
-The following table lists the sub-directories of the example -directory. - - -
- -atomic - - atomic - function examples. -
- -deprecated - - examples for functions that have been deprecated -. -
- -general - - general purpose examples. -
- -get_started - - a good place to get started using CppAD. -
- -ipopt_solve - - examples using the ipopt_solve - interface to CppAD. -
- -multi_thread - - CppAD multi_threading - examples. -
- -optimize - - examples using the optimize - operation. -
- -print_for - - examples that used the PrintFor - operation. -
- -sparse - - examples using sparsity_patterns - and - sparse_derivatives -. -
- -utility - - example using the CppAD utilities -. -
- -
Input File: omh/appendix/directory.omh - - - diff -Nru cppad-2018.00.00.0/doc/_directory_xml.js cppad-2019.02.00.0/doc/_directory_xml.js --- cppad-2018.00.00.0/doc/_directory_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_directory_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'directory.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', -'directory.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 = [ -'directory.xml#Distribution Directory', -'directory.xml#Example Directory' -]; -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-2018.00.00.0/doc/discrete.xml cppad-2019.02.00.0/doc/discrete.xml --- cppad-2018.00.00.0/doc/discrete.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/discrete.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,340 +0,0 @@ - - - -Discrete AD Functions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Discrete AD Functions
-
-Syntax - -
- -CPPAD_DISCRETE_FUNCTION(Basename)
-
- -y  = name(x)
-
- -ay = name(ax)
-
-
-Purpose -
-Record the evaluation of a discrete function as part -of an -AD<Base> - -operation sequence -. -The value of a discrete function can depend on the -independent variables -, -but its derivative is identically zero. -For example, suppose that the integer part of -a variable - -x - is the -index into an array of values. - -
-
-Base -
-This is the -base type - -corresponding to the operations sequence; -i.e., use of the -name - with arguments of type - -AD<Base> - can be recorded in an operation sequence. - -
-
-name -
-This is the name of the function (as it is used in the source code). -The user must provide a version of -name - -where the argument has type -Base -. -CppAD uses this to create a version of -name - -where the argument has type -AD<Base> -. - -
-
-x -
-The argument -x - has prototype - -
-     const 
Basex
-
-It is the value at which the user provided version of -name - -is to be evaluated. - -
-
-y -
-The result -y - has prototype - -
-     
Base y
-
-It is the return value for the user provided version of -name -. - -
-
-ax -
-The argument -ax - has prototype - -
-     const AD<
Base>& ax
-
-It is the value at which the CppAD provided version of -name - -is to be evaluated. - -
-
-ay -
-The result -ay - has prototype - -
-     AD<
Baseay
-
-It is the return value for the CppAD provided version of -name -. - - -
-
-Create AD Version -
-The preprocessor macro invocation - -
-     CPPAD_DISCRETE_FUNCTION(
Basename)
-
-defines the -AD<Base> - version of -name -. -This can be with in a namespace (not the CppAD namespace) -but must be outside of any routine. - -
-
-Operation Sequence -
-This is an AD of -Base - -atomic operation - -and hence is part of the current -AD of -Base - -operation sequence -. - -
-
-Derivatives -
-During a zero order Forward - operation, -an ADFun - object will compute the value of -name - -using the user provided -Base - version of this routine. -All the derivatives of -name - will be evaluated as zero. - -
-
-Parallel Mode -
-The first call to - -
-     
ay = name(ax)
-
-must not be in parallel - execution mode. - - -
-
-Example - -
-The file -tape_index.cpp - -contains an example and test that uses a discrete function -to vary an array index during Forward - mode calculations. -The file -interp_onetape.cpp - -contains an example and test that uses discrete -functions to avoid retaping a calculation that requires interpolation. -(The file -interp_retape.cpp - -shows how interpolation can be done with retaping.) - -
-
-CppADCreateDiscrete Deprecated 2007-07-28 -
-The preprocessor symbol CppADCreateDiscrete -is defined to be the same as CPPAD_DISCRETE_FUNCTION -but its use is deprecated. - - -
Input File: cppad/core/discrete.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_discrete_xml.js cppad-2019.02.00.0/doc/_discrete_xml.js --- cppad-2018.00.00.0/doc/_discrete_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_discrete_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'discrete.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 = [ -'tape_index.cpp.xml', -'interp_onetape.cpp.xml', -'interp_retape.cpp.xml' -]; -var list_current0 = [ -'discrete.xml#Syntax', -'discrete.xml#Purpose', -'discrete.xml#Base', -'discrete.xml#name', -'discrete.xml#x', -'discrete.xml#y', -'discrete.xml#ax', -'discrete.xml#ay', -'discrete.xml#Create AD Version', -'discrete.xml#Operation Sequence', -'discrete.xml#Derivatives', -'discrete.xml#Parallel Mode', -'discrete.xml#Example', -'discrete.xml#CppADCreateDiscrete Deprecated 2007-07-28' -]; -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-2018.00.00.0/doc/div.cpp.xml cppad-2019.02.00.0/doc/div.cpp.xml --- cppad-2018.00.00.0/doc/div.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/div.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ - - - -AD Binary Division: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -div.cppHeadings

-
AD Binary Division: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool Div(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * 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);
-
-     // some binary division operations
-     AD<double> a = x[0] / 1.; // AD<double> / double
-     AD<double> b = a  / 2;    // AD<double> / int
-     AD<double> c = 3. / b;    // double     / AD<double>
-     AD<double> d = 4  / c;    // int        / AD<double>
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = (x[0] * x[0]) / d;   // AD<double> / AD<double>
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0], x0*x0*3.*2.*1./(4.*x0), eps99, eps99);
-
-     // forward computation of partials 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], 3.*2.*1./4., eps99, eps99);
-
-     // 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], 3.*2.*1./4., eps99, eps99);
-
-     // use a VecAD<Base>::reference object with division
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero] = d;
-     AD<double> result = (x[0] * x[0]) / v[zero];
-     ok     &= (result == y[0]);
-
-     return ok;
-}
-
-
-
Input File: example/general/div.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_div.cpp_xml.js cppad-2019.02.00.0/doc/_div.cpp_xml.js --- cppad-2018.00.00.0/doc/_div.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_div.cpp_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', -'ad.xml', -'advalued.xml', -'arithmetic.xml', -'ad_binary.xml', -'div.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down1 = [ -'add.cpp.xml', -'sub.cpp.xml', -'mul.cpp.xml', -'div.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-2018.00.00.0/doc/div_eq.cpp.xml cppad-2019.02.00.0/doc/div_eq.cpp.xml --- cppad-2018.00.00.0/doc/div_eq.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/div_eq.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ - - - -AD Compound Assignment Division: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -div_eq.cppHeadings

-
AD Compound Assignment Division: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool DivEq(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t  n = 1;
-     double x0 = .5;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0]      = x0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     // range space vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = x[0] * x[0];  // initial value
-     y[0] /= 2;           // AD<double> /= int
-     y[0] /= 4.;          // AD<double> /= double
-     y[1] = y[0] /= x[0]; // use the result of a compound assignment
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0] , x0*x0/(2.*4.*x0), eps99, eps99);
-     ok &= NearEqual(y[1] ,             y[0], eps99, eps99);
-
-     // forward computation of partials 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./8., eps99, eps99);
-     ok   &= NearEqual(dy[1], 1./8., eps99, eps99);
-
-     // reverse computation of derivative of y[0]
-     CPPAD_TESTVECTOR(double)  w(m);
-     CPPAD_TESTVECTOR(double) dw(n);
-     w[0]  = 1.;
-     w[1]  = 0.;
-     dw    = f.Reverse(1, w);
-     ok   &= NearEqual(dw[0], 1./8., eps99, eps99);
-
-     // use a VecAD<Base>::reference object with computed division
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     AD<double> result = 2;
-     v[zero] = 1;
-     result /= v[zero];
-     ok     &= (result == 2);
-
-     return ok;
-}
-
-
-
Input File: example/general/div_eq.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_div_eq.cpp_xml.js cppad-2019.02.00.0/doc/_div_eq.cpp_xml.js --- cppad-2018.00.00.0/doc/_div_eq.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_div_eq.cpp_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', -'ad.xml', -'advalued.xml', -'arithmetic.xml', -'compound_assign.xml', -'div_eq.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down1 = [ -'addeq.cpp.xml', -'sub_eq.cpp.xml', -'mul_eq.cpp.xml', -'div_eq.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-2018.00.00.0/doc/double_det_lu.cpp.xml cppad-2019.02.00.0/doc/double_det_lu.cpp.xml --- cppad-2018.00.00.0/doc/double_det_lu.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/double_det_lu.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ - - - -Double Speed: Determinant Using Lu Factorization - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -double_det_lu.cpp - -

-
Double Speed: Determinant Using Lu Factorization
-
-Specifications -
-See link_det_lu -. - -
-
-Implementation - -
# include <cppad/utility/vector.hpp>
-# include <cppad/speed/det_by_lu.hpp>
-# include <cppad/speed/uniform_01.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_det_lu(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     CppAD::vector<double>           &matrix   ,
-     CppAD::vector<double>           &det      )
-{
-     if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"])
-          return false;
-     // -----------------------------------------------------
-     // setup
-     CppAD::det_by_lu<double>  Det(size);
-     size_t n = size * size; // number of independent variables
-
-     // ------------------------------------------------------
-
-     while(repeat--)
-     {     // get the next matrix
-          CppAD::uniform_01(n, matrix);
-
-          // computation of the determinant
-          det[0] = Det(matrix);
-     }
-     return true;
-}
- -
Input File: speed/double/det_lu.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_double_det_lu.cpp_xml.js cppad-2019.02.00.0/doc/_double_det_lu.cpp_xml.js --- cppad-2018.00.00.0/doc/_double_det_lu.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_double_det_lu.cpp_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', -'speed.xml', -'speed_double.xml', -'double_det_lu.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'double_det_minor.cpp.xml', -'double_det_lu.cpp.xml', -'double_mat_mul.cpp.xml', -'double_ode.cpp.xml', -'double_poly.cpp.xml', -'double_sparse_hessian.cpp.xml', -'double_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'double_det_lu.cpp.xml#Specifications', -'double_det_lu.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/double_det_minor.cpp.xml cppad-2019.02.00.0/doc/double_det_minor.cpp.xml --- cppad-2018.00.00.0/doc/double_det_minor.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/double_det_minor.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ - - - -Double Speed: Determinant by Minor Expansion - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -double_det_minor.cpp - -

-
Double Speed: Determinant by Minor Expansion
-
-Specifications -
-See link_det_minor -. - -
-
-Implementation - - -
# include <cppad/utility/vector.hpp>
-# include <cppad/speed/det_by_minor.hpp>
-# include <cppad/speed/uniform_01.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_det_minor(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &matrix   ,
-     CppAD::vector<double>     &det      )
-{
-     if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"])
-          return false;
-     // -----------------------------------------------------
-     // setup
-     CppAD::det_by_minor<double>   Det(size);
-     size_t n = size * size; // number of independent variables
-
-     // ------------------------------------------------------
-     while(repeat--)
-     {     // get the next matrix
-          CppAD::uniform_01(n, matrix);
-
-          // computation of the determinant
-          det[0] = Det(matrix);
-     }
-     return true;
-}
- -
Input File: speed/double/det_minor.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_double_det_minor.cpp_xml.js cppad-2019.02.00.0/doc/_double_det_minor.cpp_xml.js --- cppad-2018.00.00.0/doc/_double_det_minor.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_double_det_minor.cpp_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', -'speed.xml', -'speed_double.xml', -'double_det_minor.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'double_det_minor.cpp.xml', -'double_det_lu.cpp.xml', -'double_mat_mul.cpp.xml', -'double_ode.cpp.xml', -'double_poly.cpp.xml', -'double_sparse_hessian.cpp.xml', -'double_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'double_det_minor.cpp.xml#Specifications', -'double_det_minor.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/double_mat_mul.cpp.xml cppad-2019.02.00.0/doc/double_mat_mul.cpp.xml --- cppad-2018.00.00.0/doc/double_mat_mul.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/double_mat_mul.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ - - - -CppAD Speed: Matrix Multiplication (Double Version) - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -double_mat_mul.cpp - -

-
CppAD Speed: Matrix Multiplication (Double Version)
-
-Specifications -
-See link_mat_mul -. - -
-
-Implementation - -
# include <cppad/cppad.hpp>
-# include <cppad/speed/mat_sum_sq.hpp>
-# include <cppad/speed/uniform_01.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_mat_mul(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     CppAD::vector<double>&           x        ,
-     CppAD::vector<double>&           z        ,
-     CppAD::vector<double>&           dz
-)
-{
-     if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"])
-          return false;
-     // -----------------------------------------------------
-     size_t n = size * size; // number of independent variables
-     CppAD::vector<double> y(n);
-
-     while(repeat--)
-     {     // get the next matrix
-          CppAD::uniform_01(n, x);
-
-          // do computation
-          mat_sum_sq(size, x, y, z);
-
-     }
-     return true;
-}
- -
Input File: speed/double/mat_mul.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_double_mat_mul.cpp_xml.js cppad-2019.02.00.0/doc/_double_mat_mul.cpp_xml.js --- cppad-2018.00.00.0/doc/_double_mat_mul.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_double_mat_mul.cpp_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', -'speed.xml', -'speed_double.xml', -'double_mat_mul.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'double_det_minor.cpp.xml', -'double_det_lu.cpp.xml', -'double_mat_mul.cpp.xml', -'double_ode.cpp.xml', -'double_poly.cpp.xml', -'double_sparse_hessian.cpp.xml', -'double_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'double_mat_mul.cpp.xml#Specifications', -'double_mat_mul.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/double_ode.cpp.xml cppad-2019.02.00.0/doc/double_ode.cpp.xml --- cppad-2018.00.00.0/doc/double_ode.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/double_ode.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ - - - -Double Speed: Ode Solution - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -double_ode.cpp - -

-
Double Speed: Ode Solution
-
-Specifications -
-See link_ode -. - -
-
-Implementation - - -
# include <cstring>
-# include <cppad/utility/vector.hpp>
-# include <cppad/speed/ode_evaluate.hpp>
-# include <cppad/speed/uniform_01.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_ode(
-     size_t                     size       ,
-     size_t                     repeat     ,
-     CppAD::vector<double>      &x         ,
-     CppAD::vector<double>      &jacobian
-)
-{
-     if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"])
-          return false;
-     // -------------------------------------------------------------
-     // setup
-     assert( x.size() == size );
-
-     size_t n = size;
-
-     size_t m = 0;
-     CppAD::vector<double> f(n);
-
-     while(repeat--)
-     {     // choose next x value
-          uniform_01(n, x);
-
-          // evaluate function
-          CppAD::ode_evaluate(x, m, f);
-
-     }
-     size_t i;
-     for(i = 0; i < n; i++)
-          jacobian[i] = f[i];
-     return true;
-}
- -
Input File: speed/double/ode.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_double_ode.cpp_xml.js cppad-2019.02.00.0/doc/_double_ode.cpp_xml.js --- cppad-2018.00.00.0/doc/_double_ode.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_double_ode.cpp_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', -'speed.xml', -'speed_double.xml', -'double_ode.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'double_det_minor.cpp.xml', -'double_det_lu.cpp.xml', -'double_mat_mul.cpp.xml', -'double_ode.cpp.xml', -'double_poly.cpp.xml', -'double_sparse_hessian.cpp.xml', -'double_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'double_ode.cpp.xml#Specifications', -'double_ode.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/double_poly.cpp.xml cppad-2019.02.00.0/doc/double_poly.cpp.xml --- cppad-2018.00.00.0/doc/double_poly.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/double_poly.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ - - - -Double Speed: Evaluate a Polynomial - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -double_poly.cpp - -

-
Double Speed: Evaluate a Polynomial
-
-Specifications -
-See link_poly -. - -
-
-Implementation - - -
# include <cppad/cppad.hpp>
-# include <cppad/speed/uniform_01.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_poly(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &a        ,  // coefficients of polynomial
-     CppAD::vector<double>     &z        ,  // polynomial argument value
-     CppAD::vector<double>     &p        )  // second derivative w.r.t z
-{
-     if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"])
-          return false;
-     // -----------------------------------------------------
-     // setup
-
-     // ------------------------------------------------------
-     while(repeat--)
-     {     // get the next argument value
-          CppAD::uniform_01(1, z);
-
-          // evaluate the polynomial at the new argument value
-          p[0] = CppAD::Poly(0, a, z[0]);
-     }
-     return true;
-}
- -
Input File: speed/double/poly.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_double_poly.cpp_xml.js cppad-2019.02.00.0/doc/_double_poly.cpp_xml.js --- cppad-2018.00.00.0/doc/_double_poly.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_double_poly.cpp_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', -'speed.xml', -'speed_double.xml', -'double_poly.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'double_det_minor.cpp.xml', -'double_det_lu.cpp.xml', -'double_mat_mul.cpp.xml', -'double_ode.cpp.xml', -'double_poly.cpp.xml', -'double_sparse_hessian.cpp.xml', -'double_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'double_poly.cpp.xml#Specifications', -'double_poly.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/double_sparse_hessian.cpp.xml cppad-2019.02.00.0/doc/double_sparse_hessian.cpp.xml --- cppad-2018.00.00.0/doc/double_sparse_hessian.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/double_sparse_hessian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,152 +0,0 @@ - - - -Double Speed: Sparse Hessian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -double_sparse_hessian.cpp - -

-
Double Speed: Sparse Hessian
-
-Specifications -
-See link_sparse_hessian -. - -
-
-Implementation - - -
# include <cppad/utility/vector.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/speed/sparse_hes_fun.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_sparse_hessian(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     const CppAD::vector<size_t>&     row      ,
-     const CppAD::vector<size_t>&     col      ,
-     CppAD::vector<double>&           x        ,
-     CppAD::vector<double>&           hessian  ,
-     size_t&                          n_sweep  )
-{
-     if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]||global_option["boolsparsity"])
-          return false;
-     // -----------------------------------------------------
-     // setup
-     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
-     vector<double> y(m);       // function value
-
-     // choose a value for x
-     CppAD::uniform_01(n, x);
-
-     // ------------------------------------------------------
-
-     while(repeat--)
-     {
-          // computation of the function
-          CppAD::sparse_hes_fun<double>(n, x, row, col, order, y);
-     }
-     hessian[0] = y[0];
-
-     return true;
-}
- -
Input File: speed/double/sparse_hessian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_double_sparse_hessian.cpp_xml.js cppad-2019.02.00.0/doc/_double_sparse_hessian.cpp_xml.js --- cppad-2018.00.00.0/doc/_double_sparse_hessian.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_double_sparse_hessian.cpp_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', -'speed.xml', -'speed_double.xml', -'double_sparse_hessian.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'double_det_minor.cpp.xml', -'double_det_lu.cpp.xml', -'double_mat_mul.cpp.xml', -'double_ode.cpp.xml', -'double_poly.cpp.xml', -'double_sparse_hessian.cpp.xml', -'double_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'double_sparse_hessian.cpp.xml#Specifications', -'double_sparse_hessian.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/double_sparse_jacobian.cpp.xml cppad-2019.02.00.0/doc/double_sparse_jacobian.cpp.xml --- cppad-2018.00.00.0/doc/double_sparse_jacobian.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/double_sparse_jacobian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,152 +0,0 @@ - - - -Double Speed: Sparse Jacobian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -double_sparse_jacobian.cpp - -

-
Double Speed: Sparse Jacobian
-
-Specifications -
-See link_sparse_jacobian -. - -
-
-Implementation - - -
# include <cppad/utility/vector.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/speed/sparse_jac_fun.hpp>
-
-// Note that CppAD uses global_option["memory"] at the main program level
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_sparse_jacobian(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     size_t                           m        ,
-     const CppAD::vector<size_t>&     row      ,
-     const CppAD::vector<size_t>&     col      ,
-           CppAD::vector<double>&     x        ,
-           CppAD::vector<double>&     jacobian ,
-           size_t&                    n_sweep  )
-{
-     if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]||global_option["boolsparsity"])
-          return false;
-     // -----------------------------------------------------
-     // setup
-     using CppAD::vector;
-     size_t i;
-     size_t order = 0;          // order for computing function value
-     size_t n     = size;       // argument space dimension
-     vector<double> yp(m);      // function value yp = f(x)
-
-     // ------------------------------------------------------
-     while(repeat--)
-     {     // choose a value for x
-          CppAD::uniform_01(n, x);
-
-          // computation of the function
-          CppAD::sparse_jac_fun<double>(m, n, x, row, col, order, yp);
-     }
-     for(i = 0; i < m; i++)
-          jacobian[i] = yp[i];
-
-     return true;
-}
- -
Input File: speed/double/sparse_jacobian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_double_sparse_jacobian.cpp_xml.js cppad-2019.02.00.0/doc/_double_sparse_jacobian.cpp_xml.js --- cppad-2018.00.00.0/doc/_double_sparse_jacobian.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_double_sparse_jacobian.cpp_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', -'speed.xml', -'speed_double.xml', -'double_sparse_jacobian.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'double_det_minor.cpp.xml', -'double_det_lu.cpp.xml', -'double_mat_mul.cpp.xml', -'double_ode.cpp.xml', -'double_poly.cpp.xml', -'double_sparse_hessian.cpp.xml', -'double_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'double_sparse_jacobian.cpp.xml#Specifications', -'double_sparse_jacobian.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/download.xml cppad-2019.02.00.0/doc/download.xml --- cppad-2018.00.00.0/doc/download.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/download.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,383 +0,0 @@ - - - -Download The CppAD Source Code - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -download - -

- - - - - -
Download The CppAD Source Code
-
-Purpose -
-CppAD is an include file library and you therefore need the source -code to use it. -This section discusses how to download the different versions of CppAD. - -
-
-Distribution Directory -
-We refer to the CppAD source directory created by the download instructions -below as the distribution directory. -To be specific, the distribution directory contains the file -cppad/cppad.hpp. - -
-
-Version -
-A CppAD -version - number has the following fields: - -yyyy - is four decimal digits denoting a year, - -mm - is two decimal digits denoting a month, -and -dd - is two decimal digits denoting a day. -For example -version = 20160101 - corresponds to January 1, 2016. - -
-
-Release -
-Special versions corresponding to the beginning of each year -have -mm - and -dd - equal to zero. -These version numbers are combined with release numbers denoted by - -rel -. -Higher release numbers correspond to more bug fixes. -For example - -version.rel = 20160000.0 - corresponds to the first release -of the version for 2016, -20160000.1 corresponds to the first bug fix for 2016. - -
-
-License -
-We use -lic - to denote the licence corresponding to an archived -version of CppAD. -The GNU General Public License is denoted by -lic = gpl - -and the Eclipse Public License is denoted by -lic = epl -. - - -
-
-Compressed Archives -
-The Coin compressed archives have the -documentation built into them. -If you downloading an old version using another method; see -building documentation -. - - -
-
-Coin -
-The compressed archive names on the -Coin download page - -have one of the following formats: - -
-     cppad-
version.rel.lic.tgz
-     cppad-
version.lic.tgz
-
-In Unix, you can extract these compressed archives using tar. -For example, - -
-     tar -xzf cppad-
version.rel.lic.tgz
-
-No matter what the format of the name, the corresponding distribution -directory is -cppad-version -. -To see that the extraction has been done correctly, -check for the following file: - -
-     cppad-
version/cppad/cppad.hpp
-
-
-Github -
-The compressed archive names on the -Github download page - -have the format - -
-     cppad-
version.rel.tgz
-
-These archives correspond to the Eclipse Public License. - - -
-
-Source Code Control -
-These methods only provide the Eclipse Public License -version of CppAD. - -
-
-Git -
-CppAD source code development is current done using git -You can a git clone of the current version using the command - -
-    git clone https://github.com/coin-or/CppAD.git cppad.git
-
-This procedure requires that -the git - -is installed on your system. - -
-
-Subversion -
-A subversion copy of the source code is kept on the Coin web site. -You can obtain this subversion copy using the command - -
-     svn checkout https://projects.coin-or.org/svn/CppAD/trunk cppad.svn/trunk
-
-This procedure requires that -the subversion - program -is installed on your system. - - -
-
-Monthly Versions -
-Monthly versions of the compressed tar files are available on the -Coin download page -. -These are kept until the end of the current year, -when the next release is created. -The monthly versions have the form - -
-     cppad-
yyyy0101.lic.tgz
-
-
-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 7z.exe, cmake.exe, and nmake.exe are you -your execution path, you will not need to specify their paths below.) - -
  1. -Download and install the open source program -http://www.7-zip.org -. -
  2. - -Download and install the Visual Studio Express; for example -Visual Studio 2013 - -
  3. - -In a command window, execute the following commands: - -
    -     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: - -
    -     
    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
    -
    -
  4. -Use the following commands to extract the distribution from the -compressed archive: - -
    -     7z x cppad-
    version.lic.tgz
    -     7z x cppad-
    version.lic.tar
    -
    -
  5. -To see if this has been done correctly, check for the following file: - -
    -     cppad-
    version\cppad\cppad.hpp
    -
    -
  6. -The commands below are optional. -They run the CppAD tests using the default cmake - settings -(except for the generator - option) - -
    -     mkdir build
    -     cd build
    -     cmake -G "NMake Makefiles" ..
    -     nmake check
    -
    -
-
-Install Instructions -
-The install - instructions on this web site correspond to the -current version of CppAD. -If you are using an old version of CppAD -these instructions may work. -If you have trouble (or just to be careful), -you should follow the instructions in -the doc subdirectory of the distribution directory. -If there is no such documentation, you can build it; see -building documentation -. - -
-
-Building Documentation -
-If you are using one of these download methods, -you can build the documentation to get the corresponding install instructions. -The documentation for CppAD is built from the source code files using -OMhelp -. -You will need to install the omhelp command so that -
 
-     which omhelp
-
-shows it is in your path. -Once you have done this, -in the distribution directory execute the following command: - -
-     bin/run_omhelp.sh htm
-
-You will then be able to follow the install instructions in -the doc subdirectory of the distribution directory. - - - -
Input File: omh/install/download.omh - - - diff -Nru cppad-2018.00.00.0/doc/_download_xml.js cppad-2019.02.00.0/doc/_download_xml.js --- cppad-2018.00.00.0/doc/_download_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_download_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', -'install.xml', -'download.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' -]; -var list_current0 = [ -'download.xml#Purpose', -'download.xml#Distribution Directory', -'download.xml#Version', -'download.xml#Release', -'download.xml#License', -'download.xml#Compressed Archives', -'download.xml#Compressed Archives.Coin', -'download.xml#Compressed Archives.Github', -'download.xml#Source Code Control', -'download.xml#Source Code Control.Git', -'download.xml#Source Code Control.Subversion', -'download.xml#Monthly Versions', -'download.xml#Windows File Extraction and Testing', -'download.xml#Install Instructions', -'download.xml#Building Documentation' -]; -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-2018.00.00.0/doc/drivers.xml cppad-2019.02.00.0/doc/drivers.xml --- cppad-2018.00.00.0/doc/drivers.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/drivers.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ - - - -First and Second Order Derivatives: Easy Drivers - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
First and Second Order Derivatives: Easy Drivers
-
-Contents -
- -
JacobianJacobian: Driver Routine
HessianHessian: Easy Driver
ForOneFirst Order Partial Derivative: Driver Routine
RevOneFirst Order Derivative: Driver Routine
ForTwoForward Mode Second Partial Derivative Driver
RevTwoReverse Mode Second Partial Derivative Driver
-
Input File: omh/adfun.omh - - - diff -Nru cppad-2018.00.00.0/doc/_drivers_xml.js cppad-2019.02.00.0/doc/_drivers_xml.js --- cppad-2018.00.00.0/doc/_drivers_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_drivers_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', -'adfun.xml', -'drivers.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down0 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_current0 = [ -'drivers.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-2018.00.00.0/doc/eigen_array.cpp.xml cppad-2019.02.00.0/doc/eigen_array.cpp.xml --- cppad-2018.00.00.0/doc/eigen_array.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/eigen_array.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ - - - -Using Eigen Arrays: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -eigen_array.cppHeadings

-
Using Eigen Arrays: Example and Test
-
# include <cppad/cppad.hpp>
-# include <cppad/example/cppad_eigen.hpp>
-# include <cppad/speed/det_by_minor.hpp>
-# include <Eigen/Dense>
-
-bool eigen_array(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     using Eigen::Matrix;
-     using Eigen::Dynamic;
-     //
-     typedef Matrix< AD<double> , Dynamic, 1 > a_vector;
-     //
-     // some temporary indices
-     size_t i, j;
-
-     // domain and range space vectors
-     size_t n  = 10, m = n;
-     a_vector a_x(n), a_y(m);
-
-     // set and declare independent variables and start tape recording
-     for(j = 0; j < n; j++)
-          a_x[j] = double(1 + j);
-     CppAD::Independent(a_x);
-
-     // evaluate a component wise function
-     a_y = a_x.array() + a_x.array().sin();
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(a_x, a_y);
-
-     // compute the derivative of y w.r.t x using CppAD
-     CPPAD_TESTVECTOR(double) x(n);
-     for(j = 0; j < n; j++)
-          x[j] = double(j) + 1.0 / double(j+1);
-     CPPAD_TESTVECTOR(double) jac = f.Jacobian(x);
-
-     // check Jacobian
-     double eps = 100. * CppAD::numeric_limits<double>::epsilon();
-     for(i = 0; i < m; i++)
-     {     for(j = 0; j < n; j++)
-          {     double check = 1.0 + cos(x[i]);
-               if( i != j )
-                    check = 0.0;
-               ok &= NearEqual(jac[i * n + j], check, eps, eps);
-          }
-     }
-
-     return ok;
-}
-
-
-
Input File: example/general/eigen_array.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_eigen_array.cpp_xml.js cppad-2019.02.00.0/doc/_eigen_array.cpp_xml.js --- cppad-2018.00.00.0/doc/_eigen_array.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_eigen_array.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', -'cppad_eigen.hpp.xml', -'eigen_array.cpp.xml' -]; -var list_down3 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.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 = [ -'eigen_plugin.hpp.xml', -'eigen_array.cpp.xml', -'eigen_det.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-2018.00.00.0/doc/eigen_det.cpp.xml cppad-2019.02.00.0/doc/eigen_det.cpp.xml --- cppad-2018.00.00.0/doc/eigen_det.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/eigen_det.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,165 +0,0 @@ - - - -Using Eigen To Compute Determinant: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -eigen_det.cppHeadings

-
Using Eigen To Compute Determinant: Example and Test
-
# include <cppad/example/cppad_eigen.hpp>
-# include <cppad/speed/det_by_minor.hpp>
-# include <Eigen/Dense>
-
-bool eigen_det(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     using Eigen::Matrix;
-     using Eigen::Dynamic;
-     //
-     typedef Matrix< double     , Dynamic, Dynamic > matrix;
-     typedef Matrix< AD<double> , Dynamic, Dynamic > a_matrix;
-     //
-     typedef Matrix< double ,     Dynamic , 1>       vector;
-     typedef Matrix< AD<double> , Dynamic , 1>       a_vector;
-     // some temporary indices
-     size_t i, j;
-
-     // domain and range space vectors
-     size_t size = 3, n  = size * size, m = 1;
-     a_vector a_x(n), a_y(m);
-     vector x(n);
-
-     // set and declare independent variables and start tape recording
-     for(i = 0; i < size; i++)
-     {     for(j = 0; j < size; j++)
-          {     // 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);
-          }
-     }
-     CppAD::Independent(a_x);
-
-     // copy independent variable vector to a matrix
-     a_matrix a_X(size, size);
-     matrix X(size, size);
-     for(i = 0; i < size; i++)
-     {     for(j = 0; j < size; j++)
-          {     X(i, j)   = x[i * size + j];
-               // If we used a_X(i, j) = X(i, j), a_X would not depend on a_x.
-               a_X(i, j) = a_x[i * size + j];
-          }
-     }
-
-     // Compute the log of determinant of X
-     a_y[0] = log( a_X.determinant() );
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(a_x, a_y);
-
-     // check function value
-     double eps = 100. * CppAD::numeric_limits<double>::epsilon();
-     CppAD::det_by_minor<double> det(size);
-     ok &= NearEqual(Value(a_y[0]) , log(det(x)), eps, eps);
-
-     // compute the derivative of y w.r.t x using CppAD
-     vector jac = f.Jacobian(x);
-
-     // check the derivative using the formula
-     // d/dX log(det(X)) = transpose( inv(X) )
-     matrix inv_X = X.inverse();
-     for(i = 0; i < size; i++)
-     {     for(j = 0; j < size; j++)
-               ok &= NearEqual(jac[i * size + j], inv_X(j, i), eps, eps);
-     }
-
-     return ok;
-}
-
-
-
Input File: example/general/eigen_det.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_eigen_det.cpp_xml.js cppad-2019.02.00.0/doc/_eigen_det.cpp_xml.js --- cppad-2018.00.00.0/doc/_eigen_det.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_eigen_det.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', -'cppad_eigen.hpp.xml', -'eigen_det.cpp.xml' -]; -var list_down3 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.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 = [ -'eigen_plugin.hpp.xml', -'eigen_array.cpp.xml', -'eigen_det.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-2018.00.00.0/doc/eigen_plugin.hpp.xml cppad-2019.02.00.0/doc/eigen_plugin.hpp.xml --- cppad-2018.00.00.0/doc/eigen_plugin.hpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/eigen_plugin.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ - - - -Source Code for eigen_plugin.hpp - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -eigen_plugin.hppHeadings

-
Source Code for eigen_plugin.hpp
-

-// Declaration needed, before eigen-3.3.3, so Eigen vector is a simple vector
-typedef Scalar value_type;
-
- -
Input File: cppad/example/eigen_plugin.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_eigen_plugin.hpp_xml.js cppad-2019.02.00.0/doc/_eigen_plugin.hpp_xml.js --- cppad-2018.00.00.0/doc/_eigen_plugin.hpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_eigen_plugin.hpp_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', -'cppad_eigen.hpp.xml', -'eigen_plugin.hpp.xml' -]; -var list_down3 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.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 = [ -'eigen_plugin.hpp.xml', -'eigen_array.cpp.xml', -'eigen_det.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-2018.00.00.0/doc/eigen_prefix.xml cppad-2019.02.00.0/doc/eigen_prefix.xml --- cppad-2018.00.00.0/doc/eigen_prefix.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/eigen_prefix.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,218 +0,0 @@ - - - -Including the Eigen Examples and Tests - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - -
Including the Eigen Examples and Tests
-
-Purpose -
-CppAD can include the following examples and tests that -use the linear algebra package Eigen -: - - - - - - - -
- -cppad_eigen.hpp -Enable Use of Eigen Linear Algebra Package with CppAD
- -eigen_array.cpp -Using Eigen Arrays: Example and Test
- -eigen_det.cpp -Using Eigen To Compute Determinant: Example and Test
- -atomic_eigen_mat_mul.hpp -Atomic Eigen Matrix Multiply Class
- -atomic_eigen_mat_inv.hpp -Atomic Eigen Matrix Inversion Class
- -
-
-eigen_prefix -
-If Eigen is installed on your system, you can -specify a value for its install -eigen_prefix - on the -cmake - command line. -The value of -eigen_prefix - must be such that, -for one of the directories -dir - in -cmake_install_includedirs -, - -
-     
eigen_prefix/dir/Eigen/Core
-
-is a valid way to reference to the include file Core; - -
-
-Examples -
-If you include -eigen_prefix - on the cmake - command line, -you will be able to run the Eigen examples list above -by executing the following commands starting in the -distribution directory -: - -
-     cd build/example
-     make check_example
-
-If you do this, -you will see an indication that the examples -eigen_array and eigen_det -have passed their correctness check. - -options to this program. - -
-
-Test Vector -
-If you have specified -eigen_prefix - you can choose - -
-     -D cppad_testvector=eigen
-
-on the cmake command - line. -This we set the CppAD testvector - to use Eigen vectors. - - -
-
-get_eigen -
-If you are using Unix, you can download and install -a copy of Eigen using get_eigen.sh -. -The corresponding -eigen_prefix - would be -build/prefix. - - - - -
Input File: omh/install/eigen_prefix.omh - - - diff -Nru cppad-2018.00.00.0/doc/_eigen_prefix_xml.js cppad-2019.02.00.0/doc/_eigen_prefix_xml.js --- cppad-2018.00.00.0/doc/_eigen_prefix_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_eigen_prefix_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', -'install.xml', -'cmake.xml', -'eigen_prefix.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 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.xml' -]; -var list_down1 = [ -'adolc_prefix.xml', -'colpack_prefix.xml', -'eigen_prefix.xml', -'fadbad_prefix.xml', -'ipopt_prefix.xml', -'sacado_prefix.xml', -'cppad_testvector.xml' -]; -var list_down0 = [ -'get_eigen.sh.xml' -]; -var list_current0 = [ -'eigen_prefix.xml#Purpose', -'eigen_prefix.xml#eigen_prefix', -'eigen_prefix.xml#Examples', -'eigen_prefix.xml#Test Vector', -'eigen_prefix.xml#get_eigen' -]; -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-2018.00.00.0/doc/elapsed_seconds.cpp.xml cppad-2019.02.00.0/doc/elapsed_seconds.cpp.xml --- cppad-2018.00.00.0/doc/elapsed_seconds.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/elapsed_seconds.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ - - - -Elapsed Seconds: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -elapsed_seconds.cppHeadings

- - - -
Elapsed Seconds: Example and Test
-
# include <cppad/utility/elapsed_seconds.hpp>
-
-# include <iostream>
-# include <algorithm>
-# include <cmath>
-
-# define CPPAD_DEBUG_ELAPSED_SECONDS 0
-
-bool elapsed_seconds(void)
-{     bool ok = true;
-
-     double max_diff = 0.;
-     double s0 = CppAD::elapsed_seconds();
-     double s1 = CppAD::elapsed_seconds();
-     double s2 = CppAD::elapsed_seconds();
-     while(s2 - s0 < 1.)
-     {     max_diff = std::max(s2 - s1, max_diff);
-          s1 = s2;
-          s2 = CppAD::elapsed_seconds();
-
-     }
-# if CPPAD_DEBUG_ELAPSED_SECONDS
-     std::cout << "max_diff = " << max_diff << std::endl;
-# endif
-     ok &= 0. < max_diff && max_diff < .04;
-     return ok;
-}
-
-
-
Input File: speed/example/elapsed_seconds.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_elapsed_seconds.cpp_xml.js cppad-2019.02.00.0/doc/_elapsed_seconds.cpp_xml.js --- cppad-2018.00.00.0/doc/_elapsed_seconds.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_elapsed_seconds.cpp_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', -'utility.xml', -'time_test.xml', -'elapsed_seconds.xml', -'elapsed_seconds.cpp.xml' -]; -var list_down3 = [ -'errorhandler.xml', -'nearequal.xml', -'speed_test.xml', -'speedtest.xml', -'time_test.xml', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down2 = [ -'elapsed_seconds.xml', -'time_test.cpp.xml' -]; -var list_down1 = [ -'elapsed_seconds.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-2018.00.00.0/doc/elapsed_seconds_c.xml cppad-2019.02.00.0/doc/elapsed_seconds_c.xml --- cppad-2018.00.00.0/doc/elapsed_seconds_c.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/elapsed_seconds_c.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,190 +0,0 @@ - - - -Returns Elapsed Number of Seconds - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -elapsed_seconds_c - -

-
Returns Elapsed Number of Seconds
-
-Syntax - -
- -s = elapsed_seconds() - - -
-
-Purpose -
-This routine is accurate to within .02 seconds -It does not necessary work for time intervals that are greater than a day. - -
-
-s -
-is a double equal to the -number of seconds since the first call to elapsed_seconds. - - -
-
-Source Code - -
# if _MSC_VER
-// ---------------------------------------------------------------------------
-// Microsoft version of timer
-# include <windows.h>
-# include <cassert>
-double elapsed_seconds(void)
-{     static bool       first_  = true;
-     static SYSTEMTIME st_;
-     double hour, minute, second, milli, diff;
-     SYSTEMTIME st;
-
-     if( first_ )
-     {     GetSystemTime(&st_);
-          first_ = false;
-          return 0.;
-     }
-     GetSystemTime(&st);
-
-     hour   = (double) st.wHour         - (double) st_.wHour;
-     minute = (double) st.wMinute       - (double) st_.wMinute;
-     second = (double) st.wSecond       - (double) st_.wSecond;
-     milli  = (double) st.wMilliseconds - (double) st_.wMilliseconds;
-
-     diff   = 1e-3*milli + second + 60.*minute + 3600.*hour;
-     if( diff < 0. )
-          diff += 3600.*24.;
-     assert( 0 <= diff && diff < 3600.*24. );
-
-     return diff;
-}
-# else
-// ---------------------------------------------------------------------------
-// Unix version of timer
-# include <sys/time.h>
-double elapsed_seconds(void)
-{     double sec, usec, diff;
-
-     static bool first_ = true;
-     static struct timeval tv_first;
-     struct timeval        tv;
-     if( first_ )
-     {     gettimeofday(&tv_first, NULL);
-          first_ = false;
-          return 0.;
-     }
-     gettimeofday(&tv, NULL);
-     assert( tv.tv_sec >= tv_first.tv_sec );
-
-     sec  = (double)(tv.tv_sec -  tv_first.tv_sec);
-     usec = (double)tv.tv_usec - (double)tv_first.tv_usec;
-     diff = sec + 1e-6*usec;
-
-     return diff;
-}
-# endif
- -
Input File: test_more/compare_c/det_by_minor.c - - - diff -Nru cppad-2018.00.00.0/doc/_elapsed_seconds_c_xml.js cppad-2019.02.00.0/doc/_elapsed_seconds_c_xml.js --- cppad-2018.00.00.0/doc/_elapsed_seconds_c_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_elapsed_seconds_c_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'compare_c.xml', -'elapsed_seconds_c.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', -'directory.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 = [ -'det_of_minor_c.xml', -'det_by_minor_c.xml', -'uniform_01_c.xml', -'correct_det_by_minor_c.xml', -'repeat_det_by_minor_c.xml', -'elapsed_seconds_c.xml', -'time_det_by_minor_c.xml', -'main_compare_c.xml' -]; -var list_current0 = [ -'elapsed_seconds_c.xml#Syntax', -'elapsed_seconds_c.xml#Purpose', -'elapsed_seconds_c.xml#s', -'elapsed_seconds_c.xml#Source Code' -]; -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-2018.00.00.0/doc/elapsed_seconds.xml cppad-2019.02.00.0/doc/elapsed_seconds.xml --- cppad-2018.00.00.0/doc/elapsed_seconds.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/elapsed_seconds.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ - - - -Returns Elapsed Number of Seconds - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Returns Elapsed Number of Seconds
-
-Syntax - -
- -# include <cppad/utility/elapsed_seconds.hpp>
-
- -s = elapsed_seconds() - - -
-
-Purpose -
-This routine is accurate to within .02 seconds -(see elapsed_seconds.cpp -). -It does not necessary work for time intervals that are greater than a day. -
  1. -If the C++11 std::chrono::steady_clock is available, -it will be used for timing. -
  2. - -Otherwise, if running under the Microsoft compiler, -::GetSystemTime will be used for timing. -
  3. - -Otherwise, if gettimeofday is available, it is used for timing. -
  4. - -Otherwise, std::clock() will be used for timing. -
- - -
-
-s -
-is a double equal to the -number of seconds since the first call to elapsed_seconds. - -
-
-Microsoft Systems -
-It you are using ::GetSystemTime, -you will need to link in the external routine -called microsoft_timer -. - - -
-
-Example -
-The routine elapsed_seconds.cpp - is -an example and test of this routine. - - - -
Input File: cppad/utility/elapsed_seconds.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_elapsed_seconds_xml.js cppad-2019.02.00.0/doc/_elapsed_seconds_xml.js --- cppad-2018.00.00.0/doc/_elapsed_seconds_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_elapsed_seconds_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'time_test.xml', -'elapsed_seconds.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'elapsed_seconds.xml', -'time_test.cpp.xml' -]; -var list_down0 = [ -'elapsed_seconds.cpp.xml' -]; -var list_current0 = [ -'elapsed_seconds.xml#Syntax', -'elapsed_seconds.xml#Purpose', -'elapsed_seconds.xml#s', -'elapsed_seconds.xml#Microsoft Systems', -'elapsed_seconds.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-2018.00.00.0/doc/epsilon.xml cppad-2019.02.00.0/doc/epsilon.xml --- cppad-2018.00.00.0/doc/epsilon.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/epsilon.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,166 +0,0 @@ - - - -Machine Epsilon For AD Types - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -epsilon - -

- - - -
Machine Epsilon For AD Types
-
-Deprecated 2012-06-17 -
-This routine has been deprecated. -You should use the numeric_limits - epsilon instead. - -
-
-Syntax - -
- -eps = epsilon<Float>() - - -
-
-Purpose -
-Obtain the value of machine epsilon corresponding -to the type -Float -. - -
-
-Float -
-this type can either be -AD<Base> -, -or it can be -Base - for any -AD<Base> - type. - -
-
-eps -
-The result -eps - has prototype - -
-     
Float eps
-
- -
Input File: cppad/core/epsilon.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_epsilon_xml.js cppad-2019.02.00.0/doc/_epsilon_xml.js --- cppad-2018.00.00.0/doc/_epsilon_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_epsilon_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'epsilon.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', -'directory.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', -'autotools.xml' -]; -var list_current0 = [ -'epsilon.xml#Deprecated 2012-06-17', -'epsilon.xml#Syntax', -'epsilon.xml#Purpose', -'epsilon.xml#Float', -'epsilon.xml#eps' -]; -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-2018.00.00.0/doc/equal_op_seq.cpp.xml cppad-2019.02.00.0/doc/equal_op_seq.cpp.xml --- cppad-2018.00.00.0/doc/equal_op_seq.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/equal_op_seq.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ - - - -EqualOpSeq: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -equal_op_seq.cppHeadings

- - - -
EqualOpSeq: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool EqualOpSeq(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::EqualOpSeq;
-
-     // domain space vector
-     size_t n  = 1;
-     double x0 = 1.;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0]      = x0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     AD<double> a = 1. + x[0];  // this variable is 1 + x0
-     AD<double> b = 2. * x[0];  // this variable is 2 * x0
-
-     // both a and b are variables
-     ok &= (a == b);            // 1 + 1     == 2 * 1
-     ok &= ! EqualOpSeq(a, b);  // 1 + x[0]  != 2 * x[0]
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = a;
-
-     // both y[0] and a are variables
-     EqualOpSeq(y[0], a);       // 2 * x[0] == 2 * x[0]
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // both a and b are parameters (after the creation of f above)
-     ok &= EqualOpSeq(a, b);    // 1 + 1 == 2 * 1
-
-     return ok;
-}
-
-
-
Input File: example/general/equal_op_seq.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_equal_op_seq.cpp_xml.js cppad-2019.02.00.0/doc/_equal_op_seq.cpp_xml.js --- cppad-2018.00.00.0/doc/_equal_op_seq.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_equal_op_seq.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'boolvalued.xml', -'equalopseq.xml', -'equal_op_seq.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 = [ -'compare.xml', -'nearequalext.xml', -'boolfun.xml', -'parvar.xml', -'equalopseq.xml' -]; -var list_down1 = [ -'equal_op_seq.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-2018.00.00.0/doc/equalopseq.xml cppad-2019.02.00.0/doc/equalopseq.xml --- cppad-2018.00.00.0/doc/equalopseq.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/equalopseq.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,236 +0,0 @@ - - - -Check if Two Value are Identically Equal - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Check if Two Value are Identically Equal
-
-Syntax - -
- -b = EqualOpSeq(xy) - - -
-
-Purpose -
-Determine if two -x - and -y - are identically equal; i.e., -not only is -x == y - true, but -if they are variables -, -they correspond have the same -operation sequence -. - -
-
-Motivation -
-Sometimes it is useful to cache information -and only recalculate when a function's arguments change. -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 -independent variables - -by the same operation sequence. -After the assignment - -
-     
y = x
-
-these two AD objects would not only have equal values, -but would also correspond to the same operation sequence. - -
-
-x -
-The argument -x - has prototype - -
-     const AD<
Base> &x
-
-
-y -
-The argument -y - has prototype - -
-     const AD<
Base> &y
-
-
-b -
-The result -b - has prototype - -
-     bool 
b
-
-The result is true if and only if one of the following cases holds: - -
  1. -Both -x - and -y - are variables -and correspond to the same operation sequence. -
  2. - -Both -x - and -y - are parameters, - -Base - is an AD type, -and -EqualOpSeq( Value(x) , Value(y) ) - is true. -
  3. - -Both -x - and -y - are parameters, - -Base - is not an AD type, -and -x == y - is true. -
- - - -
-
-Example - -
-The file -equal_op_seq.cpp - -contains an example and test of EqualOpSeq. -It returns true if it succeeds and false otherwise. - - - -
Input File: cppad/core/equal_op_seq.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_equalopseq_xml.js cppad-2019.02.00.0/doc/_equalopseq_xml.js --- cppad-2018.00.00.0/doc/_equalopseq_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_equalopseq_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', -'boolvalued.xml', -'equalopseq.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 = [ -'compare.xml', -'nearequalext.xml', -'boolfun.xml', -'parvar.xml', -'equalopseq.xml' -]; -var list_down0 = [ -'equal_op_seq.cpp.xml' -]; -var list_current0 = [ -'equalopseq.xml#Syntax', -'equalopseq.xml#Purpose', -'equalopseq.xml#Motivation', -'equalopseq.xml#x', -'equalopseq.xml#y', -'equalopseq.xml#b', -'equalopseq.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-2018.00.00.0/doc/erf.cpp.xml cppad-2019.02.00.0/doc/erf.cpp.xml --- cppad-2018.00.00.0/doc/erf.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/erf.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,178 +0,0 @@ - - - -The AD erf Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -erf.cppHeadings

- - - -
The AD erf Function: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cmath>
-# include <limits>
-
-bool Erf(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * CppAD::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::erf(ax[0]);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // check relative erorr
-     double erf_x0 = 0.5204998778130465;
-     ok &= NearEqual(ay[0] , erf_x0,  0.,    4e-4);
-# if CPPAD_USE_CPLUSPLUS_2011
-     double tmp = std::max(1e-15, eps);
-     ok &= NearEqual(ay[0] , erf_x0,  0.,    tmp);
-# endif
-
-     // value of derivative of erf at x0
-     double pi     = 4. * std::atan(1.);
-     double factor = 2. / sqrt(pi);
-     double check  = factor * std::exp(-x0 * x0);
-
-     // 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], check,  0.,  1e-3);
-# if CPPAD_USE_CPLUSPLUS_2011
-     ok   &= NearEqual(dy[0], check,  0.,  eps);
-# endif
-
-     // 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,  0., 1e-1);
-# if CPPAD_USE_CPLUSPLUS_2011
-     ok   &= NearEqual(dw[0], check,  0., eps);
-# endif
-
-     // use a VecAD<Base>::reference object with erf
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero]           = x0;
-     AD<double> result = CppAD::erf(v[zero]);
-     ok   &= NearEqual(result, ay[0], eps, eps);
-
-     // use a double with erf
-     ok   &= NearEqual(CppAD::erf(x0), ay[0], eps, eps);
-
-     return ok;
-}
-
-
-
Input File: example/general/erf.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_erf.cpp_xml.js cppad-2019.02.00.0/doc/_erf.cpp_xml.js --- cppad-2018.00.00.0/doc/_erf.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_erf.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'erf.xml', -'erf.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 = [ -'erf.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-2018.00.00.0/doc/erf_forward.xml cppad-2019.02.00.0/doc/erf_forward.xml --- cppad-2018.00.00.0/doc/erf_forward.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/erf_forward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,447 +0,0 @@ - - - -Error Function Forward Taylor Polynomial Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -erf_forward - -

-
Error Function Forward Taylor Polynomial Theory
-
-Derivatives -
-Given - -X -( -t -) - - -, we define the function - - -Z -( -t -) -= -erf - -[ -X -( -t -) -] - - -It follows that - - - -erf - -( -1 -) - - -( -u -) - -= - -( -2 -/ -π - - -) -exp -(- -u -2 - -) - -Z -( -1 -) - - -( -t -) - -= - -erf - -( -1 -) - - -[ -X -( -t -) -] -X -( -1 -) - - -( -t -) -= -Y -( -t -) -X -( -1 -) - - -( -t -) - - - -where we define the function - - -Y -( -t -) -= -2 - -π - - - - -exp -[- -X -( -t -) -2 - -] - - -
-Taylor Coefficients Recursion -
-Suppose that we are given the Taylor coefficients -up to order - -j - - - for the function - -X -( -t -) - - - and - -Y -( -t -) - - -. -We need a formula that computes the coefficient of order - -j - - - -for - -Z -( -t -) - - -. -Using the equation above for - -Z -( -1 -) - - -( -t -) - - -, we have - - - - -k -= -1 - -j - -k -z -( -k -) - - -t -k --1 - - - -= - -[ -k -= -0 - -j - -y -( -k -) - - -t -k - -] -[ -k -= -1 - -j - -k -x -( -k -) - - -t -k --1 - - -] -+ -o -( -t -j --1 - - -) - - - -Setting the coefficients of - -t -j --1 - - - - - equal, we have - - - -j -z -( -j -) - - -= - -k -= -1 - -j - -k -x -( -k -) - - -y -( -j -- -k -) - - - -z -( -j -) - - -= -1 - -j - - - -k -= -1 - -j - -k -x -( -k -) - - -y -( -j -- -k -) - - - - - - -
Input File: omh/appendix/theory/erf_forward.omh - - - diff -Nru cppad-2018.00.00.0/doc/_erf_forward_xml.js cppad-2019.02.00.0/doc/_erf_forward_xml.js --- cppad-2018.00.00.0/doc/_erf_forward_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_erf_forward_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', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'erf_forward.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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 = [ -'erf_forward.xml#Derivatives', -'erf_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-2018.00.00.0/doc/erf_reverse.xml cppad-2019.02.00.0/doc/erf_reverse.xml --- cppad-2018.00.00.0/doc/erf_reverse.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/erf_reverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,561 +0,0 @@ - - - -Error Function Reverse Mode Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -erf_reverse - -

-
Error Function Reverse Mode Theory
-
-Notation -
-We use the reverse theory -standard math function - -definition for the functions - -H - - - and - -G - - -. - -
-
-Positive Orders Z(t) -
-For order - -j -> -0 - - -, -suppose that - -H - - - is the same as - -G - - -. - - -z -( -j -) - - -= -1 - -j - - - -k -= -1 - -j - -k -x -( -k -) - - -y -( -j -- -k -) - - - - -For - -k -= -1 -, - -, -j - - -, -the partial of - -H - - - with respect to - -x -( -k -) - - - - - is given by - - - -H - - -x -( -k -) - - - - -= - -G - - -x -( -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -k -) - - - - -= - -G - - -x -( -k -) - - - - -+ - -G - - -z -( -j -) - - - - -k - -j - - -y -( -j -- -k -) - - - - -For - -k -= -1 -, - -, -j - - - -The partial of - -H - - - with respect to - -y -j -- -k - - - - -, -is given by - - - -H - - -y -( -j -- -k -) - - - - -= - -G - - -y -( -j -- -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -y -( -j -- -k -) - - - - -= - -G - - -y -( -j -- -k -) - - - - -+ - -G - - -z -( -j -) - - - - -k - -j - - -x -k - - - - -
-Order Zero Z(t) -
-The - -z -( -0 -) - - - - - coefficient -is expressed as a function of the Taylor coefficients -for - -X -( -t -) - - - and - -Y -( -t -) - - - as follows: -In this case, - - - -H - - -x -( -0 -) - - - - -= - -G - - -x -( -0 -) - - - - -+ - -G - - -z -( -0 -) - - - - - -z -( -0 -) - - - - -x -( -0 -) - - - - -= - -G - - -x -( -0 -) - - - - -+ - -G - - -z -( -0 -) - - - - -y -( -0 -) - - - - - -
Input File: omh/appendix/theory/erf_reverse.omh - - - diff -Nru cppad-2018.00.00.0/doc/_erf_reverse_xml.js cppad-2019.02.00.0/doc/_erf_reverse_xml.js --- cppad-2018.00.00.0/doc/_erf_reverse_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_erf_reverse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +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', -'erf_reverse.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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' -]; -var list_current0 = [ -'erf_reverse.xml#Notation', -'erf_reverse.xml#Positive Orders Z(t)', -'erf_reverse.xml#Order Zero Z(t)' -]; -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-2018.00.00.0/doc/erf.xml cppad-2019.02.00.0/doc/erf.xml --- cppad-2018.00.00.0/doc/erf.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/erf.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,227 +0,0 @@ - - - -The Error Function - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
The Error Function
-
-Syntax - -
- -y = erf(x) - - -
-
-Description -
-Returns the value of the error function which is defined by - - -erf - -( -x -) -= -2 - -π - - - - - -0 -x - -exp -( -- -t -* -t -) - -d - -t - - -
-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 a fast approximation (few numerical operations) -with relative error bound - -4 -× -10 --4 - - - - -; see -Vedder, J.D., - -Simple approximations for the error function and its inverse -, -American Journal of Physics, -v 55, -n 8, -1987, -p 762-3. - -
-
-Example - -
-The file -erf.cpp - -contains an example and test of this function. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/erf.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_erf_xml.js cppad-2019.02.00.0/doc/_erf_xml.js --- cppad-2018.00.00.0/doc/_erf_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_erf_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +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', -'unary_standard_math.xml', -'erf.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 = [ -'erf.cpp.xml' -]; -var list_current0 = [ -'erf.xml#Syntax', -'erf.xml#Description', -'erf.xml#x, y', -'erf.xml#CPPAD_USE_CPLUSPLUS_2011', -'erf.xml#CPPAD_USE_CPLUSPLUS_2011.true', -'erf.xml#CPPAD_USE_CPLUSPLUS_2011.false', -'erf.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-2018.00.00.0/doc/error_handler.cpp.xml cppad-2019.02.00.0/doc/error_handler.cpp.xml --- cppad-2018.00.00.0/doc/error_handler.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/error_handler.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,165 +0,0 @@ - - - -Replacing The CppAD Error Handler: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -error_handler.cppHeadings

- - - -
Replacing The CppAD Error Handler: Example and Test
-

-# include <cppad/utility/error_handler.hpp>
-# include <cstring>
-
-namespace {
-     void myhandler(
-          bool known       ,
-          int  line        ,
-          const char *file ,
-          const char *exp  ,
-          const char *msg  )
-     {     // error handler must not return, so throw an exception
-          throw line;
-     }
-}
-
-
-bool ErrorHandler(void)
-{     using CppAD::ErrorHandler;
-
-     int lineMinusFive = 0;
-
-     // replace the default CppAD error handler
-     ErrorHandler info(myhandler);
-
-     // set ok to false unless catch block is executed
-     bool ok = false;
-
-     // use try / catch because handler throws an exception
-     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
-               __LINE__ , // current source code line number
-               __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
-          ok = (line == lineMinusFive + 5);
-     }
-
-     // info drops out of scope and the default CppAD error handler
-     // is restored when this routine returns.
-     return ok;
-}
-
-
-
Input File: example/utility/error_handler.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_error_handler.cpp_xml.js cppad-2019.02.00.0/doc/_error_handler.cpp_xml.js --- cppad-2018.00.00.0/doc/_error_handler.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_error_handler.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'errorhandler.xml', -'error_handler.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'error_handler.cpp.xml', -'cppad_assert.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-2018.00.00.0/doc/errorhandler.xml cppad-2019.02.00.0/doc/errorhandler.xml --- cppad-2018.00.00.0/doc/errorhandler.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/errorhandler.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,294 +0,0 @@ - - - -Replacing the CppAD Error Handler - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Replacing the CppAD Error Handler
-
-Syntax - -
- -# include <cppad/utility/error_handler.hpp>
-
- -ErrorHandler info(handler)
-
- -ErrorHandler::Call(knownlinefileexpmsg)
-
-
-Constructor -
-When you construct a ErrorHandler object, -the current CppAD error handler is replaced by -handler -. -When the object is destructed, the previous CppAD error handler is restored. - -
-
-Parallel Mode -
-The ErrorHandler constructor and destructor cannot be called in -parallel - execution mode. -Furthermore, this rule is not abided by, a raw C++ assert, -instead of one that uses this error handler, will be generated. - -
-
-Call -
-When 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 ErrorHandler constructor. - -
-
-info -
-The object -info - is used to store information -that is necessary to restore the previous CppAD error handler. -This is done when the destructor for -info - is called. - - -
-
-handler -
-The argument -handler - has prototype - -
-     void (*
handler)
-          (bool, int, const char *, const char *, const char *);
-
-When an error is detected, -it is called with the syntax - -
-     
handler (knownlinefileexpmsg)
-
-This routine should not return; i.e., upon detection of the error, -the routine calling -handler - does not know how to proceed. - -
-
-known -
-The -handler - argument -known - has prototype - -
-     bool 
known
-
-If it is true, the error being reported is from a know problem. - -
-
-line -
-The -handler - argument -line - has prototype - -
-     int 
line
-
-It reports the source code line number where the error is detected. - -
-
-file -
-The -handler - argument -file - has prototype - -
-     const char *
file
-
-and is a '\0' terminated character vector. -It reports the source code file where the error is detected. - -
-
-exp -
-The -handler - argument -exp - has prototype - -
-     const char *
exp
-
-and is a '\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 -handler -. - -
-
-msg -
-The -handler - argument -msg - has prototype - -
-     const char *
msg
-
-and is a '\0' terminated character vector. -It reports the meaning of the error from the C++ programmers point of view. - - -
-
-Example -
-The file -error_handler.cpp - -contains an example and test a test of using this routine. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/utility/error_handler.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_errorhandler_xml.js cppad-2019.02.00.0/doc/_errorhandler_xml.js --- cppad-2018.00.00.0/doc/_errorhandler_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_errorhandler_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'errorhandler.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'error_handler.cpp.xml', -'cppad_assert.xml' -]; -var list_current0 = [ -'errorhandler.xml#Syntax', -'errorhandler.xml#Constructor', -'errorhandler.xml#Constructor.Parallel Mode', -'errorhandler.xml#Call', -'errorhandler.xml#info', -'errorhandler.xml#handler', -'errorhandler.xml#known', -'errorhandler.xml#line', -'errorhandler.xml#file', -'errorhandler.xml#exp', -'errorhandler.xml#msg', -'errorhandler.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-2018.00.00.0/doc/exampleutility.xml cppad-2019.02.00.0/doc/exampleutility.xml --- cppad-2018.00.00.0/doc/exampleutility.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/exampleutility.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ - - - -Utility Routines used by CppAD Examples - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Utility Routines used by CppAD Examples
-
-Contents -
- -
general.cppCppAD Examples and Tests
speed_example.cppRun the Speed Examples
lu_vec_ad.cppLu Factor and Solve with Recorded Pivoting
-
Input File: omh/example_list.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exampleutility_xml.js cppad-2019.02.00.0/doc/_exampleutility_xml.js --- cppad-2018.00.00.0/doc/_exampleutility_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exampleutility_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'example.xml', -'exampleutility.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down0 = [ -'general.cpp.xml', -'speed_example.cpp.xml', -'lu_vec_ad.cpp.xml' -]; -var list_current0 = [ -'exampleutility.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-2018.00.00.0/doc/example.xml cppad-2019.02.00.0/doc/example.xml --- cppad-2018.00.00.0/doc/example.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/example.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ - - - -Examples - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -

-
Examples
-
-Introduction -
-This section organizes the information related to the CppAD examples. -Each CppAD operation has its own specific example, -for example add.cpp - is an example for -addition -. -Some of the examples are of a more general nature -(not connected of a specific feature of CppAD). -In addition, there are some utility functions that are used -by the examples. - -
-
-get_started -
-The get_started.cpp - example is a good place to start using CppAD. - -
-
-Running Examples -
-The -installation instructions - -show how the examples can be run on your system. - - -
-
-The CppAD Test Vector Template Class -
-Many of the examples use the -CPPAD_TESTVECTOR - preprocessor symbol -to determine which SimpleVector - template class is used with -the examples. - - -
-
-Contents -
- -
Input File: omh/example.omh - - - diff -Nru cppad-2018.00.00.0/doc/_example_xml.js cppad-2019.02.00.0/doc/_example_xml.js --- cppad-2018.00.00.0/doc/_example_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_example_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'example.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_current0 = [ -'example.xml#Introduction', -'example.xml#get_started', -'example.xml#Running Examples', -'example.xml#The CppAD Test Vector Template Class', -'example.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_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-2018.00.00.0/doc/exp_2_cppad.xml cppad-2019.02.00.0/doc/exp_2_cppad.xml --- cppad-2018.00.00.0/doc/exp_2_cppad.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2_cppad.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,267 +0,0 @@ - - - -exp_2: CppAD Forward and Reverse Sweeps - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_2_cppad - -

-
exp_2: CppAD Forward and Reverse Sweeps
-. - -
-
-Purpose -
-Use CppAD forward and reverse modes to compute the -partial derivative with respect to - -x - - -, -at the point - -x -= -.5 - - -, -of the function - -
-     exp_2(
x)
-
-as defined by the exp_2.hpp - include file. - -
-
-Exercises - -
  1. -Create and test a modified version of the routine below that computes -the same order derivatives with respect to - -x - - -, -at the point - -x -= -.1 - - - -of the function - -
    -     exp_2(
    x)
    -
    -
  2. -Create a routine called - -
    -     exp_3(
    x)
    -
    -that evaluates the function - - -f -( -x -) -= -1 -+ -x -2 - -/ -2 -+ -x -3 - -/ -6 - - -Test a modified version of the routine below that computes -the derivative of - -f -( -x -) - - - -at the point - -x -= -.5 - - -. -
- -

-# include <cppad/cppad.hpp>  // http://www.coin-or.org/CppAD/
-# include "exp_2.hpp"        // second order exponential approximation
-bool exp_2_cppad(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::vector;    // can use any simple vector template class
-     using CppAD::NearEqual; // checks if values are nearly equal
-
-     // domain space vector
-     size_t n = 1; // dimension of the domain space
-     vector< AD<double> > X(n);
-     X[0] = .5;    // value of x for this operation sequence
-
-     // declare independent variables and start recording operation sequence
-     CppAD::Independent(X);
-
-     // evaluate our exponential approximation
-     AD<double> x   = X[0];
-     AD<double> apx = exp_2(x);
-
-     // range space vector
-     size_t m = 1;  // dimension of the range space
-     vector< AD<double> > Y(m);
-     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
-     // sweep using values in X for x.
-     CppAD::ADFun<double> f(X, Y);
-
-     // first order forward sweep that computes
-     // partial of exp_2(x) with respect to x
-     vector<double> dx(n);  // differential in domain space
-     vector<double> dy(m);  // differential in range space
-     dx[0] = 1.;            // direction for partial derivative
-     dy    = f.Forward(1, dx);
-     double check = 1.5;
-     ok   &= NearEqual(dy[0], check, 1e-10, 1e-10);
-
-     // first order reverse sweep that computes the derivative
-     vector<double>  w(m);   // weights for components of the range
-     vector<double> dw(n);   // derivative of the weighted function
-     w[0] = 1.;              // there is only one weight
-     dw   = f.Reverse(1, w); // derivative of w[0] * exp_2(x)
-     check = 1.5;            // partial of exp_2(x) with respect to x
-     ok   &= NearEqual(dw[0], check, 1e-10, 1e-10);
-
-     // second order forward sweep that computes
-     // second partial of exp_2(x) with respect to x
-     vector<double> x2(n);     // second order Taylor coefficients
-     vector<double> 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
-     ok   &= NearEqual(y2[0], check, 1e-10, 1e-10);
-
-     // second order reverse sweep that computes
-     // derivative of partial of exp_2(x) w.r.t. x
-     dw.resize(2 * n);         // space for first and second derivatives
-     dw    = f.Reverse(2, w);
-     check = 1.;               // result should be second derivative
-     ok   &= NearEqual(dw[0*2+1], check, 1e-10, 1e-10);
-
-     return ok;
-}
-
- -
Input File: introduction/exp_2_cppad.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2_cppad_xml.js cppad-2019.02.00.0/doc/_exp_2_cppad_xml.js --- cppad-2018.00.00.0/doc/_exp_2_cppad_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2_cppad_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', -'introduction.xml', -'exp_2.xml', -'exp_2_cppad.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.xml' -]; -var list_current0 = [ -'exp_2_cppad.xml#Purpose', -'exp_2_cppad.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_2.cpp.xml cppad-2019.02.00.0/doc/exp_2.cpp.xml --- cppad-2018.00.00.0/doc/exp_2.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ - - - -exp_2: Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_2.cppHeadings

-
exp_2: Test
-
# include <cmath>           // define fabs function
-# 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;
-     return ok;
-}
-
-
Input File: introduction/exp_2.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2.cpp_xml.js cppad-2019.02.00.0/doc/_exp_2.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_2.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_2.xml', -'exp_2.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.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-2018.00.00.0/doc/exp_2_for0.cpp.xml cppad-2019.02.00.0/doc/exp_2_for0.cpp.xml --- cppad-2018.00.00.0/doc/exp_2_for0.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2_for0.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ - - - -exp_2: Verify Zero Order Forward Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_2_for0.cppHeadings

- - - -
exp_2: Verify Zero Order Forward Sweep
-
# include <cmath>            // for fabs function
-bool exp_2_for0(double *v0)  // double v0[6]
-{     bool  ok = true;
-     double x = .5;
-
-     v0[1] = x;                                  // v1 = x
-     ok  &= std::fabs( v0[1] - 0.5) < 1e-10;
-
-     v0[2] = 1. + v0[1];                         // v2 = 1 + v1
-     ok  &= std::fabs( v0[2] - 1.5) < 1e-10;
-
-     v0[3] = v0[1] * v0[1];                      // v3 = v1 * v1
-     ok  &= std::fabs( v0[3] - 0.25) < 1e-10;
-
-     v0[4] = v0[3] / 2.;                         // v4 = v3 / 2
-     ok  &= std::fabs( v0[4] - 0.125) < 1e-10;
-
-     v0[5] = v0[2] + v0[4];                      // v5  = v2 + v4
-     ok  &= std::fabs( v0[5] - 1.625) < 1e-10;
-
-     return ok;
-}
-bool exp_2_for0(void)
-{     double v0[6];
-     return exp_2_for0(v0);
-}
- -
Input File: introduction/exp_2_for0.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2_for0.cpp_xml.js cppad-2019.02.00.0/doc/_exp_2_for0.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_2_for0.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2_for0.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_2.xml', -'exp_2_for0.xml', -'exp_2_for0.cpp.xml' -]; -var list_down3 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down2 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.xml' -]; -var list_down1 = [ -'exp_2_for0.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-2018.00.00.0/doc/exp_2_for0.xml cppad-2019.02.00.0/doc/exp_2_for0.xml --- cppad-2018.00.00.0/doc/exp_2_for0.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2_for0.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,619 +0,0 @@ - - - -exp_2: Operation Sequence and Zero Order Forward Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
exp_2: Operation Sequence and Zero Order Forward Mode
-
-Mathematical Form -
-The operation sequence (see below) corresponding to -the algorithm exp_2.hpp - is the same for all values of -x -. -The mathematical form for the corresponding function is - - -f -( -x -) -= -1 -+ -x -+ -x -2 - -/ -2 - - -An algorithmic differentiation package -does not operate on the mathematical function - -f -( -x -) - - - -but rather on the particular algorithm used to compute the function -(in this case exp_2.hpp -). - -
-
-Zero Order Expansion -
-In general, a zero order forward sweep is given a vector - - -x -( -0 -) - - - -R - -n - - - - and it returns the corresponding vector - - -y -( -0 -) - - - -R - -m - - - - given by - - -y -( -0 -) - - -= -f -( -x -( -0 -) - - -) - - -The superscript - -( -0 -) - - - denotes zero order derivative; -i.e., it is equal to the value -of the corresponding variable. -For the example we are considering here, -both - -n - - - and - -m - - - are equal to one. - - -
-
-Operation Sequence -
-An atomic -Type - operation is an operation -that has a -Type - result and is not made up of -other more basic operations. -A sequence of atomic -Type - operations is called a - -Type - operation sequence. -Given an C++ algorithm and its inputs, -there is a corresponding -Type - operation sequence for each type. -If -Type - is clear from the context, -we drop it and just refer to the operation sequence. -
-
-
We consider the case where exp_2.hpp - is executed with - - -x -( -0 -) - - -= -.5 - - -. -The table below contains the corresponding operation sequence -and the results of a zero order sweep. - -
-
-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 -and ends with the last. - -
-
-Code -
-The Code column contains the C++ source code corresponding -to the corresponding atomic operation in the sequence. - -
-
-Operation -
-The Operation column contains the -mathematical function corresponding to each atomic operation in the sequence. - -
-
-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; -i.e, in order of increasing index in the operation sequence. - -
-
-Sweep - -
- -
- -Index - -    - Code - -    - Operation - -    - Zero Order -
- -1 - -    - Type v1 = x; - - - - -v -1 - -= -x - - - - - - - -v -1 -( -0 -) - - -= -0.5 - - - -
- -2 - -    - Type v2 = Type(1) + v1; - - - - -v -2 - -= -1 -+ -v -1 - - - - - - - - -v -2 -( -0 -) - - -= -1.5 - - - -
- -3 - -    - Type v3 = v1 * v1; - - - - -v -3 - -= -v -1 - -* -v -1 - - - - - - - - -v -3 -( -0 -) - - -= -0.25 - - - -
- -4 - -    - Type v4 = v3 / Type(2); - - - - -v -4 - -= -v -3 - -/ -2 - - - - - - - -v -4 -( -0 -) - - -= -0.125 - - - -
- -5 - -    - Type v5 = v2 + v4; - - - - -v -5 - -= -v -2 - -+ -v -4 - - - - - - - - -v -5 -( -0 -) - - -= -1.625 - - - -
-
Return Value -
-The return value for this case is - - -1.625 -= -v -5 -( -0 -) - - -= -f -( -x -( -0 -) - - -) - - -
-Verification -
-The file exp_2_for0.cpp - contains a routine -that verifies the values computed above. -It returns true for success and false for failure. - -
-
-Exercises - -
  1. -Suppose that - -x -( -0 -) - - -= -.2 - - -, -what is the result of a zero order forward sweep for -the operation sequence above; -i.e., what are the corresponding values for - - -v -1 -( -0 -) - - -, -v -2 -( -0 -) - - -, - -, -v -5 -( -0 -) - - - - -
  2. -Create a modified version of -exp_2_for0.cpp - that verifies the values you obtained -for the previous exercise. -
  3. - -Create and run a main program that reports the result of calling -the modified version -of exp_2_for0.cpp - in the previous exercise. -
- - - - -
Input File: introduction/exp_2.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2_for0_xml.js cppad-2019.02.00.0/doc/_exp_2_for0_xml.js --- cppad-2018.00.00.0/doc/_exp_2_for0_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2_for0_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_2.xml', -'exp_2_for0.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.xml' -]; -var list_down0 = [ -'exp_2_for0.cpp.xml' -]; -var list_current0 = [ -'exp_2_for0.xml#Mathematical Form', -'exp_2_for0.xml#Zero Order Expansion', -'exp_2_for0.xml#Operation Sequence', -'exp_2_for0.xml#Operation Sequence.Index', -'exp_2_for0.xml#Operation Sequence.Code', -'exp_2_for0.xml#Operation Sequence.Operation', -'exp_2_for0.xml#Operation Sequence.Zero Order', -'exp_2_for0.xml#Operation Sequence.Sweep', -'exp_2_for0.xml#Return Value', -'exp_2_for0.xml#Verification', -'exp_2_for0.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_2_for1.cpp.xml cppad-2019.02.00.0/doc/exp_2_for1.cpp.xml --- cppad-2018.00.00.0/doc/exp_2_for1.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2_for1.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ - - - -exp_2: Verify First Order Forward Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_2_for1.cppHeadings

-
exp_2: Verify First Order Forward Sweep
-
# include <cmath>                   // prototype for fabs
-extern bool exp_2_for0(double *v0); // computes zero order forward sweep
-bool exp_2_for1(double *v1)         // double v1[6]
-{     bool ok = true;
-     double v0[6];
-
-     // set the value of v0[j] for j = 1 , ... , 5
-     ok &= exp_2_for0(v0);
-
-     v1[1] = 1.;                                     // v1 = x
-     ok    &= std::fabs( v1[1] - 1. ) <= 1e-10;
-
-     v1[2] = v1[1];                                  // v2 = 1 + v1
-     ok    &= std::fabs( v1[2] - 1. ) <= 1e-10;
-
-     v1[3] = v1[1] * v0[1] + v0[1] * v1[1];          // v3 = v1 * v1
-     ok    &= std::fabs( v1[3] - 1. ) <= 1e-10;
-
-     v1[4] = v1[3] / 2.;                             // v4 = v3 / 2
-     ok    &= std::fabs( v1[4] - 0.5) <= 1e-10;
-
-     v1[5] = v1[2] + v1[4];                          // v5 = v2 + v4
-     ok    &= std::fabs( v1[5] - 1.5) <= 1e-10;
-
-     return ok;
-}
-bool exp_2_for1(void)
-{     double v1[6];
-     return exp_2_for1(v1);
-}
- -
Input File: introduction/exp_2_for1.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2_for1.cpp_xml.js cppad-2019.02.00.0/doc/_exp_2_for1.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_2_for1.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2_for1.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_2.xml', -'exp_2_for1.xml', -'exp_2_for1.cpp.xml' -]; -var list_down3 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down2 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.xml' -]; -var list_down1 = [ -'exp_2_for1.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-2018.00.00.0/doc/exp_2_for1.xml cppad-2019.02.00.0/doc/exp_2_for1.xml --- cppad-2018.00.00.0/doc/exp_2_for1.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2_for1.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,978 +0,0 @@ - - - -exp_2: First Order Forward Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
exp_2: First Order Forward Mode
-
-First Order Expansion -
-We define - -x -( -t -) - - - near - -t -= -0 - - - by the first order expansion - - -x -( -t -) -= -x -( -0 -) - - -+ -x -( -1 -) - - -* -t - - -it follows that - -x -( -0 -) - - - - - is the zero, -and - -x -( -1 -) - - - - - the first, -order derivative of - -x -( -t -) - - - -at - -t -= -0 - - -. - -
-
-Purpose -
-In general, a first order forward sweep is given the -zero order derivative - -for all of the variables in an operation sequence, -and the first order derivatives for the independent variables. -It uses these to compute the first order derivatives, -and thereby obtain the first order expansion, -for all the other variables in the operation sequence. - -
-
-Mathematical Form -
-Suppose that we use the algorithm exp_2.hpp - to compute - - -f -( -x -) -= -1 -+ -x -+ -x -2 - -/ -2 - - -The corresponding derivative function is - - - -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 -operation sequence - -for the for the algorithm that is used to evaluate the function. - -
-
-Operation Sequence -
-We consider the case where exp_2.hpp - is executed with - - -x -= -.5 - - -. -The corresponding operation sequence and -zero order forward mode values -(see zero order sweep -) -are inputs and are used by a first order forward sweep. - -
-
-Index -
-The Index column contains the index in the operation sequence -of the corresponding atomic operation. -A Forward sweep starts with the first operation -and ends with the last. - -
-
-Operation -
-The Operation column contains the -mathematical function corresponding to each atomic operation in the sequence. - -
-
-Zero Order -
-The Zero Order column contains the zero order derivatives -for the corresponding variable in the operation sequence -(see zero order sweep -). - -
-
-Derivative -
-The Derivative column contains the -mathematical function corresponding to the derivative -with respect to - -t - - -, -at - -t -= -0 - - -, for each variable in the sequence. - -
-
-First Order -
-The First Order column contains the first order derivatives -for the corresponding variable in the operation sequence; i.e., - - -v -j - -( -t -) -= -v -j -( -0 -) - - -+ -v -j -( -1 -) - - -t - - -We use - -x -( -1 -) - - -= -1 - - - so that differentiation -with respect to - -t - - -, -at - -t -= -0 - - -, is the same as partial differentiation -with respect to - -x - - - at - -x -= -x -( -0 -) - - - - -. - - - -
-
-Sweep - - -
- -
- -Index - -    - Operation - -    - Zero Order - -    - Derivative - -    - First Order -
- -1 - -    - - -v -1 - -= -x - - - - - - 0.5 - - - - - -v -1 -( -1 -) - - -= -x -( -1 -) - - - - - - - - - -v -1 -( -1 -) - - -= -1 - - - -
- -2 - -    - - -v -2 - -= -1 -+ -v -1 - - - - - - - 1.5 - - - - - -v -2 -( -1 -) - - -= -v -1 -( -1 -) - - - - - - - - - -v -2 -( -1 -) - - -= -1 - - - -
- -3 - -    - - -v -3 - -= -v -1 - -* -v -1 - - - - - - - 0.25 - - - - - -v -3 -( -1 -) - - -= -2 -* -v -1 -( -0 -) - - -* -v -1 -( -1 -) - - - - - - - - - -v -3 -( -1 -) - - -= -1 - - - -
- -4 - -    - - -v -4 - -= -v -3 - -/ -2 - - - - - - 0.125 - - - - - -v -4 -( -1 -) - - -= -v -3 -( -1 -) - - -/ -2 - - - - - - - -v -4 -( -1 -) - - -= -0.5 - - - -
- -5 -   - - -v -5 - -= -v -2 - -+ -v -4 - - - - - - - 1.625 - - - - - -v -5 -( -1 -) - - -= -v -2 -( -1 -) - - -+ -v -4 -( -1 -) - - - - - - - - - -v -5 -( -1 -) - - -= -1.5 - - - -
-
Return Value -
-The derivative of the return value for this case is - - - -1.5 - -= - -v -5 -( -1 -) - - -= -[ -v -5 - - - -t - - -] -t -= -0 - - -= -[ - - -t - - -f -( -x -( -0 -) - - -+ -x -( -1 -) - - -t -) -] -t -= -0 - - - - -= - -f -( -1 -) - - -( -x -( -0 -) - - -) -* -x -( -1 -) - - -= -f -( -1 -) - - -( -x -( -0 -) - - -) - - - -(We have used the fact that - -x -( -1 -) - - -= -1 - - -.) - - -
-
-Verification -
-The file exp_2_for1.cpp - contains a routine -which verifies the values computed above. -It returns true for success and false for failure. - -
-
-Exercises - -
  1. -Which statement in the routine defined by exp_2_for1.cpp - uses -the values that are calculated by the routine -defined by exp_2_for0.cpp - ? -
  2. - -Suppose that - -x -= -.1 - - -, -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 - - -v -1 -( -0 -) - - -, -v -2 -( -0 -) - - -, - -, -v -5 -( -0 -) - - - - - and - - -v -1 -( -1 -) - - -, -v -2 -( -1 -) - - -, - -, -v -5 -( -1 -) - - - - - ? -
  3. - -Create a modified version of 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 -exp_2_for1.cpp -. -
- - - -
Input File: introduction/exp_2.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2_for1_xml.js cppad-2019.02.00.0/doc/_exp_2_for1_xml.js --- cppad-2018.00.00.0/doc/_exp_2_for1_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2_for1_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_2.xml', -'exp_2_for1.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.xml' -]; -var list_down0 = [ -'exp_2_for1.cpp.xml' -]; -var list_current0 = [ -'exp_2_for1.xml#First Order Expansion', -'exp_2_for1.xml#Purpose', -'exp_2_for1.xml#Mathematical Form', -'exp_2_for1.xml#Operation Sequence', -'exp_2_for1.xml#Operation Sequence.Index', -'exp_2_for1.xml#Operation Sequence.Operation', -'exp_2_for1.xml#Operation Sequence.Zero Order', -'exp_2_for1.xml#Operation Sequence.Derivative', -'exp_2_for1.xml#Operation Sequence.First Order', -'exp_2_for1.xml#Operation Sequence.Sweep', -'exp_2_for1.xml#Return Value', -'exp_2_for1.xml#Verification', -'exp_2_for1.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_2_for2.cpp.xml cppad-2019.02.00.0/doc/exp_2_for2.cpp.xml --- cppad-2018.00.00.0/doc/exp_2_for2.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2_for2.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ - - - -exp_2: Verify Second Order Forward Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_2_for2.cppHeadings

-
exp_2: Verify Second Order Forward Sweep
-
# include <cmath>                   // prototype for fabs
-extern bool exp_2_for0(double *v0); // computes zero order forward sweep
-extern bool exp_2_for1(double *v1); // computes first order forward sweep
-bool exp_2_for2(void)
-{     bool ok = true;
-     double v0[6], v1[6], v2[6];
-
-     // set the value of v0[j], v1[j], for j = 1 , ... , 5
-     ok &= exp_2_for0(v0);
-     ok &= exp_2_for1(v1);
-
-     v2[1] = 0.;                                     // v1 = x
-     ok    &= std::fabs( v2[1] - 0. ) <= 1e-10;
-
-     v2[2] = v2[1];                                  // v2 = 1 + v1
-     ok    &= std::fabs( v2[2] - 0. ) <= 1e-10;
-
-     v2[3] = 2.*(v0[1]*v2[1] + v1[1]*v1[1]);         // v3 = v1 * v1
-     ok    &= std::fabs( v2[3] - 2. ) <= 1e-10;
-
-     v2[4] = v2[3] / 2.;                             // v4 = v3 / 2
-     ok    &= std::fabs( v2[4] - 1. ) <= 1e-10;
-
-     v2[5] = v2[2] + v2[4];                          // v5 = v2 + v4
-     ok    &= std::fabs( v2[5] - 1. ) <= 1e-10;
-
-     return ok;
-}
- -
Input File: introduction/exp_2_for2.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2_for2.cpp_xml.js cppad-2019.02.00.0/doc/_exp_2_for2.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_2_for2.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2_for2.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_2.xml', -'exp_2_for2.xml', -'exp_2_for2.cpp.xml' -]; -var list_down3 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down2 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.xml' -]; -var list_down1 = [ -'exp_2_for2.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-2018.00.00.0/doc/exp_2_for2.xml cppad-2019.02.00.0/doc/exp_2_for2.xml --- cppad-2018.00.00.0/doc/exp_2_for2.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2_for2.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1140 +0,0 @@ - - - -exp_2: Second Order Forward Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
exp_2: Second Order Forward Mode
-
-Second Order Expansion -
-We define - -x -( -t -) - - - near - -t -= -0 - - - by the second order expansion - - -x -( -t -) -= -x -( -0 -) - - -+ -x -( -1 -) - - -* -t -+ -x -( -2 -) - - -* -t -2 - -/ -2 - - -It follows that for - -k -= -0 -, -1 -, -2 - - -, - - -x -( -k -) - - -= -d - -k - - - -d - - -t - -k - - - - -x -( -0 -) - - -
-Purpose -
-In general, a second order forward sweep is given the -first order expansion - -for all of the variables in an operation sequence, -and the second order derivatives for the independent variables. -It uses these to compute the second order derivative, -and thereby obtain the second order expansion, -for all the variables in the operation sequence. - -
-
-Mathematical Form -
-Suppose that we use the algorithm exp_2.hpp - to compute - - -f -( -x -) -= -1 -+ -x -+ -x -2 - -/ -2 - - -The corresponding second derivative function is - - - -2 - - - - -x - -2 - - - - -f -( -x -) -= -1 - - -
-Operation Sequence -
-We consider the case where exp_2.hpp - is executed with - - -x -= -.5 - - -. -The corresponding operation sequence, -zero order forward sweep values, -and first order forward sweep values -are inputs and are used by a second order forward sweep. - -
-
-Index -
-The Index column contains the index in the operation sequence -of the corresponding atomic operation. -A Forward sweep starts with the first operation -and ends with the last. - -
-
-Zero -
-The Zero column contains the zero order sweep results -for the corresponding variable in the operation sequence -(see zero order sweep -). - -
-
-Operation -
-The Operation column contains the -first order sweep operation for this variable. - -
-
-First -
-The First column contains the first order sweep results -for the corresponding variable in the operation sequence -(see first order sweep -). - -
-
-Derivative -
-The Derivative column contains the -mathematical function corresponding to the second derivative -with respect to - -t - - -, -at - -t -= -0 - - -, for each variable in the sequence. - -
-
-Second -
-The Second column contains the second order derivatives -for the corresponding variable in the operation sequence; i.e., -the second order expansion for the i-th variable is given by - - -v -i - -( -t -) -= -v -i -( -0 -) - - -+ -v -i -( -1 -) - - -* -t -+ -v -i -( -2 -) - - -* -t -2 - -/ -2 - - -We use - -x -( -0 -) - - -= -1 - - -, and - -x -( -2 -) - - -= -0 - - - -so that second order differentiation -with respect to - -t - - -, at - -t -= -0 - - -, -is the same as the second partial differentiation -with respect to - -x - - - at - -x -= -x -( -0 -) - - - - -. - - -
-
-Sweep - - -
- -
- -Index - -    - Zero - -    - Operation - -    - First - -    - Derivative - -    - Second -
- -1 - - - 0.5 - -    - - -v -1 -( -1 -) - - -= -x -( -1 -) - - - - - - - - 1 - - - - - -v -1 -( -2 -) - - -= -x -( -2 -) - - - - - - - - - -v -1 -( -2 -) - - -= -0 - - - -
- -2 - - - 1.5 - -    - - -v -2 -( -1 -) - - -= -v -1 -( -1 -) - - - - - - - - 1 - - - - - -v -2 -( -2 -) - - -= -v -1 -( -2 -) - - - - - - - - - -v -2 -( -2 -) - - -= -0 - - - -
- -3 - - - 0.25 - -    - - -v -3 -( -1 -) - - -= -2 -* -v -1 -( -0 -) - - -* -v -1 -( -1 -) - - - - - - - - 1 - - - - - -v -3 -( -2 -) - - -= -2 -* -( -v -1 -( -1 -) - - -* -v -1 -( -1 -) - - -+ -v -1 -( -0 -) - - -* -v -1 -( -2 -) - - -) - - - - - - - -v -3 -( -2 -) - - -= -2 - - - -
- -4 - - - 0.125 - -    - - -v -4 -( -1 -) - - -= -v -3 -( -1 -) - - -/ -2 - - - - - - .5 - - - - - -v -4 -( -2 -) - - -= -v -3 -( -2 -) - - -/ -2 - - - - - - - -v -4 -( -2 -) - - -= -1 - - - -
- -5 - - - 1.625 - -   - - -v -5 -( -1 -) - - -= -v -2 -( -1 -) - - -+ -v -4 -( -1 -) - - - - - - - - 1.5 - - - - - -v -5 -( -2 -) - - -= -v -2 -( -2 -) - - -+ -v -4 -( -2 -) - - - - - - - - - -v -5 -( -2 -) - - -= -1 - - - -
-
Return Value -
-The second derivative of the return value for this case is - - - -1 - -= - -v -5 -( -2 -) - - -= -[ -2 - - - - -t - -2 - - - - -v -5 - -] -t -= -0 - - -= -[ -2 - - - - -t - -2 - - - - -f -( -x -( -0 -) - - -+ -x -( -1 -) - - -* -t -) -] -t -= -0 - - - - -= - -x -( -1 -) - - -* - -2 - - - - -x - -2 - - - - -f -( -x -( -0 -) - - -) -* -x -( -1 -) - - -= - -2 - - - - -x - -2 - - - - -f -( -x -( -0 -) - - -) - - - -(We have used the fact that - - -x -( -1 -) - - -= -1 - - - and - -x -( -2 -) - - -= -0 - - -.) - - -
-
-Verification -
-The file exp_2_for2.cpp - contains a routine -which verifies the values computed above. -It returns true for success and false for failure. - -
-
-Exercises - -
  1. -Which statement in the routine defined by exp_2_for2.cpp - uses -the values that are calculated by the routine -defined by exp_2_for1.cpp - ? -
  2. - -Suppose that - -x -= -.1 - - -, -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 - - -v -i -( -k -) - - - - - for - -i -= -1 -, - -, -5 - - - and - -k -= -0 -, -1 -, -2 - - -. -
  3. - -Create a modified version of 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 -exp_2_for2.cpp -. -
- - - -
Input File: introduction/exp_2.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2_for2_xml.js cppad-2019.02.00.0/doc/_exp_2_for2_xml.js --- cppad-2018.00.00.0/doc/_exp_2_for2_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2_for2_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_2.xml', -'exp_2_for2.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.xml' -]; -var list_down0 = [ -'exp_2_for2.cpp.xml' -]; -var list_current0 = [ -'exp_2_for2.xml#Second Order Expansion', -'exp_2_for2.xml#Purpose', -'exp_2_for2.xml#Mathematical Form', -'exp_2_for2.xml#Operation Sequence', -'exp_2_for2.xml#Operation Sequence.Index', -'exp_2_for2.xml#Operation Sequence.Zero', -'exp_2_for2.xml#Operation Sequence.Operation', -'exp_2_for2.xml#Operation Sequence.First', -'exp_2_for2.xml#Operation Sequence.Derivative', -'exp_2_for2.xml#Operation Sequence.Second', -'exp_2_for2.xml#Operation Sequence.Sweep', -'exp_2_for2.xml#Return Value', -'exp_2_for2.xml#Verification', -'exp_2_for2.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_2.hpp.xml cppad-2019.02.00.0/doc/exp_2.hpp.xml --- cppad-2018.00.00.0/doc/exp_2.hpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ - - - -exp_2: Implementation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_2.hppHeadings

- - - -
exp_2: Implementation
-
template <class Type>
-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 v5  = v2 + v4;          // v5 = 1 + x + x^2 / 2
-        return v5;                   // exp_2(x) = 1 + x + x^2 / 2
-}
-
-
Input File: introduction/exp_2.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2.hpp_xml.js cppad-2019.02.00.0/doc/_exp_2.hpp_xml.js --- cppad-2018.00.00.0/doc/_exp_2.hpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_2.xml', -'exp_2.hpp.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.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-2018.00.00.0/doc/exp_2_rev1.cpp.xml cppad-2019.02.00.0/doc/exp_2_rev1.cpp.xml --- cppad-2018.00.00.0/doc/exp_2_rev1.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2_rev1.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ - - - -exp_2: Verify First Order Reverse Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_2_rev1.cppHeadings

-
exp_2: Verify First Order Reverse Sweep
-
# include <cstddef>                 // define size_t
-# include <cmath>                   // prototype for fabs
-extern bool exp_2_for0(double *v0); // computes zero order forward sweep
-bool exp_2_rev1(void)
-{     bool ok = true;
-
-     // set the value of v0[j] for j = 1 , ... , 5
-     double v0[6];
-     ok &= exp_2_for0(v0);
-
-     // initial all partial derivatives as zero
-     double f_v[6];
-     size_t j;
-     for(j = 0; j < 6; j++)
-          f_v[j] = 0.;
-
-     // set partial derivative for f5
-     f_v[5] = 1.;
-     ok &= std::fabs( f_v[5] - 1. ) <= 1e-10; // f5_v5
-
-     // f4 = f5( v1 , v2 , v3 , v4 , v2 + v4 )
-     f_v[2] += f_v[5] * 1.;
-     f_v[4] += f_v[5] * 1.;
-     ok &= std::fabs( f_v[2] - 1. ) <= 1e-10; // f4_v2
-     ok &= std::fabs( f_v[4] - 1. ) <= 1e-10; // f4_v4
-
-     // f3 = f4( v1 , v2 , v3 , v3 / 2 )
-     f_v[3] += f_v[4] / 2.;
-     ok &= std::fabs( f_v[3] - 0.5) <= 1e-10; // f3_v3
-
-     // f2 = f3( v1 , v2 , v1 * v1 )
-     f_v[1] += f_v[3] * 2. * v0[1];
-     ok &= std::fabs( f_v[1] - 0.5) <= 1e-10; // f2_v1
-
-     // f1 = f2( v1 , 1 + v1 )
-     f_v[1] += f_v[2] * 1.;
-     ok &= std::fabs( f_v[1] - 1.5) <= 1e-10; // f1_v1
-
-     return ok;
-}
- -
Input File: introduction/exp_2_rev1.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2_rev1.cpp_xml.js cppad-2019.02.00.0/doc/_exp_2_rev1.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_2_rev1.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2_rev1.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_2.xml', -'exp_2_rev1.xml', -'exp_2_rev1.cpp.xml' -]; -var list_down3 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down2 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.xml' -]; -var list_down1 = [ -'exp_2_rev1.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-2018.00.00.0/doc/exp_2_rev1.xml cppad-2019.02.00.0/doc/exp_2_rev1.xml --- cppad-2018.00.00.0/doc/exp_2_rev1.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2_rev1.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1133 +0,0 @@ - - - -exp_2: First Order Reverse Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
exp_2: First Order Reverse Mode
-
-Purpose -
-First order reverse mode uses the -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 the order of the computations in the original algorithm. - -
-
-Mathematical Form -
-Suppose that we use the algorithm exp_2.hpp - to compute - - -f -( -x -) -= -1 -+ -x -+ -x -2 - -/ -2 - - -The corresponding derivative function is - - - -x - -f -( -x -) -= -1 -+ -x - - -
-f_5 -
-For our example, we chose to compute the derivative -of the value returned by exp_2.hpp - -which is equal to the symbol - -v -5 - - - - in the -exp_2 operation sequence -. -We begin with the function - -f -5 - - - - where - -v -5 - - - - -is both an argument and the value of the function; i.e., - - - -f -5 - -( -v -1 - -, -v -2 - -, -v -3 - -, -v -4 - -, -v -5 - -) - -= - -v -5 - - - -f -5 - - - -v -5 - - - - -= - -1 - - - -All the other partial derivatives of - -f -5 - - - - are zero. - -
-
-Index 5: f_4 -
-Reverse mode starts with the last operation in the sequence. -For the case in question, this is the operation with index 5, - - -v -5 - -= -v -2 - -+ -v -4 - - - -We define the function - - -f -4 - -( -v -1 - -, -v -2 - -, -v -3 - -, -v -4 - -) - - - -as equal to - -f -5 - - - - -except that - -v -5 - - - - is eliminated using -this operation; i.e. - - -f -4 - -= -f -5 - -[ -v -1 - -, -v -2 - -, -v -3 - -, -v -4 - -, -v -5 - -( -v -2 - -, -v -4 - -) -] - - -It follows that - - - - -f -4 - - - -v -2 - - - - -= - - -f -5 - - - -v -2 - - - -+ - -f -5 - - - -v -5 - - - -* - -v -5 - - - -v -2 - - - - -= -1 - - -f -4 - - - -v -4 - - - - -= - - -f -5 - - - -v -4 - - - -+ - -f -5 - - - -v -5 - - - -* - -v -5 - - - -v -4 - - - - -= -1 - - - -All the other partial derivatives of - -f -4 - - - - are zero. - -
-
-Index 4: f_3 -
-The next operation has index 4, - - -v -4 - -= -v -3 - -/ -2 - - -We define the function - - -f -3 - -( -v -1 - -, -v -2 - -, -v -3 - -) - - - -as equal to - -f -4 - - - - -except that - -v -4 - - - - is eliminated using this operation; i.e., - - -f -3 - -= -f -4 - -[ -v -1 - -, -v -2 - -, -v -3 - -, -v -4 - -( -v -3 - -) -] - - -It follows that - - - - -f -3 - - - -v -1 - - - - -= - - -f -4 - - - -v -1 - - - - -= -0 - - -f -3 - - - -v -2 - - - - -= - - -f -4 - - - -v -2 - - - - -= -1 - - -f -3 - - - -v -3 - - - - -= - - -f -4 - - - -v -3 - - - -+ - -f -4 - - - -v -4 - - - -* - -v -4 - - - -v -3 - - - - -= -0.5 - - - -
-Index 3: f_2 -
-The next operation has index 3, - - -v -3 - -= -v -1 - -* -v -1 - - - -We define the function - - -f -2 - -( -v -1 - -, -v -2 - -) - - - -as equal to - -f -3 - - - - -except that - -v -3 - - - - is eliminated using this operation; i.e., - - -f -2 - -= -f -3 - -[ -v -1 - -, -v -2 - -, -v -3 - -( -v -1 - -) -] - - -Note that the value of - -v -1 - - - - is equal to - -x - - - -which is .5 for this evaluation. -It follows that - - - - -f -2 - - - -v -1 - - - - -= - - -f -3 - - - -v -1 - - - -+ - -f -3 - - - -v -3 - - - -* - -v -3 - - - -v -1 - - - - -= -0.5 - - -f -2 - - - -v -2 - - - - -= - - -f -3 - - - -v -2 - - - - -= -1 - - - -
-Index 2: f_1 -
-The next operation has index 2, - - -v -2 - -= -1 -+ -v -1 - - - -We define the function - - -f -1 - -( -v -1 - -) - - - -as equal to - -f -2 - - - - -except that - -v -2 - - - - is eliminated using this operation; i.e., - - -f -1 - -= -f -2 - -[ -v -1 - -, -v -2 - -( -v -1 - -) -] - - -It follows that - - - - -f -1 - - - -v -1 - - - - -= - - -f -2 - - - -v -1 - - - -+ - -f -2 - - - -v -2 - - - -* - -v -2 - - - -v -1 - - - - -= -1.5 - - - -Note that - -v -1 - - - - is equal to - -x - - -, -so the derivative of this is the derivative of -the function defined by exp_2.hpp - at - -x -= -.5 - - -. - - -
-
-Verification -
-The file 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 - - -f -j - - - - that might not be equal to the corresponding -partials of - -f -j -+ -1 - - - - -; i.e., the -other partials of - -f -j - - - - must be equal to the corresponding -partials of - -f -j -+ -1 - - - - -. - -
-
-Exercises - -
  1. -Which statement in the routine defined by exp_2_rev1.cpp - uses -the values that are calculated by the routine -defined by exp_2_for0.cpp - ? -
  2. - -Consider the case where - -x -= -.1 - - - -and we first preform a zero order forward sweep -for the operation sequence used above. -What are the results of a -first order reverse sweep; i.e., -what are the corresponding derivatives of - - -f -5 - -, -f -4 - -, - -, -f -1 - - - -. -
  3. - -Create a modified version of -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 -exp_2_rev1.cpp -. -
- - - -
Input File: introduction/exp_2.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2_rev1_xml.js cppad-2019.02.00.0/doc/_exp_2_rev1_xml.js --- cppad-2018.00.00.0/doc/_exp_2_rev1_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2_rev1_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', -'introduction.xml', -'exp_2.xml', -'exp_2_rev1.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.xml' -]; -var list_down0 = [ -'exp_2_rev1.cpp.xml' -]; -var list_current0 = [ -'exp_2_rev1.xml#Purpose', -'exp_2_rev1.xml#Mathematical Form', -'exp_2_rev1.xml#f_5', -'exp_2_rev1.xml#Index 5: f_4', -'exp_2_rev1.xml#Index 4: f_3', -'exp_2_rev1.xml#Index 3: f_2', -'exp_2_rev1.xml#Index 2: f_1', -'exp_2_rev1.xml#Verification', -'exp_2_rev1.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_2_rev2.cpp.xml cppad-2019.02.00.0/doc/exp_2_rev2.cpp.xml --- cppad-2018.00.00.0/doc/exp_2_rev2.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2_rev2.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ - - - -exp_2: Verify Second Order Reverse Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_2_rev2.cppHeadings

-
exp_2: Verify Second Order Reverse Sweep
-
# include <cstddef>                 // define size_t
-# include <cmath>                   // prototype for fabs
-extern bool exp_2_for0(double *v0); // computes zero order forward sweep
-extern bool exp_2_for1(double *v1); // computes first order forward sweep
-bool exp_2_rev2(void)
-{     bool ok = true;
-
-     // set the value of v0[j], v1[j] for j = 1 , ... , 5
-     double v0[6], v1[6];
-     ok &= exp_2_for0(v0);
-     ok &= exp_2_for1(v1);
-
-     // initial all partial derivatives as zero
-     double f_v0[6], f_v1[6];
-     size_t j;
-     for(j = 0; j < 6; j++)
-     {     f_v0[j] = 0.;
-          f_v1[j] = 0.;
-     }
-
-     // set partial derivative for f_5
-     f_v1[5] = 1.;
-     ok &= std::fabs( f_v1[5] - 1. ) <= 1e-10; // partial f_5 w.r.t v_5^1
-
-     // f_4 = f_5( v_1^0 , ... , v_4^1 , v_2^0 + v_4^0 , v_2^1 + v_4^1 )
-     f_v0[2] += f_v0[5] * 1.;
-     f_v0[4] += f_v0[5] * 1.;
-     f_v1[2] += f_v1[5] * 1.;
-     f_v1[4] += f_v1[5] * 1.;
-     ok &= std::fabs( f_v0[2] - 0. ) <= 1e-10; // partial f_4 w.r.t. v_2^0
-     ok &= std::fabs( f_v0[4] - 0. ) <= 1e-10; // partial f_4 w.r.t. v_4^0
-     ok &= std::fabs( f_v1[2] - 1. ) <= 1e-10; // partial f_4 w.r.t. v_2^1
-     ok &= std::fabs( f_v1[4] - 1. ) <= 1e-10; // partial f_4 w.r.t. v_4^1
-
-     // f_3 = f_4( v_1^0 , ... , v_3^1, v_3^0 / 2 , v_3^1 / 2 )
-     f_v0[3] += f_v0[4] / 2.;
-     f_v1[3] += f_v1[4] / 2.;
-     ok &= std::fabs( f_v0[3] - 0.  ) <= 1e-10; // partial f_3 w.r.t. v_3^0
-     ok &= std::fabs( f_v1[3] - 0.5 ) <= 1e-10; // partial f_3 w.r.t. v_3^1
-
-     // f_2 = f_3(  v_1^0 , ... , v_2^1, v_1^0 * v_1^0 , 2 * v_1^0 * v_1^1 )
-     f_v0[1] += f_v0[3] * 2. * v0[1];
-     f_v0[1] += f_v1[3] * 2. * v1[1];
-     f_v1[1] += f_v1[3] * 2. * v0[1];
-     ok &= std::fabs( f_v0[1] - 1.  ) <= 1e-10; // partial f_2 w.r.t. v_1^0
-     ok &= std::fabs( f_v1[1] - 0.5 ) <= 1e-10; // partial f_2 w.r.t. v_1^1
-
-     // f_1 = f_2( v_1^0 , v_1^1 , 1 + v_1^0 , v_1^1 )
-     f_v0[1] += f_v0[2] * 1.;
-     f_v1[1] += f_v1[2] * 1.;
-     ok &= std::fabs( f_v0[1] - 1. ) <= 1e-10; // partial f_1 w.r.t. v_1^0
-     ok &= std::fabs( f_v1[1] - 1.5) <= 1e-10; // partial f_1 w.r.t. v_1^1
-
-     return ok;
-}
- -
Input File: introduction/exp_2_rev2.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2_rev2.cpp_xml.js cppad-2019.02.00.0/doc/_exp_2_rev2.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_2_rev2.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2_rev2.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_2.xml', -'exp_2_rev2.xml', -'exp_2_rev2.cpp.xml' -]; -var list_down3 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down2 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.xml' -]; -var list_down1 = [ -'exp_2_rev2.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-2018.00.00.0/doc/exp_2_rev2.xml cppad-2019.02.00.0/doc/exp_2_rev2.xml --- cppad-2018.00.00.0/doc/exp_2_rev2.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2_rev2.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1998 +0,0 @@ - - - -exp_2: Second Order Reverse Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
exp_2: Second Order Reverse Mode
-
-Purpose -
-In general, a second order reverse sweep is given the -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, -with respect to all of the independent variables. - -
-
-Mathematical Form -
-Suppose that we use the algorithm exp_2.hpp - to compute - - -f -( -x -) -= -1 -+ -x -+ -x -2 - -/ -2 - - -The corresponding second derivative is - - - -2 - - - - -x - -2 - - - - -f -( -x -) -= -1 - - -
-f_5 -
-For our example, we chose to compute the derivative of - -v -5 -( -1 -) - - - - - -with respect to all the independent variable. -For the case computed for the -first order sweep -, - - -v -5 -( -1 -) - - - - - is the derivative -of the value returned by exp_2.hpp -. -This the value computed will be the second derivative of -the value returned by exp_2.hpp -. -We begin with the function - -f -5 - - - - where - -v -5 -( -1 -) - - - - - -is both an argument and the value of the function; i.e., - - - -f -5 - -(v -1 -( -0 -) - - -, -v -1 -( -1 -) - - -, - -, -v -5 -( -0 -) - - -, -v -5 -( -1 -) - - -) - -= - -v -5 -( -1 -) - - - - -f -5 - - - -v -5 -( -1 -) - - - - - -= - -1 - - - -All the other partial derivatives of - -f -5 - - - - are zero. - -
-
-Index 5: f_4 -
-Second order reverse mode starts with the last operation in the sequence. -For the case in question, this is the operation with index 5. -The zero and first order sweep representations of this operation are - - - -v -5 -( -0 -) - - - -= - -v -2 -( -0 -) - - -+ -v -4 -( -0 -) - - - -v -5 -( -1 -) - - - -= - -v -2 -( -1 -) - - -+ -v -4 -( -1 -) - - - - - -We define the function - - -f -4 - -(v -1 -( -0 -) - - -, - -, -v -4 -( -1 -) - - -) - - - -as equal to - -f -5 - - - - -except that - -v -5 -( -0 -) - - - - - and - -v -5 -( -1 -) - - - - - are eliminated using -this operation; i.e. - - -f -4 - -= -f -5 - -[v -1 -( -0 -) - - -, - -, -v -4 -( -1 -) - - -, -v -5 -( -0 -) - - -(v -2 -( -0 -) - - -, -v -4 -( -0 -) - - -) -, -v -5 -( -1 -) - - -(v -2 -( -1 -) - - -, -v -4 -( -1 -) - - -) -] - - -It follows that - - - - -f -4 - - - -v -2 -( -1 -) - - - - - -= - - -f -5 - - - -v -2 -( -1 -) - - - - -+ - -f -5 - - - -v -5 -( -1 -) - - - - -* - -v -5 -( -1 -) - - - - -v -2 -( -1 -) - - - - - -= -1 - - -f -4 - - - -v -4 -( -1 -) - - - - - -= - - -f -5 - - - -v -4 -( -1 -) - - - - -+ - -f -5 - - - -v -5 -( -1 -) - - - - -* - -v -5 - - - -v -4 -( -1 -) - - - - - -= -1 - - - -All the other partial derivatives of - -f -4 - - - - are zero. - -
-
-Index 4: f_3 -
-The next operation has index 4, - - - -v -4 -( -0 -) - - - -= - -v -3 -( -0 -) - - -/ -2 - -v -4 -( -1 -) - - - -= - -v -3 -( -1 -) - - -/ -2 - - - -We define the function - - -f -3 - -(v -1 -( -0 -) - - -, - -, -v -3 -( -1 -) - - -) - - - -as equal to - -f -4 - - - - -except that - -v -4 -( -0 -) - - - - - and - -v -4 -( -1 -) - - - - - -are eliminated using this operation; i.e., - - -f -3 - -= -f -4 - -[v -1 -( -0 -) - - -, - -, -v -3 -( -1 -) - - -, -v -4 -( -0 -) - - -(v -3 -( -0 -) - - -) -, -v -4 -( -1 -) - - -(v -3 -( -1 -) - - -) -] - - -It follows that - - - - -f -3 - - - -v -2 -( -1 -) - - - - - -= - - -f -4 - - - -v -2 -( -1 -) - - - - - -= -1 - - -f -3 - - - -v -3 -( -1 -) - - - - - -= - - -f -4 - - - -v -3 -( -1 -) - - - - -+ - -f -4 - - - -v -4 -( -1 -) - - - - -* - -v -4 -( -1 -) - - - - -v -3 -( -1 -) - - - - - -= -0.5 - - - -All the other partial derivatives of - -f -3 - - - - are zero. - -
-
-Index 3: f_2 -
-The next operation has index 3, - - - -v -3 -( -0 -) - - - -= - -v -1 -( -0 -) - - -* -v -1 -( -0 -) - - - -v -3 -( -1 -) - - - -= - -2 -* -v -1 -( -0 -) - - -* -v -1 -( -1 -) - - - - - -We define the function - - -f -2 - -(v -1 -( -0 -) - - -, - -, -v -2 -( -1 -) - - -) - - - -as equal to - -f -3 - - - - -except that - -v -3 -( -0 -) - - - - - and - -v -3 -( -1 -) - - - - - are -eliminated using this operation; i.e., - - -f -2 - -= -f -3 - -[v -1 -( -0 -) - - -, - -, -v -2 -( -1 -) - - -, -v -3 -( -0 -) - - -( -v -1 -( -0 -) - - -) -, -v -3 -( -1 -) - - -( -v -1 -( -0 -) - - -, -v -1 -( -1 -) - - -) -] - - -Note that, from the -first order forward sweep -, -the value of - -v -1 -( -0 -) - - - - - is equal to - -.5 - - - -and - -v -1 -( -1 -) - - - - - is equal 1. -It follows that - - - - -f -2 - - - -v -1 -( -0 -) - - - - - -= - - -f -3 - - - -v -1 -( -0 -) - - - - -+ - -f -3 - - - -v -3 -( -0 -) - - - - -* - -v -3 -( -0 -) - - - - -v -1 -( -0 -) - - - - -+ - -f -3 - - - -v -3 -( -1 -) - - - - -* - -v -3 -( -1 -) - - - - -v -1 -( -0 -) - - - - - -= -1 - - -f -2 - - - -v -1 -( -1 -) - - - - - -= - - -f -3 - - - -v -1 -( -1 -) - - - - -+ - -f -3 - - - -v -3 -( -1 -) - - - - -* - -v -3 -( -1 -) - - - - -v -1 -( -1 -) - - - - - -= -0.5 - - -f -2 - - - -v -2 -( -0 -) - - - - - -= - - -f -3 - - - -v -2 -( -0 -) - - - - - -= -0 - - -f -2 - - - -v -2 -( -1 -) - - - - - -= - - -f -3 - - - -v -2 -( -1 -) - - - - - -= -1 - - - -
-Index 2: f_1 -
-The next operation has index 2, - - - -v -2 -( -0 -) - - - -= - -1 -+ -v -1 -( -0 -) - - - -v -2 -( -1 -) - - - -= - -v -1 -( -1 -) - - - - - -We define the function - - -f -1 - -( -v -1 -( -0 -) - - -, -v -1 -( -1 -) - - -) - - - -as equal to - -f -2 - - - - -except that - -v -2 -( -0 -) - - - - - and - -v -2 -( -1 -) - - - - - -are eliminated using this operation; i.e., - - -f -1 - -= -f -2 - -[v -1 -( -0 -) - - -, -v -1 -( -1 -) - - -, -v -2 -( -0 -) - - -( -v -1 -( -0 -) - - -) -, -v -2 -( -1 -) - - -( -v -1 -( -1 -) - - -) -] - - -It follows that - - - - -f -1 - - - -v -1 -( -0 -) - - - - - -= - - -f -2 - - - -v -1 -( -0 -) - - - - -+ - -f -2 - - - -v -2 -( -0 -) - - - - -* - -v -2 -( -0 -) - - - - -v -1 -( -0 -) - - - - - -= -1 - - -f -1 - - - -v -1 -( -1 -) - - - - - -= - - -f -2 - - - -v -1 -( -1 -) - - - - -+ - -f -2 - - - -v -2 -( -1 -) - - - - -* - -v -2 -( -1 -) - - - - -v -1 -( -1 -) - - - - - -= -1.5 - - - -Note that - -v -1 - - - - is equal to - -x - - -, -so the second derivative of -the function defined by exp_2.hpp - at - -x -= -.5 - - - -is given by - - - -2 - - - - -x - -2 - - - - -v -5 -( -0 -) - - -= - -v -5 -( -1 -) - - - - -x - - -= - -v -5 -( -1 -) - - - - -v -1 -( -0 -) - - - - -= - -f -1 - - - -v -1 -( -0 -) - - - - -= -1 - - -There is a theorem about Algorithmic Differentiation that explains why -the other partial of - -f -1 - - - - is equal to the -first derivative of -the function defined by exp_2.hpp - at - -x -= -.5 - - -. - - - -
-
-Verification -
-The file 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 - - -f -j - - - - that might not be equal to the corresponding -partials of - -f -j -+ -1 - - - - -; i.e., the -other partials of - -f -j - - - - must be equal to the corresponding -partials of - -f -j -+ -1 - - - - -. - -
-
-Exercises - -
  1. -Which statement in the routine defined by exp_2_rev2.cpp - uses -the values that are calculated by the routine -defined by exp_2_for0.cpp - ? -Which statements use values that are calculate by the routine -defined in exp_2_for1.cpp - ? -
  2. - -Consider the case where - -x -= -.1 - - - -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 -second order reverse sweep; i.e., -what are the corresponding derivatives of - - -f -5 - -, -f -4 - -, - -, -f -1 - - - -. -
  3. - -Create a modified version of -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 -exp_2_rev2.cpp -. -
- - - -
Input File: introduction/exp_2.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2_rev2_xml.js cppad-2019.02.00.0/doc/_exp_2_rev2_xml.js --- cppad-2018.00.00.0/doc/_exp_2_rev2_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2_rev2_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', -'introduction.xml', -'exp_2.xml', -'exp_2_rev2.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.xml' -]; -var list_down0 = [ -'exp_2_rev2.cpp.xml' -]; -var list_current0 = [ -'exp_2_rev2.xml#Purpose', -'exp_2_rev2.xml#Mathematical Form', -'exp_2_rev2.xml#f_5', -'exp_2_rev2.xml#Index 5: f_4', -'exp_2_rev2.xml#Index 4: f_3', -'exp_2_rev2.xml#Index 3: f_2', -'exp_2_rev2.xml#Index 2: f_1', -'exp_2_rev2.xml#Verification', -'exp_2_rev2.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_2.xml cppad-2019.02.00.0/doc/exp_2.xml --- cppad-2018.00.00.0/doc/exp_2.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_2.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,401 +0,0 @@ - - - -Second Order Exponential Approximation - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Second Order Exponential Approximation
-
-Syntax - -
- -# include "exp_2.hpp" - -
-
-y = exp_2(x) - - - -
-
-Purpose -
-This is a simple example algorithm that is used to demonstrate -Algorithmic Differentiation -(see exp_eps - for a more complex example). - -
-
-Mathematical Form -
-The exponential function can be defined by - - -exp -( -x -) -= -1 -+ -x -1 - -/ -1 -! -+ -x -2 - -/ -2 -! -+ - - - -The second order approximation for the exponential function is - - -exp -_ -2 - -( -x -) -= -1 -+ -x -+ -x -2 - -/ -2 - - -
-include -
-The include command in the syntax is relative to - -
-     cppad-
yyyymmdd/introduction/exp_apx
-
-where -cppad-yyyymmdd - is the distribution directory -created during the beginning steps of the -installation - of CppAD. - -
-
-x -
-The argument -x - has prototype - -
-     const 
Type &x
-
-(see -Type - below). -It specifies the point at which to evaluate the -approximation for the second order exponential approximation. - -
-
-y -
-The result -y - has prototype - -
-     
Type y
-
-It is the value of the exponential function -approximation defined above. - -
-
-Type -
-If -u - and -v - are -Type - objects and -i - -is an int: - - -
- -Operation - Result Type - Description -
- - -Type(i) - - - -Type - - - construct object with value equal to -i - -
- - -Type u = v - - - -Type - - - construct -u - with value equal to -v - -
- - -u * v - - - -Type - - - result is value of - -u -* -v - - - -
- - -u / v - - - -Type - - - result is value of - -u -/ -v - - - -
- - -u + v - - - -Type - - - result is value of - -u -+ -v - - - -
-
-Contents -
- -
exp_2.hppexp_2: Implementation
exp_2.cppexp_2: Test
exp_2_for0exp_2: Operation Sequence and Zero Order Forward Mode
exp_2_for1exp_2: First Order Forward Mode
exp_2_rev1exp_2: First Order Reverse Mode
exp_2_for2exp_2: Second Order Forward Mode
exp_2_rev2exp_2: Second Order Reverse Mode
exp_2_cppadexp_2: CppAD Forward and Reverse Sweeps

-Implementation -
-The file exp_2.hpp - -contains a C++ implementation of this function. - -
-
-Test -
-The file exp_2.cpp - -contains a test of this implementation. -It returns true for success and false for failure. - - -
-
-Exercises - -
  1. -Suppose that we make the call -
     
    -     double x = .1;
    -     double y = exp_2(x);
    -
    -What is the value assigned to -v1, v2, ... ,v5 in exp_2.hpp - ? -
  2. - -Extend the routine exp_2.hpp to -a routine exp_3.hpp that computes - - -1 -+ -x -2 - -/ -2 -! -+ -x -3 - -/ -3 -! - - -Do this in a way that only assigns one value to each variable -(as exp_2 does). -
  3. - -Suppose that we make the call -
     
    -     double x = .5;
    -     double y = exp_3(x);
    -
    -using exp_3 created in the previous problem. -What is the value assigned to the new variables in exp_3 -(variables that are in exp_3 and not in exp_2) ? -
- - - -
Input File: introduction/exp_2.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_2_xml.js cppad-2019.02.00.0/doc/_exp_2_xml.js --- cppad-2018.00.00.0/doc/_exp_2_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_2_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_2.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down0 = [ -'exp_2.hpp.xml', -'exp_2.cpp.xml', -'exp_2_for0.xml', -'exp_2_for1.xml', -'exp_2_rev1.xml', -'exp_2_for2.xml', -'exp_2_rev2.xml', -'exp_2_cppad.xml' -]; -var list_current0 = [ -'exp_2.xml#Syntax', -'exp_2.xml#Purpose', -'exp_2.xml#Mathematical Form', -'exp_2.xml#include', -'exp_2.xml#x', -'exp_2.xml#y', -'exp_2.xml#Type', -'exp_2.xml#Contents', -'exp_2.xml#Implementation', -'exp_2.xml#Test', -'exp_2.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_apx.cpp.xml cppad-2019.02.00.0/doc/exp_apx.cpp.xml --- cppad-2018.00.00.0/doc/exp_apx.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_apx.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,152 +0,0 @@ - - - -Correctness Tests For Exponential Approximation in Introduction - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -exp_apx.cpp - -

-
Correctness Tests For Exponential Approximation in Introduction
-
-Running Tests -
-To build this program and run its correctness tests see cmake_check -. - -
-
-Source - - -

-
-// system include files used for I/O
-# include <iostream>
-
-// memory allocation routine
-# include <cppad/utility/thread_alloc.hpp>
-
-// test runner
-# include <cppad/utility/test_boolofvoid.hpp>
-
-// external complied tests
-extern bool exp_2(void);
-extern bool exp_2_cppad(void);
-extern bool exp_2_for1(void);
-extern bool exp_2_for2(void);
-extern bool exp_2_rev1(void);
-extern bool exp_2_rev2(void);
-extern bool exp_2_for0(void);
-extern bool exp_eps(void);
-extern bool exp_eps_cppad(void);
-extern bool exp_eps_for1(void);
-extern bool exp_eps_for2(void);
-extern bool exp_eps_for0(void);
-extern bool exp_eps_rev1(void);
-extern bool exp_eps_rev2(void);
-
-// main program that runs all the tests
-int main(void)
-{     std::string group = "introduction";
-     size_t      width = 20;
-     CppAD::test_boolofvoid Run(group, width);
-
-     // This comment is used by OneTest
-
-     // external compiled tests
-     Run( exp_2,           "exp_2"          );
-     Run( exp_2_cppad,     "exp_2_cppad"    );
-     Run( exp_2_for0,      "exp_2_for0"     );
-     Run( exp_2_for1,      "exp_2_for1"     );
-     Run( exp_2_for2,      "exp_2_for2"     );
-     Run( exp_2_rev1,      "exp_2_rev1"     );
-     Run( exp_2_rev2,      "exp_2_rev2"     );
-     Run( exp_eps,         "exp_eps"        );
-     Run( exp_eps_cppad,   "exp_eps_cppad"  );
-     Run( exp_eps_for0,    "exp_eps_for0"   );
-     Run( exp_eps_for1,    "exp_eps_for1"   );
-     Run( exp_eps_for2,    "exp_eps_for2"   );
-     Run( exp_eps_rev1,    "exp_eps_rev1"   );
-     Run( exp_eps_rev2,    "exp_eps_rev2"   );
-     //
-     // check for memory leak
-     bool memory_ok = CppAD::thread_alloc::free_all();
-     // print summary at end
-     bool ok = Run.summary(memory_ok);
-     //
-     return static_cast<int>( ! ok );
-}
-
-
Input File: introduction/introduction.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_apx.cpp_xml.js cppad-2019.02.00.0/doc/_exp_apx.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_apx.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_apx.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_apx.cpp.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_current0 = [ -'exp_apx.cpp.xml#Running Tests', -'exp_apx.cpp.xml#Source' -]; -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-2018.00.00.0/doc/exp.cpp.xml cppad-2019.02.00.0/doc/exp.cpp.xml --- cppad-2018.00.00.0/doc/exp.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,156 +0,0 @@ - - - -The AD exp Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp.cppHeadings

-
The AD exp Function: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cmath>
-
-bool exp(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::exp(ax[0]);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // check value
-     double check = std::exp(x0);
-     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);
-     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, 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::exp(v[zero]);
-     ok   &= NearEqual(result, check, eps, eps);
-
-     return ok;
-}
-
-
-
Input File: example/general/exp.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp.cpp_xml.js cppad-2019.02.00.0/doc/_exp.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'exp.xml', -'exp.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 = [ -'exp.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-2018.00.00.0/doc/exp_eps_cppad.xml cppad-2019.02.00.0/doc/exp_eps_cppad.xml --- cppad-2018.00.00.0/doc/exp_eps_cppad.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps_cppad.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,286 +0,0 @@ - - - -exp_eps: CppAD Forward and Reverse Sweeps - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_eps_cppad - -

-
exp_eps: CppAD Forward and Reverse Sweeps
-. - -
-
-Purpose -
-Use CppAD forward and reverse modes to compute the -partial derivative with respect to - -x - - -, -at the point - -x -= -.5 - - - and - -ε -= -.2 - - -, -of the function - -
-     exp_eps(
xepsilon)
-
-as defined by the exp_eps.hpp - include file. - -
-
-Exercises - -
  1. -Create and test a modified version of the routine below that computes -the same order derivatives with respect to - -x - - -, -at the point - -x -= -.1 - - - and - -ε -= -.2 - - -, -of the function - -
    -     exp_eps(
    xepsilon)
    -
    -
  2. -Create and test a modified version of the routine below that computes -partial derivative with respect to - -x - - -, -at the point - -x -= -.1 - - - and - -ε -= -.2 - - -, -of the function corresponding to the operation sequence -for - -x -= -.5 - - - and - -ε -= -.2 - - -. -Hint: you could define a vector u with two components and use - -
    -     
    f.Forward(0, u)
    -
    -to run zero order forward mode at a point different -form the point where the operation sequence corresponding to - -f - was recorded. -
- -
# include <cppad/cppad.hpp>  // http://www.coin-or.org/CppAD/
-# include "exp_eps.hpp"      // our example exponential function approximation
-bool exp_eps_cppad(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::vector;    // can use any simple vector template class
-     using CppAD::NearEqual; // checks if values are nearly equal
-
-     // domain space vector
-     size_t n = 2; // dimension of the domain space
-     vector< AD<double> > U(n);
-     U[0] = .5;    // value of x for this operation sequence
-     U[1] = .2;    // value of e for this operation sequence
-
-     // declare independent variables and start recording operation sequence
-     CppAD::Independent(U);
-
-     // evaluate our exponential approximation
-     AD<double> x       = U[0];
-     AD<double> epsilon = U[1];
-     AD<double> apx = exp_eps(x, epsilon);
-
-     // range space vector
-     size_t m = 1;  // dimension of the range space
-     vector< AD<double> > Y(m);
-     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
-     // mode sweep using values in U for x and e.
-     CppAD::ADFun<double> f(U, Y);
-
-     // first order forward mode sweep that computes partial w.r.t x
-     vector<double> du(n);      // differential in domain space
-     vector<double> dy(m);      // differential in range space
-     du[0] = 1.;                // x direction in domain space
-     du[1] = 0.;
-     dy    = f.Forward(1, du);  // partial w.r.t. x
-     double check = 1.5;
-     ok   &= NearEqual(dy[0], check, 1e-10, 1e-10);
-
-     // first order reverse mode sweep that computes the derivative
-     vector<double>  w(m);     // weights for components of the range
-     vector<double> dw(n);     // derivative of the weighted function
-     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);
-     check = 0.;               // partial w.r.t. epsilon
-     ok   &= NearEqual(dw[1], check, 1e-10, 1e-10);
-
-     // second order forward sweep that computes
-     // second partial of exp_eps(x, epsilon) w.r.t. x
-     vector<double> x2(n);     // second order Taylor coefficients
-     vector<double> y2(m);
-     x2[0] = 0.;               // evaluate partial w.r.t x
-     x2[1] = 0.;
-     y2    = f.Forward(2, x2);
-     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
-     // derivative of partial of exp_eps(x, epsilon) w.r.t. x
-     dw.resize(2 * n);         // space for first and second derivative
-     dw    = f.Reverse(2, w);
-     check = 1.;               // result should be second derivative
-     ok   &= NearEqual(dw[0*2+1], check, 1e-10, 1e-10);
-
-     return ok;
-}
- -
Input File: introduction/exp_eps_cppad.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps_cppad_xml.js cppad-2019.02.00.0/doc/_exp_eps_cppad_xml.js --- cppad-2018.00.00.0/doc/_exp_eps_cppad_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps_cppad_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', -'introduction.xml', -'exp_eps.xml', -'exp_eps_cppad.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.xml' -]; -var list_current0 = [ -'exp_eps_cppad.xml#Purpose', -'exp_eps_cppad.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_eps.cpp.xml cppad-2019.02.00.0/doc/exp_eps.cpp.xml --- cppad-2018.00.00.0/doc/exp_eps.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ - - - -exp_eps: Test of exp_eps - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_eps.cppHeadings

-
exp_eps: Test of exp_eps
-
# include <cmath>             // for fabs function
-# include "exp_eps.hpp"       // definition of exp_eps algorithm
-bool exp_eps(void)
-{     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;
-     return ok;
-}
-
-
Input File: introduction/exp_eps.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps.cpp_xml.js cppad-2019.02.00.0/doc/_exp_eps.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_eps.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.xml', -'exp_eps.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.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-2018.00.00.0/doc/exp_eps_for0.cpp.xml cppad-2019.02.00.0/doc/exp_eps_for0.cpp.xml --- cppad-2018.00.00.0/doc/exp_eps_for0.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps_for0.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ - - - -exp_eps: Verify Zero Order Forward Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_eps_for0.cppHeadings

- - - - -
exp_eps: Verify Zero Order Forward Sweep
-
# include <cmath>                // for fabs function
-bool exp_eps_for0(double *v0)    // double v0[8]
-{     bool  ok = true;
-     double x = .5;
-
-     v0[1] = x;                                  // abs_x = x;
-     ok  &= std::fabs( v0[1] - 0.5) < 1e-10;
-
-     v0[2] = 1. * v0[1];                         // temp = term * abs_x;
-     ok  &= std::fabs( v0[2] - 0.5) < 1e-10;
-
-     v0[3] = v0[2] / 1.;                         // term = temp / Type(k);
-     ok  &= std::fabs( v0[3] - 0.5) < 1e-10;
-
-     v0[4] = 1. + v0[3];                         // sum = sum + term;
-     ok  &= std::fabs( v0[4] - 1.5) < 1e-10;
-
-     v0[5] = v0[3] * v0[1];                      // temp = term * abs_x;
-     ok  &= std::fabs( v0[5] - 0.25) < 1e-10;
-
-     v0[6] = v0[5] / 2.;                         // term = temp / Type(k);
-     ok  &= std::fabs( v0[6] - 0.125) < 1e-10;
-
-     v0[7] = v0[4] + v0[6];                      // sum = sum + term;
-     ok  &= std::fabs( v0[7] - 1.625) < 1e-10;
-
-     return ok;
-}
-bool exp_eps_for0(void)
-{     double v0[8];
-     return exp_eps_for0(v0);
-}
- -
Input File: introduction/exp_eps_for0.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps_for0.cpp_xml.js cppad-2019.02.00.0/doc/_exp_eps_for0.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_eps_for0.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps_for0.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.xml', -'exp_eps_for0.xml', -'exp_eps_for0.cpp.xml' -]; -var list_down3 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down2 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.xml' -]; -var list_down1 = [ -'exp_eps_for0.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-2018.00.00.0/doc/exp_eps_for0.xml cppad-2019.02.00.0/doc/exp_eps_for0.xml --- cppad-2018.00.00.0/doc/exp_eps_for0.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps_for0.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,666 +0,0 @@ - - - -exp_eps: Operation Sequence and Zero Order Forward Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
exp_eps: Operation Sequence and Zero Order Forward Sweep
-
-Mathematical Form -
-Suppose that we use the algorithm exp_eps.hpp - -to compute -exp_eps(xepsilon) - -with -x - is equal to .5 -and -epsilon - is equal to .2. -For this case, -the mathematical form for the operation sequence -corresponding to the exp_eps is - - -f -( -x -, -ε -) -= -1 -+ -x -+ -x -2 - -/ -2 - - -Note that, for these particular values of -x - and -epsilon -, -this is the same as the mathematical form for -exp_2 -. - - -
-
-Operation Sequence -
-We consider the -operation sequence - -corresponding to the algorithm exp_eps.hpp - -with the argument -x - is equal to .5 -and -epsilon - is equal to .2. - -
-
-Variable -
-We refer to values that depend on the input variables - -x - and -epsilon - as variables. - -
-
-Parameter -
-We refer to values that do not depend on the input variables - -x - or -epsilon - as parameters. -Operations where the result is a parameter are not included -in the zero order sweep below. - - -
-
-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 -and ends with the last. - -
-
-Code -
-The Code column contains the C++ source code corresponding -to the corresponding atomic operation in the sequence. - -
-
-Operation -
-The Operation column contains the -mathematical function corresponding to each atomic operation in the sequence. - -
-
-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; -i.e., in order of increasing index. - - -
-
-Sweep - -
- -
- -Index - -    - Code - -    - Operation - -    - Zero Order -
- -1 - -    - abs_x = x; - - - - -v -1 - -= -x - - - - - - - -v -1 -( -0 -) - - -= -0.5 - - - -
- -2 - -    - temp = term * abs_x; - - - - -v -2 - -= -1 -* -v -1 - - - - - - - - -v -2 -( -0 -) - - -= -0.5 - - - -
- -3 - -    - term = temp / Type(k); - - - - -v -3 - -= -v -2 - -/ -1 - - - - - - - -v -3 -( -0 -) - - -= -0.5 - - - -
- -4 - -    - sum = sum + term; - - - - -v -4 - -= -1 -+ -v -3 - - - - - - - - -v -4 -( -0 -) - - -= -1.5 - - - -
- -5 - -    - temp = term * abs_x; - - - - -v -5 - -= -v -3 - -* -v -1 - - - - - - - - -v -5 -( -0 -) - - -= -0.25 - - - -
- -6 - -    - term = temp / Type(k); - - - - -v -6 - -= -v -5 - -/ -2 - - - - - - - -v -6 -( -0 -) - - -= -0.125 - - - -
- -7 - -    - sum = sum + term; - - - - -v -7 - -= -v -4 - -+ -v -6 - - - - - - - - -v -7 -( -0 -) - - -= -1.625 - - - -
-
Return Value -
-The return value for this case is - - -1.625 -= -v -7 -( -0 -) - - -= -f -( -x -( -0 -) - - -, -ε -( -0 -) - - -) - - -
-Comparisons -
-If -x - were negative, -or if -epsilon - were a much smaller or much larger value, -the results of the following comparisons could be different: -
 
-     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 -exp_eps.hpp - -for values of -x - and -epsilon - within a certain range. -Note that there is a neighborhood -of - -x -= -0.5 - - - for which the comparisons would have the -same result and hence the operation sequence would be the same. - - - -
-
-Verification -
-The file exp_eps_for0.cpp - contains a routine -that verifies the values computed above. -It returns true for success and false for failure. - -
-
-Exercises - -
  1. -Suppose that - -x -( -0 -) - - -= -.1 - - -, -what is the result of a zero order forward sweep for -the operation sequence above; -i.e., what are the corresponding values for - - -v -1 -( -0 -) - - -, -v -2 -( -0 -) - - -, - -, -v -7 -( -0 -) - - - - -. -
  2. - -Create a modified version of -exp_eps_for0.cpp - that verifies the values you obtained -for the previous exercise. -
  3. - -Create and run a main program that reports the result of calling -the modified version -of exp_eps_for0.cpp - in the previous exercise. -
- - - -
Input File: introduction/exp_eps.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps_for0_xml.js cppad-2019.02.00.0/doc/_exp_eps_for0_xml.js --- cppad-2018.00.00.0/doc/_exp_eps_for0_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps_for0_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.xml', -'exp_eps_for0.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.xml' -]; -var list_down0 = [ -'exp_eps_for0.cpp.xml' -]; -var list_current0 = [ -'exp_eps_for0.xml#Mathematical Form', -'exp_eps_for0.xml#Operation Sequence', -'exp_eps_for0.xml#Operation Sequence.Variable', -'exp_eps_for0.xml#Operation Sequence.Parameter', -'exp_eps_for0.xml#Operation Sequence.Index', -'exp_eps_for0.xml#Operation Sequence.Code', -'exp_eps_for0.xml#Operation Sequence.Operation', -'exp_eps_for0.xml#Operation Sequence.Zero Order', -'exp_eps_for0.xml#Operation Sequence.Sweep', -'exp_eps_for0.xml#Return Value', -'exp_eps_for0.xml#Comparisons', -'exp_eps_for0.xml#Verification', -'exp_eps_for0.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_eps_for1.cpp.xml cppad-2019.02.00.0/doc/exp_eps_for1.cpp.xml --- cppad-2018.00.00.0/doc/exp_eps_for1.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps_for1.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ - - - -exp_eps: Verify First Order Forward Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_eps_for1.cppHeadings

-
exp_eps: Verify First Order Forward Sweep
-
# include <cmath>                     // for fabs function
-extern bool exp_eps_for0(double *v0); // computes zero order forward sweep
-bool exp_eps_for1(double *v1)         // double v[8]
-{     bool ok = true;
-     double v0[8];
-
-     // set the value of v0[j] for j = 1 , ... , 7
-     ok &= exp_eps_for0(v0);
-
-     v1[1] = 1.;                                      // v1 = x
-     ok    &= std::fabs( v1[1] - 1. ) <= 1e-10;
-
-     v1[2] = 1. * v1[1];                              // v2 = 1 * v1
-     ok    &= std::fabs( v1[2] - 1. ) <= 1e-10;
-
-     v1[3] = v1[2] / 1.;                              // v3 = v2 / 1
-     ok    &= std::fabs( v1[3] - 1. ) <= 1e-10;
-
-     v1[4] = v1[3];                                   // v4 = 1 + v3
-     ok    &= std::fabs( v1[4] - 1. ) <= 1e-10;
-
-     v1[5] = v1[3] * v0[1] + v0[3] * v1[1];           // v5 = v3 * v1
-     ok    &= std::fabs( v1[5] - 1. ) <= 1e-10;
-
-     v1[6] = v1[5] / 2.;                              // v6 = v5 / 2
-     ok    &= std::fabs( v1[6] - 0.5 ) <= 1e-10;
-
-     v1[7] = v1[4] + v1[6];                           // v7 = v4 + v6
-     ok    &= std::fabs( v1[7] - 1.5 ) <= 1e-10;
-
-     return ok;
-}
-bool exp_eps_for1(void)
-{     double v1[8];
-     return exp_eps_for1(v1);
-}
- -
Input File: introduction/exp_eps_for1.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps_for1.cpp_xml.js cppad-2019.02.00.0/doc/_exp_eps_for1.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_eps_for1.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps_for1.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.xml', -'exp_eps_for1.xml', -'exp_eps_for1.cpp.xml' -]; -var list_down3 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down2 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.xml' -]; -var list_down1 = [ -'exp_eps_for1.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-2018.00.00.0/doc/exp_eps_for1.xml cppad-2019.02.00.0/doc/exp_eps_for1.xml --- cppad-2018.00.00.0/doc/exp_eps_for1.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps_for1.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1234 +0,0 @@ - - - -exp_eps: First Order Forward Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
exp_eps: First Order Forward Sweep
-
-First Order Expansion -
-We define - -x -( -t -) - - - and - -ε -( -t -) -] - - - near - -t -= -0 - - - -by the first order expansions - - - -x -( -t -) - -= - -x -( -0 -) - - -+ -x -( -1 -) - - -* -t - -ε -( -t -) - -= - -ε -( -0 -) - - -+ -ε -( -1 -) - - -* -t - - - -It follows that - -x -( -0 -) - - - - - ( - -ε -( -0 -) - - - - -) is the zero, -and - -x -( -1 -) - - - - - ( - -ε -( -1 -) - - - - -) the first, -order derivative of - -x -( -t -) - - - -at - -t -= -0 - - - ( - -ε -( -t -) - - -) -at - -t -= -0 - - -. - -
-
-Mathematical Form -
-Suppose that we use the algorithm exp_eps.hpp - -to compute -exp_eps(xepsilon) - -with -x - is equal to .5 -and -epsilon - is equal to .2. -For this case, the mathematical function for the operation sequence -corresponding to exp_eps is - - -f -( -x -, -ε -) -= -1 -+ -x -+ -x -2 - -/ -2 - - -The corresponding partial derivative with respect to - -x - - -, -and the value of the derivative, are - - - -x - -f -( -x -, -ε -) -= -1 -+ -x -= -1.5 - - -
-Operation Sequence - - -
-
-Index -
-The Index column contains the index in the operation sequence -of the corresponding atomic operation. -A Forward sweep starts with the first operation -and ends with the last. - -
-
-Operation -
-The Operation column contains the -mathematical function corresponding to each atomic operation in the sequence. - -
-
-Zero Order -
-The Zero Order column contains the zero order derivatives -for the corresponding variable in the operation sequence -(see zero order sweep -). - -
-
-Derivative -
-The Derivative column contains the -mathematical function corresponding to the derivative -with respect to - -t - - -, -at - -t -= -0 - - -, for each variable in the sequence. - -
-
-First Order -
-The First Order column contains the first order derivatives -for the corresponding variable in the operation sequence; i.e., - - -v -j - -( -t -) -= -v -j -( -0 -) - - -+ -v -j -( -1 -) - - -t - - -We use - -x -( -1 -) - - -= -1 - - - and - -ε -( -1 -) - - -= -0 - - -, -so that differentiation with respect to - -t - - -, -at - -t -= -0 - - -, -is the same partial differentiation with respect to - -x - - - -at - -x -= -x -( -0 -) - - - - -. - - -
-
-Sweep - - -
- -
- -Index - -    - Operation - -    - Zero Order - -    - Derivative - -    - First Order -
- -1 - -    - - -v -1 - -= -x - - - - - - 0.5 - - - - - -v -1 -( -1 -) - - -= -x -( -1 -) - - - - - - - - - -v -1 -( -1 -) - - -= -1 - - - -
- -2 - -    - - -v -2 - -= -1 -* -v -1 - - - - - - - 0.5 - - - - - -v -2 -( -1 -) - - -= -1 -* -v -1 -( -1 -) - - - - - - - - - -v -2 -( -1 -) - - -= -1 - - - -
- -3 - -    - - -v -3 - -= -v -2 - -/ -1 - - - - - - 0.5 - - - - - -v -3 -( -1 -) - - -= -v -2 -( -1 -) - - -/ -1 - - - - - - - -v -3 -( -1 -) - - -= -1 - - - -
- -4 - -    - - -v -4 - -= -1 -+ -v -3 - - - - - - - 1.5 - - - - - -v -4 -( -1 -) - - -= -v -3 -( -1 -) - - - - - - - - - -v -4 -( -1 -) - - -= -1 - - - -
- -5 - -    - - -v -5 - -= -v -3 - -* -v -1 - - - - - - - 0.25 - - - - - -v -5 -( -1 -) - - -= -v -3 -( -1 -) - - -* -v -1 -( -0 -) - - -+ -v -3 -( -0 -) - - -* -v -1 -( -1 -) - - - - - - - - - -v -5 -( -1 -) - - -= -1 - - - -
- -6 - -    - - -v -6 - -= -v -5 - -/ -2 - - - - - - 0.125 - - - - - -v -6 -( -1 -) - - -= -v -5 -( -1 -) - - -/ -2 - - - - - - - -v -6 -( -1 -) - - -= -0.5 - - - -
- -7 - -    - - -v -7 - -= -v -4 - -+ -v -6 - - - - - - - 1.625 - - - - - -v -7 -( -1 -) - - -= -v -4 -( -1 -) - - -+ -v -6 -( -1 -) - - - - - - - - - -v -7 -( -1 -) - - -= -1.5 - - - -
-
Return Value -
-The derivative of the return value for this case is - - - -1.5 - -= - -v -7 -( -1 -) - - -= -[ -v -7 - - - -t - - -] -t -= -0 - - -= -[ - - -t - - -f -( -x -( -0 -) - - -+ -x -( -1 -) - - -* -t -, -ε -( -0 -) - - -) -] -t -= -0 - - - - -= - - -x - -f -( -x -( -0 -) - - -, -ε -( -0 -) - - -) -* -x -( -1 -) - - -= - -x - -f -( -x -( -0 -) - - -, -ε -( -0 -) - - -) - - - -(We have used the fact that - - -x -( -1 -) - - -= -1 - - - and - -ε -( -1 -) - - -= -0 - - -.) - - - -
-
-Verification -
-The file exp_eps_for1.cpp - contains a routine -that verifies the values computed above. -It returns true for success and false for failure. - -
-
-Exercises - -
  1. -Suppose that - -x -= -.1 - - -, -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 - - -v -1 -( -0 -) - - -, -v -2 -( -0 -) - - -, - -, -v -7 -( -0 -) - - - - - and - - -v -1 -( -1 -) - - -, -v -2 -( -1 -) - - -, - -, -v -7 -( -1 -) - - - - - ? -
  2. - -Create a modified version of 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 -exp_eps_for1.cpp -. -
  3. - -Suppose that - -x -= -.1 - - - and - - -= -.2 - - -, -what is the operation sequence corresponding to - -
    -     exp_eps(
    xepsilon)
    -
    -
- -
Input File: introduction/exp_eps.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps_for1_xml.js cppad-2019.02.00.0/doc/_exp_eps_for1_xml.js --- cppad-2018.00.00.0/doc/_exp_eps_for1_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps_for1_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.xml', -'exp_eps_for1.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.xml' -]; -var list_down0 = [ -'exp_eps_for1.cpp.xml' -]; -var list_current0 = [ -'exp_eps_for1.xml#First Order Expansion', -'exp_eps_for1.xml#Mathematical Form', -'exp_eps_for1.xml#Operation Sequence', -'exp_eps_for1.xml#Operation Sequence.Index', -'exp_eps_for1.xml#Operation Sequence.Operation', -'exp_eps_for1.xml#Operation Sequence.Zero Order', -'exp_eps_for1.xml#Operation Sequence.Derivative', -'exp_eps_for1.xml#Operation Sequence.First Order', -'exp_eps_for1.xml#Operation Sequence.Sweep', -'exp_eps_for1.xml#Return Value', -'exp_eps_for1.xml#Verification', -'exp_eps_for1.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_eps_for2.cpp.xml cppad-2019.02.00.0/doc/exp_eps_for2.cpp.xml --- cppad-2018.00.00.0/doc/exp_eps_for2.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps_for2.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ - - - -exp_eps: Verify Second Order Forward Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_eps_for2.cppHeadings

-
exp_eps: Verify Second Order Forward Sweep
-
# include <cmath>                     // for fabs function
-extern bool exp_eps_for0(double *v0); // computes zero order forward sweep
-extern bool exp_eps_for1(double *v1); // computes first order forward sweep
-bool exp_eps_for2(void)
-{     bool ok = true;
-     double v0[8], v1[8], v2[8];
-
-     // set the value of v0[j], v1[j] for j = 1 , ... , 7
-     ok &= exp_eps_for0(v0);
-     ok &= exp_eps_for1(v1);
-
-     v2[1] = 0.;                                      // v1 = x
-     ok    &= std::fabs( v2[1] - 0. ) <= 1e-10;
-
-     v2[2] = 1. * v2[1];                              // v2 = 1 * v1
-     ok    &= std::fabs( v2[2] - 0. ) <= 1e-10;
-
-     v2[3] = v2[2] / 1.;                              // v3 = v2 / 1
-     ok    &= std::fabs( v2[3] - 0. ) <= 1e-10;
-
-     v2[4] = v2[3];                                   // v4 = 1 + v3
-     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];
-     ok    &= std::fabs( v2[5] - 2. ) <= 1e-10;
-
-     v2[6] = v2[5] / 2.;                              // v6 = v5 / 2
-     ok    &= std::fabs( v2[6] - 1. ) <= 1e-10;
-
-     v2[7] = v2[4] + v2[6];                           // v7 = v4 + v6
-     ok    &= std::fabs( v2[7] - 1. ) <= 1e-10;
-
-     return ok;
-}
- -
Input File: introduction/exp_eps_for2.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps_for2.cpp_xml.js cppad-2019.02.00.0/doc/_exp_eps_for2.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_eps_for2.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps_for2.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.xml', -'exp_eps_for2.xml', -'exp_eps_for2.cpp.xml' -]; -var list_down3 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down2 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.xml' -]; -var list_down1 = [ -'exp_eps_for2.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-2018.00.00.0/doc/exp_eps_for2.xml cppad-2019.02.00.0/doc/exp_eps_for2.xml --- cppad-2018.00.00.0/doc/exp_eps_for2.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps_for2.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1394 +0,0 @@ - - - -exp_eps: Second Order Forward Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
exp_eps: Second Order Forward Mode
-
-Second Order Expansion -
-We define - -x -( -t -) - - - and - -ε -( -t -) -] - - - near - -t -= -0 - - - -by the second order expansions - - - -x -( -t -) - -= - -x -( -0 -) - - -+ -x -( -1 -) - - -* -t -+ -x -( -2 -) - - -* -t -2 - -/ -2 - -ε -( -t -) - -= - -ε -( -0 -) - - -+ -ε -( -1 -) - - -* -t -+ -ε -( -2 -) - - -* -t -2 - -/ -2 - - - -It follows that for - -k -= -0 -, -1 -, -2 - - -, - - - -x -( -k -) - - - -= - -d - -k - - - -d - - -t - -k - - - - -x -( -0 -) - -ε -( -k -) - - - -= - -d - -k - - - -d - - -t - -k - - - - -ε -( -0 -) - - - -
-Purpose -
-In general, a second order forward sweep is given the -first order expansion - -for all of the variables in an operation sequence, -and the second order derivatives for the independent variables. -It uses these to compute the second order derivative, -and thereby obtain the second order expansion, -for all the variables in the operation sequence. - -
-
-Mathematical Form -
-Suppose that we use the algorithm exp_eps.hpp - -to compute -exp_eps(xepsilon) - -with -x - is equal to .5 -and -epsilon - is equal to .2. -For this case, the mathematical function for the operation sequence -corresponding to exp_eps is - - -f -( -x -, -ε -) -= -1 -+ -x -+ -x -2 - -/ -2 - - -The corresponding second partial derivative with respect to - -x - - -, -and the value of the derivative, are - - - -2 - - - - -x - -2 - - - - -f -( -x -, -ε -) -= -1. - - -
-Operation Sequence - - -
-
-Index -
-The Index column contains the index in the operation sequence -of the corresponding atomic operation. -A Forward sweep starts with the first operation -and ends with the last. - -
-
-Zero -
-The Zero column contains the zero order sweep results -for the corresponding variable in the operation sequence -(see zero order sweep -). - -
-
-Operation -
-The Operation column contains the -first order sweep operation for this variable. - -
-
-First -
-The First column contains the first order sweep results -for the corresponding variable in the operation sequence -(see first order sweep -). - -
-
-Derivative -
-The Derivative column contains the -mathematical function corresponding to the second derivative -with respect to - -t - - -, -at - -t -= -0 - - -, for each variable in the sequence. - -
-
-Second -
-The Second column contains the second order derivatives -for the corresponding variable in the operation sequence; i.e., -the second order expansion for the i-th variable is given by - - -v -i - -( -t -) -= -v -i -( -0 -) - - -+ -v -i -( -1 -) - - -* -t -+ -v -i -( -2 -) - - -* -t -2 - -/ -2 - - -We use - -x -( -1 -) - - -= -1 - - -, - -x -( -2 -) - - -= -0 - - -, -use - -ε -( -1 -) - - -= -1 - - -, and - -ε -( -2 -) - - -= -0 - - - -so that second order differentiation -with respect to - -t - - -, at - -t -= -0 - - -, -is the same as the second partial differentiation -with respect to - -x - - - at - -x -= -x -( -0 -) - - - - -. - - -
-
-Sweep - - -
- -
- -Index - -    - Zero - -    - Operation - -    - First - -    - Derivative - -    - Second -
- -1 - - - 0.5 - - - - - -v -1 -( -1 -) - - -= -x -( -1 -) - - - - - - - - 1 - - - - - -v -2 -( -2 -) - - -= -x -( -2 -) - - - - - - - - 0 -
- -2 - - - 0.5 - - - - - -v -2 -( -1 -) - - -= -1 -* -v -1 -( -1 -) - - - - - - - - 1 - - - - - -v -2 -( -2 -) - - -= -1 -* -v -1 -( -2 -) - - - - - - - - 0 -
- -3 - - - 0.5 - - - - - -v -3 -( -1 -) - - -= -v -2 -( -1 -) - - -/ -1 - - - - - - 1 - - - - - -v -3 -( -2 -) - - -= -v -2 -( -2 -) - - -/ -1 - - - - - - 0 -
- -4 - - - 1.5 - - - - - -v -4 -( -1 -) - - -= -v -3 -( -1 -) - - - - - - - - 1 - - - - - -v -4 -( -2 -) - - -= -v -3 -( -2 -) - - - - - - - - 0 -
- -5 - - - 0.25 - - - - - -v -5 -( -1 -) - - -= -v -3 -( -1 -) - - -* -v -1 -( -0 -) - - -+ -v -3 -( -0 -) - - -* -v -1 -( -1 -) - - - - - - - - 1 - - - - - -v -5 -( -2 -) - - -= -v -3 -( -2 -) - - -* -v -1 -( -0 -) - - -+ -2 -* -v -3 -( -1 -) - - -* -v -1 -( -1 -) - - -+ -v -3 -( -0 -) - - -* -v -1 -( -2 -) - - - - - - - - 2 -
- -6 - - - 0.125 - - - - - -v -6 -( -1 -) - - -= -v -5 -( -1 -) - - -/ -2 - - - - - - 0.5 - - - - - -v -6 -( -2 -) - - -= -v -5 -( -2 -) - - -/ -2 - - - - - - 1 -
- -7 - - - 1.625 - - - - - -v -7 -( -1 -) - - -= -v -4 -( -1 -) - - -+ -v -6 -( -1 -) - - - - - - - - 1.5 - - - - - -v -7 -( -2 -) - - -= -v -4 -( -2 -) - - -+ -v -6 -( -2 -) - - - - - - - - 1 -
-
Return Value -
-The second derivative of the return value for this case is - - - -1 - -= - -v -7 -( -2 -) - - -= -[ -2 - - - - -t - -2 - - - - -v -7 - -] -t -= -0 - - -= -[ -2 - - - - -t - -2 - - - - -f -( -x -( -0 -) - - -+ -x -( -1 -) - - -* -t -, -ε -( -0 -) - - -) -] -t -= -0 - - - - -= - -x -( -1 -) - - -* - -2 - - - - -x - -2 - - - - -f -( -x -( -0 -) - - -, -ε -( -0 -) - - -) -* -x -( -1 -) - - -= - -2 - - - - -x - -2 - - - - -f -( -x -( -0 -) - - -, -ε -( -0 -) - - -) - - - -(We have used the fact that - - -x -( -1 -) - - -= -1 - - -, - -x -( -2 -) - - -= -0 - - -, - - -ε -( -1 -) - - -= -1 - - -, and - -ε -( -2 -) - - -= -0 - - -.) - - -
-
-Verification -
-The file exp_eps_for2.cpp - contains a routine -which verifies the values computed above. -It returns true for success and false for failure. - -
-
-Exercises - -
  1. -Which statement in the routine defined by exp_eps_for2.cpp - uses -the values that are calculated by the routine -defined by exp_eps_for1.cpp - ? -
  2. - -Suppose that - -x -= -.1 - - -, -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 - - -v -i -( -k -) - - - - - for - -i -= -1 -, - -, -7 - - - and - -k -= -0 -, -1 -, -2 - - -. -
  3. - -Create a modified version of 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 -exp_eps_for2.cpp -. -
- - - -
Input File: introduction/exp_eps.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps_for2_xml.js cppad-2019.02.00.0/doc/_exp_eps_for2_xml.js --- cppad-2018.00.00.0/doc/_exp_eps_for2_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps_for2_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.xml', -'exp_eps_for2.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.xml' -]; -var list_down0 = [ -'exp_eps_for2.cpp.xml' -]; -var list_current0 = [ -'exp_eps_for2.xml#Second Order Expansion', -'exp_eps_for2.xml#Purpose', -'exp_eps_for2.xml#Mathematical Form', -'exp_eps_for2.xml#Operation Sequence', -'exp_eps_for2.xml#Operation Sequence.Index', -'exp_eps_for2.xml#Operation Sequence.Zero', -'exp_eps_for2.xml#Operation Sequence.Operation', -'exp_eps_for2.xml#Operation Sequence.First', -'exp_eps_for2.xml#Operation Sequence.Derivative', -'exp_eps_for2.xml#Operation Sequence.Second', -'exp_eps_for2.xml#Operation Sequence.Sweep', -'exp_eps_for2.xml#Return Value', -'exp_eps_for2.xml#Verification', -'exp_eps_for2.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_eps.hpp.xml cppad-2019.02.00.0/doc/exp_eps.hpp.xml --- cppad-2018.00.00.0/doc/exp_eps.hpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ - - - -exp_eps: Implementation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_eps.hppHeadings

- - - -
exp_eps: Implementation
-
template <class Type>
-Type exp_eps(const Type &x, const Type &epsilon)
-{     // abs_x = |x|
-     Type abs_x = x;
-     if( Type(0) > x )
-          abs_x = - x;
-     // initialize
-     int  k    = 0;          // initial order
-     Type term = 1.;         // term = |x|^k / k !
-     Type sum  = term;       // initial sum
-     while(term > epsilon)
-     {     k         = k + 1;          // order for next term
-          Type temp = term * abs_x;   // term = |x|^k / (k-1)!
-          term      = temp / Type(k); // term = |x|^k / k !
-          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 )
-          sum = Type(1) / sum;
-     return sum;
-}
-
-
Input File: introduction/exp_eps.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps.hpp_xml.js cppad-2019.02.00.0/doc/_exp_eps.hpp_xml.js --- cppad-2018.00.00.0/doc/_exp_eps.hpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.xml', -'exp_eps.hpp.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.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-2018.00.00.0/doc/exp_eps_rev1.cpp.xml cppad-2019.02.00.0/doc/exp_eps_rev1.cpp.xml --- cppad-2018.00.00.0/doc/exp_eps_rev1.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps_rev1.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ - - - -exp_eps: Verify First Order Reverse Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_eps_rev1.cppHeadings

-
exp_eps: Verify First Order Reverse Sweep
-
# include <cstddef>                     // define size_t
-# include <cmath>                       // for fabs function
-extern bool exp_eps_for0(double *v0);   // computes zero order forward sweep
-bool exp_eps_rev1(void)
-{     bool ok = true;
-
-     // set the value of v0[j] for j = 1 , ... , 7
-     double v0[8];
-     ok &= exp_eps_for0(v0);
-
-     // initial all partial derivatives as zero
-     double f_v[8];
-     size_t j;
-     for(j = 0; j < 8; j++)
-          f_v[j] = 0.;
-
-     // set partial derivative for f7
-     f_v[7] = 1.;
-     ok    &= std::fabs( f_v[7] - 1. ) <= 1e-10;     // f7_v7
-
-     // f6( v1 , v2 , v3 , v4 , v5 , v6 )
-     f_v[4] += f_v[7] * 1.;
-     f_v[6] += f_v[7] * 1.;
-     ok     &= std::fabs( f_v[4] - 1.  ) <= 1e-10;   // f6_v4
-     ok     &= std::fabs( f_v[6] - 1.  ) <= 1e-10;   // f6_v6
-
-     // f5( v1 , v2 , v3 , v4 , v5 )
-     f_v[5] += f_v[6] / 2.;
-     ok     &= std::fabs( f_v[5] - 0.5 ) <= 1e-10;   // f5_v5
-
-     // f4( v1 , v2 , v3 , v4 )
-     f_v[1] += f_v[5] * v0[3];
-     f_v[3] += f_v[5] * v0[1];
-     ok     &= std::fabs( f_v[1] - 0.25) <= 1e-10;   // f4_v1
-     ok     &= std::fabs( f_v[3] - 0.25) <= 1e-10;   // f4_v3
-
-     // f3( v1 , v2 , v3 )
-     f_v[3] += f_v[4] * 1.;
-     ok     &= std::fabs( f_v[3] - 1.25) <= 1e-10;   // f3_v3
-
-     // f2( v1 , v2 )
-     f_v[2] += f_v[3] / 1.;
-     ok     &= std::fabs( f_v[2] - 1.25) <= 1e-10;   // f2_v2
-
-     // f1( v1 )
-     f_v[1] += f_v[2] * 1.;
-     ok     &= std::fabs( f_v[1] - 1.5 ) <= 1e-10;   // f1_v2
-
-     return ok;
-}
- -
Input File: introduction/exp_eps_rev1.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps_rev1.cpp_xml.js cppad-2019.02.00.0/doc/_exp_eps_rev1.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_eps_rev1.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps_rev1.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.xml', -'exp_eps_rev1.xml', -'exp_eps_rev1.cpp.xml' -]; -var list_down3 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down2 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.xml' -]; -var list_down1 = [ -'exp_eps_rev1.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-2018.00.00.0/doc/exp_eps_rev1.xml cppad-2019.02.00.0/doc/exp_eps_rev1.xml --- cppad-2018.00.00.0/doc/exp_eps_rev1.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps_rev1.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1724 +0,0 @@ - - - -exp_eps: First Order Reverse Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
exp_eps: First Order Reverse Sweep
-
-Purpose -
-First order reverse mode uses the -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 the order of the computations in the original algorithm. - -
-
-Mathematical Form -
-Suppose that we use the algorithm exp_eps.hpp - -to compute -exp_eps(xepsilon) - -with -x - is equal to .5 -and -epsilon - is equal to .2. -For this case, the mathematical function for the operation sequence -corresponding to exp_eps is - - -f -( -x -, -ε -) -= -1 -+ -x -+ -x -2 - -/ -2 - - -The corresponding partial derivatives, -and the value of the derivatives, are - - - - -x - -f -( -x -, -ε -) - -= - -1 -+ -x -= -1.5 - - -ε - -f -( -x -, -ε -) - -= - -0 - - - -
-epsilon -
-Since - -ε - - - is an independent variable, -it could included as an argument to all of the - - -f -j - - - - functions below. -The result would be that all the partials with respect to - - -ε - - - would be zero and hence we drop it to simplify -the presentation. - -
-
-f_7 -
-In reverse mode we choose one dependent variable and -compute its derivative with respect to all the independent variables. -For our example, we chose the value returned by exp_eps.hpp - -which is - -v -7 - - - -. -We begin with the function - -f -7 - - - - where - -v -7 - - - - -is both an argument and the value of the function; i.e., - - - -f -7 - -( -v -1 - -, -v -2 - -, -v -3 - -, -v -4 - -, -v -5 - -, -v -6 - -, -v -7 - -) - -= - -v -7 - - - -f -7 - - - -v -7 - - - - -= - -1 - - - -All the other partial derivatives of - -f -7 - - - - are zero. - -
-
-Index 7: f_6 -
-The last operation has index 7, - - -v -7 - -= -v -4 - -+ -v -6 - - - -We define the function - - -f -6 - -( -v -1 - -, -v -2 - -, -v -3 - -, -v -4 - -, -v -5 - -, -v -6 - -) - - - -as equal to - -f -7 - - - - -except that - -v -7 - - - - is eliminated using -this operation; i.e. - - -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 - - - - -f -6 - - - -v -4 - - - - -= - - -f -7 - - - -v -4 - - - -+ - -f -7 - - - -v -7 - - - -* - -v -7 - - - -v -4 - - - - -= -1 - - -f -6 - - - -v -6 - - - - -= - - -f -7 - - - -v -6 - - - -+ - -f -7 - - - -v -7 - - - -* - -v -7 - - - -v -6 - - - - -= -1 - - - -All the other partial derivatives of - -f -6 - - - - are zero. - -
-
-Index 6: f_5 -
-The previous operation has index 6, - - -v -6 - -= -v -5 - -/ -2 - - -We define the function - - -f -5 - -( -v -1 - -, -v -2 - -, -v -3 - -, -v -4 - -, -v -5 - -) - - - -as equal to - -f -6 - - - - -except that - -v -6 - - - - is eliminated using this operation; i.e., - - -f -5 - -= -f -6 - -[ -v -1 - -, -v -2 - -, -v -3 - -, -v -4 - -, -v -5 - -, -v -6 - -( -v -5 - -) -] - - -It follows that - - - - -f -5 - - - -v -4 - - - - -= - - -f -6 - - - -v -4 - - - - -= -1 - - -f -5 - - - -v -5 - - - - -= - - -f -6 - - - -v -5 - - - -+ - -f -6 - - - -v -6 - - - -* - -v -6 - - - -v -5 - - - - -= -0.5 - - - -All the other partial derivatives of - -f -5 - - - - are zero. - -
-
-Index 5: f_4 -
-The previous operation has index 5, - - -v -5 - -= -v -3 - -* -v -1 - - - -We define the function - - -f -4 - -( -v -1 - -, -v -2 - -, -v -3 - -, -v -4 - -) - - - -as equal to - -f -5 - - - - -except that - -v -5 - - - - is eliminated using this operation; i.e., - - -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 - - -v -3 - -= -0.5 - - - and - -v -1 - -= -0.5 - - -. -It follows that - - - - -f -4 - - - -v -1 - - - - -= - - -f -5 - - - -v -1 - - - -+ - -f -5 - - - -v -5 - - - -* - -v -5 - - - -v -1 - - - - -= -0.25 - - -f -4 - - - -v -2 - - - - -= - - -f -5 - - - -v -2 - - - - -= -0 - - -f -4 - - - -v -3 - - - - -= - - -f -5 - - - -v -3 - - - -+ - -f -5 - - - -v -5 - - - -* - -v -5 - - - -v -3 - - - - -= -0.25 - - -f -4 - - - -v -4 - - - - -= - - -f -5 - - - -v -4 - - - - -= -1 - - - -
-Index 4: f_3 -
-The previous operation has index 4, - - -v -4 - -= -1 -+ -v -3 - - - -We define the function - - -f -3 - -( -v -1 - -, -v -2 - -, -v -3 - -) - - - -as equal to - -f -4 - - - - -except that - -v -4 - - - - is eliminated using this operation; i.e., - - -f -3 - -= -f -4 - -[ -v -1 - -, -v -2 - -, -v -3 - -, -v -4 - -( -v -3 - -) -] - - -It follows that - - - - -f -3 - - - -v -1 - - - - -= - - -f -4 - - - -v -1 - - - - -= -0.25 - - -f -3 - - - -v -2 - - - - -= - - -f -4 - - - -v -2 - - - - -= -0 - - -f -3 - - - -v -3 - - - - -= - - -f -4 - - - -v -3 - - - -+ - -f -4 - - - -v -4 - - - -* - -v -4 - - - -v -3 - - - - -= -1.25 - - - -
-Index 3: f_2 -
-The previous operation has index 3, - - -v -3 - -= -v -2 - -/ -1 - - -We define the function - - -f -2 - -( -v -1 - -, -v -2 - -) - - - -as equal to - -f -3 - - - - -except that - -v -3 - - - - is eliminated using this operation; i.e., - - -f -2 - -= -f -4 - -[ -v -1 - -, -v -2 - -, -v -3 - -( -v -2 - -) -] - - -It follows that - - - - -f -2 - - - -v -1 - - - - -= - - -f -3 - - - -v -1 - - - - -= -0.25 - - -f -2 - - - -v -2 - - - - -= - - -f -3 - - - -v -2 - - - -+ - -f -3 - - - -v -3 - - - -* - -v -3 - - - -v -2 - - - - -= -1.25 - - - -
-Index 2: f_1 -
-The previous operation has index 1, - - -v -2 - -= -1 -* -v -1 - - - -We define the function - - -f -1 - -( -v -1 - -) - - - -as equal to - -f -2 - - - - -except that - -v -2 - - - - is eliminated using this operation; i.e., - - -f -1 - -= -f -2 - -[ -v -1 - -, -v -2 - -( -v -1 - -) -] - - -It follows that - - - - -f -1 - - - -v -1 - - - - -= - - -f -2 - - - -v -1 - - - -+ - -f -2 - - - -v -2 - - - -* - -v -2 - - - -v -1 - - - - -= -1.5 - - - -Note that - -v -1 - - - - is equal to - -x - - -, -so the derivative of -exp_eps(xepsilon) - -at -x - equal to .5 and -epsilon - equal .2 is -1.5 in the -x - direction and zero in the -epsilon - direction. -We also note that -forward - forward mode gave the -same result for the partial in the -x - direction. - - - - -
-
-Verification -
-The file 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 - - -f -j - - - - that might not be equal to the corresponding -partials of - -f -j -+ -1 - - - - -; i.e., the -other partials of - -f -j - - - - must be equal to the corresponding -partials of - -f -j -+ -1 - - - - -. - -
-
-Exercises - -
  1. -Consider the case where - -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 -first order reverse mode sweep; i.e., -what are the corresponding values for - - - -f -j - - - -v -k - - - - - - for all - -j -, -k - - - such that - - - -f -j - - - -v -k - - - - -0 - - -. -
  2. - -Create a modified version of -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 -exp_eps_rev1.cpp -. -
- - - -
Input File: introduction/exp_eps.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps_rev1_xml.js cppad-2019.02.00.0/doc/_exp_eps_rev1_xml.js --- cppad-2018.00.00.0/doc/_exp_eps_rev1_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps_rev1_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.xml', -'exp_eps_rev1.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.xml' -]; -var list_down0 = [ -'exp_eps_rev1.cpp.xml' -]; -var list_current0 = [ -'exp_eps_rev1.xml#Purpose', -'exp_eps_rev1.xml#Mathematical Form', -'exp_eps_rev1.xml#epsilon', -'exp_eps_rev1.xml#f_7', -'exp_eps_rev1.xml#Index 7: f_6', -'exp_eps_rev1.xml#Index 6: f_5', -'exp_eps_rev1.xml#Index 5: f_4', -'exp_eps_rev1.xml#Index 4: f_3', -'exp_eps_rev1.xml#Index 3: f_2', -'exp_eps_rev1.xml#Index 2: f_1', -'exp_eps_rev1.xml#Verification', -'exp_eps_rev1.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_eps_rev2.cpp.xml cppad-2019.02.00.0/doc/exp_eps_rev2.cpp.xml --- cppad-2018.00.00.0/doc/exp_eps_rev2.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps_rev2.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,153 +0,0 @@ - - - -exp_eps: Verify Second Order Reverse Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -exp_eps_rev2.cppHeadings

-
exp_eps: Verify Second Order Reverse Sweep
-
# include <cstddef>                     // define size_t
-# include <cmath>                       // for fabs function
-extern bool exp_eps_for0(double *v0);   // computes zero order forward sweep
-extern bool exp_eps_for1(double *v1);   // computes first order forward sweep
-bool exp_eps_rev2(void)
-{     bool ok = true;
-
-     // set the value of v0[j], v1[j] for j = 1 , ... , 7
-     double v0[8], v1[8];
-     ok &= exp_eps_for0(v0);
-     ok &= exp_eps_for1(v1);
-
-     // initial all partial derivatives as zero
-     double f_v0[8], f_v1[8];
-     size_t j;
-     for(j = 0; j < 8; j++)
-     {     f_v0[j] = 0.;
-          f_v1[j] = 0.;
-     }
-
-     // set partial derivative for f_7
-     f_v1[7] = 1.;
-     ok &= std::fabs( f_v1[7] - 1.  ) <= 1e-10; // partial f_7 w.r.t. v_7^1
-
-     // f_6 = f_7( v_1^0 , ... , v_6^1 , v_4^0 + v_6^0, v_4^1 , v_6^1 )
-     f_v0[4] += f_v0[7];
-     f_v0[6] += f_v0[7];
-     f_v1[4] += f_v1[7];
-     f_v1[6] += f_v1[7];
-     ok &= std::fabs( f_v0[4] - 0.  ) <= 1e-10; // partial f_6 w.r.t. v_4^0
-     ok &= std::fabs( f_v0[6] - 0.  ) <= 1e-10; // partial f_6 w.r.t. v_6^0
-     ok &= std::fabs( f_v1[4] - 1.  ) <= 1e-10; // partial f_6 w.r.t. v_4^1
-     ok &= std::fabs( f_v1[6] - 1.  ) <= 1e-10; // partial f_6 w.r.t. v_6^1
-
-     // f_5 = f_6( v_1^0 , ... , v_5^1 , v_5^0 / 2 , v_5^1 / 2 )
-     f_v0[5] += f_v0[6] / 2.;
-     f_v1[5] += f_v1[6] / 2.;
-     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 ,
-     //            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];
-     f_v1[1] += f_v1[5] * v0[3];
-     f_v1[3] += f_v1[5] * v0[1];
-     ok &= std::fabs( f_v0[1] - 0.5  ) <= 1e-10; // partial f_4 w.r.t. v_1^0
-     ok &= std::fabs( f_v0[3] - 0.5  ) <= 1e-10; // partial f_4 w.r.t. v_3^0
-     ok &= std::fabs( f_v1[1] - 0.25 ) <= 1e-10; // partial f_4 w.r.t. v_1^1
-     ok &= std::fabs( f_v1[3] - 0.25 ) <= 1e-10; // partial f_4 w.r.t. v_3^1
-
-     // f_3 = f_4(  v_1^0 , ... , v_3^1 , 1 + v_3^0 , v_3^1 )
-     f_v0[3] += f_v0[4];
-     f_v1[3] += f_v1[4];
-     ok &= std::fabs( f_v0[3] - 0.5 ) <= 1e-10;  // partial f_3 w.r.t. v_3^0
-     ok &= std::fabs( f_v1[3] - 1.25) <= 1e-10;  // partial f_3 w.r.t. v_3^1
-
-     // f_2 = f_3( v_1^0 , ... , v_2^1 , v_2^0 , v_2^1 )
-     f_v0[2] += f_v0[3];
-     f_v1[2] += f_v1[3];
-     ok &= std::fabs( f_v0[2] - 0.5 ) <= 1e-10;  // partial f_2 w.r.t. v_2^0
-     ok &= std::fabs( f_v1[2] - 1.25) <= 1e-10;  // partial f_2 w.r.t. v_2^1
-
-     // f_1 = f_2 ( v_1^0 , v_2^0 , v_1^0 , v_2^0 )
-     f_v0[1] += f_v0[2];
-     f_v1[1] += f_v1[2];
-     ok &= std::fabs( f_v0[1] - 1.  ) <= 1e-10;  // partial f_1 w.r.t. v_1^0
-     ok &= std::fabs( f_v1[1] - 1.5 ) <= 1e-10;  // partial f_1 w.r.t. v_1^1
-
-     return ok;
-}
- -
Input File: introduction/exp_eps_rev2.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps_rev2.cpp_xml.js cppad-2019.02.00.0/doc/_exp_eps_rev2.cpp_xml.js --- cppad-2018.00.00.0/doc/_exp_eps_rev2.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps_rev2.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.xml', -'exp_eps_rev2.xml', -'exp_eps_rev2.cpp.xml' -]; -var list_down3 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down2 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.xml' -]; -var list_down1 = [ -'exp_eps_rev2.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-2018.00.00.0/doc/exp_eps_rev2.xml cppad-2019.02.00.0/doc/exp_eps_rev2.xml --- cppad-2018.00.00.0/doc/exp_eps_rev2.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps_rev2.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,3055 +0,0 @@ - - - -exp_eps: Second Order Reverse Sweep - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
exp_eps: Second Order Reverse Sweep
-
-Purpose -
-In general, a second order reverse sweep is given the -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, -with respect to all of the independent variables. - -
-
-Mathematical Form -
-Suppose that we use the algorithm exp_eps.hpp - -to compute -exp_eps(xepsilon) - -with -x - is equal to .5 -and -epsilon - is equal to .2. -For this case, the mathematical function for the operation sequence -corresponding to exp_eps is - - -f -( -x -, -ε -) -= -1 -+ -x -+ -x -2 - -/ -2 - - -The corresponding derivative of the -partial derivative with respect to - -x - - - is - - - - -2 - - - - -x - -2 - - - - -f -( -x -, -ε -) - -= - -1 - - -ε - - -x - -f -( -x -, -ε -) - -= - -0 - - - -
-epsilon -
-Since - -ε - - - is an independent variable, -it could included as an argument to all of the - - -f -j - - - - functions below. -The result would be that all the partials with respect to - - -ε - - - would be zero and hence we drop it to simplify -the presentation. - -
-
-f_7 -
-In reverse mode we choose one dependent variable and -compute its derivative with respect to all the independent variables. -For our example, we chose the value returned by exp_eps.hpp - -which is - -v -7 - - - -. -We begin with the function - -f -7 - - - - where - -v -7 - - - - -is both an argument and the value of the function; i.e., - - - -f -7 - -(v -1 -( -0 -) - - -, -v -1 -( -1 -) - - -, - -, -v -7 -( -0 -) - - -, -v -7 -( -1 -) - - -) - -= - -v -7 -( -1 -) - - - - -f -7 - - - -v -7 -( -1 -) - - - - - -= - -1 - - - -All the other partial derivatives of - -f -7 - - - - are zero. - -
-
-Index 7: f_6 -
-The last operation has index 7, - - - -v -7 -( -0 -) - - - -= - -v -4 -( -0 -) - - -+ -v -6 -( -0 -) - - - -v -7 -( -1 -) - - - -= - -v -4 -( -1 -) - - -+ -v -6 -( -1 -) - - - - - -We define the function - - -f -6 - -(v -1 -( -0 -) - - -, - -, -v -6 -( -1 -) - - -) - - - -as equal to - -f -7 - - - - -except that - -v -7 -( -0 -) - - - - - and - -v -7 -( -1 -) - - - - - are eliminated using -this operation; i.e. - - -f -6 - -= -f -7 - -[v -1 -( -0 -) - - -, - -, -v -6 -( -1 -) - - -, -v -7 -( -0 -) - - -(v -4 -( -0 -) - - -, -v -6 -( -0 -) - - -) -, -v -7 -( -1 -) - - -(v -4 -( -1 -) - - -, -v -6 -( -1 -) - - -) -] - - -It follows that - - - - -f -6 - - - -v -4 -( -1 -) - - - - - -= - - -f -7 - - - -v -4 -( -1 -) - - - - -+ - -f -7 - - - -v -7 -( -1 -) - - - - -* - -v -7 -( -1 -) - - - - -v -4 -( -1 -) - - - - - -= -1 - - -f -6 - - - -v -6 -( -1 -) - - - - - -= - - -f -7 - - - -v -6 -( -1 -) - - - - -+ - -f -7 - - - -v -7 -( -1 -) - - - - -* - -v -7 -( -1 -) - - - - -v -6 -( -1 -) - - - - - -= -1 - - - -All the other partial derivatives of - -f -6 - - - - are zero. - -
-
-Index 6: f_5 -
-The previous operation has index 6, - - - -v -6 -( -0 -) - - - -= - -v -5 -( -0 -) - - -/ -2 - -v -6 -( -1 -) - - - -= - -v -5 -( -1 -) - - -/ -2 - - - -We define the function - - -f -5 - -(v -1 -( -0 -) - - -, - -, -v -5 -( -1 -) - - -) - - - -as equal to - -f -6 - - - - -except that - -v -6 -( -0 -) - - - - - and - -v -6 -( -1 -) - - - - - are eliminated using -this operation; i.e. - - -f -5 - -= -f -6 - -[v -1 -( -0 -) - - -, - -, -v -5 -( -1 -) - - -, -v -6 -( -0 -) - - -(v -5 -( -0 -) - - -) -, -v -6 -( -1 -) - - -(v -5 -( -1 -) - - -) -] - - -It follows that - - - - -f -5 - - - -v -4 -( -1 -) - - - - - -= - - -f -6 - - - -v -4 -( -1 -) - - - - - -= -1 - - -f -5 - - - -v -5 -( -1 -) - - - - - -= - - -f -6 - - - -v -5 - - - -+ - -f -6 - - - -v -6 -( -1 -) - - - - -* - -v -6 -( -1 -) - - - - -v -5 -( -1 -) - - - - - -= -0.5 - - - -All the other partial derivatives of - -f -5 - - - - are zero. - -
-
-Index 5: f_4 -
-The previous operation has index 5, - - - -v -5 -( -0 -) - - - -= - -v -3 -( -0 -) - - -* -v -1 -( -0 -) - - - -v -5 -( -1 -) - - - -= - -v -3 -( -1 -) - - -* -v -1 -( -0 -) - - -+ -v -3 -( -0 -) - - -* -v -1 -( -1 -) - - - - - -We define the function - - -f -4 - -(v -1 -( -0 -) - - -, - -, -v -4 -( -1 -) - - -) - - - -as equal to - -f -5 - - - - -except that - -v -5 -( -0 -) - - - - - and - -v -5 -( -1 -) - - - - - are eliminated using -this operation; i.e. - - -f -4 - -= -f -5 - -[v -1 -( -0 -) - - -, - -, -v -4 -( -1 -) - - -, -v -5 -( -0 -) - - -(v -1 -( -0 -) - - -, -v -3 -( -0 -) - - -) -, -v -5 -( -1 -) - - -(v -1 -( -0 -) - - -, -v -1 -( -1 -) - - -, -v -3 -( -0 -) - - -, -v -3 -( -1 -) - - -) -, -] - - -Given the information from the forward sweep, we have - - -v -1 -( -0 -) - - -= -0.5 - - -, - - -v -3 -( -0 -) - - -= -0.5 - - -, - - -v -1 -( -1 -) - - -= -1 - - -, - - -v -3 -( -1 -) - - -= -1 - - -, -and the fact that the partial of - -f -5 - - - - with respect to - - -v -5 -( -0 -) - - - - - is zero, we have - - - - -f -4 - - - -v -1 -( -0 -) - - - - - -= - - -f -5 - - - -v -1 -( -0 -) - - - - -+ - -f -5 - - - -v -5 -( -1 -) - - - - -* - -v -5 -( -1 -) - - - - -v -1 -( -0 -) - - - - - -= -0.5 - - -f -4 - - - -v -1 -( -1 -) - - - - - -= - - -f -5 - - - -v -1 -( -1 -) - - - - -+ - -f -5 - - - -v -5 -( -1 -) - - - - -* - -v -5 -( -1 -) - - - - -v -1 -( -1 -) - - - - - -= -0.25 - - -f -4 - - - -v -3 -( -0 -) - - - - - -= - - -f -5 - - - -v -3 -( -0 -) - - - - -+ - -f -5 - - - -v -5 -( -1 -) - - - - -* - -v -5 -( -1 -) - - - - -v -3 -( -0 -) - - - - - -= -0.5 - - -f -4 - - - -v -3 -( -1 -) - - - - - -= - - -f -3 - - - -v -1 -( -1 -) - - - - -+ - -f -5 - - - -v -5 -( -1 -) - - - - -* - -v -5 -( -1 -) - - - - -v -3 -( -1 -) - - - - - -= -0.25 - - -f -4 - - - -v -4 -( -1 -) - - - - - -= - - -f -5 - - - -v -4 -( -1 -) - - - - - -= -1 - - - -All the other partial derivatives of - -f -5 - - - - are zero. - -
-
-Index 4: f_3 -
-The previous operation has index 4, - - - -v -4 -( -0 -) - - -= -1 -+ -v -3 -( -0 -) - - - -v -4 -( -1 -) - - -= -v -3 -( -1 -) - - - - - -We define the function - - -f -3 - -(v -1 -( -0 -) - - -, - -, -v -3 -( -1 -) - - -) - - - -as equal to - -f -4 - - - - -except that - -v -4 -( -0 -) - - - - - and - -v -4 -( -1 -) - - - - - are eliminated using -this operation; i.e. - - -f -3 - -= -f -4 - -[v -1 -( -0 -) - - -, - -, -v -3 -( -1 -) - - -, -v -4 -( -0 -) - - -(v -3 -( -0 -) - - -) -, -v -4 -( -1 -) - - -(v -3 -( -1 -) - - -) -] - - -It follows that - - - - -f -3 - - - -v -1 -( -0 -) - - - - - -= - - -f -4 - - - -v -1 -( -0 -) - - - - - -= -0.5 - - -f -3 - - - -v -1 -( -1 -) - - - - - -= - - -f -4 - - - -v -1 -( -1 -) - - - - - -= -0.25 - - -f -3 - - - -v -2 -( -0 -) - - - - - -= - - -f -4 - - - -v -2 -( -0 -) - - - - - -= -0 - - -f -3 - - - -v -2 -( -1 -) - - - - - -= - - -f -4 - - - -v -2 -( -1 -) - - - - - -= -0 - - -f -3 - - - -v -3 -( -0 -) - - - - - -= - - -f -4 - - - -v -3 -( -0 -) - - - - -+ - -f -4 - - - -v -4 -( -0 -) - - - - -* - -v -4 -( -0 -) - - - - -v -3 -( -0 -) - - - - - -= -0.5 - - -f -3 - - - -v -3 -( -1 -) - - - - - -= - - -f -4 - - - -v -3 -( -1 -) - - - - -+ - -f -4 - - - -v -4 -( -1 -) - - - - -* - -v -4 -( -1 -) - - - - -v -3 -( -1 -) - - - - - -= -1.25 - - - -
-Index 3: f_2 -
-The previous operation has index 3, - - - -v -3 -( -0 -) - - - -= - -v -2 -( -0 -) - - -/ -1 - -v -3 -( -1 -) - - - -= - -v -2 -( -1 -) - - -/ -1 - - - -We define the function - - -f -2 - -(v -1 -( -0 -) - - -, - -, -v -2 -( -1 -) - - -) - - - -as equal to - -f -3 - - - - -except that - -v -3 -( -0 -) - - - - - and - -v -3 -( -1 -) - - - - - are eliminated using -this operation; i.e. - - -f -2 - -= -f -3 - -[v -1 -( -0 -) - - -, - -, -v -2 -( -1 -) - - -, -v -3 -( -0 -) - - -(v -2 -( -0 -) - - -) -, -v -3 -( -1 -) - - -(v -2 -( -1 -) - - -) -] - - -It follows that - - - - -f -2 - - - -v -1 -( -0 -) - - - - - -= - - -f -3 - - - -v -1 -( -0 -) - - - - - -= -0.5 - - -f -2 - - - -v -1 -( -1 -) - - - - - -= - - -f -3 - - - -v -1 -( -1 -) - - - - - -= -0.25 - - -f -2 - - - -v -2 -( -0 -) - - - - - -= - - -f -3 - - - -v -2 -( -0 -) - - - - -+ - -f -3 - - - -v -3 -( -0 -) - - - - -* - -v -3 -( -0 -) - - - - -v -2 -( -0 -) - - - - - -= -0.5 - - -f -2 - - - -v -2 -( -1 -) - - - - - -= - - -f -3 - - - -v -2 -( -1 -) - - - - -+ - -f -3 - - - -v -3 -( -1 -) - - - - -* - -v -3 -( -1 -) - - - - -v -2 -( -0 -) - - - - - -= -1.25 - - - -
-Index 2: f_1 -
-The previous operation has index 1, - - - -v -2 -( -0 -) - - - -= - -1 -* -v -1 -( -0 -) - - - -v -2 -( -1 -) - - - -= - -1 -* -v -1 -( -1 -) - - - - - -We define the function - - -f -1 - -(v -1 -( -0 -) - - -, -v -1 -( -1 -) - - -) - - - -as equal to - -f -2 - - - - -except that - -v -2 -( -0 -) - - - - - and - -v -2 -( -1 -) - - - - - are eliminated using -this operation; i.e. - - -f -1 - -= -f -2 - -[v -1 -( -0 -) - - -, -v -1 -( -1 -) - - -, -v -2 -( -0 -) - - -(v -1 -( -0 -) - - -) -, -v -2 -( -1 -) - - -(v -1 -( -1 -) - - -) -] - - -It follows that - - - - -f -1 - - - -v -1 -( -0 -) - - - - - -= - - -f -2 - - - -v -1 -( -0 -) - - - - -+ - -f -2 - - - -v -2 -( -0 -) - - - - -* - -v -2 -( -0 -) - - - - -v -1 -( -0 -) - - - - - -= -1 - - -f -1 - - - -v -1 -( -1 -) - - - - - -= - - -f -2 - - - -v -1 -( -1 -) - - - - -+ - -f -2 - - - -v -2 -( -1 -) - - - - -* - -v -2 -( -1 -) - - - - -v -1 -( -1 -) - - - - - -= -1.5 - - - -Note that - -v -1 - - - - is equal to - -x - - -, -so the second partial derivative of - -exp_eps(xepsilon) - -at -x - equal to .5 and -epsilon - equal .2 is - - - -2 - - - - -x - -2 - - - - -v -7 -( -0 -) - - -= - -v -7 -( -1 -) - - - - -x - - -= - -f -1 - - - -v -1 -( -0 -) - - - - -= -1 - - -There is a theorem about algorithmic differentiation that explains why -the other partial of - -f -1 - - - - is equal to the first partial of - -exp_eps(xepsilon) - -with respect to - -x - - -. - - - - -
-
-Verification -
-The file 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 - - -f -j - - - - that might not be equal to the corresponding -partials of - -f -j -+ -1 - - - - -; i.e., the -other partials of - -f -j - - - - must be equal to the corresponding -partials of - -f -j -+ -1 - - - - -. - -
-
-Exercises - -
  1. -Consider the case where - -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 -first order reverse mode sweep; i.e., -what are the corresponding values for - - - -f -j - - - -v -k - - - - - - for all - -j -, -k - - - such that - - - -f -j - - - -v -k - - - - -0 - - -. -
  2. - -Create a modified version of -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 -exp_eps_rev2.cpp -. -
- - - -
Input File: introduction/exp_eps.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps_rev2_xml.js cppad-2019.02.00.0/doc/_exp_eps_rev2_xml.js --- cppad-2018.00.00.0/doc/_exp_eps_rev2_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps_rev2_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.xml', -'exp_eps_rev2.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down1 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.xml' -]; -var list_down0 = [ -'exp_eps_rev2.cpp.xml' -]; -var list_current0 = [ -'exp_eps_rev2.xml#Purpose', -'exp_eps_rev2.xml#Mathematical Form', -'exp_eps_rev2.xml#epsilon', -'exp_eps_rev2.xml#f_7', -'exp_eps_rev2.xml#Index 7: f_6', -'exp_eps_rev2.xml#Index 6: f_5', -'exp_eps_rev2.xml#Index 5: f_4', -'exp_eps_rev2.xml#Index 4: f_3', -'exp_eps_rev2.xml#Index 3: f_2', -'exp_eps_rev2.xml#Index 2: f_1', -'exp_eps_rev2.xml#Verification', -'exp_eps_rev2.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_eps.xml cppad-2019.02.00.0/doc/exp_eps.xml --- cppad-2018.00.00.0/doc/exp_eps.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_eps.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,593 +0,0 @@ - - - -An Epsilon Accurate Exponential Approximation - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
An Epsilon Accurate Exponential Approximation
-
-Syntax - -
- -# include "exp_eps.hpp" - -
-
-y = exp_eps(xepsilon) - - - -
-
-Purpose -
-This is a an example algorithm that is used to demonstrate -how Algorithmic Differentiation works with loops and -boolean decision variables -(see exp_2 - for a simpler example). - -
-
-Mathematical Function -
-The exponential function can be defined by - - -exp -( -x -) -= -1 -+ -x -1 - -/ -1 -! -+ -x -2 - -/ -2 -! -+ - - - -We define - -k -( -x -, -ε -) - - - as the smallest -non-negative integer such that - -ε - -x -k - -/ -k -! - - -; i.e., - - -k -( -x -, -ε -) -= -min -{ -k - -Z - -+ - - -| - -ε - -x -k - -/ -k -! -} - - -The mathematical form for our approximation of the exponential function is - - - -exp -_ -eps - -( -x -, -ε -) - -= - -{ -1 - -exp -_ -eps - -( -- -x -, -ε -) - - - -if - - -x -< -0 - -1 -+ -x -1 - -/ -1 -! -+ - -+ -x -k -( -x -, -ε -) - - -/ -k -( -x -, -ε -) -! - -otherwise - - - - - - -
-include -
-The include command in the syntax is relative to - -
-     cppad-
yyyymmdd/introduction/exp_apx
-
-where -cppad-yyyymmdd - is the distribution directory -created during the beginning steps of the -installation - of CppAD. - - -
-
-x -
-The argument -x - has prototype - -
-     const 
Type &x
-
-(see -Type - below). -It specifies the point at which to evaluate the -approximation for the exponential function. - -
-
-epsilon -
-The argument -epsilon - has prototype - -
-     const 
Type &epsilon
-
-It specifies the accuracy with which -to approximate the exponential function value; i.e., -it is the value of - -ε - - - in the -exponential function approximation defined above. - -
-
-y -
-The result -y - has prototype - -
-     
Type y
-
-It is the value of the exponential function -approximation defined above. - -
-
-Type -
-If -u - and -v - are -Type - objects and -i - -is an int: - - -
- -Operation - Result Type - Description -
- - -Type(i) - - - -Type - - - object with value equal to -i - -
- - -Type u = v - - - -Type - - - construct -u - with value equal to -v - -
- - -u > v - - - bool - - true, - if -u - greater than -v -, an false otherwise -
- - -u = v - - - -Type - - - new -u - (and result) is value of -v - -
- - -u * v - - - -Type - - - result is value of - -u -* -v - - - -
- - -u / v - - - -Type - - - result is value of - -u -/ -v - - - -
- - -u + v - - - -Type - - - result is value of - -u -+ -v - - - -
- - --u - - - -Type - - - result is value of - -- -u - - - -
-
-Implementation -
-The file exp_eps.hpp - -contains a C++ implementation of this function. - -
-
-Test -
-The file exp_eps.cpp - -contains a test of this implementation. -It returns true for success and false for failure. - -
-
-Exercises - -
  1. -Using the definition of - -k -( -x -, -ε -) - - - above, -what is the value of - - -k -( -.5 -, -1 -) - - -, - -k -( -.5 -, -.1 -) - - -, and - -k -( -.5 -, -.01 -) - - - ? -
  2. - -Suppose that we make the following call to exp_eps: -
     
    -     double x       = 1.;
    -     double epsilon = .01;
    -     double y = exp_eps(x, epsilon);
    -
    -What is the value assigned to -k, temp, term, and sum -the first time through the while loop in exp_eps.hpp - ? -
  3. - -Continuing the previous exercise, -what is the value assigned to -k, temp, term, and sum -the second time through the while loop in exp_eps.hpp - ? -
- - - - -
Input File: introduction/exp_eps.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_eps_xml.js cppad-2019.02.00.0/doc/_exp_eps_xml.js --- cppad-2018.00.00.0/doc/_exp_eps_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_eps_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.xml', -'exp_eps.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_down0 = [ -'exp_eps.hpp.xml', -'exp_eps.cpp.xml', -'exp_eps_for0.xml', -'exp_eps_for1.xml', -'exp_eps_rev1.xml', -'exp_eps_for2.xml', -'exp_eps_rev2.xml', -'exp_eps_cppad.xml' -]; -var list_current0 = [ -'exp_eps.xml#Syntax', -'exp_eps.xml#Purpose', -'exp_eps.xml#Mathematical Function', -'exp_eps.xml#include', -'exp_eps.xml#x', -'exp_eps.xml#epsilon', -'exp_eps.xml#y', -'exp_eps.xml#Type', -'exp_eps.xml#Implementation', -'exp_eps.xml#Test', -'exp_eps.xml#Exercises' -]; -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-2018.00.00.0/doc/exp_forward.xml cppad-2019.02.00.0/doc/exp_forward.xml --- cppad-2018.00.00.0/doc/exp_forward.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_forward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,579 +0,0 @@ - - - -Exponential Function Forward Mode Theory - - - - - - - - - - - - - - - - -
- -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/appendix/theory/exp_forward.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_forward_xml.js cppad-2019.02.00.0/doc/_exp_forward_xml.js --- cppad-2018.00.00.0/doc/_exp_forward_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_forward_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', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'exp_forward.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/expm1.cpp.xml cppad-2019.02.00.0/doc/expm1.cpp.xml --- cppad-2018.00.00.0/doc/expm1.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/expm1.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,159 +0,0 @@ - - - -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/general/expm1.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_expm1.cpp_xml.js cppad-2019.02.00.0/doc/_expm1.cpp_xml.js --- cppad-2018.00.00.0/doc/_expm1.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_expm1.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'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-2018.00.00.0/doc/expm1.xml cppad-2019.02.00.0/doc/expm1.xml --- cppad-2018.00.00.0/doc/expm1.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/expm1.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,198 +0,0 @@ - - - -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/core/expm1.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_expm1_xml.js cppad-2019.02.00.0/doc/_expm1_xml.js --- cppad-2018.00.00.0/doc/_expm1_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_expm1_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +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', -'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-2018.00.00.0/doc/exp_reverse.xml cppad-2019.02.00.0/doc/exp_reverse.xml --- cppad-2018.00.00.0/doc/exp_reverse.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp_reverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,493 +0,0 @@ - - - -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/appendix/theory/exp_reverse.omh - - - diff -Nru cppad-2018.00.00.0/doc/_exp_reverse_xml.js cppad-2019.02.00.0/doc/_exp_reverse_xml.js --- cppad-2018.00.00.0/doc/_exp_reverse_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_reverse_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', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'exp_reverse.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/exp.xml cppad-2019.02.00.0/doc/exp.xml --- cppad-2018.00.00.0/doc/exp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/exp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ - - - -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_exp_xml.js cppad-2019.02.00.0/doc/_exp_xml.js --- cppad-2018.00.00.0/doc/_exp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_exp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'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-2018.00.00.0/doc/_external.xml cppad-2019.02.00.0/doc/_external.xml --- cppad-2018.00.00.0/doc/_external.xml 2018-01-01 08:32:51.000000000 +0000 +++ cppad-2019.02.00.0/doc/_external.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,260 +0,0 @@ - - - -External Internet References - - - - - - - - - - - - - -
- -Prev -Next - - - - - -_externalHeadings

-
External Internet References
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-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.orgwhats_new_13#04-28
http://eigen.tuxfamily.orgwhats_new_12#06-16
http://eigen.tuxfamily.orgautotools#eigen_dir
http://eigen.tuxfamily.org/dox/TopicCustomizingEigen.htmlwhats_new_12#07-01
http://en.wikipedia.org/wiki/Automatic_differentiationCppAD#Introduction
http://en.wikipedia.org/wiki/Automatic_differentiationCppAD#Introduction
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
http://list.coin-or.org/pipermail/cppad/2010q2/000166.htmlwhats_new_10#06-01
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://people.freedesktop.org/~dbn/pkg-config-guide.htmlpkgconfig#Purpose
http://projects.coin-or.org/CppAD/browserwhats_new_05#12-05
http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.htmlwhats_new_12#03-17
http://subversion.tigris.org/download#Source Code Control.Subversion
http://trilinos.sandia.gov/packages/sacadosacado_prefix#Purpose
http://trilinos.sandia.gov/packages/sacadoget_sacado.sh#Purpose
http://trilinos.sandia.gov/packages/sacadowhats_new_13#04-28
http://trilinos.sandia.gov/packages/sacado/CppAD#Introduction
http://trilinos.sandia.gov/packages/sacado/speed#Purpose
http://trilinos.sandia.gov/packages/sacado/whats_new_07#10-22
http://trilinos.sandia.gov/packages/sacado/autotools#sacado_dir
http://valgrind.org/whats_new_09#06-06
http://valgrind.org/whats_new_07#02-03
http://valgrind.org/whats_new_06#08-17
http://www.7-zip.orgdownload#Windows File Extraction and Testing
http://www.7-zip.orgwhats_new_04#09-02
http://www.autodiff.orgCppAD#Introduction
http://www.autodiff.orgCppAD#Introduction
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
http://www.boost.org/doc/libs/1_52_0/libs/numeric/ublas/doc/vector.htmcppad_testvector#boost
http://www.boost.org/libs/numeric/ublas/doc/index.htmCppAD#Introduction
http://www.cmake.orgwhats_new_12#11-06
http://www.cmake.org/cmake/help/cmake2.6docs.html#module:FindBoostcppad_testvector#boost
http://www.cmake.org/cmake/help/cmake2.6docs.html#section_Generatorscmake#generator
http://www.cmake.org/cmake/help/install.htmlcmake#The CMake Program
http://www.coin-or.org/CppAD/CppAD#Introduction
http://www.coin-or.org/CppAD/speed#Purpose
http://www.coin-or.org/CppAD/whats_new_05#12-06
http://www.coin-or.org/CppAD/cppad_ipopt_nlp#Purpose
http://www.coin-or.org/download/source/CppAD/download#Compressed Archives.Coin
http://www.coin-or.org/download/source/CppAD/download#Monthly Versions
http://www.coin-or.org/download/source/CppAD/whats_new_10#04-24
http://www.coin-or.org/download/source/CppAD/whats_new_09#06-25
http://www.coin-or.org/foundation.htmlCppAD#Introduction
http://www.coin-or.org/projects/Ipopt.xmlipopt_prefix#ipopt_prefix
http://www.coin-or.org/projects/Ipopt.xmlget_ipopt.sh#Purpose
http://www.coin-or.org/projects/Ipopt.xmlipopt_solve#Purpose
http://www.coin-or.org/projects/Ipopt.xmlcppad_ipopt_nlp#Purpose
http://www.coin-or.org/projects/Ipopt.xmlautotools#ipopt_dir
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/CppAD#Introduction
http://www.fadbad.com/speed#Purpose
http://www.fadbad.com/autotools#fadbad_dir
http://www.microsoft.com/en-us/download/confirmation.aspx?id=44914download#Windows File Extraction and Testing
http://www.mingw.orgwhats_new_03#12-22
http://www.opensource.org/licenses/AGPL-3.0CppAD#Introduction
http://www.opensource.org/licenses/EPL-1.0CppAD#Introduction
http://www.rpm.org/max-rpm/ch-rpm-file-format.htmlwhats_new_06#11-30
http://www.seanet.com/~bradbell/cppad_swigwhats_new_17#01-27
http://www.seanet.com/~bradbell/cppad_swigaddon#Name
http://www.seanet.com/~bradbell/omhelp/download#Building Documentation
http://www.seanet.com/~bradbell/pycppad/pycppad.htmaddon#Name
http://www.winzip.comwhats_new_04#09-02
https://cran.r-project.org/web/packages/TMB/index.htmlwhats_new_17#11-19
https://cran.r-project.org/web/packages/TMB/index.htmlwhats_new_17#11-08
https://eigen.tuxfamily.org/dox/TopicCustomizing_CustomScalar.htmlcppad_eigen.hpp#Purpose
https://en.wikipedia.org/wiki/Git_%28software%29download#Source Code Control.Git
https://github.com/coin-or/CppAD/issuesFaq#Bugs
https://github.com/coin-or/CppAD/issues/16whats_new_16#09-29
https://github.com/coin-or/CppAD/releasesdownload#Compressed Archives.Github
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-Cspeed#Purpose
https://projects.coin-or.org/ADOL-Cwhats_new_13#10-14
https://projects.coin-or.org/ADOL-Cwhats_new_09#01-18
https://projects.coin-or.org/ADOL-Cwhats_new_04#01-22
https://projects.coin-or.org/ADOL-Cautotools#adolc_dir
https://www.coin-or.org/CppAD/Doc/doxydoc/html/whats_new_17#01-18
https://www.cygwin.com/whats_new_17#02-26
mailto:Jean-Pierre.Dussault@Usherbrooke.cawhats_new_05#02-24
mailto:magister@u.washington.eduwhats_new_04#04-19
mailto:magister@u.washington.eduwhats_new_03#10-05
- - diff -Nru cppad-2018.00.00.0/doc/__external_xml.js cppad-2019.02.00.0/doc/__external_xml.js --- cppad-2018.00.00.0/doc/__external_xml.js 2018-01-01 08:32:51.000000000 +0000 +++ cppad-2019.02.00.0/doc/__external_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'_external.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' -]; -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-2018.00.00.0/doc/fabs.cpp.xml cppad-2019.02.00.0/doc/fabs.cpp.xml --- cppad-2018.00.00.0/doc/fabs.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/fabs.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,197 +0,0 @@ - - - -AD Absolute Value Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -fabs.cppHeadings

- - - -
AD Absolute Value Function: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool fabs(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n = 1;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0]     = 0.;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     // range space vector
-     size_t m = 6;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0]     = fabs(x[0] - 1.);
-     y[1]     = fabs(x[0]);
-     y[2]     = fabs(x[0] + 1.);
-     //
-     y[3]     = fabs(x[0] - 1.);
-     y[4]     = fabs(x[0]);
-     y[5]     = fabs(x[0] + 1.);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check values
-     ok &= (y[0] == 1.);
-     ok &= (y[1] == 0.);
-     ok &= (y[2] == 1.);
-     //
-     ok &= (y[3] == 1.);
-     ok &= (y[4] == 0.);
-     ok &= (y[5] == 1.);
-
-     // forward computation of partials w.r.t. a positive x[0] direction
-     size_t p = 1;
-     CPPAD_TESTVECTOR(double) dx(n), dy(m);
-     dx[0] = 1.;
-     dy    = f.Forward(p, dx);
-     ok  &= (dy[0] == - dx[0]);
-     ok  &= (dy[1] ==   0.   ); // used to be (dy[1] == + dx[0]);
-     ok  &= (dy[2] == + dx[0]);
-     //
-     ok  &= (dy[3] == - dx[0]);
-     ok  &= (dy[4] ==   0.   ); // used to be (dy[1] == + dx[0]);
-     ok  &= (dy[5] == + dx[0]);
-
-     // forward computation of partials w.r.t. a negative x[0] direction
-     dx[0] = -1.;
-     dy    = f.Forward(p, dx);
-     ok  &= (dy[0] == - dx[0]);
-     ok  &= (dy[1] ==   0.   ); // used to be (dy[1] == - dx[0]);
-     ok  &= (dy[2] == + dx[0]);
-     //
-     ok  &= (dy[3] == - dx[0]);
-     ok  &= (dy[4] ==   0.   ); // used to be (dy[1] == - dx[0]);
-     ok  &= (dy[5] == + dx[0]);
-
-     // reverse computation of derivative of y[0]
-     p    = 1;
-     CPPAD_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]
-     w[0] = 0.; w[1] = 1.;
-     dw   = f.Reverse(p, w);
-     ok  &= (dw[0] == 0.);
-
-     // reverse computation of derivative of y[5]
-     w[1] = 0.; w[5] = 1.;
-     dw   = f.Reverse(p, w);
-     ok  &= (dw[0] == 1.);
-
-     // use a VecAD<Base>::reference object with abs and fabs
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero]           = -1;
-     AD<double> result = fabs(v[zero]);
-     ok    &= NearEqual(result, 1., eps99, eps99);
-     result = fabs(v[zero]);
-     ok    &= NearEqual(result, 1., eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/fabs.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_fabs.cpp_xml.js cppad-2019.02.00.0/doc/_fabs.cpp_xml.js --- cppad-2018.00.00.0/doc/_fabs.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fabs.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'abs.xml', -'fabs.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 = [ -'fabs.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-2018.00.00.0/doc/fadbad_det_lu.cpp.xml cppad-2019.02.00.0/doc/fadbad_det_lu.cpp.xml --- cppad-2018.00.00.0/doc/fadbad_det_lu.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/fadbad_det_lu.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ - - - -Fadbad Speed: Gradient of Determinant Using Lu Factorization - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -fadbad_det_lu.cpp - -

-
Fadbad Speed: Gradient of Determinant Using Lu Factorization
-
-Specifications -
-See link_det_lu -. - -
-
-Implementation - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <FADBAD++/badiff.h>
-# include <cppad/speed/det_by_lu.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/utility/vector.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_det_lu(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &matrix   ,
-     CppAD::vector<double>     &gradient )
-{
-     // speed test global option values
-     if( global_option["onetape"] || global_option["atomic"] )
-          return false;
-     if( global_option["memory"] || global_option["optimize"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-     //
-     // object for computing determinant
-     typedef fadbad::B<double>       ADScalar;
-     typedef CppAD::vector<ADScalar> ADVector;
-     CppAD::det_by_lu<ADScalar>      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
-
-     // ------------------------------------------------------
-     while(repeat--)
-       {     // get the next matrix
-          CppAD::uniform_01(n, matrix);
-
-          // set independent variable values
-          for(i = 0; i < n; i++)
-               A[i] = matrix[i];
-
-          // compute the determinant
-          detA = Det(A);
-
-          // create function object f : A -> detA
-          detA.diff(0, m);  // index 0 of m dependent variables
-
-          // evaluate and return gradient using reverse mode
-          for(i =0; i < n; i++)
-               gradient[i] = A[i].d(0); // partial detA w.r.t A[i]
-     }
-     // ---------------------------------------------------------
-     return true;
-}
- -
Input File: speed/fadbad/det_lu.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_fadbad_det_lu.cpp_xml.js cppad-2019.02.00.0/doc/_fadbad_det_lu.cpp_xml.js --- cppad-2018.00.00.0/doc/_fadbad_det_lu.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fadbad_det_lu.cpp_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', -'speed.xml', -'speed_fadbad.xml', -'fadbad_det_lu.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'fadbad_det_minor.cpp.xml', -'fadbad_det_lu.cpp.xml', -'fadbad_mat_mul.cpp.xml', -'fadbad_ode.cpp.xml', -'fadbad_poly.cpp.xml', -'fadbad_sparse_hessian.cpp.xml', -'fadbad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'fadbad_det_lu.cpp.xml#Specifications', -'fadbad_det_lu.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/fadbad_det_minor.cpp.xml cppad-2019.02.00.0/doc/fadbad_det_minor.cpp.xml --- cppad-2018.00.00.0/doc/fadbad_det_minor.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/fadbad_det_minor.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ - - - -Fadbad Speed: Gradient of Determinant by Minor Expansion - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -fadbad_det_minor.cpp - -

-
Fadbad Speed: Gradient of Determinant by Minor Expansion
-
-Specifications -
-See link_det_minor -. - -
-
-Implementation - - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <FADBAD++/badiff.h>
-# include <cppad/speed/det_by_minor.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/utility/vector.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_det_minor(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &matrix   ,
-     CppAD::vector<double>     &gradient )
-{
-     // speed test global option values
-     if( global_option["atomic"] )
-          return false;
-     if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-
-     // object for computing determinant
-     typedef fadbad::B<double>       ADScalar;
-     typedef CppAD::vector<ADScalar> ADVector;
-     CppAD::det_by_minor<ADScalar>   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
-
-     // ------------------------------------------------------
-     while(repeat--)
-       {     // get the next matrix
-          CppAD::uniform_01(n, matrix);
-
-          // set independent variable values
-          for(i = 0; i < n; i++)
-               A[i] = matrix[i];
-
-          // compute the determinant
-          detA = Det(A);
-
-          // create function object f : A -> detA
-          detA.diff(0, m);  // index 0 of m dependent variables
-
-          // evaluate and return gradient using reverse mode
-          for(i =0; i < n; i++)
-               gradient[i] = A[i].d(0); // partial detA w.r.t A[i]
-     }
-     // ---------------------------------------------------------
-     return true;
-}
- -
Input File: speed/fadbad/det_minor.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_fadbad_det_minor.cpp_xml.js cppad-2019.02.00.0/doc/_fadbad_det_minor.cpp_xml.js --- cppad-2018.00.00.0/doc/_fadbad_det_minor.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fadbad_det_minor.cpp_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', -'speed.xml', -'speed_fadbad.xml', -'fadbad_det_minor.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'fadbad_det_minor.cpp.xml', -'fadbad_det_lu.cpp.xml', -'fadbad_mat_mul.cpp.xml', -'fadbad_ode.cpp.xml', -'fadbad_poly.cpp.xml', -'fadbad_sparse_hessian.cpp.xml', -'fadbad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'fadbad_det_minor.cpp.xml#Specifications', -'fadbad_det_minor.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/fadbad_mat_mul.cpp.xml cppad-2019.02.00.0/doc/fadbad_mat_mul.cpp.xml --- cppad-2018.00.00.0/doc/fadbad_mat_mul.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/fadbad_mat_mul.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,175 +0,0 @@ - - - -Fadbad Speed: Matrix Multiplication - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -fadbad_mat_mul.cpp - -

-
Fadbad Speed: Matrix Multiplication
-
-Specifications -
-See link_mat_mul -. - -
-
-Implementation - - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <FADBAD++/badiff.h>
-# include <cppad/speed/mat_sum_sq.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/utility/vector.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_mat_mul(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     CppAD::vector<double>&           x        ,
-     CppAD::vector<double>&           z        ,
-     CppAD::vector<double>&           dz       )
-{
-     // speed test global option values
-     if( global_option["memory"] || global_option["onetape"] || global_option["atomic"] || global_option["optimize"] )
-          return false;
-     // The correctness check for this test is failing, so abort (for now).
-     return false;
-
-     // -----------------------------------------------------
-     // setup
-
-     // object for computing determinant
-     typedef fadbad::B<double>       ADScalar;
-     typedef CppAD::vector<ADScalar> ADVector;
-
-     size_t j;                // temporary index
-     size_t m = 1;            // number of dependent variables
-     size_t n = size * size;  // number of independent variables
-     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
-          CppAD::uniform_01(n, x);
-
-          // set independent variable values
-          for(j = 0; j < n; j++)
-               X[j] = x[j];
-
-          // do the computation
-          mat_sum_sq(size, X, Y, Z);
-
-          // create function object f : X -> Z
-          Z[0].diff(0, m);  // index 0 of m dependent variables
-
-          // evaluate and return gradient using reverse mode
-          for(j = 0; j < n; j++)
-               dz[j] = X[j].d(0); // partial Z[0] w.r.t X[j]
-     }
-     // return function value
-     z[0] = Z[0].x();
-
-     // ---------------------------------------------------------
-     return true;
-}
- -
Input File: speed/fadbad/mat_mul.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_fadbad_mat_mul.cpp_xml.js cppad-2019.02.00.0/doc/_fadbad_mat_mul.cpp_xml.js --- cppad-2018.00.00.0/doc/_fadbad_mat_mul.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fadbad_mat_mul.cpp_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', -'speed.xml', -'speed_fadbad.xml', -'fadbad_mat_mul.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'fadbad_det_minor.cpp.xml', -'fadbad_det_lu.cpp.xml', -'fadbad_mat_mul.cpp.xml', -'fadbad_ode.cpp.xml', -'fadbad_poly.cpp.xml', -'fadbad_sparse_hessian.cpp.xml', -'fadbad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'fadbad_mat_mul.cpp.xml#Specifications', -'fadbad_mat_mul.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/fadbad_ode.cpp.xml cppad-2019.02.00.0/doc/fadbad_ode.cpp.xml --- cppad-2018.00.00.0/doc/fadbad_ode.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/fadbad_ode.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ - - - -Fadbad Speed: Ode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -fadbad_ode.cpp - -

-
Fadbad Speed: Ode
-
-Specifications -
-See link_ode -. - -
-
-Implementation - - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <FADBAD++/fadiff.h>
-# include <algorithm>
-# include <cassert>
-# include <cppad/utility/vector.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/speed/ode_evaluate.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-namespace fadbad {
-     // define fabs for use by ode_evaluate
-     fadbad::F<double> fabs(const fadbad::F<double>& x)
-     {     return std::max(-x, x); }
-}
-
-bool link_ode(
-     size_t                     size       ,
-     size_t                     repeat     ,
-     CppAD::vector<double>      &x         ,
-     CppAD::vector<double>      &jacobian
-)
-{
-     // speed test global option values
-     if( global_option["atomic"] )
-          return false;
-     if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] )
-          return false;
-     // -------------------------------------------------------------
-     // setup
-     assert( x.size() == size );
-     assert( jacobian.size() == size * size );
-
-     typedef fadbad::F<double>       ADScalar;
-     typedef CppAD::vector<ADScalar> ADVector;
-
-     size_t i, j;
-     size_t p = 0;          // use ode to calculate function values
-     size_t n = size;       // number of independent variables
-     size_t m = n;          // number of dependent variables
-     ADVector X(n), Y(m);   // independent and dependent variables
-
-     // -------------------------------------------------------------
-     while(repeat--)
-     {     // choose next x value
-          CppAD::uniform_01(n, x);
-          for(j = 0; j < n; j++)
-          {     // set value of x[j]
-               X[j] = x[j];
-               // set up for X as the independent variable vector
-               X[j].diff(j, n);
-          }
-
-          // evaluate function
-          CppAD::ode_evaluate(X, p, Y);
-
-          // return values with Y as the dependent variable vector
-          for(i = 0; i < m; i++)
-          {     for(j = 0; j < n; j++)
-                    jacobian[ i * n + j ] = Y[i].d(j);
-          }
-     }
-     return true;
-}
- -
Input File: speed/fadbad/ode.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_fadbad_ode.cpp_xml.js cppad-2019.02.00.0/doc/_fadbad_ode.cpp_xml.js --- cppad-2018.00.00.0/doc/_fadbad_ode.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fadbad_ode.cpp_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', -'speed.xml', -'speed_fadbad.xml', -'fadbad_ode.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'fadbad_det_minor.cpp.xml', -'fadbad_det_lu.cpp.xml', -'fadbad_mat_mul.cpp.xml', -'fadbad_ode.cpp.xml', -'fadbad_poly.cpp.xml', -'fadbad_sparse_hessian.cpp.xml', -'fadbad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'fadbad_ode.cpp.xml#Specifications', -'fadbad_ode.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/fadbad_poly.cpp.xml cppad-2019.02.00.0/doc/fadbad_poly.cpp.xml --- cppad-2018.00.00.0/doc/fadbad_poly.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/fadbad_poly.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ - - - -Fadbad Speed: Second Derivative of a Polynomial - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -fadbad_poly.cpp - -

-
Fadbad Speed: Second Derivative of a Polynomial
-
-Specifications -
-See link_poly -. - -
-
-Implementation - - -
# include <cppad/utility/vector.hpp>
-# include <cppad/utility/poly.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <FADBAD++/tadiff.h>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_poly(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &a        ,  // coefficients of polynomial
-     CppAD::vector<double>     &z        ,  // polynomial argument value
-     CppAD::vector<double>     &ddp      )  // second derivative w.r.t z
-{
-     if( global_option["atomic"] )
-          return false;
-     if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-     size_t i;             // temporary index
-     fadbad::T<double>  Z; // domain space AD value
-     fadbad::T<double>  P; // range space AD value
-
-     // choose the polynomial coefficients
-     CppAD::uniform_01(size, a);
-
-     // AD copy of the polynomial coefficients
-     CppAD::vector< fadbad::T<double> > A(size);
-     for(i = 0; i < size; i++)
-          A[i] = a[i];
-
-     // ------------------------------------------------------
-     while(repeat--)
-     {     // get the next argument value
-          CppAD::uniform_01(1, z);
-
-          // independent variable value
-          Z    = z[0]; // argument value
-          Z[1] = 1;    // argument first order Taylor coefficient
-
-          // AD computation of the dependent variable
-          P = CppAD::Poly(0, A, Z);
-
-          // Taylor-expand P to degree one
-          P.eval(2);
-
-          // second derivative is twice second order Taylor coefficient
-          ddp[0] = 2. * P[2];
-
-          // Free DAG corresponding to P does not seem to improve speed.
-          // Probably because it gets freed the next time P is assigned.
-          // P.reset();
-     }
-     // ------------------------------------------------------
-     return true;
-}
- -
Input File: speed/fadbad/poly.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_fadbad_poly.cpp_xml.js cppad-2019.02.00.0/doc/_fadbad_poly.cpp_xml.js --- cppad-2018.00.00.0/doc/_fadbad_poly.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fadbad_poly.cpp_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', -'speed.xml', -'speed_fadbad.xml', -'fadbad_poly.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'fadbad_det_minor.cpp.xml', -'fadbad_det_lu.cpp.xml', -'fadbad_mat_mul.cpp.xml', -'fadbad_ode.cpp.xml', -'fadbad_poly.cpp.xml', -'fadbad_sparse_hessian.cpp.xml', -'fadbad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'fadbad_poly.cpp.xml#Specifications', -'fadbad_poly.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/fadbad_prefix.xml cppad-2019.02.00.0/doc/fadbad_prefix.xml --- cppad-2018.00.00.0/doc/fadbad_prefix.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/fadbad_prefix.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ - - - -Including the FADBAD Speed Tests - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - -
Including the FADBAD Speed Tests
-
-Purpose -
-CppAD includes speed comparisons for the AD package -FADBAD -; see -speed_fadbad -. - - -
-
-fadbad_prefix -
-If FADBAD is installed on your system, you can -specify a value for its install -fadbad_prefix - on the -cmake - command line. -The value of -fadbad_prefix - must be such that, -for one of the directories -dir - in -cmake_install_includedirs -, - -
-     
fadbad_prefix/dir/FADBAD++/badiff.h
-
-is a valid way to reference to the include file badiff.h; - -
-
-Speed Tests -
-If you include -fadbad_prefix - on the cmake - command line, -you will be able to run the FADBAD speed correctness tests -by executing the following commands starting in the -distribution directory -: - -
-     cd build/speed/fadbad
-     make check_speed_fadbad
-
-After executing make check, you can run a specific FADBAD speed test -by executing the command ./speed_fadbad; -see speed_main - for the meaning of the command line -options to this program. - - -
-
-get_fadbad -
-If you are using Unix, you can download and install -a copy of Fadbad using get_fadbad.sh -. -The corresponding -fadbad_prefix - would be -build/prefix. - - - -
Input File: omh/install/fadbad_prefix.omh - - - diff -Nru cppad-2018.00.00.0/doc/_fadbad_prefix_xml.js cppad-2019.02.00.0/doc/_fadbad_prefix_xml.js --- cppad-2018.00.00.0/doc/_fadbad_prefix_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fadbad_prefix_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'fadbad_prefix.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 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.xml' -]; -var list_down1 = [ -'adolc_prefix.xml', -'colpack_prefix.xml', -'eigen_prefix.xml', -'fadbad_prefix.xml', -'ipopt_prefix.xml', -'sacado_prefix.xml', -'cppad_testvector.xml' -]; -var list_down0 = [ -'get_fadbad.sh.xml' -]; -var list_current0 = [ -'fadbad_prefix.xml#Purpose', -'fadbad_prefix.xml#fadbad_prefix', -'fadbad_prefix.xml#Speed Tests', -'fadbad_prefix.xml#get_fadbad' -]; -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-2018.00.00.0/doc/fadbad_sparse_hessian.cpp.xml cppad-2019.02.00.0/doc/fadbad_sparse_hessian.cpp.xml --- cppad-2018.00.00.0/doc/fadbad_sparse_hessian.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/fadbad_sparse_hessian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ - - - -Fadbad Speed: Sparse Hessian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -fadbad_sparse_hessian.cppHeadings

-
Fadbad Speed: Sparse Hessian
-
// A fadbad version of this test is not yet available
-bool link_sparse_hessian(
-        size_t                           size       ,
-        size_t                           repeat     ,
-        const CppAD::vector<size_t>&      row       ,
-        const CppAD::vector<size_t>&      col       ,
-        CppAD::vector<double>&            x         ,
-        CppAD::vector<double>&            hessian   ,
-        size_t&                           n_sweep
-)
-{
-     return false;
-}
- -
Input File: speed/fadbad/sparse_hessian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_fadbad_sparse_hessian.cpp_xml.js cppad-2019.02.00.0/doc/_fadbad_sparse_hessian.cpp_xml.js --- cppad-2018.00.00.0/doc/_fadbad_sparse_hessian.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fadbad_sparse_hessian.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', -'speed.xml', -'speed_fadbad.xml', -'fadbad_sparse_hessian.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'fadbad_det_minor.cpp.xml', -'fadbad_det_lu.cpp.xml', -'fadbad_mat_mul.cpp.xml', -'fadbad_ode.cpp.xml', -'fadbad_poly.cpp.xml', -'fadbad_sparse_hessian.cpp.xml', -'fadbad_sparse_jacobian.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-2018.00.00.0/doc/fadbad_sparse_jacobian.cpp.xml cppad-2019.02.00.0/doc/fadbad_sparse_jacobian.cpp.xml --- cppad-2018.00.00.0/doc/fadbad_sparse_jacobian.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/fadbad_sparse_jacobian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ - - - -fadbad Speed: sparse_jacobian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -fadbad_sparse_jacobian.cppHeadings

-
fadbad Speed: sparse_jacobian
-
// A fadbad version of this test is not yet available
-bool link_sparse_jacobian(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     size_t                           m        ,
-     const CppAD::vector<size_t>&     row      ,
-     const CppAD::vector<size_t>&     col      ,
-           CppAD::vector<double>&     x        ,
-           CppAD::vector<double>&     jacobian ,
-           size_t&                    n_sweep  )
-{
-     return false;
-}
- -
Input File: speed/fadbad/sparse_jacobian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_fadbad_sparse_jacobian.cpp_xml.js cppad-2019.02.00.0/doc/_fadbad_sparse_jacobian.cpp_xml.js --- cppad-2018.00.00.0/doc/_fadbad_sparse_jacobian.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fadbad_sparse_jacobian.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', -'speed.xml', -'speed_fadbad.xml', -'fadbad_sparse_jacobian.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'fadbad_det_minor.cpp.xml', -'fadbad_det_lu.cpp.xml', -'fadbad_mat_mul.cpp.xml', -'fadbad_ode.cpp.xml', -'fadbad_poly.cpp.xml', -'fadbad_sparse_hessian.cpp.xml', -'fadbad_sparse_jacobian.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-2018.00.00.0/doc/faq.xml cppad-2019.02.00.0/doc/faq.xml --- cppad-2018.00.00.0/doc/faq.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/faq.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,378 +0,0 @@ - - - -Frequently Asked Questions and Answers - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -Faq - -

-
Frequently Asked Questions and Answers
-
-Assignment and Independent -
-Why does the code sequence - -
-     Independent(
u);
-     
v = u[0];
-
-behave differently from the code sequence - -
-     
v = u[0];
-     Independent(
u);
-
-Before the call to Independent -, - -u[0] - is a parameter - -and after the call it is a variable. -Thus in the first case, -v - is a variable -and in the second case it is a parameter. - -
-
-Bugs -
-What should I do if I suspect that there is a bug in CppAD ? -
-
-
  1. The first step is to check currently open -issues - on github. -If it is an open issue, and you want to hurry it along, you can add -a comment to the effect that it is holding you up. -
  2. - -The next step is to search the -whats_new - sections for mention of a related bug fix -between the date of the version you are using and the current date. -It the bug has been fixed, obtain a more recent release that has the fix -and see if that works for you. -
  3. - -The next step is to -create a simple demonstration of the bug; -see the file bug/template.sh for a template that you can -edit for that purpose. -The smaller the program, the better the bug report. -
  4. - -The next step is open a new issue on github and provide your simple -example so that the problem can be reproduced. -
- - -
-
-CompareChange -
-If you attempt to use the -CompareChange - -function when NDEBUG is true, -you will get an error message stating that -CompareChange is not a member of the -ADFun - template class. - -
-
-Complex Types -
-Which of the following complex types is better: - -
-     AD< std::complex<
Base> >
-     std::complex< AD<
Base> >
-
-The complex abs function - is differentiable -with respect to its real and imaginary parts, -but it is not complex differentiable. -Thus one would prefer to use - -
-     std::complex< AD<
Base> >
-
-On the other hand, the C++ standard only specifies - -std::complex<Type> - where -Type - is -float, double, or lone double. -The effect of instantiating the template complex for any other type -is unspecified. - -
-
-Exceptions -
-Why, in all the examples, do you pass back a boolean variable instead -of throwing an exception ? -
-
-
The examples are also used to test the correctness of CppAD -and to check your installation. -For these two uses, it is helpful to run all the tests -and to know which ones failed. -The actual code in CppAD uses the ErrorHandler - utility -to signal exceptions. -Specifications for redefining this action are provided. - -
-
-Independent Variables -
-Is it possible to evaluate the same tape recording with different values -for the independent variables ? -
-
-
Yes (see forward_zero -). - -
-
-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 ? - -
-
-LuSolve -
-# -The example routine LuSolve - can be used to do this -because the inverse is a special case of the solution of linear equations. -The examples -jac_lu_det.cpp - and hes_lu_det.cpp - -use LuSolve to compute derivatives of the -determinant with respect to the components of the matrix. - -
-
-Atomic Operation -
-One can also do this by making the inversion of the matrix an atomic operation; -e.g., see atomic_eigen_mat_inv.cpp -. - -
-
-Mode: Forward or Reverse -
-When evaluating derivatives, -one always has a choice between -forward and reverse mode. -How does one decide which mode to use ? -
-
-
In general, the best mode depends on the number of domain and range -components in the function that your are differentiating. -Each call to Forward - computes the derivative of all -the range directions with respect to one domain direction. -Each call to Reverse - computes the derivative of one -range direction with respect to all the domain directions. -The times required for (speed of) -calls Forward and Reverse are about equal. -The Parameter - -function can be used to quickly determine that -some range directions have derivative zero. - - - -
-
-Namespace - - - -
-
-Test Vector Preprocessor Symbol -
-Why do you use CPPAD_TESTVECTOR instead of a namespace for -the CppAD testvector - class ? -
-
-
The preprocessor symbol -CPPAD_TESTVECTOR - -determines which -SimpleVector - template class is used for extensive testing. -The default definition for CPPAD_TESTVECTOR is the -CppAD::vector - template class, but it can be changed. -Note that all the preprocessor symbols that are defined or used -by CppAD begin with either CPPAD -(some old deprecated symbols begin with CppAD). - -
-
-Speed -
-How do I get the best speed performance out of CppAD ? - -
-
-NDEBUG -
-You should compile your code with optimization, without debugging, -and with the preprocessor symbol NDEBUG defined. -(The speed_cppad - tests do this.) -Note that defining NDEBUG -will turn off all of the error checking and reporting that -is done using ErrorHandler -. - -
-
-Optimize -
-It is also possible that preforming a tape -optimization - will improve the speed of evaluation -more than the time required for the optimization. - -
-
-Memory Allocation -
-You may also increase execution speed -by calling hold_memory with -value - equal to true. - -
-
-Tape Storage: Disk or Memory -
-Does CppAD store the tape on disk or in memory ? -
-
-
CppAD uses memory to store a different tape for recording operations -for each -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 -and the calculations may slow down because of necessary disk access. - - - -
Input File: omh/appendix/faq.omh - - - diff -Nru cppad-2018.00.00.0/doc/_faq_xml.js cppad-2019.02.00.0/doc/_faq_xml.js --- cppad-2018.00.00.0/doc/_faq_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_faq_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'faq.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', -'directory.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 = [ -'faq.xml#Assignment and Independent', -'faq.xml#Bugs', -'faq.xml#CompareChange', -'faq.xml#Complex Types', -'faq.xml#Exceptions', -'faq.xml#Independent Variables', -'faq.xml#Matrix Inverse', -'faq.xml#Matrix Inverse.LuSolve', -'faq.xml#Matrix Inverse.Atomic Operation', -'faq.xml#Mode: Forward or Reverse', -'faq.xml#Namespace', -'faq.xml#Namespace.Test Vector Preprocessor Symbol', -'faq.xml#Speed', -'faq.xml#Speed.NDEBUG', -'faq.xml#Speed.Optimize', -'faq.xml#Speed.Memory Allocation', -'faq.xml#Tape Storage: Disk or Memory' -]; -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-2018.00.00.0/doc/for_hes_sparsity.cpp.xml cppad-2019.02.00.0/doc/for_hes_sparsity.cpp.xml --- cppad-2018.00.00.0/doc/for_hes_sparsity.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/for_hes_sparsity.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ - - - -Forward Mode Hessian Sparsity: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -for_hes_sparsity.cppHeadings

- - - -
Forward Mode Hessian Sparsity: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool for_hes_sparsity(void)
-{     bool ok = true;
-     using CppAD::AD;
-     typedef CPPAD_TESTVECTOR(size_t)     SizeVector;
-     typedef CppAD::sparse_rc<SizeVector> sparsity;
-     //
-     // domain space vector
-     size_t n = 3;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-     ax[2] = 2.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = sin( ax[2] );
-     ay[1] = ax[0] * ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // include all x components in sparsity pattern
-     CPPAD_TESTVECTOR(bool) select_domain(n);
-     for(size_t j = 0; j < n; j++)
-          select_domain[j] = true;
-
-     // compute sparsity pattern for H(x) = F_1''(x)
-     CPPAD_TESTVECTOR(bool) select_range(m);
-     select_range[0]    = false;
-     select_range[1]    = true;
-     bool internal_bool = true;
-     sparsity pattern_out;
-     f.for_hes_sparsity(
-          select_domain, select_range, internal_bool, pattern_out
-     );
-     size_t nnz = pattern_out.nnz();
-     ok        &= nnz == 2;
-     ok        &= pattern_out.nr() == n;
-     ok        &= pattern_out.nc() == n;
-     {     // check results
-          const SizeVector& row( pattern_out.row() );
-          const SizeVector& col( pattern_out.col() );
-          SizeVector row_major = pattern_out.row_major();
-          //
-          ok &= row[ row_major[0] ] ==  0  && col[ row_major[0] ] ==  1;
-          ok &= row[ row_major[1] ] ==  1  && col[ row_major[1] ] ==  0;
-     }
-     //
-     // compute sparsity pattern for H(x) = F_0''(x)
-     select_range[0] = true;
-     select_range[1] = false;
-     f.for_hes_sparsity(
-          select_domain, select_range, internal_bool, pattern_out
-     );
-     nnz = pattern_out.nnz();
-     ok &= nnz == 1;
-     ok &= pattern_out.nr() == n;
-     ok &= pattern_out.nc() == n;
-     {     // check results
-          const SizeVector& row( pattern_out.row() );
-          const SizeVector& col( pattern_out.col() );
-          //
-          ok &= row[0] ==  2  && col[0] ==  2;
-     }
-     return ok;
-}
-
-
Input File: example/sparse/for_hes_sparsity.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_for_hes_sparsity.cpp_xml.js cppad-2019.02.00.0/doc/_for_hes_sparsity.cpp_xml.js --- cppad-2018.00.00.0/doc/_for_hes_sparsity.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_for_hes_sparsity.cpp_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', -'adfun.xml', -'sparsity_pattern.xml', -'for_hes_sparsity.xml', -'for_hes_sparsity.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down1 = [ -'for_hes_sparsity.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-2018.00.00.0/doc/for_hes_sparsity.xml cppad-2019.02.00.0/doc/for_hes_sparsity.xml --- cppad-2018.00.00.0/doc/for_hes_sparsity.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/for_hes_sparsity.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,451 +0,0 @@ - - - -Forward Mode Hessian Sparsity Patterns - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Forward Mode Hessian Sparsity Patterns
-
-Syntax - -
- -f.for_hes_sparsity(
-     
select_domainselect_rangeinternal_boolpattern_out
-)
- - -
-
-Purpose -
-We use - -F -: -R - -n - - -R - -m - - - - to denote the -AD function - corresponding to -the operation sequence stored in -f -. -Fix a diagonal matrix - -D - -R - -n -× -n - - - - -, -a vector - -s - -R - -m - - - - and define the function - - -H -( -x -) -= -D -( -s -T - - -F -) -( -2 -) - - -( -x -) -D - - -Given the sparsity for - -D - - - and - -s - - -, -for_hes_sparsity computes a sparsity pattern for - -H -( -x -) - - -. - -
-
-x -
-Note that the sparsity pattern - -H -( -x -) - - - corresponds to the -operation sequence stored in -f - and does not depend on -the argument -x -. - -
-
-BoolVector -
-The type -BoolVector - is a SimpleVector - class with -elements of type - -bool. - -
-
-SizeVector -
-The type -SizeVector - is a SimpleVector - class with -elements of type - -size_t. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-
-select_domain -
-The argument -select_domain - has prototype - -
-     const 
BoolVectorselect_domain
-
-It has size - -n - - - and specifies which components of the diagonal of - - -D - - - are non-zero; i.e., -select_domain[j] - is true -if and only if - -D -j -, -j - - - - - is possibly non-zero. - - -
-
-select_range -
-The argument -select_range - has prototype - -
-     const 
BoolVectorselect_range
-
-It has size - -m - - - and specifies which components of the vector - - -s - - - are non-zero; i.e., -select_range[i] - is true -if and only if - -s -i - - - - is possibly non-zero. - -
-
-internal_bool -
-If this is true, calculations are done with sets represented by a vector -of boolean values. Otherwise, a vector of sets of integers is used. - -
-
-pattern_out -
-This argument has prototype - -
-     sparse_rc<
SizeVector>& pattern_out
-
-This input value of -pattern_out - does not matter. -Upon return -pattern_out - is a sparsity pattern for - -H -( -x -) - - -. - -
-
-Sparsity for Entire Hessian -
-Suppose that - -R - - - is the - -n -× -n - - - identity matrix. -In this case, -pattern_out - is a sparsity pattern for - - -( -s -T - - -F -) -F -( -2 -) - - -( -x -) - - -. - -
-
-Algorithm -
-See Algorithm II in -Computing sparse Hessians with automatic differentiation -by Andrea Walther. -Note that -s - provides the information so that -'dead ends' are not included in the sparsity pattern. - -
-
-Example - -
-The file for_hes_sparsity.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/for_hes_sparsity.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_for_hes_sparsity_xml.js cppad-2019.02.00.0/doc/_for_hes_sparsity_xml.js --- cppad-2018.00.00.0/doc/_for_hes_sparsity_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_for_hes_sparsity_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparsity_pattern.xml', -'for_hes_sparsity.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down0 = [ -'for_hes_sparsity.cpp.xml' -]; -var list_current0 = [ -'for_hes_sparsity.xml#Syntax', -'for_hes_sparsity.xml#Purpose', -'for_hes_sparsity.xml#x', -'for_hes_sparsity.xml#BoolVector', -'for_hes_sparsity.xml#SizeVector', -'for_hes_sparsity.xml#f', -'for_hes_sparsity.xml#select_domain', -'for_hes_sparsity.xml#select_range', -'for_hes_sparsity.xml#internal_bool', -'for_hes_sparsity.xml#pattern_out', -'for_hes_sparsity.xml#Sparsity for Entire Hessian', -'for_hes_sparsity.xml#Algorithm', -'for_hes_sparsity.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-2018.00.00.0/doc/for_jac_sparsity.cpp.xml cppad-2019.02.00.0/doc/for_jac_sparsity.cpp.xml --- cppad-2018.00.00.0/doc/for_jac_sparsity.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/for_jac_sparsity.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ - - - -Forward Mode Jacobian Sparsity: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -for_jac_sparsity.cppHeadings

- - - -
Forward Mode Jacobian Sparsity: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool for_jac_sparsity(void)
-{     bool ok = true;
-     using CppAD::AD;
-     typedef CPPAD_TESTVECTOR(size_t)     SizeVector;
-     typedef CppAD::sparse_rc<SizeVector> sparsity;
-     //
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = ax[0];
-     ay[1] = ax[0] * ax[1];
-     ay[2] = ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // sparsity pattern for the identity matrix
-     size_t nr     = n;
-     size_t nc     = n;
-     size_t nnz_in = n;
-     sparsity pattern_in(nr, nc, nnz_in);
-     for(size_t k = 0; k < nnz_in; k++)
-     {     size_t r = k;
-          size_t c = k;
-          pattern_in.set(k, r, c);
-     }
-     //
-     // Compute sparsity pattern for J(x) = F'(x)
-     bool transpose       = false;
-     bool dependency      = false;
-     bool internal_bool   = false;
-     sparsity pattern_out;
-     f.for_jac_sparsity(
-          pattern_in, transpose, dependency, internal_bool, pattern_out
-     );
-     size_t nnz = pattern_out.nnz();
-     ok        &= nnz == 4;
-     ok        &= pattern_out.nr() == m;
-     ok        &= pattern_out.nc() == n;
-     {     // check results
-          const SizeVector& row( pattern_out.row() );
-          const SizeVector& col( pattern_out.col() );
-          SizeVector col_major = pattern_out.col_major();
-          //
-          ok &= row[ col_major[0] ] ==  0  && col[ col_major[0] ] ==  0;
-          ok &= row[ col_major[1] ] ==  1  && col[ col_major[1] ] ==  0;
-          ok &= row[ col_major[2] ] ==  1  && col[ col_major[2] ] ==  1;
-          ok &= row[ col_major[3] ] ==  2  && col[ col_major[3] ] ==  1;
-          //
-          // check that set and not boolean values are stored
-          ok &= (f.size_forward_set() > 0);
-          ok &= (f.size_forward_bool() == 0);
-     }
-     //
-     // note that the transpose of the identity is the identity
-     transpose     = true;
-     internal_bool = true;
-     f.for_jac_sparsity(
-          pattern_in, transpose, dependency, internal_bool, pattern_out
-     );
-     nnz  = pattern_out.nnz();
-     ok  &= nnz == 4;
-     ok  &= pattern_out.nr() == n;
-     ok  &= pattern_out.nc() == m;
-     {     // check results
-          const SizeVector& row( pattern_out.row() );
-          const SizeVector& col( pattern_out.col() );
-          SizeVector row_major = pattern_out.row_major();
-          //
-          ok &= col[ row_major[0] ] ==  0  && row[ row_major[0] ] ==  0;
-          ok &= col[ row_major[1] ] ==  1  && row[ row_major[1] ] ==  0;
-          ok &= col[ row_major[2] ] ==  1  && row[ row_major[2] ] ==  1;
-          ok &= col[ row_major[3] ] ==  2  && row[ row_major[3] ] ==  1;
-          //
-          // check that set and not boolean values are stored
-          ok &= (f.size_forward_set() == 0);
-          ok &= (f.size_forward_bool() > 0);
-     }
-     return ok;
-}
-
-
Input File: example/sparse/for_jac_sparsity.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_for_jac_sparsity.cpp_xml.js cppad-2019.02.00.0/doc/_for_jac_sparsity.cpp_xml.js --- cppad-2018.00.00.0/doc/_for_jac_sparsity.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_for_jac_sparsity.cpp_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', -'adfun.xml', -'sparsity_pattern.xml', -'for_jac_sparsity.xml', -'for_jac_sparsity.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down1 = [ -'for_jac_sparsity.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-2018.00.00.0/doc/for_jac_sparsity.xml cppad-2019.02.00.0/doc/for_jac_sparsity.xml --- cppad-2018.00.00.0/doc/for_jac_sparsity.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/for_jac_sparsity.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,519 +0,0 @@ - - - -Forward Mode Jacobian Sparsity Patterns - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Forward Mode Jacobian Sparsity Patterns
-
-Syntax - -
- -f.for_jac_sparsity(
-     
pattern_intransposedependencyinternal_boolpattern_out
-)
- - -
-
-Purpose -
-We use - -F -: -R - -n - - -R - -m - - - - to denote the -AD function - corresponding to -the operation sequence stored in -f -. -Fix - -R - -R - -n -× - - - - - - and define the function - - -J -( -x -) -= -F -( -1 -) - - -( -x -) -* -R - - -Given the sparsity pattern - for - -R - - -, -for_jac_sparsity computes a sparsity pattern for - -J -( -x -) - - -. - -
-
-x -
-Note that the sparsity pattern - -J -( -x -) - - - corresponds to the -operation sequence stored in -f - and does not depend on -the argument -x -. -(The operation sequence may contain -CondExp - and VecAD - operations.) - -
-
-SizeVector -
-The type -SizeVector - is a SimpleVector - class with -elements of type - -size_t. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-The ADFun - object -f - is not const. -After a call to for_jac_sparsity, a sparsity pattern -for each of the variables in the operation sequence -is held in -f - for possible later use during -reverse Hessian sparsity calculations. - -
-
-size_forward_bool -
-After for_jac_sparsity, if -k - is a size_t object, - -
-     
k = f.size_forward_bool()
-
-sets -k - to the amount of memory (in unsigned character units) -used to store the -boolean vector - -sparsity patterns. -If -internal_bool - if false, -k - will be zero. -Otherwise it will be non-zero. -If you do not need this information for RevSparseHes - -calculations, it can be deleted -(and the corresponding memory freed) using - -
-     
f.size_forward_bool(0)
-
-after which -f.size_forward_bool() - will return zero. - -
-
-size_forward_set -
-After for_jac_sparsity, if -k - is a size_t object, - -
-     
k = f.size_forward_set()
-
-sets -k - to the amount of memory (in unsigned character units) -used to store the -vector of sets - -sparsity patterns. -If -internal_bool - if true, -k - will be zero. -Otherwise it will be non-zero. -If you do not need this information for future rev_hes_sparsity - -calculations, it can be deleted -(and the corresponding memory freed) using - -
-     
f.size_forward_set(0)
-
-after which -f.size_forward_set() - will return zero. - -
-
-pattern_in -
-The argument -pattern_in - has prototype - -
-     const sparse_rc<
SizeVector>& pattern_in
-
-see sparse_rc -. -If -transpose - it is false (true), - -pattern_in - is a sparsity pattern for - -R - - - ( - -R -T - - - - -). - -
-
-transpose -
-This argument has prototype - -
-     bool 
transpose
-
-See pattern_in - above and -pattern_out - below. - -
-
-dependency -
-This argument has prototype - -
-     bool 
dependency
-
-see pattern_out - below. - -
-
-internal_bool -
-If this is true, calculations are done with sets represented by a vector -of boolean values. Otherwise, a vector of sets of integers is used. - -
-
-pattern_out -
-This argument has prototype - -
-     sparse_rc<
SizeVector>& pattern_out
-
-This input value of -pattern_out - does not matter. -If -transpose - it is false (true), -upon return -pattern_out - is a sparsity pattern for - - -J -( -x -) - - - ( - -J -( -x -) -T - - - - -). -If -dependency - is true, -pattern_out - is a -dependency pattern - -instead of sparsity pattern. - -
-
-Sparsity for Entire Jacobian -
-Suppose that - - -R - - - is the - -n -× -n - - - identity matrix. -In this case, -pattern_out - is a sparsity pattern for - - -F -( -1 -) - - -( -x -) - - - ( - -F -( -1 -) - - -( -x -) -T - - - - - ) -if -transpose - is false (true). - -
-
-Example - -
-The file -for_jac_sparsity.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/for_jac_sparsity.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_for_jac_sparsity_xml.js cppad-2019.02.00.0/doc/_for_jac_sparsity_xml.js --- cppad-2018.00.00.0/doc/_for_jac_sparsity_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_for_jac_sparsity_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparsity_pattern.xml', -'for_jac_sparsity.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down0 = [ -'for_jac_sparsity.cpp.xml' -]; -var list_current0 = [ -'for_jac_sparsity.xml#Syntax', -'for_jac_sparsity.xml#Purpose', -'for_jac_sparsity.xml#x', -'for_jac_sparsity.xml#SizeVector', -'for_jac_sparsity.xml#f', -'for_jac_sparsity.xml#f.size_forward_bool', -'for_jac_sparsity.xml#f.size_forward_set', -'for_jac_sparsity.xml#pattern_in', -'for_jac_sparsity.xml#transpose', -'for_jac_sparsity.xml#dependency', -'for_jac_sparsity.xml#internal_bool', -'for_jac_sparsity.xml#pattern_out', -'for_jac_sparsity.xml#Sparsity for Entire Jacobian', -'for_jac_sparsity.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-2018.00.00.0/doc/for_one.cpp.xml cppad-2019.02.00.0/doc/for_one.cpp.xml --- cppad-2018.00.00.0/doc/for_one.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/for_one.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,155 +0,0 @@ - - - -First Order Partial Driver: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -for_one.cppHeadings

- - - - -
First Order Partial Driver: Example and Test
-
# include <cppad/cppad.hpp>
-namespace { // -------------------------------------------------------
-// define the template function ForOneCases<Vector> in empty namespace
-template <typename Vector>
-bool ForOneCases()
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     using CppAD::exp;
-     using CppAD::sin;
-     using CppAD::cos;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>)  X(n);
-     X[0] = 1.;
-     X[1] = 2.;
-
-     // declare independent variables and starting recording
-     CppAD::Independent(X);
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>)  Y(m);
-     Y[0] = X[0] * exp( X[1] );
-     Y[1] = X[0] * sin( X[1] );
-     Y[2] = X[0] * cos( X[1] );
-
-     // create f: X -> Y and stop tape recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // new value for the independent variable vector
-     Vector x(n);
-     x[0] = 2.;
-     x[1] = 1.;
-
-     // compute partial of y w.r.t x[0]
-     Vector dy(m);
-     dy  = f.ForOne(x, 0);
-     ok &= NearEqual( dy[0], exp(x[1]), eps99, eps99); // for y[0]
-     ok &= NearEqual( dy[1], sin(x[1]), eps99, eps99); // for y[1]
-     ok &= NearEqual( dy[2], cos(x[1]), eps99, eps99); // for y[2]
-
-     // compute partial of F w.r.t x[1]
-     dy  = f.ForOne(x, 1);
-     ok &= NearEqual( dy[0],  x[0]*exp(x[1]), eps99, eps99);
-     ok &= NearEqual( dy[1],  x[0]*cos(x[1]), eps99, eps99);
-     ok &= NearEqual( dy[2], -x[0]*sin(x[1]), eps99, eps99);
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool ForOne(void)
-{     bool ok = true;
-     // Run with Vector equal to three different cases
-     // all of which are Simple Vectors with elements of type double.
-     ok &= ForOneCases< CppAD::vector  <double> >();
-     ok &= ForOneCases< std::vector    <double> >();
-     ok &= ForOneCases< std::valarray  <double> >();
-     return ok;
-}
-
-
Input File: example/general/for_one.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_for_one.cpp_xml.js cppad-2019.02.00.0/doc/_for_one.cpp_xml.js --- cppad-2018.00.00.0/doc/_for_one.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_for_one.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'forone.xml', -'for_one.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down1 = [ -'for_one.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-2018.00.00.0/doc/forone.xml cppad-2019.02.00.0/doc/forone.xml --- cppad-2018.00.00.0/doc/forone.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/forone.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,401 +0,0 @@ - - - -First Order Partial Derivative: Driver Routine - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
First Order Partial Derivative: Driver Routine
-
-Syntax - -
- -dy = f.ForOne(xj) - - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -The syntax above sets -dy - to the -partial of - -F - - - with respect to - -x -j - - - -; i.e., - - -dy -= - -F - - -x -j - - - -( -x -) -= -[ -F -0 - - - -x -j - - - -( -x -) -, - -, - -F -m --1 - - - - -x -j - - - -( -x -) -] - - -
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const -(see ForOne Uses Forward - below). - -
-
-x -
-The argument -x - has prototype - -
-     const 
Vector &x
-
-(see Vector - below) -and its size -must be equal to -n -, the dimension of the -domain - space for -f -. -It specifies -that point at which to evaluate the partial derivative. - -
-
-j -
-The argument -j - has prototype - -
-     size_t 
j
-
-an is less than -n -, -domain - space for -f -. -It specifies the component of -F - -for which we are computing the partial derivative. - -
-
-dy -
-The result -dy - has prototype - -
-     
Vector dy
-
-(see Vector - below) -and its size is - -m - - -, the dimension of the -range - space for -f -. -The value of -dy - is the partial of - -F - - - with respect to - - -x -j - - - - evaluated at -x -; i.e., -for - -i -= -0 -, - -, -m -- -1 - - - - - -. -dy -[ -i -] -= - -F -i - - - -x -j - - - -( -x -) - - -
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-ForOne Uses Forward -
-After each call to Forward -, -the object -f - contains the corresponding -Taylor coefficients -. -After a call to ForOne, -the zero order Taylor coefficients correspond to - -f.Forward(0,x) - -and the other coefficients are unspecified. - -
-
-Example - -
-The routine -ForOne - is both an example and test. -It returns true, if it succeeds and false otherwise. - - -
Input File: cppad/core/for_one.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_forone_xml.js cppad-2019.02.00.0/doc/_forone_xml.js --- cppad-2018.00.00.0/doc/_forone_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forone_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'forone.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down0 = [ -'for_one.cpp.xml' -]; -var list_current0 = [ -'forone.xml#Syntax', -'forone.xml#Purpose', -'forone.xml#f', -'forone.xml#x', -'forone.xml#j', -'forone.xml#dy', -'forone.xml#Vector', -'forone.xml#ForOne Uses Forward', -'forone.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-2018.00.00.0/doc/for_sparse_hes.cpp.xml cppad-2019.02.00.0/doc/for_sparse_hes.cpp.xml --- cppad-2018.00.00.0/doc/for_sparse_hes.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/for_sparse_hes.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,266 +0,0 @@ - - - -Forward Mode Hessian Sparsity: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -for_sparse_hes.cppHeadings

- - - -
Forward Mode Hessian Sparsity: Example and Test
-

-# include <cppad/cppad.hpp>
-namespace { // -------------------------------------------------------------
-
-// expected sparsity pattern
-bool check_f0[] = {
-     false, false, false,  // partials w.r.t x0 and (x0, x1, x2)
-     false, false, false,  // partials w.r.t x1 and (x0, x1, x2)
-     false, false, true    // partials w.r.t x2 and (x0, x1, x2)
-};
-bool check_f1[] = {
-     false,  true, false,  // partials w.r.t x0 and (x0, x1, x2)
-     true,  false, false,  // partials w.r.t x1 and (x0, x1, x2)
-     false, false, false   // partials w.r.t x2 and (x0, x1, x2)
-};
-
-// define the template function BoolCases<Vector> in empty namespace
-template <typename Vector> // vector class, elements of type bool
-bool BoolCases(bool optimize)
-{     bool ok = true;
-     using CppAD::AD;
-
-     // domain space vector
-     size_t n = 3;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-     ax[2] = 2.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = sin( ax[2] ) + ax[0] + ax[1] + ax[2];
-     ay[1] = ax[0] * ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-     if( optimize )
-          f.optimize();
-
-     // sparsity pattern for diagonal of identity matrix
-     Vector r(n);
-     size_t i, j;
-     for(i = 0; i < n; i++)
-          r[ i ] = true;
-
-     // compute sparsity pattern for H(x) = F_0^{(2)} (x)
-     Vector s(m);
-     for(i = 0; i < m; i++)
-          s[i] = false;
-     s[0] = true;
-     Vector h(n * n);
-     h    = f.ForSparseHes(r, s);
-
-     // check values
-     for(i = 0; i < n; i++)
-          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)
-     for(i = 0; i < m; i++)
-          s[i] = false;
-     s[1] = true;
-     h    = f.ForSparseHes(r, s);
-
-     // check values
-     for(i = 0; i < n; i++)
-          for(j = 0; j < n; j++)
-               ok &= (h[ i * n + j ] == check_f1[ i * n + j ] );
-
-     return ok;
-}
-// define the template function SetCases<Vector> in empty namespace
-template <typename Vector> // vector class, elements of type std::set<size_t>
-bool SetCases(bool optimize)
-{     bool ok = true;
-     using CppAD::AD;
-
-     // domain space vector
-     size_t n = 3;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-     ax[2] = 2.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = sin( ax[2] );
-     ay[1] = ax[0] * ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-     if( optimize )
-          f.optimize();
-
-     // sparsity pattern for the diagonal of the identity matrix
-     Vector r(1);
-     size_t i;
-     for(i = 0; i < n; i++)
-          r[0].insert(i);
-
-     // compute sparsity pattern for H(x) = F_0^{(2)} (x)
-     Vector s(1);
-     assert( s[0].empty() );
-     s[0].insert(0);
-     Vector h(n);
-     h    = f.ForSparseHes(r, s);
-
-     // check values
-     std::set<size_t>::iterator itr;
-     size_t j;
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j < n; j++)
-          {     bool found = h[i].find(j) != h[i].end();
-               ok        &= (found == check_f0[i * n + j]);
-          }
-     }
-
-     // compute sparsity pattern for H(x) = F_1^{(2)} (x)
-     s[0].clear();
-     assert( s[0].empty() );
-     s[0].insert(1);
-     h    = f.ForSparseHes(r, s);
-
-     // check values
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j < n; j++)
-          {     bool found = h[i].find(j) != h[i].end();
-               ok        &= (found == check_f1[i * n + j]);
-          }
-     }
-
-     return ok;
-}
-} // End empty namespace
-
-# include <vector>
-# include <valarray>
-bool for_sparse_hes(void)
-{     bool ok = true;
-     for(size_t k = 0; k < 2; k++)
-     {     bool optimize = bool(k);
-
-          // Run with Vector equal to four different cases
-          // all of which are Simple Vectors with elements of type bool.
-          ok &= BoolCases< CppAD::vector  <bool> >(optimize);
-          ok &= BoolCases< CppAD::vectorBool     >(optimize);
-          ok &= BoolCases< std::vector    <bool> >(optimize);
-          ok &= BoolCases< std::valarray  <bool> >(optimize);
-
-          // Run with Vector equal to two different cases both of which are
-          // Simple Vectors with elements of type std::set<size_t>
-          typedef std::set<size_t> set;
-          ok &= SetCases< CppAD::vector  <set> >(optimize);
-          ok &= SetCases< std::vector    <set> >(optimize);
-
-          // Do not use valarray because its element access in the const case
-          // returns a copy instead of a reference
-          // ok &= SetCases< std::valarray  <set> >(optimize);
-     }
-     return ok;
-}
-
-
-
-
Input File: example/sparse/for_sparse_hes.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_for_sparse_hes.cpp_xml.js cppad-2019.02.00.0/doc/_for_sparse_hes.cpp_xml.js --- cppad-2018.00.00.0/doc/_for_sparse_hes.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_for_sparse_hes.cpp_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', -'adfun.xml', -'sparsity_pattern.xml', -'forsparsehes.xml', -'for_sparse_hes.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down1 = [ -'for_sparse_hes.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-2018.00.00.0/doc/forsparsehes.xml cppad-2019.02.00.0/doc/forsparsehes.xml --- cppad-2018.00.00.0/doc/forsparsehes.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/forsparsehes.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,490 +0,0 @@ - - - -Hessian Sparsity Pattern: Forward Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Hessian Sparsity Pattern: Forward Mode
-
-Syntax - -
- -h = f.ForSparseHes(rs)
-
-
-Purpose -
-We use - -F -: -R - -n - - -R - -m - - - - to denote the -AD function - corresponding to -f -. -we define - - - -H -( -x -) - -= - - -x - -[ -u - -S -· -F -[ -x -+ -R -· -u -] -] -u -= -0 - - - - -= - -R -T - - -· -( -S -· -F -) -( -2 -) - - -( -x -) -· -R - - - -Where - -R - -R - -n -× -n - - - - - is a diagonal matrix -and - -S - -R - -1 -× -m - - - - - is a row vector. -Given a -sparsity pattern - -for the diagonal of - -R - - - and the vector - -S - - -, -ForSparseHes returns a sparsity pattern for the - -H -( -x -) - - -. - -
-
-f -
-The object -f - has prototype - -
-     const ADFun<
Basef
-
-
-x -
-If the operation sequence in -f - is -independent - of -the independent variables in - -x - -B -n - - - -, -the sparsity pattern is valid for all values of -(even if it has CondExp - or VecAD - operations). - -
-
-r -
-The argument -r - has prototype - -
-     const 
VectorSetr
-
-(see VectorSet - below) -If it has elements of type bool, -its size is - -n - - -. -If it has elements of type std::set<size_t>, -its size is one and all the elements of -s[0] - -are between zero and - -n -- -1 - - -. -It specifies a -sparsity pattern - -for the diagonal of - -R - - -. -The fewer non-zero elements in this sparsity pattern, -the faster the calculation should be and the more sparse - - -H -( -x -) - - - should be. - -
-
-s -
-The argument -s - has prototype - -
-     const 
VectorSets
-
-(see VectorSet - below) -If it has elements of type bool, -its size is - -m - - -. -If it has elements of type std::set<size_t>, -its size is one and all the elements of -s[0] - -are between zero and - -m -- -1 - - -. -It specifies a -sparsity pattern - -for the vector -S -. -The fewer non-zero elements in this sparsity pattern, -the faster the calculation should be and the more sparse - - -H -( -x -) - - - should be. - -
-
-h -
-The result -h - has prototype - -
-     
VectorSeth
-
-(see VectorSet - below). -If -h - has elements of type bool, -its size is - -n -* -n - - -. -If it has elements of type std::set<size_t>, -its size is - -n - - - and all the set elements are between -zero and -n-1 - inclusive. -It specifies a -sparsity pattern - -for the matrix - -H -( -x -) - - -. - -
-
-VectorSet -
-The type -VectorSet - must be a SimpleVector - class with -elements of type - -bool or std::set<size_t>; -see sparsity pattern - for a discussion -of the difference. -The type of the elements of -VectorSet - must be the -same as the type of the elements of -r -. - -
-
-Algorithm -
-See Algorithm II in -Computing sparse Hessians with automatic differentiation -by Andrea Walther. -Note that -s - provides the information so that -'dead ends' are not included in the sparsity pattern. - -
-
-Example - -
-The file -for_sparse_hes.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/for_sparse_hes.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_forsparsehes_xml.js cppad-2019.02.00.0/doc/_forsparsehes_xml.js --- cppad-2018.00.00.0/doc/_forsparsehes_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forsparsehes_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparsity_pattern.xml', -'forsparsehes.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down0 = [ -'for_sparse_hes.cpp.xml' -]; -var list_current0 = [ -'forsparsehes.xml#Syntax', -'forsparsehes.xml#Purpose', -'forsparsehes.xml#f', -'forsparsehes.xml#x', -'forsparsehes.xml#r', -'forsparsehes.xml#s', -'forsparsehes.xml#h', -'forsparsehes.xml#VectorSet', -'forsparsehes.xml#Algorithm', -'forsparsehes.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-2018.00.00.0/doc/for_sparse_jac.cpp.xml cppad-2019.02.00.0/doc/for_sparse_jac.cpp.xml --- cppad-2018.00.00.0/doc/for_sparse_jac.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/for_sparse_jac.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,280 +0,0 @@ - - - -Forward Mode Jacobian Sparsity: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -for_sparse_jac.cppHeadings

- - - -
Forward Mode Jacobian Sparsity: Example and Test
-

-# include <set>
-# include <cppad/cppad.hpp>
-
-namespace { // -------------------------------------------------------------
-// define the template function BoolCases<Vector>
-template <typename Vector>  // vector class, elements of type bool
-bool BoolCases(void)
-{     bool ok = true;
-     using CppAD::AD;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) X(n);
-     X[0] = 0.;
-     X[1] = 1.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(X);
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>) Y(m);
-     Y[0] = X[0];
-     Y[1] = X[0] * X[1];
-     Y[2] = X[1];
-
-     // create f: X -> Y and stop tape recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // sparsity pattern for the identity matrix
-     Vector r(n * n);
-     size_t i, j;
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j < n; j++)
-               r[ i * n + j ] = (i == j);
-     }
-
-     // sparsity pattern for F'(x)
-     Vector s(m * n);
-     s = f.ForSparseJac(n, r);
-
-     // check values
-     ok &= (s[ 0 * n + 0 ] == true);  // Y[0] does     depend on X[0]
-     ok &= (s[ 0 * n + 1 ] == false); // Y[0] does not depend on X[1]
-     ok &= (s[ 1 * n + 0 ] == true);  // Y[1] does     depend on X[0]
-     ok &= (s[ 1 * n + 1 ] == true);  // Y[1] does     depend on X[1]
-     ok &= (s[ 2 * n + 0 ] == false); // Y[2] does not depend on X[0]
-     ok &= (s[ 2 * n + 1 ] == true);  // Y[2] does     depend on X[1]
-
-     // check that values are stored
-     ok &= (f.size_forward_bool() > 0);
-     ok &= (f.size_forward_set() == 0);
-
-     // sparsity pattern for F'(x)^T, note R is the identity, so R^T = R
-     bool transpose = true;
-     Vector st(n * m);
-     st = f.ForSparseJac(n, r, transpose);
-
-     // check values
-     ok &= (st[ 0 * m + 0 ] == true);  // Y[0] does     depend on X[0]
-     ok &= (st[ 1 * m + 0 ] == false); // Y[0] does not depend on X[1]
-     ok &= (st[ 0 * m + 1 ] == true);  // Y[1] does     depend on X[0]
-     ok &= (st[ 1 * m + 1 ] == true);  // Y[1] does     depend on X[1]
-     ok &= (st[ 0 * m + 2 ] == false); // Y[2] does not depend on X[0]
-     ok &= (st[ 1 * m + 2 ] == true);  // Y[2] does     depend on X[1]
-
-     // check that values are stored
-     ok &= (f.size_forward_bool() > 0);
-     ok &= (f.size_forward_set() == 0);
-
-     // free values from forward calculation
-     f.size_forward_bool(0);
-     ok &= (f.size_forward_bool() == 0);
-
-     return ok;
-}
-// define the template function SetCases<Vector>
-template <typename Vector>  // vector class, elements of type std::set<size_t>
-bool SetCases(void)
-{     bool ok = true;
-     using CppAD::AD;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) X(n);
-     X[0] = 0.;
-     X[1] = 1.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(X);
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>) Y(m);
-     Y[0] = X[0];
-     Y[1] = X[0] * X[1];
-     Y[2] = X[1];
-
-     // create f: X -> Y and stop tape recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // sparsity pattern for the identity matrix
-     Vector r(n);
-     size_t i;
-     for(i = 0; i < n; i++)
-     {     assert( r[i].empty() );
-          r[i].insert(i);
-     }
-
-     // sparsity pattern for F'(x)
-     Vector s(m);
-     s = f.ForSparseJac(n, r);
-
-     // an interator to a standard set
-     std::set<size_t>::iterator itr;
-     bool found;
-
-     // Y[0] does     depend on X[0]
-     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 );
-     // Y[1] does     depend on X[0]
-     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 );
-     // Y[2] does not depend on X[0]
-     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 );
-
-     // check that values are stored
-     ok &= (f.size_forward_set() > 0);
-     ok &= (f.size_forward_bool() == 0);
-
-
-     // sparsity pattern for F'(x)^T
-     bool transpose = true;
-     Vector st(n);
-     st = f.ForSparseJac(n, r, transpose);
-
-     // Y[0] does     depend on X[0]
-     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 );
-     // Y[1] does     depend on X[0]
-     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 );
-     // Y[2] does not depend on X[0]
-     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 );
-
-     // check that values are stored
-     ok &= (f.size_forward_set() > 0);
-     ok &= (f.size_forward_bool() == 0);
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool ForSparseJac(void)
-{     bool ok = true;
-     // Run with Vector equal to four different cases
-     // all of which are Simple Vectors with elements of type bool.
-     ok &= BoolCases< CppAD::vectorBool     >();
-     ok &= BoolCases< CppAD::vector  <bool> >();
-     ok &= BoolCases< std::vector    <bool> >();
-     ok &= BoolCases< std::valarray  <bool> >();
-
-     // Run with Vector equal to two different cases both of which are
-     // Simple Vectors with elements of type std::set<size_t>
-     typedef std::set<size_t> set;
-     ok &= SetCases< CppAD::vector  <set> >();
-     // ok &= SetCases< std::vector    <set> >();
-
-     // Do not use valarray because its element access in the const case
-     // returns a copy instead of a reference
-     // ok &= SetCases< std::valarray  <set> >();
-
-     return ok;
-}
-
-
-
Input File: example/sparse/for_sparse_jac.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_for_sparse_jac.cpp_xml.js cppad-2019.02.00.0/doc/_for_sparse_jac.cpp_xml.js --- cppad-2018.00.00.0/doc/_for_sparse_jac.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_for_sparse_jac.cpp_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', -'adfun.xml', -'sparsity_pattern.xml', -'forsparsejac.xml', -'for_sparse_jac.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down1 = [ -'for_sparse_jac.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-2018.00.00.0/doc/forsparsejac.xml cppad-2019.02.00.0/doc/forsparsejac.xml --- cppad-2018.00.00.0/doc/forsparsejac.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/forsparsejac.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,719 +0,0 @@ - - - -Jacobian Sparsity Pattern: Forward Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Jacobian Sparsity Pattern: Forward Mode
-
-Syntax - -
- -s = f.ForSparseJac(qr)
-
- -s = f.ForSparseJac(qrtransposedependency) - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -For a fixed - -n -× -q - - - matrix - -R - - -, -the Jacobian of - -F -[ -x -+ -R -* -u -] - - - -with respect to - -u - - - at - -u -= -0 - - - is - - -S -( -x -) -= -F -( -1 -) - - -( -x -) -* -R - - -Given a -sparsity pattern - -for - -R - - -, -ForSparseJac returns a sparsity pattern for the - -S -( -x -) - - -. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const. -After a call to ForSparseJac, the sparsity pattern -for each of the variables in the operation sequence -is held in -f - (for possible later use by RevSparseHes -). -These sparsity patterns are stored with elements of type bool -or elements of type std::set<size_t> -(see VectorSet - below). - -
-
-size_forward_bool -
-After ForSparseJac, if -k - is a size_t object, - -
-     
k = f.size_forward_bool()
-
-sets -k - to the amount of memory (in unsigned character units) -used to store the sparsity pattern with elements of type bool -in the function object -f -. -If the sparsity patterns for the previous ForSparseJac used -elements of type bool, -the return value for size_forward_bool will be non-zero. -Otherwise, its return value will be zero. -This sparsity pattern is stored for use by RevSparseHes - and -when it is not longer needed, it can be deleted -(and the corresponding memory freed) using - -
-     
f.size_forward_bool(0)
-
-After this call, -f.size_forward_bool() - will return zero. - -
-
-size_forward_set -
-After ForSparseJac, if -k - is a size_t object, - -
-     
k = f.size_forward_set()
-
-sets -k - to the amount of memory (in unsigned character units) -used to store the -vector of sets - -sparsity patterns. -If the sparsity patterns for this operation use elements of type bool, -the return value for size_forward_set will be zero. -Otherwise, its return value will be non-zero. -This sparsity pattern is stored for use by RevSparseHes - and -when it is not longer needed, it can be deleted -(and the corresponding memory freed) using - -
-     
f.size_forward_set(0)
-
-After this call, -f.size_forward_set() - will return zero. - -
-
-x -
-If the operation sequence in -f - is -independent - of -the independent variables in - -x - -B -n - - - -, -the sparsity pattern is valid for all values of -(even if it has CondExp - or VecAD - operations). - -
-
-q -
-The argument -q - has prototype - -
-     size_t 
q
-
-It specifies the number of columns in - - -R - -B -n -× -q - - - - - and the Jacobian - - -S -( -x -) - -B -m -× -q - - - - -. - -
-
-transpose -
-The argument -transpose - has prototype - -
-     bool 
transpose
-
-The default value false is used when -transpose - is not present. - -
-
-dependency -
-The argument -dependency - has prototype - -
-     bool 
dependency
-
-If -dependency - is true, -the dependency pattern - -(instead of sparsity pattern) is computed. - -
-
-r -
-The argument -r - has prototype - -
-     const 
VectorSetr
-
-see VectorSet - below. - -
-
-transpose false -
-If -r - has elements of type bool, -its size is - -n -* -q - - -. -If it has elements of type std::set<size_t>, -its size is - -n - - - and all the set elements must be between -zero and -q-1 - inclusive. -It specifies a -sparsity pattern - -for the matrix - -R - -B -n -× -q - - - - -. - -
-
-transpose true -
-If -r - has elements of type bool, -its size is - -q -* -n - - -. -If it has elements of type std::set<size_t>, -its size is - -q - - - and all the set elements must be between -zero and -n-1 - inclusive. -It specifies a -sparsity pattern - -for the matrix - -R -T - - - -B -q -× -n - - - - -. - -
-
-s -
-The return value -s - has prototype - -
-     
VectorSet s
-
-see VectorSet - below. - -
-
-transpose false -
-If -s - has elements of type bool, -its size is - -m -* -q - - -. -If it has elements of type std::set<size_t>, -its size is - -m - - - and all its set elements are between -zero and -q-1 - inclusive. -It specifies a -sparsity pattern - -for the matrix - -S -( -x -) - -B -m -× -q - - - - -. - -
-
-transpose true -
-If -s - has elements of type bool, -its size is - -q -* -m - - -. -If it has elements of type std::set<size_t>, -its size is - -q - - - and all its set elements are between -zero and -m-1 - inclusive. -It specifies a -sparsity pattern - -for the matrix - -S -( -x -) -T - - - -B -q -× -m - - - - -. - -
-
-VectorSet -
-The type -VectorSet - must be a SimpleVector - class with -elements of type - -bool or std::set<size_t>; -see sparsity pattern - for a discussion -of the difference. - -
-
-Entire Sparsity Pattern -
-Suppose that - -q -= -n - - - and - - -R - - - is the - -n -× -n - - - identity matrix. -In this case, -the corresponding value for -s - is a -sparsity pattern for the Jacobian - -S -( -x -) -= -F -( -1 -) - - -( -x -) - - -. - -
-
-Example - -
-The file -for_sparse_jac.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. -The file -sparsity_sub.cpp - -contains an example and test of using ForSparseJac -to compute the sparsity pattern for a subset of the Jacobian. - - -
Input File: cppad/core/for_sparse_jac.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_forsparsejac_xml.js cppad-2019.02.00.0/doc/_forsparsejac_xml.js --- cppad-2018.00.00.0/doc/_forsparsejac_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forsparsejac_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparsity_pattern.xml', -'forsparsejac.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down0 = [ -'for_sparse_jac.cpp.xml' -]; -var list_current0 = [ -'forsparsejac.xml#Syntax', -'forsparsejac.xml#Purpose', -'forsparsejac.xml#f', -'forsparsejac.xml#f.size_forward_bool', -'forsparsejac.xml#f.size_forward_set', -'forsparsejac.xml#x', -'forsparsejac.xml#q', -'forsparsejac.xml#transpose', -'forsparsejac.xml#dependency', -'forsparsejac.xml#r', -'forsparsejac.xml#r.transpose false', -'forsparsejac.xml#r.transpose true', -'forsparsejac.xml#s', -'forsparsejac.xml#s.transpose false', -'forsparsejac.xml#s.transpose true', -'forsparsejac.xml#VectorSet', -'forsparsejac.xml#Entire Sparsity Pattern', -'forsparsejac.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-2018.00.00.0/doc/for_two.cpp.xml cppad-2019.02.00.0/doc/for_two.cpp.xml --- cppad-2018.00.00.0/doc/for_two.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/for_two.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,177 +0,0 @@ - - - -Subset of Second Order Partials: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -for_two.cppHeadings

- - - -
Subset of Second Order Partials: Example and Test
-
# include <cppad/cppad.hpp>
-namespace { // -----------------------------------------------------
-// define the template function in empty namespace
-// bool ForTwoCases<VectorBase, VectorSize_t>(void)
-template <class VectorBase, class VectorSize_t>
-bool ForTwoCases()
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     using CppAD::exp;
-     using CppAD::sin;
-     using CppAD::cos;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>)  X(n);
-     X[0] = 1.;
-     X[1] = 2.;
-
-     // declare independent variables and starting recording
-     CppAD::Independent(X);
-
-     // a calculation between the domain and range values
-     AD<double> Square = X[0] * X[0];
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>)  Y(m);
-     Y[0] = Square * exp( X[1] );
-     Y[1] = Square * sin( X[1] );
-     Y[2] = Square * cos( X[1] );
-
-     // create f: X -> Y and stop tape recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // new value for the independent variable vector
-     VectorBase x(n);
-     x[0] = 2.;
-     x[1] = 1.;
-
-     // set j and k to compute specific second partials of y
-     size_t p = 2;
-     VectorSize_t j(p);
-     VectorSize_t k(p);
-     j[0] = 0; k[0] = 0; // for second partial w.r.t. x[0] and x[0]
-     j[1] = 0; k[1] = 1; // for second partial w.r.t x[0] and x[1]
-
-     // 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]) ]
-     */
-     // second partial of y w.r.t x[0] and x[1]
-     ok &=  NearEqual( 2.*exp(x[1]), ddy[0*p+0], eps99, eps99);
-     ok &=  NearEqual( 2.*sin(x[1]), ddy[1*p+0], eps99, eps99);
-     ok &=  NearEqual( 2.*cos(x[1]), ddy[2*p+0], eps99, eps99);
-
-     // second partial of F w.r.t x[0] and x[1]
-     ok &=  NearEqual( 2.*x[0]*exp(x[1]), ddy[0*p+1], eps99, eps99);
-     ok &=  NearEqual( 2.*x[0]*cos(x[1]), ddy[1*p+1], eps99, eps99);
-     ok &=  NearEqual(-2.*x[0]*sin(x[1]), ddy[2*p+1], eps99, eps99);
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool ForTwo(void)
-{     bool ok = true;
-        // Run with VectorBase equal to three different cases
-        // all of which are Simple Vectors with elements of type double.
-     ok &= ForTwoCases< CppAD::vector <double>, std::vector<size_t> >();
-     ok &= ForTwoCases< std::vector   <double>, std::vector<size_t> >();
-     ok &= ForTwoCases< std::valarray <double>, std::vector<size_t> >();
-
-        // Run with VectorSize_t equal to two other cases
-        // which are Simple Vectors with elements of type size_t.
-     ok &= ForTwoCases< std::vector <double>, CppAD::vector<size_t> >();
-     ok &= ForTwoCases< std::vector <double>, std::valarray<size_t> >();
-
-     return ok;
-}
-
-
Input File: example/general/for_two.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_for_two.cpp_xml.js cppad-2019.02.00.0/doc/_for_two.cpp_xml.js --- cppad-2018.00.00.0/doc/_for_two.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_for_two.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'fortwo.xml', -'for_two.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down1 = [ -'for_two.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-2018.00.00.0/doc/fortwo.xml cppad-2019.02.00.0/doc/fortwo.xml --- cppad-2018.00.00.0/doc/fortwo.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/fortwo.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,510 +0,0 @@ - - - -Forward Mode Second Partial Derivative Driver - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Forward Mode Second Partial Derivative Driver
-
-Syntax - -
- -ddy = f.ForTwo(xjk) - - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -The syntax above sets - - -ddy -[ -i -* -p -+ - -] -= - -2 - -F -i - - - -x -j -[ - -] - - - -x -k -[ - -] - - - - -( -x -) - - -for - -i -= -0 -, - -, -m --1 - - - -and - - -= -0 -, - -, -p - - -, -where - -p - - - is the size of the vectors -j - and -k -. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const -(see ForTwo Uses Forward - below). - -
-
-x -
-The argument -x - has prototype - -
-     const 
VectorBase &x
-
-(see VectorBase - below) -and its size -must be equal to -n -, the dimension of the -domain - space for -f -. -It specifies -that point at which to evaluate the partial derivatives listed above. - -
-
-j -
-The argument -j - has prototype - -
-     const 
VectorSize_t &j
-
-(see VectorSize_t - below) -We use -p - to denote the size of the vector -j -. -All of the indices in -j - -must be less than -n -; i.e., -for - - -= -0 -, - -, -p --1 - - -, - -j -[ - -] -< -n - - -. - -
-
-k -
-The argument -k - has prototype - -
-     const 
VectorSize_t &k
-
-(see VectorSize_t - below) -and its size must be equal to -p -, -the size of the vector -j -. -All of the indices in -k - -must be less than -n -; i.e., -for - - -= -0 -, - -, -p --1 - - -, - -k -[ - -] -< -n - - -. - -
-
-ddy -
-The result -ddy - has prototype - -
-     
VectorBase ddy
-
-(see VectorBase - below) -and its size is - -m -* -p - - -. -It contains the requested partial derivatives; to be specific, -for - -i -= -0 -, - -, -m -- -1 - - - -and - - -= -0 -, - -, -p -- -1 - - - - - -ddy -[ -i -* -p -+ - -] -= - -2 - -F -i - - - -x -j -[ - -] - - - -x -k -[ - -] - - - - -( -x -) - - -
-VectorBase -
-The type -VectorBase - must be a SimpleVector - class with -elements of type Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-VectorSize_t -
-The type -VectorSize_t - must be a SimpleVector - class with -elements of type size_t -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-ForTwo Uses Forward -
-After each call to Forward -, -the object -f - contains the corresponding -Taylor coefficients -. -After a call to ForTwo, -the zero order Taylor coefficients correspond to - -f.Forward(0, x) - -and the other coefficients are unspecified. - -
-
-Examples - -
-The routine -ForTwo - is both an example and test. -It returns true, if it succeeds and false otherwise. - - -
Input File: cppad/core/for_two.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_fortwo_xml.js cppad-2019.02.00.0/doc/_fortwo_xml.js --- cppad-2018.00.00.0/doc/_fortwo_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fortwo_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'fortwo.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down0 = [ -'for_two.cpp.xml' -]; -var list_current0 = [ -'fortwo.xml#Syntax', -'fortwo.xml#Purpose', -'fortwo.xml#f', -'fortwo.xml#x', -'fortwo.xml#j', -'fortwo.xml#k', -'fortwo.xml#ddy', -'fortwo.xml#VectorBase', -'fortwo.xml#VectorSize_t', -'fortwo.xml#ForTwo Uses Forward', -'fortwo.xml#Examples' -]; -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-2018.00.00.0/doc/forward.cpp.xml cppad-2019.02.00.0/doc/forward.cpp.xml --- cppad-2018.00.00.0/doc/forward.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/forward.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ - - - -Forward Mode: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -forward.cppHeadings

- - - -
Forward Mode: Example and Test
-
# include <limits>
-# include <cppad/cppad.hpp>
-namespace { // --------------------------------------------------------
-// define the template function ForwardCases<Vector> in empty namespace
-template <class Vector>
-bool ForwardCases(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-
-     // declare independent variables and starting recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = ax[0] * ax[0] * ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // initially, the variable values during taping are stored in f
-     ok &= f.size_order() == 1;
-
-     // zero order forward mode using notation in forward_zero
-     // use the template parameter Vector for the vector type
-     Vector x0(n), y0(m);
-     x0[0] = 3.;
-     x0[1] = 4.;
-     y0    = f.Forward(0, x0);
-     ok  &= NearEqual(y0[0] , x0[0]*x0[0]*x0[1], eps, eps);
-     ok  &= f.size_order() == 1;
-
-     // first order forward mode using notation in forward_one
-     // X(t)           = x0 + x1 * t
-     // Y(t) = F[X(t)] = y0 + y1 * t + o(t)
-     Vector x1(n), y1(m);
-     x1[0] = 1.;
-     x1[1] = 0.;
-     y1    = f.Forward(1, x1); // partial F w.r.t. x_0
-     ok   &= NearEqual(y1[0] , 2.*x0[0]*x0[1], eps, eps);
-     ok   &= f.size_order() == 2;
-
-     // second order forward mode using notation in forward_order
-     // X(t) =           x0 + x1 * t + x2 * t^2
-     // Y(t) = F[X(t)] = y0 + y1 * t + y2 * t^2 + o(t^3)
-     Vector x2(n), y2(m);
-     x2[0]      = 0.;
-     x2[1]      = 0.;
-     y2         = f.Forward(2, x2);
-     double F_00 = 2. * y2[0]; // second partial F w.r.t. x_0, x_0
-     ok         &= NearEqual(F_00, 2.*x0[1], eps, eps);
-     ok         &= f.size_order() == 3;
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool Forward(void)
-{     bool ok = true;
-     // Run with Vector equal to three different cases
-     // all of which are Simple Vectors with elements of type double.
-     ok &= ForwardCases< CppAD::vector  <double> >();
-     ok &= ForwardCases< std::vector    <double> >();
-     ok &= ForwardCases< std::valarray  <double> >();
-     return ok;
-}
-
-
Input File: example/general/forward.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_forward.cpp_xml.js cppad-2019.02.00.0/doc/_forward.cpp_xml.js --- cppad-2018.00.00.0/doc/_forward.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forward.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'forward_order.xml', -'forward.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_down1 = [ -'forward.cpp.xml', -'forward_order.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-2018.00.00.0/doc/forward_dir.cpp.xml cppad-2019.02.00.0/doc/forward_dir.cpp.xml --- cppad-2018.00.00.0/doc/forward_dir.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/forward_dir.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,174 +0,0 @@ - - - -Forward Mode: Example and Test of Multiple Directions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -forward_dir.cppHeadings

- - - -
Forward Mode: Example and Test of Multiple Directions
-
# include <limits>
-# include <cppad/cppad.hpp>
-bool forward_dir(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * std::numeric_limits<double>::epsilon();
-     size_t j;
-
-     // domain space vector
-     size_t n = 3;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-     ax[2] = 2.;
-
-     // declare independent variables and starting recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = ax[0] * ax[1] * ax[2];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // initially, the variable values during taping are stored in f
-     ok &= f.size_order() == 1;
-
-     // zero order Taylor coefficients
-     CPPAD_TESTVECTOR(double) x0(n), y0;
-     for(j = 0; j < n; j++)
-          x0[j] = double(j+1);
-     y0          = f.Forward(0, x0);
-     ok         &= size_t( y0.size() ) == m;
-     double y_0  = 1.*2.*3.;
-     ok         &= NearEqual(y0[0], y_0, eps, eps);
-
-     // 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 + 1 + ell);
-     }
-     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 ] = 0.0;
-     }
-     y2  = f.Forward(2, r, x2);
-     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)
-     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.;
-     //
-     ok  &= NearEqual(y1[0] , y_1_0, eps, eps);
-     ok  &= NearEqual(y1[1] , y_1_1, eps, eps);
-     ok  &= NearEqual(y2[0] , y_2_0, eps, eps);
-     ok  &= NearEqual(y2[1] , y_2_1, eps, eps);
-     //
-     // check number of orders
-     ok   &= f.size_order() == 3;
-     //
-     // check number of directions
-     ok   &= f.size_direction() == 2;
-     //
-     return ok;
-}
-
-
Input File: example/general/forward_dir.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_forward_dir.cpp_xml.js cppad-2019.02.00.0/doc/_forward_dir.cpp_xml.js --- cppad-2018.00.00.0/doc/_forward_dir.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forward_dir.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'forward_dir.xml', -'forward_dir.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_down1 = [ -'forward_dir.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-2018.00.00.0/doc/forward_dir.xml cppad-2019.02.00.0/doc/forward_dir.xml --- cppad-2018.00.00.0/doc/forward_dir.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/forward_dir.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,996 +0,0 @@ - - - -Multiple Directions Forward Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Multiple Directions Forward Mode
-
-Syntax - -
- -yq = f.Forward(qrxq)
-
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -Given a function - -X -: -B - -B -n - - - -, -defined by its -Taylor coefficients -, -forward mode computes the Taylor coefficients for the function - - -Y -( -t -) -= -F -[ -X -( -t -) -] - - -This version of forward mode computes multiple directions as the same -time (reducing the number of passes through the tape). This requires more -memory, but might be faster in some cases. - -
-
-Reverse Mode -
-Reverse mode for multiple directions has not yet been implemented. -If you have speed tests that indicate that multiple direction forward -mode is faster, and you want to try multiple direction reverse mode, -contact the CppAD project manager. - -
-
-Notation - - -
-
-n -
-We use -n - to denote the dimension of the -domain - space for -f -. - -
-
-m -
-We use -m - to denote the dimension of the -range - space for -f -. - -
-
-f -
-The ADFun - object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const. -After this call we will have - -
-     
f.size_order()     == q + 1
-     
f.size_direction() == r
-
-
-q -
-This argument has prototype - -
-     size_t 
q
-
-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 -f - so use forward_zero - -to compute the zero order coefficients. - -
-
-r -
-This argument has prototype - -
-     size_t 
r
-
-It specifies the number of directions that are computed together. -If ( -r == 1 -), you are only using one direction and -forward_order - is simpler, and should be faster, -than this more general case. - -
-
-xq -
-The argument -xq - has prototype - -
-     const 
Vectorxq
-
-and its size must be -n*r - -(see Vector - below). -For - - -= -0 -, - -, -r --1 - - -, - - -j -= -0 -, - -, -n --1 - - -, -the j-th component of the q-th order Taylor coefficient -for - -X - - -( -t -) - - - is defined by -
-     
- -x -j -( -q -) -, - - - -= - - - -xqr * j + ell ] - - -
-
-Zero Order -
-For - -j -= -0 -, - -, -n --1 - - -, -the j-th component of the zero order Taylor coefficient -for - -X - - -( -t -) - - - is defined by -
-     
- -x -j -( -0 -) - - -= - - - -xkj ] - -where -xk - corresponds to the previous call - -
-     
f.Forward(kxk)
-
-with -k = 0 -. - -
-
-Non-Zero Lower Orders -
-For - - -= -0 -, - -, -r --1 - - -, - - -j -= -0 -, - -, -n --1 - - -, - - -k -= -1 -, - -, -q --1 - - -, -the j-th component of the k-th order Taylor coefficient -for - -X - - -( -t -) - - - is defined by -
-     
- -x -j -( -k -) -, - - - -= - - - -xkr * j + ell ] - -where -xk - corresponds to the previous call - -
-     
f.Forward(krxk)
-
-Note that -r - must have the same value in this previous call. - -
-
-X(t) -
-For - - -= -0 -, - -, -r --1 - - -, the function - - -X - - -: -B - -B -n - - - - is defined using -the Taylor coefficients - -x -( -k -) -, - - - - -B -n - - - -: - - -X - - -( -t -) -= -x -( -0 -) - - -+ -x -( -1 -) -, - - - -* -t -1 - -+ - -+ -x -( -q -) -, - - - -t -q - - - -Note that the k-th derivative of - -X - - -( -t -) - - - is related to -its Taylor coefficients by - - - -x -( -0 -) - - - -= - -X - - -( -0 -) - -x -( -k -) -, - - - - -= - -1 - -k -! - - -X - -( -k -) - - -( -0 -) - - - -for - -k -= -1 -, - -, -q - - -. - -
-
-Y(t) -
-For - - -= -0 -, - -, -r --1 - - -, the function - - -Y - - -: -B - -B -m - - - - is defined by - - -Y - - -( -t -) -= -F -[ -X - - -( -t -) -] - - -. -We use - -y -( -0 -) - - - - - for the zero order coefficient -and - -y -( -k -) -, - - - - -B -m - - - - to denote the -hight order coefficients; i.e., - - -Y - - -( -t -) -= -y -( -0 -) - - -+ -y -( -1 -) -, - - - -* -t -1 - -+ - -+ -y -( -q -) -, - - - -* -t -q - -+ -o -( -t -q - -) - - -where - -o -( -t -q - -) -* -t -- -q - - - -0 - - - as - -t - -0 - - -. -Note that the k-th derivative of - -Y - - -( -t -) - - - is related to -its Taylor coefficients by - - - -y -( -0 -) - - - -= - -Y - - -( -0 -) - -y -( -k -) -, - - - - -= - -1 - -k -! - - -Y - -( -k -) - - -( -0 -) - - - -for - -k -= -1 -, - -, -q - - -. - -
-
-yq -
-The argument -yq - has prototype - -
-     
Vector yq
-
-and its size is -m*r - -(see Vector - below). -For - - -= -0 -, - -, -r --1 - - -, - - -i -= -0 -, - -, -m --1 - - -, -the i-th component of the q-th order Taylor coefficient -for - -Y - - -( -t -) - - - is given by -
-     
- -y -i -( -q -) -, - - - -= - - - -yqr * i + ell ] - - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - - -
-
-Example -
-The file -forward_dir.cpp - -contains an example and test using one order (multiple orders). -They return true if they succeed and false otherwise. - - -
Input File: omh/forward/forward_dir.omh - - - diff -Nru cppad-2018.00.00.0/doc/_forward_dir_xml.js cppad-2019.02.00.0/doc/_forward_dir_xml.js --- cppad-2018.00.00.0/doc/_forward_dir_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forward_dir_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'forward_dir.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_down0 = [ -'forward_dir.cpp.xml' -]; -var list_current0 = [ -'forward_dir.xml#Syntax', -'forward_dir.xml#Purpose', -'forward_dir.xml#Reverse Mode', -'forward_dir.xml#Notation', -'forward_dir.xml#Notation.n', -'forward_dir.xml#Notation.m', -'forward_dir.xml#f', -'forward_dir.xml#q', -'forward_dir.xml#r', -'forward_dir.xml#xq', -'forward_dir.xml#Zero Order', -'forward_dir.xml#Non-Zero Lower Orders', -'forward_dir.xml#X(t)', -'forward_dir.xml#Y(t)', -'forward_dir.xml#yq', -'forward_dir.xml#Vector', -'forward_dir.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-2018.00.00.0/doc/forward_one.xml cppad-2019.02.00.0/doc/forward_one.xml --- cppad-2018.00.00.0/doc/forward_one.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/forward_one.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,605 +0,0 @@ - - - -First Order Forward Mode: Derivative Values - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -forward_one - -

- - - -
First Order Forward Mode: Derivative Values
-
-Syntax - -
- -y1 = f.Forward(1, x1) - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -The result of the syntax above is - - -y -1 -= -F -( -1 -) - - -( -x -0 -) -* -x -1 - - -where - -F -( -1 -) - - -( -x -0 -) - - - is the Jacobian of - -F - - - -evaluated at -x0 -. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const. -Before this call to Forward, the value returned by - -
-     
f.size_order()
-
-must be greater than or equal one. -After this call it will be will be two (see size_order -). - -
-
-x0 -
-The vector -x0 - in the formula - - -y -1 -= -F -( -1 -) - - -( -x -0 -) -* -x -1 - - -corresponds to the previous call to forward_zero - -using this ADFun object -f -; i.e., - -
-     
f.Forward(0, x0)
-
-If there is no previous call with the first argument zero, -the value of the independent - variables -during the recording of the AD sequence of operations is used -for -x0 -. - -
-
-x1 -
-The argument -x1 - has prototype - -
-     const 
Vectorx1
-
-(see Vector - below) -and its size must be equal to -n -, the dimension of the -domain - space for -f -. - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Example -
-The file -forward.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - -
-
-Special Case -
-This is special case of forward_order - where - - - -Y -( -t -) - -= - -F -[ -X -( -t -) -] - -X -( -t -) - -= - -x -( -0 -) - - -t -0 - -+ -x -( -1 -) - - -* -t -1 - -+ - -, -+ -x -( -q -) - - -* -t -q - -+ -o -( -t -q - -) - -Y -( -t -) - -= - -y -( -0 -) - - -t -0 - -+ -y -( -1 -) - - -* -t -1 - -+ - -, -+ -y -( -q -) - - -* -t -q - -+ -o -( -t -q - -) - - - -and - -o -( -t -q - -) -* -t -- -q - - - -0 - - - as - -t - -0 - - -. -For this special case, - -q -= -1 - - -, - - -x -( -0 -) - - - - - -x0 -, - - -x -( -1 -) - - - - - -x1 -, - - -X -( -t -) -= -x -( -0 -) - - -+ -x -( -1 -) - - -t - - -, and - - -y -( -0 -) - - -+ -y -( -1 -) - - -t -= -F -[ -x -( -0 -) - - -+ -x -( -1 -) - - -t -] -+ -o -( -t -) - - -Taking the derivative with respect to - -t - - -, at - -t -= -0 - - -, -we obtain - - -y -( -1 -) - - -= -F -( -1 -) - - -[ -x -( -0 -) - - -] -x -( -1 -) - - - - -which agrees with the specifications for - -y1 - in the purpose - above. - - -
Input File: omh/forward/forward_one.omh - - - diff -Nru cppad-2018.00.00.0/doc/_forward_one_xml.js cppad-2019.02.00.0/doc/_forward_one_xml.js --- cppad-2018.00.00.0/doc/_forward_one_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forward_one_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'forward_one.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_current0 = [ -'forward_one.xml#Syntax', -'forward_one.xml#Purpose', -'forward_one.xml#f', -'forward_one.xml#x0', -'forward_one.xml#x1', -'forward_one.xml#Vector', -'forward_one.xml#Example', -'forward_one.xml#Special Case' -]; -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-2018.00.00.0/doc/forward_order.cpp.xml cppad-2019.02.00.0/doc/forward_order.cpp.xml --- cppad-2018.00.00.0/doc/forward_order.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/forward_order.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ - - - -Forward Mode: Example and Test of Multiple Orders - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -forward_order.cppHeadings

-
Forward Mode: Example and Test of Multiple Orders
-
# include <limits>
-# include <cppad/cppad.hpp>
-bool forward_order(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-
-     // declare independent variables and starting recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = ax[0] * ax[0] * ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // initially, the variable values during taping are stored in f
-     ok &= f.size_order() == 1;
-
-     // Compute three forward orders at one
-     size_t q = 2, q1 = q+1;
-     CPPAD_TESTVECTOR(double) xq(n*q1), yq;
-     xq[q1*0 + 0] = 3.;    xq[q1*1 + 0] = 4.; // x^0 (order zero)
-     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 ]
-     yq  = f.Forward(q, xq);
-     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)
-     //
-     // check y^0 (order zero)
-     CPPAD_TESTVECTOR(double) x0(n);
-     x0[0] = xq[q1*0 + 0];
-     x0[1] = xq[q1*1 + 0];
-     ok  &= NearEqual(yq[q1*0 + 0] , x0[0]*x0[0]*x0[1], eps, eps);
-     //
-     // check y^1 (order one)
-     ok  &= NearEqual(yq[q1*0 + 1] , 2.*x0[0]*x0[1], eps, eps);
-     //
-     // check y^2 (order two)
-     double F_00 = 2. * yq[q1*0 + 2]; // second partial F w.r.t. x_0, x_0
-     ok   &= NearEqual(F_00, 2.*x0[1], eps, eps);
-
-     // check number of orders per variable
-     ok   &= f.size_order() == 3;
-
-     return ok;
-}
-
-
Input File: example/general/forward_order.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_forward_order.cpp_xml.js cppad-2019.02.00.0/doc/_forward_order.cpp_xml.js --- cppad-2018.00.00.0/doc/_forward_order.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forward_order.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'forward_order.xml', -'forward_order.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_down1 = [ -'forward.cpp.xml', -'forward_order.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-2018.00.00.0/doc/forward_order.xml cppad-2019.02.00.0/doc/forward_order.xml --- cppad-2018.00.00.0/doc/forward_order.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/forward_order.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1011 +0,0 @@ - - - -Multiple Order Forward Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Multiple Order Forward Mode
-
-Syntax - -
- -yq = f.Forward(qxq )
-
- -yq = f.Forward(qxqs)
-
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -Given a function - -X -: -B - -B -n - - - -, -defined by its -Taylor coefficients -, -forward mode computes the Taylor coefficients for the function - - -Y -( -t -) -= -F -[ -X -( -t -) -] - - -
-Function Values -
-If you are using forward mode to compute values for - -F -( -x -) - - -, -forward_zero - is simpler to understand -than this explanation of the general case. - -
-
-Derivative Values -
-If you are using forward mode to compute values for - -F -( -1 -) - - -( -x -) -* -dx - - -, -forward_one - is simpler to understand -than this explanation of the general case. - -
-
-Notation - - -
-
-n -
-We use -n - to denote the dimension of the -domain - space for -f -. - -
-
-m -
-We use -m - to denote the dimension of the -range - space for -f -. - - -
-
-f -
-The ADFun - object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const. -After this call we will have - -
-     
f.size_order()     == q + 1
-     
f.size_direction() == 1
-
-
-One Order -
-If -xq.size() == n -, -then we are only computing one order. -In this case, before this call we must have - -
-     
f.size_order()     >= q
-     
f.size_direction() == 1
-
-
-q -
-The argument -q - has prototype - -
-     size_t 
q
-
-and specifies the highest order of the Taylor coefficients to be calculated. - -
-
-xq -
-The argument -xq - has prototype - -
-     const 
Vectorxq
-
-(see Vector - below). -As above, we use -n - to denote the dimension of the -domain - space for -f -. -The size of -xq - must be either -n - or - -n*(q+1) -. -After this call we will have - -
-     
f.size_order()     == q + 1
-
-
-One Order -
-If -xq.size() == n -, -the q-th order Taylor coefficient for - -X -( -t -) - - - -is defined by -
-     
- -x -( -q -) - - -= - - - -xq -. -For - -k -= -0 -, - -, -q --1 - - -, -the Taylor coefficient - -x -( -k -) - - - - - -is defined by -xk - in the previous call to - -
-     
f.Forward(kxk)
-
-
-Multiple Orders -
-If -xq.size() == n*(q+1) -, -For - -k -= -0 -, - -, -q - - -, - - -j -= -0 -, - -, -n --1 - - -, -the j-th component of the k-th order Taylor coefficient -for - -X -( -t -) - - - is defined by -
-     
- -x -j -( -k -) - - -= - - - -xq[ (q+1) * j + k ] - - -
-
-Restrictions -
-Note if -f - uses old_atomic - functions, -the size of -xq - must be -n -. - -
-
-s -
-If the argument -s - is not present, std::cout -is used in its place. -Otherwise, this argument has prototype - -
-     std::ostream& 
s
-
-If order zero is begin calculated, - -s - specifies where the output corresponding to PrintFor - -will be written. -If order zero is not being calculated, - -s - is not used - -
-
-X(t) -
-The function - - -X -: -B - -B -n - - - - is defined using -the Taylor coefficients - -x -( -k -) - - - -B -n - - - -: - - -X -( -t -) -= -x -( -0 -) - - -* -t -0 - -+ -x -( -1 -) - - -* -t -1 - -+ - -+ -x -( -q -) - - -* -t -q - - - -Note that for - -k -= -0 -, - -, -q - - -, -the k-th derivative of - -X -( -t -) - - - is related to the -Taylor coefficients by the equation - - -x -( -k -) - - -= -1 - -k -! - - -X -( -k -) - - -( -0 -) - - -
-Y(t) -
-The function - - -Y -: -B - -B -m - - - - is defined by - - -Y -( -t -) -= -F -[ -X -( -t -) -] - - -. -We use - -y -( -k -) - - - -B -m - - - - -to denote the k-th order Taylor coefficient of - -Y -( -t -) - - -; i.e., - - -Y -( -t -) -= -y -( -0 -) - - -* -t -0 - -+ -y -( -1 -) - - -* -t -1 - -+ - -+ -y -( -q -) - - -* -t -q - -+ -o -( -t -q - -) - - -where - -o -( -t -q - -) -* -t -- -q - - - -0 - - - as - -t - -0 - - -. -Note that - -y -( -k -) - - - - - is related to -the k-th derivative of - -Y -( -t -) - - - by the equation - - -y -( -k -) - - -= -1 - -k -! - - -Y -( -k -) - - -( -0 -) - - -
-yq -
-The return value -yq - has prototype - -
-     
Vector yq
-
-(see Vector - below). - -
-
-One Order -
-If -xq.size() == n -, -the vector -yq - has size -m -. -The q-th order Taylor coefficient for - -Y -( -t -) - - - -is returned as - -
-     
yq
- - -= -y -( -q -) - - - - -. - -
-
-Multiple Orders -
-If -xq.size() == n*(q+1) -, -the vector -yq - has size -m*(q+1) -. -For - -k -= -0 -, - -, -q - - -, -for - -i -= -0 -, - -, -m --1 - - -, -the i-th component of the k-th order Taylor coefficient -for - -Y -( -t -) - - - is returned as - -
-     
yq[ (q+1) * i + k ]
- - -= -y -i -( -k -) - - - - - - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Zero Order -
-The case where - - -q -= -0 - - - and -xq.size() == n -, -corresponds to the zero order -special case -. - -
-
-First Order -
-The case where - - -q -= -1 - - - and -xq.size() == n -, -corresponds to the first order -special case -. - -
-
-Second Order -
-The case where - - -q -= -2 - - - and -xq.size() == n -, -corresponds to the second order -special case -. - - -
-
-Example -
-The file -forward.cpp - ( forward_order.cpp - ) -contains an example and test using one order (multiple orders). -They return true if they succeed and false otherwise. - - -
Input File: omh/forward/forward_order.omh - - - diff -Nru cppad-2018.00.00.0/doc/_forward_order_xml.js cppad-2019.02.00.0/doc/_forward_order_xml.js --- cppad-2018.00.00.0/doc/_forward_order_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forward_order_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'forward_order.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_down0 = [ -'forward.cpp.xml', -'forward_order.cpp.xml' -]; -var list_current0 = [ -'forward_order.xml#Syntax', -'forward_order.xml#Purpose', -'forward_order.xml#Purpose.Function Values', -'forward_order.xml#Purpose.Derivative Values', -'forward_order.xml#Notation', -'forward_order.xml#Notation.n', -'forward_order.xml#Notation.m', -'forward_order.xml#f', -'forward_order.xml#One Order', -'forward_order.xml#q', -'forward_order.xml#xq', -'forward_order.xml#xq.One Order', -'forward_order.xml#xq.Multiple Orders', -'forward_order.xml#xq.Restrictions', -'forward_order.xml#s', -'forward_order.xml#X(t)', -'forward_order.xml#Y(t)', -'forward_order.xml#yq', -'forward_order.xml#yq.One Order', -'forward_order.xml#yq.Multiple Orders', -'forward_order.xml#Vector', -'forward_order.xml#Zero Order', -'forward_order.xml#First Order', -'forward_order.xml#Second Order', -'forward_order.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-2018.00.00.0/doc/forwardtheory.xml cppad-2019.02.00.0/doc/forwardtheory.xml --- cppad-2018.00.00.0/doc/forwardtheory.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/forwardtheory.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1677 +0,0 @@ - - - -The Theory of Forward Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
The Theory of Forward Mode
-
-Taylor Notation -
-In Taylor notation, each variable corresponds to -a function of a single argument which we denote by -t - -(see Section 10.2 of -Evaluating Derivatives -). -Here and below - - -X -( -t -) - - -, - -Y -( -t -) - - -, and -Z(t) - are scalar valued functions -and the corresponding p-th order Taylor coefficients row vectors are - - -x - - -, - -y - - - and - -z - - -; i.e., - - - -X -( -t -) - -= - -x -( -0 -) - - -+ -x -( -1 -) - - -* -t -+ - -+ -x -( -p -) - - -* -t -p - -+ -o -( -t -p - -) - -Y -( -t -) - -= - -y -( -0 -) - - -+ -y -( -1 -) - - -* -t -+ - -+ -y -( -p -) - - -* -t -p - -+ -o -( -t -p - -) - -Z -( -t -) - -= - -z -( -0 -) - - -+ -z -( -1 -) - - -* -t -+ - -+ -z -( -p -) - - -* -t -p - -+ -o -( -t -p - -) - - - -For the purposes of this section, we are given - -x - - - and - -y - - - -and need to determine - -z - - -. - -
-
-Binary Operators - - -
-
-Addition - - - - -Z -( -t -) - -= - -X -( -t -) -+ -Y -( -t -) - - -j -= -0 - -p - -z -( -j -) - - -* -t -j - - -= - - -j -= -0 - -p - -x -( -j -) - - -* -t -j - -+ - -j -= -0 - -p - -y -( -j -) - - -* -t -j - -+ -o -( -t -p - -) - -z -( -j -) - - - -= - -x -( -j -) - - -+ -y -( -j -) - - - - - -
-Subtraction - - - - -Z -( -t -) - -= - -X -( -t -) -- -Y -( -t -) - - -j -= -0 - -p - -z -( -j -) - - -* -t -j - - -= - - -j -= -0 - -p - -x -( -j -) - - -* -t -j - -- - -j -= -0 - -p - -y -( -j -) - - -* -t -j - -+ -o -( -t -p - -) - -z -( -j -) - - - -= - -x -( -j -) - - -- -y -( -j -) - - - - - -
-Multiplication - - - - -Z -( -t -) - -= - -X -( -t -) -* -Y -( -t -) - - -j -= -0 - -p - -z -( -j -) - - -* -t -j - - -= - -( -j -= -0 - -p - -x -( -j -) - - -* -t -j - -) -* -( -j -= -0 - -p - -y -( -j -) - - -* -t -j - -) -+ -o -( -t -p - -) - -z -( -j -) - - - -= - - -k -= -0 - -j - -x -( -j -- -k -) - - -* -y -( -k -) - - - - - -
-Division - - - - -Z -( -t -) - -= - -X -( -t -) -/ -Y -( -t -) - -x - -= - -z -* -y - - -j -= -0 - -p - -x -( -j -) - - -* -t -j - - -= - -( -j -= -0 - -p - -z -( -j -) - - -* -t -j - -) -* -( -j -= -0 - -p - -y -( -j -) - - -* -t -j - -) -+ -o -( -t -p - -) - -x -( -j -) - - - -= - - -k -= -0 - -j - -z -( -j -- -k -) - - -y -( -k -) - - - -z -( -j -) - - - -= - -1 - -y -( -0 -) - - - - -(x -( -j -) - - -- - -k -= -1 - -j - -z -( -j -- -k -) - - -y -( -k -) - - -) - - - -
-Standard Math Functions -
-Suppose that - -F - - - is a standard math function and - - -Z -( -t -) -= -F -[ -X -( -t -) -] - - -
-Differential Equation -
-All of the standard math functions -satisfy a differential equation of the form - - -B -( -u -) -* -F -( -1 -) - - -( -u -) -- -A -( -u -) -* -F -( -u -) -= -D -( -u -) - - -We use - -a - - -, - -b - - - and - -d - - - to denote the -p-th order Taylor coefficient row vectors for - - -A -[ -X -( -t -) -] - - -, - -B -[ -X -( -t -) -] - - - and - -D -[ -X -( -t -) -] - - - -respectively. -We assume that these coefficients are known functions of - -x - - -, -the p-th order Taylor coefficients for - -X -( -t -) - - -. - -
-
-Taylor Coefficients Recursion Formula -
-Our problem here is to express - -z - - -, -the p-th order Taylor coefficient row vector for - -Z -( -t -) - - -, -in terms of these other known coefficients. -It follows from the formulas above that - - - -Z -( -1 -) - - -( -t -) - -= - -F -( -1 -) - - -[ -X -( -t -) -] -* -X -( -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 -) - - - -where we define - - -E -( -t -) -= -D -[ -X -( -t -) -] -+ -A -[ -X -( -t -) -] -* -Z -( -t -) - - -We can compute the value of - -z -( -0 -) - - - - - using the formula - - -z -( -0 -) - - -= -F -( -x -( -0 -) - - -) - - -Suppose by induction (on - -j - - -) that we are given the -Taylor coefficients of - -E -( -t -) - - - up to order - -j --1 - - -; i.e., - - -e -( -k -) - - - - - for - -k -= -0 -, - -, -j --1 - - - -and the coefficients - - -z -( -k -) - - - - - for - -k -= -0 -, - -, -j - - -. -We can compute - -e -( -j -) - - - - - using the formula - - -e -( -j -) - - -= -d -( -j -) - - -+ - -k -= -0 - -j - -a -( -j -- -k -) - - -* -z -( -k -) - - - - -We need to complete the induction by finding formulas for - -z -( -j -+ -1 -) - - - - -. -It follows for the formula for the -multiplication - -operator that - - - -( -k -= -0 - -j - -b -( -k -) - - -t -k - -) -* -( -k -= -1 - -j -+ -1 - - -k -z -( -k -) - - -* -t -k --1 - - -) - -= - -( -k -= -0 - -j - -e -( -k -) - - -* -t -k - -) -* -( -k -= -1 - -j -+ -1 - - -k -x -( -k -) - - -* -t -k --1 - - -) -+ -o -( -t -p - -) - -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 -) - - - - -( -k -= -1 - -j -+ -1 - - -k -x -( -k -) - - -e -( -j -+ -1 -- -k -) - - -- - -k -= -1 - -j - -k -z -( -k -) - - -b -( -j -+ -1 -- -k -) - - -) - - - -This completes the induction that computes - -e -( -j -) - - - - - -and - -z -( -j -+ -1 -) - - - - -. - - - - - - -
-
-Cases that Apply Recursion Above - - - - - - - - - -
- -exp_forward -Exponential Function Forward Mode Theory
- -log_forward -Logarithm Function Forward Mode Theory
- -sqrt_forward -Square Root Function Forward Mode Theory
- -sin_cos_forward -Trigonometric and Hyperbolic Sine and Cosine Forward Theory
- -atan_forward -Inverse Tangent and Hyperbolic Tangent Forward Mode Theory
- -asin_forward -Inverse Sine and Hyperbolic Sine Forward Mode Theory
- -acos_forward -Inverse Cosine and Hyperbolic Cosine Forward Mode Theory
- -
-
-Special Cases - - - -
- -tan_forward -Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory
- -
- -
Input File: omh/appendix/theory/forward_theory.omh - - - diff -Nru cppad-2018.00.00.0/doc/_forwardtheory_xml.js cppad-2019.02.00.0/doc/_forwardtheory_xml.js --- cppad-2018.00.00.0/doc/_forwardtheory_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forwardtheory_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +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' -]; -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', -'directory.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 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down0 = [ -'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 = [ -'forwardtheory.xml#Taylor Notation', -'forwardtheory.xml#Binary Operators', -'forwardtheory.xml#Binary Operators.Addition', -'forwardtheory.xml#Binary Operators.Subtraction', -'forwardtheory.xml#Binary Operators.Multiplication', -'forwardtheory.xml#Binary Operators.Division', -'forwardtheory.xml#Standard Math Functions', -'forwardtheory.xml#Standard Math Functions.Differential Equation', -'forwardtheory.xml#Standard Math Functions.Taylor Coefficients Recursion Formula', -'forwardtheory.xml#Standard Math Functions.Cases that Apply Recursion Above', -'forwardtheory.xml#Standard Math Functions.Special Cases' -]; -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-2018.00.00.0/doc/forward_two.xml cppad-2019.02.00.0/doc/forward_two.xml --- cppad-2018.00.00.0/doc/forward_two.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/forward_two.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,838 +0,0 @@ - - - -Second Order Forward Mode: Derivative Values - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -forward_two - -

- - - -
Second Order Forward Mode: Derivative Values
-
-Syntax - -
- -y2 = f.Forward(1, x2) - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -The result of the syntax above is that for - -i = 0 , ... , m-1 -, - -
-     
y2[i]
- - - -= -F -i -( -1 -) - - -( -x -0 -) -* -x -2 -+ -1 - -2 - - -x -1 -T - -* -F -i -( -2 -) - - -( -x -0 -) -* -x -1 - - - -
-
where - - -F -( -1 -) - - -( -x -0 -) - - - is the Jacobian of - -F - - -, and - - -F -i -( -2 -) - - -( -x -0 -) - - - is the Hessian of th i-th component of - -F - - -, -evaluated at -x0 -. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const. -Before this call to Forward, the value returned by - -
-     
f.size_order()
-
-must be greater than or equal two. -After this call it will be will be three (see size_order -). - -
-
-x0 -
-The vector -x0 - in the formula for -y2[i] - -corresponds to the previous call to forward_zero - -using this ADFun object -f -; i.e., - -
-     
f.Forward(0, x0)
-
-If there is no previous call with the first argument zero, -the value of the independent - variables -during the recording of the AD sequence of operations is used -for -x0 -. - -
-
-x1 -
-The vector -x1 - in the formula for -y2[i] - -corresponds to the previous call to forward_one - -using this ADFun object -f -; i.e., - -
-     
f.Forward(1, x1)
-
-
-x2 -
-The argument -x2 - has prototype - -
-     const 
Vectorx2
-
-(see Vector - below) -and its size must be equal to -n -, the dimension of the -domain - space for -f -. - -
-
-y2 -
-The result -y2 - has prototype - -
-     
Vector y2
-
-(see Vector - below) -The size of -y1 - is equal to -m -, the dimension of the -range - space for -f -. -Its value is given element-wise by the formula in the -purpose - above. - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Example -
-The file -forward.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - -
-
-Special Case -
-This is special case of forward_order - where - - - -Y -( -t -) - -= -F -[ -X -( -t -) -] - -X -( -t -) - -= - -x -( -0 -) - - -t -0 - -+ -x -( -1 -) - - -* -t -1 - -+ - -, -+ -x -( -q -) - - -* -t -q - -+ -o -( -t -q - -) - -Y -( -t -) - -= - -y -( -0 -) - - -t -0 - -+ -y -( -1 -) - - -* -t -1 - -+ - -, -+ -y -( -q -) - - -* -t -q - -+ -o -( -t -q - -) - - - -and - -o -( -t -q - -) -* -t -- -q - - - -0 - - - as - -t - -0 - - -. -For this special case, - -q -= -2 - - -, - - -x -( -0 -) - - - - - -x0 -, - - -x -( -1 -) - - - - - -x1 -, - - -X -( -t -) -= -x -( -0 -) - - -+ -x -( -1 -) - - -t -+ -x -( -2 -) - - -t -2 - - - -, and - - -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 i-th component, and -taking the derivative with respect to - -t - - -, we obtain - - -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 - -t - - -, -and evaluating at - -t -= -0 - - -, we obtain - - -2 -y -i -( -2 -) - - -= -[ -x -( -1 -) - - -] -T - -F -i -( -2 -) - - -[ -x -( -0 -) - - -] -x -( -1 -) - - -+ -F -i -( -1 -) - - -[ -x -( -0 -) - - -] -2 -x -( -2 -) - - - - -which agrees with the specification for -y2[i] - in the -purpose - above. - - -
Input File: omh/forward/forward_two.omh - - - diff -Nru cppad-2018.00.00.0/doc/_forward_two_xml.js cppad-2019.02.00.0/doc/_forward_two_xml.js --- cppad-2018.00.00.0/doc/_forward_two_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forward_two_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'forward_two.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_current0 = [ -'forward_two.xml#Syntax', -'forward_two.xml#Purpose', -'forward_two.xml#f', -'forward_two.xml#x0', -'forward_two.xml#x1', -'forward_two.xml#x2', -'forward_two.xml#y2', -'forward_two.xml#Vector', -'forward_two.xml#Example', -'forward_two.xml#Special Case' -]; -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-2018.00.00.0/doc/forward.xml cppad-2019.02.00.0/doc/forward.xml --- cppad-2018.00.00.0/doc/forward.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/forward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ - - - -Forward Mode - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Forward Mode
-
-Contents -
- -
forward_zeroZero Order Forward Mode: Function Values
forward_oneFirst Order Forward Mode: Derivative Values
forward_twoSecond Order Forward Mode: Derivative Values
forward_orderMultiple Order Forward Mode
forward_dirMultiple Directions Forward Mode
size_orderNumber Taylor Coefficient Orders Currently Stored
compare_changeComparison Changes Between Taping and Zero Order Forward
capacity_orderControlling Taylor Coefficients Memory Allocation
number_skipNumber of Variables that Can be Skipped
-
Input File: omh/adfun.omh - - - diff -Nru cppad-2018.00.00.0/doc/_forward_xml.js cppad-2019.02.00.0/doc/_forward_xml.js --- cppad-2018.00.00.0/doc/_forward_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forward_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', -'adfun.xml', -'forward.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down0 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_current0 = [ -'forward.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-2018.00.00.0/doc/forward_zero.xml cppad-2019.02.00.0/doc/forward_zero.xml --- cppad-2018.00.00.0/doc/forward_zero.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/forward_zero.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,521 +0,0 @@ - - - -Zero Order Forward Mode: Function Values - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -forward_zero - -

-
Zero Order Forward Mode: Function Values
-
-Syntax - -
- -y0 = f.Forward(0, x0)
-
- -y0 = f.Forward(0, x0s) - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -The result of the syntax above is - - -y -0 -= -F -( -x -0 -) - - -See the FunCheck discussion - for -possible differences between - -F -( -x -) - - - and the algorithm that defined -the operation sequence. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const. -After this call to Forward, the value returned by - -
-     
f.size_order()
-
-will be equal to one (see size_order -). - -
-
-x0 -
-The argument -x0 - has prototype - -
-     const 
Vectorx0
-
-(see Vector - below) -and its size must be equal to -n -, the dimension of the -domain - space for -f -. - -
-
-s -
-If the argument -s - is not present, std::cout -is used in its place. -Otherwise, this argument has prototype - -
-     std::ostream& 
s
-
-It specifies where the output corresponding to PrintFor -, -and this zero order forward mode call, will be written. - -
-
-y0 -
-The result -y0 - has prototype - -
-     
Vector y0
-
-(see Vector - below) -and its value is - -F -( -x -) - - - at -x = x0 -. -The size of -y0 - is equal to -m -, the dimension of the -range - space for -f -. - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Example -
-The file -forward.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - -
-
-Special Case -
-This is special case of forward_order - where - - - -Y -( -t -) - -= - -F -[ -X -( -t -) -] - -X -( -t -) - -= - -x -( -0 -) - - -t -0 - -+ -x -( -1 -) - - -* -t -1 - -+ - -, -+ -x -( -q -) - - -* -t -q - -+ -o -( -t -q - -) - -Y -( -t -) - -= - -y -( -0 -) - - -t -0 - -+ -y -( -1 -) - - -* -t -1 - -+ - -, -+ -y -( -q -) - - -* -t -q - -+ -o -( -t -q - -) - - - -and - -o -( -t -q - -) -* -t -- -q - - - -0 - - - as - -t - -0 - - -. -For this special case, - -q -= -0 - - -, - - -x -( -0 -) - - - - - -x0 -, - - -X -( -t -) -= -x -( -0 -) - - - - -, and - - -y -( -0 -) - - -= -Y -( -t -) -= -F -[ -X -( -t -) -] -= -F -( -x -( -0 -) - - -) - - -which agrees with the specifications for - -y0 - in the purpose - above. - - - - -
Input File: omh/forward/forward_zero.omh - - - diff -Nru cppad-2018.00.00.0/doc/_forward_zero_xml.js cppad-2019.02.00.0/doc/_forward_zero_xml.js --- cppad-2018.00.00.0/doc/_forward_zero_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_forward_zero_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'forward_zero.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_current0 = [ -'forward_zero.xml#Syntax', -'forward_zero.xml#Purpose', -'forward_zero.xml#f', -'forward_zero.xml#x0', -'forward_zero.xml#s', -'forward_zero.xml#y0', -'forward_zero.xml#Vector', -'forward_zero.xml#Example', -'forward_zero.xml#Special Case' -]; -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-2018.00.00.0/doc/fun_assign.cpp.xml cppad-2019.02.00.0/doc/fun_assign.cpp.xml --- cppad-2018.00.00.0/doc/fun_assign.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/fun_assign.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ - - - -ADFun Assignment: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -fun_assign.cppHeadings

- - -
ADFun Assignment: Example and Test
-
# include <cppad/cppad.hpp>
-# include <limits>
-
-bool fun_assign(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     size_t i, j;
-
-     // ten times machine percision
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-
-     // two ADFun<double> objects
-     CppAD::ADFun<double> g;
-
-     // domain space vector
-     size_t n  = 3;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     for(j = 0; j < n; j++)
-          x[j] = AD<double>(j + 2);
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     // range space vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = x[0] + x[0] * x[1];
-     y[1] = x[1] * x[2] + x[2];
-
-     // Store operation sequence, and order zero forward results, in f.
-     CppAD::ADFun<double> f(x, y);
-
-     // sparsity pattern for the identity matrix
-     CPPAD_TESTVECTOR(std::set<size_t>) r(n);
-     for(j = 0; j < n; j++)
-          r[j].insert(j);
-
-     // Store forward mode sparsity pattern in f
-     f.ForSparseJac(n, r);
-
-     // make a copy in g
-     g = f;
-
-     // check values that should be equal
-     ok &= ( g.size_order() == f.size_order() );
-     ok &= ( (g.size_forward_bool() > 0) == (f.size_forward_bool() > 0) );
-     ok &= ( (g.size_forward_set() > 0)  == (f.size_forward_set() > 0) );
-
-     // Use zero order Taylor coefficient from f for first order
-     // calculation using g.
-     CPPAD_TESTVECTOR(double) dx(n), dy(m);
-     for(i = 0; i < n; i++)
-          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]
-
-     // Use forward Jacobian sparsity pattern from f to calculate
-     // Hessian sparsity pattern using g.
-     CPPAD_TESTVECTOR(std::set<size_t>) s(1), h(n);
-     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]
-
-     return ok;
-}
-
-
-
Input File: example/general/fun_assign.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_fun_assign.cpp_xml.js cppad-2019.02.00.0/doc/_fun_assign.cpp_xml.js --- cppad-2018.00.00.0/doc/_fun_assign.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fun_assign.cpp_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', -'adfun.xml', -'record_adfun.xml', -'funconstruct.xml', -'fun_assign.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'independent.xml', -'funconstruct.xml', -'dependent.xml', -'abort_recording.xml', -'seq_property.xml' -]; -var list_down1 = [ -'fun_assign.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-2018.00.00.0/doc/fun_check.cpp.xml cppad-2019.02.00.0/doc/fun_check.cpp.xml --- cppad-2018.00.00.0/doc/fun_check.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/fun_check.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,205 +0,0 @@ - - - -ADFun Check and Re-Tape: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -fun_check.cppHeadings

- - - -
ADFun Check and Re-Tape: Example and Test
-
# include <cppad/cppad.hpp>
-
-namespace { // -----------------------------------------------------------
-// define the template function object Fun<Type,Vector> in empty namespace
-template <class Type, class Vector>
-class Fun {
-private:
-     size_t n;
-public:
-     // function constructor
-     Fun(size_t n_) : n(n_)
-     { }
-     // function evaluator
-     Vector operator() (const Vector &x)
-     {     Vector y(n);
-          size_t i;
-          for(i = 0; i < n; i++)
-          {     // This operaiton sequence depends on x
-               if( x[i] >= 0 )
-                    y[i] = exp(x[i]);
-               else     y[i] = exp(-x[i]);
-          }
-          return y;
-     }
-};
-// template function FunCheckCases<Vector, ADVector> in empty namespace
-template <class Vector, class ADVector>
-bool FunCheckCases(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::ADFun;
-     using CppAD::Independent;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // use the ADFun default constructor
-     ADFun<double> f;
-
-     // domain space vector
-     size_t n = 2;
-     ADVector X(n);
-     X[0] = -1.;
-     X[1] = 1.;
-
-     // declare independent variables and starting recording
-     Independent(X);
-
-     // create function object to use with AD<double>
-     Fun< AD<double>, ADVector > G(n);
-
-     // range space vector
-     size_t m = n;
-     ADVector Y(m);
-     Y = G(X);
-
-     // stop tape and store operation sequence in f : X -> Y
-     f.Dependent(X, Y);
-     ok &= (f.size_order() == 0);  // no implicit forward operation
-
-     // create function object to use with double
-     Fun<double, Vector> g(n);
-
-     // 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 = eps99;
-     double a = eps99;
-     ok      &= FunCheck(f, g, x, a, r);
-
-     // function values should not agree when the independent variable
-     // values are the negative of values during recording
-     for(j = 0; j < n; j++)
-          x[j] = - Value(X[j]);
-     ok      &= ! FunCheck(f, g, x, a, r);
-
-     // re-tape to obtain the new AD of double operation sequence
-     for(j = 0; j < n; j++)
-          X[j] = x[j];
-     Independent(X);
-     Y = G(X);
-
-     // stop tape and store operation sequence in f : X -> Y
-     f.Dependent(X, Y);
-     ok &= (f.size_order() == 0);  // no implicit forward with this x
-
-     // function values should agree now
-     ok      &= FunCheck(f, g, x, a, r);
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool FunCheck(void)
-{     bool ok = true;
-     typedef CppAD::vector<double>                Vector1;
-     typedef CppAD::vector< CppAD::AD<double> > ADVector1;
-     typedef   std::vector<double>                Vector2;
-     typedef   std::vector< CppAD::AD<double> > ADVector2;
-     typedef std::valarray<double>                Vector3;
-     typedef std::valarray< CppAD::AD<double> > ADVector3;
-     // Run with Vector and ADVector equal to three different cases
-     // all of which are Simple Vectors with elements of type
-     // double and AD<double> respectively.
-     ok &= FunCheckCases< Vector1, ADVector2 >();
-     ok &= FunCheckCases< Vector2, ADVector3 >();
-     ok &= FunCheckCases< Vector3, ADVector1 >();
-     return ok;
-}
-
-
Input File: example/general/fun_check.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_fun_check.cpp_xml.js cppad-2019.02.00.0/doc/_fun_check.cpp_xml.js --- cppad-2018.00.00.0/doc/_fun_check.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fun_check.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'funcheck.xml', -'fun_check.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'fun_check.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-2018.00.00.0/doc/funcheck.xml cppad-2019.02.00.0/doc/funcheck.xml --- cppad-2018.00.00.0/doc/funcheck.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/funcheck.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,623 +0,0 @@ - - - -Check an ADFun Sequence of Operations - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Check an ADFun Sequence of Operations
-
-Syntax - -
- -ok = FunCheck(fgxra) - -
-
See Also -CompareChange - - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -We use - -G -: -B -n - - -B -m - - - - to denote the -function corresponding to the C++ function object -g -. -This routine check if - - -F -( -x -) -= -G -( -x -) - - -If - -F -( -x -) - -G -( -x -) - - -, the -operation sequence - -corresponding to -f - does not represents the algorithm used -by -g - to calculate values for - -G - - - -(see Discussion - below). - -
-
-f -
-The FunCheck argument -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const -(see Forward - below). - -
-
-g -
-The FunCheck argument -g - has prototype - -
-     
Fun &g
-
-( -Fun - is defined the properties of -g -). -The C++ function object -g - supports the syntax - -
-     
y = g(x)
-
-which computes - -y -= -G -( -x -) - - -. - -
-
-x -
-The -g - argument -x - has prototype - -
-     const 
Vector &x
-
-(see Vector - below) -and its size -must be equal to -n -, the dimension of the -domain - space for -f -. - -
-
-y -
-The -g - result -y - has prototype - -
-     
Vector y
-
-and its value is - -G -( -x -) - - -. -The size of -y - -is equal to -m -, the dimension of the -range - space for -f -. - -
-
-x -
-The FunCheck argument -x - has prototype - -
-     const 
Vector &x
-
-and its size -must be equal to -n -, the dimension of the -domain - space for -f -. -This specifies that point at which to compare the values -calculated by -f - and -G -. - -
-
-r -
-The FunCheck argument -r - has prototype - -
-     const 
Base &r
-
-It specifies the relative error the element by element -comparison of the value of - -F -( -x -) - - - and - -G -( -x -) - - -. - -
-
-a -
-The FunCheck argument -a - has prototype - -
-     const 
Base &a
-
-It specifies the absolute error the element by element -comparison of the value of - -F -( -x -) - - - and - -G -( -x -) - - -. - -
-
-ok -
-The FunCheck result -ok - has prototype - -
-     bool 
ok
-
-It is true, if for - -i -= -0 -, - -, -m --1 - - - -either the relative error bound is satisfied - - -| -F -i - -( -x -) -- -G -i - -( -x -) -| - -r -( -| -F -i - -( -x -) -| -+ -| -G -i - -( -x -) -| -) - - -or the absolute error bound is satisfied - - -| -F -i - -( -x -) -- -G -i - -( -x -) -| - -a - - -It is false if for some - -( -i -, -j -) - - - neither -of these bounds is satisfied. - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-FunCheck Uses Forward -
-After each call to Forward -, -the object -f - contains the corresponding -Taylor coefficients -. -After FunCheck, -the previous calls to Forward - are undefined. - -
-
-Discussion -
-Suppose that the algorithm corresponding to -g - contains - -
-     if( 
x >= 0 )
-          
y = exp(x)
-     else 
y = exp(-x)
-
-where -x - and -y - are -AD<double> - objects. -It follows that the -AD of double operation sequence - -depends on the value of -x -. -If the sequence of operations stored in -f - corresponds to - -g - with - -x - -0 - - -, -the function values computed using -f - when - -x -< -0 - - - -will not agree with the function values computed by - -g - - -. -This is because the operation sequence corresponding to -g - changed -(and hence the object -f - does not represent the function - - -G - - - for this value of -x -). -In this case, you probably want to re-tape the calculations -performed by -g - with the -independent variables - -equal to the values in -x - -(so AD operation sequence properly represents the algorithm -for this value of independent variables). - - -
-
-Example - -
-The file -fun_check.cpp - -contains an example and test of this function. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/fun_check.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_funcheck_xml.js cppad-2019.02.00.0/doc/_funcheck_xml.js --- cppad-2018.00.00.0/doc/_funcheck_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_funcheck_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'funcheck.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down0 = [ -'fun_check.cpp.xml' -]; -var list_current0 = [ -'funcheck.xml#Syntax', -'funcheck.xml#Purpose', -'funcheck.xml#f', -'funcheck.xml#g', -'funcheck.xml#g.x', -'funcheck.xml#y', -'funcheck.xml#x', -'funcheck.xml#r', -'funcheck.xml#a', -'funcheck.xml#ok', -'funcheck.xml#Vector', -'funcheck.xml#FunCheck Uses Forward', -'funcheck.xml#Discussion', -'funcheck.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-2018.00.00.0/doc/funconstruct.xml cppad-2019.02.00.0/doc/funconstruct.xml --- cppad-2018.00.00.0/doc/funconstruct.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/funconstruct.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,469 +0,0 @@ - - - -Construct an ADFun Object and Stop Recording - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Construct an ADFun Object and Stop Recording
-
-Syntax - -
- -ADFun<Basefg
-
- -ADFun<Basef(xy)
-
- -g = f
-
-
-Purpose -
-The -AD<Base> - object -f - can -store an AD of -Base - -operation sequence -. -It can then be used to calculate derivatives of the corresponding -AD function - - - -F -: -B -n - - -B -m - - - -where - -B - - - is the space corresponding to objects of type -Base -. - -
-
-x -
-If the argument -x - is present, it has prototype - -
-     const 
VectorAD &x
-
-It must be the vector argument in the previous call to -Independent -. -Neither its size, or any of its values, are allowed to change -between calling - -
-     Independent(
x)
-
-and - -
-     ADFun<
Basef(xy)
-
-
-y -
-If the argument -y - is present, it has prototype - -
-     const 
VectorAD &y
-
-The sequence of operations that map -x - -to -y - are stored in the ADFun object -f -. - -
-
-VectorAD -
-The type -VectorAD - must be a SimpleVector - class with -elements of type - - -AD<Base> -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Default Constructor -
-The default constructor - -
-     ADFun<
Basef
-
-creates an - -AD<Base> - object with no corresponding operation sequence; i.e., - -
-     
f.size_var()
-
-returns the value zero (see size_var -). - -
-
-Sequence Constructor -
-The sequence constructor - -
-     ADFun<
Basef(xy)
-
-creates the -AD<Base> - object -f -, -stops the recording of AD of -Base - operations -corresponding to the call - -
-     Independent(
x)
-
-and stores the corresponding operation sequence in the object -f -. -It then stores the zero order Taylor coefficients -(corresponding to the value of -x -) in -f -. -This is equivalent to the following steps using the default constructor: - -
  1. -Create -f - with the default constructor - -
    -     ADFun<
    Basef;
    -
    -
  2. -Stop the tape and storing the operation sequence using - -
    -     
    f.Dependent(xy);
    -
    -(see Dependent -). -
  3. - -Calculate the zero order Taylor coefficients for all -the variables in the operation sequence using - -
    -     
    f.Forward(px_p)
    -
    -with -p - equal to zero and the elements of -x_p - -equal to the corresponding elements of -x - -(see Forward -). -
- - -
-
-Copy Constructor -
-It is an error to attempt to use the -ADFun<Base> - copy constructor; -i.e., the following syntax is not allowed: - -
-     ADFun<
Baseg(f)
-
-where -f - is an -ADFun<Base> - object. -Use its default constructor - instead -and its assignment operator. - -
-
-Assignment Operator -
-The -ADFun<Base> - assignment operation - -
-     
g = f
-
-makes a copy of the operation sequence currently stored in -f - -in the object -g -. -The object -f - is not affected by this operation and -can be const. -All of information (state) stored in -f - is copied to -g - -and any information originally in -g - is lost. - -
-
-Taylor Coefficients -
-The Taylor coefficient information currently stored in -f - -(computed by f.Forward -) is -copied to -g -. -Hence, directly after this operation - -
-     
g.size_order() == f.size_order()
-
-
-Sparsity Patterns -
-The forward Jacobian sparsity pattern currently stored in -f - -(computed by f.ForSparseJac -) is -copied to -g -. -Hence, directly after this operation - -
-     
g.size_forward_bool() == f.size_forward_bool()
-     
g.size_forward_set()  == f.size_forward_set()
-
-
-Parallel Mode -
-The call to Independent, -and the corresponding call to - -
-     ADFun<
Basefxy)
-
-or - -
-     
f.Dependent( xy)
-
-or abort_recording -, -must be preformed by the same thread; i.e., -thread_alloc::thread_num - must be the same. - -
-
-Example - - -
-
-Sequence Constructor -
-The file -independent.cpp - -contains an example and test of the sequence constructor. -It returns true if it succeeds and false otherwise. - -
-
-Default Constructor -
-The files -fun_check.cpp - -and -hes_lagrangian.cpp - -contain an examples and tests using the default constructor. -They return true if they succeed and false otherwise. - - -
-
-Assignment Operator -
-The file -fun_assign.cpp - -contains an example and test of the -ADFun<Base> - -assignment operator. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/fun_construct.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_funconstruct_xml.js cppad-2019.02.00.0/doc/_funconstruct_xml.js --- cppad-2018.00.00.0/doc/_funconstruct_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_funconstruct_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'record_adfun.xml', -'funconstruct.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'independent.xml', -'funconstruct.xml', -'dependent.xml', -'abort_recording.xml', -'seq_property.xml' -]; -var list_down0 = [ -'fun_assign.cpp.xml' -]; -var list_current0 = [ -'funconstruct.xml#Syntax', -'funconstruct.xml#Purpose', -'funconstruct.xml#x', -'funconstruct.xml#y', -'funconstruct.xml#VectorAD', -'funconstruct.xml#Default Constructor', -'funconstruct.xml#Sequence Constructor', -'funconstruct.xml#Copy Constructor', -'funconstruct.xml#Assignment Operator', -'funconstruct.xml#Assignment Operator.Taylor Coefficients', -'funconstruct.xml#Assignment Operator.Sparsity Patterns', -'funconstruct.xml#Parallel Mode', -'funconstruct.xml#Example', -'funconstruct.xml#Example.Sequence Constructor', -'funconstruct.xml#Example.Default Constructor', -'funconstruct.xml#Example.Assignment Operator' -]; -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-2018.00.00.0/doc/fundeprecated.xml cppad-2019.02.00.0/doc/fundeprecated.xml --- cppad-2018.00.00.0/doc/fundeprecated.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/fundeprecated.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,409 +0,0 @@ - - - -ADFun Object Deprecated Member Functions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -FunDeprecated - -

-
ADFun Object Deprecated Member Functions
-
-Syntax - -
- -f.Dependent(y)
-
- -o = f.Order()
-
- -m = f.Memory()
-
- -s = f.Size()
-
- -t = f.taylor_size()
-
- -u = f.use_VecAD()
-
- -v = f.size_taylor()
-
- -w = f.capacity_taylor()
-
-
-Purpose -
-The -ADFun<Base> - functions documented here have been deprecated; -i.e., they are no longer approved of and may be removed from some future -version of CppAD. - -
-
-Dependent -
-A recording of and AD of -Base - -operation sequence - -is started by a call of the form - -
-     Independent(
x)
-
-If there is only one such recording at the current time, -you can use -f.Dependent(y) - in place of - -
-     
f.Dependent(xy)
-
-See Dependent - for a description of this operation. - -
-
-Deprecated 2007-08-07 -
-This syntax was deprecated when CppAD was extended to allow -for more than one -AD<Base> - recording to be -active at one time. -This was necessary to allow for multiple threading applications. - -
-
-Order -
-The result -o - has prototype - -
-     size_t 
o
-
-and is the order of the previous forward operation -using the function -f -. -This is the highest order of the -Taylor coefficients - -that are currently stored in -f -. - -
-
-Deprecated 2006-03-31 -
-Zero order corresponds to function values being stored in -f -. -In the future, we would like to be able to erase the function -values so that -f - uses less memory. -In this case, the return value of Order would not make sense. -Use size_order - to obtain -the number of Taylor coefficients currently stored -in the ADFun object -f - -(which is equal to the order plus one). - - -
-
-Memory -
-The result - -
-     size_t 
m
-
-and is the number of memory units (sizeof) required for the -information currently stored in -f -. -This memory is returned to the system when the destructor for - -f - is called. - -
-
-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 -was called. -This is no longer the case, an ADFun object now returns memory -when it no longer needs the values stored in that memory. -Thus the Memory function is no longer well defined. - -
-
-Size -
-The result -s - has prototype - -
-     size_t 
s
-
-and is the number of variables in the operation sequence plus the following: -one for a phantom variable with tape address zero, -one for each component of the domain that is a parameter. -The amount of work and memory necessary for computing function values -and derivatives using -f - is roughly proportional to -s -. - -
-
-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 size_var - to obtain -the number of variables in the operation sequence. - -
-
-taylor_size -
-The result -t - has prototype - -
-     size_t 
t
-
-and is the number of Taylor coefficient orders -currently calculated and stored in the ADFun object -f -. - -
-
-Deprecated 2006-06-17 -
-This function has been replaced by size_order -. - -
-
-use_VecAD -
-The result -u - has prototype - -
-     bool 
u
-
-If it is true, the -AD of -Base - -operation sequence - -stored in -f - contains -VecAD - operands. -Otherwise -u - is false. - -
-
-Deprecated 2006-04-08 -
-You can instead use - -
-     
u = f.size_VecAD() > 0
-
-
-size_taylor -
-The result -v - has prototype - -
-     size_t 
v
-
-and is the number of Taylor coefficient orders -currently calculated and stored in the ADFun object -f -. - -
-
-Deprecated 2014-03-18 -
-This function has been replaced by size_order -. - -
-
-capacity_taylor -
-The result -w - has prototype - -
-     size_t 
w
-
-and is the number of Taylor coefficient orders currently allocated -in the ADFun object -f -. - -
-
-Deprecated 2014-03-18 -
-This function has been replaced by capacity_order -. - - - -
Input File: omh/appendix/deprecated/fun_deprecated.omh - - - diff -Nru cppad-2018.00.00.0/doc/_fundeprecated_xml.js cppad-2019.02.00.0/doc/_fundeprecated_xml.js --- cppad-2018.00.00.0/doc/_fundeprecated_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_fundeprecated_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'fundeprecated.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', -'directory.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', -'autotools.xml' -]; -var list_current0 = [ -'fundeprecated.xml#Syntax', -'fundeprecated.xml#Purpose', -'fundeprecated.xml#Dependent', -'fundeprecated.xml#Dependent.Deprecated 2007-08-07', -'fundeprecated.xml#Order', -'fundeprecated.xml#Order.Deprecated 2006-03-31', -'fundeprecated.xml#Memory', -'fundeprecated.xml#Memory.Deprecated 2006-03-31', -'fundeprecated.xml#Size', -'fundeprecated.xml#Size.Deprecated 2006-04-03', -'fundeprecated.xml#taylor_size', -'fundeprecated.xml#taylor_size.Deprecated 2006-06-17', -'fundeprecated.xml#use_VecAD', -'fundeprecated.xml#use_VecAD.Deprecated 2006-04-08', -'fundeprecated.xml#size_taylor', -'fundeprecated.xml#size_taylor.Deprecated 2014-03-18', -'fundeprecated.xml#capacity_taylor', -'fundeprecated.xml#capacity_taylor.Deprecated 2014-03-18' -]; -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-2018.00.00.0/doc/general.cpp.xml cppad-2019.02.00.0/doc/general.cpp.xml --- cppad-2018.00.00.0/doc/general.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/general.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,353 +0,0 @@ - - - -CppAD Examples and Tests - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -general.cpp - -

-
CppAD Examples and Tests
-
-Running Tests -
-To build this program and run its correctness tests see cmake_check -. - - -

-// CPPAD_HAS_* defines
-# include <cppad/configure.hpp>
-
-// system include files used for I/O
-# include <iostream>
-
-// C style asserts
-# include <cassert>
-
-// standard string
-# include <string>
-
-// memory utility
-# include <cppad/utility/thread_alloc.hpp>
-
-// test runner
-# include <cppad/utility/test_boolofvoid.hpp>
-
-// prototype external compiled tests (this line expected by bin/new_test.sh)
-extern bool abort_recording(void);
-extern bool fabs(void);
-extern bool acosh(void);
-extern bool acos(void);
-extern bool ad_assign(void);
-extern bool ad_ctor(void);
-extern bool AddEq(void);
-extern bool Add(void);
-extern bool ad_fun(void);
-extern bool ad_in_c(void);
-extern bool ad_input(void);
-extern bool ad_output(void);
-extern bool asinh(void);
-extern bool asin(void);
-extern bool atan2(void);
-extern bool atanh(void);
-extern bool atan(void);
-extern bool azmul(void);
-extern bool base_require(void);
-extern bool BenderQuad(void);
-extern bool BoolFun(void);
-extern bool capacity_order(void);
-extern bool change_param(void);
-extern bool check_for_nan(void);
-extern bool compare_change(void);
-extern bool Compare(void);
-extern bool complex_poly(void);
-extern bool CondExp(void);
-extern bool Cosh(void);
-extern bool Cos(void);
-extern bool DivEq(void);
-extern bool Div(void);
-extern bool eigen_array(void);
-extern bool eigen_det(void);
-extern bool EqualOpSeq(void);
-extern bool Erf(void);
-extern bool expm1(void);
-extern bool exp(void);
-extern bool ForOne(void);
-extern bool ForTwo(void);
-extern bool forward_dir(void);
-extern bool forward_order(void);
-extern bool Forward(void);
-extern bool fun_assign(void);
-extern bool FunCheck(void);
-extern bool HesLagrangian(void);
-extern bool HesLuDet(void);
-extern bool HesMinorDet(void);
-extern bool Hessian(void);
-extern bool HesTimesDir(void);
-extern bool Independent(void);
-extern bool Integer(void);
-extern bool Interface2C(void);
-extern bool interp_onetape(void);
-extern bool interp_retape(void);
-extern bool JacLuDet(void);
-extern bool JacMinorDet(void);
-extern bool Jacobian(void);
-extern bool log10(void);
-extern bool log1p(void);
-extern bool log(void);
-extern bool LuRatio(void);
-extern bool LuVecADOk(void);
-extern bool MulEq(void);
-extern bool mul_level_adolc_ode(void);
-extern bool mul_level_adolc(void);
-extern bool mul_level_ode(void);
-extern bool mul_level(void);
-extern bool Mul(void);
-extern bool NearEqualExt(void);
-extern bool number_skip(void);
-extern bool NumericType(void);
-extern bool num_limits(void);
-extern bool OdeStiff(void);
-extern bool ode_taylor(void);
-extern bool opt_val_hes(void);
-extern bool ParVar(void);
-extern bool Poly(void);
-extern bool pow_int(void);
-extern bool pow(void);
-extern bool print_for(void);
-extern bool reverse_any(void);
-extern bool reverse_one(void);
-extern bool reverse_three(void);
-extern bool reverse_two(void);
-extern bool RevOne(void);
-extern bool RevTwo(void);
-extern bool Rosen34(void);
-extern bool runge_45_2(void);
-extern bool seq_property(void);
-extern bool sign(void);
-extern bool Sinh(void);
-extern bool Sin(void);
-extern bool Sqrt(void);
-extern bool StackMachine(void);
-extern bool SubEq(void);
-extern bool Sub(void);
-extern bool Tanh(void);
-extern bool Tan(void);
-extern bool TapeIndex(void);
-extern bool UnaryMinus(void);
-extern bool UnaryPlus(void);
-extern bool Value(void);
-extern bool Var2Par(void);
-extern bool vec_ad(void);
-
-// main program that runs all the tests
-int main(void)
-{     std::string group = "example/general";
-     size_t      width = 20;
-     CppAD::test_boolofvoid Run(group, width);
-
-     // This line is used by test_one.sh
-
-     // run external compiled tests (this line expected by bin/new_test.sh)
-     Run( abort_recording,   "abort_recording"  );
-     Run( fabs,              "fabs"             );
-     Run( acos,              "acos"             );
-     Run( acosh,             "acosh"            );
-     Run( ad_assign,         "ad_assign"        );
-     Run( ad_ctor,           "ad_ctor"          );
-     Run( Add,               "Add"              );
-     Run( AddEq,             "AddEq"            );
-     Run( ad_fun,            "ad_fun"           );
-     Run( ad_in_c,           "ad_in_c"          );
-     Run( ad_input,          "ad_input"         );
-     Run( ad_output,         "ad_output"        );
-     Run( asin,              "asin"             );
-     Run( asinh,             "asinh"            );
-     Run( atan2,             "atan2"            );
-     Run( atan,              "atan"             );
-     Run( atanh,             "atanh"            );
-     Run( azmul,             "azmul"            );
-     Run( BenderQuad,        "BenderQuad"       );
-     Run( BoolFun,           "BoolFun"          );
-     Run( capacity_order,    "capacity_order"   );
-     Run( change_param,      "change_param"     );
-     Run( compare_change,    "compare_change"   );
-     Run( Compare,           "Compare"          );
-     Run( complex_poly,      "complex_poly"     );
-     Run( CondExp,           "CondExp"          );
-     Run( Cos,               "Cos"              );
-     Run( Cosh,              "Cosh"             );
-     Run( Div,               "Div"              );
-     Run( DivEq,             "DivEq"            );
-     Run( EqualOpSeq,        "EqualOpSeq"       );
-     Run( Erf,               "Erf"              );
-     Run( exp,               "exp"              );
-     Run( expm1,             "expm1"            );
-     Run( ForOne,            "ForOne"           );
-     Run( ForTwo,            "ForTwo"           );
-     Run( forward_dir,       "forward_dir"      );
-     Run( Forward,           "Forward"          );
-     Run( forward_order,     "forward_order"    );
-     Run( fun_assign,        "fun_assign"       );
-     Run( FunCheck,          "FunCheck"         );
-     Run( HesLagrangian,     "HesLagrangian"    );
-     Run( HesLuDet,          "HesLuDet"         );
-     Run( HesMinorDet,       "HesMinorDet"      );
-     Run( Hessian,           "Hessian"          );
-     Run( HesTimesDir,       "HesTimesDir"      );
-     Run( Independent,       "Independent"      );
-     Run( Integer,           "Integer"          );
-     Run( Interface2C,       "Interface2C"      );
-     Run( interp_onetape,    "interp_onetape"   );
-     Run( interp_retape,     "interp_retape"    );
-     Run( JacLuDet,          "JacLuDet"         );
-     Run( JacMinorDet,       "JacMinorDet"      );
-     Run( Jacobian,          "Jacobian"         );
-     Run( log10,             "log10"            );
-     Run( log1p,             "log1p"            );
-     Run( log,               "log"              );
-     Run( LuRatio,           "LuRatio"          );
-     Run( LuVecADOk,         "LuVecADOk"        );
-     Run( MulEq,             "MulEq"            );
-     Run( mul_level,         "mul_level"        );
-     Run( mul_level_ode,     "mul_level_ode"    );
-     Run( Mul,               "Mul"              );
-     Run( NearEqualExt,      "NearEqualExt"     );
-     Run( number_skip,       "number_skip"      );
-     Run( NumericType,       "NumericType"      );
-     Run( num_limits,        "num_limits"       );
-     Run( OdeStiff,          "OdeStiff"         );
-     Run( ode_taylor,        "ode_taylor"       );
-     Run( opt_val_hes,       "opt_val_hes"      );
-     Run( ParVar,            "ParVar"           );
-     Run( Poly,              "Poly"             );
-     Run( pow_int,           "pow_int"          );
-     Run( pow,               "pow"              );
-     Run( reverse_any,       "reverse_any"      );
-     Run( reverse_one,       "reverse_one"      );
-     Run( reverse_three,     "reverse_three"    );
-     Run( reverse_two,       "reverse_two"      );
-     Run( RevOne,            "RevOne"           );
-     Run( RevTwo,            "RevTwo"           );
-     Run( Rosen34,           "Rosen34"          );
-     Run( runge_45_2,        "runge_45_2"       );
-     Run( seq_property,      "seq_property"     );
-     Run( sign,              "sign"             );
-     Run( Sinh,              "Sinh"             );
-     Run( Sin,               "Sin"              );
-     Run( Sqrt,              "Sqrt"             );
-     Run( StackMachine,      "StackMachine"     );
-     Run( SubEq,             "SubEq"            );
-     Run( Sub,               "Sub"              );
-     Run( Tanh,              "Tanh"             );
-     Run( Tan,               "Tan"              );
-     Run( TapeIndex,         "TapeIndex"        );
-     Run( UnaryMinus,        "UnaryMinus"       );
-     Run( UnaryPlus,         "UnaryPlus"        );
-     Run( Value,             "Value"            );
-     Run( Var2Par,           "Var2Par"          );
-     Run( vec_ad,            "vec_ad"           );
-# ifndef CPPAD_DEBUG_AND_RELEASE
-     Run( check_for_nan,     "check_for_nan"    );
-# endif
-# if CPPAD_HAS_ADOLC
-     Run( mul_level_adolc,      "mul_level_adolc"     );
-     Run( mul_level_adolc_ode,  "mul_level_adolc_ode" );
-# endif
-# if CPPAD_HAS_EIGEN
-     Run( eigen_array,       "eigen_array"      );
-     Run( eigen_det,         "eigen_det"        );
-# endif
-     //
-     // check for memory leak
-     bool memory_ok = CppAD::thread_alloc::free_all();
-     // print summary at end
-     bool ok = Run.summary(memory_ok);
-     //
-     return static_cast<int>( ! ok );
-}
-
-
Input File: example/general/general.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_general.cpp_xml.js cppad-2019.02.00.0/doc/_general.cpp_xml.js --- cppad-2018.00.00.0/doc/_general.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_general.cpp_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', -'example.xml', -'exampleutility.xml', -'general.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'general.cpp.xml', -'speed_example.cpp.xml', -'lu_vec_ad.cpp.xml' -]; -var list_current0 = [ -'general.cpp.xml#Running Tests' -]; -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-2018.00.00.0/doc/general.xml cppad-2019.02.00.0/doc/general.xml --- cppad-2018.00.00.0/doc/general.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/general.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ - - - -General Examples - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - - -
General Examples
-
-Description -
-Most of the examples in CppAD are part of the documentation -for a specific feature; for example, add.cpp - is an -example using the addition operator -. -The examples list in this section are of a more general nature. - -
-
-Contents -
- -
ad_fun.cppCreating Your Own Interface to an ADFun Object
ad_in_c.cppExample and Test Linking CppAD to Languages Other than C++
conj_grad.cppDifferentiate Conjugate Gradient Algorithm: Example and Test
cppad_eigen.hppEnable Use of Eigen Linear Algebra Package with CppAD
hes_minor_det.cppGradient of Determinant Using Expansion by Minors: Example and Test
hes_lu_det.cppGradient of Determinant Using LU Factorization: Example and Test
interface2c.cppInterfacing to C: Example and Test
jac_minor_det.cppGradient of Determinant Using Expansion by Minors: Example and Test
jac_lu_det.cppGradient of Determinant Using Lu Factorization: Example and Test
mul_levelUsing Multiple Levels of AD
ode_stiff.cppA Stiff Ode: Example and Test
mul_level_ode.cppTaylor's Ode Solver: A Multi-Level AD Example and Test
mul_level_adolc_ode.cppTaylor's Ode Solver: A Multi-Level Adolc Example and Test
ode_taylor.cppTaylor's Ode Solver: An Example and Test
stack_machine.cppExample Differentiating a Stack Machine Interpreter
-
Input File: omh/example_list.omh - - - diff -Nru cppad-2018.00.00.0/doc/_general_xml.js cppad-2019.02.00.0/doc/_general_xml.js --- cppad-2018.00.00.0/doc/_general_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_general_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', -'example.xml', -'general.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down0 = [ -'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_current0 = [ -'general.xml#Description', -'general.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-2018.00.00.0/doc/get_adolc.sh.xml cppad-2019.02.00.0/doc/get_adolc.sh.xml --- cppad-2018.00.00.0/doc/get_adolc.sh.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/get_adolc.sh.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,154 +0,0 @@ - - - -Download and Install Adolc in Build Directory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -get_adolc.sh - -

- - - -
Download and Install Adolc in Build Directory
-
-Syntax - -
-bin/get_adolc.sh
- -
-
-Purpose -
-If you are using Unix, this command will download and install -ADOL-C - in the -CppAD build directory. - -
-
-Requirements -
-You must first use get_colpack.sh - to download and install -ColPack (coloring algorithms used for sparse matrix derivatives). - -
-
-Distribution Directory -
-This command must be executed in the -distribution directory -. - -
-
-External Directory -
-The Adolc source code is downloaded into the sub-directory -build/external below the distribution directory. - -
-
-Prefix Directory -
-The Adolc include files are installed in the sub-directory -build/prefix/include/adolc below the distribution directory. - -
-
-Reuse -
-The files -build/external/ADOL-C-version.tgz - -and the directory -build/external/ADOL-C-version - -will be reused if they exist. Delete this file and directory -to get a complete rebuild. - - -
Input File: bin/get_adolc.sh - - - diff -Nru cppad-2018.00.00.0/doc/_get_adolc.sh_xml.js cppad-2019.02.00.0/doc/_get_adolc.sh_xml.js --- cppad-2018.00.00.0/doc/_get_adolc.sh_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_get_adolc.sh_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +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', -'adolc_prefix.xml', -'get_adolc.sh.xml' -]; -var list_down3 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.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 = [ -'get_adolc.sh.xml' -]; -var list_current0 = [ -'get_adolc.sh.xml#Syntax', -'get_adolc.sh.xml#Purpose', -'get_adolc.sh.xml#Requirements', -'get_adolc.sh.xml#Distribution Directory', -'get_adolc.sh.xml#External Directory', -'get_adolc.sh.xml#Prefix Directory', -'get_adolc.sh.xml#Reuse' -]; -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-2018.00.00.0/doc/get_colpack.sh.xml cppad-2019.02.00.0/doc/get_colpack.sh.xml --- cppad-2018.00.00.0/doc/get_colpack.sh.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/get_colpack.sh.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ - - - -Download and Install ColPack in Build Directory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -get_colpack.sh - -

-
Download and Install ColPack in Build Directory
-
-Syntax - -
-bin/get_colpack.sh
- -
-
-Purpose -
-If you are using Unix, this command will download and install -ColPack - in the -CppAD build directory. - -
-
-Distribution Directory -
-This command must be executed in the -distribution directory -. - -
-
-External Directory -
-The ColPack source code is downloaded into the sub-directory -build/external below the distribution directory. - -
-
-Prefix Directory -
-The ColPack include files are installed in the sub-directory -build/prefix/include/ColPack below the distribution directory. - -
-
-Reuse -
-The file -build/external/ColPack-version.tar.gz - -and the directory -build/external/ColPack-version - -will be reused if they exist. Delete this file and directory -to get a complete rebuild. - - -
Input File: bin/get_colpack.sh - - - diff -Nru cppad-2018.00.00.0/doc/_get_colpack.sh_xml.js cppad-2019.02.00.0/doc/_get_colpack.sh_xml.js --- cppad-2018.00.00.0/doc/_get_colpack.sh_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_get_colpack.sh_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', -'install.xml', -'cmake.xml', -'colpack_prefix.xml', -'get_colpack.sh.xml' -]; -var list_down3 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.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_jacobian.cpp.xml', -'colpack_hes.cpp.xml', -'colpack_hessian.cpp.xml', -'get_colpack.sh.xml' -]; -var list_current0 = [ -'get_colpack.sh.xml#Syntax', -'get_colpack.sh.xml#Purpose', -'get_colpack.sh.xml#Distribution Directory', -'get_colpack.sh.xml#External Directory', -'get_colpack.sh.xml#Prefix Directory', -'get_colpack.sh.xml#Reuse' -]; -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-2018.00.00.0/doc/get_eigen.sh.xml cppad-2019.02.00.0/doc/get_eigen.sh.xml --- cppad-2018.00.00.0/doc/get_eigen.sh.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/get_eigen.sh.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ - - - -Download and Install Eigen in Build Directory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -get_eigen.sh - -

- - - -
Download and Install Eigen in Build Directory
-
-Syntax - -
-bin/get_eigen.sh
- -
-
-Purpose -
-If you are using Unix, this command will download and install -Eigen - in the -CppAD build directory. - -
-
-Distribution Directory -
-This command must be executed in the -distribution directory -. - -
-
-External Directory -
-The Eigen source code is downloaded into the sub-directory -build/external below the distribution directory. - -
-
-Prefix Directory -
-The Eigen include files are installed in the sub-directory -build/prefix/include/Eigen below the distribution directory. - -
-
-Reuse -
-The file -build/external/eigen-version.tar.gz - -and the directory -build/external/eigen-version - -will be reused if they exist. Delete this file and directory -to get a complete rebuild. - - -
Input File: bin/get_eigen.sh - - - diff -Nru cppad-2018.00.00.0/doc/_get_eigen.sh_xml.js cppad-2019.02.00.0/doc/_get_eigen.sh_xml.js --- cppad-2018.00.00.0/doc/_get_eigen.sh_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_get_eigen.sh_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +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', -'eigen_prefix.xml', -'get_eigen.sh.xml' -]; -var list_down3 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.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 = [ -'get_eigen.sh.xml' -]; -var list_current0 = [ -'get_eigen.sh.xml#Syntax', -'get_eigen.sh.xml#Purpose', -'get_eigen.sh.xml#Distribution Directory', -'get_eigen.sh.xml#External Directory', -'get_eigen.sh.xml#Prefix Directory', -'get_eigen.sh.xml#Reuse' -]; -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-2018.00.00.0/doc/get_fadbad.sh.xml cppad-2019.02.00.0/doc/get_fadbad.sh.xml --- cppad-2018.00.00.0/doc/get_fadbad.sh.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/get_fadbad.sh.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,131 +0,0 @@ - - - -Download and Install Fadbad in Build Directory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -get_fadbad.sh - -

- - - -
Download and Install Fadbad in Build Directory
-
-Syntax - -
-bin/get_fadbad.sh
- -
-
-Purpose -
-If you are using Unix, this command will download and install -Fadbad - in the -CppAD build directory. - -
-
-Distribution Directory -
-This command must be executed in the -distribution directory -. - -
-
-External Directory -
-The Fadbad source code is downloaded into the sub-directory -build/external below the distribution directory. - -
-
-Prefix Directory -
-The Fadbad include files are installed in the sub-directory -build/prefix/include/FADBAD++ below the distribution directory. - - -
Input File: bin/get_fadbad.sh - - - diff -Nru cppad-2018.00.00.0/doc/_get_fadbad.sh_xml.js cppad-2019.02.00.0/doc/_get_fadbad.sh_xml.js --- cppad-2018.00.00.0/doc/_get_fadbad.sh_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_get_fadbad.sh_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +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', -'fadbad_prefix.xml', -'get_fadbad.sh.xml' -]; -var list_down3 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.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 = [ -'get_fadbad.sh.xml' -]; -var list_current0 = [ -'get_fadbad.sh.xml#Syntax', -'get_fadbad.sh.xml#Purpose', -'get_fadbad.sh.xml#Distribution Directory', -'get_fadbad.sh.xml#External Directory', -'get_fadbad.sh.xml#Prefix Directory' -]; -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-2018.00.00.0/doc/get_ipopt.sh.xml cppad-2019.02.00.0/doc/get_ipopt.sh.xml --- cppad-2018.00.00.0/doc/get_ipopt.sh.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/get_ipopt.sh.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ - - - -Download and Install Ipopt in Build Directory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -get_ipopt.sh - -

- - - -
Download and Install Ipopt in Build Directory
-
-Syntax - -
-bin/get_ipopt.sh
- -
-
-Purpose -
-If you are using Unix, this command will download and install -Ipopt - in the -CppAD build directory. - -
-
-Distribution Directory -
-This command must be executed in the -distribution directory -. - -
-
-External Directory -
-The Ipopt source code is downloaded and compiled in the sub-directory -build/external below the distribution directory. - -
-
-Prefix Directory -
-The Ipopt libraries and include files are installed in the sub-directory -build/prefix below the distribution directory. - -
-
-Reuse -
-The file -build/external/Ipopt-version.tgz - -and the directory -build/external/Ipopt-version - -will be reused if they exist. Delete this file and directory -to get a complete rebuild. - - -
Input File: bin/get_ipopt.sh - - - diff -Nru cppad-2018.00.00.0/doc/_get_ipopt.sh_xml.js cppad-2019.02.00.0/doc/_get_ipopt.sh_xml.js --- cppad-2018.00.00.0/doc/_get_ipopt.sh_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_get_ipopt.sh_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +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', -'ipopt_prefix.xml', -'get_ipopt.sh.xml' -]; -var list_down3 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.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 = [ -'get_ipopt.sh.xml' -]; -var list_current0 = [ -'get_ipopt.sh.xml#Syntax', -'get_ipopt.sh.xml#Purpose', -'get_ipopt.sh.xml#Distribution Directory', -'get_ipopt.sh.xml#External Directory', -'get_ipopt.sh.xml#Prefix Directory', -'get_ipopt.sh.xml#Reuse' -]; -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-2018.00.00.0/doc/get_sacado.sh.xml cppad-2019.02.00.0/doc/get_sacado.sh.xml --- cppad-2018.00.00.0/doc/get_sacado.sh.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/get_sacado.sh.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ - - - -Download and Install Sacado in Build Directory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -get_sacado.sh - -

- - - -
Download and Install Sacado in Build Directory
-
-Syntax - -
-bin/get_sacado.sh
- -
-
-Purpose -
-If you are using Unix, this command will download and install -Sacado - in the -CppAD build directory. - -
-
-Distribution Directory -
-This command must be executed in the -distribution directory -. - -
-
-External Directory -
-The Sacado source code is downloaded into the sub-directory -build/external below the distribution directory. - -
-
-Prefix Directory -
-The Sacado libraries and include files are installed in the sub-directory -build/prefix below the distribution directory. - -
-
-Reuse -
-The file -build/external/trilinos-version-Source.tar.gz - -and the directory -build/external/trilinos-version-Source - -will be reused if they exist. Delete this file and directory -to get a complete rebuild. - - -
Input File: bin/get_sacado.sh - - - diff -Nru cppad-2018.00.00.0/doc/_get_sacado.sh_xml.js cppad-2019.02.00.0/doc/_get_sacado.sh_xml.js --- cppad-2018.00.00.0/doc/_get_sacado.sh_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_get_sacado.sh_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +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', -'sacado_prefix.xml', -'get_sacado.sh.xml' -]; -var list_down3 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.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 = [ -'get_sacado.sh.xml' -]; -var list_current0 = [ -'get_sacado.sh.xml#Syntax', -'get_sacado.sh.xml#Purpose', -'get_sacado.sh.xml#Distribution Directory', -'get_sacado.sh.xml#External Directory', -'get_sacado.sh.xml#Prefix Directory', -'get_sacado.sh.xml#Reuse' -]; -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-2018.00.00.0/doc/get_started.cpp.xml cppad-2019.02.00.0/doc/get_started.cpp.xml --- cppad-2018.00.00.0/doc/get_started.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/get_started.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,470 +0,0 @@ - - - -Getting Started Using CppAD to Compute Derivatives - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -get_started.cpp - -

-
Getting Started Using CppAD to Compute Derivatives
-
-Purpose -
-Demonstrate the use of CppAD by computing the derivative -of a simple example function. - -
-
-Function -
-The example function - -f -: -R - - -R - - - - is defined by - - -f -( -x -) -= -a -0 - -+ -a -1 - -* -x -1 - -+ - -+ -a -k --1 - - -* -x -k --1 - - - - -where -a - is a fixed vector of length -k -. - -
-
-Derivative -
-The derivative of - -f -( -x -) - - - is given by - - -f -' -( -x -) -= -a -1 - -+ -2 -* -a -2 - -* -x -+ - -+ -( -k --1 -) -* -a -k --1 - - -* -x -k --2 - - - - -
-Value -
-For the particular case in this example, - - -k - - - is equal to 5, - - -a -= -( -1 -, -1 -, -1 -, -1 -, -1 -) - - -, and - - -x -= -3 - - -. -If follows that - - -f -' -( -3 -) -= -1 -+ -2 -* -3 -+ -3 -* -3 -2 - -+ -4 -* -3 -3 - -= -142 - - -
-Poly -
-The routine Poly is defined below for this particular application. -A general purpose polynomial evaluation routine is documented and -distributed with CppAD (see Poly -). - -
-
-Exercises -
-Modify the program below to accomplish the following tasks -using CppAD: -
  1. -Compute and print the derivative of - -f -( -x -) -= -1 -+ -x -+ -x -2 - -+ -x -3 - -+ -x -4 - - - - -at the point - -x -= -2 - - -. -
  2. - -Compute and print the derivative of - -f -( -x -) -= -1 -+ -x -+ -x -2 - -/ -2 - - - -at the point - -x -= -.5 - - -. -
  3. - -Compute and print the derivative of - -f -( -x -) -= -exp -( -x -) -- -1 -- -x -- -x -2 - -/ -2 - - - -at the point - -x -= -.5 - - -. -
- - - -
-
-Program - -
#include <iostream>      // standard input/output
-#include <vector>        // standard vector
-#include <cppad/cppad.hpp> // the CppAD package http://www.coin-or.org/CppAD/
-
-namespace {
-      // define y(x) = Poly(a, x) in the empty namespace
-      template <class Type>
-      Type Poly(const std::vector<double> &a, const Type &x)
-      {     size_t k  = a.size();
-            Type y   = 0.;  // initialize summation
-            Type x_i = 1.;  // initialize x^i
-            size_t i;
-            for(i = 0; i < k; i++)
-            {     y   += a[i] * x_i;  // y   = y + a_i * x^i
-                  x_i *= x;           // x_i = x_i * x
-            }
-            return y;
-      }
-}
-// main program
-int main(void)
-{     using CppAD::AD;           // use AD as abbreviation for CppAD::AD
-      using std::vector;         // use vector as abbreviation for std::vector
-      size_t i;                  // a temporary index
-
-      // vector of polynomial coefficients
-      size_t k = 5;              // number of polynomial coefficients
-      vector<double> a(k);       // vector of polynomial coefficients
-      for(i = 0; i < k; i++)
-            a[i] = 1.;           // value of polynomial coefficients
-
-      // domain space vector
-      size_t n = 1;              // number of domain space variables
-      vector< AD<double> > X(n); // vector of domain space variables
-      X[0] = 3.;                 // value corresponding to operation sequence
-
-      // declare independent variables and start recording operation sequence
-      CppAD::Independent(X);
-
-      // range space vector
-      size_t m = 1;              // number of ranges space variables
-      vector< AD<double> > Y(m); // vector of ranges space variables
-      Y[0] = Poly(a, X[0]);      // value during recording of operations
-
-      // store operation sequence in f: X -> Y and stop recording
-      CppAD::ADFun<double> f(X, Y);
-
-      // compute derivative using operation sequence stored in f
-      vector<double> jac(m * n); // Jacobian of f (m by n matrix)
-      vector<double> x(n);       // domain space vector
-      x[0] = 3.;                 // argument value for derivative
-      jac  = f.Jacobian(x);      // Jacobian for operation sequence
-
-      // print the results
-      std::cout << "f'(3) computed by CppAD = " << jac[0] << std::endl;
-
-      // check if the derivative is correct
-      int error_code;
-      if( jac[0] == 142. )
-            error_code = 0;      // return code for correct case
-      else  error_code = 1;      // return code for incorrect case
-
-      return error_code;
-}
-
-Output -
-Executing the program above will generate the following output: -
 
-     f'(3) computed by CppAD = 142
-
-
-Running -
-To build and run this program see cmake_check -. - - -
Input File: example/get_started/get_started.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_get_started.cpp_xml.js cppad-2019.02.00.0/doc/_get_started.cpp_xml.js --- cppad-2018.00.00.0/doc/_get_started.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_get_started.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'example.xml', -'get_started.cpp.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_current0 = [ -'get_started.cpp.xml#Purpose', -'get_started.cpp.xml#Function', -'get_started.cpp.xml#Derivative', -'get_started.cpp.xml#Value', -'get_started.cpp.xml#Poly', -'get_started.cpp.xml#Exercises', -'get_started.cpp.xml#Program', -'get_started.cpp.xml#Output', -'get_started.cpp.xml#Running' -]; -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-2018.00.00.0/doc/glossary.xml cppad-2019.02.00.0/doc/glossary.xml --- cppad-2018.00.00.0/doc/glossary.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/glossary.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,991 +0,0 @@ - - - -Glossary - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -glossary - -

- - - - -
Glossary
-
-AD Function -
-Given an ADFun - object -f - -there is a corresponding -AD of -Base - operation sequence -. -This operation sequence -defines a function - - -F -: -B -n - - -B -m - - - - -where -B - is the space corresponding to objects of type -Base -, - -n - is the size of the domain - space, and - -m - is the size of the range - space. -We refer to - -F - - - as the AD function corresponding to -the operation sequence stored in the object -f -. -(See the FunCheck discussion - for -possible differences between - -F -( -x -) - - - and the algorithm that defined -the operation sequence.) - -
-
-AD of Base -
-An object is called an AD of -Base - object its type is -either -AD<Base> - -(see the default and copy constructors - -or -VecAD<Base>::reference - (see VecAD -) -for some -Base - type. - -
-
-AD Type Above Base -
-If -Base - is a type, -an AD type above -Base - -is the following sequence of types: - -
-     AD<
Base, AD< AD<Base> > , AD< AD< AD<Base> > > , ...
-
-
-Base Function -
-A function - -f -: -B - -B - - - -is referred to as a -Base - function, -if -Base - is a C++ type that represent elements of -the domain and range space of -f -; i.e. elements of - -B - - -. - -
-
-Base Type -
-If -x - is an -AD<Base> - object, - -Base - is referred to as the base type for -x -. - -
-
-Elementary Vector -
-The j-th elementary vector - -e -j - - -B -m - - - - is defined by - - -e -i -j - -= -{ -1 - -if - - -i -= -j - -0 - -otherwise - - - - - -
-Operation - - -
-
-Atomic -
-An atomic -Type - operation is an operation that -has a -Type - result and is not made up of other -more basic operations. - -
-
-Sequence -
-A sequence of atomic -Type - operations -is called a -Type - operation sequence. -A sequence of atomic AD of Base - operations -is referred to as an AD of -Base - operation sequence. -The abbreviated notation AD operation sequence is often used -when it is not necessary to specify the base type. - -
-
-Dependent -
-Suppose that -x - and -y - are -Type - objects and -the result of - -
-     
x < y
-
-has type bool (where -Type - is not the same as bool). -If one executes the following code - -
-     if( 
x < y )
-          
y = cos(x);
-     else 
y = sin(x);
-
-the choice above depends on the value of -x - and -y - -and the two choices result in a different -Type - operation sequence. -In this case, we say that the -Type - operation sequence depends -on -x - and -y -. - -
-
-Independent -
-Suppose that -i - and -n - are size_t objects, -and -x[i] -, -y - are -Type - objects, -where -Type - is different from size_t. -The -Type - sequence of operations corresponding to - -
-     
y = Type(0);
-     for(
i = 0; i < ni++)
-          
y += x[i];
-
-does not depend on the value of -x - or -y -. -In this case, we say that the -Type - operation sequence -is independent of -y - and the elements of -x -. - -
-
-Parameter -
-All -Base - objects are parameters. -An -AD<Base> - object -u - is currently a parameter if -its value does not depend on the value of -an Independent - variable vector for an -active tape -. -If -u - is a parameter, the function -Parameter(u) - returns true -and Variable(u) - returns false. - -
-
-Row-major Representation -
-A SimpleVector - -v - is a row-major representation of a matrix - - -M - -R - -m -× -n - - - - - if -v.size() == m * n - and -for - -i -= -0 -, - -, -m --1 - - -, - -j -= -0 -, - -, -n --1 - - - - - -M -i -, -j - - -= -v -[ -i -× -n -+ -j -] - - -
-Sparsity Pattern -
-Suppose that - -A - -B -m -× -n - - - - - is a sparse matrix. -CppAD has several ways to specify the elements of - -A - - - -that are possible non-zero. - -
-
-Row and Column Index Vectors -
-A pair of non-negative integer vectors - -r - - -, - -c - - - -are a sparsity pattern for - -A - - - -if for every non-zero element - -A -i -, -j - - - - -, -there is a - -k - - - such that - -i -= -r -k - - - - and - -j -= -c -k - - - -. -Furthermore, for every - - -! -= -k - - -, -either - -r - - -! -= -r -k - - - - or - -c - - -! -= -c -k - - - -. - -
-
-Boolean Vector -
-A boolean vector - -b - - -, of length - -m -n - - -, -is a sparsity pattern for - -A - - - -if for every non-zero element - -A -i -, -j - - - - -, - - -b -i -n -+ -j - - - - - is true. - -
-
-Vector of Sets -
-A vector of sets - -s - - - of positive integers, of length - -m - - -, -is a sparsity pattern for - -A - - - -if for every non-zero element - -A -i -, -j - - - - -, - -j - -s -k - - - -. - - -
-
-Tape - - -
-
-Active -
-A new tape is created and becomes active -after each call of the form (see Independent -) - -
-     Independent(
x)
-
-All operations that depend on the elements of -x - are -recorded on this active tape. - -
-
-Inactive -
-The -operation sequence - -stored in a tape must be transferred to a function object using the syntax -(see ADFun<Base> f(x, y) -) - -
-     ADFun<
Basefxy)
-
-or using the syntax (see f.Dependent(x, y) -) - -
-     
f.Dependent( xy)
-
-After such a transfer, the tape becomes inactive. - -
-
-Independent Variable -
-While the tape is active, we refer to the elements of -x - -as the independent variables for the tape. -When the tape becomes inactive, -the corresponding objects become -parameters -. - -
-
-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 -parameters -. - - -
-
-Taylor Coefficient -
-Suppose - -X -: -B - -B -n - - - - is a -is - -p - - - times continuously differentiable function -in some neighborhood of zero. -For - -k -= -0 -, - -, -p - - -, -we use the column vector - -x -( -k -) - - - -B -n - - - - for the k-th order -Taylor coefficient corresponding to - -X - - - -which is defined by - - -x -( -k -) - - -= -1 - -k -! - - - -k - - - - -t - -k - - - - -X -( -0 -) - - -It follows that - - -X -( -t -) -= -x -( -0 -) - - -+ -x -( -1 -) - - -t -+ - -+ -x -( -p -) - - -t -p - -+ -R -( -t -) - - -where the remainder - -R -( -t -) - - - divided by - -t -p - - - - -converges to zero and - -t - - - goes to zero. - - -
-
-Variable -
-An -AD<Base> - object -u - is a variable if -its value depends on an independent variable vector for -a currently active tape -. -If -u - is a variable, -Variable(u) - returns true and -Parameter(u) - returns false. -For example, -directly after the code sequence - -
-     Independent(
x);
-     AD<double> 
u = x[0];
-
-the -AD<double> - object -u - is currently a variable. -Directly after the code sequence - -
-     Independent(
x);
-     AD<double> 
u = x[0];
-     
u = 5;
-
- -u - is currently a parameter - -(not a variable). -
-
-
Note that we often drop the word currently and -just refer to an -AD<Base> - object as a variable -or parameter. - - -
Input File: omh/appendix/glossary.omh - - - diff -Nru cppad-2018.00.00.0/doc/_glossary_xml.js cppad-2019.02.00.0/doc/_glossary_xml.js --- cppad-2018.00.00.0/doc/_glossary_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_glossary_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'glossary.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', -'directory.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 = [ -'glossary.xml#AD Function', -'glossary.xml#AD of Base', -'glossary.xml#AD Type Above Base', -'glossary.xml#Base Function', -'glossary.xml#Base Type', -'glossary.xml#Elementary Vector', -'glossary.xml#Operation', -'glossary.xml#Operation.Atomic', -'glossary.xml#Operation.Sequence', -'glossary.xml#Operation.Dependent', -'glossary.xml#Operation.Independent', -'glossary.xml#Parameter', -'glossary.xml#Row-major Representation', -'glossary.xml#Sparsity Pattern', -'glossary.xml#Sparsity Pattern.Row and Column Index Vectors', -'glossary.xml#Sparsity Pattern.Boolean Vector', -'glossary.xml#Sparsity Pattern.Vector of Sets', -'glossary.xml#Tape', -'glossary.xml#Tape.Active', -'glossary.xml#Tape.Inactive', -'glossary.xml#Tape.Independent Variable', -'glossary.xml#Tape.Dependent Variables', -'glossary.xml#Taylor Coefficient', -'glossary.xml#Variable' -]; -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-2018.00.00.0/doc/harmonic_common.xml cppad-2019.02.00.0/doc/harmonic_common.xml --- cppad-2018.00.00.0/doc/harmonic_common.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/harmonic_common.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ - - - -Common Variables Used by Multi-threading Sum of 1/i - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -harmonic_common - -

-
Common Variables Used by Multi-threading Sum of 1/i
-
-Purpose -
-This source code defines the common -include files, defines, and variables that are used by -the summation that defines the harmonic series - - -1 -+ -1 -/ -2 -+ -1 -/ -3 -+ -. -. -. -+ -1 -/ -n - - -
-Source - -

-
-
-# include <cppad/cppad.hpp>
-# include "harmonic.hpp"
-# include "team_thread.hpp"
-# define MAX_NUMBER_THREADS 48
-
-namespace {
-     using CppAD::thread_alloc; // fast multi-threadeding memory allocator
-
-     // Number of threads, set by previous call to harmonic_time
-     // (zero means one thread with no multi-threading setup)
-     size_t num_threads_ = 0;
-
-     // value of mega_sum, set by previous call to harmonic_time.
-     size_t mega_sum_;
-
-     // structure with information for one thread
-     typedef struct {
-          // index to start summation at (worker input)
-          // set by previous call to harmonic_setup
-          size_t start;
-          // index to end summation at (worker input)
-          // set by previous call to harmonic_setup
-          size_t stop;
-          // summation for this thread
-          // set by worker
-          double sum;
-          // false if an error occurs, true otherwise
-          // set by worker
-          bool   ok;
-     } work_one_t;
-
-     // vector with information for all threads
-     // (use pointers instead of values to avoid false sharing)
-     work_one_t* work_all_[MAX_NUMBER_THREADS];
-}
- -
Input File: example/multi_thread/harmonic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_harmonic_common_xml.js cppad-2019.02.00.0/doc/_harmonic_common_xml.js --- cppad-2018.00.00.0/doc/_harmonic_common_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_harmonic_common_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'harmonic.cpp.xml', -'harmonic_common.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'harmonic_common.xml', -'harmonic_setup.xml', -'harmonic_worker.xml', -'harmonic_takedown.xml', -'harmonic_sum.xml', -'harmonic_time.xml' -]; -var list_current0 = [ -'harmonic_common.xml#Purpose', -'harmonic_common.xml#Source' -]; -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-2018.00.00.0/doc/harmonic.cpp.xml cppad-2019.02.00.0/doc/harmonic.cpp.xml --- cppad-2018.00.00.0/doc/harmonic.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/harmonic.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ - - - -Multi-Threading Harmonic Summation Example / Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Multi-Threading Harmonic Summation Example / Test
-
-Source File -
-All of the routines below are located in the file -
 
-     example/multi_thread/harmonic.cpp
-
-
-Contents -
- -
harmonic_commonCommon Variables Used by Multi-threading Sum of 1/i
harmonic_setupSet Up Multi-threading Sum of 1/i
harmonic_workerDo One Thread's Work for Sum of 1/i
harmonic_takedownTake Down Multi-threading Sum of 1/i
harmonic_sumMulti-Threaded Implementation of Summation of 1/i
harmonic_timeTiming Test of Multi-Threaded Summation of 1/i
-
Input File: example/multi_thread/harmonic.omh - - - diff -Nru cppad-2018.00.00.0/doc/_harmonic.cpp_xml.js cppad-2019.02.00.0/doc/_harmonic.cpp_xml.js --- cppad-2018.00.00.0/doc/_harmonic.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_harmonic.cpp_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'harmonic.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down1 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down0 = [ -'harmonic_common.xml', -'harmonic_setup.xml', -'harmonic_worker.xml', -'harmonic_takedown.xml', -'harmonic_sum.xml', -'harmonic_time.xml' -]; -var list_current0 = [ -'harmonic.cpp.xml#Source File', -'harmonic.cpp.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-2018.00.00.0/doc/harmonic_setup.xml cppad-2019.02.00.0/doc/harmonic_setup.xml --- cppad-2018.00.00.0/doc/harmonic_setup.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/harmonic_setup.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,192 +0,0 @@ - - - -Set Up Multi-threading Sum of 1/i - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -harmonic_setup - -

-
Set Up Multi-threading Sum of 1/i
-
-Syntax - -
- -ok = harmonic_setup(num_sum)
-
-
-Purpose -
-This routine does the setup for splitting -the summation that defines the harmonic series - - -1 -+ -1 -/ -2 -+ -1 -/ -3 -+ -. -. -. -+ -1 -/ -n - - -into separate parts for each thread. - -
-
-Thread -
-It is assumed that this function is called by thread zero, -and all the other threads are blocked (waiting). - -
-
-num_sum -
-The argument -num_sum - has prototype - -
-     size_t 
num_sum
-
-It specifies the value of - -n - - - in the summation. - -
-
-Source - -

-namespace {
-bool harmonic_setup(size_t num_sum)
-{     // sum = 1/num_sum + 1/(num_sum-1) + ... + 1
-     size_t num_threads  = std::max(num_threads_, size_t(1));
-     bool ok             = num_threads == thread_alloc::num_threads();
-     ok                 &= thread_alloc::thread_num() == 0;
-     ok                 &= num_sum >= num_threads;
-     //
-     for(size_t thread_num = 0; thread_num < num_threads; thread_num++)
-     {     // allocate separate memory for this thread to avoid false sharing
-          size_t min_bytes(sizeof(work_one_t)), cap_bytes;
-          void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes);
-          work_all_[thread_num] = static_cast<work_one_t*>(v_ptr);
-          //
-          // in case this thread's worker does not get called
-          work_all_[thread_num]->ok = false;
-          // parameters that define the work for this and previous thread
-          if( thread_num == 0 )
-               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]->start  = index;
-          }
-     }
-     work_all_[num_threads-1]->stop = num_sum + 1;
-     return ok;
-}
-}
- -
Input File: example/multi_thread/harmonic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_harmonic_setup_xml.js cppad-2019.02.00.0/doc/_harmonic_setup_xml.js --- cppad-2018.00.00.0/doc/_harmonic_setup_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_harmonic_setup_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'harmonic.cpp.xml', -'harmonic_setup.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'harmonic_common.xml', -'harmonic_setup.xml', -'harmonic_worker.xml', -'harmonic_takedown.xml', -'harmonic_sum.xml', -'harmonic_time.xml' -]; -var list_current0 = [ -'harmonic_setup.xml#Syntax', -'harmonic_setup.xml#Purpose', -'harmonic_setup.xml#Thread', -'harmonic_setup.xml#num_sum', -'harmonic_setup.xml#Source' -]; -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-2018.00.00.0/doc/harmonic_sum.xml cppad-2019.02.00.0/doc/harmonic_sum.xml --- cppad-2018.00.00.0/doc/harmonic_sum.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/harmonic_sum.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,211 +0,0 @@ - - - -Multi-Threaded Implementation of Summation of 1/i - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -harmonic_sum - -

-
Multi-Threaded Implementation of Summation of 1/i
-
-Syntax - -
- -ok = harmonic_sum(sumnum_sum) - - -
-
-Purpose -
-Multi-threaded computation of the summation that defines the harmonic series - - -s -= -1 -+ -1 -/ -2 -+ -1 -/ -3 -+ -. -. -. -+ -1 -/ -n - - -
-Thread -
-It is assumed that this function is called by thread zero, -and all the other threads are blocked (waiting). - -
-
-ok -
-This return value has prototype - -
-     bool 
ok
-
-If this return value is false, an error occurred during harmonic. - -
-
-sum -
-This argument has prototype - -
-     double& 
sum
-
-The input value of the argument does not matter. -Upon return it is the value of the summation; i.e. - -s - - -. - -
-
-num_sum -
-This argument has prototype - -
-     size_t 
num_sum
-
-It specifies the number of terms in the summation; i.e. - -n - - -. - -
-
-Source - -

-namespace {
-bool harmonic_sum(double& sum, size_t num_sum)
-{     // sum = 1/num_sum + 1/(num_sum-1) + ... + 1
-     bool ok = true;
-     ok     &= thread_alloc::thread_num() == 0;
-
-     // setup the work for multi-threading
-     ok &= harmonic_setup(num_sum);
-
-     // now do the work for each thread
-     if( num_threads_ > 0 )
-          team_work( harmonic_worker );
-     else     harmonic_worker();
-
-     // combine the result for each thread and takedown the multi-threading.
-     ok &= harmonic_takedown(sum);
-
-     return ok;
-}
-}
- -
Input File: example/multi_thread/harmonic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_harmonic_sum_xml.js cppad-2019.02.00.0/doc/_harmonic_sum_xml.js --- cppad-2018.00.00.0/doc/_harmonic_sum_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_harmonic_sum_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'harmonic.cpp.xml', -'harmonic_sum.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'harmonic_common.xml', -'harmonic_setup.xml', -'harmonic_worker.xml', -'harmonic_takedown.xml', -'harmonic_sum.xml', -'harmonic_time.xml' -]; -var list_current0 = [ -'harmonic_sum.xml#Syntax', -'harmonic_sum.xml#Purpose', -'harmonic_sum.xml#Thread', -'harmonic_sum.xml#ok', -'harmonic_sum.xml#sum', -'harmonic_sum.xml#num_sum', -'harmonic_sum.xml#Source' -]; -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-2018.00.00.0/doc/harmonic_takedown.xml cppad-2019.02.00.0/doc/harmonic_takedown.xml --- cppad-2018.00.00.0/doc/harmonic_takedown.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/harmonic_takedown.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,196 +0,0 @@ - - - -Take Down Multi-threading Sum of 1/i - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -harmonic_takedown - -

-
Take Down Multi-threading Sum of 1/i
-
-Syntax - -
- -ok = harmonic_takedown(sum)
-
-
-Purpose -
-This routine does the takedown for splitting -the summation that defines the harmonic series - - -s -= -1 -+ -1 -/ -2 -+ -1 -/ -3 -+ -. -. -. -+ -1 -/ -n - - -into separate parts for each thread; see harmonic_setup -. - -
-
-Thread -
-It is assumed that this function is called by thread zero, -and all the other threads have completed their work and are blocked (waiting). - -
-
-sum -
-This argument has prototype - -
-     double& 
sum
-
-The input value of the argument does not matter. -Upon return it is the value of the summation; i.e. - -s - - -. - -
-
-Source - -

-namespace {
-bool harmonic_takedown(double& sum)
-{     // sum = 1/num_sum + 1/(num_sum-1) + ... + 1
-     bool ok            = true;
-     ok                &= thread_alloc::thread_num() == 0;
-     size_t num_threads = std::max(num_threads_, size_t(1));
-     sum                = 0.;
-     //
-     // go down so that free memory for other threads before memory for master
-     size_t thread_num = num_threads;
-     while(thread_num--)
-     {     // check that this tread was ok with the work it did
-          ok  &= work_all_[thread_num]->ok;
-          //
-          // add this threads contribution to the sum
-          sum += work_all_[thread_num]->sum;
-          //
-          // delete problem specific information
-          void* v_ptr = static_cast<void*>( work_all_[thread_num] );
-          thread_alloc::return_memory( v_ptr );
-          //
-          // check that there is no longer any memory inuse by this thread
-          // (for general applications, the master might still be using memory)
-          ok &= thread_alloc::inuse(thread_num) == 0;
-          //
-          // return all memory being held for future use by this thread
-          thread_alloc::free_available(thread_num);
-     }
-     return ok;
-}
-}
- -
Input File: example/multi_thread/harmonic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_harmonic_takedown_xml.js cppad-2019.02.00.0/doc/_harmonic_takedown_xml.js --- cppad-2018.00.00.0/doc/_harmonic_takedown_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_harmonic_takedown_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'harmonic.cpp.xml', -'harmonic_takedown.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'harmonic_common.xml', -'harmonic_setup.xml', -'harmonic_worker.xml', -'harmonic_takedown.xml', -'harmonic_sum.xml', -'harmonic_time.xml' -]; -var list_current0 = [ -'harmonic_takedown.xml#Syntax', -'harmonic_takedown.xml#Purpose', -'harmonic_takedown.xml#Thread', -'harmonic_takedown.xml#sum', -'harmonic_takedown.xml#Source' -]; -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-2018.00.00.0/doc/harmonic_time.xml cppad-2019.02.00.0/doc/harmonic_time.xml --- cppad-2018.00.00.0/doc/harmonic_time.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/harmonic_time.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,315 +0,0 @@ - - - -Timing Test of Multi-Threaded Summation of 1/i - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -harmonic_time - -

-
Timing Test of Multi-Threaded Summation of 1/i
-
-Syntax - -
- -ok = harmonic_time(
-     
time_outtest_timenum_threadsmega_sum
-)
- - -
-
-Purpose -
-Runs a correctness and timing test for a multi-threaded -computation of the summation that defines the harmonic series - - -1 -+ -1 -/ -2 -+ -1 -/ -3 -+ -. -. -. -+ -1 -/ -n - - -
-Thread -
-It is assumed that this function is called by thread zero in sequential -mode; i.e., not in_parallel -. - -
-
-ok -
-This return value has prototype - -
-     bool 
ok
-
-If it is true, -harmonic_time passed the correctness test. -Otherwise it is false. - -
-
-time_out -
-This argument has prototype - -
-     double& 
time_out
-
-The input value of the argument does not matter. -Upon return it is the number of wall clock seconds required for -to compute the summation. - -
-
-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. -The reported -time_out - is the total wall clock time divided by the -number of repeats. - -
-
-num_threads -
-This argument has prototype - -
-     size_t 
num_threads
-
-It specifies the number of threads that are available for this test. -If it is zero, the test is run without the multi-threading environment and - -
-     1 == thread_alloc::num_threads()
-
-when harmonic_time is called. -If it is non-zero, the test is run with the multi-threading and - -
-     
num_threads = thread_alloc::num_threads()
-
-when harmonic_time is called. - -
-
-mega_sum -
-This argument has prototype - -
-     size_t& 
mega_sum
-
-and is greater than zero. -The value - -n - - - in the summation -is equal to - -10 -6 - - - - times -mega_sum -. - -
-
-Source - -

-# include <cstring>
-# include <limits>
-# include <iostream>
-# include <cstdlib>
-# include <algorithm>
-
-// Note there is no mention of parallel mode in the documentation for
-// speed_test (so it is safe to use without special consideration).
-# include <cppad/utility/time_test.hpp>
-
-namespace {
-     // value of sum resulting from most recent call to test_once
-     double sum_ = 0.;
-     //
-     void test_once(void)
-     {     if( mega_sum_ < 1 )
-          {     std::cerr << "harmonic_time: mega_sum < 1" << std::endl;
-               exit(1);
-          }
-          size_t num_sum = mega_sum_ * 1000000;
-          bool ok = harmonic_sum(sum_, num_sum);
-          if( ! ok )
-          {     std::cerr << "harmonic: error" << std::endl;
-               exit(1);
-          }
-          return;
-     }
-     //
-     void test_repeat(size_t repeat)
-     {     size_t i;
-          for(i = 0; i < repeat; i++)
-               test_once();
-          return;
-     }
-}
-
-// This is the only routine that is accessible outside of this file
-bool harmonic_time(
-     double& time_out, double test_time, size_t num_threads, size_t mega_sum)
-{     bool ok  = true;
-     ok      &= thread_alloc::thread_num() == 0;
-
-     // arguments passed to harmonic_sum
-     num_threads_ = num_threads;
-     mega_sum_    = mega_sum;
-
-     // create team of threads
-     ok &= thread_alloc::in_parallel() == false;
-     if( num_threads > 0 )
-     {     team_create(num_threads);
-          ok &= num_threads == thread_alloc::num_threads();
-     }
-     else
-     {     ok &= 1 == thread_alloc::num_threads();
-     }
-
-     // run the test case and set the time return value
-     time_out = CppAD::time_test(test_repeat, test_time);
-
-     // destroy team of threads
-     if( num_threads > 0 )
-          team_destroy();
-     ok &= thread_alloc::in_parallel() == false;
-
-     // Correctness check
-     double eps1000 =
-          double(mega_sum_) * 1e3 * std::numeric_limits<double>::epsilon();
-     size_t i       = mega_sum_ * 1000000;
-     double check = 0.;
-     while(i)
-          check += 1. / double(i--);
-     ok &= std::fabs(sum_ - check) <= eps1000;
-
-     return ok;
-}
-
- -
Input File: example/multi_thread/harmonic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_harmonic_time_xml.js cppad-2019.02.00.0/doc/_harmonic_time_xml.js --- cppad-2018.00.00.0/doc/_harmonic_time_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_harmonic_time_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'harmonic.cpp.xml', -'harmonic_time.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'harmonic_common.xml', -'harmonic_setup.xml', -'harmonic_worker.xml', -'harmonic_takedown.xml', -'harmonic_sum.xml', -'harmonic_time.xml' -]; -var list_current0 = [ -'harmonic_time.xml#Syntax', -'harmonic_time.xml#Purpose', -'harmonic_time.xml#Thread', -'harmonic_time.xml#ok', -'harmonic_time.xml#time_out', -'harmonic_time.xml#test_time', -'harmonic_time.xml#num_threads', -'harmonic_time.xml#mega_sum', -'harmonic_time.xml#Source' -]; -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-2018.00.00.0/doc/harmonic_worker.xml cppad-2019.02.00.0/doc/harmonic_worker.xml --- cppad-2018.00.00.0/doc/harmonic_worker.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/harmonic_worker.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,166 +0,0 @@ - - - -Do One Thread's Work for Sum of 1/i - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -harmonic_worker - -

-
Do One Thread's Work for Sum of 1/i
-
-Syntax - -
- -harmonic_worker()
-
-
-Purpose -
-This routines computes the sum -the summation that defines the harmonic series - -
-     1/
start + 1/(start+1) + ... + 1/(end-1)
-
-
-start -
-This is the value of the harmonic_common - information - -
-     
start = work_all_[thread_num]->start
-
-
-end -
-This is the value of the harmonic_common - information - -
-     
end = work_all_[thread_num]->end
-
-
-thread_num -
-This is the number for the current thread; see -thread_num -. - -
-
-Source - -

-namespace {
-void harmonic_worker(void)
-{     // sum =  1/(stop-1) + 1/(stop-2) + ... + 1/start
-     size_t thread_num  = thread_alloc::thread_num();
-     size_t num_threads = std::max(num_threads_, size_t(1));
-     bool   ok          = thread_num < num_threads;
-     size_t start       = work_all_[thread_num]->start;
-     size_t stop        = work_all_[thread_num]->stop;
-     double sum         = 0.;
-
-     ok &= stop > start;
-     size_t i = stop;
-     while( i > start )
-     {     i--;
-          sum += 1. / double(i);
-     }
-
-     work_all_[thread_num]->sum = sum;
-     work_all_[thread_num]->ok  = ok;
-}
-}
- -
Input File: example/multi_thread/harmonic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_harmonic_worker_xml.js cppad-2019.02.00.0/doc/_harmonic_worker_xml.js --- cppad-2018.00.00.0/doc/_harmonic_worker_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_harmonic_worker_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'harmonic.cpp.xml', -'harmonic_worker.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'harmonic_common.xml', -'harmonic_setup.xml', -'harmonic_worker.xml', -'harmonic_takedown.xml', -'harmonic_sum.xml', -'harmonic_time.xml' -]; -var list_current0 = [ -'harmonic_worker.xml#Syntax', -'harmonic_worker.xml#Purpose', -'harmonic_worker.xml#start', -'harmonic_worker.xml#end', -'harmonic_worker.xml#thread_num', -'harmonic_worker.xml#Source' -]; -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-2018.00.00.0/doc/hes_lagrangian.cpp.xml cppad-2019.02.00.0/doc/hes_lagrangian.cpp.xml --- cppad-2018.00.00.0/doc/hes_lagrangian.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/hes_lagrangian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,297 +0,0 @@ - - - -Hessian of Lagrangian and ADFun Default Constructor: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -hes_lagrangian.cppHeadings

-
Hessian of Lagrangian and ADFun Default Constructor: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cassert>
-
-namespace {
-     CppAD::AD<double> Lagragian(
-          const CppAD::vector< CppAD::AD<double> > &xyz )
-     {     using CppAD::AD;
-          assert( xyz.size() == 6 );
-
-          AD<double> x0 = xyz[0];
-          AD<double> x1 = xyz[1];
-          AD<double> x2 = xyz[2];
-          AD<double> y0 = xyz[3];
-          AD<double> y1 = xyz[4];
-          AD<double> z  = xyz[5];
-
-          // compute objective function
-          AD<double> f = x0 * x0;
-          // compute constraint functions
-          AD<double> g0 = 1. + 2.*x1 + 3.*x2;
-          AD<double> g1 = log( x0 * x2 );
-          // compute the Lagragian
-          AD<double> L = y0 * g0 + y1 * g1 + z * f;
-
-          return L;
-
-     }
-     CppAD::vector< CppAD::AD<double> > fg(
-          const CppAD::vector< CppAD::AD<double> > &x )
-     {     using CppAD::AD;
-          using CppAD::vector;
-          assert( x.size() == 3 );
-
-          vector< AD<double> > fg(3);
-          fg[0] = x[0] * x[0];
-          fg[1] = 1. + 2. * x[1] + 3. * x[2];
-          fg[2] = log( x[0] * x[2] );
-
-          return fg;
-     }
-     bool CheckHessian(
-     CppAD::vector<double> H ,
-     double x0, double x1, double x2, double y0, double y1, double z )
-     {     using CppAD::NearEqual;
-          double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-          bool ok  = true;
-          size_t n = 3;
-          assert( H.size() == n * n );
-          /*
-          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_00 = 2 * z - y1 / ( x0 * x0 )
-          double check = 2. * z - y1 / (x0 * x0);
-          ok &= NearEqual(H[0 * n + 0], check, eps99, eps99);
-          // L_01 = L_10 = 0
-          ok &= NearEqual(H[0 * n + 1], 0., eps99, eps99);
-          ok &= NearEqual(H[1 * n + 0], 0., eps99, eps99);
-          // L_02 = L_20 = 0
-          ok &= NearEqual(H[0 * n + 2], 0., eps99, eps99);
-          ok &= NearEqual(H[2 * n + 0], 0., eps99, eps99);
-          // L_11 = 0
-          ok &= NearEqual(H[1 * n + 1], 0., eps99, eps99);
-          // L_12 = L_21 = 0
-          ok &= NearEqual(H[1 * n + 2], 0., eps99, eps99);
-          ok &= NearEqual(H[2 * n + 1], 0., eps99, eps99);
-          // L_22 = - y1 / (x2 * x2)
-          check = - y1 / (x2 * x2);
-          ok &= NearEqual(H[2 * n + 2], check, eps99, eps99);
-
-          return ok;
-     }
-     bool UseL()
-     {     using CppAD::AD;
-          using CppAD::vector;
-
-          // double values corresponding to x, y, and z vectors
-          double x0(.5), x1(1e3), x2(1), y0(2.), y1(3.), z(4.);
-
-          // domain space vector
-          size_t n = 3;
-          vector< AD<double> >  a_x(n);
-          a_x[0] = x0;
-          a_x[1] = x1;
-          a_x[2] = x2;
-
-          // declare a_x as independent variable vector and start recording
-          CppAD::Independent(a_x);
-
-          // vector including x, y, and z
-          vector< AD<double> > a_xyz(n + 2 + 1);
-          a_xyz[0] = a_x[0];
-          a_xyz[1] = a_x[1];
-          a_xyz[2] = a_x[2];
-          a_xyz[3] = y0;
-          a_xyz[4] = y1;
-          a_xyz[5] = z;
-
-          // range space vector
-          size_t m = 1;
-          vector< AD<double> >  a_L(m);
-          a_L[0] = Lagragian(a_xyz);
-
-          // create K: x -> L and stop tape recording.
-          // Use default ADFun construction for example purposes.
-          CppAD::ADFun<double> K;
-          K.Dependent(a_x, a_L);
-
-          // Operation sequence corresponding to K depends on
-          // value of y0, y1, and z. Must redo calculations above when
-          // y0, y1, or z changes.
-
-          // declare independent variable vector and Hessian
-          vector<double> x(n);
-          vector<double> H( n * n );
-
-          // point at which we are computing the Hessian
-          // (must redo calculations below each time x changes)
-          x[0] = x0;
-          x[1] = x1;
-          x[2] = x2;
-          H = K.Hessian(x, 0);
-
-          // check this Hessian calculation
-          return CheckHessian(H, x0, x1, x2, y0, y1, z);
-     }
-     bool Usefg()
-     {     using CppAD::AD;
-          using CppAD::vector;
-
-          // parameters defining problem
-          double x0(.5), x1(1e3), x2(1), y0(2.), y1(3.), z(4.);
-
-          // domain space vector
-          size_t n = 3;
-          vector< AD<double> >  a_x(n);
-          a_x[0] = x0;
-          a_x[1] = x1;
-          a_x[2] = x2;
-
-          // declare a_x as independent variable vector and start recording
-          CppAD::Independent(a_x);
-
-          // range space vector
-          size_t m = 3;
-          vector< AD<double> >  a_fg(m);
-          a_fg = fg(a_x);
-
-          // create K: x -> fg and stop tape recording
-          CppAD::ADFun<double> K;
-          K.Dependent(a_x, a_fg);
-
-          // 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
-          vector<double> x(n);
-          vector<double> H( n * n );
-          vector<double>  dx(n);
-          vector<double>   w(m);
-          vector<double>  dw(2*n);
-
-          // compute Hessian at this value of x
-          // (must redo calculations below each time x changes)
-          x[0] = x0;
-          x[1] = x1;
-          x[2] = x2;
-          K.Forward(0, x);
-
-          // set weights to Lagrange multiplier values
-          // (must redo calculations below each time y0, y1, or z changes)
-          w[0] = z;
-          w[1] = y0;
-          w[2] = y1;
-
-          // initialize dx as zero
-          size_t i, j;
-          for(i = 0; i < n; i++)
-               dx[i] = 0.;
-          // loop over components of x
-          for(i = 0; i < n; i++)
-          {     dx[i] = 1.;             // dx is i-th elementary vector
-               K.Forward(1, dx);       // partial w.r.t dx
-               dw = K.Reverse(2, w);   // deritavtive of partial
-               for(j = 0; j < n; j++)
-                    H[ i * n + j ] = dw[ j * 2 + 1 ];
-               dx[i] = 0.;             // dx is zero vector
-          }
-
-          // check this Hessian calculation
-          return CheckHessian(H, x0, x1, x2, y0, y1, z);
-     }
-}
-
-bool HesLagrangian(void)
-{     bool ok = true;
-
-     // UseL is simpler, but must retape every time that y of z changes
-     ok     &= UseL();
-
-     // Usefg does not need to retape unless operation sequence changes
-     ok     &= Usefg();
-     return ok;
-}
-
-
-
Input File: example/general/hes_lagrangian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_hes_lagrangian.cpp_xml.js cppad-2019.02.00.0/doc/_hes_lagrangian.cpp_xml.js --- cppad-2018.00.00.0/doc/_hes_lagrangian.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_hes_lagrangian.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'hessian.xml', -'hes_lagrangian.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down1 = [ -'hessian.cpp.xml', -'hes_lagrangian.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-2018.00.00.0/doc/hes_lu_det.cpp.xml cppad-2019.02.00.0/doc/hes_lu_det.cpp.xml --- cppad-2018.00.00.0/doc/hes_lu_det.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/hes_lu_det.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ - - - -Gradient of Determinant Using LU Factorization: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -hes_lu_det.cppHeadings

-
Gradient of Determinant Using LU Factorization: Example and Test
-
// Complex examples should supppress conversion warnings
-# include <cppad/wno_conversion.hpp>
-
-# include <cppad/cppad.hpp>
-# include <cppad/speed/det_by_lu.hpp>
-
-// The AD complex case is used by this example so must
-// define a specializatgion of LeqZero,AbsGeq for the AD<Complex> case
-namespace CppAD {
-     CPPAD_BOOL_BINARY( std::complex<double> ,  AbsGeq   )
-     CPPAD_BOOL_UNARY(  std::complex<double> ,  LeqZero )
-}
-
-
-bool HesLuDet(void)
-{     bool ok = true;
-
-     using namespace CppAD;
-     typedef std::complex<double> Complex;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     size_t n = 2;
-
-     // object for computing determinants
-     det_by_lu< AD<Complex> > Det(n);
-
-     // independent and dependent variable vectors
-     CPPAD_TESTVECTOR(AD<Complex>)  X(n * n);
-     CPPAD_TESTVECTOR(AD<Complex>)  D(1);
-
-     // value of the independent variable
-     size_t i;
-     for(i = 0; i < n * n; i++)
-          X[i] = Complex(int(i), -int(i) );
-
-     // set the independent variables
-     Independent(X);
-
-     D[0]  = Det(X);
-
-     // create the function object
-     ADFun<Complex> f(X, D);
-
-     // argument value
-     CPPAD_TESTVECTOR(Complex)     x( n * n );
-     for(i = 0; i < n * n; i++)
-          x[i] = Complex(2 * i, i);
-
-     // first derivative of the determinant
-     CPPAD_TESTVECTOR(Complex) H( n * n * n * n );
-     H = f.Hessian(x, 0);
-
-     /*
-     f(x)     = x[0] * x[3] - x[1] * x[2]
-     f'(x)    = ( x[3], -x[2], -x[1], x[0] )
-     */
-     Complex zero(0., 0.);
-     Complex one(1., 0.);
-     Complex Htrue[]  = {
-          zero, zero, zero,  one,
-          zero, zero, -one, zero,
-          zero, -one, zero, zero,
-           one, zero, zero, zero
-     };
-     for( i = 0; i < n*n*n*n; i++)
-          ok &= NearEqual( Htrue[i], H[i], eps99 , eps99 );
-
-     return ok;
-}
-
-
-
Input File: example/general/hes_lu_det.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_hes_lu_det.cpp_xml.js cppad-2019.02.00.0/doc/_hes_lu_det.cpp_xml.js --- cppad-2018.00.00.0/doc/_hes_lu_det.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_hes_lu_det.cpp_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', -'example.xml', -'general.xml', -'hes_lu_det.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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' -]; -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-2018.00.00.0/doc/hes_minor_det.cpp.xml cppad-2019.02.00.0/doc/hes_minor_det.cpp.xml --- cppad-2018.00.00.0/doc/hes_minor_det.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/hes_minor_det.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ - - - -Gradient of Determinant Using Expansion by Minors: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -hes_minor_det.cppHeadings

-
Gradient of Determinant Using Expansion by Minors: Example and Test
-
// Complex examples should supppress conversion warnings
-# include <cppad/wno_conversion.hpp>
-
-# include <cppad/cppad.hpp>
-# include <cppad/speed/det_by_minor.hpp>
-# include <complex>
-
-typedef std::complex<double>     Complex;
-typedef CppAD::AD<Complex>       ADComplex;
-typedef CPPAD_TESTVECTOR(ADComplex)   ADVector;
-
-// ----------------------------------------------------------------------------
-
-bool HesMinorDet(void)
-{     bool ok = true;
-
-     using namespace CppAD;
-
-     size_t n = 2;
-
-     // object for computing determinants
-     det_by_minor<ADComplex> Det(n);
-
-     // independent and dependent variable vectors
-     CPPAD_TESTVECTOR(ADComplex)  X(n * n);
-     CPPAD_TESTVECTOR(ADComplex)  D(1);
-
-     // value of the independent variable
-     size_t i;
-     for(i = 0; i < n * n; i++)
-          X[i] = Complex(int(i), -int(i));
-
-     // set the independent variables
-     Independent(X);
-
-     // comupute the determinant
-     D[0] = Det(X);
-
-     // create the function object
-     ADFun<Complex> f(X, D);
-
-     // argument value
-     CPPAD_TESTVECTOR(Complex)     x( n * n );
-     for(i = 0; i < n * n; i++)
-          x[i] = Complex(2 * i, i);
-
-     // first derivative of the determinant
-     CPPAD_TESTVECTOR(Complex) H( n * n * n * n);
-     H = f.Hessian(x, 0);
-
-     /*
-     f(x)     = x[0] * x[3] - x[1] * x[2]
-     f'(x)    = ( x[3], -x[2], -x[1], x[0] )
-     */
-     Complex zero(0., 0.);
-     Complex one(1., 0.);
-     Complex Htrue[]  = {
-          zero, zero, zero,  one,
-          zero, zero, -one, zero,
-          zero, -one, zero, zero,
-           one, zero, zero, zero
-     };
-     for( i = 0; i < n*n*n*n; i++)
-          ok &= Htrue[i] == H[i];
-
-     return ok;
-
-}
-
-
-
Input File: example/general/hes_minor_det.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_hes_minor_det.cpp_xml.js cppad-2019.02.00.0/doc/_hes_minor_det.cpp_xml.js --- cppad-2018.00.00.0/doc/_hes_minor_det.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_hes_minor_det.cpp_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', -'example.xml', -'general.xml', -'hes_minor_det.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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' -]; -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-2018.00.00.0/doc/hessian.cpp.xml cppad-2019.02.00.0/doc/hessian.cpp.xml --- cppad-2018.00.00.0/doc/hessian.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/hessian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ - - - -Hessian: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -hessian.cppHeadings

- - - -
Hessian: Example and Test
-

-# include <cppad/cppad.hpp>
-namespace { // ---------------------------------------------------------
-// define the template function HessianCases<Vector> in empty namespace
-template <typename Vector>
-bool HessianCases()
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     using CppAD::exp;
-     using CppAD::sin;
-     using CppAD::cos;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>)  X(n);
-     X[0] = 1.;
-     X[1] = 2.;
-
-     // declare independent variables and starting recording
-     CppAD::Independent(X);
-
-     // a calculation between the domain and range values
-     AD<double> Square = X[0] * X[0];
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>)  Y(m);
-     Y[0] = Square * exp( X[1] );
-     Y[1] = Square * sin( X[1] );
-     Y[2] = Square * cos( X[1] );
-
-     // create f: X -> Y and stop tape recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // new value for the independent variable vector
-     Vector x(n);
-     x[0] = 2.;
-     x[1] = 1.;
-
-     // second derivative of y[1]
-     Vector hes( n * n );
-     hes = f.Hessian(x, 1);
-     /*
-     F_1       = x[0] * x[0] * sin(x[1])
-
-     F_1^{(1)} = [ 2 * x[0] * sin(x[1]) , x[0] * x[0] * cos(x[1]) ]
-
-     F_1^{(2)} = [        2 * sin(x[1]) ,      2 * x[0] * cos(x[1]) ]
-                 [ 2 * x[0] * cos(x[1]) , - x[0] * x[0] * sin(x[1]) ]
-     */
-     ok &=  NearEqual(          2.*sin(x[1]), hes[0*n+0], eps99, eps99);
-     ok &=  NearEqual(     2.*x[0]*cos(x[1]), hes[0*n+1], eps99, eps99);
-     ok &=  NearEqual(     2.*x[0]*cos(x[1]), hes[1*n+0], eps99, eps99);
-     ok &=  NearEqual( - x[0]*x[0]*sin(x[1]), hes[1*n+1], eps99, eps99);
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool Hessian(void)
-{     bool ok = true;
-     // Run with Vector equal to three different cases
-     // all of which are Simple Vectors with elements of type double.
-     ok &= HessianCases< CppAD::vector  <double> >();
-     ok &= HessianCases< std::vector    <double> >();
-     ok &= HessianCases< std::valarray  <double> >();
-     return ok;
-}
-
-
Input File: example/general/hessian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_hessian.cpp_xml.js cppad-2019.02.00.0/doc/_hessian.cpp_xml.js --- cppad-2018.00.00.0/doc/_hessian.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_hessian.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'hessian.xml', -'hessian.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down1 = [ -'hessian.cpp.xml', -'hes_lagrangian.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-2018.00.00.0/doc/hessian.xml cppad-2019.02.00.0/doc/hessian.xml --- cppad-2018.00.00.0/doc/hessian.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/hessian.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,443 +0,0 @@ - - - -Hessian: Easy Driver - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Hessian: Easy Driver
-
-Syntax - -
- -hes = f.Hessian(xw)
-
- -hes = f.Hessian(xl)
-
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -The syntax above sets -hes - to the Hessian -The syntax above sets -h - to the Hessian - - -hes -= -d - -2 - - - -d - - -x - -2 - - - - - -i -= -1 - -m - -w -i - -F -i - -( -x -) - - -The routine sparse_hessian - may be faster in the case -where the Hessian is sparse. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const -(see Hessian Uses Forward - below). - -
-
-x -
-The argument -x - has prototype - -
-     const 
Vector &x
-
-(see Vector - below) -and its size -must be equal to -n -, the dimension of the -domain - space for -f -. -It specifies -that point at which to evaluate the Hessian. - -
-
-l -
-If the argument -l - is present, it has prototype - -
-     size_t 
l
-
-and is less than -m -, the dimension of the -range - space for -f -. -It specifies the component of -F - -for which we are evaluating the Hessian. -To be specific, in the case where the argument -l - is present, - - -w -i - -= -{ -1 - -i -= -l - -0 - -otherwise - - - - - -
-w -
-If the argument -w - is present, it has prototype - -
-     const 
Vector &w
-
-and size - -m - - -. -It specifies the value of - -w -i - - - - in the expression -for -h -. - -
-
-hes -
-The result -hes - has prototype - -
-     
Vector hes
-
-(see Vector - below) -and its size is - -n -* -n - - -. -For - -j -= -0 -, - -, -n -- -1 - - - -and - - -= -0 -, - -, -n -- -1 - - - - - -hes -[ -j -* -n -+ - -] -= - -2 - -w -T - - -F - - -x -j - - -x - - - - -( -x -) - - -
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Hessian Uses Forward -
-After each call to Forward -, -the object -f - contains the corresponding -Taylor coefficients -. -After a call to Hessian, -the zero order Taylor coefficients correspond to - -f.Forward(0, x) - -and the other coefficients are unspecified. - -
-
-Example - -
-The routines -hessian.cpp - and -hes_lagrangian.cpp - -are examples and tests of Hessian. -They return true, if they succeed and false otherwise. - - - -
Input File: cppad/core/hessian.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_hessian_xml.js cppad-2019.02.00.0/doc/_hessian_xml.js --- cppad-2018.00.00.0/doc/_hessian_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_hessian_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'hessian.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down0 = [ -'hessian.cpp.xml', -'hes_lagrangian.cpp.xml' -]; -var list_current0 = [ -'hessian.xml#Syntax', -'hessian.xml#Purpose', -'hessian.xml#f', -'hessian.xml#x', -'hessian.xml#l', -'hessian.xml#w', -'hessian.xml#hes', -'hessian.xml#Vector', -'hessian.xml#Hessian Uses Forward', -'hessian.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-2018.00.00.0/doc/hes_times_dir.cpp.xml cppad-2019.02.00.0/doc/hes_times_dir.cpp.xml --- cppad-2018.00.00.0/doc/hes_times_dir.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/hes_times_dir.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ - - - -Hessian Times Direction: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -hes_times_dir.cppHeadings

-
Hessian Times Direction: Example and Test
-
// Example and test of computing the Hessian times a direction; i.e.,
-// given F : R^n -> R and a direction dx in R^n, we compute F''(x) * dx
-
-# include <cppad/cppad.hpp>
-
-namespace { // put this function in the empty namespace
-     // F(x) = |x|^2 = x[0]^2 + ... + x[n-1]^2
-     template <class Type>
-     Type F(CPPAD_TESTVECTOR(Type) &x)
-     {     Type sum = 0;
-          size_t i = x.size();
-          while(i--)
-               sum += x[i] * x[i];
-          return sum;
-     }
-}
-
-bool HesTimesDir(void)
-{     bool ok = true;                   // initialize test result
-     size_t j;                         // a domain variable variable
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n = 5;
-     CPPAD_TESTVECTOR(AD<double>)  X(n);
-     for(j = 0; j < n; j++)
-          X[j] = AD<double>(j);
-
-     // declare independent variables and start recording
-     CppAD::Independent(X);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) Y(m);
-     Y[0] = F(X);
-
-     // create f : X -> Y and stop recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // choose a direction dx and compute dy(x) = F'(x) * dx
-     CPPAD_TESTVECTOR(double) dx(n);
-     CPPAD_TESTVECTOR(double) dy(m);
-     for(j = 0; j < n; j++)
-          dx[j] = double(n - j);
-     dy = f.Forward(1, dx);
-
-     // compute ddw = F''(x) * dx
-     CPPAD_TESTVECTOR(double) w(m);
-     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
-     for(j = 0; j < n; j++)
-          ok &= NearEqual(ddw[j * 2 + 1], 2.*dx[j], eps99, eps99);
-
-     return ok;
-}
-
-
Input File: example/general/hes_times_dir.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_hes_times_dir.cpp_xml.js cppad-2019.02.00.0/doc/_hes_times_dir.cpp_xml.js --- cppad-2018.00.00.0/doc/_hes_times_dir.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_hes_times_dir.cpp_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', -'adfun.xml', -'reverse.xml', -'reverse_two.xml', -'hes_times_dir.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'reverse_one.xml', -'reverse_two.xml', -'reverse_any.xml', -'subgraph_reverse.xml' -]; -var list_down1 = [ -'reverse_two.cpp.xml', -'hes_times_dir.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]; -} Binary files /tmp/tmpTwBTkM/UyeeZ_oWm3/cppad-2018.00.00.0/doc/_image.gif and /tmp/tmpTwBTkM/C6x_sNH1xf/cppad-2019.02.00.0/doc/_image.gif differ diff -Nru cppad-2018.00.00.0/doc/include_deprecated.xml cppad-2019.02.00.0/doc/include_deprecated.xml --- cppad-2018.00.00.0/doc/include_deprecated.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/include_deprecated.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,310 +0,0 @@ - - - -Deprecated Include Files - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -include_deprecated - -

- - - -
Deprecated Include Files
-
-Deprecated 2015-11-30 -
-The utility - individual include files have been deprecated; e.g., -
 
-     # include <cppad/runge_45.hpp>
-
-You must instead use -
 
-     # include <cppad/utility.hpp>
-
-or you can include individual utility files; e.g., -
 
-     # include <cppad/utility/runge_45.hpp>
-
-
-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 -
 
-     # include <CppAD/CppAD.h>
-
-you must change it to the command -
 
-     # include <cppad/cppad.hpp>
-
- -
-Deprecated    - Should Use -    - Documentation -
- - -CppAD/CheckNumericType.h    - cppad/check_numeric_type.hpp -    - CheckNumericType - -
- - -CppAD/CheckSimpleVector.h    - cppad/check_simple_vector.hpp -    - CheckSimpleVector - -
- - -CppAD/CppAD.h    - cppad/cppad.hpp -    - CppAD - -
- - -CppAD/CppAD_vector.h    - cppad/vector.hpp -    - CppAD_vector - -
- - -CppAD/ErrorHandler.h    - cppad/error_handler.hpp -    - ErrorHandler - -
- - -CppAD/LuFactor.h    - cppad/lu_factor.hpp -    - LuFactor - -
- - -CppAD/LuInvert.h    - cppad/lu_invert.hpp -    - LuInvert - -
- - -CppAD/LuSolve.h    - cppad/lu_solve.hpp -    - LuSolve - -
- - -CppAD/NearEqual.h    - cppad/near_equal.hpp -    - NearEqual - -
- - -CppAD/OdeErrControl.h    - cppad/ode_err_control.hpp -    - OdeErrControl - -
- - -CppAD/OdeGear.h    - cppad/ode_gear.hpp -    - OdeGear - -
- - -CppAD/OdeGearControl.h    - cppad/ode_gear_control.hpp -    - OdeGearControl - -
- - -CppAD/Poly.h    - cppad/poly.hpp -    - Poly - -
- - -CppAD/PowInt.h    - cppad/pow_int.hpp -    - pow_int - -
- - -CppAD/RombergMul.h    - cppad/romberg_mul.hpp -    - RombergMul - -
- - -CppAD/RombergOne.h    - cppad/romberg_one.hpp -    - RombergOne - -
- - -CppAD/Rosen34.h    - cppad/rosen_34.hpp -    - Rosen34 - -
- - -CppAD/Runge45.h    - cppad/runge_45.hpp -    - Runge45 - -
- - -CppAD/SpeedTest.h    - cppad/speed_test.hpp -    - SpeedTest - -
- - -CppAD/TrackNewDel.h    - cppad/track_new_del.hpp -    - TrackNewDel - -
- -
Input File: omh/appendix/deprecated/include_deprecated.omh - - - diff -Nru cppad-2018.00.00.0/doc/_include_deprecated_xml.js cppad-2019.02.00.0/doc/_include_deprecated_xml.js --- cppad-2018.00.00.0/doc/_include_deprecated_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_include_deprecated_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'include_deprecated.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', -'directory.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', -'autotools.xml' -]; -var list_current0 = [ -'include_deprecated.xml#Deprecated 2015-11-30', -'include_deprecated.xml#Deprecated 2006-12-17' -]; -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-2018.00.00.0/doc/independent.cpp.xml cppad-2019.02.00.0/doc/independent.cpp.xml --- cppad-2018.00.00.0/doc/independent.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/independent.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ - - - -Independent and ADFun Constructor: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -independent.cppHeadings

- - - -
Independent and ADFun Constructor: Example and Test
-
# include <cppad/cppad.hpp>
-
-namespace { // --------------------------------------------------------
-// define the template function Test<VectorAD>(void) in empty namespace
-template <class VectorAD>
-bool Test(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t  n  = 2;
-     VectorAD X(n);  // VectorAD is the template parameter in call to Test
-     X[0] = 0.;
-     X[1] = 1.;
-
-     // declare independent variables and start recording
-     // use the template parameter VectorAD for the vector type
-     CppAD::Independent(X);
-
-     AD<double> a = X[0] + X[1];      // first AD operation
-     AD<double> b = X[0] * X[1];      // second AD operation
-
-     // range space vector
-     size_t m = 2;
-     VectorAD Y(m);  // VectorAD is the template paraemter in call to Test
-     Y[0] = a;
-     Y[1] = b;
-
-     // create f: X -> Y and stop tape recording
-     // use the template parameter VectorAD for the vector type
-     CppAD::ADFun<double> f(X, Y);
-
-     // check value
-     ok &= NearEqual(Y[0] , 1.,  eps99 , eps99);
-     ok &= NearEqual(Y[1] , 0.,  eps99 , eps99);
-
-     // compute f(1, 2)
-     CPPAD_TESTVECTOR(double) x(n);
-     CPPAD_TESTVECTOR(double) y(m);
-     x[0] = 1.;
-     x[1] = 2.;
-     y    = f.Forward(0, x);
-     ok &= NearEqual(y[0] , 3.,  eps99 , eps99);
-     ok &= NearEqual(y[1] , 2.,  eps99 , eps99);
-
-     // compute partial of f w.r.t x[0] at (1, 2)
-     CPPAD_TESTVECTOR(double) dx(n);
-     CPPAD_TESTVECTOR(double) dy(m);
-     dx[0] = 1.;
-     dx[1] = 0.;
-     dy    = f.Forward(1, dx);
-     ok &= NearEqual(dy[0] ,   1.,  eps99 , eps99);
-     ok &= NearEqual(dy[1] , x[1],  eps99 , eps99);
-
-     // compute partial of f w.r.t x[1] at (1, 2)
-     dx[0] = 0.;
-     dx[1] = 1.;
-     dy    = f.Forward(1, dx);
-     ok &= NearEqual(dy[0] ,   1.,  eps99 , eps99);
-     ok &= NearEqual(dy[1] , x[0],  eps99 , eps99);
-
-     return ok;
-}
-} // End of empty namespace -------------------------------------------
-
-# include <vector>
-# include <valarray>
-bool Independent(void)
-{     bool ok = true;
-     typedef CppAD::AD<double> ADdouble;
-     // Run with VectorAD equal to three different cases
-     // all of which are Simple Vectors with elements of type AD<double>.
-     ok &= Test< CppAD::vector  <ADdouble> >();
-     ok &= Test< std::vector    <ADdouble> >();
-     ok &= Test< std::valarray  <ADdouble> >();
-     return ok;
-}
-
-
-
Input File: example/general/independent.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_independent.cpp_xml.js cppad-2019.02.00.0/doc/_independent.cpp_xml.js --- cppad-2018.00.00.0/doc/_independent.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_independent.cpp_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', -'adfun.xml', -'record_adfun.xml', -'independent.xml', -'independent.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'independent.xml', -'funconstruct.xml', -'dependent.xml', -'abort_recording.xml', -'seq_property.xml' -]; -var list_down1 = [ -'independent.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-2018.00.00.0/doc/independent.xml cppad-2019.02.00.0/doc/independent.xml --- cppad-2018.00.00.0/doc/independent.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/independent.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,268 +0,0 @@ - - - -Declare Independent Variables and Start Recording - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Declare Independent Variables and Start Recording
-
-Syntax - -
- -Independent(x)
-
- -Independent(xabort_op_index)
-
-
-Purpose -
-Start recording -AD of Base - operations -with -x - as the independent variable vector. -Once the -operation sequence - is completed, -it must be transferred to a function object; see below. - -
-
-Start Recording -
-An operation sequence recording is started by the commands - -
-     Independent(
x)
-     Independent(
xabort_op_index)
-
-
-Stop Recording -
-The recording is stopped, -and the operation sequence is transferred to the AD function object -f -, -using either the function constructor - - -
-     ADFun<
Basef(xy)
-
-or the dependent variable specifier - - -
-     
f.Dependent(xy)
-
-The only other way to stop a recording is using -abort_recording -. -Between when the recording is started and when it stopped, -we refer to the elements of -x -, -and the values that depend on the elements of -x -, -as -AD<Base> - variables. - -
-
-x -
-The vector -x - has prototype - -
-     
VectorAD &x
-
-(see -VectorAD - below). -The size of the vector -x -, must be greater than zero, -and is the number of independent variables for this -AD operation sequence. - -
-
-abort_op_index -
-It specifies the operator index at which the execution is be aborted -by calling the CppAD error handler -. -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 -purpose -. -No abort will occur if -abort_op_index - is zero, -of if NDEBUG - is defined. - -
-
-VectorAD -
-The type -VectorAD - must be a SimpleVector - class with -elements of type - - -AD<Base> -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Parallel Mode -
-Each thread can have one, and only one, active recording. -A call to Independent starts the recording for the current thread. -The recording must be stopped by a corresponding call to - -
-     ADFun<
Basefxy)
-
-or - -
-     
f.Dependent( xy)
-
-or abort_recording - -preformed by the same thread; i.e., -thread_alloc::thread_num - must be the same. - -
-
-Example - -
-The file -independent.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/independent.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_independent_xml.js cppad-2019.02.00.0/doc/_independent_xml.js --- cppad-2018.00.00.0/doc/_independent_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_independent_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'record_adfun.xml', -'independent.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'independent.xml', -'funconstruct.xml', -'dependent.xml', -'abort_recording.xml', -'seq_property.xml' -]; -var list_down0 = [ -'independent.cpp.xml' -]; -var list_current0 = [ -'independent.xml#Syntax', -'independent.xml#Purpose', -'independent.xml#Start Recording', -'independent.xml#Stop Recording', -'independent.xml#x', -'independent.xml#abort_op_index', -'independent.xml#VectorAD', -'independent.xml#Parallel Mode', -'independent.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-2018.00.00.0/doc/index.html cppad-2019.02.00.0/doc/index.html --- cppad-2018.00.00.0/doc/index.html 2018-01-01 08:33:22.000000000 +0000 +++ cppad-2019.02.00.0/doc/index.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ - diff -Nru cppad-2018.00.00.0/doc/index_sort.cpp.xml cppad-2019.02.00.0/doc/index_sort.cpp.xml --- cppad-2018.00.00.0/doc/index_sort.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/index_sort.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,181 +0,0 @@ - - - -Index Sort: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -index_sort.cppHeadings

- - -
Index Sort: Example and Test
-
# include <cppad/utility/index_sort.hpp>
-# include <cppad/utility/vector.hpp>
-# include <valarray>
-# include <vector>
-
-
-namespace{
-     // class that uses < to compare a pair of size_t values
-     class Key {
-     public:
-          size_t first_;
-          size_t second_;
-          //
-          Key(void)
-          { }
-          //
-          Key(size_t first, size_t second)
-          : first_(first), second_(second)
-          { }
-          //
-          bool operator<(const Key& other) const
-          {     if( first_ == other.first_ )
-                    return second_ < other.second_;
-               return first_ < other.first_;
-          }
-     };
-
-     template <class VectorKey, class VectorSize>
-     bool vector_case(void)
-     {     bool ok = true;
-          size_t i, j;
-          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;
-     }
-}
-
-bool index_sort(void)
-{     bool ok = true;
-
-     // some example simple vector template classes
-     ok &= vector_case<  std::vector<Key>,  std::valarray<size_t> >();
-     ok &= vector_case< std::valarray<Key>, CppAD::vector<size_t> >();
-     ok &= vector_case< CppAD::vector<Key>,   std::vector<size_t> >();
-
-     return ok;
-}
-
-
-
Input File: example/utility/index_sort.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_index_sort.cpp_xml.js cppad-2019.02.00.0/doc/_index_sort.cpp_xml.js --- cppad-2018.00.00.0/doc/_index_sort.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_index_sort.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'index_sort.xml', -'index_sort.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'index_sort.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-2018.00.00.0/doc/index_sort.xml cppad-2019.02.00.0/doc/index_sort.xml --- cppad-2018.00.00.0/doc/index_sort.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/index_sort.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,213 +0,0 @@ - - - -Returns Indices that Sort a Vector - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - -
Returns Indices that Sort a Vector
-
-Syntax - -
- -# include <cppad/utility/index_sort.hpp>
-
- -index_sort(keysind) - - -
-
-keys -
-The argument -keys - has prototype - -
-     const 
VectorKeykeys
-
-where -VectorKey - is -a SimpleVector - class with elements that support the < -operation. - -
-
-ind -
-The argument -ind - has prototype - -
-     
VectorSizeind
-
-where -VectorSize - is -a SimpleVector - class with elements of type size_t. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Input -
-The size of -ind - must be the same as the size of -keys - -and the value of its input elements does not matter. - -
-
-Return -
-Upon return, -ind - is a permutation of the set of indices -that yields increasing order for -keys -. -In other words, for all -i != j -, - -
-     
ind[i] != ind[j]
-
-and for -i = 0 , ... , size-2 -, - -
-     ( 
keysind[i+1] ] < keysind[i] ] ) == false
-
-
-Example - -
-The file index_sort.cpp - contains an example -and test of this routine. -It return true if it succeeds and false otherwise. - - -
Input File: cppad/utility/index_sort.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_index_sort_xml.js cppad-2019.02.00.0/doc/_index_sort_xml.js --- cppad-2018.00.00.0/doc/_index_sort_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_index_sort_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'index_sort.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'index_sort.cpp.xml' -]; -var list_current0 = [ -'index_sort.xml#Syntax', -'index_sort.xml#keys', -'index_sort.xml#ind', -'index_sort.xml#ind.Input', -'index_sort.xml#ind.Return', -'index_sort.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-2018.00.00.0/doc/_index.xml cppad-2019.02.00.0/doc/_index.xml --- cppad-2018.00.00.0/doc/_index.xml 2018-01-01 08:32:51.000000000 +0000 +++ cppad-2019.02.00.0/doc/_index.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,9765 +0,0 @@ - - - -Keyword Index - - - - - - - - - - - - - -
- -Prev -Next - - - - - - -_index - -

-
Keyword Index
-!= AD Binary Comparison Operators
-   AD Binary Comparison Operators: Example and Test
-(checkpointing): Reverse Mode General Case (Checkpointing): Example and Test
-(double CppAD Speed: Matrix Multiplication (Double Version)
-(except List All (Except Deprecated) CppAD Examples
-(record Create an ADFun Object (Record an Operation Sequence)
-* AD Binary Arithmetic Operators
-  AD Compound Assignment Operators
-  AD Binary Multiplication: Example and Test
-*= AD Compound Assignment Multiplication: Example and Test
-+ AD Compound Assignment Operators
-  AD Binary Addition: Example and Test
-  AD Unary Plus Operator
-  AD Binary Arithmetic Operators
-+= AD Compound Assignment Addition: Example and Test
-- AD Compound Assignment Operators
-  AD Binary Subtraction: Example and Test
-  AD Binary Arithmetic Operators
-  AD Unary Minus Operator
---with-documentation Autotools Unix Test and Installation: --with-Documentation
---with-testvector Autotools Unix Test and Installation: --with-testvector
--= AD Compound Assignment Subtraction: Example and Test
-/ Multi-Threaded Newton Method Example / Test
-  Multi-Threading User Atomic Example / Test
-  Multi-Threading Harmonic Summation Example / Test
-  AD Compound Assignment Operators
-  AD Binary Division: Example and Test
-  AD Binary Arithmetic Operators
-/= AD Compound Assignment Division: Example and Test
-0 Evaluate a Function Defined in Terms of an ODE: p.p == 0
-  AD Theory for Cholesky Factorization: Reverse Mode.Case k > 0
-  AD Theory for Cholesky Factorization: Reverse Mode.Case k = 0
-01-02 Changes and Additions to CppAD During 2006: 01-02
-      CppAD Changes and Additions During 2012: 01-02
-      CppAD Changes and Additions During 2015: 01-02
-01-04 Changes and Additions to CppAD During 2010: 01-04
-01-05 Changes and Additions to CppAD During 2006: 01-05
-01-06 Changes and Additions to CppAD During 2009: 01-06
-01-07 Changes and Additions to CppAD During 2006: 01-07
-      CppAD Changes and Additions During 2012: 01-07
-      CppAD Changes and Additions During 2015: 01-07
-01-08 Changes and Additions to CppAD During 2005: 01-08
-      Changes and Additions to CppAD During 2006: 01-08
-      Changes and Additions to CppAD During 2008: 01-08
-01-09 Changes and Additions to CppAD During 2011: 01-09
-      CppAD Changes and Additions During 2015: 01-09
-01-10 CppAD Changes and Additions During 2014: 01-10
-01-11 Changes and Additions to CppAD During 2008: 01-11
-01-12 CppAD Changes and Additions During 2012: 01-12
-01-15 CppAD Changes and Additions During 2012: 01-15
-01-16 Changes and Additions to CppAD During 2011: 01-16
-      CppAD Changes and Additions During 2012: 01-16
-01-17 Changes and Additions to CppAD During 2017: 01-17
-01-18 Changes and Additions to CppAD During 2006: 01-18
-      Changes and Additions to CppAD During 2009: 01-18
-      Changes and Additions to CppAD During 2010: 01-18
-      Changes and Additions to CppAD During 2016: 01-18
-      Changes and Additions to CppAD During 2017: 01-18
-01-19 Changes and Additions to CppAD During 2011: 01-19
-      CppAD Changes and Additions During 2012: 01-19
-      Changes and Additions to CppAD During 2017: 01-19
-01-20 Changes and Additions to CppAD During 2006: 01-20
-      Changes and Additions to CppAD During 2008: 01-20
-      Changes and Additions to CppAD During 2010: 01-20
-      CppAD Changes and Additions During 2012: 01-20
-      CppAD Changes and Additions During 2015: 01-20
-      Changes and Additions to CppAD During 2016: 01-20
-01-21 Changes and Additions to CppAD During 2008: 01-21
-      CppAD Changes and Additions During 2014: 01-21
-      CppAD Changes and Additions During 2015: 01-21
-      Changes and Additions to CppAD During 2016: 01-21
-01-22 Changes and Additions to CppAD During 2004: 01-22
-01-23 Changes and Additions to CppAD During 2010: 01-23
-      CppAD Changes and Additions During 2012: 01-23
-      CppAD Changes and Additions During 2015: 01-23
-01-24 Changes and Additions to CppAD During 2008: 01-24
-      Changes and Additions to CppAD During 2010: 01-24
-      CppAD Changes and Additions During 2012: 01-24
-01-26 Changes and Additions to CppAD During 2008: 01-26
-      Changes and Additions to CppAD During 2010: 01-26
-      CppAD Changes and Additions During 2014: 01-26
-      CppAD Changes and Additions During 2015: 01-26
-01-27 CppAD Changes and Additions During 2012: 01-27
-      Changes and Additions to CppAD During 2017: 01-27
-01-28 Changes and Additions to CppAD During 2004: 01-28
-01-29 Changes and Additions to CppAD During 2004: 01-29
-      Changes and Additions to CppAD During 2007: 01-29
-      CppAD Changes and Additions During 2015: 01-29
-      Changes and Additions to CppAD During 2017: 01-29
-01-30 CppAD Changes and Additions During 2012: 01-30
-      CppAD Changes and Additions During 2015: 01-30
-      Changes and Additions to CppAD During 2017: 01-30
-01-31 Changes and Additions to CppAD During 2009: 01-31
-02-01 Changes and Additions to CppAD During 2004: 02-01
-      Changes and Additions to CppAD During 2007: 02-01
-      Changes and Additions to CppAD During 2009: 02-01
-      Changes and Additions to CppAD During 2011: 02-01
-      Changes and Additions to CppAD During 2017: 02-01
-02-02 Changes and Additions to CppAD During 2007: 02-02
-      Changes and Additions to CppAD During 2011: 02-02
-      CppAD Changes and Additions During 2015: 02-02
-      Changes and Additions to CppAD During 2017: 02-02
-02-03 Changes and Additions to CppAD During 2007: 02-03
-      Changes and Additions to CppAD During 2008: 02-03
-      Changes and Additions to CppAD During 2010: 02-03
-      CppAD Changes and Additions During 2015: 02-03
-      Changes and Additions to CppAD During 2017: 02-03
-02-04 Changes and Additions to CppAD During 2006: 02-04
-      Changes and Additions to CppAD During 2007: 02-04
-      CppAD Changes and Additions During 2015: 02-04
-02-05 Changes and Additions to CppAD During 2008: 02-05
-      Changes and Additions to CppAD During 2010: 02-05
-      Changes and Additions to CppAD During 2017: 02-05
-02-06 Changes and Additions to CppAD During 2007: 02-06
-      Changes and Additions to CppAD During 2010: 02-06
-      Changes and Additions to CppAD During 2011: 02-06
-      CppAD Changes and Additions During 2015: 02-06
-02-07 CppAD Changes and Additions During 2015: 02-07
-02-08 Changes and Additions to CppAD During 2010: 02-08
-      Changes and Additions to CppAD During 2017: 02-08
-02-09 Changes and Additions to CppAD During 2011: 02-09
-      CppAD Changes and Additions During 2012: 02-09
-      CppAD Changes and Additions During 2015: 02-09
-      Changes and Additions to CppAD During 2017: 02-09
-02-10 Changes and Additions to CppAD During 2006: 02-10
-      CppAD Changes and Additions During 2012: 02-10
-      CppAD Changes and Additions During 2015: 02-10
-      Changes and Additions to CppAD During 2017: 02-10
-02-11 Changes and Additions to CppAD During 2006: 02-11
-      Changes and Additions to CppAD During 2010: 02-11
-      CppAD Changes and Additions During 2012: 02-11
-      CppAD Changes and Additions During 2015: 02-11
-      Changes and Additions to CppAD During 2017: 02-11
-02-12 Changes and Additions to CppAD During 2004: 02-12
-02-13 Changes and Additions to CppAD During 2006: 02-13
-      Changes and Additions to CppAD During 2017: 02-13
-02-14 Changes and Additions to CppAD During 2006: 02-14
-      CppAD Changes and Additions During 2015: 02-14
-02-15 Changes and Additions to CppAD During 2004: 02-15
-      Changes and Additions to CppAD During 2006: 02-15
-      Changes and Additions to CppAD During 2007: 03-09.02-15
-      Changes and Additions to CppAD During 2009: 02-15
-      Changes and Additions to CppAD During 2011: 02-15
-      CppAD Changes and Additions During 2014: 02-15
-      Changes and Additions to CppAD During 2017: 02-15
-02-16 Changes and Additions to CppAD During 2004: 02-16
-      Changes and Additions to CppAD During 2007: 03-09.02-16
-      CppAD Changes and Additions During 2015: 02-16
-02-17 Changes and Additions to CppAD During 2004: 02-17
-      Changes and Additions to CppAD During 2007: 03-09.02-17
-      Changes and Additions to CppAD During 2011: 02-17
-      CppAD Changes and Additions During 2014: 02-17
-02-18 CppAD Changes and Additions During 2015: 02-18
-02-19 Changes and Additions to CppAD During 2011: 02-19
-      Changes and Additions to CppAD During 2017: 02-19
-02-20 Changes and Additions to CppAD During 2004: 02-20
-      Changes and Additions to CppAD During 2009: 02-20
-02-21 Changes and Additions to CppAD During 2004: 02-21
-      Changes and Additions to CppAD During 2006: 02-21
-      Changes and Additions to CppAD During 2017: 02-21
-02-22 Changes and Additions to CppAD During 2007: 03-09.02-22
-      Changes and Additions to CppAD During 2011: 02-22
-      CppAD Changes and Additions During 2014: 02-22
-02-23 Changes and Additions to CppAD During 2006: 02-23
-      CppAD Changes and Additions During 2014: 02-23
-      Changes and Additions to CppAD During 2016: 02-23
-02-24 Changes and Additions to CppAD During 2005: 02-24
-      Changes and Additions to CppAD During 2006: 02-24
-02-25 Changes and Additions to CppAD During 2006: 02-25
-      Changes and Additions to CppAD During 2016: 02-25
-02-26 CppAD Changes and Additions During 2014: 02-26
-      Changes and Additions to CppAD During 2016: 02-26
-      Changes and Additions to CppAD During 2017: 02-26
-02-27 Changes and Additions to CppAD During 2007: 03-09.02-27
-      CppAD Changes and Additions During 2014: 02-27
-      Changes and Additions to CppAD During 2016: 02-27
-02-28 Changes and Additions to CppAD During 2004: 02-28
-      Changes and Additions to CppAD During 2006: 02-28
-      CppAD Changes and Additions During 2014: 02-28
-      CppAD Changes and Additions During 2015: 02-28
-      Changes and Additions to CppAD During 2016: 02-28
-02-29 Changes and Additions to CppAD During 2004: 02-29
-      Changes and Additions to CppAD During 2016: 02-29
-03-01 Changes and Additions to CppAD During 2004: 03-01
-      Changes and Additions to CppAD During 2005: 03-01
-      CppAD Changes and Additions During 2014: 03-01
-      Changes and Additions to CppAD During 2016: 03-01
-03-02 CppAD Changes and Additions During 2012: 03-02
-      CppAD Changes and Additions During 2014: 03-02
-03-03 Changes and Additions to CppAD During 2004: 03-03
-      Changes and Additions to CppAD During 2010: 03-03
-      CppAD Changes and Additions During 2012: 03-03
-03-04 Changes and Additions to CppAD During 2004: 03-04
-      Changes and Additions to CppAD During 2005: 03-04
-      Changes and Additions to CppAD During 2017: 03-04
-03-05 Changes and Additions to CppAD During 2004: 03-05
-      Changes and Additions to CppAD During 2006: 03-05
-      Changes and Additions to CppAD During 2011: 03-05
-      CppAD Changes and Additions During 2014: 03-05
-      Changes and Additions to CppAD During 2016: 03-05
-03-06 Changes and Additions to CppAD During 2004: 03-06
-      CppAD Changes and Additions During 2015: 03-06
-      Changes and Additions to CppAD During 2017: 03-06
-03-07 Changes and Additions to CppAD During 2004: 03-07
-      Changes and Additions to CppAD During 2006: 03-07
-03-09 Changes and Additions to CppAD During 2004: 03-09
-      Changes and Additions to CppAD During 2005: 03-09
-      Changes and Additions to CppAD During 2006: 03-09
-      Changes and Additions to CppAD During 2007: 03-09
-      Changes and Additions to CppAD During 2010: 03-09
-      CppAD Changes and Additions During 2014: 03-09
-03-10 Changes and Additions to CppAD During 2006: 03-10
-      Changes and Additions to CppAD During 2010: 03-10
-      Changes and Additions to CppAD During 2017: 03-10
-03-11 Changes and Additions to CppAD During 2004: 03-11
-      Changes and Additions to CppAD During 2006: 03-11
-      Changes and Additions to CppAD During 2010: 03-11
-      Changes and Additions to CppAD During 2011: 03-11
-      CppAD Changes and Additions During 2012: 03-11
-      Changes and Additions to CppAD During 2017: 03-11
-03-12 Changes and Additions to CppAD During 2004: 03-12
-      Changes and Additions to CppAD During 2016: 03-12
-03-13 Changes and Additions to CppAD During 2007: 03-15.03-13
-      CppAD Changes and Additions During 2015: 03-13
-      Changes and Additions to CppAD During 2017: 03-13
-03-14 Changes and Additions to CppAD During 2007: 03-15.03-14
-03-15 Changes and Additions to CppAD During 2004: 03-15
-      Changes and Additions to CppAD During 2006: 03-15
-      Changes and Additions to CppAD During 2007: 03-15.03-15
-      Changes and Additions to CppAD During 2007: 03-15
-03-16 Changes and Additions to CppAD During 2006: 03-16
-03-17 Changes and Additions to CppAD During 2004: 03-17
-      Changes and Additions to CppAD During 2006: 03-17
-      CppAD Changes and Additions During 2012: 03-17
-      CppAD Changes and Additions During 2014: 03-17
-      Changes and Additions to CppAD During 2016: 03-17
-03-18 Changes and Additions to CppAD During 2004: 03-18
-      Changes and Additions to CppAD During 2006: 03-18
-      CppAD Changes and Additions During 2014: 03-18
-03-19 Changes and Additions to CppAD During 2011: 03-19
-      Changes and Additions to CppAD During 2016: 03-19
-03-20 Changes and Additions to CppAD During 2007: 03-20
-      Changes and Additions to CppAD During 2016: 03-20
-      Changes and Additions to CppAD During 2017: 03-20
-03-21 CppAD Changes and Additions During 2012: 03-21
-      Changes and Additions to CppAD During 2016: 03-21
-03-22 Changes and Additions to CppAD During 2005: 03-22
-      Changes and Additions to CppAD During 2006: 03-22
-      Changes and Additions to CppAD During 2016: 03-22
-03-23 Changes and Additions to CppAD During 2005: 03-23
-      Changes and Additions to CppAD During 2006: 03-23
-      CppAD Changes and Additions During 2012: 03-23
-      Changes and Additions to CppAD During 2016: 03-23
-03-24 Changes and Additions to CppAD During 2006: 03-24
-      Changes and Additions to CppAD During 2009: 03-24
-      Changes and Additions to CppAD During 2016: 03-24
-03-25 Changes and Additions to CppAD During 2004: 03-25
-      Changes and Additions to CppAD During 2016: 03-25
-      Changes and Additions to CppAD During 2017: 03-25
-03-26 Changes and Additions to CppAD During 2005: 03-26
-      Changes and Additions to CppAD During 2006: 03-26
-      CppAD Changes and Additions During 2012: 03-26
-      Changes and Additions to CppAD During 2016: 03-26
-03-27 Changes and Additions to CppAD During 2006: 03-27
-      Changes and Additions to CppAD During 2008: 03-27
-      CppAD Changes and Additions During 2012: 03-27
-      Changes and Additions to CppAD During 2016: 03-27
-03-28 Changes and Additions to CppAD During 2004: 03-28
-      Changes and Additions to CppAD During 2006: 03-28
-      Changes and Additions to CppAD During 2007: 03-09.03-28
-03-29 Changes and Additions to CppAD During 2006: 03-29
-      Changes and Additions to CppAD During 2007: 03-29
-      Changes and Additions to CppAD During 2017: 03-29
-03-30 Changes and Additions to CppAD During 2004: 03-30
-      Changes and Additions to CppAD During 2006: 03-30
-      Changes and Additions to CppAD During 2007: 03-31.03-30
-03-31 Changes and Additions to CppAD During 2006: 03-31
-      Changes and Additions to CppAD During 2007: 03-31.03-31
-      Changes and Additions to CppAD During 2007: 03-31
-      Changes and Additions to CppAD During 2017: 03-31
-04-01 Changes and Additions to CppAD During 2004: 04-01
-      Changes and Additions to CppAD During 2006: 04-01
-      Changes and Additions to CppAD During 2010: 04-01
-      CppAD Changes and Additions During 2012: 04-01
-04-02 Changes and Additions to CppAD During 2004: 04-02
-      Changes and Additions to CppAD During 2006: 04-02
-      Changes and Additions to CppAD During 2017: 04-02
-04-03 Changes and Additions to CppAD During 2004: 04-03
-      Changes and Additions to CppAD During 2006: 04-03
-04-04 Changes and Additions to CppAD During 2006: 04-04
-      Changes and Additions to CppAD During 2008: 04-04
-04-05 Changes and Additions to CppAD During 2006: 04-05
-      Changes and Additions to CppAD During 2007: 04-11.04-05
-      CppAD Changes and Additions During 2012: 04-05
-04-06 Changes and Additions to CppAD During 2006: 04-06
-      Changes and Additions to CppAD During 2007: 04-11.04-06
-      Changes and Additions to CppAD During 2008: 04-06
-      CppAD Changes and Additions During 2012: 04-06
-04-07 Changes and Additions to CppAD During 2004: 04-07
-      Changes and Additions to CppAD During 2007: 04-11.04-07
-04-08 Changes and Additions to CppAD During 2004: 04-08
-      Changes and Additions to CppAD During 2006: 04-08
-      Changes and Additions to CppAD During 2017: 04-08
-04-09 Changes and Additions to CppAD During 2004: 04-09
-04-10 Changes and Additions to CppAD During 2007: 04-11.04-10
-      Changes and Additions to CppAD During 2008: 04-10
-      CppAD Changes and Additions During 2012: 04-10
-04-11 Changes and Additions to CppAD During 2007: 04-11.04-11
-      Changes and Additions to CppAD During 2007: 04-11
-04-13 Changes and Additions to CppAD During 2006: 04-13
-04-14 Changes and Additions to CppAD During 2006: 04-14
-      Changes and Additions to CppAD During 2007: 04-14
-04-15 Changes and Additions to CppAD During 2006: 04-15
-04-17 Changes and Additions to CppAD During 2006: 04-17
-      Changes and Additions to CppAD During 2007: 04-17
-      CppAD Changes and Additions During 2012: 04-17
-      Changes and Additions to CppAD During 2016: 04-17
-04-18 Changes and Additions to CppAD During 2006: 04-18
-      Changes and Additions to CppAD During 2008: 04-18
-      CppAD Changes and Additions During 2012: 04-18
-      CppAD Changes and Additions During 2015: 04-18
-04-19 Changes and Additions to CppAD During 2004: 04-19
-      Changes and Additions to CppAD During 2005: 04-19
-      Changes and Additions to CppAD During 2006: 04-19
-      Changes and Additions to CppAD During 2007: 04-19
-      Changes and Additions to CppAD During 2011: 04-19
-      CppAD Changes and Additions During 2012: 04-19
-04-20 Changes and Additions to CppAD During 2004: 04-20
-      Changes and Additions to CppAD During 2005: 04-20
-      Changes and Additions to CppAD During 2008: 04-20
-      Changes and Additions to CppAD During 2011: 04-20
-04-21 Changes and Additions to CppAD During 2004: 04-21
-      Changes and Additions to CppAD During 2005: 04-21
-04-22 Changes and Additions to CppAD During 2004: 04-22
-04-24 Changes and Additions to CppAD During 2004: 04-24
-      Changes and Additions to CppAD During 2010: 04-24
-04-25 Changes and Additions to CppAD During 2004: 04-25
-      Changes and Additions to CppAD During 2006: 04-25
-04-26 Changes and Additions to CppAD During 2006: 04-26
-      Changes and Additions to CppAD During 2010: 04-26
-      CppAD Changes and Additions During 2013: 04-26
-04-27 CppAD Changes and Additions During 2013: 04-27
-04-28 Changes and Additions to CppAD During 2004: 04-28
-      Changes and Additions to CppAD During 2006: 04-28
-      Changes and Additions to CppAD During 2010: 04-28
-      CppAD Changes and Additions During 2013: 04-28
-04-29 Changes and Additions to CppAD During 2004: 04-29
-      Changes and Additions to CppAD During 2006: 04-29
-      Changes and Additions to CppAD During 2011: 04-29
-05-01 Changes and Additions to CppAD During 2005: 05-01
-05-03 Changes and Additions to CppAD During 2004: 05-03
-      Changes and Additions to CppAD During 2006: 05-03
-      Changes and Additions to CppAD During 2008: 05-03
-      Changes and Additions to CppAD During 2011: 05-03
-05-04 Changes and Additions to CppAD During 2004: 05-04
-      CppAD Changes and Additions During 2013: 05-04
-05-05 Changes and Additions to CppAD During 2007: 05-05
-      CppAD Changes and Additions During 2015: 05-05
-      Changes and Additions to CppAD During 2016: 05-05
-05-06 Changes and Additions to CppAD During 2005: 05-06
-05-07 Changes and Additions to CppAD During 2004: 05-07
-      CppAD Changes and Additions During 2015: 05-07
-05-08 Changes and Additions to CppAD During 2007: 05-08
-      Changes and Additions to CppAD During 2008: 05-08
-      CppAD Changes and Additions During 2015: 05-08
-05-09 Changes and Additions to CppAD During 2004: 05-09
-      CppAD Changes and Additions During 2015: 05-09
-05-10 CppAD Changes and Additions During 2015: 05-10
-05-11 Changes and Additions to CppAD During 2011: 05-11
-      CppAD Changes and Additions During 2013: 05-11
-      CppAD Changes and Additions During 2015: 05-11
-05-12 Changes and Additions to CppAD During 2004: 05-12
-      Changes and Additions to CppAD During 2005: 05-12
-      CppAD Changes and Additions During 2013: 05-12
-      Changes and Additions to CppAD During 2017: 05-12
-05-14 Changes and Additions to CppAD During 2004: 05-14
-      CppAD Changes and Additions During 2013: 05-14
-      CppAD Changes and Additions During 2014: 05-14
-      Changes and Additions to CppAD During 2017: 05-14
-05-15 CppAD Changes and Additions During 2013: 05-15
-05-16 Changes and Additions to CppAD During 2005: 05-16
-      CppAD Changes and Additions During 2014: 05-16
-05-17 CppAD Changes and Additions During 2013: 05-17
-05-18 Changes and Additions to CppAD During 2005: 05-18
-05-19 Changes and Additions to CppAD During 2005: 05-19
-      CppAD Changes and Additions During 2014: 05-19
-      Changes and Additions to CppAD During 2017: 05-19
-05-20 Changes and Additions to CppAD During 2009: 05-20
-      CppAD Changes and Additions During 2014: 05-20
-05-21 CppAD Changes and Additions During 2013: 05-21
-05-22 Changes and Additions to CppAD During 2007: 05-22
-      Changes and Additions to CppAD During 2011: 05-22
-      CppAD Changes and Additions During 2014: 05-22
-05-23 CppAD Changes and Additions During 2014: 05-23
-05-24 Changes and Additions to CppAD During 2007: 05-24
-      CppAD Changes and Additions During 2012: 05-24
-05-25 Changes and Additions to CppAD During 2004: 05-25
-      Changes and Additions to CppAD During 2007: 05-25
-05-26 Changes and Additions to CppAD During 2004: 05-26
-      Changes and Additions to CppAD During 2007: 05-26
-      Changes and Additions to CppAD During 2011: 05-26
-      CppAD Changes and Additions During 2015: 05-26
-05-27 Changes and Additions to CppAD During 2006: 05-27
-      CppAD Changes and Additions During 2012: 05-27
-      CppAD Changes and Additions During 2014: 05-27
-05-28 Changes and Additions to CppAD During 2011: 05-28
-      CppAD Changes and Additions During 2013: 05-28
-      CppAD Changes and Additions During 2014: 05-28
-05-29 Changes and Additions to CppAD During 2004: 05-29
-      Changes and Additions to CppAD During 2006: 05-29
-      Changes and Additions to CppAD During 2011: 05-29
-      CppAD Changes and Additions During 2012: 05-29
-      Changes and Additions to CppAD During 2017: 05-29
-05-30 Changes and Additions to CppAD During 2004: 05-30
-      CppAD Changes and Additions During 2012: 05-30
-05-31 Changes and Additions to CppAD During 2006: 05-31
-      CppAD Changes and Additions During 2012: 05-31
-06-01 Changes and Additions to CppAD During 2004: 06-01
-      Changes and Additions to CppAD During 2010: 06-01
-      CppAD Changes and Additions During 2012: 06-01
-      Changes and Additions to CppAD During 2017: 06-01
-06-02 Changes and Additions to CppAD During 2006: 06-02
-      CppAD Changes and Additions During 2012: 06-02
-06-03 Changes and Additions to CppAD During 2004: 06-03
-      CppAD Changes and Additions During 2012: 06-03
-      Changes and Additions to CppAD During 2017: 06-03
-06-04 Changes and Additions to CppAD During 2004: 06-04
-      CppAD Changes and Additions During 2012: 06-04
-      Changes and Additions to CppAD During 2017: 06-04
-06-05 Changes and Additions to CppAD During 2006: 06-05
-      CppAD Changes and Additions During 2012: 06-05
-06-06 Changes and Additions to CppAD During 2005: 06-06
-      Changes and Additions to CppAD During 2009: 06-06
-06-07 Changes and Additions to CppAD During 2006: 06-07
-      CppAD Changes and Additions During 2012: 06-07
-      CppAD Changes and Additions During 2015: 06-07
-      Changes and Additions to CppAD During 2017: 06-07
-06-08 CppAD Changes and Additions During 2012: 06-08
-06-09 Changes and Additions to CppAD During 2006: 06-09
-      CppAD Changes and Additions During 2012: 06-09
-      CppAD Changes and Additions During 2015: 06-09
-06-10 Changes and Additions to CppAD During 2008: 06-10
-      CppAD Changes and Additions During 2012: 06-10
-      Changes and Additions to CppAD During 2016: 06-10
-      Changes and Additions to CppAD During 2017: 06-10
-06-11 Changes and Additions to CppAD During 2008: 06-11
-      CppAD Changes and Additions During 2015: 06-11
-      Changes and Additions to CppAD During 2017: 06-11
-06-12 Changes and Additions to CppAD During 2004: 06-12
-      CppAD Changes and Additions During 2012: 06-12
-06-13 Changes and Additions to CppAD During 2005: 06-13
-06-14 Changes and Additions to CppAD During 2005: 06-14
-      Changes and Additions to CppAD During 2007: 06-14
-06-15 Changes and Additions to CppAD During 2006: 06-15
-      Changes and Additions to CppAD During 2008: 06-15
-      CppAD Changes and Additions During 2012: 06-15
-06-16 CppAD Changes and Additions During 2012: 06-16
-      CppAD Changes and Additions During 2015: 06-16
-06-17 Changes and Additions to CppAD During 2006: 06-17
-      Changes and Additions to CppAD During 2006: 06-19.06-17
-      CppAD Changes and Additions During 2012: 06-17
-06-18 Changes and Additions to CppAD During 2005: 06-18
-      Changes and Additions to CppAD During 2006: 06-19.06-18
-      Changes and Additions to CppAD During 2008: 06-18
-      Changes and Additions to CppAD During 2011: 06-18
-06-19 Changes and Additions to CppAD During 2006: 06-19
-06-20 Changes and Additions to CppAD During 2007: 06-20
-      Changes and Additions to CppAD During 2009: 06-20
-06-21 Changes and Additions to CppAD During 2009: 06-21
-      Changes and Additions to CppAD During 2011: 06-21
-06-22 Changes and Additions to CppAD During 2006: 06-22
-      Changes and Additions to CppAD During 2007: 06-22
-      Changes and Additions to CppAD During 2009: 06-22
-06-23 Changes and Additions to CppAD During 2011: 06-23
-06-24 Changes and Additions to CppAD During 2005: 06-24
-06-25 Changes and Additions to CppAD During 2004: 06-25
-      Changes and Additions to CppAD During 2005: 06-25
-      Changes and Additions to CppAD During 2009: 06-25
-      Changes and Additions to CppAD During 2016: 06-25
-06-27 Changes and Additions to CppAD During 2016: 06-27
-06-28 Changes and Additions to CppAD During 2009: 07-04.06-28
-      Changes and Additions to CppAD During 2017: 06-28
-06-29 Changes and Additions to CppAD During 2004: 06-29
-      Changes and Additions to CppAD During 2006: 06-29
-      Changes and Additions to CppAD During 2009: 07-04.06-29
-      Changes and Additions to CppAD During 2016: 06-29
-06-30 Changes and Additions to CppAD During 2009: 07-04.06-30
-      Changes and Additions to CppAD During 2016: 06-30
-07-01 Changes and Additions to CppAD During 2005: 07-01
-      Changes and Additions to CppAD During 2009: 07-04.07-01
-      CppAD Changes and Additions During 2012: 07-01
-      Changes and Additions to CppAD During 2017: 07-01
-07-02 Changes and Additions to CppAD During 2004: 07-02
-      Changes and Additions to CppAD During 2005: 07-02
-      Changes and Additions to CppAD During 2008: 07-02
-      Changes and Additions to CppAD During 2009: 07-04.07-02
-      CppAD Changes and Additions During 2012: 07-02
-07-03 Changes and Additions to CppAD During 2004: 07-03
-      Changes and Additions to CppAD During 2005: 07-03
-      Changes and Additions to CppAD During 2009: 07-04.07-03
-      CppAD Changes and Additions During 2012: 07-03
-      Changes and Additions to CppAD During 2017: 07-03
-07-04 Changes and Additions to CppAD During 2005: 07-04
-      Changes and Additions to CppAD During 2009: 07-04.07-04
-      Changes and Additions to CppAD During 2009: 07-04
-      CppAD Changes and Additions During 2012: 07-04
-07-05 Changes and Additions to CppAD During 2005: 07-05
-      CppAD Changes and Additions During 2012: 07-05
-07-06 Changes and Additions to CppAD During 2009: 07-23.07-06
-07-07 Changes and Additions to CppAD During 2004: 07-07
-      Changes and Additions to CppAD During 2011: 07-07
-      CppAD Changes and Additions During 2012: 07-07
-07-08 Changes and Additions to CppAD During 2004: 07-08
-      Changes and Additions to CppAD During 2005: 07-08
-      CppAD Changes and Additions During 2012: 07-08
-07-09 Changes and Additions to CppAD During 2011: 07-09
-07-10 Changes and Additions to CppAD During 2011: 07-10
-07-11 Changes and Additions to CppAD During 2005: 07-11
-      Changes and Additions to CppAD During 2010: 07-11
-      Changes and Additions to CppAD During 2011: 07-11
-07-12 Changes and Additions to CppAD During 2006: 07-12
-07-13 Changes and Additions to CppAD During 2007: 07-13
-      Changes and Additions to CppAD During 2011: 07-13
-07-14 Changes and Additions to CppAD During 2003: 07-14
-      Changes and Additions to CppAD During 2006: 07-14
-      Changes and Additions to CppAD During 2007: 07-14
-      Changes and Additions to CppAD During 2010: 07-14
-      Changes and Additions to CppAD During 2011: 07-14
-      Changes and Additions to CppAD During 2016: 07-14
-07-15 Changes and Additions to CppAD During 2005: 07-15
-07-16 Changes and Additions to CppAD During 2003: 07-16
-07-17 Changes and Additions to CppAD During 2011: 07-17
-      Changes and Additions to CppAD During 2016: 07-17
-07-18 Changes and Additions to CppAD During 2003: 07-18
-      Changes and Additions to CppAD During 2007: 07-18
-      Changes and Additions to CppAD During 2011: 07-18
-07-19 Changes and Additions to CppAD During 2005: 07-19
-      Changes and Additions to CppAD During 2007: 07-19
-07-20 Changes and Additions to CppAD During 2003: 07-20
-      Changes and Additions to CppAD During 2007: 07-20
-07-21 Changes and Additions to CppAD During 2005: 07-21
-      Changes and Additions to CppAD During 2007: 07-21
-07-22 Changes and Additions to CppAD During 2003: 07-22
-      Changes and Additions to CppAD During 2007: 07-22
-07-23 Changes and Additions to CppAD During 2007: 07-23
-      Changes and Additions to CppAD During 2009: 07-23
-07-24 Changes and Additions to CppAD During 2009: 07-24
-07-25 Changes and Additions to CppAD During 2007: 07-26.07-25
-      Changes and Additions to CppAD During 2009: 07-25
-      Changes and Additions to CppAD During 2011: 07-25
-      Changes and Additions to CppAD During 2017: 07-25
-07-26 Changes and Additions to CppAD During 2003: 07-26
-      Changes and Additions to CppAD During 2007: 07-26.07-26
-      Changes and Additions to CppAD During 2007: 07-26
-      Changes and Additions to CppAD During 2009: 07-26
-      CppAD Changes and Additions During 2013: 07-26
-07-27 Changes and Additions to CppAD During 2011: 07-27
-07-28 Changes and Additions to CppAD During 2007: 07-28
-      Changes and Additions to CppAD During 2011: 07-28
-07-29 Changes and Additions to CppAD During 2003: 07-29
-      Changes and Additions to CppAD During 2007: 07-29
-      Changes and Additions to CppAD During 2011: 07-29
-07-30 Changes and Additions to CppAD During 2003: 07-30
-      Changes and Additions to CppAD During 2007: 07-30
-      CppAD Changes and Additions During 2012: 07-30
-07-31 Changes and Additions to CppAD During 2004: 07-31
-      Changes and Additions to CppAD During 2009: 07-31
-      Changes and Additions to CppAD During 2011: 07-31
-      CppAD Changes and Additions During 2015: 07-31
-08-01 Changes and Additions to CppAD During 2003: 08-01
-      Changes and Additions to CppAD During 2009: 08-01
-08-02 Changes and Additions to CppAD During 2009: 08-02
-      Changes and Additions to CppAD During 2011: 08-02
-08-03 Changes and Additions to CppAD During 2003: 08-03
-      Changes and Additions to CppAD During 2011: 08-03
-08-04 Changes and Additions to CppAD During 2003: 08-04
-      Changes and Additions to CppAD During 2011: 08-11.08-04
-08-05 Changes and Additions to CppAD During 2003: 08-05
-      CppAD Changes and Additions During 2012: 08-05
-08-06 Changes and Additions to CppAD During 2003: 08-06
-      Changes and Additions to CppAD During 2009: 08-06
-      Changes and Additions to CppAD During 2011: 08-11.08-06
-      CppAD Changes and Additions During 2013: 08-06
-      CppAD Changes and Additions During 2015: 08-06
-08-07 Changes and Additions to CppAD During 2003: 08-07
-      Changes and Additions to CppAD During 2005: 08-07
-      Changes and Additions to CppAD During 2007: 08-07
-      Changes and Additions to CppAD During 2011: 08-11.08-07
-08-08 Changes and Additions to CppAD During 2008: 08-08
-      Changes and Additions to CppAD During 2011: 08-11.08-08
-      Changes and Additions to CppAD During 2017: 08-08
-08-09 Changes and Additions to CppAD During 2007: 08-09
-      Changes and Additions to CppAD During 2009: 08_13.08-09
-      Changes and Additions to CppAD During 2011: 08-11.08-09
-      CppAD Changes and Additions During 2015: 08-09
-      Changes and Additions to CppAD During 2017: 08-09
-08-10 Changes and Additions to CppAD During 2003: 08-10
-      Changes and Additions to CppAD During 2009: 08_13.08-10
-      Changes and Additions to CppAD During 2011: 08-11.08-10
-08-11 Changes and Additions to CppAD During 2003: 08-11
-      Changes and Additions to CppAD During 2009: 08_13.08-11
-      Changes and Additions to CppAD During 2011: 08-11
-      CppAD Changes and Additions During 2013: 08-11
-08-12 Changes and Additions to CppAD During 2004: 08-12
-      CppAD Changes and Additions During 2013: 08-12
-08-13 Changes and Additions to CppAD During 2005: 08-13
-      Changes and Additions to CppAD During 2009: 08_13.08-13
-08-14 Changes and Additions to CppAD During 2005: 08-14
-      Changes and Additions to CppAD During 2009: 08-14
-08-15 Changes and Additions to CppAD During 2005: 08-15
-08-16 Changes and Additions to CppAD During 2003: 08-16
-      CppAD Changes and Additions During 2015: 08-16
-08-17 Changes and Additions to CppAD During 2003: 08-17
-      Changes and Additions to CppAD During 2006: 08-17
-      CppAD Changes and Additions During 2015: 08-17
-08-19 Changes and Additions to CppAD During 2003: 08-19
-      Changes and Additions to CppAD During 2005: 08-19
-      Changes and Additions to CppAD During 2008: 08-19
-08-20 Changes and Additions to CppAD During 2005: 08-20
-      CppAD Changes and Additions During 2015: 08-20
-08-21 Changes and Additions to CppAD During 2010: 08-21
-      Changes and Additions to CppAD During 2011: 09-01.08-21
-08-22 Changes and Additions to CppAD During 2003: 08-22
-08-23 Changes and Additions to CppAD During 2003: 08-23
-      Changes and Additions to CppAD During 2011: 09-01.08-23
-08-24 Changes and Additions to CppAD During 2004: 08-24
-      Changes and Additions to CppAD During 2005: 08-24
-08-25 Changes and Additions to CppAD During 2004: 08-25
-      Changes and Additions to CppAD During 2009: 08-25
-      Changes and Additions to CppAD During 2011: 09-01.08-25
-      CppAD Changes and Additions During 2015: 08-25
-      Changes and Additions to CppAD During 2016: 08-25
-08-26 CppAD Changes and Additions During 2015: 08-26
-08-27 Changes and Additions to CppAD During 2004: 08-27
-08-28 CppAD Changes and Additions During 2015: 08-28
-08-29 Changes and Additions to CppAD During 2008: 08-29
-      CppAD Changes and Additions During 2015: 08-29
-      Changes and Additions to CppAD During 2017: 08-29
-08-30 Changes and Additions to CppAD During 2005: 08-30
-      Changes and Additions to CppAD During 2011: 09-01.08-30
-      CppAD Changes and Additions During 2015: 08-30
-      Changes and Additions to CppAD During 2016: 08-30
-      Changes and Additions to CppAD During 2017: 08-30
-08-31 Changes and Additions to CppAD During 2011: 09-01.08-31
-      CppAD Changes and Additions During 2015: 08-31
-08_13 Changes and Additions to CppAD During 2009: 08_13
-09-01 Changes and Additions to CppAD During 2008: 09-01
-      Changes and Additions to CppAD During 2011: 09-01
-09-02 Changes and Additions to CppAD During 2004: 09-02
-      Changes and Additions to CppAD During 2011: 09-02
-      CppAD Changes and Additions During 2015: 09-02
-09-03 Changes and Additions to CppAD During 2003: 09-03
-      Changes and Additions to CppAD During 2008: 09-03
-      CppAD Changes and Additions During 2015: 09-03
-09-04 Changes and Additions to CppAD During 2003: 09-04
-      Changes and Additions to CppAD During 2004: 09-04
-      Changes and Additions to CppAD During 2008: 09-04
-09-05 Changes and Additions to CppAD During 2003: 09-05
-      Changes and Additions to CppAD During 2008: 09-05
-      Changes and Additions to CppAD During 2011: 09-05
-09-06 Changes and Additions to CppAD During 2003: 09-06
-      Changes and Additions to CppAD During 2007: 09-06
-      Changes and Additions to CppAD During 2008: 09-06
-      Changes and Additions to CppAD During 2011: 09-06
-09-07 Changes and Additions to CppAD During 2004: 09-07
-      Changes and Additions to CppAD During 2005: 09-07
-      Changes and Additions to CppAD During 2008: 09-07
-      CppAD Changes and Additions During 2013: 09-07
-09-09 Changes and Additions to CppAD During 2004: 09-09
-      Changes and Additions to CppAD During 2005: 09-09
-      Changes and Additions to CppAD During 2008: 09-09
-09-10 Changes and Additions to CppAD During 2004: 09-10
-      Changes and Additions to CppAD During 2008: 09-10
-09-11 CppAD Changes and Additions During 2012: 09-11
-09-12 Changes and Additions to CppAD During 2008: 09-12
-09-13 Changes and Additions to CppAD During 2003: 09-13
-      Changes and Additions to CppAD During 2004: 09-13
-      Changes and Additions to CppAD During 2016: 09-13
-09-14 Changes and Additions to CppAD During 2003: 09-14
-      Changes and Additions to CppAD During 2005: 09-14
-09-15 Changes and Additions to CppAD During 2003: 09-15
-09-16 Changes and Additions to CppAD During 2008: 09-16
-      CppAD Changes and Additions During 2015: 09-16
-      Changes and Additions to CppAD During 2016: 09-16
-      Changes and Additions to CppAD During 2017: 09-16
-09-17 Changes and Additions to CppAD During 2008: 09-17
-09-18 Changes and Additions to CppAD During 2003: 09-18
-      Changes and Additions to CppAD During 2008: 09-18
-      Changes and Additions to CppAD During 2009: 09-18
-      CppAD Changes and Additions During 2013: 09-18
-09-19 Changes and Additions to CppAD During 2003: 09-19
-      Changes and Additions to CppAD During 2009: 09-19
-      CppAD Changes and Additions During 2013: 09-19
-      CppAD Changes and Additions During 2015: 09-19
-09-20 Changes and Additions to CppAD During 2003: 09-20
-      Changes and Additions to CppAD During 2005: 09-20
-      Changes and Additions to CppAD During 2009: 09-20
-      CppAD Changes and Additions During 2013: 09-20
-      CppAD Changes and Additions During 2015: 09-20
-09-21 Changes and Additions to CppAD During 2004: 09-21
-      CppAD Changes and Additions During 2014: 09-21
-      CppAD Changes and Additions During 2015: 09-21
-09-22 Changes and Additions to CppAD During 2010: 09-22
-09-23 Changes and Additions to CppAD During 2004: 09-23
-      CppAD Changes and Additions During 2015: 09-23
-09-24 Changes and Additions to CppAD During 2005: 09-24
-      CppAD Changes and Additions During 2012: 09-24
-      CppAD Changes and Additions During 2015: 09-24
-09-25 CppAD Changes and Additions During 2014: 09-25
-      CppAD Changes and Additions During 2015: 09-25
-09-26 Changes and Additions to CppAD During 2004: 09-26
-      Changes and Additions to CppAD During 2008: 09-26
-      Changes and Additions to CppAD During 2009: 09-26
-      Changes and Additions to CppAD During 2010: 09-26
-      Changes and Additions to CppAD During 2016: 09-26
-09-27 Changes and Additions to CppAD During 2005: 09-27
-      CppAD Changes and Additions During 2014: 09-27
-      CppAD Changes and Additions During 2015: 09-27
-      Changes and Additions to CppAD During 2016: 09-27
-09-28 Changes and Additions to CppAD During 2009: 09-28
-      CppAD Changes and Additions During 2014: 09-28
-      CppAD Changes and Additions During 2015: 09-28
-09-29 Changes and Additions to CppAD During 2004: 09-29
-      Changes and Additions to CppAD During 2005: 09-29
-      Changes and Additions to CppAD During 2009: 09-29
-      Changes and Additions to CppAD During 2016: 09-29
-09-30 Changes and Additions to CppAD During 2003: 09-30
-      Changes and Additions to CppAD During 2006: 09-30
-      Changes and Additions to CppAD During 2008: 09-30
-      Changes and Additions to CppAD During 2009: 09-30
-1 Evaluate a Function Defined in Terms of an ODE: p.p = 1
-  AD Theory for Cholesky Factorization: Lemma 1
-1/Timing Test of Multi-Threaded Summation of 1/i
-    Multi-Threaded Implementation of Summation of 1/i
-    Take Down Multi-threading Sum of 1/i
-    Do One Thread's Work for Sum of 1/i
-    Set Up Multi-threading Sum of 1/i
-    Common Variables Used by Multi-threading Sum of 1/i
-10 The Base 10 Logarithm Function: log10
-10-02 Changes and Additions to CppAD During 2007: 10-02
-      CppAD Changes and Additions During 2012: 10-02
-      CppAD Changes and Additions During 2015: 10-02
-10-03 Changes and Additions to CppAD During 2009: 10-03
-      CppAD Changes and Additions During 2012: 10-03
-      CppAD Changes and Additions During 2015: 10-03
-10-04 CppAD Changes and Additions During 2012: 10-04
-      CppAD Changes and Additions During 2015: 10-04
-10-05 Changes and Additions to CppAD During 2003: 10-05
-      Changes and Additions to CppAD During 2007: 10-05
-10-06 Changes and Additions to CppAD During 2003: 10-06
-      Changes and Additions to CppAD During 2004: 10-06
-      Changes and Additions to CppAD During 2005: 10-06
-      CppAD Changes and Additions During 2015: 10-06
-10-10 Changes and Additions to CppAD During 2003: 10-10
-      Changes and Additions to CppAD During 2006: 10-10
-10-12 Changes and Additions to CppAD During 2005: 10-12
-      Changes and Additions to CppAD During 2011: 10-12
-      CppAD Changes and Additions During 2012: 10-12
-      CppAD Changes and Additions During 2013: 10-12
-      Changes and Additions to CppAD During 2016: 10-12
-10-13 Changes and Additions to CppAD During 2007: 10-13
-      CppAD Changes and Additions During 2013: 10-13
-10-14 Changes and Additions to CppAD During 2003: 10-14
-      Changes and Additions to CppAD During 2005: 10-14
-      Changes and Additions to CppAD During 2009: 10-14
-      Changes and Additions to CppAD During 2011: 10-14
-      CppAD Changes and Additions During 2013: 10-14
-10-15 CppAD Changes and Additions During 2013: 10-15
-10-16 Changes and Additions to CppAD During 2003: 10-16
-      Changes and Additions to CppAD During 2004: 10-16
-      Changes and Additions to CppAD During 2006: 10-16
-      Changes and Additions to CppAD During 2007: 10-16
-      Changes and Additions to CppAD During 2008: 10-16
-      Changes and Additions to CppAD During 2009: 10-16
-      CppAD Changes and Additions During 2013: 10-16
-      CppAD Changes and Additions During 2015: 10-16
-10-17 Changes and Additions to CppAD During 2008: 10-17
-10-18 Changes and Additions to CppAD During 2005: 10-18
-      Changes and Additions to CppAD During 2006: 10-18
-10-19 Changes and Additions to CppAD During 2004: 10-19
-10-20 Changes and Additions to CppAD During 2005: 10-20
-10-21 Changes and Additions to CppAD During 2003: 10-21
-      Changes and Additions to CppAD During 2004: 10-21
-      Changes and Additions to CppAD During 2009: 10-21
-      CppAD Changes and Additions During 2015: 10-21
-10-22 Changes and Additions to CppAD During 2007: 10-22
-      CppAD Changes and Additions During 2013: 10-22
-10-23 Changes and Additions to CppAD During 2007: 10-23
-      Changes and Additions to CppAD During 2009: 10-23
-      CppAD Changes and Additions During 2013: 10-23
-      Changes and Additions to CppAD During 2017: 10-23
-10-24 Changes and Additions to CppAD During 2009: 10-24
-      CppAD Changes and Additions During 2012: 10-24
-10-25 Changes and Additions to CppAD During 2006: 10-25
-      CppAD Changes and Additions During 2012: 10-25
-10-26 Changes and Additions to CppAD During 2006: 10-26
-10-27 Changes and Additions to CppAD During 2004: 10-27
-      Changes and Additions to CppAD During 2006: 10-27
-      Changes and Additions to CppAD During 2007: 10-27
-      Changes and Additions to CppAD During 2008: 10-27
-      Changes and Additions to CppAD During 2009: 10-27
-      Changes and Additions to CppAD During 2016: 10-27
-10-28 Changes and Additions to CppAD During 2004: 10-28
-      Changes and Additions to CppAD During 2006: 10-28
-      Changes and Additions to CppAD During 2009: 10-28
-10-29 Changes and Additions to CppAD During 2004: 10-29
-      Changes and Additions to CppAD During 2006: 10-29
-      Changes and Additions to CppAD During 2009: 10-29
-      Changes and Additions to CppAD During 2011: 10-29
-      CppAD Changes and Additions During 2013: 10-29
-10-30 Changes and Additions to CppAD During 2007: 10-30
-      Changes and Additions to CppAD During 2009: 10-30
-      Changes and Additions to CppAD During 2011: 10-30
-      CppAD Changes and Additions During 2012: 10-30
-10-31 Changes and Additions to CppAD During 2006: 10-31
-      CppAD Changes and Additions During 2012: 10-31
-11-01 Changes and Additions to CppAD During 2004: 11-01
-      Changes and Additions to CppAD During 2005: 11-01
-      Changes and Additions to CppAD During 2006: 11-01
-      Changes and Additions to CppAD During 2007: 11-01
-      Changes and Additions to CppAD During 2011: 11-01
-11-02 Changes and Additions to CppAD During 2003: 11-02
-      Changes and Additions to CppAD During 2004: 11-02
-      Changes and Additions to CppAD During 2006: 11-02
-      Changes and Additions to CppAD During 2007: 11-02
-11-03 Changes and Additions to CppAD During 2007: 11-03
-11-04 Changes and Additions to CppAD During 2003: 11-04
-      Changes and Additions to CppAD During 2004: 11-04
-      Changes and Additions to CppAD During 2006: 11-04
-      Changes and Additions to CppAD During 2007: 11-04
-      Changes and Additions to CppAD During 2011: 11-04
-      CppAD Changes and Additions During 2012: 11-04
-      Changes and Additions to CppAD During 2017: 11-04
-11-05 Changes and Additions to CppAD During 2006: 11-05
-      Changes and Additions to CppAD During 2007: 11-05
-11-06 Changes and Additions to CppAD During 2003: 11-06
-      Changes and Additions to CppAD During 2005: 11-06
-      Changes and Additions to CppAD During 2006: 11-06
-      Changes and Additions to CppAD During 2007: 11-06
-      Changes and Additions to CppAD During 2011: 11-06
-      CppAD Changes and Additions During 2012: 11-06
-      CppAD Changes and Additions During 2015: 11-06
-      Changes and Additions to CppAD During 2017: 11-06
-11-07 Changes and Additions to CppAD During 2005: 11-07
-      Changes and Additions to CppAD During 2011: 11-07
-11-08 Changes and Additions to CppAD During 2006: 11-08
-      CppAD Changes and Additions During 2015: 11-08
-      Changes and Additions to CppAD During 2017: 11-08
-11-09 Changes and Additions to CppAD During 2005: 11-09
-      Changes and Additions to CppAD During 2011: 11-09
-      CppAD Changes and Additions During 2012: 11-09
-11-10 Changes and Additions to CppAD During 2004: 11-10
-11-11 Changes and Additions to CppAD During 2003: 11-11
-11-12 Changes and Additions to CppAD During 2003: 11-12
-      Changes and Additions to CppAD During 2004: 11-12
-      Changes and Additions to CppAD During 2005: 11-12
-      Changes and Additions to CppAD During 2006: 11-12
-      CppAD Changes and Additions During 2013: 11-12
-      Changes and Additions to CppAD During 2017: 11-12
-11-13 Changes and Additions to CppAD During 2004: 11-13
-      CppAD Changes and Additions During 2013: 11-13
-      Changes and Additions to CppAD During 2016: 11-13
-      Changes and Additions to CppAD During 2017: 11-13
-11-14 Changes and Additions to CppAD During 2003: 11-14
-      Changes and Additions to CppAD During 2004: 11-14
-      CppAD Changes and Additions During 2012: 11-14
-      CppAD Changes and Additions During 2015: 11-14
-      Changes and Additions to CppAD During 2016: 11-14
-11-15 Changes and Additions to CppAD During 2003: 11-15
-      Changes and Additions to CppAD During 2004: 11-15
-      Changes and Additions to CppAD During 2005: 11-15
-      Changes and Additions to CppAD During 2017: 11-15
-11-16 Changes and Additions to CppAD During 2003: 11-16
-      Changes and Additions to CppAD During 2004: 11-16
-      CppAD Changes and Additions During 2012: 11-16
-11-17 Changes and Additions to CppAD During 2004: 11-17
-      Changes and Additions to CppAD During 2011: 11-17
-      CppAD Changes and Additions During 2012: 11-17
-11-18 Changes and Additions to CppAD During 2006: 11-18
-      Changes and Additions to CppAD During 2007: 11-18
-      Changes and Additions to CppAD During 2011: 11-18
-      Changes and Additions to CppAD During 2016: 11-18
-11-19 Changes and Additions to CppAD During 2005: 11-19
-      Changes and Additions to CppAD During 2017: 11-19
-11-20 Changes and Additions to CppAD During 2003: 11-20
-      Changes and Additions to CppAD During 2005: 11-20
-      Changes and Additions to CppAD During 2008: 11-20
-      Changes and Additions to CppAD During 2011: 11-20
-      CppAD Changes and Additions During 2012: 11-20
-      Changes and Additions to CppAD During 2017: 11-20
-11-21 Changes and Additions to CppAD During 2003: 11-21
-      Changes and Additions to CppAD During 2008: 11-21
-      Changes and Additions to CppAD During 2011: 11-21
-      CppAD Changes and Additions During 2012: 11-21
-11-22 Changes and Additions to CppAD During 2005: 11-22
-      Changes and Additions to CppAD During 2008: 11-22
-11-23 Changes and Additions to CppAD During 2005: 11-23
-      Changes and Additions to CppAD During 2006: 11-23
-      Changes and Additions to CppAD During 2007: 11-23
-      Changes and Additions to CppAD During 2017: 11-23
-11-24 Changes and Additions to CppAD During 2011: 11-24
-      CppAD Changes and Additions During 2015: 11-24
-11-25 CppAD Changes and Additions During 2015: 11-25
-11-26 Changes and Additions to CppAD During 2009: 11-26
-11-27 Changes and Additions to CppAD During 2009: 11-27
-      Changes and Additions to CppAD During 2010: 11-27
-      Changes and Additions to CppAD During 2011: 11-27
-      CppAD Changes and Additions During 2013: 11-27
-      CppAD Changes and Additions During 2014: 11-27
-11-28 Changes and Additions to CppAD During 2006: 11-28
-      Changes and Additions to CppAD During 2009: 11-28
-      CppAD Changes and Additions During 2012: 11-28
-      CppAD Changes and Additions During 2014: 11-28
-11-29 Changes and Additions to CppAD During 2006: 11-29
-      Changes and Additions to CppAD During 2007: 11-29
-      Changes and Additions to CppAD During 2011: 11-29
-11-30 Changes and Additions to CppAD During 2006: 11-30
-      CppAD Changes and Additions During 2015: 11-30
-      Changes and Additions to CppAD During 2017: 11-30
-12-01 Changes and Additions to CppAD During 2003: 12-01
-      Changes and Additions to CppAD During 2005: 12-01
-      Changes and Additions to CppAD During 2006: 12-01
-      CppAD Changes and Additions During 2015: 12-01
-      Changes and Additions to CppAD During 2017: 12-01
-12-02 Changes and Additions to CppAD During 2005: 12-02
-      Changes and Additions to CppAD During 2006: 12-02
-      Changes and Additions to CppAD During 2007: 12-02
-      Changes and Additions to CppAD During 2009: 12-02
-12-03 Changes and Additions to CppAD During 2004: 12-03
-      Changes and Additions to CppAD During 2005: 12-03
-      Changes and Additions to CppAD During 2006: 12-03
-      Changes and Additions to CppAD During 2007: 12-03
-12-04 Changes and Additions to CppAD During 2007: 12-04
-      Changes and Additions to CppAD During 2008: 12-04
-      Changes and Additions to CppAD During 2009: 12-04
-      Changes and Additions to CppAD During 2017: 12-04
-12-05 Changes and Additions to CppAD During 2003: 12-05
-      Changes and Additions to CppAD During 2005: 12-05
-      Changes and Additions to CppAD During 2006: 12-05
-      Changes and Additions to CppAD During 2007: 12-05
-      Changes and Additions to CppAD During 2017: 12-05
-12-06 Changes and Additions to CppAD During 2005: 12-06
-      Changes and Additions to CppAD During 2017: 12-06
-12-07 Changes and Additions to CppAD During 2005: 12-07
-      Changes and Additions to CppAD During 2006: 12-07
-12-08 Changes and Additions to CppAD During 2005: 12-08
-      Changes and Additions to CppAD During 2007: 12-08
-      CppAD Changes and Additions During 2015: 12-08
-      Changes and Additions to CppAD During 2017: 12-08
-12-09 Changes and Additions to CppAD During 2004: 12-09
-      Changes and Additions to CppAD During 2006: 12-09
-      Changes and Additions to CppAD During 2016: 12-09
-12-10 Changes and Additions to CppAD During 2003: 12-10
-      Changes and Additions to CppAD During 2006: 12-10
-12-11 Changes and Additions to CppAD During 2004: 12-11
-      Changes and Additions to CppAD During 2005: 12-11
-      Changes and Additions to CppAD During 2006: 12-11
-      Changes and Additions to CppAD During 2016: 12-11
-12-12 Changes and Additions to CppAD During 2003: 12-12
-      Changes and Additions to CppAD During 2006: 12-12
-      Changes and Additions to CppAD During 2009: 12-12
-12-13 Changes and Additions to CppAD During 2003: 12-13
-      Changes and Additions to CppAD During 2006: 12-13
-      CppAD Changes and Additions During 2012: 12-13
-      Changes and Additions to CppAD During 2016: 12-13
-12-14 Changes and Additions to CppAD During 2003: 12-14
-      Changes and Additions to CppAD During 2005: 12-14
-      Changes and Additions to CppAD During 2008: 12-14
-      CppAD Changes and Additions During 2012: 12-14
-      Changes and Additions to CppAD During 2017: 12-14
-12-15 Changes and Additions to CppAD During 2005: 12-15
-      Changes and Additions to CppAD During 2006: 12-15
-      CppAD Changes and Additions During 2012: 12-15
-      CppAD Changes and Additions During 2014: 12-15
-12-16 Changes and Additions to CppAD During 2005: 12-16
-      CppAD Changes and Additions During 2014: 12-16
-12-17 Changes and Additions to CppAD During 2006: 12-17
-      CppAD Changes and Additions During 2012: 12-17
-      CppAD Changes and Additions During 2014: 12-17
-12-18 Changes and Additions to CppAD During 2006: 12-18
-      Changes and Additions to CppAD During 2009: 12-18
-      Changes and Additions to CppAD During 2016: 12-18
-12-19 Changes and Additions to CppAD During 2005: 12-19
-      Changes and Additions to CppAD During 2006: 12-19
-      Changes and Additions to CppAD During 2008: 12-19
-      CppAD Changes and Additions During 2012: 12-19
-12-20 Changes and Additions to CppAD During 2005: 12-20
-      Changes and Additions to CppAD During 2011: 12-20
-      CppAD Changes and Additions During 2012: 12-20
-      Changes and Additions to CppAD During 2016: 12-20
-12-21 Changes and Additions to CppAD During 2006: 12-21
-      Changes and Additions to CppAD During 2007: 12-21
-      Changes and Additions to CppAD During 2011: 12-21
-12-22 Changes and Additions to CppAD During 2003: 12-22
-      Changes and Additions to CppAD During 2005: 12-22
-      Changes and Additions to CppAD During 2006: 12-22
-      Changes and Additions to CppAD During 2009: 12-22
-      CppAD Changes and Additions During 2012: 12-22
-      CppAD Changes and Additions During 2014: 12-22
-12-23 Changes and Additions to CppAD During 2005: 12-23
-      Changes and Additions to CppAD During 2006: 12-23
-      Changes and Additions to CppAD During 2009: 12-23
-      CppAD Changes and Additions During 2012: 12-23
-      CppAD Changes and Additions During 2014: 12-23
-      Changes and Additions to CppAD During 2016: 12-23
-12-24 Changes and Additions to CppAD During 2003: 12-24
-      Changes and Additions to CppAD During 2005: 12-24
-      Changes and Additions to CppAD During 2006: 12-24
-      CppAD Changes and Additions During 2013: 12-24
-12-25 Changes and Additions to CppAD During 2007: 12-25
-      CppAD Changes and Additions During 2014: 12-25
-12-26 CppAD Changes and Additions During 2012: 12-26
-      CppAD Changes and Additions During 2013: 12-26
-      CppAD Changes and Additions During 2014: 12-26
-12-27 CppAD Changes and Additions During 2012: 12-27
-      CppAD Changes and Additions During 2013: 12-27
-      CppAD Changes and Additions During 2014: 12-27
-12-28 Changes and Additions to CppAD During 2011: 12-28
-      CppAD Changes and Additions During 2012: 12-28
-      CppAD Changes and Additions During 2014: 12-28
-      CppAD Changes and Additions During 2015: 12-28
-12-29 Changes and Additions to CppAD During 2007: 12-29
-      CppAD Changes and Additions During 2012: 12-29
-      CppAD Changes and Additions During 2013: 12-29
-      CppAD Changes and Additions During 2014: 12-29
-      CppAD Changes and Additions During 2015: 12-29
-12-30 Changes and Additions to CppAD During 2011: 12-30
-      CppAD Changes and Additions During 2012: 12-30
-      CppAD Changes and Additions During 2014: 12-30
-12-31 Changes and Additions to CppAD During 2010: 12-31
-      CppAD Changes and Additions During 2015: 12-31
-1: CppAD Download, Test, and Install Instructions: Instructions.Step 1: Download
-2 AD Theory for Cholesky Factorization: Lemma 2
-2003 Changes and Additions to CppAD During 2003
-2004 Changes and Additions to CppAD During 2004
-2005 Changes and Additions to CppAD During 2005
-2005-08-07 AD Conditional Expressions: Deprecate 2005-08-07
-2006 Changes and Additions to CppAD During 2006
-2006-03-31 ADFun Object Deprecated Member Functions: Memory.Deprecated 2006-03-31
-           ADFun Object Deprecated Member Functions: Order.Deprecated 2006-03-31
-2006-04-03 ADFun Object Deprecated Member Functions: Size.Deprecated 2006-04-03
-2006-04-08 ADFun Object Deprecated Member Functions: use_VecAD.Deprecated 2006-04-08
-2006-06-17 ADFun Object Deprecated Member Functions: taylor_size.Deprecated 2006-06-17
-2006-12-17 Deprecated Include Files: Deprecated 2006-12-17
-2007 Changes and Additions to CppAD During 2007
-2007-07-23 Routines That Track Use of New and Delete: Deprecated 2007-07-23
-2007-07-28 Choosing The Vector Testing Template Class: CppADvector Deprecated 2007-07-28
-           Discrete AD Functions: CppADCreateDiscrete Deprecated 2007-07-28
-2007-07-31 AD Boolean Functions: Deprecated 2007-07-31
-2007-08-07 ADFun Object Deprecated Member Functions: Dependent.Deprecated 2007-08-07
-2008 Changes and Additions to CppAD During 2008
-2009 Changes and Additions to CppAD During 2009
-2010 Changes and Additions to CppAD During 2010
-2011 Changes and Additions to CppAD During 2011
-2011-06-23 OpenMP Parallel Setup: Deprecated 2011-06-23
-2011-08-23 A Quick OpenMP Memory Allocator Used by CppAD: Deprecated 2011-08-23
-2011-08-31 OpenMP Memory Allocator: Example and Test: Deprecated 2011-08-31
-           Return A Raw Array to The Available Memory for a Thread: Deprecated 2011-08-31
-           Allocate Memory and Create A Raw Array: Deprecated 2011-08-31
-           Amount of Memory Available for Quick Use by a Thread: Deprecated 2011-08-31
-           Amount of Memory a Thread is Currently Using: Deprecated 2011-08-31
-           Free Memory Currently Available for Quick Use by a Thread: Deprecated 2011-08-31
-           Return Memory to omp_alloc: Deprecated 2011-08-31
-           Get At Least A Specified Amount of Memory: Deprecated 2011-08-31
-           Get the Current OpenMP Thread Number: Deprecated 2011-08-31
-           Is The Current Execution in OpenMP Parallel Mode: Deprecated 2011-08-31
-           Set and Get Maximum Number of Threads for omp_alloc Allocator: Deprecated 2011-08-31
-2012 CppAD Changes and Additions During 2012
-2012-04-06 Memory Leak Detection: Deprecated 2012-04-06
-2012-06-17 Machine Epsilon For AD Types: Deprecated 2012-06-17
-2012-07-03 Choosing The Vector Testing Template Class: Deprecated 2012-07-03
-2012-11-28 Nonlinear Programming Using the CppAD Interface to Ipopt: Deprecated 2012-11-28
-2012-12-26 Autotools Unix Test and Installation: Deprecated 2012-12-26
-2013 CppAD Changes and Additions During 2013
-2013-05-27 Old Matrix Multiply as a User Atomic Operation: Example and Test: Deprecated 2013-05-27
-           Old Tan and Tanh as User Atomic Operations: Example and Test: Deprecated 2013-05-27
-           Using AD to Compute Atomic Function Derivatives: Deprecated 2013-05-27
-           Using AD to Compute Atomic Function Derivatives: Deprecated 2013-05-27
-           Old Atomic Operation Reciprocal: Example and Test: Deprecated 2013-05-27
-           User Defined Atomic AD Functions: Deprecated 2013-05-27
-2014 CppAD Changes and Additions During 2014
-2014-03-18 ADFun Object Deprecated Member Functions: capacity_taylor.Deprecated 2014-03-18
-           ADFun Object Deprecated Member Functions: size_taylor.Deprecated 2014-03-18
-2015 CppAD Changes and Additions During 2015
-2015-01-20 Comparison Changes During Zero Order Forward Mode: Deprecated 2015-01-20
-2015-09-26 zdouble: An AD Base Type With Absolute Zero: Deprecated 2015-09-26
-2015-10-04 Obtain Nan or Determine if a Value is Nan: nan(zero).Deprecated 2015-10-04
-2015-11-30 Deprecated Include Files: Deprecated 2015-11-30
-2016 Changes and Additions to CppAD During 2016
-2016-06-27 Atomic Reverse Hessian Sparsity Patterns: Deprecated 2016-06-27
-           Atomic Forward Hessian Sparsity Patterns: Deprecated 2016-06-27
-           Atomic Reverse Jacobian Sparsity Patterns: Deprecated 2016-06-27
-           Atomic Forward Jacobian Sparsity Patterns: Deprecated 2016-06-27
-2017 Changes and Additions to CppAD During 2017
-2017-06-01 Sparse Hessian: work.colpack.star Deprecated 2017-06-01
-           Computing Sparse Hessians: coloring.colpack.star Deprecated 2017-06-01
-2: exp_eps: Second Order Reverse Sweep: Index 2: f_1
-   exp_eps: First Order Reverse Sweep: Index 2: f_1
-   exp_2: Second Order Reverse Mode: Index 2: f_1
-   exp_2: First Order Reverse Mode: Index 2: f_1
-   CppAD Download, Test, and Install Instructions: Instructions.Step 2: Cmake
-3 Check Gradient of Determinant of 3 by 3 matrix
-  Check Gradient of Determinant of 3 by 3 matrix
-  Check Determinant of 3 by 3 matrix
-  Check Determinant of 3 by 3 matrix
-3: exp_eps: Second Order Reverse Sweep: Index 3: f_2
-   exp_eps: First Order Reverse Sweep: Index 3: f_2
-   exp_2: Second Order Reverse Mode: Index 3: f_2
-   exp_2: First Order Reverse Mode: Index 3: f_2
-   CppAD Download, Test, and Install Instructions: Instructions.Step 3: Check
-3rd A 3rd and 4th Order Rosenbrock ODE Solver
-4: exp_eps: Second Order Reverse Sweep: Index 4: f_3
-   exp_eps: First Order Reverse Sweep: Index 4: f_3
-   exp_2: Second Order Reverse Mode: Index 4: f_3
-   exp_2: First Order Reverse Mode: Index 4: f_3
-   CppAD Download, Test, and Install Instructions: Instructions.Step 4: Installation
-4th A 3rd and 4th Order Rosenbrock ODE Solver
-    An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-5: exp_eps: Second Order Reverse Sweep: Index 5: f_4
-   exp_eps: First Order Reverse Sweep: Index 5: f_4
-   exp_2: Second Order Reverse Mode: Index 5: f_4
-   exp_2: First Order Reverse Mode: Index 5: f_4
-5th An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-6: exp_eps: Second Order Reverse Sweep: Index 6: f_5
-   exp_eps: First Order Reverse Sweep: Index 6: f_5
-7: exp_eps: Second Order Reverse Sweep: Index 7: f_6
-   exp_eps: First Order Reverse Sweep: Index 7: f_6
-< AD Binary Comparison Operators: Example and Test
-  AD Binary Comparison Operators
-<< AD Output Operator: Example and Test
-   AD Output Operator: Example and Test
-   AD Output Stream Operator
-<= AD Binary Comparison Operators: Example and Test
-   AD Binary Comparison Operators
-= Evaluate a Function Defined in Terms of an ODE: p.p = 1
-  AD Theory for Cholesky Factorization: Reverse Mode.Case k = 0
-== Evaluate a Function Defined in Terms of an ODE: p.p == 0
-   AD Binary Comparison Operators: Example and Test
-   AD Binary Comparison Operators
-> Using Multiple Levels of AD: Procedure.Second Start AD< AD<double> >
-  Using Multiple Levels of AD: Procedure.Start AD< AD<double> > Recording
-  AD Binary Comparison Operators: Example and Test
-  AD Binary Comparison Operators
-  AD Theory for Cholesky Factorization: Reverse Mode.Case k > 0
->= AD Binary Comparison Operators: Example and Test
-   AD Binary Comparison Operators
->> AD Output Stream Operator
-[0
-     1] Simulate a [0,1] Uniform Random Variate
-     1] Simulate a [0,1] Uniform Random Variate
-[] The CppAD::vector Template Class
-   Definition of a Simple Vector
- -A -
-A.1.1c A Simple Parallel Pthread Example and Test
-       A Simple Boost Thread Example and Test
-       A Simple OpenMP Example and Test
-AD Nonlinear Programming Using CppAD and Ipopt: Example and Test
-   Nonlinear Programming Using the CppAD Interface to Ipopt
-   Computing a Jacobian With Constants that Change
-   Example and Test Linking CppAD to Languages Other than C++
-   Nonlinear Programming Using CppAD and Ipopt: Example and Test
-   A Simple pthread AD: Example and Test
-   A Simple Boost Threading AD: Example and Test
-   A Simple OpenMP AD: Example and Test
-   An Introduction by Example to Algorithmic Differentiation
-   cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-ADFun Comparison Changes During Zero Order Forward Mode
-      Comparison Changes Between Taping and Zero Order Forward
-      Stop Recording and Store Operation Sequence
-Automatic An Introduction by Example to Algorithmic Differentiation
-a(x) Create An Abs-normal Representation of a Function: Abs-normal Approximation.Approximating a(x)
-     Create An Abs-normal Representation of a Function: a.a(x)
-a11c Run Multi-Threading Examples and Speed Tests: a11c
-abort Abort Current Recording: Example and Test
-      Abort Recording of an Operation Sequence
-abort_op_index Declare Independent Variables and Start Recording: abort_op_index
-above Glossary: AD Type Above Base
-      The Theory of Forward Mode: Standard Math Functions.Cases that Apply Recursion Above
-abramowitz Bibliography: Abramowitz and Stegun
-abs Enable use of AD<Base> where Base is Adolc's adouble Type: abs
-    AD Absolute Value Function: Example and Test
-    AD Absolute Value Functions: abs, fabs
-abs-normal Non-Smooth Optimization Using Abs-normal Quadratic Approximations
-           abs_normal: Minimize a Linear Abs-normal Approximation
-           Non-Smooth Optimization Using Abs-normal Linear Approximations
-           abs_normal: Minimize a Linear Abs-normal Approximation
-           Create An Abs-normal Representation of a Function: Abs-normal Approximation
-           Create An Abs-normal Representation of a Function
-           Abs-normal Representation of Non-Smooth Functions
-abs_eval abs_eval Source Code
-abs_eval: abs_eval: Example and Test
-abs_min_linear abs_min_linear Source Code
-abs_min_linear: abs_min_linear: Example and Test
-abs_min_quad abs_min_quad Source Code
-abs_min_quad: abs_min_quad: Example and Test
-abs_normal abs_normal min_nso_quad: Example and Test
-           abs_normal qp_box: Example and Test
-           abs_normal qp_interior: Example and Test
-           abs_normal min_nso_linear: Example and Test
-           abs_normal lp_box: Example and Test
-           abs_normal simplex_method: Example and Test
-           abs_normal Getting Started: Example and Test
-abs_normal: abs_normal: Minimize a Linear Abs-normal Approximation
-            abs_normal: Solve a Quadratic Program With Box Constraints
-            abs_normal: Minimize a Linear Abs-normal Approximation
-            abs_normal: Solve a Linear Program With Box Constraints
-            abs_normal: Solve a Linear Program Using Simplex Method
-            abs_normal: Evaluate First Order Approximation
-            abs_normal: Print a Vector or Matrix
-absgeq LU Factorization of A Square Matrix: AbsGeq
-       Compute Determinant and Solve Linear Equations: AbsGeq
-absolute zdouble: An AD Base Type With Absolute Zero: Absolute Zero
-         zdouble: An AD Base Type With Absolute Zero
-         Determine if Two Values Are Nearly Equal
-         AD<Base> Requirements for a CppAD Base Type: Absolute Zero, azmul
-         AD Absolute Zero Multiplication: Example and Test
-         Absolute Zero Multiplication
-         AD Absolute Value Function: Example and Test
-         AD Absolute Value Functions: abs, fabs
-access The CppAD::vector Template Class: Element Access
-       Definition of a Simple Vector: Element Access
-accurate An Epsilon Accurate Exponential Approximation
-aclocal Changes and Additions to CppAD During 2006
-acos Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
-     Inverse Cosine and Hyperbolic Cosine Forward Mode Theory
-     The AD acos Function: Example and Test
-     Inverse Sine Function: acos
-acosh Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
-      Inverse Cosine and Hyperbolic Cosine Forward Mode Theory
-      Enable use of AD<Base> where Base is Adolc's adouble Type: erf, asinh, acosh, atanh, expm1, log1p
-      Example AD<Base> Where Base Constructor Allocates Memory: erf, asinh, acosh, atanh, expm1, log1p
-      Base Type Requirements for Standard Math Functions: erf, asinh, acosh, atanh, expm1, log1p
-      The AD acosh Function: Example and Test
-      The Inverse Hyperbolic Cosine Function: acosh
-active Glossary: Tape.Active
-activity Example Optimization and Reverse Activity Analysis
-         Example Optimization and Forward Activity Analysis
-ad Some Numerical AD Utilities
-   zdouble: An AD Base Type With Absolute Zero
-   Using AD to Compute Atomic Function Derivatives
-   Using AD to Compute Atomic Function Derivatives
-   User Defined Atomic AD Functions: Example.Use AD
-   User Defined Atomic AD Functions
-   Machine Epsilon For AD Types
-   Glossary: AD Type Above Base
-   Glossary: AD of Base
-   Glossary: AD Function
-   Running the Speed Test Program: package.AD Package
-   Speed Test an Operator Overloading AD Package
-   Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Taylor's Method Using AD
-   Taylor's Ode Solver: A Multi-Level AD Example and Test: Taylor's Method Using AD
-   Taylor's Ode Solver: A Multi-Level AD Example and Test
-   Using Multiple Levels of AD
-   Pthread Implementation of a Team of AD Threads
-   Boost Thread Implementation of a Team of AD Threads
-   OpenMP Implementation of a Team of AD Threads
-   Specifications for A Team of AD Threads
-   Using a Team of AD Threads: Example and Test
-   Enable AD Calculations During Parallel Mode
-   Using CppAD in a Multi-Threading Environment: Parallel AD
-   Using a User Defined AD Base Type: Example and Test
-   Example AD Base Types That are not AD<OtherBase>
-   AD Vectors that Record Index Operations: Example and Test
-   AD Vectors that Record Index Operations: AD Indexing
-   AD Vectors that Record Index Operations
-   AD Parameter and Variable Functions: Example and Test
-   Is an AD Object a Parameter or Variable
-   AD Boolean Functions: Example and Test
-   AD Boolean Functions
-   Compare AD with Base Objects: Example and Test
-   Compare AD and Base Objects for Nearly Equal
-   AD Binary Comparison Operators: Example and Test
-   AD Binary Comparison Operators
-   Bool Valued Operations and Functions with AD Arguments
-   AD Theory for Cholesky Factorization
-   Using AD Version of Atomic Function
-   User Defined Atomic AD Functions
-   Checkpointing Functions: Purpose.Multiple Level AD
-   Atomic AD Functions
-   Numeric Limits For an AD and Base Types
-   Discrete AD Functions: Create AD Version
-   Discrete AD Functions
-   AD Conditional Expressions
-   AD Absolute Zero Multiplication: Example and Test
-   The AD Power Function: Example and Test
-   The AD Power Function
-   The AD atan2 Function: Example and Test
-   AD Two Argument Inverse Tangent Function
-   The AD log1p Function: Example and Test
-   The AD exp Function: Example and Test
-   The AD erf Function: Example and Test
-   The AD atanh Function: Example and Test
-   The AD asinh Function: Example and Test
-   The AD acosh Function: Example and Test
-   AD Absolute Value Function: Example and Test
-   AD Absolute Value Functions: abs, fabs
-   The AD tanh Function: Example and Test
-   The AD tan Function: Example and Test
-   The AD sqrt Function: Example and Test
-   The AD sinh Function: Example and Test
-   The AD sin Function: Example and Test
-   The AD log10 Function: Example and Test
-   The AD log Function: Example and Test
-   The AD exp Function: Example and Test
-   The AD cosh Function: Example and Test
-   The AD cos Function: Example and Test
-   The AD atan Function: Example and Test
-   The AD asin Function: Example and Test
-   The AD acos Function: Example and Test
-   AD Compound Assignment Division: Example and Test
-   AD Compound Assignment Multiplication: Example and Test
-   AD Compound Assignment Subtraction: Example and Test
-   AD Compound Assignment Addition: Example and Test
-   AD Compound Assignment Operators
-   AD Binary Division: Example and Test
-   AD Binary Multiplication: Example and Test
-   AD Binary Subtraction: Example and Test
-   AD Binary Addition: Example and Test
-   AD Binary Arithmetic Operators
-   AD Unary Minus Operator: Example and Test
-   AD Unary Minus Operator
-   AD Unary Plus Operator: Example and Test
-   AD Unary Plus Operator
-   AD Arithmetic Operators and Compound Assignments
-   AD Valued Operations and Functions
-   Convert an AD Variable to a Parameter: Example and Test
-   Convert an AD Variable to a Parameter
-   Printing AD Values During Forward Mode
-   AD Output Operator: Example and Test
-   AD Output Operator: Example and Test
-   AD Output Stream Operator
-   AD Output Stream Operator
-   Convert An AD or Base Type to String
-   Convert From AD to Integer: Example and Test
-   Convert From AD to Integer: x.AD Types
-   Convert From AD to Integer
-   Convert From AD to its Base Type: Example and Test
-   Convert From an AD Type to its Base Type
-   Conversion and I/O of AD Objects
-   AD Assignment: Example and Test
-   AD Assignment Operator
-   AD Constructors: Example and Test
-   AD Constructors
-   AD Objects
-ad: Multiple Level of AD: Example and Test
-    A Simple pthread AD: Example and Test
-    A Simple Boost Threading AD: Example and Test
-    A Simple OpenMP AD: Example and Test
-    Atomic Operations and Multiple-Levels of AD: Example and Test
-ad< Using Multiple Levels of AD: Procedure.Second Start AD< AD<double> >
-    Using Multiple Levels of AD: Procedure.Start AD< AD<double> > Recording
-ad<base> Enable use of AD<Base> where Base is std::complex<double>
-         Enable use of AD<Base> where Base is double
-         Enable use of AD<Base> where Base is float
-         Enable use of AD<Base> where Base is Adolc's adouble Type
-         Example AD<Base> Where Base Constructor Allocates Memory
-         AD<Base> Requirements for a CppAD Base Type
-         Absolute Zero Multiplication: AD<Base>
-         The Unary Standard Math Functions: Possible Types.AD<Base>
-ad<double> Using Multiple Levels of AD: Procedure.Second Start AD< AD<double> >
-           Using Multiple Levels of AD: Procedure.Start AD< AD<double> > Recording
-           Using Multiple Levels of AD: Procedure.First Start AD<double>
-ad<otherbase> Example AD Base Types That are not AD<OtherBase>
-add AD Compound Assignment Division: Example and Test
-    AD Compound Assignment Multiplication: Example and Test
-    AD Compound Assignment Subtraction: Example and Test
-    AD Compound Assignment Addition: Example and Test
-    AD Compound Assignment Operators
-    AD Binary Addition: Example and Test
-    AD Binary Arithmetic Operators
-add_static Memory Leak Detection: add_static
-addition The Theory of Reverse Mode: Binary Operators.Addition
-         The Theory of Forward Mode: Binary Operators.Addition
-         AD Compound Assignment Operators: Derivative.Addition
-         AD Binary Arithmetic Operators: Derivative.Addition
-addition: AD Compound Assignment Addition: Example and Test
-          AD Binary Addition: Example and Test
-additions Changes and Additions to CppAD During 2003
-          Changes and Additions to CppAD During 2004
-          Changes and Additions to CppAD During 2005
-          Changes and Additions to CppAD During 2006
-          Changes and Additions to CppAD During 2007
-          Changes and Additions to CppAD During 2008
-          Changes and Additions to CppAD During 2009
-          Changes and Additions to CppAD During 2010
-          Changes and Additions to CppAD During 2011
-          CppAD Changes and Additions During 2012
-          CppAD Changes and Additions During 2013
-          CppAD Changes and Additions During 2014
-          CppAD Changes and Additions During 2015
-          Changes and Additions to CppAD During 2016
-          Changes and Additions to CppAD During 2017
-          Changes and Additions to CppAD
-addons CppAD Addons
-adfun ADFun Object Deprecated Member Functions
-      Creating Your Own Interface to an ADFun Object
-      ADFun Checking For Nan: Example and Test
-      Check an ADFun Object For Nan Results
-      ADFun Check and Re-Tape: Example and Test
-      Check an ADFun Sequence of Operations
-      Optimize an ADFun Object Tape
-      Hessian of Lagrangian and ADFun Default Constructor: Example and Test
-      ADFun Sequence Properties: Example and Test
-      ADFun Sequence Properties
-      ADFun Assignment: Example and Test
-      Construct an ADFun Object and Stop Recording
-      Independent and ADFun Constructor: Example and Test
-      Create an ADFun Object (Record an Operation Sequence)
-      ADFun Objects
-adnumber Nonlinear Programming Using the CppAD Interface to Ipopt: ADNumber
-adol-Including the ADOL-C Examples and Tests
-adolc The CppAD Wish List: Adolc
-      Adolc Test Utility: Allocate and Free Memory For a Matrix
-      adolc Speed: Sparse Jacobian
-      Adolc Speed: Sparse Hessian
-      Adolc Speed: Second Derivative of a Polynomial
-      Adolc Speed: Ode
-      Adolc Speed: Matrix Multiplication
-      Adolc Speed: Gradient of Determinant Using Lu Factorization
-      Adolc Speed: Gradient of Determinant by Minor Expansion
-      Speed Test of Derivatives Using Adolc
-      Taylor's Ode Solver: A Multi-Level Adolc Example and Test
-      Using Adolc with Multiple Levels of Taping: Example and Test
-      Download and Install Adolc in Build Directory
-      Including the ADOL-C Examples and Tests
-adolc'Enable use of AD<Base> where Base is Adolc's adouble Type
-adolc_alloc_mat Adolc Test Utility: Allocate and Free Memory For a Matrix
-adolc_dir Autotools Unix Test and Installation: adolc_dir
-adolc_prefix Speed Test of Derivatives Using Adolc: adolc_prefix
-             Including the ADOL-C Examples and Tests: adolc_prefix
-adouble Enable use of AD<Base> where Base is Adolc's adouble Type
-advector LU Factorization of A Square Matrix and Stability Calculation: ADvector
-         Computing Jacobian and Hessian of Bender's Reduced Objective: ADvector
-         Nonlinear Programming Using the CppAD Interface to Ipopt: ADVector
-         Use Ipopt to Solve a Nonlinear Programming Problem: fg_eval.ADvector
-         Stop Recording and Store Operation Sequence: ADvector
-         Using AD Version of Atomic Function: ADVector
-         Checkpointing Functions: ADVector
-affine Create An Abs-normal Representation of a Function: Affine Approximation
-after Printing AD Values During Forward Mode: after
-afun User Defined Atomic AD Functions: afun
-     Using AD Version of Atomic Function: afun
-     Atomic Function Constructor: atomic_user.afun
-algebra Enable Use of Eigen Linear Algebra Package with CppAD
-algo Checkpointing Functions: algo
-algorithm Differentiate Conjugate Gradient Algorithm: Example and Test: Algorithm
-          Hessian Sparsity Pattern: Forward Mode: Algorithm
-          Forward Mode Hessian Sparsity Patterns: Algorithm
-          An Epsilon Accurate Exponential Approximation
-          Second Order Exponential Approximation
-          cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-algorithm: Differentiate Conjugate Gradient Algorithm: Example and Test
-algorithmic Example and Test Linking CppAD to Languages Other than C++
-            An Introduction by Example to Algorithmic Differentiation: Preface.Algorithmic Differentiation
-            An Introduction by Example to Algorithmic Differentiation
-            cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-algorithms cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-alignment Allocate An Array and Call Default Constructor for its Elements: Alignment
-          Get At Least A Specified Amount of Memory: Alignment
-all List All (Except Deprecated) CppAD Examples
-    Free All Memory That Was Allocated for Use by thread_alloc
-    Checking the CppAD Examples and Tests: Check All
-alloc Adolc Test Utility: Allocate and Free Memory For a Matrix
-      Control When Thread Alloc Retains Memory For Future Use
-allocate Allocate Memory and Create A Raw Array
-         Adolc Test Utility: Allocate and Free Memory For a Matrix
-         Allocate An Array and Call Default Constructor for its Elements
-         Get At Least A Specified Amount of Memory
-allocated Free All Memory That Was Allocated for Use by thread_alloc
-allocates Example AD<Base> Where Base Constructor Allocates Memory
-allocation OpenMP Memory Allocator: Example and Test
-           Check If A Memory Allocation is Efficient for Another Use
-           Get At Least A Specified Amount of Memory: Allocation Speed
-           A Quick OpenMP Memory Allocator Used by CppAD
-           Frequently Asked Questions and Answers: Speed.Memory Allocation
-           Get At Least A Specified Amount of Memory: Allocation Speed
-           Fast Multi-Threading Memory Allocator: Example and Test
-           A Fast Multi-Threading Memory Allocator
-           Some General Purpose Utilities: Miscellaneous.Multi-Threading Memory Allocation
-           Controlling Taylor Coefficients Memory Allocation
-allocation: Controlling Taylor Coefficient Memory Allocation: Example and Test
-allocator Set Maximum Number of Threads for omp_alloc Allocator
-          Set and Get Maximum Number of Threads for omp_alloc Allocator
-          A Quick OpenMP Memory Allocator Used by CppAD
-          A Fast Multi-Threading Memory Allocator
-allocator: OpenMP Memory Allocator: Example and Test
-           Fast Multi-Threading Memory Allocator: Example and Test
-also Jacobian and Hessian of Optimal Values: See Also
-     Computing Jacobian and Hessian of Bender's Reduced Objective: See Also
-     Convert Certain Types to a String: See Also
-     The Integer Power Function: See Also
-     Example Optimization and Nested Conditional Expressions: See Also
-     Example Optimization and Conditional Expressions: See Also
-     Example Optimization and Comparison Operators: See Also
-     Subset of a Sparse Hessian: Example and Test: See Also
-     Computing Sparse Hessian for a Subset of Variables: See Also
-     Sparsity Patterns For a Subset of Variables: Example and Test: See Also
-     Reverse Mode General Case (Checkpointing): Example and Test: See Also
-     Number of Variables that Can be Skipped: Syntax.See Also
-     Controlling Taylor Coefficients Memory Allocation: Syntax.See Also
-     Number Taylor Coefficient Orders Currently Stored: Syntax.See Also
-     ADFun Sequence Properties: Syntax.See Also
-     Matrix Multiply as an Atomic Operation: See Also
-     User Atomic Matrix Multiply: Example and Test: See Also
-     Atomic Eigen Matrix Multiply Class: See Also
-     Checkpointing an Extended ODE Solver: Example and Test: See Also
-     Checkpointing an ODE Solver: Example and Test: See Also
-     Checkpointing Functions: See Also
-     Interpolation With Retaping: Example and Test: See Also
-     Interpolation With Out Retaping: Example and Test: See Also
-     Conditional Expressions: Example and Test: See Also
-     The AD Power Function: See Also
-     Convert an AD Variable to a Parameter: See Also
-     Convert An AD or Base Type to String: See Also
-     Convert From an AD Type to its Base Type: See Also
-alternative Printing AD Values During Forward Mode: Alternative
-alternatives AD Vectors that Record Index Operations: Alternatives
-amount Determine Amount of Time to Execute det_by_minor
-       Amount of Memory Available for Quick Use by a Thread
-       Amount of Memory a Thread is Currently Using
-       Get At Least A Specified Amount of Memory
-       Amount of Memory Available for Quick Use by a Thread
-       Amount of Memory a Thread is Currently Using
-       Get At Least A Specified Amount of Memory
-       Determine Amount of Time to Execute a Test
-analysis Example Optimization and Reverse Activity Analysis
-         Example Optimization and Forward Activity Analysis
-analytic An ODE Inverse Problem Example: Measurements.Simulation Analytic Solution
-         ODE Inverse Problem Definitions: Source Code: Measurements.Simulation Analytic Solution
-another Check If A Memory Allocation is Efficient for Another Use
-        Extending to_string To Another Floating Point Type
-answers Frequently Asked Questions and Answers
-any Any Order Reverse Mode
-    Multiple Order Forward Mode
-api CppAD Deprecated API Features
-    Changes and Additions to CppAD During 2017: API Changes
-    The CppAD Wish List: Atomic.New API
-    CppAD API Preprocessor Symbols
-    AD<Base> Requirements for a CppAD Base Type: API Warning
-appendix Appendix
-apply The Theory of Forward Mode: Standard Math Functions.Cases that Apply Recursion Above
-approximating Create An Abs-normal Representation of a Function: Abs-normal Approximation.Approximating f(x)
-              Create An Abs-normal Representation of a Function: Abs-normal Approximation.Approximating a(x)
-approximation ODE Fitting Using Fast Representation: Trapezoidal Approximation
-              ODE Fitting Using Simple Representation: Trapezoidal Approximation Constraint
-              An ODE Inverse Problem Example: Trapezoidal Approximation
-              ODE Inverse Problem Definitions: Source Code: Trapezoidal Approximation
-              abs_normal: Minimize a Linear Abs-normal Approximation
-              abs_normal: Minimize a Linear Abs-normal Approximation
-              abs_normal: Evaluate First Order Approximation
-              Create An Abs-normal Representation of a Function: Abs-normal Approximation
-              Create An Abs-normal Representation of a Function: Affine Approximation
-              Correctness Tests For Exponential Approximation in Introduction
-              An Epsilon Accurate Exponential Approximation
-              Second Order Exponential Approximation
-approximations Non-Smooth Optimization Using Abs-normal Quadratic Approximations
-               Non-Smooth Optimization Using Abs-normal Linear Approximations
-arbitrary An Arbitrary Order Gear Method
-archives Download The CppAD Source Code: Compressed Archives
-are Determine if Two Values Are Nearly Equal
-    Example AD Base Types That are not AD<OtherBase>
-    Check if Two Value are Identically Equal
-argument ODE Fitting Using Simple Representation: Argument Vector
-         OdeErrControl: Example and Test Using Maxabs Argument
-         AD Two Argument Inverse Tangent Function
-argument: The Logarithm of One Plus Argument: log1p
-arguments Bool Valued Operations and Functions with AD Arguments
-arguments: LuSolve With Complex Arguments: Example and Test
-arithmetic zdouble: An AD Base Type With Absolute Zero: Syntax.Arithmetic Operators
-           AD Binary Arithmetic Operators
-           AD Arithmetic Operators and Compound Assignments
-array Return A Raw Array to The Available Memory for a Thread: array
-      Return A Raw Array to The Available Memory for a Thread
-      Allocate Memory and Create A Raw Array: array
-      Allocate Memory and Create A Raw Array
-      Using Eigen Arrays: Example and Test
-      Deallocate An Array and Call Destructor for its Elements: array
-      Deallocate An Array and Call Destructor for its Elements
-      Allocate An Array and Call Default Constructor for its Elements: array
-      Allocate An Array and Call Default Constructor for its Elements
-      Taping Array Index Operation: Example and Test
-arrays: Using Eigen Arrays: Example and Test
-asin Inverse Sine and Hyperbolic Sine Reverse Mode Theory
-     Inverse Sine and Hyperbolic Sine Forward Mode Theory
-     The AD asin Function: Example and Test
-     Inverse Sine Function: asin
-asinh Inverse Sine and Hyperbolic Sine Reverse Mode Theory
-      Inverse Sine and Hyperbolic Sine Forward Mode Theory
-      Enable use of AD<Base> where Base is Adolc's adouble Type: erf, asinh, acosh, atanh, expm1, log1p
-      Example AD<Base> Where Base Constructor Allocates Memory: erf, asinh, acosh, atanh, expm1, log1p
-      Base Type Requirements for Standard Math Functions: erf, asinh, acosh, atanh, expm1, log1p
-      The AD asinh Function: Example and Test
-      The Inverse Hyperbolic Sine Function: asinh
-asked Frequently Asked Questions and Answers
-assert CppAD Assertions During Execution
-       Replacing the CppAD Error Handler
-assertions CppAD Assertions During Execution
-assign AD Conditional Expressions
-       AD Compound Assignment Division: Example and Test
-       AD Compound Assignment Multiplication: Example and Test
-       AD Compound Assignment Subtraction: Example and Test
-       AD Compound Assignment Addition: Example and Test
-       AD Assignment: Example and Test
-       AD Assignment Operator
-assignment zdouble: An AD Base Type With Absolute Zero: Syntax.Constructor and Assignment
-           Frequently Asked Questions and Answers: Assignment and Independent
-           The CppAD::vector Template Class: Assignment
-           Definition of a Simple Vector: Element Access.Assignment
-           Definition of a Simple Vector: Assignment
-           Definition of a Numeric Type: Assignment
-           ADFun Assignment: Example and Test
-           Construct an ADFun Object and Stop Recording: Example.Assignment Operator
-           Construct an ADFun Object and Stop Recording: Assignment Operator
-           Example AD<Base> Where Base Constructor Allocates Memory: Compound Assignment Macro
-           Required Base Class Member Functions: Assignment Operators
-           AD Compound Assignment Division: Example and Test
-           AD Compound Assignment Multiplication: Example and Test
-           AD Compound Assignment Subtraction: Example and Test
-           AD Compound Assignment Addition: Example and Test
-           AD Compound Assignment Operators
-           AD Assignment Operator
-assignment: ADFun Assignment: Example and Test
-            AD Assignment: Example and Test
-assignments AD Arithmetic Operators and Compound Assignments
-assumption AD Output Stream Operator: Assumption
-assumptions AD Binary Comparison Operators: Assumptions
-atan Inverse Tangent and Hyperbolic Tangent Forward Mode Theory
-     The AD atan Function: Example and Test
-     Inverse Tangent Function: atan
-atan2 The CppAD Wish List: atan2
-      AD Conditional Expressions: Atan2
-      The AD atan2 Function: Example and Test
-      AD Two Argument Inverse Tangent Function
-atanh Inverse Tangent and Hyperbolic Tangent Forward Mode Theory
-      Enable use of AD<Base> where Base is Adolc's adouble Type: erf, asinh, acosh, atanh, expm1, log1p
-      Example AD<Base> Where Base Constructor Allocates Memory: erf, asinh, acosh, atanh, expm1, log1p
-      Base Type Requirements for Standard Math Functions: erf, asinh, acosh, atanh, expm1, log1p
-      The AD atanh Function: Example and Test
-      The Inverse Hyperbolic Tangent Function: atanh
-atom_fun Checkpointing Functions: atom_fun
-atomic Define Matrix Multiply as a User Atomic Operation: CppAD User Atomic Callback Functions
-       Define Matrix Multiply as a User Atomic Operation
-       Old Matrix Multiply as a User Atomic Operation: Example and Test
-       Old Tan and Tanh as User Atomic Operations: Example and Test
-       Using AD to Compute Atomic Function Derivatives
-       Using AD to Compute Atomic Function Derivatives
-       Old Atomic Operation Reciprocal: Example and Test
-       User Defined Atomic AD Functions
-       CppAD Deprecated API Features: Atomic Functions
-       The CppAD Wish List: Atomic
-       Glossary: Operation.Atomic
-       Frequently Asked Questions and Answers: Matrix Inverse.Atomic Operation
-       Running the Speed Test Program: Global Options.atomic
-       Timing Test for Multi-Threaded User Atomic Calculation
-       Run Multi-Threaded User Atomic Calculation
-       Multi-Threaded User Atomic Take Down
-       Multi-Threaded User Atomic Worker
-       Multi-Threaded User Atomic Set Up
-       Multi-Threaded User Atomic Common Information
-       Defines a User Atomic Operation that Computes Square Root
-       Multi-Threading User Atomic Example / Test
-       Optimize an ADFun Object Tape: Atomic Functions
-       Subgraph Dependency Sparsity Patterns: Atomic Function
-       Matrix Multiply as an Atomic Operation
-       User Atomic Matrix Multiply: Example and Test: Use Atomic Function
-       User Atomic Matrix Multiply: Example and Test
-       Atomic Eigen Cholesky Factorization Class
-       Atomic Eigen Cholesky Factorization: Example and Test: Use Atomic Function
-       Atomic Eigen Cholesky Factorization: Example and Test
-       Atomic Eigen Matrix Inversion Class
-       Atomic Eigen Matrix Inverse: Example and Test: Use Atomic Function
-       Atomic Eigen Matrix Inverse: Example and Test
-       Atomic Eigen Matrix Multiply Class
-       Atomic Eigen Matrix Multiply: Example and Test: Use Atomic Function
-       Atomic Eigen Matrix Multiply: Example and Test
-       Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function
-       Tan and Tanh as User Atomic Operations: Example and Test
-       Atomic Sparsity with Set Patterns: Example and Test: Test Atomic Function
-       Atomic Sparsity with Set Patterns: Example and Test
-       Reciprocal as an Atomic Operation: Example and Test: Use Atomic Function
-       Reciprocal as an Atomic Operation: Example and Test
-       Atomic Euclidean Norm Squared: Example and Test: Use Atomic Function
-       Atomic Euclidean Norm Squared: Example and Test
-       Getting Started with Atomic Operations: Example and Test: Use Atomic Function
-       Getting Started with Atomic Operations: Example and Test
-       Atomic Reverse Hessian Sparsity: Example and Test: Use Atomic Function
-       Atomic Reverse Hessian Sparsity: Example and Test
-       Atomic Forward Hessian Sparsity: Example and Test: Use Atomic Function
-       Atomic Forward Hessian Sparsity: Example and Test
-       Atomic Reverse Jacobian Sparsity: Example and Test: Use Atomic Function
-       Atomic Reverse Jacobian Sparsity: Example and Test
-       Atomic Forward Jacobian Sparsity: Example and Test: Use Atomic Function
-       Atomic Forward Jacobian Sparsity: Example and Test
-       Atomic Reverse: Example and Test: Use Atomic Function
-       Atomic Reverse: Example and Test
-       Atomic Forward: Example and Test: Use Atomic Function
-       Atomic Forward: Example and Test
-       Atomic Reverse Hessian Sparsity Patterns
-       Atomic Forward Hessian Sparsity Patterns
-       Atomic Reverse Jacobian Sparsity Patterns
-       Atomic Forward Jacobian Sparsity Patterns
-       Atomic Reverse Mode
-       Atomic Forward Mode
-       Using AD Version of Atomic Function
-       Set Atomic Function Options
-       Atomic Function Constructor
-       User Defined Atomic AD Functions
-       Atomic Operations and Multiple-Levels of AD: Example and Test
-       Atomic AD Functions
-       The Sign: sign: Atomic
-       AD Absolute Value Functions: abs, fabs: Atomic
-       The Hyperbolic Tangent Function: tanh: Atomic
-       The Tangent Function: tan: Atomic
-       The Square Root Function: sqrt: Atomic
-       The Hyperbolic Sine Function: sinh: Atomic
-       The Sine Function: sin: Atomic
-       The Exponential Function: log: Atomic
-       The Exponential Function: exp: Atomic
-       The Hyperbolic Cosine Function: cosh: Atomic
-       The Cosine Function: cos: Atomic
-       Inverse Tangent Function: atan: Atomic
-       Inverse Sine Function: asin: Atomic
-       Inverse Sine Function: acos: Atomic
-atomic_base Atomic Function Constructor: atomic_base
-atomic_sparsity Set Atomic Function Options: atomic_sparsity
-atomic_user Atomic Function Constructor: atomic_user
-au Defines a User Atomic Operation that Computes Square Root: au
-automatic Example and Test Linking CppAD to Languages Other than C++
-          cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-autotools Autotools Unix Test and Installation
-available Memory Leak Detection: available
-          Return A Raw Array to The Available Memory for a Thread
-          Amount of Memory Available for Quick Use by a Thread
-          Free Memory Currently Available for Quick Use by a Thread
-          Amount of Memory Available for Quick Use by a Thread
-          Free Memory Currently Available for Quick Use by a Thread
-          Return Memory to thread_alloc
-ax User Defined Atomic AD Functions: afun.ax
-   Using AD Version of Atomic Function: ax
-   Checkpointing Functions: ax
-   Discrete AD Functions: ax
-ay User Defined Atomic AD Functions: afun.ay
-   Defines a User Atomic Operation that Computes Square Root: ay
-   Using AD Version of Atomic Function: ay
-   Checkpointing Functions: ay
-   Discrete AD Functions: ay
-azmul Enable use of AD<Base> where Base is std::complex<double>: azmul
-      Enable use of AD<Base> where Base is double: azmul
-      Enable use of AD<Base> where Base is float: azmul
-      Enable use of AD<Base> where Base is Adolc's adouble Type: azmul
-      Example AD<Base> Where Base Constructor Allocates Memory: azmul
-      AD<Base> Requirements for a CppAD Base Type: Absolute Zero, azmul
- -B -
-Base AD Assignment Operator
-     AD Constructors
-BenderQuad BenderQuad: Example and Test
-           Computing Jacobian and Hessian of Bender's Reduced Objective
-b_in Non-Smooth Optimization Using Abs-normal Quadratic Approximations: b_in
-     Non-Smooth Optimization Using Abs-normal Linear Approximations: b_in
-background Using Multiple Levels of AD: Background
-base zdouble: An AD Base Type With Absolute Zero: Base Type Requirements
-     zdouble: An AD Base Type With Absolute Zero
-     User Defined Atomic AD Functions: CPPAD_USER_ATOMIC.Base
-     The CppAD Wish List: Base Requirements
-     Glossary: Base Type
-     Glossary: Base Function
-     Glossary: AD Type Above Base
-     Glossary: AD of Base
-     Enable use of AD<Base> where Base is std::complex<double>
-     Enable use of AD<Base> where Base is double
-     Enable use of AD<Base> where Base is float
-     Enable use of AD<Base> where Base is Adolc's adouble Type
-     Using a User Defined AD Base Type: Example and Test
-     Example AD<Base> Where Base Constructor Allocates Memory
-     Example AD Base Types That are not AD<OtherBase>
-     Base Type Requirements for Hash Coding Values
-     Extending to_string To Another Floating Point Type: Base Requirement
-     Base Type Requirements for Numeric Limits
-     Base Type Requirements for Standard Math Functions
-     Base Type Requirements for Ordered Comparisons
-     Base Type Requirements for Identically Equal Comparisons
-     Base Type Requirements for Conditional Expressions
-     Required Base Class Member Functions
-     AD<Base> Requirements for a CppAD Base Type: Standard Base Types
-     AD<Base> Requirements for a CppAD Base Type
-     Compare AD with Base Objects: Example and Test
-     Compare AD and Base Objects for Nearly Equal
-     Atomic Function Constructor: atomic_base.Base
-     Checkpointing Functions: Base
-     Numeric Limits For an AD and Base Types
-     Discrete AD Functions: Base
-     Absolute Zero Multiplication: Base
-     The Base 10 Logarithm Function: log10
-     The Unary Standard Math Functions: Possible Types.Base
-     AD Compound Assignment Operators: Base
-     AD Binary Arithmetic Operators: Base
-     AD Unary Minus Operator: Base
-     Convert An AD or Base Type to String
-     Convert From AD to its Base Type: Example and Test
-     Convert From an AD Type to its Base Type
-     AD Objects: Base Type Requirements
-base_adolc.hpp Taylor's Ode Solver: A Multi-Level Adolc Example and Test: base_adolc.hpp
-basevector Jacobian and Hessian of Optimal Values: BaseVector
-           Compute Sparse Jacobians Using Subgraphs: BaseVector
-           Computing Sparse Hessians: BaseVector
-           Computing Sparse Jacobians: BaseVector
-           Reverse Mode Using Subgraphs: BaseVector
-bavector Computing Jacobian and Hessian of Bender's Reduced Objective: BAvector
-be Number of Variables That Can be Skipped: Example and Test
-   Number of Variables that Can be Skipped
-before Printing AD Values During Forward Mode: before
-begin Define Matrix Multiply as a User Atomic Operation: Begin Source
-bender'Computing Jacobian and Hessian of Bender's Reduced Objective
-benderquad The CppAD Wish List: BenderQuad
-benderquad: BenderQuad: Example and Test
-between Comparison Changes Between Taping and Zero Order Forward
-bibliography Bibliography
-binary The Theory of Reverse Mode: Binary Operators
-       The Theory of Forward Mode: Binary Operators
-       Example AD<Base> Where Base Constructor Allocates Memory: Binary Operator Macro
-       Required Base Class Member Functions: Binary Operators
-       AD Boolean Functions: Create Binary
-       AD Binary Comparison Operators: Example and Test
-       AD Binary Comparison Operators
-       The Binary Math Functions
-       AD Binary Division: Example and Test
-       AD Binary Multiplication: Example and Test
-       AD Binary Subtraction: Example and Test
-       AD Binary Addition: Example and Test
-       AD Binary Arithmetic Operators
-binary_name AD Boolean Functions: binary_name
-bit_per_unit The CppAD::vector Template Class: vectorBool.bit_per_unit
-black An ODE Inverse Problem Example: Black Box Method
-bool CppAD::vectorBool Class: Example and Test
-     Required Base Class Member Functions: Bool Operators
-     AD Boolean Functions: Example and Test
-     AD Boolean Functions
-     Bool Valued Operations and Functions with AD Arguments
-bool_sparsity_enum Atomic Euclidean Norm Squared: Example and Test
-                   Set Atomic Function Options: atomic_sparsity.bool_sparsity_enum
-boolean Glossary: Sparsity Pattern.Boolean Vector
-        Example AD<Base> Where Base Constructor Allocates Memory: Boolean Operator Macro
-        AD Boolean Functions: Example and Test
-        AD Boolean Functions
-boolsparsity Running the Speed Test Program: Sparsity Options.boolsparsity
-boolvector Compute Sparse Jacobians Using Subgraphs: BoolVector
-           Subgraph Dependency Sparsity Patterns: BoolVector
-           Forward Mode Hessian Sparsity Patterns: BoolVector
-           Reverse Mode Hessian Sparsity Patterns: BoolVector
-           Reverse Mode Using Subgraphs: BoolVector
-boost Fast Multi-Threading Memory Allocator: Example and Test
-      Boost Thread Implementation of a Team of AD Threads
-      A Simple Boost Threading AD: Example and Test
-      A Simple Boost Thread Example and Test
-      Choosing the CppAD Test Vector Template Class: boost
-boost::numeric::ublas::vector Choosing The Vector Testing Template Class: boost::numeric::ublas::vector
-                              Using The CppAD Test Vector Template Class: boost::numeric::ublas::vector
-boost_dir Autotools Unix Test and Installation: boost_dir
-both Speed Test for Both Simple and Fast Representations
-     Correctness Check for Both Simple and Fast Representations
-     Atomic Reverse Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-     Atomic Forward Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-     Atomic Reverse Jacobian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-     Atomic Forward Jacobian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-bound abs_normal: Minimize a Linear Abs-normal Approximation: bound
-      abs_normal: Minimize a Linear Abs-normal Approximation: bound
-box An ODE Inverse Problem Example: Black Box Method
-    abs_normal: Solve a Quadratic Program With Box Constraints
-    abs_normal: Solve a Linear Program With Box Constraints
-bthread Boost Thread Implementation of a Team of AD Threads
-bug Pthread Implementation of a Team of AD Threads: Bug in Cygwin
-bugs Frequently Asked Questions and Answers: Bugs
-build Autotools Unix Test and Installation: Build Directory
-      Run Multi-Threading Examples and Speed Tests: build
-      Download and Install Sacado in Build Directory
-      Download and Install Ipopt in Build Directory
-      Download and Install Fadbad in Build Directory
-      Download and Install Eigen in Build Directory
-      Download and Install ColPack in Build Directory
-      Download and Install Adolc in Build Directory
-      Using CMake to Configure CppAD: CMake Command.Build Directory
-building Download The CppAD Source Code: Building Documentation
-bvector Use Ipopt to Solve a Nonlinear Programming Problem: Bvector
- -C -
-C Interfacing to C: Example and Test
-  Example and Test Linking CppAD to Languages Other than C++
-     compare speed with C++ Compare Speed of C and C++
-C++ cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-     compare speed with Compare Speed of C and C++
-CheckNumericType Check NumericType Class Concept
-CheckSimpleVector Check Simple Vector Concept
-CompareChange Comparison Changes During Zero Order Forward Mode
-CondExp Base Type Requirements for Conditional Expressions
-CPPAD_ CppAD API Preprocessor Symbols
-CPPAD_ASSERT_KNOWN CppAD Assertions During Execution
-CPPAD_ASSERT_UNKNOWN CppAD Assertions During Execution
-CPPAD_BOOL_BINARY AD Boolean Functions
-CPPAD_BOOL_UNARY AD Boolean Functions
-CPPAD_COND_EXP_REL Base Type Requirements for Conditional Expressions
-CPPAD_DISCRETE_FUNCTION Discrete AD Functions
-CPPAD_TEST_VECTOR Choosing The Vector Testing Template Class
-CPPAD_TESTVECTOR Using The CppAD Test Vector Template Class
-CPPAD_TRACK_COUNT Routines That Track Use of New and Delete
-CPPAD_TRACK_DEL_VEC Routines That Track Use of New and Delete
-CPPAD_TRACK_EXTEND Routines That Track Use of New and Delete
-CPPAD_TRACK_NEW_VEC Routines That Track Use of New and Delete
-CppAD CppAD::vectorBool Class: Example and Test
-      CppAD::vector Template Class: Example and Test
-      The CppAD::vector Template Class
-      cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-CppADTrackDelVec Routines That Track Use of New and Delete
-CppADTrackExtend Routines That Track Use of New and Delete
-CppADTrackNewVec Routines That Track Use of New and Delete
-c Main Program For Comparing C and C++ Speed
-  Determinant of a Minor: c
-  Compare Speed of C and C++
-  Comparison Changes During Zero Order Forward Mode: c
-  Determinant of a Minor: c
-  Row and Column Index Sparsity Patterns: set.c
-  abs_normal: Solve a Quadratic Program With Box Constraints: C
-  abs_normal: Solve a Quadratic Program With Box Constraints: c
-  Solve a Quadratic Program Using Interior Point Method: C
-  Solve a Quadratic Program Using Interior Point Method: c
-  abs_normal: Solve a Linear Program With Box Constraints: c
-  abs_normal: Solve a Linear Program Using Simplex Method: c
-  Controlling Taylor Coefficients Memory Allocation: c
-c++ Main Program For Comparing C and C++ Speed
-    Compare Speed of C and C++
-    Bibliography: The C++ Programming Language
-    Example and Test Linking CppAD to Languages Other than C++
-    Some General Purpose Utilities: C++ Concepts
-    cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-c++11 Using CMake to Configure CppAD: cppad_cxx_flags.C++11
-c: Interfacing to C: Example and Test
-calculating Calculating Sparse Derivatives
-            Calculating Sparsity Patterns
-calculation LU Factorization of A Square Matrix and Stability Calculation
-            Timing Test for Multi-Threaded User Atomic Calculation
-            Run Multi-Threaded User Atomic Calculation
-calculations The Theory of Derivative Calculations
-             Enable AD Calculations During Parallel Mode
-             Including the ColPack Sparsity Calculations
-call Define Matrix Multiply as a User Atomic Operation: Extra Call Information
-     Deallocate An Array and Call Destructor for its Elements
-     Allocate An Array and Call Default Constructor for its Elements
-     Replacing the CppAD Error Handler: Call
-callback Define Matrix Multiply as a User Atomic Operation: CppAD User Atomic Callback Functions
-         User Defined Atomic AD Functions: Syntax Function.Callback Routines
-         Atomic Forward Mode
-can Number of Variables That Can be Skipped: Example and Test
-    Number of Variables that Can be Skipped
-cap_bytes Get At Least A Specified Amount of Memory: cap_bytes
-          Get At Least A Specified Amount of Memory: cap_bytes
-capacity The CppAD::vector Template Class: capacity
-capacity_order Controlling Taylor Coefficient Memory Allocation: Example and Test
-               Controlling Taylor Coefficients Memory Allocation
-               Number Taylor Coefficient Orders Currently Stored: capacity_order
-capacity_taylor ADFun Object Deprecated Member Functions: capacity_taylor
-case Using AD to Compute Atomic Function Derivatives: Simple Case
-     Reverse Mode General Case (Checkpointing): Example and Test
-     Second Order Forward Mode: Derivative Values: Special Case
-     First Order Forward Mode: Derivative Values: Special Case
-     Zero Order Forward Mode: Function Values: Special Case
-     Base Type Requirements for Identically Equal Comparisons: EqualOpSeq.The Simple Case
-     AD Theory for Cholesky Factorization: Reverse Mode.Case k > 0
-     AD Theory for Cholesky Factorization: Reverse Mode.Case k = 0
-     User Defined Atomic AD Functions: General Case
-cases The Theory of Forward Mode: Standard Math Functions.Special Cases
-      The Theory of Forward Mode: Standard Math Functions.Cases that Apply Recursion Above
-      Base Type Requirements for Identically Equal Comparisons: EqualOpSeq.More Complicated Cases
-central Interfacing to C: Example and Test
-certain Convert Certain Types to a String
-change Computing a Jacobian With Constants that Change
-       CompareChange and Re-Tape: Example and Test
-changes Comparison Changes During Zero Order Forward Mode
-        CppAD Deprecated API Features: Name Changes
-        Changes and Additions to CppAD During 2003
-        Changes and Additions to CppAD During 2004
-        Changes and Additions to CppAD During 2005
-        Changes and Additions to CppAD During 2006
-        Changes and Additions to CppAD During 2007
-        Changes and Additions to CppAD During 2008
-        Changes and Additions to CppAD During 2009
-        Changes and Additions to CppAD During 2010
-        Changes and Additions to CppAD During 2011
-        CppAD Changes and Additions During 2012
-        CppAD Changes and Additions During 2013
-        CppAD Changes and Additions During 2014
-        CppAD Changes and Additions During 2015
-        Changes and Additions to CppAD During 2016
-        Changes and Additions to CppAD During 2017: API Changes
-        Changes and Additions to CppAD During 2017
-        Changes and Additions to CppAD
-        Comparison Changes Between Taping and Zero Order Forward
-check Correctness Check for Both Simple and Fast Representations
-      Memory Leak Detection
-      Check If A Memory Allocation is Efficient for Another Use
-      Check Gradient of Determinant of 3 by 3 matrix
-      Check Determinant of 3 by 3 matrix
-      The CppAD::vector Template Class: Assignment.Check Size
-      The CheckSimpleVector Function: Example and Test
-      Check Simple Vector Concept
-      The CheckNumericType Function: Example and Test
-      Check NumericType Class Concept
-      Check an ADFun Object For Nan Results
-      ADFun Check and Re-Tape: Example and Test
-      Check an ADFun Sequence of Operations
-      Check if Two Value are Identically Equal
-      Checking the CppAD Examples and Tests: Subsets of make check
-      Checking the CppAD Examples and Tests: Check All
-      Using CMake to Configure CppAD: make check
-      CppAD Download, Test, and Install Instructions: Instructions.Step 3: Check
-check_finite The CppAD Wish List: check_finite
-checking ADFun Checking For Nan: Example and Test
-         Optimize an ADFun Object Tape: Checking Optimization
-         Checking the CppAD Examples and Tests
-checknumerictype The CheckNumericType Function: Example and Test
-checkpoint Using AD to Compute Atomic Function Derivatives
-           Using AD to Compute Atomic Function Derivatives
-           The CppAD Wish List: checkpoint
-checkpointing Checkpointing an Extended ODE Solver: Example and Test
-              Checkpointing an ODE Solver: Example and Test
-              Checkpointing Functions
-checkpointing: Simple Checkpointing: Example and Test
-checksimplevector The CheckSimpleVector Function: Example and Test
-                  Enable AD Calculations During Parallel Mode: CheckSimpleVector
-choice Using The CppAD Test Vector Template Class: Choice
-cholesky Atomic Eigen Cholesky Factorization Class
-         AD Theory for Cholesky Factorization: Notation.Cholesky Factor
-         AD Theory for Cholesky Factorization
-         Atomic Eigen Cholesky Factorization: Example and Test
-choosing Choosing The Vector Testing Template Class
-         Choosing the CppAD Test Vector Template Class
-class Choosing The Vector Testing Template Class
-      Using The CppAD Test Vector Template Class
-      Examples: The CppAD Test Vector Template Class
-      The CppAD::vector Template Class
-      Definition of a Simple Vector: Template Class Requirements
-      Check NumericType Class Concept
-      Some General Purpose Utilities: Miscellaneous.The CppAD Vector Template Class
-      Example AD<Base> Where Base Constructor Allocates Memory: Class Definition
-      Required Base Class Member Functions
-      Matrix Multiply as an Atomic Operation: End Class Definition
-      Matrix Multiply as an Atomic Operation: Start Class Definition
-      User Atomic Matrix Multiply: Example and Test: Class Definition
-      Atomic Eigen Cholesky Factorization Class: End Class Definition
-      Atomic Eigen Cholesky Factorization Class: Start Class Definition
-      Atomic Eigen Cholesky Factorization Class
-      Atomic Eigen Matrix Inversion Class: End Class Definition
-      Atomic Eigen Matrix Inversion Class: Start Class Definition
-      Atomic Eigen Matrix Inversion Class
-      Atomic Eigen Matrix Inverse: Example and Test: Class Definition
-      Atomic Eigen Matrix Multiply Class: End Class Definition
-      Atomic Eigen Matrix Multiply Class: Start Class Definition
-      Atomic Eigen Matrix Multiply Class
-      Atomic Eigen Matrix Multiply: Example and Test: Class Definition
-      Tan and Tanh as User Atomic Operations: Example and Test: End Class Definition
-      Tan and Tanh as User Atomic Operations: Example and Test: Start Class Definition
-      Atomic Sparsity with Set Patterns: Example and Test: End Class Definition
-      Atomic Sparsity with Set Patterns: Example and Test: Start Class Definition
-      Reciprocal as an Atomic Operation: Example and Test: End Class Definition
-      Reciprocal as an Atomic Operation: Example and Test: Start Class Definition
-      Atomic Euclidean Norm Squared: Example and Test: End Class Definition
-      Atomic Euclidean Norm Squared: Example and Test: Start Class Definition
-      Getting Started with Atomic Operations: Example and Test: End Class Definition
-      Getting Started with Atomic Operations: Example and Test: Start Class Definition
-      Atomic Reverse Hessian Sparsity: Example and Test: Start Class Definition
-      Atomic Forward Hessian Sparsity: Example and Test: Start Class Definition
-      Atomic Reverse Jacobian Sparsity: Example and Test: Start Class Definition
-      Atomic Forward Jacobian Sparsity: Example and Test: Start Class Definition
-      Atomic Reverse: Example and Test: Start Class Definition
-      Atomic Forward: Example and Test: Start Class Definition
-      Choosing the CppAD Test Vector Template Class
-class: CppAD::vectorBool Class: Example and Test
-       CppAD::vector Template Class: Example and Test
-       Simple Vector Template Class: Example and Test
-clear User Defined Atomic AD Functions: clear
-      The CppAD::vector Template Class: clear
-      Free Static Variables
-      Checkpointing Functions: clear
-cmake Using CMake to Configure CppAD: CMake Command
-      Using CMake to Configure CppAD: The CMake Program
-      Using CMake to Configure CppAD
-      CppAD Download, Test, and Install Instructions: Instructions.Step 2: Cmake
-cmake_install_datadir Using CMake to Configure CppAD: cmake_install_datadir
-cmake_install_docdir Using CMake to Configure CppAD: cmake_install_docdir
-cmake_install_includedirs Using CMake to Configure CppAD: cmake_install_includedirs
-cmake_install_libdirs Using CMake to Configure CppAD: cmake_install_libdirs
-cmake_verbose_makefile Using CMake to Configure CppAD: cmake_verbose_makefile
-code Main Program For Comparing C and C++ Speed: Source Code
-     Determine Amount of Time to Execute det_by_minor: Source Code
-     Returns Elapsed Number of Seconds: Source Code
-     Repeat det_by_minor Routine A Specified Number of Times: Source Code
-     Correctness Test of det_by_minor Routine: Source Code
-     Simulate a [0,1] Uniform Random Variate: Source Code
-     Compute Determinant using Expansion by Minors: Source Code
-     Determinant of a Minor: Source Code
-     ODE Inverse Problem Definitions: Source Code
-     Simulate a [0,1] Uniform Random Variate: Source Code
-     Evaluate a Function That Has a Sparse Hessian: Source Code
-     Evaluate a Function That Has a Sparse Jacobian: Source Code
-     Evaluate a Function Defined in Terms of an ODE: Source Code
-     Sum Elements of a Matrix Times Itself: Source Code
-     Check Gradient of Determinant of 3 by 3 matrix: Source Code
-     Check Determinant of 3 by 3 matrix: Source Code
-     Determinant Using Expansion by Minors: Source Code
-     Determinant of a Minor: Source Code
-     Determinant Using Expansion by Lu Factorization: Source Code
-     Speed Testing Utilities: Source Code
-     Source Code for eigen_plugin.hpp
-     ODE Inverse Problem Definitions: Source Code
-     An Error Controller for Gear's Ode Solvers: Source Code
-     An Arbitrary Order Gear Method: Source Code
-     An Error Controller for ODE Solvers: Source Code
-     A 3rd and 4th Order Rosenbrock ODE Solver: Source Code
-     An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Source Code
-     Multi-dimensional Romberg Integration: Source Code
-     One DimensionalRomberg Integration: Source Code
-     Using a Team of AD Threads: Example and Test: Source Code
-     A Simple pthread AD: Example and Test: Source Code
-     A Simple Boost Threading AD: Example and Test: Source Code
-     A Simple OpenMP AD: Example and Test: Source Code
-     A Simple Parallel Pthread Example and Test: Source Code
-     A Simple Boost Thread Example and Test: Source Code
-     A Simple OpenMP Example and Test: Source Code
-     min_nso_quad Source Code
-     abs_min_quad Source Code
-     qp_box Source Code
-     qp_interior Source Code
-     min_nso_linear Source Code
-     abs_min_linear Source Code
-     lp_box Source Code
-     simplex_method Source Code
-     abs_eval Source Code
-     Base Type Requirements for Hash Coding Values: code
-     Printing During Forward Mode: Example and Test: Source Code
-     exp_eps: Operation Sequence and Zero Order Forward Sweep: Operation Sequence.Code
-     exp_2: Operation Sequence and Zero Order Forward Mode: Operation Sequence.Code
-     Download The CppAD Source Code: Source Code Control
-     Download The CppAD Source Code
-coding Base Type Requirements for Hash Coding Values
-coefficient Glossary: Taylor Coefficient
-            Controlling Taylor Coefficient Memory Allocation: Example and Test
-            Number Taylor Coefficient Orders Currently Stored
-            AD Theory for Cholesky Factorization: Notation.Taylor Coefficient
-coefficients Error Function Forward Taylor Polynomial Theory: Taylor Coefficients Recursion
-             Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory: Taylor Coefficients Recursion
-             Inverse Cosine and Hyperbolic Cosine Forward Mode Theory: Taylor Coefficients Recursion
-             Inverse Sine and Hyperbolic Sine Forward Mode Theory: Taylor Coefficients Recursion
-             Inverse Tangent and Hyperbolic Tangent Forward Mode Theory: Taylor Coefficients Recursion
-             Logarithm Function Forward Mode Theory: Taylor Coefficients Recursion
-             Exponential Function Forward Mode Theory: Taylor Coefficients Recursion
-             The Theory of Forward Mode: Standard Math Functions.Taylor Coefficients Recursion Formula
-             Third Order Reverse Mode: Example and Test: Taylor Coefficients
-             Controlling Taylor Coefficients Memory Allocation
-             Construct an ADFun Object and Stop Recording: Assignment Operator.Taylor Coefficients
-coin Download The CppAD Source Code: Compressed Archives.Coin
-col Evaluate a Function That Has a Sparse Hessian: col
-    Evaluate a Function That Has a Sparse Jacobian: col
-    Speed Testing Sparse Jacobian: col
-    Speed Testing Sparse Hessian: col
-    Sparse Matrix Row, Column, Value Representation: col
-    Row and Column Index Sparsity Patterns: col
-    Sparse Hessian: row, col
-    Sparse Jacobian: row, col
-    Reverse Mode Using Subgraphs: col
-col_major Sparse Matrix Row, Column, Value Representation: col_major
-          Row and Column Index Sparsity Patterns: col_major
-color_method Sparse Hessian: work.color_method
-             Sparse Jacobian: work.color_method
-coloring Computing Sparse Hessians: coloring
-         Computing Sparse Jacobians: coloring
-colpack Running the Speed Test Program: Sparsity Options.colpack
-        Computing Sparse Jacobians: coloring.colpack
-        Download and Install ColPack in Build Directory
-        Including the ColPack Sparsity Calculations
-colpack.general Computing Sparse Hessians: coloring.colpack.general
-colpack.star Sparse Hessian: work.colpack.star Deprecated 2017-06-01
-             Computing Sparse Hessians: coloring.colpack.star Deprecated 2017-06-01
-colpack.symmetric Computing Sparse Hessians: coloring.colpack.symmetric
-colpack: ColPack: Sparse Hessian Example and Test
-         ColPack: Sparse Hessian Example and Test
-         ColPack: Sparse Jacobian Example and Test
-         ColPack: Sparse Jacobian Example and Test
-colpack_prefix Including the ColPack Sparsity Calculations: colpack_prefix
-column Glossary: Sparsity Pattern.Row and Column Index Vectors
-       Sparse Matrix Row, Column, Value Representation
-       Row and Column Index Sparsity Patterns
-       Sparse Hessian: p.Column Subset
-       Preferred Sparsity Patterns: Row and Column Indices: Example and Test
-command Using CMake to Configure CppAD: CMake Command
-common Common Variables use by Multi-Threaded Newton Method
-       Multi-Threaded User Atomic Common Information
-       Common Variables Used by Multi-threading Sum of 1/i
-compare Compare Speed of C and C++
-        CompareChange and Re-Tape: Example and Test
-        Compare AD with Base Objects: Example and Test
-        Compare AD and Base Objects for Nearly Equal
-        AD Binary Comparison Operators: Example and Test
-        AD Binary Comparison Operators
-     speed C and C++ Compare Speed of C and C++
-compare_change Comparison Changes Between Taping and Zero Order Forward
-comparechange Frequently Asked Questions and Answers: CompareChange
-              CompareChange and Re-Tape: Example and Test
-compareop Base Type Requirements for Conditional Expressions: CompareOp
-comparing Main Program For Comparing C and C++ Speed
-comparison zdouble: An AD Base Type With Absolute Zero: Syntax.Comparison Operators
-           Comparison Changes During Zero Order Forward Mode
-           Example Optimization and Comparison Operators
-           Comparison Changes Between Taping and Zero Order Forward
-           AD Binary Comparison Operators: Example and Test
-           AD Binary Comparison Operators
-comparisons Base Type Requirements for Ordered Comparisons
-            Base Type Requirements for Identically Equal Comparisons
-            exp_eps: Operation Sequence and Zero Order Forward Sweep: Comparisons
-compilation The CppAD Wish List: Compilation Speed
-compile Using CMake to Configure CppAD
-complex Frequently Asked Questions and Answers: Complex Types
-        LuSolve With Complex Arguments: Example and Test
-        Complex Polynomial: Example and Test
-        AD Absolute Value Functions: abs, fabs: Complex Types
-        Convert From AD to Integer: x.Complex Types
-complicated Base Type Requirements for Identically Equal Comparisons: EqualOpSeq.More Complicated Cases
-compound Example AD<Base> Where Base Constructor Allocates Memory: Compound Assignment Macro
-         AD Compound Assignment Division: Example and Test
-         AD Compound Assignment Multiplication: Example and Test
-         AD Compound Assignment Subtraction: Example and Test
-         AD Compound Assignment Addition: Example and Test
-         AD Compound Assignment Operators
-         AD Arithmetic Operators and Compound Assignments
-compressed Download The CppAD Source Code: Compressed Archives
-computation Computing Dependency: Example and Test: Computation
-compute Compute Determinant using Expansion by Minors
-        Using AD to Compute Atomic Function Derivatives
-        Using AD to Compute Atomic Function Derivatives
-        Using Eigen To Compute Determinant: Example and Test
-        Getting Started Using CppAD to Compute Derivatives
-        Compute Determinant and Solve Linear Equations
-        Compute Determinants and Solve Equations by LU Factorization
-        Compute Sparse Jacobians Using Subgraphs
-computes Defines a User Atomic Operation that Computes Square Root
-computing Computing Jacobian and Hessian of Bender's Reduced Objective
-          Computing a Jacobian With Constants that Change
-          Computing Sparse Jacobian Using Reverse Mode: Example and Test
-          Computing Sparse Hessian for a Subset of Variables
-          Computing Sparse Hessian: Example and Test
-          Computing Sparse Hessians
-          Computing Sparse Jacobian Using Reverse Mode: Example and Test
-          Computing Sparse Jacobian Using Forward Mode: Example and Test
-          Computing Sparse Jacobians
-          Computing Dependency: Example and Test
-          Computing Reverse Mode on Subgraphs: Example and Test
-concept Check Simple Vector Concept
-        Check NumericType Class Concept
-concepts Some General Purpose Utilities: C++ Concepts
-cond_exp_CppAD Changes and Additions During 2015: 05-26.cond_exp_1
-cond_exp_CppAD Changes and Additions During 2015: 05-26.cond_exp_2
-condexpop Enable use of AD<Base> where Base is std::complex<double>: CondExpOp
-          Enable use of AD<Base> where Base is double: CondExpOp
-          Enable use of AD<Base> where Base is float: CondExpOp
-          Enable use of AD<Base> where Base is Adolc's adouble Type: CondExpOp
-          Example AD<Base> Where Base Constructor Allocates Memory: CondExpOp
-condexprel Enable use of AD<Base> where Base is std::complex<double>: CondExpRel
-           Enable use of AD<Base> where Base is double: CondExpRel
-           Enable use of AD<Base> where Base is float: CondExpRel
-           Enable use of AD<Base> where Base is Adolc's adouble Type: CondExpRel
-           Example AD<Base> Where Base Constructor Allocates Memory: CondExpRel
-           Base Type Requirements for Conditional Expressions: CondExpRel
-condexptemplate Base Type Requirements for Conditional Expressions: CondExpTemplate
-condition ODE Fitting Using Fast Representation: Initial Condition
-          ODE Fitting Using Simple Representation: Initial Condition Constraint
-          Number of Variables That Can be Skipped: Example and Test
-conditional Example Optimization and Nested Conditional Expressions
-            Example Optimization and Conditional Expressions
-            Number of Variables That Can be Skipped: Example and Test
-            Base Type Requirements for Conditional Expressions
-            Conditional Expressions: Example and Test
-            AD Conditional Expressions
-conditions abs_normal: Solve a Quadratic Program With Box Constraints: KKT Conditions
-           Solve a Quadratic Program Using Interior Point Method: KKT Conditions
-configuration Nonlinear Programming Using CppAD and Ipopt: Example and Test: Configuration Requirement
-              Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Configuration Requirement
-              Nonlinear Programming Using CppAD and Ipopt: Example and Test: Configuration Requirement
-              Using Adolc with Multiple Levels of Taping: Example and Test: Configuration Requirement
-              CppAD pkg-config Files: CppAD Configuration Files
-configure Autotools Unix Test and Installation: Configure
-          Using CMake to Configure CppAD
-conjugate Differentiate Conjugate Gradient Algorithm: Example and Test
-constants Computing a Jacobian With Constants that Change
-constraint ODE Fitting Using Simple Representation: Trapezoidal Approximation Constraint
-           ODE Fitting Using Simple Representation: Initial Condition Constraint
-constraints abs_normal: Solve a Quadratic Program With Box Constraints
-            abs_normal: Solve a Linear Program With Box Constraints
-construct Construct an ADFun Object and Stop Recording
-constructor zdouble: An AD Base Type With Absolute Zero: Syntax.Constructor and Assignment
-            Determinant Using Expansion by Minors: Constructor
-            Determinant Using Expansion by Lu Factorization: Constructor
-            Allocate An Array and Call Default Constructor for its Elements
-            Definition of a Simple Vector: Element Constructor and Destructor
-            Definition of a Simple Vector: Copy Constructor
-            Definition of a Simple Vector: Sizing Constructor
-            Definition of a Simple Vector: Default Constructor
-            Definition of a Numeric Type: Copy Constructor
-            Definition of a Numeric Type: Constructor From Integer
-            Definition of a Numeric Type: Default Constructor
-            Replacing the CppAD Error Handler: Constructor
-            Number Taylor Coefficient Orders Currently Stored: Constructor
-            Construct an ADFun Object and Stop Recording: Example.Default Constructor
-            Construct an ADFun Object and Stop Recording: Example.Sequence Constructor
-            Construct an ADFun Object and Stop Recording: Copy Constructor
-            Construct an ADFun Object and Stop Recording: Sequence Constructor
-            Construct an ADFun Object and Stop Recording: Default Constructor
-            Example AD<Base> Where Base Constructor Allocates Memory
-            Required Base Class Member Functions: Copy Constructor
-            Required Base Class Member Functions: Double Constructor
-            Required Base Class Member Functions: Default Constructor
-            AD Vectors that Record Index Operations: Constructor
-            Matrix Multiply as an Atomic Operation: Constructor
-            User Atomic Matrix Multiply: Example and Test: Use Atomic Function.Constructor
-            Atomic Eigen Cholesky Factorization Class: Public.Constructor
-            Atomic Eigen Cholesky Factorization: Example and Test: Use Atomic Function.Constructor
-            Atomic Eigen Matrix Inversion Class: Public.Constructor
-            Atomic Eigen Matrix Inverse: Example and Test: Use Atomic Function.Constructor
-            Atomic Eigen Matrix Multiply Class: Public.Constructor
-            Atomic Eigen Matrix Multiply: Example and Test: Use Atomic Function.Constructor
-            Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function.Constructor
-            Tan and Tanh as User Atomic Operations: Example and Test: Constructor
-            Atomic Sparsity with Set Patterns: Example and Test: Test Atomic Function.Constructor
-            Atomic Sparsity with Set Patterns: Example and Test: Constructor
-            Reciprocal as an Atomic Operation: Example and Test: Use Atomic Function.Constructor
-            Reciprocal as an Atomic Operation: Example and Test: Constructor
-            Atomic Euclidean Norm Squared: Example and Test: Use Atomic Function.Constructor
-            Atomic Euclidean Norm Squared: Example and Test: Constructor
-            Getting Started with Atomic Operations: Example and Test: Use Atomic Function.Constructor
-            Getting Started with Atomic Operations: Example and Test: Constructor
-            Atomic Reverse Hessian Sparsity: Example and Test: Constructor
-            Atomic Forward Hessian Sparsity: Example and Test: Constructor
-            Atomic Reverse Jacobian Sparsity: Example and Test: Constructor
-            Atomic Forward Jacobian Sparsity: Example and Test: Constructor
-            Atomic Reverse: Example and Test: Constructor
-            Atomic Forward: Example and Test: Constructor
-            Atomic Function Constructor: Example.Use Constructor
-            Atomic Function Constructor: Example.Define Constructor
-            Atomic Function Constructor
-            Checkpointing Functions: constructor
-            AD Constructors: Example and Test
-constructor: Hessian of Lagrangian and ADFun Default Constructor: Example and Test
-             Independent and ADFun Constructor: Example and Test
-constructors AD Constructors
-constructors: AD Constructors: Example and Test
-control Control When Thread Alloc Retains Memory For Future Use
-        Controlling Taylor Coefficients Memory Allocation
-        Download The CppAD Source Code: Source Code Control
-controller An Error Controller for Gear's Ode Solvers
-           An Error Controller for ODE Solvers
-controlling Controlling Taylor Coefficient Memory Allocation: Example and Test
-            Controlling Taylor Coefficients Memory Allocation
-convention Lu Factor and Solve with Recorded Pivoting: Storage Convention
-conversion Suppress Suspect Implicit Conversion Warnings
-           Conversion and I/O of AD Objects
-convert Convert Certain Types to a String
-        Convert an AD Variable to a Parameter: Example and Test
-        Convert an AD Variable to a Parameter
-        Convert An AD or Base Type to String
-        Convert From AD to Integer: Example and Test
-        Convert From AD to Integer
-        Convert From AD to its Base Type: Example and Test
-        Convert From an AD Type to its Base Type
-        Conversion and I/O of AD Objects
-        AD Constructors
-copy Definition of a Simple Vector: Copy Constructor
-     Definition of a Numeric Type: Copy Constructor
-     Construct an ADFun Object and Stop Recording: Copy Constructor
-     Required Base Class Member Functions: Copy Constructor
-correct Check Gradient of Determinant of 3 by 3 matrix
-        Check Determinant of 3 by 3 matrix
-        Running the Speed Test Program: test.correct
-correctness Correctness Test of det_by_minor Routine
-            Correctness Check for Both Simple and Fast Representations
-            Running the Speed Test Program: Correctness Results
-            Correctness Tests For Exponential Approximation in Introduction
-correspondence Create An Abs-normal Representation of a Function: Correspondence to Literature
-cos Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
-    Trigonometric and Hyperbolic Sine and Cosine Forward Theory
-    The AD cos Function: Example and Test
-    The Cosine Function: cos
-cosh Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
-     Trigonometric and Hyperbolic Sine and Cosine Forward Theory
-     The AD cosh Function: Example and Test
-     The Hyperbolic Cosine Function: cosh
-cosine Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
-       Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
-       Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
-       Inverse Cosine and Hyperbolic Cosine Forward Mode Theory
-       Inverse Cosine and Hyperbolic Cosine Forward Mode Theory
-       Trigonometric and Hyperbolic Sine and Cosine Forward Theory
-       The Inverse Hyperbolic Cosine Function: acosh
-       The Hyperbolic Cosine Function: cosh
-       The Cosine Function: cos
-count Comparison Changes Between Taping and Zero Order Forward: count
-      An Introduction by Example to Algorithmic Differentiation: Preface.Operation Count
-cppad Your License for the CppAD Software
-      CppAD Addons
-      Autotools Unix Test and Installation: Profiling CppAD
-      zdouble: An AD Base Type With Absolute Zero: Motivation.CppAD
-      Define Matrix Multiply as a User Atomic Operation: CppAD User Atomic Callback Functions
-      Nonlinear Programming Using CppAD and Ipopt: Example and Test
-      Nonlinear Programming Using the CppAD Interface to Ipopt
-      A Quick OpenMP Memory Allocator Used by CppAD
-      CppAD Deprecated API Features
-      Changes and Additions to CppAD During 2003
-      Changes and Additions to CppAD During 2004
-      Changes and Additions to CppAD During 2005
-      Changes and Additions to CppAD During 2006
-      Changes and Additions to CppAD During 2007
-      Changes and Additions to CppAD During 2008
-      Changes and Additions to CppAD During 2009
-      Changes and Additions to CppAD During 2010
-      Changes and Additions to CppAD During 2011
-      CppAD Changes and Additions During 2012
-      CppAD Changes and Additions During 2013
-      CppAD Changes and Additions During 2014
-      CppAD Changes and Additions During 2015
-      Changes and Additions to CppAD During 2016
-      Changes and Additions to CppAD During 2017
-      Changes and Additions to CppAD
-      The CppAD Wish List
-      CppAD Speed: Sparse Jacobian
-      CppAD Speed: Sparse Hessian
-      CppAD Speed: Second Derivative of a Polynomial
-      CppAD Speed: Gradient of Ode Solution
-      CppAD Speed, Matrix Multiplication
-      CppAD Speed: Gradient of Determinant Using Lu Factorization
-      CppAD Speed: Gradient of Determinant by Minor Expansion
-      Speed Test Derivatives Using CppAD
-      CppAD Speed: Matrix Multiplication (Double Version)
-      Running the Speed Test Program
-      Using The CppAD Test Vector Template Class
-      CppAD Examples and Tests
-      Enable Use of Eigen Linear Algebra Package with CppAD: CppAD Namespace
-      Enable Use of Eigen Linear Algebra Package with CppAD
-      Example and Test Linking CppAD to Languages Other than C++
-      List All (Except Deprecated) CppAD Examples
-      Utility Routines used by CppAD Examples
-      Getting Started Using CppAD to Compute Derivatives
-      Examples: The CppAD Test Vector Template Class
-      Nonlinear Programming Using CppAD and Ipopt: Example and Test
-      CppAD Assertions During Execution
-      Replacing The CppAD Error Handler: Example and Test
-      Replacing the CppAD Error Handler
-      Some General Purpose Utilities: Miscellaneous.The CppAD Vector Template Class
-      Using CppAD in a Multi-Threading Environment
-      CppAD API Preprocessor Symbols
-      Computing Sparse Jacobians: coloring.cppad
-      AD<Base> Requirements for a CppAD Base Type
-      exp_eps: CppAD Forward and Reverse Sweeps
-      exp_2: CppAD Forward and Reverse Sweeps
-      CppAD pkg-config Files: CppAD Configuration Files
-      CppAD pkg-config Files
-      Checking the CppAD Examples and Tests
-      Choosing the CppAD Test Vector Template Class: cppad
-      Choosing the CppAD Test Vector Template Class
-      Including the cppad_ipopt Library and Tests
-      Using CMake to Configure CppAD
-      Download The CppAD Source Code
-      CppAD Download, Test, and Install Instructions
-cppad-20180000.0: cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-cppad.general Computing Sparse Hessians: coloring.cppad.general
-cppad.hpp cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-cppad.symmetric Computing Sparse Hessians: coloring.cppad.symmetric
-cppad::numeric_limits Base Type Requirements for Numeric Limits: CppAD::numeric_limits
-                      Numeric Limits For an AD and Base Types: CppAD::numeric_limits
-cppad::vector Choosing The Vector Testing Template Class: CppAD::vector
-              Using The CppAD Test Vector Template Class: CppAD::vector
-              CppAD::vector Template Class: Example and Test
-              The CppAD::vector Template Class
-cppad::vectorbool CppAD::vectorBool Class: Example and Test
-cppad_cxx_flags Using CMake to Configure CppAD: cppad_cxx_flags
-cppad_debug_and_release CppAD API Preprocessor Symbols: Documented Here.CPPAD_DEBUG_AND_RELEASE
-cppad_debug_which Using CMake to Configure CppAD: cppad_debug_which
-cppad_deprecated Using CMake to Configure CppAD: cppad_deprecated
-cppad_ipopt Nonlinear Programming Using the CppAD Interface to Ipopt: cppad_ipopt namespace
-            Including the cppad_ipopt Library and Tests
-cppad_ipopt_nlp ODE Fitting Using Fast Representation
-                ODE Fitting Using Simple Representation
-                ODE Fitting Using Simple Representation
-cppad_lib Including the ColPack Sparsity Calculations: cppad_lib
-cppad_max_num_threads Using CppAD in a Multi-Threading Environment: CPPAD_MAX_NUM_THREADS
-                      Using CMake to Configure CppAD: cppad_max_num_threads
-cppad_null CppAD API Preprocessor Symbols: Documented Here.CPPAD_NULL
-cppad_numeric_limits Base Type Requirements for Numeric Limits: CPPAD_NUMERIC_LIMITS
-cppad_package_string CppAD API Preprocessor Symbols: Documented Here.CPPAD_PACKAGE_STRING
-cppad_postfix Using CMake to Configure CppAD: cppad_postfix
-cppad_prefix Using CMake to Configure CppAD: cppad_prefix
-cppad_profile_flag Using CMake to Configure CppAD: cppad_profile_flag
-cppad_standard_math_unary Base Type Requirements for Standard Math Functions: CPPAD_STANDARD_MATH_UNARY
-cppad_tape_addr_type Using CMake to Configure CppAD: cppad_tape_addr_type
-cppad_tape_id_type Using CMake to Configure CppAD: cppad_tape_id_type
-cppad_testvector Using CMake to Configure CppAD: cppad_testvector
-cppad_to_string Extending to_string To Another Floating Point Type: CPPAD_TO_STRING
-cppad_use_cplusplus_2011 CppAD API Preprocessor Symbols: Documented Here.CPPAD_USE_CPLUSPLUS_2011
-                         The Logarithm of One Plus Argument: log1p: CPPAD_USE_CPLUSPLUS_2011
-                         The Exponential Function Minus One: expm1: CPPAD_USE_CPLUSPLUS_2011
-                         The Error Function: CPPAD_USE_CPLUSPLUS_2011
-                         The Inverse Hyperbolic Tangent Function: atanh: CPPAD_USE_CPLUSPLUS_2011
-                         The Inverse Hyperbolic Sine Function: asinh: CPPAD_USE_CPLUSPLUS_2011
-                         The Inverse Hyperbolic Cosine Function: acosh: CPPAD_USE_CPLUSPLUS_2011
-cppad_user_atomic User Defined Atomic AD Functions: CPPAD_USER_ATOMIC
-cppadcreatediscrete Discrete AD Functions: CppADCreateDiscrete Deprecated 2007-07-28
-cppadvector Choosing The Vector Testing Template Class: CppADvector Deprecated 2007-07-28
-create Allocate Memory and Create A Raw Array
-       Create An Abs-normal Representation of a Function
-       Create an ADFun Object (Record an Operation Sequence)
-       AD Boolean Functions: Create Binary
-       AD Boolean Functions: Create Unary
-       Discrete AD Functions: Create AD Version
-create_array Allocate Memory and Create A Raw Array
-             Allocate An Array and Call Default Constructor for its Elements
-creating Creating Your Own Interface to an ADFun Object
-criteria An Error Controller for Gear's Ode Solvers: Error Criteria Discussion
-         An Error Controller for ODE Solvers: Error Criteria Discussion
-cstdint Using CMake to Configure CppAD: cppad_tape_addr_type.cstdint
-        Using CMake to Configure CppAD: cppad_tape_id_type.cstdint
-ctor Using CMake to Configure CppAD
-ctor_arg_list Atomic Function Constructor: atomic_user.ctor_arg_list
-cumulative Example Optimization and Cumulative Sum Operations
-current Get the Current OpenMP Thread Number
-        Is The Current Execution in OpenMP Parallel Mode
-        Get the Current Thread Number
-        Is The Current Execution in Parallel Mode
-        Abort Current Recording: Example and Test
-currently Amount of Memory a Thread is Currently Using
-          Free Memory Currently Available for Quick Use by a Thread
-          Amount of Memory a Thread is Currently Using
-          Free Memory Currently Available for Quick Use by a Thread
-          Number Taylor Coefficient Orders Currently Stored
-cutting abs_normal: Minimize a Linear Abs-normal Approximation: Method.Cutting Planes
-        abs_normal: Minimize a Linear Abs-normal Approximation: Method.Cutting Planes
-cxx_flags Autotools Unix Test and Installation: cxx_flags
-cygwin Autotools Unix Test and Installation: adolc_dir.Cygwin
-       Pthread Implementation of a Team of AD Threads: Bug in Cygwin
-       Including the ADOL-C Examples and Tests: Cygwin
- -D -
-Dependent ADFun Check and Re-Tape: Example and Test
-          Stop Recording and Store Operation Sequence
-Domain ADFun Sequence Properties: Example and Test
-data The CppAD::vector Template Class: vectorBool.data
-     The CppAD::vector Template Class: data
-datadir Using CMake to Configure CppAD
-dblvector Non-Smooth Optimization Using Abs-normal Quadratic Approximations: DblVector
-          abs_normal: Minimize a Linear Abs-normal Approximation: DblVector
-          Non-Smooth Optimization Using Abs-normal Linear Approximations: DblVector
-          abs_normal: Minimize a Linear Abs-normal Approximation: DblVector
-ddp Speed Testing Second Derivative of a Polynomial: ddp
-ddw Reverse Mode Second Partial Derivative Driver: ddw
-ddy Forward Mode Second Partial Derivative Driver: ddy
-deallocate Deallocate An Array and Call Destructor for its Elements
-debug Printing AD Values During Forward Mode
-      Using CMake to Configure CppAD: cppad_cxx_flags.debug and release
-debug_which Speed Test an Operator Overloading AD Package: debug_which
-debugging Check an ADFun Object For Nan Results: Debugging
-declare Define Matrix Multiply as a User Atomic Operation: Declare mat_mul Function
-        Declare Independent Variables and Start Recording
-default Allocate An Array and Call Default Constructor for its Elements
-        Definition of a Simple Vector: Default Constructor
-        Definition of a Numeric Type: Default Constructor
-        Check an ADFun Object For Nan Results: Default
-        Hessian of Lagrangian and ADFun Default Constructor: Example and Test
-        Construct an ADFun Object and Stop Recording: Example.Default Constructor
-        Construct an ADFun Object and Stop Recording: Default Constructor
-        Base Type Requirements for Hash Coding Values: Default
-        Required Base Class Member Functions: Default Constructor
-define Define Matrix Multiply as a User Atomic Operation
-       Atomic Function Constructor: Example.Define Constructor
-defined User Defined Atomic AD Functions
-        Evaluate a Function Defined in Terms of an ODE
-        Using a User Defined AD Base Type: Example and Test
-        User Defined Atomic AD Functions
-        CppAD pkg-config Files: Defined Fields
-defines Defines a User Atomic Operation that Computes Square Root
-definition Definition of a Simple Vector
-           Definition of a Numeric Type
-           Example AD<Base> Where Base Constructor Allocates Memory: Class Definition
-           Matrix Multiply as an Atomic Operation: End Class Definition
-           Matrix Multiply as an Atomic Operation: Start Class Definition
-           User Atomic Matrix Multiply: Example and Test: Class Definition
-           Atomic Eigen Cholesky Factorization Class: End Class Definition
-           Atomic Eigen Cholesky Factorization Class: Start Class Definition
-           Atomic Eigen Matrix Inversion Class: End Class Definition
-           Atomic Eigen Matrix Inversion Class: Start Class Definition
-           Atomic Eigen Matrix Inverse: Example and Test: Class Definition
-           Atomic Eigen Matrix Multiply Class: End Class Definition
-           Atomic Eigen Matrix Multiply Class: Start Class Definition
-           Atomic Eigen Matrix Multiply: Example and Test: Class Definition
-           Tan and Tanh as User Atomic Operations: Example and Test: End Class Definition
-           Tan and Tanh as User Atomic Operations: Example and Test: Start Class Definition
-           Atomic Sparsity with Set Patterns: Example and Test: End Class Definition
-           Atomic Sparsity with Set Patterns: Example and Test: Start Class Definition
-           Reciprocal as an Atomic Operation: Example and Test: End Class Definition
-           Reciprocal as an Atomic Operation: Example and Test: Start Class Definition
-           Atomic Euclidean Norm Squared: Example and Test: End Class Definition
-           Atomic Euclidean Norm Squared: Example and Test: Start Class Definition
-           Getting Started with Atomic Operations: Example and Test: End Class Definition
-           Getting Started with Atomic Operations: Example and Test: Start Class Definition
-           Atomic Reverse Hessian Sparsity: Example and Test: Start Class Definition
-           Atomic Forward Hessian Sparsity: Example and Test: Start Class Definition
-           Atomic Reverse Jacobian Sparsity: Example and Test: Start Class Definition
-           Atomic Forward Jacobian Sparsity: Example and Test: Start Class Definition
-           Atomic Reverse: Example and Test: Start Class Definition
-           Atomic Forward: Example and Test: Start Class Definition
-definitions: ODE Inverse Problem Definitions: Source Code
-             ODE Inverse Problem Definitions: Source Code
-delete Tracking Use of New and Delete: Example and Test
-       Routines That Track Use of New and Delete
-delete: Tracking Use of New and Delete: Example and Test
-delete_array Return A Raw Array to The Available Memory for a Thread
-             Deallocate An Array and Call Destructor for its Elements
-delta Return A Raw Array to The Available Memory for a Thread: Delta
-      Allocate Memory and Create A Raw Array: Delta
-      Deallocate An Array and Call Destructor for its Elements: Delta
-      Allocate An Array and Call Default Constructor for its Elements: Delta
-delta_abs_normal: Minimize a Linear Abs-normal Approximation: delta_x
-        abs_normal: Minimize a Linear Abs-normal Approximation: delta_x
-        abs_normal: Evaluate First Order Approximation: delta_x
-dependency Subgraph Dependency Sparsity Patterns: Example and Test
-           Subgraph Dependency Sparsity Patterns
-           Computing Dependency: Example and Test: Dependency Pattern
-           Jacobian Sparsity Pattern: Reverse Mode: dependency
-           Reverse Mode Jacobian Sparsity Patterns: dependency
-           Jacobian Sparsity Pattern: Forward Mode: dependency
-           Forward Mode Jacobian Sparsity Patterns: dependency
-dependency: Computing Dependency: Example and Test
-dependent ADFun Object Deprecated Member Functions: Dependent
-          Glossary: Tape.Dependent Variables
-          Glossary: Operation.Dependent
-deprecate AD Conditional Expressions: Deprecate 2005-08-07
-deprecated Autotools Unix Test and Installation: Deprecated 2012-12-26
-           zdouble: An AD Base Type With Absolute Zero: Deprecated 2015-09-26
-           Old Matrix Multiply as a User Atomic Operation: Example and Test: Deprecated 2013-05-27
-           Old Tan and Tanh as User Atomic Operations: Example and Test: Deprecated 2013-05-27
-           Using AD to Compute Atomic Function Derivatives: Deprecated 2013-05-27
-           Using AD to Compute Atomic Function Derivatives: Deprecated 2013-05-27
-           Old Atomic Operation Reciprocal: Example and Test: Deprecated 2013-05-27
-           User Defined Atomic AD Functions: Deprecated 2013-05-27
-           Nonlinear Programming Using the CppAD Interface to Ipopt: Deprecated 2012-11-28
-           Choosing The Vector Testing Template Class: CppADvector Deprecated 2007-07-28
-           Choosing The Vector Testing Template Class: Deprecated 2012-07-03
-           Machine Epsilon For AD Types: Deprecated 2012-06-17
-           Memory Leak Detection: Deprecated 2012-04-06
-           OpenMP Memory Allocator: Example and Test: Deprecated 2011-08-31
-           Return A Raw Array to The Available Memory for a Thread: Deprecated 2011-08-31
-           Allocate Memory and Create A Raw Array: Deprecated 2011-08-31
-           Amount of Memory Available for Quick Use by a Thread: Deprecated 2011-08-31
-           Amount of Memory a Thread is Currently Using: Deprecated 2011-08-31
-           Free Memory Currently Available for Quick Use by a Thread: Deprecated 2011-08-31
-           Return Memory to omp_alloc: Deprecated 2011-08-31
-           Get At Least A Specified Amount of Memory: Deprecated 2011-08-31
-           Get the Current OpenMP Thread Number: Deprecated 2011-08-31
-           Is The Current Execution in OpenMP Parallel Mode: Deprecated 2011-08-31
-           Set and Get Maximum Number of Threads for omp_alloc Allocator: Deprecated 2011-08-31
-           A Quick OpenMP Memory Allocator Used by CppAD: Deprecated 2011-08-23
-           Routines That Track Use of New and Delete: TrackCount.Previously Deprecated
-           Routines That Track Use of New and Delete: TrackExtend.Previously Deprecated
-           Routines That Track Use of New and Delete: TrackDelVec.Previously Deprecated
-           Routines That Track Use of New and Delete: TrackNewVec.Previously Deprecated
-           Routines That Track Use of New and Delete: Deprecated 2007-07-23
-           OpenMP Parallel Setup: Deprecated 2011-06-23
-           Comparison Changes During Zero Order Forward Mode: Deprecated 2015-01-20
-           ADFun Object Deprecated Member Functions: capacity_taylor.Deprecated 2014-03-18
-           ADFun Object Deprecated Member Functions: size_taylor.Deprecated 2014-03-18
-           ADFun Object Deprecated Member Functions: use_VecAD.Deprecated 2006-04-08
-           ADFun Object Deprecated Member Functions: taylor_size.Deprecated 2006-06-17
-           ADFun Object Deprecated Member Functions: Size.Deprecated 2006-04-03
-           ADFun Object Deprecated Member Functions: Memory.Deprecated 2006-03-31
-           ADFun Object Deprecated Member Functions: Order.Deprecated 2006-03-31
-           ADFun Object Deprecated Member Functions: Dependent.Deprecated 2007-08-07
-           ADFun Object Deprecated Member Functions
-           Deprecated Include Files: Deprecated 2006-12-17
-           Deprecated Include Files: Deprecated 2015-11-30
-           Deprecated Include Files
-           CppAD Deprecated API Features
-           Obtain Nan or Determine if a Value is Nan: nan(zero).Deprecated 2015-10-04
-           CppAD API Preprocessor Symbols: Deprecated
-           Sparse Hessian: work.colpack.star Deprecated 2017-06-01
-           Computing Sparse Hessians: coloring.colpack.star Deprecated 2017-06-01
-           AD Boolean Functions: Deprecated 2007-07-31
-           Atomic Reverse Hessian Sparsity Patterns: u.x
-           Atomic Reverse Hessian Sparsity Patterns: Deprecated 2016-06-27
-           Atomic Forward Hessian Sparsity Patterns: Implementation.x
-           Atomic Forward Hessian Sparsity Patterns: Deprecated 2016-06-27
-           Atomic Reverse Jacobian Sparsity Patterns: Implementation.x
-           Atomic Reverse Jacobian Sparsity Patterns: Deprecated 2016-06-27
-           Atomic Forward Jacobian Sparsity Patterns: Implementation.x
-           Atomic Forward Jacobian Sparsity Patterns: Deprecated 2016-06-27
-           Discrete AD Functions: CppADCreateDiscrete Deprecated 2007-07-28
-           CppAD Download, Test, and Install Instructions: Deprecated
-deprecated) List All (Except Deprecated) CppAD Examples
-derivative The Theory of Derivative Calculations
-           Sacado Speed: Second Derivative of a Polynomial
-           Fadbad Speed: Second Derivative of a Polynomial
-           CppAD Speed: Second Derivative of a Polynomial
-           Adolc Speed: Second Derivative of a Polynomial
-           Speed Testing Second Derivative of a Polynomial
-           Speed Testing Derivative of Matrix Multiply
-           Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Derivative of ODE Solution
-           Taylor's Ode Solver: A Multi-Level AD Example and Test: Derivative of ODE Solution
-           Getting Started Using CppAD to Compute Derivatives: Derivative
-           Evaluate a Polynomial or its Derivative
-           Any Order Reverse Mode
-           Second Order Reverse Mode
-           First Order Reverse Mode
-           Multiple Order Forward Mode: Purpose.Derivative Values
-           Second Order Forward Mode: Derivative Values
-           First Order Forward Mode: Derivative Values
-           Reverse Mode Second Partial Derivative Driver
-           Forward Mode Second Partial Derivative Driver
-           First Order Derivative Driver: Example and Test
-           First Order Derivative: Driver Routine
-           Hessian: Easy Driver
-           Jacobian: Driver Routine
-           The Sign: sign: Derivative
-           AD Absolute Value Functions: abs, fabs: Derivative
-           The Hyperbolic Tangent Function: tanh: Derivative
-           The Tangent Function: tan: Derivative
-           The Square Root Function: sqrt: Derivative
-           The Hyperbolic Sine Function: sinh: Derivative
-           The Sine Function: sin: Derivative
-           The Exponential Function: log: Derivative
-           The Exponential Function: exp: Derivative
-           The Hyperbolic Cosine Function: cosh: Derivative
-           The Cosine Function: cos: Derivative
-           Inverse Tangent Function: atan: Derivative
-           Inverse Sine Function: asin: Derivative
-           Inverse Sine Function: acos: Derivative
-           AD Compound Assignment Operators: Derivative
-           AD Binary Arithmetic Operators: Derivative
-           AD Unary Minus Operator: Derivative
-           AD Unary Plus Operator: Derivative
-           exp_eps: Second Order Forward Mode: Operation Sequence.Derivative
-           exp_eps: First Order Forward Sweep: Operation Sequence.Derivative
-           exp_2: Second Order Forward Mode: Operation Sequence.Derivative
-           exp_2: First Order Forward Mode: Operation Sequence.Derivative
-           cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-derivative: First Order Derivative: Driver Routine
-            First Order Partial Derivative: Driver Routine
-derivatives Using AD to Compute Atomic Function Derivatives
-            Using AD to Compute Atomic Function Derivatives
-            An ODE Inverse Problem Example: Black Box Method.Derivatives
-            Bibliography: Evaluating Derivatives
-            Error Function Forward Taylor Polynomial Theory: Derivatives
-            Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory: Derivatives
-            Inverse Cosine and Hyperbolic Cosine Forward Mode Theory: Derivatives
-            Inverse Sine and Hyperbolic Sine Forward Mode Theory: Derivatives
-            Inverse Tangent and Hyperbolic Tangent Forward Mode Theory: Derivatives
-            Logarithm Function Forward Mode Theory: Derivatives
-            Exponential Function Forward Mode Theory: Derivatives
-            Speed Test Derivatives Using Sacado
-            Speed Test Derivatives Using Fadbad
-            Speed Test Derivatives Using CppAD
-            Speed Test of Derivatives Using Adolc
-            Using Multiple Levels of AD: Procedure.Derivatives of Outer Function
-            Getting Started Using CppAD to Compute Derivatives
-            Calculating Sparse Derivatives
-            Discrete AD Functions: Derivatives
-derivatives: First and Second Order Derivatives: Easy Drivers
-description LU Factorization of A Square Matrix and Stability Calculation: Description
-            General Examples: Description
-            The CppAD::vector Template Class: Description
-            An Error Controller for ODE Solvers: Description
-            A 3rd and 4th Order Rosenbrock ODE Solver: Description
-            Multi-dimensional Romberg Integration: Description
-            One DimensionalRomberg Integration: Description
-            Invert an LU Factored Equation: Description
-            LU Factorization of A Square Matrix: Description
-            Compute Determinant and Solve Linear Equations: Description
-            Evaluate a Polynomial or its Derivative: Description
-            Atomic Eigen Cholesky Factorization: Example and Test: Description
-            Atomic Eigen Matrix Inverse: Example and Test: Description
-            Atomic Eigen Matrix Multiply: Example and Test: Description
-            Conditional Expressions: Example and Test: Description
-            The Sign: sign: Description
-            The Logarithm of One Plus Argument: log1p: Description
-            The Exponential Function Minus One: expm1: Description
-            The Error Function: Description
-            The Inverse Hyperbolic Tangent Function: atanh: Description
-            The Inverse Hyperbolic Sine Function: asinh: Description
-            The Inverse Hyperbolic Cosine Function: acosh: Description
-destructor Deallocate An Array and Call Destructor for its Elements
-           Definition of a Simple Vector: Element Constructor and Destructor
-det Determinant Using Expansion by Minors: det
-    Determinant Using Expansion by Lu Factorization: det
-det_33 Source: det_33
-       Check Determinant of 3 by 3 matrix
-det_by_lu Source: det_by_lu
-          Determinant Using Expansion by Lu Factorization
-det_by_minor Determine Amount of Time to Execute det_by_minor
-             Repeat det_by_minor Routine A Specified Number of Times
-             Correctness Test of det_by_minor Routine
-             Source: det_by_minor
-det_grad_33 Source: det_grad_33
-            Check Gradient of Determinant of 3 by 3 matrix
-det_of_minor Source: det_of_minor
-             Determinant of a Minor: Example and Test
-             Determinant of a Minor
-detection Memory Leak Detection
-determinant LU Factorization of A Square Matrix and Stability Calculation: LU.Determinant
-            Compute Determinant using Expansion by Minors
-            Determinant of a Minor: Determinant of A
-            Determinant of a Minor
-            Sacado Speed: Gradient of Determinant Using Lu Factorization
-            Sacado Speed: Gradient of Determinant by Minor Expansion
-            Fadbad Speed: Gradient of Determinant Using Lu Factorization
-            Fadbad Speed: Gradient of Determinant by Minor Expansion
-            CppAD Speed: Gradient of Determinant Using Lu Factorization
-            CppAD Speed: Gradient of Determinant by Minor Expansion
-            Adolc Speed: Gradient of Determinant Using Lu Factorization
-            Adolc Speed: Gradient of Determinant by Minor Expansion
-            Double Speed: Determinant Using Lu Factorization
-            Double Speed: Determinant by Minor Expansion
-            Check Gradient of Determinant of 3 by 3 matrix
-            Check Determinant of 3 by 3 matrix
-            Determinant Using Expansion by Minors: Example and Test
-            Determinant Using Expansion by Minors
-            Determinant of a Minor: Example and Test
-            Determinant of a Minor: Determinant of A
-            Determinant of a Minor
-            Determinant Using Lu Factorization: Example and Test
-            Determinant Using Expansion by Lu Factorization
-            Speed Testing Gradient of Determinant by Minor Expansion
-            Speed Testing Gradient of Determinant Using Lu Factorization
-            Lu Factor and Solve with Recorded Pivoting
-            Gradient of Determinant Using Lu Factorization: Example and Test
-            Gradient of Determinant Using Expansion by Minors: Example and Test
-            Gradient of Determinant Using LU Factorization: Example and Test
-            Gradient of Determinant Using Expansion by Minors: Example and Test
-            Using Eigen To Compute Determinant: Example and Test
-            LU Factorization of A Square Matrix: LU.Determinant
-            Compute Determinant and Solve Linear Equations
-determinant: Using Eigen To Compute Determinant: Example and Test
-determinants Compute Determinants and Solve Equations by LU Factorization
-determine Determine Amount of Time to Execute det_by_minor
-          Obtain Nan or Determine if a Value is Nan
-          Determine Amount of Time to Execute a Test
-          Determine if Two Values Are Nearly Equal
-difference Interfacing to C: Example and Test
-           Determine if Two Values Are Nearly Equal
-differential Trigonometric and Hyperbolic Sine and Cosine Forward Theory: Differential Equation
-             The Theory of Forward Mode: Standard Math Functions.Differential Equation
-             An Error Controller for Gear's Ode Solvers
-             An Arbitrary Order Gear Method
-             An Error Controller for ODE Solvers
-             A 3rd and 4th Order Rosenbrock ODE Solver
-             An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-differentiate Differentiate Conjugate Gradient Algorithm: Example and Test
-differentiating Example Differentiating a Stack Machine Interpreter
-differentiation Example and Test Linking CppAD to Languages Other than C++
-                An Introduction by Example to Algorithmic Differentiation: Preface.Algorithmic Differentiation
-                An Introduction by Example to Algorithmic Differentiation
-                cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-                cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-digits10 Numeric Limits For an AD and Base Types: digits10
-dimension Multi-dimensional Romberg Integration
-dimensional One Dimensional Romberg Integration: Example and Test
-            Multi-dimensional Romberg Integration
-            One Dimensional Romberg Integration: Example and Test
-dimensionalromberg One DimensionalRomberg Integration
-dimensions Matrix Multiply as an Atomic Operation: Matrix Dimensions
-           Atomic Eigen Matrix Inversion Class: Matrix Dimensions
-           Atomic Eigen Matrix Multiply Class: Matrix Dimensions
-direction Hessian Times Direction: Example and Test
-          Second Order Reverse Mode: Hessian Times Direction
-direction: Hessian Times Direction: Example and Test
-directions Forward Mode: Example and Test of Multiple Directions
-           Multiple Directions Forward Mode
-           Reverse Mode: Multiple Directions
-directories Using CMake to Configure CppAD
-directory Autotools Unix Test and Installation: Build Directory
-          Autotools Unix Test and Installation: Distribution Directory
-          Directory Structure: Example Directory
-          Directory Structure: Distribution Directory
-          Directory Structure
-          Download and Install Sacado in Build Directory: Prefix Directory
-          Download and Install Sacado in Build Directory: External Directory
-          Download and Install Sacado in Build Directory: Distribution Directory
-          Download and Install Sacado in Build Directory
-          Download and Install Ipopt in Build Directory: Prefix Directory
-          Download and Install Ipopt in Build Directory: External Directory
-          Download and Install Ipopt in Build Directory: Distribution Directory
-          Download and Install Ipopt in Build Directory
-          Download and Install Fadbad in Build Directory: Prefix Directory
-          Download and Install Fadbad in Build Directory: External Directory
-          Download and Install Fadbad in Build Directory: Distribution Directory
-          Download and Install Fadbad in Build Directory
-          Download and Install Eigen in Build Directory: Prefix Directory
-          Download and Install Eigen in Build Directory: External Directory
-          Download and Install Eigen in Build Directory: Distribution Directory
-          Download and Install Eigen in Build Directory
-          Download and Install ColPack in Build Directory: Prefix Directory
-          Download and Install ColPack in Build Directory: External Directory
-          Download and Install ColPack in Build Directory: Distribution Directory
-          Download and Install ColPack in Build Directory
-          Download and Install Adolc in Build Directory: Prefix Directory
-          Download and Install Adolc in Build Directory: External Directory
-          Download and Install Adolc in Build Directory: Distribution Directory
-          Download and Install Adolc in Build Directory
-          Using CMake to Configure CppAD: CMake Command.Build Directory
-          Download The CppAD Source Code: Distribution Directory
-discrete Discrete AD Functions
-discussion Comparison Changes During Zero Order Forward Mode: Discussion
-           An Error Controller for Gear's Ode Solvers: Error Criteria Discussion
-           An Error Controller for ODE Solvers: Error Criteria Discussion
-           Enable AD Calculations During Parallel Mode: Discussion
-           Check an ADFun Sequence of Operations: Discussion
-           abs_normal min_nso_quad: Example and Test: Discussion
-           abs_normal min_nso_linear: Example and Test: Discussion
-           Computing Dependency: Example and Test: Discussion
-           Comparison Changes Between Taping and Zero Order Forward: number.Discussion
-           Atomic Forward Mode: Discussion
-           Checkpointing an Extended ODE Solver: Example and Test: Discussion
-           Atomic Operations and Multiple-Levels of AD: Example and Test: Discussion
-           Printing AD Values During Forward Mode: Discussion
-disk Frequently Asked Questions and Answers: Tape Storage: Disk or Memory
-distribution Autotools Unix Test and Installation: Distribution Directory
-             Directory Structure: Distribution Directory
-             Download and Install Sacado in Build Directory: Distribution Directory
-             Download and Install Ipopt in Build Directory: Distribution Directory
-             Download and Install Fadbad in Build Directory: Distribution Directory
-             Download and Install Eigen in Build Directory: Distribution Directory
-             Download and Install ColPack in Build Directory: Distribution Directory
-             Download and Install Adolc in Build Directory: Distribution Directory
-             Download The CppAD Source Code: Distribution Directory
-divide AD Compound Assignment Division: Example and Test
-       AD Compound Assignment Operators
-       AD Binary Division: Example and Test
-       AD Binary Arithmetic Operators
-division The Theory of Reverse Mode: Binary Operators.Division
-         The Theory of Forward Mode: Binary Operators.Division
-         AD Compound Assignment Operators: Derivative.Division
-         AD Binary Arithmetic Operators: Derivative.Division
-division: AD Compound Assignment Division: Example and Test
-          AD Binary Division: Example and Test
-do Do One Thread's Work for Multi-Threaded Newton Method
-   Do One Thread's Work for Sum of 1/i
-documentation Using CMake to Configure CppAD
-              Download The CppAD Source Code: Building Documentation
-documented CppAD API Preprocessor Symbols: Documented Elsewhere
-           CppAD API Preprocessor Symbols: Documented Here
-domain ODE Fitting Using Fast Representation: Trapezoidal Approximation.Domain Indices J(k,0)
-       ODE Fitting Using Fast Representation: Initial Condition.Domain Indices J(k,0)
-       ODE Fitting Using Fast Representation: Objective Function.Domain Indices J(k,0)
-       ADFun Sequence Properties: Domain
-double Double Speed: Sparse Jacobian
-       Double Speed: Sparse Hessian
-       Double Speed: Evaluate a Polynomial
-       Double Speed: Ode Solution
-       Double Speed: Determinant Using Lu Factorization
-       Double Speed: Determinant by Minor Expansion
-       Speed Test of Functions in Double
-       Speed Testing Sparse Jacobian: n_sweep.double
-       Speed Testing Sparse Hessian: n_sweep.double
-       Speed Testing Second Derivative of a Polynomial: ddp.double
-       Speed Testing the Jacobian of Ode Solution: jacobian.double
-       Speed Testing Gradient of Determinant by Minor Expansion: gradient.double
-       Speed Testing Gradient of Determinant Using Lu Factorization: gradient.double
-       Running the Speed Test Program: package.double
-       Enable use of AD<Base> where Base is double
-       Required Base Class Member Functions: Double Constructor
-down Take Down Multi-threaded Newton Method
-     Multi-Threaded User Atomic Take Down
-     Take Down Multi-threading Sum of 1/i
-download Download and Install Sacado in Build Directory
-         Download and Install Ipopt in Build Directory
-         Download and Install Fadbad in Build Directory
-         Download and Install Eigen in Build Directory
-         Download and Install ColPack in Build Directory
-         Download and Install Adolc in Build Directory
-         Download The CppAD Source Code
-         CppAD Download, Test, and Install Instructions: Instructions.Step 1: Download
-         CppAD Download, Test, and Install Instructions
-     install fadbad Download and Install Fadbad in Build Directory
-     install ipopt Download and Install Ipopt in Build Directory
-     install sacado Download and Install Sacado in Build Directory
-driver Driver for Running the Ipopt ODE Example
-       Reverse Mode Second Partial Derivative Driver
-       Forward Mode Second Partial Derivative Driver
-       First Order Derivative: Driver Routine
-       First Order Partial Derivative: Driver Routine
-       Hessian: Easy Driver
-       Jacobian: Driver Routine
-driver: Second Partials Reverse Driver: Example and Test
-        First Order Derivative Driver: Example and Test
-        First Order Partial Driver: Example and Test
-drivers First and Second Order Derivatives: Easy Drivers
-during Comparison Changes During Zero Order Forward Mode
-       Changes and Additions to CppAD During 2003
-       Changes and Additions to CppAD During 2004
-       Changes and Additions to CppAD During 2005
-       Changes and Additions to CppAD During 2006
-       Changes and Additions to CppAD During 2007
-       Changes and Additions to CppAD During 2008
-       Changes and Additions to CppAD During 2009
-       Changes and Additions to CppAD During 2010
-       Changes and Additions to CppAD During 2011
-       CppAD Changes and Additions During 2012
-       CppAD Changes and Additions During 2013
-       CppAD Changes and Additions During 2014
-       CppAD Changes and Additions During 2015
-       Changes and Additions to CppAD During 2016
-       Changes and Additions to CppAD During 2017
-       CppAD Assertions During Execution
-       Enable AD Calculations During Parallel Mode
-       Convert an AD Variable to a Parameter: Example and Test
-       Convert an AD Variable to a Parameter
-       Print During Zero Order Forward Mode: Example and Test
-       Printing During Forward Mode: Example and Test
-       Printing AD Values During Forward Mode
-dvector Use Ipopt to Solve a Nonlinear Programming Problem: Dvector
-dw Reverse Mode Using Subgraphs: dw
-   Any Order Reverse Mode: dw
-   Second Order Reverse Mode: dw
-   First Order Reverse Mode: dw
-   First Order Derivative: Driver Routine: dw
-dy First Order Partial Derivative: Driver Routine: dy
-dz Speed Testing Derivative of Matrix Multiply: dz
- -E -
-EqualOpSeq EqualOpSeq: Example and Test
-           Check if Two Value are Identically Equal
-ErrorHandler Replacing the CppAD Error Handler
-e An Arbitrary Order Gear Method: e
-  A 3rd and 4th Order Rosenbrock ODE Solver: e
-  An Embedded 4th and 5th Order Runge-Kutta ODE Solver: e
-  Multi-dimensional Romberg Integration: e
-  One DimensionalRomberg Integration: e
-eabs An Error Controller for Gear's Ode Solvers: eabs
-     An Error Controller for ODE Solvers: eabs
-easy Reverse Mode Second Partial Derivative Driver
-     Forward Mode Second Partial Derivative Driver
-     First Order Derivative: Driver Routine
-     First Order Partial Derivative: Driver Routine
-     Hessian: Easy Driver
-     First and Second Order Derivatives: Easy Drivers
-ef An Error Controller for Gear's Ode Solvers: ef
-   An Error Controller for ODE Solvers: ef
-efficiency Optimize an ADFun Object Tape: Efficiency
-           An Introduction by Example to Algorithmic Differentiation: Preface.Efficiency
-efficient Check If A Memory Allocation is Efficient for Another Use
-          Glossary
-eigen The CppAD Wish List: Eigen
-      Using The CppAD Test Vector Template Class: Eigen Vectors
-      Using Eigen To Compute Determinant: Example and Test
-      Using Eigen Arrays: Example and Test
-      Enable Use of Eigen Linear Algebra Package with CppAD: Eigen NumTraits
-      Enable Use of Eigen Linear Algebra Package with CppAD
-      Atomic Eigen Cholesky Factorization Class
-      Atomic Eigen Cholesky Factorization: Example and Test
-      Atomic Eigen Matrix Inversion Class
-      Atomic Eigen Matrix Inverse: Example and Test
-      Atomic Eigen Matrix Multiply Class
-      Atomic Eigen Matrix Multiply: Example and Test
-      Choosing the CppAD Test Vector Template Class: eigen
-      Download and Install Eigen in Build Directory
-      Including the Eigen Examples and Tests
-      Using CMake to Configure CppAD: cppad_profile_flag.Eigen and Fadbad
-eigen_dir Autotools Unix Test and Installation: eigen_dir
-eigen_plugin.hpp Source Code for eigen_plugin.hpp
-eigen_prefix Including the Eigen Examples and Tests: eigen_prefix
-elapsed Returns Elapsed Number of Seconds
-        Microsoft Version of Elapsed Number of Seconds
-        Elapsed Seconds: Example and Test
-        Returns Elapsed Number of Seconds
-elapsed_seconds Returns Elapsed Number of Seconds
-element Union of Standard Sets: Element
-        The CppAD::vector Template Class: vectorBool.Element Type
-        The CppAD::vector Template Class: Element Access
-        Definition of a Simple Vector: Element Access
-        Definition of a Simple Vector: Element Constructor and Destructor
-        Matrix Multiply as an Atomic Operation: Result Element Index
-        Matrix Multiply as an Atomic Operation: Right Operand Element Index
-        Matrix Multiply as an Atomic Operation: Left Operand Element Index
-element-wise The CppAD Wish List: Atomic.Element-wise Operations
-elementary Glossary: Elementary Vector
-           Solve a Quadratic Program Using Interior Point Method: Newton Step.Elementary Row Reduction
-elements Sum of the Elements of the Square of a Matrix: Example and Test
-         Sum Elements of a Matrix Times Itself
-         Deallocate An Array and Call Destructor for its Elements
-         Allocate An Array and Call Default Constructor for its Elements
-         Definition of a Simple Vector: Elements of Specified Type
-eliminating Tangent and Hyperbolic Tangent Reverse Mode Theory: Eliminating Y(t)
-ell Reverse Mode Using Subgraphs: ell
-elsewhere CppAD API Preprocessor Symbols: Documented Elsewhere
-embedded An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-empty Sparse Matrix Row, Column, Value Representation: empty
-      Row and Column Index Sparsity Patterns: empty
-enable Enable Use of Eigen Linear Algebra Package with CppAD
-       Enable AD Calculations During Parallel Mode
-       Enable use of AD<Base> where Base is std::complex<double>
-       Enable use of AD<Base> where Base is double
-       Enable use of AD<Base> where Base is float
-       Enable use of AD<Base> where Base is Adolc's adouble Type
-end Do One Thread's Work for Sum of 1/i: end
-    Matrix Multiply as an Atomic Operation: End Class Definition
-    Atomic Eigen Cholesky Factorization Class: End Class Definition
-    Atomic Eigen Matrix Inversion Class: End Class Definition
-    Atomic Eigen Matrix Multiply Class: End Class Definition
-    Tan and Tanh as User Atomic Operations: Example and Test: End Class Definition
-    Atomic Sparsity with Set Patterns: Example and Test: End Class Definition
-    Reciprocal as an Atomic Operation: Example and Test: End Class Definition
-    Atomic Euclidean Norm Squared: Example and Test: End Class Definition
-    Getting Started with Atomic Operations: Example and Test: End Class Definition
-entire Forward Mode Hessian Sparsity Patterns: Sparsity for Entire Hessian
-       Hessian Sparsity Pattern: Reverse Mode: Entire Sparsity Pattern
-       Reverse Mode Hessian Sparsity Patterns: Sparsity for Entire Hessian
-       Jacobian Sparsity Pattern: Reverse Mode: Entire Sparsity Pattern
-       Reverse Mode Jacobian Sparsity Patterns: Sparsity for Entire Jacobian
-       Jacobian Sparsity Pattern: Forward Mode: Entire Sparsity Pattern
-       Forward Mode Jacobian Sparsity Patterns: Sparsity for Entire Jacobian
-environment Setup thread_alloc For Use in Multi-Threading Environment
-            Using CppAD in a Multi-Threading Environment
-eps Machine Epsilon For AD Types: eps
-epsilon Machine Epsilon For AD Types
-        A Multi-Threaded Newton's Method: epsilon
-        Set Up Multi-Threaded Newton Method: epsilon
-        Non-Smooth Optimization Using Abs-normal Quadratic Approximations: epsilon
-        abs_normal: Minimize a Linear Abs-normal Approximation: epsilon
-        abs_normal: Solve a Quadratic Program With Box Constraints: epsilon
-        Solve a Quadratic Program Using Interior Point Method: epsilon
-        Non-Smooth Optimization Using Abs-normal Linear Approximations: epsilon
-        abs_normal: Minimize a Linear Abs-normal Approximation: epsilon
-        Numeric Limits For an AD and Base Types: epsilon
-        exp_eps: Second Order Reverse Sweep: epsilon
-        exp_eps: First Order Reverse Sweep: epsilon
-        An Epsilon Accurate Exponential Approximation: epsilon
-        An Epsilon Accurate Exponential Approximation
-equal Determine if Two Values Are Nearly Equal
-      Base Type Requirements for Identically Equal Comparisons
-      Check if Two Value are Identically Equal
-      Compare AD and Base Objects for Nearly Equal
-equalopseq Enable use of AD<Base> where Base is std::complex<double>: EqualOpSeq
-           Enable use of AD<Base> where Base is double: EqualOpSeq
-           Enable use of AD<Base> where Base is float: EqualOpSeq
-           Enable use of AD<Base> where Base is Adolc's adouble Type: EqualOpSeq
-           Example AD<Base> Where Base Constructor Allocates Memory: EqualOpSeq
-           Base Type Requirements for Identically Equal Comparisons: EqualOpSeq
-equalopseq: EqualOpSeq: Example and Test
-equation LU Factorization of A Square Matrix and Stability Calculation
-         Trigonometric and Hyperbolic Sine and Cosine Forward Theory: Differential Equation
-         The Theory of Forward Mode: Standard Math Functions.Differential Equation
-         Lu Factor and Solve with Recorded Pivoting
-         An Error Controller for Gear's Ode Solvers
-         An Arbitrary Order Gear Method
-         An Error Controller for ODE Solvers
-         A 3rd and 4th Order Rosenbrock ODE Solver
-         An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-         Invert an LU Factored Equation
-         LU Factorization of A Square Matrix
-equations Compute Determinant and Solve Linear Equations
-          Compute Determinants and Solve Equations by LU Factorization
-erel An Error Controller for Gear's Ode Solvers: erel
-     An Error Controller for ODE Solvers: erel
-erf Changes and Additions to CppAD During 2008
-    Error Function Reverse Mode Theory
-    Error Function Forward Taylor Polynomial Theory
-    Enable use of AD<Base> where Base is Adolc's adouble Type: erf, asinh, acosh, atanh, expm1, log1p
-    Example AD<Base> Where Base Constructor Allocates Memory: erf, asinh, acosh, atanh, expm1, log1p
-    Base Type Requirements for Standard Math Functions: erf, asinh, acosh, atanh, expm1, log1p
-    The AD erf Function: Example and Test
-error Memory Leak Detection: Error Message
-      Error Function Reverse Mode Theory
-      Error Function Forward Taylor Polynomial Theory
-      An Error Controller for Gear's Ode Solvers: Error Criteria Discussion
-      An Error Controller for Gear's Ode Solvers
-      An Error Controller for ODE Solvers: Error Criteria Discussion
-      An Error Controller for ODE Solvers
-      CppAD Assertions During Execution: Error Handler
-      Replacing The CppAD Error Handler: Example and Test
-      Replacing the CppAD Error Handler
-      Some General Purpose Utilities: Miscellaneous.Error Handler
-      Check an ADFun Object For Nan Results: Error Message
-      The Error Function
-errors Run One Speed Test and Print Results: Errors
-euclidean Atomic Euclidean Norm Squared: Example and Test
-evaluate Double Speed: Evaluate a Polynomial
-         Evaluate a Function That Has a Sparse Hessian
-         Evaluate a Function That Has a Sparse Jacobian
-         Evaluate a Function Defined in Terms of an ODE
-         Evaluate a Polynomial or its Derivative
-         abs_normal: Evaluate First Order Approximation
-evaluating Bibliography: Evaluating Derivatives
-evaluation: Polynomial Evaluation: Example and Test
-example LuRatio: Example and Test
-        LU Factorization of A Square Matrix and Stability Calculation: Example
-        opt_val_hes: Example and Test
-        Jacobian and Hessian of Optimal Values: Example
-        BenderQuad: Example and Test
-        Computing Jacobian and Hessian of Bender's Reduced Objective: Example
-        zdouble: Example and Test
-        zdouble: An AD Base Type With Absolute Zero: Example
-        Define Matrix Multiply as a User Atomic Operation: Example
-        Old Matrix Multiply as a User Atomic Operation: Example and Test
-        Old Tan and Tanh as User Atomic Operations: Example and Test
-        Old Atomic Operation Reciprocal: Example and Test
-        User Defined Atomic AD Functions: Example
-        Driver for Running the Ipopt ODE Example
-        ODE Fitting Using Fast Representation
-        ODE Fitting Using Simple Representation
-        ODE Inverse Problem Definitions: Source Code
-        An ODE Inverse Problem Example
-        Example Simultaneous Solution of Forward and Inverse Problem
-        Nonlinear Programming Using CppAD and Ipopt: Example and Test
-        Nonlinear Programming Using the CppAD Interface to Ipopt: Example
-        OpenMP Memory Allocator: Example and Test
-        Return A Raw Array to The Available Memory for a Thread: Example
-        Allocate Memory and Create A Raw Array: Example
-        Amount of Memory Available for Quick Use by a Thread: Example
-        Amount of Memory a Thread is Currently Using: Example
-        Free Memory Currently Available for Quick Use by a Thread: Example
-        Return Memory to omp_alloc: Example
-        Get At Least A Specified Amount of Memory: Example
-        Get the Current OpenMP Thread Number: Example
-        Is The Current Execution in OpenMP Parallel Mode: Example
-        Tracking Use of New and Delete: Example and Test
-        Routines That Track Use of New and Delete: Example
-        The CppAD Wish List: Example
-        Directory Structure: Example Directory
-        sparse_hes_fun: Example and test
-        Evaluate a Function That Has a Sparse Hessian: Example
-        sparse_jac_fun: Example and test
-        Evaluate a Function That Has a Sparse Jacobian: Example
-        ode_evaluate: Example and test
-        Evaluate a Function Defined in Terms of an ODE: Example
-        Sum of the Elements of the Square of a Matrix: Example and Test
-        Sum Elements of a Matrix Times Itself: Example
-        Determinant Using Expansion by Minors: Example and Test
-        Determinant Using Expansion by Minors: Example
-        Determinant of a Minor: Example and Test
-        Determinant of a Minor: Example
-        Determinant Using Lu Factorization: Example and Test
-        Determinant Using Expansion by Lu Factorization: Example
-        Lu Factor and Solve With Recorded Pivoting: Example and Test
-        Lu Factor and Solve with Recorded Pivoting: Example
-        Example Differentiating a Stack Machine Interpreter
-        Taylor's Ode Solver: An Example and Test
-        Taylor's Ode Solver: A Multi-Level Adolc Example and Test
-        Taylor's Ode Solver: A Multi-Level AD Example and Test
-        A Stiff Ode: Example and Test
-        Multiple Level of AD: Example and Test
-        Using Multiple Levels of AD: Example
-        Gradient of Determinant Using Lu Factorization: Example and Test
-        Gradient of Determinant Using Expansion by Minors: Example and Test
-        Interfacing to C: Example and Test
-        Gradient of Determinant Using LU Factorization: Example and Test
-        Gradient of Determinant Using Expansion by Minors: Example and Test
-        Using Eigen To Compute Determinant: Example and Test
-        Using Eigen Arrays: Example and Test
-        Enable Use of Eigen Linear Algebra Package with CppAD: Example
-        Differentiate Conjugate Gradient Algorithm: Example and Test
-        Example and Test Linking CppAD to Languages Other than C++
-        Creating Your Own Interface to an ADFun Object
-        Getting Started Using CppAD to Compute Derivatives
-        ODE Inverse Problem Definitions: Source Code
-        Nonlinear Programming Retaping: Example and Test
-        Nonlinear Programming Using CppAD and Ipopt: Example and Test
-        Use Ipopt to Solve a Nonlinear Programming Problem: Example
-        sparse_rcv: Example and Test
-        Sparse Matrix Row, Column, Value Representation: Example
-        sparse_rc: Example and Test
-        Row and Column Index Sparsity Patterns: Example
-        Set Union: Example and Test
-        Union of Standard Sets: Example
-        to_string: Example and Test
-        Convert Certain Types to a String: Example
-        Index Sort: Example and Test
-        Returns Indices that Sort a Vector: Example
-        Free All Memory That Was Allocated for Use by thread_alloc: Example
-        Deallocate An Array and Call Destructor for its Elements: Example
-        Allocate An Array and Call Default Constructor for its Elements: Example
-        Amount of Memory Available for Quick Use by a Thread: Example
-        Amount of Memory a Thread is Currently Using: Example
-        Free Memory Currently Available for Quick Use by a Thread: Example
-        Return Memory to thread_alloc: Example
-        Get At Least A Specified Amount of Memory: Example
-        Get the Current Thread Number: Example
-        Is The Current Execution in Parallel Mode: Example
-        Get Number of Threads: Example
-        Setup thread_alloc For Use in Multi-Threading Environment: Example
-        Fast Multi-Threading Memory Allocator: Example and Test
-        CppAD::vectorBool Class: Example and Test
-        CppAD::vector Template Class: Example and Test
-        The CppAD::vector Template Class: Example
-        OdeGearControl: Example and Test
-        An Error Controller for Gear's Ode Solvers: Example
-        OdeGear: Example and Test
-        An Arbitrary Order Gear Method: Example
-        OdeErrControl: Example and Test Using Maxabs Argument
-        OdeErrControl: Example and Test
-        An Error Controller for ODE Solvers: Example
-        Rosen34: Example and Test
-        A 3rd and 4th Order Rosenbrock ODE Solver: Example
-        Runge45: Example and Test
-        Runge45: Example and Test
-        An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Example
-        One Dimensional Romberg Integration: Example and Test
-        Multi-dimensional Romberg Integration: Example
-        One Dimensional Romberg Integration: Example and Test
-        One DimensionalRomberg Integration: Example
-        LuInvert: Example and Test
-        Invert an LU Factored Equation: Example
-        LuFactor: Example and Test
-        LU Factorization of A Square Matrix: Example
-        LuSolve With Complex Arguments: Example and Test
-        Compute Determinant and Solve Linear Equations: Example
-        Polynomial Evaluation: Example and Test
-        Evaluate a Polynomial or its Derivative: Example
-        The Pow Integer Exponent: Example and Test
-        The Integer Power Function: Example
-        nan: Example and Test
-        Obtain Nan or Determine if a Value is Nan: Example
-        The CheckSimpleVector Function: Example and Test
-        Check Simple Vector Concept: Example
-        Simple Vector Template Class: Example and Test
-        Definition of a Simple Vector: Example
-        The CheckNumericType Function: Example and Test
-        Check NumericType Class Concept: Example
-        The NumericType: Example and Test
-        Definition of a Numeric Type: Example
-        Object that Runs a Group of Tests: Example
-        time_test: Example and test
-        Elapsed Seconds: Example and Test
-        Returns Elapsed Number of Seconds: Example
-        Determine Amount of Time to Execute a Test: Example
-        Example Use of SpeedTest
-        speed_test: Example and test
-        Run One Speed Test and Print Results: Example
-        Run One Speed Test and Return Results: Example
-        NearEqual Function: Example and Test
-        Determine if Two Values Are Nearly Equal: Example
-        Replacing The CppAD Error Handler: Example and Test
-        Replacing the CppAD Error Handler: Example
-        Specifications for A Team of AD Threads: Example Implementation
-        Specifications for A Team of AD Threads: Example Use
-        Multi-Threaded Newton Method Example / Test
-        Multi-Threading User Atomic Example / Test
-        Multi-Threading Harmonic Summation Example / Test
-        Using a Team of AD Threads: Example and Test
-        A Simple pthread AD: Example and Test
-        A Simple Boost Threading AD: Example and Test
-        A Simple OpenMP AD: Example and Test
-        A Simple Parallel Pthread Example and Test
-        A Simple Boost Thread Example and Test
-        A Simple OpenMP Example and Test
-        Enable AD Calculations During Parallel Mode: Example
-        ADFun Checking For Nan: Example and Test
-        Check an ADFun Object For Nan Results: Example
-        ADFun Check and Re-Tape: Example and Test
-        Check an ADFun Sequence of Operations: Example
-        abs_normal min_nso_quad: Example and Test
-        Non-Smooth Optimization Using Abs-normal Quadratic Approximations: Example
-        abs_min_quad: Example and Test
-        abs_normal: Minimize a Linear Abs-normal Approximation: Example
-        abs_normal qp_box: Example and Test
-        abs_normal: Solve a Quadratic Program With Box Constraints: Example
-        abs_normal qp_interior: Example and Test
-        Solve a Quadratic Program Using Interior Point Method: Example
-        abs_normal min_nso_linear: Example and Test
-        Non-Smooth Optimization Using Abs-normal Linear Approximations: Example
-        abs_min_linear: Example and Test
-        abs_normal: Minimize a Linear Abs-normal Approximation: Example
-        abs_normal lp_box: Example and Test
-        abs_normal: Solve a Linear Program With Box Constraints: Example
-        abs_normal simplex_method: Example and Test
-        abs_normal: Solve a Linear Program Using Simplex Method: Example
-        abs_eval: Example and Test
-        abs_normal: Evaluate First Order Approximation: Example
-        abs_normal Getting Started: Example and Test
-        Create An Abs-normal Representation of a Function: Example
-        Example Optimization and Cumulative Sum Operations
-        Example Optimization and Nested Conditional Expressions
-        Example Optimization and Conditional Expressions
-        Example Optimization and Print Forward Operators
-        Example Optimization and Comparison Operators
-        Example Optimization and Reverse Activity Analysis
-        Example Optimization and Forward Activity Analysis
-        Sparse Hessian Using Subgraphs and Jacobian: Example and Test
-        Computing Sparse Jacobian Using Reverse Mode: Example and Test
-        Compute Sparse Jacobians Using Subgraphs: Example
-        Subset of a Sparse Hessian: Example and Test
-        Computing Sparse Hessian for a Subset of Variables: Example
-        Sparse Hessian: Example and Test
-        Sparse Hessian: Example
-        Computing Sparse Hessian: Example and Test
-        Computing Sparse Hessians: Example
-        Sparse Jacobian: Example and Test
-        Sparse Jacobian: Example
-        Computing Sparse Jacobian Using Reverse Mode: Example and Test
-        Computing Sparse Jacobian Using Forward Mode: Example and Test
-        Computing Sparse Jacobians: Example
-        Subgraph Dependency Sparsity Patterns: Example and Test
-        Subgraph Dependency Sparsity Patterns: Example
-        Preferred Sparsity Patterns: Row and Column Indices: Example and Test
-        Computing Dependency: Example and Test
-        Forward Mode Hessian Sparsity: Example and Test
-        Hessian Sparsity Pattern: Forward Mode: Example
-        Forward Mode Hessian Sparsity: Example and Test
-        Forward Mode Hessian Sparsity Patterns: Example
-        Sparsity Patterns For a Subset of Variables: Example and Test
-        Reverse Mode Hessian Sparsity: Example and Test
-        Hessian Sparsity Pattern: Reverse Mode: Example
-        Reverse Mode Hessian Sparsity: Example and Test
-        Reverse Mode Hessian Sparsity Patterns: Example
-        Reverse Mode Jacobian Sparsity: Example and Test
-        Jacobian Sparsity Pattern: Reverse Mode: Example
-        Reverse Mode Jacobian Sparsity: Example and Test
-        Reverse Mode Jacobian Sparsity Patterns: Example
-        Forward Mode Jacobian Sparsity: Example and Test
-        Jacobian Sparsity Pattern: Forward Mode: Example
-        Forward Mode Jacobian Sparsity: Example and Test
-        Forward Mode Jacobian Sparsity Patterns: Example
-        Computing Reverse Mode on Subgraphs: Example and Test
-        Reverse Mode Using Subgraphs: Example
-        Reverse Mode General Case (Checkpointing): Example and Test
-        Third Order Reverse Mode: Example and Test
-        Any Order Reverse Mode: Example
-        Hessian Times Direction: Example and Test
-        Second Order Reverse ModeExample and Test
-        Second Order Reverse Mode: Example
-        First Order Reverse Mode: Example and Test
-        First Order Reverse Mode: Example
-        Number of Variables That Can be Skipped: Example and Test
-        Number of Variables that Can be Skipped: Example
-        Controlling Taylor Coefficient Memory Allocation: Example and Test
-        Controlling Taylor Coefficients Memory Allocation: Example
-        CompareChange and Re-Tape: Example and Test
-        Comparison Changes Between Taping and Zero Order Forward: Example
-        Number Taylor Coefficient Orders Currently Stored: Example
-        Forward Mode: Example and Test of Multiple Directions
-        Multiple Directions Forward Mode: Example
-        Forward Mode: Example and Test of Multiple Orders
-        Forward Mode: Example and Test
-        Multiple Order Forward Mode: Example
-        Second Order Forward Mode: Derivative Values: Example
-        First Order Forward Mode: Derivative Values: Example
-        Zero Order Forward Mode: Function Values: Example
-        Second Partials Reverse Driver: Example and Test
-        Subset of Second Order Partials: Example and Test
-        First Order Derivative Driver: Example and Test
-        First Order Derivative: Driver Routine: Example
-        First Order Partial Driver: Example and Test
-        First Order Partial Derivative: Driver Routine: Example
-        Hessian of Lagrangian and ADFun Default Constructor: Example and Test
-        Hessian: Example and Test
-        Hessian: Easy Driver: Example
-        Jacobian: Example and Test
-        Jacobian: Driver Routine: Example
-        ADFun Sequence Properties: Example and Test
-        ADFun Sequence Properties: Example
-        Abort Current Recording: Example and Test
-        Abort Recording of an Operation Sequence: Example
-        Stop Recording and Store Operation Sequence: Example
-        ADFun Assignment: Example and Test
-        Construct an ADFun Object and Stop Recording: Example
-        Independent and ADFun Constructor: Example and Test
-        Declare Independent Variables and Start Recording: Example
-        Complex Polynomial: Example and Test
-        Enable use of AD<Base> where Base is std::complex<double>: Example
-        Using Adolc with Multiple Levels of Taping: Example and Test
-        Enable use of AD<Base> where Base is Adolc's adouble Type: Example
-        Using a User Defined AD Base Type: Example and Test
-        Example AD<Base> Where Base Constructor Allocates Memory
-        Example AD Base Types That are not AD<OtherBase>
-        Base Type Requirements for Hash Coding Values: Example
-        Required Base Class Member Functions: Example
-        AD Vectors that Record Index Operations: Example and Test
-        AD Vectors that Record Index Operations: Example
-        EqualOpSeq: Example and Test
-        Check if Two Value are Identically Equal: Example
-        AD Parameter and Variable Functions: Example and Test
-        Is an AD Object a Parameter or Variable: Example
-        AD Boolean Functions: Example and Test
-        AD Boolean Functions: Example
-        Compare AD with Base Objects: Example and Test
-        Compare AD and Base Objects for Nearly Equal: Example
-        AD Binary Comparison Operators: Example and Test
-        AD Binary Comparison Operators: Example
-        User Atomic Matrix Multiply: Example and Test
-        Atomic Eigen Cholesky Factorization: Example and Test
-        Atomic Eigen Matrix Inverse: Example and Test
-        Atomic Eigen Matrix Multiply: Example and Test
-        Tan and Tanh as User Atomic Operations: Example and Test
-        Atomic Sparsity with Set Patterns: Example and Test
-        Reciprocal as an Atomic Operation: Example and Test
-        Atomic Euclidean Norm Squared: Example and Test
-        Getting Started with Atomic Operations: Example and Test
-        Atomic Reverse Hessian Sparsity: Example and Test
-        Atomic Forward Hessian Sparsity: Example and Test
-        Atomic Reverse Jacobian Sparsity: Example and Test
-        Atomic Forward Jacobian Sparsity: Example and Test
-        Atomic Reverse: Example and Test
-        Atomic Forward: Example and Test
-        Atomic Function Constructor: Example
-        Checkpointing an Extended ODE Solver: Example and Test
-        Checkpointing an ODE Solver: Example and Test
-        Atomic Operations and Multiple-Levels of AD: Example and Test
-        Simple Checkpointing: Example and Test
-        Checkpointing Functions: Example
-        Numeric Limits: Example and Test
-        Numeric Limits For an AD and Base Types: Example
-        Interpolation With Retaping: Example and Test
-        Interpolation With Out Retaping: Example and Test
-        Taping Array Index Operation: Example and Test
-        Discrete AD Functions: Example
-        Conditional Expressions: Example and Test
-        AD Conditional Expressions: Example
-        AD Absolute Zero Multiplication: Example and Test
-        Absolute Zero Multiplication: Example
-        The AD Power Function: Example and Test
-        The AD Power Function: Example
-        The AD atan2 Function: Example and Test
-        AD Two Argument Inverse Tangent Function: Example
-        Sign Function: Example and Test
-        The Sign: sign: Example
-        The AD log1p Function: Example and Test
-        The Logarithm of One Plus Argument: log1p: Example
-        The AD exp Function: Example and Test
-        The Exponential Function Minus One: expm1: Example
-        The AD erf Function: Example and Test
-        The Error Function: Example
-        The AD atanh Function: Example and Test
-        The Inverse Hyperbolic Tangent Function: atanh: Example
-        The AD asinh Function: Example and Test
-        The Inverse Hyperbolic Sine Function: asinh: Example
-        The AD acosh Function: Example and Test
-        The Inverse Hyperbolic Cosine Function: acosh: Example
-        AD Absolute Value Function: Example and Test
-        AD Absolute Value Functions: abs, fabs: Example
-        The AD tanh Function: Example and Test
-        The AD tan Function: Example and Test
-        The AD sqrt Function: Example and Test
-        The AD sinh Function: Example and Test
-        The AD sin Function: Example and Test
-        The AD log10 Function: Example and Test
-        The AD log Function: Example and Test
-        The AD exp Function: Example and Test
-        The AD cosh Function: Example and Test
-        The AD cos Function: Example and Test
-        The AD atan Function: Example and Test
-        The AD asin Function: Example and Test
-        The AD acos Function: Example and Test
-        The Hyperbolic Tangent Function: tanh: Example
-        The Tangent Function: tan: Example
-        The Square Root Function: sqrt: Example
-        The Hyperbolic Sine Function: sinh: Example
-        The Sine Function: sin: Example
-        The Base 10 Logarithm Function: log10: Example
-        The Exponential Function: log: Example
-        The Exponential Function: exp: Example
-        The Hyperbolic Cosine Function: cosh: Example
-        The Cosine Function: cos: Example
-        Inverse Tangent Function: atan: Example
-        Inverse Sine Function: asin: Example
-        Inverse Sine Function: acos: Example
-        AD Compound Assignment Division: Example and Test
-        AD Compound Assignment Multiplication: Example and Test
-        AD Compound Assignment Subtraction: Example and Test
-        AD Compound Assignment Addition: Example and Test
-        AD Compound Assignment Operators: Example
-        AD Binary Division: Example and Test
-        AD Binary Multiplication: Example and Test
-        AD Binary Subtraction: Example and Test
-        AD Binary Addition: Example and Test
-        AD Binary Arithmetic Operators: Example
-        AD Unary Minus Operator: Example and Test
-        AD Unary Minus Operator: Example
-        AD Unary Plus Operator: Example and Test
-        AD Unary Plus Operator: Example
-        Convert an AD Variable to a Parameter: Example and Test
-        Convert an AD Variable to a Parameter: Example
-        Print During Zero Order Forward Mode: Example and Test
-        Printing During Forward Mode: Example and Test
-        Printing AD Values During Forward Mode: Example
-        AD Output Operator: Example and Test
-        AD Output Operator: Example and Test
-        AD Output Stream Operator: Example
-        AD Output Stream Operator: Example
-        Convert An AD or Base Type to String: Example
-        Convert From AD to Integer: Example and Test
-        Convert From AD to Integer: Example
-        Convert From AD to its Base Type: Example and Test
-        Convert From an AD Type to its Base Type: Example
-        AD Assignment: Example and Test
-        AD Assignment Operator: Example
-        AD Constructors: Example and Test
-        AD Constructors: Example
-        exp_eps: Operation Sequence and Zero Order Forward Sweep
-        An Epsilon Accurate Exponential Approximation
-        exp_2: Operation Sequence and Zero Order Forward Mode
-        Second Order Exponential Approximation
-        An Introduction by Example to Algorithmic Differentiation
-        ColPack: Sparse Hessian Example and Test
-        ColPack: Sparse Hessian Example and Test
-        ColPack: Sparse Jacobian Example and Test
-        ColPack: Sparse Jacobian Example and Test
-        Including the ColPack Sparsity Calculations: Example
-        cppad-20180000.0: A Package for Differentiation of C++ Algorithms: Example
-examples Autotools Unix Test and Installation: make.Examples and Tests
-         Run the Speed Examples
-         CppAD Examples and Tests
-         List All (Except Deprecated) CppAD Examples
-         Utility Routines used by CppAD Examples
-         General Examples
-         Examples: Running Examples
-         Examples
-         Run Multi-Threading Examples and Speed Tests
-         Optimize an ADFun Object Tape: Examples
-         Reverse Mode Second Partial Derivative Driver: Examples
-         Forward Mode Second Partial Derivative Driver: Examples
-         Base Type Requirements for Identically Equal Comparisons: Identical.Examples
-         Atomic Reverse Hessian Sparsity Patterns: Examples
-         Atomic Forward Hessian Sparsity Patterns: Examples
-         Atomic Reverse Jacobian Sparsity Patterns: Examples
-         Atomic Forward Jacobian Sparsity Patterns: Examples
-         Atomic Reverse Mode: Examples
-         Atomic Forward Mode: Examples
-         Using AD Version of Atomic Function: Examples
-         User Defined Atomic AD Functions: Examples
-         Checking the CppAD Examples and Tests
-         Including the cppad_ipopt Library and Tests: Examples and Tests
-         Including the Eigen Examples and Tests: Examples
-         Including the Eigen Examples and Tests
-         Including the ADOL-C Examples and Tests: Examples
-         Including the ADOL-C Examples and Tests
-exception Replacing the CppAD Error Handler
-          Using CMake to Configure CppAD: cppad_debug_which.Exception
-exceptions Frequently Asked Questions and Answers: Exceptions
-           AD Vectors that Record Index Operations: VecAD<Base>::reference.Exceptions
-execute Determine Amount of Time to Execute det_by_minor
-        Determine Amount of Time to Execute a Test
-execution Is The Current Execution in OpenMP Parallel Mode
-          Is The Current Execution in Parallel Mode
-          CppAD Assertions During Execution
-          Using CppAD in a Multi-Threading Environment
-exercise The CppAD::vector Template Class: Exercise
-         Definition of a Simple Vector: Exercise
-         Definition of a Numeric Type: Exercise
-         Determine if Two Values Are Nearly Equal: Exercise
-exercises Getting Started Using CppAD to Compute Derivatives: Exercises
-          exp_eps: CppAD Forward and Reverse Sweeps: Exercises
-          exp_eps: Second Order Reverse Sweep: Exercises
-          exp_eps: Second Order Forward Mode: Exercises
-          exp_eps: First Order Reverse Sweep: Exercises
-          exp_eps: First Order Forward Sweep: Exercises
-          exp_eps: Operation Sequence and Zero Order Forward Sweep: Exercises
-          An Epsilon Accurate Exponential Approximation: Exercises
-          exp_2: CppAD Forward and Reverse Sweeps: Exercises
-          exp_2: Second Order Reverse Mode: Exercises
-          exp_2: Second Order Forward Mode: Exercises
-          exp_2: First Order Reverse Mode: Exercises
-          exp_2: First Order Forward Mode: Exercises
-          exp_2: Operation Sequence and Zero Order Forward Mode: Exercises
-          Second Order Exponential Approximation: Exercises
-exp Exponential Function Reverse Mode Theory
-    Exponential Function Forward Mode Theory
-    CppAD Assertions During Execution: Exp
-    Replacing the CppAD Error Handler: exp
-    The AD exp Function: Example and Test
-    The AD exp Function: Example and Test
-    The Exponential Function: exp
-exp_exp_eps: Verify Second Order Forward Sweep
-      exp_eps: Verify First Order Forward Sweep
-      exp_2: Verify Second Order Reverse Sweep
-      exp_2: Verify Second Order Forward Sweep
-      exp_2: Verify First Order Reverse Sweep
-      exp_2: Verify First Order Forward Sweep
-      exp_2: Verify Zero Order Forward Sweep
-      exp_2: Implementation
-      Second Order Exponential Approximation
-exp_2: exp_2: CppAD Forward and Reverse Sweeps
-       exp_2: Verify Second Order Reverse Sweep
-       exp_2: Verify Second Order Forward Sweep
-       exp_2: Verify First Order Reverse Sweep
-       exp_2: Verify First Order Forward Sweep
-       exp_2: Verify Zero Order Forward Sweep
-       exp_2: Second Order Reverse Mode
-       exp_2: Second Order Forward Mode
-       exp_2: First Order Reverse Mode
-       exp_2: First Order Forward Mode
-       exp_2: Operation Sequence and Zero Order Forward Mode
-       exp_2: Test
-       exp_2: Implementation
-exp_apx Correctness Tests For Exponential Approximation in Introduction
-exp_eps exp_eps: Verify Second Order Reverse Sweep
-        exp_eps: Verify First Order Reverse Sweep
-        exp_eps: Verify Zero Order Forward Sweep
-        exp_eps: Test of exp_eps
-        exp_eps: Implementation
-        An Epsilon Accurate Exponential Approximation
-exp_eps: exp_eps: CppAD Forward and Reverse Sweeps
-         exp_eps: Verify Second Order Reverse Sweep
-         exp_eps: Verify Second Order Forward Sweep
-         exp_eps: Verify First Order Reverse Sweep
-         exp_eps: Verify First Order Forward Sweep
-         exp_eps: Verify Zero Order Forward Sweep
-         exp_eps: Second Order Reverse Sweep
-         exp_eps: Second Order Forward Mode
-         exp_eps: First Order Reverse Sweep
-         exp_eps: First Order Forward Sweep
-         exp_eps: Operation Sequence and Zero Order Forward Sweep
-         exp_eps: Test of exp_eps
-         exp_eps: Implementation
-expansion Compute Determinant using Expansion by Minors
-          Sacado Speed: Gradient of Determinant by Minor Expansion
-          Fadbad Speed: Gradient of Determinant by Minor Expansion
-          CppAD Speed: Gradient of Determinant by Minor Expansion
-          Adolc Speed: Gradient of Determinant by Minor Expansion
-          Double Speed: Determinant by Minor Expansion
-          Determinant Using Expansion by Minors: Example and Test
-          Determinant Using Expansion by Minors
-          Determinant Using Expansion by Lu Factorization
-          Speed Testing Gradient of Determinant by Minor Expansion
-          Gradient of Determinant Using Expansion by Minors: Example and Test
-          Gradient of Determinant Using Expansion by Minors: Example and Test
-          exp_eps: Second Order Forward Mode: Second Order Expansion
-          exp_eps: First Order Forward Sweep: First Order Expansion
-          exp_2: Second Order Forward Mode: Second Order Expansion
-          exp_2: First Order Forward Mode: First Order Expansion
-          exp_2: Operation Sequence and Zero Order Forward Mode: Zero Order Expansion
-explicit AD Constructors: x.explicit
-         Using CMake to Configure CppAD
-expm1 Exponential Function Reverse Mode Theory
-      Exponential Function Forward Mode Theory
-      Enable use of AD<Base> where Base is Adolc's adouble Type: erf, asinh, acosh, atanh, expm1, log1p
-      Example AD<Base> Where Base Constructor Allocates Memory: erf, asinh, acosh, atanh, expm1, log1p
-      Base Type Requirements for Standard Math Functions: erf, asinh, acosh, atanh, expm1, log1p
-      The Exponential Function Minus One: expm1
-exponent The Integer Power Function
-         The AD Power Function
-exponent: The Pow Integer Exponent: Example and Test
-exponential Exponential Function Reverse Mode Theory
-            Exponential Function Forward Mode Theory
-            The Exponential Function Minus One: expm1
-            The Exponential Function: log
-            The Exponential Function: exp
-            Correctness Tests For Exponential Approximation in Introduction
-            An Epsilon Accurate Exponential Approximation
-            Second Order Exponential Approximation
-expression Number of Variables That Can be Skipped: Example and Test
-expressions Example Optimization and Nested Conditional Expressions
-            Example Optimization and Conditional Expressions
-            Base Type Requirements for Conditional Expressions
-            AD Conditional Expressions
-expressions: Conditional Expressions: Example and Test
-extended Checkpointing an Extended ODE Solver: Example and Test
-extending Extending to_string To Another Floating Point Type
-external Download and Install Sacado in Build Directory: External Directory
-         Download and Install Ipopt in Build Directory: External Directory
-         Download and Install Fadbad in Build Directory: External Directory
-         Download and Install Eigen in Build Directory: External Directory
-         Download and Install ColPack in Build Directory: External Directory
-         Download and Install Adolc in Build Directory: External Directory
-extra Define Matrix Multiply as a User Atomic Operation: Extra Call Information
-      Free Memory Currently Available for Quick Use by a Thread: Purpose.Extra Memory
-extraction Download The CppAD Source Code: Windows File Extraction and Testing
- -F -
-ForSparseHes Forward Mode Hessian Sparsity: Example and Test
-ForSparseJac Forward Mode Jacobian Sparsity: Example and Test
-Forward Controlling Taylor Coefficients Memory Allocation
-FunCheck ADFun Check and Re-Tape: Example and Test
-f(x) Create An Abs-normal Representation of a Function: Abs-normal Approximation.Approximating f(x)
-f.forward(Printing AD Values During Forward Mode: f.Forward(0, x)
-f_exp_eps: Second Order Reverse Sweep: Index 2: f_1
-    exp_eps: First Order Reverse Sweep: Index 2: f_1
-    exp_2: Second Order Reverse Mode: Index 2: f_1
-    exp_2: First Order Reverse Mode: Index 2: f_1
-f_exp_eps: Second Order Reverse Sweep: Index 3: f_2
-    exp_eps: First Order Reverse Sweep: Index 3: f_2
-    exp_2: Second Order Reverse Mode: Index 3: f_2
-    exp_2: First Order Reverse Mode: Index 3: f_2
-f_exp_eps: Second Order Reverse Sweep: Index 4: f_3
-    exp_eps: First Order Reverse Sweep: Index 4: f_3
-    exp_2: Second Order Reverse Mode: Index 4: f_3
-    exp_2: First Order Reverse Mode: Index 4: f_3
-f_exp_eps: Second Order Reverse Sweep: Index 5: f_4
-    exp_eps: First Order Reverse Sweep: Index 5: f_4
-    exp_2: Second Order Reverse Mode: Index 5: f_4
-    exp_2: First Order Reverse Mode: Index 5: f_4
-f_exp_eps: Second Order Reverse Sweep: Index 6: f_5
-    exp_eps: First Order Reverse Sweep: Index 6: f_5
-    exp_2: Second Order Reverse Mode: f_5
-    exp_2: First Order Reverse Mode: f_5
-f_exp_eps: Second Order Reverse Sweep: Index 7: f_6
-    exp_eps: First Order Reverse Sweep: Index 7: f_6
-f_exp_eps: Second Order Reverse Sweep: f_7
-    exp_eps: First Order Reverse Sweep: f_7
-f_A 3rd and 4th Order Rosenbrock ODE Solver: Fun.f_t
-f_An Error Controller for Gear's Ode Solvers: Fun.f_x
-    An Arbitrary Order Gear Method: Fun.f_x
-    A 3rd and 4th Order Rosenbrock ODE Solver: Fun.f_x
-fabs Evaluate a Function Defined in Terms of an ODE: Float.fabs
-     An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Scalar.fabs
-     AD Absolute Value Function: Example and Test
-     AD Absolute Value Functions: abs, fabs
-factor LU Factorization of A Square Matrix and Stability Calculation: LU.Factor
-       Sacado Speed: Gradient of Determinant Using Lu Factorization
-       Fadbad Speed: Gradient of Determinant Using Lu Factorization
-       CppAD Speed: Gradient of Determinant Using Lu Factorization
-       Adolc Speed: Gradient of Determinant Using Lu Factorization
-       Double Speed: Determinant Using Lu Factorization
-       Determinant Using Expansion by Lu Factorization
-       Lu Factor and Solve With Recorded Pivoting: Example and Test
-       Lu Factor and Solve with Recorded Pivoting
-       LU Factorization of A Square Matrix: LU.Factor
-       Compute Determinant and Solve Linear Equations: Factor and Invert
-       Compute Determinants and Solve Equations by LU Factorization
-       AD Theory for Cholesky Factorization: Notation.Cholesky Factor
-factored Invert an LU Factored Equation
-factorization LU Factorization of A Square Matrix and Stability Calculation
-              Sacado Speed: Gradient of Determinant Using Lu Factorization
-              Fadbad Speed: Gradient of Determinant Using Lu Factorization
-              CppAD Speed: Gradient of Determinant Using Lu Factorization
-              Adolc Speed: Gradient of Determinant Using Lu Factorization
-              Double Speed: Determinant Using Lu Factorization
-              Determinant Using Expansion by Lu Factorization
-              Speed Testing Gradient of Determinant Using Lu Factorization
-              LU Factorization of A Square Matrix
-              Compute Determinants and Solve Equations by LU Factorization
-              Atomic Eigen Cholesky Factorization Class
-              AD Theory for Cholesky Factorization
-factorization: Determinant Using Lu Factorization: Example and Test
-               Gradient of Determinant Using Lu Factorization: Example and Test
-               Gradient of Determinant Using LU Factorization: Example and Test
-               Atomic Eigen Cholesky Factorization: Example and Test
-fadbad fadbad Speed: sparse_jacobian
-       Fadbad Speed: Sparse Hessian
-       Fadbad Speed: Second Derivative of a Polynomial
-       Fadbad Speed: Ode
-       Fadbad Speed: Matrix Multiplication
-       Fadbad Speed: Gradient of Determinant Using Lu Factorization
-       Fadbad Speed: Gradient of Determinant by Minor Expansion
-       Speed Test Derivatives Using Fadbad
-       Download and Install Fadbad in Build Directory
-       Including the FADBAD Speed Tests
-       Using CMake to Configure CppAD: cppad_profile_flag.Eigen and Fadbad
-     download and install Download and Install Fadbad in Build Directory
-fadbad_dir Autotools Unix Test and Installation: fadbad_dir
-fadbad_prefix Speed Test Derivatives Using Fadbad: fadbad_prefix
-              Including the FADBAD Speed Tests: fadbad_prefix
-false Hessian Sparsity Pattern: Reverse Mode: h.transpose false
-      Jacobian Sparsity Pattern: Reverse Mode: s.transpose false
-      Jacobian Sparsity Pattern: Reverse Mode: r.transpose false
-      Jacobian Sparsity Pattern: Forward Mode: s.transpose false
-      Jacobian Sparsity Pattern: Forward Mode: r.transpose false
-      The Logarithm of One Plus Argument: log1p: CPPAD_USE_CPLUSPLUS_2011.false
-      The Exponential Function Minus One: expm1: CPPAD_USE_CPLUSPLUS_2011.false
-      The Error Function: CPPAD_USE_CPLUSPLUS_2011.false
-      The Inverse Hyperbolic Tangent Function: atanh: CPPAD_USE_CPLUSPLUS_2011.false
-      The Inverse Hyperbolic Sine Function: asinh: CPPAD_USE_CPLUSPLUS_2011.false
-      The Inverse Hyperbolic Cosine Function: acosh: CPPAD_USE_CPLUSPLUS_2011.false
-fast Speed Test for Both Simple and Fast Representations
-     Correctness Check for Both Simple and Fast Representations
-     ODE Fitting Using Fast Representation
-     ODE Fitting Using Fast Representation
-     Fast Multi-Threading Memory Allocator: Example and Test
-     A Fast Multi-Threading Memory Allocator
-faster Checkpointing Functions: Purpose.Faster Recording
-features CppAD Deprecated API Features
-fg Use Ipopt to Solve a Nonlinear Programming Problem: fg_eval.fg
-fg(x) Nonlinear Programming Using the CppAD Interface to Ipopt: fg(x)
-fg_eval Use Ipopt to Solve a Nonlinear Programming Problem: fg_eval
-fg_info Nonlinear Programming Using the CppAD Interface to Ipopt: fg_info
-fg_info.domain_size Nonlinear Programming Using the CppAD Interface to Ipopt: fg_info.fg_info.domain_size
-fg_info.eval_Nonlinear Programming Using the CppAD Interface to Ipopt: fg_info.fg_info.eval_r
-fg_info.index Nonlinear Programming Using the CppAD Interface to Ipopt: fg_info.fg_info.index
-fg_info.number_functions Nonlinear Programming Using the CppAD Interface to Ipopt: fg_info.fg_info.number_functions
-fg_info.number_terms Nonlinear Programming Using the CppAD Interface to Ipopt: fg_info.fg_info.number_terms
-fg_info.range_size Nonlinear Programming Using the CppAD Interface to Ipopt: fg_info.fg_info.range_size
-fg_info.retape Nonlinear Programming Using the CppAD Interface to Ipopt: fg_info.fg_info.retape
-fields CppAD pkg-config Files: Defined Fields
-file Old Matrix Multiply as a User Atomic Operation: Example and Test: Include File
-     Routines That Track Use of New and Delete: file
-     Use Ipopt to Solve a Nonlinear Programming Problem: Include File
-     NearEqual Function: Example and Test: File Name
-     Replacing the CppAD Error Handler: file
-     Multi-Threaded Newton Method Example / Test: Source File
-     Multi-Threading User Atomic Example / Test: Source File
-     Multi-Threading Harmonic Summation Example / Test: Source File
-     Check an ADFun Object For Nan Results: get_check_for_nan.file
-     Example AD<Base> Where Base Constructor Allocates Memory: Include File
-     Download The CppAD Source Code: Windows File Extraction and Testing
-     cppad-20180000.0: A Package for Differentiation of C++ Algorithms: Include File
-file_name Check an ADFun Object For Nan Results: Error Message.file_name
-files CppAD Addons: Library Files
-      CppAD Addons: Include Files
-      Deprecated Include Files
-      Enable Use of Eigen Linear Algebra Package with CppAD: Include Files
-      Determine if Two Values Are Nearly Equal: Include Files
-      Enable use of AD<Base> where Base is Adolc's adouble Type: Include Files
-      CppAD pkg-config Files: CppAD Configuration Files
-      CppAD pkg-config Files
-first Using Multiple Levels of AD: Procedure.First Start AD<double>
-      Run One Speed Test and Print Results: first
-      abs_normal: Evaluate First Order Approximation
-      Any Order Reverse Mode: First Order
-      Second Order Reverse Mode: dw.First Order Partials
-      First Order Reverse Mode: Example and Test
-      First Order Reverse Mode
-      Multiple Order Forward Mode: First Order
-      First Order Forward Mode: Derivative Values
-      First Order Derivative Driver: Example and Test
-      First Order Derivative: Driver Routine
-      First Order Partial Driver: Example and Test
-      First Order Partial Derivative: Driver Routine
-      Jacobian: Driver Routine
-      First and Second Order Derivatives: Easy Drivers
-      exp_eps: Verify Second Order Forward Sweep
-      exp_eps: Verify First Order Reverse Sweep
-      exp_eps: Verify First Order Forward Sweep
-      exp_eps: Second Order Forward Mode: Operation Sequence.First
-      exp_eps: First Order Reverse Sweep
-      exp_eps: First Order Forward Sweep: Operation Sequence.First Order
-      exp_eps: First Order Forward Sweep: First Order Expansion
-      exp_eps: First Order Forward Sweep
-      exp_2: Verify First Order Reverse Sweep
-      exp_2: Verify First Order Forward Sweep
-      exp_2: Second Order Forward Mode: Operation Sequence.First
-      exp_2: First Order Reverse Mode
-      exp_2: First Order Forward Mode: Operation Sequence.First Order
-      exp_2: First Order Forward Mode: First Order Expansion
-      exp_2: First Order Forward Mode
-      Checking the CppAD Examples and Tests: First Level
-fitting ODE Fitting Using Fast Representation
-        ODE Fitting Using Simple Representation
-        ODE Fitting Using Fast Representation
-        ODE Fitting Using Simple Representation
-flag Correctness Test of det_by_minor Routine: flag
-     Memory Leak Detection: flag
-     Check If A Memory Allocation is Efficient for Another Use: flag
-     Is The Current Execution in OpenMP Parallel Mode: flag
-     Is The Current Execution in Parallel Mode: flag
-flags Using CMake to Configure CppAD
-float Machine Epsilon For AD Types: Float
-      Evaluate a Function That Has a Sparse Hessian: Float
-      Evaluate a Function That Has a Sparse Jacobian: Float
-      Evaluate a Function Defined in Terms of an ODE: Float
-      Convert Certain Types to a String: s.Float
-      Convert Certain Types to a String: value.Float
-      Multi-dimensional Romberg Integration: Float
-      One DimensionalRomberg Integration: Float
-      LU Factorization of A Square Matrix: Float
-      Compute Determinant and Solve Linear Equations: Float
-      Enable use of AD<Base> where Base is float
-      Numeric Limits For an AD and Base Types: Float
-floating Extending to_string To Another Floating Point Type
-floatvector Evaluate a Function That Has a Sparse Hessian: FloatVector
-            Evaluate a Function That Has a Sparse Jacobian: FloatVector
-            Multi-dimensional Romberg Integration: FloatVector
-            LU Factorization of A Square Matrix: FloatVector
-            Compute Determinant and Solve Linear Equations: FloatVector
-for_jac_sparse User Defined Atomic AD Functions: for_jac_sparse
-for_sparse_hes Atomic Eigen Matrix Multiply Class: Private.for_sparse_hes
-               Atomic Sparsity with Set Patterns: Example and Test: Test Atomic Function.for_sparse_hes
-               Atomic Sparsity with Set Patterns: Example and Test: for_sparse_hes
-               Atomic Forward Hessian Sparsity: Example and Test: for_sparse_hes
-for_sparse_jac Matrix Multiply as an Atomic Operation: for_sparse_jac
-               User Atomic Matrix Multiply: Example and Test: Use Atomic Function.for_sparse_jac
-               Atomic Eigen Matrix Multiply Class: Private.for_sparse_jac
-               Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function.for_sparse_jac
-               Tan and Tanh as User Atomic Operations: Example and Test: for_sparse_jac
-               Atomic Sparsity with Set Patterns: Example and Test: Test Atomic Function.for_sparse_jac
-               Atomic Sparsity with Set Patterns: Example and Test: for_sparse_jac
-               Reciprocal as an Atomic Operation: Example and Test: Use Atomic Function.for_sparse_jac
-               Reciprocal as an Atomic Operation: Example and Test: for_sparse_jac
-               Atomic Euclidean Norm Squared: Example and Test: Use Atomic Function.for_sparse_jac
-               Atomic Euclidean Norm Squared: Example and Test: for_sparse_jac
-               Atomic Reverse Hessian Sparsity: Example and Test: for_sparse_jac
-               Atomic Forward Hessian Sparsity: Example and Test: for_sparse_jac
-               Atomic Forward Jacobian Sparsity: Example and Test: for_sparse_jac
-form exp_eps: Second Order Reverse Sweep: Mathematical Form
-     exp_eps: Second Order Forward Mode: Mathematical Form
-     exp_eps: First Order Reverse Sweep: Mathematical Form
-     exp_eps: First Order Forward Sweep: Mathematical Form
-     exp_eps: Operation Sequence and Zero Order Forward Sweep: Mathematical Form
-     exp_2: Second Order Reverse Mode: Mathematical Form
-     exp_2: Second Order Forward Mode: Mathematical Form
-     exp_2: First Order Reverse Mode: Mathematical Form
-     exp_2: First Order Forward Mode: Mathematical Form
-     exp_2: Operation Sequence and Zero Order Forward Mode: Mathematical Form
-     Second Order Exponential Approximation: Mathematical Form
-formula The Theory of Forward Mode: Standard Math Functions.Taylor Coefficients Recursion Formula
-forone First Order Partial Derivative: Driver Routine: ForOne Uses Forward
-forsparsejac Sparsity Patterns For a Subset of Variables: Example and Test: ForSparseJac
-fortwo Forward Mode Second Partial Derivative Driver: ForTwo Uses Forward
-forward User Defined Atomic AD Functions: forward
-        User Defined Atomic AD Functions: ty.forward
-        An ODE Inverse Problem Example: Forward Problem
-        Example Simultaneous Solution of Forward and Inverse Problem
-        Comparison Changes During Zero Order Forward Mode
-        The CppAD Wish List: Forward Mode Recomputation
-        Error Function Forward Taylor Polynomial Theory
-        Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory
-        Inverse Cosine and Hyperbolic Cosine Forward Mode Theory
-        Inverse Sine and Hyperbolic Sine Forward Mode Theory
-        Inverse Tangent and Hyperbolic Tangent Forward Mode Theory
-        Trigonometric and Hyperbolic Sine and Cosine Forward Theory
-        Square Root Function Forward Mode Theory
-        Logarithm Function Forward Mode Theory
-        Exponential Function Forward Mode Theory
-        The Theory of Forward Mode
-        Frequently Asked Questions and Answers: Mode: Forward or Reverse
-        Taylor's Ode Solver: An Example and Test: Forward Mode
-        ODE Inverse Problem Definitions: Source Code: Forward Problem
-        Check an ADFun Sequence of Operations: FunCheck Uses Forward
-        Example Optimization and Print Forward Operators
-        Example Optimization and Forward Activity Analysis
-        Compute Sparse Jacobians Using Subgraphs: Uses Forward
-        Sparse Hessian: Uses Forward
-        Computing Sparse Hessians: Uses Forward
-        Sparse Jacobian: Uses Forward
-        Computing Sparse Jacobian Using Forward Mode: Example and Test
-        Computing Sparse Jacobians: Uses Forward
-        Forward Mode Hessian Sparsity: Example and Test
-        Hessian Sparsity Pattern: Forward Mode
-        Forward Mode Hessian Sparsity: Example and Test
-        Forward Mode Hessian Sparsity Patterns
-        Forward Mode Jacobian Sparsity: Example and Test
-        Jacobian Sparsity Pattern: Forward Mode
-        Forward Mode Jacobian Sparsity: Example and Test
-        Forward Mode Jacobian Sparsity Patterns
-        Comparison Changes Between Taping and Zero Order Forward
-        Number Taylor Coefficient Orders Currently Stored: Forward
-        Forward Mode: Example and Test of Multiple Directions
-        Multiple Directions Forward Mode
-        Forward Mode: Example and Test of Multiple Orders
-        Forward Mode: Example and Test
-        Multiple Order Forward Mode
-        Second Order Forward Mode: Derivative Values
-        First Order Forward Mode: Derivative Values
-        Zero Order Forward Mode: Function Values
-        Reverse Mode Second Partial Derivative Driver: RevTwo Uses Forward
-        Forward Mode Second Partial Derivative Driver: ForTwo Uses Forward
-        Forward Mode Second Partial Derivative Driver
-        First Order Derivative: Driver Routine: RevOne Uses Forward
-        First Order Partial Derivative: Driver Routine: ForOne Uses Forward
-        Hessian: Easy Driver: Hessian Uses Forward
-        Jacobian: Driver Routine: Forward or Reverse
-        Stop Recording and Store Operation Sequence: Forward
-        Forward Mode
-        Matrix Multiply as an Atomic Operation: forward
-        Matrix Multiply as an Atomic Operation: Forward Matrix Multiply
-        User Atomic Matrix Multiply: Example and Test: Use Atomic Function.forward
-        Atomic Eigen Cholesky Factorization Class: Private.forward
-        AD Theory for Cholesky Factorization: Forward Mode
-        Atomic Eigen Matrix Inversion Class: Private.forward
-        Atomic Eigen Matrix Inversion Class: Theory.Forward
-        Atomic Eigen Matrix Multiply Class: Private.forward
-        Atomic Eigen Matrix Multiply Class: Theory.Forward
-        Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function.forward
-        Tan and Tanh as User Atomic Operations: Example and Test: forward
-        Atomic Sparsity with Set Patterns: Example and Test: forward
-        Reciprocal as an Atomic Operation: Example and Test: Use Atomic Function.forward
-        Reciprocal as an Atomic Operation: Example and Test: forward
-        Atomic Euclidean Norm Squared: Example and Test: Use Atomic Function.forward
-        Atomic Euclidean Norm Squared: Example and Test: forward
-        Getting Started with Atomic Operations: Example and Test: Use Atomic Function.forward
-        Getting Started with Atomic Operations: Example and Test: forward
-        Atomic Reverse Hessian Sparsity: Example and Test: forward
-        Atomic Forward Hessian Sparsity: Example and Test: forward
-        Atomic Forward Hessian Sparsity: Example and Test
-        Atomic Reverse Jacobian Sparsity: Example and Test: forward
-        Atomic Forward Jacobian Sparsity: Example and Test: forward
-        Atomic Forward Jacobian Sparsity: Example and Test
-        Atomic Reverse: Example and Test: forward
-        Atomic Forward: Example and Test: forward
-        Atomic Forward Hessian Sparsity Patterns
-        Atomic Forward Jacobian Sparsity Patterns
-        Atomic Forward Mode
-        Checkpointing Functions: Purpose.Repeating Forward
-        Print During Zero Order Forward Mode: Example and Test
-        Printing During Forward Mode: Example and Test
-        Printing AD Values During Forward Mode
-        exp_eps: CppAD Forward and Reverse Sweeps
-        exp_eps: Verify Second Order Forward Sweep
-        exp_eps: Verify First Order Forward Sweep
-        exp_eps: Verify Zero Order Forward Sweep
-        exp_eps: Second Order Forward Mode
-        exp_eps: First Order Forward Sweep
-        exp_eps: Operation Sequence and Zero Order Forward Sweep
-        exp_2: CppAD Forward and Reverse Sweeps
-        exp_2: Verify Second Order Forward Sweep
-        exp_2: Verify First Order Forward Sweep
-        exp_2: Verify Zero Order Forward Sweep
-        exp_2: Second Order Forward Mode
-        exp_2: First Order Forward Mode
-        exp_2: Operation Sequence and Zero Order Forward Mode
-        An Introduction by Example to Algorithmic Differentiation: Preface.Forward Mode
-forward: Atomic Forward: Example and Test
-fp Evaluate a Function That Has a Sparse Hessian: fp
-   Evaluate a Function That Has a Sparse Jacobian: fp
-   Evaluate a Function Defined in Terms of an ODE: fp
-free User Defined Atomic AD Functions: Syntax Function.Free Static Memory
-     Free Memory Currently Available for Quick Use by a Thread
-     Adolc Test Utility: Allocate and Free Memory For a Matrix
-     Free All Memory That Was Allocated for Use by thread_alloc
-     Free Memory Currently Available for Quick Use by a Thread
-     Free Static Variables
-free_available Free Memory Currently Available for Quick Use by a Thread
-               Control When Thread Alloc Retains Memory For Future Use: free_available
-               Free Memory Currently Available for Quick Use by a Thread
-freeing Controlling Taylor Coefficients Memory Allocation: c.Freeing Memory
-frequently Frequently Asked Questions and Answers
-from Definition of a Numeric Type: Constructor From Integer
-     Convert an AD Variable to a Parameter
-     Convert From AD to Integer: Example and Test
-     Convert From AD to Integer
-     Convert From AD to its Base Type: Example and Test
-     Convert From an AD Type to its Base Type
-     Conversion and I/O of AD Objects
-fun Jacobian and Hessian of Optimal Values: Fun
-    Computing Jacobian and Hessian of Bender's Reduced Objective: fun
-    An Error Controller for Gear's Ode Solvers: Fun
-    An Arbitrary Order Gear Method: Fun
-    A 3rd and 4th Order Rosenbrock ODE Solver: Fun
-    An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Fun
-    A Multi-Threaded Newton's Method: fun
-    The Unary Standard Math Functions: fun
-fun.dy Computing Jacobian and Hessian of Bender's Reduced Objective: fun.fun.dy
-fun.ell Jacobian and Hessian of Optimal Values: Fun.fun.ell
-fun.Computing Jacobian and Hessian of Bender's Reduced Objective: fun.fun.f
-fun.Computing Jacobian and Hessian of Bender's Reduced Objective: fun.fun.h
-fun.Jacobian and Hessian of Optimal Values: Fun.fun.s
-fun.sy Jacobian and Hessian of Optimal Values: Fun.fun.sy
-fun::ad_vector Jacobian and Hessian of Optimal Values: Fun.Fun::ad_vector
-funcheck Check an ADFun Sequence of Operations: FunCheck Uses Forward
-function Define Matrix Multiply as a User Atomic Operation: Declare mat_mul Function
-         Using AD to Compute Atomic Function Derivatives
-         Using AD to Compute Atomic Function Derivatives
-         User Defined Atomic AD Functions: Example.Tangent Function
-         User Defined Atomic AD Functions: Syntax Function.Use Function
-         User Defined Atomic AD Functions: Syntax Function
-         ODE Fitting Using Fast Representation: Objective Function
-         ODE Fitting Using Simple Representation: Objective Function
-         Glossary: Base Function
-         Glossary: AD Function
-         Error Function Reverse Mode Theory
-         Square Root Function Reverse Mode Theory
-         Logarithm Function Reverse Mode Theory
-         Exponential Function Reverse Mode Theory
-         Error Function Forward Taylor Polynomial Theory
-         Square Root Function Forward Mode Theory
-         Logarithm Function Forward Mode Theory
-         Exponential Function Forward Mode Theory
-         Evaluate a Function That Has a Sparse Hessian: fp.Function
-         Evaluate a Function That Has a Sparse Hessian
-         Evaluate a Function That Has a Sparse Jacobian: fp.Function
-         Evaluate a Function That Has a Sparse Jacobian
-         Evaluate a Function Defined in Terms of an ODE: fp.Function
-         Evaluate a Function Defined in Terms of an ODE
-         Using Multiple Levels of AD: Procedure.Derivatives of Outer Function
-         Using Multiple Levels of AD: Procedure.Outer Function
-         Using Multiple Levels of AD: Procedure.Inner Function
-         Getting Started Using CppAD to Compute Derivatives: Function
-         The Integer Power Function
-         Create An Abs-normal Representation of a Function
-         Computing Sparse Hessian for a Subset of Variables: Function
-         Subgraph Dependency Sparsity Patterns: Atomic Function
-         Multiple Order Forward Mode: Purpose.Function Values
-         Zero Order Forward Mode: Function Values
-         User Atomic Matrix Multiply: Example and Test: Use Atomic Function
-         Atomic Eigen Cholesky Factorization: Example and Test: Use Atomic Function
-         Atomic Eigen Matrix Inverse: Example and Test: Use Atomic Function
-         Atomic Eigen Matrix Multiply: Example and Test: Use Atomic Function
-         Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function
-         Atomic Sparsity with Set Patterns: Example and Test: Test Atomic Function
-         Atomic Sparsity with Set Patterns: Example and Test: function
-         Reciprocal as an Atomic Operation: Example and Test: Use Atomic Function
-         Atomic Euclidean Norm Squared: Example and Test: Use Atomic Function
-         Getting Started with Atomic Operations: Example and Test: Use Atomic Function
-         Atomic Reverse Hessian Sparsity: Example and Test: Use Atomic Function
-         Atomic Reverse Hessian Sparsity: Example and Test: function
-         Atomic Forward Hessian Sparsity: Example and Test: Use Atomic Function
-         Atomic Forward Hessian Sparsity: Example and Test: function
-         Atomic Reverse Jacobian Sparsity: Example and Test: Use Atomic Function
-         Atomic Reverse Jacobian Sparsity: Example and Test: function
-         Atomic Forward Jacobian Sparsity: Example and Test: Use Atomic Function
-         Atomic Forward Jacobian Sparsity: Example and Test: function
-         Atomic Reverse: Example and Test: Use Atomic Function
-         Atomic Reverse: Example and Test: function
-         Atomic Forward: Example and Test: Use Atomic Function
-         Atomic Forward: Example and Test: function
-         Using AD Version of Atomic Function
-         Set Atomic Function Options
-         Atomic Function Constructor
-         User Defined Atomic AD Functions: Examples.Scalar Function
-         The AD Power Function
-         AD Two Argument Inverse Tangent Function
-         The Exponential Function Minus One: expm1
-         The Error Function
-         An Epsilon Accurate Exponential Approximation: Mathematical Function
-function: The CheckSimpleVector Function: Example and Test
-          The CheckNumericType Function: Example and Test
-          NearEqual Function: Example and Test
-          The AD Power Function: Example and Test
-          The AD atan2 Function: Example and Test
-          Sign Function: Example and Test
-          The AD log1p Function: Example and Test
-          The AD exp Function: Example and Test
-          The AD erf Function: Example and Test
-          The AD atanh Function: Example and Test
-          The Inverse Hyperbolic Tangent Function: atanh
-          The AD asinh Function: Example and Test
-          The Inverse Hyperbolic Sine Function: asinh
-          The AD acosh Function: Example and Test
-          The Inverse Hyperbolic Cosine Function: acosh
-          AD Absolute Value Function: Example and Test
-          The AD tanh Function: Example and Test
-          The AD tan Function: Example and Test
-          The AD sqrt Function: Example and Test
-          The AD sinh Function: Example and Test
-          The AD sin Function: Example and Test
-          The AD log10 Function: Example and Test
-          The AD log Function: Example and Test
-          The AD exp Function: Example and Test
-          The AD cosh Function: Example and Test
-          The AD cos Function: Example and Test
-          The AD atan Function: Example and Test
-          The AD asin Function: Example and Test
-          The AD acos Function: Example and Test
-          The Hyperbolic Tangent Function: tanh
-          The Tangent Function: tan
-          The Square Root Function: sqrt
-          The Hyperbolic Sine Function: sinh
-          The Sine Function: sin
-          The Base 10 Logarithm Function: log10
-          The Exponential Function: log
-          The Exponential Function: exp
-          The Hyperbolic Cosine Function: cosh
-          The Cosine Function: cos
-          Inverse Tangent Function: atan
-          Inverse Sine Function: asin
-          Inverse Sine Function: acos
-functions Define Matrix Multiply as a User Atomic Operation: CppAD User Atomic Callback Functions
-          User Defined Atomic AD Functions
-          ADFun Object Deprecated Member Functions
-          CppAD Deprecated API Features: Atomic Functions
-          The Theory of Reverse Mode: Standard Math Functions
-          The Theory of Forward Mode: Standard Math Functions
-          Speed Test of Functions in Double
-          Running the Speed Test Program: Link Functions
-          Abs-normal Representation of Non-Smooth Functions
-          Optimize an ADFun Object Tape: Atomic Functions
-          Base Type Requirements for Standard Math Functions
-          Base Type Requirements for Identically Equal Comparisons: Identical.Identical Functions
-          Required Base Class Member Functions
-          AD Boolean Functions
-          Bool Valued Operations and Functions with AD Arguments
-          User Defined Atomic AD Functions: Virtual Functions
-          User Defined Atomic AD Functions
-          Checkpointing Functions
-          Atomic AD Functions
-          Discrete AD Functions
-          The Binary Math Functions
-          The Unary Standard Math Functions
-          AD Valued Operations and Functions
-functions: AD Parameter and Variable Functions: Example and Test
-           AD Boolean Functions: Example and Test
-           AD Absolute Value Functions: abs, fabs
-future Control When Thread Alloc Retains Memory For Future Use
-       Free Static Variables: Future Use
- -G -
-Gear An Error Controller for Gear's Ode Solvers
-g Computing Jacobian and Hessian of Bender's Reduced Objective: g
-  Nonlinear Programming Using the CppAD Interface to Ipopt: solution.g
-  Check Gradient of Determinant of 3 by 3 matrix: g
-  Use Ipopt to Solve a Nonlinear Programming Problem: solution.g
-  Check an ADFun Sequence of Operations: g
-  Non-Smooth Optimization Using Abs-normal Quadratic Approximations: g
-  abs_normal: Minimize a Linear Abs-normal Approximation: g
-  abs_normal: Solve a Quadratic Program With Box Constraints: G
-  abs_normal: Solve a Quadratic Program With Box Constraints: g
-  Solve a Quadratic Program Using Interior Point Method: G
-  Solve a Quadratic Program Using Interior Point Method: g
-  Non-Smooth Optimization Using Abs-normal Linear Approximations: g
-  abs_normal: Minimize a Linear Abs-normal Approximation: g
-  abs_normal: Evaluate First Order Approximation: g
-  Create An Abs-normal Representation of a Function: g
-  Atomic Reverse Mode: G, H
-g_hat abs_normal: Minimize a Linear Abs-normal Approximation: g_hat
-      abs_normal: Minimize a Linear Abs-normal Approximation: g_hat
-      abs_normal: Evaluate First Order Approximation: g_hat
-g_jac abs_normal: Minimize a Linear Abs-normal Approximation: g_jac
-      abs_normal: Minimize a Linear Abs-normal Approximation: g_jac
-      abs_normal: Evaluate First Order Approximation: g_jac
-g_Nonlinear Programming Using the CppAD Interface to Ipopt: g_l
-g_tilde abs_normal: Evaluate First Order Approximation: g_tilde
-g_Nonlinear Programming Using the CppAD Interface to Ipopt: g_u
-gear An Arbitrary Order Gear Method
-gear'An Error Controller for Gear's Ode Solvers
-       An Arbitrary Order Gear Method: Gear's Method
-general zdouble: An AD Base Type With Absolute Zero: Motivation.General
-        General Examples
-        Some General Purpose Utilities: General Numerical Routines
-        Some General Purpose Utilities
-        Reverse Mode General Case (Checkpointing): Example and Test
-        User Defined Atomic AD Functions: General Case
-generator Using CMake to Configure CppAD: generator
-get Get At Least A Specified Amount of Memory
-    Get the Current OpenMP Thread Number
-    Set and Get Maximum Number of Threads for omp_alloc Allocator
-    Get At Least A Specified Amount of Memory
-    Get the Current Thread Number
-    Get Number of Threads
-    Including the Sacado Speed Tests
-    Including the cppad_ipopt Library and Tests
-    Including the FADBAD Speed Tests
-    Including the Eigen Examples and Tests
-    Including the ColPack Sparsity Calculations
-    Including the ADOL-C Examples and Tests
-get_adolc Including the ADOL-C Examples and Tests: get_adolc
-get_check_for_nan Check an ADFun Object For Nan Results: get_check_for_nan
-get_colpack Including the ColPack Sparsity Calculations: get_colpack
-get_eigen Including the Eigen Examples and Tests: get_eigen
-get_fadbad Including the FADBAD Speed Tests: get_fadbad
-get_ipopt Including the cppad_ipopt Library and Tests: get_ipopt
-get_max_num_threads Set and Get Maximum Number of Threads for omp_alloc Allocator: get_max_num_threads
-get_sacado Including the Sacado Speed Tests: get_sacado
-get_started Examples: get_started
-            Use Ipopt to Solve a Nonlinear Programming Problem: Example.get_started
-get_thread_num Get the Current OpenMP Thread Number
-getting Getting Started Using CppAD to Compute Derivatives
-        abs_normal Getting Started: Example and Test
-        Getting Started with Atomic Operations: Example and Test
-        User Defined Atomic AD Functions: Examples.Getting Started
-git Download The CppAD Source Code: Source Code Control.Git
-github Download The CppAD Source Code: Compressed Archives.Github
-gl Use Ipopt to Solve a Nonlinear Programming Problem: gl
-global Running the Speed Test Program: Global Options
-gradient Sacado Speed: Gradient of Ode Solution
-         Sacado Speed: Gradient of Determinant Using Lu Factorization
-         Sacado Speed: Gradient of Determinant by Minor Expansion
-         Fadbad Speed: Gradient of Determinant Using Lu Factorization
-         Fadbad Speed: Gradient of Determinant by Minor Expansion
-         CppAD Speed: Gradient of Ode Solution
-         CppAD Speed: Gradient of Determinant Using Lu Factorization
-         CppAD Speed: Gradient of Determinant by Minor Expansion
-         Adolc Speed: Gradient of Determinant Using Lu Factorization
-         Adolc Speed: Gradient of Determinant by Minor Expansion
-         Evaluate a Function Defined in Terms of an ODE: fp.Gradient
-         Check Gradient of Determinant of 3 by 3 matrix
-         Speed Testing Gradient of Determinant by Minor Expansion: gradient
-         Speed Testing Gradient of Determinant by Minor Expansion
-         Speed Testing Gradient of Determinant Using Lu Factorization: gradient
-         Speed Testing Gradient of Determinant Using Lu Factorization
-         Gradient of Determinant Using Lu Factorization: Example and Test
-         Gradient of Determinant Using Expansion by Minors: Example and Test
-         Gradient of Determinant Using LU Factorization: Example and Test
-         Gradient of Determinant Using Expansion by Minors: Example and Test
-         Differentiate Conjugate Gradient Algorithm: Example and Test
-grid An ODE Inverse Problem Example: Trapezoidal Approximation.Trapezoidal Time Grid
-group Object that Runs a Group of Tests: group
-      Object that Runs a Group of Tests
-group_max Computing Sparse Jacobians: group_max
-gu Use Ipopt to Solve a Nonlinear Programming Problem: gu
-guidelines The CppAD Wish List: Software Guidelines
-gx Computing Jacobian and Hessian of Bender's Reduced Objective: gx
-gxx Computing Jacobian and Hessian of Bender's Reduced Objective: gxx
- -H -
-Hessian Hessian: Example and Test
-h Hessian Sparsity Pattern: Forward Mode: h
-  Hessian Sparsity Pattern: Reverse Mode: h
-  Atomic Forward Hessian Sparsity Patterns: Implementation.h
-  Atomic Reverse Mode: G, H
-handler CppAD Assertions During Execution: Error Handler
-        Replacing The CppAD Error Handler: Example and Test
-        Replacing the CppAD Error Handler: handler
-        Replacing the CppAD Error Handler
-        Some General Purpose Utilities: Miscellaneous.Error Handler
-handler: Replacing The CppAD Error Handler: Example and Test
-harmonic Multi-Threading Harmonic Summation Example / Test
-         Run Multi-Threading Examples and Speed Tests: harmonic
-has Evaluate a Function That Has a Sparse Hessian
-    Evaluate a Function That Has a Sparse Jacobian
-hash Base Type Requirements for Hash Coding Values
-hash_code Enable use of AD<Base> where Base is Adolc's adouble Type: hash_code
-          Example AD<Base> Where Base Constructor Allocates Memory: hash_code
-hasnan Obtain Nan or Determine if a Value is Nan: hasnan
-head Routines That Track Use of New and Delete: head newptr
-here CppAD API Preprocessor Symbols: Documented Here
-hes Jacobian and Hessian of Optimal Values: hes
-    Sparse Hessian: hes
-    Hessian: Easy Driver: hes
-hes2jac Running the Speed Test Program: Global Options.hes2jac
-hessian Jacobian and Hessian of Optimal Values
-        Computing Jacobian and Hessian of Bender's Reduced Objective
-        Sacado Speed: Sparse Hessian
-        Fadbad Speed: Sparse Hessian
-        CppAD Speed: Sparse Hessian
-        Adolc Speed: Sparse Hessian
-        Double Speed: Sparse Hessian
-        Evaluate a Function That Has a Sparse Hessian: fp.Hessian
-        Evaluate a Function That Has a Sparse Hessian
-        Speed Testing Sparse Hessian: hessian
-        Speed Testing Sparse Hessian
-        abs_normal: Minimize a Linear Abs-normal Approximation: hessian
-        Sparse Hessian Using Subgraphs and Jacobian: Example and Test
-        Computing Sparse Hessian for a Subset of Variables
-        Sparse Hessian: Subset Hessian
-        Sparse Hessian
-        Computing Sparse Hessians: Subset Hessian
-        Forward Mode Hessian Sparsity: Example and Test
-        Hessian Sparsity Pattern: Forward Mode
-        Forward Mode Hessian Sparsity: Example and Test
-        Forward Mode Hessian Sparsity Patterns: Sparsity for Entire Hessian
-        Forward Mode Hessian Sparsity Patterns
-        Reverse Mode Hessian Sparsity: Example and Test
-        Hessian Sparsity Pattern: Reverse Mode
-        Reverse Mode Hessian Sparsity: Example and Test
-        Reverse Mode Hessian Sparsity Patterns: Sparsity for Entire Hessian
-        Reverse Mode Hessian Sparsity Patterns
-        Hessian Times Direction: Example and Test
-        Second Order Reverse Mode: Hessian Times Direction
-        Hessian of Lagrangian and ADFun Default Constructor: Example and Test
-        Hessian: Easy Driver: Hessian Uses Forward
-        Atomic Reverse Hessian Sparsity: Example and Test
-        Atomic Forward Hessian Sparsity: Example and Test
-        Atomic Reverse Hessian Sparsity Patterns
-        Atomic Forward Hessian Sparsity Patterns
-        User Defined Atomic AD Functions: Examples.Hessian Sparsity Patterns
-        ColPack: Sparse Hessian Example and Test
-        ColPack: Sparse Hessian Example and Test
-hessian: Subset of a Sparse Hessian: Example and Test
-         Sparse Hessian: Example and Test
-         Computing Sparse Hessian: Example and Test
-         Hessian: Example and Test
-         Hessian: Easy Driver
-hessians Computing Sparse Hessians
-hold Control When Thread Alloc Retains Memory For Future Use
-hold_memory Using CppAD in a Multi-Threading Environment: hold_memory
-hyperbolic Tangent and Hyperbolic Tangent Reverse Mode Theory
-           Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
-           Inverse Sine and Hyperbolic Sine Reverse Mode Theory
-           Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory
-           Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
-           Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory
-           Inverse Cosine and Hyperbolic Cosine Forward Mode Theory
-           Inverse Sine and Hyperbolic Sine Forward Mode Theory
-           Inverse Tangent and Hyperbolic Tangent Forward Mode Theory
-           Trigonometric and Hyperbolic Sine and Cosine Forward Theory
-           The Inverse Hyperbolic Tangent Function: atanh
-           The Inverse Hyperbolic Sine Function: asinh
-           The Inverse Hyperbolic Cosine Function: acosh
-           The Hyperbolic Tangent Function: tanh
-           The Hyperbolic Sine Function: sinh
-           The Hyperbolic Cosine Function: cosh
- -I -
-Integer Convert From AD to Integer: Example and Test
-i(k
-     0) ODE Fitting Using Fast Representation: Trapezoidal Approximation.Range Indices I(k,0)
-     0) ODE Fitting Using Fast Representation: Initial Condition.Range Indices I(k,0)
-     0) ODE Fitting Using Fast Representation: Objective Function.Range Indices I(k,0)
-i/Conversion and I/O of AD Objects
-id User Defined Atomic AD Functions: id
-identical Enable use of AD<Base> where Base is std::complex<double>: Identical
-          Enable use of AD<Base> where Base is double: Identical
-          Enable use of AD<Base> where Base is float: Identical
-          Enable use of AD<Base> where Base is Adolc's adouble Type: Identical
-          Example AD<Base> Where Base Constructor Allocates Memory: Identical
-          Base Type Requirements for Identically Equal Comparisons: Identical.Identical Functions
-          Base Type Requirements for Identically Equal Comparisons: Identical
-identically Base Type Requirements for Identically Equal Comparisons
-            Check if Two Value are Identically Equal
-identicalpar Base Type Requirements for Identically Equal Comparisons: Identical.IdenticalPar
-identity An Important Reverse Mode Identity
-if Check If A Memory Allocation is Efficient for Another Use
-   Obtain Nan or Determine if a Value is Nan
-   Determine if Two Values Are Nearly Equal
-   Check if Two Value are Identically Equal
-if_false AD Conditional Expressions: if_false
-if_true AD Conditional Expressions: if_true
-implementation User Defined Atomic AD Functions: Partial Implementation
-               Sacado Speed: Second Derivative of a Polynomial: Implementation
-               Sacado Speed: Gradient of Ode Solution: Implementation
-               Sacado Speed: Matrix Multiplication: Implementation
-               Sacado Speed: Gradient of Determinant Using Lu Factorization: Implementation
-               Sacado Speed: Gradient of Determinant by Minor Expansion: Implementation
-               Fadbad Speed: Second Derivative of a Polynomial: Implementation
-               Fadbad Speed: Ode: Implementation
-               Fadbad Speed: Matrix Multiplication: Implementation
-               Fadbad Speed: Gradient of Determinant Using Lu Factorization: Implementation
-               Fadbad Speed: Gradient of Determinant by Minor Expansion: Implementation
-               CppAD Speed: Sparse Jacobian: Implementation
-               CppAD Speed: Sparse Hessian: Implementation
-               CppAD Speed: Second Derivative of a Polynomial: Implementation
-               CppAD Speed: Gradient of Ode Solution: Implementation
-               CppAD Speed, Matrix Multiplication: Implementation
-               CppAD Speed: Gradient of Determinant Using Lu Factorization: Implementation
-               CppAD Speed: Gradient of Determinant by Minor Expansion: Implementation
-               adolc Speed: Sparse Jacobian: Implementation
-               Adolc Speed: Sparse Hessian: Implementation
-               Adolc Speed: Second Derivative of a Polynomial: Implementation
-               Adolc Speed: Ode: Implementation
-               Adolc Speed: Matrix Multiplication: Implementation
-               Adolc Speed: Gradient of Determinant Using Lu Factorization: Implementation
-               Adolc Speed: Gradient of Determinant by Minor Expansion: Implementation
-               Double Speed: Sparse Jacobian: Implementation
-               Double Speed: Sparse Hessian: Implementation
-               Double Speed: Evaluate a Polynomial: Implementation
-               Double Speed: Ode Solution: Implementation
-               CppAD Speed: Matrix Multiplication (Double Version): Implementation
-               Double Speed: Determinant Using Lu Factorization: Implementation
-               Double Speed: Determinant by Minor Expansion: Implementation
-               Pthread Implementation of a Team of AD Threads
-               Boost Thread Implementation of a Team of AD Threads
-               OpenMP Implementation of a Team of AD Threads
-               Specifications for A Team of AD Threads: Speed Test of Implementation
-               Specifications for A Team of AD Threads: Example Implementation
-               Multi-Threaded Implementation of Summation of 1/i
-               Atomic Reverse Hessian Sparsity Patterns: Implementation
-               Atomic Forward Hessian Sparsity Patterns: Implementation
-               Atomic Reverse Jacobian Sparsity Patterns: Implementation
-               Atomic Forward Jacobian Sparsity Patterns: Implementation
-               Atomic Reverse Mode: Implementation
-               Atomic Forward Mode: Implementation
-               Atomic Function Constructor: atomic_user.Implementation
-               exp_eps: Implementation
-               An Epsilon Accurate Exponential Approximation: Implementation
-               exp_2: Implementation
-               Second Order Exponential Approximation: Implementation
-implementations Run Multi-Threading Examples and Speed Tests: Team Implementations
-implicit Suppress Suspect Implicit Conversion Warnings
-         AD Constructors: x.implicit
-         Using CMake to Configure CppAD
-important An Important Reverse Mode Identity
-in_parallel Is The Current Execution in OpenMP Parallel Mode
-            Setup thread_alloc For Use in Multi-Threading Environment: in_parallel
-inactive Glossary: Tape.Inactive
-inc Run One Speed Test and Print Results: inc
-include CppAD Addons: Include Files
-        LU Factorization of A Square Matrix and Stability Calculation: Include
-        Old Matrix Multiply as a User Atomic Operation: Example and Test: Include File
-        A Quick OpenMP Memory Allocator Used by CppAD: Include
-        Routines That Track Use of New and Delete: Include
-        Deprecated Include Files
-        Enable Use of Eigen Linear Algebra Package with CppAD: Include Files
-        Use Ipopt to Solve a Nonlinear Programming Problem: Include File
-        A Fast Multi-Threading Memory Allocator: Include
-        The CppAD::vector Template Class: Include
-        An Error Controller for Gear's Ode Solvers: Include
-        An Arbitrary Order Gear Method: Include
-        An Error Controller for ODE Solvers: Include
-        A 3rd and 4th Order Rosenbrock ODE Solver: Include
-        An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Include
-        Multi-dimensional Romberg Integration: Include
-        One DimensionalRomberg Integration: Include
-        Invert an LU Factored Equation: Include
-        LU Factorization of A Square Matrix: Include
-        Compute Determinant and Solve Linear Equations: Include
-        Evaluate a Polynomial or its Derivative: Include
-        The Integer Power Function: Include
-        Obtain Nan or Determine if a Value is Nan: Include
-        Check Simple Vector Concept: Include
-        Check NumericType Class Concept: Include
-        Determine Amount of Time to Execute a Test: Include
-        Run One Speed Test and Print Results: Include
-        Run One Speed Test and Return Results: Include
-        Determine if Two Values Are Nearly Equal: Include Files
-        Enable use of AD<Base> where Base is std::complex<double>: Include Order
-        Enable use of AD<Base> where Base is Adolc's adouble Type: Include Files
-        Example AD<Base> Where Base Constructor Allocates Memory: Include File
-        AD<Base> Requirements for a CppAD Base Type: Include Order
-        An Epsilon Accurate Exponential Approximation: include
-        Second Order Exponential Approximation: include
-        Using CMake to Configure CppAD
-        cppad-20180000.0: A Package for Differentiation of C++ Algorithms: Include File
-including Including the Sacado Speed Tests
-          Including the cppad_ipopt Library and Tests
-          Including the FADBAD Speed Tests
-          Including the Eigen Examples and Tests
-          Including the ColPack Sparsity Calculations
-          Including the ADOL-C Examples and Tests
-inclusion Simulate a [0,1] Uniform Random Variate: Inclusion
-          Evaluate a Function That Has a Sparse Hessian: Inclusion
-          Evaluate a Function That Has a Sparse Jacobian: Inclusion
-          Evaluate a Function Defined in Terms of an ODE: Inclusion
-          Sum Elements of a Matrix Times Itself: Inclusion
-          Check Gradient of Determinant of 3 by 3 matrix: Inclusion
-          Check Determinant of 3 by 3 matrix: Inclusion
-          Determinant Using Expansion by Minors: Inclusion
-          Determinant of a Minor: Inclusion
-          Determinant Using Expansion by Lu Factorization: Inclusion
-ind Returns Indices that Sort a Vector: ind
-independent OpenMP Parallel Setup: Independent
-            Glossary: Tape.Independent Variable
-            Glossary: Operation.Independent
-            Frequently Asked Questions and Answers: Independent Variables
-            Frequently Asked Questions and Answers: Assignment and Independent
-            Independent and ADFun Constructor: Example and Test
-            Declare Independent Variables and Start Recording
-index Nonlinear Programming Using the CppAD Interface to Ipopt: fg(x).Index Vector
-      Glossary: Sparsity Pattern.Row and Column Index Vectors
-      Row and Column Index Sparsity Patterns
-      Index Sort: Example and Test
-      Check an ADFun Object For Nan Results: Error Message.index
-      AD Vectors that Record Index Operations: Example and Test
-      AD Vectors that Record Index Operations
-      Matrix Multiply as an Atomic Operation: Result Element Index
-      Matrix Multiply as an Atomic Operation: Right Operand Element Index
-      Matrix Multiply as an Atomic Operation: Left Operand Element Index
-      Taping Array Index Operation: Example and Test
-      exp_eps: Second Order Reverse Sweep: Index 2: f_1
-      exp_eps: Second Order Reverse Sweep: Index 3: f_2
-      exp_eps: Second Order Reverse Sweep: Index 4: f_3
-      exp_eps: Second Order Reverse Sweep: Index 5: f_4
-      exp_eps: Second Order Reverse Sweep: Index 6: f_5
-      exp_eps: Second Order Reverse Sweep: Index 7: f_6
-      exp_eps: Second Order Forward Mode: Operation Sequence.Index
-      exp_eps: First Order Reverse Sweep: Index 2: f_1
-      exp_eps: First Order Reverse Sweep: Index 3: f_2
-      exp_eps: First Order Reverse Sweep: Index 4: f_3
-      exp_eps: First Order Reverse Sweep: Index 5: f_4
-      exp_eps: First Order Reverse Sweep: Index 6: f_5
-      exp_eps: First Order Reverse Sweep: Index 7: f_6
-      exp_eps: First Order Forward Sweep: Operation Sequence.Index
-      exp_eps: Operation Sequence and Zero Order Forward Sweep: Operation Sequence.Index
-      exp_2: Second Order Reverse Mode: Index 2: f_1
-      exp_2: Second Order Reverse Mode: Index 3: f_2
-      exp_2: Second Order Reverse Mode: Index 4: f_3
-      exp_2: Second Order Reverse Mode: Index 5: f_4
-      exp_2: Second Order Forward Mode: Operation Sequence.Index
-      exp_2: First Order Reverse Mode: Index 2: f_1
-      exp_2: First Order Reverse Mode: Index 3: f_2
-      exp_2: First Order Reverse Mode: Index 4: f_3
-      exp_2: First Order Reverse Mode: Index 5: f_4
-      exp_2: First Order Forward Mode: Operation Sequence.Index
-      exp_2: Operation Sequence and Zero Order Forward Mode: Operation Sequence.Index
-index_sort Index Sort: Example and Test
-           Returns Indices that Sort a Vector
-indexing Define Matrix Multiply as a User Atomic Operation: Matrix Indexing
-         AD Vectors that Record Index Operations: AD Indexing
-         AD Vectors that Record Index Operations: size_t Indexing
-indices ODE Fitting Using Fast Representation: Trapezoidal Approximation.Domain Indices J(k,0)
-        ODE Fitting Using Fast Representation: Trapezoidal Approximation.Range Indices I(k,0)
-        ODE Fitting Using Fast Representation: Initial Condition.Domain Indices J(k,0)
-        ODE Fitting Using Fast Representation: Initial Condition.Range Indices I(k,0)
-        ODE Fitting Using Fast Representation: Objective Function.Domain Indices J(k,0)
-        ODE Fitting Using Fast Representation: Objective Function.Range Indices I(k,0)
-        Returns Indices that Sort a Vector
-        Some General Purpose Utilities: Miscellaneous.Sorting Indices
-indices: Preferred Sparsity Patterns: Row and Column Indices: Example and Test
-info Replacing the CppAD Error Handler: info
-information Define Matrix Multiply as a User Atomic Operation: Extra Call Information
-            Multi-Threaded User Atomic Common Information
-initial ODE Fitting Using Fast Representation: Initial Condition
-        ODE Fitting Using Simple Representation: Initial Condition Constraint
-initialization Using CppAD in a Multi-Threading Environment: Initialization
-initialize Setup thread_alloc For Use in Multi-Threading Environment
-injection Nonlinear Programming Using the CppAD Interface to Ipopt: fg(x).Injection
-inline Base Type Requirements for Hash Coding Values: inline
-inner Using Multiple Levels of AD: Procedure.Inner Function
-input Returns Indices that Sort a Vector: ind.Input
-      AD Output Operator: Example and Test
-      AD Output Stream Operator
-inside Using AD to Compute Atomic Function Derivatives
-       Using AD to Compute Atomic Function Derivatives
-install Autotools Unix Test and Installation: make install
-        Download and Install Sacado in Build Directory
-        Download and Install Ipopt in Build Directory
-        Download and Install Fadbad in Build Directory
-        Download and Install Eigen in Build Directory
-        Download and Install ColPack in Build Directory
-        Download and Install Adolc in Build Directory
-        Using CMake to Configure CppAD
-        Download The CppAD Source Code: Install Instructions
-        CppAD Download, Test, and Install Instructions
-     fadbad Download and Install Fadbad in Build Directory
-     ipopt Download and Install Ipopt in Build Directory
-     sacado Download and Install Sacado in Build Directory
-installation Autotools Unix Test and Installation
-             CppAD Download, Test, and Install Instructions: Instructions.Step 4: Installation
-instructions Download The CppAD Source Code: Install Instructions
-             CppAD Download, Test, and Install Instructions: Instructions
-             CppAD Download, Test, and Install Instructions
-int The Pow Integer Exponent: Example and Test
-    Definition of a Numeric Type
-integer Use Ipopt to Solve a Nonlinear Programming Problem: options.Integer
-        Convert Certain Types to a String: s.Integer
-        Convert Certain Types to a String: value.Integer
-        The Pow Integer Exponent: Example and Test
-        The Integer Power Function
-        Definition of a Numeric Type: Constructor From Integer
-        Enable use of AD<Base> where Base is std::complex<double>: Integer
-        Enable use of AD<Base> where Base is double: Integer
-        Enable use of AD<Base> where Base is float: Integer
-        Enable use of AD<Base> where Base is Adolc's adouble Type: Integer
-        Example AD<Base> Where Base Constructor Allocates Memory: Integer
-        AD<Base> Requirements for a CppAD Base Type: Integer
-        Convert From AD to Integer
-integer: Convert From AD to Integer: Example and Test
-integrate Multi-dimensional Romberg Integration
-          One DimensionalRomberg Integration
-integration Multi-dimensional Romberg Integration
-            One DimensionalRomberg Integration
-integration: One Dimensional Romberg Integration: Example and Test
-             One Dimensional Romberg Integration: Example and Test
-interface Nonlinear Programming Using the CppAD Interface to Ipopt
-          The CppAD Wish List: Iterator Interface
-          Interfacing to C: Example and Test
-          Creating Your Own Interface to an ADFun Object
-interfacing Interfacing to C: Example and Test
-interior Solve a Quadratic Program Using Interior Point Method
-internal Using CMake to Configure CppAD
-internal_bool Forward Mode Hessian Sparsity Patterns: internal_bool
-              Reverse Mode Hessian Sparsity Patterns: internal_bool
-              Reverse Mode Jacobian Sparsity Patterns: internal_bool
-              Forward Mode Jacobian Sparsity Patterns: internal_bool
-interpolate Interpolation With Retaping: Example and Test
-            Interpolation With Out Retaping: Example and Test
-interpolation Interpolation With Retaping: Example and Test
-              Interpolation With Out Retaping: Example and Test
-interpreter Example Differentiating a Stack Machine Interpreter
-introduction Choosing The Vector Testing Template Class: Introduction
-             Changes and Additions to CppAD During 2003: Introduction
-             Changes and Additions to CppAD During 2004: Introduction
-             Changes and Additions to CppAD During 2006: Introduction
-             Changes and Additions to CppAD During 2007: Introduction
-             Changes and Additions to CppAD During 2008: Introduction
-             Changes and Additions to CppAD During 2009: Introduction
-             Changes and Additions to CppAD During 2010: Introduction
-             Changes and Additions to CppAD During 2011: Introduction
-             CppAD Changes and Additions During 2012: Introduction
-             CppAD Changes and Additions During 2013: Introduction
-             CppAD Changes and Additions During 2014: Introduction
-             CppAD Changes and Additions During 2015: Introduction
-             Changes and Additions to CppAD During 2016: Introduction
-             Changes and Additions to CppAD: Introduction
-             Examples: Introduction
-             Correctness Tests For Exponential Approximation in Introduction
-             An Introduction by Example to Algorithmic Differentiation
-             cppad-20180000.0: A Package for Differentiation of C++ Algorithms: Introduction
-inuse Memory Leak Detection: inuse
-      Amount of Memory a Thread is Currently Using
-      Amount of Memory a Thread is Currently Using
-invalid Enable use of AD<Base> where Base is std::complex<double>: Invalid Unary Math
-inverse ODE Inverse Problem Definitions: Source Code
-        An ODE Inverse Problem Example: Inverse Problem
-        An ODE Inverse Problem Example
-        Example Simultaneous Solution of Forward and Inverse Problem
-        Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
-        Inverse Sine and Hyperbolic Sine Reverse Mode Theory
-        Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory
-        Inverse Cosine and Hyperbolic Cosine Forward Mode Theory
-        Inverse Sine and Hyperbolic Sine Forward Mode Theory
-        Inverse Tangent and Hyperbolic Tangent Forward Mode Theory
-        Frequently Asked Questions and Answers: Matrix Inverse
-        ODE Inverse Problem Definitions: Source Code: Inverse Problem
-        ODE Inverse Problem Definitions: Source Code
-        AD Two Argument Inverse Tangent Function
-        The Inverse Hyperbolic Tangent Function: atanh
-        The Inverse Hyperbolic Sine Function: asinh
-        The Inverse Hyperbolic Cosine Function: acosh
-        Inverse Tangent Function: atan
-        Inverse Sine Function: asin
-        Inverse Sine Function: acos
-inverse: Atomic Eigen Matrix Inverse: Example and Test
-inversion Atomic Eigen Matrix Inversion Class
-invert Invert an LU Factored Equation
-       Compute Determinant and Solve Linear Equations: Factor and Invert
-ip LU Factorization of A Square Matrix and Stability Calculation: ip
-   Invert an LU Factored Equation: ip
-   LU Factorization of A Square Matrix: ip
-ipopt Driver for Running the Ipopt ODE Example
-      Nonlinear Programming Using CppAD and Ipopt: Example and Test
-      Nonlinear Programming Using the CppAD Interface to Ipopt
-      Nonlinear Programming Using CppAD and Ipopt: Example and Test
-      Use Ipopt to Solve a Nonlinear Programming Problem
-      Download and Install Ipopt in Build Directory
-      Including the cppad_ipopt Library and Tests
-     download and install Download and Install Ipopt in Build Directory
-ipopt: Nonlinear Programming Using CppAD and Ipopt: Example and Test
-       Nonlinear Programming Using CppAD and Ipopt: Example and Test
-ipopt_cppad_nlp Changes and Additions to CppAD During 2008
-ipopt_dir Autotools Unix Test and Installation: ipopt_dir
-ipopt_library_paths Nonlinear Programming Using the CppAD Interface to Ipopt: ipopt_library_paths
-ipopt_prefix Including the cppad_ipopt Library and Tests: ipopt_prefix
-ipopt_solve Nonlinear Programming Retaping: Example and Test
-is Check If A Memory Allocation is Efficient for Another Use
-   Amount of Memory a Thread is Currently Using
-   Is The Current Execution in OpenMP Parallel Mode
-   Amount of Memory a Thread is Currently Using
-   Is The Current Execution in Parallel Mode
-   Obtain Nan or Determine if a Value is Nan
-   Enable use of AD<Base> where Base is std::complex<double>
-   Enable use of AD<Base> where Base is double
-   Enable use of AD<Base> where Base is float
-   Enable use of AD<Base> where Base is Adolc's adouble Type
-   Is an AD Object a Parameter or Variable
-   AD Output Stream Operator: is
-isnan Obtain Nan or Determine if a Value is Nan: isnan
-      Enable use of AD<Base> where Base is std::complex<double>: isnan
-      Base Type Requirements for Standard Math Functions: isnan
-iteration An ODE Inverse Problem Example: Black Box Method.Two levels of Iteration
-          abs_normal: Minimize a Linear Abs-normal Approximation: Method.Iteration
-          abs_normal: Minimize a Linear Abs-normal Approximation: Method.Iteration
-iterator The CppAD Wish List: Iterator Interface
-its Deallocate An Array and Call Destructor for its Elements
-    Allocate An Array and Call Default Constructor for its Elements
-    Evaluate a Polynomial or its Derivative
-    Convert From AD to its Base Type: Example and Test
-    Convert From an AD Type to its Base Type
-itself Sum Elements of a Matrix Times Itself
- -J -
-Jacobian Jacobian: Example and Test
-         Jacobian: Driver Routine
-j Reverse Mode Second Partial Derivative Driver: j
-  Forward Mode Second Partial Derivative Driver: j
-  First Order Partial Derivative: Driver Routine: j
-j(k
-     0) ODE Fitting Using Fast Representation: Trapezoidal Approximation.Domain Indices J(k,0)
-     0) ODE Fitting Using Fast Representation: Initial Condition.Domain Indices J(k,0)
-     0) ODE Fitting Using Fast Representation: Objective Function.Domain Indices J(k,0)
-jac Jacobian and Hessian of Optimal Values: jac
-    Sparse Jacobian: jac
-    Jacobian: Driver Routine: jac
-jacobian Jacobian and Hessian of Optimal Values
-         Computing Jacobian and Hessian of Bender's Reduced Objective
-         CppAD Speed: Sparse Jacobian
-         adolc Speed: Sparse Jacobian
-         Double Speed: Sparse Jacobian
-         Evaluate a Function That Has a Sparse Jacobian: fp.Jacobian
-         Evaluate a Function That Has a Sparse Jacobian
-         Speed Testing Sparse Jacobian: jacobian
-         Speed Testing Sparse Jacobian
-         Speed Testing the Jacobian of Ode Solution: jacobian
-         Speed Testing the Jacobian of Ode Solution
-         Computing a Jacobian With Constants that Change
-         Computing Sparse Jacobian Using Reverse Mode: Example and Test
-         Sparse Jacobian
-         Computing Sparse Jacobian Using Reverse Mode: Example and Test
-         Computing Sparse Jacobian Using Forward Mode: Example and Test
-         Reverse Mode Jacobian Sparsity: Example and Test
-         Jacobian Sparsity Pattern: Reverse Mode
-         Reverse Mode Jacobian Sparsity: Example and Test
-         Reverse Mode Jacobian Sparsity Patterns: Sparsity for Entire Jacobian
-         Reverse Mode Jacobian Sparsity Patterns
-         Forward Mode Jacobian Sparsity: Example and Test
-         Jacobian Sparsity Pattern: Forward Mode
-         Forward Mode Jacobian Sparsity: Example and Test
-         Forward Mode Jacobian Sparsity Patterns: Sparsity for Entire Jacobian
-         Forward Mode Jacobian Sparsity Patterns
-         Atomic Reverse Jacobian Sparsity: Example and Test
-         Atomic Forward Jacobian Sparsity: Example and Test
-         Atomic Reverse Jacobian Sparsity Patterns
-         Atomic Forward Jacobian Sparsity Patterns
-         ColPack: Sparse Jacobian Example and Test
-         ColPack: Sparse Jacobian Example and Test
-jacobian: Sparse Hessian Using Subgraphs and Jacobian: Example and Test
-          Sparse Jacobian: Example and Test
-          Jacobian: Example and Test
-          Jacobian: Driver Routine
-jacobians Compute Sparse Jacobians Using Subgraphs
-          Computing Sparse Jacobians
-jp LU Factorization of A Square Matrix and Stability Calculation: jp
-   Invert an LU Factored Equation: jp
-   LU Factorization of A Square Matrix: jp
- -K -
-Kutta An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-k User Defined Atomic AD Functions: k
-  Sparse Matrix Row, Column, Value Representation: set.k
-  Row and Column Index Sparsity Patterns: set.k
-  Evaluate a Polynomial or its Derivative: k
-  Forward Mode Second Partial Derivative Driver: k
-  AD Theory for Cholesky Factorization: Reverse Mode.Case k > 0
-  AD Theory for Cholesky Factorization: Reverse Mode.Case k = 0
-keys Returns Indices that Sort a Vector: keys
-kkt abs_normal: Solve a Quadratic Program With Box Constraints: KKT Conditions
-    Solve a Quadratic Program Using Interior Point Method: KKT Conditions
-known CppAD Assertions During Execution: Known
-      Replacing the CppAD Error Handler: known
- -L -
-Lu Compute Determinant and Solve Linear Equations
-LuFactor LuFactor: Example and Test
-         LU Factorization of A Square Matrix
-LuInvert LuInvert: Example and Test
-         Invert an LU Factored Equation
-LuRatio LuRatio: Example and Test
-        LU Factorization of A Square Matrix and Stability Calculation
-LuSolve Compute Determinant and Solve Linear Equations
-LuVecAD Lu Factor and Solve with Recorded Pivoting
-l LU Factorization of A Square Matrix and Stability Calculation: LU.L
-  Invert an LU Factored Equation: LU.L
-  LU Factorization of A Square Matrix: LU.L
-  Hessian: Easy Driver: l
-l.f. Bibliography: Shampine, L.F.
-lagrangian Hessian of Lagrangian and ADFun Default Constructor: Example and Test
-lambda Nonlinear Programming Using the CppAD Interface to Ipopt: solution.lambda
-       Use Ipopt to Solve a Nonlinear Programming Problem: solution.lambda
-language Bibliography: The C++ Programming Language
-languages Example and Test Linking CppAD to Languages Other than C++
-large Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function.Large x Values
-last Run One Speed Test and Print Results: last
-leak Memory Leak Detection
-least Get At Least A Specified Amount of Memory
-      Get At Least A Specified Amount of Memory
-left Union of Standard Sets: left
-     Matrix Multiply as an Atomic Operation: Left Operand Element Index
-     AD Conditional Expressions: left
-lemma AD Theory for Cholesky Factorization: Lemma 2
-      AD Theory for Cholesky Factorization: Lemma 1
-leqzero Compute Determinant and Solve Linear Equations: LeqZero
-level Computing a Jacobian With Constants that Change
-      Multiple Level of AD: Example and Test
-      Non-Smooth Optimization Using Abs-normal Quadratic Approximations: level
-      abs_normal: Minimize a Linear Abs-normal Approximation: level
-      abs_normal: Solve a Quadratic Program With Box Constraints: level
-      Solve a Quadratic Program Using Interior Point Method: level
-      Non-Smooth Optimization Using Abs-normal Linear Approximations: level
-      abs_normal: Minimize a Linear Abs-normal Approximation: level
-      abs_normal: Solve a Linear Program With Box Constraints: level
-      abs_normal: Solve a Linear Program Using Simplex Method: level
-      Checkpointing Functions: Purpose.Multiple Level AD
-      Checking the CppAD Examples and Tests: First Level
-levels An ODE Inverse Problem Example: Black Box Method.Two levels of Iteration
-       Using Multiple Levels of AD
-       Using Adolc with Multiple Levels of Taping: Example and Test
-lib Using CMake to Configure CppAD
-library CppAD Addons: Library Files
-        Speed Testing Utilities: Library Routines
-        Including the cppad_ipopt Library and Tests
-license Your License for the CppAD Software
-        Download The CppAD Source Code: License
-limitations Defines a User Atomic Operation that Computes Square Root: Limitations
-limits Base Type Requirements for Numeric Limits
-       Numeric Limits For an AD and Base Types
-limits: Numeric Limits: Example and Test
-line Routines That Track Use of New and Delete: line
-     Replacing the CppAD Error Handler: line
-linear LU Factorization of A Square Matrix and Stability Calculation
-       Lu Factor and Solve with Recorded Pivoting
-       Enable Use of Eigen Linear Algebra Package with CppAD
-       Invert an LU Factored Equation
-       LU Factorization of A Square Matrix
-       Compute Determinant and Solve Linear Equations
-       Compute Determinants and Solve Equations by LU Factorization
-       abs_normal: Minimize a Linear Abs-normal Approximation
-       Non-Smooth Optimization Using Abs-normal Linear Approximations
-       abs_normal: Minimize a Linear Abs-normal Approximation
-       abs_normal: Solve a Linear Program With Box Constraints
-       abs_normal: Solve a Linear Program Using Simplex Method
-link Running the Speed Test Program: Link Functions
-     Example and Test Linking CppAD to Languages Other than C++
-link_det_lu Sacado Speed: Gradient of Determinant Using Lu Factorization
-            Fadbad Speed: Gradient of Determinant Using Lu Factorization
-            CppAD Speed: Gradient of Determinant Using Lu Factorization
-            Adolc Speed: Gradient of Determinant Using Lu Factorization
-            Double Speed: Determinant Using Lu Factorization
-            Speed Testing Gradient of Determinant Using Lu Factorization
-link_det_minor Sacado Speed: Gradient of Determinant by Minor Expansion
-               Fadbad Speed: Gradient of Determinant by Minor Expansion
-               CppAD Speed: Gradient of Determinant by Minor Expansion
-               Adolc Speed: Gradient of Determinant by Minor Expansion
-               Double Speed: Determinant by Minor Expansion
-               Speed Testing Gradient of Determinant by Minor Expansion
-link_mat_mul Sacado Speed: Matrix Multiplication
-             Fadbad Speed: Matrix Multiplication
-             CppAD Speed, Matrix Multiplication
-             Adolc Speed: Matrix Multiplication
-             CppAD Speed: Matrix Multiplication (Double Version)
-             Speed Testing Derivative of Matrix Multiply
-link_ode Sacado Speed: Gradient of Ode Solution
-         Fadbad Speed: Ode
-         CppAD Speed: Gradient of Ode Solution
-         Adolc Speed: Ode
-         Double Speed: Ode Solution
-         Speed Testing the Jacobian of Ode Solution
-link_poly Sacado Speed: Second Derivative of a Polynomial
-          Fadbad Speed: Second Derivative of a Polynomial
-          CppAD Speed: Second Derivative of a Polynomial
-          Adolc Speed: Second Derivative of a Polynomial
-          Double Speed: Evaluate a Polynomial
-          Speed Testing Second Derivative of a Polynomial
-link_sparse_hessian CppAD Speed: Sparse Hessian
-                    Adolc Speed: Sparse Hessian
-                    Double Speed: Sparse Hessian
-                    Speed Testing Sparse Hessian
-link_sparse_jacobian CppAD Speed: Sparse Jacobian
-                     adolc Speed: Sparse Jacobian
-                     Double Speed: Sparse Jacobian
-                     Speed Testing Sparse Jacobian
-linking Microsoft Version of Elapsed Number of Seconds: Linking
-        Example and Test Linking CppAD to Languages Other than C++
-linux Autotools Unix Test and Installation: adolc_dir.Linux
-list Nonlinear Programming Using the CppAD Interface to Ipopt: Wish List
-     The CppAD Wish List
-     List All (Except Deprecated) CppAD Examples
-literature Create An Abs-normal Representation of a Function: Correspondence to Literature
-log The AD log Function: Example and Test
-    The Exponential Function: log
-log10 The AD log10 Function: Example and Test
-      The Base 10 Logarithm Function: log10
-log1p Logarithm Function Reverse Mode Theory
-      Logarithm Function Forward Mode Theory
-      Enable use of AD<Base> where Base is Adolc's adouble Type: erf, asinh, acosh, atanh, expm1, log1p
-      Example AD<Base> Where Base Constructor Allocates Memory: erf, asinh, acosh, atanh, expm1, log1p
-      Base Type Requirements for Standard Math Functions: erf, asinh, acosh, atanh, expm1, log1p
-      The AD log1p Function: Example and Test
-      The Logarithm of One Plus Argument: log1p
-logarithm Logarithm Function Reverse Mode Theory
-          Logarithm Function Forward Mode Theory
-          The Logarithm of One Plus Argument: log1p
-          The Base 10 Logarithm Function: log10
-logdet Lu Factor and Solve with Recorded Pivoting: logdet
-       Compute Determinant and Solve Linear Equations: logdet
-low Do One Thread's Work for Multi-Threaded Newton Method: low
-lower Multiple Directions Forward Mode: Non-Zero Lower Orders
-      AD Theory for Cholesky Factorization: Notation.Lower Triangular Part
-lp_box lp_box Source Code
-lp_box: abs_normal lp_box: Example and Test
-lu LU Factorization of A Square Matrix and Stability Calculation: LU
-   LU Factorization of A Square Matrix and Stability Calculation
-   Sacado Speed: Gradient of Determinant Using Lu Factorization
-   Fadbad Speed: Gradient of Determinant Using Lu Factorization
-   CppAD Speed: Gradient of Determinant Using Lu Factorization
-   Adolc Speed: Gradient of Determinant Using Lu Factorization
-   Double Speed: Determinant Using Lu Factorization
-   Determinant Using Lu Factorization: Example and Test
-   Determinant Using Expansion by Lu Factorization
-   Speed Testing Gradient of Determinant Using Lu Factorization
-   Lu Factor and Solve With Recorded Pivoting: Example and Test
-   Lu Factor and Solve with Recorded Pivoting
-   Gradient of Determinant Using Lu Factorization: Example and Test
-   Gradient of Determinant Using LU Factorization: Example and Test
-   Invert an LU Factored Equation: LU
-   Invert an LU Factored Equation
-   LU Factorization of A Square Matrix: LU
-   LU Factorization of A Square Matrix
-   Compute Determinants and Solve Equations by LU Factorization
-lufactor Source: LuFactor
-lufactor: LuFactor: Example and Test
-luinvert Source: LuInvert
-luinvert: LuInvert: Example and Test
-luratio: LuRatio: Example and Test
-lusolve Frequently Asked Questions and Answers: Matrix Inverse.LuSolve
-        Source: LuSolve
-        LuSolve With Complex Arguments: Example and Test
- -M -
-m Compute Determinant using Expansion by Minors: m
-  Determinant of a Minor: m
-  User Defined Atomic AD Functions: m
-  Nonlinear Programming Using the CppAD Interface to Ipopt: m
-  Adolc Test Utility: Allocate and Free Memory For a Matrix: m
-  Evaluate a Function That Has a Sparse Jacobian: m
-  Determinant of a Minor: m
-  Speed Testing Sparse Jacobian: m
-  Lu Factor and Solve with Recorded Pivoting: m
-  An Error Controller for Gear's Ode Solvers: M
-  An Arbitrary Order Gear Method: m
-  A 3rd and 4th Order Rosenbrock ODE Solver: M
-  An Embedded 4th and 5th Order Runge-Kutta ODE Solver: M
-  Multi-dimensional Romberg Integration: m
-  Compute Determinant and Solve Linear Equations: m
-  Non-Smooth Optimization Using Abs-normal Quadratic Approximations: f.m
-  abs_normal: Minimize a Linear Abs-normal Approximation: m
-  Non-Smooth Optimization Using Abs-normal Linear Approximations: f.m
-  abs_normal: Minimize a Linear Abs-normal Approximation: m
-  abs_normal: Evaluate First Order Approximation: m
-  Create An Abs-normal Representation of a Function: f.m
-  Multiple Directions Forward Mode: Notation.m
-  Multiple Order Forward Mode: Notation.m
-machine Machine Epsilon For AD Types
-        Example Differentiating a Stack Machine Interpreter
-macro Routines That Track Use of New and Delete: TrackCount.Macro
-      Routines That Track Use of New and Delete: TrackExtend.Macro
-      Routines That Track Use of New and Delete: TrackDelVec.Macro
-      Routines That Track Use of New and Delete: TrackNewVec.Macro
-      CppAD Assertions During Execution
-      Example AD<Base> Where Base Constructor Allocates Memory: Boolean Operator Macro
-      Example AD<Base> Where Base Constructor Allocates Memory: Binary Operator Macro
-      Example AD<Base> Where Base Constructor Allocates Memory: Compound Assignment Macro
-macros Obtain Nan or Determine if a Value is Nan: Include.Macros
-main Main Program For Comparing C and C++ Speed
-     Speed Testing Utilities: Speed Main Program
-     Correctness Tests For Exponential Approximation in Introduction
-make Autotools Unix Test and Installation: make install
-     Autotools Unix Test and Installation: make
-     Checking the CppAD Examples and Tests: Subsets of make check
-     Using CMake to Configure CppAD: make check
-makefile Using CMake to Configure CppAD
-management Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Memory Management
-           Using Adolc with Multiple Levels of Taping: Example and Test: Memory Management
-mat Adolc Test Utility: Allocate and Free Memory For a Matrix: mat
-    abs_normal: Print a Vector or Matrix: mat
-mat_mul Define Matrix Multiply as a User Atomic Operation: Declare mat_mul Function
-mat_sum_sq Source: mat_sum_sq
-           Sum of the Elements of the Square of a Matrix: Example and Test
-           Sum Elements of a Matrix Times Itself
-math zdouble: An AD Base Type With Absolute Zero: Syntax.Standard Math
-     The Theory of Reverse Mode: Standard Math Functions
-     The Theory of Forward Mode: Standard Math Functions
-     Enable use of AD<Base> where Base is std::complex<double>: Invalid Unary Math
-     Enable use of AD<Base> where Base is std::complex<double>: Valid Unary Math
-     Enable use of AD<Base> where Base is double: Unary Standard Math
-     Enable use of AD<Base> where Base is float: Unary Standard Math
-     Enable use of AD<Base> where Base is Adolc's adouble Type: Unary Standard Math
-     Example AD<Base> Where Base Constructor Allocates Memory: Unary Standard Math
-     Base Type Requirements for Standard Math Functions: Unary Standard Math
-     Base Type Requirements for Standard Math Functions
-     The Binary Math Functions
-     The Unary Standard Math Functions
-mathematical exp_eps: Second Order Reverse Sweep: Mathematical Form
-             exp_eps: Second Order Forward Mode: Mathematical Form
-             exp_eps: First Order Reverse Sweep: Mathematical Form
-             exp_eps: First Order Forward Sweep: Mathematical Form
-             exp_eps: Operation Sequence and Zero Order Forward Sweep: Mathematical Form
-             An Epsilon Accurate Exponential Approximation: Mathematical Function
-             exp_2: Second Order Reverse Mode: Mathematical Form
-             exp_2: Second Order Forward Mode: Mathematical Form
-             exp_2: First Order Reverse Mode: Mathematical Form
-             exp_2: First Order Forward Mode: Mathematical Form
-             exp_2: Operation Sequence and Zero Order Forward Mode: Mathematical Form
-             Second Order Exponential Approximation: Mathematical Form
-matrices Some General Purpose Utilities: Miscellaneous.Sparse Matrices
-         Atomic Eigen Matrix Inversion Class: Theory.Product of Three Matrices
-         Atomic Eigen Matrix Multiply Class: Theory.Product of Two Matrices
-matrix LU Factorization of A Square Matrix and Stability Calculation: Matrix Storage
-       LU Factorization of A Square Matrix and Stability Calculation
-       Define Matrix Multiply as a User Atomic Operation: One Matrix Multiply
-       Define Matrix Multiply as a User Atomic Operation: Matrix Indexing
-       Define Matrix Multiply as a User Atomic Operation
-       Old Matrix Multiply as a User Atomic Operation: Example and Test
-       User Defined Atomic AD Functions: Example.Matrix Multiplication
-       Frequently Asked Questions and Answers: Matrix Inverse
-       Sacado Speed: Matrix Multiplication
-       Sacado Speed: Gradient of Determinant Using Lu Factorization
-       Fadbad Speed: Matrix Multiplication
-       Fadbad Speed: Gradient of Determinant Using Lu Factorization
-       CppAD Speed, Matrix Multiplication
-       CppAD Speed: Gradient of Determinant Using Lu Factorization
-       Adolc Test Utility: Allocate and Free Memory For a Matrix
-       Adolc Speed: Matrix Multiplication
-       Adolc Speed: Gradient of Determinant Using Lu Factorization
-       CppAD Speed: Matrix Multiplication (Double Version)
-       Double Speed: Determinant Using Lu Factorization
-       Sum Elements of a Matrix Times Itself
-       Check Gradient of Determinant of 3 by 3 matrix
-       Check Determinant of 3 by 3 matrix
-       Determinant of a Minor
-       Speed Testing Derivative of Matrix Multiply
-       Speed Testing Gradient of Determinant by Minor Expansion: matrix
-       Speed Testing Gradient of Determinant Using Lu Factorization: matrix
-       Lu Factor and Solve with Recorded Pivoting: Matrix
-       Sparse Matrix Row, Column, Value Representation: matrix
-       Sparse Matrix Row, Column, Value Representation
-       Invert an LU Factored Equation: Matrix Storage
-       LU Factorization of A Square Matrix: Matrix Storage
-       LU Factorization of A Square Matrix
-       Compute Determinant and Solve Linear Equations: Matrix Storage
-       Compute Determinants and Solve Equations by LU Factorization
-       abs_normal: Print a Vector or Matrix
-       Matrix Multiply as an Atomic Operation: Reverse Matrix Multiply
-       Matrix Multiply as an Atomic Operation: Forward Matrix Multiply
-       Matrix Multiply as an Atomic Operation: Matrix Dimensions
-       Matrix Multiply as an Atomic Operation
-       User Atomic Matrix Multiply: Example and Test
-       Atomic Eigen Matrix Inversion Class: Matrix Dimensions
-       Atomic Eigen Matrix Inversion Class
-       Atomic Eigen Matrix Inverse: Example and Test
-       Atomic Eigen Matrix Multiply Class: Matrix Dimensions
-       Atomic Eigen Matrix Multiply Class
-       Atomic Eigen Matrix Multiply: Example and Test
-matrix: Sum of the Elements of the Square of a Matrix: Example and Test
-matrix_out Compute Sparse Jacobians Using Subgraphs: matrix_out
-max Numeric Limits For an AD and Base Types: max
-max_itr A Multi-Threaded Newton's Method: max_itr
-        Set Up Multi-Threaded Newton Method: max_itr
-max_num_threads Autotools Unix Test and Installation: max_num_threads
-                Set Maximum Number of Threads for omp_alloc Allocator
-max_threads Run Multi-Threading Examples and Speed Tests: multi_newton.max_threads
-            Run Multi-Threading Examples and Speed Tests: harmonic.max_threads
-maxabs An Error Controller for Gear's Ode Solvers: maxabs
-       OdeErrControl: Example and Test Using Maxabs Argument
-       An Error Controller for ODE Solvers: maxabs
-maximum Set Maximum Number of Threads for omp_alloc Allocator
-        Set and Get Maximum Number of Threads for omp_alloc Allocator
-        Using CppAD in a Multi-Threading Environment
-        Using CMake to Configure CppAD
-maxitr Non-Smooth Optimization Using Abs-normal Quadratic Approximations: maxitr
-       abs_normal: Minimize a Linear Abs-normal Approximation: maxitr
-       abs_normal: Solve a Quadratic Program With Box Constraints: maxitr
-       Solve a Quadratic Program Using Interior Point Method: maxitr
-       Non-Smooth Optimization Using Abs-normal Linear Approximations: maxitr
-       abs_normal: Minimize a Linear Abs-normal Approximation: maxitr
-       abs_normal: Solve a Linear Program With Box Constraints: maxitr
-       abs_normal: Solve a Linear Program Using Simplex Method: maxitr
-measurement An ODE Inverse Problem Example: Measurements.Simulated Measurement Values
-            ODE Inverse Problem Definitions: Source Code: Measurements.Simulated Measurement Values
-measurements An ODE Inverse Problem Example: Measurements
-             ODE Inverse Problem Definitions: Source Code: Measurements
-mega_sum Timing Test of Multi-Threaded Summation of 1/i: mega_sum
-         Run Multi-Threading Examples and Speed Tests: harmonic.mega_sum
-member ADFun Object Deprecated Member Functions
-       Required Base Class Member Functions
-memory User Defined Atomic AD Functions: Syntax Function.Free Static Memory
-       Memory Leak Detection
-       OpenMP Memory Allocator: Example and Test
-       Check If A Memory Allocation is Efficient for Another Use
-       Return A Raw Array to The Available Memory for a Thread
-       Allocate Memory and Create A Raw Array
-       Amount of Memory Available for Quick Use by a Thread
-       Amount of Memory a Thread is Currently Using
-       Free Memory Currently Available for Quick Use by a Thread
-       Return Memory to omp_alloc
-       Get At Least A Specified Amount of Memory
-       A Quick OpenMP Memory Allocator Used by CppAD
-       Routines That Track Use of New and Delete
-       ADFun Object Deprecated Member Functions: Memory
-       The CppAD Wish List: Optimization.Memory
-       Frequently Asked Questions and Answers: Tape Storage: Disk or Memory
-       Frequently Asked Questions and Answers: Speed.Memory Allocation
-       Adolc Test Utility: Allocate and Free Memory For a Matrix
-       Running the Speed Test Program: Global Options.memory
-       Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Memory Management
-       Free All Memory That Was Allocated for Use by thread_alloc
-       Amount of Memory Available for Quick Use by a Thread
-       Amount of Memory a Thread is Currently Using
-       Control When Thread Alloc Retains Memory For Future Use
-       Free Memory Currently Available for Quick Use by a Thread: Purpose.Extra Memory
-       Free Memory Currently Available for Quick Use by a Thread
-       Return Memory to thread_alloc
-       Get At Least A Specified Amount of Memory
-       Fast Multi-Threading Memory Allocator: Example and Test
-       A Fast Multi-Threading Memory Allocator
-       The CppAD::vector Template Class: Memory and Parallel Mode
-       The CppAD::vector Template Class: vectorBool.Memory
-       Some General Purpose Utilities: Miscellaneous.Multi-Threading Memory Allocation
-       Optimize an ADFun Object Tape
-       Controlling Taylor Coefficient Memory Allocation: Example and Test
-       Controlling Taylor Coefficients Memory Allocation: c.Freeing Memory
-       Controlling Taylor Coefficients Memory Allocation: c.Pre-Allocating Memory
-       Controlling Taylor Coefficients Memory Allocation
-       Using Adolc with Multiple Levels of Taping: Example and Test: Memory Management
-       Example AD<Base> Where Base Constructor Allocates Memory
-       AD Vectors that Record Index Operations: Speed and Memory
-       Checkpointing Functions: Purpose.Reduce Memory
-       Using CMake to Configure CppAD
-memory_leak Memory Leak Detection
-memory_ok Object that Runs a Group of Tests: memory_ok
-message Memory Leak Detection: Error Message
-        Check an ADFun Object For Nan Results: Error Message
-method An ODE Inverse Problem Example: Simultaneous Method
-       An ODE Inverse Problem Example: Black Box Method
-       Speed Testing Sparse Jacobian: Method
-       Speed Testing Sparse Hessian: Method
-       Speed Testing Second Derivative of a Polynomial: Method
-       Speed Testing the Jacobian of Ode Solution: Method
-       Speed Testing Gradient of Determinant by Minor Expansion: Method
-       Speed Testing Gradient of Determinant Using Lu Factorization: Method
-       Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Taylor's Method Using AD
-       Taylor's Ode Solver: A Multi-Level AD Example and Test: Taylor's Method Using AD
-       ODE Inverse Problem Definitions: Source Code: Solution Method
-       An Arbitrary Order Gear Method: Gear's Method
-       An Arbitrary Order Gear Method
-       An Error Controller for ODE Solvers: Method
-       Timing Test of Multi-Threaded Newton Method
-       A Multi-Threaded Newton's Method: Method
-       A Multi-Threaded Newton's Method
-       Take Down Multi-threaded Newton Method
-       Do One Thread's Work for Multi-Threaded Newton Method
-       Set Up Multi-Threaded Newton Method
-       Common Variables use by Multi-Threaded Newton Method
-       Multi-Threaded Newton Method Example / Test
-       abs_normal: Minimize a Linear Abs-normal Approximation: Method
-       Solve a Quadratic Program Using Interior Point Method
-       abs_normal: Minimize a Linear Abs-normal Approximation: Method
-       abs_normal: Solve a Linear Program Using Simplex Method
-       Compute Sparse Jacobians Using Subgraphs: Method
-       Subgraph Dependency Sparsity Patterns: Method
-       Checkpointing Functions: Method
-       The Base 10 Logarithm Function: log10: Method
-microsoft Microsoft Version of Elapsed Number of Seconds
-          Returns Elapsed Number of Seconds: Microsoft Systems
-min Numeric Limits For an AD and Base Types: min
-min_bytes Get At Least A Specified Amount of Memory: min_bytes
-          Get At Least A Specified Amount of Memory: min_bytes
-min_nso_linear min_nso_linear Source Code
-min_nso_linear: abs_normal min_nso_linear: Example and Test
-min_nso_quad min_nso_quad Source Code
-min_nso_quad: abs_normal min_nso_quad: Example and Test
-minimize abs_normal: Minimize a Linear Abs-normal Approximation
-         abs_normal: Minimize a Linear Abs-normal Approximation
-minor Determinant of a Minor
-      Sacado Speed: Gradient of Determinant by Minor Expansion
-      Fadbad Speed: Gradient of Determinant by Minor Expansion
-      CppAD Speed: Gradient of Determinant by Minor Expansion
-      Adolc Speed: Gradient of Determinant by Minor Expansion
-      Double Speed: Determinant by Minor Expansion
-      Determinant of a Minor
-      Speed Testing Gradient of Determinant by Minor Expansion
-minor: Determinant of a Minor: Example and Test
-minors Compute Determinant using Expansion by Minors
-       Determinant Using Expansion by Minors: Example and Test
-       Determinant Using Expansion by Minors
-       Determinant Using Lu Factorization: Example and Test
-       Gradient of Determinant Using Expansion by Minors: Example and Test
-       Gradient of Determinant Using Expansion by Minors: Example and Test
-minors: Determinant Using Expansion by Minors: Example and Test
-        Gradient of Determinant Using Expansion by Minors: Example and Test
-        Gradient of Determinant Using Expansion by Minors: Example and Test
-minus The Exponential Function Minus One: expm1
-      AD Compound Assignment Operators
-      AD Binary Subtraction: Example and Test
-      AD Binary Arithmetic Operators
-      AD Unary Minus Operator: Example and Test
-      AD Unary Minus Operator
-miscellaneous Some General Purpose Utilities: Miscellaneous
-mode User Defined Atomic AD Functions: afun.Parallel Mode
-     Is The Current Execution in OpenMP Parallel Mode
-     Comparison Changes During Zero Order Forward Mode
-     The CppAD Wish List: Forward Mode Recomputation
-     An Important Reverse Mode Identity
-     Error Function Reverse Mode Theory
-     Tangent and Hyperbolic Tangent Reverse Mode Theory
-     Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
-     Inverse Sine and Hyperbolic Sine Reverse Mode Theory
-     Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory
-     Square Root Function Reverse Mode Theory
-     Logarithm Function Reverse Mode Theory
-     Exponential Function Reverse Mode Theory
-     The Theory of Reverse Mode
-     Inverse Cosine and Hyperbolic Cosine Forward Mode Theory
-     Inverse Sine and Hyperbolic Sine Forward Mode Theory
-     Inverse Tangent and Hyperbolic Tangent Forward Mode Theory
-     Square Root Function Forward Mode Theory
-     Logarithm Function Forward Mode Theory
-     Exponential Function Forward Mode Theory
-     The Theory of Forward Mode
-     Taylor's Ode Solver: An Example and Test: Forward Mode
-     Is The Current Execution in Parallel Mode
-     The CppAD::vector Template Class: Memory and Parallel Mode
-     A 3rd and 4th Order Rosenbrock ODE Solver: Parallel Mode
-     An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Parallel Mode
-     Check Simple Vector Concept: Parallel Mode
-     Check NumericType Class Concept: Parallel Mode
-     Replacing the CppAD Error Handler: Constructor.Parallel Mode
-     Enable AD Calculations During Parallel Mode
-     Using CppAD in a Multi-Threading Environment
-     Forward Mode Hessian Sparsity: Example and Test
-     Hessian Sparsity Pattern: Forward Mode
-     Forward Mode Hessian Sparsity: Example and Test
-     Forward Mode Hessian Sparsity Patterns
-     Reverse Mode Hessian Sparsity: Example and Test
-     Hessian Sparsity Pattern: Reverse Mode
-     Reverse Mode Hessian Sparsity: Example and Test
-     Reverse Mode Hessian Sparsity Patterns
-     Reverse Mode Jacobian Sparsity: Example and Test
-     Jacobian Sparsity Pattern: Reverse Mode
-     Reverse Mode Jacobian Sparsity: Example and Test
-     Reverse Mode Jacobian Sparsity Patterns
-     Forward Mode Jacobian Sparsity: Example and Test
-     Jacobian Sparsity Pattern: Forward Mode
-     Forward Mode Jacobian Sparsity: Example and Test
-     Forward Mode Jacobian Sparsity Patterns
-     Computing Reverse Mode on Subgraphs: Example and Test
-     Reverse Mode Using Subgraphs
-     Reverse Mode General Case (Checkpointing): Example and Test
-     Any Order Reverse Mode
-     Second Order Reverse Mode
-     First Order Reverse Mode
-     Multiple Directions Forward Mode: Reverse Mode
-     Multiple Directions Forward Mode
-     Multiple Order Forward Mode
-     Reverse Mode Second Partial Derivative Driver
-     Forward Mode Second Partial Derivative Driver
-     Stop Recording and Store Operation Sequence: Parallel Mode
-     Construct an ADFun Object and Stop Recording: Parallel Mode
-     Declare Independent Variables and Start Recording: Parallel Mode
-     Reverse Mode
-     Forward Mode
-     AD Theory for Cholesky Factorization: Reverse Mode
-     AD Theory for Cholesky Factorization: Forward Mode
-     Atomic Reverse Mode
-     Atomic Forward Mode
-     Discrete AD Functions: Parallel Mode
-     Printing During Forward Mode: Example and Test
-     Printing AD Values During Forward Mode
-     exp_eps: Second Order Forward Mode
-     exp_eps: First Order Reverse Sweep
-     exp_2: Verify Second Order Reverse Sweep
-     exp_2: Verify First Order Reverse Sweep
-     exp_2: Second Order Reverse Mode
-     exp_2: Second Order Forward Mode
-     exp_2: First Order Reverse Mode
-     exp_2: First Order Forward Mode
-     exp_2: Operation Sequence and Zero Order Forward Mode
-     An Introduction by Example to Algorithmic Differentiation: Preface.Reverse Mode
-     An Introduction by Example to Algorithmic Differentiation: Preface.Forward Mode
-mode: Frequently Asked Questions and Answers: Mode: Forward or Reverse
-      Computing Sparse Jacobian Using Reverse Mode: Example and Test
-      Computing Sparse Jacobian Using Reverse Mode: Example and Test
-      Computing Sparse Jacobian Using Forward Mode: Example and Test
-      Third Order Reverse Mode: Example and Test
-      First Order Reverse Mode: Example and Test
-      Forward Mode: Example and Test of Multiple Directions
-      Forward Mode: Example and Test of Multiple Orders
-      Forward Mode: Example and Test
-      Second Order Forward Mode: Derivative Values
-      First Order Forward Mode: Derivative Values
-      Zero Order Forward Mode: Function Values
-      Print During Zero Order Forward Mode: Example and Test
-      Printing During Forward Mode: Example and Test
-modeexample Second Order Reverse ModeExample and Test
-monthly Download The CppAD Source Code: Monthly Versions
-more Base Type Requirements for Identically Equal Comparisons: EqualOpSeq.More Complicated Cases
-motivation zdouble: An AD Base Type With Absolute Zero: Motivation
-           Using Multiple Levels of AD: Motivation
-           Determine Amount of Time to Execute a Test: Motivation
-           Run One Speed Test and Print Results: Motivation
-           Run One Speed Test and Return Results: Motivation
-           Check if Two Value are Identically Equal: Motivation
-move The CppAD::vector Template Class: Assignment.Move Semantics
-ms Choosing The Vector Testing Template Class: MS Windows
-msg CppAD Assertions During Execution: Msg
-    Replacing the CppAD Error Handler: msg
-mul_level
-     checkpoint Checkpointing an Extended ODE Solver: Example and Test
-multi OpenMP Memory Allocator: Example and Test
-      Routines That Track Use of New and Delete
-      Multi-dimensional Romberg Integration
-multi-dimensional Multi-dimensional Romberg Integration
-multi-level Taylor's Ode Solver: A Multi-Level Adolc Example and Test
-            Taylor's Ode Solver: A Multi-Level AD Example and Test
-multi-thread Fast Multi-Threading Memory Allocator: Example and Test
-multi-threaded Timing Test of Multi-Threaded Newton Method
-               A Multi-Threaded Newton's Method
-               Take Down Multi-threaded Newton Method
-               Do One Thread's Work for Multi-Threaded Newton Method
-               Set Up Multi-Threaded Newton Method
-               Common Variables use by Multi-Threaded Newton Method
-               Multi-Threaded Newton Method Example / Test
-               Timing Test for Multi-Threaded User Atomic Calculation
-               Run Multi-Threaded User Atomic Calculation
-               Multi-Threaded User Atomic Take Down
-               Multi-Threaded User Atomic Worker
-               Multi-Threaded User Atomic Set Up
-               Multi-Threaded User Atomic Common Information
-               Timing Test of Multi-Threaded Summation of 1/i
-               Multi-Threaded Implementation of Summation of 1/i
-multi-threading A Quick OpenMP Memory Allocator Used by CppAD
-                Routines That Track Use of New and Delete: Multi-Threading
-                The CppAD Wish List: Multi-Threading
-                Setup thread_alloc For Use in Multi-Threading Environment
-                Fast Multi-Threading Memory Allocator: Example and Test
-                A Fast Multi-Threading Memory Allocator
-                Some General Purpose Utilities: Miscellaneous.Multi-Threading Memory Allocation
-                Multi-Threading User Atomic Example / Test
-                Take Down Multi-threading Sum of 1/i
-                Set Up Multi-threading Sum of 1/i
-                Common Variables Used by Multi-threading Sum of 1/i
-                Multi-Threading Harmonic Summation Example / Test
-                Run Multi-Threading Examples and Speed Tests
-                Using CppAD in a Multi-Threading Environment
-multi_newton Run Multi-Threading Examples and Speed Tests: multi_newton
-multiple Speed Testing Derivative of Matrix Multiply
-         Computing a Jacobian With Constants that Change
-         Multiple Level of AD: Example and Test
-         Using Multiple Levels of AD
-         Forward Mode: Example and Test of Multiple Directions
-         Multiple Directions Forward Mode
-         Forward Mode: Example and Test of Multiple Orders
-         Multiple Order Forward Mode: yq.Multiple Orders
-         Multiple Order Forward Mode: xq.Multiple Orders
-         Multiple Order Forward Mode
-         Reverse Mode: Multiple Directions
-         Using Adolc with Multiple Levels of Taping: Example and Test
-         Checkpointing Functions: Purpose.Multiple Level AD
-         AD Compound Assignment Operators
-multiple-levels Atomic Operations and Multiple-Levels of AD: Example and Test
-multiplication User Defined Atomic AD Functions: Example.Matrix Multiplication
-               The Theory of Reverse Mode: Binary Operators.Multiplication
-               The Theory of Forward Mode: Binary Operators.Multiplication
-               Sacado Speed: Matrix Multiplication
-               Fadbad Speed: Matrix Multiplication
-               CppAD Speed, Matrix Multiplication
-               Adolc Speed: Matrix Multiplication
-               CppAD Speed: Matrix Multiplication (Double Version)
-               Absolute Zero Multiplication
-               AD Compound Assignment Operators: Derivative.Multiplication
-               AD Binary Arithmetic Operators: Derivative.Multiplication
-multiplication: AD Absolute Zero Multiplication: Example and Test
-                AD Compound Assignment Multiplication: Example and Test
-                AD Binary Multiplication: Example and Test
-multiply Define Matrix Multiply as a User Atomic Operation: One Matrix Multiply
-         Define Matrix Multiply as a User Atomic Operation
-         Old Matrix Multiply as a User Atomic Operation: Example and Test
-         Sacado Speed: Matrix Multiplication
-         Fadbad Speed: Matrix Multiplication
-         CppAD Speed, Matrix Multiplication
-         Adolc Speed: Matrix Multiplication
-         CppAD Speed: Matrix Multiplication (Double Version)
-         Sum Elements of a Matrix Times Itself
-         Speed Testing Derivative of Matrix Multiply
-         Matrix Multiply as an Atomic Operation: Reverse Matrix Multiply
-         Matrix Multiply as an Atomic Operation: Forward Matrix Multiply
-         Matrix Multiply as an Atomic Operation
-         Atomic Eigen Matrix Multiply Class
-         AD Compound Assignment Multiplication: Example and Test
-         AD Compound Assignment Operators
-         AD Binary Multiplication: Example and Test
-         AD Binary Arithmetic Operators
-multiply: User Atomic Matrix Multiply: Example and Test
-          Atomic Eigen Matrix Multiply: Example and Test
- -N -
-NDEBUG Routines That Track Use of New and Delete
-       Definition of a Simple Vector
-       Optimize an ADFun Object Tape
-NearEqual Determine if Two Values Are Nearly Equal
-          Compare AD and Base Objects for Nearly Equal
-NearEqualExt Compare AD with Base Objects: Example and Test
-NULL CppAD API Preprocessor Symbols
-NumericType The CheckNumericType Function: Example and Test
-            The NumericType: Example and Test
-n_sweep Speed Testing Sparse Jacobian: n_sweep
-        Speed Testing Sparse Hessian: n_sweep
-        Running the Speed Test Program: Speed Results.n_sweep
-        Sparse Hessian: n_sweep
-        Computing Sparse Hessians: n_sweep
-        Sparse Jacobian: n_sweep
-        Computing Sparse Jacobians: n_sweep
-name CppAD Addons: Name
-     CppAD Deprecated API Features: Name Changes
-     Object that Runs a Group of Tests: name
-     Run One Speed Test and Print Results: Test.name
-     NearEqual Function: Example and Test: File Name
-     abs_normal: Print a Vector or Matrix: name
-     Atomic Function Constructor: atomic_base.name
-     Checkpointing Functions: name
-     Discrete AD Functions: name
-namespace CppAD Addons: Namespace
-          Nonlinear Programming Using the CppAD Interface to Ipopt: cppad_ipopt namespace
-          Frequently Asked Questions and Answers: Namespace
-          Enable Use of Eigen Linear Algebra Package with CppAD: CppAD Namespace
-          cppad-20180000.0: A Package for Differentiation of C++ Algorithms: Namespace
-nan zdouble: An AD Base Type With Absolute Zero: Syntax.Nan
-    OdeErrControl: Example and Test: Nan
-    An Error Controller for ODE Solvers: Method.Nan
-    A 3rd and 4th Order Rosenbrock ODE Solver: Fun.Nan
-    Obtain Nan or Determine if a Value is Nan
-    Obtain Nan or Determine if a Value is Nan
-    Check an ADFun Object For Nan Results
-    Optimize an ADFun Object Tape: Atomic Functions.nan
-nan(zero) Obtain Nan or Determine if a Value is Nan: nan(zero)
-nan: nan: Example and Test
-     ADFun Checking For Nan: Example and Test
-nc Sparse Matrix Row, Column, Value Representation: nc
-   Row and Column Index Sparsity Patterns: nc
-   abs_normal: Print a Vector or Matrix: nc
-ncopy Routines That Track Use of New and Delete: ncopy
-ndebug Check If A Memory Allocation is Efficient for Another Use: NDEBUG
-       Return Memory to omp_alloc: NDEBUG
-       Frequently Asked Questions and Answers: Speed.NDEBUG
-       Return Memory to thread_alloc: NDEBUG
-       CppAD Assertions During Execution: NDEBUG
-near Determine if Two Values Are Nearly Equal
-nearequal NearEqual Function: Example and Test
-nearly Determine if Two Values Are Nearly Equal
-       Compare AD and Base Objects for Nearly Equal
-nested Example Optimization and Nested Conditional Expressions
-new Tracking Use of New and Delete: Example and Test
-    Routines That Track Use of New and Delete
-    The CppAD Wish List: Atomic.New API
-newlen Routines That Track Use of New and Delete: newlen
-newptr Routines That Track Use of New and Delete: head newptr
-newton Timing Test of Multi-Threaded Newton Method
-       Take Down Multi-threaded Newton Method
-       Do One Thread's Work for Multi-Threaded Newton Method
-       Set Up Multi-Threaded Newton Method
-       Common Variables use by Multi-Threaded Newton Method
-       Multi-Threaded Newton Method Example / Test
-       Solve a Quadratic Program Using Interior Point Method: Newton Step
-newton'A Multi-Threaded Newton's Method
-nnz Sparse Matrix Row, Column, Value Representation: nnz
-    Row and Column Index Sparsity Patterns: nnz
-no_compare_op Optimize an ADFun Object Tape: options.no_compare_op
-no_conditional_skip Optimize an ADFun Object Tape: options.no_conditional_skip
-no_print_for_op Optimize an ADFun Object Tape: options.no_print_for_op
-non-smooth Non-Smooth Optimization Using Abs-normal Quadratic Approximations
-           Non-Smooth Optimization Using Abs-normal Linear Approximations
-           Abs-normal Representation of Non-Smooth Functions
-non-zero Multiple Directions Forward Mode: Non-Zero Lower Orders
-nonlinear Nonlinear Programming Using CppAD and Ipopt: Example and Test
-          Nonlinear Programming Using the CppAD Interface to Ipopt
-          Nonlinear Programming Retaping: Example and Test
-          Nonlinear Programming Using CppAD and Ipopt: Example and Test
-          Use Ipopt to Solve a Nonlinear Programming Problem
-norm Atomic Euclidean Norm Squared: Example and Test
-not Example AD Base Types That are not AD<OtherBase>
-    Base Type Requirements for Ordered Comparisons: Not Ordered
-    Base Type Requirements for Conditional Expressions: CondExpTemplate.Not Ordered
-notation An ODE Inverse Problem Example: Notation
-         An Important Reverse Mode Identity: Notation
-         Error Function Reverse Mode Theory: Notation
-         Tangent and Hyperbolic Tangent Reverse Mode Theory: Notation
-         The Theory of Reverse Mode: Taylor Notation
-         The Theory of Forward Mode: Taylor Notation
-         An Error Controller for Gear's Ode Solvers: Notation
-         An Error Controller for ODE Solvers: Notation
-         Subgraph Dependency Sparsity Patterns: Notation
-         Reverse Mode Using Subgraphs: Notation
-         Any Order Reverse Mode: Notation
-         Multiple Directions Forward Mode: Notation
-         Multiple Order Forward Mode: Notation
-         Required Base Class Member Functions: Notation
-         AD Theory for Cholesky Factorization: Notation
-nr Sparse Matrix Row, Column, Value Representation: nr
-   Row and Column Index Sparsity Patterns: nr
-   abs_normal: Print a Vector or Matrix: nr
-nstep An Error Controller for Gear's Ode Solvers: nstep
-      An Error Controller for ODE Solvers: nstep
-num_bytes Check If A Memory Allocation is Efficient for Another Use: num_bytes
-          Amount of Memory Available for Quick Use by a Thread: num_bytes
-          Amount of Memory a Thread is Currently Using: num_bytes
-          Amount of Memory Available for Quick Use by a Thread: num_bytes
-          Amount of Memory a Thread is Currently Using: num_bytes
-num_itr Defines a User Atomic Operation that Computes Square Root: au.num_itr
-num_solve Timing Test for Multi-Threaded User Atomic Calculation: num_solve
-num_sub Timing Test of Multi-Threaded Newton Method: num_sub
-        A Multi-Threaded Newton's Method: num_sub
-        Set Up Multi-Threaded Newton Method: num_sub
-        Run Multi-Threading Examples and Speed Tests: multi_newton.num_sub
-num_sum Timing Test of Multi-Threaded Newton Method: num_sum
-        Multi-Threaded Implementation of Summation of 1/i: num_sum
-        Set Up Multi-threading Sum of 1/i: num_sum
-        Run Multi-Threading Examples and Speed Tests: multi_newton.num_sum
-num_threads Setup thread_alloc For Use in Multi-Threading Environment: num_threads
-            Timing Test of Multi-Threaded Newton Method: num_threads
-            A Multi-Threaded Newton's Method: num_threads
-            Set Up Multi-Threaded Newton Method: num_threads
-            Timing Test for Multi-Threaded User Atomic Calculation: num_threads
-            Timing Test of Multi-Threaded Summation of 1/i: num_threads
-num_zero Timing Test of Multi-Threaded Newton Method: num_zero
-         Run Multi-Threading Examples and Speed Tests: multi_newton.num_zero
-number Returns Elapsed Number of Seconds
-       Repeat det_by_minor Routine A Specified Number of Times
-       Set Maximum Number of Threads for omp_alloc Allocator: number
-       Set Maximum Number of Threads for omp_alloc Allocator
-       Get the Current OpenMP Thread Number
-       Set and Get Maximum Number of Threads for omp_alloc Allocator: number
-       Set and Get Maximum Number of Threads for omp_alloc Allocator
-       OpenMP Parallel Setup: number
-       Microsoft Version of Elapsed Number of Seconds
-       Get the Current Thread Number
-       Get Number of Threads: number
-       Get Number of Threads
-       Returns Elapsed Number of Seconds
-       Using CppAD in a Multi-Threading Environment
-       Number of Variables That Can be Skipped: Example and Test
-       Number of Variables that Can be Skipped
-       Comparison Changes Between Taping and Zero Order Forward: number
-       Number Taylor Coefficient Orders Currently Stored
-       Using CMake to Configure CppAD
-number_skip Number of Variables That Can be Skipped: Example and Test
-            Number of Variables that Can be Skipped
-numbervector Nonlinear Programming Using the CppAD Interface to Ipopt: NumberVector
-numeric Use Ipopt to Solve a Nonlinear Programming Problem: options.Numeric
-        Check NumericType Class Concept
-        Definition of a Numeric Type
-        Base Type Requirements for Numeric Limits
-        AD<Base> Requirements for a CppAD Base Type: Numeric Type
-        Numeric Limits: Example and Test
-        Numeric Limits For an AD and Base Types
-numeric_limits Enable use of AD<Base> where Base is std::complex<double>: numeric_limits
-               Enable use of AD<Base> where Base is double: numeric_limits
-               Enable use of AD<Base> where Base is float: numeric_limits
-               Enable use of AD<Base> where Base is Adolc's adouble Type: numeric_limits
-               Example AD<Base> Where Base Constructor Allocates Memory: numeric_limits
-numerical Some Numerical AD Utilities
-          Bibliography: Numerical Recipes
-          Some General Purpose Utilities: General Numerical Routines
-numerictype Check NumericType Class Concept
-numerictype: The NumericType: Example and Test
-numtraits Enable Use of Eigen Linear Algebra Package with CppAD: Eigen NumTraits
- -O -
-Ode An Arbitrary Order Gear Method
-OdeErrControl OdeErrControl: Example and Test Using Maxabs Argument
-              An Error Controller for ODE Solvers
-OdeGear OdeGear: Example and Test
-        An Arbitrary Order Gear Method
-OdeGearControl OdeGearControl: Example and Test
-               An Error Controller for Gear's Ode Solvers
-OpenMP A Simple Parallel Pthread Example and Test
-obj_value Nonlinear Programming Using the CppAD Interface to Ipopt: solution.obj_value
-          Use Ipopt to Solve a Nonlinear Programming Problem: solution.obj_value
-object ADFun Object Deprecated Member Functions
-       Creating Your Own Interface to an ADFun Object
-       Object that Runs a Group of Tests
-       Check an ADFun Object For Nan Results
-       Optimize an ADFun Object Tape
-       Construct an ADFun Object and Stop Recording
-       Create an ADFun Object (Record an Operation Sequence)
-       Is an AD Object a Parameter or Variable
-       AD Assignment: Example and Test
-       AD Constructors: Example and Test
-objective Computing Jacobian and Hessian of Bender's Reduced Objective
-          ODE Fitting Using Fast Representation: Objective Function
-          ODE Fitting Using Simple Representation: Objective Function
-objects ADFun Objects
-        Compare AD and Base Objects for Nearly Equal
-        Conversion and I/O of AD Objects
-        AD Objects
-objects: Compare AD with Base Objects: Example and Test
-obtain Obtain Nan or Determine if a Value is Nan
-       Convert an AD Variable to a Parameter
-ode Driver for Running the Ipopt ODE Example
-    ODE Fitting Using Fast Representation
-    ODE Fitting Using Simple Representation
-    ODE Inverse Problem Definitions: Source Code
-    ODE Fitting Using Fast Representation
-    ODE Fitting Using Simple Representation
-    An ODE Inverse Problem Example
-    Sacado Speed: Gradient of Ode Solution
-    Fadbad Speed: Ode
-    CppAD Speed: Gradient of Ode Solution
-    Adolc Speed: Ode
-    Double Speed: Ode Solution
-    Evaluate a Function Defined in Terms of an ODE
-    Speed Testing the Jacobian of Ode Solution
-    Taylor's Ode Solver: An Example and Test: ODE Solution
-    Taylor's Ode Solver: An Example and Test: ODE
-    Taylor's Ode Solver: An Example and Test
-    Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Derivative of ODE Solution
-    Taylor's Ode Solver: A Multi-Level Adolc Example and Test: ODE Solution
-    Taylor's Ode Solver: A Multi-Level Adolc Example and Test: ODE
-    Taylor's Ode Solver: A Multi-Level Adolc Example and Test
-    Taylor's Ode Solver: A Multi-Level AD Example and Test: Derivative of ODE Solution
-    Taylor's Ode Solver: A Multi-Level AD Example and Test: ODE Solution
-    Taylor's Ode Solver: A Multi-Level AD Example and Test: ODE
-    Taylor's Ode Solver: A Multi-Level AD Example and Test
-    A Stiff Ode: Example and Test
-    ODE Inverse Problem Definitions: Source Code
-    An Error Controller for Gear's Ode Solvers
-    An Error Controller for ODE Solvers
-    A 3rd and 4th Order Rosenbrock ODE Solver
-    An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-    Checkpointing an Extended ODE Solver: Example and Test: ODE
-    Checkpointing an Extended ODE Solver: Example and Test: ODE Solver
-    Checkpointing an Extended ODE Solver: Example and Test
-    Checkpointing an ODE Solver: Example and Test: ODE
-    Checkpointing an ODE Solver: Example and Test: ODE Solver
-    Checkpointing an ODE Solver: Example and Test
-ode: A Stiff Ode: Example and Test
-ode_evaluate Source: ode_evaluate
-             ode_evaluate: Example and test
-             Evaluate a Function Defined in Terms of an ODE
-ode_evaluate: ode_evaluate: Example and test
-ode_inverse Use Ipopt to Solve a Nonlinear Programming Problem: Example.ode_inverse
-odeerrcontrol: OdeErrControl: Example and Test Using Maxabs Argument
-               OdeErrControl: Example and Test
-odegear: OdeGear: Example and Test
-odegearcontrol: OdeGearControl: Example and Test
-ok User Defined Atomic AD Functions: ok
-   Check Gradient of Determinant of 3 by 3 matrix: ok
-   Check Determinant of 3 by 3 matrix: ok
-   Free All Memory That Was Allocated for Use by thread_alloc: ok
-   Object that Runs a Group of Tests: ok
-   Specifications for A Team of AD Threads: ok
-   Timing Test of Multi-Threaded Newton Method: ok
-   A Multi-Threaded Newton's Method: ok
-   Timing Test for Multi-Threaded User Atomic Calculation: ok
-   Run Multi-Threaded User Atomic Calculation: ok
-   Multi-Threaded User Atomic Take Down: ok
-   Multi-Threaded User Atomic Set Up: ok
-   Timing Test of Multi-Threaded Summation of 1/i: ok
-   Multi-Threaded Implementation of Summation of 1/i: ok
-   Check an ADFun Sequence of Operations: ok
-   abs_normal: Solve a Quadratic Program With Box Constraints: ok
-   Solve a Quadratic Program Using Interior Point Method: ok
-   abs_normal: Solve a Linear Program With Box Constraints: ok
-   abs_normal: Solve a Linear Program Using Simplex Method: ok
-   Atomic Reverse Jacobian Sparsity Patterns: ok
-   Atomic Forward Jacobian Sparsity Patterns: ok
-   Atomic Reverse Mode: ok
-   Atomic Forward Mode: ok
-old Old Matrix Multiply as a User Atomic Operation: Example and Test
-    Old Tan and Tanh as User Atomic Operations: Example and Test
-    Old Atomic Operation Reciprocal: Example and Test
-    Calculating Sparse Derivatives: Old Sparsity Patterns
-    Calculating Sparsity Patterns: Old Sparsity Patterns
-old_atomic Define Matrix Multiply as a User Atomic Operation
-           User Defined Atomic AD Functions
-old_mat_mul Define Matrix Multiply as a User Atomic Operation
-oldptr Routines That Track Use of New and Delete: oldptr
-omp_alloc Set Maximum Number of Threads for omp_alloc Allocator
-          Return Memory to omp_alloc
-          Set and Get Maximum Number of Threads for omp_alloc Allocator
-omp_max_thread OpenMP Parallel Setup
-on Computing Reverse Mode on Subgraphs: Example and Test
-one Define Matrix Multiply as a User Atomic Operation: Reverse Partials One Order
-    Define Matrix Multiply as a User Atomic Operation: One Matrix Multiply
-    One Dimensional Romberg Integration: Example and Test
-    One Dimensional Romberg Integration: Example and Test
-    One DimensionalRomberg Integration
-    Run One Speed Test and Print Results
-    Run One Speed Test and Return Results
-    Do One Thread's Work for Multi-Threaded Newton Method
-    Do One Thread's Work for Sum of 1/i
-    Multiple Order Forward Mode: yq.One Order
-    Multiple Order Forward Mode: xq.One Order
-    Multiple Order Forward Mode: One Order
-    First Order Forward Mode: Derivative Values
-    The Logarithm of One Plus Argument: log1p
-one: The Exponential Function Minus One: expm1
-onetape Running the Speed Test Program: Global Options.onetape
-op AD Binary Comparison Operators: Op
-   Atomic Eigen Cholesky Factorization Class: Public.op
-   Atomic Eigen Matrix Inversion Class: Public.op
-   Atomic Eigen Matrix Multiply Class: Public.op
-   AD Compound Assignment Operators: Op
-   AD Binary Arithmetic Operators: Op
-op_index Comparison Changes Between Taping and Zero Order Forward: op_index
-openmp OpenMP Memory Allocator: Example and Test
-       Get the Current OpenMP Thread Number
-       Is The Current Execution in OpenMP Parallel Mode
-       A Quick OpenMP Memory Allocator Used by CppAD
-       OpenMP Parallel Setup
-       Fast Multi-Threading Memory Allocator: Example and Test
-       OpenMP Implementation of a Team of AD Threads
-       A Simple OpenMP AD: Example and Test
-       A Simple OpenMP Example and Test
-openmp/run.sh Changes and Additions to CppAD During 2011: 07-11.openmp/run.sh
-openmp_flags Autotools Unix Test and Installation: openmp_flags
-operand Matrix Multiply as an Atomic Operation: Right Operand Element Index
-        Matrix Multiply as an Atomic Operation: Left Operand Element Index
-operation Define Matrix Multiply as a User Atomic Operation
-          Old Atomic Operation Reciprocal: Example and Test
-          User Defined Atomic AD Functions
-          The CppAD Wish List: Operation Sequence
-          Glossary: Operation
-          Frequently Asked Questions and Answers: Matrix Inverse.Atomic Operation
-          Evaluate a Function Defined in Terms of an ODE: Float.Operation Sequence
-          An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Operation Sequence
-          Evaluate a Polynomial or its Derivative: Operation Sequence
-          The Integer Power Function: Operation Sequence
-          Defines a User Atomic Operation that Computes Square Root
-          Abort Recording of an Operation Sequence
-          Stop Recording and Store Operation Sequence
-          Create an ADFun Object (Record an Operation Sequence)
-          Check if Two Value are Identically Equal
-          Is an AD Object a Parameter or Variable: Operation Sequence
-          AD Boolean Functions: Operation Sequence
-          Compare AD and Base Objects for Nearly Equal: Operation Sequence
-          AD Binary Comparison Operators: Operation Sequence
-          Matrix Multiply as an Atomic Operation
-          Tan and Tanh as User Atomic Operations: Example and Test
-          Atomic AD Functions
-          Taping Array Index Operation: Example and Test
-          Discrete AD Functions: Operation Sequence
-          AD Conditional Expressions: Operation Sequence
-          The AD Power Function: Operation Sequence
-          AD Two Argument Inverse Tangent Function: Operation Sequence
-          AD Compound Assignment Operators: Operation Sequence
-          AD Binary Arithmetic Operators: Operation Sequence
-          AD Unary Minus Operator: Operation Sequence
-          AD Unary Plus Operator: Operation Sequence
-          AD Output Stream Operator: Operation Sequence
-          AD Output Stream Operator: Operation Sequence
-          Convert From AD to Integer: Operation Sequence
-          Convert From an AD Type to its Base Type: Operation Sequence
-          exp_eps: Second Order Forward Mode: Operation Sequence.Operation
-          exp_eps: Second Order Forward Mode: Operation Sequence
-          exp_eps: First Order Forward Sweep: Operation Sequence.Operation
-          exp_eps: First Order Forward Sweep: Operation Sequence
-          exp_eps: Operation Sequence and Zero Order Forward Sweep: Operation Sequence.Operation
-          exp_eps: Operation Sequence and Zero Order Forward Sweep: Operation Sequence
-          exp_eps: Operation Sequence and Zero Order Forward Sweep
-          exp_2: Second Order Forward Mode: Operation Sequence.Operation
-          exp_2: Second Order Forward Mode: Operation Sequence
-          exp_2: First Order Forward Mode: Operation Sequence.Operation
-          exp_2: First Order Forward Mode: Operation Sequence
-          exp_2: Operation Sequence and Zero Order Forward Mode: Operation Sequence.Operation
-          exp_2: Operation Sequence and Zero Order Forward Mode: Operation Sequence
-          exp_2: Operation Sequence and Zero Order Forward Mode
-          An Introduction by Example to Algorithmic Differentiation: Preface.Operation Count
-operation: Old Matrix Multiply as a User Atomic Operation: Example and Test
-           Reciprocal as an Atomic Operation: Example and Test
-           Taping Array Index Operation: Example and Test
-operations The CppAD Wish List: Atomic.Element-wise Operations
-           Evaluate a Polynomial or its Derivative: Type.Operations
-           Check an ADFun Sequence of Operations
-           Example Optimization and Cumulative Sum Operations
-           Optimize an ADFun Object Tape
-           AD Vectors that Record Index Operations
-           Bool Valued Operations and Functions with AD Arguments
-           Atomic Operations and Multiple-Levels of AD: Example and Test
-           AD Valued Operations and Functions
-operations: Old Tan and Tanh as User Atomic Operations: Example and Test
-            AD Vectors that Record Index Operations: Example and Test
-            Tan and Tanh as User Atomic Operations: Example and Test
-            Getting Started with Atomic Operations: Example and Test
-operator Speed Test an Operator Overloading AD Package
-         Construct an ADFun Object and Stop Recording: Example.Assignment Operator
-         Construct an ADFun Object and Stop Recording: Assignment Operator
-         Example AD<Base> Where Base Constructor Allocates Memory: Output Operator
-         Example AD<Base> Where Base Constructor Allocates Memory: Boolean Operator Macro
-         Example AD<Base> Where Base Constructor Allocates Memory: Binary Operator Macro
-         AD<Base> Requirements for a CppAD Base Type: Output Operator
-         AD Unary Minus Operator
-         AD Unary Plus Operator
-         AD Output Stream Operator
-         AD Output Stream Operator
-         AD Assignment Operator
-operator: AD Unary Minus Operator: Example and Test
-          AD Unary Plus Operator: Example and Test
-          AD Output Operator: Example and Test
-          AD Output Operator: Example and Test
-operators zdouble: An AD Base Type With Absolute Zero: Syntax.Arithmetic Operators
-          zdouble: An AD Base Type With Absolute Zero: Syntax.Comparison Operators
-          The CppAD Wish List: Optimization.Special Operators
-          The Theory of Reverse Mode: Binary Operators
-          The Theory of Forward Mode: Binary Operators
-          Definition of a Numeric Type: Operators
-          Example Optimization and Print Forward Operators
-          Example Optimization and Comparison Operators
-          Required Base Class Member Functions: Bool Operators
-          Required Base Class Member Functions: Binary Operators
-          Required Base Class Member Functions: Assignment Operators
-          Required Base Class Member Functions: Unary Operators
-          AD Binary Comparison Operators
-          AD Compound Assignment Operators
-          AD Binary Arithmetic Operators
-          AD Arithmetic Operators and Compound Assignments
-operators: AD Binary Comparison Operators: Example and Test
-opt_val_hes opt_val_hes: Example and Test
-            Jacobian and Hessian of Optimal Values
-opt_val_hes: opt_val_hes: Example and Test
-optimal Jacobian and Hessian of Optimal Values
-optimization The CppAD Wish List: Optimization
-             A 3rd and 4th Order Rosenbrock ODE Solver: Fun.Optimization
-             Non-Smooth Optimization Using Abs-normal Quadratic Approximations
-             Non-Smooth Optimization Using Abs-normal Linear Approximations
-             Example Optimization and Cumulative Sum Operations
-             Example Optimization and Nested Conditional Expressions
-             Example Optimization and Conditional Expressions
-             Example Optimization and Print Forward Operators
-             Example Optimization and Comparison Operators
-             Example Optimization and Reverse Activity Analysis
-             Example Optimization and Forward Activity Analysis
-             Optimize an ADFun Object Tape: Checking Optimization
-optimize Frequently Asked Questions and Answers: Speed.Optimize
-         Running the Speed Test Program: Global Options.optimize
-         Optimize an ADFun Object Tape
-         Number of Variables That Can be Skipped: Example and Test
-         Checkpointing Functions: optimize
-         AD Conditional Expressions: Optimize
-option User Atomic Matrix Multiply: Example and Test: Use Atomic Function.option
-       Checkpointing Functions: option
-options Running the Speed Test Program: Sparsity Options
-        Running the Speed Test Program: Global Options
-        Use Ipopt to Solve a Nonlinear Programming Problem: options
-        Optimize an ADFun Object Tape: options
-        Set Atomic Function Options
-order Define Matrix Multiply as a User Atomic Operation: Reverse Partials One Order
-      Comparison Changes During Zero Order Forward Mode
-      ADFun Object Deprecated Member Functions: Order
-      Error Function Reverse Mode Theory: Order Zero Z(t)
-      Tangent and Hyperbolic Tangent Reverse Mode Theory: Order Zero Z(t)
-      An Arbitrary Order Gear Method
-      An Error Controller for ODE Solvers: Method.order
-      A 3rd and 4th Order Rosenbrock ODE Solver
-      An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-      abs_normal: Evaluate First Order Approximation
-      Third Order Reverse Mode: Example and Test
-      Any Order Reverse Mode: Second Order
-      Any Order Reverse Mode: First Order
-      Any Order Reverse Mode
-      Second Order Reverse ModeExample and Test
-      Second Order Reverse Mode: dw.Second Order Partials
-      Second Order Reverse Mode: dw.First Order Partials
-      Second Order Reverse Mode
-      First Order Reverse Mode: Example and Test
-      First Order Reverse Mode
-      Comparison Changes Between Taping and Zero Order Forward
-      Forward Mode: Example and Test of Multiple Directions
-      Multiple Directions Forward Mode: Zero Order
-      Multiple Order Forward Mode: Second Order
-      Multiple Order Forward Mode: First Order
-      Multiple Order Forward Mode: Zero Order
-      Multiple Order Forward Mode: yq.One Order
-      Multiple Order Forward Mode: xq.One Order
-      Multiple Order Forward Mode: One Order
-      Multiple Order Forward Mode
-      Second Order Forward Mode: Derivative Values
-      First Order Forward Mode: Derivative Values
-      Zero Order Forward Mode: Function Values
-      Reverse Mode Second Partial Derivative Driver
-      Subset of Second Order Partials: Example and Test
-      Forward Mode Second Partial Derivative Driver
-      First Order Derivative Driver: Example and Test
-      First Order Derivative: Driver Routine
-      First Order Partial Driver: Example and Test
-      First Order Partial Derivative: Driver Routine
-      First and Second Order Derivatives: Easy Drivers
-      Enable use of AD<Base> where Base is std::complex<double>: Include Order
-      AD<Base> Requirements for a CppAD Base Type: Include Order
-      Print During Zero Order Forward Mode: Example and Test
-      exp_eps: Verify Second Order Reverse Sweep
-      exp_eps: Verify Second Order Forward Sweep
-      exp_eps: Verify First Order Reverse Sweep
-      exp_eps: Verify First Order Forward Sweep
-      exp_eps: Verify Zero Order Forward Sweep
-      exp_eps: Second Order Reverse Sweep
-      exp_eps: Second Order Forward Mode: Second Order Expansion
-      exp_eps: Second Order Forward Mode
-      exp_eps: First Order Reverse Sweep
-      exp_eps: First Order Forward Sweep: Operation Sequence.First Order
-      exp_eps: First Order Forward Sweep: Operation Sequence.Zero Order
-      exp_eps: First Order Forward Sweep: First Order Expansion
-      exp_eps: First Order Forward Sweep
-      exp_eps: Operation Sequence and Zero Order Forward Sweep: Operation Sequence.Zero Order
-      exp_eps: Operation Sequence and Zero Order Forward Sweep
-      exp_2: Verify Second Order Reverse Sweep
-      exp_2: Verify Second Order Forward Sweep
-      exp_2: Verify First Order Reverse Sweep
-      exp_2: Verify First Order Forward Sweep
-      exp_2: Verify Zero Order Forward Sweep
-      exp_2: Second Order Reverse Mode
-      exp_2: Second Order Forward Mode: Second Order Expansion
-      exp_2: Second Order Forward Mode
-      exp_2: First Order Reverse Mode
-      exp_2: First Order Forward Mode: Operation Sequence.First Order
-      exp_2: First Order Forward Mode: Operation Sequence.Zero Order
-      exp_2: First Order Forward Mode: First Order Expansion
-      exp_2: First Order Forward Mode
-      exp_2: Operation Sequence and Zero Order Forward Mode: Operation Sequence.Zero Order
-      exp_2: Operation Sequence and Zero Order Forward Mode: Zero Order Expansion
-      exp_2: Operation Sequence and Zero Order Forward Mode
-      Second Order Exponential Approximation
-ordered Enable use of AD<Base> where Base is std::complex<double>: Ordered
-        Enable use of AD<Base> where Base is double: Ordered
-        Enable use of AD<Base> where Base is float: Ordered
-        Enable use of AD<Base> where Base is Adolc's adouble Type: Ordered
-        Example AD<Base> Where Base Constructor Allocates Memory: Ordered
-        Base Type Requirements for Ordered Comparisons: Not Ordered
-        Base Type Requirements for Ordered Comparisons: Ordered Type
-        Base Type Requirements for Ordered Comparisons
-        Base Type Requirements for Conditional Expressions: CondExpTemplate.Not Ordered
-        Base Type Requirements for Conditional Expressions: CondExpTemplate.Ordered Type
-orders Error Function Reverse Mode Theory: Positive Orders Z(t)
-       Tangent and Hyperbolic Tangent Reverse Mode Theory: Positive Orders Z(t)
-       Number Taylor Coefficient Orders Currently Stored
-       Forward Mode: Example and Test of Multiple Directions
-       Multiple Directions Forward Mode: Non-Zero Lower Orders
-       Forward Mode: Example and Test of Multiple Orders
-       Multiple Order Forward Mode: yq.Multiple Orders
-       Multiple Order Forward Mode: xq.Multiple Orders
-original Controlling Taylor Coefficients Memory Allocation: Original State
-os AD Output Stream Operator: os
-other Example and Test Linking CppAD to Languages Other than C++
-out Interpolation With Out Retaping: Example and Test
-outer Using Multiple Levels of AD: Procedure.Derivatives of Outer Function
-      Using Multiple Levels of AD: Procedure.Outer Function
-outline An Introduction by Example to Algorithmic Differentiation: Outline
-output Getting Started Using CppAD to Compute Derivatives: Output
-       The CppAD::vector Template Class: vectorBool.Output
-       The CppAD::vector Template Class: Output
-       Example Use of SpeedTest: Output
-       Example AD<Base> Where Base Constructor Allocates Memory: Output Operator
-       AD<Base> Requirements for a CppAD Base Type: Output Operator
-       Printing During Forward Mode: Example and Test: Output
-       Printing AD Values During Forward Mode: Redirecting Output
-       Printing AD Values During Forward Mode
-       AD Output Operator: Example and Test
-       AD Output Operator: Example and Test
-       AD Output Stream Operator
-       AD Output Stream Operator
-overloading Speed Test an Operator Overloading AD Package
-own Creating Your Own Interface to an ADFun Object
- -P -
-Parameter ADFun Sequence Properties: Example and Test
-Poly Evaluate a Polynomial or its Derivative
-p LU Factorization of A Square Matrix and Stability Calculation: LU.P
-  Evaluate a Function That Has a Sparse Hessian: p
-  Evaluate a Function That Has a Sparse Jacobian: p
-  Evaluate a Function Defined in Terms of an ODE: p.p = 1
-  Evaluate a Function Defined in Terms of an ODE: p.p == 0
-  Evaluate a Function Defined in Terms of an ODE: p
-  Multi-dimensional Romberg Integration: p
-  One DimensionalRomberg Integration: p
-  Invert an LU Factored Equation: LU.P
-  LU Factorization of A Square Matrix: LU.P
-  Evaluate a Polynomial or its Derivative: p
-  Sparse Hessian: work.p
-  Sparse Hessian: p
-  Sparse Jacobian: work.p
-  Sparse Jacobian: p
-  Atomic Forward Mode: p
-pack_sparsity_enum Set Atomic Function Options: atomic_sparsity.pack_sparsity_enum
-package Running the Speed Test Program: package.AD Package
-        Running the Speed Test Program: package
-        Speed Test an Operator Overloading AD Package
-        Enable Use of Eigen Linear Algebra Package with CppAD
-        Using CMake to Configure CppAD
-        cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-package_prefix Using CMake to Configure CppAD: package_prefix
-parallel User Defined Atomic AD Functions: afun.Parallel Mode
-         Is The Current Execution in OpenMP Parallel Mode
-         OpenMP Parallel Setup
-         Is The Current Execution in Parallel Mode
-         Setup thread_alloc For Use in Multi-Threading Environment
-         The CppAD::vector Template Class: Memory and Parallel Mode
-         A 3rd and 4th Order Rosenbrock ODE Solver: Parallel Mode
-         An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Parallel Mode
-         Check Simple Vector Concept: Parallel Mode
-         Check NumericType Class Concept: Parallel Mode
-         Replacing the CppAD Error Handler: Constructor.Parallel Mode
-         A Simple Parallel Pthread Example and Test
-         Enable AD Calculations During Parallel Mode
-         Using CppAD in a Multi-Threading Environment: Parallel Prohibited
-         Using CppAD in a Multi-Threading Environment: Parallel AD
-         Stop Recording and Store Operation Sequence: Parallel Mode
-         Construct an ADFun Object and Stop Recording: Parallel Mode
-         Declare Independent Variables and Start Recording: Parallel Mode
-         Discrete AD Functions: Parallel Mode
-parallel_setup Using CppAD in a Multi-Threading Environment: parallel_setup
-parameter An ODE Inverse Problem Example: Measurements.Simulation Parameter Values
-          Glossary: Parameter
-          ODE Inverse Problem Definitions: Source Code: Measurements.Simulation Parameter Values
-          ADFun Sequence Properties: Parameter
-          AD Parameter and Variable Functions: Example and Test
-          Is an AD Object a Parameter or Variable
-          Atomic Reverse Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-          Atomic Forward Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-          Atomic Reverse Jacobian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-          Atomic Forward Jacobian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-          Convert an AD Variable to a Parameter
-          exp_eps: Operation Sequence and Zero Order Forward Sweep: Operation Sequence.Parameter
-parameter: Convert an AD Variable to a Parameter: Example and Test
-part AD Theory for Cholesky Factorization: Notation.Lower Triangular Part
-partial User Defined Atomic AD Functions: Partial Implementation
-        Reverse Mode Second Partial Derivative Driver
-        Subset of Second Order Partials: Example and Test
-        Forward Mode Second Partial Derivative Driver
-        First Order Partial Driver: Example and Test
-        First Order Partial Derivative: Driver Routine
-partials Define Matrix Multiply as a User Atomic Operation: Reverse Partials One Order
-         Second Order Reverse Mode: dw.Second Order Partials
-         Second Order Reverse Mode: dw.First Order Partials
-         Second Partials Reverse Driver: Example and Test
-partials: Subset of Second Order Partials: Example and Test
-pattern Glossary: Sparsity Pattern
-        Sparse Matrix Row, Column, Value Representation: pattern
-        Row and Column Index Sparsity Patterns: pattern
-        Computing Sparse Hessians: pattern
-        Computing Sparse Jacobians: pattern
-        Computing Dependency: Example and Test: Dependency Pattern
-        Hessian Sparsity Pattern: Reverse Mode: Entire Sparsity Pattern
-        Jacobian Sparsity Pattern: Reverse Mode: Entire Sparsity Pattern
-        Jacobian Sparsity Pattern: Forward Mode: Entire Sparsity Pattern
-pattern: Hessian Sparsity Pattern: Forward Mode
-         Hessian Sparsity Pattern: Reverse Mode
-         Jacobian Sparsity Pattern: Reverse Mode
-         Jacobian Sparsity Pattern: Forward Mode
-pattern_in Reverse Mode Jacobian Sparsity Patterns: pattern_in
-           Forward Mode Jacobian Sparsity Patterns: pattern_in
-pattern_out Subgraph Dependency Sparsity Patterns: pattern_out
-            Forward Mode Hessian Sparsity Patterns: pattern_out
-            Reverse Mode Hessian Sparsity Patterns: pattern_out
-            Reverse Mode Jacobian Sparsity Patterns: pattern_out
-            Forward Mode Jacobian Sparsity Patterns: pattern_out
-patterns Row and Column Index Sparsity Patterns
-         Subgraph Dependency Sparsity Patterns
-         Forward Mode Hessian Sparsity Patterns
-         Sparsity Patterns For a Subset of Variables: Example and Test
-         Reverse Mode Hessian Sparsity Patterns
-         Reverse Mode Jacobian Sparsity Patterns
-         Forward Mode Jacobian Sparsity Patterns
-         Construct an ADFun Object and Stop Recording: Assignment Operator.Sparsity Patterns
-         Calculating Sparse Derivatives: Old Sparsity Patterns
-         Calculating Sparse Derivatives: Preferred Sparsity Patterns
-         Calculating Sparsity Patterns: Old Sparsity Patterns
-         Calculating Sparsity Patterns: Preferred Sparsity Patterns
-         Calculating Sparsity Patterns
-         Atomic Reverse Hessian Sparsity Patterns
-         Atomic Forward Hessian Sparsity Patterns
-         Atomic Reverse Jacobian Sparsity Patterns
-         Atomic Forward Jacobian Sparsity Patterns
-         User Defined Atomic AD Functions: Examples.Hessian Sparsity Patterns
-patterns: Subgraph Dependency Sparsity Patterns: Example and Test
-          Preferred Sparsity Patterns: Row and Column Indices: Example and Test
-          Atomic Sparsity with Set Patterns: Example and Test
-pc CppAD pkg-config Files
-pivot Lu Factor and Solve With Recorded Pivoting: Example and Test
-pivoting Lu Factor and Solve with Recorded Pivoting
-pivoting: Lu Factor and Solve With Recorded Pivoting: Example and Test
-pkg-config CppAD pkg-config Files
-planes abs_normal: Minimize a Linear Abs-normal Approximation: Method.Cutting Planes
-       abs_normal: Minimize a Linear Abs-normal Approximation: Method.Cutting Planes
-plus The Logarithm of One Plus Argument: log1p
-     AD Compound Assignment Division: Example and Test
-     AD Compound Assignment Multiplication: Example and Test
-     AD Compound Assignment Subtraction: Example and Test
-     AD Compound Assignment Addition: Example and Test
-     AD Compound Assignment Operators
-     AD Binary Addition: Example and Test
-     AD Binary Arithmetic Operators
-     AD Unary Plus Operator: Example and Test
-     AD Unary Plus Operator
-point Solve a Quadratic Program Using Interior Point Method
-      Extending to_string To Another Floating Point Type
-pointer CppAD API Preprocessor Symbols
-poly Getting Started Using CppAD to Compute Derivatives: Poly
-     Source: Poly
-     Complex Polynomial: Example and Test: Poly
-polynomial Error Function Forward Taylor Polynomial Theory
-           Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory
-           Sacado Speed: Second Derivative of a Polynomial
-           Fadbad Speed: Second Derivative of a Polynomial
-           CppAD Speed: Second Derivative of a Polynomial
-           Adolc Speed: Second Derivative of a Polynomial
-           Double Speed: Evaluate a Polynomial
-           Speed Testing Second Derivative of a Polynomial
-           Polynomial Evaluation: Example and Test
-           Evaluate a Polynomial or its Derivative
-           Complex Polynomial: Example and Test
-polynomial: Complex Polynomial: Example and Test
-pos Printing AD Values During Forward Mode: pos
-positive Error Function Reverse Mode Theory: Positive Orders Z(t)
-         Tangent and Hyperbolic Tangent Reverse Mode Theory: Positive Orders Z(t)
-possible The Unary Standard Math Functions: Possible Types
-postfix Using CMake to Configure CppAD
-postfix_dir Autotools Unix Test and Installation: postfix_dir
-pow The Pow Integer Exponent: Example and Test
-    The Integer Power Function
-    Enable use of AD<Base> where Base is std::complex<double>: pow
-    Enable use of AD<Base> where Base is double: pow
-    Enable use of AD<Base> where Base is float: pow
-    Enable use of AD<Base> where Base is Adolc's adouble Type: pow
-    Example AD<Base> Where Base Constructor Allocates Memory: pow
-    Base Type Requirements for Standard Math Functions: pow
-    The AD Power Function
-power The Integer Power Function
-      The AD Power Function: Example and Test
-      The AD Power Function
-pre-allocating Controlling Taylor Coefficients Memory Allocation: c.Pre-Allocating Memory
-preface An Introduction by Example to Algorithmic Differentiation: Preface
-preferred Preferred Sparsity Patterns: Row and Column Indices: Example and Test
-          Calculating Sparse Derivatives: Preferred Sparsity Patterns
-          Calculating Sparsity Patterns: Preferred Sparsity Patterns
-prefix Download and Install Sacado in Build Directory: Prefix Directory
-       Including the Sacado Speed Tests
-       Download and Install Ipopt in Build Directory: Prefix Directory
-       Including the cppad_ipopt Library and Tests
-       Download and Install Fadbad in Build Directory: Prefix Directory
-       Including the FADBAD Speed Tests
-       Download and Install Eigen in Build Directory: Prefix Directory
-       Including the Eigen Examples and Tests
-       Download and Install ColPack in Build Directory: Prefix Directory
-       Including the ColPack Sparsity Calculations
-       Download and Install Adolc in Build Directory: Prefix Directory
-       Including the ADOL-C Examples and Tests
-       Using CMake to Configure CppAD
-prefix_dir Autotools Unix Test and Installation: prefix_dir
-preprocessor CppAD Addons: Preprocessor Symbols
-             Frequently Asked Questions and Answers: Namespace.Test Vector Preprocessor Symbol
-             CppAD API Preprocessor Symbols
-             cppad-20180000.0: A Package for Differentiation of C++ Algorithms: Preprocessor Symbols
-previous Changes and Additions to CppAD: Previous Years
-previously Routines That Track Use of New and Delete: TrackCount.Previously Deprecated
-           Routines That Track Use of New and Delete: TrackExtend.Previously Deprecated
-           Routines That Track Use of New and Delete: TrackDelVec.Previously Deprecated
-           Routines That Track Use of New and Delete: TrackNewVec.Previously Deprecated
-print Run One Speed Test and Print Results
-      abs_normal: Print a Vector or Matrix
-      Example Optimization and Print Forward Operators
-      Print During Zero Order Forward Mode: Example and Test
-      Printing During Forward Mode: Example and Test
-      Printing AD Values During Forward Mode
-printing Printing During Forward Mode: Example and Test
-         Printing AD Values During Forward Mode
-private Atomic Eigen Cholesky Factorization Class: Private
-        Atomic Eigen Matrix Inversion Class: Private
-        Atomic Eigen Matrix Multiply Class: Private
-problem Computing Jacobian and Hessian of Bender's Reduced Objective: Problem
-        ODE Inverse Problem Definitions: Source Code
-        An ODE Inverse Problem Example: Inverse Problem
-        An ODE Inverse Problem Example: Forward Problem
-        An ODE Inverse Problem Example
-        Example Simultaneous Solution of Forward and Inverse Problem
-        ODE Inverse Problem Definitions: Source Code: Inverse Problem
-        ODE Inverse Problem Definitions: Source Code: Forward Problem
-        ODE Inverse Problem Definitions: Source Code
-        Use Ipopt to Solve a Nonlinear Programming Problem
-        abs_normal qp_box: Example and Test: Problem
-        abs_normal: Solve a Quadratic Program With Box Constraints: Problem
-        abs_normal qp_interior: Example and Test: Problem
-        Solve a Quadratic Program Using Interior Point Method: Problem
-        abs_normal lp_box: Example and Test: Problem
-        abs_normal: Solve a Linear Program With Box Constraints: Problem
-        abs_normal simplex_method: Example and Test: Problem
-        abs_normal: Solve a Linear Program Using Simplex Method: Problem
-        Checkpointing an Extended ODE Solver: Example and Test: Problem
-        Checkpointing an ODE Solver: Example and Test: Problem
-procedure Using Multiple Levels of AD: Procedure
-processing Reverse Mode General Case (Checkpointing): Example and Test: Processing Steps
-product Atomic Eigen Matrix Inversion Class: Theory.Product of Three Matrices
-        Atomic Eigen Matrix Multiply Class: Theory.Product of Two Matrices
-profile Running the Speed Test Program: package.profile
-        Using CMake to Configure CppAD
-profiling Autotools Unix Test and Installation: Profiling CppAD
-program Main Program For Comparing C and C++ Speed
-        Speed Testing Utilities: Speed Main Program
-        Running the Speed Test Program
-        Run the Speed Examples
-        Getting Started Using CppAD to Compute Derivatives: Program
-        Example Use of SpeedTest: Program
-        Example Use of SpeedTest: Running This Program
-        Run Multi-Threading Examples and Speed Tests: program
-        abs_normal: Solve a Quadratic Program With Box Constraints
-        Solve a Quadratic Program Using Interior Point Method
-        abs_normal: Solve a Linear Program With Box Constraints
-        abs_normal: Solve a Linear Program Using Simplex Method
-        Using CMake to Configure CppAD: The CMake Program
-programming Nonlinear Programming Using CppAD and Ipopt: Example and Test
-            Nonlinear Programming Using the CppAD Interface to Ipopt
-            Bibliography: The C++ Programming Language
-            Nonlinear Programming Retaping: Example and Test
-            Nonlinear Programming Using CppAD and Ipopt: Example and Test
-            Use Ipopt to Solve a Nonlinear Programming Problem
-prohibited Using CppAD in a Multi-Threading Environment: Parallel Prohibited
-projection Nonlinear Programming Using the CppAD Interface to Ipopt: fg(x).Projection
-proof An Important Reverse Mode Identity: Proof
-      AD Theory for Cholesky Factorization: Lemma 1.Proof
-properties ADFun Sequence Properties
-properties: ADFun Sequence Properties: Example and Test
-prototype Speed Testing Sparse Jacobian: Prototype
-          Speed Testing Sparse Hessian: Prototype
-          Speed Testing Second Derivative of a Polynomial: Prototype
-          Speed Testing the Jacobian of Ode Solution: Prototype
-          Speed Testing Derivative of Matrix Multiply: Prototype
-          Speed Testing Gradient of Determinant by Minor Expansion: Prototype
-          Speed Testing Gradient of Determinant Using Lu Factorization: Prototype
-          Non-Smooth Optimization Using Abs-normal Quadratic Approximations: Prototype
-          abs_normal: Minimize a Linear Abs-normal Approximation: Prototype
-          abs_normal: Solve a Quadratic Program With Box Constraints: Prototype
-          Solve a Quadratic Program Using Interior Point Method: Prototype
-          Non-Smooth Optimization Using Abs-normal Linear Approximations: Prototype
-          abs_normal: Minimize a Linear Abs-normal Approximation: Prototype
-          abs_normal: Solve a Linear Program With Box Constraints: Prototype
-          abs_normal: Solve a Linear Program Using Simplex Method: Prototype
-          abs_normal: Evaluate First Order Approximation: Prototype
-          abs_normal: Print a Vector or Matrix: Prototype
-prototypes Base Type Requirements for Identically Equal Comparisons: Identical.Prototypes
-pthread Fast Multi-Threading Memory Allocator: Example and Test
-        Pthread Implementation of a Team of AD Threads
-        A Simple pthread AD: Example and Test
-        A Simple Parallel Pthread Example and Test
-pthread_exit Pthread Implementation of a Team of AD Threads
-public Atomic Eigen Cholesky Factorization Class: Public
-       Atomic Eigen Matrix Inversion Class: Public
-       Atomic Eigen Matrix Multiply Class: Public
-purpose LU Factorization of A Square Matrix and Stability Calculation: ratio.Purpose
-        Jacobian and Hessian of Optimal Values: Purpose
-        Computing Jacobian and Hessian of Bender's Reduced Objective: Purpose
-        Determine Amount of Time to Execute det_by_minor: Purpose
-        Returns Elapsed Number of Seconds: Purpose
-        Simulate a [0,1] Uniform Random Variate: Purpose
-        Compute Determinant using Expansion by Minors: Purpose
-        Determinant of a Minor: Purpose
-        Compare Speed of C and C++: Purpose
-        Using AD to Compute Atomic Function Derivatives: Purpose
-        Using AD to Compute Atomic Function Derivatives: Purpose
-        User Defined Atomic AD Functions: Purpose
-        ODE Fitting Using Fast Representation: Purpose
-        ODE Fitting Using Simple Representation: Purpose
-        Nonlinear Programming Using CppAD and Ipopt: Example and Test: Purpose
-        Nonlinear Programming Using the CppAD Interface to Ipopt: Purpose
-        Machine Epsilon For AD Types: Purpose
-        Memory Leak Detection: Purpose
-        Set Maximum Number of Threads for omp_alloc Allocator: Purpose
-        Check If A Memory Allocation is Efficient for Another Use: Purpose
-        Return A Raw Array to The Available Memory for a Thread: Purpose
-        Allocate Memory and Create A Raw Array: Purpose
-        Amount of Memory Available for Quick Use by a Thread: Purpose
-        Amount of Memory a Thread is Currently Using: Purpose
-        Free Memory Currently Available for Quick Use by a Thread: Purpose
-        Return Memory to omp_alloc: Purpose
-        Get At Least A Specified Amount of Memory: Purpose
-        Get the Current OpenMP Thread Number: Purpose
-        Is The Current Execution in OpenMP Parallel Mode: Purpose
-        Set and Get Maximum Number of Threads for omp_alloc Allocator: Purpose
-        A Quick OpenMP Memory Allocator Used by CppAD: Purpose
-        Routines That Track Use of New and Delete: Purpose
-        OpenMP Parallel Setup: Purpose
-        Comparison Changes During Zero Order Forward Mode: Purpose
-        ADFun Object Deprecated Member Functions: Purpose
-        Speed Test Derivatives Using Sacado: Purpose
-        Speed Test Derivatives Using Fadbad: Purpose
-        Speed Test Derivatives Using CppAD: Purpose
-        Adolc Test Utility: Allocate and Free Memory For a Matrix: Purpose
-        Speed Test of Derivatives Using Adolc: Purpose
-        Speed Test of Functions in Double: Purpose
-        Simulate a [0,1] Uniform Random Variate: Purpose
-        Evaluate a Function That Has a Sparse Hessian: Purpose
-        Evaluate a Function That Has a Sparse Jacobian: Purpose
-        Evaluate a Function Defined in Terms of an ODE: Purpose
-        Sum Elements of a Matrix Times Itself: Purpose
-        Check Gradient of Determinant of 3 by 3 matrix: Purpose
-        Check Determinant of 3 by 3 matrix: Purpose
-        Determinant of a Minor: Purpose
-        Microsoft Version of Elapsed Number of Seconds: Purpose
-        Speed Testing Second Derivative of a Polynomial: Purpose
-        Speed Testing the Jacobian of Ode Solution: Purpose
-        Speed Testing Derivative of Matrix Multiply: Purpose
-        Speed Testing Gradient of Determinant by Minor Expansion: Purpose
-        Speed Testing Gradient of Determinant Using Lu Factorization: Purpose
-        Running the Speed Test Program: Purpose
-        Speed Test an Operator Overloading AD Package: Purpose
-        Suppress Suspect Implicit Conversion Warnings: Purpose
-        Using The CppAD Test Vector Template Class: Purpose
-        Lu Factor and Solve with Recorded Pivoting: Purpose
-        Taylor's Ode Solver: An Example and Test: Purpose
-        Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Purpose
-        Taylor's Ode Solver: A Multi-Level AD Example and Test: Purpose
-        Computing a Jacobian With Constants that Change: Purpose
-        Multiple Level of AD: Example and Test: Purpose
-        Enable Use of Eigen Linear Algebra Package with CppAD: Purpose
-        Differentiate Conjugate Gradient Algorithm: Example and Test: Purpose
-        Getting Started Using CppAD to Compute Derivatives: Purpose
-        ODE Inverse Problem Definitions: Source Code: Purpose
-        Nonlinear Programming Retaping: Example and Test: Purpose
-        Nonlinear Programming Using CppAD and Ipopt: Example and Test: Purpose
-        Use Ipopt to Solve a Nonlinear Programming Problem: Purpose
-        Union of Standard Sets: Purpose
-        Convert Certain Types to a String: Purpose
-        Free All Memory That Was Allocated for Use by thread_alloc: Purpose
-        Deallocate An Array and Call Destructor for its Elements: Purpose
-        Allocate An Array and Call Default Constructor for its Elements: Purpose
-        Amount of Memory Available for Quick Use by a Thread: Purpose
-        Amount of Memory a Thread is Currently Using: Purpose
-        Control When Thread Alloc Retains Memory For Future Use: Purpose
-        Free Memory Currently Available for Quick Use by a Thread: Purpose
-        Return Memory to thread_alloc: Purpose
-        Get At Least A Specified Amount of Memory: Purpose
-        Get the Current Thread Number: Purpose
-        Is The Current Execution in Parallel Mode: Purpose
-        Get Number of Threads: Purpose
-        Setup thread_alloc For Use in Multi-Threading Environment: Purpose
-        A Fast Multi-Threading Memory Allocator: Purpose
-        An Error Controller for Gear's Ode Solvers: Purpose
-        An Arbitrary Order Gear Method: Purpose
-        An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Purpose
-        The Integer Power Function: Purpose
-        Obtain Nan or Determine if a Value is Nan: Purpose
-        Check Simple Vector Concept: Purpose
-        Check NumericType Class Concept: Purpose
-        Object that Runs a Group of Tests: Purpose
-        Returns Elapsed Number of Seconds: Purpose
-        Determine Amount of Time to Execute a Test: Purpose
-        Run One Speed Test and Print Results: Purpose
-        Run One Speed Test and Return Results: Purpose
-        Determine if Two Values Are Nearly Equal: Purpose
-        CppAD Assertions During Execution: Purpose
-        Some General Purpose Utilities
-        Specifications for A Team of AD Threads: Purpose
-        Timing Test of Multi-Threaded Newton Method: Purpose
-        A Multi-Threaded Newton's Method: Purpose
-        Take Down Multi-threaded Newton Method: Purpose
-        Do One Thread's Work for Multi-Threaded Newton Method: Purpose
-        Set Up Multi-Threaded Newton Method: Purpose
-        Common Variables use by Multi-Threaded Newton Method: Purpose
-        Multi-Threaded User Atomic Take Down: Purpose
-        Multi-Threaded User Atomic Worker: Purpose
-        Multi-Threaded User Atomic Set Up: Purpose
-        Multi-Threaded User Atomic Common Information: Purpose
-        Defines a User Atomic Operation that Computes Square Root: Purpose
-        Timing Test of Multi-Threaded Summation of 1/i: Purpose
-        Multi-Threaded Implementation of Summation of 1/i: Purpose
-        Take Down Multi-threading Sum of 1/i: Purpose
-        Do One Thread's Work for Sum of 1/i: Purpose
-        Set Up Multi-threading Sum of 1/i: Purpose
-        Common Variables Used by Multi-threading Sum of 1/i: Purpose
-        Using a Team of AD Threads: Example and Test: Purpose
-        A Simple pthread AD: Example and Test: Purpose
-        A Simple Boost Threading AD: Example and Test: Purpose
-        A Simple OpenMP AD: Example and Test: Purpose
-        A Simple Parallel Pthread Example and Test: Purpose
-        A Simple Boost Thread Example and Test: Purpose
-        A Simple OpenMP Example and Test: Purpose
-        Run Multi-Threading Examples and Speed Tests: Purpose
-        Enable AD Calculations During Parallel Mode: Purpose
-        Using CppAD in a Multi-Threading Environment: Purpose
-        CppAD API Preprocessor Symbols: Purpose
-        Check an ADFun Sequence of Operations: Purpose
-        abs_normal min_nso_quad: Example and Test: Purpose
-        Non-Smooth Optimization Using Abs-normal Quadratic Approximations: Purpose
-        abs_min_quad: Example and Test: Purpose
-        abs_normal: Minimize a Linear Abs-normal Approximation: Purpose
-        abs_normal: Solve a Quadratic Program With Box Constraints: Purpose
-        Solve a Quadratic Program Using Interior Point Method: Purpose
-        abs_normal min_nso_linear: Example and Test: Purpose
-        Non-Smooth Optimization Using Abs-normal Linear Approximations: Purpose
-        abs_min_linear: Example and Test: Purpose
-        abs_normal: Minimize a Linear Abs-normal Approximation: Purpose
-        abs_eval: Example and Test: Purpose
-        abs_normal: Evaluate First Order Approximation: Purpose
-        abs_normal: Print a Vector or Matrix: Purpose
-        abs_normal Getting Started: Example and Test: Purpose
-        Optimize an ADFun Object Tape: Purpose
-        Compute Sparse Jacobians Using Subgraphs: Purpose
-        Subset of a Sparse Hessian: Example and Test: Purpose
-        Computing Sparse Hessian for a Subset of Variables: Purpose
-        Sparse Hessian: p.Purpose
-        Sparse Hessian: Purpose
-        Computing Sparse Hessians: Purpose
-        Sparse Jacobian: Purpose
-        Computing Sparse Jacobians: Purpose
-        Preferred Sparsity Patterns: Row and Column Indices: Example and Test: Purpose
-        Hessian Sparsity Pattern: Forward Mode: Purpose
-        Forward Mode Hessian Sparsity Patterns: Purpose
-        Hessian Sparsity Pattern: Reverse Mode: Purpose
-        Reverse Mode Hessian Sparsity Patterns: Purpose
-        Jacobian Sparsity Pattern: Reverse Mode: Purpose
-        Reverse Mode Jacobian Sparsity Patterns: Purpose
-        Jacobian Sparsity Pattern: Forward Mode: Purpose
-        Forward Mode Jacobian Sparsity Patterns: Purpose
-        Reverse Mode Using Subgraphs: Purpose
-        Reverse Mode General Case (Checkpointing): Example and Test: Purpose
-        Any Order Reverse Mode: Purpose
-        Second Order Reverse Mode: Purpose
-        First Order Reverse Mode: Purpose
-        Number of Variables that Can be Skipped: Purpose
-        Controlling Taylor Coefficients Memory Allocation: Purpose
-        Comparison Changes Between Taping and Zero Order Forward: op_index.Purpose
-        Comparison Changes Between Taping and Zero Order Forward: Purpose
-        Number Taylor Coefficient Orders Currently Stored: Purpose
-        Multiple Directions Forward Mode: Purpose
-        Multiple Order Forward Mode: Purpose
-        Second Order Forward Mode: Derivative Values: Purpose
-        First Order Forward Mode: Derivative Values: Purpose
-        Zero Order Forward Mode: Function Values: Purpose
-        Reverse Mode Second Partial Derivative Driver: Purpose
-        Forward Mode Second Partial Derivative Driver: Purpose
-        First Order Derivative: Driver Routine: Purpose
-        First Order Partial Derivative: Driver Routine: Purpose
-        Hessian: Easy Driver: Purpose
-        Jacobian: Driver Routine: Purpose
-        ADFun Sequence Properties: Purpose
-        Abort Recording of an Operation Sequence: Purpose
-        Stop Recording and Store Operation Sequence: Purpose
-        Construct an ADFun Object and Stop Recording: Purpose
-        Declare Independent Variables and Start Recording: Purpose
-        ADFun Objects: Purpose
-        Using Adolc with Multiple Levels of Taping: Example and Test: Purpose
-        Using a User Defined AD Base Type: Example and Test: Purpose
-        Example AD<Base> Where Base Constructor Allocates Memory: Purpose
-        Base Type Requirements for Hash Coding Values: Purpose
-        Base Type Requirements for Standard Math Functions: Purpose
-        Base Type Requirements for Ordered Comparisons: Purpose
-        Base Type Requirements for Conditional Expressions: Purpose
-        AD<Base> Requirements for a CppAD Base Type: Purpose
-        AD Vectors that Record Index Operations: Purpose
-        Check if Two Value are Identically Equal: Purpose
-        Is an AD Object a Parameter or Variable: Purpose
-        AD Boolean Functions: Purpose
-        Compare AD and Base Objects for Nearly Equal: Purpose
-        AD Binary Comparison Operators: Purpose
-        Atomic Eigen Cholesky Factorization Class: Purpose
-        Atomic Eigen Matrix Inversion Class: Purpose
-        Atomic Eigen Matrix Multiply Class: Purpose
-        Getting Started with Atomic Operations: Example and Test: Purpose
-        Atomic Reverse Hessian Sparsity: Example and Test: Purpose
-        Atomic Forward Hessian Sparsity: Example and Test: Purpose
-        Atomic Reverse Jacobian Sparsity: Example and Test: Purpose
-        Atomic Forward Jacobian Sparsity: Example and Test: Purpose
-        Atomic Reverse: Example and Test: Purpose
-        Atomic Forward: Example and Test: Purpose
-        Free Static Variables: Purpose
-        Atomic Reverse Hessian Sparsity Patterns: Purpose
-        Atomic Forward Hessian Sparsity Patterns: Purpose
-        Atomic Reverse Jacobian Sparsity Patterns: Purpose
-        Atomic Forward Jacobian Sparsity Patterns: Purpose
-        Atomic Reverse Mode: Purpose
-        Atomic Forward Mode: Purpose
-        Using AD Version of Atomic Function: Purpose
-        User Defined Atomic AD Functions: Purpose
-        Checkpointing an ODE Solver: Example and Test: Purpose
-        Simple Checkpointing: Example and Test: Purpose
-        Checkpointing Functions: Purpose
-        Discrete AD Functions: Purpose
-        AD Conditional Expressions: Purpose
-        Absolute Zero Multiplication: Purpose
-        The AD Power Function: Purpose
-        AD Two Argument Inverse Tangent Function: Purpose
-        The Unary Standard Math Functions: Purpose
-        AD Compound Assignment Operators: Purpose
-        AD Binary Arithmetic Operators: Purpose
-        AD Unary Minus Operator: Purpose
-        AD Unary Plus Operator: Purpose
-        Convert an AD Variable to a Parameter: Purpose
-        Printing AD Values During Forward Mode: Purpose
-        AD Output Stream Operator: Purpose
-        AD Output Stream Operator: Purpose
-        Convert From AD to Integer: Purpose
-        Convert From an AD Type to its Base Type: Purpose
-        AD Assignment Operator: Purpose
-        AD Constructors: Purpose
-        AD Objects: Purpose
-        exp_eps: CppAD Forward and Reverse Sweeps: Purpose
-        exp_eps: Second Order Reverse Sweep: Purpose
-        exp_eps: Second Order Forward Mode: Purpose
-        exp_eps: First Order Reverse Sweep: Purpose
-        An Epsilon Accurate Exponential Approximation: Purpose
-        exp_2: CppAD Forward and Reverse Sweeps: Purpose
-        exp_2: Second Order Reverse Mode: Purpose
-        exp_2: Second Order Forward Mode: Purpose
-        exp_2: First Order Reverse Mode: Purpose
-        exp_2: First Order Forward Mode: Purpose
-        Second Order Exponential Approximation: Purpose
-        An Introduction by Example to Algorithmic Differentiation: Purpose
-        CppAD pkg-config Files: Purpose
-        Checking the CppAD Examples and Tests: Purpose
-        Choosing the CppAD Test Vector Template Class: Purpose
-        Download and Install Sacado in Build Directory: Purpose
-        Including the Sacado Speed Tests: Purpose
-        Download and Install Ipopt in Build Directory: Purpose
-        Including the cppad_ipopt Library and Tests: Purpose
-        Download and Install Fadbad in Build Directory: Purpose
-        Including the FADBAD Speed Tests: Purpose
-        Download and Install Eigen in Build Directory: Purpose
-        Including the Eigen Examples and Tests: Purpose
-        Download and Install ColPack in Build Directory: Purpose
-        Including the ColPack Sparsity Calculations: Purpose
-        Download and Install Adolc in Build Directory: Purpose
-        Including the ADOL-C Examples and Tests: Purpose
-        Download The CppAD Source Code: Purpose
-push The CppAD::vector Template Class
-push_back The CppAD::vector Template Class: push_back
-push_vector The CppAD::vector Template Class: push_vector
-px User Defined Atomic AD Functions: reverse.px
-   Atomic Reverse Mode: py.px
-py User Defined Atomic AD Functions: reverse.py
-   Atomic Reverse Mode: py
- -Q -
-q User Defined Atomic AD Functions: rev_hes_sparse.q
-  User Defined Atomic AD Functions: rev_jac_sparse.q
-  User Defined Atomic AD Functions: for_jac_sparse.q
-  Hessian Sparsity Pattern: Reverse Mode: q
-  Jacobian Sparsity Pattern: Reverse Mode: q
-  Jacobian Sparsity Pattern: Forward Mode: q
-  Reverse Mode Using Subgraphs: q
-  Any Order Reverse Mode: q
-  Multiple Directions Forward Mode: q
-  Multiple Order Forward Mode: q
-  Atomic Reverse Hessian Sparsity Patterns: Implementation.q
-  Atomic Reverse Jacobian Sparsity Patterns: Implementation.q
-  Atomic Forward Jacobian Sparsity Patterns: Implementation.q
-  Atomic Reverse Mode: q
-  Atomic Forward Mode: q
-qp_box qp_box Source Code
-qp_box: abs_normal qp_box: Example and Test
-qp_interior qp_interior Source Code
-qp_interior: abs_normal qp_interior: Example and Test
-quadratic Non-Smooth Optimization Using Abs-normal Quadratic Approximations
-          abs_normal: Solve a Quadratic Program With Box Constraints
-          Solve a Quadratic Program Using Interior Point Method
-questions Frequently Asked Questions and Answers
-quick Amount of Memory Available for Quick Use by a Thread
-      Free Memory Currently Available for Quick Use by a Thread
-      A Quick OpenMP Memory Allocator Used by CppAD
-      Amount of Memory Available for Quick Use by a Thread
-      Free Memory Currently Available for Quick Use by a Thread
-quiet_nan Numeric Limits For an AD and Base Types: quiet_NaN
-quotient AD Binary Division: Example and Test
- -R -
-Range ADFun Sequence Properties: Example and Test
-RevSparseHes Reverse Mode Hessian Sparsity: Example and Test
-RevSparseJac Reverse Mode Jacobian Sparsity: Example and Test
-             Jacobian Sparsity Pattern: Reverse Mode
-Romberg One DimensionalRomberg Integration
-Rosen34 Rosen34: Example and Test
-        A 3rd and 4th Order Rosenbrock ODE Solver
-Runge An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-Runge45 Runge45: Example and Test
-        Runge45: Example and Test
-        An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-random Simulate a [0,1] Uniform Random Variate
-       Simulate a [0,1] Uniform Random Variate
-range ODE Fitting Using Fast Representation: Trapezoidal Approximation.Range Indices I(k,0)
-      ODE Fitting Using Fast Representation: Initial Condition.Range Indices I(k,0)
-      ODE Fitting Using Fast Representation: Objective Function.Range Indices I(k,0)
-      ADFun Sequence Properties: Range
-      User Defined Atomic AD Functions: Examples.Vector Range
-rate Run One Speed Test and Print Results: rate
-rate_vec Run One Speed Test and Return Results: rate_vec
-ratio LU Factorization of A Square Matrix and Stability Calculation: ratio
-raw Return A Raw Array to The Available Memory for a Thread
-    Allocate Memory and Create A Raw Array
-re-tape CompareChange and Re-Tape: Example and Test
-re-tape: ADFun Check and Re-Tape: Example and Test
-         CompareChange and Re-Tape: Example and Test
-real Convert From AD to Integer: x.Real Types
-realistic General Examples
-recipes Bibliography: Numerical Recipes
-reciprocal Reciprocal as an Atomic Operation: Example and Test
-reciprocal: Old Atomic Operation Reciprocal: Example and Test
-recomputation The CppAD Wish List: Forward Mode Recomputation
-record Lu Factor and Solve With Recorded Pivoting: Example and Test
-       AD Vectors that Record Index Operations: Example and Test
-       AD Vectors that Record Index Operations
-       Convert From AD to its Base Type: Example and Test
-recorded Lu Factor and Solve With Recorded Pivoting: Example and Test
-         Lu Factor and Solve with Recorded Pivoting
-recording Using Multiple Levels of AD: Procedure.Start AD< AD<double> > Recording
-          Abort Current Recording: Example and Test
-          Abort Recording of an Operation Sequence
-          Stop Recording and Store Operation Sequence
-          Construct an ADFun Object and Stop Recording
-          Declare Independent Variables and Start Recording: Stop Recording
-          Declare Independent Variables and Start Recording: Start Recording
-          Declare Independent Variables and Start Recording
-          User Atomic Matrix Multiply: Example and Test: Use Atomic Function.Recording
-          Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function.Recording
-          Atomic Sparsity with Set Patterns: Example and Test: Test Atomic Function.Recording
-          Reciprocal as an Atomic Operation: Example and Test: Use Atomic Function.Recording
-          Atomic Euclidean Norm Squared: Example and Test: Use Atomic Function.Recording
-          Getting Started with Atomic Operations: Example and Test: Use Atomic Function.Recording
-          Checkpointing Functions: Purpose.Faster Recording
-recording: Abort Current Recording: Example and Test
-recursion Error Function Forward Taylor Polynomial Theory: Taylor Coefficients Recursion
-          Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory: Taylor Coefficients Recursion
-          Inverse Cosine and Hyperbolic Cosine Forward Mode Theory: Taylor Coefficients Recursion
-          Inverse Sine and Hyperbolic Sine Forward Mode Theory: Taylor Coefficients Recursion
-          Inverse Tangent and Hyperbolic Tangent Forward Mode Theory: Taylor Coefficients Recursion
-          Logarithm Function Forward Mode Theory: Taylor Coefficients Recursion
-          Exponential Function Forward Mode Theory: Taylor Coefficients Recursion
-          The Theory of Forward Mode: Standard Math Functions.Cases that Apply Recursion Above
-          The Theory of Forward Mode: Standard Math Functions.Taylor Coefficients Recursion Formula
-redirecting Printing AD Values During Forward Mode: Redirecting Output
-reduce Checkpointing Functions: Purpose.Reduce Memory
-reduced Computing Jacobian and Hessian of Bender's Reduced Objective
-reduction Solve a Quadratic Program Using Interior Point Method: Newton Step.Elementary Row Reduction
-reference Jacobian and Hessian of Optimal Values: Reference
-          The CppAD::vector Template Class: Assignment.Return Reference
-          Abs-normal Representation of Non-Smooth Functions: Reference
-          AD Vectors that Record Index Operations
-          AD Theory for Cholesky Factorization: Reference
-          An Introduction by Example to Algorithmic Differentiation: Reference
-rel AD Conditional Expressions: Rel
-relative Determine if Two Values Are Nearly Equal
-release Using CMake to Configure CppAD: cppad_cxx_flags.debug and release
-        Download The CppAD Source Code: Release
-removed Set Maximum Number of Threads for omp_alloc Allocator: Removed
-        Check If A Memory Allocation is Efficient for Another Use: Removed
-repeat Repeat det_by_minor Routine A Specified Number of Times: repeat
-       Repeat det_by_minor Routine A Specified Number of Times
-       Speed Testing Sparse Jacobian: repeat
-       Speed Testing Sparse Hessian: repeat
-       Speed Testing Second Derivative of a Polynomial: repeat
-       Speed Testing the Jacobian of Ode Solution: repeat
-       Speed Testing Derivative of Matrix Multiply: repeat
-       Speed Testing Gradient of Determinant by Minor Expansion: repeat
-       Speed Testing Gradient of Determinant Using Lu Factorization: repeat
-       Determine Amount of Time to Execute a Test: test.repeat
-       Run One Speed Test and Print Results: Test.repeat
-       Run One Speed Test and Return Results: test.repeat
-repeating Checkpointing Functions: Purpose.Repeating Forward
-replace Replacing the CppAD Error Handler
-replacing Replacing The CppAD Error Handler: Example and Test
-          Replacing the CppAD Error Handler
-representation ODE Fitting Using Fast Representation
-               ODE Fitting Using Simple Representation
-               ODE Fitting Using Fast Representation
-               ODE Fitting Using Simple Representation
-               Nonlinear Programming Using the CppAD Interface to Ipopt: Simple Representation
-               Nonlinear Programming Using the CppAD Interface to Ipopt: fg(x).Representation
-               Glossary: Row-major Representation
-               Sparse Matrix Row, Column, Value Representation
-               Create An Abs-normal Representation of a Function
-               Abs-normal Representation of Non-Smooth Functions
-representations Speed Test for Both Simple and Fast Representations
-                Correctness Check for Both Simple and Fast Representations
-require Base Type Requirements for Identically Equal Comparisons
-        Base Type Requirements for Conditional Expressions
-        AD Objects
-required Required Base Class Member Functions
-requirement Nonlinear Programming Using CppAD and Ipopt: Example and Test: Configuration Requirement
-            Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Configuration Requirement
-            Nonlinear Programming Using CppAD and Ipopt: Example and Test: Configuration Requirement
-            Using Adolc with Multiple Levels of Taping: Example and Test: Configuration Requirement
-            Extending to_string To Another Floating Point Type: Base Requirement
-requirements zdouble: An AD Base Type With Absolute Zero: Base Type Requirements
-             The CppAD Wish List: Base Requirements
-             Definition of a Simple Vector: Template Class Requirements
-             Definition of a Numeric Type: Type Requirements
-             Base Type Requirements for Hash Coding Values
-             Base Type Requirements for Numeric Limits
-             Base Type Requirements for Standard Math Functions
-             Base Type Requirements for Ordered Comparisons
-             Base Type Requirements for Identically Equal Comparisons
-             Base Type Requirements for Conditional Expressions
-             AD<Base> Requirements for a CppAD Base Type
-             AD Objects: Base Type Requirements
-             Download and Install Adolc in Build Directory: Requirements
-resize Row and Column Index Sparsity Patterns: resize
-       The CppAD::vector Template Class: resize
-       Definition of a Simple Vector: Resize
-restriction User Defined Atomic AD Functions: clear.Restriction
-            OpenMP Parallel Setup: Restriction
-            CppAD Assertions During Execution: Restriction
-            Enable AD Calculations During Parallel Mode: Restriction
-            Free Static Variables: Restriction
-            Checkpointing Functions: clear.Restriction
-            Checkpointing Functions: Purpose.Restriction
-            Convert From an AD Type to its Base Type: Restriction
-restrictions Set Maximum Number of Threads for omp_alloc Allocator: Restrictions
-             Set and Get Maximum Number of Threads for omp_alloc Allocator: Restrictions
-             Free All Memory That Was Allocated for Use by thread_alloc: Restrictions
-             Setup thread_alloc For Use in Multi-Threading Environment: Restrictions
-             Check Simple Vector Concept: Restrictions
-             Specifications for A Team of AD Threads: Restrictions
-             Sparse Hessian: VectorSet.Restrictions
-             Sparse Jacobian: VectorSet.Restrictions
-             Multiple Order Forward Mode: xq.Restrictions
-             Atomic Function Constructor: atomic_base.Restrictions
-result Lu Factor and Solve with Recorded Pivoting: Result
-       Union of Standard Sets: result
-       Matrix Multiply as an Atomic Operation: Result Element Index
-       Atomic Sparsity with Set Patterns: Example and Test: Test Atomic Function.Test Result
-       AD Conditional Expressions: result
-       AD Compound Assignment Operators: Result
-       AD Output Stream Operator: Result
-       AD Output Stream Operator: Result
-results Running the Speed Test Program: Speed Results
-        Running the Speed Test Program: Correctness Results
-        Run One Speed Test and Print Results
-        Run One Speed Test and Return Results
-        Check an ADFun Object For Nan Results
-retains Control When Thread Alloc Retains Memory For Future Use
-retape The CppAD Wish List: checkpoint.Retape
-       Nonlinear Programming Retaping: Example and Test
-       Use Ipopt to Solve a Nonlinear Programming Problem: Example.retape
-       Use Ipopt to Solve a Nonlinear Programming Problem: options.Retape
-       Interpolation With Retaping: Example and Test
-       Interpolation With Out Retaping: Example and Test
-retaping: Nonlinear Programming Retaping: Example and Test
-          Interpolation With Retaping: Example and Test
-          Interpolation With Out Retaping: Example and Test
-return Return A Raw Array to The Available Memory for a Thread
-       Return Memory to omp_alloc
-       Speed Testing Second Derivative of a Polynomial: Return Value
-       Speed Testing the Jacobian of Ode Solution: Return Value
-       Speed Testing Derivative of Matrix Multiply: Return Value
-       Speed Testing Gradient of Determinant by Minor Expansion: Return Value
-       Speed Testing Gradient of Determinant Using Lu Factorization: Return Value
-       Returns Indices that Sort a Vector: ind.Return
-       Return Memory to thread_alloc
-       The CppAD::vector Template Class: Assignment.Return Reference
-       Run One Speed Test and Return Results
-       exp_eps: Second Order Forward Mode: Return Value
-       exp_eps: First Order Forward Sweep: Return Value
-       exp_eps: Operation Sequence and Zero Order Forward Sweep: Return Value
-       exp_2: Second Order Forward Mode: Return Value
-       exp_2: First Order Forward Mode: Return Value
-       exp_2: Operation Sequence and Zero Order Forward Mode: Return Value
-return_memory Return Memory to omp_alloc
-              Return Memory to thread_alloc
-returns Returns Elapsed Number of Seconds
-        Returns Indices that Sort a Vector
-        Returns Elapsed Number of Seconds
-reuse Download and Install Sacado in Build Directory: Reuse
-      Download and Install Ipopt in Build Directory: Reuse
-      Download and Install Eigen in Build Directory: Reuse
-      Download and Install ColPack in Build Directory: Reuse
-      Download and Install Adolc in Build Directory: Reuse
-rev_hes_sparse User Defined Atomic AD Functions: rev_hes_sparse
-rev_jac_sparse User Defined Atomic AD Functions: rev_jac_sparse
-rev_sparse_hes Matrix Multiply as an Atomic Operation: rev_sparse_hes
-               User Atomic Matrix Multiply: Example and Test: Use Atomic Function.rev_sparse_hes
-               Atomic Eigen Matrix Multiply Class: Private.rev_sparse_hes
-               Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function.rev_sparse_hes
-               Tan and Tanh as User Atomic Operations: Example and Test: rev_sparse_hes
-               Atomic Sparsity with Set Patterns: Example and Test: Test Atomic Function.rev_sparse_hes
-               Atomic Sparsity with Set Patterns: Example and Test: rev_sparse_hes
-               Reciprocal as an Atomic Operation: Example and Test: Use Atomic Function.rev_sparse_hes
-               Reciprocal as an Atomic Operation: Example and Test: rev_sparse_hes
-               Atomic Euclidean Norm Squared: Example and Test: Use Atomic Function.rev_sparse_hes
-               Atomic Euclidean Norm Squared: Example and Test: rev_sparse_hes
-               Atomic Reverse Hessian Sparsity: Example and Test: rev_sparse_hes
-rev_sparse_jac Optimize an ADFun Object Tape: Atomic Functions.rev_sparse_jac
-               Matrix Multiply as an Atomic Operation: rev_sparse_jac
-               User Atomic Matrix Multiply: Example and Test: Use Atomic Function.rev_sparse_jac
-               Atomic Eigen Matrix Multiply Class: Private.rev_sparse_jac
-               Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function.rev_sparse_jac
-               Tan and Tanh as User Atomic Operations: Example and Test: rev_sparse_jac
-               Atomic Sparsity with Set Patterns: Example and Test: Test Atomic Function.rev_sparse_jac
-               Atomic Sparsity with Set Patterns: Example and Test: rev_sparse_jac
-               Reciprocal as an Atomic Operation: Example and Test: Use Atomic Function.rev_sparse_jac
-               Reciprocal as an Atomic Operation: Example and Test: rev_sparse_jac
-               Atomic Euclidean Norm Squared: Example and Test: Use Atomic Function.rev_sparse_jac
-               Atomic Euclidean Norm Squared: Example and Test: rev_sparse_jac
-               Atomic Reverse Hessian Sparsity: Example and Test: rev_sparse_jac
-               Atomic Forward Hessian Sparsity: Example and Test: rev_sparse_jac
-               Atomic Reverse Jacobian Sparsity: Example and Test: rev_sparse_jac
-reverse Define Matrix Multiply as a User Atomic Operation: Reverse Partials One Order
-        User Defined Atomic AD Functions: reverse
-        User Defined Atomic AD Functions: ty.reverse
-        An Important Reverse Mode Identity: Reverse Sweep
-        An Important Reverse Mode Identity
-        Error Function Reverse Mode Theory
-        Tangent and Hyperbolic Tangent Reverse Mode Theory
-        Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
-        Inverse Sine and Hyperbolic Sine Reverse Mode Theory
-        Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory
-        Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
-        Square Root Function Reverse Mode Theory
-        Logarithm Function Reverse Mode Theory
-        Exponential Function Reverse Mode Theory
-        The Theory of Reverse Mode
-        Frequently Asked Questions and Answers: Mode: Forward or Reverse
-        Example Optimization and Reverse Activity Analysis
-        Computing Sparse Jacobian Using Reverse Mode: Example and Test
-        Computing Sparse Jacobian Using Reverse Mode: Example and Test
-        Reverse Mode Hessian Sparsity: Example and Test
-        Hessian Sparsity Pattern: Reverse Mode
-        Reverse Mode Hessian Sparsity: Example and Test
-        Reverse Mode Hessian Sparsity Patterns
-        Reverse Mode Jacobian Sparsity: Example and Test
-        Jacobian Sparsity Pattern: Reverse Mode
-        Reverse Mode Jacobian Sparsity: Example and Test
-        Reverse Mode Jacobian Sparsity Patterns
-        Computing Reverse Mode on Subgraphs: Example and Test
-        Reverse Mode Using Subgraphs
-        Reverse Mode General Case (Checkpointing): Example and Test
-        Third Order Reverse Mode: Example and Test
-        Any Order Reverse Mode
-        Second Order Reverse ModeExample and Test
-        Second Order Reverse Mode
-        First Order Reverse Mode: Example and Test
-        First Order Reverse Mode
-        Multiple Directions Forward Mode: Reverse Mode
-        Second Partials Reverse Driver: Example and Test
-        Reverse Mode Second Partial Derivative Driver
-        Jacobian: Driver Routine: Forward or Reverse
-        Reverse Mode
-        Matrix Multiply as an Atomic Operation: reverse
-        Matrix Multiply as an Atomic Operation: Reverse Matrix Multiply
-        User Atomic Matrix Multiply: Example and Test: Use Atomic Function.reverse
-        Atomic Eigen Cholesky Factorization Class: Private.reverse
-        AD Theory for Cholesky Factorization: Reverse Mode
-        Atomic Eigen Matrix Inversion Class: Private.reverse
-        Atomic Eigen Matrix Inversion Class: Theory.Reverse
-        Atomic Eigen Matrix Multiply Class: Private.reverse
-        Atomic Eigen Matrix Multiply Class: Theory.Reverse
-        Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function.reverse
-        Tan and Tanh as User Atomic Operations: Example and Test: reverse
-        Reciprocal as an Atomic Operation: Example and Test: Use Atomic Function.reverse
-        Reciprocal as an Atomic Operation: Example and Test: reverse
-        Atomic Euclidean Norm Squared: Example and Test: Use Atomic Function.reverse
-        Atomic Euclidean Norm Squared: Example and Test: reverse
-        Atomic Reverse Hessian Sparsity: Example and Test
-        Atomic Reverse Jacobian Sparsity: Example and Test
-        Atomic Reverse: Example and Test: reverse
-        Atomic Reverse Hessian Sparsity Patterns
-        Atomic Reverse Jacobian Sparsity Patterns
-        Atomic Reverse Mode
-        exp_eps: CppAD Forward and Reverse Sweeps
-        exp_eps: Verify Second Order Reverse Sweep
-        exp_eps: Verify First Order Reverse Sweep
-        exp_eps: Second Order Reverse Sweep
-        exp_eps: First Order Reverse Sweep
-        exp_2: CppAD Forward and Reverse Sweeps
-        exp_2: Verify Second Order Reverse Sweep
-        exp_2: Verify First Order Reverse Sweep
-        exp_2: Second Order Reverse Mode
-        exp_2: First Order Reverse Mode
-        An Introduction by Example to Algorithmic Differentiation: Preface.Reverse Mode
-reverse: Atomic Reverse: Example and Test
-revone First Order Derivative: Driver Routine: RevOne Uses Forward
-revsparsehes Sparsity Patterns For a Subset of Variables: Example and Test: RevSparseHes
-revsparsity Running the Speed Test Program: Sparsity Options.revsparsity
-revtwo Reverse Mode Second Partial Derivative Driver: RevTwo Uses Forward
-rhs Lu Factor and Solve with Recorded Pivoting: Rhs
-right Union of Standard Sets: right
-      Matrix Multiply as an Atomic Operation: Right Operand Element Index
-      AD Conditional Expressions: right
-romberg One Dimensional Romberg Integration: Example and Test
-        Multi-dimensional Romberg Integration
-        One Dimensional Romberg Integration: Example and Test
-root Square Root Function Reverse Mode Theory
-     Square Root Function Forward Mode Theory
-     Defines a User Atomic Operation that Computes Square Root
-     The Square Root Function: sqrt
-rosen34: Rosen34: Example and Test
-rosenbrock A 3rd and 4th Order Rosenbrock ODE Solver
-routine Repeat det_by_minor Routine A Specified Number of Times
-        Correctness Test of det_by_minor Routine
-        First Order Derivative: Driver Routine
-        First Order Partial Derivative: Driver Routine
-        Jacobian: Driver Routine
-routines User Defined Atomic AD Functions: Syntax Function.Callback Routines
-         Routines That Track Use of New and Delete
-         Speed Testing Utilities: Library Routines
-         Speed Testing Utilities: Speed Utility Routines
-         Utility Routines used by CppAD Examples
-         Some General Purpose Utilities: General Numerical Routines
-row Glossary: Sparsity Pattern.Row and Column Index Vectors
-    Evaluate a Function That Has a Sparse Hessian: row
-    Evaluate a Function That Has a Sparse Jacobian: row
-    Speed Testing Sparse Jacobian: row
-    Speed Testing Sparse Hessian: row
-    Sparse Matrix Row, Column, Value Representation: row
-    Sparse Matrix Row, Column, Value Representation
-    Row and Column Index Sparsity Patterns: row
-    Row and Column Index Sparsity Patterns
-    Solve a Quadratic Program Using Interior Point Method: Newton Step.Elementary Row Reduction
-    Sparse Hessian: row, col
-    Sparse Jacobian: row, col
-    Preferred Sparsity Patterns: Row and Column Indices: Example and Test
-row-major Glossary: Row-major Representation
-row_major Sparse Matrix Row, Column, Value Representation: row_major
-          Row and Column Index Sparsity Patterns: row_major
-rt Atomic Reverse Jacobian Sparsity Patterns: Implementation.rt
-run Run the Speed Examples
-    Run One Speed Test and Print Results
-    Run One Speed Test and Return Results
-    Run Multi-Threaded User Atomic Calculation
-    Run Multi-Threading Examples and Speed Tests
-    Correctness Tests For Exponential Approximation in Introduction
-runge-kutta An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-runge45: Runge45: Example and Test
-         Runge45: Example and Test
-running Driver for Running the Ipopt ODE Example
-        Speed Test Derivatives Using Sacado: Running Tests
-        Speed Test Derivatives Using Fadbad: Running Tests
-        Speed Test Derivatives Using CppAD: Running Tests
-        Speed Test of Derivatives Using Adolc: Running Tests
-        Speed Test of Functions in Double: Running Tests
-        Running the Speed Test Program
-        Run the Speed Examples: Running Tests
-        CppAD Examples and Tests: Running Tests
-        Getting Started Using CppAD to Compute Derivatives: Running
-        Examples: Running Examples
-        Example Use of SpeedTest: Running This Program
-        Run Multi-Threading Examples and Speed Tests: Running Tests
-        Printing During Forward Mode: Example and Test: Running
-        Correctness Tests For Exponential Approximation in Introduction: Running Tests
-runs Object that Runs a Group of Tests
- -S -
-SimpleVector The CheckSimpleVector Function: Example and Test
-SpeedTest Run One Speed Test and Print Results
-sacado sacado Speed: sparse_jacobian
-       Sacado Speed: Sparse Hessian
-       Sacado Speed: Second Derivative of a Polynomial
-       Sacado Speed: Gradient of Ode Solution
-       Sacado Speed: Matrix Multiplication
-       Sacado Speed: Gradient of Determinant Using Lu Factorization
-       Sacado Speed: Gradient of Determinant by Minor Expansion
-       Speed Test Derivatives Using Sacado
-       Download and Install Sacado in Build Directory
-       Including the Sacado Speed Tests
-     download and install Download and Install Sacado in Build Directory
-sacado_dir Autotools Unix Test and Installation: sacado_dir
-sacado_prefix Speed Test Derivatives Using Sacado: sacado_prefix
-              Including the Sacado Speed Tests: sacado_prefix
-same Using CppAD in a Multi-Threading Environment: Same Thread
-scalar Determinant Using Expansion by Minors: Scalar
-       Determinant of a Minor: Scalar
-       Determinant Using Expansion by Lu Factorization: Scalar
-       An Error Controller for Gear's Ode Solvers: Scalar
-       An Arbitrary Order Gear Method: Scalar
-       An Error Controller for ODE Solvers: Scalar
-       A 3rd and 4th Order Rosenbrock ODE Solver: Scalar
-       An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Scalar
-       Obtain Nan or Determine if a Value is Nan: Scalar
-       User Defined Atomic AD Functions: Examples.Scalar Function
-scur An Error Controller for ODE Solvers: scur
-second Sacado Speed: Second Derivative of a Polynomial
-       Fadbad Speed: Second Derivative of a Polynomial
-       CppAD Speed: Second Derivative of a Polynomial
-       Adolc Speed: Second Derivative of a Polynomial
-       Speed Testing Second Derivative of a Polynomial
-       Using Multiple Levels of AD: Procedure.Second Start AD< AD<double> >
-       Any Order Reverse Mode: Second Order
-       Second Order Reverse ModeExample and Test
-       Second Order Reverse Mode: dw.Second Order Partials
-       Second Order Reverse Mode
-       Multiple Order Forward Mode: Second Order
-       Second Order Forward Mode: Derivative Values
-       Second Partials Reverse Driver: Example and Test
-       Reverse Mode Second Partial Derivative Driver
-       Subset of Second Order Partials: Example and Test
-       Forward Mode Second Partial Derivative Driver
-       Hessian: Easy Driver
-       First and Second Order Derivatives: Easy Drivers
-       exp_eps: Verify Second Order Reverse Sweep
-       exp_eps: Verify Second Order Forward Sweep
-       exp_eps: Second Order Reverse Sweep
-       exp_eps: Second Order Forward Mode: Operation Sequence.Second
-       exp_eps: Second Order Forward Mode: Second Order Expansion
-       exp_eps: Second Order Forward Mode
-       exp_2: Verify Second Order Reverse Sweep
-       exp_2: Verify Second Order Forward Sweep
-       exp_2: Second Order Reverse Mode
-       exp_2: Second Order Forward Mode: Operation Sequence.Second
-       exp_2: Second Order Forward Mode: Second Order Expansion
-       exp_2: Second Order Forward Mode
-       Second Order Exponential Approximation
-seconds Returns Elapsed Number of Seconds
-        Microsoft Version of Elapsed Number of Seconds
-        Elapsed Seconds: Example and Test
-        Returns Elapsed Number of Seconds
-seconds: Elapsed Seconds: Example and Test
-see Jacobian and Hessian of Optimal Values: See Also
-    Computing Jacobian and Hessian of Bender's Reduced Objective: See Also
-    Convert Certain Types to a String: See Also
-    The Integer Power Function: See Also
-    Example Optimization and Nested Conditional Expressions: See Also
-    Example Optimization and Conditional Expressions: See Also
-    Example Optimization and Comparison Operators: See Also
-    Subset of a Sparse Hessian: Example and Test: See Also
-    Computing Sparse Hessian for a Subset of Variables: See Also
-    Sparsity Patterns For a Subset of Variables: Example and Test: See Also
-    Reverse Mode General Case (Checkpointing): Example and Test: See Also
-    Number of Variables that Can be Skipped: Syntax.See Also
-    Controlling Taylor Coefficients Memory Allocation: Syntax.See Also
-    Number Taylor Coefficient Orders Currently Stored: Syntax.See Also
-    ADFun Sequence Properties: Syntax.See Also
-    Matrix Multiply as an Atomic Operation: See Also
-    User Atomic Matrix Multiply: Example and Test: See Also
-    Atomic Eigen Matrix Multiply Class: See Also
-    Checkpointing an Extended ODE Solver: Example and Test: See Also
-    Checkpointing an ODE Solver: Example and Test: See Also
-    Checkpointing Functions: See Also
-    Interpolation With Retaping: Example and Test: See Also
-    Interpolation With Out Retaping: Example and Test: See Also
-    Conditional Expressions: Example and Test: See Also
-    The AD Power Function: See Also
-    Convert an AD Variable to a Parameter: See Also
-    Convert An AD or Base Type to String: See Also
-    Convert From an AD Type to its Base Type: See Also
-seed Simulate a [0,1] Uniform Random Variate: seed
-     Simulate a [0,1] Uniform Random Variate: seed
-     Running the Speed Test Program: seed
-select_domain Compute Sparse Jacobians Using Subgraphs: select_domain
-              Subgraph Dependency Sparsity Patterns: select_domain
-              Forward Mode Hessian Sparsity Patterns: select_domain
-              Reverse Mode Using Subgraphs: select_domain
-select_range Compute Sparse Jacobians Using Subgraphs: select_range
-             Subgraph Dependency Sparsity Patterns: select_range
-             Forward Mode Hessian Sparsity Patterns: select_range
-             Reverse Mode Hessian Sparsity Patterns: select_range
-semantics The CppAD::vector Template Class: Assignment.Move Semantics
-sequence The CppAD Wish List: Operation Sequence
-         Glossary: Operation.Sequence
-         Evaluate a Function Defined in Terms of an ODE: Float.Operation Sequence
-         An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Operation Sequence
-         Evaluate a Polynomial or its Derivative: Operation Sequence
-         The Integer Power Function: Operation Sequence
-         Check an ADFun Sequence of Operations
-         Optimize an ADFun Object Tape
-         ADFun Sequence Properties: Example and Test
-         ADFun Sequence Properties
-         Abort Recording of an Operation Sequence
-         Stop Recording and Store Operation Sequence
-         Construct an ADFun Object and Stop Recording: Example.Sequence Constructor
-         Construct an ADFun Object and Stop Recording: Sequence Constructor
-         Check if Two Value are Identically Equal
-         Is an AD Object a Parameter or Variable: Operation Sequence
-         AD Boolean Functions: Operation Sequence
-         Compare AD and Base Objects for Nearly Equal: Operation Sequence
-         AD Binary Comparison Operators: Operation Sequence
-         Discrete AD Functions: Operation Sequence
-         AD Conditional Expressions: Operation Sequence
-         The AD Power Function: Operation Sequence
-         AD Two Argument Inverse Tangent Function: Operation Sequence
-         AD Compound Assignment Operators: Operation Sequence
-         AD Binary Arithmetic Operators: Operation Sequence
-         AD Unary Minus Operator: Operation Sequence
-         AD Unary Plus Operator: Operation Sequence
-         AD Output Stream Operator: Operation Sequence
-         AD Output Stream Operator: Operation Sequence
-         Convert From AD to Integer: Operation Sequence
-         Convert From an AD Type to its Base Type: Operation Sequence
-         exp_eps: Second Order Forward Mode: Operation Sequence
-         exp_eps: First Order Forward Sweep: Operation Sequence
-         exp_eps: Operation Sequence and Zero Order Forward Sweep: Operation Sequence
-         exp_eps: Operation Sequence and Zero Order Forward Sweep
-         exp_2: Second Order Forward Mode: Operation Sequence
-         exp_2: First Order Forward Mode: Operation Sequence
-         exp_2: Operation Sequence and Zero Order Forward Mode: Operation Sequence
-         exp_2: Operation Sequence and Zero Order Forward Mode
-sequence) Create an ADFun Object (Record an Operation Sequence)
-sequential Is The Current Execution in Parallel Mode
-set Define Matrix Multiply as a User Atomic Operation: Set Union
-    Set Maximum Number of Threads for omp_alloc Allocator
-    Set and Get Maximum Number of Threads for omp_alloc Allocator
-    Sparse Matrix Row, Column, Value Representation: set
-    Row and Column Index Sparsity Patterns: set
-    Set Union: Example and Test
-    Set Up Multi-Threaded Newton Method
-    Multi-Threaded User Atomic Set Up
-    Set Up Multi-threading Sum of 1/i
-    Atomic Sparsity with Set Patterns: Example and Test
-    Set Atomic Function Options
-set_max_num_threads Set and Get Maximum Number of Threads for omp_alloc Allocator: set_max_num_threads
-set_sparsity_enum Atomic Sparsity with Set Patterns: Example and Test: set_sparsity_enum
-                  Reciprocal as an Atomic Operation: Example and Test
-                  Set Atomic Function Options: atomic_sparsity.set_sparsity_enum
-set_union Some General Purpose Utilities: Miscellaneous.set_union
-sets Glossary: Sparsity Pattern.Vector of Sets
-     Union of Standard Sets
-     Using CMake to Configure CppAD
-setup OpenMP Parallel Setup
-      Setup thread_alloc For Use in Multi-Threading Environment
-shampine Bibliography: Shampine, L.F.
-sigma abs_normal: Minimize a Linear Abs-normal Approximation: Method.sigma
-      abs_normal: Minimize a Linear Abs-normal Approximation: Method.sigma
-sign LU Factorization of A Square Matrix and Stability Calculation: sign
-     LU Factorization of A Square Matrix: sign
-     Enable use of AD<Base> where Base is double: sign
-     Enable use of AD<Base> where Base is float: sign
-     Enable use of AD<Base> where Base is Adolc's adouble Type: sign
-     Example AD<Base> Where Base Constructor Allocates Memory: sign
-     Base Type Requirements for Standard Math Functions: sign
-     Sign Function: Example and Test
-     The Sign: sign
-sign: The Sign: sign
-signdet Jacobian and Hessian of Optimal Values: signdet
-        Compute Determinant and Solve Linear Equations: signdet
-simple Using AD to Compute Atomic Function Derivatives: Simple Case
-       User Defined Atomic AD Functions: Example.Simple
-       Speed Test for Both Simple and Fast Representations
-       Correctness Check for Both Simple and Fast Representations
-       ODE Fitting Using Simple Representation
-       ODE Fitting Using Simple Representation
-       Nonlinear Programming Using the CppAD Interface to Ipopt: Simple Representation
-       Getting Started Using CppAD to Compute Derivatives
-       Check Simple Vector Concept
-       Simple Vector Template Class: Example and Test
-       Definition of a Simple Vector
-       A Simple pthread AD: Example and Test
-       A Simple Boost Threading AD: Example and Test
-       A Simple OpenMP AD: Example and Test
-       A Simple Parallel Pthread Example and Test
-       A Simple Boost Thread Example and Test
-       A Simple OpenMP Example and Test
-       Base Type Requirements for Identically Equal Comparisons: EqualOpSeq.The Simple Case
-       Simple Checkpointing: Example and Test
-simple_ad Run Multi-Threading Examples and Speed Tests: simple_ad
-simplex abs_normal: Solve a Linear Program Using Simplex Method
-simplex_method simplex_method Source Code
-simplex_method: abs_normal simplex_method: Example and Test
-simulate Simulate a [0,1] Uniform Random Variate
-         Simulate a [0,1] Uniform Random Variate
-simulated An ODE Inverse Problem Example: Measurements.Simulated Measurement Values
-          ODE Inverse Problem Definitions: Source Code: Measurements.Simulated Measurement Values
-simulation An ODE Inverse Problem Example: Measurements.Simulation Parameter Values
-           An ODE Inverse Problem Example: Measurements.Simulation Analytic Solution
-           ODE Inverse Problem Definitions: Source Code: Measurements.Simulation Parameter Values
-           ODE Inverse Problem Definitions: Source Code: Measurements.Simulation Analytic Solution
-simultaneous An ODE Inverse Problem Example: Simultaneous Method
-             Example Simultaneous Solution of Forward and Inverse Problem
-sin Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
-    Trigonometric and Hyperbolic Sine and Cosine Forward Theory
-    The AD sin Function: Example and Test
-    The Sine Function: sin
-sine Inverse Sine and Hyperbolic Sine Reverse Mode Theory
-     Inverse Sine and Hyperbolic Sine Reverse Mode Theory
-     Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
-     Inverse Sine and Hyperbolic Sine Forward Mode Theory
-     Inverse Sine and Hyperbolic Sine Forward Mode Theory
-     Trigonometric and Hyperbolic Sine and Cosine Forward Theory
-     The Inverse Hyperbolic Sine Function: asinh
-     The Hyperbolic Sine Function: sinh
-     The Sine Function: sin
-     Inverse Sine Function: asin
-     Inverse Sine Function: acos
-sinh Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
-     Trigonometric and Hyperbolic Sine and Cosine Forward Theory
-     The AD sinh Function: Example and Test
-     The Hyperbolic Sine Function: sinh
-sini An Error Controller for Gear's Ode Solvers: sini
-size Repeat det_by_minor Routine A Specified Number of Times: size
-     ADFun Object Deprecated Member Functions: Size
-     Speed Testing Sparse Jacobian: size
-     Speed Testing Sparse Hessian: size
-     Speed Testing Second Derivative of a Polynomial: size
-     Speed Testing the Jacobian of Ode Solution: size
-     Speed Testing Gradient of Determinant by Minor Expansion: size
-     Speed Testing Gradient of Determinant Using Lu Factorization: size
-     The CppAD::vector Template Class: Assignment.Check Size
-     Definition of a Simple Vector: Size
-     Determine Amount of Time to Execute a Test: test.size
-     Run One Speed Test and Print Results: Test.size
-     Run One Speed Test and Return Results: test.size
-     AD Vectors that Record Index Operations: size
-size_forward_bool Jacobian Sparsity Pattern: Forward Mode: f.size_forward_bool
-                  Forward Mode Jacobian Sparsity Patterns: f.size_forward_bool
-size_forward_set Jacobian Sparsity Pattern: Forward Mode: f.size_forward_set
-                 Forward Mode Jacobian Sparsity Patterns: f.size_forward_set
-size_min Allocate Memory and Create A Raw Array: size_min
-         Allocate An Array and Call Default Constructor for its Elements: size_min
-size_op ADFun Sequence Properties: size_op
-size_op_arg ADFun Sequence Properties: Example and Test
-            ADFun Sequence Properties: size_op_arg
-size_op_seq ADFun Sequence Properties: size_op_seq
-size_out Allocate Memory and Create A Raw Array: size_out
-         Allocate An Array and Call Default Constructor for its Elements: size_out
-size_par ADFun Sequence Properties: Example and Test
-         ADFun Sequence Properties: size_par
-size_AD Vectors that Record Index Operations: size_t Indexing
-size_taylor ADFun Object Deprecated Member Functions: size_taylor
-size_text ADFun Sequence Properties: size_text
-size_VecAD ADFun Sequence Properties: Example and Test
-size_var ADFun Sequence Properties: Example and Test
-         ADFun Sequence Properties: size_var
-         Checkpointing Functions: size_var
-size_vec Run One Speed Test and Return Results: size_vec
-size_vecad ADFun Sequence Properties: size_VecAD
-sizevector LU Factorization of A Square Matrix and Stability Calculation: SizeVector
-           Nonlinear Programming Using the CppAD Interface to Ipopt: SizeVector
-           Sparse Matrix Row, Column, Value Representation: SizeVector
-           Row and Column Index Sparsity Patterns: SizeVector
-           LU Factorization of A Square Matrix: SizeVector
-           Non-Smooth Optimization Using Abs-normal Quadratic Approximations: SizeVector
-           abs_normal: Minimize a Linear Abs-normal Approximation: SizeVector
-           Non-Smooth Optimization Using Abs-normal Linear Approximations: SizeVector
-           abs_normal: Minimize a Linear Abs-normal Approximation: SizeVector
-           Compute Sparse Jacobians Using Subgraphs: SizeVector
-           Computing Sparse Hessians: SizeVector
-           Computing Sparse Jacobians: SizeVector
-           Subgraph Dependency Sparsity Patterns: SizeVector
-           Forward Mode Hessian Sparsity Patterns: SizeVector
-           Reverse Mode Hessian Sparsity Patterns: SizeVector
-           Reverse Mode Jacobian Sparsity Patterns: SizeVector
-           Forward Mode Jacobian Sparsity Patterns: SizeVector
-           Reverse Mode Using Subgraphs: SizeVector
-sizing Definition of a Simple Vector: Sizing Constructor
-skipped Number of Variables that Can be Skipped
-skipped: Number of Variables That Can be Skipped: Example and Test
-smax An Error Controller for Gear's Ode Solvers: smax
-     An Error Controller for ODE Solvers: smax
-smin An Error Controller for Gear's Ode Solvers: smin
-     An Error Controller for ODE Solvers: smin
-software Your License for the CppAD Software
-         The CppAD Wish List: Software Guidelines
-solution An ODE Inverse Problem Example: Measurements.Simulation Analytic Solution
-         Example Simultaneous Solution of Forward and Inverse Problem
-         Nonlinear Programming Using the CppAD Interface to Ipopt: solution
-         Sacado Speed: Gradient of Ode Solution
-         CppAD Speed: Gradient of Ode Solution
-         Double Speed: Ode Solution
-         Speed Testing the Jacobian of Ode Solution
-         Taylor's Ode Solver: An Example and Test: ODE Solution
-         Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Derivative of ODE Solution
-         Taylor's Ode Solver: A Multi-Level Adolc Example and Test: ODE Solution
-         Taylor's Ode Solver: A Multi-Level AD Example and Test: Derivative of ODE Solution
-         Taylor's Ode Solver: A Multi-Level AD Example and Test: ODE Solution
-         ODE Inverse Problem Definitions: Source Code: Solution Method
-         ODE Inverse Problem Definitions: Source Code: Measurements.Simulation Analytic Solution
-         Use Ipopt to Solve a Nonlinear Programming Problem: solution
-         Solve a Quadratic Program Using Interior Point Method: Solution
-         Checkpointing an Extended ODE Solver: Example and Test: Solution
-         Checkpointing an ODE Solver: Example and Test: Solution
-solve LU Factorization of A Square Matrix and Stability Calculation
-      Lu Factor and Solve With Recorded Pivoting: Example and Test
-      Lu Factor and Solve with Recorded Pivoting
-      Use Ipopt to Solve a Nonlinear Programming Problem
-      A 3rd and 4th Order Rosenbrock ODE Solver
-      An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-      LU Factorization of A Square Matrix
-      Compute Determinant and Solve Linear Equations
-      Compute Determinants and Solve Equations by LU Factorization
-      abs_normal: Solve a Quadratic Program With Box Constraints
-      Solve a Quadratic Program Using Interior Point Method
-      abs_normal: Solve a Linear Program With Box Constraints
-      abs_normal: Solve a Linear Program Using Simplex Method
-solver A 3rd and 4th Order Rosenbrock ODE Solver
-       An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-       Checkpointing an Extended ODE Solver: Example and Test: ODE Solver
-       Checkpointing an ODE Solver: Example and Test: ODE Solver
-solver: Taylor's Ode Solver: An Example and Test
-        Taylor's Ode Solver: A Multi-Level Adolc Example and Test
-        Taylor's Ode Solver: A Multi-Level AD Example and Test
-        Checkpointing an Extended ODE Solver: Example and Test
-        Checkpointing an ODE Solver: Example and Test
-solvers An Error Controller for Gear's Ode Solvers
-        An Error Controller for ODE Solvers
-some Some Numerical AD Utilities
-     Some General Purpose Utilities
-sort Returns Indices that Sort a Vector
-sort: Index Sort: Example and Test
-sorting Some General Purpose Utilities: Miscellaneous.Sorting Indices
-source Main Program For Comparing C and C++ Speed: Source Code
-       Determine Amount of Time to Execute det_by_minor: Source Code
-       Returns Elapsed Number of Seconds: Source Code
-       Repeat det_by_minor Routine A Specified Number of Times: Source Code
-       Correctness Test of det_by_minor Routine: Source Code
-       Simulate a [0,1] Uniform Random Variate: Source Code
-       Compute Determinant using Expansion by Minors: Source Code
-       Determinant of a Minor: Source Code
-       Define Matrix Multiply as a User Atomic Operation: Begin Source
-       ODE Fitting Using Fast Representation
-       ODE Fitting Using Simple Representation
-       ODE Inverse Problem Definitions: Source Code
-       ODE Fitting Using Fast Representation: Source
-       ODE Fitting Using Simple Representation: Source
-       An ODE Inverse Problem Example: Source
-       Source: uniform_01
-       Simulate a [0,1] Uniform Random Variate: Source Code
-       Source: sparse_hes_fun
-       Evaluate a Function That Has a Sparse Hessian: Source Code
-       Source: sparse_jac_fun
-       Evaluate a Function That Has a Sparse Jacobian: Source Code
-       Source: ode_evaluate
-       Evaluate a Function Defined in Terms of an ODE: Source Code
-       Source: mat_sum_sq
-       Sum Elements of a Matrix Times Itself: Source Code
-       Source: det_grad_33
-       Check Gradient of Determinant of 3 by 3 matrix: Source Code
-       Source: det_33
-       Check Determinant of 3 by 3 matrix: Source Code
-       Source: det_by_minor
-       Determinant Using Expansion by Minors: Source Code
-       Source: det_of_minor
-       Determinant of a Minor: Source Code
-       Source: det_by_lu
-       Determinant Using Expansion by Lu Factorization: Source Code
-       Speed Testing Utilities: Source Code
-       Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Source
-       Taylor's Ode Solver: A Multi-Level AD Example and Test: Source
-       Multiple Level of AD: Example and Test: Source
-       Source Code for eigen_plugin.hpp
-       ODE Inverse Problem Definitions: Source Code: Source
-       ODE Inverse Problem Definitions: Source Code
-       An Error Controller for Gear's Ode Solvers: Source Code
-       An Arbitrary Order Gear Method: Source Code
-       An Error Controller for ODE Solvers: Source Code
-       A 3rd and 4th Order Rosenbrock ODE Solver: Source Code
-       An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Source Code
-       Multi-dimensional Romberg Integration: Source Code
-       One DimensionalRomberg Integration: Source Code
-       Source: LuInvert
-       Invert an LU Factored Equation: Source
-       Source: LuFactor
-       LU Factorization of A Square Matrix: Source
-       Source: LuSolve
-       Compute Determinant and Solve Linear Equations: Source
-       Source: Poly
-       Evaluate a Polynomial or its Derivative: Source
-       Specifications for A Team of AD Threads: Source
-       Timing Test of Multi-Threaded Newton Method: Source
-       A Multi-Threaded Newton's Method: Source
-       Take Down Multi-threaded Newton Method: Source
-       Do One Thread's Work for Multi-Threaded Newton Method: Source
-       Set Up Multi-Threaded Newton Method: Source
-       Common Variables use by Multi-Threaded Newton Method: Source
-       Multi-Threaded Newton Method Example / Test: Source File
-       Run Multi-Threaded User Atomic Calculation: Source
-       Multi-Threaded User Atomic Take Down: Source
-       Multi-Threaded User Atomic Worker: Source
-       Multi-Threaded User Atomic Set Up: Source
-       Multi-Threaded User Atomic Common Information: Source
-       Defines a User Atomic Operation that Computes Square Root: Source
-       Multi-Threading User Atomic Example / Test: Source File
-       Timing Test of Multi-Threaded Summation of 1/i: Source
-       Multi-Threaded Implementation of Summation of 1/i: Source
-       Take Down Multi-threading Sum of 1/i: Source
-       Do One Thread's Work for Sum of 1/i: Source
-       Set Up Multi-threading Sum of 1/i: Source
-       Common Variables Used by Multi-threading Sum of 1/i: Source
-       Multi-Threading Harmonic Summation Example / Test: Source File
-       Using a Team of AD Threads: Example and Test: Source Code
-       A Simple pthread AD: Example and Test: Source Code
-       A Simple Boost Threading AD: Example and Test: Source Code
-       A Simple OpenMP AD: Example and Test: Source Code
-       A Simple Parallel Pthread Example and Test: Source Code
-       A Simple Boost Thread Example and Test: Source Code
-       A Simple OpenMP Example and Test: Source Code
-       Run Multi-Threading Examples and Speed Tests: Source
-       min_nso_quad Source Code
-       abs_normal min_nso_quad: Example and Test: Source
-       Non-Smooth Optimization Using Abs-normal Quadratic Approximations: Source
-       abs_min_quad Source Code
-       abs_min_quad: Example and Test: Source
-       abs_normal: Minimize a Linear Abs-normal Approximation: Source
-       qp_box Source Code
-       abs_normal qp_box: Example and Test: Source
-       abs_normal: Solve a Quadratic Program With Box Constraints: Source
-       qp_interior Source Code
-       abs_normal qp_interior: Example and Test: Source
-       Solve a Quadratic Program Using Interior Point Method: Source
-       min_nso_linear Source Code
-       abs_normal min_nso_linear: Example and Test: Source
-       Non-Smooth Optimization Using Abs-normal Linear Approximations: Source
-       abs_min_linear Source Code
-       abs_min_linear: Example and Test: Source
-       abs_normal: Minimize a Linear Abs-normal Approximation: Source
-       lp_box Source Code
-       abs_normal lp_box: Example and Test: Source
-       abs_normal: Solve a Linear Program With Box Constraints: Source
-       simplex_method Source Code
-       abs_normal simplex_method: Example and Test: Source
-       abs_normal: Solve a Linear Program Using Simplex Method: Source
-       abs_eval Source Code
-       abs_eval: Example and Test: Source
-       abs_normal: Evaluate First Order Approximation: Source
-       abs_normal Getting Started: Example and Test: Source
-       Using Adolc with Multiple Levels of Taping: Example and Test: Source
-       Printing During Forward Mode: Example and Test: Source Code
-       Correctness Tests For Exponential Approximation in Introduction: Source
-       Download The CppAD Source Code: Source Code Control
-       Download The CppAD Source Code
-source: Source: uniform_01
-        Source: sparse_hes_fun
-        Source: sparse_jac_fun
-        Source: ode_evaluate
-        Source: mat_sum_sq
-        Source: det_grad_33
-        Source: det_33
-        Source: det_by_minor
-        Source: det_of_minor
-        Source: det_by_lu
-        Source: LuInvert
-        Source: LuFactor
-        Source: LuSolve
-        Source: Poly
-sout Solve a Quadratic Program Using Interior Point Method: sout
-sparse Sacado Speed: Sparse Hessian
-       Fadbad Speed: Sparse Hessian
-       CppAD Speed: Sparse Jacobian
-       CppAD Speed: Sparse Hessian
-       adolc Speed: Sparse Jacobian
-       Adolc Speed: Sparse Hessian
-       Double Speed: Sparse Jacobian
-       Double Speed: Sparse Hessian
-       Evaluate a Function That Has a Sparse Hessian
-       Evaluate a Function That Has a Sparse Jacobian
-       Speed Testing Sparse Jacobian
-       Speed Testing Sparse Hessian
-       Use Ipopt to Solve a Nonlinear Programming Problem: options.Sparse
-       Sparse Matrix Row, Column, Value Representation
-       Some General Purpose Utilities: Miscellaneous.Sparse Matrices
-       Sparse Hessian Using Subgraphs and Jacobian: Example and Test
-       Computing Sparse Jacobian Using Reverse Mode: Example and Test
-       Compute Sparse Jacobians Using Subgraphs
-       Subset of a Sparse Hessian: Example and Test
-       Computing Sparse Hessian for a Subset of Variables
-       Sparse Hessian: Example and Test
-       Sparse Hessian
-       Computing Sparse Hessian: Example and Test
-       Computing Sparse Hessians
-       Sparse Jacobian: Example and Test
-       Sparse Jacobian
-       Computing Sparse Jacobian Using Reverse Mode: Example and Test
-       Computing Sparse Jacobian Using Forward Mode: Example and Test
-       Computing Sparse Jacobians
-       Jacobian Sparsity Pattern: Reverse Mode
-       Calculating Sparse Derivatives
-       ColPack: Sparse Hessian Example and Test
-       ColPack: Sparse Hessian Example and Test
-       ColPack: Sparse Jacobian Example and Test
-       ColPack: Sparse Jacobian Example and Test
-sparse_hes_fun Source: sparse_hes_fun
-               sparse_hes_fun: Example and test
-               Evaluate a Function That Has a Sparse Hessian
-sparse_hes_fun: sparse_hes_fun: Example and test
-sparse_jac_for Computing Sparse Jacobians: sparse_jac_for
-sparse_jac_fun Source: sparse_jac_fun
-               sparse_jac_fun: Example and test
-               Evaluate a Function That Has a Sparse Jacobian
-sparse_jac_fun: sparse_jac_fun: Example and test
-sparse_jac_rev Computing Sparse Jacobians: sparse_jac_rev
-sparse_jacobian sacado Speed: sparse_jacobian
-                fadbad Speed: sparse_jacobian
-sparse_rc: sparse_rc: Example and Test
-sparse_rcv: sparse_rcv: Example and Test
-sparsity The CppAD Wish List: Atomic.Sparsity
-         Glossary: Sparsity Pattern
-         Running the Speed Test Program: Sparsity Options
-         Row and Column Index Sparsity Patterns
-         Subgraph Dependency Sparsity Patterns: Example and Test
-         Subgraph Dependency Sparsity Patterns
-         Preferred Sparsity Patterns: Row and Column Indices: Example and Test
-         Forward Mode Hessian Sparsity: Example and Test
-         Hessian Sparsity Pattern: Forward Mode
-         Forward Mode Hessian Sparsity Patterns: Sparsity for Entire Hessian
-         Forward Mode Hessian Sparsity Patterns
-         Sparsity Patterns For a Subset of Variables: Example and Test
-         Reverse Mode Hessian Sparsity: Example and Test
-         Hessian Sparsity Pattern: Reverse Mode: Entire Sparsity Pattern
-         Hessian Sparsity Pattern: Reverse Mode
-         Reverse Mode Hessian Sparsity Patterns: Sparsity for Entire Hessian
-         Reverse Mode Hessian Sparsity Patterns
-         Reverse Mode Jacobian Sparsity: Example and Test
-         Jacobian Sparsity Pattern: Reverse Mode: Entire Sparsity Pattern
-         Jacobian Sparsity Pattern: Reverse Mode
-         Reverse Mode Jacobian Sparsity Patterns: Sparsity for Entire Jacobian
-         Reverse Mode Jacobian Sparsity Patterns
-         Forward Mode Jacobian Sparsity: Example and Test
-         Jacobian Sparsity Pattern: Forward Mode: Entire Sparsity Pattern
-         Jacobian Sparsity Pattern: Forward Mode
-         Forward Mode Jacobian Sparsity Patterns: Sparsity for Entire Jacobian
-         Forward Mode Jacobian Sparsity Patterns
-         Construct an ADFun Object and Stop Recording: Assignment Operator.Sparsity Patterns
-         Calculating Sparse Derivatives: Old Sparsity Patterns
-         Calculating Sparse Derivatives: Preferred Sparsity Patterns
-         Calculating Sparsity Patterns: Old Sparsity Patterns
-         Calculating Sparsity Patterns: Preferred Sparsity Patterns
-         Calculating Sparsity Patterns
-         Tan and Tanh as User Atomic Operations: Example and Test: sparsity
-         Atomic Sparsity with Set Patterns: Example and Test
-         Reciprocal as an Atomic Operation: Example and Test: sparsity
-         Atomic Euclidean Norm Squared: Example and Test: sparsity
-         Atomic Reverse Hessian Sparsity Patterns
-         Atomic Forward Hessian Sparsity Patterns
-         Atomic Reverse Jacobian Sparsity Patterns
-         Atomic Forward Jacobian Sparsity Patterns
-         Atomic Function Constructor: atomic_base.sparsity
-         User Defined Atomic AD Functions: Examples.Hessian Sparsity Patterns
-         Checkpointing Functions: sparsity
-         Including the ColPack Sparsity Calculations
-         Using CMake to Configure CppAD
-sparsity: Forward Mode Hessian Sparsity: Example and Test
-          Forward Mode Hessian Sparsity: Example and Test
-          Reverse Mode Hessian Sparsity: Example and Test
-          Reverse Mode Hessian Sparsity: Example and Test
-          Reverse Mode Jacobian Sparsity: Example and Test
-          Reverse Mode Jacobian Sparsity: Example and Test
-          Forward Mode Jacobian Sparsity: Example and Test
-          Forward Mode Jacobian Sparsity: Example and Test
-          Atomic Reverse Hessian Sparsity: Example and Test
-          Atomic Forward Hessian Sparsity: Example and Test
-          Atomic Reverse Jacobian Sparsity: Example and Test
-          Atomic Forward Jacobian Sparsity: Example and Test
-special The CppAD Wish List: Optimization.Special Operators
-        The Theory of Forward Mode: Standard Math Functions.Special Cases
-        Second Order Forward Mode: Derivative Values: Special Case
-        First Order Forward Mode: Derivative Values: Special Case
-        Zero Order Forward Mode: Function Values: Special Case
-specifications Sacado Speed: Second Derivative of a Polynomial: Specifications
-               Sacado Speed: Gradient of Ode Solution: Specifications
-               Sacado Speed: Matrix Multiplication: Specifications
-               Sacado Speed: Gradient of Determinant Using Lu Factorization: Specifications
-               Sacado Speed: Gradient of Determinant by Minor Expansion: Specifications
-               Fadbad Speed: Second Derivative of a Polynomial: Specifications
-               Fadbad Speed: Ode: Specifications
-               Fadbad Speed: Matrix Multiplication: Specifications
-               Fadbad Speed: Gradient of Determinant Using Lu Factorization: Specifications
-               Fadbad Speed: Gradient of Determinant by Minor Expansion: Specifications
-               CppAD Speed: Sparse Jacobian: Specifications
-               CppAD Speed: Sparse Hessian: Specifications
-               CppAD Speed: Second Derivative of a Polynomial: Specifications
-               CppAD Speed: Gradient of Ode Solution: Specifications
-               CppAD Speed, Matrix Multiplication: Specifications
-               CppAD Speed: Gradient of Determinant Using Lu Factorization: Specifications
-               CppAD Speed: Gradient of Determinant by Minor Expansion: Specifications
-               adolc Speed: Sparse Jacobian: Specifications
-               Adolc Speed: Sparse Hessian: Specifications
-               Adolc Speed: Second Derivative of a Polynomial: Specifications
-               Adolc Speed: Ode: Specifications
-               Adolc Speed: Matrix Multiplication: Specifications
-               Adolc Speed: Gradient of Determinant Using Lu Factorization: Specifications
-               Adolc Speed: Gradient of Determinant by Minor Expansion: Specifications
-               Double Speed: Sparse Jacobian: Specifications
-               Double Speed: Sparse Hessian: Specifications
-               Double Speed: Evaluate a Polynomial: Specifications
-               Double Speed: Ode Solution: Specifications
-               CppAD Speed: Matrix Multiplication (Double Version): Specifications
-               Double Speed: Determinant Using Lu Factorization: Specifications
-               Double Speed: Determinant by Minor Expansion: Specifications
-               Specifications for A Team of AD Threads
-specified Repeat det_by_minor Routine A Specified Number of Times
-          Get At Least A Specified Amount of Memory
-          Get At Least A Specified Amount of Memory
-          Definition of a Simple Vector: Elements of Specified Type
-speed Main Program For Comparing C and C++ Speed
-      Compare Speed of C and C++
-      Speed Test for Both Simple and Fast Representations
-      Get At Least A Specified Amount of Memory: Allocation Speed
-      The CppAD Wish List: Compilation Speed
-      Frequently Asked Questions and Answers: Speed
-      Sacado Speed: Second Derivative of a Polynomial
-      Sacado Speed: Gradient of Ode Solution
-      Sacado Speed: Matrix Multiplication
-      Sacado Speed: Gradient of Determinant Using Lu Factorization
-      Sacado Speed: Gradient of Determinant by Minor Expansion
-      Speed Test Derivatives Using Sacado
-      Fadbad Speed: Second Derivative of a Polynomial
-      Fadbad Speed: Ode
-      Fadbad Speed: Matrix Multiplication
-      Fadbad Speed: Gradient of Determinant Using Lu Factorization
-      Fadbad Speed: Gradient of Determinant by Minor Expansion
-      Speed Test Derivatives Using Fadbad
-      CppAD Speed: Sparse Jacobian
-      CppAD Speed: Sparse Hessian
-      CppAD Speed: Second Derivative of a Polynomial
-      CppAD Speed: Gradient of Ode Solution
-      CppAD Speed, Matrix Multiplication
-      CppAD Speed: Gradient of Determinant Using Lu Factorization
-      CppAD Speed: Gradient of Determinant by Minor Expansion
-      Speed Test Derivatives Using CppAD
-      adolc Speed: Sparse Jacobian
-      Adolc Speed: Sparse Hessian
-      Adolc Speed: Second Derivative of a Polynomial
-      Adolc Speed: Ode
-      Adolc Speed: Matrix Multiplication
-      Adolc Speed: Gradient of Determinant Using Lu Factorization
-      Adolc Speed: Gradient of Determinant by Minor Expansion
-      Speed Test of Derivatives Using Adolc
-      Double Speed: Sparse Jacobian
-      Double Speed: Sparse Hessian
-      Double Speed: Evaluate a Polynomial
-      Double Speed: Ode Solution
-      CppAD Speed: Matrix Multiplication (Double Version)
-      Double Speed: Determinant Using Lu Factorization
-      Double Speed: Determinant by Minor Expansion
-      Speed Test of Functions in Double
-      Sum Elements of a Matrix Times Itself
-      Speed Testing Utilities: Speed Utility Routines
-      Speed Testing Utilities: Speed Main Program
-      Speed Testing Utilities
-      Speed Testing Sparse Jacobian
-      Speed Testing Sparse Hessian
-      Speed Testing Second Derivative of a Polynomial
-      Speed Testing the Jacobian of Ode Solution
-      Speed Testing Derivative of Matrix Multiply
-      Speed Testing Gradient of Determinant by Minor Expansion
-      Speed Testing Gradient of Determinant Using Lu Factorization
-      Running the Speed Test Program: Speed Results
-      Running the Speed Test Program: test.speed
-      Running the Speed Test Program
-      Speed Test an Operator Overloading AD Package
-      Run the Speed Examples
-      Get At Least A Specified Amount of Memory: Allocation Speed
-      Setup thread_alloc For Use in Multi-Threading Environment: Speed
-      Determine Amount of Time to Execute a Test
-      Example Use of SpeedTest
-      Run One Speed Test and Print Results
-      Run One Speed Test and Return Results
-      Specifications for A Team of AD Threads: Speed Test of Implementation
-      Run Multi-Threading Examples and Speed Tests
-      Optimize an ADFun Object Tape: Speed Testing
-      Optimize an ADFun Object Tape
-      Comparison Changes Between Taping and Zero Order Forward: count.Speed
-      AD Vectors that Record Index Operations: Speed and Memory
-      Including the Sacado Speed Tests: Speed Tests
-      Including the Sacado Speed Tests
-      Including the FADBAD Speed Tests: Speed Tests
-      Including the FADBAD Speed Tests
-      Including the ADOL-C Examples and Tests: Speed Tests
-     compare C and C++ Compare Speed of C and C++
-speed: sacado Speed: sparse_jacobian
-       Sacado Speed: Sparse Hessian
-       Sacado Speed: Second Derivative of a Polynomial
-       Sacado Speed: Gradient of Ode Solution
-       Sacado Speed: Matrix Multiplication
-       Sacado Speed: Gradient of Determinant Using Lu Factorization
-       Sacado Speed: Gradient of Determinant by Minor Expansion
-       fadbad Speed: sparse_jacobian
-       Fadbad Speed: Sparse Hessian
-       Fadbad Speed: Second Derivative of a Polynomial
-       Fadbad Speed: Ode
-       Fadbad Speed: Matrix Multiplication
-       Fadbad Speed: Gradient of Determinant Using Lu Factorization
-       Fadbad Speed: Gradient of Determinant by Minor Expansion
-       CppAD Speed: Sparse Jacobian
-       CppAD Speed: Sparse Hessian
-       CppAD Speed: Second Derivative of a Polynomial
-       CppAD Speed: Gradient of Ode Solution
-       CppAD Speed: Gradient of Determinant Using Lu Factorization
-       CppAD Speed: Gradient of Determinant by Minor Expansion
-       adolc Speed: Sparse Jacobian
-       Adolc Speed: Sparse Hessian
-       Adolc Speed: Second Derivative of a Polynomial
-       Adolc Speed: Ode
-       Adolc Speed: Matrix Multiplication
-       Adolc Speed: Gradient of Determinant Using Lu Factorization
-       Adolc Speed: Gradient of Determinant by Minor Expansion
-       Double Speed: Sparse Jacobian
-       Double Speed: Sparse Hessian
-       Double Speed: Evaluate a Polynomial
-       Double Speed: Ode Solution
-       CppAD Speed: Matrix Multiplication (Double Version)
-       Double Speed: Determinant Using Lu Factorization
-       Double Speed: Determinant by Minor Expansion
-speed_test speed_test: Example and test
-           Run One Speed Test and Return Results
-speed_test: speed_test: Example and test
-speedtest Example Use of SpeedTest
-sqrt Square Root Function Reverse Mode Theory
-     Square Root Function Forward Mode Theory
-     The AD sqrt Function: Example and Test
-     The Square Root Function: sqrt
-square LU Factorization of A Square Matrix and Stability Calculation
-       Square Root Function Reverse Mode Theory
-       Square Root Function Forward Mode Theory
-       Sum of the Elements of the Square of a Matrix: Example and Test
-       LU Factorization of A Square Matrix
-       Defines a User Atomic Operation that Computes Square Root
-       The Square Root Function: sqrt
-square_root Run Multi-Threaded User Atomic Calculation: square_root
-            Multi-Threaded User Atomic Take Down: square_root
-squared: Atomic Euclidean Norm Squared: Example and Test
-st Atomic Reverse Jacobian Sparsity Patterns: Implementation.st
-stability LU Factorization of A Square Matrix and Stability Calculation
-stack Example Differentiating a Stack Machine Interpreter
-standard zdouble: An AD Base Type With Absolute Zero: Syntax.Standard Math
-         The Theory of Reverse Mode: Standard Math Functions
-         The Theory of Forward Mode: Standard Math Functions
-         Union of Standard Sets
-         Enable use of AD<Base> where Base is double: Unary Standard Math
-         Enable use of AD<Base> where Base is float: Unary Standard Math
-         Enable use of AD<Base> where Base is Adolc's adouble Type: Unary Standard Math
-         Example AD<Base> Where Base Constructor Allocates Memory: Unary Standard Math
-         Base Type Requirements for Standard Math Functions: Unary Standard Math
-         Base Type Requirements for Standard Math Functions
-         AD<Base> Requirements for a CppAD Base Type: Standard Base Types
-         The Unary Standard Math Functions
-start Using Multiple Levels of AD: Procedure.Second Start AD< AD<double> >
-      Using Multiple Levels of AD: Procedure.Start AD< AD<double> > Recording
-      Using Multiple Levels of AD: Procedure.First Start AD<double>
-      Getting Started Using CppAD to Compute Derivatives
-      Do One Thread's Work for Sum of 1/i: start
-      Declare Independent Variables and Start Recording: Start Recording
-      Declare Independent Variables and Start Recording
-      Matrix Multiply as an Atomic Operation: Start Class Definition
-      Atomic Eigen Cholesky Factorization Class: Start Class Definition
-      Atomic Eigen Matrix Inversion Class: Start Class Definition
-      Atomic Eigen Matrix Multiply Class: Start Class Definition
-      Tan and Tanh as User Atomic Operations: Example and Test: Start Class Definition
-      Atomic Sparsity with Set Patterns: Example and Test: Start Class Definition
-      Reciprocal as an Atomic Operation: Example and Test: Start Class Definition
-      Atomic Euclidean Norm Squared: Example and Test: Start Class Definition
-      Getting Started with Atomic Operations: Example and Test: Start Class Definition
-      Atomic Reverse Hessian Sparsity: Example and Test: Start Class Definition
-      Atomic Forward Hessian Sparsity: Example and Test: Start Class Definition
-      Atomic Reverse Jacobian Sparsity: Example and Test: Start Class Definition
-      Atomic Forward Jacobian Sparsity: Example and Test: Start Class Definition
-      Atomic Reverse: Example and Test: Start Class Definition
-      Atomic Forward: Example and Test: Start Class Definition
-started Getting Started Using CppAD to Compute Derivatives
-        Getting Started with Atomic Operations: Example and Test
-        User Defined Atomic AD Functions: Examples.Getting Started
-started: abs_normal Getting Started: Example and Test
-state Controlling Taylor Coefficients Memory Allocation: Original State
-static User Defined Atomic AD Functions: Syntax Function.Free Static Memory
-       Memory Leak Detection
-       Free Static Variables
-status Nonlinear Programming Using the CppAD Interface to Ipopt: solution.status
-       Use Ipopt to Solve a Nonlinear Programming Problem: solution.status
-std Choosing the CppAD Test Vector Template Class: std
-std::complex<double> Enable use of AD<Base> where Base is std::complex<double>
-std::numeric_limits Numeric Limits For an AD and Base Types: std::numeric_limits
-std::vector Choosing The Vector Testing Template Class: std::vector
-            Using The CppAD Test Vector Template Class: std::vector
-stegun Bibliography: Abramowitz and Stegun
-step An Error Controller for ODE Solvers: Method.step
-     Solve a Quadratic Program Using Interior Point Method: Newton Step
-     CppAD Download, Test, and Install Instructions: Instructions.Step 4: Installation
-     CppAD Download, Test, and Install Instructions: Instructions.Step 3: Check
-     CppAD Download, Test, and Install Instructions: Instructions.Step 2: Cmake
-     CppAD Download, Test, and Install Instructions: Instructions.Step 1: Download
-steps Reverse Mode General Case (Checkpointing): Example and Test: Processing Steps
-stiff A Stiff Ode: Example and Test
-      An Arbitrary Order Gear Method
-      A 3rd and 4th Order Rosenbrock ODE Solver
-stop Stop Recording and Store Operation Sequence
-     Construct an ADFun Object and Stop Recording
-     Declare Independent Variables and Start Recording: Stop Recording
-storage LU Factorization of A Square Matrix and Stability Calculation: Matrix Storage
-        Lu Factor and Solve with Recorded Pivoting: Storage Convention
-        Invert an LU Factored Equation: Matrix Storage
-        LU Factorization of A Square Matrix: Matrix Storage
-        Compute Determinant and Solve Linear Equations: Matrix Storage
-storage: Frequently Asked Questions and Answers: Tape Storage: Disk or Memory
-store Stop Recording and Store Operation Sequence
-stored Number Taylor Coefficient Orders Currently Stored
-stream AD Output Stream Operator
-       AD Output Stream Operator
-string Use Ipopt to Solve a Nonlinear Programming Problem: options.String
-       Convert Certain Types to a String
-       Convert An AD or Base Type to String
-structure Directory Structure
-          Using CMake to Configure CppAD
-subgraph The CppAD Wish List: Atomic.Subgraph
-         Running the Speed Test Program: Global Options.subgraph
-         Subgraph Dependency Sparsity Patterns: Example and Test
-         Subgraph Dependency Sparsity Patterns
-subgraphs Sparse Hessian Using Subgraphs and Jacobian: Example and Test
-          Compute Sparse Jacobians Using Subgraphs
-          Reverse Mode Using Subgraphs
-subgraphs: Computing Reverse Mode on Subgraphs: Example and Test
-subset Compute Sparse Jacobians Using Subgraphs: subset
-       Subset of a Sparse Hessian: Example and Test
-       Computing Sparse Hessian for a Subset of Variables: Subset
-       Computing Sparse Hessian for a Subset of Variables
-       Sparse Hessian: Subset Hessian
-       Sparse Hessian: p.Column Subset
-       Computing Sparse Hessians: Subset Hessian
-       Computing Sparse Hessians: pattern.subset
-       Computing Sparse Hessians: subset
-       Computing Sparse Jacobians: subset
-       Sparsity Patterns For a Subset of Variables: Example and Test
-       Subset of Second Order Partials: Example and Test
-subsets Checking the CppAD Examples and Tests: Subsets of make check
-subsparsity Running the Speed Test Program: Sparsity Options.subsparsity
-subtract AD Compound Assignment Subtraction: Example and Test
-         AD Compound Assignment Operators
-         AD Binary Subtraction: Example and Test
-         AD Binary Arithmetic Operators
-subtraction The Theory of Reverse Mode: Binary Operators.Subtraction
-            The Theory of Forward Mode: Binary Operators.Subtraction
-            AD Compound Assignment Operators: Derivative.Subtraction
-            AD Binary Arithmetic Operators: Derivative.Subtraction
-subtraction: AD Compound Assignment Subtraction: Example and Test
-             AD Binary Subtraction: Example and Test
-subversion Download The CppAD Source Code: Source Code Control.Subversion
-suggestion AD<Base> Requirements for a CppAD Base Type: Integer.Suggestion
-sum Sum of the Elements of the Square of a Matrix: Example and Test
-    Sum Elements of a Matrix Times Itself
-    Multi-Threaded Implementation of Summation of 1/i: sum
-    Take Down Multi-threading Sum of 1/i: sum
-    Take Down Multi-threading Sum of 1/i
-    Do One Thread's Work for Sum of 1/i
-    Set Up Multi-threading Sum of 1/i
-    Common Variables Used by Multi-threading Sum of 1/i
-    Example Optimization and Cumulative Sum Operations
-summation Timing Test of Multi-Threaded Summation of 1/i
-          Multi-Threaded Implementation of Summation of 1/i
-          Multi-Threading Harmonic Summation Example / Test
-suppress Suppress Suspect Implicit Conversion Warnings
-suspect Suppress Suspect Implicit Conversion Warnings
-sweep An Important Reverse Mode Identity: Reverse Sweep
-      exp_eps: Verify Second Order Reverse Sweep
-      exp_eps: Verify Second Order Forward Sweep
-      exp_eps: Verify First Order Reverse Sweep
-      exp_eps: Verify First Order Forward Sweep
-      exp_eps: Verify Zero Order Forward Sweep
-      exp_eps: Second Order Reverse Sweep
-      exp_eps: Second Order Forward Mode: Operation Sequence.Sweep
-      exp_eps: First Order Reverse Sweep
-      exp_eps: First Order Forward Sweep: Operation Sequence.Sweep
-      exp_eps: First Order Forward Sweep
-      exp_eps: Operation Sequence and Zero Order Forward Sweep: Operation Sequence.Sweep
-      exp_eps: Operation Sequence and Zero Order Forward Sweep
-      exp_2: Verify Second Order Reverse Sweep
-      exp_2: Verify Second Order Forward Sweep
-      exp_2: Verify First Order Reverse Sweep
-      exp_2: Verify First Order Forward Sweep
-      exp_2: Verify Zero Order Forward Sweep
-      exp_2: Second Order Forward Mode: Operation Sequence.Sweep
-      exp_2: First Order Forward Mode: Operation Sequence.Sweep
-      exp_2: Operation Sequence and Zero Order Forward Mode: Operation Sequence.Sweep
-sweeps exp_eps: CppAD Forward and Reverse Sweeps
-       exp_2: CppAD Forward and Reverse Sweeps
-symbol Frequently Asked Questions and Answers: Namespace.Test Vector Preprocessor Symbol
-symbols CppAD Addons: Preprocessor Symbols
-        CppAD API Preprocessor Symbols
-        cppad-20180000.0: A Package for Differentiation of C++ Algorithms: Preprocessor Symbols
-syntax LU Factorization of A Square Matrix and Stability Calculation: Syntax
-       Jacobian and Hessian of Optimal Values: Syntax
-       Computing Jacobian and Hessian of Bender's Reduced Objective: Syntax
-       Determine Amount of Time to Execute det_by_minor: Syntax
-       Returns Elapsed Number of Seconds: Syntax
-       Repeat det_by_minor Routine A Specified Number of Times: Syntax
-       Correctness Test of det_by_minor Routine: Syntax
-       Simulate a [0,1] Uniform Random Variate: Syntax
-       Compute Determinant using Expansion by Minors: Syntax
-       Determinant of a Minor: Syntax
-       Compare Speed of C and C++: Syntax
-       zdouble: An AD Base Type With Absolute Zero: Syntax
-       Define Matrix Multiply as a User Atomic Operation: Syntax
-       User Defined Atomic AD Functions: Syntax Function
-       Nonlinear Programming Using the CppAD Interface to Ipopt: Syntax
-       Choosing The Vector Testing Template Class: Syntax
-       Machine Epsilon For AD Types: Syntax
-       Memory Leak Detection: Syntax
-       Set Maximum Number of Threads for omp_alloc Allocator: Syntax
-       Check If A Memory Allocation is Efficient for Another Use: Syntax
-       Return A Raw Array to The Available Memory for a Thread: Syntax
-       Allocate Memory and Create A Raw Array: Syntax
-       Amount of Memory Available for Quick Use by a Thread: Syntax
-       Amount of Memory a Thread is Currently Using: Syntax
-       Free Memory Currently Available for Quick Use by a Thread: Syntax
-       Return Memory to omp_alloc: Syntax
-       Get At Least A Specified Amount of Memory: Syntax
-       Get the Current OpenMP Thread Number: Syntax
-       Is The Current Execution in OpenMP Parallel Mode: Syntax
-       Set and Get Maximum Number of Threads for omp_alloc Allocator: Syntax
-       A Quick OpenMP Memory Allocator Used by CppAD: Syntax
-       Routines That Track Use of New and Delete: Syntax
-       OpenMP Parallel Setup: Syntax
-       Comparison Changes During Zero Order Forward Mode: Syntax
-       ADFun Object Deprecated Member Functions: Syntax
-       Adolc Test Utility: Allocate and Free Memory For a Matrix: Syntax
-       Simulate a [0,1] Uniform Random Variate: Syntax
-       Evaluate a Function That Has a Sparse Hessian: Syntax
-       Evaluate a Function That Has a Sparse Jacobian: Syntax
-       Evaluate a Function Defined in Terms of an ODE: Syntax
-       Sum Elements of a Matrix Times Itself: Syntax
-       Check Gradient of Determinant of 3 by 3 matrix: Syntax
-       Check Determinant of 3 by 3 matrix: Syntax
-       Determinant Using Expansion by Minors: Syntax
-       Determinant of a Minor: Syntax
-       Determinant Using Expansion by Lu Factorization: Syntax
-       Microsoft Version of Elapsed Number of Seconds: Syntax
-       Running the Speed Test Program: Syntax
-       Suppress Suspect Implicit Conversion Warnings: Syntax
-       Using The CppAD Test Vector Template Class: Syntax
-       Lu Factor and Solve with Recorded Pivoting: Syntax
-       Enable Use of Eigen Linear Algebra Package with CppAD: Syntax
-       Use Ipopt to Solve a Nonlinear Programming Problem: Syntax
-       Sparse Matrix Row, Column, Value Representation: Syntax
-       Row and Column Index Sparsity Patterns: Syntax
-       Union of Standard Sets: Syntax
-       Convert Certain Types to a String: Syntax
-       Returns Indices that Sort a Vector: Syntax
-       Free All Memory That Was Allocated for Use by thread_alloc: Syntax
-       Deallocate An Array and Call Destructor for its Elements: Syntax
-       Allocate An Array and Call Default Constructor for its Elements: Syntax
-       Amount of Memory Available for Quick Use by a Thread: Syntax
-       Amount of Memory a Thread is Currently Using: Syntax
-       Control When Thread Alloc Retains Memory For Future Use: Syntax
-       Free Memory Currently Available for Quick Use by a Thread: Syntax
-       Return Memory to thread_alloc: Syntax
-       Get At Least A Specified Amount of Memory: Syntax
-       Get the Current Thread Number: Syntax
-       Is The Current Execution in Parallel Mode: Syntax
-       Get Number of Threads: Syntax
-       Setup thread_alloc For Use in Multi-Threading Environment: Syntax
-       A Fast Multi-Threading Memory Allocator: Syntax
-       The CppAD::vector Template Class: Syntax
-       An Error Controller for Gear's Ode Solvers: Syntax
-       An Arbitrary Order Gear Method: Syntax
-       An Error Controller for ODE Solvers: Syntax
-       A 3rd and 4th Order Rosenbrock ODE Solver: Syntax
-       An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Syntax
-       Multi-dimensional Romberg Integration: Syntax
-       One DimensionalRomberg Integration: Syntax
-       Invert an LU Factored Equation: Syntax
-       LU Factorization of A Square Matrix: Syntax
-       Compute Determinant and Solve Linear Equations: Syntax
-       Evaluate a Polynomial or its Derivative: Syntax
-       The Integer Power Function: Syntax
-       Obtain Nan or Determine if a Value is Nan: nan(zero).Syntax
-       Obtain Nan or Determine if a Value is Nan: Syntax
-       Check Simple Vector Concept: Syntax
-       Check NumericType Class Concept: Syntax
-       Object that Runs a Group of Tests: Syntax
-       Returns Elapsed Number of Seconds: Syntax
-       Determine Amount of Time to Execute a Test: Syntax
-       Run One Speed Test and Print Results: Syntax
-       Run One Speed Test and Return Results: Syntax
-       Determine if Two Values Are Nearly Equal: Syntax
-       CppAD Assertions During Execution: Syntax
-       Replacing the CppAD Error Handler: Syntax
-       Specifications for A Team of AD Threads: Syntax
-       Timing Test of Multi-Threaded Newton Method: Syntax
-       A Multi-Threaded Newton's Method: Syntax
-       Take Down Multi-threaded Newton Method: Syntax
-       Do One Thread's Work for Multi-Threaded Newton Method: Syntax
-       Set Up Multi-Threaded Newton Method: Syntax
-       Timing Test for Multi-Threaded User Atomic Calculation: Syntax
-       Run Multi-Threaded User Atomic Calculation: Syntax
-       Multi-Threaded User Atomic Take Down: Syntax
-       Multi-Threaded User Atomic Set Up: Syntax
-       Defines a User Atomic Operation that Computes Square Root: Syntax
-       Timing Test of Multi-Threaded Summation of 1/i: Syntax
-       Multi-Threaded Implementation of Summation of 1/i: Syntax
-       Take Down Multi-threading Sum of 1/i: Syntax
-       Do One Thread's Work for Sum of 1/i: Syntax
-       Set Up Multi-threading Sum of 1/i: Syntax
-       Enable AD Calculations During Parallel Mode: Syntax
-       Check an ADFun Object For Nan Results: Syntax
-       Check an ADFun Sequence of Operations: Syntax
-       Non-Smooth Optimization Using Abs-normal Quadratic Approximations: Syntax
-       abs_normal: Minimize a Linear Abs-normal Approximation: Syntax
-       abs_normal: Solve a Quadratic Program With Box Constraints: Syntax
-       Solve a Quadratic Program Using Interior Point Method: Syntax
-       Non-Smooth Optimization Using Abs-normal Linear Approximations: Syntax
-       abs_normal: Minimize a Linear Abs-normal Approximation: Syntax
-       abs_normal: Solve a Linear Program With Box Constraints: Syntax
-       abs_normal: Solve a Linear Program Using Simplex Method: Syntax
-       abs_normal: Evaluate First Order Approximation: Syntax
-       abs_normal: Print a Vector or Matrix: Syntax
-       Create An Abs-normal Representation of a Function: Syntax
-       Optimize an ADFun Object Tape: Syntax
-       Compute Sparse Jacobians Using Subgraphs: Syntax
-       Sparse Hessian: Syntax
-       Computing Sparse Hessians: Syntax
-       Sparse Jacobian: Syntax
-       Computing Sparse Jacobians: Syntax
-       Subgraph Dependency Sparsity Patterns: Syntax
-       Hessian Sparsity Pattern: Forward Mode: Syntax
-       Forward Mode Hessian Sparsity Patterns: Syntax
-       Hessian Sparsity Pattern: Reverse Mode: Syntax
-       Reverse Mode Hessian Sparsity Patterns: Syntax
-       Jacobian Sparsity Pattern: Reverse Mode: Syntax
-       Reverse Mode Jacobian Sparsity Patterns: Syntax
-       Jacobian Sparsity Pattern: Forward Mode: Syntax
-       Forward Mode Jacobian Sparsity Patterns: Syntax
-       Reverse Mode Using Subgraphs: Syntax
-       Any Order Reverse Mode: Syntax
-       Second Order Reverse Mode: Syntax
-       First Order Reverse Mode: Syntax
-       Number of Variables that Can be Skipped: Syntax
-       Controlling Taylor Coefficients Memory Allocation: Syntax
-       Comparison Changes Between Taping and Zero Order Forward: Syntax
-       Number Taylor Coefficient Orders Currently Stored: Syntax
-       Multiple Directions Forward Mode: Syntax
-       Multiple Order Forward Mode: Syntax
-       Second Order Forward Mode: Derivative Values: Syntax
-       First Order Forward Mode: Derivative Values: Syntax
-       Zero Order Forward Mode: Function Values: Syntax
-       Reverse Mode Second Partial Derivative Driver: Syntax
-       Forward Mode Second Partial Derivative Driver: Syntax
-       First Order Derivative: Driver Routine: Syntax
-       First Order Partial Derivative: Driver Routine: Syntax
-       Hessian: Easy Driver: Syntax
-       Jacobian: Driver Routine: Syntax
-       ADFun Sequence Properties: Syntax
-       Abort Recording of an Operation Sequence: Syntax
-       Stop Recording and Store Operation Sequence: Syntax
-       Construct an ADFun Object and Stop Recording: Syntax
-       Declare Independent Variables and Start Recording: Syntax
-       Enable use of AD<Base> where Base is Adolc's adouble Type: Syntax
-       Base Type Requirements for Hash Coding Values: Syntax
-       AD<Base> Requirements for a CppAD Base Type: Syntax
-       AD Vectors that Record Index Operations: Syntax
-       Check if Two Value are Identically Equal: Syntax
-       Is an AD Object a Parameter or Variable: Syntax
-       AD Boolean Functions: Syntax
-       Compare AD and Base Objects for Nearly Equal: Syntax
-       AD Binary Comparison Operators: Syntax
-       Free Static Variables: Syntax
-       Atomic Reverse Hessian Sparsity Patterns: Syntax
-       Atomic Forward Hessian Sparsity Patterns: Syntax
-       Atomic Reverse Jacobian Sparsity Patterns: Syntax
-       Atomic Forward Jacobian Sparsity Patterns: Syntax
-       Atomic Reverse Mode: Syntax
-       Atomic Forward Mode: Syntax
-       Using AD Version of Atomic Function: Syntax
-       Set Atomic Function Options: Syntax
-       Atomic Function Constructor: Syntax
-       User Defined Atomic AD Functions: Syntax
-       Checkpointing Functions: Syntax
-       Numeric Limits For an AD and Base Types: Syntax
-       Discrete AD Functions: Syntax
-       AD Conditional Expressions: Syntax
-       Absolute Zero Multiplication: Syntax
-       The AD Power Function: Syntax
-       AD Two Argument Inverse Tangent Function: Syntax
-       The Sign: sign: Syntax
-       The Logarithm of One Plus Argument: log1p: Syntax
-       The Exponential Function Minus One: expm1: Syntax
-       The Error Function: Syntax
-       The Inverse Hyperbolic Tangent Function: atanh: Syntax
-       The Inverse Hyperbolic Sine Function: asinh: Syntax
-       The Inverse Hyperbolic Cosine Function: acosh: Syntax
-       AD Absolute Value Functions: abs, fabs: Syntax
-       The Hyperbolic Tangent Function: tanh: Syntax
-       The Tangent Function: tan: Syntax
-       The Square Root Function: sqrt: Syntax
-       The Hyperbolic Sine Function: sinh: Syntax
-       The Sine Function: sin: Syntax
-       The Base 10 Logarithm Function: log10: Syntax
-       The Exponential Function: log: Syntax
-       The Exponential Function: exp: Syntax
-       The Hyperbolic Cosine Function: cosh: Syntax
-       The Cosine Function: cos: Syntax
-       Inverse Tangent Function: atan: Syntax
-       Inverse Sine Function: asin: Syntax
-       Inverse Sine Function: acos: Syntax
-       The Unary Standard Math Functions: Syntax
-       AD Compound Assignment Operators: Syntax
-       AD Binary Arithmetic Operators: Syntax
-       AD Unary Minus Operator: Syntax
-       AD Unary Plus Operator: Syntax
-       Convert an AD Variable to a Parameter: Syntax
-       Printing AD Values During Forward Mode: Syntax
-       AD Output Stream Operator: Syntax
-       AD Output Stream Operator: Syntax
-       Convert An AD or Base Type to String: Syntax
-       Convert From AD to Integer: Syntax
-       Convert From an AD Type to its Base Type: Syntax
-       AD Assignment Operator: Syntax
-       AD Constructors: Syntax
-       An Epsilon Accurate Exponential Approximation: Syntax
-       Second Order Exponential Approximation: Syntax
-       Download and Install Sacado in Build Directory: Syntax
-       Download and Install Ipopt in Build Directory: Syntax
-       Download and Install Fadbad in Build Directory: Syntax
-       Download and Install Eigen in Build Directory: Syntax
-       Download and Install ColPack in Build Directory: Syntax
-       Download and Install Adolc in Build Directory: Syntax
-       cppad-20180000.0: A Package for Differentiation of C++ Algorithms: Syntax
-systems Returns Elapsed Number of Seconds: Microsoft Systems
- -T -
-Taylor Taylor's Ode Solver: An Example and Test
-take Take Down Multi-threaded Newton Method
-     Multi-Threaded User Atomic Take Down
-     Take Down Multi-threading Sum of 1/i
-tan Old Tan and Tanh as User Atomic Operations: Example and Test
-    Tangent and Hyperbolic Tangent Reverse Mode Theory
-    Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory
-    Tan and Tanh as User Atomic Operations: Example and Test
-    AD Two Argument Inverse Tangent Function
-    The AD tan Function: Example and Test
-    The Tangent Function: tan
-tangent User Defined Atomic AD Functions: Example.Tangent Function
-        Tangent and Hyperbolic Tangent Reverse Mode Theory
-        Tangent and Hyperbolic Tangent Reverse Mode Theory
-        Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory
-        Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory
-        Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory
-        Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory
-        Inverse Tangent and Hyperbolic Tangent Forward Mode Theory
-        Inverse Tangent and Hyperbolic Tangent Forward Mode Theory
-        Tan and Tanh as User Atomic Operations: Example and Test
-        AD Two Argument Inverse Tangent Function
-        The Inverse Hyperbolic Tangent Function: atanh
-        The Hyperbolic Tangent Function: tanh
-        The Tangent Function: tan
-        Inverse Tangent Function: atan
-tanh Old Tan and Tanh as User Atomic Operations: Example and Test
-     Tan and Tanh as User Atomic Operations: Example and Test
-     The AD tanh Function: Example and Test
-     The Hyperbolic Tangent Function: tanh
-tape Glossary: Tape
-     Frequently Asked Questions and Answers: Tape Storage: Disk or Memory
-     Optimize an ADFun Object Tape
-     Abort Recording of an Operation Sequence
-     Stop Recording and Store Operation Sequence
-     Construct an ADFun Object and Stop Recording
-     AD Vectors that Record Index Operations
-     Interpolation With Retaping: Example and Test
-     Interpolation With Out Retaping: Example and Test
-     Taping Array Index Operation: Example and Test
-     Using CMake to Configure CppAD
-tape_addr_type Autotools Unix Test and Installation: tape_addr_type
-tape_id_type Autotools Unix Test and Installation: tape_id_type
-taping The CppAD Wish List: Optimization.Taping
-       Comparison Changes Between Taping and Zero Order Forward
-       Stop Recording and Store Operation Sequence: Taping
-       Taping Array Index Operation: Example and Test
-       Convert an AD Variable to a Parameter: Example and Test
-       Convert an AD Variable to a Parameter
-taping: Using Adolc with Multiple Levels of Taping: Example and Test
-target Sparse Matrix Row, Column, Value Representation: target
-       Row and Column Index Sparsity Patterns: target
-taylor Glossary: Taylor Coefficient
-       The Theory of Reverse Mode: Taylor Notation
-       Error Function Forward Taylor Polynomial Theory: Taylor Coefficients Recursion
-       Error Function Forward Taylor Polynomial Theory
-       Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory: Taylor Coefficients Recursion
-       Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory
-       Inverse Cosine and Hyperbolic Cosine Forward Mode Theory: Taylor Coefficients Recursion
-       Inverse Sine and Hyperbolic Sine Forward Mode Theory: Taylor Coefficients Recursion
-       Inverse Tangent and Hyperbolic Tangent Forward Mode Theory: Taylor Coefficients Recursion
-       Logarithm Function Forward Mode Theory: Taylor Coefficients Recursion
-       Exponential Function Forward Mode Theory: Taylor Coefficients Recursion
-       The Theory of Forward Mode: Standard Math Functions.Taylor Coefficients Recursion Formula
-       The Theory of Forward Mode: Taylor Notation
-       Third Order Reverse Mode: Example and Test: Taylor Coefficients
-       Controlling Taylor Coefficient Memory Allocation: Example and Test
-       Controlling Taylor Coefficients Memory Allocation
-       Number Taylor Coefficient Orders Currently Stored
-       Construct an ADFun Object and Stop Recording: Assignment Operator.Taylor Coefficients
-       AD Theory for Cholesky Factorization: Notation.Taylor Coefficient
-taylor'Taylor's Ode Solver: An Example and Test
-         Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Taylor's Method Using AD
-         Taylor's Ode Solver: A Multi-Level Adolc Example and Test
-         Taylor's Ode Solver: A Multi-Level AD Example and Test: Taylor's Method Using AD
-         Taylor's Ode Solver: A Multi-Level AD Example and Test
-taylor_size ADFun Object Deprecated Member Functions: taylor_size
-team Pthread Implementation of a Team of AD Threads
-     Boost Thread Implementation of a Team of AD Threads
-     OpenMP Implementation of a Team of AD Threads
-     Specifications for A Team of AD Threads
-     Using a Team of AD Threads: Example and Test
-     Run Multi-Threading Examples and Speed Tests: Team Implementations
-team_create Specifications for A Team of AD Threads: team_create
-team_destroy Specifications for A Team of AD Threads: team_destroy
-team_example Run Multi-Threading Examples and Speed Tests: team_example
-team_name Specifications for A Team of AD Threads: team_name
-team_work Specifications for A Team of AD Threads: team_work
-template Choosing The Vector Testing Template Class
-         Using The CppAD Test Vector Template Class
-         Examples: The CppAD Test Vector Template Class
-         CppAD::vector Template Class: Example and Test
-         The CppAD::vector Template Class
-         Evaluate a Polynomial or its Derivative
-         Simple Vector Template Class: Example and Test
-         Definition of a Simple Vector: Template Class Requirements
-         Some General Purpose Utilities: Miscellaneous.The CppAD Vector Template Class
-         Choosing the CppAD Test Vector Template Class
-terms Evaluate a Function Defined in Terms of an ODE
-test LuRatio: Example and Test
-     opt_val_hes: Example and Test
-     BenderQuad: Example and Test
-     Correctness Test of det_by_minor Routine
-     Autotools Unix Test and Installation
-     zdouble: Example and Test
-     Define Matrix Multiply as a User Atomic Operation
-     Old Matrix Multiply as a User Atomic Operation: Example and Test
-     Old Tan and Tanh as User Atomic Operations: Example and Test
-     Old Atomic Operation Reciprocal: Example and Test
-     Speed Test for Both Simple and Fast Representations
-     Nonlinear Programming Using CppAD and Ipopt: Example and Test
-     Choosing The Vector Testing Template Class
-     OpenMP Memory Allocator: Example and Test
-     Tracking Use of New and Delete: Example and Test
-     Frequently Asked Questions and Answers: Namespace.Test Vector Preprocessor Symbol
-     Speed Test Derivatives Using Sacado
-     Speed Test Derivatives Using Fadbad
-     Speed Test Derivatives Using CppAD
-     Adolc Test Utility: Allocate and Free Memory For a Matrix
-     Speed Test of Derivatives Using Adolc
-     Speed Test of Functions in Double
-     sparse_hes_fun: Example and test
-     sparse_jac_fun: Example and test
-     ode_evaluate: Example and test
-     Sum of the Elements of the Square of a Matrix: Example and Test
-     Sum Elements of a Matrix Times Itself
-     Determinant Using Expansion by Minors: Example and Test
-     Determinant of a Minor: Example and Test
-     Determinant Using Lu Factorization: Example and Test
-     Speed Testing Sparse Jacobian
-     Speed Testing Sparse Hessian
-     Speed Testing Second Derivative of a Polynomial
-     Speed Testing the Jacobian of Ode Solution
-     Speed Testing Derivative of Matrix Multiply
-     Speed Testing Gradient of Determinant by Minor Expansion
-     Speed Testing Gradient of Determinant Using Lu Factorization
-     Running the Speed Test Program: test
-     Running the Speed Test Program
-     Speed Test an Operator Overloading AD Package
-     Using The CppAD Test Vector Template Class
-     Lu Factor and Solve With Recorded Pivoting: Example and Test
-     Example Differentiating a Stack Machine Interpreter
-     Taylor's Ode Solver: An Example and Test
-     Taylor's Ode Solver: A Multi-Level Adolc Example and Test
-     Taylor's Ode Solver: A Multi-Level AD Example and Test
-     A Stiff Ode: Example and Test
-     Multiple Level of AD: Example and Test
-     Gradient of Determinant Using Lu Factorization: Example and Test
-     Gradient of Determinant Using Expansion by Minors: Example and Test
-     Interfacing to C: Example and Test
-     Gradient of Determinant Using LU Factorization: Example and Test
-     Gradient of Determinant Using Expansion by Minors: Example and Test
-     Using Eigen To Compute Determinant: Example and Test
-     Using Eigen Arrays: Example and Test
-     Differentiate Conjugate Gradient Algorithm: Example and Test
-     Example and Test Linking CppAD to Languages Other than C++
-     Creating Your Own Interface to an ADFun Object
-     Examples: The CppAD Test Vector Template Class
-     Nonlinear Programming Retaping: Example and Test
-     Nonlinear Programming Using CppAD and Ipopt: Example and Test
-     sparse_rcv: Example and Test
-     sparse_rc: Example and Test
-     Set Union: Example and Test
-     to_string: Example and Test
-     Index Sort: Example and Test
-     Fast Multi-Threading Memory Allocator: Example and Test
-     CppAD::vectorBool Class: Example and Test
-     CppAD::vector Template Class: Example and Test
-     OdeGearControl: Example and Test
-     OdeGear: Example and Test
-     OdeErrControl: Example and Test Using Maxabs Argument
-     OdeErrControl: Example and Test
-     Rosen34: Example and Test
-     Runge45: Example and Test
-     Runge45: Example and Test
-     One Dimensional Romberg Integration: Example and Test
-     One Dimensional Romberg Integration: Example and Test
-     LuInvert: Example and Test
-     LuFactor: Example and Test
-     LuSolve With Complex Arguments: Example and Test
-     Polynomial Evaluation: Example and Test
-     The Pow Integer Exponent: Example and Test
-     nan: Example and Test
-     The CheckSimpleVector Function: Example and Test
-     Simple Vector Template Class: Example and Test
-     The CheckNumericType Function: Example and Test
-     The NumericType: Example and Test
-     Object that Runs a Group of Tests: test
-     time_test: Example and test
-     Elapsed Seconds: Example and Test
-     Determine Amount of Time to Execute a Test: test
-     Determine Amount of Time to Execute a Test
-     Example Use of SpeedTest
-     speed_test: Example and test
-     Run One Speed Test and Print Results: Test
-     Run One Speed Test and Print Results
-     Run One Speed Test and Return Results: test
-     Run One Speed Test and Return Results
-     NearEqual Function: Example and Test
-     Replacing The CppAD Error Handler: Example and Test
-     Specifications for A Team of AD Threads: Speed Test of Implementation
-     Timing Test of Multi-Threaded Newton Method
-     Multi-Threaded Newton Method Example / Test
-     Timing Test for Multi-Threaded User Atomic Calculation
-     Multi-Threading User Atomic Example / Test
-     Timing Test of Multi-Threaded Summation of 1/i
-     Multi-Threading Harmonic Summation Example / Test
-     Using a Team of AD Threads: Example and Test
-     A Simple pthread AD: Example and Test
-     A Simple Boost Threading AD: Example and Test
-     A Simple OpenMP AD: Example and Test
-     A Simple Parallel Pthread Example and Test
-     A Simple Boost Thread Example and Test
-     A Simple OpenMP Example and Test
-     ADFun Checking For Nan: Example and Test
-     ADFun Check and Re-Tape: Example and Test
-     abs_normal min_nso_quad: Example and Test
-     abs_min_quad: Example and Test
-     abs_normal qp_box: Example and Test
-     abs_normal qp_interior: Example and Test
-     abs_normal min_nso_linear: Example and Test
-     abs_min_linear: Example and Test
-     abs_normal lp_box: Example and Test
-     abs_normal simplex_method: Example and Test
-     abs_eval: Example and Test
-     abs_normal Getting Started: Example and Test
-     Sparse Hessian Using Subgraphs and Jacobian: Example and Test
-     Computing Sparse Jacobian Using Reverse Mode: Example and Test
-     Subset of a Sparse Hessian: Example and Test
-     Sparse Hessian: Example and Test
-     Computing Sparse Hessian: Example and Test
-     Sparse Jacobian: Example and Test
-     Computing Sparse Jacobian Using Reverse Mode: Example and Test
-     Computing Sparse Jacobian Using Forward Mode: Example and Test
-     Subgraph Dependency Sparsity Patterns: Example and Test
-     Preferred Sparsity Patterns: Row and Column Indices: Example and Test
-     Computing Dependency: Example and Test
-     Forward Mode Hessian Sparsity: Example and Test
-     Forward Mode Hessian Sparsity: Example and Test
-     Sparsity Patterns For a Subset of Variables: Example and Test
-     Reverse Mode Hessian Sparsity: Example and Test
-     Reverse Mode Hessian Sparsity: Example and Test
-     Reverse Mode Jacobian Sparsity: Example and Test
-     Reverse Mode Jacobian Sparsity: Example and Test
-     Forward Mode Jacobian Sparsity: Example and Test
-     Forward Mode Jacobian Sparsity: Example and Test
-     Computing Reverse Mode on Subgraphs: Example and Test
-     Reverse Mode General Case (Checkpointing): Example and Test
-     Third Order Reverse Mode: Example and Test
-     Hessian Times Direction: Example and Test
-     Second Order Reverse ModeExample and Test
-     First Order Reverse Mode: Example and Test
-     Number of Variables That Can be Skipped: Example and Test
-     Controlling Taylor Coefficient Memory Allocation: Example and Test
-     CompareChange and Re-Tape: Example and Test
-     Forward Mode: Example and Test of Multiple Directions
-     Forward Mode: Example and Test of Multiple Orders
-     Forward Mode: Example and Test
-     Second Partials Reverse Driver: Example and Test
-     Subset of Second Order Partials: Example and Test
-     First Order Derivative Driver: Example and Test
-     First Order Partial Driver: Example and Test
-     Hessian of Lagrangian and ADFun Default Constructor: Example and Test
-     Hessian: Example and Test
-     Jacobian: Example and Test
-     ADFun Sequence Properties: Example and Test
-     Abort Current Recording: Example and Test
-     ADFun Assignment: Example and Test
-     Independent and ADFun Constructor: Example and Test
-     Complex Polynomial: Example and Test
-     Using Adolc with Multiple Levels of Taping: Example and Test
-     Using a User Defined AD Base Type: Example and Test
-     AD Vectors that Record Index Operations: Example and Test
-     EqualOpSeq: Example and Test
-     AD Parameter and Variable Functions: Example and Test
-     AD Boolean Functions: Example and Test
-     Compare AD with Base Objects: Example and Test
-     AD Binary Comparison Operators: Example and Test
-     User Atomic Matrix Multiply: Example and Test
-     Atomic Eigen Cholesky Factorization: Example and Test
-     Atomic Eigen Matrix Inverse: Example and Test
-     Atomic Eigen Matrix Multiply: Example and Test
-     Tan and Tanh as User Atomic Operations: Example and Test
-     Atomic Sparsity with Set Patterns: Example and Test: Test Atomic Function.Test Result
-     Atomic Sparsity with Set Patterns: Example and Test: Test Atomic Function
-     Atomic Sparsity with Set Patterns: Example and Test
-     Reciprocal as an Atomic Operation: Example and Test
-     Atomic Euclidean Norm Squared: Example and Test
-     Getting Started with Atomic Operations: Example and Test
-     Atomic Reverse Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-     Atomic Reverse Hessian Sparsity: Example and Test
-     Atomic Forward Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-     Atomic Forward Hessian Sparsity: Example and Test
-     Atomic Reverse Jacobian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-     Atomic Reverse Jacobian Sparsity: Example and Test
-     Atomic Forward Jacobian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-     Atomic Forward Jacobian Sparsity: Example and Test
-     Atomic Reverse: Example and Test
-     Atomic Forward: Example and Test
-     Checkpointing an Extended ODE Solver: Example and Test
-     Checkpointing an ODE Solver: Example and Test
-     Atomic Operations and Multiple-Levels of AD: Example and Test
-     Simple Checkpointing: Example and Test
-     Numeric Limits: Example and Test
-     Interpolation With Retaping: Example and Test
-     Interpolation With Out Retaping: Example and Test
-     Taping Array Index Operation: Example and Test
-     Conditional Expressions: Example and Test
-     AD Conditional Expressions: Test
-     AD Absolute Zero Multiplication: Example and Test
-     The AD Power Function: Example and Test
-     The AD atan2 Function: Example and Test
-     Sign Function: Example and Test
-     The AD log1p Function: Example and Test
-     The AD exp Function: Example and Test
-     The AD erf Function: Example and Test
-     The AD atanh Function: Example and Test
-     The AD asinh Function: Example and Test
-     The AD acosh Function: Example and Test
-     AD Absolute Value Function: Example and Test
-     The AD tanh Function: Example and Test
-     The AD tan Function: Example and Test
-     The AD sqrt Function: Example and Test
-     The AD sinh Function: Example and Test
-     The AD sin Function: Example and Test
-     The AD log10 Function: Example and Test
-     The AD log Function: Example and Test
-     The AD exp Function: Example and Test
-     The AD cosh Function: Example and Test
-     The AD cos Function: Example and Test
-     The AD atan Function: Example and Test
-     The AD asin Function: Example and Test
-     The AD acos Function: Example and Test
-     AD Compound Assignment Division: Example and Test
-     AD Compound Assignment Multiplication: Example and Test
-     AD Compound Assignment Subtraction: Example and Test
-     AD Compound Assignment Addition: Example and Test
-     AD Binary Division: Example and Test
-     AD Binary Multiplication: Example and Test
-     AD Binary Subtraction: Example and Test
-     AD Binary Addition: Example and Test
-     AD Unary Minus Operator: Example and Test
-     AD Unary Plus Operator: Example and Test
-     Convert an AD Variable to a Parameter: Example and Test
-     Print During Zero Order Forward Mode: Example and Test
-     Printing During Forward Mode: Example and Test
-     AD Output Operator: Example and Test
-     AD Output Operator: Example and Test
-     Convert From AD to Integer: Example and Test
-     Convert From AD to its Base Type: Example and Test
-     AD Assignment: Example and Test
-     AD Constructors: Example and Test
-     exp_eps: Test of exp_eps
-     An Epsilon Accurate Exponential Approximation: Test
-     exp_2: Test
-     Second Order Exponential Approximation: Test
-     Choosing the CppAD Test Vector Template Class
-     Including the Eigen Examples and Tests: Test Vector
-     ColPack: Sparse Hessian Example and Test
-     ColPack: Sparse Hessian Example and Test
-     ColPack: Sparse Jacobian Example and Test
-     ColPack: Sparse Jacobian Example and Test
-     CppAD Download, Test, and Install Instructions
-test_boolofvoid The CppAD Wish List: test_boolofvoid
-test_size Determine Amount of Time to Execute a Test: test_size
-test_time Timing Test of Multi-Threaded Newton Method: test_time
-          Timing Test for Multi-Threaded User Atomic Calculation: test_time
-          Timing Test of Multi-Threaded Summation of 1/i: test_time
-          Run Multi-Threading Examples and Speed Tests: multi_newton.test_time
-          Run Multi-Threading Examples and Speed Tests: harmonic.test_time
-testing Choosing The Vector Testing Template Class
-        The CppAD Wish List: checkpoint.Testing
-        Speed Testing Utilities
-        Speed Testing Sparse Jacobian
-        Speed Testing Sparse Hessian
-        Speed Testing Second Derivative of a Polynomial
-        Speed Testing the Jacobian of Ode Solution
-        Speed Testing Derivative of Matrix Multiply
-        Speed Testing Gradient of Determinant by Minor Expansion
-        Speed Testing Gradient of Determinant Using Lu Factorization
-        Some General Purpose Utilities: Testing
-        Optimize an ADFun Object Tape: Speed Testing
-        Download The CppAD Source Code: Windows File Extraction and Testing
-tests Autotools Unix Test and Installation: make.Examples and Tests
-      Speed Test Derivatives Using Sacado: Running Tests
-      Speed Test Derivatives Using Fadbad: Running Tests
-      Speed Test Derivatives Using CppAD: Running Tests
-      Speed Test of Derivatives Using Adolc: Running Tests
-      Speed Test of Functions in Double: Running Tests
-      Run the Speed Examples: Running Tests
-      CppAD Examples and Tests: Running Tests
-      CppAD Examples and Tests
-      Object that Runs a Group of Tests
-      Run Multi-Threading Examples and Speed Tests: Running Tests
-      Run Multi-Threading Examples and Speed Tests
-      Correctness Tests For Exponential Approximation in Introduction: Running Tests
-      Correctness Tests For Exponential Approximation in Introduction
-      Checking the CppAD Examples and Tests
-      Including the Sacado Speed Tests: Speed Tests
-      Including the Sacado Speed Tests
-      Including the cppad_ipopt Library and Tests: Examples and Tests
-      Including the cppad_ipopt Library and Tests
-      Including the FADBAD Speed Tests: Speed Tests
-      Including the FADBAD Speed Tests
-      Including the Eigen Examples and Tests
-      Including the ADOL-C Examples and Tests: Speed Tests
-      Including the ADOL-C Examples and Tests
-text Printing AD Values During Forward Mode
-tf An Error Controller for Gear's Ode Solvers: tf
-   An Error Controller for ODE Solvers: tf
-   A 3rd and 4th Order Rosenbrock ODE Solver: tf
-   An Embedded 4th and 5th Order Runge-Kutta ODE Solver: tf
-than Example and Test Linking CppAD to Languages Other than C++
-that Routines That Track Use of New and Delete
-     The Theory of Forward Mode: Standard Math Functions.Cases that Apply Recursion Above
-     Evaluate a Function That Has a Sparse Hessian
-     Evaluate a Function That Has a Sparse Jacobian
-     Computing a Jacobian With Constants that Change
-     Returns Indices that Sort a Vector
-     Free All Memory That Was Allocated for Use by thread_alloc
-     Object that Runs a Group of Tests
-     Defines a User Atomic Operation that Computes Square Root
-     Number of Variables That Can be Skipped: Example and Test
-     Number of Variables that Can be Skipped
-     Example AD Base Types That are not AD<OtherBase>
-     AD Vectors that Record Index Operations: Example and Test
-     AD Vectors that Record Index Operations
-the Your License for the CppAD Software
-    Driver for Running the Ipopt ODE Example
-    Nonlinear Programming Using the CppAD Interface to Ipopt
-    Choosing The Vector Testing Template Class
-    Return A Raw Array to The Available Memory for a Thread
-    Get the Current OpenMP Thread Number
-    Is The Current Execution in OpenMP Parallel Mode
-    The CppAD Wish List
-    Bibliography: The C++ Programming Language
-    The Theory of Reverse Mode
-    The Theory of Forward Mode
-    The Theory of Derivative Calculations
-    Sum of the Elements of the Square of a Matrix: Example and Test
-    Sum of the Elements of the Square of a Matrix: Example and Test
-    Speed Testing the Jacobian of Ode Solution
-    Running the Speed Test Program
-    Using The CppAD Test Vector Template Class
-    Run the Speed Examples
-    Examples: The CppAD Test Vector Template Class
-    Get the Current Thread Number
-    Is The Current Execution in Parallel Mode
-    The CppAD::vector Template Class
-    The Pow Integer Exponent: Example and Test
-    The Integer Power Function
-    The CheckSimpleVector Function: Example and Test
-    The CheckNumericType Function: Example and Test
-    The NumericType: Example and Test
-    Replacing The CppAD Error Handler: Example and Test
-    Replacing the CppAD Error Handler
-    Some General Purpose Utilities: Miscellaneous.The CppAD Vector Template Class
-    Base Type Requirements for Identically Equal Comparisons: EqualOpSeq.The Simple Case
-    The AD Power Function: Example and Test
-    The AD Power Function
-    The AD atan2 Function: Example and Test
-    The Sign: sign
-    The AD log1p Function: Example and Test
-    The Logarithm of One Plus Argument: log1p
-    The AD exp Function: Example and Test
-    The Exponential Function Minus One: expm1
-    The AD erf Function: Example and Test
-    The Error Function
-    The AD atanh Function: Example and Test
-    The Inverse Hyperbolic Tangent Function: atanh
-    The AD asinh Function: Example and Test
-    The Inverse Hyperbolic Sine Function: asinh
-    The AD acosh Function: Example and Test
-    The Inverse Hyperbolic Cosine Function: acosh
-    The AD tanh Function: Example and Test
-    The AD tan Function: Example and Test
-    The AD sqrt Function: Example and Test
-    The AD sinh Function: Example and Test
-    The AD sin Function: Example and Test
-    The AD log10 Function: Example and Test
-    The AD log Function: Example and Test
-    The AD exp Function: Example and Test
-    The AD cosh Function: Example and Test
-    The AD cos Function: Example and Test
-    The AD atan Function: Example and Test
-    The AD asin Function: Example and Test
-    The AD acos Function: Example and Test
-    The Hyperbolic Tangent Function: tanh
-    The Tangent Function: tan
-    The Square Root Function: sqrt
-    The Hyperbolic Sine Function: sinh
-    The Sine Function: sin
-    The Base 10 Logarithm Function: log10
-    The Exponential Function: log
-    The Exponential Function: exp
-    The Hyperbolic Cosine Function: cosh
-    The Cosine Function: cos
-    The Binary Math Functions
-    The Unary Standard Math Functions
-    Checking the CppAD Examples and Tests
-    Choosing the CppAD Test Vector Template Class
-    Including the Sacado Speed Tests
-    Including the cppad_ipopt Library and Tests
-    Including the FADBAD Speed Tests
-    Including the Eigen Examples and Tests
-    Including the ColPack Sparsity Calculations
-    Including the ADOL-C Examples and Tests
-    Using CMake to Configure CppAD: The CMake Program
-    Download The CppAD Source Code
-theorem An Important Reverse Mode Identity: Theorem
-theory Old Tan and Tanh as User Atomic Operations: Example and Test: Theory
-       Old Atomic Operation Reciprocal: Example and Test: Theory
-       Error Function Reverse Mode Theory
-       Tangent and Hyperbolic Tangent Reverse Mode Theory
-       Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
-       Inverse Sine and Hyperbolic Sine Reverse Mode Theory
-       Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory
-       Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
-       Square Root Function Reverse Mode Theory
-       Logarithm Function Reverse Mode Theory
-       Exponential Function Reverse Mode Theory
-       The Theory of Reverse Mode
-       Error Function Forward Taylor Polynomial Theory
-       Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory
-       Inverse Cosine and Hyperbolic Cosine Forward Mode Theory
-       Inverse Sine and Hyperbolic Sine Forward Mode Theory
-       Inverse Tangent and Hyperbolic Tangent Forward Mode Theory
-       Trigonometric and Hyperbolic Sine and Cosine Forward Theory
-       Square Root Function Forward Mode Theory
-       Logarithm Function Forward Mode Theory
-       Exponential Function Forward Mode Theory
-       The Theory of Forward Mode
-       The Theory of Derivative Calculations
-       An Error Controller for Gear's Ode Solvers: Theory
-       An Arbitrary Order Gear Method: Theory
-       An Error Controller for ODE Solvers: Theory
-       AD Theory for Cholesky Factorization
-       Atomic Eigen Matrix Inversion Class: Theory
-       Atomic Eigen Matrix Multiply Class: Theory
-       Tan and Tanh as User Atomic Operations: Example and Test: Theory
-       Reciprocal as an Atomic Operation: Example and Test: Theory
-       Atomic Euclidean Norm Squared: Example and Test: Theory
-theta AD Two Argument Inverse Tangent Function: theta
-third Third Order Reverse Mode: Example and Test
-this Changes and Additions to CppAD: This Year
-     Example Use of SpeedTest: Running This Program
-thread Memory Leak Detection: thread
-       OpenMP Memory Allocator: Example and Test
-       Check If A Memory Allocation is Efficient for Another Use: Thread
-       Return A Raw Array to The Available Memory for a Thread: Thread
-       Return A Raw Array to The Available Memory for a Thread
-       Amount of Memory Available for Quick Use by a Thread: thread
-       Amount of Memory Available for Quick Use by a Thread
-       Amount of Memory a Thread is Currently Using: thread
-       Amount of Memory a Thread is Currently Using
-       Free Memory Currently Available for Quick Use by a Thread: thread
-       Free Memory Currently Available for Quick Use by a Thread
-       Return Memory to omp_alloc: Thread
-       Get the Current OpenMP Thread Number: thread
-       Get the Current OpenMP Thread Number
-       Routines That Track Use of New and Delete
-       Deallocate An Array and Call Destructor for its Elements: Thread
-       Amount of Memory Available for Quick Use by a Thread: thread
-       Amount of Memory Available for Quick Use by a Thread
-       Amount of Memory a Thread is Currently Using: thread
-       Amount of Memory a Thread is Currently Using
-       Control When Thread Alloc Retains Memory For Future Use
-       Free Memory Currently Available for Quick Use by a Thread: thread
-       Free Memory Currently Available for Quick Use by a Thread
-       Return Memory to thread_alloc: Thread
-       Get the Current Thread Number: thread
-       Get the Current Thread Number
-       Boost Thread Implementation of a Team of AD Threads
-       Timing Test of Multi-Threaded Newton Method: Thread
-       A Multi-Threaded Newton's Method: Thread
-       Take Down Multi-threaded Newton Method: Thread
-       Set Up Multi-Threaded Newton Method: Thread
-       Timing Test for Multi-Threaded User Atomic Calculation: Thread
-       Run Multi-Threaded User Atomic Calculation: Thread
-       Multi-Threaded User Atomic Take Down: Thread
-       Multi-Threaded User Atomic Set Up: Thread
-       Timing Test of Multi-Threaded Summation of 1/i: Thread
-       Multi-Threaded Implementation of Summation of 1/i: Thread
-       Take Down Multi-threading Sum of 1/i: Thread
-       Set Up Multi-threading Sum of 1/i: Thread
-       Using a Team of AD Threads: Example and Test
-       A Simple Boost Threading AD: Example and Test
-       A Simple Parallel Pthread Example and Test
-       A Simple Boost Thread Example and Test
-       A Simple OpenMP Example and Test
-       Using CppAD in a Multi-Threading Environment: Same Thread
-thread'Do One Thread's Work for Multi-Threaded Newton Method
-         Do One Thread's Work for Sum of 1/i
-thread_alloc Free All Memory That Was Allocated for Use by thread_alloc
-             Return Memory to thread_alloc
-             Setup thread_alloc For Use in Multi-Threading Environment
-             The CppAD::vector Template Class
-thread_num Setup thread_alloc For Use in Multi-Threading Environment: thread_num
-           Do One Thread's Work for Multi-Threaded Newton Method: thread_num
-           Do One Thread's Work for Sum of 1/i: thread_num
-thread_team Using a Team of AD Threads: Example and Test: thread_team
-threading A Simple Boost Threading AD: Example and Test
-          Run Multi-Threading Examples and Speed Tests: threading
-threads Set Maximum Number of Threads for omp_alloc Allocator
-        Set and Get Maximum Number of Threads for omp_alloc Allocator
-        Get Number of Threads
-        Pthread Implementation of a Team of AD Threads
-        Boost Thread Implementation of a Team of AD Threads
-        OpenMP Implementation of a Team of AD Threads
-        Specifications for A Team of AD Threads
-        Using CMake to Configure CppAD
-threads: Using a Team of AD Threads: Example and Test
-three Atomic Eigen Matrix Inversion Class: Theory.Product of Three Matrices
-ti An Error Controller for Gear's Ode Solvers: ti
-   An Error Controller for ODE Solvers: ti
-   A 3rd and 4th Order Rosenbrock ODE Solver: ti
-   An Embedded 4th and 5th Order Runge-Kutta ODE Solver: ti
-time Determine Amount of Time to Execute det_by_minor: time
-     Determine Amount of Time to Execute det_by_minor
-     An ODE Inverse Problem Example: Trapezoidal Approximation.Trapezoidal Time Grid
-     Returns Elapsed Number of Seconds
-     Determine Amount of Time to Execute a Test: time
-     Determine Amount of Time to Execute a Test
-time_min Determine Amount of Time to Execute det_by_minor: time_min
-         Determine Amount of Time to Execute a Test: time_min
-         Run One Speed Test and Return Results: time_min
-time_out Timing Test of Multi-Threaded Newton Method: time_out
-         Timing Test for Multi-Threaded User Atomic Calculation: time_out
-         Timing Test of Multi-Threaded Summation of 1/i: time_out
-time_test time_test: Example and test
-          Determine Amount of Time to Execute a Test
-time_test: time_test: Example and test
-timer Elapsed Seconds: Example and Test
-times Repeat det_by_minor Routine A Specified Number of Times
-      Sum Elements of a Matrix Times Itself
-      Hessian Times Direction: Example and Test
-      Second Order Reverse Mode: Hessian Times Direction
-      AD Compound Assignment Operators
-      AD Binary Multiplication: Example and Test
-      AD Binary Arithmetic Operators
-timing Determine Amount of Time to Execute a Test: Timing
-       Run One Speed Test and Return Results: Timing
-       Timing Test of Multi-Threaded Newton Method
-       Timing Test for Multi-Threaded User Atomic Calculation
-       Timing Test of Multi-Threaded Summation of 1/i
-to_string Some General Purpose Utilities: Miscellaneous.to_string
-          Enable use of AD<Base> where Base is std::complex<double>: to_string
-          Enable use of AD<Base> where Base is double: to_string
-          Enable use of AD<Base> where Base is float: to_string
-          Enable use of AD<Base> where Base is Adolc's adouble Type: to_string
-          Example AD<Base> Where Base Constructor Allocates Memory: to_string
-          Extending to_string To Another Floating Point Type
-to_string: to_string: Example and Test
-tracing The CppAD Wish List: Tracing
-track Routines That Track Use of New and Delete
-track_count Memory Leak Detection: TRACK_COUNT
-trackcount Routines That Track Use of New and Delete: TrackCount
-trackdelvec Routines That Track Use of New and Delete: TrackDelVec
-trackextend Routines That Track Use of New and Delete: TrackExtend
-tracking Tracking Use of New and Delete: Example and Test
-tracknewvec Routines That Track Use of New and Delete: TrackNewVec
-transpose Subgraph Dependency Sparsity Patterns: transpose
-          Hessian Sparsity Pattern: Reverse Mode: h.transpose true
-          Hessian Sparsity Pattern: Reverse Mode: h.transpose false
-          Hessian Sparsity Pattern: Reverse Mode: transpose
-          Reverse Mode Hessian Sparsity Patterns: transpose
-          Jacobian Sparsity Pattern: Reverse Mode: s.transpose true
-          Jacobian Sparsity Pattern: Reverse Mode: s.transpose false
-          Jacobian Sparsity Pattern: Reverse Mode: r.transpose true
-          Jacobian Sparsity Pattern: Reverse Mode: r.transpose false
-          Jacobian Sparsity Pattern: Reverse Mode: transpose
-          Reverse Mode Jacobian Sparsity Patterns: transpose
-          Jacobian Sparsity Pattern: Forward Mode: s.transpose true
-          Jacobian Sparsity Pattern: Forward Mode: s.transpose false
-          Jacobian Sparsity Pattern: Forward Mode: r.transpose true
-          Jacobian Sparsity Pattern: Forward Mode: r.transpose false
-          Jacobian Sparsity Pattern: Forward Mode: transpose
-          Forward Mode Jacobian Sparsity Patterns: transpose
-trapezoidal ODE Fitting Using Fast Representation: Trapezoidal Approximation
-            ODE Fitting Using Simple Representation: Trapezoidal Approximation Constraint
-            An ODE Inverse Problem Example: Trapezoidal Approximation.Trapezoidal Time Grid
-            An ODE Inverse Problem Example: Trapezoidal Approximation
-            ODE Inverse Problem Definitions: Source Code: Trapezoidal Approximation
-triangular AD Theory for Cholesky Factorization: Notation.Lower Triangular Part
-trigonometric Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
-              Trigonometric and Hyperbolic Sine and Cosine Forward Theory
-true Hessian Sparsity Pattern: Reverse Mode: h.transpose true
-     Jacobian Sparsity Pattern: Reverse Mode: s.transpose true
-     Jacobian Sparsity Pattern: Reverse Mode: r.transpose true
-     Jacobian Sparsity Pattern: Forward Mode: s.transpose true
-     Jacobian Sparsity Pattern: Forward Mode: r.transpose true
-     The Logarithm of One Plus Argument: log1p: CPPAD_USE_CPLUSPLUS_2011.true
-     The Exponential Function Minus One: expm1: CPPAD_USE_CPLUSPLUS_2011.true
-     The Error Function: CPPAD_USE_CPLUSPLUS_2011.true
-     The Inverse Hyperbolic Tangent Function: atanh: CPPAD_USE_CPLUSPLUS_2011.true
-     The Inverse Hyperbolic Sine Function: asinh: CPPAD_USE_CPLUSPLUS_2011.true
-     The Inverse Hyperbolic Cosine Function: acosh: CPPAD_USE_CPLUSPLUS_2011.true
-tvector User Defined Atomic AD Functions: CPPAD_USER_ATOMIC.Tvector
-two An ODE Inverse Problem Example: Black Box Method.Two levels of Iteration
-    Determine if Two Values Are Nearly Equal
-    Second Order Forward Mode: Derivative Values
-    Check if Two Value are Identically Equal
-    Atomic Eigen Matrix Multiply Class: Theory.Product of Two Matrices
-    AD Two Argument Inverse Tangent Function
-tx User Defined Atomic AD Functions: tx
-   Atomic Reverse Mode: tx
-   Atomic Forward Mode: tx
-ty User Defined Atomic AD Functions: ty
-   Atomic Reverse Mode: ty
-   Atomic Forward Mode: ty
-type zdouble: An AD Base Type With Absolute Zero: Base Type Requirements
-     zdouble: An AD Base Type With Absolute Zero
-     Return A Raw Array to The Available Memory for a Thread: Type
-     Allocate Memory and Create A Raw Array: Type
-     Glossary: Base Type
-     Glossary: AD Type Above Base
-     Deallocate An Array and Call Destructor for its Elements: Type
-     Allocate An Array and Call Default Constructor for its Elements: Type
-     The CppAD::vector Template Class: vectorBool.Element Type
-     Evaluate a Polynomial or its Derivative: Type
-     The Integer Power Function: Type
-     Definition of a Simple Vector: Value Type
-     Definition of a Simple Vector: Elements of Specified Type
-     Definition of a Numeric Type: Type Requirements
-     Definition of a Numeric Type
-     Determine if Two Values Are Nearly Equal: Type
-     Enable use of AD<Base> where Base is Adolc's adouble Type
-     Using a User Defined AD Base Type: Example and Test
-     Base Type Requirements for Hash Coding Values
-     Extending to_string To Another Floating Point Type
-     Base Type Requirements for Numeric Limits
-     Base Type Requirements for Standard Math Functions
-     Base Type Requirements for Ordered Comparisons: Ordered Type
-     Base Type Requirements for Ordered Comparisons
-     Base Type Requirements for Identically Equal Comparisons
-     Base Type Requirements for Conditional Expressions: CondExpTemplate.Ordered Type
-     Base Type Requirements for Conditional Expressions
-     AD<Base> Requirements for a CppAD Base Type: Numeric Type
-     AD<Base> Requirements for a CppAD Base Type
-     Compare AD and Base Objects for Nearly Equal: Type
-     AD Conditional Expressions: Type
-     Convert An AD or Base Type to String
-     Convert From an AD Type to its Base Type
-     Convert From an AD Type to its Base Type
-     AD Objects: Base Type Requirements
-     An Epsilon Accurate Exponential Approximation: Type
-     Second Order Exponential Approximation: Type
-type: Using a User Defined AD Base Type: Example and Test
-      Convert From AD to its Base Type: Example and Test
-types Machine Epsilon For AD Types
-      Frequently Asked Questions and Answers: Complex Types
-      Convert Certain Types to a String
-      Example AD Base Types That are not AD<OtherBase>
-      AD<Base> Requirements for a CppAD Base Type: Standard Base Types
-      Atomic Eigen Cholesky Factorization Class: Public.Types
-      Atomic Eigen Matrix Inversion Class: Public.Types
-      Atomic Eigen Matrix Multiply Class: Public.Types
-      Numeric Limits For an AD and Base Types
-      AD Absolute Value Functions: abs, fabs: Complex Types
-      The Unary Standard Math Functions: Possible Types
-      Convert From AD to Integer: x.AD Types
-      Convert From AD to Integer: x.Complex Types
-      Convert From AD to Integer: x.Real Types
- -U -
-u LU Factorization of A Square Matrix and Stability Calculation: LU.U
-  User Defined Atomic AD Functions: rev_hes_sparse.u
-  Invert an LU Factored Equation: LU.U
-  LU Factorization of A Square Matrix: LU.U
-  AD Boolean Functions: u
-  Atomic Reverse Hessian Sparsity Patterns: u
-u) Create An Abs-normal Representation of a Function: g.y(x, u)
-   Create An Abs-normal Representation of a Function: g.z(x, u)
-   Any Order Reverse Mode: Notation.Y(t, u)
-   Any Order Reverse Mode: Notation.X(t, u)
-u^(k) Any Order Reverse Mode: Notation.u^(k)
-unary Enable use of AD<Base> where Base is std::complex<double>: Invalid Unary Math
-      Enable use of AD<Base> where Base is std::complex<double>: Valid Unary Math
-      Enable use of AD<Base> where Base is double: Unary Standard Math
-      Enable use of AD<Base> where Base is float: Unary Standard Math
-      Enable use of AD<Base> where Base is Adolc's adouble Type: Unary Standard Math
-      Example AD<Base> Where Base Constructor Allocates Memory: Unary Standard Math
-      Base Type Requirements for Standard Math Functions: Unary Standard Math
-      Required Base Class Member Functions: Unary Operators
-      AD Boolean Functions: Create Unary
-      The Unary Standard Math Functions
-      AD Unary Minus Operator: Example and Test
-      AD Unary Minus Operator
-      AD Unary Plus Operator: Example and Test
-      AD Unary Plus Operator
-unary_name AD Boolean Functions: unary_name
-uniform Simulate a [0,1] Uniform Random Variate
-        Simulate a [0,1] Uniform Random Variate
-uniform_01 Source: uniform_01
-           Simulate a [0,1] Uniform Random Variate
-           Running the Speed Test Program
-union Define Matrix Multiply as a User Atomic Operation: Set Union
-      Union of Standard Sets
-union: Set Union: Example and Test
-unix Autotools Unix Test and Installation
-     Including the ADOL-C Examples and Tests: Unix
-unknown CppAD Assertions During Execution: Unknown
-up Do One Thread's Work for Multi-Threaded Newton Method: up
-   Set Up Multi-Threaded Newton Method
-   Multi-Threaded User Atomic Set Up
-   Set Up Multi-threading Sum of 1/i
-usage User Defined Atomic AD Functions: rev_hes_sparse.Usage
-      User Defined Atomic AD Functions: rev_jac_sparse.Usage
-      User Defined Atomic AD Functions: for_jac_sparse.Usage
-      User Defined Atomic AD Functions: reverse.Usage
-      User Defined Atomic AD Functions: forward.Usage
-      CppAD pkg-config Files: Usage
-      Using CMake to Configure CppAD
-use User Defined Atomic AD Functions: Example.Use AD
-    User Defined Atomic AD Functions: Syntax Function.Use Function
-    Check If A Memory Allocation is Efficient for Another Use
-    Amount of Memory Available for Quick Use by a Thread
-    Free Memory Currently Available for Quick Use by a Thread
-    Tracking Use of New and Delete: Example and Test
-    Routines That Track Use of New and Delete
-    Enable Use of Eigen Linear Algebra Package with CppAD
-    Use Ipopt to Solve a Nonlinear Programming Problem
-    Free All Memory That Was Allocated for Use by thread_alloc
-    Amount of Memory Available for Quick Use by a Thread
-    Control When Thread Alloc Retains Memory For Future Use
-    Free Memory Currently Available for Quick Use by a Thread
-    Setup thread_alloc For Use in Multi-Threading Environment
-    Example Use of SpeedTest
-    Specifications for A Team of AD Threads: Example Use
-    Common Variables use by Multi-Threaded Newton Method
-    Enable use of AD<Base> where Base is std::complex<double>
-    Enable use of AD<Base> where Base is double
-    Enable use of AD<Base> where Base is float
-    Enable use of AD<Base> where Base is Adolc's adouble Type
-    User Atomic Matrix Multiply: Example and Test: Use Atomic Function
-    Atomic Eigen Cholesky Factorization: Example and Test: Use Atomic Function
-    Atomic Eigen Matrix Inverse: Example and Test: Use Atomic Function
-    Atomic Eigen Matrix Multiply: Example and Test: Use Atomic Function
-    Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function
-    Reciprocal as an Atomic Operation: Example and Test: Use Atomic Function
-    Atomic Euclidean Norm Squared: Example and Test: Use Atomic Function
-    Getting Started with Atomic Operations: Example and Test: Use Atomic Function
-    Atomic Reverse Hessian Sparsity: Example and Test: Use Atomic Function
-    Atomic Forward Hessian Sparsity: Example and Test: Use Atomic Function
-    Atomic Reverse Jacobian Sparsity: Example and Test: Use Atomic Function
-    Atomic Forward Jacobian Sparsity: Example and Test: Use Atomic Function
-    Atomic Reverse: Example and Test: Use Atomic Function
-    Atomic Forward: Example and Test: Use Atomic Function
-    Free Static Variables: Future Use
-    Atomic Function Constructor: Example.Use Constructor
-use_ad Timing Test of Multi-Threaded Newton Method: use_ad
-       Run Multi-Threading Examples and Speed Tests: multi_newton.use_ad
-use_vecad ADFun Object Deprecated Member Functions: use_VecAD
-used A Quick OpenMP Memory Allocator Used by CppAD
-     Utility Routines used by CppAD Examples
-     Common Variables Used by Multi-threading Sum of 1/i
-user Define Matrix Multiply as a User Atomic Operation: CppAD User Atomic Callback Functions
-     Define Matrix Multiply as a User Atomic Operation
-     Old Matrix Multiply as a User Atomic Operation: Example and Test
-     Old Tan and Tanh as User Atomic Operations: Example and Test
-     Using AD to Compute Atomic Function Derivatives
-     Using AD to Compute Atomic Function Derivatives
-     User Defined Atomic AD Functions
-     Timing Test for Multi-Threaded User Atomic Calculation
-     Run Multi-Threaded User Atomic Calculation
-     Multi-Threaded User Atomic Take Down
-     Multi-Threaded User Atomic Worker
-     Multi-Threaded User Atomic Set Up
-     Multi-Threaded User Atomic Common Information
-     Defines a User Atomic Operation that Computes Square Root
-     Multi-Threading User Atomic Example / Test
-     Using a User Defined AD Base Type: Example and Test
-     User Atomic Matrix Multiply: Example and Test
-     Tan and Tanh as User Atomic Operations: Example and Test
-     User Defined Atomic AD Functions
-uses Check an ADFun Sequence of Operations: FunCheck Uses Forward
-     Compute Sparse Jacobians Using Subgraphs: Uses Forward
-     Sparse Hessian: Uses Forward
-     Computing Sparse Hessians: Uses Forward
-     Sparse Jacobian: Uses Forward
-     Computing Sparse Jacobians: Uses Forward
-     Reverse Mode Second Partial Derivative Driver: RevTwo Uses Forward
-     Forward Mode Second Partial Derivative Driver: ForTwo Uses Forward
-     First Order Derivative: Driver Routine: RevOne Uses Forward
-     First Order Partial Derivative: Driver Routine: ForOne Uses Forward
-     Hessian: Easy Driver: Hessian Uses Forward
-using Compute Determinant using Expansion by Minors
-      Using AD to Compute Atomic Function Derivatives
-      Using AD to Compute Atomic Function Derivatives
-      ODE Fitting Using Fast Representation
-      ODE Fitting Using Simple Representation
-      ODE Fitting Using Fast Representation
-      ODE Fitting Using Simple Representation
-      Nonlinear Programming Using CppAD and Ipopt: Example and Test
-      Nonlinear Programming Using the CppAD Interface to Ipopt
-      Amount of Memory a Thread is Currently Using
-      Sacado Speed: Gradient of Determinant Using Lu Factorization
-      Speed Test Derivatives Using Sacado
-      Fadbad Speed: Gradient of Determinant Using Lu Factorization
-      Speed Test Derivatives Using Fadbad
-      CppAD Speed: Gradient of Determinant Using Lu Factorization
-      Speed Test Derivatives Using CppAD
-      Adolc Speed: Gradient of Determinant Using Lu Factorization
-      Speed Test of Derivatives Using Adolc
-      Double Speed: Determinant Using Lu Factorization
-      Determinant Using Expansion by Minors: Example and Test
-      Determinant Using Expansion by Minors
-      Determinant Using Lu Factorization: Example and Test
-      Determinant Using Expansion by Lu Factorization
-      Speed Testing Gradient of Determinant Using Lu Factorization
-      Using The CppAD Test Vector Template Class
-      Taylor's Ode Solver: A Multi-Level Adolc Example and Test: Taylor's Method Using AD
-      Taylor's Ode Solver: A Multi-Level AD Example and Test: Taylor's Method Using AD
-      Using Multiple Levels of AD
-      Gradient of Determinant Using Lu Factorization: Example and Test
-      Gradient of Determinant Using Expansion by Minors: Example and Test
-      Gradient of Determinant Using LU Factorization: Example and Test
-      Gradient of Determinant Using Expansion by Minors: Example and Test
-      Using Eigen To Compute Determinant: Example and Test
-      Using Eigen Arrays: Example and Test
-      Getting Started Using CppAD to Compute Derivatives
-      Nonlinear Programming Using CppAD and Ipopt: Example and Test
-      Amount of Memory a Thread is Currently Using
-      OdeErrControl: Example and Test Using Maxabs Argument
-      Definition of a Simple Vector: Element Access.Using Value
-      Using a Team of AD Threads: Example and Test
-      Using CppAD in a Multi-Threading Environment
-      Non-Smooth Optimization Using Abs-normal Quadratic Approximations
-      Solve a Quadratic Program Using Interior Point Method
-      Non-Smooth Optimization Using Abs-normal Linear Approximations
-      abs_normal: Solve a Linear Program Using Simplex Method
-      Sparse Hessian Using Subgraphs and Jacobian: Example and Test
-      Computing Sparse Jacobian Using Reverse Mode: Example and Test
-      Compute Sparse Jacobians Using Subgraphs
-      Computing Sparse Jacobian Using Reverse Mode: Example and Test
-      Computing Sparse Jacobian Using Forward Mode: Example and Test
-      Reverse Mode Using Subgraphs
-      Using Adolc with Multiple Levels of Taping: Example and Test
-      Using a User Defined AD Base Type: Example and Test
-      Using AD Version of Atomic Function
-      Using CMake to Configure CppAD
-utilities Some Numerical AD Utilities
-          Speed Testing Utilities
-          Some General Purpose Utilities
-utility Speed Testing Utilities: Speed Utility Routines
-        Utility Routines used by CppAD Examples
-utility: Adolc Test Utility: Allocate and Free Memory For a Matrix
- -V -
-Value Convert an AD Variable to a Parameter: Example and Test
-      Convert From AD to its Base Type: Example and Test
-      Convert From an AD Type to its Base Type
-Var2Par Convert an AD Variable to a Parameter: Example and Test
-        Convert an AD Variable to a Parameter
-VecAD AD Vectors that Record Index Operations: Example and Test
-      AD Vectors that Record Index Operations
-      AD Assignment Operator
-      AD Constructors
-VecAD<Base> AD Vectors that Record Index Operations
-v User Defined Atomic AD Functions: rev_hes_sparse.v
-  Sparse Matrix Row, Column, Value Representation: set.v
-  Obtain Nan or Determine if a Value is Nan: hasnan.v
-  AD Vectors that Record Index Operations: Constructor.v
-  AD Boolean Functions: v
-  Atomic Reverse Hessian Sparsity Patterns: u.v
-v_ptr Check If A Memory Allocation is Efficient for Another Use: v_ptr
-      Return Memory to omp_alloc: v_ptr
-      Get At Least A Specified Amount of Memory: v_ptr
-      Return Memory to thread_alloc: v_ptr
-      Get At Least A Specified Amount of Memory: v_ptr
-val Sparse Matrix Row, Column, Value Representation: val
-valid Enable use of AD<Base> where Base is std::complex<double>: Valid Unary Math
-value Speed Testing Second Derivative of a Polynomial: Return Value
-      Speed Testing the Jacobian of Ode Solution: Return Value
-      Speed Testing Derivative of Matrix Multiply: Return Value
-      Speed Testing Gradient of Determinant by Minor Expansion: Return Value
-      Speed Testing Gradient of Determinant Using Lu Factorization: Return Value
-      Getting Started Using CppAD to Compute Derivatives: Value
-      Sparse Matrix Row, Column, Value Representation
-      Convert Certain Types to a String: value
-      Control When Thread Alloc Retains Memory For Future Use: value
-      Obtain Nan or Determine if a Value is Nan
-      Definition of a Simple Vector: Element Access.Using Value
-      Definition of a Simple Vector: Value Type
-      Check if Two Value are Identically Equal
-      AD Absolute Value Function: Example and Test
-      AD Absolute Value Functions: abs, fabs
-      Convert An AD or Base Type to String: value
-      exp_eps: Second Order Forward Mode: Return Value
-      exp_eps: First Order Forward Sweep: Return Value
-      exp_eps: Operation Sequence and Zero Order Forward Sweep: Return Value
-      exp_2: Second Order Forward Mode: Return Value
-      exp_2: First Order Forward Mode: Return Value
-      exp_2: Operation Sequence and Zero Order Forward Mode: Return Value
-value_ Convert an AD Variable to a Parameter
-value_type Definition of a Simple Vector
-valued Bool Valued Operations and Functions with AD Arguments
-       AD Valued Operations and Functions
-values Jacobian and Hessian of Optimal Values
-       An ODE Inverse Problem Example: Measurements.Simulated Measurement Values
-       An ODE Inverse Problem Example: Measurements.Simulation Parameter Values
-       ODE Inverse Problem Definitions: Source Code: Measurements.Simulated Measurement Values
-       ODE Inverse Problem Definitions: Source Code: Measurements.Simulation Parameter Values
-       Determine if Two Values Are Nearly Equal
-       Multiple Order Forward Mode: Purpose.Derivative Values
-       Multiple Order Forward Mode: Purpose.Function Values
-       Second Order Forward Mode: Derivative Values
-       First Order Forward Mode: Derivative Values
-       Zero Order Forward Mode: Function Values
-       Base Type Requirements for Hash Coding Values
-       Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function.Large x Values
-       Printing AD Values During Forward Mode
-valuevector Sparse Matrix Row, Column, Value Representation: ValueVector
-var Printing AD Values During Forward Mode: var
-variable Glossary: Variable
-         Glossary: Tape.Independent Variable
-         AD Parameter and Variable Functions: Example and Test
-         Is an AD Object a Parameter or Variable
-         Atomic Reverse Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-         Atomic Forward Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-         Atomic Reverse Jacobian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-         Atomic Forward Jacobian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-         Convert an AD Variable to a Parameter: Example and Test
-         Convert an AD Variable to a Parameter
-         exp_eps: Operation Sequence and Zero Order Forward Sweep: Operation Sequence.Variable
-variables Glossary: Tape.Dependent Variables
-          Frequently Asked Questions and Answers: Independent Variables
-          Common Variables use by Multi-Threaded Newton Method
-          Common Variables Used by Multi-threading Sum of 1/i
-          Computing Sparse Hessian for a Subset of Variables
-          Number of Variables That Can be Skipped: Example and Test
-          Number of Variables that Can be Skipped
-          Declare Independent Variables and Start Recording
-          Atomic Eigen Cholesky Factorization Class: Private.Variables
-          Atomic Eigen Matrix Inversion Class: Private.Variables
-          Atomic Eigen Matrix Multiply Class: Private.Variables
-          Free Static Variables
-variables: Sparsity Patterns For a Subset of Variables: Example and Test
-variate Simulate a [0,1] Uniform Random Variate
-        Simulate a [0,1] Uniform Random Variate
-vec Check an ADFun Object For Nan Results: get_check_for_nan.vec
-vec_ad.cpp AD Vectors that Record Index Operations: Example and Test
-vecad<base> Absolute Zero Multiplication: VecAD<Base>
-            The Unary Standard Math Functions: Possible Types.VecAD<Base>
-vecad<base>::reference AD Vectors that Record Index Operations: VecAD<Base>::reference
-vector ODE Fitting Using Simple Representation: Argument Vector
-       Nonlinear Programming Using the CppAD Interface to Ipopt: fg(x).Index Vector
-       Choosing The Vector Testing Template Class
-       Glossary: Sparsity Pattern.Vector of Sets
-       Glossary: Sparsity Pattern.Boolean Vector
-       Glossary: Elementary Vector
-       Frequently Asked Questions and Answers: Namespace.Test Vector Preprocessor Symbol
-       Simulate a [0,1] Uniform Random Variate: Vector
-       Sum Elements of a Matrix Times Itself: Vector
-       Check Gradient of Determinant of 3 by 3 matrix: Vector
-       Check Determinant of 3 by 3 matrix: Vector
-       Determinant Using Expansion by Minors: Vector
-       Determinant Using Expansion by Lu Factorization: Vector
-       Using The CppAD Test Vector Template Class
-       Examples: The CppAD Test Vector Template Class
-       Returns Indices that Sort a Vector
-       CppAD::vector Template Class: Example and Test
-       The CppAD::vector Template Class
-       An Error Controller for Gear's Ode Solvers: Vector
-       An Arbitrary Order Gear Method: Vector
-       An Error Controller for ODE Solvers: Vector
-       A 3rd and 4th Order Rosenbrock ODE Solver: Vector
-       An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Vector
-       Evaluate a Polynomial or its Derivative: Vector
-       Obtain Nan or Determine if a Value is Nan: Vector
-       Check Simple Vector Concept
-       Simple Vector Template Class: Example and Test
-       Definition of a Simple Vector
-       Run One Speed Test and Return Results: Vector
-       Some General Purpose Utilities: Miscellaneous.The CppAD Vector Template Class
-       Check an ADFun Sequence of Operations: Vector
-       abs_normal: Solve a Quadratic Program With Box Constraints: Vector
-       Solve a Quadratic Program Using Interior Point Method: Vector
-       abs_normal: Solve a Linear Program With Box Constraints: Vector
-       abs_normal: Solve a Linear Program Using Simplex Method: Vector
-       abs_normal: Evaluate First Order Approximation: Vector
-       abs_normal: Print a Vector or Matrix
-       Any Order Reverse Mode: Vector
-       Second Order Reverse Mode: Vector
-       First Order Reverse Mode: Vector
-       Multiple Directions Forward Mode: Vector
-       Multiple Order Forward Mode: Vector
-       Second Order Forward Mode: Derivative Values: Vector
-       First Order Forward Mode: Derivative Values: Vector
-       Zero Order Forward Mode: Function Values: Vector
-       First Order Derivative: Driver Routine: Vector
-       First Order Partial Derivative: Driver Routine: Vector
-       Hessian: Easy Driver: Vector
-       Jacobian: Driver Routine: Vector
-       User Defined Atomic AD Functions: Examples.Vector Range
-       Choosing the CppAD Test Vector Template Class
-       Including the Eigen Examples and Tests: Test Vector
-       Using CMake to Configure CppAD
-vector_size Check an ADFun Object For Nan Results: Error Message.vector_size
-vectorad Construct an ADFun Object and Stop Recording: VectorAD
-         Declare Independent Variables and Start Recording: VectorAD
-vectorBool CppAD::vectorBool Class: Example and Test
-vectorbase Sparse Hessian: VectorBase
-           Sparse Jacobian: VectorBase
-           Reverse Mode Second Partial Derivative Driver: VectorBase
-           Forward Mode Second Partial Derivative Driver: VectorBase
-vectorbool The CppAD::vector Template Class: vectorBool
-vectors Glossary: Sparsity Pattern.Row and Column Index Vectors
-        Using The CppAD Test Vector Template Class: Eigen Vectors
-        AD Vectors that Record Index Operations: Example and Test
-        AD Vectors that Record Index Operations
-vectorset Sparse Hessian: VectorSet
-          Sparse Jacobian: VectorSet
-          Hessian Sparsity Pattern: Forward Mode: VectorSet
-          Hessian Sparsity Pattern: Reverse Mode: VectorSet
-          Jacobian Sparsity Pattern: Reverse Mode: VectorSet
-          Jacobian Sparsity Pattern: Forward Mode: VectorSet
-vectorsize Sparse Hessian: VectorSize
-           Sparse Jacobian: VectorSize
-vectorsize_Reverse Mode Second Partial Derivative Driver: VectorSize_t
-             Forward Mode Second Partial Derivative Driver: VectorSize_t
-verification exp_eps: Second Order Reverse Sweep: Verification
-             exp_eps: Second Order Forward Mode: Verification
-             exp_eps: First Order Reverse Sweep: Verification
-             exp_eps: First Order Forward Sweep: Verification
-             exp_eps: Operation Sequence and Zero Order Forward Sweep: Verification
-             exp_2: Second Order Reverse Mode: Verification
-             exp_2: Second Order Forward Mode: Verification
-             exp_2: First Order Reverse Mode: Verification
-             exp_2: First Order Forward Mode: Verification
-             exp_2: Operation Sequence and Zero Order Forward Mode: Verification
-verify exp_eps: Verify Second Order Reverse Sweep
-       exp_eps: Verify Second Order Forward Sweep
-       exp_eps: Verify First Order Reverse Sweep
-       exp_eps: Verify First Order Forward Sweep
-       exp_eps: Verify Zero Order Forward Sweep
-       exp_2: Verify Second Order Reverse Sweep
-       exp_2: Verify Second Order Forward Sweep
-       exp_2: Verify First Order Reverse Sweep
-       exp_2: Verify First Order Forward Sweep
-       exp_2: Verify Zero Order Forward Sweep
-version Microsoft Version of Elapsed Number of Seconds
-        Using AD Version of Atomic Function
-        Discrete AD Functions: Create AD Version
-        Download The CppAD Source Code: Version
-        cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-version) CppAD Speed: Matrix Multiplication (Double Version)
-versions Download The CppAD Source Code: Monthly Versions
-virtual Atomic Forward Mode
-        User Defined Atomic AD Functions: Virtual Functions
-vx User Defined Atomic AD Functions: forward.vx
-   Atomic Reverse Hessian Sparsity Patterns: Implementation.vx
-   Atomic Forward Hessian Sparsity Patterns: Implementation.vx
-   Atomic Forward Mode: vx
-vy User Defined Atomic AD Functions: forward.vy
-   Atomic Forward Mode: vy
- -W -
-w Sparse Hessian: w
-  Computing Sparse Hessians: w
-  Any Order Reverse Mode: w
-  Second Order Reverse Mode: w
-  Second Order Reverse Mode: W
-  First Order Reverse Mode: w
-  Hessian: Easy Driver: w
-w(u) Any Order Reverse Mode: Notation.W(u)
-w^(k) Any Order Reverse Mode: Notation.w^(k)
-warning An Error Controller for Gear's Ode Solvers: Fun.Warning
-        An Arbitrary Order Gear Method: Fun.Warning
-        A 3rd and 4th Order Rosenbrock ODE Solver: Fun.Warning
-        An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Fun.Warning
-        AD<Base> Requirements for a CppAD Base Type: API Warning
-warnings Suppress Suspect Implicit Conversion Warnings
-was Free All Memory That Was Allocated for Use by thread_alloc
-when Control When Thread Alloc Retains Memory For Future Use
-where Enable use of AD<Base> where Base is std::complex<double>
-      Enable use of AD<Base> where Base is double
-      Enable use of AD<Base> where Base is float
-      Enable use of AD<Base> where Base is Adolc's adouble Type
-      Example AD<Base> Where Base Constructor Allocates Memory
-width Object that Runs a Group of Tests: width
-windows Choosing The Vector Testing Template Class: MS Windows
-        Checking the CppAD Examples and Tests: Check All.Windows
-        Download The CppAD Source Code: Windows File Extraction and Testing
-wish Nonlinear Programming Using the CppAD Interface to Ipopt: Wish List
-     The CppAD Wish List
-with zdouble: An AD Base Type With Absolute Zero
-     Lu Factor and Solve With Recorded Pivoting: Example and Test
-     Lu Factor and Solve with Recorded Pivoting
-     Computing a Jacobian With Constants that Change
-     Enable Use of Eigen Linear Algebra Package with CppAD
-     LuSolve With Complex Arguments: Example and Test
-     abs_normal: Solve a Quadratic Program With Box Constraints
-     abs_normal: Solve a Linear Program With Box Constraints
-     Using Adolc with Multiple Levels of Taping: Example and Test
-     Compare AD with Base Objects: Example and Test
-     Compare AD and Base Objects for Nearly Equal
-     Bool Valued Operations and Functions with AD Arguments
-     Atomic Sparsity with Set Patterns: Example and Test
-     Getting Started with Atomic Operations: Example and Test
-     Atomic Reverse Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-     Atomic Forward Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-     Atomic Reverse Jacobian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-     Atomic Forward Jacobian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-     Interpolation With Retaping: Example and Test
-     Interpolation With Out Retaping: Example and Test
-work Do One Thread's Work for Multi-Threaded Newton Method
-     Do One Thread's Work for Sum of 1/i
-     Sparse Hessian: work
-     Sparse Hessian: p.work
-     Computing Sparse Hessians: work
-     Sparse Jacobian: work
-     Computing Sparse Jacobians: work
-worker Multi-Threaded User Atomic Worker
-write AD Output Stream Operator
- -X -
-x Jacobian and Hessian of Optimal Values: x
-  Computing Jacobian and Hessian of Bender's Reduced Objective: x
-  Nonlinear Programming Using the CppAD Interface to Ipopt: solution.x
-  Simulate a [0,1] Uniform Random Variate: x
-  Evaluate a Function That Has a Sparse Hessian: x
-  Evaluate a Function That Has a Sparse Jacobian: x
-  Evaluate a Function Defined in Terms of an ODE: x
-  Sum Elements of a Matrix Times Itself: x
-  Check Gradient of Determinant of 3 by 3 matrix: x
-  Check Determinant of 3 by 3 matrix: x
-  Speed Testing Sparse Jacobian: x
-  Speed Testing Sparse Hessian: x
-  Speed Testing the Jacobian of Ode Solution: x
-  Speed Testing Derivative of Matrix Multiply: x
-  Use Ipopt to Solve a Nonlinear Programming Problem: solution.x
-  Use Ipopt to Solve a Nonlinear Programming Problem: fg_eval.x
-  An Error Controller for Gear's Ode Solvers: Fun.x
-  An Arbitrary Order Gear Method: X
-  An Arbitrary Order Gear Method: Fun.x
-  A 3rd and 4th Order Rosenbrock ODE Solver: Fun.x
-  An Embedded 4th and 5th Order Runge-Kutta ODE Solver: Fun.x
-  Invert an LU Factored Equation: X
-  Compute Determinant and Solve Linear Equations: X
-  The Integer Power Function: x
-  Check Simple Vector Concept: x, y
-  Determine if Two Values Are Nearly Equal: x
-  Check an ADFun Sequence of Operations: x
-  Check an ADFun Sequence of Operations: g.x
-  Compute Sparse Jacobians Using Subgraphs: x
-  Sparse Hessian: x
-  Computing Sparse Hessians: x
-  Sparse Jacobian: x
-  Computing Sparse Jacobians: x
-  Hessian Sparsity Pattern: Forward Mode: x
-  Forward Mode Hessian Sparsity Patterns: x
-  Hessian Sparsity Pattern: Reverse Mode: x
-  Reverse Mode Hessian Sparsity Patterns: x
-  Jacobian Sparsity Pattern: Reverse Mode: x
-  Reverse Mode Jacobian Sparsity Patterns: x
-  Jacobian Sparsity Pattern: Forward Mode: x
-  Forward Mode Jacobian Sparsity Patterns: x
-  First Order Reverse Mode: x
-  Reverse Mode Second Partial Derivative Driver: x
-  Forward Mode Second Partial Derivative Driver: x
-  First Order Derivative: Driver Routine: x
-  First Order Partial Derivative: Driver Routine: x
-  Hessian: Easy Driver: x
-  Jacobian: Driver Routine: x
-  Stop Recording and Store Operation Sequence: x
-  Construct an ADFun Object and Stop Recording: x
-  Declare Independent Variables and Start Recording: x
-  Base Type Requirements for Hash Coding Values: x
-  AD Vectors that Record Index Operations: AD Indexing.x
-  Check if Two Value are Identically Equal: x
-  Is an AD Object a Parameter or Variable: x
-  AD Boolean Functions: x
-  Compare AD and Base Objects for Nearly Equal: x
-  AD Binary Comparison Operators: x
-  Tan and Tanh as User Atomic Operations: Example and Test: Use Atomic Function.Large x Values
-  Atomic Reverse Hessian Sparsity Patterns: u.x
-  Atomic Forward Hessian Sparsity Patterns: Implementation.x
-  Atomic Reverse Jacobian Sparsity Patterns: Implementation.x
-  Atomic Forward Jacobian Sparsity Patterns: Implementation.x
-  Discrete AD Functions: x
-  The AD Power Function: x
-  AD Two Argument Inverse Tangent Function: x
-  The Sign: sign: x, y
-  The Logarithm of One Plus Argument: log1p: x, y
-  The Exponential Function Minus One: expm1: x, y
-  The Error Function: x, y
-  The Inverse Hyperbolic Tangent Function: atanh: x, y
-  The Inverse Hyperbolic Sine Function: asinh: x, y
-  The Inverse Hyperbolic Cosine Function: acosh: x, y
-  AD Absolute Value Functions: abs, fabs: x, y
-  The Hyperbolic Tangent Function: tanh: x, y
-  The Tangent Function: tan: x, y
-  The Square Root Function: sqrt: x, y
-  The Hyperbolic Sine Function: sinh: x, y
-  The Sine Function: sin: x, y
-  The Base 10 Logarithm Function: log10: x, y
-  The Exponential Function: log: x, y
-  The Exponential Function: exp: x, y
-  The Hyperbolic Cosine Function: cosh: x, y
-  The Cosine Function: cos: x, y
-  Inverse Tangent Function: atan: x, y
-  Inverse Sine Function: asin: x, y
-  Inverse Sine Function: acos: x, y
-  AD Compound Assignment Operators: x
-  AD Binary Arithmetic Operators: x
-  AD Unary Minus Operator: x
-  AD Unary Plus Operator: x
-  Convert an AD Variable to a Parameter: x
-  AD Output Stream Operator: x
-  AD Output Stream Operator: x
-  Convert From AD to Integer: x
-  Convert From an AD Type to its Base Type: x
-  AD Assignment Operator: x
-  AD Constructors: x
-  An Epsilon Accurate Exponential Approximation: x
-  Second Order Exponential Approximation: x
-x(Any Order Reverse Mode: Notation.X(t, u)
-x(t) Multiple Directions Forward Mode: X(t)
-     Multiple Order Forward Mode: X(t)
-x) Printing AD Values During Forward Mode: f.Forward(0, x)
-x0 Second Order Forward Mode: Derivative Values: x0
-   First Order Forward Mode: Derivative Values: x0
-   Zero Order Forward Mode: Function Values: x0
-x1 Second Order Forward Mode: Derivative Values: x1
-   First Order Forward Mode: Derivative Values: x1
-x2 Second Order Forward Mode: Derivative Values: x2
-x^(k) Second Order Reverse Mode: x^(k)
-x_Atomic Reverse Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-    Atomic Forward Hessian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-    Atomic Reverse Jacobian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-    Atomic Forward Jacobian Sparsity: Example and Test: Test with x_1 Both a Variable and a Parameter
-x_Nonlinear Programming Using the CppAD Interface to Ipopt: x_i
-x_in Non-Smooth Optimization Using Abs-normal Quadratic Approximations: x_in
-     Non-Smooth Optimization Using Abs-normal Linear Approximations: x_in
-x_Nonlinear Programming Using the CppAD Interface to Ipopt: x_l
-x_out Non-Smooth Optimization Using Abs-normal Quadratic Approximations: x_out
-      Non-Smooth Optimization Using Abs-normal Linear Approximations: x_out
-x_Nonlinear Programming Using the CppAD Interface to Ipopt: x_u
-xf An Error Controller for Gear's Ode Solvers: xf
-   An Error Controller for ODE Solvers: xf
-   A 3rd and 4th Order Rosenbrock ODE Solver: xf
-   An Embedded 4th and 5th Order Runge-Kutta ODE Solver: xf
-xi Use Ipopt to Solve a Nonlinear Programming Problem: xi
-   An Error Controller for Gear's Ode Solvers: xi
-   An Error Controller for ODE Solvers: xi
-   A 3rd and 4th Order Rosenbrock ODE Solver: xi
-   An Embedded 4th and 5th Order Runge-Kutta ODE Solver: xi
-xin abs_normal: Solve a Quadratic Program With Box Constraints: xin
-    Solve a Quadratic Program Using Interior Point Method: xin
-xl Use Ipopt to Solve a Nonlinear Programming Problem: xl
-xlow A Multi-Threaded Newton's Method: xlow
-     Set Up Multi-Threaded Newton Method: xlow
-xout A Multi-Threaded Newton's Method: xout
-     Take Down Multi-threaded Newton Method: xout
-     abs_normal: Solve a Quadratic Program With Box Constraints: xout
-     Solve a Quadratic Program Using Interior Point Method: xout
-     abs_normal: Solve a Linear Program With Box Constraints: xout
-     abs_normal: Solve a Linear Program Using Simplex Method: xout
-xq Multiple Directions Forward Mode: xq
-   Multiple Order Forward Mode: xq
-xu Use Ipopt to Solve a Nonlinear Programming Problem: xu
-xup A Multi-Threaded Newton's Method: xup
-    Set Up Multi-Threaded Newton Method: xup
- -Y -
-y(Any Order Reverse Mode: Notation.Y(t, u)
-y(t) Tangent and Hyperbolic Tangent Reverse Mode Theory: Eliminating Y(t)
-     Multiple Directions Forward Mode: Y(t)
-     Multiple Order Forward Mode: Y(t)
-y(Create An Abs-normal Representation of a Function: g.y(x, u)
-y0 Zero Order Forward Mode: Function Values: y0
-y2 Second Order Forward Mode: Derivative Values: y2
-y_initial Defines a User Atomic Operation that Computes Square Root: au.y_initial
-y_squared Run Multi-Threaded User Atomic Calculation: y_squared
-          Multi-Threaded User Atomic Set Up: y_squared
-          Defines a User Atomic Operation that Computes Square Root: au.y_squared
-year Changes and Additions to CppAD: This Year
-years Changes and Additions to CppAD: Previous Years
-your Your License for the CppAD Software
-     Creating Your Own Interface to an ADFun Object
-yout Solve a Quadratic Program Using Interior Point Method: yout
-yq Multiple Directions Forward Mode: yq
-   Multiple Order Forward Mode: yq
- -Z -
-z Sum Elements of a Matrix Times Itself: z
-  Speed Testing Second Derivative of a Polynomial: z
-  Speed Testing Derivative of Matrix Multiply: z
-  Evaluate a Polynomial or its Derivative: z
-  The Integer Power Function: z
-  Obtain Nan or Determine if a Value is Nan: nan(zero).z
-  The AD Power Function: z
-  AD Binary Arithmetic Operators: z
-z(t) Error Function Reverse Mode Theory: Order Zero Z(t)
-     Error Function Reverse Mode Theory: Positive Orders Z(t)
-     Tangent and Hyperbolic Tangent Reverse Mode Theory: Order Zero Z(t)
-     Tangent and Hyperbolic Tangent Reverse Mode Theory: Positive Orders Z(t)
-z(Create An Abs-normal Representation of a Function: g.z(x, u)
-z_Nonlinear Programming Using the CppAD Interface to Ipopt: solution.z_l
-z_Nonlinear Programming Using the CppAD Interface to Ipopt: solution.z_u
-zdouble: zdouble: Example and Test
-         zdouble: An AD Base Type With Absolute Zero
-zero zdouble: An AD Base Type With Absolute Zero: Absolute Zero
-     zdouble: An AD Base Type With Absolute Zero
-     Comparison Changes During Zero Order Forward Mode
-     Error Function Reverse Mode Theory: Order Zero Z(t)
-     Tangent and Hyperbolic Tangent Reverse Mode Theory: Order Zero Z(t)
-     Comparison Changes Between Taping and Zero Order Forward
-     Multiple Directions Forward Mode: Zero Order
-     Multiple Order Forward Mode: Zero Order
-     Zero Order Forward Mode: Function Values
-     AD<Base> Requirements for a CppAD Base Type: Absolute Zero, azmul
-     AD Absolute Zero Multiplication: Example and Test
-     Absolute Zero Multiplication
-     Print During Zero Order Forward Mode: Example and Test
-     exp_eps: Verify Zero Order Forward Sweep
-     exp_eps: Second Order Forward Mode: Operation Sequence.Zero
-     exp_eps: First Order Forward Sweep: Operation Sequence.Zero Order
-     exp_eps: Operation Sequence and Zero Order Forward Sweep: Operation Sequence.Zero Order
-     exp_eps: Operation Sequence and Zero Order Forward Sweep
-     exp_2: Verify Zero Order Forward Sweep
-     exp_2: Second Order Forward Mode: Operation Sequence.Zero
-     exp_2: First Order Forward Mode: Operation Sequence.Zero Order
-     exp_2: Operation Sequence and Zero Order Forward Mode: Operation Sequence.Zero Order
-     exp_2: Operation Sequence and Zero Order Forward Mode: Zero Order Expansion
-     exp_2: Operation Sequence and Zero Order Forward Mode
-zeta Create An Abs-normal Representation of a Function: a.zeta
-zl Use Ipopt to Solve a Nonlinear Programming Problem: solution.zl
-zu Use Ipopt to Solve a Nonlinear Programming Problem: solution.zu
- - - diff -Nru cppad-2018.00.00.0/doc/__index_xml.js cppad-2019.02.00.0/doc/__index_xml.js --- cppad-2018.00.00.0/doc/__index_xml.js 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/__index_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'_index.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_current0 = [ -'_index.xml#A', -'_index.xml#B', -'_index.xml#C', -'_index.xml#D', -'_index.xml#E', -'_index.xml#F', -'_index.xml#G', -'_index.xml#H', -'_index.xml#I', -'_index.xml#J', -'_index.xml#K', -'_index.xml#L', -'_index.xml#M', -'_index.xml#N', -'_index.xml#O', -'_index.xml#P', -'_index.xml#Q', -'_index.xml#R', -'_index.xml#S', -'_index.xml#T', -'_index.xml#U', -'_index.xml#V', -'_index.xml#W', -'_index.xml#X', -'_index.xml#Y', -'_index.xml#Z' -]; -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-2018.00.00.0/doc/install.xml cppad-2019.02.00.0/doc/install.xml --- cppad-2018.00.00.0/doc/install.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/install.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ - - - -CppAD Download, Test, and Install Instructions - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -

-
CppAD Download, Test, and Install Instructions
-
-Instructions - - -
-
-Step 1: Download -
-Use the download - instructions to obtain a copy or CppAD. - -
-
-Step 2: Cmake -
-Use the cmake - instructions to configure CppAD. - -
-
-Step 3: Check -
-Use the cmake_check - instructions to check the -CppAD examples and tests. - -
-
-Step 4: Installation -
-Use the command -
 
-     make install
-
-to install CppAD. -If you created nmake makefiles, you will have -to use -
 
-     nmake install
-
-see the -generator - option for the cmake command. - - -
-
-Contents -
- -
downloadDownload The CppAD Source Code
cmakeUsing CMake to Configure CppAD
cmake_checkChecking the CppAD Examples and Tests
pkgconfigCppAD pkg-config Files

-Deprecated - -
-autotools - - - - - -
Input File: omh/install/install.omh - - - diff -Nru cppad-2018.00.00.0/doc/_install_xml.js cppad-2019.02.00.0/doc/_install_xml.js --- cppad-2018.00.00.0/doc/_install_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_install_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'install.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 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.xml' -]; -var list_current0 = [ -'install.xml#Instructions', -'install.xml#Instructions.Step 1: Download', -'install.xml#Instructions.Step 2: Cmake', -'install.xml#Instructions.Step 3: Check', -'install.xml#Instructions.Step 4: Installation', -'install.xml#Contents', -'install.xml#Deprecated' -]; -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-2018.00.00.0/doc/integer.cpp.xml cppad-2019.02.00.0/doc/integer.cpp.xml --- cppad-2018.00.00.0/doc/integer.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/integer.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,136 +0,0 @@ - - - -Convert From AD to Integer: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -integer.cppHeadings

- - - -
Convert From AD to Integer: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool Integer(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::Integer;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0] = 3.5;
-     x[1] = 4.5;
-
-     // check integer before recording
-     ok &= (Integer(x[0]) == 3);
-     ok &= (Integer(x[1]) == 4);
-
-     // start recording
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     // check integer during recording
-     ok &= (Integer(x[0]) == 3);
-     ok &= (Integer(x[1]) == 4);
-
-     // check integer for VecAD element
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero] = 2;
-     ok &= (Integer(v[zero]) == 2);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = - x[1];
-
-     // create f: x -> y and stop recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check integer after recording
-     ok &= (Integer(x[0]) ==  3.);
-     ok &= (Integer(x[1]) ==  4.);
-     ok &= (Integer(y[0]) == -4.);
-
-     return ok;
-}
-
-
Input File: example/general/integer.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_integer.cpp_xml.js cppad-2019.02.00.0/doc/_integer.cpp_xml.js --- cppad-2018.00.00.0/doc/_integer.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_integer.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'convert.xml', -'integer.xml', -'integer.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 = [ -'value.xml', -'integer.xml', -'ad_to_string.xml', -'ad_input.xml', -'ad_output.xml', -'printfor.xml', -'var2par.xml' -]; -var list_down1 = [ -'integer.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-2018.00.00.0/doc/integer.xml cppad-2019.02.00.0/doc/integer.xml --- cppad-2018.00.00.0/doc/integer.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/integer.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,248 +0,0 @@ - - - -Convert From AD to Integer - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Convert From AD to Integer
-
-Syntax - -
- -i = Integer(x) - - - -
-
-Purpose -
-Converts from an AD type to the corresponding integer value. - -
-
-i -
-The result -i - has prototype - -
-     int 
i
-
-
-x - - -
-
-Real Types -
-If the argument -x - has either of the following prototypes: - -
-     const float                
  &x
-     const double               
  &x
-
-the fractional part is dropped to form the integer value. -For example, if -x - is 1.5, -i - is 1. -In general, if - -x - -0 - - -, -i - is the -greatest integer less than or equal -x -. -If - -x - -0 - - -, -i - is the -smallest integer greater than or equal -x -. - -
-
-Complex Types -
-If the argument -x - has either of the following prototypes: - -
-     const std::complex<float>  
  &x
-     const std::complex<double> 
  &x
-
-The result -i - is given by - -
-     
i = Integer(x.real())
-
-
-AD Types -
-If the argument -x - has either of the following prototypes: - -
-     const AD<
Base>               &x
-     const VecAD<
Base>::reference &x
-
- -Base - must support the Integer function and -the conversion has the same meaning as for -Base -. - -
-
-Operation Sequence -
-The result of this operation is not an -AD of Base - object. -Thus it will not be recorded as part of an -AD of -Base - -operation sequence -. - -
-
-Example - -
-The file -integer.cpp - -contains an example and test of this operation. - - -
Input File: cppad/core/integer.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_integer_xml.js cppad-2019.02.00.0/doc/_integer_xml.js --- cppad-2018.00.00.0/doc/_integer_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_integer_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'convert.xml', -'integer.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_down0 = [ -'integer.cpp.xml' -]; -var list_current0 = [ -'integer.xml#Syntax', -'integer.xml#Purpose', -'integer.xml#i', -'integer.xml#x', -'integer.xml#x.Real Types', -'integer.xml#x.Complex Types', -'integer.xml#x.AD Types', -'integer.xml#Operation Sequence', -'integer.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-2018.00.00.0/doc/interface2c.cpp.xml cppad-2019.02.00.0/doc/interface2c.cpp.xml --- cppad-2018.00.00.0/doc/interface2c.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/interface2c.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,255 +0,0 @@ - - - -Interfacing to C: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -interface2c.cppHeadings

-
Interfacing to C: Example and Test
-
# include <cppad/cppad.hpp>  // CppAD utilities
-# include <cassert>        // assert macro
-
-namespace { // Begin empty namespace
-/*
-Compute the value of a sum of Gaussians defined by a and evaluated at x
-     y = sum_{i=1}^n a[3*i] exp( (x - a[3*i+1])^2 / a[3*i+2])^2 )
-where the floating point type is a template parameter
-*/
-template <class Float>
-Float sumGauss(const Float &x, const CppAD::vector<Float> &a)
-{
-     // number of components in a
-     size_t na = a.size();
-
-     // number of Gaussians
-     size_t n = na / 3;
-
-     // check the restricitons on na
-     assert( na == n * 3 );
-
-     // declare temporaries used inside of loop
-     Float ex, arg;
-
-     // initialize sum
-     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;
-     }
-     return y;
-}
-/*
-Create a C function interface that computes both
-     y = sum_{i=1}^n a[3*i] exp( (x - a[3*i+1])^2 / a[3*i+2])^2 )
-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;
-     // for example, std::vector, std::valarray
-
-     // check the restrictions on na
-     assert( na % 3 == 0 );  // mod(na, 3) = 0
-
-     // use the shorthand ADfloat for the type CppAD::AD<float>
-     typedef CppAD::AD<float> ADfloat;
-
-     // vector for indpendent variables
-     CppAD::vector<ADfloat> A(na);      // used with template function above
-     CppAD::vector<float>   acopy(na);  // used for derivative calculations
-
-     // vector for the dependent variables (there is only one)
-     CppAD::vector<ADfloat> 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];
-
-     // declare that A is the independent variable vector
-     CppAD::Independent(A);
-
-     // value of x as an ADfloat object
-     ADfloat X = x;
-
-     // Evaluate template version of sumGauss with ADfloat as the template
-     // parameter. Set the independent variable to the resulting value
-     Y[0] = sumGauss(X, A);
-
-     // create the AD function object F : A -> Y
-     CppAD::ADFun<float> F(A, Y);
-
-     // use Value to convert Y[0] to float and return y = F(a)
-     *y = CppAD::Value(Y[0]);
-
-     // evaluate the derivative F'(a)
-     CppAD::vector<float> J(na);
-     J = F.Jacobian(acopy);
-
-     // return the value of dyda = F'(a) as a C vector
-     for(i = 0; i < na; i++)
-          dyda[i] = J[i];
-
-     return;
-}
-/*
-Link CppAD::NearEqual so do not have to use namespace notation in Interface2C
-*/
-bool NearEqual(float x, float y, float r, float a)
-{     return CppAD::NearEqual(x, y, r, a);
-}
-
-} // End empty namespace
-
-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;
-
-     // declare variables
-     float x, a[6], y, dyda[6], tmp[6];
-     size_t na, i;
-
-     // number of parameters (3 for each Gaussian)
-     na = 6;
-
-     // number of Gaussians: n  = na / 3;
-
-     // value of x
-     x = 1.;
-
-     // value of the parameter vector a
-     for(i = 0; i < na; i++)
-          a[i] = (float) (i+1);
-
-     // evaulate function and derivative
-     sumGauss(x, a, &y, dyda, na);
-
-     // compare dyda to central difference approximation for deriative
-     for(i = 0; i < na; i++)
-     {     // local variables
-          float small, ai, yp, ym, dy_da;
-
-          // 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;
-
-          // value of this component of a
-          ai    = a[i];
-
-          // evaluate F( a + small * ei )
-          a[i]  = ai + small;
-          sumGauss(x, a, &yp, tmp, na);
-
-          // evaluate F( a - small * ei )
-          a[i]  = ai - small;
-          sumGauss(x, a, &ym, tmp, na);
-
-          // evaluate central difference approximates for partial
-          dy_da = (yp - ym) / (2 * small);
-
-          // restore this component of a
-          a[i]  = ai;
-
-          ok   &= NearEqual(dyda[i], dy_da, small, small);
-     }
-     return ok;
-}
-
-
Input File: example/general/interface2c.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_interface2c.cpp_xml.js cppad-2019.02.00.0/doc/_interface2c.cpp_xml.js --- cppad-2018.00.00.0/doc/_interface2c.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_interface2c.cpp_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', -'example.xml', -'general.xml', -'interface2c.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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' -]; -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-2018.00.00.0/doc/interp_onetape.cpp.xml cppad-2019.02.00.0/doc/interp_onetape.cpp.xml --- cppad-2018.00.00.0/doc/interp_onetape.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/interp_onetape.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,220 +0,0 @@ - - - -Interpolation With Out Retaping: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -interp_onetape.cpp - -

-
Interpolation With Out Retaping: Example and Test
-
-See Also - -
-interp_retape.cpp - -
-
-
# include <cppad/cppad.hpp>
-# include <cassert>
-# include <cmath>
-
-namespace {
-     double ArgumentValue[] = {
-          .0 ,
-          .2 ,
-          .4 ,
-          .8 ,
-          1.
-     };
-     double FunctionValue[] = {
-          std::sin( ArgumentValue[0] ) ,
-          std::sin( ArgumentValue[1] ) ,
-          std::sin( ArgumentValue[2] ) ,
-          std::sin( ArgumentValue[3] ) ,
-          std::sin( ArgumentValue[4] )
-     };
-     size_t TableLength = 5;
-
-     size_t Index(const double &x)
-     {     // determine the index j such that x is between
-          // ArgumentValue[j] and ArgumentValue[j+1]
-          static size_t j = 0;
-          while ( x < ArgumentValue[j] && j > 0 )
-               j--;
-          while ( x > ArgumentValue[j+1] && j < TableLength - 2)
-               j++;
-          // assert conditions that must be true given logic above
-          assert( j >= 0 && j < TableLength - 1 );
-          return j;
-     }
-
-     double Argument(const double &x)
-     {     size_t j = Index(x);
-          return ArgumentValue[j];
-     }
-     double Function(const double &x)
-     {     size_t j = Index(x);
-          return FunctionValue[j];
-     }
-
-     double Slope(const double &x)
-     {     size_t j  = Index(x);
-          double dx = ArgumentValue[j+1] - ArgumentValue[j];
-          double dy = FunctionValue[j+1] - FunctionValue[j];
-          return dy / dx;
-     }
-     CPPAD_DISCRETE_FUNCTION(double, Argument)
-     CPPAD_DISCRETE_FUNCTION(double, Function)
-     CPPAD_DISCRETE_FUNCTION(double, Slope)
-}
-
-
-bool interp_onetape(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n = 1;
-     CPPAD_TESTVECTOR(AD<double>) X(n);
-     X[0] = .4 * ArgumentValue[1] + .6 * ArgumentValue[2];
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(X);
-
-     // evaluate piecewise linear interpolant at X[0]
-     AD<double> A = Argument(X[0]);
-     AD<double> F = Function(X[0]);
-     AD<double> S = Slope(X[0]);
-     AD<double> I = F + (X[0] - A) * S;
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) Y(m);
-     Y[0] = I;
-
-     // create f: X -> Y and stop tape recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // 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) 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
-     // 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;
-     ok  &= NearEqual(Y[0], check, eps99, eps99);
-
-     // evaluate f where x has different value
-     x[0]   = .7 * ArgumentValue[2] + .3 * ArgumentValue[3];
-     y      = f.Forward(0, x);
-
-     // check function value
-     delta  = ArgumentValue[3] - ArgumentValue[2];
-     check  = FunctionValue[3] * (x[0] - ArgumentValue[2]) / delta
-                   + FunctionValue[2] * (ArgumentValue[3] - x[0]) / delta;
-     ok  &= NearEqual(y[0], check, eps99, eps99);
-
-     // evaluate partials w.r.t. x[0]
-     dx[0] = 1.;
-     dy    = f.Forward(1, dx);
-
-     // check that the derivative is the slope
-     check = (FunctionValue[3] - FunctionValue[2])
-           / (ArgumentValue[3] - ArgumentValue[2]);
-     ok   &= NearEqual(dy[0], check, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/interp_onetape.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_interp_onetape.cpp_xml.js cppad-2019.02.00.0/doc/_interp_onetape.cpp_xml.js --- cppad-2018.00.00.0/doc/_interp_onetape.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_interp_onetape.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +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', -'discrete.xml', -'interp_onetape.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 = [ -'tape_index.cpp.xml', -'interp_onetape.cpp.xml', -'interp_retape.cpp.xml' -]; -var list_current0 = [ -'interp_onetape.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-2018.00.00.0/doc/interp_retape.cpp.xml cppad-2019.02.00.0/doc/interp_retape.cpp.xml --- cppad-2018.00.00.0/doc/interp_retape.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/interp_retape.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,212 +0,0 @@ - - - -Interpolation With Retaping: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -interp_retape.cpp - -

-
Interpolation With Retaping: Example and Test
-
-See Also - -
-interp_onetape.cpp - - -
-
-
# include <cppad/cppad.hpp>
-# include <cassert>
-# include <cmath>
-
-namespace {
-     double ArgumentValue[] = {
-          .0 ,
-          .2 ,
-          .4 ,
-          .8 ,
-          1.
-     };
-     double FunctionValue[] = {
-          std::sin( ArgumentValue[0] ) ,
-          std::sin( ArgumentValue[1] ) ,
-          std::sin( ArgumentValue[2] ) ,
-          std::sin( ArgumentValue[3] ) ,
-          std::sin( ArgumentValue[4] )
-     };
-     size_t TableLength = 5;
-
-     size_t Index(const CppAD::AD<double> &x)
-     {     // determine the index j such that x is between
-          // ArgumentValue[j] and ArgumentValue[j+1]
-          static size_t j = 0;
-          while ( x < ArgumentValue[j] && j > 0 )
-               j--;
-          while ( x > ArgumentValue[j+1] && j < TableLength - 2)
-               j++;
-          // assert conditions that must be true given logic above
-          assert( j >= 0 && j < TableLength - 1 );
-          return j;
-     }
-     double Argument(const CppAD::AD<double> &x)
-     {     size_t j = Index(x);
-          return ArgumentValue[j];
-     }
-     double Function(const CppAD::AD<double> &x)
-     {     size_t j = Index(x);
-          return FunctionValue[j];
-     }
-     double Slope(const CppAD::AD<double> &x)
-     {     size_t j  = Index(x);
-          double dx = ArgumentValue[j+1] - ArgumentValue[j];
-          double dy = FunctionValue[j+1] - FunctionValue[j];
-          return dy / dx;
-     }
-}
-
-bool interp_retape(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n = 1;
-     CPPAD_TESTVECTOR(AD<double>) X(n);
-
-     // loop over argument values
-     size_t k;
-     for(k = 0; k < TableLength - 1; k++)
-     {
-          X[0] = .4 * ArgumentValue[k] + .6 * ArgumentValue[k+1];
-
-          // declare independent variables and start tape recording
-          // (use a different tape for each argument value)
-          CppAD::Independent(X);
-
-          // evaluate piecewise linear interpolant at X[0]
-          AD<double> A = Argument(X[0]);
-          AD<double> F = Function(X[0]);
-          AD<double> S = Slope(X[0]);
-          AD<double> I = F + (X[0] - A) * S;
-
-          // range space vector
-          size_t m = 1;
-          CPPAD_TESTVECTOR(AD<double>) Y(m);
-          Y[0] = I;
-
-          // create f: X -> Y and stop tape recording
-          CppAD::ADFun<double> f(X, Y);
-
-          // 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) 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
-          // ArgumentValue[k] and ArgumentValue[k+1]
-          double delta, check;
-          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;
-          ok    &= NearEqual(Y[0], check, eps99, eps99);
-
-          // evaluate partials w.r.t. x[0]
-          dx[0] = 1.;
-          dy    = f.Forward(1, dx);
-
-          // check that the derivative is the slope
-          check = (FunctionValue[k+1] - FunctionValue[k])
-                / (ArgumentValue[k+1] - ArgumentValue[k]);
-          ok   &= NearEqual(dy[0], check, eps99, eps99);
-     }
-     return ok;
-}
-
-
-
Input File: example/general/interp_retape.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_interp_retape.cpp_xml.js cppad-2019.02.00.0/doc/_interp_retape.cpp_xml.js --- cppad-2018.00.00.0/doc/_interp_retape.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_interp_retape.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +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', -'discrete.xml', -'interp_retape.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 = [ -'tape_index.cpp.xml', -'interp_onetape.cpp.xml', -'interp_retape.cpp.xml' -]; -var list_current0 = [ -'interp_retape.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-2018.00.00.0/doc/introduction.xml cppad-2019.02.00.0/doc/introduction.xml --- cppad-2018.00.00.0/doc/introduction.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/introduction.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,243 +0,0 @@ - - - -An Introduction by Example to Algorithmic Differentiation - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -

-
An Introduction by Example to Algorithmic Differentiation
-
-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 -for a forward or reverse sweep. - - -
-
-Preface - - -
-
-Algorithmic Differentiation -
-Algorithmic Differentiation -(often referred to as Automatic Differentiation or just AD) -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 -(do not have any truncation error). - -
-
-Forward Mode -
-A forward mode sweep computes -the partial derivative of all the dependent variables with respect -to one independent variable (or independent variable direction). - -
-
-Reverse Mode -
-A reverse mode sweep computes -the derivative of one dependent variable -(or one dependent variable direction) -with respect to all the independent variables. - -
-
-Operation Count -
-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. -Thus, using reverse mode, -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. - -
-
-Efficiency -
-AD automatically takes advantage of the -speed of your algorithmic representation of a function. -For example, -if you calculate a determinant using LU factorization, -AD will use the LU representation for -the derivative of the determinant -(which is faster than using the definition of the determinant). - -
-
-Outline - -
  1. -Demonstrate the use of CppAD to calculate derivatives of a -polynomial: get_started.cpp -. - -
  2. - -Present two algorithms that approximate the exponential function. -The first algorithm exp_2.hpp - is simpler and does not -include any logical variables or loops. -The second algorithm exp_eps.hpp - includes -logical operations and a while loop. -For each of these algorithms, do the following: - -
    1. -Define the mathematical function corresponding to the algorithm -(exp_2 - and exp_eps -). -
    2. - -Write out the floating point operation sequence, -and corresponding values, -that correspond to executing the algorithm for a specific input -(exp_2_for0 - and exp_eps_for0 -). -
    3. - -Compute a forward sweep derivative of the operation sequence -(exp_2_for1 - and exp_eps_for1 -). -
    4. - -Compute a reverse sweep derivative of the operation sequence -(exp_2_rev1 - and exp_eps_rev1 -). -
    5. - -Use CppAD to compute both a forward and reverse sweep -of the operation sequence -(exp_2_cppad - and exp_eps_cppad -). -
    - - -
  3. - -The program exp_apx.cpp - runs all of the test -routines that validate the calculations in the exp_2 - -and exp_eps - presentation. -
- - -
-
-Reference -
-An in-depth review of AD theory and methods can be found in -the book - -Evaluating Derivatives:
-Principles and Techniques of Algorithmic Differentiation
-
-, -Andreas Griewank, -SIAM Frontiers in Applied Mathematics, -2000. - -
-
-Contents -
- -
exp_2Second Order Exponential Approximation
exp_epsAn Epsilon Accurate Exponential Approximation
exp_apx.cppCorrectness Tests For Exponential Approximation in Introduction
-
Input File: omh/introduction.omh - - - diff -Nru cppad-2018.00.00.0/doc/_introduction_xml.js cppad-2019.02.00.0/doc/_introduction_xml.js --- cppad-2018.00.00.0/doc/_introduction_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_introduction_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'introduction.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 = [ -'exp_2.xml', -'exp_eps.xml', -'exp_apx.cpp.xml' -]; -var list_current0 = [ -'introduction.xml#Purpose', -'introduction.xml#Preface', -'introduction.xml#Preface.Algorithmic Differentiation', -'introduction.xml#Preface.Forward Mode', -'introduction.xml#Preface.Reverse Mode', -'introduction.xml#Preface.Operation Count', -'introduction.xml#Preface.Efficiency', -'introduction.xml#Outline', -'introduction.xml#Reference', -'introduction.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_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-2018.00.00.0/doc/ipopt_nlp_get_started.cpp.xml cppad-2019.02.00.0/doc/ipopt_nlp_get_started.cpp.xml --- cppad-2018.00.00.0/doc/ipopt_nlp_get_started.cpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_nlp_get_started.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,365 +0,0 @@ - - - -Nonlinear Programming Using CppAD and Ipopt: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ipopt_nlp_get_started.cpp - -

- - - -
Nonlinear Programming Using CppAD and Ipopt: Example and Test
-
-Purpose -
-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 - - - -minimize - - - -x -1 - -* -x -4 - -* -( -x -1 - -+ -x -2 - -+ -x -3 - -) -+ -x -3 - - -subject - -to - - - -x -1 - -* -x -2 - -* -x -3 - -* -x -4 - - -25 - - -x -1 -2 - -+ -x -2 -2 - -+ -x -3 -2 - -+ -x -4 -2 - -= -40 - - -1 - -x -1 - -, -x -2 - -, -x -3 - -, -x -4 - - -5 - - - -
-Configuration Requirement -
-This example will be compiled and tested provided that -a value for -ipopt_prefix - -is specified on the cmake - command line. - - -

-# include <cppad_ipopt_nlp.hpp>
-
-namespace {
-     using namespace cppad_ipopt;
-
-     class FG_info : public cppad_ipopt_fg_info
-     {
-     private:
-          bool retape_;
-     public:
-          // derived class part of constructor
-          FG_info(bool retape_in)
-          : retape_ (retape_in)
-          { }
-          // Evaluation of the objective f(x), and constraints g(x)
-          // using an Algorithmic Differentiation (AD) class.
-          ADVector eval_r(size_t k, const ADVector&  x)
-          {     ADVector fg(3);
-
-               // Fortran style indexing
-               ADNumber x1 = x[0];
-               ADNumber x2 = x[1];
-               ADNumber x3 = x[2];
-               ADNumber x4 = x[3];
-               // f(x)
-               fg[0] = x1 * x4 * (x1 + x2 + x3) + x3;
-               // g_1 (x)
-               fg[1] = x1 * x2 * x3 * x4;
-               // g_2 (x)
-               fg[2] = x1 * x1 + x2 * x2 + x3 * x3 + x4 * x4;
-               return fg;
-          }
-          bool retape(size_t k)
-          {     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;
-     // number of constraints (range dimension for g)
-     size_t m = 2;
-     // initial value of the independent variables
-     NumberVector x_i(n);
-     x_i[0] = 1.0;
-     x_i[1] = 5.0;
-     x_i[2] = 5.0;
-     x_i[3] = 1.0;
-     // lower and upper limits for x
-     NumberVector x_l(n);
-     NumberVector x_u(n);
-     for(j = 0; j < n; j++)
-     {     x_l[j] = 1.0;
-          x_u[j] = 5.0;
-     }
-     // lower and upper limits for g
-     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;
-
-     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
-          // the operation sequence does not depend on x (for this case).
-          bool retape = icase != 0;
-
-          // object in derived class
-          FG_info fg_info(retape);
-
-          // create the Ipopt interface
-          cppad_ipopt_solution solution;
-          Ipopt::SmartPtr<Ipopt::TNLP> cppad_nlp = new cppad_ipopt_nlp(
-          n, m, x_i, x_l, x_u, g_l, g_u, &fg_info, &solution
-          );
-
-          // Create an instance of the IpoptApplication
-          using Ipopt::IpoptApplication;
-          Ipopt::SmartPtr<IpoptApplication> app = new IpoptApplication();
-
-          // turn off any printing
-          app->Options()->SetIntegerValue("print_level", 0);
-          app->Options()->SetStringValue("sb", "yes");
-
-          // maximum number of iterations
-          app->Options()->SetIntegerValue("max_iter", 10);
-
-          // approximate accuracy in first order necessary conditions;
-          // see Mathematical Programming, Volume 106, Number 1,
-          // Pages 25-57, Equation (6)
-          app->Options()->SetNumericValue("tol", 1e-9);
-
-          // derivative testing
-          app->Options()->
-          SetStringValue("derivative_test", "second-order");
-          app->Options()-> SetNumericValue(
-               "point_perturbation_radius", 0.
-          );
-
-          // Initialize the IpoptApplication and process the options
-          Ipopt::ApplicationReturnStatus status = app->Initialize();
-          ok    &= status == Ipopt::Solve_Succeeded;
-
-          // Run the IpoptApplication
-          status = app->OptimizeTNLP(cppad_nlp);
-          ok    &= status == Ipopt::Solve_Succeeded;
-
-          /*
-          Check some of the solution values
-          */
-          ok &= solution.status == cppad_ipopt_solution::success;
-          //
-          double check_x[]   = { 1.000000, 4.743000, 3.82115, 1.379408 };
-          double check_z_l[] = { 1.087871, 0.,       0.,      0.       };
-          double check_z_u[] = { 0.,       0.,       0.,      0.       };
-          double rel_tol     = 1e-6;  // relative tolerance
-          double abs_tol     = 1e-6;  // absolute tolerance
-          for(j = 0; j < n; j++)
-          {     ok &= CppAD::NearEqual(
-               check_x[j],   solution.x[j],   rel_tol, abs_tol
-               );
-               ok &= CppAD::NearEqual(
-               check_z_l[j], solution.z_l[j], rel_tol, abs_tol
-               );
-               ok &= CppAD::NearEqual(
-               check_z_u[j], solution.z_u[j], rel_tol, abs_tol
-               );
-          }
-     }
-
-     return ok;
-}
-
-
-
Input File: cppad_ipopt/example/get_started.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_nlp_get_started.cpp_xml.js cppad-2019.02.00.0/doc/_ipopt_nlp_get_started.cpp_xml.js --- cppad-2018.00.00.0/doc/_ipopt_nlp_get_started.cpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_nlp_get_started.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'cppad_ipopt_nlp.xml', -'ipopt_nlp_get_started.cpp.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'ipopt_nlp_get_started.cpp.xml', -'ipopt_nlp_ode.xml', -'ipopt_ode_speed.cpp.xml' -]; -var list_current0 = [ -'ipopt_nlp_get_started.cpp.xml#Purpose', -'ipopt_nlp_get_started.cpp.xml#Configuration Requirement' -]; -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-2018.00.00.0/doc/ipopt_nlp_ode_check.cpp.xml cppad-2019.02.00.0/doc/ipopt_nlp_ode_check.cpp.xml --- cppad-2018.00.00.0/doc/ipopt_nlp_ode_check.cpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_nlp_ode_check.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,178 +0,0 @@ - - - -Correctness Check for Both Simple and Fast Representations - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ipopt_nlp_ode_check.cppHeadings

-
Correctness Check for Both Simple and Fast Representations
-
# include "ode_run.hpp"
-
-bool ode_check(const SizeVector& N, const NumberVector& x)
-{     bool ok = true;
-     size_t i, j;
-
-     // number of components of x corresponding to values for y
-     size_t ny_inx = x.size() - Na;
-
-     // compute the partial sums of the number of grid points
-     // and the maximum step size for the trapezoidal approximation
-     SizeVector S(Nz+1);
-     S[0] = 0;
-     Number max_step = 0.;
-     for(i = 1; i <= Nz; i++)
-     {     S[i] = S[i-1] + N[i];
-          max_step = std::max(max_step, Number(s[i] - s[i-1]) / Number(N[i]) );
-     }
-
-     // split out return values
-     NumberVector a(Na), y_0(Ny), y_1(Ny), y_2(Ny);
-     for(j = 0; j < Na; j++)
-          a[j] = x[ny_inx+j];
-     for(j = 0; j < Ny; j++)
-     {     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;
-     Number abs_tol = rel_tol;
-     Number check_a[] = {a0, a1, a2}; // see the y_one function
-     for(j = 0; j < Na; j++)
-     {
-          ok &= CppAD::NearEqual(
-               check_a[j], a[j], rel_tol, abs_tol
-          );
-     }
-
-     // check accuarcy of constraint equations
-     rel_tol = 1e-9;
-     abs_tol = 1e-9;
-
-     // check the initial value constraint
-     NumberVector F = eval_F(a);
-     for(j = 0; j < Ny; j++)
-          ok &= CppAD::NearEqual(F[j], y_0[j], rel_tol, abs_tol);
-
-     // check the first trapezoidal equation
-     NumberVector G_0 = eval_G(y_0, a);
-     NumberVector G_1 = eval_G(y_1, a);
-     Number dt = (s[1] - s[0]) / Number(N[1]);
-     Number check;
-     for(j = 0; j < Ny; j++)
-     {     check = y_1[j] - y_0[j] - (G_1[j]+G_0[j])*dt/2;
-          ok &= CppAD::NearEqual( check, 0., rel_tol, abs_tol);
-     }
-     //
-     // check the second trapezoidal equation
-     NumberVector G_2 = eval_G(y_2, a);
-     if( N[1] == 1 )
-          dt = (s[2] - s[1]) / Number(N[2]);
-     for(j = 0; j < Ny; j++)
-     {     check = y_2[j] - y_1[j] - (G_2[j]+G_1[j])*dt/2;
-          ok &= CppAD::NearEqual( check, 0., rel_tol, abs_tol);
-     }
-     //
-     // check the objective function (specialized to this case)
-     check = 0.;
-     NumberVector y_i(Ny);
-     for(size_t k = 0; k < Nz; k++)
-     {     for(j = 0; j < Ny; j++)
-               y_i[j] =  x[S[k+1] * Ny + j];
-          check += eval_H<Number>(k + 1, y_i, a);
-     }
-     Number obj_value = 0.; // optimal object (no noise in simulation)
-     ok &= CppAD::NearEqual(check, obj_value, rel_tol, abs_tol);
-
-     // Use this empty namespace function to avoid warning that it is not used
-     static size_t ode_check_count = 0;
-     ode_check_count++;
-     ok &= count_eval_r() == ode_check_count;
-
-     return ok;
-}
-
-
Input File: cppad_ipopt/example/ode_check.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_nlp_ode_check.cpp_xml.js cppad-2019.02.00.0/doc/_ipopt_nlp_ode_check.cpp_xml.js --- cppad-2018.00.00.0/doc/_ipopt_nlp_ode_check.cpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_nlp_ode_check.cpp_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', -'deprecated.xml', -'cppad_ipopt_nlp.xml', -'ipopt_nlp_ode.xml', -'ipopt_nlp_ode_check.cpp.xml' -]; -var list_down3 = [ -'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', -'autotools.xml' -]; -var list_down2 = [ -'ipopt_nlp_get_started.cpp.xml', -'ipopt_nlp_ode.xml', -'ipopt_ode_speed.cpp.xml' -]; -var list_down1 = [ -'ipopt_nlp_ode_problem.xml', -'ipopt_nlp_ode_simple.xml', -'ipopt_nlp_ode_fast.xml', -'ipopt_nlp_ode_run.hpp.xml', -'ipopt_nlp_ode_check.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-2018.00.00.0/doc/ipopt_nlp_ode_fast.hpp.xml cppad-2019.02.00.0/doc/ipopt_nlp_ode_fast.hpp.xml --- cppad-2018.00.00.0/doc/ipopt_nlp_ode_fast.hpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_nlp_ode_fast.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,234 +0,0 @@ - - - -ODE Fitting Using Fast Representation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ipopt_nlp_ode_fast.hppHeadings

-
ODE Fitting Using Fast Representation
-
# include "ode_problem.hpp"
-
-namespace {
-     using namespace cppad_ipopt;
-
-     class FG_fast : public cppad_ipopt_fg_info
-     {
-     private:
-          bool       retape_;
-          SizeVector N_;
-          SizeVector S_;
-     public:
-          // derived class part of constructor
-          FG_fast(bool retape_in, const SizeVector& N)
-          : retape_ (retape_in), N_(N)
-          {     assert( N_[0] == 0 );
-               S_.resize( N_.size() );
-               S_[0] = 0;
-               for(size_t i = 1; i < N_.size(); i++)
-                    S_[i] = S_[i-1] + N_[i];
-          }
-          // r^k for k = 0, 1, ..., Nz-1 used for measurements
-          // r^k for k = Nz              use for initial condition
-          // r^k for k = Nz+1, ..., 2*Nz used for trapezoidal approx
-          size_t number_functions(void)
-          {     return Nz + 1 + Nz; }
-          ADVector eval_r(size_t k, const ADVector &u)
-          {     count_eval_r();
-
-               size_t j;
-               ADVector y(Ny), a(Na);
-               // objective function --------------------------------
-               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]
-                    for(j = 0; j < Ny; j++)
-                         y[j] = u[j];
-                    for(j = 0; j < Na; j++)
-                         a[j] = u[Ny + j];
-                    r[0] = eval_H<ADNumber>(k+1, y, a);
-                    return r;
-               }
-               // initial condition ---------------------------------
-               if( k == Nz )
-               {     ADVector r(Ny), F(Ny);
-                    // 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];
-                    return  r;
-               }
-               // trapezoidal approximation -------------------------
-               ADVector ym(Ny), G(Ny), Gm(Ny), r(Ny);
-               // 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 )
-               for(j = 0; j < Ny; j++)
-               {     ym[j] = u[j];
-                    y[j]  = u[Ny + j];
-               }
-               for(j = 0; j < Na; j++)
-                    a[j] = u[2 * Ny + j];
-               Gm  = eval_G(ym, a);
-               G   = eval_G(y,  a);
-               for(j = 0; j < Ny; j++)
-                    r[j] = y[j] - ym[j] - (G[j] + Gm[j]) * dt / 2.;
-               return r;
-          }
-          // The operations sequence for r_eval does not depend on u,
-          // hence retape = false should work and be faster.
-          bool retape(size_t k)
-          {     return retape_; }
-          // size of the vector u in eval_r
-          size_t domain_size(size_t k)
-          {     if( k < Nz )
-                    return Ny + Na;   // objective function
-               if( k == Nz )
-                    return Ny + Na;  // initial value constraint
-               return 2 * Ny + Na;      // trapezodial constraints
-          }
-          // size of the return value from eval_r
-          size_t range_size(size_t k)
-          {     if( k < Nz )
-                    return 1;
-               return Ny;
-          }
-          // number of terms that use this value of k
-          size_t number_terms(size_t k)
-          {     if( k <= Nz )
-                    return 1;  // r^k used once for k <= Nz
-               // r^k used N_[k-Nz] times for k > Nz
-               return N_[k-Nz];
-          }
-          void index(size_t k, size_t ell, SizeVector& I, SizeVector& J)
-          {     size_t i, j;
-               // # of components of x corresponding to values for y
-               size_t ny_inx = (S_[Nz] + 1) * Ny;
-               // objective function -------------------------------
-               if( k < Nz )
-               {     // 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]]
-                    // 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;
-                    return;
-               }
-               // initial conditions --------------------------------
-               if( k == Nz )
-               {     // index in fg for inidial condition constraint
-                    for(j = 0; j < Ny; j++)
-                         I[j] = 1 + j;
-                    // u = [ y(t, a) , a ] where t = 0
-                    // x indices corresponding to this value of y
-                    for(j = 0; j < Ny; j++)
-                         J[j] = j;
-                    // following that, u contains the vector a
-                    for(j = 0; j < Na; j++)
-                         J[Ny + j] = ny_inx + j;
-                    return;
-               }
-               // trapoziodal approximation -------------------------
-               // index of first grid point in this approximation
-               i = S_[k - Nz - 1]  + ell;
-               // 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++)
-                    I[j] = 1 + Ny + i * Ny + j;
-               // u = [ y(t, a) , y(t+dt, a) , a ] at t = t[i]
-               for(j = 0; j < Ny; j++)
-               {     J[j]      = i * Ny  + j; // y^i indices
-                    J[Ny + j] = J[j] + Ny;   // y^{i+1} indices
-               }
-               for(j = 0; j < Na; j++)
-                    J[2 * Ny + j] = ny_inx + j; // a indices
-          }
-     };
-
-}
-
-
Input File: cppad_ipopt/example/ode_fast.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_nlp_ode_fast.hpp_xml.js cppad-2019.02.00.0/doc/_ipopt_nlp_ode_fast.hpp_xml.js --- cppad-2018.00.00.0/doc/_ipopt_nlp_ode_fast.hpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_nlp_ode_fast.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'cppad_ipopt_nlp.xml', -'ipopt_nlp_ode.xml', -'ipopt_nlp_ode_fast.xml', -'ipopt_nlp_ode_fast.hpp.xml' -]; -var list_down3 = [ -'ipopt_nlp_get_started.cpp.xml', -'ipopt_nlp_ode.xml', -'ipopt_ode_speed.cpp.xml' -]; -var list_down2 = [ -'ipopt_nlp_ode_problem.xml', -'ipopt_nlp_ode_simple.xml', -'ipopt_nlp_ode_fast.xml', -'ipopt_nlp_ode_run.hpp.xml', -'ipopt_nlp_ode_check.cpp.xml' -]; -var list_down1 = [ -'ipopt_nlp_ode_fast.hpp.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-2018.00.00.0/doc/ipopt_nlp_ode_fast.xml cppad-2019.02.00.0/doc/ipopt_nlp_ode_fast.xml --- cppad-2018.00.00.0/doc/ipopt_nlp_ode_fast.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_nlp_ode_fast.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1556 +0,0 @@ - - - -ODE Fitting Using Fast Representation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
ODE Fitting Using Fast Representation
-
-Purpose -
-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 -(either by hand coding or by using AD). - -
-
-Objective Function -
-We use the following representation for the -objective function -: -For - -k -= -0 -, - -, -Nz -- -1 - - -, -we define the function - -r -k - -: -R - -Ny -+ -Na - - - -R - - - - -by - - - -fg -0 - -( -x -) - -= - - -i -= -1 - -Nz - - -H -i - -( -y -S -( -i -) - - -, -a -) - -fg -0 - -( -x -) - -= - - -k -= -0 - -Nz --1 - - -r -k - -( -u -k -, -0 - - -) - - - -where for - -k -= -0 -, - -, -Nz --1 - - -, - - -u -k -, -0 - - - -R - -Ny -+ -Na - - - - - is defined by - - -u -k -, -0 - - -= -( -y -S -( -k -+ -1 -) - - -, -a -) - - - - -
-
-Range Indices I(k,0) -
-For - -k -= -0 -, - -, -Nz -- -1 - - -, -the range index in the vector - -fg -( -x -) - - - -corresponding to - -r -k - -( -u -k -, -0 - - -) - - - is 0. -Thus, the range indices are given by - - -I -( -k -, -0 -) -= -{ -0 -} - - - for - -k -= -0 -, - -, -Nz --1 - - -. - -
-
-Domain Indices J(k,0) -
-For - -k -= -0 -, - -, -Nz -- -1 - - -, -the components of the vector - -x - - - -corresponding to the vector - -u -k -, -0 - - - - - are - - - -u -k -, -0 - - - -= - -( -y -S -( -k -+ -1 - - -, -a -) - - -= - -( -x -Ny -* -S -( -k -+ -1 -) - - - -, - - - -, - -x -Ny -* -S -( -k -+ -1 -) -+ -Ny -- -1 - - - -, - -x -Ny -* -S -( -Nz -) -+ -Ny - - - -, - - - -, - -x -Ny -* -S -( -Nz -) -+ -Ny -+ -Na -- -1 - - -) - - - -Thus, the domain indices are given by - - -J -( -k -, -0 -) -= -{ -Ny -* -S -( -k -+ -1 -) - -, - - - -, - -Ny -* -S -( -k -+ -1 -) -+ -Ny -- -1 - -, - -Ny -* -S -( -Nz -) -+ -Ny - -, - - - -, - -Ny -* -S -( -Nz -) -+ -Ny -+ -Na -- -1 -} - - -
-Initial Condition -
-We use the following representation for the -initial condition constraint -: -For - -k -= -Nz - - - we define the function - - -r -k - -: -R - -Ny - - -× -R - -Na -+ -Ny - - - - - by - - - -0 - -= - -fg -i - -( -x -) -= -y -i -0 - -- -F -i - -( -a -) - -0 - -= - -r -i --1 - -k - -( -u -k -, -0 - - -) -= -y -i -0 - -- -F -i - -( -a -) - - - -where - -i -= -1 -, - -, -Ny - - - and -where - -u -k -, -0 - - - -R - -Ny -+ -Na - - - - - is defined by - - -u -k -, -0 - - -= -( -y -0 - -, -a -) - - -. - -
-
-Range Indices I(k,0) -
-For - -k -= -Nz - - -, -the range index in the vector - -fg -( -x -) - - - -corresponding to - -r -k - -( -u -k -, -0 - - -) - - - are - - -I -( -k -, -0 -) -= -{ -1 -, - -, -Ny -} - - -. - -
-
-Domain Indices J(k,0) -
-For - -k -= -Nz - - -, -the components of the vector - -x - - - -corresponding to the vector - -u -k -, -0 - - - - - are - - - -u -k -, -0 - - - -= - -( -y -0 - -, -a -) - - -= - -( -x -0 - - -, - - - -, - -x -Ny --1 - - - -, - -x -Ny -* -S -( -Nz -) -+ -Ny - - - -, - - - -, - -x -Ny -* -S -( -Nz -) -+ -Ny -+ -Na -- -1 - - -) - - - -Thus, the domain indices are given by - - -J -( -k -, -0 -) -= -{ -0 - -, - - - -, - -Ny -- -1 - -, - -Ny -* -S -( -Nz -) -+ -Ny - -, - - - -, - -Ny -* -S -( -Nz -) -+ -Ny -+ -Na -- -1 -} - - -
-Trapezoidal Approximation -
-We use the following representation for the -trapezoidal approximation constraint -: -For - -k -= -1 -, - -, -Nz - - -, -we define the function - -r -Nz -+ -k - - -: -R - -2 -* -Ny -+ -Na - - - -R - -Ny - - - - - by - - -r -Nz -+ -k - - -( -y -, -w -, -a -) -= -y -- -w -- -[ -G -( -y -, -a -) -+ -G -( -w -, -a -) -] -* -Δ -t -k - - -2 - - - - -For - - -= -0 -, - -, -N -( -k -) --1 - - -, -using the notation - -i -= -Ny -* -S -( -k --1 -) -+ - -+ -1 - - -, -the corresponding trapezoidal approximation is represented by - - - -0 - -= - -fg -Ny -+ -i - - -( -x -) - - -= - -y -i - -- -y -i --1 - - -- -[G -( -y -i - -, -a -) -+ -G -( -y -i --1 - - -, -a -) -] -* -Δ -t -k - - -2 - - - - -= - -r -Nz -+ -k - - -( -u -Nz -+ -k -, - - - -) - - - -where - -u -Nz -+ -k -, - - - - -R - -2 -* -Ny -+ -Na - - - - - is defined by - - -u -Nz -+ -k -, - - - -= -( -y -i --1 - - -, -y -i - -, -a -) - - -. - -
-
-Range Indices I(k,0) -
-For - -k -= -Nz -+ -1 -, - -, -2 -* -Nz - - -, -and - - -= -0 -, - -, -N -( -k -) --1 - - -, -the range index in the vector - -fg -( -x -) - - - -corresponding to - -r -k - -( -u -k -, - - - -) - - - are - - -I -( -k -, - -) -= -{ -Ny -+ -i -, - -, -2 -* -Ny -+ -i -- -1 -} - - - -where - -i -= -Ny -* -S -( -k --1 -) -+ - -+ -1 - - -. - -
-
-Domain Indices J(k,0) -
-For - -k -= -Nz -+ -1 -, - -, -2 -* -Nz - - -, -and - - -= -0 -, - -, -N -( -k -) --1 - - -, -define - -i -= -Ny -* -S -( -k --1 -) -+ - -+ -1 - - -. -The components of the vector - -x - - - -corresponding to the vector - -u -k -, - - - - - - are -(and the function - -fg -( -x -) - - - in cppad_ipopt_nlp - ) - - - -u -k -, - - - - -= - -( -y -i --1 - - -, -y -i - -, -a -) - - -= - -( -x -Ny -* -( -i --1 -) - - - -, - - - -, - -x -Ny -* -( -i -+ -1 -) -- -1 - - - -, - -x -Ny -* -S -( -Nz -) -+ -Ny - - - -, - - - -, - -x -Ny -* -S -( -Nz -) -+ -Ny -+ -Na -- -1 - - -) - - - -Thus, the domain indices are given by - - -J -( -k -, - -) -= -{ -Ny -* -( -i --1 -) - -, - - - -, - -Ny -* -( -i -+ -1 -) -- -1 - -, - -Ny -* -S -( -Nz -) -+ -Ny - -, - - - -, - -Ny -* -S -( -Nz -) -+ -Ny -+ -Na -- -1 -} - - -
-Source -
-The file ipopt_nlp_ode_fast.hpp - -contains source code for this representation of the objective -and constraints. - - - -
Input File: cppad_ipopt/example/ode2.omh - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_nlp_ode_fast_xml.js cppad-2019.02.00.0/doc/_ipopt_nlp_ode_fast_xml.js --- cppad-2018.00.00.0/doc/_ipopt_nlp_ode_fast_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_nlp_ode_fast_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'cppad_ipopt_nlp.xml', -'ipopt_nlp_ode.xml', -'ipopt_nlp_ode_fast.xml' -]; -var list_down3 = [ -'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', -'autotools.xml' -]; -var list_down2 = [ -'ipopt_nlp_get_started.cpp.xml', -'ipopt_nlp_ode.xml', -'ipopt_ode_speed.cpp.xml' -]; -var list_down1 = [ -'ipopt_nlp_ode_problem.xml', -'ipopt_nlp_ode_simple.xml', -'ipopt_nlp_ode_fast.xml', -'ipopt_nlp_ode_run.hpp.xml', -'ipopt_nlp_ode_check.cpp.xml' -]; -var list_down0 = [ -'ipopt_nlp_ode_fast.hpp.xml' -]; -var list_current0 = [ -'ipopt_nlp_ode_fast.xml#Purpose', -'ipopt_nlp_ode_fast.xml#Objective Function', -'ipopt_nlp_ode_fast.xml#Objective Function.Range Indices I(k,0)', -'ipopt_nlp_ode_fast.xml#Objective Function.Domain Indices J(k,0)', -'ipopt_nlp_ode_fast.xml#Initial Condition', -'ipopt_nlp_ode_fast.xml#Initial Condition.Range Indices I(k,0)', -'ipopt_nlp_ode_fast.xml#Initial Condition.Domain Indices J(k,0)', -'ipopt_nlp_ode_fast.xml#Trapezoidal Approximation', -'ipopt_nlp_ode_fast.xml#Trapezoidal Approximation.Range Indices I(k,0)', -'ipopt_nlp_ode_fast.xml#Trapezoidal Approximation.Domain Indices J(k,0)', -'ipopt_nlp_ode_fast.xml#Source' -]; -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-2018.00.00.0/doc/ipopt_nlp_ode_problem.hpp.xml cppad-2019.02.00.0/doc/ipopt_nlp_ode_problem.hpp.xml --- cppad-2018.00.00.0/doc/ipopt_nlp_ode_problem.hpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_nlp_ode_problem.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ - - - -ODE Inverse Problem Definitions: Source Code - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ipopt_nlp_ode_problem.hppHeadings

- - - -
ODE Inverse Problem Definitions: Source Code
-
# include "../src/cppad_ipopt_nlp.hpp"
-
-namespace {
-     //------------------------------------------------------------------
-     typedef Ipopt::Number Number;
-     Number a0 = 1.;  // simulation value for a[0]
-     Number a1 = 2.;  // simulation value for a[1]
-     Number a2 = 1.;  // simulatioln value for a[2]
-
-     // function used to simulate data
-     Number y_one(Number t)
-     {     Number y_1 =  a0*a1 * (exp(-a2*t) - exp(-a1*t)) / (a1 - a2);
-          return y_1;
-     }
-
-     // time points were we have data (no data at first point)
-     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
-     size_t Nz  = sizeof(z) / sizeof(z[0]) - 1;
-     // Number of components in the function y(t, a)
-     size_t Ny  = 2;
-     // Number of components in the vectro a
-     size_t Na  = 3;
-
-     // Initial Condition function, F(a) = y(t, a) at t = 0
-     // (for this particular example)
-     template <class Vector>
-     Vector eval_F(const Vector &a)
-     {     Vector F(Ny);
-          // y_0 (t) = a[0]*exp(-a[1] * t)
-          F[0] = a[0];
-          // y_1 (t) =
-          // a[0]*a[1]*(exp(-a[2] * t) - exp(-a[1] * t))/(a[1] - a[2])
-          F[1] = 0.;
-          return F;
-     }
-     // G(y, a) =  \partial_t y(t, a); i.e. the differential equation
-     // (for this particular example)
-     template <class Vector>
-     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) =
-          // 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];
-          return G;
-     }
-     // H(i, y, a) = contribution to objective at i-th data point
-     // (for this particular example)
-     template <class Scalar, class Vector>
-     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;
-     }
-     // function used to count the number of calls to eval_r
-     size_t count_eval_r(void)
-     {     static size_t count = 0;
-          ++count;
-          return count;
-     }
-}
-
-
Input File: cppad_ipopt/example/ode_problem.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_nlp_ode_problem.hpp_xml.js cppad-2019.02.00.0/doc/_ipopt_nlp_ode_problem.hpp_xml.js --- cppad-2018.00.00.0/doc/_ipopt_nlp_ode_problem.hpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_nlp_ode_problem.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'cppad_ipopt_nlp.xml', -'ipopt_nlp_ode.xml', -'ipopt_nlp_ode_problem.xml', -'ipopt_nlp_ode_problem.hpp.xml' -]; -var list_down3 = [ -'ipopt_nlp_get_started.cpp.xml', -'ipopt_nlp_ode.xml', -'ipopt_ode_speed.cpp.xml' -]; -var list_down2 = [ -'ipopt_nlp_ode_problem.xml', -'ipopt_nlp_ode_simple.xml', -'ipopt_nlp_ode_fast.xml', -'ipopt_nlp_ode_run.hpp.xml', -'ipopt_nlp_ode_check.cpp.xml' -]; -var list_down1 = [ -'ipopt_nlp_ode_problem.hpp.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-2018.00.00.0/doc/ipopt_nlp_ode_problem.xml cppad-2019.02.00.0/doc/ipopt_nlp_ode_problem.xml --- cppad-2018.00.00.0/doc/ipopt_nlp_ode_problem.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_nlp_ode_problem.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1719 +0,0 @@ - - - -An ODE Inverse Problem Example - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
An ODE Inverse Problem Example
-
-Notation -
-The table below contains -the name of a variable, -the meaning of the variable value, -and the value for this particular example. -If the value is not specified in the table below, -the corresponding value in ipopt_nlp_ode_problem.hpp - -can be changed and the example should still run -(with no other changes). - -
- -Name - Meaning - Value -
- - - -Na - - - - number of parameters to fit - 3 -
- - - -Ny - - - - number components in ODE - 2 -
- - - -Nz - - - - number of measurements - 4 -
- - - -N -( -i -) - - - - -number of grid points between i-1-th and i-th measurement -
- - - -S -( -i -) - - - - -number of grid points up to an including the i-th measurement -
-
-Forward Problem -
-We consider the following ordinary differential equation: - - - - -t - -y -0 - -( -t -, -a -) - -= - -- -a -1 - -* -y -0 - -( -t -, -a -) - - -t - -y -1 - -( -t -, -a -) - -= - -+ -a -1 - -* -y -0 - -( -t -, -a -) -- -a -2 - -* -y -1 - -( -t -, -a -) - - - -with the initial conditions - - -y -0 - -( -0 -, -a -) -= -F -( -a -) -= -( -a -0 - - -0 - -) - - -where - -Na - - - is the number of parameters, - - -a - -R - -Na - - - - - is an unknown parameter vector. -The function and - -F -: -R - -Na - - - -R - -Ny - - - - - -is defined by the equation above -where - -Ny - - - is the number of components in - -y -( -t -, -a -) - - -. -Our forward problem is stated as follows: Given - -a - -R - -Na - - - - - -determine the value of - -y -( -t -, -a -) - - -, for - -t - -R - - -, that -solves the initial value problem above. - -
-
-Measurements -
-We use - -Nz - - - to denote the number of measurements. -Suppose we are also given a measurement vector - -z - -R - -Nz - - - - - -and for - -i -= -1 -, - -, -Nz - - -, -we model - -z -i - - - - by - - -z -i - -= -y -1 - -( -s -i - -, -a -) -+ -e -i - - - -where - -s -i - - -R - - - - is the time for the i-th measurement, - - -e -i - - -N - -( -0 -, -σ -2 - -) - - - is the corresponding noise, -and - -σ - -R - -+ - - - - is the corresponding standard deviation. - -
-
-Simulation Analytic Solution -
-The following analytic solution to the forward problem is used -to simulate a data set: - - - -y -0 - -( -t -, -a -) - -= - -a -0 - -* -exp -( -- -a -1 - -* -t -) - -y -1 - -( -t -, -a -) - -= - -a -0 - -* -a -1 - -* -exp -( -- -a -2 - -* -t -) -- -exp -( -- -a -1 - -* -t -) - -a -1 - -- -a -2 - - - - - - -
-Simulation Parameter Values - - -
- - - -a - -¯ -0 - -= -1 - - -   - - initial value of - -y -0 - -( -t -, -a -) - - - -
- - - -a - -¯ -1 - -= -2 - - -   - - transfer rate from compartment zero to compartment one -
- - - -a - -¯ -2 - -= -1 - - -   - - transfer rate from compartment one to outside world -
- - - -σ -= -0 - - -   - - standard deviation of measurement noise -
- - - -e -i - -= -0 - - -   - - simulated measurement noise, - -i -= -1 -, - -, -Nz - - - -
- - - -s -i - -= -i -* -.5 - - -   - - time corresponding to the i-th measurement, - - -i -= -1 -, - -, -Nz - - - -
-
-Simulated Measurement Values -
-The simulated measurement values are given by the equation - - - -z -i - - -= - -e -i - -+ -y -1 - -( -s -i - -, -a - -¯ -) - - -= - -e -i - -+ -a - -¯ -0 - -* -a - -¯ -1 - -* -exp -( -- -a - -¯ -2 - -* -s -i - -) -- -exp -( -- -a - -¯ -1 - -* -s -i - -) - -a - -¯ -1 - -- -a - -¯ -2 - - - - - - -for - -k -= -1 -, - -, -Nz - - -. - - -
-
-Inverse Problem -
-The maximum likelihood estimate for - -a - - - given - -z - - - -solves the following inverse problem - - - -minimize - - - - -i -= -1 - -Nz - - -H -i - -[ -y -( -s -i - -, -a -) -, -a -] - - -w -. -r -. -t - - -a - -R - -Na - - - - - -where the functions - - -H -i - -: -R - -Ny - - -× -R - -Na - - - -R - - - - is -defined by - - -H -i - -( -y -, -a -) -= -( -z -i - -- -y -1 - -) -2 - - - -
-Trapezoidal Approximation -
-This example uses a trapezoidal approximation to solve the ODE. -This approximation procedures starts with - - -y -0 - -= -y -( -0 -, -a -) -= -( -a -0 - - -0 - -) - - -Given a time grid - -{ -t -i - -} - - - and -an approximate value - -y -i --1 - - - - - for - -y -( -t -i --1 - - -, -a -) - - -, -the a trapezoidal method approximates - -y -( -t -i - -, -a -) - - - -(denoted by - -y -i - - - - ) by solving the equation - - -y -i - -= -y -i --1 - - -+ -[G -( -y -i - -, -a -) -+ -G -( -y -i --1 - - -, -a -) -] -* -t -i - -- -t -i --1 - - - -2 - - - - -where - -G -: -R - -Ny - - -× -R - -Na - - - -R - -Ny - - - - - is the -function representing this ODE; i.e. - - -G -( -y -, -a -) -= -( -- -a -1 - -* -y -0 - - -+ -a -1 - -* -y -0 - -- -a -2 - -* -y -1 - - -) - - -This - -G -( -y -, -a -) - - - is linear with respect to - -y - - -, hence -the implicit equation defining - -y -i - - - - can be solved -inverting the a set of linear equations. -In the general case, -where - -G -( -y -, -a -) - - - is non-linear with respect to - -y - - -, -an iterative procedure is used to calculate - -y -i - - - - -from - -y -i --1 - - - - -. - -
-
-Trapezoidal Time Grid -
-The discrete time grid, used for the trapezoidal approximation, is -denoted by - -{ -t -i - -} - - - which is defined by: - - -t -0 - -= -0 - - - and -for - -i -= -1 -, - -, -Nz - - - and for - -j -= -1 -, - -, -N -( -i -) - - -, - - - -Δ -t -i - - -= - -( -s -i - -- -s -i --1 - - -) -/ -N -( -i -) - -t -S -( -i --1 -) -+ -j - - - -= - -s -i --1 - - -+ -Δ -t -i - -* -j - - - -where - -s -0 - -= -0 - - -, - - -N -( -i -) - - - is the number of time grid points between - - -s -i --1 - - - - - and - -s -i - - - -, - - -S -( -0 -) -= -0 - - -, and - - -S -( -i -) -= -N -( -1 -) -+ - -+ -N -( -i -) - - -. -Note that for - -i -= -0 -, - -, -S -( -Nz -) - - -, - - -y -i - - - - denotes our approximation for - -y -( -t -i - -, -a -) - - - -and - -t -S -( -i -) - - - - - is equal to - -s -i - - - -. - -
-
-Black Box Method -
-A common approach to an inverse problem is to treat the forward problem -as a black box (that we do not look inside of or try to understand). -In this approach, for each value of the parameter vector - -a - - - -one uses the -trapezoidal approximation - -(on a finer grid that - -{ -s -i - -} - - -) -to solve for - -y -1 - -( -s -i - -, -a -) - - - for - -i -= -1 -, - -, -Nz - - -. - -
-
-Two levels of Iteration -
-As noted above, the trapezoidal approximation -often requires an iterative procedure. -Thus, in this approach, there are two levels of iterations, -one with respect to the parameter values during the minimization -and the other for solving the trapezoidal approximation equation. - -
-
-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 -iterative procedure. -(There are special techniques for applying AD to the solutions of iterative -procedures, but that is outside the scope of this presentation). - -
-
-Simultaneous Method -
-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, - - - -minimize - - - -i -= -1 - -Nz - - -H -i - -( -y -N -( -i -) - - -, -a -) - - -w -. -r -. -t - - -y -1 - - -R - -Ny - - -, - -, -y -S -( -Nz -) - - - -R - -Ny - - -, - -a - -R - -Na - - - -subject - -to - - -y -j - -= -y -j --1 - - -+ -[G -( -y -j --1 - - -, -a -) -+ -G -( -y -j - -, -a -) -] -* -t -j - -- -t -j --1 - - - -2 - - - - -for - - -j -= -1 -, - -, -S -( -Nz -) - - -y -0 - -= -F -( -a -) - - - -where for - -i -= -1 -, - -, -Nz - - -, - - -N -( -i -) - - - is the number of time intervals between - - -s -i --1 - - - - - and - -s -i - - - - (with - -s -0 - -= -0 - - -) -and - -S -( -i -) -= -N -( -1 -) -+ - -+ -N -( -i -) - - -. -Note that, in this form, the iterations of the optimization procedure -also solve the forward problem equations. -In addition, the functions that need to be differentiated -do not involve an iterative procedure. - - -
-
-Source -
-The file ipopt_nlp_ode_problem.hpp - contains -source code that defines the example values and functions defined above. - - -
Input File: cppad_ipopt/example/ode2.omh - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_nlp_ode_problem_xml.js cppad-2019.02.00.0/doc/_ipopt_nlp_ode_problem_xml.js --- cppad-2018.00.00.0/doc/_ipopt_nlp_ode_problem_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_nlp_ode_problem_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'cppad_ipopt_nlp.xml', -'ipopt_nlp_ode.xml', -'ipopt_nlp_ode_problem.xml' -]; -var list_down3 = [ -'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', -'autotools.xml' -]; -var list_down2 = [ -'ipopt_nlp_get_started.cpp.xml', -'ipopt_nlp_ode.xml', -'ipopt_ode_speed.cpp.xml' -]; -var list_down1 = [ -'ipopt_nlp_ode_problem.xml', -'ipopt_nlp_ode_simple.xml', -'ipopt_nlp_ode_fast.xml', -'ipopt_nlp_ode_run.hpp.xml', -'ipopt_nlp_ode_check.cpp.xml' -]; -var list_down0 = [ -'ipopt_nlp_ode_problem.hpp.xml' -]; -var list_current0 = [ -'ipopt_nlp_ode_problem.xml#Notation', -'ipopt_nlp_ode_problem.xml#Forward Problem', -'ipopt_nlp_ode_problem.xml#Measurements', -'ipopt_nlp_ode_problem.xml#Measurements.Simulation Analytic Solution', -'ipopt_nlp_ode_problem.xml#Measurements.Simulation Parameter Values', -'ipopt_nlp_ode_problem.xml#Measurements.Simulated Measurement Values', -'ipopt_nlp_ode_problem.xml#Inverse Problem', -'ipopt_nlp_ode_problem.xml#Trapezoidal Approximation', -'ipopt_nlp_ode_problem.xml#Trapezoidal Approximation.Trapezoidal Time Grid', -'ipopt_nlp_ode_problem.xml#Black Box Method', -'ipopt_nlp_ode_problem.xml#Black Box Method.Two levels of Iteration', -'ipopt_nlp_ode_problem.xml#Black Box Method.Derivatives', -'ipopt_nlp_ode_problem.xml#Simultaneous Method', -'ipopt_nlp_ode_problem.xml#Source' -]; -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-2018.00.00.0/doc/ipopt_nlp_ode_run.hpp.xml cppad-2019.02.00.0/doc/ipopt_nlp_ode_run.hpp.xml --- cppad-2018.00.00.0/doc/ipopt_nlp_ode_run.hpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_nlp_ode_run.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,185 +0,0 @@ - - - -Driver for Running the Ipopt ODE Example - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ipopt_nlp_ode_run.hppHeadings

-
Driver for Running the Ipopt ODE Example
-
# include "ode_problem.hpp"
-
-namespace { // BEGIN empty namespace -----------------------------------------
-using namespace cppad_ipopt;
-
-template <class FG_info>
-void ipopt_ode_case(
-     bool  retape        ,
-     const SizeVector& N ,
-     NumberVector&     x )
-{     bool ok = true;
-     size_t i, j;
-
-     // compute the partial sums of the number of grid points
-     assert( N.size() == Nz + 1);
-     assert( N[0] == 0 );
-     SizeVector S(Nz+1);
-     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
-     // 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++)
-     {     x_i[j] = 0.;       // initial y(t) for optimization
-          x_l[j] = -1.0e19;  // no lower limit
-          x_u[j] = +1.0e19;  // no upper limit
-     }
-     for(j = 0; j < Na; j++)
-     {     x_i[ny_inx + j ] = .5;       // initiali a for optimization
-          x_l[ny_inx + j ] =  -1.e19;  // no lower limit
-          x_u[ny_inx + j ] =  +1.e19;  // no upper
-     }
-     // all of the difference equations are constrained to the value zero
-     NumberVector g_l(m), g_u(m);
-     for(i = 0; i < m; i++)
-     {     g_l[i] = 0.;
-          g_u[i] = 0.;
-     }
-
-     // object defining the objective f(x) and constraints g(x)
-     FG_info fg_info(retape, N);
-
-     // create the CppAD Ipopt interface
-     cppad_ipopt_solution solution;
-     Ipopt::SmartPtr<Ipopt::TNLP> cppad_nlp = new cppad_ipopt_nlp(
-          n, m, x_i, x_l, x_u, g_l, g_u, &fg_info, &solution
-     );
-
-     // Create an Ipopt application
-     using Ipopt::IpoptApplication;
-     Ipopt::SmartPtr<IpoptApplication> app = new IpoptApplication();
-
-     // turn off any printing
-     app->Options()->SetIntegerValue("print_level", 0);
-     app->Options()->SetStringValue("sb", "yes");
-
-     // maximum number of iterations
-     app->Options()->SetIntegerValue("max_iter", 30);
-
-     // approximate accuracy in first order necessary conditions;
-     // see Mathematical Programming, Volume 106, Number 1,
-     // Pages 25-57, Equation (6)
-     app->Options()->SetNumericValue("tol", 1e-9);
-
-     // Derivative testing is very slow for large problems
-     // so comment this out if you use a large value for N[].
-     app->Options()-> SetStringValue( "derivative_test", "second-order");
-     app->Options()-> SetNumericValue( "point_perturbation_radius", 0.);
-
-     // Initialize the application and process the options
-     Ipopt::ApplicationReturnStatus status = app->Initialize();
-     ok    &= status == Ipopt::Solve_Succeeded;
-
-     // Run the application
-     status = app->OptimizeTNLP(cppad_nlp);
-     ok    &= status == Ipopt::Solve_Succeeded;
-
-     // return the solution
-     x.resize( solution.x.size() );
-     for(j = 0; j < x.size(); j++)
-          x[j] = solution.x[j];
-
-     return;
-}
-} // END empty namespace ----------------------------------------------------
-
-
Input File: cppad_ipopt/example/ode_run.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_nlp_ode_run.hpp_xml.js cppad-2019.02.00.0/doc/_ipopt_nlp_ode_run.hpp_xml.js --- cppad-2018.00.00.0/doc/_ipopt_nlp_ode_run.hpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_nlp_ode_run.hpp_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', -'deprecated.xml', -'cppad_ipopt_nlp.xml', -'ipopt_nlp_ode.xml', -'ipopt_nlp_ode_run.hpp.xml' -]; -var list_down3 = [ -'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', -'autotools.xml' -]; -var list_down2 = [ -'ipopt_nlp_get_started.cpp.xml', -'ipopt_nlp_ode.xml', -'ipopt_ode_speed.cpp.xml' -]; -var list_down1 = [ -'ipopt_nlp_ode_problem.xml', -'ipopt_nlp_ode_simple.xml', -'ipopt_nlp_ode_fast.xml', -'ipopt_nlp_ode_run.hpp.xml', -'ipopt_nlp_ode_check.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-2018.00.00.0/doc/ipopt_nlp_ode_simple.hpp.xml cppad-2019.02.00.0/doc/ipopt_nlp_ode_simple.hpp.xml --- cppad-2018.00.00.0/doc/ipopt_nlp_ode_simple.hpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_nlp_ode_simple.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,174 +0,0 @@ - - - -ODE Fitting Using Simple Representation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ipopt_nlp_ode_simple.hppHeadings

-
ODE Fitting Using Simple Representation
-
# include "ode_problem.hpp"
-
-// define in the empty namespace
-namespace {
-     using namespace cppad_ipopt;
-
-     class FG_simple : public cppad_ipopt_fg_info
-     {
-     private:
-          bool       retape_;
-          SizeVector N_;
-          SizeVector S_;
-     public:
-          // derived class part of constructor
-          FG_simple(bool retape_in, const SizeVector& N)
-          : retape_ (retape_in), N_(N)
-          {     assert( N_[0] == 0 );
-               S_.resize( N.size() );
-               S_[0] = 0;
-               for(size_t i = 1; i < N_.size(); i++)
-                    S_[i] = S_[i-1] + N_[i];
-          }
-          // Evaluation of the objective f(x), and constraints g(x)
-          // using an Algorithmic Differentiation (AD) class.
-          ADVector eval_r(size_t not_used, const ADVector&  x)
-          {     count_eval_r();
-
-               // temporary indices
-               size_t i, j, k;
-               // # of components of x corresponding to values for y
-               size_t ny_inx = (S_[Nz] + 1) * Ny;
-               // # of constraints (range dimension of g)
-               size_t m = ny_inx;
-               // # of components in x (domain dimension for f and g)
-               assert ( x.size() == ny_inx + Na );
-               // vector for return value
-               ADVector fg(m + 1);
-               // vector of parameters
-               ADVector a(Na);
-               for(j = 0; j < Na; j++)
-                    a[j] = x[ny_inx + j];
-               // vector for value of y(t)
-               ADVector y(Ny);
-               // objective function -------------------------------
-               fg[0] = 0.;
-               for(k = 0; k < Nz; k++)
-               {     for(j = 0; j < Ny; j++)
-                         y[j] = x[Ny*S_[k+1] + j];
-                    fg[0] += eval_H<ADNumber>(k+1, y, a);
-               }
-               // initial condition ---------------------------------
-               ADVector F = eval_F(a);
-               for(j = 0; j < Ny; j++)
-               {     y[j]    = x[j];
-                    fg[1+j] = y[j] - F[j];
-               }
-               // trapezoidal approximation --------------------------
-               ADVector ym(Ny), G(Ny), Gm(Ny);
-               G = eval_G(y, a);
-               ADNumber dy;
-               for(k = 0; k < Nz; k++)
-               {     // interval between data points
-                    Number T  = s[k+1] - s[k];
-                    // integration step size
-                    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
-                         ym = y;
-                         // G(y, a) at end of last step
-                         Gm = G;
-                         // value of y(t) at end of this step
-                         for(i = 0; i < Ny; i++)
-                              y[i] = x[Ny + Index + i];
-                         // G(y, a) at end of this step
-                         G = eval_G(y, a);
-                         // trapezoidal approximation residual
-                         for(i = 0; i < Ny; i++)
-                         {     dy = (G[i] + Gm[i]) * dt / 2;
-                              fg[1+Ny+Index+i] =
-                                   y[i] - ym[i] - dy;
-                         }
-                    }
-               }
-               return fg;
-          }
-          // The operations sequence for r_eval does not depend on u,
-          // hence retape = false should work and be faster.
-          bool retape(size_t k)
-          {     return retape_; }
-     };
-
-}
-
-
Input File: cppad_ipopt/example/ode_simple.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_nlp_ode_simple.hpp_xml.js cppad-2019.02.00.0/doc/_ipopt_nlp_ode_simple.hpp_xml.js --- cppad-2018.00.00.0/doc/_ipopt_nlp_ode_simple.hpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_nlp_ode_simple.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'cppad_ipopt_nlp.xml', -'ipopt_nlp_ode.xml', -'ipopt_nlp_ode_simple.xml', -'ipopt_nlp_ode_simple.hpp.xml' -]; -var list_down3 = [ -'ipopt_nlp_get_started.cpp.xml', -'ipopt_nlp_ode.xml', -'ipopt_ode_speed.cpp.xml' -]; -var list_down2 = [ -'ipopt_nlp_ode_problem.xml', -'ipopt_nlp_ode_simple.xml', -'ipopt_nlp_ode_fast.xml', -'ipopt_nlp_ode_run.hpp.xml', -'ipopt_nlp_ode_check.cpp.xml' -]; -var list_down1 = [ -'ipopt_nlp_ode_simple.hpp.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-2018.00.00.0/doc/ipopt_nlp_ode_simple.xml cppad-2019.02.00.0/doc/ipopt_nlp_ode_simple.xml --- cppad-2018.00.00.0/doc/ipopt_nlp_ode_simple.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_nlp_ode_simple.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,461 +0,0 @@ - - - -ODE Fitting Using Simple Representation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
ODE Fitting Using Simple Representation
-
-Purpose -
-In this section we represent the objective and constraint functions, -(in the simultaneous forward and reverse optimization problem) -using the simple representation - -in the sense of cppad_ipopt_nlp. - -
-
-Argument Vector -
-The argument vector that we are optimizing with respect to -( - -x - - - in cppad_ipopt_nlp - ) -has the following structure - - -x -= -( -y -0 - -, - -, -y -S -( -Nz -) - - -, -a -) - - -Note that - -x - -R - -S -( -Nz -) -+ -Na - - - - - and - - - -y -i - - -= - -( -x -Ny -* -i - - -, - -, -x -Ny -* -i -+ -Ny -- -1 - - -) - -a - -= - -( -x -Ny -* -S -( -Nz -) -+ -Ny - - -, - -, -x -Ny -* -S -( -Nz -) -+ -Na -- -1 - - -) - - - -
-Objective Function -
-The objective function -( - -fg -0 - -( -x -) - - - in cppad_ipopt_nlp - ) -has the following representation, - - -fg -0 - -( -x -) -= - -i -= -1 - -Nz - - -H -i - -( -y -S -( -i -) - - -, -a -) - - -
-Initial Condition Constraint -
-For - -i -= -1 -, - -, -Ny - - -, -we define the component functions - -fg -i - -( -x -) - - -, -and corresponding constraint equations, by - - -0 -= -fg -i - -( -x -) -= -y -i -0 - -- -F -i - -( -a -) - - -
-Trapezoidal Approximation Constraint -
-For - -i -= -1 -, - -, -S -( -Nz -) - - -, -and for - -j -= -1 -, - -, -Ny - - -, -we define the component functions - -fg -Ny -* -i -+ -j - - -( -x -) - - -, -and corresponding constraint equations, by - - -0 -= -fg -Ny -* -i -+ -j - - -= -y -j -i - - -- -y -j -i --1 - - -- -[G -j - -( -y -i - -, -a -) -+ -G -j - -( -y -i --1 - - -, -a -) -] -* -t -i - -- -t -i --1 - - - -2 - - - - -
-Source -
-The file ipopt_nlp_ode_simple.hpp - -contains source code for this representation of the -objective and constraints. - - -
Input File: cppad_ipopt/example/ode2.omh - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_nlp_ode_simple_xml.js cppad-2019.02.00.0/doc/_ipopt_nlp_ode_simple_xml.js --- cppad-2018.00.00.0/doc/_ipopt_nlp_ode_simple_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_nlp_ode_simple_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', -'deprecated.xml', -'cppad_ipopt_nlp.xml', -'ipopt_nlp_ode.xml', -'ipopt_nlp_ode_simple.xml' -]; -var list_down3 = [ -'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', -'autotools.xml' -]; -var list_down2 = [ -'ipopt_nlp_get_started.cpp.xml', -'ipopt_nlp_ode.xml', -'ipopt_ode_speed.cpp.xml' -]; -var list_down1 = [ -'ipopt_nlp_ode_problem.xml', -'ipopt_nlp_ode_simple.xml', -'ipopt_nlp_ode_fast.xml', -'ipopt_nlp_ode_run.hpp.xml', -'ipopt_nlp_ode_check.cpp.xml' -]; -var list_down0 = [ -'ipopt_nlp_ode_simple.hpp.xml' -]; -var list_current0 = [ -'ipopt_nlp_ode_simple.xml#Purpose', -'ipopt_nlp_ode_simple.xml#Argument Vector', -'ipopt_nlp_ode_simple.xml#Objective Function', -'ipopt_nlp_ode_simple.xml#Initial Condition Constraint', -'ipopt_nlp_ode_simple.xml#Trapezoidal Approximation Constraint', -'ipopt_nlp_ode_simple.xml#Source' -]; -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-2018.00.00.0/doc/ipopt_nlp_ode.xml cppad-2019.02.00.0/doc/ipopt_nlp_ode.xml --- cppad-2018.00.00.0/doc/ipopt_nlp_ode.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_nlp_ode.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ - - - -Example Simultaneous Solution of Forward and Inverse Problem - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Example Simultaneous Solution of Forward and Inverse Problem
-
-Contents -
- -
Input File: cppad_ipopt/example/ode1.omh - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_nlp_ode_xml.js cppad-2019.02.00.0/doc/_ipopt_nlp_ode_xml.js --- cppad-2018.00.00.0/doc/_ipopt_nlp_ode_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_nlp_ode_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'cppad_ipopt_nlp.xml', -'ipopt_nlp_ode.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'ipopt_nlp_get_started.cpp.xml', -'ipopt_nlp_ode.xml', -'ipopt_ode_speed.cpp.xml' -]; -var list_down0 = [ -'ipopt_nlp_ode_problem.xml', -'ipopt_nlp_ode_simple.xml', -'ipopt_nlp_ode_fast.xml', -'ipopt_nlp_ode_run.hpp.xml', -'ipopt_nlp_ode_check.cpp.xml' -]; -var list_current0 = [ -'ipopt_nlp_ode.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-2018.00.00.0/doc/ipopt_ode_speed.cpp.xml cppad-2019.02.00.0/doc/ipopt_ode_speed.cpp.xml --- cppad-2018.00.00.0/doc/ipopt_ode_speed.cpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_ode_speed.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ - - - -Speed Test for Both Simple and Fast Representations - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ipopt_ode_speed.cppHeadings

-
Speed Test for Both Simple and Fast Representations
-
# include "../example/ode_run.hpp"
-# include "../example/ode_simple.hpp"
-# include "../example/ode_fast.hpp"
-# include <cassert>
-# include <cstring>
-
-# if CPPAD_HAS_GETTIMEOFDAY & CPPAD_NO_MICROSOFT
-# include <sys/time.h>
-# else
-# include <ctime>
-# endif
-
-namespace {
-     double current_second(void)
-     {
-# if CPPAD_HAS_GETTIMEOFDAY & CPPAD_NOT_MICOROSOFT
-          struct timeval value;
-          gettimeofday(&value, 0);
-          return double(value.tv_sec) + double(value.tv_usec) * 1e-6;
-# else
-          return (double) clock() / (double) CLOCKS_PER_SEC;
-# endif
-     }
-}
-
-double ode_speed(const char* name, size_t& count)
-{
-     // determine simple and retape flags
-     bool simple = true, retape = true;
-     if( std::strcmp(name, "simple_retape_no") == 0 )
-     {     simple = true; retape = false; }
-     else if( std::strcmp(name, "simple_retape_yes") == 0 )
-     {     simple = true; retape = true; }
-     else if( std::strcmp(name, "fast_retape_no") == 0 )
-     {     simple = false; retape = false; }
-     else if( std::strcmp(name, "fast_retape_yes") == 0 )
-     {     simple = false; retape = true; }
-     else     assert(false);
-
-     size_t i;
-        double s0, s1;
-     size_t  c0, c1;
-
-     // solution vector
-     NumberVector x;
-
-     // number of time grid intervals between measurement values
-     SizeVector N(Nz + 1);
-     N[0] = 0;
-     for(i = 1; i <= Nz; i++)
-     {     N[i] = 10;
-          // n   += N[i] * Ny;
-     }
-     // n += Na;
-
-     s0              = current_second();
-     c0              = count_eval_r();
-     if( simple )
-          ipopt_ode_case<FG_simple>(retape, N, x);
-     else     ipopt_ode_case<FG_fast>(retape, N, x);
-     s1              = current_second();
-     c1              = count_eval_r();
-     count           = c1 - c0 - 1;
-     return s1 - s0;
-}
-
-
Input File: cppad_ipopt/speed/ode_speed.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_ode_speed.cpp_xml.js cppad-2019.02.00.0/doc/_ipopt_ode_speed.cpp_xml.js --- cppad-2018.00.00.0/doc/_ipopt_ode_speed.cpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_ode_speed.cpp_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', -'appendix.xml', -'deprecated.xml', -'cppad_ipopt_nlp.xml', -'ipopt_ode_speed.cpp.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'ipopt_nlp_get_started.cpp.xml', -'ipopt_nlp_ode.xml', -'ipopt_ode_speed.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-2018.00.00.0/doc/ipopt_prefix.xml cppad-2019.02.00.0/doc/ipopt_prefix.xml --- cppad-2018.00.00.0/doc/ipopt_prefix.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_prefix.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,173 +0,0 @@ - - - -Including the cppad_ipopt Library and Tests - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - -
Including the cppad_ipopt Library and Tests
-
-Purpose -
-Includes the cppad_ipopt_nlp - -example and tests as well as installing the cppad_ipopt library -during the make install step. - - -
-
-ipopt_prefix -
-If you have -Ipopt - -installed on your system, you can -specify the value for -ipopt_prefix - on the -cmake - command line. -The value of -ipopt_prefix - must be such that, -for one of the directories -dir - in -cmake_install_includedirs -, - -
-     
ipopt_prefix/dir/coin/IpIpoptApplication.hpp
-
-is a valid way to reference to the include file -IpIpoptApplication.hpp. - -
-
-Examples and Tests -
-If you include -ipopt_prefix - on the cmake - command line, -you will be able to run the Ipopt examples and tests -by executing the following commands starting in the -distribution directory -: - -
-     cd cppad_ipopt
-     make check_ipopt
-
-
-get_ipopt -
-If you are using Unix, you can download and install -a copy of Ipopt using get_ipopt.sh -. -The corresponding -ipopt_prefix - would be -build/prefix. - - -
Input File: omh/install/ipopt_prefix.omh - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_prefix_xml.js cppad-2019.02.00.0/doc/_ipopt_prefix_xml.js --- cppad-2018.00.00.0/doc/_ipopt_prefix_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_prefix_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'ipopt_prefix.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 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.xml' -]; -var list_down1 = [ -'adolc_prefix.xml', -'colpack_prefix.xml', -'eigen_prefix.xml', -'fadbad_prefix.xml', -'ipopt_prefix.xml', -'sacado_prefix.xml', -'cppad_testvector.xml' -]; -var list_down0 = [ -'get_ipopt.sh.xml' -]; -var list_current0 = [ -'ipopt_prefix.xml#Purpose', -'ipopt_prefix.xml#ipopt_prefix', -'ipopt_prefix.xml#Examples and Tests', -'ipopt_prefix.xml#get_ipopt' -]; -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-2018.00.00.0/doc/ipopt_solve_get_started.cpp.xml cppad-2019.02.00.0/doc/ipopt_solve_get_started.cpp.xml --- cppad-2018.00.00.0/doc/ipopt_solve_get_started.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_solve_get_started.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,310 +0,0 @@ - - - -Nonlinear Programming Using CppAD and Ipopt: Example and Test - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -ipopt_solve_get_started.cpp - -

- - - -
Nonlinear Programming Using CppAD and Ipopt: Example and Test
-
-Purpose -
-This example program demonstrates how to use ipopt_solve - to -solve the example problem in the Ipopt documentation; i.e., the problem - - - -minimize - - - -x -1 - -* -x -4 - -* -( -x -1 - -+ -x -2 - -+ -x -3 - -) -+ -x -3 - - -subject - -to - - - -x -1 - -* -x -2 - -* -x -3 - -* -x -4 - - -25 - - -x -1 -2 - -+ -x -2 -2 - -+ -x -3 -2 - -+ -x -4 -2 - -= -40 - - -1 - -x -1 - -, -x -2 - -, -x -3 - -, -x -4 - - -5 - - - -
-Configuration Requirement -
-This example will be compiled and tested provided that -ipopt_prefix - is specified on the cmake - command line. - - -
# include <cppad/ipopt/solve.hpp>
-
-namespace {
-     using CppAD::AD;
-
-     class FG_eval {
-     public:
-          typedef CPPAD_TESTVECTOR( AD<double> ) ADvector;
-          void operator()(ADvector& fg, const ADvector& x)
-          {     assert( fg.size() == 3 );
-               assert( x.size()  == 4 );
-
-               // Fortran style indexing
-               AD<double> x1 = x[0];
-               AD<double> x2 = x[1];
-               AD<double> x3 = x[2];
-               AD<double> x4 = x[3];
-               // f(x)
-               fg[0] = x1 * x4 * (x1 + x2 + x3) + x3;
-               // g_1 (x)
-               fg[1] = x1 * x2 * x3 * x4;
-               // g_2 (x)
-               fg[2] = x1 * x1 + x2 * x2 + x3 * x3 + x4 * x4;
-               //
-               return;
-          }
-     };
-}
-
-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;
-     // number of constraints (range dimension for g)
-     size_t ng = 2;
-     // initial value of the independent variables
-     Dvector xi(nx);
-     xi[0] = 1.0;
-     xi[1] = 5.0;
-     xi[2] = 5.0;
-     xi[3] = 1.0;
-     // lower and upper limits for x
-     Dvector xl(nx), xu(nx);
-     for(i = 0; i < nx; i++)
-     {     xl[i] = 1.0;
-          xu[i] = 5.0;
-     }
-     // 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;
-
-     // object that computes objective and constraints
-     FG_eval fg_eval;
-
-     // options
-     std::string options;
-     // turn off any printing
-     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,
-     // 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.,
-     // when evaluation finite diff
-     options += "Numeric point_perturbation_radius  0.\n";
-
-     // place to return solution
-     CppAD::ipopt::solve_result<Dvector> solution;
-
-     // solve the problem
-     CppAD::ipopt::solve<Dvector, FG_eval>(
-          options, xi, xl, xu, gl, gu, fg_eval, solution
-     );
-     //
-     // Check some of the solution values
-     //
-     ok &= solution.status == CppAD::ipopt::solve_result<Dvector>::success;
-     //
-     double check_x[]  = { 1.000000, 4.743000, 3.82115, 1.379408 };
-     double check_zl[] = { 1.087871, 0.,       0.,      0.       };
-     double check_zu[] = { 0.,       0.,       0.,      0.       };
-     double rel_tol    = 1e-6;  // relative tolerance
-     double abs_tol    = 1e-6;  // absolute tolerance
-     for(i = 0; i < nx; i++)
-     {     ok &= CppAD::NearEqual(
-               check_x[i],  solution.x[i],   rel_tol, abs_tol
-          );
-          ok &= CppAD::NearEqual(
-               check_zl[i], solution.zl[i], rel_tol, abs_tol
-          );
-          ok &= CppAD::NearEqual(
-               check_zu[i], solution.zu[i], rel_tol, abs_tol
-          );
-     }
-
-     return ok;
-}
-
-
Input File: example/ipopt_solve/get_started.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_solve_get_started.cpp_xml.js cppad-2019.02.00.0/doc/_ipopt_solve_get_started.cpp_xml.js --- cppad-2018.00.00.0/doc/_ipopt_solve_get_started.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_solve_get_started.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ipopt_solve.xml', -'ipopt_solve_get_started.cpp.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 = [ -'ipopt_solve_get_started.cpp.xml', -'ipopt_solve_retape.cpp.xml', -'ipopt_solve_ode_inverse.cpp.xml' -]; -var list_current0 = [ -'ipopt_solve_get_started.cpp.xml#Purpose', -'ipopt_solve_get_started.cpp.xml#Configuration Requirement' -]; -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-2018.00.00.0/doc/ipopt_solve_ode_inverse.cpp.xml cppad-2019.02.00.0/doc/ipopt_solve_ode_inverse.cpp.xml --- cppad-2018.00.00.0/doc/ipopt_solve_ode_inverse.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_solve_ode_inverse.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1411 +0,0 @@ - - - -ODE Inverse Problem Definitions: Source Code - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -ipopt_solve_ode_inverse.cpp - -

-
ODE Inverse Problem Definitions: Source Code
-
-Purpose -
-This example demonstrates how to invert for parameters -in a ODE where the solution of the ODE is numerically approximated. - -
-
-Forward Problem -
-We consider the following ordinary differential equation: - - - - -t - -y -0 - -( -t -, -a -) - -= - -- -a -1 - -* -y -0 - -( -t -, -a -) - - -t - -y -1 - -( -t -, -a -) - -= - -+ -a -1 - -* -y -0 - -( -t -, -a -) -- -a -2 - -* -y -1 - -( -t -, -a -) - - - -with the initial conditions - - -y -0 - -( -0 -, -a -) -= -( -a -0 - -, -0 -) -T - - - - -Our forward problem is stated as follows: -Given - -a - -R - -3 - - - - -determine the value of - -y -( -t -, -a -) - - -, -for - -t - -R - - -, that solves the initial value problem above. - -
-
-Measurements -
-Suppose we are also given measurement times - -s - -R - -5 - - - - -and a measurement vector - -z - -R - -4 - - - - -and for - -i -= -0 -, - -, -3 - - -, we model - -z -i - - - - by - - -z -i - -= -y -1 - -( -s -i -+ -1 - - -, -a -) -+ -e -i - - - -where - -e -i --1 - - - -N - -( -0 -, -σ -2 - -) - - - -is the measurement noise, -and - -σ -> -0 - - - is the standard deviation of the noise. - -
-
-Simulation Analytic Solution -
-The following analytic solution to the forward problem is used -to simulate a data set: - - - -y -0 - -( -t -, -a -) - -= - -a -0 - -* -exp -( -- -a -1 - -* -t -) - -y -1 - -( -t -, -a -) - -= - -a -0 - -* -a -1 - -* -exp -( -- -a -2 - -* -t -) -- -exp -( -- -a -1 - -* -t -) - -a -1 - -- -a -2 - - - - - - -
-Simulation Parameter Values - - -
- - - -a - -¯ -0 - -= -1 - - -   - - initial value of - -y -0 - -( -t -, -a -) - - - -
- - - -a - -¯ -1 - -= -2 - - -   - - transfer rate from compartment zero to compartment one -
- - - -a - -¯ -2 - -= -1 - - -   - - transfer rate from compartment one to outside world -
- - - -σ -= -0 - - -   - - standard deviation of measurement noise -
- - - -e -i - -= -0 - - -   - - simulated measurement noise, - -i -= -1 -, - -, -Nz - - - -
- - - -s -i - -= -i -* -.5 - - -   - - time corresponding to the i-th measurement, - - -i -= -0 -, - -, -3 - - - -
-
-Simulated Measurement Values -
-The simulated measurement values are given by the equation - - - -z -i - - -= - -e -i - -+ -y -1 - -( -s -i -+ -1 - - -, -a - -¯ -) - - -= - -a - -¯ -0 - -* -a - -¯ -1 - -* -exp -( -- -a - -¯ -2 - -* -s -i - -) -- -exp -( -- -a - -¯ -1 - -* -s -i - -) - -a - -¯ -1 - -- -a - -¯ -2 - - - - - - -for - -i -= -0 -, - -, -3 - - -. - - -
-
-Inverse Problem -
-The maximum likelihood estimate for - -a - - - given - -z - - - -solves the following optimization problem - - - -minimize - - - - -i -= -0 - -3 - -( -z -i - -- -y -1 - -( -s -i -+ -1 - - -, -a -) -) -2 - - - -w -. -r -. -t - - -a - -R - -3 - - - - -
-Trapezoidal Approximation -
-We are given a number of approximation points per measurement interval - - -np - - - and define the time grid - -t - -R - -4 -· -np -+ -1 - - - - - -as follows: - - -t -0 - -= -s -0 - - - - and -for - -i -= -0 -, -1 -, -2 -, -3 - - -, - -j -= -1 -, - -, -np - - - - - -t -i -· -np -+ -j - - -= -s -i - -+ -( -s -i -+ -1 - - -- -s -i - -) -i - -np - - - - -We note that for - -i -= -1 -, - -, -4 - - -, - - -t -i -· -np - - -= -s -i - - - -. -This example uses a trapezoidal approximation to solve the ODE. -Given - -a - -R - -3 - - - - and - -y -k --1 - - - -y -( -t -k --1 - - -, -a -) - - -, -the a trapezoidal method approximates - -y -( -t -j - -, -a -) - - - -by the value - -y -k - - -R - -2 - - - - ) that solves the equation - - -y -k - -= -y -k --1 - - -+ -G -( -y -k - -, -a -) -+ -G -( -y -k --1 - - -, -a -) - -2 - - -* -( -t -k - -- -t -k --1 - - -) - - -where - -G -: -R - -2 - -× -R - -3 - - -R - -2 - - - - is defined by - - - -G -0 - -( -y -, -a -) - -= - -- -a -1 - -* -y -0 - - -G -1 - -( -y -, -a -) - -= - -+ -a -1 - -* -y -0 - -- -a -2 - -* -y -1 - - - - -
-Solution Method -
-We use constraints to embed the -forward problem in the inverse problem. -To be specific, we solve the optimization problem - - - -minimize - - - -i -= -0 - -3 - -( -z -i - -- -y -1 -( -i -+ -1 -) -· -np - - -) -2 - - - -w -. -r -. -t - - -a - -R - -3 - - -y -0 - - -R - -2 - -, - -, -y -3 -· -np --1 - - - -R - -2 - - -subject - -to - -0 -= -y -0 - -- -( -a -0 - -, -0 -) -T - - - - -0 -= -y -k - -- -y -k --1 - - -- -G -( -y -k - -, -a -) -+ -G -( -y -k --1 - - -, -a -) - -2 - - -( -t -k - -- -t -k --1 - - -) - - -for - - -k -= -1 -, - -, -4 -· -np - - - -The code below we using the notation - - -x - -3 -+ -( -4 -· -np -+ -1 -) -· -2 - - - - defined by - - -x -= -(a -0 - -, -a -1 - -, -a -2 - -, -y -0 -0 - -, -y -1 -0 - -, - -, -y -0 -4 -· -np - - -, -y -1 -4 - -np - - -) - - -
-Source -
-The following source code -implements the ODE inversion method proposed above: - -
# include <cppad/ipopt/solve.hpp>
-
-namespace {
-     using CppAD::AD;
-
-     // 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]);
-
-     // function used to simulate data
-     double yone(double t)
-     {     return
-               a_[0]*a_[1] * (exp(-a_[2]*t) - exp(-a_[1]*t)) / (a_[1] - a_[2]);
-     }
-
-     // time points were we have data (no data at first point)
-     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])};
-     size_t nz_  = sizeof(z_) / sizeof(z_[0]);
-
-     // number of trapozoidal approximation points per measurement interval
-     size_t np_  = 40;
-
-
-     class FG_eval
-     {
-     private:
-     public:
-          // derived class part of constructor
-          typedef CPPAD_TESTVECTOR( AD<double> ) ADvector;
-
-          // Evaluation of the objective f(x), and constraints g(x)
-          void operator()(ADvector& fg, const ADvector& x)
-          {     CPPAD_TESTVECTOR( AD<double> ) a(na_);
-               size_t i, j, k;
-
-               // extract the vector a
-               for(i = 0; i < na_; i++)
-                    a[i] = x[i];
-
-               // compute the object f(x)
-               fg[0] = 0.0;
-               for(i = 0; i < nz_; i++)
-               {     k = (i + 1) * np_;
-                    AD<double> y_1 = x[na_ + 2 * k + 1];
-                    AD<double> 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
-               fg[1] = x[na_+0] - a[0];
-               fg[2] = x[na_+1] - 0.0;
-
-               // constraints corresponding to trapozoidal approximation
-               for(i = 0; i < nz_; i++)
-               {     // spacing between grid point
-                    double dt = (s_[i+1] - s_[i]) / static_cast<double>(np_);
-                    for(j = 1; j <= np_; j++)
-                    {     k = i * np_ + j;
-                         // compute derivative at y^k
-                         AD<double> y_0  = x[na_ + 2 * k + 0];
-                         AD<double> y_1  = x[na_ + 2 * k + 1];
-                         AD<double> G_0  = - a[1] * y_0;
-                         AD<double> G_1  = + a[1] * y_0 - a[2] * y_1;
-
-                         // compute derivative at y^{k-1}
-                         AD<double> ym_0  = x[na_ + 2 * (k-1) + 0];
-                         AD<double> ym_1  = x[na_ + 2 * (k-1) + 1];
-                         AD<double> Gm_0  = - a[1] * ym_0;
-                         AD<double> Gm_1  = + a[1] * ym_0 - a[2] * ym_1;
-
-                         // constraint should be zero
-                         fg[1 + 2*k ] = y_0  - ym_0 - dt*(G_0 + Gm_0)/2.;
-                         fg[2 + 2*k ] = y_1  - ym_1 - dt*(G_1 + Gm_1)/2.;
-
-                         // scale g(x) so it has similar size as f(x)
-                         fg[1 + 2*k ] /= dt;
-                         fg[2 + 2*k ] /= dt;
-                    }
-               }
-          }
-     };
-}
-bool ode_inverse(void)
-{     bool ok = true;
-     size_t i;
-     typedef CPPAD_TESTVECTOR( double ) Dvector;
-
-     // number of components in the function g
-     size_t ng = (np_ * nz_ + 1) * 2;
-     // number of independent variables
-     size_t nx = na_ + ng;
-     // initial vlaue for the variables we are optimizing w.r.t
-     Dvector xi(nx), xl(nx), xu(nx);
-     for(i = 0; i < nx; i++)
-     {     xi[i] =   0.0; // initial value
-          xl[i] = -1e19; // no lower limit
-          xu[i] = +1e19; // no upper limit
-     }
-     for(i = 0; i < na_; i++)
-          xi[0] = 1.5;   // initial value for a
-
-     // all the difference equations are constrainted to be zero
-     Dvector gl(ng), gu(ng);
-     for(i = 0; i < ng; i++)
-     {     gl[i] = 0.0;
-          gu[i] = 0.0;
-     }
-     // object defining both f(x) and g(x)
-     FG_eval fg_eval;
-
-     // 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 += "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,
-     // Pages 25-57, Equation (6)
-     options += "Numeric tol         1e-6\n";
-
-     // place to return solution
-     CppAD::ipopt::solve_result<Dvector> solution;
-
-     // solve the problem
-     CppAD::ipopt::solve<Dvector, FG_eval>(
-          options, xi, xl, xu, gl, gu, fg_eval, solution
-     );
-     //
-     // Check some of the solution values
-     //
-     ok &= solution.status == CppAD::ipopt::solve_result<Dvector>::success;
-     //
-     double rel_tol    = 1e-4;  // relative tolerance
-     double abs_tol    = 1e-4;  // absolute tolerance
-     for(i = 0; i < na_; i++)
-          ok &= CppAD::NearEqual( a_[i],  solution.x[i],   rel_tol, abs_tol);
-
-     return ok;
-}
-
-
Input File: example/ipopt_solve/ode_inverse.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_solve_ode_inverse.cpp_xml.js cppad-2019.02.00.0/doc/_ipopt_solve_ode_inverse.cpp_xml.js --- cppad-2018.00.00.0/doc/_ipopt_solve_ode_inverse.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_solve_ode_inverse.cpp_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', -'ipopt_solve.xml', -'ipopt_solve_ode_inverse.cpp.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 = [ -'ipopt_solve_get_started.cpp.xml', -'ipopt_solve_retape.cpp.xml', -'ipopt_solve_ode_inverse.cpp.xml' -]; -var list_current0 = [ -'ipopt_solve_ode_inverse.cpp.xml#Purpose', -'ipopt_solve_ode_inverse.cpp.xml#Forward Problem', -'ipopt_solve_ode_inverse.cpp.xml#Measurements', -'ipopt_solve_ode_inverse.cpp.xml#Measurements.Simulation Analytic Solution', -'ipopt_solve_ode_inverse.cpp.xml#Measurements.Simulation Parameter Values', -'ipopt_solve_ode_inverse.cpp.xml#Measurements.Simulated Measurement Values', -'ipopt_solve_ode_inverse.cpp.xml#Inverse Problem', -'ipopt_solve_ode_inverse.cpp.xml#Trapezoidal Approximation', -'ipopt_solve_ode_inverse.cpp.xml#Solution Method', -'ipopt_solve_ode_inverse.cpp.xml#Source' -]; -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-2018.00.00.0/doc/ipopt_solve_retape.cpp.xml cppad-2019.02.00.0/doc/ipopt_solve_retape.cpp.xml --- cppad-2018.00.00.0/doc/ipopt_solve_retape.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_solve_retape.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ - - - -Nonlinear Programming Retaping: Example and Test - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -ipopt_solve_retape.cpp - -

-
Nonlinear Programming Retaping: Example and Test
-
-Purpose -
-This example program demonstrates a case were the ipopt::solve -argument retape - should be true. - - -
# include <cppad/ipopt/solve.hpp>
-
-namespace {
-     using CppAD::AD;
-
-     class FG_eval {
-     public:
-          typedef CPPAD_TESTVECTOR( AD<double> ) ADvector;
-          void operator()(ADvector& fg, const ADvector& x)
-          {     assert( fg.size() == 1 );
-               assert( x.size()  == 1 );
-
-               // compute the Huber function using a conditional
-               // statement that depends on the value of x.
-               double eps = 0.1;
-               if( fabs(x[0]) <= eps )
-                    fg[0] = x[0] * x[0] / (2.0 * eps);
-               else
-                    fg[0] = fabs(x[0]) - eps / 2.0;
-
-               return;
-          }
-     };
-}
-
-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;
-     // number of constraints (range dimension for g)
-     size_t ng = 0;
-     // initial value, lower and upper limits, for the independent variables
-     Dvector xi(nx), xl(nx), xu(nx);
-     xi[0] = 2.0;
-     xl[0] = -1e+19;
-     xu[0] = +1e+19;
-     // lower and upper limits for g
-     Dvector gl(ng), gu(ng);
-
-     // object that computes objective and constraints
-     FG_eval fg_eval;
-
-     // 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 += "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,
-     // 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.,
-     // when evaluation finite diff
-     options += "Numeric point_perturbation_radius  0.\n";
-
-     // place to return solution
-     CppAD::ipopt::solve_result<Dvector> solution;
-
-     // solve the problem
-     CppAD::ipopt::solve<Dvector, FG_eval>(
-          options, xi, xl, xu, gl, gu, fg_eval, solution
-     );
-     //
-     // Check some of the solution values
-     //
-     ok &= solution.status == CppAD::ipopt::solve_result<Dvector>::success;
-     double rel_tol    = 1e-6;  // relative tolerance
-     double abs_tol    = 1e-6;  // absolute tolerance
-     ok &= CppAD::NearEqual( solution.x[0], 0.0,  rel_tol, abs_tol);
-
-     return ok;
-}
-
-
Input File: example/ipopt_solve/retape.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_solve_retape.cpp_xml.js cppad-2019.02.00.0/doc/_ipopt_solve_retape.cpp_xml.js --- cppad-2018.00.00.0/doc/_ipopt_solve_retape.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_solve_retape.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ipopt_solve.xml', -'ipopt_solve_retape.cpp.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 = [ -'ipopt_solve_get_started.cpp.xml', -'ipopt_solve_retape.cpp.xml', -'ipopt_solve_ode_inverse.cpp.xml' -]; -var list_current0 = [ -'ipopt_solve_retape.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_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-2018.00.00.0/doc/ipopt_solve.xml cppad-2019.02.00.0/doc/ipopt_solve.xml --- cppad-2018.00.00.0/doc/ipopt_solve.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ipopt_solve.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,817 +0,0 @@ - - - -Use Ipopt to Solve a Nonlinear Programming Problem - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -

-
Use Ipopt to Solve a Nonlinear Programming Problem
-
-Syntax - -
- -# include <cppad/ipopt/solve.hpp>
-
- -ipopt::solve(
-     
optionsxixlxuglgufg_evalsolution
-)
- - -
-
-Purpose -
-The function ipopt::solve solves nonlinear programming -problems of the form - - - -minimize - - -f -( -x -) - -subject - -to - - -gl - -g -( -x -) - -gu - - -xl - -x - -xu - - - -This is done using -Ipopt - -optimizer and CppAD for the derivative and sparsity calculations. - -
-
-Include File -
-Currently, this routine -ipopt::solve - is not included by the command - -
-     # include <cppad/cppad.hpp>
-
-(Doing so would require the ipopt library to link -the corresponding program (even if ipopt::solve) was not used.) -For this reason, -if you are using ipopt::solve you should use - -
-     # include <cppad/ipopt/solve.hpp>
-
-which in turn will also include <cppad/cppad.hpp>. - -
-
-Bvector -
-The type -Bvector - must be a SimpleVector - class with -elements of type - -bool. - -
-
-Dvector -
-The type -DVector - must be a SimpleVector - class with -elements of type - -double. - -
-
-options -
-The argument -options - has prototype - -
-     const std::string 
options
-
-It contains a list of options. -Each option, including the last option, -is terminated by the '\n' character. -Each line consists of two or three tokens separated by one or more spaces. - -
-
-Retape -
-You can set the retape flag with the following syntax: - -
-     Retape 
value
-
-If the value is true, ipopt::solve with retape the -operation sequence - for each -new value of -x -. -If the value is false, ipopt::solve -will tape the operation sequence at the value -of -xi - and use that sequence for the entire optimization process. -The default value is false. - -
-
-Sparse -
-You can set the sparse Jacobian and Hessian flag with the following syntax: - -
-     Sparse 
value direction
-
-If the value is true, ipopt::solve will use a sparse -matrix representation for the computation of Jacobians and Hessians. -Otherwise, it will use a full matrix representation for -these calculations. -The default for -value - is false. -If sparse is true, retape must be false. -
-
-
It is unclear if sparse_jacobian - would be faster user -forward or reverse mode so you are able to choose the direction. -If - -
-     
value == true && direction == forward
-
-the Jacobians will be calculated using SparseJacobianForward. -If - -
-     
value == true && direction == reverse
-
-the Jacobians will be calculated using SparseJacobianReverse. - -
-
-String -
-You can set any Ipopt string option using a line with the following syntax: - -
-     String 
name value
-
-Here -name - is any valid Ipopt string option -and -value - is its setting. - -
-
-Numeric -
-You can set any Ipopt numeric option using a line with the following syntax: - -
-     Numeric 
name value
-
-Here -name - is any valid Ipopt numeric option -and -value - is its setting. - -
-
-Integer -
-You can set any Ipopt integer option using a line with the following syntax: - -
-     Integer 
name value
-
-Here -name - is any valid Ipopt integer option -and -value - is its setting. - -
-
-xi -
-The argument -xi - has prototype - -
-     const 
Vectorxi
-
-and its size is equal to -nx -. -It specifies the initial point where Ipopt starts the optimization process. - -
-
-xl -
-The argument -xl - has prototype - -
-     const 
Vectorxl
-
-and its size is equal to -nx -. -It specifies the lower limits for the argument in the optimization problem. - -
-
-xu -
-The argument -xu - has prototype - -
-     const 
Vectorxu
-
-and its size is equal to -nx -. -It specifies the upper limits for the argument in the optimization problem. - -
-
-gl -
-The argument -gl - has prototype - -
-     const 
Vectorgl
-
-and its size is equal to -ng -. -It specifies the lower limits for the constraints in the optimization problem. - -
-
-gu -
-The argument -gu - has prototype - -
-     const 
Vectorgu
-
-and its size is equal to -ng -. -It specifies the upper limits for the constraints in the optimization problem. - -
-
-fg_eval -
-The argument -fg_eval - has prototype - -
-     
FG_eval fg_eval
-
-where the class -FG_eval - is unspecified except for the fact that -it supports the syntax - -
-     
FG_eval::ADvector
-     
fg_eval(fgx)
-
-The type -ADvector - -and the arguments to -fg -, -x - have the following meaning: - -
-
-ADvector -
-The type -FG_eval::ADvector - must be a SimpleVector - class with -elements of type - -AD<double>. - -
-
-x -
-The -fg_eval - argument -x - has prototype - -
-     const 
ADvectorx
-
-where -nx = x.size() -. - -
-
-fg -
-The -fg_eval - argument -fg - has prototype - -
-     
ADvectorfg
-
-where -1 + ng = fg.size() -. -The input value of the elements of -fg - does not matter. -Upon return from -fg_eval -, - -
-     
fg[0] =
- - -f -( -x -) - - - -
-
-and for - -i -= -0 -, - -, -ng --1 - - -, - -
-     
fg[1 + i] =
- - -g -i - -( -x -) - - - - -
-
-solution -
-The argument -solution - has prototype - -
-     ipopt::solve_result<
Dvector>& solution
-
-After the optimization process is completed, -solution - contains -the following information: - -
-
-status -
-The -status - field of -solution - has prototype - -
-     ipopt::solve_result<
Dvector>::status_type solution.status
-
-It is the final Ipopt status for the optimizer. -Here is a list of the possible values for the status: - - -
- - -status - - Meaning -
- -not_defined - -The optimizer did not return a final status for this problem. -
- -unknown - -The status returned by the optimizer is not defined in the Ipopt -documentation for finalize_solution. -
- -success - -Algorithm terminated successfully at a point satisfying the convergence -tolerances (see Ipopt options). -
- -maxiter_exceeded - -The maximum number of iterations was exceeded (see Ipopt options). -
- -stop_at_tiny_step - -Algorithm terminated because progress was very slow. -
- -stop_at_acceptable_point - -Algorithm stopped at a point that was converged, -not to the 'desired' tolerances, but to 'acceptable' tolerances -(see Ipopt options). -
- -local_infeasibility - -Algorithm converged to a non-feasible point -(problem may have no solution). -
- -user_requested_stop - -This return value should not happen. -
- -diverging_iterates - -It the iterates are diverging. -
- -restoration_failure - -Restoration phase failed, algorithm doesn't know how to proceed. -
- -error_in_step_computation - -An unrecoverable error occurred while Ipopt tried to -compute the search direction. -
- -invalid_number_detected - -Algorithm received an invalid number (such as nan or inf) -from the users function -fg_info.eval - or from the CppAD evaluations -of its derivatives -(see the Ipopt option check_derivatives_for_naninf). -
- -internal_error - -An unknown Ipopt internal error occurred. -Contact the Ipopt authors through the mailing list. -
-
-x -
-The x field of -solution - has prototype - -
-     
Vector solution.x
-
-and its size is equal to -nx -. -It is the final - -x - - - value for the optimizer. - -
-
-zl -
-The zl field of -solution - has prototype - -
-     
Vector solution.zl
-
-and its size is equal to -nx -. -It is the final Lagrange multipliers for the -lower bounds on - -x - - -. - -
-
-zu -
-The zu field of -solution - has prototype - -
-     
Vector solution.zu
-
-and its size is equal to -nx -. -It is the final Lagrange multipliers for the -upper bounds on - -x - - -. - -
-
-g -
-The g field of -solution - has prototype - -
-     
Vector solution.g
-
-and its size is equal to -ng -. -It is the final value for the constraint function - -g -( -x -) - - -. - -
-
-lambda -
-The lambda field of -solution - has prototype - -
-     
Vectorsolution.lambda
-
-and its size is equal to -ng -. -It is the final value for the -Lagrange multipliers corresponding to the constraint function. - -
-
-obj_value -
-The obj_value field of -solution - has prototype - -
-     double 
solution.obj_value
-
-It is the final value of the objective function - -f -( -x -) - - -. - - -
-
-Example -
-All the examples return true if it succeeds and false otherwise. - -
-
-get_started -
-The file -example/ipopt_solve/get_started.cpp - -is an example and test of ipopt::solve -taken from the Ipopt manual. - -
-
-retape -
-The file -example/ipopt_solve/retape.cpp - -demonstrates when it is necessary to specify -retape - as true. - -
-
-ode_inverse -
-The file -example/ipopt_solve/ode_inverse.cpp - -demonstrates using Ipopt to solve for parameters in an ODE model. - - -
Input File: cppad/ipopt/solve.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ipopt_solve_xml.js cppad-2019.02.00.0/doc/_ipopt_solve_xml.js --- cppad-2018.00.00.0/doc/_ipopt_solve_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ipopt_solve_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', -'ipopt_solve.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 = [ -'ipopt_solve_get_started.cpp.xml', -'ipopt_solve_retape.cpp.xml', -'ipopt_solve_ode_inverse.cpp.xml' -]; -var list_current0 = [ -'ipopt_solve.xml#Syntax', -'ipopt_solve.xml#Purpose', -'ipopt_solve.xml#Include File', -'ipopt_solve.xml#Bvector', -'ipopt_solve.xml#Dvector', -'ipopt_solve.xml#options', -'ipopt_solve.xml#options.Retape', -'ipopt_solve.xml#options.Sparse', -'ipopt_solve.xml#options.String', -'ipopt_solve.xml#options.Numeric', -'ipopt_solve.xml#options.Integer', -'ipopt_solve.xml#xi', -'ipopt_solve.xml#xl', -'ipopt_solve.xml#xu', -'ipopt_solve.xml#gl', -'ipopt_solve.xml#gu', -'ipopt_solve.xml#fg_eval', -'ipopt_solve.xml#fg_eval.ADvector', -'ipopt_solve.xml#fg_eval.x', -'ipopt_solve.xml#fg_eval.fg', -'ipopt_solve.xml#solution', -'ipopt_solve.xml#solution.status', -'ipopt_solve.xml#solution.x', -'ipopt_solve.xml#solution.zl', -'ipopt_solve.xml#solution.zu', -'ipopt_solve.xml#solution.g', -'ipopt_solve.xml#solution.lambda', -'ipopt_solve.xml#solution.obj_value', -'ipopt_solve.xml#Example', -'ipopt_solve.xml#Example.get_started', -'ipopt_solve.xml#Example.retape', -'ipopt_solve.xml#Example.ode_inverse' -]; -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-2018.00.00.0/doc/jac_lu_det.cpp.xml cppad-2019.02.00.0/doc/jac_lu_det.cpp.xml --- cppad-2018.00.00.0/doc/jac_lu_det.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/jac_lu_det.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,164 +0,0 @@ - - - -Gradient of Determinant Using Lu Factorization: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -jac_lu_det.cppHeadings

-
Gradient of Determinant Using Lu Factorization: Example and Test
-
// Complex examples should supppress conversion warnings
-# include <cppad/wno_conversion.hpp>
-
-# include <cppad/cppad.hpp>
-# include <cppad/speed/det_by_lu.hpp>
-
-// The AD complex case is used by this example so must
-// define a specializatgion of LeqZero,AbsGeq for the AD<Complex> case
-namespace CppAD {
-     CPPAD_BOOL_BINARY( std::complex<double> ,  AbsGeq   )
-     CPPAD_BOOL_UNARY(  std::complex<double> ,  LeqZero )
-}
-
-bool JacLuDet(void)
-{     bool ok = true;
-     using namespace CppAD;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     typedef std::complex<double> Complex;
-     typedef AD<Complex>          ADComplex;
-
-     size_t n = 2;
-
-     // object for computing determinants
-     det_by_lu<ADComplex> Det(n);
-
-     // independent and dependent variable vectors
-     CPPAD_TESTVECTOR(ADComplex)  X(n * n);
-     CPPAD_TESTVECTOR(ADComplex)  D(1);
-
-     // value of the independent variable
-     size_t i;
-     for(i = 0; i < n * n; i++)
-          X[i] = Complex(int(i), -int(i));
-
-     // set the independent variables
-     Independent(X);
-
-     // compute the determinant
-     D[0]  = Det(X);
-
-     // create the function object
-     ADFun<Complex> f(X, D);
-
-     // argument value
-     CPPAD_TESTVECTOR(Complex)     x( n * n );
-     for(i = 0; i < n * n; i++)
-          x[i] = Complex(2 * i, i);
-
-     // first derivative of the determinant
-     CPPAD_TESTVECTOR(Complex) J( n * n );
-     J = f.Jacobian(x);
-
-     /*
-     f(x)     = x[0] * x[3] - x[1] * x[2]
-     */
-     Complex Jtrue[]  = { x[3], -x[2], -x[1], x[0] };
-     for( i = 0; i < n*n; i++)
-          ok &= NearEqual( Jtrue[i], J[i], eps99 , eps99 );
-
-     return ok;
-}
-
-
-
Input File: example/general/jac_lu_det.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_jac_lu_det.cpp_xml.js cppad-2019.02.00.0/doc/_jac_lu_det.cpp_xml.js --- cppad-2018.00.00.0/doc/_jac_lu_det.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_jac_lu_det.cpp_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', -'example.xml', -'general.xml', -'jac_lu_det.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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' -]; -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-2018.00.00.0/doc/jac_minor_det.cpp.xml cppad-2019.02.00.0/doc/jac_minor_det.cpp.xml --- cppad-2018.00.00.0/doc/jac_minor_det.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/jac_minor_det.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,164 +0,0 @@ - - - -Gradient of Determinant Using Expansion by Minors: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -jac_minor_det.cppHeadings

-
Gradient of Determinant Using Expansion by Minors: Example and Test
-
// Complex examples should supppress conversion warnings
-# include <cppad/wno_conversion.hpp>
-
-# include <cppad/cppad.hpp>
-# include <cppad/speed/det_by_minor.hpp>
-# include <complex>
-
-
-typedef std::complex<double>     Complex;
-typedef CppAD::AD<Complex>       ADComplex;
-typedef CPPAD_TESTVECTOR(ADComplex)   ADVector;
-
-// ----------------------------------------------------------------------------
-
-bool JacMinorDet(void)
-{     bool ok = true;
-
-     using namespace CppAD;
-
-     size_t n = 2;
-
-     // object for computing determinant
-     det_by_minor<ADComplex> Det(n);
-
-     // independent and dependent variable vectors
-     CPPAD_TESTVECTOR(ADComplex)  X(n * n);
-     CPPAD_TESTVECTOR(ADComplex)  D(1);
-
-     // value of the independent variable
-     size_t i;
-     for(i = 0; i < n * n; i++)
-          X[i] = Complex(int(i), -int(i));
-
-     // set the independent variables
-     Independent(X);
-
-     // comupute the determinant
-     D[0] = Det(X);
-
-     // create the function object
-     ADFun<Complex> f(X, D);
-
-     // argument value
-     CPPAD_TESTVECTOR(Complex)     x( n * n );
-     for(i = 0; i < n * n; i++)
-          x[i] = Complex(2 * i, i);
-
-     // first derivative of the determinant
-     CPPAD_TESTVECTOR(Complex) J( n * n );
-     J = f.Jacobian(x);
-
-     /*
-     f(x)     = x[0] * x[3] - x[1] * x[2]
-     f'(x)    = ( x[3], -x[2], -x[1], x[0] )
-     */
-     Complex Jtrue[] = { x[3], -x[2], -x[1], x[0] };
-     for(i = 0; i < n * n; i++)
-          ok &= Jtrue[i] == J[i];
-
-     return ok;
-
-}
-
-
-
Input File: example/general/jac_minor_det.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_jac_minor_det.cpp_xml.js cppad-2019.02.00.0/doc/_jac_minor_det.cpp_xml.js --- cppad-2018.00.00.0/doc/_jac_minor_det.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_jac_minor_det.cpp_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', -'example.xml', -'general.xml', -'jac_minor_det.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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' -]; -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-2018.00.00.0/doc/jacobian.cpp.xml cppad-2019.02.00.0/doc/jacobian.cpp.xml --- cppad-2018.00.00.0/doc/jacobian.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/jacobian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ - - - -Jacobian: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -jacobian.cppHeadings

- - - -
Jacobian: Example and Test
-

-# include <cppad/cppad.hpp>
-namespace { // ---------------------------------------------------------
-// define the template function JacobianCases<Vector> in empty namespace
-template <typename Vector>
-bool JacobianCases()
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     using CppAD::exp;
-     using CppAD::sin;
-     using CppAD::cos;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>)  X(n);
-     X[0] = 1.;
-     X[1] = 2.;
-
-     // declare independent variables and starting recording
-     CppAD::Independent(X);
-
-     // a calculation between the domain and range values
-     AD<double> Square = X[0] * X[0];
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>)  Y(m);
-     Y[0] = Square * exp( X[1] );
-     Y[1] = Square * sin( X[1] );
-     Y[2] = Square * cos( X[1] );
-
-     // create f: X -> Y and stop tape recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // new value for the independent variable vector
-     Vector x(n);
-     x[0] = 2.;
-     x[1] = 1.;
-
-     // compute the derivative at this x
-     Vector jac( m * n );
-     jac = f.Jacobian(x);
-
-     /*
-     F'(x) = [ 2 * x[0] * exp(x[1]) ,  x[0] * x[0] * exp(x[1]) ]
-             [ 2 * x[0] * sin(x[1]) ,  x[0] * x[0] * cos(x[1]) ]
-             [ 2 * x[0] * cos(x[1]) , -x[0] * x[0] * sin(x[i]) ]
-     */
-     ok &=  NearEqual( 2.*x[0]*exp(x[1]), jac[0*n+0], eps99, eps99);
-     ok &=  NearEqual( 2.*x[0]*sin(x[1]), jac[1*n+0], eps99, eps99);
-     ok &=  NearEqual( 2.*x[0]*cos(x[1]), jac[2*n+0], eps99, eps99);
-
-     ok &=  NearEqual( x[0] * x[0] *exp(x[1]), jac[0*n+1], eps99, eps99);
-     ok &=  NearEqual( x[0] * x[0] *cos(x[1]), jac[1*n+1], eps99, eps99);
-     ok &=  NearEqual(-x[0] * x[0] *sin(x[1]), jac[2*n+1], eps99, eps99);
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool Jacobian(void)
-{     bool ok = true;
-     // Run with Vector equal to three different cases
-     // all of which are Simple Vectors with elements of type double.
-     ok &= JacobianCases< CppAD::vector  <double> >();
-     ok &= JacobianCases< std::vector    <double> >();
-     ok &= JacobianCases< std::valarray  <double> >();
-     return ok;
-}
-
-
Input File: example/general/jacobian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_jacobian.cpp_xml.js cppad-2019.02.00.0/doc/_jacobian.cpp_xml.js --- cppad-2018.00.00.0/doc/_jacobian.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_jacobian.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'jacobian.xml', -'jacobian.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down1 = [ -'jacobian.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-2018.00.00.0/doc/jacobian.xml cppad-2019.02.00.0/doc/jacobian.xml --- cppad-2018.00.00.0/doc/jacobian.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/jacobian.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,340 +0,0 @@ - - - -Jacobian: Driver Routine - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Jacobian: Driver Routine
-
-Syntax - -
- -jac = f.Jacobian(x) - - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -The syntax above sets -jac - to the -Jacobian of -F - evaluated at -x -; i.e., - - -jac -= -F -( -1 -) - - -( -x -) - - -
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const -(see Forward or Reverse - below). - -
-
-x -
-The argument -x - has prototype - -
-     const 
Vector &x
-
-(see Vector - below) -and its size -must be equal to -n -, the dimension of the -domain - space for -f -. -It specifies -that point at which to evaluate the Jacobian. - -
-
-jac -
-The result -jac - has prototype - -
-     
Vector jac
-
-(see Vector - below) -and its size is - -m -* -n - - -; i.e., the product of the -domain - -and -range - -dimensions for -f -. -For - -i -= -0 -, - -, -m -- -1 - - - -and - -j -= -0 -, - -, -n -- -1 - - - - - -. -jac -[ -i -* -n -+ -j -] -= - -F -i - - - -x -j - - - -( -x -) - - -
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Forward or Reverse -
-This will use order zero Forward mode and either -order one Forward or order one Reverse to compute the Jacobian -(depending on which it estimates will require less work). -After each call to Forward -, -the object -f - contains the corresponding -Taylor coefficients -. -After a call to Jacobian, -the zero order Taylor coefficients correspond to - -f.Forward(0, x) - -and the other coefficients are unspecified. - -
-
-Example - -
-The routine -Jacobian - is both an example and test. -It returns true, if it succeeds and false otherwise. - - -
Input File: cppad/core/jacobian.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_jacobian_xml.js cppad-2019.02.00.0/doc/_jacobian_xml.js --- cppad-2018.00.00.0/doc/_jacobian_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_jacobian_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'jacobian.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down0 = [ -'jacobian.cpp.xml' -]; -var list_current0 = [ -'jacobian.xml#Syntax', -'jacobian.xml#Purpose', -'jacobian.xml#f', -'jacobian.xml#x', -'jacobian.xml#jac', -'jacobian.xml#Vector', -'jacobian.xml#Forward or Reverse', -'jacobian.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-2018.00.00.0/doc/license.xml cppad-2019.02.00.0/doc/license.xml --- cppad-2018.00.00.0/doc/license.xml 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/license.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,766 +0,0 @@ - - - -Your License for the CppAD Software - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -LicenseHeadings

- - - -
Your License for the CppAD Software
-
-
-
                    GNU GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-                            Preamble
-
-  The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
-  The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works.  By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.  We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors.  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
-  To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights.  Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received.  You must make sure that they, too, receive
-or can get the source code.  And you must show them these terms so they
-know their rights.
-
-  Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
-  For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software.  For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
-  Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so.  This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software.  The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable.  Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products.  If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
-  Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary.  To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-                       TERMS AND CONDITIONS
-
-  0. Definitions.
-
-  "This License" refers to version 3 of the GNU General Public License.
-
-  "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
-  "The Program" refers to any copyrightable work licensed under this
-License.  Each licensee is addressed as "you".  "Licensees" and
-"recipients" may be individuals or organizations.
-
-  To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy.  The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
-  A "covered work" means either the unmodified Program or a work based
-on the Program.
-
-  To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy.  Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
-  To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies.  Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
-  An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License.  If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
-  1. Source Code.
-
-  The "source code" for a work means the preferred form of the work
-for making modifications to it.  "Object code" means any non-source
-form of a work.
-
-  A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
-  The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form.  A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
-  The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities.  However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work.  For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
-  The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
-  The Corresponding Source for a work in source code form is that
-same work.
-
-  2. Basic Permissions.
-
-  All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met.  This License explicitly affirms your unlimited
-permission to run the unmodified Program.  The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work.  This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
-  You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force.  You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright.  Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
-  Conveying under any other circumstances is permitted solely under
-the conditions stated below.  Sublicensing is not allowed; section 10
-makes it unnecessary.
-
-  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
-  No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
-  When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
-  4. Conveying Verbatim Copies.
-
-  You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
-  You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
-  5. Conveying Modified Source Versions.
-
-  You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
-    a) The work must carry prominent notices stating that you modified
-    it, and giving a relevant date.
-
-    b) The work must carry prominent notices stating that it is
-    released under this License and any conditions added under section
-    7.  This requirement modifies the requirement in section 4 to
-    "keep intact all notices".
-
-    c) You must license the entire work, as a whole, under this
-    License to anyone who comes into possession of a copy.  This
-    License will therefore apply, along with any applicable section 7
-    additional terms, to the whole of the work, and all its parts,
-    regardless of how they are packaged.  This License gives no
-    permission to license the work in any other way, but it does not
-    invalidate such permission if you have separately received it.
-
-    d) If the work has interactive user interfaces, each must display
-    Appropriate Legal Notices; however, if the Program has interactive
-    interfaces that do not display Appropriate Legal Notices, your
-    work need not make them do so.
-
-  A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit.  Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
-  6. Conveying Non-Source Forms.
-
-  You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
-    a) Convey the object code in, or embodied in, a physical product
-    (including a physical distribution medium), accompanied by the
-    Corresponding Source fixed on a durable physical medium
-    customarily used for software interchange.
-
-    b) Convey the object code in, or embodied in, a physical product
-    (including a physical distribution medium), accompanied by a
-    written offer, valid for at least three years and valid for as
-    long as you offer spare parts or customer support for that product
-    model, to give anyone who possesses the object code either (1) a
-    copy of the Corresponding Source for all the software in the
-    product that is covered by this License, on a durable physical
-    medium customarily used for software interchange, for a price no
-    more than your reasonable cost of physically performing this
-    conveying of source, or (2) access to copy the
-    Corresponding Source from a network server at no charge.
-
-    c) Convey individual copies of the object code with a copy of the
-    written offer to provide the Corresponding Source.  This
-    alternative is allowed only occasionally and noncommercially, and
-    only if you received the object code with such an offer, in accord
-    with subsection 6b.
-
-    d) Convey the object code by offering access from a designated
-    place (gratis or for a charge), and offer equivalent access to the
-    Corresponding Source in the same way through the same place at no
-    further charge.  You need not require recipients to copy the
-    Corresponding Source along with the object code.  If the place to
-    copy the object code is a network server, the Corresponding Source
-    may be on a different server (operated by you or a third party)
-    that supports equivalent copying facilities, provided you maintain
-    clear directions next to the object code saying where to find the
-    Corresponding Source.  Regardless of what server hosts the
-    Corresponding Source, you remain obligated to ensure that it is
-    available for as long as needed to satisfy these requirements.
-
-    e) Convey the object code using peer-to-peer transmission, provided
-    you inform other peers where the object code and Corresponding
-    Source of the work are being offered to the general public at no
-    charge under subsection 6d.
-
-  A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
-  A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling.  In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage.  For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product.  A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
-  "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source.  The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
-  If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information.  But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
-  The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed.  Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
-  Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
-  7. Additional Terms.
-
-  "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law.  If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
-  When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it.  (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.)  You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
-  Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
-    a) Disclaiming warranty or limiting liability differently from the
-    terms of sections 15 and 16 of this License; or
-
-    b) Requiring preservation of specified reasonable legal notices or
-    author attributions in that material or in the Appropriate Legal
-    Notices displayed by works containing it; or
-
-    c) Prohibiting misrepresentation of the origin of that material, or
-    requiring that modified versions of such material be marked in
-    reasonable ways as different from the original version; or
-
-    d) Limiting the use for publicity purposes of names of licensors or
-    authors of the material; or
-
-    e) Declining to grant rights under trademark law for use of some
-    trade names, trademarks, or service marks; or
-
-    f) Requiring indemnification of licensors and authors of that
-    material by anyone who conveys the material (or modified versions of
-    it) with contractual assumptions of liability to the recipient, for
-    any liability that these contractual assumptions directly impose on
-    those licensors and authors.
-
-  All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10.  If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term.  If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
-  If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
-  Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
-  8. Termination.
-
-  You may not propagate or modify a covered work except as expressly
-provided under this License.  Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
-  However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
-  Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
-  Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License.  If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
-  9. Acceptance Not Required for Having Copies.
-
-  You are not required to accept this License in order to receive or
-run a copy of the Program.  Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance.  However,
-nothing other than this License grants you permission to propagate or
-modify any covered work.  These actions infringe copyright if you do
-not accept this License.  Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
-  10. Automatic Licensing of Downstream Recipients.
-
-  Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License.  You are not responsible
-for enforcing compliance by third parties with this License.
-
-  An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations.  If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
-  You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License.  For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
-  11. Patents.
-
-  A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based.  The
-work thus licensed is called the contributor's "contributor version".
-
-  A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version.  For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
-  Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
-  In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement).  To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
-  If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients.  "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
-  If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
-  A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License.  You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
-  Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
-  12. No Surrender of Others' Freedom.
-
-  If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all.  For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
-  13. Use with the GNU Affero General Public License.
-
-  Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work.  The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
-  14. Revised Versions of this License.
-
-  The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-  Each version is given a distinguishing version number.  If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation.  If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
-  If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
-  Later license versions may give you additional or different
-permissions.  However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
-  15. Disclaimer of Warranty.
-
-  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. Limitation of Liability.
-
-  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
-  17. Interpretation of Sections 15 and 16.
-
-  If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
-                     END OF TERMS AND CONDITIONS
-
-            How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    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 3 of the License, 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 <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
-  If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
-    <program>  Copyright (C) <year>  <name of author>
-    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
-  You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
-  The GNU General Public License does not permit incorporating your program
-into proprietary programs.  If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.  But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
-

-
-
Input File: omh/appendix/license.omh - - - diff -Nru cppad-2018.00.00.0/doc/_license_xml.js cppad-2019.02.00.0/doc/_license_xml.js --- cppad-2018.00.00.0/doc/_license_xml.js 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/_license_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'license.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', -'directory.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' -]; -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-2018.00.00.0/doc/link_det_lu.xml cppad-2019.02.00.0/doc/link_det_lu.xml --- cppad-2018.00.00.0/doc/link_det_lu.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/link_det_lu.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,207 +0,0 @@ - - - -Speed Testing Gradient of Determinant Using Lu Factorization - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -link_det_lu - -

-
Speed Testing Gradient of Determinant Using Lu Factorization
-
-Prototype - -
- -extern bool link_det_lu(
-     size_t                 
size      ,
-     size_t                 
repeat    ,
-     CppAD::vector<double> &
matrix    ,
-     CppAD::vector<double> &
gradient
-);
-
-
-Purpose -
-Each package - -must define a version of this routine as specified below. -This is used by the speed_main - program -to run the corresponding speed and correctness tests. - -
-
-Method -
-The same template routine det_by_lu - is used -by the different AD packages. - -
-
-Return Value -
-If this speed test is not yet -supported by a particular -package -, -the corresponding return value for link_det_lu -should be false. - -
-
-size -
-The argument -size - -is the number of rows and columns in the matrix. - -
-
-repeat -
-The argument -repeat - is the number of different matrices -that the gradient (or determinant) is computed for. - -
-
-matrix -
-The argument -matrix - is a vector with -size*size - elements. -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. - -
-
-gradient -
-The argument -gradient - is a vector with -size*size - elements. -The input value of its elements does not matter. -The output value of its elements is the gradient of the -determinant of -matrix - with respect to its elements. - -
-
-double -
-In the case where -package - is double, -only the first element of -gradient - is used and it is actually -the determinant value (the gradient value is not computed). - - -
Input File: speed/src/link_det_lu.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_link_det_lu_xml.js cppad-2019.02.00.0/doc/_link_det_lu_xml.js --- cppad-2018.00.00.0/doc/_link_det_lu_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_link_det_lu_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_main.xml', -'link_det_lu.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'link_det_lu.xml', -'link_det_minor.xml', -'link_mat_mul.xml', -'link_ode.xml', -'link_poly.xml', -'link_sparse_hessian.xml', -'link_sparse_jacobian.xml', -'microsoft_timer.xml' -]; -var list_current0 = [ -'link_det_lu.xml#Prototype', -'link_det_lu.xml#Purpose', -'link_det_lu.xml#Method', -'link_det_lu.xml#Return Value', -'link_det_lu.xml#size', -'link_det_lu.xml#repeat', -'link_det_lu.xml#matrix', -'link_det_lu.xml#gradient', -'link_det_lu.xml#gradient.double' -]; -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-2018.00.00.0/doc/link_det_minor.xml cppad-2019.02.00.0/doc/link_det_minor.xml --- cppad-2018.00.00.0/doc/link_det_minor.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/link_det_minor.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,213 +0,0 @@ - - - -Speed Testing Gradient of Determinant by Minor Expansion - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -link_det_minor - -

- - - - -
Speed Testing Gradient of Determinant by Minor Expansion
-
-Prototype - -
- -extern bool link_det_minor(
-     size_t                 
size      ,
-     size_t                 
repeat    ,
-     CppAD::vector<double> &
matrix    ,
-     CppAD::vector<double> &
gradient
-);
-
-
-Purpose -
-Each package - -must define a version of this routine as specified below. -This is used by the speed_main - program -to run the corresponding speed and correctness tests. - -
-
-Method -
-The same template class det_by_minor - -is used by the different AD packages. - -
-
-Return Value -
-If this speed test is not yet -supported by a particular -package -, -the corresponding return value for link_det_minor -should be false. - -
-
-size -
-The argument -size - -is the number of rows and columns in the matrix. - -
-
-repeat -
-The argument -repeat - is the number of different matrices -that the gradient (or determinant) is computed for. - -
-
-matrix -
-The argument -matrix - is a vector with - -size*size - elements. -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. - -
-
-gradient -
-The argument -gradient - is a vector with - -size*size - elements. -The input value of its elements does not matter. -The output value of its elements is the gradient of the -determinant of -matrix - with respect to its elements. - -
-
-double -
-In the case where -package - is double, -only the first element of -gradient - is used and it is actually -the determinant value (the gradient value is not computed). - - -
Input File: speed/src/link_det_minor.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_link_det_minor_xml.js cppad-2019.02.00.0/doc/_link_det_minor_xml.js --- cppad-2018.00.00.0/doc/_link_det_minor_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_link_det_minor_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_main.xml', -'link_det_minor.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'link_det_lu.xml', -'link_det_minor.xml', -'link_mat_mul.xml', -'link_ode.xml', -'link_poly.xml', -'link_sparse_hessian.xml', -'link_sparse_jacobian.xml', -'microsoft_timer.xml' -]; -var list_current0 = [ -'link_det_minor.xml#Prototype', -'link_det_minor.xml#Purpose', -'link_det_minor.xml#Method', -'link_det_minor.xml#Return Value', -'link_det_minor.xml#size', -'link_det_minor.xml#repeat', -'link_det_minor.xml#matrix', -'link_det_minor.xml#gradient', -'link_det_minor.xml#gradient.double' -]; -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-2018.00.00.0/doc/link_mat_mul.xml cppad-2019.02.00.0/doc/link_mat_mul.xml --- cppad-2018.00.00.0/doc/link_mat_mul.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/link_mat_mul.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,302 +0,0 @@ - - - -Speed Testing Derivative of Matrix Multiply - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -link_mat_mul - -

- - - - -
Speed Testing Derivative of Matrix Multiply
-
-Prototype - -
- -extern bool link_mat_mul(
-     size_t                         
size    ,
-     size_t                         
repeat  ,
-     CppAD::vector<double>&         
x       ,
-     CppAD::vector<double>&         
z       ,
-     CppAD::vector<double>&         
dz
-);
-
-
-Purpose -
-Each package - -must define a version of this routine as specified below. -This is used by the speed_main - program -to run the corresponding speed and correctness tests. - -
-
-Return Value -
-If this speed test is not yet -supported by a particular -package -, -the corresponding return value for link_mat_mul -should be false. - -
-
-n -
-The argument -n - is the number of rows and columns -in the square matrix -x -. - -
-
-repeat -
-The argument -repeat - is the number of different argument values -that the derivative of -z - (or just the value of -z -) -will be computed. - -
-
-x -
-The argument -x - is a vector with - -x.size() = size * size - elements. -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 -z -; - - -x -i -, -j - - -= -x -[ -i -* -s -+ -j -] - - -where -s = size -. - -
-
-z -
-The argument -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 - -y = x * x -; i.e., - - - -y -i -, -j - - - -= - - -k -= -0 - -s --1 - - -x -i -, -k - - -x -k -, -j - - - -z - -= - - -i -= -0 - -s --1 - - - -j -= -0 - -s --1 - - -y -i -, -j - - - - - -
-dz -
-The argument -dz - is a vector with - -dz.size() = size * size -. -The input values of its elements do not matter. -The output value of its elements form the -derivative of -z - with respect to -x -. - - -
Input File: speed/src/link_mat_mul.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_link_mat_mul_xml.js cppad-2019.02.00.0/doc/_link_mat_mul_xml.js --- cppad-2018.00.00.0/doc/_link_mat_mul_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_link_mat_mul_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', -'speed.xml', -'speed_main.xml', -'link_mat_mul.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'link_det_lu.xml', -'link_det_minor.xml', -'link_mat_mul.xml', -'link_ode.xml', -'link_poly.xml', -'link_sparse_hessian.xml', -'link_sparse_jacobian.xml', -'microsoft_timer.xml' -]; -var list_current0 = [ -'link_mat_mul.xml#Prototype', -'link_mat_mul.xml#Purpose', -'link_mat_mul.xml#Return Value', -'link_mat_mul.xml#n', -'link_mat_mul.xml#repeat', -'link_mat_mul.xml#x', -'link_mat_mul.xml#z', -'link_mat_mul.xml#dz' -]; -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-2018.00.00.0/doc/link_ode.xml cppad-2019.02.00.0/doc/link_ode.xml --- cppad-2018.00.00.0/doc/link_ode.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/link_ode.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,342 +0,0 @@ - - - -Speed Testing the Jacobian of Ode Solution - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -link_ode - -

- - - - -
Speed Testing the Jacobian of Ode Solution
-
-Prototype - -
- -extern bool link_ode(
-     size_t                 
size      ,
-     size_t                 
repeat    ,
-     CppAD::vector<double> &
x         ,
-     CppAD::vector<double> &
jacobian
-);
-
-
-Purpose -
-Each package - -must define a version of this routine as specified below. -This is used by the speed_main - program -to run the corresponding speed and correctness tests. - -
-
-Method -
-The same template routine ode_evaluate - is used -by th different AD packages. - -
-
-f -
-The function - - -f -: -R - -n - - -R - -n - - - - that is defined and computed by -evaluating ode_evaluate - with a call of the form - -
-     ode_evaluate(
xpfp)
-
-with -p - equal to zero. -Calls with the value -p - equal to one are used to check -the derivative values. - -
-
-Return Value -
-If this speed test is not yet -supported by a particular -package -, -the corresponding return value for link_ode -should be false. - -
-
-size -
-The argument -size - -is the number of variables in the ordinary differential equations -which is also equal to - -n - - -. - -
-
-repeat -
-The argument -repeat - is the number of times the -Jacobian is computed. - -
-
-x -
-The argument -x - is a vector with - -n - - - elements. -The input value of the elements of -x - does not matter. -On output, it has been set to the -argument value for which the function, -or its derivative, is being evaluated. -The value of this vector must change with each repetition. - -
-
-jacobian -
-The argument -jacobian - is a vector with - -n -2 - - - - elements. -The input value of its elements does not matter. -The output value of its elements is the Jacobian of the function - -f -( -x -) - - - -that corresponds to output value of -x -. -To be more specific, for - - -i -= -0 -, - -, -n --1 - - - and - -j -= -0 -, - -, -n --1 - - -, - - - -f -[ -i -] - - -x -[ -j -] - - -( -x -) -= -jacobian -[ -i -· -n -+ -j -] - - -
-double -
-In the case where -package - is double, -only the first - -n - - - element of -jacobian - -are modified and they are to the function value - - -f -( -x -) - - - corresponding to the output value of -x -. - - -
Input File: speed/src/link_ode.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_link_ode_xml.js cppad-2019.02.00.0/doc/_link_ode_xml.js --- cppad-2018.00.00.0/doc/_link_ode_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_link_ode_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_main.xml', -'link_ode.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'link_det_lu.xml', -'link_det_minor.xml', -'link_mat_mul.xml', -'link_ode.xml', -'link_poly.xml', -'link_sparse_hessian.xml', -'link_sparse_jacobian.xml', -'microsoft_timer.xml' -]; -var list_current0 = [ -'link_ode.xml#Prototype', -'link_ode.xml#Purpose', -'link_ode.xml#Method', -'link_ode.xml#f', -'link_ode.xml#Return Value', -'link_ode.xml#size', -'link_ode.xml#repeat', -'link_ode.xml#x', -'link_ode.xml#jacobian', -'link_ode.xml#jacobian.double' -]; -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-2018.00.00.0/doc/link_poly.xml cppad-2019.02.00.0/doc/link_poly.xml --- cppad-2018.00.00.0/doc/link_poly.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/link_poly.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,223 +0,0 @@ - - - -Speed Testing Second Derivative of a Polynomial - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -link_poly - -

- - - - -
Speed Testing Second Derivative of a Polynomial
-
-Prototype - -
- -extern bool link_poly(
-     size_t                 
size    ,
-     size_t                 
repeat  ,
-     CppAD::vector<double> &
a       ,
-     CppAD::vector<double> &
z       ,
-     CppAD::vector<double> &
ddp
-);
-
-
-Purpose -
-Each package - -must define a version of this routine as specified below. -This is used by the speed_main - program -to run the corresponding speed and correctness tests. - -
-
-Method -
-The same template routine Poly - is used -by the different AD packages. - -
-
-Return Value -
-If this speed test is not yet -supported by a particular -package -, -the corresponding return value for link_poly -should be false. - -
-
-size -
-The argument -size - is the order of the polynomial -(the number of coefficients in the polynomial). - -
-
-repeat -
-The argument -repeat - is the number of different argument values -that the second derivative (or just the polynomial) will be computed at. - -
-
-a -
-The argument -a - is a vector with -size - elements. -The input value of its elements does not matter. -The output value of its elements is the coefficients of the -polynomial that is differentiated -(i-th element is coefficient of order -i -). - -
-
-z -
-The argument -z - is a vector with one element. -The input value of the element does not matter. -The output of its element is the polynomial argument value -were the last second derivative (or polynomial value) was computed. - -
-
-ddp -
-The argument -ddp - is a vector with one element. -The input value of its element does not matter. -The output value of its element is the -second derivative of the polynomial with respect to it's argument value. - -
-
-double -
-In the case where -package - is double, -the output value of the element of -ddp - -is the polynomial value (the second derivative is not computed). - - -
Input File: speed/src/link_poly.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_link_poly_xml.js cppad-2019.02.00.0/doc/_link_poly_xml.js --- cppad-2018.00.00.0/doc/_link_poly_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_link_poly_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_main.xml', -'link_poly.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'link_det_lu.xml', -'link_det_minor.xml', -'link_mat_mul.xml', -'link_ode.xml', -'link_poly.xml', -'link_sparse_hessian.xml', -'link_sparse_jacobian.xml', -'microsoft_timer.xml' -]; -var list_current0 = [ -'link_poly.xml#Prototype', -'link_poly.xml#Purpose', -'link_poly.xml#Method', -'link_poly.xml#Return Value', -'link_poly.xml#size', -'link_poly.xml#repeat', -'link_poly.xml#a', -'link_poly.xml#z', -'link_poly.xml#ddp', -'link_poly.xml#ddp.double' -]; -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-2018.00.00.0/doc/link_sparse_hessian.xml cppad-2019.02.00.0/doc/link_sparse_hessian.xml --- cppad-2018.00.00.0/doc/link_sparse_hessian.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/link_sparse_hessian.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,545 +0,0 @@ - - - -Speed Testing Sparse Hessian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -link_sparse_hessian - -

- - - - -
Speed Testing Sparse Hessian
-
-Prototype - -
- -extern bool link_sparse_hessian(
-     size_t                        
size      ,
-     size_t                        
repeat    ,
-     CppAD::vector<double>&        
x         ,
-     const CppAD::vector<size_t>&  
row       ,
-     const CppAD::vector<size_t>&  
col       ,
-     CppAD::vector<double>&        
hessian   ,
-     size_t                        
n_sweep
-);
-
-
-Method -
-Given a row index vector - -row - - - -and a second column vector - -col - - -, -the corresponding function - - -f -: -R - -n - - -R - - - - -is defined by sparse_hes_fun -. -The non-zero entries in the Hessian of this function have -one of the following forms: - - - -2 - -f - - -x -[ -row -[ -k -] -] - -x -[ -row -[ -k -] -] - - - -, - - -2 - -f - - -x -[ -row -[ -k -] -] - -x -[ -col -[ -k -] -] - - - -, - - -2 - -f - - -x -[ -col -[ -k -] -] - -x -[ -row -[ -k -] -] - - - -, - - -2 - -f - - -x -[ -col -[ -k -] -] - -x -[ -col -[ -k -] -] - - - - -for some - -k - - - between zero and - -K --1 - - -. -All the other terms of the Hessian are zero. - -
-
-size -
-The argument -size -, referred to as - -n - - - below, -is the dimension of the domain space for - -f -( -x -) - - -. - -
-
-repeat -
-The argument -repeat - is the number of times -to repeat the test -(with a different value for -x - corresponding to -each repetition). - -
-
-x -
-The argument -x - has prototype - -
-        CppAD::vector<double>& 
x
-
-and its size is - -n - - -; i.e., -x.size() == size -. -The input value of the elements of -x - does not matter. -On output, it has been set to the -argument value for which the function, -or its derivative, is being evaluated. -The value of this vector need not change with each repetition. - -
-
-row -
-The argument -row - has prototype - -
-     const CppAD::vector<size_t> 
row
-
-Its size defines the value - -K - - -. -It contains the row indices for the corresponding function - -f -( -x -) - - -. -All the elements of -row - are between zero and - -n --1 - - -. - -
-
-col -
-The argument -col - has prototype - -
-     const CppAD::vector<size_t> 
col
-
-Its size must be the same as -row -; i.e., - -K - - -. -It contains the column indices for the corresponding function - - -f -( -x -) - - -. -All the elements of -col - are between zero and - -n --1 - - -. -There are no duplicated entries requested, to be specific, -if -k1 != k2 - then - -
-     ( 
row[k1] , col[k1] ) != ( row[k2] , col[k2] )
-
-Furthermore, the entries are lower triangular; i.e., - -
-     
col[k] <= row[k]
-
-. - - -
-
-hessian -
-The argument -hessian - has prototype - -
-     CppAD::vector<double>&  hessian
-
-and its size is -K -. -The input value of its elements does not matter. -The output value of its elements is the Hessian of the function - -f -( -x -) - - -. -To be more specific, for - - -k -= -0 -, - -, -K --1 - - -, - - - -2 - -f - - -x -[ -row - -[ -k -] -] - -x -[ -col - -[ -k -] -] - - -= -hessian - -[ -k -] - - -
-n_sweep -
-The input value of -n_sweep - does not matter. On output, -it is the value n_sweep - corresponding -to the evaluation of -hessian -. -This is also the number of colors corresponding to the -coloring method -, -which can be set to colpack -, -and is otherwise cppad. - - -
-
-double -
-In the case where -package - is double, -only the first element of -hessian - is used and it is actually -the value of - -f -( -x -) - - - (derivatives are not computed). - - -
Input File: speed/src/link_sparse_hessian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_link_sparse_hessian_xml.js cppad-2019.02.00.0/doc/_link_sparse_hessian_xml.js --- cppad-2018.00.00.0/doc/_link_sparse_hessian_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_link_sparse_hessian_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_main.xml', -'link_sparse_hessian.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'link_det_lu.xml', -'link_det_minor.xml', -'link_mat_mul.xml', -'link_ode.xml', -'link_poly.xml', -'link_sparse_hessian.xml', -'link_sparse_jacobian.xml', -'microsoft_timer.xml' -]; -var list_current0 = [ -'link_sparse_hessian.xml#Prototype', -'link_sparse_hessian.xml#Method', -'link_sparse_hessian.xml#size', -'link_sparse_hessian.xml#repeat', -'link_sparse_hessian.xml#x', -'link_sparse_hessian.xml#row', -'link_sparse_hessian.xml#col', -'link_sparse_hessian.xml#hessian', -'link_sparse_hessian.xml#n_sweep', -'link_sparse_hessian.xml#n_sweep.double' -]; -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-2018.00.00.0/doc/link_sparse_jacobian.xml cppad-2019.02.00.0/doc/link_sparse_jacobian.xml --- cppad-2018.00.00.0/doc/link_sparse_jacobian.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/link_sparse_jacobian.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,448 +0,0 @@ - - - -Speed Testing Sparse Jacobian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -link_sparse_jacobian - -

- - - - -
Speed Testing Sparse Jacobian
-
-Prototype - -
- -extern bool link_sparse_jacobian(
-     size_t                       
size      ,
-     size_t                       
repeat    ,
-     size_t                       
m         ,
-     const CppAD::vector<size_t>& 
row       ,
-     const CppAD::vector<size_t>& 
col       ,
-           CppAD::vector<double>& 
x         ,
-           CppAD::vector<double>& 
jacobian  ,
-           size_t&                
n_sweep
-);
-
-
-Method -
-Given a range space dimension -m - -the row index vector - -row - - -, and column index vector - -col - - -, -a corresponding function - -f -: -R - -n - - -R - -m - - - - -is defined by sparse_jac_fun -. -The non-zero entries in the Jacobian of this function have the form - - - -f -[ -row -[ -k -] -] - - -x -[ -col -[ -k -] -] -] - - - - -for some - -k - - - between zero and -K = row.size()-1 -. -All the other terms of the Jacobian are zero. - - -
-
-size -
-The argument -size -, referred to as - -n - - - below, -is the dimension of the domain space for - -f -( -x -) - - -. - -
-
-repeat -
-The argument -repeat - is the number of times -to repeat the test -(with a different value for -x - corresponding to -each repetition). - -
-
-m -
-Is the dimension of the range space for the function - -f -( -x -) - - -. - -
-
-row -
-The size of the vector -row - defines the value - -K - - -. -All the elements of -row - are between zero and - -m --1 - - -. - -
-
-col -
-The argument -col - is a vector with size - -K - - -. -The input value of its elements does not matter. -On output, it has been set the column index vector -for the last repetition. -All the elements of -col - are between zero and - -n --1 - - -. -There are no duplicate row and column entires; i.e., if -j != k -, - -
-     
row[j] != row[k] || col[j] != col[k]
-
-
-x -
-The argument -x - has prototype - -
-        CppAD::vector<double>& 
x
-
-and its size is - -n - - -; i.e., -x.size() == size -. -The input value of the elements of -x - does not matter. -On output, it has been set to the -argument value for which the function, -or its derivative, is being evaluated and placed in -jacobian -. -The value of this vector need not change with each repetition. - -
-
-jacobian -
-The argument -jacobian - has prototype - -
-        CppAD::vector<double>& 
jacobian
-
-and its size is -K -. -The input value of its elements does not matter. -The output value of its elements is the Jacobian of the function - -f -( -x -) - - -. -To be more specific, for - - -k -= -0 -, - -, -K -- -1 - - -, - - - -f -[ -row - -[ -k -] -] - - -x -[ -col - -[ -k -] -] - - -( -x -) -= -jacobian - -[ -k -] - - -
-n_sweep -
-The input value of -n_sweep - does not matter. On output, -it is the value n_sweep - corresponding -to the evaluation of -jacobian -. -This is also the number of colors corresponding to the -coloring method -, -which can be set to colpack -, -and is otherwise cppad. - -
-
-double -
-In the case where -package - is double, -only the first - -m - - - -elements of -jacobian - are used and they are set to -the value of - -f -( -x -) - - -. - - -
Input File: speed/src/link_sparse_jacobian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_link_sparse_jacobian_xml.js cppad-2019.02.00.0/doc/_link_sparse_jacobian_xml.js --- cppad-2018.00.00.0/doc/_link_sparse_jacobian_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_link_sparse_jacobian_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_main.xml', -'link_sparse_jacobian.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'link_det_lu.xml', -'link_det_minor.xml', -'link_mat_mul.xml', -'link_ode.xml', -'link_poly.xml', -'link_sparse_hessian.xml', -'link_sparse_jacobian.xml', -'microsoft_timer.xml' -]; -var list_current0 = [ -'link_sparse_jacobian.xml#Prototype', -'link_sparse_jacobian.xml#Method', -'link_sparse_jacobian.xml#size', -'link_sparse_jacobian.xml#repeat', -'link_sparse_jacobian.xml#m', -'link_sparse_jacobian.xml#row', -'link_sparse_jacobian.xml#col', -'link_sparse_jacobian.xml#x', -'link_sparse_jacobian.xml#jacobian', -'link_sparse_jacobian.xml#n_sweep', -'link_sparse_jacobian.xml#n_sweep.double' -]; -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-2018.00.00.0/doc/listallexamples.xml cppad-2019.02.00.0/doc/listallexamples.xml --- cppad-2018.00.00.0/doc/listallexamples.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/listallexamples.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,809 +0,0 @@ - - - -List All (Except Deprecated) CppAD Examples - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -ListAllExamplesHeadings

-
List All (Except Deprecated) CppAD Examples
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-a11c_bthread.cpp -A Simple Boost Thread Example and Test
-a11c_openmp.cpp -A Simple OpenMP Example and Test
-a11c_pthread.cpp -A Simple Parallel Pthread Example and Test
-abort_recording.cpp -Abort Current Recording: Example and Test
-abs_eval.cpp -abs_eval: Example and Test
-abs_eval.hpp -abs_eval Source Code
-abs_get_started.cpp -abs_normal Getting Started: Example and Test
-abs_min_linear.cpp -abs_min_linear: Example and Test
-abs_min_linear.hpp -abs_min_linear Source Code
-abs_min_quad.cpp -abs_min_quad: Example and Test
-abs_min_quad.hpp -abs_min_quad Source Code
-acos.cpp -The AD acos Function: Example and Test
-acosh.cpp -The AD acosh Function: Example and Test
-ad_assign.cpp -AD Assignment: Example and Test
-ad_ctor.cpp -AD Constructors: Example and Test
-add.cpp -AD Binary Addition: Example and Test
-AddEq.cpp -AD Compound Assignment Addition: Example and Test
-ad_fun.cpp -Creating Your Own Interface to an ADFun Object
-ad_in_c.cpp -Example and Test Linking CppAD to Languages Other than C++
-ad_input.cpp -AD Output Operator: Example and Test
-ad_output.cpp -AD Output Operator: Example and Test
-asin.cpp -The AD asin Function: Example and Test
-asinh.cpp -The AD asinh Function: Example and Test
-atan2.cpp -The AD atan2 Function: Example and Test
-atan.cpp -The AD atan Function: Example and Test
-atanh.cpp -The AD atanh Function: Example and Test
-atomic_eigen_cholesky.cpp -Atomic Eigen Cholesky Factorization: Example and Test
-atomic_eigen_cholesky.hpp -Atomic Eigen Cholesky Factorization Class
-atomic_eigen_mat_inv.cpp -Atomic Eigen Matrix Inverse: Example and Test
-atomic_eigen_mat_inv.hpp -Atomic Eigen Matrix Inversion Class
-atomic_eigen_mat_mul.cpp -Atomic Eigen Matrix Multiply: Example and Test
-atomic_eigen_mat_mul.hpp -Atomic Eigen Matrix Multiply Class
-atomic_for_sparse_hes.cpp -Atomic Forward Hessian Sparsity: Example and Test
-atomic_for_sparse_jac.cpp -Atomic Forward Jacobian Sparsity: Example and Test
-atomic_forward.cpp -Atomic Forward: Example and Test
-atomic_get_started.cpp -Getting Started with Atomic Operations: Example and Test
-atomic_mat_mul.cpp -User Atomic Matrix Multiply: Example and Test
-atomic_mat_mul.hpp -Matrix Multiply as an Atomic Operation
-atomic_mul_level.cpp -Atomic Operations and Multiple-Levels of AD: Example and Test
-atomic_norm_sq.cpp -Atomic Euclidean Norm Squared: Example and Test
-atomic_reciprocal.cpp -Reciprocal as an Atomic Operation: Example and Test
-atomic_reverse.cpp -Atomic Reverse: Example and Test
-atomic_rev_sparse_hes.cpp -Atomic Reverse Hessian Sparsity: Example and Test
-atomic_rev_sparse_jac.cpp -Atomic Reverse Jacobian Sparsity: Example and Test
-atomic_set_sparsity.cpp -Atomic Sparsity with Set Patterns: Example and Test
-atomic_tangent.cpp -Tan and Tanh as User Atomic Operations: Example and Test
-azmul.cpp -AD Absolute Zero Multiplication: Example and Test
-base_adolc.hpp -Enable use of AD<Base> where Base is Adolc's adouble Type
-base_alloc.hpp -Example AD<Base> Where Base Constructor Allocates Memory
-base_complex.hpp -Enable use of AD<Base> where Base is std::complex<double>
-base_require.cpp -Using a User Defined AD Base Type: Example and Test
-bender_quad.cpp -BenderQuad: Example and Test
-bool_fun.cpp -AD Boolean Functions: Example and Test
-capacity_order.cpp -Controlling Taylor Coefficient Memory Allocation: Example and Test
-change_param.cpp -Computing a Jacobian With Constants that Change
-check_for_nan.cpp -ADFun Checking For Nan: Example and Test
-check_numeric_type.cpp -The CheckNumericType Function: Example and Test
-checkpoint.cpp -Simple Checkpointing: Example and Test
-checkpoint_extended_ode.cpp -Checkpointing an Extended ODE Solver: Example and Test
-checkpoint_ode.cpp -Checkpointing an ODE Solver: Example and Test
-check_simple_vector.cpp -The CheckSimpleVector Function: Example and Test
-colpack_hes.cpp -ColPack: Sparse Hessian Example and Test
-colpack_hessian.cpp -ColPack: Sparse Hessian Example and Test
-colpack_jac.cpp -ColPack: Sparse Jacobian Example and Test
-colpack_jacobian.cpp -ColPack: Sparse Jacobian Example and Test
-compare_change.cpp -CompareChange and Re-Tape: Example and Test
-compare.cpp -AD Binary Comparison Operators: Example and Test
-complex_poly.cpp -Complex Polynomial: Example and Test
-cond_exp.cpp -Conditional Expressions: Example and Test
-conj_grad.cpp -Differentiate Conjugate Gradient Algorithm: Example and Test
-cos.cpp -The AD cos Function: Example and Test
-cosh.cpp -The AD cosh Function: Example and Test
-cppad_eigen.hpp -Enable Use of Eigen Linear Algebra Package with CppAD
-cppad_vector.cpp -CppAD::vector Template Class: Example and Test
-dependency.cpp -Computing Dependency: Example and Test
-det_by_lu.cpp -Determinant Using Lu Factorization: Example and Test
-det_by_minor.cpp -Determinant Using Expansion by Minors: Example and Test
-det_of_minor.cpp -Determinant of a Minor: Example and Test
-div.cpp -AD Binary Division: Example and Test
-div_eq.cpp -AD Compound Assignment Division: Example and Test
-eigen_array.cpp -Using Eigen Arrays: Example and Test
-eigen_det.cpp -Using Eigen To Compute Determinant: Example and Test
-elapsed_seconds.cpp -Elapsed Seconds: Example and Test
-equal_op_seq.cpp -EqualOpSeq: Example and Test
-erf.cpp -The AD erf Function: Example and Test
-error_handler.cpp -Replacing The CppAD Error Handler: Example and Test
-exp.cpp -The AD exp Function: Example and Test
-expm1.cpp -The AD exp Function: Example and Test
-expm1.cpp -The AD exp Function: Example and Test
-fabs.cpp -AD Absolute Value Function: Example and Test
-for_hes_sparsity.cpp -Forward Mode Hessian Sparsity: Example and Test
-for_jac_sparsity.cpp -Forward Mode Jacobian Sparsity: Example and Test
-for_one.cpp -First Order Partial Driver: Example and Test
-for_sparse_hes.cpp -Forward Mode Hessian Sparsity: Example and Test
-for_sparse_jac.cpp -Forward Mode Jacobian Sparsity: Example and Test
-for_two.cpp -Subset of Second Order Partials: Example and Test
-forward.cpp -Forward Mode: Example and Test
-forward_dir.cpp -Forward Mode: Example and Test of Multiple Directions
-forward_order.cpp -Forward Mode: Example and Test of Multiple Orders
-fun_assign.cpp -ADFun Assignment: Example and Test
-fun_check.cpp -ADFun Check and Re-Tape: Example and Test
-general.cpp -CppAD Examples and Tests
-get_started.cpp -Getting Started Using CppAD to Compute Derivatives
-harmonic.cpp -Multi-Threading Harmonic Summation Example / Test
-hes_lagrangian.cpp -Hessian of Lagrangian and ADFun Default Constructor: Example and Test
-hes_lu_det.cpp -Gradient of Determinant Using LU Factorization: Example and Test
-hes_minor_det.cpp -Gradient of Determinant Using Expansion by Minors: Example and Test
-hessian.cpp -Hessian: Example and Test
-hes_times_dir.cpp -Hessian Times Direction: Example and Test
-independent.cpp -Independent and ADFun Constructor: Example and Test
-index_sort.cpp -Index Sort: Example and Test
-integer.cpp -Convert From AD to Integer: Example and Test
-interface2c.cpp -Interfacing to C: Example and Test
-interp_onetape.cpp -Interpolation With Out Retaping: Example and Test
-interp_retape.cpp -Interpolation With Retaping: Example and Test
-ipopt_solve_get_started.cpp -Nonlinear Programming Using CppAD and Ipopt: Example and Test
-ipopt_solve_ode_inverse.cpp -ODE Inverse Problem Definitions: Source Code
-ipopt_solve_retape.cpp -Nonlinear Programming Retaping: Example and Test
-jac_lu_det.cpp -Gradient of Determinant Using Lu Factorization: Example and Test
-jac_minor_det.cpp -Gradient of Determinant Using Expansion by Minors: Example and Test
-jacobian.cpp -Jacobian: Example and Test
-log10.cpp -The AD log10 Function: Example and Test
-log1p.cpp -The AD log1p Function: Example and Test
-log.cpp -The AD log Function: Example and Test
-lp_box.cpp -abs_normal lp_box: Example and Test
-lp_box.hpp -lp_box Source Code
-lu_factor.cpp -LuFactor: Example and Test
-lu_invert.cpp -LuInvert: Example and Test
-lu_ratio.cpp -LuRatio: Example and Test
-lu_solve.cpp -LuSolve With Complex Arguments: Example and Test
-lu_vec_ad_ok.cpp -Lu Factor and Solve With Recorded Pivoting: Example and Test
-mat_sum_sq.cpp -Sum of the Elements of the Square of a Matrix: Example and Test
-min_nso_linear.cpp -abs_normal min_nso_linear: Example and Test
-min_nso_linear.hpp -min_nso_linear Source Code
-min_nso_quad.cpp -abs_normal min_nso_quad: Example and Test
-min_nso_quad.hpp -min_nso_quad Source Code
-mul.cpp -AD Binary Multiplication: Example and Test
-mul_eq.cpp -AD Compound Assignment Multiplication: Example and Test
-mul_level_adolc.cpp -Using Adolc with Multiple Levels of Taping: Example and Test
-mul_level_adolc_ode.cpp -Taylor's Ode Solver: A Multi-Level Adolc Example and Test
-mul_level.cpp -Multiple Level of AD: Example and Test
-mul_level_ode.cpp -Taylor's Ode Solver: A Multi-Level AD Example and Test
-multi_atomic.cpp -Multi-Threading User Atomic Example / Test
-multi_newton.cpp -Multi-Threaded Newton Method Example / Test
-nan.cpp -nan: Example and Test
-near_equal.cpp -NearEqual Function: Example and Test
-near_equal_ext.cpp -Compare AD with Base Objects: Example and Test
-number_skip.cpp -Number of Variables That Can be Skipped: Example and Test
-numeric_type.cpp -The NumericType: Example and Test
-num_limits.cpp -Numeric Limits: Example and Test
-ode_err_control.cpp -OdeErrControl: Example and Test
-ode_err_maxabs.cpp -OdeErrControl: Example and Test Using Maxabs Argument
-ode_evaluate.cpp -ode_evaluate: Example and test
-ode_gear_control.cpp -OdeGearControl: Example and Test
-ode_gear.cpp -OdeGear: Example and Test
-ode_stiff.cpp -A Stiff Ode: Example and Test
-ode_taylor.cpp -Taylor's Ode Solver: An Example and Test
-optimize_compare_op.cpp -Example Optimization and Comparison Operators
-optimize_conditional_skip.cpp -Example Optimization and Conditional Expressions
-optimize_cumulative_sum.cpp -Example Optimization and Cumulative Sum Operations
-optimize_forward_active.cpp -Example Optimization and Forward Activity Analysis
-optimize_nest_conditional.cpp -Example Optimization and Nested Conditional Expressions
-optimize_print_for.cpp -Example Optimization and Print Forward Operators
-optimize_reverse_active.cpp -Example Optimization and Reverse Activity Analysis
-opt_val_hes.cpp -opt_val_hes: Example and Test
-par_var.cpp -AD Parameter and Variable Functions: Example and Test
-poly.cpp -Polynomial Evaluation: Example and Test
-pow.cpp -The AD Power Function: Example and Test
-pow_int.cpp -The Pow Integer Exponent: Example and Test
-print_for_cout.cpp -Printing During Forward Mode: Example and Test
-print_for_string.cpp -Print During Zero Order Forward Mode: Example and Test
-qp_box.cpp -abs_normal qp_box: Example and Test
-qp_box.hpp -qp_box Source Code
-qp_interior.cpp -abs_normal qp_interior: Example and Test
-qp_interior.hpp -qp_interior Source Code
-rc_sparsity.cpp -Preferred Sparsity Patterns: Row and Column Indices: Example and Test
-reverse_checkpoint.cpp -Reverse Mode General Case (Checkpointing): Example and Test
-reverse_one.cpp -First Order Reverse Mode: Example and Test
-reverse_three.cpp -Third Order Reverse Mode: Example and Test
-reverse_two.cpp -Second Order Reverse ModeExample and Test
-rev_hes_sparsity.cpp -Reverse Mode Hessian Sparsity: Example and Test
-rev_jac_sparsity.cpp -Reverse Mode Jacobian Sparsity: Example and Test
-rev_one.cpp -First Order Derivative Driver: Example and Test
-rev_sparse_hes.cpp -Reverse Mode Hessian Sparsity: Example and Test
-rev_sparse_jac.cpp -Reverse Mode Jacobian Sparsity: Example and Test
-rev_two.cpp -Second Partials Reverse Driver: Example and Test
-Rombergmul.cpp -One Dimensional Romberg Integration: Example and Test
-romberg_one.cpp -One Dimensional Romberg Integration: Example and Test
-rosen_34.cpp -Rosen34: Example and Test
-runge45_1.cpp -Runge45: Example and Test
-runge45_2.cpp -Runge45: Example and Test
-seq_property.cpp -ADFun Sequence Properties: Example and Test
-set_union.cpp -Set Union: Example and Test
-simple_ad_bthread.cpp -A Simple Boost Threading AD: Example and Test
-simple_ad_openmp.cpp -A Simple OpenMP AD: Example and Test
-simple_ad_pthread.cpp -A Simple pthread AD: Example and Test
-simple_vector.cpp -Simple Vector Template Class: Example and Test
-simplex_method.cpp -abs_normal simplex_method: Example and Test
-simplex_method.hpp -simplex_method Source Code
-sin.cpp -The AD sin Function: Example and Test
-sinh.cpp -The AD sinh Function: Example and Test
-sparse_hes.cpp -Computing Sparse Hessian: Example and Test
-sparse_hes_fun.cpp -sparse_hes_fun: Example and test
-sparse_hessian.cpp -Sparse Hessian: Example and Test
-sparse_jac_for.cpp -Computing Sparse Jacobian Using Forward Mode: Example and Test
-sparse_jac_fun.cpp -sparse_jac_fun: Example and test
-sparse_jacobian.cpp -Sparse Jacobian: Example and Test
-sparse_jac_rev.cpp -Computing Sparse Jacobian Using Reverse Mode: Example and Test
-sparse_rc.cpp -sparse_rc: Example and Test
-sparse_rcv.cpp -sparse_rcv: Example and Test
-sparse_sub_hes.cpp -Subset of a Sparse Hessian: Example and Test
-sparsity_sub.cpp -Sparsity Patterns For a Subset of Variables: Example and Test
-speed_example.cpp -Run the Speed Examples
-speed_program.cpp -Example Use of SpeedTest
-speed_test.cpp -speed_test: Example and test
-sqrt.cpp -The AD sqrt Function: Example and Test
-stack_machine.cpp -Example Differentiating a Stack Machine Interpreter
-sub.cpp -AD Binary Subtraction: Example and Test
-sub_eq.cpp -AD Compound Assignment Subtraction: Example and Test
-subgraph_hes2jac.cpp -Sparse Hessian Using Subgraphs and Jacobian: Example and Test
-subgraph_jac_rev.cpp -Computing Sparse Jacobian Using Reverse Mode: Example and Test
-subgraph_reverse.cpp -Computing Reverse Mode on Subgraphs: Example and Test
-subgraph_sparsity.cpp -Subgraph Dependency Sparsity Patterns: Example and Test
-sub_sparse_hes.cpp -Computing Sparse Hessian for a Subset of Variables
-tan.cpp -The AD tan Function: Example and Test
-tanh.cpp -The AD tanh Function: Example and Test
-tape_index.cpp -Taping Array Index Operation: Example and Test
-team_bthread.cpp -Boost Thread Implementation of a Team of AD Threads
-team_example.cpp -Using a Team of AD Threads: Example and Test
-team_openmp.cpp -OpenMP Implementation of a Team of AD Threads
-team_pthread.cpp -Pthread Implementation of a Team of AD Threads
-team_thread.hpp -Specifications for A Team of AD Threads
-thread_alloc.cpp -Fast Multi-Threading Memory Allocator: Example and Test
-thread_test.cpp -Run Multi-Threading Examples and Speed Tests
-time_test.cpp -time_test: Example and test
-to_string.cpp -to_string: Example and Test
-unary_minus.cpp -AD Unary Minus Operator: Example and Test
-unary_plus.cpp -AD Unary Plus Operator: Example and Test
-value.cpp -Convert From AD to its Base Type: Example and Test
-var2par.cpp -Convert an AD Variable to a Parameter: Example and Test
-vec_ad.cpp -AD Vectors that Record Index Operations: Example and Test
-vector_bool.cpp -CppAD::vectorBool Class: Example and Test
-
- -
Input File: omh/example_list.omh - - - diff -Nru cppad-2018.00.00.0/doc/_listallexamples_xml.js cppad-2019.02.00.0/doc/_listallexamples_xml.js --- cppad-2018.00.00.0/doc/_listallexamples_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_listallexamples_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'example.xml', -'listallexamples.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.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_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-2018.00.00.0/doc/log10.cpp.xml cppad-2019.02.00.0/doc/log10.cpp.xml --- cppad-2018.00.00.0/doc/log10.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/log10.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ - - - -The AD log10 Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -log10.cppHeadings

-
The AD log10 Function: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool log10(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * 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);
-
-     // ten raised to the x0 power
-     AD<double> ten = 10.;
-     AD<double> pow_10_x0 = CppAD::pow(ten, x[0]);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::log10(pow_10_x0);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0] , x0, eps99, eps99);
-
-     // 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., eps99, eps99);
-
-     // 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., eps99, eps99);
-
-     // use a VecAD<Base>::reference object with log10
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero]           = pow_10_x0;
-     AD<double> result = CppAD::log10(v[zero]);
-     ok   &= NearEqual(result, x0, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/log10.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_log10.cpp_xml.js cppad-2019.02.00.0/doc/_log10.cpp_xml.js --- cppad-2018.00.00.0/doc/_log10.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_log10.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'log10.xml', -'log10.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 = [ -'log10.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-2018.00.00.0/doc/log10.xml cppad-2019.02.00.0/doc/log10.xml --- cppad-2018.00.00.0/doc/log10.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/log10.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ - - - -The Base 10 Logarithm Function: log10 - - - - - - - - - - - - - - - - -
- -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_log10_xml.js cppad-2019.02.00.0/doc/_log10_xml.js --- cppad-2018.00.00.0/doc/_log10_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_log10_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +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', -'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-2018.00.00.0/doc/log1p.cpp.xml cppad-2019.02.00.0/doc/log1p.cpp.xml --- cppad-2018.00.00.0/doc/log1p.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/log1p.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ - - - -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/general/log1p.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_log1p.cpp_xml.js cppad-2019.02.00.0/doc/_log1p.cpp_xml.js --- cppad-2018.00.00.0/doc/_log1p.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_log1p.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'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-2018.00.00.0/doc/log1p.xml cppad-2019.02.00.0/doc/log1p.xml --- cppad-2018.00.00.0/doc/log1p.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/log1p.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,199 +0,0 @@ - - - -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/core/log1p.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_log1p_xml.js cppad-2019.02.00.0/doc/_log1p_xml.js --- cppad-2018.00.00.0/doc/_log1p_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_log1p_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +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', -'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-2018.00.00.0/doc/log.cpp.xml cppad-2019.02.00.0/doc/log.cpp.xml --- cppad-2018.00.00.0/doc/log.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/log.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ - - - -The AD log Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -log.cppHeadings

-
The AD log Function: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool log(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * 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> exp_of_x0 = CppAD::exp(x[0]);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::log(exp_of_x0);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0] , x0, eps99, eps99);
-
-     // 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., eps99, eps99);
-
-     // 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., eps99, eps99);
-
-     // use a VecAD<Base>::reference object with log
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero]           = exp_of_x0;
-     AD<double> result = CppAD::log(v[zero]);
-     ok   &= NearEqual(result, x0, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/log.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_log.cpp_xml.js cppad-2019.02.00.0/doc/_log.cpp_xml.js --- cppad-2018.00.00.0/doc/_log.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_log.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'log.xml', -'log.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 = [ -'log.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-2018.00.00.0/doc/log_forward.xml cppad-2019.02.00.0/doc/log_forward.xml --- cppad-2018.00.00.0/doc/log_forward.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/log_forward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,566 +0,0 @@ - - - -Logarithm Function Forward Mode Theory - - - - - - - - - - - - - - - - -
- -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/appendix/theory/log_forward.omh - - - diff -Nru cppad-2018.00.00.0/doc/_log_forward_xml.js cppad-2019.02.00.0/doc/_log_forward_xml.js --- cppad-2018.00.00.0/doc/_log_forward_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_log_forward_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', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'log_forward.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/log_reverse.xml cppad-2019.02.00.0/doc/log_reverse.xml --- cppad-2018.00.00.0/doc/log_reverse.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/log_reverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,850 +0,0 @@ - - - -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/appendix/theory/log_reverse.omh - - - diff -Nru cppad-2018.00.00.0/doc/_log_reverse_xml.js cppad-2019.02.00.0/doc/_log_reverse_xml.js --- cppad-2018.00.00.0/doc/_log_reverse_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_log_reverse_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', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'log_reverse.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/log.xml cppad-2019.02.00.0/doc/log.xml --- cppad-2018.00.00.0/doc/log.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/log.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,183 +0,0 @@ - - - -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_log_xml.js cppad-2019.02.00.0/doc/_log_xml.js --- cppad-2018.00.00.0/doc/_log_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_log_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'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-2018.00.00.0/doc/lp_box.cpp.xml cppad-2019.02.00.0/doc/lp_box.cpp.xml --- cppad-2018.00.00.0/doc/lp_box.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/lp_box.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,195 +0,0 @@ - - - -abs_normal lp_box: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -lp_box.cpp - -

- - - -
abs_normal lp_box: Example and Test
-
-Problem -
-Our original problem is - - - -minimize - - -x -0 - -- -x -1 - - -w -. -r -. -t - - -x - -R - -2 - - -subject - -to - - --2 - -x -0 - - -+ -2 - -and - - --2 - -x -1 - - -+ -2 - - - -
-Source - -

-# include <limits>
-# include <cppad/utility/vector.hpp>
-# include "lp_box.hpp"
-
-bool lp_box(void)
-{     bool ok = true;
-     typedef CppAD::vector<double> vector;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     //
-     size_t n = 2;
-     size_t m = 0;
-     vector A(m), b(m), c(n), d(n), xout(n);
-     c[0] = +1.0;
-     c[1] = -1.0;
-     //
-     d[0] = +2.0;
-     d[1] = +2.0;
-     //
-     size_t level   = 0;
-     size_t maxitr  = 20;
-     //
-     ok &= CppAD::lp_box(level, A, b, c, d, maxitr, xout);
-     //
-     // check optimal value for x
-     ok &= std::fabs( xout[0] + 2.0 ) < eps99;
-     ok &= std::fabs( xout[1] - 2.0 ) < eps99;
-     //
-     return ok;
-}
- -
Input File: example/abs_normal/lp_box.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_lp_box.cpp_xml.js cppad-2019.02.00.0/doc/_lp_box.cpp_xml.js --- cppad-2018.00.00.0/doc/_lp_box.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lp_box.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'lp_box.xml', -'lp_box.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'lp_box.cpp.xml', -'lp_box.hpp.xml' -]; -var list_current0 = [ -'lp_box.cpp.xml#Problem', -'lp_box.cpp.xml#Source' -]; -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-2018.00.00.0/doc/lp_box.hpp.xml cppad-2019.02.00.0/doc/lp_box.hpp.xml --- cppad-2018.00.00.0/doc/lp_box.hpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/lp_box.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,194 +0,0 @@ - - - -lp_box Source Code - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -lp_box.hppHeadings

-
lp_box Source Code
-
namespace CppAD { // BEGIN_CPPAD_NAMESPACE
-
-// BEGIN PROTOTYPE
-template <class Vector>
-bool lp_box(
-     size_t        level   ,
-     const Vector& A       ,
-     const Vector& b       ,
-     const Vector& c       ,
-     const Vector& d       ,
-     size_t        maxitr  ,
-     Vector&       xout    )
-// END PROTOTYPE
-{     double inf = std::numeric_limits<double>::infinity();
-     //
-     size_t m = b.size();
-     size_t n = c.size();
-     //
-     CPPAD_ASSERT_KNOWN(
-          level <= 3, "lp_box: level is greater than 3");
-     CPPAD_ASSERT_KNOWN(
-          size_t(A.size()) == m * n, "lp_box: size of A is not m * n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(d.size()) == n, "lp_box: size of d is not n"
-     );
-     if( level > 0 )
-     {     std::cout << "start lp_box\n";
-          CppAD::abs_print_mat("A", m, n, A);
-          CppAD::abs_print_mat("b", m, 1, b);
-          CppAD::abs_print_mat("c", n, 1, c);
-          CppAD::abs_print_mat("d", n, 1, d);
-     }
-     //
-     // count number of limits
-     size_t n_limit = 0;
-     for(size_t j = 0; j < n; j++)
-     {     if( d[j] < inf )
-               n_limit += 1;
-     }
-     //
-     // A_simplex and b_simplex define the extended constraints
-     Vector A_simplex((m + 2 * n_limit) * (2 * n) ), b_simplex(m + 2 * n_limit);
-     for(size_t i = 0; i < size_t(A_simplex.size()); i++)
-          A_simplex[i] = 0.0;
-     //
-     // put A * x + b <= 0 in A_simplex, b_simplex
-     for(size_t i = 0; i < m; i++)
-     {     b_simplex[i] = b[i];
-          for(size_t j = 0; j < n; j++)
-          {     // x_j^+ coefficient (positive component)
-               A_simplex[i * (2 * n) + 2 * j]     =   A[i * n + j];
-               // x_j^- coefficient (negative component)
-               A_simplex[i * (2 * n) + 2 * j + 1] = - A[i * n + j];
-          }
-     }
-     //
-     // put | x_j | <= d_j in A_simplex, b_simplex
-     size_t i_limit = 0;
-     for(size_t j = 0; j < n; j++) if( d[j] < inf )
-     {
-          // x_j^+ <= d_j constraint
-          b_simplex[ m + 2 * i_limit]                         = - d[j];
-          A_simplex[(m + 2 * i_limit) * (2 * n) + 2 * j]      = 1.0;
-          //
-          // x_j^- <= d_j constraint
-          b_simplex[ m + 2 * i_limit + 1]                         = - d[j];
-          A_simplex[(m + 2 * i_limit + 1) * (2 * n) + 2 * j + 1]  = 1.0;
-          //
-          ++i_limit;
-     }
-     //
-     // c_simples
-     Vector c_simplex(2 * n);
-     for(size_t j = 0; j < n; j++)
-     {     // x_j+ component
-          c_simplex[2 * j]     = c[j];
-          // x_j^- component
-          c_simplex[2 * j + 1] = - c[j];
-     }
-     size_t level_simplex = 0;
-     if( level >= 2 )
-          level_simplex = level - 1;
-     //
-     Vector x_simplex(2 * n);
-     bool ok = CppAD::simplex_method(
-          level_simplex, A_simplex, b_simplex, c_simplex, maxitr, x_simplex
-     );
-     for(size_t j = 0; j < n; j++)
-          xout[j] = x_simplex[2 * j] - x_simplex[2 * j + 1];
-     if( level > 0 )
-     {     CppAD::abs_print_mat("xout", n, 1, xout);
-          if( ok )
-               std::cout << "end lp_box: ok = true\n";
-          else
-               std::cout << "end lp_box: ok = false\n";
-     }
-     return ok;
-}
-
-} // END_CPPAD_NAMESPACE
- -
Input File: example/abs_normal/lp_box.omh - - - diff -Nru cppad-2018.00.00.0/doc/_lp_box.hpp_xml.js cppad-2019.02.00.0/doc/_lp_box.hpp_xml.js --- cppad-2018.00.00.0/doc/_lp_box.hpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lp_box.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'lp_box.xml', -'lp_box.hpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'lp_box.cpp.xml', -'lp_box.hpp.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-2018.00.00.0/doc/lp_box.xml cppad-2019.02.00.0/doc/lp_box.xml --- cppad-2018.00.00.0/doc/lp_box.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/lp_box.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,398 +0,0 @@ - - - -abs_normal: Solve a Linear Program With Box Constraints - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
abs_normal: Solve a Linear Program With Box Constraints
-
-Syntax - -
- -ok = lp_box(
-     
levelAbcdmaxitrxout
-)
- - -
-
-Prototype - -

-template <class Vector>
-bool lp_box(
-     size_t        level   ,
-     const Vector& A       ,
-     const Vector& b       ,
-     const Vector& c       ,
-     const Vector& d       ,
-     size_t        maxitr  ,
-     Vector&       xout    )
-
-Source -
-This following is a link to the source code for this example: -lp_box.hpp -. - -
-
-Problem -
-We are given - - -A - -R - -m -× -n - - - - -, - - -b - -R - -m - - - -, - - -c - -R - -n - - - -, - - -d - -R - -n - - - -, -This routine solves the problem - - - -minimize - - -c -T - -x - -w -. -r -. -t - - -x - -R - -n - - -subject - -to - - -A -x -+ -b - -0 - -and - - -- -d - -x - -d - - - -
-Vector -
-The type -Vector - is a -simple vector with elements of type double. - -
-
-level -
-This value is less that or equal two. -If -level == 0 -, -no tracing is printed. -If -level >= 1 -, -a trace of the lp_box operations is printed. -If -level >= 2 -, -the objective and primal variables - -x - - - are printed -at each simplex_method - iteration. -If -level == 3 -, -the simplex tableau is printed at each simplex iteration. - -
-
-A -
-This is a row-major - representation -of the matrix - -A - - - in the problem. - -
-
-b -
-This is the vector - -b - - - in the problem. - -
-
-c -
-This is the vector - -c - - - in the problem. - -
-
-d -
-This is the vector - -d - - - in the problem. -If - -d -j - - - - is infinity, there is no limit for the size of - - -x -j - - - -. - -
-
-maxitr -
-This is the maximum number of newton iterations to try before giving up -on convergence. - -
-
-xout -
-This argument has size is -n - and -the input value of its elements does no matter. -Upon return it is the primal variables - - -x - - - corresponding to the problem solution. - -
-
-ok -
-If the return value -ok - is true, an optimal solution was found. - - -
-
-Example -
-The file lp_box.cpp - contains an example and test of -lp_box. -It returns true if the test passes and false otherwise. - - -
Input File: example/abs_normal/lp_box.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_lp_box_xml.js cppad-2019.02.00.0/doc/_lp_box_xml.js --- cppad-2018.00.00.0/doc/_lp_box_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lp_box_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'lp_box.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down0 = [ -'lp_box.cpp.xml', -'lp_box.hpp.xml' -]; -var list_current0 = [ -'lp_box.xml#Syntax', -'lp_box.xml#Prototype', -'lp_box.xml#Source', -'lp_box.xml#Problem', -'lp_box.xml#Vector', -'lp_box.xml#level', -'lp_box.xml#A', -'lp_box.xml#b', -'lp_box.xml#c', -'lp_box.xml#d', -'lp_box.xml#maxitr', -'lp_box.xml#xout', -'lp_box.xml#ok', -'lp_box.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-2018.00.00.0/doc/ludetandsolve.xml cppad-2019.02.00.0/doc/ludetandsolve.xml --- cppad-2018.00.00.0/doc/ludetandsolve.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/ludetandsolve.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ - - - -Compute Determinants and Solve Equations by LU Factorization - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - - -
Compute Determinants and Solve Equations by LU Factorization
-
-Contents -
- -
LuSolveCompute Determinant and Solve Linear Equations
LuFactorLU Factorization of A Square Matrix
LuInvertInvert an LU Factored Equation
-
Input File: omh/lu_det_and_solve.omh - - - diff -Nru cppad-2018.00.00.0/doc/_ludetandsolve_xml.js cppad-2019.02.00.0/doc/_ludetandsolve_xml.js --- cppad-2018.00.00.0/doc/_ludetandsolve_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ludetandsolve_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'ludetandsolve.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'lusolve.xml', -'lufactor.xml', -'luinvert.xml' -]; -var list_current0 = [ -'ludetandsolve.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-2018.00.00.0/doc/lu_factor.cpp.xml cppad-2019.02.00.0/doc/lu_factor.cpp.xml --- cppad-2018.00.00.0/doc/lu_factor.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/lu_factor.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,194 +0,0 @@ - - - -LuFactor: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -lu_factor.cppHeadings

- - - -
LuFactor: Example and Test
-
# include <cstdlib>               // for rand function
-# include <cppad/utility/lu_factor.hpp>      // for CppAD::LuFactor
-# include <cppad/utility/near_equal.hpp>     // for CppAD::NearEqual
-# include <cppad/utility/vector.hpp>  // for CppAD::vector
-
-bool LuFactor(void)
-{     bool  ok = true;
-
-# ifndef _MSC_VER
-     using std::rand;
-     using std::srand;
-# endif
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     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
-     size_t  i, j, k;                      // temporary indices
-
-     // A is an n by n matrix
-     CppAD::vector<double> A(n*n), LU(n*n), L(n*n), U(n*n);
-
-     // set A equal to an n by n random matrix
-     for(i = 0; i < n; i++)
-          for(j = 0; j < n; j++)
-               A[i * n + j] = rand() / rand_max;
-
-     // pivot vectors
-     CppAD::vector<size_t> ip(n);
-     CppAD::vector<size_t> jp(n);
-
-     // factor the matrix A
-     LU       = A;
-     CppAD::LuFactor(ip, jp, LU);
-
-     // check that ip and jp are permutations of the indices 0, ... , n-1
-     for(i = 0; i < n; i++)
-     {     ok &= (ip[i] < n);
-          ok &= (jp[i] < n);
-          for(j = 0; j < n; j++)
-          {     if( i != j )
-               {     ok &= (ip[i] != ip[j]);
-                    ok &= (jp[i] != jp[j]);
-               }
-          }
-     }
-
-     // Extract L from LU
-     for(i = 0; i < n; i++)
-     {     // elements along and below the diagonal
-          for(j = 0; j <= i; j++)
-               L[i * n + j] = LU[ ip[i] * n + jp[j] ];
-          // elements above the diagonal
-          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
-          for(j = 0; j < i; j++)
-               U[i * n + j] = 0.;
-          // elements along the diagonal
-          U[i * n + i] = 1.;
-          // elements above the diagonal
-          for(j = i+1; j < n; j++)
-               U[i * n + j] = LU[ ip[i] * n + jp[j] ];
-     }
-
-     // Compute L * U
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j < n; j++)
-          {     // compute element (i,j) entry in L * U
-               sum = 0.;
-               for(k = 0; k < n; k++)
-                    sum += L[i * n + k] * U[k * n + j];
-               // element (i,j) in permuted version of A
-               pij  = A[ ip[i] * n + jp[j] ];
-               // compare
-               ok  &= NearEqual(pij, sum, eps99, eps99);
-          }
-     }
-
-     return ok;
-}
-
-
-
Input File: example/utility/lu_factor.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_lu_factor.cpp_xml.js cppad-2019.02.00.0/doc/_lu_factor.cpp_xml.js --- cppad-2018.00.00.0/doc/_lu_factor.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lu_factor.cpp_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', -'utility.xml', -'ludetandsolve.xml', -'lufactor.xml', -'lu_factor.cpp.xml' -]; -var list_down3 = [ -'errorhandler.xml', -'nearequal.xml', -'speed_test.xml', -'speedtest.xml', -'time_test.xml', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down2 = [ -'lusolve.xml', -'lufactor.xml', -'luinvert.xml' -]; -var list_down1 = [ -'lu_factor.cpp.xml', -'lu_factor.hpp.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-2018.00.00.0/doc/lu_factor.hpp.xml cppad-2019.02.00.0/doc/lu_factor.hpp.xml --- cppad-2018.00.00.0/doc/lu_factor.hpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/lu_factor.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,266 +0,0 @@ - - - -Source: LuFactor - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -lu_factor.hppHeadings

-
Source: LuFactor
-# ifndef CPPAD_LU_FACTOR_HPP -
-
# define CPPAD_LU_FACTOR_HPP - -

-# include <complex>
-# include <vector>
-
-# include <cppad/core/cppad_assert.hpp>
-# include <cppad/utility/check_simple_vector.hpp>
-# include <cppad/utility/check_numeric_type.hpp>
-
-namespace CppAD { // BEGIN CppAD namespace
-
-// AbsGeq
-template <typename Float>
-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<double> &x,
-     const std::complex<double> &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<float> &x,
-     const std::complex<float> &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/core/lu_ratio.hpp end with //
-template <class SizeVector, class FloatVector>                          //
-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<Float>();
-
-     // check simple vector class specifications
-     CheckSimpleVector<Float, FloatVector>();
-     CheckSimpleVector<size_t, SizeVector>();
-
-     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
-# endif -
- - -
Input File: omh/lu_factor_hpp.omh - - - diff -Nru cppad-2018.00.00.0/doc/_lu_factor.hpp_xml.js cppad-2019.02.00.0/doc/_lu_factor.hpp_xml.js --- cppad-2018.00.00.0/doc/_lu_factor.hpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lu_factor.hpp_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', -'utility.xml', -'ludetandsolve.xml', -'lufactor.xml', -'lu_factor.hpp.xml' -]; -var list_down3 = [ -'errorhandler.xml', -'nearequal.xml', -'speed_test.xml', -'speedtest.xml', -'time_test.xml', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down2 = [ -'lusolve.xml', -'lufactor.xml', -'luinvert.xml' -]; -var list_down1 = [ -'lu_factor.cpp.xml', -'lu_factor.hpp.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-2018.00.00.0/doc/lufactor.xml cppad-2019.02.00.0/doc/lufactor.xml --- cppad-2018.00.00.0/doc/lufactor.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/lufactor.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,653 +0,0 @@ - - - -LU Factorization of A Square Matrix - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - - -
LU Factorization of A Square Matrix
-
-
Syntax -
- - include <cppad/utility/lu_factor.hpp>
-
- -sign = LuFactor(ipjpLU) - - - -
-
-Description -
-Computes an LU factorization of the matrix -A - -where -A - is a square matrix. - -
-
-Include -
-The file cppad/lu_factor.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-Matrix Storage -
-All matrices are stored in row major order. -To be specific, if - -Y - - - is a vector -that contains a - -p - - - by - -q - - - matrix, -the size of - -Y - - - must be equal to - -p -* -q - - - and for - - -i -= -0 -, - -, -p --1 - - -, - - -j -= -0 -, - -, -q --1 - - -, - - -Y -i -, -j - - -= -Y -[ -i -* -q -+ -j -] - - -
-sign -
-The return value -sign - has prototype - -
-     int 
sign
-
-If -A - is invertible, -sign - is plus or minus one -and is the sign of the permutation corresponding to the row ordering - -ip - and column ordering -jp -. -If -A - is not invertible, -sign - is zero. - -
-
-ip -
-The argument -ip - has prototype - -
-     
SizeVector &ip
-
-(see description of SizeVector - below). -The size of -ip - is referred to as -n - in the -specifications below. -The input value of the elements of -ip - does not matter. -The output value of the elements of -ip - determine -the order of the rows in the permuted matrix. - -
-
-jp -
-The argument -jp - has prototype - -
-     
SizeVector &jp
-
-(see description of SizeVector - below). -The size of -jp - must be equal to -n -. -The input value of the elements of -jp - does not matter. -The output value of the elements of -jp - determine -the order of the columns in the permuted matrix. - -
-
-LU -
-The argument -LU - has the prototype - -
-     
FloatVector &LU
-
-and the size of -LU - must equal - -n -* -n - - - -(see description of FloatVector - below). - -
-
-A -
-We define -A - as the matrix corresponding to the input -value of -LU -. - -
-
-P -
-We define the permuted matrix -P - in terms of -A - by - -
-     
P(ij) = Aip[i] * n + jp[j] ]
-
-
-L -
-We define the lower triangular matrix -L - in terms of the -output value of -LU -. -The matrix -L - is zero above the diagonal -and the rest of the elements are defined by - -
-     
L(ij) = LUip[i] * n + jp[j] ]
-
-for - -i -= -0 -, - -, -n --1 - - - and - -j -= -0 -, - -, -i - - -. - -
-
-U -
-We define the upper triangular matrix -U - in terms of the -output value of -LU -. -The matrix -U - is zero below the diagonal, -one on the diagonal, -and the rest of the elements are defined by - -
-     
U(ij) = LUip[i] * n + jp[j] ]
-
-for - -i -= -0 -, - -, -n --2 - - - and - -j -= -i -+ -1 -, - -, -n --1 - - -. - -
-
-Factor -
-If the return value -sign - is non-zero, - -
-     
L * U = P
-
-If the return value of -sign - is zero, -the contents of -L - and -U - are not defined. - -
-
-Determinant -
-If the return value -sign - is zero, -the determinant of -A - is zero. -If -sign - is non-zero, -using the output value of -LU - -the determinant of the matrix -A - is equal to - -
-
sign * LU[ip[0], jp[0]] * ... * LU[ip[n-1], jp[n-1]]
-
-
-SizeVector -
-The type -SizeVector - must be a SimpleVector - class with -elements of type size_t -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-FloatVector -
-The type -FloatVector - must be a -simple vector class -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Float -
-This notation is used to denote the type corresponding -to the elements of a -FloatVector -. -The type -Float - must satisfy the conditions -for a NumericType - type. -The routine CheckNumericType - will generate an error message -if this is not the case. -In addition, the following operations must be defined for any pair -of -Float - objects -x - and -y -: - - -
- -Operation - Description
- - -log(x) - - - returns the logarithm of -x - as a -Float - object -
-
-AbsGeq -
-Including the file lu_factor.hpp defines the template function - -
-     template <typename 
Float>
-     bool AbsGeq<
Float>(const Float &x, const Float &y)
-
-in the CppAD namespace. -This function returns true if the absolute value of - -x - is greater than or equal the absolute value of -y -. -It is used by LuFactor to choose the pivot elements. -This template function definition uses the operator -<= to obtain the absolute value for -Float - objects. -If this operator is not defined for your use of -Float -, -you will need to specialize this template so that it works for your -use of LuFactor. -
-
-
Complex numbers do not have the operation <= defined. -The specializations - -
-bool AbsGeq< std::complex<float> >
-     (const std::complex<float> &
x, const std::complex<float> &y)
-bool AbsGeq< std::complex<double> >
-     (const std::complex<double> &
x, const std::complex<double> &y)
-
-are define by including lu_factor.hpp -These return true if the sum of the square of the real and imaginary parts -of -x - is greater than or equal the -sum of the square of the real and imaginary parts of -y -. - - -
-
-Example -
-The file -lu_factor.cpp - -contains an example and test of using LuFactor by itself. -It returns true if it succeeds and false otherwise. -
-
-
The file lu_solve.hpp - provides a useful example usage of -LuFactor with LuInvert. - -
-
-Source -
-The file lu_factor.hpp - contains the -current source code that implements these specifications. - - -
Input File: cppad/utility/lu_factor.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_lufactor_xml.js cppad-2019.02.00.0/doc/_lufactor_xml.js --- cppad-2018.00.00.0/doc/_lufactor_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lufactor_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,129 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'ludetandsolve.xml', -'lufactor.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'lusolve.xml', -'lufactor.xml', -'luinvert.xml' -]; -var list_down0 = [ -'lu_factor.cpp.xml', -'lu_factor.hpp.xml' -]; -var list_current0 = [ -'lufactor.xml#Syntax', -'lufactor.xml#Description', -'lufactor.xml#Include', -'lufactor.xml#Matrix Storage', -'lufactor.xml#sign', -'lufactor.xml#ip', -'lufactor.xml#jp', -'lufactor.xml#LU', -'lufactor.xml#LU.A', -'lufactor.xml#LU.P', -'lufactor.xml#LU.L', -'lufactor.xml#LU.U', -'lufactor.xml#LU.Factor', -'lufactor.xml#LU.Determinant', -'lufactor.xml#SizeVector', -'lufactor.xml#FloatVector', -'lufactor.xml#Float', -'lufactor.xml#AbsGeq', -'lufactor.xml#Example', -'lufactor.xml#Source' -]; -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-2018.00.00.0/doc/lu_invert.cpp.xml cppad-2019.02.00.0/doc/lu_invert.cpp.xml --- cppad-2018.00.00.0/doc/lu_invert.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/lu_invert.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,204 +0,0 @@ - - - -LuInvert: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -lu_invert.cppHeadings

- - - -
LuInvert: Example and Test
-
# include <cstdlib>               // for rand function
-# include <cppad/utility/lu_invert.hpp>      // for CppAD::LuInvert
-# include <cppad/utility/near_equal.hpp>     // for CppAD::NearEqual
-# include <cppad/utility/vector.hpp>  // for CppAD::vector
-
-bool LuInvert(void)
-{     bool  ok = true;
-
-# ifndef _MSC_VER
-     using std::rand;
-     using std::srand;
-# endif
-     double eps200 = 200.0 * std::numeric_limits<double>::epsilon();
-
-     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<double>
-          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);
-
-     // pivot vectors
-     CppAD::vector<size_t> ip(n);
-     CppAD::vector<size_t> jp(n);
-
-     // set pivot vectors
-     for(i = 0; i < n; i++)
-     {     ip[i] = (i + 2) % n;      // ip = 2 , 3, ... , n-1, 0, 1
-          jp[i] = (n + 2 - i) % n;  // jp = 2 , 1, n-1, n-2, ... , 3
-     }
-
-     // chose L, a random lower triangular matrix
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j <= i; j++)
-               L [i * n + j]  = rand() / rand_max;
-          for(j = i+1; j < n; j++)
-               L [i * n + j]  = 0.;
-     }
-     // 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 + i ] = 1.;
-          for(j = i+1; j < n; j++)
-               U [i * n + j]  = rand() / rand_max;
-     }
-     // chose X, a random matrix
-     for(i = 0; i < n; i++)
-     {     for(k = 0; k < m; k++)
-               X[i * m + k] = rand() / rand_max;
-     }
-     // set LU to a permuted combination of both L and U
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j <= i; j++)
-               LU [ ip[i] * n + jp[j] ]  = L[i * n + j];
-          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
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j < n; j++)
-          {     // compute (i,j) entry in permuted matrix
-               sum = 0.;
-               for(k = 0; k < n; k++)
-                    sum += L[i * n + k] * U[k * n + j];
-               A[ ip[i] * n + jp[j] ] = sum;
-          }
-     }
-     // set B to A * X
-     for(i = 0; i < n; i++)
-     {     for(k = 0; k < m; k++)
-          {     // compute (i,k) entry of B
-               sum = 0.;
-               for(j = 0; j < n; j++)
-                    sum += A[i * n + j] * X[j * m + k];
-               B[i * m + k] = sum;
-          }
-     }
-     // solve for X
-     CppAD::LuInvert(ip, jp, LU, B);
-
-     // check result
-     for(i = 0; i < n; i++)
-     {     for(k = 0; k < m; k++)
-          {     ok &= CppAD::NearEqual(
-                    X[i * m + k], B[i * m + k], eps200, eps200
-               );
-          }
-     }
-     return ok;
-}
-
-
-
Input File: example/utility/lu_invert.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_lu_invert.cpp_xml.js cppad-2019.02.00.0/doc/_lu_invert.cpp_xml.js --- cppad-2018.00.00.0/doc/_lu_invert.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lu_invert.cpp_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', -'utility.xml', -'ludetandsolve.xml', -'luinvert.xml', -'lu_invert.cpp.xml' -]; -var list_down3 = [ -'errorhandler.xml', -'nearequal.xml', -'speed_test.xml', -'speedtest.xml', -'time_test.xml', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down2 = [ -'lusolve.xml', -'lufactor.xml', -'luinvert.xml' -]; -var list_down1 = [ -'lu_invert.cpp.xml', -'lu_invert.hpp.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-2018.00.00.0/doc/lu_invert.hpp.xml cppad-2019.02.00.0/doc/lu_invert.hpp.xml --- cppad-2018.00.00.0/doc/lu_invert.hpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/lu_invert.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,187 +0,0 @@ - - - -Source: LuInvert - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -lu_invert.hppHeadings

-
Source: LuInvert
-# ifndef CPPAD_LU_INVERT_HPP -
-
# define CPPAD_LU_INVERT_HPP - -
# include <cppad/core/cppad_assert.hpp>
-# include <cppad/utility/check_simple_vector.hpp>
-# include <cppad/utility/check_numeric_type.hpp>
-
-namespace CppAD { // BEGIN CppAD namespace
-
-// LuInvert
-template <typename SizeVector, typename FloatVector>
-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<Float>();
-
-     // check simple vector class specifications
-     CheckSimpleVector<Float, FloatVector>();
-     CheckSimpleVector<size_t, SizeVector>();
-
-     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
-# endif -
- - -
Input File: omh/lu_invert_hpp.omh - - - diff -Nru cppad-2018.00.00.0/doc/_lu_invert.hpp_xml.js cppad-2019.02.00.0/doc/_lu_invert.hpp_xml.js --- cppad-2018.00.00.0/doc/_lu_invert.hpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lu_invert.hpp_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', -'utility.xml', -'ludetandsolve.xml', -'luinvert.xml', -'lu_invert.hpp.xml' -]; -var list_down3 = [ -'errorhandler.xml', -'nearequal.xml', -'speed_test.xml', -'speedtest.xml', -'time_test.xml', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down2 = [ -'lusolve.xml', -'lufactor.xml', -'luinvert.xml' -]; -var list_down1 = [ -'lu_invert.cpp.xml', -'lu_invert.hpp.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-2018.00.00.0/doc/luinvert.xml cppad-2019.02.00.0/doc/luinvert.xml --- cppad-2018.00.00.0/doc/luinvert.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/luinvert.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,506 +0,0 @@ - - - -Invert an LU Factored Equation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - - -
Invert an LU Factored Equation
-
-
Syntax -
- - include <cppad/utility/lu_invert.hpp>
-
- -LuInvert(ipjpLUX) - - - -
-
-Description -
-Solves the matrix equation -A * X = B - -using an LU factorization computed by LuFactor -. - -
-
-Include -
-The file cppad/lu_invert.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-Matrix Storage -
-All matrices are stored in row major order. -To be specific, if - -Y - - - is a vector -that contains a - -p - - - by - -q - - - matrix, -the size of - -Y - - - must be equal to - -p -* -q - - - and for - - -i -= -0 -, - -, -p --1 - - -, - - -j -= -0 -, - -, -q --1 - - -, - - -Y -i -, -j - - -= -Y -[ -i -* -q -+ -j -] - - -
-ip -
-The argument -ip - has prototype - -
-     const 
SizeVector &ip
-
-(see description for -SizeVector - in -LuFactor - specifications). -The size of -ip - is referred to as -n - in the -specifications below. -The elements of -ip - determine -the order of the rows in the permuted matrix. - -
-
-jp -
-The argument -jp - has prototype - -
-     const 
SizeVector &jp
-
-(see description for -SizeVector - in -LuFactor - specifications). -The size of -jp - must be equal to -n -. -The elements of -jp - determine -the order of the columns in the permuted matrix. - -
-
-LU -
-The argument -LU - has the prototype - -
-     const 
FloatVector &LU
-
-and the size of -LU - must equal - -n -* -n - - - -(see description for -FloatVector - in -LuFactor - specifications). - -
-
-L -
-We define the lower triangular matrix -L - in terms of -LU -. -The matrix -L - is zero above the diagonal -and the rest of the elements are defined by - -
-     
L(ij) = LUip[i] * n + jp[j] ]
-
-for - -i -= -0 -, - -, -n --1 - - - and - -j -= -0 -, - -, -i - - -. - -
-
-U -
-We define the upper triangular matrix -U - in terms of -LU -. -The matrix -U - is zero below the diagonal, -one on the diagonal, -and the rest of the elements are defined by - -
-     
U(ij) = LUip[i] * n + jp[j] ]
-
-for - -i -= -0 -, - -, -n --2 - - - and - -j -= -i -+ -1 -, - -, -n --1 - - -. - -
-
-P -
-We define the permuted matrix -P - in terms of -the matrix -L - and the matrix -U - -by -P = L * U -. - -
-
-A -
-The matrix -A -, -which defines the linear equations that we are solving, is given by - -
-     
P(ij) = Aip[i] * n + jp[j] ]
-
-(Hence - -LU - contains a permuted factorization of the matrix -A -.) - - -
-
-X -
-The argument -X - has prototype - -
-     
FloatVector &X
-
-(see description for -FloatVector - in -LuFactor - specifications). -The matrix -X - -must have the same number of rows as the matrix -A -. -The input value of -X - is the matrix -B - and the -output value solves the matrix equation -A * X = B -. - - - -
-
-Example -
-The file lu_solve.hpp - is a good example usage of -LuFactor with LuInvert. -The file -lu_invert.cpp - -contains an example and test of using LuInvert by itself. -It returns true if it succeeds and false otherwise. - -
-
-Source -
-The file lu_invert.hpp - contains the -current source code that implements these specifications. - - -
Input File: cppad/utility/lu_invert.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_luinvert_xml.js cppad-2019.02.00.0/doc/_luinvert_xml.js --- cppad-2018.00.00.0/doc/_luinvert_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_luinvert_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', -'utility.xml', -'ludetandsolve.xml', -'luinvert.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'lusolve.xml', -'lufactor.xml', -'luinvert.xml' -]; -var list_down0 = [ -'lu_invert.cpp.xml', -'lu_invert.hpp.xml' -]; -var list_current0 = [ -'luinvert.xml#Syntax', -'luinvert.xml#Description', -'luinvert.xml#Include', -'luinvert.xml#Matrix Storage', -'luinvert.xml#ip', -'luinvert.xml#jp', -'luinvert.xml#LU', -'luinvert.xml#LU.L', -'luinvert.xml#LU.U', -'luinvert.xml#LU.P', -'luinvert.xml#LU.A', -'luinvert.xml#X', -'luinvert.xml#Example', -'luinvert.xml#Source' -]; -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-2018.00.00.0/doc/lu_ratio.cpp.xml cppad-2019.02.00.0/doc/lu_ratio.cpp.xml --- cppad-2018.00.00.0/doc/lu_ratio.cpp.xml 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/lu_ratio.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,249 +0,0 @@ - - - -LuRatio: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -lu_ratio.cppHeadings

- - - -
LuRatio: Example and Test
-
# include <cstdlib>               // for rand function
-# include <cassert>
-# include <cppad/cppad.hpp>
-
-namespace { // Begin empty namespace
-
-CppAD::ADFun<double> *NewFactor(
-     size_t                           n ,
-     const CPPAD_TESTVECTOR(double) &x ,
-     bool                           &ok ,
-     CPPAD_TESTVECTOR(size_t)      &ip ,
-     CPPAD_TESTVECTOR(size_t)      &jp )
-{     using CppAD::AD;
-     using CppAD::ADFun;
-     size_t i, j, k;
-
-     // values for independent and dependent variables
-     CPPAD_TESTVECTOR(AD<double>) Y(n*n+1), X(n*n);
-
-     // values for the LU factor
-     CPPAD_TESTVECTOR(AD<double>) LU(n*n);
-
-     // record the LU factorization corresponding to this value of x
-     AD<double> Ratio;
-     for(k = 0; k < n*n; k++)
-          X[k] = x[k];
-     Independent(X);
-     for(k = 0; k < n*n; k++)
-          LU[k] = X[k];
-     CppAD::LuRatio(ip, jp, LU, Ratio);
-     for(k = 0; k < n*n; k++)
-          Y[k] = LU[k];
-     Y[n*n] = Ratio;
-
-     // use a function pointer so can return ADFun object
-     ADFun<double> *FunPtr = new ADFun<double>(X, Y);
-
-     // check value of ratio during recording
-     ok &= (Ratio == 1.);
-
-     // check that ip and jp are permutations of the indices 0, ... , n-1
-     for(i = 0; i < n; i++)
-     {     ok &= (ip[i] < n);
-          ok &= (jp[i] < n);
-          for(j = 0; j < n; j++)
-          {     if( i != j )
-               {     ok &= (ip[i] != ip[j]);
-                    ok &= (jp[i] != jp[j]);
-               }
-          }
-     }
-     return FunPtr;
-}
-bool CheckLuFactor(
-     size_t                           n  ,
-     const CPPAD_TESTVECTOR(double) &x  ,
-     const CPPAD_TESTVECTOR(double) &y  ,
-     const CPPAD_TESTVECTOR(size_t) &ip ,
-     const CPPAD_TESTVECTOR(size_t) &jp )
-{     bool     ok = true;
-
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     double  sum;                          // element of L * U
-     double  pij;                          // element of permuted x
-     size_t  i, j, k;                      // temporary indices
-
-     // L and U factors
-     CPPAD_TESTVECTOR(double)  L(n*n), U(n*n);
-
-     // Extract L from LU factorization
-     for(i = 0; i < n; i++)
-     {     // elements along and below the diagonal
-          for(j = 0; j <= i; j++)
-               L[i * n + j] = y[ ip[i] * n + jp[j] ];
-          // elements above the diagonal
-          for(j = i+1; j < n; j++)
-               L[i * n + j] = 0.;
-     }
-
-     // Extract U from LU factorization
-     for(i = 0; i < n; i++)
-     {     // elements below the diagonal
-          for(j = 0; j < i; j++)
-               U[i * n + j] = 0.;
-          // elements along the diagonal
-          U[i * n + i] = 1.;
-          // elements above the diagonal
-          for(j = i+1; j < n; j++)
-               U[i * n + j] = y[ ip[i] * n + jp[j] ];
-     }
-
-     // Compute L * U
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j < n; j++)
-          {     // compute element (i,j) entry in L * U
-               sum = 0.;
-               for(k = 0; k < n; k++)
-                    sum += L[i * n + k] * U[k * n + j];
-               // element (i,j) in permuted version of A
-               pij  = x[ ip[i] * n + jp[j] ];
-               // compare
-               ok  &= NearEqual(pij, sum, eps99, eps99);
-          }
-     }
-     return ok;
-}
-
-} // end Empty namespace
-
-bool LuRatio(void)
-{     bool  ok = true;
-
-     size_t  n = 2; // number rows in A
-     double  ratio;
-
-     // values for independent and dependent variables
-     CPPAD_TESTVECTOR(double)  x(n*n), y(n*n+1);
-
-     // pivot vectors
-     CPPAD_TESTVECTOR(size_t) ip(n), jp(n);
-
-     // set x equal to the identity matrix
-     x[0] = 1.; x[1] = 0;
-     x[2] = 0.; x[3] = 1.;
-
-     // create a fnction object corresponding to this value of x
-     CppAD::ADFun<double> *FunPtr = NewFactor(n, x, ok, ip, jp);
-
-     // use function object to factor matrix
-     y     = FunPtr->Forward(0, x);
-     ratio = y[n*n];
-     ok   &= (ratio == 1.);
-     ok   &= CheckLuFactor(n, x, y, ip, jp);
-
-     // set x so that the pivot ratio will be infinite
-     x[0] = 0. ; x[1] = 1.;
-     x[2] = 1. ; x[3] = 0.;
-
-     // try to use old function pointer to factor matrix
-     y     = FunPtr->Forward(0, x);
-     ratio = y[n*n];
-
-     // check to see if we need to refactor matrix
-     ok &= (ratio > 10.);
-     if( ratio > 10. )
-     {     delete FunPtr; // to avoid a memory leak
-          FunPtr = NewFactor(n, x, ok, ip, jp);
-     }
-
-     //  now we can use the function object to factor matrix
-     y     = FunPtr->Forward(0, x);
-     ratio = y[n*n];
-     ok    &= (ratio == 1.);
-     ok    &= CheckLuFactor(n, x, y, ip, jp);
-
-     delete FunPtr;  // avoid memory leak
-     return ok;
-}
-
-
Input File: example/general/lu_ratio.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_lu_ratio.cpp_xml.js cppad-2019.02.00.0/doc/_lu_ratio.cpp_xml.js --- cppad-2018.00.00.0/doc/_lu_ratio.cpp_xml.js 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lu_ratio.cpp_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', -'numeric_ad.xml', -'luratio.xml', -'lu_ratio.cpp.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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 = [ -'benderquad.xml', -'opt_val_hes.xml', -'luratio.xml' -]; -var list_down1 = [ -'lu_ratio.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-2018.00.00.0/doc/luratio.xml cppad-2019.02.00.0/doc/luratio.xml --- cppad-2018.00.00.0/doc/luratio.xml 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/luratio.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,631 +0,0 @@ - - - -LU Factorization of A Square Matrix and Stability Calculation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
LU Factorization of A Square Matrix and Stability Calculation
-
-Syntax - -
-# include <cppad/cppad.hpp>
-
-
-sign = LuRatio(ipjpLUratio) - - - -
-
-Description -
-Computes an LU factorization of the matrix -A - -where -A - is a square matrix. -A measure of the numerical stability called -ratio - is calculated. -This ratio is useful when the results of LuRatio are -used as part of an ADFun - object. - -
-
-Include -
-This routine is designed to be used with AD objects and -requires the cppad/cppad.hpp file to be included. - -
-
-Matrix Storage -
-All matrices are stored in row major order. -To be specific, if - -Y - - - is a vector -that contains a - -p - - - by - -q - - - matrix, -the size of - -Y - - - must be equal to - -p -* -q - - - and for - - -i -= -0 -, - -, -p --1 - - -, - - -j -= -0 -, - -, -q --1 - - -, - - -Y -i -, -j - - -= -Y -[ -i -* -q -+ -j -] - - -
-sign -
-The return value -sign - has prototype - -
-     int 
sign
-
-If -A - is invertible, -sign - is plus or minus one -and is the sign of the permutation corresponding to the row ordering - -ip - and column ordering -jp -. -If -A - is not invertible, -sign - is zero. - -
-
-ip -
-The argument -ip - has prototype - -
-     
SizeVector &ip
-
-(see description of SizeVector - below). -The size of -ip - is referred to as -n - in the -specifications below. -The input value of the elements of -ip - does not matter. -The output value of the elements of -ip - determine -the order of the rows in the permuted matrix. - -
-
-jp -
-The argument -jp - has prototype - -
-     
SizeVector &jp
-
-(see description of SizeVector - below). -The size of -jp - must be equal to -n -. -The input value of the elements of -jp - does not matter. -The output value of the elements of -jp - determine -the order of the columns in the permuted matrix. - -
-
-LU -
-The argument -LU - has the prototype - -
-     
ADvector &LU
-
-and the size of -LU - must equal - -n -* -n - - - -(see description of ADvector - below). - -
-
-A -
-We define -A - as the matrix corresponding to the input -value of -LU -. - -
-
-P -
-We define the permuted matrix -P - in terms of -A - by - -
-     
P(ij) = Aip[i] * n + jp[j] ]
-
-
-L -
-We define the lower triangular matrix -L - in terms of the -output value of -LU -. -The matrix -L - is zero above the diagonal -and the rest of the elements are defined by - -
-     
L(ij) = LUip[i] * n + jp[j] ]
-
-for - -i -= -0 -, - -, -n --1 - - - and - -j -= -0 -, - -, -i - - -. - -
-
-U -
-We define the upper triangular matrix -U - in terms of the -output value of -LU -. -The matrix -U - is zero below the diagonal, -one on the diagonal, -and the rest of the elements are defined by - -
-     
U(ij) = LUip[i] * n + jp[j] ]
-
-for - -i -= -0 -, - -, -n --2 - - - and - -j -= -i -+ -1 -, - -, -n --1 - - -. - -
-
-Factor -
-If the return value -sign - is non-zero, - -
-     
L * U = P
-
-If the return value of -sign - is zero, -the contents of -L - and -U - are not defined. - -
-
-Determinant -
-If the return value -sign - is zero, -the determinant of -A - is zero. -If -sign - is non-zero, -using the output value of -LU - -the determinant of the matrix -A - is equal to - -
-
sign * LU[ip[0], jp[0]] * ... * LU[ip[n-1], jp[n-1]]
-
-
-ratio -
-The argument -ratio - has prototype - -
-        AD<
Base> &ratio
-
-On input, the value of -ratio - does not matter. -On output it is a measure of how good the choice of pivots is. -For - -p -= -0 -, - -, -n --1 - - -, -the p-th pivot element is the element of maximum absolute value of a - - -( -n -- -p -) -× -( -n -- -p -) - - - sub-matrix. -The ratio of each element of sub-matrix divided by the pivot element -is computed. -The return value of -ratio - is the maximum absolute value of -such ratios over with respect to all elements and all the pivots. - -
-
-Purpose -
-Suppose that the execution of a call to LuRatio -is recorded in the -ADFun<Base> - object -F -. -Then a call to Forward - of the form - -
-     
F.Forward(kxk)
-
-with -k - equal to zero will revaluate this Lu factorization -with the same pivots and a new value for -A -. -In this case, the resulting -ratio - may not be one. -If -ratio - is too large (the meaning of too large is up to you), -the current pivots do not yield a stable LU factorization of -A -. -A better choice for the pivots (for this value of -A -) -will be made if you recreate the ADFun object -starting with the Independent - variable values -that correspond to the vector -xk -. - -
-
-SizeVector -
-The type -SizeVector - must be a SimpleVector - class with -elements of type size_t -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-ADvector -
-The type -ADvector - must be a -simple vector class - with elements of type - -AD<Base> -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - - -
-
-Example - -
-The file lu_ratio.cpp - -contains an example and test of using LuRatio. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/lu_ratio.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_luratio_xml.js cppad-2019.02.00.0/doc/_luratio_xml.js --- cppad-2018.00.00.0/doc/_luratio_xml.js 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/_luratio_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -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', -'luratio.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', -'directory.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 = [ -'benderquad.xml', -'opt_val_hes.xml', -'luratio.xml' -]; -var list_down0 = [ -'lu_ratio.cpp.xml' -]; -var list_current0 = [ -'luratio.xml#Syntax', -'luratio.xml#Description', -'luratio.xml#Include', -'luratio.xml#Matrix Storage', -'luratio.xml#sign', -'luratio.xml#ip', -'luratio.xml#jp', -'luratio.xml#LU', -'luratio.xml#LU.A', -'luratio.xml#LU.P', -'luratio.xml#LU.L', -'luratio.xml#LU.U', -'luratio.xml#LU.Factor', -'luratio.xml#LU.Determinant', -'luratio.xml#ratio', -'luratio.xml#ratio.Purpose', -'luratio.xml#SizeVector', -'luratio.xml#ADvector', -'luratio.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-2018.00.00.0/doc/lu_solve.cpp.xml cppad-2019.02.00.0/doc/lu_solve.cpp.xml --- cppad-2018.00.00.0/doc/lu_solve.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/lu_solve.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ - - - -LuSolve With Complex Arguments: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -lu_solve.cppHeadings

- - - -
LuSolve With Complex Arguments: Example and Test
-

-# include <cppad/utility/lu_solve.hpp>       // for CppAD::LuSolve
-# include <cppad/utility/near_equal.hpp>     // for CppAD::NearEqual
-# include <cppad/utility/vector.hpp>  // for CppAD::vector
-# include <complex>               // for std::complex
-
-typedef std::complex<double> Complex;    // define the Complex type
-bool LuSolve(void)
-{     bool  ok = true;
-     using namespace CppAD;
-
-     size_t   n = 3;           // number rows in A and B
-     size_t   m = 2;           // number columns in B, X and S
-
-     // A is an n by n matrix, B, X, and S are n by m matrices
-     CppAD::vector<Complex> A(n * n), B(n * m), X(n * m) , S(n * m);
-
-     Complex  logdet;          // log of determinant of A
-     int      signdet;         // zero if A is singular
-     Complex  det;             // determinant of A
-     size_t   i, j, k;         // some temporary indices
-
-     // set A equal to the n by n Hilbert Matrix
-     for(i = 0; i < n; i++)
-          for(j = 0; j < n; j++)
-               A[i * n + j] = 1. / (double) (i + j + 1);
-
-     // set S to the solution of the equation we will solve
-     for(j = 0; j < n; j++)
-          for(k = 0; k < m; k++)
-               S[ j * m + k ] = Complex(double(j), double(j + k));
-
-     // set B = A * S
-     size_t ik;
-     Complex sum;
-     for(k = 0; k < m; k++)
-     {     for(i = 0; i < n; i++)
-          {     sum = 0.;
-               for(j = 0; j < n; j++)
-                    sum += A[i * n + j] * S[j * m + k];
-               B[i * m + k] = sum;
-          }
-     }
-
-     // solve the equation A * X = B and compute determinant of A
-     signdet = CppAD::LuSolve(n, m, A, B, X, logdet);
-     det     = Complex( signdet ) * exp( logdet );
-
-     double cond  = 4.62963e-4;       // condition number of A when n = 3
-     double determinant = 1. / 2160.; // determinant of A when n = 3
-     double delta = 1e-14 / cond;     // accuracy expected in X
-
-     // check determinant
-     ok &= CppAD::NearEqual(det, determinant, delta, delta);
-
-     // check solution
-     for(ik = 0; ik < n * m; ik++)
-          ok &= CppAD::NearEqual(X[ik], S[ik], delta, delta);
-
-     return ok;
-}
-
-
Input File: example/utility/lu_solve.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_lu_solve.cpp_xml.js cppad-2019.02.00.0/doc/_lu_solve.cpp_xml.js --- cppad-2018.00.00.0/doc/_lu_solve.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lu_solve.cpp_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', -'utility.xml', -'ludetandsolve.xml', -'lusolve.xml', -'lu_solve.cpp.xml' -]; -var list_down3 = [ -'errorhandler.xml', -'nearequal.xml', -'speed_test.xml', -'speedtest.xml', -'time_test.xml', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down2 = [ -'lusolve.xml', -'lufactor.xml', -'luinvert.xml' -]; -var list_down1 = [ -'lu_solve.cpp.xml', -'lu_solve.hpp.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-2018.00.00.0/doc/lu_solve.hpp.xml cppad-2019.02.00.0/doc/lu_solve.hpp.xml --- cppad-2018.00.00.0/doc/lu_solve.hpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/lu_solve.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,213 +0,0 @@ - - - -Source: LuSolve - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -lu_solve.hppHeadings

-
Source: LuSolve
-# ifndef CPPAD_LU_SOLVE_HPP -
-
# define CPPAD_LU_SOLVE_HPP - -
# include <complex>
-# include <vector>
-
-// link exp for float and double cases
-# include <cppad/base_require.hpp>
-
-# include <cppad/core/cppad_assert.hpp>
-# include <cppad/utility/check_simple_vector.hpp>
-# include <cppad/utility/check_numeric_type.hpp>
-# include <cppad/utility/lu_factor.hpp>
-# include <cppad/utility/lu_invert.hpp>
-
-namespace CppAD { // BEGIN CppAD namespace
-
-// LeqZero
-template <typename Float>
-inline bool LeqZero(const Float &x)
-{     return x <= Float(0); }
-inline bool LeqZero( const std::complex<double> &x )
-{     return x == std::complex<double>(0); }
-inline bool LeqZero( const std::complex<float> &x )
-{     return x == std::complex<float>(0); }
-
-// LuSolve
-template <typename Float, typename FloatVector>
-int LuSolve(
-     size_t             n      ,
-     size_t             m      ,
-     const FloatVector &A      ,
-     const FloatVector &B      ,
-     FloatVector       &X      ,
-     Float        &logdet      )
-{
-     // check numeric type specifications
-     CheckNumericType<Float>();
-
-     // check simple vector class specifications
-     CheckSimpleVector<Float, FloatVector>();
-
-     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<size_t> ip(n);
-     std::vector<size_t> 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
-# endif -
- - -
Input File: omh/lu_solve_hpp.omh - - - diff -Nru cppad-2018.00.00.0/doc/_lu_solve.hpp_xml.js cppad-2019.02.00.0/doc/_lu_solve.hpp_xml.js --- cppad-2018.00.00.0/doc/_lu_solve.hpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lu_solve.hpp_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', -'utility.xml', -'ludetandsolve.xml', -'lusolve.xml', -'lu_solve.hpp.xml' -]; -var list_down3 = [ -'errorhandler.xml', -'nearequal.xml', -'speed_test.xml', -'speedtest.xml', -'time_test.xml', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down2 = [ -'lusolve.xml', -'lufactor.xml', -'luinvert.xml' -]; -var list_down1 = [ -'lu_solve.cpp.xml', -'lu_solve.hpp.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-2018.00.00.0/doc/lusolve.xml cppad-2019.02.00.0/doc/lusolve.xml --- cppad-2018.00.00.0/doc/lusolve.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/lusolve.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,644 +0,0 @@ - - - -Compute Determinant and Solve Linear Equations - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Compute Determinant and Solve Linear Equations
-
-
Syntax -
- - include <cppad/utility/lu_solve.hpp>
-
- -signdet = LuSolve(nmABXlogdet) - - - -
-
-Description -
-Use an LU factorization of the matrix -A - to -compute its determinant -and solve for -X - in the linear of equation - - -A -* -X -= -B - - -where -A - is an - -n - by -n - matrix, - -X - is an - -n - by -m - matrix, and - -B - is an - -n -x -m - - - matrix. - -
-
-Include -
-The file cppad/lu_solve.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-Factor and Invert -
-This routine is an easy to user interface to -LuFactor - and LuInvert - for computing determinants and -solutions of linear equations. -These separate routines should be used if -one right hand side -B - -depends on the solution corresponding to another -right hand side (with the same value of -A -). -In this case only one call to LuFactor is required -but there will be multiple calls to LuInvert. - - -
-
-Matrix Storage -
-All matrices are stored in row major order. -To be specific, if - -Y - - - is a vector -that contains a - -p - - - by - -q - - - matrix, -the size of - -Y - - - must be equal to - -p -* -q - - - and for - - -i -= -0 -, - -, -p --1 - - -, - - -j -= -0 -, - -, -q --1 - - -, - - -Y -i -, -j - - -= -Y -[ -i -* -q -+ -j -] - - -
-signdet -
-The return value -signdet - is a int value -that specifies the sign factor for the determinant of -A -. -This determinant of -A - is zero if and only if -signdet - -is zero. - -
-
-n -
-The argument -n - has type size_t -and specifies the number of rows in the matrices - -A -, - -X -, -and -B -. -The number of columns in -A - is also equal to -n -. - -
-
-m -
-The argument -m - has type size_t -and specifies the number of columns in the matrices - -X - -and -B -. -If -m - is zero, -only the determinant of -A - is computed and -the matrices -X - and -B - are not used. - -
-
-A -
-The argument -A - has the prototype - -
-     const 
FloatVector &A
-
-and the size of -A - must equal - -n -* -n - - - -(see description of FloatVector - below). -This is the - -n - - - by -n - matrix that -we are computing the determinant of -and that defines the linear equation. - -
-
-B -
-The argument -B - has the prototype - -
-     const 
FloatVector &B
-
-and the size of -B - must equal - -n -* -m - - - -(see description of FloatVector - below). -This is the - -n - - - by -m - matrix that -defines the right hand side of the linear equations. -If -m - is zero, -B - is not used. - -
-
-X -
-The argument -X - has the prototype - -
-     
FloatVector &X
-
-and the size of -X - must equal - -n -* -m - - - -(see description of FloatVector - below). -The input value of -X - does not matter. -On output, the elements of -X - contain the solution -of the equation we wish to solve -(unless -signdet - is equal to zero). -If -m - is zero, -X - is not used. - -
-
-logdet -
-The argument -logdet - has prototype - -
-     
Float &logdet
-
-On input, the value of -logdet - does not matter. -On output, it has been set to the -log of the determinant of -A - -(but not quite). -To be more specific, -the determinant of -A - is given by the formula - -
-     
det = signdet * exp( logdet )
-
-This enables LuSolve to use logs of absolute values -in the case where -Float - corresponds to a real number. - -
-
-Float -
-The type -Float - must satisfy the conditions -for a NumericType - type. -The routine CheckNumericType - will generate an error message -if this is not the case. -In addition, the following operations must be defined for any pair -of -Float - objects -x - and -y -: - - -
- -Operation - Description
- - -log(x) - - - returns the logarithm of -x - as a -Float - object -
-
-FloatVector -
-The type -FloatVector - must be a SimpleVector - class with -elements of type Float -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-LeqZero -
-Including the file lu_solve.hpp defines the template function - -
-     template <typename 
Float>
-     bool LeqZero<
Float>(const Float &x)
-
-in the CppAD namespace. -This function returns true if -x - is less than or equal to zero -and false otherwise. -It is used by LuSolve to avoid taking the log of -zero (or a negative number if -Float - corresponds to real numbers). -This template function definition assumes that the operator -<= is defined for -Float - objects. -If this operator is not defined for your use of -Float -, -you will need to specialize this template so that it works for your -use of LuSolve. -
-
-
Complex numbers do not have the operation or <= defined. -In addition, in the complex case, -one can take the log of a negative number. -The specializations - -
-     bool LeqZero< std::complex<float> > (const std::complex<float> &
x)
-     bool LeqZero< std::complex<double> >(const std::complex<double> &
x)
-
-are defined by including lu_solve.hpp. -These return true if -x - is zero and false otherwise. - -
-
-AbsGeq -
-Including the file lu_solve.hpp defines the template function - -
-     template <typename 
Float>
-     bool AbsGeq<
Float>(const Float &x, const Float &y)
-
-If the type -Float - does not support the <= operation -and it is not std::complex<float> or std::complex<double>, -see the documentation for AbsGeq in LuFactor -. - - -
-
-Example -
-The file -lu_solve.cpp - -contains an example and test of using this routine. -It returns true if it succeeds and false otherwise. - -
-
-Source -
-The file lu_solve.hpp - contains the -current source code that implements these specifications. - - -
Input File: cppad/utility/lu_solve.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_lusolve_xml.js cppad-2019.02.00.0/doc/_lusolve_xml.js --- cppad-2018.00.00.0/doc/_lusolve_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lusolve_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'ludetandsolve.xml', -'lusolve.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'lusolve.xml', -'lufactor.xml', -'luinvert.xml' -]; -var list_down0 = [ -'lu_solve.cpp.xml', -'lu_solve.hpp.xml' -]; -var list_current0 = [ -'lusolve.xml#Syntax', -'lusolve.xml#Description', -'lusolve.xml#Include', -'lusolve.xml#Factor and Invert', -'lusolve.xml#Matrix Storage', -'lusolve.xml#signdet', -'lusolve.xml#n', -'lusolve.xml#m', -'lusolve.xml#A', -'lusolve.xml#B', -'lusolve.xml#X', -'lusolve.xml#logdet', -'lusolve.xml#Float', -'lusolve.xml#FloatVector', -'lusolve.xml#LeqZero', -'lusolve.xml#AbsGeq', -'lusolve.xml#Example', -'lusolve.xml#Source' -]; -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-2018.00.00.0/doc/lu_vec_ad.cpp.xml cppad-2019.02.00.0/doc/lu_vec_ad.cpp.xml --- cppad-2018.00.00.0/doc/lu_vec_ad.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/lu_vec_ad.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,409 +0,0 @@ - - - -Lu Factor and Solve with Recorded Pivoting - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Lu Factor and Solve with Recorded Pivoting
-
-
Syntax - -
- -int LuVecAD(
-     size_t 
n,
-     size_t 
m,
-     VecAD<
double> &Matrix,
-     VecAD<
double> &Rhs,
-     VecAD<
double> &Result,
-     AD<
double> &logdet)
- - - -
-
-Purpose -
-Solves the linear equation - - -Matrix -* -Result -= -Rhs - - -where -Matrix - is an - -n -× -n - - - matrix, - -Rhs - is an - -n -x -m - - - matrix, and - -Result - is an - -n -x -m - - - matrix. -
-
-
The routine LuSolve - uses an arbitrary vector type, -instead of VecAD -, -to hold its elements. -The pivoting operations for a ADFun object -corresponding to an LuVecAD solution -will change to be optimal for the matrix being factored. -
-
-
It is often the case that -LuSolve is faster than LuVecAD when LuSolve -uses a simple vector class with -elements of type double -, -but the corresponding ADFun - objects have a fixed -set of pivoting operations. - -
-
-Storage Convention -
-The matrices stored in row major order. -To be specific, if - -A - - - contains the vector storage for an - - -n -x -m - - - matrix, - - -i - - - is between zero and - -n --1 - - -, -and - -j - - - is between zero and - -m --1 - - -, - - -A -i -, -j - - -= -A -[ -i -* -m -+ -j -] - - -(The length of - -A - - - must be equal to - -n -* -m - - -.) - -
-
-n -
-is the number of rows in - -Matrix -, - -Rhs -, -and -Result -. - -
-
-m -
-is the number of columns in - -Rhs - -and -Result -. -It is ok for -m - to be zero which is reasonable when -you are only interested in the determinant of -Matrix -. - - -
-
-Matrix -
-On input, this is an - - -n -× -n - - - matrix containing the variable coefficients for -the equation we wish to solve. -On output, the elements of -Matrix - have been overwritten -and are not specified. - -
-
-Rhs -
-On input, this is an - - -n -× -m - - - matrix containing the right hand side -for the equation we wish to solve. -On output, the elements of -Rhs - have been overwritten -and are not specified. -If -m - is zero, -Rhs - is not used. - -
-
-Result -
-On input, this is an - - -n -× -m - - - matrix and the value of its elements do not matter. -On output, the elements of -Rhs - contain the solution -of the equation we wish to solve -(unless the value returned by LuVecAD is equal to zero). -If -m - is zero, -Result - is not used. - -
-
-logdet -
-On input, the value of -logdet - does not matter. -On output, it has been set to the -log of the determinant of -Matrix - (but not quite). -To be more specific, -if -signdet - is the value returned by LuVecAD, -the determinant of -Matrix - is given by the formula - - -det -= -signdet -exp -( -logdet -) - - -This enables LuVecAD to use logs of absolute values. - - -
-
-Example - -
-The file -lu_vec_ad_ok.cpp - -contains an example and test of LuVecAD. -It returns true if it succeeds and false otherwise. - - - -
Input File: example/general/lu_vec_ad.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_lu_vec_ad.cpp_xml.js cppad-2019.02.00.0/doc/_lu_vec_ad.cpp_xml.js --- cppad-2018.00.00.0/doc/_lu_vec_ad.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lu_vec_ad.cpp_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', -'example.xml', -'exampleutility.xml', -'lu_vec_ad.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'general.cpp.xml', -'speed_example.cpp.xml', -'lu_vec_ad.cpp.xml' -]; -var list_down0 = [ -'lu_vec_ad_ok.cpp.xml' -]; -var list_current0 = [ -'lu_vec_ad.cpp.xml#Syntax', -'lu_vec_ad.cpp.xml#Purpose', -'lu_vec_ad.cpp.xml#Storage Convention', -'lu_vec_ad.cpp.xml#n', -'lu_vec_ad.cpp.xml#m', -'lu_vec_ad.cpp.xml#Matrix', -'lu_vec_ad.cpp.xml#Rhs', -'lu_vec_ad.cpp.xml#Result', -'lu_vec_ad.cpp.xml#logdet', -'lu_vec_ad.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-2018.00.00.0/doc/lu_vec_ad_ok.cpp.xml cppad-2019.02.00.0/doc/lu_vec_ad_ok.cpp.xml --- cppad-2018.00.00.0/doc/lu_vec_ad_ok.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/lu_vec_ad_ok.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,207 +0,0 @@ - - - -Lu Factor and Solve With Recorded Pivoting: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -lu_vec_ad_ok.cppHeadings

- - - -
Lu Factor and Solve With Recorded Pivoting: Example and Test
-

-# include <cppad/cppad.hpp>
-# include "lu_vec_ad.hpp"
-# include <cppad/speed/det_by_minor.hpp>
-
-bool LuVecADOk(void)
-{     bool  ok = true;
-
-     using namespace CppAD;
-     typedef AD<double> ADdouble;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     size_t              n = 3;
-     size_t              m = 2;
-     double a1[] = {
-          3., 0., 0., // (1,1) is first  pivot
-          1., 2., 1., // (2,2) is second pivot
-          1., 0., .5  // (3,3) is third  pivot
-     };
-     double a2[] = {
-          1., 2., 1., // (1,2) is second pivot
-          3., 0., 0., // (2,1) is first  pivot
-          1., 0., .5  // (3,3) is third  pivot
-     };
-     double rhs[] = {
-          1., 3.,
-          2., 2.,
-          3., 1.
-     };
-
-     VecAD<double>       Copy    (n * n);
-     VecAD<double>       Rhs     (n * m);
-     VecAD<double>       Result  (n * m);
-     ADdouble            logdet;
-     ADdouble            signdet;
-
-     // routine for checking determinants using expansion by minors
-     det_by_minor<ADdouble> Det(n);
-
-     // matrix we are computing the determinant of
-     CPPAD_TESTVECTOR(ADdouble) A(n * n);
-
-     // dependent variable values
-     CPPAD_TESTVECTOR(ADdouble) Y(1 + n * m);
-
-     size_t  i;
-     size_t  j;
-     size_t  k;
-
-     // Original matrix
-     for(i = 0; i < n * n; i++)
-          A[i] = a1[i];
-
-     // right hand side
-     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);
-
-     // Copy the matrix
-     ADdouble index(0);
-     for(i = 0; i < n*n; i++)
-     {     Copy[index] = A[i];
-          index += 1.;
-     }
-
-     // Solve the equation
-     signdet = LuVecAD(n, m, Copy, Rhs, Result, logdet);
-
-     // Result is the first n * m dependent variables
-     index = 0.;
-     for(i = 0; i < n * m; i++)
-     {     Y[i] = Result[index];
-          index += 1.;
-     }
-
-     // Determinant is last component of the solution
-     Y[ n * m ] = signdet * exp( logdet );
-
-     // construct f: A -> Y
-     ADFun<double> f(A, Y);
-
-     // check determinant using minors routine
-     ADdouble determinant = Det( A );
-     ok &= NearEqual(Y[n * m], determinant, eps99, eps99);
-
-
-     // Check solution of Rhs = A * Result
-     double sum;
-     for(k = 0; k < m; k++)
-     {     for(i = 0; i < n; i++)
-          {     sum = 0.;
-               for(j = 0; j < n; j++)
-                    sum += a1[i * n + j] * Value( Y[j * m + k] );
-               ok &= NearEqual( rhs[i * m + k], sum, eps99, eps99);
-          }
-     }
-
-     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), eps99, eps99);
-
-     // Check solution of Rhs = A2 * Result
-     for(k = 0; k < m; k++)
-     {     for(i = 0; i < n; i++)
-          {     sum = 0.;
-               for(j = 0; j < n; j++)
-                    sum += a2[i * n + j] * y2[j * m + k];
-               ok &= NearEqual( rhs[i * m + k], sum, eps99, eps99);
-          }
-     }
-
-     return ok;
-}
-
-
-
Input File: example/general/lu_vec_ad_ok.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_lu_vec_ad_ok.cpp_xml.js cppad-2019.02.00.0/doc/_lu_vec_ad_ok.cpp_xml.js --- cppad-2018.00.00.0/doc/_lu_vec_ad_ok.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_lu_vec_ad_ok.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'example.xml', -'exampleutility.xml', -'lu_vec_ad.cpp.xml', -'lu_vec_ad_ok.cpp.xml' -]; -var list_down3 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down2 = [ -'general.cpp.xml', -'speed_example.cpp.xml', -'lu_vec_ad.cpp.xml' -]; -var list_down1 = [ -'lu_vec_ad_ok.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-2018.00.00.0/doc/main_compare_c.xml cppad-2019.02.00.0/doc/main_compare_c.xml --- cppad-2018.00.00.0/doc/main_compare_c.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/main_compare_c.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ - - - -Main Program For Comparing C and C++ Speed - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -main_compare_c - -

-
Main Program For Comparing C and C++ Speed
-
-Source Code - -
int main(void)
-{     bool flag;
-     size_t i;
-
-     random_seed(123);
-
-     printf("correct_det_by_minor: ");
-     flag = correct_det_by_minor();
-     if( flag )
-          printf("OK\n");
-     else     printf("Error\n");
-
-     for(i = 0; i < 5; i++)
-     {     double time_min = 1.0;
-          size_t size     = 2 + i * 2;
-          int   i_size    = (int) size;
-          printf("time_det_minor for %d x %d matrix = ", i_size, i_size);
-          printf("%g\n", time_det_by_minor(size, time_min) );
-     }
-
-     if( flag )
-          return 0;
-     return 1;
-}
- -
Input File: test_more/compare_c/det_by_minor.c - - - diff -Nru cppad-2018.00.00.0/doc/_main_compare_c_xml.js cppad-2019.02.00.0/doc/_main_compare_c_xml.js --- cppad-2018.00.00.0/doc/_main_compare_c_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_main_compare_c_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', -'compare_c.xml', -'main_compare_c.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', -'directory.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 = [ -'det_of_minor_c.xml', -'det_by_minor_c.xml', -'uniform_01_c.xml', -'correct_det_by_minor_c.xml', -'repeat_det_by_minor_c.xml', -'elapsed_seconds_c.xml', -'time_det_by_minor_c.xml', -'main_compare_c.xml' -]; -var list_current0 = [ -'main_compare_c.xml#Source Code' -]; -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-2018.00.00.0/doc/mat_sum_sq.cpp.xml cppad-2019.02.00.0/doc/mat_sum_sq.cpp.xml --- cppad-2018.00.00.0/doc/mat_sum_sq.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/mat_sum_sq.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,136 +0,0 @@ - - - -Sum of the Elements of the Square of a Matrix: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -mat_sum_sq.cppHeadings

- - - -
Sum of the Elements of the Square of a Matrix: Example and Test
-
# include <vector>
-# include <cstddef>
-# include <cppad/utility/vector.hpp>
-# include <cppad/speed/mat_sum_sq.hpp>
-
-bool mat_sum_sq()
-{     bool   ok = true;
-     double x_00, x_01, x_10, x_11, check;
-
-     // dimension of the matrices x, y, and the result z
-     size_t n = 2;
-     CppAD::vector<double> x(n * n), y(n * n), z(1);
-
-     // x = [ 1 2 ; 3 4 ]
-     x[0] = x_00 = 1.;
-     x[1] = x_01 = 2.;
-     x[2] = x_10 = 3.;
-     x[3] = x_11 = 4.;
-
-     // compute y = x * x and z = sum of elements in y
-     CppAD::mat_sum_sq(n, x, y, z);
-
-     // check y_00
-     check = x_00 * x_00 + x_01 * x_10;
-     ok   &= (check == y[0]);
-
-     // check y_01
-     check = x_00 * x_01 + x_01 * x_11;
-     ok   &= (check == y[1]);
-
-     // check y_10
-     check = x_10 * x_00 + x_11 * x_10;
-     ok   &= (check == y[2]);
-
-     // check y_11
-     check = x_10 * x_01 + x_11 * x_11;
-     ok   &= (check == y[3]);
-
-     // check z
-     check = y[0] + y[1] + y[2] + y[3];
-     ok   &= (check == z[0]);
-
-     return ok;
-}
-
-
Input File: speed/example/mat_sum_sq.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_mat_sum_sq.cpp_xml.js cppad-2019.02.00.0/doc/_mat_sum_sq.cpp_xml.js --- cppad-2018.00.00.0/doc/_mat_sum_sq.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_mat_sum_sq.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'mat_sum_sq.xml', -'mat_sum_sq.cpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'mat_sum_sq.cpp.xml', -'mat_sum_sq.hpp.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-2018.00.00.0/doc/mat_sum_sq.hpp.xml cppad-2019.02.00.0/doc/mat_sum_sq.hpp.xml --- cppad-2018.00.00.0/doc/mat_sum_sq.hpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/mat_sum_sq.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ - - - -Source: mat_sum_sq - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -mat_sum_sq.hppHeadings

-
Source: mat_sum_sq
-# ifndef CPPAD_MAT_SUM_SQ_HPP -
-
# define CPPAD_MAT_SUM_SQ_HPP - -
# include <cstddef>
-//
-namespace CppAD {
-     template <class Vector>
-     void mat_sum_sq(size_t n, Vector& x , Vector& y , Vector& z)
-     {     size_t i, j, k;
-          // Very simple computation of y = x * x for speed comparison
-          for(i = 0; i < n; i++)
-          {     for(j = 0; j < n; j++)
-               {     y[i * n + j] = 0.;
-                    for(k = 0; k < n; k++)
-                         y[i * n + j] += x[i * n + k] * x[k * n + j];
-               }
-          }
-          z[0] = 0.;
-          for(i = 0; i < n; i++)
-          {     for(j = 0; j < n; j++)
-                    z[0] += y[i * n + j];
-          }
-          return;
-     }
-
-}
-# endif -
- - -
Input File: omh/mat_sum_sq_hpp.omh - - - diff -Nru cppad-2018.00.00.0/doc/_mat_sum_sq.hpp_xml.js cppad-2019.02.00.0/doc/_mat_sum_sq.hpp_xml.js --- cppad-2018.00.00.0/doc/_mat_sum_sq.hpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_mat_sum_sq.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'mat_sum_sq.xml', -'mat_sum_sq.hpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'mat_sum_sq.cpp.xml', -'mat_sum_sq.hpp.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-2018.00.00.0/doc/mat_sum_sq.xml cppad-2019.02.00.0/doc/mat_sum_sq.xml --- cppad-2018.00.00.0/doc/mat_sum_sq.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/mat_sum_sq.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,427 +0,0 @@ - - - -Sum Elements of a Matrix Times Itself - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Sum Elements of a Matrix Times Itself
-
-Syntax - -
- -# include <cppad/speed/mat_sum_sq.hpp>
-
- -mat_sum_sq(nxyz) - - -
-
-Purpose -
-This routine is intended for use with the matrix multiply speed tests; -to be specific, it computes - - - -y -i -, -j - - - -= - - -k -= -0 - -n --1 - - -x -i -, -k - - -x -k -, -j - - - -z -0 - - -= - - -i -= -0 - -n --1 - - - -j -= -0 - -n --1 - - -y -i -, -j - - - - - -see link_mat_mul -. - -
-
-Inclusion -
-The template function mat_sum_sq is defined in the CppAD -namespace by including -the file cppad/speed/mat_sum_sq.hpp -(relative to the CppAD distribution directory). - -
-
-n -
-This argument has prototype - -
-     size_t 
n
-
-It specifies the size of the matrices. - -
-
-x -
-The argument -x - has prototype - -
-     const 
Vector &x
-
-and -x.size() == n * n -. -It contains the elements of - -x - - - in row major order; i.e., - - -x -i -, -j - - -= -x -[ -i -* -n -+ -j -] - - -
-y -
-The argument -y - has prototype - -
-     
Vectory
-
-and -y.size() == n * n -. -The input value of its elements does not matter. -Upon return, - - - -y -i -, -j - - - -= - - -k -= -0 - -n --1 - - -x -i -, -k - - -x -k -, -j - - - -y -[ -i -* -n -+ -j -] - -= - -y -i -, -j - - - - - -
-z -
-The argument -d - has prototype - -
-     
Vectorz
-
-. -The input value of its element does not matter. -Upon return - - - -z -0 - - -= - - -i -= -0 - -n --1 - - - -j -= -0 - -n - -y -i -, -j - - - -z -[ -0 -] - -= - -z -0 - - - - -
-Vector -
-The type -Vector - is any -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 -and to a double value. - - - - -
-
-Example -
-The file -mat_sum_sq.cpp - -contains an example and test of mat_sum_sq.hpp. -It returns true if it succeeds and false otherwise. - -
-
-Source Code -
-The file -mat_sum_sq.hpp - -contains the source for this template function. - - -
Input File: cppad/speed/mat_sum_sq.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_mat_sum_sq_xml.js cppad-2019.02.00.0/doc/_mat_sum_sq_xml.js --- cppad-2018.00.00.0/doc/_mat_sum_sq_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_mat_sum_sq_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'mat_sum_sq.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down0 = [ -'mat_sum_sq.cpp.xml', -'mat_sum_sq.hpp.xml' -]; -var list_current0 = [ -'mat_sum_sq.xml#Syntax', -'mat_sum_sq.xml#Purpose', -'mat_sum_sq.xml#Inclusion', -'mat_sum_sq.xml#n', -'mat_sum_sq.xml#x', -'mat_sum_sq.xml#y', -'mat_sum_sq.xml#z', -'mat_sum_sq.xml#Vector', -'mat_sum_sq.xml#Example', -'mat_sum_sq.xml#Source Code' -]; -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-2018.00.00.0/doc/memory_leak.xml cppad-2019.02.00.0/doc/memory_leak.xml --- cppad-2018.00.00.0/doc/memory_leak.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/memory_leak.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,261 +0,0 @@ - - - -Memory Leak Detection - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -memory_leak - -

-
Memory Leak Detection
-
-Deprecated 2012-04-06 -
-This routine has been deprecated. -You should instead use the routine ta_free_all -. - -
-
-Syntax - -
- -# include <cppad/utility/memory_leak.hpp>
-
- -flag = memory_leak()
-
- -flag = memory_leak(add_static) - - -
-
-Purpose -
-This routine checks that the are no memory leaks -caused by improper use of thread_alloc - memory allocator. -The deprecated memory allocator TrackNewDel - is also checked. -Memory errors in the deprecated omp_alloc - allocator are -reported as being in thread_alloc. - -
-
-thread -
-It is assumed that in_parallel() - is false -and thread_num - is zero when -memory_leak is called. - -
-
-add_static -
-This argument has prototype - -
-     size_t 
add_static
-
-and its default value is zero. -Static variables hold onto memory forever. -If the argument -add_static - is present (and non-zero), -memory_leak adds this amount of memory to the -inuse - sum that corresponds to -static variables in the program. -A call with -add_static - should be make after -a routine that has static variables which -use get_memory - to allocate memory. -The value of -add_static - should be the difference of - -
-     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. - -
-
-flag -
-The return value -flag - has prototype - -
-     bool 
flag
-
-If -add_static - is non-zero, -the return value for memory_leak is false. -Otherwise, the return value for memory_leak should be false -(indicating that the only allocated memory corresponds to static variables). - -
-
-inuse -
-It is assumed that, when memory_leak is called, -there should not be any memory -inuse - or omp_inuse - for any thread -(except for inuse memory corresponding to static variables). -If there is, a message is printed and memory_leak returns false. - -
-
-available -
-It is assumed that, when memory_leak is called, -there should not be any memory -available - or omp_available - for any thread; -i.e., it all has been returned to the system. -If there is memory still available for any thread, -memory_leak returns false. - -
-
-TRACK_COUNT -
-It is assumed that, when memory_leak is called, -TrackCount - will return a zero value. -If it returns a non-zero value, -memory_leak returns false. - -
-
-Error Message -
-If this is the first call to 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. - - -
Input File: cppad/utility/memory_leak.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_memory_leak_xml.js cppad-2019.02.00.0/doc/_memory_leak_xml.js --- cppad-2018.00.00.0/doc/_memory_leak_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_memory_leak_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'memory_leak.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', -'directory.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', -'autotools.xml' -]; -var list_current0 = [ -'memory_leak.xml#Deprecated 2012-04-06', -'memory_leak.xml#Syntax', -'memory_leak.xml#Purpose', -'memory_leak.xml#thread', -'memory_leak.xml#add_static', -'memory_leak.xml#flag', -'memory_leak.xml#inuse', -'memory_leak.xml#available', -'memory_leak.xml#TRACK_COUNT', -'memory_leak.xml#Error Message' -]; -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-2018.00.00.0/doc/microsoft_timer.xml cppad-2019.02.00.0/doc/microsoft_timer.xml --- cppad-2018.00.00.0/doc/microsoft_timer.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/microsoft_timer.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,141 +0,0 @@ - - - -Microsoft Version of Elapsed Number of Seconds - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -microsoft_timer - -

- - - -
Microsoft Version of Elapsed Number of Seconds
-
-Syntax - -
- -s = microsoft_timer() - - -
-
-Purpose -
-This routine is accurate to within .02 seconds -(see elapsed_seconds - which uses this routine when -the preprocessor symbol _MSC_VER is defined). -It does not necessary work for time intervals that are greater than a day. -It uses ::GetSystemTime for timing. - -
-
-s -
-is a double equal to the -number of seconds since the first call to microsoft_timer. - -
-
-Linking -
-The source code for this routine is located in -speed/src/microsoft_timer.cpp. -The preprocessor symbol _MSC_VER must -be defined, or this routine is not compiled. - - -
Input File: speed/src/microsoft_timer.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_microsoft_timer_xml.js cppad-2019.02.00.0/doc/_microsoft_timer_xml.js --- cppad-2018.00.00.0/doc/_microsoft_timer_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_microsoft_timer_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', -'speed.xml', -'speed_main.xml', -'microsoft_timer.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'link_det_lu.xml', -'link_det_minor.xml', -'link_mat_mul.xml', -'link_ode.xml', -'link_poly.xml', -'link_sparse_hessian.xml', -'link_sparse_jacobian.xml', -'microsoft_timer.xml' -]; -var list_current0 = [ -'microsoft_timer.xml#Syntax', -'microsoft_timer.xml#Purpose', -'microsoft_timer.xml#s', -'microsoft_timer.xml#Linking' -]; -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-2018.00.00.0/doc/min_nso_linear.cpp.xml cppad-2019.02.00.0/doc/min_nso_linear.cpp.xml --- cppad-2018.00.00.0/doc/min_nso_linear.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/min_nso_linear.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,258 +0,0 @@ - - - -abs_normal min_nso_linear: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -min_nso_linear.cpp - -

- - - -
abs_normal min_nso_linear: Example and Test
-
-Purpose -
-We minimize the function - - -f -: -R - -3 - - -R - - - - defined by - - - -f -( -x -0 - -, -x -1 - -, -x -2 - -) - -= - -x -0 -2 - -+ -2 -( -x -0 - -+ -x -1 - -) -2 - -+ -| -x -2 - -| - - - -
-Discussion -
-This routine uses abs_min_linear - which uses lp_box -, -a linear programming algorithm. -It is mean to be compared with min_nso_quad.cpp - which uses -a quadratic programing algorithm for the same problem. -To see this comparison, set -level = 1 - is both examples. - - -
-
-Source - -

-# include <cppad/cppad.hpp>
-# include "min_nso_linear.hpp"
-
-bool min_nso_linear(void)
-{     bool ok = true;
-     //
-     using CppAD::AD;
-     using CppAD::ADFun;
-     //
-     typedef CPPAD_TESTVECTOR(size_t)       s_vector;
-     typedef CPPAD_TESTVECTOR(double)       d_vector;
-     typedef CPPAD_TESTVECTOR( AD<double> ) ad_vector;
-     //
-     size_t level = 0;    // level of tracing
-     size_t n     = 3;    // size of x
-     size_t m     = 1;    // size of y
-     size_t s     = 1;    // number of data points and absolute values
-     //
-     // start recording the function f(x)
-     ad_vector ax(n), ay(m);
-     for(size_t j = 0; j < n; j++)
-          ax[j] = double(j + 1);
-     Independent( ax );
-     //
-     ay[0]  =  ax[0] * ax[0];
-     ay[0] += 2.0 * (ax[0] + ax[1]) * (ax[0] + ax[1]);
-     ay[0] += fabs( ax[2] );
-     ADFun<double> f(ax, ay);
-     //
-     // create its abs_normal representation in g, a
-     ADFun<double> g, a;
-     f.abs_normal_fun(g, a);
-
-     // check dimension of domain and range space for g
-     ok &= g.Domain() == n + s;
-     ok &= g.Range()  == m + s;
-
-     // check dimension of domain and range space for a
-     ok &= a.Domain() == n;
-     ok &= a.Range()  == s;
-
-     // epsilon
-     d_vector epsilon(2);
-     double eps = 1e-3;
-     epsilon[0] = eps;
-     epsilon[1] = eps;
-
-     // maxitr
-     s_vector maxitr(3);
-     maxitr[0] = 100;
-     maxitr[1] = 20;
-     maxitr[2] = 20;
-
-     // b_in
-     double b_in = 1.0;
-
-     // call min_nso_linear
-     d_vector x_in(n), x_out(n);
-     for(size_t j = 0; j < n; j++)
-          x_in[j]  = double(j + 1);
-
-     //
-     ok &= CppAD::min_nso_linear(
-          level, g, a, epsilon, maxitr, b_in, x_in, x_out
-     );
-     //
-     for(size_t j = 0; j < n; j++)
-          ok &= std::fabs( x_out[j] ) < eps;
-
-     return ok;
-}
- -
Input File: example/abs_normal/min_nso_linear.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_min_nso_linear.cpp_xml.js cppad-2019.02.00.0/doc/_min_nso_linear.cpp_xml.js --- cppad-2018.00.00.0/doc/_min_nso_linear.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_min_nso_linear.cpp_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', -'adfun.xml', -'abs_normal.xml', -'min_nso_linear.xml', -'min_nso_linear.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'min_nso_linear.cpp.xml', -'min_nso_linear.hpp.xml' -]; -var list_current0 = [ -'min_nso_linear.cpp.xml#Purpose', -'min_nso_linear.cpp.xml#Discussion', -'min_nso_linear.cpp.xml#Source' -]; -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-2018.00.00.0/doc/min_nso_linear.hpp.xml cppad-2019.02.00.0/doc/min_nso_linear.hpp.xml --- cppad-2018.00.00.0/doc/min_nso_linear.hpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/min_nso_linear.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,289 +0,0 @@ - - - -min_nso_linear Source Code - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -min_nso_linear.hppHeadings

-
min_nso_linear Source Code
-
namespace {
-     CPPAD_TESTVECTOR(double) min_nso_linear_join(
-          const CPPAD_TESTVECTOR(double)& x ,
-          const CPPAD_TESTVECTOR(double)& u )
-     {     size_t n = x.size();
-          size_t s = u.size();
-          CPPAD_TESTVECTOR(double) xu(n + s);
-          for(size_t j = 0; j < n; j++)
-               xu[j] = x[j];
-          for(size_t j = 0; j < s; j++)
-               xu[n + j] = u[j];
-          return xu;
-     }
-}
-
-// BEGIN C++
-namespace CppAD { // BEGIN_CPPAD_NAMESPACE
-
-// BEGIN PROTOTYPE
-template <class DblVector, class SizeVector>
-bool min_nso_linear(
-     size_t           level     ,
-     ADFun<double>&   g         ,
-     ADFun<double>&   a         ,
-     const DblVector& epsilon   ,
-     SizeVector       maxitr    ,
-     double           b_in      ,
-     const DblVector& x_in      ,
-     DblVector&       x_out     )
-// END PROTOTYPE
-{
-     using std::fabs;
-     //
-     // number of absolute value terms
-     size_t s  = a.Range();
-     //
-     // size of domain for f
-     size_t n  = g.Domain() - s;
-     //
-     // size of range space for f
-     size_t m = g.Range() - s;
-     //
-     CPPAD_ASSERT_KNOWN(
-          level <= 5,
-          "min_nso_linear: level is not less that or equal 5"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(epsilon.size()) == 2,
-          "min_nso_linear: size of epsilon not equal to 2"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(maxitr.size()) == 3,
-          "min_nso_linear: size of maxitr not equal to 3"
-     );
-     CPPAD_ASSERT_KNOWN(
-          g.Domain() > s && g.Range() > s,
-          "min_nso_linear: g, a is not an abs-normal representation"
-     );
-     CPPAD_ASSERT_KNOWN(
-          m == 1,
-          "min_nso_linear: m is not equal to 1"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(x_in.size()) == n,
-          "min_nso_linear: size of x_in not equal to n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(x_out.size()) == n,
-          "min_nso_linear: size of x_out not equal to n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          epsilon[0] < b_in,
-          "min_nso_linear: b_in <= epsilon[0]"
-     );
-     if( level > 0 )
-     {     std::cout << "start min_nso_linear\n";
-          std::cout << "b_in = " << b_in << "\n";
-          CppAD::abs_print_mat("x_in", n, 1, x_in);
-     }
-     // level in abs_min_linear sub-problem
-     size_t level_tilde = 0;
-     if( level > 0 )
-          level_tilde = level - 1;
-     //
-     // maxitr in abs_min_linear sub-problem
-     SizeVector maxitr_tilde(2);
-     maxitr_tilde[0] = maxitr[1];
-     maxitr_tilde[1] = maxitr[2];
-     //
-     // epsilon in abs_min_linear sub-problem
-     DblVector eps_tilde(2);
-     eps_tilde[0] = epsilon[0] / 10.;
-     eps_tilde[1] = epsilon[1] / 10.;
-     //
-     // current bound
-     double b_cur = b_in;
-     //
-     // initilaize the current x
-     x_out = x_in;
-     //
-     // value of a(x) at current x
-     DblVector a_cur = a.Forward(0, x_out);
-     //
-     // (x_out, a_cur)
-     DblVector xu_cur = min_nso_linear_join(x_out, a_cur);
-     //
-     // value of g[ x_cur, a_cur ]
-     DblVector g_cur = g.Forward(0, xu_cur);
-     //
-     for(size_t itr = 0; itr < maxitr[0]; itr++)
-     {
-          // Jacobian of g[ x_cur, a_cur ]
-          DblVector g_jac = g.Jacobian(xu_cur);
-          //
-          // bound in abs_min_linear sub-problem
-          DblVector bound_tilde(n);
-          for(size_t j = 0; j < n; j++)
-               bound_tilde[j] = b_cur;
-          //
-          DblVector delta_x(n);
-          bool ok = abs_min_linear(
-               level_tilde, n, m, s,
-               g_cur, g_jac, bound_tilde, eps_tilde, maxitr_tilde, delta_x
-          );
-          if( ! ok )
-          {     if( level > 0 )
-                    std::cout << "end min_nso_linear: abs_min_linear failed\n";
-               return false;
-          }
-          //
-          // new candidate value for x
-          DblVector x_new(n);
-          double max_delta_x = 0.0;
-          for(size_t j = 0; j < n; j++)
-          {     x_new[j] = x_out[j] + delta_x[j];
-               max_delta_x = std::max(max_delta_x, std::fabs( delta_x[j] ) );
-          }
-          //
-          if( max_delta_x < b_cur && max_delta_x < epsilon[0] )
-          {     if( level > 0 )
-                    std::cout << "end min_nso_linear: delta_x is near zero\n";
-               return true;
-          }
-          // value of abs-normal approximation at minimizer
-          DblVector g_tilde = CppAD::abs_eval(n, m, s, g_cur, g_jac, delta_x);
-          //
-          double derivative = (g_tilde[0] - g_cur[0]) / max_delta_x;
-          CPPAD_ASSERT_UNKNOWN( derivative <= 0.0 )
-          if( - epsilon[1] < derivative )
-          {     if( level > 0 )
-                    std::cout << "end min_nso_linear: derivative near zero\n";
-               return true;
-          }
-          //
-          // value of a(x) at new x
-          DblVector a_new = a.Forward(0, x_new);
-          //
-          // (x_new, a_new)
-          DblVector xu_new = min_nso_linear_join(x_new, a_new);
-          //
-          // value of g[ x_new, a_new ]
-          DblVector g_new = g.Forward(0, xu_new);
-          //
-          //
-          // check for descent of objective
-          double rate_new = (g_new[0] - g_cur[0]) / max_delta_x;
-          if( - epsilon[1] < rate_new )
-          {     // did not get sufficient descent
-               b_cur /= 2.0;
-               if( level > 0 )
-                    std::cout << "itr = " << itr
-                    << ", rate_new = " << rate_new
-                    << ", b_cur = " << b_cur << "\n";
-               //
-          }
-          else
-          {     // got sufficient descent so accept candidate for x
-               x_out  = x_new;
-               a_cur  = a_new;
-               g_cur  = g_new;
-               xu_cur = xu_new;
-               //
-               if( level >  0 )
-               {     std::cout << "itr = " << itr
-                    << ", derivative = "<< derivative
-                    << ", max_delta_x = "<< max_delta_x
-                    << ", objective = " << g_cur[0] << "\n";
-                    abs_print_mat("x_out", n, 1, x_out);
-               }
-          }
-     }
-     if( level > 0 )
-          std::cout << "end min_nso_linear: maximum number of iterations exceeded\n";
-     return false;
-}
-} // END_CPPAD_NAMESPACE
- -
Input File: example/abs_normal/min_nso_linear.omh - - - diff -Nru cppad-2018.00.00.0/doc/_min_nso_linear.hpp_xml.js cppad-2019.02.00.0/doc/_min_nso_linear.hpp_xml.js --- cppad-2018.00.00.0/doc/_min_nso_linear.hpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_min_nso_linear.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'min_nso_linear.xml', -'min_nso_linear.hpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'min_nso_linear.cpp.xml', -'min_nso_linear.hpp.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-2018.00.00.0/doc/min_nso_linear.xml cppad-2019.02.00.0/doc/min_nso_linear.xml --- cppad-2018.00.00.0/doc/min_nso_linear.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/min_nso_linear.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,450 +0,0 @@ - - - -Non-Smooth Optimization Using Abs-normal Linear Approximations - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Non-Smooth Optimization Using Abs-normal Linear Approximations
-
-Syntax - -
- -ok = min_nso_linear(
-     
levelgaepsilonmaxitrb_inx_inx_out
-)
- - -
-
-Prototype - -

-template <class DblVector, class SizeVector>
-bool min_nso_linear(
-     size_t           level     ,
-     ADFun<double>&   g         ,
-     ADFun<double>&   a         ,
-     const DblVector& epsilon   ,
-     SizeVector       maxitr    ,
-     double           b_in      ,
-     const DblVector& x_in      ,
-     DblVector&       x_out     )
-
-Source -
-This following is a link to the source code for this example: -min_nso_linear.hpp -. - -
-
-Purpose -
-Given a current that abs-normal representation -g -, a -, -for a function - -f -( -x -) - - -, -this routine minimizes - -f -( -x -) - - -. - -
-
-DblVector -
-is a SimpleVector - class with elements of type double. - -
-
-SizeVector -
-is a SimpleVector - class with elements of type size_t. - -
-
-f -
-We use the notation -f - for the original function; see -f -. - -
-
-n -
-We use -n - to denote the dimension of the domain for -f -; i.e., - -f.Domain() -. - -
-
-m -
-We use -m - to denote the dimension of the range for -f -; i.e., - -f.Range() -. -This must be equal to one. - -
-
-s -
-We use -s - to denote the number absolute terms in -f -. - -
-
-level -
-This value is less that or equal 5. -If -level == 0 -, -no tracing of the optimization is printed. -If -level >= 1 -, -a trace of each iteration of min_nso_linear is printed. -If -level >= 2 -, -a trace of each iteration of the abs_min_linear sub-problem is printed. -If -level >= 3 -, -a trace of the lp_box - sub-problem is printed. -If -level >= 4 -, -a trace of the objective and primal variables - -x - - - are printed -at each simplex_method - iteration. -If -level == 5 -, -the simplex tableau is printed at each simplex iteration. - -
-
-g -
-This is the function g - -in the abs-normal representation of -f -. - -
-
-a -
-This is the function a - -in the abs-normal representation of -f -. - -
-
-epsilon -
-This is a vector with size 2. -The value -epsilon[0] - is convergence criteria in terms -of the infinity norm of the difference of -x_out - -between iterations. -The value -epsilon[1] - is convergence criteria in terms -of the derivative of - -f -( -x -) - - -. -This derivative is actually the average of the directional derivative -in the direction of the sub-problem minimizer. - -
-
-maxitr -
-This is a vector with size 3. -The value -maxitr[0] - is the maximum number of -min_nso_linear iterations to try before giving up on convergence. -The value -maxitr[1] - is the maximum number of iterations in the -abs_min_linear sub-problem. -The value -maxitr[2] - is the maximum number of iterations in -the simplex_method - sub-problems. - -
-
-b_in -
-This the initial bound on the trust region size. -To be specific, if - -b - - - is the current trust region size, -at each iteration affine approximation is minimized with respect to - - -Δ -x - - - and subject to - - -- -b - -Δ -x -j - - -b - - -for -j = 0 , ...n-1 -. -It must hold that -b_in > epsilon[0] -. - -
-
-x_in -
-This vector -x_out - has size -n -. -It is the starting point for the optimization procedure; i.e., -the min_nso_linear iterations. - -
-
-x_out -
-This vector -x_out - has size -n -. -The input value of its elements does not matter. -Upon return, -it is the approximate minimizer -of the abs-normal approximation for - -f -( -x -) - - - over the trust region -is - -x -= -x - -^ -+ -Δ -x - - -. - - -
-
-Example -
-The file min_nso_linear.cpp - contains an example and test of -min_nso_linear. -It returns true if the test passes and false otherwise. - - -
Input File: example/abs_normal/min_nso_linear.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_min_nso_linear_xml.js cppad-2019.02.00.0/doc/_min_nso_linear_xml.js --- cppad-2018.00.00.0/doc/_min_nso_linear_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_min_nso_linear_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'min_nso_linear.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down0 = [ -'min_nso_linear.cpp.xml', -'min_nso_linear.hpp.xml' -]; -var list_current0 = [ -'min_nso_linear.xml#Syntax', -'min_nso_linear.xml#Prototype', -'min_nso_linear.xml#Source', -'min_nso_linear.xml#Purpose', -'min_nso_linear.xml#DblVector', -'min_nso_linear.xml#SizeVector', -'min_nso_linear.xml#f', -'min_nso_linear.xml#f.n', -'min_nso_linear.xml#f.m', -'min_nso_linear.xml#f.s', -'min_nso_linear.xml#level', -'min_nso_linear.xml#g', -'min_nso_linear.xml#a', -'min_nso_linear.xml#epsilon', -'min_nso_linear.xml#maxitr', -'min_nso_linear.xml#b_in', -'min_nso_linear.xml#x_in', -'min_nso_linear.xml#x_out', -'min_nso_linear.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-2018.00.00.0/doc/min_nso_quad.cpp.xml cppad-2019.02.00.0/doc/min_nso_quad.cpp.xml --- cppad-2018.00.00.0/doc/min_nso_quad.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/min_nso_quad.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,258 +0,0 @@ - - - -abs_normal min_nso_quad: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -min_nso_quad.cpp - -

- - - -
abs_normal min_nso_quad: Example and Test
-
-Purpose -
-We minimize the function - - -f -: -R - -3 - - -R - - - - defined by - - - -f -( -x -0 - -, -x -1 - -, -x -2 - -) - -= - -x -0 -2 - -+ -2 -( -x -0 - -+ -x -1 - -) -2 - -+ -| -x -2 - -| - - - -
-Discussion -
-This routine uses abs_min_quad - which uses qp_box -, -a quadratic programming algorithm. -It is mean to be compared with min_nso_linear.cpp - which uses -a linear programing algorithm for the same problem. -To see this comparison, set -level = 1 - is both examples. - - -
-
-Source - -

-# include <cppad/cppad.hpp>
-# include "min_nso_quad.hpp"
-
-bool min_nso_quad(void)
-{     bool ok = true;
-     //
-     using CppAD::AD;
-     using CppAD::ADFun;
-     //
-     typedef CPPAD_TESTVECTOR(size_t)       s_vector;
-     typedef CPPAD_TESTVECTOR(double)       d_vector;
-     typedef CPPAD_TESTVECTOR( AD<double> ) ad_vector;
-     //
-     size_t level = 0;    // level of tracing
-     size_t n     = 3;    // size of x
-     size_t m     = 1;    // size of y
-     size_t s     = 1;    // number of data points and absolute values
-     //
-     // start recording the function f(x)
-     ad_vector ax(n), ay(m);
-     for(size_t j = 0; j < n; j++)
-          ax[j] = double(j + 1);
-     Independent( ax );
-     //
-     ay[0]  =  ax[0] * ax[0];
-     ay[0] += 2.0 * (ax[0] + ax[1]) * (ax[0] + ax[1]);
-     ay[0] += fabs( ax[2] );
-     ADFun<double> f(ax, ay);
-     //
-     // create its abs_normal representation in g, a
-     ADFun<double> g, a;
-     f.abs_normal_fun(g, a);
-
-     // check dimension of domain and range space for g
-     ok &= g.Domain() == n + s;
-     ok &= g.Range()  == m + s;
-
-     // check dimension of domain and range space for a
-     ok &= a.Domain() == n;
-     ok &= a.Range()  == s;
-
-     // epsilon
-     d_vector epsilon(2);
-     double eps = 1e-3;
-     epsilon[0] = eps;
-     epsilon[1] = eps;
-
-     // maxitr
-     s_vector maxitr(3);
-     maxitr[0] = 100;
-     maxitr[1] = 20;
-     maxitr[2] = 20;
-
-     // b_in
-     double b_in = 1.0;
-
-     // call min_nso_quad
-     d_vector x_in(n), x_out(n);
-     for(size_t j = 0; j < n; j++)
-          x_in[j]  = double(j + 1);
-
-     //
-     ok &= CppAD::min_nso_quad(
-          level, f, g, a, epsilon, maxitr, b_in, x_in, x_out
-     );
-     //
-     for(size_t j = 0; j < n; j++)
-          ok &= std::fabs( x_out[j] ) < eps;
-
-     return ok;
-}
- -
Input File: example/abs_normal/min_nso_quad.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_min_nso_quad.cpp_xml.js cppad-2019.02.00.0/doc/_min_nso_quad.cpp_xml.js --- cppad-2018.00.00.0/doc/_min_nso_quad.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_min_nso_quad.cpp_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', -'adfun.xml', -'abs_normal.xml', -'min_nso_quad.xml', -'min_nso_quad.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'min_nso_quad.cpp.xml', -'min_nso_quad.hpp.xml' -]; -var list_current0 = [ -'min_nso_quad.cpp.xml#Purpose', -'min_nso_quad.cpp.xml#Discussion', -'min_nso_quad.cpp.xml#Source' -]; -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-2018.00.00.0/doc/min_nso_quad.hpp.xml cppad-2019.02.00.0/doc/min_nso_quad.hpp.xml --- cppad-2018.00.00.0/doc/min_nso_quad.hpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/min_nso_quad.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,298 +0,0 @@ - - - -min_nso_quad Source Code - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -min_nso_quad.hppHeadings

-
min_nso_quad Source Code
-
namespace {
-     CPPAD_TESTVECTOR(double) min_nso_quad_join(
-          const CPPAD_TESTVECTOR(double)& x ,
-          const CPPAD_TESTVECTOR(double)& u )
-     {     size_t n = x.size();
-          size_t s = u.size();
-          CPPAD_TESTVECTOR(double) xu(n + s);
-          for(size_t j = 0; j < n; j++)
-               xu[j] = x[j];
-          for(size_t j = 0; j < s; j++)
-               xu[n + j] = u[j];
-          return xu;
-     }
-}
-
-// BEGIN C++
-namespace CppAD { // BEGIN_CPPAD_NAMESPACE
-
-// BEGIN PROTOTYPE
-template <class DblVector, class SizeVector>
-bool min_nso_quad(
-     size_t           level     ,
-     ADFun<double>&   f         ,
-     ADFun<double>&   g         ,
-     ADFun<double>&   a         ,
-     const DblVector& epsilon   ,
-     SizeVector       maxitr    ,
-     double           b_in      ,
-     const DblVector& x_in      ,
-     DblVector&       x_out     )
-// END PROTOTYPE
-{
-     using std::fabs;
-     //
-     // number of absolute value terms
-     size_t s  = a.Range();
-     //
-     // size of domain for f
-     size_t n  = f.Domain();
-     //
-     // size of range space for f
-     size_t m = f.Range();
-     //
-     CPPAD_ASSERT_KNOWN( g.Domain() == n + s,
-          "min_nso_quad: (g, a) is not an abs-normal for for f"
-     );
-     CPPAD_ASSERT_KNOWN( g.Range() == m + s,
-          "min_nso_quad: (g, a) is not an abs-normal for for f"
-     );
-     CPPAD_ASSERT_KNOWN(
-          level <= 5,
-          "min_nso_quad: level is not less that or equal 5"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(epsilon.size()) == 2,
-          "min_nso_quad: size of epsilon not equal to 2"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(maxitr.size()) == 3,
-          "min_nso_quad: size of maxitr not equal to 3"
-     );
-     CPPAD_ASSERT_KNOWN(
-          g.Domain() > s && g.Range() > s,
-          "min_nso_quad: g, a is not an abs-normal representation"
-     );
-     CPPAD_ASSERT_KNOWN(
-          m == 1,
-          "min_nso_quad: m is not equal to 1"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(x_in.size()) == n,
-          "min_nso_quad: size of x_in not equal to n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(x_out.size()) == n,
-          "min_nso_quad: size of x_out not equal to n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          epsilon[0] < b_in,
-          "min_nso_quad: b_in <= epsilon[0]"
-     );
-     if( level > 0 )
-     {     std::cout << "start min_nso_quad\n";
-          std::cout << "b_in = " << b_in << "\n";
-          CppAD::abs_print_mat("x_in", n, 1, x_in);
-     }
-     // level in abs_min_quad sub-problem
-     size_t level_tilde = 0;
-     if( level > 0 )
-          level_tilde = level - 1;
-     //
-     // maxitr in abs_min_quad sub-problem
-     SizeVector maxitr_tilde(2);
-     maxitr_tilde[0] = maxitr[1];
-     maxitr_tilde[1] = maxitr[2];
-     //
-     // epsilon in abs_min_quad sub-problem
-     DblVector eps_tilde(2);
-     eps_tilde[0] = epsilon[0] / 10.;
-     eps_tilde[1] = epsilon[1] / 10.;
-     //
-     // current bound
-     double b_cur = b_in;
-     //
-     // initilaize the current x
-     x_out = x_in;
-     //
-     // value of a(x) at current x
-     DblVector a_cur = a.Forward(0, x_out);
-     //
-     // (x_out, a_cur)
-     DblVector xu_cur = min_nso_quad_join(x_out, a_cur);
-     //
-     // value of g[ x_cur, a_cur ]
-     DblVector g_cur = g.Forward(0, xu_cur);
-     //
-     for(size_t itr = 0; itr < maxitr[0]; itr++)
-     {
-          // Jacobian of g[ x_cur, a_cur ]
-          DblVector g_jac = g.Jacobian(xu_cur);
-          //
-          // Hessian at x_cur
-          DblVector f_hes = f.Hessian(x_out, 0);
-          //
-          // bound in abs_min_quad sub-problem
-          DblVector bound_tilde(n);
-          for(size_t j = 0; j < n; j++)
-               bound_tilde[j] = b_cur;
-          //
-          DblVector delta_x(n);
-          bool ok = abs_min_quad(
-               level_tilde, n, m, s,
-               g_cur, g_jac, f_hes, bound_tilde, eps_tilde, maxitr_tilde, delta_x
-          );
-          if( ! ok )
-          {     if( level > 0 )
-                    std::cout << "end min_nso_quad: abs_min_quad failed\n";
-               return false;
-          }
-          //
-          // new candidate value for x
-          DblVector x_new(n);
-          double max_delta_x = 0.0;
-          for(size_t j = 0; j < n; j++)
-          {     x_new[j] = x_out[j] + delta_x[j];
-               max_delta_x = std::max(max_delta_x, std::fabs( delta_x[j] ) );
-          }
-          //
-          if( max_delta_x < 0.75 * b_cur && max_delta_x < epsilon[0] )
-          {     if( level > 0 )
-                    std::cout << "end min_nso_quad: delta_x is near zero\n";
-               return true;
-          }
-          // value of abs-normal approximation at minimizer
-          DblVector g_tilde = CppAD::abs_eval(n, m, s, g_cur, g_jac, delta_x);
-          //
-          double derivative = (g_tilde[0] - g_cur[0]) / max_delta_x;
-          CPPAD_ASSERT_UNKNOWN( derivative <= 0.0 )
-          if( - epsilon[1] < derivative )
-          {     if( level > 0 )
-                    std::cout << "end min_nso_quad: derivative near zero\n";
-               return true;
-          }
-          //
-          // value of a(x) at new x
-          DblVector a_new = a.Forward(0, x_new);
-          //
-          // (x_new, a_new)
-          DblVector xu_new = min_nso_quad_join(x_new, a_new);
-          //
-          // value of g[ x_new, a_new ]
-          DblVector g_new = g.Forward(0, xu_new);
-          //
-          // check for descent of objective
-          double rate_new = (g_new[0] - g_cur[0]) / max_delta_x;
-          if( - epsilon[1] < rate_new )
-          {     // did not get sufficient descent
-               b_cur /= 2.0;
-               if( level > 0 )
-                    std::cout << "itr = " << itr
-                    << ", rate_new = " << rate_new
-                    << ", b_cur = " << b_cur << "\n";
-               //
-          }
-          else
-          {     // got sufficient descent so accept candidate for x
-               x_out  = x_new;
-               a_cur  = a_new;
-               g_cur  = g_new;
-               xu_cur = xu_new;
-               //
-               if( level >  0 )
-               {     std::cout << "itr = " << itr
-                    << ", derivative = "<< derivative
-                    << ", max_delta_x = "<< max_delta_x
-                    << ", objective = " << g_cur[0] << "\n";
-                    abs_print_mat("x_out", n, 1, x_out);
-               }
-          }
-     }
-     if( level > 0 )
-          std::cout << "end min_nso_quad: maximum number of iterations exceeded\n";
-     return false;
-}
-} // END_CPPAD_NAMESPACE
- -
Input File: example/abs_normal/min_nso_quad.omh - - - diff -Nru cppad-2018.00.00.0/doc/_min_nso_quad.hpp_xml.js cppad-2019.02.00.0/doc/_min_nso_quad.hpp_xml.js --- cppad-2018.00.00.0/doc/_min_nso_quad.hpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_min_nso_quad.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'min_nso_quad.xml', -'min_nso_quad.hpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'min_nso_quad.cpp.xml', -'min_nso_quad.hpp.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-2018.00.00.0/doc/min_nso_quad.xml cppad-2019.02.00.0/doc/min_nso_quad.xml --- cppad-2018.00.00.0/doc/min_nso_quad.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/min_nso_quad.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,439 +0,0 @@ - - - -Non-Smooth Optimization Using Abs-normal Quadratic Approximations - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Non-Smooth Optimization Using Abs-normal Quadratic Approximations
-
-Syntax - -
- -ok = min_nso_quad(
-     
levelfgaepsilonmaxitrb_inx_inx_out
-)
- - -
-
-Prototype - -

-template <class DblVector, class SizeVector>
-bool min_nso_quad(
-     size_t           level     ,
-     ADFun<double>&   f         ,
-     ADFun<double>&   g         ,
-     ADFun<double>&   a         ,
-     const DblVector& epsilon   ,
-     SizeVector       maxitr    ,
-     double           b_in      ,
-     const DblVector& x_in      ,
-     DblVector&       x_out     )
-
-Source -
-This following is a link to the source code for this example: -min_nso_quad.hpp -. - -
-
-Purpose -
-Given a current that abs-normal representation -g -, a -, -for a function - -f -( -x -) - - -, -this routine minimizes - -f -( -x -) - - -. - -
-
-DblVector -
-is a SimpleVector - class with elements of type double. - -
-
-SizeVector -
-is a SimpleVector - class with elements of type size_t. - -
-
-level -
-This value is less that or equal 5. -If -level == 0 -, -no tracing of the optimization is printed. -If -level >= 1 -, -a trace of each iteration of min_nso_quad is printed. -If -level >= 2 -, -a trace of each iteration of the abs_min_quad sub-problem is printed. -If -level >= 3 -, -a trace of the qp_box - sub-problem is printed. -If -level >= 4 -, -a trace of the qp_interior - sub-problem is printed. - -
-
-f -
-This is the original function for the abs-normal form; see -f -. - -
-
-n -
-We use -n - to denote the dimension of the domain for -f -; i.e., - -f.Domain() -. - -
-
-m -
-We use -m - to denote the dimension of the range for -f -; i.e., - -f.Range() -. -This must be equal to one. - -
-
-s -
-We use -s - to denote the number absolute terms in -f -. - -
-
-g -
-This is the function g - -in the abs-normal representation of -f -. - -
-
-a -
-This is the function a - -in the abs-normal representation of -f -. - -
-
-epsilon -
-This is a vector with size 2. -The value -epsilon[0] - is convergence criteria in terms -of the infinity norm of the difference of -x_out - -between iterations. -The value -epsilon[1] - is convergence criteria in terms -of the derivative of - -f -( -x -) - - -. -This derivative is actually the average of the directional derivative -in the direction of the sub-problem minimizer. - -
-
-maxitr -
-This is a vector with size 3. -The value -maxitr[0] - is the maximum number of -min_nso_quad iterations to try before giving up on convergence. -The value -maxitr[1] - is the maximum number of iterations in the -abs_min_quad sub-problem. -The value -maxitr[2] - is the maximum number of iterations in -the qp_interior - sub-problems. - -
-
-b_in -
-This the initial bound on the trust region size. -To be specific, if - -b - - - is the current trust region size, -at each iteration affine approximation is minimized with respect to - - -Δ -x - - - and subject to - - -- -b - -Δ -x -j - - -b - - -for -j = 0 , ...n-1 -. -It must hold that -b_in > epsilon[0] -. - -
-
-x_in -
-This vector -x_out - has size -n -. -It is the starting point for the optimization procedure; i.e., -the min_nso_quad iterations. - -
-
-x_out -
-This vector -x_out - has size -n -. -The input value of its elements does not matter. -Upon return, -it is the approximate minimizer -of the abs-normal approximation for - -f -( -x -) - - - over the trust region -is - -x -= -x - -^ -+ -Δ -x - - -. - - -
-
-Example -
-The file min_nso_quad.cpp - contains an example and test of -min_nso_quad. -It returns true if the test passes and false otherwise. - - -
Input File: example/abs_normal/min_nso_quad.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_min_nso_quad_xml.js cppad-2019.02.00.0/doc/_min_nso_quad_xml.js --- cppad-2018.00.00.0/doc/_min_nso_quad_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_min_nso_quad_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'min_nso_quad.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down0 = [ -'min_nso_quad.cpp.xml', -'min_nso_quad.hpp.xml' -]; -var list_current0 = [ -'min_nso_quad.xml#Syntax', -'min_nso_quad.xml#Prototype', -'min_nso_quad.xml#Source', -'min_nso_quad.xml#Purpose', -'min_nso_quad.xml#DblVector', -'min_nso_quad.xml#SizeVector', -'min_nso_quad.xml#level', -'min_nso_quad.xml#f', -'min_nso_quad.xml#f.n', -'min_nso_quad.xml#f.m', -'min_nso_quad.xml#f.s', -'min_nso_quad.xml#g', -'min_nso_quad.xml#a', -'min_nso_quad.xml#epsilon', -'min_nso_quad.xml#maxitr', -'min_nso_quad.xml#b_in', -'min_nso_quad.xml#x_in', -'min_nso_quad.xml#x_out', -'min_nso_quad.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-2018.00.00.0/doc/mul.cpp.xml cppad-2019.02.00.0/doc/mul.cpp.xml --- cppad-2018.00.00.0/doc/mul.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/mul.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ - - - -AD Binary Multiplication: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -mul.cppHeadings

-
AD Binary Multiplication: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool Mul(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n  = 1;
-     double x0 = .5;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0]      = x0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     // some binary multiplication operations
-     AD<double> a = x[0] * 1.; // AD<double> * double
-     AD<double> b = a    * 2;  // AD<double> * int
-     AD<double> c = 3.   * b;  // double     * AD<double>
-     AD<double> d = 4    * c;  // int        * AD<double>
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = x[0] * d;          // AD<double> * AD<double>
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0] , x0*(4.*3.*2.*1.)*x0,  eps99 , eps99);
-
-     // forward computation of partials 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], (4.*3.*2.*1.)*2.*x0, eps99 , eps99);
-
-     // 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], (4.*3.*2.*1.)*2.*x0, eps99 , eps99);
-
-     // use a VecAD<Base>::reference object with multiplication
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero] = c;
-     AD<double> result = 4 * v[zero];
-     ok     &= (result == d);
-
-     return ok;
-}
-
-
-
Input File: example/general/mul.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_mul.cpp_xml.js cppad-2019.02.00.0/doc/_mul.cpp_xml.js --- cppad-2018.00.00.0/doc/_mul.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_mul.cpp_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', -'ad.xml', -'advalued.xml', -'arithmetic.xml', -'ad_binary.xml', -'mul.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down1 = [ -'add.cpp.xml', -'sub.cpp.xml', -'mul.cpp.xml', -'div.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-2018.00.00.0/doc/mul_eq.cpp.xml cppad-2019.02.00.0/doc/mul_eq.cpp.xml --- cppad-2018.00.00.0/doc/mul_eq.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/mul_eq.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ - - - -AD Compound Assignment Multiplication: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -mul_eq.cppHeadings

-
AD Compound Assignment Multiplication: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool MulEq(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t  n = 1;
-     double x0 = .5;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0]      = x0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     // range space vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = x[0];         // initial value
-     y[0] *= 2;           // AD<double> *= int
-     y[0] *= 4.;          // AD<double> *= double
-     y[1] = y[0] *= x[0]; // use the result of a compound assignment
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0] , x0*2.*4.*x0, eps99, eps99);
-     ok &= NearEqual(y[1] ,        y[0], eps99, eps99);
-
-     // forward computation of partials 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], 8.*2.*x0, eps99, eps99);
-     ok   &= NearEqual(dy[1], 8.*2.*x0, eps99, eps99);
-
-     // reverse computation of derivative of y[0]
-     CPPAD_TESTVECTOR(double)  w(m);
-     CPPAD_TESTVECTOR(double) dw(n);
-     w[0]  = 1.;
-     w[1]  = 0.;
-     dw    = f.Reverse(1, w);
-     ok   &= NearEqual(dw[0], 8.*2.*x0, eps99, eps99);
-
-     // use a VecAD<Base>::reference object with computed multiplication
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     AD<double> result = 1;
-     v[zero] = 2;
-     result *= v[zero];
-     ok     &= (result == 2);
-
-     return ok;
-}
-
-
-
Input File: example/general/mul_eq.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_mul_eq.cpp_xml.js cppad-2019.02.00.0/doc/_mul_eq.cpp_xml.js --- cppad-2018.00.00.0/doc/_mul_eq.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_mul_eq.cpp_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', -'ad.xml', -'advalued.xml', -'arithmetic.xml', -'compound_assign.xml', -'mul_eq.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down1 = [ -'addeq.cpp.xml', -'sub_eq.cpp.xml', -'mul_eq.cpp.xml', -'div_eq.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-2018.00.00.0/doc/mul_level_adolc.cpp.xml cppad-2019.02.00.0/doc/mul_level_adolc.cpp.xml --- cppad-2018.00.00.0/doc/mul_level_adolc.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/mul_level_adolc.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,389 +0,0 @@ - - - -Using Adolc with Multiple Levels of Taping: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -mul_level_adolc.cpp - -

- - - -
Using Adolc with Multiple Levels of Taping: Example and Test
-
-Purpose -
-In this example, we use AD< adouble> > (level two taping), -the compute values of the function - -f -: -R - -n - - -R - - - - where - - -f -( -x -) -= -1 - -2 - - -(x -0 -2 - -+ - -+ -x -n --1 - -2 - -) - - -We then use Adolc's adouble (level one taping) to compute -the directional derivative - - -f -( -1 -) - - -( -x -) -* -v -= -x -0 - -v -0 - -+ - -+ -x -n --1 - - -v -n --1 - - - - -. -where - -v - -R - -n - - - -. -We then use double (no taping) to compute - - -d - -dx - - -[f -( -1 -) - - -( -x -) -* -v -] -= -v - - -This is only meant as an example of multiple levels of taping. -The example hes_times_dir.cpp - computes the same value more -efficiently by using the identity: - - -d - -dx - - -[f -( -1 -) - - -( -x -) -* -v -] -= -f -( -2 -) - - -( -x -) -* -v - - -The example mul_level.cpp - computes the same values using -AD< AD<double> > and AD<double>. - -
-
-Memory Management -
-Adolc uses raw memory arrays that depend on the number of -dependent and independent variables. -The memory management utility thread_alloc - -is used to manage this memory allocation. - -
-
-Configuration Requirement -
-This example will be compiled and tested provided that -the value adolc_prefix - is specified on the -cmake - command line. - -
-
-Source - - -

-// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-
-# include <adolc/adouble.h>
-# include <adolc/taping.h>
-# include <adolc/interfaces.h>
-
-// adouble definitions not in Adolc distribution and
-// required in order to use CppAD::AD<adouble>
-# include <cppad/example/base_adolc.hpp>
-
-# include <cppad/cppad.hpp>
-
-namespace {
-     // f(x) = |x|^2 / 2 = .5 * ( x[0]^2 + ... + x[n-1]^2 )
-     template <class Type>
-     Type f(const CPPAD_TESTVECTOR(Type)& x)
-     {     Type sum;
-
-          sum  = 0.;
-          size_t i = size_t(x.size());
-          for(i = 0; i < size_t(x.size()); i++)
-               sum += x[i] * x[i];
-
-          return .5 * sum;
-     }
-}
-
-bool mul_level_adolc(void)
-{     bool ok = true;                // initialize test result
-     using CppAD::thread_alloc;        // The CppAD memory allocator
-
-     typedef adouble           a1type;  // for first level of taping
-     typedef CppAD::AD<a1type> a2type; // for second level of taping
-     size_t n = 5;                          // number independent variables
-     size_t j;
-
-     // 10 times machine epsilon
-     double eps = 10. * std::numeric_limits<double>::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++)
-          a2x[j] = double(j);
-     // Declare the independent variable for taping f(x)
-     CppAD::Independent(a2x);
-
-     // Use AD<adouble> to tape the evaluation of f(x)
-     CPPAD_TESTVECTOR(a2type) a2y(1);
-     a2y[0] = f(a2x);
-
-     // Declare a1f as the corresponding ADFun<adouble> function f(x)
-     // (make sure we do not run zero order forward during constructor)
-     CppAD::ADFun<a1type> a1f;
-     a1f.Dependent(a2x, a2y);
-
-     // Value of the independent variables whitle taping f'(x) * v
-     int tag = 0;
-     int keep = 1;
-     trace_on(tag, keep);
-     for(j = 0; j < n; j++)
-          a1x[j] <<= double(j);
-
-     // set the argument value x for computing f'(x) * v
-     a1f.Forward(0, a1x);
-
-     // compute f'(x) * v
-     CPPAD_TESTVECTOR(a1type) a1v(n);
-     CPPAD_TESTVECTOR(a1type) a1df(1);
-     for(j = 0; j < n; j++)
-          a1v[j] = double(n - j);
-     a1df = a1f.Forward(1, a1v);
-
-     // declare Adolc function corresponding to f'(x) * v
-     double df;
-     a1df[0] >>= df;
-     trace_off();
-
-     // compute the d/dx of f'(x) * v = f''(x) * v
-     size_t m      = 1;                     // # dependent in f'(x) * v
-
-     // w = new double[capacity] where capacity >= m
-     size_t capacity;
-     double* w  = thread_alloc::create_array<double>(m, capacity);
-
-     // dw = new double[capacity] where capacity >= n
-     double* dw = thread_alloc::create_array<double>(n, capacity);
-
-     w[0]  = 1.;
-     fos_reverse(tag, int(m), int(n), w, dw);
-
-     for(j = 0; j < n; j++)
-     {     double vj = a1v[j].value();
-          ok &= CppAD::NearEqual(dw[j], vj, eps, eps);
-     }
-
-     // make memory avaialble for other use by this thread
-     thread_alloc::delete_array(w);
-     thread_alloc::delete_array(dw);
-     return ok;
-}
-
-
Input File: example/general/mul_level_adolc.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_mul_level_adolc.cpp_xml.js cppad-2019.02.00.0/doc/_mul_level_adolc.cpp_xml.js --- cppad-2018.00.00.0/doc/_mul_level_adolc.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_mul_level_adolc.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -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_example.xml', -'base_adolc.hpp.xml', -'mul_level_adolc.cpp.xml' -]; -var list_down3 = [ -'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_hash.xml', -'base_example.xml' -]; -var list_down2 = [ -'base_alloc.hpp.xml', -'base_require.cpp.xml', -'base_adolc.hpp.xml', -'base_float.hpp.xml', -'base_double.hpp.xml', -'base_complex.hpp.xml' -]; -var list_down1 = [ -'mul_level_adolc.cpp.xml' -]; -var list_current0 = [ -'mul_level_adolc.cpp.xml#Purpose', -'mul_level_adolc.cpp.xml#Memory Management', -'mul_level_adolc.cpp.xml#Configuration Requirement', -'mul_level_adolc.cpp.xml#Source' -]; -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-2018.00.00.0/doc/mul_level_adolc_ode.cpp.xml cppad-2019.02.00.0/doc/mul_level_adolc_ode.cpp.xml --- cppad-2018.00.00.0/doc/mul_level_adolc_ode.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/mul_level_adolc_ode.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1115 +0,0 @@ - - - -Taylor's Ode Solver: A Multi-Level Adolc Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -mul_level_adolc_ode.cpp - -

-
Taylor's Ode Solver: A Multi-Level Adolc Example and Test
-
-Purpose -
-This is a realistic example using -two levels of AD; see mul_level -. -The first level uses Adolc's 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 uses CppAD's type AD<adouble> -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. -The example mul_level_ode.cpp - computes the same values using -AD<double> and AD< AD<double> >. -The example ode_taylor.cpp - is a simpler applications -of Taylor's method for solving an ODE. - -
-
-ODE -
-For this example the ODE's are defined by the function - - -h -: -R - -n - -× -R - -n - - -R - -n - - - - where - - -h -[ -x -, -y -( -t -, -x -) -] -= -( -x -0 - - -x -1 - -y -0 - -( -t -, -x -) - - - -x -n --1 - - -y -n --2 - - -( -t -, -x -) - -) -= -( - -t - -y -0 - -( -t -, -x -) - - -t - -y -1 - -( -t -, -x -) - - - - -t - -y -n --1 - - -( -t -, -x -) - -) - - -and the initial condition - -y -( -0 -, -x -) -= -0 - - -. -The value of - -x - - - is fixed during the solution of the ODE -and the function - -g -: -R - -n - - -R - -n - - - - is used to -define the ODE where - - -g -( -y -) -= -( -x -0 - - -x -1 - -y -0 - - - - -x -n --1 - - -y -n --2 - - - -) - - -
-ODE Solution -
-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 - - -y -( -t -, -x -) -= -( -x -0 - -t - -x -1 - -x -0 - -t -2 - -/ -2 - - - -x -n --1 - - -x -n --2 - - - -x -0 - -t -n - -/ -n -! - -) - - -
-Derivative of ODE Solution -
-Differentiating the solution above, -with respect to the parameter vector - -x - - -, -we notice that - - - -x - -y -( -t -, -x -) -= -( -y -0 - -( -t -, -x -) -/ -x -0 - - -0 - - - -0 - -y -1 - -( -t -, -x -) -/ -x -0 - - -y -1 - -( -t -, -x -) -/ -x -1 - - -0 - - - - - - - - - -0 - -y -n --1 - - -( -t -, -x -) -/ -x -0 - - -y -n --1 - - -( -t -, -x -) -/ -x -1 - - - - -y -n --1 - - -( -t -, -x -) -/ -x -n --1 - - - -) - - -
- -
-An m-th order Taylor method for -approximating the solution of an -ordinary differential equations is - - -y -( -t -+ -Δ -t -, -x -) - - -k -= -0 - -p - - -t -k - -y -( -t -, -x -) -Δ -t -k - - -k -! - - -= -y -( -0 -) - - -( -t -, -x -) -+ -y -( -1 -) - - -( -t -, -x -) -Δ -t -+ - -+ -y -( -p -) - - -( -t -, -x -) -Δ -t -p - - - -where the Taylor coefficients - -y -( -k -) - - -( -t -, -x -) - - - are defined by - - -y -( -k -) - - -( -t -, -x -) -= - -t -k - -y -( -t -, -x -) -/ -k -! - - -We define the function - -z -( -t -, -x -) - - - by the equation - - -z -( -t -, -x -) -= -g -[ -y -( -t -, -x -) -] -= -h -[ -x -, -y -( -t -, -x -) -] - - -It follows that - - - - -t - -y -( -t -, -x -) - -= - -z -( -t -, -x -) - - -t -k -+ -1 - - -y -( -t -, -x -) - -= - - -t -k - -z -( -t -, -x -) - -y -( -k -+ -1 -) - - -( -t -, -x -) - -= - -z -( -k -) - - -( -t -, -x -) -/ -( -k -+ -1 -) - - - -where - -z -( -k -) - - -( -t -, -x -) - - - is the -k-th order Taylor coefficient -for - -z -( -t -, -x -) - - -. -In the example below, the Taylor coefficients - - -y -( -0 -) - - -( -t -, -x -) -, - -, -y -( -k -) - - -( -t -, -x -) - - -are used to calculate the Taylor coefficient - -z -( -k -) - - -( -t -, -x -) - - - -which in turn gives the value for - -y -( -k -+ -1 -) - - -y -( -t -, -x -) - - -. - -
-
-base_adolc.hpp -
-The file base_adolc.hpp - is implements the -Base type requirements - where -Base - -is adolc. - -
-
-Memory Management -
-Adolc uses raw memory arrays that depend on the number of -dependent and independent variables. -The thread_alloc - memory management utilities -create_array - and -delete_array - -are used to manage this memory allocation. - -
-
-Configuration Requirement -
-This example will be compiled and tested provided that -the value ipopt_prefix - is specified on the -cmake - command line. - -
-
-Source - - - -

-// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-
-# include <adolc/adouble.h>
-# include <adolc/taping.h>
-# include <adolc/drivers/drivers.h>
-
-// definitions not in Adolc distribution and required to use CppAD::AD<adouble>
-# include <cppad/example/base_adolc.hpp>
-
-# include <cppad/cppad.hpp>
-// ==========================================================================
-namespace { // BEGIN empty namespace
-// define types for each level
-typedef adouble           a1type;
-typedef CppAD::AD<a1type> 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(a1type) a1x_;
-public:
-     // constructor
-     Ode(const CPPAD_TESTVECTOR(a1type)& a1x) : a1x_(a1x)
-     { }
-     // the function g(y) is evaluated with two levels of taping
-     CPPAD_TESTVECTOR(a2type) operator()
-     ( const CPPAD_TESTVECTOR(a2type)& a2y) const
-     {     size_t n = a2y.size();
-          CPPAD_TESTVECTOR(a2type) a2g(n);
-          size_t i;
-          a2g[0] = a1x_[0];
-          for(i = 1; i < n; i++)
-               a2g[i] = a1x_[i] * a2y[i-1];
-
-          return a2g;
-     }
-};
-
-// -------------------------------------------------------------------------
-// Routine that uses Taylor's method to solve ordinary differential equaitons
-// 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 = a1y_ini.size();
-
-     // copies of x and g(y) with two levels of taping
-     CPPAD_TESTVECTOR(a2type)   a2y(n), Z(n);
-
-     // y, y^{(k)} , z^{(k)}, and y^{(k+1)}
-     CPPAD_TESTVECTOR(a1type)  a1y(n), a1y_k(n), a1z_k(n), a1y_kp(n);
-
-     // initialize x
-     for(i = 0; i < n; 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 using a1type
-          for(i = 0; i < n; i++)
-               a2y[i] = a1y[i];
-          CppAD::Independent(a2y);
-
-          // evaluate ODE using a2type
-          Z = G(a2y);
-
-          // define differentiable version of g: X -> Y
-          // that computes its derivatives using a1type
-          CppAD::ADFun<a1type> a1g(a2y, Z);
-
-          // Use Taylor's method to take a step
-          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
-               a1z_k = a1g.Forward(k, a1y_k);
-
-               for(i = 0; i < n; i++)
-               {     // convert to (k+1)-Taylor coefficient for x
-                    a1y_kp[i] = a1z_k[i] / a1type(k + 1);
-
-                    // add term for to this Taylor coefficient
-                    // to solution for y(t, x)
-                    a1y[i]    += a1y_kp[i] * dt_kp;
-               }
-               // next power of t
-               dt_kp *= a1dt;
-               // next Taylor coefficient
-               a1y_k   = a1y_kp;
-          }
-     }
-     return a1y;
-}
-} // END empty namespace
-// ==========================================================================
-// Routine that tests algorithmic differentiation of solutions computed
-// by the routine taylor_ode.
-bool mul_level_adolc_ode(void)
-{     bool ok = true;
-     double eps = 100. * std::numeric_limits<double>::epsilon();
-
-     // number of components in differential equation
-     size_t n = 4;
-
-     // some temporary indices
-     size_t i, j;
-
-     // set up for thread_alloc memory allocator
-     using CppAD::thread_alloc; // the allocator
-     size_t capacity;           // capacity of an allocation
-
-     // the vector x with length n (or greater) in double
-     double* x = thread_alloc::create_array<double>(n, capacity);
-
-     // the vector x with length n in a1type
-     CPPAD_TESTVECTOR(a1type) a1x(n);
-     for(i = 0; i < n; i++)
-          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++)
-          a1x[i] <<= double(i + 1);  // a1x is independent for adouble type
-
-     // 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
-     a1type   a1dt  = 1.;     // Delta t for each step
-     // value of y(t, x) at the initial time
-     CPPAD_TESTVECTOR(a1type) a1y_ini(n);
-     for(i = 0; i < n; i++)
-          a1y_ini[i] = 0.;
-
-     // integrate the differential equation
-     CPPAD_TESTVECTOR(a1type) a1y_final(n);
-     a1y_final = taylor_ode_adolc(G, order, nstep, a1dt, a1y_ini);
-
-     // declare the differentiable fucntion f : x -> y_final
-     // (corresponding to the tape of adouble operations)
-     double* y_final = thread_alloc::create_array<double>(n, capacity);
-     for(i = 0; i < n; i++)
-          a1y_final[i] >>= y_final[i];
-     trace_off();
-
-     // check function values
-     double check = 1.;
-     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, eps, eps);
-     }
-
-     // memory where Jacobian will be returned
-     double* jac_ = thread_alloc::create_array<double>(n * n, capacity);
-     double** jac = thread_alloc::create_array<double*>(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
-     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, eps, eps);
-          }
-     }
-
-     // make memroy avaiable for other use by this thread
-     thread_alloc::delete_array(x);
-     thread_alloc::delete_array(y_final);
-     thread_alloc::delete_array(jac_);
-     thread_alloc::delete_array(jac);
-     return ok;
-}
-
-
-
Input File: example/general/mul_level_adolc_ode.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_mul_level_adolc_ode.cpp_xml.js cppad-2019.02.00.0/doc/_mul_level_adolc_ode.cpp_xml.js --- cppad-2018.00.00.0/doc/_mul_level_adolc_ode.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_mul_level_adolc_ode.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +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_adolc_ode.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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_current0 = [ -'mul_level_adolc_ode.cpp.xml#Purpose', -'mul_level_adolc_ode.cpp.xml#ODE', -'mul_level_adolc_ode.cpp.xml#ODE Solution', -'mul_level_adolc_ode.cpp.xml#Derivative of ODE Solution', -'mul_level_adolc_ode.cpp.xml#Taylor\'s Method Using AD', -'mul_level_adolc_ode.cpp.xml#base_adolc.hpp', -'mul_level_adolc_ode.cpp.xml#Memory Management', -'mul_level_adolc_ode.cpp.xml#Configuration Requirement', -'mul_level_adolc_ode.cpp.xml#Source' -]; -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-2018.00.00.0/doc/mul_level.cpp.xml cppad-2019.02.00.0/doc/mul_level.cpp.xml --- cppad-2018.00.00.0/doc/mul_level.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/mul_level.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,349 +0,0 @@ - - - -Multiple Level of AD: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -mul_level.cpp - -

- - - -
Multiple Level of AD: Example and Test
-
-Purpose -
-In this example, we use AD< AD<double> > (level two taping), -the compute values of the function - -f -: -R - -n - - -R - - - - where - - -f -( -x -) -= -1 - -2 - - -(x -0 -2 - -+ - -+ -x -n --1 - -2 - -) - - -We then use AD<double> (level one taping) to compute -the directional derivative - - -f -( -1 -) - - -( -x -) -* -v -= -x -0 - -v -0 - -+ - -+ -x -n --1 - - -v -n --1 - - - - -. -where - -v - -R - -n - - - -. -We then use double (no taping) to compute - - -d - -dx - - -[f -( -1 -) - - -( -x -) -* -v -] -= -v - - -This is only meant as an example of multiple levels of taping. -The example hes_times_dir.cpp - computes the same value more -efficiently by using the identity: - - -d - -dx - - -[f -( -1 -) - - -( -x -) -* -v -] -= -f -( -2 -) - - -( -x -) -* -v - - -The example mul_level_adolc.cpp - computes the same values using -Adolc's type adouble and CppAD's type AD<adouble>. - - -
-
-Source - - -

-
-# include <cppad/cppad.hpp>
-
-namespace {
-     // f(x) = |x|^2 / 2 = .5 * ( x[0]^2 + ... + x[n-1]^2 )
-     template <class Type>
-     Type f(const CPPAD_TESTVECTOR(Type)& x)
-     {     Type sum;
-
-          sum  = 0.;
-          size_t i = size_t(x.size());
-          for(i = 0; i < size_t(x.size()); i++)
-               sum += x[i] * x[i];
-
-          return .5 * sum;
-     }
-}
-
-bool mul_level(void)
-{     bool ok = true;                          // initialize test result
-
-     typedef CppAD::AD<double>   a1type;    // for one level of taping
-     typedef CppAD::AD<a1type>    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<double>::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++)
-          a2x[j] = a1x[j] = x[j] = double(j);
-     // Declare the independent variable for taping f(x)
-     CppAD::Independent(a2x);
-
-     // Use AD< AD<double> > to tape the evaluation of f(x)
-     a2y[0] = f(a2x);
-
-     // Declare a1f as the corresponding ADFun< AD<double> >
-     // (make sure we do not run zero order forward during constructor)
-     CppAD::ADFun<a1type> a1f;
-     a1f.Dependent(a2x, a2y);
-
-     // Values for the independent variables while taping f'(x) * v
-     // Declare the independent variable for taping f'(x) * v
-     // (Note we did not have to tape the creationg of a1f.)
-     CppAD::Independent(a1x);
-
-     // set the argument value x for computing f'(x) * v
-     a1f.Forward(0, a1x);
-     // compute f'(x) * v
-     for(j = 0; j < n; j++)
-          a1v[j] = double(n - j);
-     a1dy = a1f.Forward(1, a1v);
-
-     // declare g as ADFun<double> function corresponding to f'(x) * v
-     CppAD::ADFun<double> g;
-     g.Dependent(a1x, a1dy);
-
-     // optimize out operations not necessary for function f'(x) * v
-     g.optimize();
-
-     // Evaluate f'(x) * v
-     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   = g.Reverse(1, w);
-
-     for(j = 0; j < n; j++)
-          ok &= CppAD::NearEqual(dw[j], a1v[j], eps, eps);
-
-     return ok;
-}
-
-
Input File: example/general/mul_level.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_mul_level.cpp_xml.js cppad-2019.02.00.0/doc/_mul_level.cpp_xml.js --- cppad-2018.00.00.0/doc/_mul_level.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_mul_level.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +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', -'mul_level.cpp.xml' -]; -var list_down3 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.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 = [ -'mul_level.cpp.xml#Purpose', -'mul_level.cpp.xml#Source' -]; -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-2018.00.00.0/doc/mul_level_ode.cpp.xml cppad-2019.02.00.0/doc/mul_level_ode.cpp.xml --- cppad-2018.00.00.0/doc/mul_level_ode.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/mul_level_ode.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1044 +0,0 @@ - - - -Taylor's Ode Solver: A Multi-Level AD Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -mul_level_ode.cpp - -

-
Taylor's Ode Solver: A Multi-Level AD Example and Test
-
-Purpose -
-This is a realistic example using -two levels of AD; see mul_level -. -The first level uses AD<double> to tape the solution of an -ordinary differential equation. -This solution is then differentiated with respect to a parameter vector. -The second level uses AD< AD<double> > -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. -The example mul_level_adolc_ode.cpp - computes the same values using -Adolc's type adouble and CppAD's type AD<adouble>. -The example ode_taylor.cpp - is a simpler applications -of Taylor's method for solving an ODE. - -
-
-ODE -
-For this example the ODE's are defined by the function - - -h -: -R - -n - -× -R - -n - - -R - -n - - - - where - - -h -[ -x -, -y -( -t -, -x -) -] -= -( -x -0 - - -x -1 - -y -0 - -( -t -, -x -) - - - -x -n --1 - - -y -n --2 - - -( -t -, -x -) - -) -= -( - -t - -y -0 - -( -t -, -x -) - - -t - -y -1 - -( -t -, -x -) - - - - -t - -y -n --1 - - -( -t -, -x -) - -) - - -and the initial condition - -y -( -0 -, -x -) -= -0 - - -. -The value of - -x - - - is fixed during the solution of the ODE -and the function - -g -: -R - -n - - -R - -n - - - - is used to -define the ODE where - - -g -( -y -) -= -( -x -0 - - -x -1 - -y -0 - - - - -x -n --1 - - -y -n --2 - - - -) - - -
-ODE Solution -
-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 - - -y -( -t -, -x -) -= -( -x -0 - -t - -x -1 - -x -0 - -t -2 - -/ -2 - - - -x -n --1 - - -x -n --2 - - - -x -0 - -t -n - -/ -n -! - -) - - -
-Derivative of ODE Solution -
-Differentiating the solution above, -with respect to the parameter vector - -x - - -, -we notice that - - - -x - -y -( -t -, -x -) -= -( -y -0 - -( -t -, -x -) -/ -x -0 - - -0 - - - -0 - -y -1 - -( -t -, -x -) -/ -x -0 - - -y -1 - -( -t -, -x -) -/ -x -1 - - -0 - - - - - - - - - -0 - -y -n --1 - - -( -t -, -x -) -/ -x -0 - - -y -n --1 - - -( -t -, -x -) -/ -x -1 - - - - -y -n --1 - - -( -t -, -x -) -/ -x -n --1 - - - -) - - -
- -
-An m-th order Taylor method for -approximating the solution of an -ordinary differential equations is - - -y -( -t -+ -Δ -t -, -x -) - - -k -= -0 - -p - - -t -k - -y -( -t -, -x -) -Δ -t -k - - -k -! - - -= -y -( -0 -) - - -( -t -, -x -) -+ -y -( -1 -) - - -( -t -, -x -) -Δ -t -+ - -+ -y -( -p -) - - -( -t -, -x -) -Δ -t -p - - - -where the Taylor coefficients - -y -( -k -) - - -( -t -, -x -) - - - are defined by - - -y -( -k -) - - -( -t -, -x -) -= - -t -k - -y -( -t -, -x -) -/ -k -! - - -We define the function - -z -( -t -, -x -) - - - by the equation - - -z -( -t -, -x -) -= -g -[ -y -( -t -, -x -) -] -= -h -[ -x -, -y -( -t -, -x -) -] - - -It follows that - - - - -t - -y -( -t -, -x -) - -= - -z -( -t -, -x -) - - -t -k -+ -1 - - -y -( -t -, -x -) - -= - - -t -k - -z -( -t -, -x -) - -y -( -k -+ -1 -) - - -( -t -, -x -) - -= - -z -( -k -) - - -( -t -, -x -) -/ -( -k -+ -1 -) - - - -where - -z -( -k -) - - -( -t -, -x -) - - - is the -k-th order Taylor coefficient -for - -z -( -t -, -x -) - - -. -In the example below, the Taylor coefficients - - -y -( -0 -) - - -( -t -, -x -) -, - -, -y -( -k -) - - -( -t -, -x -) - - -are used to calculate the Taylor coefficient - -z -( -k -) - - -( -t -, -x -) - - - -which in turn gives the value for - -y -( -k -+ -1 -) - - -y -( -t -, -x -) - - -. - -
-
-Source - - -

-
-# include <cppad/cppad.hpp>
-
-// =========================================================================
-// define types for each level
-namespace { // BEGIN empty namespace
-typedef CppAD::AD<double>   a1type;
-typedef CppAD::AD<a1type>   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(a1type) a1x_;
-public:
-     // constructor
-     Ode(const CPPAD_TESTVECTOR(a1type)& a1x) : a1x_(a1x)
-     { }
-     // the function g(y) is evaluated with two levels of taping
-     CPPAD_TESTVECTOR(a2type) operator()
-     ( const CPPAD_TESTVECTOR(a2type)& a2y) const
-     {     size_t n = a2y.size();
-          CPPAD_TESTVECTOR(a2type) a2g(n);
-          size_t i;
-          a2g[0] = a1x_[0];
-          for(i = 1; i < n; i++)
-               a2g[i] = a1x_[i] * a2y[i-1];
-
-          return a2g;
-     }
-};
-
-// -------------------------------------------------------------------------
-// Routine that uses Taylor's method to solve ordinary differential equaitons
-// 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 = a1y_ini.size();
-
-     // copies of x and g(y) with two levels of taping
-     CPPAD_TESTVECTOR(a2type)   a2y(n), a2z(n);
-
-     // y, y^{(k)} , z^{(k)}, and y^{(k+1)}
-     CPPAD_TESTVECTOR(a1type)  a1y(n), a1y_k(n), a1z_k(n), a1y_kp(n);
-
-     // initialize x
-     for(i = 0; i < n; 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 using a1type
-          for(i = 0; i < n; i++)
-               a2y[i] = a1y[i];
-          CppAD::Independent(a2y);
-
-          // evaluate ODE in a2type
-          a2z = G(a2y);
-
-          // define differentiable version of a1g: y -> z
-          // that computes its derivatives using a1type objects
-          CppAD::ADFun<a1type> a1g(a2y, a2z);
-
-          // Use Taylor's method to take a step
-          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
-               a1z_k = a1g.Forward(k, a1y_k);
-
-               for(i = 0; i < n; i++)
-               {     // convert to (k+1)-Taylor coefficient for x
-                    a1y_kp[i] = a1z_k[i] / a1type(k + 1);
-
-                    // add term for to this Taylor coefficient
-                    // to solution for y(t, x)
-                    a1y[i]    += a1y_kp[i] * a1dt_kp;
-               }
-               // next power of t
-               a1dt_kp *= a1dt;
-               // next Taylor coefficient
-               a1y_k   = a1y_kp;
-          }
-     }
-     return a1y;
-}
-} // END empty namespace
-// ==========================================================================
-// Routine that tests alogirhtmic differentiation of solutions computed
-// by the routine taylor_ode.
-bool mul_level_ode(void)
-{     bool ok = true;
-     double eps = 100. * std::numeric_limits<double>::epsilon();
-
-     // number of components in differential equation
-     size_t n = 4;
-
-     // some temporary indices
-     size_t i, j;
-
-     // parameter vector in both double and a1type
-     CPPAD_TESTVECTOR(double)  x(n);
-     CPPAD_TESTVECTOR(a1type)  a1x(n);
-     for(i = 0; i < n; i++)
-          a1x[i] = x[i] = double(i + 1);
-
-     // declare the parameters as the independent variable
-     CppAD::Independent(a1x);
-
-     // 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
-     a1type   a1dt  = double(1.);     // Delta t for each step
-     // value of y(t, x) at the initial time
-     CPPAD_TESTVECTOR(a1type) a1y_ini(n);
-     for(i = 0; i < n; i++)
-          a1y_ini[i] = 0.;
-
-     // integrate the differential equation
-     CPPAD_TESTVECTOR(a1type) a1y_final(n);
-     a1y_final = taylor_ode(G, order, nstep, a1dt, a1y_ini);
-
-     // define differentiable fucntion object f : x -> y_final
-     // that computes its derivatives in double
-     CppAD::ADFun<double> f(a1x, a1y_final);
-
-     // check function values
-     double check = 1.;
-     double t     = double(nstep) * Value(a1dt);
-     for(i = 0; i < n; i++)
-     {     check *= x[i] * t / double(i + 1);
-          ok &= CppAD::NearEqual(Value(a1y_final[i]), check, eps, eps);
-     }
-
-     // evaluate the Jacobian of h at a
-     CPPAD_TESTVECTOR(double) jac ( f.Jacobian(x) );
-     // There appears to be a bug in g++ version 4.4.2 because it generates
-     // a warning for the equivalent form
-     // CPPAD_TESTVECTOR(double) jac = f.Jacobian(x);
-
-     // check Jacobian
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j < n; j++)
-          {     double jac_ij = jac[i * n + j];
-               if( i < j )
-                    check = 0.;
-               else     check = Value( a1y_final[i] ) / x[j];
-               ok &= CppAD::NearEqual(jac_ij, check, eps, eps);
-          }
-     }
-     return ok;
-}
-
-
-
Input File: example/general/mul_level_ode.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_mul_level_ode.cpp_xml.js cppad-2019.02.00.0/doc/_mul_level_ode.cpp_xml.js --- cppad-2018.00.00.0/doc/_mul_level_ode.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_mul_level_ode.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +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_ode.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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_current0 = [ -'mul_level_ode.cpp.xml#Purpose', -'mul_level_ode.cpp.xml#ODE', -'mul_level_ode.cpp.xml#ODE Solution', -'mul_level_ode.cpp.xml#Derivative of ODE Solution', -'mul_level_ode.cpp.xml#Taylor\'s Method Using AD', -'mul_level_ode.cpp.xml#Source' -]; -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-2018.00.00.0/doc/mul_level.xml cppad-2019.02.00.0/doc/mul_level.xml --- cppad-2018.00.00.0/doc/mul_level.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/mul_level.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,362 +0,0 @@ - - - -Using Multiple Levels of AD - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Using Multiple Levels of AD
-
-Background -
-If -f - is an -ADFun<Base> - object, -the vectors returned by -f.Forward -, -and -f.Reverse -, -have values of type -Base - and not - -AD<Base> -. -This reflects the fact that operations used to calculate -these function values are not recorded by the tape corresponding to - -AD<Base> - operations. - -
-
-Motivation -
-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 -f.Forward - -might be used as part of -Taylor's method for solving ordinary -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: - -
  1. -The function defining the -differential equation could be calculated using the class - -AD< AD<double> > -. - -
  2. - -The operations during the calculation of Taylor's method -could be done using the -AD<double> - class. - -
  3. - -Derivatives of the solution of the differential equation -could then be calculated using the double class. - -
- - -
-
-Procedure - - -
-
-First Start AD<double> -
-If some of the parameters - -in the -AD< AD<double> > - recording depend on the -variables - -in the -AD<double> - recording, -we must first declaring these variables; i.e., - -
-     Independent(
a1x)
-
-where -a1x - is -a SimpleVector - with elements of type -AD<double> -. -This will start recording a new tape of -operations performed using -AD<double> - class objects. - -
-
-Start AD< AD<double> > Recording -
-The next step is to declare the independent variables using - -
-     Independent(
a2x)
-
-where -a2x - is -a SimpleVector - with elements of type - -AD< AD<double> > -. -This will start recording a new tape of -operations performed using -AD< AD<double> > - class objects. - -
-
-Inner Function -
-The next step is to calculate the inner function -using -AD< AD<double> > - class objects. -We then stop the recording using - -
-     
a1f.Dependent(a2xa2y)
-
-where -a2y - is -a SimpleVector - with elements of type - -AD< AD<double> > - -and -a1f - is an -ADFun< AD<double> > - object. - -
-
-Second Start AD< AD<double> > -
-If none of the parameters - -in the -AD< AD<double> > - recording depend on the -variables - -in the -AD<double> - recording, -it is preferred to delay declaring these variables to this point; i.e., - -
-     Independent(
a1x)
-
-where -a1x - is -a SimpleVector - with elements of type -AD<double> -. -This will start recording a new tape of -operations performed using -AD<double> - class objects. - -
-
-Outer Function -
-The next step is to calculate the outer function -using -AD<double> - class objects. -Note that derivatives of the inner function can be included -in the calculation of the outer function using -a1f -. -We then stop the recording of -AD<double> - operations using - -
-     
g.Dependent(a1xa1y)
-
-where -a1y - is -a SimpleVector - with elements of type - -AD<double> - -and -g - is an -ADFun<double> - object. - -
-
-Derivatives of Outer Function -
-The AD function object -g - can then be used to calculate -the derivatives of the outer function. - - - -
-
-Example -
-The files -mul_level.cpp - and change_param.cpp - -contain an examples and tests of this procedure. -They return true if they succeed and false otherwise. -The file mul_level_ode.cpp - is a more complex example -use of multiple tapes. - - -
Input File: omh/mul_level.omh - - - diff -Nru cppad-2018.00.00.0/doc/_mul_level_xml.js cppad-2019.02.00.0/doc/_mul_level_xml.js --- cppad-2018.00.00.0/doc/_mul_level_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_mul_level_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +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' -]; -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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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_down0 = [ -'mul_level.cpp.xml', -'change_param.cpp.xml' -]; -var list_current0 = [ -'mul_level.xml#Background', -'mul_level.xml#Motivation', -'mul_level.xml#Procedure', -'mul_level.xml#Procedure.First Start AD<double>', -'mul_level.xml#Procedure.Start AD< AD<double> > Recording', -'mul_level.xml#Procedure.Inner Function', -'mul_level.xml#Procedure.Second Start AD< AD<double> >', -'mul_level.xml#Procedure.Outer Function', -'mul_level.xml#Procedure.Derivatives of Outer Function', -'mul_level.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-2018.00.00.0/doc/multi_atomic_common.xml cppad-2019.02.00.0/doc/multi_atomic_common.xml --- cppad-2018.00.00.0/doc/multi_atomic_common.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_atomic_common.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ - - - -Multi-Threaded User Atomic Common Information - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_atomic_common - -

-
Multi-Threaded User Atomic Common Information
-
-Purpose -
-This source code defines the common variables that are used by -the -multi_atomic_name - functions. - -
-
-Source - -

-namespace {
-     // Number of threads, set by multi_atomic_time
-     // (zero means one thread with no multi-threading setup)
-     size_t num_threads_ = 0;
-
-     // Number of Newton iterations, set by multi_atomic_time
-     size_t num_itr_;
-
-     // We can use one atomic_user function for all threads because
-     // there is no member data that gets changed during worker call.
-     // This needs to stay in scope for as long as a recording will use it.
-     // We cannot be in parallel mode when this object is created or deleted.
-     // We use a pointer so that there is no left over memory in thread zero.
-     atomic_user* a_square_root_ = 0;
-
-     // structure with information for one thread
-     typedef struct {
-          // used by worker to compute the square root, set by multi_atomic_setup
-          CppAD::ADFun<double>* fun;
-          //
-          // value we are computing square root of, set by multi_atomic_setup
-          vector<double>* y_squared;
-          //
-          // square root, set by worker
-          vector<double>* square_root;
-          //
-          // false if an error occurs, true otherwise, set by worker
-          bool ok;
-     } work_one_t;
-     //
-     // Vector with information for all threads
-     // (uses pointers instead of values to avoid false sharing)
-     // allocated by multi_atomic_setup, freed by multi_atomic_takedown
-     work_one_t* work_all_[CPPAD_MAX_NUM_THREADS];
-}
- -
Input File: example/multi_thread/multi_atomic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_atomic_common_xml.js cppad-2019.02.00.0/doc/_multi_atomic_common_xml.js --- cppad-2018.00.00.0/doc/_multi_atomic_common_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_atomic_common_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_atomic.cpp.xml', -'multi_atomic_common.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_atomic_user.xml', -'multi_atomic_common.xml', -'multi_atomic_setup.xml', -'multi_atomic_worker.xml', -'multi_atomic_takedown.xml', -'multi_atomic_run.xml', -'multi_atomic_time.xml' -]; -var list_current0 = [ -'multi_atomic_common.xml#Purpose', -'multi_atomic_common.xml#Source' -]; -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-2018.00.00.0/doc/multi_atomic.cpp.xml cppad-2019.02.00.0/doc/multi_atomic.cpp.xml --- cppad-2018.00.00.0/doc/multi_atomic.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_atomic.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ - - - -Multi-Threading User Atomic Example / Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Multi-Threading User Atomic Example / Test
-
-Source File -
-All of the routines below are located in the file -
 
-     example/multi_thread/multi_atomic.cpp
-
-
-Contents -
- -
multi_atomic_userDefines a User Atomic Operation that Computes Square Root
multi_atomic_commonMulti-Threaded User Atomic Common Information
multi_atomic_setupMulti-Threaded User Atomic Set Up
multi_atomic_workerMulti-Threaded User Atomic Worker
multi_atomic_takedownMulti-Threaded User Atomic Take Down
multi_atomic_runRun Multi-Threaded User Atomic Calculation
multi_atomic_timeTiming Test for Multi-Threaded User Atomic Calculation
-
Input File: example/multi_thread/multi_atomic.omh - - - diff -Nru cppad-2018.00.00.0/doc/_multi_atomic.cpp_xml.js cppad-2019.02.00.0/doc/_multi_atomic.cpp_xml.js --- cppad-2018.00.00.0/doc/_multi_atomic.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_atomic.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_atomic.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down1 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down0 = [ -'multi_atomic_user.xml', -'multi_atomic_common.xml', -'multi_atomic_setup.xml', -'multi_atomic_worker.xml', -'multi_atomic_takedown.xml', -'multi_atomic_run.xml', -'multi_atomic_time.xml' -]; -var list_current0 = [ -'multi_atomic.cpp.xml#Source File', -'multi_atomic.cpp.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-2018.00.00.0/doc/multi_atomic_run.xml cppad-2019.02.00.0/doc/multi_atomic_run.xml --- cppad-2018.00.00.0/doc/multi_atomic_run.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_atomic_run.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,184 +0,0 @@ - - - -Run Multi-Threaded User Atomic Calculation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_atomic_run - -

-
Run Multi-Threaded User Atomic Calculation
-
-Syntax - -
- -ok = multi_atomic_run(y_squaredsquare_root) - - -
-
-Thread -
-It is assumed that this function is called by thread zero -and all the other threads are blocked (waiting). - -
-
-y_squared -
-This argument has prototype - -
-     const vector<double>& 
y_squared
-
-and its size is equal to the number of threads. -It is the values that we are computing the square root of. - -
-
-square_root -
-This argument has prototype - -
-     vector<double>& 
square_root
-
-The input value of -square_root - does not matter. -Upon return, -it has the same size and -is the element by element square root of -y_squared -. - -
-
-ok -
-This return value has prototype - -
-     bool 
ok
-
-If it is false, -multi_atomic_run detected an error. - -
-
-Source - -

-namespace {
-bool multi_atomic_run(
-     const vector<double>& y_squared  ,
-     vector<double>&      square_root )
-{
-     bool ok = true;
-     ok     &= thread_alloc::thread_num() == 0;
-
-     // setup the work for multi-threading
-     ok &= multi_atomic_setup(y_squared);
-
-     // now do the work for each thread
-     if( num_threads_ > 0 )
-          team_work( multi_atomic_worker );
-     else     multi_atomic_worker();
-
-     // combine the result for each thread and takedown the multi-threading.
-     ok &= multi_atomic_takedown(square_root);
-
-     return ok;
-}
-}
- -
Input File: example/multi_thread/multi_atomic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_atomic_run_xml.js cppad-2019.02.00.0/doc/_multi_atomic_run_xml.js --- cppad-2018.00.00.0/doc/_multi_atomic_run_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_atomic_run_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_atomic.cpp.xml', -'multi_atomic_run.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_atomic_user.xml', -'multi_atomic_common.xml', -'multi_atomic_setup.xml', -'multi_atomic_worker.xml', -'multi_atomic_takedown.xml', -'multi_atomic_run.xml', -'multi_atomic_time.xml' -]; -var list_current0 = [ -'multi_atomic_run.xml#Syntax', -'multi_atomic_run.xml#Thread', -'multi_atomic_run.xml#y_squared', -'multi_atomic_run.xml#square_root', -'multi_atomic_run.xml#ok', -'multi_atomic_run.xml#Source' -]; -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-2018.00.00.0/doc/multi_atomic_setup.xml cppad-2019.02.00.0/doc/multi_atomic_setup.xml --- cppad-2018.00.00.0/doc/multi_atomic_setup.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_atomic_setup.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,211 +0,0 @@ - - - -Multi-Threaded User Atomic Set Up - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_atomic_setup - -

-
Multi-Threaded User Atomic Set Up
-. - -
-
-Syntax - -
- -ok = multi_atomic_setup(y_squared) - - -
-
-Purpose -
-This routine splits up the computation into the individual threads. - -
-
-Thread -
-It is assumed that this function is called by thread zero -and all the other threads are blocked (waiting). - -
-
-y_squared -
-This argument has prototype - -
-     const vector<double>& 
y_squared
-
-and its size is equal to the number of equations to solve. -It is the values that we are computing the square root of. - -
-
-ok -
-This return value has prototype - -
-     bool 
ok
-
-If it is false, -multi_atomic_setup detected an error. - -
-
-Source - -

-namespace {
-bool multi_atomic_setup(const vector<double>& y_squared)
-{     using CppAD::AD;
-     size_t num_threads = std::max(num_threads_, size_t(1));
-     bool   ok          = num_threads == thread_alloc::num_threads();
-     ok                &= thread_alloc::thread_num() == 0;
-     //
-     // declare independent variable variable vector
-     vector< AD<double> > ax(1);
-     ax[0] = 2.0;
-     CppAD::Independent(ax);
-     //
-     // argument and result for atomic function
-     vector< AD<double> > au(3), ay(1);
-     au[0] = AD<double>( num_itr_ ); // num_itr
-     au[1] = ax[0];                  // y_initial
-     au[2] = ax[0];                  // y_squared
-     // put user atomic operation in recording
-     (*a_square_root_)(au, ay);
-     //
-     // f(u) = sqrt(u)
-     CppAD::ADFun<double> fun(ax, ay);
-     //
-     // number of square roots for each thread
-     size_t per_thread = (y_squared.size() + num_threads - 1) / num_threads;
-     size_t y_index    = 0;
-     //
-     for(size_t thread_num = 0; thread_num < num_threads; thread_num++)
-     {     // allocate separate memory for each thread to avoid false sharing
-          size_t min_bytes(sizeof(work_one_t)), cap_bytes;
-          void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes);
-          work_all_[thread_num] = static_cast<work_one_t*>(v_ptr);
-          //
-          // Run constructor on work_all_[thread_num]->fun
-          work_all_[thread_num]->fun = new CppAD::ADFun<double>;
-          //
-          // Run constructor on work_all_[thread_num] vectors
-          work_all_[thread_num]->y_squared = new vector<double>;
-          work_all_[thread_num]->square_root = new vector<double>;
-          //
-          // Each worker gets a separate copy of fun. This is necessary because
-          // the Taylor coefficients will be set by each thread.
-          *(work_all_[thread_num]->fun) = fun;
-          //
-          // values we are computing square root of for this thread
-          ok &=  0 == work_all_[thread_num]->y_squared->size();
-          for(size_t i = 0; i < per_thread; i++)
-          if( y_index < y_squared.size() )
-               work_all_[thread_num]->y_squared->push_back(y_squared[y_index++]);
-          //
-          // set to false in case this thread's worker does not get called
-          work_all_[thread_num]->ok = false;
-     }
-     ok &= y_index == y_squared.size();
-     //
-     return ok;
-}
-}
- -
Input File: example/multi_thread/multi_atomic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_atomic_setup_xml.js cppad-2019.02.00.0/doc/_multi_atomic_setup_xml.js --- cppad-2018.00.00.0/doc/_multi_atomic_setup_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_atomic_setup_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_atomic.cpp.xml', -'multi_atomic_setup.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_atomic_user.xml', -'multi_atomic_common.xml', -'multi_atomic_setup.xml', -'multi_atomic_worker.xml', -'multi_atomic_takedown.xml', -'multi_atomic_run.xml', -'multi_atomic_time.xml' -]; -var list_current0 = [ -'multi_atomic_setup.xml#Syntax', -'multi_atomic_setup.xml#Purpose', -'multi_atomic_setup.xml#Thread', -'multi_atomic_setup.xml#y_squared', -'multi_atomic_setup.xml#ok', -'multi_atomic_setup.xml#Source' -]; -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-2018.00.00.0/doc/multi_atomic_takedown.xml cppad-2019.02.00.0/doc/multi_atomic_takedown.xml --- cppad-2018.00.00.0/doc/multi_atomic_takedown.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_atomic_takedown.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,200 +0,0 @@ - - - -Multi-Threaded User Atomic Take Down - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_atomic_takedown - -

-
Multi-Threaded User Atomic Take Down
-
-Syntax - -
- -ok = multi_atomic_takedown(square_root) - - -
-
-Purpose -
-This routine gathers up the results for each thread and -frees memory that was allocated by multi_atomic_setup -. - -
-
-Thread -
-It is assumed that this function is called by thread zero -and all the other threads are blocked (waiting). - -
-
-square_root -
-This argument has prototype - -
-     vector<double>& 
square_root
-
-The input value of -square_root - does not matter. -Upon return, -it has the same size and is the element by element square root of -y_squared -. - -
-
-ok -
-This return value has prototype - -
-     bool 
ok
-
-If it is false, -multi_atomic_takedown detected an error. - -
-
-Source - -

-namespace {
-bool multi_atomic_takedown(vector<double>& square_root)
-{     bool ok            = true;
-     ok                &= thread_alloc::thread_num() == 0;
-     size_t num_threads = std::max(num_threads_, size_t(1));
-     //
-     // extract square roots in original order
-     square_root.resize(0);
-     for(size_t thread_num = 0; thread_num < num_threads; thread_num++)
-     {     // results for this thread
-          size_t n = work_all_[thread_num]->square_root->size();
-          for(size_t i = 0; i < n; i++)
-               square_root.push_back((* work_all_[thread_num]->square_root )[i]);
-     }
-     //
-     // go down so that free memory for other threads before memory for master
-     size_t thread_num = num_threads;
-     while(thread_num--)
-     {     // check that this tread was ok with the work it did
-          ok  &= work_all_[thread_num]->ok;
-          //
-          // run destructor on vector object for this thread
-          delete work_all_[thread_num]->y_squared;
-          delete work_all_[thread_num]->square_root;
-          //
-          // run destructor on function object for this thread
-          delete work_all_[thread_num]->fun;
-          //
-          // delete problem specific information
-          void* v_ptr = static_cast<void*>( work_all_[thread_num] );
-          thread_alloc::return_memory( v_ptr );
-          //
-          // check that there is no longer any memory inuse by this thread
-          if( thread_num > 0 )
-          {     ok &= 0 == thread_alloc::inuse(thread_num);
-               //
-               // return all memory being held for future use by this thread
-               thread_alloc::free_available(thread_num);
-          }
-     }
-     return ok;
-}
-}
- -
Input File: example/multi_thread/multi_atomic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_atomic_takedown_xml.js cppad-2019.02.00.0/doc/_multi_atomic_takedown_xml.js --- cppad-2018.00.00.0/doc/_multi_atomic_takedown_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_atomic_takedown_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_atomic.cpp.xml', -'multi_atomic_takedown.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_atomic_user.xml', -'multi_atomic_common.xml', -'multi_atomic_setup.xml', -'multi_atomic_worker.xml', -'multi_atomic_takedown.xml', -'multi_atomic_run.xml', -'multi_atomic_time.xml' -]; -var list_current0 = [ -'multi_atomic_takedown.xml#Syntax', -'multi_atomic_takedown.xml#Purpose', -'multi_atomic_takedown.xml#Thread', -'multi_atomic_takedown.xml#square_root', -'multi_atomic_takedown.xml#ok', -'multi_atomic_takedown.xml#Source' -]; -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-2018.00.00.0/doc/multi_atomic_time.xml cppad-2019.02.00.0/doc/multi_atomic_time.xml --- cppad-2018.00.00.0/doc/multi_atomic_time.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_atomic_time.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,190 +0,0 @@ - - - -Timing Test for Multi-Threaded User Atomic Calculation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_atomic_time - -

-
Timing Test for Multi-Threaded User Atomic Calculation
-
-Syntax - -
- -ok = multi_atomic_time(
-     
time_outtest_timenum_threadsnum_itr
-)
- - - -
-
-Thread -
-It is assumed that this function is called by thread zero in sequential -mode; i.e., not in_parallel -. - -
-
-time_out -
-This argument has prototype - -
-     double& 
time_out
-
-Its input value of the argument does not matter. -Upon return it is the number of wall clock seconds -used by multi_atomic_run -. - -
-
-test_time -
-This argument has prototype - -
-     double 
test_time
-
-and 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. -The reported -time_out - is the total wall clock time divided by the -number of repeats. - -
-
-num_threads -
-This argument has prototype - -
-     size_t 
num_threads
-
-It specifies the number of threads that are available for this test. -If it is zero, the test is run without the multi-threading environment and - -
-     1 == thread_alloc::num_threads()
-
-If it is non-zero, the test is run with the multi-threading and - -
-     
num_threads = thread_alloc::num_threads()
-
-
-num_solve -
-This specifies the number of square roots that will be solved for. - -
-
-ok -
-The return value has prototype - -
-     bool 
ok
-
-If it is true, -harmonic_time passed the correctness test and -multi_atomic_time did not detect an error. -Otherwise it is false. - - -
Input File: example/multi_thread/multi_atomic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_atomic_time_xml.js cppad-2019.02.00.0/doc/_multi_atomic_time_xml.js --- cppad-2018.00.00.0/doc/_multi_atomic_time_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_atomic_time_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,91 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_atomic.cpp.xml', -'multi_atomic_time.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_atomic_user.xml', -'multi_atomic_common.xml', -'multi_atomic_setup.xml', -'multi_atomic_worker.xml', -'multi_atomic_takedown.xml', -'multi_atomic_run.xml', -'multi_atomic_time.xml' -]; -var list_current0 = [ -'multi_atomic_time.xml#Syntax', -'multi_atomic_time.xml#Thread', -'multi_atomic_time.xml#time_out', -'multi_atomic_time.xml#test_time', -'multi_atomic_time.xml#num_threads', -'multi_atomic_time.xml#num_solve', -'multi_atomic_time.xml#ok' -]; -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-2018.00.00.0/doc/multi_atomic_user.xml cppad-2019.02.00.0/doc/multi_atomic_user.xml --- cppad-2018.00.00.0/doc/multi_atomic_user.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_atomic_user.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,269 +0,0 @@ - - - -Defines a User Atomic Operation that Computes Square Root - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_atomic_user - -

-
Defines a User Atomic Operation that Computes Square Root
-
-Syntax - -
- -atomic_user a_square_root
-
- -a_square_root(auay) - - -
-
-Purpose -
-This user atomic operation computes a square root using Newton's method. -It is meant to be very inefficient in order to demonstrate timing results. - -
-
-au -
-This argument has prototype - -
-     const 
ADvectorau
-
-where -ADvector - is a -simple vector class - with elements -of type AD<double>. -The size of -au - is three. - -
-
-num_itr -
-We use the notation - -
-     
num_itr = size_t( Integer( au[0] ) )
-
-for the number of Newton iterations in the computation of the square root -function. The component -au[0] - must be a -parameter -. - -
-
-y_initial -
-We use the notation - -
-     
y_initial = au[1]
-
-for the initial value of the Newton iterate. - -
-
-y_squared -
-We use the notation - -
-     
y_squared = au[2]
-
-for the value we are taking the square root of. - -
-
-ay -
-This argument has prototype - -
-     
ADvectoray
-
-The size of -ay - is one and - -ay[0] - is the square root of -y_squared -. - -
-
-Limitations -
-Only zero order forward mode is implements for the -atomic_user class. - -
-
-Source - -

-// includes used by all source code in multi_atomic.cpp file
-# include <cppad/cppad.hpp>
-# include "multi_atomic.hpp"
-# include "team_thread.hpp"
-//
-namespace {
-using CppAD::thread_alloc; // fast multi-threading memory allocator
-using CppAD::vector;       // uses thread_alloc
-
-class atomic_user : public CppAD::atomic_base<double> {
-public:
-     // ctor
-     atomic_user(void)
-     : CppAD::atomic_base<double>("atomic_square_root")
-     { }
-private:
-     // forward mode routine called by CppAD
-     virtual bool forward(
-          size_t                   p   ,
-          size_t                   q   ,
-          const vector<bool>&      vu  ,
-          vector<bool>&            vy  ,
-          const vector<double>&    tu  ,
-          vector<double>&          ty  )
-     {
-# ifndef NDEBUG
-          size_t n = tu.size() / (q + 1);
-          size_t m = ty.size() / (q + 1);
-          assert( n == 3 );
-          assert( m == 1 );
-# endif
-          // only implementing zero order forward for this example
-          if( q != 0 )
-               return false;
-
-          // extract components of argument vector
-          size_t num_itr    = size_t( tu[0] );
-          double y_initial  = tu[1];
-          double y_squared  = tu[2];
-
-          // check for setting variable information
-          if( vu.size() > 0 )
-          {     if( vu[0] )
-                    return false;
-               vy[0] = vu[1] || vu[2];
-          }
-
-          // Use Newton's method to solve f(y) = y^2 = y_squared
-          double y_itr = y_initial;
-          for(size_t itr = 0; itr < num_itr; itr++)
-          {     // solve (y - y_itr) * f'(y_itr) = y_squared - y_itr^2
-               double fp_itr = 2.0 * y_itr;
-               y_itr         = y_itr + (y_squared - y_itr * y_itr) / fp_itr;
-          }
-
-          // return the Newton approximation for f(y) = y_squared
-          ty[0] = y_itr;
-          return true;
-     }
-};
-}
- -
Input File: example/multi_thread/multi_atomic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_atomic_user_xml.js cppad-2019.02.00.0/doc/_multi_atomic_user_xml.js --- cppad-2018.00.00.0/doc/_multi_atomic_user_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_atomic_user_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_atomic.cpp.xml', -'multi_atomic_user.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_atomic_user.xml', -'multi_atomic_common.xml', -'multi_atomic_setup.xml', -'multi_atomic_worker.xml', -'multi_atomic_takedown.xml', -'multi_atomic_run.xml', -'multi_atomic_time.xml' -]; -var list_current0 = [ -'multi_atomic_user.xml#Syntax', -'multi_atomic_user.xml#Purpose', -'multi_atomic_user.xml#au', -'multi_atomic_user.xml#au.num_itr', -'multi_atomic_user.xml#au.y_initial', -'multi_atomic_user.xml#au.y_squared', -'multi_atomic_user.xml#ay', -'multi_atomic_user.xml#Limitations', -'multi_atomic_user.xml#Source' -]; -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-2018.00.00.0/doc/multi_atomic_worker.xml cppad-2019.02.00.0/doc/multi_atomic_worker.xml --- cppad-2018.00.00.0/doc/multi_atomic_worker.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_atomic_worker.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ - - - -Multi-Threaded User Atomic Worker - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_atomic_worker - -

-
Multi-Threaded User Atomic Worker
-
-Purpose -
-This routine does the computation for one thread. - -
-
-Source - -

-namespace {
-void multi_atomic_worker(void)
-{     size_t thread_num  = thread_alloc::thread_num();
-     size_t num_threads = std::max(num_threads_, size_t(1));
-     bool   ok          = thread_num < num_threads;
-     //
-     vector<double> x(1), y(1);
-     size_t n = work_all_[thread_num]->y_squared->size();
-     work_all_[thread_num]->square_root->resize(n);
-     for(size_t i = 0; i < n; i++)
-     {     x[0] = (* work_all_[thread_num]->y_squared )[i];
-          y    = work_all_[thread_num]->fun->Forward(0, x);
-          //
-          (* work_all_[thread_num]->square_root )[i] = y[0];
-     }
-     work_all_[thread_num]->ok             = ok;
-}
-}
- -
Input File: example/multi_thread/multi_atomic.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_atomic_worker_xml.js cppad-2019.02.00.0/doc/_multi_atomic_worker_xml.js --- cppad-2018.00.00.0/doc/_multi_atomic_worker_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_atomic_worker_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_atomic.cpp.xml', -'multi_atomic_worker.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_atomic_user.xml', -'multi_atomic_common.xml', -'multi_atomic_setup.xml', -'multi_atomic_worker.xml', -'multi_atomic_takedown.xml', -'multi_atomic_run.xml', -'multi_atomic_time.xml' -]; -var list_current0 = [ -'multi_atomic_worker.xml#Purpose', -'multi_atomic_worker.xml#Source' -]; -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-2018.00.00.0/doc/multi_newton_common.xml cppad-2019.02.00.0/doc/multi_newton_common.xml --- cppad-2018.00.00.0/doc/multi_newton_common.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_newton_common.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,156 +0,0 @@ - - - -Common Variables use by Multi-Threaded Newton Method - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_newton_common - -

-
Common Variables use by Multi-Threaded Newton Method
-
-Purpose -
-This source code defined the common -include files, defines, and variables that are used by the -multi-newton method. - -
-
-Source - -

-# include <cppad/cppad.hpp>
-# include <cppad/utility/time_test.hpp>
-# include <cmath>
-# include <cstring>
-# include "multi_newton.hpp"
-# include "team_thread.hpp"
-# define USE_THREAD_ALLOC_FOR_WORK_ALL 1
-
-namespace {
-     using CppAD::thread_alloc; // fast multi-threadeding memory allocator
-     using CppAD::vector;       // uses thread_alloc
-
-     // number of threads, set by multi_newton_time.
-     size_t num_threads_ = 0;
-
-     // function we are finding zeros of, set by multi_newton_time
-     void (*fun_)(double x, double& f, double& df) = 0;
-
-     // convergence criteria, set by multi_newton_setup
-     double epsilon_ = 0.;
-
-     // maximum number of iterations, set by  multi_newton_setup
-     size_t max_itr_ = 0;
-
-     // length for all sub-intervals
-     double sub_length_ = 0.;
-
-     // structure with information for one thread
-     typedef struct {
-          // number of sub intervals (worker input)
-          size_t num_sub;
-          // beginning of interval (worker input)
-          double xlow;
-          // end of interval (worker input)
-          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_takedown: x.size() == 0
-          vector<double> x;
-          // false if an error occurs, true otherwise (worker output)
-          bool   ok;
-     } work_one_t;
-     // vector with information for all threads
-     // after call to multi_newton_setup:    work_all.size() == num_threads
-     // after call to multi_newton_takedown: work_all.size() == 0
-     // (use pointers instead of values to avoid false sharing)
-     vector<work_one_t*> work_all_;
-}
- -
Input File: example/multi_thread/multi_newton.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_newton_common_xml.js cppad-2019.02.00.0/doc/_multi_newton_common_xml.js --- cppad-2018.00.00.0/doc/_multi_newton_common_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_newton_common_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_newton.cpp.xml', -'multi_newton_common.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_newton_common.xml', -'multi_newton_setup.xml', -'multi_newton_worker.xml', -'multi_newton_takedown.xml', -'multi_newton_run.xml', -'multi_newton_time.xml' -]; -var list_current0 = [ -'multi_newton_common.xml#Purpose', -'multi_newton_common.xml#Source' -]; -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-2018.00.00.0/doc/multi_newton.cpp.xml cppad-2019.02.00.0/doc/multi_newton.cpp.xml --- cppad-2018.00.00.0/doc/multi_newton.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_newton.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ - - - -Multi-Threaded Newton Method Example / Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Multi-Threaded Newton Method Example / Test
-
-Source File -
-All of the routines below are located in the file -
 
-     example/multi_thread/multi_newton.cpp
-
-
-Contents -
- -
multi_newton_commonCommon Variables use by Multi-Threaded Newton Method
multi_newton_setupSet Up Multi-Threaded Newton Method
multi_newton_workerDo One Thread's Work for Multi-Threaded Newton Method
multi_newton_takedownTake Down Multi-threaded Newton Method
multi_newton_runA Multi-Threaded Newton's Method
multi_newton_timeTiming Test of Multi-Threaded Newton Method
-
Input File: example/multi_thread/multi_newton.omh - - - diff -Nru cppad-2018.00.00.0/doc/_multi_newton.cpp_xml.js cppad-2019.02.00.0/doc/_multi_newton.cpp_xml.js --- cppad-2018.00.00.0/doc/_multi_newton.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_newton.cpp_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_newton.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down1 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down0 = [ -'multi_newton_common.xml', -'multi_newton_setup.xml', -'multi_newton_worker.xml', -'multi_newton_takedown.xml', -'multi_newton_run.xml', -'multi_newton_time.xml' -]; -var list_current0 = [ -'multi_newton.cpp.xml#Source File', -'multi_newton.cpp.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-2018.00.00.0/doc/multi_newton_run.xml cppad-2019.02.00.0/doc/multi_newton_run.xml --- cppad-2018.00.00.0/doc/multi_newton_run.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_newton_run.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,558 +0,0 @@ - - - -A Multi-Threaded Newton's Method - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_newton_run - -

-
A Multi-Threaded Newton's Method
-
-Syntax - -
- -ok = multi_newton_run(xout,
-     
funnum_subxlowxupepsilonmax_itrnum_threads
-)
- - -
-
-Purpose -
-Multi-threaded determination of the argument values - -x - - -, -in the interval - -[ -a -, -b -] - - - (where - -a -< -b - - -), -such that - -f -( -x -) -= -0 - - -. - -
-
-Thread -
-It is assumed that this function is called by thread zero, -and all the other threads are blocked (waiting). - -
-
-Method -
-For - -i -= -0 -, - -, -n - - -, -we define the i-th grid point - -g -i - - - - by - - -g -i - -= -a -n -- -i - -n - - -+ -b -i - -n - - - - -For - -i -= -0 -, - -, -n --1 - - -, -we define the i-th sub-interval of - -[ -a -, -b -] - - - by - - -I -i - -= -[ -g -i - -, -g -i -+ -1 - - -] - - -Newton's method is applied starting -at the center of each of the sub-intervals - -I -i - - - - for - - -i -= -0 -, - -, -n --1 - - - -and at most one zero is found for each sub-interval. - -
-
-ok -
-The return value -ok - has prototype - -
-     bool 
ok
-
-If an error occurs, it is false, otherwise it is true. - -
-
-xout -
-The argument -xout - has the prototype - -
-     vector<double>& 
xout
-
-The input size and value of the elements of -xout - do not matter. -Upon return from multi_newton, -the size of -xout - is less than or equal -the number of sub-intervals - -n - - - and - - -| -f -( -xout -[ -i -] -) -| - -epsilon - - -for each valid index -0 <= i < xout.size() -. -Two - -x - - - solutions are considered equal (and joined as one) if -the absolute difference between the solutions is less than - - -( -b -- -a -) -/ -n - - -. - -
-
-fun -
-The argument -fun - has prototype - -
-     void 
fun (double x, double& f, double& df)
-
-This function must evaluate - -f -( -x -) - - -, -and its derivative - -f -( -1 -) - - -( -x -) - - -, -using the syntax - -
-     
fun(xfdf)
-
-where the arguments to -fun - have the prototypes - -
-     double    
x
-     double&   
f
-     double&   
df
-
-. -The input values of -f - and -df - do not matter. -Upon return they are - -f -( -x -) - - - and - -f -( -1 -) - - -( -x -) - - - respectively. - -
-
-num_sub -
-The argument -num_sub - has prototype - -
-     size_t 
num_sub
-
-It specifies the number of sub-intervals; i.e., - -n - - -. - -
-
-xlow -
-The argument -xlow - has prototype - -
-     double 
xlow
-
-It specifies the lower limit for the entire search interval; i.e., - -a - - -. - -
-
-xup -
-The argument -xup - has prototype - -
-     double 
xup
-
-It specifies the upper limit for the entire search interval; i.e., - -b - - -. - -
-
-epsilon -
-The argument -epsilon - has prototype - -
-     double 
epsilon
-
-It specifies the convergence criteria for Newton's method in terms -of how small the function value must be. - -
-
-max_itr -
-The argument -max_itr - has prototype - -
-     size_t 
max_itr
-
-It specifies the maximum number of iterations of Newton's method to try -before giving up on convergence (on each sub-interval). - -
-
-num_threads -
-This argument has prototype - -
-     size_t 
num_threads
-
-It specifies the number of threads that are available for this test. -If it is zero, the test is run without the multi-threading environment. - -
-
-Source - -

-namespace {
-bool multi_newton_run(
-     vector<double>& 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;
-     ok     &= thread_alloc::thread_num() == 0;
-
-     // setup the work for num_threads threads
-     ok &= multi_newton_setup(
-          num_sub, xlow, xup, epsilon, max_itr, num_threads
-     );
-
-     // now do the work for each thread
-     if( num_threads > 0 )
-          team_work( multi_newton_worker );
-     else     multi_newton_worker();
-
-     // now combine the results for all the threads
-     ok &= multi_newton_takedown(xout);
-
-     return ok;
-}
-}
- -
Input File: example/multi_thread/multi_newton.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_newton_run_xml.js cppad-2019.02.00.0/doc/_multi_newton_run_xml.js --- cppad-2018.00.00.0/doc/_multi_newton_run_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_newton_run_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_newton.cpp.xml', -'multi_newton_run.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_newton_common.xml', -'multi_newton_setup.xml', -'multi_newton_worker.xml', -'multi_newton_takedown.xml', -'multi_newton_run.xml', -'multi_newton_time.xml' -]; -var list_current0 = [ -'multi_newton_run.xml#Syntax', -'multi_newton_run.xml#Purpose', -'multi_newton_run.xml#Thread', -'multi_newton_run.xml#Method', -'multi_newton_run.xml#ok', -'multi_newton_run.xml#xout', -'multi_newton_run.xml#fun', -'multi_newton_run.xml#num_sub', -'multi_newton_run.xml#xlow', -'multi_newton_run.xml#xup', -'multi_newton_run.xml#epsilon', -'multi_newton_run.xml#max_itr', -'multi_newton_run.xml#num_threads', -'multi_newton_run.xml#Source' -]; -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-2018.00.00.0/doc/multi_newton_setup.xml cppad-2019.02.00.0/doc/multi_newton_setup.xml --- cppad-2018.00.00.0/doc/multi_newton_setup.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_newton_setup.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,262 +0,0 @@ - - - -Set Up Multi-Threaded Newton Method - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_newton_setup - -

-
Set Up Multi-Threaded Newton Method
-
-Syntax - -
- -ok = multi_newton_setup(
-     
num_subxlowxupepsilonmax_itrnum_threads
-)
- - -
-
-Purpose -
-These routine does the setup for splitting finding all the zeros in an -interval into separate sub-intervals, one for each thread. - -
-
-Thread -
-It is assumed that this function is called by thread zero, -and all the other threads are blocked (waiting). - -
-
-num_sub -
-See -num_sub - in multi_newton_run -. - -
-
-xlow -
-See -xlow - in multi_newton_run -. - -
-
-xup -
-See -xup - in multi_newton_run -. - -
-
-epsilon -
-See -epsilon - in multi_newton_run -. - -
-
-max_itr -
-See -max_itr - in multi_newton_run -. - -
-
-num_threads -
-See -num_threads - in -multi_newton_run -. - -
-
-Source - -

-namespace {
-bool multi_newton_setup(
-     size_t num_sub                              ,
-     double xlow                                 ,
-     double xup                                  ,
-     double epsilon                              ,
-     size_t max_itr                              ,
-     size_t num_threads                          )
-{
-     num_threads  = std::max(num_threads_, size_t(1));
-     bool ok      = num_threads == thread_alloc::num_threads();
-     ok          &= thread_alloc::thread_num() == 0;
-
-     // inputs that are same for all threads
-     epsilon_ = epsilon;
-     max_itr_ = max_itr;
-
-     // resize the work vector to accomidate the number of threads
-     ok &= work_all_.size() == 0;
-     work_all_.resize(num_threads);
-
-     // length of each sub interval
-     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_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;
-     for(thread_num = 0; thread_num < num_threads; thread_num++)
-     {
-# if  USE_THREAD_ALLOC_FOR_WORK_ALL
-          // allocate separate memory for this thread to avoid false sharing
-          size_t min_bytes(sizeof(work_one_t)), cap_bytes;
-          void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes);
-          work_all_[thread_num] = static_cast<work_one_t*>(v_ptr);
-
-          // thread_alloc is a raw memory allocator; i.e., it does not call
-          // the constructor for the objects it creates. The vector
-          // class requires it's constructor to be called so we do it here
-          new(& (work_all_[thread_num]->x) ) vector<double>();
-# else
-          work_all_[thread_num] = new work_one_t;
-# endif
-
-          // number of sub-intervalse for this thread
-          if( thread_num < num_more  )
-               num_sub_thread = num_min + 1;
-          else     num_sub_thread = num_min;
-
-          // when thread_num == 0, xlow_thread == xlow
-          double xlow_thread = xlow + double(sum_num) * sub_length_;
-
-          // when thread_num == num_threads - 1, xup_thread = xup
-          double xup_thread =
-               xlow + double(sum_num + num_sub_thread) * sub_length_;
-          if( thread_num == num_threads - 1 )
-               xup_thread = xup;
-
-          // update sum_num for next time through loop
-          sum_num += num_sub_thread;
-
-          // input information specific to this thread
-          work_all_[thread_num]->num_sub = num_sub_thread;
-          work_all_[thread_num]->xlow    = xlow_thread;
-          work_all_[thread_num]->xup     = xup_thread;
-          ok &= work_all_[thread_num]->x.size() == 0;
-
-          // in case this thread does not get called
-          work_all_[thread_num]->ok = false;
-     }
-     ok &= sum_num == num_sub;
-     return ok;
-}
-}
- -
Input File: example/multi_thread/multi_newton.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_newton_setup_xml.js cppad-2019.02.00.0/doc/_multi_newton_setup_xml.js --- cppad-2018.00.00.0/doc/_multi_newton_setup_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_newton_setup_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_newton.cpp.xml', -'multi_newton_setup.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_newton_common.xml', -'multi_newton_setup.xml', -'multi_newton_worker.xml', -'multi_newton_takedown.xml', -'multi_newton_run.xml', -'multi_newton_time.xml' -]; -var list_current0 = [ -'multi_newton_setup.xml#Syntax', -'multi_newton_setup.xml#Purpose', -'multi_newton_setup.xml#Thread', -'multi_newton_setup.xml#num_sub', -'multi_newton_setup.xml#xlow', -'multi_newton_setup.xml#xup', -'multi_newton_setup.xml#epsilon', -'multi_newton_setup.xml#max_itr', -'multi_newton_setup.xml#num_threads', -'multi_newton_setup.xml#Source' -]; -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-2018.00.00.0/doc/multi_newton_takedown.xml cppad-2019.02.00.0/doc/multi_newton_takedown.xml --- cppad-2018.00.00.0/doc/multi_newton_takedown.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_newton_takedown.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,196 +0,0 @@ - - - -Take Down Multi-threaded Newton Method - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_newton_takedown - -

-
Take Down Multi-threaded Newton Method
-
-Syntax - -
- -ok = harmonic_takedown(xout)
-
-
-Purpose -
-This routine does the takedown for splitting the Newton method into -sub-intervals. - -
-
-Thread -
-It is assumed that this function is called by thread zero, -and all the other threads have completed their work and are blocked (waiting). - -
-
-xout -
-See multi_newton_run -. - -
-
-Source - -

-namespace {
-bool multi_newton_takedown(vector<double>& xout)
-{     // number of threads in the calculation
-     size_t num_threads  = std::max(num_threads_, size_t(1));
-
-     // remove duplicates and points that are not solutions
-     xout.resize(0);
-     bool   ok = true;
-     ok       &= thread_alloc::thread_num() == 0;
-
-     // initialize as more that sub_length_ / 2 from any possible solution
-     double xlast = - sub_length_;
-     for(size_t thread_num = 0; thread_num < num_threads; thread_num++)
-     {     vector<double>& x = work_all_[thread_num]->x;
-
-          size_t i;
-          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_ )
-               {     xout.push_back( x[i] );
-                    xlast = x[i];
-               }
-               else
-               {     double fcur, flast, df;
-                    fun_(x[i],   fcur, df);
-                    fun_(xlast, flast, df);
-                    if( fabs(fcur) < fabs(flast) )
-                    {     xout[ xout.size() - 1] = x[i];
-                         xlast                  = x[i];
-                    }
-               }
-          }
-          // check that this thread was ok with the work it did
-          ok &= work_all_[thread_num]->ok;
-     }
-
-     // go down so free memory for other threads before memory for master
-     size_t thread_num = num_threads;
-     while(thread_num--)
-     {
-# if USE_THREAD_ALLOC_FOR_WORK_ALL
-          // call the destructor for vector destructor
-          work_all_[thread_num]->x.~vector<double>();
-          // delete the raw memory allocation
-          void* v_ptr = static_cast<void*>( 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).
-          if( thread_num > 0 )
-          {     // check that there is no longer any memory inuse by this thread
-               ok &= thread_alloc::inuse(thread_num) == 0;
-               // return all memory being held for future use by this thread
-               thread_alloc::free_available(thread_num);
-          }
-     }
-     // now we are done with the work_all_ vector so free its memory
-     // (because it is a static variable)
-     work_all_.clear();
-
-     return ok;
-}
-}
- -
Input File: example/multi_thread/multi_newton.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_newton_takedown_xml.js cppad-2019.02.00.0/doc/_multi_newton_takedown_xml.js --- cppad-2018.00.00.0/doc/_multi_newton_takedown_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_newton_takedown_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_newton.cpp.xml', -'multi_newton_takedown.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_newton_common.xml', -'multi_newton_setup.xml', -'multi_newton_worker.xml', -'multi_newton_takedown.xml', -'multi_newton_run.xml', -'multi_newton_time.xml' -]; -var list_current0 = [ -'multi_newton_takedown.xml#Syntax', -'multi_newton_takedown.xml#Purpose', -'multi_newton_takedown.xml#Thread', -'multi_newton_takedown.xml#xout', -'multi_newton_takedown.xml#Source' -]; -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-2018.00.00.0/doc/multi_newton_time.xml cppad-2019.02.00.0/doc/multi_newton_time.xml --- cppad-2018.00.00.0/doc/multi_newton_time.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_newton_time.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,512 +0,0 @@ - - - -Timing Test of Multi-Threaded Newton Method - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_newton_time - -

-. - -
Timing Test of Multi-Threaded Newton Method
-
-Syntax - -
- -ok = multi_newton_time(time_outtest_timenum_threads,
-     
num_zeronum_subnum_sumuse_ad
-)
- - -
-
-Purpose -
-Runs correctness and timing test for a multi-threaded Newton method. -This test uses Newton's method to determine all the zeros of the sine -function on an interval. -CppAD, or hand coded derivatives, -can be used to calculate the derivatives used by Newton's method. -The calculation can be done in parallel on the different sub-intervals. -In addition, the calculation can be done without multi-threading. - -
-
-Thread -
-It is assumed that this function is called by thread zero in sequential -mode; i.e., not in_parallel -. - -
-
-ok -
-This return value has prototype - -
-     bool 
ok
-
-If it is true, -multi_newton_time passed the correctness test. -Otherwise it is false. - -
-
-time_out -
-This argument has prototype - -
-     double& 
time_out
-
-The input value of the argument does not matter. -Upon return it is the number of wall clock seconds required for -the multi-threaded Newton method can compute all the zeros. - -
-
-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. -The reported -time_out - is the total wall clock time divided by the -number of repeats. - -
-
-num_threads -
-This argument has prototype - -
-     size_t 
num_threads
-
-It specifies the number of threads that -are available for this test. -If it is zero, the test is run without multi-threading and - -
-     1 == thread_alloc::num_threads()
-
-when multi_newton_time is called. -If it is non-zero, the test is run with multi-threading and - -
-     
num_threads == thread_alloc::num_threads()
-
-when multi_newton_time is called. - -
-
-num_zero -
-This argument has prototype - -
-     size_t 
num_zero
-
-and it must be greater than one. -It specifies the actual number of zeros in the test function - - -sin -( -x -) - - -. -To be specific, multi_newton_time will attempt to determine -all of the values of - -x - - - for which - -sin -( -x -) -= -0 - - - and - - -x - - - is in the interval - -
-     [ 0 , (
num_zero - 1) * pi ]
-
-. - -
-
-num_sub -
-This argument has prototype - -
-     size_t 
num_sub
-
-It specifies the number of sub-intervals to divide the total interval into. -It must be greater than -num_zero - -(so that the correctness test can check we have found all the zeros). - -
-
-num_sum -
-This argument has prototype - -
-     size_t 
num_sum
-
-and must be greater than zero. -The actual function used by the Newton method is - - -f -( -x -) -= -1 - -n - - - -i -= -1 - -n - - -sin -( -x -) - - -where - -n - - - is equal to -num_sum -. -Larger values of -num_sum - simulate a case where the -evaluation of the function - -f -( -x -) - - - takes more time. - -
-
-use_ad -
-This argument has prototype - -
-     bool 
user_ad
-
-If -use_ad - is true, -then derivatives will be computed using CppAD. -Note that this derivative computation includes -re-taping the function for each -value of - -x - - - (even though re-taping is not necessary). -
-
-
If -use_ad - is false, -derivatives will be computed using a hand coded routine. - -
-
-Source - -

-
-namespace { // empty namespace
-
-     // values correspond to arguments in previous call 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
-
-     // value of xout corresponding to most recent call to test_once
-     vector<double> xout_;
-
-     // A version of the sine function that can be made as slow as we like
-     template <class Float>
-     Float f_eval(Float x)
-     {     Float sum = 0.;
-          size_t i;
-          for(i = 0; i < num_sum_; i++)
-               sum += sin(x);
-
-          return sum / Float(num_sum_);
-     }
-
-     // Direct calculation of derivative with same number of floating point
-     // operations as for f_eval.
-     double df_direct(double x)
-     {     double sum = 0.;
-          size_t i;
-          for(i = 0; i < num_sum_; i++)
-               sum += cos(x);
-
-          return sum / double(num_sum_);
-     }
-
-     // AD calculation of detivative
-     void fun_ad(double x, double& f, double& df)
-     {     using CppAD::AD;
-
-          // use vector because it uses fast multi-threaded memory alloc
-          vector< AD<double> > X(1), Y(1);
-          X[0] = x;
-          CppAD::Independent(X);
-          Y[0] = f_eval(X[0]);
-          CppAD::ADFun<double> F(X, Y);
-          vector<double> dx(1), dy(1);
-          dx[0] = 1.;
-          dy    = F.Forward(1, dx);
-          f     = Value( Y[0] );
-          df    = dy[0];
-          return;
-     }
-
-     // evaulate the function and its derivative
-     void fun_no(double x, double& f, double& df)
-     {     f  = f_eval(x);
-          df = df_direct(x);
-          return;
-     }
-
-
-     // Run computation of all the zeros once
-     void test_once(void)
-     {     if(  num_zero_ == 0 )
-          {     std::cerr << "multi_newton_time: num_zero == 0" << std::endl;
-               exit(1);
-          }
-          double pi      = 4. * std::atan(1.);
-          double xlow    = 0.;
-          double xup     = double(num_zero_ - 1) * pi;
-          double eps     =
-               xup * 100. * CppAD::numeric_limits<double>::epsilon();
-          size_t max_itr = 20;
-
-          // note that fun_ is set to fun_ad or fun_no by multi_newton_time
-          bool ok = multi_newton_run(
-               xout_       ,
-               fun_        ,
-               num_sub_    ,
-               xlow        ,
-               xup         ,
-               eps         ,
-               max_itr     ,
-               num_threads_
-          );
-          if( ! ok )
-          {     std::cerr << "multi_newton: error" << std::endl;
-               exit(1);
-          }
-          return;
-     }
-
-     // Repeat computation of all the zeros a specied number of times
-     void test_repeat(size_t repeat)
-     {     size_t i;
-          for(i = 0; i < repeat; i++)
-               test_once();
-          return;
-     }
-} // end empty namespace
-
-
-// This is the only routine that is accessible outside of this file
-bool multi_newton_time(
-     double& time_out      ,
-     double  test_time     ,
-     size_t  num_threads   ,
-     size_t  num_zero      ,
-     size_t  num_sub       ,
-     size_t  num_sum       ,
-     bool    use_ad
-)
-{
-     bool ok = true;
-     ok     &= thread_alloc::thread_num() == 0;
-     ok     &= num_sub > num_zero;
-
-     // Set local namespace environment variables
-     num_threads_  = num_threads;
-     if( use_ad )
-          fun_ = fun_ad;
-     else     fun_ = fun_no;
-     //
-     num_zero_     = num_zero;
-     num_sub_      = num_sub;
-     num_sum_      = num_sum;
-
-     // create team of threads
-     ok &= thread_alloc::in_parallel() == false;
-     if( num_threads > 0 )
-     {     team_create(num_threads);
-          ok &= num_threads == thread_alloc::num_threads();
-     }
-     else
-     {     ok &= 1 == thread_alloc::num_threads();
-     }
-
-     // run the test case and set time return value
-     time_out = CppAD::time_test(test_repeat, test_time);
-
-     // destroy team of threads
-     if( num_threads > 0 )
-          team_destroy();
-     ok &= thread_alloc::in_parallel() == false;
-     //
-     // correctness check
-     double pi      = 4. * std::atan(1.);
-     double xup     = double(num_zero_ - 1) * pi;
-     double eps     = xup * 100. * CppAD::numeric_limits<double>::epsilon();
-     ok        &= (xout_.size() == num_zero);
-     size_t i   = 0;
-     for(i = 0; i < xout_.size(); i++)
-          ok &= std::fabs( xout_[i] - pi * double(i)) <= 2 * eps;
-
-     // xout_ is a static variable, so clear it to free its memory
-     xout_.clear();
-
-     // return correctness check result
-     return  ok;
-}
- -
Input File: example/multi_thread/multi_newton.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_newton_time_xml.js cppad-2019.02.00.0/doc/_multi_newton_time_xml.js --- cppad-2018.00.00.0/doc/_multi_newton_time_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_newton_time_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_newton.cpp.xml', -'multi_newton_time.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_newton_common.xml', -'multi_newton_setup.xml', -'multi_newton_worker.xml', -'multi_newton_takedown.xml', -'multi_newton_run.xml', -'multi_newton_time.xml' -]; -var list_current0 = [ -'multi_newton_time.xml#Syntax', -'multi_newton_time.xml#Purpose', -'multi_newton_time.xml#Thread', -'multi_newton_time.xml#ok', -'multi_newton_time.xml#time_out', -'multi_newton_time.xml#test_time', -'multi_newton_time.xml#num_threads', -'multi_newton_time.xml#num_zero', -'multi_newton_time.xml#num_sub', -'multi_newton_time.xml#num_sum', -'multi_newton_time.xml#use_ad', -'multi_newton_time.xml#Source' -]; -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-2018.00.00.0/doc/multi_newton_worker.xml cppad-2019.02.00.0/doc/multi_newton_worker.xml --- cppad-2018.00.00.0/doc/multi_newton_worker.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_newton_worker.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,231 +0,0 @@ - - - -Do One Thread's Work for Multi-Threaded Newton Method - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -multi_newton_worker - -

-
Do One Thread's Work for Multi-Threaded Newton Method
-
-Syntax - -
- -multi_newton_worker() - - - -
-
-Purpose -
-This function finds all the zeros in the interval -low , up ] -. - -
-
-low -
-This is the value of the multi_newton_common - information - -
-     
low = work_all_[thread_num]->xlow
-
-
-up -
-This is the value of the multi_newton_common - information - -
-     
up = work_all_[thread_num]->xup
-
-
-thread_num -
-This is the number for the current thread; see -thread_num -. - -
-
-Source - -

-namespace {
-void multi_newton_worker(void)
-{
-     // Split [xlow, xup] into num_sub intervales and
-     // look for one zero in each sub-interval.
-     size_t thread_num    = thread_alloc::thread_num();
-     size_t num_threads   = std::max(num_threads_, size_t(1));
-     bool   ok            = thread_num < num_threads;
-     size_t num_sub       = work_all_[thread_num]->num_sub;
-     double xlow          = work_all_[thread_num]->xlow;
-     double xup           = work_all_[thread_num]->xup;
-     vector<double>& x    = work_all_[thread_num]->x;
-
-     // check arguments
-     ok &= max_itr_ > 0;
-     ok &= num_sub > 0;
-     ok &= xlow < xup;
-     ok &= x.size() == 0;
-
-     // check for special case where there is nothing for this thread to do
-     if( num_sub == 0 )
-     {     work_all_[thread_num]->ok = ok;
-          return;
-     }
-
-     // check for a zero on each sub-interval
-     size_t i;
-     double xlast = xlow - 2.0 * sub_length_; // over sub_length_ away from x_low
-     double flast = 2.0 * epsilon_;           // any value > epsilon_ would do
-     for(i = 0; i < num_sub; i++)
-     {
-          // note that when i == 0, xlow_i == xlow (exactly)
-          double xlow_i = xlow + double(i) * sub_length_;
-
-          // note that when i == num_sub - 1, xup_i = xup (exactly)
-          double xup_i  = xup  - double(num_sub - i - 1) * sub_length_;
-
-          // initial point for Newton iterations
-          double xcur = (xup_i + xlow_i) / 2.;
-
-          // Newton iterations
-          bool more_itr = true;
-          size_t itr    = 0;
-          // initialize these values to avoid MSC C++ warning
-          double fcur=0.0, dfcur=0.0;
-          while( more_itr )
-          {     fun_(xcur, fcur, dfcur);
-
-               // check end of iterations
-               if( fabs(fcur) <= epsilon_ )
-                    more_itr = false;
-               if( (xcur == xlow_i ) & (fcur * dfcur > 0.) )
-                    more_itr = false;
-               if( (xcur == xup_i)   & (fcur * dfcur < 0.) )
-                    more_itr = false;
-
-               // next Newton iterate
-               if( more_itr )
-               {     xcur = xcur - fcur / dfcur;
-                    // keep in bounds
-                    xcur = std::max(xcur, xlow_i);
-                    xcur = std::min(xcur, xup_i);
-
-                    more_itr = ++itr < max_itr_;
-               }
-          }
-          if( fabs( fcur ) <= epsilon_ )
-          {     // 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;
-                    flast            = fcur;
-               }
-          }
-     }
-     work_all_[thread_num]->ok = ok;
-}
-}
- -
Input File: example/multi_thread/multi_newton.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_multi_newton_worker_xml.js cppad-2019.02.00.0/doc/_multi_newton_worker_xml.js --- cppad-2018.00.00.0/doc/_multi_newton_worker_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_newton_worker_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'multi_newton.cpp.xml', -'multi_newton_worker.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'multi_newton_common.xml', -'multi_newton_setup.xml', -'multi_newton_worker.xml', -'multi_newton_takedown.xml', -'multi_newton_run.xml', -'multi_newton_time.xml' -]; -var list_current0 = [ -'multi_newton_worker.xml#Syntax', -'multi_newton_worker.xml#Purpose', -'multi_newton_worker.xml#low', -'multi_newton_worker.xml#up', -'multi_newton_worker.xml#thread_num', -'multi_newton_worker.xml#Source' -]; -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-2018.00.00.0/doc/multi_thread.xml cppad-2019.02.00.0/doc/multi_thread.xml --- cppad-2018.00.00.0/doc/multi_thread.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/multi_thread.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,195 +0,0 @@ - - - -Using CppAD in a Multi-Threading Environment - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -

-
Using CppAD in a Multi-Threading Environment
-
-Purpose -
-Extra steps and care must be taken to use CppAD -in parallel - execution mode. -This section collects this information in one place. - -
-
-CPPAD_MAX_NUM_THREADS -
-The value 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, -it must be an integer greater than or equal to one. -Otherwise, cppad_max_num_threads - -is used to define this preprocessor symbol. -Note that the minimum allowable value for - -cppad_max_num_threads - is 4; i.e., you can only -get smaller values for CPPAD_MAX_NUM_THREADS by -defining it before including the CppAD header files. - -
-
-parallel_setup -
-Using any of the following routines in a multi-threading environment -requires that thread_alloc::parallel_setup - -has been completed: -CppAD::vector -, -CheckSimpleVector -, -CheckNumericType -, -parallel_ad -. - -
-
-hold_memory -
-Memory allocation should be much faster after calling -hold_memory with -value - equal to true. -This may even be true if there is only one thread. - -
-
- -
-One must first call -thread_alloc::parallel_setup - -and then call parallel_ad - before using AD types -in parallel - execution mode. - -
-
-Initialization -
-The following routines must be called at least once before being used -in parallel mode: -CheckSimpleVector -, -CheckNumericType -, -discrete functions -, -Rosen34 -, -Runge45 -. - -
-
-Same Thread -
-Some operations must be preformed by the same thread: -ADFun -, -Independent -, Dependent -. - - -
-
-Parallel Prohibited -
-The following routine cannot be called in parallel mode: -ErrorHandler constructor -. - -
-
-Contents -
- -
parallel_adEnable AD Calculations During Parallel Mode
thread_test.cppRun Multi-Threading Examples and Speed Tests
-
Input File: omh/multi_thread.omh - - - diff -Nru cppad-2018.00.00.0/doc/_multi_thread_xml.js cppad-2019.02.00.0/doc/_multi_thread_xml.js --- cppad-2018.00.00.0/doc/_multi_thread_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_multi_thread_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_current0 = [ -'multi_thread.xml#Purpose', -'multi_thread.xml#CPPAD_MAX_NUM_THREADS', -'multi_thread.xml#parallel_setup', -'multi_thread.xml#hold_memory', -'multi_thread.xml#Parallel AD', -'multi_thread.xml#Initialization', -'multi_thread.xml#Same Thread', -'multi_thread.xml#Parallel Prohibited', -'multi_thread.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_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-2018.00.00.0/doc/nan.cpp.xml cppad-2019.02.00.0/doc/nan.cpp.xml --- cppad-2018.00.00.0/doc/nan.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/nan.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ - - - -nan: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -nan.cppHeadings

- - -
nan: Example and Test
-
# include <cppad/utility/nan.hpp>
-# include <vector>
-# include <limits>
-
-bool nan(void)
-{     bool ok = true;
-
-     // get a nan
-     double double_zero = 0.;
-     double double_nan = std::numeric_limits<double>::quiet_NaN();
-
-     // create a simple vector with no nans
-     std::vector<double> v(2);
-     v[0] = double_zero;
-     v[1] = double_zero;
-
-     // check that zero is not nan
-     ok &= ! CppAD::isnan(double_zero);
-     ok &= ! CppAD::hasnan(v);
-
-     // check that nan is a nan
-     v[1] = double_nan;
-     ok &= CppAD::isnan(double_nan);
-     ok &= CppAD::hasnan(v);
-
-     // check that nan is not equal to itself
-     ok &= (double_nan != double_nan);
-
-     return ok;
-}
-
-
-
Input File: example/utility/nan.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_nan.cpp_xml.js cppad-2019.02.00.0/doc/_nan.cpp_xml.js --- cppad-2018.00.00.0/doc/_nan.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_nan.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'nan.xml', -'nan.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'nan.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-2018.00.00.0/doc/nan.xml cppad-2019.02.00.0/doc/nan.xml --- cppad-2018.00.00.0/doc/nan.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/nan.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,358 +0,0 @@ - - - -Obtain Nan or Determine if a Value is Nan - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Obtain Nan or Determine if a Value is Nan
-
-Syntax - -
- -# include <cppad/utility/nan.hpp>
-
- -b = isnan(s)
-
- -b = hasnan(v) - - -
-
-Purpose -
-It obtain and check for the value not a number nan. -The IEEE standard specifies that a floating point value -a - -is nan if and only if the following returns true - -
-     
a != a
-
-
-Include -
-The file cppad/nan.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-Macros -
-Some C++ compilers use preprocessor symbols called nan -and isnan. -These preprocessor symbols will no longer be defined after -this file is included. - -
-
-isnan -
-This routine determines if a scalar value is nan. - -
-
-s -
-The argument -s - has prototype - -
-     const 
Scalar s
-
-
-b -
-The return value -b - has prototype - -
-     bool 
b
-
-It is true if the value -s - is nan. - -
-
-hasnan -
-This routine determines if a -SimpleVector - has an element that is nan. - -
-
-v -
-The argument -v - has prototype - -
-     const 
Vector &v
-
-(see Vector - for the definition of -Vector -). - -
-
-b -
-The return value -b - has prototype - -
-     bool 
b
-
-It is true if the vector -v - has a nan. - - -
-
-nan(zero) - - -
-
-Deprecated 2015-10-04 -
-This routine has been deprecated, use CppAD numeric limits -quiet_NaN - in its place. - -
-
-Syntax - -
- -s = nan(z)
-
-
-z -
-The argument -z - has prototype - -
-     const 
Scalar &z
-
-and its value is zero -(see Scalar - for the definition of -Scalar -). - -
-
-s -
-The return value -s - has prototype - -
-     
Scalar s
-
-It is the value nan for this floating point type. - -
-
-Scalar -
-The type -Scalar - must support the following operations; - -
- -Operation - Description
- - -a / b - - - division operator (returns a -Scalar - object) -
- - -a == b - - - equality operator (returns a bool object) -
- - -a != b - - - not equality operator (returns a bool object) -
-Note that the division operator will be used with -a - and -b - -equal to zero. For some types (e.g. int) this may generate -an exception. No attempt is made to catch any such exception. - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type -Scalar -. - - -
-
-Example -
-The file nan.cpp - -contains an example and test of this routine. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/utility/nan.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_nan_xml.js cppad-2019.02.00.0/doc/_nan_xml.js --- cppad-2018.00.00.0/doc/_nan_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_nan_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'nan.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'nan.cpp.xml' -]; -var list_current0 = [ -'nan.xml#Syntax', -'nan.xml#Purpose', -'nan.xml#Include', -'nan.xml#Include.Macros', -'nan.xml#isnan', -'nan.xml#isnan.s', -'nan.xml#isnan.b', -'nan.xml#hasnan', -'nan.xml#hasnan.v', -'nan.xml#hasnan.b', -'nan.xml#nan(zero)', -'nan.xml#nan(zero).Deprecated 2015-10-04', -'nan.xml#nan(zero).Syntax', -'nan.xml#nan(zero).z', -'nan.xml#nan(zero).s', -'nan.xml#Scalar', -'nan.xml#Vector', -'nan.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-2018.00.00.0/doc/near_equal.cpp.xml cppad-2019.02.00.0/doc/near_equal.cpp.xml --- cppad-2018.00.00.0/doc/near_equal.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/near_equal.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ - - - -NearEqual Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -near_equal.cpp - -

-
NearEqual Function: Example and Test
-
-File Name -
-This file is called near_equal.cpp instead of -NearEqual.cpp -to avoid a name conflict with ../lib/NearEqual.cpp -in the corresponding Microsoft project file. - - -

-# include <cppad/utility/near_equal.hpp>
-
-# include <complex>
-
-bool Near_Equal(void)
-{     bool ok = true;
-     typedef std::complex<double> Complex;
-     using CppAD::NearEqual;
-
-     // double
-     double x    = 1.00000;
-     double y    = 1.00001;
-     double a    =  .00003;
-     double r    =  .00003;
-     double zero = 0.;
-     double inf  = 1. / zero;
-     double nan  = 0. / zero;
-
-     ok &= NearEqual(x, y, zero, a);
-     ok &= NearEqual(x, y, r, zero);
-     ok &= NearEqual(x, y, r, a);
-
-     ok &= ! NearEqual(x, y, r / 10., a / 10.);
-     ok &= ! NearEqual(inf, inf, r, a);
-     ok &= ! NearEqual(-inf, -inf, r, a);
-     ok &= ! NearEqual(nan, nan, r, a);
-
-     // complex
-     Complex X(x, x / 2.);
-     Complex Y(y, y / 2.);
-     Complex Inf(inf, zero);
-     Complex Nan(zero, nan);
-
-     ok &= NearEqual(X, Y, zero, a);
-     ok &= NearEqual(X, Y, r, zero);
-     ok &= NearEqual(X, Y, r, a);
-
-     ok &= ! NearEqual(X, Y, r / 10., a / 10.);
-     ok &= ! NearEqual(Inf, Inf, r, a);
-     ok &= ! NearEqual(-Inf, -inf, r, a);
-     ok &= ! NearEqual(Nan, Nan, r, a);
-
-     return ok;
-}
-
-
-
Input File: example/utility/near_equal.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_near_equal.cpp_xml.js cppad-2019.02.00.0/doc/_near_equal.cpp_xml.js --- cppad-2018.00.00.0/doc/_near_equal.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_near_equal.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'nearequal.xml', -'near_equal.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'near_equal.cpp.xml' -]; -var list_current0 = [ -'near_equal.cpp.xml#File Name' -]; -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-2018.00.00.0/doc/near_equal_ext.cpp.xml cppad-2019.02.00.0/doc/near_equal_ext.cpp.xml --- cppad-2018.00.00.0/doc/near_equal_ext.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/near_equal_ext.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ - - - -Compare AD with Base Objects: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -near_equal_ext.cppHeadings

- - - -
Compare AD with Base Objects: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <complex>
-
-bool NearEqualExt(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-
-     // double
-     double x    = 1.00000;
-     double y    = 1.00001;
-     double a    =  .00005;
-     double r    =  .00005;
-     double zero = 0.;
-
-     // AD<double>
-     AD<double> ax(x);
-     AD<double> ay(y);
-
-     ok &= NearEqual(ax, ay, zero, a);
-     ok &= NearEqual(ax, y,  r, zero);
-     ok &= NearEqual(x, ay,  r,    a);
-
-     // std::complex<double>
-     AD<double> cx(x);
-     AD<double> cy(y);
-
-     // AD< std::complex<double> >
-     AD<double> acx(x);
-     AD<double> acy(y);
-
-     ok &= NearEqual(acx, acy, zero, a);
-     ok &= NearEqual(acx,  cy, r, zero);
-     ok &= NearEqual(acx,   y, r,    a);
-     ok &= NearEqual( cx, acy, r,    a);
-     ok &= NearEqual(  x, acy, r,    a);
-
-     return ok;
-}
-
-
-
Input File: example/general/near_equal_ext.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_near_equal_ext.cpp_xml.js cppad-2019.02.00.0/doc/_near_equal_ext.cpp_xml.js --- cppad-2018.00.00.0/doc/_near_equal_ext.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_near_equal_ext.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'boolvalued.xml', -'nearequalext.xml', -'near_equal_ext.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 = [ -'compare.xml', -'nearequalext.xml', -'boolfun.xml', -'parvar.xml', -'equalopseq.xml' -]; -var list_down1 = [ -'near_equal_ext.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-2018.00.00.0/doc/nearequalext.xml cppad-2019.02.00.0/doc/nearequalext.xml --- cppad-2018.00.00.0/doc/nearequalext.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/nearequalext.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,298 +0,0 @@ - - - -Compare AD and Base Objects for Nearly Equal - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Compare AD and Base Objects for Nearly Equal
-
-Syntax - -
- -b = NearEqual(xyra) - - - -
-
-Purpose -
-The routine NearEqual - determines if two objects of -the same type are nearly. -This routine is extended to the case where one object can have type - -Type - while the other can have type - -AD<Type> - or - -AD< std::complex<Type> > -. - -
-
-x -
-The arguments -x - -has one of the following possible prototypes: - -
-     const 
Type                     &x
-     const AD<
Type>                 &x
-     const AD< std::complex<
Type> > &x
-
-
-y -
-The arguments -y - -has one of the following possible prototypes: - -
-     const 
Type                     &y
-     const AD<
Type>                 &y
-     const AD< std::complex<
Type> > &x
-
-
-r -
-The relative error criteria -r - has prototype - -
-     const 
Type &r
-
-It must be greater than or equal to zero. -The relative error condition is defined as: - - -| -x -- -y -| - -| -x -| -+ -| -y -| - - - -r - - -
-a -
-The absolute error criteria -a - has prototype - -
-     const 
Type &a
-
-It must be greater than or equal to zero. -The absolute error condition is defined as: - - -| -x -- -y -| - -a - - -
-b -
-The return value -b - has prototype - -
-     bool 
b
-
-If either -x - or -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. - -
-
-Type -
-The type -Type - must be a -NumericType -. -The routine CheckNumericType - will generate -an error message if this is not the case. -If -a - and -b - have type -Type -, -the following operation must be defined - -
- -Operation - - Description
- - -a <= b - - - less that or equal operator (returns a bool object) -
-
-Operation Sequence -
-The result of this operation is not an -AD of Base - object. -Thus it will not be recorded as part of an -AD of -Base - -operation sequence -. - -
-
-Example - -
-The file near_equal_ext.cpp - contains an example -and test of this extension of NearEqual -. -It return true if it succeeds and false otherwise. - - -
Input File: cppad/core/near_equal_ext.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_nearequalext_xml.js cppad-2019.02.00.0/doc/_nearequalext_xml.js --- cppad-2018.00.00.0/doc/_nearequalext_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_nearequalext_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'boolvalued.xml', -'nearequalext.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 = [ -'compare.xml', -'nearequalext.xml', -'boolfun.xml', -'parvar.xml', -'equalopseq.xml' -]; -var list_down0 = [ -'near_equal_ext.cpp.xml' -]; -var list_current0 = [ -'nearequalext.xml#Syntax', -'nearequalext.xml#Purpose', -'nearequalext.xml#x', -'nearequalext.xml#y', -'nearequalext.xml#r', -'nearequalext.xml#a', -'nearequalext.xml#b', -'nearequalext.xml#Type', -'nearequalext.xml#Operation Sequence', -'nearequalext.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-2018.00.00.0/doc/nearequal.xml cppad-2019.02.00.0/doc/nearequal.xml --- cppad-2018.00.00.0/doc/nearequal.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/nearequal.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,320 +0,0 @@ - - - -Determine if Two Values Are Nearly Equal - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - -
Determine if Two Values Are Nearly Equal
-
-Syntax - - -
- -# include <cppad/utility/near_equal.hpp>
-
- -b = NearEqual(xyra) - - - -
-
-Purpose -
-Returns true, -if -x - and -y - are nearly equal, -and false otherwise. - -
-
-x -
-The argument -x - -has one of the following possible prototypes - -
-     const 
Type               &x,
-     const std::complex<
Type> &x,
-
-
-y -
-The argument -y - -has one of the following possible prototypes - -
-     const 
Type               &y,
-     const std::complex<
Type> &y,
-
-
-r -
-The relative error criteria -r - has prototype - -
-     const 
Type &r
-
-It must be greater than or equal to zero. -The relative error condition is defined as: - - -| -x -- -y -| - -r -( -| -x -| -+ -| -y -| -) - - -
-a -
-The absolute error criteria -a - has prototype - -
-     const 
Type &a
-
-It must be greater than or equal to zero. -The absolute error condition is defined as: - - -| -x -- -y -| - -a - - -
-b -
-The return value -b - has prototype - -
-     bool 
b
-
-If either -x - or -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. - -
-
-Type -
-The type -Type - must be a -NumericType -. -The routine CheckNumericType - will generate -an error message if this is not the case. -In addition, the following operations must be defined objects - -a - and -b - of type -Type -: - -
- -Operation - - Description
- - -a <= b - - - less that or equal operator (returns a bool object) -
-
-Include Files -
-The file cppad/near_equal.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-Example - -
-The file near_equal.cpp - contains an example -and test of NearEqual. -It return true if it succeeds and false otherwise. - -
-
-Exercise -
-Create and run a program that contains the following code: -
 
-     using std::complex;
-     using std::cout;
-     using std::endl;
-
-     complex<double> one(1., 0), i(0., 1);
-     complex<double> x = one / i;
-     complex<double> 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;
-
- -
Input File: cppad/utility/near_equal.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_nearequal_xml.js cppad-2019.02.00.0/doc/_nearequal_xml.js --- cppad-2018.00.00.0/doc/_nearequal_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_nearequal_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'nearequal.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'near_equal.cpp.xml' -]; -var list_current0 = [ -'nearequal.xml#Syntax', -'nearequal.xml#Purpose', -'nearequal.xml#x', -'nearequal.xml#y', -'nearequal.xml#r', -'nearequal.xml#a', -'nearequal.xml#b', -'nearequal.xml#Type', -'nearequal.xml#Include Files', -'nearequal.xml#Example', -'nearequal.xml#Exercise' -]; -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-2018.00.00.0/doc/number_skip.cpp.xml cppad-2019.02.00.0/doc/number_skip.cpp.xml --- cppad-2018.00.00.0/doc/number_skip.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/number_skip.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ - - - -Number of Variables That Can be Skipped: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -number_skip.cppHeadings

- - - -
Number of Variables That Can be Skipped: Example and Test
-
# include <cppad/cppad.hpp>
-bool number_skip(void)
-{     bool ok = true;
-     using CppAD::AD;
-
-     // independent variable vector
-     CppAD::vector< AD<double> > ax(2);
-     ax[0] = 0.;
-     ax[1] = 1.;
-     Independent(ax);
-
-     // Use a conditional expression
-     CppAD::vector< AD<double> > ay(1);
-
-     // variable that gets optimized out
-     AD<double> 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<double> f;
-     f.Dependent(ax, ay);
-
-     // use zero order to evaluate F[ (3, 4) ]
-     CppAD::vector<double>  x( f.Domain() );
-     CppAD::vector<double>  y( f.Range() );
-     x[0]    = 3.;
-     x[1]    = 4.;
-     y   = f.Forward(0, x);
-     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();
-
-     // after optimize, check forward mode result
-     x[0]    = 4.;
-     x[1]    = 3.;
-     y   = f.Forward(0, x);
-     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;
-}
-
-
-
Input File: example/general/number_skip.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_number_skip.cpp_xml.js cppad-2019.02.00.0/doc/_number_skip.cpp_xml.js --- cppad-2018.00.00.0/doc/_number_skip.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_number_skip.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'number_skip.xml', -'number_skip.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_down1 = [ -'number_skip.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-2018.00.00.0/doc/number_skip.xml cppad-2019.02.00.0/doc/number_skip.xml --- cppad-2018.00.00.0/doc/number_skip.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/number_skip.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,177 +0,0 @@ - - - -Number of Variables that Can be Skipped - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Number of Variables that Can be Skipped
-
-Syntax - -
- -n = f.number_skip() - - -
-
-See Also - -
-seq_property - - -
-
-Purpose -
-The conditional expressions - use either the -if_true - or if_false -. -Hence, some terms only need to be evaluated -depending on the value of the comparison in the conditional expression. -The optimize - option is capable of detecting some of these -case and determining variables that can be skipped. -This routine returns the number such variables. - -
-
-n -
-The return value -n - has type size_t -is the number of variables that the optimizer has determined can be skipped -(given the independent variable values specified by the previous call to -f.Forward - for order zero). - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-
-Example -
-The file number_skip.cpp - -contains an example and test of this function. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/num_skip.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_number_skip_xml.js cppad-2019.02.00.0/doc/_number_skip_xml.js --- cppad-2018.00.00.0/doc/_number_skip_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_number_skip_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'number_skip.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_down0 = [ -'number_skip.cpp.xml' -]; -var list_current0 = [ -'number_skip.xml#Syntax', -'number_skip.xml#Syntax.See Also', -'number_skip.xml#Purpose', -'number_skip.xml#n', -'number_skip.xml#f', -'number_skip.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-2018.00.00.0/doc/numeric_ad.xml cppad-2019.02.00.0/doc/numeric_ad.xml --- cppad-2018.00.00.0/doc/numeric_ad.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/numeric_ad.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ - - - -Some Numerical AD Utilities - - - - - - - - - - - - - - - -
- -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/appendix/numeric_ad.omh - - - diff -Nru cppad-2018.00.00.0/doc/_numeric_ad_xml.js cppad-2019.02.00.0/doc/_numeric_ad_xml.js --- cppad-2018.00.00.0/doc/_numeric_ad_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_numeric_ad_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -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', -'directory.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-2018.00.00.0/doc/numeric_limits.xml cppad-2019.02.00.0/doc/numeric_limits.xml --- cppad-2018.00.00.0/doc/numeric_limits.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/numeric_limits.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,306 +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()
-
- -nan = numeric_limits<Float>::quiet_NaN()
-
- -numeric_limits<Float>::digits10 - - -
-
-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. -(Note that digits10 is member variable and not a function.) - -
-
-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
-
-
-digits10 -
-The member variable digits10 has prototype - -
-     static const int numeric_limits<
Float>::digits10
-
-It is the number of decimal digits that can be represented by a - -Float - value. A number with this many decimal digits can be -converted to -Float - and back to a string, -without change due to rounding or overflow. - - -
-
-Example - -
-The file -num_limits.cpp - -contains an example and test of these functions. - - -
Input File: cppad/core/numeric_limits.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_numeric_limits_xml.js cppad-2019.02.00.0/doc/_numeric_limits_xml.js --- cppad-2018.00.00.0/doc/_numeric_limits_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_numeric_limits_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +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', -'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#digits10', -'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-2018.00.00.0/doc/numeric_type.cpp.xml cppad-2019.02.00.0/doc/numeric_type.cpp.xml --- cppad-2018.00.00.0/doc/numeric_type.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/numeric_type.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ - - - -The NumericType: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -numeric_type.cppHeadings

- - -
The NumericType: Example and Test
-

-# include <cppad/cppad.hpp>
-
-namespace { // Empty namespace
-
-     // -------------------------------------------------------------------
-     class MyType {
-     private:
-          double d;
-     public:
-          // constructor from void
-          MyType(void) : d(0.)
-          { }
-          // constructor from an int
-          MyType(int d_) : d(d_)
-          { }
-          // copy constructor
-          MyType(const MyType &x)
-          {     d = x.d; }
-          // assignment operator
-          void operator = (const MyType &x)
-          {     d = x.d; }
-          // member function that converts to double
-          double Double(void) const
-          {     return d; }
-          // unary plus
-          MyType operator + (void) const
-          {     MyType x;
-               x.d =  d;
-               return x;
-          }
-          // unary plus
-          MyType operator - (void) const
-          {     MyType x;
-               x.d = - d;
-               return x;
-          }
-          // binary addition
-          MyType operator + (const MyType &x) const
-          {     MyType y;
-               y.d = d + x.d ;
-               return y;
-          }
-          // binary subtraction
-          MyType operator - (const MyType &x) const
-          {     MyType y;
-               y.d = d - x.d ;
-               return y;
-          }
-          // binary multiplication
-          MyType operator * (const MyType &x) const
-          {     MyType y;
-               y.d = d * x.d ;
-               return y;
-          }
-          // binary division
-          MyType operator / (const MyType &x) const
-          {     MyType y;
-               y.d = d / x.d ;
-               return y;
-          }
-          // compound assignment addition
-          void operator += (const MyType &x)
-          {     d += x.d; }
-          // compound assignment subtraction
-          void operator -= (const MyType &x)
-          {     d -= x.d; }
-          // compound assignment multiplication
-          void operator *= (const MyType &x)
-          {     d *= x.d; }
-          // compound assignment division
-          void operator /= (const MyType &x)
-          {     d /= x.d; }
-     };
-}
-bool NumericType(void)
-{     bool ok  = true;
-     using CppAD::AD;
-     using CppAD::CheckNumericType;
-
-     CheckNumericType<MyType>            ();
-
-     CheckNumericType<int>               ();
-     CheckNumericType<double>            ();
-     CheckNumericType< AD<double> >      ();
-     CheckNumericType< AD< AD<double> > >();
-
-     return ok;
-}
-
-
-
Input File: example/general/numeric_type.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_numeric_type.cpp_xml.js cppad-2019.02.00.0/doc/_numeric_type.cpp_xml.js --- cppad-2018.00.00.0/doc/_numeric_type.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_numeric_type.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'numerictype.xml', -'numeric_type.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'numeric_type.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-2018.00.00.0/doc/numerictype.xml cppad-2019.02.00.0/doc/numerictype.xml --- cppad-2018.00.00.0/doc/numerictype.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/numerictype.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,379 +0,0 @@ - - - -Definition of a Numeric Type - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - - -
Definition of a Numeric Type
-
-Type Requirements -
-A -NumericType - is any type -that satisfies the requirements below. -The following is a list of some numeric types: -int, float, double, -AD<double>, AD< AD<double> >. -The routine CheckNumericType - can be used to check -that a type satisfies these conditions. - -
-
-Default Constructor -
-The syntax - -
-     
NumericType x;
-
-creates a -NumericType - object -with an unspecified value. - -
-
-Constructor From Integer -
-If -i - is an int, -the syntax - -
-     
NumericType x(i);
-
-creates a -NumericType - object with a value -equal to -i - where -i - can be const. - -
-
-Copy Constructor -
-If -x - is a -NumericType - object -the syntax - -
-     
NumericType y(x);
-
-creates a -NumericType - object -y - -with the same value as -x - -where -x - can be const. - -
-
-Assignment -
-If -x - and -y - are -NumericType - objects, -the syntax - -
-     
x = y
-
-sets the value of -x - equal to the value of -y - -where -y - can be const. -The expression corresponding to this operation is unspecified; i.e., -it could be void and hence - -
-     
x = y = z
-
-may not be legal. - -
-
-Operators -
-Suppose -x -, -y - and -z - - -NumericType - objects where - -x - and -y - may be const. -In the result type column, - -NumericType - can be replaced by any type that can -be used just like a -NumericType - object. - -
- -Operation - Description - - Result Type
- - -+x - - unary plus - - -NumericType -
- - --x - - unary minus - - -NumericType -
- - -x +  y - - binary addition - - -NumericType -
- - -x -  y - - binary subtraction - - -NumericType -
- - -x *  y - - binary multiplication - - -NumericType -
- - -x /  y - - binary division - - -NumericType -
- - -z += y - - compound assignment addition - - unspecified
- - -z -= y - - compound assignment subtraction - - unspecified
- - -z *= y - - compound assignment multiplication - - unspecified
- - -z /= y - - compound assignment division - - unspecified -
-
-Example - -
-The file -numeric_type.cpp - -contains an example and test of using numeric types. -It returns true if it succeeds and false otherwise. -(It is easy to modify to test additional numeric types.) - -
-
-Exercise - - -
  1. -List three operators that are not supported by every -numeric type but that are supported by the numeric types -int, -float, -double. - -
  2. - -Which of the following are numeric types: -std::complex<double>, -std::valarray<double>, -std::vector<double> ? - -
- - - -
Input File: omh/numeric_type.omh - - - diff -Nru cppad-2018.00.00.0/doc/_numerictype_xml.js cppad-2019.02.00.0/doc/_numerictype_xml.js --- cppad-2018.00.00.0/doc/_numerictype_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_numerictype_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'numerictype.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'numeric_type.cpp.xml' -]; -var list_current0 = [ -'numerictype.xml#Type Requirements', -'numerictype.xml#Default Constructor', -'numerictype.xml#Constructor From Integer', -'numerictype.xml#Copy Constructor', -'numerictype.xml#Assignment', -'numerictype.xml#Operators', -'numerictype.xml#Example', -'numerictype.xml#Exercise' -]; -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-2018.00.00.0/doc/num_limits.cpp.xml cppad-2019.02.00.0/doc/num_limits.cpp.xml --- cppad-2018.00.00.0/doc/num_limits.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/num_limits.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ - - - -Numeric Limits: 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         &= fabs(match / min - 1.0)  > 3.0 * eps;
-          //
-          match       = (min * 100.) / 100.;
-          ok         &= fabs(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         &= fabs(match / max - 1.0) > 3.0 * eps;
-          //
-          match       = (max / 100.) * 100.;
-          ok         &= fabs(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 check_digits10(void)
-     {     bool ok     = true;
-          Float neg_log_eps =
-               - log10( CppAD::numeric_limits<Float>::epsilon() );
-          int ceil_neg_log_eps =
-               Integer( neg_log_eps );
-          ok &= ceil_neg_log_eps == CppAD::numeric_limits<Float>::digits10;
-          return ok;
-     }
-}
-
-bool num_limits(void)
-{     bool ok = true;
-
-     ok &= check_epsilon();
-     ok &= check_min();
-     ok &= check_max();
-     ok &= check_nan();
-     ok &= check_digits10();
-
-     return ok;
-}
-
-
Input File: example/general/num_limits.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_num_limits.cpp_xml.js cppad-2019.02.00.0/doc/_num_limits.cpp_xml.js --- cppad-2018.00.00.0/doc/_num_limits.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_num_limits.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +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', -'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-2018.00.00.0/doc/ode_err_control.cpp.xml cppad-2019.02.00.0/doc/ode_err_control.cpp.xml --- cppad-2018.00.00.0/doc/ode_err_control.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ode_err_control.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,412 +0,0 @@ - - - -OdeErrControl: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ode_err_control.cpp - -

- - - -
OdeErrControl: Example and Test
-Define - - -X -: -R - - -R - -2 - - - - by - - - -X -0 - -( -0 -) - -= - -1 - -X -1 - -( -0 -) - -= - -0 - -X -0 -( -1 -) - - -( -t -) - -= - -- -α -X -0 - -( -t -) - -X -1 -( -1 -) - - -( -t -) - -= - -1 -/ -X -0 - -( -t -) - - - -It follows that - - - -X -0 - -( -t -) - -= - -exp -( -- -α -t -) - -X -1 - -( -t -) - -= - -[ -exp -( -α -t -) -- -1 -] -/ -α - - - -This example tests OdeErrControl using the relations above. - -
-
-Nan -
-Note that - -X -0 - -( -t -) -> -0 - - - for all - -t - - - and that the -ODE goes through a singularity between - -X -0 - -( -t -) -> -0 - - - -and - -X -0 - -( -t -) -< -0 - - -. -If - -X -0 - -( -t -) -< -0 - - -, -we return nan in order to inform -OdeErrControl that its is taking to large a step. - - - -

-# include <limits>                      // for quiet_NaN
-# include <cstddef>                     // for size_t
-# include <cmath>                       // for exp
-# include <cppad/utility/ode_err_control.hpp>   // CppAD::OdeErrControl
-# include <cppad/utility/near_equal.hpp>        // CppAD::NearEqual
-# include <cppad/utility/vector.hpp>            // CppAD::vector
-# include <cppad/utility/runge_45.hpp>          // CppAD::Runge45
-
-namespace {
-     // --------------------------------------------------------------
-     class Fun {
-     private:
-          const double alpha_;
-     public:
-          // constructor
-          Fun(double alpha) : alpha_(alpha)
-          { }
-
-          // set f = x'(t)
-          void Ode(
-               const double                &t,
-               const CppAD::vector<double> &x,
-               CppAD::vector<double>       &f)
-          {     f[0] = - alpha_ * x[0];
-               f[1] = 1. / x[0];
-               // case where ODE does not make sense
-               if( x[0] < 0. )
-                    f[1] = std::numeric_limits<double>::quiet_NaN();
-          }
-
-     };
-
-     // --------------------------------------------------------------
-     class Method {
-     private:
-          Fun F;
-     public:
-          // constructor
-          Method(double alpha) : F(alpha)
-          { }
-          void step(
-               double ta,
-               double tb,
-               CppAD::vector<double> &xa ,
-               CppAD::vector<double> &xb ,
-               CppAD::vector<double> &eb )
-          {     xb = CppAD::Runge45(F, 1, ta, tb, xa, eb);
-          }
-          size_t order(void)
-          {     return 4; }
-     };
-}
-
-bool OdeErrControl(void)
-{     bool ok = true;     // initial return value
-
-     double alpha = 10.;
-     Method method(alpha);
-
-     CppAD::vector<double> xi(2);
-     xi[0] = 1.;
-     xi[1] = 0.;
-
-     CppAD::vector<double> eabs(2);
-     eabs[0] = 1e-4;
-     eabs[1] = 1e-4;
-
-     // inputs
-     double ti   = 0.;
-     double tf   = 1.;
-     double smin = 1e-4;
-     double smax = 1.;
-     double scur = 1.;
-     double erel = 0.;
-
-     // outputs
-     CppAD::vector<double> ef(2);
-     CppAD::vector<double> xf(2);
-     CppAD::vector<double> maxabs(2);
-     size_t nstep;
-
-
-     xf = OdeErrControl(method,
-          ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep);
-
-     double x0 = exp(-alpha*tf);
-     ok &= CppAD::NearEqual(x0, xf[0], 1e-4, 1e-4);
-     ok &= CppAD::NearEqual(0., ef[0], 1e-4, 1e-4);
-
-     double x1 = (exp(alpha*tf) - 1) / alpha;
-     ok &= CppAD::NearEqual(x1, xf[1], 1e-4, 1e-4);
-     ok &= CppAD::NearEqual(0., ef[1], 1e-4, 1e-4);
-
-     return ok;
-}
-
-
-
Input File: example/utility/ode_err_control.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ode_err_control.cpp_xml.js cppad-2019.02.00.0/doc/_ode_err_control.cpp_xml.js --- cppad-2018.00.00.0/doc/_ode_err_control.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ode_err_control.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'odeerrcontrol.xml', -'ode_err_control.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'ode_err_control.cpp.xml', -'ode_err_maxabs.cpp.xml' -]; -var list_current0 = [ -'ode_err_control.cpp.xml#Nan' -]; -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-2018.00.00.0/doc/odeerrcontrol.xml cppad-2019.02.00.0/doc/odeerrcontrol.xml --- cppad-2018.00.00.0/doc/odeerrcontrol.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/odeerrcontrol.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1298 +0,0 @@ - - - -An Error Controller for ODE Solvers - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
An Error Controller for ODE Solvers
-
-Syntax - -
- -# include <cppad/utility/ode_err_control.hpp>
-
- -xf = OdeErrControl(methodtitfxi,
-     
sminsmaxscureabserelef , maxabsnstep )
- - - -
-
-Description -
-Let - -R - - - - denote the real numbers -and let - -F -: -R - -× -R - -n - - -R - -n - - - - be a smooth function. -We define - -X -: -[ -ti -, -tf -] - -R - -n - - - - by -the following initial value problem: - - - -X -( -ti -) - -= - -xi - -X -' -( -t -) - -= - -F -[ -t -, -X -( -t -) -] - - - -The routine 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. - -
-
-Include -
-The file cppad/ode_err_control.hpp is included by -cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-Notation -
-The template parameter types Scalar - and -Vector - are documented below. - -
-
-xf -
-The return value -xf - has the prototype - -
-     
Vector xf
-
-(see description of Vector - below). -and the size of -xf - is equal to -n -. -If -xf - contains not a number nan -, -see the discussion of step -. - -
-
-Method -
-The class -Method - -and the object -method - satisfy the following syntax - -
-     
Method &method
-
-The object -method - must support step and -order member functions defined below: - -
-
-step -
-The syntax - -
-     
method.step(tatbxaxbeb)
-
-executes one step of the integration method. - -
-
-
ta
-
-The argument -ta - has prototype - -
-     const 
Scalar &ta
-
-It specifies the initial time for this step in the -ODE integration. -(see description of Scalar - below). - -
-
-
tb
-
-The argument -tb - has prototype - -
-     const 
Scalar &tb
-
-It specifies the final time for this step in the -ODE integration. - -
-
-
xa
-
-The argument -xa - has prototype - -
-     const 
Vector &xa
-
-and size -n -. -It specifies the value of - -X -( -ta -) - - -. -(see description of Vector - below). - -
-
-
xb
-
-The argument value -xb - has prototype - -
-     
Vector &xb
-
-and size -n -. -The input value of its elements does not matter. -On output, -it contains the approximation for - -X -( -tb -) - - - that the method obtains. - -
-
-
eb
-
-The argument value -eb - has prototype - -
-     
Vector &eb
-
-and size -n -. -The input value of its elements does not matter. -On output, -it contains an estimate for the error in the approximation -xb -. -It is assumed (locally) that the error bound in this approximation -nearly equal to - -K -( -tb -- -ta -) -m - - - - -where -K - is a fixed constant and -m - -is the corresponding argument to CodeControl. - -
-
-Nan -
-If any element of the vector -eb - or -xb - are -not a number nan, -the current step is considered to large. -If this happens with the current step size equal to -smin -, -OdeErrControl returns with -xf - and -ef - as vectors -of nan. - -
-
-order -
-If -m - is size_t, -the object -method - must also support the following syntax - -
-     
m = method.order()
-
-The return value -m - is the order of the error estimate; -i.e., there is a constant K such that if - -ti - -ta - -tb - -tf - - -, - - -| -eb -( -tb -) -| - -K -| -tb -- -ta -| -m - - - -where -ta -, -tb -, and -eb - are as in - -method.step(tatbxaxbeb) - - - -
-
-ti -
-The argument -ti - has prototype - -
-     const 
Scalar &ti
-
-It specifies the initial time for the integration of -the differential equation. - - -
-
-tf -
-The argument -tf - has prototype - -
-     const 
Scalar &tf
-
-It specifies the final time for the integration of -the differential equation. - -
-
-xi -
-The argument -xi - has prototype - -
-     const 
Vector &xi
-
-and size -n -. -It specifies value of - -X -( -ti -) - - -. - -
-
-smin -
-The argument -smin - has prototype - -
-     const 
Scalar &smin
-
-The step size during a call to -method - is defined as -the corresponding value of - -tb -- -ta - - -. -If - -tf -- -ti - -smin - - -, -the integration will be done in one step of size -tf - ti -. -Otherwise, -the minimum value of -tb - ta - will be - -smin - - - -except for the last two calls to -method - where it may be -as small as - -smin -/ -2 - - -. - -
-
-smax -
-The argument -smax - has prototype - -
-     const 
Scalar &smax
-
-It specifies the maximum step size to use during the integration; -i.e., the maximum value for - -tb -- -ta - - - in a call to -method -. -The value of -smax - must be greater than or equal -smin -. - -
-
-scur -
-The argument -scur - has prototype - -
-     
Scalar &scur
-
-The value of -scur - is the suggested next step size, -based on error criteria, to try in the next call to -method -. -On input it corresponds to the first call to -method -, -in this call to OdeErrControl (where - -ta -= -ti - - -). -On output it corresponds to the next call to -method -, -in a subsequent call to OdeErrControl (where -ta = tf -). - -
-
-eabs -
-The argument -eabs - has prototype - -
-     const 
Vector &eabs
-
-and size -n -. -Each of the elements of -eabs - must be -greater than or equal zero. -It specifies a bound for the absolute -error in the return value -xf - as an approximation for - -X -( -tf -) - - -. -(see the -error criteria discussion - -below). - -
-
-erel -
-The argument -erel - has prototype - -
-     const 
Scalar &erel
-
-and is greater than or equal zero. -It specifies a bound for the relative -error in the return value -xf - as an approximation for - -X -( -tf -) - - - -(see the -error criteria discussion - -below). - -
-
-ef -
-The argument value -ef - has prototype - -
-     
Vector &ef
-
-and size -n -. -The input value of its elements does not matter. -On output, -it contains an estimated bound for the -absolute error in the approximation -xf -; i.e., - - -ef -i - -> -| -X -( -tf -) -i - -- -xf -i - -| - - -If on output -ef - contains not a number nan, -see the discussion of step -. - -
-
-maxabs -
-The argument -maxabs - is optional in the call to OdeErrControl. -If it is present, it has the prototype - -
-     
Vector &maxabs
-
-and size -n -. -The input value of its elements does not matter. -On output, -it contains an estimate for the -maximum absolute value of - -X -( -t -) - - -; i.e., - - -maxabs -[ -i -] - -max -{| -X -( -t -) -i - -| - -: - -t - -[ -ti -, -tf -] -} - - -
-nstep -
-The argument -nstep - is optional in the call to OdeErrControl. -If it is present, it has the prototype - -
-     
size_t &nstep
-
-Its input value does not matter and its output value -is the number of calls to -method.step - -used by OdeErrControl. - -
-
-Error Criteria Discussion -
-The relative error criteria -erel - and -absolute error criteria -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 - -X - -˜ -( -t -) - - - is the approximate solution -at time - -t - - -, - -ta - is the initial step time, -and -tb - is the final step time, - - -|X - -˜ -( -tb -) -j - -- -X -( -tb -) -j - -| - -tf -- -ti - -tb -- -ta - - -[eabs -[ -j -] -+ -erel - -| -X - -˜ -( -tb -) -j - -| -] - - -If - -X -( -tb -) -j - - - - is near zero for some - -tb - -[ -ti -, -tf -] - - -, -and one uses an absolute error criteria - -eabs -[ -j -] - - - of zero, -the error criteria above will force OdeErrControl -to use step sizes equal to -smin - -for steps ending near - -tb - - -. -In this case, the error relative to -maxabs - can be judged after -OdeErrControl returns. -If -ef - is to large relative to -maxabs -, -OdeErrControl can be called again -with a smaller value of -smin -. - -
-
-Scalar -
-The type -Scalar - must satisfy the conditions -for a NumericType - type. -The routine CheckNumericType - will generate an error message -if this is not the case. -In addition, the following operations must be defined for - -Scalar - objects -a - and -b -: - - -
- -Operation - Description
- - -a <= b - - - returns true (false) if -a - is less than or equal - (greater than) -b -. -
- - -a == b - - - returns true (false) if -a - is equal to -b -. -
- - -log(a) - - - returns a -Scalar - equal to the logarithm of -a - -
- - -exp(a) - - - returns a -Scalar - equal to the exponential of -a - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type Scalar -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Example - -
-The files -ode_err_control.cpp - -and -ode_err_maxabs.cpp - -contain examples and tests of using this routine. -They return true if they succeed and false otherwise. - -
-
-Theory -
-Let - -e -( -s -) - - - be the error as a function of the -step size - -s - - - and suppose that there is a constant - - -K - - - such that - -e -( -s -) -= -K -s -m - - - -. -Let - -a - - - be our error bound. -Given the value of - -e -( -s -) - - -, a step of size - -λ -s - - - -would be ok provided that - - - -a - - - -e -( -λ -s -) -( -tf -- -ti -) -/ -( -λ -s -) - -a - - - -K -λ -m - -s -m - -( -tf -- -ti -) -/ -( -λ -s -) - -a - - - -λ -m --1 - - -s -m --1 - - -( -tf -- -ti -) -e -( -s -) -/ -s -m - - -a - - - -λ -m --1 - - -( -tf -- -ti -) -e -( -s -) -/ -s - -λ -m --1 - - - - - -a - -e -( -s -) - - -s - -tf -- -ti - - - - - -Thus if the right hand side of the last inequality is greater -than or equal to one, the step of size - -s - - - is ok. - -
-
-Source Code -
-The source code for this routine is in the file -cppad/ode_err_control.hpp. - - -
Input File: cppad/utility/ode_err_control.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_odeerrcontrol_xml.js cppad-2019.02.00.0/doc/_odeerrcontrol_xml.js --- cppad-2018.00.00.0/doc/_odeerrcontrol_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_odeerrcontrol_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', -'utility.xml', -'odeerrcontrol.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'ode_err_control.cpp.xml', -'ode_err_maxabs.cpp.xml' -]; -var list_current0 = [ -'odeerrcontrol.xml#Syntax', -'odeerrcontrol.xml#Description', -'odeerrcontrol.xml#Include', -'odeerrcontrol.xml#Notation', -'odeerrcontrol.xml#xf', -'odeerrcontrol.xml#Method', -'odeerrcontrol.xml#Method.step', -'odeerrcontrol.xml#Method.Nan', -'odeerrcontrol.xml#Method.order', -'odeerrcontrol.xml#ti', -'odeerrcontrol.xml#tf', -'odeerrcontrol.xml#xi', -'odeerrcontrol.xml#smin', -'odeerrcontrol.xml#smax', -'odeerrcontrol.xml#scur', -'odeerrcontrol.xml#eabs', -'odeerrcontrol.xml#erel', -'odeerrcontrol.xml#ef', -'odeerrcontrol.xml#maxabs', -'odeerrcontrol.xml#nstep', -'odeerrcontrol.xml#Error Criteria Discussion', -'odeerrcontrol.xml#Scalar', -'odeerrcontrol.xml#Vector', -'odeerrcontrol.xml#Example', -'odeerrcontrol.xml#Theory', -'odeerrcontrol.xml#Source Code' -]; -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-2018.00.00.0/doc/ode_err_maxabs.cpp.xml cppad-2019.02.00.0/doc/ode_err_maxabs.cpp.xml --- cppad-2018.00.00.0/doc/ode_err_maxabs.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ode_err_maxabs.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,413 +0,0 @@ - - - -OdeErrControl: Example and Test Using Maxabs Argument - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ode_err_maxabs.cppHeadings

-
OdeErrControl: Example and Test Using Maxabs Argument
-Define - - -X -: -R - - -R - -2 - - - - by - - - -X -0 - -( -t -) - -= - -- -exp -( -- -w -0 - -t -) - -X -1 - -( -t -) - -= - -w -0 - - -w -1 - -- -w -0 - - - -[ -exp -( -- -w -0 - -t -) -- -exp -( -- -w -1 - -t -) -] - - - -It follows that - -X -0 - -( -0 -) -= -1 - - -, - -X -1 - -( -0 -) -= -0 - - - and - - - -X -0 -( -1 -) - - -( -t -) - -= - -- -w -0 - -X -0 - -( -t -) - -X -1 -( -1 -) - - -( -t -) - -= - -+ -w -0 - -X -0 - -( -t -) -- -w -1 - -X -1 - -( -t -) - - - -Note that - -X -1 - -( -0 -) - - - is zero an if - -w -0 - -t - - - is large, - - -X -0 - -( -t -) - - - is near zero. -This example tests OdeErrControl using the -maxabs - argument. - - -

-# include <cstddef>              // for size_t
-# include <cmath>                // for exp
-# include <cppad/utility/ode_err_control.hpp>   // CppAD::OdeErrControl
-# include <cppad/utility/near_equal.hpp>    // CppAD::NearEqual
-# include <cppad/utility/vector.hpp> // CppAD::vector
-# include <cppad/utility/runge_45.hpp>      // CppAD::Runge45
-
-namespace {
-     // --------------------------------------------------------------
-     class Fun {
-     private:
-           CppAD::vector<double> w;
-     public:
-          // constructor
-          Fun(const CppAD::vector<double> &w_) : w(w_)
-          { }
-
-          // set f = x'(t)
-          void Ode(
-               const double                &t,
-               const CppAD::vector<double> &x,
-               CppAD::vector<double>       &f)
-          {     f[0] = - w[0] * x[0];
-               f[1] = + w[0] * x[0] - w[1] * x[1];
-          }
-     };
-
-     // --------------------------------------------------------------
-     class Method {
-     private:
-          Fun F;
-     public:
-          // constructor
-          Method(const CppAD::vector<double> &w_) : F(w_)
-          { }
-          void step(
-               double ta,
-               double tb,
-               CppAD::vector<double> &xa ,
-               CppAD::vector<double> &xb ,
-               CppAD::vector<double> &eb )
-          {     xb = CppAD::Runge45(F, 1, ta, tb, xa, eb);
-          }
-          size_t order(void)
-          {     return 4; }
-     };
-}
-
-bool OdeErrMaxabs(void)
-{     bool ok = true;     // initial return value
-
-     CppAD::vector<double> w(2);
-     w[0] = 10.;
-     w[1] = 1.;
-     Method method(w);
-
-     CppAD::vector<double> xi(2);
-     xi[0] = 1.;
-     xi[1] = 0.;
-
-     CppAD::vector<double> eabs(2);
-     eabs[0] = 0.;
-     eabs[1] = 0.;
-
-     CppAD::vector<double> ef(2);
-     CppAD::vector<double> xf(2);
-     CppAD::vector<double> maxabs(2);
-
-     double ti   = 0.;
-     double tf   = 1.;
-     double smin = .5;
-     double smax = 1.;
-     double scur = .5;
-     double erel = 1e-4;
-
-     bool accurate = false;
-     while( ! accurate )
-     {     xf = OdeErrControl(method,
-               ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs);
-          accurate = true;
-          size_t i;
-          for(i = 0; i < 2; i++)
-               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.);
-     ok &= CppAD::NearEqual(0., ef[0], erel, erel);
-
-     double x1 = w[0] * (exp(-w[0]*tf) - exp(-w[1]*tf))/(w[1] - w[0]);
-     ok &= CppAD::NearEqual(x1, xf[1], erel, 0.);
-     ok &= CppAD::NearEqual(0., ef[1], erel, erel);
-
-     return ok;
-}
-
-
-
Input File: example/utility/ode_err_maxabs.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ode_err_maxabs.cpp_xml.js cppad-2019.02.00.0/doc/_ode_err_maxabs.cpp_xml.js --- cppad-2018.00.00.0/doc/_ode_err_maxabs.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ode_err_maxabs.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'odeerrcontrol.xml', -'ode_err_maxabs.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'ode_err_control.cpp.xml', -'ode_err_maxabs.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-2018.00.00.0/doc/ode_evaluate.cpp.xml cppad-2019.02.00.0/doc/ode_evaluate.cpp.xml --- cppad-2018.00.00.0/doc/ode_evaluate.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/ode_evaluate.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ - - - -ode_evaluate: Example and test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ode_evaluate.cppHeadings

- - - - -
ode_evaluate: Example and test
-
# include <cppad/speed/ode_evaluate.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/cppad.hpp>
-
-bool ode_evaluate(void)
-{     using CppAD::NearEqual;
-     using CppAD::AD;
-
-     bool ok = true;
-
-     size_t n = 3;
-     CppAD::vector<double>       x(n);
-     CppAD::vector<double>       ym(n * n);
-     CppAD::vector< AD<double> > X(n);
-     CppAD::vector< AD<double> > Ym(n);
-
-     // choose x
-     size_t j;
-     for(j = 0; j < n; j++)
-     {     x[j] = double(j + 1);
-          X[j] = x[j];
-     }
-
-     // declare independent variables
-     Independent(X);
-
-     // evaluate function
-     size_t m = 0;
-     CppAD::ode_evaluate(X, m, Ym);
-
-     // evaluate derivative
-     m = 1;
-     CppAD::ode_evaluate(x, m, ym);
-
-     // use AD to evaluate derivative
-     CppAD::ADFun<double>   F(X, Ym);
-     CppAD::vector<double>  dy(n * n);
-     dy = F.Jacobian(x);
-
-     size_t k;
-     for(k = 0; k < n * n; k++)
-          ok &= NearEqual(ym[k], dy[k] , 1e-7, 1e-7);
-
-     return ok;
-}
-
-
Input File: speed/example/ode_evaluate.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ode_evaluate.cpp_xml.js cppad-2019.02.00.0/doc/_ode_evaluate.cpp_xml.js --- cppad-2018.00.00.0/doc/_ode_evaluate.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ode_evaluate.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'ode_evaluate.xml', -'ode_evaluate.cpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'ode_evaluate.cpp.xml', -'ode_evaluate.hpp.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-2018.00.00.0/doc/ode_evaluate.hpp.xml cppad-2019.02.00.0/doc/ode_evaluate.hpp.xml --- cppad-2018.00.00.0/doc/ode_evaluate.hpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/ode_evaluate.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,187 +0,0 @@ - - - -Source: ode_evaluate - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ode_evaluate.hppHeadings

-
Source: ode_evaluate
-# ifndef CPPAD_ODE_EVALUATE_HPP -
-
# define CPPAD_ODE_EVALUATE_HPP - -
# include <cppad/utility/vector.hpp>
-# include <cppad/utility/ode_err_control.hpp>
-# include <cppad/utility/runge_45.hpp>
-
-namespace CppAD {
-
-     template <class Float>
-     class ode_evaluate_fun {
-     public:
-          // 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_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<Float>&     y,
-               CppAD::vector<Float>&           f)
-          {     size_t n  = y.size();
-               f[0]      = 0.;
-               for(size_t k = 1; k < n; k++)
-                    f[k] = y[k-1];
-          }
-     };
-     //
-     template <class Float>
-     void ode_evaluate(
-          const CppAD::vector<Float>& x  ,
-          size_t                      p  ,
-          CppAD::vector<Float>&       fp )
-     {     using CppAD::vector;
-          typedef vector<Float> VectorFloat;
-
-          size_t n = x.size();
-          CPPAD_ASSERT_KNOWN( p == 0 || p == 1,
-               "ode_evaluate: p is not zero or one"
-          );
-          CPPAD_ASSERT_KNOWN(
-               ((p==0) & (fp.size()==n)) || ((p==1) & (fp.size()==n*n)),
-               "ode_evaluate: the size of fp is not correct"
-          );
-          if( p == 0 )
-          {     // function that defines the ode
-               ode_evaluate_fun<Float> F;
-
-               // number of Runge45 steps to use
-               size_t M = 10;
-
-               // initial and final time
-               Float ti = 0.0;
-               Float tf = 1.0;
-
-               // initial value for y(x, t); i.e. y(x, 0)
-               // (is a reference to x)
-               const VectorFloat& yi = x;
-
-               // 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);
-
-               return;
-          }
-          /* 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_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!
-          ...
-          */
-          size_t i, j, k;
-          for(i = 0; i < n; i++)
-          {     for(j = 0; j < n; j++)
-                    fp[ i * n + j ] = 0.0;
-          }
-          size_t factorial = 1;
-          for(k = 0; k < n; k++)
-          {     if( k > 1 )
-                    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;
-                    fp[ i * n + j ] += 1.0 / Float(factorial);
-               }
-          }
-     }
-}
-# endif -
- - -
Input File: omh/ode_evaluate.omh - - - diff -Nru cppad-2018.00.00.0/doc/_ode_evaluate.hpp_xml.js cppad-2019.02.00.0/doc/_ode_evaluate.hpp_xml.js --- cppad-2018.00.00.0/doc/_ode_evaluate.hpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ode_evaluate.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'ode_evaluate.xml', -'ode_evaluate.hpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'ode_evaluate.cpp.xml', -'ode_evaluate.hpp.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-2018.00.00.0/doc/ode_evaluate.xml cppad-2019.02.00.0/doc/ode_evaluate.xml --- cppad-2018.00.00.0/doc/ode_evaluate.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/ode_evaluate.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,502 +0,0 @@ - - - -Evaluate a Function Defined in Terms of an ODE - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Evaluate a Function Defined in Terms of an ODE
-
-Syntax - -
- -# include <cppad/speed/ode_evaluate.hpp>
-
- -ode_evaluate(xpfp) - - -
-
-Purpose -
-This routine evaluates a function - -f -: -R - -n - - -R - -n - - - - -defined by - - -f -( -x -) -= -y -( -x -, -1 -) - - -where - -y -( -x -, -t -) - - - solves the ordinary differential equation - - - -y -( -x -, -0 -) - -= - -x - - -t - -y -( -x -, -t -) - -= - -g -[ -y -( -x -, -t -) -, -t -] - - - -where - -g -: -R - -n - -× -R - - -R - -n - - - - -is an unspecified function. - -
-
-Inclusion -
-The template function ode_evaluate -is defined in the CppAD namespace by including -the file cppad/speed/ode_evaluate.hpp -(relative to the CppAD distribution directory). - -
-
-Float - - -
-
-Operation Sequence -
-The type -Float - must be a NumericType -. -The -Float - -operation sequence - -for this routine does not depend on the value of the argument -x -, -hence it does not need to be retaped for each value of - -x - - -. - -
-
-fabs -
-If -y - and -z - are -Float - objects, the syntax - -
-     
y = fabs(z)
-
-must be supported. Note that it does not matter if the operation -sequence for fabs depends on -z - because the -corresponding results are not actually used by ode_evaluate; -see fabs in Runge45 -. - -
-
-x -
-The argument -x - has prototype - -
-     const CppAD::vector<
Float>& x
-
-It contains he argument value for which the function, -or its derivative, is being evaluated. -The value - -n - - - is determined by the size of the vector -x -. - -
-
-p -
-The argument -p - has prototype - -
-     size_t 
p
-
-
-p == 0 -
-In this case a numerical method is used to solve the ode -and obtain an accurate approximation for - -y -( -x -, -1 -) - - -. -This numerical method has a fixed -that does not depend on -x -. - -
-
-p = 1 -
-In this case an analytic solution for the partial derivative - - - -x - -y -( -x -, -1 -) - - - is returned. - -
-
-fp -
-The argument -fp - has prototype - -
-     CppAD::vector<
Float>& fp
-
-The input value of the elements of -fp - does not matter. - -
-
-Function -
-If -p - is zero, -fp - has size equal to - -n - - - -and contains the value of - -y -( -x -, -1 -) - - -. - -
-
-Gradient -
-If -p - is one, -fp - has size equal to -n^2 - -and for - -i -= -0 -, - -1 - - -, - -j -= -0 -, - -, -n --1 - - - - - - -y -[ -i -] - - -x -[ -j -] - - -( -x -, -1 -) -= -fp -[ -i -· -n -+ -j -] - - -
-Example -
-The file -ode_evaluate.cpp - -contains an example and test of ode_evaluate.hpp. -It returns true if it succeeds and false otherwise. - - -
-
-Source Code -
-The file -ode_evaluate.hpp - -contains the source code for this template function. - - -
Input File: cppad/speed/ode_evaluate.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ode_evaluate_xml.js cppad-2019.02.00.0/doc/_ode_evaluate_xml.js --- cppad-2018.00.00.0/doc/_ode_evaluate_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ode_evaluate_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'ode_evaluate.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down0 = [ -'ode_evaluate.cpp.xml', -'ode_evaluate.hpp.xml' -]; -var list_current0 = [ -'ode_evaluate.xml#Syntax', -'ode_evaluate.xml#Purpose', -'ode_evaluate.xml#Inclusion', -'ode_evaluate.xml#Float', -'ode_evaluate.xml#Float.Operation Sequence', -'ode_evaluate.xml#Float.fabs', -'ode_evaluate.xml#x', -'ode_evaluate.xml#p', -'ode_evaluate.xml#p.p == 0', -'ode_evaluate.xml#p.p = 1', -'ode_evaluate.xml#fp', -'ode_evaluate.xml#fp.Function', -'ode_evaluate.xml#fp.Gradient', -'ode_evaluate.xml#Example', -'ode_evaluate.xml#Source Code' -]; -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-2018.00.00.0/doc/ode_gear_control.cpp.xml cppad-2019.02.00.0/doc/ode_gear_control.cpp.xml --- cppad-2018.00.00.0/doc/ode_gear_control.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ode_gear_control.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,397 +0,0 @@ - - - -OdeGearControl: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ode_gear_control.cppHeadings

- - - -
OdeGearControl: Example and Test
-Define - - -X -: -R - - -R - -2 - - - - by - - - -X -0 - -( -t -) - -= - -- -exp -( -- -w -0 - -t -) - -X -1 - -( -t -) - -= - -w -0 - - -w -1 - -- -w -0 - - - -[ -exp -( -- -w -0 - -t -) -- -exp -( -- -w -1 - -t -) -] - - - -It follows that - -X -0 - -( -0 -) -= -1 - - -, - -X -1 - -( -0 -) -= -0 - - - and - - - -X -0 -( -1 -) - - -( -t -) - -= - -- -w -0 - -X -0 - -( -t -) - -X -1 -( -1 -) - - -( -t -) - -= - -+ -w -0 - -X -0 - -( -t -) -- -w -1 - -X -1 - -( -t -) - - - -The example tests OdeGearControl using the relations above: - - -

-# include <cppad/cppad.hpp>
-# include <cppad/utility/ode_gear_control.hpp>   // CppAD::OdeGearControl
-
-namespace {
-     // --------------------------------------------------------------
-     class Fun {
-     private:
-           CPPAD_TESTVECTOR(double) w;
-     public:
-          // constructor
-          Fun(const CPPAD_TESTVECTOR(double) &w_) : w(w_)
-          { }
-
-          // set f = x'(t)
-          template <typename Scalar>
-          void Ode(
-               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];
-          }
-
-          void Ode_dep(
-               const double                    &t,
-               const CPPAD_TESTVECTOR(double) &x,
-               CPPAD_TESTVECTOR(double)       &f_x)
-          {     using namespace CppAD;
-
-               size_t n  = x.size();
-               CPPAD_TESTVECTOR(AD<double>) T(1);
-               CPPAD_TESTVECTOR(AD<double>) X(n);
-               CPPAD_TESTVECTOR(AD<double>) F(n);
-
-               // set argument values
-               T[0] = t;
-               size_t i, j;
-               for(i = 0; i < n; i++)
-                    X[i] = x[i];
-
-               // declare independent variables
-               Independent(X);
-
-               // compute f(t, x)
-               this->Ode(T[0], X, F);
-
-               // define AD function object
-               ADFun<double> fun(X, F);
-
-               // compute partial of f w.r.t x
-               CPPAD_TESTVECTOR(double) dx(n);
-               CPPAD_TESTVECTOR(double) df(n);
-               for(j = 0; j < n; j++)
-                    dx[j] = 0.;
-               for(j = 0; j < n; j++)
-               {     dx[j] = 1.;
-                    df = fun.Forward(1, dx);
-                    for(i = 0; i < n; i++)
-                         f_x [i * n + j] = df[i];
-                    dx[j] = 0.;
-               }
-          }
-     };
-}
-
-bool OdeGearControl(void)
-{     bool ok = true;     // initial return value
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     CPPAD_TESTVECTOR(double) w(2);
-     w[0] = 10.;
-     w[1] = 1.;
-     Fun F(w);
-
-     CPPAD_TESTVECTOR(double) xi(2);
-     xi[0] = 1.;
-     xi[1] = 0.;
-
-     CPPAD_TESTVECTOR(double) eabs(2);
-     eabs[0] = 1e-4;
-     eabs[1] = 1e-4;
-
-     // return values
-     CPPAD_TESTVECTOR(double) ef(2);
-     CPPAD_TESTVECTOR(double) maxabs(2);
-     CPPAD_TESTVECTOR(double) xf(2);
-     size_t                nstep;
-
-     // input values
-     size_t  M   = 5;
-     double ti   = 0.;
-     double tf   = 1.;
-     double smin = 1e-8;
-     double smax = 1.;
-     double sini = eps99;
-     double erel = 0.;
-
-     xf = CppAD::OdeGearControl(F, M,
-          ti, tf, xi, smin, smax, sini, eabs, erel, ef, maxabs, nstep);
-
-     double x0 = exp(-w[0]*tf);
-     ok &= NearEqual(x0, xf[0], 1e-4, 1e-4);
-     ok &= NearEqual(0., ef[0], 1e-4, 1e-4);
-
-     double x1 = w[0] * (exp(-w[0]*tf) - exp(-w[1]*tf))/(w[1] - w[0]);
-     ok &= NearEqual(x1, xf[1], 1e-4, 1e-4);
-     ok &= NearEqual(0., ef[1], 1e-4, 1e-4);
-
-     return ok;
-}
-
-
-
Input File: example/utility/ode_gear_control.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ode_gear_control.cpp_xml.js cppad-2019.02.00.0/doc/_ode_gear_control.cpp_xml.js --- cppad-2018.00.00.0/doc/_ode_gear_control.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ode_gear_control.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'odegearcontrol.xml', -'ode_gear_control.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'ode_gear_control.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-2018.00.00.0/doc/odegearcontrol.xml cppad-2019.02.00.0/doc/odegearcontrol.xml --- cppad-2018.00.00.0/doc/odegearcontrol.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/odegearcontrol.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1226 +0,0 @@ - - - -An Error Controller for Gear's Ode Solvers - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
An Error Controller for Gear's Ode Solvers
-
-Syntax - -
- -# include <cppad/utility/ode_gear_control.hpp>
-
- -xf = OdeGearControl(FMtitfxi,
-     
sminsmaxsinieabserelef , maxabsnstep )
- - - -
-
-Purpose -
-Let - -R - - - - denote the real numbers -and let - -f -: -R - -× -R - -n - - -R - -n - - - - be a smooth function. -We define - -X -: -[ -ti -, -tf -] - -R - -n - - - - by -the following initial value problem: - - - -X -( -ti -) - -= - -xi - -X -' -( -t -) - -= - -f -[ -t -, -X -( -t -) -] - - - -The routine OdeGear - is a stiff multi-step method that -can be used to approximate the solution to this equation. -The routine OdeGearControl sets up this multi-step method -and controls the error during such an approximation. - -
-
-Include -
-The file cppad/ode_gear_control.hpp -is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-Notation -
-The template parameter types Scalar - and -Vector - are documented below. - -
-
-xf -
-The return value -xf - has the prototype - -
-     
Vector xf
-
-and the size of -xf - is equal to -n - -(see description of Vector - below). -It is the approximation for - -X -( -tf -) - - -. - -
-
-Fun -
-The class -Fun - -and the object -F - satisfy the prototype - -
-     
Fun &F
-
-This must support the following set of calls - -
-     
F.Ode(txf)
-     
F.Ode_dep(txf_x)
-
-
-t -
-The argument -t - has prototype - -
-     const 
Scalar &t
-
-(see description of Scalar - below). - -
-
-x -
-The argument -x - has prototype - -
-     const 
Vector &x
-
-and has size -N - -(see description of Vector - below). - -
-
-f -
-The argument -f - to -F.Ode - has prototype - -
-     
Vector &f
-
-On input and output, -f - is a vector of size -N - -and the input values of the elements of -f - do not matter. -On output, - -f - is set equal to - -f -( -t -, -x -) - - - -(see -f(t, x) - in Purpose -). - -
-
-f_x -
-The argument -f_x - has prototype - -
-     
Vector &f_x
-
-On input and output, -f_x - is a vector of size - -N -* -N - - - -and the input values of the elements of -f_x - do not matter. -On output, - - -f -_ -x -[ -i -* -n -+ -j -] -= - -x -( -j -) - - -f -i - -( -t -, -x -) - - -
-Warning -
-The arguments -f -, and -f_x - -must have a call by reference in their prototypes; i.e., -do not forget the & in the prototype for - -f - and -f_x -. - -
-
-M -
-The argument -M - has prototype - -
-     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 -M - must greater than or equal one. - -
-
-ti -
-The argument -ti - has prototype - -
-     const 
Scalar &ti
-
-It specifies the initial time for the integration of -the differential equation. - -
-
-tf -
-The argument -tf - has prototype - -
-     const 
Scalar &tf
-
-It specifies the final time for the integration of -the differential equation. - -
-
-xi -
-The argument -xi - has prototype - -
-     const 
Vector &xi
-
-and size -n -. -It specifies value of - -X -( -ti -) - - -. - -
-
-smin -
-The argument -smin - has prototype - -
-     const 
Scalar &smin
-
-The minimum value of - -T -[ -M -] -- -T -[ -M --1 -] - - - in a call to OdeGear -will be - -smin - - - except for the last two calls where it may be -as small as - -smin -/ -2 - - -. -The value of -smin - must be less than or equal -smax -. - -
-
-smax -
-The argument -smax - has prototype - -
-     const 
Scalar &smax
-
-It specifies the maximum step size to use during the integration; -i.e., the maximum value for - -T -[ -M -] -- -T -[ -M --1 -] - - - -in a call to OdeGear. - -
-
-sini -
-The argument -sini - has prototype - -
-     
Scalar &sini
-
-The value of -sini - is the minimum -step size to use during initialization of the multi-step method; i.e., -for calls to OdeGear where - -m -< -M - - -. -The value of -sini - must be less than or equal -smax - -(and can also be less than -smin -). - -
-
-eabs -
-The argument -eabs - has prototype - -
-     const 
Vector &eabs
-
-and size -n -. -Each of the elements of -eabs - must be -greater than or equal zero. -It specifies a bound for the absolute -error in the return value -xf - as an approximation for - -X -( -tf -) - - -. -(see the -error criteria discussion - -below). - -
-
-erel -
-The argument -erel - has prototype - -
-     const 
Scalar &erel
-
-and is greater than or equal zero. -It specifies a bound for the relative -error in the return value -xf - as an approximation for - -X -( -tf -) - - - -(see the -error criteria discussion - -below). - -
-
-ef -
-The argument value -ef - has prototype - -
-     
Vector &ef
-
-and size -n -. -The input value of its elements does not matter. -On output, -it contains an estimated bound for the -absolute error in the approximation -xf -; i.e., - - -ef -i - -> -| -X -( -tf -) -i - -- -xf -i - -| - - -
-maxabs -
-The argument -maxabs - is optional in the call to OdeGearControl. -If it is present, it has the prototype - -
-     
Vector &maxabs
-
-and size -n -. -The input value of its elements does not matter. -On output, -it contains an estimate for the -maximum absolute value of - -X -( -t -) - - -; i.e., - - -maxabs -[ -i -] - -max -{| -X -( -t -) -i - -| - -: - -t - -[ -ti -, -tf -] -} - - -
-nstep -
-The argument -nstep - has the prototype - -
-     
size_t &nstep
-
-Its input value does not matter and its output value -is the number of calls to OdeGear - -used by OdeGearControl. - -
-
-Error Criteria Discussion -
-The relative error criteria -erel - and -absolute error criteria -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 - -X - -˜ -( -t -) - - - is the approximate solution -at time - -t - - -, - -ta - is the initial step time, -and -tb - is the final step time, - - -|X - -˜ -( -tb -) -j - -- -X -( -tb -) -j - -| - -tf -- -ti - -tb -- -ta - - -[eabs -[ -j -] -+ -erel - -| -X - -˜ -( -tb -) -j - -| -] - - -If - -X -( -tb -) -j - - - - is near zero for some - -tb - -[ -ti -, -tf -] - - -, -and one uses an absolute error criteria - -eabs -[ -j -] - - - of zero, -the error criteria above will force OdeGearControl -to use step sizes equal to -smin - -for steps ending near - -tb - - -. -In this case, the error relative to -maxabs - can be judged after -OdeGearControl returns. -If -ef - is to large relative to -maxabs -, -OdeGearControl can be called again -with a smaller value of -smin -. - -
-
-Scalar -
-The type -Scalar - must satisfy the conditions -for a NumericType - type. -The routine CheckNumericType - will generate an error message -if this is not the case. -In addition, the following operations must be defined for - -Scalar - objects -a - and -b -: - - -
- -Operation - Description
- - -a <= b - - - returns true (false) if -a - is less than or equal - (greater than) -b -. -
- - -a == b - - - returns true (false) if -a - is equal to -b -. -
- - -log(a) - - - returns a -Scalar - equal to the logarithm of -a - -
- - -exp(a) - - - returns a -Scalar - equal to the exponential of -a - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type Scalar -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Example - -
-The file -ode_gear_control.cpp - -contains an example and test a test of using this routine. -It returns true if it succeeds and false otherwise. - -
-
-Theory -
-Let - -e -( -s -) - - - be the error as a function of the -step size - -s - - - and suppose that there is a constant - - -K - - - such that - -e -( -s -) -= -K -s -m - - - -. -Let - -a - - - be our error bound. -Given the value of - -e -( -s -) - - -, a step of size - -λ -s - - - -would be ok provided that - - - -a - - - -e -( -λ -s -) -( -tf -- -ti -) -/ -( -λ -s -) - -a - - - -K -λ -m - -s -m - -( -tf -- -ti -) -/ -( -λ -s -) - -a - - - -λ -m --1 - - -s -m --1 - - -( -tf -- -ti -) -e -( -s -) -/ -s -m - - -a - - - -λ -m --1 - - -( -tf -- -ti -) -e -( -s -) -/ -s - -λ -m --1 - - - - - -a - -e -( -s -) - - -s - -tf -- -ti - - - - - -Thus if the right hand side of the last inequality is greater -than or equal to one, the step of size - -s - - - is ok. - -
-
-Source Code -
-The source code for this routine is in the file -cppad/ode_gear_control.hpp. - - -
Input File: cppad/utility/ode_gear_control.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_odegearcontrol_xml.js cppad-2019.02.00.0/doc/_odegearcontrol_xml.js --- cppad-2018.00.00.0/doc/_odegearcontrol_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_odegearcontrol_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'odegearcontrol.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'ode_gear_control.cpp.xml' -]; -var list_current0 = [ -'odegearcontrol.xml#Syntax', -'odegearcontrol.xml#Purpose', -'odegearcontrol.xml#Include', -'odegearcontrol.xml#Notation', -'odegearcontrol.xml#xf', -'odegearcontrol.xml#Fun', -'odegearcontrol.xml#Fun.t', -'odegearcontrol.xml#Fun.x', -'odegearcontrol.xml#Fun.f', -'odegearcontrol.xml#Fun.f_x', -'odegearcontrol.xml#Fun.Warning', -'odegearcontrol.xml#M', -'odegearcontrol.xml#ti', -'odegearcontrol.xml#tf', -'odegearcontrol.xml#xi', -'odegearcontrol.xml#smin', -'odegearcontrol.xml#smax', -'odegearcontrol.xml#sini', -'odegearcontrol.xml#eabs', -'odegearcontrol.xml#erel', -'odegearcontrol.xml#ef', -'odegearcontrol.xml#maxabs', -'odegearcontrol.xml#nstep', -'odegearcontrol.xml#Error Criteria Discussion', -'odegearcontrol.xml#Scalar', -'odegearcontrol.xml#Vector', -'odegearcontrol.xml#Example', -'odegearcontrol.xml#Theory', -'odegearcontrol.xml#Source Code' -]; -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-2018.00.00.0/doc/ode_gear.cpp.xml cppad-2019.02.00.0/doc/ode_gear.cpp.xml --- cppad-2018.00.00.0/doc/ode_gear.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ode_gear.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,375 +0,0 @@ - - - -OdeGear: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ode_gear.cppHeadings

- - - -
OdeGear: Example and Test
-Define - - -x -: -R - - -R - -n - - - - by - - -x -i - -( -t -) -= -t -i -+ -1 - - - - -for - -i -= -1 -, - -, -n --1 - - -. -It follows that - - - -x -i - -( -0 -) - -= - -0 - -for - -all - - -i - -x -i - -' -( -t -) - -= - -1 - -if - - -i -= -0 - -x -i - -' -( -t -) - -= - -( -i -+ -1 -) -t -i - -= -( -i -+ -1 -) -x -i --1 - - -( -t -) - -if - - -i -> -0 - - - -The example tests OdeGear using the relations above: - - -

-# include <cppad/utility/ode_gear.hpp>
-# include <cppad/cppad.hpp>        // For automatic differentiation
-
-namespace {
-     class Fun {
-     public:
-          // constructor
-          Fun(bool use_x_) : use_x(use_x_)
-          { }
-
-          // compute f(t, x) both for double and AD<double>
-          template <typename Scalar>
-          void Ode(
-               const Scalar                    &t,
-               const CPPAD_TESTVECTOR(Scalar) &x,
-               CPPAD_TESTVECTOR(Scalar)       &f)
-          {     size_t n  = x.size();
-               Scalar ti(1);
-               f[0]   = Scalar(1);
-               size_t i;
-               for(i = 1; i < n; i++)
-               {     ti *= t;
-                    // convert int(size_t) to avoid warning
-                    // on _MSC_VER systems
-                    if( use_x )
-                         f[i] = int(i+1) * x[i-1];
-                    else     f[i] = int(i+1) * ti;
-               }
-          }
-
-          void Ode_dep(
-               const double                    &t,
-               const CPPAD_TESTVECTOR(double) &x,
-               CPPAD_TESTVECTOR(double)       &f_x)
-          {     using namespace CppAD;
-
-               size_t n  = x.size();
-               CPPAD_TESTVECTOR(AD<double>) T(1);
-               CPPAD_TESTVECTOR(AD<double>) X(n);
-               CPPAD_TESTVECTOR(AD<double>) F(n);
-
-               // set argument values
-               T[0] = t;
-               size_t i, j;
-               for(i = 0; i < n; i++)
-                    X[i] = x[i];
-
-               // declare independent variables
-               Independent(X);
-
-               // compute f(t, x)
-               this->Ode(T[0], X, F);
-
-               // define AD function object
-               ADFun<double> fun(X, F);
-
-               // compute partial of f w.r.t x
-               CPPAD_TESTVECTOR(double) dx(n);
-               CPPAD_TESTVECTOR(double) df(n);
-               for(j = 0; j < n; j++)
-                    dx[j] = 0.;
-               for(j = 0; j < n; j++)
-               {     dx[j] = 1.;
-                    df = fun.Forward(1, dx);
-                    for(i = 0; i < n; i++)
-                         f_x [i * n + j] = df[i];
-                    dx[j] = 0.;
-               }
-          }
-
-     private:
-          const bool use_x;
-
-     };
-}
-
-bool OdeGear(void)
-{     bool ok = true; // initial return value
-     size_t i, j;    // temporary indices
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     size_t  m = 4;  // index of next value in X
-     size_t  n = m;  // number of components in x(t)
-
-     // vector of times
-     CPPAD_TESTVECTOR(double) T(m+1);
-     double step = .1;
-     T[0]        = 0.;
-     for(j = 1; j <= m; j++)
-     {     T[j] = T[j-1] + step;
-          step = 2. * step;
-     }
-
-     // initial values for x( T[m-j] )
-     CPPAD_TESTVECTOR(double) X((m+1) * n);
-     for(j = 0; j < m; j++)
-     {     double ti = T[j];
-          for(i = 0; i < n; i++)
-          {     X[ j * n + i ] = ti;
-               ti *= T[j];
-          }
-     }
-
-     // error bound
-     CPPAD_TESTVECTOR(double) e(n);
-
-     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);
-
-          // compute OdeGear approximation for x( T[m] )
-          CppAD::OdeGear(F, m, n, T, X, e);
-
-          double check = T[m];
-          for(i = 0; i < n; i++)
-          {     // method is exact up to order m and x[i] = t^{i+1}
-               if( i + 1 <= m ) ok &= CppAD::NearEqual(
-                    X[m * n + i], check, eps99, eps99
-               );
-               // error bound should be zero up to order m-1
-               if( i + 1 < m ) ok &= CppAD::NearEqual(
-                    e[i], 0., eps99, eps99
-               );
-               // check value for next i
-               check *= T[m];
-          }
-     }
-     return ok;
-}
-
-
-
Input File: example/utility/ode_gear.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ode_gear.cpp_xml.js cppad-2019.02.00.0/doc/_ode_gear.cpp_xml.js --- cppad-2018.00.00.0/doc/_ode_gear.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ode_gear.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'odegear.xml', -'ode_gear.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'ode_gear.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-2018.00.00.0/doc/odegear.xml cppad-2019.02.00.0/doc/odegear.xml --- cppad-2018.00.00.0/doc/odegear.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/odegear.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1798 +0,0 @@ - - - -An Arbitrary Order Gear Method - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
An Arbitrary Order Gear Method
-
-Syntax - -
- -# include <cppad/utility/ode_gear.hpp>
-
- -OdeGear(FmnTXe) - - - -
-
-Purpose -
-This routine applies -Gear's Method - -to solve an explicit set of ordinary differential equations. -We are given - - -f -: -R - -× -R - -n - - -R - -n - - - - be a smooth function. -This routine solves the following initial value problem - - - -x -( -t -m --1 - - -) - -= - -x -0 - - -x - - -( -t -) - -= - -f -[ -t -, -x -( -t -) -] - - - -for the value of - -x -( -t -m - -) - - -. -If your set of ordinary differential equations are not stiff -an explicit method may be better (perhaps Runge45 -.) - -
-
-Include -
-The file cppad/ode_gear.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-Fun -
-The class -Fun - -and the object -F - satisfy the prototype - -
-     
Fun &F
-
-This must support the following set of calls - -
-     
F.Ode(txf)
-     
F.Ode_dep(txf_x)
-
-
-t -
-The argument -t - has prototype - -
-     const 
Scalar &t
-
-(see description of Scalar - below). - -
-
-x -
-The argument -x - has prototype - -
-     const 
Vector &x
-
-and has size -n - -(see description of Vector - below). - -
-
-f -
-The argument -f - to -F.Ode - has prototype - -
-     
Vector &f
-
-On input and output, -f - is a vector of size -n - -and the input values of the elements of -f - do not matter. -On output, - -f - is set equal to - -f -( -t -, -x -) - - - -(see -f(t, x) - in Purpose -). - -
-
-f_x -
-The argument -f_x - has prototype - -
-     
Vector &f_x
-
-On input and output, -f_x - is a vector of size - -n -* -n - - - -and the input values of the elements of -f_x - do not matter. -On output, - - -f -_ -x -[ -i -* -n -+ -j -] -= - -x -( -j -) - - -f -i - -( -t -, -x -) - - -
-Warning -
-The arguments -f -, and -f_x - -must have a call by reference in their prototypes; i.e., -do not forget the & in the prototype for - -f - and -f_x -. - -
-
-m -
-The argument -m - has prototype - -
-     size_t 
m
-
-It specifies the order (highest power of - -t - - -) -used to represent the function - -x -( -t -) - - - in the multi-step method. -Upon return from OdeGear, -the i-th component of the polynomial is defined by - - -p -i - -( -t -j - -) -= -X -[ -j -* -n -+ -i -] - - -for - -j -= -0 -, - -, -m - - - (where - -0 - -i -< -n - - -). -The value of - -m - - - must be greater than or equal one. - -
-
-n -
-The argument -n - has prototype - -
-     size_t 
n
-
-It specifies the range space dimension of the -vector valued function - -x -( -t -) - - -. - -
-
-T -
-The argument -T - has prototype - -
-     const 
Vector &T
-
-and size greater than or equal to - -m -+ -1 - - -. -For - -j -= -0 -, - -m - - -, - -T -[ -j -] - - - is the time -corresponding to time corresponding -to a previous point in the multi-step method. -The value - -T -[ -m -] - - - is the time -of the next point in the multi-step method. -The array - -T - - - must be monotone increasing; i.e., - - -T -[ -j -] -< -T -[ -j -+ -1 -] - - -. -Above and below we often use the shorthand - -t -j - - - - for - -T -[ -j -] - - -. - - -
-
-X -
-The argument -X - has the prototype - -
-     
Vector &X
-
-and size greater than or equal to - -( -m -+ -1 -) -* -n - - -. -On input to OdeGear, -for - -j -= -0 -, - -, -m --1 - - -, and - - -i -= -0 -, - -, -n --1 - - - - - -X -[ -j -* -n -+ -i -] -= -x -i - -( -t -j - -) - - -Upon return from OdeGear, -for - -i -= -0 -, - -, -n --1 - - - - - -X -[ -m -* -n -+ -i -] - -x -i - -( -t -m - -) - - -
-e -
-The vector -e - is an approximate error bound for the result; i.e., - - -e -[ -i -] - -| -X -[ -m -* -n -+ -i -] -- -x -i - -( -t -m - -) -| - - -The order of this approximation is one less than the order of -the solution; i.e., - - -e -= -O -( -h -m - -) - - -where - -h - - - is the maximum of - -t -j -+ -1 - - -- -t -j - - - -. - -
-
-Scalar -
-The type -Scalar - must satisfy the conditions -for a NumericType - type. -The routine CheckNumericType - will generate an error message -if this is not the case. -In addition, the following operations must be defined for - -Scalar - objects -a - and -b -: - - -
- -Operation - Description
- - -a < b - - - less than operator (returns a bool object) -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type Scalar -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Example - -
-The file -ode_gear.cpp - -contains an example and test a test of using this routine. -It returns true if it succeeds and false otherwise. - -
-
-Source Code -
-The source code for this routine is in the file -cppad/ode_gear.hpp. - -
-
-Theory -
-For this discussion we use the shorthand - -x -j - - - - -for the value - -x -( -t -j - -) - -R - -n - - - - which is not to be confused -with - -x -i - -( -t -) - -R - - - - in the notation above. -The interpolating polynomial - -p -( -t -) - - - is given by - - -p -( -t -) -= - -j -= -0 - -m - -x -j - - -i - -j - - -( -t -- -t -i - -) - - -i - -j - - -( -t -j - -- -t -i - -) - - - - -The derivative - -p - - -( -t -) - - - is given by - - -p - - -( -t -) -= - -j -= -0 - -m - -x -j - - -i - -j - - - -k - -i -, -j - - -( -t -- -t -k - -) - - -k - -j - - -( -t -j - -- -t -k - -) - - - - -Evaluating the derivative at the point - -t - - - - - we have - - - -p - - -( -t - - -) - -= - -x - - - -i - - - - - -k - -i -, - - - -( -t - - -- -t -k - -) - - -k - - - - -( -t - - -- -t -k - -) - - -+ - -j - - - - -x -j - - -i - -j - - - -k - -i -, -j - - -( -t - - -- -t -k - -) - - -k - -j - - -( -t -j - -- -t -k - -) - - - - -= - -x - - - -i - - - - -1 - -t - - -- -t -i - - - -+ - -j - - - - -x -j - - -k - - -, -j - - -( -t - - -- -t -k - -) - - -k - -j - - -( -t -j - -- -t -k - -) - - - - -= - -x - - - -k - - - - -( -t - - -- -t -k - -) --1 - - -+ - -j - - - - -x -j - -( -t -j - -- -t - - -) --1 - - - -k - - -, -j - - -( -t - - -- -t -k - -) -/ -( -t -j - -- -t -k - -) - - - -We define the vector - -α - -R - -m -+ -1 - - - - - by - - -α -j - -= -{ - -k - -m - - -( -t -m - -- -t -k - -) --1 - - - -if - - -j -= -m - -( -t -j - -- -t -m - -) --1 - - - -k - -m -, -j - - -( -t -m - -- -t -k - -) -/ -( -t -j - -- -t -k - -) - -otherwise - - - - - -It follows that - - -p - - -( -t -m - -) -= -α -0 - -x -0 - -+ - -+ -α -m - -x -m - - - -Gear's method determines - -x -m - - - - by solving the following -nonlinear equation - - -f -( -t -m - -, -x -m - -) -= -α -0 - -x -0 - -+ - -+ -α -m - -x -m - - - -Newton's method for solving this equation determines iterates, -which we denote by - -x -m -k - - - -, by solving the following affine -approximation of the equation above - - - -f -( -t -m - -, -x -m -k --1 - - -) -+ - -x - -f -( -t -m - -, -x -m -k --1 - - -) -( -x -m -k - -- -x -m -k --1 - - -) - -= - -α -0 - -x -0 -k - -+ -α -1 - -x -1 - -+ - -+ -α -m - -x -m - - -[α -m - -I -- - -x - -f -( -t -m - -, -x -m -k --1 - - -) -] -x -m - - -= - -[f -( -t -m - -, -x -m -k --1 - - -) -- - -x - -f -( -t -m - -, -x -m -k --1 - - -) -x -m -k --1 - - -- -α -0 - -x -0 - -- - -- -α -m --1 - - -x -m --1 - - -] - - - -In order to initialize Newton's method; i.e. choose - -x -m -0 - - - - -we define the vector - -β - -R - -m -+ -1 - - - - - by - - -β -j - -= -{ - -k - -m --1 - - -( -t -m --1 - - -- -t -k - -) --1 - - - -if - - -j -= -m --1 - -( -t -j - -- -t -m --1 - - -) --1 - - - -k - -m --1 -, -j - - -( -t -m --1 - - -- -t -k - -) -/ -( -t -j - -- -t -k - -) - -otherwise - - - - - -It follows that - - -p - - -( -t -m --1 - - -) -= -β -0 - -x -0 - -+ - -+ -β -m - -x -m - - - -We solve the following approximation of the equation above to determine - - -x -m -0 - - - -: - - -f -( -t -m --1 - - -, -x -m --1 - - -) -= -β -0 - -x -0 - -+ - -+ -β -m --1 - - -x -m --1 - - -+ -β -m - -x -m -0 - - - -
-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. - - - -
Input File: cppad/utility/ode_gear.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_odegear_xml.js cppad-2019.02.00.0/doc/_odegear_xml.js --- cppad-2018.00.00.0/doc/_odegear_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_odegear_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'odegear.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'ode_gear.cpp.xml' -]; -var list_current0 = [ -'odegear.xml#Syntax', -'odegear.xml#Purpose', -'odegear.xml#Include', -'odegear.xml#Fun', -'odegear.xml#Fun.t', -'odegear.xml#Fun.x', -'odegear.xml#Fun.f', -'odegear.xml#Fun.f_x', -'odegear.xml#Fun.Warning', -'odegear.xml#m', -'odegear.xml#n', -'odegear.xml#T', -'odegear.xml#X', -'odegear.xml#e', -'odegear.xml#Scalar', -'odegear.xml#Vector', -'odegear.xml#Example', -'odegear.xml#Source Code', -'odegear.xml#Theory', -'odegear.xml#Gear\'s Method' -]; -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-2018.00.00.0/doc/ode_stiff.cpp.xml cppad-2019.02.00.0/doc/ode_stiff.cpp.xml --- cppad-2018.00.00.0/doc/ode_stiff.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ode_stiff.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,436 +0,0 @@ - - - -A Stiff Ode: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ode_stiff.cppHeadings

- - - -
A Stiff Ode: Example and Test
-Define - - -x -: -R - - -R - -2 - - - - by - - - -x -0 - -( -0 -) - -= - -1 - -x -1 - -( -0 -) - -= - -0 - -x -0 - - -( -t -) - -= - -- -a -0 - -x -0 - -( -t -) - -x -1 - - -( -t -) - -= - -+ -a -0 - -x -0 - -( -t -) -- -a -1 - -x -1 - -( -t -) - - - -If - -a -0 - - -a -1 - -> -0 - - -, this is a stiff Ode and -the analytic solution is - - - -x -0 - -( -t -) - -= - -exp -( -- -a -0 - -t -) - -x -1 - -( -t -) - -= - -a -0 - -[ -exp -( -- -a -1 - -t -) -- -exp -( -- -a -0 - -t -) -] -/ -( -a -0 - -- -a -1 - -) - - - -The example tests Rosen34 using the relations above: - - -

-# include <cppad/cppad.hpp>
-
-// To print the comparision, change the 0 to 1 on the next line.
-# define CPPAD_ODE_STIFF_PRINT 0
-
-namespace {
-     // --------------------------------------------------------------
-     class Fun {
-     private:
-          CPPAD_TESTVECTOR(double) a;
-     public:
-          // constructor
-          Fun(const CPPAD_TESTVECTOR(double)& a_) : a(a_)
-          { }
-          // compute f(t, x)
-          void Ode(
-               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];
-          }
-          // compute partial of f(t, x) w.r.t. t
-          void Ode_ind(
-               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
-          void Ode_dep(
-               const double                    &t,
-               const CPPAD_TESTVECTOR(double) &x,
-               CPPAD_TESTVECTOR(double)       &f_x)
-          {     f_x[0] = -a[0];
-               f_x[1] = 0.;
-               f_x[2] = +a[0];
-               f_x[3] = -a[1];
-          }
-     };
-     // --------------------------------------------------------------
-     class RungeMethod {
-     private:
-          Fun F;
-     public:
-          // constructor
-          RungeMethod(const CPPAD_TESTVECTOR(double) &a_) : F(a_)
-          { }
-          void step(
-               double                     ta ,
-               double                     tb ,
-               CPPAD_TESTVECTOR(double) &xa ,
-               CPPAD_TESTVECTOR(double) &xb ,
-               CPPAD_TESTVECTOR(double) &eb )
-          {     xb = CppAD::Runge45(F, 1, ta, tb, xa, eb);
-          }
-          size_t order(void)
-          {     return 5; }
-     };
-     class RosenMethod {
-     private:
-          Fun F;
-     public:
-          // constructor
-          RosenMethod(const CPPAD_TESTVECTOR(double) &a_) : F(a_)
-          { }
-          void step(
-               double                     ta ,
-               double                     tb ,
-               CPPAD_TESTVECTOR(double) &xa ,
-               CPPAD_TESTVECTOR(double) &xb ,
-               CPPAD_TESTVECTOR(double) &eb )
-          {     xb = CppAD::Rosen34(F, 1, ta, tb, xa, eb);
-          }
-          size_t order(void)
-          {     return 4; }
-     };
-}
-
-bool OdeStiff(void)
-{     bool ok = true;     // initial return value
-
-     CPPAD_TESTVECTOR(double) a(2);
-     a[0] = 1e3;
-     a[1] = 1.;
-     RosenMethod rosen(a);
-     RungeMethod runge(a);
-     Fun          gear(a);
-
-     CPPAD_TESTVECTOR(double) xi(2);
-     xi[0] = 1.;
-     xi[1] = 0.;
-
-     CPPAD_TESTVECTOR(double) eabs(2);
-     eabs[0] = 1e-6;
-     eabs[1] = 1e-6;
-
-     CPPAD_TESTVECTOR(double) ef(2);
-     CPPAD_TESTVECTOR(double) xf(2);
-     CPPAD_TESTVECTOR(double) maxabs(2);
-     size_t                nstep;
-
-     size_t k;
-     for(k = 0; k < 3; k++)
-     {
-          size_t M    = 5;
-          double ti   = 0.;
-          double tf   = 1.;
-          double smin = 1e-7;
-          double sini = 1e-7;
-          double smax = 1.;
-          double scur = .5;
-          double erel = 0.;
-
-          if( k == 0 )
-          {     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,
-               xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep);
-          }
-          else if( k == 2 )
-          {     xf = CppAD::OdeGearControl(gear, M, ti, tf,
-               xi, smin, smax, sini, eabs, erel, ef, maxabs, nstep);
-          }
-          double x0 = exp(-a[0]*tf);
-          ok &= CppAD::NearEqual(x0, xf[0], 0., eabs[0]);
-          ok &= CppAD::NearEqual(0., ef[0], 0., eabs[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]);
-# if CPPAD_ODE_STIFF_PRINT
-          const char* method[]={ "Rosen34", "Runge45", "Gear5" };
-          std::cout << std::endl;
-          std::cout << "method     = " << method[k] << std::endl;
-          std::cout << "nstep      = " << nstep  << std::endl;
-          std::cout << "x0         = " << x0 << std::endl;
-          std::cout << "xf[0]      = " << xf[0] << std::endl;
-          std::cout << "x0 - xf[0] = " << x0 - xf[0] << std::endl;
-          std::cout << "ef[0]      = " << ef[0] << std::endl;
-          std::cout << "x1         = " << x1 << std::endl;
-          std::cout << "xf[1]      = " << xf[1] << std::endl;
-          std::cout << "x1 - xf[1] = " << x1 - xf[1] << std::endl;
-          std::cout << "ef[1]      = " << ef[1] << std::endl;
-# endif
-     }
-
-     return ok;
-}
-
-
-
Input File: example/general/ode_stiff.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ode_stiff.cpp_xml.js cppad-2019.02.00.0/doc/_ode_stiff.cpp_xml.js --- cppad-2018.00.00.0/doc/_ode_stiff.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ode_stiff.cpp_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', -'example.xml', -'general.xml', -'ode_stiff.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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' -]; -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-2018.00.00.0/doc/ode_taylor.cpp.xml cppad-2019.02.00.0/doc/ode_taylor.cpp.xml --- cppad-2018.00.00.0/doc/ode_taylor.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ode_taylor.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,586 +0,0 @@ - - - -Taylor's Ode Solver: An Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ode_taylor.cpp - -

-
Taylor's Ode Solver: An Example and Test
-
-Purpose -
-This example solves an ordinary differential equation using Taylor's method; -i.e., - - -Z -( -t -+ -Δ -t -) - -Z -( -0 -) - - -( -t -) -+ -Z -( -1 -) - - -( -t -) - -1 -! - - -Δ -t -+ - -+ -Z -( -p -) - - -( -t -) - -p -! - - -( -Δ -t -) -p - -) - - -
-ODE -
-The ODE is defined by the function - - -h -: -R - -n - - -R - -n - - - -, -which for this example is given by - - -Z -( -1 -) - - -( -t -) -= -H -[ -Z -( -t -) -] -= -( -1 - -Z -1 - -( -t -) - - - -Z -n --1 - - -( -t -) - -) - - -and the initial condition is - -z -( -0 -) -= -0 - - -. - -
-
-ODE Solution -
-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 - - -Z -( -t -) -= -( -t - -t -2 - -/ -2 - - - -t -n - -/ -n -! - -) - - -
-Forward Mode -
-Given the Taylor coefficients for - -k -= -0 -, - -, -K - - - - - -z -( -k -) - - -= -Z -( -k -) - - - -k -! - - -( -t -) - - -we note that - - - -Z -( -1 -) - - -( -t -) - -= - -H -( -z -( -0 -) - - -+ -z -( -1 -) - - -t -+ - -+ -z -( -K -) - - -t -K - -) -+ -O -( -t -K -+ -1 - - -) - - -= - -h -( -0 -) - - -+ -h -( -1 -) - - -t -+ - -+ -h -( -K -) - - -t -K - -+ -O -( -t -K -+ -1 - - -) - - - -where - -h -( -k -) - - - - - is the k-th order Taylor coefficient for - - -H -( -Z -( -t -) -) - - -. -Taking K-th order derivatives of both sides we obtain - - - -Z -( -K -+ -1 -) - - -( -t -) - -= - -K -! -h -( -K -) - - - -z -( -K -+ -1 -) - - - -= - -h -( -K -) - - -/ -K - - - -The code below uses this relationship to implement Taylor's -method for approximating the solution of an ODE. - - -

-# include <cppad/cppad.hpp>
-
-// =========================================================================
-// define types for each level
-namespace { // BEGIN empty namespace
-     using CppAD::AD;
-
-     CPPAD_TESTVECTOR( AD<double> ) ode(
-          const CPPAD_TESTVECTOR( AD<double> )& Z )
-     {     size_t n = Z.size();
-          CPPAD_TESTVECTOR( AD<double> ) y(n);
-          y[0] = 1;
-          for(size_t k = 1; k < n; k++)
-               y[k] = Z[k-1];
-          return y;
-     }
-
-}
-
-// -------------------------------------------------------------------------
-// Example that uses Taylor's method to solve ordinary differential equaitons
-bool ode_taylor(void)
-{     // initialize the return value as true
-     bool ok = true;
-
-     // some temporary indices
-     size_t i, j, k;
-
-     // The ODE does not depend on the arugment values
-     // so only tape once, also note that ode does not depend on t
-     size_t n = 5;    // number of independent and dependent variables
-     CPPAD_TESTVECTOR( AD<double> ) a_x(n), a_y(n);
-     CppAD::Independent( a_x );
-     a_y = ode(a_x);
-     CppAD::ADFun<double> H(a_x, a_y);
-
-     // initialize the solution vector at time zero
-     CPPAD_TESTVECTOR( double ) z(n);
-     for(j = 0; j < n; j++)
-          z[j] = 0.0;
-
-     size_t order   = n;   // order of the Taylor method
-     size_t n_step  = 4;   // number of time steps
-     double dt      = 0.5; // step size in time
-     // Taylor coefficients of order k
-     CPPAD_TESTVECTOR( double ) hk(n), zk(n);
-
-     // loop with respect to each step of Taylor's method
-     for(size_t i_step = 0; i_step < n_step; i_step++)
-     {     // Use Taylor's method to take a step
-          zk           = z;     // initialize z^{(k)}  for k = 0
-          double dt_kp = dt;    // initialize dt^(k+1) for k = 0
-          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);
-
-                    // add term for to this Taylor coefficient
-                    // to solution for y(t, x)
-                    z[j] += zk[j] * dt_kp;
-               }
-               // next power of t
-               dt_kp *= dt;
-          }
-     }
-
-     // check solution of the ODE,
-     // Taylor's method should have no truncation error for this case
-     double eps   = 100. * std::numeric_limits<double>::epsilon();
-     double check = 1.;
-     double t     = double(n_step) * dt;
-     for(i = 0; i < n; i++)
-     {     check *= t / double(i + 1);
-          ok &= CppAD::NearEqual(z[i], check, eps, eps);
-     }
-
-     return ok;
-}
-
-
-
Input File: example/general/ode_taylor.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_ode_taylor.cpp_xml.js cppad-2019.02.00.0/doc/_ode_taylor.cpp_xml.js --- cppad-2018.00.00.0/doc/_ode_taylor.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ode_taylor.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +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', -'ode_taylor.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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_current0 = [ -'ode_taylor.cpp.xml#Purpose', -'ode_taylor.cpp.xml#ODE', -'ode_taylor.cpp.xml#ODE Solution', -'ode_taylor.cpp.xml#Forward Mode' -]; -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-2018.00.00.0/doc/old_atomic.xml cppad-2019.02.00.0/doc/old_atomic.xml --- cppad-2018.00.00.0/doc/old_atomic.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/old_atomic.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,3286 +0,0 @@ - - - -User Defined Atomic AD Functions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
User Defined Atomic AD Functions
-
-Deprecated 2013-05-27 -
-Using CPPAD_USER_ATOMIC has been deprecated. -Use atomic_base - instead. - -
-
-Syntax Function - -
- -CPPAD_USER_ATOMIC(afunTvectorBase,
-     
forwardreversefor_jac_sparserev_jac_sparserev_hes_sparse
-)
-
-
-Use Function - -
- -afun(idaxay)
-
-
-Callback Routines - -
- -ok = forward(idknmvxvytxty)
-
- -ok = reverse(idknmtxtypxpy)
-
- -ok = for_jac_sparse(idnmqrs)
-
- -ok = rev_jac_sparse(idnmqrs)
-
- -ok = rev_hes_sparse(idnmqrstuv)
-
-
-Free Static Memory - -
- -user_atomic<Base>::clear() - - -
-
-Purpose -
-In some cases, the user knows how to compute the derivative -of a function - - -y -= -f -( -x -) - -where - - -f -: -B -n - - -B -m - - - -more efficiently than by coding it using -AD<Base> - -atomic - operations -and letting CppAD do the rest. -In this case, CPPAD_USER_ATOMIC can be used -add the user code for - -f -( -x -) - - -, and its derivatives, -to the set of -AD<Base> - atomic operations. -
-
-
Another possible purpose is to reduce the size of the tape; -see use AD - - -
-
-Partial Implementation -
-The routines -forward -, -reverse -, -for_jac_sparse -, -rev_jac_sparse -, and -rev_hes_sparse -, -must be defined by the user. -The -forward - the routine, -for the case -k = 0 -, must be implemented. -Functions with the correct prototype, -that just return false, -can be used for the other cases -(unless they are required by your calculations). -For example, you need not implement - -forward - for the case -k == 2 - until you require -forward mode calculation of second derivatives. - -
-
-CPPAD_USER_ATOMIC -
-The macro - -
-CPPAD_USER_ATOMIC(
afunTvectorBase,
-     
forwardreversefor_jac_sparserev_jac_sparserev_hes_sparse
-)
-
-defines the -AD<Base> - routine -afun -. -This macro can be placed within a namespace -(not the CppAD namespace) -but must be outside of any routine. - -
-
-Tvector -
-The macro argument -Tvector - must be a -simple vector template class -. -It determines the type of vectors used as arguments to the routine - -afun -. - -
-
-Base -
-The macro argument -Base - specifies the -base type - -corresponding to -AD<Base> - operation sequences. -Calling the routine -afun - will add the operator defined -by this macro to an -AD<Base> - operation sequence. - -
-
-ok -
-For all routines documented below, -the return value -ok - has prototype - -
-     bool 
ok
-
-If it is true, the corresponding evaluation succeeded, -otherwise it failed. - -
-
-id -
-For all routines documented below, -the argument -id - has prototype - -
-     size_t 
id
-
-Its value in all other calls is the same as in the corresponding -call to -afun -. -It can be used to store and retrieve extra information about -a specific call to -afun -. - -
-
-k -
-For all routines documented below, the argument -k - has prototype - -
-     size_t 
k
-
-The value -k - is the order of the Taylor coefficient that -we are evaluating (forward -) -or taking the derivative of (reverse -). - -
-
-n -
-For all routines documented below, -the argument -n - has prototype - -
-     size_t 
n
-
-It is the size of the vector -ax - in the corresponding call to - -afun(idaxay) -; i.e., -the dimension of the domain space for - -y -= -f -( -x -) - - -. - -
-
-m -
-For all routines documented below, the argument -m - has prototype - -
-     size_t 
m
-
-It is the size of the vector -ay - in the corresponding call to - -afun(idaxay) -; i.e., -the dimension of the range space for - -y -= -f -( -x -) - - -. - -
-
-tx -
-For all routines documented below, -the argument -tx - has prototype - -
-     const CppAD::vector<
Base>& tx
-
-and -tx.size() >= (k + 1) * n -. -For - -j -= -0 -, - -, -n --1 - - - and - - -= -0 -, - -, -k - - -, -we use the Taylor coefficient notation - - - -x -j - - - -= - -tx -[ -j -* -( -k -+ -1 -) -+ - -] - -X -j - -( -t -) - -= - -x -j -0 - -+ -x -j -1 - -t -1 - -+ - -+ -x -j -k - -t -k - - - - -If -tx.size() > (k + 1) * n -, -the other components of -tx - are not specified and should not be used. -Note that superscripts represent an index for - -x -j - - - - - -and an exponent for - -t - - - - -. -Also note that the Taylor coefficients for - -X -( -t -) - - - correspond -to the derivatives of - -X -( -t -) - - - at - -t -= -0 - - - in the following way: - - -x -j - - -= -1 - - -! - - -X -j -( - -) - - -( -0 -) - - -
-ty -
-In calls to forward -, -the argument -ty - has prototype - -
-     CppAD::vector<
Base>& ty
-
-while in calls to reverse - it has prototype - -
-     const CppAD::vector<
Base>& ty
-
-For all calls, -tx.size() >= (k + 1) * m -. -For - -i -= -0 -, - -, -m --1 - - - and - - -= -0 -, - -, -k - - -, -we use the Taylor coefficient notation - - - -y -i - - - -= - -ty -[ -i -* -( -k -+ -1 -) -+ - -] - -Y -i - -( -t -) - -= - -y -i -0 - -+ -y -i -1 - -t -1 - -+ - -+ -y -i -k - -t -k - -+ -o -( -t -k - -) - - - -where - -o -( -t -k - -) -/ -t -k - - -0 - - - as - -t - -0 - - -. -If -ty.size() > (k + 1) * m -, -the other components of -ty - are not specified and should not be used. -Note that superscripts represent an index for - -y -j - - - - - -and an exponent for - -t - - - - -. -Also note that the Taylor coefficients for - -Y -( -t -) - - - correspond -to the derivatives of - -Y -( -t -) - - - at - -t -= -0 - - - in the following way: - - -y -j - - -= -1 - - -! - - -Y -j -( - -) - - -( -0 -) - - -
-forward -
-In the case of -forward -, -for - -i -= -0 -, - -, -m --1 - - -, - -ty -[ -i -* -( -k -+ -1 -) -+ -k -] - - - is an output -and all the other components of -ty - are inputs. - -
-
-reverse -
-In the case of -reverse -, -all the components of -ty - are inputs. - -
-
-afun -
-The macro argument -afun -, -is the name of the AD function corresponding to this atomic -operation (as it is used in the source code). -CppAD uses the other functions, -where the arguments are vectors with elements of type -Base -, -to implement the function - -
-     
afun(idaxay)
-
-where the argument are vectors with elements of type -AD<Base> -. - -
-
-ax -
-The -afun - argument -ax - has prototype - -
-     const 
Tvector< AD<Base> >& ax
-
-It is the argument vector - -x - -B -n - - - - -at which the -AD<Base> - version of - - -y -= -f -( -x -) - - - is to be evaluated. -The dimension of the domain space for - -y -= -f -( -x -) - - - -is specified by n - -ax.size() -, -which must be greater than zero. - -
-
-ay -
-The -afun - result -ay - has prototype - -
-     
Tvector< AD<Base> >& ay
-
-The input values of its elements -are not specified (must not matter). -Upon return, it is the -AD<Base> - version of the -result vector - -y -= -f -( -x -) - - -. -The dimension of the range space for - -y -= -f -( -x -) - - - -is specified by m - -ay.size() -, -which must be greater than zero. - -
-
-Parallel Mode -
-The first call to - -
-     
afun(idaxay)
-
-must not be in parallel - mode. -In addition, the -old_atomic clear - -routine cannot be called while in parallel mode. - -
-
-forward -
-The macro argument -forward - is a -user defined function - -
-     
ok = forward(idknmvxvytxty)
-
-that computes results during a forward - mode sweep. -For this call, we are given the Taylor coefficients in -tx - -form order zero through -k -, -and the Taylor coefficients in -ty - with order less than -k -. -The -forward - routine computes the - -k - order Taylor coefficients for - -y - - - using the definition - - -Y -( -t -) -= -f -[ -X -( -t -) -] - - -. -For example, for - -i -= -0 -, - -, -m --1 - - -, - - - -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 -2 - - -= - -1 - -2 -! - - -Y -( -2 -) - - -( -0 -) - - -= - -1 - -2 - - -X -( -1 -) - - -( -0 -) -T - - -f -i -( -2 -) - - -( -x -0 - -) -X -( -1 -) - - -( -0 -) -+ -1 - -2 - - -f -i -( -1 -) - - -( -x -0 - -) -X -( -2 -) - - -( -0 -) - - -= - -1 - -2 - - -( -x -1 - -) -T - - -f -i -( -2 -) - - -( -x -0 - -) -x -1 - -+ -f -i -( -1 -) - - -( -x -0 - -) -x -2 - - - - -Then, for - -i -= -0 -, - -, -m --1 - - -, it sets - - -ty -[ -i -* -( -k -+ -1 -) -+ -k -] -= -y -i -k - - - -The other components of -ty - must be left unchanged. - -
-
-Usage -
-This routine is used, -with -vx.size() > 0 - and -k == 0 -, -by calls to -afun -. -It is used, -with -vx.size() = 0 - and - -k - equal to the order of the derivative begin computed, -by calls to forward -. - -
-
-vx -
-The -forward - argument -vx - has prototype - -
-     const CppAD::vector<bool>& 
vx
-
-The case -vx.size() > 0 - occurs -once for each call to -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 -the corresponding -id - -(such as the elements of -vx -). -If -vx.size() > 0 - then - -k == 0 -, - -vx.size() >= n -, and -for - -j -= -0 -, - -, -n --1 - - -, - -vx[j] - is true if and only if - -ax[j] - is a variable -. -
-
-
If -vx.size() == 0 -, -then -vy.size() == 0 - and neither of these vectors -should be used. - -
-
-vy -
-The -forward - argument -vy - has prototype - -
-     CppAD::vector<bool>& 
vy
-
-If -vy.size() == 0 -, it should not be used. -Otherwise, - -k == 0 - and -vy.size() >= m -. -The input values of the elements of -vy - -are not specified (must not matter). -Upon return, for - -j -= -0 -, - -, -m --1 - - -, - -vy[i] - is true if and only if - -ay[j] - is a variable. -(CppAD uses -vy - to reduce the necessary computations.) - -
-
-reverse -
-The macro argument -reverse - -is a user defined function - -
-     
ok = reverse(idknmtxtypxpy)
-
-that computes results during a reverse - mode sweep. -The input value of the vectors -tx - and -ty - -contain Taylor coefficient, up to order -k -, -for - -X -( -t -) - - - and - -Y -( -t -) - - - respectively. -We use the - -{ -x -j - - -} - - - and - -{ -y -i - - -} - - - -to denote these Taylor coefficients where the implicit range indices are - - -i -= -0 -, - -, -m --1 - - -, - - -j -= -0 -, - -, -n --1 - - -, - - - -= -0 -, - -, -k - - -. -Using the calculations done by forward -, -the Taylor coefficients - -{ -y -i - - -} - - - are a function of the Taylor -coefficients for - -{ -x -j - - -} - - -; i.e., given - -y -= -f -( -x -) - - - -we define the function - - -F -: -B -n -× -( -k -+ -1 -) - - - -B -m -× -( -k -+ -1 -) - - - - - by - - -y -i - - -= -F -i - - -( -{ -x -j - - -} -) - - -We use - -G -: -B -m -× -( -k -+ -1 -) - - - -B - - - -to denote an arbitrary scalar valued function of the Taylor coefficients for - - -Y -( -t -) - - - and write - -z -= -G -( -{ -y -i - - -} -) - - -. -The reverse routine -is given the derivative of - -z - - - with respect to - - -{ -y -i - - -} - - - and computes its derivative with respect -to - -{ -x -j - - -} - - -. - -
-
-Usage -
-This routine is used, -with -k + 1 - equal to the order of the derivative being calculated, -by calls to reverse -. - -
-
-py -
-The -reverse - argument -py - has prototype - -
-     const CppAD::vector<
Base>& py
-
-and -py.size() >= (k + 1) * m -. -For - -i -= -0 -, - -, -m --1 - - - and - - -= -0 -, - -, -k - - -, - - -py -[ -i -* -( -k -+ -1 -) -+ - -] -= - -G -/ - -y -i - - - - -If -py.size() > (k + 1) * m -, -the other components of -py - are not specified and should not be used. - -
-
-px -
-We define the function - - -H -( -{ -x -j - - -} -) -= -G -[ -F -( -{ -x -j - - -} -) -] - - -The -reverse - argument -px - has prototype - -
-     CppAD::vector<
Base>& px
-
-and -px.size() >= (k + 1) * n -. -The input values of the elements of -px - -are not specified (must not matter). -Upon return, -for - -j -= -0 -, - -, -n --1 - - - and - -p -= -0 -, - -, -k - - -, - - - -px -[ -j -* -( -k -+ -1 -) -+ -p -] - -= - - -H -/ - -x -j -p - - - -= - -( - -G -/ - -{ -y -i - - -} -) -( - -{ -y -i - - -} -/ - -x -j -p - -) - - -= - - -i -= -0 - -m --1 - - - - -= -0 - -k - -( - -G -/ - -y -i - - -) -( - -y -i - - -/ - -x -j -p - -) - - -= - - -i -= -0 - -m --1 - - - - -= -p - -k - -py -[ -i -* -( -k -+ -1 -) -+ - -] -( - -F -i - - -/ - -x -j -p - -) - - - -Note that we have used the fact that for - - -< -p - - -, - - - -F -i - - -/ - -x -j -p - -= -0 - - -. -If -px.size() > (k + 1) * n -, -the other components of -px - are not specified and should not be used. - -
-
-for_jac_sparse -
-The macro argument -for_jac_sparse - -is a user defined function - -
-     
ok = for_jac_sparse(idnmqrs)
-
-that is used to compute results during a forward Jacobian sparsity sweep. -For a fixed - -n -× -q - - - matrix - -R - - -, -the Jacobian of - -f -( -x -+ -R -* -u -) - - - with respect to - -u - -B -q - - - - is - - -S -( -x -) -= -f -( -1 -) - - -( -x -) -* -R - - -Given a sparsity pattern - for - -R - - -, - -for_jac_sparse - computes a sparsity pattern for - -S -( -x -) - - -. - -
-
-Usage -
-This routine is used by calls to ForSparseJac -. - -
-
-q -
-The -for_jac_sparse - argument -q - has prototype - -
-     size_t 
q
-
-It specifies the number of columns in - - -R - -B -n -× -q - - - - - and the Jacobian - - -S -( -x -) - -B -m -× -q - - - - -. - -
-
-r -
-The -for_jac_sparse - argument -r - has prototype - -
-     const CppAD::vector< std::set<size_t> >& 
r
-
-and -r.size() >= n -. -For - -j -= -0 -, - -, -n --1 - - -, -all the elements of -r[j] - are between -zero and -q-1 - inclusive. -This specifies a sparsity pattern for the matrix - -R - - -. - -
-
-s -
-The -for_jac_sparse - return value -s - has prototype - -
-     CppAD::vector< std::set<size_t> >& 
s
-
-and -s.size() >= m -. -The input values of its sets -are not specified (must not matter). Upon return -for - -i -= -0 -, - -, -m --1 - - -, -all the elements of -s[i] - are between -zero and -q-1 - inclusive. -This represents a sparsity pattern for the matrix - -S -( -x -) - - -. - -
-
-rev_jac_sparse -
-The macro argument -rev_jac_sparse - -is a user defined function - -
-     
ok = rev_jac_sparse(idnmqrs)
-
-that is used to compute results during a reverse Jacobian sparsity sweep. -For a fixed - -q -× -m - - - matrix - -S - - -, -the Jacobian of - -S -* -f -( -x -) - - - with respect to - -x - -B -n - - - - is - - -R -( -x -) -= -S -* -f -( -1 -) - - -( -x -) - - -Given a sparsity pattern - for - -S - - -, - -rev_jac_sparse - computes a sparsity pattern for - -R -( -x -) - - -. - -
-
-Usage -
-This routine is used by calls to RevSparseJac - -and to optimize -. - - -
-
-q -
-The -rev_jac_sparse - argument -q - has prototype - -
-     size_t 
q
-
-It specifies the number of rows in - - -S - -B -q -× -m - - - - - and the Jacobian - - -R -( -x -) - -B -q -× -n - - - - -. - -
-
-s -
-The -rev_jac_sparse - argument -s - has prototype - -
-     const CppAD::vector< std::set<size_t> >& 
s
-
-and -s.size() >= m -. -For - -i -= -0 -, - -, -m --1 - - -, -all the elements of -s[i] - -are between zero and -q-1 - inclusive. -This specifies a sparsity pattern for the matrix - -S -T - - - - -. - -
-
-r -
-The -rev_jac_sparse - return value -r - has prototype - -
-     CppAD::vector< std::set<size_t> >& 
r
-
-and -r.size() >= n -. -The input values of its sets -are not specified (must not matter). -Upon return for - -j -= -0 -, - -, -n --1 - - -, -all the elements of -r[j] - -are between zero and -q-1 - inclusive. -This represents a sparsity pattern for the matrix - -R -( -x -) -T - - - - -. - -
-
-rev_hes_sparse -
-The macro argument -rev_hes_sparse - -is a user defined function - -
-     
ok = rev_hes_sparse(idnmqrstuv)
-
-There is an unspecified scalar valued function - - -g -: -B -m - - -B - - -. -Given a sparsity pattern for - -R - - - -and information about the function - -z -= -g -( -y -) - - -, -this routine computes the sparsity pattern for - - -V -( -x -) -= -( -g - -f -) -( -2 -) - - -( -x -) -R - - -
-Usage -
-This routine is used by calls to RevSparseHes -. - -
-
-q -
-The -rev_hes_sparse - argument -q - has prototype - -
-     size_t 
q
-
-It specifies the number of columns in the sparsity patterns. - -
-
-r -
-The -rev_hes_sparse - argument -r - has prototype - -
-     const CppAD::vector< std::set<size_t> >& 
r
-
-and -r.size() >= n -. -For - -j -= -0 -, - -, -n --1 - - -, -all the elements of -r[j] - are between -zero and -q-1 - inclusive. -This specifies a sparsity pattern for the matrix - -R - -B -n -× -q - - - - -. - -
-
-s -
-The -rev_hes_sparse - argument -s - has prototype - -
-     const CppAD::vector<bool>& 
s
-
-and -s.size() >= m -. -This specifies a sparsity pattern for the matrix - - -S -( -x -) -= -g -( -1 -) - - -( -y -) - -B -1 -× -m - - - - -. - -
-
-t -
-The -rev_hes_sparse - argument -t - has prototype - -
-     CppAD::vector<bool>& 
t
-
-and -t.size() >= n -. -The input values of its elements -are not specified (must not matter). -Upon return it represents a sparsity pattern for the matrix - - -T -( -x -) - -B -1 -× -n - - - - - defined by - - -T -( -x -) -= -( -g - -f -) -( -1 -) - - -( -x -) -= -S -( -x -) -* -f -( -1 -) - - -( -x -) - - -
-u -
-The -rev_hes_sparse - argument -u - has prototype - -
-     const CppAD::vector< std::set<size_t> >& 
u
-
-and -u.size() >= m -. -For - -i -= -0 -, - -, -m --1 - - -, -all the elements of -u[i] - -are between zero and -q-1 - inclusive. -This specifies a sparsity pattern -for the matrix - -U -( -x -) - -B -m -× -q - - - - - defined by - - - -U -( -x -) - -= - - -u - -{ - -y - -g -[ -y -+ -f -( -1 -) - - -( -x -) -R -u -] -} -u -= -0 - - - - -= - - -u - -{ -g -( -1 -) - - -[ -y -+ -f -( -1 -) - - -( -x -) -R -u -] -} -u -= -0 - - - - -= - -g -( -2 -) - - -( -y -) -f -( -1 -) - - -( -x -) -R - - - -
-v -
-The -rev_hes_sparse - argument -v - has prototype - -
-     CppAD::vector< std::set<size_t> >& 
v
-
-and -v.size() >= n -. -The input values of its elements -are not specified (must not matter). -Upon return, for - -j -= -0 -, - -, -n --1 - - -, -all the elements of -v[j] - -are between zero and -q-1 - inclusive. -This represents a sparsity pattern for the matrix - - -V -( -x -) - -B -n -× -q - - - - - defined by - - - -V -( -x -) - -= - - -u - -[ - -x - -( -g - -f -) -( -x -+ -R -u -) -] -u -= -0 - - - - -= - - -u - -[ -( -g - -f -) -( -1 -) - - -( -x -+ -R -u -) -] -u -= -0 - - - - -= - -( -g - -f -) -( -2 -) - - -( -x -) -R - - -= - -f -( -1 -) - - -( -x -) -T - - -g -( -2 -) - - -( -y -) -f -( -1 -) - - -( -x -) -R -+ - -i -= -1 - -m - -[ -g -( -1 -) - - -( -y -) -] -i - - -f -i -( -2 -) - - -( -x -) -R - - -= - -f -( -1 -) - - -( -x -) -T - - -U -( -x -) -+ - -i -= -1 - -m - -S -( -x -) -i - - -f -i -( -2 -) - - -( -x -) -R - - - -
-clear -
-User atomic functions hold onto static work space in order to -increase speed by avoiding system memory allocation calls. -The function call -
-     user_atomic<
Base>::clear()
-
-makes to work space available - to -for other uses by the same thread. -This should be called when you are done using the -user atomic functions for a specific value of -Base -. - -
-
-Restriction -
-The user atomic clear routine cannot be called -while in parallel - execution mode. - - -
-
-Example - - -
-
-Simple -
-The file old_reciprocal.cpp - contains the simplest example and test -of a user atomic operation. - -
-
- -
-The examples -old_usead_1.cpp - and old_usead_2.cpp - -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. - -
-
-Tangent Function -
-The file old_tan.cpp - contains an example and test -implementation of the tangent function as a user atomic operation. - -
-
-Matrix Multiplication -
-The file old_mat_mul.cpp - contains an example and test -implementation of matrix multiplication a a user atomic operation. - - -
Input File: cppad/core/old_atomic.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_old_atomic_xml.js cppad-2019.02.00.0/doc/_old_atomic_xml.js --- cppad-2018.00.00.0/doc/_old_atomic_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_old_atomic_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'old_atomic.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', -'directory.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', -'autotools.xml' -]; -var list_down0 = [ -'old_reciprocal.cpp.xml', -'old_usead_1.cpp.xml', -'old_usead_2.cpp.xml', -'old_tan.cpp.xml', -'old_mat_mul.cpp.xml' -]; -var list_current0 = [ -'old_atomic.xml#Deprecated 2013-05-27', -'old_atomic.xml#Syntax Function', -'old_atomic.xml#Syntax Function.Use Function', -'old_atomic.xml#Syntax Function.Callback Routines', -'old_atomic.xml#Syntax Function.Free Static Memory', -'old_atomic.xml#Purpose', -'old_atomic.xml#Partial Implementation', -'old_atomic.xml#CPPAD_USER_ATOMIC', -'old_atomic.xml#CPPAD_USER_ATOMIC.Tvector', -'old_atomic.xml#CPPAD_USER_ATOMIC.Base', -'old_atomic.xml#ok', -'old_atomic.xml#id', -'old_atomic.xml#k', -'old_atomic.xml#n', -'old_atomic.xml#m', -'old_atomic.xml#tx', -'old_atomic.xml#ty', -'old_atomic.xml#ty.forward', -'old_atomic.xml#ty.reverse', -'old_atomic.xml#afun', -'old_atomic.xml#afun.ax', -'old_atomic.xml#afun.ay', -'old_atomic.xml#afun.Parallel Mode', -'old_atomic.xml#forward', -'old_atomic.xml#forward.Usage', -'old_atomic.xml#forward.vx', -'old_atomic.xml#forward.vy', -'old_atomic.xml#reverse', -'old_atomic.xml#reverse.Usage', -'old_atomic.xml#reverse.py', -'old_atomic.xml#reverse.px', -'old_atomic.xml#for_jac_sparse', -'old_atomic.xml#for_jac_sparse.Usage', -'old_atomic.xml#for_jac_sparse.q', -'old_atomic.xml#for_jac_sparse.r', -'old_atomic.xml#for_jac_sparse.s', -'old_atomic.xml#rev_jac_sparse', -'old_atomic.xml#rev_jac_sparse.Usage', -'old_atomic.xml#rev_jac_sparse.q', -'old_atomic.xml#rev_jac_sparse.s', -'old_atomic.xml#rev_jac_sparse.r', -'old_atomic.xml#rev_hes_sparse', -'old_atomic.xml#rev_hes_sparse.Usage', -'old_atomic.xml#rev_hes_sparse.q', -'old_atomic.xml#rev_hes_sparse.r', -'old_atomic.xml#rev_hes_sparse.s', -'old_atomic.xml#rev_hes_sparse.t', -'old_atomic.xml#rev_hes_sparse.u', -'old_atomic.xml#rev_hes_sparse.v', -'old_atomic.xml#clear', -'old_atomic.xml#clear.Restriction', -'old_atomic.xml#Example', -'old_atomic.xml#Example.Simple', -'old_atomic.xml#Example.Use AD', -'old_atomic.xml#Example.Tangent Function', -'old_atomic.xml#Example.Matrix Multiplication' -]; -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-2018.00.00.0/doc/old_mat_mul.cpp.xml cppad-2019.02.00.0/doc/old_mat_mul.cpp.xml --- cppad-2018.00.00.0/doc/old_mat_mul.cpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/old_mat_mul.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,356 +0,0 @@ - - - -Old Matrix Multiply as a User Atomic Operation: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Old Matrix Multiply as a User Atomic Operation: Example and Test
-
-Deprecated 2013-05-27 -
-This example has been deprecated; -use atomic_mat_mul.cpp - instead. - - -
-
-Include File -
-This routine uses the include file old_mat_mul.hpp -. - - -
# include <cppad/cppad.hpp>
-# 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<double> 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<double> > 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<double> version of matrix multiply
-     mat_mul(id, ax, ay);
-     //----------------------------------------------------------------------
-     // check AD<double>  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<double> 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<double> x( X.size() ), y(m);
-     for(j = 0; j <  X.size() ; j++)
-          x[j] = double(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<double> dx( X.size() ), dy(m);
-     for(j = 0; j <  X.size() ; j++)
-          dx[j] = double(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<double> 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<double> 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<size_t> > 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<size_t> > 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<double>::clear();
-     info_.clear();
-
-     return ok;
-}
-
-
Input File: example/deprecated/old_mat_mul.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_old_mat_mul.cpp_xml.js cppad-2019.02.00.0/doc/_old_mat_mul.cpp_xml.js --- cppad-2018.00.00.0/doc/_old_mat_mul.cpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_old_mat_mul.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'old_atomic.xml', -'old_mat_mul.cpp.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'old_reciprocal.cpp.xml', -'old_usead_1.cpp.xml', -'old_usead_2.cpp.xml', -'old_tan.cpp.xml', -'old_mat_mul.cpp.xml' -]; -var list_down0 = [ -'old_mat_mul.hpp.xml' -]; -var list_current0 = [ -'old_mat_mul.cpp.xml#Deprecated 2013-05-27', -'old_mat_mul.cpp.xml#Include File' -]; -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-2018.00.00.0/doc/old_mat_mul.hpp.xml cppad-2019.02.00.0/doc/old_mat_mul.hpp.xml --- cppad-2018.00.00.0/doc/old_mat_mul.hpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/old_mat_mul.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,483 +0,0 @@ - - - -Define Matrix Multiply as a User Atomic Operation - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -old_mat_mul.hpp - -

-
Define Matrix Multiply as a User Atomic Operation
-
-Syntax -
-This file is located in the example directory. -It can be copied to the current working directory and included -with the syntax - -
-     # include "old_mat_mul.hpp"
-
-
-Example -
-The file old_mat_mul.cpp - contains an example use of -old_mat_mul.hpp. -It returns true if it succeeds and false otherwise. - -
-
-Begin Source - -

-# include <cppad/cppad.hpp>      // Include CppAD definitions
-namespace {                      // Begin empty namespace
-     using CppAD::vector;        // Let vector denote CppAD::vector
-
-
-Extra Call Information - -
     // 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<bool>  vx;
-     };
-     vector<call_info> 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<bool>* 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_);
-     }
-
-Matrix Indexing - -
     // 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;
-     }
-
-One Matrix Multiply -
-Forward mode matrix multiply left times right and sum into result: -
     void multiply_and_sum(
-          size_t                order_left ,
-          size_t                order_right,
-          const vector<double>&         tx ,
-          vector<double>&               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;
-     }
-
-Reverse Partials One Order -
-Compute reverse mode partials for one order and sum into px: -
     void reverse_multiply(
-          size_t                order_left ,
-          size_t                order_right,
-          const vector<double>&         tx ,
-          const vector<double>&         ty ,
-          vector<double>&               px ,
-          const vector<double>&         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;
-     }
-
-Set Union - -

-     using CppAD::set_union;
-
-
-CppAD User Atomic Callback Functions - -
     // ----------------------------------------------------------------------
-     // forward mode routine called by CppAD
-     bool mat_mul_forward(
-          size_t                   id ,
-          size_t                    k ,
-          size_t                    n ,
-          size_t                    m ,
-          const vector<bool>&      vx ,
-          vector<bool>&            vy ,
-          const vector<double>&    tx ,
-          vector<double>&          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<double>&    tx ,
-          const vector<double>&    ty ,
-          vector<double>&          px ,
-          const vector<double>&    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<size_t> >&     r ,
-          vector< std::set<size_t> >&           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] )
-                         s[ij_result] = set_union(s[ij_result], r[im_left]);
-
-                         // s[ij_result] = union( s[ij_result], r[mj_right] )
-                         s[ij_result] = set_union(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<size_t> >&           r ,
-          const vector< std::set<size_t> >&     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] )
-                         r[im_left] = set_union(r[im_left], s[ij_result]);
-
-                         // r[mj_right] = union( r[mj_right], s[ij_result] )
-                         r[mj_right] = set_union(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<size_t> >&     r ,
-          const vector<bool>&                   s ,
-          vector<bool>&                         t ,
-          const vector< std::set<size_t> >&     u ,
-          vector< std::set<size_t> >&           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] )
-                         v[im_left] = set_union(v[im_left],  u[ij_result] );
-                         v[mj_right] = set_union(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] )
-                              v[im_left] = set_union(v[im_left], r[mj_right] );
-                              // v[mj_right] = union( v[mj_right], r[im_left] )
-                              v[mj_right] = set_union(v[mj_right], r[im_left] );
-                         }
-                    }
-               }
-          }
-          return true;
-     }
-
-Declare mat_mul Function -
-Declare the AD<double> routine -mat_mul(idaxay) - -and end empty namespace -(we could use any simple vector template class - -instead of CppAD::vector): -
     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
- -
Input File: example/deprecated/old_mat_mul.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_old_mat_mul.hpp_xml.js cppad-2019.02.00.0/doc/_old_mat_mul.hpp_xml.js --- cppad-2018.00.00.0/doc/_old_mat_mul.hpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_old_mat_mul.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'old_atomic.xml', -'old_mat_mul.cpp.xml', -'old_mat_mul.hpp.xml' -]; -var list_down3 = [ -'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', -'autotools.xml' -]; -var list_down2 = [ -'old_reciprocal.cpp.xml', -'old_usead_1.cpp.xml', -'old_usead_2.cpp.xml', -'old_tan.cpp.xml', -'old_mat_mul.cpp.xml' -]; -var list_down1 = [ -'old_mat_mul.hpp.xml' -]; -var list_current0 = [ -'old_mat_mul.hpp.xml#Syntax', -'old_mat_mul.hpp.xml#Example', -'old_mat_mul.hpp.xml#Begin Source', -'old_mat_mul.hpp.xml#Extra Call Information', -'old_mat_mul.hpp.xml#Matrix Indexing', -'old_mat_mul.hpp.xml#One Matrix Multiply', -'old_mat_mul.hpp.xml#Reverse Partials One Order', -'old_mat_mul.hpp.xml#Set Union', -'old_mat_mul.hpp.xml#CppAD User Atomic Callback Functions', -'old_mat_mul.hpp.xml#Declare mat_mul Function' -]; -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-2018.00.00.0/doc/old_max_num_threads.xml cppad-2019.02.00.0/doc/old_max_num_threads.xml --- cppad-2018.00.00.0/doc/old_max_num_threads.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/old_max_num_threads.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ - - - -Set Maximum Number of Threads for omp_alloc Allocator - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -old_max_num_threads - -

- - -
Set Maximum Number of Threads for omp_alloc Allocator
-
-Removed -
-This function has been removed from the CppAD API. -Use the function thread_alloc::parallel_setup - -in its place. - -
-
-Syntax - -
- -# include <cppad/utility/omp_alloc.hpp>
-
- -omp_alloc::max_num_threads(number) - - -
-
-Purpose -
-By default there is only one thread and all execution is in sequential mode -(not parallel -). - -
-
-number -
-The argument -number - has prototype - -
-     size_t 
number
-
-It must be greater than zero and specifies the maximum number of -OpenMP threads that will be active at one time. - -
-
-Restrictions -
-This function must be called before the program enters -parallel - execution mode. - - -
Input File: cppad/utility/omp_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_old_max_num_threads_xml.js cppad-2019.02.00.0/doc/_old_max_num_threads_xml.js --- cppad-2018.00.00.0/doc/_old_max_num_threads_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_old_max_num_threads_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'old_max_num_threads.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'old_max_num_threads.xml#Removed', -'old_max_num_threads.xml#Syntax', -'old_max_num_threads.xml#Purpose', -'old_max_num_threads.xml#number', -'old_max_num_threads.xml#Restrictions' -]; -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-2018.00.00.0/doc/old_reciprocal.cpp.xml cppad-2019.02.00.0/doc/old_reciprocal.cpp.xml --- cppad-2018.00.00.0/doc/old_reciprocal.cpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/old_reciprocal.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,489 +0,0 @@ - - - -Old Atomic Operation Reciprocal: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -old_reciprocal.cpp - -

- -
Old Atomic Operation Reciprocal: Example and Test
-
-Deprecated 2013-05-27 -
-This example has been deprecated; -see atomic_reciprocal.cpp - instead. - -
-
-Theory -
-The example below defines the user atomic function - - -f -: -R - -n - - -R - -m - - - - where - - -n -= -1 - - -, - -m -= -1 - - -, and - -f -( -x -) -= -1 -/ -x - - -. - - -
# include <cppad/cppad.hpp>
-
-namespace { // Begin empty namespace
-     using CppAD::vector;
-     // ----------------------------------------------------------------------
-     // a utility to compute the union of two sets.
-     using CppAD::set_union;
-
-     // ----------------------------------------------------------------------
-     // forward mode routine called by CppAD
-     bool reciprocal_forward(
-          size_t                   id ,
-          size_t                    k ,
-          size_t                    n ,
-          size_t                    m ,
-          const vector<bool>&      vx ,
-          vector<bool>&            vy ,
-          const vector<double>&    tx ,
-          vector<double>&          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<double>&    tx ,
-          const vector<double>&    ty ,
-          vector<double>&          px ,
-          const vector<double>&    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<size_t> >&     r ,
-          vector< std::set<size_t> >&           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<size_t> >&           r ,
-          const vector< std::set<size_t> >&     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<size_t> >&     r ,
-          const vector<bool>&                   s ,
-                vector<bool>&                   t ,
-          const vector< std::set<size_t> >&     u ,
-                vector< std::set<size_t> >&     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] )
-               v[0] = set_union(v[0], r[0] );
-
-
-          return true;
-     }
-     // ---------------------------------------------------------------------
-     // Declare the AD<double> 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<double>::epsilon();
-
-     // --------------------------------------------------------------------
-     // Create the function f(x)
-     //
-     // domain space vector
-     size_t n  = 1;
-     double  x0 = 0.5;
-     vector< AD<double> > ax(n);
-     ax[0]     = x0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     vector< AD<double> > ay(m);
-
-     // call user function and store reciprocal(x) in au[0]
-     vector< AD<double> > 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<double> 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<double> 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<double> 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<double>::clear();
-
-     return ok;
-}
-
-
Input File: example/deprecated/old_reciprocal.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_old_reciprocal.cpp_xml.js cppad-2019.02.00.0/doc/_old_reciprocal.cpp_xml.js --- cppad-2018.00.00.0/doc/_old_reciprocal.cpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_old_reciprocal.cpp_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', -'appendix.xml', -'deprecated.xml', -'old_atomic.xml', -'old_reciprocal.cpp.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'old_reciprocal.cpp.xml', -'old_usead_1.cpp.xml', -'old_usead_2.cpp.xml', -'old_tan.cpp.xml', -'old_mat_mul.cpp.xml' -]; -var list_current0 = [ -'old_reciprocal.cpp.xml#Deprecated 2013-05-27', -'old_reciprocal.cpp.xml#Theory' -]; -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-2018.00.00.0/doc/old_tan.cpp.xml cppad-2019.02.00.0/doc/old_tan.cpp.xml --- cppad-2018.00.00.0/doc/old_tan.cpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/old_tan.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,501 +0,0 @@ - - - -Old Tan and Tanh as User Atomic Operations: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -old_tan.cpp - -

-
Old Tan and Tanh as User Atomic Operations: Example and Test
-
-Deprecated 2013-05-27 -
-This example has not deprecated; -see atomic_tangent.cpp - instead. - -
-
-Theory -
-The code below uses the tan_forward - and tan_reverse - -to implement the tangent ( -id == 0 -) and hyperbolic tangent -( -id == 1 -) functions as user atomic operations. - - -
# include <cppad/cppad.hpp>
-
-namespace { // Begin empty namespace
-     using CppAD::vector;
-
-     // a utility to compute the union of two sets.
-     using CppAD::set_union;
-
-     // ----------------------------------------------------------------------
-     // forward mode routine called by CppAD
-     bool old_tan_forward(
-          size_t                   id ,
-          size_t                order ,
-          size_t                    n ,
-          size_t                    m ,
-          const vector<bool>&      vx ,
-          vector<bool>&           vzy ,
-          const vector<float>&     tx ,
-          vector<float>&          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] = float( tan( tx[0] ) );
-               else     tzy[0] = float( 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] * float(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<float>&     tx ,
-          const vector<float>&    tzy ,
-          vector<float>&           px ,
-          const vector<float>&    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<float> 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] * float(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] * float(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<size_t> >&     r ,
-          vector< std::set<size_t> >&           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<size_t> >&           r ,
-          const vector< std::set<size_t> >&     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]
-          r[0] = set_union(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<size_t> >&     r ,
-          const vector<bool>&                   s ,
-          vector<bool>&                         t ,
-          const vector< std::set<size_t> >&     u ,
-          vector< std::set<size_t> >&           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, ...
-          v[0] = set_union(u[0], u[1]);
-
-          // convert forward Jacobian sparsity to Hessian sparsity
-          // because tan and tanh are nonlinear
-          if( t[0] )
-               v[0] = set_union(v[0], r[0]);
-
-          return true;
-     }
-     // ---------------------------------------------------------------------
-     // Declare the AD<float> 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<float>::epsilon();
-
-     // domain space vector
-     size_t n  = 1;
-     float  x0 = 0.5;
-     CppAD::vector< AD<float> > 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<float> > af(m);
-
-     // temporary vector for old_tan computations
-     // (old_tan computes tan or tanh and its square)
-     CppAD::vector< AD<float> > 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<float> > one(1);
-     one[0] = 1.;
-     old_tan(id, one, az);
-     af[2] = az[0];
-
-     // create f: x -> f and stop tape recording
-     CppAD::ADFun<float> 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<float> 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<float> dx(n), df(m);
-     dx[0] = 1.;
-     df    = F.Forward(1, dx);
-
-     // compute derivative of tan - tanh using reverse mode
-     CppAD::vector<float> 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<float> ddx(n), ddf(m);
-     ddx[0] = 0.;
-     ddf    = F.Forward(2, ddx);
-
-     // compute second derivative of tan - tanh using reverse mode
-     CppAD::vector<float> 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<float>::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<float>::clear();
-
-     return ok;
-}
-
-
Input File: example/deprecated/old_tan.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_old_tan.cpp_xml.js cppad-2019.02.00.0/doc/_old_tan.cpp_xml.js --- cppad-2018.00.00.0/doc/_old_tan.cpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_old_tan.cpp_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', -'appendix.xml', -'deprecated.xml', -'old_atomic.xml', -'old_tan.cpp.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'old_reciprocal.cpp.xml', -'old_usead_1.cpp.xml', -'old_usead_2.cpp.xml', -'old_tan.cpp.xml', -'old_mat_mul.cpp.xml' -]; -var list_current0 = [ -'old_tan.cpp.xml#Deprecated 2013-05-27', -'old_tan.cpp.xml#Theory' -]; -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-2018.00.00.0/doc/old_usead_1.cpp.xml cppad-2019.02.00.0/doc/old_usead_1.cpp.xml --- cppad-2018.00.00.0/doc/old_usead_1.cpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/old_usead_1.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,459 +0,0 @@ - - - -Using AD to Compute Atomic Function Derivatives - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -old_usead_1.cpp - -

-
Using AD to Compute Atomic Function Derivatives
-
-Deprecated 2013-05-27 -
-This example has been deprecated because it is easier to use the -checkpoint - class instead. - -
-
-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 -size_var -, -and hence the required memory. - -
-
-Simple Case -
-This example is the same as 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 old_usead_2.cpp - for a more complete example. - - -
# include <cppad/cppad.hpp>
-
-namespace { // Begin empty namespace
-     using CppAD::AD;
-     using CppAD::ADFun;
-     using CppAD::vector;
-
-     // ----------------------------------------------------------------------
-     // function that computes reciprocal
-     ADFun<double>* r_ptr_;
-     void create_r(void)
-     {     vector< AD<double> > ax(1), ay(1);
-          ax[0]  = 1;
-          CppAD::Independent(ax);
-          ay[0]  = 1.0 / ax[0];
-          r_ptr_ = new ADFun<double>(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<bool>&      vx ,
-          vector<bool>&            vy ,
-          const vector<double>&    tx ,
-          vector<double>&          ty
-     )
-     {     assert( id == 0 );
-          assert( n == 1 );
-          assert( m == 1 );
-          assert( k == 0 || vx.size() == 0 );
-          bool ok = true;
-          vector<double> 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<double>&    tx ,
-          const vector<double>&    ty ,
-          vector<double>&          px ,
-          const vector<double>&    py
-     )
-     {     assert( id == 0 );
-          assert( n == 1 );
-          assert( m == 1 );
-          bool ok = true;
-          vector<double> 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<double> 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<size_t> >&     r ,
-          vector< std::set<size_t> >&           s )
-     {     assert( id == 0 );
-          assert( n == 1 );
-          assert( m == 1 );
-          bool ok = true;
-
-          vector< std::set<size_t> > 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<size_t> >&           r ,
-          const vector< std::set<size_t> >&     s )
-     {
-          assert( id == 0 );
-          assert( n == 1 );
-          assert( m == 1 );
-          bool ok = true;
-
-          vector< std::set<size_t> > 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<size_t> >&     r ,
-          const vector<bool>&                   s ,
-          vector<bool>&                         t ,
-          const vector< std::set<size_t> >&     u ,
-          vector< std::set<size_t> >&           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<bool> 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<bool> Ut(p), A(p);
-          size_t q;
-          for(q = 0; q < p; q++)
-               Ut[q] = false;
-          std::set<size_t>::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<bool> 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<double> 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<double>::epsilon();
-
-     // --------------------------------------------------------------------
-     // Create the ADFun<doulbe> r_
-     create_r();
-
-     // --------------------------------------------------------------------
-     // Create the function f(x)
-     //
-     // domain space vector
-     size_t n  = 1;
-     double  x0 = 0.5;
-     vector< AD<double> > ax(n);
-     ax[0]     = x0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     vector< AD<double> > ay(m);
-
-     // call user function and store reciprocal(x) in au[0]
-     vector< AD<double> > 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<double> 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<double> 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<double> 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<double>::clear();
-
-     return ok;
-}
-
-
Input File: example/deprecated/old_usead_1.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_old_usead_1.cpp_xml.js cppad-2019.02.00.0/doc/_old_usead_1.cpp_xml.js --- cppad-2018.00.00.0/doc/_old_usead_1.cpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_old_usead_1.cpp_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', -'appendix.xml', -'deprecated.xml', -'old_atomic.xml', -'old_usead_1.cpp.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'old_reciprocal.cpp.xml', -'old_usead_1.cpp.xml', -'old_usead_2.cpp.xml', -'old_tan.cpp.xml', -'old_mat_mul.cpp.xml' -]; -var list_current0 = [ -'old_usead_1.cpp.xml#Deprecated 2013-05-27', -'old_usead_1.cpp.xml#Purpose', -'old_usead_1.cpp.xml#Simple Case' -]; -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-2018.00.00.0/doc/old_usead_2.cpp.xml cppad-2019.02.00.0/doc/old_usead_2.cpp.xml --- cppad-2018.00.00.0/doc/old_usead_2.cpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/old_usead_2.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,579 +0,0 @@ - - - -Using AD to Compute Atomic Function Derivatives - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -old_usead_2.cpp - -

-
Using AD to Compute Atomic Function Derivatives
-
-Deprecated 2013-05-27 -
-This example has been deprecated because it is easier to use the -checkpoint - class instead. - -
-
-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 -size_var -, -and hence the required memory. - - -
# include <cppad/cppad.hpp>
-
-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<double>           &t,
-               const vector< AD<double> > &z,
-               vector< AD<double> >       &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<double>* r_ptr_;
-     void create_r(void)
-     {     size_t n = 3, m = 2;
-          vector< AD<double> > 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<double> ti = 0.0;   // t does not appear in ODE so does not matter
-          AD<double> 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<double>(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<bool>&      vx ,
-          vector<bool>&            vy ,
-          const vector<double>&    tx ,
-          vector<double>&          ty
-     )
-     {     assert( id == 0 );
-          assert( n == 3 );
-          assert( m == 2 );
-          assert( k == 0 || vx.size() == 0 );
-          bool ok = true;
-          vector<double> 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<size_t> > s(m), r(m);
-               for(i = 0; i < m; i++)
-                    s[i].insert(i);
-               r = r_ptr_->RevSparseJac(m, s);
-               std::set<size_t>::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<double>&    tx ,
-          const vector<double>&    ty ,
-          vector<double>&          px ,
-          const vector<double>&    py
-     )
-     {     assert( id == 0 );
-          assert( n == 3 );
-          assert( m == 2 );
-          bool ok = true;
-          vector<double> 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<double> 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<size_t> >&     r ,
-          vector< std::set<size_t> >&           s )
-     {     assert( id == 0 );
-          assert( n == 3 );
-          assert( m == 2 );
-          bool ok = true;
-
-          vector< std::set<size_t> > 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<size_t> >&           r ,
-          const vector< std::set<size_t> >&     s )
-     {
-          assert( id == 0 );
-          assert( n == 3 );
-          assert( m == 2 );
-          bool ok = true;
-
-          vector< std::set<size_t> > R(p), S(p);
-          std::set<size_t>::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<size_t> >&     r ,
-          const vector<bool>&                   s ,
-          vector<bool>&                         t ,
-          const vector< std::set<size_t> >&     u ,
-          vector< std::set<size_t> >&           v )
-     {     // Can just return false if not use RevSparseHes.
-          assert( id == 0 );
-          assert( n == 3 );
-          assert( m == 2 );
-          bool ok = true;
-          std::set<size_t>::const_iterator itr;
-
-          // compute sparsity pattern for T(x) = S(x) * f'(x)
-          vector< std::set<size_t> > 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<size_t> > 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<size_t> > 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<double> 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<double>::epsilon();
-
-     // --------------------------------------------------------------------
-     // Create the ADFun<doulbe> r_
-     create_r();
-
-     // --------------------------------------------------------------------
-     // domain and range space vectors
-     size_t n = 3, m = 2;
-     vector< AD<double> > 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<double> dt = au[2] / double(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<double> f;
-     f.Dependent(au, ay);
-
-     // --------------------------------------------------------------------
-     // Check forward mode results
-     //
-     // zero order forward
-     vector<double> 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<double> 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<double>::clear();
-
-     return ok;
-}
-
-
Input File: example/deprecated/old_usead_2.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_old_usead_2.cpp_xml.js cppad-2019.02.00.0/doc/_old_usead_2.cpp_xml.js --- cppad-2018.00.00.0/doc/_old_usead_2.cpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_old_usead_2.cpp_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', -'appendix.xml', -'deprecated.xml', -'old_atomic.xml', -'old_usead_2.cpp.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'old_reciprocal.cpp.xml', -'old_usead_1.cpp.xml', -'old_usead_2.cpp.xml', -'old_tan.cpp.xml', -'old_mat_mul.cpp.xml' -]; -var list_current0 = [ -'old_usead_2.cpp.xml#Deprecated 2013-05-27', -'old_usead_2.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-2018.00.00.0/doc/omp_alloc.cpp.xml cppad-2019.02.00.0/doc/omp_alloc.cpp.xml --- cppad-2018.00.00.0/doc/omp_alloc.cpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_alloc.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,282 +0,0 @@ - - - -OpenMP Memory Allocator: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_alloc.cpp - -

- - - -
OpenMP Memory Allocator: Example and Test
-
-Deprecated 2011-08-31 -
-This example is only intended to help convert calls to omp_alloc - -to calls to thread_alloc -. - - -
# include <cppad/utility/omp_alloc.hpp>
-# include <cppad/utility/memory_leak.hpp>
-# include <vector>
-
-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<void*> 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<size_t*>(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<my_char>(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<my_char>(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;
-}
-
-
-
-
Input File: example/deprecated/omp_alloc.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_alloc.cpp_xml.js cppad-2019.02.00.0/doc/_omp_alloc.cpp_xml.js --- cppad-2018.00.00.0/doc/_omp_alloc.cpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_alloc.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'omp_alloc.cpp.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_alloc.cpp.xml#Deprecated 2011-08-31' -]; -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-2018.00.00.0/doc/omp_alloc.xml cppad-2019.02.00.0/doc/omp_alloc.xml --- cppad-2018.00.00.0/doc/omp_alloc.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_alloc.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,173 +0,0 @@ - - - -A Quick OpenMP Memory Allocator Used by CppAD - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
A Quick OpenMP Memory Allocator Used by CppAD
-
-Syntax - -
-# include <cppad/omp_alloc.hpp>
- -
-
-Purpose -
-The C++ new and delete operators are thread safe, -but this means that a thread may have to wait for a lock on these operations. -Once memory is obtained for a thread, the omp_alloc memory -allocator keeps that memory 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. -The omp_free_available - function should be used to return memory -to the system (once it is no longer required by a thread). - -
-
-Include -
-The routines in sections below are defined by cppad/omp_alloc.hpp. -This file is included by -cppad/cppad.hpp, but it can also be included separately with out -the rest of the CppAD. - -
-
-Deprecated 2011-08-23 -
-Use thread_alloc - instead. - -
-
-Contents -
- -
omp_max_num_threadsSet and Get Maximum Number of Threads for omp_alloc Allocator
omp_in_parallelIs The Current Execution in OpenMP Parallel Mode
omp_get_thread_numGet the Current OpenMP Thread Number
omp_get_memoryGet At Least A Specified Amount of Memory
omp_return_memoryReturn Memory to omp_alloc
omp_free_availableFree Memory Currently Available for Quick Use by a Thread
omp_inuseAmount of Memory a Thread is Currently Using
omp_availableAmount of Memory Available for Quick Use by a Thread
omp_create_arrayAllocate Memory and Create A Raw Array
omp_delete_arrayReturn A Raw Array to The Available Memory for a Thread
omp_efficientCheck If A Memory Allocation is Efficient for Another Use
old_max_num_threadsSet Maximum Number of Threads for omp_alloc Allocator
omp_alloc.cppOpenMP Memory Allocator: Example and Test
-
Input File: omh/appendix/deprecated/omp_alloc.omh - - - diff -Nru cppad-2018.00.00.0/doc/_omp_alloc_xml.js cppad-2019.02.00.0/doc/_omp_alloc_xml.js --- cppad-2018.00.00.0/doc/_omp_alloc_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_alloc_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.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', -'directory.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', -'autotools.xml' -]; -var list_down0 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_alloc.xml#Syntax', -'omp_alloc.xml#Purpose', -'omp_alloc.xml#Include', -'omp_alloc.xml#Deprecated 2011-08-23', -'omp_alloc.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-2018.00.00.0/doc/omp_available.xml cppad-2019.02.00.0/doc/omp_available.xml --- cppad-2018.00.00.0/doc/omp_available.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_available.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,185 +0,0 @@ - - - -Amount of Memory Available for Quick Use by a Thread - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_available - -

- - - -
Amount of Memory Available for Quick Use by a Thread
-
-Deprecated 2011-08-31 -
-Use the function thread_alloc::available - instead. - -
-
-Syntax - -
- -# include <cppad/utility/omp_alloc.hpp>
-
- -num_bytes = omp_alloc::available(thread) - - -
-
-Purpose -
-Memory being managed by 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. - -
-
-thread -
-This argument has prototype - -
-     size_t 
thread
-
-Either omp_get_thread_num - must be the same as -thread -, -or the current execution mode must be sequential -(not parallel -). - -
-
-num_bytes -
-The return value has prototype - -
-     size_t 
num_bytes
-
-It is the number of bytes currently available for use by the specified thread. - -
-
-Example - -
-omp_alloc.cpp - - - -
Input File: cppad/utility/omp_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_available_xml.js cppad-2019.02.00.0/doc/_omp_available_xml.js --- cppad-2018.00.00.0/doc/_omp_available_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_available_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'omp_available.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_available.xml#Deprecated 2011-08-31', -'omp_available.xml#Syntax', -'omp_available.xml#Purpose', -'omp_available.xml#thread', -'omp_available.xml#num_bytes', -'omp_available.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-2018.00.00.0/doc/omp_create_array.xml cppad-2019.02.00.0/doc/omp_create_array.xml --- cppad-2018.00.00.0/doc/omp_create_array.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_create_array.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,245 +0,0 @@ - - - -Allocate Memory and Create A Raw Array - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_create_array - -

- - - -
Allocate Memory and Create A Raw Array
-
-Deprecated 2011-08-31 -
-Use the function thread_alloc::create_array - instead. - -
-
-Syntax - -
- -# include <cppad/utility/omp_alloc.hpp>
-
- -array = omp_alloc::create_array<Type>(size_minsize_out) -. - -
-
-Purpose -
-Create a new raw array using omp_alloc - a fast memory allocator -that works well in a multi-threading OpenMP environment. - -
-
-Type -
-The type of the elements of the array. - -
-
-size_min -
-This argument has prototype - -
-     size_t 
size_min
-
-This is the minimum number of elements that there can be -in the resulting -array -. - -
-
-size_out -
-This argument has prototype - -
-     size_t& 
size_out
-
-The input value of this argument does not matter. -Upon return, it is the actual number of elements -in -array - -( - size_min <= size_out -). - -
-
-array -
-The return value -array - has prototype - -
-     
Typearray
-
-It is array with -size_out - elements. -The default constructor for -Type - is used to initialize the -elements of -array -. -Note that omp_delete_array - -should be used to destroy the array when it is no longer needed. - -
-
-Delta -
-The amount of memory omp_inuse - by the current thread, -will increase -delta - where - -
-     sizeof(
Type) * (size_out + 1) > delta >= sizeof(Type) * size_out
-
-The omp_available - memory will decrease by -delta -, -(and the allocation will be faster) -if a previous allocation with -size_min - between its current value -and -size_out - is available. - -
-
-Example - -
-omp_alloc.cpp - - - -
Input File: cppad/utility/omp_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_create_array_xml.js cppad-2019.02.00.0/doc/_omp_create_array_xml.js --- cppad-2018.00.00.0/doc/_omp_create_array_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_create_array_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'omp_create_array.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_create_array.xml#Deprecated 2011-08-31', -'omp_create_array.xml#Syntax', -'omp_create_array.xml#Purpose', -'omp_create_array.xml#Type', -'omp_create_array.xml#size_min', -'omp_create_array.xml#size_out', -'omp_create_array.xml#array', -'omp_create_array.xml#Delta', -'omp_create_array.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-2018.00.00.0/doc/omp_delete_array.xml cppad-2019.02.00.0/doc/omp_delete_array.xml --- cppad-2018.00.00.0/doc/omp_delete_array.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_delete_array.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,213 +0,0 @@ - - - -Return A Raw Array to The Available Memory for a Thread - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_delete_array - -

- - - -
Return A Raw Array to The Available Memory for a Thread
-
-Deprecated 2011-08-31 -
-Use the function thread_alloc::delete_array - instead. - -
-
-Syntax - -
- -# include <cppad/utility/omp_alloc.hpp>
-
- -omp_alloc::delete_array(array) -. - -
-
-Purpose -
-Returns memory corresponding to a raw array -(create by omp_create_array -) to the -omp_available - memory pool for the current thread. - -
-
-Type -
-The type of the elements of the array. - -
-
-array -
-The argument -array - has prototype - -
-     
Typearray
-
-It is a value returned by omp_create_array - and not yet deleted. -The -Type - destructor is called for each element in the array. - -
-
-Thread -
-The current thread - must be the -same as when omp_create_array - returned the value -array -. -There is an exception to this rule: -when the current execution mode is sequential -(not parallel -) the current thread number does not matter. - -
-
-Delta -
-The amount of memory omp_inuse - will decrease by -delta -, -and the omp_available - memory will increase by -delta -, -where delta - -is the same as for the corresponding call to create_array. - -
-
-Example - -
-omp_alloc.cpp - - - -
Input File: cppad/utility/omp_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_delete_array_xml.js cppad-2019.02.00.0/doc/_omp_delete_array_xml.js --- cppad-2018.00.00.0/doc/_omp_delete_array_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_delete_array_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'omp_delete_array.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_delete_array.xml#Deprecated 2011-08-31', -'omp_delete_array.xml#Syntax', -'omp_delete_array.xml#Purpose', -'omp_delete_array.xml#Type', -'omp_delete_array.xml#array', -'omp_delete_array.xml#Thread', -'omp_delete_array.xml#Delta', -'omp_delete_array.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-2018.00.00.0/doc/omp_efficient.xml cppad-2019.02.00.0/doc/omp_efficient.xml --- cppad-2018.00.00.0/doc/omp_efficient.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_efficient.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,226 +0,0 @@ - - - -Check If A Memory Allocation is Efficient for Another Use - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_efficient - -

- - - -
Check If A Memory Allocation is Efficient for Another Use
-
-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. - -
-
-Syntax - -
- -# include <cppad/utility/omp_alloc.hpp>
-
- -flag = omp_alloc::efficient(v_ptrnum_bytes) - - -
-
-Purpose -
-Check if memory that is currently in use is an efficient -allocation for a specified number of bytes. - -
-
-v_ptr -
-This argument has prototype - -
-     const void* 
v_ptr
-
-. -It must be a pointer to memory that is currently in use; i.e. -obtained by a previous call to omp_get_memory - and not yet returned. - -
-
-num_bytes -
-This argument has prototype - -
-     size_t 
num_bytes
-
-It specifies the number of bytes of the memory allocated by -v_ptr - -that we want to use. - -
-
-flag -
-The return value has prototype - -
-     bool 
flag
-
-It is true, -a call to get_memory with -min_bytes - -equal to -num_bytes - would result in a value for -cap_bytes - that is the same as when v_ptr -was returned by get_memory; i.e., - -v_ptr - is an efficient memory block for -num_bytes - -bytes of information. - -
-
-Thread -
-Either the current thread - must be the same as during -the corresponding call to omp_get_memory -, -or the current execution mode must be sequential -(not parallel -). - -
-
-NDEBUG -
-If NDEBUG is defined, -v_ptr - is not checked (this is faster). -Otherwise, a list of in use pointers is searched to make sure -that -v_ptr - is in the list. - - -
Input File: cppad/utility/omp_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_efficient_xml.js cppad-2019.02.00.0/doc/_omp_efficient_xml.js --- cppad-2018.00.00.0/doc/_omp_efficient_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_efficient_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'omp_efficient.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_efficient.xml#Removed', -'omp_efficient.xml#Syntax', -'omp_efficient.xml#Purpose', -'omp_efficient.xml#v_ptr', -'omp_efficient.xml#num_bytes', -'omp_efficient.xml#flag', -'omp_efficient.xml#Thread', -'omp_efficient.xml#NDEBUG' -]; -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-2018.00.00.0/doc/omp_free_available.xml cppad-2019.02.00.0/doc/omp_free_available.xml --- cppad-2018.00.00.0/doc/omp_free_available.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_free_available.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ - - - -Free Memory Currently Available for Quick Use by a Thread - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_free_available - -

- - - -
Free Memory Currently Available for Quick Use by a Thread
-
-Deprecated 2011-08-31 -
-Use the function thread_alloc::free_available - -instead. - -
-
-Syntax - -
- -# include <cppad/utility/omp_alloc.hpp>
-
- -omp_alloc::free_available(thread) - - -
-
-Purpose -
-Free memory, currently available for quick use by a specific thread, -for general future use. - -
-
-thread -
-This argument has prototype - -
-     size_t 
thread
-
-Either omp_get_thread_num - must be the same as -thread -, -or the current execution mode must be sequential -(not parallel -). - -
-
-Example - -
-omp_alloc.cpp - - - -
Input File: cppad/utility/omp_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_free_available_xml.js cppad-2019.02.00.0/doc/_omp_free_available_xml.js --- cppad-2018.00.00.0/doc/_omp_free_available_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_free_available_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'omp_free_available.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_free_available.xml#Deprecated 2011-08-31', -'omp_free_available.xml#Syntax', -'omp_free_available.xml#Purpose', -'omp_free_available.xml#thread', -'omp_free_available.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-2018.00.00.0/doc/omp_get_memory.xml cppad-2019.02.00.0/doc/omp_get_memory.xml --- cppad-2018.00.00.0/doc/omp_get_memory.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_get_memory.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,221 +0,0 @@ - - - -Get At Least A Specified Amount of Memory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_get_memory - -

- - - -
Get At Least A Specified Amount of Memory
-
-Deprecated 2011-08-31 -
-Use the function thread_alloc::get_memory - instead. - -
-
-Syntax - -
- -# include <cppad/utility/omp_alloc.hpp>
-
- -v_ptr = omp_alloc::get_memory(min_bytescap_bytes) - - -
-
-Purpose -
-Use omp_alloc - to obtain a minimum number of bytes of memory -(for use by the current thread -). - -
-
-min_bytes -
-This argument has prototype - -
-     size_t 
min_bytes
-
-It specifies the minimum number of bytes to allocate. - -
-
-cap_bytes -
-This argument has prototype - -
-     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, - -
-     
min_bytes <= cap_bytes
-
-
-v_ptr -
-The return value -v_ptr - has prototype - -
-     void* 
v_ptr
-
-It is the location where the -cap_bytes - of memory -that have been allocated for use begins. - -
-
-Allocation Speed -
-This allocation should be faster if the following conditions hold: -
  1. -The memory allocated by a previous call to get_memory -is currently available for use. -
  2. - -The current -min_bytes - is between -the previous -min_bytes - and previous -cap_bytes -. -
- - -
-
-Example - -
-omp_alloc.cpp - - - -
Input File: cppad/utility/omp_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_get_memory_xml.js cppad-2019.02.00.0/doc/_omp_get_memory_xml.js --- cppad-2018.00.00.0/doc/_omp_get_memory_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_get_memory_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'omp_get_memory.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_get_memory.xml#Deprecated 2011-08-31', -'omp_get_memory.xml#Syntax', -'omp_get_memory.xml#Purpose', -'omp_get_memory.xml#min_bytes', -'omp_get_memory.xml#cap_bytes', -'omp_get_memory.xml#v_ptr', -'omp_get_memory.xml#Allocation Speed', -'omp_get_memory.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-2018.00.00.0/doc/omp_get_thread_num.xml cppad-2019.02.00.0/doc/omp_get_thread_num.xml --- cppad-2018.00.00.0/doc/omp_get_thread_num.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_get_thread_num.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ - - - -Get the Current OpenMP Thread Number - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_get_thread_num - -

- - - -
Get the Current OpenMP Thread Number
-
-Deprecated 2011-08-31 -
-Use the function thread_alloc::thread_num - instead. - -
-
-Syntax - -
- -# include <cppad/utility/omp_alloc.hpp>
-
- -thread = omp_alloc::get_thread_num() - - -
-
-Purpose -
-Some of the omp_alloc - allocation routines have a thread number. -This routine enables you to determine the current thread. - -
-
-thread -
-The return value -thread - has prototype - -
-     size_t 
thread
-
-and is the currently executing thread number. -If _OPENMP is not defined, -thread - is zero. - -
-
-Example - -
-omp_alloc.cpp - - - -
Input File: cppad/utility/omp_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_get_thread_num_xml.js cppad-2019.02.00.0/doc/_omp_get_thread_num_xml.js --- cppad-2018.00.00.0/doc/_omp_get_thread_num_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_get_thread_num_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'omp_get_thread_num.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_get_thread_num.xml#Deprecated 2011-08-31', -'omp_get_thread_num.xml#Syntax', -'omp_get_thread_num.xml#Purpose', -'omp_get_thread_num.xml#thread', -'omp_get_thread_num.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-2018.00.00.0/doc/omp_in_parallel.xml cppad-2019.02.00.0/doc/omp_in_parallel.xml --- cppad-2018.00.00.0/doc/omp_in_parallel.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_in_parallel.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ - - - -Is The Current Execution in OpenMP Parallel Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_in_parallel - -

- - -
Is The Current Execution in OpenMP Parallel Mode
-
-Deprecated 2011-08-31 -
-Use the function thread_alloc::in_parallel - instead. - -
-
-Syntax - -
- -# include <cppad/utility/omp_alloc.hpp>
-
- -flag = omp_alloc::in_parallel() - - -
-
-Purpose -
-Some of the 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. - -
-
-flag -
-The return value has prototype - -
-     bool 
flag
-
-It is true if the current execution is in parallel mode -(possibly multi-threaded) and false otherwise (sequential mode). - -
-
-Example - -
-omp_alloc.cpp - - - -
Input File: cppad/utility/omp_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_in_parallel_xml.js cppad-2019.02.00.0/doc/_omp_in_parallel_xml.js --- cppad-2018.00.00.0/doc/_omp_in_parallel_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_in_parallel_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'omp_in_parallel.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_in_parallel.xml#Deprecated 2011-08-31', -'omp_in_parallel.xml#Syntax', -'omp_in_parallel.xml#Purpose', -'omp_in_parallel.xml#flag', -'omp_in_parallel.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-2018.00.00.0/doc/omp_inuse.xml cppad-2019.02.00.0/doc/omp_inuse.xml --- cppad-2018.00.00.0/doc/omp_inuse.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_inuse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,185 +0,0 @@ - - - -Amount of Memory a Thread is Currently Using - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_inuse - -

- - - -
Amount of Memory a Thread is Currently Using
-
-Deprecated 2011-08-31 - - -
-
-Syntax - -
- -# include <cppad/utility/omp_alloc.hpp>
-
- -num_bytes = omp_alloc::inuse(thread) - -Use the function thread_alloc::inuse - instead. - -
-
-Purpose -
-Memory being managed by 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. - -
-
-thread -
-This argument has prototype - -
-     size_t 
thread
-
-Either omp_get_thread_num - must be the same as -thread -, -or the current execution mode must be sequential -(not parallel -). - -
-
-num_bytes -
-The return value has prototype - -
-     size_t 
num_bytes
-
-It is the number of bytes currently in use by the specified thread. - -
-
-Example - -
-omp_alloc.cpp - - - -
Input File: cppad/utility/omp_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_inuse_xml.js cppad-2019.02.00.0/doc/_omp_inuse_xml.js --- cppad-2018.00.00.0/doc/_omp_inuse_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_inuse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'omp_inuse.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_inuse.xml#Deprecated 2011-08-31', -'omp_inuse.xml#Syntax', -'omp_inuse.xml#Purpose', -'omp_inuse.xml#thread', -'omp_inuse.xml#num_bytes', -'omp_inuse.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-2018.00.00.0/doc/omp_max_num_threads.xml cppad-2019.02.00.0/doc/omp_max_num_threads.xml --- cppad-2018.00.00.0/doc/omp_max_num_threads.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_max_num_threads.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ - - - -Set and Get Maximum Number of Threads for omp_alloc Allocator - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_max_num_threads - -

-
Set and Get Maximum Number of Threads for omp_alloc Allocator
-
-Deprecated 2011-08-31 -
-Use the functions thread_alloc::parallel_setup - -and thread_alloc:num_threads - instead. - -
-
-Syntax - -
- -# include <cppad/utility/omp_alloc.hpp>
-
- -omp_alloc::set_max_num_threads(number)
-
- -number = omp_alloc::get_max_num_threads()
-
-
-Purpose -
-By default there is only one thread and all execution is in sequential mode -(not parallel -). - -
-
-number -
-The argument and return value -number - has prototype - -
-     size_t 
number
-
-and must be greater than zero. - -
-
-set_max_num_threads -
-Informs omp_alloc - of the maximum number of OpenMP threads. - -
-
-get_max_num_threads -
-Returns the valued used in the previous call to set_max_num_threads. -If there was no such previous call, the value one is returned -(and only thread number zero can use omp_alloc -). - -
-
-Restrictions -
-The function set_max_num_threads must be called before -the program enters parallel - execution mode. -In addition, this function cannot be called while in parallel mode. - - -
Input File: cppad/utility/omp_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_max_num_threads_xml.js cppad-2019.02.00.0/doc/_omp_max_num_threads_xml.js --- cppad-2018.00.00.0/doc/_omp_max_num_threads_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_max_num_threads_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'omp_max_num_threads.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_max_num_threads.xml#Deprecated 2011-08-31', -'omp_max_num_threads.xml#Syntax', -'omp_max_num_threads.xml#Purpose', -'omp_max_num_threads.xml#number', -'omp_max_num_threads.xml#set_max_num_threads', -'omp_max_num_threads.xml#get_max_num_threads', -'omp_max_num_threads.xml#Restrictions' -]; -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-2018.00.00.0/doc/omp_max_thread.xml cppad-2019.02.00.0/doc/omp_max_thread.xml --- cppad-2018.00.00.0/doc/omp_max_thread.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_max_thread.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,191 +0,0 @@ - - - -OpenMP Parallel Setup - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_max_thread - -

- - - -
OpenMP Parallel Setup
-
-Deprecated 2011-06-23 -
-Use thread_alloc::parallel_setup - -to set the number of threads. - -
-
-Syntax - -
- -AD<Base>::omp_max_thread(number)
-
-
-Purpose -
-By default, for each -AD<Base> - class there is only one -tape that records 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 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 - -AD<Base> - class and thread pair. - -
-
-number -
-The argument -number - has prototype - -
-     size_t 
number
-
-It must be greater than zero and specifies the maximum number of -OpenMp threads that will be active at one time. - - -
-
-Independent -
-Each call to Independent(x) - -creates a new active - tape. -All of the operations with the corresponding variables -must be preformed by the same OpenMP thread. -This includes the corresponding call to -f.Dependent(x,y) - or the -ADFun f(x, y) - -during which the tape stops recording and the variables -become parameters. - -
-
-Restriction -
-No tapes can be -active - when this function is called. - - -
Input File: cppad/core/omp_max_thread.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_max_thread_xml.js cppad-2019.02.00.0/doc/_omp_max_thread_xml.js --- cppad-2018.00.00.0/doc/_omp_max_thread_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_max_thread_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_max_thread.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', -'directory.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', -'autotools.xml' -]; -var list_current0 = [ -'omp_max_thread.xml#Deprecated 2011-06-23', -'omp_max_thread.xml#Syntax', -'omp_max_thread.xml#Purpose', -'omp_max_thread.xml#number', -'omp_max_thread.xml#Independent', -'omp_max_thread.xml#Restriction' -]; -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-2018.00.00.0/doc/omp_return_memory.xml cppad-2019.02.00.0/doc/omp_return_memory.xml --- cppad-2018.00.00.0/doc/omp_return_memory.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/omp_return_memory.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,197 +0,0 @@ - - - -Return Memory to omp_alloc - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -omp_return_memory - -

- - - -
Return Memory to omp_alloc
-
-Deprecated 2011-08-31 -
-Use the function thread_alloc::return_memory - instead. - -
-
-Syntax - -
- -# include <cppad/utility/omp_alloc.hpp>
-
- -omp_alloc::return_memory(v_ptr) - - -
-
-Purpose -
-If omp_max_num_threads - is one, -the memory is returned to the system. -Otherwise, the memory is retained by omp_alloc - for quick future use -by the thread that allocated to memory. - -
-
-v_ptr -
-This argument has prototype - -
-     void* 
v_ptr
-
-. -It must be a pointer to memory that is currently in use; i.e. -obtained by a previous call to omp_get_memory - and not yet returned. - -
-
-Thread -
-Either the current thread - must be the same as during -the corresponding call to omp_get_memory -, -or the current execution mode must be sequential -(not parallel -). - -
-
-NDEBUG -
-If NDEBUG is defined, -v_ptr - is not checked (this is faster). -Otherwise, a list of in use pointers is searched to make sure -that -v_ptr - is in the list. - -
-
-Example - -
-omp_alloc.cpp - - - -
Input File: cppad/utility/omp_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_omp_return_memory_xml.js cppad-2019.02.00.0/doc/_omp_return_memory_xml.js --- cppad-2018.00.00.0/doc/_omp_return_memory_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_omp_return_memory_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'omp_alloc.xml', -'omp_return_memory.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'omp_max_num_threads.xml', -'omp_in_parallel.xml', -'omp_get_thread_num.xml', -'omp_get_memory.xml', -'omp_return_memory.xml', -'omp_free_available.xml', -'omp_inuse.xml', -'omp_available.xml', -'omp_create_array.xml', -'omp_delete_array.xml', -'omp_efficient.xml', -'old_max_num_threads.xml', -'omp_alloc.cpp.xml' -]; -var list_current0 = [ -'omp_return_memory.xml#Deprecated 2011-08-31', -'omp_return_memory.xml#Syntax', -'omp_return_memory.xml#Purpose', -'omp_return_memory.xml#v_ptr', -'omp_return_memory.xml#Thread', -'omp_return_memory.xml#NDEBUG', -'omp_return_memory.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]; -} Binary files /tmp/tmpTwBTkM/UyeeZ_oWm3/cppad-2018.00.00.0/doc/_openblue.gif and /tmp/tmpTwBTkM/C6x_sNH1xf/cppad-2019.02.00.0/doc/_openblue.gif differ Binary files /tmp/tmpTwBTkM/UyeeZ_oWm3/cppad-2018.00.00.0/doc/_open.gif and /tmp/tmpTwBTkM/C6x_sNH1xf/cppad-2019.02.00.0/doc/_open.gif differ diff -Nru cppad-2018.00.00.0/doc/optimize_compare_op.cpp.xml cppad-2019.02.00.0/doc/optimize_compare_op.cpp.xml --- cppad-2018.00.00.0/doc/optimize_compare_op.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/optimize_compare_op.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,222 +0,0 @@ - - - -Example Optimization and Comparison Operators - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -optimize_compare_op.cpp - -

-
Example Optimization and Comparison Operators
-
-See Also - -
-cond_exp.cpp - - - -
# include <cppad/cppad.hpp>
-namespace {
-     struct tape_size { size_t n_var; size_t n_op; };
-
-     template <class Vector> void fun(
-          const std::string& options ,
-          const Vector& x, Vector& y, tape_size& before, tape_size& after
-     )
-     {     typedef typename Vector::value_type scalar;
-
-          // phantom variable with index 0 and independent variables
-          // begin operator, independent variable operators and end operator
-          before.n_var = 1 + x.size(); before.n_op  = 2 + x.size();
-          after.n_var  = 1 + x.size(); after.n_op   = 2 + x.size();
-
-          // Create a variable that is is only used in the comparision operation
-          // It is not used when the comparison operator is not included
-          scalar one = 1. / x[0];
-          before.n_var += 1; before.n_op += 1;
-          after.n_var  += 0; after.n_op  += 0;
-          // If we keep comparision operators, we must compute their operands
-          if( options.find("no_compare_op") == std::string::npos )
-          {     after.n_var += 1;  after.n_op += 1;
-          }
-
-          // Create a variable that is used by the result
-          scalar two = x[0] * 5.;
-          before.n_var += 1; before.n_op += 1;
-          after.n_var  += 1; after.n_op += 1;
-
-          // Only one variable created for this comparison operation
-          // but the value depends on which branch is taken.
-          scalar three;
-          if( one < x[0] )        // comparison operator
-               three = two / 2.0;  // division operator
-          else
-               three = 2.0 * two;  // multiplication operator
-          // comparison and either division of multiplication operator
-          before.n_var += 1; before.n_op += 2;
-          // comparison operator depends on optimization options
-          after.n_var += 1;  after.n_op += 1;
-          // check if we are keeping the comparison operator
-          if( options.find("no_compare_op") == std::string::npos )
-               after.n_op += 1;
-
-          // results for this operation sequence
-          y[0] = three;
-          before.n_var += 0; before.n_op  += 0;
-          after.n_var  += 0; after.n_op   += 0;
-     }
-}
-
-bool compare_op(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps10 = 10.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n  = 1;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.5;
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-
-     for(size_t k = 0; k < 2; k++)
-     {     // optimization options
-          std::string options = "";
-          if( k == 0 )
-               options = "no_compare_op";
-
-          // declare independent variables and start tape recording
-          CppAD::Independent(ax);
-
-          // compute function value
-          tape_size before, after;
-          fun(options, ax, ay, before, after);
-
-          // create f: x -> y and stop tape recording
-          CppAD::ADFun<double> f(ax, ay);
-          ok &= f.size_var() == before.n_var;
-          ok &= f.size_op() == before.n_op;
-
-          // Optimize the operation sequence
-          f.optimize(options);
-          ok &= f.size_var() == after.n_var;
-          ok &= f.size_op() == after.n_op;
-
-          // 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);
-          if ( options == "" )
-               ok  &= f.compare_change_number() == 0;
-          fun(options, x, check, before, after);
-          ok &= NearEqual(y[0], check[0], eps10, eps10);
-
-          // Check case where result of the comparision is differnent
-          // (hence one needs to re-tape to get correct result)
-          x[0] = 2.0;
-          y    = f.Forward(0, x);
-          if ( options == "" )
-               ok  &= f.compare_change_number() == 1;
-          fun(options, x, check, before, after);
-          ok  &= std::fabs(y[0] - check[0]) > 0.5;
-     }
-     return ok;
-}
-
-
-
Input File: example/optimize/compare_op.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_optimize_compare_op.cpp_xml.js cppad-2019.02.00.0/doc/_optimize_compare_op.cpp_xml.js --- cppad-2018.00.00.0/doc/_optimize_compare_op.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_optimize_compare_op.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'optimize.xml', -'optimize_compare_op.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'optimize_forward_active.cpp.xml', -'optimize_reverse_active.cpp.xml', -'optimize_compare_op.cpp.xml', -'optimize_print_for.cpp.xml', -'optimize_conditional_skip.cpp.xml', -'optimize_nest_conditional.cpp.xml', -'optimize_cumulative_sum.cpp.xml' -]; -var list_current0 = [ -'optimize_compare_op.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-2018.00.00.0/doc/optimize_conditional_skip.cpp.xml cppad-2019.02.00.0/doc/optimize_conditional_skip.cpp.xml --- cppad-2018.00.00.0/doc/optimize_conditional_skip.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/optimize_conditional_skip.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,231 +0,0 @@ - - - -Example Optimization and Conditional Expressions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -optimize_conditional_skip.cpp - -

-
Example Optimization and Conditional Expressions
-
-See Also - -
-cond_exp.cpp - - - -
# include <cppad/cppad.hpp>
-namespace {
-     struct tape_size { size_t n_var; size_t n_op; };
-
-     template <class Vector> void fun(
-          const std::string& options ,
-          const Vector& x, Vector& y, tape_size& before, tape_size& after
-     )
-     {     typedef typename Vector::value_type scalar;
-
-
-          // phantom variable with index 0 and independent variables
-          // begin operator, independent variable operators and end operator
-          before.n_var = 1 + x.size(); before.n_op  = 2 + x.size();
-          after.n_var  = 1 + x.size(); after.n_op   = 2 + x.size();
-
-          // Create a variable that is is only used as left operand
-          // in the comparision operation
-          scalar left = 1. / x[0];
-          before.n_var += 1; before.n_op += 1;
-          after.n_var  += 1; after.n_op  += 1;
-
-          // right operand in comparison operation
-          scalar right  = x[0];
-          before.n_var += 0; before.n_op  += 0;
-          after.n_var  += 0; after.n_op   += 0;
-
-          // Note that the left and right operand in the CondExpLt comparison
-          // are determined at this point. Hence the conditional skip operator
-          // will be inserted here so that the operations mentioned below can
-          // also be skipped during zero order foward mode.
-          if( options.find("no_conditional_skip") == std::string::npos )
-               after.n_op += 1; // for conditional skip operation
-
-          // Create a variable that is only used when comparison result is true
-          // (can be skipped when the comparison result is false)
-          scalar if_true = x[0] * 5.0;
-          before.n_var += 1; before.n_op += 1;
-          after.n_var  += 1; after.n_op  += 1;
-
-          // Create two variables only used when the comparison result is false
-          // (can be skipped when the comparison result is true)
-          scalar temp      = 5.0 + x[0];
-          scalar if_false  = temp * 3.0;
-          before.n_var += 2; before.n_op += 2;
-          after.n_var  += 2; after.n_op  += 2;
-
-          // conditional comparision is 1 / x[0] < x[0]
-          scalar value = CppAD::CondExpLt(left, right, if_true, if_false);
-          before.n_var += 1; before.n_op += 1;
-          after.n_var  += 1; after.n_op  += 1;
-
-          // results for this operation sequence
-          y[0] = value;
-          before.n_var += 0; before.n_op  += 0;
-          after.n_var  += 0; after.n_op   += 0;
-     }
-}
-
-bool conditional_skip(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps10 = 10.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n  = 1;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.5;
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-
-     for(size_t k = 0; k < 2; k++)
-     {     // optimization options
-          std::string options = "";
-          if( k == 0 )
-               options = "no_conditional_skip";
-
-          // declare independent variables and start tape recording
-          CppAD::Independent(ax);
-
-          // compute function computation
-          tape_size before, after;
-          fun(options, ax, ay, before, after);
-
-          // create f: x -> y and stop tape recording
-          CppAD::ADFun<double> f(ax, ay);
-          ok &= f.size_var() == before.n_var;
-          ok &= f.size_op()  == before.n_op;
-
-          // Optimize the operation sequence
-          f.optimize(options);
-          ok &= f.size_var() == after.n_var;
-          ok &= f.size_op()  == after.n_op;
-
-          // Check case where result of the comparison is true (x[0] > 1.0).
-          CPPAD_TESTVECTOR(double) x(n), y(m), check(m);
-          x[0] = 1.75;
-          y    = f.Forward(0, x);
-          fun(options, x, check, before, after);
-          ok &= NearEqual(y[0], check[0], eps10, eps10);
-          if( options == "" )
-               ok  &= f.number_skip() == 2;
-          else
-               ok &= f.number_skip() == 0;
-
-          // Check case where result of the comparision is false (x[0] <= 1.0)
-          x[0] = 0.5;
-          y    = f.Forward(0, x);
-          fun(options, x, check, before, after);
-          ok &= NearEqual(y[0], check[0], eps10, eps10);
-          if( options == "" )
-               ok  &= f.number_skip() == 1;
-          else
-               ok &= f.number_skip() == 0;
-     }
-     return ok;
-}
-
-
-
Input File: example/optimize/conditional_skip.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_optimize_conditional_skip.cpp_xml.js cppad-2019.02.00.0/doc/_optimize_conditional_skip.cpp_xml.js --- cppad-2018.00.00.0/doc/_optimize_conditional_skip.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_optimize_conditional_skip.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'optimize.xml', -'optimize_conditional_skip.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'optimize_forward_active.cpp.xml', -'optimize_reverse_active.cpp.xml', -'optimize_compare_op.cpp.xml', -'optimize_print_for.cpp.xml', -'optimize_conditional_skip.cpp.xml', -'optimize_nest_conditional.cpp.xml', -'optimize_cumulative_sum.cpp.xml' -]; -var list_current0 = [ -'optimize_conditional_skip.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-2018.00.00.0/doc/optimize_cumulative_sum.cpp.xml cppad-2019.02.00.0/doc/optimize_cumulative_sum.cpp.xml --- cppad-2018.00.00.0/doc/optimize_cumulative_sum.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/optimize_cumulative_sum.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ - - - -Example Optimization and Cumulative Sum Operations - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -optimize_cumulative_sum.cppHeadings

-
Example Optimization and Cumulative Sum Operations
-
# include <cppad/cppad.hpp>
-
-namespace {
-     struct tape_size { size_t n_var; size_t n_op; };
-
-     template <class Vector> void fun(
-          const Vector& x, Vector& y, tape_size& before, tape_size& after
-     )
-     {     typedef typename Vector::value_type scalar;
-
-          // phantom variable with index 0 and independent variables
-          // begin operator, independent variable operators and end operator
-          before.n_var = 1 + x.size(); before.n_op  = 2 + x.size();
-          after.n_var  = 1 + x.size(); after.n_op   = 2 + x.size();
-
-          // operators that are identical, and that will be made part of the
-          // cummulative summation. Make sure do not replace second variable
-          // using the first and then remove the first as part of the
-          // cumulative summation.
-          scalar first  = x[0] + x[1];
-          scalar second = x[0] + x[1];
-          before.n_var += 2; before.n_op  += 2;
-          after.n_var  += 0; after.n_op   += 0;
-
-          // test that subtractions are also included in cumulative summations
-          scalar third = x[1] - 2.0;
-          before.n_var += 1; before.n_op  += 1;
-          after.n_var  += 0; after.n_op   += 0;
-
-          // the finial summation is converted to a cumulative summation
-          // the other is removed.
-          scalar csum = first + second + third;
-          before.n_var += 2; before.n_op  += 2;
-          after.n_var  += 1; after.n_op   += 1;
-
-          // results for this operation sequence
-          y[0] = csum;
-          before.n_var += 0; before.n_op  += 0;
-          after.n_var  += 0; after.n_op   += 0;
-     }
-}
-bool cumulative_sum(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps10 = 10.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n  = 2;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.5;
-     ax[1] = 1.5;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     tape_size before, after;
-     fun(ax, ay, before, after);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-     ok &= f.size_var() == before.n_var;
-     ok &= f.size_op()  == before.n_op;
-
-     // Optimize the operation sequence
-     f.optimize();
-     ok &= f.size_var() == after.n_var;
-     ok &= f.size_op()  == after.n_op;
-
-     // Check result for a zero order calculation for a different x,
-     CPPAD_TESTVECTOR(double) x(n), y(m), check(m);
-     x[0] = 0.75;
-     x[1] = 2.25;
-     y    = f.Forward(0, x);
-     fun(x, check, before, after);
-     ok  &= CppAD::NearEqual(y[0], check[0], eps10, eps10);
-
-     return ok;
-}
-
-
Input File: example/optimize/cumulative_sum.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_optimize_cumulative_sum.cpp_xml.js cppad-2019.02.00.0/doc/_optimize_cumulative_sum.cpp_xml.js --- cppad-2018.00.00.0/doc/_optimize_cumulative_sum.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_optimize_cumulative_sum.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'optimize.xml', -'optimize_cumulative_sum.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'optimize_forward_active.cpp.xml', -'optimize_reverse_active.cpp.xml', -'optimize_compare_op.cpp.xml', -'optimize_print_for.cpp.xml', -'optimize_conditional_skip.cpp.xml', -'optimize_nest_conditional.cpp.xml', -'optimize_cumulative_sum.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-2018.00.00.0/doc/optimize_forward_active.cpp.xml cppad-2019.02.00.0/doc/optimize_forward_active.cpp.xml --- cppad-2018.00.00.0/doc/optimize_forward_active.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/optimize_forward_active.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,211 +0,0 @@ - - - -Example Optimization and Forward Activity Analysis - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -optimize_forward_active.cppHeadings

- - -
Example Optimization and Forward Activity Analysis
-
# include <cppad/cppad.hpp>
-namespace {
-     struct tape_size { size_t n_var; size_t n_op; };
-
-     template <class Vector> void fun(
-          const Vector& x, Vector& y, tape_size& before, tape_size& after
-     )
-     {     typedef typename Vector::value_type scalar;
-
-          // phantom variable with index 0 and independent variables
-          // begin operator, independent variable operators and end operator
-          before.n_var = 1 + x.size(); before.n_op  = 2 + x.size();
-          after.n_var  = 1 + x.size(); after.n_op   = 2 + x.size();
-
-          // adding the constant zero does not take any operations
-          scalar zero   = 0.0 + x[0];
-          before.n_var += 0; before.n_op  += 0;
-          after.n_var  += 0; after.n_op   += 0;
-
-          // multiplication by the constant one does not take any operations
-          scalar one    = 1.0 * x[1];
-          before.n_var += 0; before.n_op  += 0;
-          after.n_var  += 0; after.n_op   += 0;
-
-          // multiplication by the constant zero does not take any operations
-          // and results in the constant zero.
-          scalar two    = 0.0 * x[0];
-
-          // operations that only involve constants do not take any operations
-          scalar three  = (1.0 + two) * 3.0;
-          before.n_var += 0; before.n_op  += 0;
-          after.n_var  += 0; after.n_op   += 0;
-
-          // The optimizer will reconize that zero + one = one + zero
-          // for all values of x.
-          scalar four   = zero + one;
-          scalar five   = one  + zero;
-          before.n_var += 2; before.n_op  += 2;
-          after.n_var  += 1; after.n_op   += 1;
-
-          // The optimizer will reconize that sin(x[3]) = sin(x[3])
-          // for all values of x. Note that, for computation of derivatives,
-          // sin(x[3]) and cos(x[3]) are stored on the tape as a pair.
-          scalar six    = sin(x[2]);
-          scalar seven  = sin(x[2]);
-          before.n_var += 4; before.n_op  += 2;
-          after.n_var  += 2; after.n_op   += 1;
-
-          // If we used addition here, five + seven = zero + one + seven
-          // which would get converted to a cumulative summation operator.
-          scalar eight = five * seven;
-          before.n_var += 1; before.n_op  += 1;
-          after.n_var  += 1; after.n_op   += 1;
-
-          // Use two, three, four and six in order to avoid a compiler warning
-          // Note that addition of two and three does not take any operations.
-          // Also note that optimizer reconizes four * six == five * seven.
-          scalar nine  = eight + four * six * (two + three);
-          before.n_var += 3; before.n_op  += 3;
-          after.n_var  += 2; after.n_op   += 2;
-
-          // results for this operation sequence
-          y[0] = nine;
-          before.n_var += 0; before.n_op  += 0;
-          after.n_var  += 0; after.n_op   += 0;
-     }
-}
-
-bool forward_active(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps10 = 10.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n  = 3;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.5;
-     ax[1] = 1.5;
-     ax[2] = 2.0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     tape_size before, after;
-     fun(ax, ay, before, after);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-     ok &= f.size_var() == before.n_var;
-     ok &= f.size_op()  == before.n_op;
-
-     // Optimize the operation sequence
-     // Note that, for this case, all the optimization was done during
-     // the recording and there is no benifit to the optimization.
-     f.optimize();
-     ok &= f.size_var() == after.n_var;
-     ok &= f.size_op()  == after.n_op;
-
-     // check zero order forward with different argument value
-     CPPAD_TESTVECTOR(double) x(n), y(m), check(m);
-     for(size_t i = 0; i < n; i++)
-          x[i] = double(i + 2);
-     y    = f.Forward(0, x);
-     fun(x, check, before, after);
-     ok &= NearEqual(y[0], check[0], eps10, eps10);
-
-     return ok;
-}
-
-
Input File: example/optimize/forward_active.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_optimize_forward_active.cpp_xml.js cppad-2019.02.00.0/doc/_optimize_forward_active.cpp_xml.js --- cppad-2018.00.00.0/doc/_optimize_forward_active.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_optimize_forward_active.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'optimize.xml', -'optimize_forward_active.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'optimize_forward_active.cpp.xml', -'optimize_reverse_active.cpp.xml', -'optimize_compare_op.cpp.xml', -'optimize_print_for.cpp.xml', -'optimize_conditional_skip.cpp.xml', -'optimize_nest_conditional.cpp.xml', -'optimize_cumulative_sum.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-2018.00.00.0/doc/optimize_nest_conditional.cpp.xml cppad-2019.02.00.0/doc/optimize_nest_conditional.cpp.xml --- cppad-2018.00.00.0/doc/optimize_nest_conditional.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/optimize_nest_conditional.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,263 +0,0 @@ - - - -Example Optimization and Nested Conditional Expressions - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -optimize_nest_conditional.cpp - -

-
Example Optimization and Nested Conditional Expressions
-
-See Also - -
-cond_exp.cpp - - - -
# include <cppad/cppad.hpp>
-namespace {
-     struct tape_size { size_t n_var; size_t n_op; };
-
-     template <class Vector> void fun(
-          const std::string& options ,
-          const Vector& x, Vector& y, tape_size& before, tape_size& after
-     )
-     {     typedef typename Vector::value_type scalar;
-
-          // phantom variable with index 0 and independent variables
-          // begin operator, independent variable operators and end operator
-          before.n_var = 1 + x.size(); before.n_op  = 2 + x.size();
-          after.n_var  = 1 + x.size(); after.n_op   = 2 + x.size();
-
-          // Create a variable that is is only used in the second comparision
-          scalar two = 1. + x[0];
-          before.n_var += 1; before.n_op += 1;
-          after.n_var  += 1; after.n_op  += 1;
-
-          // Conditional skip for second comparison will be inserted here.
-          if( options.find("no_conditional_skip") == std::string::npos )
-               after.n_op += 1; // for conditional skip operation
-
-          // Create a variable that is is only used in the first comparision
-          // (can be skipped when second comparison result is false)
-          scalar one = 1. / x[0];
-          before.n_var += 1; before.n_op += 1;
-          after.n_var  += 1; after.n_op  += 1;
-
-          // Conditional skip for first comparison will be inserted here.
-          if( options.find("no_conditional_skip") == std::string::npos )
-               after.n_op += 1; // for conditional skip operation
-
-          // value when first comparison if false
-          scalar one_false = 5.0;
-
-          // Create a variable that is only used when second comparison is true
-          // (can be skipped when it is false)
-          scalar one_true = x[0] / 5.0;
-          before.n_var += 1; before.n_op += 1;
-          after.n_var  += 1; after.n_op  += 1;
-
-          // value when second comparison is false
-          scalar two_false = 3.0;
-
-          // First conditional compaison is 1 / x[0] < x[0]
-          // is only used when second conditional expression is true
-          // (can be skipped when it is false)
-          scalar two_true  = CppAD::CondExpLt(one, x[0], one_true, one_false);
-          before.n_var += 1; before.n_op += 1;
-          after.n_var  += 1; after.n_op  += 1;
-
-          // Second conditional compaison is 1 + x[0] < x[1]
-          scalar two_value = CppAD::CondExpLt(two, x[1], two_true, two_false);
-          before.n_var += 1; before.n_op += 1;
-          after.n_var  += 1; after.n_op  += 1;
-
-          // results for this operation sequence
-          y[0] = two_value;
-          before.n_var += 0; before.n_op  += 0;
-          after.n_var  += 0; after.n_op   += 0;
-     }
-}
-
-bool nest_conditional(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps10 = 10.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n  = 2;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.5;
-     ax[1] = 0.5;
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-
-     for(size_t k = 0; k < 2; k++)
-     {     // optimization options
-          std::string options = "";
-          if( k == 0 )
-               options = "no_conditional_skip";
-
-          // declare independent variables and start tape recording
-          CppAD::Independent(ax);
-
-          // compute function computation
-          tape_size before, after;
-          fun(options, ax, ay, before, after);
-
-          // create f: x -> y and stop tape recording
-          CppAD::ADFun<double> f(ax, ay);
-          ok &= f.size_var() == before.n_var;
-          ok &= f.size_op()  == before.n_op;
-
-          // Optimize the operation sequence
-          f.optimize(options);
-          ok &= f.size_var() == after.n_var;
-          ok &= f.size_op()  == after.n_op;
-
-          // Check case where result of the second comparison is true
-          // and first comparison is true
-          CPPAD_TESTVECTOR(double) x(n), y(m), check(m);
-          x[0] = 1.75;
-          x[1] = 4.0;
-          y    = f.Forward(0, x);
-          fun(options, x, check, before, after);
-          ok &= NearEqual(y[0], check[0], eps10, eps10);
-          ok  &= f.number_skip() == 0;
-
-          // Check case where result of the second comparison is true
-          // and first comparison is false
-          x[0] = 0.5;
-          x[1] = 4.0;
-          y    = f.Forward(0, x);
-          fun(options, x, check, before, after);
-          ok &= NearEqual(y[0], check[0], eps10, eps10);
-          if( options == "" )
-               ok  &= f.number_skip() == 1;
-          else
-               ok &= f.number_skip() == 0;
-
-          // Check case where result of the second comparison is false
-          // and first comparison is true
-          x[0] = 1.75;
-          x[1] = 0.0;
-          y    = f.Forward(0, x);
-          fun(options, x, check, before, after);
-          ok &= NearEqual(y[0], check[0], eps10, eps10);
-          if( options == "" )
-               ok  &= f.number_skip() == 3;
-          else
-               ok &= f.number_skip() == 0;
-
-          // Check case where result of the second comparison is false
-          // and first comparison is false
-          x[0] = 0.5;
-          x[1] = 0.0;
-          y    = f.Forward(0, x);
-          fun(options, x, check, before, after);
-          ok &= NearEqual(y[0], check[0], eps10, eps10);
-          if( options == "" )
-               ok  &= f.number_skip() == 3;
-          else
-               ok &= f.number_skip() == 0;
-     }
-     return ok;
-}
-
-
-
Input File: example/optimize/nest_conditional.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_optimize_nest_conditional.cpp_xml.js cppad-2019.02.00.0/doc/_optimize_nest_conditional.cpp_xml.js --- cppad-2018.00.00.0/doc/_optimize_nest_conditional.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_optimize_nest_conditional.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'optimize.xml', -'optimize_nest_conditional.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'optimize_forward_active.cpp.xml', -'optimize_reverse_active.cpp.xml', -'optimize_compare_op.cpp.xml', -'optimize_print_for.cpp.xml', -'optimize_conditional_skip.cpp.xml', -'optimize_nest_conditional.cpp.xml', -'optimize_cumulative_sum.cpp.xml' -]; -var list_current0 = [ -'optimize_nest_conditional.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-2018.00.00.0/doc/optimize_print_for.cpp.xml cppad-2019.02.00.0/doc/optimize_print_for.cpp.xml --- cppad-2018.00.00.0/doc/optimize_print_for.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/optimize_print_for.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,189 +0,0 @@ - - - -Example Optimization and Print Forward Operators - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -optimize_print_for.cppHeadings

-
Example Optimization and Print Forward Operators
-
# include <cppad/cppad.hpp>
-
-namespace {
-     struct tape_size { size_t n_var; size_t n_op; };
-
-     void PrintFor(
-          double pos, const char* before, double var, const char* after
-     )
-     {     if( pos <= 0.0 )
-               std::cout << before << var << after;
-          return;
-     }
-     template <class Vector> void fun(
-          const std::string& options ,
-          const Vector& x, Vector& y, tape_size& before, tape_size& after
-     )
-     {     typedef typename Vector::value_type scalar;
-
-          // phantom variable with index 0 and independent variables
-          // begin operator, independent variable operators and end operator
-          before.n_var = 1 + x.size(); before.n_op  = 2 + x.size();
-          after.n_var  = 1 + x.size(); after.n_op   = 2 + x.size();
-
-          // Argument to PrintFor is only needed
-          // if we are keeping print forward operators
-          scalar minus_one = x[0] - 1.0;
-          before.n_var += 1; before.n_op += 1;
-          if( options.find("no_print_for_op") == std::string::npos )
-          {     after.n_var += 1;  after.n_op += 1;
-          }
-
-          // print argument to log function minus one, if it is <= 0
-          PrintFor(minus_one, "minus_one == ", minus_one , " is <=  0\n");
-          before.n_var += 0; before.n_op += 1;
-          if( options.find("no_print_for_op") == std::string::npos )
-          {     after.n_var += 0;  after.n_op += 1;
-          }
-
-          // now compute log
-          y[0] = log( x[0] );
-          before.n_var += 1; before.n_op += 1;
-          after.n_var  += 1; after.n_op  += 1;
-     }
-}
-
-bool print_for(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps10 = 10.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n  = 1;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 1.5;
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-
-     for(size_t k = 0; k < 2; k++)
-     {     // optimization options
-          std::string options = "";
-          if( k == 0 )
-               options = "no_print_for_op";
-
-          // declare independent variables and start tape recording
-          CppAD::Independent(ax);
-
-          // compute function value
-          tape_size before, after;
-          fun(options, ax, ay, before, after);
-
-          // create f: x -> y and stop tape recording
-          CppAD::ADFun<double> f(ax, ay);
-          ok &= f.size_var() == before.n_var;
-          ok &= f.size_op() == before.n_op;
-
-          // Optimize the operation sequence
-          f.optimize(options);
-          ok &= f.size_var() == after.n_var;
-          ok &= f.size_op() == after.n_op;
-
-          // Check result for a zero order calculation for a different x
-          CPPAD_TESTVECTOR(double) x(n), y(m), check(m);
-          x[0] = 2.75;
-          y    = f.Forward(0, x);
-          fun(options, x, check, before, after);
-          ok &= NearEqual(y[0], check[0], eps10, eps10);
-     }
-     return ok;
-}
-
-
Input File: example/optimize/print_for.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_optimize_print_for.cpp_xml.js cppad-2019.02.00.0/doc/_optimize_print_for.cpp_xml.js --- cppad-2018.00.00.0/doc/_optimize_print_for.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_optimize_print_for.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'optimize.xml', -'optimize_print_for.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'optimize_forward_active.cpp.xml', -'optimize_reverse_active.cpp.xml', -'optimize_compare_op.cpp.xml', -'optimize_print_for.cpp.xml', -'optimize_conditional_skip.cpp.xml', -'optimize_nest_conditional.cpp.xml', -'optimize_cumulative_sum.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-2018.00.00.0/doc/optimize_reverse_active.cpp.xml cppad-2019.02.00.0/doc/optimize_reverse_active.cpp.xml --- cppad-2018.00.00.0/doc/optimize_reverse_active.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/optimize_reverse_active.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ - - - -Example Optimization and Reverse Activity Analysis - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -optimize_reverse_active.cppHeadings

-
Example Optimization and Reverse Activity Analysis
-
# include <cppad/cppad.hpp>
-namespace {
-     struct tape_size { size_t n_var; size_t n_op; };
-
-     template <class Vector> void fun(
-          const Vector& x, Vector& y, tape_size& before, tape_size& after
-     )
-     {     typedef typename Vector::value_type scalar;
-
-          // phantom variable with index 0 and independent variables
-          // begin operator, independent variable operators and end operator
-          before.n_var = 1 + x.size(); before.n_op  = 2 + x.size();
-          after.n_var  = 1 + x.size(); after.n_op   = 2 + x.size();
-
-          // initilized product of even and odd variables
-          scalar prod_even = x[0];
-          scalar prod_odd  = x[1];
-          before.n_var += 0; before.n_op  += 0;
-          after.n_var  += 0; after.n_op   += 0;
-          //
-          // compute product of even and odd variables
-          for(size_t i = 2; i < size_t( x.size() ); i++)
-          {     if( i % 2 == 0 )
-               {     // prod_even will affect dependent variable
-                    prod_even = prod_even * x[i];
-                    before.n_var += 1; before.n_op += 1;
-                    after.n_var  += 1; after.n_op  += 1;
-               }
-               else
-               {     // prod_odd will not affect dependent variable
-                    prod_odd  = prod_odd * x[i];
-                    before.n_var += 1; before.n_op += 1;
-                    after.n_var  += 0; after.n_op  += 0;
-               }
-          }
-
-          // dependent variable for this operation sequence
-          y[0] = prod_even;
-          before.n_var += 0; before.n_op  += 0;
-          after.n_var  += 0; after.n_op   += 0;
-     }
-}
-
-bool reverse_active(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps10 = 10.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n  = 6;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     for(size_t i = 0; i < n; i++)
-          ax[i] = AD<double>(i + 1);
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     tape_size before, after;
-     fun(ax, ay, before, after);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-     ok &= f.size_var() == before.n_var;
-     ok &= f.size_op()  == before.n_op;
-
-     // Optimize the operation sequence
-     f.optimize();
-     ok &= f.size_var() == after.n_var;
-     ok &= f.size_op()  == after.n_op;
-
-     // check zero order forward with different argument value
-     CPPAD_TESTVECTOR(double) x(n), y(m), check(m);
-     for(size_t i = 0; i < n; i++)
-          x[i] = double(i + 2);
-     y    = f.Forward(0, x);
-     fun(x, check, before, after);
-     ok &= NearEqual(y[0], check[0], eps10, eps10);
-
-     return ok;
-}
-
-
-
Input File: example/optimize/reverse_active.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_optimize_reverse_active.cpp_xml.js cppad-2019.02.00.0/doc/_optimize_reverse_active.cpp_xml.js --- cppad-2018.00.00.0/doc/_optimize_reverse_active.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_optimize_reverse_active.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'optimize.xml', -'optimize_reverse_active.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'optimize_forward_active.cpp.xml', -'optimize_reverse_active.cpp.xml', -'optimize_compare_op.cpp.xml', -'optimize_print_for.cpp.xml', -'optimize_conditional_skip.cpp.xml', -'optimize_nest_conditional.cpp.xml', -'optimize_cumulative_sum.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-2018.00.00.0/doc/optimize.xml cppad-2019.02.00.0/doc/optimize.xml --- cppad-2018.00.00.0/doc/optimize.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/optimize.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,387 +0,0 @@ - - - -Optimize an ADFun Object Tape - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Optimize an ADFun Object Tape
-
-Syntax - -
- -f.optimize()
-
- -f.optimize(options)
-
-
-Purpose -
-The operation sequence corresponding to an ADFun - object can -be very large and involve many operations; see the -size functions in seq_property -. -The -f.optimize - procedure reduces the number of operations, -and thereby the time and the memory, required to -compute function and derivative values. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-
-options -
-This argument has prototype - -
-     const std::string& 
options
-
-The default for -options - is the empty string. -If it is present, it must consist of one or more of the options below -separated by a single space character. - -
-
-no_conditional_skip -
-The optimize function can create conditional skip operators -to improve the speed of conditional expressions; see -optimize -. -If the sub-string no_conditional_skip appears in -options -, -conditional skip operations are not be generated. -This may make the optimize routine use significantly less memory -and take less time to optimize -f -. -If conditional skip operations are generated, -it may save a significant amount of time when -using -f - for forward - or reverse - mode calculations; -see number_skip -. - -
-
-no_compare_op -
-If the sub-string no_compare_op appears in -options -, -comparison operators will be removed from the optimized function. -These operators are necessary for the -compare_change - functions to be meaningful. -On the other hand, they are not necessary, and take extra time, -when the compare_change functions are not used. - -
-
-no_print_for_op -
-If the sub-string no_compare_op appears in -options -, -PrintFor - operations will be removed form the optimized function. -These operators are useful for reporting problems evaluating derivatives -at independent variable values different from those used to record a function. - -
-
-Examples - - - -
- -forward_active.cpp - - - Example Optimization and Forward Activity Analysis -
- -reverse_active.cpp - - - Example Optimization and Reverse Activity Analysis -
- -compare_op.cpp - - - Example Optimization and Comparison Operators -
- -print_for_op.cpp - - - Example Optimization and Print Forward Operators -
- -conditional_skip.cpp - - - Example Optimization and Conditional Expressions -
- -nest_conditional.cpp - - - Example Optimization and Nested Conditional Expressions -
- -cumulative_sum.cpp - - - Example Optimization and Cumulative Sum Operations -
-
-Efficiency -
-If a zero order forward - calculation is done during -the construction of -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 - -
-     ADFun<
Basef;
-     
f.Dependent(xy);
-     
f.optimize();
-
-instead of - -
-     ADFun<
Basef(xy)
-     
f.optimize();
-
-See the discussion about -sequence constructors -. - -
-
-Speed Testing -
-You can run the CppAD speed - tests and see -the corresponding changes in number of variables and execution time. -Note that there is an interaction between using -optimize - and -onetape -. -If -onetape - is true and -optimize - is true, -the optimized tape will be reused many times. -If -onetape - is false and -optimize - is true, -the tape will be re-optimized for each test. - -
-
-Atomic Functions -
-There are some subtitle issue with optimized atomic - functions - - -v -= -g -( -u -) - - -: - -
-
-rev_sparse_jac -
-The atomic_rev_sparse_jac - function is be used to determine -which components of -u - affect the dependent variables of -f -. -For each atomic operation, the current -atomic_sparsity - setting is used -to determine if pack_sparsity_enum, bool_sparsity_enum, -or set_sparsity_enum is used to determine dependency relations -between argument and result variables. - -
-
-nan -
-If -u[i] - does not affect the value of -the dependent variables for -f -, -the value of -u[i] - is set to nan -. - -
-
-Checking Optimization -
-If NDEBUG - is not defined, -and f.size_order() - is greater than zero, -a forward_zero - calculation is done using the optimized version -of -f - and the results are checked to see that they are -the same as before. -If they are not the same, the -ErrorHandler - is called with a known error message -related to -f.optimize() -. - - -
Input File: cppad/core/optimize.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_optimize_xml.js cppad-2019.02.00.0/doc/_optimize_xml.js --- cppad-2018.00.00.0/doc/_optimize_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_optimize_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'optimize.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down0 = [ -'optimize_forward_active.cpp.xml', -'optimize_reverse_active.cpp.xml', -'optimize_compare_op.cpp.xml', -'optimize_print_for.cpp.xml', -'optimize_conditional_skip.cpp.xml', -'optimize_nest_conditional.cpp.xml', -'optimize_cumulative_sum.cpp.xml' -]; -var list_current0 = [ -'optimize.xml#Syntax', -'optimize.xml#Purpose', -'optimize.xml#f', -'optimize.xml#options', -'optimize.xml#options.no_conditional_skip', -'optimize.xml#options.no_compare_op', -'optimize.xml#options.no_print_for_op', -'optimize.xml#Examples', -'optimize.xml#Efficiency', -'optimize.xml#Speed Testing', -'optimize.xml#Atomic Functions', -'optimize.xml#Atomic Functions.rev_sparse_jac', -'optimize.xml#Atomic Functions.nan', -'optimize.xml#Checking Optimization' -]; -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-2018.00.00.0/doc/opt_val_hes.cpp.xml cppad-2019.02.00.0/doc/opt_val_hes.cpp.xml --- cppad-2018.00.00.0/doc/opt_val_hes.cpp.xml 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/opt_val_hes.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,581 +0,0 @@ - - - -opt_val_hes: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -opt_val_hes.cppHeadings

- - - -
opt_val_hes: Example and Test
-Fix - -z - -R - - - - - - and define the functions - - -S -k - -: -R - -× -R - - -R - - - - - - by and - - -F -: -R - -× -R - - -R - - - - by - - - -S -k - -( -x -, -y -) - -= - -1 - -2 - - -[ -y -* -sin -( -x -* -t -k - -) -- -z -k - -] -2 - - -F -( -x -, -y -) - -= - - -k -= -0 - - --1 - - -S -k - -( -x -, -y -) - - - -It follows that - - - - -y - -F -( -x -, -y -) - -= - - -k -= -0 - - --1 - - -[ -y -* -sin -( -x -* -t -k - -) -- -z -k - -] -sin -( -x -* -t -k - -) - - -y - - -y - -F -( -x -, -y -) - -= - - -k -= -0 - - --1 - - -sin -( -x -t -k - -) -2 - - - - -Furthermore if we define - -Y -( -x -) - - - -as solving the equation - - -F -[ -x -, -Y -( -x -) -] -= -0 - - - we have - - - -0 - -= - - -k -= -0 - - --1 - - -[ -Y -( -x -) -* -sin -( -x -* -t -k - -) -- -z -k - -] -sin -( -x -* -t -k - -) - -Y -( -x -) - -k -= -0 - - --1 - - -sin -( -x -* -t -k - -) -2 - -- - -k -= -0 - - --1 - - -sin -( -x -* -t -k - -) -z -k - - -Y -( -x -) - -= - - -k -= -0 - - --1 - - -sin -( -x -* -t -k - -) -z -k - - - -k -= -0 - - --1 - - -sin -( -x -* -t -k - -) -2 - - - - - - -

-# include <limits>
-# include <cppad/cppad.hpp>
-
-namespace {
-     using CppAD::AD;
-     typedef CPPAD_TESTVECTOR(double)       BaseVector;
-     typedef CPPAD_TESTVECTOR(AD<double>) ADVector;
-
-     class Fun {
-     private:
-          const BaseVector t_;    // measurement times
-          const BaseVector z_;    // measurement values
-     public:
-          typedef ADVector ad_vector;
-          // constructor
-          Fun(const BaseVector &t, const BaseVector &z)
-          : t_(t) , z_(z)
-          {     assert( t.size() == z.size() ); }
-          // ell
-          size_t ell(void) const
-          {     return t_.size(); }
-          // Fun.s
-          AD<double> s(size_t k, const ad_vector& x, const ad_vector& y) const
-          {
-               AD<double> residual = y[0] * sin( x[0] * t_[k] ) - z_[k];
-               AD<double> s_k      = .5 * residual * residual;
-
-               return s_k;
-          }
-          // Fun.sy
-          ad_vector sy(size_t k, const ad_vector& x, const ad_vector& y) const
-          {     assert( y.size() == 1);
-               ad_vector sy_k(1);
-
-               AD<double> residual = y[0] * sin( x[0] * t_[k] ) - z_[k];
-               sy_k[0] = residual * sin( x[0] * t_[k] );
-
-               return sy_k;
-          }
-     };
-     // Used to test calculation of Hessian of V
-     AD<double> V(const ADVector& x, const BaseVector& t, const BaseVector& z)
-     {     // compute Y(x)
-          AD<double> numerator = 0.;
-          AD<double> denominator = 0.;
-          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] );
-          }
-          AD<double> y = numerator / denominator;
-
-          // V(x) = F[x, Y(x)]
-          AD<double> sum = 0;
-          for(k = 0; k < size_t(t.size()); k++)
-          {     AD<double> residual = y * sin( x[0] * t[k] ) - z[k];
-               sum += .5 * residual * residual;
-          }
-          return sum;
-     }
-}
-
-bool opt_val_hes(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-
-     // temporary indices
-     size_t j, k;
-
-     // x space vector
-     size_t n = 1;
-     BaseVector x(n);
-     x[0] = 2. * 3.141592653;
-
-     // y space vector
-     size_t m = 1;
-     BaseVector y(m);
-     y[0] = 1.;
-
-     // t and z vectors
-     size_t ell = 10;
-     BaseVector t(ell);
-     BaseVector z(ell);
-     for(k = 0; k < ell; k++)
-     {     t[k] = double(k) / double(ell);       // time of measurement
-          z[k] = y[0] * sin( x[0] * t[k] );     // data without noise
-     }
-
-     // construct the function object
-     Fun fun(t, z);
-
-     // evaluate the Jacobian and Hessian
-     BaseVector jac(n), hes(n * n);
-# ifndef NDEBUG
-     int signdet =
-# endif
-     CppAD::opt_val_hes(x, y, fun, jac, hes);
-
-     // we know that F_yy is positive definate for this case
-     assert( signdet == 1 );
-
-     // create ADFun object g corresponding to V(x)
-     ADVector a_x(n), a_v(1);
-     for(j = 0; j < n; j++)
-          a_x[j] = x[j];
-     Independent(a_x);
-     a_v[0] = V(a_x, t, z);
-     CppAD::ADFun<double> g(a_x, a_v);
-
-     // accuracy for checks
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-
-     // check Jacobian
-     BaseVector check_jac = g.Jacobian(x);
-     for(j = 0; j < n; j++)
-          ok &= NearEqual(jac[j], check_jac[j], eps, eps);
-
-     // check Hessian
-     BaseVector check_hes = g.Hessian(x, 0);
-     for(j = 0; j < n*n; j++)
-          ok &= NearEqual(hes[j], check_hes[j], eps, eps);
-
-     return ok;
-}
-
-
-
Input File: example/general/opt_val_hes.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_opt_val_hes.cpp_xml.js cppad-2019.02.00.0/doc/_opt_val_hes.cpp_xml.js --- cppad-2018.00.00.0/doc/_opt_val_hes.cpp_xml.js 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/_opt_val_hes.cpp_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', -'numeric_ad.xml', -'opt_val_hes.xml', -'opt_val_hes.cpp.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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 = [ -'benderquad.xml', -'opt_val_hes.xml', -'luratio.xml' -]; -var list_down1 = [ -'opt_val_hes.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-2018.00.00.0/doc/opt_val_hes.xml cppad-2019.02.00.0/doc/opt_val_hes.xml --- cppad-2018.00.00.0/doc/opt_val_hes.xml 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/opt_val_hes.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,843 +0,0 @@ - - - -Jacobian and Hessian of Optimal Values - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Jacobian and Hessian of Optimal Values
-
-Syntax - -
- -signdet = opt_val_hes(xyfunjaches) - - -
-
-See Also - -
-BenderQuad - - -
-
-Reference -
-Algorithmic differentiation of implicit functions and optimal values, -Bradley M. Bell and James V. Burke, Advances in Automatic Differentiation, -2008, Springer. - -
-
-Purpose -
-We are given a function - - -S -: -R - -n - -× -R - -m - - -R - - - - - - -and we define - -F -: -R - -n - -× -R - -m - - -R - - - - -and - -V -: -R - -n - - -R - - - - by - - - -F -( -x -, -y -) - -= - - -k -= -0 - - --1 - - -S -k - -( -x -, -y -) - -V -( -x -) - -= - -F -[ -x -, -Y -( -x -) -] - -0 - -= - - -y - -F -[ -x -, -Y -( -x -) -] - - - -We wish to compute the Jacobian -and possibly also the Hessian, of - -V -( -x -) - - -. - -
-
-BaseVector -
-The type -BaseVector - must be a -SimpleVector - class. -We use -Base - to refer to the type of the elements of - -BaseVector -; i.e., - -
-     
BaseVector::value_type
-
-
-x -
-The argument -x - has prototype - -
-     const 
BaseVectorx
-
-and its size must be equal to -n -. -It specifies the point at which we evaluating -the Jacobian - -V -( -1 -) - - -( -x -) - - - -(and possibly the Hessian - -V -( -2 -) - - -( -x -) - - -). - - -
-
-y -
-The argument -y - has prototype - -
-     const 
BaseVectory
-
-and its size must be equal to -m -. -It must be equal to - -Y -( -x -) - - -; i.e., -it must solve the implicit equation - - -0 -= - -y - -F -( -x -, -y -) - - -
-Fun -
-The argument -fun - is an object of type -Fun - -which must support the member functions listed below. -CppAD will may be recording operations of the type -AD<Base> - -when these member functions are called. -These member functions must not stop such a recording; e.g., -they must not call AD<Base>::abort_recording -. - -
-
-Fun::ad_vector -
-The type -Fun::ad_vector - must be a -SimpleVector - class with elements of type -AD<Base> -; i.e. - -
-     
Fun::ad_vector::value_type
-
-is equal to -AD<Base> -. - -
-
-fun.ell -
-The type -Fun - must support the syntax - -
-     
ell = fun.ell()
-
-where -ell - has prototype - -
-     size_t 
ell
-
-and is the value of - - - - -; i.e., -the number of terms in the summation. -
-
-
One can choose -ell - equal to one, and have - - -S -( -x -, -y -) - - - the same as - -F -( -x -, -y -) - - -. -Each of the functions - -S -k - -( -x -, -y -) - - -, -(in the summation defining - -F -( -x -, -y -) - - -) -is differentiated separately using AD. -For very large problems, breaking - -F -( -x -, -y -) - - - into the sum -of separate simpler functions may reduce the amount of memory necessary for -algorithmic differentiation and there by speed up the process. - -
-
-fun.s -
-The type -Fun - must support the syntax - -
-     
s_k = fun.s(kxy)
-
-The -fun.s - argument -k - has prototype - -
-     size_t 
k
-
-and is between zero and -ell - 1 -. -The argument -x - to -fun.s - has prototype - -
-     const 
Fun::ad_vector& x
-
-and its size must be equal to -n -. -The argument -y - to -fun.s - has prototype - -
-     const 
Fun::ad_vector& y
-
-and its size must be equal to -m -. -The -fun.s - result -s_k - has prototype - -
-     AD<
Bases_k
-
-and its value must be given by - -s -k - -= -S -k - -( -x -, -y -) - - -. - -
-
-fun.sy -
-The type -Fun - must support the syntax - -
-     
sy_k = fun.sy(kxy)
-
-The argument -k - to -fun.sy - has prototype - -
-     size_t 
k
-
-The argument -x - to -fun.sy - has prototype - -
-     const 
Fun::ad_vector& x
-
-and its size must be equal to -n -. -The argument -y - to -fun.sy - has prototype - -
-     const 
Fun::ad_vector& y
-
-and its size must be equal to -m -. -The -fun.sy - result -sy_k - has prototype - -
-     
Fun::ad_vector sy_k
-
-its size must be equal to -m -, -and its value must be given by - -sy -k - -= - -y - -S -k - -( -x -, -y -) - - -. - -
-
-jac -
-The argument -jac - has prototype - -
-     
BaseVectorjac
-
-and has size -n - or zero. -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 - -V -( -x -) - - -; i.e., -for - -j -= -0 -, - -, -n --1 - - -, - - -jac -[ -j -] -= -V -( -1 -) - - -( -x -) -j - - - -where -x - is the first argument to opt_val_hes. - -
-
-hes -
-The argument -hes - has prototype - -
-     
BaseVectorhes
-
-and has size -n * n - or zero. -The input values of its elements do not matter. -If it has size zero, it is not affected. Otherwise, on output -it contains the Hessian of - -V -( -x -) - - -; i.e., -for - -i -= -0 -, - -, -n --1 - - -, and - - -j -= -0 -, - -, -n --1 - - -, - - -hes -[ -i -* -n -+ -j -] -= -V -( -2 -) - - -( -x -) -i -, -j - - - - -
-signdet -
-If -hes - has size zero, -signdet - is not defined. -Otherwise -the return value -signdet - is the sign of the determinant for - - - -yy - -2 - -F -( -x -, -y -) - - -. -If it is zero, then the matrix is singular and -the Hessian is not computed ( -hes - is not changed). - -
-
-Example - -
-The file -opt_val_hes.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/opt_val_hes.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_opt_val_hes_xml.js cppad-2019.02.00.0/doc/_opt_val_hes_xml.js --- cppad-2018.00.00.0/doc/_opt_val_hes_xml.js 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/_opt_val_hes_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -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', -'opt_val_hes.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', -'directory.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 = [ -'benderquad.xml', -'opt_val_hes.xml', -'luratio.xml' -]; -var list_down0 = [ -'opt_val_hes.cpp.xml' -]; -var list_current0 = [ -'opt_val_hes.xml#Syntax', -'opt_val_hes.xml#See Also', -'opt_val_hes.xml#Reference', -'opt_val_hes.xml#Purpose', -'opt_val_hes.xml#BaseVector', -'opt_val_hes.xml#x', -'opt_val_hes.xml#y', -'opt_val_hes.xml#Fun', -'opt_val_hes.xml#Fun.Fun::ad_vector', -'opt_val_hes.xml#Fun.fun.ell', -'opt_val_hes.xml#Fun.fun.s', -'opt_val_hes.xml#Fun.fun.sy', -'opt_val_hes.xml#jac', -'opt_val_hes.xml#hes', -'opt_val_hes.xml#signdet', -'opt_val_hes.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-2018.00.00.0/doc/parallel_ad.xml cppad-2019.02.00.0/doc/parallel_ad.xml --- cppad-2018.00.00.0/doc/parallel_ad.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/parallel_ad.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ - - - -Enable AD Calculations During Parallel Mode - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -parallel_ad - -

-
Enable AD Calculations During Parallel Mode
-
-Syntax - -
- -parallel_ad<Base>() - - -
-
-Purpose -
-The function - -parallel_ad<Base>() - -must be called before any -AD<Base> - objects are used -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 -the multiple -AD<Base> - tapes required for parallel execution. - -
-
-Discussion -
-By default, for each -AD<Base> - class there is only one -tape that records AD of Base - operations. -This tape is a global variable and hence it cannot be used -by multiple threads at the same time. -The parallel_setup - function informs CppAD of the -maximum number of threads that can be active in parallel mode. -This routine does extra setup -(and teardown) for the particular -Base - type. - -
-
-CheckSimpleVector -
-This routine has the side effect of calling the routines - -
-     CheckSimpleVector< 
Type, CppAD::vector<Type> >()
-
-where -Type - is -Base - and -AD<Base> -. - -
-
-Example -
-The files -team_openmp.cpp -, -team_bthread.cpp -, and -team_pthread.cpp -, -contain examples and tests that implement this function. - -
-
-Restriction -
-This routine cannot be called in parallel mode or while -there is a tape recording -AD<Base> - operations. - - -
Input File: cppad/core/parallel_ad.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_parallel_ad_xml.js cppad-2019.02.00.0/doc/_parallel_ad_xml.js --- cppad-2018.00.00.0/doc/_parallel_ad_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_parallel_ad_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'parallel_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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_current0 = [ -'parallel_ad.xml#Syntax', -'parallel_ad.xml#Purpose', -'parallel_ad.xml#Discussion', -'parallel_ad.xml#CheckSimpleVector', -'parallel_ad.xml#Example', -'parallel_ad.xml#Restriction' -]; -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-2018.00.00.0/doc/par_var.cpp.xml cppad-2019.02.00.0/doc/par_var.cpp.xml --- cppad-2018.00.00.0/doc/par_var.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/par_var.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ - - - -AD Parameter and Variable Functions: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -par_var.cppHeadings

- - -
AD Parameter and Variable Functions: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool ParVar(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::VecAD;
-     using CppAD::Parameter;
-     using CppAD::Variable;
-
-     // declare independent variables and start tape recording
-     size_t n = 1;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     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
-
-     // dependent variable vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = 2.;
-     ok  &= Parameter(y[0]);    // y[0] does not depend on x[0]
-     y[1] = fabs(x[0]);
-     ok  &= Variable(y[1]);     // y[1] does depends on x[0]
-
-     // VecAD objects
-     VecAD<double> z(2);
-     z[0] = 0.;
-     z[1] = 1.;
-     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<double> f(x, y);
-
-     // check that now all AD<double> objects are parameters
-     ok &= Parameter(x[0]); ok &= ! Variable(x[0]);
-     ok &= Parameter(y[0]); ok &= ! Variable(y[0]);
-     ok &= Parameter(y[1]); ok &= ! Variable(y[1]);
-
-     // check that the VecAD<double> object is a parameter
-     ok &= Parameter(z);
-
-     return ok;
-}
-
-
-
Input File: example/general/par_var.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_par_var.cpp_xml.js cppad-2019.02.00.0/doc/_par_var.cpp_xml.js --- cppad-2018.00.00.0/doc/_par_var.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_par_var.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'boolvalued.xml', -'parvar.xml', -'par_var.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 = [ -'compare.xml', -'nearequalext.xml', -'boolfun.xml', -'parvar.xml', -'equalopseq.xml' -]; -var list_down1 = [ -'par_var.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-2018.00.00.0/doc/parvar.xml cppad-2019.02.00.0/doc/parvar.xml --- cppad-2018.00.00.0/doc/parvar.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/parvar.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ - - - -Is an AD Object a Parameter or Variable - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Is an AD Object a Parameter or Variable
-
-Syntax - -
- -b = Parameter(x) - -
-
-b = Variable(x) - - - -
-
-Purpose -
-Determine if -x - is a -parameter - or -variable -. - -
-
-x -
-The argument -x - has prototype - -
-     const AD<
Base>    &x
-     const VecAD<
Base> &x
-
-
-b -
-The return value -b - has prototype - -
-     bool 
b
-
-The return value for Parameter (Variable) -is true if and only if -x - is a parameter (variable). -Note that a VecAD<Base> - object -is a variable if any element of the vector depends on the independent -variables. - -
-
-Operation Sequence -
-The result of this operation is not an -AD of Base - object. -Thus it will not be recorded as part of an -AD of -Base - -operation sequence -. - -
-
-Example - -
-The file -par_var.cpp - -contains an example and test of these functions. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/par_var.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_parvar_xml.js cppad-2019.02.00.0/doc/_parvar_xml.js --- cppad-2018.00.00.0/doc/_parvar_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_parvar_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', -'ad.xml', -'boolvalued.xml', -'parvar.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 = [ -'compare.xml', -'nearequalext.xml', -'boolfun.xml', -'parvar.xml', -'equalopseq.xml' -]; -var list_down0 = [ -'par_var.cpp.xml' -]; -var list_current0 = [ -'parvar.xml#Syntax', -'parvar.xml#Purpose', -'parvar.xml#x', -'parvar.xml#b', -'parvar.xml#Operation Sequence', -'parvar.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-2018.00.00.0/doc/pkgconfig.xml cppad-2019.02.00.0/doc/pkgconfig.xml --- cppad-2018.00.00.0/doc/pkgconfig.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/pkgconfig.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,231 +0,0 @@ - - - -CppAD pkg-config Files - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -pkgconfig - -

- - - -
CppAD pkg-config Files
-
-Purpose -
-The pkg-config package helps with the use of installed libraries; -see its -guide - -for more information. - -
-
-Usage -
-The necessary flags for compiling code that includes CppAD can -be obtained with the command -
 
-     pkg-config --cflags cppad
-
-Note that this command assumes cppad.pc - is in -the search path PKG_CONFIG_PATH. -If ipopt_prefix - is specified, -the necessary flags for linking cppad_ipopt - -can be obtained with the commands -
 
-     pkg-config --libs cppad
-
-Note that this command assumes ipopt.pc is in -the search path PKG_CONFIG_PATH. - -
-
-Defined Fields - - -
- - -Name - - - A human-readable name for the CppAD package. -
- - -Description - - - A brief description of the CppAD package. -
- - -URL - - - A URL where people can get more information about the CppAD package. -
- - -Version - - - A string specifically defining the version of the CppAD package. -
- - -Cflags - - - The necessary flags for using any of the CppAD include files. -
- - -Libs - - - If ipopt_prefix - is specified, - the necessary flags for using the cppad_ipopt - - library -
- - -Requires - - - If ipopt_prefix - is specified, - the packages required to use the cppad_ipopt - - library -
-
-CppAD Configuration Files -
-In the table below, - -builddir - is the build directory; i.e., the directory where -the CppAD -cmake command - is executed. -The directory -prefix - is the value of -cppad_prefix - during configuration. -The directory -datadir - is the value of -cmake_install_datadir -. -The following configuration files contain the information above - -
- - -File - - - -Description -
- - -prefix/datadir/pkgconfig/cppad.pc - - - for use after - make install - -
- - -builddir/pkgconfig/cppad-uninstalled.pc - - - for testing before make install -
- -
Input File: omh/install/pkgconfig.omh - - - diff -Nru cppad-2018.00.00.0/doc/_pkgconfig_xml.js cppad-2019.02.00.0/doc/_pkgconfig_xml.js --- cppad-2018.00.00.0/doc/_pkgconfig_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_pkgconfig_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'install.xml', -'pkgconfig.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' -]; -var list_current0 = [ -'pkgconfig.xml#Purpose', -'pkgconfig.xml#Usage', -'pkgconfig.xml#Defined Fields', -'pkgconfig.xml#CppAD Configuration Files' -]; -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-2018.00.00.0/doc/poly.cpp.xml cppad-2019.02.00.0/doc/poly.cpp.xml --- cppad-2018.00.00.0/doc/poly.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/poly.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ - - - -Polynomial Evaluation: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -poly.cppHeadings

- - -
Polynomial Evaluation: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cmath>
-
-bool Poly(void)
-{     bool ok = true;
-
-     // degree of the polynomial
-     size_t deg = 3;
-
-     // set the polynomial coefficients
-     CPPAD_TESTVECTOR(double)   a(deg + 1);
-     size_t i;
-     for(i = 0; i <= deg; i++)
-          a[i] = 1.;
-
-     // evaluate this polynomial
-     size_t k = 0;
-     double z = 2.;
-     double p = CppAD::Poly(k, a, z);
-     ok      &= (p == 1. + z + z*z + z*z*z);
-
-     // evaluate derivative
-     k = 1;
-     p = CppAD::Poly(k, a, z);
-     ok &= (p == 1 + 2.*z + 3.*z*z);
-
-     return ok;
-}
-
-
-
Input File: example/general/poly.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_poly.cpp_xml.js cppad-2019.02.00.0/doc/_poly.cpp_xml.js --- cppad-2018.00.00.0/doc/_poly.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_poly.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'poly.xml', -'poly.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'poly.cpp.xml', -'poly.hpp.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-2018.00.00.0/doc/poly.hpp.xml cppad-2019.02.00.0/doc/poly.hpp.xml --- cppad-2018.00.00.0/doc/poly.hpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/poly.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,165 +0,0 @@ - - - -Source: Poly - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -poly.hppHeadings

-
Source: Poly
-# ifndef CPPAD_POLY_HPP -
-
# define CPPAD_POLY_HPP - -
# include <cstddef>  // used to defined size_t
-# include <cppad/utility/check_simple_vector.hpp>
-
-namespace CppAD {    // BEGIN CppAD namespace
-
-template <class Type, class Vector>
-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<Type, Vector>();
-
-     // 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       = double( 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
-# endif -
- - -
Input File: omh/poly_hpp.omh - - - diff -Nru cppad-2018.00.00.0/doc/_poly.hpp_xml.js cppad-2019.02.00.0/doc/_poly.hpp_xml.js --- cppad-2018.00.00.0/doc/_poly.hpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_poly.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'poly.xml', -'poly.hpp.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'poly.cpp.xml', -'poly.hpp.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-2018.00.00.0/doc/poly.xml cppad-2019.02.00.0/doc/poly.xml --- cppad-2018.00.00.0/doc/poly.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/poly.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,448 +0,0 @@ - - - -Evaluate a Polynomial or its Derivative - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Evaluate a Polynomial or its Derivative
-
-Syntax - -
- -# include <cppad/utility/poly.hpp>
-
- -p = Poly(kaz) - - - -
-
-Description -
-Computes the k-th derivative of the polynomial - - -P -( -z -) -= -a -0 - -+ -a -1 - -z -1 - -+ - -+ -a -d - -z -d - - - -If -k - is equal to zero, the return value is - -P -( -z -) - - -. - -
-
-Include -
-The file cppad/poly.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. -Including this file defines -Poly within the CppAD namespace. - -
-
-k -
-The argument -k - has prototype - -
-     size_t 
k
-
-It specifies the order of the derivative to calculate. - -
-
-a -
-The argument -a - has prototype - -
-     const 
Vector &a
-
-(see Vector - below). -It specifies the vector corresponding to the polynomial - -P -( -z -) - - -. - -
-
-z -
-The argument -z - has prototype - -
-     const 
Type &z
-
-(see -Type - below). -It specifies the point at which to evaluate the polynomial - -
-
-p -
-The result -p - has prototype - -
-     
Type p
-
-(see Type - below) -and it is equal to the k-th derivative of - -P -( -z -) - - -; i.e., - - -p -= -k -! - -0 -! - - -a -k - -+ -( -k -+ -1 -) -! - -1 -! - - -a -k -+ -1 - - -z -1 - -+ - -+ -d -! - -( -d -- -k -) -! - - -a -d - -z -d -- -k - - - - -If - -k -> -d - - -, -p = Type(0) -. - -
-
-Type -
-The type -Type - is determined by the argument -z -. -It is assumed that -multiplication and addition of -Type - objects -are commutative. - -
-
-Operations -
-The following operations must be supported where - -x - and -y - are objects of type -Type - -and -i - is an int: - -
- - -x  = i - - assignment
- - -x  = y - - assignment
- - -x *= y - - multiplication compound assignment
- - -x += y - - addition compound assignment - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Type -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Operation Sequence -
-The -Type - operation sequence used to calculate -p - is -independent - -of -z - and the elements of -a - -(it does depend on the size of the vector -a -). - - - - -
-
-Example -
-The file -poly.cpp - -contains an example and test of this routine. -It returns true if it succeeds and false otherwise. - -
-
-Source -
-The file poly.hpp - contains the -current source code that implements these specifications. - - -
Input File: cppad/utility/poly.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_poly_xml.js cppad-2019.02.00.0/doc/_poly_xml.js --- cppad-2018.00.00.0/doc/_poly_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_poly_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'poly.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'poly.cpp.xml', -'poly.hpp.xml' -]; -var list_current0 = [ -'poly.xml#Syntax', -'poly.xml#Description', -'poly.xml#Include', -'poly.xml#k', -'poly.xml#a', -'poly.xml#z', -'poly.xml#p', -'poly.xml#Type', -'poly.xml#Type.Operations', -'poly.xml#Vector', -'poly.xml#Operation Sequence', -'poly.xml#Example', -'poly.xml#Source' -]; -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-2018.00.00.0/doc/pow.cpp.xml cppad-2019.02.00.0/doc/pow.cpp.xml --- cppad-2018.00.00.0/doc/pow.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/pow.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ - - - -The AD Power Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -pow.cppHeadings

- - - -
The AD Power Function: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cmath>
-
-bool pow(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n  = 2;
-     double x = 0.5;
-     double y = 2.;
-     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 = 3;
-     CPPAD_TESTVECTOR(AD<double>) 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: axy -> az and stop tape recording
-     CppAD::ADFun<double> f(axy, az);
-
-     // check value
-     double check = std::pow(x, y);
-     size_t i;
-     for(i = 0; i < m; i++)
-          ok &= NearEqual(az[i] , check,  eps, eps);
-
-     // forward computation of first partial w.r.t. x
-     CPPAD_TESTVECTOR(double) dxy(n);
-     CPPAD_TESTVECTOR(double) dz(m);
-     dxy[0] = 1.;
-     dxy[1] = 0.;
-     dz    = f.Forward(1, dxy);
-     check = y * std::pow(x, y-1.);
-     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, 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);
-     CPPAD_TESTVECTOR(double) dw(n);
-     w[0]  = 1.;
-     w[1]  = 1.;
-     w[2]  = 1.;
-     dw    = f.Reverse(1, w);
-     check = y * std::pow(x, y-1.);
-     ok   &= NearEqual(dw[0], 2. * check, eps, eps);
-     check = std::log(x) * std::pow(x, y);
-     ok   &= NearEqual(dw[1], 2. * check, eps, eps);
-
-     // use a VecAD<Base>::reference object with pow
-     CppAD::VecAD<double> v(2);
-     AD<double> zero(0);
-     AD<double> one(1);
-     v[zero]           = axy[0];
-     v[one]            = axy[1];
-     AD<double> result = CppAD::pow(v[zero], v[one]);
-     ok               &= NearEqual(result, az[0], eps, eps);
-
-     return ok;
-}
-
-
-
Input File: example/general/pow.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_pow.cpp_xml.js cppad-2019.02.00.0/doc/_pow.cpp_xml.js --- cppad-2018.00.00.0/doc/_pow.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_pow.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +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', -'binary_math.xml', -'pow.xml', -'pow.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 = [ -'pow.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-2018.00.00.0/doc/pow_int.cpp.xml cppad-2019.02.00.0/doc/pow_int.cpp.xml --- cppad-2018.00.00.0/doc/pow_int.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/pow_int.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ - - - -The Pow Integer Exponent: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -pow_int.cppHeadings

- - - -
The Pow Integer Exponent: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cmath>
-
-bool pow_int(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // declare independent variables and start tape recording
-     size_t n  = 1;
-     double x0 = -0.5;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0]      = x0;
-     CppAD::Independent(x);
-
-     // dependent variable vector
-     size_t m = 7;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     int 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<double> f(x, y);
-
-     // check value
-     double check;
-     for(i = 0; i < int(m); i++)
-     {     check = std::pow(x0, double(i - 3));
-          ok &= NearEqual(y[i] , check,  eps99 , eps99);
-     }
-
-     // 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);
-     for(i = 0; i < int(m); i++)
-     {     check = double(i-3) * std::pow(x0, double(i - 4));
-          ok &= NearEqual(dy[i] , check,  eps99 , eps99);
-     }
-
-     // reverse computation of derivative of y[i]
-     CPPAD_TESTVECTOR(double)  w(m);
-     CPPAD_TESTVECTOR(double) dw(n);
-     for(i = 0; i < int(m); i++)
-          w[i] = 0.;
-     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,  eps99 , eps99);
-          w[i] = 0.;
-     }
-
-     return ok;
-}
-
-
-
Input File: example/general/pow_int.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_pow_int.cpp_xml.js cppad-2019.02.00.0/doc/_pow_int.cpp_xml.js --- cppad-2018.00.00.0/doc/_pow_int.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_pow_int.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'pow_int.xml', -'pow_int.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'pow_int.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-2018.00.00.0/doc/pow_int.xml cppad-2019.02.00.0/doc/pow_int.xml --- cppad-2018.00.00.0/doc/pow_int.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/pow_int.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,301 +0,0 @@ - - - -The Integer Power Function - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
The Integer Power Function
-
-Syntax - -
- -# include <cppad/utility/pow_int.hpp>
-
- -z = pow(xy) - - -
-
-See Also - -
-pow - - -
-
-Purpose -
-Determines the value of the power function - - -pow - -( -x -, -y -) -= -x -y - - - -for integer exponents -n - -using multiplication and possibly division to compute the value. -The other CppAD pow - function may use logarithms and exponentiation -to compute derivatives of the same value -(which will not work if -x - is less than or equal zero). - -
-
-Include -
-The file cppad/pow_int.h is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. -Including this file defines -this version of the pow within the CppAD namespace. - -
-
-x -
-The argument -x - has prototype - -
-     const 
Typex
-
-
-y -
-The argument -y - has prototype - -
-     const int& 
y
-
-
-z -
-The result -z - has prototype - -
-     
Type z
-
-
-Type -
-The type -Type - must support the following operations -where -a - and -b - are -Type - objects -and -i - is an int: - -
- -Operation    - - Description - - Result Type -
- - -Type a(i) - - - construction of a -Type - object from an int - - -Type - -
- - -a * b - - - binary multiplication of -Type - objects - - -Type - -
- - -a / b - - - binary division of -Type - objects - - -Type - -
-
-Operation Sequence -
-The -Type - operation sequence used to calculate -z - is -independent - -of -x -. - -
-
-Example - -
-The file pow_int.cpp - -is an example and test of this function. -It returns true if it succeeds and false otherwise. - - - -
Input File: cppad/utility/pow_int.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_pow_int_xml.js cppad-2019.02.00.0/doc/_pow_int_xml.js --- cppad-2018.00.00.0/doc/_pow_int_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_pow_int_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'pow_int.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'pow_int.cpp.xml' -]; -var list_current0 = [ -'pow_int.xml#Syntax', -'pow_int.xml#See Also', -'pow_int.xml#Purpose', -'pow_int.xml#Include', -'pow_int.xml#x', -'pow_int.xml#y', -'pow_int.xml#z', -'pow_int.xml#Type', -'pow_int.xml#Operation Sequence', -'pow_int.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-2018.00.00.0/doc/pow.xml cppad-2019.02.00.0/doc/pow.xml --- cppad-2018.00.00.0/doc/pow.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/pow.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,229 +0,0 @@ - - - -The AD Power Function - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
The AD Power Function
-
-Syntax - -
- -z = pow(xy) - - -
-
-See Also - -
-pow_int - - - -
-
-Purpose -
-Determines the value of the power function which is defined by - - -pow - -( -x -, -y -) -= -x -y - - - -This version of the pow function may use -logarithms and exponentiation to compute derivatives. -This will not work if -x - is less than or equal zero. -If the value of -y - is an integer, -the pow_int - function is used to compute this value -using only multiplication (and division if -y - is negative). -(This will work even if -x - is less than or equal zero.) - -
-
-x -
-The argument -x - has one of the following prototypes - -
-     const 
Base&                    x
-     const AD<
Base>&                x
-     const VecAD<
Base>::reference&  x
-
-
-y -
-The argument -y - has one of the following prototypes - -
-     const 
Base&                    y
-     const AD<
Base>&                y
-     const VecAD<
Base>::reference&  y
-
-
-z -
-If both -x - and -y - are -Base - objects, -the result -z - is also a -Base - object. -Otherwise, it has prototype - -
-     AD<
Basez
-
-
-Operation Sequence -
-This is an AD of -Base - -atomic operation - -and hence is part of the current -AD of -Base - -operation sequence -. - -
-
-Example - -
-The file -pow.cpp - -is an examples and tests of this function. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/pow.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_pow_xml.js cppad-2019.02.00.0/doc/_pow_xml.js --- cppad-2018.00.00.0/doc/_pow_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_pow_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'binary_math.xml', -'pow.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 = [ -'pow.cpp.xml' -]; -var list_current0 = [ -'pow.xml#Syntax', -'pow.xml#See Also', -'pow.xml#Purpose', -'pow.xml#x', -'pow.xml#y', -'pow.xml#z', -'pow.xml#Operation Sequence', -'pow.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-2018.00.00.0/doc/preprocessor.xml cppad-2019.02.00.0/doc/preprocessor.xml --- cppad-2018.00.00.0/doc/preprocessor.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/preprocessor.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,230 +0,0 @@ - - - -CppAD API Preprocessor Symbols - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - -preprocessor - -

-
CppAD API Preprocessor Symbols
-
-Purpose -
-The CppAD include files defines preprocessor symbols all of which begin -with CPPAD_. -Note that there are some old, deprecated preprocessor symbols that -begin with CppAD. -In this section we list all of the CppAD preprocessor symbols that -are part of the CppAD Application Interface (API). - -
-
-Documented Here - - -
-
-CPPAD_DEBUG_AND_RELEASE -
-This flag is an exception because it is defined (or not) by the user when -compiling programs that include CppAD source code. -If it is defined, less error checking is done and the -debug and release versions of CppAD can be mixed in the same program. -Of particular note is that thread_alloc - does less error checking. -For programs that do a lot of memory allocation, -this can be a significant time savings when NDEBUG is defined. - -
-
-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 nullptr in C++11. - -
-
-CPPAD_PACKAGE_STRING -
-Is a const char* representation of this version of CppAD. - -
-
-CPPAD_USE_CPLUSPLUS_2011 -
-This preprocessor symbol has the value has the value 1 -if C++11 features are being used by CppAD. -Otherwise it has the value zero. - - -
-
-Documented Elsewhere - - -
- -CPPAD_BOOL_BINARY - -
- -CPPAD_BOOL_UNARY - -
- -CPPAD_DISCRETE_FUNCTION - -
- -CPPAD_MAX_NUM_THREADS - -
- -CPPAD_NUMERIC_LIMITS - -
- -CPPAD_STANDARD_MATH_UNARY - -
- -CPPAD_TAPE_ADDR_TYPE - -
- -CPPAD_TAPE_ID_TYPE - -
- -CPPAD_TESTVECTOR - -
- -CPPAD_TO_STRING - -
-
-Deprecated - - -
- -CppADCreateDiscrete - -
- -CppADvector - -
- -CPPAD_TEST_VECTOR - -
- -CPPAD_TRACK_NEW_VEC - -
- -CPPAD_TRACK_DEL_VEC - -
- -CPPAD_TRACK_EXTEND - -
- -CPPAD_TRACK_COUNT - -
- -CPPAD_USER_ATOMIC - -
- -CppADTrackNewVec - -
- -CppADTrackDelVec - -
- -CppADTrackExtend - -
- -CppADTrackCount - -
- -
Input File: omh/preprocessor.omh - - - diff -Nru cppad-2018.00.00.0/doc/_preprocessor_xml.js cppad-2019.02.00.0/doc/_preprocessor_xml.js --- cppad-2018.00.00.0/doc/_preprocessor_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_preprocessor_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'preprocessor.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_current0 = [ -'preprocessor.xml#Purpose', -'preprocessor.xml#Documented Here', -'preprocessor.xml#Documented Here.CPPAD_DEBUG_AND_RELEASE', -'preprocessor.xml#Documented Here.CPPAD_NULL', -'preprocessor.xml#Documented Here.CPPAD_PACKAGE_STRING', -'preprocessor.xml#Documented Here.CPPAD_USE_CPLUSPLUS_2011', -'preprocessor.xml#Documented Elsewhere', -'preprocessor.xml#Deprecated' -]; -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-2018.00.00.0/doc/print_for_cout.cpp.xml cppad-2019.02.00.0/doc/print_for_cout.cpp.xml --- cppad-2018.00.00.0/doc/print_for_cout.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/print_for_cout.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,193 +0,0 @@ - - - -Printing During Forward Mode: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -print_for_cout.cpp - -

- - - -
Printing During Forward Mode: Example and Test
-
-Running -
-To build this program and run its correctness test see cmake_check -. - -
-
-Source Code - -
# include <cppad/cppad.hpp>
-
-namespace {
-     using std::cout;
-     using std::endl;
-     using CppAD::AD;
-
-     // use of PrintFor to check for invalid function arguments
-     AD<double> check_log(const AD<double>& y)
-     {     // check during recording
-          if( y <= 0. )
-               cout << "check_log: y = " << y << " is <= 0" << endl;
-
-          // check during zero order forward calculation
-          PrintFor(y, "check_log: y == ", y , " which is <= 0\n");
-
-          return log(y);
-     }
-}
-
-void print_for(void)
-{     using CppAD::PrintFor;
-
-     // independent variable vector
-     size_t n = 1;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 1.;
-     Independent(ax);
-
-     // print a VecAD<double>::reference object that is a parameter
-     CppAD::VecAD<double> av(1);
-     AD<double> Zero(0);
-     av[Zero] = 0.;
-     PrintFor("v[0] = ", av[Zero]);
-
-     // Print a newline to separate this from previous output,
-     // then print an AD<double> object that is a variable.
-     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");
-
-     // A conditional print that will generate output when x[0] = 2.
-     PrintFor(ax[0] - 2., "\n  3. + x[0] = ",   3. + ax[0], "\n");
-
-     // A log evaluations that will result in an error message when x[0] = 2.
-     AD<double> var     = 2. - ax[0];
-     AD<double> log_var = check_log(var);
-
-     // dependent variable vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = av[Zero] + ax[0];
-
-     // define f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // 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 << "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);
-
-     return;
-}
-int main(void)
-{     print_for();
-
-     return 0;
-}
-
-Output -
-Executing the program above generates the following output: -
 
-     v[0] = 0
-     v[0] + x[0] = 2
-     Test passes if two lines above repeat below:
-     v[0] = 0
-     v[0] + x[0] = 2
-
- -
Input File: example/print_for/print_for.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_print_for_cout.cpp_xml.js cppad-2019.02.00.0/doc/_print_for_cout.cpp_xml.js --- cppad-2018.00.00.0/doc/_print_for_cout.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_print_for_cout.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'convert.xml', -'printfor.xml', -'print_for_cout.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 = [ -'value.xml', -'integer.xml', -'ad_to_string.xml', -'ad_input.xml', -'ad_output.xml', -'printfor.xml', -'var2par.xml' -]; -var list_down1 = [ -'print_for_cout.cpp.xml', -'print_for_string.cpp.xml' -]; -var list_current0 = [ -'print_for_cout.cpp.xml#Running', -'print_for_cout.cpp.xml#Source Code', -'print_for_cout.cpp.xml#Output' -]; -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-2018.00.00.0/doc/print_for_string.cpp.xml cppad-2019.02.00.0/doc/print_for_string.cpp.xml --- cppad-2018.00.00.0/doc/print_for_string.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/print_for_string.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ - - - -Print During Zero Order Forward Mode: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -print_for_string.cppHeadings

-
Print During Zero Order Forward Mode: Example and Test
-
# include <cppad/cppad.hpp>
-
-namespace {
-     using std::endl;
-     using CppAD::AD;
-
-     // use of PrintFor to check for invalid function arguments
-     AD<double> check_log(const AD<double>& y, std::ostream& s_out)
-     {     // check AD<double> value during recording
-          if( y <= 0 )
-               s_out << "check_log: y == " << y << " which is <= 0\n";
-
-          // check double value during zero order forward calculation
-          PrintFor(y, "check_log: y == ", y , " which is <= 0\n");
-
-          return log(y);
-     }
-}
-
-bool print_for(void)
-{     bool ok = true;
-     using CppAD::PrintFor;
-     std::stringstream stream_out;
-
-     // independent variable vector
-     size_t n = 1;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 1.;         // value of the independent variable during recording
-     Independent(ax);
-
-     // A log evaluations that is OK when x[0] = 1 but not when x[0] = 2.
-     AD<double> var     = 2. - ax[0];
-     AD<double> log_var = check_log(var, stream_out);
-     ok &= stream_out.str() == "";
-
-     // dependent variable vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0]    = log_var;
-
-     // define f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // zero order forward with x[0] = 2
-     CPPAD_TESTVECTOR(double) x(n);
-     x[0] = 2.;
-     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";
-
-     return ok;
-}
-
-
Input File: example/general/print_for.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_print_for_string.cpp_xml.js cppad-2019.02.00.0/doc/_print_for_string.cpp_xml.js --- cppad-2018.00.00.0/doc/_print_for_string.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_print_for_string.cpp_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', -'ad.xml', -'convert.xml', -'printfor.xml', -'print_for_string.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 = [ -'value.xml', -'integer.xml', -'ad_to_string.xml', -'ad_input.xml', -'ad_output.xml', -'printfor.xml', -'var2par.xml' -]; -var list_down1 = [ -'print_for_cout.cpp.xml', -'print_for_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-2018.00.00.0/doc/printfor.xml cppad-2019.02.00.0/doc/printfor.xml --- cppad-2018.00.00.0/doc/printfor.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/printfor.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,304 +0,0 @@ - - - -Printing AD Values During Forward Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Printing AD Values During Forward Mode
-
-Syntax - -
- -f.Forward(0, x)
-
- -PrintFor(beforevar)
-
- -PrintFor(posbeforevarafter)
-
-
-Purpose -
-The zero order forward - mode command - -
-     
f.Forward(0, x)
-
-assigns the -independent variable - vector -equal to -x -. -It then computes a value for all of the dependent variables in the -operation sequence - corresponding -to -f -. -Putting a PrintFor in the operation sequence will -cause the value of -var -, corresponding to -x -, -to be printed during zero order forward operations. - -
-
-f.Forward(0, x) -
-The objects -f -, -x -, and the purpose -for this operation, are documented in Forward -. - -
-
-pos -
-If present, the argument -pos - has one of the following prototypes - -
-     const AD<
Base>&               pos
-     const VecAD<
Base>::reference& pos
-
-In this case -the text and -var - will be printed if and only if - -pos - is not greater than zero and a finite number. - -
-
-before -
-The argument -before - has prototype - -
-     const char* 
before
-
-This text is written to std::cout before -var -. - -
-
-var -
-The argument -var - has one of the following prototypes - -
-     const AD<
Base>&               var
-     const VecAD<
Base>::reference& var
-
-The value of -var -, that corresponds to -x -, -is written to std::cout during the execution of - -
-     
f.Forward(0, x)
-
-Note that -var - may be a -variable - or -parameter -. -(A parameters value does not depend on the value of -the independent variable vector -x -.) - -
-
-after -
-The argument -after - has prototype - -
-     const char* 
after
-
-This text is written to std::cout after -var -. - -
-
-Redirecting Output -
-You can redirect this output to any standard output stream; see the -s - in the forward mode documentation. - -
-
-Discussion -
-This is helpful for understanding why tape evaluations -have trouble. -For example, if one of the operations in -f - is - -log(var) - and -var <= 0 -, -the corresponding result will be nan -. - -
-
-Alternative -
-The ad_output - section describes the normal -printing of values; i.e., printing when the corresponding -code is executed. - -
-
-Example - -
-The program -print_for_cout.cpp - -is an example and test that prints to standard output. -The output of this program -states the conditions for passing and failing the test. -The function -print_for_string.cpp - -is an example and test that prints to an standard string stream. -This function automatically check for correct output. - - -
Input File: cppad/core/print_for.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_printfor_xml.js cppad-2019.02.00.0/doc/_printfor_xml.js --- cppad-2018.00.00.0/doc/_printfor_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_printfor_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'convert.xml', -'printfor.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_down0 = [ -'print_for_cout.cpp.xml', -'print_for_string.cpp.xml' -]; -var list_current0 = [ -'printfor.xml#Syntax', -'printfor.xml#Purpose', -'printfor.xml#f.Forward(0, x)', -'printfor.xml#pos', -'printfor.xml#before', -'printfor.xml#var', -'printfor.xml#after', -'printfor.xml#Redirecting Output', -'printfor.xml#Discussion', -'printfor.xml#Alternative', -'printfor.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-2018.00.00.0/doc/qp_box.cpp.xml cppad-2019.02.00.0/doc/qp_box.cpp.xml --- cppad-2018.00.00.0/doc/qp_box.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/qp_box.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,204 +0,0 @@ - - - -abs_normal qp_box: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -qp_box.cpp - -

- - - -
abs_normal qp_box: Example and Test
-
-Problem -
-Our original problem is - - - -minimize - - -x -0 - -- -x -1 - - -w -. -r -. -t - - -x - -R - -2 - - -subject - -to - - --2 - -x -0 - - -+ -2 - -and - - --2 - -x -1 - - -+ -2 - - - -
-Source - -

-# include <limits>
-# include <cppad/utility/vector.hpp>
-# include "qp_box.hpp"
-
-bool qp_box(void)
-{     bool ok = true;
-     typedef CppAD::vector<double> vector;
-     //
-     size_t n = 2;
-     size_t m = 0;
-     vector a(n), b(n), c(m), C(m), g(n), G(n*n), xin(n), xout(n);
-     a[0] = -2.0;
-     a[1] = -2.0;
-     b[0] = +2.0;
-     b[1] = +2.0;
-     g[0] = +1.0;
-     g[1] = -1.0;
-     for(size_t i = 0; i < n * n; i++)
-          G[i] = 0.0;
-     //
-     // (0, 0) is feasible.
-     xin[0] = 0.0;
-     xin[1] = 0.0;
-     //
-     size_t level   = 0;
-     double epsilon = 99.0 * std::numeric_limits<double>::epsilon();
-     size_t maxitr  = 20;
-     //
-     ok &= CppAD::qp_box(
-          level, a, b, c, C, g, G, epsilon, maxitr, xin, xout
-     );
-     //
-     // check optimal value for x
-     ok &= std::fabs( xout[0] + 2.0 ) < epsilon;
-     ok &= std::fabs( xout[1] - 2.0 ) < epsilon;
-     //
-     return ok;
-}
- -
Input File: example/abs_normal/qp_box.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_qp_box.cpp_xml.js cppad-2019.02.00.0/doc/_qp_box.cpp_xml.js --- cppad-2018.00.00.0/doc/_qp_box.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_qp_box.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'qp_box.xml', -'qp_box.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'qp_box.cpp.xml', -'qp_box.hpp.xml' -]; -var list_current0 = [ -'qp_box.cpp.xml#Problem', -'qp_box.cpp.xml#Source' -]; -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-2018.00.00.0/doc/qp_box.hpp.xml cppad-2019.02.00.0/doc/qp_box.hpp.xml --- cppad-2018.00.00.0/doc/qp_box.hpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/qp_box.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,194 +0,0 @@ - - - -qp_box Source Code - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -qp_box.hppHeadings

-
qp_box Source Code
-
namespace CppAD { // BEGIN_CPPAD_NAMESPACE
-
-// BEGIN PROTOTYPE
-template <class Vector>
-bool qp_box(
-     size_t        level   ,
-     const Vector& a       ,
-     const Vector& b       ,
-     const Vector& c       ,
-     const Vector& C       ,
-     const Vector& g       ,
-     const Vector& G       ,
-     double        epsilon ,
-     size_t        maxitr  ,
-     const Vector& xin     ,
-     Vector&       xout    )
-// END PROTOTYPE
-{     double inf = std::numeric_limits<double>::infinity();
-     //
-     size_t n = a.size();
-     size_t m = c.size();
-     //
-     CPPAD_ASSERT_KNOWN(level <= 2, "qp_interior: level is greater than 2");
-     CPPAD_ASSERT_KNOWN(
-          size_t(b.size()) == n, "qp_box: size of b is not n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(C.size()) == m * n, "qp_box: size of C is not m * n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(g.size()) == n, "qp_box: size of g is not n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(G.size()) == n * n, "qp_box: size of G is not n * n"
-     );
-     if( level > 0 )
-     {     std::cout << "start qp_box\n";
-          CppAD::abs_print_mat("a", n, 1, a);
-          CppAD::abs_print_mat("b", n, 1, b);
-          CppAD::abs_print_mat("c", m, 1, c);
-          CppAD::abs_print_mat("C", m, n, C);
-          CppAD::abs_print_mat("g", 1, n, g);
-          CppAD::abs_print_mat("G", n, n, G);
-          CppAD::abs_print_mat("xin", n, 1, xin);
-     }
-     //
-     // count number of lower and upper limits
-     size_t n_limit = 0;
-     for(size_t j = 0; j < n; j++)
-     {     CPPAD_ASSERT_KNOWN(G[j * n + j] >= 0.0, "qp_box: G_{j,j} < 0.0");
-          if( -inf < a[j] )
-               ++n_limit;
-          if( b[j] < inf )
-               ++n_limit;
-     }
-     //
-     // C_int and c_int define the extended constraints
-     Vector C_int((m + n_limit) * n ), c_int(m + n_limit);
-     for(size_t i = 0; i < size_t(C_int.size()); i++)
-          C_int[i] = 0.0;
-     //
-     // put C * x + c <= 0 in C_int, c_int
-     for(size_t i = 0; i < m; i++)
-     {     c_int[i] = c[i];
-          for(size_t j = 0; j < n; j++)
-               C_int[i * n + j] = C[i * n + j];
-     }
-     //
-     // put I * x - b <= 0 in C_int, c_int
-     size_t i_limit = 0;
-     for(size_t j = 0; j < n; j++) if( b[j] < inf )
-     {     c_int[m + i_limit]            = - b[j];
-          C_int[(m + i_limit) * n + j]  = 1.0;
-          ++i_limit;
-     }
-     //
-     // put a - I * x <= 0 in C_int, c_int
-     for(size_t j = 0; j < n; j++) if( -inf < a[j] )
-     {     c_int[m + i_limit]           = a[j];
-          C_int[(m + i_limit) * n + j] = -1.0;
-          ++i_limit;
-     }
-     Vector yout(m + n_limit), sout(m + n_limit);
-     size_t level_int = 0;
-     if( level == 2 )
-          level_int = 1;
-     bool ok = qp_interior( level_int,
-          c_int, C_int, g, G, epsilon, maxitr, xin, xout, yout, sout
-     );
-     if( level > 0 )
-     {     if( level < 2 )
-               CppAD::abs_print_mat("xout", n, 1, xout);
-          if( ok )
-               std::cout << "end q_box: ok = true\n";
-          else
-               std::cout << "end q_box: ok = false\n";
-     }
-     return ok;
-}
-
-} // END_CPPAD_NAMESPACE
- -
Input File: example/abs_normal/qp_box.omh - - - diff -Nru cppad-2018.00.00.0/doc/_qp_box.hpp_xml.js cppad-2019.02.00.0/doc/_qp_box.hpp_xml.js --- cppad-2018.00.00.0/doc/_qp_box.hpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_qp_box.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'qp_box.xml', -'qp_box.hpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'qp_box.cpp.xml', -'qp_box.hpp.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-2018.00.00.0/doc/qp_box.xml cppad-2019.02.00.0/doc/qp_box.xml --- cppad-2018.00.00.0/doc/qp_box.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/qp_box.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,956 +0,0 @@ - - - -abs_normal: Solve a Quadratic Program With Box Constraints - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
abs_normal: Solve a Quadratic Program With Box Constraints
-
-Syntax - -
- -ok = qp_box(
-     
levelabcCgGepsilonmaxitrxinxout
-)
- - -
-
-Prototype - -

-template <class Vector>
-bool qp_box(
-     size_t        level   ,
-     const Vector& a       ,
-     const Vector& b       ,
-     const Vector& c       ,
-     const Vector& C       ,
-     const Vector& g       ,
-     const Vector& G       ,
-     double        epsilon ,
-     size_t        maxitr  ,
-     const Vector& xin     ,
-     Vector&       xout    )
-
-Source -
-This following is a link to the source code for this example: -qp_box.hpp -. - -
-
-Purpose -
-This routine could be used to create a version of abs_min_linear - -that solved quadratic programs (instead of linear programs). - -
-
-Problem -
-We are given - - -a - -R - -n - - - -, - - -b - -R - -n - - - -, - - -c - -R - -m - - - -, - - -C - -R - -m -× -n - - - - -, - - -g - -R - -n - - - -, - - -G - -R - -n -× -n - - - - -, -where - -G - - - is positive semi-definite. -This routine solves the problem - - - -minimize - - -1 - -2 - - -x -T - -G -x -+ -g -T - -x - -w -. -r -. -t - - -x - -R - -n - - -subject - -to - - -C -x -+ -c - -0 - -and - - -a - -x - -b - - - -The matrix - -G -+ -C -T - -C - - - must be positive definite on components -of the vector - -x - - - where the lower limit minus infinity -and the upper limit is plus infinity; see -a - and -b - below. - -
-
-Vector -
-The type -Vector - is a -simple vector with elements of type double. - -
-
-level -
-This value is less that or equal two. -If -level == 0 -, -no tracing is printed. -If -level >= 1 -, -a trace of the qp_box operations is printed. -If -level == 2 -, -a trace of the qp_interior - sub-problem is printed. - -
-
-a -
-This is the vector of lower limits for - -x - - - in the problem. -If -a[j] - is minus infinity, there is no lower limit -for - -x -j - - - -. - -
-
-b -
-This is the vector of upper limits for - -x - - - in the problem. -If -a[j] - is plus infinity, there is no upper limit -for - -x -j - - - -. - -
-
-c -
-This is the value of the inequality constraint function at - -x -= -0 - - -. - -
-
-C -
-This is a row-major - representation -of thee the inequality constraint matrix - -C - - -. - -
-
-g -
-This is the gradient of the objective function. - -
-
-G -
-This is a row-major representation of the Hessian of the objective function. -For - -j -= -0 -, - -, -n --1 - - -, - - -- - -< -a -j - - - - or - - -b -j - -< -+ - - - - or - - -G -j -, -j - - -> -0.0 - - -. - -
-
-epsilon -
-This argument is the convergence criteria; -see KKT conditions - below. -It must be greater than zero. - -
-
-maxitr -
-This is the maximum number of -qp_interior - iterations to try before giving up -on convergence. - -
-
-xin -
-This argument has size -n - and is the initial point for the algorithm. -It must strictly satisfy the constraints; i.e., - -
-     
a < xin,  xin < b,  C * xin - c < 0
-
-
-xout -
-This argument has size is -n - and -the input value of its elements does no matter. -Upon return it is the primal variables - - -x - - - corresponding to the problem solution. - -
-
-ok -
-If the return value -ok - is true, convergence is obtained; i.e., - - -| -F -( -x -, -y -a - -, -s -a - -, -y -b - -, -s -b - -, -y -c - -, -s -c - -) -| - - -< -ε - - -where - -| -v -| - - - - - is the infinity norm of the vector - -v - - -, - - -ε - - - is -epsilon -, - - -x - - - is equal to -xout -, - - -y -a - -, -s -a - - -R - -+ -n - - - -, - - -y -b - -, -s -b - - -R - -+ -n - - - - and - - -y -c - -, -s -c - - -R - -+ -m - - - -. - -
-
-KKT Conditions -
-Give a vector - -v - -R - -m - - - - we define - - -D -( -v -) - -R - -m -× -m - - - - - as the corresponding diagonal matrix. -We also define - -1 -m - - -R - -m - - - - as the vector of ones. -We define - - -F -( -x -, -y -a - -, -s -a - -, -y -b - -, -s -b - -, -y -c - -, -s -c - -) -= -( -g -+ -G -x -- -y -a - -+ -y -b - -+ -y -c -T - -C - -a -+ -s -a - -- -x - -x -+ -s -b - -- -b - -C -x -+ -c -+ -s -c - - -D -( -s -a - -) -D -( -y -a - -) -1 -m - - -D -( -s -b - -) -D -( -y -b - -) -1 -m - - -D -( -s -c - -) -D -( -y -c - -) -1 -m - - -) - - -where - - -x - -R - -n - - - -, - - -y -a - -, -s -a - - -R - -+ -n - - - -, - - -y -b - -, -s -b - - -R - -+ -n - - - - and - - -y -c - -, -s -c - - -R - -+ -m - - - -. -The KKT conditions for a solution of this problem is - - -F -( -x -, -y -a - -, -s -a - -, -y -b - -, -s -b - -, -y -c - -, -s -c - -) -= -0 - - -
-Example -
-The file qp_box.cpp - contains an example and test of -qp_box. -It returns true if the test passes and false otherwise. - - -
Input File: example/abs_normal/qp_box.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_qp_box_xml.js cppad-2019.02.00.0/doc/_qp_box_xml.js --- cppad-2018.00.00.0/doc/_qp_box_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_qp_box_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'qp_box.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down0 = [ -'qp_box.cpp.xml', -'qp_box.hpp.xml' -]; -var list_current0 = [ -'qp_box.xml#Syntax', -'qp_box.xml#Prototype', -'qp_box.xml#Source', -'qp_box.xml#Purpose', -'qp_box.xml#Problem', -'qp_box.xml#Vector', -'qp_box.xml#level', -'qp_box.xml#a', -'qp_box.xml#b', -'qp_box.xml#c', -'qp_box.xml#C', -'qp_box.xml#g', -'qp_box.xml#G', -'qp_box.xml#epsilon', -'qp_box.xml#maxitr', -'qp_box.xml#xin', -'qp_box.xml#xout', -'qp_box.xml#ok', -'qp_box.xml#KKT Conditions', -'qp_box.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-2018.00.00.0/doc/qp_interior.cpp.xml cppad-2019.02.00.0/doc/qp_interior.cpp.xml --- cppad-2018.00.00.0/doc/qp_interior.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/qp_interior.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,304 +0,0 @@ - - - -abs_normal qp_interior: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -qp_interior.cpp - -

- - - -
abs_normal qp_interior: Example and Test
-
-Problem -
-Our original problem is - - -minimize - - -| -u -- -1 -| - -w -. -r -. -t - - -u - -R - - - -We reformulate this as the following problem - - - -minimize - - -v - -w -. -r -. -t - - -( -u -, -v -) - -R - -2 - - -subject - -to - - -u -- -1 - -v - - -1 -- -u - -v - - - -This is equivalent to - - - -minimize - - -( -0 -, -1 -) -· -( -u -, -v -) -T - - -w -. -r -. -t - - -( -u -, -v -) - -R - -2 - - -subject - -to - - -( -1 - --1 - --1 - --1 - -) -( -u - -v - -) -+ -( --1 - -1 - -) - -0 - - - -which is in the form expected by qp_interior -. - - -
-
-Source - -

-# include <limits>
-# include <cppad/utility/vector.hpp>
-# include "qp_interior.hpp"
-
-bool qp_interior(void)
-{     bool ok = true;
-     typedef CppAD::vector<double> vector;
-     //
-     size_t n = 2;
-     size_t m = 2;
-     vector C(m*n), c(m), G(n*n), g(n), xin(n), xout(n), yout(m), sout(m);
-     C[ 0 * n + 0 ] =  1.0; // C(0,0)
-     C[ 0 * n + 1 ] = -1.0; // C(0,1)
-     C[ 1 * n + 0 ] = -1.0; // C(1,0)
-     C[ 1 * n + 1 ] = -1.0; // C(1,1)
-     //
-     c[0]           = -1.0;
-     c[1]           =  1.0;
-     //
-     g[0]           =  0.0;
-     g[1]           =  1.0;
-     //
-     // G = 0
-     for(size_t i = 0; i < n * n; i++)
-          G[i] = 0.0;
-     //
-     // If (u, v) = (0,2), C * (u, v) + c = (-2,-2)^T + (1,-1)^T < 0
-     // Hence (0, 2) is feasible.
-     xin[0] = 0.0;
-     xin[1] = 2.0;
-     //
-     double epsilon = 99.0 * std::numeric_limits<double>::epsilon();
-     size_t maxitr  = 10;
-     size_t level   = 0;
-     //
-     ok &= CppAD::qp_interior(
-          level, c, C, g, G, epsilon, maxitr, xin, xout, yout, sout
-     );
-     //
-     // check optimal value for u
-     ok &= std::fabs( xout[0] - 1.0 ) < epsilon;
-     // check optimal value for v
-     ok &= std::fabs( xout[1] ) < epsilon;
-     //
-     return ok;
-}
- -
Input File: example/abs_normal/qp_interior.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_qp_interior.cpp_xml.js cppad-2019.02.00.0/doc/_qp_interior.cpp_xml.js --- cppad-2018.00.00.0/doc/_qp_interior.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_qp_interior.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'qp_interior.xml', -'qp_interior.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'qp_interior.cpp.xml', -'qp_interior.hpp.xml' -]; -var list_current0 = [ -'qp_interior.cpp.xml#Problem', -'qp_interior.cpp.xml#Source' -]; -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-2018.00.00.0/doc/qp_interior.hpp.xml cppad-2019.02.00.0/doc/qp_interior.hpp.xml --- cppad-2018.00.00.0/doc/qp_interior.hpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/qp_interior.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,397 +0,0 @@ - - - -qp_interior Source Code - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -qp_interior.hppHeadings

-
qp_interior Source Code
-
namespace {
-     // ------------------------------------------------------------------------
-     template <class Vector>
-     double qp_interior_max_abs(const Vector& v)
-     {     double max_abs = 0.0;
-          for(size_t j = 0; j < size_t(v.size()); j++)
-               max_abs = std::max( max_abs, std::fabs(v[j]) );
-          return max_abs;
-     }
-     // ------------------------------------------------------------------------
-     template <class Vector>
-     void qp_interior_split(
-          const Vector& v, Vector& v_x, Vector& v_y, Vector& v_s
-     )
-     {     size_t n = v_x.size();
-          size_t m = v_y.size();
-          CPPAD_ASSERT_UNKNOWN( size_t(v_s.size()) == m );
-          CPPAD_ASSERT_UNKNOWN( size_t(v.size()) == n + m + m );
-          for(size_t i = 0; i < n; i++)
-               v_x[i] = v[i];
-          for(size_t i = 0; i < m; i++)
-          {     v_y[i] = v[n + i];
-               v_s[i] = v[n + m + i];
-          }
-          return;
-     }
-     // ------------------------------------------------------------------------
-     template <class Vector>
-     void qp_interior_join(
-          Vector& v, const Vector& v_x, const Vector& v_y, const Vector& v_s
-     )
-     {     size_t n = v_x.size();
-          size_t m = v_y.size();
-          CPPAD_ASSERT_UNKNOWN( size_t(v_s.size()) == m );
-          CPPAD_ASSERT_UNKNOWN( size_t(v.size()) == n + m + m );
-          for(size_t i = 0; i < n; i++)
-               v[i] = v_x[i];
-          for(size_t i = 0; i < m; i++)
-               v[n + i] = v_y[i];
-          for(size_t i = 0; i < m; i++)
-               v[n + m + i] = v_s[i];
-          return;
-     }
-     // ------------------------------------------------------------------------
-     template <class Vector>
-     Vector qp_interior_F_0(
-          const Vector& c       ,
-          const Vector& C       ,
-          const Vector& g       ,
-          const Vector& G       ,
-          const Vector& x       ,
-          const Vector& y       ,
-          const Vector& s       )
-     {     size_t n = g.size();
-          size_t m = c.size();
-          // compute r_x(x, y, s) = g + G x + y^T C
-          Vector r_x(n);
-          for(size_t j = 0; j < n; j++)
-          {     r_x[j] = g[j];
-               for(size_t i = 0; i < n; i++)
-                    r_x[j] += G[j * n + i] * x[i];
-               for(size_t i = 0; i < m; i++)
-                    r_x[j] += y[i] * C[i * n + j];
-          }
-          // compute r_y(x, y, s) = C x + c + s
-          Vector r_y(m);
-          for(size_t i = 0; i < m; i++)
-          {     r_y[i] = c[i] + s[i];
-               for(size_t j = 0; j < n; j++)
-                    r_y[i] += C[i * n + j] * x[j];
-          }
-          // compute r_s(x, y, s) = D(s) * D(y) * 1_m - mu * 1_m
-          // where mu = 0
-          Vector r_s(m);
-          for(size_t i = 0; i < m; i++)
-               r_s[i] = s[i] * y[i];
-          //
-          // combine into one vector
-          Vector F_0(n + m + m);
-          qp_interior_join(F_0, r_x, r_y, r_s);
-          //
-          return F_0;
-     }
-}
-// BEGIN C++
-namespace CppAD { // BEGIN_CPPAD_NAMESPACE
-
-// BEGIN PROTOTYPE
-template <class Vector>
-bool qp_interior(
-     size_t        level   ,
-     const Vector& c       ,
-     const Vector& C       ,
-     const Vector& g       ,
-     const Vector& G       ,
-     double        epsilon ,
-     size_t        maxitr  ,
-     const Vector& xin     ,
-     Vector&       xout    ,
-     Vector&       yout    ,
-     Vector&       sout    )
-// END PROTOTYPE
-{     size_t m = c.size();
-     size_t n = g.size();
-     CPPAD_ASSERT_KNOWN(
-          level <= 1,
-          "qp_interior: level is greater than one"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(C.size()) == m * n,
-          "qp_interior: size of C is not m * n"
-     );
-     CPPAD_ASSERT_KNOWN(
-          size_t(G.size()) == n * n,
-          "qp_interior: size of G is not n * n"
-     );
-     if( level > 0 )
-     {     std::cout << "start qp_interior\n";
-          CppAD::abs_print_mat("c", m, 1, c);
-          CppAD::abs_print_mat("C", m, n, C);
-          CppAD::abs_print_mat("g", n, 1, g);
-          CppAD::abs_print_mat("G", n, n, G);
-          CppAD::abs_print_mat("xin", n, 1, xin);
-     }
-     //
-     // compute the maximum absolute element of the problem vectors and matrices
-     double max_element = 0.0;
-     for(size_t i = 0; i < size_t(C.size()); i++)
-          max_element = std::max(max_element , std::fabs(C[i]) );
-     for(size_t i = 0; i < size_t(c.size()); i++)
-          max_element = std::max(max_element , std::fabs(c[i]) );
-     for(size_t i = 0; i < size_t(G.size()); i++)
-          max_element = std::max(max_element , std::fabs(G[i]) );
-     for(size_t i = 0; i < size_t(g.size()); i++)
-          max_element = std::max(max_element , std::fabs(g[i]) );
-     //
-     double mu = 1e-1 * max_element;
-     //
-     if( max_element == 0.0 )
-     {     if( level > 0 )
-               std::cout << "end qp_interior: line_search failed\n";
-          return false;
-     }
-     //
-     // initialize x, y, s
-     xout = xin;
-     for(size_t i = 0; i < m; i++)
-     {     double sum = c[i];
-          for(size_t j = 0; j < n; j++)
-               sum += C[ i * n + j ] * xout[j];
-          if( sum > 0.0 )
-          {     if( level > 0 ) std::cout <<
-                    "end qp_interior: xin is not in interior of feasible set\n";
-               return false;
-          }
-          //
-          sout[i] = std::sqrt(mu);
-          yout[i] = std::sqrt(mu);
-     }
-     // ----------------------------------------------------------------------
-     // initialie F_0(xout, yout, sout)
-     Vector F_0       = qp_interior_F_0(c, C, g, G, xout, yout, sout);
-     double F_max_abs = qp_interior_max_abs( F_0 );
-     for(size_t itr = 0; itr <= maxitr; itr++)
-     {
-          // check for convergence
-          if( F_max_abs <= epsilon )
-          {     if( level > 0 )
-                    std::cout << "end qp_interior: ok = true\n";
-               return true;
-          }
-          if( itr == maxitr )
-          {     if( level > 0 ) std::cout <<
-                    "end qp_interior: max # iterations without convergence\n";
-               return false;
-          }
-          //
-          // compute F_mu(xout, yout, sout)
-          Vector F_mu  = F_0;
-          for(size_t i = 0; i < m; i++)
-               F_mu[n + m + i] -= mu;
-          //
-          // r_x, r_y, r_s (xout, yout, sout)
-          Vector r_x(n), r_y(m), r_s(m);
-          qp_interior_split(F_mu, r_x, r_y, r_s);
-          //
-          // tmp_m = D(s)^{-1} * [ r_s - D(y) r_y ]
-          Vector tmp_m(m);
-          for(size_t i = 0; i < m; i++)
-               tmp_m[i]  = ( r_s[i] - yout[i] * r_y[i] ) / sout[i];
-          //
-          // right_x = C^T * D(s)^{-1} * [ r_s - D(y) r_y ] - r_x
-          Vector right_x(n);
-          for(size_t j = 0; j < n; j++)
-          {     right_x[j] = 0.0;
-               for(size_t i = 0; i < m; i++)
-                    right_x[j] += C[ i * n + j ] * tmp_m[i];
-               right_x[j] -= r_x[j];
-          }
-          //
-          // Left_x = G + C^T * D(y / s) * C
-          Vector Left_x = G;
-          for(size_t i = 0; i < n; i++)
-          {     for(size_t j = 0; j < n; j++)
-               {     for(size_t k = 0; k < m; k++)
-                    {     double y_s = yout[k] / sout[k];
-                         Left_x[ i * n + j] += C[k * n + j] * y_s * C[k * n + i];
-                    }
-               }
-          }
-          // delta_x
-          Vector delta_x(n);
-          double logdet;
-          LuSolve(n, 1, Left_x, right_x, delta_x, logdet);
-          //
-          // C_delta_x = C * delta_x
-          Vector C_delta_x(m);
-          for(size_t i = 0; i < m; i++)
-          {     C_delta_x[i] = 0.0;
-               for(size_t j = 0; j < n; j++)
-                    C_delta_x[i] += C[ i * n + j ] * delta_x[j];
-          }
-          //
-          // delta_y = D(s)^-1 * [D(y) * r_y - r_s + D(y) * C * delta_x]
-          Vector delta_y(m);
-          for(size_t i = 0; i < m; i++)
-          {     delta_y[i] = yout[i] * r_y[i] - r_s[i] + yout[i] * C_delta_x[i];
-               delta_y[i] /= sout[i];
-          }
-          // delta_s = - r_y - C * delta_x
-          Vector delta_s(m);
-          for(size_t i = 0; i < m; i++)
-               delta_s[i] = - r_y[i] - C_delta_x[i];
-          //
-          // delta_xys
-          Vector delta_xys(n + m + m);
-          qp_interior_join(delta_xys, delta_x, delta_y, delta_s);
-          // -------------------------------------------------------------------
-          //
-          // The initial derivative in direction  Delta_xys is equal to
-          // the negative of the norm square of F_mu
-          //
-          // line search parameter lam
-          Vector x(n), y(m), s(m);
-          double  lam = 2.0;
-          bool lam_ok = false;
-          while( ! lam_ok && lam > 1e-5 )
-          {     lam = lam / 2.0;
-               for(size_t j = 0; j < n; j++)
-                    x[j] = xout[j] + lam * delta_xys[j];
-               lam_ok = true;
-               for(size_t i = 0; i < m; i++)
-               {     y[i] = yout[i] + lam * delta_xys[n + i];
-                    s[i] = sout[i] + lam * delta_xys[n + m + i];
-                    lam_ok &= s[i] > 0.0 && y[i] > 0.0;
-               }
-               if( lam_ok )
-               {     Vector F_mu_tmp = qp_interior_F_0(c, C, g, G, x, y, s);
-                    for(size_t i = 0; i < m; i++)
-                         F_mu_tmp[n + m + i] -= mu;
-                    // avoid cancellation roundoff in difference of norm squared
-                    // |v + dv|^2         = v^T * v + 2 * v^T * dv + dv^T * dv
-                    // |v + dv|^2 - |v|^2 =           2 * v^T * dv + dv^T * dv
-                    double F_norm_sq    = 0.0;
-                    double diff_norm_sq = 0.0;
-                    for(size_t i = 0; i < n + m + m; i++)
-                    {     double dv     = F_mu_tmp[i] - F_mu[i];
-                         F_norm_sq    += F_mu[i] * F_mu[i];
-                         diff_norm_sq += 2.0 * F_mu[i] * dv + dv * dv;
-                    }
-                    lam_ok &= diff_norm_sq < - lam * F_norm_sq / 4.0;
-               }
-          }
-          if( ! lam_ok )
-          {     if( level > 0 )
-                    std::cout << "end qp_interior: line search failed\n";
-               return false;
-          }
-          //
-          // update current solution
-          xout = x;
-          yout = y;
-          sout = s;
-          //
-          // updage F_0
-          F_0       = qp_interior_F_0(c, C, g, G, xout, yout, sout);
-          F_max_abs = qp_interior_max_abs( F_0 );
-          //
-          // update mu
-          if( F_max_abs <= 1e1 *  mu )
-               mu = mu / 1e2;
-          if( level > 0 )
-          {     std::cout << "itr = " << itr
-                    << ", mu = " << mu
-                    << ", lam = " << lam
-                    << ", F_max_abs = " << F_max_abs << "\n";
-               abs_print_mat("xout", 1, n, xout);
-          }
-     }
-     if( level > 0 )
-          std::cout << "end qp_interior: progam error\n";
-     return false;
-}
-} // END_CPPAD_NAMESPACE
- -
Input File: example/abs_normal/qp_interior.omh - - - diff -Nru cppad-2018.00.00.0/doc/_qp_interior.hpp_xml.js cppad-2019.02.00.0/doc/_qp_interior.hpp_xml.js --- cppad-2018.00.00.0/doc/_qp_interior.hpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_qp_interior.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'qp_interior.xml', -'qp_interior.hpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'qp_interior.cpp.xml', -'qp_interior.hpp.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-2018.00.00.0/doc/qp_interior.xml cppad-2019.02.00.0/doc/qp_interior.xml --- cppad-2018.00.00.0/doc/qp_interior.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/qp_interior.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1637 +0,0 @@ - - - -Solve a Quadratic Program Using Interior Point Method - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Solve a Quadratic Program Using Interior Point Method
-
-Syntax - -
- -ok = qp_interior(
-
levelcCgGepsilonmaxitrxinxoutyoutsout
-)
- - -
-
-Prototype - -

-template <class Vector>
-bool qp_interior(
-     size_t        level   ,
-     const Vector& c       ,
-     const Vector& C       ,
-     const Vector& g       ,
-     const Vector& G       ,
-     double        epsilon ,
-     size_t        maxitr  ,
-     const Vector& xin     ,
-     Vector&       xout    ,
-     Vector&       yout    ,
-     Vector&       sout    )
-
-Source -
-This following is a link to the source code for this example: -qp_interior.hpp -. - -
-
-Purpose -
-This routine could be used to create a version of abs_min_linear - -that solved Quadratic programs (instead of linear programs). - -
-
-Problem -
-We are given - - -C - -R - -m -× -n - - - - -, - - -c - -R - -m - - - -, - - -G - -R - -n -× -n - - - - -, - - -g - -R - -n - - - -, -where - -G - - - is positive semi-definite -and - -G -+ -C -T - -C - - - is positive definite. -This routine solves the problem - - - -minimize - - -1 - -2 - - -x -T - -G -x -+ -g -T - -x - -w -. -r -. -t - - -x - -R - -n - - -subject - -to - - -C -x -+ -c - -0 - - - -
-Vector -
-The type -Vector - is a -simple vector with elements of type double. - -
-
-level -
-This value is zero or one. -If -level == 0 -, -no tracing is printed. -If -level == 1 -, -a trace of the qp_interior optimization is printed. - -
-
-c -
-This is the vector - -c - - - in the problem. - -
-
-C -
-This is a row-major - -of the matrix - -C - - - in the problem. - -
-
-g -
-This is the vector - -g - - - in the problem. - -
-
-G -
-This is a row-major - -of the matrix - -G - - - in the problem. - -
-
-epsilon -
-This argument is the convergence criteria; -see KKT conditions - below. -It must be greater than zero. - -
-
-maxitr -
-This is the maximum number of newton iterations to try before giving up -on convergence. - -
-
-xin -
-This argument has size -n - and is the initial point for the algorithm. -It must strictly satisfy the constraints; i.e., - - -C -x -- -c -< -0 - - - for -x = xin -. - -
-
-xout -
-This argument has size is -n - and -the input value of its elements does no matter. -Upon return it is the primal variables corresponding to the problem solution. - -
-
-yout -
-This argument has size is -m - and -the input value of its elements does no matter. -Upon return it the components of -yout - are all positive -and it is the dual variables corresponding to the program solution. - -
-
-sout -
-This argument has size is -m - and -the input value of its elements does no matter. -Upon return it the components of -sout - are all positive -and it is the slack variables corresponding to the program solution. - -
-
-ok -
-If the return value -ok - is true, convergence is obtained; i.e., - - -| -F -0 - -( -xout -, -yout -, -sout -) -| - - - -epsilon - - -where - -| -v -| - - - - - is the maximum absolute element -for the vector - -v - - - and - -F -μ - -( -x -, -y -, -s -) - - - is defined below. - - -
-
-KKT Conditions -
-Give a vector - -v - -R - -m - - - - we define - - -D -( -v -) - -R - -m -× -m - - - - - as the corresponding diagonal matrix. -We also define - -1 -m - - -R - -m - - - - as the vector of ones. -We define - - -F -μ - -: -R - -n -+ -m -+ -m - - - -R - -n -+ -m -+ -m - - - - - -by - - -F -μ - -( -x -, -y -, -s -) -= -( -g -+ -G -x -+ -y -T - -C - -C -x -+ -c -+ -s - -D -( -s -) -D -( -y -) -1 -m - -- -μ -1 -m - - -) - - -The KKT conditions for a solution of this problem is - - -0 - -y - - -, - - -0 - -s - - -, and - - -F -0 - -( -x -, -y -, -s -) -= -0 - - -. - -
-
-Newton Step -
-The derivative of - -F -μ - - - - is given by - - -F -μ -( -1 -) - - -( -x -, -y -, -s -) -= -( -G - -C -T - - -0 -n -, -m - - - -C - -0 - -I -m -, -m - - - -0 -m -, -m - - - -D -( -s -) - -D -( -y -) - -) - - -The Newton step solves the following equation for - - -Δ -x - - -, - -Δ -y - - -, and - -Δ -z - - - - - -F -μ -( -1 -) - - -( -x -, -y -, -s -) -( -Δ -x - -Δ -y - -Δ -s - -) -= -- -F -μ - -( -x -, -y -, -s -) - - -To simplify notation, we define - - - -r -x - -( -x -, -y -, -s -) - -= - -g -+ -G -x -+ -y -T - -C - -r -y - -( -x -, -y -, -s -) - -= - -C -x -+ -c -+ -s - -r -s - -( -x -, -y -, -s -) - -= - -D -( -s -) -D -( -y -) -1 -m - -- -μ -1 -m - - - - -It follows that - - -( -G - -C -T - - -0 -n -, -m - - - -C - -0 - -I -m -, -m - - - -0 -m -, -m - - - -D -( -s -) - -D -( -y -) - -) -( -Δ -x - -Δ -y - -Δ -s - -) -= -- -( -r -x - -( -x -, -y -, -s -) - -r -y - -( -x -, -y -, -s -) - -r -s - -( -x -, -y -, -s -) - -) - - -
-Elementary Row Reduction -
-Subtracting - -D -( -y -) - - - times the second row from the third row -we obtain: - - -( -G - -C -T - - -0 -n -, -m - - - -C - -0 - -I -m -, -m - - - -- -D -( -y -) -C - -D -( -s -) - -0 -m -, -m - - - -) -( -Δ -x - -Δ -y - -Δ -s - -) -= -- -( -r -x - -( -x -, -y -, -s -) - -r -y - -( -x -, -y -, -s -) - -r -s - -( -x -, -y -, -s -) -- -D -( -y -) -r -y - -( -x -, -y -, -s -) - -) - - -Multiplying the third row by - -D -( -s -) --1 - - - - - we obtain: - - -( -G - -C -T - - -0 -n -, -m - - - -C - -0 - -I -m -, -m - - - -- -D -( -y -/ -s -) -C - -I -m -, -m - - - -0 -m -, -m - - - -) -( -Δ -x - -Δ -y - -Δ -s - -) -= -- -( -r -x - -( -x -, -y -, -s -) - -r -y - -( -x -, -y -, -s -) - -D -( -s -) --1 - - -r -s - -( -x -, -y -, -s -) -- -D -( -y -/ -s -) -r -y - -( -x -, -y -, -s -) - -) - - -where - -y -/ -s - - - is the vector in - -R - -m - - - - defined by - - -( -y -/ -s -) -i - -= -y -i - -/ -s -i - - - -. -Subtracting - -C -T - - - - times the third row from the first row we obtain: - - -( -G -+ -C -T - -D -( -y -/ -s -) -C - -0 -n -, -m - - - -0 -n -, -m - - - -C - -0 - -I -m -, -m - - - -- -D -( -y -/ -s -) -C - -I -m -, -m - - - -0 -m -, -m - - - -) -( -Δ -x - -Δ -y - -Δ -s - -) -= -- -( -r -x - -( -x -, -y -, -s -) -- -C -T - -D -( -s -) --1 - - -[r -s - -( -x -, -y -, -s -) -- -D -( -y -) -r -y - -( -x -, -y -, -s -) -] - -r -y - -( -x -, -y -, -s -) - -D -( -s -) --1 - - -r -s - -( -x -, -y -, -s -) -- -D -( -y -/ -s -) -r -y - -( -x -, -y -, -s -) - -) - - -
-Solution -
-It follows that - -G -+ -C -T - -D -( -y -/ -s -) -C - - - is invertible and -we can determine - -Δ -x - - - by solving the equation - - -[ -G -+ -C -T - -D -( -y -/ -s -) -C -] -Δ -x -= -C -T - -D -( -s -) --1 - - -[r -s - -( -x -, -y -, -s -) -- -D -( -y -) -r -y - -( -x -, -y -, -s -) -] -- -r -x - -( -x -, -y -, -s -) - - -Given - -Δ -x - - - we have that - - -Δ -s -= -- -r -y - -( -x -, -y -, -s -) -- -C -Δ -x - - - - -Δ -y -= -D -( -s -) --1 - - -[ -D -( -y -) -r -y - -( -x -, -y -, -s -) -- -r -s - -( -x -, -y -, -s -) -+ -D -( -y -) -C -Δ -x -] - - -
-Example -
-The file qp_interior.cpp - contains an example and test of -qp_interior. -It returns true if the test passes and false otherwise. - - -
Input File: example/abs_normal/qp_interior.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_qp_interior_xml.js cppad-2019.02.00.0/doc/_qp_interior_xml.js --- cppad-2018.00.00.0/doc/_qp_interior_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_qp_interior_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'qp_interior.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down0 = [ -'qp_interior.cpp.xml', -'qp_interior.hpp.xml' -]; -var list_current0 = [ -'qp_interior.xml#Syntax', -'qp_interior.xml#Prototype', -'qp_interior.xml#Source', -'qp_interior.xml#Purpose', -'qp_interior.xml#Problem', -'qp_interior.xml#Vector', -'qp_interior.xml#level', -'qp_interior.xml#c', -'qp_interior.xml#C', -'qp_interior.xml#g', -'qp_interior.xml#G', -'qp_interior.xml#epsilon', -'qp_interior.xml#maxitr', -'qp_interior.xml#xin', -'qp_interior.xml#xout', -'qp_interior.xml#yout', -'qp_interior.xml#sout', -'qp_interior.xml#ok', -'qp_interior.xml#KKT Conditions', -'qp_interior.xml#Newton Step', -'qp_interior.xml#Newton Step.Elementary Row Reduction', -'qp_interior.xml#Solution', -'qp_interior.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-2018.00.00.0/doc/rc_sparsity.cpp.xml cppad-2019.02.00.0/doc/rc_sparsity.cpp.xml --- cppad-2018.00.00.0/doc/rc_sparsity.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/rc_sparsity.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,431 +0,0 @@ - - - -Preferred Sparsity Patterns: Row and Column Indices: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -rc_sparsity.cpp - -

-
Preferred Sparsity Patterns: Row and Column Indices: Example and Test
-
-Purpose -
-This example show how to use row and column index sparsity patterns -sparse_rc - to compute sparse Jacobians and Hessians. -This became the preferred way to represent sparsity on -2017-02-09 -. - - -
# include <cppad/cppad.hpp>
-namespace {
-     using CppAD::sparse_rc;
-     using CppAD::sparse_rcv;
-     using CppAD::NearEqual;
-     //
-     typedef CPPAD_TESTVECTOR(bool)                b_vector;
-     typedef CPPAD_TESTVECTOR(size_t)              s_vector;
-     typedef CPPAD_TESTVECTOR(double)              d_vector;
-     typedef CPPAD_TESTVECTOR( CppAD::AD<double> ) a_vector;
-     //
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     // -----------------------------------------------------------------------
-     // function f(x) that we are computing sparse results for
-     // -----------------------------------------------------------------------
-     a_vector fun(const a_vector& x)
-     {     size_t n  = x.size();
-          a_vector ret(n + 1);
-          for(size_t i = 0; i < n; i++)
-          {     size_t j = (i + 1) % n;
-               ret[i]     = x[i] * x[i] * x[j];
-          }
-          ret[n] = 0.0;
-          return ret;
-     }
-     // -----------------------------------------------------------------------
-     // Jacobian
-     // -----------------------------------------------------------------------
-     bool check_jac(
-          const d_vector&                       x      ,
-          const sparse_rcv<s_vector, d_vector>& subset )
-     {     bool ok  = true;
-          size_t n = x.size();
-          //
-          ok &= subset.nnz() == 2 * n;
-          const s_vector& row( subset.row() );
-          const s_vector& col( subset.col() );
-          const d_vector& val( subset.val() );
-          s_vector row_major = subset.row_major();
-          for(size_t i = 0; i < n; i++)
-          {     size_t j = (i + 1) % n;
-               size_t k = 2 * i;
-               //
-               ok &= row[ row_major[k] ]   == i;
-               ok &= row[ row_major[k+1] ] == i;
-               //
-               size_t ck  = col[ row_major[k] ];
-               size_t ckp = col[ row_major[k+1] ];
-               double vk  = val[ row_major[k] ];
-               double vkp = val[ row_major[k+1] ];
-               //
-               // put diagonal element first
-               if( j < i )
-               {     std::swap(ck, ckp);
-                    std::swap(vk, vkp);
-               }
-               // diagonal element
-               ok &= ck == i;
-               ok &= NearEqual( vk, 2.0 * x[i] * x[j], eps99, eps99 );
-               // off diagonal element
-               ok &= ckp == j;
-               ok &= NearEqual( vkp, x[i] * x[i], eps99, eps99 );
-          }
-          return ok;
-     }
-     // Use forward mode for Jacobian and sparsity pattern
-     bool forward_jac(CppAD::ADFun<double>& f)
-     {     bool ok = true;
-          size_t n = f.Domain();
-          //
-          // sparsity pattern for identity matrix
-          sparse_rc<s_vector> pattern_in(n, n, n);
-          for(size_t k = 0; k < n; k++)
-               pattern_in.set(k, k, k);
-          //
-          // sparsity pattern for Jacobian
-          bool transpose     = false;
-          bool dependency    = false;
-          bool internal_bool = false;
-          sparse_rc<s_vector> pattern_out;
-          f.for_jac_sparsity(
-               pattern_in, transpose, dependency, internal_bool, pattern_out
-          );
-          //
-          // compute entire Jacobian
-          size_t                         group_max = 1;
-          std::string                    coloring  = "cppad";
-          sparse_rcv<s_vector, d_vector> subset( pattern_out );
-          CppAD::sparse_jac_work         work;
-          d_vector x(n);
-          for(size_t j = 0; j < n; j++)
-               x[j] = double(j + 2);
-          size_t n_sweep = f.sparse_jac_for(
-               group_max, x, subset, pattern_out, coloring, work
-          );
-          //
-          // check Jacobian
-          ok &= check_jac(x, subset);
-          ok &= n_sweep == 2;
-          //
-          return ok;
-     }
-     // Use reverse mode for Jacobian and sparsity pattern
-     bool reverse_jac(CppAD::ADFun<double>& f)
-     {     bool ok = true;
-          size_t n = f.Domain();
-          size_t m = f.Range();
-          //
-          // sparsity pattern for identity matrix
-          sparse_rc<s_vector> pattern_in(m, m, m);
-          for(size_t k = 0; k < m; k++)
-               pattern_in.set(k, k, k);
-          //
-          // sparsity pattern for Jacobian
-          bool transpose     = false;
-          bool dependency    = false;
-          bool internal_bool = false;
-          sparse_rc<s_vector> pattern_out;
-          f.rev_jac_sparsity(
-               pattern_in, transpose, dependency, internal_bool, pattern_out
-          );
-          //
-          // compute entire Jacobian
-          std::string                    coloring  = "cppad";
-          sparse_rcv<s_vector, d_vector> subset( pattern_out );
-          CppAD::sparse_jac_work         work;
-          d_vector x(n);
-          for(size_t j = 0; j < n; j++)
-               x[j] = double(j + 2);
-          size_t n_sweep = f.sparse_jac_rev(
-               x, subset, pattern_out, coloring, work
-          );
-          //
-          // check Jacobian
-          ok &= check_jac(x, subset);
-          ok &= n_sweep == 2;
-          //
-          return ok;
-     }
-     // ------------------------------------------------------------------------
-     // Hessian
-     // ------------------------------------------------------------------------
-     bool check_hes(
-          size_t                                i      ,
-          const d_vector&                       x      ,
-          const sparse_rcv<s_vector, d_vector>& subset )
-     {     bool ok  = true;
-          size_t n = x.size();
-          size_t j = (i + 1) % n;
-          //
-          ok &= subset.nnz() == 3;
-          const s_vector& row( subset.row() );
-          const s_vector& col( subset.col() );
-          const d_vector& val( subset.val() );
-          s_vector row_major = subset.row_major();
-          //
-          double v0 = val[ row_major[0] ];
-          double v1 = val[ row_major[1] ];
-          double v2 = val[ row_major[2] ];
-          if( j < i )
-          {     ok &= row[ row_major[0] ] == j;
-               ok &= col[ row_major[0] ] == i;
-               ok &= NearEqual( v0, 2.0 * x[i], eps99, eps99 );
-               //
-               ok &= row[ row_major[1] ] == i;
-               ok &= col[ row_major[1] ] == j;
-               ok &= NearEqual( v1, 2.0 * x[i], eps99, eps99 );
-               //
-               ok &= row[ row_major[2] ] == i;
-               ok &= col[ row_major[2] ] == i;
-               ok &= NearEqual( v2, 2.0 * x[j], eps99, eps99 );
-          }
-          else
-          {     ok &= row[ row_major[0] ] == i;
-               ok &= col[ row_major[0] ] == i;
-               ok &= NearEqual( v0, 2.0 * x[j], eps99, eps99 );
-               //
-               ok &= row[ row_major[1] ] == i;
-               ok &= col[ row_major[1] ] == j;
-               ok &= NearEqual( v1, 2.0 * x[i], eps99, eps99 );
-               //
-               ok &= row[ row_major[2] ] == j;
-               ok &= col[ row_major[2] ] == i;
-               ok &= NearEqual( v2, 2.0 * x[i], eps99, eps99 );
-          }
-          return ok;
-     }
-     // Use forward mode for Hessian and sparsity pattern
-     bool forward_hes(CppAD::ADFun<double>& f)
-     {     bool ok = true;
-          size_t n = f.Domain();
-          size_t m = f.Range();
-          //
-          b_vector select_domain(n);
-          for(size_t j = 0; j < n; j++)
-               select_domain[j] = true;
-          sparse_rc<s_vector> pattern_out;
-          //
-          for(size_t i = 0; i < m; i++)
-          {     // select i-th component of range
-               b_vector select_range(m);
-               d_vector w(m);
-               for(size_t k = 0; k < m; k++)
-               {     select_range[k] = k == i;
-                    w[k] = 0.0;
-                    if( k == i )
-                         w[k] = 1.0;
-               }
-               //
-               bool internal_bool = false;
-               f.for_hes_sparsity(
-                    select_domain, select_range, internal_bool, pattern_out
-               );
-               //
-               // compute Hessian for i-th component function
-               std::string                    coloring  = "cppad.symmetric";
-               sparse_rcv<s_vector, d_vector> subset( pattern_out );
-               CppAD::sparse_hes_work         work;
-               d_vector x(n);
-               for(size_t j = 0; j < n; j++)
-                    x[j] = double(j + 2);
-               size_t n_sweep = f.sparse_hes(
-                    x, w, subset, pattern_out, coloring, work
-               );
-               //
-               // check Hessian
-               if( i == n )
-                    ok &= subset.nnz() == 0;
-               else
-               {     ok &= check_hes(i, x, subset);
-                    ok &= n_sweep == 1;
-               }
-          }
-          return ok;
-     }
-     // Use reverse mode for Hessian and sparsity pattern
-     bool reverse_hes(CppAD::ADFun<double>& f)
-     {     bool ok = true;
-          size_t n = f.Domain();
-          size_t m = f.Range();
-          //
-          // n by n identity matrix
-          sparse_rc<s_vector> pattern_in(n, n, n);
-          for(size_t j = 0; j < n; j++)
-               pattern_in.set(j, j, j);
-          //
-          bool transpose     = false;
-          bool dependency    = false;
-          bool internal_bool = true;
-          sparse_rc<s_vector> pattern_out;
-          //
-          f.for_jac_sparsity(
-               pattern_in, transpose, dependency, internal_bool, pattern_out
-          );
-          //
-          for(size_t i = 0; i < m; i++)
-          {     // select i-th component of range
-               b_vector select_range(m);
-               d_vector w(m);
-               for(size_t k = 0; k < m; k++)
-               {     select_range[k] = k == i;
-                    w[k] = 0.0;
-                    if( k == i )
-                         w[k] = 1.0;
-               }
-               //
-               f.rev_hes_sparsity(
-                    select_range, transpose, internal_bool, pattern_out
-               );
-               //
-               // compute Hessian for i-th component function
-               std::string                    coloring  = "cppad.symmetric";
-               sparse_rcv<s_vector, d_vector> subset( pattern_out );
-               CppAD::sparse_hes_work         work;
-               d_vector x(n);
-               for(size_t j = 0; j < n; j++)
-                    x[j] = double(j + 2);
-               size_t n_sweep = f.sparse_hes(
-                    x, w, subset, pattern_out, coloring, work
-               );
-               //
-               // check Hessian
-               if( i == n )
-                    ok &= subset.nnz() == 0;
-               else
-               {     ok &= check_hes(i, x, subset);
-                    ok &= n_sweep == 1;
-               }
-          }
-          return ok;
-     }
-}
-// driver for all of the cases above
-bool rc_sparsity(void)
-{     bool ok = true;
-     //
-     // record the funcion
-     size_t n = 20;
-     size_t m = n + 1;
-     a_vector x(n), y(m);
-     for(size_t j = 0; j < n; j++)
-          x[j] = CppAD::AD<double>(j+1);
-     CppAD::Independent(x);
-     y = fun(x);
-     CppAD::ADFun<double> f(x, y);
-     //
-     // run the example / tests
-     ok &= forward_jac(f);
-     ok &= reverse_jac(f);
-     ok &= forward_hes(f);
-     ok &= reverse_hes(f);
-     //
-     return ok;
-}
-
-
Input File: example/sparse/rc_sparsity.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_rc_sparsity.cpp_xml.js cppad-2019.02.00.0/doc/_rc_sparsity.cpp_xml.js --- cppad-2018.00.00.0/doc/_rc_sparsity.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rc_sparsity.cpp_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', -'adfun.xml', -'sparsity_pattern.xml', -'rc_sparsity.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_current0 = [ -'rc_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-2018.00.00.0/doc/record_adfun.xml cppad-2019.02.00.0/doc/record_adfun.xml --- cppad-2018.00.00.0/doc/record_adfun.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/record_adfun.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ - - - -Create an ADFun Object (Record an Operation Sequence) - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Create an ADFun Object (Record an Operation Sequence)
-
-Contents -
- -
IndependentDeclare Independent Variables and Start Recording
FunConstructConstruct an ADFun Object and Stop Recording
DependentStop Recording and Store Operation Sequence
abort_recordingAbort Recording of an Operation Sequence
seq_propertyADFun Sequence Properties
-
Input File: omh/adfun.omh - - - diff -Nru cppad-2018.00.00.0/doc/_record_adfun_xml.js cppad-2019.02.00.0/doc/_record_adfun_xml.js --- cppad-2018.00.00.0/doc/_record_adfun_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_record_adfun_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'record_adfun.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down0 = [ -'independent.xml', -'funconstruct.xml', -'dependent.xml', -'abort_recording.xml', -'seq_property.xml' -]; -var list_current0 = [ -'record_adfun.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-2018.00.00.0/doc/_reference.xml cppad-2019.02.00.0/doc/_reference.xml --- cppad-2018.00.00.0/doc/_reference.xml 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/_reference.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,831 +0,0 @@ - - - -Alphabetic Listing of Cross Reference Tags - - - - - - - - - - - - - -
- -Prev -Next - - - - - - -_reference - -

-
Alphabetic Listing of Cross Reference Tags
- -
- -A
-a11c_bthread.cpp
A Simple Boost Thread Example and Test
-a11c_openmp.cpp
A Simple OpenMP Example and Test
-a11c_pthread.cpp
A Simple Parallel Pthread Example and Test
-abort_recording
Abort Recording of an Operation Sequence
-abort_recording.cpp
Abort Current Recording: Example and Test
-abs
AD Absolute Value Functions: abs, fabs
-abs_eval
abs_normal: Evaluate First Order Approximation
-abs_eval.cpp
abs_eval: Example and Test
-abs_eval.hpp
abs_eval Source Code
-abs_get_started.cpp
abs_normal Getting Started: Example and Test
-abs_min_linear
abs_normal: Minimize a Linear Abs-normal Approximation
-abs_min_linear.cpp
abs_min_linear: Example and Test
-abs_min_linear.hpp
abs_min_linear Source Code
-abs_min_quad
abs_normal: Minimize a Linear Abs-normal Approximation
-abs_min_quad.cpp
abs_min_quad: Example and Test
-abs_min_quad.hpp
abs_min_quad Source Code
-abs_normal
Abs-normal Representation of Non-Smooth Functions
-abs_normal_fun
Create An Abs-normal Representation of a Function
-abs_print_mat
abs_normal: Print a Vector or Matrix
-acos
Inverse Sine Function: acos
-acos.cpp
The AD acos Function: Example and Test
-acos_forward
Inverse Cosine and Hyperbolic Cosine Forward Mode Theory
-acos_reverse
Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory
-acosh
The Inverse Hyperbolic Cosine Function: acosh
-acosh.cpp
The AD acosh Function: Example and Test
-AD
AD Objects
-ad_assign
AD Assignment Operator
-ad_assign.cpp
AD Assignment: Example and Test
-ad_binary
AD Binary Arithmetic Operators
-ad_ctor
AD Constructors
-ad_ctor.cpp
AD Constructors: Example and Test
-ad_fun.cpp
Creating Your Own Interface to an ADFun Object
-ad_in_c.cpp
Example and Test Linking CppAD to Languages Other than C++
-ad_input
AD Output Stream Operator
-ad_input.cpp
AD Output Operator: Example and Test
-ad_output
AD Output Stream Operator
-ad_output.cpp
AD Output Operator: Example and Test
-ad_to_string
Convert An AD or Base Type to String
-add.cpp
AD Binary Addition: Example and Test
-AddEq.cpp
AD Compound Assignment Addition: Example and Test
-addon
CppAD Addons
-ADFun
ADFun Objects
-adolc_alloc_mat
Adolc Test Utility: Allocate and Free Memory For a Matrix
-adolc_det_lu.cpp
Adolc Speed: Gradient of Determinant Using Lu Factorization
-adolc_det_minor.cpp
Adolc Speed: Gradient of Determinant by Minor Expansion
-adolc_mat_mul.cpp
Adolc Speed: Matrix Multiplication
-adolc_ode.cpp
Adolc Speed: Ode
-adolc_poly.cpp
Adolc Speed: Second Derivative of a Polynomial
-adolc_prefix
Including the ADOL-C Examples and Tests
-adolc_sparse_hessian.cpp
Adolc Speed: Sparse Hessian
-adolc_sparse_jacobian.cpp
adolc Speed: Sparse Jacobian
-ADValued
AD Valued Operations and Functions
-Appendix
Appendix
-Arithmetic
AD Arithmetic Operators and Compound Assignments
-asin
Inverse Sine Function: asin
-asin.cpp
The AD asin Function: Example and Test
-asin_forward
Inverse Sine and Hyperbolic Sine Forward Mode Theory
-asin_reverse
Inverse Sine and Hyperbolic Sine Reverse Mode Theory
-asinh
The Inverse Hyperbolic Sine Function: asinh
-asinh.cpp
The AD asinh Function: Example and Test
-atan
Inverse Tangent Function: atan
-atan.cpp
The AD atan Function: Example and Test
-atan2
AD Two Argument Inverse Tangent Function
-atan2.cpp
The AD atan2 Function: Example and Test
-atan_forward
Inverse Tangent and Hyperbolic Tangent Forward Mode Theory
-atan_reverse
Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory
-atanh
The Inverse Hyperbolic Tangent Function: atanh
-atanh.cpp
The AD atanh Function: Example and Test
-atomic
Atomic AD Functions
-atomic_afun
Using AD Version of Atomic Function
-atomic_base
User Defined Atomic AD Functions
-atomic_base_clear
Free Static Variables
-atomic_ctor
Atomic Function Constructor
-atomic_eigen_cholesky.cpp
Atomic Eigen Cholesky Factorization: Example and Test
-atomic_eigen_cholesky.hpp
Atomic Eigen Cholesky Factorization Class
-atomic_eigen_mat_inv.cpp
Atomic Eigen Matrix Inverse: Example and Test
-atomic_eigen_mat_inv.hpp
Atomic Eigen Matrix Inversion Class
-atomic_eigen_mat_mul.cpp
Atomic Eigen Matrix Multiply: Example and Test
-atomic_eigen_mat_mul.hpp
Atomic Eigen Matrix Multiply Class
-atomic_for_sparse_hes
Atomic Forward Hessian Sparsity Patterns
-atomic_for_sparse_hes.cpp
Atomic Forward Hessian Sparsity: Example and Test
-atomic_for_sparse_jac
Atomic Forward Jacobian Sparsity Patterns
-atomic_for_sparse_jac.cpp
Atomic Forward Jacobian Sparsity: Example and Test
-atomic_forward
Atomic Forward Mode
-atomic_forward.cpp
Atomic Forward: Example and Test
-atomic_get_started.cpp
Getting Started with Atomic Operations: Example and Test
-atomic_mat_mul.cpp
User Atomic Matrix Multiply: Example and Test
-atomic_mat_mul.hpp
Matrix Multiply as an Atomic Operation
-atomic_mul_level.cpp
Atomic Operations and Multiple-Levels of AD: Example and Test
-atomic_norm_sq.cpp
Atomic Euclidean Norm Squared: Example and Test
-atomic_option
Set Atomic Function Options
-atomic_reciprocal.cpp
Reciprocal as an Atomic Operation: Example and Test
-atomic_rev_sparse_hes
Atomic Reverse Hessian Sparsity Patterns
-atomic_rev_sparse_hes.cpp
Atomic Reverse Hessian Sparsity: Example and Test
-atomic_rev_sparse_jac
Atomic Reverse Jacobian Sparsity Patterns
-atomic_rev_sparse_jac.cpp
Atomic Reverse Jacobian Sparsity: Example and Test
-atomic_reverse
Atomic Reverse Mode
-atomic_reverse.cpp
Atomic Reverse: Example and Test
-atomic_set_sparsity.cpp
Atomic Sparsity with Set Patterns: Example and Test
-atomic_tangent.cpp
Tan and Tanh as User Atomic Operations: Example and Test
-autotools
Autotools Unix Test and Installation
-azmul
Absolute Zero Multiplication
-azmul.cpp
AD Absolute Zero Multiplication: Example and Test
- -B
-base_adolc.hpp
Enable use of AD<Base> where Base is Adolc's adouble Type
-base_alloc.hpp
Example AD<Base> Where Base Constructor Allocates Memory
-base_complex.hpp
Enable use of AD<Base> where Base is std::complex<double>
-base_cond_exp
Base Type Requirements for Conditional Expressions
-base_double.hpp
Enable use of AD<Base> where Base is double
-base_example
Example AD Base Types That are not AD<OtherBase>
-base_float.hpp
Enable use of AD<Base> where Base is float
-base_hash
Base Type Requirements for Hash Coding Values
-base_identical
Base Type Requirements for Identically Equal Comparisons
-base_limits
Base Type Requirements for Numeric Limits
-base_member
Required Base Class Member Functions
-base_ordered
Base Type Requirements for Ordered Comparisons
-base_require
AD<Base> Requirements for a CppAD Base Type
-base_require.cpp
Using a User Defined AD Base Type: Example and Test
-base_std_math
Base Type Requirements for Standard Math Functions
-base_to_string
Extending to_string To Another Floating Point Type
-bender_quad.cpp
BenderQuad: Example and Test
-BenderQuad
Computing Jacobian and Hessian of Bender's Reduced Objective
-Bib
Bibliography
-binary_math
The Binary Math Functions
-bool_fun.cpp
AD Boolean Functions: Example and Test
-BoolFun
AD Boolean Functions
-BoolValued
Bool Valued Operations and Functions with AD Arguments
- -C
-capacity_order
Controlling Taylor Coefficients Memory Allocation
-capacity_order.cpp
Controlling Taylor Coefficient Memory Allocation: Example and Test
-change_param.cpp
Computing a Jacobian With Constants that Change
-check_for_nan
Check an ADFun Object For Nan Results
-check_for_nan.cpp
ADFun Checking For Nan: Example and Test
-check_numeric_type.cpp
The CheckNumericType Function: Example and Test
-check_simple_vector.cpp
The CheckSimpleVector Function: Example and Test
-CheckNumericType
Check NumericType Class Concept
-checkpoint
Checkpointing Functions
-checkpoint.cpp
Simple Checkpointing: Example and Test
-checkpoint_extended_ode.cpp
Checkpointing an Extended ODE Solver: Example and Test
-checkpoint_ode.cpp
Checkpointing an ODE Solver: Example and Test
-CheckSimpleVector
Check Simple Vector Concept
-cholesky_theory
AD Theory for Cholesky Factorization
-cmake
Using CMake to Configure CppAD
-cmake_check
Checking the CppAD Examples and Tests
-colpack_hes.cpp
ColPack: Sparse Hessian Example and Test
-colpack_hessian.cpp
ColPack: Sparse Hessian Example and Test
-colpack_jac.cpp
ColPack: Sparse Jacobian Example and Test
-colpack_jacobian.cpp
ColPack: Sparse Jacobian Example and Test
-colpack_prefix
Including the ColPack Sparsity Calculations
-Compare
AD Binary Comparison Operators
-compare.cpp
AD Binary Comparison Operators: Example and Test
-compare_c
Compare Speed of C and C++
-compare_change
Comparison Changes Between Taping and Zero Order Forward
-compare_change.cpp
CompareChange and Re-Tape: Example and Test
-CompareChange
Comparison Changes During Zero Order Forward Mode
-complex_poly.cpp
Complex Polynomial: Example and Test
-compound_assign
AD Compound Assignment Operators
-cond_exp.cpp
Conditional Expressions: Example and Test
-CondExp
AD Conditional Expressions
-conj_grad.cpp
Differentiate Conjugate Gradient Algorithm: Example and Test
-Convert
Conversion and I/O of AD Objects
-correct_det_by_minor_c
Correctness Test of det_by_minor Routine
-cos
The Cosine Function: cos
-cos.cpp
The AD cos Function: Example and Test
-cosh
The Hyperbolic Cosine Function: cosh
-cosh.cpp
The AD cosh Function: Example and Test
-CppAD
cppad-20180000.0: A Package for Differentiation of C++ Algorithms
-cppad_assert
CppAD Assertions During Execution
-cppad_det_lu.cpp
CppAD Speed: Gradient of Determinant Using Lu Factorization
-cppad_det_minor.cpp
CppAD Speed: Gradient of Determinant by Minor Expansion
-cppad_eigen.hpp
Enable Use of Eigen Linear Algebra Package with CppAD
-cppad_ipopt_nlp
Nonlinear Programming Using the CppAD Interface to Ipopt
-cppad_mat_mul.cpp
CppAD Speed, Matrix Multiplication
-cppad_ode.cpp
CppAD Speed: Gradient of Ode Solution
-cppad_poly.cpp
CppAD Speed: Second Derivative of a Polynomial
-cppad_sparse_hessian.cpp
CppAD Speed: Sparse Hessian
-cppad_sparse_jacobian.cpp
CppAD Speed: Sparse Jacobian
-cppad_testvector
Choosing the CppAD Test Vector Template Class
-CppAD_vector
The CppAD::vector Template Class
-cppad_vector.cpp
CppAD::vector Template Class: Example and Test
- -D
-dependency.cpp
Computing Dependency: Example and Test
-Dependent
Stop Recording and Store Operation Sequence
-deprecated
CppAD Deprecated API Features
-det_33
Check Determinant of 3 by 3 matrix
-det_33.hpp
Source: det_33
-det_by_lu
Determinant Using Expansion by Lu Factorization
-det_by_lu.cpp
Determinant Using Lu Factorization: Example and Test
-det_by_lu.hpp
Source: det_by_lu
-det_by_minor
Determinant Using Expansion by Minors
-det_by_minor.cpp
Determinant Using Expansion by Minors: Example and Test
-det_by_minor.hpp
Source: det_by_minor
-det_by_minor_c
Compute Determinant using Expansion by Minors
-det_grad_33
Check Gradient of Determinant of 3 by 3 matrix
-det_grad_33.hpp
Source: det_grad_33
-det_of_minor
Determinant of a Minor
-det_of_minor.cpp
Determinant of a Minor: Example and Test
-det_of_minor.hpp
Source: det_of_minor
-det_of_minor_c
Determinant of a Minor
-directory
Directory Structure
-Discrete
Discrete AD Functions
-div.cpp
AD Binary Division: Example and Test
-div_eq.cpp
AD Compound Assignment Division: Example and Test
-double_det_lu.cpp
Double Speed: Determinant Using Lu Factorization
-double_det_minor.cpp
Double Speed: Determinant by Minor Expansion
-double_mat_mul.cpp
CppAD Speed: Matrix Multiplication (Double Version)
-double_ode.cpp
Double Speed: Ode Solution
-double_poly.cpp
Double Speed: Evaluate a Polynomial
-double_sparse_hessian.cpp
Double Speed: Sparse Hessian
-double_sparse_jacobian.cpp
Double Speed: Sparse Jacobian
-download
Download The CppAD Source Code
-drivers
First and Second Order Derivatives: Easy Drivers
- -E
-eigen_array.cpp
Using Eigen Arrays: Example and Test
-eigen_det.cpp
Using Eigen To Compute Determinant: Example and Test
-eigen_plugin.hpp
Source Code for eigen_plugin.hpp
-eigen_prefix
Including the Eigen Examples and Tests
-elapsed_seconds
Returns Elapsed Number of Seconds
-elapsed_seconds.cpp
Elapsed Seconds: Example and Test
-elapsed_seconds_c
Returns Elapsed Number of Seconds
-epsilon
Machine Epsilon For AD Types
-equal_op_seq.cpp
EqualOpSeq: Example and Test
-EqualOpSeq
Check if Two Value are Identically Equal
-erf
The Error Function
-erf.cpp
The AD erf Function: Example and Test
-erf_forward
Error Function Forward Taylor Polynomial Theory
-erf_reverse
Error Function Reverse Mode Theory
-error_handler.cpp
Replacing The CppAD Error Handler: Example and Test
-ErrorHandler
Replacing the CppAD Error Handler
-Example
Examples
-ExampleUtility
Utility Routines used by CppAD Examples
-exp
The Exponential Function: exp
-exp.cpp
The AD exp Function: Example and Test
-exp_2
Second Order Exponential Approximation
-exp_2.cpp
exp_2: Test
-exp_2.hpp
exp_2: Implementation
-exp_2_cppad
exp_2: CppAD Forward and Reverse Sweeps
-exp_2_for0
exp_2: Operation Sequence and Zero Order Forward Mode
-exp_2_for0.cpp
exp_2: Verify Zero Order Forward Sweep
-exp_2_for1
exp_2: First Order Forward Mode
-exp_2_for1.cpp
exp_2: Verify First Order Forward Sweep
-exp_2_for2
exp_2: Second Order Forward Mode
-exp_2_for2.cpp
exp_2: Verify Second Order Forward Sweep
-exp_2_rev1
exp_2: First Order Reverse Mode
-exp_2_rev1.cpp
exp_2: Verify First Order Reverse Sweep
-exp_2_rev2
exp_2: Second Order Reverse Mode
-exp_2_rev2.cpp
exp_2: Verify Second Order Reverse Sweep
-exp_apx.cpp
Correctness Tests For Exponential Approximation in Introduction
-exp_eps
An Epsilon Accurate Exponential Approximation
-exp_eps.cpp
exp_eps: Test of exp_eps
-exp_eps.hpp
exp_eps: Implementation
-exp_eps_cppad
exp_eps: CppAD Forward and Reverse Sweeps
-exp_eps_for0
exp_eps: Operation Sequence and Zero Order Forward Sweep
-exp_eps_for0.cpp
exp_eps: Verify Zero Order Forward Sweep
-exp_eps_for1
exp_eps: First Order Forward Sweep
-exp_eps_for1.cpp
exp_eps: Verify First Order Forward Sweep
-exp_eps_for2
exp_eps: Second Order Forward Mode
-exp_eps_for2.cpp
exp_eps: Verify Second Order Forward Sweep
-exp_eps_rev1
exp_eps: First Order Reverse Sweep
-exp_eps_rev1.cpp
exp_eps: Verify First Order Reverse Sweep
-exp_eps_rev2
exp_eps: Second Order Reverse Sweep
-exp_eps_rev2.cpp
exp_eps: Verify Second Order Reverse Sweep
-exp_forward
Exponential Function Forward Mode Theory
-exp_reverse
Exponential Function Reverse Mode Theory
-expm1
The Exponential Function Minus One: expm1
-expm1.cpp
The AD exp Function: Example and Test
- -F
-fabs.cpp
AD Absolute Value Function: Example and Test
-fadbad_det_lu.cpp
Fadbad Speed: Gradient of Determinant Using Lu Factorization
-fadbad_det_minor.cpp
Fadbad Speed: Gradient of Determinant by Minor Expansion
-fadbad_mat_mul.cpp
Fadbad Speed: Matrix Multiplication
-fadbad_ode.cpp
Fadbad Speed: Ode
-fadbad_poly.cpp
Fadbad Speed: Second Derivative of a Polynomial
-fadbad_prefix
Including the FADBAD Speed Tests
-fadbad_sparse_hessian.cpp
Fadbad Speed: Sparse Hessian
-fadbad_sparse_jacobian.cpp
fadbad Speed: sparse_jacobian
-Faq
Frequently Asked Questions and Answers
-for_hes_sparsity
Forward Mode Hessian Sparsity Patterns
-for_hes_sparsity.cpp
Forward Mode Hessian Sparsity: Example and Test
-for_jac_sparsity
Forward Mode Jacobian Sparsity Patterns
-for_jac_sparsity.cpp
Forward Mode Jacobian Sparsity: Example and Test
-for_one.cpp
First Order Partial Driver: Example and Test
-for_sparse_hes.cpp
Forward Mode Hessian Sparsity: Example and Test
-for_sparse_jac.cpp
Forward Mode Jacobian Sparsity: Example and Test
-for_two.cpp
Subset of Second Order Partials: Example and Test
-ForOne
First Order Partial Derivative: Driver Routine
-ForSparseHes
Hessian Sparsity Pattern: Forward Mode
-ForSparseJac
Jacobian Sparsity Pattern: Forward Mode
-ForTwo
Forward Mode Second Partial Derivative Driver
-Forward
Forward Mode
-forward.cpp
Forward Mode: Example and Test
-forward_dir
Multiple Directions Forward Mode
-forward_dir.cpp
Forward Mode: Example and Test of Multiple Directions
-forward_one
First Order Forward Mode: Derivative Values
-forward_order
Multiple Order Forward Mode
-forward_order.cpp
Forward Mode: Example and Test of Multiple Orders
-forward_two
Second Order Forward Mode: Derivative Values
-forward_zero
Zero Order Forward Mode: Function Values
-ForwardTheory
The Theory of Forward Mode
-fun_assign.cpp
ADFun Assignment: Example and Test
-fun_check.cpp
ADFun Check and Re-Tape: Example and Test
-FunCheck
Check an ADFun Sequence of Operations
-FunConstruct
Construct an ADFun Object and Stop Recording
-FunDeprecated
ADFun Object Deprecated Member Functions
- -G
-General
General Examples
-general.cpp
CppAD Examples and Tests
-get_adolc.sh
Download and Install Adolc in Build Directory
-get_colpack.sh
Download and Install ColPack in Build Directory
-get_eigen.sh
Download and Install Eigen in Build Directory
-get_fadbad.sh
Download and Install Fadbad in Build Directory
-get_ipopt.sh
Download and Install Ipopt in Build Directory
-get_sacado.sh
Download and Install Sacado in Build Directory
-get_started.cpp
Getting Started Using CppAD to Compute Derivatives
-glossary
Glossary
- -H
-harmonic.cpp
Multi-Threading Harmonic Summation Example / Test
-harmonic_common
Common Variables Used by Multi-threading Sum of 1/i
-harmonic_setup
Set Up Multi-threading Sum of 1/i
-harmonic_sum
Multi-Threaded Implementation of Summation of 1/i
-harmonic_takedown
Take Down Multi-threading Sum of 1/i
-harmonic_time
Timing Test of Multi-Threaded Summation of 1/i
-harmonic_worker
Do One Thread's Work for Sum of 1/i
-hes_lagrangian.cpp
Hessian of Lagrangian and ADFun Default Constructor: Example and Test
-hes_lu_det.cpp
Gradient of Determinant Using LU Factorization: Example and Test
-hes_minor_det.cpp
Gradient of Determinant Using Expansion by Minors: Example and Test
-hes_times_dir.cpp
Hessian Times Direction: Example and Test
-Hessian
Hessian: Easy Driver
-hessian.cpp
Hessian: Example and Test
- -I
-include_deprecated
Deprecated Include Files
-Independent
Declare Independent Variables and Start Recording
-independent.cpp
Independent and ADFun Constructor: Example and Test
-index_sort
Returns Indices that Sort a Vector
-index_sort.cpp
Index Sort: Example and Test
-Install
CppAD Download, Test, and Install Instructions
-Integer
Convert From AD to Integer
-integer.cpp
Convert From AD to Integer: Example and Test
-interface2c.cpp
Interfacing to C: Example and Test
-interp_onetape.cpp
Interpolation With Out Retaping: Example and Test
-interp_retape.cpp
Interpolation With Retaping: Example and Test
-Introduction
An Introduction by Example to Algorithmic Differentiation
-ipopt_nlp_get_started.cpp
Nonlinear Programming Using CppAD and Ipopt: Example and Test
-ipopt_nlp_ode
Example Simultaneous Solution of Forward and Inverse Problem
-ipopt_nlp_ode_check.cpp
Correctness Check for Both Simple and Fast Representations
-ipopt_nlp_ode_fast
ODE Fitting Using Fast Representation
-ipopt_nlp_ode_fast.hpp
ODE Fitting Using Fast Representation
-ipopt_nlp_ode_problem
An ODE Inverse Problem Example
-ipopt_nlp_ode_problem.hpp
ODE Inverse Problem Definitions: Source Code
-ipopt_nlp_ode_run.hpp
Driver for Running the Ipopt ODE Example
-ipopt_nlp_ode_simple
ODE Fitting Using Simple Representation
-ipopt_nlp_ode_simple.hpp
ODE Fitting Using Simple Representation
-ipopt_ode_speed.cpp
Speed Test for Both Simple and Fast Representations
-ipopt_prefix
Including the cppad_ipopt Library and Tests
-ipopt_solve
Use Ipopt to Solve a Nonlinear Programming Problem
-ipopt_solve_get_started.cpp
Nonlinear Programming Using CppAD and Ipopt: Example and Test
-ipopt_solve_ode_inverse.cpp
ODE Inverse Problem Definitions: Source Code
-ipopt_solve_retape.cpp
Nonlinear Programming Retaping: Example and Test
- -J
-jac_lu_det.cpp
Gradient of Determinant Using Lu Factorization: Example and Test
-jac_minor_det.cpp
Gradient of Determinant Using Expansion by Minors: Example and Test
-Jacobian
Jacobian: Driver Routine
-jacobian.cpp
Jacobian: Example and Test
- -L
-License
Your License for the CppAD Software
-link_det_lu
Speed Testing Gradient of Determinant Using Lu Factorization
-link_det_minor
Speed Testing Gradient of Determinant by Minor Expansion
-link_mat_mul
Speed Testing Derivative of Matrix Multiply
-link_ode
Speed Testing the Jacobian of Ode Solution
-link_poly
Speed Testing Second Derivative of a Polynomial
-link_sparse_hessian
Speed Testing Sparse Hessian
-link_sparse_jacobian
Speed Testing Sparse Jacobian
-ListAllExamples
List All (Except Deprecated) CppAD Examples
-log
The Exponential Function: log
-log.cpp
The AD log Function: Example and Test
-log10
The Base 10 Logarithm Function: log10
-log10.cpp
The AD log10 Function: Example and Test
-log1p
The Logarithm of One Plus Argument: log1p
-log1p.cpp
The AD log1p Function: Example and Test
-log_forward
Logarithm Function Forward Mode Theory
-log_reverse
Logarithm Function Reverse Mode Theory
-lp_box
abs_normal: Solve a Linear Program With Box Constraints
-lp_box.cpp
abs_normal lp_box: Example and Test
-lp_box.hpp
lp_box Source Code
-lu_factor.cpp
LuFactor: Example and Test
-lu_factor.hpp
Source: LuFactor
-lu_invert.cpp
LuInvert: Example and Test
-lu_invert.hpp
Source: LuInvert
-lu_ratio.cpp
LuRatio: Example and Test
-lu_solve.cpp
LuSolve With Complex Arguments: Example and Test
-lu_solve.hpp
Source: LuSolve
-lu_vec_ad.cpp
Lu Factor and Solve with Recorded Pivoting
-lu_vec_ad_ok.cpp
Lu Factor and Solve With Recorded Pivoting: Example and Test
-LuDetAndSolve
Compute Determinants and Solve Equations by LU Factorization
-LuFactor
LU Factorization of A Square Matrix
-LuInvert
Invert an LU Factored Equation
-LuRatio
LU Factorization of A Square Matrix and Stability Calculation
-LuSolve
Compute Determinant and Solve Linear Equations
- -M
-main_compare_c
Main Program For Comparing C and C++ Speed
-mat_sum_sq
Sum Elements of a Matrix Times Itself
-mat_sum_sq.cpp
Sum of the Elements of the Square of a Matrix: Example and Test
-mat_sum_sq.hpp
Source: mat_sum_sq
-memory_leak
Memory Leak Detection
-microsoft_timer
Microsoft Version of Elapsed Number of Seconds
-min_nso_linear
Non-Smooth Optimization Using Abs-normal Linear Approximations
-min_nso_linear.cpp
abs_normal min_nso_linear: Example and Test
-min_nso_linear.hpp
min_nso_linear Source Code
-min_nso_quad
Non-Smooth Optimization Using Abs-normal Quadratic Approximations
-min_nso_quad.cpp
abs_normal min_nso_quad: Example and Test
-min_nso_quad.hpp
min_nso_quad Source Code
-mul.cpp
AD Binary Multiplication: Example and Test
-mul_eq.cpp
AD Compound Assignment Multiplication: Example and Test
-mul_level
Using Multiple Levels of AD
-mul_level.cpp
Multiple Level of AD: Example and Test
-mul_level_adolc.cpp
Using Adolc with Multiple Levels of Taping: Example and Test
-mul_level_adolc_ode.cpp
Taylor's Ode Solver: A Multi-Level Adolc Example and Test
-mul_level_ode.cpp
Taylor's Ode Solver: A Multi-Level AD Example and Test
-multi_atomic.cpp
Multi-Threading User Atomic Example / Test
-multi_atomic_common
Multi-Threaded User Atomic Common Information
-multi_atomic_run
Run Multi-Threaded User Atomic Calculation
-multi_atomic_setup
Multi-Threaded User Atomic Set Up
-multi_atomic_takedown
Multi-Threaded User Atomic Take Down
-multi_atomic_time
Timing Test for Multi-Threaded User Atomic Calculation
-multi_atomic_user
Defines a User Atomic Operation that Computes Square Root
-multi_atomic_worker
Multi-Threaded User Atomic Worker
-multi_newton.cpp
Multi-Threaded Newton Method Example / Test
-multi_newton_common
Common Variables use by Multi-Threaded Newton Method
-multi_newton_run
A Multi-Threaded Newton's Method
-multi_newton_setup
Set Up Multi-Threaded Newton Method
-multi_newton_takedown
Take Down Multi-threaded Newton Method
-multi_newton_time
Timing Test of Multi-Threaded Newton Method
-multi_newton_worker
Do One Thread's Work for Multi-Threaded Newton Method
-multi_thread
Using CppAD in a Multi-Threading Environment
- -N
-nan
Obtain Nan or Determine if a Value is Nan
-nan.cpp
nan: Example and Test
-near_equal.cpp
NearEqual Function: Example and Test
-near_equal_ext.cpp
Compare AD with Base Objects: Example and Test
-NearEqual
Determine if Two Values Are Nearly Equal
-NearEqualExt
Compare AD and Base Objects for Nearly Equal
-num_limits.cpp
Numeric Limits: Example and Test
-number_skip
Number of Variables that Can be Skipped
-number_skip.cpp
Number of Variables That Can be Skipped: Example and Test
-numeric_ad
Some Numerical AD Utilities
-numeric_limits
Numeric Limits For an AD and Base Types
-numeric_type.cpp
The NumericType: Example and Test
-NumericType
Definition of a Numeric Type
- -O
-ode_err_control.cpp
OdeErrControl: Example and Test
-ode_err_maxabs.cpp
OdeErrControl: Example and Test Using Maxabs Argument
-ode_evaluate
Evaluate a Function Defined in Terms of an ODE
-ode_evaluate.cpp
ode_evaluate: Example and test
-ode_evaluate.hpp
Source: ode_evaluate
-ode_gear.cpp
OdeGear: Example and Test
-ode_gear_control.cpp
OdeGearControl: Example and Test
-ode_stiff.cpp
A Stiff Ode: Example and Test
-ode_taylor.cpp
Taylor's Ode Solver: An Example and Test
-OdeErrControl
An Error Controller for ODE Solvers
-OdeGear
An Arbitrary Order Gear Method
-OdeGearControl
An Error Controller for Gear's Ode Solvers
-old_atomic
User Defined Atomic AD Functions
-old_mat_mul.cpp
Old Matrix Multiply as a User Atomic Operation: Example and Test
-old_mat_mul.hpp
Define Matrix Multiply as a User Atomic Operation
-old_max_num_threads
Set Maximum Number of Threads for omp_alloc Allocator
-old_reciprocal.cpp
Old Atomic Operation Reciprocal: Example and Test
-old_tan.cpp
Old Tan and Tanh as User Atomic Operations: Example and Test
-old_usead_1.cpp
Using AD to Compute Atomic Function Derivatives
-old_usead_2.cpp
Using AD to Compute Atomic Function Derivatives
-omp_alloc
A Quick OpenMP Memory Allocator Used by CppAD
-omp_alloc.cpp
OpenMP Memory Allocator: Example and Test
-omp_available
Amount of Memory Available for Quick Use by a Thread
-omp_create_array
Allocate Memory and Create A Raw Array
-omp_delete_array
Return A Raw Array to The Available Memory for a Thread
-omp_efficient
Check If A Memory Allocation is Efficient for Another Use
-omp_free_available
Free Memory Currently Available for Quick Use by a Thread
-omp_get_memory
Get At Least A Specified Amount of Memory
-omp_get_thread_num
Get the Current OpenMP Thread Number
-omp_in_parallel
Is The Current Execution in OpenMP Parallel Mode
-omp_inuse
Amount of Memory a Thread is Currently Using
-omp_max_num_threads
Set and Get Maximum Number of Threads for omp_alloc Allocator
-omp_max_thread
OpenMP Parallel Setup
-omp_return_memory
Return Memory to omp_alloc
-opt_val_hes
Jacobian and Hessian of Optimal Values
-opt_val_hes.cpp
opt_val_hes: Example and Test
-optimize
Optimize an ADFun Object Tape
-optimize_compare_op.cpp
Example Optimization and Comparison Operators
-optimize_conditional_skip.cpp
Example Optimization and Conditional Expressions
-optimize_cumulative_sum.cpp
Example Optimization and Cumulative Sum Operations
-optimize_forward_active.cpp
Example Optimization and Forward Activity Analysis
-optimize_nest_conditional.cpp
Example Optimization and Nested Conditional Expressions
-optimize_print_for.cpp
Example Optimization and Print Forward Operators
-optimize_reverse_active.cpp
Example Optimization and Reverse Activity Analysis
- -P
-par_var.cpp
AD Parameter and Variable Functions: Example and Test
-parallel_ad
Enable AD Calculations During Parallel Mode
-ParVar
Is an AD Object a Parameter or Variable
-pkgconfig
CppAD pkg-config Files
-Poly
Evaluate a Polynomial or its Derivative
-poly.cpp
Polynomial Evaluation: Example and Test
-poly.hpp
Source: Poly
-pow
The AD Power Function
-pow.cpp
The AD Power Function: Example and Test
-pow_int
The Integer Power Function
-pow_int.cpp
The Pow Integer Exponent: Example and Test
-preprocessor
CppAD API Preprocessor Symbols
-print_for_cout.cpp
Printing During Forward Mode: Example and Test
-print_for_string.cpp
Print During Zero Order Forward Mode: Example and Test
-PrintFor
Printing AD Values During Forward Mode
- -Q
-qp_box
abs_normal: Solve a Quadratic Program With Box Constraints
-qp_box.cpp
abs_normal qp_box: Example and Test
-qp_box.hpp
qp_box Source Code
-qp_interior
Solve a Quadratic Program Using Interior Point Method
-qp_interior.cpp
abs_normal qp_interior: Example and Test
-qp_interior.hpp
qp_interior Source Code
- -R
-rc_sparsity.cpp
Preferred Sparsity Patterns: Row and Column Indices: Example and Test
-record_adfun
Create an ADFun Object (Record an Operation Sequence)
-repeat_det_by_minor_c
Repeat det_by_minor Routine A Specified Number of Times
-rev_hes_sparsity
Reverse Mode Hessian Sparsity Patterns
-rev_hes_sparsity.cpp
Reverse Mode Hessian Sparsity: Example and Test
-rev_jac_sparsity
Reverse Mode Jacobian Sparsity Patterns
-rev_jac_sparsity.cpp
Reverse Mode Jacobian Sparsity: Example and Test
-rev_one.cpp
First Order Derivative Driver: Example and Test
-rev_sparse_hes.cpp
Reverse Mode Hessian Sparsity: Example and Test
-rev_sparse_jac.cpp
Reverse Mode Jacobian Sparsity: Example and Test
-rev_two.cpp
Second Partials Reverse Driver: Example and Test
-Reverse
Reverse Mode
-reverse_any
Any Order Reverse Mode
-reverse_checkpoint.cpp
Reverse Mode General Case (Checkpointing): Example and Test
-reverse_identity
An Important Reverse Mode Identity
-reverse_one
First Order Reverse Mode
-reverse_one.cpp
First Order Reverse Mode: Example and Test
-reverse_three.cpp
Third Order Reverse Mode: Example and Test
-reverse_two
Second Order Reverse Mode
-reverse_two.cpp
Second Order Reverse ModeExample and Test
-ReverseTheory
The Theory of Reverse Mode
-RevOne
First Order Derivative: Driver Routine
-RevSparseHes
Hessian Sparsity Pattern: Reverse Mode
-RevSparseJac
Jacobian Sparsity Pattern: Reverse Mode
-RevTwo
Reverse Mode Second Partial Derivative Driver
-romberg_one.cpp
One Dimensional Romberg Integration: Example and Test
-RombergMul
Multi-dimensional Romberg Integration
-Rombergmul.cpp
One Dimensional Romberg Integration: Example and Test
-RombergOne
One DimensionalRomberg Integration
-Rosen34
A 3rd and 4th Order Rosenbrock ODE Solver
-rosen_34.cpp
Rosen34: Example and Test
-Runge45
An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-runge45_1.cpp
Runge45: Example and Test
-runge45_2.cpp
Runge45: Example and Test
- -S
-sacado_det_lu.cpp
Sacado Speed: Gradient of Determinant Using Lu Factorization
-sacado_det_minor.cpp
Sacado Speed: Gradient of Determinant by Minor Expansion
-sacado_mat_mul.cpp
Sacado Speed: Matrix Multiplication
-sacado_ode.cpp
Sacado Speed: Gradient of Ode Solution
-sacado_poly.cpp
Sacado Speed: Second Derivative of a Polynomial
-sacado_prefix
Including the Sacado Speed Tests
-sacado_sparse_hessian.cpp
Sacado Speed: Sparse Hessian
-sacado_sparse_jacobian.cpp
sacado Speed: sparse_jacobian
-seq_property
ADFun Sequence Properties
-seq_property.cpp
ADFun Sequence Properties: Example and Test
-set_union
Union of Standard Sets
-set_union.cpp
Set Union: Example and Test
-sign
The Sign: sign
-sign.cpp
Sign Function: Example and Test
-simple_ad_bthread.cpp
A Simple Boost Threading AD: Example and Test
-simple_ad_openmp.cpp
A Simple OpenMP AD: Example and Test
-simple_ad_pthread.cpp
A Simple pthread AD: Example and Test
-simple_vector.cpp
Simple Vector Template Class: Example and Test
-SimpleVector
Definition of a Simple Vector
-simplex_method
abs_normal: Solve a Linear Program Using Simplex Method
-simplex_method.cpp
abs_normal simplex_method: Example and Test
-simplex_method.hpp
simplex_method Source Code
-sin
The Sine Function: sin
-sin.cpp
The AD sin Function: Example and Test
-sin_cos_forward
Trigonometric and Hyperbolic Sine and Cosine Forward Theory
-sin_cos_reverse
Trigonometric and Hyperbolic Sine and Cosine Reverse Theory
-sinh
The Hyperbolic Sine Function: sinh
-sinh.cpp
The AD sinh Function: Example and Test
-size_order
Number Taylor Coefficient Orders Currently Stored
-sparse_derivative
Calculating Sparse Derivatives
-sparse_hes
Computing Sparse Hessians
-sparse_hes.cpp
Computing Sparse Hessian: Example and Test
-sparse_hes_fun
Evaluate a Function That Has a Sparse Hessian
-sparse_hes_fun.cpp
sparse_hes_fun: Example and test
-sparse_hes_fun.hpp
Source: sparse_hes_fun
-sparse_hessian
Sparse Hessian
-sparse_hessian.cpp
Sparse Hessian: Example and Test
-sparse_jac
Computing Sparse Jacobians
-sparse_jac_for.cpp
Computing Sparse Jacobian Using Forward Mode: Example and Test
-sparse_jac_fun
Evaluate a Function That Has a Sparse Jacobian
-sparse_jac_fun.cpp
sparse_jac_fun: Example and test
-sparse_jac_fun.hpp
Source: sparse_jac_fun
-sparse_jac_rev.cpp
Computing Sparse Jacobian Using Reverse Mode: Example and Test
-sparse_jacobian
Sparse Jacobian
-sparse_jacobian.cpp
Sparse Jacobian: Example and Test
-sparse_rc
Row and Column Index Sparsity Patterns
-sparse_rc.cpp
sparse_rc: Example and Test
-sparse_rcv
Sparse Matrix Row, Column, Value Representation
-sparse_rcv.cpp
sparse_rcv: Example and Test
-sparse_sub_hes.cpp
Subset of a Sparse Hessian: Example and Test
-sparsity_pattern
Calculating Sparsity Patterns
-sparsity_sub.cpp
Sparsity Patterns For a Subset of Variables: Example and Test
-speed
Speed Test an Operator Overloading AD Package
-speed_adolc
Speed Test of Derivatives Using Adolc
-speed_cppad
Speed Test Derivatives Using CppAD
-speed_double
Speed Test of Functions in Double
-speed_example.cpp
Run the Speed Examples
-speed_fadbad
Speed Test Derivatives Using Fadbad
-speed_main
Running the Speed Test Program
-speed_program.cpp
Example Use of SpeedTest
-speed_sacado
Speed Test Derivatives Using Sacado
-speed_test
Run One Speed Test and Return Results
-speed_test.cpp
speed_test: Example and test
-speed_utility
Speed Testing Utilities
-SpeedTest
Run One Speed Test and Print Results
-sqrt
The Square Root Function: sqrt
-sqrt.cpp
The AD sqrt Function: Example and Test
-sqrt_forward
Square Root Function Forward Mode Theory
-sqrt_reverse
Square Root Function Reverse Mode Theory
-stack_machine.cpp
Example Differentiating a Stack Machine Interpreter
-sub.cpp
AD Binary Subtraction: Example and Test
-sub_eq.cpp
AD Compound Assignment Subtraction: Example and Test
-sub_sparse_hes.cpp
Computing Sparse Hessian for a Subset of Variables
-subgraph_hes2jac.cpp
Sparse Hessian Using Subgraphs and Jacobian: Example and Test
-subgraph_jac_rev
Compute Sparse Jacobians Using Subgraphs
-subgraph_jac_rev.cpp
Computing Sparse Jacobian Using Reverse Mode: Example and Test
-subgraph_reverse
Reverse Mode Using Subgraphs
-subgraph_reverse.cpp
Computing Reverse Mode on Subgraphs: Example and Test
-subgraph_sparsity
Subgraph Dependency Sparsity Patterns
-subgraph_sparsity.cpp
Subgraph Dependency Sparsity Patterns: Example and Test
- -T
-ta_available
Amount of Memory Available for Quick Use by a Thread
-ta_create_array
Allocate An Array and Call Default Constructor for its Elements
-ta_delete_array
Deallocate An Array and Call Destructor for its Elements
-ta_free_all
Free All Memory That Was Allocated for Use by thread_alloc
-ta_free_available
Free Memory Currently Available for Quick Use by a Thread
-ta_get_memory
Get At Least A Specified Amount of Memory
-ta_hold_memory
Control When Thread Alloc Retains Memory For Future Use
-ta_in_parallel
Is The Current Execution in Parallel Mode
-ta_inuse
Amount of Memory a Thread is Currently Using
-ta_num_threads
Get Number of Threads
-ta_parallel_setup
Setup thread_alloc For Use in Multi-Threading Environment
-ta_return_memory
Return Memory to thread_alloc
-ta_thread_num
Get the Current Thread Number
-tan
The Tangent Function: tan
-tan.cpp
The AD tan Function: Example and Test
-tan_forward
Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory
-tan_reverse
Tangent and Hyperbolic Tangent Reverse Mode Theory
-tanh
The Hyperbolic Tangent Function: tanh
-tanh.cpp
The AD tanh Function: Example and Test
-tape_index.cpp
Taping Array Index Operation: Example and Test
-team_bthread.cpp
Boost Thread Implementation of a Team of AD Threads
-team_example.cpp
Using a Team of AD Threads: Example and Test
-team_openmp.cpp
OpenMP Implementation of a Team of AD Threads
-team_pthread.cpp
Pthread Implementation of a Team of AD Threads
-team_thread.hpp
Specifications for A Team of AD Threads
-test_boolofvoid
Object that Runs a Group of Tests
-test_vector
Choosing The Vector Testing Template Class
-testvector
Using The CppAD Test Vector Template Class
-Theory
The Theory of Derivative Calculations
-thread_alloc
A Fast Multi-Threading Memory Allocator
-thread_alloc.cpp
Fast Multi-Threading Memory Allocator: Example and Test
-thread_test.cpp
Run Multi-Threading Examples and Speed Tests
-time_det_by_minor_c
Determine Amount of Time to Execute det_by_minor
-time_test
Determine Amount of Time to Execute a Test
-time_test.cpp
time_test: Example and test
-to_string
Convert Certain Types to a String
-to_string.cpp
to_string: Example and Test
-TrackNewDel
Routines That Track Use of New and Delete
-TrackNewDel.cpp
Tracking Use of New and Delete: Example and Test
- -U
-unary_minus.cpp
AD Unary Minus Operator: Example and Test
-unary_plus.cpp
AD Unary Plus Operator: Example and Test
-unary_standard_math
The Unary Standard Math Functions
-UnaryMinus
AD Unary Minus Operator
-UnaryPlus
AD Unary Plus Operator
-uniform_01
Simulate a [0,1] Uniform Random Variate
-uniform_01.hpp
Source: uniform_01
-uniform_01_c
Simulate a [0,1] Uniform Random Variate
-utility
Some General Purpose Utilities
- -V
-Value
Convert From an AD Type to its Base Type
-value.cpp
Convert From AD to its Base Type: Example and Test
-Var2Par
Convert an AD Variable to a Parameter
-var2par.cpp
Convert an AD Variable to a Parameter: Example and Test
-vec_ad.cpp
AD Vectors that Record Index Operations: Example and Test
-VecAD
AD Vectors that Record Index Operations
-vector_bool.cpp
CppAD::vectorBool Class: Example and Test
- -W
-whats_new
Changes and Additions to CppAD
-whats_new_03
Changes and Additions to CppAD During 2003
-whats_new_04
Changes and Additions to CppAD During 2004
-whats_new_05
Changes and Additions to CppAD During 2005
-whats_new_06
Changes and Additions to CppAD During 2006
-whats_new_07
Changes and Additions to CppAD During 2007
-whats_new_08
Changes and Additions to CppAD During 2008
-whats_new_09
Changes and Additions to CppAD During 2009
-whats_new_10
Changes and Additions to CppAD During 2010
-whats_new_11
Changes and Additions to CppAD During 2011
-whats_new_12
CppAD Changes and Additions During 2012
-whats_new_13
CppAD Changes and Additions During 2013
-whats_new_14
CppAD Changes and Additions During 2014
-whats_new_15
CppAD Changes and Additions During 2015
-whats_new_16
Changes and Additions to CppAD During 2016
-whats_new_17
Changes and Additions to CppAD During 2017
-wish_list
The CppAD Wish List
-wno_conversion
Suppress Suspect Implicit Conversion Warnings
- -Z
-zdouble
zdouble: An AD Base Type With Absolute Zero
-zdouble.cpp
zdouble: Example and Test
-
- - - diff -Nru cppad-2018.00.00.0/doc/__reference_xml.js cppad-2019.02.00.0/doc/__reference_xml.js --- cppad-2018.00.00.0/doc/__reference_xml.js 2018-01-01 08:32:49.000000000 +0000 +++ cppad-2019.02.00.0/doc/__reference_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'_reference.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_current0 = [ -'_reference.xml#A', -'_reference.xml#B', -'_reference.xml#C', -'_reference.xml#D', -'_reference.xml#E', -'_reference.xml#F', -'_reference.xml#G', -'_reference.xml#H', -'_reference.xml#I', -'_reference.xml#J', -'_reference.xml#L', -'_reference.xml#M', -'_reference.xml#N', -'_reference.xml#O', -'_reference.xml#P', -'_reference.xml#Q', -'_reference.xml#R', -'_reference.xml#S', -'_reference.xml#T', -'_reference.xml#U', -'_reference.xml#V', -'_reference.xml#W', -'_reference.xml#Z' -]; -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-2018.00.00.0/doc/repeat_det_by_minor_c.xml cppad-2019.02.00.0/doc/repeat_det_by_minor_c.xml --- cppad-2018.00.00.0/doc/repeat_det_by_minor_c.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/repeat_det_by_minor_c.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ - - - -Repeat det_by_minor Routine A Specified Number of Times - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -repeat_det_by_minor_c - -

-
Repeat det_by_minor Routine A Specified Number of Times
-
-Syntax - -
- -repeat_det_by_minor(repeatsize) - - -
-
-repeat -
-The argument has prototype - -
-     size_t 
repeat
-
-It specifies the number of times to repeat the calculation. - -
-
-size -
-The argument has prototype - -
-     size_t 
size
-
-It specifies the number of rows (and columns) in the square -matrix we are computing the determinant of. - - - - -
-
-Source Code - -
void repeat_det_by_minor(size_t repeat, size_t size)
-{     double *a;
-     a = (double*) malloc( (size * size) * sizeof(double) );
-
-     while(repeat--)
-     {     uniform_01(size * size, a);
-          det_by_minor(a, size);
-     }
-
-     free(a);
-     return;
-}
- -
Input File: test_more/compare_c/det_by_minor.c - - - diff -Nru cppad-2018.00.00.0/doc/_repeat_det_by_minor_c_xml.js cppad-2019.02.00.0/doc/_repeat_det_by_minor_c_xml.js --- cppad-2018.00.00.0/doc/_repeat_det_by_minor_c_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_repeat_det_by_minor_c_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'compare_c.xml', -'repeat_det_by_minor_c.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', -'directory.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 = [ -'det_of_minor_c.xml', -'det_by_minor_c.xml', -'uniform_01_c.xml', -'correct_det_by_minor_c.xml', -'repeat_det_by_minor_c.xml', -'elapsed_seconds_c.xml', -'time_det_by_minor_c.xml', -'main_compare_c.xml' -]; -var list_current0 = [ -'repeat_det_by_minor_c.xml#Syntax', -'repeat_det_by_minor_c.xml#repeat', -'repeat_det_by_minor_c.xml#size', -'repeat_det_by_minor_c.xml#Source Code' -]; -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-2018.00.00.0/doc/reverse_any.xml cppad-2019.02.00.0/doc/reverse_any.xml --- cppad-2018.00.00.0/doc/reverse_any.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/reverse_any.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1337 +0,0 @@ - - - -Any Order Reverse Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Any Order Reverse Mode
-
-Syntax - -
- -dw = f.Reverse(qw) - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -Reverse mode computes the derivative of the Forward - mode -Taylor coefficients - -with respect to the domain variable - -x - - -. -To be specific, it computes the derivative - - -W -( -1 -) - - -( -u -) - - - at - -u -= -x - - - -which is specified by the following notation: - -
-
-Notation - - -
-
-u^(k) -
-For - -k -= -0 -, - -, -q --1 - - -, -the vector - -u -( -k -) - - - -B -n - - - - is defined as the value of - -x_k - in the previous calls of the form - -
-     
f.Forward(kx_k)
-
-If there is no previous call with - -k -= -0 - - -, - - -u -( -0 -) - - - - - is the value of the independent variables when the -corresponding -AD of -Base - -operation sequence - was recorded. - -
-
-X(t, u) -
-The function - - -X -: -B -× -B -n -× -q - - - -B -n - - - - is defined by - - -X -( -t -, -u -) -= -u -( -0 -) - - -+ -u -( -1 -) - - -* -t -+ - -+ -u -( -q --1 -) - - -* -t -q --1 - - - - -Note that for - -k -= -0 -, - -, -q --1 - - -, - - -u -( -k -) - - - - - is related to the k-th partial of - -X -( -t -, -u -) - - - -with respect to - -t - - - by - - -u -( -k -) - - -= -1 - -k -! - - - -k - - - - -t - -k - - - - -X -( -0 -, -u -) - - -
-Y(t, u) -
-The function - - -Y -: -B -× -B -n -× -q - - - -B -m - - - - is defined by - - -Y -( -t -, -u -) -= -F -[ -X -( -t -, -u -) -] - - -
-w^(k) -
-If the argument -w - has size -m * q -, -for - -k -= -0 -, - -, -q --1 - - - and - -i -= -0 -, - -, -m --1 - - -, - - -w -i -( -k -) - - -= -w -[ -i -* -q -+ -k -] - - -If the argument -w - has size -m -, -for - -k -= -0 -, - -, -q --1 - - - and - -i -= -0 -, - -, -m --1 - - -, - - -w -i -( -k -) - - -= -{ -w -[ -i -] - -if - - -k -= -q --1 - -0 - -otherwise - - - - - -
-W(u) -
-The function - -W -: -B -n -× -q - - - -B - - - is defined by - - -W -( -u -) -= - -k -= -0 - -q --1 - - -( -w -( -k -) - - -) -T - - -1 - -k -! - - - -k - - - - -t - -k - - - - -Y -( -0 -, -u -) - - -
-f -
-The object -f - has prototype - -
-     const ADFun<
Basef
-
-Before this call to Reverse, the value returned by - -
-     
f.size_order()
-
-must be greater than or equal -q - -(see size_order -). - -
-
-q -
-The argument -q - has prototype - -
-     size_t 
q
-
-and specifies the number of Taylor coefficient orders to be differentiated -(for each variable). - - -
-
-w -
-The argument -w - has prototype - -
-     const 
Vector &w
-
-(see Vector - below) -and its size -must be equal to -m - or -m * q -, -It specifies the weighting vector -w - -in the definition of -W(u) -. - - -
-
-dw -
-The return value -dw - has prototype - -
-     
Vector dw
-
-(see Vector - below). -It is a vector with size - -n -× -q - - -. -For - -j -= -0 -, - -, -n --1 - - - and - -k -= -0 -, - -, -q --1 - - - -If the argument -w - has size -m * q -, - - -dw -[ -j -* -q -+ -k -] -= -W -( -1 -) - - -( -x -) -j -, -k - - - - -where - -u -= -x - - - is value of the Taylor coefficients where the -derivative is evaluated. -
-
-
If the argument -w - has size -m -, - - -dw -[ -j -* -q -+ -q -- -k -- -1 -] -= -W -( -1 -) - - -( -x -) -j -, -k - - - - -where - -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 Reverse backward -compatible. - -
-
-First Order -
-We consider the case where - -q = 1 - and -w.size() == m -. -In this case - - - -W -( -u -) - -= - -w -0 - -Y -0 - -( -0 -, -u -) -+ - -+ -w -m - -Y -m - -( -0 -, -u -) - -W -( -u -) - -= - -w -0 - -F -0 - -[ -X -( -0 -, -u -) -] -+ - -+ -w -m - -F -m - -[ -X -( -0 -, -u -) -] - -W -( -1 -) - - -( -x -) - -= - -w -0 - -F -0 -( -1 -) - - -( -x -( -0 -) - - -) -+ - -+ -w -m - -F -m -( -1 -) - - -( -x -( -0 -) - - -) - - - -This is the same as the result documented in reverse_one -. - - -
-
-Second Order -
-We consider the case where - -q = 2 - and -w.size() == m -. -In this case - - - -W -( -u -) - -= - -w -0 - - -t - -Y -0 - -( -0 -, -u -) -+ - -+ -w -m - - -t - -Y -m - -( -0 -, -u -) - -W -( -u -) - -= - -w -0 - - -t - -{ -F -0 - -[ -X -( -t -, -u -) -] -} -t -= -0 - - -+ - -+ -w -m - - -t - -{ -F -m - -[ -X -( -t -, -u -) -] -} -t -= -0 - - - -W -( -u -) - -= - -w -0 - -F -0 -( -1 -) - - -( -u -( -0 -) - - -) -u -( -1 -) - - -+ - -+ -w -0 - -F -m -( -1 -) - - -( -u -( -0 -) - - -) -u -( -1 -) - - - - -u -( -0 -) - - -W -( -x -) - -= - -w -0 - -( -x -( -1 -) - - -) -T - - -F -0 -( -2 -) - - -( -x -( -0 -) - - -) -+ - -+ -w -m - -( -x -( -1 -) - - -) -T - - -F -m -( -2 -) - - -( -x -( -0 -) - - -) - - -u -( -1 -) - - -W -( -x -) - -= - -w -0 - -F -0 -( -1 -) - - -( -x -( -0 -) - - -) -+ - -+ -w -m - -F -m -( -1 -) - - -( -x -( -0 -) - - -) - - - -where - - -u -( -0 -) - - - - -denotes partial with respect to - -u -( -0 -) - - - - -. -These are the same as the result documented in reverse_two -. - - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - - -
-
-Example - - - -
  1. -The file reverse_three.cpp - -contains an example and test of using reverse mode -to compute third order derivatives. -
  2. - -The file reverse_checkpoint.cpp - -contains an example and test of the general reverse mode case. -
- - - -
Input File: omh/reverse/reverse_any.omh - - - diff -Nru cppad-2018.00.00.0/doc/_reverse_any_xml.js cppad-2019.02.00.0/doc/_reverse_any_xml.js --- cppad-2018.00.00.0/doc/_reverse_any_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_reverse_any_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'reverse.xml', -'reverse_any.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'reverse_one.xml', -'reverse_two.xml', -'reverse_any.xml', -'subgraph_reverse.xml' -]; -var list_down0 = [ -'reverse_three.cpp.xml', -'reverse_checkpoint.cpp.xml' -]; -var list_current0 = [ -'reverse_any.xml#Syntax', -'reverse_any.xml#Purpose', -'reverse_any.xml#Notation', -'reverse_any.xml#Notation.u^(k)', -'reverse_any.xml#Notation.X(t, u)', -'reverse_any.xml#Notation.Y(t, u)', -'reverse_any.xml#Notation.w^(k)', -'reverse_any.xml#Notation.W(u)', -'reverse_any.xml#f', -'reverse_any.xml#q', -'reverse_any.xml#w', -'reverse_any.xml#dw', -'reverse_any.xml#First Order', -'reverse_any.xml#Second Order', -'reverse_any.xml#Vector', -'reverse_any.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-2018.00.00.0/doc/reverse_checkpoint.cpp.xml cppad-2019.02.00.0/doc/reverse_checkpoint.cpp.xml --- cppad-2018.00.00.0/doc/reverse_checkpoint.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/reverse_checkpoint.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1157 +0,0 @@ - - - -Reverse Mode General Case (Checkpointing): Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -reverse_checkpoint.cpp - -

-
Reverse Mode General Case (Checkpointing): Example and Test
-
-See Also - -
-checkpoint - - -
-
-Purpose -
-Break a large computation into pieces and only store values at the -interface of the pieces (this is much easier to do using checkpoint -). -In actual applications, there may be many functions, but -for this example there are only two. -The functions - - -F -: -R - -2 - - -R - -2 - - - - -and - - -G -: -R - -2 - - -R - -2 - - - - -defined by - - -F -( -x -) -= -( -x -0 - -x -1 - - -x -1 - -- -x -0 - - -) - -, - -G -( -y -) -= -( -y -0 - -- -y -1 - - -y -1 - -y -0 - - -) - - -
-Processing Steps -
-We apply reverse mode to compute the derivative of - - -H -: -R - -2 - - -R - - - - -is defined by - - - -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 - -( -1 -- -x -0 - -+ -x -1 - -) -- -x -1 - -+ -x -0 - - - - -Given the zero and first order Taylor coefficients - - -x -( -0 -) - - - - - and - -x -( -1 -) - - - - -, -we use - -X -( -t -) - - -, - -Y -( -t -) - - - and - -Z -( -t -) - - - -for the corresponding functions; i.e., - - - -X -( -t -) - -= - -x -( -0 -) - - -+ -x -( -1 -) - - -t - -Y -( -t -) - -= - -F -[ -X -( -t -) -] -= -y -( -0 -) - - -+ -y -( -1 -) - - -t -+ -O -( -t -2 - -) - -Z -( -t -) - -= - -G -{ -F -[ -X -( -t -) -] -} -= -z -( -0 -) - - -+ -z -( -1 -) - - -t -+ -O -( -t -2 - -) - -h -( -0 -) - - - -= - -z -0 -( -0 -) - - -+ -z -1 -( -0 -) - - - -h -( -1 -) - - - -= - -z -0 -( -1 -) - - -+ -z -1 -( -1 -) - - - - - -Here are the processing steps: - -
  1. -Use forward mode on - -F -( -x -) - - - to compute - - -y -( -0 -) - - - - - and - -y -( -1 -) - - - - -. -
  2. - -Free some, or all, of the memory corresponding to - -F -( -x -) - - -. -
  3. - -Use forward mode on - -G -( -y -) - - - to compute - - -z -( -0 -) - - - - - and - -z -( -1 -) - - - - - -
  4. - -Use reverse mode on - -G -( -y -) - - - to compute the derivative of - - -h -( -1 -) - - - - - with respect to - - -y -( -0 -) - - - - - and - -y -( -1 -) - - - - -. -
  5. - -Free all the memory corresponding to - -G -( -y -) - - -. -
  6. - -Use reverse mode on - -F -( -x -) - - - to compute the derivative of - - -h -( -1 -) - - - - - with respect to - - -x -( -0 -) - - - - - and - -x -( -1 -) - - - - -. -
- -This uses the following relations: - - - - -x -( -0 -) - - -h -( -1 -) - - -[ -x -( -0 -) - - -, -x -( -1 -) - - -] - -= - - -y -( -0 -) - - -h -( -1 -) - - -[ -y -( -0 -) - - -, -y -( -1 -) - - -] - -x -( -0 -) - - -y -( -0 -) - - -[ -x -( -0 -) - - -, -x -( -1 -) - - -] - - -+ - - -y -( -1 -) - - -h -( -1 -) - - -[ -y -( -0 -) - - -, -y -( -1 -) - - -] - -x -( -0 -) - - -y -( -1 -) - - -[ -x -( -0 -) - - -, -x -( -1 -) - - -] - - -x -( -1 -) - - -h -( -1 -) - - -[ -x -( -0 -) - - -, -x -( -1 -) - - -] - -= - - -y -( -0 -) - - -h -( -1 -) - - -[ -y -( -0 -) - - -, -y -( -1 -) - - -] - -x -( -1 -) - - -y -( -0 -) - - -[ -x -( -0 -) - - -, -x -( -1 -) - - -] - - -+ - - -y -( -1 -) - - -h -( -1 -) - - -[ -y -( -0 -) - - -, -y -( -1 -) - - -] - -x -( -1 -) - - -y -( -1 -) - - -[ -x -( -0 -) - - -, -x -( -1 -) - - -] - - - -where - - -x -( -0 -) - - - - - denotes the partial with respect -to - -x -( -0 -) - - - - -. - - -

-# include <cppad/cppad.hpp>
-
-namespace {
-     template <class Vector>
-     Vector F(const Vector& x)
-     {     Vector y(2);
-          y[0] = x[0] * x[1];
-          y[1] = x[1] - x[0];
-          return y;
-     }
-     template <class Vector>
-     Vector G(const Vector& y)
-     {     Vector z(2);
-          z[0] = y[0] - y[1];
-          z[1] = y[1] * y[0];
-          return z;
-     }
-}
-
-namespace {
-     bool reverse_any_case(bool free_all)
-     {     bool ok = true;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-
-          using CppAD::AD;
-          using CppAD::NearEqual;
-          CppAD::ADFun<double> f, g, empty;
-
-          // specify the Taylor coefficients for X(t)
-          size_t n    = 2;
-          CPPAD_TESTVECTOR(double) x0(n), x1(n);
-          x0[0] = 1.; x0[1] = 2.;
-          x1[0] = 3.; x1[1] = 4.;
-
-          // record the function F(x)
-          CPPAD_TESTVECTOR(AD<double>) X(n), Y(n);
-          size_t i;
-          for(i = 0; i < n; i++)
-               X[i] = x0[i];
-          CppAD::Independent(X);
-          Y = F(X);
-          f.Dependent(X, Y);
-
-          // a fucntion object with an almost empty operation sequence
-          CppAD::Independent(X);
-          empty.Dependent(X, X);
-
-          // compute the Taylor coefficients for Y(t)
-          CPPAD_TESTVECTOR(double) y0(n), y1(n);
-          y0 = f.Forward(0, x0);
-          y1 = f.Forward(1, x1);
-          if( free_all )
-               f = empty;
-          else
-          {     // free all the Taylor coefficients stored in f
-               f.capacity_order(0);
-          }
-
-          // record the function G(x)
-          CPPAD_TESTVECTOR(AD<double>) Z(n);
-          CppAD::Independent(Y);
-          Z = G(Y);
-          g.Dependent(Y, Z);
-
-          // compute the Taylor coefficients for Z(t)
-          CPPAD_TESTVECTOR(double) z0(n), z1(n);
-          z0 = g.Forward(0, y0);
-          z1 = g.Forward(1, y1);
-
-          // check zero order Taylor coefficient for h^0 = z_0^0 + z_1^0
-          double check = x0[0] * x0[1] * (1. - x0[0] + x0[1]) - x0[1] + x0[0];
-          double h0    = z0[0] + z0[1];
-          ok          &= NearEqual(h0, check, eps, eps);
-
-          // check first order Taylor coefficient h^1
-          check     = x0[0] * x0[1] * (- x1[0] + x1[1]) - x1[1] + x1[0];
-          check    += x1[0] * x0[1] * (1. - x0[0] + x0[1]);
-          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);
-          w[0*p+0] = 0.; // coefficient for z_0^0
-          w[0*p+1] = 1.; // coefficient for z_0^1
-          w[1*p+0] = 0.; // coefficient for z_1^0
-          w[1*p+1] = 1.; // coefficient for z_1^1
-          dw       = g.Reverse(p, w);
-
-          // We are done using g, so we can free its memory.
-          g = empty;
-          // We need to use f next.
-          if( free_all )
-          {     // we must again record the operation sequence for F(x)
-               CppAD::Independent(X);
-               Y = F(X);
-               f.Dependent(X, Y);
-          }
-          // now recompute the Taylor coefficients corresponding to F(x)
-          // (we already know the result; i.e., y0 and y1).
-          f.Forward(0, x0);
-          f.Forward(1, x1);
-
-          // 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);
-
-          // check partial of h^1 w.r.t x^0_0
-          check  = x0[1] * (- x1[0] + x1[1]);
-          check -= x1[0] * x0[1];
-          check += x1[1] * (1. - x0[0] + x0[1]) - x0[0] * x1[1];
-          ok    &= NearEqual(dv[0*p+0], check, eps, eps);
-
-          // 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 += x0[0] * x1[1];
-          ok    &= NearEqual(dv[1*p+0], check, eps, eps);
-
-          // check partial of h^1 w.r.t x^1_0
-          check  = 1. - x0[0] * x0[1];
-          check += x0[1] * (1. - x0[0] + x0[1]);
-          ok    &= NearEqual(dv[0*p+1], check, eps, eps);
-
-          // check partial of h^1 w.r.t x^1_1
-          check  = x0[0] * x0[1] - 1.;
-          check += x0[0] * (1. - x0[0] + x0[1]);
-          ok    &= NearEqual(dv[1*p+1], check, eps, eps);
-
-          return ok;
-     }
-}
-bool reverse_any(void)
-{     bool ok = true;
-     ok     &= reverse_any_case(true);
-     ok     &= reverse_any_case(false);
-     return ok;
-}
-
-
-
Input File: example/general/reverse_checkpoint.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_reverse_checkpoint.cpp_xml.js cppad-2019.02.00.0/doc/_reverse_checkpoint.cpp_xml.js --- cppad-2018.00.00.0/doc/_reverse_checkpoint.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_reverse_checkpoint.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'reverse.xml', -'reverse_any.xml', -'reverse_checkpoint.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'reverse_one.xml', -'reverse_two.xml', -'reverse_any.xml', -'subgraph_reverse.xml' -]; -var list_down1 = [ -'reverse_three.cpp.xml', -'reverse_checkpoint.cpp.xml' -]; -var list_current0 = [ -'reverse_checkpoint.cpp.xml#See Also', -'reverse_checkpoint.cpp.xml#Purpose', -'reverse_checkpoint.cpp.xml#Processing Steps' -]; -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-2018.00.00.0/doc/reverse_identity.xml cppad-2019.02.00.0/doc/reverse_identity.xml --- cppad-2018.00.00.0/doc/reverse_identity.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/reverse_identity.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1431 +0,0 @@ - - - -An Important Reverse Mode Identity - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -reverse_identity - -

-
An Important Reverse Mode Identity
-The theorem and the proof below is a restatement -of the results on page 236 of -Evaluating Derivatives -. - -
-
-Notation -
-Given a function - -f -( -u -, -v -) - - - where - -u - -B -n - - - - -we use the notation - - - -f - - -u - - -( -u -, -v -) -= -[ -f - - -u -1 - - - -( -u -, -v -) -, - -, - -f - - -u -n - - - -( -u -, -v -) -] - - -
-Reverse Sweep -
-When using reverse mode - -we are given a function - -F -: -B -n - - -B -m - - - -, -a matrix of Taylor coefficients - -x - -B -n -× -p - - - - -, -and a weight vector - -w - -B -m - - - -. -We define the functions - -X -: -B -× -B -n -× -p - - - -B -n - - - -, - - -W -: -B -× -B -n -× -p - - - -B - - -, and - - -W -j - -: -B -n -× -p - - - -B - - - by - - - -X -( -t -, -x -) - -= - -x -( -0 -) - - -+ -x -( -1 -) - - -t -+ - -+ -x -( -p --1 -) - - -t -p --1 - - - -W -( -t -, -x -) - -= - -w -0 - -F -0 - -[ -X -( -t -, -x -) -] -+ - -+ -w -m --1 - - -F -m --1 - - -[ -X -( -t -, -x -) -] - -W -j - -( -x -) - -= - -1 - -j -! - - - -j - - - - -t - -j - - - - -W -( -0 -, -x -) - - - -where - -x -( -j -) - - - - - is the j-th column of - -x - -B -n -× -p - - - - -. -The theorem below implies that - - - -W -j - - - -x -( -i -) - - - - -( -x -) -= - -W -j -- -i - - - - -x -( -0 -) - - - - -( -x -) - - -A general reverse sweep - calculates the values - - - -W -p --1 - - - - -x -( -i -) - - - - -( -x -) - -( -i -= -0 -, - -, -p --1 -) - - -But the return values for a reverse sweep are specified -in terms of the more useful values - - - -W -j - - - -x -( -0 -) - - - - -( -x -) - -( -j -= -0 -, - -, -p --1 -) - - -
-Theorem -
-Suppose that - -F -: -B -n - - -B -m - - - - is a - -p - - - times -continuously differentiable function. -Define the functions - - -Z -: -B -× -B -n -× -p - - - -B -n - - - -, - - -Y -: -B -× -B -n -× -p - - - -B -m - - - -, -and - - -y -( -j -) - - -: -B -n -× -p - - - -B -m - - - - by - - - -Z -( -t -, -x -) - -= - -x -( -0 -) - - -+ -x -( -1 -) - - -t -+ - -+ -x -( -p --1 -) - - -t -p --1 - - - -Y -( -t -, -x -) - -= - -F -[ -Z -( -t -, -x -) -] - -y -( -j -) - - -( -x -) - -= - -1 - -j -! - - - -j - - - - -t - -j - - - - -Y -( -0 -, -x -) - - - -where - -x -( -j -) - - - - - denotes the j-th column of - - -x - -B -n -× -p - - - - -. -It follows that -for all - -i -, -j - - - such that - -i - -j -< -p - - -, - - - - -y -( -j -) - - - - -x -( -i -) - - - - -( -x -) - -= - - -y -( -j -- -i -) - - - - -x -( -0 -) - - - - -( -x -) - - - -
-Proof -
-If follows from the definitions that - - - - -y -( -j -) - - - - -x -( -i -) - - - - -( -x -) - -= - -1 - -j -! - - - - - -x -( -i -) - - - - -[ -j - - - - -t - -j - - - - -( -F - -Z -) -( -t -, -x -) -] -t -= -0 - - - - -= - -1 - -j -! - - -[ -j - - - - -t - -j - - - - - - - -x -( -i -) - - - - -( -F - -Z -) -( -t -, -x -) -] -t -= -0 - - - - -= - -1 - -j -! - - -{ -j - - - - -t - -j - - - - -[t -i - -( -F -( -1 -) - - - -Z -) -( -t -, -x -) -] -} -t -= -0 - - - - - -For - -k -> -i - - -, the k-th -partial of - -t -i - - - - with respect to - -t - - - is zero. -Thus, the partial with respect to - -t - - - is given by - - - - -j - - - - -t - -j - - - - -[t -i - -( -F -( -1 -) - - - -Z -) -( -t -, -x -) -] - -= - - -k -= -0 - -i - -( -j - -k - -) -i -! - -( -i -- -k -) -! - - -t -i -- -k - - - - -j -- -k - - - - -t - -j -- -k - - - - -( -F -( -1 -) - - - -Z -) -( -t -, -x -) - -{ -j - - - - -t - -j - - - - -[t -i - -( -F -( -1 -) - - - -Z -) -( -t -, -x -) -] -} -t -= -0 - - - -= - -( -j - -i - -) -i -! - -j -- -i - - - - -t - -j -- -i - - - - -( -F -( -1 -) - - - -Z -) -( -t -, -x -) - - -= - -j -! - -( -j -- -i -) -! - - - -j -- -i - - - - -t - -j -- -i - - - - -( -F -( -1 -) - - - -Z -) -( -t -, -x -) - - -y -( -j -) - - - - -x -( -i -) - - - - -( -x -) - -= - -1 - -( -j -- -i -) -! - - - -j -- -i - - - - -t - -j -- -i - - - - -( -F -( -1 -) - - - -Z -) -( -t -, -x -) - - - -Applying this formula to the case where - -j - - - -is replaced by - -j -- -i - - - and - -i - - - is replaced by zero, -we obtain - - - -y -( -j -- -i -) - - - - -x -( -0 -) - - - - -( -x -) -= -1 - -( -j -- -i -) -! - - - -j -- -i - - - - -t - -j -- -i - - - - -( -F -( -1 -) - - - -Z -) -( -t -, -x -) -= - -y -( -j -) - - - - -x -( -i -) - - - - -( -x -) - - -which completes the proof - - -
Input File: omh/appendix/theory/reverse_identity.omh - - - diff -Nru cppad-2018.00.00.0/doc/_reverse_identity_xml.js cppad-2019.02.00.0/doc/_reverse_identity_xml.js --- cppad-2018.00.00.0/doc/_reverse_identity_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_reverse_identity_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', -'appendix.xml', -'theory.xml', -'reverse_identity.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', -'directory.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 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_current0 = [ -'reverse_identity.xml#Notation', -'reverse_identity.xml#Reverse Sweep', -'reverse_identity.xml#Theorem', -'reverse_identity.xml#Proof' -]; -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-2018.00.00.0/doc/reverse_one.cpp.xml cppad-2019.02.00.0/doc/reverse_one.cpp.xml --- cppad-2018.00.00.0/doc/reverse_one.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/reverse_one.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,152 +0,0 @@ - - - -First Order Reverse Mode: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -reverse_one.cppHeadings

- - - -
First Order Reverse Mode: Example and Test
-
# include <cppad/cppad.hpp>
-namespace { // ----------------------------------------------------------
-// define the template function reverse_one_cases<Vector> in empty namespace
-template <typename Vector>
-bool reverse_one_cases(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = ax[0] * ax[0] * ax[1];
-
-     // create f : x -> y and stop recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // use first order reverse mode to evaluate derivative of y[0]
-     // and use the values in x for the independent variables.
-     CPPAD_TESTVECTOR(double) w(m), dw(n);
-     w[0] = 1.;
-     dw   = f.Reverse(1, w);
-     ok  &= NearEqual(dw[0] , 2.*ax[0]*ax[1], eps99, eps99);
-     ok  &= NearEqual(dw[1] ,    ax[0]*ax[0], eps99, eps99);
-
-     // use zero order forward mode to evaluate y at x = (3, 4)
-     // and use the template parameter Vector for the vector type
-     Vector x(n), y(m);
-     x[0]    = 3.;
-     x[1]    = 4.;
-     y       = f.Forward(0, x);
-     ok     &= NearEqual(y[0] , x[0]*x[0]*x[1], eps99, eps99);
-
-     // use first order reverse mode to evaluate derivative of y[0]
-     // and using the values in x for the independent variables.
-     w[0] = 1.;
-     dw   = f.Reverse(1, w);
-     ok  &= NearEqual(dw[0] , 2.*x[0]*x[1], eps99, eps99);
-     ok  &= NearEqual(dw[1] ,    x[0]*x[0], eps99, eps99);
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool reverse_one(void)
-{     bool ok = true;
-     // Run with Vector equal to three different cases
-     // all of which are Simple Vectors with elements of type double.
-     ok &= reverse_one_cases< CppAD::vector  <double> >();
-     ok &= reverse_one_cases< std::vector    <double> >();
-     ok &= reverse_one_cases< std::valarray  <double> >();
-     return ok;
-}
-
-
Input File: example/general/reverse_one.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_reverse_one.cpp_xml.js cppad-2019.02.00.0/doc/_reverse_one.cpp_xml.js --- cppad-2018.00.00.0/doc/_reverse_one.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_reverse_one.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'reverse.xml', -'reverse_one.xml', -'reverse_one.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'reverse_one.xml', -'reverse_two.xml', -'reverse_any.xml', -'subgraph_reverse.xml' -]; -var list_down1 = [ -'reverse_one.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-2018.00.00.0/doc/reverse_one.xml cppad-2019.02.00.0/doc/reverse_one.xml --- cppad-2018.00.00.0/doc/reverse_one.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/reverse_one.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,407 +0,0 @@ - - - -First Order Reverse Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
First Order Reverse Mode
-
-Syntax - -
- -dw = f.Reverse(1, w) - - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -The function - -W -: -B -n - - -B - - - is defined by - - -W -( -x -) -= -w -0 - -* -F -0 - -( -x -) -+ - -+ -w -m --1 - - -* -F -m --1 - - -( -x -) - - -The result of this operation is the derivative - - -dw -= -W -( -1 -) - - -( -x -) - - -; i.e., - - -dw -= -w -0 - -* -F -0 -( -1 -) - - -( -x -) -+ - -+ -w -m --1 - - -* -F -m --1 - -( -1 -) - - -( -x -) - - -Note that if - -w - - - is the i-th -elementary vector -, - - -dw -= -F -i -( -1 -) - - -( -x -) - - -. - -
-
-f -
-The object -f - has prototype - -
-     const ADFun<
Basef
-
-Before this call to Reverse, the value returned by - -
-     
f.size_order()
-
-must be greater than or equal one (see size_order -). - -
-
-x -
-The vector -x - in expression for -dw - above -corresponds to the previous call to forward_zero - -using this ADFun object -f -; i.e., - -
-     
f.Forward(0, x)
-
-If there is no previous call with the first argument zero, -the value of the independent - variables -during the recording of the AD sequence of operations is used -for -x -. - -
-
-w -
-The argument -w - has prototype - -
-     const 
Vector &w
-
-(see Vector - below) -and its size -must be equal to -m -, the dimension of the -range - space for -f -. - -
-
-dw -
-The result -dw - has prototype - -
-     
Vector dw
-
-(see Vector - below) -and its value is the derivative - -W -( -1 -) - - -( -x -) - - -. -The size of -dw - -is equal to -n -, the dimension of the -domain - space for -f -. - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Example - -
-The file -reverse_one.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: omh/reverse/reverse_one.omh - - - diff -Nru cppad-2018.00.00.0/doc/_reverse_one_xml.js cppad-2019.02.00.0/doc/_reverse_one_xml.js --- cppad-2018.00.00.0/doc/_reverse_one_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_reverse_one_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'reverse.xml', -'reverse_one.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'reverse_one.xml', -'reverse_two.xml', -'reverse_any.xml', -'subgraph_reverse.xml' -]; -var list_down0 = [ -'reverse_one.cpp.xml' -]; -var list_current0 = [ -'reverse_one.xml#Syntax', -'reverse_one.xml#Purpose', -'reverse_one.xml#f', -'reverse_one.xml#x', -'reverse_one.xml#w', -'reverse_one.xml#dw', -'reverse_one.xml#Vector', -'reverse_one.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-2018.00.00.0/doc/reversetheory.xml cppad-2019.02.00.0/doc/reversetheory.xml --- cppad-2018.00.00.0/doc/reversetheory.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/reversetheory.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1520 +0,0 @@ - - - -The Theory of Reverse Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
The Theory of Reverse Mode
-
-Taylor Notation -
-In Taylor notation, each variable corresponds to -a function of a single argument which we denote by -t - -(see Section 10.2 of -Evaluating Derivatives -). -Here and below - - -X -( -t -) - - -, - -Y -( -t -) - - -, and -Z(t) - are scalar valued functions -and the corresponding p-th order Taylor coefficients row vectors are - - -x - - -, - -y - - - and - -z - - -; i.e., - - - -X -( -t -) - -= - -x -( -0 -) - - -+ -x -( -1 -) - - -* -t -+ - -+ -x -( -p -) - - -* -t -p - -+ -O -( -t -p -+ -1 - - -) - -Y -( -t -) - -= - -y -( -0 -) - - -+ -y -( -1 -) - - -* -t -+ - -+ -y -( -p -) - - -* -t -p - -+ -O -( -t -p -+ -1 - - -) - -Z -( -t -) - -= - -z -( -0 -) - - -+ -z -( -1 -) - - -* -t -+ - -+ -z -( -p -) - - -* -t -p - -+ -O -( -t -p -+ -1 - - -) - - - -For the purposes of this discussion, -we are given the p-th order Taylor coefficient row vectors - - -x - - -, - -y - - -, and - -z - - -. -In addition, we are given the partial derivatives of a scalar valued function - - -G -( -z -( -j -) - - -, - -, -z -( -0 -) - - -, -x -, -y -) - - -We need to compute the partial derivatives of the scalar valued function - - -H -( -z -( -j --1 -) - - -, - -, -z -( -0 -) - - -, -x -, -y -) -= -G -( -z -( -j -) - - -, -z -( -j --1 -) - - -, - -, -z -( -0 -) - - -, -x -, -y -) - - -where - -z -( -j -) - - - - - is expressed as a function of the -j-1-th order Taylor coefficient row -vector for - -Z - - - and the vectors - -x - - -, - -y - - -; i.e., - - -z -( -j -) - - - - - above is a shorthand for - - -z -( -j -) - - -( -z -( -j --1 -) - - -, - -, -z -( -0 -) - - -, -x -, -y -) - - -If we do not provide a formula for -a partial derivative of - -H - - -, then that partial derivative -has the same value as for the function - -G - - -. - -
-
-Binary Operators - - -
-
-Addition -
-The forward mode formula for -addition - is - - -z -( -j -) - - -= -x -( -j -) - - -+ -y -( -j -) - - - - -If follows that for - -k -= -0 -, - -, -j - - - -and - -l -= -0 -, - -, -j --1 - - - - - - - -H - - -x -( -k -) - - - - - -= - - -G - - -x -( -k -) - - - - -+ - -G - - -z -( -k -) - - - - - - - -H - - -y -( -k -) - - - - - -= - - -G - - -y -( -k -) - - - - -+ - -G - - -z -( -k -) - - - - - - -H - - -z -( -l -) - - - - - -= - - -G - - -z -( -l -) - - - - - - - -
-Subtraction -
-The forward mode formula for -subtraction - is - - -z -( -j -) - - -= -x -( -j -) - - -- -y -( -j -) - - - - -If follows that for - -k -= -0 -, - -, -j - - - - - - - -H - - -x -( -k -) - - - - - -= - - -G - - -x -( -k -) - - - - -- - -G - - -z -( -k -) - - - - - - - -H - - -y -( -k -) - - - - - -= - - -G - - -y -( -k -) - - - - -- - -G - - -z -( -k -) - - - - - - - -
-Multiplication -
-The forward mode formula for -multiplication - is - - -z -( -j -) - - -= - -k -= -0 - -j - -x -( -j -- -k -) - - -* -y -( -k -) - - - - -If follows that for - -k -= -0 -, - -, -j - - - -and - -l -= -0 -, - -, -j --1 - - - - - - - -H - - -x -( -j -- -k -) - - - - - -= - - -G - - -x -( -j -- -k -) - - - - -+ - -k -= -0 - -j - - -G - - -z -( -j -) - - - - -y -( -k -) - - - - -H - - -y -( -k -) - - - - - -= - - -G - - -y -( -k -) - - - - -+ - -k -= -0 - -j - - -G - - -z -( -j -) - - - - -x -( -j -- -k -) - - - - - -
-Division -
-The forward mode formula for -division - is - - -z -( -j -) - - -= -1 - -y -( -0 -) - - - - -(x -( -j -) - - -- - -k -= -1 - -j - -z -( -j -- -k -) - - -y -( -k -) - - -) - - -If follows that for - -k -= -1 -, - -, -j - - - - - - - -H - - -x -( -j -) - - - - - -= - - -G - - -x -( -j -) - - - - -+ - -G - - -z -( -j -) - - - - -1 - -y -( -0 -) - - - - - - -H - - -z -( -j -- -k -) - - - - - -= - - -G - - -z -( -j -- -k -) - - - - -- - -G - - -z -( -j -) - - - - -1 - -y -( -0 -) - - - - -y -( -k -) - - - - -H - - -y -( -k -) - - - - - -= - - -G - - -y -( -k -) - - - - -- - -G - - -z -( -j -) - - - - -1 - -y -( -0 -) - - - - -z -( -j -- -k -) - - - - -H - - -y -( -0 -) - - - - - -= - - -G - - -y -( -0 -) - - - - -- - -G - - -z -( -j -) - - - - -1 - -y -( -0 -) - - - - -1 - -y -( -0 -) - - - - -(x -( -j -) - - -- - -k -= -1 - -j - -z -( -j -- -k -) - - -y -( -k -) - - -) - - -= - - -G - - -y -( -0 -) - - - - -- - -G - - -z -( -j -) - - - - -1 - -y -( -0 -) - - - - -z -( -j -) - - - - - -
-Standard Math Functions -
-The standard math functions have only one argument. -Hence we are given the partial derivatives of a scalar valued function - - -G -( -z -( -j -) - - -, - -, -z -( -0 -) - - -, -x -) - - -We need to compute the partial derivatives of the scalar valued function - - -H -( -z -( -j --1 -) - - -, - -, -z -( -0 -) - - -, -x -) -= -G -( -z -( -j -) - - -, -z -( -j --1 -) - - -, - -, -z -( -0 -) - - -, -x -) - - -where - -z -( -j -) - - - - - is expressed as a function of the -j-1-th order Taylor coefficient row -vector for - -Z - - - and the vector - -x - - -; i.e., - - -z -( -j -) - - - - - above is a shorthand for - - -z -( -j -) - - -( -z -( -j --1 -) - - -, - -, -z -( -0 -) - - -, -x -) - - -
-Contents -
- -
exp_reverseExponential Function Reverse Mode Theory
log_reverseLogarithm Function Reverse Mode Theory
sqrt_reverseSquare Root Function Reverse Mode Theory
sin_cos_reverseTrigonometric and Hyperbolic Sine and Cosine Reverse Theory
atan_reverseInverse Tangent and Hyperbolic Tangent Reverse Mode Theory
asin_reverseInverse Sine and Hyperbolic Sine Reverse Mode Theory
acos_reverseInverse Cosine and Hyperbolic Cosine Reverse Mode Theory
tan_reverseTangent and Hyperbolic Tangent Reverse Mode Theory
erf_reverseError Function Reverse Mode Theory
-
Input File: omh/appendix/theory/reverse_theory.omh - - - diff -Nru cppad-2018.00.00.0/doc/_reversetheory_xml.js cppad-2019.02.00.0/doc/_reversetheory_xml.js --- cppad-2018.00.00.0/doc/_reversetheory_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_reversetheory_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +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' -]; -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', -'directory.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 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_down0 = [ -'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' -]; -var list_current0 = [ -'reversetheory.xml#Taylor Notation', -'reversetheory.xml#Binary Operators', -'reversetheory.xml#Binary Operators.Addition', -'reversetheory.xml#Binary Operators.Subtraction', -'reversetheory.xml#Binary Operators.Multiplication', -'reversetheory.xml#Binary Operators.Division', -'reversetheory.xml#Standard Math Functions', -'reversetheory.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-2018.00.00.0/doc/reverse_three.cpp.xml cppad-2019.02.00.0/doc/reverse_three.cpp.xml --- cppad-2018.00.00.0/doc/reverse_three.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/reverse_three.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,333 +0,0 @@ - - - -Third Order Reverse Mode: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -reverse_three.cpp - -

- - - -
Third Order Reverse Mode: Example and Test
-
-Taylor Coefficients - - - - -X -( -t -) - -= - -x -( -0 -) - - -+ -x -( -1 -) - - -t -+ -x -( -2 -) - - -t -2 - - -X -( -1 -) - - -( -t -) - -= - -x -( -1 -) - - -+ -2 -x -( -2 -) - - -t - -X -( -2 -) - - -( -t -) - -= - -2 -x -( -2 -) - - - - - -Thus, we need to be careful to properly account for the fact that - - -X -( -2 -) - - -( -0 -) -= -2 -x -( -2 -) - - - - - -(and similarly - -Y -( -2 -) - - -( -0 -) -= -2 -y -( -2 -) - - - - -). - - -
# include <cppad/cppad.hpp>
-namespace { // ----------------------------------------------------------
-// define the template function cases<Vector> in empty namespace
-template <typename Vector>
-bool cases(void)
-{     bool ok    = true;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-     using CppAD::AD;
-     using CppAD::NearEqual;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) X(n);
-     X[0] = 0.;
-     X[1] = 1.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(X);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) Y(m);
-     Y[0] = X[0] * X[1];
-
-     // create f : X -> Y and stop recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // 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)
-     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
-     Vector x1(n), y1(m);
-     x1[0] = 4.;
-     x1[1] = 5.;
-     y1    = f.Forward(1, x1);
-
-     // Y^1 (x) = partial_t F( x^0 + x^1 * t )
-     // y^1     = Y^1 (0)
-     check = x1[0] * x0[1] + x0[0] * x1[1];
-     ok   &= NearEqual(y1[0], check, eps, eps);
-
-     // define x^2 and compute y^2 using second order forward mode
-     Vector x2(n), y2(m);
-     x2[0] = 6.;
-     x2[1] = 7.;
-     y2    = f.Forward(2, x2);
-
-     // Y^2 (x) = partial_tt F( x^0 + x^1 * t + x^2 * t^2 )
-     // y^2     = (1/2) *  Y^2 (0)
-     check  = x2[0] * x0[1] + x1[0] * x1[1] + x0[0] * x2[1];
-     ok    &= NearEqual(y2[0], check, eps, eps);
-
-     // W(x)  = Y^0 (x) + 2 * Y^1 (x) + 3 * (1/2) * Y^2 (x)
-     size_t p = 3;
-     Vector dw(n*p), w(m*p);
-     w[0] = 1.;
-     w[1] = 2.;
-     w[2] = 3.;
-     dw   = f.Reverse(p, w);
-
-     // check partial w.r.t x^0_0 of W(x)
-     check = x0[1] + 2. * x1[1] + 3. * x2[1];
-     ok   &= NearEqual(dw[0*p+0], check, eps, eps);
-
-     // check partial w.r.t x^0_1 of W(x)
-     check = x0[0] + 2. * x1[0] + 3. * x2[0];
-     ok   &= NearEqual(dw[1*p+0], check, eps, eps);
-
-     // check partial w.r.t x^1_0 of W(x)
-     check = 2. * x0[1] + 3. * x1[1];
-     ok   &= NearEqual(dw[0*p+1], check, eps, eps);
-
-     // check partial w.r.t x^1_1 of W(x)
-     check = 2. * x0[0] + 3. * x1[0];
-     ok   &= NearEqual(dw[1*p+1], check, eps, eps);
-
-     // check partial w.r.t x^2_0 of W(x)
-     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];
-     ok   &= NearEqual(dw[1*p+2], check, eps, eps);
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool reverse_three(void)
-{     bool ok = true;
-     ok &= cases< CppAD::vector  <double> >();
-     ok &= cases< std::vector    <double> >();
-     ok &= cases< std::valarray  <double> >();
-     return ok;
-}
-
-
Input File: example/general/reverse_three.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_reverse_three.cpp_xml.js cppad-2019.02.00.0/doc/_reverse_three.cpp_xml.js --- cppad-2018.00.00.0/doc/_reverse_three.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_reverse_three.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'reverse.xml', -'reverse_any.xml', -'reverse_three.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'reverse_one.xml', -'reverse_two.xml', -'reverse_any.xml', -'subgraph_reverse.xml' -]; -var list_down1 = [ -'reverse_three.cpp.xml', -'reverse_checkpoint.cpp.xml' -]; -var list_current0 = [ -'reverse_three.cpp.xml#Taylor Coefficients' -]; -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-2018.00.00.0/doc/reverse_two.cpp.xml cppad-2019.02.00.0/doc/reverse_two.cpp.xml --- cppad-2018.00.00.0/doc/reverse_two.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/reverse_two.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,161 +0,0 @@ - - - -Second Order Reverse ModeExample and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -reverse_two.cppHeadings

- - - -
Second Order Reverse ModeExample and Test
-
# include <cppad/cppad.hpp>
-namespace { // ----------------------------------------------------------
-// define the template function reverse_two_cases<Vector> in empty namespace
-template <typename Vector>
-bool reverse_two_cases(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) X(n);
-     X[0] = 0.;
-     X[1] = 1.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(X);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) Y(m);
-     Y[0] = X[0] * X[0] * X[1];
-
-     // create f : X -> Y and stop recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // use zero order forward mode to evaluate y at x = (3, 4)
-     // use the template parameter Vector for the vector type
-     Vector x(n), y(m);
-     x[0]  = 3.;
-     x[1]  = 4.;
-     y     = f.Forward(0, x);
-     ok    &= NearEqual(y[0] , x[0]*x[0]*x[1], eps99, eps99);
-
-     // use first order forward mode in x[0] direction
-     // (all second order partials below involve x[0])
-     Vector dx(n), dy(m);
-     dx[0] = 1.;
-     dx[1] = 1.;
-     dy    = f.Forward(1, dx);
-     double check = 2.*x[0]*x[1]*dx[0] + x[0]*x[0]*dx[1];
-     ok   &= NearEqual(dy[0], check, eps99, eps99);
-
-     // use second order reverse mode to evalaute second partials of y[0]
-     // with respect to (x[0], x[0]) and with respect to (x[0], x[1])
-     Vector w(m), dw( n * 2 );
-     w[0]  = 1.;
-     dw    = f.Reverse(2, w);
-
-     // check derivative of f
-     ok   &= NearEqual(dw[0*2+0] , 2.*x[0]*x[1], eps99, eps99);
-     ok   &= NearEqual(dw[1*2+0] ,    x[0]*x[0], eps99, eps99);
-
-     // 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, eps99, eps99);
-     check = 2.*x[0]*dx[1];
-     ok   &= NearEqual(dw[1*2+1] , check, eps99, eps99);
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool reverse_two(void)
-{     bool ok = true;
-     ok &= reverse_two_cases< CppAD::vector  <double> >();
-     ok &= reverse_two_cases< std::vector    <double> >();
-     ok &= reverse_two_cases< std::valarray  <double> >();
-     return ok;
-}
-
-
Input File: example/general/reverse_two.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_reverse_two.cpp_xml.js cppad-2019.02.00.0/doc/_reverse_two.cpp_xml.js --- cppad-2018.00.00.0/doc/_reverse_two.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_reverse_two.cpp_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', -'adfun.xml', -'reverse.xml', -'reverse_two.xml', -'reverse_two.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'reverse_one.xml', -'reverse_two.xml', -'reverse_any.xml', -'subgraph_reverse.xml' -]; -var list_down1 = [ -'reverse_two.cpp.xml', -'hes_times_dir.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-2018.00.00.0/doc/reverse_two.xml cppad-2019.02.00.0/doc/reverse_two.xml --- cppad-2018.00.00.0/doc/reverse_two.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/reverse_two.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1076 +0,0 @@ - - - -Second Order Reverse Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Second Order Reverse Mode
-
-Syntax - -
- -dw = f.Reverse(2, w) - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -Reverse mode computes the derivative of the Forward - mode -Taylor coefficients - -with respect to the domain variable - -x - - -. - -
-
-x^(k) -
-For - -k -= -0 -, -1 - - -, -the vector - -x -( -k -) - - - -B -n - - - - is defined as the value of - -x_k - in the previous call (counting this call) of the form - -
-     
f.Forward(kx_k)
-
-If there is no previous call with - -k -= -0 - - -, - - -x -( -0 -) - - - - - is the value of the independent variables when the -corresponding -AD of -Base - -operation sequence - was recorded. - - -
-
-W -
-The functions - - -W -0 - -: -B -n - - -B - - - and - - -W -1 - -: -B -n - - -B - - - -are defined by - - - -W -0 - -( -u -) - -= - -w -0 - -* -F -0 - -( -u -) -+ - -+ -w -m --1 - - -* -F -m --1 - - -( -u -) - -W -1 - -( -u -) - -= - -w -0 - -* -F -0 -( -1 -) - - -( -u -) -* -x -( -1 -) - - -+ - -+ -w -m --1 - - -* -F -m --1 - -( -1 -) - - -( -u -) -* -x -( -1 -) - - - - - -This operation computes the derivatives - - - -W -0 -( -1 -) - - -( -u -) - -= - -w -0 - -* -F -0 -( -1 -) - - -( -u -) -+ - -+ -w -m --1 - - -* -F -m --1 - -( -1 -) - - -( -u -) - -W -1 -( -1 -) - - -( -u -) - -= - -w -0 - -* -(x -( -1 -) - - -) -T - - -* -F -0 -( -2 -) - - -( -u -) -+ - -+ -w -m --1 - - -* -(x -( -1 -) - - -) -T - - -F -m --1 - -( -2 -) - - -( -u -) - - - -at - -u -= -x -( -0 -) - - - - -. - -
-
-f -
-The object -f - has prototype - -
-     const ADFun<
Basef
-
-Before this call to Reverse, the value returned by - -
-     
f.size_order()
-
-must be greater than or equal two (see size_order -). - -
-
-w -
-The argument -w - has prototype - -
-     const 
Vector &w
-
-(see Vector - below) -and its size -must be equal to -m -, the dimension of the -range - space for -f -. - -
-
-dw -
-The result -dw - has prototype - -
-     
Vector dw
-
-(see Vector - below). -It contains both the derivative - - -W -( -1 -) - - -( -x -) - - - and the derivative - -U -( -1 -) - - -( -x -) - - -. -The size of -dw - -is equal to - -n -× -2 - - -, -where - -n - - - is the dimension of the -domain - space for -f -. - -
-
-First Order Partials -
-For - -j -= -0 -, - -, -n -- -1 - - -, - - -dw -[ -j -* -2 -+ -0 -] -= - -W -0 - - - -u -j - - - -(x -( -0 -) - - -) -= -w -0 - -* - -F -0 - - - -u -j - - - -(x -( -0 -) - - -) -+ - -+ -w -m --1 - - -* - -F -m --1 - - - - -u -j - - - -(x -( -0 -) - - -) - - -This part of -dw - contains the same values as are returned -by reverse_one -. - -
-
-Second Order Partials -
-For - -j -= -0 -, - -, -n -- -1 - - -, - - -dw -[ -j -* -2 -+ -1 -] -= - -W -1 - - - -u -j - - - -(x -( -0 -) - - -) -= - - -= -0 - -n --1 - - -x - -( -1 -) - - -[w -0 - -* - -2 - -F -0 - - - -u - - - -u -j - - - -(x -( -0 -) - - -) -+ - -+ -w -m --1 - - -* - -2 - -F -m --1 - - - - -u - - - -u -j - - - -(x -( -0 -) - - -) -] - - -
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - - -
-
-Hessian Times Direction -
-Suppose that - -w - - - is the i-th elementary vector. -It follows that for - -j -= -0 -, - -, -n --1 - - - - - - -dw -[ -j -* -2 -+ -1 -] - -= - -w -i - - - -= -0 - -n --1 - - - -2 - -F -i - - - -u -j - - -u - - - - -(x -( -0 -) - - -) -x - -( -1 -) - - - - -= - -[F -i -( -2 -) - - -(x -( -0 -) - - -) -* -x -( -1 -) - - -] -j - - - - -Thus the vector - -( -dw -[ -1 -] -, -dw -[ -3 -] -, - -, -dw -[ -n -* -q -- -1 -] -) - - - -is equal to the Hessian of - -F -i - -( -x -) - - - times the direction - - -x -( -1 -) - - - - -. -In the special case where - - -x -( -1 -) - - - - - is the l-th -elementary vector -, - - -dw -[ -j -* -2 -+ -1 -] -= - -2 - -F -i - - - -x -j - - -x - - - - -(x -( -0 -) - - -) - - -
-Example - -
-The files -reverse_two.cpp - -and -hes_times_dir.cpp - -contain a examples and tests of reverse mode calculations. -They return true if they succeed and false otherwise. - - -
Input File: omh/reverse/reverse_two.omh - - - diff -Nru cppad-2018.00.00.0/doc/_reverse_two_xml.js cppad-2019.02.00.0/doc/_reverse_two_xml.js --- cppad-2018.00.00.0/doc/_reverse_two_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_reverse_two_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'reverse.xml', -'reverse_two.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'reverse_one.xml', -'reverse_two.xml', -'reverse_any.xml', -'subgraph_reverse.xml' -]; -var list_down0 = [ -'reverse_two.cpp.xml', -'hes_times_dir.cpp.xml' -]; -var list_current0 = [ -'reverse_two.xml#Syntax', -'reverse_two.xml#Purpose', -'reverse_two.xml#x^(k)', -'reverse_two.xml#W', -'reverse_two.xml#f', -'reverse_two.xml#w', -'reverse_two.xml#dw', -'reverse_two.xml#dw.First Order Partials', -'reverse_two.xml#dw.Second Order Partials', -'reverse_two.xml#Vector', -'reverse_two.xml#Hessian Times Direction', -'reverse_two.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-2018.00.00.0/doc/reverse.xml cppad-2019.02.00.0/doc/reverse.xml --- cppad-2018.00.00.0/doc/reverse.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/reverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ - - - -Reverse Mode - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Reverse Mode
-
-Multiple Directions -
-Reverse mode after Forward(q, r, xq) - -with number of directions -r != 1 - is not yet supported. -There is one exception, reverse_one - is allowed -because there is only one zero order forward direction. -After such an operation, only the zero order forward -results are retained (the higher order forward results are lost). - -
-
-Contents -
- -
reverse_oneFirst Order Reverse Mode
reverse_twoSecond Order Reverse Mode
reverse_anyAny Order Reverse Mode
subgraph_reverseReverse Mode Using Subgraphs
-
Input File: omh/adfun.omh - - - diff -Nru cppad-2018.00.00.0/doc/_reverse_xml.js cppad-2019.02.00.0/doc/_reverse_xml.js --- cppad-2018.00.00.0/doc/_reverse_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_reverse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'reverse.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down0 = [ -'reverse_one.xml', -'reverse_two.xml', -'reverse_any.xml', -'subgraph_reverse.xml' -]; -var list_current0 = [ -'reverse.xml#Multiple Directions', -'reverse.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-2018.00.00.0/doc/rev_hes_sparsity.cpp.xml cppad-2019.02.00.0/doc/rev_hes_sparsity.cpp.xml --- cppad-2018.00.00.0/doc/rev_hes_sparsity.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/rev_hes_sparsity.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ - - - -Reverse Mode Hessian Sparsity: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -rev_hes_sparsity.cppHeadings

- - - -
Reverse Mode Hessian Sparsity: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool rev_hes_sparsity(void)
-{     bool ok = true;
-     using CppAD::AD;
-     typedef CPPAD_TESTVECTOR(size_t)     SizeVector;
-     typedef CppAD::sparse_rc<SizeVector> sparsity;
-     //
-     // domain space vector
-     size_t n = 3;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-     ax[2] = 2.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = sin( ax[2] );
-     ay[1] = ax[0] * ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // sparsity pattern for the identity matrix
-     size_t nr     = n;
-     size_t nc     = n;
-     size_t nnz_in = n;
-     sparsity pattern_in(nr, nc, nnz_in);
-     for(size_t k = 0; k < nnz_in; k++)
-     {     size_t r = k;
-          size_t c = k;
-          pattern_in.set(k, r, c);
-     }
-     // compute sparsity pattern for J(x) = F'(x)
-     bool transpose       = false;
-     bool dependency      = false;
-     bool internal_bool   = false;
-     sparsity pattern_out;
-     f.for_jac_sparsity(
-          pattern_in, transpose, dependency, internal_bool, pattern_out
-     );
-     //
-     // compute sparsity pattern for H(x) = F_1''(x)
-     CPPAD_TESTVECTOR(bool) select_range(m);
-     select_range[0] = false;
-     select_range[1] = true;
-     f.rev_hes_sparsity(
-          select_range, transpose, internal_bool, pattern_out
-     );
-     size_t nnz = pattern_out.nnz();
-     ok        &= nnz == 2;
-     ok        &= pattern_out.nr() == n;
-     ok        &= pattern_out.nc() == n;
-     {     // check results
-          const SizeVector& row( pattern_out.row() );
-          const SizeVector& col( pattern_out.col() );
-          SizeVector row_major = pattern_out.row_major();
-          //
-          ok &= row[ row_major[0] ] ==  0  && col[ row_major[0] ] ==  1;
-          ok &= row[ row_major[1] ] ==  1  && col[ row_major[1] ] ==  0;
-     }
-     //
-     // compute sparsity pattern for H(x) = F_0''(x)
-     select_range[0] = true;
-     select_range[1] = false;
-     f.rev_hes_sparsity(
-          select_range, transpose, internal_bool, pattern_out
-     );
-     nnz = pattern_out.nnz();
-     ok &= nnz == 1;
-     ok &= pattern_out.nr() == n;
-     ok &= pattern_out.nc() == n;
-     {     // check results
-          const SizeVector& row( pattern_out.row() );
-          const SizeVector& col( pattern_out.col() );
-          //
-          ok &= row[0] ==  2  && col[0] ==  2;
-     }
-     return ok;
-}
-
-
Input File: example/sparse/rev_hes_sparsity.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_rev_hes_sparsity.cpp_xml.js cppad-2019.02.00.0/doc/_rev_hes_sparsity.cpp_xml.js --- cppad-2018.00.00.0/doc/_rev_hes_sparsity.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rev_hes_sparsity.cpp_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', -'adfun.xml', -'sparsity_pattern.xml', -'rev_hes_sparsity.xml', -'rev_hes_sparsity.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down1 = [ -'rev_hes_sparsity.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-2018.00.00.0/doc/rev_hes_sparsity.xml cppad-2019.02.00.0/doc/rev_hes_sparsity.xml --- cppad-2018.00.00.0/doc/rev_hes_sparsity.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/rev_hes_sparsity.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,453 +0,0 @@ - - - -Reverse Mode Hessian Sparsity Patterns - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Reverse Mode Hessian Sparsity Patterns
-
-Syntax - -
- -f.rev_hes_sparsity(
-     
select_rangetransposeinternal_boolpattern_out
-)
- - -
-
-Purpose -
-We use - -F -: -R - -n - - -R - -m - - - - to denote the -AD function - corresponding to -the operation sequence stored in -f -. -Fix - -R - -R - -n -× - - - - - -, - -s - -R - -m - - - - -and define the function - - -H -( -x -) -= -( -s -T - - -F -) -( -2 -) - - -( -x -) -R - - -Given a sparsity pattern - for - -R - - - -and for the vector - -s - - -, -rev_hes_sparsity computes a sparsity pattern for - -H -( -x -) - - -. - -
-
-x -
-Note that the sparsity pattern - -H -( -x -) - - - corresponds to the -operation sequence stored in -f - and does not depend on -the argument -x -. - -
-
-BoolVector -
-The type -BoolVector - is a SimpleVector - class with -elements of type - -bool. - -
-
-SizeVector -
-The type -SizeVector - is a SimpleVector - class with -elements of type - -size_t. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-
-R -
-The sparsity pattern for the matrix - -R - - - is specified by -pattern_in - in the previous call - -
-     
f.for_jac_sparsity(
-          
pattern_intransposedependencyinternal_boolpattern_out
-)
- - -
-
-select_range -
-The argument -select_range - has prototype - -
-     const 
BoolVectorselect_range
-
-It has size - -m - - - and specifies which components of the vector - - -s - - - are non-zero; i.e., -select_range[i] - is true -if and only if - -s -i - - - - is possibly non-zero. - -
-
-transpose -
-This argument has prototype - -
-     bool 
transpose
-
-See pattern_out - below. - -
-
-internal_bool -
-If this is true, calculations are done with sets represented by a vector -of boolean values. Otherwise, a vector of sets of integers is used. -This must be the same as in the previous call to - -f.for_jac_sparsity -. - -
-
-pattern_out -
-This argument has prototype - -
-     sparse_rc<
SizeVector>& pattern_out
-
-This input value of -pattern_out - does not matter. -If -transpose - it is false (true), -upon return -pattern_out - is a sparsity pattern for - - -H -( -x -) - - - ( - -H -( -x -) -T - - - - -). - -
-
-Sparsity for Entire Hessian -
-Suppose that - -R - - - is the - -n -× -n - - - identity matrix. -In this case, -pattern_out - is a sparsity pattern for - - -( -s -T - - -F -) -F -( -2 -) - - -( -x -) - - -. - -
-
-Example - -
-The file -rev_hes_sparsity.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/rev_hes_sparsity.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_rev_hes_sparsity_xml.js cppad-2019.02.00.0/doc/_rev_hes_sparsity_xml.js --- cppad-2018.00.00.0/doc/_rev_hes_sparsity_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rev_hes_sparsity_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparsity_pattern.xml', -'rev_hes_sparsity.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down0 = [ -'rev_hes_sparsity.cpp.xml' -]; -var list_current0 = [ -'rev_hes_sparsity.xml#Syntax', -'rev_hes_sparsity.xml#Purpose', -'rev_hes_sparsity.xml#x', -'rev_hes_sparsity.xml#BoolVector', -'rev_hes_sparsity.xml#SizeVector', -'rev_hes_sparsity.xml#f', -'rev_hes_sparsity.xml#R', -'rev_hes_sparsity.xml#select_range', -'rev_hes_sparsity.xml#transpose', -'rev_hes_sparsity.xml#internal_bool', -'rev_hes_sparsity.xml#pattern_out', -'rev_hes_sparsity.xml#Sparsity for Entire Hessian', -'rev_hes_sparsity.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-2018.00.00.0/doc/rev_jac_sparsity.cpp.xml cppad-2019.02.00.0/doc/rev_jac_sparsity.cpp.xml --- cppad-2018.00.00.0/doc/rev_jac_sparsity.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/rev_jac_sparsity.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ - - - -Reverse Mode Jacobian Sparsity: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -rev_jac_sparsity.cppHeadings

- - - -
Reverse Mode Jacobian Sparsity: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool rev_jac_sparsity(void)
-{     bool ok = true;
-     using CppAD::AD;
-     typedef CPPAD_TESTVECTOR(size_t)     SizeVector;
-     typedef CppAD::sparse_rc<SizeVector> sparsity;
-     //
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = ax[0];
-     ay[1] = ax[0] * ax[1];
-     ay[2] = ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // sparsity pattern for the identity matrix
-     size_t nr     = m;
-     size_t nc     = m;
-     size_t nnz_in = m;
-     sparsity pattern_in(nr, nc, nnz_in);
-     for(size_t k = 0; k < nnz_in; k++)
-     {     size_t r = k;
-          size_t c = k;
-          pattern_in.set(k, r, c);
-     }
-     // compute sparsite pattern for J(x) = F'(x)
-     bool transpose       = false;
-     bool dependency      = false;
-     bool internal_bool   = false;
-     sparsity pattern_out;
-     f.rev_jac_sparsity(
-          pattern_in, transpose, dependency, internal_bool, pattern_out
-     );
-     size_t nnz = pattern_out.nnz();
-     ok        &= nnz == 4;
-     ok        &= pattern_out.nr() == m;
-     ok        &= pattern_out.nc() == n;
-     {     // check results
-          const SizeVector& row( pattern_out.row() );
-          const SizeVector& col( pattern_out.col() );
-          SizeVector col_major = pattern_out.col_major();
-          //
-          ok &= row[ col_major[0] ] ==  0  && col[ col_major[0] ] ==  0;
-          ok &= row[ col_major[1] ] ==  1  && col[ col_major[1] ] ==  0;
-          ok &= row[ col_major[2] ] ==  1  && col[ col_major[2] ] ==  1;
-          ok &= row[ col_major[3] ] ==  2  && col[ col_major[3] ] ==  1;
-     }
-     // note that the transpose of the identity is the identity
-     transpose     = true;
-     internal_bool = true;
-     f.rev_jac_sparsity(
-          pattern_in, transpose, dependency, internal_bool, pattern_out
-     );
-     nnz  = pattern_out.nnz();
-     ok  &= nnz == 4;
-     ok  &= pattern_out.nr() == n;
-     ok  &= pattern_out.nc() == m;
-     {     // check results
-          const SizeVector& row( pattern_out.row() );
-          const SizeVector& col( pattern_out.col() );
-          SizeVector row_major = pattern_out.row_major();
-          //
-          ok &= col[ row_major[0] ] ==  0  && row[ row_major[0] ] ==  0;
-          ok &= col[ row_major[1] ] ==  1  && row[ row_major[1] ] ==  0;
-          ok &= col[ row_major[2] ] ==  1  && row[ row_major[2] ] ==  1;
-          ok &= col[ row_major[3] ] ==  2  && row[ row_major[3] ] ==  1;
-     }
-     return ok;
-}
-
-
Input File: example/sparse/rev_jac_sparsity.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_rev_jac_sparsity.cpp_xml.js cppad-2019.02.00.0/doc/_rev_jac_sparsity.cpp_xml.js --- cppad-2018.00.00.0/doc/_rev_jac_sparsity.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rev_jac_sparsity.cpp_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', -'adfun.xml', -'sparsity_pattern.xml', -'rev_jac_sparsity.xml', -'rev_jac_sparsity.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down1 = [ -'rev_jac_sparsity.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-2018.00.00.0/doc/rev_jac_sparsity.xml cppad-2019.02.00.0/doc/rev_jac_sparsity.xml --- cppad-2018.00.00.0/doc/rev_jac_sparsity.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/rev_jac_sparsity.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,433 +0,0 @@ - - - -Reverse Mode Jacobian Sparsity Patterns - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Reverse Mode Jacobian Sparsity Patterns
-
-Syntax - -
- -f.rev_jac_sparsity(
-     
pattern_intransposedependencyinternal_boolpattern_out
-)
- - -
-
-Purpose -
-We use - -F -: -R - -n - - -R - -m - - - - to denote the -AD function - corresponding to -the operation sequence stored in -f -. -Fix - -R - -R - - -× -m - - - - - and define the function - - -J -( -x -) -= -R -* -F -( -1 -) - - -( -x -) - - -Given the sparsity pattern - for - -R - - -, -rev_jac_sparsity computes a sparsity pattern for - -J -( -x -) - - -. - -
-
-x -
-Note that the sparsity pattern - -J -( -x -) - - - corresponds to the -operation sequence stored in -f - and does not depend on -the argument -x -. -(The operation sequence may contain -CondExp - and VecAD - operations.) - -
-
-SizeVector -
-The type -SizeVector - is a SimpleVector - class with -elements of type - -size_t. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-
-pattern_in -
-The argument -pattern_in - has prototype - -
-     const sparse_rc<
SizeVector>& pattern_in
-
-see sparse_rc -. -If -transpose - it is false (true), - -pattern_in - is a sparsity pattern for - -R - - - ( - -R -T - - - - -). - -
-
-transpose -
-This argument has prototype - -
-     bool 
transpose
-
-See pattern_in - above and -pattern_out - below. - -
-
-dependency -
-This argument has prototype - -
-     bool 
dependency
-
-see pattern_out - below. - -
-
-internal_bool -
-If this is true, calculations are done with sets represented by a vector -of boolean values. Otherwise, a vector of sets of integers is used. - -
-
-pattern_out -
-This argument has prototype - -
-     sparse_rc<
SizeVector>& pattern_out
-
-This input value of -pattern_out - does not matter. -If -transpose - it is false (true), -upon return -pattern_out - is a sparsity pattern for - - -J -( -x -) - - - ( - -J -( -x -) -T - - - - -). -If -dependency - is true, -pattern_out - is a -dependency pattern - -instead of sparsity pattern. - -
-
-Sparsity for Entire Jacobian -
-Suppose that - - -R - - - is the - -m -× -m - - - identity matrix. -In this case, -pattern_out - is a sparsity pattern for - - -F -( -1 -) - - -( -x -) - - - ( - -F -( -1 -) - - -( -x -) -T - - - - - ) -if -transpose - is false (true). - -
-
-Example - -
-The file -rev_jac_sparsity.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/rev_jac_sparsity.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_rev_jac_sparsity_xml.js cppad-2019.02.00.0/doc/_rev_jac_sparsity_xml.js --- cppad-2018.00.00.0/doc/_rev_jac_sparsity_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rev_jac_sparsity_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparsity_pattern.xml', -'rev_jac_sparsity.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down0 = [ -'rev_jac_sparsity.cpp.xml' -]; -var list_current0 = [ -'rev_jac_sparsity.xml#Syntax', -'rev_jac_sparsity.xml#Purpose', -'rev_jac_sparsity.xml#x', -'rev_jac_sparsity.xml#SizeVector', -'rev_jac_sparsity.xml#f', -'rev_jac_sparsity.xml#pattern_in', -'rev_jac_sparsity.xml#transpose', -'rev_jac_sparsity.xml#dependency', -'rev_jac_sparsity.xml#internal_bool', -'rev_jac_sparsity.xml#pattern_out', -'rev_jac_sparsity.xml#Sparsity for Entire Jacobian', -'rev_jac_sparsity.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-2018.00.00.0/doc/rev_one.cpp.xml cppad-2019.02.00.0/doc/rev_one.cpp.xml --- cppad-2018.00.00.0/doc/rev_one.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/rev_one.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ - - - -First Order Derivative Driver: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -rev_one.cppHeadings

- - - -
First Order Derivative Driver: Example and Test
-
# include <cppad/cppad.hpp>
-namespace { // -------------------------------------------------------
-// define the template function RevOneCases<Vector> in empty namespace
-template <typename Vector>
-bool RevOneCases()
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     using CppAD::exp;
-     using CppAD::sin;
-     using CppAD::cos;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>)  X(n);
-     X[0] = 1.;
-     X[1] = 2.;
-
-     // declare independent variables and starting recording
-     CppAD::Independent(X);
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>)  Y(m);
-     Y[0] = X[0] * exp( X[1] );
-     Y[1] = X[0] * sin( X[1] );
-     Y[2] = X[0] * cos( X[1] );
-
-     // create f: X -> Y and stop tape recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // new value for the independent variable vector
-     Vector x(n);
-     x[0] = 2.;
-     x[1] = 1.;
-
-     // compute and check derivative of y[0]
-     Vector dw(n);
-     dw  = f.RevOne(x, 0);
-     ok &= NearEqual(dw[0],      exp(x[1]), eps99, eps99); // w.r.t x[0]
-     ok &= NearEqual(dw[1], x[0]*exp(x[1]), eps99, eps99); // w.r.t x[1]
-
-     // compute and check derivative of y[1]
-     dw  = f.RevOne(x, 1);
-     ok &= NearEqual(dw[0],      sin(x[1]), eps99, eps99);
-     ok &= NearEqual(dw[1], x[0]*cos(x[1]), eps99, eps99);
-
-     // compute and check derivative of y[2]
-     dw  = f.RevOne(x, 2);
-     ok &= NearEqual(dw[0],        cos(x[1]), eps99, eps99);
-     ok &= NearEqual(dw[1], - x[0]*sin(x[1]), eps99, eps99);
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool RevOne(void)
-{     bool ok = true;
-     // Run with Vector equal to three different cases
-     // all of which are Simple Vectors with elements of type double.
-     ok &= RevOneCases< CppAD::vector  <double> >();
-     ok &= RevOneCases< std::vector    <double> >();
-     ok &= RevOneCases< std::valarray  <double> >();
-     return ok;
-}
-
-
Input File: example/general/rev_one.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_rev_one.cpp_xml.js cppad-2019.02.00.0/doc/_rev_one.cpp_xml.js --- cppad-2018.00.00.0/doc/_rev_one.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rev_one.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'revone.xml', -'rev_one.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down1 = [ -'rev_one.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-2018.00.00.0/doc/revone.xml cppad-2019.02.00.0/doc/revone.xml --- cppad-2018.00.00.0/doc/revone.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/revone.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,397 +0,0 @@ - - - -First Order Derivative: Driver Routine - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
First Order Derivative: Driver Routine
-
-Syntax - -
- -dw = f.RevOne(xi) - - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -The syntax above sets -dw - to the -derivative of - -F -i - - - - with respect to - -x - - -; i.e., - - -dw -= -F -i -( -1 -) - - -( -x -) -= -[ -F -i - - - -x -0 - - - -( -x -) -, - -, - -F -i - - - -x -n --1 - - - - -( -x -) -] - - -
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const -(see RevOne Uses Forward - below). - -
-
-x -
-The argument -x - has prototype - -
-     const 
Vector &x
-
-(see Vector - below) -and its size -must be equal to -n -, the dimension of the -domain - space for -f -. -It specifies -that point at which to evaluate the derivative. - -
-
-i -
-The index -i - has prototype - -
-     size_t 
i
-
-and is less than - -m - - -, the dimension of the -range - space for -f -. -It specifies the -component of - -F - - - that we are computing the derivative of. - -
-
-dw -
-The result -dw - has prototype - -
-     
Vector dw
-
-(see Vector - below) -and its size is -n -, the dimension of the -domain - space for -f -. -The value of -dw - is the derivative of - -F -i - - - - -evaluated at -x -; i.e., -for - -j -= -0 -, - -, -n -- -1 - - - - - -. -dw -[ -j -] -= - -F -i - - - -x -j - - - -( -x -) - - -
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-RevOne Uses Forward -
-After each call to Forward -, -the object -f - contains the corresponding -Taylor coefficients -. -After a call to RevOne, -the zero order Taylor coefficients correspond to - -f.Forward(0, x) - -and the other coefficients are unspecified. - -
-
-Example - -
-The routine -RevOne - is both an example and test. -It returns true, if it succeeds and false otherwise. - - -
Input File: cppad/core/rev_one.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_revone_xml.js cppad-2019.02.00.0/doc/_revone_xml.js --- cppad-2018.00.00.0/doc/_revone_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_revone_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'revone.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down0 = [ -'rev_one.cpp.xml' -]; -var list_current0 = [ -'revone.xml#Syntax', -'revone.xml#Purpose', -'revone.xml#f', -'revone.xml#x', -'revone.xml#i', -'revone.xml#dw', -'revone.xml#Vector', -'revone.xml#RevOne Uses Forward', -'revone.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-2018.00.00.0/doc/rev_sparse_hes.cpp.xml cppad-2019.02.00.0/doc/rev_sparse_hes.cpp.xml --- cppad-2018.00.00.0/doc/rev_sparse_hes.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/rev_sparse_hes.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,291 +0,0 @@ - - - -Reverse Mode Hessian Sparsity: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -rev_sparse_hes.cppHeadings

- - - -
Reverse Mode Hessian Sparsity: Example and Test
-

-# include <cppad/cppad.hpp>
-namespace { // -------------------------------------------------------------
-
-// expected sparsity pattern
-bool check_f0[] = {
-     false, false, false,  // partials w.r.t x0 and (x0, x1, x2)
-     false, false, false,  // partials w.r.t x1 and (x0, x1, x2)
-     false, false, true    // partials w.r.t x2 and (x0, x1, x2)
-};
-bool check_f1[] = {
-     false,  true, false,  // partials w.r.t x0 and (x0, x1, x2)
-     true,  false, false,  // partials w.r.t x1 and (x0, x1, x2)
-     false, false, false   // partials w.r.t x2 and (x0, x1, x2)
-};
-
-// define the template function BoolCases<Vector> in empty namespace
-template <typename Vector> // vector class, elements of type bool
-bool BoolCases(void)
-{     bool ok = true;
-     using CppAD::AD;
-
-     // domain space vector
-     size_t n = 3;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-     ax[2] = 2.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = sin( ax[2] );
-     ay[1] = ax[0] * ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // sparsity pattern for the identity matrix
-     Vector r(n * n);
-     size_t i, j;
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j < n; j++)
-               r[ i * n + j ] = (i == j);
-     }
-
-     // compute sparsity pattern for J(x) = F^{(1)} (x)
-     f.ForSparseJac(n, r);
-
-     // compute sparsity pattern for H(x) = F_0^{(2)} (x)
-     Vector s(m);
-     for(i = 0; i < m; i++)
-          s[i] = false;
-     s[0] = true;
-     Vector h(n * n);
-     h    = f.RevSparseHes(n, s);
-
-     // check values
-     for(i = 0; i < n; i++)
-          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)
-     for(i = 0; i < m; i++)
-          s[i] = false;
-     s[1] = true;
-     h    = f.RevSparseHes(n, s);
-
-     // check values
-     for(i = 0; i < n; i++)
-          for(j = 0; j < n; j++)
-               ok &= (h[ i * n + j ] == check_f1[ i * n + j ] );
-
-     // call that transposed the result
-     bool transpose = true;
-     h    = f.RevSparseHes(n, s, transpose);
-
-     // This h is symmetric, because R is symmetric, not really testing here
-     for(i = 0; i < n; i++)
-          for(j = 0; j < n; j++)
-               ok &= (h[ j * n + i ] == check_f1[ i * n + j ] );
-
-     return ok;
-}
-// define the template function SetCases<Vector> in empty namespace
-template <typename Vector> // vector class, elements of type std::set<size_t>
-bool SetCases(void)
-{     bool ok = true;
-     using CppAD::AD;
-
-     // domain space vector
-     size_t n = 3;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-     ax[2] = 2.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = sin( ax[2] );
-     ay[1] = ax[0] * ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // sparsity pattern for the identity matrix
-     Vector r(n);
-     size_t i;
-     for(i = 0; i < n; i++)
-     {     assert( r[i].empty() );
-          r[i].insert(i);
-     }
-
-     // compute sparsity pattern for J(x) = F^{(1)} (x)
-     f.ForSparseJac(n, r);
-
-     // compute sparsity pattern for H(x) = F_0^{(2)} (x)
-     Vector s(1);
-     assert( s[0].empty() );
-     s[0].insert(0);
-     Vector h(n);
-     h    = f.RevSparseHes(n, s);
-
-     // check values
-     std::set<size_t>::iterator itr;
-     size_t j;
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j < n; j++)
-          {     bool found = h[i].find(j) != h[i].end();
-               ok        &= (found == check_f0[i * n + j]);
-          }
-     }
-
-     // compute sparsity pattern for H(x) = F_1^{(2)} (x)
-     s[0].clear();
-     assert( s[0].empty() );
-     s[0].insert(1);
-     h    = f.RevSparseHes(n, s);
-
-     // check values
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j < n; j++)
-          {     bool found = h[i].find(j) != h[i].end();
-               ok        &= (found == check_f1[i * n + j]);
-          }
-     }
-
-     // call that transposed the result
-     bool transpose = true;
-     h    = f.RevSparseHes(n, s, transpose);
-
-     // This h is symmetric, because R is symmetric, not really testing here
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j < n; j++)
-          {     bool found = h[j].find(i) != h[j].end();
-               ok        &= (found == check_f1[i * n + j]);
-          }
-     }
-
-     return ok;
-}
-} // End empty namespace
-
-# include <vector>
-# include <valarray>
-bool rev_sparse_hes(void)
-{     bool ok = true;
-     // Run with Vector equal to four different cases
-     // all of which are Simple Vectors with elements of type bool.
-     ok &= BoolCases< CppAD::vector  <bool> >();
-     ok &= BoolCases< CppAD::vectorBool     >();
-     ok &= BoolCases< std::vector    <bool> >();
-     ok &= BoolCases< std::valarray  <bool> >();
-
-     // Run with Vector equal to two different cases both of which are
-     // Simple Vectors with elements of type std::set<size_t>
-     typedef std::set<size_t> set;
-     ok &= SetCases< CppAD::vector  <set> >();
-     ok &= SetCases< std::vector    <set> >();
-
-     // Do not use valarray because its element access in the const case
-     // returns a copy instead of a reference
-     // ok &= SetCases< std::valarray  <set> >();
-
-     return ok;
-}
-
-
-
-
Input File: example/sparse/rev_sparse_hes.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_rev_sparse_hes.cpp_xml.js cppad-2019.02.00.0/doc/_rev_sparse_hes.cpp_xml.js --- cppad-2018.00.00.0/doc/_rev_sparse_hes.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rev_sparse_hes.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparsity_pattern.xml', -'revsparsehes.xml', -'rev_sparse_hes.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down1 = [ -'rev_sparse_hes.cpp.xml', -'sparsity_sub.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-2018.00.00.0/doc/revsparsehes.xml cppad-2019.02.00.0/doc/revsparsehes.xml --- cppad-2018.00.00.0/doc/revsparsehes.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/revsparsehes.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,703 +0,0 @@ - - - -Hessian Sparsity Pattern: Reverse Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Hessian Sparsity Pattern: Reverse Mode
-
-Syntax - -
- -h = f.RevSparseHes(qs)
-
- -h = f.RevSparseHes(qstranspose) - - -
-
-Purpose -
-We use - -F -: -R - -n - - -R - -m - - - - to denote the -AD function - corresponding to -f -. -For a fixed matrix - -R - -R - -n -× -q - - - - - -and a fixed vector - -S - -R - -1 -× -m - - - - -, -we define - - - -H -( -x -) - -= - - -x - -[ -u - -S -* -F -[ -x -+ -R -* -u -] -] -u -= -0 - - - - -= - -R -T - - -* -( -S -* -F -) -( -2 -) - - -( -x -) - -H -( -x -) -T - - - -= - -( -S -* -F -) -( -2 -) - - -( -x -) -* -R - - - -Given a -sparsity pattern - -for the matrix - -R - - - and the vector - -S - - -, -RevSparseHes returns a sparsity pattern for the - -H -( -x -) - - -. - -
-
-f -
-The object -f - has prototype - -
-     const ADFun<
Basef
-
-
-x -
-If the operation sequence in -f - is -independent - of -the independent variables in - -x - -B -n - - - -, -the sparsity pattern is valid for all values of -(even if it has CondExp - or VecAD - operations). - -
-
-q -
-The argument -q - has prototype - -
-     size_t 
q
-
-It specifies the number of columns in - -R - -R - -n -× -q - - - - - -and the number of rows in - -H -( -x -) - -R - -q -× -n - - - - -. -It must be the same value as in the previous ForSparseJac - call - -
-     
f.ForSparseJac(qrr_transpose)
-
-Note that if -r_transpose - is true, -r - in the call above -corresponding to - -R -T - - - -R - -q -× -n - - - - - - -
-
-transpose -
-The argument -transpose - has prototype - -
-     bool 
transpose
-
-The default value false is used when -transpose - is not present. - - -
-
-r -
-The matrix - -R - - - is specified by the previous call - -
-     
f.ForSparseJac(qrtranspose)
-
-see r -. -The type of the elements of -VectorSet - must be the -same as the type of the elements of -r -. - -
-
-s -
-The argument -s - has prototype - -
-     const 
VectorSets
-
-(see VectorSet - below) -If it has elements of type bool, -its size is - -m - - -. -If it has elements of type std::set<size_t>, -its size is one and all the elements of -s[0] - -are between zero and - -m -- -1 - - -. -It specifies a -sparsity pattern - -for the vector -S -. - -
-
-h -
-The result -h - has prototype - -
-     
VectorSeth
-
-(see VectorSet - below). - -
-
-transpose false -
-If -h - has elements of type bool, -its size is - -q -* -n - - -. -If it has elements of type std::set<size_t>, -its size is - -q - - - and all the set elements are between -zero and -n-1 - inclusive. -It specifies a -sparsity pattern - -for the matrix - -H -( -x -) - - -. - -
-
-transpose true -
-If -h - has elements of type bool, -its size is - -n -* -q - - -. -If it has elements of type std::set<size_t>, -its size is - -n - - - and all the set elements are between -zero and -q-1 - inclusive. -It specifies a -sparsity pattern - -for the matrix - -H -( -x -) -T - - - - -. - -
-
-VectorSet -
-The type -VectorSet - must be a SimpleVector - class with -elements of type - -bool or std::set<size_t>; -see sparsity pattern - for a discussion -of the difference. -The type of the elements of -VectorSet - must be the -same as the type of the elements of -r -. - -
-
-Entire Sparsity Pattern -
-Suppose that - -q -= -n - - - and - - -R - -R - -n -× -n - - - - - is the - -n -× -n - - - identity matrix. -Further suppose that the - -S - - - is the k-th -elementary vector -; i.e. - - -S -j - -= -{ -1 - -if - - -j -= -k - -0 - -otherwise - - - - - -In this case, -the corresponding value -h - is a -sparsity pattern for the Hessian matrix - - -F -k -( -2 -) - - -( -x -) - -R - -n -× -n - - - - -. - -
-
-Example - -
-The file -rev_sparse_hes.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. -The file -sparsity_sub.cpp - -contains an example and test of using RevSparseHes -to compute the sparsity pattern for a subset of the Hessian. - - -
Input File: cppad/core/rev_sparse_hes.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_revsparsehes_xml.js cppad-2019.02.00.0/doc/_revsparsehes_xml.js --- cppad-2018.00.00.0/doc/_revsparsehes_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_revsparsehes_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparsity_pattern.xml', -'revsparsehes.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down0 = [ -'rev_sparse_hes.cpp.xml', -'sparsity_sub.cpp.xml' -]; -var list_current0 = [ -'revsparsehes.xml#Syntax', -'revsparsehes.xml#Purpose', -'revsparsehes.xml#f', -'revsparsehes.xml#x', -'revsparsehes.xml#q', -'revsparsehes.xml#transpose', -'revsparsehes.xml#r', -'revsparsehes.xml#s', -'revsparsehes.xml#h', -'revsparsehes.xml#h.transpose false', -'revsparsehes.xml#h.transpose true', -'revsparsehes.xml#VectorSet', -'revsparsehes.xml#Entire Sparsity Pattern', -'revsparsehes.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-2018.00.00.0/doc/rev_sparse_jac.cpp.xml cppad-2019.02.00.0/doc/rev_sparse_jac.cpp.xml --- cppad-2018.00.00.0/doc/rev_sparse_jac.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/rev_sparse_jac.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,257 +0,0 @@ - - - -Reverse Mode Jacobian Sparsity: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -rev_sparse_jac.cppHeadings

- - - -
Reverse Mode Jacobian Sparsity: Example and Test
-

-# include <cppad/cppad.hpp>
-namespace { // -------------------------------------------------------------
-// define the template function BoolCases<Vector>
-template <typename Vector>  // vector class, elements of type bool
-bool BoolCases(void)
-{     bool ok = true;
-     using CppAD::AD;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = ax[0];
-     ay[1] = ax[0] * ax[1];
-     ay[2] = ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // sparsity pattern for the identity matrix
-     Vector r(m * m);
-     size_t i, j;
-     for(i = 0; i < m; i++)
-     {     for(j = 0; j < m; j++)
-               r[ i * m + j ] = (i == j);
-     }
-
-     // sparsity pattern for F'(x)
-     Vector s(m * n);
-     s = f.RevSparseJac(m, r);
-
-     // check values
-     ok &= (s[ 0 * n + 0 ] == true);  // y[0] does     depend on x[0]
-     ok &= (s[ 0 * n + 1 ] == false); // y[0] does not depend on x[1]
-     ok &= (s[ 1 * n + 0 ] == true);  // y[1] does     depend on x[0]
-     ok &= (s[ 1 * n + 1 ] == true);  // y[1] does     depend on x[1]
-     ok &= (s[ 2 * n + 0 ] == false); // y[2] does not depend on x[0]
-     ok &= (s[ 2 * n + 1 ] == true);  // y[2] does     depend on x[1]
-
-     // sparsity pattern for F'(x)^T, note R is the identity, so R^T = R
-     bool transpose = true;
-     Vector st(n * m);
-     st = f.RevSparseJac(m, r, transpose);
-
-     // check values
-     ok &= (st[ 0 * m + 0 ] == true);  // y[0] does     depend on x[0]
-     ok &= (st[ 1 * m + 0 ] == false); // y[0] does not depend on x[1]
-     ok &= (st[ 0 * m + 1 ] == true);  // y[1] does     depend on x[0]
-     ok &= (st[ 1 * m + 1 ] == true);  // y[1] does     depend on x[1]
-     ok &= (st[ 0 * m + 2 ] == false); // y[2] does not depend on x[0]
-     ok &= (st[ 1 * m + 2 ] == true);  // y[2] does     depend on x[1]
-
-     return ok;
-}
-// define the template function SetCases<Vector>
-template <typename Vector>  // vector class, elements of type std::set<size_t>
-bool SetCases(void)
-{     bool ok = true;
-     using CppAD::AD;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = ax[0];
-     ay[1] = ax[0] * ax[1];
-     ay[2] = ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // sparsity pattern for the identity matrix
-     Vector r(m);
-     size_t i;
-     for(i = 0; i < m; i++)
-     {     assert( r[i].empty() );
-          r[i].insert(i);
-     }
-
-     // sparsity pattern for F'(x)
-     Vector s(m);
-     s = f.RevSparseJac(m, r);
-
-     // check values
-     bool found;
-
-     // y[0] does     depend on x[0]
-     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);
-     // y[1] does     depend on x[0]
-     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);
-     // y[2] does not depend on x[0]
-     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);
-
-     // sparsity pattern for F'(x)^T
-     bool transpose = true;
-     Vector st(n);
-     st = f.RevSparseJac(m, r, transpose);
-
-     // y[0] does     depend on x[0]
-     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);
-     // y[1] does     depend on x[0]
-     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);
-     // y[2] does not depend on x[0]
-     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);
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool RevSparseJac(void)
-{     bool ok = true;
-     // Run with Vector equal to four different cases
-     // all of which are Simple Vectors with elements of type bool.
-     ok &= BoolCases< CppAD::vectorBool     >();
-     ok &= BoolCases< CppAD::vector  <bool> >();
-     ok &= BoolCases< std::vector    <bool> >();
-     ok &= BoolCases< std::valarray  <bool> >();
-
-
-     // Run with Vector equal to two different cases both of which are
-     // Simple Vectors with elements of type std::set<size_t>
-     typedef std::set<size_t> set;
-     ok &= SetCases< CppAD::vector  <set> >();
-     ok &= SetCases< std::vector    <set> >();
-
-     // Do not use valarray because its element access in the const case
-     // returns a copy instead of a reference
-     // ok &= SetCases< std::valarray  <set> >();
-
-     return ok;
-}
-
-
-
Input File: example/sparse/rev_sparse_jac.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_rev_sparse_jac.cpp_xml.js cppad-2019.02.00.0/doc/_rev_sparse_jac.cpp_xml.js --- cppad-2018.00.00.0/doc/_rev_sparse_jac.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rev_sparse_jac.cpp_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', -'adfun.xml', -'sparsity_pattern.xml', -'revsparsejac.xml', -'rev_sparse_jac.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down1 = [ -'rev_sparse_jac.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-2018.00.00.0/doc/revsparsejac.xml cppad-2019.02.00.0/doc/revsparsejac.xml --- cppad-2018.00.00.0/doc/revsparsejac.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/revsparsejac.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,620 +0,0 @@ - - - -Jacobian Sparsity Pattern: Reverse Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Jacobian Sparsity Pattern: Reverse Mode
-
-Syntax - -
- -s = f.RevSparseJac(qr)
-
- -s = f.RevSparseJac(qrtransposedependency) - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -For a fixed matrix - -R - -B -q -× -m - - - - -, -the Jacobian of - -R -* -F -( -x -) - - - -with respect to - -x - - - is - - -S -( -x -) -= -R -* -F -( -1 -) - - -( -x -) - - -Given a -sparsity pattern - -for - -R - - -, -RevSparseJac returns a sparsity pattern for the - -S -( -x -) - - -. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-
-x -
-If the operation sequence in -f - is -independent - of -the independent variables in - -x - -B -n - - - -, -the sparsity pattern is valid for all values of -(even if it has CondExp - or VecAD - operations). - -
-
-q -
-The argument -q - has prototype - -
-     size_t 
q
-
-It specifies the number of rows in - - -R - -B -q -× -m - - - - - and the -Jacobian - -S -( -x -) - -B -q -× -n - - - - -. - -
-
-transpose -
-The argument -transpose - has prototype - -
-     bool 
transpose
-
-The default value false is used when -transpose - is not present. - -
-
-dependency -
-The argument -dependency - has prototype - -
-     bool 
dependency
-
-If -dependency - is true, -the dependency pattern - -(instead of sparsity pattern) is computed. - -
-
-r -
-The argument -s - has prototype - -
-     const 
VectorSetr
-
-see VectorSet - below. - -
-
-transpose false -
-If -r - has elements of type bool, -its size is - -q -* -m - - -. -If it has elements of type std::set<size_t>, -its size is -q - and all its set elements are between -zero and - -m -- -1 - - -. -It specifies a -sparsity pattern - -for the matrix - -R - -B -q -× -m - - - - -. - -
-
-transpose true -
-If -r - has elements of type bool, -its size is - -m -* -q - - -. -If it has elements of type std::set<size_t>, -its size is -m - and all its set elements are between -zero and - -q -- -1 - - -. -It specifies a -sparsity pattern - -for the matrix - -R -T - - - -B -m -× -q - - - - -. - -
-
-s -
-The return value -s - has prototype - -
-     
VectorSet s
-
-see VectorSet - below. - -
-
-transpose false -
-If it has elements of type bool, -its size is - -q -* -n - - -. -If it has elements of type std::set<size_t>, -its size is -q - and all its set elements are between -zero and - -n -- -1 - - -. -It specifies a -sparsity pattern - -for the matrix - -S -( -x -) - -q -× -n - - - -. - -
-
-transpose true -
-If it has elements of type bool, -its size is - -n -* -q - - -. -If it has elements of type std::set<size_t>, -its size is -n - and all its set elements are between -zero and - -q -- -1 - - -. -It specifies a -sparsity pattern - -for the matrix - -S -( -x -) -T - - - -n -× -q - - - -. - -
-
-VectorSet -
-The type -VectorSet - must be a SimpleVector - class with -elements of type - -bool or std::set<size_t>; -see sparsity pattern - for a discussion -of the difference. - -
-
-Entire Sparsity Pattern -
-Suppose that - -q -= -m - - - and - - -R - - - is the - -m -× -m - - - identity matrix. -In this case, -the corresponding value for -s - is a -sparsity pattern for the Jacobian - -S -( -x -) -= -F -( -1 -) - - -( -x -) - - -. - -
-
-Example - -
-The file -rev_sparse_jac.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/rev_sparse_jac.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_revsparsejac_xml.js cppad-2019.02.00.0/doc/_revsparsejac_xml.js --- cppad-2018.00.00.0/doc/_revsparsejac_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_revsparsejac_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparsity_pattern.xml', -'revsparsejac.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down0 = [ -'rev_sparse_jac.cpp.xml' -]; -var list_current0 = [ -'revsparsejac.xml#Syntax', -'revsparsejac.xml#Purpose', -'revsparsejac.xml#f', -'revsparsejac.xml#x', -'revsparsejac.xml#q', -'revsparsejac.xml#transpose', -'revsparsejac.xml#dependency', -'revsparsejac.xml#r', -'revsparsejac.xml#r.transpose false', -'revsparsejac.xml#r.transpose true', -'revsparsejac.xml#s', -'revsparsejac.xml#s.transpose false', -'revsparsejac.xml#s.transpose true', -'revsparsejac.xml#VectorSet', -'revsparsejac.xml#Entire Sparsity Pattern', -'revsparsejac.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-2018.00.00.0/doc/rev_two.cpp.xml cppad-2019.02.00.0/doc/rev_two.cpp.xml --- cppad-2018.00.00.0/doc/rev_two.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/rev_two.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ - - - -Second Partials Reverse Driver: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -rev_two.cppHeadings

- - - -
Second Partials Reverse Driver: Example and Test
-
# include <cppad/cppad.hpp>
-namespace { // -----------------------------------------------------
-// define the template function in empty namespace
-// bool RevTwoCases<VectorBase, VectorSize_t>(void)
-template <class VectorBase, class VectorSize_t>
-bool RevTwoCases()
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     using CppAD::exp;
-     using CppAD::sin;
-     using CppAD::cos;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>)  X(n);
-     X[0] = 1.;
-     X[1] = 2.;
-
-     // declare independent variables and starting recording
-     CppAD::Independent(X);
-
-     // a calculation between the domain and range values
-     AD<double> Square = X[0] * X[0];
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>)  Y(m);
-     Y[0] = Square * exp( X[1] );
-     Y[1] = Square * sin( X[1] );
-     Y[2] = Square * cos( X[1] );
-
-     // create f: X -> Y and stop tape recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // new value for the independent variable vector
-     VectorBase x(n);
-     x[0] = 2.;
-     x[1] = 1.;
-
-     // set i and j to compute specific second partials of y
-     size_t p = 2;
-     VectorSize_t i(p);
-     VectorSize_t j(p);
-     i[0] = 0; j[0] = 0; // for partials y[0] w.r.t x[0] and x[k]
-     i[1] = 1; j[1] = 1; // for partials y[1] w.r.t x[1] and x[k]
-
-     // compute the second partials
-     VectorBase ddw(n * p);
-     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
-     ok &=  NearEqual(      2.*exp(x[1]), ddw[0*p+0], eps99, eps99);
-     ok &=  NearEqual( 2.*x[0]*exp(x[1]), ddw[1*p+0], eps99, eps99);
-
-     // 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
-     ok &=  NearEqual(    2.*x[0]*cos(x[1]), ddw[0*p+1], eps99, eps99);
-     ok &=  NearEqual( -x[0]*x[0]*sin(x[1]), ddw[1*p+1], eps99, eps99);
-
-     return ok;
-}
-} // End empty namespace
-# include <vector>
-# include <valarray>
-bool RevTwo(void)
-{     bool ok = true;
-        // Run with VectorBase equal to three different cases
-        // all of which are Simple Vectors with elements of type double.
-     ok &= RevTwoCases< CppAD::vector <double>, std::vector<size_t> >();
-     ok &= RevTwoCases< std::vector   <double>, std::vector<size_t> >();
-     ok &= RevTwoCases< std::valarray <double>, std::vector<size_t> >();
-
-        // Run with VectorSize_t equal to two other cases
-        // which are Simple Vectors with elements of type size_t.
-     ok &= RevTwoCases< std::vector <double>, CppAD::vector<size_t> >();
-     ok &= RevTwoCases< std::vector <double>, std::valarray<size_t> >();
-
-     return ok;
-}
-
-
Input File: example/general/rev_two.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_rev_two.cpp_xml.js cppad-2019.02.00.0/doc/_rev_two.cpp_xml.js --- cppad-2018.00.00.0/doc/_rev_two.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rev_two.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'revtwo.xml', -'rev_two.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down1 = [ -'rev_two.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-2018.00.00.0/doc/revtwo.xml cppad-2019.02.00.0/doc/revtwo.xml --- cppad-2018.00.00.0/doc/revtwo.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/revtwo.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,514 +0,0 @@ - - - -Reverse Mode Second Partial Derivative Driver - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Reverse Mode Second Partial Derivative Driver
-
-Syntax - -
- -ddw = f.RevTwo(xij) - - - -
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -The syntax above sets - - -ddw -[ -k -* -p -+ - -] -= - -2 - -F -i -[ - -] - - - - -x -j -[ - -] - - - -x -k - - - -( -x -) - - -for - -k -= -0 -, - -, -n --1 - - - -and - - -= -0 -, - -, -p - - -, -where - -p - - - is the size of the vectors -i - and -j -. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const -(see RevTwo Uses Forward - below). - -
-
-x -
-The argument -x - has prototype - -
-     const 
VectorBase &x
-
-(see VectorBase - below) -and its size -must be equal to -n -, the dimension of the -domain - space for -f -. -It specifies -that point at which to evaluate the partial derivatives listed above. - -
-
-i -
-The argument -i - has prototype - -
-     const 
VectorSize_t &i
-
-(see VectorSize_t - below) -We use -p - to denote the size of the vector -i -. -All of the indices in -i - -must be less than -m -, the dimension of the -range - space for -f -; i.e., -for - - -= -0 -, - -, -p --1 - - -, - -i -[ - -] -< -m - - -. - -
-
-j -
-The argument -j - has prototype - -
-     const 
VectorSize_t &j
-
-(see VectorSize_t - below) -and its size must be equal to -p -, -the size of the vector -i -. -All of the indices in -j - -must be less than -n -; i.e., -for - - -= -0 -, - -, -p --1 - - -, - -j -[ - -] -< -n - - -. - -
-
-ddw -
-The result -ddw - has prototype - -
-     
VectorBase ddw
-
-(see VectorBase - below) -and its size is - -n -* -p - - -. -It contains the requested partial derivatives; to be specific, -for - -k -= -0 -, - -, -n -- -1 - - - -and - - -= -0 -, - -, -p -- -1 - - - - - -ddw -[ -k -* -p -+ - -] -= - -2 - -F -i -[ - -] - - - - -x -j -[ - -] - - - -x -k - - - -( -x -) - - -
-VectorBase -
-The type -VectorBase - must be a SimpleVector - class with -elements of type Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-VectorSize_t -
-The type -VectorSize_t - must be a SimpleVector - class with -elements of type size_t -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-RevTwo Uses Forward -
-After each call to Forward -, -the object -f - contains the corresponding -Taylor coefficients -. -After a call to RevTwo, -the zero order Taylor coefficients correspond to - -f.Forward(0, x) - -and the other coefficients are unspecified. - -
-
-Examples - -
-The routine -RevTwo - is both an example and test. -It returns true, if it succeeds and false otherwise. - - -
Input File: cppad/core/rev_two.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_revtwo_xml.js cppad-2019.02.00.0/doc/_revtwo_xml.js --- cppad-2018.00.00.0/doc/_revtwo_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_revtwo_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'drivers.xml', -'revtwo.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'jacobian.xml', -'hessian.xml', -'forone.xml', -'revone.xml', -'fortwo.xml', -'revtwo.xml' -]; -var list_down0 = [ -'rev_two.cpp.xml' -]; -var list_current0 = [ -'revtwo.xml#Syntax', -'revtwo.xml#Purpose', -'revtwo.xml#f', -'revtwo.xml#x', -'revtwo.xml#i', -'revtwo.xml#j', -'revtwo.xml#ddw', -'revtwo.xml#VectorBase', -'revtwo.xml#VectorSize_t', -'revtwo.xml#RevTwo Uses Forward', -'revtwo.xml#Examples' -]; -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-2018.00.00.0/doc/rombergmul.cpp.xml cppad-2019.02.00.0/doc/rombergmul.cpp.xml --- cppad-2018.00.00.0/doc/rombergmul.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/rombergmul.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,208 +0,0 @@ - - - -One Dimensional Romberg Integration: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -Rombergmul.cppHeadings

- - - -
One Dimensional Romberg Integration: Example and Test
-

-# include <cppad/utility/romberg_mul.hpp>
-# include <cppad/utility/vector.hpp>
-# include <cppad/utility/near_equal.hpp>
-
-
-namespace {
-
-     class TestFun {
-     private:
-          const CppAD::vector<size_t> deg;
-     public:
-          // constructor
-          TestFun(const CppAD::vector<size_t> deg_)
-          : deg(deg_)
-          { }
-
-          // function F(x) = x[0]^deg[0] * x[1]^deg[1]
-          double operator () (const CppAD::vector<double> &x)
-          {     size_t i;
-               double   f = 1;
-               for(i = 0; i < deg[0]; i++)
-                    f *= x[0];
-               for(i = 0; i < deg[1]; i++)
-                    f *= x[1];
-               return f;
-          }
-     };
-
-}
-
-bool RombergMul(void)
-{     bool ok = true;
-     size_t i;
-     size_t k;
-
-     CppAD::vector<size_t> deg(2);
-     deg[0] = 5;
-     deg[1] = 3;
-     TestFun F(deg);
-
-     CppAD::RombergMul<
-          TestFun              ,
-          CppAD::vector<size_t>,
-          CppAD::vector<double>,
-          2                    > RombergMulTest;
-
-     // arugments to RombergMul
-     CppAD::vector<double> a(2);
-     CppAD::vector<double> b(2);
-     CppAD::vector<size_t> n(2);
-     CppAD::vector<size_t> p(2);
-     for(i = 0; i < 2; i++)
-     {     a[i] = 0.;
-          b[i] = 1.;
-     }
-     n[0] = 4;
-     n[1] = 3;
-     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)
-     double bpow = 1.;
-     double apow = 1.;
-     for(i = 0; i <= deg[0]; i++)
-     {     bpow *= b[0];
-          apow *= a[0];
-     }
-     double check = (bpow - apow) / double(deg[0]+1);
-     bpow = 1.;
-     apow = 1.;
-     for(i = 0; i <= deg[1]; i++)
-     {     bpow *= b[1];
-          apow *= a[1];
-     }
-     check *= (bpow - apow) / double(deg[1]+1);
-
-     double step = (b[1] - a[1]) / exp(log(2.)*double(n[1]-1));
-     double spow = 1;
-     for(k = 0; k <= n[1]; k++)
-     {     spow = spow * step * step;
-          double bnd = 3 * double(deg[1] + 1) * spow;
-
-          for(i = 0; i < 2; i++)
-               p[i] = k;
-          r    = RombergMulTest(F, a, b, n, p, e);
-
-          ok  &= e < bnd;
-          ok  &= CppAD::NearEqual(check, r, 0., e);
-
-     }
-
-     return ok;
-}
-
-
-
Input File: example/utility/romberg_mul.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_rombergmul.cpp_xml.js cppad-2019.02.00.0/doc/_rombergmul.cpp_xml.js --- cppad-2018.00.00.0/doc/_rombergmul.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rombergmul.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'rombergmul.xml', -'rombergmul.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'rombergmul.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-2018.00.00.0/doc/rombergmul.xml cppad-2019.02.00.0/doc/rombergmul.xml --- cppad-2018.00.00.0/doc/rombergmul.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/rombergmul.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,510 +0,0 @@ - - - -Multi-dimensional Romberg Integration - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Multi-dimensional Romberg Integration
-
-Syntax - -
- -# include <cppad/utility/romberg_mul.hpp>
-
- -RombergMul<FunSizeVectorFloatVectormR - -
-
-r = R(Fabnpe) - - - -
-
-Description -
-Returns the Romberg integration estimate - - -r - - - for the multi-dimensional integral - - -r -= - -a -[ -0 -] - -b -[ -0 -] - - - - -a -[ -m --1 -] - -b -[ -m --1 -] - - - -F -( -x -) - -d - -x -0 - - -d - -x -m --1 - - - -+ - - -i -= -0 - -m --1 - - -O -[( -b -[ -i -] -- -a -[ -i -] -) -/ -2 -n -[ -i -] --1 - - -] -2 -( -p -[ -i -] -+ -1 -) - - - - -
-Include -
-The file cppad/romberg_mul.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-m -
-The template parameter -m - must be convertible to a size_t -object with a value that can be determined at compile time; for example -2. -It determines the dimension of the domain space for the integration. - -
-
-r -
-The return value -r - has prototype - -
-     
Float r
-
-It is the estimate computed by RombergMul for the integral above -(see description of Float - below). - -
-
-F -
-The object -F - has the prototype - -
-     
Fun &F
-
-It must support the operation - -
-     
F(x)
-
-The argument -x - to -F - has prototype - -
-     const 
Float &x
-
-The return value of -F - is a -Float - object - -
-
-a -
-The argument -a - has prototype - -
-     const 
FloatVector &a
-
-It specifies the lower limit for the integration -(see description of FloatVector - below). - -
-
-b -
-The argument -b - has prototype - -
-     const 
FloatVector &b
-
-It specifies the upper limit for the integration. - -
-
-n -
-The argument -n - has prototype - -
-     const 
SizeVector &n
-
-A total number of - -2 -n -[ -i -] --1 - - -+ -1 - - - -evaluations of -F(x) - are used to estimate the integral -with respect to - -d - -x -i - - - -. - -
-
-p -
-The argument -p - has prototype - -
-     const 
SizeVector &p
-
-For - -i -= -0 -, - -, -m --1 - - -, - - -n -[ -i -] - - - determines the accuracy order in the -approximation for the integral -that is returned by RombergMul. -The values in -p - must be less than or equal -n -; i.e., - -p[i] <= n[i] -. - -
-
-e -
-The argument -e - has prototype - -
-     
Float &e
-
-The input value of -e - does not matter -and its output value is an approximation for the absolute error in -the integral estimate. - -
-
-Float -
-The type -Float - is defined as the type of the elements of -FloatVector -. -The type -Float - must satisfy the conditions -for a NumericType - type. -The routine CheckNumericType - will generate an error message -if this is not the case. -In addition, if -x - and -y - are -Float - objects, - -
-     
x < y
-
-returns the bool value true if -x - is less than - -y - and false otherwise. - -
-
-FloatVector -
-The type -FloatVector - must be a SimpleVector - class. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - - - -
-
-Example - -
-The file -Rombergmul.cpp - -contains an example and test a test of using this routine. -It returns true if it succeeds and false otherwise. - -
-
-Source Code -
-The source code for this routine is in the file -cppad/romberg_mul.hpp. - - -
Input File: cppad/utility/romberg_mul.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_rombergmul_xml.js cppad-2019.02.00.0/doc/_rombergmul_xml.js --- cppad-2018.00.00.0/doc/_rombergmul_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rombergmul_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'rombergmul.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'rombergmul.cpp.xml' -]; -var list_current0 = [ -'rombergmul.xml#Syntax', -'rombergmul.xml#Description', -'rombergmul.xml#Include', -'rombergmul.xml#m', -'rombergmul.xml#r', -'rombergmul.xml#F', -'rombergmul.xml#a', -'rombergmul.xml#b', -'rombergmul.xml#n', -'rombergmul.xml#p', -'rombergmul.xml#e', -'rombergmul.xml#Float', -'rombergmul.xml#FloatVector', -'rombergmul.xml#Example', -'rombergmul.xml#Source Code' -]; -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-2018.00.00.0/doc/romberg_one.cpp.xml cppad-2019.02.00.0/doc/romberg_one.cpp.xml --- cppad-2018.00.00.0/doc/romberg_one.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/romberg_one.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,180 +0,0 @@ - - - -One Dimensional Romberg Integration: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -romberg_one.cppHeadings

- - - -
One Dimensional Romberg Integration: Example and Test
-

-# include <cppad/utility/romberg_one.hpp>
-# include <cppad/utility/vector.hpp>
-# include <cppad/utility/near_equal.hpp>
-
-namespace {
-     class Fun {
-     private:
-          const size_t degree;
-     public:
-          // constructor
-          Fun(size_t degree_) : degree(degree_)
-          { }
-
-          // function F(x) = x^degree
-          template <class Type>
-          Type operator () (const Type &x)
-          {     size_t i;
-               Type   f = 1;
-               for(i = 0; i < degree; i++)
-                    f *= x;
-               return f;
-          }
-     };
-}
-
-bool RombergOne(void)
-{     bool ok = true;
-     size_t i;
-
-     size_t degree = 4;
-     Fun F(degree);
-
-     // arguments to RombergOne
-     double a = 0.;
-     double b = 1.;
-     size_t n = 4;
-     size_t p;
-     double r, e;
-
-     // 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) / double(degree+1);
-
-     // step size corresponding to r
-     double step = (b - a) / exp(log(2.)*double(n-1));
-     // step size corresponding to error estimate
-     step *= 2.;
-     // step size raised to a power
-     double spow = 1;
-
-     for(p = 0; p < n; p++)
-     {     spow = spow * step * step;
-
-          r = CppAD::RombergOne(F, a, b, n, p, e);
-
-          ok  &= e < double(degree+1) * spow;
-          ok  &= CppAD::NearEqual(check, r, 0., e);
-     }
-
-     return ok;
-}
-
-
-
Input File: example/utility/romberg_one.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_romberg_one.cpp_xml.js cppad-2019.02.00.0/doc/_romberg_one.cpp_xml.js --- cppad-2018.00.00.0/doc/_romberg_one.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_romberg_one.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'rombergone.xml', -'romberg_one.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'romberg_one.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-2018.00.00.0/doc/rombergone.xml cppad-2019.02.00.0/doc/rombergone.xml --- cppad-2018.00.00.0/doc/rombergone.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/rombergone.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,433 +0,0 @@ - - - -One DimensionalRomberg Integration - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - -
One DimensionalRomberg Integration
-
-Syntax - -
- -# include <cppad/utility/romberg_one.hpp>
-
- -r = RombergOne(Fabne) - - - -
-
-Description -
-Returns the Romberg integration estimate - - -r - - - for a one dimensional integral - - -r -= - -a -b - -F -( -x -) -d - -x -+ -O -[( -b -- -a -) -/ -2 -n --1 - - -] -2 -( -p -+ -1 -) - - - - -
-Include -
-The file cppad/romberg_one.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-r -
-The return value -r - has prototype - -
-     
Float r
-
-It is the estimate computed by RombergOne for the integral above. - -
-
-F -
-The object -F - can be of any type, but it must support -the operation - -
-     
F(x)
-
-The argument -x - to -F - has prototype - -
-     const 
Float &x
-
-The return value of -F - is a -Float - object -(see description of Float - below). - -
-
-a -
-The argument -a - has prototype - -
-     const 
Float &a
-
-It specifies the lower limit for the integration. - -
-
-b -
-The argument -b - has prototype - -
-     const 
Float &b
-
-It specifies the upper limit for the integration. - -
-
-n -
-The argument -n - has prototype - -
-     size_t 
n
-
-A total number of - -2 -n --1 - - -+ -1 - - - evaluations of -F(x) - -are used to estimate the integral. - -
-
-p -
-The argument -p - has prototype - -
-     size_t 
p
-
-It must be less than or equal - -n - - - -and determines the accuracy order in the approximation for the integral -that is returned by RombergOne. -To be specific - - -r -= - -a -b - -F -( -x -) -d - -x -+ -O -[( -b -- -a -) -/ -2 -n --1 - - -] -2 -( -p -+ -1 -) - - - - -
-e -
-The argument -e - has prototype - -
-     
Float &e
-
-The input value of -e - does not matter -and its output value is an approximation for the error in -the integral estimates; i.e., - - -e - -|r -- - -a -b - -F -( -x -) -d - -x -| - - -
-Float -
-The type -Float - must satisfy the conditions -for a NumericType - type. -The routine CheckNumericType - will generate an error message -if this is not the case. -In addition, if -x - and -y - are -Float - objects, - -
-     
x < y
-
-returns the bool value true if -x - is less than - -y - and false otherwise. - - -
-
-Example - -
-The file -romberg_one.cpp - -contains an example and test a test of using this routine. -It returns true if it succeeds and false otherwise. - -
-
-Source Code -
-The source code for this routine is in the file -cppad/romberg_one.hpp. - - -
Input File: cppad/utility/romberg_one.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_rombergone_xml.js cppad-2019.02.00.0/doc/_rombergone_xml.js --- cppad-2018.00.00.0/doc/_rombergone_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rombergone_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'rombergone.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'romberg_one.cpp.xml' -]; -var list_current0 = [ -'rombergone.xml#Syntax', -'rombergone.xml#Description', -'rombergone.xml#Include', -'rombergone.xml#r', -'rombergone.xml#F', -'rombergone.xml#a', -'rombergone.xml#b', -'rombergone.xml#n', -'rombergone.xml#p', -'rombergone.xml#e', -'rombergone.xml#Float', -'rombergone.xml#Example', -'rombergone.xml#Source Code' -]; -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-2018.00.00.0/doc/rosen_34.cpp.xml cppad-2019.02.00.0/doc/rosen_34.cpp.xml --- cppad-2018.00.00.0/doc/rosen_34.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/rosen_34.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,397 +0,0 @@ - - - -Rosen34: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -rosen_34.cppHeadings

- - - -
Rosen34: Example and Test
-Define - - -X -: -R - - -R - -n - - - - by - - -X -i - -( -t -) -= -t -i -+ -1 - - - - -for - -i -= -1 -, - -, -n --1 - - -. -It follows that - - - -X -i - -( -0 -) - -= - -0 - -for - -all - - -i - -X -i - -' -( -t -) - -= - -1 - -if - - -i -= -0 - -X -i - -' -( -t -) - -= - -( -i -+ -1 -) -t -i - -= -( -i -+ -1 -) -X -i --1 - - -( -t -) - -if - - -i -> -0 - - - -The example tests Rosen34 using the relations above: - - -

-# include <cppad/cppad.hpp>        // For automatic differentiation
-
-namespace {
-     class Fun {
-     public:
-          // constructor
-          Fun(bool use_x_) : use_x(use_x_)
-          { }
-
-          // compute f(t, x) both for double and AD<double>
-          template <typename Scalar>
-          void Ode(
-               const Scalar                    &t,
-               const CPPAD_TESTVECTOR(Scalar) &x,
-               CPPAD_TESTVECTOR(Scalar)       &f)
-          {     size_t n  = x.size();
-               Scalar ti(1);
-               f[0]   = Scalar(1);
-               size_t i;
-               for(i = 1; i < n; i++)
-               {     ti *= t;
-                    // convert int(size_t) to avoid warning
-                    // on _MSC_VER systems
-                    if( use_x )
-                         f[i] = int(i+1) * x[i-1];
-                    else     f[i] = int(i+1) * ti;
-               }
-          }
-
-          // compute partial of f(t, x) w.r.t. t using AD
-          void Ode_ind(
-               const double                    &t,
-               const CPPAD_TESTVECTOR(double) &x,
-               CPPAD_TESTVECTOR(double)       &f_t)
-          {     using namespace CppAD;
-
-               size_t n  = x.size();
-               CPPAD_TESTVECTOR(AD<double>) T(1);
-               CPPAD_TESTVECTOR(AD<double>) X(n);
-               CPPAD_TESTVECTOR(AD<double>) F(n);
-
-               // set argument values
-               T[0] = t;
-               size_t i;
-               for(i = 0; i < n; i++)
-                    X[i] = x[i];
-
-               // declare independent variables
-               Independent(T);
-
-               // compute f(t, x)
-               this->Ode(T[0], X, F);
-
-               // define AD function object
-               ADFun<double> fun(T, F);
-
-               // compute partial of f w.r.t t
-               CPPAD_TESTVECTOR(double) dt(1);
-               dt[0] = 1.;
-               f_t = fun.Forward(1, dt);
-          }
-
-          // compute partial of f(t, x) w.r.t. x using AD
-          void Ode_dep(
-               const double                    &t,
-               const CPPAD_TESTVECTOR(double) &x,
-               CPPAD_TESTVECTOR(double)       &f_x)
-          {     using namespace CppAD;
-
-               size_t n  = x.size();
-               CPPAD_TESTVECTOR(AD<double>) T(1);
-               CPPAD_TESTVECTOR(AD<double>) X(n);
-               CPPAD_TESTVECTOR(AD<double>) F(n);
-
-               // set argument values
-               T[0] = t;
-               size_t i, j;
-               for(i = 0; i < n; i++)
-                    X[i] = x[i];
-
-               // declare independent variables
-               Independent(X);
-
-               // compute f(t, x)
-               this->Ode(T[0], X, F);
-
-               // define AD function object
-               ADFun<double> fun(X, F);
-
-               // compute partial of f w.r.t x
-               CPPAD_TESTVECTOR(double) dx(n);
-               CPPAD_TESTVECTOR(double) df(n);
-               for(j = 0; j < n; j++)
-                    dx[j] = 0.;
-               for(j = 0; j < n; j++)
-               {     dx[j] = 1.;
-                    df = fun.Forward(1, dx);
-                    for(i = 0; i < n; i++)
-                         f_x [i * n + j] = df[i];
-                    dx[j] = 0.;
-               }
-          }
-
-     private:
-          const bool use_x;
-
-     };
-}
-
-bool Rosen34(void)
-{     bool ok = true;     // initial return value
-     size_t i;           // temporary indices
-
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     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
-
-     // xi = X(0)
-     CPPAD_TESTVECTOR(double) xi(n);
-     for(i = 0; i <n; i++)
-          xi[i] = 0.;
-
-     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);
-
-          // compute Rosen34 approximation for X(tf)
-          CPPAD_TESTVECTOR(double) xf(n), e(n);
-          xf = CppAD::Rosen34(F, M, ti, tf, xi, e);
-
-          double check = tf;
-          for(i = 0; i < n; i++)
-          {     // check that error is always positive
-               ok    &= (e[i] >= 0.);
-               // 4th order method is exact for i < 4
-               if( i < 4 ) ok &=
-                    NearEqual(xf[i], check, eps99, eps99);
-               // 3rd order method is exact for i < 3
-               if( i < 3 )
-                    ok &= (e[i] <= eps99);
-
-               // check value for next i
-               check *= tf;
-          }
-     }
-     return ok;
-}
-
-
-
Input File: example/general/rosen_34.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_rosen_34.cpp_xml.js cppad-2019.02.00.0/doc/_rosen_34.cpp_xml.js --- cppad-2018.00.00.0/doc/_rosen_34.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rosen_34.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'rosen34.xml', -'rosen_34.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'rosen_34.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-2018.00.00.0/doc/rosen34.xml cppad-2019.02.00.0/doc/rosen34.xml --- cppad-2018.00.00.0/doc/rosen34.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/rosen34.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,822 +0,0 @@ - - - -A 3rd and 4th Order Rosenbrock ODE Solver - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
A 3rd and 4th Order Rosenbrock ODE Solver
-
-Syntax - -
- -# include <cppad/utility/rosen_34.hpp>
-
- -xf = Rosen34(FMtitfxi)
-
- -xf = Rosen34(FMtitfxie)
-
-
-Description -
-This is an embedded 3rd and 4th order Rosenbrock ODE solver -(see Section 16.6 of Numerical Recipes - -for a description of Rosenbrock ODE solvers). -In particular, we use the formulas taken from page 100 of -Shampine, L.F. - -(except that the fraction 98/108 has been correction to be 97/108). -
-
-
We use - -n - - - for the size of the vector -xi -. -Let - -R - - - - denote the real numbers -and let - -F -: -R - -× -R - -n - - -R - -n - - - - be a smooth function. -The return value -xf - contains a 5th order -approximation for the value - -X -( -tf -) - - - where - - -X -: -[ -ti -, -tf -] - -R - -n - - - - is defined by -the following initial value problem: - - - -X -( -ti -) - -= - -xi - -X -' -( -t -) - -= - -F -[ -t -, -X -( -t -) -] - - - -If your set of ordinary differential equations are not stiff -an explicit method may be better (perhaps Runge45 -.) - -
-
-Include -
-The file cppad/rosen_34.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-xf -
-The return value -xf - has the prototype - -
-     
Vector xf
-
-and the size of -xf - is equal to -n - -(see description of Vector - below). - - -X -( -tf -) -= -xf -+ -O -( -h -5 - -) - - -where - -h -= -( -tf -- -ti -) -/ -M - - - is the step size. -If -xf - contains not a number nan -, -see the discussion of f -. - -
-
-Fun -
-The class -Fun - -and the object -F - satisfy the prototype - -
-     
Fun &F
-
-This must support the following set of calls - -
-     
F.Ode(txf)
-     
F.Ode_ind(txf_t)
-     
F.Ode_dep(txf_x)
-
-
-t -
-In all three cases, -the argument -t - has prototype - -
-     const 
Scalar &t
-
-(see description of Scalar - below). - -
-
-x -
-In all three cases, -the argument -x - has prototype - -
-     const 
Vector &x
-
-and has size -n - -(see description of Vector - below). - -
-
-f -
-The argument -f - to -F.Ode - has prototype - -
-     
Vector &f
-
-On input and output, -f - is a vector of size -n - -and the input values of the elements of -f - do not matter. -On output, - -f - is set equal to - -F -( -t -, -x -) - - - -(see -F(t, x) - in Description -). - -
-
-f_t -
-The argument -f_t - to -F.Ode_ind - has prototype - -
-     
Vector &f_t
-
-On input and output, -f_t - is a vector of size -n - -and the input values of the elements of -f_t - do not matter. -On output, the i-th element of - -f_t - is set equal to - - -t - -F -i - -( -t -, -x -) - - - -(see -F(t, x) - in Description -). - -
-
-f_x -
-The argument -f_x - to -F.Ode_dep - has prototype - -
-     
Vector &f_x
-
-On input and output, -f_x - is a vector of size -n*n - -and the input values of the elements of -f_x - do not matter. -On output, the [ -i*n+j -] element of - -f_x - is set equal to - - -x -( -j -) - - -F -i - -( -t -, -x -) - - - -(see -F(t, x) - in Description -). - -
-
-Nan -
-If any of the elements of -f -, -f_t -, or -f_x - -have the value not a number nan, -the routine Rosen34 returns with all the -elements of -xf - and -e - equal to nan. - -
-
-Warning -
-The arguments -f -, -f_t -, and -f_x - -must have a call by reference in their prototypes; i.e., -do not forget the & in the prototype for - -f -, -f_t - and -f_x -. - -
-
-Optimization -
-Every call of the form - -
-     
F.Ode_ind(txf_t)
-
-is directly followed by a call of the form - -
-     
F.Ode_dep(txf_x)
-
-where the arguments -t - and -x - have not changed between calls. -In many cases it is faster to compute the values of -f_t - -and -f_x - together and then pass them back one at a time. - -
-
-M -
-The argument -M - has prototype - -
-     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 - -h -= -( -tf -- -ti -) -/ -M - - -, thus -the larger -M -, the more accurate the -return value -xf - is as an approximation -for - -X -( -tf -) - - -. - -
-
-ti -
-The argument -ti - has prototype - -
-     const 
Scalar &ti
-
-(see description of Scalar - below). -It specifies the initial time for -t - in the -differential equation; i.e., -the time corresponding to the value -xi -. - -
-
-tf -
-The argument -tf - has prototype - -
-     const 
Scalar &tf
-
-It specifies the final time for -t - in the -differential equation; i.e., -the time corresponding to the value -xf -. - -
-
-xi -
-The argument -xi - has the prototype - -
-     const 
Vector &xi
-
-and the size of -xi - is equal to -n -. -It specifies the value of - -X -( -ti -) - - - - -
-
-e -
-The argument -e - is optional and has the prototype - -
-     
Vector &e
-
-If -e - is present, -the size of -e - must be equal to -n -. -The input value of the elements of -e - does not matter. -On output -it contains an element by element -estimated bound for the absolute value of the error in -xf - - - -e -= -O -( -h -4 - -) - - -where - -h -= -( -tf -- -ti -) -/ -M - - - is the step size. - -
-
-Scalar -
-The type -Scalar - must satisfy the conditions -for a NumericType - type. -The routine CheckNumericType - will generate an error message -if this is not the case. -In addition, the following operations must be defined for - -Scalar - objects -a - and -b -: - - -
- -Operation - Description
- - -a < b - - - less than operator (returns a bool object) -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type Scalar -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Parallel Mode -
-For each set of types -Scalar -, -Vector -, and -Fun -, -the first call to Rosen34 -must not be parallel - execution mode. - -
-
-Example - -
-The file -rosen_34.cpp - -contains an example and test a test of using this routine. -It returns true if it succeeds and false otherwise. - -
-
-Source Code -
-The source code for this routine is in the file -cppad/rosen_34.hpp. - - -
Input File: cppad/utility/rosen_34.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_rosen34_xml.js cppad-2019.02.00.0/doc/_rosen34_xml.js --- cppad-2018.00.00.0/doc/_rosen34_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_rosen34_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'rosen34.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'rosen_34.cpp.xml' -]; -var list_current0 = [ -'rosen34.xml#Syntax', -'rosen34.xml#Description', -'rosen34.xml#Include', -'rosen34.xml#xf', -'rosen34.xml#Fun', -'rosen34.xml#Fun.t', -'rosen34.xml#Fun.x', -'rosen34.xml#Fun.f', -'rosen34.xml#Fun.f_t', -'rosen34.xml#Fun.f_x', -'rosen34.xml#Fun.Nan', -'rosen34.xml#Fun.Warning', -'rosen34.xml#Fun.Optimization', -'rosen34.xml#M', -'rosen34.xml#ti', -'rosen34.xml#tf', -'rosen34.xml#xi', -'rosen34.xml#e', -'rosen34.xml#Scalar', -'rosen34.xml#Vector', -'rosen34.xml#Parallel Mode', -'rosen34.xml#Example', -'rosen34.xml#Source Code' -]; -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-2018.00.00.0/doc/runge45_1.cpp.xml cppad-2019.02.00.0/doc/runge45_1.cpp.xml --- cppad-2018.00.00.0/doc/runge45_1.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/runge45_1.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,327 +0,0 @@ - - - -Runge45: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -runge45_1.cppHeadings

- - - -
Runge45: Example and Test
-Define - - -X -: -R - - -R - -n - - - - by - - -X -i - -( -t -) -= -t -i -+ -1 - - - - -for - -i -= -1 -, - -, -n --1 - - -. -It follows that - - - -X -i - -( -0 -) - -= - -0 - -for - -all - - -i - -X -i - -' -( -t -) - -= - -1 - -if - - -i -= -0 - -X -i - -' -( -t -) - -= - -( -i -+ -1 -) -t -i - -= -( -i -+ -1 -) -X -i --1 - - -( -t -) - -if - - -i -> -0 - - - -The example tests Runge45 using the relations above: - - -

-# include <cstddef>                 // for size_t
-# include <cppad/utility/near_equal.hpp>    // for CppAD::NearEqual
-# include <cppad/utility/vector.hpp>        // for CppAD::vector
-# include <cppad/utility/runge_45.hpp>      // for CppAD::Runge45
-
-// Runge45 requires fabs to be defined (not std::fabs)
-// <cppad/cppad.hpp> defines this for doubles, but runge_45.hpp does not.
-# include <math.h>      // for fabs without std in front
-
-namespace {
-     class Fun {
-     public:
-          // constructor
-          Fun(bool use_x_) : use_x(use_x_)
-          { }
-
-          // set f = x'(t)
-          void Ode(
-               const double                &t,
-               const CppAD::vector<double> &x,
-               CppAD::vector<double>       &f)
-          {     size_t n  = x.size();
-               double ti = 1.;
-               f[0]      = 1.;
-               size_t i;
-               for(i = 1; i < n; i++)
-               {     ti *= t;
-                    if( use_x )
-                         f[i] = double(i+1) * x[i-1];
-                    else     f[i] = double(i+1) * ti;
-               }
-          }
-     private:
-          const bool use_x;
-
-     };
-}
-
-bool runge_45_1(void)
-{     bool ok = true;     // initial return value
-     size_t i;           // temporary indices
-
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     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
-
-     // xi = X(0)
-     CppAD::vector<double> xi(n);
-     for(i = 0; i <n; i++)
-          xi[i] = 0.;
-
-     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);
-
-          // compute Runge45 approximation for X(tf)
-          CppAD::vector<double> xf(n), e(n);
-          xf = CppAD::Runge45(F, M, ti, tf, xi, e);
-
-          double check = tf;
-          for(i = 0; i < n; i++)
-          {     // check that error is always positive
-               ok    &= (e[i] >= 0.);
-               // 5th order method is exact for i < 5
-               if( i < 5 ) ok &=
-                    NearEqual(xf[i], check, eps99, eps99);
-               // 4th order method is exact for i < 4
-               if( i < 4 )
-                    ok &= (e[i] <= eps99);
-
-               // check value for next i
-               check *= tf;
-          }
-     }
-     return ok;
-}
-
-
-
Input File: example/utility/runge45_1.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_runge45_1.cpp_xml.js cppad-2019.02.00.0/doc/_runge45_1.cpp_xml.js --- cppad-2018.00.00.0/doc/_runge45_1.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_runge45_1.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'runge45.xml', -'runge45_1.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'runge45_1.cpp.xml', -'runge45_2.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-2018.00.00.0/doc/runge45_2.cpp.xml cppad-2019.02.00.0/doc/runge45_2.cpp.xml --- cppad-2018.00.00.0/doc/runge45_2.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/runge45_2.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,442 +0,0 @@ - - - -Runge45: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -runge45_2.cppHeadings

-
Runge45: Example and Test
-Define - - -X -: -R - -× -R - - -R - -n - - - - by - - -X -j - -( -b -, -t -) -= -b -( -k -= -0 - -j - -t -k - -/ -k -! -) - - -for - -j -= -0 -, - -, -n --1 - - -. -It follows that - - - -X -j - -( -b -, -0 -) - -= - -b - - -t - -X -j - -( -b -, -t -) - -= - -b -( -k -= -0 - -j --1 - - -t -k - -/ -k -! -) - - -t - -X -j - -( -b -, -t -) - -= - -{ -0 - -if - - -j -= -0 - -X -j --1 - - -( -b -, -t -) - -otherwise - - - - - - -For a fixed - -t -f - - - -, -we can use Runge45 - to define - - -f -: -R - - -R - -n - - - - as an approximation for - - -f -( -b -) -= -X -( -b -, -t -f - -) - - -. -We can then compute - -f -( -1 -) - - -( -b -) - - - which is an approximation for - - - -b - -X -( -b -, -t -f - -) -= - -k -= -0 - -j - -t -f -k - -/ -k -! - - -

-# include <cstddef>              // for size_t
-# include <limits>               // for machine epsilon
-# include <cppad/cppad.hpp>      // for all of CppAD
-
-namespace {
-
-     template <class Scalar>
-     class Fun {
-     public:
-          // constructor
-          Fun(void)
-          { }
-
-          // set return value to X'(t)
-          void Ode(
-               const Scalar                    &t,
-               const CPPAD_TESTVECTOR(Scalar) &x,
-               CPPAD_TESTVECTOR(Scalar)       &f)
-          {     size_t n  = x.size();
-               f[0]      = 0.;
-               for(size_t k = 1; k < n; k++)
-                    f[k] = x[k-1];
-          }
-     };
-}
-
-bool runge_45_2(void)
-{     typedef CppAD::AD<double> Scalar;
-     using CppAD::NearEqual;
-
-     bool ok = true;     // initial return value
-     size_t j;           // temporary indices
-
-     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
-
-     // value of independent variable at which to record operations
-     CPPAD_TESTVECTOR(Scalar) ad_b(1);
-     ad_b[0] = 1.;
-
-     // declare b to be the independent variable
-     Independent(ad_b);
-
-     // object to evaluate ODE
-     Fun<Scalar> ad_F;
-
-     // xi = X(0)
-     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);
-     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
-     CppAD::ADFun<double> f(ad_b, ad_xf);
-
-     // evaluate f(b)
-     CPPAD_TESTVECTOR(double)  b(1);
-     CPPAD_TESTVECTOR(double) xf(n);
-     b[0] = 1.;
-     xf   = f.Forward(0, b);
-
-     // check that f(b) = X(b, tf)
-     double tf    = Value(ad_tf);
-     double term  = 1;
-     double sum   = 0;
-     double eps   = 10. * CppAD::numeric_limits<double>::epsilon();
-     for(j = 0; j < n; j++)
-     {     sum += term;
-          ok &= NearEqual(xf[j], b[0] * sum, eps, eps);
-          term *= tf;
-          term /= double(j+1);
-     }
-
-     // evalute f'(b)
-     CPPAD_TESTVECTOR(double) d_xf(n);
-     d_xf = f.Jacobian(b);
-
-     // check that f'(b) = partial of X(b, tf) w.r.t b
-     term  = 1;
-     sum   = 0;
-     for(j = 0; j < n; j++)
-     {     sum += term;
-          ok &= NearEqual(d_xf[j], sum, eps, eps);
-          term *= tf;
-          term /= double(j+1);
-     }
-
-     return ok;
-}
-
-
-
Input File: example/general/runge45_2.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_runge45_2.cpp_xml.js cppad-2019.02.00.0/doc/_runge45_2.cpp_xml.js --- cppad-2018.00.00.0/doc/_runge45_2.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_runge45_2.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'runge45.xml', -'runge45_2.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'runge45_1.cpp.xml', -'runge45_2.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-2018.00.00.0/doc/runge45.xml cppad-2019.02.00.0/doc/runge45.xml --- cppad-2018.00.00.0/doc/runge45.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/runge45.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,723 +0,0 @@ - - - -An Embedded 4th and 5th Order Runge-Kutta ODE Solver - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
An Embedded 4th and 5th Order Runge-Kutta ODE Solver
-
-Syntax - -
- -# include <cppad/utility/runge_45.hpp>
-
- -xf = Runge45(FMtitfxi)
-
- -xf = Runge45(FMtitfxie)
-
-
-Purpose -
-This is an implementation of the -Cash-Karp embedded 4th and 5th order Runge-Kutta ODE solver -described in Section 16.2 of Numerical Recipes -. -We use - -n - - - for the size of the vector -xi -. -Let - -R - - - - denote the real numbers -and let - -F -: -R - -× -R - -n - - -R - -n - - - - -be a smooth function. -The return value -xf - contains a 5th order -approximation for the value - -X -( -tf -) - - - where - - -X -: -[ -ti -, -tf -] - -R - -n - - - - is defined by -the following initial value problem: - - - -X -( -ti -) - -= - -xi - -X -' -( -t -) - -= - -F -[ -t -, -X -( -t -) -] - - - -If your set of ordinary differential equations -are stiff, an implicit method may be better -(perhaps Rosen34 -.) - -
-
-Operation Sequence -
-The operation sequence - for -Runge - -does not depend on any of its -Scalar - input values provided that -the operation sequence for - -
-     
F.Ode(txf)
-
-does not on any of its -Scalar - inputs (see below). - -
-
-Include -
-The file cppad/runge_45.hpp is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-xf -
-The return value -xf - has the prototype - -
-     
Vector xf
-
-and the size of -xf - is equal to -n - -(see description of Vector - below). - - -X -( -tf -) -= -xf -+ -O -( -h -6 - -) - - -where - -h -= -( -tf -- -ti -) -/ -M - - - is the step size. -If -xf - contains not a number nan -, -see the discussion for f -. - -
-
-Fun -
-The class -Fun - -and the object -F - satisfy the prototype - -
-     
Fun &F
-
-The object -F - (and the class -Fun -) -must have a member function named Ode -that supports the syntax - -
-     
F.Ode(txf)
-
-
-t -
-The argument -t - to -F.Ode - has prototype - -
-     const 
Scalar &t
-
-(see description of Scalar - below). - -
-
-x -
-The argument -x - to -F.Ode - has prototype - -
-     const 
Vector &x
-
-and has size -n - -(see description of Vector - below). - -
-
-f -
-The argument -f - to -F.Ode - has prototype - -
-     
Vector &f
-
-On input and output, -f - is a vector of size -n - -and the input values of the elements of -f - do not matter. -On output, - -f - is set equal to - -F -( -t -, -x -) - - - in the differential equation. -If any of the elements of -f - have the value not a number nan -the routine Runge45 returns with all the -elements of -xf - and -e - equal to nan. - -
-
-Warning -
-The argument -f - to -F.Ode - -must have a call by reference in its prototype; i.e., -do not forget the & in the prototype for -f -. - -
-
-M -
-The argument -M - has prototype - -
-     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 - -h -= -( -tf -- -ti -) -/ -M - - -, thus -the larger -M -, the more accurate the -return value -xf - is as an approximation -for - -X -( -tf -) - - -. - -
-
-ti -
-The argument -ti - has prototype - -
-     const 
Scalar &ti
-
-(see description of Scalar - below). -It specifies the initial time for -t - in the -differential equation; i.e., -the time corresponding to the value -xi -. - -
-
-tf -
-The argument -tf - has prototype - -
-     const 
Scalar &tf
-
-It specifies the final time for -t - in the -differential equation; i.e., -the time corresponding to the value -xf -. - -
-
-xi -
-The argument -xi - has the prototype - -
-     const 
Vector &xi
-
-and the size of -xi - is equal to -n -. -It specifies the value of - -X -( -ti -) - - - - -
-
-e -
-The argument -e - is optional and has the prototype - -
-     
Vector &e
-
-If -e - is present, -the size of -e - must be equal to -n -. -The input value of the elements of -e - does not matter. -On output -it contains an element by element -estimated bound for the absolute value of the error in -xf - - - -e -= -O -( -h -5 - -) - - -where - -h -= -( -tf -- -ti -) -/ -M - - - is the step size. -If on output, -e - contains not a number nan, -see the discussion for f -. - -
-
-Scalar -
-The type -Scalar - must satisfy the conditions -for a NumericType - type. -The routine CheckNumericType - will generate an error message -if this is not the case. - -
-
-fabs -
-In addition, the following function must be defined for - -Scalar - objects -a - and -b - - -
-     
a = fabs(b)
-
-Note that this operation is only used for computing -e -; hence -the operation sequence for -xf - can still be independent of -the arguments to Runge45 even if - -
-     fabs(
b) = std::max(-bb)
-
-. - -
-
-Vector -
-The type -Vector - must be a SimpleVector - class with -elements of type Scalar -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Parallel Mode -
-For each set of types -Scalar -, -Vector -, and -Fun -, -the first call to Runge45 -must not be parallel - execution mode. - - -
-
-Example - -
-The file -runge45_1.cpp - -contains a simple example and test of Runge45. -It returns true if it succeeds and false otherwise. -
-
-
The file -runge45_2.cpp - contains an example using Runge45 -in the context of algorithmic differentiation. -It also returns true if it succeeds and false otherwise. - -
-
-Source Code -
-The source code for this routine is in the file -cppad/runge_45.hpp. - - -
Input File: cppad/utility/runge_45.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_runge45_xml.js cppad-2019.02.00.0/doc/_runge45_xml.js --- cppad-2018.00.00.0/doc/_runge45_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_runge45_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'runge45.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'runge45_1.cpp.xml', -'runge45_2.cpp.xml' -]; -var list_current0 = [ -'runge45.xml#Syntax', -'runge45.xml#Purpose', -'runge45.xml#Operation Sequence', -'runge45.xml#Include', -'runge45.xml#xf', -'runge45.xml#Fun', -'runge45.xml#Fun.t', -'runge45.xml#Fun.x', -'runge45.xml#Fun.f', -'runge45.xml#Fun.Warning', -'runge45.xml#M', -'runge45.xml#ti', -'runge45.xml#tf', -'runge45.xml#xi', -'runge45.xml#e', -'runge45.xml#Scalar', -'runge45.xml#Scalar.fabs', -'runge45.xml#Vector', -'runge45.xml#Parallel Mode', -'runge45.xml#Example', -'runge45.xml#Source Code' -]; -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-2018.00.00.0/doc/sacado_det_lu.cpp.xml cppad-2019.02.00.0/doc/sacado_det_lu.cpp.xml --- cppad-2018.00.00.0/doc/sacado_det_lu.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sacado_det_lu.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ - - - -Sacado Speed: Gradient of Determinant Using Lu Factorization - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sacado_det_lu.cpp - -

-
Sacado Speed: Gradient of Determinant Using Lu Factorization
-
-Specifications -
-See link_det_lu -. - -
-
-Implementation - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-
-# include <Sacado.hpp>
-# include <cppad/speed/det_by_lu.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/utility/vector.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_det_lu(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &matrix   ,
-     CppAD::vector<double>     &gradient )
-{
-     // speed test global option values
-     if( global_option["onetape"] || global_option["atomic"] )
-          return false;
-     if( global_option["memory"] || global_option["optimize"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-     //
-     // object for computing determinant
-     typedef Sacado::Rad::ADvar<double>   ADScalar;
-     typedef CppAD::vector<ADScalar>      ADVector;
-     CppAD::det_by_lu<ADScalar>           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
-
-     // ------------------------------------------------------
-     while(repeat--)
-     {     // get the next matrix
-          CppAD::uniform_01(n, matrix);
-
-          // set independent variable values
-          for(i = 0; i < n; i++)
-               A[i] = matrix[i];
-
-          // compute the determinant
-          detA = Det(A);
-
-          // compute the gradient of detA
-          ADScalar::Gradcomp();
-
-          // evaluate and return gradient using reverse mode
-          for(i =0; i < n; i++)
-               gradient[i] = A[i].adj(); // partial detA w.r.t A[i]
-     }
-     // ---------------------------------------------------------
-     return true;
-}
- -
Input File: speed/sacado/det_lu.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sacado_det_lu.cpp_xml.js cppad-2019.02.00.0/doc/_sacado_det_lu.cpp_xml.js --- cppad-2018.00.00.0/doc/_sacado_det_lu.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sacado_det_lu.cpp_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', -'speed.xml', -'speed_sacado.xml', -'sacado_det_lu.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'sacado_det_minor.cpp.xml', -'sacado_det_lu.cpp.xml', -'sacado_mat_mul.cpp.xml', -'sacado_ode.cpp.xml', -'sacado_poly.cpp.xml', -'sacado_sparse_hessian.cpp.xml', -'sacado_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'sacado_det_lu.cpp.xml#Specifications', -'sacado_det_lu.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/sacado_det_minor.cpp.xml cppad-2019.02.00.0/doc/sacado_det_minor.cpp.xml --- cppad-2018.00.00.0/doc/sacado_det_minor.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sacado_det_minor.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ - - - -Sacado Speed: Gradient of Determinant by Minor Expansion - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sacado_det_minor.cpp - -

-
Sacado Speed: Gradient of Determinant by Minor Expansion
-
-Specifications -
-See link_det_minor -. - -
-
-Implementation - - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <Sacado.hpp>
-# include <cppad/speed/det_by_minor.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/utility/vector.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_det_minor(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &matrix   ,
-     CppAD::vector<double>     &gradient )
-{
-     // speed test global option values
-     if( global_option["atomic"] )
-          return false;
-     if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-
-     // object for computing determinant
-     typedef Sacado::Rad::ADvar<double>    ADScalar;
-     typedef CppAD::vector<ADScalar>       ADVector;
-     CppAD::det_by_minor<ADScalar>         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
-
-     // ------------------------------------------------------
-     while(repeat--)
-     {     // get the next matrix
-          CppAD::uniform_01(n, matrix);
-
-          // set independent variable values
-          for(i = 0; i < n; i++)
-               A[i] = matrix[i];
-
-          // compute the determinant
-          detA = Det(A);
-
-          // reverse mode compute gradient of last computed value; i.e., detA
-          ADScalar::Gradcomp();
-
-          // return gradient
-          for(i =0; i < n; i++)
-               gradient[i] = A[i].adj(); // partial detA w.r.t A[i]
-     }
-     // ---------------------------------------------------------
-     return true;
-}
- -
Input File: speed/sacado/det_minor.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sacado_det_minor.cpp_xml.js cppad-2019.02.00.0/doc/_sacado_det_minor.cpp_xml.js --- cppad-2018.00.00.0/doc/_sacado_det_minor.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sacado_det_minor.cpp_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', -'speed.xml', -'speed_sacado.xml', -'sacado_det_minor.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'sacado_det_minor.cpp.xml', -'sacado_det_lu.cpp.xml', -'sacado_mat_mul.cpp.xml', -'sacado_ode.cpp.xml', -'sacado_poly.cpp.xml', -'sacado_sparse_hessian.cpp.xml', -'sacado_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'sacado_det_minor.cpp.xml#Specifications', -'sacado_det_minor.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/sacado_mat_mul.cpp.xml cppad-2019.02.00.0/doc/sacado_mat_mul.cpp.xml --- cppad-2018.00.00.0/doc/sacado_mat_mul.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sacado_mat_mul.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ - - - -Sacado Speed: Matrix Multiplication - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sacado_mat_mul.cpp - -

-
Sacado Speed: Matrix Multiplication
-
-Specifications -
-See link_mat_mul -. - -
-
-Implementation - - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <Sacado.hpp>
-# include <cppad/utility/vector.hpp>
-# include <cppad/speed/mat_sum_sq.hpp>
-# include <cppad/speed/uniform_01.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_mat_mul(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     CppAD::vector<double>&           x        ,
-     CppAD::vector<double>&           z        ,
-     CppAD::vector<double>&           dz       )
-{
-     // speed test global option values
-     if( global_option["memory"] || global_option["onetape"] || global_option["atomic"] || global_option["optimize"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-
-     // object for computing determinant
-     typedef Sacado::Rad::ADvar<double>    ADScalar;
-     typedef CppAD::vector<ADScalar>       ADVector;
-
-     size_t j;                // temporary index
-     size_t m = 1;            // number of dependent variables
-     size_t n = size * size;  // number of independent variables
-     ADVector   X(n);         // AD domain space vector
-     ADVector   Y(n);         // Store product matrix
-     ADVector   Z(m);         // AD range space vector
-     ADScalar   f;
-
-     // ------------------------------------------------------
-     while(repeat--)
-     {     // get the next matrix
-          CppAD::uniform_01(n, x);
-
-          // set independent variable values
-          for(j = 0; j < n; j++)
-               X[j] = x[j];
-
-          // do the computation
-          mat_sum_sq(size, X, Y, Z);
-
-          // create function object f : X -> Z
-          f = Z[0];
-
-          // reverse mode gradient of last ADvar computed value; i.e., f
-          ADScalar::Gradcomp();
-
-          // return gradient
-          for(j = 0; j < n; j++)
-               dz[j] = X[j].adj(); // partial f w.r.t X[j]
-     }
-     // return function value
-     z[0] = f.val();
-
-     // ---------------------------------------------------------
-     return true;
-}
- -
Input File: speed/sacado/mat_mul.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sacado_mat_mul.cpp_xml.js cppad-2019.02.00.0/doc/_sacado_mat_mul.cpp_xml.js --- cppad-2018.00.00.0/doc/_sacado_mat_mul.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sacado_mat_mul.cpp_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', -'speed.xml', -'speed_sacado.xml', -'sacado_mat_mul.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'sacado_det_minor.cpp.xml', -'sacado_det_lu.cpp.xml', -'sacado_mat_mul.cpp.xml', -'sacado_ode.cpp.xml', -'sacado_poly.cpp.xml', -'sacado_sparse_hessian.cpp.xml', -'sacado_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'sacado_mat_mul.cpp.xml#Specifications', -'sacado_mat_mul.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/sacado_ode.cpp.xml cppad-2019.02.00.0/doc/sacado_ode.cpp.xml --- cppad-2018.00.00.0/doc/sacado_ode.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sacado_ode.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ - - - -Sacado Speed: Gradient of Ode Solution - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sacado_ode.cpp - -

-
Sacado Speed: Gradient of Ode Solution
-
-Specifications -
-See link_ode -. - -
-
-Implementation - - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <Sacado.hpp>
-# include <cassert>
-# include <cppad/utility/vector.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/speed/ode_evaluate.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_ode(
-     size_t                     size       ,
-     size_t                     repeat     ,
-     CppAD::vector<double>      &x         ,
-     CppAD::vector<double>      &jacobian
-)
-{
-     // speed test global option values
-     if( global_option["atomic"] )
-          return false;
-     if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] )
-          return false;
-     // -------------------------------------------------------------
-     // setup
-     assert( x.size() == size );
-     assert( jacobian.size() == size * size );
-
-     typedef Sacado::Fad::DFad<double>  ADScalar;
-     typedef CppAD::vector<ADScalar>    ADVector;
-
-     size_t i, j;
-     size_t p = 0;          // use ode to calculate function values
-     size_t n = size;       // number of independent variables
-     size_t m = n;          // number of dependent variables
-     ADVector X(n), Y(m);   // independent and dependent variables
-
-     // -------------------------------------------------------------
-     while(repeat--)
-     {     // choose next x value
-          CppAD::uniform_01(n, x);
-          for(j = 0; j < n; j++)
-          {     // set up for X as the independent variable vector
-               X[j] = ADScalar(int(n), int(j), x[j]);
-          }
-
-          // evaluate function
-          CppAD::ode_evaluate(X, p, Y);
-
-          // return values with Y as the dependent variable vector
-          for(i = 0; i < m; i++)
-          {     for(j = 0; j < n; j++)
-                    jacobian[ i * n + j ] = Y[i].dx(j);
-          }
-     }
-     return true;
-}
- -
Input File: speed/sacado/ode.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sacado_ode.cpp_xml.js cppad-2019.02.00.0/doc/_sacado_ode.cpp_xml.js --- cppad-2018.00.00.0/doc/_sacado_ode.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sacado_ode.cpp_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', -'speed.xml', -'speed_sacado.xml', -'sacado_ode.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'sacado_det_minor.cpp.xml', -'sacado_det_lu.cpp.xml', -'sacado_mat_mul.cpp.xml', -'sacado_ode.cpp.xml', -'sacado_poly.cpp.xml', -'sacado_sparse_hessian.cpp.xml', -'sacado_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'sacado_ode.cpp.xml#Specifications', -'sacado_ode.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/sacado_poly.cpp.xml cppad-2019.02.00.0/doc/sacado_poly.cpp.xml --- cppad-2018.00.00.0/doc/sacado_poly.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sacado_poly.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,173 +0,0 @@ - - - -Sacado Speed: Second Derivative of a Polynomial - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sacado_poly.cpp - -

-
Sacado Speed: Second Derivative of a Polynomial
-
-Specifications -
-See link_poly -. - -
-
-Implementation - - - -
// suppress conversion warnings before other includes
-# include <cppad/wno_conversion.hpp>
-//
-# include <Sacado.hpp>
-# include <cppad/utility/vector.hpp>
-# include <cppad/utility/poly.hpp>
-# include <cppad/speed/uniform_01.hpp>
-
-// list of possible options
-# include <map>
-extern std::map<std::string, bool> global_option;
-
-bool link_poly(
-     size_t                     size     ,
-     size_t                     repeat   ,
-     CppAD::vector<double>     &a        ,  // coefficients of polynomial
-     CppAD::vector<double>     &z        ,  // polynomial argument value
-     CppAD::vector<double>     &ddp      )  // second derivative w.r.t z
-{
-     if( global_option["atomic"] )
-          return false;
-     if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] )
-          return false;
-     // -----------------------------------------------------
-     // setup
-     typedef Sacado::Tay::Taylor<double>  ADScalar;
-     CppAD::vector<ADScalar>              A(size);
-
-     size_t i;               // temporary index
-     ADScalar   Z;           // domain 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);
-
-     // choose the polynomial coefficients
-     CppAD::uniform_01(size, a);
-
-     // AD copy of the polynomial coefficients
-     for(i = 0; i < size; i++)
-          A[i] = a[i];
-
-     // ------------------------------------------------------
-     while(repeat--)
-     {     // get the next argument value
-          CppAD::uniform_01(1, z);
-
-          // independent variable value
-          Z.fastAccessCoeff(0)   = z[0]; // argument value
-          Z.fastAccessCoeff(1)   = 1.;   // first order coefficient
-          Z.fastAccessCoeff(2)   = 0.;   // second order coefficient
-
-          // AD computation of the dependent variable
-          P = CppAD::Poly(0, A, Z);
-
-          // second derivative is twice second order Taylor coefficient
-          ddp[0] = 2. * P.fastAccessCoeff(2);
-     }
-     // ------------------------------------------------------
-     return true;
-}
- -
Input File: speed/sacado/poly.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sacado_poly.cpp_xml.js cppad-2019.02.00.0/doc/_sacado_poly.cpp_xml.js --- cppad-2018.00.00.0/doc/_sacado_poly.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sacado_poly.cpp_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', -'speed.xml', -'speed_sacado.xml', -'sacado_poly.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'sacado_det_minor.cpp.xml', -'sacado_det_lu.cpp.xml', -'sacado_mat_mul.cpp.xml', -'sacado_ode.cpp.xml', -'sacado_poly.cpp.xml', -'sacado_sparse_hessian.cpp.xml', -'sacado_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'sacado_poly.cpp.xml#Specifications', -'sacado_poly.cpp.xml#Implementation' -]; -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-2018.00.00.0/doc/sacado_prefix.xml cppad-2019.02.00.0/doc/sacado_prefix.xml --- cppad-2018.00.00.0/doc/sacado_prefix.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/sacado_prefix.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,181 +0,0 @@ - - - -Including the Sacado Speed Tests - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - - -
Including the Sacado Speed Tests
-
-Purpose -
-CppAD includes speed comparisons for the AD package -Sacado -; see -speed_sacado -. - - -
-
-sacado_prefix -
-If Sacado is installed on your system, you can -specify a value for its install -sacado_prefix - on the -cmake - command line. -The value of -sacado_prefix - must be such that, -for one of the directories -dir - in -cmake_install_includedirs -, - -
-     
sacado_prefix/dir/Sacado.hpp
-
-is a valid way to reference to the include file Sacado.hpp; - -
-
-Speed Tests -
-If you include -sacado_prefix - on the cmake - command line, -you will be able to run the Sacado speed correctness tests -by executing the following commands starting in the -distribution directory -: - -
-     cd build/speed/sacado
-     make check_speed_sacado
-
-After executing make check_speed_sacado, -you can run a specific Sacado speed test -by executing the command ./speed_sacado; -see speed_main - for the meaning of the command line -options to this program. - - -
-
-get_sacado -
-If you are using Unix, you can download and install -a copy of Sacado using get_sacado.sh -. -The corresponding -sacado_prefix - would be -build/prefix. - - - - -
Input File: omh/install/sacado_prefix.omh - - - diff -Nru cppad-2018.00.00.0/doc/_sacado_prefix_xml.js cppad-2019.02.00.0/doc/_sacado_prefix_xml.js --- cppad-2018.00.00.0/doc/_sacado_prefix_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sacado_prefix_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'sacado_prefix.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 = [ -'download.xml', -'cmake.xml', -'cmake_check.xml', -'pkgconfig.xml' -]; -var list_down1 = [ -'adolc_prefix.xml', -'colpack_prefix.xml', -'eigen_prefix.xml', -'fadbad_prefix.xml', -'ipopt_prefix.xml', -'sacado_prefix.xml', -'cppad_testvector.xml' -]; -var list_down0 = [ -'get_sacado.sh.xml' -]; -var list_current0 = [ -'sacado_prefix.xml#Purpose', -'sacado_prefix.xml#sacado_prefix', -'sacado_prefix.xml#Speed Tests', -'sacado_prefix.xml#get_sacado' -]; -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-2018.00.00.0/doc/sacado_sparse_hessian.cpp.xml cppad-2019.02.00.0/doc/sacado_sparse_hessian.cpp.xml --- cppad-2018.00.00.0/doc/sacado_sparse_hessian.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sacado_sparse_hessian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ - - - -Sacado Speed: Sparse Hessian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sacado_sparse_hessian.cppHeadings

-
Sacado Speed: Sparse Hessian
-
// A sacado version of this test is not yet implemented
-extern bool link_sparse_hessian(
-        size_t                           size       ,
-        size_t                           repeat     ,
-        const CppAD::vector<size_t>&      row       ,
-        const CppAD::vector<size_t>&      col       ,
-        CppAD::vector<double>&            x         ,
-        CppAD::vector<double>&            hessian   ,
-        size_t&                           n_sweep
-)
-{
-     return false;
-}
- -
Input File: speed/sacado/sparse_hessian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sacado_sparse_hessian.cpp_xml.js cppad-2019.02.00.0/doc/_sacado_sparse_hessian.cpp_xml.js --- cppad-2018.00.00.0/doc/_sacado_sparse_hessian.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sacado_sparse_hessian.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', -'speed.xml', -'speed_sacado.xml', -'sacado_sparse_hessian.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'sacado_det_minor.cpp.xml', -'sacado_det_lu.cpp.xml', -'sacado_mat_mul.cpp.xml', -'sacado_ode.cpp.xml', -'sacado_poly.cpp.xml', -'sacado_sparse_hessian.cpp.xml', -'sacado_sparse_jacobian.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-2018.00.00.0/doc/sacado_sparse_jacobian.cpp.xml cppad-2019.02.00.0/doc/sacado_sparse_jacobian.cpp.xml --- cppad-2018.00.00.0/doc/sacado_sparse_jacobian.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sacado_sparse_jacobian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ - - - -sacado Speed: sparse_jacobian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sacado_sparse_jacobian.cppHeadings

-
sacado Speed: sparse_jacobian
-
// A sacado version of this test is not yet available
-bool link_sparse_jacobian(
-     size_t                           size     ,
-     size_t                           repeat   ,
-     size_t                           m        ,
-     const CppAD::vector<size_t>&     row      ,
-     const CppAD::vector<size_t>&     col      ,
-           CppAD::vector<double>&     x        ,
-           CppAD::vector<double>&     jacobian ,
-           size_t&                    n_sweep  )
-{
-     return false;
-}
- -
Input File: speed/sacado/sparse_jacobian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sacado_sparse_jacobian.cpp_xml.js cppad-2019.02.00.0/doc/_sacado_sparse_jacobian.cpp_xml.js --- cppad-2018.00.00.0/doc/_sacado_sparse_jacobian.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sacado_sparse_jacobian.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', -'speed.xml', -'speed_sacado.xml', -'sacado_sparse_jacobian.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'sacado_det_minor.cpp.xml', -'sacado_det_lu.cpp.xml', -'sacado_mat_mul.cpp.xml', -'sacado_ode.cpp.xml', -'sacado_poly.cpp.xml', -'sacado_sparse_hessian.cpp.xml', -'sacado_sparse_jacobian.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-2018.00.00.0/doc/_search_xml.htm cppad-2019.02.00.0/doc/_search_xml.htm --- cppad-2018.00.00.0/doc/_search_xml.htm 2018-01-01 08:32:51.000000000 +0000 +++ cppad-2019.02.00.0/doc/_search_xml.htm 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ - - -Search This Web Site - - - - - - - - - - - - - -
- -Prev -Next - - - - - - -_searchHeadings

- - -

Search This Web Site

-
-

- - -
- 1: Enter keywords separated by spaces - - 3: - section -
- - -

-

- - -
2: Select from following list of keyword matches

-
- - - - diff -Nru cppad-2018.00.00.0/doc/__search_xml.js cppad-2019.02.00.0/doc/__search_xml.js --- cppad-2018.00.00.0/doc/__search_xml.js 2018-01-01 08:32:51.000000000 +0000 +++ cppad-2019.02.00.0/doc/__search_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'_search_xml.htm' -]; -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' -]; -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-2018.00.00.0/doc/_search.xml.js cppad-2019.02.00.0/doc/_search.xml.js --- cppad-2018.00.00.0/doc/_search.xml.js 2018-01-01 08:32:40.000000000 +0000 +++ cppad-2019.02.00.0/doc/_search.xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,782 +0,0 @@ -// ------------------------------------------------------------ -// Copyright (C) Bradley M. Bell 1998-2015, All rights reserved -// ------------------------------------------------------------ -Keyword = -[ -'CppAD cppad-20180000.0: A Package for Differentiation of C++ Algorithms ',' algorithmic automatic derivative version cppad.hpp syntax introduction example include file preprocessor symbols namespace ', -'Install CppAD Download, Test, and Install Instructions ',' step 1: 2: cmake 3: check 4: installation deprecated ', -'download Download The CppAD Source Code ',' purpose distribution directory version release license compressed archives coin github control subversion monthly versions windows file extraction testing install instructions building documentation ', -'cmake Using CMake to Configure CppAD ',' makefile install prefix postfix include directories lib datadir documentation package compile flags profile maximum number threads sparsity internal structure vector sets memory usage tape implicit explicit the program command build directory check cmake_verbose_makefile generator cppad_prefix cppad_postfix cmake_install_includedirs cmake_install_libdirs cmake_install_datadir cmake_install_docdir package_prefix cppad_cxx_flags c++11 debug release cppad_profile_flag eigen fadbad cppad_testvector cppad_max_num_threads cppad_tape_id_type cstdint cppad_tape_addr_type cppad_debug_which exception cppad_deprecated ', -'adolc_prefix Including the ADOL-C Examples and Tests ',' get purpose speed unix cygwin get_adolc ', -'get_adolc.sh Download and Install Adolc in Build Directory ',' syntax purpose requirements distribution external prefix reuse ', -'colpack_prefix Including the ColPack Sparsity Calculations ',' get purpose cppad_lib example get_colpack ', -'colpack_jac.cpp ColPack: Sparse Jacobian Example and Test ',' ', -'colpack_jacobian.cpp ColPack: Sparse Jacobian Example and Test ',' ', -'colpack_hes.cpp ColPack: Sparse Hessian Example and Test ',' ', -'colpack_hessian.cpp ColPack: Sparse Hessian Example and Test ',' ', -'get_colpack.sh Download and Install ColPack in Build Directory ',' syntax purpose distribution external prefix reuse ', -'eigen_prefix Including the Eigen Examples and Tests ',' get purpose vector get_eigen ', -'get_eigen.sh Download and Install Eigen in Build Directory ',' syntax purpose distribution external prefix reuse ', -'fadbad_prefix Including the FADBAD Speed Tests ',' get purpose get_fadbad ', -'get_fadbad.sh Download and Install Fadbad in Build Directory ',' syntax purpose distribution external prefix ', -'ipopt_prefix Including the cppad_ipopt Library and Tests ',' get purpose examples get_ipopt ', -'get_ipopt.sh Download and Install Ipopt in Build Directory ',' syntax purpose distribution external prefix reuse ', -'sacado_prefix Including the Sacado Speed Tests ',' get purpose get_sacado ', -'get_sacado.sh Download and Install Sacado in Build Directory ',' syntax purpose distribution external prefix reuse ', -'cppad_testvector Choosing the CppAD Test Vector Template Class ',' purpose std boost eigen ', -'cmake_check Checking the CppAD Examples and Tests ',' purpose all windows subsets first level ', -'pkgconfig CppAD pkg-config Files ',' pc purpose usage defined fields configuration ', -'Introduction An Introduction by Example to Algorithmic Differentiation ',' ad automatic purpose preface forward mode reverse operation count efficiency outline reference ', -'exp_2 Second Order Exponential Approximation ',' example algorithm syntax purpose mathematical form include type implementation test exercises ', -'exp_2.hpp exp_2: Implementation ',' ', -'exp_2.cpp exp_2: Test ',' ', -'exp_2_for0 exp_2: Operation Sequence and Zero Order Forward Mode ',' example mathematical form expansion index code sweep return value verification exercises ', -'exp_2_for1 exp_2: First Order Forward Mode ',' expansion purpose mathematical form operation sequence index zero derivative sweep return value verification exercises ', -'exp_2_rev1 exp_2: First Order Reverse Mode ',' purpose mathematical form f_5 index 5: f_4 4: f_3 3: f_2 f_1 verification exercises ', -'exp_2_for2 exp_2: Second Order Forward Mode ',' expansion purpose mathematical form operation sequence index zero first derivative sweep return value verification exercises ', -'exp_2_rev2 exp_2: Second Order Reverse Mode ',' purpose mathematical form f_5 index 5: f_4 4: f_3 3: f_2 f_1 verification exercises ', -'exp_2_for0.cpp exp_2: Verify Zero Order Forward Sweep ',' ', -'exp_2_for1.cpp exp_2: Verify First Order Forward Sweep ',' ', -'exp_2_rev1.cpp exp_2: Verify First Order Reverse Sweep ',' mode ', -'exp_2_for2.cpp exp_2: Verify Second Order Forward Sweep ',' ', -'exp_2_rev2.cpp exp_2: Verify Second Order Reverse Sweep ',' mode ', -'exp_2_cppad exp_2: CppAD Forward and Reverse Sweeps ',' purpose exercises ', -'exp_eps An Epsilon Accurate Exponential Approximation ',' example algorithm syntax purpose mathematical function include type implementation test exercises ', -'exp_eps.hpp exp_eps: Implementation ',' ', -'exp_eps.cpp exp_eps: Test of exp_eps ',' ', -'exp_eps_for0 exp_eps: Operation Sequence and Zero Order Forward Sweep ',' example mathematical form variable parameter index code return value comparisons verification exercises ', -'exp_eps_for1 exp_eps: First Order Forward Sweep ',' expansion mathematical form operation sequence index zero derivative return value verification exercises ', -'exp_eps_rev1 exp_eps: First Order Reverse Sweep ',' mode purpose mathematical form epsilon f_7 index 7: f_6 6: f_5 5: f_4 4: f_3 3: f_2 2: f_1 verification exercises ', -'exp_eps_for2 exp_eps: Second Order Forward Mode ',' expansion purpose mathematical form operation sequence index zero first derivative sweep return value verification exercises ', -'exp_eps_rev2 exp_eps: Second Order Reverse Sweep ',' purpose mathematical form epsilon f_7 index 7: f_6 6: f_5 5: f_4 4: f_3 3: f_2 2: f_1 verification exercises ', -'exp_eps_for0.cpp exp_eps: Verify Zero Order Forward Sweep ',' ', -'exp_eps_for1.cpp exp_eps: Verify First Order Forward Sweep ',' exp_2 ', -'exp_eps_rev1.cpp exp_eps: Verify First Order Reverse Sweep ',' ', -'exp_eps_for2.cpp exp_eps: Verify Second Order Forward Sweep ',' first exp_2 ', -'exp_eps_rev2.cpp exp_eps: Verify Second Order Reverse Sweep ',' ', -'exp_eps_cppad exp_eps: CppAD Forward and Reverse Sweeps ',' purpose exercises ', -'exp_apx.cpp Correctness Tests For Exponential Approximation in Introduction ',' main run running source ', -'AD AD Objects ',' require purpose base type requirements ', -'ad_ctor AD Constructors ',' convert base vecad syntax purpose implicit explicit example ', -'ad_ctor.cpp AD Constructors: Example and Test ',' object ', -'ad_assign AD Assignment Operator ',' base vecad syntax purpose example ', -'ad_assign.cpp AD Assignment: Example and Test ',' object ', -'Convert Conversion and I/O of AD Objects ',' from ', -'Value Convert From an AD Type to its Base Type ',' syntax see also purpose operation sequence restriction example ', -'value.cpp Convert From AD to its Base Type: Example and Test ',' record ', -'Integer Convert From AD to Integer ',' syntax purpose real types complex operation sequence example ', -'integer.cpp Convert From AD to Integer: Example and Test ',' ', -'ad_to_string Convert An AD or Base Type to String ',' syntax see also value example ', -'ad_input AD Output Stream Operator ',' >> write syntax purpose is result operation sequence example ', -'ad_output AD Output Stream Operator ',' << syntax purpose assumption result operation sequence example ', -'ad_input.cpp AD Output Operator: Example and Test ',' << ', -'ad_output.cpp AD Output Operator: Example and Test ',' << ', -'PrintFor Printing AD Values During Forward Mode ',' text output debug syntax purpose f.forward(0 x) before var after redirecting discussion alternative example ', -'print_for_cout.cpp Printing During Forward Mode: Example and Test ',' running source code output ', -'print_for_string.cpp Print During Zero Order Forward Mode: Example and Test ',' ', -'Var2Par Convert an AD Variable to a Parameter ',' from value_ obtain during taping syntax see also purpose example ', -'var2par.cpp Convert an AD Variable to a Parameter: Example and Test ',' value during taping ', -'ADValued AD Valued Operations and Functions ',' ', -'Arithmetic AD Arithmetic Operators and Compound Assignments ',' ', -'UnaryPlus AD Unary Plus Operator ',' + syntax purpose operation sequence derivative example ', -'unary_plus.cpp AD Unary Plus Operator: Example and Test ',' ', -'UnaryMinus AD Unary Minus Operator ',' - syntax purpose base operation sequence derivative example ', -'unary_minus.cpp AD Unary Minus Operator: Example and Test ',' ', -'ad_binary AD Binary Arithmetic Operators ',' + add plus - subtract minus * multiply times / divide syntax purpose base z operation sequence example derivative addition subtraction multiplication division ', -'add.cpp AD Binary Addition: Example and Test ',' + plus ', -'sub.cpp AD Binary Subtraction: Example and Test ',' - minus ', -'mul.cpp AD Binary Multiplication: Example and Test ',' * multiply times ', -'div.cpp AD Binary Division: Example and Test ',' / divide quotient ', -'compound_assign AD Compound Assignment Operators ',' + add plus - subtract minus * multiply times / divide multiple syntax purpose base result operation sequence example derivative addition subtraction multiplication division ', -'AddEq.cpp AD Compound Assignment Addition: Example and Test ',' += plus ', -'sub_eq.cpp AD Compound Assignment Subtraction: Example and Test ',' -= plus add ', -'mul_eq.cpp AD Compound Assignment Multiplication: Example and Test ',' *= multiply plus add ', -'div_eq.cpp AD Compound Assignment Division: Example and Test ',' /= divide plus add ', -'unary_standard_math The Unary Standard Math Functions ',' syntax purpose possible types base ad vecad ', -'binary_math The Binary Math Functions ',' ', -'acos Inverse Sine Function: acos ',' syntax atomic derivative example ', -'asin Inverse Sine Function: asin ',' syntax atomic derivative example ', -'atan Inverse Tangent Function: atan ',' syntax atomic derivative example ', -'cos The Cosine Function: cos ',' syntax atomic derivative example ', -'cosh The Hyperbolic Cosine Function: cosh ',' syntax atomic derivative example ', -'exp The Exponential Function: exp ',' syntax atomic derivative example ', -'log The Exponential Function: log ',' syntax atomic derivative example ', -'log10 The Base 10 Logarithm Function: log10 ',' syntax method example ', -'sin The Sine Function: sin ',' syntax atomic derivative example ', -'sinh The Hyperbolic Sine Function: sinh ',' syntax atomic derivative example ', -'sqrt The Square Root Function: sqrt ',' syntax atomic derivative example ', -'tan The Tangent Function: tan ',' syntax atomic derivative example ', -'tanh The Hyperbolic Tangent Function: tanh ',' syntax atomic derivative example ', -'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 ',' ', -'abs AD Absolute Value Functions: abs, fabs ',' syntax atomic complex types derivative example ', -'fabs.cpp AD Absolute Value Function: Example and Test ',' ', -'acosh The Inverse Hyperbolic Cosine Function: acosh ',' syntax description cppad_use_cplusplus_2011 true false example ', -'acosh.cpp The AD acosh Function: Example and Test ',' ', -'asinh The Inverse Hyperbolic Sine Function: asinh ',' syntax description cppad_use_cplusplus_2011 true false example ', -'asinh.cpp The AD asinh Function: Example and Test ',' ', -'atanh The Inverse Hyperbolic Tangent Function: atanh ',' syntax description cppad_use_cplusplus_2011 true false example ', -'atanh.cpp The AD atanh Function: Example and Test ',' ', -'erf The Error Function ',' syntax description cppad_use_cplusplus_2011 true false example ', -'erf.cpp The AD erf Function: Example and Test ',' ', -'expm1 The Exponential Function Minus One: expm1 ',' syntax description cppad_use_cplusplus_2011 true false example ', -'expm1.cpp The AD exp Function: Example and Test ',' ', -'log1p The Logarithm of One Plus Argument: log1p ',' syntax description cppad_use_cplusplus_2011 true false example ', -'log1p.cpp The AD log1p Function: Example and Test ',' ', -'sign The Sign: sign ',' syntax description atomic derivative example ', -'sign.cpp Sign Function: Example and Test ',' ', -'atan2 AD Two Argument Inverse Tangent Function ',' syntax purpose theta operation sequence example ', -'atan2.cpp The AD atan2 Function: Example and Test ',' ', -'pow The AD Power Function ',' exponent syntax see also purpose z operation sequence example ', -'pow.cpp The AD Power Function: Example and Test ',' ', -'azmul Absolute Zero Multiplication ',' syntax purpose base ad vecad example ', -'azmul.cpp AD Absolute Zero Multiplication: Example and Test ',' ', -'CondExp AD Conditional Expressions ',' assign syntax purpose rel type left right if_true if_false result optimize deprecate 2005-08-07 operation sequence example test atan2 ', -'cond_exp.cpp Conditional Expressions: Example and Test ',' see also description ', -'Discrete Discrete AD Functions ',' cppad_discrete_function syntax purpose base name ay create version operation sequence derivatives parallel mode example cppadcreatediscrete deprecated 2007-07-28 ', -'tape_index.cpp Taping Array Index Operation: Example and Test ',' ', -'interp_onetape.cpp Interpolation With Out Retaping: Example and Test ',' interpolate retape see also ', -'interp_retape.cpp Interpolation With Retaping: Example and Test ',' interpolate see also ', -'numeric_limits Numeric Limits For an AD and Base Types ',' syntax cppad::numeric_limits std::numeric_limits float epsilon min max quiet_nan digits10 example ', -'num_limits.cpp Numeric Limits: Example and Test ',' ', -'atomic Atomic AD Functions ',' operation ', -'checkpoint Checkpointing Functions ',' syntax see also purpose reduce memory faster recording repeating forward restriction multiple level ad method constructor base advector name ay sparsity optimize size_var option algo atom_fun clear example ', -'checkpoint.cpp Simple Checkpointing: Example and Test ',' purpose ', -'atomic_mul_level.cpp Atomic Operations and Multiple-Levels of AD: Example and Test ',' discussion ', -'checkpoint_ode.cpp Checkpointing an ODE Solver: Example and Test ',' see also purpose problem solution ', -'checkpoint_extended_ode.cpp Checkpointing an Extended ODE Solver: Example and Test ',' mul_level see also discussion problem solution ', -'atomic_base User Defined Atomic AD Functions ',' syntax purpose virtual examples getting started scalar vector range hessian sparsity patterns general case ', -'atomic_ctor Atomic Function Constructor ',' syntax atomic_user ctor_arg_list afun implementation atomic_base restrictions name sparsity example define ', -'atomic_option Set Atomic Function Options ',' syntax atomic_sparsity pack_sparsity_enum bool_sparsity_enum set_sparsity_enum ', -'atomic_afun Using AD Version of Atomic Function ',' syntax purpose advector ay examples ', -'atomic_forward Atomic Forward Mode ',' callback virtual syntax purpose implementation q vx vy tx ty ok discussion examples ', -'atomic_reverse Atomic Reverse Mode ',' syntax purpose implementation q tx ty f g h py px ok examples ', -'atomic_for_sparse_jac Atomic Forward Jacobian Sparsity Patterns ',' syntax deprecated 2016-06-27 purpose implementation q ok examples ', -'atomic_rev_sparse_jac Atomic Reverse Jacobian Sparsity Patterns ',' syntax deprecated 2016-06-27 purpose implementation q rt st ok examples ', -'atomic_for_sparse_hes Atomic Forward Hessian Sparsity Patterns ',' syntax deprecated 2016-06-27 purpose implementation vx examples ', -'atomic_rev_sparse_hes Atomic Reverse Hessian Sparsity Patterns ',' syntax deprecated 2016-06-27 purpose implementation vx q examples ', -'atomic_base_clear Free Static Variables ',' syntax purpose future use restriction ', -'atomic_forward.cpp Atomic Forward: Example and Test ',' purpose function start class definition constructor use ', -'atomic_reverse.cpp Atomic Reverse: Example and Test ',' purpose function start class definition constructor forward use ', -'atomic_for_sparse_jac.cpp Atomic Forward Jacobian Sparsity: Example and Test ',' purpose function start class definition constructor use with x_1 both variable parameter ', -'atomic_rev_sparse_jac.cpp Atomic Reverse Jacobian Sparsity: Example and Test ',' purpose function start class definition constructor forward use with x_1 both variable parameter ', -'atomic_for_sparse_hes.cpp Atomic Forward Hessian Sparsity: Example and Test ',' purpose function start class definition constructor for_sparse_jac rev_sparse_jac use with x_1 both variable parameter ', -'atomic_rev_sparse_hes.cpp Atomic Reverse Hessian Sparsity: Example and Test ',' purpose function start class definition constructor forward for_sparse_jac rev_sparse_jac use with x_1 both variable parameter ', -'atomic_get_started.cpp Getting Started with Atomic Operations: Example and Test ',' purpose class definition constructor forward end use function recording ', -'atomic_norm_sq.cpp Atomic Euclidean Norm Squared: Example and Test ',' bool_sparsity_enum theory start class definition constructor forward reverse for_sparse_jac rev_sparse_jac rev_sparse_hes end use function recording ', -'atomic_reciprocal.cpp Reciprocal as an Atomic Operation: Example and Test ',' set_sparsity_enum theory start class definition constructor forward reverse for_sparse_jac rev_sparse_jac rev_sparse_hes end use function recording ', -'atomic_set_sparsity.cpp Atomic Sparsity with Set Patterns: Example and Test ',' function set_sparsity_enum start class definition constructor forward for_sparse_jac rev_sparse_jac for_sparse_hes rev_sparse_hes end recording result ', -'atomic_tangent.cpp Tan and Tanh as User Atomic Operations: Example and Test ',' theory sparsity start class definition constructor forward reverse for_sparse_jac rev_sparse_jac rev_sparse_hes end function recording large values ', -'atomic_eigen_mat_mul.cpp Atomic Eigen Matrix Multiply: Example and Test ',' description class definition use function constructor ', -'atomic_eigen_mat_mul.hpp Atomic Eigen Matrix Multiply Class ',' see also purpose dimensions theory forward product two matrices reverse start definition public types constructor op private variables for_sparse_jac rev_sparse_jac for_sparse_hes rev_sparse_hes end ', -'atomic_eigen_mat_inv.cpp Atomic Eigen Matrix Inverse: Example and Test ',' description class definition use function constructor ', -'atomic_eigen_mat_inv.hpp Atomic Eigen Matrix Inversion Class ',' purpose dimensions theory forward product three matrices reverse start definition public types constructor op private variables end ', -'atomic_eigen_cholesky.cpp Atomic Eigen Cholesky Factorization: Example and Test ',' description use function constructor ', -'cholesky_theory AD Theory for Cholesky Factorization ',' reference notation taylor coefficient lower triangular part forward mode lemma 1 proof 2 reverse case = 0 > ', -'atomic_eigen_cholesky.hpp Atomic Eigen Cholesky Factorization Class ',' purpose start definition public types constructor op private variables forward reverse end ', -'atomic_mat_mul.cpp User Atomic Matrix Multiply: Example and Test ',' see also class definition function constructor recording forward reverse option for_sparse_jac rev_sparse_jac rev_sparse_hes ', -'atomic_mat_mul.hpp Matrix Multiply as an Atomic Operation ',' see also dimensions start class definition constructor left operand element index right result forward reverse for_sparse_jac rev_sparse_jac rev_sparse_hes end ', -'BoolValued Bool Valued Operations and Functions with AD Arguments ',' ', -'Compare AD Binary Comparison Operators ',' < <= > >= == != syntax purpose operation sequence assumptions example ', -'compare.cpp AD Binary Comparison Operators: Example and Test ',' < <= > >= == != ', -'NearEqualExt Compare AD and Base Objects for Nearly Equal ',' with syntax purpose type operation sequence example ', -'near_equal_ext.cpp Compare AD with Base Objects: Example and Test ',' nearequalext ', -'BoolFun AD Boolean Functions ',' cppad_bool_unary cppad_bool_binary syntax purpose unary_name create binary_name v operation sequence example deprecated 2007-07-31 ', -'bool_fun.cpp AD Boolean Functions: Example and Test ',' ', -'ParVar Is an AD Object a Parameter or Variable ',' syntax purpose operation sequence example ', -'par_var.cpp AD Parameter and Variable Functions: Example and Test ',' ', -'EqualOpSeq Check if Two Value are Identically Equal ',' operation sequence syntax purpose motivation b example ', -'equal_op_seq.cpp EqualOpSeq: Example and Test ',' ', -'VecAD AD Vectors that Record Index Operations ',' tape reference vecad syntax purpose alternatives vecad::reference exceptions constructor size size_t indexing example speed memory ', -'vec_ad.cpp AD Vectors that Record Index Operations: Example and Test ',' vecad ', -'base_require AD Requirements for a CppAD Base Type ',' syntax purpose api warning standard types include order numeric output operator integer suggestion absolute zero azmul ', -'base_member Required Base Class Member Functions ',' notation default constructor double copy unary operators assignment binary bool example ', -'base_cond_exp Base Type Requirements for Conditional Expressions ',' condexp cppad_cond_exp_rel purpose compareop condexptemplate ordered not condexprel ', -'base_identical Base Type Requirements for Identically Equal Comparisons ',' equalopseq the simple case more complicated cases identicalpar prototypes functions examples ', -'base_ordered Base Type Requirements for Ordered Comparisons ',' purpose not ', -'base_std_math Base Type Requirements for Standard Math Functions ',' purpose unary cppad_standard_math_unary erf asinh acosh atanh expm1 log1p sign pow isnan ', -'base_limits Base Type Requirements for Numeric Limits ',' cppad::numeric_limits cppad_numeric_limits ', -'base_to_string Extending to_string To Another Floating Point Type ',' requirement cppad_to_string ', -'base_hash Base Type Requirements for Hash Coding Values ',' syntax purpose default code inline example ', -'base_example Example AD Base Types That are not AD ',' ', -'base_alloc.hpp Example AD Where Base Constructor Allocates Memory ',' purpose include file compound assignment macro binary operator boolean class definition condexpop condexprel equalopseq identical output integer azmul ordered unary standard math erf asinh acosh atanh expm1 log1p pow numeric_limits to_string hash_code ', -'base_require.cpp Using a User Defined AD Base Type: Example and Test ',' purpose ', -'base_adolc.hpp Enable use of AD where Base is Adolc\'s adouble Type ',' syntax example include files condexpop condexprel equalopseq identical integer azmul ordered unary standard math erf asinh acosh atanh expm1 log1p sign abs pow numeric_limits to_string hash_code ', -'mul_level_adolc.cpp Using Adolc with Multiple Levels of Taping: Example and Test ',' purpose memory management configuration requirement source ', -'base_float.hpp Enable use of AD where Base is float ',' condexpop condexprel equalopseq identical integer azmul ordered unary standard math sign pow numeric_limits to_string ', -'base_double.hpp Enable use of AD where Base is double ',' condexpop condexprel equalopseq identical integer azmul ordered unary standard math sign pow numeric_limits to_string ', -'base_complex.hpp Enable use of AD where Base is std::complex ',' example include order condexpop condexprel equalopseq identical ordered integer azmul isnan valid unary math invalid pow numeric_limits to_string ', -'complex_poly.cpp Complex Polynomial: Example and Test ',' ', -'ADFun ADFun Objects ',' purpose ', -'record_adfun Create an ADFun Object (Record an Operation Sequence) ',' ', -'drivers First and Second Order Derivatives: Easy Drivers ',' ', -'Forward Forward Mode ',' ', -'Reverse Reverse Mode ',' multiple directions ', -'sparsity_pattern Calculating Sparsity Patterns ',' preferred old ', -'sparse_derivative Calculating Sparse Derivatives ',' preferred sparsity patterns old ', -'Independent Declare Independent Variables and Start Recording ',' syntax purpose stop abort_op_index vectorad parallel mode example ', -'independent.cpp Independent and ADFun Constructor: Example and Test ',' ', -'FunConstruct Construct an ADFun Object and Stop Recording ',' tape syntax purpose vectorad default constructor sequence copy assignment operator taylor coefficients sparsity patterns parallel mode example ', -'fun_assign.cpp ADFun Assignment: Example and Test ',' ', -'Dependent Stop Recording and Store Operation Sequence ',' adfun tape syntax purpose advector taping forward parallel mode example ', -'abort_recording Abort Recording of an Operation Sequence ',' tape syntax purpose example ', -'abort_recording.cpp Abort Current Recording: Example and Test ',' ', -'seq_property ADFun Sequence Properties ',' syntax see also purpose domain range parameter size_var size_par size_op size_op_arg size_text size_vecad size_op_seq example ', -'seq_property.cpp ADFun Sequence Properties: Example and Test ',' domain range parameter size_var size_par size_op_arg size_vecad ', -'Jacobian Jacobian: Driver Routine ',' first derivative syntax purpose vector forward reverse example ', -'jacobian.cpp Jacobian: Example and Test ',' ', -'Hessian Hessian: Easy Driver ',' second derivative syntax purpose f l w vector uses forward example ', -'hessian.cpp Hessian: Example and Test ',' ', -'hes_lagrangian.cpp Hessian of Lagrangian and ADFun Default Constructor: Example and Test ',' ', -'ForOne First Order Partial Derivative: Driver Routine ',' easy syntax purpose j dy vector uses forward example ', -'for_one.cpp First Order Partial Driver: Example and Test ',' ', -'RevOne First Order Derivative: Driver Routine ',' easy syntax purpose dw vector uses forward example ', -'rev_one.cpp First Order Derivative Driver: Example and Test ',' ', -'ForTwo Forward Mode Second Partial Derivative Driver ',' order easy syntax purpose j k ddy vectorbase vectorsize_t uses examples ', -'for_two.cpp Subset of Second Order Partials: Example and Test ',' ', -'RevTwo Reverse Mode Second Partial Derivative Driver ',' order easy syntax purpose f j ddw vectorbase vectorsize_t uses forward examples ', -'rev_two.cpp Second Partials Reverse Driver: Example and Test ',' ', -'forward_zero Zero Order Forward Mode: Function Values ',' syntax purpose x0 y0 vector example special case ', -'forward_one First Order Forward Mode: Derivative Values ',' syntax purpose x0 x1 vector example special case ', -'forward_two Second Order Forward Mode: Derivative Values ',' syntax purpose x0 x1 x2 y2 vector example special case ', -'forward_order Multiple Order Forward Mode ',' any syntax purpose function values derivative notation one q xq orders restrictions x(t) y(t) yq vector zero first second example ', -'forward.cpp Forward Mode: Example and Test ',' ', -'forward_order.cpp Forward Mode: Example and Test of Multiple Orders ',' ', -'forward_dir Multiple Directions Forward Mode ',' syntax purpose reverse notation q xq zero order non-zero lower orders x(t) y(t) yq vector example ', -'forward_dir.cpp Forward Mode: Example and Test of Multiple Directions ',' orders ', -'size_order Number Taylor Coefficient Orders Currently Stored ',' syntax see also purpose constructor forward capacity_order example ', -'compare_change Comparison Changes Between Taping and Zero Order Forward ',' adfun syntax purpose count speed number discussion op_index example ', -'compare_change.cpp CompareChange and Re-Tape: Example and Test ',' ', -'capacity_order Controlling Taylor Coefficients Memory Allocation ',' forward syntax see also purpose pre-allocating freeing original state example ', -'capacity_order.cpp Controlling Taylor Coefficient Memory Allocation: Example and Test ',' ', -'number_skip Number of Variables that Can be Skipped ',' syntax see also purpose example ', -'number_skip.cpp Number of Variables That Can be Skipped: Example and Test ',' optimize conditional expression ', -'reverse_one First Order Reverse Mode ',' derivative syntax purpose w dw vector example ', -'reverse_one.cpp First Order Reverse Mode: Example and Test ',' ', -'reverse_two Second Order Reverse Mode ',' derivative syntax purpose x^(k) f dw first partials vector hessian times direction example ', -'reverse_two.cpp Second Order Reverse ModeExample and Test ',' ', -'hes_times_dir.cpp Hessian Times Direction: Example and Test ',' ', -'reverse_any Any Order Reverse Mode ',' derivative syntax purpose notation u^(k) x(t u) y(t w^(k) w(u) f q dw first second vector example ', -'reverse_three.cpp Third Order Reverse Mode: Example and Test ',' taylor coefficients ', -'reverse_checkpoint.cpp Reverse Mode General Case (Checkpointing): Example and Test ',' see also purpose processing steps ', -'subgraph_reverse Reverse Mode Using Subgraphs ',' syntax purpose notation basevector boolvector sizevector select_domain q ell col dw example ', -'subgraph_reverse.cpp Computing Reverse Mode on Subgraphs: Example and Test ',' ', -'for_jac_sparsity Forward Mode Jacobian Sparsity Patterns ',' syntax purpose sizevector size_forward_bool size_forward_set pattern_in transpose dependency internal_bool pattern_out entire example ', -'for_jac_sparsity.cpp Forward Mode Jacobian Sparsity: Example and Test ',' ', -'ForSparseJac Jacobian Sparsity Pattern: Forward Mode ',' syntax purpose size_forward_bool size_forward_set q transpose dependency false true vectorset entire example ', -'for_sparse_jac.cpp Forward Mode Jacobian Sparsity: Example and Test ',' forsparsejac ', -'rev_jac_sparsity Reverse Mode Jacobian Sparsity Patterns ',' syntax purpose sizevector f pattern_in transpose dependency internal_bool pattern_out entire example ', -'rev_jac_sparsity.cpp Reverse Mode Jacobian Sparsity: Example and Test ',' ', -'RevSparseJac Jacobian Sparsity Pattern: Reverse Mode ',' syntax purpose f q transpose dependency false true vectorset entire example ', -'rev_sparse_jac.cpp Reverse Mode Jacobian Sparsity: Example and Test ',' revsparsejac ', -'rev_hes_sparsity Reverse Mode Hessian Sparsity Patterns ',' syntax purpose boolvector sizevector f select_range transpose internal_bool pattern_out entire example ', -'rev_hes_sparsity.cpp Reverse Mode Hessian Sparsity: Example and Test ',' ', -'RevSparseHes Hessian Sparsity Pattern: Reverse Mode ',' syntax purpose f q transpose false true vectorset entire example ', -'rev_sparse_hes.cpp Reverse Mode Hessian Sparsity: Example and Test ',' revsparsehes ', -'sparsity_sub.cpp Sparsity Patterns For a Subset of Variables: Example and Test ',' see also forsparsejac revsparsehes ', -'for_hes_sparsity Forward Mode Hessian Sparsity Patterns ',' syntax purpose boolvector sizevector select_domain select_range internal_bool pattern_out entire algorithm example ', -'for_hes_sparsity.cpp Forward Mode Hessian Sparsity: Example and Test ',' ', -'ForSparseHes Hessian Sparsity Pattern: Forward Mode ',' syntax purpose vectorset algorithm example ', -'for_sparse_hes.cpp Forward Mode Hessian Sparsity: Example and Test ',' forsparsehes ', -'dependency.cpp Computing Dependency: Example and Test ',' discussion pattern computation ', -'rc_sparsity.cpp Preferred Sparsity Patterns: Row and Column Indices: Example and Test ',' purpose ', -'subgraph_sparsity Subgraph Dependency Sparsity Patterns ',' syntax notation method atomic function boolvector sizevector select_domain select_range transpose pattern_out example ', -'subgraph_sparsity.cpp Subgraph Dependency Sparsity Patterns: Example and Test ',' ', -'sparse_jac Computing Sparse Jacobians ',' syntax purpose sizevector basevector sparse_jac_for sparse_jac_rev group_max subset pattern coloring cppad colpack work n_sweep uses forward example ', -'sparse_jac_for.cpp Computing Sparse Jacobian Using Forward Mode: Example and Test ',' ', -'sparse_jac_rev.cpp Computing Sparse Jacobian Using Reverse Mode: Example and Test ',' ', -'sparse_jacobian Sparse Jacobian ',' syntax purpose f row col work color_method n_sweep vectorbase vectorset restrictions vectorsize uses forward example ', -'sparse_jacobian.cpp Sparse Jacobian: Example and Test ',' ', -'sparse_hes Computing Sparse Hessians ',' syntax purpose sizevector basevector f w subset pattern coloring cppad.symmetric cppad.general colpack.symmetric colpack.general colpack.star deprecated 2017-06-01 work n_sweep uses forward example ', -'sparse_hes.cpp Computing Sparse Hessian: Example and Test ',' ', -'sparse_hessian Sparse Hessian ',' syntax purpose f w work column subset row color_method colpack.star deprecated 2017-06-01 n_sweep vectorbase vectorset restrictions vectorsize uses forward example ', -'sparse_hessian.cpp Sparse Hessian: Example and Test ',' ', -'sub_sparse_hes.cpp Computing Sparse Hessian for a Subset of Variables ',' purpose see also function example ', -'sparse_sub_hes.cpp Subset of a Sparse Hessian: Example and Test ',' purpose see also ', -'subgraph_jac_rev Compute Sparse Jacobians Using Subgraphs ',' syntax purpose method basevector sizevector boolvector f uses forward subset select_domain select_range matrix_out example ', -'subgraph_jac_rev.cpp Computing Sparse Jacobian Using Reverse Mode: Example and Test ',' ', -'subgraph_hes2jac.cpp Sparse Hessian Using Subgraphs and Jacobian: Example and Test ',' ', -'optimize Optimize an ADFun Object Tape ',' sequence operations speed memory ndebug syntax purpose options no_conditional_skip no_compare_op no_print_for_op examples efficiency testing atomic functions rev_sparse_jac nan checking optimization ', -'optimize_forward_active.cpp Example Optimization and Forward Activity Analysis ',' ', -'optimize_reverse_active.cpp Example Optimization and Reverse Activity Analysis ',' ', -'optimize_compare_op.cpp Example Optimization and Comparison Operators ',' see also ', -'optimize_print_for.cpp Example Optimization and Print Forward Operators ',' ', -'optimize_conditional_skip.cpp Example Optimization and Conditional Expressions ',' see also ', -'optimize_nest_conditional.cpp Example Optimization and Nested Conditional Expressions ',' see also ', -'optimize_cumulative_sum.cpp Example Optimization and Cumulative Sum Operations ',' ', -'abs_normal Abs-normal Representation of Non-Smooth Functions ',' reference ', -'abs_normal_fun Create An Abs-normal Representation of a Function ',' syntax zeta a(x) g z(x u) y(x affine approximation approximating f(x) correspondence to literature example ', -'abs_get_started.cpp abs_normal Getting Started: Example and Test ',' purpose source ', -'abs_print_mat abs_normal: Print a Vector or Matrix ',' syntax prototype purpose name nr nc ', -'abs_eval abs_normal: Evaluate First Order Approximation ',' syntax prototype source purpose vector g g_hat g_jac delta_x g_tilde example ', -'abs_eval.cpp abs_eval: Example and Test ',' purpose source ', -'abs_eval.hpp abs_eval Source Code ',' ', -'simplex_method abs_normal: Solve a Linear Program Using Simplex Method ',' syntax prototype source problem vector level maxitr xout ok example ', -'simplex_method.cpp abs_normal simplex_method: Example and Test ',' problem source ', -'simplex_method.hpp simplex_method Source Code ',' ', -'lp_box abs_normal: Solve a Linear Program With Box Constraints ',' syntax prototype source problem vector level d maxitr xout ok example ', -'lp_box.cpp abs_normal lp_box: Example and Test ',' problem source ', -'lp_box.hpp lp_box Source Code ',' ', -'abs_min_linear abs_normal: Minimize a Linear Abs-normal Approximation ',' syntax prototype source purpose dblvector sizevector f level g g_hat g_jac bound epsilon maxitr delta_x method sigma cutting planes iteration example ', -'abs_min_linear.cpp abs_min_linear: Example and Test ',' purpose source ', -'abs_min_linear.hpp abs_min_linear Source Code ',' ', -'min_nso_linear Non-Smooth Optimization Using Abs-normal Linear Approximations ',' syntax prototype source purpose dblvector sizevector f level epsilon maxitr b_in x_in x_out example ', -'min_nso_linear.cpp abs_normal min_nso_linear: Example and Test ',' purpose discussion source ', -'min_nso_linear.hpp min_nso_linear Source Code ',' ', -'qp_interior Solve a Quadratic Program Using Interior Point Method ',' syntax prototype source purpose problem vector level epsilon maxitr xin xout yout sout ok kkt conditions newton step elementary row reduction solution example ', -'qp_interior.cpp abs_normal qp_interior: Example and Test ',' problem source ', -'qp_interior.hpp qp_interior Source Code ',' ', -'qp_box abs_normal: Solve a Quadratic Program With Box Constraints ',' syntax prototype source purpose problem vector level epsilon maxitr xin xout ok kkt conditions example ', -'qp_box.cpp abs_normal qp_box: Example and Test ',' problem source ', -'qp_box.hpp qp_box Source Code ',' ', -'abs_min_quad abs_normal: Minimize a Linear Abs-normal Approximation ',' syntax prototype source purpose dblvector sizevector f level g g_hat g_jac hessian bound epsilon maxitr delta_x method sigma cutting planes iteration example ', -'abs_min_quad.cpp abs_min_quad: Example and Test ',' purpose source ', -'abs_min_quad.hpp abs_min_quad Source Code ',' ', -'min_nso_quad Non-Smooth Optimization Using Abs-normal Quadratic Approximations ',' syntax prototype source purpose dblvector sizevector level f epsilon maxitr b_in x_in x_out example ', -'min_nso_quad.cpp abs_normal min_nso_quad: Example and Test ',' purpose discussion source ', -'min_nso_quad.hpp min_nso_quad Source Code ',' ', -'FunCheck Check an ADFun Sequence of Operations ',' syntax purpose g ok vector uses forward discussion example ', -'fun_check.cpp ADFun Check and Re-Tape: Example and Test ',' funcheck dependent ', -'check_for_nan Check an ADFun Object For Nan Results ',' syntax debugging default error message vector_size file_name index get_check_for_nan example ', -'check_for_nan.cpp ADFun Checking For Nan: Example and Test ',' ', -'preprocessor CppAD API Preprocessor Symbols ',' cppad_ null pointer purpose documented here cppad_debug_and_release cppad_null cppad_package_string cppad_use_cplusplus_2011 elsewhere deprecated ', -'multi_thread Using CppAD in a Multi-Threading Environment ',' mode execution maximum number purpose cppad_max_num_threads parallel_setup hold_memory initialization same prohibited ', -'parallel_ad Enable AD Calculations During Parallel Mode ',' syntax purpose discussion checksimplevector example restriction ', -'thread_test.cpp Run Multi-Threading Examples and Speed Tests ',' purpose build program running a11c simple_ad team_example harmonic test_time max_threads mega_sum multi_newton num_zero num_sub num_sum use_ad implementations source ', -'a11c_openmp.cpp A Simple OpenMP Example and Test ',' a.1.1c thread purpose source code ', -'a11c_bthread.cpp A Simple Boost Thread Example and Test ',' a.1.1c purpose source code ', -'a11c_pthread.cpp A Simple Parallel Pthread Example and Test ',' openmp a.1.1c purpose source code ', -'simple_ad_openmp.cpp A Simple OpenMP AD: Example and Test ',' purpose source code ', -'simple_ad_bthread.cpp A Simple Boost Threading AD: Example and Test ',' purpose source code ', -'simple_ad_pthread.cpp A Simple pthread AD: Example and Test ',' purpose source code ', -'team_example.cpp Using a Team of AD Threads: Example and Test ',' purpose thread_team source code ', -'harmonic.cpp Multi-Threading Harmonic Summation Example / Test ',' source file ', -'harmonic_common Common Variables Used by Multi-threading Sum of 1/i ',' purpose source ', -'harmonic_setup Set Up Multi-threading Sum of 1/i ',' syntax purpose num_sum source ', -'harmonic_worker Do One Thread\'s Work for Sum of 1/i ',' syntax purpose start end thread_num source ', -'harmonic_takedown Take Down Multi-threading Sum of 1/i ',' syntax purpose source ', -'harmonic_sum Multi-Threaded Implementation of Summation of 1/i ',' syntax purpose ok num_sum source ', -'harmonic_time Timing Test of Multi-Threaded Summation of 1/i ',' syntax purpose ok time_out test_time num_threads mega_sum source ', -'multi_atomic.cpp Multi-Threading User Atomic Example / Test ',' source file ', -'multi_atomic_user Defines a User Atomic Operation that Computes Square Root ',' syntax purpose au num_itr y_initial y_squared ay limitations source ', -'multi_atomic_common Multi-Threaded User Atomic Common Information ',' purpose source ', -'multi_atomic_setup Multi-Threaded User Atomic Set Up ',' syntax purpose y_squared ok source ', -'multi_atomic_worker Multi-Threaded User Atomic Worker ',' purpose source ', -'multi_atomic_takedown Multi-Threaded User Atomic Take Down ',' syntax purpose square_root ok source ', -'multi_atomic_run Run Multi-Threaded User Atomic Calculation ',' syntax y_squared square_root ok source ', -'multi_atomic_time Timing Test for Multi-Threaded User Atomic Calculation ',' syntax time_out test_time num_threads num_solve ok ', -'multi_newton.cpp Multi-Threaded Newton Method Example / Test ',' source file ', -'multi_newton_common Common Variables use by Multi-Threaded Newton Method ',' purpose source ', -'multi_newton_setup Set Up Multi-Threaded Newton Method ',' syntax purpose num_sub xlow xup epsilon max_itr num_threads source ', -'multi_newton_worker Do One Thread\'s Work for Multi-Threaded Newton Method ',' syntax purpose low up thread_num source ', -'multi_newton_takedown Take Down Multi-threaded Newton Method ',' syntax purpose xout source ', -'multi_newton_run A Multi-Threaded Newton\'s Method ',' syntax purpose ok xout fun num_sub xlow xup epsilon max_itr num_threads source ', -'multi_newton_time Timing Test of Multi-Threaded Newton Method ',' syntax purpose ok time_out test_time num_threads num_zero num_sub num_sum use_ad source ', -'team_thread.hpp Specifications for A Team of AD Threads ',' syntax purpose restrictions team_create team_work team_destroy team_name ok example use implementation speed test source ', -'team_openmp.cpp OpenMP Implementation of a Team of AD Threads ',' ', -'team_bthread.cpp Boost Thread Implementation of a Team of AD Threads ',' ', -'team_pthread.cpp Pthread Implementation of a Team of AD Threads ',' pthread_exit bug cygwin ', -'utility Some General Purpose Utilities ',' testing c++ concepts numerical routines miscellaneous error handler the cppad vector template class multi-threading memory allocation sorting indices to_string set_union sparse matrices ', -'ErrorHandler Replacing the CppAD Error Handler ',' replace assert exception syntax constructor parallel mode call info known line file exp msg example ', -'error_handler.cpp Replacing The CppAD Error Handler: Example and Test ',' ', -'cppad_assert CppAD Assertions During Execution ',' macro cppad_assert_known cppad_assert_unknown syntax purpose ndebug restriction exp msg error handler ', -'NearEqual Determine if Two Values Are Nearly Equal ',' absolute difference relative syntax purpose type include files example exercise ', -'near_equal.cpp NearEqual Function: Example and Test ',' file name ', -'speed_test Run One Speed Test and Return Results ',' syntax purpose motivation include vector size repeat size_vec time_min rate_vec timing example ', -'SpeedTest Run One Speed Test and Print Results ',' syntax purpose motivation include size repeat name first last rate errors example ', -'speed_test.cpp speed_test: Example and test ',' ', -'speed_program.cpp Example Use of SpeedTest ',' running this output ', -'time_test Determine Amount of Time to Execute a Test ',' speed syntax purpose motivation include size repeat time_min test_size timing example ', -'elapsed_seconds Returns Elapsed Number of Seconds ',' time syntax purpose microsoft systems example ', -'elapsed_seconds.cpp Elapsed Seconds: Example and Test ',' timer ', -'time_test.cpp time_test: Example and test ',' ', -'test_boolofvoid Object that Runs a Group of Tests ',' syntax purpose width name memory_ok example ', -'NumericType Definition of a Numeric Type ',' int requirements default constructor from integer copy assignment operators example exercise ', -'numeric_type.cpp The NumericType: Example and Test ',' ', -'CheckNumericType Check NumericType Class Concept ',' syntax purpose include parallel mode example ', -'check_numeric_type.cpp The CheckNumericType Function: Example and Test ',' ', -'SimpleVector Definition of a Simple Vector ',' value_type [] ndebug template class requirements elements specified default constructor sizing copy destructor assignment size resize access using example exercise ', -'simple_vector.cpp Simple Vector Template Class: Example and Test ',' ', -'CheckSimpleVector Check Simple Vector Concept ',' syntax purpose restrictions include parallel mode example ', -'check_simple_vector.cpp The CheckSimpleVector Function: Example and Test ',' ', -'nan Obtain Nan or Determine if a Value is Nan ',' syntax purpose include macros isnan hasnan nan(zero) deprecated 2015-10-04 scalar vector example ', -'nan.cpp nan: Example and Test ',' ', -'pow_int The Integer Power Function ',' exponent syntax see also purpose include z type operation sequence example ', -'pow_int.cpp The Pow Integer Exponent: Example and Test ',' ', -'Poly Evaluate a Polynomial or its Derivative ',' template syntax description include k z type operations vector sequence example source ', -'poly.cpp Polynomial Evaluation: Example and Test ',' ', -'poly.hpp Source: Poly ',' ', -'LuDetAndSolve Compute Determinants and Solve Equations by LU Factorization ',' matrix linear ', -'LuSolve Compute Determinant and Solve Linear Equations ',' syntax description include factor invert matrix storage signdet b logdet float floatvector leqzero absgeq example source ', -'lu_solve.cpp LuSolve With Complex Arguments: Example and Test ',' ', -'lu_solve.hpp Source: LuSolve ',' ', -'LuFactor LU Factorization of A Square Matrix ',' linear equation solve syntax description include storage sign jp determinant sizevector floatvector absgeq example source ', -'lu_factor.cpp LuFactor: Example and Test ',' ', -'lu_factor.hpp Source: LuFactor ',' ', -'LuInvert Invert an LU Factored Equation ',' linear syntax description include matrix storage jp example source ', -'lu_invert.cpp LuInvert: Example and Test ',' ', -'lu_invert.hpp Source: LuInvert ',' ', -'RombergOne One DimensionalRomberg Integration ',' integrate syntax description include f float example source code ', -'romberg_one.cpp One Dimensional Romberg Integration: Example and Test ',' ', -'RombergMul Multi-dimensional Romberg Integration ',' integrate syntax description include f float floatvector example source code ', -'Rombergmul.cpp One Dimensional Romberg Integration: Example and Test ',' ', -'Runge45 An Embedded 4th and 5th Order Runge-Kutta ODE Solver ',' differential equation syntax purpose operation sequence include xf fun warning tf xi scalar fabs vector parallel mode example source code ', -'runge45_1.cpp Runge45: Example and Test ',' ', -'runge45_2.cpp Runge45: Example and Test ',' ', -'Rosen34 A 3rd and 4th Order Rosenbrock ODE Solver ',' stiff differential equation syntax description include xf fun f_t f_x nan warning optimization tf xi scalar vector parallel mode example source code ', -'rosen_34.cpp Rosen34: Example and Test ',' ', -'OdeErrControl An Error Controller for ODE Solvers ',' differential equation syntax description include notation xf method step nan order tf xi smin smax scur eabs erel ef maxabs nstep criteria discussion scalar vector example theory source code ', -'ode_err_control.cpp OdeErrControl: Example and Test ',' nan ', -'ode_err_maxabs.cpp OdeErrControl: Example and Test Using Maxabs Argument ',' ', -'OdeGear An Arbitrary Order Gear Method ',' stiff differential equation syntax purpose include fun f_x warning scalar vector example source code theory gear\'s ', -'ode_gear.cpp OdeGear: Example and Test ',' ', -'OdeGearControl An Error Controller for Gear\'s Ode Solvers ',' differential equation syntax purpose include notation xf fun f_x warning m tf xi smin smax sini eabs erel ef maxabs nstep criteria discussion scalar vector example theory source code ', -'ode_gear_control.cpp OdeGearControl: Example and Test ',' ', -'CppAD_vector The CppAD::vector Template Class ',' [] push thread_alloc syntax description include capacity assignment check size return reference move semantics element access push_back push_vector output resize clear data vectorbool memory bit_per_unit type parallel mode example exercise ', -'cppad_vector.cpp CppAD::vector Template Class: Example and Test ',' ', -'vector_bool.cpp CppAD::vectorBool Class: Example and Test ',' ', -'thread_alloc A Fast Multi-Threading Memory Allocator ',' allocation syntax purpose include ', -'thread_alloc.cpp Fast Multi-Threading Memory Allocator: Example and Test ',' openmp allocation pthread boost ', -'ta_parallel_setup Setup thread_alloc For Use in Multi-Threading Environment ',' initialize syntax purpose speed num_threads in_parallel thread_num restrictions example ', -'ta_num_threads Get Number of Threads ',' syntax purpose example ', -'ta_in_parallel Is The Current Execution in Parallel Mode ',' sequential syntax purpose flag example ', -'ta_thread_num Get the Current Thread Number ',' syntax purpose example ', -'ta_get_memory Get At Least A Specified Amount of Memory ',' allocate syntax purpose min_bytes cap_bytes v_ptr allocation speed alignment example ', -'ta_return_memory Return Memory to thread_alloc ',' available syntax purpose v_ptr ndebug example ', -'ta_free_available Free Memory Currently Available for Quick Use by a Thread ',' syntax purpose extra example ', -'ta_hold_memory Control When Thread Alloc Retains Memory For Future Use ',' syntax purpose value free_available ', -'ta_inuse Amount of Memory a Thread is Currently Using ',' syntax purpose num_bytes example ', -'ta_available Amount of Memory Available for Quick Use by a Thread ',' syntax purpose num_bytes example ', -'ta_create_array Allocate An Array and Call Default Constructor for its Elements ',' syntax purpose type size_min size_out delta alignment example ', -'ta_delete_array Deallocate An Array and Call Destructor for its Elements ',' syntax purpose type thread delta example ', -'ta_free_all Free All Memory That Was Allocated for Use by thread_alloc ',' syntax purpose ok restrictions example ', -'index_sort Returns Indices that Sort a Vector ',' syntax keys input example ', -'index_sort.cpp Index Sort: Example and Test ',' ', -'to_string Convert Certain Types to a String ',' syntax see also purpose value integer float example ', -'to_string.cpp to_string: Example and Test ',' ', -'set_union Union of Standard Sets ',' syntax purpose element left right result example ', -'set_union.cpp Set Union: Example and Test ',' ', -'sparse_rc Row and Column Index Sparsity Patterns ',' syntax sizevector empty target nr nc nnz resize set k row_major col_major example ', -'sparse_rc.cpp sparse_rc: Example and Test ',' ', -'sparse_rcv Sparse Matrix Row, Column, Value Representation ',' syntax sizevector valuevector empty pattern target nr nc nnz set k row_major col_major example ', -'sparse_rcv.cpp sparse_rcv: Example and Test ',' ', -'ipopt_solve Use Ipopt to Solve a Nonlinear Programming Problem ',' syntax purpose include file bvector dvector options retape sparse string numeric integer xi xl xu gl gu fg_eval advector solution status zl zu lambda obj_value example get_started ode_inverse ', -'ipopt_solve_get_started.cpp Nonlinear Programming Using CppAD and Ipopt: Example and Test ',' purpose configuration requirement ', -'ipopt_solve_retape.cpp Nonlinear Programming Retaping: Example and Test ',' purpose ', -'ipopt_solve_ode_inverse.cpp ODE Inverse Problem Definitions: Source Code ',' example purpose forward measurements simulation analytic solution parameter values simulated trapezoidal approximation method ', -'Example Examples ',' introduction get_started running the cppad test vector template class ', -'get_started.cpp Getting Started Using CppAD to Compute Derivatives ',' simple example purpose function value poly exercises program output running ', -'General General Examples ',' realistic description ', -'ExampleUtility Utility Routines used by CppAD Examples ',' ', -'ListAllExamples List All (Except Deprecated) CppAD Examples ',' ', -'ad_fun.cpp Creating Your Own Interface to an ADFun Object ',' example test ', -'ad_in_c.cpp Example and Test Linking CppAD to Languages Other than C++ ',' algorithmic differentiation automatic ', -'conj_grad.cpp Differentiate Conjugate Gradient Algorithm: Example and Test ',' purpose ', -'cppad_eigen.hpp Enable Use of Eigen Linear Algebra Package with CppAD ',' syntax purpose example include files numtraits namespace ', -'eigen_plugin.hpp Source Code for eigen_plugin.hpp ',' ', -'eigen_array.cpp Using Eigen Arrays: Example and Test ',' ', -'eigen_det.cpp Using Eigen To Compute Determinant: Example and Test ',' ', -'hes_minor_det.cpp Gradient of Determinant Using Expansion by Minors: Example and Test ',' ', -'hes_lu_det.cpp Gradient of Determinant Using LU Factorization: Example and Test ',' ', -'interface2c.cpp Interfacing to C: Example and Test ',' difference central ', -'jac_minor_det.cpp Gradient of Determinant Using Expansion by Minors: Example and Test ',' ', -'jac_lu_det.cpp Gradient of Determinant Using Lu Factorization: Example and Test ',' ', -'mul_level Using Multiple Levels of AD ',' background motivation procedure first start ad recording inner function second outer derivatives example ', -'mul_level.cpp Multiple Level of AD: Example and Test ',' purpose source ', -'change_param.cpp Computing a Jacobian With Constants that Change ',' multiple ad level purpose ', -'ode_stiff.cpp A Stiff Ode: Example and Test ',' ', -'mul_level_ode.cpp Taylor\'s Ode Solver: A Multi-Level AD Example and Test ',' purpose solution derivative method using source ', -'mul_level_adolc_ode.cpp Taylor\'s Ode Solver: A Multi-Level Adolc Example and Test ',' purpose solution derivative method using base_adolc.hpp memory management configuration requirement source ', -'ode_taylor.cpp Taylor\'s Ode Solver: An Example and Test ',' purpose solution forward mode ', -'stack_machine.cpp Example Differentiating a Stack Machine Interpreter ',' test ', -'general.cpp CppAD Examples and Tests ',' running ', -'speed_example.cpp Run the Speed Examples ',' program running tests ', -'lu_vec_ad.cpp Lu Factor and Solve with Recorded Pivoting ',' luvecad linear equation determinant syntax purpose storage convention matrix rhs result logdet example ', -'lu_vec_ad_ok.cpp Lu Factor and Solve With Recorded Pivoting: Example and Test ',' ', -'testvector Using The CppAD Test Vector Template Class ',' cppad_testvector syntax purpose choice cppad::vector std::vector boost::numeric::ublas::vector eigen vectors ', -'wno_conversion Suppress Suspect Implicit Conversion Warnings ',' syntax purpose ', -'speed Speed Test an Operator Overloading AD Package ',' purpose debug_which ', -'speed_main Running the Speed Test Program ',' cppad uniform_01 syntax purpose package double profile correct seed global options onetape memory optimize atomic hes2jac subgraph sparsity boolsparsity revsparsity subsparsity colpack correctness results n_sweep link functions ', -'link_det_lu Speed Testing Gradient of Determinant Using Lu Factorization ',' prototype purpose method return value size repeat matrix double ', -'link_det_minor Speed Testing Gradient of Determinant by Minor Expansion ',' prototype purpose method return value size repeat matrix double ', -'link_mat_mul Speed Testing Derivative of Matrix Multiply ',' multiple prototype purpose return value repeat z dz ', -'link_ode Speed Testing the Jacobian of Ode Solution ',' prototype purpose method return value size repeat x double ', -'link_poly Speed Testing Second Derivative of a Polynomial ',' prototype purpose method return value size repeat ddp double ', -'link_sparse_hessian Speed Testing Sparse Hessian ',' prototype method size repeat x row col n_sweep double ', -'link_sparse_jacobian Speed Testing Sparse Jacobian ',' prototype method size repeat row col x n_sweep double ', -'microsoft_timer Microsoft Version of Elapsed Number of Seconds ',' syntax purpose linking ', -'speed_utility Speed Testing Utilities ',' main program routines library source code ', -'det_by_lu Determinant Using Expansion by Lu Factorization ',' syntax inclusion constructor scalar vector example source code ', -'det_by_lu.cpp Determinant Using Lu Factorization: Example and Test ',' minors ', -'det_by_lu.hpp Source: det_by_lu ',' ', -'det_of_minor Determinant of a Minor ',' matrix syntax inclusion purpose scalar example source code ', -'det_of_minor.cpp Determinant of a Minor: Example and Test ',' ', -'det_of_minor.hpp Source: det_of_minor ',' ', -'det_by_minor Determinant Using Expansion by Minors ',' syntax inclusion constructor scalar vector example source code ', -'det_by_minor.cpp Determinant Using Expansion by Minors: Example and Test ',' ', -'det_by_minor.hpp Source: det_by_minor ',' ', -'det_33 Check Determinant of 3 by 3 matrix ',' correct syntax purpose inclusion vector ok source code ', -'det_33.hpp Source: det_33 ',' ', -'det_grad_33 Check Gradient of Determinant of 3 by 3 matrix ',' correct syntax purpose inclusion vector ok source code ', -'det_grad_33.hpp Source: det_grad_33 ',' ', -'mat_sum_sq Sum Elements of a Matrix Times Itself ',' multiply speed test syntax purpose inclusion z vector example source code ', -'mat_sum_sq.cpp Sum of the Elements of the Square of a Matrix: Example and Test ',' ', -'mat_sum_sq.hpp Source: mat_sum_sq ',' ', -'ode_evaluate Evaluate a Function Defined in Terms of an ODE ',' syntax purpose inclusion float operation sequence fabs == 0 1 fp gradient example source code ', -'ode_evaluate.cpp ode_evaluate: Example and test ',' ', -'ode_evaluate.hpp Source: ode_evaluate ',' ', -'sparse_jac_fun Evaluate a Function That Has a Sparse Jacobian ',' syntax purpose inclusion float floatvector m row col fp example source code ', -'sparse_jac_fun.cpp sparse_jac_fun: Example and test ',' ', -'sparse_jac_fun.hpp Source: sparse_jac_fun ',' ', -'sparse_hes_fun Evaluate a Function That Has a Sparse Hessian ',' syntax purpose inclusion float floatvector row col fp example source code ', -'sparse_hes_fun.cpp sparse_hes_fun: Example and test ',' ', -'sparse_hes_fun.hpp Source: sparse_hes_fun ',' ', -'uniform_01 Simulate a [0,1] Uniform Random Variate ',' [01] syntax purpose inclusion seed vector source code ', -'uniform_01.hpp Source: uniform_01 ',' ', -'speed_double Speed Test of Functions in Double ',' purpose running tests ', -'double_det_minor.cpp Double Speed: Determinant by Minor Expansion ',' link_det_minor specifications implementation ', -'double_det_lu.cpp Double Speed: Determinant Using Lu Factorization ',' link_det_lu matrix specifications implementation ', -'double_mat_mul.cpp CppAD Speed: Matrix Multiplication (Double Version) ',' multiply link_mat_mul specifications implementation ', -'double_ode.cpp Double Speed: Ode Solution ',' link_ode specifications implementation ', -'double_poly.cpp Double Speed: Evaluate a Polynomial ',' link_poly specifications implementation ', -'double_sparse_hessian.cpp Double Speed: Sparse Hessian ',' link_sparse_hessian specifications implementation ', -'double_sparse_jacobian.cpp Double Speed: Sparse Jacobian ',' link_sparse_jacobian specifications implementation ', -'speed_adolc Speed Test of Derivatives Using Adolc ',' purpose adolc_prefix running tests ', -'adolc_det_minor.cpp Adolc Speed: Gradient of Determinant by Minor Expansion ',' link_det_minor specifications implementation ', -'adolc_det_lu.cpp Adolc Speed: Gradient of Determinant Using Lu Factorization ',' link_det_lu matrix specifications implementation ', -'adolc_mat_mul.cpp Adolc Speed: Matrix Multiplication ',' link_mat_mul multiply specifications implementation ', -'adolc_ode.cpp Adolc Speed: Ode ',' link_ode specifications implementation ', -'adolc_poly.cpp Adolc Speed: Second Derivative of a Polynomial ',' link_poly specifications implementation ', -'adolc_sparse_hessian.cpp Adolc Speed: Sparse Hessian ',' link_sparse_hessian specifications implementation ', -'adolc_sparse_jacobian.cpp adolc Speed: Sparse Jacobian ',' link_sparse_jacobian specifications implementation ', -'adolc_alloc_mat Adolc Test Utility: Allocate and Free Memory For a Matrix ',' syntax purpose ', -'speed_cppad Speed Test Derivatives Using CppAD ',' purpose running tests ', -'cppad_det_minor.cpp CppAD Speed: Gradient of Determinant by Minor Expansion ',' link_det_minor specifications implementation ', -'cppad_det_lu.cpp CppAD Speed: Gradient of Determinant Using Lu Factorization ',' link_det_lu matrix specifications implementation ', -'cppad_mat_mul.cpp CppAD Speed, Matrix Multiplication ',' link_mat_mul multiply specifications implementation ', -'cppad_ode.cpp CppAD Speed: Gradient of Ode Solution ',' link_ode specifications implementation ', -'cppad_poly.cpp CppAD Speed: Second Derivative of a Polynomial ',' link_poly specifications implementation ', -'cppad_sparse_hessian.cpp CppAD Speed: Sparse Hessian ',' link_sparse_hessian specifications implementation ', -'cppad_sparse_jacobian.cpp CppAD Speed: Sparse Jacobian ',' link_sparse_jacobian specifications implementation ', -'speed_fadbad Speed Test Derivatives Using Fadbad ',' purpose fadbad_prefix running tests ', -'fadbad_det_minor.cpp Fadbad Speed: Gradient of Determinant by Minor Expansion ',' link_det_minor specifications implementation ', -'fadbad_det_lu.cpp Fadbad Speed: Gradient of Determinant Using Lu Factorization ',' link_det_lu matrix specifications implementation ', -'fadbad_mat_mul.cpp Fadbad Speed: Matrix Multiplication ',' link_mat_mul multiply specifications implementation ', -'fadbad_ode.cpp Fadbad Speed: Ode ',' link_ode specifications implementation ', -'fadbad_poly.cpp Fadbad Speed: Second Derivative of a Polynomial ',' link_poly specifications implementation ', -'fadbad_sparse_hessian.cpp Fadbad Speed: Sparse Hessian ',' ', -'fadbad_sparse_jacobian.cpp fadbad Speed: sparse_jacobian ',' ', -'speed_sacado Speed Test Derivatives Using Sacado ',' purpose sacado_prefix running tests ', -'sacado_det_minor.cpp Sacado Speed: Gradient of Determinant by Minor Expansion ',' link_det_minor specifications implementation ', -'sacado_det_lu.cpp Sacado Speed: Gradient of Determinant Using Lu Factorization ',' link_det_lu matrix specifications implementation ', -'sacado_mat_mul.cpp Sacado Speed: Matrix Multiplication ',' link_mat_mul multiply specifications implementation ', -'sacado_ode.cpp Sacado Speed: Gradient of Ode Solution ',' link_ode specifications implementation ', -'sacado_poly.cpp Sacado Speed: Second Derivative of a Polynomial ',' link_poly specifications implementation ', -'sacado_sparse_hessian.cpp Sacado Speed: Sparse Hessian ',' ', -'sacado_sparse_jacobian.cpp sacado Speed: sparse_jacobian ',' ', -'Appendix Appendix ',' ', -'Faq Frequently Asked Questions and Answers ',' assignment independent bugs comparechange complex types exceptions variables matrix inverse lusolve atomic operation mode: forward reverse namespace test vector preprocessor symbol speed ndebug optimize memory allocation tape storage: disk ', -'directory Directory Structure ',' distribution example ', -'Theory The Theory of Derivative Calculations ',' ', -'ForwardTheory The Theory of Forward Mode ',' taylor notation binary operators addition subtraction multiplication division standard math functions differential equation coefficients recursion formula cases that apply above special ', -'exp_forward Exponential Function Forward Mode Theory ',' expm1 derivatives taylor coefficients recursion ', -'log_forward Logarithm Function Forward Mode Theory ',' log1p derivatives taylor coefficients recursion ', -'sqrt_forward Square Root Function Forward Mode Theory ',' ', -'sin_cos_forward Trigonometric and Hyperbolic Sine and Cosine Forward Theory ',' sinh cosh differential equation ', -'atan_forward Inverse Tangent and Hyperbolic Tangent Forward Mode Theory ',' atanh derivatives taylor coefficients recursion ', -'asin_forward Inverse Sine and Hyperbolic Sine Forward Mode Theory ',' asinh derivatives taylor coefficients recursion ', -'acos_forward Inverse Cosine and Hyperbolic Cosine Forward Mode Theory ',' acosh derivatives taylor coefficients recursion ', -'tan_forward Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory ',' derivatives coefficients recursion ', -'erf_forward Error Function Forward Taylor Polynomial Theory ',' derivatives coefficients recursion ', -'ReverseTheory The Theory of Reverse Mode ',' taylor notation binary operators addition subtraction multiplication division standard math functions ', -'exp_reverse Exponential Function Reverse Mode Theory ',' expm1 ', -'log_reverse Logarithm Function Reverse Mode Theory ',' log1p ', -'sqrt_reverse Square Root Function Reverse Mode Theory ',' ', -'sin_cos_reverse Trigonometric and Hyperbolic Sine and Cosine Reverse Theory ',' sinh cosh ', -'atan_reverse Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory ',' ', -'asin_reverse Inverse Sine and Hyperbolic Sine Reverse Mode Theory ',' asinh ', -'acos_reverse Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory ',' acosh ', -'tan_reverse Tangent and Hyperbolic Tangent Reverse Mode Theory ',' notation eliminating y(t) positive orders z(t) zero ', -'erf_reverse Error Function Reverse Mode Theory ',' notation positive orders z(t) zero ', -'reverse_identity An Important Reverse Mode Identity ',' notation sweep theorem proof ', -'glossary Glossary ',' efficient ad function base type above elementary vector operation atomic sequence dependent independent parameter row-major representation sparsity pattern column index vectors boolean sets tape active inactive variable variables taylor coefficient ', -'Bib Bibliography ',' abramowitz stegun the c++ programming language evaluating derivatives numerical recipes shampine l.f. ', -'wish_list The CppAD Wish List ',' multi-threading atomic subgraph new api sparsity element-wise operations check_finite test_boolofvoid eigen example optimization taping special operators memory checkpoint retape testing compilation speed base requirements adolc forward mode recomputation iterator interface sequence software guidelines tracing atan2 benderquad ', -'whats_new Changes and Additions to CppAD ',' introduction this year previous years ', -'whats_new_17 Changes and Additions to CppAD During 2017 ',' api 12-14 12-08 12-06 12-05 12-04 12-01 11-30 11-23 11-20 11-19 11-15 11-13 11-12 11-08 11-06 11-04 10-23 09-16 08-30 08-29 08-09 08-08 07-25 07-03 07-01 06-28 06-11 06-10 06-07 06-04 06-03 06-01 05-29 05-19 05-14 05-12 04-08 04-02 03-31 03-29 03-25 03-20 03-13 03-11 03-10 03-06 03-04 02-26 02-21 02-19 02-15 02-13 02-11 02-10 02-09 02-08 02-05 02-03 02-02 02-01 01-30 01-29 01-27 01-19 01-18 01-17 ', -'whats_new_16 Changes and Additions to CppAD During 2016 ',' introduction 12-23 12-20 12-18 12-13 12-11 12-09 11-18 11-14 11-13 10-27 10-12 09-29 09-27 09-26 09-16 09-13 08-30 08-25 07-17 07-14 06-30 06-29 06-27 06-25 06-10 05-05 04-17 03-27 03-26 03-25 03-24 03-23 03-22 03-21 03-20 03-19 03-17 03-12 03-05 03-01 02-29 02-28 02-27 02-26 02-25 02-23 01-21 01-20 01-18 ', -'whats_new_15 CppAD Changes and Additions During 2015 ',' introduction 12-31 12-29 12-28 12-08 12-01 11-30 11-25 11-24 11-14 11-08 11-06 10-21 10-16 10-06 10-04 10-03 10-02 09-28 09-27 09-25 09-24 09-23 09-21 09-20 09-19 09-16 09-03 09-02 08-31 08-30 08-29 08-28 08-26 08-25 08-20 08-17 08-16 08-09 08-06 07-31 06-16 06-11 06-09 06-07 05-26 cond_exp_1 cond_exp_2 05-11 05-10 05-09 05-08 05-07 05-05 04-18 03-13 03-06 02-28 02-18 02-16 02-14 02-11 02-10 02-09 02-07 02-06 02-04 02-03 02-02 01-30 01-29 01-26 01-23 01-21 01-20 01-09 01-07 01-02 ', -'whats_new_14 CppAD Changes and Additions During 2014 ',' introduction 12-30 12-29 12-28 12-27 12-26 12-25 12-23 12-22 12-17 12-16 12-15 11-28 11-27 09-28 09-27 09-25 09-21 05-28 05-27 05-23 05-22 05-20 05-19 05-16 05-14 03-18 03-17 03-09 03-05 03-02 03-01 02-28 02-27 02-26 02-23 02-22 02-17 02-15 01-26 01-21 01-10 ', -'whats_new_13 CppAD Changes and Additions During 2013 ',' introduction 12-29 12-27 12-26 12-24 11-27 11-13 11-12 10-29 10-23 10-22 10-16 10-15 10-14 10-13 10-12 09-20 09-19 09-18 09-07 08-12 08-11 08-06 07-26 05-28 05-21 05-17 05-15 05-14 05-12 05-11 05-04 04-28 04-27 04-26 ', -'whats_new_12 CppAD Changes and Additions During 2012 ',' introduction 12-30 12-29 12-28 12-27 12-26 12-23 12-22 12-20 12-19 12-17 12-15 12-14 12-13 11-28 11-21 11-20 11-17 11-16 11-14 11-09 11-06 11-04 10-31 10-30 10-25 10-24 10-12 10-04 10-03 10-02 09-24 09-11 08-05 07-30 07-08 07-07 07-05 07-04 07-03 07-02 07-01 06-17 06-16 06-15 06-12 06-10 06-09 06-08 06-07 06-05 06-04 06-03 06-02 06-01 05-31 05-30 05-29 05-27 05-24 04-19 04-18 04-17 04-10 04-06 04-05 04-01 03-27 03-26 03-23 03-21 03-17 03-11 03-03 03-02 02-11 02-10 02-09 01-30 01-27 01-24 01-23 01-20 01-19 01-16 01-15 01-12 01-07 01-02 ', -'whats_new_11 Changes and Additions to CppAD During 2011 ',' introduction 12-30 12-28 12-21 12-20 11-29 11-27 11-24 11-21 11-20 11-18 11-17 11-09 11-07 11-06 11-04 11-01 10-30 10-29 10-14 10-12 09-06 09-05 09-02 09-01 08-31 08-30 08-25 08-23 08-21 08-11 08-10 08-09 08-08 08-07 08-06 08-04 08-03 08-02 07-31 07-29 07-28 07-27 07-25 07-18 07-17 07-14 07-13 07-11 openmp/run.sh 07-10 07-09 07-07 06-23 06-21 06-18 05-29 05-28 05-26 05-22 05-11 05-03 04-29 04-20 04-19 03-19 03-11 03-05 02-22 02-19 02-17 02-15 02-09 02-06 02-02 02-01 01-19 01-16 01-09 ', -'whats_new_10 Changes and Additions to CppAD During 2010 ',' introduction 12-31 11-27 09-26 09-22 08-21 07-14 07-11 06-01 04-28 04-26 04-24 04-01 03-11 03-10 03-09 03-03 02-11 02-08 02-06 02-05 02-03 01-26 01-24 01-23 01-20 01-18 01-04 ', -'whats_new_09 Changes and Additions to CppAD During 2009 ',' introduction 12-23 12-22 12-18 12-12 12-04 12-02 11-28 11-27 11-26 10-30 10-29 10-28 10-27 10-24 10-23 10-21 10-16 10-14 10-03 09-30 09-29 09-28 09-26 09-20 09-19 09-18 08-25 08-14 08_13 08-13 08-11 08-10 08-09 08-06 08-02 08-01 07-31 07-26 07-25 07-24 07-23 07-06 07-04 07-03 07-02 07-01 06-30 06-29 06-28 06-25 06-22 06-21 06-20 06-06 05-20 03-24 02-20 02-15 02-01 01-31 01-18 01-06 ', -'whats_new_08 Changes and Additions to CppAD During 2008 ',' erf ipopt_cppad_nlp introduction 12-19 12-14 12-04 11-22 11-21 11-20 10-27 10-17 10-16 09-30 09-26 09-18 09-17 09-16 09-12 09-10 09-09 09-07 09-06 09-05 09-04 09-03 09-01 08-29 08-19 08-08 07-02 06-18 06-15 06-11 06-10 05-08 05-03 04-20 04-18 04-10 04-06 04-04 03-27 02-05 02-03 01-26 01-24 01-21 01-20 01-11 01-08 ', -'whats_new_07 Changes and Additions to CppAD During 2007 ',' introduction 12-29 12-25 12-21 12-08 12-05 12-04 12-03 12-02 11-29 11-23 11-18 11-06 11-05 11-04 11-03 11-02 11-01 10-30 10-27 10-23 10-22 10-16 10-13 10-05 10-02 09-06 08-09 08-07 07-30 07-29 07-28 07-26 07-25 07-23 07-22 07-21 07-20 07-19 07-18 07-14 07-13 06-22 06-20 06-14 05-26 05-25 05-24 05-22 05-08 05-05 04-19 04-17 04-14 04-11 04-10 04-07 04-06 04-05 03-31 03-30 03-29 03-20 03-15 03-14 03-13 03-09 03-28 02-27 02-22 02-17 02-16 02-15 02-06 02-04 02-03 02-02 02-01 01-29 ', -'whats_new_06 Changes and Additions to CppAD During 2006 ',' aclocal introduction 12-24 12-23 12-22 12-21 12-19 12-18 12-17 12-15 12-13 12-12 12-11 12-10 12-09 12-07 12-05 12-03 12-02 12-01 11-30 11-29 11-28 11-23 11-18 11-12 11-08 11-06 11-05 11-04 11-02 11-01 10-31 10-29 10-28 10-27 10-26 10-25 10-18 10-16 10-10 09-30 08-17 07-14 07-12 06-29 06-22 06-19 06-17 06-18 06-15 06-09 06-07 06-05 06-02 05-31 05-29 05-27 05-03 04-29 04-28 04-26 04-25 04-19 04-18 04-17 04-15 04-14 04-13 04-08 04-06 04-05 04-04 04-03 04-02 04-01 03-31 03-30 03-29 03-28 03-27 03-26 03-24 03-23 03-22 03-18 03-17 03-16 03-15 03-11 03-10 03-09 03-07 03-05 02-28 02-25 02-24 02-23 02-21 02-15 02-14 02-13 02-11 02-10 02-04 01-20 01-18 01-08 01-07 01-02 01-05 ', -'whats_new_05 Changes and Additions to CppAD During 2005 ',' 12-24 12-23 12-22 12-20 12-19 12-16 12-15 12-14 12-11 12-08 12-07 12-06 12-05 12-03 12-02 12-01 11-23 11-22 11-20 11-19 11-15 11-12 11-09 11-07 11-06 11-01 10-20 10-18 10-14 10-12 10-06 09-29 09-27 09-24 09-20 09-14 09-09 09-07 08-30 08-24 08-20 08-19 08-15 08-14 08-13 08-07 07-21 07-19 07-15 07-11 07-08 07-05 07-04 07-03 07-02 07-01 06-25 06-24 06-18 06-14 06-13 06-06 05-19 05-18 05-16 05-12 05-06 05-01 04-21 04-20 04-19 03-26 03-23 03-22 03-09 03-04 03-01 02-24 01-08 ', -'whats_new_04 Changes and Additions to CppAD During 2004 ',' introduction 12-11 12-09 12-03 11-17 11-16 11-15 11-14 11-13 11-12 11-10 11-04 11-02 11-01 10-29 10-28 10-27 10-21 10-19 10-16 10-06 09-29 09-26 09-23 09-21 09-13 09-10 09-09 09-07 09-04 09-02 08-27 08-25 08-24 08-12 07-31 07-08 07-07 07-03 07-02 06-29 06-25 06-12 06-04 06-03 06-01 05-30 05-29 05-26 05-25 05-14 05-12 05-09 05-07 05-04 05-03 04-29 04-28 04-25 04-24 04-22 04-21 04-20 04-19 04-09 04-08 04-07 04-03 04-02 04-01 03-30 03-28 03-25 03-18 03-17 03-15 03-12 03-11 03-09 03-07 03-06 03-05 03-04 03-03 03-01 02-29 02-28 02-21 02-20 02-17 02-16 02-15 02-12 02-01 01-29 01-28 01-22 ', -'whats_new_03 Changes and Additions to CppAD During 2003 ',' introduction 12-24 12-22 12-14 12-13 12-12 12-10 12-05 12-01 11-21 11-20 11-16 11-15 11-14 11-12 11-11 11-06 11-04 11-02 10-21 10-16 10-14 10-10 10-06 10-05 09-30 09-20 09-19 09-18 09-15 09-14 09-13 09-06 09-05 09-04 09-03 08-23 08-22 08-19 08-17 08-16 08-11 08-10 08-07 08-06 08-05 08-04 08-03 08-01 07-30 07-29 07-26 07-22 07-20 07-18 07-16 07-14 ', -'deprecated CppAD Deprecated API Features ',' name changes atomic functions ', -'include_deprecated Deprecated Include Files ',' 2015-11-30 2006-12-17 ', -'FunDeprecated ADFun Object Deprecated Member Functions ',' syntax purpose dependent 2007-08-07 order 2006-03-31 memory size 2006-04-03 taylor_size 2006-06-17 use_vecad 2006-04-08 size_taylor 2014-03-18 capacity_taylor ', -'CompareChange Comparison Changes During Zero Order Forward Mode ',' adfun syntax deprecated 2015-01-20 purpose discussion ', -'omp_max_thread OpenMP Parallel Setup ',' deprecated 2011-06-23 syntax purpose number independent restriction ', -'TrackNewDel Routines That Track Use of New and Delete ',' memory ndebug cppad_track_new_vec cppadtracknewvec cppad_track_del_vec cppadtrackdelvec cppad_track_extend cppadtrackextend cppad_track_count thread multi deprecated 2007-07-23 syntax purpose include file line oldptr newlen head newptr ncopy macro previously trackcount multi-threading example ', -'TrackNewDel.cpp Tracking Use of New and Delete: Example and Test ',' ', -'omp_alloc A Quick OpenMP Memory Allocator Used by CppAD ',' multi-threading allocation syntax purpose include deprecated 2011-08-23 ', -'omp_max_num_threads Set and Get Maximum Number of Threads for omp_alloc Allocator ',' deprecated 2011-08-31 syntax purpose set_max_num_threads get_max_num_threads restrictions ', -'omp_in_parallel Is The Current Execution in OpenMP Parallel Mode ',' deprecated 2011-08-31 syntax purpose flag example ', -'omp_get_thread_num Get the Current OpenMP Thread Number ',' deprecated 2011-08-31 syntax purpose example ', -'omp_get_memory Get At Least A Specified Amount of Memory ',' deprecated 2011-08-31 syntax purpose min_bytes cap_bytes v_ptr allocation speed example ', -'omp_return_memory Return Memory to omp_alloc ',' deprecated 2011-08-31 syntax purpose v_ptr thread ndebug example ', -'omp_free_available Free Memory Currently Available for Quick Use by a Thread ',' deprecated 2011-08-31 syntax purpose example ', -'omp_inuse Amount of Memory a Thread is Currently Using ',' deprecated 2011-08-31 syntax purpose num_bytes example ', -'omp_available Amount of Memory Available for Quick Use by a Thread ',' deprecated 2011-08-31 syntax purpose num_bytes example ', -'omp_create_array Allocate Memory and Create A Raw Array ',' deprecated 2011-08-31 syntax purpose type size_min size_out delta example ', -'omp_delete_array Return A Raw Array to The Available Memory for a Thread ',' deprecated 2011-08-31 syntax purpose type delta example ', -'omp_efficient Check If A Memory Allocation is Efficient for Another Use ',' removed syntax purpose v_ptr num_bytes flag thread ndebug ', -'old_max_num_threads Set Maximum Number of Threads for omp_alloc Allocator ',' removed syntax purpose restrictions ', -'omp_alloc.cpp OpenMP Memory Allocator: Example and Test ',' allocation multi thread deprecated 2011-08-31 ', -'memory_leak Memory Leak Detection ',' check static deprecated 2012-04-06 syntax purpose thread add_static flag inuse available track_count error message ', -'epsilon Machine Epsilon For AD Types ',' deprecated 2012-06-17 syntax purpose float ', -'test_vector Choosing The Vector Testing Template Class ',' cppad_test_vector deprecated 2012-07-03 syntax introduction ms windows cppad::vector std::vector boost::numeric::ublas::vector cppadvector 2007-07-28 ', -'cppad_ipopt_nlp Nonlinear Programming Using the CppAD Interface to Ipopt ',' deprecated 2012-11-28 syntax purpose namespace ipopt_library_paths fg(x) index vector projection injection representation simple sizevector numbervector adnumber advector x_i x_l x_u g_l g_u fg_info fg_info.number_functions fg_info.eval_r fg_info.retape fg_info.domain_size fg_info.range_size fg_info.number_terms fg_info.index solution status z_l z_u lambda obj_value example wish list ', -'ipopt_nlp_get_started.cpp Nonlinear Programming Using CppAD and Ipopt: Example and Test ',' purpose configuration requirement ', -'ipopt_nlp_ode Example Simultaneous Solution of Forward and Inverse Problem ',' ', -'ipopt_nlp_ode_problem An ODE Inverse Problem Example ',' notation forward measurements simulation analytic solution parameter values simulated trapezoidal approximation time grid black box method two levels iteration derivatives simultaneous source ', -'ipopt_nlp_ode_simple ODE Fitting Using Simple Representation ',' cppad_ipopt_nlp purpose argument vector objective function initial condition constraint trapezoidal approximation source ', -'ipopt_nlp_ode_fast ODE Fitting Using Fast Representation ',' purpose objective function range indices i(k0) domain j(k0) initial condition trapezoidal approximation source ', -'ipopt_nlp_ode_problem.hpp ODE Inverse Problem Definitions: Source Code ',' example ', -'ipopt_nlp_ode_simple.hpp ODE Fitting Using Simple Representation ',' cppad_ipopt_nlp example source ', -'ipopt_nlp_ode_fast.hpp ODE Fitting Using Fast Representation ',' cppad_ipopt_nlp example source ', -'ipopt_nlp_ode_run.hpp Driver for Running the Ipopt ODE Example ',' ', -'ipopt_nlp_ode_check.cpp Correctness Check for Both Simple and Fast Representations ',' ', -'ipopt_ode_speed.cpp Speed Test for Both Simple and Fast Representations ',' ', -'old_atomic User Defined Atomic AD Functions ',' operation deprecated 2013-05-27 syntax callback routines free static memory purpose partial implementation cppad_user_atomic tvector base ok id tx ty forward reverse afun ay parallel mode usage vx vy py px for_jac_sparse q rev_jac_sparse rev_hes_sparse clear restriction example simple tangent matrix multiplication ', -'old_reciprocal.cpp Old Atomic Operation Reciprocal: Example and Test ',' deprecated 2013-05-27 theory ', -'old_usead_1.cpp Using AD to Compute Atomic Function Derivatives ',' inside user checkpoint deprecated 2013-05-27 purpose simple case ', -'old_usead_2.cpp Using AD to Compute Atomic Function Derivatives ',' inside user checkpoint deprecated 2013-05-27 purpose ', -'old_tan.cpp Old Tan and Tanh as User Atomic Operations: Example and Test ',' deprecated 2013-05-27 theory ', -'old_mat_mul.cpp Old Matrix Multiply as a User Atomic Operation: Example and Test ',' deprecated 2013-05-27 include file ', -'old_mat_mul.hpp Define Matrix Multiply as a User Atomic Operation ',' old_atomic test syntax example begin source extra call information indexing one reverse partials order set union cppad callback functions declare ', -'zdouble zdouble: An AD Base Type With Absolute Zero ',' deprecated 2015-09-26 syntax constructor assignment comparison operators arithmetic standard math nan motivation general cppad requirements example ', -'zdouble.cpp zdouble: Example and Test ',' ', -'autotools Autotools Unix Test and Installation ',' deprecated 2012-12-26 distribution directory build configure make examples tests profiling cppad prefix_dir --with-documentation --with-testvector max_num_threads cxx_flags openmp_flags postfix_dir adolc_dir linux cygwin boost_dir eigen_dir fadbad_dir ipopt_dir sacado_dir tape_addr_type tape_id_type ', -'compare_c Compare Speed of C and C++ ',' with syntax purpose ', -'det_of_minor_c Determinant of a Minor ',' syntax purpose source code ', -'det_by_minor_c Compute Determinant using Expansion by Minors ',' syntax purpose source code ', -'uniform_01_c Simulate a [0,1] Uniform Random Variate ',' [01] syntax purpose seed source code ', -'correct_det_by_minor_c Correctness Test of det_by_minor Routine ',' syntax flag source code ', -'repeat_det_by_minor_c Repeat det_by_minor Routine A Specified Number of Times ',' syntax size source code ', -'elapsed_seconds_c Returns Elapsed Number of Seconds ',' syntax purpose source code ', -'time_det_by_minor_c Determine Amount of Time to Execute det_by_minor ',' syntax purpose time_min source code ', -'main_compare_c Main Program For Comparing C and C++ Speed ',' source code ', -'numeric_ad Some Numerical AD Utilities ',' ', -'BenderQuad Computing Jacobian and Hessian of Bender\'s Reduced Objective ',' syntax see also problem purpose fun fun.f fun.h fun.dy gx gxx bavector advector example ', -'bender_quad.cpp BenderQuad: Example and Test ',' ', -'opt_val_hes Jacobian and Hessian of Optimal Values ',' syntax see also reference purpose basevector fun fun::ad_vector fun.ell fun.s fun.sy signdet example ', -'opt_val_hes.cpp opt_val_hes: Example and Test ',' ', -'LuRatio LU Factorization of A Square Matrix and Stability Calculation ',' linear equation solve syntax description include storage sign jp determinant purpose sizevector advector example ', -'lu_ratio.cpp LuRatio: Example and Test ',' ', -'addon CppAD Addons ',' name include files library preprocessor symbols namespace ', -'License Your License for the CppAD Software ',' ' -] - -var MaxList = 100; -var Nstring = -1; -var Nkeyword = Keyword.length / 2; -Initialize(); - -function Initialize() -{ - UpdateList(); - document.search.keywords.focus(); -} -function UpdateList(event) -{ - key = 0; - if( window.event ) - key = window.event.keyCode; - else if( event ) - key = event.which; - if( key == 13 ) - { Goto(); - return; - } - var string = document.search.keywords.value; - if( Nstring == string.length ) - return; - Nstring = string.length; - - var word = string.match(/\S+/g); - var nword = 0; - if(word != null ) - nword = word.length; - - var pattern = new Array(nword); - for(var j = 0; j < nword; j++) - pattern[j] = new RegExp(word[j], 'i'); - - var nlist = 0; - var list = ''; - for(i = 0; (i < Nkeyword) && (nlist < MaxList) ; i++) - { - var match = true; - for(j = 0; j < nword; j++) - { var flag = pattern[j].test(Keyword[2*i]); - flag = flag || pattern[j].test(Keyword[2*i+1]); - match = match && flag; - } - - if( match ) - { - line = Keyword[2*i].split(/\s+/); - line = line.join(' '); - list = list + line + '\n'; - nlist = nlist + 1; - } - } - document.search.list.value = list; -} -function Choose(textarea) -{ var start_select = textarea.value.substring(0, textarea.selectionStart); - var start_pos = Math.max(0, start_select.lastIndexOf('\n') ); - var length = textarea.value.length; - var end_select = - textarea.value.substring(textarea.selectionEnd, length); - var end_pos = end_select.indexOf('\n'); - if( end_pos >= 0 ) - { end_pos = textarea.selectionEnd + end_pos; - } else - { end_pos = length; - } - // highlight the selected line - textarea.selectionStart = start_pos; - textarea.selectionEnd = end_pos; - // get the choice from the beginning of the line - var line = textarea.value.substring(start_pos, length); - var end_choice = line.indexOf(' '); - if( end_choice >= 0 ) - { var choice = line.substring(0, end_choice); - document.search.choice.value = choice.toLowerCase(); - } - - return true; -} -function Goto() -{ -parent.location = document.search.choice.value + '.xml'; -} diff -Nru cppad-2018.00.00.0/doc/seq_property.cpp.xml cppad-2019.02.00.0/doc/seq_property.cpp.xml --- cppad-2018.00.00.0/doc/seq_property.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/seq_property.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,197 +0,0 @@ - - - -ADFun Sequence Properties: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -seq_property.cppHeadings

- - - -
ADFun Sequence Properties: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool seq_property(void)
-{     bool ok = true;
-     using CppAD::AD;
-
-     // Use nvar to track the number of variables in the operation sequence.
-     // Start with one for the phantom variable at tape address zero.
-     size_t nvar = 1;
-
-     // Use npar to track the number of parameters in the operation sequence.
-     size_t npar = 0;
-
-     // Start with one for operator corresponding to phantom variable
-     size_t nop  = 1;
-
-     // Start with one for operator corresponding to phantom argument
-     size_t narg = 1;
-
-     // Use ntext to track the number of characters used to label
-     // output generated using PrintFor commands.
-     size_t ntext = 0;
-
-     // Use nvecad to track the number of VecAD vectors, plus the number
-     // of VecAD vector elements, in the operation sequence.
-     size_t nvecad = 0;
-
-     // a VecAD vector
-     CppAD::VecAD<double> v(2);
-     v[0]     = 0; // requires the parameter 0, when becomes a variable
-     v[1]     = 1; // requires the parameter 1, when becomes a variable
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0]     = 0.;
-     x[1]     = 1.;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-     nvar    += n;
-     nop     += n;
-
-     // a computation that adds to the operation sequence
-     AD<double> I = 0;
-     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]
-
-     // some operations that do not add to the operation sequence
-     AD<double> u = x[0];  // use same variable as x[0]
-     AD<double> w = x[1];  // use same variable as x[1]
-
-     // a computation that adds to the operation sequence
-     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
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-
-     // operations that do not add to the operation sequence
-     y[0]   = 1.;  // re-use the parameter 1
-     y[1]   = u;   // use same variable as u
-
-     // a computation that adds to the operation sequence
-     y[2]   = w + 2.;
-     nop   += 1;   // requires a new add operator
-     npar  += 1;   // new parameter 2 is new, so it must be included
-     nvar  += 1;   // variable corresponding to the result
-     narg  += 2;   // operator has two arguments
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-     nop   += 1;   // special operator for y[0] because 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]
-     nop   += 1;   // special operator at the end of operation sequence
-
-     // check the sequence property functions
-     ok &= f.Domain()      == n;
-     ok &= f.Range()       == m;
-     ok &= f.Parameter(0)  == true;
-     ok &= f.Parameter(1)  == false;
-     ok &= f.Parameter(2)  == false;
-     ok &= f.size_var()    == nvar;
-     ok &= f.size_op()     == nop;
-     ok &= f.size_op_arg() == narg;
-     ok &= f.size_par()    == npar;
-     ok &= f.size_text()   == ntext;
-     ok &= f.size_VecAD()  == nvecad;
-     size_t sum = 0;
-     sum += nop    * sizeof(CppAD::local::OpCode);
-     sum += narg   * sizeof(CPPAD_TAPE_ADDR_TYPE);
-     sum += npar   * sizeof(double);
-     sum += ntext  * sizeof(char);
-     sum += nvecad * sizeof(CPPAD_TAPE_ADDR_TYPE);
-     sum += nop    * sizeof(CPPAD_TAPE_ADDR_TYPE) * 3;
-     ok &= f.size_op_seq() == sum;
-
-     return ok;
-}
-
-
-
Input File: example/general/seq_property.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_seq_property.cpp_xml.js cppad-2019.02.00.0/doc/_seq_property.cpp_xml.js --- cppad-2018.00.00.0/doc/_seq_property.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_seq_property.cpp_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', -'adfun.xml', -'record_adfun.xml', -'seq_property.xml', -'seq_property.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'independent.xml', -'funconstruct.xml', -'dependent.xml', -'abort_recording.xml', -'seq_property.xml' -]; -var list_down1 = [ -'seq_property.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-2018.00.00.0/doc/seq_property.xml cppad-2019.02.00.0/doc/seq_property.xml --- cppad-2018.00.00.0/doc/seq_property.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/seq_property.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,518 +0,0 @@ - - - -ADFun Sequence Properties - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
ADFun Sequence Properties
-
-Syntax - -
- -n = f.Domain()
-
- -m = f.Range()
-
- -p = f.Parameter(i)
-
- -s = f.size_var()
-
- -s = f.size_par()
-
- -s = f.size_op()
-
- -s = f.size_op_arg()
-
- -s = f.size_text()
-
- -s = f.size_VecAD()
-
- -s = f.size_op_seq()
-
-
-See Also - -
-size_order -, capacity_order -, number_skip -. - -
-
-Purpose -
-The operations above return properties of the -AD of -Base - -operation sequence - -stored in the ADFun object -f -. -(If there is no operation sequence stored in -f -, -size_var returns zero.) - -
-
-f -
-The object -f - has prototype - -
-     const ADFun<
Basef
-
-(see -ADFun<Base> - constructor -). - -
-
-Domain -
-The result -n - has prototype - -
-     size_t 
n
-
-and is the dimension of the domain space corresponding to -f -. -This is equal to the size of the vector -x - in the call - -
-     Independent(
x)
-
-that starting recording the operation sequence -currently stored in -f - -(see FunConstruct - and Dependent -). - -
-
-Range -
-The result -m - has prototype - -
-     size_t 
m
-
-and is the dimension of the range space corresponding to -f -. -This is equal to the size of the vector -y - in syntax - -
-     ADFun<
Base> f(xy)
-
-or - -
-     
f.Dependent(y)
-
-depending on which stored the operation sequence currently in -f - -(see FunConstruct - and Dependent -). - -
-
-Parameter -
-The argument -i - has prototype - -
-     size_t 
i
-
-and - -0 - -i -< -m - - -. -The result -p - has prototype - -
-     bool 
p
-
-It is true if the i-th component of range space for - -F - - - -corresponds to a -parameter - in the operation sequence. -In this case, -the i-th component of - -F - - - is constant and - - - -F -i - - - -x -j - - - -( -x -) -= -0 - - -for - -j -= -0 -, - -, -n --1 - - - and all - -x - -B -n - - - -. - -
-
-size_var -
-The result -s - has prototype - -
-     size_t 
s
-
-and is the number of variables in the operation sequence plus the following: -one for a phantom variable with tape address zero, -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 -f - is roughly proportional to -s -. -(The function call f.size_order() - -returns the number of Taylor coefficient orders, per variable,direction, -currently stored in -f -.) -
-
-
If there is no operation sequence stored in -f -, -size_var returns zero -(see default constructor -). - -
-
-size_par -
-The result -s - has prototype - -
-     size_t 
s
-
-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 -considered extra data in the function object -f -. -Note that one -Base - value is required for each parameter. - -
-
-size_op -
-The result -s - has prototype - -
-     size_t 
s
-
-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 -size_var -. -Note that one enum value is required for each operator. - -
-
-size_op_arg -
-The result -s - has prototype - -
-     size_t 
s
-
-and is the total number of operator arguments in the operation sequence. -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 -phantom argument with index 0 that is not used. - -
-
-size_text -
-The result -s - has prototype - -
-     size_t 
s
-
-and is the total characters used in the PrintFor - commands -in this operation sequence. - -
-
-size_VecAD -
-The result -s - has prototype - -
-     size_t 
s
-
-and is the number of VecAD - vectors, -plus the number of elements in the vectors. -Only VecAD vectors that depend on the -independent variables are stored in the operation sequence. - -
-
-size_op_seq -
-The result -s - has prototype - -
-     size_t 
s
-
-and is the amount of memory required to store the operation sequence -(not counting a small amount of memory required for every operation sequence). -For the current version of CppAD, this is given by - - -
-     
s = f.size_op()     * sizeof(CppAD::local::OpCode)
-         + 
f.size_op_arg() * sizeof(tape_addr_type)
-         + 
f.size_par()    * sizeof(Base)
-         + 
f.size_text()   * sizeof(char)
-         + 
f.size_VecAD()  * sizeof(tape_addr_type)
-         + 
f.size_op()     * sizeof(tape_addr_type) * 3
-
-see tape_addr_type -. -Note that this is the minimal amount of memory that can hold -the information corresponding to an operation sequence. -The actual amount of memory allocated (inuse -) -for the operations sequence may be larger. - -
-
-Example - -
-The file -seq_property.cpp - -contains an example and test of these operations. -It returns true if it succeeds and false otherwise. - - - -
Input File: omh/seq_property.omh - - - diff -Nru cppad-2018.00.00.0/doc/_seq_property_xml.js cppad-2019.02.00.0/doc/_seq_property_xml.js --- cppad-2018.00.00.0/doc/_seq_property_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_seq_property_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'record_adfun.xml', -'seq_property.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'independent.xml', -'funconstruct.xml', -'dependent.xml', -'abort_recording.xml', -'seq_property.xml' -]; -var list_down0 = [ -'seq_property.cpp.xml' -]; -var list_current0 = [ -'seq_property.xml#Syntax', -'seq_property.xml#Syntax.See Also', -'seq_property.xml#Purpose', -'seq_property.xml#f', -'seq_property.xml#Domain', -'seq_property.xml#Range', -'seq_property.xml#Parameter', -'seq_property.xml#size_var', -'seq_property.xml#size_par', -'seq_property.xml#size_op', -'seq_property.xml#size_op_arg', -'seq_property.xml#size_text', -'seq_property.xml#size_VecAD', -'seq_property.xml#size_op_seq', -'seq_property.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-2018.00.00.0/doc/set_union.cpp.xml cppad-2019.02.00.0/doc/set_union.cpp.xml --- cppad-2018.00.00.0/doc/set_union.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/set_union.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ - - - -Set Union: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -set_union.cppHeadings

- - -
Set Union: Example and Test
-
# include <cppad/utility/set_union.hpp>
-
-bool set_union(void)
-{     bool ok = true;
-
-     // create empty sets
-     std::set<size_t> left, right, result;
-
-     // set left = {1, 2}
-     left.insert(1);
-     left.insert(2);
-
-     // set right = {2, 3}
-     right.insert(2);
-     right.insert(3);
-
-     // set result = {1, 2} U {2, 3}
-     result = CppAD::set_union(left, right);
-
-     // expected result
-     size_t check_vec[] = {1, 2, 3};
-     std::set<size_t> check_set(check_vec, check_vec + 3);
-
-     // check result
-     ok &= result == check_set;
-
-     return ok;
-}
-
-
-
Input File: example/utility/set_union.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_set_union.cpp_xml.js cppad-2019.02.00.0/doc/_set_union.cpp_xml.js --- cppad-2018.00.00.0/doc/_set_union.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_set_union.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'set_union.xml', -'set_union.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'set_union.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-2018.00.00.0/doc/set_union.xml cppad-2019.02.00.0/doc/set_union.xml --- cppad-2018.00.00.0/doc/set_union.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/set_union.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ - - - -Union of Standard Sets - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Union of Standard Sets
-
-Syntax - -
- -result = set_union(leftright) - - -
-
-Purpose -
-This is a simplified (and restricted) interface to -the std::union operation. - -
-
-Element -
-This is the type of the elements of the sets. - -
-
-left -
-This argument has prototype - -
-     const std::set<
Element>& left
-
-
-right -
-This argument has prototype - -
-     const std::set<
Element>& right
-
-
-result -
-The return value has prototype - -
-     std::set<
Element>& result
-
-It contains the union of -left - and -right -. -Note that C++11 detects that the return value is a temporary -and uses it for the result instead of making a separate copy. - - -
-
-Example -
-The file set_union.cpp - contains an example and test of this -operation. It returns true if the test passes and false otherwise. - - - -
Input File: cppad/utility/set_union.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_set_union_xml.js cppad-2019.02.00.0/doc/_set_union_xml.js --- cppad-2018.00.00.0/doc/_set_union_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_set_union_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'set_union.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'set_union.cpp.xml' -]; -var list_current0 = [ -'set_union.xml#Syntax', -'set_union.xml#Purpose', -'set_union.xml#Element', -'set_union.xml#left', -'set_union.xml#right', -'set_union.xml#result', -'set_union.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-2018.00.00.0/doc/sign.cpp.xml cppad-2019.02.00.0/doc/sign.cpp.xml --- cppad-2018.00.00.0/doc/sign.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/sign.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ - - - -Sign Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sign.cppHeadings

- - - -
Sign Function: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool sign(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-
-     // create f: x -> y where f(x) = sign(x)
-     size_t n = 1;
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ax(n), ay(m);
-     ax[0]     = 0.;
-     CppAD::Independent(ax);
-     ay[0]     = sign(ax[0]);
-     CppAD::ADFun<double> f(ax, ay);
-
-     // check value during recording
-     ok &= (ay[0] == 0.);
-
-     // 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.;
-     //
-     x[0]  = 2.;
-     y     = f.Forward(0, x);
-     ok   &= (y[0] == 1.);
-     dy    = f.Forward(1, dx);
-     ok   &= (dy[0] == 0.);
-     dw   = f.Reverse(1, w);
-     ok  &= (dw[0] == 0.);
-     //
-     x[0]  = 0.;
-     y     = f.Forward(0, x);
-     ok   &= (y[0] == 0.);
-     dy    = f.Forward(1, dx);
-     ok   &= (dy[0] == 0.);
-     dw   = f.Reverse(1, w);
-     ok  &= (dw[0] == 0.);
-     //
-     x[0]  = -2.;
-     y     = f.Forward(0, x);
-     ok   &= (y[0] == -1.);
-     dy    = f.Forward(1, dx);
-     ok   &= (dy[0] == 0.);
-     dw   = f.Reverse(1, w);
-     ok  &= (dw[0] == 0.);
-
-     // use a VecAD<Base>::reference object with sign
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero]           = 2.;
-     AD<double> result = sign(v[zero]);
-     ok   &= (result == 1.);
-
-     return ok;
-}
-
-
-
Input File: example/general/sign.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sign.cpp_xml.js cppad-2019.02.00.0/doc/_sign.cpp_xml.js --- cppad-2018.00.00.0/doc/_sign.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sign.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'sign.xml', -'sign.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 = [ -'sign.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-2018.00.00.0/doc/sign.xml cppad-2019.02.00.0/doc/sign.xml --- cppad-2018.00.00.0/doc/sign.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/sign.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,238 +0,0 @@ - - - -The Sign: sign - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
The Sign: sign
-
-Syntax - -
- -y = sign(x) - - -
-
-Description -
-Evaluates the sign function which is defined by - - -sign - -( -x -) -= -{ -+ -1 - -if - - -x -> -0 - -0 - -if - - -x -= -0 - --1 - -if - - -x -< -0 - - - - -
-x, y -
-See the possible types - -for a unary standard math function. - -
-
-Atomic -
-This is an atomic operation -. - -
-
-Derivative -
-CppAD computes the derivative of the sign function as zero for all -argument values -x -. -The correct mathematical derivative is different and -is given by - - -sign - -( -1 -) - - -( -x -) -= -2 -δ -( -x -) - - -where - -δ -( -x -) - - - is the Dirac Delta function. - -
-
-Example - -
-The file -sign.cpp - -contains an example and test of this function. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/sign.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_sign_xml.js cppad-2019.02.00.0/doc/_sign_xml.js --- cppad-2018.00.00.0/doc/_sign_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sign_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +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', -'unary_standard_math.xml', -'sign.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 = [ -'sign.cpp.xml' -]; -var list_current0 = [ -'sign.xml#Syntax', -'sign.xml#Description', -'sign.xml#x, y', -'sign.xml#Atomic', -'sign.xml#Derivative', -'sign.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-2018.00.00.0/doc/simple_ad_bthread.cpp.xml cppad-2019.02.00.0/doc/simple_ad_bthread.cpp.xml --- cppad-2018.00.00.0/doc/simple_ad_bthread.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/simple_ad_bthread.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,320 +0,0 @@ - - - -A Simple Boost Threading AD: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -simple_ad_bthread.cpp - -

-
A Simple Boost Threading AD: Example and Test
-
-Purpose -
-This example demonstrates how CppAD can be used in a -boost multi-threading environment. - -
-
-Source Code - - -

-# include <cppad/cppad.hpp>
-# include <boost/thread.hpp>
-# define NUMBER_THREADS  4
-
-namespace {
-     // structure with problem specific information
-     typedef struct {
-          // function argument (worker input)
-          double          x;
-          // This structure would also have return information in it,
-          // but this example only returns the ok flag
-     } problem_specific;
-     // =====================================================================
-     // General purpose code you can copy to your application
-     // =====================================================================
-     using CppAD::thread_alloc;
-     // ------------------------------------------------------------------
-     // thread specific point to the thread number (initialize as null)
-     void cleanup(size_t*)
-     {     return; }
-     boost::thread_specific_ptr<size_t> thread_num_ptr_(cleanup);
-
-     // Are we in sequential mode; i.e., other threads are waiting for
-     // master thread to set up next job ?
-     bool sequential_execution_ = true;
-
-     // used to inform CppAD when we are in parallel execution mode
-     bool in_parallel(void)
-     {     return ! sequential_execution_; }
-
-     // used to inform CppAD of current thread number thread_number()
-     size_t thread_number(void)
-     {     // return thread_all_[thread_num].thread_num
-          return *thread_num_ptr_.get();
-     }
-     // ---------------------------------------------------------------------
-     // structure with information for one thread
-     typedef struct {
-          // number for this thread (thread specific points here)
-          size_t            thread_num;
-          // pointer to this boost thread
-          boost::thread*    bthread;
-          // false if an error occurs, true otherwise
-          bool              ok;
-          // pointer to problem specific information
-          problem_specific* info;
-     } thread_one_t;
-     // vector with information for all threads
-     thread_one_t thread_all_[NUMBER_THREADS];
-     // --------------------------------------------------------------------
-     // function that initializes the thread and then calls actual worker
-     bool worker(size_t thread_num, problem_specific* info);
-     void run_one_worker(size_t thread_num)
-     {     bool ok = true;
-
-          // The master thread should call worker directly
-          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
-          // of this threads number.
-          // We must do this before calling thread_alloc::thread_num().
-          thread_num_ptr_.reset(& thread_all_[thread_num].thread_num);
-
-          // Check the value of thread_alloc::thread_num().
-          ok = thread_num == thread_alloc::thread_num();
-
-          // Now do the work
-          ok &= worker(thread_num, thread_all_[thread_num].info);
-
-          // pass back ok information for this thread
-          thread_all_[thread_num].ok = ok;
-
-          // no return value
-          return;
-     }
-     // ----------------------------------------------------------------------
-     // function that calls all the workers
-     bool run_all_workers(size_t num_threads, problem_specific* info_all[])
-     {     bool ok = true;
-
-          // initialize thread_all_ (execpt for pthread_id)
-          size_t thread_num;
-          for(thread_num = 0; thread_num < num_threads; thread_num++)
-          {     // pointed to by thread specific info for this thread
-               thread_all_[thread_num].thread_num = thread_num;
-               // initialize as false to make sure worker gets called by other
-               // threads. Note that thread_all_[0].ok does not get used
-               thread_all_[thread_num].ok         = false;
-               // problem specific information
-               thread_all_[thread_num].info       = info_all[thread_num];
-          }
-
-          // master bthread number
-          thread_num_ptr_.reset(& thread_all_[0].thread_num);
-
-          // Now thread_number() has necessary information for this thread
-          // (number zero), and while still in sequential mode,
-          // call setup for using CppAD::AD<double> in parallel mode.
-          thread_alloc::parallel_setup(
-               num_threads, in_parallel, thread_number
-          );
-          thread_alloc::hold_memory(true);
-          CppAD::parallel_ad<double>();
-
-          // 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 =
-                    new boost::thread(run_one_worker, thread_num);
-          }
-
-          // now call worker for the master thread
-          thread_num = thread_alloc::thread_num();
-          ok &= thread_num == 0;
-          ok &= worker(thread_num, thread_all_[thread_num].info);
-
-          // 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;
-               thread_all_[thread_num].bthread = CPPAD_NULL;
-          }
-
-          // Inform CppAD that we now are definately back to sequential mode
-          sequential_execution_ = true;
-
-          // now inform CppAD that there is only one thread
-          thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL);
-          thread_alloc::hold_memory(false);
-          CppAD::parallel_ad<double>();
-
-          // check to ok flag returned by during calls to work by other threads
-          for(thread_num = 1; thread_num < num_threads; thread_num++)
-               ok &= thread_all_[thread_num].ok;
-
-          return ok;
-     }
-     // =====================================================================
-     // End of General purpose code
-     // =====================================================================
-     // function that does the work for one thread
-     bool worker(size_t thread_num, problem_specific* info)
-     {     bool ok = true;
-
-          // CppAD::vector uses the CppAD fast multi-threading allocator
-          CppAD::vector< CppAD::AD<double> > ax(1), ay(1);
-          ax[0] = info->x;
-          Independent(ax);
-          ay[0] = sqrt( ax[0] * ax[0] );
-          CppAD::ADFun<double> f(ax, ay);
-
-          // Check function value corresponds to the identity
-          double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-          ok        &= CppAD::NearEqual(ay[0], ax[0], eps, eps);
-
-          // Check derivative value corresponds to the identity.
-          CppAD::vector<double> d_x(1), d_y(1);
-          d_x[0] = 1.;
-          d_y    = f.Forward(1, d_x);
-          ok    &= CppAD::NearEqual(d_x[0], 1., eps, eps);
-
-          return ok;
-     }
-}
-bool simple_ad(void)
-{     bool ok = true;
-     size_t num_threads = NUMBER_THREADS;
-
-     // Check that no memory is in use or avialable at start
-     // (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;
-     }
-
-     // initialize info_all
-     problem_specific *info, *info_all[NUMBER_THREADS];
-     for(thread_num = 0; thread_num < num_threads; thread_num++)
-     {     // problem specific information
-          size_t min_bytes(sizeof(info)), cap_bytes;
-          void*  v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes);
-          info         = static_cast<problem_specific*>(v_ptr);
-          info->x      = double(thread_num) + 1.;
-          info_all[thread_num] = info;
-     }
-
-     ok &= run_all_workers(num_threads, info_all);
-
-     // go down so that free memory for other threads before memory for master
-     thread_num = num_threads;
-     while(thread_num--)
-     {     // delete problem specific information
-          void* v_ptr = static_cast<void*>( 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;
-          // return all memory being held for future use by this thread
-          thread_alloc::free_available(thread_num);
-     }
-
-     return ok;
-}
-
-
Input File: example/multi_thread/bthread/simple_ad_bthread.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_simple_ad_bthread.cpp_xml.js cppad-2019.02.00.0/doc/_simple_ad_bthread.cpp_xml.js --- cppad-2018.00.00.0/doc/_simple_ad_bthread.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_simple_ad_bthread.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'simple_ad_bthread.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down1 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_current0 = [ -'simple_ad_bthread.cpp.xml#Purpose', -'simple_ad_bthread.cpp.xml#Source Code' -]; -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-2018.00.00.0/doc/simple_ad_openmp.cpp.xml cppad-2019.02.00.0/doc/simple_ad_openmp.cpp.xml --- cppad-2018.00.00.0/doc/simple_ad_openmp.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/simple_ad_openmp.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,257 +0,0 @@ - - - -A Simple OpenMP AD: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -simple_ad_openmp.cpp - -

-
A Simple OpenMP AD: Example and Test
-
-Purpose -
-This example demonstrates how CppAD can be used in a -OpenMP multi-threading environment. - -
-
-Source Code - - -

-# include <cppad/cppad.hpp>
-# include <omp.h>
-# define NUMBER_THREADS  4
-
-namespace {
-     // structure with problem specific information
-     typedef struct {
-          // function argument (worker input)
-          double          x;
-          // This structure would also have return information in it,
-          // but this example only returns the ok flag
-     } problem_specific;
-     // =====================================================================
-     // General purpose code you can copy to your application
-     // =====================================================================
-     using CppAD::thread_alloc;
-     // ------------------------------------------------------------------
-     // used to inform CppAD when we are in parallel execution mode
-     bool in_parallel(void)
-     {     return omp_in_parallel() != 0; }
-     // ------------------------------------------------------------------
-     // used to inform CppAD of the current thread number
-     size_t thread_number(void)
-     {     return static_cast<size_t>( omp_get_thread_num() ); }
-     // ------------------------------------------------------------------
-     // structure with information for one thread
-     typedef struct {
-          // false if an error occurs, true otherwise (worker output)
-          bool               ok;
-     } thread_one_t;
-     // vector with information for all threads
-     thread_one_t thread_all_[NUMBER_THREADS];
-     // ------------------------------------------------------------------
-     // function that calls all the workers
-     bool worker(problem_specific* info);
-     bool run_all_workers(size_t num_threads, problem_specific* info_all[])
-     {     bool ok = true;
-
-          // 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
-               thread_all_[thread_num].ok         = false;
-          }
-
-          // turn off dynamic thread adjustment
-          omp_set_dynamic(0);
-
-          // set the number of OpenMP threads
-          omp_set_num_threads( int_num_threads );
-
-          // setup for using CppAD::AD<double> in parallel
-          thread_alloc::parallel_setup(
-               num_threads, in_parallel, thread_number
-          );
-          thread_alloc::hold_memory(true);
-          CppAD::parallel_ad<double>();
-
-          // execute worker in parallel
-# pragma omp parallel for
-     for(thread_num = 0; thread_num < int_num_threads; thread_num++)
-          thread_all_[thread_num].ok = worker(info_all[thread_num]);
-// end omp parallel for
-
-          // set the number of OpenMP threads to one
-          omp_set_num_threads(1);
-
-          // now inform CppAD that there is only one thread
-          thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL);
-          thread_alloc::hold_memory(false);
-          CppAD::parallel_ad<double>();
-
-          // check to ok flag returned by during calls to work by other threads
-          for(thread_num = 1; thread_num < int_num_threads; thread_num++)
-               ok &= thread_all_[thread_num].ok;
-
-          return ok;
-     }
-     // =====================================================================
-     // End of General purpose code
-     // =====================================================================
-     // function that does the work for one thread
-     bool worker(problem_specific* info)
-     {     using CppAD::NearEqual;
-          using CppAD::AD;
-          bool ok = true;
-
-          // CppAD::vector uses the CppAD fast multi-threading allocator
-          CppAD::vector< AD<double> > ax(1), ay(1);
-          ax[0] = info->x;
-          Independent(ax);
-          ay[0] = sqrt( ax[0] * ax[0] );
-          CppAD::ADFun<double> f(ax, ay);
-
-          // Check function value corresponds to the identity
-          double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-          ok        &= NearEqual(ay[0], ax[0], eps, eps);
-
-          // Check derivative value corresponds to the identity.
-          CppAD::vector<double> d_x(1), d_y(1);
-          d_x[0] = 1.;
-          d_y    = f.Forward(1, d_x);
-          ok    &= NearEqual(d_x[0], 1., eps, eps);
-
-          return ok;
-     }
-}
-bool simple_ad(void)
-{     bool ok = true;
-     size_t num_threads = NUMBER_THREADS;
-
-     // Check that no memory is in use or avialable at start
-     // (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;
-     }
-
-     // initialize info_all
-     problem_specific *info, *info_all[NUMBER_THREADS];
-     for(thread_num = 0; thread_num < num_threads; thread_num++)
-     {     // problem specific information
-          size_t min_bytes(sizeof(info)), cap_bytes;
-          void*  v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes);
-          info         = static_cast<problem_specific*>(v_ptr);
-          info->x      = double(thread_num) + 1.;
-          info_all[thread_num] = info;
-     }
-
-     ok &= run_all_workers(num_threads, info_all);
-
-     // go down so that free memory for other threads before memory for master
-     thread_num = num_threads;
-     while(thread_num--)
-     {     // delete problem specific information
-          void* v_ptr = static_cast<void*>( 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;
-          // return all memory being held for future use by this thread
-          thread_alloc::free_available(thread_num);
-     }
-
-     return ok;
-}
-
-
Input File: example/multi_thread/openmp/simple_ad_openmp.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_simple_ad_openmp.cpp_xml.js cppad-2019.02.00.0/doc/_simple_ad_openmp.cpp_xml.js --- cppad-2018.00.00.0/doc/_simple_ad_openmp.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_simple_ad_openmp.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'simple_ad_openmp.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down1 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_current0 = [ -'simple_ad_openmp.cpp.xml#Purpose', -'simple_ad_openmp.cpp.xml#Source Code' -]; -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-2018.00.00.0/doc/simple_ad_pthread.cpp.xml cppad-2019.02.00.0/doc/simple_ad_pthread.cpp.xml --- cppad-2018.00.00.0/doc/simple_ad_pthread.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/simple_ad_pthread.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,366 +0,0 @@ - - - -A Simple pthread AD: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -simple_ad_pthread.cpp - -

-
A Simple pthread AD: Example and Test
-
-Purpose -
-This example demonstrates how CppAD can be used in a -pthread multi-threading environment. - -
-
-Source Code - - -

-# include <cppad/cppad.hpp>
-# include <pthread.h>
-# define NUMBER_THREADS  4
-
-namespace {
-     // structure with problem specific information
-     typedef struct {
-          // function argument (worker input)
-          double          x;
-          // This structure would also have return information in it,
-          // but this example only returns the ok flag
-     } problem_specific;
-     // =====================================================================
-     // General purpose code you can copy to your application
-     // =====================================================================
-     using CppAD::thread_alloc;
-     // ------------------------------------------------------------------
-     // key for accessing thread specific information
-     pthread_key_t thread_specific_key_;
-
-     // no need to destroy thread specific information
-     void thread_specific_destructor(void* thread_num_vptr)
-     {     return; }
-
-     // Are we in sequential mode; i.e., other threads are waiting for
-     // master thread to set up next job ?
-     bool sequential_execution_ = true;
-
-     // used to inform CppAD when we are in parallel execution mode
-     bool in_parallel(void)
-     {     return ! sequential_execution_; }
-
-     // 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_);
-          size_t* thread_num_ptr  = static_cast<size_t*>(thread_num_vptr);
-          size_t  thread_num      = *thread_num_ptr;
-          return thread_num;
-     }
-     // ---------------------------------------------------------------------
-     // structure with information for one thread
-     typedef struct {
-          // number for this thread (thread specific points here)
-          size_t            thread_num;
-          // pthread unique identifier for this thread
-          pthread_t         pthread_id;
-          // false if an error occurs, true otherwise
-          bool              ok;
-          // pointer to problem specific information
-          problem_specific* info;
-     } thread_one_t;
-     // vector with information for all threads
-     thread_one_t thread_all_[NUMBER_THREADS];
-     // --------------------------------------------------------------------
-     // function that initializes the thread and then calls the actual worker
-     bool worker(size_t thread_num, problem_specific* info);
-     void* run_one_worker(void* thread_num_vptr)
-     {     bool ok = true;
-
-          // thread_num for this thread
-          size_t thread_num = *static_cast<size_t*>(thread_num_vptr);
-
-          // The master thread should call worker directly
-          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
-          // of this threads number.
-          // We must do this before calling thread_alloc::thread_num().
-          int rc = pthread_setspecific(
-               thread_specific_key_,
-               thread_num_vptr
-          );
-          ok &= rc == 0;
-
-          // check the value of thread_alloc::thread_num().
-          ok = thread_num == thread_alloc::thread_num();
-
-          // Now do the work
-          ok &= worker(thread_num, thread_all_[thread_num].info);
-
-          // pass back ok information for this thread
-          thread_all_[thread_num].ok = ok;
-
-          // no return value
-          return CPPAD_NULL;
-     }
-     // --------------------------------------------------------------------
-     // function that calls all the workers
-     bool run_all_workers(size_t num_threads, problem_specific* info_all[])
-     {     bool ok = true;
-
-          // initialize thread_all_ (execpt for pthread_id)
-          size_t thread_num;
-          for(thread_num = 0; thread_num < num_threads; thread_num++)
-          {     // pointed to by thread specific info for this thread
-               thread_all_[thread_num].thread_num = thread_num;
-               // initialize as false to make sure worker gets called by other
-               // threads. Note that thread_all_[0].ok does not get used
-               thread_all_[thread_num].ok         = false;
-               // problem specific information
-               thread_all_[thread_num].info       = info_all[thread_num];
-          }
-
-          // master pthread_id
-          thread_all_[0].pthread_id = pthread_self();
-
-          // error flag for calls to pthread library
-          int rc;
-
-          // 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)
-          void* thread_num_vptr = static_cast<void*>(
-               &(thread_all_[0].thread_num)
-          );
-          rc = pthread_setspecific(thread_specific_key_, thread_num_vptr);
-          ok &= (rc == 0);
-
-          // Now thread_number() has necessary information for this thread
-          // (number zero), and while still in sequential mode,
-          // call setup for using CppAD::AD<double> in parallel mode.
-          thread_alloc::parallel_setup(
-               num_threads, in_parallel, thread_number
-          );
-          thread_alloc::hold_memory(true);
-          CppAD::parallel_ad<double>();
-
-          // 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
-          pthread_attr_t* no_attr= CPPAD_NULL;
-
-          // 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<void*> (
-                    &(thread_all_[thread_num].thread_num)
-               );
-               rc = pthread_create(
-                         &pthread_id ,
-                         no_attr     ,
-                         run_one_worker,
-                         thread_num_vptr
-               );
-               thread_all_[thread_num].pthread_id = pthread_id;
-               ok &= (rc == 0);
-          }
-
-          // now call worker for the master thread
-          thread_num = thread_alloc::thread_num();
-          ok &= thread_num == 0;
-          ok &= worker(thread_num, thread_all_[thread_num].info);
-
-          // 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(
-                    thread_all_[thread_num].pthread_id, &no_status
-               );
-               ok &= (rc == 0);
-          }
-
-          // Inform CppAD that we now are definately back to sequential mode
-          sequential_execution_ = true;
-
-          // now inform CppAD that there is only one thread
-          thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL);
-          thread_alloc::hold_memory(false);
-          CppAD::parallel_ad<double>();
-
-          // destroy the key for thread specific data
-          pthread_key_delete(thread_specific_key_);
-
-          // check to ok flag returned by during calls to work by other threads
-          for(thread_num = 1; thread_num < num_threads; thread_num++)
-               ok &= thread_all_[thread_num].ok;
-
-          return ok;
-     }
-     // =====================================================================
-     // End of General purpose code
-     // =====================================================================
-     // function that does the work for one thread
-     bool worker(size_t thread_num, problem_specific* info)
-     {     bool ok = true;
-
-          // CppAD::vector uses the CppAD fast multi-threading allocator
-          CppAD::vector< CppAD::AD<double> > ax(1), ay(1);
-          ax[0] = info->x;
-          Independent(ax);
-          ay[0] = sqrt( ax[0] * ax[0] );
-          CppAD::ADFun<double> f(ax, ay);
-
-          // Check function value corresponds to the identity
-          double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-          ok        &= CppAD::NearEqual(ay[0], ax[0], eps, eps);
-
-          // Check derivative value corresponds to the identity.
-          CppAD::vector<double> d_x(1), d_y(1);
-          d_x[0] = 1.;
-          d_y    = f.Forward(1, d_x);
-          ok    &= CppAD::NearEqual(d_x[0], 1., eps, eps);
-
-          return ok;
-     }
-}
-bool simple_ad(void)
-{     bool ok = true;
-     size_t num_threads = NUMBER_THREADS;
-
-     // Check that no memory is in use or avialable at start
-     // (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;
-     }
-
-     // initialize info_all
-     problem_specific *info, *info_all[NUMBER_THREADS];
-     for(thread_num = 0; thread_num < num_threads; thread_num++)
-     {     // problem specific information
-          size_t min_bytes(sizeof(info)), cap_bytes;
-          void*  v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes);
-          info         = static_cast<problem_specific*>(v_ptr);
-          info->x      = double(thread_num) + 1.;
-          info_all[thread_num] = info;
-     }
-
-     ok &= run_all_workers(num_threads, info_all);
-
-     // go down so that free memory for other threads before memory for master
-     thread_num = num_threads;
-     while(thread_num--)
-     {     // delete problem specific information
-          void* v_ptr = static_cast<void*>( 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;
-          // return all memory being held for future use by this thread
-          thread_alloc::free_available(thread_num);
-     }
-
-     return ok;
-}
-
-
Input File: example/multi_thread/pthread/simple_ad_pthread.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_simple_ad_pthread.cpp_xml.js cppad-2019.02.00.0/doc/_simple_ad_pthread.cpp_xml.js --- cppad-2018.00.00.0/doc/_simple_ad_pthread.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_simple_ad_pthread.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'simple_ad_pthread.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down1 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_current0 = [ -'simple_ad_pthread.cpp.xml#Purpose', -'simple_ad_pthread.cpp.xml#Source Code' -]; -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-2018.00.00.0/doc/simple_vector.cpp.xml cppad-2019.02.00.0/doc/simple_vector.cpp.xml --- cppad-2018.00.00.0/doc/simple_vector.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/simple_vector.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ - - - -Simple Vector Template Class: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -simple_vector.cppHeadings

- - - -
Simple Vector Template Class: Example and Test
-
# include <iostream>                   // std::cout and std::endl
-
-# include <vector>                     // std::vector
-# include <valarray>                   // std::valarray
-# include <cppad/utility/vector.hpp>       // CppAD::vector
-# include <cppad/utility/check_simple_vector.hpp>  // CppAD::CheckSimpleVector
-namespace {
-     template <typename Vector>
-     bool Ok(void)
-     {     // type corresponding to elements of Vector
-          typedef typename Vector::value_type Scalar;
-
-          bool ok = true;             // initialize testing flag
-
-          Vector x;                   // use the default constructor
-          ok &= (x.size() == 0);      // test size for an empty vector
-          Vector y(2);                // use the sizing constructor
-          ok &= (y.size() == 2);      // size for an vector with elements
-
-          // non-const access to the elements of y
-          size_t i;
-          for(i = 0; i < 2; i++)
-               y[i] = Scalar(i);
-
-          const Vector z(y);          // copy constructor
-          x.resize(2);                // resize
-          x = z;                      // vector assignment
-
-          // use the const access to the elements of x
-          // and test the values of elements of x, y, z
-          for(i = 0; i < 2; i++)
-          {     ok &= (x[i] == Scalar(i));
-               ok &= (y[i] == Scalar(i));
-               ok &= (z[i] == Scalar(i));
-          }
-          return ok;
-     }
-}
-bool SimpleVector (void)
-{     bool ok = true;
-
-     // use routine above to check these cases
-     ok &= Ok< std::vector<double> >();
-     ok &= Ok< std::valarray<float> >();
-     ok &= Ok< CppAD::vector<int> >();
-# ifndef _MSC_VER
-     // Avoid Microsoft following compiler warning:  'size_t' :
-     // forcing value to bool 'true' or 'false' (performance warning)
-     ok &= Ok< std::vector<bool> >();
-     ok &= Ok< CppAD::vector<bool> >();
-# endif
-     // use CheckSimpleVector for more extensive testing
-     CppAD::CheckSimpleVector<double, std::vector<double>  >();
-     CppAD::CheckSimpleVector<float,  std::valarray<float> >();
-     CppAD::CheckSimpleVector<int,    CppAD::vector<int>   >();
-     CppAD::CheckSimpleVector<bool,   std::vector<bool>    >();
-     CppAD::CheckSimpleVector<bool,   CppAD::vector<bool>  >();
-
-     return ok;
-}
-
-
Input File: example/utility/simple_vector.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_simple_vector.cpp_xml.js cppad-2019.02.00.0/doc/_simple_vector.cpp_xml.js --- cppad-2018.00.00.0/doc/_simple_vector.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_simple_vector.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'simplevector.xml', -'simple_vector.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'simple_vector.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-2018.00.00.0/doc/simplevector.xml cppad-2019.02.00.0/doc/simplevector.xml --- cppad-2018.00.00.0/doc/simplevector.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/simplevector.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,517 +0,0 @@ - - - -Definition of a Simple Vector - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Definition of a Simple Vector
-
-Template Class Requirements -
-A simple vector template class -SimpleVector -, -is any template class -that satisfies the requirements below. -The following is a list of some simple vector template classes: - -
- -Name - Documentation
- -std::vector - Section 16.3 of -The C++ Programming Language - -
- -std::valarray - Section 22.4 of -The C++ Programming Language - -
- -CppAD::vector - The CppAD::vector Template Class -
-
-Elements of Specified Type -
-A simple vector class with elements of type -Scalar -, -is any class that satisfies the requirements for a class of the form - -
-     
SimpleVector<Scalar>
-
-The routine CheckSimpleVector - can be used to check -that a class is a simple vector class with a specified element type. - -
-
-Default Constructor -
-The syntax - -
-     
SimpleVector<Scalarx;
-
-creates an empty vector -x - ( -x.size() - is zero) -that can later contain elements of the specified type -(see resize - below). - -
-
-Sizing Constructor -
-If -n - has type size_t, - -
-     
SimpleVector<Scalarx(n)
-
-creates a vector -x - with -n - elements -each of the specified type. - -
-
-Copy Constructor -
-If -x - is a -SimpleVector<Scalar> - object, - -
-     
SimpleVector<Scalary(x)
-
-creates a vector with the same type and number of elements -as -x -. -The -Scalar - assignment operator ( = ) -is used to set each element of -y - -equal to the corresponding element of -x -. -This is a `deep copy' in that the values of the elements -of -x - and -y - can be set independently after the copy. -The argument -x - is passed by reference -and may be const. - -
-
-Element Constructor and Destructor -
-The default constructor for type -Scalar - is called -for every element in a vector when the vector element is created. -The -Scalar - destructor is called when it is removed -from the vector (this includes when the vector is destroyed). - -
-
-Assignment -
-If -x - and -y - are - -SimpleVector<Scalar> - objects, - -
-     
y = x
-
-uses the -Scalar - assignment operator ( = ) -to set each element of -y - equal to -the corresponding element of -x -. -This is a `deep assignment' in that the values of the elements -of -x - and -y - can be set independently after the assignment. -The vectors -x - and -y - must have -the same number of elements. -The argument -x - is passed by reference -and may be const. -
-
-
The type returned by this assignment is unspecified; for example, -it might be void in which case the syntax - -
-     
z = y = x
-
-would not be valid. - -
-
-Size -
-If -x - is a -SimpleVector<Scalar> - object -and n has type size_t, - -
-     
n = size_t( x.size() )
-
-sets -n - to the number of elements in the vector -x -. -The object -x - may be const. - -
-
-Resize -
-If -x - is a -SimpleVector<Scalar> - object -and n has type size_t, - -
-     
x.resize(n)
-
-changes the number of elements contained in the vector -x - -to be -n -. -The value of the elements of -x - -are not specified after this operation; i.e., -any values previously stored in -x - are lost. -(The object -x - can not be const.) - -
-
-Value Type -
-If -Vector - is any simple vector class, -the syntax - -
-     
Vector::value_type
-
-is the type of the elements corresponding to the vector class; i.e., - -
-     
SimpleVector<Scalar>::value_type
-
-is equal to -Scalar -. - -
-
-Element Access -
-If -x - is a -SimpleVector<Scalar> - object -and -i - has type size_t, - -
-     
x[i]
-
-returns an object of an unspecified type, -referred to here as -elementType -. - -
-
-Using Value -
-If -elementType - is not the same as -Scalar -, -the conversion operator - -
-     static_cast<
Scalar>(x[i])
-
-is used implicitly when -x[i] - is used in an expression -with values of type -Scalar -. -For this type of usage, the object -x - may be const. - -
-
-Assignment -
-If -y - is an object of type -Scalar -, - -
-     
x[i] = y
-
-assigns the i-th element of -x - to have value -y -. -For this type of usage, the object -x - can not be const. -The type returned by this assignment is unspecified; for example, -it might be void in which case the syntax - -
-     
z = x[i] = y
-
-would not be valid. - -
-
-Example - -
-The file -simple_vector.cpp - -contains an example and test of a Simple template class. -It returns true if it succeeds and false otherwise. -(It is easy to modify to test additional simple vector template classes.) - -
-
-Exercise - -
  1. -If -Vector - is a simple vector template class, -the following code may not be valid: - -
    -     
    Vector<double> x(2);
    -     x[2] = 1.;
    -
    -Create and run a program that executes the code segment -above where -Vector - is each of the following cases: -std::vector, -CppAD::vector. -Do this both where the compiler option --DNDEBUG is and is not present on the compilation command line. -
  2. - -If -Vector - is a simple vector template class, -the following code may not be valid: - -
    -     
    Vector<int> x(2);
    -     
    Vector<int> y(1);
    -     x[0] = 0;
    -     x[1] = 1;
    -     y    = x;
    -
    -Create and run a program that executes the code segment -above where -Vector - is each of the following cases: -std::valarray, -CppAD::vector. -Do this both where the compiler option --DNDEBUG is and is not present on the compilation command line. -
- - - - -
Input File: omh/simple_vector.omh - - - diff -Nru cppad-2018.00.00.0/doc/_simplevector_xml.js cppad-2019.02.00.0/doc/_simplevector_xml.js --- cppad-2018.00.00.0/doc/_simplevector_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_simplevector_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'simplevector.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'simple_vector.cpp.xml' -]; -var list_current0 = [ -'simplevector.xml#Template Class Requirements', -'simplevector.xml#Elements of Specified Type', -'simplevector.xml#Default Constructor', -'simplevector.xml#Sizing Constructor', -'simplevector.xml#Copy Constructor', -'simplevector.xml#Element Constructor and Destructor', -'simplevector.xml#Assignment', -'simplevector.xml#Size', -'simplevector.xml#Resize', -'simplevector.xml#Value Type', -'simplevector.xml#Element Access', -'simplevector.xml#Element Access.Using Value', -'simplevector.xml#Element Access.Assignment', -'simplevector.xml#Example', -'simplevector.xml#Exercise' -]; -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-2018.00.00.0/doc/simplex_method.cpp.xml cppad-2019.02.00.0/doc/simplex_method.cpp.xml --- cppad-2018.00.00.0/doc/simplex_method.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/simplex_method.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,392 +0,0 @@ - - - -abs_normal simplex_method: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -simplex_method.cpp - -

- - - -
abs_normal simplex_method: Example and Test
-
-Problem -
-Our original problem is - - -minimize - - -| -u -- -1 -| - -w -. -r -. -t - - -u - -R - - - -We reformulate this as the following problem - - - -minimize - - -v - -w -. -r -. -t - - -( -u -, -v -) - -R - -2 - - -subject - -to - - -u -- -1 - -v - - -1 -- -u - -v - - - -We know that the value of - -v - - - at the solution is greater than -or equal zero. Hence we can reformulate this problem as - - - -minimize - - -v - -w -. -r -. -t - - -( -u -- - -, -u -+ - -, -v -) - -R - -+ -3 - - -subject - -to - - -u -+ - -- -u -- - -- -1 - -v - - -1 -- -u -+ - -+ -u -- - - -v - - - -This is equivalent to - - - -minimize - - -( -0 -, -0 -, -1 -) -· -( -u -+ - -, -u -- - -, -v -) -T - - -w -. -r -. -t - - -( -u -, -v -) - -R - -+ -3 - - -subject - -to - - -( -+ -1 - --1 - --1 - --1 - -+ -1 - -+ -1 - -) -( -u -+ - - -u -- - - -v - -) -+ -( --1 - -1 - -) - -0 - - - -which is in the form expected by simplex_method -. - - -
-
-Source - -

-# include <limits>
-# include <cppad/utility/vector.hpp>
-# include "simplex_method.hpp"
-
-bool simplex_method(void)
-{     bool ok = true;
-     typedef CppAD::vector<double> vector;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     //
-     size_t n = 3;
-     size_t m = 2;
-     vector A(m * n), b(m), c(n), xout(n);
-     A[ 0 * n + 0 ] =  1.0; // A(0,0)
-     A[ 0 * n + 1 ] = -1.0; // A(0,1)
-     A[ 0 * n + 2 ] = -1.0; // A(0,2)
-     //
-     A[ 1 * n + 0 ] = -1.0; // A(1,0)
-     A[ 1 * n + 1 ] = +1.0; // A(1,1)
-     A[ 1 * n + 2 ] = -1.0; // A(1,2)
-     //
-     b[0]           = -1.0;
-     b[1]           =  1.0;
-     //
-     c[0]           =  0.0;
-     c[1]           =  0.0;
-     c[2]           =  1.0;
-     //
-     size_t maxitr  = 10;
-     size_t level   = 0;
-     //
-     ok &= CppAD::simplex_method(level, A, b, c,  maxitr, xout);
-     //
-     // check optimal value for u
-     ok &= std::fabs( xout[0] - 1.0 ) < eps99;
-     //
-     // check optimal value for v
-     ok &= std::fabs( xout[1] ) < eps99;
-     //
-     return ok;
-}
- -
Input File: example/abs_normal/simplex_method.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_simplex_method.cpp_xml.js cppad-2019.02.00.0/doc/_simplex_method.cpp_xml.js --- cppad-2018.00.00.0/doc/_simplex_method.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_simplex_method.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'simplex_method.xml', -'simplex_method.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'simplex_method.cpp.xml', -'simplex_method.hpp.xml' -]; -var list_current0 = [ -'simplex_method.cpp.xml#Problem', -'simplex_method.cpp.xml#Source' -]; -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-2018.00.00.0/doc/simplex_method.hpp.xml cppad-2019.02.00.0/doc/simplex_method.hpp.xml --- cppad-2018.00.00.0/doc/simplex_method.hpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/simplex_method.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,342 +0,0 @@ - - - -simplex_method Source Code - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -simplex_method.hppHeadings

-
simplex_method Source Code
-
namespace CppAD { // BEGIN_CPPAD_NAMESPACE
-
-// BEGIN PROTOTYPE
-template <class Vector>
-bool simplex_method(
-     size_t        level   ,
-     const Vector& A       ,
-     const Vector& b       ,
-     const Vector& c       ,
-     size_t        maxitr  ,
-     Vector&       xout    )
-// END PROTOTYPE
-{     // number of equations
-     size_t ne  = b.size();
-     // number of x variables
-     size_t nx = c.size();
-     CPPAD_ASSERT_UNKNOWN( size_t(A.size()) == ne * nx );
-     CPPAD_ASSERT_UNKNOWN( level <= 2 );
-     //
-     if( level > 0 )
-     {     std::cout << "start simplex_method\n";
-          CppAD::abs_print_mat("A", ne, nx, A);
-          CppAD::abs_print_mat("b", ne,  1, b);
-          CppAD::abs_print_mat("c", nx, 1, c);
-     }
-     //
-     // variables (columns) in the Tableau:
-     // x: the original primary variables with size n
-     // s: slack variables, one for each equation
-     // a: auxillary variables, one for each negative right hand size
-     // r: right hand size for equations
-     //
-     // Determine number of auxillary variables
-     size_t na = 0;
-     for(size_t i = 0; i < ne; i++)
-     {     if( b[i] > 0.0 )
-               ++na;
-     }
-     // size of columns in the Tableau
-     size_t nc = nx + ne + na + 1;
-
-     // number of rows in Tableau, the equations plust two objectives
-     size_t nr = ne + 2;
-
-     // Initilize Tableau as zero
-     Vector T(nr * nc);
-     for(size_t i = 0; i < nr * nc; i++)
-          T[i] = 0.0;
-
-     // initialize basic variable flag as false
-     CppAD::vector<size_t> basic(nc);
-     for(size_t j = 0; j < nc; j++)
-          basic[j] = false;
-
-     // For i = 0 , ... , m-1, place the Equations
-     // sum_j A_{i,j} * x_j + b_i <= 0 in Tableau
-     na = 0; // use as index of next auxillary variable
-     for(size_t i = 0; i < ne; i++)
-     {     if( b[i] > 0.0)
-          {     // convert to - sum_j A_{i,j} x_j - b_i >= 0
-               for(size_t j = 0; j < nx; j++)
-                    T[i * nc + j] = - A[i * nx + j];
-               // slack variable has negative coefficient
-               T[i * nc + (nx + i)] = -1.0;
-               // auxillary variable is basic for this constraint
-               T[i * nc + (nx + ne + na)] = 1.0;
-               basic[nx + ne + na]        = true;
-               // right hand side
-               T[i * nc + (nc - 1)] = b[i];
-               //
-               ++na;
-          }
-          else
-          {     // sum_j A_{i,j} x_j + b_i <= 0
-               for(size_t j = 0; j < nx; j++)
-                    T[i * nc + j] = A[i * nx + j];
-               //  slack variable is also basic
-               T[ i * nc + (nx + i) ]  = 1.0;
-               basic[nx + i]           = true;
-               // right hand side for equations
-               T[ i * nc + (nc - 1) ] = - b[i];
-          }
-     }
-     // na is back to its original value
-     CPPAD_ASSERT_UNKNOWN( nc == nx + ne + na + 1 );
-     //
-     // place the equation objective equation in Tablueau
-     // row ne corresponds to the equation z - sum_j c_j x_j = 0
-     // column index for z is nx + ne + na
-     for(size_t j = 0; j < nx; j++)
-          T[ne * nc + j] = - c[j];
-     //
-     // row ne+1 corresponds to the equation w - a_0 - ... - a_{na-1} = 0
-     // column index for w is nx + ne + na +1
-     for(size_t j = 0; j < na; j++)
-          T[(ne + 1) * nc + (nx + ne + j)] = -1.0;
-     //
-     // fix auxillary objective so coefficients in w
-     // for auxillary variables are zero
-     for(size_t k = 0; k < na; k++)
-     {     size_t ja  = nx + ne + k;
-          size_t ia  = ne;
-          for(size_t i = 0; i < ne; i++)
-          {     if( T[i * nc + ja] != 0.0 )
-               {     CPPAD_ASSERT_UNKNOWN( T[i * nc + ja] == 1.0 );
-                    CPPAD_ASSERT_UNKNOWN( T[(ne + 1) * nc + ja] == -1.0 )
-                    CPPAD_ASSERT_UNKNOWN( ia == ne );
-                    ia = i;
-               }
-          }
-          CPPAD_ASSERT_UNKNOWN( ia < ne );
-          for(size_t j = 0; j < nc; j++)
-               T[(ne + 1) * nc + j] += T[ia * nc + j];
-          // The result in column ja is zero, avoid roundoff
-          T[(ne + 1) * nc + ja] = 0.0;
-     }
-     //
-     // index of current objective
-     size_t iobj = ne;  // original objective z
-     if( na > 0 )
-          iobj = ne + 1; // auxillary objective w
-     //
-     // simplex interations
-     for(size_t itr = 0; itr < maxitr; itr++)
-     {     // current value for xout
-          for(size_t j = 0; j < nx; j++)
-          {     xout[j] = 0.0;
-               if( basic[j] )
-               {     // determine which row of column j is non-zero
-                    xout[j] = std::numeric_limits<double>::quiet_NaN();
-                    for(size_t i = 0; i < ne; i++)
-                    {     double T_ij = T[i * nc + j];
-                         CPPAD_ASSERT_UNKNOWN( T_ij == 0.0 || T_ij == 1.0 );
-                         if( T_ij == 1.0 )
-                         {     // corresponding value in right hand side
-                              xout[j] = T[ i * nc + (nc-1) ];
-                         }
-                    }
-               }
-          }
-          if( level > 1 )
-               CppAD::abs_print_mat("T", nr, nc, T);
-          if( level > 0 )
-          {     CppAD::abs_print_mat("x", nx, 1, xout);
-               std::cout << "itr = " << itr;
-               if( iobj > ne )
-                    std::cout << ", auxillary objective w = ";
-               else
-                    std::cout << ", objective z = ";
-               std::cout << T[iobj * nc + (nc - 1)] << "\n";
-          }
-          //
-          // number of variables depends on objective
-          size_t nv = nx + ne;   // (x, s)
-          if( iobj == ne + 1 )
-          {     // check if we have solved the auxillary problem
-               bool done = true;
-               for(size_t k = 0; k < na; k++)
-                    if( basic[nx + ne + k] )
-                         done = false;
-               if( done )
-               {     // switch to optimizing the original objective
-                    iobj = ne;
-               }
-               else
-                    nv = nx + ne + na; // (x, s, a)
-          }
-          //
-          // determine variable with maximuim coefficient in objective row
-          double cmax = 0.0;
-          size_t jmax = nv;
-          for(size_t j = 0; j < nv; j++)
-          {     if( T[iobj * nc + j] > cmax )
-               {     CPPAD_ASSERT_UNKNOWN( ! basic[j] );
-                    cmax = T[ iobj * nc + j];
-                    jmax = j;
-               }
-          }
-          // check for solution
-          if( jmax == nv )
-          {     if( iobj == ne )
-               {     if( level > 0 )
-                         std::cout << "end simplex_method\n";
-                    return true;
-               }
-               if( level > 0 )
-                    std::cout << "end_simples_method: no feasible solution\n";
-               return false;
-          }
-          //
-          // We will increase the j-th variable.
-          // Determine which row will be the pivot row.
-          double rmin = std::numeric_limits<double>::infinity();
-          size_t imin = ne;
-          for(size_t i = 0; i < ne; i++)
-          {     if( T[i * nc + jmax] > 0.0 )
-               {     double r =     T[i * nc + (nc-1) ] / T[i * nc + jmax];
-                    if( r < rmin )
-                    {     rmin = r;
-                         imin = i;
-                    }
-               }
-          }
-          if( imin == ne )
-          {     // not auxillary objective
-               CPPAD_ASSERT_UNKNOWN( iobj == ne );
-               if( level > 0 ) std::cout
-                    << "end simplex_method: objective is unbounded below\n";
-               return false;
-          }
-          double pivot = T[imin * nc + jmax];
-          //
-          // Which variable is changing from basic to non-basic.
-          // Initilaize as not yet determined.
-          size_t basic2not = nc;
-          //
-          // Divide row imin by pivot element
-          for(size_t j = 0; j < nc; j++)
-          {     if( basic[j] && T[imin * nc + j] == 1.0 )
-               {     CPPAD_ASSERT_UNKNOWN( basic2not == nc );
-                    basic2not = j;
-               }
-               T[imin * nc + j] /= pivot;
-          }
-          // The result in column jmax is one, avoid roundoff
-          T[imin * nc + jmax ] = 1.0;
-          //
-          // Check that we found the variable going from basic to non-basic
-          CPPAD_ASSERT_UNKNOWN( basic2not < nv && basic2not != jmax );
-          //
-          // convert variable for column jmax to basic
-          // and for column basic2not to non-basic
-          for(size_t i = 0; i < nr; i++) if( i != imin )
-          {     double r =     T[i * nc + jmax ] / T[imin * nc + jmax];
-               // row_i = row_i - r * row_imin
-               for(size_t j = 0; j < nc; j++)
-                    T[i * nc + j] -= r * T[imin * nc + j];
-               // The result in column jmax is zero, avoid roundoff
-               T[i * nc + jmax] = 0.0;
-          }
-          // update flag for basic variables
-          basic[ basic2not ] = false;
-          basic[ jmax ]      = true;
-     }
-     if( level > 0 ) std::cout
-          << "end simplex_method: maximum # iterations without solution\n";
-     return false;
-}
-} // END_CPPAD_NAMESPACE
- -
Input File: example/abs_normal/simplex_method.omh - - - diff -Nru cppad-2018.00.00.0/doc/_simplex_method.hpp_xml.js cppad-2019.02.00.0/doc/_simplex_method.hpp_xml.js --- cppad-2018.00.00.0/doc/_simplex_method.hpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_simplex_method.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'simplex_method.xml', -'simplex_method.hpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down1 = [ -'simplex_method.cpp.xml', -'simplex_method.hpp.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-2018.00.00.0/doc/simplex_method.xml cppad-2019.02.00.0/doc/simplex_method.xml --- cppad-2018.00.00.0/doc/simplex_method.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/simplex_method.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,339 +0,0 @@ - - - -abs_normal: Solve a Linear Program Using Simplex Method - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
abs_normal: Solve a Linear Program Using Simplex Method
-
-Syntax - -
- -ok = simplex_method(levelbAcmaxitrxout)
-
-
-Prototype - -

-template <class Vector>
-bool simplex_method(
-     size_t        level   ,
-     const Vector& A       ,
-     const Vector& b       ,
-     const Vector& c       ,
-     size_t        maxitr  ,
-     Vector&       xout    )
-
-Source -
-This following is a link to the source code for this example: -simplex_method.hpp -. - -
-
-Problem -
-We are given - - -A - -R - -m -× -n - - - - -, - - -b - -R - -m - - - -, - - -c - -R - -n - - - -. -This routine solves the problem - - - -minimize - - -g -T - -x - -w -. -r -. -t - - -x - -R - -+ -n - - -subject - -to - - -A -x -+ -b - -0 - - - -
-Vector -
-The type -Vector - is a -simple vector with elements of type double. - -
-
-level -
-This value is less than or equal two. -If -level == 0 -, -no tracing is printed. -If -level >= 1 -, -a trace - -x - - - and the corresponding objective - -z - - - -is printed at each iteration. -If -level == 2 -, -a trace of the simplex Tableau is printed at each iteration. - -
-
-A -
-This is a row-major - representation -of the matrix - -A - - - in the problem. - -
-
-b -
-This is the vector - -b - - - in the problem. - -
-
-c -
-This is the vector - -c - - - in the problem. - -
-
-maxitr -
-This is the maximum number of simplex iterations to try before giving up -on convergence. - -
-
-xout -
-This argument has size is -n - and -the input value of its elements does no matter. -Upon return it is the primal variables corresponding to the problem solution. - -
-
-ok -
-If the return value -ok - is true, a solution has been found. - - -
-
-Example -
-The file simplex_method.cpp - contains an example and test of -simplex_method. -It returns true if the test passes and false otherwise. - - -
Input File: example/abs_normal/simplex_method.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_simplex_method_xml.js cppad-2019.02.00.0/doc/_simplex_method_xml.js --- cppad-2018.00.00.0/doc/_simplex_method_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_simplex_method_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'abs_normal.xml', -'simplex_method.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'abs_normal_fun.xml', -'abs_print_mat.xml', -'abs_eval.xml', -'simplex_method.xml', -'lp_box.xml', -'abs_min_linear.xml', -'min_nso_linear.xml', -'qp_interior.xml', -'qp_box.xml', -'abs_min_quad.xml', -'min_nso_quad.xml' -]; -var list_down0 = [ -'simplex_method.cpp.xml', -'simplex_method.hpp.xml' -]; -var list_current0 = [ -'simplex_method.xml#Syntax', -'simplex_method.xml#Prototype', -'simplex_method.xml#Source', -'simplex_method.xml#Problem', -'simplex_method.xml#Vector', -'simplex_method.xml#level', -'simplex_method.xml#A', -'simplex_method.xml#b', -'simplex_method.xml#c', -'simplex_method.xml#maxitr', -'simplex_method.xml#xout', -'simplex_method.xml#ok', -'simplex_method.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-2018.00.00.0/doc/sin_cos_forward.xml cppad-2019.02.00.0/doc/sin_cos_forward.xml --- cppad-2018.00.00.0/doc/sin_cos_forward.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sin_cos_forward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,669 +0,0 @@ - - - -Trigonometric and Hyperbolic Sine and Cosine Forward Theory - - - - - - - - - - - - - - - - -
- -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/appendix/theory/sin_cos_forward.omh - - - diff -Nru cppad-2018.00.00.0/doc/_sin_cos_forward_xml.js cppad-2019.02.00.0/doc/_sin_cos_forward_xml.js --- cppad-2018.00.00.0/doc/_sin_cos_forward_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sin_cos_forward_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +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', -'sin_cos_forward.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/sin_cos_reverse.xml cppad-2019.02.00.0/doc/sin_cos_reverse.xml --- cppad-2018.00.00.0/doc/sin_cos_reverse.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sin_cos_reverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,749 +0,0 @@ - - - -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/appendix/theory/sin_cos_reverse.omh - - - diff -Nru cppad-2018.00.00.0/doc/_sin_cos_reverse_xml.js cppad-2019.02.00.0/doc/_sin_cos_reverse_xml.js --- cppad-2018.00.00.0/doc/_sin_cos_reverse_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sin_cos_reverse_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', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'sin_cos_reverse.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/sin.cpp.xml cppad-2019.02.00.0/doc/sin.cpp.xml --- cppad-2018.00.00.0/doc/sin.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/sin.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ - - - -The AD sin Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sin.cppHeadings

-
The AD sin Function: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cmath>
-
-bool Sin(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * 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);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::sin(x[0]);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     double check = std::sin(x0);
-     ok &= NearEqual(y[0] , check, eps99, eps99);
-
-     // 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::cos(x0);
-     ok   &= NearEqual(dy[0], check, eps99, eps99);
-
-     // 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, eps99, eps99);
-
-     // use a VecAD<Base>::reference object with sin
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero]           = x0;
-     AD<double> result = CppAD::sin(v[zero]);
-     check = std::sin(x0);
-     ok   &= NearEqual(result, check, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/sin.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sin.cpp_xml.js cppad-2019.02.00.0/doc/_sin.cpp_xml.js --- cppad-2018.00.00.0/doc/_sin.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sin.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'sin.xml', -'sin.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 = [ -'sin.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-2018.00.00.0/doc/sinh.cpp.xml cppad-2019.02.00.0/doc/sinh.cpp.xml --- cppad-2018.00.00.0/doc/sinh.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/sinh.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ - - - -The AD sinh Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sinh.cppHeadings

-
The AD sinh Function: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cmath>
-
-bool Sinh(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * 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);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::sinh(x[0]);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     double check = std::sinh(x0);
-     ok &= NearEqual(y[0] , check, eps99, eps99);
-
-     // 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::cosh(x0);
-     ok   &= NearEqual(dy[0], check, eps99, eps99);
-
-     // 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, eps99, eps99);
-
-     // use a VecAD<Base>::reference object with sinh
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero]           = x0;
-     AD<double> result = CppAD::sinh(v[zero]);
-     check = std::sinh(x0);
-     ok   &= NearEqual(result, check, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/sinh.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sinh.cpp_xml.js cppad-2019.02.00.0/doc/_sinh.cpp_xml.js --- cppad-2018.00.00.0/doc/_sinh.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sinh.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'sinh.xml', -'sinh.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 = [ -'sinh.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-2018.00.00.0/doc/sinh.xml cppad-2019.02.00.0/doc/sinh.xml --- cppad-2018.00.00.0/doc/sinh.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/sinh.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ - - - -The Hyperbolic Sine Function: sinh - - - - - - - - - - - - - - - - -
- -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_sinh_xml.js cppad-2019.02.00.0/doc/_sinh_xml.js --- cppad-2018.00.00.0/doc/_sinh_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sinh_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'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-2018.00.00.0/doc/sin.xml cppad-2019.02.00.0/doc/sin.xml --- cppad-2018.00.00.0/doc/sin.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/sin.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ - - - -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_sin_xml.js cppad-2019.02.00.0/doc/_sin_xml.js --- cppad-2018.00.00.0/doc/_sin_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sin_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'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-2018.00.00.0/doc/size_order.xml cppad-2019.02.00.0/doc/size_order.xml --- cppad-2018.00.00.0/doc/size_order.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/size_order.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,277 +0,0 @@ - - - -Number Taylor Coefficient Orders Currently Stored - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -size_order - -

-
Number Taylor Coefficient Orders Currently Stored
-
-Syntax - -
- -s = f.size_order() - - -
-
-See Also - -
-seq_property - - -
-
-Purpose -
-Determine the number of Taylor coefficient orders, per variable,direction, -currently calculated and stored in the ADFun object -f -. -See the discussion under -Constructor -, -Forward -, and -capacity_order - -for a description of when this value can change. - - -
-
-f -
-The object -f - has prototype - -
-     const ADFun<
Basef
-
-
-s -
-The result -s - has prototype - -
-     size_t 
s
-
-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 -. - -
-
-Constructor -
-Directly after the FunConstruct - syntax - -
-     ADFun<
Basef(xy)
-
-the value of -s - returned by size_order is one. -This is because -there is an implicit call to Forward that computes -the zero order Taylor coefficients during this constructor. - -
-
-Forward -
-After a call to Forward - with the syntax - -
-        
f.Forward(qx_q)
-
-the value of -s - returned by size_order -would be - -q -+ -1 - - -. -The call to Forward above -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 -. -Thus there are - -q -+ -1 - - - (order zero through -q -) -Taylor coefficients per variable,direction. -(You can determine the number of variables in the operation sequence -using the size_var - function.) - -
-
-capacity_order -
-If the number of Taylor coefficient orders -currently stored in -f - is less than or equal -c -, -a call to capacity_order - with the syntax - -
-     
f.capacity_order(c)
-
-does not affect the value -s - returned by size_order. -Otherwise, -the value -s - returned by size_order -is equal to -c - -(only Taylor coefficients of order zero through - -c --1 - - - -have been retained). - -
-
-Example -
-The file -forward.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: omh/forward/size_order.omh - - - diff -Nru cppad-2018.00.00.0/doc/_size_order_xml.js cppad-2019.02.00.0/doc/_size_order_xml.js --- cppad-2018.00.00.0/doc/_size_order_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_size_order_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'forward.xml', -'size_order.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'forward_zero.xml', -'forward_one.xml', -'forward_two.xml', -'forward_order.xml', -'forward_dir.xml', -'size_order.xml', -'compare_change.xml', -'capacity_order.xml', -'number_skip.xml' -]; -var list_current0 = [ -'size_order.xml#Syntax', -'size_order.xml#Syntax.See Also', -'size_order.xml#Purpose', -'size_order.xml#f', -'size_order.xml#s', -'size_order.xml#Constructor', -'size_order.xml#Forward', -'size_order.xml#capacity_order', -'size_order.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-2018.00.00.0/doc/sparse_derivative.xml cppad-2019.02.00.0/doc/sparse_derivative.xml --- cppad-2018.00.00.0/doc/sparse_derivative.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_derivative.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,133 +0,0 @@ - - - -Calculating Sparse Derivatives - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Calculating Sparse Derivatives
-
-Preferred Sparsity Patterns - - - - - -
- -sparse_jac -Computing Sparse Jacobians
- -sparse_hes -Computing Sparse Hessians
- -subgraph_jac_rev -Compute Sparse Jacobians Using Subgraphs
- -
-
-Old Sparsity Patterns - - - - -
- -sparse_jacobian -Sparse Jacobian
- -sparse_hessian -Sparse Hessian
- -
- -
Input File: omh/adfun.omh - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_derivative_xml.js cppad-2019.02.00.0/doc/_sparse_derivative_xml.js --- cppad-2018.00.00.0/doc/_sparse_derivative_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_derivative_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', -'adfun.xml', -'sparse_derivative.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down0 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_current0 = [ -'sparse_derivative.xml#Preferred Sparsity Patterns', -'sparse_derivative.xml#Old Sparsity Patterns' -]; -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-2018.00.00.0/doc/sparse_hes.cpp.xml cppad-2019.02.00.0/doc/sparse_hes.cpp.xml --- cppad-2018.00.00.0/doc/sparse_hes.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_hes.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,171 +0,0 @@ - - - -Computing Sparse Hessian: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sparse_hes.cppHeadings

- - - -
Computing Sparse Hessian: Example and Test
-
# include <cppad/cppad.hpp>
-bool sparse_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_TESTVECTOR(size_t)                   s_vector;
-     typedef CPPAD_TESTVECTOR(bool)                     b_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] = a_x[0] * a_x[1];
-     for(size_t j = 0; j < n; j++)
-          a_y[0] += a_x[j] * 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);
-     //
-     // new value for the independent variable vector, and weighting vector
-     d_vector w(m), x(n);
-     for(size_t j = 0; j < n; j++)
-          x[j] = double(j);
-     w[0] = 1.0;
-     //
-     // vector used to check the value of the hessian
-     d_vector check(n * n);
-     size_t ij  = 0 * n + 1;
-     for(ij = 0; ij < n * n; ij++)
-          check[ij] = 0.0;
-     ij         = 0 * n + 1;
-     check[ij]  = 1.0;
-     ij         = 1 * n + 0;
-     check[ij]  = 1.0 ;
-     for(size_t j = 0; j < n; j++)
-     {     ij = j * n + j;
-          check[ij] = 6.0 * x[j];
-     }
-     //
-     // compute Hessian sparsity pattern
-     b_vector select_domain(n), select_range(m);
-     for(size_t j = 0; j < n; j++)
-          select_domain[j] = true;
-     select_range[0] = true;
-     //
-     CppAD::sparse_rc<s_vector> hes_pattern;
-     bool internal_bool = false;
-     f.for_hes_sparsity(
-          select_domain, select_range, internal_bool, hes_pattern
-     );
-     //
-     // compute entire sparse Hessian (really only need lower triangle)
-     CppAD::sparse_rcv<s_vector, d_vector> subset( hes_pattern );
-     CppAD::sparse_hes_work work;
-     std::string coloring = "cppad.symmetric";
-     size_t n_sweep = f.sparse_hes(x, w, subset, hes_pattern, coloring, work);
-     ok &= n_sweep == 2;
-     //
-     const s_vector row( subset.row() );
-     const s_vector col( subset.col() );
-     const d_vector val( subset.val() );
-     size_t nnz = subset.nnz();
-     ok &= nnz == n + 2;
-     for(size_t k = 0; k < nnz; k++)
-     {     ij = row[k] * n + col[k];
-          ok &= val[k] == check[ij];
-     }
-     return ok;
-}
-
-
Input File: example/sparse/sparse_hes.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_hes.cpp_xml.js cppad-2019.02.00.0/doc/_sparse_hes.cpp_xml.js --- cppad-2018.00.00.0/doc/_sparse_hes.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_hes.cpp_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', -'adfun.xml', -'sparse_derivative.xml', -'sparse_hes.xml', -'sparse_hes.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_down1 = [ -'sparse_hes.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-2018.00.00.0/doc/sparse_hes_fun.cpp.xml cppad-2019.02.00.0/doc/sparse_hes_fun.cpp.xml --- cppad-2018.00.00.0/doc/sparse_hes_fun.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_hes_fun.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ - - - -sparse_hes_fun: Example and test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sparse_hes_fun.cppHeadings

- - - - -
sparse_hes_fun: Example and test
-
# include <cppad/speed/sparse_hes_fun.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/cppad.hpp>
-
-bool sparse_hes_fun(void)
-{     using CppAD::NearEqual;
-     bool ok = true;
-
-     typedef CppAD::AD<double> ADScalar;
-
-     size_t j, k;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-     size_t n   = 5;
-     size_t m   = 1;
-     size_t K   = 2 * n;
-     CppAD::vector<size_t>       row(K),  col(K);
-     CppAD::vector<double>       x(n),    ypp(K);
-     CppAD::vector<ADScalar>     a_x(n),  a_y(m);
-
-     // choose x
-     for(j = 0; j < n; j++)
-          a_x[j] = x[j] = double(j + 1);
-
-     // choose row, col
-     for(k = 0; k < K; k++)
-     {     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
-     Independent(a_x);
-
-     // evaluate function
-     size_t order = 0;
-     CppAD::sparse_hes_fun<ADScalar>(n, a_x, row, col, order, a_y);
-
-     // evaluate Hessian
-     order = 2;
-     CppAD::sparse_hes_fun<double>(n, x, row, col, order, ypp);
-
-     // use AD to evaluate Hessian
-     CppAD::ADFun<double>   f(a_x, a_y);
-     CppAD::vector<double>  hes(n * n);
-     // compoute Hessian of f_0 (x)
-     hes = f.Hessian(x, 0);
-
-     for(k = 0; k < K; k++)
-     {     size_t index = row[k] * n + col[k];
-          ok &= NearEqual(hes[index], ypp[k] , eps, eps);
-     }
-     return ok;
-}
-
-
Input File: speed/example/sparse_hes_fun.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_hes_fun.cpp_xml.js cppad-2019.02.00.0/doc/_sparse_hes_fun.cpp_xml.js --- cppad-2018.00.00.0/doc/_sparse_hes_fun.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_hes_fun.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'sparse_hes_fun.xml', -'sparse_hes_fun.cpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'sparse_hes_fun.cpp.xml', -'sparse_hes_fun.hpp.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-2018.00.00.0/doc/sparse_hes_fun.hpp.xml cppad-2019.02.00.0/doc/sparse_hes_fun.hpp.xml --- cppad-2018.00.00.0/doc/sparse_hes_fun.hpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_hes_fun.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,192 +0,0 @@ - - - -Source: sparse_hes_fun - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sparse_hes_fun.hppHeadings

-
Source: sparse_hes_fun
-# ifndef CPPAD_SPARSE_HES_FUN_HPP -
-
# define CPPAD_SPARSE_HES_FUN_HPP - -
# include <cppad/core/cppad_assert.hpp>
-# include <cppad/utility/check_numeric_type.hpp>
-# include <cppad/utility/vector.hpp>
-
-// following needed by gcc under fedora 17 so that exp(double) is defined
-# include <cppad/base_require.hpp>
-
-namespace CppAD {
-     template <class Float, class FloatVector>
-     void sparse_hes_fun(
-          size_t                       n    ,
-          const FloatVector&           x    ,
-          const CppAD::vector<size_t>& row  ,
-          const CppAD::vector<size_t>& col  ,
-          size_t                       p    ,
-          FloatVector&                fp    )
-     {
-          // check numeric type specifications
-          CheckNumericType<Float>();
-
-          // check value of p
-          CPPAD_ASSERT_KNOWN(
-               p == 0 || p == 2,
-               "sparse_hes_fun: p != 0 and p != 2"
-          );
-
-          size_t K = row.size();
-          size_t i, j, k;
-          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<size_t> 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<Float> 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);
-               }
-          }
-
-          Float t;
-          for(k = 0; k < K; k++)
-          {     i    = row[k];
-               j    = col[k];
-               t    = exp( x[i] * x[j] );
-               switch(p)
-               {
-                    case 0:
-                    fp[0] += t;
-                    break;
-
-                    case 2:
-                    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;
-               }
-          }
-
-     }
-}
-# endif -
- - -
Input File: omh/sparse_hes_fun.omh - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_hes_fun.hpp_xml.js cppad-2019.02.00.0/doc/_sparse_hes_fun.hpp_xml.js --- cppad-2018.00.00.0/doc/_sparse_hes_fun.hpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_hes_fun.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'sparse_hes_fun.xml', -'sparse_hes_fun.hpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'sparse_hes_fun.cpp.xml', -'sparse_hes_fun.hpp.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-2018.00.00.0/doc/sparse_hes_fun.xml cppad-2019.02.00.0/doc/sparse_hes_fun.xml --- cppad-2018.00.00.0/doc/sparse_hes_fun.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_hes_fun.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,644 +0,0 @@ - - - -Evaluate a Function That Has a Sparse Hessian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Evaluate a Function That Has a Sparse Hessian
-
-Syntax - -
- -# include <cppad/speed/sparse_hes_fun.hpp>
-
- -sparse_hes_fun(nxrowcolpfp) - - -
-
-Purpose -
-This routine evaluates - - -f -( -x -) - - -, - -f -( -1 -) - - -( -x -) - - -, or - -f -( -2 -) - - -( -x -) - - - -where the Hessian - -f -( -2 -) - - -( -x -) - - - is sparse. -The function - -f -: -R - -n - - -R - - - - only depends on the -size and contents of the index vectors -row - and -col -. -The non-zero entries in the Hessian of this function have -one of the following forms: - - - -2 - -f - - -x -[ -row -[ -k -] -] - -x -[ -row -[ -k -] -] - - - -, - - -2 - -f - - -x -[ -row -[ -k -] -] - -x -[ -col -[ -k -] -] - - - -, - - -2 - -f - - -x -[ -col -[ -k -] -] - -x -[ -row -[ -k -] -] - - - -, - - -2 - -f - - -x -[ -col -[ -k -] -] - -x -[ -col -[ -k -] -] - - - - -for some - -k - - - between zero and - -K --1 - - -. -All the other terms of the Hessian are zero. - -
-
-Inclusion -
-The template function sparse_hes_fun -is defined in the CppAD namespace by including -the file cppad/speed/sparse_hes_fun.hpp -(relative to the CppAD distribution directory). - -
-
-Float -
-The type -Float - must be a NumericType -. -In addition, if -y - and -z - are -Float - objects, - -
-     
y = exp(z)
-
-must set the -y - equal the exponential of -z -, i.e., -the derivative of -y - with respect to -z - is equal to -y -. - -
-
-FloatVector -
-The type -FloatVector - is any -SimpleVector -, or it can be a raw pointer, -with elements of type -Float -. - -
-
-n -
-The argument -n - has prototype - -
-     size_t 
n
-
-It specifies the dimension for the domain space for - -f -( -x -) - - -. - -
-
-x -
-The argument -x - has prototype - -
-     const 
FloatVectorx
-
-It contains the argument value for which the function, -or its derivative, is being evaluated. -We use - -n - - - to denote the size of the vector -x -. - -
-
-row -
-The argument -row - has prototype - -
-      const CppAD::vector<size_t>& 
row
-
-It specifies one of the first -index of - -x - - - for each non-zero Hessian term -(see purpose - above). -All the elements of -row - must be between zero and -n-1 -. -The value - -K - - - is defined by -K = row.size() -. - -
-
-col -
-The argument -col - has prototype - -
-      const CppAD::vector<size_t>& 
col
-
-and its size must be - -K - - -; i.e., the same as for -col -. -It specifies the second -index of - -x - - - for the non-zero Hessian terms. -All the elements of -col - must be between zero and -n-1 -. -There are no duplicated entries requested, to be specific, -if -k1 != k2 - then - -
-     ( 
row[k1] , col[k1] ) != ( row[k2] , col[k2] )
-
-
-p -
-The argument -p - has prototype - -
-     size_t 
p
-
-It is either zero or two and -specifies the order of the derivative of - -f - - - -that is being evaluated, i.e., - -f -( -p -) - - -( -x -) - - - is evaluated. - -
-
-fp -
-The argument -fp - has prototype - -
-     
FloatVectorfp
-
-The input value of the elements of -fp - does not matter. - -
-
-Function -
-If -p - is zero, -fp - has size one and - -fp[0] - is the value of - -f -( -x -) - - -. - -
-
-Hessian -
-If -p - is two, -fp - has size -K - and -for - -k -= -0 -, - -, -K --1 - - -, - - - -2 - -f - - -x -[ -row - -[ -k -] -] - -x -[ -col - -[ -k -] -] - - -= -fp -[ -k -] - - -
-Example -
-The file -sparse_hes_fun.cpp - -contains an example and test of sparse_hes_fun.hpp. -It returns true if it succeeds and false otherwise. - -
-
-Source Code -
-The file -sparse_hes_fun.hpp - -contains the source code for this template function. - - -
Input File: cppad/speed/sparse_hes_fun.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_hes_fun_xml.js cppad-2019.02.00.0/doc/_sparse_hes_fun_xml.js --- cppad-2018.00.00.0/doc/_sparse_hes_fun_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_hes_fun_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'sparse_hes_fun.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down0 = [ -'sparse_hes_fun.cpp.xml', -'sparse_hes_fun.hpp.xml' -]; -var list_current0 = [ -'sparse_hes_fun.xml#Syntax', -'sparse_hes_fun.xml#Purpose', -'sparse_hes_fun.xml#Inclusion', -'sparse_hes_fun.xml#Float', -'sparse_hes_fun.xml#FloatVector', -'sparse_hes_fun.xml#n', -'sparse_hes_fun.xml#x', -'sparse_hes_fun.xml#row', -'sparse_hes_fun.xml#col', -'sparse_hes_fun.xml#p', -'sparse_hes_fun.xml#fp', -'sparse_hes_fun.xml#fp.Function', -'sparse_hes_fun.xml#fp.Hessian', -'sparse_hes_fun.xml#Example', -'sparse_hes_fun.xml#Source Code' -]; -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-2018.00.00.0/doc/sparse_hessian.cpp.xml cppad-2019.02.00.0/doc/sparse_hessian.cpp.xml --- cppad-2018.00.00.0/doc/sparse_hessian.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_hessian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,233 +0,0 @@ - - - -Sparse Hessian: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sparse_hessian.cppHeadings

- - - -
Sparse Hessian: Example and Test
-
# include <cppad/cppad.hpp>
-bool sparse_hessian(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     size_t i, j, k, ell;
-     typedef CPPAD_TESTVECTOR(AD<double>)               a_vector;
-     typedef CPPAD_TESTVECTOR(double)                     d_vector;
-     typedef CPPAD_TESTVECTOR(size_t)                     i_vector;
-     typedef CPPAD_TESTVECTOR(bool)                       b_vector;
-     typedef CPPAD_TESTVECTOR(std::set<size_t>)         s_vector;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n = 12;  // must be greater than or equal 3; see n_sweep below
-     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);
-
-     // range space vector
-     size_t m = 1;
-     a_vector a_y(m);
-     a_y[0] = a_x[0]*a_x[1];
-     for(j = 0; j < n; j++)
-          a_y[0] += a_x[j] * 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);
-
-     // new value for the independent variable vector, and weighting vector
-     d_vector w(m), x(n);
-     for(j = 0; j < n; j++)
-          x[j] = double(j);
-     w[0] = 1.0;
-
-     // vector used to check the value of the hessian
-     d_vector check(n * n);
-     for(ell = 0; ell < n * n; ell++)
-          check[ell] = 0.0;
-     ell        = 0 * n + 1;
-     check[ell] = 1.0;
-     ell        = 1 * n + 0;
-     check[ell] = 1.0 ;
-     for(j = 0; j < n; j++)
-     {     ell = j * n + j;
-          check[ell] = 6.0 * x[j];
-     }
-
-     // -------------------------------------------------------------------
-     // second derivative of y[0] w.r.t x
-     d_vector hes(n * n);
-     hes = f.SparseHessian(x, w);
-     for(ell = 0; ell < n * n; ell++)
-          ok &=  NearEqual(w[0] * check[ell], hes[ell], eps, eps );
-
-     // --------------------------------------------------------------------
-     // example using vectors of bools to compute sparsity pattern for Hessian
-     b_vector r_bool(n * n);
-     for(i = 0; i < n; i++)
-     {     for(j = 0; j < n; j++)
-               r_bool[i * n + j] = false;
-          r_bool[i * n + i] = true;
-     }
-     f.ForSparseJac(n, r_bool);
-     //
-     b_vector s_bool(m);
-     for(i = 0; i < m; i++)
-          s_bool[i] = w[i] != 0;
-     b_vector p_bool = f.RevSparseHes(n, s_bool);
-
-     hes = f.SparseHessian(x, w, p_bool);
-     for(ell = 0; ell < n * n; ell++)
-          ok &=  NearEqual(w[0] * check[ell], hes[ell], eps, eps );
-
-     // --------------------------------------------------------------------
-     // example using vectors of sets to compute sparsity pattern for Hessian
-     s_vector r_set(n);
-     for(i = 0; i < n; i++)
-          r_set[i].insert(i);
-     f.ForSparseJac(n, r_set);
-     //
-     s_vector s_set(m);
-     for(i = 0; i < m; i++)
-          if( w[i] != 0. )
-               s_set[0].insert(i);
-     s_vector p_set = f.RevSparseHes(n, s_set);
-
-     // example passing sparsity pattern to SparseHessian
-     hes = f.SparseHessian(x, w, p_set);
-     for(ell = 0; ell < n * n; ell++)
-          ok &=  NearEqual(w[0] * check[ell], hes[ell], eps, eps );
-
-     // --------------------------------------------------------------------
-     // use row and column indices to specify upper triangle of
-     // non-zero elements of Hessian
-     size_t K = n + 1;
-     i_vector row(K), col(K);
-     hes.resize(K);
-     k = 0;
-     for(j = 0; j < n; j++)
-     {     // diagonal of Hessian
-          row[k] = j;
-          col[k] = j;
-          k++;
-     }
-     // only off diagonal non-zero elemenet in upper triangle
-     row[k] = 0;
-     col[k] = 1;
-     k++;
-     ok &= k == K;
-     CppAD::sparse_hessian_work work;
-
-     // can use p_set or p_bool.
-     size_t n_sweep = f.SparseHessian(x, w, p_set, 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;
-
-     // now recompute at a different x and w (using work from previous call
-     w[0]       = 2.0;
-     x[1]       = 0.5;
-     ell        = 1 * n + 1;
-     check[ell] = 6.0 * x[1];
-     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;
-}
-
-
Input File: example/sparse/sparse_hessian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_hessian.cpp_xml.js cppad-2019.02.00.0/doc/_sparse_hessian.cpp_xml.js --- cppad-2018.00.00.0/doc/_sparse_hessian.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_hessian.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparse_derivative.xml', -'sparse_hessian.xml', -'sparse_hessian.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_down1 = [ -'sparse_hessian.cpp.xml', -'sub_sparse_hes.cpp.xml', -'sparse_sub_hes.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-2018.00.00.0/doc/sparse_hessian.xml cppad-2019.02.00.0/doc/sparse_hessian.xml --- cppad-2018.00.00.0/doc/sparse_hessian.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_hessian.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,932 +0,0 @@ - - - -Sparse Hessian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Sparse Hessian
-
-Syntax - -
- -hes = f.SparseHessian(xw)
-
hes = f.SparseHessian(xwp)
-
n_sweep = f.SparseHessian(xwprowcolheswork)
-
-
-Purpose -
-We use - -n - - - for the domain - size, -and - -m - - - for the range - size of -f -. -We use - -F -: -R - -n - - -R - -m - - - - do denote the -AD function - -corresponding to -f -. -The syntax above sets -hes - to the Hessian - - -H -( -x -) -= -d - -2 - - - -d - - -x - -2 - - - - - -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. -If -row - and -col - are present, it also takes -advantage of the reduced set of elements of the Hessian that -need to be computed. -One can use speed tests (e.g. speed_test -) -to verify that results are computed faster -than when using the routine Hessian -. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const -(see Uses Forward - below). - -
-
-x -
-The argument -x - has prototype - -
-     const 
VectorBasex
-
-(see VectorBase - below) -and its size -must be equal to -n -, the dimension of the -domain - space for -f -. -It specifies -that point at which to evaluate the Hessian. - -
-
-w -
-The argument -w - has prototype - -
-     const 
VectorBasew
-
-and size - -m - - -. -It specifies the value of - -w -i - - - - in the expression -for -hes -. -The more components of - -w - - - that are identically zero, -the more sparse the resulting Hessian may be (and hence the more efficient -the calculation of -hes - may be). - -
-
-p -
-The argument -p - is optional and has prototype - -
-     const 
VectorSetp
-
-(see VectorSet - below) -If it has elements of type bool, -its size is - -n -* -n - - -. -If it has elements of type std::set<size_t>, -its size is - -n - - - and all its set elements are between -zero and - -n -- -1 - - -. -It specifies a -sparsity pattern - -for the Hessian - -H -( -x -) - - -. - -
-
-Purpose -
-If this sparsity pattern does not change between calls to - -SparseHessian -, it should be faster to calculate -p - once and -pass this argument to -SparseHessian -. -If you specify -p -, CppAD will use the same -type of sparsity representation -(vectors of bool or vectors of std::set<size_t>) -for its internal calculations. -Otherwise, the representation -for the internal calculations is unspecified. - -
-
-work -
-If you specify -work - in the calling sequence, -it is not necessary to keep the sparsity pattern; see the heading -p - under the -work - description. - -
-
-Column Subset -
-If the arguments -row - and -col - are present, -and color_method - is -cppad.general or cppad.symmetric, -it is not necessary to compute the entire sparsity pattern. -Only the following subset of column values will matter: - -
-     { 
col[k] : k = 0 , ... , K-1 }
-
-. - - -
-
-row, col -
-The arguments -row - and -col - are optional and have prototype - -
-     const 
VectorSizerow
-     const 
VectorSizecol
-
-(see VectorSize - below). -They specify which rows and columns of - -H -( -x -) - - - are -returned and in what order. -We use - -K - - - to denote the value -hes.size() - -which must also equal the size of -row - and -col -. -Furthermore, -for - -k -= -0 -, - -, -K --1 - - -, it must hold that - - -row -[ -k -] -< -n - - - and - -col -[ -k -] -< -n - - -. -In addition, -all of the - -( -row -[ -k -] -, -col -[ -k -] -) - - - pairs must correspond to a true value -in the sparsity pattern -p -. - -
-
-hes -
-The result -hes - has prototype - -
-     
VectorBase hes
-
-In the case where -row - and -col - are not present, -the size of -hes - is - -n -* -n - - - and -its size is - -n -* -n - - -. -In this case, for - -i -= -0 -, - -, -n -- -1 - - - -and - -ell -= -0 -, - -, -n -- -1 - - - - - -hes -[ -j -* -n -+ - -] -= - -2 - -w -T - - -F - - -x -j - - -x - - - - -( -x -) - - -
-
-
In the case where the arguments -row - and -col - are present, -we use - -K - - - to denote the size of -hes -. -The input value of its elements does not matter. -Upon return, for - -k -= -0 -, - -, -K -- -1 - - -, - - -hes -[ -k -] -= - -2 - -w -T - - -F - - -x -j - - -x - - - - -( -x -) - -, - - -where - - -j -= -row -[ -k -] - -and - - - -= -col -[ -k -] - - -
-work -
-If this argument is present, it has prototype - -
-     sparse_hessian_work& 
work
-
-This object can only be used with the routines SparseHessian. -During its the first use, information is stored in -work -. -This is used to reduce the work done by future calls to SparseHessian -with the same -f -, -p -, -row -, and -col -. -If a future call is made where any of these values have changed, -you must first call -work.clear() - -to inform CppAD that this information needs to be recomputed. - -
-
-color_method -
-The coloring algorithm determines which rows and columns -can be computed during the same sweep. -This field has prototype - -
-     std::string 
work.color_method
-
-This value only matters on the first call to sparse_hessian that -follows the -work - constructor or a call to - -work.clear() -. - -
-
-"cppad.symmetric"
-
-This is the default coloring method (after a constructor or clear()). -It takes advantage of the fact that the Hessian matrix -is symmetric to find a coloring that requires fewer -sweeps -. - -
-
-"cppad.general"
-
-This is the same as the "cppad" method for the -sparse_jacobian - calculation. - -
-
-"colpack.symmetric"
-
-This method requires that -colpack_prefix - was specified on the -cmake command - line. -It also takes advantage of the fact that the Hessian matrix is symmetric. - -
-
-"colpack.general"
-
-This is the same as the "colpack" method for the -sparse_jacobian - calculation. - -
-
-colpack.star Deprecated 2017-06-01 -
-The colpack.star method is deprecated. -It is the same as the colpack.symmetric -which should be used instead. - -
-
-p -
-If -work - is present, and it is not the first call after -its construction or a clear, -the sparsity pattern -p - is not used. -This enables one to free the sparsity pattern -and still compute corresponding sparse Hessians. - -
-
-n_sweep -
-The return value -n_sweep - has prototype - -
-     size_t 
n_sweep
-
-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 -so it is also the number of reverse sweeps. -This is proportional to the total work that SparseHessian does, -not counting the zero order forward sweep, -or the work to combine multiple columns into a single -forward-reverse sweep pair. - -
-
-VectorBase -
-The type -VectorBase - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-VectorSet -
-The type -VectorSet - must be a SimpleVector - class with -elements of type - -bool or std::set<size_t>; -see sparsity pattern - for a discussion -of the difference. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Restrictions -
-If -VectorSet - has elements of std::set<size_t>, -then -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, -std::valarray< std::set<size_t> > does not satisfy -this condition. - -
-
-VectorSize -
-The type -VectorSize - must be a SimpleVector - class with -elements of type - -size_t. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Uses Forward -
-After each call to Forward -, -the object -f - contains the corresponding -Taylor coefficients -. -After a call to any of the sparse Hessian routines, -the zero order Taylor coefficients correspond to - -f.Forward(0, x) - -and the other coefficients are unspecified. - - - -
-
-Example -
-The routine -sparse_hessian.cpp - -is examples and tests of sparse_hessian. -It return true, if it succeeds and false otherwise. - -
-
-Subset Hessian -
-The routine -sub_sparse_hes.cpp - -is an example and test that compute a sparse Hessian -for a subset of the variables. -It returns true, for success, and false otherwise. - - -
Input File: cppad/core/sparse_hessian.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_hessian_xml.js cppad-2019.02.00.0/doc/_sparse_hessian_xml.js --- cppad-2018.00.00.0/doc/_sparse_hessian_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_hessian_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparse_derivative.xml', -'sparse_hessian.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_down0 = [ -'sparse_hessian.cpp.xml', -'sub_sparse_hes.cpp.xml', -'sparse_sub_hes.cpp.xml' -]; -var list_current0 = [ -'sparse_hessian.xml#Syntax', -'sparse_hessian.xml#Purpose', -'sparse_hessian.xml#f', -'sparse_hessian.xml#x', -'sparse_hessian.xml#w', -'sparse_hessian.xml#p', -'sparse_hessian.xml#p.Purpose', -'sparse_hessian.xml#p.work', -'sparse_hessian.xml#p.Column Subset', -'sparse_hessian.xml#row, col', -'sparse_hessian.xml#hes', -'sparse_hessian.xml#work', -'sparse_hessian.xml#work.color_method', -'sparse_hessian.xml#work.colpack.star Deprecated 2017-06-01', -'sparse_hessian.xml#work.p', -'sparse_hessian.xml#n_sweep', -'sparse_hessian.xml#VectorBase', -'sparse_hessian.xml#VectorSet', -'sparse_hessian.xml#VectorSet.Restrictions', -'sparse_hessian.xml#VectorSize', -'sparse_hessian.xml#Uses Forward', -'sparse_hessian.xml#Example', -'sparse_hessian.xml#Subset Hessian' -]; -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-2018.00.00.0/doc/sparse_hes.xml cppad-2019.02.00.0/doc/sparse_hes.xml --- cppad-2018.00.00.0/doc/sparse_hes.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_hes.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,632 +0,0 @@ - - - -Computing Sparse Hessians - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Computing Sparse Hessians
-
-Syntax - -
- -n_sweep = f.sparse_hes(
-     
xwsubsetpatterncoloringwork
-)
- - -
-
-Purpose -
-We use - -F -: -R - -n - - -R - -m - - - - to denote the -function corresponding to -f -. -Here -n - is the domain - size, -and -m - is the range - size, or -f -. -The syntax above takes advantage of sparsity when computing the Hessian - - -H -( -x -) -= -d - -2 - - - -d - - -x - -2 - - - - - -i -= -0 - -m --1 - - -w -i - -F -i - -( -x -) - - -In the sparse case, this should be faster and take less memory than -Hessian -. -The matrix element - -H -i -, -j - - -( -x -) - - - is the second partial of - - -w -T - - -F -( -x -) - - - with respect to - -x -i - - - - and - -x -j - - - -. - -
-
-SizeVector -
-The type -SizeVector - is a SimpleVector - class with -elements of type - -size_t. - -
-
-BaseVector -
-The type -BaseVector - is a SimpleVector - class with -elements of type - -size_t. - -
-
-f -
-This object has prototype - -
-     ADFun<
Basef
-
-Note that the Taylor coefficients stored in -f - are affected -by this operation; see -uses forward - below. - -
-
-x -
-This argument has prototype - -
-     const 
BaseVectorx
-
-and its size is -n -. -It specifies the point at which to evaluate the Hessian - - -H -( -x -) - - -. - -
-
-w -
-This argument has prototype - -
-     const 
BaseVectorw
-
-and its size is -m -. -It specifies the weight for each of the components of - -F -( -x -) - - -; -i.e. - -w -i - - - - is the weight for - -F -i - -( -x -) - - -. - -
-
-subset -
-This argument has prototype - -
-     sparse_rcv<
SizeVectorBaseVector>& subset
-
-Its row size and column size is -n -; i.e., - -subset.nr() == n - and -subset.nc() == n -. -It specifies which elements of the Hessian are computed. -
  1. -The input value of its value vector - -subset.val() - does not matter. -Upon return it contains the value of the corresponding elements -of the Hessian. -
  2. - -All of the row, column pairs in -subset - must also appear in - -pattern -; i.e., they must be possibly non-zero. -
  3. - -The Hessian is symmetric, so one has a choice as to which off diagonal -elements to put in -subset -. -It will probably be more efficient if one makes this choice so that -the there are more entries in each non-zero column of -subset -; -see n_sweep - below. -
- - -
-
-pattern -
-This argument has prototype - -
-     const sparse_rc<
SizeVector>& pattern
-
-Its row size and column size is -n -; i.e., - -pattern.nr() == n - and -pattern.nc() == n -. -It is a sparsity pattern for the Hessian - -H -( -x -) - - -. -If the i-th row (j-th column) does not appear in -subset -, -the i-th row (j-th column) of -pattern - does not matter -and need not be computed. -This argument is not used (and need not satisfy any conditions), -when work - is non-empty. - -
-
-subset -
-If the i-th row and i-th column do not appear in -subset -, -the i-th row and column of -pattern - do not matter. -In this case the i-th-th row and column may have no entries in - -pattern - even though they are possibly non-zero in - -H -( -x -) - - -. -(This can be used to reduce the amount of computation required to find - -pattern -.) - -
-
-coloring -
-The coloring algorithm determines which rows and columns -can be computed during the same sweep. -This field has prototype - -
-     const std::string& 
coloring
-
-This value only matters when work is empty; i.e., -after the -work - constructor or -work.clear() -. - -
-
-cppad.symmetric -
-This coloring takes advantage of the fact that the Hessian matrix -is symmetric when find a coloring that requires fewer -sweeps -. - -
-
-cppad.general -
-This is the same as the sparse Jacobian -cppad - method -which does not take advantage of symmetry. - -
-
-colpack.symmetric -
-If colpack_prefix - was specified on the -cmake command - line, -you can set -coloring - to colpack.symmetric. -This also takes advantage of the fact that the Hessian matrix is symmetric. - -
-
-colpack.general -
-If colpack_prefix - was specified on the -cmake command - line, -you can set -coloring - to colpack.general. -This is the same as the sparse Jacobian -colpack - method -which does not take advantage of symmetry. - -
-
-colpack.star Deprecated 2017-06-01 -
-The colpack.star method is deprecated. -It is the same as the colpack.symmetric method -which should be used instead. - - -
-
-work -
-This argument has prototype - -
-     sparse_hes_work& 
work
-
-We refer to its initial value, -and its value after -work.clear() -, as empty. -If it is empty, information is stored in -work -. -This can be used to reduce computation when -a future call is for the same object -f -, -and the same subset of the Hessian. -If either of these values change, use -work.clear() - to -empty this structure. - -
-
-n_sweep -
-The return value -n_sweep - has prototype - -
-     size_t 
n_sweep
-
-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 -so it is also the number of reverse sweeps. -It is also the number of colors determined by the coloring method -mentioned above. -This is proportional to the total computational work, -not counting the zero order forward sweep, -or combining multiple columns and rows into a single sweep. - -
-
-Uses Forward -
-After each call to Forward -, -the object -f - contains the corresponding -Taylor coefficients -. -After a call to sparse_hes -the zero order coefficients correspond to - -
-     
f.Forward(0, x)
-
-All the other forward mode coefficients are unspecified. - -
-
-Example - -
-The files sparse_hes.cpp - -is an example and test of sparse_hes. -It returns true, if it succeeds, and false otherwise. - -
-
-Subset Hessian -
-The routine -sparse_sub_hes.cpp - -is an example and test that compute a subset of a sparse Hessian. -It returns true, for success, and false otherwise. - - -
Input File: cppad/core/sparse_hes.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_hes_xml.js cppad-2019.02.00.0/doc/_sparse_hes_xml.js --- cppad-2018.00.00.0/doc/_sparse_hes_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_hes_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparse_derivative.xml', -'sparse_hes.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_down0 = [ -'sparse_hes.cpp.xml' -]; -var list_current0 = [ -'sparse_hes.xml#Syntax', -'sparse_hes.xml#Purpose', -'sparse_hes.xml#SizeVector', -'sparse_hes.xml#BaseVector', -'sparse_hes.xml#f', -'sparse_hes.xml#x', -'sparse_hes.xml#w', -'sparse_hes.xml#subset', -'sparse_hes.xml#pattern', -'sparse_hes.xml#pattern.subset', -'sparse_hes.xml#coloring', -'sparse_hes.xml#coloring.cppad.symmetric', -'sparse_hes.xml#coloring.cppad.general', -'sparse_hes.xml#coloring.colpack.symmetric', -'sparse_hes.xml#coloring.colpack.general', -'sparse_hes.xml#coloring.colpack.star Deprecated 2017-06-01', -'sparse_hes.xml#work', -'sparse_hes.xml#n_sweep', -'sparse_hes.xml#Uses Forward', -'sparse_hes.xml#Example', -'sparse_hes.xml#Subset Hessian' -]; -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-2018.00.00.0/doc/sparse_jac_for.cpp.xml cppad-2019.02.00.0/doc/sparse_jac_for.cpp.xml --- cppad-2018.00.00.0/doc/sparse_jac_for.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_jac_for.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,219 +0,0 @@ - - - -Computing Sparse Jacobian Using Forward Mode: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sparse_jac_for.cppHeadings

- - - -
Computing Sparse Jacobian Using Forward Mode: Example and Test
-
# include <cppad/cppad.hpp>
-bool sparse_jac_for(void)
-{     bool ok = true;
-     //
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     using CppAD::sparse_rc;
-     using CppAD::sparse_rcv;
-     //
-     typedef CPPAD_TESTVECTOR(AD<double>) a_vector;
-     typedef CPPAD_TESTVECTOR(double)     d_vector;
-     typedef CPPAD_TESTVECTOR(size_t)     s_vector;
-     //
-     // domain space vector
-     size_t n = 3;
-     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);
-     //
-     size_t m = 4;
-     a_vector  a_y(m);
-     a_y[0] = a_x[0] + a_x[2];
-     a_y[1] = a_x[0] + a_x[2];
-     a_y[2] = a_x[1] + a_x[2];
-     a_y[3] = a_x[1] + a_x[2] * a_x[2] / 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(size_t j = 0; j < n; j++)
-          x[j] = double(j);
-     /*
-            [ 1 0 1   ]
-     J(x) = [ 1 0 1   ]
-            [ 0 1 1   ]
-            [ 0 1 x_2 ]
-     */
-     d_vector check(m * n);
-     //
-     // column-major order values of J(x)
-     size_t nnz = 8;
-     s_vector check_row(nnz), check_col(nnz);
-     d_vector check_val(nnz);
-     for(size_t k = 0; k < nnz; k++)
-     {     // check_val
-          if( k < 7 )
-               check_val[k] = 1.0;
-          else
-               check_val[k] = x[2];
-          //
-          // check_row and check_col
-          check_row[k] = k;
-          if( k < 2 )
-               check_col[k] = 0;
-          else if( k < 4 )
-               check_col[k] = 1;
-          else
-          {     check_col[k] = 2;
-               check_row[k] = k - 4;
-          }
-     }
-     //
-     // n by n identity matrix sparsity
-     sparse_rc<s_vector> pattern_in;
-     pattern_in.resize(n, n, n);
-     for(size_t k = 0; k < n; k++)
-          pattern_in.set(k, k, k);
-     //
-     // sparsity for J(x)
-     bool transpose     = false;
-     bool dependency    = false;
-     bool internal_bool = true;
-     sparse_rc<s_vector> pattern_jac;
-     f.for_jac_sparsity(
-          pattern_in, transpose, dependency, internal_bool, pattern_jac
-     );
-     //
-     // compute entire forward mode Jacobian
-     sparse_rcv<s_vector, d_vector> subset( pattern_jac );
-     CppAD::sparse_jac_work work;
-     std::string coloring = "cppad";
-     size_t group_max = 10;
-     size_t n_sweep = f.sparse_jac_for(
-          group_max, x, subset, pattern_jac, coloring, work
-     );
-     ok &= n_sweep == 2;
-     //
-     const s_vector row( subset.row() );
-     const s_vector col( subset.col() );
-     const d_vector val( subset.val() );
-     s_vector col_major = subset.col_major();
-     ok  &= subset.nnz() == nnz;
-     for(size_t k = 0; k < nnz; k++)
-     {     ok &= row[ col_major[k] ] == check_row[k];
-          ok &= col[ col_major[k] ] == check_col[k];
-          ok &= val[ col_major[k] ] == check_val[k];
-     }
-     // compute non-zero in row 3 only
-     sparse_rc<s_vector> pattern_row3;
-     pattern_row3.resize(m, n, 2); // nr = m, nc = n, nnz = 2
-     pattern_row3.set(0, 3, 1);    // row[0] = 3, col[0] = 1
-     pattern_row3.set(1, 3, 2);    // row[1] = 3, col[1] = 2
-     sparse_rcv<s_vector, d_vector> subset_row3( pattern_row3 );
-     work.clear();
-     n_sweep = f.sparse_jac_for(
-          group_max, x, subset_row3, pattern_jac, coloring, work
-     );
-     ok &= n_sweep == 2;
-     //
-     const s_vector row_row3( subset_row3.row() );
-     const s_vector col_row3( subset_row3.col() );
-     const d_vector val_row3( subset_row3.val() );
-     ok &= subset_row3.nnz() == 2;
-     //
-     ok &= row_row3[0] == 3;
-     ok &= col_row3[0] == 1;
-     ok &= val_row3[0] == 1.0;
-     //
-     ok &= row_row3[1] == 3;
-     ok &= col_row3[1] == 2;
-     ok &= val_row3[1] == x[2];
-     //
-     return ok;
-}
-
-
Input File: example/sparse/sparse_jac_for.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_jac_for.cpp_xml.js cppad-2019.02.00.0/doc/_sparse_jac_for.cpp_xml.js --- cppad-2018.00.00.0/doc/_sparse_jac_for.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_jac_for.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparse_derivative.xml', -'sparse_jac.xml', -'sparse_jac_for.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_down1 = [ -'sparse_jac_for.cpp.xml', -'sparse_jac_rev.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-2018.00.00.0/doc/sparse_jac_fun.cpp.xml cppad-2019.02.00.0/doc/sparse_jac_fun.cpp.xml --- cppad-2018.00.00.0/doc/sparse_jac_fun.cpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_jac_fun.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ - - - -sparse_jac_fun: Example and test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sparse_jac_fun.cppHeadings

- - - - -
sparse_jac_fun: Example and test
-
# include <cppad/speed/sparse_jac_fun.hpp>
-# include <cppad/speed/uniform_01.hpp>
-# include <cppad/cppad.hpp>
-
-bool sparse_jac_fun(void)
-{     using CppAD::NearEqual;
-     using CppAD::AD;
-
-     bool ok = true;
-
-     size_t j, k;
-     double eps = CppAD::numeric_limits<double>::epsilon();
-     size_t n   = 3;
-     size_t m   = 4;
-     size_t K   = 5;
-     CppAD::vector<size_t>       row(K), col(K);
-     CppAD::vector<double>       x(n),   yp(K);
-     CppAD::vector< AD<double> > a_x(n), a_y(m);
-
-     // choose x
-     for(j = 0; j < n; j++)
-          a_x[j] = x[j] = double(j + 1);
-
-     // choose row, col
-     for(k = 0; k < K; k++)
-     {     row[k] = k % m;
-          col[k] = (K - k) % n;
-     }
-
-     // declare independent variables
-     Independent(a_x);
-
-     // evaluate function
-     size_t order = 0;
-     CppAD::sparse_jac_fun< AD<double> >(m, n, a_x, row, col, order, a_y);
-
-     // evaluate derivative
-     order = 1;
-     CppAD::sparse_jac_fun<double>(m, n, x, row, col, order, yp);
-
-     // use AD to evaluate derivative
-     CppAD::ADFun<double>   f(a_x, a_y);
-     CppAD::vector<double>  jac(m * n);
-     jac = f.Jacobian(x);
-
-     for(k = 0; k < K; k++)
-     {     size_t index = row[k] * n + col[k];
-          ok &= NearEqual(jac[index], yp[k] , eps, eps);
-     }
-     return ok;
-}
-
-
Input File: speed/example/sparse_jac_fun.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_jac_fun.cpp_xml.js cppad-2019.02.00.0/doc/_sparse_jac_fun.cpp_xml.js --- cppad-2018.00.00.0/doc/_sparse_jac_fun.cpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_jac_fun.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'sparse_jac_fun.xml', -'sparse_jac_fun.cpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'sparse_jac_fun.cpp.xml', -'sparse_jac_fun.hpp.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-2018.00.00.0/doc/sparse_jac_fun.hpp.xml cppad-2019.02.00.0/doc/sparse_jac_fun.hpp.xml --- cppad-2018.00.00.0/doc/sparse_jac_fun.hpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_jac_fun.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ - - - -Source: sparse_jac_fun - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sparse_jac_fun.hppHeadings

-
Source: sparse_jac_fun
-# ifndef CPPAD_SPARSE_JAC_FUN_HPP -
-
# define CPPAD_SPARSE_JAC_FUN_HPP - -
# include <cppad/core/cppad_assert.hpp>
-# include <cppad/utility/check_numeric_type.hpp>
-# include <cppad/utility/vector.hpp>
-
-// following needed by gcc under fedora 17 so that exp(double) is defined
-# include <cppad/base_require.hpp>
-
-namespace CppAD {
-     template <class Float, class FloatVector>
-     void sparse_jac_fun(
-          size_t                       m    ,
-          size_t                       n    ,
-          const FloatVector&           x    ,
-          const CppAD::vector<size_t>& row  ,
-          const CppAD::vector<size_t>& col  ,
-          size_t                       p    ,
-          FloatVector&                 fp   )
-     {
-          // check numeric type specifications
-          CheckNumericType<Float>();
-          // check value of p
-          CPPAD_ASSERT_KNOWN(
-               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;
-
-          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 );
-               switch(p)
-               {
-                    case 0:
-                    fp[i] += t;
-                    break;
-
-                    case 1:
-                    fp[k] = t * x[j];
-                    break;
-               }
-          }
-     }
-}
-# endif -
- - -
Input File: omh/sparse_jac_fun.omh - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_jac_fun.hpp_xml.js cppad-2019.02.00.0/doc/_sparse_jac_fun.hpp_xml.js --- cppad-2018.00.00.0/doc/_sparse_jac_fun.hpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_jac_fun.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'sparse_jac_fun.xml', -'sparse_jac_fun.hpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'sparse_jac_fun.cpp.xml', -'sparse_jac_fun.hpp.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-2018.00.00.0/doc/sparse_jac_fun.xml cppad-2019.02.00.0/doc/sparse_jac_fun.xml --- cppad-2018.00.00.0/doc/sparse_jac_fun.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_jac_fun.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,579 +0,0 @@ - - - -Evaluate a Function That Has a Sparse Jacobian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Evaluate a Function That Has a Sparse Jacobian
-
-Syntax - -
- -# include <cppad/speed/sparse_jac_fun.hpp>
-
- -sparse_jac_fun(mnxrowcolpfp) - - -
-
-Purpose -
-This routine evaluates - - -f -( -x -) - - - and - -f -( -1 -) - - -( -x -) - - - -where the Jacobian - -f -( -1 -) - - -( -x -) - - - is sparse. -The function - -f -: -R - -n - - -R - -m - - - - only depends on the -size and contents of the index vectors -row - and -col -. -The non-zero entries in the Jacobian of this function have -one of the following forms: - - - -f -[ -row -[ -k -] -] - - -x -[ -col -[ -k -] -] - - - - -for some - -k - - - between zero and - -K --1 - - -. -All the other terms of the Jacobian are zero. - -
-
-Inclusion -
-The template function sparse_jac_fun -is defined in the CppAD namespace by including -the file cppad/speed/sparse_jac_fun.hpp -(relative to the CppAD distribution directory). - -
-
-Float -
-The type -Float - must be a NumericType -. -In addition, if -y - and -z - are -Float - objects, - -
-     
y = exp(z)
-
-must set the -y - equal the exponential of -z -, i.e., -the derivative of -y - with respect to -z - is equal to -y -. - -
-
-FloatVector -
-The type -FloatVector - is any -SimpleVector -, or it can be a raw pointer, -with elements of type -Float -. - -
-
-n -
-The argument -n - has prototype - -
-     size_t 
n
-
-It specifies the dimension for the domain space for - -f -( -x -) - - -. - -
-
-m -
-The argument -m - has prototype - -
-     size_t 
m
-
-It specifies the dimension for the range space for - -f -( -x -) - - -. - -
-
-x -
-The argument -x - has prototype - -
-     const 
FloatVectorx
-
-It contains the argument value for which the function, -or its derivative, is being evaluated. -We use - -n - - - to denote the size of the vector -x -. - -
-
-row -
-The argument -row - has prototype - -
-      const CppAD::vector<size_t>& 
row
-
-It specifies indices in the range of - -f -( -x -) - - - for non-zero components -of the Jacobian -(see purpose - above). -The value - -K - - - is defined by -K = row.size() -. -All the elements of -row - must be between zero and -m-1 -. - -
-
-col -
-The argument -col - has prototype - -
-      const CppAD::vector<size_t>& 
col
-
-and its size must be - -K - - -; i.e., the same as -row -. -It specifies the component of - -x - - - for -the non-zero Jacobian terms. -All the elements of -col - must be between zero and -n-1 -. - -
-
-p -
-The argument -p - has prototype - -
-     size_t 
p
-
-It is either zero or one and -specifies the order of the derivative of - -f - - - -that is being evaluated, i.e., - -f -( -p -) - - -( -x -) - - - is evaluated. - -
-
-fp -
-The argument -fp - has prototype - -
-     
FloatVectorfp
-
-If -p = 0 -, it size is -m - -otherwise its size is -K -. -The input value of the elements of -fp - does not matter. - -
-
-Function -
-If -p - is zero, -fp - has size - -m - - - and - -(fp[0], ... , fp[m-1]) - is the value of - -f -( -x -) - - -. - -
-
-Jacobian -
-If -p - is one, -fp - has size -K - and -for - -k -= -0 -, - -, -K --1 - - -, - - - -f -[ -row - -[ -i -] -] - - -x -[ -col - -[ -j -] -] - - -= -fp -[ -k -] - - -
-Example -
-The file -sparse_jac_fun.cpp - -contains an example and test of sparse_jac_fun.hpp. -It returns true if it succeeds and false otherwise. - -
-
-Source Code -
-The file -sparse_jac_fun.hpp - -contains the source code for this template function. - - -
Input File: cppad/speed/sparse_jac_fun.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_jac_fun_xml.js cppad-2019.02.00.0/doc/_sparse_jac_fun_xml.js --- cppad-2018.00.00.0/doc/_sparse_jac_fun_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_jac_fun_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'sparse_jac_fun.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down0 = [ -'sparse_jac_fun.cpp.xml', -'sparse_jac_fun.hpp.xml' -]; -var list_current0 = [ -'sparse_jac_fun.xml#Syntax', -'sparse_jac_fun.xml#Purpose', -'sparse_jac_fun.xml#Inclusion', -'sparse_jac_fun.xml#Float', -'sparse_jac_fun.xml#FloatVector', -'sparse_jac_fun.xml#n', -'sparse_jac_fun.xml#m', -'sparse_jac_fun.xml#x', -'sparse_jac_fun.xml#row', -'sparse_jac_fun.xml#col', -'sparse_jac_fun.xml#p', -'sparse_jac_fun.xml#fp', -'sparse_jac_fun.xml#fp.Function', -'sparse_jac_fun.xml#fp.Jacobian', -'sparse_jac_fun.xml#Example', -'sparse_jac_fun.xml#Source Code' -]; -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-2018.00.00.0/doc/sparse_jacobian.cpp.xml cppad-2019.02.00.0/doc/sparse_jacobian.cpp.xml --- cppad-2018.00.00.0/doc/sparse_jacobian.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_jacobian.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,326 +0,0 @@ - - - -Sparse Jacobian: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sparse_jacobian.cppHeadings

- - - -
Sparse Jacobian: Example and Test
-

-# include <cppad/cppad.hpp>
-namespace { // ---------------------------------------------------------
-bool reverse()
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     typedef CPPAD_TESTVECTOR(AD<double>)   a_vector;
-     typedef CPPAD_TESTVECTOR(double)       d_vector;
-     typedef CPPAD_TESTVECTOR(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);
-
-     // Jacobian of y without sparsity pattern
-     d_vector jac(m * n);
-     jac = f.SparseJacobian(x);
-     /*
-           [ 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];
-     for(ell = 0; ell < size_t(check.size()); ell++)
-          ok &=  NearEqual(check[ell], jac[ell], eps, eps );
-
-     // using packed boolean sparsity patterns
-     CppAD::vectorBool s_b(m * m), p_b(m * n);
-     for(i = 0; i < m; i++)
-     {     for(ell = 0; ell < m; ell++)
-               s_b[i * m + ell] = false;
-          s_b[i * m + i] = true;
-     }
-     p_b   = f.RevSparseJac(m, s_b);
-     jac   = f.SparseJacobian(x, p_b);
-     for(ell = 0; ell < size_t(check.size()); ell++)
-          ok &=  NearEqual(check[ell], jac[ell], eps, eps );
-
-     // using vector of sets sparsity patterns
-     std::vector< std::set<size_t> > s_s(m),  p_s(m);
-     for(i = 0; i < m; i++)
-          s_s[i].insert(i);
-     p_s   = f.RevSparseJac(m, s_s);
-     jac   = f.SparseJacobian(x, p_s);
-     for(ell = 0; ell < size_t(check.size()); ell++)
-          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).
-     size_t K = 6;
-     i_vector row(K), col(K);
-     jac.resize(K);
-     k = 0;
-     for(j = 0; j < n; j++)
-     {     for(i = 1; i < m; i++)
-          {     ell = i * n + j;
-               if( p_b[ell] )
-               {     ok &= check[ell] != 0.;
-                    row[k] = i;
-                    col[k] = j;
-                    k++;
-               }
-          }
-     }
-     ok &= k == K;
-
-     // empty work structure
-     CppAD::sparse_jacobian_work work;
-
-     // 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];
-          ok &= NearEqual(check[ell], jac[k], eps, eps);
-     }
-     ok &= n_sweep == 2;
-
-     // now recompute at a different x value (using work from previous call)
-     check[11] = x[3] = 10.;
-     std::vector< std::set<size_t> > 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);
-     }
-     ok &= n_sweep == 2;
-
-     return ok;
-}
-
-bool forward()
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     typedef CPPAD_TESTVECTOR(AD<double>) a_vector;
-     typedef CPPAD_TESTVECTOR(double)       d_vector;
-     typedef CPPAD_TESTVECTOR(size_t)       i_vector;
-     size_t i, j, k, ell;
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n = 3;
-     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 = 4;
-     a_vector  a_y(m);
-     a_y[0] = a_x[0] + a_x[2];
-     a_y[1] = a_x[0] + a_x[2];
-     a_y[2] = a_x[1] + a_x[2];
-     a_y[3] = a_x[1] + a_x[2] * a_x[2] / 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);
-
-     // Jacobian of y without sparsity pattern
-     d_vector jac(m * n);
-     jac = f.SparseJacobian(x);
-     /*
-           [ 1 0 1   ]
-     jac = [ 1 0 1   ]
-           [ 0 1 1   ]
-           [ 0 1 x_2 ]
-     */
-     d_vector check(m * n);
-     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[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 );
-
-     // test using packed boolean vectors for sparsity pattern
-     CppAD::vectorBool r_b(n * n), p_b(m * n);
-     for(j = 0; j < n; j++)
-     {     for(ell = 0; ell < n; ell++)
-               r_b[j * n + ell] = false;
-          r_b[j * n + j] = true;
-     }
-     p_b = f.ForSparseJac(n, r_b);
-     jac = f.SparseJacobian(x, p_b);
-     for(ell = 0; ell < size_t(check.size()); ell++)
-          ok &=  NearEqual(check[ell], jac[ell], eps, eps );
-
-     // test using vector of sets for sparsity pattern
-     std::vector< std::set<size_t> > r_s(n), p_s(m);
-     for(j = 0; j < n; j++)
-          r_s[j].insert(j);
-     p_s = f.ForSparseJac(n, r_s);
-     jac = f.SparseJacobian(x, p_s);
-     for(ell = 0; ell < size_t(check.size()); ell++)
-          ok &=  NearEqual(check[ell], jac[ell], eps, eps );
-
-     // using row and column indices to compute non-zero elements excluding
-     // row 0 and column 0.
-     size_t K = 5;
-     i_vector row(K), col(K);
-     jac.resize(K);
-     k = 0;
-     for(i = 1; i < m; i++)
-     {     for(j = 1; j < n; j++)
-          {     ell = i * n + j;
-               if( p_b[ell] )
-               {     ok &= check[ell] != 0.;
-                    row[k] = i;
-                    col[k] = j;
-                    k++;
-               }
-          }
-     }
-     ok &= k == K;
-
-     // empty work structure
-     CppAD::sparse_jacobian_work work;
-
-     // 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];
-          ok &= NearEqual(check[ell], jac[k], eps, eps);
-     }
-     ok &= n_sweep == 2;
-
-     // now recompute at a different x value (using work from previous call)
-     check[11] = x[2] = 10.;
-     n_sweep = f.SparseJacobianForward(x, p_s, 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 empty namespace
-
-bool sparse_jacobian(void)
-{     bool ok = true;
-     ok &= forward();
-     ok &= reverse();
-
-     return ok;
-}
-
-
Input File: example/sparse/sparse_jacobian.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_jacobian.cpp_xml.js cppad-2019.02.00.0/doc/_sparse_jacobian.cpp_xml.js --- cppad-2018.00.00.0/doc/_sparse_jacobian.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_jacobian.cpp_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', -'adfun.xml', -'sparse_derivative.xml', -'sparse_jacobian.xml', -'sparse_jacobian.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_down1 = [ -'sparse_jacobian.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-2018.00.00.0/doc/sparse_jacobian.xml cppad-2019.02.00.0/doc/sparse_jacobian.xml --- cppad-2018.00.00.0/doc/sparse_jacobian.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_jacobian.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,782 +0,0 @@ - - - -Sparse Jacobian - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Sparse Jacobian
-
-Syntax - -
- -jac = f.SparseJacobian(x)
-
jac = f.SparseJacobian(xp)
-
n_sweep = f.SparseJacobianForward(xprowcoljacwork)
-
n_sweep = f.SparseJacobianReverse(xprowcoljacwork)
-
-
-Purpose -
-We use - -n - - - for the domain - size, -and - -m - - - for the range - size of -f -. -We use - -F -: -R - -n - - -R - -m - - - - do denote the -AD function - -corresponding to -f -. -The syntax above sets -jac - to the Jacobian - - -jac -= -F -( -1 -) - - -( -x -) - - -This routine takes advantage of the sparsity of the Jacobian -in order to reduce the amount of computation necessary. -If -row - and -col - are present, it also takes -advantage of the reduced set of elements of the Jacobian that -need to be computed. -One can use speed tests (e.g. speed_test -) -to verify that results are computed faster -than when using the routine Jacobian -. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-Note that the ADFun - object -f - is not const -(see Uses Forward - below). - -
-
-x -
-The argument -x - has prototype - -
-     const 
VectorBasex
-
-(see VectorBase - below) -and its size -must be equal to -n -, the dimension of the -domain - space for -f -. -It specifies -that point at which to evaluate the Jacobian. - -
-
-p -
-The argument -p - is optional and has prototype - -
-     const 
VectorSetp
-
-(see VectorSet - below). -If it has elements of type bool, -its size is - -m -* -n - - -. -If it has elements of type std::set<size_t>, -its size is - -m - - - and all its set elements are between -zero and - -n -- -1 - - -. -It specifies a -sparsity pattern - -for the Jacobian - -F -( -1 -) - - -( -x -) - - -. -
-
-
If this sparsity pattern does not change between calls to - -SparseJacobian -, it should be faster to calculate -p - once -(using ForSparseJac - or RevSparseJac -) -and then pass -p - to -SparseJacobian -. -Furthermore, if you specify -work - in the calling sequence, -it is not necessary to keep the sparsity pattern; see the heading -p - under the -work - description. -
-
-
In addition, -if you specify -p -, CppAD will use the same -type of sparsity representation -(vectors of bool or vectors of std::set<size_t>) -for its internal calculations. -Otherwise, the representation -for the internal calculations is unspecified. - -
-
-row, col -
-The arguments -row - and -col - are optional and have prototype - -
-     const 
VectorSizerow
-     const 
VectorSizecol
-
-(see VectorSize - below). -They specify which rows and columns of - -F -( -1 -) - - -( -x -) - - - are -computes and in what order. -Not all the non-zero entries in - -F -( -1 -) - - -( -x -) - - - need be computed, -but all the entries specified by -row - and -col - -must be possibly non-zero in the sparsity pattern. -We use - -K - - - to denote the value -jac.size() - -which must also equal the size of -row - and -col -. -Furthermore, -for - -k -= -0 -, - -, -K --1 - - -, it must hold that - - -row -[ -k -] -< -m - - - and - -col -[ -k -] -< -n - - -. - -
-
-jac -
-The result -jac - has prototype - -
-     
VectorBasejac
-
-In the case where the arguments -row - and -col - are not present, -the size of -jac - is - -m -* -n - - - and -for - -i -= -0 -, - -, -m --1 - - -, - - -j -= -0 -, - -, -n --1 - - -, - - -jac -[ -i -* -n -+ -j -] -= - -F -i - - - -x -j - - - -( -x -) - - -
-
-
In the case where the arguments -row - and -col - are present, -we use - -K - - - to denote the size of -jac -. -The input value of its elements does not matter. -Upon return, for - -k -= -0 -, - -, -K -- -1 - - -, - - -jac -[ -k -] -= - -F -i - - - -x -j - - - -( -x -) - -, - - -where - - -i -= -row -[ -k -] - -and - - -j -= -col -[ -k -] - - -
-work -
-If this argument is present, it has prototype - -
-     sparse_jacobian_work& 
work
-
-This object can only be used with the routines -SparseJacobianForward and SparseJacobianReverse. -During its the first use, information is stored in -work -. -This is used to reduce the work done by future calls to the same mode -(forward or reverse), -the same -f -, -p -, -row -, and -col -. -If a future call is for a different mode, -or any of these values have changed, -you must first call -work.clear() - -to inform CppAD that this information needs to be recomputed. - -
-
-color_method -
-The coloring algorithm determines which columns (forward mode) -or rows (reverse mode) can be computed during the same sweep. -This field has prototype - -
-     std::string 
work.color_method
-
-and its default value (after a constructor or clear()) -is "cppad". -If colpack_prefix - is specified on the -cmake command - line, -you can set this method to "colpack". -This value only matters on the first call to sparse_jacobian -that follows the -work - constructor or a call to - -work.clear() -. - -
-
-p -
-If -work - is present, and it is not the first call after -its construction or a clear, -the sparsity pattern -p - is not used. -This enables one to free the sparsity pattern -and still compute corresponding sparse Jacobians. - -
-
-n_sweep -
-The return value -n_sweep - has prototype - -
-     size_t 
n_sweep
-
-If SparseJacobianForward (SparseJacobianReverse) is used, - -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 SparseJacobian does, -not counting the zero order forward sweep, -or the work to combine multiple columns (rows) into a single sweep. - -
-
-VectorBase -
-The type -VectorBase - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-VectorSet -
-The type -VectorSet - must be a SimpleVector - class with -elements of type - -bool or std::set<size_t>; -see sparsity pattern - for a discussion -of the difference. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Restrictions -
-If -VectorSet - has elements of std::set<size_t>, -then -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, -std::valarray< std::set<size_t> > does not satisfy -this condition. - -
-
-VectorSize -
-The type -VectorSize - must be a SimpleVector - class with -elements of type - -size_t. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-Uses Forward -
-After each call to Forward -, -the object -f - contains the corresponding -Taylor coefficients -. -After a call to any of the sparse Jacobian routines, -the zero order Taylor coefficients correspond to - -f.Forward(0, x) - -and the other coefficients are unspecified. - -After SparseJacobian, -the previous calls to Forward - are undefined. - -
-
-Example - -
-The routine -sparse_jacobian.cpp - -is examples and tests of sparse_jacobian. -It return true, if it succeeds and false otherwise. - - -
Input File: cppad/core/sparse_jacobian.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_jacobian_xml.js cppad-2019.02.00.0/doc/_sparse_jacobian_xml.js --- cppad-2018.00.00.0/doc/_sparse_jacobian_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_jacobian_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparse_derivative.xml', -'sparse_jacobian.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_down0 = [ -'sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'sparse_jacobian.xml#Syntax', -'sparse_jacobian.xml#Purpose', -'sparse_jacobian.xml#f', -'sparse_jacobian.xml#x', -'sparse_jacobian.xml#p', -'sparse_jacobian.xml#row, col', -'sparse_jacobian.xml#jac', -'sparse_jacobian.xml#work', -'sparse_jacobian.xml#work.color_method', -'sparse_jacobian.xml#work.p', -'sparse_jacobian.xml#n_sweep', -'sparse_jacobian.xml#VectorBase', -'sparse_jacobian.xml#VectorSet', -'sparse_jacobian.xml#VectorSet.Restrictions', -'sparse_jacobian.xml#VectorSize', -'sparse_jacobian.xml#Uses Forward', -'sparse_jacobian.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-2018.00.00.0/doc/sparse_jac_rev.cpp.xml cppad-2019.02.00.0/doc/sparse_jac_rev.cpp.xml --- cppad-2018.00.00.0/doc/sparse_jac_rev.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_jac_rev.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,218 +0,0 @@ - - - -Computing Sparse Jacobian Using Reverse Mode: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sparse_jac_rev.cppHeadings

-
Computing Sparse Jacobian Using Reverse Mode: Example and Test
-
# include <cppad/cppad.hpp>
-bool sparse_jac_rev(void)
-{     bool ok = true;
-     //
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     using CppAD::sparse_rc;
-     using CppAD::sparse_rcv;
-     //
-     typedef CPPAD_TESTVECTOR(AD<double>) a_vector;
-     typedef CPPAD_TESTVECTOR(double)     d_vector;
-     typedef CPPAD_TESTVECTOR(size_t)     s_vector;
-     //
-     // domain space vector
-     size_t n = 4;
-     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);
-     //
-     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(size_t j = 0; j < n; j++)
-          x[j] = double(j);
-     /*
-            [ 1 1 0 0  ]
-     J(x) = [ 0 0 1 1  ]
-            [ 1 1 1 x_3]
-     */
-     //
-     // row-major order values of J(x)
-     size_t nnz = 8;
-     s_vector check_row(nnz), check_col(nnz);
-     d_vector check_val(nnz);
-     for(size_t k = 0; k < nnz; k++)
-     {     // check_val
-          if( k < 7 )
-               check_val[k] = 1.0;
-          else
-               check_val[k] = x[3];
-          //
-          // check_row and check_col
-          check_col[k] = k;
-          if( k < 2 )
-               check_row[k] = 0;
-          else if( k < 4 )
-               check_row[k] = 1;
-          else
-          {     check_row[k] = 2;
-               check_col[k] = k - 4;
-          }
-     }
-     //
-     // m by m identity matrix sparsity
-     sparse_rc<s_vector> pattern_in(m, m, m);
-     for(size_t k = 0; k < m; k++)
-          pattern_in.set(k, k, k);
-     //
-     // sparsity for J(x)
-     bool transpose     = false;
-     bool dependency    = false;
-     bool internal_bool = true;
-     sparse_rc<s_vector> pattern_jac;
-     f.rev_jac_sparsity(
-          pattern_in, transpose, dependency, internal_bool, pattern_jac
-     );
-     //
-     // compute entire reverse mode Jacobian
-     sparse_rcv<s_vector, d_vector> subset( pattern_jac );
-     CppAD::sparse_jac_work work;
-     std::string coloring = "cppad";
-     size_t n_sweep = f.sparse_jac_rev(x, subset, pattern_jac, coloring, work);
-     ok &= n_sweep == 2;
-     //
-     const s_vector row( subset.row() );
-     const s_vector col( subset.col() );
-     const d_vector val( subset.val() );
-     s_vector row_major = subset.row_major();
-     ok  &= subset.nnz() == nnz;
-     for(size_t k = 0; k < nnz; k++)
-     {     ok &= row[ row_major[k] ] == check_row[k];
-          ok &= col[ row_major[k] ] == check_col[k];
-          ok &= val[ row_major[k] ] == check_val[k];
-     }
-     //
-     // test using work stored by previous sparse_jac_rev
-     sparse_rc<s_vector> pattern_not_used;
-     std::string         coloring_not_used;
-     n_sweep = f.sparse_jac_rev(x, subset, pattern_jac, coloring, work);
-     ok &= n_sweep == 2;
-     for(size_t k = 0; k < nnz; k++)
-     {     ok &= row[ row_major[k] ] == check_row[k];
-          ok &= col[ row_major[k] ] == check_col[k];
-          ok &= val[ row_major[k] ] == check_val[k];
-     }
-     //
-     // compute non-zero in col 3 only, nr = m, nc = n, nnz = 2
-     sparse_rc<s_vector> pattern_col3(m, n, 2);
-     pattern_col3.set(0, 1, 3);    // row[0] = 1, col[0] = 3
-     pattern_col3.set(1, 2, 3);    // row[1] = 2, col[1] = 3
-     sparse_rcv<s_vector, d_vector> subset_col3( pattern_col3 );
-     work.clear();
-     n_sweep = f.sparse_jac_rev(x, subset_col3, pattern_jac, coloring, work);
-     ok &= n_sweep == 2;
-     //
-     const s_vector row_col3( subset_col3.row() );
-     const s_vector col_col3( subset_col3.col() );
-     const d_vector val_col3( subset_col3.val() );
-     ok &= subset_col3.nnz() == 2;
-     //
-     ok &= row_col3[0] == 1;
-     ok &= col_col3[0] == 3;
-     ok &= val_col3[0] == 1.0;
-     //
-     ok &= row_col3[1] == 2;
-     ok &= col_col3[1] == 3;
-     ok &= val_col3[1] == x[3];
-     //
-     return ok;
-}
-
-
Input File: example/sparse/sparse_jac_rev.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_jac_rev.cpp_xml.js cppad-2019.02.00.0/doc/_sparse_jac_rev.cpp_xml.js --- cppad-2018.00.00.0/doc/_sparse_jac_rev.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_jac_rev.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparse_derivative.xml', -'sparse_jac.xml', -'sparse_jac_rev.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_down1 = [ -'sparse_jac_for.cpp.xml', -'sparse_jac_rev.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-2018.00.00.0/doc/sparse_jac.xml cppad-2019.02.00.0/doc/sparse_jac.xml --- cppad-2018.00.00.0/doc/sparse_jac.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_jac.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,502 +0,0 @@ - - - -Computing Sparse Jacobians - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Computing Sparse Jacobians
-
-Syntax - -
- -n_sweep = f.sparse_jac_for(
-     
group_maxxsubsetpatterncoloringwork
-)
-
- -n_sweep = f.sparse_jac_rev(
-     
xsubsetpatterncoloringwork
-)
- - - -
-
-Purpose -
-We use - -F -: -R - -n - - -R - -m - - - - to denote the -function corresponding to -f -. -Here -n - is the domain - size, -and -m - is the range - size, or -f -. -The syntax above takes advantage of sparsity when computing the Jacobian - - -J -( -x -) -= -F -( -1 -) - - -( -x -) - - -In the sparse case, this should be faster and take less memory than -Jacobian -. -We use the notation - -J -i -, -j - - -( -x -) - - - to denote the partial of - - -F -i - -( -x -) - - - with respect to - -x -j - - - -. - -
-
-SizeVector -
-The type -SizeVector - is a SimpleVector - class with -elements of type - -size_t. - -
-
-BaseVector -
-The type -BaseVector - is a SimpleVector - class with -elements of type - -size_t. - -
-
-sparse_jac_for -
-This function uses first order forward mode sweeps forward_one - -to compute multiple columns of the Jacobian at the same time. - -
-
-sparse_jac_rev -
-This uses function first order reverse mode sweeps reverse_one - -to compute multiple rows of the Jacobian at the same time. - -
-
-f -
-This object has prototype - -
-     ADFun<
Basef
-
-Note that the Taylor coefficients stored in -f - are affected -by this operation; see -uses forward - below. - -
-
-group_max -
-This argument has prototype - -
-     size_t 
group_max
-
-and must be greater than zero. -It specifies the maximum number of colors to group during -a single forward sweep. -If a single color is in a group, -a single direction for of first order forward mode -forward_one - is used for each color. -If multiple colors are in a group, -the multiple direction for of first order forward mode -forward_dir - is used with one direction for each color. -This uses separate memory for each direction (more memory), -but my be significantly faster. - -
-
-x -
-This argument has prototype - -
-     const 
BaseVectorx
-
-and its size is -n -. -It specifies the point at which to evaluate the Jacobian - - -J -( -x -) - - -. - -
-
-subset -
-This argument has prototype - -
-     sparse_rcv<
SizeVectorBaseVector>& subset
-
-Its row size is -subset.nr() == m -, -and its column size is -subset.nc() == n -. -It specifies which elements of the Jacobian are computed. -The input value of its value vector - -subset.val() - does not matter. -Upon return it contains the value of the corresponding elements -of the Jacobian. -All of the row, column pairs in -subset - must also appear in - -pattern -; i.e., they must be possibly non-zero. - -
-
-pattern -
-This argument has prototype - -
-     const sparse_rc<
SizeVector>& pattern
-
-Its row size is -pattern.nr() == m -, -and its column size is -pattern.nc() == n -. -It is a sparsity pattern for the Jacobian - -J -( -x -) - - -. -This argument is not used (and need not satisfy any conditions), -when work - is non-empty. - -
-
-coloring -
-The coloring algorithm determines which rows (reverse) or columns (forward) -can be computed during the same sweep. -This field has prototype - -
-     const std::string& 
coloring
-
-This value only matters when work is empty; i.e., -after the -work - constructor or -work.clear() -. - -
-
-cppad -
-This uses a general purpose coloring algorithm written for Cppad. - -
-
-colpack -
-If colpack_prefix - is specified on the -cmake command - line, -you can set -coloring - to colpack. -This uses a general purpose coloring algorithm that is part of Colpack. - -
-
-work -
-This argument has prototype - -
-     sparse_jac_work& 
work
-
-We refer to its initial value, -and its value after -work.clear() -, as empty. -If it is empty, information is stored in -work -. -This can be used to reduce computation when -a future call is for the same object -f -, -the same member function sparse_jac_for or sparse_jac_rev, -and the same subset of the Jacobian. -If any of these values change, use -work.clear() - to -empty this structure. - -
-
-n_sweep -
-The return value -n_sweep - has prototype - -
-     size_t 
n_sweep
-
-If sparse_jac_for (sparse_jac_rev) is used, - -n_sweep - is the number of first order forward (reverse) sweeps -used to compute the requested Jacobian values. -It is also the number of colors determined by the coloring method -mentioned above. -This is proportional to the total computational work, -not counting the zero order forward sweep, -or combining multiple columns (rows) into a single sweep. - -
-
-Uses Forward -
-After each call to Forward -, -the object -f - contains the corresponding -Taylor coefficients -. -After a call to sparse_jac_forward or sparse_jac_rev, -the zero order coefficients correspond to - -
-     
f.Forward(0, x)
-
-All the other forward mode coefficients are unspecified. - -
-
-Example - -
-The files sparse_jac_for.cpp - and sparse_jac_rev.cpp - -are examples and tests of sparse_jac_for and sparse_jac_rev. -They return true, if they succeed, and false otherwise. - - -
Input File: cppad/core/sparse_jac.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_jac_xml.js cppad-2019.02.00.0/doc/_sparse_jac_xml.js --- cppad-2018.00.00.0/doc/_sparse_jac_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_jac_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparse_derivative.xml', -'sparse_jac.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_down0 = [ -'sparse_jac_for.cpp.xml', -'sparse_jac_rev.cpp.xml' -]; -var list_current0 = [ -'sparse_jac.xml#Syntax', -'sparse_jac.xml#Purpose', -'sparse_jac.xml#SizeVector', -'sparse_jac.xml#BaseVector', -'sparse_jac.xml#sparse_jac_for', -'sparse_jac.xml#sparse_jac_rev', -'sparse_jac.xml#f', -'sparse_jac.xml#group_max', -'sparse_jac.xml#x', -'sparse_jac.xml#subset', -'sparse_jac.xml#pattern', -'sparse_jac.xml#coloring', -'sparse_jac.xml#coloring.cppad', -'sparse_jac.xml#coloring.colpack', -'sparse_jac.xml#work', -'sparse_jac.xml#n_sweep', -'sparse_jac.xml#Uses Forward', -'sparse_jac.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-2018.00.00.0/doc/sparse_rc.cpp.xml cppad-2019.02.00.0/doc/sparse_rc.cpp.xml --- cppad-2018.00.00.0/doc/sparse_rc.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_rc.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ - - - -sparse_rc: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sparse_rc.cppHeadings

- - - -
sparse_rc: Example and Test
-
# include <cppad/utility/sparse_rc.hpp>
-# include <vector>
-
-bool sparse_rc(void)
-{     bool ok = true;
-     typedef std::vector<size_t> SizeVector;
-
-     // 3 by 3 identity matrix
-     size_t nr  = 3;
-     size_t nc  = 3;
-     size_t nnz = 3;
-     CppAD::sparse_rc<SizeVector> pattern(nr, nc, nnz);
-     for(size_t k = 0; k < nnz; k++)
-          pattern.set(k, k, k);
-
-     // row and column vectors corresponding to pattern
-     const SizeVector& row( pattern.row() );
-     const SizeVector& col( pattern.row() );
-
-     // check pattern
-     ok &= pattern.nnz() == nnz;
-     ok &= pattern.nr()  == nr;
-     ok &= pattern.nc()  == nc;
-     for(size_t k = 0; k < nnz; k++)
-     {     ok &= row[k] == k;
-          ok &= col[k] == k;
-     }
-
-     // change to sparsity pattern for a 5 by 5 diagonal matrix
-     nr  = 5;
-     nc  = 5;
-     nnz = 5;
-     pattern.resize(nr, nc, nnz);
-     for(size_t k = 0; k < nnz; k++)
-     {     size_t r = nnz - k - 1; // reverse or row-major order
-          size_t c = nnz - k - 1;
-          pattern.set(k, r, c);
-     }
-     SizeVector row_major = pattern.row_major();
-
-     // check row and column
-     for(size_t k = 0; k < nnz; k++)
-     {     ok &= row[ row_major[k] ] == k;
-          ok &= col[ row_major[k] ] == k;
-     }
-
-     // create an empty pattern
-     CppAD::sparse_rc<SizeVector> target;
-     ok &= target.nnz() == 0;
-     ok &= target.nr()  == 0;
-     ok &= target.nc()  == 0;
-
-     // now use it as the target for an assignment statement
-     target = pattern;
-     ok    &= target.nr()  == pattern.nr();
-     ok    &= target.nc()  == pattern.nc();
-     ok    &= target.nnz() == pattern.nnz();
-     for(size_t k = 0; k < nnz; k++)
-     {     ok &= target.row()[k] == row[k];
-          ok &= target.col()[k] == col[k];
-     }
-     return ok;
-}
-
-
-
Input File: example/utility/sparse_rc.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_rc.cpp_xml.js cppad-2019.02.00.0/doc/_sparse_rc.cpp_xml.js --- cppad-2018.00.00.0/doc/_sparse_rc.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_rc.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'sparse_rc.xml', -'sparse_rc.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'sparse_rc.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-2018.00.00.0/doc/sparse_rcv.cpp.xml cppad-2019.02.00.0/doc/sparse_rcv.cpp.xml --- cppad-2018.00.00.0/doc/sparse_rcv.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_rcv.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ - - - -sparse_rcv: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sparse_rcv.cppHeadings

- - - -
sparse_rcv: Example and Test
-
# include <cppad/utility/sparse_rcv.hpp>
-# include <vector>
-
-bool sparse_rcv(void)
-{     bool ok = true;
-     typedef std::vector<size_t> SizeVector;
-     typedef std::vector<double> ValueVector;
-
-     // sparsity pattern for a 5 by 5 diagonal matrix
-     size_t nr  = 5;
-     size_t nc  = 5;
-     size_t nnz = 5;
-     CppAD::sparse_rc<SizeVector> pattern(nr, nc, nnz);
-     for(size_t k = 0; k < nnz; k++)
-     {     size_t r = nnz - k - 1; // reverse or column-major order
-          size_t c = nnz - k - 1;
-          pattern.set(k, r, c);
-     }
-
-     // sparse matrix
-     CppAD::sparse_rcv<SizeVector, ValueVector> matrix(pattern);
-     for(size_t k = 0; k < nnz; k++)
-     {     double v = double(k);
-          matrix.set(nnz - k - 1, v);
-     }
-
-     // row, column, and value vectors
-     const SizeVector&  row( matrix.row() );
-     const SizeVector&  col( matrix.row() );
-     const ValueVector& val( matrix.val() );
-     SizeVector col_major = matrix.col_major();
-
-     // check row,  column, and value
-     for(size_t k = 0; k < nnz; k++)
-     {     ok &= row[ col_major[k] ] == k;
-          ok &= col[ col_major[k] ] == k;
-          ok &= val[ col_major[k] ] == double(k);
-     }
-
-     // create an empty matrix
-     CppAD::sparse_rcv<SizeVector, ValueVector> target;
-     ok &= target.nnz() == 0;
-     ok &= target.nr()  == 0;
-     ok &= target.nc()  == 0;
-
-     // now use it as the target for an assignment statement
-     target = matrix;
-     ok    &= target.nr()  == matrix.nr();
-     ok    &= target.nc()  == matrix.nc();
-     ok    &= target.nnz() == matrix.nnz();
-     for(size_t k = 0; k < nnz; k++)
-     {     ok &= target.row()[k] == row[k];
-          ok &= target.col()[k] == col[k];
-          ok &= target.val()[k] == val[k];
-     }
-     return ok;
-}
-
-
-
Input File: example/utility/sparse_rcv.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_rcv.cpp_xml.js cppad-2019.02.00.0/doc/_sparse_rcv.cpp_xml.js --- cppad-2018.00.00.0/doc/_sparse_rcv.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_rcv.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'sparse_rcv.xml', -'sparse_rcv.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'sparse_rcv.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-2018.00.00.0/doc/sparse_rcv.xml cppad-2019.02.00.0/doc/sparse_rcv.xml --- cppad-2018.00.00.0/doc/sparse_rcv.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_rcv.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,452 +0,0 @@ - - - -Sparse Matrix Row, Column, Value Representation - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Sparse Matrix Row, Column, Value Representation
-
-Syntax - -
- -# include <cppad/utility/sparse_rcv.hpp>
-
- -sparse_rcv<SizeVectorValueVector>  empty
-
- -sparse_rcv<SizeVectorValueVector>  matrix(pattern)
-
- -target = matrix
-
- -matrix.set(kv)
-
- -nr = matrix.nr()
-
- -nc = matrix.nc()
-
- -nnz = matrix.nnz()
-
- -const SizeVectorrowmatrix.row() )
-
- -const SizeVectorcolmatrix.col() )
-
- -const ValueVectorvalmatrix.val() )
-
- -row_major = matrix.row_major()
-
- -col_major = matrix.col_major()
-
-
-SizeVector -
-We use SizeVector - to denote the -SimpleVector - class corresponding to -pattern -. - -
-
-ValueVector -
-We use -ValueVector - to denote the -SimpleVector - class corresponding to -val -. - -
-
-empty -
-This is an empty sparse matrix object. To be specific, -the corresponding number of rows -nr -, -number of columns -nc -, -and number of possibly non-zero values -nnz -, -are all zero. - - -
-
-pattern -
-This argument has prototype - -
-     const sparse_rc<
SizeVector>& pattern
-
-It specifies the number of rows, number of columns and -the possibly non-zero entries in the -matrix -. - -
-
-matrix -
-This is a sparse matrix object with the sparsity specified by -pattern -. -Only the -val - vector can be changed. All other values returned by - -matrix - are fixed during the constructor and constant there after. -The -val - vector is only changed by the constructor -and the set function. -There is one exception to the rule, where -matrix - corresponds -to -target - for an assignment statement. - -
-
-target -
-The target of the assignment statement must have prototype - -
-     sparse_rcv<
SizeVectorValueVector>  target
-
-After this assignment statement, -target - is an independent copy -of -matrix -; i.e. it has all the same values as -matrix - -and changes to -target - do not affect -matrix -. - -
-
-nr -
-This return value has prototype - -
-     size_t 
nr
-
-and is the number of rows in -matrix -. - -
-
-nc -
-This argument and return value has prototype - -
-     size_t 
nc
-
-and is the number of columns in -matrix -. - -
-
-nnz -
-We use the notation -nnz - to denote the number of -possibly non-zero entries in -matrix -. - -
-
-set -
-This function sets the value - -
-     
val[k] = v
-
-
-k -
-This argument has type - -
-     size_t 
k
-
-and must be less than -nnz -. - -
-
-v -
-This argument has type - -
-     const 
ValueVector::value_type& v
-
-It specifies the value assigned to -val[k] -. - - -
-
-row -
-This vector has size -nnz - and - -row[k] - -is the row index of the k-th possibly non-zero -element in -matrix -. - -
-
-col -
-This vector has size -nnz - and - -col[k] - is the column index of the k-th possibly non-zero -element in -matrix - - -
-
-val -
-This vector has size -nnz - and - -val[k] - is value of the k-th possibly non-zero entry -in the sparse matrix (the value may be zero). - -
-
-row_major -
-This vector has prototype - -
-     
SizeVector row_major
-
-and its size -nnz -. -It sorts the sparsity pattern in row-major order. -To be specific, - -
-     
colrow_major[k] ] <= colrow_major[k+1] ]
-
-and if -colrow_major[k] ] == colrow_major[k+1] ] -, - -
-     
rowrow_major[k] ] < rowrow_major[k+1] ]
-
-This routine generates an assert if there are two entries with the same -row and column values (if NDEBUG is not defined). - -
-
-col_major -
-This vector has prototype - -
-     
SizeVector col_major
-
-and its size -nnz -. -It sorts the sparsity pattern in column-major order. -To be specific, - -
-     
rowcol_major[k] ] <= rowcol_major[k+1] ]
-
-and if -rowcol_major[k] ] == rowcol_major[k+1] ] -, - -
-     
colcol_major[k] ] < colcol_major[k+1] ]
-
-This routine generates an assert if there are two entries with the same -row and column values (if NDEBUG is not defined). - - -
-
-Example -
-The file sparse_rcv.cpp - -contains an example and test of this class. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/utility/sparse_rcv.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_rcv_xml.js cppad-2019.02.00.0/doc/_sparse_rcv_xml.js --- cppad-2018.00.00.0/doc/_sparse_rcv_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_rcv_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'sparse_rcv.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'sparse_rcv.cpp.xml' -]; -var list_current0 = [ -'sparse_rcv.xml#Syntax', -'sparse_rcv.xml#SizeVector', -'sparse_rcv.xml#ValueVector', -'sparse_rcv.xml#empty', -'sparse_rcv.xml#pattern', -'sparse_rcv.xml#matrix', -'sparse_rcv.xml#target', -'sparse_rcv.xml#nr', -'sparse_rcv.xml#nc', -'sparse_rcv.xml#nnz', -'sparse_rcv.xml#set', -'sparse_rcv.xml#set.k', -'sparse_rcv.xml#set.v', -'sparse_rcv.xml#row', -'sparse_rcv.xml#col', -'sparse_rcv.xml#val', -'sparse_rcv.xml#row_major', -'sparse_rcv.xml#col_major', -'sparse_rcv.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-2018.00.00.0/doc/sparse_rc.xml cppad-2019.02.00.0/doc/sparse_rc.xml --- cppad-2018.00.00.0/doc/sparse_rc.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_rc.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,432 +0,0 @@ - - - -Row and Column Index Sparsity Patterns - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Row and Column Index Sparsity Patterns
-
-Syntax - -
- -# include <cppad/utility/sparse_rc.hpp>
-
- -sparse_rc<SizeVector>  empty
-
- -sparse_rc<SizeVector>  pattern(nrncnnz)
-
- -target = pattern
-
- -resize(nrncnnz)
-
- -pattern.set(krc)
-
- -pattern.nr()
-
- -pattern.nc()
-
- -pattern.nnz()
-
- -const SizeVectorrowpattern.row() )
-
- -const SizeVectorcolpattern.col() )
-
- -row_major = pattern.row_major()
-
- -col_major = pattern.col_major()
-
-
-SizeVector -
-We use -SizeVector - to denote SimpleVector - class -with elements of type - -size_t. - -
-
-empty -
-This is an empty sparsity pattern. To be specific, -the corresponding number of rows -nr -, -number of columns -nc -, -and number of possibly non-zero values -nnz -, -are all zero. - -
-
-pattern -
-This object is used to hold a sparsity pattern for a matrix. -The sparsity -pattern - is const -except during its constructor, resize, and set. - -
-
-target -
-The target of the assignment statement must have prototype - -
-     sparse_rc<
SizeVector>  target
-
-After this assignment statement, -target - is an independent copy -of -pattern -; i.e. it has all the same values as -pattern - -and changes to -target - do not affect -pattern -. - -
-
-nr -
-This argument has prototype - -
-     size_t 
nr
-
-It specifies the number of rows in the sparsity pattern. -The function call nr() returns the value of -nr -. - -
-
-nc -
-This argument has prototype - -
-     size_t 
nc
-
-It specifies the number of columns in the sparsity pattern. -The function call nc() returns the value of -nc -. - -
-
-nnz -
-This argument has prototype - -
-     size_t 
nnz
-
-It specifies the number of possibly non-zero -index pairs in the sparsity pattern. -The function call nnz() returns the value of -nnz -. - -
-
-resize -
-The current sparsity pattern is lost and a new one is started -with the specified parameters. The elements in the -row - -and -col - vectors should be assigned using set. - -
-
-set -
-This function sets the values - -
-     
row[k] = r
-     
col[k] = c
-
-
-k -
-This argument has type - -
-     size_t 
k
-
-and must be less than -nnz -. - -
-
-r -
-This argument has type - -
-     size_t 
r
-
-It specifies the value assigned to -row[k] - and must -be less than -nr -. - -
-
-c -
-This argument has type - -
-     size_t 
c
-
-It specifies the value assigned to -col[k] - and must -be less than -nc -. - -
-
-row -
-This vector has size -nnz - and - -row[k] - -is the row index of the k-th possibly non-zero -index pair in the sparsity pattern. - -
-
-col -
-This vector has size -nnz - and - -col[k] - is the column index of the k-th possibly non-zero -index pair in the sparsity pattern. - -
-
-row_major -
-This vector has prototype - -
-     
SizeVector row_major
-
-and its size -nnz -. -It sorts the sparsity pattern in row-major order. -To be specific, - -
-     
colrow_major[k] ] <= colrow_major[k+1] ]
-
-and if -colrow_major[k] ] == colrow_major[k+1] ] -, - -
-     
rowrow_major[k] ] < rowrow_major[k+1] ]
-
-This routine generates an assert if there are two entries with the same -row and column values (if NDEBUG is not defined). - -
-
-col_major -
-This vector has prototype - -
-     
SizeVector col_major
-
-and its size -nnz -. -It sorts the sparsity pattern in column-major order. -To be specific, - -
-     
rowcol_major[k] ] <= rowcol_major[k+1] ]
-
-and if -rowcol_major[k] ] == rowcol_major[k+1] ] -, - -
-     
colcol_major[k] ] < colcol_major[k+1] ]
-
-This routine generates an assert if there are two entries with the same -row and column values (if NDEBUG is not defined). - - -
-
-Example -
-The file sparse_rc.cpp - -contains an example and test of this class. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/utility/sparse_rc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_rc_xml.js cppad-2019.02.00.0/doc/_sparse_rc_xml.js --- cppad-2018.00.00.0/doc/_sparse_rc_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_rc_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'sparse_rc.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'sparse_rc.cpp.xml' -]; -var list_current0 = [ -'sparse_rc.xml#Syntax', -'sparse_rc.xml#SizeVector', -'sparse_rc.xml#empty', -'sparse_rc.xml#pattern', -'sparse_rc.xml#target', -'sparse_rc.xml#nr', -'sparse_rc.xml#nc', -'sparse_rc.xml#nnz', -'sparse_rc.xml#resize', -'sparse_rc.xml#set', -'sparse_rc.xml#set.k', -'sparse_rc.xml#set.r', -'sparse_rc.xml#set.c', -'sparse_rc.xml#row', -'sparse_rc.xml#col', -'sparse_rc.xml#row_major', -'sparse_rc.xml#col_major', -'sparse_rc.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-2018.00.00.0/doc/sparse_sub_hes.cpp.xml cppad-2019.02.00.0/doc/sparse_sub_hes.cpp.xml --- cppad-2018.00.00.0/doc/sparse_sub_hes.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparse_sub_hes.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,226 +0,0 @@ - - - -Subset of a Sparse Hessian: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sparse_sub_hes.cpp - -

-
Subset of a Sparse Hessian: Example and Test
-
-Purpose -
-This example uses a -column subset - of the sparsity pattern -to compute a subset of the Hessian. - -
-
-See Also - -
-sub_sparse_hes.cpp - - - -
# include <cppad/cppad.hpp>
-bool sparse_sub_hes(void)
-{     bool ok = true;
-     using CppAD::AD;
-     typedef CPPAD_TESTVECTOR(size_t)     SizeVector;
-     typedef CPPAD_TESTVECTOR(double)     DoubleVector;
-     typedef CppAD::sparse_rc<SizeVector> sparsity;
-     //
-     // domain space vector
-     size_t n = 4;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     for(size_t j = 0; j < n; j++)
-          ax[j] = double(j);
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = 0.0;
-     for(size_t j = 0; j < n; j++)
-          ay[0] += double(j+1) * ax[0] * ax[j];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-     // sparsity pattern for the identity matrix
-     size_t nr     = n;
-     size_t nc     = n;
-     size_t nnz_in = n;
-     sparsity pattern_in(nr, nc, nnz_in);
-     for(size_t k = 0; k < nnz_in; k++)
-     {     size_t r = k;
-          size_t c = k;
-          pattern_in.set(k, r, c);
-     }
-     // compute sparsity pattern for J(x) = f'(x)
-     bool transpose       = false;
-     bool dependency      = false;
-     bool internal_bool   = false;
-     sparsity pattern_out;
-     f.for_jac_sparsity(
-          pattern_in, transpose, dependency, internal_bool, pattern_out
-     );
-     //
-     // compute sparsity pattern for H(x) = f''(x)
-     CPPAD_TESTVECTOR(bool) select_range(m);
-     select_range[0]      = true;
-     CppAD::sparse_hes_work work;
-     f.rev_hes_sparsity(
-          select_range, transpose, internal_bool, pattern_out
-     );
-     size_t nnz = pattern_out.nnz();
-     ok        &= nnz == 7;
-     ok        &= pattern_out.nr() == n;
-     ok        &= pattern_out.nc() == n;
-     {     // check results
-          const SizeVector& row( pattern_out.row() );
-          const SizeVector& col( pattern_out.col() );
-          SizeVector row_major = pattern_out.row_major();
-          //
-          ok &= row[ row_major[0] ] ==  0  && col[ row_major[0] ] ==  0;
-          ok &= row[ row_major[1] ] ==  0  && col[ row_major[1] ] ==  1;
-          ok &= row[ row_major[2] ] ==  0  && col[ row_major[2] ] ==  2;
-          ok &= row[ row_major[3] ] ==  0  && col[ row_major[3] ] ==  3;
-          //
-          ok &= row[ row_major[4] ] ==  1  && col[ row_major[4] ] ==  0;
-          ok &= row[ row_major[5] ] ==  2  && col[ row_major[5] ] ==  0;
-          ok &= row[ row_major[6] ] ==  3  && col[ row_major[6] ] ==  0;
-     }
-     //
-     // Only interested in cross-terms. Since we are not computing rwo 0,
-     // we do not need sparsity entries in row 0.
-     CppAD::sparse_rc<SizeVector> subset_pattern(n, n, 3);
-     for(size_t k = 0; k < 3; k++)
-          subset_pattern.set(k, k+1, 0);
-     CppAD::sparse_rcv<SizeVector, DoubleVector> subset( subset_pattern );
-     //
-     // argument and weight values for computation
-     CPPAD_TESTVECTOR(double) x(n), w(m);
-     for(size_t j = 0; j < n; j++)
-          x[j] = double(n) / double(j+1);
-     w[0] = 1.0;
-     //
-     std::string coloring = "cppad.general";
-     size_t n_sweep = f.sparse_hes(
-          x, w, subset, subset_pattern, coloring, work
-     );
-     ok &= n_sweep == 1;
-     for(size_t k = 0; k < 3; k++)
-     {     size_t i = k + 1;
-          ok &= subset.val()[k] == double(i + 1);
-     }
-     //
-     // convert subset from lower triangular to upper triangular
-     for(size_t k = 0; k < 3; k++)
-          subset_pattern.set(k, 0, k+1);
-     subset = CppAD::sparse_rcv<SizeVector, DoubleVector>( subset_pattern );
-     //
-     // This will require more work because the Hessian is computed
-     // column by column (not row by row).
-     work.clear();
-     n_sweep = f.sparse_hes(
-          x, w, subset, subset_pattern, coloring, work
-     );
-     ok &= n_sweep == 3;
-     //
-     // but it will get the right answer
-     for(size_t k = 0; k < 3; k++)
-     {     size_t i = k + 1;
-          ok &= subset.val()[k] == double(i + 1);
-     }
-     return ok;
-}
-
-
Input File: example/sparse/sparse_sub_hes.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparse_sub_hes.cpp_xml.js cppad-2019.02.00.0/doc/_sparse_sub_hes.cpp_xml.js --- cppad-2018.00.00.0/doc/_sparse_sub_hes.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparse_sub_hes.cpp_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', -'adfun.xml', -'sparse_derivative.xml', -'sparse_hessian.xml', -'sparse_sub_hes.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.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-2018.00.00.0/doc/sparsity_pattern.xml cppad-2019.02.00.0/doc/sparsity_pattern.xml --- cppad-2018.00.00.0/doc/sparsity_pattern.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparsity_pattern.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,155 +0,0 @@ - - - -Calculating Sparsity Patterns - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Calculating Sparsity Patterns
-
-Preferred Sparsity Patterns - - - - - - - -
- -for_jac_sparsity -Forward Mode Jacobian Sparsity Patterns
- -rev_jac_sparsity -Reverse Mode Jacobian Sparsity Patterns
- -for_hes_sparsity -Forward Mode Hessian Sparsity Patterns
- -rev_hes_sparsity -Reverse Mode Hessian Sparsity Patterns
- -subgraph_sparsity -Subgraph Dependency Sparsity Patterns
- -
-
-Old Sparsity Patterns - - - - - - -
- -ForSparseJac -Jacobian Sparsity Pattern: Forward Mode
- -RevSparseJac -Jacobian Sparsity Pattern: Reverse Mode
- -ForSparseHes -Hessian Sparsity Pattern: Forward Mode
- -RevSparseHes -Hessian Sparsity Pattern: Reverse Mode
- -
- -
Input File: omh/adfun.omh - - - diff -Nru cppad-2018.00.00.0/doc/_sparsity_pattern_xml.js cppad-2019.02.00.0/doc/_sparsity_pattern_xml.js --- cppad-2018.00.00.0/doc/_sparsity_pattern_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparsity_pattern_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', -'adfun.xml', -'sparsity_pattern.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down0 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_current0 = [ -'sparsity_pattern.xml#Preferred Sparsity Patterns', -'sparsity_pattern.xml#Old Sparsity Patterns' -]; -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-2018.00.00.0/doc/sparsity_sub.cpp.xml cppad-2019.02.00.0/doc/sparsity_sub.cpp.xml --- cppad-2018.00.00.0/doc/sparsity_sub.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sparsity_sub.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,197 +0,0 @@ - - - -Sparsity Patterns For a Subset of Variables: Example and Test - - - - - - - - - - - - - - - - -
- -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/sparse/sparsity_sub.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sparsity_sub.cpp_xml.js cppad-2019.02.00.0/doc/_sparsity_sub.cpp_xml.js --- cppad-2018.00.00.0/doc/_sparsity_sub.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sparsity_sub.cpp_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', -'adfun.xml', -'sparsity_pattern.xml', -'revsparsehes.xml', -'sparsity_sub.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.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-2018.00.00.0/doc/speed_adolc.xml cppad-2019.02.00.0/doc/speed_adolc.xml --- cppad-2018.00.00.0/doc/speed_adolc.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/speed_adolc.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ - - - -Speed Test of Derivatives Using Adolc - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Speed Test of Derivatives Using Adolc
-
-Purpose -
-CppAD has a set of speed tests that are used to compare -Adolc with other AD packages. -This section links to the source code the Adolc speed tests -(any suggestions to make the Adolc results faster are welcome). - -
-
-adolc_prefix -
-To run these tests, -you must include the adolc_prefix - -in you cmake command -. - - -
-
-Running Tests -
-To build these speed tests, and run their correctness tests, -execute the following commands starting in the -build directory -: - -
-     cd speed/adolc
-     make check_speed_adolc VERBOSE=1
-
-You can then run the corresponding speed tests -with the following command - -
-     ./speed_adolc speed 
seed
-
-where -seed - is a positive integer. -See speed_main - for more options. - -
-
-Contents -
- -
Input File: omh/speed/speed_adolc.omh - - - diff -Nru cppad-2018.00.00.0/doc/_speed_adolc_xml.js cppad-2019.02.00.0/doc/_speed_adolc_xml.js --- cppad-2018.00.00.0/doc/_speed_adolc_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speed_adolc_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', -'speed.xml', -'speed_adolc.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down0 = [ -'adolc_det_minor.cpp.xml', -'adolc_det_lu.cpp.xml', -'adolc_mat_mul.cpp.xml', -'adolc_ode.cpp.xml', -'adolc_poly.cpp.xml', -'adolc_sparse_hessian.cpp.xml', -'adolc_sparse_jacobian.cpp.xml', -'adolc_alloc_mat.xml' -]; -var list_current0 = [ -'speed_adolc.xml#Purpose', -'speed_adolc.xml#adolc_prefix', -'speed_adolc.xml#Running Tests', -'speed_adolc.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-2018.00.00.0/doc/speed_cppad.xml cppad-2019.02.00.0/doc/speed_cppad.xml --- cppad-2018.00.00.0/doc/speed_cppad.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/speed_cppad.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ - - - -Speed Test Derivatives Using CppAD - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - - -
Speed Test Derivatives Using CppAD
-
-Purpose -
-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 -(any suggestions to make the CppAD results faster are welcome). - - -
-
-Running Tests -
-To build these speed tests, and run their correctness tests, -execute the following commands starting in the -build directory -: - -
-     cd speed/cppad
-     make check_speed_cppad VERBOSE=1
-
-You can then run the corresponding speed tests -with the following command - -
-     ./speed_cppad speed 
seed
-
-where -seed - is a positive integer. -See speed_main - for more options. - -
-
-Contents -
- -
Input File: omh/speed/speed_cppad.omh - - - diff -Nru cppad-2018.00.00.0/doc/_speed_cppad_xml.js cppad-2019.02.00.0/doc/_speed_cppad_xml.js --- cppad-2018.00.00.0/doc/_speed_cppad_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speed_cppad_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', -'speed.xml', -'speed_cppad.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down0 = [ -'cppad_det_minor.cpp.xml', -'cppad_det_lu.cpp.xml', -'cppad_mat_mul.cpp.xml', -'cppad_ode.cpp.xml', -'cppad_poly.cpp.xml', -'cppad_sparse_hessian.cpp.xml', -'cppad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'speed_cppad.xml#Purpose', -'speed_cppad.xml#Running Tests', -'speed_cppad.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-2018.00.00.0/doc/speed_double.xml cppad-2019.02.00.0/doc/speed_double.xml --- cppad-2018.00.00.0/doc/speed_double.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/speed_double.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ - - - -Speed Test of Functions in Double - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - - -
Speed Test of Functions in Double
-
-Purpose -
-CppAD has a set of speed tests for just calculating functions -(in double precision instead of an AD type). -This section links to the source code the function value speed tests. - -
-
-Running Tests -
-To build these speed tests, and run their correctness tests, -execute the following commands starting in the -build directory -: - -
-     cd speed/double
-     make check_speed_double VERBOSE=1
-
-You can then run the corresponding speed tests -with the following command - -
-     ./speed_double speed 
seed
-
-where -seed - is a positive integer. -See speed_main - for more options. - -
-
-Contents -
- -
Input File: omh/speed/speed_double.omh - - - diff -Nru cppad-2018.00.00.0/doc/_speed_double_xml.js cppad-2019.02.00.0/doc/_speed_double_xml.js --- cppad-2018.00.00.0/doc/_speed_double_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speed_double_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', -'speed.xml', -'speed_double.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down0 = [ -'double_det_minor.cpp.xml', -'double_det_lu.cpp.xml', -'double_mat_mul.cpp.xml', -'double_ode.cpp.xml', -'double_poly.cpp.xml', -'double_sparse_hessian.cpp.xml', -'double_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'speed_double.xml#Purpose', -'speed_double.xml#Running Tests', -'speed_double.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-2018.00.00.0/doc/speed_example.cpp.xml cppad-2019.02.00.0/doc/speed_example.cpp.xml --- cppad-2018.00.00.0/doc/speed_example.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/speed_example.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,192 +0,0 @@ - - - -Run the Speed Examples - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -speed_example.cpp - -

-
Run the Speed Examples
-
-Running Tests -
-To build this program and run its correctness tests see cmake_check -. - - - -

-# include <cppad/cppad.hpp>
-
-// various example routines
-extern bool det_of_minor(void);
-extern bool det_by_lu(void);
-extern bool det_by_minor(void);
-extern bool elapsed_seconds(void);
-extern bool mat_sum_sq(void);
-extern bool ode_evaluate(void);
-extern bool sparse_hes_fun(void);
-extern bool sparse_jac_fun(void);
-extern bool speed_test(void);
-extern bool time_test(void);
-
-namespace {
-     // function that runs one test
-     size_t Run_ok_count    = 0;
-     size_t Run_error_count = 0;
-     const char* exception_list[] = {
-          "elapsed_seconds",
-          "speed_test",
-          "time_test"
-     };
-     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::cout.width( width );
-          std::cout.setf( std::ios_base::left );
-          std::cout << name;
-          bool exception = false;
-          for(size_t i = 0; i < n_exception; i++)
-               exception |= exception_list[i] == name;
-          //
-          ok &= name.size() < size_t(width);
-          ok &= TestOk();
-          if( ok )
-          {     std::cout << "OK" << std::endl;
-               Run_ok_count++;
-          }
-          else if ( exception )
-          {     std::cout << "Error: perhaps too many other programs running";
-               std::cout << std::endl;
-               // no change to Run_ok_count
-               ok = true;
-          }
-          else
-          {     std::cout << "Error" << std::endl;
-               Run_error_count++;
-          }
-          return ok;
-     }
-}
-
-// main program that runs all the tests
-int main(void)
-{     bool ok = true;
-     using std::cout;
-     using std::endl;
-
-     ok &= Run(det_of_minor,          "det_of_minor"   );
-     ok &= Run(det_by_minor,         "det_by_minor"    );
-     ok &= Run(det_by_lu,               "det_by_lu"    );
-     ok &= Run(elapsed_seconds,   "elapsed_seconds"    );
-     ok &= Run(mat_sum_sq,             "mat_sum_sq"    );
-     ok &= Run(ode_evaluate,         "ode_evaluate"    );
-     ok &= Run(sparse_hes_fun,    "sparse_hes_fun"     );
-     ok &= Run(sparse_jac_fun,    "sparse_jac_fun"     );
-     ok &= Run(speed_test,             "speed_test"    );
-     ok &= Run(time_test,               "time_test"    );
-     assert( ok || (Run_error_count > 0) );
-
-     // check for memory leak in previous calculations
-     if( ! CppAD::thread_alloc::free_all() )
-     {     ok = false;
-          cout << "Error: memroy leak detected" << endl;
-     }
-
-     if( ok )
-     {     cout << "All " << int(Run_ok_count) << " tests passed ";
-          cout << "(possibly excepting elapsed_seconds).";
-     }
-     else     cout << int(Run_error_count) << " tests failed.";
-     cout << endl;
-
-
-     return static_cast<int>( ! ok );
-}
-
-
-
Input File: speed/example/example.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_speed_example.cpp_xml.js cppad-2019.02.00.0/doc/_speed_example.cpp_xml.js --- cppad-2018.00.00.0/doc/_speed_example.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speed_example.cpp_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', -'example.xml', -'exampleutility.xml', -'speed_example.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'general.cpp.xml', -'speed_example.cpp.xml', -'lu_vec_ad.cpp.xml' -]; -var list_current0 = [ -'speed_example.cpp.xml#Running Tests' -]; -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-2018.00.00.0/doc/speed_fadbad.xml cppad-2019.02.00.0/doc/speed_fadbad.xml --- cppad-2018.00.00.0/doc/speed_fadbad.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/speed_fadbad.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,155 +0,0 @@ - - - -Speed Test Derivatives Using Fadbad - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Speed Test Derivatives Using Fadbad
-
-Purpose -
-CppAD has a set of speed tests that are used to compare -Fadbad with other AD packages. -This section links to the source code the Fadbad speed tests -(any suggestions to make the Fadbad results faster are welcome). - -
-
-fadbad_prefix -
-To run these tests, -you must include the fadbad_prefix - -in you cmake command -. - - -
-
-Running Tests -
-To build these speed tests, and run their correctness tests, -execute the following commands starting in the -build directory -: - -
-     cd speed/fadbad
-     make check_speed_fadbad VERBOSE=1
-
-You can then run the corresponding speed tests -with the following command - -
-     ./speed_fadbad speed 
seed
-
-where -seed - is a positive integer. -See speed_main - for more options. - -
-
-Contents -
- -
Input File: omh/speed/speed_fadbad.omh - - - diff -Nru cppad-2018.00.00.0/doc/_speed_fadbad_xml.js cppad-2019.02.00.0/doc/_speed_fadbad_xml.js --- cppad-2018.00.00.0/doc/_speed_fadbad_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speed_fadbad_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_fadbad.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down0 = [ -'fadbad_det_minor.cpp.xml', -'fadbad_det_lu.cpp.xml', -'fadbad_mat_mul.cpp.xml', -'fadbad_ode.cpp.xml', -'fadbad_poly.cpp.xml', -'fadbad_sparse_hessian.cpp.xml', -'fadbad_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'speed_fadbad.xml#Purpose', -'speed_fadbad.xml#fadbad_prefix', -'speed_fadbad.xml#Running Tests', -'speed_fadbad.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-2018.00.00.0/doc/speed_main.xml cppad-2019.02.00.0/doc/speed_main.xml --- cppad-2018.00.00.0/doc/speed_main.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/speed_main.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,574 +0,0 @@ - - - -Running the Speed Test Program - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Running the Speed Test Program
-
-Syntax - -
- -speed/package/speed_package test seed option_list - - -
-
-Purpose -
-A version of this program runs the correctness tests -or the speed tests for one AD package identified by -package -. - -
-
-package - - -
-
-AD Package -
-The command line argument - -package - specifies one of the AD package. -The CppAD distribution comes with support for the following packages: -adolc -, -cppad -, -fadbad -, -sacado -. -You can extend this program to include other package. -Such an extension need not include all the tests. -For example, -link_sparse_hessian - just returns false for the -fadbad - and -sacado - packages. - - -
-
-double -
-The value - -package - can be double in which case -the function values (instead of derivatives) are computed -using double precision operations. -This enables one to compare the speed of computing function -values in 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 double.) - -
-
-profile -
-In the special case where -package - is profile, -the CppAD package is compiled and run with profiling to aid in determining -where it is spending most of its time. - -
-
-test -
-It the argument -test - specifies which test to run -and has the following possible values: -correct -, -speed -, -det_minor -, -det_lu -, -mat_mul -, -ode -, -poly -, -sparse_hessian -, -sparse_jacobian -. -You can experiment with changing the implementation of a -particular test for a particular package. - -
-
-correct -
-If -test - is equal to correct, -all of the correctness tests are run. - -
-
-speed -
-If -test - is equal to speed, -all of the speed tests are run. - -
-
-seed -
-The command line argument -seed - is an unsigned integer -(all its characters are between 0 and 9). -The random number simulator uniform_01 - is initialized with -the call - -
-     uniform_01(
seed)
-
-before any of the testing routines (listed above) are called. - -
-
-Global Options -
-This global variable has prototype -

-     extern std::map<std::string, bool> global_option;
-
-The syntax - -
-     global_option["
option"]
-
-has the value true, if -option - is present, -and false otherwise. -This is true for each option that follows -seed -. -The order of the options does not matter and the list can be empty. -Each option, is be a separate command line argument to the main program. -The documentation below specifics how -speed_cppad - uses these options, -see the examples in speed_adolc - for how another package might -uses these options. - -
-
-onetape -
-If this option is present, -speed_cppad - will use one taping of the operation -sequence for all the repetitions of that speed test. -Otherwise, the -operation sequence - -will be retaped for each test repetition. -
-
-
All of the tests, except det_lu -, -have the same operation sequence for each repetition. -The operation sequence for det_lu -may be different because it depends on the matrix for which the determinant -is being calculated. -For this reason, cppad_det_lu.cpp - returns false, -to indicate that the test not implemented, -when global_onetape is true. - -
-
-memory -
-This option is special because individual CppAD speed tests need not do -anything different if this option is true or false. -If the memory option is present, the CppAD -hold_memory - routine will be called by -the speed test main program before any of the tests are executed -This should make the CppAD thread_alloc allocator faster. -If it is not present, CppAD will used standard memory allocation. -Another package might use this option for a different -memory allocation method. - -
-
-optimize -
-If this option is present, -CppAD will optimize - -the operation sequence before doing computations. -If it is false, this optimization will not be done. -Note that this option is usually slower unless it is combined with the -onetape option. - -
-
-atomic -
-If this option is present, -CppAD will use a user defined -atomic - operation is used for the test. -So far, CppAD has only implemented -the mat_mul - test as an atomic operation. - -
-
-hes2jac -
-If this option is present, -speed_cppad - will compute hessians as the Jacobian -of the gradient. -This is accomplished using -multiple levels - of AD. -So far, CppAD has only implemented -the sparse_hessian - -test in this manner. - -
-
-subgraph -
-If this option is present, -speed_cppad - will compute sparse Jacobians using subgraphs. -The CppAD sparse_jacobian - -test is implemented for this option. -In addition, the CppAD sparse_hessian - -test is implemented for this option when hes2jac is present. - -
-
-Sparsity Options -
-The following options only apply to the -sparse_jacobian - and -sparse_hessian - tests. -The other tests return false when any of these options -are present. - -
-
-boolsparsity -
-If this option is present, CppAD will use a -vectors of bool - -to compute sparsity patterns. -Otherwise CppAD will use -vectors of sets -. - -
-
-revsparsity -
-If this option is present, -CppAD will use reverse mode for to compute sparsity patterns. -Otherwise CppAD will use forward mode. - -
-
-subsparsity -
-If this option is present, -CppAD will use subgraphs to compute sparsity patterns. -If either the boolsparsity or revsparsity is also present, -the CppAD speed tests will return false; i.e., these options are not -supported by subgraph_sparsity -. - -
-
-colpack -
-If this option is present, -CppAD will use colpack - to do the coloring. -Otherwise, it will use it's own coloring algorithm. - -
-
-Correctness Results -
-One, but not both, of the following two output lines - -
-     
package_test_optionlist_available = false
-     
package_test_optionlist_ok = flag
-
-is generated for each correctness test where - -package - and -test - are as above, - -optionlist - are the options (in -option_list -) -separated by the underbar _ character -(whereas they are separated by spaces in -option_list -), -and -flag - is true or false. - -
-
-Speed Results -
-For each speed test, corresponds to three lines of the -following form are generated: - -
-     
package_test_optionlist_ok   = flag
-     
package_test_size = [ size_1...size_n ]
-     
package_test_rate = [ rate_1...rate_n ]
-
-The values -package -, -test -, -optionlist -, -and -flag - are as in the correctness results above. -The values -size_1 -, ..., -size_n - are the -size arguments used for the corresponding tests. -The values -rate_1 -, ..., -rate_n - are the number of times -per second that the corresponding size problem executed. - -
-
-n_sweep -
-The sparse_jacobian - -and sparse_hessian - tests has an extra output -line with the following form - -
-     
package_sparse_test_n_sweep = [ n_sweep_1...n_sweep_n ]
-
-were -test - is jacobian (hessian). -The values -n_sweep_1 -, ..., -n_sweep_n - are the number of -sweeps (colors) used for each sparse Jacobian (Hessian) calculation; see - -n_sweep - for -sparse_jacobian - and -sparse_hessian -. - - - - -
-
-Link Functions -
-Each package - -defines it's own version of one of the link functions listed below. -Each of these functions links this main program to the corresponding test: - - - - - - - - -
- -link_det_lu -Speed Testing Gradient of Determinant Using Lu Factorization
- -link_det_minor -Speed Testing Gradient of Determinant by Minor Expansion
- -link_mat_mul -Speed Testing Derivative of Matrix Multiply
- -link_ode -Speed Testing the Jacobian of Ode Solution
- -link_poly -Speed Testing Second Derivative of a Polynomial
- -link_sparse_hessian -Speed Testing Sparse Hessian
- -link_sparse_jacobian -Speed Testing Sparse Jacobian
- -
- -
Input File: speed/main.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_speed_main_xml.js cppad-2019.02.00.0/doc/_speed_main_xml.js --- cppad-2018.00.00.0/doc/_speed_main_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speed_main_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_main.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down0 = [ -'link_det_lu.xml', -'link_det_minor.xml', -'link_mat_mul.xml', -'link_ode.xml', -'link_poly.xml', -'link_sparse_hessian.xml', -'link_sparse_jacobian.xml', -'microsoft_timer.xml' -]; -var list_current0 = [ -'speed_main.xml#Syntax', -'speed_main.xml#Purpose', -'speed_main.xml#package', -'speed_main.xml#package.AD Package', -'speed_main.xml#package.double', -'speed_main.xml#package.profile', -'speed_main.xml#test', -'speed_main.xml#test.correct', -'speed_main.xml#test.speed', -'speed_main.xml#seed', -'speed_main.xml#Global Options', -'speed_main.xml#Global Options.onetape', -'speed_main.xml#Global Options.memory', -'speed_main.xml#Global Options.optimize', -'speed_main.xml#Global Options.atomic', -'speed_main.xml#Global Options.hes2jac', -'speed_main.xml#Global Options.subgraph', -'speed_main.xml#Sparsity Options', -'speed_main.xml#Sparsity Options.boolsparsity', -'speed_main.xml#Sparsity Options.revsparsity', -'speed_main.xml#Sparsity Options.subsparsity', -'speed_main.xml#Sparsity Options.colpack', -'speed_main.xml#Correctness Results', -'speed_main.xml#Speed Results', -'speed_main.xml#Speed Results.n_sweep', -'speed_main.xml#Link Functions' -]; -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-2018.00.00.0/doc/speed_program.cpp.xml cppad-2019.02.00.0/doc/speed_program.cpp.xml --- cppad-2018.00.00.0/doc/speed_program.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/speed_program.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,181 +0,0 @@ - - - -Example Use of SpeedTest - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -speed_program.cpp - -

-
Example Use of SpeedTest
-
-Running This Program -
-On a Unix system that includes the g++ compiler, -you can compile and run this program by changing into the -speed/example directory and executing the following commands -
 
-     g++ -I../.. speed_program.cpp -o speed_program.exe
-     ./speed_program.exe
-
-
-Program - -
# include <cppad/utility/speed_test.hpp>
-
-std::string Test(size_t size, size_t repeat)
-{     // setup
-     double *a = new double[size];
-     double *b = new double[size];
-     double *c = new double[size];
-     size_t i  = size;;
-     while(i)
-     {     --i;
-          a[i] = i;
-          b[i] = 2 * i;
-     }
-     // operations we are timing
-     while(repeat--)
-     {     i = size;;
-          while(i)
-          {     --i;
-               c[i] = a[i] + b[i];
-          }
-     }
-     // teardown
-     delete [] a;
-     delete [] b;
-     delete [] c;
-
-     // return a test name that is valid for all sizes and repeats
-     return "double: c[*] = a[*] + b[*]";
-}
-int main(void)
-{
-     CppAD::SpeedTest(Test, 10, 10, 100);
-     return 0;
-}
-
-Output -
-Executing of the program above generated the following output -(the rates will be different for each particular system): -
 
-     double: c[*] = a[*] + b[*]
-     size = 10  rate = 14,122,236
-     size = 20  rate = 7,157,515
-     size = 30  rate = 4,972,500
-     size = 40  rate = 3,887,214
-     size = 50  rate = 3,123,086
-     size = 60  rate = 2,685,214
-     size = 70  rate = 2,314,737
-     size = 80  rate = 2,032,124
-     size = 90  rate = 1,814,145
-     size = 100 rate = 1,657,828
-
- -
Input File: speed/example/speed_program.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_speed_program.cpp_xml.js cppad-2019.02.00.0/doc/_speed_program.cpp_xml.js --- cppad-2018.00.00.0/doc/_speed_program.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speed_program.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'speedtest.xml', -'speed_program.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'speed_program.cpp.xml' -]; -var list_current0 = [ -'speed_program.cpp.xml#Running This Program', -'speed_program.cpp.xml#Program', -'speed_program.cpp.xml#Output' -]; -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-2018.00.00.0/doc/speed_sacado.xml cppad-2019.02.00.0/doc/speed_sacado.xml --- cppad-2018.00.00.0/doc/speed_sacado.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/speed_sacado.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,155 +0,0 @@ - - - -Speed Test Derivatives Using Sacado - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Speed Test Derivatives Using Sacado
-
-Purpose -
-CppAD has a set of speed tests that are used to compare -Sacado with other AD packages. -This section links to the source code the Sacado speed tests -(any suggestions to make the Sacado results faster are welcome). - -
-
-sacado_prefix -
-To run these tests, -you must include the sacado_prefix - -in you cmake command -. - - -
-
-Running Tests -
-To build these speed tests, and run their correctness tests, -execute the following commands starting in the -build directory -: - -
-     cd speed/sacado
-     make check_speed_sacado VERBOSE=1
-
-You can then run the corresponding speed tests -with the following command - -
-     ./speed_sacado speed 
seed
-
-where -seed - is a positive integer. -See speed_main - for more options. - -
-
-Contents -
- -
Input File: omh/speed/speed_sacado.omh - - - diff -Nru cppad-2018.00.00.0/doc/_speed_sacado_xml.js cppad-2019.02.00.0/doc/_speed_sacado_xml.js --- cppad-2018.00.00.0/doc/_speed_sacado_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speed_sacado_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_sacado.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down0 = [ -'sacado_det_minor.cpp.xml', -'sacado_det_lu.cpp.xml', -'sacado_mat_mul.cpp.xml', -'sacado_ode.cpp.xml', -'sacado_poly.cpp.xml', -'sacado_sparse_hessian.cpp.xml', -'sacado_sparse_jacobian.cpp.xml' -]; -var list_current0 = [ -'speed_sacado.xml#Purpose', -'speed_sacado.xml#sacado_prefix', -'speed_sacado.xml#Running Tests', -'speed_sacado.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-2018.00.00.0/doc/speed_test.cpp.xml cppad-2019.02.00.0/doc/speed_test.cpp.xml --- cppad-2018.00.00.0/doc/speed_test.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/speed_test.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ - - - -speed_test: Example and test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -speed_test.cppHeadings

- - - - -
speed_test: Example and test
-
# include <cppad/utility/speed_test.hpp>
-# include <cppad/utility/vector.hpp>
-
-namespace { // empty namespace
-     using CppAD::vector;
-     vector<double> a, b, c;
-     void test(size_t size, size_t repeat)
-     {     // setup
-          a.resize(size);
-          b.resize(size);
-          c.resize(size);
-          size_t i  = size;;
-          while(i)
-          {     --i;
-               a[i] = double(i);
-               b[i] = double(2 * i);
-               c[i] = 0.0;
-          }
-          // operations we are timing
-          while(repeat--)
-          {     i = size;;
-               while(i)
-               {     --i;
-                    c[i] += std::sqrt(a[i] * a[i] + b[i] * b[i]);
-               }
-          }
-     }
-}
-bool speed_test(void)
-{     bool ok = true;
-
-     // size of the test cases
-     vector<size_t> size_vec(2);
-     size_vec[0] = 40;
-     size_vec[1] = 80;
-
-     // minimum amount of time to run test
-     double time_min = 0.5;
-
-     // run the test cases
-     vector<size_t> rate_vec(2);
-     rate_vec = CppAD::speed_test(test, size_vec, time_min);
-
-     // time per repeat loop (note counting setup or teardown)
-     double time_0 = 1. / double(rate_vec[0]);
-     double time_1 = 1. / double(rate_vec[1]);
-
-     // for this case, time should be linear w.r.t size
-     double check    = double(size_vec[1]) * time_0 / double(size_vec[0]);
-     double rel_diff = (check - time_1) / time_1;
-     ok             &= (std::fabs(rel_diff) <= .1);
-     if( ! ok )
-          std::cout << std::endl << "rel_diff = " << rel_diff << std::endl;
-
-     a.clear();
-     b.clear();
-     c.clear();
-     return ok;
-}
-
-
Input File: speed/example/speed_test.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_speed_test.cpp_xml.js cppad-2019.02.00.0/doc/_speed_test.cpp_xml.js --- cppad-2018.00.00.0/doc/_speed_test.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speed_test.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'speed_test.xml', -'speed_test.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'speed_test.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-2018.00.00.0/doc/speed_test.xml cppad-2019.02.00.0/doc/speed_test.xml --- cppad-2018.00.00.0/doc/speed_test.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/speed_test.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,326 +0,0 @@ - - - -Run One Speed Test and Return Results - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Run One Speed Test and Return Results
-
-Syntax - -
- -# include <cppad/utility/speed_test.hpp>
-
- -rate_vec = speed_test(testsize_vectime_min) - - -
-
-Purpose -
-The speed_test function executes a speed test -for various sized problems -and reports the rate of execution. - -
-
-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 speed_test -automatically determines how many times to -repeat the section of the test that we wish to time. - - -
-
-Include -
-The file cppad/speed_test.hpp defines the -speed_test function. -This file is included by cppad/cppad.hpp -and it can also be included separately with out the rest of -the CppAD routines. - -
-
-Vector -
-We use -Vector - to denote a -simple vector class - with elements -of type size_t. - -
-
-test -
-The speed_test argument -test - is a function with the syntax - -
-     
test(sizerepeat)
-
-and its return value is void. - -
-
-size -
-The -test - argument -size - has prototype - -
-     size_t 
size
-
-It specifies the size for this test. - -
-
-repeat -
-The -test - argument -repeat - has prototype - -
-     size_t 
repeat
-
-It specifies the number of times to repeat the test. - -
-
-size_vec -
-The speed_test argument -size_vec - has prototype - -
-     const 
Vectorsize_vec
-
-This vector determines the size for each of the tests problems. - -
-
-time_min -
-The argument -time_min - has prototype - -
-     double 
time_min
-
-It specifies the minimum amount of time in seconds -that the -test - routine should take. -The -repeat - argument to -test - is increased -until this amount of execution time is reached. - -
-
-rate_vec -
-The return value -rate_vec - has prototype - -
-     
Vectorrate_vec
-
-We use - -n - - - to denote its size which is the same as -the vector -size_vec -. -For - -i -= -0 -, - -, -n --1 - - -, - -
-     
rate_vec[i]
-
-is the ratio of -repeat - divided by time in seconds -for the problem with size -size_vec[i] -. - -
-
-Timing -
-If your system supports the unix gettimeofday function, -it will be used to measure time. -Otherwise, -time is measured by the difference in -
 
-     (double) clock() / (double) CLOCKS_PER_SEC
-
-in the context of the standard <ctime> definitions. - - -
-
-Example -
-The routine speed_test.cpp - is an example and test -of speed_test. - - -
Input File: cppad/utility/speed_test.hpp - - - diff -Nru cppad-2018.00.00.0/doc/speedtest.xml cppad-2019.02.00.0/doc/speedtest.xml --- cppad-2018.00.00.0/doc/speedtest.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/speedtest.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,362 +0,0 @@ - - - -Run One Speed Test and Print Results - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - - -
Run One Speed Test and Print Results
-
-Syntax - - -
- -# include <cppad/utility/speed_test.hpp>
-
- -SpeedTest(Testfirstinclast) - - - -
-
-Purpose -
-The SpeedTest function executes a speed test -for various sized problems -and reports the results on standard output; i.e. std::cout. -The size of each test problem is included in its report -(unless -first - is equal to -last -). - -
-
-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 SpeedTest -automatically determines how many times to -repeat the section of the test that we wish to time. - - -
-
-Include -
-The file speed_test.hpp contains the -SpeedTest function. -This file is included by cppad/cppad.hpp -but it can also be included separately with out the rest of -the CppAD routines. - -
-
-Test -
-The SpeedTest argument -Test - is a function with the syntax - -
-     
name = Test(sizerepeat)
-
-
-size -
-The -Test - argument -size - has prototype - -
-     size_t 
size
-
-It specifies the size for this test. - -
-
-repeat -
-The -Test - argument -repeat - has prototype - -
-     size_t 
repeat
-
-It specifies the number of times to repeat the test. - -
-
-name -
-The -Test - result -name - has prototype - -
-     std::string 
name
-
-The results for this test are reported on std::cout -with -name - as an identifier for the test. -It is assumed that, -for the duration of this call to SpeedTest, - -Test - will always return -the same value for -name -. -If -name - is the empty string, -no test name is reported by SpeedTest. - -
-
-first -
-The SpeedTest argument -first - has prototype - -
-     size_t 
first
-
-It specifies the size of the first test problem reported by this call to -SpeedTest. - -
-
-last -
-The SpeedTest argument -last - has prototype - -
-     size_t 
last
-
-It specifies the size of the last test problem reported by this call to -SpeedTest. - -
-
-inc -
-The SpeedTest argument -inc - has prototype - -
-     int 
inc
-
-It specifies the increment between problem sizes; i.e., -all values of -size - in calls to -Test - are given by - -
-     
size = first + j * inc
-
-where -j - is a positive integer. -The increment can be positive or negative but it cannot be zero. -The values -first -, -last - and -inc - must -satisfy the relation - - -inc -* -( -last -- -first -) - -0 - - -
-rate -
-The value displayed in the rate column on std::cout -is defined as the value of -repeat - divided by the -corresponding elapsed execution time in seconds. -The elapsed execution time is measured by the difference in -
 
-     (double) clock() / (double) CLOCKS_PER_SEC
-
-in the context of the standard <ctime> definitions. - - -
-
-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 -ErrorHandler - - -
-
-Example - -
-The program speed_program.cpp - is an example usage -of SpeedTest. - - -
Input File: cppad/utility/speed_test.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_speed_test_xml.js cppad-2019.02.00.0/doc/_speed_test_xml.js --- cppad-2018.00.00.0/doc/_speed_test_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speed_test_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'speed_test.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'speed_test.cpp.xml' -]; -var list_current0 = [ -'speed_test.xml#Syntax', -'speed_test.xml#Purpose', -'speed_test.xml#Motivation', -'speed_test.xml#Include', -'speed_test.xml#Vector', -'speed_test.xml#test', -'speed_test.xml#test.size', -'speed_test.xml#test.repeat', -'speed_test.xml#size_vec', -'speed_test.xml#time_min', -'speed_test.xml#rate_vec', -'speed_test.xml#Timing', -'speed_test.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-2018.00.00.0/doc/_speedtest_xml.js cppad-2019.02.00.0/doc/_speedtest_xml.js --- cppad-2018.00.00.0/doc/_speedtest_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speedtest_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'speedtest.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'speed_program.cpp.xml' -]; -var list_current0 = [ -'speedtest.xml#Syntax', -'speedtest.xml#Purpose', -'speedtest.xml#Motivation', -'speedtest.xml#Include', -'speedtest.xml#Test', -'speedtest.xml#Test.size', -'speedtest.xml#Test.repeat', -'speedtest.xml#Test.name', -'speedtest.xml#first', -'speedtest.xml#last', -'speedtest.xml#inc', -'speedtest.xml#rate', -'speedtest.xml#Errors', -'speedtest.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-2018.00.00.0/doc/speed_utility.xml cppad-2019.02.00.0/doc/speed_utility.xml --- cppad-2018.00.00.0/doc/speed_utility.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/speed_utility.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,241 +0,0 @@ - - - -Speed Testing Utilities - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - -
Speed Testing Utilities
-
-Speed Main Program - - - -
- -speed_main -Running the Speed Test Program
- -
-
-Speed Utility Routines - - - - - - - - - - - - -
- -det_by_lu -Determinant Using Expansion by Lu Factorization
- -det_by_minor -Determinant Using Expansion by Minors
- -det_of_minor -Determinant of a Minor
- -det_33 -Check Determinant of 3 by 3 matrix
- -det_grad_33 -Check Gradient of Determinant of 3 by 3 matrix
- -mat_sum_sq -Sum Elements of a Matrix Times Itself
- -ode_evaluate -Evaluate a Function Defined in Terms of an ODE
- -sparse_jac_fun -Evaluate a Function That Has a Sparse Jacobian
- -sparse_hes_fun -Evaluate a Function That Has a Sparse Hessian
- -uniform_01 -Simulate a [0,1] Uniform Random Variate
- -
-
-Library Routines - - - - - - -
- -LuFactor -LU Factorization of A Square Matrix
- -LuInvert -Invert an LU Factored Equation
- -LuSolve -Compute Determinant and Solve Linear Equations
- -Poly -Evaluate a Polynomial or its Derivative
- -
-
-Source Code - - - - - - - - - - - - - - -
- -det_by_lu.hpp -Source: det_by_lu
- -det_by_minor.hpp -Source: det_by_minor
- -det_grad_33.hpp -Source: det_grad_33
- -det_of_minor.hpp -Source: det_of_minor
- -lu_factor.hpp -Source: LuFactor
- -lu_invert.hpp -Source: LuInvert
- -lu_solve.hpp -Source: LuSolve
- -mat_sum_sq.hpp -Source: mat_sum_sq
- -poly.hpp -Source: Poly
- -sparse_jac_fun.hpp -Source: sparse_jac_fun
- -sparse_hes_fun.hpp -Source: sparse_hes_fun
- -uniform_01.hpp -Source: uniform_01
- -
- -
Input File: omh/speed/speed_utility.omh - - - diff -Nru cppad-2018.00.00.0/doc/_speed_utility_xml.js cppad-2019.02.00.0/doc/_speed_utility_xml.js --- cppad-2018.00.00.0/doc/_speed_utility_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speed_utility_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down0 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_current0 = [ -'speed_utility.xml#Speed Main Program', -'speed_utility.xml#Speed Utility Routines', -'speed_utility.xml#Library Routines', -'speed_utility.xml#Source Code' -]; -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-2018.00.00.0/doc/speed.xml cppad-2019.02.00.0/doc/speed.xml --- cppad-2018.00.00.0/doc/speed.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/speed.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ - - - -Speed Test an Operator Overloading AD Package - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -

- - - - -
Speed Test an Operator Overloading AD Package
-
-Purpose -
-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 -Adolc -, -CppAD -, -Fadbad - and -Sacado -. - -
-
-debug_which -
-Usually, one wants to compile the speed tests in release mode. -This can be done by setting -cppad_debug_which - to debug_none -in the cmake command. -Correctness tests are included for all the speed tests, -so it is possible you will want to compile these tests for debugging; i.e., -set -cppad_debug_which - to debug_all. - -The sections below explain how you can run these tests on your computer. - -
-
-Contents -
- -
speed_mainRunning the Speed Test Program
speed_utilitySpeed Testing Utilities
speed_doubleSpeed Test of Functions in Double
speed_adolcSpeed Test of Derivatives Using Adolc
speed_cppadSpeed Test Derivatives Using CppAD
speed_fadbadSpeed Test Derivatives Using Fadbad
speed_sacadoSpeed Test Derivatives Using Sacado
-
Input File: omh/speed/speed.omh - - - diff -Nru cppad-2018.00.00.0/doc/_speed_xml.js cppad-2019.02.00.0/doc/_speed_xml.js --- cppad-2018.00.00.0/doc/_speed_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_speed_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_current0 = [ -'speed.xml#Purpose', -'speed.xml#debug_which', -'speed.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_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-2018.00.00.0/doc/sqrt.cpp.xml cppad-2019.02.00.0/doc/sqrt.cpp.xml --- cppad-2018.00.00.0/doc/sqrt.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/sqrt.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ - - - -The AD sqrt Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sqrt.cppHeadings

-
The AD sqrt Function: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cmath>
-
-bool Sqrt(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * 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);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::sqrt(x[0]);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     double check = std::sqrt(x0);
-     ok &= NearEqual(y[0] , check, eps99, eps99);
-
-     // 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 = 1. / (2. * std::sqrt(x0) );
-     ok   &= NearEqual(dy[0], check, eps99, eps99);
-
-     // 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, eps99, eps99);
-
-     // use a VecAD<Base>::reference object with sqrt
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero]           = x0;
-     AD<double> result = CppAD::sqrt(v[zero]);
-     check = std::sqrt(x0);
-     ok   &= NearEqual(result, check, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/sqrt.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sqrt.cpp_xml.js cppad-2019.02.00.0/doc/_sqrt.cpp_xml.js --- cppad-2018.00.00.0/doc/_sqrt.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sqrt.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'sqrt.xml', -'sqrt.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 = [ -'sqrt.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-2018.00.00.0/doc/sqrt_forward.xml cppad-2019.02.00.0/doc/sqrt_forward.xml --- cppad-2018.00.00.0/doc/sqrt_forward.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sqrt_forward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,492 +0,0 @@ - - - -Square Root Function Forward Mode Theory - - - - - - - - - - - - - - - - -
- -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/appendix/theory/sqrt_forward.omh - - - diff -Nru cppad-2018.00.00.0/doc/_sqrt_forward_xml.js cppad-2019.02.00.0/doc/_sqrt_forward_xml.js --- cppad-2018.00.00.0/doc/_sqrt_forward_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sqrt_forward_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', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'sqrt_forward.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/sqrt_reverse.xml cppad-2019.02.00.0/doc/sqrt_reverse.xml --- cppad-2018.00.00.0/doc/sqrt_reverse.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/sqrt_reverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,653 +0,0 @@ - - - -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/appendix/theory/sqrt_reverse.omh - - - diff -Nru cppad-2018.00.00.0/doc/_sqrt_reverse_xml.js cppad-2019.02.00.0/doc/_sqrt_reverse_xml.js --- cppad-2018.00.00.0/doc/_sqrt_reverse_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sqrt_reverse_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', -'appendix.xml', -'theory.xml', -'reversetheory.xml', -'sqrt_reverse.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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-2018.00.00.0/doc/sqrt.xml cppad-2019.02.00.0/doc/sqrt.xml --- cppad-2018.00.00.0/doc/sqrt.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/sqrt.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ - - - -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_sqrt_xml.js cppad-2019.02.00.0/doc/_sqrt_xml.js --- cppad-2018.00.00.0/doc/_sqrt_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sqrt_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'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-2018.00.00.0/doc/stack_machine.cpp.xml cppad-2019.02.00.0/doc/stack_machine.cpp.xml --- cppad-2018.00.00.0/doc/stack_machine.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/stack_machine.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,290 +0,0 @@ - - - -Example Differentiating a Stack Machine Interpreter - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -stack_machine.cppHeadings

-
Example Differentiating a Stack Machine Interpreter
-

-# include <cstring>
-# include <cstddef>
-# include <cstdlib>
-# include <cctype>
-# include <cassert>
-# include <stack>
-
-# include <cppad/cppad.hpp>
-
-namespace {
-// Begin empty namespace ------------------------------------------------
-
-bool is_number( const std::string &s )
-{     char ch = s[0];
-     bool number = (std::strchr("0123456789.", ch) != 0);
-     return number;
-}
-bool is_binary( const std::string &s )
-{     char ch = s[0];
-     bool binary = (strchr("+-*/.", ch) != 0);
-     return binary;
-}
-bool is_variable( const std::string &s )
-{     char ch = s[0];
-     bool variable = ('a' <= ch) & (ch <= 'z');
-     return variable;
-}
-
-void StackMachine(
-     std::stack< std::string >          &token_stack  ,
-     CppAD::vector< CppAD::AD<double> > &variable     )
-{     using std::string;
-     using std::stack;
-
-     using CppAD::AD;
-
-     stack< AD<double> > value_stack;
-     string              token;
-     AD<double>          value_one;
-     AD<double>          value_two;
-
-     while( ! token_stack.empty() )
-     {     string s = token_stack.top();
-          token_stack.pop();
-
-          if( is_number(s) )
-          {     value_one = std::atof( s.c_str() );
-               value_stack.push( value_one );
-          }
-          else if( is_variable(s) )
-          {     value_one = variable[ size_t(s[0]) - size_t('a') ];
-               value_stack.push( value_one );
-          }
-          else if( is_binary(s) )
-          {     assert( value_stack.size() >= 2 );
-               value_one = value_stack.top();
-               value_stack.pop();
-               value_two = value_stack.top();
-               value_stack.pop();
-
-               switch( s[0] )
-               {
-                    case '+':
-                    value_stack.push(value_one + value_two);
-                    break;
-
-                    case '-':
-                    value_stack.push(value_one - value_two);
-                    break;
-
-                    case '*':
-                    value_stack.push(value_one * value_two);
-                    break;
-
-                    case '/':
-                    value_stack.push(value_one / value_two);
-                    break;
-
-                    default:
-                    assert(0);
-               }
-          }
-          else if( s[0] == '=' )
-          {     assert( value_stack.size() >= 1 );
-               assert( token_stack.size() >= 1 );
-               //
-               s = token_stack.top();
-               token_stack.pop();
-               //
-               assert( is_variable( s ) );
-               value_one = value_stack.top();
-               value_stack.pop();
-               //
-               variable[ size_t(s[0]) - size_t('a') ] = value_one;
-          }
-          else assert(0);
-     }
-     return;
-}
-
-// End empty namespace -------------------------------------------------------
-}
-
-bool StackMachine(void)
-{     bool ok = true;
-
-     using std::string;
-     using std::stack;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     using CppAD::vector;
-
-     // The users program in that stack machine language
-     const char *program[] = {
-          "1.0", "a", "+", "=", "b",  // b = a + 1
-          "2.0", "b", "*", "=", "c",  // c = b * 2
-          "3.0", "c", "-", "=", "d",  // d = c - 3
-          "4.0", "d", "/", "=", "e"   // e = d / 4
-     };
-     size_t n_program = sizeof( program ) / sizeof( program[0] );
-
-     // put the program in the token stack
-     stack< string > token_stack;
-     size_t i = n_program;
-     while(i--)
-          token_stack.push( program[i] );
-
-     // domain space vector
-     size_t n = 1;
-     vector< AD<double> > X(n);
-     X[0] = 0.;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(X);
-
-     // x[0] corresponds to a in the stack machine
-     vector< AD<double> > variable(26);
-     variable[0] = X[0];
-
-     // calculate the resutls of the program
-     StackMachine( token_stack , variable);
-
-     // range space vector
-     size_t m = 4;
-     vector< AD<double> > Y(m);
-     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
-
-     // create f : X -> Y and stop tape recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // use forward mode to evaluate function at different argument value
-     size_t p = 0;
-     vector<double> x(n);
-     vector<double> y(m);
-     x[0] = 1.;
-     y    = f.Forward(p, x);
-
-     // check function values
-     ok &= (y[0] == x[0] + 1.);
-     ok &= (y[1] == (x[0] + 1.) * 2.);
-     ok &= (y[2] == (x[0] + 1.) * 2. - 3.);
-     ok &= (y[3] == ( (x[0] + 1.) * 2. - 3.) / 4.);
-
-     // Use forward mode (because x is shorter than y) to calculate Jacobian
-     p = 1;
-     vector<double> dx(n);
-     vector<double> dy(m);
-     dx[0] = 1.;
-     dy    = f.Forward(p, dx);
-     ok   &= NearEqual(dy[0], 1., eps99, eps99);
-     ok   &= NearEqual(dy[1], 2., eps99, eps99);
-     ok   &= NearEqual(dy[2], 2., eps99, eps99);
-     ok   &= NearEqual(dy[3], .5, eps99, eps99);
-
-     // Use Jacobian routine (which automatically decides which mode to use)
-     dy = f.Jacobian(x);
-     ok   &= NearEqual(dy[0], 1., eps99, eps99);
-     ok   &= NearEqual(dy[1], 2., eps99, eps99);
-     ok   &= NearEqual(dy[2], 2., eps99, eps99);
-     ok   &= NearEqual(dy[3], .5, eps99, eps99);
-
-     return ok;
-}
-
-
Input File: example/general/stack_machine.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_stack_machine.cpp_xml.js cppad-2019.02.00.0/doc/_stack_machine.cpp_xml.js --- cppad-2018.00.00.0/doc/_stack_machine.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_stack_machine.cpp_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', -'example.xml', -'general.xml', -'stack_machine.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_down1 = [ -'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' -]; -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-2018.00.00.0/doc/sub.cpp.xml cppad-2019.02.00.0/doc/sub.cpp.xml --- cppad-2018.00.00.0/doc/sub.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/sub.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ - - - -AD Binary Subtraction: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sub.cppHeadings

-
AD Binary Subtraction: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool Sub(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t  n =  1;
-     double x0 = .5;
-     CPPAD_TESTVECTOR(AD<double>) x(1);
-     x[0]      = x0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     AD<double> a = 2. * x[0] - 1.; // AD<double> - double
-     AD<double> b = a  - 2;         // AD<double> - int
-     AD<double> c = 3. - b;         // double     - AD<double>
-     AD<double> d = 4  - c;         // int        - AD<double>
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = x[0] - d;              // AD<double> - AD<double>
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0], x0-4.+3.+2.-2.*x0+1., eps99, eps99);
-
-     // forward computation of partials 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., eps99, eps99);
-
-     // 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., eps99, eps99);
-
-     // use a VecAD<Base>::reference object with subtraction
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero] = b;
-     AD<double> result = 3. - v[zero];
-     ok     &= (result == c);
-
-     return ok;
-}
-
-
-
Input File: example/general/sub.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sub.cpp_xml.js cppad-2019.02.00.0/doc/_sub.cpp_xml.js --- cppad-2018.00.00.0/doc/_sub.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sub.cpp_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', -'ad.xml', -'advalued.xml', -'arithmetic.xml', -'ad_binary.xml', -'sub.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down1 = [ -'add.cpp.xml', -'sub.cpp.xml', -'mul.cpp.xml', -'div.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-2018.00.00.0/doc/sub_eq.cpp.xml cppad-2019.02.00.0/doc/sub_eq.cpp.xml --- cppad-2018.00.00.0/doc/sub_eq.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/sub_eq.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ - - - -AD Compound Assignment Subtraction: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -sub_eq.cppHeadings

-
AD Compound Assignment Subtraction: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool SubEq(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t  n = 1;
-     double x0 = .5;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0]      = x0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     // range space vector
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = 3. * x[0];    // initial value
-     y[0] -= 2;           // AD<double> -= int
-     y[0] -= 4.;          // AD<double> -= double
-     y[1] = y[0] -= x[0]; // use the result of a compound assignment
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     ok &= NearEqual(y[0] , 3.*x0-(2.+4.+x0), eps99, eps99);
-     ok &= NearEqual(y[1] ,             y[0], eps99, eps99);
-
-     // forward computation of partials 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], 2., eps99, eps99);
-     ok   &= NearEqual(dy[1], 2., eps99, eps99);
-
-     // reverse computation of derivative of y[0]
-     CPPAD_TESTVECTOR(double)  w(m);
-     CPPAD_TESTVECTOR(double) dw(n);
-     w[0]  = 1.;
-     w[1]  = 0.;
-     dw    = f.Reverse(1, w);
-     ok   &= NearEqual(dw[0], 2., eps99, eps99);
-
-     // use a VecAD<Base>::reference object with computed subtraction
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     AD<double> result = 1;
-     v[zero] = 2;
-     result -= v[zero];
-     ok     &= (result == -1);
-
-     return ok;
-}
-
-
-
Input File: example/general/sub_eq.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sub_eq.cpp_xml.js cppad-2019.02.00.0/doc/_sub_eq.cpp_xml.js --- cppad-2018.00.00.0/doc/_sub_eq.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sub_eq.cpp_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', -'ad.xml', -'advalued.xml', -'arithmetic.xml', -'compound_assign.xml', -'sub_eq.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down1 = [ -'addeq.cpp.xml', -'sub_eq.cpp.xml', -'mul_eq.cpp.xml', -'div_eq.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-2018.00.00.0/doc/subgraph_hes2jac.cpp.xml cppad-2019.02.00.0/doc/subgraph_hes2jac.cpp.xml --- cppad-2018.00.00.0/doc/subgraph_hes2jac.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/subgraph_hes2jac.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ - - - -Sparse Hessian Using Subgraphs and Jacobian: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -subgraph_hes2jac.cppHeadings

-
Sparse Hessian Using Subgraphs and Jacobian: Example and Test
-
# include <cppad/cppad.hpp>
-bool subgraph_hes2jac(void)
-{     bool ok = true;
-     using CppAD::NearEqual;
-     typedef CppAD::AD<double>                      a1double;
-     typedef CppAD::AD<a1double>                    a2double;
-     typedef CPPAD_TESTVECTOR(double)               d_vector;
-     typedef CPPAD_TESTVECTOR(a1double)             a1vector;
-     typedef CPPAD_TESTVECTOR(a2double)             a2vector;
-     typedef CPPAD_TESTVECTOR(size_t)               s_vector;
-     typedef CPPAD_TESTVECTOR(bool)                 b_vector;
-     typedef CppAD::sparse_rcv<s_vector, d_vector>  sparse_matrix;
-     //
-     double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-     //
-     // double version of x
-     size_t n = 12;
-     d_vector x(n);
-     for(size_t j = 0; j < n; j++)
-          x[j] = double(j + 2);
-     //
-     // a1double version of x
-     a1vector a1x(n);
-     for(size_t j = 0; j < n; j++)
-          a1x[j] = x[j];
-     //
-     // a2double version of x
-     a2vector a2x(n);
-     for(size_t j = 0; j < n; j++)
-          a2x[j] = a1x[j];
-     //
-     // declare independent variables and starting recording
-     CppAD::Independent(a2x);
-     //
-     // a2double version of y = f(x) = 5 * x0 * x1 + sum_j xj^3
-     size_t m = 1;
-     a2vector a2y(m);
-     a2y[0] = 5.0 * a2x[0] * a2x[1];
-     for(size_t j = 0; j < n; j++)
-          a2y[0] += a2x[j] * a2x[j] * a2x[j];
-     //
-     // create a1double version of f: x -> y and stop tape recording
-     // (without executing zero order forward calculation)
-     CppAD::ADFun<a1double> a1f;
-     a1f.Dependent(a2x, a2y);
-     //
-     // Optimize this function to reduce future computations.
-     // Perhaps only one optimization at the end would be faster.
-     a1f.optimize();
-     //
-     // declare independent variables and start recording g(x) = f'(x)
-     Independent(a1x);
-     //
-     // Use one reverse mode pass to compute z = f'(x)
-     a1vector a1w(m), a1z(n);
-     a1w[0] = 1.0;
-     a1f.Forward(0, a1x);
-     a1z = a1f.Reverse(1, a1w);
-     //
-     // create double version of g : x -> f'(x)
-     CppAD::ADFun<double> g;
-     g.Dependent(a1x, a1z);
-     //
-     // Optimize this function to reduce future computations.
-     // Perhaps no optimization would be faster.
-     g.optimize();
-     //
-     // compute f''(x) = g'(x)
-     b_vector select_domain(n), select_range(n);
-     for(size_t j = 0; j < n; ++j)
-     {     select_domain[j] = true;
-          select_range[j]  = true;
-     }
-     sparse_matrix hessian;
-     g.subgraph_jac_rev(select_domain, select_range, x, hessian);
-     // -------------------------------------------------------------------
-     // check number of non-zeros in the Hessian
-     // (only x0 * x1 generates off diagonal terms)
-     ok &= hessian.nnz() == n + 2;
-     //
-     for(size_t k = 0; k < hessian.nnz(); ++k)
-     {     size_t r = hessian.row()[k];
-          size_t c = hessian.col()[k];
-          double v = hessian.val()[k];
-          //
-          if( r == c )
-          {     // a diagonal element
-               double check = 6.0 * x[r];
-               ok          &= NearEqual(v, check, eps, eps);
-          }
-          else
-          {     // off diagonal element
-               ok   &= (r == 0 && c == 1) || (r == 1 && c == 0);
-               double check = 5.0;
-               ok          &= NearEqual(v, check, eps, eps);
-          }
-     }
-     return ok;
-}
-
-
Input File: example/sparse/subgraph_hes2jac.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_subgraph_hes2jac.cpp_xml.js cppad-2019.02.00.0/doc/_subgraph_hes2jac.cpp_xml.js --- cppad-2018.00.00.0/doc/_subgraph_hes2jac.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_subgraph_hes2jac.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparse_derivative.xml', -'subgraph_jac_rev.xml', -'subgraph_hes2jac.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_down1 = [ -'subgraph_jac_rev.cpp.xml', -'subgraph_hes2jac.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-2018.00.00.0/doc/subgraph_jac_rev.cpp.xml cppad-2019.02.00.0/doc/subgraph_jac_rev.cpp.xml --- cppad-2018.00.00.0/doc/subgraph_jac_rev.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/subgraph_jac_rev.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,200 +0,0 @@ - - - -Computing Sparse Jacobian Using Reverse Mode: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -subgraph_jac_rev.cppHeadings

- - - -
Computing Sparse Jacobian Using Reverse Mode: Example and Test
-
# include <cppad/cppad.hpp>
-bool subgraph_jac_rev(void)
-{     bool ok = true;
-     //
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     using CppAD::sparse_rc;
-     using CppAD::sparse_rcv;
-     //
-     typedef CPPAD_TESTVECTOR(AD<double>) a_vector;
-     typedef CPPAD_TESTVECTOR(double)     d_vector;
-     typedef CPPAD_TESTVECTOR(size_t)     s_vector;
-     typedef CPPAD_TESTVECTOR(bool)       b_vector;
-     //
-     // domain space vector
-     size_t n = 4;
-     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);
-     //
-     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(size_t j = 0; j < n; j++)
-          x[j] = double(j);
-     /*
-            [ 1 1 0 0  ]
-     J(x) = [ 0 0 1 1  ]
-            [ 1 1 1 x_3]
-     */
-     //
-     // row-major order values of J(x)
-     size_t nnz = 8;
-     s_vector check_row(nnz), check_col(nnz);
-     d_vector check_val(nnz);
-     for(size_t k = 0; k < nnz; k++)
-     {     // check_val
-          if( k < 7 )
-               check_val[k] = 1.0;
-          else
-               check_val[k] = x[3];
-          //
-          // check_row and check_col
-          check_col[k] = k;
-          if( k < 2 )
-               check_row[k] = 0;
-          else if( k < 4 )
-               check_row[k] = 1;
-          else
-          {     check_row[k] = 2;
-               check_col[k] = k - 4;
-          }
-     }
-     //
-     // select all range components of domain and range
-     b_vector select_domain(n), select_range(m);
-     for(size_t j = 0; j < n; ++j)
-          select_domain[j] = true;
-     for(size_t i = 0; i < m; ++i)
-          select_range[i] = true;
-     // -----------------------------------------------------------------------
-     // Compute Jacobian using f.subgraph_jac_rev(x, subset)
-     // -----------------------------------------------------------------------
-     //
-     // get sparsity pattern
-     bool transpose     = false;
-     sparse_rc<s_vector> pattern_jac;
-     f.subgraph_sparsity(
-          select_domain, select_range, transpose, pattern_jac
-     );
-     // f.subgraph_jac_rev(x, subset)
-     sparse_rcv<s_vector, d_vector> subset( pattern_jac );
-     f.subgraph_jac_rev(x, subset);
-     //
-     // check result
-     ok  &= subset.nnz() == nnz;
-     s_vector row_major = subset.row_major();
-     for(size_t k = 0; k < nnz; k++)
-     {     ok &= subset.row()[ row_major[k] ] == check_row[k];
-          ok &= subset.col()[ row_major[k] ] == check_col[k];
-          ok &= subset.val()[ row_major[k] ] == check_val[k];
-     }
-     // -----------------------------------------------------------------------
-     // f.subgraph_jac_rev(select_domain, select_range, x, matrix_out)
-     // -----------------------------------------------------------------------
-     sparse_rcv<s_vector, d_vector>  matrix_out;
-     f.subgraph_jac_rev(select_domain, select_range, x, matrix_out);
-     //
-     // check result
-     ok  &= matrix_out.nnz() == nnz;
-     row_major = matrix_out.row_major();
-     for(size_t k = 0; k < nnz; k++)
-     {     ok &= matrix_out.row()[ row_major[k] ] == check_row[k];
-          ok &= matrix_out.col()[ row_major[k] ] == check_col[k];
-          ok &= matrix_out.val()[ row_major[k] ] == check_val[k];
-     }
-     //
-     return ok;
-}
-
-
Input File: example/sparse/subgraph_jac_rev.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_subgraph_jac_rev.cpp_xml.js cppad-2019.02.00.0/doc/_subgraph_jac_rev.cpp_xml.js --- cppad-2018.00.00.0/doc/_subgraph_jac_rev.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_subgraph_jac_rev.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparse_derivative.xml', -'subgraph_jac_rev.xml', -'subgraph_jac_rev.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_down1 = [ -'subgraph_jac_rev.cpp.xml', -'subgraph_hes2jac.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-2018.00.00.0/doc/subgraph_jac_rev.xml cppad-2019.02.00.0/doc/subgraph_jac_rev.xml --- cppad-2018.00.00.0/doc/subgraph_jac_rev.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/subgraph_jac_rev.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,473 +0,0 @@ - - - -Compute Sparse Jacobians Using Subgraphs - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Compute Sparse Jacobians Using Subgraphs
-
-Syntax - -
- -f.subgraph_jac_rev(xsubset)
-
- -f.subgraph_jac_rev(
-     
select_domainselect_rangexmatrix_out
-)
- - -
-
-Purpose -
-We use - -F -: -R - -n - - -R - -m - - - - to denote the -function corresponding to -f -. -Here -n - is the domain - size, -and -m - is the range - size, or -f -. -The syntax above takes advantage of sparsity when computing the Jacobian - - -J -( -x -) -= -F -( -1 -) - - -( -x -) - - -The first syntax computes the sparsity pattern and the value -of the Jacobian at the same time. -If one only wants the sparsity pattern, -it should be faster to use subgraph_sparsity -. - -
-
-Method -
-This routine uses a subgraph technique. To be specific, -for each dependent variable, -it creates a subgraph of the operation sequence -containing the variables that affect the dependent variable. -This avoids the overhead of performing set operations -that is inherent in other methods for computing sparsity patterns. - -
-
-BaseVector -
-The type -BaseVector - is a SimpleVector - class with -elements of type - - -Base -. - -
-
-SizeVector -
-The type -SizeVector - is a SimpleVector - class with -elements of type - -size_t. - -
-
-BoolVector -
-The type -BoolVector - is a SimpleVector - class with -elements of type - -bool. - -
-
-f -
-This object has prototype - -
-     ADFun<
Basef
-
-Note that the Taylor coefficients stored in -f - are affected -by this operation; see -uses forward - below. - -
-
-x -
-This argument has prototype - -
-     const 
BaseVectorx
-
-It is the value of -x - at which we are computing the Jacobian. - -
-
-Uses Forward -
-After each call to Forward -, -the object -f - contains the corresponding -Taylor coefficients -. -After a call to sparse_jac_forward or sparse_jac_rev, -the zero order coefficients correspond to - -
-     
f.Forward(0, x)
-
-All the other forward mode coefficients are unspecified. - -
-
-subset -
-This argument has prototype - -
-     sparse_rcv<
SizeVectorBaseVector>& subset
-
-Its row size is -subset.nr() == m -, -and its column size is -subset.nc() == n -. -It specifies which elements of the Jacobian are computed. -The input elements in its value vector - -subset.val() - do not matter. -Upon return it contains the value of the corresponding elements -of the Jacobian. - -
-
-select_domain -
-The argument -select_domain - has prototype - -
-     const 
BoolVectorselect_domain
-
-It has size - -n - - - and specifies which independent variables -to include. - -
-
-select_range -
-The argument -select_range - has prototype - -
-     const 
BoolVectorselect_range
-
-It has size - -m - - - and specifies which components of the range -to include in the calculation. -A subgraph is built for each dependent variable and the selected set -of independent variables. - -
-
-matrix_out -
-This argument has prototype - -
-     sparse_rcv<
SizeVectorBaseVector>& matrix_out
-
-This input value of -matrix_out - does not matter. -Upon return -matrix_out - is -sparse matrix - representation of - -F -( -1 -) - - -( -x -) - - -. -The matrix has - -m - - - rows, - -n - - - columns. -If -select_domain[j] - is true, - -select_range[i] - is true, and - - -F -i - -( -x -) - - - depends on - -x -j - - - -, -then the pair - -( -i -, -j -) - - - is in -matrix_out -. -For each -k = 0 , ...matrix_out.nnz() -, let - -
-     
i = matrix_out.row()[k]
-     
j = matrix_out.col()[k]
-     
v = matrix_out.val()[k]
-
-It follows that the partial of - -F -i - -( -x -) - - - with respect to - - -x -j - - - - is equal to - -v - - -. - - -
-
-Example - -
-The files subgraph_jac_rev.cpp - and subgraph_hes2jac.cpp - -are examples and tests using subgraph_jac_rev. -They returns true for success and false for failure. - - -
Input File: cppad/core/subgraph_jac_rev.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_subgraph_jac_rev_xml.js cppad-2019.02.00.0/doc/_subgraph_jac_rev_xml.js --- cppad-2018.00.00.0/doc/_subgraph_jac_rev_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_subgraph_jac_rev_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparse_derivative.xml', -'subgraph_jac_rev.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.xml' -]; -var list_down0 = [ -'subgraph_jac_rev.cpp.xml', -'subgraph_hes2jac.cpp.xml' -]; -var list_current0 = [ -'subgraph_jac_rev.xml#Syntax', -'subgraph_jac_rev.xml#Purpose', -'subgraph_jac_rev.xml#Method', -'subgraph_jac_rev.xml#BaseVector', -'subgraph_jac_rev.xml#SizeVector', -'subgraph_jac_rev.xml#BoolVector', -'subgraph_jac_rev.xml#f', -'subgraph_jac_rev.xml#x', -'subgraph_jac_rev.xml#Uses Forward', -'subgraph_jac_rev.xml#subset', -'subgraph_jac_rev.xml#select_domain', -'subgraph_jac_rev.xml#select_range', -'subgraph_jac_rev.xml#matrix_out', -'subgraph_jac_rev.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-2018.00.00.0/doc/subgraph_reverse.cpp.xml cppad-2019.02.00.0/doc/subgraph_reverse.cpp.xml --- cppad-2018.00.00.0/doc/subgraph_reverse.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/subgraph_reverse.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,177 +0,0 @@ - - - -Computing Reverse Mode on Subgraphs: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -subgraph_reverse.cppHeadings

- - - -
Computing Reverse Mode on Subgraphs: Example and Test
-
# include <cppad/cppad.hpp>
-bool subgraph_reverse(void)
-{     bool ok = true;
-     //
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     using CppAD::sparse_rc;
-     using CppAD::sparse_rcv;
-     //
-     typedef CPPAD_TESTVECTOR(AD<double>) a_vector;
-     typedef CPPAD_TESTVECTOR(double)     d_vector;
-     typedef CPPAD_TESTVECTOR(bool)       b_vector;
-     typedef CPPAD_TESTVECTOR(size_t)     s_vector;
-     //
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-     //
-     // domain space vector
-     size_t n = 4;
-     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);
-     //
-     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(size_t j = 0; j < n; j++)
-          x[j] = double(j);
-     f.Forward(0, x);
-     /*
-            [ 1 1 0 0  ]
-     J(x) = [ 0 0 1 1  ]
-            [ 1 1 1 x_3]
-     */
-     double J[] = {
-          1.0, 1.0, 0.0, 0.0,
-          0.0, 0.0, 1.0, 1.0,
-          1.0, 1.0, 1.0, 0.0
-     };
-     J[11] = x[3];
-     //
-     // exclude x[0] from the calculations
-     b_vector select_domain(n);
-     select_domain[0] = false;
-     for(size_t j = 1; j < n; j++)
-          select_domain[j] = true;
-     //
-     // initilaize for reverse mode derivatives computation on subgraphs
-     f.subgraph_reverse(select_domain);
-     //
-     // compute the derivative for each range component
-     for(size_t i = 0; i < m; i++)
-     {     d_vector dw;
-          s_vector col;
-          size_t   q = 1; // derivative of one Taylor coefficient (zero order)
-          f.subgraph_reverse(q, i, col, dw);
-          //
-          // check order in col
-          for(size_t c = 1; c < size_t( col.size() ); c++)
-               ok &= col[c] > col[c-1];
-          //
-          // check that x[0] has been excluded by select_domain
-          if( size_t( col.size() ) > 0 )
-               ok &= col[0] != 0;
-          //
-          // check derivatives for i-th row of J(x)
-          // note that dw is only specified for j in col
-          size_t c = 0;
-          for(size_t j = 1; j < n; j++)
-          {     while( c < size_t( col.size() ) && col[c] < j )
-                    ++c;
-               if( c < size_t( col.size() ) && col[c] == j )
-                    ok &= NearEqual(dw[j], J[i * n + j], eps99, eps99);
-               else
-                    ok &= NearEqual(0.0, J[i * n + j], eps99, eps99);
-          }
-     }
-     return ok;
-}
-
-
Input File: example/sparse/subgraph_reverse.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_subgraph_reverse.cpp_xml.js cppad-2019.02.00.0/doc/_subgraph_reverse.cpp_xml.js --- cppad-2018.00.00.0/doc/_subgraph_reverse.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_subgraph_reverse.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'reverse.xml', -'subgraph_reverse.xml', -'subgraph_reverse.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'reverse_one.xml', -'reverse_two.xml', -'reverse_any.xml', -'subgraph_reverse.xml' -]; -var list_down1 = [ -'subgraph_reverse.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-2018.00.00.0/doc/subgraph_reverse.xml cppad-2019.02.00.0/doc/subgraph_reverse.xml --- cppad-2018.00.00.0/doc/subgraph_reverse.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/subgraph_reverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,455 +0,0 @@ - - - -Reverse Mode Using Subgraphs - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Reverse Mode Using Subgraphs
-
-Syntax - -
- -f.subgraph_reverse(select_domain)
-
- -f.subgraph_reverse(qellcoldw)
-
-
-Purpose -
-We use - -F -: -B -n - - -B -m - - - - to denote the -AD function - corresponding to -f -. -Reverse mode computes the derivative of the Forward - mode -Taylor coefficients - -with respect to the domain variable - -x - - -. - -
-
-Notation -
-We use the reverse mode -notation - with the following change: -the vector -w^(k) - is defined - - -w -i -( -k -) - - -= -{ -1 - -if - - -k -= -q --1 - -and - - -i -= - - -0 - -otherwise - - - - - -
-BaseVector -
-The type -BaseVector - must be a SimpleVector - class with -elements of type - - -Base -. -The routine CheckSimpleVector - will generate an error message -if this is not the case. - -
-
-BoolVector -
-The type -BoolVector - is a SimpleVector - class with -elements of type - -bool. - -
-
-SizeVector -
-The type -SizeVector - is a SimpleVector - class with -elements of type - -size_t. - -
-
-select_domain -
-The argument -select_domain - has prototype - -
-     const 
BoolVectorselect_domain
-
-It has size - -n - - - and specifies which independent variables -to include in the calculation. -If -select_domain[j] - is false, -it is assumed that - -u -j -( -k -) - - -= -0 - - - for - -k -> -0 - - -; i.e., -the j-th component of the Taylor coefficient for - -x - - -, -with order greater that zero, are zero; see -u^(k) -. - -
-
-q -
-The argument -q - has prototype - -
-     size_t 
q
-
-and specifies the number of Taylor coefficient orders to be differentiated. - -
-
-ell -
-The argument -ell - has prototype - -
-     size_t 
ell
-
-and specifies the dependent variable index that we are computing -the derivatives for; i.e. - - - - -. -This index can only be used once per, and after, a call that selects -the independent variables using -select_domain -. - -
-
-col -
-This argument -col - has prototype - -
-     
SizeVector col
-
-The input size and value of its elements do not matter. -The -col.resize - member function is used to change its size -to the number the number of possible non-zero derivative components. -For each -c -, - -
-     
select_domaincol[c] ] == true
-     
col[c+1] >= col[c]
-
-and the derivative with respect to the j-th independent -variable is possibly non-zero where - -j = col[c] -. - -
-
-dw -
-The argument -dw - has prototype - -
-     
Vector dw
-
-Its input size and value does not matter. -Upon return, -it is a vector with size - -n -× -q - - -. -For - -c -= -0 -, - -, - - -, -and - -k -= -0 -, - -, -q --1 - - -, - - -dw -[ -j -* -q -+ -k -] -= -W -( -1 -) - - -( -x -) -j -, -k - - - - -is the derivative of the specified Taylor coefficients w.r.t the j-th -independent variable where -j = col[c] -. -Note that this corresponds to the reverse_any - convention when -w - has size -m * q -. - -
-
-Example - -
-The file -subgraph_reverse.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/subgraph_reverse.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_subgraph_reverse_xml.js cppad-2019.02.00.0/doc/_subgraph_reverse_xml.js --- cppad-2018.00.00.0/doc/_subgraph_reverse_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_subgraph_reverse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'reverse.xml', -'subgraph_reverse.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'reverse_one.xml', -'reverse_two.xml', -'reverse_any.xml', -'subgraph_reverse.xml' -]; -var list_down0 = [ -'subgraph_reverse.cpp.xml' -]; -var list_current0 = [ -'subgraph_reverse.xml#Syntax', -'subgraph_reverse.xml#Purpose', -'subgraph_reverse.xml#Notation', -'subgraph_reverse.xml#BaseVector', -'subgraph_reverse.xml#BoolVector', -'subgraph_reverse.xml#SizeVector', -'subgraph_reverse.xml#select_domain', -'subgraph_reverse.xml#q', -'subgraph_reverse.xml#ell', -'subgraph_reverse.xml#col', -'subgraph_reverse.xml#dw', -'subgraph_reverse.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-2018.00.00.0/doc/subgraph_sparsity.cpp.xml cppad-2019.02.00.0/doc/subgraph_sparsity.cpp.xml --- cppad-2018.00.00.0/doc/subgraph_sparsity.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/subgraph_sparsity.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ - - - -Subgraph Dependency Sparsity Patterns: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -subgraph_sparsity.cppHeadings

- - - -
Subgraph Dependency Sparsity Patterns: Example and Test
-
# include <cppad/cppad.hpp>
-
-bool subgraph_sparsity(void)
-{     bool ok = true;
-     using CppAD::AD;
-     typedef CPPAD_TESTVECTOR(size_t)     SizeVector;
-     typedef CppAD::sparse_rc<SizeVector> sparsity;
-     //
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) ax(n);
-     ax[0] = 0.;
-     ax[1] = 1.;
-
-     // declare independent variables and start recording
-     CppAD::Independent(ax);
-
-     // range space vector
-     size_t m = 3;
-     CPPAD_TESTVECTOR(AD<double>) ay(m);
-     ay[0] = ax[0];
-     ay[1] = ax[0] * ax[1];
-     ay[2] = ax[1];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(ax, ay);
-
-
-
-     // compute sparsite pattern for F'(x)
-     CPPAD_TESTVECTOR(bool) select_domain(n), select_range(m);
-     for(size_t j = 0; j < n; j++)
-          select_domain[j] = true;
-     for(size_t i = 0; i < m; i++)
-          select_range[i] = true;
-     bool transpose       = false;
-     sparsity pattern_out;
-     f.subgraph_sparsity(select_domain, select_range, transpose, pattern_out);
-
-     // check sparsity pattern
-     size_t nnz = pattern_out.nnz();
-     ok        &= nnz == 4;
-     ok        &= pattern_out.nr() == m;
-     ok        &= pattern_out.nc() == n;
-     {     // check results
-          const SizeVector& row( pattern_out.row() );
-          const SizeVector& col( pattern_out.col() );
-          SizeVector col_major = pattern_out.col_major();
-          //
-          ok &= row[ col_major[0] ] ==  0  && col[ col_major[0] ] ==  0;
-          ok &= row[ col_major[1] ] ==  1  && col[ col_major[1] ] ==  0;
-          ok &= row[ col_major[2] ] ==  1  && col[ col_major[2] ] ==  1;
-          ok &= row[ col_major[3] ] ==  2  && col[ col_major[3] ] ==  1;
-     }
-     // note that the transpose of the identity is the identity
-     transpose     = true;
-     f.subgraph_sparsity(select_domain, select_range, transpose, pattern_out);
-     //
-     nnz  = pattern_out.nnz();
-     ok  &= nnz == 4;
-     ok  &= pattern_out.nr() == n;
-     ok  &= pattern_out.nc() == m;
-     {     // check results
-          const SizeVector& row( pattern_out.row() );
-          const SizeVector& col( pattern_out.col() );
-          SizeVector row_major = pattern_out.row_major();
-          //
-          ok &= col[ row_major[0] ] ==  0  && row[ row_major[0] ] ==  0;
-          ok &= col[ row_major[1] ] ==  1  && row[ row_major[1] ] ==  0;
-          ok &= col[ row_major[2] ] ==  1  && row[ row_major[2] ] ==  1;
-          ok &= col[ row_major[3] ] ==  2  && row[ row_major[3] ] ==  1;
-     }
-     return ok;
-}
-
-
Input File: example/sparse/subgraph_sparsity.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_subgraph_sparsity.cpp_xml.js cppad-2019.02.00.0/doc/_subgraph_sparsity.cpp_xml.js --- cppad-2018.00.00.0/doc/_subgraph_sparsity.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_subgraph_sparsity.cpp_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', -'adfun.xml', -'sparsity_pattern.xml', -'subgraph_sparsity.xml', -'subgraph_sparsity.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down1 = [ -'subgraph_sparsity.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-2018.00.00.0/doc/subgraph_sparsity.xml cppad-2019.02.00.0/doc/subgraph_sparsity.xml --- cppad-2018.00.00.0/doc/subgraph_sparsity.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/subgraph_sparsity.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,421 +0,0 @@ - - - -Subgraph Dependency Sparsity Patterns - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Subgraph Dependency Sparsity Patterns
-
-Syntax - -
- -f.subgraph_sparsity(
-     
select_domainselect_rangetransposepattern_out
-)
- - -
-
-Notation -
-We use - -F -: -R - -n - - -R - -m - - - - to denote the -AD function - corresponding to -the operation sequence stored in -f -. - - -
-
-Method -
-This routine uses a subgraph technique. To be specific, -for each dependent variable, -it creates a subgraph of the operation sequence -containing the variables that affect the dependent variable. -This avoids the overhead of performing set operations -that is inherent in other methods for computing sparsity patterns. - -
-
-Atomic Function -
-The sparsity calculation for -atomic functions - in the -f - operation sequence -are not efficient. To be specific, each atomic function is treated as if -all of its outputs depend on all of its inputs. -This may be improved upon in the future; see the -subgraph atomic functions - -wish list item. - -
-
-BoolVector -
-The type -BoolVector - is a SimpleVector - class with -elements of type - -bool. - -
-
-SizeVector -
-The type -SizeVector - is a SimpleVector - class with -elements of type - -size_t. - -
-
-f -
-The object -f - has prototype - -
-     ADFun<
Basef
-
-
-select_domain -
-The argument -select_domain - has prototype - -
-     const 
BoolVectorselect_domain
-
-It has size - -n - - - and specifies which independent variables -to include in the calculation. -If not all the independent variables are included in the calculation, -a forward pass on the operation sequence is used to determine which -nodes may be in the subgraphs. - -
-
-select_range -
-The argument -select_range - has prototype - -
-     const 
BoolVectorselect_range
-
-It has size - -m - - - and specifies which components of the range -to include in the calculation. -A subgraph is built for each dependent variable -and the selected set of independent variables. - -
-
-transpose -
-This argument has prototype - -
-     bool 
transpose
-
-If -transpose - it is false (true), -upon return -pattern_out - is a sparsity pattern for - - -J -( -x -) - - - ( - -J -( -x -) -T - - - - -) defined below. - -
-
-pattern_out -
-This argument has prototype - -
-     sparse_rc<
SizeVector>& pattern_out
-
-This input value of -pattern_out - does not matter. -Upon return -pattern_out - is a -dependency pattern - -for - -F -( -x -) - - -. -The pattern has - -m - - - rows, - -n - - - columns. -If -select_domain[j] - is true, - -select_range[i] - is true, and - - -F -i - -( -x -) - - - depends on - -x -j - - - -, -then the pair - -( -i -, -j -) - - - is in -pattern_out -. -Not that this is also a sparsity pattern for the Jacobian - - -J -( -x -) -= -R -F -( -1 -) - - -( -x -) -D - - -where - -D - - - ( - -R - - -) is the diagonal matrix corresponding -to -select_domain - ( -select_range -). - -
-
-Example - -
-The file -subgraph_sparsity.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/subgraph_sparsity.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_subgraph_sparsity_xml.js cppad-2019.02.00.0/doc/_subgraph_sparsity_xml.js --- cppad-2018.00.00.0/doc/_subgraph_sparsity_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_subgraph_sparsity_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'adfun.xml', -'sparsity_pattern.xml', -'subgraph_sparsity.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 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down1 = [ -'for_jac_sparsity.xml', -'forsparsejac.xml', -'rev_jac_sparsity.xml', -'revsparsejac.xml', -'rev_hes_sparsity.xml', -'revsparsehes.xml', -'for_hes_sparsity.xml', -'forsparsehes.xml', -'dependency.cpp.xml', -'rc_sparsity.cpp.xml', -'subgraph_sparsity.xml' -]; -var list_down0 = [ -'subgraph_sparsity.cpp.xml' -]; -var list_current0 = [ -'subgraph_sparsity.xml#Syntax', -'subgraph_sparsity.xml#Notation', -'subgraph_sparsity.xml#Method', -'subgraph_sparsity.xml#Atomic Function', -'subgraph_sparsity.xml#BoolVector', -'subgraph_sparsity.xml#SizeVector', -'subgraph_sparsity.xml#f', -'subgraph_sparsity.xml#select_domain', -'subgraph_sparsity.xml#select_range', -'subgraph_sparsity.xml#transpose', -'subgraph_sparsity.xml#pattern_out', -'subgraph_sparsity.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-2018.00.00.0/doc/sub_sparse_hes.cpp.xml cppad-2019.02.00.0/doc/sub_sparse_hes.cpp.xml --- cppad-2018.00.00.0/doc/sub_sparse_hes.cpp.xml 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/sub_sparse_hes.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,328 +0,0 @@ - - - -Computing Sparse Hessian for a Subset of Variables - - - - - - - - - - - - - - - - -
- -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/sparse/sub_sparse_hes.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_sub_sparse_hes.cpp_xml.js cppad-2019.02.00.0/doc/_sub_sparse_hes.cpp_xml.js --- cppad-2018.00.00.0/doc/_sub_sparse_hes.cpp_xml.js 2018-01-01 08:32:44.000000000 +0000 +++ cppad-2019.02.00.0/doc/_sub_sparse_hes.cpp_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', -'adfun.xml', -'sparse_derivative.xml', -'sparse_hessian.xml', -'sub_sparse_hes.cpp.xml' -]; -var list_down3 = [ -'record_adfun.xml', -'drivers.xml', -'forward.xml', -'reverse.xml', -'sparsity_pattern.xml', -'sparse_derivative.xml', -'optimize.xml', -'abs_normal.xml', -'funcheck.xml', -'check_for_nan.xml' -]; -var list_down2 = [ -'sparse_jac.xml', -'sparse_jacobian.xml', -'sparse_hes.xml', -'sparse_hessian.xml', -'subgraph_jac_rev.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-2018.00.00.0/doc/ta_available.xml cppad-2019.02.00.0/doc/ta_available.xml --- cppad-2018.00.00.0/doc/ta_available.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_available.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ - - - -Amount of Memory Available for Quick Use by a Thread - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_available - -

- - - -
Amount of Memory Available for Quick Use by a Thread
-
-Syntax - -
- -num_bytes = thread_alloc::available(thread) - - -
-
-Purpose -
-Memory being managed by 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. - -
-
-thread -
-This argument has prototype - -
-     size_t 
thread
-
-Either thread_num - must be the same as -thread -, -or the current execution mode must be sequential -(not parallel -). - -
-
-num_bytes -
-The return value has prototype - -
-     size_t 
num_bytes
-
-It is the number of bytes currently available for use by the specified thread. - -
-
-Example - -
-thread_alloc.cpp - - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_available_xml.js cppad-2019.02.00.0/doc/_ta_available_xml.js --- cppad-2018.00.00.0/doc/_ta_available_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_available_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'ta_available.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_available.xml#Syntax', -'ta_available.xml#Purpose', -'ta_available.xml#thread', -'ta_available.xml#num_bytes', -'ta_available.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-2018.00.00.0/doc/ta_create_array.xml cppad-2019.02.00.0/doc/ta_create_array.xml --- cppad-2018.00.00.0/doc/ta_create_array.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_create_array.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,261 +0,0 @@ - - - -Allocate An Array and Call Default Constructor for its Elements - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_create_array - -

- - - -
Allocate An Array and Call Default Constructor for its Elements
-
-Syntax - -
- -array = thread_alloc::create_array<Type>(size_minsize_out) -. - -
-
-Purpose -
-Create a new raw array using thread_alloc - memory allocator -(works well in a multi-threading environment) -and call default constructor for each element. - -
-
-Type -
-The type of the elements of the array. - -
-
-size_min -
-This argument has prototype - -
-     size_t 
size_min
-
-This is the minimum number of elements that there can be -in the resulting -array -. - -
-
-size_out -
-This argument has prototype - -
-     size_t& 
size_out
-
-The input value of this argument does not matter. -Upon return, it is the actual number of elements -in -array - -( - size_min <= size_out -). - -
-
-array -
-The return value -array - has prototype - -
-     
Typearray
-
-It is array with -size_out - elements. -The default constructor for -Type - is used to initialize the -elements of -array -. -Note that delete_array - -should be used to destroy the array when it is no longer needed. - -
-
-Delta -
-The amount of memory inuse - by the current thread, -will increase -delta - where - -
-     sizeof(
Type) * (size_out + 1) > delta >= sizeof(Type) * size_out
-
-The available - memory will decrease by -delta -, -(and the allocation will be faster) -if a previous allocation with -size_min - between its current value -and -size_out - is available. - -
-
-Alignment -
-We call a memory allocation aligned if the address is a multiple -of the number of bytes in a size_t value. -If the system new allocator is aligned, then -array - -pointer is also aligned. - -
-
-Example - -
-thread_alloc.cpp - - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_create_array_xml.js cppad-2019.02.00.0/doc/_ta_create_array_xml.js --- cppad-2018.00.00.0/doc/_ta_create_array_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_create_array_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'ta_create_array.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_create_array.xml#Syntax', -'ta_create_array.xml#Purpose', -'ta_create_array.xml#Type', -'ta_create_array.xml#size_min', -'ta_create_array.xml#size_out', -'ta_create_array.xml#array', -'ta_create_array.xml#Delta', -'ta_create_array.xml#Alignment', -'ta_create_array.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-2018.00.00.0/doc/ta_delete_array.xml cppad-2019.02.00.0/doc/ta_delete_array.xml --- cppad-2018.00.00.0/doc/ta_delete_array.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_delete_array.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,216 +0,0 @@ - - - -Deallocate An Array and Call Destructor for its Elements - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_delete_array - -

- - - -
Deallocate An Array and Call Destructor for its Elements
-
-Syntax - -
- -thread_alloc::delete_array(array) -. - -
-
-Purpose -
-Returns memory corresponding to an array created by -(create by create_array -) to the -available - memory pool for the current thread. - -
-
-Type -
-The type of the elements of the array. - -
-
-array -
-The argument -array - has prototype - -
-     
Typearray
-
-It is a value returned by create_array - and not yet deleted. -The -Type - destructor is called for each element in the array. - -
-
-Thread -
-The current thread - must be the -same as when create_array - returned the value -array -. -There is an exception to this rule: -when the current execution mode is sequential -(not parallel -) the current thread number does not matter. - -
-
-Delta -
-The amount of memory inuse - will decrease by -delta -, -and the available - memory will increase by -delta -, -where delta - -is the same as for the corresponding call to create_array. - -
-
-Example - -
-thread_alloc.cpp - - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_delete_array_xml.js cppad-2019.02.00.0/doc/_ta_delete_array_xml.js --- cppad-2018.00.00.0/doc/_ta_delete_array_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_delete_array_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', -'utility.xml', -'thread_alloc.xml', -'ta_delete_array.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_delete_array.xml#Syntax', -'ta_delete_array.xml#Purpose', -'ta_delete_array.xml#Type', -'ta_delete_array.xml#array', -'ta_delete_array.xml#Thread', -'ta_delete_array.xml#Delta', -'ta_delete_array.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-2018.00.00.0/doc/ta_free_all.xml cppad-2019.02.00.0/doc/ta_free_all.xml --- cppad-2018.00.00.0/doc/ta_free_all.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_free_all.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,184 +0,0 @@ - - - -Free All Memory That Was Allocated for Use by thread_alloc - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_free_all - -

- - - -
Free All Memory That Was Allocated for Use by thread_alloc
-
-Syntax - -
- -ok = thread_alloc::free_all() -. - -
-
-Purpose -
-Returns all memory that was used by thread_alloc to the system. - -
-
-ok -
-The return value -ok - has prototype - -
-     bool 
ok
-
-Its value will be true if all the memory can be freed. -This requires that for all -thread - indices, there is no memory -inuse -; i.e., - -
-     0 == thread_alloc::inuse(
thread)
-
-Otherwise, the return value will be false. - -
-
-Restrictions -
-This function cannot be called while in parallel mode. - -
-
-Example - -
-thread_alloc.cpp - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_free_all_xml.js cppad-2019.02.00.0/doc/_ta_free_all_xml.js --- cppad-2018.00.00.0/doc/_ta_free_all_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_free_all_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'ta_free_all.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_free_all.xml#Syntax', -'ta_free_all.xml#Purpose', -'ta_free_all.xml#ok', -'ta_free_all.xml#Restrictions', -'ta_free_all.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-2018.00.00.0/doc/ta_free_available.xml cppad-2019.02.00.0/doc/ta_free_available.xml --- cppad-2018.00.00.0/doc/ta_free_available.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_free_available.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,190 +0,0 @@ - - - -Free Memory Currently Available for Quick Use by a Thread - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_free_available - -

- - - -
Free Memory Currently Available for Quick Use by a Thread
-
-Syntax - -
- -thread_alloc::free_available(thread) - - -
-
-Purpose -
-Return to the system all the memory that is currently being -held - for quick use by the specified thread. - -
-
-Extra Memory -
-In the case where -thread > 0 -, -some extra memory is used to track allocations by the specified thread. -If - -
-     thread_alloc::inuse(
thread) == 0
-
-the extra memory is also returned to the system. - -
-
-thread -
-This argument has prototype - -
-     size_t 
thread
-
-Either thread_num - must be the same as -thread -, -or the current execution mode must be sequential -(not parallel -). - -
-
-Example - -
-thread_alloc.cpp - - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_free_available_xml.js cppad-2019.02.00.0/doc/_ta_free_available_xml.js --- cppad-2018.00.00.0/doc/_ta_free_available_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_free_available_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'ta_free_available.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_free_available.xml#Syntax', -'ta_free_available.xml#Purpose', -'ta_free_available.xml#Purpose.Extra Memory', -'ta_free_available.xml#thread', -'ta_free_available.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-2018.00.00.0/doc/ta_get_memory.xml cppad-2019.02.00.0/doc/ta_get_memory.xml --- cppad-2018.00.00.0/doc/ta_get_memory.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_get_memory.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,238 +0,0 @@ - - - -Get At Least A Specified Amount of Memory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_get_memory - -

- - - -
Get At Least A Specified Amount of Memory
-
-Syntax - -
- -v_ptr = thread_alloc::get_memory(min_bytescap_bytes) - - -
-
-Purpose -
-Use thread_alloc - to obtain a minimum number of bytes of memory -(for use by the current thread -). - -
-
-min_bytes -
-This argument has prototype - -
-     size_t 
min_bytes
-
-It specifies the minimum number of bytes to allocate. -This value must be less than -
 
-     std::numeric_limits<size_t>::max() / 2
-
-
-cap_bytes -
-This argument has prototype - -
-     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, - -
-     
min_bytes <= cap_bytes
-
-
-v_ptr -
-The return value -v_ptr - has prototype - -
-     void* 
v_ptr
-
-It is the location where the -cap_bytes - of memory -that have been allocated for use begins. - -
-
-Allocation Speed -
-This allocation should be faster if the following conditions hold: -
  1. -The memory allocated by a previous call to get_memory -is currently available for use. -
  2. - -The current -min_bytes - is between -the previous -min_bytes - and previous -cap_bytes -. -
- - -
-
-Alignment -
-We call a memory allocation aligned if the address is a multiple -of the number of bytes in a size_t value. -If the system new allocator is aligned, then -v_ptr - -pointer is also aligned. - -
-
-Example - -
-thread_alloc.cpp - - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_get_memory_xml.js cppad-2019.02.00.0/doc/_ta_get_memory_xml.js --- cppad-2018.00.00.0/doc/_ta_get_memory_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_get_memory_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'ta_get_memory.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_get_memory.xml#Syntax', -'ta_get_memory.xml#Purpose', -'ta_get_memory.xml#min_bytes', -'ta_get_memory.xml#cap_bytes', -'ta_get_memory.xml#v_ptr', -'ta_get_memory.xml#Allocation Speed', -'ta_get_memory.xml#Alignment', -'ta_get_memory.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-2018.00.00.0/doc/ta_hold_memory.xml cppad-2019.02.00.0/doc/ta_hold_memory.xml --- cppad-2018.00.00.0/doc/ta_hold_memory.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_hold_memory.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ - - - -Control When Thread Alloc Retains Memory For Future Use - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_hold_memory - -

- - - -
Control When Thread Alloc Retains Memory For Future Use
-
-Syntax - -
- -thread_alloc::hold_memory(value) - - -
-
-Purpose -
-It should be faster, even when -num_thread - is equal to one, -for thread_alloc to hold onto memory. -Calling -hold_memory - with -value - equal to true, -instructs thread_alloc to hold onto memory, -and put it in the available - pool, -after each call to return_memory -. - -
-
-value -
-If -value - is true, -thread_alloc with hold onto memory for future quick use. -If it is false, future calls to return_memory - -will return the corresponding memory to the system. -By default (when hold_memory has not been called) -thread_alloc does not hold onto memory. - -
-
-free_available -
-Memory that is being held by thread_alloc can be returned -to the system using free_available -. - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_hold_memory_xml.js cppad-2019.02.00.0/doc/_ta_hold_memory_xml.js --- cppad-2018.00.00.0/doc/_ta_hold_memory_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_hold_memory_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'ta_hold_memory.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_hold_memory.xml#Syntax', -'ta_hold_memory.xml#Purpose', -'ta_hold_memory.xml#value', -'ta_hold_memory.xml#free_available' -]; -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-2018.00.00.0/doc/ta_in_parallel.xml cppad-2019.02.00.0/doc/ta_in_parallel.xml --- cppad-2018.00.00.0/doc/ta_in_parallel.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_in_parallel.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ - - - -Is The Current Execution in Parallel Mode - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_in_parallel - -

- - -
Is The Current Execution in Parallel Mode
-
-Syntax - -
- -flag = thread_alloc::in_parallel() - - -
-
-Purpose -
-Some of the 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. - -
-
-flag -
-The return value has prototype - -
-     bool 
flag
-
-It is true if the current execution is in parallel mode -(possibly multi-threaded) and false otherwise (sequential mode). - -
-
-Example - -
-thread_alloc.cpp - - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_in_parallel_xml.js cppad-2019.02.00.0/doc/_ta_in_parallel_xml.js --- cppad-2018.00.00.0/doc/_ta_in_parallel_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_in_parallel_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'ta_in_parallel.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_in_parallel.xml#Syntax', -'ta_in_parallel.xml#Purpose', -'ta_in_parallel.xml#flag', -'ta_in_parallel.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-2018.00.00.0/doc/ta_inuse.xml cppad-2019.02.00.0/doc/ta_inuse.xml --- cppad-2018.00.00.0/doc/ta_inuse.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_inuse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ - - - -Amount of Memory a Thread is Currently Using - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_inuse - -

- - - -
Amount of Memory a Thread is Currently Using
-
-Syntax - -
- -num_bytes = thread_alloc::inuse(thread) - - -
-
-Purpose -
-Memory being managed by 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. - -
-
-thread -
-This argument has prototype - -
-     size_t 
thread
-
-Either thread_num - must be the same as -thread -, -or the current execution mode must be sequential -(not parallel -). - -
-
-num_bytes -
-The return value has prototype - -
-     size_t 
num_bytes
-
-It is the number of bytes currently in use by the specified thread. - -
-
-Example - -
-thread_alloc.cpp - - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_inuse_xml.js cppad-2019.02.00.0/doc/_ta_inuse_xml.js --- cppad-2018.00.00.0/doc/_ta_inuse_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_inuse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'ta_inuse.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_inuse.xml#Syntax', -'ta_inuse.xml#Purpose', -'ta_inuse.xml#thread', -'ta_inuse.xml#num_bytes', -'ta_inuse.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-2018.00.00.0/doc/tan.cpp.xml cppad-2019.02.00.0/doc/tan.cpp.xml --- cppad-2018.00.00.0/doc/tan.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/tan.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,159 +0,0 @@ - - - -The AD tan Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -tan.cppHeadings

-
The AD tan Function: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cmath>
-# include <limits>
-
-bool Tan(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>) x(n);
-     x[0]      = x0;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::tan(x[0]);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     double check = std::tan(x0);
-     ok &= NearEqual(y[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 = 1. + std::tan(x0) * std::tan(x0);
-     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, eps, eps);
-
-     // use a VecAD<Base>::reference object with tan
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero]           = x0;
-     AD<double> result = CppAD::tan(v[zero]);
-     check = std::tan(x0);
-     ok   &= NearEqual(result, check, eps, eps);
-
-     return ok;
-}
-
-
-
Input File: example/general/tan.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_tan.cpp_xml.js cppad-2019.02.00.0/doc/_tan.cpp_xml.js --- cppad-2018.00.00.0/doc/_tan.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_tan.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'tan.xml', -'tan.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 = [ -'tan.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-2018.00.00.0/doc/tan_forward.xml cppad-2019.02.00.0/doc/tan_forward.xml --- cppad-2018.00.00.0/doc/tan_forward.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/tan_forward.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,671 +0,0 @@ - - - -Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -tan_forward - -

-
Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory
-
-Derivatives - - - - -tan -( -1 -) - - -( -u -) - -= - -[ -cos -( -u -) -2 - -+ -sin -( -u -) -2 - -] -/ -cos -( -u -) -2 - - - -= - -1 -+ -tan -( -u -) -2 - - -tanh -( -1 -) - - -( -u -) - -= - -[ -cosh -( -u -) -2 - -- -sinh -( -u -) -2 - -] -/ -cosh -( -u -) -2 - - - -= - -1 -- -tanh -( -u -) -2 - - - - -If - -F -( -u -) - - - is - -tan -( -u -) - - - or - -tanh -( -u -) - - - -the corresponding derivative is given by - - -F -( -1 -) - - -( -u -) -= -1 -± -F -( -u -) -2 - - - -Given - -X -( -t -) - - -, we define the function - -Z -( -t -) -= -F -[ -X -( -t -) -] - - -. -It follows that - - -Z -( -1 -) - - -( -t -) -= -F -( -1 -) - - -[ -X -( -t -) -] -X -( -1 -) - - -( -t -) -= -[ -1 -± -Y -( -t -) -] -X -( -1 -) - - -( -t -) - - -where we define the function - -Y -( -t -) -= -Z -( -t -) -2 - - - -. - -
-
-Taylor Coefficients Recursion -
-Suppose that we are given the Taylor coefficients -up to order - -j - - - for the function - -X -( -t -) - - - and -up to order - -j --1 - - - for the functions - -Y -( -t -) - - - and - -Z -( -t -) - - -. -We need a formula that computes the coefficient of order - -j - - - -for - -Y -( -t -) - - - and - -Z -( -t -) - - -. -Using the equation above for - -Z -( -1 -) - - -( -t -) - - -, we have - - - - -k -= -1 - -j - -k -z -( -k -) - - -t -k --1 - - - -= - - -k -= -1 - -j - -k -x -( -k -) - - -t -k --1 - - -± -[ -k -= -0 - -j --1 - - -y -( -k -) - - -t -k - -] -[ -k -= -1 - -j - -k -x -( -k -) - - -t -k --1 - - -] -+ -o -( -t -j --1 - - -) - - - -Setting the coefficients of - -t -j --1 - - - - - equal, we have - - - -j -z -( -j -) - - -= -j -x -( -j -) - - -± - -k -= -1 - -j - -k -x -( -k -) - - -y -( -j -- -k -) - - - -z -( -j -) - - -= -x -( -j -) - - -± -1 - -j - - - -k -= -1 - -j - -k -x -( -k -) - - -y -( -j -- -k -) - - - - - -Once we have computed - -z -( -j -) - - - - -, -we can compute - -y -( -j -) - - - - - as follows: - - -y -( -j -) - - -= - -k -= -0 - -j - -z -( -k -) - - -z -( -j -- -k -) - - - - - -
Input File: omh/appendix/theory/tan_forward.omh - - - diff -Nru cppad-2018.00.00.0/doc/_tan_forward_xml.js cppad-2019.02.00.0/doc/_tan_forward_xml.js --- cppad-2018.00.00.0/doc/_tan_forward_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_tan_forward_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', -'appendix.xml', -'theory.xml', -'forwardtheory.xml', -'tan_forward.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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 = [ -'tan_forward.xml#Derivatives', -'tan_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-2018.00.00.0/doc/tanh.cpp.xml cppad-2019.02.00.0/doc/tanh.cpp.xml --- cppad-2018.00.00.0/doc/tanh.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/tanh.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,159 +0,0 @@ - - - -The AD tanh Function: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -tanh.cppHeadings

-
The AD tanh Function: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cmath>
-# include <limits>
-
-bool Tanh(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps = 10. * CppAD::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);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = CppAD::tanh(x[0]);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check value
-     double check = std::tanh(x0);
-     ok &= NearEqual(y[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 = 1. - std::tanh(x0) * std::tanh(x0);
-     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, eps, eps);
-
-     // use a VecAD<Base>::reference object with tan
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero]           = x0;
-     AD<double> result = CppAD::tanh(v[zero]);
-     check = std::tanh(x0);
-     ok   &= NearEqual(result, check, eps, eps);
-
-     return ok;
-}
-
-
-
Input File: example/general/tanh.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_tanh.cpp_xml.js cppad-2019.02.00.0/doc/_tanh.cpp_xml.js --- cppad-2018.00.00.0/doc/_tanh.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_tanh.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'unary_standard_math.xml', -'tanh.xml', -'tanh.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 = [ -'tanh.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-2018.00.00.0/doc/tanh.xml cppad-2019.02.00.0/doc/tanh.xml --- cppad-2018.00.00.0/doc/tanh.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/tanh.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ - - - -The Hyperbolic Tangent Function: tanh - - - - - - - - - - - - - - - - -
- -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_tanh_xml.js cppad-2019.02.00.0/doc/_tanh_xml.js --- cppad-2018.00.00.0/doc/_tanh_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_tanh_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'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-2018.00.00.0/doc/tan_reverse.xml cppad-2019.02.00.0/doc/tan_reverse.xml --- cppad-2018.00.00.0/doc/tan_reverse.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/tan_reverse.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,929 +0,0 @@ - - - -Tangent and Hyperbolic Tangent Reverse Mode Theory - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -tan_reverse - -

-
Tangent and Hyperbolic Tangent Reverse Mode Theory
-
-Notation -
-We use the reverse theory -standard math function - -definition for the functions - -H - - - and - -G - - -. -In addition, we use the forward mode notation in tan_forward - for - - -X -( -t -) - - -, - -Y -( -t -) - - - and - -Z -( -t -) - - -. - -
-
-Eliminating Y(t) -
-For - -j -> -0 - - -, the forward mode coefficients are given by - - -y -( -j --1 -) - - -= - -k -= -0 - -j --1 - - -z -( -k -) - - -z -( -j -- -k --1 -) - - - - -Fix - -j -> -0 - - - and suppose that - -H - - - is the same as - -G - - - -except that - -y -( -j --1 -) - - - - - is replaced as a function of the Taylor -coefficients for - -Z -( -t -) - - -. -To be specific, for - -k -= -0 -, - -, -j --1 - - -, - - - - -H - - -z -( -k -) - - - - - -= - - -G - - -z -( -k -) - - - - -+ - -G - - -y -( -j --1 -) - - - - - -y -( -j --1 -) - - - - -z -( -k -) - - - - - - -= - - -G - - -z -( -k -) - - - - -+ - -G - - -y -( -j --1 -) - - - - -2 -z -( -j -- -k --1 -) - - - - - -
-Positive Orders Z(t) -
-For order - -j -> -0 - - -, -suppose that - -H - - - is the same as - -G - - - except that - - -z -( -j -) - - - - - is expressed as a function of -the coefficients for - -X -( -t -) - - -, and the -lower order Taylor coefficients for - -Y -( -t -) - - -, - -Z -( -t -) - - -. - - -z -( -j -) - - -= -x -( -j -) - - -± -1 - -j - - - -k -= -1 - -j - -k -x -( -k -) - - -y -( -j -- -k -) - - - - -For - -k -= -1 -, - -, -j - - -, -the partial of - -H - - - with respect to - -x -( -k -) - - - - - is given by - - - - -H - - -x -( -k -) - - - - - -= - - -G - - -x -( -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -x -( -k -) - - - - - - -= - - -G - - -x -( -k -) - - - - -+ - -G - - -z -( -j -) - - - - -[δ -( -j -- -k -) -± -k - -j - - -y -( -j -- -k -) - - -] - - - -where - -δ -( -j -- -k -) - - - is one if - -j -= -k - - - and zero -otherwise. -For - -k -= -1 -, - -, -j - - - -The partial of - -H - - - with respect to - -y -j -- -k - - - - -, -is given by - - - - -H - - -y -( -j -- -k -) - - - - - -= - - -G - - -y -( -j -- -k -) - - - - -+ - -G - - -z -( -j -) - - - - - -z -( -j -) - - - - -y -( -j -- -k -) - - - - - - -= - - -G - - -y -( -j -- -k -) - - - - -± - -G - - -z -( -j -) - - - - -k - -j - - -x -k - - - - - -
-Order Zero Z(t) -
-The order zero coefficients for the tangent and hyperbolic tangent are - - - -z -( -0 -) - - - -= - -{ -tan -( -x -( -0 -) - - -) - -tanh -( -x -( -0 -) - - -) - - - - - -Suppose that - -H - - - is the same as - -G - - - except that - - -z -( -0 -) - - - - - is expressed as a function of the Taylor coefficients -for - -X -( -t -) - - -. -In this case, - - - - -H - - -x -( -0 -) - - - - - -= - - -G - - -x -( -0 -) - - - - -+ - -G - - -z -( -0 -) - - - - - -z -( -0 -) - - - - -x -( -0 -) - - - - - - -= - - -G - - -x -( -0 -) - - - - -+ - -G - - -z -( -0 -) - - - - -( -1 -± -y -( -0 -) - - -) - - - - -
Input File: omh/appendix/theory/tan_reverse.omh - - - diff -Nru cppad-2018.00.00.0/doc/_tan_reverse_xml.js cppad-2019.02.00.0/doc/_tan_reverse_xml.js --- cppad-2018.00.00.0/doc/_tan_reverse_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_tan_reverse_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'tan_reverse.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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' -]; -var list_current0 = [ -'tan_reverse.xml#Notation', -'tan_reverse.xml#Eliminating Y(t)', -'tan_reverse.xml#Positive Orders Z(t)', -'tan_reverse.xml#Order Zero Z(t)' -]; -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-2018.00.00.0/doc/ta_num_threads.xml cppad-2019.02.00.0/doc/ta_num_threads.xml --- cppad-2018.00.00.0/doc/ta_num_threads.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_num_threads.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,173 +0,0 @@ - - - -Get Number of Threads - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_num_threads - -

- - -
Get Number of Threads
-
-Syntax - -
- -number = thread_alloc::num_threads() - - -
-
-Purpose -
-Determine the number of threads as set during parallel_setup -. - -
-
-number -
-The return value -number - has prototype - -
-     size_t 
number
-
-and is equal to the value of -num_threads - -in the previous call to -parallel_setup -. -If there was no such previous call, the value one is returned. - -
-
-Example -
-The example and test thread_alloc.cpp - uses this routine. - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_num_threads_xml.js cppad-2019.02.00.0/doc/_ta_num_threads_xml.js --- cppad-2018.00.00.0/doc/_ta_num_threads_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_num_threads_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'ta_num_threads.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_num_threads.xml#Syntax', -'ta_num_threads.xml#Purpose', -'ta_num_threads.xml#number', -'ta_num_threads.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-2018.00.00.0/doc/tan.xml cppad-2019.02.00.0/doc/tan.xml --- cppad-2018.00.00.0/doc/tan.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/tan.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ - - - -The Tangent Function: tan - - - - - - - - - - - - - - - - -
- -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/core/std_math_98.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_tan_xml.js cppad-2019.02.00.0/doc/_tan_xml.js --- cppad-2018.00.00.0/doc/_tan_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_tan_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +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', -'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-2018.00.00.0/doc/ta_parallel_setup.xml cppad-2019.02.00.0/doc/ta_parallel_setup.xml --- cppad-2018.00.00.0/doc/ta_parallel_setup.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_parallel_setup.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,255 +0,0 @@ - - - -Setup thread_alloc For Use in Multi-Threading Environment - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_parallel_setup - -

-
Setup thread_alloc For Use in Multi-Threading Environment
-
-Syntax - -
- -thread_alloc::parallel_setup(num_threadsin_parallelthread_num)
-
-
-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. - -
-
-Speed -
-It should be faster, even when -num_thread - is equal to one, -for thread_alloc to hold onto memory. -This can be accomplished using the function call - -
-     thread_alloc::hold_memory(true)
-
-see hold_memory -. - -
-
-num_threads -
-This argument has prototype - -
-     size_t 
num_threads
-
-and must be greater than zero. -It specifies the number of threads that are sharing memory. -The case -num_threads == 1 - is a special case that is -used to terminate a multi-threading environment. - -
-
-in_parallel -
-This function has prototype - -
-     bool 
in_parallel(void)
-
-It must return true if there is more than one thread -currently executing. -Otherwise it can return false. -
-
-
In the special case where -num_threads == 1 -, -the routine -in_parallel - is not used. - -
-
-thread_num -
-This function has prototype - -
-     size_t 
thread_num(void)
-
-It must return a thread number that uniquely identifies the -currently executing thread. -Furthermore - -
-     0 <= 
thread_num() < num_threads
-
-. -In the special case where -num_threads == 1 -, -the routine -thread_num - is not used. -
-
-
Note that this function is called by other routines so, -as soon as a new thread is executing, -one must be certain that -thread_num() - will -work for that thread. - -
-
-Restrictions -
-The function parallel_setup must be called before -the program enters parallel - execution mode. -In addition, this function cannot be called while in parallel mode. - -
-
-Example -
-The files -simple_ad_openmp.cpp -, -simple_ad_bthread.cpp -, and -simple_ad_pthread.cpp -, -contain examples and tests that use this function. - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_parallel_setup_xml.js cppad-2019.02.00.0/doc/_ta_parallel_setup_xml.js --- cppad-2018.00.00.0/doc/_ta_parallel_setup_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_parallel_setup_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'ta_parallel_setup.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_parallel_setup.xml#Syntax', -'ta_parallel_setup.xml#Purpose', -'ta_parallel_setup.xml#Speed', -'ta_parallel_setup.xml#num_threads', -'ta_parallel_setup.xml#in_parallel', -'ta_parallel_setup.xml#thread_num', -'ta_parallel_setup.xml#Restrictions', -'ta_parallel_setup.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-2018.00.00.0/doc/tape_index.cpp.xml cppad-2019.02.00.0/doc/tape_index.cpp.xml --- cppad-2018.00.00.0/doc/tape_index.cpp.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/tape_index.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ - - - -Taping Array Index Operation: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -tape_index.cppHeadings

- - -
Taping Array Index Operation: Example and Test
-
# include <cppad/cppad.hpp>
-
-namespace {
-     double Array(const double &index)
-     {     static double array[] = {
-               5.,
-               4.,
-               3.,
-               2.,
-               1.
-          };
-          static size_t number = sizeof(array) / sizeof(array[0]);
-          if( index < 0. )
-               return array[0];
-
-          size_t i = static_cast<size_t>(index);
-          if( i >= number )
-               return array[number-1];
-
-          return array[i];
-     }
-     // in empty namespace and outside any other routine
-     CPPAD_DISCRETE_FUNCTION(double, Array)
-}
-
-bool TapeIndex(void)
-{     bool ok = true;
-     using CppAD::AD;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) X(n);
-     X[0] = 2.;   // array index value
-     X[1] = 3.;   // multiplier of array index value
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(X);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) Y(m);
-     Y[0] = X[1] * Array( X[0] );
-
-     // create f: X -> Y and stop tape recording
-     CppAD::ADFun<double> f(X, Y);
-
-     // 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) dw(n);  // derivative of weighted function
-
-     // check function value
-     x[0] = Value(X[0]);
-     x[1] = Value(X[1]);
-     y[0] = Value(Y[0]);
-     ok  &= y[0] == x[1] * Array(x[0]);
-
-     // evaluate f where x has different values
-     x[0] = x[0] + 1.;  // new array index value
-     x[1] = x[1] + 1.;  // new multiplier value
-     y    = f.Forward(0, x);
-     ok  &= y[0] == x[1] * Array(x[0]);
-
-     // evaluate derivaitve of y[0]
-     w[0] = 1.;
-     dw   = f.Reverse(1, w);
-     ok   &= dw[0] == 0.;              // partial w.r.t array index
-     ok   &= dw[1] == Array(x[0]);     // partial w.r.t multiplier
-
-     return ok;
-}
-
-
-
Input File: example/general/tape_index.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_tape_index.cpp_xml.js cppad-2019.02.00.0/doc/_tape_index.cpp_xml.js --- cppad-2018.00.00.0/doc/_tape_index.cpp_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_tape_index.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +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', -'discrete.xml', -'tape_index.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 = [ -'tape_index.cpp.xml', -'interp_onetape.cpp.xml', -'interp_retape.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-2018.00.00.0/doc/ta_return_memory.xml cppad-2019.02.00.0/doc/ta_return_memory.xml --- cppad-2018.00.00.0/doc/ta_return_memory.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_return_memory.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,201 +0,0 @@ - - - -Return Memory to thread_alloc - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_return_memory - -

- - - -
Return Memory to thread_alloc
-
-Syntax - -
- -thread_alloc::return_memory(v_ptr) - - -
-
-Purpose -
-If hold_memory - is false, -the memory is returned to the system. -Otherwise, the memory is retained by thread_alloc - for quick future use -by the thread that allocated to memory. - -
-
-v_ptr -
-This argument has prototype - -
-     void* 
v_ptr
-
-. -It must be a pointer to memory that is currently in use; i.e. -obtained by a previous call to -get_memory - and not yet returned. - -
-
-Thread -
-Either the current thread - must be the same as during -the corresponding call to get_memory -, -or the current execution mode must be sequential -(not parallel -). - -
-
-NDEBUG -
-If NDEBUG is defined, -v_ptr - is not checked (this is faster). -Otherwise, a list of in use pointers is searched to make sure -that -v_ptr - is in the list. - -
-
-Example - -
-thread_alloc.cpp - - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_return_memory_xml.js cppad-2019.02.00.0/doc/_ta_return_memory_xml.js --- cppad-2018.00.00.0/doc/_ta_return_memory_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_return_memory_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'ta_return_memory.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_return_memory.xml#Syntax', -'ta_return_memory.xml#Purpose', -'ta_return_memory.xml#v_ptr', -'ta_return_memory.xml#Thread', -'ta_return_memory.xml#NDEBUG', -'ta_return_memory.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-2018.00.00.0/doc/ta_thread_num.xml cppad-2019.02.00.0/doc/ta_thread_num.xml --- cppad-2018.00.00.0/doc/ta_thread_num.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/ta_thread_num.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,170 +0,0 @@ - - - -Get the Current Thread Number - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -ta_thread_num - -

- - - -
Get the Current Thread Number
-
-Syntax - -
- -thread = thread_alloc::thread_num() - - -
-
-Purpose -
-Some of the thread_alloc - allocation routines have a thread number. -This routine enables you to determine the current thread. - -
-
-thread -
-The return value -thread - has prototype - -
-     size_t 
thread
-
-and is the currently executing thread number. - -
-
-Example - -
-thread_alloc.cpp - - - -
Input File: cppad/utility/thread_alloc.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_ta_thread_num_xml.js cppad-2019.02.00.0/doc/_ta_thread_num_xml.js --- cppad-2018.00.00.0/doc/_ta_thread_num_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_ta_thread_num_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'ta_thread_num.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'ta_thread_num.xml#Syntax', -'ta_thread_num.xml#Purpose', -'ta_thread_num.xml#thread', -'ta_thread_num.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-2018.00.00.0/doc/team_bthread.cpp.xml cppad-2019.02.00.0/doc/team_bthread.cpp.xml --- cppad-2018.00.00.0/doc/team_bthread.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/team_bthread.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,328 +0,0 @@ - - - -Boost Thread Implementation of a Team of AD Threads - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -team_bthread.cppHeadings

-
Boost Thread Implementation of a Team of AD Threads
-See team_thread.hpp - for this routines specifications. - - -
# include <boost/thread.hpp>
-# include <cppad/cppad.hpp>
-# include "../team_thread.hpp"
-# define MAX_NUMBER_THREADS 48
-
-namespace {
-     using CppAD::thread_alloc;
-
-     // number of threads in the team
-     size_t num_threads_ = 1;
-
-     // no need to cleanup up thread specific data
-     void cleanup(size_t*)
-     {     return; }
-
-     // thread specific pointer the thread number (initialize as null)
-     boost::thread_specific_ptr<size_t> thread_num_ptr_(cleanup);
-
-     // type of the job currently being done by each thread
-     enum thread_job_t { init_enum, work_enum, join_enum } thread_job_;
-
-     // barrier used to wait for other threads to finish work
-     boost::barrier* wait_for_work_ = CPPAD_NULL;
-
-     // barrier used to wait for master thread to set next job
-     boost::barrier* wait_for_job_ = CPPAD_NULL;
-
-     // Are we in sequential mode; i.e., other threads are waiting for
-     // master thread to set up next job ?
-     bool sequential_execution_ = true;
-
-     // structure with information for one thread
-     typedef struct {
-          // The thread
-          boost::thread*       bthread;
-          // CppAD thread number as global (pointed to by thread_num_ptr_)
-          size_t               thread_num;
-          // true if no error for this thread, false otherwise.
-          bool                 ok;
-     } thread_one_t;
-
-     // vector with information for all threads
-     thread_one_t thread_all_[MAX_NUMBER_THREADS];
-
-     // pointer to function that does the work for one thread
-     void (* worker_)(void) = CPPAD_NULL;
-
-     // ---------------------------------------------------------------------
-     // in_parallel()
-     bool in_parallel(void)
-     {     return ! sequential_execution_; }
-
-     // ---------------------------------------------------------------------
-     // thread_number()
-     size_t thread_number(void)
-     {     // return thread_all_[thread_num].thread_num
-          return *thread_num_ptr_.get();
-     }
-     // --------------------------------------------------------------------
-     // function that gets called by boost thread constructor
-     void thread_work(size_t thread_num)
-     {     bool ok = wait_for_work_ != CPPAD_NULL;
-          ok     &= wait_for_job_  != CPPAD_NULL;
-          ok     &= thread_num     != 0;
-
-          // thread specific storage of thread number for this thread
-          thread_num_ptr_.reset(& thread_all_[thread_num].thread_num );
-
-          while( true )
-          {
-               // Use wait_for_jog_ to give master time in sequential mode
-               // (so it can change global information like thread_job_)
-               wait_for_job_->wait();
-
-               // case where we are terminating this thread (no more work)
-               if( thread_job_ == join_enum)
-                    break;
-
-               // only other case once wait_for_job_ has been completed (so far)
-               ok &= thread_job_ == work_enum;
-               worker_();
-
-               // Use wait_for_work_ to inform master that our work is done and
-               // that this thread will not use global infromation until
-               // passing its barrier wait_for_job_ above.
-               wait_for_work_->wait();
-
-          }
-          thread_all_[thread_num].ok &= ok;
-          return;
-     }
-}
-
-bool team_create(size_t num_threads)
-{     bool ok = true;;
-
-     if( num_threads > MAX_NUMBER_THREADS )
-     {     std::cerr << "team_create: num_threads greater than ";
-          std::cerr << MAX_NUMBER_THREADS << std::endl;
-          exit(1);
-     }
-     // check that we currently do not have multiple threads running
-     ok  = num_threads_ == 1;
-     ok &= wait_for_work_ == CPPAD_NULL;
-     ok &= wait_for_job_  == CPPAD_NULL;
-     ok &= sequential_execution_;
-
-     size_t thread_num;
-     for(thread_num = 0; thread_num < num_threads; thread_num++)
-     {     // Each thread gets a pointer to its version of this thread_num
-          // so it knows which section of thread_all it is working with
-          thread_all_[thread_num].thread_num = thread_num;
-
-          // initialize
-          thread_all_[thread_num].ok = true;
-          thread_all_[0].bthread     = CPPAD_NULL;
-     }
-     // Finish setup of thread_all_ for this thread
-     thread_num_ptr_.reset(& thread_all_[0].thread_num);
-
-     // Now that thread_number() has necessary information for the case
-     // num_threads_ == 1, and while still in sequential mode,
-     // call setup for using CppAD::AD<double> in parallel mode.
-     thread_alloc::parallel_setup(num_threads, in_parallel, thread_number);
-     thread_alloc::hold_memory(true);
-     CppAD::parallel_ad<double>();
-
-     // now change num_threads_ to its final value.
-     num_threads_ = num_threads;
-
-     // initialize two barriers, one for work done, one for new job ready
-     wait_for_work_ = new boost::barrier( (unsigned int) num_threads );
-     wait_for_job_  = new boost::barrier( (unsigned int) num_threads );
-
-     // initial job for the threads
-     thread_job_           = init_enum;
-     if( num_threads > 1 )
-          sequential_execution_ = false;
-
-     // 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_all_[thread_num].bthread =
-               new boost::thread(thread_work, thread_num);
-     }
-
-     // Current state is other threads are at wait_for_job_.
-     // This master thread (thread zero) has not completed wait_for_job_
-     sequential_execution_ = true;
-     return ok;
-}
-
-bool team_work(void worker(void))
-{
-     // Current state is other threads are at wait_for_job_.
-     // This master thread (thread zero) has not completed wait_for_job_
-     bool ok = sequential_execution_;
-     ok     &= thread_number() == 0;
-     ok     &= wait_for_work_  != CPPAD_NULL;
-     ok     &= wait_for_job_   != CPPAD_NULL;
-
-     // set global version of this work routine
-     worker_ = worker;
-
-     // set the new job that other threads are waiting for
-     thread_job_ = work_enum;
-
-     // Enter parallel exectuion when master thread calls wait_for_job_
-     if( num_threads_ > 1 )
-          sequential_execution_ = false;
-     wait_for_job_->wait();
-
-     // Now do the work in this thread and then wait
-     // until all threads have completed wait_for_work_
-     worker();
-     wait_for_work_->wait();
-
-     // Current state is other threads are at wait_for_job_.
-     // This master thread (thread zero) has not completed wait_for_job_
-     sequential_execution_ = true;
-
-     size_t thread_num;
-     for(thread_num = 0; thread_num < num_threads_; thread_num++)
-          ok &= thread_all_[thread_num].ok;
-     return ok;
-}
-
-bool team_destroy(void)
-{     // Current state is other threads are at wait_for_job_.
-     // This master thread (thread zero) has not completed wait_for_job_
-     bool ok = sequential_execution_;
-     ok     &= thread_number() == 0;
-     ok     &= wait_for_work_ != CPPAD_NULL;
-     ok     &= wait_for_job_  != CPPAD_NULL;
-
-     // 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_
-     if( num_threads_ > 1 )
-               sequential_execution_ = false;
-     wait_for_job_->wait();
-
-     // now wait for the other threads to be destroyed
-     size_t thread_num;
-     ok &= thread_all_[0].bthread == CPPAD_NULL;
-     for(thread_num = 1; thread_num < num_threads_; thread_num++)
-     {     thread_all_[thread_num].bthread->join();
-          delete thread_all_[thread_num].bthread;
-          thread_all_[thread_num].bthread = CPPAD_NULL;
-     }
-     // now we are down to just the master thread (thread zero)
-     sequential_execution_ = true;
-
-     // destroy wait_for_work_
-     delete wait_for_work_;
-     wait_for_work_ = CPPAD_NULL;
-
-     // destroy wait_for_job_
-     delete wait_for_job_;
-     wait_for_job_ = CPPAD_NULL;
-
-     // check ok before changing num_threads_
-     for(thread_num = 0; thread_num < num_threads_; thread_num++)
-          ok &= thread_all_[thread_num].ok;
-
-     // now inform CppAD that there is only one thread
-     num_threads_ = 1;
-     thread_alloc::parallel_setup(num_threads_, CPPAD_NULL, CPPAD_NULL);
-     thread_alloc::hold_memory(false);
-     CppAD::parallel_ad<double>();
-
-     return ok;
-}
-
-const char* team_name(void)
-{     return "bthread"; }
-
-
Input File: example/multi_thread/bthread/team_bthread.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_team_bthread.cpp_xml.js cppad-2019.02.00.0/doc/_team_bthread.cpp_xml.js --- cppad-2018.00.00.0/doc/_team_bthread.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_team_bthread.cpp_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'team_thread.hpp.xml', -'team_bthread.cpp.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'team_openmp.cpp.xml', -'team_bthread.cpp.xml', -'team_pthread.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-2018.00.00.0/doc/team_example.cpp.xml cppad-2019.02.00.0/doc/team_example.cpp.xml --- cppad-2018.00.00.0/doc/team_example.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/team_example.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,226 +0,0 @@ - - - -Using a Team of AD Threads: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -team_example.cpp - -

-
Using a Team of AD Threads: Example and Test
-
-Purpose -
-This example demonstrates how use a team of threads with CppAD. - -
-
-thread_team -
-The following three implementations of the -team_thread.hpp - specifications are included: - - - - -
- -team_openmp.cpp -OpenMP Implementation of a Team of AD Threads
- -team_bthread.cpp -Boost Thread Implementation of a Team of AD Threads
- -team_pthread.cpp -Pthread Implementation of a Team of AD Threads
- -
-
-Source Code - - -

-# include <cppad/cppad.hpp>
-# include "team_thread.hpp"
-# define NUMBER_THREADS  4
-
-namespace {
-     using CppAD::thread_alloc;
-
-     // structure with information for one thread
-     typedef struct {
-          // function argument (worker input)
-          double          x;
-          // false if an error occurs, true otherwise (worker output)
-          bool            ok;
-     } work_one_t;
-     // vector with information for all threads
-     // (use pointers instead of values to avoid false sharing)
-     work_one_t* work_all_[NUMBER_THREADS];
-     // --------------------------------------------------------------------
-     // function that does the work for one thread
-     void worker(void)
-     {     using CppAD::NearEqual;
-          using CppAD::AD;
-          bool ok = true;
-          size_t thread_num = thread_alloc::thread_num();
-
-          // CppAD::vector uses the CppAD fast multi-threading allocator
-          CppAD::vector< AD<double> > ax(1), ay(1);
-          ax[0] = work_all_[thread_num]->x;
-          Independent(ax);
-          ay[0] = sqrt( ax[0] * ax[0] );
-          CppAD::ADFun<double> f(ax, ay);
-
-          // Check function value corresponds to the identity
-          double eps = 10. * CppAD::numeric_limits<double>::epsilon();
-          ok        &= NearEqual(ay[0], ax[0], eps, eps);
-
-          // Check derivative value corresponds to the identity.
-          CppAD::vector<double> d_x(1), d_y(1);
-          d_x[0] = 1.;
-          d_y    = f.Forward(1, d_x);
-          ok    &= NearEqual(d_x[0], 1., eps, eps);
-
-          // pass back ok information for this thread
-          work_all_[thread_num]->ok = ok;
-     }
-}
-
-// This test routine is only called by the master thread (thread_num = 0).
-bool team_example(void)
-{     bool ok = true;
-
-     size_t num_threads = NUMBER_THREADS;
-
-     // Check that no memory is in use or avialable at start
-     // (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;
-     }
-
-     // initialize work_all_
-     for(thread_num = 0; thread_num < num_threads; thread_num++)
-     {     // allocate separate memory for this thread to avoid false sharing
-          size_t min_bytes(sizeof(work_one_t)), cap_bytes;
-          void*  v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes);
-          work_all_[thread_num]     = static_cast<work_one_t*>(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
-          work_all_[thread_num]->x  = double(thread_num) + 1.;
-     }
-
-     ok &= team_create(num_threads);
-     ok &= team_work(worker);
-     ok &= team_destroy();
-
-     // go down so that free memrory for other threads before memory for master
-     thread_num = num_threads;
-     while(thread_num--)
-     {     // check that this thread was ok with the work it did
-          ok &= work_all_[thread_num]->ok;
-          // delete problem specific information
-          void* v_ptr = static_cast<void*>( work_all_[thread_num] );
-          thread_alloc::return_memory( v_ptr );
-          // check that there is no longer any memory inuse by this thread
-          // (for general applications, the master might still be using memory)
-          ok &= thread_alloc::inuse(thread_num) == 0;
-          // return all memory being held for future use by this thread
-          thread_alloc::free_available(thread_num);
-     }
-     return ok;
-}
-
-
Input File: example/multi_thread/team_example.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_team_example.cpp_xml.js cppad-2019.02.00.0/doc/_team_example.cpp_xml.js --- cppad-2018.00.00.0/doc/_team_example.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_team_example.cpp_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'team_example.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down1 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_current0 = [ -'team_example.cpp.xml#Purpose', -'team_example.cpp.xml#thread_team', -'team_example.cpp.xml#Source Code' -]; -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-2018.00.00.0/doc/team_openmp.cpp.xml cppad-2019.02.00.0/doc/team_openmp.cpp.xml --- cppad-2018.00.00.0/doc/team_openmp.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/team_openmp.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,168 +0,0 @@ - - - -OpenMP Implementation of a Team of AD Threads - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -team_openmp.cppHeadings

-
OpenMP Implementation of a Team of AD Threads
-See team_thread.hpp - for this routines specifications. - - -
# include <omp.h>
-# include <cppad/cppad.hpp>
-# include "../team_thread.hpp"
-
-namespace {
-     using CppAD::thread_alloc;
-
-     // number of threads in this team
-     size_t num_threads_;
-
-     // used to inform CppAD when we are in parallel execution mode
-     bool in_parallel(void)
-     {     return omp_in_parallel() != 0; }
-
-     // used to inform CppAD of the current thread number
-     size_t thread_num(void)
-     {     return static_cast<size_t>( omp_get_thread_num() ); }
-}
-
-bool team_create(size_t num_threads)
-{
-     bool ok = ! in_parallel();
-     ok     &= thread_num() == 0;;
-     ok     &= num_threads > 0;
-
-     // Turn off dynamic thread adjustment
-     omp_set_dynamic(0);
-
-     // Set the number of OpenMP threads
-     omp_set_num_threads( int(num_threads) );
-
-     // setup for using CppAD::AD<double> in parallel
-     thread_alloc::parallel_setup(num_threads, in_parallel, thread_num);
-     thread_alloc::hold_memory(true);
-     CppAD::parallel_ad<double>();
-
-     // inform team_work of number of threads
-     num_threads_ = num_threads;
-
-     return ok;
-}
-
-bool team_work(void worker(void))
-{     bool ok = ! in_parallel();
-     ok     &= thread_num() == 0;;
-     ok     &= num_threads_ > 0;
-
-     int number_threads = int(num_threads_);
-     int thread_num;
-# pragma omp parallel for
-     for(thread_num = 0; thread_num < number_threads; thread_num++)
-          worker();
-// end omp parallel for
-
-     return ok;
-}
-
-bool team_destroy(void)
-{     bool ok = ! in_parallel();
-     ok     &= thread_num() == 0;;
-     ok     &= num_threads_ > 0;
-
-     // inform team_work of number of threads
-     num_threads_ = 1;
-
-     // Set the number of OpenMP threads to one
-     omp_set_num_threads( int(num_threads_) );
-
-     // inform CppAD no longer in multi-threading mode
-     thread_alloc::parallel_setup(num_threads_, CPPAD_NULL, CPPAD_NULL);
-     thread_alloc::hold_memory(false);
-     CppAD::parallel_ad<double>();
-
-     return ok;
-}
-
-const char* team_name(void)
-{     return "openmp"; }
-
-
Input File: example/multi_thread/openmp/team_openmp.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_team_openmp.cpp_xml.js cppad-2019.02.00.0/doc/_team_openmp.cpp_xml.js --- cppad-2018.00.00.0/doc/_team_openmp.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_team_openmp.cpp_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', -'multi_thread.xml', -'thread_test.cpp.xml', -'team_thread.hpp.xml', -'team_openmp.cpp.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'team_openmp.cpp.xml', -'team_bthread.cpp.xml', -'team_pthread.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-2018.00.00.0/doc/team_pthread.cpp.xml cppad-2019.02.00.0/doc/team_pthread.cpp.xml --- cppad-2018.00.00.0/doc/team_pthread.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/team_pthread.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,408 +0,0 @@ - - - -Pthread Implementation of a Team of AD Threads - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -team_pthread.cpp - -

-
Pthread Implementation of a Team of AD Threads
-See team_thread.hpp - for this routines specifications. - -
-
-Bug in Cygwin -
-There is a bug in pthread_exit, -using cygwin 5.1 and g++ version 4.3.4, -whereby calling pthread_exit is not the same as returning from -the corresponding routine. -To be specific, destructors for the vectors are not called -and a memory leaks result. -Set the following preprocessor symbol to 1 to demonstrate this bug: -

-# define DEMONSTRATE_BUG_IN_CYGWIN 0
-
-
# include <pthread.h>
-# include <cppad/cppad.hpp>
-# include "../team_thread.hpp"
-# define MAX_NUMBER_THREADS 48
-
-// It seems that when a barrier is passed, its counter is automatically reset
-// to its original value and it can be used again, but where is this
-// stated in the pthreads speicifcations ?
-namespace {
-     using CppAD::thread_alloc;
-
-     // number of threads in the team
-     size_t num_threads_ = 1;
-
-     // key for accessing thread specific information
-     pthread_key_t thread_specific_key_;
-
-     // no need to destroy thread specific information
-     void thread_specific_destructor(void* thread_num_vptr)
-     {     return; }
-
-     // type of the job currently being done by each thread
-     enum thread_job_t { init_enum, work_enum, join_enum } thread_job_;
-
-     // barrier used to wait for other threads to finish work
-     pthread_barrier_t wait_for_work_;
-
-     // barrier used to wait for master thread to set next job
-     pthread_barrier_t wait_for_job_;
-
-     // Are we in sequential mode; i.e., other threads are waiting for
-     // master thread to set up next job ?
-     bool sequential_execution_ = true;
-
-     // structure with information for one thread
-     typedef struct {
-          // cppad unique identifier for thread that uses this struct
-          size_t          thread_num;
-          // pthread unique identifier for thread that uses this struct
-          pthread_t       pthread_id;
-          // true if no error for this thread, false otherwise.
-          bool            ok;
-     } thread_one_t;
-
-     // vector with information for all threads
-     thread_one_t thread_all_[MAX_NUMBER_THREADS];
-
-     // pointer to function that does the work for one thread
-     void (* worker_)(void) = CPPAD_NULL;
-
-     // ---------------------------------------------------------------------
-     // in_parallel()
-     bool in_parallel(void)
-     {     return ! sequential_execution_; }
-
-     // ---------------------------------------------------------------------
-     // thread_number()
-     size_t thread_number(void)
-     {     // get thread specific information
-          void*   thread_num_vptr = pthread_getspecific(thread_specific_key_);
-          size_t* thread_num_ptr  = static_cast<size_t*>(thread_num_vptr);
-          size_t  thread_num      = *thread_num_ptr;
-          if( thread_num >= num_threads_ )
-          {     std::cerr << "thread_number: program error" << std::endl;
-               exit(1);
-          }
-          return thread_num;
-     }
-     // --------------------------------------------------------------------
-     // function that gets called by pthread_create
-     void* thread_work(void* thread_num_vptr)
-     {     int rc;
-          bool ok = true;
-
-          // Set thread specific data where other routines can access it
-          rc = pthread_setspecific(thread_specific_key_, thread_num_vptr);
-          ok &= rc == 0;
-
-          // thread_num to problem specific information for this thread
-          size_t thread_num = *static_cast<size_t*>(thread_num_vptr);
-
-          // master thread does not use this routine
-          ok &= thread_num > 0;
-
-          while( true )
-          {
-               // Use wait_for_job_ to give master time in sequential mode
-               // (so it can change global infromation like thread_job_)
-               rc = pthread_barrier_wait(&wait_for_job_);
-               ok &= (rc == 0 || rc == PTHREAD_BARRIER_SERIAL_THREAD);
-
-               // case where we are terminating this thread (no more work)
-               if( thread_job_ == join_enum )
-                    break;
-
-               // only other case once wait_for_job_ barrier is passed (so far)
-               ok &= thread_job_ == work_enum;
-               worker_();
-
-               // Use wait_for_work_ to inform master that our work is done and
-               // 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);
-          }
-          thread_all_[thread_num].ok = ok;
-# if DEMONSTRATE_BUG_IN_CYGWIN
-          // Terminate this thread
-          void* no_status = CPPAD_NULL;
-          pthread_exit(no_status);
-# endif
-          return CPPAD_NULL;
-     }
-}
-
-bool team_create(size_t num_threads)
-{     bool ok = true;;
-     int rc;
-
-     if( num_threads > MAX_NUMBER_THREADS )
-     {     std::cerr << "team_create: num_threads greater than ";
-          std::cerr << MAX_NUMBER_THREADS << std::endl;
-          exit(1);
-     }
-     // check that we currently do not have multiple threads running
-     ok  = num_threads_ == 1;
-     ok &= sequential_execution_;
-
-     size_t thread_num;
-     for(thread_num = 0; thread_num < num_threads; thread_num++)
-     {     // Each thread gets a pointer to its version of this thread_num
-          // so it knows which section of thread_all_ it is working with
-          thread_all_[thread_num].thread_num = thread_num;
-
-          // initialize
-          thread_all_[thread_num].ok         = true;
-     }
-     // Finish setup of thread_all_ for this thread
-     thread_all_[0].pthread_id = pthread_self();
-
-     // 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)
-     void* thread_num_vptr = static_cast<void*>(&(thread_all_[0].thread_num));
-     rc = pthread_setspecific(thread_specific_key_, thread_num_vptr);
-     ok &= (rc == 0);
-
-     // Now that thread_number() has necessary information for this thread
-     // (number zero), and while still in sequential mode,
-     // call setup for using CppAD::AD<double> in parallel mode.
-     thread_alloc::parallel_setup(num_threads, in_parallel, thread_number);
-     thread_alloc::hold_memory(true);
-     CppAD::parallel_ad<double>();
-
-     // 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;
-
-     // initialize two barriers, one for work done, one for new job ready
-     pthread_barrierattr_t* no_barrierattr = CPPAD_NULL;
-     rc = pthread_barrier_init(
-          &wait_for_work_, no_barrierattr, (unsigned int) num_threads
-     );
-     ok &= (rc == 0);
-     rc  = pthread_barrier_init(
-          &wait_for_job_, no_barrierattr, (unsigned int) num_threads
-     );
-     ok &= (rc == 0);
-
-     // structure used to create the threads
-     pthread_t       pthread_id;
-     // default for pthread_attr_setdetachstate is PTHREAD_CREATE_JOINABLE
-     pthread_attr_t* no_attr= CPPAD_NULL;
-
-     // initial job for the threads
-     thread_job_           = init_enum;
-     if( num_threads > 1 )
-          sequential_execution_ = false;
-
-     // 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<void*> (
-               &(thread_all_[thread_num].thread_num)
-          );
-          rc = pthread_create(
-                    &pthread_id ,
-                    no_attr     ,
-                    thread_work ,
-                    thread_num_vptr
-          );
-          thread_all_[thread_num].pthread_id = pthread_id;
-          ok &= (rc == 0);
-     }
-
-     // Current state is other threads are at wait_for_job_.
-     // This master thread (thread zero) has not completed wait_for_job_
-     sequential_execution_ = true;
-     return ok;
-}
-
-bool team_work(void worker(void))
-{     int rc;
-
-     // Current state is other threads are at wait_for_job_.
-     // This master thread (thread zero) has not completed wait_for_job_
-     bool ok = sequential_execution_;
-     ok     &= thread_number() == 0;
-
-     // set global version of this work routine
-     worker_ = worker;
-
-
-     // 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_
-     if( num_threads_ > 1 )
-          sequential_execution_ = false;
-
-     // wait until all threads have completed wait_for_job_
-     rc  = pthread_barrier_wait(&wait_for_job_);
-     ok &= (rc == 0 || rc == PTHREAD_BARRIER_SERIAL_THREAD);
-
-     // Now do the work in this thread and then wait
-     // until all threads have completed wait_for_work_
-     worker();
-     rc = pthread_barrier_wait(&wait_for_work_);
-     ok &= (rc == 0 || rc == PTHREAD_BARRIER_SERIAL_THREAD);
-
-     // Current state is other threads are at wait_for_job_.
-     // This master thread (thread zero) has not completed wait_for_job_
-     sequential_execution_ = true;
-
-     size_t thread_num;
-     for(thread_num = 0; thread_num < num_threads_; thread_num++)
-          ok &= thread_all_[thread_num].ok;
-     return ok;
-}
-
-bool team_destroy(void)
-{     int rc;
-
-     // Current state is other threads are at wait_for_job_.
-     // This master thread (thread zero) has not completed wait_for_job_
-     bool ok = sequential_execution_;
-     ok     &= thread_number() == 0;
-
-     // 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_
-     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
-     size_t thread_num;
-     for(thread_num = 1; thread_num < num_threads_; thread_num++)
-     {     void* no_status = CPPAD_NULL;
-          rc      = pthread_join(
-               thread_all_[thread_num].pthread_id, &no_status
-          );
-          ok &= (rc == 0);
-     }
-
-     // now we are down to just the master thread (thread zero)
-     sequential_execution_ = true;
-
-     // destroy the key for thread specific data
-     pthread_key_delete(thread_specific_key_);
-
-     // destroy wait_for_work_
-     rc  = pthread_barrier_destroy(&wait_for_work_);
-     ok &= (rc == 0);
-
-     // destroy wait_for_job_
-     rc  = pthread_barrier_destroy(&wait_for_job_);
-     ok &= (rc == 0);
-
-     // check ok before changing num_threads_
-     for(thread_num = 0; thread_num < num_threads_; thread_num++)
-          ok &= thread_all_[thread_num].ok;
-
-     // now inform CppAD that there is only one thread
-     num_threads_ = 1;
-     thread_alloc::parallel_setup(num_threads_, CPPAD_NULL, CPPAD_NULL);
-     thread_alloc::hold_memory(false);
-     CppAD::parallel_ad<double>();
-
-     return ok;
-}
-
-const char* team_name(void)
-{     return "pthread"; }
-
-
Input File: example/multi_thread/pthread/team_pthread.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_team_pthread.cpp_xml.js cppad-2019.02.00.0/doc/_team_pthread.cpp_xml.js --- cppad-2018.00.00.0/doc/_team_pthread.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_team_pthread.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'team_thread.hpp.xml', -'team_pthread.cpp.xml' -]; -var list_down3 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down2 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down1 = [ -'team_openmp.cpp.xml', -'team_bthread.cpp.xml', -'team_pthread.cpp.xml' -]; -var list_current0 = [ -'team_pthread.cpp.xml#Bug in Cygwin' -]; -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-2018.00.00.0/doc/team_thread.hpp.xml cppad-2019.02.00.0/doc/team_thread.hpp.xml --- cppad-2018.00.00.0/doc/team_thread.hpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/team_thread.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,285 +0,0 @@ - - - -Specifications for A Team of AD Threads - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Specifications for A Team of AD Threads
-
-Syntax - -
- -include "team_thread.hpp"
-
ok   = team_create(num_threads)
-
ok   = team_work(worker)
-
ok   = team_destroy()
-
name = team_name()
-
-
-Purpose -
-These routines start, use, and stop a team of threads that can -be used with the CppAD type AD<double>. -For example, -these could be OpenMP threads, pthreads, or Boost threads to name a few. - -
-
-Restrictions -
-Calls to the routines -team_create, -team_work, and -team_destroy, must all be done by the master thread; i.e., -thread_num - must be zero. -In addition, they must all be done in sequential execution mode; i.e., -when the master thread is the only thread that is running -(in_parallel - must be false). - -
-
-team_create -
-The argument - -num_threads > 0 - has type size_t -and specifies the number of threads in this team. -This initializes both AD<double> and team_work -to be used with -num_threads -. -If -num_threads > 1 -, - -num_threads - 1 - new threads are created -and put in a waiting state until team_work is called. - -
-
-team_work -
-This routine may be called one or more times -between the call to team_create and team_destroy. -The argument -worker - has type - -bool worker(void) -. -Each call to team_work runs -num_threads - versions -of -worker - with the corresponding value of -thread_num - -between zero and -num_threads - 1 - and -different for each thread, - -
-
-team_destroy -
-This routine terminates all the other threads except for -thread number zero; i.e., it terminates the threads corresponding to - -
-     
thread_num = 1 , ... , num_threads-1
-
-
-team_name -
-This routines returns a name that identifies this thread_team. -The return value has prototype - -
-     const char* 
name
-
-and is a statically allocated '\0' terminated C string. - -
-
-ok -
-The return value -ok - has type bool. -It is false if an error is detected during the -corresponding call. -Otherwise it is true. - - - -
-
-Example Use -
-Example use of these specifications can be found in the file -team_example.cpp -. - -
-
-Example Implementation -
-Example implementations of these specifications can be found in the files: - - - - -
- -team_openmp.cpp -OpenMP Implementation of a Team of AD Threads
- -team_bthread.cpp -Boost Thread Implementation of a Team of AD Threads
- -team_pthread.cpp -Pthread Implementation of a Team of AD Threads
- -
-
-Speed Test of Implementation -
-Speed tests of using CppAD with the team implementations above -can be found in: - - - -
- -harmonic.cpp -Multi-Threading Harmonic Summation Example / Test
- -multi_newton.cpp -Multi-Threaded Newton Method Example / Test
- -
-
-Source - -
# include <cstddef> // for size_t
-
-extern bool team_create(size_t num_threads);
-extern bool team_work(void worker(void));
-extern bool team_destroy(void);
-extern const char* team_name(void);
- -
Input File: example/multi_thread/team_thread.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_team_thread.hpp_xml.js cppad-2019.02.00.0/doc/_team_thread.hpp_xml.js --- cppad-2018.00.00.0/doc/_team_thread.hpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_team_thread.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.xml', -'team_thread.hpp.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down1 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_down0 = [ -'team_openmp.cpp.xml', -'team_bthread.cpp.xml', -'team_pthread.cpp.xml' -]; -var list_current0 = [ -'team_thread.hpp.xml#Syntax', -'team_thread.hpp.xml#Purpose', -'team_thread.hpp.xml#Restrictions', -'team_thread.hpp.xml#team_create', -'team_thread.hpp.xml#team_work', -'team_thread.hpp.xml#team_destroy', -'team_thread.hpp.xml#team_name', -'team_thread.hpp.xml#ok', -'team_thread.hpp.xml#Example Use', -'team_thread.hpp.xml#Example Implementation', -'team_thread.hpp.xml#Speed Test of Implementation', -'team_thread.hpp.xml#Source' -]; -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-2018.00.00.0/doc/test_boolofvoid.xml cppad-2019.02.00.0/doc/test_boolofvoid.xml --- cppad-2018.00.00.0/doc/test_boolofvoid.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/test_boolofvoid.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,211 +0,0 @@ - - - -Object that Runs a Group of Tests - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -test_boolofvoid - -

-
Object that Runs a Group of Tests
-
-Syntax - -
- -test_boolofvoid Run(groupwidth)
-
- -Run(testname)
-
- -ok = Run.summary(memory_ok) - - -
-
-Purpose -
-The object -Run - is used to run a group of tests functions -and report the results on standard output. - -
-
-group -
-The argument has prototype - -
-     const std::string& 
group
-
-It is the name for this group of tests. - -
-
-width -
-The argument has prototype - -
-     size_t 
width
-
-It is the number of columns used to display the name of each test. -It must be greater than the maximum number of characters in a test name. - -
-
-test -
-The argument has prototype - -
-     bool 
test(void)
-
-It is a function that returns true (when the test passes) and false -otherwise. - -
-
-name -
-The argument has prototype - -
-     const std::string& 
name
-
-It is the name for the corresponding -test -. - -
-
-memory_ok -
-The argument has prototype - -
-     bool 
memory_ok
-
-It is false if a memory leak is detected (and true otherwise). - -
-
-ok -
-This is true if all of the tests pass (including the memory leak test), -otherwise it is false. - -
-
-Example -
-See any of the main programs in the example directory; e.g., -example/ipopt_solve.cpp. - - -
Input File: cppad/utility/test_boolofvoid.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_test_boolofvoid_xml.js cppad-2019.02.00.0/doc/_test_boolofvoid_xml.js --- cppad-2018.00.00.0/doc/_test_boolofvoid_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_test_boolofvoid_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'test_boolofvoid.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_current0 = [ -'test_boolofvoid.xml#Syntax', -'test_boolofvoid.xml#Purpose', -'test_boolofvoid.xml#group', -'test_boolofvoid.xml#width', -'test_boolofvoid.xml#test', -'test_boolofvoid.xml#name', -'test_boolofvoid.xml#memory_ok', -'test_boolofvoid.xml#ok', -'test_boolofvoid.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-2018.00.00.0/doc/test_vector.xml cppad-2019.02.00.0/doc/test_vector.xml --- cppad-2018.00.00.0/doc/test_vector.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/test_vector.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,231 +0,0 @@ - - - -Choosing The Vector Testing Template Class - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -test_vector - -

-
Choosing The Vector Testing Template Class
-
-Deprecated 2012-07-03 -
-The CPPAD_TEST_VECTOR macro has been deprecated, -use CPPAD_TESTVECTOR - instead. - -
-
-Syntax - -
- -CPPAD_TEST_VECTOR<Scalar>
-
-
-Introduction -
-Many of the CppAD examples - and tests use -the CPPAD_TEST_VECTOR template class to pass information. -The default definition for this template class is -CppAD::vector -. - -
-
-MS Windows -
-The include path for boost is not defined in the Windows project files. -If we are using Microsofts compiler, the following code overrides the setting -of CPPAD_BOOSTVECTOR: -
// The next 7 lines are C++ source code.
-# ifdef _MSC_VER
-# if CPPAD_BOOSTVECTOR
-# undef  CPPAD_BOOSTVECTOR
-# define CPPAD_BOOSTVECTOR 0
-# undef  CPPAD_CPPADVECTOR
-# define CPPAD_CPPADVECTOR 1
-# endif
-# endif
-
-CppAD::vector -
-By default CPPAD_CPPADVECTOR is true -and CPPAD_TEST_VECTOR is defined by the following source code -
// The next 3 line are C++ source code.
-# if CPPAD_CPPADVECTOR
-# define CPPAD_TEST_VECTOR CppAD::vector
-# endif
-If you specify --with-eigenvector on the -configure - command line, -CPPAD_EIGENVECTOR is true. -This vector type cannot be supported by CPPAD_TEST_VECTOR -(use CPPAD_TESTVECTOR - for this support) -so CppAD::vector is used in this case -
// The next 3 line are C++ source code.
-# if CPPAD_EIGENVECTOR
-# define CPPAD_TEST_VECTOR CppAD::vector
-# endif
-
-std::vector -
-If you specify --with-stdvector on the -configure - -command line during CppAD installation, -CPPAD_STDVECTOR is true -and CPPAD_TEST_VECTOR is defined by the following source code -
// The next 4 lines are C++ source code.
-# if CPPAD_STDVECTOR
-# include <vector>
-# define CPPAD_TEST_VECTOR std::vector
-# endif
-In this case CppAD will use std::vector for its examples and tests. -Use of CppAD::vector, std::vector, -and std::valarray with CppAD is always tested to some degree. -Specifying --with-stdvector will increase the amount of -std::vector testing. - -
-
-boost::numeric::ublas::vector -
-If you specify a value for -boost_dir - on the configure -command line during CppAD installation, -CPPAD_BOOSTVECTOR is true -and CPPAD_TEST_VECTOR is defined by the following source code -
// The next 4 lines are C++ source code.
-# if CPPAD_BOOSTVECTOR
-# include <boost/numeric/ublas/vector.hpp>
-# define CPPAD_TEST_VECTOR boost::numeric::ublas::vector
-# endif
-In this case CppAD will use Ublas vectors for its examples and tests. -Use of CppAD::vector, std::vector, -and std::valarray with CppAD is always tested to some degree. -Specifying -boost_dir - will increase the amount of -Ublas vector testing. - -
-
-CppADvector Deprecated 2007-07-28 -
-The preprocessor symbol CppADvector is defined to -have the same value as CPPAD_TEST_VECTOR but its use is deprecated: -

-# define CppADvector CPPAD_TEST_VECTOR
-
- -
Input File: cppad/core/test_vector.hpp - - - diff -Nru cppad-2018.00.00.0/doc/testvector.xml cppad-2019.02.00.0/doc/testvector.xml --- cppad-2018.00.00.0/doc/testvector.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/testvector.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,208 +0,0 @@ - - - -Using The CppAD Test Vector Template Class - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -testvector - -

-
Using The CppAD Test Vector Template Class
-
-Syntax - -
- -CPPAD_TESTVECTOR(Scalar)
-
-
-Purpose -
-Many of the CppAD examples - and tests use -the CPPAD_TESTVECTOR template class to pass information to CppAD. -This is not a true template class because it's syntax uses - -(Scalar) - instead of -<Scalar> -. -This enables us to use - -
-     Eigen::Matrix<
Scalar, Eigen::Dynamic, 1>
-
-as one of the possible cases for this 'template class'. - -
-
-Choice -
-The user can choose, during the install procedure, -which template class to use in the examples and tests; see below. -This shows that any -simple vector - class can be used in place of - -
-     CPPAD_TESTVECTOR(
Type)
-
-When writing their own code, -users can choose a specific simple vector they prefer; for example, - -
-     CppAD::vector<
Type>
-
-
-CppAD::vector -
-If in the cmake command - -you specify cppad_testvector - to be cppad, -CPPAD_CPPADVECTOR will be true. -In this case, -CPPAD_TESTVECTOR is defined by the following source code: -

-# if CPPAD_CPPADVECTOR
-# define CPPAD_TESTVECTOR(Scalar) CppAD::vector< Scalar >
-# endif
-
-In this case CppAD will use its own vector for -many of its examples and tests. - -
-
-std::vector -
-If in the cmake command -you specify -cppad_testvector - to be std, -CPPAD_STDVECTOR will be true. -In this case, -CPPAD_TESTVECTOR is defined by the following source code: -
# if CPPAD_STDVECTOR
-# include <vector>
-# define CPPAD_TESTVECTOR(Scalar) std::vector< Scalar >
-# endif
-In this case CppAD will use standard vector for -many of its examples and tests. - -
-
-boost::numeric::ublas::vector -
-If in the cmake command -you specify -cppad_testvector - to be boost, -CPPAD_BOOSTVECTOR will be true. -In this case, -CPPAD_TESTVECTOR is defined by the following source code: -
# if CPPAD_BOOSTVECTOR
-# include <boost/numeric/ublas/vector.hpp>
-# define CPPAD_TESTVECTOR(Scalar) boost::numeric::ublas::vector< Scalar >
-# endif
-In this case CppAD will use this boost vector for -many of its examples and tests. - -
-
-Eigen Vectors -
-If in the cmake command -you specify -cppad_testvector - to be eigen, -CPPAD_EIGENVECTOR will be true. -In this case, -CPPAD_TESTVECTOR is defined by the following source code: -
# if CPPAD_EIGENVECTOR
-# include <cppad/example/cppad_eigen.hpp>
-# define CPPAD_TESTVECTOR(Scalar) Eigen::Matrix< Scalar , Eigen::Dynamic, 1>
-# endif
-In this case CppAD will use the Eigen vector -for many of its examples and tests. - - -
Input File: cppad/core/testvector.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_test_vector_xml.js cppad-2019.02.00.0/doc/_test_vector_xml.js --- cppad-2018.00.00.0/doc/_test_vector_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_test_vector_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'test_vector.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', -'directory.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', -'autotools.xml' -]; -var list_current0 = [ -'test_vector.xml#Deprecated 2012-07-03', -'test_vector.xml#Syntax', -'test_vector.xml#Introduction', -'test_vector.xml#MS Windows', -'test_vector.xml#CppAD::vector', -'test_vector.xml#std::vector', -'test_vector.xml#boost::numeric::ublas::vector', -'test_vector.xml#CppADvector Deprecated 2007-07-28' -]; -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-2018.00.00.0/doc/_testvector_xml.js cppad-2019.02.00.0/doc/_testvector_xml.js --- cppad-2018.00.00.0/doc/_testvector_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_testvector_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', -'example.xml', -'testvector.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_current0 = [ -'testvector.xml#Syntax', -'testvector.xml#Purpose', -'testvector.xml#Choice', -'testvector.xml#CppAD::vector', -'testvector.xml#std::vector', -'testvector.xml#boost::numeric::ublas::vector', -'testvector.xml#Eigen Vectors' -]; -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-2018.00.00.0/doc/theory.xml cppad-2019.02.00.0/doc/theory.xml --- cppad-2018.00.00.0/doc/theory.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/theory.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ - - - -The Theory of Derivative Calculations - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
The Theory of Derivative Calculations
-
-Contents -
- -
Input File: omh/appendix/theory/theory.omh - - - diff -Nru cppad-2018.00.00.0/doc/_theory_xml.js cppad-2019.02.00.0/doc/_theory_xml.js --- cppad-2018.00.00.0/doc/_theory_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_theory_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +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' -]; -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', -'directory.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 = [ -'forwardtheory.xml', -'reversetheory.xml', -'reverse_identity.xml' -]; -var list_current0 = [ -'theory.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-2018.00.00.0/doc/thread_alloc.cpp.xml cppad-2019.02.00.0/doc/thread_alloc.cpp.xml --- cppad-2018.00.00.0/doc/thread_alloc.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/thread_alloc.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,332 +0,0 @@ - - - -Fast Multi-Threading Memory Allocator: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -thread_alloc.cppHeadings

-
Fast Multi-Threading Memory Allocator: Example and Test
-
# include <cppad/utility/thread_alloc.hpp>
-# include <vector>
-# include <limits>
-
-
-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
-     ok &= thread_alloc::free_all();
-
-     // amount of static memory used by thread zero
-     size_t static_inuse = 0;
-
-     // 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;
-     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.
-          std::vector<void*> v_ptr(n_inner);
-          // 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<size_t*>(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(size_t k = 0; k < cap_size_t; k++)
-                    new(ptr + k) size_t(i + j + k);
-               // check that the constructor worked
-               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
-          thread = thread_alloc::thread_num();
-          ok &= thread_alloc::inuse(thread) == n_inner*cap_bytes + static_inuse;
-          ok &= thread_alloc::available(thread) == 0;
-          // return the memrory to thread_alloc
-          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
-          ok &= thread_alloc::inuse(thread) == static_inuse;
-          ok &= thread_alloc::available(thread) == n_inner * cap_bytes;
-     }
-     thread_alloc::free_available(thread);
-
-     // check that the tests have not held onto memory
-     ok &= thread_alloc::free_all();
-
-     return ok;
-}
-
-class my_char {
-public:
-     char ch_ ;
-     my_char(void) : ch_(' ')
-     { }
-     my_char(const my_char& my_ch) : ch_(my_ch.ch_)
-     { }
-};
-
-bool type_allocate(void)
-{     bool ok = true;
-     using CppAD::thread_alloc;
-     size_t i;
-
-     // check initial memory values
-     size_t thread = thread_alloc::thread_num();
-     ok &= thread == 0;
-     ok &= thread_alloc::free_all();
-     size_t static_inuse = 0;
-
-     // initial allocation of an array
-     size_t  size_min  = 3;
-     size_t  size_one;
-     my_char *array_one  =
-          thread_alloc::create_array<my_char>(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 =
-          thread_alloc::create_array<my_char>(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   &= thread_alloc::inuse(thread) - check < sizeof(my_char);
-     ok   &= thread_alloc::available(thread) == 0;
-
-     // delete the arrays
-     thread_alloc::delete_array(array_one);
-     thread_alloc::delete_array(array_two);
-     ok   &= thread_alloc::inuse(thread) == static_inuse;
-     check = sizeof(my_char)*(size_one + size_two);
-     ok   &= thread_alloc::available(thread) - check < sizeof(my_char);
-
-     // free the memory for use by this thread
-     thread_alloc::free_available(thread);
-
-     // check that the tests have not held onto memory
-     ok &= thread_alloc::free_all();
-
-     return ok;
-}
-
-} // End empty namespace
-
-bool check_alignment(void)
-{     bool ok = true;
-     using CppAD::thread_alloc;
-
-     // number of binary digits in a size_t value
-     size_t n_digit = std::numeric_limits<size_t>::digits;
-
-     // must be a multiple of 8
-     ok &= (n_digit % 8) == 0;
-
-     // number of bytes in a size_t value
-     size_t n_byte  = n_digit / 8;
-
-     // check raw allocation -------------------------------------------------
-     size_t min_bytes = 1;
-     size_t cap_bytes;
-     void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes);
-
-     // convert to a size_t value
-     size_t v_size_t = reinterpret_cast<size_t>(v_ptr);
-
-     // check that it is aligned
-     ok &= (v_size_t % n_byte) == 0;
-
-     // 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 =
-          thread_alloc::create_array<my_char>(size_min, size_out);
-
-     // convert to a size_t value
-     size_t array_size_t = reinterpret_cast<size_t>(array_ptr);
-
-     // check that it is aligned
-     ok &= (array_size_t % n_byte) == 0;
-
-     // return memory to avialable pool
-     thread_alloc::delete_array(array_ptr);
-
-     return ok;
-}
-
-
-bool thread_alloc(void)
-{     bool ok  = true;
-     using CppAD::thread_alloc;
-
-     // check that there is only on thread
-     ok  &= thread_alloc::num_threads() == 1;
-     // so thread number must be zero
-     ok  &= thread_alloc::thread_num() == 0;
-     // and we are in sequential execution mode
-     ok  &= thread_alloc::in_parallel() == false;
-
-     // Instruct thread_alloc to hold onto memory.  This makes memory
-     // allocation faster (especially when there are multiple threads).
-     thread_alloc::hold_memory(true);
-
-     // run raw allocation tests
-     ok &= raw_allocate();
-
-     // run typed allocation tests
-     ok &= type_allocate();
-
-     // check alignment
-     ok &= check_alignment();
-
-     // return allocator to its default mode
-     thread_alloc::hold_memory(false);
-     return ok;
-}
-
-
-
-
Input File: example/utility/thread_alloc.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_thread_alloc.cpp_xml.js cppad-2019.02.00.0/doc/_thread_alloc.cpp_xml.js --- cppad-2018.00.00.0/doc/_thread_alloc.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_thread_alloc.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.xml', -'thread_alloc.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.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-2018.00.00.0/doc/thread_alloc.xml cppad-2019.02.00.0/doc/thread_alloc.xml --- cppad-2018.00.00.0/doc/thread_alloc.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/thread_alloc.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ - - - -A Fast Multi-Threading Memory Allocator - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
A Fast Multi-Threading Memory Allocator
-
-Syntax - -
-# include <cppad/thread_alloc.hpp>
- -
-
-Purpose -
-The C++ new and delete operators are thread safe, -but this means that a thread may have to wait for a lock on these operations. -Once memory is obtained for a thread, the thread_alloc memory -allocator keeps that memory available - for the thread so that -it can be re-used without waiting for a lock. -All the CppAD memory allocations use this utility. -The free_available - function should be used to return memory -to the system (once it is no longer required by a thread). - -
-
-Include -
-The routines in sections below are defined by cppad/thread_alloc.hpp. -This file is included by -cppad/cppad.hpp, but it can also be included separately with out -the rest of the CppAD. - -
-
-Contents -
- -
thread_alloc.cppFast Multi-Threading Memory Allocator: Example and Test
ta_parallel_setupSetup thread_alloc For Use in Multi-Threading Environment
ta_num_threadsGet Number of Threads
ta_in_parallelIs The Current Execution in Parallel Mode
ta_thread_numGet the Current Thread Number
ta_get_memoryGet At Least A Specified Amount of Memory
ta_return_memoryReturn Memory to thread_alloc
ta_free_availableFree Memory Currently Available for Quick Use by a Thread
ta_hold_memoryControl When Thread Alloc Retains Memory For Future Use
ta_inuseAmount of Memory a Thread is Currently Using
ta_availableAmount of Memory Available for Quick Use by a Thread
ta_create_arrayAllocate An Array and Call Default Constructor for its Elements
ta_delete_arrayDeallocate An Array and Call Destructor for its Elements
ta_free_allFree All Memory That Was Allocated for Use by thread_alloc
-
Input File: omh/thread_alloc.omh - - - diff -Nru cppad-2018.00.00.0/doc/_thread_alloc_xml.js cppad-2019.02.00.0/doc/_thread_alloc_xml.js --- cppad-2018.00.00.0/doc/_thread_alloc_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_thread_alloc_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'thread_alloc.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'thread_alloc.cpp.xml', -'ta_parallel_setup.xml', -'ta_num_threads.xml', -'ta_in_parallel.xml', -'ta_thread_num.xml', -'ta_get_memory.xml', -'ta_return_memory.xml', -'ta_free_available.xml', -'ta_hold_memory.xml', -'ta_inuse.xml', -'ta_available.xml', -'ta_create_array.xml', -'ta_delete_array.xml', -'ta_free_all.xml' -]; -var list_current0 = [ -'thread_alloc.xml#Syntax', -'thread_alloc.xml#Purpose', -'thread_alloc.xml#Include', -'thread_alloc.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-2018.00.00.0/doc/thread_test.cpp.xml cppad-2019.02.00.0/doc/thread_test.cpp.xml --- cppad-2018.00.00.0/doc/thread_test.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/thread_test.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,601 +0,0 @@ - - - -Run Multi-Threading Examples and Speed Tests - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - - - -
Run Multi-Threading Examples and Speed Tests
-
-Purpose -
-Runs the CppAD multi-threading examples and timing tests: - -
-
-build -
-We use -build - for the directory where you run the cmake - -command. - -
-
-threading -
-If the cmake - command output indicates that -bthread, pthread, or openmp is available, -you can run the program below with -threading - equal to -bthread, pthread, or openmp respectively. - -
-
-program -
-We use the notation -program - for - -
-      example_multi_thread_
threading
-
-
-Running Tests -
-You can build this program and run the default version of its test -parameters by executing the following commands: - -
-     cd 
build
-     make check_
program
-
-After this operation, in the directory - -
-     
build/example/multi_thread/threading
-
-you can execute the following commands: - -.
-./
program a11c
-./
program simple_ad
-./
program team_example
-./
program harmonic     test_time max_threads mega_sum
-./
program multi_newton test_time max_threads \
-     
num_zero num_sub num_sum use_ad
-
-
-a11c -
-The examples -a11c_openmp.cpp -, -a11c_bthread.cpp -, and -a11c_pthread.cpp - -demonstrate simple multi-threading, -without algorithmic differentiation. - -
-
-simple_ad -
-The examples -simple_ad_openmp.cpp -, -simple_ad_bthread.cpp -, -and -simple_ad_pthread.cpp - -demonstrate simple multi-threading, -with algorithmic differentiation, using -OpenMP, boost threads and pthreads respectively. - -
-
-team_example -
-The team_example.cpp - routine -demonstrates simple multi-threading with algorithmic differentiation -and using a team of threads -. - - - -
-
-harmonic -
-The harmonic_time - routine -preforms a timing test for a multi-threading -example without algorithmic differentiation using a team of threads. - -
-
-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. -The reported time is the total wall clock time divided by the -number of repeats. - -
-
-max_threads -
-If the argument -max_threads - is a non-negative integer specifying -the maximum number of threads to use for the test. -The specified test is run with the following number of threads: - -
-     
num_threads = 0 , ... , max_threads
-
-The value of zero corresponds to not using the multi-threading system. - -
-
-mega_sum -
-The command line argument -mega_sum - -is an integer greater than or equal one and has the same meaning as in -harmonic_time -. - - - -
-
-multi_newton -
-The multi_newton_time - routine -preforms a timing test for a multi-threading -example with algorithmic differentiation using a team of threads. - -
-
-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. -The reported time is the total wall clock time divided by the -number of repeats. - -
-
-max_threads -
-If the argument -max_threads - is a non-negative integer specifying -the maximum number of threads to use for the test. -The specified test is run with the following number of threads: - -
-     
num_threads = 0 , ... , max_threads
-
-The value of zero corresponds to not using the multi-threading system. - -
-
-num_zero -
-The command line argument -num_zero - -is an integer greater than or equal two and has the same meaning as in -multi_newton_time -. - -
-
-num_sub -
-The command line argument -num_sub - -is an integer greater than or equal one and has the same meaning as in -multi_newton_time -. - -
-
-num_sum -
-The command line argument -num_sum - -is an integer greater than or equal one and has the same meaning as in -multi_newton_time -. - -
-
-use_ad -
-The command line argument -use_ad - is either -true or false and has the same meaning as in -multi_newton_time -. - - - -
-
-Team Implementations -
-The following routines are used to implement the specific threading -systems through the common interface team_thread.hpp -: - - - - -
- -team_openmp.cpp -OpenMP Implementation of a Team of AD Threads
- -team_bthread.cpp -Boost Thread Implementation of a Team of AD Threads
- -team_pthread.cpp -Pthread Implementation of a Team of AD Threads
- -
-
-Source - - -

-
-# include <cppad/cppad.hpp>
-# include <cmath>
-# include <cstring>
-# include <ctime>
-# include "team_thread.hpp"
-# include "team_example.hpp"
-# include "harmonic.hpp"
-# include "multi_atomic.hpp"
-# include "multi_newton.hpp"
-
-extern bool a11c(void);
-extern bool simple_ad(void);
-
-namespace {
-     size_t arg2size_t(
-          const char* arg       ,
-          int limit             ,
-          const char* error_msg )
-     {     int i = std::atoi(arg);
-          if( i >= limit )
-               return size_t(i);
-          std::cerr << "value = " << i << std::endl;
-          std::cerr << error_msg << std::endl;
-          exit(1);
-     }
-     double arg2double(
-          const char* arg       ,
-          double limit          ,
-          const char* error_msg )
-     {     double d = std::atof(arg);
-          if( d >= limit )
-               return d;
-          std::cerr << "value = " << d << std::endl;
-          std::cerr << error_msg << std::endl;
-          exit(1);
-     }
-}
-
-int main(int argc, char *argv[])
-{     using CppAD::thread_alloc;
-     bool ok         = true;
-     using std::cout;
-     using std::endl;
-
-     // commnd line usage message
-     const char* usage =
-     "./<thread>_test a11c\n"
-     "./<thread>_test simple_ad\n"
-     "./<thread>_test team_example\n"
-     "./<thread>_test harmonic     test_time max_threads mega_sum\n"
-     "./<thread>_test multi_atomic test_time max_threads num_solve\n"
-     "./<thread>_test multi_newton test_time max_threads \\\n"
-     "     num_zero num_sub num_sum use_ad\\\n"
-     "where <thread> is bthread, openmp, or pthread";
-
-     // command line argument values (assign values to avoid compiler warnings)
-     size_t num_zero=0, num_sub=0, num_sum=0;
-     bool use_ad=true;
-
-     // put the date and time in the output file
-     std::time_t rawtime;
-     std::time( &rawtime );
-     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++)
-          if( gmt[i] != '\n' ) cout << gmt[i];
-     cout << "';" << endl;
-
-     // CppAD version number
-     cout << "cppad_version = '" << CPPAD_PACKAGE_STRING << "';" << endl;
-
-     // put the team name in the output file
-     cout << "team_name     = '" << team_name() << "';" << endl;
-
-     // print command line as valid matlab/octave
-     cout << "command       = '" << argv[0];
-     for(int i = 1; i < argc; i++)
-          cout << " " << argv[i];
-     cout << "';" << endl;
-
-     ok = false;
-     const char* test_name = "";
-     if( argc > 1 )
-          test_name = *++argv;
-     bool run_a11c         = std::strcmp(test_name, "a11c")         == 0;
-     bool run_simple_ad    = std::strcmp(test_name, "simple_ad")    == 0;
-     bool run_team_example = std::strcmp(test_name, "team_example") == 0;
-     bool run_harmonic     = std::strcmp(test_name, "harmonic")     == 0;
-     bool run_multi_atomic = std::strcmp(test_name, "multi_atomic") == 0;
-     bool run_multi_newton = std::strcmp(test_name, "multi_newton") == 0;
-     if( run_a11c || run_simple_ad || run_team_example )
-          ok = (argc == 2);
-     else if( run_harmonic || run_multi_atomic )
-          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 << usage << endl;
-          exit(1);
-     }
-     if( run_a11c || run_simple_ad || run_team_example )
-     {     if( run_a11c )
-               ok        = a11c();
-          else if( run_simple_ad )
-               ok        = simple_ad();
-          else     ok        = team_example();
-          if( thread_alloc::free_all() )
-               cout << "free_all      = true;"  << endl;
-          else
-          {     ok = false;
-               cout << "free_all      = false;" << endl;
-          }
-          if( ok )
-               cout << "OK            = true;"  << endl;
-          else cout << "OK            = false;" << endl;
-          return ! ok;
-     }
-
-     // 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,
-          "run: max_threads is less than zero"
-     );
-
-     size_t mega_sum  = 0; // assignment to avoid compiler warning
-     size_t num_solve = 0;
-     if( run_harmonic )
-     {     // mega_sum
-          mega_sum = arg2size_t( *++argv, 1,
-               "run: mega_sum is less than one"
-          );
-     }
-     else if( run_multi_atomic )
-     {     // num_solve
-          num_solve = arg2size_t( *++argv, 1,
-               "run: num_solve is less than one"
-          );
-     }
-     else
-     {     ok &= run_multi_newton;
-
-          // num_zero
-          num_zero = arg2size_t( *++argv, 2,
-               "run: num_zero is less than two"
-          );
-
-          // num_sub
-          num_sub = arg2size_t( *++argv, 1,
-               "run: num_sub is less than one"
-          );
-
-          // num_sum
-          num_sum = arg2size_t( *++argv, 1,
-               "run: num_sum is less than one"
-          );
-
-          // use_ad
-          ++argv;
-          if( std::strcmp(*argv, "true") == 0 )
-               use_ad = true;
-          else if( std::strcmp(*argv, "false") == 0 )
-               use_ad = false;
-          else
-          {     std::cerr << "run: use_ad = '" << *argv;
-               std::cerr << "' is not true or false" << endl;
-               exit(1);
-          }
-     }
-
-     // run the test for each number of threads
-     cout << "time_all  = [" << endl;
-     for(size_t num_threads = 0; num_threads <= max_threads; num_threads++)
-     {     double time_out;
-
-          // run the requested test
-          if( run_harmonic ) ok &=
-               harmonic_time(time_out, test_time, num_threads, mega_sum);
-          else if( run_multi_atomic ) ok &=
-               multi_atomic_time(time_out, test_time, num_threads, num_solve);
-          else
-          {     ok &= run_multi_newton;
-               ok &= multi_newton_time(
-                    time_out                ,
-                    test_time               ,
-                    num_threads             ,
-                    num_zero                ,
-                    num_sub                 ,
-                    num_sum                 ,
-                    use_ad
-               );
-          }
-          // time_out
-          cout << "\t" << time_out << " % ";
-          // num_threads
-          if( num_threads == 0 )
-               cout << "no threading" << endl;
-          else     cout << num_threads << " threads" << endl;
-     }
-     cout << "];" << endl;
-     //
-     if( thread_alloc::free_all() )
-          cout << "free_all      = true;"  << endl;
-     else
-     {     ok = false;
-          cout << "free_all      = false;" << endl;
-     }
-     if( ok )
-          cout << "OK            = true;"  << endl;
-     else cout << "OK            = false;" << endl;
-
-     return  ! ok;
-}
-
-
-
Input File: example/multi_thread/thread_test.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_thread_test.cpp_xml.js cppad-2019.02.00.0/doc/_thread_test.cpp_xml.js --- cppad-2018.00.00.0/doc/_thread_test.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_thread_test.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'multi_thread.xml', -'thread_test.cpp.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 = [ -'parallel_ad.xml', -'thread_test.cpp.xml' -]; -var list_down0 = [ -'a11c_openmp.cpp.xml', -'a11c_bthread.cpp.xml', -'a11c_pthread.cpp.xml', -'simple_ad_openmp.cpp.xml', -'simple_ad_bthread.cpp.xml', -'simple_ad_pthread.cpp.xml', -'team_example.cpp.xml', -'harmonic.cpp.xml', -'multi_atomic.cpp.xml', -'multi_newton.cpp.xml', -'team_thread.hpp.xml' -]; -var list_current0 = [ -'thread_test.cpp.xml#Purpose', -'thread_test.cpp.xml#build', -'thread_test.cpp.xml#threading', -'thread_test.cpp.xml#program', -'thread_test.cpp.xml#Running Tests', -'thread_test.cpp.xml#a11c', -'thread_test.cpp.xml#simple_ad', -'thread_test.cpp.xml#team_example', -'thread_test.cpp.xml#harmonic', -'thread_test.cpp.xml#harmonic.test_time', -'thread_test.cpp.xml#harmonic.max_threads', -'thread_test.cpp.xml#harmonic.mega_sum', -'thread_test.cpp.xml#multi_newton', -'thread_test.cpp.xml#multi_newton.test_time', -'thread_test.cpp.xml#multi_newton.max_threads', -'thread_test.cpp.xml#multi_newton.num_zero', -'thread_test.cpp.xml#multi_newton.num_sub', -'thread_test.cpp.xml#multi_newton.num_sum', -'thread_test.cpp.xml#multi_newton.use_ad', -'thread_test.cpp.xml#Team Implementations', -'thread_test.cpp.xml#Source' -]; -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-2018.00.00.0/doc/time_det_by_minor_c.xml cppad-2019.02.00.0/doc/time_det_by_minor_c.xml --- cppad-2018.00.00.0/doc/time_det_by_minor_c.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/time_det_by_minor_c.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,191 +0,0 @@ - - - -Determine Amount of Time to Execute det_by_minor - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -time_det_by_minor_c - -

-
Determine Amount of Time to Execute det_by_minor
-
-Syntax - -
- -time = time_test(sizetime_min) - - -
-
-Purpose -
-reports the amount of wall clock time for det_by_minor -to compute the determinant of a square matrix. - -The -size - has prototype - -
-     size_t 
size
-
-It specifies the number of rows (and columns) in the square matrix -that the determinant is being calculated for. - -
-
-time_min -
-The argument -time_min - has prototype - -
-     double 
time_min
-
-It specifies the minimum amount of time in seconds -that the -test - routine should take. -The calculations is repeated the necessary number of times so that -this amount of execution time (or more) is reached. - -
-
-time -
-The return value -time - has prototype - -
-     double 
time
-
-and is the number of wall clock seconds that it took for -det_by_minor to compute its determinant -(plus overhead which includes choosing a random matrix). - - - - -
-
-Source Code - -
double time_det_by_minor(size_t size, double time_min)
-{     size_t repeat;
-     double s0, s1, time;
-     repeat = 0;
-     s0     = elapsed_seconds();
-     s1     = s0;
-     while( s1 - s0 < time_min )
-     {     if( repeat == 0 )
-               repeat = 1;
-          else     repeat = 2 * repeat;
-          s0     = elapsed_seconds();
-          repeat_det_by_minor(repeat, size);
-          s1     = elapsed_seconds();
-     }
-     time = (s1 - s0) / (double) repeat;
-     return time;
-}
- -
Input File: test_more/compare_c/det_by_minor.c - - - diff -Nru cppad-2018.00.00.0/doc/_time_det_by_minor_c_xml.js cppad-2019.02.00.0/doc/_time_det_by_minor_c_xml.js --- cppad-2018.00.00.0/doc/_time_det_by_minor_c_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_time_det_by_minor_c_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'compare_c.xml', -'time_det_by_minor_c.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', -'directory.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 = [ -'det_of_minor_c.xml', -'det_by_minor_c.xml', -'uniform_01_c.xml', -'correct_det_by_minor_c.xml', -'repeat_det_by_minor_c.xml', -'elapsed_seconds_c.xml', -'time_det_by_minor_c.xml', -'main_compare_c.xml' -]; -var list_current0 = [ -'time_det_by_minor_c.xml#Syntax', -'time_det_by_minor_c.xml#Purpose', -'time_det_by_minor_c.xml#time_min', -'time_det_by_minor_c.xml#time', -'time_det_by_minor_c.xml#Source Code' -]; -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-2018.00.00.0/doc/time_test.cpp.xml cppad-2019.02.00.0/doc/time_test.cpp.xml --- cppad-2018.00.00.0/doc/time_test.cpp.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/time_test.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ - - - -time_test: Example and test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -time_test.cppHeadings

-
time_test: Example and test
-
# include <cppad/utility/time_test.hpp>
-# include <cppad/utility/vector.hpp>
-
-namespace { // empty namespace
-     using CppAD::vector;
-
-     // size for the test
-     size_t size_;
-
-     vector<double> a, b, c;
-     void test(size_t repeat)
-     {     // setup
-          a.resize(size_);
-          b.resize(size_);
-          c.resize(size_);
-          size_t i  = size_;;
-          while(i)
-          {     --i;
-               a[i] = float(i);
-               b[i] = float(2 * i);
-               c[i] = 0.0;
-          }
-          // operations we are timing
-          while(repeat--)
-          {     i = size_;;
-               while(i)
-               {     --i;
-                    c[i] += std::sqrt(a[i] * a[i] + b[i] * b[i]);
-               }
-          }
-     }
-
-}
-bool time_test(void)
-{     bool ok = true;
-
-     // minimum amount of time to run test
-     double time_min = 0.5;
-
-     // size of first test case
-     size_ = 20;
-
-     // run the first test case
-     double time_first = CppAD::time_test(test, time_min);
-
-     // size of second test case is twice as large
-     size_ = 2 * size_;
-
-     // run the second test case
-     double time_second = CppAD::time_test(test, time_min);
-
-     // for this case, time should be linear w.r.t size
-     double rel_diff = 1. - 2. * time_first / time_second;
-     ok             &= (std::fabs(rel_diff) <= .1);
-     if( ! ok )
-          std::cout << std::endl << "rel_diff = " << rel_diff  << std::endl;
-
-     a.clear();
-     b.clear();
-     c.clear();
-     return ok;
-}
-
-
Input File: speed/example/time_test.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_time_test.cpp_xml.js cppad-2019.02.00.0/doc/_time_test.cpp_xml.js --- cppad-2018.00.00.0/doc/_time_test.cpp_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_time_test.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'time_test.xml', -'time_test.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'elapsed_seconds.xml', -'time_test.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-2018.00.00.0/doc/time_test.xml cppad-2019.02.00.0/doc/time_test.xml --- cppad-2018.00.00.0/doc/time_test.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/time_test.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,309 +0,0 @@ - - - -Determine Amount of Time to Execute a Test - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
Determine Amount of Time to Execute a Test
-
-Syntax - -
- -# include <cppad/utility/time_test.hpp>
-
- -time = time_test(testtime_min)
-
- -time = time_test(testtime_mintest_size) - - -
-
-Purpose -
-The time_test function executes a timing test -and reports the amount of wall clock time for execution. - -
-
-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 time_test -automatically determines how many times to -repeat the section of the test that we wish to time. - -
-
-Include -
-The file cppad/time_test.hpp defines the -time_test function. -This file is included by cppad/cppad.hpp -and it can also be included separately with out the rest of -the CppAD routines. - -
-
-test -
-The time_test argument -test - is a function, -or function object. -In the case where -test_size - is not present, - -test - supports the syntax - -
-     
test(repeat)
-
-In the case where -test_size - is present, - -test - supports the syntax - -
-     
test(sizerepeat)
-
-In either case, the return value for -test - is void. - -
-
-size -
-If the argument -size - is present, -it has prototype - -
-     size_t 
size
-
-and is equal to the -test_size - argument to time_test. - -
-
-repeat -
-The -test - argument -repeat - has prototype - -
-     size_t 
repeat
-
-It will be equal to the -size - argument to time_test. - -
-
-time_min -
-The argument -time_min - has prototype - -
-     double 
time_min
-
-It specifies the minimum amount of time in seconds -that the -test - routine should take. -The -repeat - argument to -test - is increased -until this amount of execution time (or more) is reached. - -
-
-test_size -
-This argument has prototype - -
-     size_t 
test_size
-
-It specifies the -size - argument to -test -. - -
-
-time -
-The return value -time - has prototype - -
-     double 
time
-
-and is the number of wall clock seconds that it took -to execute -test - divided by the value used for -repeat -. - -
-
-Timing -
-The routine elapsed_seconds - will be used to determine the -amount of time it took to execute the test. - - -
-
-Example -
-The routine time_test.cpp - is an example and test -of time_test. - - -
Input File: cppad/utility/time_test.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_time_test_xml.js cppad-2019.02.00.0/doc/_time_test_xml.js --- cppad-2018.00.00.0/doc/_time_test_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_time_test_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'time_test.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down0 = [ -'elapsed_seconds.xml', -'time_test.cpp.xml' -]; -var list_current0 = [ -'time_test.xml#Syntax', -'time_test.xml#Purpose', -'time_test.xml#Motivation', -'time_test.xml#Include', -'time_test.xml#test', -'time_test.xml#test.size', -'time_test.xml#test.repeat', -'time_test.xml#time_min', -'time_test.xml#test_size', -'time_test.xml#time', -'time_test.xml#Timing', -'time_test.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-2018.00.00.0/doc/to_string.cpp.xml cppad-2019.02.00.0/doc/to_string.cpp.xml --- cppad-2018.00.00.0/doc/to_string.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/to_string.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,218 +0,0 @@ - - - -to_string: Example and Test - - - - - - - - - - - - - - - - -
- -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 string2signed(const std::string& s)
-     {     Integer result = 0;
-          size_t index   = 0;
-          if( s[0] == '-' )
-               ++index;
-          while( index < s.size() )
-               result = Integer(10 * result + s[index++] - '0');
-          if( s[0] == '-' )
-               return - result;
-          return result;
-     }
-     template <class Integer>
-     Integer string2unsigned(const std::string& s)
-     {     Integer result = 0;
-          size_t index   = 0;
-          while( index < s.size() )
-               result = Integer(10 * result + s[index++] - '0');
-          return result;
-     }
-     template <class Integer>
-     bool signed_integer(void)
-     {     bool ok = true;
-          //
-          Integer max    = std::numeric_limits<Integer>::max();
-          std::string s  = CppAD::to_string(max);
-          Integer check  = string2signed<Integer>(s);
-          ok            &= max == check;
-          //
-          Integer min    = std::numeric_limits<Integer>::min();
-          s              = CppAD::to_string(min);
-          check          = string2signed<Integer>(s);
-          ok            &= min == check;
-          //
-          return ok;
-     }
-     template <class Integer>
-     bool unsigned_integer(void)
-     {     bool ok = true;
-          //
-          Integer max    = std::numeric_limits<Integer>::max();
-          std::string s  = CppAD::to_string(max);
-          Integer check  = string2unsigned<Integer>(s);
-          ok            &= max == check;
-          ok            &= std::numeric_limits<Integer>::min() == 0;
-          //
-          return ok;
-     }
-     template <class Float>
-     bool floating(void)
-     {     bool  ok  = true;
-          Float eps = std::numeric_limits<Float>::epsilon();
-          Float pi  = Float( 4.0 * std::atan(1.0) );
-          //
-          std::string s = CppAD::to_string( pi );
-          Float check   = Float( std::atof( s.c_str() ) );
-          ok           &= std::fabs( check / pi - 1.0 ) <= 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   = Base( 4.0 * std::atan(1.0) );
-          //
-          std::string s = CppAD::to_string( CppAD::AD<Base>( pi ) );
-          Base check    = Base( std::atof( s.c_str() ) );
-          ok           &= fabs( check / pi - Base(1.0) ) <= Base( 2.0 ) * eps;
-          //
-          return ok;
-     }
-}
-
-// Test driver
-bool to_string(void)
-{     bool ok = true;
-
-     ok &= unsigned_integer<unsigned short>();
-     ok &= signed_integer<signed int>();
-     //
-     ok &= unsigned_integer<unsigned long>();
-     ok &= signed_integer<signed long>();
-# if CPPAD_USE_CPLUSPLUS_2011
-     ok &= unsigned_integer<unsigned long long>();
-     ok &= signed_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/utility/to_string.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_to_string.cpp_xml.js cppad-2019.02.00.0/doc/_to_string.cpp_xml.js --- cppad-2018.00.00.0/doc/_to_string.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_to_string.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.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-2018.00.00.0/doc/to_string.xml cppad-2019.02.00.0/doc/to_string.xml --- cppad-2018.00.00.0/doc/to_string.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/to_string.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,264 +0,0 @@ - - - -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 -. -
  5. - -For integer types, conversion to a string is exact. -For floating point types, conversion to a string yields a value -that has relative error within machine epsilon. -
- - -
-
-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-2018.00.00.0/doc/_to_string_xml.js cppad-2019.02.00.0/doc/_to_string_xml.js --- cppad-2018.00.00.0/doc/_to_string_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_to_string_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.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-2018.00.00.0/doc/tracknewdel.cpp.xml cppad-2019.02.00.0/doc/tracknewdel.cpp.xml --- cppad-2018.00.00.0/doc/tracknewdel.cpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/tracknewdel.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ - - - -Tracking Use of New and Delete: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -TrackNewDel.cppHeadings

- - -
Tracking Use of New and Delete: Example and Test
-

-# include <cppad/utility/track_new_del.hpp>
-
-bool track_new_del(void)
-{     bool ok = true;
-
-     // initial count
-     size_t count = CPPAD_TRACK_COUNT();
-
-     // allocate an array of length 5
-     double *ptr = CPPAD_NULL;
-     size_t  newlen = 5;
-     ptr = CPPAD_TRACK_NEW_VEC(newlen, ptr);
-
-     // copy data into the array
-     size_t ncopy = newlen;
-     size_t i;
-     for(i = 0; i < ncopy; i++)
-          ptr[i] = double(i);
-
-     // extend the buffer to be length 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++)
-          ok &= (ptr[i] == double(i));
-
-     // free the memory allocated since previous call to TrackCount
-     CPPAD_TRACK_DEL_VEC(ptr);
-
-     // check for memory leak
-     ok &= (count == CPPAD_TRACK_COUNT());
-
-     return ok;
-}
-
-
-
Input File: example/deprecated/track_new_del.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_tracknewdel.cpp_xml.js cppad-2019.02.00.0/doc/_tracknewdel.cpp_xml.js --- cppad-2018.00.00.0/doc/_tracknewdel.cpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_tracknewdel.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'tracknewdel.xml', -'tracknewdel.cpp.xml' -]; -var list_down3 = [ -'faq.xml', -'directory.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', -'autotools.xml' -]; -var list_down1 = [ -'tracknewdel.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-2018.00.00.0/doc/tracknewdel.xml cppad-2019.02.00.0/doc/tracknewdel.xml --- cppad-2018.00.00.0/doc/tracknewdel.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/tracknewdel.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,472 +0,0 @@ - - - -Routines That Track Use of New and Delete - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Routines That Track Use of New and Delete
-
-Deprecated 2007-07-23 -
-All these routines have been deprecated. -You should use the thread_alloc - memory allocator instead -(which works better in both a single thread and -properly in multi-threading environment). - -
-
-Syntax - -
- -# include <cppad/utility/track_new_del.hpp>
-
- -newptr = TrackNewVec(filelinenewlenoldptr)
-
- -TrackDelVec(filelineoldptr)
-
- -newptr = TrackExtend(filelinenewlenncopyoldptr)
-
- -count = TrackCount(fileline) - - - -
-
-Purpose -
-These routines -aid in the use of new[] and delete[] -during the execution of a C++ program. - -
-
-Include -
-The file cppad/track_new_del.hpp is included by -cppad/cppad.hpp -but it can also be included separately with out the rest of the -CppAD include files. - - -
-
-file -
-The argument -file - has prototype - -
-     const char *
file
-
-It should be the source code file name -where the call to TrackNew is located. -The best way to accomplish this is the use the preprocessor symbol -__FILE__ for this argument. - -
-
-line -
-The argument -line - has prototype - -
-     int 
line
-
-It should be the source code file line number -where the call to TrackNew is located. -The best way to accomplish this is the use the preprocessor symbol -__LINE__ for this argument. - -
-
-oldptr -
-The argument -oldptr - has prototype - -
-     
Type *oldptr
-
-This argument is used to identify the type -Type -. - -
-
-newlen -
-The argument -newlen - has prototype - -
-     size_t 
newlen
-
-
-head newptr -
-The return value -newptr - has prototype - -
-     
Type *newptr
-
-It points to the newly allocated vector of objects -that were allocated using - -
-     new Type[
newlen]
-
-
-ncopy -
-The argument -ncopy - has prototype - -
-        size_t 
ncopy
-
-This specifies the number of elements that are copied from -the old array to the new array. -The value of -ncopy - -must be less than or equal -newlen -. - -
-
-TrackNewVec -
-If NDEBUG is defined, this routine only sets - -
-     
newptr = Type new[newlen]
-
-The value of -oldptr - does not matter -(except that it is used to identify -Type -). -If NDEBUG is not defined, TrackNewVec also -tracks the this memory allocation. -In this case, if memory cannot be allocated -ErrorHandler - is used to generate a message -stating that there was not sufficient memory. - -
-
-Macro -
-The preprocessor macro call - -
-     CPPAD_TRACK_NEW_VEC(
newlenoldptr)
-
-expands to - -
-     CppAD::TrackNewVec(__FILE__, __LINE__, 
newlenoldptr)
-
-
-Previously Deprecated -
-The preprocessor macro CppADTrackNewVec is the -same as CPPAD_TRACK_NEW_VEC and was previously deprecated. - -
-
-TrackDelVec -
-This routine is used to a vector of objects -that have been allocated using TrackNew or TrackExtend. -If NDEBUG is defined, this routine only frees memory with - -
-     delete [] 
oldptr
-
-If NDEBUG is not defined, TrackDelete also checks that - -oldptr - was allocated by TrackNew or TrackExtend -and has not yet been freed. -If this is not the case, -ErrorHandler - is used to generate an error message. - -
-
-Macro -
-The preprocessor macro call - -
-     CPPAD_TRACK_DEL_VEC(
oldptr)
-
-expands to - -
-     CppAD::TrackDelVec(__FILE__, __LINE__, 
oldptr)
-
-
-Previously Deprecated -
-The preprocessor macro CppADTrackDelVec is the -same as CPPAD_TRACK_DEL_VEC was previously deprecated. - -
-
-TrackExtend -
-This routine is used to -allocate a new vector (using TrackNewVec), -copy -ncopy - elements from the old vector to the new vector. -If -ncopy - is greater than zero, -oldptr - -must have been allocated using TrackNewVec or TrackExtend. -In this case, the vector pointed to by -oldptr - -must be have at least -ncopy - elements -and it will be deleted (using TrackDelVec). -Note that the dependence of TrackExtend on NDEBUG -is indirectly through the routines TrackNewVec and -TrackDelVec. - -
-
-Macro -
-The preprocessor macro call - -
-     CPPAD_TRACK_EXTEND(
newlenncopyoldptr)
-
-expands to - -
-     CppAD::TrackExtend(__FILE__, __LINE__, 
newlenncopyoldptr)
-
-
-Previously Deprecated -
-The preprocessor macro CppADTrackExtend is the -same as CPPAD_TRACK_EXTEND and was previously deprecated. - -
-
-TrackCount -
-The return value -count - has prototype - -
-     size_t 
count
-
-If NDEBUG is defined, -count - will be zero. -Otherwise, it will be -the number of vectors that -have been allocated -(by TrackNewVec or TrackExtend) -and not yet freed -(by TrackDelete). - -
-
-Macro -
-The preprocessor macro call - -
-     CPPAD_TRACK_COUNT()
-
-expands to - -
-     CppAD::TrackCount(__FILE__, __LINE__)
-
-
-Previously Deprecated -
-The preprocessor macro CppADTrackCount is the -same as CPPAD_TRACK_COUNT and was previously deprecated. - -
-
-Multi-Threading -
-These routines cannot be used in_parallel - -execution mode. -Use the thread_alloc - routines instead. - -
-
-Example - -
-The file TrackNewDel.cpp - -contains an example and test of these functions. -It returns true, if it succeeds, and false otherwise. - - -
Input File: cppad/utility/track_new_del.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_tracknewdel_xml.js cppad-2019.02.00.0/doc/_tracknewdel_xml.js --- cppad-2018.00.00.0/doc/_tracknewdel_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_tracknewdel_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'deprecated.xml', -'tracknewdel.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', -'directory.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', -'autotools.xml' -]; -var list_down0 = [ -'tracknewdel.cpp.xml' -]; -var list_current0 = [ -'tracknewdel.xml#Deprecated 2007-07-23', -'tracknewdel.xml#Syntax', -'tracknewdel.xml#Purpose', -'tracknewdel.xml#Include', -'tracknewdel.xml#file', -'tracknewdel.xml#line', -'tracknewdel.xml#oldptr', -'tracknewdel.xml#newlen', -'tracknewdel.xml#head newptr', -'tracknewdel.xml#ncopy', -'tracknewdel.xml#TrackNewVec', -'tracknewdel.xml#TrackNewVec.Macro', -'tracknewdel.xml#TrackNewVec.Previously Deprecated', -'tracknewdel.xml#TrackDelVec', -'tracknewdel.xml#TrackDelVec.Macro', -'tracknewdel.xml#TrackDelVec.Previously Deprecated', -'tracknewdel.xml#TrackExtend', -'tracknewdel.xml#TrackExtend.Macro', -'tracknewdel.xml#TrackExtend.Previously Deprecated', -'tracknewdel.xml#TrackCount', -'tracknewdel.xml#TrackCount.Macro', -'tracknewdel.xml#TrackCount.Previously Deprecated', -'tracknewdel.xml#Multi-Threading', -'tracknewdel.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-2018.00.00.0/doc/unary_minus.cpp.xml cppad-2019.02.00.0/doc/unary_minus.cpp.xml --- cppad-2018.00.00.0/doc/unary_minus.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/unary_minus.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ - - - -AD Unary Minus Operator: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -unary_minus.cppHeadings

- - - -
AD Unary Minus Operator: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool UnaryMinus(void)
-{     bool ok = true;
-     using CppAD::AD;
-
-
-     // domain space vector
-     size_t n = 1;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0]      = 3.;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = - x[0];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check values
-     ok &= ( y[0] == -3. );
-
-     // forward computation of partials w.r.t. x[0]
-     CPPAD_TESTVECTOR(double) dx(n);
-     CPPAD_TESTVECTOR(double) dy(m);
-     size_t p = 1;
-     dx[0]    = 1.;
-     dy       = f.Forward(p, dx);
-     ok      &= ( dy[0] == -1. );   // dy[0] / dx[0]
-
-     // reverse computation of dertivative of y[0]
-     CPPAD_TESTVECTOR(double)  w(m);
-     CPPAD_TESTVECTOR(double) dw(n);
-     w[0] = 1.;
-     dw   = f.Reverse(p, w);
-     ok &= ( dw[0] == -1. );       // dy[0] / dx[0]
-
-     // use a VecAD<Base>::reference object with unary minus
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero] = x[0];
-     AD<double> result = - v[zero];
-     ok     &= (result == y[0]);
-
-     return ok;
-}
-
-
Input File: example/general/unary_minus.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_unary_minus.cpp_xml.js cppad-2019.02.00.0/doc/_unary_minus.cpp_xml.js --- cppad-2018.00.00.0/doc/_unary_minus.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_unary_minus.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +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', -'arithmetic.xml', -'unaryminus.xml', -'unary_minus.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down1 = [ -'unary_minus.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-2018.00.00.0/doc/unaryminus.xml cppad-2019.02.00.0/doc/unaryminus.xml --- cppad-2018.00.00.0/doc/unaryminus.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/unaryminus.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,224 +0,0 @@ - - - -AD Unary Minus Operator - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
AD Unary Minus Operator
-
-Syntax - - -
- -y = - x - - - -
-
-Purpose -
-Computes the negative of -x -. - -
-
-Base -
-The operation in the syntax above must be supported for the case where -the operand is a const -Base - object. - -
-
-x -
-The operand -x - has one of the following prototypes - -
-     const AD<
Base>               &x
-     const VecAD<
Base>::reference &x
-
-
-y -
-The result -y - has type - -
-     AD<
Basey
-
-It is equal to the negative of the operand -x -. - -
-
-Operation Sequence -
-This is an AD of -Base - -atomic operation - -and hence is part of the current -AD of -Base - -operation sequence -. - -
-
-Derivative -
-If - -f - - - is a -Base function -, - - - -[ -- -f -( -x -) -] - - -x - - -= -- - -f -( -x -) - - -x - - - - -
-Example - -
-The file -unary_minus.cpp - -contains an example and test of this operation. - - -
Input File: cppad/core/unary_minus.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_unaryminus_xml.js cppad-2019.02.00.0/doc/_unaryminus_xml.js --- cppad-2018.00.00.0/doc/_unaryminus_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_unaryminus_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', -'arithmetic.xml', -'unaryminus.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down0 = [ -'unary_minus.cpp.xml' -]; -var list_current0 = [ -'unaryminus.xml#Syntax', -'unaryminus.xml#Purpose', -'unaryminus.xml#Base', -'unaryminus.xml#x', -'unaryminus.xml#y', -'unaryminus.xml#Operation Sequence', -'unaryminus.xml#Derivative', -'unaryminus.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-2018.00.00.0/doc/unary_plus.cpp.xml cppad-2019.02.00.0/doc/unary_plus.cpp.xml --- cppad-2018.00.00.0/doc/unary_plus.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/unary_plus.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ - - - -AD Unary Plus Operator: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -unary_plus.cppHeadings

- - - -
AD Unary Plus Operator: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool UnaryPlus(void)
-{     bool ok = true;
-     using CppAD::AD;
-
-
-     // domain space vector
-     size_t n = 1;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0]      = 3.;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = + x[0];
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // check values
-     ok &= ( y[0] == 3. );
-
-     // forward computation of partials w.r.t. x[0]
-     CPPAD_TESTVECTOR(double) dx(n);
-     CPPAD_TESTVECTOR(double) dy(m);
-     size_t p = 1;
-     dx[0]    = 1.;
-     dy       = f.Forward(p, dx);
-     ok      &= ( dy[0] == 1. );   // dy[0] / dx[0]
-
-     // reverse computation of dertivative of y[0]
-     CPPAD_TESTVECTOR(double)  w(m);
-     CPPAD_TESTVECTOR(double) dw(n);
-     w[0] = 1.;
-     dw   = f.Reverse(p, w);
-     ok &= ( dw[0] == 1. );       // dy[0] / dx[0]
-
-     // use a VecAD<Base>::reference object with unary plus
-     CppAD::VecAD<double> v(1);
-     AD<double> zero(0);
-     v[zero] = x[0];
-     AD<double> result = + v[zero];
-     ok     &= (result == y[0]);
-
-     return ok;
-}
-
-
Input File: example/general/unary_plus.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_unary_plus.cpp_xml.js cppad-2019.02.00.0/doc/_unary_plus.cpp_xml.js --- cppad-2018.00.00.0/doc/_unary_plus.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_unary_plus.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +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', -'arithmetic.xml', -'unaryplus.xml', -'unary_plus.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down1 = [ -'unary_plus.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-2018.00.00.0/doc/unaryplus.xml cppad-2019.02.00.0/doc/unaryplus.xml --- cppad-2018.00.00.0/doc/unaryplus.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/unaryplus.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,217 +0,0 @@ - - - -AD Unary Plus Operator - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
AD Unary Plus Operator
-
-Syntax - - -
- -y = + x - - - -
-
-Purpose -
-Performs the unary plus operation -(the result -y - is equal to the operand -x -). - - -
-
-x -
-The operand -x - has one of the following prototypes - -
-     const AD<
Base>               &x
-     const VecAD<
Base>::reference &x
-
-
-y -
-The result -y - has type - -
-     AD<
Basey
-
-It is equal to the operand -x -. - -
-
-Operation Sequence -
-This is an AD of -Base - -atomic operation - -and hence is part of the current -AD of -Base - -operation sequence -. - -
-
-Derivative -
-If - -f - - - is a -Base function -, - - - -[ -+ -f -( -x -) -] - - -x - - -= - -f -( -x -) - - -x - - - - -
-Example - -
-The file -unary_plus.cpp - -contains an example and test of this operation. - - -
Input File: cppad/core/unary_plus.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_unaryplus_xml.js cppad-2019.02.00.0/doc/_unaryplus_xml.js --- cppad-2018.00.00.0/doc/_unaryplus_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_unaryplus_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +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', -'arithmetic.xml', -'unaryplus.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 = [ -'unaryplus.xml', -'unaryminus.xml', -'ad_binary.xml', -'compound_assign.xml' -]; -var list_down0 = [ -'unary_plus.cpp.xml' -]; -var list_current0 = [ -'unaryplus.xml#Syntax', -'unaryplus.xml#Purpose', -'unaryplus.xml#x', -'unaryplus.xml#y', -'unaryplus.xml#Operation Sequence', -'unaryplus.xml#Derivative', -'unaryplus.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-2018.00.00.0/doc/unary_standard_math.xml cppad-2019.02.00.0/doc/unary_standard_math.xml --- cppad-2018.00.00.0/doc/unary_standard_math.xml 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/unary_standard_math.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,310 +0,0 @@ - - - -The Unary Standard Math Functions - - - - - - - - - - - - - - - - -
- -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/core/standard_math.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_unary_standard_math_xml.js cppad-2019.02.00.0/doc/_unary_standard_math_xml.js --- cppad-2018.00.00.0/doc/_unary_standard_math_xml.js 2018-01-01 08:32:42.000000000 +0000 +++ cppad-2019.02.00.0/doc/_unary_standard_math_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +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', -'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-2018.00.00.0/doc/uniform_01_c.xml cppad-2019.02.00.0/doc/uniform_01_c.xml --- cppad-2018.00.00.0/doc/uniform_01_c.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/uniform_01_c.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,191 +0,0 @@ - - - -Simulate a [0,1] Uniform Random Variate - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -uniform_01_c - -

-
Simulate a [0,1] Uniform Random Variate
-
-Syntax - -
- -random_seed(seed)
-
- -uniform_01(na) - - -
-
-Purpose -
-This routine is used to create random values for speed testing purposes. - -
-
-seed -
-The argument -seed - has prototype - -
-     size_t 
seed
-
-It specifies a seed -for the uniform random number generator. - -
-
-n -
-The argument -n - has prototype - -
-     size_t 
n
-
-It specifies the number of elements in the random vector -a -. - -
-
-a -
-The argument -a - has prototype - -
-     double* 
a
-
-. -The input value of the elements of -a - does not matter. -Upon return, the elements of -a - are set to values -randomly sampled over the interval [0,1]. - - - - -
-
-Source Code - -
void random_seed(size_t seed)
-{     srand( (unsigned int) seed );
-}
-void uniform_01(size_t n, double* a)
-{     static double factor = 1. / (double) RAND_MAX;
-     while(n--)
-          a[n] = rand() * factor;
-}
- -
Input File: test_more/compare_c/det_by_minor.c - - - diff -Nru cppad-2018.00.00.0/doc/_uniform_01_c_xml.js cppad-2019.02.00.0/doc/_uniform_01_c_xml.js --- cppad-2018.00.00.0/doc/_uniform_01_c_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_uniform_01_c_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'appendix.xml', -'compare_c.xml', -'uniform_01_c.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', -'directory.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 = [ -'det_of_minor_c.xml', -'det_by_minor_c.xml', -'uniform_01_c.xml', -'correct_det_by_minor_c.xml', -'repeat_det_by_minor_c.xml', -'elapsed_seconds_c.xml', -'time_det_by_minor_c.xml', -'main_compare_c.xml' -]; -var list_current0 = [ -'uniform_01_c.xml#Syntax', -'uniform_01_c.xml#Purpose', -'uniform_01_c.xml#seed', -'uniform_01_c.xml#n', -'uniform_01_c.xml#a', -'uniform_01_c.xml#Source Code' -]; -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-2018.00.00.0/doc/uniform_01.hpp.xml cppad-2019.02.00.0/doc/uniform_01.hpp.xml --- cppad-2018.00.00.0/doc/uniform_01.hpp.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/uniform_01.hpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ - - - -Source: uniform_01 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -uniform_01.hppHeadings

- - - -
Source: uniform_01
-# ifndef CPPAD_UNIFORM_01_HPP -
-
# define CPPAD_UNIFORM_01_HPP - -
# include <cstdlib>
-
-namespace CppAD {
-     inline void uniform_01(size_t seed)
-     {     std::srand( (unsigned int) seed); }
-
-     template <class Vector>
-     void uniform_01(size_t n, Vector &x)
-     {     static double factor = 1. / double(RAND_MAX);
-          while(n--)
-               x[n] = std::rand() * factor;
-     }
-}
-# endif -
- - -
Input File: omh/uniform_01_hpp.omh - - - diff -Nru cppad-2018.00.00.0/doc/_uniform_01.hpp_xml.js cppad-2019.02.00.0/doc/_uniform_01.hpp_xml.js --- cppad-2018.00.00.0/doc/_uniform_01.hpp_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_uniform_01.hpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'uniform_01.xml', -'uniform_01.hpp.xml' -]; -var list_down3 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down2 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down1 = [ -'uniform_01.hpp.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-2018.00.00.0/doc/uniform_01.xml cppad-2019.02.00.0/doc/uniform_01.xml --- cppad-2018.00.00.0/doc/uniform_01.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/uniform_01.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,234 +0,0 @@ - - - -Simulate a [0,1] Uniform Random Variate - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

- - - -
Simulate a [0,1] Uniform Random Variate
-
-Syntax - -
- -# include <cppad/speed/uniform_01.hpp>
-
- -uniform_01(seed)
-
- -uniform_01(nx) - - -
-
-Purpose -
-This routine is used to create random values for speed testing purposes. - -
-
-Inclusion -
-The template function uniform_01 is defined in the CppAD -namespace by including -the file cppad/speed/uniform_01.hpp -(relative to the CppAD distribution directory). - -
-
-seed -
-The argument -seed - has prototype - -
-     size_t 
seed
-
-It specifies a seed -for the uniform random number generator. - -
-
-n -
-The argument -n - has prototype - -
-     size_t 
n
-
-It specifies the number of elements in the random vector -x -. - -
-
-x -
-The argument -x - has prototype - -
-     
Vector &x
-
-. -The input value of the elements of -x - does not matter. -Upon return, the elements of -x - are set to values -randomly sampled over the interval [0,1]. - -
-
-Vector -
-If -y - is a double value, -the object -x - must support the syntax - -
-     
x[i] = y
-
-where -i - has type size_t with value less than -or equal - -n --1 - - -. -This is the only requirement of the type -Vector -. - - - -
-
-Source Code -
-The file -uniform_01.hpp - -constraints the source code for this template function. - - -
Input File: cppad/speed/uniform_01.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_uniform_01_xml.js cppad-2019.02.00.0/doc/_uniform_01_xml.js --- cppad-2018.00.00.0/doc/_uniform_01_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_uniform_01_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'speed.xml', -'speed_utility.xml', -'uniform_01.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 = [ -'speed_main.xml', -'speed_utility.xml', -'speed_double.xml', -'speed_adolc.xml', -'speed_cppad.xml', -'speed_fadbad.xml', -'speed_sacado.xml' -]; -var list_down1 = [ -'det_by_lu.xml', -'det_of_minor.xml', -'det_by_minor.xml', -'det_33.xml', -'det_grad_33.xml', -'mat_sum_sq.xml', -'ode_evaluate.xml', -'sparse_jac_fun.xml', -'sparse_hes_fun.xml', -'uniform_01.xml' -]; -var list_down0 = [ -'uniform_01.hpp.xml' -]; -var list_current0 = [ -'uniform_01.xml#Syntax', -'uniform_01.xml#Purpose', -'uniform_01.xml#Inclusion', -'uniform_01.xml#seed', -'uniform_01.xml#n', -'uniform_01.xml#x', -'uniform_01.xml#Vector', -'uniform_01.xml#Source Code' -]; -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-2018.00.00.0/doc/utility.xml cppad-2019.02.00.0/doc/utility.xml --- cppad-2018.00.00.0/doc/utility.xml 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/utility.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,327 +0,0 @@ - - - -Some General Purpose Utilities - - - - - - - - - - - - - - -
- -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
- -test_boolofvoid -Object that Runs a Group of Tests
- -
-
-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
- -
-
-The CppAD Vector Template Class -
-This is 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
- -
-
-set_union - - - -
- -set_union -Union of Standard Sets
- -
-
-Sparse Matrices - - - - -
- -sparse_rc -Row and Column Index Sparsity Patterns
- -sparse_rcv -Sparse Matrix Row, Column, Value Representation
- -
- -
Input File: omh/utility.omh - - - diff -Nru cppad-2018.00.00.0/doc/_utility_xml.js cppad-2019.02.00.0/doc/_utility_xml.js --- cppad-2018.00.00.0/doc/_utility_xml.js 2018-01-01 08:32:45.000000000 +0000 +++ cppad-2019.02.00.0/doc/_utility_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', -'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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.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.The CppAD Vector Template Class', -'utility.xml#Miscellaneous.Multi-Threading Memory Allocation', -'utility.xml#Miscellaneous.Sorting Indices', -'utility.xml#Miscellaneous.to_string', -'utility.xml#Miscellaneous.set_union', -'utility.xml#Miscellaneous.Sparse Matrices' -]; -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-2018.00.00.0/doc/value.cpp.xml cppad-2019.02.00.0/doc/value.cpp.xml --- cppad-2018.00.00.0/doc/value.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/value.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ - - - -Convert From AD to its Base Type: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -value.cppHeadings

- - - -
Convert From AD to its Base Type: Example and Test
-

-# include <cppad/cppad.hpp>
-
-bool Value(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::Value;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) x(n);
-     x[0] = 3.;
-     x[1] = 4.;
-
-     // check value before recording
-     ok &= (Value(x[0]) == 3.);
-     ok &= (Value(x[1]) == 4.);
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(x);
-
-     // range space vector
-     size_t m = 1;
-     CPPAD_TESTVECTOR(AD<double>) y(m);
-     y[0] = - x[1];
-
-     // cannot call Value(x[j]) or Value(y[0]) here (currently variables)
-     AD<double> p = 5.;        // p is a parameter (does not depend on x)
-     ok &= (Value(p) == 5.);
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // can call Value(x[j]) or Value(y[0]) here (currently parameters)
-     ok &= (Value(x[0]) ==  3.);
-     ok &= (Value(x[1]) ==  4.);
-     ok &= (Value(y[0]) == -4.);
-
-     return ok;
-}
-
-
Input File: example/general/value.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_value.cpp_xml.js cppad-2019.02.00.0/doc/_value.cpp_xml.js --- cppad-2018.00.00.0/doc/_value.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_value.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'convert.xml', -'value.xml', -'value.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 = [ -'value.xml', -'integer.xml', -'ad_to_string.xml', -'ad_input.xml', -'ad_output.xml', -'printfor.xml', -'var2par.xml' -]; -var list_down1 = [ -'value.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-2018.00.00.0/doc/value.xml cppad-2019.02.00.0/doc/value.xml --- cppad-2018.00.00.0/doc/value.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/value.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,199 +0,0 @@ - - - -Convert From an AD Type to its Base Type - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Convert From an AD Type to its Base Type
-
-Syntax - -
- -b = Value(x) - - -
-
-See Also - -
-var2par - - - -
-
-Purpose -
-Converts from an AD type to the corresponding -base type -. - -
-
-x -
-The argument -x - has prototype - -
-     const AD<
Base> &x
-
-
-b -
-The return value -b - has prototype - -
-     
Base b
-
-
-Operation Sequence -
-The result of this operation is not an -AD of Base - object. -Thus it will not be recorded as part of an -AD of -Base - -operation sequence -. - -
-
-Restriction -
-If the argument -x - is a -variable - its dependency information -would not be included in the Value result (see above). -For this reason, -the argument -x - must be a parameter -; i.e., -it cannot depend on the current -independent variables -. - -
-
-Example - -
-The file -value.cpp - -contains an example and test of this operation. - - -
Input File: cppad/core/value.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_value_xml.js cppad-2019.02.00.0/doc/_value_xml.js --- cppad-2018.00.00.0/doc/_value_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_value_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'convert.xml', -'value.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_down0 = [ -'value.cpp.xml' -]; -var list_current0 = [ -'value.xml#Syntax', -'value.xml#See Also', -'value.xml#Purpose', -'value.xml#x', -'value.xml#b', -'value.xml#Operation Sequence', -'value.xml#Restriction', -'value.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-2018.00.00.0/doc/var2par.cpp.xml cppad-2019.02.00.0/doc/var2par.cpp.xml --- cppad-2018.00.00.0/doc/var2par.cpp.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/var2par.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ - - - -Convert an AD Variable to a Parameter: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -var2par.cppHeadings

- - - -
Convert an AD Variable to a Parameter: Example and Test
-

-# include <cppad/cppad.hpp>
-
-
-bool Var2Par(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::Value;
-     using CppAD::Var2Par;
-
-     // domain space vector
-     size_t n = 2;
-     CPPAD_TESTVECTOR(AD<double>) 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<double>) 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. );
-
-     // create f: x -> y and stop tape recording
-     CppAD::ADFun<double> f(x, y);
-
-     // can call Value(x[j]) or Value(y[0]) here (currently parameters)
-     ok &= (Value(x[0]) ==  3.);
-     ok &= (Value(x[1]) ==  4.);
-     ok &= (Value(y[0]) == -12.);
-
-     // evaluate derivative of y w.r.t x
-     CPPAD_TESTVECTOR(double) w(m);
-     CPPAD_TESTVECTOR(double) dw(n);
-     w[0] = 1.;
-     dw   = f.Reverse(1, w);
-     ok  &= (dw[0] == 0.);  // derivative of y[0] w.r.t x[0] is zero
-     ok  &= (dw[1] == -3.); // derivative of y[0] w.r.t x[1] is 3
-
-     return ok;
-}
-
-
Input File: example/general/var2par.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_var2par.cpp_xml.js cppad-2019.02.00.0/doc/_var2par.cpp_xml.js --- cppad-2018.00.00.0/doc/_var2par.cpp_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_var2par.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'convert.xml', -'var2par.xml', -'var2par.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 = [ -'value.xml', -'integer.xml', -'ad_to_string.xml', -'ad_input.xml', -'ad_output.xml', -'printfor.xml', -'var2par.xml' -]; -var list_down1 = [ -'var2par.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-2018.00.00.0/doc/var2par.xml cppad-2019.02.00.0/doc/var2par.xml --- cppad-2018.00.00.0/doc/var2par.xml 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/var2par.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,184 +0,0 @@ - - - -Convert an AD Variable to a Parameter - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - - - -

-
Convert an AD Variable to a Parameter
-
-Syntax - -
- -y = Var2Par(x) - - -
-
-See Also - -
-value - - - -
-
-Purpose -
-Returns a -parameter - -y - -with the same value as the -variable - -x -. - -
-
-x -
-The argument -x - has prototype - -
-     const AD<
Base> &x
-
-The argument -x - may be a variable or parameter. - - -
-
-y -
-The result -y - has prototype - -
-     AD<
Base> &y
-
-The return value -y - will be a parameter. - - -
-
-Example - -
-The file -var2par.cpp - -contains an example and test of this operation. -It returns true if it succeeds and false otherwise. - - -
Input File: cppad/core/var2par.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_var2par_xml.js cppad-2019.02.00.0/doc/_var2par_xml.js --- cppad-2018.00.00.0/doc/_var2par_xml.js 2018-01-01 08:32:41.000000000 +0000 +++ cppad-2019.02.00.0/doc/_var2par_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', -'ad.xml', -'convert.xml', -'var2par.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_down0 = [ -'var2par.cpp.xml' -]; -var list_current0 = [ -'var2par.xml#Syntax', -'var2par.xml#See Also', -'var2par.xml#Purpose', -'var2par.xml#x', -'var2par.xml#y', -'var2par.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-2018.00.00.0/doc/vec_ad.cpp.xml cppad-2019.02.00.0/doc/vec_ad.cpp.xml --- cppad-2018.00.00.0/doc/vec_ad.cpp.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/vec_ad.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,236 +0,0 @@ - - - -AD Vectors that Record Index Operations: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -vec_ad.cppHeadings

- - - -
AD Vectors that Record Index Operations: Example and Test
-

-# include <cppad/cppad.hpp>
-# include <cassert>
-
-namespace {
-     // 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<double> tape
-     typedef CPPAD_TESTVECTOR(CppAD::AD<double>) Vector;
-     Vector Solve(const Vector &a , const Vector &b)
-     {     using namespace CppAD;
-          assert(a.size() == 4 && b.size() == 2);
-
-          // copy the vector b into the VecAD object B
-          VecAD<double> B(2);
-          AD<double>    u;
-          for(u = 0; u < 2; u += 1.)
-               B[u] = b[ Integer(u) ];
-
-          // copy the matrix a into the VecAD object A
-          VecAD<double> A(4);
-          for(u = 0; u < 4; u += 1.)
-               A[u] = a [ Integer(u) ];
-
-          // tape AD operation sequence that determines the row of A
-          // with maximum absolute element in column zero
-          AD<double> zero(0), one(1);
-          AD<double> rmax = CondExpGt(fabs(a[0]), fabs(a[2]), zero, one);
-
-          // divide row rmax by A(rmax, 0)
-          A[rmax * 2 + 1]  = A[rmax * 2 + 1] / A[rmax * 2 + 0];
-          B[rmax]          = B[rmax]         / A[rmax * 2 + 0];
-          A[rmax * 2 + 0]  = one;
-
-          // subtract A(other,0) times row A(rmax, *) from row A(other,*)
-          AD<double> other   = one - rmax;
-          A[other * 2 + 1]   = A[other * 2 + 1]
-                             - A[other * 2 + 0] * A[rmax * 2 + 1];
-          B[other]           = B[other]
-                             - A[other * 2 + 0] * B[rmax];
-          A[other * 2 + 0] = zero;
-
-          // back substitute to compute the solution vector x.
-          // Note that the columns of A correspond to rows of x.
-          // Also note that A[rmax * 2 + 0] is equal to one.
-          CPPAD_TESTVECTOR(AD<double>) x(2);
-          x[1] = B[other] / A[other * 2 + 1];
-          x[0] = B[rmax] - A[rmax * 2 + 1] * x[1];
-
-          return x;
-     }
-}
-
-bool vec_ad(void)
-{     bool ok = true;
-
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     double eps99 = 99.0 * std::numeric_limits<double>::epsilon();
-
-     // domain space vector
-     size_t n = 4;
-     CPPAD_TESTVECTOR(double)       x(n);
-     CPPAD_TESTVECTOR(AD<double>) 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.;
-
-     // declare independent variables and start tape recording
-     CppAD::Independent(X);
-
-     // define the vector b
-     CPPAD_TESTVECTOR(double)       b(2);
-     CPPAD_TESTVECTOR(AD<double>) B(2);
-     B[0] = b[0] = 0.;
-     B[1] = b[1] = 1.;
-
-     // range space vector solves X * Y = b
-     size_t m = 2;
-     CPPAD_TESTVECTOR(AD<double>) Y(m);
-     Y = Solve(X, B);
-
-     // create f: X -> Y and stop tape recording
-     CppAD::ADFun<double> 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
-     ok &= NearEqual(Y[0] , num0 / den, eps99, eps99);
-     ok &= NearEqual(Y[1] , num1 / den, eps99, eps99);
-
-     // forward computation of partials w.r.t. x[0]
-     CPPAD_TESTVECTOR(double) dx(n);
-     CPPAD_TESTVECTOR(double) dy(m);
-     dx[0] = 1.; dx[1] = 0.;
-     dx[2] = 0.; dx[3] = 0.;
-     dy    = f.Forward(1, dx);
-     ok &= NearEqual(dy[0], 0.         - num0 * x[3] / dsq, eps99, eps99);
-     ok &= NearEqual(dy[1], b[1] / den - num1 * x[3] / dsq, eps99, eps99);
-
-     // compute the solution for a new x matrix such that pivioting
-     // on the original rmax row would divide by zero
-     CPPAD_TESTVECTOR(double) y(m);
-     x[0] = 0.; x[1] = 2.;
-     x[2] = 2.; x[3] = 0.;
-
-     // new values for Cramer's rule
-     den   = x[0] * x[3] - x[1] * x[2];
-     dsq   = den * den;
-     num0  = b[0] * x[3] - x[1] * b[1];
-     num1  = x[0] * b[1] - b[0] * x[2];
-
-     // check values
-     y    = f.Forward(0, x);
-     ok &= NearEqual(y[0] , num0 / den, eps99, eps99);
-     ok &= NearEqual(y[1] , num1 / den, eps99, eps99);
-
-     // forward computation of partials w.r.t. x[1]
-     dx[0] = 0.; dx[1] = 1.;
-     dx[2] = 0.; dx[3] = 0.;
-     dy    = f.Forward(1, dx);
-     ok   &= NearEqual(dy[0],-b[1] / den + num0 * x[2] / dsq, eps99, eps99);
-     ok   &= NearEqual(dy[1], 0.         + num1 * x[2] / dsq, eps99, eps99);
-
-     // reverse computation of derivative of y[0] w.r.t x
-     CPPAD_TESTVECTOR(double) w(m);
-     CPPAD_TESTVECTOR(double) dw(n);
-     w[0] = 1.; w[1] = 0.;
-     dw   = f.Reverse(1, w);
-     ok  &= NearEqual(dw[0], 0.         - num0 * x[3] / dsq, eps99, eps99);
-     ok  &= NearEqual(dw[1],-b[1] / den + num0 * x[2] / dsq, eps99, eps99);
-     ok  &= NearEqual(dw[2], 0.         + num0 * x[1] / dsq, eps99, eps99);
-     ok  &= NearEqual(dw[3], b[0] / den - num0 * x[0] / dsq, eps99, eps99);
-
-     return ok;
-}
-
-
-
Input File: example/general/vec_ad.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_vec_ad.cpp_xml.js cppad-2019.02.00.0/doc/_vec_ad.cpp_xml.js --- cppad-2018.00.00.0/doc/_vec_ad.cpp_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_vec_ad.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'vecad.xml', -'vec_ad.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 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down1 = [ -'vec_ad.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-2018.00.00.0/doc/vecad.xml cppad-2019.02.00.0/doc/vecad.xml --- cppad-2018.00.00.0/doc/vecad.xml 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/vecad.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,616 +0,0 @@ - - - -AD Vectors that Record Index Operations - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

-
AD Vectors that Record Index Operations
-
-Syntax - -
- -VecAD<Basev(n) - -
-
-v.size() - -
-
-b = v[i] - -
-
-r = v[x] - - -
-
-Purpose -
-If either -v - or -x - is a -variable -, -the indexing operation - -
-     
r = v[x]
-
-is recorded in the corresponding -AD of -Base - -operation sequence - and -transferred to the corresponding ADFun - object -f -. -Such an index can change each time -zero order f.Forward - is used; i.e., - -f - is evaluated with new value for the -independent variables -. -Note that the value of -y - depends on the value of -x - -in a discrete fashion and CppAD computes its partial derivative with -respect to -x - as zero. - -
-
-Alternatives -
-If only the values in the vector, -and not the indices, -depend on the independent variables, -the class -Vector< AD<Base> > - is much more efficient for -storing AD values where -Vector - is any -SimpleVector - template class, -If only the indices, -and not the values in the vector, -depend on the independent variables, -The Discrete - functions are a much more efficient -way to represent these vectors. - -
-
-VecAD<Base>::reference -
-The result -r - has type - -
-     VecAD<
Base>::reference
-
-which is very much like the -AD<Base> - type -with some notable exceptions: - -
-
-Exceptions - -
  1. -The object -r - cannot be used with the -Value - function to compute the corresponding -Base - value. -If -v - and -i - are not variables - - -
    -     
    b = v[i]
    -
    -can be used to compute the corresponding -Base - value. - -
  2. - -The object -r - cannot be used -with the compound assignments operators - -+=, --=, -*=, or -/=. -For example, the following syntax is not valid: - -
    -     
    v[x] += z;
    -
    -no matter what the types of -z -. - -
  3. - -Assignment to -r - returns a void. -For example, the following syntax is not valid: - -
    -     
    z = v[x] = u;
    -
    -no matter what the types of -z -, and -u -. - -
  4. - -The CondExp - functions do not accept - -VecAD<Base>::reference - arguments. -For example, the following syntax is not valid: - -
    -     CondExpGt(
    v[x], zuv)
    -
    -no matter what the types of -z -, -u -, and -v -. - -
  5. - -The Parameter and Variable - functions cannot be used with - -VecAD<Base>::reference - arguments like -r -, -use the entire -VecAD<Base> - vector instead; i.e. -v -. - -
  6. - -The vectors passed to Independent - must have elements -of type -AD<Base> -; i.e., VecAD - vectors -cannot be passed to Independent. - -
  7. - -If one uses this type in a -AD of -Base - -operation sequence -, -sparsity pattern - calculations -(sparsity_pattern -) -are less efficient because the dependence of different -elements of the vector cannot be separated. - -
- - -
-
-Constructor - - -
-
-v -
-The syntax - -
-     VecAD<
Basev(n)
-
-creates an VecAD object -v - with - -n - elements. -The initial value of the elements of -v - is unspecified. - -
-
-n -
-The argument -n - has prototype - -
-     size_t 
n
-
-
-size -
-The syntax - -
-     
v.size()
-
-returns the number of elements in the vector -v -; -i.e., the value of -n - when it was constructed. - -
-
-size_t Indexing -
-We refer to the syntax - -
-     
b = v[i]
-
-as size_t indexing of a VecAD object. -This indexing is only valid if the vector -v - is a -parameter -; i.e., -it does not depend on the independent variables. - -
-
-i -
-The operand -i - has prototype - -
-     size_t 
i
-
-It must be greater than or equal zero -and less than -n -; i.e., less than -the number of elements in -v -. - -
-
-b -
-The result -b - has prototype - -
-     
Base b
-
-and is a reference to the i-th element in the vector -v -. -It can be used to change the element value; -for example, - -
-     
v[i] = c
-
-is valid where -c - is a -Base - object. -The reference -b - is no longer valid once the -destructor for -v - is called; for example, -when -v - falls out of scope. - -
-
-AD Indexing -
-We refer to the syntax - -
-     
r = v[x]
-
-as AD indexing of a VecAD object. - -
-
-x -
-The argument -x - has prototype - -
-     const AD<
Base> &x
-
-The value of -x - must be greater than or equal zero -and less than -n -; i.e., less than -the number of elements in -v -. - -
-
-r -
-The result -r - has prototype - -
-     VecAD<
Base>::reference r
-
-The object -r - has an AD type and its -operations are recorded as part of the same -AD of -Base - -operation sequence - as -for -AD<Base> - objects. -It acts as a reference to the -element with index - -floor - -( -x -) - - - in the vector -v - -( - -floor - -( -x -) - - - is -the greatest integer less than or equal -x -). -Because it is a reference, it can be used to change the element value; -for example, - -
-     
v[x] = z
-
-is valid where -z - is an - -VecAD<Base>::reference - object. -As a reference, -r - is no longer valid once the -destructor for -v - is called; for example, -when -v - falls out of scope. - -
-
-Example - -
-The file -vec_ad.cpp - -contains an example and test using VecAD vectors. -It returns true if it succeeds and false otherwise. - - -
-
-Speed and Memory -
-The VecAD - vector type is inefficient because every -time an element of a vector is accessed, a new CppAD -variable - is created on the tape -using either the Ldp or Ldv operation -(unless all of the elements of the vector are -parameters -). -The effect of this can be seen by executing the following steps: - -
  1. -In the file cppad/local/forward1sweep.h, -change the definition of CPPAD_FORWARD1SWEEP_TRACE to -
     
    -     # define CPPAD_FORWARD1SWEEP_TRACE 1
    -
    -
  2. -In the Example directory, execute the command -
     
    -     ./test_one.sh lu_vec_ad_ok.cpp lu_vec_ad.cpp -DNDEBUG > lu_vec_ad_ok.log
    -
    -This will write a trace of all the forward tape operations, -for the test case lu_vec_ad_ok.cpp -, -to the file lu_vec_ad_ok.log. -
  3. - -In the Example directory execute the commands -
     
    -     grep "op="           lu_vec_ad_ok.log | wc -l
    -     grep "op=Ld[vp]"     lu_vec_ad_ok.log | wc -l
    -     grep "op=St[vp][vp]" lu_vec_ad_ok.log | wc -l
    -
    -The first command counts the number of operators in the tracing, -the second counts the number of VecAD load operations, -and the third counts the number of VecAD store operations. -(For CppAD version 05-11-20 these counts were 956, 348, and 118 -respectively.) -
- - - -
Input File: cppad/core/vec_ad.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_vecad_xml.js cppad-2019.02.00.0/doc/_vecad_xml.js --- cppad-2018.00.00.0/doc/_vecad_xml.js 2018-01-01 08:32:43.000000000 +0000 +++ cppad-2019.02.00.0/doc/_vecad_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'ad.xml', -'vecad.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 = [ -'ad_ctor.xml', -'ad_assign.xml', -'convert.xml', -'advalued.xml', -'boolvalued.xml', -'vecad.xml', -'base_require.xml' -]; -var list_down0 = [ -'vec_ad.cpp.xml' -]; -var list_current0 = [ -'vecad.xml#Syntax', -'vecad.xml#Purpose', -'vecad.xml#Alternatives', -'vecad.xml#VecAD<Base>::reference', -'vecad.xml#VecAD<Base>::reference.Exceptions', -'vecad.xml#Constructor', -'vecad.xml#Constructor.v', -'vecad.xml#n', -'vecad.xml#size', -'vecad.xml#size_t Indexing', -'vecad.xml#size_t Indexing.i', -'vecad.xml#size_t Indexing.b', -'vecad.xml#AD Indexing', -'vecad.xml#AD Indexing.x', -'vecad.xml#AD Indexing.r', -'vecad.xml#Example', -'vecad.xml#Speed and Memory' -]; -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-2018.00.00.0/doc/vector_bool.cpp.xml cppad-2019.02.00.0/doc/vector_bool.cpp.xml --- cppad-2018.00.00.0/doc/vector_bool.cpp.xml 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/vector_bool.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,189 +0,0 @@ - - - -CppAD::vectorBool Class: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -vector_bool.cppHeadings

-
CppAD::vectorBool Class: Example and Test
-

-# include <cppad/utility/vector.hpp>
-# include <cppad/utility/check_simple_vector.hpp>
-# include <sstream> // sstream and string are used to test output operation
-# include <string>
-
-bool vectorBool(void)
-{     bool ok = true;
-     using CppAD::vectorBool;
-
-     vectorBool x;          // default constructor
-     ok &= (x.size() == 0);
-
-     x.resize(2);             // resize and set element assignment to bool
-     ok &= (x.size() == 2);
-     x[0] = false;
-     x[1] = true;
-
-     vectorBool y(2);       // sizing constructor
-     ok &= (y.size() == 2);
-
-     const vectorBool z(x); // copy constructor and const element access
-     ok &= (z.size() == 2);
-     ok &= ( (z[0] == false) && (z[1] == true) );
-
-     x[0] = true;           // modify, assignment changes x
-     ok &= (x[0] == true);
-
-     // 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) );
-
-     // test of push_vector
-     y.push_vector(z);
-     ok &= y.size() == 4;
-     ok &= ( (y[0] == false) && (y[1] == true) );
-     ok &= ( (y[2] == false) && (y[3] == true) );
-
-     y[1] = false;           // element assignment to another element
-     x[0] = y[1];
-     ok &= (x[0] == false);
-
-     // test of output
-     std::string        correct= "01";
-     std::string        str;
-     std::ostringstream buf;
-     buf << z;
-     str = buf.str();
-     ok &= (str == correct);
-
-     // test resize(0), capacity, and clear
-     size_t i = x.capacity();
-     ok      &= i > 0;
-     x.resize(0);
-     ok      &= i == x.capacity();
-     x.clear();
-     ok      &= 0 == x.capacity();
-
-     // test of push_back element
-     for(i = 0; i < 100; i++)
-          x.push_back( (i % 3) != 0 );
-     ok &= (x.size() == 100);
-     for(i = 0; i < 100; i++)
-          ok &= ( x[i] == ((i % 3) != 0) );
-
-     // is that boolvector is
-     // a simple vector class with elements of type bool
-     CppAD::CheckSimpleVector< bool, vectorBool >();
-
-     return ok;
-}
-
-
-
Input File: example/utility/vector_bool.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_vector_bool.cpp_xml.js cppad-2019.02.00.0/doc/_vector_bool.cpp_xml.js --- cppad-2018.00.00.0/doc/_vector_bool.cpp_xml.js 2018-01-01 08:32:46.000000000 +0000 +++ cppad-2019.02.00.0/doc/_vector_bool.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'utility.xml', -'cppad_vector.xml', -'vector_bool.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', -'test_boolofvoid.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', -'set_union.xml', -'sparse_rc.xml', -'sparse_rcv.xml' -]; -var list_down1 = [ -'cppad_vector.cpp.xml', -'vector_bool.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-2018.00.00.0/doc/whats_new_03.xml cppad-2019.02.00.0/doc/whats_new_03.xml --- cppad-2018.00.00.0/doc/whats_new_03.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_03.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1242 +0,0 @@ - - - -Changes and Additions to CppAD During 2003 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_03 - -

- - - -
Changes and Additions to CppAD During 2003
-
-Introduction -
-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. - -
-
-12-24 -
-Some references to double should have been references -to the base type - -(in reverse mode and in the Grad/ and Hess functions). -This has been fixed. - -
-
-12-22 -
-The preprocessor symbol WIN32 was being used to determine -if one was using Microsoft's C++ compiler. -This symbol is predefined by the -MinGW - version of the GNU C++ compiler -and hence CppAD had errors during installation using MinGW. -This has been fixed by using the preprocessor symbol -_MSC_VER to determine if -one is using the Microsoft C++ compiler. - - -
-
-12-14 -
-The extended system solvers OdeOne and OdeTwo have -been removed from the distribution. -In addition, the interface to the ODE solvers have been simplified. - -
-
-12-13 -
-Remove the CppADCreateTape macro -and have the tapes created and grow automatically. - - -
-
-12-12 -
-The old method where one directly accesses the tape has been removed and the -following functions are no longer available: - -
-          size_t 
TapeName.Independent(AD<Base> &indvar)
-          size_t 
TapeName.Record(size_t order)
-          size_t 
TapeName.Stop(void)
-          bool Dependent(const AD<
Base> &var) const
-          bool 
TapeName.Dependent(const AD<Base> &var) const
-          size_t 
TapeName.Total(void) const
-          size_t 
TapeName.Required(void) const
-          size_t 
TapeName.Erase(void)
-          TapeState 
TapeName.State(void) const
-          size_t 
TapeName.Order(void) const
-          size_t 
TapeName.Required(void) const
-          bool Parameter(CppADvector< AD<
Base> > &u)
-          
TapeName.Forward(indvar)
-          
TapeName.Reverse(var)
-          
TapeName.Partial(var)
-          
TapeName.ForwardTwo(indvar)
-          
TapeName.ReverseTwo(var)
-          
TapeName.PartialTwo(var)
-
-
-12-10 -
-The change on 12-01 - make the taping process simpler -if one does not directly access -CppADCreateTape. -The examples - were changed to not use - -TapeName -. -The following examples were skipped because -they document the functions that access -TapeName -: -DefFun.cpp, -For.cpp, -for_two.cpp, -Rev.cpp, and -rev_two.cpp. - -
-
-12-05 -
-There was a bug in - -f.Rev - and - -f.RevTwo - and -when two dependent variables were always equal and shared -the same location in the tape. -This has been fixed. -
-
-
The ODE Example was changed to tape the solution -(and not use OdeOne or OdeTwo). -This is simpler to use and -the resulting speed tests gave much faster results. - -
-
-12-01 -
-The following function has been added: - -
-     void Independent(const CppADvector<
Base> &x)
-
-which will declare the independent variables and begin recording - -AD<Base> - operations -(see Independent -). -The ADFun - constructor was modified so that it -stops the recording and erases that tape as well as creates the -ADFun - object. -In addition, the tape no longer needs to be specified in the constructor. - - -
-
-11-21 -
-Add StiffZero to set of ODE solvers. - - -
-
-11-20 -
-The AbsGeq and LeqZero in -LuSolve - were changed to template functions so they could have -default definitions in the case where the <= and >= -operators are defined. -This made the double and AD<double> use of -LuSolve simpler because the user need not worry about these functions. -On the other hand, it made the std::complex -and AD<std::complex> use of -LuSolve more complex. -
-
-
The member function names for the - -fun - argument to ODE were changed from - -fun.f - to - -fun.Ode - -and from - -fun.g - to - -fun.Ode_ini -. - - -
-
-11-16 -
-The -table of contents - was reorganized -to provide a better grouping of the documentation. -
-
-
The LuSolve - utility is now part of the distribution -and not just an example; i.e., -it is automatically included by -cppad.hpp. - - -
-
-11-15 -
-The -ODE solver was modified so that it can -be used with any type (not just an AD type. -This was useful for the speed testing. -It is also useful for determining how the integrator -steps should be before starting the tape. -
-
-
The template argument -Type - was changed to - -Base - where ever it was the -base type - of an AD class. - - -
-
-11-14 -
-An -speed_cppad/OdeSpeed.cpp/ test was added -and some changes were made to the -ODE interface in order to make it faster. -The most significant change was in the specifications for -the ODE function object -fun -. - - -
-
-11-12 -
-The user defined unary function example -example/UnaryFun.cpp was incorrect. -It has been corrected and extended. - -
-
-11-11 -
-The CppAD::vector - template class is now -used where the std::vector template class was previously used. -You can replace the CppAD::vector class -with a vector template class of your choosing during the -Install - procedure. - -
-
-11-06 -
-The documentation for -taping derivative calculations - was improved -as well as the corresponding example. -In order to make this simpler, -the example tape name DoubleTape was changed to ADdoubleTape -(and the other example tape names were also changed). - -
-
-11-04 -
-The ODE utility was changed from an example to -part of the distribution. -In addition, it was extended so that it now supports taping the -solution of the differential equations (case -order - equal zero) -or solving the extended set of differential equations -for both first and second derivatives (cases -order - equal -one and two). -In addition, an initial condition that depends on the parameter -values is also allowed. - - - -
-
-11-02 -
-It is now legal to differentiate a -parameter - -with respect to an -independent variable - -(parameter derivatives are always equal to zero). -This is an extension of the -Reverse, -Partial, -ReverseTwo, and -PartialTwo -functions. - -
-
-10-21 -
-All the CppAD include files, -except cppad.hpp were moved into an include subdirectory. - - - -
-
-10-16 -
-The ADFun - template class was added so that one can save -a tape recording and use it as a differentiable function. -The ADFun functions supports directional derivatives in both -Forward - and Reverse - mode where as the -tape only supports partial derivatives. - -
-
-10-14 -
-The sqrt function was added to the -unary_standard_math - functions. -In addition, a definition of the power function for the types -float and double -was automatically included in the CppAD namespace. -
-
-
The Value - function was changed so that it can -be called when the tape is in the Empty state. - -
-
-10-10 -
-The atan function was added to the -unary_standard_math - functions. - -
-
-10-06 -
-In the notation below, -zero - and -one - -are parameters that are exactly equal to zero and one. -If the variables -z - and -x - -were related in any of the following ways, -they share can share the same record on the tape -because they will have the same derivatives. - -
-     
z = x + zero        z =  x * one
-     
z = zero + x        z =  one * x
-     
z = x - zero        z =  x / one
-
-Furthermore, in the following cases, the result - -z - is a parameter (equal to zero) -and need not be recorded in the tape: - -
-     
z = x * zero        z =  zero / x
-     
z = zero * x
-
-The -arithmetic operators - were -all checked to make sure they did not add to the tape -in these special cases. -The total record count for the program in the Example directory -was 552 before this change -and 458 after. - -
-
-10-05 -
-The process of converting the tape to operators was completed. -In order to make this conversion, the binary user defined -functions were removed. -(Bob Goddard -suggested a very nice way to keep the unary functions.) -Another significant change was made to the user interface during this procedure, -the standard math library functions -are now part of the CppAD distribution and not defined by the user. -
-
-
The function -TapeName.Total - was added -to make it easy to track how many tape records are used by -the test suite. -This will help with future optimization of the CppAD recording process. -
-
-
There was a bug -(found by Mike Dodds -) -in the error checking of the - -TapeName.Erase - function. -If Erase was called twice in a row, -and NDEBUG was false during compilation, -the program would abort. -This has been fixed. - - -
-
-09-30 -
-A process of changing the tape from storing partial derivatives to -storing operators has been started. -This will make the tape smaller and it will enable the computation -of higher derivatives with out having to tape the tape -(see mul_level -). -The Add, Subtract, Multiply and Divide operators have been converted. -The user defined functions are presenting some difficulties, -so this process has not yet been completed. -
-
-
There was a bug in reverse mode when an dependent variable -was exactly equal to an independent variable. -In this case, it was possible for it to be located -before other of the independent variables on the tape. -These other independent variable partials were not initialized -to zero before the reverse calculation and hence had what ever -value was left by the previous mode calculation. -This has been fixed and the -Eq.cpp example has been changed to test for this case. -
-
-
The following tape functions were changed to be declared -const because they do not modify the tape in any way: -State, -Order, -Required, -Dependent, and -Parameter -. - -
-
-09-20 -
-The functions Grad and Hess were -changed to use function objects -instead of function pointers. - - -
-
-09-19 -
-The higher order constructors (in standard valarray) were removed from the -ODE example in order to avoid memory allocation of temporaries -(and hence increase speed). -In addition, the function objects in the -ODE examples were changed to be const. - -
-
-09-18 -
-An ordinary differential equation solver was added. -In addition, -the extended system to differentiate the solution was included. - -
-
-09-15 -
-The linked list of AD variables was not being maintained correctly -by the AD destructor. -This was fixed by have the destructor use RemoveFromVarList -to remove variables from the list. -(RemoveFromVarList is a private AD member function -not visible to the user.) - -
-
-09-14 -
-There is a new Faq question about evaluating derivatives at multiple -values for the -independent variables -. - -
-
-09-13 -
-An example that uses -AD< AD<double> > -to compute higher derivatives was added. -
-
-
The name GaussEliminate was changed to -LuSolve - to better reflect the solution method. - -
-
-09-06 -
-Changed the -get_started.cpp - and complex_poly.cpp - examples -so they use a template function with both base type and AD type arguments. -(The resulting code is simpler and a good use of templates.) - -
-
-09-05 -
-A getting started - -example was added and the organization -of the Examples - was changed. - -
-
-09-04 -
-The AbsOfDoubleNotDefine flag is no longer used -and it was removed from the Windows -install - instructions. -
-
-
The 03-09-03 distribution did not have the proper date -attached to it. -The distribution script has been changed so that attaching -the proper date is automated -(i.e., this should not happen again). -
-
-
A Frequently Asked Questions and Answers section was started. - -
-
-09-03 -
-Added the -Value - function which returns -the base type - value -corresponding to an AD object. - -
-
-08-23 -
-A new version of Cygwin was installed on the development system -(this may affect the timing tests reported in this document). -In addition, LuSolve - was changed to use back substitution -instead of reduction to an identity matrix. This reduced the number -of floating point operations corresponding to evaluation of the determinant. -The following results correspond to the speed test -of DetLu on a 9 by 9 matrix: - -
- -Version - - double Rate - - AD<double> Rate - - Gradient Rate - - Hessian Rate - - Tape Length -
- -03-08-20 - - 8,524 - - 5,278 - - 4,260 - - 2,450 - - 532 -
- -03-08-23 - - 7,869 - - 4,989 - - 4,870 - - 2,637 - - 464 -
-
-08-22 -
-The -unary minus - operator was added to the AD operations. - - -
-
-08-19 -
-The standard math function -examples were extended to include the complex case. -
-
-
The -LuSolve - -routine what changed to use - -std::vector<Base> & - arguments in place of - -Base * - arguments. -This removes the need to use new and delete -with LuSolve. -
-
-
When testing the speed of the change to using standard vector, -it was noticed that the LuSolve routine -was much slower. (see times for 03-08-16 below). -This was do to computing the determinant instead of the log -of the determinant. -Converting back to the log of the determinant regained -the high speeds. -The following results correspond to the speed test -of DetLu on a 9 by 9 matrix: - -
- -Version - - double Rate - - AD<double> Rate - - Gradient Rate - - Hessian Rate - - Tape Length -
- -03-08-16 - - 9,509 - - 5,565 - - 3,587 - - 54 - - 537 -
- -03-08-19 - - 8,655 - - 5,313 - - 4,307 - - 2,495 - - 532 -
-
-08-17 -
-The macro -CppADTapeOverflow was added -so that CppAD can check for tape overflow -even in the NDEBUG preprocessor flag is defined. - -
-
-08-16 -
-The -LuSolve - routine was extended to -handle complex arguments. -Because the complex absolute value function is nowhere differentiable, -this required the allowing for user defined -boolean valued functions with AD arguments -. -The examples -lu_solve.cpp - -and -GradLu.cpp -were converted to a complex case. - - -
-
-08-11 -
-The routine LuSolve - was made more efficient -so that it is more useful as a tool for -differentiating linear algebra calculations. -The following results correspond to the speed test -of DetLu on a 9 by 9 matrix: - -
- -Version - - double Rate - - AD<double> Rate - - Gradient Rate - - Hessian Rate - - Tape Length -
- -03-08-10 - - 49,201 - - 7,787 - - 2,655 - - 1,809 - - 824 -
- -03-08-11 - - 35,178 - - 12,681 - - 4,521 - - 2,541 - - 540 -
-In addition the corresponding test case -lu_solve.cpp - was changed to a Hilbert matrix case. - - - -
-
-08-10 -
-A complex polynomial - -example was added. -
-
-
The documentation and type conversion in -LuSolve - was improved. -
-
-
The absolute value function was removed from the examples because -some systems do not yet properly support -double abs(double x) -, - - -
-
-08-07 -
-Because the change to the multiplication operator had such -a large positive effect, -all of the -arithmetic operators - -were modified to reduce the amount of information -in the tape (where possible). - -
-
-08-06 -
-During Lu factorization, certain elements of the matrix -are know to be zero or one and do not depend on the variables. -The multiplication - operator was modified to take -advantage of this fact. -This reduced the size of the tape and increased the speed -for the calculation of the gradient and Hessian for -the Lu determinant test of a 5 by 5 matrix as follows: - -
- -Version - - Tape Length - - Gradient Rate - - Hessian Rate -
- -03-08-05 - 176 - 11,362 - 1,149
- -03-08-06 - 167 - 12,780 - 10,625 -
-
-08-05 -
-Fixed a mistake in the calculation of the sign of the determinant in -the LuSolve - example. - -
-
-08-04 -
-Added a the compiler flag -
 
-     AbsOfDoubleNotDefined
-
-to the make files so that it could be removed on systems where the -function - -
-     double abs(double 
x)
-
-was defined in math.h. - -
-
-08-03 -
-The -Grad and Hess functions were modified -to handel the case where the function does not depend on -the independent variables. -
-
-
The -LuSolve - example was added to show how -on can differentiate linear algebra calculations. -In addition, it was used to add another set of -speed tests -. -
-
-
The standard Math functions were added both -as examples of defining atomic operations and to support -mathematical operations for the AD<double> case. -
-
-
The << - operator was added to the AD -template class for output to streams. - - -
-
-08-01 -
-The -compound assignment - operators were added -to the AD template class. -
-
-
The name of the Speed/SpeedTest program was changed to -Speed/Speed -. -In addition, Speed/SpeedRun was changed to -Speed/SpeedTest. - - -
-
-07-30 -
-The -assignment - -operator was changed so the it returns a reference to -the target. -This allows for statements of the form - -
-     
x = y = z;
-
-i.e., multiple assignments. - -
-
-07-29 -
-If the -AD copy constructor - constructor or -assignment - operator -used an -independent variable - -for its source value, -the result was also an independent variable. -This has been fixed so that the result is -a dependent variable in these cases. - -
-
-07-26 -
-The -AD<Base> - data structure -was changed to include a doubly linked list of variables. -This enabled the -AD copy constructor - constructor and -assignment - operator -to create multiple references to -the same place in the tape. -This reduced the size of the tape and increased the speed -for the calculation of the gradient and Hessian for -the determinant of a 5 by 5 matrix as follows: - -
- -Version - - Tape Length - - Gradient Rate - - Hessian Rate -
- -03-07-22 - 1668 - 1,363 - 53
- -03-07-26 - 436 - 3,436 - 213 -
-
-07-22 -
-The facility was added so that the user can define -binary functions -together with their derivatives. -(This facility has been removed because it is better to define -binary functions using AD variables.) -
-
-
The Windows version make file directive /I ..\.. -in example\Example.mak and Speed\Speed.mak -was changed to /I .. (as it should have been). - - - -
-
-07-20 -
-The facility was added so that the user can define -unary functions, -together with their derivatives. -For example, the standard math functions such as -exp - -are good candidates for such definitions. -(This feature has been replaced by and the standard math functions -are now part of the AD types, see AD -.) -
-
-
The first Alpha for the Windows -installation - was released. - -
-
-07-18 -
-Computing the determinant of a minor of a matrix -det_of_minor - -was documented as a realistic example using CppAD. - - -
-
-07-16 -
-Fixed some non-standard constructions that caused problems -with the installation on other machines. -
-
-
Compiled and ran the tests under Microsoft Windows. -(The Windows release should not take much more work.) - -
-
-07-14 -
-First Alpha release of CppAD -and is being released under the -Gnu Public License -. -It is intended for use by a Unix system. -A Microsoft release is intended in the near future. - - -
Input File: omh/appendix/whats_new/whats_new_03.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_03_xml.js cppad-2019.02.00.0/doc/_whats_new_03_xml.js --- cppad-2018.00.00.0/doc/_whats_new_03_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_03_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,158 +0,0 @@ -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_03.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_03.xml#Introduction', -'whats_new_03.xml#12-24', -'whats_new_03.xml#12-22', -'whats_new_03.xml#12-14', -'whats_new_03.xml#12-13', -'whats_new_03.xml#12-12', -'whats_new_03.xml#12-10', -'whats_new_03.xml#12-05', -'whats_new_03.xml#12-01', -'whats_new_03.xml#11-21', -'whats_new_03.xml#11-20', -'whats_new_03.xml#11-16', -'whats_new_03.xml#11-15', -'whats_new_03.xml#11-14', -'whats_new_03.xml#11-12', -'whats_new_03.xml#11-11', -'whats_new_03.xml#11-06', -'whats_new_03.xml#11-04', -'whats_new_03.xml#11-02', -'whats_new_03.xml#10-21', -'whats_new_03.xml#10-16', -'whats_new_03.xml#10-14', -'whats_new_03.xml#10-10', -'whats_new_03.xml#10-06', -'whats_new_03.xml#10-05', -'whats_new_03.xml#09-30', -'whats_new_03.xml#09-20', -'whats_new_03.xml#09-19', -'whats_new_03.xml#09-18', -'whats_new_03.xml#09-15', -'whats_new_03.xml#09-14', -'whats_new_03.xml#09-13', -'whats_new_03.xml#09-06', -'whats_new_03.xml#09-05', -'whats_new_03.xml#09-04', -'whats_new_03.xml#09-03', -'whats_new_03.xml#08-23', -'whats_new_03.xml#08-22', -'whats_new_03.xml#08-19', -'whats_new_03.xml#08-17', -'whats_new_03.xml#08-16', -'whats_new_03.xml#08-11', -'whats_new_03.xml#08-10', -'whats_new_03.xml#08-07', -'whats_new_03.xml#08-06', -'whats_new_03.xml#08-05', -'whats_new_03.xml#08-04', -'whats_new_03.xml#08-03', -'whats_new_03.xml#08-01', -'whats_new_03.xml#07-30', -'whats_new_03.xml#07-29', -'whats_new_03.xml#07-26', -'whats_new_03.xml#07-22', -'whats_new_03.xml#07-20', -'whats_new_03.xml#07-18', -'whats_new_03.xml#07-16', -'whats_new_03.xml#07-14' -]; -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-2018.00.00.0/doc/whats_new_04.xml cppad-2019.02.00.0/doc/whats_new_04.xml --- cppad-2018.00.00.0/doc/whats_new_04.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_04.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1704 +0,0 @@ - - - -Changes and Additions to CppAD During 2004 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_04 - -

- - - -
Changes and Additions to CppAD During 2004
-
-Introduction -
-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 -assist you in learning about changes between various versions. - - -
-
-12-11 -
-The documentation for the CppAD error macros was improved. -The package title in cppad - was changed. -The documentation for CppAD::vector - -was improved and the corresponding source code -cppad/vector.hpp was included. - -
-
-12-09 -
-The LuSolve - and OdeRunge source code -was modified to make the more in line with the introduction -to C++ AD book -(OdeRunge has been replaced by Runge45 -). -In addition, the examples OdeRunge.cpp and -lu_solve.cpp - were modified to make the simpler. -(The more complex version of OdeRunge.cpp -was moved to the TestMore directory.) - -
-
-12-03 -
-The Poly - documentation and source code were modified to -make them more in line with the introduction to C++ AD book. - -
-
-11-17 -
-Changing to Autoconf and Automake on -08-24 - mistakenly forgot -the -Wall compiler switch (all warnings). -This has been added and the corresponding warnings -have been fixed. - -
-
-11-16 -
-The 11-15 Debug version would not compile under Visual C++ version 7.0 -because a declaration of LessThanOrZero was missing. -This has been fixed. - -
-
-11-15 -
-The ForOne - and RevOne - -easy to use drivers - were added. - -
-
-11-14 -
-The notation in the ADFun - sections was changed -to make the Forward - and Reverse - routines -easier to use. - - -
-
-11-13 -
-The Taylor coefficient vector and matrix notation was folded into -just Taylor coefficients -. - -
-
-11-12 -
-If NDEBUG is not defined during compile time, -all -AD<Base> - -comparison - operations are checked during -zero order - forward mode calculations. -The -CompareChange - function -returns the number of comparison operations that have changed. - -
-
-11-10 -
-The get_started.cpp - example was changed to use the -Jacobian - driver. -In addition, more index - entries, -that point to the easy to use drivers -, -were added. - -
-
-11-04 -
-The Microsoft Visual Studio -project file example/Example.dsp/ was missing some -new examples that needed to be linked in -the install windows procedure. -This has been fixed. - -
-
-11-02 -
-The unix installation - required the user -to touch the files to get the dates in proper order. -This is no longer necessary. - -
-
-11-01 -
-Some of the dependency directories and files, for example -PrintFor/.deps and -PrintFor/.deps/PrintFor.Po had an extra ? -at the end of their names. -This seems to have been fixed by using a newer version of the autoconf -and automake tools. - -
-
-10-29 -
-Add the example and test simple_vector.cpp - -to the SimpleVector - documentation. -
-
-
The specifications for -preprocessor symbols - -state that all the CppAD preprocessor symbols -begin with CppAD -(so they do not conflict with other packages). -Some preprocessor symbols in the file cppad/config.h did -began with WITH_. -This has been fixed. - -
-
-10-28 -
-The examples -hes_lu_det.cpp -, -hes_minor_det.cpp -, -jac_lu_det.cpp -, -and -jac_minor_det.cpp - used the negative of a size_t value. -The value has been changed to an int. -
-
-
The CppAD::vector - template class -was converted into a library routine so it can be used -separately from the rest of CppAD. - -
-
-10-27 -
-The PrintFor - example was moved to its own directory -because the conversion from VC 6.0 to VC 7.0 projects -did not work when there were multiple executables in one project file. -The install - instructions were modified to reflect this change. - -
-
-10-21 -
-One declaration (for the Value - function) was missing -from the file cppad/local/Declare.h. -This has been added and CppAD should now compile and run -under both Microsoft VC 6.0 and 7.0. - -
-
-10-19 -
-The current version of CppAD has a problem compiling under Microsoft -Visual C++ version 7.0 (it compiles and works under version 6.0). -The problem appears to be due to a closer agreement between VC 7.0 and the -C++ standard for declaring templates functions as friends. -Some friend declarations were removed and others were made more specific -in order to migrate the a version that will compile and run using VC 7.0. - -
-
-10-16 -
-The example compare.cpp - displayed the text from -bool_fun.cpp - by mistake. -This has been fixed. -
-
-
The Compare - operators have been extended to work with -int operands. - -
-
-10-06 -
-The test -TapeDetLu was added to speed_cppad/DetLuSpeed.cpp -and -TapeDetMinor was added to 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 -from the derivative calculation time. -
-
-
The -windows installation steps -do not build a config.h file. -Hence a default config.h file was added to the -distribution for use with Microsoft Visual Studio. -
-
-
The Distribute section of the -developer documentation was brought up to date. -
-
-
Links to the ADOLC and FADBAD download pages were added -to the unix installation - instructions. - -
-
-09-29 -
-The include files for the utilities - are now included -by the root file cppad/cppad.hpp. -They can still be included individually with out the rest of -the CppAD package. - -
-
-09-26 -
-The routine OdeRunge was modified -so that it will now integrate functions of a complex arguments. -This was done by removing -all uses of greater than and less than comparisons were removed. -(OdeRunge has been replaced by Runge45 -). -
-
-
The changes on 09-21 - did not fix all -the file date and time problems; i.e., automake was still running -in response to the unix installation - -make command. - - -
-
-09-23 -
-There was a reference to -B - that should have been -X - -in the description of the -X - argument of LuSolve. -This has been fixed. - -
-
-09-21 -
-The CondExp - function has been modified so that it works properly -for -AD< AD<Base> > - types; i.e., -it now works for multiple levels of taping. -
-
-
The date of the files aclocal.m4 and config.h.in -were later than the date of top level Makefile.am. -This caused the make command during the -unix installation - -to try to run autoconf -and this did not work on systems with very old versions of autoconf. -This has been fixed. - - -
-
-09-13 -
-The examples that are specific to an operation were moved -to be below that operation in the documentation tree. -For example -add.cpp - is below ad_binary - -in the documentation tree. - -
-
-09-10 -
-The version released on 04-09-09 did not have the -new file PrintFor.h in cppad/local. -This has been fixed. -
-
-
The -Base - type requirements were simplified. -
-
-
The Unix installation - 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). - -
-
-09-09 -
-The PrintFor - function was added so that -users can debug the computation of function values -at arguments that are different from those used when taping. - -
-
-09-07 -
-In the Unix installation - instructions -place ./ in front of current directory program names; for example, -./GetStarted instead of GetStarted -(because some unix systems do not have the current directory -in the default executable path). - - -
-
-09-04 -
-A library containing the -SpeedTest - and NearEqual - object files -was added to the distribution. -
-
-
All of the include files of the form - -<cppad/library/name.h> - were moved to - -<cppad/name.h> -. - -
-
-09-02 -
-Some more messages were added to the output of configure -during the Unix installation -. -
-
-
The suggested compression program during -Windows installation -was changed from -7-zip - -to -WinZip -. - - -
-
-08-27 -
-The error messages printed by the default version of -the CppAD error macros had YY-MM-DD in place of the -date for the current version. -This has been fixed. -
-
-
All the correctness tests are now compiled with the -g -command line option -(the speed tests are still compiled with -O2 -DNDEBUG). -
-
-
The installation instructions - for -Unix and Windows were split into separate pages. - -
-
-08-25 -
-The installation - now automates the replacement -of CppAD::vector - by -either the std::vector -or boost::numeric::ublas::vector. - -
-
-08-24 -
-This date marks the first release that uses -the Gnu tools Autoconf and Automake. -This automates the building of the make files for the -installation - and is the standard -way to distribute open source software. -This caused some organizational changes, -for example, the GetStarted - example now -has its own directory and -the distribution directory is named - -
-     cppad-
yy-mm-dd
-
-where -yy-mm-dd - is the year, month and date -of the distribution. -(Note the distribution directory is different from the directory -where CppAD is finally installed.) - - -
-
-08-12 -
-Move OdeExplicit into the cppad/library/ directory. -In addition, change it so that the vector type was a template argument; i.e., -works for any type of vector (not just CppADvector). - -
-
-07-31 -
-Move LuSolve - into the cppad/library/ directory. -In addition, change it so that the vector type was a template argument; i.e., -works for any type of vector (not just CppADvector). - - -
-
-07-08 -
-The file cppad/example/NearEqual.h has been moved -to cppad/example/NearEqualExt.h because it contains -extensions of the NearEqual - routine to AD types. - -
-
-07-07 -
-The double and std::complex<double> -cases for the NearEqual - routine arguments -has been moved to the general purpose utilities -. - -
-
-07-03 -
-The CppAD error macros names -CppADExternalAssert and CppADInternalAssert -were changed to -CppADUsageError and CppADUnknownError. -The SpeedTest - routine was changed to use CppADUsageError -instead of a C assert. - -
-
-07-02 -
-The SpeedTest - output was improved so that the columns of -values line up. Previously, this was not the case when -the number of digits in the size changed. - -
-
-06-29 -
-Added code to trap and report memory allocation errors during -new operations. - -
-
-06-25 -
-A discussion of the order dependence of the -assignment - operator -and the -independent function - -was added to the -Faq -. -In addition, -a similar discussion -was added to the documentation for the -Independent - function. -
-
-
The definition of a -parameter - -and -variable - -were changed to reflect that fact that -these are time dependent (current) properties -of an -AD<Base> - object. - - -
-
-06-12 -
-All of the -arithmetic operators - -(except for the unary operators) -can now accept int arguments. -The documentation for these arguments has been changed to reflect this. -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 -cppad/Test directory. - - -
-
-06-04 -
-The atan2 - function was added. - -
-
-06-03 -
-The asin and acos -unary_standard_math - functions were added. -
-
-
There was a bug the reverse mode theory and calculation of -derivatives of sqrt - for fourth and higher orders. -This has been fixed. -In addition, -the following examples have been changed -so that they test derivative up to fifth order: -asin -, -atan -, -cos -, -exp -, -log -, -sin -, -sqrt -. - - -
-
-06-01 -
-There was a bug in the atan - function -forward mode - calculations for Taylor coefficient -orders greater than two. -This has been fixed. - -
-
-05-30 -
-The sin - and cos - examples were -changed so that they tested higher order derivatives. - - -
-
-05-29 -
-The forward mode recursion formulas for each of the -standard math functions - -has been split into separate sections. -
-
-
A roman (instead of italic) font was used for the name of -for the name of each of the standard math functions -in the assumption statements below the section -for the standard math functions. -For example, - -sin -( -x -) - - - instead of - -sin -( -x -) - - -. - - -
-
-05-26 -
-In the documentation for Poly -, -the reference to example/Poly.h -was corrected to cppad/library/Poly.h. -
-
-
In the documentation for SpeedTest -, -the reference to Lib/SpeedTest.h -was corrected to cppad/library/SpeedTest.h. -In addition, the example case was corrected. -
-
-
In Reverse -, the definition for - -U -( -t -, -u -) - - - had - - -t -p - --1 - - - where it should have had - -t -p --1 - - - - -. -This has been fixed. - - -
-
-05-25 -
-The special case where the second argument to the pow - function is an -int has been added. - -
-
-05-14 -
-Change all of the include syntax - -
-     # include "
filename"
-
-to the syntax - -
-     # include <
filename>
-
-so that examples and other use better reflect how one would use CppAD after -it was installed in a standard include directory; for example -/usr/local/include/cppad. -
-
-
The user documentation was moved from the directory -cppad/User to the directory cppad/Doc. -
-
-
The directory cppad/Lib was moved to cppad/library -to reflect that fact that it is not what one expects in a standard -lib directory or a standard include directory. - - -
-
-05-12 -
-The string YY-MM-DD in the preprocessor symbol CppADVersion -was not being replaced by the current date during distribution. -This resulted in the CppADExternalAssert macro printing -YY-MM-DD where is should have printed the date of distribution. -This has been fixed. -
-
-
All of the include commands of the form - -
-     # include "include/
name.h"
-     # include "lib/
name.h"
-
-have been changed to the form - -
-     # include "cppad/include/
name.h"
-     # include "cppad/lib/
name.h"
-
-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 -CppAD directory be searched by the compiler. -For example, -if CppAD is in /usr/local/cppad, -you must specify that /usr/local be searched by the compiler. -Note that if /usr/local/cppad/ is no longer searched, -you will have to change -
 
-     # include "cppad.hpp"
-
-to -
 
-     # include "cppad/cppad.hpp"
-
-. -
-
-
The window nmake file Speed/Speed.mak was out of date. -This has been fixed. - -
-
-05-09 -
-Move Poly - and SpeedTest - into the -cppad/Lib directory and the CppAD namespace. - - -
-
-05-07 -
-The divide operator tests - were extended to -include a second order derivative calculation using reverse mode. -
-
-
The Poly - routine was modified to be more efficient in the -derivative case. In addition, it was changed to use an arbitrary -vector for the coefficients (not just a CppADvector). - - -
-
-05-04 -
-A reloading of the data base -caused the files include/atan.h and include/cos.h to be -mistakenly started with lower case letters. -These have been moved to include/Atan.h and include/Cos.h -respectively. - -
-
-05-03 -
-The Reverse - mode calculations for -conditional expressions - were mistakenly left out. -This has been fixed. - -
-
-04-29 -
-The unary functions, such as sin - and cos -, -were not defined for elements of an VecAD - vector. -This has been fixed. - - -
-
-04-28 -
-The operator << - was added to the -default test_vector - template class. -
-
-
A FADBAD correctness and speed comparison with CppAD -was added. - -
-
-04-25 -
-Factor out common sub-expressions in order to make -lu_vec_ad.cpp - faster. -
-
-
Convert description -from C++ Automatic Differentiation to C++ Algorithmic Differentiation. - -
-
-04-24 -
-The VecAD - element class is no longer -a derived class of the AD - class. -This enabled a decrease in tape memory -and an increase in the speed for VecAD - operations. -
-
-
The log10 - function was added. - - -
-
-04-22 -
-Add CondExp - and use it to speed up lu_vec_ad.cpp -. - -
-
-04-21 -
-Use abs - to speed up lu_vec_ad.cpp -. - -
-
-04-20 -
-The absolute value - function was added. -
-
-
The value -n - for -OdeExplicit and OdeImplicit -is deduced from the argument -x0 - and is not passed -as a separate argument. -This documentation has been fixed to this effect. - - - -
-
-04-19 -
-The += - operator did not function correctly -when the left hand operand was a -parameter - -and the right hand operand was a variable -(found by Mike Dodds -). -This has been fixed. - - -
-
-04-09 -
-Adding special operators for using parameters to index VecAD objects -increased the speed and reduced the memory requirements (by about 20%) for -the VecAD - case in the speed_cppad/LuSolveSpeed.cpp/ test. -
-
-
The VecAD - objects are not being handled correctly by the -Reverse - function. -The VecAD test was extended to demonstrate the problem -and the problem was fixed -(it is now part of TestMore/VecAD). - -
-
-04-08 -
-The example lu_vec_ad_ok.cpp - -uses VecAD - to executes different pivoting operations -during the solution of linear equations with out having to retape. -
-
-
The speed test speed_cppad/LuSolveSpeed.cpp/ has been added. -It shows that the initial implementation of VecAD - is slow -(and uses a lot of memory.) -In fact, -it is faster to use LuSolve - and retape for each set of equations -than it is to use lu_vec_ad.cpp - and not have to retape. -This test will help us improve the speed of lu_vec_ad.cpp -. - - -
-
-04-07 -
-There were bugs in the assignment to VecAD - elements -during taping that have been fixed. -In addition, an example of tapping the pivoting operations in -an Lu factorization - has been added. - -
-
-04-03 -
-Added size_t indexing to the VecAD - class. -
-
-
Fixed a bug connected to the VecAD - class and erasing the tape. - -
-
-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 -AD< AD<Base> > - class had values that were variables in the - -AD<Base> - class. -This has been fixed. - -
-
-04-01 -
-The name of the class that tapes indexing operations -was changed from ADVec to VecAD -. -This class was extended so that -the value of elements in these vectors can be variables -(need not be parameters -). - -
-
-03-30 -
-Do some simple searching of the parameter table during taping -avoid multiple copies of parameters on tape (use less tape memory). - - -
-
-03-28 -
-The version ADVec -, -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 -parameters -. - - - -
-
-03-25 -
-The internal taping structure has been changed to have variable length -instructions. -This is to save memory on the tape. -In addition, it may help in the implementation of the -vector class that tracks indexing. -(A now functioning version of this class is described in -VecAD -.) - - -
-
-03-18 -
-A change was made to the way parameter values are stored on the tape. -This resulted in a significant savings in the amount of memory required. - - -
-
-03-17 -
-Change the return type for SpeedTest - from const char * -to std::string. -The memory required for the largest test cases was added to the -speed_cppad - tests output. - -
-
-03-15 -
-The comparison between ADOLC and CppAD for -the DetLuADOLC.cpp/ example was returning an error -(because it was checking for exact equality of calculated derivatives -instead of nearly equal). -This has been fixed. - -
-
-03-12 -
-The user defined unary functions were removed and -the user defined discrete functions - were -added. -These discrete functions add the capability of conditional expressions -(alternate calculations) -being included in an ADFun - object. - -
-
-03-11 -
-The classes det_by_minor - and det_by_lu - were added -and used these to simplify the -examples that compute determinants. - -
-
-03-09 -
-The routines Grad and Hess have been removed. -You should use Jacobian - and Hessian - instead. - - -
-
-03-07 -
-The driver routines Hessian - and RevTwo - has been added. -These to compute specialized subsets of the second order partials. -
-
-
Documentation errors in ForTwo - and Reverse - were fixed. -The example - documentation was reorganized. - - -
-
-03-06 -
-The driver ForTwo - has been added. -It uses forward mode to compute a subset of the second order partials. -
-
-
Split all of the "example" and "test" index entries that come from - -cppad/example/*.cpp - -into sorted subheadings. - -
-
-03-05 -
-The Grad routine, -which only computed first derivatives of scalar valued functions, -has been replaced by the Jacobian - routine which -computes the derivative of vector valued functions. - -
-
-03-04 -
-The bug reported on 02-17 - was present in all -the operators. These have all been fixed and tests for all the operators -have been added to the cppad/Test directory. -
-
-
The f.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. -This helps when deciding whether to use forward or reverse mode. - -
-
-03-03 -
-Special operators were added to distinguish the cases where -one of the operands is a -parameter -. -This reduced the amount of branching that is necessary -when executing Forward - and Reverse - calculations. -
-
-
The Independent - and Parameter - functions -were moved below ADFun - in the documentation. - - -
-
-03-01 -
-The DetLuADOLC.cpp, DetLu case was added to the ADOLC -comparison tests. - -
-
-02-29 -
-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 -when debugging was turned off. This has been fixed. - - -
-
-02-28 -
-A set of routines for comparing CppAD with -ADOLC has been added to the distribution. -In addition, documentation for compiling and linking the -Examples - and Speed Tests - -has been added. - -
-
-02-21 -
-If you use the user defined unary atomic functions -there is a restriction on the order of the derivatives that can be calculated. -This restriction was documented in the user defined unary function -Forward - -and Reverse -. -(These unary functions were removed on 03-12 -.) - -
-
-02-20 -
-A user interface to arbitrary order -reverse mode - calculations was implemented. -In addition, the ADFun - member functions -Rev and RevTwo were removed -because it is easier to use the uniform syntax below: - -
- -Old Syntax - Uniform Syntax -
- - -r1 = f.Rev(v) - - -r1 = f.Reverse(1, v) - -
- - -q1 = f.RevTwo(v) - - -r2 = f.Reverse(2, v) - -
- - - -q1[i] == r2[2 * i + 1] - -
-
-
-
The 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 -04-02-15 -. -
-
-
The directory cppad/Test has been added. -It contains tests cases that are not intended as examples. - -
-
-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 -parameter on an -AD< AD<Base> > - tape and a its value -might be a variable on the - -AD<Base> - tape. -This bug in the multiply and divide routines has been fixed. -
-
-
There was a bug that is some cases reported a divide by zero error -when the numerator was zero. This has been fixed. - - -
-
-02-16 -
-A bug in Forward - prevented the calculation of derivatives -with higher order than two. -In addition, this checking for user errors in the use of Forward -was also faulty. -This has been fixed. -
-
-
The Microsoft project file example\Example.dsp -was out of date. This has been fixed. -
-
-
The example that tapes derivative calculations - -has been changed to an application of -Taylor's method - for solving ordinary differential -equations. - -
-
-02-15 -
-A user interface to arbitrary order -forward mode - calculations was implemented. -In addition, the ADFun - member functions -Arg, For and ForTwo were removed -because it is easier to use the uniform syntax below: - -
- -Old Syntax - Uniform Syntax -
- - -v0 = f.Arg(u0) - - -v0 = f.Forward(0, u0) - -
- - -v1 = f.For(u1) - - -v1 = f.Forward(1, u1) - -
- - -v2 = f.For(u2) - - -v2 = f.Forward(1, u2) - -
-
-02-12 -
-All of the derivative calculations are now done using arbitrary -order Taylor arithmetic routines. -The Theory - section was changed to document this method -of calculation. - - -
-
-02-01 -
-The definition of a -Taylor coefficient - -was changed to include the factorial factor. -This change was also made to the output specifications for the -FunForTwo routine. - -
-
-01-29 -
-There were some bugs in the FunArg function -that were fixed. -
  1. -If one of the dependent variables was a -parameter - -FunArg did not set it's value properly. -(All its derivatives are zero and this was handled properly.) -
  2. - -The user defined unary functions were not -computed correctly. -
- - -The specifications for the usage and unknown CppAD error macros -were modified so that they could be used with out side effects. - -
-
-01-28 -
-Some corrections and improvements were made to the documentation including: -CppADvector was placed before its use, -a reference to Ode_ind and Ode_dep was fixed in -OdeImplicit. - -
-
-01-22 -
-The specifications for the routine FunForTwo -was changed to use -Taylor coefficients -. -This makes the interface to CppAD closer to the interface for -ADOLC -. - - - - - -
Input File: omh/appendix/whats_new/whats_new_04.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_04_xml.js cppad-2019.02.00.0/doc/_whats_new_04_xml.js --- cppad-2018.00.00.0/doc/_whats_new_04_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_04_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,198 +0,0 @@ -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_04.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_04.xml#Introduction', -'whats_new_04.xml#12-11', -'whats_new_04.xml#12-09', -'whats_new_04.xml#12-03', -'whats_new_04.xml#11-17', -'whats_new_04.xml#11-16', -'whats_new_04.xml#11-15', -'whats_new_04.xml#11-14', -'whats_new_04.xml#11-13', -'whats_new_04.xml#11-12', -'whats_new_04.xml#11-10', -'whats_new_04.xml#11-04', -'whats_new_04.xml#11-02', -'whats_new_04.xml#11-01', -'whats_new_04.xml#10-29', -'whats_new_04.xml#10-28', -'whats_new_04.xml#10-27', -'whats_new_04.xml#10-21', -'whats_new_04.xml#10-19', -'whats_new_04.xml#10-16', -'whats_new_04.xml#10-06', -'whats_new_04.xml#09-29', -'whats_new_04.xml#09-26', -'whats_new_04.xml#09-23', -'whats_new_04.xml#09-21', -'whats_new_04.xml#09-13', -'whats_new_04.xml#09-10', -'whats_new_04.xml#09-09', -'whats_new_04.xml#09-07', -'whats_new_04.xml#09-04', -'whats_new_04.xml#09-02', -'whats_new_04.xml#08-27', -'whats_new_04.xml#08-25', -'whats_new_04.xml#08-24', -'whats_new_04.xml#08-12', -'whats_new_04.xml#07-31', -'whats_new_04.xml#07-08', -'whats_new_04.xml#07-07', -'whats_new_04.xml#07-03', -'whats_new_04.xml#07-02', -'whats_new_04.xml#06-29', -'whats_new_04.xml#06-25', -'whats_new_04.xml#06-12', -'whats_new_04.xml#06-04', -'whats_new_04.xml#06-03', -'whats_new_04.xml#06-01', -'whats_new_04.xml#05-30', -'whats_new_04.xml#05-29', -'whats_new_04.xml#05-26', -'whats_new_04.xml#05-25', -'whats_new_04.xml#05-14', -'whats_new_04.xml#05-12', -'whats_new_04.xml#05-09', -'whats_new_04.xml#05-07', -'whats_new_04.xml#05-04', -'whats_new_04.xml#05-03', -'whats_new_04.xml#04-29', -'whats_new_04.xml#04-28', -'whats_new_04.xml#04-25', -'whats_new_04.xml#04-24', -'whats_new_04.xml#04-22', -'whats_new_04.xml#04-21', -'whats_new_04.xml#04-20', -'whats_new_04.xml#04-19', -'whats_new_04.xml#04-09', -'whats_new_04.xml#04-08', -'whats_new_04.xml#04-07', -'whats_new_04.xml#04-03', -'whats_new_04.xml#04-02', -'whats_new_04.xml#04-01', -'whats_new_04.xml#03-30', -'whats_new_04.xml#03-28', -'whats_new_04.xml#03-25', -'whats_new_04.xml#03-18', -'whats_new_04.xml#03-17', -'whats_new_04.xml#03-15', -'whats_new_04.xml#03-12', -'whats_new_04.xml#03-11', -'whats_new_04.xml#03-09', -'whats_new_04.xml#03-07', -'whats_new_04.xml#03-06', -'whats_new_04.xml#03-05', -'whats_new_04.xml#03-04', -'whats_new_04.xml#03-03', -'whats_new_04.xml#03-01', -'whats_new_04.xml#02-29', -'whats_new_04.xml#02-28', -'whats_new_04.xml#02-21', -'whats_new_04.xml#02-20', -'whats_new_04.xml#02-17', -'whats_new_04.xml#02-16', -'whats_new_04.xml#02-15', -'whats_new_04.xml#02-12', -'whats_new_04.xml#02-01', -'whats_new_04.xml#01-29', -'whats_new_04.xml#01-28', -'whats_new_04.xml#01-22' -]; -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-2018.00.00.0/doc/whats_new_05.xml cppad-2019.02.00.0/doc/whats_new_05.xml --- cppad-2018.00.00.0/doc/whats_new_05.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_05.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1496 +0,0 @@ - - - -Changes and Additions to CppAD During 2005 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_05 - -

- - - -
Changes and Additions to CppAD During 2005
-
-12-24 -
-Fix a memory leak that could occur during the ForSparseJac - -calculations. - -
-
-12-23 -
-The buffers that are used to do -RevSparseJac - and RevSparseHes - -calculations are now freed directly after use. -
-
-
The TrackNewDel.cpp - example was missing from the Windows install -examples and testing -project file. -This has been fixed. - -
-
-12-22 -
-The buffer that is are used to do -Reverse - mode -calculations is now freed directly after use. -This reduces the memory requirements attached to an ADFun - object. - -
-
-12-20 -
-Buffers that are used to store the tape information corresponding to -the -AD<Base> - type are now freed when the corresponding -ADFun - object is constructed. -This reduces memory requirements and actually had better results -with the speed_cppad - tests. -
-
-
The speed_cppad - test program now outputs the version of CppAD -at the top (to help when comparing output between different versions). - - -
-
-12-19 -
-The TrackNewDel - routines were added for track memory allocation -and deletion with new[] and delete[]. -This is in preparation for making CppAD more efficient in it's use of -memory. -The bug mentioned on 12-01 - resurfaced -and the corresponding routine was changed as follows: -
 
-     static local::ADTape<Base> *Tape(void)
-     {    // If we return &tape, instead of creating and returning ptr,
-          // there seems to be a bug in g++ with -O2 option.
-          static local::ADTape<Base> tape;
-          static local::ADTape<Base> *ptr = &tape;
-          return ptr;
-     }
-
-
-12-16 -
-The NearEqual - function documentation for the relative error case -was changed to - -
-     | 
x - y | <= r * ( |x| + |y| )
-
-so that there is no problem with division by zero when - -x - and -y - are zero -(the code was changed to that form also). -The std::abs function replaced the -direct computation of the complex norms -(for the complex case in NearEqual). -In addition, more extensive testing was done in near_equal.cpp -. - - - -
-
-12-15 -
-Extend NearEqual - and NearEqualExt - -to cover more cases while converting them from, -a library function in lib/CppADlib.a -and an utility in example/NearEqualExt.h, -to a template functions in -cppad/near_equal.hpp and -cppad/local/NearEqualExt.h. -This is another step along the way of removing -the entire CppADlib.a library. -
-
-
The change on 12-14 - broke the -Microsoft project files example/Example.sln -and TestMore/TestMore.sln used during CppAD -installation on Windows. -This has been fixed. -
-
-
Move lib/SpeedTest.cpp to 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 CppADlib.a. -The corresponding entry has been removed from the wish_list -. -
-
-
One of the entries in the wish_list - corresponded to the -Integer - function. -It has also been removed (because it is already implemented). - - - -
-
-12-14 -
-Extend erf - to cover more cases while converting it -from a function in lib/CppADlib.a -to a template function in cppad/local/Erf.h. -This is one step along the way of removing -the entire CppADlib.a library. - - -
-
-12-11 -
-Group routines that extend the domain for which an ADFun - -object is useful into the ExtendDomain section. -
-
-
Add an example of a C callable routine that computes -derivatives using CppAD (see interface2c.cpp -). - -
-
-12-08 -
-Split out LuFactor - with the -ratio - argument -to a separate function called LuRatio -. -This needed to be done because LuRatio - is more restrictive -and should not be part of the general template utilities -. - -
-
-12-07 -
-Improve CheckSimpleVector - so that it tests element assignment. -Change 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 -void. - - -
-
-12-06 -
-The specifications for a SimpleVector - template class -were extended so that the return type of an element access is -not necessarily the same as the type of the elements. -This enables us to include std::vector<bool> -which packs multiple elements into a single storage location -and returns a special type on element access (not the same as bool). -To be more specific, -if -x - is a std::vector<bool> object -and -i - has type size_t, - -x[i] - does not have type bool. -
-
-
Add a Home icon, -that links to the -CppAD home page -, -to the top left of the navigation frame -(left frame) for each documentation section. - -
-
-12-05 -
-The RevSparseHes - reverse mode Hessian sparsity calculation -has been added. -
-
-
The definition of a sparsity pattern - -has been corrected to properly correspond to the more efficient form -mentioned under whats_new_05 - below. -
-
-
The dates in this file used to correspond to -local time for when the change was checked -into the -subversion repository -. -From now on the dates in this file will correspond to the first -version of CppAD where the change appears; i.e., the date in the -unix and windows -download file names -CppAD-yy-mm-dd -. - - -
-
-12-03 -
-There was a bug in the RevSparseJac - -reverse mode sparsity patterns when used with VecAD - calculations. -This bug was fixed and the calculations were made more efficient -(fewer true entries). - - -
-
-12-02 -
-There was a bug in the ForSparseJac - -forward mode sparsity patterns when used with VecAD - calculations. -This bug was fixed and the calculations were made more efficient -(fewer true entries). - - -
-
-12-01 -
-The speed test of 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 -
 
-     static local::ADTape<Base> *Tape(void)
-     {    static local::ADTape<Base> tape;
-          return &tape;
-     }
-
-(in cppad/local/AD.h) -would sometimes return a null value (during VecAD - operations). -A speed improvement in -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. -
-
-
The source code for -lu_vec_ad_ok.cpp - was mistakenly used for -speed_cppad/LuSolveSpeed.cpp. -This has been fixed. - - - -
-
-11-23 -
-The speed test of lu_vec_ad.cpp - has been commented out -because it sometimes generates a segmentation fault. -Here is an explanation: -
-
-
If -X - is a -AD<Base> - object, - -y - is a -Base - object, - -X[y] - uses pointer from the element -back to the original vector. -Optimizing compilers might reorder operations so that -the vector is destroyed before the object is used. -This can be avoided by changing the syntax for VecAD - objects -to use set and get member functions. - - -
-
-11-22 -
-A much better example - for using VecAD - -vectors has been provided. In addition, a bug -in the computation of derivatives using VecAD vectors -has been fixed. -
-
-
CppAD now checks that the domain dimension during -Independent - and -the range dimension during ADFun - -(provided that -DNDEBUG is not defined). -If either of these is zero, -the CppADUsageError macro is invoked. - - -
-
-11-20 -
-The sparsity pattern routines -ForSparseJac - and RevSparseJac - -have been modified so that they are relative -to the Jacobian at a single argument value. -This enables us to return more efficient -sparsity patterns -. -
-
-
An extra exception - has been -added to the use of VecAD - elements. -This makes VecAD some what more efficient. - -
-
-11-19 -
-Improve the output messages generated during execution of the -configure - command. -
-
-
Put a try and catch block around all of the uses of -new so that if a memory allocation error occurs, -it will generate a CppADUsageError/ message. -
-
-
The get_started.cpp - example has been simplified -so that it is easier to understand. - -
-
-11-15 -
-Fix a memory leak in both the ForSparseJac - and -RevSparseJac - calculations. - -
-
-11-12 -
-Add reverse mode Jacobian sparsity - calculation. - -
-
-11-09 -
-Add prototype documentation for logdet - in -the LuSolve - function. -
-
-
Add the optional -ratio - argument to the -LuFactor - routine. -(This has since been moved to a separate routine called LuRatio -.) - -
-
-11-07 -
-Remove some blank lines from the example files listed -directly below (under 11-06). -Comments for computing the entire Jacobian -entire sparsity pattern - -was added. - -
-
-11-06 -
-The cases of std::vector, std::valarray, and -CppAD::vector were folded into the standard example and tests -format for the following cases: -rev_two.cpp -, -rev_one.cpp -, -Reverse.cpp, -hessian.cpp -, -jacobian.cpp -, -forward.cpp -, -for_two.cpp -, -for_one.cpp -, -Fun.cpp -(Fun.cpp has since been replaced by independent.cpp -, -Reverse.cpp has since been replaced by -reverse_one.cpp - and reverse_checkpoint.cpp). - -
-
-11-01 -
-Add forward mode Jacobian sparsity - calculation. - -
-
-10-20 -
-Add sparsity patterns - to -the whish list. - -
-
-10-18 -
-The Unix install configure - command -was missing the -- before of the prefix command line -argument. - -
-
-10-14 -
-The template class 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 -the preprocessor variable NDEBUG is defined. -
-
-
The specialization of CppAD::vector<bool> -was moved to vectorBool - -so that CppAD::vector<bool> does not pack one bit per value -(which can be slow to access). - - -
-
-10-12 -
-Change the -configure - script so that compilation of the -get_started.cpp - and print_for_cout.cpp - examples are optional. -
-
-
One of the dates in the Unix installation -extraction discussion was -out of date. This has been fixed. - - - -
-
-10-06 -
-Change the Unix install configure script -so that is reports information using the same order and notation as its -documentation -. -
-
-
Some compiler errors in the ode_gear_control.cpp - and -ode_stiff.cpp - examples were fixed. - - -
-
-09-29 -
-Add a specialization to CppAD_vector - for the -CppAD::vector<bool> case. -A test for the push_back member function as well as a -CheckSimpleVector - test has been added to cppad_vector.cpp -. -The source code for this template vector class, -cppad/vector.hpp, -has been removed from the documentation. - - -
-
-09-27 -
-Add the -prefix_dir - and - -postfix_dir - ( -postfix_dir - has since been removed) -options to the configure command line. -This gives the user more control over the location where CppAD is installed. - -
-
-09-24 -
-The stiff Ode routines, -OdeGear - and OdeGearControl -, -were added to the utilities -. -A comparison various Ode solvers on a stiff problem -ode_stiff.cpp - was added. -In addition, OdeGear and OdeGearControl -were added to the utilities - and the library was -reorganized. - -
-
-09-20 -
-The Microsoft compiler project files -example/Example.vcproj and TestMore/TestMore.vcproj -were not up to date. -This has been fixed. -In addition, the example numeric_type.cpp - has been added. -
-
-
Make the building of the -Example, TestMore, and Speed, directories -optional during the configure - command. -The Unix installation instructions - were -overhauled to make the larger set of options easy to understand. - -
-
-09-14 -
-Added the NumericType - concept and made the following -library routines require this -concept for their floating point template parameter type: -LuSolve -, -LuFactor -, -RombergOne -, -RombergMul -, -Runge45 -, -Rosen34 -, and -OdeErrControl -. -This is more restrictive than the previous requirements -for these routines but it -enables future changes to the implementation of these routines -(for optimization purposes) with out affecting their specifications. - - -
-
-09-09 -
-Add the UnaryPlus - operator and move the Neg -examples and tests to UnaryMinus -. - -
-
-09-07 -
-Change name of distribution files from -CppAD.unix.tar.gz and CppAD.dos.tar.gz -to - -CppAD-yy-mm-dd.tar.gz - and -CppAD-yy-mm-dd.zip - -(the -*.zip - file -uses pkzip compression). - - -
-
-08-30 -
-The -maxabs - argument has been added to the -OdeErrControl - function so that it can be used -with relative errors where components of the ODE solution may be zero -(some of the time). -In addition, some of the rest of the OdeErrControl documentation -has been improved. -
-
-
The documentation for -replacing defaults -in CppAD error macros has been improved. - -
-
-08-24 -
-Changed Romberg to RombergOne - and added RombergMul -. -In addition, added missing entries to ListAllExamples - -and reorganized utilities -. - -
-
-08-20 -
-Backed out addition of Romberg integration routine -(at this point uncertain of the interface that is most useful in -the context of AD.) - -
-
-08-19 -
-Added a Romberg integration routine for -where the argument types are template parameters -(for use with AD types). - -
-
-08-15 -
-The Microsoft project files example/Example.vcproj and -TestMore/TestMore.vcproj were missing some necessary routines. -In addition, Speed/Speed.vcproj was generating a warning. -This has been fixed. - -
-
-08-14 -
-An Integer - conversion function as been added. -
-
-
The value.cpp - example has been improved and the old example -has been moved into the TestMore directory. - -
-
-08-13 -
-The unary_standard_math - functions -sinh, and cosh have been added. -In addition, more correctness testing -has been added for the sin and cos functions. -
-
-
The OdeErrControl - routine could lock in an infinite loop. -This has been fixed and a test case has been added to check for this problem. - -
-
-08-07 -
-The conditional expression - function has been changed -from just CondExp to -CondExpLt, -CondExpLe, -CondExpEq, -CondExpGe, -CondExpGt. -This should make code with conditional expressions easier to understand. -In addition, it should reduce the number of tape operations because -one need not create as many temporaries to do comparisons with. -The old CondExp function has been deprecated. - -
-
-07-21 -
-Remove unnecessary no-op that was left in tape for the -unary_standard_math - functions -acos, asin, atan, cos. -
-
-
Improve the index entries in the documentation that corresponds -to the cppad/local directory source code. - -
-
-07-19 -
-The wish_list - and Bugs information -were moved out of this section and into their own separate sections -(the Bugs section has been removed; see the bug subdirectory -instead). -
-
-
A discussion of -VecAD speed and memory - was added -as well as an entry in the -wish_list - to make it more efficient. - - -
-
-07-15 -
-The BOOST_DIR and CPP_ERROR_WARN -configure - options -were not properly implemented for compiling the -lib sub-directory. -This has been fixed. -
-
-
Some compiler warnings in the file lib/ErrFun.cpp, -which computes the erf - function, -have been fixed. - -
-
-07-11 -
-The push_back - function has -been added to the CppAD::vector template class. -
-
-
It appears that the TestMore/Runge45.cpp file was missing -an include of example/NearEqualExt.h. This has been fixed. - -
-
-07-08 -
-The documentation for Forward - and Reverse - has been -improved. - -
-
-07-05 -
-The rosen_34.cpp - example mixed the -CppAD::vector - and -CppADvector vector types. -This caused the compilation of the examples to fail when -CppADvector was defined as something other than -CppAD::vector (found by Jon Pearce). -This has been fixed. -
-
-
The CheckSimpleVector - run time code has been improved so that it is -only run once per case that is being checked. -
-
-
Simple Vector concept checking (CheckSimpleVector -) was -added to the routines: -ForOne -, -ForTwo -, -Forward -, -ADFun -, -Hessian -, -Independent -, -Jacobian -, -RevOne -, -RevTwo -, and -Reverse -. - -
-
-07-04 -
-Simple Vector concept checking (CheckSimpleVector -) was -added to the routines: -LuFactor -, -LuSolve -, -LuInvert -, -OdeErrControl -, -Runge45 -, and -Rosen34 -. -
-
-
The previous version of the -routine OdeErrControl - was mistakenly in the global namespace. -It has been moved to the CppAD namespace -(where all the other utilities - routines are). -
-
-
The previous distribution (version 05-07-02) was missing the file -cppad/local/Default.h. -This has been fixed. - -
-
-07-03 -
-Added CheckSimpleVector -, a C++ concept checking utility -that checks if a vector type has all the necessary conditions -to be a SimpleVector - class with a specific element type. - -
-
-07-02 -
-Version 7 of Microsoft's C++ compiler -supports the standard declaration for a friend template function. -Version 6 did not and -CppAD used macros to substitute the empty string for -<Base>, < AD<Base> >, and < VecAD<Base> > -in these declarations. -These macro substitutions have been removed -because Version 6 of Microsoft's C++ compiler -is no longer supported by CppAD. -
-
-
The copy base section was split into the default -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 -Base - to a - -AD< AD<Base> > -, -AD< AD< AD<Base> > > - etc. - - -
-
-07-01 -
-The permissions were set as executable for many of the no-executable files -in the distribution; for example, the README, file. -This has been fixed. - -
-
-06-25 -
-Some improvements were made to the -README, AUTHORS, COPYING, and INSTALL files. -In addition, the file -UWCopy040507.html -which contains the University of Washington's copyright -policy (see Section 2) was added to the distribution. - -
-
-06-24 -
-The List2Vector -example utility - is no longer used and has -been removed. - -
-
-06-18 -
-CppAD is now supported by Microsoft Visual C++ version 7 or higher. -The version 6 project files - -*.dsw - and -*.dsp - -have been replaced by the version 7 project files - -*.sln - and -*.vcproj -. - -
-
-06-14 -
-A new CondExp example - has been added and -the old CondExp - example has been moved to the -TestMore directory (it is now only a test). - - -
-
-06-13 -
-The changes made on 06-06 do not run under Microsoft Visual C++ version 6.0 -(even though they are within the C++ standard). -Preliminary testing under version 7 indicates that Microsoft -has fixed this problem in later versions of their C++ compiler. - -
-
-06-06 -
-Converted the routines -Forward - and Reverse - to allow for any -SimpleVector - instead of just CppADvector. -In addition, separated the syntax of the function call -from the prototype for each of the arguments. -This was also done for all the easy to use Drivers - -as well as the Independent - function and -the ADFun - constructor. -
-
-
Add a section containing a list of -all the examples -. - -
-
-05-19 -
-A significant improvement in speed was obtained by moving -the buffer extension to a separate function and then -inline the rest of putting operators in the tape. -For example, -here is part of the speed test output before this change: -
 
-     Tape of Expansion by Minors Determinant: Length = 350, Memory = 6792
-     size = 5 rate = 230
-     size = 4 rate = 1,055
-     size = 3 rate = 3,408
-     size = 2 rate = 7,571
-     size = 1 rate = 13,642
-
-and here is the same output after this change: -
 
-     Tape of Expansion by Minors Determinant: Length = 350, Memory = 6792
-     size = 5 rate = 448
-     size = 4 rate = 2,004
-     size = 3 rate = 5,761
-     size = 2 rate = 10,221
-     size = 1 rate = 14,734
-
-Note that your results will vary depending on operating system and machine. - -
-
-05-18 -
-Change name of OdeControl to OdeErrControl - -and improve its documentation. -
-
-
Correct the syntax for the Parameter and Variable - -functions. - - -
-
-05-16 -
-Change OdeErrControl - to have method return its order instead -of having a separate argument to OdeErrControl. -
-
-
Add the argument -scur - to OdeErrControl, -improve OdeErrControl choice of step size and documentation. - - -
-
-05-12 -
-Using profiling, the -multiplication operator - 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 -to the ad_binary - and compound_assign - operators. - - -
-
-05-06 -
-The documentation for -SimpleVector - and NearEqual - -were changed to use more syntax (what the user enters) -and simpler prototypes -(the compiler oriented description of the arguments). -In addition, exercises were added at the end of the -SimpleVector -, CppAD_vector -, and NearEqual - -documentation. -
-
-
There was a undesired divide by zero case in the file -TestMore/VecUnary.cpp that just happened to work -in corresponding NearEqual - check. -The 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 -the TestMore/VecUnary.cpp test. - - - -
-
-05-01 -
-The doubly linked list was also removed from the VecAD - -internal data structure because this method of coding is simpler -and it makes it more like the rest of CppAD. - -
-
-04-21 -
-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 -an AD object was destroyed. -In order to speed AD operations in general, -the internal data structure of an AD object has been changed so that -this list is no longer necessary (a tape id number is used in its place) -
-
-
During the process above, the function Variable - was added. - - -
-
-04-20 -
-Add profiling - -to the speed tests. - -
-
-04-19 -
-Remove an extra (not necessary) -semi-colon from the file cppad/local/Operator.h. - -
-
-03-26 -
-The new routine OdeErrControl - does -automatic step size control for the ODE solvers. - -
-
-03-23 -
-The routine Rosen34 - is an improved stiff integration method -that has an optional error estimate in the calling sequence. -You must change all your calls to OdeImplicit -to use Rosen34 (but do not need to change other arguments -because error estimate is optional). - -
-
-03-22 -
-The routine Runge45 - is an improved Runge-Kutta method -that has an optional error estimate in the calling sequence. -You must change all your calls to OdeRunge -to use Runge45 (but do not need to change other arguments -because error estimate is optional). - -
-
-03-09 -
-Some extra semi-colons (empty statements) -were generating warnings on some compilers. -The ones that occurred after the macros -CppADStandardMathBinaryFun, -CppADCompareMember, -CppADBinaryMember, and -CppADFoldBinaryOperator have been removed. - -
-
-03-04 -
-An new multiple level of AD example mul_level - was added. - -
-
-03-01 -
-An option that specifies error and warning -flags - -for all the C++ compile commands, -was added to the -Unix installation instructions -. - - -
-
-02-24 -
-The routine LuSolve - was split into LuFactor - -and 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 -left hand side for a previous equation. -
-
-
An extra requirement was added to the -SimpleVector - template class. -There must be a typedef for value_type -which is the type of elements in the vector -
-
-
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 -Jean-Pierre Dussault -). -This has been fixed. - -
-
-01-08 -
-The erf - function was added. -The implementation of this function used conditional expressions -(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 -has been removed. - - - -
Input File: omh/appendix/whats_new/whats_new_05.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_05_xml.js cppad-2019.02.00.0/doc/_whats_new_05_xml.js --- cppad-2018.00.00.0/doc/_whats_new_05_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_05_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,180 +0,0 @@ -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_05.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_05.xml#12-24', -'whats_new_05.xml#12-23', -'whats_new_05.xml#12-22', -'whats_new_05.xml#12-20', -'whats_new_05.xml#12-19', -'whats_new_05.xml#12-16', -'whats_new_05.xml#12-15', -'whats_new_05.xml#12-14', -'whats_new_05.xml#12-11', -'whats_new_05.xml#12-08', -'whats_new_05.xml#12-07', -'whats_new_05.xml#12-06', -'whats_new_05.xml#12-05', -'whats_new_05.xml#12-03', -'whats_new_05.xml#12-02', -'whats_new_05.xml#12-01', -'whats_new_05.xml#11-23', -'whats_new_05.xml#11-22', -'whats_new_05.xml#11-20', -'whats_new_05.xml#11-19', -'whats_new_05.xml#11-15', -'whats_new_05.xml#11-12', -'whats_new_05.xml#11-09', -'whats_new_05.xml#11-07', -'whats_new_05.xml#11-06', -'whats_new_05.xml#11-01', -'whats_new_05.xml#10-20', -'whats_new_05.xml#10-18', -'whats_new_05.xml#10-14', -'whats_new_05.xml#10-12', -'whats_new_05.xml#10-06', -'whats_new_05.xml#09-29', -'whats_new_05.xml#09-27', -'whats_new_05.xml#09-24', -'whats_new_05.xml#09-20', -'whats_new_05.xml#09-14', -'whats_new_05.xml#09-09', -'whats_new_05.xml#09-07', -'whats_new_05.xml#08-30', -'whats_new_05.xml#08-24', -'whats_new_05.xml#08-20', -'whats_new_05.xml#08-19', -'whats_new_05.xml#08-15', -'whats_new_05.xml#08-14', -'whats_new_05.xml#08-13', -'whats_new_05.xml#08-07', -'whats_new_05.xml#07-21', -'whats_new_05.xml#07-19', -'whats_new_05.xml#07-15', -'whats_new_05.xml#07-11', -'whats_new_05.xml#07-08', -'whats_new_05.xml#07-05', -'whats_new_05.xml#07-04', -'whats_new_05.xml#07-03', -'whats_new_05.xml#07-02', -'whats_new_05.xml#07-01', -'whats_new_05.xml#06-25', -'whats_new_05.xml#06-24', -'whats_new_05.xml#06-18', -'whats_new_05.xml#06-14', -'whats_new_05.xml#06-13', -'whats_new_05.xml#06-06', -'whats_new_05.xml#05-19', -'whats_new_05.xml#05-18', -'whats_new_05.xml#05-16', -'whats_new_05.xml#05-12', -'whats_new_05.xml#05-06', -'whats_new_05.xml#05-01', -'whats_new_05.xml#04-21', -'whats_new_05.xml#04-20', -'whats_new_05.xml#04-19', -'whats_new_05.xml#03-26', -'whats_new_05.xml#03-23', -'whats_new_05.xml#03-22', -'whats_new_05.xml#03-09', -'whats_new_05.xml#03-04', -'whats_new_05.xml#03-01', -'whats_new_05.xml#02-24', -'whats_new_05.xml#01-08' -]; -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-2018.00.00.0/doc/whats_new_06.xml cppad-2019.02.00.0/doc/whats_new_06.xml --- cppad-2018.00.00.0/doc/whats_new_06.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_06.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,2028 +0,0 @@ - - - -Changes and Additions to CppAD During 2006 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_06 - -

- - - -
Changes and Additions to CppAD During 2006
-
-Introduction -
-This section contains a list of the changes to CppAD during 2006 -(in reverse order by date). -The purpose of this section is to -assist you in learning about changes between various versions of CppAD. - -
-
-12-24 -
-Move exp_eps_ad to exp_eps_cppad and -add exercises to the following sections: -exp_eps_rev1 -, -exp_eps_cppad -. -
-
-
Add operation sequence indices to help track operations in -exp_eps_for0 -, -exp_eps_for1 -, -exp_eps_rev1 -. - -
-
-12-23 -
-Add exercises to the following sections: -get_started.cpp -, -exp_eps -, -exp_eps_for0 -, and -exp_eps_for1 -. - -
-
-12-22 -
-Move get_started.cpp - below the introduction - directory. -
-
-
Move the exponential example to the subdirectory -introduction/exp_apx and change the ---with-Introduction -unix configure option -to build both the get_started.cpp - and exp_apx.cpp - -example programs. -(The --with-GetStarted configure command line option has been removed.) - -
-
-12-21 -
-Add the source code for Poly - to the documentation -and include Poly - in the in the speed_utility - section. -
-
-
The get_started.cpp - section has been moved -into the Introduction - and -exercises - were added to that section. -In addition some sections has switched position between -the top level CppAD - and the Appendix -. - - -
-
-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 -following routines: -det_by_minor -, -det_grad_33 -, -uniform_01 -, -det_of_minor -, -det_by_lu -, -LuInvert -, -LuFactor -, -LuSolve -. -
-
-
Separate the specifications for the source in -speed_utility - and add cross reference to the following routine -specification and implementations: -det_by_minor -, -det_grad_33 -, -uniform_01 -, -det_of_minor -, -det_by_lu -, -LuInvert -, -LuFactor -, -LuSolve -. - - -
-
-12-18 -
-Make the speed - source code easier to read. -
-
-
Change the speed test output name det_poly to poly -(as it should have been). - -
-
-12-17 -
-The speed test det_grad_33 - was missing its documentation -(this has been fixed). -In addition, the titles and indexing for the speed test documentation -has been improved. -
-
-
Add to the specifications that each repeated test corresponds to a -different matrix in -det_lu - and -det_minor -. -In addition, modify all the speed tests so that they abide by this rule. -
-
-
Change some references from the deprecated name CppAD.h to -new name cppad.hpp. -
-
-
Change adolc_det_minor.cpp - and cppad_det_minor.cpp - -to tape once and reuse operation sequence for each repeated -matrix in the test. -
-
-
Add the poly - speed test for all three packages. -In addition, correct a missing include in poly - routine. - - -
-
-12-15 -
-The wish list item -to simplify and better organize the speed tests been completed: - -
- -speed/ - - - template functions that are speed tested
- -speed/example - - example usage of speed template functions
- -speed/adolc - - - Adolc drivers for the template functions
- -speed/cppad - - - CppAD drivers for the template functions
- -speed/fadbad - - - Fadbad drivers for the template functions
- -speed/profile - - - profiling version of CppAD drivers -
-
-12-13 -
-Next step for the speed wish list item: -remove speed_cppad from the documentation and replace it by -speed/cppad, see speed_cppad - for the new CppAD speed -test routines. - -
-
-12-12 -
-Started the speed wish list item by -move the adolc director to speed/adolc and -fadbad to speed/fadbad. - -
-
-12-11 -
-Started the speed wish list item by -creating the speed/example directory and moving the relevant -examples from - -example/*.cpp - and - -speed_example/*.cpp - to - -speed/example/*.cpp -. -In addition, the relevant include files have been moved from - -example/*.hpp - to - -speed/*.hpp -. -
-
-
A new speed_test - routine was added to the library. - - -
-
-12-10 -
-The pow - function was changed to be a an -AD<Base> - -atomic - operation. -This function used to return a nan if - -x - is negative because it was implemented as - -
-     pow(
xy) = exp( log(x) * y )
-
-This has been fixed so that the function and its derivatives are now -calculated properly when -x - is less than zero. -The pow - documentation was improved -and the pow.cpp - example was changed to -test more cases and to use the same variable -names as in the documentation. - -
-
-12-09 -
-A speed wish list item was added to the wish list. -
-
-
The prototype for int arguments in binary operations -(for example addition -) was documented as -const int & but was actually just plain int. -This has been fixed. -(Later changed to double.) - -
-
-12-07 -
-Fix bug in the -subversion installation instructions; see -bug report -. -
-
-
The some of the automatically generated makefile.in files -had an improper license statement in the GPL license version. -This has been fixed. - -
-
-12-05 -
-Add the unix installation ---with-Documentation - option -and remove the - -postfix_dir - option. -
-
-
Create a fixed -whats_new - section above the section for each particular year. -Also improve the CppAD distribution README file. - - -
-
-12-03 -
-The include file directory CppAD was changed to be all -lower case; i.e., cppad. -If you are using a Unix system, see include_deprecated -. -This completes the following wish_list - items (which were removed): - -
  1. -File and directory names should only contain lowercase letters, -numbers underscores and possibly one period. -The leading character must be alphabetic. - -
  2. - -C++ header files should have the .hpp extension. - -
- - - -
-
-12-02 -
-Put explanation of version numbering in the -download instructions. -
-
-
Correct some file name references under the Windows heading in -speed_cppad -. - -
-
-12-01 -
-All of the Makefile.am and Makefile files were changed -to lower case; i.e., makefile.am and makefile. -
-
-
Fix compiler warning while compiling cppad/RombergOne/ -(mistake occurred during 11-20 - change). - -
-
-11-30 -
-Cygwin packages, and other system packages, -should not have a dash in the version number. -See -cygwin package file naming - -or, to quote the -rpm file naming convention - - -The only restriction placed on the version is that -it cannot contain a dash "-". - -As per the acceptable package naming conventions for cygwin, -CppAD version numbering has be changed from - -yy-mm-dd - format to -yyyymmdd -; i.e. -cppad-06-11-30 was changed to cppad-20061130. - -
-
-11-29 -
-There was a problem using RombergOne - with floating point -types other than double. This has been fixed. - -
-
-11-28 -
-The installation - download files were not being built -because Makefile.am referenced Doc when it should have -referenced doc. This has been fixed. - -
-
-11-23 -
-A Version Numbering entry was added to the -wish_list - (this was completed on 11-30 -). - -
-
-11-18 -
-The example routine that computes determinants using expansion -by minors DetOfMinor was changed to det_of_minor -, -in preparation for -more formal speed comparisons with other packages. -To be specific, its documentation was improved, -its dependence on the rest of CppAD was removed -(it no longer includes CppAD.h -). - - -
-
-11-12 -
-The -general.cpp - and -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". -
-
-
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. - -
-
-11-08 -
-Move the Example directory to example -and change all its files to use lower case names. - -
-
-11-06 -
-Move the TestMore directory to test_more -and change all its files to use lower case names. - - -
-
-11-05 -
-Remove references in the speed_cppad - tests to the -Memory and Size functions because they -have been deprecated -. -
-
-
Correct some references to var_size that should have been -size_var -. - -
-
-11-04 -
-Put text written to standard output in the documentation for the -get_started.cpp - and -print_for.cpp examples. -(Now documentation can be built from a subversion checkout with out -needing to execute automake.) -The PrintFor.cpp and -speedtest.cpp examples were missing in ListAllExamples - -(which has been fixed). -
-
-
Move the Speed directory to speed -and change all its files to use lower case names. - -
-
-11-02 -
-The print_for directory was referenced as PrintFor -in the root CppAD Makefile.am this has been fixed. -
-
-
The documentation for the Adolc helper routines -AllocVec and AllocMat were not being included. -This has been fixed. -
-
-
Move the GetStarted directory to get_started -and change all its files to use lower case names. - -
-
-11-01 -
-Move the PrintFor directory to print_for -and change all its files to use lower case names. - -
-
-10-31 -
-Move the SpeedExample directory to speed_cppad_example -and change all its files to use lower case names. - -
-
-10-29 -
-Move the Adolc directory to adolc -and change all its files to use lower case names. -
-
-
Change all the file in the omh directory to -use lower case names. -
-
-
The file Makefile.am in the distribution directory had the -CPL copyright message in the GPL version. This has been fixed. - -
-
-10-28 -
-The copyright message in the script files -example/OneTest and TestMore/OneTest were GPL -(in the CPL distribution). -This has been fixed by moving them to -example/OneTest.sh and TestMore/OneTest.sh so that -the distribution automatically edits the copyright message. - - -
-
-10-27 -
-Change 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. - -
-
-10-26 -
-Change hes_lagrangian.cpp - example so that it modifies -the independent variable vector between the call to -Independent - and the -ADFun<Base> - -constructor -. - -
-
-10-25 -
-A subversion install procedure was -added to the documentation. -
-
-
Fix definition of preprocessor symbol -PACKAGE_STRING in Speed/Speed.cpp -(broken by change on 10-18). -
-
-
Added the example -hes_lagrangian.cpp - which computes the Hessian -of a Lagrangian. - -
-
-10-18 -
-Document and fix possible conflicts for -preprocessor symbols - -that do not begin with CppAD or CPPAD_. -
-
-
Include a default value for the file cppad/config.h -in the subversion repository. - -
-
-10-16 -
-Fix bug when using OdeErrControl - with the type -AD< AD<double> >. - - -
-
-10-10 -
-Add the Var2Par - function so it is possible -to obtain the Value - of a variable. -Move the Discrete.cpp example to tape_index.cpp -. -Fix the Microsoft project file so that the Windows install -examples and testing works properly -(it was missing the stack_machine.cpp - example). - -
-
-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 -get the nightly build changed: -
  1. -Change shell scripts to use *.sh extension. -
  2. - -Two versions, one with CPL and other with GPL license. -
  3. - -Change subversion version of CppAD from GPL to CPL copyright. -
  4. - -Change all files in cppad/local to use lower case and *.hpp extension. -
  5. - -CppAD_vector.h was generating a warning on version 4 of gcc. -This have been fixed. -
  6. - -Change the preprocessor # define commands -in cppad/local/*.hpp to use upper case names. -
  7. - -Add the stack_machine.cpp - example. -
- - -
-
-08-17 -
-Some error message occurred while executing -
 
-     valgrind --tool=memcheck example/example
-     valgrind --tool=memcheck TestMore/TestMore
-
-
-These were not really bugs, but they have been fixed to avoid -this conflict between CppAD and valgrind -. - -
-
-07-14 -
-Make some improvements were made to the Introduction -, -exp_eps.hpp - and exp_eps_rev1 - sections. - -
-
-07-12 -
-Use a drop down menu for the navigation links, instead of a separate frame -for the navigation links, for each section in the documentation. - -
-
-06-29 -
-Newer versions of the gcc compiler generated an error because -erf - was using CondExp - before it was defined. -This was found by Kasper Kristensen and his fix has been -included in the CppAD distribution. - -
-
-06-22 -
-The ADFun - operation - -f(xy) - no longer executes a zero order -Forward - operation when a new operation sequence is stored in - -f -. -In addition, the syntax for this operation was changed to - -f.Dependent(y) - (see Dependent -). - - -
-
-06-19 -
-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 wish_list -: -
-
-
"We would like to be able to erase the function -values so that ADFun - objects use less memory. -We may even want to erase the AD operation sequence so that -ADFun - objects use even less memory and can be used -for a subsequent AD operation sequence." - -
-
-06-17 -
-Added capacity_order - which can be used to control -the amount of memory used to store Forward - results. -Also deprecated - taylor_size, and defined -size_order - in its place. - -
-
-06-18 -
-Added the ADFun default constructor - -and the ability to -store a new operation sequence - -in an ADFun object with out having to use -ADFun pointers together with new -and delete. - - - -
-
-06-17 -
-The location where the distribution files are stored has changed -and this broke the Download Current Version links for the -unix and windows installation. -This has been fixed. -
-
-
The compiling instructions for the speed_cppad - routines have been improved. -
-
-
The Value - function has been extended to allow for -parameter - arguments even if the corresponding -tape is in the Recording state. -
-
-
The BenderQuad - documentation and example have been improved -by changing -Vector - to -BAvector - to emphasize that -it corresponds to a vector of -Base - objects. - - -
-
-06-15 -
-Change BenderQuad - to use -Base - instead of - -AD<Base> - where every possible. -This allows for more calculations to be done in the base type; i.e., -is more efficient. - -
-
-06-09 -
-Add a size check (size one) for the -function value argument, g - in BenderQuad. - -
-
-06-07 -
-Some major changes were made to the notation in -get_started.cpp - (to make it easier to start using CppAD). -
-
-
In the Introduction - example, - - -exp -eps - - - - was changed to - -exp -_ -eps - - - -. - -
-
-06-05 -
-Change BenderQuad - - - -F -y - -( -x -, -y -) - - - to - -H -( -x -, -y -) - - - so applies in a more -general setting. -This was another change to the BenderQuad interface, - -fun.fy - was changed to -fun.h -. - -
-
-06-02 -
-Newer versions of the gcc compiler generated a warning for possible -use of an uninitialized pointer. -This was found by Michael Tautschnig and his fix has been -included in the CppAD distribution. - - -
-
-05-31 -
-The interface to BenderQuad - has been changed. -Now all the function evaluation routines -are member functions of one class object. -This makes it easy for them to share common data. - -
-
-05-29 -
-Change statement of command syntax to -be in the same browser frame as the command documentation -(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 -follow another link to see to the command syntax. - -
-
-05-27 -
-Added BenderQuad - for computing the Hessian of -Bender's reduced objective function. -
-
-
Added special specifications for resize(0) -to CppAD_vector -. - -
-
-05-03 -
-The g++ (GCC) 4.1.0 (Red Hat 4.1.0-3) compiler reported an error -because certain functions were used before being defined -(version 3.4.4 did not complain about this). -This has been fixed. - -
-
-04-29 -
-Change all of the example and test driver programs so that they return -error codes; i.e., zero for no error and one for an error. -
-
-
Add more discussion and a reference for a -gcc 3.4.4 -O2 bug (since been removed). - -
-
-04-28 -
-Improve the get_started.cpp - example and move -it so that it is visible at the too level of the documentation. - -
-
-04-26 -
-The programs in Introduction - have been converted to automated -test that return true or false with the driver program -Introduction -. - -
-
-04-25 -
-Add an Introduction - section to the documentation -(replaces old example that was part of the Theory - section). - -
-
-04-19 -
-A discussion was added near the end of the FunCheck - documentation. -And the cross references to the CompareChange - discussion -were changed to the FunCheck discussion. -
-
-
An operation sequence entry was added to the wish_list -. - -
-
-04-18 -
-The new definitions for -AD of Base - -and -operation sequence - -have been used throughout the documentation. -
-
-
Add the FunCheck - section for checking that a sequence of -operations is as intended. - - -
-
-04-17 -
-The documentation for SpeedTest - and Poly - was improved. -
-
-
Definitions were added for an atomic operation - -and for an operation sequence being -dependent and independent of the values of specific operands. -
-
-
The definition of AD sequence of operations was made abstract -and moved to the glossary as -Type operation sequence -. - -
-
-04-15 -
-The mul_level - example was moved from -ADFun - to General -. -The documentation for SpeedTest - was improved. - -
-
-04-14 -
-Documentation and examples were improved for the following routines: -ForTwo -, -RevTwo -. -In addition, the computation in RevTwo was made more efficient -(it used to possibly calculate some first order partials that were not used). - -
-
-04-13 -
-Documentation and examples were improved for the following routines: -Jacobian -, -ForOne -, -RevOne -, -and Hessian -. - - -
-
-04-08 -
-In the case where use_VecAD - is true, -the 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 -(because it only applies to the current forward_zero -). -
-
-
The conversion from -VecAD<Base>::reference - -to AD - gave a compile error (this has been fixed). -Code example for this fix -
 
-     VecAD<double> V(1);
-     AD<double> zero = 0;
-     V[zero] = 1.;
-     static_cast< AD<double> > ( V[zero] );
-
-
-04-06 -
-The ForSparseJac -, RevSparseJac -, RevSparseHes - -sparsity results are now valid for -all independent variable values -(if the AD operation sequence does no use any - -VecAD<Base> - operands). -In addition, the -ForSparseJac, RevSparseJac - and RevSparseHes - -documentation and examples were improved. -
-
-
The useVecAD - -member function was added to ADFun - objects. -
-
-
The var_size member function was changed to -size_var - -(this is not backward compatible, but var_size was just added on -04-03 -). - - -
-
-04-05 -
-The documentation and example for CompareChange - were -improved and moved to be part of the Forward - section. - -
-
-04-04 -
-The documentation and examples for Reverse - were -improved and split into reverse_one - and reverse_any -. - -
-
-04-03 -
-Create separate sections for the -zero - and forward_one - first order case -of Forward - mode. -
-
-
The ADFun Size - member function -has been deprecated (use size_order - instead). -
-
-
The Reverse - member function is now declared, -and documented as, const; i.e., -it does not effect the state of the ADFun object. -
-
-
Change the examples that use Reverse - to use the same -return value notation as the documentation; i.e., dw. - -
-
-04-02 -
-The member functions of ADFun - that return properties of -AD of -Base - -operation sequence - -have been grouped into the seq_property - section. -In addition, the seq_property.cpp - example has been added. -
-
-
The CompareChange - function documentation was improved -and moved to a separate section. -
-
-
Group the documentation for the ADFun - member functions that -evaluate functions and derivative values. -This organization has since been changed. -
-
-
Remove the old Fun.cpp example and extend -independent.cpp - so that it demonstrates using different -choices for the SimpleVector - type. - -
-
-04-01 -
-Move the ADFun Constructor - to its own separate -section, improve its documentation, and use independent.cpp - -for its example. -
-
-
The following member functions of ADFun - have been -deprecated -: -Order, Memory. -
-
-
The wish list entry for Memory usage -was updated on 04-01. -The request was implemented on 06-19 - -and the entry was removed from the wish list. - -
-
-03-31 -
-Add examples for the Parameter, Variable - and -Independent - functions. -
-
-
Move the Parameter and Variable - functions from -the ADFun - section to the AD - section. -
-
-
In the examples for the AD - sections, -refer to the range space vector instead of the dependent variable vector -because some of the components may not be -variables -. - -
-
-03-30 -
-Move the LuRatio - section below LuDetAndSolve -. -
-
-
Move the definition of an -AD of -Base - -operation sequence - -from the glossary to the AD - section. -
-
-
Improve the definition of tape state. -
-
-
Add mention of taping to -Erf -, BoolFun -, NearEqualExt -,and Pow -. -
-
-
Change the definition for -VecAD<Base>::reference - -so that it stands out of the text better. - - -
-
-03-29 -
-Mention the VecAD<Base>::reference - case in -documentation and examples for -abs -, atan2 -, erf -, and pow -. -
-
-
Fix a bug derivative computation for -abs(x) - -when -x - had type -AD< AD<double> > - and -x - -had value zero. -
-
-
Fix a bug using non-zero AD indices for VecAD - vectors -while the tape is in the empty state. -
-
-
Extend erf - to include float, double, -and -VecAD<Base>::reference -. - -
-
-03-28 -
-Mention the -VecAD<Base>::reference - case in -documentation and examples for -UnaryPlus -, -UnaryMinus -, -ad_binary -, -compound_assign -, and -unary_standard_math - - - -
-
-03-27 -
-Extend and improve the -VecAD exceptions -. -
-
-
Mention the VecAD<Base>::reference - case -and generally improve -addition - documentation and examples. - - -
-
-03-26 -
-Improve documentation and examples for VecAD - and change -its element type from - -VecADelem<Base> - to -VecAD_reference<Base> - -(so that it looks more like -VecAD<Base>::reference -). -
-
-
Mention the VecAD<Base>::reference - case -and generally improve -Value -, ad_output - and assignment - documentation -and examples. -
-
-
Extend Integer - and PrintFor - to include the -VecAD<Base>::reference - case -(and mention in documentation and examples). - - -
-
-03-24 -
-Move VecAD - and LuRatio - from the old ExtendDomain section -to AD -. - -
-
-03-23 -
-Improve documentation and examples for -CondExp - and Discrete -. -Move both of these sections from ExtendDomain to ADValued -. - -
-
-03-22 -
-The documentation sections under AD - -have been organized into a new set of sub-groups. - -
-
-03-18 -
-The documentation and example for PrintFor - have been improved. -The sections below AD - -in the documentation have been organized into subgroups. - -
-
-03-17 -
-The documentation and examples have been improved for the -following functions: -BoolFun -, and -NearEqualExt -. - -
-
-03-16 -
-Improve the documentation and example for the pow - function. -This includes splitting out and generalizing the integer case -pow_int -. -
-
-
The copies of the atan2 function were included -in the CppAD namespace for the -float and double types. - -
-
-03-15 -
-Improve the -introduction - to CppAD. - -
-
-03-11 -
-The file 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. -
-
-
The term AD of -Base - -operation sequence - -has been defined. -It will be used to improve the user's understanding of exactly -how an ADFun - object is related to the C++ algorithm. - - -
-
-03-10 -
-The math functions that are not under unary_standard_math - have -been grouped under MathOther. -
-
-
The documentation and examples have been improved for the -following functions: -abs -, atan2 -. - -
-
-03-09 -
-The examples -cos.cpp -, -cosh.cpp -, -exp.cpp -, -log.cpp -, -log10.cpp -, -sin.cpp -, -sinh.cpp -, -sqrt.cpp - -have been improved. - -
-
-03-07 -
-The tan function has been added to CppAD. -
-
-
The examples Acos.cpp -, Asin.cpp - and -atan.cpp - have been improved. - -
-
-03-05 -
-The AD standard math unary functions documentation -has been grouped together with improved documentation -in unary_standard_math -. - -
-
-02-28 -
-The ad_output - and Abs - -documentation and example have been improved. -Minor improvements were also made to the lu_vec_ad.cpp - documentation. - -
-
-02-25 -
-The Compare - documentation and example have been improved. - -
-
-02-24 -
-The documentation and examples have been improved for the following sections: -division -, -= -, *= -, and /= -. - -
-
-02-23 -
-The multiplication - documentation and example have been improved. - -
-
-02-21 -
-The subtraction - documentation and example have been improved. -
-
-
There was a bug RevTwo - that was not detected by the -rev_two.cpp - test. This bug was reported by -Kasper Kristensen - -A test was added TestMore/rev_two.cpp that detects this problem -and the problem has been fixed. - - -
-
-02-15 -
-The += - documentation and example have been improved. - -
-
-02-14 -
-The addition - documentation and example have been improved. - - -
-
-02-13 -
-Combine the old binary operator and compound assignment documentation -into Arithmetic - documentation. -
-
-
The documentation and examples have been improved for the following sections: -assignment -, UnaryPlus -, UnaryMinus -. - -
-
-02-11 -
-The documentation and examples have been improved for the following sections: -ad_ctor -, -ad_ctor - and ad_assign -, and -Value -. - -
-
-02-10 -
-This is the beginning of a pass to improve the documentation: -The documentation sections -The CopyBase (formerly FromBase and now part of ad_ctor - and ad_assign -) and -AD copy constructor - -(formerly Copy) documentation has been modified. -
-
-
Some of the error messaging during ADFun - construction -has been improved. - -
-
-02-04 -
-There was a read memory access past the end of an array in -CppAD::vector::push_back -. -This has been fixed and in addition -TrackNewDel - is now used to do and check the allocation in -CppAD::vector. -
-
-
The routines Runge45 - and Rosen34 - -had static vectors to avoid recalculation on each call. -These have been changed to be plain vectors to avoid memory -leak detection by TrackCount -. - -
-
-01-20 -
-Add -software guidelines - -to the wish list. - -
-
-01-18 -
-Improve the definition for -parameters - and -variables -. -Remove unnecessary reference to parameter and variable -in documentation for Independent -. - -
-
-01-08 -
-The aclocal program is part of the automake and autoconf system. -It often generates warnings of the form: - -
-     /usr/share/aclocal/
...: warning: underquoted definition of
-     
...
-
-The shell script file FixAclocal, -which attempts to fix these warnings, -was added to the distribution. - -
-
-01-07 -
-Change CppAD error handler from using the macros defined in -cppad/CppADError.h to using a class defined in -cppad/utility/error_handler.hpp -. -The macros CppADUnknownError and CppADUsageError -have been deprecated (they are temporarily still available in the -file cppad/local/CppADError.h). - -
-
-01-02 -
-Add the sed script Speed/gprof.sed to aid in the display of the -profiling - output. -
-
-
Make the following source code files easier to understand: -Add.h, Sub.h, Mul.h, Div.h -(in the directory cppad/local). - -
-
-01-05 -
-Make the following source code files easier to understand: -RevSparseHes.h, -Reverse.h, -Fun.h, -Forward.h, -ForSparseJac.h, -RevSparseJac.h -(in the directory cppad/local). - - - -
Input File: omh/appendix/whats_new/whats_new_06.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_06_xml.js cppad-2019.02.00.0/doc/_whats_new_06_xml.js --- cppad-2018.00.00.0/doc/_whats_new_06_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_06_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,212 +0,0 @@ -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_06.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_06.xml#Introduction', -'whats_new_06.xml#12-24', -'whats_new_06.xml#12-23', -'whats_new_06.xml#12-22', -'whats_new_06.xml#12-21', -'whats_new_06.xml#12-19', -'whats_new_06.xml#12-18', -'whats_new_06.xml#12-17', -'whats_new_06.xml#12-15', -'whats_new_06.xml#12-13', -'whats_new_06.xml#12-12', -'whats_new_06.xml#12-11', -'whats_new_06.xml#12-10', -'whats_new_06.xml#12-09', -'whats_new_06.xml#12-07', -'whats_new_06.xml#12-05', -'whats_new_06.xml#12-03', -'whats_new_06.xml#12-02', -'whats_new_06.xml#12-01', -'whats_new_06.xml#11-30', -'whats_new_06.xml#11-29', -'whats_new_06.xml#11-28', -'whats_new_06.xml#11-23', -'whats_new_06.xml#11-18', -'whats_new_06.xml#11-12', -'whats_new_06.xml#11-08', -'whats_new_06.xml#11-06', -'whats_new_06.xml#11-05', -'whats_new_06.xml#11-04', -'whats_new_06.xml#11-02', -'whats_new_06.xml#11-01', -'whats_new_06.xml#10-31', -'whats_new_06.xml#10-29', -'whats_new_06.xml#10-28', -'whats_new_06.xml#10-27', -'whats_new_06.xml#10-26', -'whats_new_06.xml#10-25', -'whats_new_06.xml#10-18', -'whats_new_06.xml#10-16', -'whats_new_06.xml#10-10', -'whats_new_06.xml#09-30', -'whats_new_06.xml#08-17', -'whats_new_06.xml#07-14', -'whats_new_06.xml#07-12', -'whats_new_06.xml#06-29', -'whats_new_06.xml#06-22', -'whats_new_06.xml#06-19', -'whats_new_06.xml#06-19.06-17', -'whats_new_06.xml#06-19.06-18', -'whats_new_06.xml#06-17', -'whats_new_06.xml#06-15', -'whats_new_06.xml#06-09', -'whats_new_06.xml#06-07', -'whats_new_06.xml#06-05', -'whats_new_06.xml#06-02', -'whats_new_06.xml#05-31', -'whats_new_06.xml#05-29', -'whats_new_06.xml#05-27', -'whats_new_06.xml#05-03', -'whats_new_06.xml#04-29', -'whats_new_06.xml#04-28', -'whats_new_06.xml#04-26', -'whats_new_06.xml#04-25', -'whats_new_06.xml#04-19', -'whats_new_06.xml#04-18', -'whats_new_06.xml#04-17', -'whats_new_06.xml#04-15', -'whats_new_06.xml#04-14', -'whats_new_06.xml#04-13', -'whats_new_06.xml#04-08', -'whats_new_06.xml#04-06', -'whats_new_06.xml#04-05', -'whats_new_06.xml#04-04', -'whats_new_06.xml#04-03', -'whats_new_06.xml#04-02', -'whats_new_06.xml#04-01', -'whats_new_06.xml#03-31', -'whats_new_06.xml#03-30', -'whats_new_06.xml#03-29', -'whats_new_06.xml#03-28', -'whats_new_06.xml#03-27', -'whats_new_06.xml#03-26', -'whats_new_06.xml#03-24', -'whats_new_06.xml#03-23', -'whats_new_06.xml#03-22', -'whats_new_06.xml#03-18', -'whats_new_06.xml#03-17', -'whats_new_06.xml#03-16', -'whats_new_06.xml#03-15', -'whats_new_06.xml#03-11', -'whats_new_06.xml#03-10', -'whats_new_06.xml#03-09', -'whats_new_06.xml#03-07', -'whats_new_06.xml#03-05', -'whats_new_06.xml#02-28', -'whats_new_06.xml#02-25', -'whats_new_06.xml#02-24', -'whats_new_06.xml#02-23', -'whats_new_06.xml#02-21', -'whats_new_06.xml#02-15', -'whats_new_06.xml#02-14', -'whats_new_06.xml#02-13', -'whats_new_06.xml#02-11', -'whats_new_06.xml#02-10', -'whats_new_06.xml#02-04', -'whats_new_06.xml#01-20', -'whats_new_06.xml#01-18', -'whats_new_06.xml#01-08', -'whats_new_06.xml#01-07', -'whats_new_06.xml#01-02', -'whats_new_06.xml#01-05' -]; -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-2018.00.00.0/doc/whats_new_07.xml cppad-2019.02.00.0/doc/whats_new_07.xml --- cppad-2018.00.00.0/doc/whats_new_07.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_07.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1570 +0,0 @@ - - - -Changes and Additions to CppAD During 2007 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_07 - -

- - - -
Changes and Additions to CppAD During 2007
-
-Introduction -
-This section contains a list of the changes to CppAD during 2007 -(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 -
-License conversions missed the copyright message at the top -in the following special cases: -makefile.am, makefile.in, and -omh/appendix/license.omh. - - -
-
-12-25 -
-The install - instructions have been improved. - -
-
-12-21 -
-The --with-Documentation - -option on the 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. - -
-
-12-08 -
-By mistake, the documentation License - statement -for the GPL distribution was the same as for the CPL distribution. -This has been fixed. - -
-
-12-05 -
-Change the name of the spec file from - -cppad-yyyymmdd.spec - to cppad.spec. - -
-
-12-04 -
-Add the capability for the RPM spec file to use a different -prefix directory. - -
-
-12-03 -
-This is the first version with the rpm spec file -cppad.spec. - -
-
-12-02 -
-Add the -DESTDIR=directory - option on the -make install - command line. - -
-
-11-29 -
-The unary_standard_math - function sqrt did not link properly -when -Base - was AD<double>. -This has been fixed. - -
-
-11-23 -
-The routines nan and isnan were failing -for some systems because they use nan and or isnan -as preprocessor symbols. -This has been fixed; see macros -. -In addition, the example and test nan.cpp - has been added. - -
-
-11-18 -
-Speed tests for tape_values branch were not better than trunk, -so the good parts of that branch (but not all) were merged into the trunk. -
-
-
The interface specifications for -base type requirements - have been changed so that -CppAD would compile with gcc 4.1.1 -(which requires more definitions before use in template functions). -This changed of requirements is demonstrated by the -base_complex.hpp - and base_adolc.hpp - examples. -
-
-
The problem with newer C++ compilers requiring more definitions before use -also required the user to know about float and double -definitions for the standard math -functions in the CppAD namespace; -see base_std_math -. -
-
-
The example/test_one.sh and test_more/test_one.sh -scripts were modified so that one only need specify the test file name -(does not also need the test routine name). Some of the test routine -declarations were changed from -name() - to - -name(void) - to make this possible. -
-
-
The program test_more/test_more was changed to always -report the memory leak test results (same as example/example). -
-
-
The PrintFor - function was putting an unused variable in the tape. -This has been fixed. - - - -
-
-11-06 -
-Added the -DRAD_EQ_ALIAS compiler flag to the -Sacado speed tests -. -In addition, compiler flag documentation was included for -Sacado and all the other speed tests. - -
-
-11-05 -
-MS project files have been added for running the -cppad - and -double - -speed tests. - -
-
-11-04 -
-The 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. -
-
-
The unix install - procedure has been modified -so that the one configure flag ---with-Speed -builds all the possible executables related to the speed testing. - -
-
-11-03 -
-Improve the speed_main - documentation and output -(as well as the title for other sections under speed -). -
-
-
The subversion copy of the configure - script -was not executable. -This has been fixed. - -
-
-11-02 -
-The instructions for downloading the current version using -subversion have changed. -The user should now directly edit the file -
 
-     trunk/configure
-
-in order to set the correct date for the installation -and to build the corresponding documentation. -
-
-
The speed - section has been slightly reorganized -(the main program and utilities have been separated). -
-
-
Add speed_double - for testing the speed of evaluating -functions in double as apposed to gradients using AD types. - -
-
-11-01 -
-The instructions for downloading the current version using subversion -have changed. -The user must now execute the command -
 
-     ./build.sh version
-
-in order to set the correct version number for her (or his) installation. -
-
-
Add the return status for all the correctness tests -to the documentation; see make test. - -
-
-10-30 -
-The download instructions did not update current version number -and this broke the links to the current tarballs. -This has been fixed. -
-
-
The documentation for det_by_minor - and det_by_lu - -has been improved. -The order of the elements in det_of_minor - has been -corrected (they were transposed but this did not really matter -because determinants of transposes are equal). -
-
-
The makefiles in the distribution have been changed so that -one can run configure from a directory other than the distribution directory. - -
-
-10-27 -
-A subversion method -for downloading CppAD has been added. -
-
-
The installation was broken on some systems because the -configure - command tried to run -the autoconf and automake programs. -This has been fixed by adding -AM_MAINTAINER_MODE to the autoconf input file. -
-
-
Extend the -subversion -methods to include a full installation and old versions. - -
-
-10-23 -
-The cxx_flags - environment variable -has been changed from CPP_ERROR_WARN to CXX_FLAGS. -
-
-
The command configure --help now prints a description -of the environment variables -ADOLC_DIR, -FADBAD_DIR, -SACADO_DIR, -BOOST_DIR, -and -CXX_FLAGS. -In addition, if the environment variables -POSTFIX_DIR or CPP_ERROR_WARN are used, -an message is printed saying that are not longer valid. - - -
-
-10-22 -
-The correctness checks and speed test wrappers were moved -from the individual package directories to 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 - -compute_test_name - to be the same for all packages. -
-
-
The Sacado - -package was added to the list of speed - tests. -In addition, the discussion about how to run each of the -speed tests was corrected to include the -seed - argument. -
-
-
The -postfix_dir - option -was removed on 2006-12-05 - but -it was not removed from the -configure - -documentation. -This has been fixed. -
-
-
The routine CheckSimpleVector - was changed. -It used to require conversion of the form - -
-     
Scalar(i)
-
-where -i - was 0 or 1. -This does not work with when -Scalar - is -Sacado::Tay::Taylor<double>. -This requirement has been changed -(see restrictions -) -to support of - -
-     
x = i
-
-where -x - has type -Scalar - -and -i - has type int. -
-
-
Fix include directives in speed_fadbad - programs -det_lu, det_minor, and poly, -to use FADBAD++ instead of Fadbad++ directory. -
-
-
Add ADOLC_DIR, FADBAD_DIR, SACADO_DIR, -and BOOST_DIR -to the configure - help string. - - -
-
-10-16 -
-Add -seed - argument and -improve speed_main - documentation. - -
-
-10-13 -
-Fix the title in adolc_det_lu.cpp -. -Add the package name to each test case result printed by -speed_main -. - -
-
-10-05 -
-Added and example using complex calculations for a -function that is not complex differentiable not_complex_ad.cpp. -(This example has been removed; see complex FAQ -.) - -
-
-10-02 -
-Extend the pow - function to work for any case where one argument -is -AD<Base> - and the other is double -(as do the binary operators). - -
-
-09-06 -
-If the method.step - function returned -nan (not a number), -it was possible for OdeErrControl - to drop into an infinite loop. -This has been fixed. - -
-
-08-09 -
-Let user detect and handel the case where an ODE initial vector -xi - -contains not a number nan -(see Runge45 -, Rosen34 -, and OdeErrControl -). -
-
-
Use the || operation instead of | -operator in the nan function -(The Ginac library seems to use an alias for the type bool and -does not have | defined for this alias). -
-
-
The file test_more/ode_err_control.cpp was using the -wrong include file name since the change on 08/07. -This has been fixed. - -
-
-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 Runge45 - and Rosen34 - have been -modified to abort -and return nan - when it is returned by the differential -equation evaluation. -The solver OdeErrControl - have been modified to try smaller steps -when this happens. -
-
-
Fix an Sequence Constructor - -referenced to Dependent in documentation -(was using the FunDeprecated - one argument syntax). -
-
-
Add comment about mixing debug and non-debug versions of -CppAD in TrackDelVec - error message. - - -
-
-07-30 - -
-CppADCreateBinaryBool
and CppADCreateUnaryBool -have been replaced by CPPAD_BOOL_BINARY and -CPPAD_BOOL_UNARY respectively. -In addition, the wish_list - item for conversion -of all preprocessor macros to upper case been completed and removed. - -
-
-07-29 -
-The preprocessor macros -CppADUsageError and CppADUnknownError -have been replaced by CPPAD_ASSERT_KNOWN and -CPPAD_ASSERT_UNKNOWN respectively. -The meaning for these macros -has been included in the cppad_assert - section. -In addition, the -known - argument to ErrorHandler - -was wrong for the unknown case. -
-
-
The wish_list - item -for conversion of all preprocessor macros to upper case -has been changes (to an item that was previous missing). - -
-
-07-28 -
-The preprocessor macro CPPAD_DISCRETE_FUNCTIOIN was defined -as a replacement for CppADCreateDiscrete -which has been deprecated. - -
-
-07-26 -
-Merge in changes made in branches/test_vector. - -
-
-07-26 -
-Change all occurrences of CppADvector, -in the files -test_more/*.cpp - and -speed/*/*.cpp -, -where changed to CPPAD_TEST_VECTOR. -All occurrences of the CppADvector in the documentation -were edited to reflect that fact that it has been deprecated. -The documentation index and search for -deprecated items has been improved. - -
-
-07-25 -
-Deprecate the preprocessor symbol CppADvector -and start changing it to -CPPAD_TEST_VECTOR - . -
-
-
Change all occurrences of CppADvector, -in the -example/*.cpp - files, -to CPPAD_TEST_VECTOR. - -
-
-07-23 -
-The TrackNewDel - macros -CppADTrackNewVec, -CppADTrackDelVec, and -CppADTrackExtend have been deprecated. -The new macros names to use are -CPPAD_TRACK_NEW_VEC, -CPPAD_TRACK_DEL_VEC, and -CPPAD_TRACK_EXTEND respectively. -This item has been removed from the -software guidelines - -section of the wish list. -
-
-
The member variable -software guideline - -wish list item has be brought up to date. - -
-
-07-22 -
-Minor improvements to the mul_level_adolc_ode.cpp - example. - -
-
-07-21 - -
  1. -The openmp/run.sh example programs -example_a11c.cpp, -openmp_newton_example.cpp, and -sum_i_inv.cpp -have been changed so that they run on more systems -(are C++ standard compliant). -
  2. - -base_require -: -The IdenticalEqual function, -in the base_require - specification, -was changed to IdenticalEqualPar -(note the API warning - in the - -Base - requirement specifications). -
  3. - -Implementation of the base requirements - for complex types -were moved into the base_complex.hpp - example. -
- - - - -
-
-07-20 -
-The download for CppAD was still broken. -It turned out that the copyright message was missing from the file -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 -that missing copyright messages and test program failures will -be more obvious in the test log. - -
-
-07-19 -
-The download for CppAD has been broken since the example -mul_level_adolc_ode.cpp was added because the -example/example program was failing. -This has been fixed. - -
-
-07-18 -
-A realistic example using Adolc with CppAD -mul_level_adolc_ode.cpp - was added. -The documentation for TrackNewDel - was improved. - -
-
-07-14 -
-Add a discussion at the beginning of -mul_level_ode.cpp - example -(and improve the notation used in the example). - -
-
-07-13 -
-Separate the include file -base_adolc.hpp - -from the mul_level_adolc.cpp - example -so that it can be used by other examples. - -
-
-06-22 -
-Add mul_level_adolc.cpp -, an example that demonstrates using -adouble and for the Base - type. -
-
-
The get_started.cpp - -example did not build when -the --with-Introduction and -BOOST_DIR options were included on the -configure - command line. -In fact, some of the speed - tests also had compilation errors -when BOOST_DIR was include in the configure command. -This has been fixed. -
-
-
There was a namespace reference missing in the files -that could have caused compilation errors in the files -speed/cppad/det_minor.cpp and -speed/cppad/det_lu.cpp. -This has been fixed. - -
-
-06-20 -
-The MS project -test_more/test_more.vcproj would not build because -the file test_more/fun_check.cpp was missing; -this has been fixed. -In addition, -fix warnings generated by the MS compiler when compiling the -test_more/test_more.cpp file. -
-
-
Add a section defining the Base type requirements -. -Remove the -Base - type restrictions from the Faq -. -Make all the prototype for the default Base types agree with -the specifications in the Base type requirements. -
-
-
Fix the description of the tan function in -unary_standard_math -. - - -
-
-06-14 -
-The routine Rosen34 - ( Runge45 - ) had a division -of a size_t ( int ) by a -Scalar -, -where -Scalar - was any NumericType -. -Such an operation may not be valid for a particular numeric type. -This has been fixed by explicitly converting the -size_t to an int, -then converting the int to a -Scalar -, -and then preforming the division. -(The conversion of an int to any numeric type must be valid.) - -
-
-05-26 -
-If the -Base - type is not double, -the compound assignment - operators did not -always allow for double operands. For example, -if -x - had type AD< AD<double> > - -
-     
x += .5;
-
-would slice the value .5 to an int -and then convert it to an AD< AD<double> >. -This has been fixed. -
-
-
This slicing has also been fixed in the -assignment - operation. -In addition, the assignment and copy operations -have been grouped together in the documentation; see ad_ctor - and ad_assign -. - - -
-
-05-25 -
-Document usage of double with -binary arithmetic operators, -and combine all those operators into one section (ad_binary -). -
-
-
The documentation for all the compound assignment - -operators has been grouped together. -In addition, a -compound assignment wish list item has been added -(it was completed and removed with the -05-26 - update.) - - -
-
-05-24 -
-Suppose that -op - is a binary operation and we have - -
-     
left op right
-
-where one of the operands was AD< AD<double> > and -the other operand was double. -There was a bug in this case that caused the double -operand to be converted to int before -being converted to AD< AD<double> >. -This has been fixed. - -
-
-05-22 -
-The Microsoft -examples and testing -project file example/example.vcproj -was missing a reference to the -source code file example/reverse_two.cpp. -This has been fixed. - -
-
-05-08 -
-Reverse mode does not work with the -pow - function when the base is less than or equal zero -and the exponent is an integer. -For this reason, the pow_int - function -is no longer deprecated (and is used by CppAD when the exponent -has type int). - - -
-
-05-05 -
-Third and fourth order derivatives were included in the -routine test_more/sqrt.cpp that tests square roots. -
-
-
The return value descriptions were improved for the introduction -examples: -exp_2_for1 -, -exp_2_for2 -, -exp_eps_for1 -, and -exp_eps_for2 -. -
-
-
The summation index in sqrt_reverse - was changed from - - -k - - - to - - - - - to make partial differentiation -with respect to - -z -( -k -) - - - - - easier to understand. -In addition, a sign error was corrected near the end of -sqrt_reverse -. -
-
-
The dimension for the notation - -X - - - in -reverse_identity - was corrected. -
-
-
The word mega was added to the spelling exception list for -openmp/run.sh. - -
-
-04-19 -
-Improve connection from reverse_identity - theorem -to reverse_any - calculations. -
-
-
Improve the 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. -
-
-
Add the sum_i_inv_time.cpp OpenMP example case. -
-
-
There was a typo in the -second order - discussion -(found by Kipp Martin). -It has been fixed. - - -
-
-04-17 -
-Add a paragraph to reverse_identity - explaining -how it relates to reverse_any - calculations. -Add description of -first - and -second order - -results in reverse_any -. - -
-
-04-14 -
-Simplify the Reverse - mode documentation by creating -a separate reverse_two - section for second order reverse, -making major changes to the description in reverse_any -, -and creating a third order example reverse_checkpoint.cpp - for -reverse mode calculations. -
-
-
Improve the reverse_identity - proof. - -
-
-04-11 -
-Merge in changes made in branches/intro. - -
-
-04-11 -
-Add exp_eps_rev2 - and its verification routine -exp_eps_rev2.cpp -. - -
-
-04-10 -
-Finished off exp_2_rev2 - and -added exp_2_rev2.cpp - which verifies its calculations. -Added second order calculations to exp_2_cppad -. -Added exp_eps_for2 - and its verification routine. - - -
-
-04-07 -
-Added a preliminary version of exp_2_rev2 - -(does not yet have verification or exercises). - -
-
-04-06 -
-Fixed a problem with the Microsoft Visual Studio project file -introduction/exp_apx/exp_apx.vcproj -(it did not track the file name changes of the form -exp_apx/exp_2_for to exp_apx/exp_2_for1 -on 04-05). -
-
-
Added exp_2_for2 - to introduction. - -
-
-04-05 -
-Use order expansions in introduction; e.g., the -second order expansion - -for the exp_2 - example. - -
-
-03-31 -
-Merge in changes made in branches/intro -and remove the corresponding Introduction item from the wish list: - -
-
-03-31 -
-Create the a simpler exponential approximation in the introduction - -called exp_2 - which has a different program -variable for each variable in the operation sequence. -
-
-
Simplify the exp_eps - approximation using the - - -v -1 - -, - -, -v -7 - - - - notation so that variables directly -correspond to index in operation sequence (as with the exp_2 - -example). - -
-
-03-30 -
-The Microsoft project file introduction/exp_apx/exp_apx.vcproj -was referencing exp_apx_ad.cpp which no longer exists. -It has been changed to reference exp_apx_cppad.cpp -which is the new name for that file. - - -
-
-03-29 -
-Fixed entries in this file where the year was mistakenly used for the month. -To be more specific, -07-dd - was changed to -03-dd - -for some of the entries directly below. -
-
-
Corrected some places where CppAD was used in stead of Adolc -in the adolc_poly.cpp - documentation. -
-
-
Added an Introduction and -Tracing - entry to the wish list. -(The Introduction item was completed on 03-31 -.) - -
-
-03-20 -
-Example A.1.1c, example_a11c.cpp, -from the OpenMP 2.5 standards document, -was added to the tests that can be run using openmp/run.sh. - -
-
-03-15 -
-Included the changes from openmp branch -so that so CppAD does not use the OpenMP threadprivate command -(some systems do not support this command). - -
-
-03-15 -
-Add command line arguments to openmp_newton_example.cpp, and -modified openmp/run.sh to allow for more flexible testing. - -
-
-03-14 -
-Fixed some Microsoft compiler warnings by explicitly converting from -size_t to int. -
-
-
In the Microsoft compiler case, the cppad/config.h file had -the wrong setting of GETTIMEOFDAY. -The setting is now overridden (and always false) when the -_MSC_VER preprocessor symbol is defined. -
-
-
Some minor changes were made in an effort to speed up the multi-threading case. - -
-
-03-13 -
-Started a new openmp branch and created a version of CppAD -that does not use the OpenMP threadprivate command -(not supported on some systems). - -
-
-03-09 -
-Included the changes from openmp branch -so that OpenMP can be used with CppAD, -see omp_max_thread -. -The changes -dated between 02-15 - and 03-28 below -were made in the openmp branch and transferred to the trunk on 03-09. - - -
-
-03-28 -
-The conditional include commands were missing on some include files; -for example -
 
-     # ifndef CPPAD_BENDER_QUAD_HPP
-     # define CPPAD_BENDER_QUAD_HPP
-
-was missing at the beginning of the BenderQuad - include file. -This has been fixed. -
-
-
The speed_test routines timing - was -changed to use gettimeofday if it is available. -(gettimeofday measures wall clock time -which is better in a multi-threading environment). -
-
-
Added the user multi-threading interface -omp_max_thread - along with its examples -which are distributed in the directory openmp. -
-
-
The -speed/*.hpp - files have been moved to - -cppad/speed/*.hpp - and the corresponding wish list -item has been removed. -
-
-
The multiple tapes with the same base type wish list item -have been removed (it's purpose was multi-threading which -has been implemented). - - -
-
-02-27 -
-The speed - include files are currently being distributed -above the cppad include directory. -A fix this wish list item has been added. -
-
-
Multiple active tapes required a lot of multi-threading access -management for the tapes. This was made simpler (and faster) -by having at most one tape per thread. - - -
-
-02-22 -
-The include command in the speed_test - documentation was -
 
-     # include <speed/speed_test.hpp>
-
-but it should have been -
 
-     # include <cppad/speed_test.hpp>
-
-This has been fixed. - -
-
-02-17 -
-An entry about optimizing the operation -sequence in an ADFun - object was added to the -wish_list -. -
-
-
Change the argument syntax for Dependent - and deprecate the -old Dependent syntax -. - - -
-
-02-16 -
-Added -VecAD<Base> - as a valid argument type for the -Parameter and Variable - functions. -In addition, size_t indexing - -is was extended to be allowed during taping so long as the -VecAD object is a parameter. - - -
-
-02-15 -
-Fixed the example/test_one.sh script -(it was using its old name one_test). - -
-
-02-06 -
-The BenderQuad - documentation was improved by adding the fact -that the -x - and -y - arguments to the -f.dy - -member function are equal to the -x - and -y - arguments -to BenderQuad. Hence values depending on them can be stored -as private objects in -f - and need not be recalculated. - -
-
-02-04 -
-The method for distributing the documentation needed to be -changed in the top level makefile.am in order to -be compatible with automake version 1.10. - -
-
-02-03 -
-The change on 02-01 - had a new, saved as a static -pointer, with no corresponding delete. -This was not a bug, but it has been changed to avoid -an error message when using CppAD with -valgrind -. -
-
-
The change to the pow function on -06-12-10 - did not include the -necessary changes to the sparsity calculations. -This has been fixed. - -
-
-02-02 -
-Fix minor errors and improve -profiling - documentation. -Also change the problem sizes used for the speed - tests. - -
-
-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 -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. - -
-
-01-29 -
-The copyright message was missing from some of the distribution files -for some new files added on 06-12-15 -. -This resulted in the -tarballs -*.tgz - and -*.zip - -not existing for a period of time. -The automated tests have been extended so that this should not happen again. - - -
Input File: omh/appendix/whats_new/whats_new_07.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_07_xml.js cppad-2019.02.00.0/doc/_whats_new_07_xml.js --- cppad-2018.00.00.0/doc/_whats_new_07_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_07_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,184 +0,0 @@ -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_07.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_07.xml#Introduction', -'whats_new_07.xml#12-29', -'whats_new_07.xml#12-25', -'whats_new_07.xml#12-21', -'whats_new_07.xml#12-08', -'whats_new_07.xml#12-05', -'whats_new_07.xml#12-04', -'whats_new_07.xml#12-03', -'whats_new_07.xml#12-02', -'whats_new_07.xml#11-29', -'whats_new_07.xml#11-23', -'whats_new_07.xml#11-18', -'whats_new_07.xml#11-06', -'whats_new_07.xml#11-05', -'whats_new_07.xml#11-04', -'whats_new_07.xml#11-03', -'whats_new_07.xml#11-02', -'whats_new_07.xml#11-01', -'whats_new_07.xml#10-30', -'whats_new_07.xml#10-27', -'whats_new_07.xml#10-23', -'whats_new_07.xml#10-22', -'whats_new_07.xml#10-16', -'whats_new_07.xml#10-13', -'whats_new_07.xml#10-05', -'whats_new_07.xml#10-02', -'whats_new_07.xml#09-06', -'whats_new_07.xml#08-09', -'whats_new_07.xml#08-07', -'whats_new_07.xml#07-30', -'whats_new_07.xml#07-29', -'whats_new_07.xml#07-28', -'whats_new_07.xml#07-26', -'whats_new_07.xml#07-26.07-26', -'whats_new_07.xml#07-26.07-25', -'whats_new_07.xml#07-23', -'whats_new_07.xml#07-22', -'whats_new_07.xml#07-21', -'whats_new_07.xml#07-20', -'whats_new_07.xml#07-19', -'whats_new_07.xml#07-18', -'whats_new_07.xml#07-14', -'whats_new_07.xml#07-13', -'whats_new_07.xml#06-22', -'whats_new_07.xml#06-20', -'whats_new_07.xml#06-14', -'whats_new_07.xml#05-26', -'whats_new_07.xml#05-25', -'whats_new_07.xml#05-24', -'whats_new_07.xml#05-22', -'whats_new_07.xml#05-08', -'whats_new_07.xml#05-05', -'whats_new_07.xml#04-19', -'whats_new_07.xml#04-17', -'whats_new_07.xml#04-14', -'whats_new_07.xml#04-11', -'whats_new_07.xml#04-11.04-11', -'whats_new_07.xml#04-11.04-10', -'whats_new_07.xml#04-11.04-07', -'whats_new_07.xml#04-11.04-06', -'whats_new_07.xml#04-11.04-05', -'whats_new_07.xml#03-31', -'whats_new_07.xml#03-31.03-31', -'whats_new_07.xml#03-31.03-30', -'whats_new_07.xml#03-29', -'whats_new_07.xml#03-20', -'whats_new_07.xml#03-15', -'whats_new_07.xml#03-15.03-15', -'whats_new_07.xml#03-15.03-14', -'whats_new_07.xml#03-15.03-13', -'whats_new_07.xml#03-09', -'whats_new_07.xml#03-09.03-28', -'whats_new_07.xml#03-09.02-27', -'whats_new_07.xml#03-09.02-22', -'whats_new_07.xml#03-09.02-17', -'whats_new_07.xml#03-09.02-16', -'whats_new_07.xml#03-09.02-15', -'whats_new_07.xml#02-06', -'whats_new_07.xml#02-04', -'whats_new_07.xml#02-03', -'whats_new_07.xml#02-02', -'whats_new_07.xml#02-01', -'whats_new_07.xml#01-29' -]; -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-2018.00.00.0/doc/whats_new_08.xml cppad-2019.02.00.0/doc/whats_new_08.xml --- cppad-2018.00.00.0/doc/whats_new_08.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_08.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,870 +0,0 @@ - - - -Changes and Additions to CppAD During 2008 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_08 - -

- - - -
Changes and Additions to CppAD During 2008
-
-Introduction -
-This section contains a list of the changes to CppAD during 2008 -(in reverse order by date). -The purpose of this section is to -assist you in learning about changes between various versions of CppAD. - -
-
-12-19 -
-In the documentation for pow_int - change the integer exponent -from -int y - to -const int &y -. -In the implementation for pow - make the integer base case -agree with the documentation; i.e., change -from -int x - to -const int &x -. - -
-
-12-14 -
-Added another test of mul_level - calculations (in the -test_more directory). - -
-
-12-04 -
-Extensive explanation for the ipopt_cppad/ipopt_cppad_ode example was -provided in the section ipopt_cppad_ode -. - -
-
-11-22 -
-The CppAD interface to the Ipopt nonlinear programming solver -cppad_ipopt_nlp - -has been moved from example/ipopt_cppad_nlp to -ipopt_cppad/ipopt_cppad_nlp. - -
-
-11-21 -
-The Microsoft's Visual C++ Version 9.0 generates a warning of the form - -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 -these inline directives are converted to -empty code when a Microsoft Visual C++ is used. - - -
-
-11-20 -
-The function -tanh(x) - was added to the -unary_standard_math - functions. -The abs and erf functions were removed from the -Base requirements -. -The restrictions about the Base class were removed from -abs -, atan2 -, LuRatio -, erf -. -
-
-
Visual Studio Version 9.0 could not handle the large number of static -constants in the CppAD erf - function. -This function was changed to a simpler representation -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. - -
-
-10-27 -
-Change prototypes for ipopt_cppad/ipopt_cppad_ode helper routines -to use const (where appropriate). - -
-
-10-17 -
-Major improvements to the ipopt_cppad/ipopt_cppad_ode example. - -
-
-10-16 -
-Minor improvement to description of optimization argument in -ipopt_cppad/ipopt_cppad_ode. - -
-
-09-30 -
-Add or modify some wish list entries; see -cppad_ipopt_nlp (since removed), -multiple argument forward (completed with forward_dir -), -and sparsity patterns -(sparsity patterns - has been fulfilled). - - -
-
-09-26 -
-Use parenthesis and brackets to group terms of the form - - -m -× -I - - - to make the documentation of -ipopt_cppad_nlp - easier to read. - -Changed ipopt_cppad/ipopt_cppad_ode to use - -y -( -t -) - - - for -the solution of the ODE to distinguish it for - -x - - -, -the vector we are optimizing with respect to. - -
-
-09-18 -
-Changed ipopt_cppad/ipopt_cppad_ode to a case where - -x -( -t -) - - - -is a pair of exponential functions instead of a linear and quadratic. -Fixed some of the comments in this example and included the source -code in the documentation (which was missing by mistake). - -
-
-09-17 -
-Changed ipopt_cppad/ipopt_cppad_ode to a case where there are -two components in the ODE (instead of one). -Also removed an initialization section that was only intended for tests -with a specific initial value. - -
-
-09-16 -
-Add ipopt_cppad/ipopt_cppad_ode, an example and test -that optimizes the solution of an ODE. -Change r_eval to eval_r in ipopt_cppad_nlp -. -Fix a dimension of u_ad error in ipopt_cppad_nlp. - -
-
-09-12 -
-Converted from storing full Hessian and Jacobian to a sparse data structure -in ipopt_cppad_nlp -. -This greatly reduced the memory requirements (and increased the speed) -for sparse problems. - -
-
-09-10 -
-Fixed more indexing bugs in ipopt_cppad_nlp - -that effected cases where the domain index vector - -J -k -, - - - - - - -was different for different values of - -k - - - and - - - - -. -
-
-
In ipopt_cppad_nlp -, -combined -fg_info->domain_index() - and - -fg_info->range_index() - into a single function called - -fg_info->index() -. -Also added more error checking (if NDEBUG is not defined). - -
-
-09-09 -
-Fixed an indexing bug in ipopt_cppad_nlp -. -(This effected cases where the domain index vector - -J -k -, - - - - - - -was different for different values of - -k - - - and - - - - -.) - -
-
-09-07 -
-Change ipopt_cppad_nlp - so that object and constraints -are expressed as the double summation of simpler functions. -This is more versatile that the single summation representation. - -
-
-09-06 -
-Checked in a major change to ipopt_cppad_nlp - -whereby the object and constraints can be expressed as the -sum of simpler functions. -This is the first step in what will eventually be a more versatile -representation. - -
-
-09-05 -
-Fix bug in ipopt_cppad_nlp - (not recording the function -at the proper location. Here is the difference that occurred -multiple places in the ipopt_cppad/ipopt_cppad_nlp.cpp source: -
 
-     for(j = 0; j < n_; j++)
--         x_ad_vec[0] = x[j];
-+         x_ad_vec[j] = x[j];
-
-This did not show up in testing because there currently is no test of -ipopt_cppad_nlp where the operation sequence depends -on the value of - -x - - -. -
-
-
Changed eval_grad_f in ipopt_cppad_nlp.cpp -to be more efficient. - -
-
-09-04 -
-The ipopt_cppad_nlp - interface has been changed to use -a derived class object instead of a pointer to a function. - -
-
-09-03 -
-The ipopt_cppad_nlp - interface has been changed to use -size_t instead of Ipopt::Index. - -
-
-09-01 -
-Back out the changes made to ipopt_cppad_nlp - on 08-29 -(because testing proved the change to be less efficient in the case -that motivated the change). - -
-
-08-29 -
-The push_vector member function was missing from the -vectorBool - class. -This has been fixed. -In addition, it seems that for some cases (or compilers) -the assignment - -
-     
x[i] = y[j]
-
-did not work properly when both -x - and -y - -had type vectorBool. -This has been fixed. -
-
-
The ipopt_cppad_nlp - example has been extended -so that it allows for both scalar and vector evaluation of the -objective and constraints; see the argument -fg_vector - in -ipopt_cppad_nlp -. -In the case where there is not a lot of common terms -between the functions, the scalar evaluation may be more efficient. - -
-
-08-19 -
-Add push of a vector - -to the CppAD::vector template class. -This makes it easy to accumulate multiple scalars and -simple vectors - into one large CppAD::vector. - -
-
-08-08 -
-There was an indexing bug in the -ipopt_cppad_nlp - example -that affected the -retape - equal to false case. -This has been fixed. -In addition, the missing - -retape - documentation was added. - -
-
-07-02 -
-Extend configure - command to check for -extras libraries that are necessary for linking the ipopt example. - -
-
-06-18 -
-Add specifications for the Ipopt class ipopt_cppad_nlp -. -This is only an example class it may change with future -versions of CppAD. - -
-
-06-15 -
-The nonlinear programming example ipopt_nlp_get_started.cpp - was added. -This is a preliminary version of this example. - -
-
-06-11 -
-The sparsity pattern for the Hessian was being calculated each time -by SparseHessian -. -This is not efficient -when the pattern does not change between calls to SparseHessian. -An optional sparsity pattern argument was added to SparseHessian -so that it need not be recalculated each time. - -
-
-06-10 -
-The sparsity pattern for the Jacobian was being calculated each time -by SparseJacobian -. -This is not efficient -when the pattern does not change between calls to SparseJacobian. -An optional sparsity pattern argument was added to SparseJacobian -so that it need not be recalculated each time. - -
-
-05-08 -
-The sparse_jacobian - routine has been added. -
-
-
The example in sparse_hessian - pointed to hessian.cpp - -instead of sparse_hessian.cpp -. -This has been fixed. - -
-
-05-03 -
-The retape flag has been added to speed_main -. -In addition the routines -link_det_minor -, link_poly -, and link_ode - -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 following tests use this flag: -adolc_det_minor.cpp -, -cppad_det_minor.cpp -, -cppad_ode.cpp -, -adolc_poly.cpp -, -cppad_poly.cpp -. -
-
-
Create specialized zero order forward mode routine that should be faster, -but does not test out as faster under cygwin g++ (GCC) 3.4.4. - - - - -
-
-04-20 -
-Added the ode_evaluate - speed test utility in -preparation for having ode speed tests. -Created ode speed test for the cppad and double -cases; see speed_main -. -In addition, -added the examples ode_evaluate.cpp - and sparse_hessian.cpp -. -
-
-
Changed the speed_main - routines defined for each package -from -compute_name - to -link_name -. -For example, in speed/cppad/det_minor.cpp, -the function name -compute_det_minor was changed to link_det_minor. - - -
-
-04-18 -
-Fix a problem in the link_poly - correctness test. -Also add double_sparse_hessian.cpp - to the set -speed and correctness tests (now available). - - -
-
-04-10 -
-Change all the -Adolc speed - examples to use -TrackNewDel - instead of using new and delete -directly. -This makes it easy to check for memory allocation errors and leaks -(when NDEBUG is not defined). -Also include in documentation sub functions that indicate -the sparse_hessian speed test is not available for -double_sparse_hessian.cpp -, -fadbad_sparse_hessian.cpp -, and -sacado_sparse_hessian.cpp -. - -
-
-04-06 -
-The following wish list - -entry has been completed and removed from the list: -"Change private member variables names -(not part of the user interface) -so that they all end with an underscore." - -
-
-04-04 -
-Fix a problem compiling the speed test -main - program with gcc 4.3. - -
-
-03-27 -
-Corrected cppad_sparse_hessian.cpp - -so that it uses the sparse case when -USE_CPPAD_SPARSE_HESSIAN is 1. -Also added a wish list sparsity pattern entry -(the sparsity pattern - entry -has been fulfilled). -
-
-
Change the name of speedtest.cpp to speed_program.cpp -. - - -
-
-02-05 -
-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 -speed/cppad, speed/double, and speed/example -were missing. This has also been fixed. - -
-
-02-03 -
-There was an ambiguity problem -(detected by g++ 4.3) with the following operations - -
-     
x op y
-
-where -x - and -y - were AD<double> and - -op - was a member operator of that class. -This has been fixed by making all such member functions friends -instead of members of AD<double>. -
-
-
Remove compound assignment entry from wish list -(it was fixed on 2007-05-26 -). -Add an expression hashing entry to the wish_list - -(it has since been removed). -Add Library and Scripting Languages to the wish list -(this has since been fulfilled by the example ad_in_c.cpp -). - -
-
-01-26 -
-The LuFactor - routine gave a misleading error message -when the input matrix had not a number or infinity in it. -This has been fixed. - -
-
-01-24 -
-The postfix_dir - -has been added to the configure command line options. - -
-
-01-21 -
-A sparse Hessian case was added to the speed - tests; see -sparse_hessian -. - -
-
-01-20 -
-CppAD can now be installed using yum on -Fedora operating systems. - - -
-
-01-11 -
-The CppAD correctness tests assume that machine epsilon is less -than 1e-13. A test for this has been added to the -test_more/test_more program. - -
-
-01-08 -
-Added a sparse_hessian - routine and -extended Hessian - to allow for a weight vector -w - -instead of just one component -l -. - - -
Input File: omh/appendix/whats_new/whats_new_08.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_08_xml.js cppad-2019.02.00.0/doc/_whats_new_08_xml.js --- cppad-2018.00.00.0/doc/_whats_new_08_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_08_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,149 +0,0 @@ -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_08.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_08.xml#Introduction', -'whats_new_08.xml#12-19', -'whats_new_08.xml#12-14', -'whats_new_08.xml#12-04', -'whats_new_08.xml#11-22', -'whats_new_08.xml#11-21', -'whats_new_08.xml#11-20', -'whats_new_08.xml#10-27', -'whats_new_08.xml#10-17', -'whats_new_08.xml#10-16', -'whats_new_08.xml#09-30', -'whats_new_08.xml#09-26', -'whats_new_08.xml#09-18', -'whats_new_08.xml#09-17', -'whats_new_08.xml#09-16', -'whats_new_08.xml#09-12', -'whats_new_08.xml#09-10', -'whats_new_08.xml#09-09', -'whats_new_08.xml#09-07', -'whats_new_08.xml#09-06', -'whats_new_08.xml#09-05', -'whats_new_08.xml#09-04', -'whats_new_08.xml#09-03', -'whats_new_08.xml#09-01', -'whats_new_08.xml#08-29', -'whats_new_08.xml#08-19', -'whats_new_08.xml#08-08', -'whats_new_08.xml#07-02', -'whats_new_08.xml#06-18', -'whats_new_08.xml#06-15', -'whats_new_08.xml#06-11', -'whats_new_08.xml#06-10', -'whats_new_08.xml#05-08', -'whats_new_08.xml#05-03', -'whats_new_08.xml#04-20', -'whats_new_08.xml#04-18', -'whats_new_08.xml#04-10', -'whats_new_08.xml#04-06', -'whats_new_08.xml#04-04', -'whats_new_08.xml#03-27', -'whats_new_08.xml#02-05', -'whats_new_08.xml#02-03', -'whats_new_08.xml#01-26', -'whats_new_08.xml#01-24', -'whats_new_08.xml#01-21', -'whats_new_08.xml#01-20', -'whats_new_08.xml#01-11', -'whats_new_08.xml#01-08' -]; -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-2018.00.00.0/doc/whats_new_09.xml cppad-2019.02.00.0/doc/whats_new_09.xml --- cppad-2018.00.00.0/doc/whats_new_09.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_09.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1029 +0,0 @@ - - - -Changes and Additions to CppAD During 2009 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_09 - -

- - - -
Changes and Additions to CppAD During 2009
-
-Introduction -
-This section contains a list of the changes to CppAD during 2009 -(in reverse order by date). -The purpose of this section is to -assist you in learning about changes between various versions of CppAD. -(Comments about developer documentation are only important if you are -trying to read and understand the CppAD source code.) - -
-
-12-23 -
-The -ADFun assignment operator - -was changed so that it now copies forward mode -Taylor coefficients and sparsity pattern information. -(This assignment operator was added on 10-24 -.) -You can use capacity_order - to delete the Taylor coefficients -before copying them. -Two new functions were added so that you can query and delete the -forward mode sparsity information; -see -size_forward_bool - and -size_forward_set -. - -
-
-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 -for forward and reverse mode computations of an optimized tape. - -
-
-12-18 -
-It turns out that detection of a sequence of additions makes the optimization -longer. This was simplified and makes slightly faster by converting two -jointly recursive routines to one non-recursive routine that uses a -stack for the necessary information. -More work is planned to make this optimization faster. - -
-
-12-12 -
-Detection of a sequence of additions that can be converted to one variable -during the optimize - process. -This leads to a significant improvement in the tape size and speed. - -
-
-12-04 -
-Change hash coding of parameter values as part of operators -during the optimize - process. -This should leads to more detection and removal of duplicate operations. - -
-
-12-02 -
-Fix minor grammatical error in the Purpose heading -for conditional expressions -. -
-
-
Add the following functions: -size_op -, -size_op_arg -, -and -size_op_seq -. -In addition, improve and extend the -seq_property.cpp - example. - -
-
-11-28 -
-Fix bug in tape optimization with VecAD - objects. - -
-
-11-27 -
-Remove duplicate expressions for the commutative binary operators; i.e., -addition and multiplication. - -
-
-11-26 -
-Improve optimize - command so that it removes some duplicate -expressions from the tape (more of this is planned). - -
-
-10-30 -
-Make program that check Ipopt ODE example correctness -a separate file ipopt_nlp_ode_check.cpp - -Split out Ipopt driver for ODE example ipopt_nlp_ode_run.hpp -. -Add the speed testing problem ipopt_cppad/ipopt_ode_speed.cpp. - -
-
-10-29 -
-Split out the -ode inverse problem -, -its simple representation -, -and -its fast representation -, -as a separate files; to be specific, -ipopt_nlp_ode_problem.hpp -, -ipopt_nlp_ode_simple.hpp -, -ipopt_nlp_ode_fast.hpp -, -and -ipopt_nlp_ode_check.cpp -. - -
-
-10-28 -
-Improve the documentation for ipopt_nlp_ode_simple - and -ipopt_nlp_ode_fast -. - -
-
-10-27 -
-Moved old ipopt_cppad_simple.cpp to ipopt_nlp_get_started.cpp -, -created the example ipopt_nlp_ode_simple.hpp -, -and split and ipopt_cppad_ode.cpp -into ipopt_nlp_ode_fast.hpp - and ipopt_nlp_ode_check.cpp -. - -
-
-10-24 -
-Added the assignment operator - -to the ADFun object class. -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 ADFun -copy constructor - -and generates an error message if it is used. - -
-
-10-23 -
-The sparse_hessian - routine was extended so the user can now choose -between vectors of sets and boolean vectors for representing -sparsity patterns -. - -
-
-10-21 -
-The CheckSimpleVector - function was extended so that -it can check simple vectors where the elements of the vector -can not be assigned to integer values. -This was done by adding the x, y - -arguments to CheckSimpleVector. - -
-
-10-16 -
-The sparse_jacobian - routine was extended so the user can now choose -between vectors of sets and boolean vectors for representing -sparsity patterns -. - -
-
-10-14 -
-The -packed - parameter for the sparsity routines -ForSparseJac -, RevSparseJac -, and RevSparseHes - -(introduced on 09-26 -) has been removed. -It has been replaced by changing the argument and return values -to be more versatile. -To be specific, they can now represent sparsity -using vectors of std::set<size_t> -instead of just as vectors of bool -(see sparsity patterns -). - -
-
-10-03 -
-The Microsoft Visual Studio project files for -examples and testing -and for -more correctness testing -were not including some new tests in their builds. -This has been fixed. - -
-
-09-30 -
-Added the cppad_sparse_jacobian.cpp - speed test -and increased the sizes used by link_sparse_hessian -. -Some mistakes were fixed in the documentation for speed tests -link_sparse_hessian - and sparse_hes_fun -. - -
-
-09-29 -
-The documentation definition of the function - -H -( -x -) - - - in -RevSparseHes - was missing a factor of - -R - - -. -This has been fixed. - -
-
-09-28 -
-Changed RevSparseHes - so that it uses a sparse -representation when the corresponding call to -ForSparseJac - used a sparse representation. -This should have been included with the change on 09-26 -because Hessian sparsity patters after ForSparseJac -with -packed - did not work. -Thus, this could be considered a bug fix. - -
-
-09-26 -
-Added the packed parameter to -ForSparseJac - and RevSparseJac -. -If -packed - is false, -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. -The functions ForSparseJac and RevSparseJac -return packed representations. -The plan is to eventually provide new member functions that return -sparse representations. - -
-
-09-20 -
-Fixed a bug in the Hessian Sparsity - calculations -that included use of VecAD - objects. - -
-
-09-19 -
-Some more memory allocation improvements (related to those -on 09-18) were made. - -
-
-09-18 -
-A bug was found in all the sparsity_pattern - calculations. -The result was that eight times the necessary memory was being used -during these calculations. This has been fixed. - - -
-
-08-25 -
-Add ad_fun.cpp - -an example of how to create your own interface to an ADFun - object. - -
-
-08-14 -
-Add ad_in_c.cpp - -an example of how to link CppAD to other languages. - -
-
-08_13 -
-Add an option to optimize - an operation sequence. -
-
-
Begin Merge -
-
of changes from the directory branches/optimize -in the CppAD subversion repository. -The subheading dates below represent when the correspond change was made in -branches/optimize. - -
-
-08-13 -
-An automatic check of the forward_zero - results was added -after each call to f.optimize() - -(this check - -is skipped when NDEBUG is defined). -In addition, all of the -speed/cppad/*.cpp - tests -now check and use the speed test -optimize - flag. - -
-
-08-11 -
-Change the speed test main program - so -that it uses a list of options instead of a boolean flag for each option. -This will make it possible to add options in the future with out -having to change all the existing tests because the options are now -global variables instead of arguments to the speed test routines; for example, -see retape speed test option. - -
-
-08-10 -
-The routine for optimizing - the operation sequence -has been added has been further tested using test_more/optimize.cpp. -Some bugs have been fix and the routine can -now be trusted to work correctly. -
-
-
The function -size_VecAD - function was added -so that the user could see the VecAD vectors -and elements corresponding to an operation sequence. - -
-
-08-09 -
-A routine for optimizing - the operation sequence -has been added. -This is a preliminary version and needs more testing before it can -be trusted to work correctly. -
-
End Merge - - -
-
-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 -size_par - was added -so that the user could see the number of parameters -corresponding to an operation sequence. - -
-
-08-02 -
-Fix bug in new version of how ForSparseJac - handles -VecAD - objects. -
-
-
Fix bug in overnight build where HTML version and entire documentation -as one page versions of documentation were not being built. -
-
-
Fix missing new line under -Using Value - -heading for simple vector documentation. - -
-
-08-01 -
-Fix bug in reverse mode Jacobian sparsity - -for VecAD - objects. - -
-
-07-31 -
-The forward - and reverse - -sparse Jacobian routines have been improved so the resulting sparsity -patterns are valid for all values of the independent variables -(even if you use CondExp - or VecAD -). - -
-
-07-26 -
-Convert developer documentation from -forward and reverse mode sweep routines from OMhelp to doxygen. - -
-
-07-25 -
-Add developer documentation for PrintFor - operations. - -
-
-07-24 -
-Add developer documentation for Discrete - operations. - -
-
-07-23 -
-Add developer documentation for tape evaluation of VecAD - store -operations. (a store operation changes the value of a VecAD element). -
-
-
Improve the vec_ad.cpp - user example. - -
-
-07-06 -
-Fixed a bug in second or higher order reverse mode calculations -that used VecAD -. -This bug was demonstrated by the test case SecondOrderReverse -in the file test_more/vec_ad.cpp. -
-
-
Add developer documentation for tape evaluation of the -VecAD load operations -(a load operation accesses an element of the vector but -does not change it.) -
-
-
Fix isnan undefined in example/cond_exp.cpp error -introduced on 07-04 change. - -
-
-07-04 -
-Add developer documentation for the -CompareChange - operations during tape evaluation. -
-
-
Begin Merge -
-
of changes from the directory branches/sweep -in the CppAD subversion repository. -The subheading dates below represent when the correspond change was made in -branches/sweep. - -
-
-07-04 -
-Fixed a bug in second or higher order reverse mode calculations -that included conditional expressions -. -This bug was demonstrated by the test case SecondOrderReverse -in the file test_more/cond_exp.cpp. -
-
-
A simpler and useful example was provided for -conditional expressions -; -see cond_exp.cpp -. - - -
-
-07-03 -
-Some minor improvements were made to the documentation for -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. - -
-
-07-02 -
-Add developer doxygen documentation of -tape evaluation for power (exponentiation) operators. - -
-
-07-01 -
-Fix an example indexing error in -introduction/exp_apx/exp_eps_for2.cpp (found by valgrind). -
-
-
Add developer doxygen documentation of -tape evaluation for multiplication and division operators. - -
-
-06-30 -
-Add developer doxygen documentation of -tape evaluation for addition and subtraction operators. - -
-
-06-29 -
-Add developer doxygen documentation of -tape evaluation for sin, sinh, cos, and cosh. - -
-
-06-28 -
-Add developer doxygen documentation of -tape evaluation for atan, asin, acos, sqrt, log. -
-
End Merge - -
-
-06-25 -
-The tarball for most recent release (of the subversion trunk for CppAD) -was not being placed in the -download - -directory. -This has been fixed. - -
-
-06-22 -
-Fix compiler warnings during the openmp/run.sh test. -
-
-
Changed speed_example.cpp - to omit the speed_test from -the correctness result. -In stead, a message is printed explaining that timing tests need -to be run without a lot of other demands on the system. - -
-
-06-21 -
-The configure instructions for ipopt_dir - -had the wrong path for IpIpoptApplication.hpp. -This has been fixed. - -
-
-06-20 -
-Upgrade to from autoconf 2.61 to 2.63, -and from automake 1.10.1 to 1.11. -
-
-
Fix conflict between CppAD's use of config.h preprocessor symbols -and other packages use of the same symbol names. - -
-
-06-06 - -
  1. -Using complex of an AD type (instead of AD of complex) was not working -correctly in not_complex_ad.cpp because the -default constructor - 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 not_complex_ad.cpp example has been removed; -see complex FAQ -.) -
  2. - -Fixing the not_complex_ad.cpp problem above also fixed a warning -generated by valgrind -. -Now valgrind runs the CppAD example/example program -with out any warning or error messages. -In addition, a minor initialization error was fixed in the -test_more/jacobian.cpp routine so now -valgrind also runs the CppAD test_more/test_more program -with out any warnings or error messages. -
- - -
-
-05-20 -
-A change was make to the trunk on 05-19 (svn revision 1361) that broke the -Unix install - procedure. -This was has been fixed (revision 1362). - -
-
-03-24 -
-Added cross references in -the examples - to occurrence of the following tokens: -AD -, -ADFun -, -CPPAD_TEST_VECTOR -, -Forward -, -Independent -, -Jacobian - -NearEqual -, -Reverse -. - -
-
-02-20 -
-Demonstrate using AD to compute the derivative -of the solution of an ODE with respect to a parameter -(in the runge45_2.cpp - example). - -
-
-02-15 -
-Change the distribution -compressed tar file - -to only contain one copy of the documentation. -Link to the current Internet documentation for the other three copies. - - -
-
-02-01 -
-Move the Prev and Next buttons at the top of the documentation -to the beginning so that their position does not change between sections. -This makes it easier to repeatedly select this links. - - -
-
-01-31 -
-Modify cppad/local/op_code.hpp to avoid incorrect warning by -g++ version 4.3.2 when building pycppad (a python interface to CppAD). - -
-
-01-18 -
-Sometimes an error occurs while taping AD operations. -The abort_recording - function has been added -to make it easier to recover in such cases. -
-
-
Previously, CppAD speed and comparison tests used Adolc-1.10.2. -The version used in the tests has been upgraded to -Adolc-2.0.0. - -
-
-
A discussion has been added to the documentation for Jacobian - -about its use of -forward or reverse - -mode depending on which it estimates is more efficient. -
-
-
A minor typo has been fixed in the description of -W(t, u) in reverse_any -. -To be specific, - - -o -( -t -p --1 - - -) -* -t -1 -- -p - - - -0 - - - -has been replaced by - - -o -( -t -p --1 - - -) -/ -t -1 -- -p - - - -0 - - -. - -
-
-01-06 -
-Made some minor improvements to the documentation in -FunConstruct -. - - -
Input File: omh/appendix/whats_new/whats_new_09.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_09_xml.js cppad-2019.02.00.0/doc/_whats_new_09_xml.js --- cppad-2018.00.00.0/doc/_whats_new_09_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_09_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,165 +0,0 @@ -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_09.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_09.xml#Introduction', -'whats_new_09.xml#12-23', -'whats_new_09.xml#12-22', -'whats_new_09.xml#12-18', -'whats_new_09.xml#12-12', -'whats_new_09.xml#12-04', -'whats_new_09.xml#12-02', -'whats_new_09.xml#11-28', -'whats_new_09.xml#11-27', -'whats_new_09.xml#11-26', -'whats_new_09.xml#10-30', -'whats_new_09.xml#10-29', -'whats_new_09.xml#10-28', -'whats_new_09.xml#10-27', -'whats_new_09.xml#10-24', -'whats_new_09.xml#10-23', -'whats_new_09.xml#10-21', -'whats_new_09.xml#10-16', -'whats_new_09.xml#10-14', -'whats_new_09.xml#10-03', -'whats_new_09.xml#09-30', -'whats_new_09.xml#09-29', -'whats_new_09.xml#09-28', -'whats_new_09.xml#09-26', -'whats_new_09.xml#09-20', -'whats_new_09.xml#09-19', -'whats_new_09.xml#09-18', -'whats_new_09.xml#08-25', -'whats_new_09.xml#08-14', -'whats_new_09.xml#08_13', -'whats_new_09.xml#08_13.08-13', -'whats_new_09.xml#08_13.08-11', -'whats_new_09.xml#08_13.08-10', -'whats_new_09.xml#08_13.08-09', -'whats_new_09.xml#08-06', -'whats_new_09.xml#08-02', -'whats_new_09.xml#08-01', -'whats_new_09.xml#07-31', -'whats_new_09.xml#07-26', -'whats_new_09.xml#07-25', -'whats_new_09.xml#07-24', -'whats_new_09.xml#07-23', -'whats_new_09.xml#07-23.07-06', -'whats_new_09.xml#07-04', -'whats_new_09.xml#07-04.07-04', -'whats_new_09.xml#07-04.07-03', -'whats_new_09.xml#07-04.07-02', -'whats_new_09.xml#07-04.07-01', -'whats_new_09.xml#07-04.06-30', -'whats_new_09.xml#07-04.06-29', -'whats_new_09.xml#07-04.06-28', -'whats_new_09.xml#06-25', -'whats_new_09.xml#06-22', -'whats_new_09.xml#06-21', -'whats_new_09.xml#06-20', -'whats_new_09.xml#06-06', -'whats_new_09.xml#05-20', -'whats_new_09.xml#03-24', -'whats_new_09.xml#02-20', -'whats_new_09.xml#02-15', -'whats_new_09.xml#02-01', -'whats_new_09.xml#01-31', -'whats_new_09.xml#01-18', -'whats_new_09.xml#01-06' -]; -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-2018.00.00.0/doc/whats_new_10.xml cppad-2019.02.00.0/doc/whats_new_10.xml --- cppad-2018.00.00.0/doc/whats_new_10.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_10.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,606 +0,0 @@ - - - -Changes and Additions to CppAD During 2010 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_10 - -

- - - -
Changes and Additions to CppAD During 2010
-
-Introduction -
-This section contains a list of the changes to CppAD during 2010 -(in reverse order by date). -The purpose of this section is to -assist you in learning about changes between various versions of CppAD. - -
-
-12-31 - -
  1. -Add specifications for the CppAD pkgconfig - files. -
  2. - -Update the CppAD README file. -
  3. - -Move most all CppAD development shell scripts to the bin -subdirectory of the distribution directory. -
  4. - -Fix warnings generated by the g++ compiler option -Wshadow; -for example, - -sparse_pack.hpp:101:2: warning: declaration of 'end' shadows a member of 'this' - -
- - -
-
-11-27 -
-If NDEBUB was defined, -the default CppAD error handler - would return -because its assert had no effect in this case. -This has been fixed by placing a call to std::exit(1) -after its assert. - -
-
-09-26 -
-There was a bug -(introduced on 09-22) -in make test -when the configure command was executed from a directory -other than the distribution directory -(the cppad_ipopt_nlp - did not build). -This has been fixed. - - -
-
-09-22 -
-Promote cppad_ipopt_nlp - from an example to a library -that gets installed -(provided that the ipopt_dir - -is specified on the configure command line). - -
-
-08-21 -
-Fix problems with linking of cppad_ipopt_nlp - test with -both older and newer versions of ipopt. - -
-
-07-14 -
-The new versions of ipopt use pkg-config to record the location -where its necessary libraries are stored on the system. -The cppad configure - command has -been improved so that it can work both with versions of ipopt that use -pkg-config and ones that don't. - -
-
-07-11 -
-Old versions of the ipopt library were located in - -ipopt_dir/lib/libipopt.* - -(see ipopt_dir -), -but newer versions will be located in - -ipopt_dir/lib/coin/libipopt.* -. -The directory -ipopt_dir/lib/coin - has been added to the library -search path so that the -cppad_ipopt_nlp examples - -work with both old and new versions of ipopt. - -
-
-06-01 -
-In the case where the preprocessor symbol NDEBUG was defined -(see speed -), -the function - -
-     CheckSimpleVector(const 
Scalarx, const Scalary)
-
-was not defined; see -bug report -. -This has been fixed. - -
-
-04-28 -
-Change the multi-level taping examples -mul_level.cpp - and mul_level_adolc.cpp - -to be more efficient. - -
-
-04-26 -
-Include Blas and Linpack libraries in makefile links for -cppad_ipopt_nlp - examples. -This removes the need to use get.Blas when building Ipopt. -
-
-
The speed test in cppad_ipopt/speed was missing -a link to the library ../src/libcppad_ipopt.a. -This has been fixed. - -
-
-04-24 -
-There was a bug in the error checking done by cppad/local/sub_op.hpp -that caused the following improper abort: - -
-Error detected by false result for
-    arg[1] < i_z
-at line 337 in the file
-    
.../include/cppad/local/sub_op.hpp
-
-This was fixed in the trunk. -It was also fixed in the release with version number 20100101.3 -which can be downloaded from the CppAD -download directory -. - - -
-
-04-01 -
-Some of the speed_utility - library -(in speed/src) was being compiled for debugging. -This has been changed and they are now compiled with debugging off -and optimization on. - -
-
-03-11 -
-The old reverse_any - example was moved to reverse_three.cpp -, -the old checkpoint example is now the general case reverse example, -and a better checkpoint.cpp/ example was created. - -
-
-03-10 -
-The optimize - routine would mistakenly remove some -expressions that depended on the independent variables and that -affected the result of certain CondExp - operations. -This has been fixed. - -
-
-03-09 -
-Extend reverse_any - so that it can be used for -checkpointing -; i.e., -splitting reverse mode calculations at function composition points. - -
-
-03-03 -
-Fixed a bug in handling -vector of boolean - -sparsity patterns. -(when the number of elements per set was a multiple of -sizeof(size_t)). - -
-
-02-11 -
-The speed directory has been reorganized and the -common part of the link functions -, -as well as the microsoft_timer -, -have been moved to the subdirectory speed/src -where a library is built. - -
-
-02-08 -
-A bug was introduced in the 02-05 - -change whereby the make command tried to build the -libcppad_ipopt.a library even if IPOPT_DIR was -not specified on the configure - command line. -This has been fixed. - -
-
-02-06 -
-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 -format.) -
-
-
Add an automated check for optimize - bug -fixed on 02-05. -(Automatic checking for PrintFor - bug was added on 02-05.) - -
-
-02-05 - -
  1. -Simplify running all the tests by adding the -make test command. -
  2. - -Simplify the configure - command by removing -need for: ---with-Speed, ---with-Introduction, ---with-Example, ---with-TestMore, -and --with-PrintFor. -
  3. - -Add files that were missing in the Microsoft Visual Studio -projects. -
  4. - -Fix two significant bugs. One in the optimize - command -and the other in the PrintFor - command. -
- - -
-
-02-03 -
-Fix a mistakes in the test bender_quad.cpp -. -In addition, the optimize - routine was used to reduce the -tape before doing the calculations. -
-
-
The routine opt_val_hes - was added as an alternative to -BenderQuad -. - -
-
-01-26 -
-Another speed improvement was made to cppad_ipopt_nlp -. -To be specific, the Lagragian multipliers where checked and components -that were zero were excluded form the Hessian evaluation. - -
-
-01-24 -
-It appears that in cppad_ipopt_nlp -, when retape[k] was true, -and 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 -produced). This is because the argument value to - -r -k - -( -u -) - - - depends -on the value of - - - - - in the expression - - -r -k - - -[ -J -k -, - - - - -n -] -( -x -) - - -(even when the value of - -x - - - does not change). -
-
-
There was a bug in the ipopt_nlp_ode_check.cpp - program, -for a long time, that did not show up until now. Basically, -the check had code of the was using an undefined value. -This has been fixed. - -
-
-01-23 -
-Improve the sparsity patterns and reduce the amount of memory -required for large sparse problems using cppad_ipopt_nlp -. -The speed test cppad_ipopt/speed showed significant improvement. - - -
-
-01-20 -
-We plan to split up the -ipopt_cppad/src/ipopt_cppad_nlp.hpp include file. -In preparation, -the example ipopt_cppad has been changed to cppad_ipopt. -This will facilitate using CPPAD_IPOPT_* for the -# ifdef commands in the new include files -(note that they must begin with CPPAD). - - -
-
-01-18 -
-The ipopt_cppad subdirectory of the distribution -has been split into an src, example, and speed -subdirectories. -The example (speed) -subdirectory is where one builds the ipopt_cppad_nlp - examples -(speed tests -). - -
-
-01-04 -
-The following items have been fulfilled and -hence were removed for the wish_list -: -
  1. -If an exception occurs before the call to the corresponding -ADFun - constructor or Dependent -, -the tape recording can be stopped using abort_recording -. - -
  2. - -A speed test for ipopt_cppad_nlp - was added; see -ipopt_ode_speed.cpp -. - -
  3. - -The optimize - command uses hash coding to check -when an expression is already in the tape and can be reused. - -
  4. - -The optimize - command removes operations that -are not used by any of the dependent variables. - -
  5. - -The ad_in_c.cpp - example demonstrates how to connect -CppAD to an arbitrary scripting language. - -
  6. - -The vector of sets option has been added to sparsity calculations; -see sparsity pattern -. - -
- - - - -
Input File: omh/appendix/whats_new/whats_new_10.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_10_xml.js cppad-2019.02.00.0/doc/_whats_new_10_xml.js --- cppad-2018.00.00.0/doc/_whats_new_10_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_10_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,129 +0,0 @@ -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_10.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_10.xml#Introduction', -'whats_new_10.xml#12-31', -'whats_new_10.xml#11-27', -'whats_new_10.xml#09-26', -'whats_new_10.xml#09-22', -'whats_new_10.xml#08-21', -'whats_new_10.xml#07-14', -'whats_new_10.xml#07-11', -'whats_new_10.xml#06-01', -'whats_new_10.xml#04-28', -'whats_new_10.xml#04-26', -'whats_new_10.xml#04-24', -'whats_new_10.xml#04-01', -'whats_new_10.xml#03-11', -'whats_new_10.xml#03-10', -'whats_new_10.xml#03-09', -'whats_new_10.xml#03-03', -'whats_new_10.xml#02-11', -'whats_new_10.xml#02-08', -'whats_new_10.xml#02-06', -'whats_new_10.xml#02-05', -'whats_new_10.xml#02-03', -'whats_new_10.xml#01-26', -'whats_new_10.xml#01-24', -'whats_new_10.xml#01-23', -'whats_new_10.xml#01-20', -'whats_new_10.xml#01-18', -'whats_new_10.xml#01-04' -]; -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-2018.00.00.0/doc/whats_new_11.xml cppad-2019.02.00.0/doc/whats_new_11.xml --- cppad-2018.00.00.0/doc/whats_new_11.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_11.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1745 +0,0 @@ - - - -Changes and Additions to CppAD During 2011 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_11 - -

- - - -
Changes and Additions to CppAD During 2011
-
-Introduction -
-This section contains a list of the changes to CppAD during 2011 -(in reverse order by date). -The purpose of this section is to -assist you in learning about changes between various versions of CppAD. - -
-
-12-30 - -
  1. -There was a bug when using abs - with an AD< AD<double> > -argument, whereby the corresponding AD<double> operation sequence -depended on the value of the argument to the abs function. -
  2. - -Change the specifications for the derivative of the abs - -function to be the sign - function instead of a directional derivative. -
  3. - -Add the sign - function to the -AD<Base> - list of -available functions. -In addition, add the -sign - function to the list of -base type requirements -. -
- - -
-
-12-28 -
-The file time_test.hpp - -was not being included by cppad/cppad.hpp. -This has been fixed. - -
-
-12-21 -
-The types -SizeVector, -NumberVector, -ADNumber, and -ADVector, -were in the global namespace and this was causing warnings -about the shadowing of these declarations. -The -cppad_ipopt namespace - -was created to avoid these problems. -The simplest way to make old cppad_ipopt_nlp - code work with this -change is to use the command -
 
-     using namespace cppad_ipopt;
-
-
-12-20 - -
  1. -Change team_start to team_create - -and team_stop to team_destroy -. -
  2. - -Change NDEBUG mentions to include link to -NDEBUG -. -
  3. - -Improve memory_leak - documentation. -
- - -
-
-11-29 -
-THe 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. - -
-
-11-27 -
-Move multi_thread.cpp to thread_test.cpp - -and fix its running - instructions. - -
-
-11-24 -
-Create preprocessor - section with pointers to all the -preprocessor symbols that are in the CppAD API. - -
-
-11-21 -
-Separate --with-boostvector - -for boost_dir -. -This enables one to specify -boost_dir - for -team_bthread.cpp - with out using boost vectors. - -
-
-11-20 - -
  1. -Move sum_i_inv.cpp to harmonic.cpp -. -
  2. - -Include the date, time, CppAD version, and -team_name - in the -thread_test.cpp - output. -
- - -
-
-11-18 - -
  1. -The thread_test.cpp - program was truncating -test_time - -to the nearest integer. -This has been fixed. -
  2. - -The time_test - routine has been made more efficient and now -check for the case where only one execution of the test is necessary -to achieve the desired -test_time - -(it used to always run at least two). -
  3. - -The sum_i_inv_time.cpp and multi_newton.cpp - -routines were calling the test an extra time at the end to check for -correctness. -The results of the last test are now cached and used for the correctness -test so that an extra call is not necessary (to make the tests run faster -when only a few repetitions are necessary). -
- - - -
-
-11-17 - -
  1. -Create another speed testing routine time_test - which is -like speed_test - but it returns the time instead of rate -and as a double instead of a size_t. -The use it for the timing tests in -sum_i_inv_time.cpp and multi_newton_time -. -
  2. - -Add -test_time - as a command line argument -to the multi-threading sum_i_inv -and multi_newton - -timing tests. -
- - - -
-
-11-09 -
-Change thread_team.hpp to team_thread.hpp - and do -the same for all other names that ended in _team; e.g., -team_openmp.cpp -. - -
-
-11-07 -
-The users choice for test_vector - was not actually changing -the tests that the user ran. This have been fixed. - -
-
-11-06 -
-Make all the output generated by multi_newton.cpp - valid -matlab and octave input so it is easy to plot the results. - -
-
-11-04 -
-Use thread specific data to simplify team_openmp.cpp -. - -
-
-11-01 -
-Make team_bthread.cpp - more similar to team_pthread.cpp -. - -
-
-10-30 - -
  1. -Reorganize and improve the multi_thread - section and its subsections. -
  2. - -There was a bug in multi_newton.cpp - that only showed up when -the number of threads was greater than or equal 4. -This has been fixed. -In addition, -CPPAD_MAX_NUM_THREADS - -was increased from 2 to 4 (to enable testing for this bug). -
  3. - -The accuracy expected in the sum_i_inv.cpp results were failing -when mega_sum was large. -This check has been modified to include a correction for -mega_sum -. -
- - -
-
-10-29 -
-The following changes were merged in from branches/thread: - -
  1. -Move openmp to example/multi_thread/openmp. -and create example/multi_thread/bthread, multi_thread/pthread -with similar tests. -
  2. - -Put multi-threading common code in multi_thread directory -and threading system specific code in -example/multi_thread/threading - -for -threading - equal to openmp, bthread, -and pthread. -
  3. - -Update the README file. -
  4. - -Remove the bug/optimize.sh file (no longer a bug). -
  5. - -Make arc_tan.cpp -utility that can be used by multiple multi-threading tests. -
  6. - -Create team_thread.hpp - specifications, -move OpenMP management to team_openmp.cpp -, -Boost thread management to team_bthread.cpp -, -and pthread management to team_pthread.cpp -. -
  7. - -All of the make files were modified so that the command -
     
    -     make test
    -
    -would run the tests for the current directory. -
  8. - -Extend the multi-threading speed tests -sum_i_inv.cpp and multi_newton.cpp - so they run -using Boost threads and pthreads (as well as OpenMP threads). -
- - -
-
-10-14 -
-Fix some compiler warnings about shadowed variables that were -detected by g++ version 4.6.1 20110908. - -
-
-10-12 - -
  1. -The MAC version of the pthread library does not include the -pthread_barrier_wait function; i.e., is not compliant with -the IEEE Std 1003.1, 2004 Edition for pthread. -This caused the pthread_simple_ad.cpp to fail to compile on the MAC. -This has been fixed by not compiling the pthread examples -unless pthread_barrier_wait is present. -
  2. - -The cppad_ipopt_nlp - routine has been changed to -optimize - the functions - -r -k - -( -u -) - - - such that - -retape(k) - is false. -
- - -
-
-09-06 - -
  1. -Add the -boost multi-threading - -examples a11c_bthread.cpp - and bthread_simple_ad.cpp. -
  2. - -Improve documentation for -thread_num - argument -to parallel_setup. -
  3. - -More simplification of bthread_simple_ad.cpp example. -
- - -
-
-09-05 -
-Simply and fix some problems with pthread_simple_ad.cpp, -including avoiding a Bug in Cygwin -. - -
-
-09-02 - -
  1. -The OpenMP speed test program 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. -
  2. - -The thread_alloc.cpp - example was missing from the -Microsoft 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. -
  3. - -There was an oversight, -and CPPAD_MAX_NUM_THREAD -was being set to 2 when _OPENMP was not defined. -This has been fixed and -CPPAD_MAX_NUM_THREADS - -has been documented and is now part of the CppAD API. -
  4. - -The pthread_simple_ad.cpp test failed under cygwin. -This was because the previous test openmp_ad.cpp was -set up calls to OpenMP routines that were still in effect -when pthread/simple_ad ran. -This has been fixed by making - -num_threads == 1 - a special case in -parallel_setup -. -
- - -
-
-09-01 - -
  1. -Modify the CppAD trunk using the -changes from svn revision 2060 to revision 2081 in the branch -
     
    -     https://projects.coin-or.org/svn/CppAD/branches/pthread
    -
    -These changes are described below under the headings -08-21 - through -08-31 -. -
  2. - -There was a bug in the old_atomic - functions -in the case where none of the elements of the argument to the function -was a variable -. -This has been fixed. -In addition, old_tan.cpp - generated an assert for this -case and this has also been fixed (in addition to including an example -for this case). -
- - -
-
-08-31 - -
  1. -Move the sum_i_inv_time.cpp test from -openmp/run.sh to openmp/run.cpp. -
  2. - -Change --with-openmp to -OPENMP_FLAGS=openmp_flags - configure -command line argument. -
- - -
-
-08-30 - -
  1. -Create the openmp/run.cpp program -and move the openmp_multi_newton.cpp test from -openmp/run.sh to openmp/run.cpp. -This uses configure - -information for building the tests. -
  2. - -Document the --with-openmp configure -command line argument. -
  3. - -Move openmp/multi_newton.hpp to -openmp/newton_method.hpp and -openmp/multi_newton.cpp to -openmp/newton_example.cpp. -
- - -
-
-08-25 - -
  1. -Replace omp_alloc - by thread_alloc - in -multi_thread -, the section on how to use CppAD in parallel. -
  2. - -Implement omp_alloc - as links to corresponding thread_alloc - -sections. -
  3. - -Create the pthread_simple_ad.cpp example that does AD using the -pthread library. -In addition, fix some problems in openmp_simple_ad.cpp -
  4. - -Move openmp/example_a11c.cpp to -example/a11c_openmp.cpp -. -
  5. - -Move openmp/parallel_ad.cpp to -openmp_simple_ad.cpp. -
- - -
-
-08-23 -
-Beginning steps in replacing omp_alloc - by thread_alloc -: -
  1. -Replace omp_alloc - by thread_alloc - -in the utilities -. -
  2. - -move omp_alloc - to the deprecated section of the -documentation. -
  3. - -Change all omp_alloc - section names to begin with omp_, -and change all thread_alloc - section names to begin with new_. -
  4. - -Convert CppAD_vector - from using omp_alloc - to using -thread_alloc - for memory allocation. -
  5. - -Extend the memory_leak - routine to also check the -thread_alloc - allocator. -
- - -
-
-08-21 -
-Create the OpenMP and pthread examples -a11c_openmp.cpp -, -a11c_pthread.cpp -, and -openmp_simple_ad.cpp. -These OpenMP examples were originally in the openmp directory, -and have been moved, and modified to conform, to the normal example directory. - -
-
-08-11 -
-Modify the CppAD trunk using the -changes from svn revision 2044 to revision 2056 in the branch -
 
-     https://projects.coin-or.org/svn/CppAD/branches/base_require
-
-These changes are described below under the headings -08-04 - through -08-10 -. - -
-
-08-10 - -
  1. -Add the output stream optional argument -s - in - -
    -     
    f.Forward(0, xs)
    -
    -See zero order forward mode - and PrintFor -. -
  2. - -Improve omp_alloc.cpp - example. -
- - - -
-
-08-09 - -
  1. -base_require -: -Add epsilon - to the - -Base - type requirements. -
  2. - -Extend epsilon to AD types. -
- - -
-
-08-08 - -
  1. -Improve the base_require - documentation for -standard math functions -. -
  2. - -base_require -: -Add abs_geq to the requirements - -for a user defined -Base - type. -
  3. - -Check that zero order forward mode results are approximately equal, -instead of exactly equal, -after an optimize - operation. -This fixes a bug in the optimize correctness check -(The order of operations can be changed by optimize -and hence the zero order forward mode results may not be exactly the same.) -
- - -
-
-08-07 -
-Improve the base_require - documentation for -EqualOpSeq -, -Identical - -Integer -, and -Ordered - -operations. - -
-
-08-06 -
-Add the CondExpRel - paragraph to the -base requirements documentation. -This was missing and are required for -CondExp - to work with -AD<Base> - arguments -and a non-standard -Base - type. - -
-
-08-04 - -
  1. -base_require -: -Change the include - file name to -base_require.hpp -. -
  2. - -Use base_float.hpp - and base_double.hpp - as additional examples -for the CondExp Base requirements - -requirements. -
- - -
-
-08-03 -
-Change PrintFor - condition from less than or equal zero -to not greater than zero;i.e., not positive. -This makes nan print because it results in false for all comparisons. - -
-
-08-02 - -
  1. -Change PrintFor - so it no longer aborts execution when -there is no operation sequence being recording; see -start recording -. -
  2. - -Improve the print_for_cout.cpp - example. -
- - -
-
-07-31 -
-Add a conditional version of the PrintFor - command - -
-     PrintFor(
textyz)
-
-which only prints when -z <= 0 -. -This is useful for error reporting during forward mode; i.e., -reporting when the argument to the log function is not valid. - -
-
-07-29 - -
  1. -The routines set_max_num_threads - and -get_max_num_threads were created. -User's will need to replace calls to -max_num_threads - -by calls to set_max_num_threads. -
  2. - -The functions omp_efficient - was deprecated because it -has not been shown to be useful. -
- - -
-
-07-28 - -
  1. -Change omp_return_memory - so that if omp_max_num_threads - is one -(the default), omp_alloc - does not hold onto memory -(keep it available for the corresponding thread). -
  2. - -Add files that were missing from the Microsoft Visual Studio -example and test_more subdirectory -project files. -
  3. - -Fix some warnings generated by Microsoft Visual Studio 2010 build. -
- - -
-
-07-27 -
-Make tan and tanh atomic - -operations; see tan_forward - and tan_reverse -. - -
-
-07-25 -
-Finish the old_atomic - example old_tan.cpp -. -This is also a design and implementation of the routines necessary -to make tan and tanh CppAD atomic operations. - -
-
-07-18 -
-The reverse mode formulas for - -Z -( -t -) - - - need to involve -the lower order Taylor coefficients for - -Y -( -t -) - - -. -This has been fixed in tan_reverse -. - -
-
-07-17 - -
  1. -Fix bug in old_atomic - functions. -To be specific, the Taylor coefficients for - -y - - -, -of order less than -k -, -were not passed into the old_atomic -forward - callback function. -
  2. - -Derive the theory for including the tangent and hyperbolic tangent -as CppAD atomic operations tan_forward - and tan_reverse -; -see the wish list item Tan and Tanh. -
  3. - -Implement and test forward mode calculation of derivative for -the tangent and hyperbolic tangent functions; -see the new old_atomic - example old_tan.cpp -. -
- - -
-
-07-14 - -
  1. -The autotools - instructions for running the individual -correctness and speed tests were out of date. -This has been fixed; see -example and tests -. -
  2. - -Move parallel_ad.cpp from example directory -to openmp directory (and convert it from a function to a program). -
  3. - -Simplify example_a11c.cpp by making it just a correctness test. -
  4. - -Change openmp/run.sh so that it runs correctness tests with -the compiler debugging flags. -
- - -
-
-07-13 - -
  1. -static hash code data that was begin used by multiple threads -when recording -AD<Base> - operations -omp_in_parallel - execution mode. This has been fixed. -
  2. - -Make the sparse calculations safe -for use during omp_in_parallel - execution mode. -
  3. - -Add the parallel_ad.cpp example. -
  4. - -Change example_a11c.cpp example so that is just a correctness -(not speed) test. -
- - -
-
-07-11 - -
  1. -Change the upper limit for -omp_max_num_threads - from 32 to 48. -
  2. - -Add parallel - documentation for, -nan, -Rosen34 -, and -Runge45 -. -
  3. - -Fix CheckNumericType - and CheckSimpleVector - -so they work properly when used in parallel mode. -
- - - -
-
-openmp/run.sh -
-The following changes were made to openmp/run.sh: -
  1. -
  2. - -Change to openmp/run.sh -maximum number of threads -instead of specifying the entire set of values to be tested. -
  3. - -Change settings for -newton_example -so that n_gird is a multiple of the maximum number of threads. -
  4. - -Report dynamic number of thread -results as a separate result in the summary output line. -
  5. - -Fix automatic removal of executables from openmp directory -(was commented out). -
  6. - -The documentation for openmp/run.sh was moved to the -multi_thread section. -
- - - -
-
-07-10 - -
  1. -Add link to Discrete AD Functions in multi_thread -. -
  2. - -Make use of the TrackNewDel - routines -omp_in_parallel - execution mode an error (it never worked properly); -see TrackNewDel multi-threading -. -
  3. - -Change memory_leak - so that it checks for a leak in all threads. -This is what openmp_newton_example.cpp and -sum_i_inv_time.cpp -assumed was being done. -
- - -
-
-07-09 -
-All the OpenMP parallel execution requirements -have been grouped in the section multi_thread -. - -
-
-07-07 -
-Add the routine parallel_ad - to fix bug when using - -AD<Base> - in parallel - execution mode. - -
-
-06-23 - -
  1. -Fix a bug whereby the assert - -
    -     Error detected by false result for
    -          ! omp_in_parallel()
    -     at line 
    n in the file
    -     
    prefix/include/cppad/omp_alloc.hpp
    -
    -sometimes occurred. -
  2. - -The routine omp_max_thread - was deprecated, -use the routine omp_max_num_threads - instead. -
  3. - -The deprecated routines have been grouped together in the -deprecated - section of the CppAD manual. -
- - -
-
-06-21 - -
  1. -The openmp/run.sh routine was changed to use zero, -instead of automatic, for automatic choice of -openmp/run.sh -number of repeats -and -maximum number of threads. - -
  2. - -The output of each of the OpenMP examples / speed tests -(run by openmp/run.sh) -was changed to be valid matlab / octave assignment statements. - -
  3. - -In the case where OpenMP is enabled during compilation, -a summary for the different number of threads as added at the end of -the openmp/run.sh output. - -
- - -
-
-06-18 - -
  1. -The tape_addr_type - option was added -to the configure - command line. -
  2. - -The function size_op_seq - results uses -sizeof(CppAD_TAPE_ADDR_TYPE) -where it used to use sizeof(size_t). -
  3. - -Remove cppad/config.h from CppAD distribution, -(put the information in cppad/configure.hpp.) -This removes the need to undefine symbols that were -defined by cppad/config.h and that did not begin with CPPAD_. -
  4. - -Change adolc - library linkage so it -works with version ADOL-C-2.2.0. -
- - -
-
-05-29 -
-Fix bug (introduced on 05-22 -) -whereby constructor might not be called (but required) when the -base type - is not plain old data. - -
-
-05-28 - -
  1. -Add the omp_efficient - routine to the omp_alloc - system. -
  2. - -Improve the omp_alloc tracing so it prints the same pointer -as returned to the user (not an offset version of that pointer). -
- - -
-
-05-26 -
-Fix Visual Studio project files that were broken during the change on 05-22. -In addition, in the file cppad/omp_alloc.hpp, -suppress the following Microsoft Visual Studio warning -
 
-     warning C4345: behavior change: an object of POD type constructed with
-     an initializer of the form () will be default-initialized
-
-
-05-22 - -
  1. -The old memory tracking routines TrackNewDel - have been deprecated. -Their use should be replaced using the omp_alloc - -a memory allocator which is designed to work well in a multi-threading OpenMP -environment; see purpose -. -
  2. - -The replacement of TrackNewDel by omp_alloc -has been throughout the CppAD source code, including the examples -that used TrackNewDel; namely, -mul_level_adolc.cpp -, mul_level_adolc_ode.cpp -. -
  3. - -The CppAD vector template class -and the vectorBool - class -were modified to use the omp_alloc -memory - manager. -This should improves its speed of memory allocation -omp_in_parallel - sections of a program. -
  4. - -The speed_test - argument -size_vec - call was by value, -instead of by reference (as documented). -This has been fixed and the call is now by reference. -
  5. - -The capacity - function has been added -to the CppAD vector class. -
  6. - -The simple vector -element constructor and destructor - -description has been changed to explicitly specify that the -default constructor is used to initialize elements of the array. -
  7. - -The size_op_seq - documentation -has been improved to mention that the allocated memory may be larger. -
- - -
-
-05-11 - -
  1. -Avoid ambiguity in the definition of the -complex isnan - function. -
  2. - -Errors during make test were not -being detected. -This has been fixed. -
- - -
-
-05-03 - -
  1. -If NDEBUG is not defined, -the hasnan - function is used to make sure that the -results of any 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 ErrorHandler -. - -
  2. - -In the event that the -cppad_ipopt_nlp - objective function, the constraints, -or their derivatives are infinite, -an error message is generated and the program terminates -(proved that NDEBUG is not defined and the default error -handler has not been replaced). -
- - -
-
-04-29 - -
  1. -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 -Compiler Error C2918 -. -These project files were converted to Visual Studio 2008 where they do work -(if you use a later version, Visual Studio should automatically -convert them for you). - -
  2. - -The old speed test directory was moved to speed_cppad -before the new speed - test organization was created on 2006-12-11 -(revision 715 of the repository). -The old speed tests have not been used for years and so have been deleted. -
- - -
-
-04-20 -
-The openmp/run.sh script what changed -to take an argument that specifies which tests is run -(it no longer runs all the tests). -Also improve the openmp test program output formatting. - -
-
-04-19 -
-The -use_ad - option was added to the -openmp_newton_example.cpp test case. - -
-
-03-19 -
-The subversion write protected directory -bin/.svn was mistakenly part of the -compressed tar file -. -It has been removed. - -
-
-03-11 -
-The vector of sets argument -r - -to the old_atomic function -rev_hes_sparse - -must have size greater than or equal to -n -. -There was a check that its size was greater than or equal -q -. -This was incorrect and has been fixed. - -
-
-03-05 -
-Add the conjugate gradient - example. - -
-
-02-22 -
-Add the atomic - option to the -speed test program and use -old_mat_mul.hpp - during the -cppad_mat_mul.cpp - speed test when the atomic option is specified. - - -
-
-02-19 -
-There was a bug when omp_max_thread - was set to one, -and NDEBUG was not defined, -the thread corresponding to parameters was one, but the only valid thread -number was zero (only one thread) -and an CPPAD stopped with an assertion error. -This has been fixed. - -
-
-02-17 -
-There was a mistake in openmp/run.sh where it attempted -to remove a non-existent file in the case where -openmp/run.sh -openmp_flag was not "". -This has been fixed. - -
-
-02-15 -
-A matrix multiply speed test has been added. -So far, this has only implemented for the -cppad - and double - cases. -(For the time being this test is not available for the other -speed comparison cases.) - -
-
-02-09 -
-A variable in old_atomic.hpp was declare of type -Base - -when it should have been declared of type size_t. -It caused the old_atomic - feature to fail with some base types. -This has been fixed. -
-
-
The old_mat_mul.hpp - example has been improved by -caching the - -x - - - variable information and using it during -reverse Hessian sparsity - calculations. -
-
-
Some of the old_atomic - documentation was extended to -include more explanation. - -
-
-02-06 -
-The use can now define complex atomic - operations -and store them in a CppAD ADFun - object. -This item has been remove from the -wish list -. -
-
-
The documentation for RevSparseHes - had a dimension error. -This has been fixed. -
-
-
A faster set operations item was added to the wish list. -This has since been satisfied by -cppad_sparse_list choice during -the install process (since removed). - -
-
-02-02 -
-The documentation for ForSparseJac - had some formatting errors. -The errors have been fix and the documentation has been improved. - -
-
-02-01 -
-The subversion -install instructions were brought up to date. -They have since been replaced by just separate -subversion instructions. - -
-
-01-19 -
-The directory where the pkgconfig - file cppad.pc -is stored has been moved from - -prefixdir/lib/pkgconfig/cppad.pc - -to - -prefixdir/share/pkgconfig/cppad.pc -; -see -devel@lists.fedoraproject.org -. - -
-
-01-16 -
-The following have been fixed: -
  1. -The install of the documentation failed -when it was done from a directory other than the top source directory. -
  2. - -The GPL distribution had the output of the -configure - command in it. -
  3. - -Since the change on 01-09, the file -omh/appendix/whats_new_11.omh has been required to build the -documentation (and it has been missing from the distribution). -
  4. - -Fadbad was generating warnings due to the -Wshadow flag -with the g++ compiler. -The Fadbad speed - tests have a special -flag with this warning removed from the -cxx_flags -. -
- - -
-
-01-09 -
-There were some problems running make test in the releases - -
-http://www.coin-or.org/download/source/CppAD/cppad-20110101.0.
license.tgz
-
-where -license - is gpl or cpl. -
  1. -The version of automake used to build the corresponding -makefile.in files did not define abs_top_builddir. -
  2. - -The include file cppad_ipopt_nlp.hpp was always installed, even if -ipopt_dir - was not defined on the -configure command line. -
  3. - -The speed test library libspeed.a was being installed -(it is only intended for testing). -
- -These problems are fixed in the trunk -and these fixes will be copied to the corresponding stable and -release versions; i.e., - -
-http://www.coin-or.org/download/source/CppAD/cppad-20110101.1.
license.tgz
-
-will not have this problem. - - -
Input File: omh/appendix/whats_new/whats_new_11.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_11_xml.js cppad-2019.02.00.0/doc/_whats_new_11_xml.js --- cppad-2018.00.00.0/doc/_whats_new_11_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_11_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,180 +0,0 @@ -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_11.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_11.xml#Introduction', -'whats_new_11.xml#12-30', -'whats_new_11.xml#12-28', -'whats_new_11.xml#12-21', -'whats_new_11.xml#12-20', -'whats_new_11.xml#11-29', -'whats_new_11.xml#11-27', -'whats_new_11.xml#11-24', -'whats_new_11.xml#11-21', -'whats_new_11.xml#11-20', -'whats_new_11.xml#11-18', -'whats_new_11.xml#11-17', -'whats_new_11.xml#11-09', -'whats_new_11.xml#11-07', -'whats_new_11.xml#11-06', -'whats_new_11.xml#11-04', -'whats_new_11.xml#11-01', -'whats_new_11.xml#10-30', -'whats_new_11.xml#10-29', -'whats_new_11.xml#10-14', -'whats_new_11.xml#10-12', -'whats_new_11.xml#09-06', -'whats_new_11.xml#09-05', -'whats_new_11.xml#09-02', -'whats_new_11.xml#09-01', -'whats_new_11.xml#09-01.08-31', -'whats_new_11.xml#09-01.08-30', -'whats_new_11.xml#09-01.08-25', -'whats_new_11.xml#09-01.08-23', -'whats_new_11.xml#09-01.08-21', -'whats_new_11.xml#08-11', -'whats_new_11.xml#08-11.08-10', -'whats_new_11.xml#08-11.08-09', -'whats_new_11.xml#08-11.08-08', -'whats_new_11.xml#08-11.08-07', -'whats_new_11.xml#08-11.08-06', -'whats_new_11.xml#08-11.08-04', -'whats_new_11.xml#08-03', -'whats_new_11.xml#08-02', -'whats_new_11.xml#07-31', -'whats_new_11.xml#07-29', -'whats_new_11.xml#07-28', -'whats_new_11.xml#07-27', -'whats_new_11.xml#07-25', -'whats_new_11.xml#07-18', -'whats_new_11.xml#07-17', -'whats_new_11.xml#07-14', -'whats_new_11.xml#07-13', -'whats_new_11.xml#07-11', -'whats_new_11.xml#07-11.openmp/run.sh', -'whats_new_11.xml#07-10', -'whats_new_11.xml#07-09', -'whats_new_11.xml#07-07', -'whats_new_11.xml#06-23', -'whats_new_11.xml#06-21', -'whats_new_11.xml#06-18', -'whats_new_11.xml#05-29', -'whats_new_11.xml#05-28', -'whats_new_11.xml#05-26', -'whats_new_11.xml#05-22', -'whats_new_11.xml#05-11', -'whats_new_11.xml#05-03', -'whats_new_11.xml#04-29', -'whats_new_11.xml#04-20', -'whats_new_11.xml#04-19', -'whats_new_11.xml#03-19', -'whats_new_11.xml#03-11', -'whats_new_11.xml#03-05', -'whats_new_11.xml#02-22', -'whats_new_11.xml#02-19', -'whats_new_11.xml#02-17', -'whats_new_11.xml#02-15', -'whats_new_11.xml#02-09', -'whats_new_11.xml#02-06', -'whats_new_11.xml#02-02', -'whats_new_11.xml#02-01', -'whats_new_11.xml#01-19', -'whats_new_11.xml#01-16', -'whats_new_11.xml#01-09' -]; -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-2018.00.00.0/doc/whats_new_12.xml cppad-2019.02.00.0/doc/whats_new_12.xml --- cppad-2018.00.00.0/doc/whats_new_12.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_12.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1888 +0,0 @@ - - - -CppAD Changes and Additions During 2012 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_12 - -

- - - - -
CppAD Changes and Additions During 2012
-
-Introduction -
-This section contains a list of the changes to CppAD during 2012 -(in reverse order by date). -The purpose of this section is to -assist you in learning about changes between various versions of CppAD. - -
-
-12-30 - -
  1. -Merge changes in branches/ipopt_solve to trunk, -delete that branch, and -advance version number to cppad-20121230. -
  2. - -Remove cppad/configure.hpp from repository because -it is built by the configuration process -(even for MS Visual Studio, now that we are using cmake -). -
  3. - -Add the -AD<Base> - input stream operator >> -. -
- - -
-
-12-29 -
-In branches/ipopt_solve: -
  1. -Complete implementation of sparse Jacobian and Hessian calculations -and add options that allow to user to choose between forward and reverse -sparse Jacobians. -
  2. - -The ipopt_solve - routine seems to be faster and simpler -than cppad_ipopt_nlp -. -More speed comparisons would be good to have. -
  3. - -All of the ADFun Drivers - -have added specifications for the zero order Taylor coefficients -after the routine is called. -For example, see -Hessian uses forward -. -
- - - -
-
-12-28 -
-In branches/ipopt_solve: -
  1. -Add the ipopt_solve_retape.cpp - and ipopt_solve_ode_inverse.cpp - -examples. -
  2. - -Use ipopt::solve options - -argument (and not a file) for all the Ipopt options. -As well as allowing for adding ipopt::solve special options; e.g., -retape -. -
- - -
-
-12-27 -
-In branches/ipopt_solve: -Change documentation section names that begin with cppad_ipopt -to begin with ipopt_nlp - -to distinguish them from CppAD::ipopt::solve -. - -
-
-12-26 -
-In branches/ipopt_solve: -
  1. -Convert documentation most all documentation references from -the deprecated autotools - instructions to the new cmake - -instructions. -
  2. - -Include the Introduction - programs in the -cmake_check - built using cmake -. -
  3. - -Deprecate cppad_ipopt_nlp - and replace it by ipopt_solve - -which is easier to use. -This is a first version of ipopt_solve and its speed -and memory use needs to be improved. -
- - -
-
-12-23 -
-Copy development trunk to branches/ipopt_solve. - -
-
-12-22 -
-Define a doxygen module (group) for each file that has doxygen documentation. - -
-
-12-20 - -
  1. -The install instructions - -were installing cppad/CMakeLists.txt and cppad/configure.hpp.in -in the cppad include directory. -This has been fixed so that only -*.h - and -*.hpp - files -get installed in the cppad include directory. -
  2. - -Advance the version number to cppad-20121220. -
- - -
-
-12-19 -
-The files <stdbool.h> and <sys/time.h> -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 -compare_c/det_by_minor.c source code. - -
-
-12-17 -
-There was a mistake in a check for a valid op code in the -file hash_code.hpp. -This mistake could generate a C++ assertion with an unknown error source. -It has been fixed. - - -
-
-12-15 - -
  1. -Advance version number from 20121120 to 20121215. -Note that the CppAD version number no longer automatically advances with the -date and is rather chosen to advance to the current date. -
  2. - -The cmake - installation was putting the cppad.pc -pkgconfig - file in - -
    -     cppad_prefix
    /cmake_install_datadir/cppad.pc
    -
    -This has been fixed and is now - -
    -     cppad_prefix
    /cmake_install_datadir/pkgconfig/cppad.pc
    -
    -
  3. -The pkgconfig - documentation has been improved. -
  4. - -The command for running the -adolc examples - and -eigen examples - -was fixed -(changed from make check to make check_example). -
- - - -
-
-12-14 - -
  1. -Fix the old autotools - so that it works with the -new cppad.pc. -
  2. - -Fix the old installation ---with-Documentation - option -(it was attempting to copy from the wrong directory). -
- - - -
-
-12-13 - -
  1. -Include documentation for ipopt_prefix - -
  2. - -Fix the cppad.pc pkgconfig - file -so that it includes the necessary libraries and include commands -when ipopt_prefix - is specified; see -pkgconfig usage -. -
- - - -
-
-11-28 -
-Update the wish_list -: -
  1. -Remove Microsoft compiler warning item that has been fixed. -
  2. - -Remove faster sparse set operations item that was completed using -cppad_sparse_list (not part of user API). -
  3. - -Remove cmake - items that have been completed. -
  4. - -Remove CondExp - items related to using -AD< std::complex<double> > types because it is better to use -std::complex< AD<double> >. -
  5. - -Remove thread_alloc - memory chunk item that has been completed. -
  6. - -Remove VecAD - item about slicing from floating point type to int -(not important). -
  7. - -Change an Ipopt item to a cppad_ipopt_nlp - -(which was removed because cppad_ipopt_nlp is now deprecated). -Add new cppad_ipopt_sum item to the wish list. -(This has been removed because checkpointing - -can now be used for this purpose.) -
  8. - -Add new old_atomic wish_list - item (since removed). - -
- - -
-
-11-21 - -
  1. -Fix the -version - number in link to the -current download files. -
  2. - -Change the -subversion download instructions to use -the export instead of checkout command. -This avoids downloading the source code control files. -
- - -
-
-11-20 - -
  1. -The cmake variables -cmake_install_includedir and -cmake_install_libdir -were changed to -cmake_install_includedirs - and -cmake_install_libdirs - -to signify the fact that they can now be a list of directories. -
  2. - -Advance version number to cppad-20121120. -
- - -
-
-11-17 - -
  1. -Finish documenting the new cmake - configuration instructions -and deprecate the old unix - instructions. -
  2. - -Change the specifications for -CPPAD_MAX_NUM_THREADS - -to allow for a value of one. -This enables one to have more tapes during a program execution. -
  3. - -Include the C versus C++ - speed comparison -in the cmake - build. -
- - -
-
-11-16 -
-Fix a warning that occurred in Rosen34 - -when it was compiled with the preprocessor symbol NDEBUG defined. - -
-
-11-14 -
-Advanced the CppAD version to cppad-20121114. - -
  1. -Started documenting the -cmake - configuration procedure during installation. -This included factoring out the -download - procedure as a separate section -so that the same download instruction also apply to the -unix - install procedure. - -
  2. - -Changed -example/compare_change.cpp - -to just return true when NDEBUG is defined. -This enabled all the tests in the -example directory to be compiled -with NDEBUG is defined and to pass. - -
  3. - -In the case where NDEBUG is defined, -removed detection of nan during forward mode from -test_more/forward.cpp%. -This enables all the tests in the -test_more directory to be compiled -with NDEBUG is defined and to pass. - -
  4. - -Started a wish list for CppAD's use of cmake -. -The wish list items were completed and removed. - -
- - - -
-
-11-09 -
-The team_pthread.cpp - was failing to link on Ubuntu 12.04 -because the libraries were not at the end of the link line. -This has been fixed. - -
-
-11-06 - -
  1. -Remove some remaining references to the old licenses CPL-1.0 and GPL-2.0; -see 10-24 -. -
  2. - -Remove out of date Microsoft project files from the distribution. -The build system is being converted to use -cmake - which builds these files automatically -and thereby keeps them up to date. -This feature is not yet documented, but one can inspect the file -bin/run_cmake.sh to see how to use cmake with CppAD. -
- - - -
-
-11-04 -
-Add missing return value to the example base_alloc -CondExpOp - function. -This has been fixed and the comments for this example have been improved. - -
-
-10-31 -
-The CppAD profiling - was not compiling -the speed/src/*.cpp files with the profiling flag. -This has been changes -(only for the profiling speed test). - -
-
-10-30 -
-The fadbad_dir - directory install instructions -were changed. -To be specific, FADBAD++ was changed to include/FADBAD++. -This makes it more like the other optional packages. - -
-
-10-25 -
-The test runge45_1.cpp - was failing when using gcc-4.5.2. -This has been fixed by properly defining -fabs(x) - where - -x - is a double (without the std in front). - -
-
-10-24 -
-Change the CppAD licenses from CPL-1.0 and GPL-2.0 to -EPL-1.0 and GPL-3.0. - -
-
-10-12 - -
  1. -Change all the multiple levels of AD examples to -start with mul_level -. -To be specific, move -ode_taylor.cpp to mul_level_ode.cpp - and -ode_taylor_adolc.cpp to mul_level_adolc_ode.cpp -. -
  2. - -Add ode_taylor.cpp - as a example of Taylor's method for solving ODEs, -(mul_level_ode.cpp - is an application of this method -to multi-level AD.) -
- - -
-
-10-04 - -
  1. -Change speed_main - so that it outputs small rates (less than 1000) -with two decimal points of precision (instead of as integers). -In addition, flush result for each size when it finishes to give user -more feedback about how things are progressing. -
  2. - -Add the optional test_size - argument -to the time_test routine. -
- - -
-
-10-03 -
-Change the hold_memory speed to option to just -memory -. -In addition, in the speed test output, include all of the options -that are present in the output variable name; -see speed results -. - -
-
-10-02 -
-Fix another problem with Debian's /bin/sh shell executing -example/multi_thread/test.sh; see 03-17 - - -
-
-09-24 -
-Improve documentation for the -old_atomic - -rev_hes_sparse - -argument -v -. -In addition, -add sparsity calculations to the old_reciprocal.cpp - example. - -
-
-09-11 -
-Add user_simple.cpp, -a simpler old_atomic - example. - -
-
-08-05 - -
  1. -A new type was added for the internal representation of -vector of sets - -sparsity patterns; see the configure ---with-sparse_option (since removed). -
  2. - -A new speed test, compare_c -, compares the speed of the same -source code compiled with C and C++. -
- - -
-
-07-30 - -
  1. -The clear - function was added to -CppAD::vector. -
  2. - -Warning !!: -The CppAD::vector resize - specifications -were changed so that -x.resize(0) - no longer frees -the corresponding memory (use -x.clear() - instead). -
  3. - -Fix a bug in error checking during optimize - procedure -had the following valgrind symptom during the -optimize.cpp example: -
     
    -     ==6344== Conditional jump or move depends on uninitialised value(s)
    -
    -
  4. -Fix mistake in old_tan.cpp - where w[2] = 0 -was missing before the call -
     
    -          dw    = F.Reverse(1, w);
    -
    -
-
-07-08 - -
  1. -Improve the documentation for pow - and pow_int -. -
  2. - -Change all the example section names to be same as corresponding file names; -e.g. change vectorBool.cpp to vector_bool.cpp - -for the example example/utility/vector_bool.cpp. -
- - -
-
-07-07 -
-Add the CPPAD_TAPE_ID_TYPE argument to the -configure - command line. - -
-
-07-05 -
-Deprecate CPPAD_TEST_VECTOR - and use -CPPAD_TESTVECTOR - in its place. -This fixes a problem introduced by changes on 07-03 whereby code that -used CPPAD_TEST_VECTOR would no longer work. - -
-
-07-04 - -
  1. -Replace the requirement that the SimpleVector - -size - function return a size_t value to -the requirement that it can be converted to a size_t value. -
  2. - -The --with-eigenvector - option was -added to the configure command line. -
- - -
-
-07-03 -
-Fix bug in old_atomic - functions identification of variables -that caused old_tan.cpp - to fail with error message -
 
-Error detected by false result for
-    y_taddr > 0
-at line 262 in the file cppad/local/dependent.hpp
-
-
-07-02 -
-Add eigen_plugin.hpp so that -an Eigen vector can be used as a -SimpleVector -. -This has since been removed; see -2017-05-11 -. - -
-
-07-01 - -
  1. -Change cppad_eigen.hpp - -to match new specifications and example in eigen help files on -customizing and extending eigen. - -
  2. - -Fix bug whereby a newly constructed VecAD - object was a -variable - (instead of a parameter) directly after construction -(when no previous ADFun - object had been created). -
  3. - -Change a ok != a == 0. to ok &= a == 0. in -the example ad_ctor.cpp -. -
  4. - -Add the eigen_array.cpp - example. -
- - -
-
-06-17 - -
  1. -Move epsilon - to numeric_limits - -and add the functions min and max -in -CppAD::numeric_limits<Type> -. -
  2. - -Convert use of the deprecated epsilon - in examples -to use of numeric_limits epsilon -. -
  3. - -Complete cppad_eigen.hpp - interface to -lowest and highest functions for -all non-complex AD types. -
- - - -
-
-06-16 -
-Add the example eigen_det.cpp - that uses the -Eigen - -linear algebra package. - -
-
-06-15 -
-Include the base_adolc.hpp - as -<cppad/example/base_adolc.hpp> under the -prefix_dir - directory. - -
-
-06-12 -
-Increase the size and of the -sparse Jacobian speed tests -. - -
-
-06-10 - -
  1. -Add the hold_memory - option -to the speed test main program. -This was changed to just memory; see -10-03 -. -
  2. - -In cppad_sparse_jacobian.cpp -, -change USE_BOOL_SPARSITY from true to false. -In addition, change the number of non-zeros per row from about approximately -three to approximately ten. -
- - -
-
-06-09 -
-Change adolc_sparse_jacobian.cpp - to use the sparse adolc -Jacobian (instead of the full Jacobian) driver. -This was also done for adolc_sparse_hessian.cpp -, -but there is a problem with the test that is being investigated. - -
-
-06-08 -
-Implement the matrix multiply speed test link_mat_mul - for all packages -(there is a problem with the fadbad_mat_mul.cpp - -implementation and it is being looked into). - -
-
-06-07 -
-Make all the speed tests implementations (for the specific packages) -uniform by having a Specification and Implementation heading and similar -indexing. For example, see -adolc_det_minor.cpp -, -cppad_det_minor.cpp -, -double_det_minor.cpp -, -fadbad_det_minor.cpp -, and -sacado_det_minor.cpp -. - -
-
-06-05 -
-Add the sacado_ode.cpp - speed test. - -
-
-06-04 - -
  1. -The specifications for Runge45 - where changes so that -it uses the fabs function instead of the < operation. -This enabled the a more precise statement about its -operation sequence -. -
  2. - -The fabs function as added to the CppAD standard math library -(see abs -) -and the base type requirements -. -This enables one to write code that works with AD<double> as -well as double without having to define abs for -double arguments -(and similarly for float). -
  3. - -Add the adolc_ode.cpp - and fadbad_ode.cpp - speed tests -(and edit the cppad_ode.cpp - test). -
- - -
-
-06-03 - -
  1. -The CppAD::vector class was extended to allow assignment -with the target of size zero and the source of non-zero size; -see check size -. -
  2. - -A memory leak and a bug in cppad_mat_mul.cpp were fixed -(the bug was related to the change to CppAD::vector above). -
- - -
-
-06-02 - -
  1. -Remove the deprecated symbol -CppADvector - from the -det_by_lu - speed test source code det_by_lu.hpp -. -
  2. - -Include memory_leak - in the list of -deprecated - features. -
  3. - -Change the ode_evaluate - speed test utility so that its -operation sequence - -does not depend on the repetition; see -p == 0 - in its documentation. -
  4. - -Use same argument for taping and derivative evaluation when -retape speed test option is true. -
  5. - -Implement the -retape == false - option -in cppad_ode.cpp -. -
  6. - -Have -cppad_det_lu.cpp -, -cppad_det_minor.cpp -, -and cppad_poly.cpp -, -return false when one of the specified options is not supported. -Do the same for - -package_test.cpp - for -package - equal to -adolc, fadbad, and sacado and -for -test - equal to -det_lu, det_minor, poly. -
- - -
-
-06-01 -
-Change -cppad_sparse_hessian.cpp - and -cppad_sparse_jacobian.cpp - -to use -the -row -, -col - interface to sparse_hessian -. -In addition, implement the speed test -retape speed test option for these tests. - -
-
-05-31 -
-Add the cppad_print_optimize routine to so that the corresponding -code does not need to be reproduced for all the -speed_cppad - tests. -In addition, during CppAD speed tests, -print out the optimization results for each test size. - -
-
-05-30 -
-Change specifications for -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 -retape speed test option -during sparse Hessian speed tests. - -
-
-05-29 -
-Add index_sort - to the general purpose template utilities - -so that it can be used by the implementations of -link_sparse_jacobian - and link_sparse_hessian -. - -
-
-05-27 -
-Split the sparse Jacobian and Hessian test function the separate function -sparse_jac_fun - and sparse_hes_fun - -(do not use sparse Hessian for both). -In addition, change row and column indices from -i - -and -j - to -row - and -col -. - -
-
-05-24 -
-Merged in changes from branches/sparse: -
  1. -A new interface was added to -sparse_jacobian - and sparse_hessian -. -This interface -returns a sparse representation of the corresponding matrices -using row and column index vectors. -
  2. - -The examples -sparse_jacobian.cpp - and -sparse_hessian.cpp - were improved -and extended to include the new interface. -
  3. - -The definition of an -AD function - was improved -to include definition of the corresponding -n - and -m -. -
- - - -
-
-04-19 -
-The 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 - -boost_dir/boost - was the boost include directory, -now -boost_dir/include - is the boost include directory. -This make it the same as the other directory arguments on the configure -command line. -In addition, it fixes some bugs in the detection of the boost -multi-threading library. - - -
-
-04-18 -
-Add documentation and testing for not using free_all - and -old_atomic clear - while in -parallel - mode. - -
-
-04-17 -
-Fix bug when using old_atomic - functions with -multi_threading -. - -
-
-04-10 -
-Add control of the -max_num_threads - argument -to the unix -configure - command. - -
-
-04-06 - -
  1. -A change was made to the way that the tapes were managed to reduce -false sharing during multi-threading -. -Because of this change, it is now suggest that the user call -parallel_ad - after the multi-threading section of the program. -
  2. - -The routine ta_free_all - was created to make it easier -to manage memory and the routine memory_leak - -was deprecated. -
  3. - -Add the -lteuchos flag to the link line for the -speed_sacado - tests. -(This was not necessary for trilinos-10.8.3 -but is necessary for trilinos-10.10.1) -
- - -
-
-04-05 -
-The restriction was added that -parallel_ad - cannot be called while a tape is being recorded. -This was necessary inorder to initialize some new statics in the tape. - -
-
-04-01 -
-Fixed a race condition when using CppAD with -multi-threading -. -This has been fixed and the error message below no longer occurs. -Suppose that you ran the CppAD -configure - command in the work -directory. -If you then edited the file work/multi_thread/makefile -and changed -
 
-     # AM_CXXFLAGS     = -g $(CXX_FLAGS)
-     AM_CXXFLAGS = -DNDEBUG -O2 $(CXX_FLAGS)
-
-to -
 
-     AM_CXXFLAGS     = -g $(CXX_FLAGS)
-     # AM_CXXFLAGS = -DNDEBUG -O2 $(CXX_FLAGS)
-
-and then executed the commands -
 
-     make clean
-     make pthread_test
-     valgrind --tool=helgrind ./pthread_test simple_ad
-
-The following error message would result: - -
-     ... snip ...

-==7041== Possible data race during write of size 4 at 0x8077460 by thread #1
-==7041==    at 0x804FE23: CppAD::AD<double>::tape_new() (tape_link.hpp:221)
-
     ... snip ...
-
-
-03-27 -
-Reduce the amount of memory allocation and copying of information during -a Dependent - operation or an ADFun -sequence constructor -. - -
-
-03-26 -
-Calling taylor_capacity, with to with capacity equal to zero, -was not -freeing memory -. -This has been fixed. - -
-
-03-23 - -
  1. -Improve, the multi-threading examples -simple_ad_openmp.cpp -, -simple_ad_bthread.cpp -, and -simple_ad_pthread.cpp -. -This includes separating generic code that can be used for all applications -from problem specific code. -
  2. - -Add initialization of statics in -CheckSimpleVector - -during parallel_ad call. -These statics are required to use -CppAD::vector -. -
  3. - -Add a debugging check to make sure CheckSimpleVector - -is initialized in sequential mode. -
- - -
-
-03-21 -
-Fix an incorrect error check in thread_alloc -that did not allow ta_return_memory - -to return memory in sequential execution mode that was allocated by a -different thread during parallel execution. - -
-
-03-17 -
-Debian recently converted the default shell corresponding to -/bin/sh to dash -(which caused example/multi_thread/test.sh to fail). -This has been fixed. -In general, Debian's policy is that bin/sh will be a -Posix Shell -. - -
-
-03-11 -
-There was a bug in thread_alloc - where extra memory was held -onto even if hold_memory - was never called -and only one thread was used by the program. This caused - -
-valgrind --leak-check=full --show-reachable=yes
-
-to generate an error message. -If multiple threads - are used, -one should free this -extra memory - -for threads other than thread zero. -If hold_memory is used, -one should call free_available - for all threads. - - -
-
-03-03 - -
  1. -Add the examples -simple_ad_openmp.cpp -, -simple_ad_bthread.cpp - -and simple_ad_pthread.cpp -. -
  2. - -Fix bug in finding boost multi-threading library -(due to fact that boost_dir - -is not the prefix during the boost installation). -
- - -
-
-03-02 - -
  1. -Change the name simple_ad.cpp to team_example.cpp - -
  2. - -The multi-threading team_example.cpp example was changed to use - - -f -( -x -) -= -x -2 - - - - - - instead of the function - - -atan -2 - -[ -sin -( -x -) -, -cos -( -x -) -] - - - -(both functions should behave like the identity function - -f -( -x -) -= -x - - -). -This enabled the removal of example/multi_thread/arc_tan.cpp. -
  3. - -In team_example.cpp - check that all of the threads -pass their individual test; i.e. -work_all_[thread_num].ok - -is true for all -thread_num -. -
- - -
-
-02-11 - -
  1. -The requirements in -base_member - were missing from the base_require - documentation. -In addition, -the base_require.cpp - example has been added. -
- -The specifications for memory_leak - where changes so that -calling routine specifies the amount of static memory to add. -In addition, -it is now possible to call -memory_leak when num_threads - -is greater than one -(still can't be in parallel mode). - -
-
-02-10 - -
  1. -Add the missing Base class requirements in -the entire base_member - section -and under the Output Operator - -in the base_require - section. -
  2. - -Add the base_alloc.hpp - example. -
- - - -
-
-02-09 - -
  1. -Add the -set_static - to memory_leak -. -This is necessary for testing base types that allocate memory -for each element. -
  2. - -Fix memory allocation bug in cppad/local/pod_vector.hpp -when each element of the Base - type allocated memory. -
- - -
-
-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 boost_dir - override the default -library. - -
-
-01-27 -
-There were some problems with -configure's - automatic detection of -the boost multi-threading library. -These have been fixed. - -
-
-01-24 -
-It used to be that thread_alloc - did not hold onto memory -when -num_threads - was one in the previous call to -parallel_setup -. -Holding onto memory is now controlled by the separate routine -hold_memory -. -This give the user more control over the memory allocator -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 - -
-thread_alloc::parallel_setup(
num_threadsin_parallelthread_num);
-
-put the following call - -
-thread_alloc::hold_memory(
num_threads > 1);
-
-
-01-23 -
-Change variable notation and use optimize - in -mul_level.cpp -. - -
-
-01-20 - -
  1. -Add the example change_param.cpp - -which shows how to compute derivatives of functions that have -parameters that change, but derivatives are not computed -with respect to these parameters. -
  2. - -The documentation for machine epsilon - -has been improved. -(The fact that it can be used for -Base - types was missing.) -
- - -
-
-01-19 - -
  1. -In cases where test.sh is trivial, -put its operations in corresponding makefile. -
  2. - -Fix problem compiling cppad/speed/sparse_evaluate.hpp -under gcc on Fedora 17. -
  3. - -Run example/multi_thread/test.sh from source directory -(no need to copy to build directory). -
- - -
-
-01-16 -
-The test program example/multi_thread/test.sh failed if the -openmp_flags - not present in the -configure command. -This has been fixed. -In addition, this test.sh has been made faster by cycling through -the available threading systems instead of doing every system for every -test. - -
-
-01-15 -
-Fix make test so it works when -configure - is run in the distribution directory - -cppad-yyyymmdd - -(not just when it is run in a different directory). - - -
-
-01-12 -
-The -lpthread library was missing from the -multi_thread - test program linker command. -This has been fixed. - -
-
-01-07 - -
  1. -A duplicated code block beginning with -
     
    -if( fabs( fcur ) <= epsilon_ )
    -
    -was removed from the routine multi_newton_worker. - -
  2. - -The distance between solutions that are joined to one solution -has been corrected from - -( -b -- -a -) -/ -( -2 -n -) - - - to - - -( -b -- -a -) -/ -n - - -; see -xout -. -The correction was in the file multi_newton.cpp - where -sub_length_ / 2 was change to sub_length_. - -
- - -
-
-01-02 - -
  1. -The thread_alloc - memory allocator was changed to avoid -certain false sharing situations -(cases where two different thread were changing and using memory -that is on the same page of cache). -On one tests machine, the execution time for the 32 thread case for the test -
     
    -./openmp_test multi_newton 1 32 1000 4800 10 true
    -
    -improved from 0.0302 seconds to 0.0135 seconds. - -
  2. - -There was a problem with the correctness test section of the -multi_newton_time - test. -The convergence criteria, and correctness criteria, -needed to be scaled by the largest argument values. -This was a problem with over a hundred zeros were included in the test -(and the largest argument value was - -100 -π - - - or more). - -
  3. - -There was a problem with the way that -multi_newton_takedown - -joined two solutions into one. -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. - -
- -for the previous - - -
Input File: omh/appendix/whats_new/whats_new_12.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_12_xml.js cppad-2019.02.00.0/doc/_whats_new_12_xml.js --- cppad-2018.00.00.0/doc/_whats_new_12_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_12_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,190 +0,0 @@ -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_12.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_12.xml#Introduction', -'whats_new_12.xml#12-30', -'whats_new_12.xml#12-29', -'whats_new_12.xml#12-28', -'whats_new_12.xml#12-27', -'whats_new_12.xml#12-26', -'whats_new_12.xml#12-23', -'whats_new_12.xml#12-22', -'whats_new_12.xml#12-20', -'whats_new_12.xml#12-19', -'whats_new_12.xml#12-17', -'whats_new_12.xml#12-15', -'whats_new_12.xml#12-14', -'whats_new_12.xml#12-13', -'whats_new_12.xml#11-28', -'whats_new_12.xml#11-21', -'whats_new_12.xml#11-20', -'whats_new_12.xml#11-17', -'whats_new_12.xml#11-16', -'whats_new_12.xml#11-14', -'whats_new_12.xml#11-09', -'whats_new_12.xml#11-06', -'whats_new_12.xml#11-04', -'whats_new_12.xml#10-31', -'whats_new_12.xml#10-30', -'whats_new_12.xml#10-25', -'whats_new_12.xml#10-24', -'whats_new_12.xml#10-12', -'whats_new_12.xml#10-04', -'whats_new_12.xml#10-03', -'whats_new_12.xml#10-02', -'whats_new_12.xml#09-24', -'whats_new_12.xml#09-11', -'whats_new_12.xml#08-05', -'whats_new_12.xml#07-30', -'whats_new_12.xml#07-08', -'whats_new_12.xml#07-07', -'whats_new_12.xml#07-05', -'whats_new_12.xml#07-04', -'whats_new_12.xml#07-03', -'whats_new_12.xml#07-02', -'whats_new_12.xml#07-01', -'whats_new_12.xml#06-17', -'whats_new_12.xml#06-16', -'whats_new_12.xml#06-15', -'whats_new_12.xml#06-12', -'whats_new_12.xml#06-10', -'whats_new_12.xml#06-09', -'whats_new_12.xml#06-08', -'whats_new_12.xml#06-07', -'whats_new_12.xml#06-05', -'whats_new_12.xml#06-04', -'whats_new_12.xml#06-03', -'whats_new_12.xml#06-02', -'whats_new_12.xml#06-01', -'whats_new_12.xml#05-31', -'whats_new_12.xml#05-30', -'whats_new_12.xml#05-29', -'whats_new_12.xml#05-27', -'whats_new_12.xml#05-24', -'whats_new_12.xml#04-19', -'whats_new_12.xml#04-18', -'whats_new_12.xml#04-17', -'whats_new_12.xml#04-10', -'whats_new_12.xml#04-06', -'whats_new_12.xml#04-05', -'whats_new_12.xml#04-01', -'whats_new_12.xml#03-27', -'whats_new_12.xml#03-26', -'whats_new_12.xml#03-23', -'whats_new_12.xml#03-21', -'whats_new_12.xml#03-17', -'whats_new_12.xml#03-11', -'whats_new_12.xml#03-03', -'whats_new_12.xml#03-02', -'whats_new_12.xml#02-11', -'whats_new_12.xml#02-10', -'whats_new_12.xml#02-09', -'whats_new_12.xml#01-30', -'whats_new_12.xml#01-27', -'whats_new_12.xml#01-24', -'whats_new_12.xml#01-23', -'whats_new_12.xml#01-20', -'whats_new_12.xml#01-19', -'whats_new_12.xml#01-16', -'whats_new_12.xml#01-15', -'whats_new_12.xml#01-12', -'whats_new_12.xml#01-07', -'whats_new_12.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-2018.00.00.0/doc/whats_new_13.xml cppad-2019.02.00.0/doc/whats_new_13.xml --- cppad-2018.00.00.0/doc/whats_new_13.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_13.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,774 +0,0 @@ - - - -CppAD Changes and Additions During 2013 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_13 - -

- - - - -
CppAD Changes and Additions During 2013
-
-Introduction -
-This section contains a list of the changes to CppAD during 2013 -(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 - -
  1. -The include file -cppad_eigen.hpp - now automatically includes cppad.hpp. -
  2. - -There was a problem with this automation -when eigen was used for the cppad testvector -. -This has been fixed. -
  3. - -There was a problem with deprecated autotools - -(created when optional implicit constructor from any type was added). -This has been fixed by adding the ---with-implicit_ctor option -(later removed on 2017-02-10 -.) -
- - -
-
-12-27 -
-The constructor from an arbitrary type to -AD<Base> - was -implicit, but there was no specification to this effect. -The caused problems when using CppAD with -eigen 3.2 - (scheduled to be fixed in 3.3). -The default for this constructor has been changed to be -explicit -. -In addition, other -implicit - constructors -are now listed in the documentation. -
-
-
If you get a compiler error on an constructor / assignment of the form - -
-     AD<
Base> x = y
-
-(that used to work) try changing the constructor call to - -
-     AD<
Base>( y )
-
-A deprecated alternative is to make this constructor implicit using the -cppad_deprecated - -option during the install procedure. - -
-
-12-26 -
-Document fact that -monthly versions - -of the CppAD compressed tar file last till the end of the year. - -
-
-12-24 -
-The interface to eigen - defined a function - -
-     NumTraits< CppAD::AD<
Base> >::dummy_epsilon()
-
-that should have been named dummy_precision(). -This has been fixed. - -
-
-11-27 - -
  1. -Fix bug when using optimize - with an ADFun - object containing -the sign - function. -
  2. - -Add atomic_norm_sq.cpp -, an atomic function example -with domain dimension two and range dimension one. -
- - -
-
-11-13 -
-It used to be that one had to define the std::set version of -atomic_rev_sparse_jac - for each atomic function that was -part of an ADFun - object that was optimized -. -Now the current -atomic_sparsity - setting is used -to determine if the bool or std::set version of -rev_sparse_jac is used by the optimization process. - -
-
-11-12 -
-Error detection and reporting (when NDEBUG is not defined) -has been added for the following case: -Using optimize - -with atomic_base - functions that have not defined -rev_sparse_jac -. - -
-
-10-29 -
-The optimization - -now handles nested conditional expressions. -For example, give 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 conditional expressions will be evaluated -(one will be skipped depending on the result of left_z == right_z). -For more details, see optimize_nest_conditional.cpp -. - -
-
-10-23 - -
  1. -Fix a bug in the optimization of calls to atomic - functions. -This bug existed before recent change to optimizing conditional expressions. -This required adding the -dependency - argument to the -reverse Jacobian sparsity pattern calculation. -
  2. - -Fix the deprecated autotools install (see autotools -) -which was broken by the changes on 10-22. -To be specific, the -example for number_skip - was not being included. -
- - -
-
-10-22 - -
  1. -Add optimization - of conditional expressions; see -CondExp -. -
  2. - -Add a phantom argument at the beginning of the operations sequence; -size_op_arg - and seq_property.cpp -. -(This helps with the optimization mentioned above.) -
  3. - -Add the function number_skip - to measure how much optimization -of the conditional expressions there is. -
- - -
-
-10-16 -
-Fix bug in Tracing - atomic - functions. - -
-
-10-15 -
-The documentation for the class -vectorBool - was improved. - -
-
-10-14 -
-The script get_adolc.sh - was added -(for downloading and installing -ADOL-C -) in the -build directory. -Note that this local install of Adolc requires ColPack; see -get_colpack.sh -. -In addition, the requirement that ColPack and Adolc are installed -with the same prefix was added. - -
-
-10-13 -
-Make sure that all of the -preprocessor symbols -, -that are not part of the CppAD API, are undefined when the -<cppad/cppad.hpp> file concludes. - -
-
-10-12 - -
  1. -Change get_eigen.sh - so that it will reuse install information -when it is present. -In addition document reuse for -get_eigen.sh -, -get_ipopt.sh -, and -get_sacado.sh -. -
  2. - -Fix following g++ error on OSX system: -
     
    -error: no match for 'operator|=' (operand types are
    -'std::vector<bool>::reference {aka std::_Bit_reference}' and 'bool')
    -    Check[i * n + j] |= F2[i * n + k] & r[ k * n + j];
    -                     ^
    -
    -
-
-09-20 - -
  1. -Add lines for atomic_base - function documentation -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 -atomic forward examples -. -
  2. - -Improve the documentation for atomic_base_clear - -and remove its use from the -atomic_base examples - -(because it is not needed). -
- - -
-
-09-19 -
-Add links from the 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 -atomic forward examples -. - -
-
-09-18 - -
  1. -A segmentation fault would occur if -an ADFun - object used an atomic - -function that had been deleted. -This has been fixed so that when NDEBUG is not defined, -an error message is generated. -
  2. - -A mistake in the documentation for -Memory and Parallel Mode - -has been fixed. -This corresponds to the change in the specifications for -CppAD::vector::resize - made on -2012-07-30 - -
  3. - -There was a bug during the -checking for nan - during -reverse - mode. -This has been fixed. -
  4. - -It appears, from inspecting the Ipopt source file -Ipopt/src/Algorithm/IpIpoptAlg.cpp that the option sb -to yes suppress the printing of the Ipopt banner. -The Ipopt examples and tests have been changed to use this option -(although it is not in the ipopt documentation). -
  5. - -Fix the a typo in the documentation for ipopt_solve -Integer - options -(Numeric was changed to Integer). -
- - -
-
-09-07 -
-There was a bug in the cumulative sum operator -(which is used by optimize - ) -for Forward - orders greater than zero. -This was detected by the checkpoint - tests -when 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). - -
-
-08-12 - -
  1. -The ability to turn on and off checking for nan - in -Forward - mode results has been added; see check_for_nan -. -
  2. - -Use this option to remove the need to handel nan as a special -case in checkpoint - functions that -atomic functions - in within -another function is optimized. -
  3. - -Check reverse - mode results when -check_for_nan - is true. -(It used to be the case that only forward - results -were checked for nan.) -
- - -
-
-08-11 -
-If an atomic - function had arguments that did not affect -the final dependent variables in -f -, -f.optimize() - would fail. -This has been fixed. -In addition, documentation about using optimize -with atomic functions - has been added. - -
-
-08-06 -
-Fix a case where the test test_more/num_limits.cpp failed because -
 
-     double inf   = std::numeric_limits<double>::infinity();
-     double check = std::complex<double>(inf) / std::complex<float>(1.)
-
-can result in the imaginary part of check being - nan. - -
-
-07-26 -
-Allow for use of const::string& as a possible type for -name - in the atomic_base -constructor. - -
-
-05-28 -
-Remove -ok - return flag from -checkpoint algo - -and -checkpoint atom_fun -. - -
-
-05-21 - -
  1. -Deprecate the old_atomic - interface and replace it by the -atomic_base - and checkpoint - interfaces. -
  2. - -There was a problem with the cmake - command -if the cppad_cxx_flags - was not specified. -This has been fixed. -
- - - -
-
-05-17 - -
  1. -Add the transpose - option to -ForSparseJac -. -
  2. - -Add the transpose - option to -RevSparseHes -. -
- - -
-
-05-15 -
-Change RevSparseJac - parameter names to be closer to the -ForSparseJac - names so the difference is clearer. - -
-
-05-14 - -
  1. -The checkpoint - class has been added. -This is a much easier way to do checkpointing than the -old checkpoint example. -The old checkpointing example is now the reverse_checkpoint.cpp - example. -
  2. - -Fix bug in RevSparseJac - for case when q - -was not equal to -m - (range dimension) and sparsity pattern was a -vector of bool. -
  3. - -Add the transpose - option to -RevSparseJac -. -
- - -
-
-05-12 -
-The sparse hessian example in old_reciprocal.cpp - was not -being run. This has been fixed. - -
-
-05-11 -
-The old_atomic examples - -names were all changed to begin with user. - -
-
-05-04 -
-The option to compute -multiple orders - was added. -The old_usead_2.cpp - example shows the need for this. -The problem is that a new atomic function interface needs to be designed -with checkpointing as a particular application. -Multiple order forward mode is the first step in this direction. - -
-
-04-28 - -
  1. -The scripts get_eigen.sh - and get_sacado.sh - were added. -If you are using Unix, and you do not have -Eigen - or -Sacado - -installed on your system, you can use the corresponding script -to download and install a local copy for use when testing CppAD. -
  2. - -The code -std::cout << X -, -would generate a compile error when -X - was an Eigen matrix -with -CppAD::AD<Base> - elements. -This has been fixed. -
- - - -
-
-04-27 -
-There was a problem using the output operator << with -and eigen - matrix of AD elements. -This has been fixed using a template partial specialization of -
 
-     template<typename Scalar, bool IsInteger>
-     struct significant_decimals_default_impl
-
-because the original template requires definition of a implicit conversion -from the scalar type to an int and this is dangerous for AD types -(note that Integer - is used for explicit conversions). - - -
-
-04-26 - -
  1. -The example 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. -
  2. - -The script get_fadbad.sh - has been added. -If you are using Unix, and you do not have -FADBAD - -installed on your system, you can use this script -to download and install a local copy for use when testing CppAD. -
- - - -
Input File: omh/appendix/whats_new/whats_new_13.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_13_xml.js cppad-2019.02.00.0/doc/_whats_new_13_xml.js --- cppad-2018.00.00.0/doc/_whats_new_13_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_13_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,136 +0,0 @@ -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_13.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_13.xml#Introduction', -'whats_new_13.xml#12-29', -'whats_new_13.xml#12-27', -'whats_new_13.xml#12-26', -'whats_new_13.xml#12-24', -'whats_new_13.xml#11-27', -'whats_new_13.xml#11-13', -'whats_new_13.xml#11-12', -'whats_new_13.xml#10-29', -'whats_new_13.xml#10-23', -'whats_new_13.xml#10-22', -'whats_new_13.xml#10-16', -'whats_new_13.xml#10-15', -'whats_new_13.xml#10-14', -'whats_new_13.xml#10-13', -'whats_new_13.xml#10-12', -'whats_new_13.xml#09-20', -'whats_new_13.xml#09-19', -'whats_new_13.xml#09-18', -'whats_new_13.xml#09-07', -'whats_new_13.xml#08-12', -'whats_new_13.xml#08-11', -'whats_new_13.xml#08-06', -'whats_new_13.xml#07-26', -'whats_new_13.xml#05-28', -'whats_new_13.xml#05-21', -'whats_new_13.xml#05-17', -'whats_new_13.xml#05-15', -'whats_new_13.xml#05-14', -'whats_new_13.xml#05-12', -'whats_new_13.xml#05-11', -'whats_new_13.xml#05-04', -'whats_new_13.xml#04-28', -'whats_new_13.xml#04-27', -'whats_new_13.xml#04-26' -]; -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-2018.00.00.0/doc/whats_new_14.xml cppad-2019.02.00.0/doc/whats_new_14.xml --- cppad-2018.00.00.0/doc/whats_new_14.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_14.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,875 +0,0 @@ - - - -CppAD Changes and Additions During 2014 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_14 - -

- - - - -
CppAD Changes and Additions During 2014
-
-Introduction -
-This section contains a list of the changes to CppAD during 2014 -(in reverse order by date). -The purpose of this section is to -assist you in learning about changes between various versions of CppAD. - -
-
-12-30 -
-There was a bug in the cmake - whereby it would sometimes mistakenly -exit with the error message -
 
-     cppad_max_num_threads is not an integer greater than or equal 4
-
-This has been fixed. - -
-
-12-29 -
-The example not_complex_ad.cpp was using the type - -
-     std::complex< CppAD::AD<double> >
-
-and was failing to compile with the clang complier. -This example has been removed because it is not consistent with the -C++ standard; see -complex FAQ -. - - -
-
-12-28 - -
  1. -Fix some warnings generated by clang 3.5 about local functions -that were not being used; e.g., sub-tests that were not being executed. -
  2. - -Fix cmake setting -cppad_implicit_ctor_from_any_type -Note that this cmake option has since been replaced by -cppad_deprecated -. -
  3. - -The clang++ compiler was optimizing out the calculations -in the time_test.cpp - and speed_test.cpp - examples. -This caused these tests to hang while trying to determine how -many times to repeat the test. -This has been fixed. -
- - -
-
-12-27 -
-More work on the bug in -optimizing - -conditional expressions. - -
-
-12-26 -
-A minimal example for computing cross terms in atomic operation -Hessian sparsity patterns atomic_rev_sparse_hes.cpp - was added. - -
-
-12-25 -
-More work on the bug in -optimizing - -conditional expressions. - -
-
-12-23 -
-The c++11 standard includes the error function erf - in -cmath. -If the c++ compiler has the error function defined in cmath, -the complier version of the error function is used and it corresponds to an -atomic operation. -
-
-
Fix typo in tangent reverse mode theory for -Positive Orders -. - -
-
-12-22 -
-There was a bug related to -optimizing - -conditional expressions. -This has been fixed. - -
-
-12-17 -
-Fix some compiler warnings and speed - program names -when using the deprecated autotools - install procedure. - -
-
-12-16 -
-If the c++11 include file <cstdint> -defines all the standard types, they can be used by to specify -cppad_tape_addr_type - and -cppad_tape_id_type -. - -
-
-12-15 -
-Correct the title and _index - entries for forward_two - -from first to second order. - -
-
-11-28 -
-Improve the index - and search using -a new version of the omhelp documentation tool. - -
-
-11-27 - -
  1. -Add alignment to the -get_memory - and -create_array - specifications -and -thread_alloc example -. -
  2. - -Advance the deprecated unix install - utilities to -autoconf-2.69 and automake-1.13.4. -
- - -
-
-09-28 -
-Fix more bugs related to optimizing condition conditional expressions. -
  1. -Using old instead of new operator indices. -
  2. - -Not properly following dependence back through atomic operations. -
  3. - -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). -
  4. - -Reverse mode not properly handling the variable number of arguments in the -conditional skip operation. -
  5. - -Reverse mode tracing not properly handling the variable number -of argument operations; i.e., conditional skip and cumulative summation. -
- - -
-
-09-27 -
-Fix a bug that occurred when -f.optimize - was used with a function -f - -that contained calls to user defined atomic - operations -and conditional expressions -. - -
-
-09-25 -
-Fix a bug that occurred when -f.optimize - was used with a function -f - -that contained discrete - functions. - -
-
-09-21 -
-Fix a typo in documentation for -any order reverse -. -To be specific, - -x -( -k -) - - - - - was changed to be - -u -( -k -) - - - - -. - -
-
-05-28 - -
  1. -Change the boolsparsity - -so that it only affects the sparsity speed tests -sparse_jacobian - and -sparse_hessian -; -i.e., it is now ignored by the other tests. -
  2. - -Improve the speed - documentation page. -
- - -
-
-05-27 - -
  1. -The 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 because -cppad_colpack.cpp is not an include file. -
  2. - -If colpack_prefix - was specified, the CppAD -pkgconfig - file was missing some information. -This has been fixed. -
- - -
-
-05-23 -
-The speed - test instructions were converted from using -the old autotools unix install - instructions -to use the cmake - install instructions. -These instructions should work on any system, not just unix. - -
-
-05-22 - -
  1. -Add multiple direction for mode -forward_dir - and use it to speed up the forward -version of sparse_jacobian -. -Below is an example run of cppad_sparse_jacobian.cpp - results -before this change: -
     
    -     cppad_sparse_jacobian_size = [ 100, 400, 900, 1600, 2500 ]
    -     cppad_sparse_jacobian_rate = [ 2973, 431.94, 142.25, 78.64, 26.87 ]
    -
    -and after this change: -
     
    -     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, -multiple direction items were added to the wish list -(they were later removed). -
  2. - -Improve the forward mode tracing of arguments to, -and results from, user defined atomic - operations. -
- - -
-
-05-20 - -
  1. -Move speed/adolc/alloc_mat.hpp to -speed/adolc/adolc_alloc_mat.hpp so it has the -same name is its # ifndef command. -
  2. - -Fix # ifndef command in -cppad/ipopt/solve_callback.hpp. -
  3. - -Add # ifndef command to test_more/extern_value.hpp. -
- - - -
-
-05-19 -
-In the files -cppad/local/asin_op.hpp and cppad/local/acos_op.hpp -there were assignments of the form uj = 0. where u_j -has type Base -. -These may have not be defined operations in certain cases and -have been converted to uj = Base(0). - - -
-
-05-16 -
-There was a mistake in printing the arguments for -CSumOp and CSkipOp when using the undocumented -TRACE option during forward mode (available in files of the form - -cppad/local/*sweep.hpp/ -). -This has been fixed. - -
-
-05-14 - -
  1. -There were some global variables in the file -cppad/local/op_code.hpp that might have caused multiple definitions -during link time for CppAD applications. -These variables have been changed to be local so that this cannot happen. -
  2. - -There was a mistaken assert that the number of arguments for the -BeginOp was zero that caused an abort when using the undocumented -TRACE option available in files of the form - -cppad/local/*sweep.hpp/ -. -This has been fixed. -
- - -
-
-03-18 - -
  1. -The -size_taylor - -and -capacity_taylor - -functions were deprecated; -use size_order - and capacity_order - instead. -
  2. - -The documentation for forward - and the examples -forward.cpp -, forward_order.cpp -, have been improved. -To be more specific, forward_order - now references the special -cases forward_zero -, forward_one - and the new case -forward_two -. -
- - -
-
-03-17 -
-The -move semantics - -version of the CppAD::vector assignment statement -was not checking vector sizes. -This has been fixed so that things work the same with compilers -that do not have move semantics. -(Note that with move semantics, no extra memory allocation is done -even if the target vector has a different size.) - -
-
-03-09 -
-The documentation links -forwardzero, forwardone, and forwardany -have been changed to -forward_zero -, forward_one -, -and forward_order - respectively. -This may affect links from other web pages to the CppAD documentation. - -
-
-03-05 -
-The names -p - and -q - in the -forward -, -reverse -, -atomic_forward -, and -atomic_reverse - functions -were reverse so that -p <= q -. -This is only a notational change to make the arguments easier to remember. - -
-
-03-02 - -
  1. -In the output for the speed -correct - test, -mention which tests are not available. -Note that the set of available tests can depend on the -list of options -. -
  2. - -In the documentation for -n_sweep -, -mention that it is equal to the number of colors determined by the -color_method -. -
  3. - -The speed_cppad - tests were simplified by removing the printing -of auxillary information related to the -optimize - option. -Future auxillary information will be passed back in a manner similar to -n_sweep - for the sparse jacobian test. -
  4. - -Move semantics - -were added to the CppAD::vector assignment operator. -
- - -
-
-03-01 - -
  1. -Change the prototype for -row - and -col - in the -link_sparse_jacobian - speed test to be const; i.e., -they are not changed. -
  2. - -Move -x - near end of link_sparse_hessian - speed test -parameter list, -(as is the case for link_sparse_jacobian -). -
- - -
-
-02-28 -
-The data - function was added to the -CppAD::vector template class. - -
-
-02-27 -
-The CppAD developer documentation for the subdirectory -cppad/ipopt was not being built by the command -bin/run_doxygen.sh. -This has been fixed. - -
-
-02-26 - -
  1. -The -adolc - and -cppad - sparse jacobian speed tests now print out -n_sweep -. -
  2. - -The size of some of the speed - test cases has been increased -to test behavior for larger problems. -
  3. - -A link to ode_evaluate - was missing in the -Speed Utility Routines - table. -This has been fixed. -
- - - -
-
-02-23 -
-The color_method - -option was added to the sparse Jacobian calculations. -This enables one to use ColPack - -do color the rows or columns. -The speed test colpack - option -was also added (but not yet implemented for -sparse_hessian - speed tests). - - -
-
-02-22 -
-The program names in -thread_test.cpp - where changes from - -threading_test - to -multi_thread_threading - -where -threading - is openmp, pthread or bthread. - -
-
-02-17 -
-Fix ambiguous call to isnan - -during MS Visual Studio 2012 compilation. - -
-
-02-15 - -
  1. -The boolsparsity - option -was added to the speed_main - program. -
  2. - -The retape option what changed to -onetape - so that the default -is to retape (option not present). -This was done because -fadbad - and -sacado - always retape. -
  3. - -The documentation, and example source code, for all the speed -options - was improved -(made clearer). -
  4. - -Improve the success rate for -speed_test.cpp - and time_test.cpp -. -
- - -
-
-01-26 -
-The destination directory for the -cppad documentation - -is now set separately from the data directory -using the cmake option - -
-     -D cmake_install_docdir=
cmake_install_docdir
-
-This has increased the flexibility of the documentation installation -and removed the need for the option - -
-     -D cppad_documentation=
yes_or_no
-
-which has been removed. - -
-
-01-21 -
-The destination directory for the -cppad documentation -used to be one of the following: - -
-     
prefix/datadir/doc/cppad-version
-     
prefix/datadir/doc/postfixcppad-version
-
-This has been changed by dropping the -version - number -at the end of the directory name. - -
-
-01-10 -
-The change on 2013-12-27 - -caused a conversion error in atan2 - when it was used with -AD< AD<double> > arguments (and other similar cases). -This has been fixed. - - -
Input File: omh/appendix/whats_new/whats_new_14.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_14_xml.js cppad-2019.02.00.0/doc/_whats_new_14_xml.js --- cppad-2018.00.00.0/doc/_whats_new_14_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_14_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ -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_14.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_14.xml#Introduction', -'whats_new_14.xml#12-30', -'whats_new_14.xml#12-29', -'whats_new_14.xml#12-28', -'whats_new_14.xml#12-27', -'whats_new_14.xml#12-26', -'whats_new_14.xml#12-25', -'whats_new_14.xml#12-23', -'whats_new_14.xml#12-22', -'whats_new_14.xml#12-17', -'whats_new_14.xml#12-16', -'whats_new_14.xml#12-15', -'whats_new_14.xml#11-28', -'whats_new_14.xml#11-27', -'whats_new_14.xml#09-28', -'whats_new_14.xml#09-27', -'whats_new_14.xml#09-25', -'whats_new_14.xml#09-21', -'whats_new_14.xml#05-28', -'whats_new_14.xml#05-27', -'whats_new_14.xml#05-23', -'whats_new_14.xml#05-22', -'whats_new_14.xml#05-20', -'whats_new_14.xml#05-19', -'whats_new_14.xml#05-16', -'whats_new_14.xml#05-14', -'whats_new_14.xml#03-18', -'whats_new_14.xml#03-17', -'whats_new_14.xml#03-09', -'whats_new_14.xml#03-05', -'whats_new_14.xml#03-02', -'whats_new_14.xml#03-01', -'whats_new_14.xml#02-28', -'whats_new_14.xml#02-27', -'whats_new_14.xml#02-26', -'whats_new_14.xml#02-23', -'whats_new_14.xml#02-22', -'whats_new_14.xml#02-17', -'whats_new_14.xml#02-15', -'whats_new_14.xml#01-26', -'whats_new_14.xml#01-21', -'whats_new_14.xml#01-10' -]; -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-2018.00.00.0/doc/whats_new_15.xml cppad-2019.02.00.0/doc/whats_new_15.xml --- cppad-2018.00.00.0/doc/whats_new_15.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_15.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1633 +0,0 @@ - - - -CppAD Changes and Additions During 2015 - - - - - - - - - - - - - - - - -
- -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-31 -
-The download - instructions were modified to have more mention of -using git - and less mention of -subversion -. - -
-
-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 autotools - install handling of the -deprecated files. -This included changing the autotools ---with-implicit_ctor option to autotools -. -This was removed on -2017-02-10 -. - -
-
-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. -(This has since been replaced by rc_sparsity.cpp -.) -
  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 wish list item. -This has been done, -see no_print_for_op -. - -
-
-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 example/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 autotools - 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 autotools - 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 -no_compare_op -. - -
  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/appendix/whats_new/whats_new_15.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_15_xml.js cppad-2019.02.00.0/doc/_whats_new_15_xml.js --- cppad-2018.00.00.0/doc/_whats_new_15_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_15_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ -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', -'directory.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_17.xml', -'whats_new_16.xml', -'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-31', -'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-2018.00.00.0/doc/whats_new_16.xml cppad-2019.02.00.0/doc/whats_new_16.xml --- cppad-2018.00.00.0/doc/whats_new_16.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_16.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,915 +0,0 @@ - - - -Changes and Additions to CppAD During 2016 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_16 - -

- - - -
Changes and Additions to CppAD During 2016
-
-Introduction -
-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. - -
-
-12-23 -
-Added a way for the user to determine what tests options are available; see -make check -. - -
-
-12-20 -
-Change the optimize examples - to use -NearEqual - for floating point tests (instead of exactly equal). -There were some other exactly equal floating point tests that were -failing on a mingw system. Theses have also been fixed. - -
-
-12-18 -
-Add the no_print_for_op - to the -optimize routine. - -
-
-12-13 - -
  1. -Fix a bug in ForSparseHes -. To be more specific, -there was a bug in handling the cumulative summations operator in this -routine. This could only come up when used -an optimized - f -, -
  2. - -Add the -nest_conditional.cpp - example. -
- - - -
-
-12-11 -
-Improve the optimize - documentation. -This includes making examples that demonstrate -specific aspects of the optimization; see -forward_active.cpp -, -reverse_active.cpp -, -compare_op.cpp -, -conditional_skip.cpp -, -cumulative_sum.cpp -. - - -
-
-12-09 -
-The options - argument was added to the -optimize routine. - -
-
-11-18 -
-Move classes and functions that are part of the user API from the -cppad/local directory to the cppad/core directory. -The remaining symbols, in the cppad/local directory, are now -in the CppAD::local namespace. -Note that a class in the CppAD name space, may have a member -function that is not part of the user API. - -
-
-11-14 -
-Increase the speed of the sparse_pack class. -This improves the speed for -vector of boolean - -sparsity pattern calculations. - -
-
-11-13 -
-Merged in the sparse branch which has const_iterator, -instead of next_element for the -sparse_list and sparse_pack classes. -These classes are not part of the CppAD API and hence their specifications -can change (as in this case). -They can be used to get more efficient representations of -sparsity patterns -. - -
-
-10-27 -
-The optional optimize - option -was added to the checkpoint functions. - -
-
-10-12 - -
  1. -Change elapsed_seconds - to use -std::chrono::steady_clock instead of -std::chrono::high_resolution_clock. -
  2. - -The test for C++11 features was failing on a Mac system -because the elapsed time was returning as zero (between two events). -This test has been made more robust by add a one millisecond sleep -between the two clock accesses. -
- - - -
-
-09-29 -
-The multiple directions version of -forward - was missing erf - function -in the case where C++ 2011 was supported; see -issue 16 -. -This has been fixed. - -
-
-09-27 -
-Change the implementation of atomic_eigen_cholesky.hpp - so that -the computation of - -M -k - - - - exactly agrees with the corresponding -theory -. - -
-
-09-26 - -
  1. -A possible bug in the optimize - command was fixed. -To be specific, a warning of the form -indentations; - -
    -     warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    -
    -using the gcc-6.2.1 compiler, was fixed and it may have fixed a bug. -
  2. - -There was a problem with the -sacado - where the symbol -HAS_C99_TR1_CMATH was being defined twice. -This has been fixed by leaving it up to the sacado install to determine -if this symbol should be defined. -
- - -
-
-09-16 -
-Fix a problem using the -colpack - option to the -speed_cppad program. -(There was a problem whereby the speed_cppad -program did not properly detect when colpack was available.) - -
-
-09-13 -
-Test third order and fix -bug in atomic_eigen_cholesky.hpp - for orders greater -than or equal to three. - -
-
-08-30 -
-Add the atomic_eigen_cholesky.cpp - example. - -
-
-08-25 - -
  1. -Fix some missing include files in -optimize.hpp and set_union.hpp -(when compiling with MS Visual Studio 2015). -
  2. - -Fix a warning in atanh.hpp -(when compiling with MS Visual Studio 14). -
  3. - -Fix a typo in the -Reverse - section of the -eigen_mat_inv.hpp example. -
- - -
-
-07-17 -
-Add documentation for only needing to compute a -column subset - of the sparsity -pattern when computing a subset of a sparse Hessians. -In addition, improve the corresponding example -sparse_sub_hes.cpp -. - -
-
-07-14 -
-Correct title in ForSparseHes - (change Reverse to Forward). - -
-
-06-30 -
-Change the atomic_mat_mul.cpp - example so that on atomic object -works for matrices of any size. - -
-
-06-29 -
-Change the atomic_base - examples so they do no longer use the -deprecated atomic function - interfaces to -for_sparse_jac, rev_sparse_jac, -for_sparse_hes, and rev_sparse_hes. - -
-
-06-27 - -
  1. -Improve the atomic_eigen_mat_mul.hpp - and -atomic_eigen_mat_inv.hpp - examples. -Most importantly, one atomic object now works for matrices of any size. -
  2. - -Add the vector -x -, -that contains the parameters in an atomic function call -to the user following atomic functions: -for_sparse_jac -, -rev_sparse_jac -, -for_sparse_hes -, -rev_sparse_hes -. -This enables one to pass parameter information to these functions; e.g., -the dimensions of matrices that the function operates on. -
- - - -
-
-06-25 -
-Add more entries to the optimization -wish_list -. - -
-
-06-10 -
-Add a check_finite - wish list item. - -
-
-05-05 - -
  1. -Add documentation for -redirecting output - for the -PrintFor function. -
  2. - -Change distributed version to build examples as debug instead -of release version. -(Was changed to release version while checking for compiler warnings; -see 04-17 below). -
- - -
-
-04-17 -
-Fix all some compiler warnings that occurred when compiling the -examples - with -NDEBUG - defined. - -
-
-03-27 - -
  1. -Fix a bug in the calculation of the atomic_eigen_mat_inv.hpp - -reverse - example. -
  2. - -Use a very simple method (that over estimates variables) for calculating -vy - in the atomic_eigen_mat_inv.hpp - -forward - example. -
- - -
-
-03-26 - -
  1. -Implement and test the atomic_eigen_mat_inv.cpp - -reverse - is implemented. -
  2. - -Fix a bug in the calculation of -vy - in the atomic_eigen_mat_inv.hpp - -forward - example. -
- - - -
-
-03-25 - -
  1. -Start construction of the atomic_eigen_mat_inv.cpp - example, -currently only -forward - is implemented -and tested. -
  2. - -More improvements to atomic_eigen_mat_mul.cpp - example. -
- - -
-
-03-24 - -
  1. -Fix build of example/atomic.cpp when -eigen_prefix - is not available -(bug introduced when atomic_eigen_mat_mul.cpp - was added). -
  2. - -Extend atomic_eigen_mat_mul.cpp - example to include -for_sparse_jac -, -rev_sparse_jac -, -for_sparse_hes -, -rev_sparse_hes -. -
  3. - -Fix a bug in the ForSparseHes - routine. -
  4. - -Edit atomic_rev_sparse_hes - documentation. -
- - -
-
-03-23 - -
  1. -Fix bug in autotools file example/atomic/makefile.am -(introduced on 03-22). -
  2. - -Improve the atomic_eigen_mat_mul.cpp - example -and extend it to include reverse mode. -
- - -
-
-03-22 - -
  1. -Start construction of the atomic_eigen_mat_mul.cpp - example. -
  2. - -change atomic_ode.cpp to checkpoint_ode.cpp - and -atomic_extended_ode.cpp to checkpoint_extended_ode.cpp -. -
- - -
-
-03-21 -
-Change the atomic_mat_mul.hpp - class name from mat_mul -to atomic_mat_mul. This example use of the name mat_mul -in the atomic_mat_mul.cpp - example / test. - -
-
-03-20 - -
  1. -Include the sub-directory name to the include guards -in -*.hpp - files. For example, -
     
    -     # ifndef CPPAD_UTILITY_VECTOR_HPP
    -     # define CPPAD_UTILITY_VECTOR_HPP
    -
    -appears in the file cppad/utility/vector.hpp. This makes it -easier to avoid conflicts when choosing addon - names. -
  2. - -Add the set_union - utility and use it to simplify the -atomic - examples that use -vector of sets - -sparsity patterns. -
- - - -
-
-03-19 - -
  1. -Move atomic_mat_mul.cpp - to atomic_mat_mul_xam.cpp -(moved back on 03-21 -. -
  2. - -Move atomic_matrix_mul.hpp to atomic_mat_mul.hpp -. -
- - -
-
-03-17 -
-Add the -atomic_ode.cpp and atomic_extended_ode.cpp examples. - -
-
-03-12 - -
  1. -Move the example reverse_any.cpp to reverse_checkpoint.cpp -. -
  2. - -Add the atomic_mul_level.cpp - example. -
- - -
-
-03-05 -
-The following atomic function examples were added -These examples are for a specific atomic operation. -In addition, the domain and range dimensions for these examples -are not one and not equal to each other: -atomic_forward.cpp -, -atomic_reverse.cpp -, -atomic_for_sparse_jac.cpp -, -atomic_rev_sparse_jac.cpp -, -atomic_for_sparse_hes.cpp -, -atomic_rev_sparse_hes.cpp -. - - -
-
-03-01 - -
  1. -Improve documentation of implementation requirements for the atomic -rev_sparse_jac -. -
  2. - -Make some corrections to the atomic_for_sparse_hes - documentation. -and fix a bug in how CppAD used these functions. -
- - -
-
-02-29 - -
  1. -Merged sparse into master branch. This makes the -ForSparseHes - routine available for use. -
  2. - -Changed the -global options - -in the speed test main program to use one global variable with prototype -
    
    -     extern std::map<std::string, bool> global_option;
    -
    -
-
-02-28 -
-Fix a mistake in the old atomic -example/sparsity/sparsity.cpp example. -This example has since been changed to -atomic_set_sparsity.cpp -. - - -
-
-02-27 -
-The --with-sparse_set and --with-sparse_set options -were removed from the autotools - install procedure. - -
-
-02-26 -
-The condition that the operation sequence in -f - is -independent - of -the independent variables was added to the statement about -the validity of the sparsity patterns; see -x - in -ForSparseJac -, -RevSparseJac -, and -RevSparseHes -. - -
-
-02-25 -
-The cmake - command line argument cppad_sparse_list -has been removed (because it is so much better than the other option). - -
-
-02-23 -
-A new version of the -cppad_sparse_list class (not part of user API) uses -reference counters to reduce the number of copies of sets that are equal. -This improved the speed of sparsity pattern computations that use -the vector of sets - -representation. -For example, the results for the -cppad_sparse_hessian.cpp - test compare as follows: -
 
-     sparse_hessian_size     = [  100,    400,   900,  1600, 2500 ]
-     sparse_hessian_rate_old = [ 1480, 265.21, 93.33, 41.93, 0.86 ]
-     sparse_hessian_rate_new = [ 1328, 241.61, 92.99, 40.51, 3.80 ]
-
-Note that the improvement is only for large problems. In fact, -for large problems, preliminary testing indicates that -the new vector of sets representation preforms better than -the vector of boolean - -representation. - - -
-
-01-21 -
-Fix a valgrind warning about use of uninitialized memory -in the test test_more/checkpoint.cpp (the problem was in the test). - -
-
-01-20 - -
  1. -Fix a valgrind warning about use of uninitialized memory -when using the adouble - base type. -This required an optional base_hash - function and the special -adouble hash_code - implementation. -
  2. - -The adouble to_string - functions -required a special implementation; see -adouble to_string -. -
  3. - -Add the to_string - and -hash_code - examples -to the base_alloc.hpp example. -
- - -
-
-01-18 - -
  1. -Fix ambiguity between CppAD::sin and std::sin, -and other standard math functions, -when using -
     
    -     using namespace std;
    -     using namespace CppAD;
    -
    -This is OK for simple programs, but not generally recommended. -See double version of base class definitions for -Unary Standard Math - -for more details. -
  2. - -Change Eigen array example -eigen_array.cpp - -to use member function version of sin function -(as per Eigen's array class documentation). -
- - - -
Input File: omh/appendix/whats_new/whats_new_16.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_16_xml.js cppad-2019.02.00.0/doc/_whats_new_16_xml.js --- cppad-2018.00.00.0/doc/_whats_new_16_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_16_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ -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_16.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_16.xml#Introduction', -'whats_new_16.xml#12-23', -'whats_new_16.xml#12-20', -'whats_new_16.xml#12-18', -'whats_new_16.xml#12-13', -'whats_new_16.xml#12-11', -'whats_new_16.xml#12-09', -'whats_new_16.xml#11-18', -'whats_new_16.xml#11-14', -'whats_new_16.xml#11-13', -'whats_new_16.xml#10-27', -'whats_new_16.xml#10-12', -'whats_new_16.xml#09-29', -'whats_new_16.xml#09-27', -'whats_new_16.xml#09-26', -'whats_new_16.xml#09-16', -'whats_new_16.xml#09-13', -'whats_new_16.xml#08-30', -'whats_new_16.xml#08-25', -'whats_new_16.xml#07-17', -'whats_new_16.xml#07-14', -'whats_new_16.xml#06-30', -'whats_new_16.xml#06-29', -'whats_new_16.xml#06-27', -'whats_new_16.xml#06-25', -'whats_new_16.xml#06-10', -'whats_new_16.xml#05-05', -'whats_new_16.xml#04-17', -'whats_new_16.xml#03-27', -'whats_new_16.xml#03-26', -'whats_new_16.xml#03-25', -'whats_new_16.xml#03-24', -'whats_new_16.xml#03-23', -'whats_new_16.xml#03-22', -'whats_new_16.xml#03-21', -'whats_new_16.xml#03-20', -'whats_new_16.xml#03-19', -'whats_new_16.xml#03-17', -'whats_new_16.xml#03-12', -'whats_new_16.xml#03-05', -'whats_new_16.xml#03-01', -'whats_new_16.xml#02-29', -'whats_new_16.xml#02-28', -'whats_new_16.xml#02-27', -'whats_new_16.xml#02-26', -'whats_new_16.xml#02-25', -'whats_new_16.xml#02-23', -'whats_new_16.xml#01-21', -'whats_new_16.xml#01-20', -'whats_new_16.xml#01-18' -]; -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-2018.00.00.0/doc/whats_new_17.xml cppad-2019.02.00.0/doc/whats_new_17.xml --- cppad-2018.00.00.0/doc/whats_new_17.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new_17.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,1193 +0,0 @@ - - - -Changes and Additions to CppAD During 2017 - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -whats_new_17 - -

- - - -
Changes and Additions to CppAD During 2017
-
-API Changes -
-Speed tests no longer automatically compile in release mode; see -debug_which - - -
-
-12-14 -
-Add the subgraph_hes2jac.cpp - example -which computes sparse Hessians using subgraphs and Jacobians. - -
-
-12-08 - -
  1. -A wish list item for a -new API - for -user defined atomic - functions. -
  2. - -A multi-threading - -wish list item was added. -
- - -
-
-12-06 -
-A wish_list - item to enable one to iterate through a -const ADFun - operation sequence was completed. -In addition, the f - argument to the -abs_normal operation was converted to be const. - - -
-
-12-05 -
-The internal data object used to represent sparsity patterns as -vectors of integers was improved; -see internal_bool - -in for_jac_sparsity and other -preferred sparsity pattern - -routines. - -
-
-12-04 -
-Back out the hold_reverse_memory option. - -
-
-12-01 -
-The hold_reverse_memory option was added. - -
-
-11-30 -
-Edit the download - instructions. - -
-
-11-23 -
-The ADFun function optimizer - -was not handling hash code collisions properly. -To be specific, only the arguments -that were variables where checked for a complete match. -The arguments that are constants need to also be checked. -This has been fixed. - -
-
-11-20 - -
  1. -Add the subgraph_jac_rev - method for computing -sparse Jacobians. -
  2. - -Add the subgraph - option -to the CppAD speed tests. -
- - -
-
-11-19 -
-Add the subgraph_reverse - method for computing -sparse derivatives. -This was inspired by the -TMB - package. - - -
-
-11-15 - -
  1. -Add wish list item for subgraph_sparsity - when -atomic functions - -are present. -
  2. - -Fix cmake_check - when ipopt_prefix - is not present on the -cmake - command line -(make was trying to build some of the ipopt tests). -
- - -
-
-11-13 - -
  1. -Add the hes2jac - option -to the CppAD speed tests. -
  2. - -Implement the -subsparsity - option -for the CppAD sparse_hessian - test. -
  3. - -Fix detection of invalid options in the speed test programs; see the -global - and -sparsity - options. -
- - -
-
-11-12 -
-Add the subsparsity - option -to the CppAD speed tests. - -
-
-11-08 -
-Add the subgraph_sparsity - method for computing -dependency and sparsity. -This was inspired by the -TMB - package. - - -
-
-11-06 -
-More information has been added to the operation sequence. -To be specific, the extra amount of - -
-     
f.size_op() * sizeof(tape_addr_type)
-
-was added to the value returned by -size_op_seq -. - -
-
-11-04 -
-The method for iterating through the tape has been changed. -It now includes an extra data structure that makes it faster, -but also requires slightly more memory. To be specific, the term - -
-     
f.size_op() * sizeof(tape_addr_type) * 2
-
-was added to the value returned by -size_op_seq -. -In addition, some minor corrections were made to the -tape_addr_type - -requirements. - -
-
-10-23 - -
  1. -Require cmake.3.1 or greater and fix -a cmake warning by always using the new CMP0054 policy. -
  2. - -Fix a g++ 7.2.1 warning about a possibly uninitialized value -in the file cppad/local/optimize/hash_code.hpp. -
- - -
-
-09-16 -
-An optimization memory - entry -was added to the wish list -and the check_finite - entry was modified. - -
-
-08-30 - -
  1. -If colpack_prefix - was not specified, one would get the following -waring during the cmake - command: - -
    -     Policy CMP0046 is not set: Error on non-existent dependency in
    -
    -This has been fixed by not adding the dependency when it is not needed. -
  2. - -There was a problem running make check - -when cppad_cxx_flags - was not specified. -This has been fixed. -This was probably introduced on 05-29 -. -
- - - -
-
-08-29 -
-There was a problem on some systems that created an error when -specializing the is_pod template function in the -CppAD::local namespace. -This has been fixed by testing for compatibility at during the -cmake - command and creating the file cppad/local/is_pod.hpp. - - -
-
-08-09 -
-Add the test_boolofvoid - -wish list item. - -
-
-08-08 - -
  1. -The eigen_plugin.hpp - was put back in the -cppad_eigen.hpp - definitions. -This makes CppAD incompatible with older versions of eigen; e.g., eigen-3.2.9. -The plugin was removed on 05-12 -. -
  2. - -Fix some minor typos in the documentation. -To be specific: -The font, in the sparse_rc - and sparse_rcv - syntax, -for the text - -
    -     
    target = pattern
    -
    -The font, in capacity_order -, for the text - -
    -     
    xq.size() == f.Domain()
    -
    -Remove a percent sign %, in CppAD_vector -, in the text - -
    -     # include <cppad/utility/vector.hpp>
    -
    -
-
-07-25 - -
  1. -Fix warnings related to type conversions that -occurred when one used -Wconversion with -g++ version 6.3.1. -
  2. - -The warning were not fixed for complex AD types; e.g., -complex_poly.cpp -. -The wno_conversion - include file was added to deal with -cases like this. -
- - -
-
-07-03 - -
  1. -The min_nso_linear - abs-normal example was added. -
  2. - -Fix bug in abs_normal_fun -, to be specific, the multiplication -of a variable on the left by a parameter was not handled. -
- - -
-
-07-01 -
-the abs_normal - examples were converted from using -quadratic programming problems to using linear programming problems. - -
-
-06-28 -
-The abs-normal - -representation of non-smooth functions has been added. -Examples and utilities that use this representation have also been included, -see abs_normal -. - -
-
-06-11 -
-The user atomic functions base class atomic_base - -makes more of an effort to avoid false sharing cache misses. -This may the speed of multi-threaded applications with user atomic functions; -e.g., see multi_atomic.cpp -. - -
-
-06-10 - -
  1. -Add the multi-threading user atomic function example -multi_atomic.cpp -. -
  2. - -The example/multi_thread/test_multi directory used -to have an example using the deprecated -old_atomic - functions in a multi-threading setting -(that only built with the deprecated autotools -). -This have been removed. -
- - -
-
-06-07 -
-The multi-threading examples -harmonic.cpp - and multi_newton.cpp - were re-organized. -To be specific, the source code for each example was moved to one file. -In addition, for each example, -the documentation for each of the routines has been separated -and placed next to its source code. - -
-
-06-04 -
-Most all the deprecated - features have been removed -from the examples with the exception of those in the -example/deprecated directory. - -
-
-06-03 -
-Add the fact that the pair -( -row -, col -) -is lower triangular to the speed test -link_sparse_hessian routine. - - -
-
-06-01 - -
  1. -There was a bug in the -sparse_hes - routine and it was using the general coloring algorithm when -cppad.symmetric - was specified. -This has been fixed and improves the efficiency in this case. -
  2. - -Some bugs were fixed in the use of -colpack - as the coloring algorithm for -sparse Jacobian and Hessian calculations. -This has improved the efficiency of Colpack colorings for computing Hessians -(when colpack.symmetric is used). -
  3. - -The colpack.star coloring method for sparse Hessians has -been deprecated; see -sparse_hes - -and -sparse_hessian -. -Use the colpack.symmetric method instead; see -sparse_hes - and -sparse_hes -. -
- - -
-
-05-29 - -
  1. -Add the capability to compile so that CppAD debug and release mode -can be mixed; see -CPPAD_DEBUG_AND_RELEASE -. -
  2. - -Add the cppad_debug_which - flags -that determines which files are compiled for debugging versus release -during the CppAD testing; see cmake_check -. -
  3. - -There was a problem linking the proper libraries for using newer versions of -sacado -. -This has been fixed. -
- - -
-
-05-19 -
-Most all the examples have been moved to example directory -and grouped as sub-directories; e.g., the ipopt_solve - examples -are in the example/ipopt_solve directory. - -
-
-05-14 - -
  1. -The file build.sh was moved to bin/autotools.sh, -and `auto tools' has been changed to autotools -. -
  2. - -The README file was replace by readme.md -and AUTHORS was moved to authors. -
  3. - -The NEWS, INSALL, and ChangeLog files -are no longer necessary for autotools build and have been removed. -
  4. - -The file test_more/sparse_jacobian.cpp generated a warning -under some gcc compiler options. -This has been fixed. -
  5. - -Specifications were added so that to_string - yields exact results -for integer types and machine precision for floating point types. -
  6. - -Some editing was done to the autotools - instructions. -
- - -
-
-05-12 - -
  1. -The Faq - has been updated. -
  2. - -Remove includes of cppad/cppad.hpp from the - -cppad/speed/*.hpp - files. -This avoids an incompatibility between sacado and newer versions of eigen, -when eigen is used for the -test vector -. -
  3. - -The eigen - package changed its requirements for -defining Scalar types -(some where between eigen-3.2.9 and eigen-3.3.3). -The member variable -digit10 - was added to the -numeric_limits to accommodate this change. -
  4. - -Note that this fix required adding digits10 to the -user defined -Base - type -requirements -; see -base_limits -. -
  5. - -In addition, it is no longer necessary to add the typedef - -
    -     typedef Scalar value_type;
    -
    -so the file cppad/example/eigen_plugin.hpp has been removed. -(This type definition was previously necessary for eigen vectors -to be simple vectors -.) -
- - -
-
-04-08 -
-The optimization -, with a large number of -conditional expressions -, was performing many -memory allocations and deallocations. This has been reduced. - - -
-
-04-02 -
-Fix a bug in the optimization of conditional expressions; see, -no_conditional_skip -. - -
-
-03-31 -
-Fix some valgrind errors that occurred while running the CppAD -test set. - -
-
-03-29 -
-The following valgrind error might occur when the optimize skipped -setting values that did not affect the dependent variables: - -
-     Conditional jump or move depends on uninitialised value(s)
-
-This was not a bug, the code has been changed to avoid this error -in order to make it easier to use valgrind with CppAD. - -
-
-03-25 - -
  1. -The sparse_hes - function was more efficient if -there were more entries in each row of the requested -subset -. This has been changed -to more entries in each column, and documentation to this effect -was included. -
  2. - -The optimize - routine was using to much memory when -it was optimizing conditional skip operations; see -no_conditional_skip -. -This has been fixed. -
- - -
-
-03-20 -
-There was a mistake in sparse_jac - that caused the -following assert to mistakenly occur: -
 
-sparse_jac_rev: work is non-empty and conditions have changed
-Error detected by false result for
-    color.size() == 0 || color.size() == n
-
-A test that using a previously stores work vector -has been added to sparse_jac_rev.cpp - -and this bug has been fixed. - -
-
-03-13 -
-The documentation for the Hessian in rev_hes_sparsity - was -transposed; i.e., the sense of -transpose - was reversed. - -
-
-03-11 -
-Add sparse assignment statements; see -target - for -sparse_rc - and -sparse_rcv -. - -
-
-03-10 -
-Add the a sizing constructor to the -sparse_rc syntax -; i.e., -a constructor that sets the number of row, number of columns, -and number of possibly non-zero values in the sparsity pattern. - -
-
-03-06 -
-Fix a bug in the sparsity computation using the -internal representation for -vectors of sets -; -i.e., when -internal_bool - was false in -any of the sparsity_pattern - calculations; e.g., -for_jac_sparsity -. - -
-
-03-04 -
-Fix a bug in the optimization of conditional expressions; -see no_conditional_skip -. - -
-
-02-26 - -
  1. -Fix warning during cmake - command, -on cygwin - systems, -about WIN32 not being defined. -
  2. - -Add element-wise operations - -to the wish list. -
- - -
-
-02-21 - -
  1. -Minor improvements to syntax and documentation for -sparse_rc - and sparse_rcv -. -
  2. - -Separate preferred sparsity versions in -sparsity_pattern - and sparse_derivative -. -
- - -
-
-02-19 - -
  1. -Remove the bool_sparsity.cpp example and -add the rc_sparsity.cpp - example. -
  2. - -Check for duplicate entries during -row_major - and col_major in -sparse_rc. -
- - -
-
-02-15 -
-Fix bug when using ForSparseHes - with atomic functions; i.e., -atomic_for_sparse_hes -. - -
-
-02-13 -
-Improve for_sparse_jac - -calculation in eigen_mat_mul.hpp example. -It now checks for the parameter zero and does not propagate any sparsity -in this case (because the result is always zero). - -
-
-02-11 - -
  1. -Remove the 'Under Construction' heading from the -sparse_rc - and sparse_rcv - documentation; i.e., -they are ready for public use (part of the CppAD API). -
  2. - -Fix some warning that occur when using -eigen - for the CppAD test vector. -(The Eigen vector size() function -returns an int instead of size_t.) -
  3. - -Fix a bug in sparse_jac_rev -. -
- - -
-
-02-10 - -
  1. -The subset of deprecated features corresponding to -cppad_deprecated=YES - -have been completely removed. -
  2. - -Fix problems with autotools - build -(started near 02-01 while working on sparsity branch). -
  3. - -Reorder (better organize) the ADFun - documentation section. -
- - -
-
-02-09 - -
  1. -Remove the sparsity pattern wish list item. -For sparsity patterns, this was completed by -sparse_rc - and the sparsity pattern routines that used it; -e.g., for_jac_sparsity -. -For sparse matrices, it was completed by -sparse_rcv - and the sparse matrix routines that use it; e.g., -sparse_jac -. -
  2. - -Add the Deprecated and -example - items to the wish list. -(The Deprecated item was partially completed and partially removed.) -
- - -
-
-02-08 - -
  1. -Make coloring a separate argument to -sparse_jac - and -sparse_hes -. -
  2. - -Add the -group_max - -argument to the sparse_jac_for function. -
- - -
-
-02-05 - -
  1. -Add the sparse_jac_for - routine -which uses sparse_rc - sparsity patterns -and sparse_rcv - matrix subsets. -
  2. - -Order for sparse_rc - row-major and column-major was switched. -This has been fixed. -
- - -
-
-02-03 -
-Add the -rev_jac_sparsity - -rev_hes_sparsity -, and -for_hes_sparsity - interfaces to sparsity calculations. -These use sparse_rc - sparsity patterns. - -
-
-02-02 -
-Change size_forward_bool - and -Change size_forward_set - -so that they are a better approximation of the number of bytes -(unsigned characters) being used. -The exact same sparsity pattern might use different memory -in two different function objects (because memory is allocated in chunks). -The fun_assign.cpp - example has been changed to reflect this fact. - -
-
-02-01 -
-Add the for_jac_sparsity - interface for the sparse Jacobian calculations. -This is the first use of sparse_rc -, -a sparsity pattern class that uses row and column -index vectors -. - -
-
-01-30 -
-Move the sparsity_pattern - examples from example -to example/sparse subdirectory. -This included the sparse driver - examples. - -
-
-01-29 -
-Move the utility - examples from example -to example/utility subdirectory. - -
-
-01-27 -
-Add a addon - link to -cppad_swig -, -a C++ AD object library and swig interface to Perl, Octave, and Python. - -
-
-01-19 -
-Convert more examples / tests to use a multiple of machine epsilon -instead of 1e-10. - -
-
-01-18 - -
  1. -Fix developer -doxydoc - -documentation so that it works with newer version of doxygen. -
  2. - -Fix a Visual C++ 2015 compilation problem in friend declarations -in the file cppad/local/ad_tape.hpp. -
- - -
-
-01-17 -
-Change computed assignment to -compound assignment -. - - -
Input File: omh/appendix/whats_new/whats_new_17.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_17_xml.js cppad-2019.02.00.0/doc/_whats_new_17_xml.js --- cppad-2018.00.00.0/doc/_whats_new_17_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_17_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,168 +0,0 @@ -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_17.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', -'directory.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_17.xml', -'whats_new_16.xml', -'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_17.xml#API Changes', -'whats_new_17.xml#12-14', -'whats_new_17.xml#12-08', -'whats_new_17.xml#12-06', -'whats_new_17.xml#12-05', -'whats_new_17.xml#12-04', -'whats_new_17.xml#12-01', -'whats_new_17.xml#11-30', -'whats_new_17.xml#11-23', -'whats_new_17.xml#11-20', -'whats_new_17.xml#11-19', -'whats_new_17.xml#11-15', -'whats_new_17.xml#11-13', -'whats_new_17.xml#11-12', -'whats_new_17.xml#11-08', -'whats_new_17.xml#11-06', -'whats_new_17.xml#11-04', -'whats_new_17.xml#10-23', -'whats_new_17.xml#09-16', -'whats_new_17.xml#08-30', -'whats_new_17.xml#08-29', -'whats_new_17.xml#08-09', -'whats_new_17.xml#08-08', -'whats_new_17.xml#07-25', -'whats_new_17.xml#07-03', -'whats_new_17.xml#07-01', -'whats_new_17.xml#06-28', -'whats_new_17.xml#06-11', -'whats_new_17.xml#06-10', -'whats_new_17.xml#06-07', -'whats_new_17.xml#06-04', -'whats_new_17.xml#06-03', -'whats_new_17.xml#06-01', -'whats_new_17.xml#05-29', -'whats_new_17.xml#05-19', -'whats_new_17.xml#05-14', -'whats_new_17.xml#05-12', -'whats_new_17.xml#04-08', -'whats_new_17.xml#04-02', -'whats_new_17.xml#03-31', -'whats_new_17.xml#03-29', -'whats_new_17.xml#03-25', -'whats_new_17.xml#03-20', -'whats_new_17.xml#03-13', -'whats_new_17.xml#03-11', -'whats_new_17.xml#03-10', -'whats_new_17.xml#03-06', -'whats_new_17.xml#03-04', -'whats_new_17.xml#02-26', -'whats_new_17.xml#02-21', -'whats_new_17.xml#02-19', -'whats_new_17.xml#02-15', -'whats_new_17.xml#02-13', -'whats_new_17.xml#02-11', -'whats_new_17.xml#02-10', -'whats_new_17.xml#02-09', -'whats_new_17.xml#02-08', -'whats_new_17.xml#02-05', -'whats_new_17.xml#02-03', -'whats_new_17.xml#02-02', -'whats_new_17.xml#02-01', -'whats_new_17.xml#01-30', -'whats_new_17.xml#01-29', -'whats_new_17.xml#01-27', -'whats_new_17.xml#01-19', -'whats_new_17.xml#01-18', -'whats_new_17.xml#01-17' -]; -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-2018.00.00.0/doc/whats_new.xml cppad-2019.02.00.0/doc/whats_new.xml --- cppad-2018.00.00.0/doc/whats_new.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/whats_new.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ - - - -Changes and Additions to CppAD - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - - - -

- - - -
Changes and Additions to CppAD
-
-Introduction -
-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. - - - -
-
-This Year - -
-whats_new_17 - - -
-
- - -
-whats_new_16 - -whats_new_15 - -whats_new_14 - -whats_new_13 - -whats_new_12 - -whats_new_11 -, -whats_new_10 -, -whats_new_09 -, -whats_new_08 -, -whats_new_07 -, -whats_new_06 -, -whats_new_05 -, -whats_new_04 -, -whats_new_03 -. - - -
Input File: omh/appendix/whats_new/whats_new.omh - - - diff -Nru cppad-2018.00.00.0/doc/_whats_new_xml.js cppad-2019.02.00.0/doc/_whats_new_xml.js --- cppad-2018.00.00.0/doc/_whats_new_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_whats_new_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', -'appendix.xml', -'whats_new.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', -'directory.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 = [ -'whats_new_17.xml', -'whats_new_16.xml', -'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.xml#Introduction', -'whats_new.xml#This Year', -'whats_new.xml#Previous Years' -]; -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-2018.00.00.0/doc/wish_list.xml cppad-2019.02.00.0/doc/wish_list.xml --- cppad-2018.00.00.0/doc/wish_list.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/wish_list.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,461 +0,0 @@ - - - -The CppAD Wish List - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -wish_list - -

- - - -
The CppAD Wish List
-
-Multi-Threading -
-The TMB packages has a special version of the -checkpoint - class -that enables one checkpoint function to be my multiple OpenMp threads. -Perhaps it would be useful to extend the CppAD multi-threading environment -to allow for this. -In addition, perhaps a multi-threading version of an ADFun object would -be useful. - - -
-
-Atomic - - -
-
-Subgraph -
-The subgraph_sparsity - calculation treats -each atomic function call as if -all of its outputs depend on all of its inputs; -see atomic function -. -These sparsity patterns could be made more efficient -(could have fewer possibly non-zeros entries) -by using the sparsity patterns for the atomic functions. - -
-
-New API -
-A new API for atomic functions could be created that uses -sparse_rc - for sparsity patterns and an interface like - -
-     
afun.jac_sparsity(select_domainselect_rangepattern_out)
-     
afun.hes_sparsity(select_domainselect_rangepattern_out)
-
-see subgraph_sparsity -. -This would be simpler for the user. - -
-
-Sparsity -
-Add an atomic_option - that checks if the sparsity patterns calculated -by user atomic functions have -elements for arguments that are know to be parameters and -could be more efficient. -For example, the user's version of for_sparse_jac could check -x - to see for which components -are variables; -i.e., isnan(x[j]) - is true for a particular call. -Note that -vx - should be removed, -because the method above can be used to determine this information. - -
-
-Element-wise Operations -
-Add user atomic functions for element-wise addition, subtraction, -multiplication, and division. -Where the operands are simple vectors - -with elements of type -AD<Base> -. - - - -
-
-check_finite - -
  1. -Sometimes one only gets infinite value during zero order forward -and nan when computing corresponding derivatives. -Change check_for_nan - to check_finite -(not infinite or nan) so that error detection happens during zero -order forward instead of later. -
  2. - -In addition, the current check_for_nan - writes the corresponding -zero order values to a temporary file. -It would be nice if the check_finite routine made writing -the zero order values optional. -
- - -
-
-test_boolofvoid -
-For general purpose use, the test_boolofvoid - should be usable -without including a memory check at the end. - -
-
-Eigen -
-Use a wrapper class for -eigen vectors - so that the -size member function returns a -size_t instead of an int. -This would allow TESTVECTOR - to be a true template class; i.e., -to use the syntax - -
-     TESTVECTOR<
Scalar>
-
-
-Example -
-Split the example list - -into separate groups by the corresponding example subdirectory. - - -
-
-Optimization - - -
-
-Taping -
-Perhaps some of the optimization done while taping forward mode -should be delayed to the optimization step. - -
-
-Special Operators -
-Add special operators that can be implemented more efficiently, e.g., - -
-     square(
x) = x * x
-
-and have the optimizer recognize when they should be used. -(They could also be in the user API, but it would not be expected -that the user would use them.) - -
-
-Memory -
-The optimize - command seems to use a lot of memory when the -tape is large. We should create a test case that demonstrates this and then -work on reducing the amount of memory needed by this operation. - - -
-
-checkpoint - - -
-
-Retape -
-Perhaps there should be a version of the -checkpoint - class that uses a tapeless AD package to compute -the derivative values. -This would allow for algorithms where the operations sequence -depends on the independent variable values. -There is a question as to how sparsity patterns would be determined -in this case. -Perhaps they would be passed into the constructor. -If it was known to be constant, -the user could compute the pattern using CppAD. -Otherwise, the user could input -a conservative estimate of the pattern that would be correct. - -
-
-Testing -
-There should be some examples and tests for both speed and memory use -that demonstrate that checkpointing is useful. - - - -
-
-Compilation Speed -
-Create a library corresponding to AD<double> so that -one does not need to re-compile all the header files every time. - -
-
-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 -. - -
-
-Adolc -
-Create a documentation page that shows how to convert Adolc commands to -CppAD commands. - -
-
-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). -
- - -
-
-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 -. - -
-
-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/appendix/wish_list.omh - - - diff -Nru cppad-2018.00.00.0/doc/_wish_list_xml.js cppad-2019.02.00.0/doc/_wish_list_xml.js --- cppad-2018.00.00.0/doc/_wish_list_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_wish_list_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -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', -'directory.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#Multi-Threading', -'wish_list.xml#Atomic', -'wish_list.xml#Atomic.Subgraph', -'wish_list.xml#Atomic.New API', -'wish_list.xml#Atomic.Sparsity', -'wish_list.xml#Atomic.Element-wise Operations', -'wish_list.xml#check_finite', -'wish_list.xml#test_boolofvoid', -'wish_list.xml#Eigen', -'wish_list.xml#Example', -'wish_list.xml#Optimization', -'wish_list.xml#Optimization.Taping', -'wish_list.xml#Optimization.Special Operators', -'wish_list.xml#Optimization.Memory', -'wish_list.xml#checkpoint', -'wish_list.xml#checkpoint.Retape', -'wish_list.xml#checkpoint.Testing', -'wish_list.xml#Compilation Speed', -'wish_list.xml#Base Requirements', -'wish_list.xml#Adolc', -'wish_list.xml#Forward Mode Recomputation', -'wish_list.xml#Iterator Interface', -'wish_list.xml#Operation Sequence', -'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-2018.00.00.0/doc/wno_conversion.xml cppad-2019.02.00.0/doc/wno_conversion.xml --- cppad-2018.00.00.0/doc/wno_conversion.xml 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/wno_conversion.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ - - - -Suppress Suspect Implicit Conversion Warnings - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - -wno_conversion - -

- - - -
Suppress Suspect Implicit Conversion Warnings
-
-Syntax - -
- -# include <cppad/wno_conversion.hpp> - - -
-
-Purpose -
-In many cases it is good to have warnings for implicit conversions -that may loose range or precision. -The include command above, before any other includes, suppresses -these warning for a particular compilation unit (which usually corresponds -to a -*.cpp - file). - - -
Input File: cppad/wno_conversion.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_wno_conversion_xml.js cppad-2019.02.00.0/doc/_wno_conversion_xml.js --- cppad-2018.00.00.0/doc/_wno_conversion_xml.js 2018-01-01 08:32:47.000000000 +0000 +++ cppad-2019.02.00.0/doc/_wno_conversion_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -var list_across0 = [ -'_contents_xml.htm', -'_reference.xml', -'_index.xml', -'_search_xml.htm', -'_external.xml' -]; -var list_up0 = [ -'cppad.xml', -'example.xml', -'wno_conversion.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 = [ -'get_started.cpp.xml', -'general.xml', -'exampleutility.xml', -'listallexamples.xml', -'testvector.xml', -'wno_conversion.xml' -]; -var list_current0 = [ -'wno_conversion.xml#Syntax', -'wno_conversion.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_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-2018.00.00.0/doc/zdouble.cpp.xml cppad-2019.02.00.0/doc/zdouble.cpp.xml --- cppad-2018.00.00.0/doc/zdouble.cpp.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/zdouble.cpp.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,212 +0,0 @@ - - - -zdouble: Example and Test - - - - - - - - - - - - - - - - -
- -Prev -Next - - - - - - - - - - -zdouble.cppHeadings

- - - -
zdouble: Example and Test
-
# include <cppad/cppad.hpp>
-
-namespace {
-     template <class Base> bool test_one(void)
-     {     bool ok = true;
-          Base eps99 = 99. * 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], eps99, eps99);
-          ok &= CppAD::NearEqual(z[1], - x[0]/(x[1]*x[1]), eps99, eps99);
-
-          return ok;
-     }
-     bool test_two(void)
-     {     bool ok = true;
-          using CppAD::zdouble;
-          //
-          zdouble eps = CppAD::numeric_limits<zdouble>::epsilon();
-          ok          &= eps == std::numeric_limits<double>::epsilon();
-          //
-          zdouble min = CppAD::numeric_limits<zdouble>::min();
-          ok          &= min == std::numeric_limits<double>::min();
-          //
-          zdouble max = CppAD::numeric_limits<zdouble>::max();
-          ok          &= max == std::numeric_limits<double>::max();
-          //
-          zdouble nan = CppAD::numeric_limits<zdouble>::quiet_NaN();
-          ok          &= nan != nan;
-          //
-          int digits10 = CppAD::numeric_limits<zdouble>::digits10;
-          ok          &= digits10 == std::numeric_limits<double>::digits10;
-          //
-          return ok;
-     }
-}
-
-bool zdouble(void)
-{     bool ok = true;
-     using CppAD::AD;
-     using CppAD::NearEqual;
-     using CppAD::zdouble;
-     //
-     ok &= test_one<zdouble>();
-     ok &= test_one<double>();
-     //
-     ok &= test_two();
-     //
-     return ok;
-}
-
-
Input File: example/deprecated/zdouble.cpp - - - diff -Nru cppad-2018.00.00.0/doc/_zdouble.cpp_xml.js cppad-2019.02.00.0/doc/_zdouble.cpp_xml.js --- cppad-2018.00.00.0/doc/_zdouble.cpp_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_zdouble.cpp_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -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', -'directory.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', -'autotools.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-2018.00.00.0/doc/zdouble.xml cppad-2019.02.00.0/doc/zdouble.xml --- cppad-2018.00.00.0/doc/zdouble.xml 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/zdouble.xml 1970-01-01 00:00:00.000000000 +0000 @@ -1,329 +0,0 @@ - - - -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/core/zdouble.hpp - - - diff -Nru cppad-2018.00.00.0/doc/_zdouble_xml.js cppad-2019.02.00.0/doc/_zdouble_xml.js --- cppad-2018.00.00.0/doc/_zdouble_xml.js 2018-01-01 08:32:48.000000000 +0000 +++ cppad-2019.02.00.0/doc/_zdouble_xml.js 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -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', -'directory.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', -'autotools.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-2018.00.00.0/doc.omh cppad-2019.02.00.0/doc.omh --- cppad-2018.00.00.0/doc.omh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/doc.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,27 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin CppAD$$ +$escape $$ $comment default navigate command for all of CppAD documentation$$ $navigate% - Prev%Prev% - Next%Next% - Across%Index% - Up%Up% - Down_up_3%_up_3% - Down_up_2%_up_2% - Down_up_1%_up_1% - Down_up_0%_up_0% - Current%Headings + Prev%Prev% + Next%Next% + Across%Index% + Up%Up% + Down_up_3%_up_3% + Down_up_2%_up_2% + Down_up_1%_up_1% + Down_up_0%_up_0% + Current%Headings %$$ $comment ------------------------------------------------------------- default automatic indexing command for all CppAD documentaiton @@ -37,144 +39,189 @@ \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} } $$ -$comment ------------------------------------------------------------- -hilite commands used throughout the CppAD documentation +$comment +============================================================================== $$ -$hilitecmd% - verbatim% - codep -%$$ -$hiliteseq% - - CppAD::%AD%<% AD -% %AD%<% AD - -%CppAD::%ADFun%<% FunConstruct -% %ADFun%<% FunConstruct - -% %CPPAD_TESTVECTOR%(% testvector - - %.%Forward%(% Forward - -%CppAD::%Independent%(% Independent -% %Independent%(% Independent - - %.%Jacobian%(% Jacobian - -%CppAD::%NearEqual%(% NearEqual -% %NearEqual%(% NearEqual - - %.%Reverse%(% Reverse -%$$ $spell - Jax - cppad.hpp - cppad - namespaces - std - templated - const - CppADvector - multiplicative - Microsoft - bool - Det - namespace - Cpp - Var - Diff - initializes + cppad + templated + Microsoft + Cpp + http + www + seanet + bradbell + https + github + Jacobian + Jacobians + subgraph + Posix + Openmp $$ -, - $comment bin/version assumes that : follows cppad version number here$$ $section -cppad-20180000.0: A Package for Differentiation of C++ Algorithms -$$ -$mindex AD algorithmic differentiation automatic C++ algorithm derivative CppAD version cppad.hpp$$ +cppad-20190200.0: A C++ Algorithmic Differentiation Package$$ -$comment This comment is used to remove the table below$$ +$comment =================================================================== $$ +$align middle$$ $table +$icon coin.png$$ $cnext - One section per web page $pre $$ $cnext - All sections in one web page -$rnext -$cnext - (fast to load) $pre $$ $cnext - (slow to load) -$rnext -Math displayed using MathJax $pre $$ $cnext -$href%cppad.htm%$$ -$pre $$ $cnext -$href%_printable.htm%$$ -$rnext -Math displayed using MathML $pre $$ $cnext -$href%cppad.xml%$$ $pre $$ $cnext -$href%_printable.xml%$$ +$comment ------------------------------------------------------------------- $$ + +$table +$href%https://github.com/coin-or/CppAD%github%$$, $cnext +$href%https://travis-ci.org/coin-or/CppAD%travis%$$, $cnext +$href%https://ci.appveyor.com/project/bradbell/cppad%appveyor%$$ $tend +$pre +$$ +$comment ------------------------------------------------------------------- $$ +$table +$cref install$$, $cnext +$cref/get_started/get_started.cpp/$$, $cnext +$cref whats_new$$, $cnext +$cref addon$$, $cnext +$cref research$$, $cnext +$href%http://www.seanet.com/~bradbell%project manager%$$ +$tend +$pre -$head Syntax$$ -$code # include $$ +$$ +$comment ------------------------------------------------------------------- $$ +CppAD is distributed by +$href%http://www.coin-or.org%COIN-OR%$$ +with the Eclipse Public License +$href%http://www.opensource.org/licenses/EPL-2.0%EPL-2.0%$$ +or the GNU General Public License +$href%http://www.opensource.org/licenses/GPL-2.0%GPL-2.0%$$ or later. + +$tend +$align top$$ +$comment =================================================================== $$ -$head 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$$.) -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 +$head Algorithmic Differentiation$$ +We refer to the automatic creation of an algorithm that +computes derivative values from an algorithm that computes function values +as $italic Algorithmic Differentiation$$, +also referred to as $italic Automatic Differentiation$$ or just AD. +A brief introduction to AD can be found in $href%http://en.wikipedia.org/wiki/Automatic_differentiation%wikipedia%$$. 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 -$href%http://www.coin-or.org/foundation.html%COIN-OR Foundation%$$ -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%$$. -Testing and installation is supported for Unix, Microsoft, and Apple -operating systems. -Extensive user and developer documentation is included. - -$lnext -An AD of $italic Base$$ -$xref/glossary/Operation/Sequence/operation sequence/1/$$ -is stored as an -$xref/ADFun//AD function object/$$ -which can evaluate function values and derivatives. +$head Features$$ + +$subhead Operator Overloading$$ +CppAD uses operator overloading of the C++ template class $cref AD$$ +to compute derivatives of algorithms defined using AD objects; see +the $cref introduction$$ for a description of how this is accomplished. + +$subhead Base Type$$ +The operator overloading uses a templated base type that +can be user defined; see $cref base_require$$. +The required definitions for $code AD$$ and +$code AD$$ are included as part of CppAD. + +$subhead Recording Operations$$ +A sequence of $codei%AD<%Base%>%$$ +$cref/operations/glossary/Operation/Sequence/$$ +can be recorded and stored in an +$cref/AD function object/ADFun/$$ object. +This object can then be used to evaluate +function values and arbitrary order derivatives, +and sparsity patterns of derivative values using the $icode Base$$ type. + +$subhead Multi-Threading$$ +CppAD supports an arbitrary $cref/multi threading/multi_thread/$$ environment. +Examples are provided using Boost threads, Posix threads, and Openmp threads. + +$subhead Optimizing Operations Sequences$$ +During the recording of a function, +the $cref Independent$$ variables are know and a forward dependency +analysis is used to determine which operations should be recorded. +Once the $cref Dependent$$ variables are determined, +a reverse dependency analysis can be preformed. +This $cref optimize$$ routine uses a reverse dependency analysis, +and other techniques, +to remove unnecessary operations. + +$subhead Dynamic Parameters$$ +CppAD enables one to specify a vector of +$cref/dynamic/glossary/Parameter/Dynamic/$$ parameters. +The value of the function and derivatives can depend on these parameters, +but no derivatives are taken with respect to these parameters. +This enables CppAD to reduce the derivative calculations; e.g., +the derivative of variable times a variable has two terms +while a variable times a parameter only has one. + +$subhead Derivative Calculations$$ Arbitrary order -$xref/Forward//forward/$$ and $xref/Reverse//reverse/$$ +$cref/forward/Forward/$$ and $cref/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 -$xref/Discrete//discrete functions/$$ can also be included -in the sequence of operations; i.e., +can be preformed using an $code ADFun$$ object. +Easy to user drivers that compute the +entire $cref Jacobian$$ and a specific $cref Hessian$$ are included. + +$subhead Sparsity$$ +Both forward and reverse mode can be used to calculation the sparsity +pattern for Jacobians and Hessians; see $cref sparsity_pattern$$. +Where a Jacobian or Hessian is sparse, +both forward and reverse mode can be combined with the sparsity pattern +to speed up the calculation of +$cref/sparse derivatives/sparse_derivative/$$. +In addition, a $cref/subgraph/subgraph_jac_rev/$$ method, +that does not require a sparsity pattern, can be used +to speed up these derivative calculations. + +$subhead Recording Derivative Operations$$ +A $code ADFun$$ object can be converted into an object that +evaluates derivatives using the type $codei%AD<%Base%>%$$; see $cref base2ad$$. +This enables one to record new functions that +are expressed using derivatives of other functions. + +$subhead Atomic Functions$$ +User defined derivative calculations for arbitrary functions +can also be included in +a recording using $cref/atomic functions/atomic_two/$$ functions. +A special $cref/checkpoint/chkpoint_one/$$ class is included +which allows one to record a function and reuse it as +an atomic operation in other functions. +There also is a special interface for user defined unary +$cref/discrete functions/Discrete/$$ functions; i.e., functions that depend on the $cref/independent variables/glossary/Tape/Independent Variable/$$ -but which have identically zero derivatives -(e.g., a step function). +but which have identically zero derivatives (e.g., a step function). + +$subhead Logical Comparisons$$ +Logical comparisons can be included in an operation sequence +using AD $cref/conditional expressions/CondExp/$$. -$lnext -Derivatives of functions that are defined in terms of other derivatives -can be computed using multiple levels of AD; -see $cref/mul_level.cpp/$$ for a simple example -and $cref/mul_level_ode.cpp/$$ for a more realistic example. -To this end, CppAD can also be used with other AD types; for example see -$cref/mul_level_adolc_ode.cpp/$$. +$subhead Vectors$$ +The CppAD API allows one to use any +$cref SimpleVector$$ class. +The preprocessor symbol $cref/CPPAD_TESTVECTOR/testvector/$$ +is template vector class which is used for correctness testing. +Many of the correctness tests use this template vector class +which you can choose during the $cref cmake$$ configuration command. + +$head Software Engineering$$ +CppAD is developed using the software engineering procedures described +on the project manager's +$href%https://www.seanet.com/~bradbell/software.htm%software%$$ +web page. -$lnext -A set of programs for doing $cref/speed/$$ comparisons between +$head Testing$$ + +$subhead Correctness$$ +There is an extensive set of correctness tests; see $cref cmake_check$$. + +$subhead Speed$$ +A set of programs for doing $cref speed$$ comparisons between $href%https://projects.coin-or.org/ADOL-C%Adolc%$$, CppAD, $href%http://www.fadbad.com/%Fadbad%$$, @@ -182,81 +229,34 @@ $href%http://trilinos.sandia.gov/packages/sacado/%Sacado%$$ are included. +$head Utilities$$ +CppAD includes a set of C++ $cref/utilities/utility/$$ that are useful +for general operator overloaded numerical methods. -$lnext -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; -for example, you can do your testing with the -$href%http://www.boost.org/libs/numeric/ublas/doc/index.htm%uBlas%$$ -template vector class. - -$lnext -See $xref/whats_new/$$ for a list of recent extensions and bug fixes. - -$lend - -You can find out about other algorithmic differentiation tools -and about algorithmic differentiation in general at the following web sites: -$href%http://en.wikipedia.org/wiki/Automatic_differentiation%wikipedia%$$, -$href%http://www.autodiff.org%autodiff.org%$$. +$head Release Notes$$ +This $cref whats_new$$ for a list of recent extensions and bug fixes. $head Example$$ -The file -$xref/get_started.cpp/$$ +The file $cref get_started.cpp$$ contains an example and test of using CppAD to compute the derivative of a polynomial. There are many other -$xref/Example//examples/$$. - -$head Include File$$ -The following include directive -$syntax% - # include -%$$ -includes the CppAD package for the rest of the current compilation unit. - -$head Preprocessor Symbols$$ -All the $cref preprocessor$$ symbols used by CppAD begin with eight -$code CppAD$$ or $code CPPAD_$$. - -$head Namespace$$ -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 -$syntax% - size_t n = 2; - CppAD::vector< CppAD::AD<%Base%> > %x%(%n%) -%$$ -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 -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. - - -$childtable% - omh/install/install.omh% - omh/introduction.omh% - cppad/core/user_ad.hpp% - cppad/core/ad_fun.hpp% - omh/preprocessor.omh% - omh/multi_thread.omh% - omh/utility.omh% - cppad/ipopt/solve.hpp% - omh/example.omh% - omh/speed/speed.omh% - omh/appendix.omh +$cref/examples/Example/$$. +All of the examples are also correctness tests, +which ensures that they work properly. + +$children% + omh/install/install.omh% + omh/theory/theory.omh% + include/cppad/core/user_ad.hpp% + include/cppad/core/ad_fun.hpp% + omh/preprocessor.omh% + omh/multi_thread.omh% + omh/utility.omh% + include/cppad/ipopt/solve.hpp% + omh/example.omh% + omh/speed/speed.omh% + omh/appendix.omh %$$ $end diff -Nru cppad-2018.00.00.0/epl-2.0.txt cppad-2019.02.00.0/epl-2.0.txt --- cppad-2018.00.00.0/epl-2.0.txt 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/epl-2.0.txt 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,277 @@ +Eclipse Public License - v 2.0 + + THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE + 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 content + 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 changes or additions to the Program that + are not Modified Works. + +"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 +or any Secondary License (as applicable), including Contributors. + +"Derivative Works" shall mean any work, whether in Source Code or other +form, that is based on (or derived from) the Program and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. + +"Modified Works" shall mean any work in Source Code or other form that +results from an addition to, deletion from, or modification of the +contents of the Program, including, for purposes of clarity any new file +in Source Code form that contains any contents of the Program. Modified +Works shall not include works that contain only declarations, +interfaces, types, classes, structures, or files of the Program solely +in each case in order to link to, bind by name, or subclass the Program +or Modified Works thereof. + +"Distribute" means the acts of a) distributing or b) making available +in any manner that enables the transfer of a copy. + +"Source Code" means the form of a Program preferred for making +modifications, including but not limited to software source code, +documentation source, and configuration files. + +"Secondary License" means either the GNU General Public License, +Version 2.0, or any later versions of that license, including any +exceptions or additional permissions as identified by the initial +Contributor. + +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. + + 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 or other 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. + + e) Notwithstanding the terms of any Secondary License, no + Contributor makes additional grants to any Recipient (other than + those set forth in this Agreement) as a result of such Recipient's + receipt of the Program under the terms of a Secondary License + (if permitted under the terms of Section 3). + +3. REQUIREMENTS + +3.1 If a Contributor Distributes the Program in any form, then: + + a) the Program must also be made available as Source Code, in + accordance with section 3.2, and the Contributor must accompany + the Program with a statement that the Source Code for the Program + is available under this Agreement, and informs Recipients how to + obtain it in a reasonable manner on or through a medium customarily + used for software exchange; and + + b) the Contributor may Distribute the Program under a license + different than this Agreement, provided that such license: + i) effectively disclaims on behalf of all other 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 other Contributors all + liability for damages, including direct, indirect, special, + incidental and consequential damages, such as lost profits; + + iii) does not attempt to limit or alter the recipients' rights + in the Source Code under section 3.2; and + + iv) requires any subsequent distribution of the Program by any + party to be under a license that satisfies the requirements + of this section 3. + +3.2 When the Program is Distributed as Source Code: + + a) it must be made available under this Agreement, or if the + Program (i) is combined with other material in a separate file or + files made available under a Secondary License, and (ii) the initial + Contributor attached to the Source Code the notice described in + Exhibit A of this Agreement, then the Program may be made available + under the terms of such Secondary Licenses, and + + b) a copy of this Agreement must be included with each copy of + the Program. + +3.3 Contributors may not remove or alter any copyright, patent, +trademark, attribution notices, disclaimers of warranty, or limitations +of liability ("notices") contained within the Program from any copy of +the Program which they Distribute, provided that Contributors may add +their own appropriate notices. + +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, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, 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, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, 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 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. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation 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. Nothing in this Agreement is intended +to be enforceable by any entity that is not a Contributor or Recipient. +No third-party beneficiary rights are created under this Agreement. + +Exhibit A - Form of Secondary Licenses Notice + +"This Source Code may also be made available under the following +Secondary Licenses when the conditions for such availability set forth +in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), +version(s), and exceptions or additional permissions here}." + + Simply including a copy of this Agreement, including this Exhibit A + is not sufficient to license the Source Code under Secondary Licenses. + + If it is not possible or desirable to put the notice in a particular + file, then You may include the notice in a location (such as a LICENSE + file in a relevant directory) where a recipient would be likely to + look for such a notice. + + You may add additional accurate notices of copyright ownership. \ No newline at end of file diff -Nru cppad-2018.00.00.0/example/abs_normal/abs_eval.cpp cppad-2019.02.00.0/example/abs_normal/abs_eval.cpp --- cppad-2018.00.00.0/example/abs_normal/abs_eval.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/abs_eval.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,18 +1,19 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin abs_eval.cpp$$ $spell - eval + eval $$ $section abs_eval: Example and Test$$ @@ -21,7 +22,7 @@ The function $latex f : \B{R}^3 \rightarrow \B{R}$$ defined by $latex \[ - f( x_0, x_1, x_2 ) = | x_0 + x_1 | + | x_1 + x_2 | + f( x_0, x_1, x_2 ) = | x_0 + x_1 | + | x_1 + x_2 | \] $$ is affine, except for its absolute value terms. For this case, the abs_normal approximation should be equal @@ -29,7 +30,7 @@ $head Source$$ $srcfile%example/abs_normal/abs_eval.cpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 1%$$ $end @@ -40,96 +41,96 @@ # include "abs_eval.hpp" namespace { - CPPAD_TESTVECTOR(double) join( - const CPPAD_TESTVECTOR(double)& x , - const CPPAD_TESTVECTOR(double)& u ) - { size_t n = x.size(); - size_t s = u.size(); - CPPAD_TESTVECTOR(double) xu(n + s); - for(size_t j = 0; j < n; j++) - xu[j] = x[j]; - for(size_t j = 0; j < s; j++) - xu[n + j] = u[j]; - return xu; - } + CPPAD_TESTVECTOR(double) join( + const CPPAD_TESTVECTOR(double)& x , + const CPPAD_TESTVECTOR(double)& u ) + { size_t n = x.size(); + size_t s = u.size(); + CPPAD_TESTVECTOR(double) xu(n + s); + for(size_t j = 0; j < n; j++) + xu[j] = x[j]; + for(size_t j = 0; j < s; j++) + xu[n + j] = u[j]; + return xu; + } } bool abs_eval(void) -{ bool ok = true; - // - using CppAD::AD; - using CppAD::ADFun; - // - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR( AD ) ad_vector; - // - double eps99 = 99.0 * std::numeric_limits::epsilon(); - // - size_t n = 3; // size of x - size_t m = 1; // size of y - size_t s = 2; // number of absolute value terms - // - // record the function f(x) - ad_vector ad_x(n), ad_y(m); - for(size_t j = 0; j < n; j++) - ad_x[j] = double(j + 1); - Independent( ad_x ); - // for this example, we ensure first absolute value is | x_0 + x_1 | - AD ad_0 = abs( ad_x[0] + ad_x[1] ); - // and second absolute value is | x_1 + x_2 | - AD ad_1 = abs( ad_x[1] + ad_x[2] ); - ad_y[0] = ad_0 + ad_1; - ADFun f(ad_x, ad_y); - - // create its abs_normal representation in g, a - ADFun g, a; - f.abs_normal_fun(g, a); - - // check dimension of domain and range space for g - ok &= g.Domain() == n + s; - ok &= g.Range() == m + s; - - // check dimension of domain and range space for a - ok &= a.Domain() == n; - ok &= a.Range() == s; - - // -------------------------------------------------------------------- - // Choose a point x_hat - d_vector x_hat(n); - for(size_t j = 0; j < n; j++) - x_hat[j] = double(j - 1); - - // value of a_hat = a(x_hat) - d_vector a_hat = a.Forward(0, x_hat); - - // (x_hat, a_hat) - d_vector xu_hat = join(x_hat, a_hat); - - // value of g[ x_hat, a_hat ] - d_vector g_hat = g.Forward(0, xu_hat); - - // Jacobian of g[ x_hat, a_hat ] - d_vector g_jac = g.Jacobian(xu_hat); - - // value of delta_x - d_vector delta_x(n); - delta_x[0] = 1.0; - delta_x[1] = -2.0; - delta_x[2] = +2.0; - - // value of x - d_vector x(n); - for(size_t j = 0; j < n; j++) - x[j] = x_hat[j] + delta_x[j]; - - // value of f(x) - d_vector y = f.Forward(0, x); +{ bool ok = true; + // + using CppAD::AD; + using CppAD::ADFun; + // + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR( AD ) ad_vector; + // + double eps99 = 99.0 * std::numeric_limits::epsilon(); + // + size_t n = 3; // size of x + size_t m = 1; // size of y + size_t s = 2; // number of absolute value terms + // + // record the function f(x) + ad_vector ad_x(n), ad_y(m); + for(size_t j = 0; j < n; j++) + ad_x[j] = double(j + 1); + Independent( ad_x ); + // for this example, we ensure first absolute value is | x_0 + x_1 | + AD ad_0 = abs( ad_x[0] + ad_x[1] ); + // and second absolute value is | x_1 + x_2 | + AD ad_1 = abs( ad_x[1] + ad_x[2] ); + ad_y[0] = ad_0 + ad_1; + ADFun f(ad_x, ad_y); + + // create its abs_normal representation in g, a + ADFun g, a; + f.abs_normal_fun(g, a); + + // check dimension of domain and range space for g + ok &= g.Domain() == n + s; + ok &= g.Range() == m + s; + + // check dimension of domain and range space for a + ok &= a.Domain() == n; + ok &= a.Range() == s; + + // -------------------------------------------------------------------- + // Choose a point x_hat + d_vector x_hat(n); + for(size_t j = 0; j < n; j++) + x_hat[j] = double(j - 1); + + // value of a_hat = a(x_hat) + d_vector a_hat = a.Forward(0, x_hat); + + // (x_hat, a_hat) + d_vector xu_hat = join(x_hat, a_hat); + + // value of g[ x_hat, a_hat ] + d_vector g_hat = g.Forward(0, xu_hat); + + // Jacobian of g[ x_hat, a_hat ] + d_vector g_jac = g.Jacobian(xu_hat); + + // value of delta_x + d_vector delta_x(n); + delta_x[0] = 1.0; + delta_x[1] = -2.0; + delta_x[2] = +2.0; + + // value of x + d_vector x(n); + for(size_t j = 0; j < n; j++) + x[j] = x_hat[j] + delta_x[j]; + + // value of f(x) + d_vector y = f.Forward(0, x); - // value of g_tilde - d_vector g_tilde = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_x); + // value of g_tilde + d_vector g_tilde = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_x); - // should be equal because f is affine, except for abs terms - ok &= CppAD::NearEqual(y[0], g_tilde[0], eps99, eps99); + // should be equal because f is affine, except for abs terms + ok &= CppAD::NearEqual(y[0], g_tilde[0], eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/abs_eval.hpp cppad-2019.02.00.0/example/abs_normal/abs_eval.hpp --- cppad-2018.00.00.0/example/abs_normal/abs_eval.hpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/abs_eval.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,20 +3,21 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin abs_eval$$ $spell - jac - Jacobian - eval - hpp + jac + Jacobian + eval + hpp $$ $section abs_normal: Evaluate First Order Approximation$$ @@ -25,7 +26,7 @@ $head Prototype$$ $srcfile%example/abs_normal/abs_eval.hpp% - 0%// BEGIN PROTOTYPE%// END PROTOTYPE% + 0%// BEGIN PROTOTYPE%// END PROTOTYPE% 1%$$ $head Source$$ @@ -38,9 +39,9 @@ and a $latex \Delta x \in \B{R}^n$$, this routine evaluates the abs-normal $cref/approximation for f(x) - /abs_normal_fun - /Abs-normal Approximation - /Approximating f(x) + /abs_normal_fun + /Abs-normal Approximation + /Approximating f(x) /$$ where $latex x = \hat{x} + \Delta x$$. @@ -88,12 +89,11 @@ $latex x = \hat{x} + \Delta x$$ and $latex u = a(x)$$. $children%example/abs_normal/abs_eval.cpp - %example/abs_normal/abs_eval.omh + %example/abs_normal/abs_eval.omh %$$ $head Example$$ The file $cref abs_eval.cpp$$ contains an example and test of $code abs_eval$$. -It returns true if the test passes and false otherwise. $end ----------------------------------------------------------------------------- @@ -104,88 +104,88 @@ // BEGIN PROTOTYPE template Vector abs_eval( - size_t n , - size_t m , - size_t s , - const Vector& g_hat , - const Vector& g_jac , - const Vector& delta_x ) + size_t n , + size_t m , + size_t s , + const Vector& g_hat , + const Vector& g_jac , + const Vector& delta_x ) // END PROTOTYPE -{ using std::fabs; - // - CPPAD_ASSERT_KNOWN( - size_t(delta_x.size()) == n, - "abs_eval: size of delta_x not equal to n" - ); - CPPAD_ASSERT_KNOWN( - size_t(g_hat.size()) == m + s, - "abs_eval: size of g_hat not equal to m + s" - ); - CPPAD_ASSERT_KNOWN( - size_t(g_jac.size()) == (m + s) * (n + s), - "abs_eval: size of g_jac not equal to (m + s)*(n + s)" - ); +{ using std::fabs; + // + CPPAD_ASSERT_KNOWN( + size_t(delta_x.size()) == n, + "abs_eval: size of delta_x not equal to n" + ); + CPPAD_ASSERT_KNOWN( + size_t(g_hat.size()) == m + s, + "abs_eval: size of g_hat not equal to m + s" + ); + CPPAD_ASSERT_KNOWN( + size_t(g_jac.size()) == (m + s) * (n + s), + "abs_eval: size of g_jac not equal to (m + s)*(n + s)" + ); # ifndef NDEBUG - // Check that partial_u z(x, u) is strictly lower triangular - for(size_t i = 0; i < s; i++) - { for(size_t j = i; j < s; j++) - { // index in g_jac of partial of z_i w.r.t u_j - // (note that g_jac has n + s elements in each row) - size_t index = (m + i) * (n + s) + (n + j); - CPPAD_ASSERT_KNOWN( - g_jac[index] == 0.0, - "abs_eval: partial z_i w.r.t u_j non-zero for i <= j" - ); - } - } + // Check that partial_u z(x, u) is strictly lower triangular + for(size_t i = 0; i < s; i++) + { for(size_t j = i; j < s; j++) + { // index in g_jac of partial of z_i w.r.t u_j + // (note that g_jac has n + s elements in each row) + size_t index = (m + i) * (n + s) + (n + j); + CPPAD_ASSERT_KNOWN( + g_jac[index] == 0.0, + "abs_eval: partial z_i w.r.t u_j non-zero for i <= j" + ); + } + } # endif - // return value - Vector g_tilde(m + s); - // - // compute z_tilde, the last s components of g_tilde - for(size_t i = 0; i < s; i++) - { // start at z_hat_i - g_tilde[m + i] = g_hat[m + i]; - // contribution for change x - for(size_t j = 0; j < n; j++) - { // index in g_jac of partial of z_i w.r.t x_j - size_t index = (m + i) * (n + s) + j; - // add contribution for delta_x_j to z_tilde_i - g_tilde[m + i] += g_jac[index] * delta_x[j]; - } - // contribution for change in u_j for j < i - for(size_t j = 0; j < i; j++) - { // approixmation for change in absolute value - double delta_a_j = fabs(g_tilde[m + j]) - fabs(g_hat[m + j]); - // index in g_jac of partial of z_i w.r.t u_j - size_t index = (m + i) * (n + s) + n + j; - // add constribution for delta_a_j to s_tilde_i - g_tilde[m + i] += g_jac[index] * delta_a_j; - } - } - // - // compute y_tilde, the first m components of g_tilde - for(size_t i = 0; i < m; i++) - { // start at y_hat_i - g_tilde[i] = g_hat[i]; - // contribution for change x - for(size_t j = 0; j < n; j++) - { // index in g_jac of partial of y_i w.r.t x_j - size_t index = i * (n + s) + j; - // add contribution for delta_x_j to y_tilde_i - g_tilde[i] += g_jac[index] * delta_x[j]; - } - // contribution for change in u_j - for(size_t j = 0; j < s; j++) - { // approximation for change in absolute value - double delta_a_j = fabs(g_tilde[m + j]) - fabs(g_hat[m + j]); - // index in g_jac of partial of y_i w.r.t u_j - size_t index = i * (n + s) + n + j; - // add constribution for delta_a_j to s_tilde_i - g_tilde[i] += g_jac[index] * delta_a_j; - } - } - return g_tilde; + // return value + Vector g_tilde(m + s); + // + // compute z_tilde, the last s components of g_tilde + for(size_t i = 0; i < s; i++) + { // start at z_hat_i + g_tilde[m + i] = g_hat[m + i]; + // contribution for change x + for(size_t j = 0; j < n; j++) + { // index in g_jac of partial of z_i w.r.t x_j + size_t index = (m + i) * (n + s) + j; + // add contribution for delta_x_j to z_tilde_i + g_tilde[m + i] += g_jac[index] * delta_x[j]; + } + // contribution for change in u_j for j < i + for(size_t j = 0; j < i; j++) + { // approixmation for change in absolute value + double delta_a_j = fabs(g_tilde[m + j]) - fabs(g_hat[m + j]); + // index in g_jac of partial of z_i w.r.t u_j + size_t index = (m + i) * (n + s) + n + j; + // add constribution for delta_a_j to s_tilde_i + g_tilde[m + i] += g_jac[index] * delta_a_j; + } + } + // + // compute y_tilde, the first m components of g_tilde + for(size_t i = 0; i < m; i++) + { // start at y_hat_i + g_tilde[i] = g_hat[i]; + // contribution for change x + for(size_t j = 0; j < n; j++) + { // index in g_jac of partial of y_i w.r.t x_j + size_t index = i * (n + s) + j; + // add contribution for delta_x_j to y_tilde_i + g_tilde[i] += g_jac[index] * delta_x[j]; + } + // contribution for change in u_j + for(size_t j = 0; j < s; j++) + { // approximation for change in absolute value + double delta_a_j = fabs(g_tilde[m + j]) - fabs(g_hat[m + j]); + // index in g_jac of partial of y_i w.r.t u_j + size_t index = i * (n + s) + n + j; + // add constribution for delta_a_j to s_tilde_i + g_tilde[i] += g_jac[index] * delta_a_j; + } + } + return g_tilde; } } // END_CPPAD_NAMESPACE // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/abs_eval.omh cppad-2019.02.00.0/example/abs_normal/abs_eval.omh --- cppad-2018.00.00.0/example/abs_normal/abs_eval.omh 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/abs_eval.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,23 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin abs_eval.hpp$$ $spell - eval + eval $$ $section abs_eval Source Code$$ $srcfile%example/abs_normal/abs_eval.hpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 0%$$ $end diff -Nru cppad-2018.00.00.0/example/abs_normal/abs_min_linear.cpp cppad-2019.02.00.0/example/abs_normal/abs_min_linear.cpp --- cppad-2018.00.00.0/example/abs_normal/abs_min_linear.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/abs_min_linear.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin abs_min_linear.cpp$$ @@ -40,7 +41,7 @@ $head Source$$ $srcfile%example/abs_normal/abs_min_linear.cpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 1%$$ $end @@ -51,116 +52,116 @@ # include "abs_min_linear.hpp" namespace { - CPPAD_TESTVECTOR(double) join( - const CPPAD_TESTVECTOR(double)& x , - const CPPAD_TESTVECTOR(double)& u ) - { size_t n = x.size(); - size_t s = u.size(); - CPPAD_TESTVECTOR(double) xu(n + s); - for(size_t j = 0; j < n; j++) - xu[j] = x[j]; - for(size_t j = 0; j < s; j++) - xu[n + j] = u[j]; - return xu; - } + CPPAD_TESTVECTOR(double) join( + const CPPAD_TESTVECTOR(double)& x , + const CPPAD_TESTVECTOR(double)& u ) + { size_t n = x.size(); + size_t s = u.size(); + CPPAD_TESTVECTOR(double) xu(n + s); + for(size_t j = 0; j < n; j++) + xu[j] = x[j]; + for(size_t j = 0; j < s; j++) + xu[n + j] = u[j]; + return xu; + } } bool abs_min_linear(void) -{ bool ok = true; - // - using CppAD::AD; - using CppAD::ADFun; - // - typedef CPPAD_TESTVECTOR(size_t) s_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR( AD ) ad_vector; - // - size_t dpx = 3; // number of data points per x variable - size_t level = 0; // level of tracing - size_t n = 2; // size of x - size_t m = 1; // size of y - size_t s = dpx * n; // number of data points and absolute values - // data points - d_vector data(s); - for(size_t i = 0; i < s; i++) - data[i] = double(s - i) + 5.0 - double(i % 2) / 2.0; - // - // record the function f(x) - ad_vector ad_x(n), ad_y(m); - for(size_t j = 0; j < n; j++) - ad_x[j] = double(j + 1); - Independent( ad_x ); - AD sum = 0.0; - for(size_t j = 0; j < n; j++) - for(size_t k = 0; k < dpx; k++) - sum += abs( data[j * dpx + k] - ad_x[j] ); - ad_y[0] = sum; - ADFun f(ad_x, ad_y); - - // create its abs_normal representation in g, a - ADFun g, a; - f.abs_normal_fun(g, a); - - // check dimension of domain and range space for g - ok &= g.Domain() == n + s; - ok &= g.Range() == m + s; - - // check dimension of domain and range space for a - ok &= a.Domain() == n; - ok &= a.Range() == s; - - // -------------------------------------------------------------------- - // Choose a point x_hat - d_vector x_hat(n); - for(size_t j = 0; j < n; j++) - x_hat[j] = double(0.0); - - // value of a_hat = a(x_hat) - d_vector a_hat = a.Forward(0, x_hat); - - // (x_hat, a_hat) - d_vector xu_hat = join(x_hat, a_hat); - - // value of g[ x_hat, a_hat ] - d_vector g_hat = g.Forward(0, xu_hat); - - // Jacobian of g[ x_hat, a_hat ] - d_vector g_jac = g.Jacobian(xu_hat); - - // trust region bound (make large enough to include solutuion) - d_vector bound(n); - for(size_t j = 0; j < n; j++) - bound[j] = 10.0; - - // convergence criteria - d_vector epsilon(2); - double eps99 = 99.0 * std::numeric_limits::epsilon(); - epsilon[0] = eps99; - epsilon[1] = eps99; - - // maximum number of iterations - s_vector maxitr(2); - maxitr[0] = 10; // maximum number of abs_min_linear iterations - maxitr[1] = 35; // maximum number of qp_interior iterations - - // minimize the approxiamtion for f, which is equal to f because - // f is affine, except for absolute value terms - d_vector delta_x(n); - ok &= CppAD::abs_min_linear( - level, n, m, s, g_hat, g_jac, bound, epsilon, maxitr, delta_x - ); - - // number of data points per variable is odd - ok &= dpx % 2 == 1; - - // check that the solution is the median of the corresponding data` - for(size_t j = 0; j < n; j++) - { // data[j * dpx + 0] , ... , data[j * dpx + dpx - 1] corresponds to x[j] - // the median of this data has index j * dpx + dpx / 2 - size_t j_median = j * dpx + (dpx / 2); - // - ok &= CppAD::NearEqual( delta_x[j], data[j_median], eps99, eps99 ); - } +{ bool ok = true; + // + using CppAD::AD; + using CppAD::ADFun; + // + typedef CPPAD_TESTVECTOR(size_t) s_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR( AD ) ad_vector; + // + size_t dpx = 3; // number of data points per x variable + size_t level = 0; // level of tracing + size_t n = 2; // size of x + size_t m = 1; // size of y + size_t s = dpx * n; // number of data points and absolute values + // data points + d_vector data(s); + for(size_t i = 0; i < s; i++) + data[i] = double(s - i) + 5.0 - double(i % 2) / 2.0; + // + // record the function f(x) + ad_vector ad_x(n), ad_y(m); + for(size_t j = 0; j < n; j++) + ad_x[j] = double(j + 1); + Independent( ad_x ); + AD sum = 0.0; + for(size_t j = 0; j < n; j++) + for(size_t k = 0; k < dpx; k++) + sum += abs( data[j * dpx + k] - ad_x[j] ); + ad_y[0] = sum; + ADFun f(ad_x, ad_y); + + // create its abs_normal representation in g, a + ADFun g, a; + f.abs_normal_fun(g, a); + + // check dimension of domain and range space for g + ok &= g.Domain() == n + s; + ok &= g.Range() == m + s; + + // check dimension of domain and range space for a + ok &= a.Domain() == n; + ok &= a.Range() == s; + + // -------------------------------------------------------------------- + // Choose a point x_hat + d_vector x_hat(n); + for(size_t j = 0; j < n; j++) + x_hat[j] = double(0.0); + + // value of a_hat = a(x_hat) + d_vector a_hat = a.Forward(0, x_hat); + + // (x_hat, a_hat) + d_vector xu_hat = join(x_hat, a_hat); + + // value of g[ x_hat, a_hat ] + d_vector g_hat = g.Forward(0, xu_hat); + + // Jacobian of g[ x_hat, a_hat ] + d_vector g_jac = g.Jacobian(xu_hat); + + // trust region bound (make large enough to include solutuion) + d_vector bound(n); + for(size_t j = 0; j < n; j++) + bound[j] = 10.0; + + // convergence criteria + d_vector epsilon(2); + double eps99 = 99.0 * std::numeric_limits::epsilon(); + epsilon[0] = eps99; + epsilon[1] = eps99; + + // maximum number of iterations + s_vector maxitr(2); + maxitr[0] = 10; // maximum number of abs_min_linear iterations + maxitr[1] = 35; // maximum number of qp_interior iterations + + // minimize the approxiamtion for f, which is equal to f because + // f is affine, except for absolute value terms + d_vector delta_x(n); + ok &= CppAD::abs_min_linear( + level, n, m, s, g_hat, g_jac, bound, epsilon, maxitr, delta_x + ); + + // number of data points per variable is odd + ok &= dpx % 2 == 1; + + // check that the solution is the median of the corresponding data` + for(size_t j = 0; j < n; j++) + { // data[j * dpx + 0] , ... , data[j * dpx + dpx - 1] corresponds to x[j] + // the median of this data has index j * dpx + dpx / 2 + size_t j_median = j * dpx + (dpx / 2); + // + ok &= CppAD::NearEqual( delta_x[j], data[j_median], eps99, eps99 ); + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/abs_min_linear.hpp cppad-2019.02.00.0/example/abs_normal/abs_min_linear.hpp --- cppad-2018.00.00.0/example/abs_normal/abs_min_linear.hpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/abs_min_linear.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,32 +3,33 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin abs_min_linear$$ $spell - hpp - jac - Jacobian - maxitr + hpp + jac + Jacobian + maxitr $$ $section abs_normal: Minimize a Linear Abs-normal Approximation$$ $head Syntax$$ $icode%ok% = abs_min_linear( - %level%, %n%, %m%, %s%, - %g_hat%, %g_jac%, %bound%, %epsilon%, %maxitr%, %delta_x% + %level%, %n%, %m%, %s%, + %g_hat%, %g_jac%, %bound%, %epsilon%, %maxitr%, %delta_x% )%$$ $head Prototype$$ $srcfile%example/abs_normal/abs_min_linear.hpp% - 0%// BEGIN PROTOTYPE%// END PROTOTYPE% + 0%// BEGIN PROTOTYPE%// END PROTOTYPE% 1%$$ $head Source$$ @@ -39,9 +40,9 @@ We are given a point $latex \hat{x} \in \B{R}^n$$ and use the notation $latex \tilde{f} (x)$$ for the abs-normal $cref/approximation for f(x) - /abs_normal_fun - /Abs-normal Approximation - /Approximating f(x) + /abs_normal_fun + /Abs-normal Approximation + /Approximating f(x) /$$ near $latex \hat{x}$$. We are also given a vector $latex b \in \B{R}_+^n$$. @@ -109,7 +110,7 @@ and we denote its value by $latex b \in \B{R}^n$$. The trust region is defined as the set of $latex x$$ such that $latex \[ - | x_j - \hat{x}_j | \leq b_j + | x_j - \hat{x}_j | \leq b_j \]$$ for $latex j = 0 , \ldots , n-1$$, where $latex x$$ is the point that we are approximating $latex f(x)$$. @@ -142,7 +143,7 @@ $subhead sigma$$ We use the notation $latex \[ - \sigma (x) = \R{sign} ( z[ x , a(x) ] ) + \sigma (x) = \R{sign} ( z[ x , a(x) ] ) \] $$ where $cref/a(x)/abs_normal_fun/a/a(x)/$$ and @@ -162,8 +163,8 @@ $latex \[ \begin{array}{lll} \R{minimize} - & \max \{ p_k (x) \W{:} k = 0 , \ldots , K-1 \} - & \R{w.r.t} \; x + & \max \{ p_k (x) \W{:} k = 0 , \ldots , K-1 \} + & \R{w.r.t} \; x \\ \R{subject \; to} & - b \leq x \leq + b \end{array} @@ -176,12 +177,11 @@ $children%example/abs_normal/abs_min_linear.cpp - %example/abs_normal/abs_min_linear.omh + %example/abs_normal/abs_min_linear.omh %$$ $head Example$$ The file $cref abs_min_linear.cpp$$ contains an example and test of $code abs_min_linear$$. -It returns true if the test passes and false otherwise. $end ----------------------------------------------------------------------------- @@ -196,237 +196,237 @@ // BEGIN PROTOTYPE template bool abs_min_linear( - size_t level , - size_t n , - size_t m , - size_t s , - const DblVector& g_hat , - const DblVector& g_jac , - const DblVector& bound , - const DblVector& epsilon , - const SizeVector& maxitr , - DblVector& delta_x ) + size_t level , + size_t n , + size_t m , + size_t s , + const DblVector& g_hat , + const DblVector& g_jac , + const DblVector& bound , + const DblVector& epsilon , + const SizeVector& maxitr , + DblVector& delta_x ) // END PROTOTYPE -{ using std::fabs; - bool ok = true; - double inf = std::numeric_limits::infinity(); - // - CPPAD_ASSERT_KNOWN( - level <= 4, - "abs_min_linear: level is not less that or equal 4" - ); - CPPAD_ASSERT_KNOWN( - size_t(epsilon.size()) == 2, - "abs_min_linear: size of epsilon not equal to 2" - ); - CPPAD_ASSERT_KNOWN( - size_t(maxitr.size()) == 2, - "abs_min_linear: size of maxitr not equal to 2" - ); - CPPAD_ASSERT_KNOWN( - m == 1, - "abs_min_linear: m is not equal to 1" - ); - CPPAD_ASSERT_KNOWN( - size_t(delta_x.size()) == n, - "abs_min_linear: size of delta_x not equal to n" - ); - CPPAD_ASSERT_KNOWN( - size_t(bound.size()) == n, - "abs_min_linear: size of bound not equal to n" - ); - CPPAD_ASSERT_KNOWN( - size_t(g_hat.size()) == m + s, - "abs_min_linear: size of g_hat not equal to m + s" - ); - CPPAD_ASSERT_KNOWN( - size_t(g_jac.size()) == (m + s) * (n + s), - "abs_min_linear: size of g_jac not equal to (m + s)*(n + s)" - ); - CPPAD_ASSERT_KNOWN( - size_t(bound.size()) == n, - "abs_min_linear: size of bound is not equal to n" - ); - if( level > 0 ) - { std::cout << "start abs_min_linear\n"; - CppAD::abs_print_mat("bound", n, 1, bound); - CppAD::abs_print_mat("g_hat", m + s, 1, g_hat); - CppAD::abs_print_mat("g_jac", m + s, n + s, g_jac); - - } - // partial y(x, u) w.r.t x (J in reference) - DblVector py_px(n); - for(size_t j = 0; j < n; j++) - py_px[ j ] = g_jac[ j ]; - // - // partial y(x, u) w.r.t u (Y in reference) - DblVector py_pu(s); - for(size_t j = 0; j < s; j++) - py_pu[ j ] = g_jac[ n + j ]; - // - // partial z(x, u) w.r.t x (Z in reference) - DblVector pz_px(s * n); - for(size_t i = 0; i < s; i++) - { for(size_t j = 0; j < n; j++) - { pz_px[ i * n + j ] = g_jac[ (n + s) * (i + m) + j ]; - } - } - // partial z(x, u) w.r.t u (L in reference) - DblVector pz_pu(s * s); - for(size_t i = 0; i < s; i++) - { for(size_t j = 0; j < s; j++) - { pz_pu[ i * s + j ] = g_jac[ (n + s) * (i + m) + n + j ]; - } - } - // initailize delta_x - for(size_t j = 0; j < n; j++) - delta_x[j] = 0.0; - // - // value of approximation for g(x, u) at current delta_x - DblVector g_tilde = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_x); - // - // value of sigma at delta_x = 0; i.e., sign( z(x, u) ) - CppAD::vector sigma(s); - for(size_t i = 0; i < s; i++) - sigma[i] = CppAD::sign( g_tilde[m + i] ); - // - // current set of cutting planes - DblVector C(maxitr[0] * n), c(maxitr[0]); - // - // - size_t n_plane = 0; - for(size_t itr = 0; itr < maxitr[0]; itr++) - { - // Equation (5), Propostion 3.1 of reference - // dy_dx = py_px + py_pu * Sigma * (I - pz_pu * Sigma)^-1 * pz_px - // - // tmp_ss = I - pz_pu * Sigma - DblVector tmp_ss(s * s); - for(size_t i = 0; i < s; i++) - { for(size_t j = 0; j < s; j++) - tmp_ss[i * s + j] = - pz_pu[i * s + j] * sigma[j]; - tmp_ss[i * s + i] += 1.0; - } - // tmp_sn = (I - pz_pu * Sigma)^-1 * pz_px - double logdet; - DblVector tmp_sn(s * n); - LuSolve(s, n, tmp_ss, pz_px, tmp_sn, logdet); - // - // tmp_sn = Sigma * (I - pz_pu * Sigma)^-1 * pz_px - for(size_t i = 0; i < s; i++) - { for(size_t j = 0; j < n; j++) - tmp_sn[i * n + j] *= sigma[i]; - } - // dy_dx = py_px + py_pu * Sigma * (I - pz_pu * Sigma)^-1 * pz_px - DblVector dy_dx(n); - for(size_t j = 0; j < n; j++) - { dy_dx[j] = py_px[j]; - for(size_t k = 0; k < s; k++) - dy_dx[j] += py_pu[k] * tmp_sn[ k * n + j]; - } - // - // check for case where derivative of hyperplane is zero - // (in convex case, this is the minimizer) - bool near_zero = true; - for(size_t j = 0; j < n; j++) - near_zero &= std::fabs( dy_dx[j] ) < epsilon[1]; - if( near_zero ) - { if( level > 0 ) - std::cout << "end abs_min_linear: local derivative near zero\n"; - return true; - } - - // value of hyperplane at delta_x - double plane_at_zero = g_tilde[0]; - // value of hyperplane at 0 - for(size_t j = 0; j < n; j++) - plane_at_zero -= dy_dx[j] * delta_x[j]; - // - // add a cutting plane with value g_tilde[0] at delta_x - // and derivative dy_dx - c[n_plane] = plane_at_zero; - for(size_t j = 0; j < n; j++) - C[n_plane * n + j] = dy_dx[j]; - ++n_plane; - // - // variables for cutting plane problem are (dx, w) - // c[i] + C[i,:]*dx <= w - DblVector b_box(n_plane), A_box(n_plane * (n + 1)); - for(size_t i = 0; i < n_plane; i++) - { b_box[i] = c[i]; - for(size_t j = 0; j < n; j++) - A_box[i * (n+1) + j] = C[i * n + j]; - A_box[i *(n+1) + n] = -1.0; - } - // w is the objective - DblVector c_box(n + 1); - for(size_t i = 0; i < size_t(c_box.size()); i++) - c_box[i] = 0.0; - c_box[n] = 1.0; - // - // d_box - DblVector d_box(n+1); - for(size_t j = 0; j < n; j++) - d_box[j] = bound[j]; - d_box[n] = inf; - // - // solve the cutting plane problem - DblVector xout_box(n + 1); - size_t level_box = 0; - if( level > 0 ) - level_box = level - 1; - ok &= CppAD::lp_box( - level_box, - A_box, - b_box, - c_box, - d_box, - maxitr[1], - xout_box - ); - if( ! ok ) - { if( level > 0 ) - { CppAD::abs_print_mat("delta_x", n, 1, delta_x); - std::cout << "end abs_min_linear: lp_box failed\n"; - } - return false; - } - // - // check for convergence - double max_diff = 0.0; - for(size_t j = 0; j < n; j++) - { double diff = delta_x[j] - xout_box[j]; - max_diff = std::max( max_diff, std::fabs(diff) ); - } - // - // check for descent in value of approximation objective - DblVector delta_new(n); - for(size_t j = 0; j < n; j++) - delta_new[j] = xout_box[j]; - DblVector g_new = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_new); - if( level > 0 ) - { std::cout << "itr = " << itr << ", max_diff = " << max_diff - << ", y_cur = " << g_tilde[0] << ", y_new = " << g_new[0] - << "\n"; - CppAD::abs_print_mat("delta_new", n, 1, delta_new); - } - // - g_tilde = g_new; - delta_x = delta_new; - // - // value of sigma at new delta_x; i.e., sign( z(x, u) ) - for(size_t i = 0; i < s; i++) - sigma[i] = CppAD::sign( g_tilde[m + i] ); - // - if( max_diff < epsilon[0] ) - { if( level > 0 ) - std::cout << "end abs_min_linear: change in delta_x near zero\n"; - return true; - } - } - if( level > 0 ) - std::cout << "end abs_min_linear: maximum number of iterations exceeded\n"; - return false; +{ using std::fabs; + bool ok = true; + double inf = std::numeric_limits::infinity(); + // + CPPAD_ASSERT_KNOWN( + level <= 4, + "abs_min_linear: level is not less that or equal 4" + ); + CPPAD_ASSERT_KNOWN( + size_t(epsilon.size()) == 2, + "abs_min_linear: size of epsilon not equal to 2" + ); + CPPAD_ASSERT_KNOWN( + size_t(maxitr.size()) == 2, + "abs_min_linear: size of maxitr not equal to 2" + ); + CPPAD_ASSERT_KNOWN( + m == 1, + "abs_min_linear: m is not equal to 1" + ); + CPPAD_ASSERT_KNOWN( + size_t(delta_x.size()) == n, + "abs_min_linear: size of delta_x not equal to n" + ); + CPPAD_ASSERT_KNOWN( + size_t(bound.size()) == n, + "abs_min_linear: size of bound not equal to n" + ); + CPPAD_ASSERT_KNOWN( + size_t(g_hat.size()) == m + s, + "abs_min_linear: size of g_hat not equal to m + s" + ); + CPPAD_ASSERT_KNOWN( + size_t(g_jac.size()) == (m + s) * (n + s), + "abs_min_linear: size of g_jac not equal to (m + s)*(n + s)" + ); + CPPAD_ASSERT_KNOWN( + size_t(bound.size()) == n, + "abs_min_linear: size of bound is not equal to n" + ); + if( level > 0 ) + { std::cout << "start abs_min_linear\n"; + CppAD::abs_print_mat("bound", n, 1, bound); + CppAD::abs_print_mat("g_hat", m + s, 1, g_hat); + CppAD::abs_print_mat("g_jac", m + s, n + s, g_jac); + + } + // partial y(x, u) w.r.t x (J in reference) + DblVector py_px(n); + for(size_t j = 0; j < n; j++) + py_px[ j ] = g_jac[ j ]; + // + // partial y(x, u) w.r.t u (Y in reference) + DblVector py_pu(s); + for(size_t j = 0; j < s; j++) + py_pu[ j ] = g_jac[ n + j ]; + // + // partial z(x, u) w.r.t x (Z in reference) + DblVector pz_px(s * n); + for(size_t i = 0; i < s; i++) + { for(size_t j = 0; j < n; j++) + { pz_px[ i * n + j ] = g_jac[ (n + s) * (i + m) + j ]; + } + } + // partial z(x, u) w.r.t u (L in reference) + DblVector pz_pu(s * s); + for(size_t i = 0; i < s; i++) + { for(size_t j = 0; j < s; j++) + { pz_pu[ i * s + j ] = g_jac[ (n + s) * (i + m) + n + j ]; + } + } + // initailize delta_x + for(size_t j = 0; j < n; j++) + delta_x[j] = 0.0; + // + // value of approximation for g(x, u) at current delta_x + DblVector g_tilde = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_x); + // + // value of sigma at delta_x = 0; i.e., sign( z(x, u) ) + CppAD::vector sigma(s); + for(size_t i = 0; i < s; i++) + sigma[i] = CppAD::sign( g_tilde[m + i] ); + // + // current set of cutting planes + DblVector C(maxitr[0] * n), c(maxitr[0]); + // + // + size_t n_plane = 0; + for(size_t itr = 0; itr < maxitr[0]; itr++) + { + // Equation (5), Propostion 3.1 of reference + // dy_dx = py_px + py_pu * Sigma * (I - pz_pu * Sigma)^-1 * pz_px + // + // tmp_ss = I - pz_pu * Sigma + DblVector tmp_ss(s * s); + for(size_t i = 0; i < s; i++) + { for(size_t j = 0; j < s; j++) + tmp_ss[i * s + j] = - pz_pu[i * s + j] * sigma[j]; + tmp_ss[i * s + i] += 1.0; + } + // tmp_sn = (I - pz_pu * Sigma)^-1 * pz_px + double logdet; + DblVector tmp_sn(s * n); + LuSolve(s, n, tmp_ss, pz_px, tmp_sn, logdet); + // + // tmp_sn = Sigma * (I - pz_pu * Sigma)^-1 * pz_px + for(size_t i = 0; i < s; i++) + { for(size_t j = 0; j < n; j++) + tmp_sn[i * n + j] *= sigma[i]; + } + // dy_dx = py_px + py_pu * Sigma * (I - pz_pu * Sigma)^-1 * pz_px + DblVector dy_dx(n); + for(size_t j = 0; j < n; j++) + { dy_dx[j] = py_px[j]; + for(size_t k = 0; k < s; k++) + dy_dx[j] += py_pu[k] * tmp_sn[ k * n + j]; + } + // + // check for case where derivative of hyperplane is zero + // (in convex case, this is the minimizer) + bool near_zero = true; + for(size_t j = 0; j < n; j++) + near_zero &= std::fabs( dy_dx[j] ) < epsilon[1]; + if( near_zero ) + { if( level > 0 ) + std::cout << "end abs_min_linear: local derivative near zero\n"; + return true; + } + + // value of hyperplane at delta_x + double plane_at_zero = g_tilde[0]; + // value of hyperplane at 0 + for(size_t j = 0; j < n; j++) + plane_at_zero -= dy_dx[j] * delta_x[j]; + // + // add a cutting plane with value g_tilde[0] at delta_x + // and derivative dy_dx + c[n_plane] = plane_at_zero; + for(size_t j = 0; j < n; j++) + C[n_plane * n + j] = dy_dx[j]; + ++n_plane; + // + // variables for cutting plane problem are (dx, w) + // c[i] + C[i,:]*dx <= w + DblVector b_box(n_plane), A_box(n_plane * (n + 1)); + for(size_t i = 0; i < n_plane; i++) + { b_box[i] = c[i]; + for(size_t j = 0; j < n; j++) + A_box[i * (n+1) + j] = C[i * n + j]; + A_box[i *(n+1) + n] = -1.0; + } + // w is the objective + DblVector c_box(n + 1); + for(size_t i = 0; i < size_t(c_box.size()); i++) + c_box[i] = 0.0; + c_box[n] = 1.0; + // + // d_box + DblVector d_box(n+1); + for(size_t j = 0; j < n; j++) + d_box[j] = bound[j]; + d_box[n] = inf; + // + // solve the cutting plane problem + DblVector xout_box(n + 1); + size_t level_box = 0; + if( level > 0 ) + level_box = level - 1; + ok &= CppAD::lp_box( + level_box, + A_box, + b_box, + c_box, + d_box, + maxitr[1], + xout_box + ); + if( ! ok ) + { if( level > 0 ) + { CppAD::abs_print_mat("delta_x", n, 1, delta_x); + std::cout << "end abs_min_linear: lp_box failed\n"; + } + return false; + } + // + // check for convergence + double max_diff = 0.0; + for(size_t j = 0; j < n; j++) + { double diff = delta_x[j] - xout_box[j]; + max_diff = std::max( max_diff, std::fabs(diff) ); + } + // + // check for descent in value of approximation objective + DblVector delta_new(n); + for(size_t j = 0; j < n; j++) + delta_new[j] = xout_box[j]; + DblVector g_new = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_new); + if( level > 0 ) + { std::cout << "itr = " << itr << ", max_diff = " << max_diff + << ", y_cur = " << g_tilde[0] << ", y_new = " << g_new[0] + << "\n"; + CppAD::abs_print_mat("delta_new", n, 1, delta_new); + } + // + g_tilde = g_new; + delta_x = delta_new; + // + // value of sigma at new delta_x; i.e., sign( z(x, u) ) + for(size_t i = 0; i < s; i++) + sigma[i] = CppAD::sign( g_tilde[m + i] ); + // + if( max_diff < epsilon[0] ) + { if( level > 0 ) + std::cout << "end abs_min_linear: change in delta_x near zero\n"; + return true; + } + } + if( level > 0 ) + std::cout << "end abs_min_linear: maximum number of iterations exceeded\n"; + return false; } } // END_CPPAD_NAMESPACE // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/abs_min_linear.omh cppad-2019.02.00.0/example/abs_normal/abs_min_linear.omh --- cppad-2018.00.00.0/example/abs_normal/abs_min_linear.omh 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/abs_min_linear.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin abs_min_linear.hpp$$ $spell @@ -15,7 +16,7 @@ $section abs_min_linear Source Code$$ $srcfile%example/abs_normal/abs_min_linear.hpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 0%$$ $end diff -Nru cppad-2018.00.00.0/example/abs_normal/abs_min_quad.cpp cppad-2019.02.00.0/example/abs_normal/abs_min_quad.cpp --- cppad-2018.00.00.0/example/abs_normal/abs_min_quad.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/abs_min_quad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin abs_min_quad.cpp$$ @@ -31,7 +32,7 @@ $head Source$$ $srcfile%example/abs_normal/abs_min_quad.cpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 1%$$ $end @@ -42,110 +43,110 @@ # include "abs_min_quad.hpp" namespace { - CPPAD_TESTVECTOR(double) join( - const CPPAD_TESTVECTOR(double)& x , - const CPPAD_TESTVECTOR(double)& u ) - { size_t n = x.size(); - size_t s = u.size(); - CPPAD_TESTVECTOR(double) xu(n + s); - for(size_t j = 0; j < n; j++) - xu[j] = x[j]; - for(size_t j = 0; j < s; j++) - xu[n + j] = u[j]; - return xu; - } + CPPAD_TESTVECTOR(double) join( + const CPPAD_TESTVECTOR(double)& x , + const CPPAD_TESTVECTOR(double)& u ) + { size_t n = x.size(); + size_t s = u.size(); + CPPAD_TESTVECTOR(double) xu(n + s); + for(size_t j = 0; j < n; j++) + xu[j] = x[j]; + for(size_t j = 0; j < s; j++) + xu[n + j] = u[j]; + return xu; + } } bool abs_min_quad(void) -{ bool ok = true; - // - using CppAD::AD; - using CppAD::ADFun; - // - typedef CPPAD_TESTVECTOR(size_t) s_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR( AD ) ad_vector; - // - size_t level = 0; // level of tracing - size_t n = 2; // size of x - size_t m = 1; // size of y - size_t s = 2 ; // number of data points and absolute values - // - // record the function f(x) - ad_vector ad_x(n), ad_y(m); - for(size_t j = 0; j < n; j++) - ad_x[j] = double(j + 1); - Independent( ad_x ); - AD sum = 0.0; - sum += ad_x[0] * ad_x[0] / 2.0 + abs( ad_x[0] - 5 ); - sum += ad_x[1] * ad_x[1] / 2.0 + abs( ad_x[1] + 5 ); - ad_y[0] = sum; - ADFun f(ad_x, ad_y); - - // create its abs_normal representation in g, a - ADFun g, a; - f.abs_normal_fun(g, a); - - // check dimension of domain and range space for g - ok &= g.Domain() == n + s; - ok &= g.Range() == m + s; - - // check dimension of domain and range space for a - ok &= a.Domain() == n; - ok &= a.Range() == s; - - // -------------------------------------------------------------------- - // Choose the point x_hat = 0 - d_vector x_hat(n); - for(size_t j = 0; j < n; j++) - x_hat[j] = 0.0; - - // value of a_hat = a(x_hat) - d_vector a_hat = a.Forward(0, x_hat); - - // (x_hat, a_hat) - d_vector xu_hat = join(x_hat, a_hat); - - // value of g[ x_hat, a_hat ] - d_vector g_hat = g.Forward(0, xu_hat); - - // Jacobian of g[ x_hat, a_hat ] - d_vector g_jac = g.Jacobian(xu_hat); - - // trust region bound - d_vector bound(n); - for(size_t j = 0; j < n; j++) - bound[j] = 10.0; - - // convergence criteria - d_vector epsilon(2); - double eps99 = 99.0 * std::numeric_limits::epsilon(); - epsilon[0] = eps99; - epsilon[1] = eps99; - - // maximum number of iterations - s_vector maxitr(2); - maxitr[0] = 10; // maximum number of abs_min_quad iterations - maxitr[1] = 35; // maximum number of qp_interior iterations - - // set Hessian equal to identity matrix I - d_vector hessian(n * n); - for(size_t i = 0; i < n; i++) - { for(size_t j = 0; j < n; j++) - hessian[i * n + j] = 0.0; - hessian[i * n + i] = 1.0; - } - - // minimize the approxiamtion for f (which is equal to f for this case) - d_vector delta_x(n); - ok &= CppAD::abs_min_quad( - level, n, m, s, - g_hat, g_jac, hessian, bound, epsilon, maxitr, delta_x - ); - - // check that the solution - ok &= CppAD::NearEqual( delta_x[0], +1.0, eps99, eps99 ); - ok &= CppAD::NearEqual( delta_x[1], -1.0, eps99, eps99 ); +{ bool ok = true; + // + using CppAD::AD; + using CppAD::ADFun; + // + typedef CPPAD_TESTVECTOR(size_t) s_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR( AD ) ad_vector; + // + size_t level = 0; // level of tracing + size_t n = 2; // size of x + size_t m = 1; // size of y + size_t s = 2 ; // number of data points and absolute values + // + // record the function f(x) + ad_vector ad_x(n), ad_y(m); + for(size_t j = 0; j < n; j++) + ad_x[j] = double(j + 1); + Independent( ad_x ); + AD sum = 0.0; + sum += ad_x[0] * ad_x[0] / 2.0 + abs( ad_x[0] - 5 ); + sum += ad_x[1] * ad_x[1] / 2.0 + abs( ad_x[1] + 5 ); + ad_y[0] = sum; + ADFun f(ad_x, ad_y); + + // create its abs_normal representation in g, a + ADFun g, a; + f.abs_normal_fun(g, a); + + // check dimension of domain and range space for g + ok &= g.Domain() == n + s; + ok &= g.Range() == m + s; + + // check dimension of domain and range space for a + ok &= a.Domain() == n; + ok &= a.Range() == s; + + // -------------------------------------------------------------------- + // Choose the point x_hat = 0 + d_vector x_hat(n); + for(size_t j = 0; j < n; j++) + x_hat[j] = 0.0; + + // value of a_hat = a(x_hat) + d_vector a_hat = a.Forward(0, x_hat); + + // (x_hat, a_hat) + d_vector xu_hat = join(x_hat, a_hat); + + // value of g[ x_hat, a_hat ] + d_vector g_hat = g.Forward(0, xu_hat); + + // Jacobian of g[ x_hat, a_hat ] + d_vector g_jac = g.Jacobian(xu_hat); + + // trust region bound + d_vector bound(n); + for(size_t j = 0; j < n; j++) + bound[j] = 10.0; + + // convergence criteria + d_vector epsilon(2); + double eps99 = 99.0 * std::numeric_limits::epsilon(); + epsilon[0] = eps99; + epsilon[1] = eps99; + + // maximum number of iterations + s_vector maxitr(2); + maxitr[0] = 10; // maximum number of abs_min_quad iterations + maxitr[1] = 35; // maximum number of qp_interior iterations + + // set Hessian equal to identity matrix I + d_vector hessian(n * n); + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n; j++) + hessian[i * n + j] = 0.0; + hessian[i * n + i] = 1.0; + } + + // minimize the approxiamtion for f (which is equal to f for this case) + d_vector delta_x(n); + ok &= CppAD::abs_min_quad( + level, n, m, s, + g_hat, g_jac, hessian, bound, epsilon, maxitr, delta_x + ); + + // check that the solution + ok &= CppAD::NearEqual( delta_x[0], +1.0, eps99, eps99 ); + ok &= CppAD::NearEqual( delta_x[1], -1.0, eps99, eps99 ); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/abs_min_quad.hpp cppad-2019.02.00.0/example/abs_normal/abs_min_quad.hpp --- cppad-2018.00.00.0/example/abs_normal/abs_min_quad.hpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/abs_min_quad.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,33 +3,34 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin abs_min_quad$$ $spell - hpp - qp - jac - Jacobian - maxitr + hpp + qp + jac + Jacobian + maxitr $$ $section abs_normal: Minimize a Linear Abs-normal Approximation$$ $head Syntax$$ $icode%ok% = abs_min_quad( - %level%, %n%, %m%, %s%, - %g_hat%, %g_jac%, %hessian%, %bound%, %epsilon%, %maxitr%, %delta_x% + %level%, %n%, %m%, %s%, + %g_hat%, %g_jac%, %hessian%, %bound%, %epsilon%, %maxitr%, %delta_x% )%$$ $head Prototype$$ $srcfile%example/abs_normal/abs_min_quad.hpp% - 0%// BEGIN PROTOTYPE%// END PROTOTYPE% + 0%// BEGIN PROTOTYPE%// END PROTOTYPE% 1%$$ $head Source$$ @@ -40,9 +41,9 @@ We are given a point $latex \hat{x} \in \B{R}^n$$ and use the notation $latex \tilde{f} (x)$$ for the abs-normal $cref/approximation for f(x) - /abs_normal_fun - /Abs-normal Approximation - /Approximating f(x) + /abs_normal_fun + /Abs-normal Approximation + /Approximating f(x) /$$ near $latex \hat{x}$$. We are also given a vector $latex b \in \B{R}_+^n$$ @@ -51,8 +52,8 @@ $latex \[ \begin{array}{lll} \R{minimize} & - \Delta x^T H \Delta x / 2 + \tilde{f}( \hat{x} + \Delta x ) & - \R{w.r.t} \; \Delta x \in \B{R}^n + \Delta x^T H \Delta x / 2 + \tilde{f}( \hat{x} + \Delta x ) & + \R{w.r.t} \; \Delta x \in \B{R}^n \\ \R{subject \; to} & | \Delta x_j | \leq b_j & j = 0 , \ldots , n-1 \end{array} @@ -113,7 +114,7 @@ This vector has size $icode n$$ and is the vector $latex b \in \B{R}^n$$. The trust region is defined as the set of $latex \Delta x$$ such that $latex \[ - | \Delta x | \leq b_j + | \Delta x | \leq b_j \]$$ for $latex j = 0 , \ldots , n-1$$. @@ -124,7 +125,7 @@ The value $icode%epsilon%[1]%$$ is convergence criteria in terms of the derivative of the objective; i.e. $latex \[ - \Delta x^T H \Delta x / 2 + \tilde{f}( \hat{x} + \Delta x) + \Delta x^T H \Delta x / 2 + \tilde{f}( \hat{x} + \Delta x) \] $$ $head maxitr$$ @@ -145,7 +146,7 @@ $subhead sigma$$ We use the notation $latex \[ - \sigma (x) = \R{sign} ( z[ x , a(x) ] ) + \sigma (x) = \R{sign} ( z[ x , a(x) ] ) \] $$ where $cref/a(x)/abs_normal_fun/a/a(x)/$$ and @@ -165,7 +166,7 @@ \begin{array}{lll} \R{minimize} & \Delta x^T H \Delta x / 2 + - \max \{ p_k ( \hat{x} + \Delta x) \W{:} k = 0 , \ldots , K-1 \} + \max \{ p_k ( \hat{x} + \Delta x) \W{:} k = 0 , \ldots , K-1 \} & \R{w.r.t} \; \Delta x \\ \R{subject \; to} & - b \leq \Delta x \leq + b @@ -179,12 +180,11 @@ $children%example/abs_normal/abs_min_quad.cpp - %example/abs_normal/abs_min_quad.omh + %example/abs_normal/abs_min_quad.omh %$$ $head Example$$ The file $cref abs_min_quad.cpp$$ contains an example and test of $code abs_min_quad$$. -It returns true if the test passes and false otherwise. $end ----------------------------------------------------------------------------- @@ -199,290 +199,290 @@ // BEGIN PROTOTYPE template bool abs_min_quad( - size_t level , - size_t n , - size_t m , - size_t s , - const DblVector& g_hat , - const DblVector& g_jac , - const DblVector& hessian , - const DblVector& bound , - const DblVector& epsilon , - const SizeVector& maxitr , - DblVector& delta_x ) + size_t level , + size_t n , + size_t m , + size_t s , + const DblVector& g_hat , + const DblVector& g_jac , + const DblVector& hessian , + const DblVector& bound , + const DblVector& epsilon , + const SizeVector& maxitr , + DblVector& delta_x ) // END PROTOTYPE -{ using std::fabs; - bool ok = true; - double inf = std::numeric_limits::infinity(); - // - CPPAD_ASSERT_KNOWN( - level <= 4, - "abs_min_quad: level is not less that or equal 3" - ); - CPPAD_ASSERT_KNOWN( - size_t(epsilon.size()) == 2, - "abs_min_quad: size of epsilon not equal to 2" - ); - CPPAD_ASSERT_KNOWN( - size_t(maxitr.size()) == 2, - "abs_min_quad: size of maxitr not equal to 2" - ); - CPPAD_ASSERT_KNOWN( - m == 1, - "abs_min_quad: m is not equal to 1" - ); - CPPAD_ASSERT_KNOWN( - size_t(delta_x.size()) == n, - "abs_min_quad: size of delta_x not equal to n" - ); - CPPAD_ASSERT_KNOWN( - size_t(bound.size()) == n, - "abs_min_quad: size of bound not equal to n" - ); - CPPAD_ASSERT_KNOWN( - size_t(g_hat.size()) == m + s, - "abs_min_quad: size of g_hat not equal to m + s" - ); - CPPAD_ASSERT_KNOWN( - size_t(g_jac.size()) == (m + s) * (n + s), - "abs_min_quad: size of g_jac not equal to (m + s)*(n + s)" - ); - CPPAD_ASSERT_KNOWN( - size_t(hessian.size()) == n * n, - "abs_min_quad: size of hessian not equal to n * n" - ); - CPPAD_ASSERT_KNOWN( - size_t(bound.size()) == n, - "abs_min_quad: size of bound is not equal to n" - ); - if( level > 0 ) - { std::cout << "start abs_min_quad\n"; - CppAD::abs_print_mat("g_hat", m + s, 1, g_hat); - CppAD::abs_print_mat("g_jac", m + s, n + s, g_jac); - CppAD::abs_print_mat("hessian", n, n, hessian); - CppAD::abs_print_mat("bound", n, 1, bound); - } - // partial y(x, u) w.r.t x (J in reference) - DblVector py_px(n); - for(size_t j = 0; j < n; j++) - py_px[ j ] = g_jac[ j ]; - // - // partial y(x, u) w.r.t u (Y in reference) - DblVector py_pu(s); - for(size_t j = 0; j < s; j++) - py_pu[ j ] = g_jac[ n + j ]; - // - // partial z(x, u) w.r.t x (Z in reference) - DblVector pz_px(s * n); - for(size_t i = 0; i < s; i++) - { for(size_t j = 0; j < n; j++) - { pz_px[ i * n + j ] = g_jac[ (n + s) * (i + m) + j ]; - } - } - // partial z(x, u) w.r.t u (L in reference) - DblVector pz_pu(s * s); - for(size_t i = 0; i < s; i++) - { for(size_t j = 0; j < s; j++) - { pz_pu[ i * s + j ] = g_jac[ (n + s) * (i + m) + n + j ]; - } - } - // initailize delta_x - for(size_t j = 0; j < n; j++) - delta_x[j] = 0.0; - // - // current set of cutting planes - DblVector C(maxitr[0] * n), c(maxitr[0]); - // - // value of abs-normal approximation at x_hat + delta_x - DblVector g_tilde = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_x); - // - // value of sigma at delta_x = 0; i.e., sign( z(x, u) ) - CppAD::vector sigma(s); - for(size_t i = 0; i < s; i++) - sigma[i] = CppAD::sign( g_tilde[m + i] ); - // - // initial value of the objective - double obj_cur = g_tilde[0]; - // - // initial number of cutting planes - size_t n_plane = 0; - // - if( level > 0 ) - { std::cout << "obj = " << obj_cur << "\n"; - CppAD::abs_print_mat("delta_x", n, 1, delta_x); - } - for(size_t itr = 0; itr < maxitr[0]; itr++) - { - // Equation (5), Propostion 3.1 of reference - // dy_dx = py_px + py_pu * Sigma * (I - pz_pu * Sigma)^-1 * pz_px - // - // tmp_ss = I - pz_pu * Sigma - DblVector tmp_ss(s * s); - for(size_t i = 0; i < s; i++) - { for(size_t j = 0; j < s; j++) - tmp_ss[i * s + j] = - pz_pu[i * s + j] * sigma[j]; - tmp_ss[i * s + i] += 1.0; - } - // tmp_sn = (I - pz_pu * Sigma)^-1 * pz_px - double logdet; - DblVector tmp_sn(s * n); - LuSolve(s, n, tmp_ss, pz_px, tmp_sn, logdet); - // - // tmp_sn = Sigma * (I - pz_pu * Sigma)^-1 * pz_px - for(size_t i = 0; i < s; i++) - { for(size_t j = 0; j < n; j++) - tmp_sn[i * n + j] *= sigma[i]; - } - // dy_dx = py_px + py_pu * Sigma * (I - pz_pu * Sigma)^-1 * pz_px - DblVector dy_dx(n); - for(size_t j = 0; j < n; j++) - { dy_dx[j] = py_px[j]; - for(size_t k = 0; k < s; k++) - dy_dx[j] += py_pu[k] * tmp_sn[ k * n + j]; - } - // - // compute derivative of the quadratic term - DblVector dq_dx(n); - for(size_t j = 0; j < n; j++) - { dq_dx[j] = 0.0; - for(size_t i = 0; i < n; i++) - dq_dx[j] += delta_x[i] * hessian[i * n + j]; - } - // - // check for case where derivative of objective is zero - // (in convex case, this is the minimizer) - bool near_zero = true; - for(size_t j = 0; j < n; j++) - near_zero &= std::fabs( dq_dx[j] + dy_dx[j] ) < epsilon[1]; - if( near_zero ) - { if( level > 0 ) - std::cout << "end abs_min_quad: local derivative near zero\n"; - return true; - } - // value of hyperplane at delta_x - double plane_at_zero = g_tilde[0]; - // - // value of hyperplane at 0 - for(size_t j = 0; j < n; j++) - plane_at_zero -= dy_dx[j] * delta_x[j]; - // - // add a cutting plane with value g_tilde[0] at delta_x - // and derivative dy_dx - c[n_plane] = plane_at_zero; - for(size_t j = 0; j < n; j++) - C[n_plane * n + j] = dy_dx[j]; - ++n_plane; - // - // variables for cutting plane problem are (dx, w) - // c[i] + C[i,:] * dx <= w - DblVector c_box(n_plane), C_box(n_plane * (n + 1)); - for(size_t i = 0; i < n_plane; i++) - { c_box[i] = c[i]; - for(size_t j = 0; j < n; j++) - C_box[i * (n+1) + j] = C[i * n + j]; - C_box[i * (n+1) + n] = -1.0; - } - // - // w is the objective - DblVector g_box(n + 1); - for(size_t i = 0; i < size_t(c_box.size()); i++) - g_box[i] = 0.0; - g_box[n] = 1.0; - // - // a_box, b_box - DblVector a_box(n+1), b_box(n+1); - for(size_t j = 0; j < n; j++) - { a_box[j] = - bound[j]; - b_box[j] = + bound[j]; - } - a_box[n] = - inf; - b_box[n] = + inf; - // - // initial delta_x in qp_box is zero - DblVector xin_box(n + 1); - for(size_t j = 0; j < n; j++) - xin_box[j] = 0.0; - // initial w in qp_box is 1 + max_i c[i] - xin_box[n] = 1.0 + c_box[0]; - for(size_t i = 1; i < n_plane; i++) - xin_box[n] = std::max( xin_box[n], 1.0 + c_box[i] ); - // - DblVector hessian_box( (n+1) * (n+1) ); - for(size_t i = 0; i < n+1; i++) - { for(size_t j = 0; j < n+1; j++) - { if( i == n || j == n ) - hessian_box[i * (n+1) + j] = 0.0; - else - hessian_box[i * (n+1) + j] = hessian[i * n + j]; - } - } - // - // solve the cutting plane problem - DblVector xout_box(n + 1); - size_t level_box = 0; - if( level > 0 ) - level_box = level - 1; - ok &= CppAD::qp_box( - level_box, - a_box, - b_box, - c_box, - C_box, - g_box, - hessian_box, - epsilon[1], - maxitr[1], - xin_box, - xout_box - ); - if( ! ok ) - { if( level > 0 ) - { CppAD::abs_print_mat("delta_x", n, 1, delta_x); - std::cout << "end abs_min_quad: qp_box failed\n"; - } - return false; - } - DblVector delta_new(n); - for(size_t j = 0; j < n; j++) - delta_new[j] = xout_box[j]; - // - // check for convergence - double max_diff = 0.0; - for(size_t j = 0; j < n; j++) - { double diff = delta_x[j] - delta_new[j]; - max_diff = std::max( max_diff, std::fabs(diff) ); - } - // - // new value of the objective - DblVector g_new = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_new); - double obj_new = g_new[0]; - for(size_t i = 0; i < n; i++) - { for(size_t j = 0; j < n; j++) - obj_new += delta_new[i] * hessian[i * n + j] * delta_new[j]; - } - g_tilde = g_new; - obj_cur = obj_new; - delta_x = delta_new; - // - if( level > 0 ) - { std::cout << "itr = " << itr << ", max_diff = " << max_diff - << ", obj_cur = " << obj_cur << "\n"; - CppAD::abs_print_mat("delta_x", n, 1, delta_x); - } - // - // value of sigma at new delta_x; i.e., sign( z(x, u) ) - for(size_t i = 0; i < s; i++) - sigma[i] = CppAD::sign( g_tilde[m + i] ); - // - if( max_diff < epsilon[0] ) - { if( level > 0 ) - std::cout << "end abs_min_quad: change in delta_x near zero\n"; - return true; - } - } - if( level > 0 ) - std::cout << "end abs_min_quad: maximum number of iterations exceeded\n"; - return false; +{ using std::fabs; + bool ok = true; + double inf = std::numeric_limits::infinity(); + // + CPPAD_ASSERT_KNOWN( + level <= 4, + "abs_min_quad: level is not less that or equal 3" + ); + CPPAD_ASSERT_KNOWN( + size_t(epsilon.size()) == 2, + "abs_min_quad: size of epsilon not equal to 2" + ); + CPPAD_ASSERT_KNOWN( + size_t(maxitr.size()) == 2, + "abs_min_quad: size of maxitr not equal to 2" + ); + CPPAD_ASSERT_KNOWN( + m == 1, + "abs_min_quad: m is not equal to 1" + ); + CPPAD_ASSERT_KNOWN( + size_t(delta_x.size()) == n, + "abs_min_quad: size of delta_x not equal to n" + ); + CPPAD_ASSERT_KNOWN( + size_t(bound.size()) == n, + "abs_min_quad: size of bound not equal to n" + ); + CPPAD_ASSERT_KNOWN( + size_t(g_hat.size()) == m + s, + "abs_min_quad: size of g_hat not equal to m + s" + ); + CPPAD_ASSERT_KNOWN( + size_t(g_jac.size()) == (m + s) * (n + s), + "abs_min_quad: size of g_jac not equal to (m + s)*(n + s)" + ); + CPPAD_ASSERT_KNOWN( + size_t(hessian.size()) == n * n, + "abs_min_quad: size of hessian not equal to n * n" + ); + CPPAD_ASSERT_KNOWN( + size_t(bound.size()) == n, + "abs_min_quad: size of bound is not equal to n" + ); + if( level > 0 ) + { std::cout << "start abs_min_quad\n"; + CppAD::abs_print_mat("g_hat", m + s, 1, g_hat); + CppAD::abs_print_mat("g_jac", m + s, n + s, g_jac); + CppAD::abs_print_mat("hessian", n, n, hessian); + CppAD::abs_print_mat("bound", n, 1, bound); + } + // partial y(x, u) w.r.t x (J in reference) + DblVector py_px(n); + for(size_t j = 0; j < n; j++) + py_px[ j ] = g_jac[ j ]; + // + // partial y(x, u) w.r.t u (Y in reference) + DblVector py_pu(s); + for(size_t j = 0; j < s; j++) + py_pu[ j ] = g_jac[ n + j ]; + // + // partial z(x, u) w.r.t x (Z in reference) + DblVector pz_px(s * n); + for(size_t i = 0; i < s; i++) + { for(size_t j = 0; j < n; j++) + { pz_px[ i * n + j ] = g_jac[ (n + s) * (i + m) + j ]; + } + } + // partial z(x, u) w.r.t u (L in reference) + DblVector pz_pu(s * s); + for(size_t i = 0; i < s; i++) + { for(size_t j = 0; j < s; j++) + { pz_pu[ i * s + j ] = g_jac[ (n + s) * (i + m) + n + j ]; + } + } + // initailize delta_x + for(size_t j = 0; j < n; j++) + delta_x[j] = 0.0; + // + // current set of cutting planes + DblVector C(maxitr[0] * n), c(maxitr[0]); + // + // value of abs-normal approximation at x_hat + delta_x + DblVector g_tilde = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_x); + // + // value of sigma at delta_x = 0; i.e., sign( z(x, u) ) + CppAD::vector sigma(s); + for(size_t i = 0; i < s; i++) + sigma[i] = CppAD::sign( g_tilde[m + i] ); + // + // initial value of the objective + double obj_cur = g_tilde[0]; + // + // initial number of cutting planes + size_t n_plane = 0; + // + if( level > 0 ) + { std::cout << "obj = " << obj_cur << "\n"; + CppAD::abs_print_mat("delta_x", n, 1, delta_x); + } + for(size_t itr = 0; itr < maxitr[0]; itr++) + { + // Equation (5), Propostion 3.1 of reference + // dy_dx = py_px + py_pu * Sigma * (I - pz_pu * Sigma)^-1 * pz_px + // + // tmp_ss = I - pz_pu * Sigma + DblVector tmp_ss(s * s); + for(size_t i = 0; i < s; i++) + { for(size_t j = 0; j < s; j++) + tmp_ss[i * s + j] = - pz_pu[i * s + j] * sigma[j]; + tmp_ss[i * s + i] += 1.0; + } + // tmp_sn = (I - pz_pu * Sigma)^-1 * pz_px + double logdet; + DblVector tmp_sn(s * n); + LuSolve(s, n, tmp_ss, pz_px, tmp_sn, logdet); + // + // tmp_sn = Sigma * (I - pz_pu * Sigma)^-1 * pz_px + for(size_t i = 0; i < s; i++) + { for(size_t j = 0; j < n; j++) + tmp_sn[i * n + j] *= sigma[i]; + } + // dy_dx = py_px + py_pu * Sigma * (I - pz_pu * Sigma)^-1 * pz_px + DblVector dy_dx(n); + for(size_t j = 0; j < n; j++) + { dy_dx[j] = py_px[j]; + for(size_t k = 0; k < s; k++) + dy_dx[j] += py_pu[k] * tmp_sn[ k * n + j]; + } + // + // compute derivative of the quadratic term + DblVector dq_dx(n); + for(size_t j = 0; j < n; j++) + { dq_dx[j] = 0.0; + for(size_t i = 0; i < n; i++) + dq_dx[j] += delta_x[i] * hessian[i * n + j]; + } + // + // check for case where derivative of objective is zero + // (in convex case, this is the minimizer) + bool near_zero = true; + for(size_t j = 0; j < n; j++) + near_zero &= std::fabs( dq_dx[j] + dy_dx[j] ) < epsilon[1]; + if( near_zero ) + { if( level > 0 ) + std::cout << "end abs_min_quad: local derivative near zero\n"; + return true; + } + // value of hyperplane at delta_x + double plane_at_zero = g_tilde[0]; + // + // value of hyperplane at 0 + for(size_t j = 0; j < n; j++) + plane_at_zero -= dy_dx[j] * delta_x[j]; + // + // add a cutting plane with value g_tilde[0] at delta_x + // and derivative dy_dx + c[n_plane] = plane_at_zero; + for(size_t j = 0; j < n; j++) + C[n_plane * n + j] = dy_dx[j]; + ++n_plane; + // + // variables for cutting plane problem are (dx, w) + // c[i] + C[i,:] * dx <= w + DblVector c_box(n_plane), C_box(n_plane * (n + 1)); + for(size_t i = 0; i < n_plane; i++) + { c_box[i] = c[i]; + for(size_t j = 0; j < n; j++) + C_box[i * (n+1) + j] = C[i * n + j]; + C_box[i * (n+1) + n] = -1.0; + } + // + // w is the objective + DblVector g_box(n + 1); + for(size_t i = 0; i < size_t(c_box.size()); i++) + g_box[i] = 0.0; + g_box[n] = 1.0; + // + // a_box, b_box + DblVector a_box(n+1), b_box(n+1); + for(size_t j = 0; j < n; j++) + { a_box[j] = - bound[j]; + b_box[j] = + bound[j]; + } + a_box[n] = - inf; + b_box[n] = + inf; + // + // initial delta_x in qp_box is zero + DblVector xin_box(n + 1); + for(size_t j = 0; j < n; j++) + xin_box[j] = 0.0; + // initial w in qp_box is 1 + max_i c[i] + xin_box[n] = 1.0 + c_box[0]; + for(size_t i = 1; i < n_plane; i++) + xin_box[n] = std::max( xin_box[n], 1.0 + c_box[i] ); + // + DblVector hessian_box( (n+1) * (n+1) ); + for(size_t i = 0; i < n+1; i++) + { for(size_t j = 0; j < n+1; j++) + { if( i == n || j == n ) + hessian_box[i * (n+1) + j] = 0.0; + else + hessian_box[i * (n+1) + j] = hessian[i * n + j]; + } + } + // + // solve the cutting plane problem + DblVector xout_box(n + 1); + size_t level_box = 0; + if( level > 0 ) + level_box = level - 1; + ok &= CppAD::qp_box( + level_box, + a_box, + b_box, + c_box, + C_box, + g_box, + hessian_box, + epsilon[1], + maxitr[1], + xin_box, + xout_box + ); + if( ! ok ) + { if( level > 0 ) + { CppAD::abs_print_mat("delta_x", n, 1, delta_x); + std::cout << "end abs_min_quad: qp_box failed\n"; + } + return false; + } + DblVector delta_new(n); + for(size_t j = 0; j < n; j++) + delta_new[j] = xout_box[j]; + // + // check for convergence + double max_diff = 0.0; + for(size_t j = 0; j < n; j++) + { double diff = delta_x[j] - delta_new[j]; + max_diff = std::max( max_diff, std::fabs(diff) ); + } + // + // new value of the objective + DblVector g_new = CppAD::abs_eval(n, m, s, g_hat, g_jac, delta_new); + double obj_new = g_new[0]; + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n; j++) + obj_new += delta_new[i] * hessian[i * n + j] * delta_new[j]; + } + g_tilde = g_new; + obj_cur = obj_new; + delta_x = delta_new; + // + if( level > 0 ) + { std::cout << "itr = " << itr << ", max_diff = " << max_diff + << ", obj_cur = " << obj_cur << "\n"; + CppAD::abs_print_mat("delta_x", n, 1, delta_x); + } + // + // value of sigma at new delta_x; i.e., sign( z(x, u) ) + for(size_t i = 0; i < s; i++) + sigma[i] = CppAD::sign( g_tilde[m + i] ); + // + if( max_diff < epsilon[0] ) + { if( level > 0 ) + std::cout << "end abs_min_quad: change in delta_x near zero\n"; + return true; + } + } + if( level > 0 ) + std::cout << "end abs_min_quad: maximum number of iterations exceeded\n"; + return false; } } // END_CPPAD_NAMESPACE // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/abs_min_quad.omh cppad-2019.02.00.0/example/abs_normal/abs_min_quad.omh --- cppad-2018.00.00.0/example/abs_normal/abs_min_quad.omh 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/abs_min_quad.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin abs_min_quad.hpp$$ $spell @@ -15,7 +16,7 @@ $section abs_min_quad Source Code$$ $srcfile%example/abs_normal/abs_min_quad.hpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 0%$$ $end diff -Nru cppad-2018.00.00.0/example/abs_normal/abs_normal.cpp cppad-2019.02.00.0/example/abs_normal/abs_normal.cpp --- cppad-2018.00.00.0/example/abs_normal/abs_normal.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/abs_normal.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // CPPAD_HAS_* defines # include @@ -38,28 +39,28 @@ // main program that runs all the tests int main(void) -{ std::string group = "example/abs_norml"; - size_t width = 20; - CppAD::test_boolofvoid Run(group, width); - - // This line is used by test_one.sh - - // external compiled tests - Run( abs_eval, "abs_eval" ); - Run( abs_min_linear, "abs_min_linear" ); - Run( abs_min_quad, "abs_min_quad" ); - Run( get_started, "get_started" ); - Run( lp_box, "lp_box" ); - Run( min_nso_linear, "min_nso_linear" ); - Run( min_nso_quad, "min_nso_quad" ); - Run( qp_box, "qp_box" ); - Run( qp_interior, "qp_interior" ); - Run( simplex_method, "simplex_method" ); - - // check for memory leak - bool memory_ok = CppAD::thread_alloc::free_all(); - // print summary at end - bool ok = Run.summary(memory_ok); - // - return static_cast( ! ok ); +{ std::string group = "example/abs_norml"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + // external compiled tests + Run( abs_eval, "abs_eval" ); + Run( abs_min_linear, "abs_min_linear" ); + Run( abs_min_quad, "abs_min_quad" ); + Run( get_started, "get_started" ); + Run( lp_box, "lp_box" ); + Run( min_nso_linear, "min_nso_linear" ); + Run( min_nso_quad, "min_nso_quad" ); + Run( qp_box, "qp_box" ); + Run( qp_interior, "qp_interior" ); + Run( simplex_method, "simplex_method" ); + + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); } diff -Nru cppad-2018.00.00.0/example/abs_normal/abs_normal.omh cppad-2019.02.00.0/example/abs_normal/abs_normal.omh --- cppad-2018.00.00.0/example/abs_normal/abs_normal.omh 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/abs_normal.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin abs_normal$$ $spell - Andreas Griewank - Jens-Uwe Bernt - Manuel Radons - Tom Streubel + Andreas Griewank + Jens-Uwe Bernt + Manuel Radons + Tom Streubel $$ $section Abs-normal Representation of Non-Smooth Functions$$ @@ -24,17 +25,17 @@ Linear Algebra and its Applications, vol. 471 (2015), pages 500-530. -$childtable%cppad/core/abs_normal_fun.hpp - %example/abs_normal/abs_print_mat.hpp - %example/abs_normal/abs_eval.hpp - %example/abs_normal/simplex_method.hpp - %example/abs_normal/lp_box.hpp - %example/abs_normal/abs_min_linear.hpp - %example/abs_normal/min_nso_linear.hpp - %example/abs_normal/qp_interior.hpp - %example/abs_normal/qp_box.hpp - %example/abs_normal/abs_min_quad.hpp - %example/abs_normal/min_nso_quad.hpp +$childtable%include/cppad/core/abs_normal_fun.hpp + %example/abs_normal/abs_print_mat.hpp + %example/abs_normal/abs_eval.hpp + %example/abs_normal/simplex_method.hpp + %example/abs_normal/lp_box.hpp + %example/abs_normal/abs_min_linear.hpp + %example/abs_normal/min_nso_linear.hpp + %example/abs_normal/qp_interior.hpp + %example/abs_normal/qp_box.hpp + %example/abs_normal/abs_min_quad.hpp + %example/abs_normal/min_nso_quad.hpp %$$ $end diff -Nru cppad-2018.00.00.0/example/abs_normal/abs_print_mat.hpp cppad-2019.02.00.0/example/abs_normal/abs_print_mat.hpp --- cppad-2018.00.00.0/example/abs_normal/abs_print_mat.hpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/abs_print_mat.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,19 +3,20 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin abs_print_mat$$ $spell - nr - nc - std::cout + nr + nc + std::cout $$ $section abs_normal: Print a Vector or Matrix$$ @@ -24,7 +25,7 @@ $head Prototype$$ $srcfile%example/abs_normal/abs_print_mat.hpp% - 0%// BEGIN PROTOTYPE%// END PROTOTYPE% + 0%// BEGIN PROTOTYPE%// END PROTOTYPE% 1%$$ @@ -50,7 +51,7 @@ of the matrix (hence a $cref SimpleVector$$). The syntax $codei% - std::cout << %mat%[%i%]% + std::cout << %mat%[%i%]% %$$ must output the $th i$$ element of the simple vector $icode mat$$. @@ -64,54 +65,54 @@ // BEGIN PROTOTYPE template void abs_print_mat( - const std::string& name , - size_t nr , - size_t nc , - const Vector& mat ) + const std::string& name , + size_t nr , + size_t nc , + const Vector& mat ) // END PROTOTYPE { - CPPAD_ASSERT_KNOWN( - size_t(mat.size()) == nr * nc, - "abs_print_mat: size of mat is not nr * nc" - ); - // output name - std::cout << name << " ="; - // - // handel empty case - if( nr == 0 || nc == 0 ) - { std::cout << " " << nr << " by " << nc << " empty matrix\n"; - return; - } - // - // handle vector case - if( nr == 1 || nc == 1 ) - { std::cout << " ["; - for(size_t i = 0; i < nr * nc; i++) - { if( i > 0 ) - std::cout << ", "; - std::cout << mat[i]; - } - std::cout << "]"; - // - // column vectors are printed as row vectors with a transpose at end - if( nr > 1 ) - std::cout << "^T"; - // - std::cout << "\n"; - return; - } - // non-empty matrix - std::cout << "\n"; - for(size_t i = 0; i < nr; i++) - { std::cout << "["; - for(size_t j = 0; j < nc; j++) - { if( j > 0 ) - std::cout << ", "; - std::cout << mat[i * nc + j]; - } - std::cout << "]\n"; - } - return; + CPPAD_ASSERT_KNOWN( + size_t(mat.size()) == nr * nc, + "abs_print_mat: size of mat is not nr * nc" + ); + // output name + std::cout << name << " ="; + // + // handel empty case + if( nr == 0 || nc == 0 ) + { std::cout << " " << nr << " by " << nc << " empty matrix\n"; + return; + } + // + // handle vector case + if( nr == 1 || nc == 1 ) + { std::cout << " ["; + for(size_t i = 0; i < nr * nc; i++) + { if( i > 0 ) + std::cout << ", "; + std::cout << mat[i]; + } + std::cout << "]"; + // + // column vectors are printed as row vectors with a transpose at end + if( nr > 1 ) + std::cout << "^T"; + // + std::cout << "\n"; + return; + } + // non-empty matrix + std::cout << "\n"; + for(size_t i = 0; i < nr; i++) + { std::cout << "["; + for(size_t j = 0; j < nc; j++) + { if( j > 0 ) + std::cout << ", "; + std::cout << mat[i * nc + j]; + } + std::cout << "]\n"; + } + return; } } // END_CPPAD_NAMESPACE diff -Nru cppad-2018.00.00.0/example/abs_normal/CMakeLists.txt cppad-2019.02.00.0/example/abs_normal/CMakeLists.txt --- cppad-2018.00.00.0/example/abs_normal/CMakeLists.txt 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,28 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the example/print_for directory tests # SET(source_list - abs_eval.cpp - abs_min_linear.cpp - abs_min_quad.cpp - abs_normal.cpp - get_started.cpp - lp_box.cpp - min_nso_linear.cpp - min_nso_quad.cpp - qp_box.cpp - qp_interior.cpp - simplex_method.cpp + abs_eval.cpp + abs_min_linear.cpp + abs_min_quad.cpp + abs_normal.cpp + get_started.cpp + lp_box.cpp + min_nso_linear.cpp + min_nso_quad.cpp + qp_box.cpp + qp_interior.cpp + simplex_method.cpp ) # set_compile_flags( example_abs_normal "${cppad_debug_which}" "${source_list}" ) @@ -30,9 +31,9 @@ # check_example_abs_normal target ADD_CUSTOM_TARGET(check_example_abs_normal - example_abs_normal - DEPENDS - example_abs_normal + example_abs_normal + DEPENDS + example_abs_normal ) MESSAGE(STATUS "make check_example_abs_normal: available") diff -Nru cppad-2018.00.00.0/example/abs_normal/get_started.cpp cppad-2019.02.00.0/example/abs_normal/get_started.cpp --- cppad-2018.00.00.0/example/abs_normal/get_started.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/get_started.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin abs_get_started.cpp$$ @@ -18,24 +19,24 @@ Creates an $cref abs_normal$$ representation $latex g$$ for the function $latex f : \B{R}^3 \rightarrow \B{R}$$ defined by $latex \[ - f( x_0, x_1, x_2 ) = | x_0 + x_1 | + | x_1 + x_2 | + f( x_0, x_1, x_2 ) = | x_0 + x_1 | + | x_1 + x_2 | \] $$ The corresponding $cref/g/abs_normal_fun/g/$$ $latex : \B{R}^5 \rightarrow \B{R}^3$$ is given by $latex \[ \begin{array}{rclrcl} - g_0 ( x_0, x_1, x_2, u_0, u_1 ) & = & u_0 + u_1 & = & y_0 (x, u) - \\ - g_1 ( x_0, x_1, x_2, u_0, u_1 ) & = & x_0 + x_1 & = & z_0 (x, u) - \\ - g_1 ( x_0, x_1, x_2, u_0, u_1 ) & = & x_1 + x_2 & = & z_1 (x, u) + g_0 ( x_0, x_1, x_2, u_0, u_1 ) & = & u_0 + u_1 & = & y_0 (x, u) + \\ + g_1 ( x_0, x_1, x_2, u_0, u_1 ) & = & x_0 + x_1 & = & z_0 (x, u) + \\ + g_1 ( x_0, x_1, x_2, u_0, u_1 ) & = & x_1 + x_2 & = & z_1 (x, u) \end{array} \] $$ $head Source$$ $srcfile%example/abs_normal/get_started.cpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 1%$$ $end @@ -44,93 +45,93 @@ // BEGIN C++ # include namespace { - CPPAD_TESTVECTOR(double) join( - const CPPAD_TESTVECTOR(double)& x , - const CPPAD_TESTVECTOR(double)& u ) - { size_t n = x.size(); - size_t s = u.size(); - CPPAD_TESTVECTOR(double) xu(n + s); - for(size_t j = 0; j < n; j++) - xu[j] = x[j]; - for(size_t j = 0; j < s; j++) - xu[n + j] = u[j]; - return xu; - } + CPPAD_TESTVECTOR(double) join( + const CPPAD_TESTVECTOR(double)& x , + const CPPAD_TESTVECTOR(double)& u ) + { size_t n = x.size(); + size_t s = u.size(); + CPPAD_TESTVECTOR(double) xu(n + s); + for(size_t j = 0; j < n; j++) + xu[j] = x[j]; + for(size_t j = 0; j < s; j++) + xu[n + j] = u[j]; + return xu; + } } bool get_started(void) -{ bool ok = true; - // - using CppAD::AD; - using CppAD::ADFun; - // - size_t n = 3; // size of x - size_t m = 1; // size of y - size_t s = 2; // size of u and z - // - // record the function f(x) - CPPAD_TESTVECTOR( AD ) ax(n), ay(m); - for(size_t j = 0; j < n; j++) - ax[j] = double(j + 1); - Independent( ax ); - // for this example, we ensure first absolute value is | x_0 + x_1 | - AD a0 = abs( ax[0] + ax[1] ); - // and second absolute value is | x_1 + x_2 | - AD a1 = abs( ax[1] + ax[2] ); - ay[0] = a0 + a1; - ADFun f(ax, ay); - - // create its abs_normal representation in g, a - ADFun g, a; - f.abs_normal_fun(g, a); - - // check dimension of domain and range space for g - ok &= g.Domain() == n + s; - ok &= g.Range() == m + s; - - // check dimension of domain and range space for a - ok &= a.Domain() == n; - ok &= a.Range() == s; - - // -------------------------------------------------------------------- - // a(x) has all the operations used to compute f(x), but the sum of the - // absolute values is not needed for a(x), so optimize it out. - size_t n_op = f.size_op(); - ok &= a.size_op() == n_op; - a.optimize(); - ok &= a.size_op() < n_op; - - // -------------------------------------------------------------------- - // zero order forward mode calculation using g(x, u) - CPPAD_TESTVECTOR(double) x(n), u(s), xu(n+s), yz(m+s); - for(size_t j = 0; j < n; j++) - x[j] = double(j + 2); - for(size_t j = 0; j < s; j++) - u[j] = double(j + n + 2); - xu = join(x, u); - yz = g.Forward(0, xu); - - // check y_0(x, u) - double y0 = u[0] + u[1]; - ok &= y0 == yz[0]; - - // check z_0 (x, u) - double z0 = x[0] + x[1]; - ok &= z0 == yz[1]; - - // check z_1 (x, u) - double z1 = x[1] + x[2]; - ok &= z1 == yz[2]; - - - // -------------------------------------------------------------------- - // check that y(x, a(x) ) == f(x) - CPPAD_TESTVECTOR(double) y(m); - y = f.Forward(0, x); // y = f(x) - u = a.Forward(0, x); // u = a(x) - xu = join(x, u); // xu = ( x, a(x) ) - yz = g.Forward(0, xu); // yz = ( y(x, a(x)), z(x, a(x)) ) - ok &= yz[0] == y[0]; +{ bool ok = true; + // + using CppAD::AD; + using CppAD::ADFun; + // + size_t n = 3; // size of x + size_t m = 1; // size of y + size_t s = 2; // size of u and z + // + // record the function f(x) + CPPAD_TESTVECTOR( AD ) ax(n), ay(m); + for(size_t j = 0; j < n; j++) + ax[j] = double(j + 1); + Independent( ax ); + // for this example, we ensure first absolute value is | x_0 + x_1 | + AD a0 = abs( ax[0] + ax[1] ); + // and second absolute value is | x_1 + x_2 | + AD a1 = abs( ax[1] + ax[2] ); + ay[0] = a0 + a1; + ADFun f(ax, ay); + + // create its abs_normal representation in g, a + ADFun g, a; + f.abs_normal_fun(g, a); + + // check dimension of domain and range space for g + ok &= g.Domain() == n + s; + ok &= g.Range() == m + s; + + // check dimension of domain and range space for a + ok &= a.Domain() == n; + ok &= a.Range() == s; + + // -------------------------------------------------------------------- + // a(x) has all the operations used to compute f(x), but the sum of the + // absolute values is not needed for a(x), so optimize it out. + size_t n_op = f.size_op(); + ok &= a.size_op() == n_op; + a.optimize(); + ok &= a.size_op() < n_op; + + // -------------------------------------------------------------------- + // zero order forward mode calculation using g(x, u) + CPPAD_TESTVECTOR(double) x(n), u(s), xu(n+s), yz(m+s); + for(size_t j = 0; j < n; j++) + x[j] = double(j + 2); + for(size_t j = 0; j < s; j++) + u[j] = double(j + n + 2); + xu = join(x, u); + yz = g.Forward(0, xu); + + // check y_0(x, u) + double y0 = u[0] + u[1]; + ok &= y0 == yz[0]; + + // check z_0 (x, u) + double z0 = x[0] + x[1]; + ok &= z0 == yz[1]; + + // check z_1 (x, u) + double z1 = x[1] + x[2]; + ok &= z1 == yz[2]; + + + // -------------------------------------------------------------------- + // check that y(x, a(x) ) == f(x) + CPPAD_TESTVECTOR(double) y(m); + y = f.Forward(0, x); // y = f(x) + u = a.Forward(0, x); // u = a(x) + xu = join(x, u); // xu = ( x, a(x) ) + yz = g.Forward(0, xu); // yz = ( y(x, a(x)), z(x, a(x)) ) + ok &= yz[0] == y[0]; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/lp_box.cpp cppad-2019.02.00.0/example/abs_normal/lp_box.cpp --- cppad-2018.00.00.0/example/abs_normal/lp_box.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/lp_box.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,17 +1,18 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin lp_box.cpp$$ $spell - lp + lp $$ $section abs_normal lp_box: Example and Test$$ @@ -27,7 +28,7 @@ $head Source$$ $srcfile%example/abs_normal/lp_box.cpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 1%$$ $end @@ -38,28 +39,28 @@ # include "lp_box.hpp" bool lp_box(void) -{ bool ok = true; - typedef CppAD::vector vector; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - // - size_t n = 2; - size_t m = 0; - vector A(m), b(m), c(n), d(n), xout(n); - c[0] = +1.0; - c[1] = -1.0; - // - d[0] = +2.0; - d[1] = +2.0; - // - size_t level = 0; - size_t maxitr = 20; - // - ok &= CppAD::lp_box(level, A, b, c, d, maxitr, xout); - // - // check optimal value for x - ok &= std::fabs( xout[0] + 2.0 ) < eps99; - ok &= std::fabs( xout[1] - 2.0 ) < eps99; - // - return ok; +{ bool ok = true; + typedef CppAD::vector vector; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + // + size_t n = 2; + size_t m = 0; + vector A(m), b(m), c(n), d(n), xout(n); + c[0] = +1.0; + c[1] = -1.0; + // + d[0] = +2.0; + d[1] = +2.0; + // + size_t level = 0; + size_t maxitr = 20; + // + ok &= CppAD::lp_box(level, A, b, c, d, maxitr, xout); + // + // check optimal value for x + ok &= std::fabs( xout[0] + 2.0 ) < eps99; + ok &= std::fabs( xout[1] - 2.0 ) < eps99; + // + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/lp_box.hpp cppad-2019.02.00.0/example/abs_normal/lp_box.hpp --- cppad-2018.00.00.0/example/abs_normal/lp_box.hpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/lp_box.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,39 +3,40 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin lp_box$$ $spell - hpp - lp - const - col - xout - yout - sout - cols - prog - maxitr - xin - qp + hpp + lp + const + col + xout + yout + sout + cols + prog + maxitr + xin + qp $$ $section abs_normal: Solve a Linear Program With Box Constraints$$ $head Syntax$$ $icode%ok% = lp_box( - %level%, %A%, %b%, %c%, %d%, %maxitr%, %xout% + %level%, %A%, %b%, %c%, %d%, %maxitr%, %xout% )%$$ $head Prototype$$ $srcfile%example/abs_normal/lp_box.hpp% - 0%// BEGIN PROTOTYPE%// END PROTOTYPE% + 0%// BEGIN PROTOTYPE%// END PROTOTYPE% 1%$$ $head Source$$ @@ -103,12 +104,11 @@ If the return value $icode ok$$ is true, an optimal solution was found. $children%example/abs_normal/lp_box.cpp - %example/abs_normal/lp_box.omh + %example/abs_normal/lp_box.omh %$$ $head Example$$ The file $cref lp_box.cpp$$ contains an example and test of $code lp_box$$. -It returns true if the test passes and false otherwise. $end ----------------------------------------------------------------------------- @@ -121,99 +121,99 @@ // BEGIN PROTOTYPE template bool lp_box( - size_t level , - const Vector& A , - const Vector& b , - const Vector& c , - const Vector& d , - size_t maxitr , - Vector& xout ) + size_t level , + const Vector& A , + const Vector& b , + const Vector& c , + const Vector& d , + size_t maxitr , + Vector& xout ) // END PROTOTYPE -{ double inf = std::numeric_limits::infinity(); - // - size_t m = b.size(); - size_t n = c.size(); - // - CPPAD_ASSERT_KNOWN( - level <= 3, "lp_box: level is greater than 3"); - CPPAD_ASSERT_KNOWN( - size_t(A.size()) == m * n, "lp_box: size of A is not m * n" - ); - CPPAD_ASSERT_KNOWN( - size_t(d.size()) == n, "lp_box: size of d is not n" - ); - if( level > 0 ) - { std::cout << "start lp_box\n"; - CppAD::abs_print_mat("A", m, n, A); - CppAD::abs_print_mat("b", m, 1, b); - CppAD::abs_print_mat("c", n, 1, c); - CppAD::abs_print_mat("d", n, 1, d); - } - // - // count number of limits - size_t n_limit = 0; - for(size_t j = 0; j < n; j++) - { if( d[j] < inf ) - n_limit += 1; - } - // - // A_simplex and b_simplex define the extended constraints - Vector A_simplex((m + 2 * n_limit) * (2 * n) ), b_simplex(m + 2 * n_limit); - for(size_t i = 0; i < size_t(A_simplex.size()); i++) - A_simplex[i] = 0.0; - // - // put A * x + b <= 0 in A_simplex, b_simplex - for(size_t i = 0; i < m; i++) - { b_simplex[i] = b[i]; - for(size_t j = 0; j < n; j++) - { // x_j^+ coefficient (positive component) - A_simplex[i * (2 * n) + 2 * j] = A[i * n + j]; - // x_j^- coefficient (negative component) - A_simplex[i * (2 * n) + 2 * j + 1] = - A[i * n + j]; - } - } - // - // put | x_j | <= d_j in A_simplex, b_simplex - size_t i_limit = 0; - for(size_t j = 0; j < n; j++) if( d[j] < inf ) - { - // x_j^+ <= d_j constraint - b_simplex[ m + 2 * i_limit] = - d[j]; - A_simplex[(m + 2 * i_limit) * (2 * n) + 2 * j] = 1.0; - // - // x_j^- <= d_j constraint - b_simplex[ m + 2 * i_limit + 1] = - d[j]; - A_simplex[(m + 2 * i_limit + 1) * (2 * n) + 2 * j + 1] = 1.0; - // - ++i_limit; - } - // - // c_simples - Vector c_simplex(2 * n); - for(size_t j = 0; j < n; j++) - { // x_j+ component - c_simplex[2 * j] = c[j]; - // x_j^- component - c_simplex[2 * j + 1] = - c[j]; - } - size_t level_simplex = 0; - if( level >= 2 ) - level_simplex = level - 1; - // - Vector x_simplex(2 * n); - bool ok = CppAD::simplex_method( - level_simplex, A_simplex, b_simplex, c_simplex, maxitr, x_simplex - ); - for(size_t j = 0; j < n; j++) - xout[j] = x_simplex[2 * j] - x_simplex[2 * j + 1]; - if( level > 0 ) - { CppAD::abs_print_mat("xout", n, 1, xout); - if( ok ) - std::cout << "end lp_box: ok = true\n"; - else - std::cout << "end lp_box: ok = false\n"; - } - return ok; +{ double inf = std::numeric_limits::infinity(); + // + size_t m = b.size(); + size_t n = c.size(); + // + CPPAD_ASSERT_KNOWN( + level <= 3, "lp_box: level is greater than 3"); + CPPAD_ASSERT_KNOWN( + size_t(A.size()) == m * n, "lp_box: size of A is not m * n" + ); + CPPAD_ASSERT_KNOWN( + size_t(d.size()) == n, "lp_box: size of d is not n" + ); + if( level > 0 ) + { std::cout << "start lp_box\n"; + CppAD::abs_print_mat("A", m, n, A); + CppAD::abs_print_mat("b", m, 1, b); + CppAD::abs_print_mat("c", n, 1, c); + CppAD::abs_print_mat("d", n, 1, d); + } + // + // count number of limits + size_t n_limit = 0; + for(size_t j = 0; j < n; j++) + { if( d[j] < inf ) + n_limit += 1; + } + // + // A_simplex and b_simplex define the extended constraints + Vector A_simplex((m + 2 * n_limit) * (2 * n) ), b_simplex(m + 2 * n_limit); + for(size_t i = 0; i < size_t(A_simplex.size()); i++) + A_simplex[i] = 0.0; + // + // put A * x + b <= 0 in A_simplex, b_simplex + for(size_t i = 0; i < m; i++) + { b_simplex[i] = b[i]; + for(size_t j = 0; j < n; j++) + { // x_j^+ coefficient (positive component) + A_simplex[i * (2 * n) + 2 * j] = A[i * n + j]; + // x_j^- coefficient (negative component) + A_simplex[i * (2 * n) + 2 * j + 1] = - A[i * n + j]; + } + } + // + // put | x_j | <= d_j in A_simplex, b_simplex + size_t i_limit = 0; + for(size_t j = 0; j < n; j++) if( d[j] < inf ) + { + // x_j^+ <= d_j constraint + b_simplex[ m + 2 * i_limit] = - d[j]; + A_simplex[(m + 2 * i_limit) * (2 * n) + 2 * j] = 1.0; + // + // x_j^- <= d_j constraint + b_simplex[ m + 2 * i_limit + 1] = - d[j]; + A_simplex[(m + 2 * i_limit + 1) * (2 * n) + 2 * j + 1] = 1.0; + // + ++i_limit; + } + // + // c_simples + Vector c_simplex(2 * n); + for(size_t j = 0; j < n; j++) + { // x_j+ component + c_simplex[2 * j] = c[j]; + // x_j^- component + c_simplex[2 * j + 1] = - c[j]; + } + size_t level_simplex = 0; + if( level >= 2 ) + level_simplex = level - 1; + // + Vector x_simplex(2 * n); + bool ok = CppAD::simplex_method( + level_simplex, A_simplex, b_simplex, c_simplex, maxitr, x_simplex + ); + for(size_t j = 0; j < n; j++) + xout[j] = x_simplex[2 * j] - x_simplex[2 * j + 1]; + if( level > 0 ) + { CppAD::abs_print_mat("xout", n, 1, xout); + if( ok ) + std::cout << "end lp_box: ok = true\n"; + else + std::cout << "end lp_box: ok = false\n"; + } + return ok; } } // END_CPPAD_NAMESPACE diff -Nru cppad-2018.00.00.0/example/abs_normal/lp_box.omh cppad-2019.02.00.0/example/abs_normal/lp_box.omh --- cppad-2018.00.00.0/example/abs_normal/lp_box.omh 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/lp_box.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,23 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin lp_box.hpp$$ $spell - lp + lp $$ $section lp_box Source Code$$ $srcfile%example/abs_normal/lp_box.hpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 0%$$ $end diff -Nru cppad-2018.00.00.0/example/abs_normal/makefile.am cppad-2019.02.00.0/example/abs_normal/makefile.am --- cppad-2018.00.00.0/example/abs_normal/makefile.am 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -14,22 +15,17 @@ DEFS = # # Make sure that ../cppad-uninstalled.pc works for determining cflags -if CppAD_PKG_CONFIG -CPPAD_INCLUDE = `( \ - export PKG_CONFIG_PATH=$(top_builddir)/pkgconfig ; \ - pkg-config --cflags cppad \ -)` -else -CPPAD_INCLUDE = -I$(top_srcdir) -endif +CPPAD_INCLUDE = -I$(top_srcdir)/include # -EXTRA_DIST = abs_normal.omh # check_PROGRAMS = abs_normal # -AM_CPPFLAGS = -I. $(CPPAD_INCLUDE) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + $(CPPAD_INCLUDE) \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) # abs_normal_SOURCES = \ abs_eval.cpp \ diff -Nru cppad-2018.00.00.0/example/abs_normal/makefile.in cppad-2019.02.00.0/example/abs_normal/makefile.in --- cppad-2018.00.00.0/example/abs_normal/makefile.in 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -199,19 +199,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -284,10 +283,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -306,9 +303,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -331,8 +330,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -352,20 +349,17 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -@CppAD_PKG_CONFIG_FALSE@CPPAD_INCLUDE = -I$(top_srcdir) # # Make sure that ../cppad-uninstalled.pc works for determining cflags -@CppAD_PKG_CONFIG_TRUE@CPPAD_INCLUDE = `( \ -@CppAD_PKG_CONFIG_TRUE@ export PKG_CONFIG_PATH=$(top_builddir)/pkgconfig ; \ -@CppAD_PKG_CONFIG_TRUE@ pkg-config --cflags cppad \ -@CppAD_PKG_CONFIG_TRUE@)` - -# -EXTRA_DIST = abs_normal.omh +CPPAD_INCLUDE = -I$(top_srcdir)/include # -AM_CPPFLAGS = -I. $(CPPAD_INCLUDE) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + $(CPPAD_INCLUDE) \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + # abs_normal_SOURCES = \ abs_eval.cpp \ diff -Nru cppad-2018.00.00.0/example/abs_normal/min_nso_linear.cpp cppad-2019.02.00.0/example/abs_normal/min_nso_linear.cpp --- cppad-2018.00.00.0/example/abs_normal/min_nso_linear.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/min_nso_linear.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin min_nso_linear.cpp$$ $spell - nso - smo + nso + smo $$ $section abs_normal min_nso_linear: Example and Test$$ @@ -37,7 +38,7 @@ $head Source$$ $srcfile%example/abs_normal/min_nso_linear.cpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 1%$$ $end @@ -48,71 +49,71 @@ # include "min_nso_linear.hpp" bool min_nso_linear(void) -{ bool ok = true; - // - using CppAD::AD; - using CppAD::ADFun; - // - typedef CPPAD_TESTVECTOR(size_t) s_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR( AD ) ad_vector; - // - size_t level = 0; // level of tracing - size_t n = 3; // size of x - size_t m = 1; // size of y - size_t s = 1; // number of data points and absolute values - // - // start recording the function f(x) - ad_vector ax(n), ay(m); - for(size_t j = 0; j < n; j++) - ax[j] = double(j + 1); - Independent( ax ); - // - ay[0] = ax[0] * ax[0]; - ay[0] += 2.0 * (ax[0] + ax[1]) * (ax[0] + ax[1]); - ay[0] += fabs( ax[2] ); - ADFun f(ax, ay); - // - // create its abs_normal representation in g, a - ADFun g, a; - f.abs_normal_fun(g, a); - - // check dimension of domain and range space for g - ok &= g.Domain() == n + s; - ok &= g.Range() == m + s; - - // check dimension of domain and range space for a - ok &= a.Domain() == n; - ok &= a.Range() == s; - - // epsilon - d_vector epsilon(2); - double eps = 1e-3; - epsilon[0] = eps; - epsilon[1] = eps; - - // maxitr - s_vector maxitr(3); - maxitr[0] = 100; - maxitr[1] = 20; - maxitr[2] = 20; - - // b_in - double b_in = 1.0; - - // call min_nso_linear - d_vector x_in(n), x_out(n); - for(size_t j = 0; j < n; j++) - x_in[j] = double(j + 1); - - // - ok &= CppAD::min_nso_linear( - level, g, a, epsilon, maxitr, b_in, x_in, x_out - ); - // - for(size_t j = 0; j < n; j++) - ok &= std::fabs( x_out[j] ) < eps; +{ bool ok = true; + // + using CppAD::AD; + using CppAD::ADFun; + // + typedef CPPAD_TESTVECTOR(size_t) s_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR( AD ) ad_vector; + // + size_t level = 0; // level of tracing + size_t n = 3; // size of x + size_t m = 1; // size of y + size_t s = 1; // number of data points and absolute values + // + // start recording the function f(x) + ad_vector ax(n), ay(m); + for(size_t j = 0; j < n; j++) + ax[j] = double(j + 1); + Independent( ax ); + // + ay[0] = ax[0] * ax[0]; + ay[0] += 2.0 * (ax[0] + ax[1]) * (ax[0] + ax[1]); + ay[0] += fabs( ax[2] ); + ADFun f(ax, ay); + // + // create its abs_normal representation in g, a + ADFun g, a; + f.abs_normal_fun(g, a); + + // check dimension of domain and range space for g + ok &= g.Domain() == n + s; + ok &= g.Range() == m + s; + + // check dimension of domain and range space for a + ok &= a.Domain() == n; + ok &= a.Range() == s; + + // epsilon + d_vector epsilon(2); + double eps = 1e-3; + epsilon[0] = eps; + epsilon[1] = eps; + + // maxitr + s_vector maxitr(3); + maxitr[0] = 100; + maxitr[1] = 20; + maxitr[2] = 20; + + // b_in + double b_in = 1.0; + + // call min_nso_linear + d_vector x_in(n), x_out(n); + for(size_t j = 0; j < n; j++) + x_in[j] = double(j + 1); + + // + ok &= CppAD::min_nso_linear( + level, g, a, epsilon, maxitr, b_in, x_in, x_out + ); + // + for(size_t j = 0; j < n; j++) + ok &= std::fabs( x_out[j] ) < eps; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/min_nso_linear.hpp cppad-2019.02.00.0/example/abs_normal/min_nso_linear.hpp --- cppad-2018.00.00.0/example/abs_normal/min_nso_linear.hpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/min_nso_linear.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,33 +3,34 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin min_nso_linear$$ $spell - hpp - nso - jac - Jacobian - maxitr - smo + hpp + nso + jac + Jacobian + maxitr + smo $$ $section Non-Smooth Optimization Using Abs-normal Linear Approximations$$ $head Syntax$$ $icode%ok% = min_nso_linear( - %level%, %g%, %a%, %epsilon%, %maxitr%, %b_in%, %x_in%, %x_out% + %level%, %g%, %a%, %epsilon%, %maxitr%, %b_in%, %x_in%, %x_out% )%$$ $head Prototype$$ $srcfile%example/abs_normal/min_nso_linear.hpp% - 0%// BEGIN PROTOTYPE%// END PROTOTYPE% + 0%// BEGIN PROTOTYPE%// END PROTOTYPE% 1%$$ $head Source$$ @@ -114,7 +115,7 @@ at each iteration affine approximation is minimized with respect to $latex \Delta x$$ and subject to $latex \[ - -b \leq \Delta x_j \leq b + -b \leq \Delta x_j \leq b \] $$ for $icode%j% = 0 , %...%, %n%-1%$$. It must hold that $icode%b_in% > %epsilon%[0]%$$. @@ -133,12 +134,11 @@ is $latex x = \hat{x} + \Delta x$$. $children%example/abs_normal/min_nso_linear.cpp - %example/abs_normal/min_nso_linear.omh + %example/abs_normal/min_nso_linear.omh %$$ $head Example$$ The file $cref min_nso_linear.cpp$$ contains an example and test of $code min_nso_linear$$. -It returns true if the test passes and false otherwise. $end ----------------------------------------------------------------------------- @@ -149,18 +149,18 @@ // BEGIN C++ namespace { - CPPAD_TESTVECTOR(double) min_nso_linear_join( - const CPPAD_TESTVECTOR(double)& x , - const CPPAD_TESTVECTOR(double)& u ) - { size_t n = x.size(); - size_t s = u.size(); - CPPAD_TESTVECTOR(double) xu(n + s); - for(size_t j = 0; j < n; j++) - xu[j] = x[j]; - for(size_t j = 0; j < s; j++) - xu[n + j] = u[j]; - return xu; - } + CPPAD_TESTVECTOR(double) min_nso_linear_join( + const CPPAD_TESTVECTOR(double)& x , + const CPPAD_TESTVECTOR(double)& u ) + { size_t n = x.size(); + size_t s = u.size(); + CPPAD_TESTVECTOR(double) xu(n + s); + for(size_t j = 0; j < n; j++) + xu[j] = x[j]; + for(size_t j = 0; j < s; j++) + xu[n + j] = u[j]; + return xu; + } } // BEGIN C++ @@ -169,179 +169,179 @@ // BEGIN PROTOTYPE template bool min_nso_linear( - size_t level , - ADFun& g , - ADFun& a , - const DblVector& epsilon , - SizeVector maxitr , - double b_in , - const DblVector& x_in , - DblVector& x_out ) + size_t level , + ADFun& g , + ADFun& a , + const DblVector& epsilon , + SizeVector maxitr , + double b_in , + const DblVector& x_in , + DblVector& x_out ) // END PROTOTYPE { - using std::fabs; - // - // number of absolute value terms - size_t s = a.Range(); - // - // size of domain for f - size_t n = g.Domain() - s; - // - // size of range space for f - size_t m = g.Range() - s; - // - CPPAD_ASSERT_KNOWN( - level <= 5, - "min_nso_linear: level is not less that or equal 5" - ); - CPPAD_ASSERT_KNOWN( - size_t(epsilon.size()) == 2, - "min_nso_linear: size of epsilon not equal to 2" - ); - CPPAD_ASSERT_KNOWN( - size_t(maxitr.size()) == 3, - "min_nso_linear: size of maxitr not equal to 3" - ); - CPPAD_ASSERT_KNOWN( - g.Domain() > s && g.Range() > s, - "min_nso_linear: g, a is not an abs-normal representation" - ); - CPPAD_ASSERT_KNOWN( - m == 1, - "min_nso_linear: m is not equal to 1" - ); - CPPAD_ASSERT_KNOWN( - size_t(x_in.size()) == n, - "min_nso_linear: size of x_in not equal to n" - ); - CPPAD_ASSERT_KNOWN( - size_t(x_out.size()) == n, - "min_nso_linear: size of x_out not equal to n" - ); - CPPAD_ASSERT_KNOWN( - epsilon[0] < b_in, - "min_nso_linear: b_in <= epsilon[0]" - ); - if( level > 0 ) - { std::cout << "start min_nso_linear\n"; - std::cout << "b_in = " << b_in << "\n"; - CppAD::abs_print_mat("x_in", n, 1, x_in); - } - // level in abs_min_linear sub-problem - size_t level_tilde = 0; - if( level > 0 ) - level_tilde = level - 1; - // - // maxitr in abs_min_linear sub-problem - SizeVector maxitr_tilde(2); - maxitr_tilde[0] = maxitr[1]; - maxitr_tilde[1] = maxitr[2]; - // - // epsilon in abs_min_linear sub-problem - DblVector eps_tilde(2); - eps_tilde[0] = epsilon[0] / 10.; - eps_tilde[1] = epsilon[1] / 10.; - // - // current bound - double b_cur = b_in; - // - // initilaize the current x - x_out = x_in; - // - // value of a(x) at current x - DblVector a_cur = a.Forward(0, x_out); - // - // (x_out, a_cur) - DblVector xu_cur = min_nso_linear_join(x_out, a_cur); - // - // value of g[ x_cur, a_cur ] - DblVector g_cur = g.Forward(0, xu_cur); - // - for(size_t itr = 0; itr < maxitr[0]; itr++) - { - // Jacobian of g[ x_cur, a_cur ] - DblVector g_jac = g.Jacobian(xu_cur); - // - // bound in abs_min_linear sub-problem - DblVector bound_tilde(n); - for(size_t j = 0; j < n; j++) - bound_tilde[j] = b_cur; - // - DblVector delta_x(n); - bool ok = abs_min_linear( - level_tilde, n, m, s, - g_cur, g_jac, bound_tilde, eps_tilde, maxitr_tilde, delta_x - ); - if( ! ok ) - { if( level > 0 ) - std::cout << "end min_nso_linear: abs_min_linear failed\n"; - return false; - } - // - // new candidate value for x - DblVector x_new(n); - double max_delta_x = 0.0; - for(size_t j = 0; j < n; j++) - { x_new[j] = x_out[j] + delta_x[j]; - max_delta_x = std::max(max_delta_x, std::fabs( delta_x[j] ) ); - } - // - if( max_delta_x < b_cur && max_delta_x < epsilon[0] ) - { if( level > 0 ) - std::cout << "end min_nso_linear: delta_x is near zero\n"; - return true; - } - // value of abs-normal approximation at minimizer - DblVector g_tilde = CppAD::abs_eval(n, m, s, g_cur, g_jac, delta_x); - // - double derivative = (g_tilde[0] - g_cur[0]) / max_delta_x; - CPPAD_ASSERT_UNKNOWN( derivative <= 0.0 ) - if( - epsilon[1] < derivative ) - { if( level > 0 ) - std::cout << "end min_nso_linear: derivative near zero\n"; - return true; - } - // - // value of a(x) at new x - DblVector a_new = a.Forward(0, x_new); - // - // (x_new, a_new) - DblVector xu_new = min_nso_linear_join(x_new, a_new); - // - // value of g[ x_new, a_new ] - DblVector g_new = g.Forward(0, xu_new); - // - // - // check for descent of objective - double rate_new = (g_new[0] - g_cur[0]) / max_delta_x; - if( - epsilon[1] < rate_new ) - { // did not get sufficient descent - b_cur /= 2.0; - if( level > 0 ) - std::cout << "itr = " << itr - << ", rate_new = " << rate_new - << ", b_cur = " << b_cur << "\n"; - // - } - else - { // got sufficient descent so accept candidate for x - x_out = x_new; - a_cur = a_new; - g_cur = g_new; - xu_cur = xu_new; - // - if( level > 0 ) - { std::cout << "itr = " << itr - << ", derivative = "<< derivative - << ", max_delta_x = "<< max_delta_x - << ", objective = " << g_cur[0] << "\n"; - abs_print_mat("x_out", n, 1, x_out); - } - } - } - if( level > 0 ) - std::cout << "end min_nso_linear: maximum number of iterations exceeded\n"; - return false; + using std::fabs; + // + // number of absolute value terms + size_t s = a.Range(); + // + // size of domain for f + size_t n = g.Domain() - s; + // + // size of range space for f + size_t m = g.Range() - s; + // + CPPAD_ASSERT_KNOWN( + level <= 5, + "min_nso_linear: level is not less that or equal 5" + ); + CPPAD_ASSERT_KNOWN( + size_t(epsilon.size()) == 2, + "min_nso_linear: size of epsilon not equal to 2" + ); + CPPAD_ASSERT_KNOWN( + size_t(maxitr.size()) == 3, + "min_nso_linear: size of maxitr not equal to 3" + ); + CPPAD_ASSERT_KNOWN( + g.Domain() > s && g.Range() > s, + "min_nso_linear: g, a is not an abs-normal representation" + ); + CPPAD_ASSERT_KNOWN( + m == 1, + "min_nso_linear: m is not equal to 1" + ); + CPPAD_ASSERT_KNOWN( + size_t(x_in.size()) == n, + "min_nso_linear: size of x_in not equal to n" + ); + CPPAD_ASSERT_KNOWN( + size_t(x_out.size()) == n, + "min_nso_linear: size of x_out not equal to n" + ); + CPPAD_ASSERT_KNOWN( + epsilon[0] < b_in, + "min_nso_linear: b_in <= epsilon[0]" + ); + if( level > 0 ) + { std::cout << "start min_nso_linear\n"; + std::cout << "b_in = " << b_in << "\n"; + CppAD::abs_print_mat("x_in", n, 1, x_in); + } + // level in abs_min_linear sub-problem + size_t level_tilde = 0; + if( level > 0 ) + level_tilde = level - 1; + // + // maxitr in abs_min_linear sub-problem + SizeVector maxitr_tilde(2); + maxitr_tilde[0] = maxitr[1]; + maxitr_tilde[1] = maxitr[2]; + // + // epsilon in abs_min_linear sub-problem + DblVector eps_tilde(2); + eps_tilde[0] = epsilon[0] / 10.; + eps_tilde[1] = epsilon[1] / 10.; + // + // current bound + double b_cur = b_in; + // + // initilaize the current x + x_out = x_in; + // + // value of a(x) at current x + DblVector a_cur = a.Forward(0, x_out); + // + // (x_out, a_cur) + DblVector xu_cur = min_nso_linear_join(x_out, a_cur); + // + // value of g[ x_cur, a_cur ] + DblVector g_cur = g.Forward(0, xu_cur); + // + for(size_t itr = 0; itr < maxitr[0]; itr++) + { + // Jacobian of g[ x_cur, a_cur ] + DblVector g_jac = g.Jacobian(xu_cur); + // + // bound in abs_min_linear sub-problem + DblVector bound_tilde(n); + for(size_t j = 0; j < n; j++) + bound_tilde[j] = b_cur; + // + DblVector delta_x(n); + bool ok = abs_min_linear( + level_tilde, n, m, s, + g_cur, g_jac, bound_tilde, eps_tilde, maxitr_tilde, delta_x + ); + if( ! ok ) + { if( level > 0 ) + std::cout << "end min_nso_linear: abs_min_linear failed\n"; + return false; + } + // + // new candidate value for x + DblVector x_new(n); + double max_delta_x = 0.0; + for(size_t j = 0; j < n; j++) + { x_new[j] = x_out[j] + delta_x[j]; + max_delta_x = std::max(max_delta_x, std::fabs( delta_x[j] ) ); + } + // + if( max_delta_x < b_cur && max_delta_x < epsilon[0] ) + { if( level > 0 ) + std::cout << "end min_nso_linear: delta_x is near zero\n"; + return true; + } + // value of abs-normal approximation at minimizer + DblVector g_tilde = CppAD::abs_eval(n, m, s, g_cur, g_jac, delta_x); + // + double derivative = (g_tilde[0] - g_cur[0]) / max_delta_x; + CPPAD_ASSERT_UNKNOWN( derivative <= 0.0 ) + if( - epsilon[1] < derivative ) + { if( level > 0 ) + std::cout << "end min_nso_linear: derivative near zero\n"; + return true; + } + // + // value of a(x) at new x + DblVector a_new = a.Forward(0, x_new); + // + // (x_new, a_new) + DblVector xu_new = min_nso_linear_join(x_new, a_new); + // + // value of g[ x_new, a_new ] + DblVector g_new = g.Forward(0, xu_new); + // + // + // check for descent of objective + double rate_new = (g_new[0] - g_cur[0]) / max_delta_x; + if( - epsilon[1] < rate_new ) + { // did not get sufficient descent + b_cur /= 2.0; + if( level > 0 ) + std::cout << "itr = " << itr + << ", rate_new = " << rate_new + << ", b_cur = " << b_cur << "\n"; + // + } + else + { // got sufficient descent so accept candidate for x + x_out = x_new; + a_cur = a_new; + g_cur = g_new; + xu_cur = xu_new; + // + if( level > 0 ) + { std::cout << "itr = " << itr + << ", derivative = "<< derivative + << ", max_delta_x = "<< max_delta_x + << ", objective = " << g_cur[0] << "\n"; + abs_print_mat("x_out", n, 1, x_out); + } + } + } + if( level > 0 ) + std::cout << "end min_nso_linear: maximum number of iterations exceeded\n"; + return false; } } // END_CPPAD_NAMESPACE // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/min_nso_linear.omh cppad-2019.02.00.0/example/abs_normal/min_nso_linear.omh --- cppad-2018.00.00.0/example/abs_normal/min_nso_linear.omh 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/min_nso_linear.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,23 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin min_nso_linear.hpp$$ $spell - nso + nso $$ $section min_nso_linear Source Code$$ $srcfile%example/abs_normal/min_nso_linear.hpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 0%$$ $end diff -Nru cppad-2018.00.00.0/example/abs_normal/min_nso_quad.cpp cppad-2019.02.00.0/example/abs_normal/min_nso_quad.cpp --- cppad-2018.00.00.0/example/abs_normal/min_nso_quad.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/min_nso_quad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin min_nso_quad.cpp$$ $spell - nso - smo + nso + smo $$ $section abs_normal min_nso_quad: Example and Test$$ @@ -37,7 +38,7 @@ $head Source$$ $srcfile%example/abs_normal/min_nso_quad.cpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 1%$$ $end @@ -48,71 +49,71 @@ # include "min_nso_quad.hpp" bool min_nso_quad(void) -{ bool ok = true; - // - using CppAD::AD; - using CppAD::ADFun; - // - typedef CPPAD_TESTVECTOR(size_t) s_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR( AD ) ad_vector; - // - size_t level = 0; // level of tracing - size_t n = 3; // size of x - size_t m = 1; // size of y - size_t s = 1; // number of data points and absolute values - // - // start recording the function f(x) - ad_vector ax(n), ay(m); - for(size_t j = 0; j < n; j++) - ax[j] = double(j + 1); - Independent( ax ); - // - ay[0] = ax[0] * ax[0]; - ay[0] += 2.0 * (ax[0] + ax[1]) * (ax[0] + ax[1]); - ay[0] += fabs( ax[2] ); - ADFun f(ax, ay); - // - // create its abs_normal representation in g, a - ADFun g, a; - f.abs_normal_fun(g, a); - - // check dimension of domain and range space for g - ok &= g.Domain() == n + s; - ok &= g.Range() == m + s; - - // check dimension of domain and range space for a - ok &= a.Domain() == n; - ok &= a.Range() == s; - - // epsilon - d_vector epsilon(2); - double eps = 1e-3; - epsilon[0] = eps; - epsilon[1] = eps; - - // maxitr - s_vector maxitr(3); - maxitr[0] = 100; - maxitr[1] = 20; - maxitr[2] = 20; - - // b_in - double b_in = 1.0; - - // call min_nso_quad - d_vector x_in(n), x_out(n); - for(size_t j = 0; j < n; j++) - x_in[j] = double(j + 1); - - // - ok &= CppAD::min_nso_quad( - level, f, g, a, epsilon, maxitr, b_in, x_in, x_out - ); - // - for(size_t j = 0; j < n; j++) - ok &= std::fabs( x_out[j] ) < eps; +{ bool ok = true; + // + using CppAD::AD; + using CppAD::ADFun; + // + typedef CPPAD_TESTVECTOR(size_t) s_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR( AD ) ad_vector; + // + size_t level = 0; // level of tracing + size_t n = 3; // size of x + size_t m = 1; // size of y + size_t s = 1; // number of data points and absolute values + // + // start recording the function f(x) + ad_vector ax(n), ay(m); + for(size_t j = 0; j < n; j++) + ax[j] = double(j + 1); + Independent( ax ); + // + ay[0] = ax[0] * ax[0]; + ay[0] += 2.0 * (ax[0] + ax[1]) * (ax[0] + ax[1]); + ay[0] += fabs( ax[2] ); + ADFun f(ax, ay); + // + // create its abs_normal representation in g, a + ADFun g, a; + f.abs_normal_fun(g, a); + + // check dimension of domain and range space for g + ok &= g.Domain() == n + s; + ok &= g.Range() == m + s; + + // check dimension of domain and range space for a + ok &= a.Domain() == n; + ok &= a.Range() == s; + + // epsilon + d_vector epsilon(2); + double eps = 1e-3; + epsilon[0] = eps; + epsilon[1] = eps; + + // maxitr + s_vector maxitr(3); + maxitr[0] = 100; + maxitr[1] = 20; + maxitr[2] = 20; + + // b_in + double b_in = 1.0; + + // call min_nso_quad + d_vector x_in(n), x_out(n); + for(size_t j = 0; j < n; j++) + x_in[j] = double(j + 1); + + // + ok &= CppAD::min_nso_quad( + level, f, g, a, epsilon, maxitr, b_in, x_in, x_out + ); + // + for(size_t j = 0; j < n; j++) + ok &= std::fabs( x_out[j] ) < eps; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/min_nso_quad.hpp cppad-2019.02.00.0/example/abs_normal/min_nso_quad.hpp --- cppad-2018.00.00.0/example/abs_normal/min_nso_quad.hpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/min_nso_quad.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,34 +3,35 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin min_nso_quad$$ $spell - hpp - qp - nso - jac - Jacobian - maxitr - smo + hpp + qp + nso + jac + Jacobian + maxitr + smo $$ $section Non-Smooth Optimization Using Abs-normal Quadratic Approximations$$ $head Syntax$$ $icode%ok% = min_nso_quad( - %level%, %f%, %g%, %a%, %epsilon%, %maxitr%, %b_in%, %x_in%, %x_out% + %level%, %f%, %g%, %a%, %epsilon%, %maxitr%, %b_in%, %x_in%, %x_out% )%$$ $head Prototype$$ $srcfile%example/abs_normal/min_nso_quad.hpp% - 0%// BEGIN PROTOTYPE%// END PROTOTYPE% + 0%// BEGIN PROTOTYPE%// END PROTOTYPE% 1%$$ $head Source$$ @@ -112,7 +113,7 @@ at each iteration affine approximation is minimized with respect to $latex \Delta x$$ and subject to $latex \[ - -b \leq \Delta x_j \leq b + -b \leq \Delta x_j \leq b \] $$ for $icode%j% = 0 , %...%, %n%-1%$$. It must hold that $icode%b_in% > %epsilon%[0]%$$. @@ -131,12 +132,11 @@ is $latex x = \hat{x} + \Delta x$$. $children%example/abs_normal/min_nso_quad.cpp - %example/abs_normal/min_nso_quad.omh + %example/abs_normal/min_nso_quad.omh %$$ $head Example$$ The file $cref min_nso_quad.cpp$$ contains an example and test of $code min_nso_quad$$. -It returns true if the test passes and false otherwise. $end ----------------------------------------------------------------------------- @@ -147,18 +147,18 @@ // BEGIN C++ namespace { - CPPAD_TESTVECTOR(double) min_nso_quad_join( - const CPPAD_TESTVECTOR(double)& x , - const CPPAD_TESTVECTOR(double)& u ) - { size_t n = x.size(); - size_t s = u.size(); - CPPAD_TESTVECTOR(double) xu(n + s); - for(size_t j = 0; j < n; j++) - xu[j] = x[j]; - for(size_t j = 0; j < s; j++) - xu[n + j] = u[j]; - return xu; - } + CPPAD_TESTVECTOR(double) min_nso_quad_join( + const CPPAD_TESTVECTOR(double)& x , + const CPPAD_TESTVECTOR(double)& u ) + { size_t n = x.size(); + size_t s = u.size(); + CPPAD_TESTVECTOR(double) xu(n + s); + for(size_t j = 0; j < n; j++) + xu[j] = x[j]; + for(size_t j = 0; j < s; j++) + xu[n + j] = u[j]; + return xu; + } } // BEGIN C++ @@ -167,188 +167,188 @@ // BEGIN PROTOTYPE template bool min_nso_quad( - size_t level , - ADFun& f , - ADFun& g , - ADFun& a , - const DblVector& epsilon , - SizeVector maxitr , - double b_in , - const DblVector& x_in , - DblVector& x_out ) + size_t level , + ADFun& f , + ADFun& g , + ADFun& a , + const DblVector& epsilon , + SizeVector maxitr , + double b_in , + const DblVector& x_in , + DblVector& x_out ) // END PROTOTYPE { - using std::fabs; - // - // number of absolute value terms - size_t s = a.Range(); - // - // size of domain for f - size_t n = f.Domain(); - // - // size of range space for f - size_t m = f.Range(); - // - CPPAD_ASSERT_KNOWN( g.Domain() == n + s, - "min_nso_quad: (g, a) is not an abs-normal for for f" - ); - CPPAD_ASSERT_KNOWN( g.Range() == m + s, - "min_nso_quad: (g, a) is not an abs-normal for for f" - ); - CPPAD_ASSERT_KNOWN( - level <= 5, - "min_nso_quad: level is not less that or equal 5" - ); - CPPAD_ASSERT_KNOWN( - size_t(epsilon.size()) == 2, - "min_nso_quad: size of epsilon not equal to 2" - ); - CPPAD_ASSERT_KNOWN( - size_t(maxitr.size()) == 3, - "min_nso_quad: size of maxitr not equal to 3" - ); - CPPAD_ASSERT_KNOWN( - g.Domain() > s && g.Range() > s, - "min_nso_quad: g, a is not an abs-normal representation" - ); - CPPAD_ASSERT_KNOWN( - m == 1, - "min_nso_quad: m is not equal to 1" - ); - CPPAD_ASSERT_KNOWN( - size_t(x_in.size()) == n, - "min_nso_quad: size of x_in not equal to n" - ); - CPPAD_ASSERT_KNOWN( - size_t(x_out.size()) == n, - "min_nso_quad: size of x_out not equal to n" - ); - CPPAD_ASSERT_KNOWN( - epsilon[0] < b_in, - "min_nso_quad: b_in <= epsilon[0]" - ); - if( level > 0 ) - { std::cout << "start min_nso_quad\n"; - std::cout << "b_in = " << b_in << "\n"; - CppAD::abs_print_mat("x_in", n, 1, x_in); - } - // level in abs_min_quad sub-problem - size_t level_tilde = 0; - if( level > 0 ) - level_tilde = level - 1; - // - // maxitr in abs_min_quad sub-problem - SizeVector maxitr_tilde(2); - maxitr_tilde[0] = maxitr[1]; - maxitr_tilde[1] = maxitr[2]; - // - // epsilon in abs_min_quad sub-problem - DblVector eps_tilde(2); - eps_tilde[0] = epsilon[0] / 10.; - eps_tilde[1] = epsilon[1] / 10.; - // - // current bound - double b_cur = b_in; - // - // initilaize the current x - x_out = x_in; - // - // value of a(x) at current x - DblVector a_cur = a.Forward(0, x_out); - // - // (x_out, a_cur) - DblVector xu_cur = min_nso_quad_join(x_out, a_cur); - // - // value of g[ x_cur, a_cur ] - DblVector g_cur = g.Forward(0, xu_cur); - // - for(size_t itr = 0; itr < maxitr[0]; itr++) - { - // Jacobian of g[ x_cur, a_cur ] - DblVector g_jac = g.Jacobian(xu_cur); - // - // Hessian at x_cur - DblVector f_hes = f.Hessian(x_out, 0); - // - // bound in abs_min_quad sub-problem - DblVector bound_tilde(n); - for(size_t j = 0; j < n; j++) - bound_tilde[j] = b_cur; - // - DblVector delta_x(n); - bool ok = abs_min_quad( - level_tilde, n, m, s, - g_cur, g_jac, f_hes, bound_tilde, eps_tilde, maxitr_tilde, delta_x - ); - if( ! ok ) - { if( level > 0 ) - std::cout << "end min_nso_quad: abs_min_quad failed\n"; - return false; - } - // - // new candidate value for x - DblVector x_new(n); - double max_delta_x = 0.0; - for(size_t j = 0; j < n; j++) - { x_new[j] = x_out[j] + delta_x[j]; - max_delta_x = std::max(max_delta_x, std::fabs( delta_x[j] ) ); - } - // - if( max_delta_x < 0.75 * b_cur && max_delta_x < epsilon[0] ) - { if( level > 0 ) - std::cout << "end min_nso_quad: delta_x is near zero\n"; - return true; - } - // value of abs-normal approximation at minimizer - DblVector g_tilde = CppAD::abs_eval(n, m, s, g_cur, g_jac, delta_x); - // - double derivative = (g_tilde[0] - g_cur[0]) / max_delta_x; - CPPAD_ASSERT_UNKNOWN( derivative <= 0.0 ) - if( - epsilon[1] < derivative ) - { if( level > 0 ) - std::cout << "end min_nso_quad: derivative near zero\n"; - return true; - } - // - // value of a(x) at new x - DblVector a_new = a.Forward(0, x_new); - // - // (x_new, a_new) - DblVector xu_new = min_nso_quad_join(x_new, a_new); - // - // value of g[ x_new, a_new ] - DblVector g_new = g.Forward(0, xu_new); - // - // check for descent of objective - double rate_new = (g_new[0] - g_cur[0]) / max_delta_x; - if( - epsilon[1] < rate_new ) - { // did not get sufficient descent - b_cur /= 2.0; - if( level > 0 ) - std::cout << "itr = " << itr - << ", rate_new = " << rate_new - << ", b_cur = " << b_cur << "\n"; - // - } - else - { // got sufficient descent so accept candidate for x - x_out = x_new; - a_cur = a_new; - g_cur = g_new; - xu_cur = xu_new; - // - if( level > 0 ) - { std::cout << "itr = " << itr - << ", derivative = "<< derivative - << ", max_delta_x = "<< max_delta_x - << ", objective = " << g_cur[0] << "\n"; - abs_print_mat("x_out", n, 1, x_out); - } - } - } - if( level > 0 ) - std::cout << "end min_nso_quad: maximum number of iterations exceeded\n"; - return false; + using std::fabs; + // + // number of absolute value terms + size_t s = a.Range(); + // + // size of domain for f + size_t n = f.Domain(); + // + // size of range space for f + size_t m = f.Range(); + // + CPPAD_ASSERT_KNOWN( g.Domain() == n + s, + "min_nso_quad: (g, a) is not an abs-normal for for f" + ); + CPPAD_ASSERT_KNOWN( g.Range() == m + s, + "min_nso_quad: (g, a) is not an abs-normal for for f" + ); + CPPAD_ASSERT_KNOWN( + level <= 5, + "min_nso_quad: level is not less that or equal 5" + ); + CPPAD_ASSERT_KNOWN( + size_t(epsilon.size()) == 2, + "min_nso_quad: size of epsilon not equal to 2" + ); + CPPAD_ASSERT_KNOWN( + size_t(maxitr.size()) == 3, + "min_nso_quad: size of maxitr not equal to 3" + ); + CPPAD_ASSERT_KNOWN( + g.Domain() > s && g.Range() > s, + "min_nso_quad: g, a is not an abs-normal representation" + ); + CPPAD_ASSERT_KNOWN( + m == 1, + "min_nso_quad: m is not equal to 1" + ); + CPPAD_ASSERT_KNOWN( + size_t(x_in.size()) == n, + "min_nso_quad: size of x_in not equal to n" + ); + CPPAD_ASSERT_KNOWN( + size_t(x_out.size()) == n, + "min_nso_quad: size of x_out not equal to n" + ); + CPPAD_ASSERT_KNOWN( + epsilon[0] < b_in, + "min_nso_quad: b_in <= epsilon[0]" + ); + if( level > 0 ) + { std::cout << "start min_nso_quad\n"; + std::cout << "b_in = " << b_in << "\n"; + CppAD::abs_print_mat("x_in", n, 1, x_in); + } + // level in abs_min_quad sub-problem + size_t level_tilde = 0; + if( level > 0 ) + level_tilde = level - 1; + // + // maxitr in abs_min_quad sub-problem + SizeVector maxitr_tilde(2); + maxitr_tilde[0] = maxitr[1]; + maxitr_tilde[1] = maxitr[2]; + // + // epsilon in abs_min_quad sub-problem + DblVector eps_tilde(2); + eps_tilde[0] = epsilon[0] / 10.; + eps_tilde[1] = epsilon[1] / 10.; + // + // current bound + double b_cur = b_in; + // + // initilaize the current x + x_out = x_in; + // + // value of a(x) at current x + DblVector a_cur = a.Forward(0, x_out); + // + // (x_out, a_cur) + DblVector xu_cur = min_nso_quad_join(x_out, a_cur); + // + // value of g[ x_cur, a_cur ] + DblVector g_cur = g.Forward(0, xu_cur); + // + for(size_t itr = 0; itr < maxitr[0]; itr++) + { + // Jacobian of g[ x_cur, a_cur ] + DblVector g_jac = g.Jacobian(xu_cur); + // + // Hessian at x_cur + DblVector f_hes = f.Hessian(x_out, 0); + // + // bound in abs_min_quad sub-problem + DblVector bound_tilde(n); + for(size_t j = 0; j < n; j++) + bound_tilde[j] = b_cur; + // + DblVector delta_x(n); + bool ok = abs_min_quad( + level_tilde, n, m, s, + g_cur, g_jac, f_hes, bound_tilde, eps_tilde, maxitr_tilde, delta_x + ); + if( ! ok ) + { if( level > 0 ) + std::cout << "end min_nso_quad: abs_min_quad failed\n"; + return false; + } + // + // new candidate value for x + DblVector x_new(n); + double max_delta_x = 0.0; + for(size_t j = 0; j < n; j++) + { x_new[j] = x_out[j] + delta_x[j]; + max_delta_x = std::max(max_delta_x, std::fabs( delta_x[j] ) ); + } + // + if( max_delta_x < 0.75 * b_cur && max_delta_x < epsilon[0] ) + { if( level > 0 ) + std::cout << "end min_nso_quad: delta_x is near zero\n"; + return true; + } + // value of abs-normal approximation at minimizer + DblVector g_tilde = CppAD::abs_eval(n, m, s, g_cur, g_jac, delta_x); + // + double derivative = (g_tilde[0] - g_cur[0]) / max_delta_x; + CPPAD_ASSERT_UNKNOWN( derivative <= 0.0 ) + if( - epsilon[1] < derivative ) + { if( level > 0 ) + std::cout << "end min_nso_quad: derivative near zero\n"; + return true; + } + // + // value of a(x) at new x + DblVector a_new = a.Forward(0, x_new); + // + // (x_new, a_new) + DblVector xu_new = min_nso_quad_join(x_new, a_new); + // + // value of g[ x_new, a_new ] + DblVector g_new = g.Forward(0, xu_new); + // + // check for descent of objective + double rate_new = (g_new[0] - g_cur[0]) / max_delta_x; + if( - epsilon[1] < rate_new ) + { // did not get sufficient descent + b_cur /= 2.0; + if( level > 0 ) + std::cout << "itr = " << itr + << ", rate_new = " << rate_new + << ", b_cur = " << b_cur << "\n"; + // + } + else + { // got sufficient descent so accept candidate for x + x_out = x_new; + a_cur = a_new; + g_cur = g_new; + xu_cur = xu_new; + // + if( level > 0 ) + { std::cout << "itr = " << itr + << ", derivative = "<< derivative + << ", max_delta_x = "<< max_delta_x + << ", objective = " << g_cur[0] << "\n"; + abs_print_mat("x_out", n, 1, x_out); + } + } + } + if( level > 0 ) + std::cout << "end min_nso_quad: maximum number of iterations exceeded\n"; + return false; } } // END_CPPAD_NAMESPACE // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/min_nso_quad.omh cppad-2019.02.00.0/example/abs_normal/min_nso_quad.omh --- cppad-2018.00.00.0/example/abs_normal/min_nso_quad.omh 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/min_nso_quad.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,23 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin min_nso_quad.hpp$$ $spell - nso + nso $$ $section min_nso_quad Source Code$$ $srcfile%example/abs_normal/min_nso_quad.hpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 0%$$ $end diff -Nru cppad-2018.00.00.0/example/abs_normal/qp_box.cpp cppad-2019.02.00.0/example/abs_normal/qp_box.cpp --- cppad-2018.00.00.0/example/abs_normal/qp_box.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/qp_box.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,17 +1,18 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin qp_box.cpp$$ $spell - qp + qp $$ $section abs_normal qp_box: Example and Test$$ @@ -27,7 +28,7 @@ $head Source$$ $srcfile%example/abs_normal/qp_box.cpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 1%$$ $end @@ -38,37 +39,37 @@ # include "qp_box.hpp" bool qp_box(void) -{ bool ok = true; - typedef CppAD::vector vector; - // - size_t n = 2; - size_t m = 0; - vector a(n), b(n), c(m), C(m), g(n), G(n*n), xin(n), xout(n); - a[0] = -2.0; - a[1] = -2.0; - b[0] = +2.0; - b[1] = +2.0; - g[0] = +1.0; - g[1] = -1.0; - for(size_t i = 0; i < n * n; i++) - G[i] = 0.0; - // - // (0, 0) is feasible. - xin[0] = 0.0; - xin[1] = 0.0; - // - size_t level = 0; - double epsilon = 99.0 * std::numeric_limits::epsilon(); - size_t maxitr = 20; - // - ok &= CppAD::qp_box( - level, a, b, c, C, g, G, epsilon, maxitr, xin, xout - ); - // - // check optimal value for x - ok &= std::fabs( xout[0] + 2.0 ) < epsilon; - ok &= std::fabs( xout[1] - 2.0 ) < epsilon; - // - return ok; +{ bool ok = true; + typedef CppAD::vector vector; + // + size_t n = 2; + size_t m = 0; + vector a(n), b(n), c(m), C(m), g(n), G(n*n), xin(n), xout(n); + a[0] = -2.0; + a[1] = -2.0; + b[0] = +2.0; + b[1] = +2.0; + g[0] = +1.0; + g[1] = -1.0; + for(size_t i = 0; i < n * n; i++) + G[i] = 0.0; + // + // (0, 0) is feasible. + xin[0] = 0.0; + xin[1] = 0.0; + // + size_t level = 0; + double epsilon = 99.0 * std::numeric_limits::epsilon(); + size_t maxitr = 20; + // + ok &= CppAD::qp_box( + level, a, b, c, C, g, G, epsilon, maxitr, xin, xout + ); + // + // check optimal value for x + ok &= std::fabs( xout[0] + 2.0 ) < epsilon; + ok &= std::fabs( xout[1] - 2.0 ) < epsilon; + // + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/qp_box.hpp cppad-2019.02.00.0/example/abs_normal/qp_box.hpp --- cppad-2018.00.00.0/example/abs_normal/qp_box.hpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/qp_box.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,38 +3,39 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin qp_box$$ $spell - hpp - const - col - xout - yout - sout - cols - prog - maxitr - xin - qp + hpp + const + col + xout + yout + sout + cols + prog + maxitr + xin + qp $$ $section abs_normal: Solve a Quadratic Program With Box Constraints$$ $head Syntax$$ $icode%ok% = qp_box( - %level%, %a%, %b%, %c%, %C%, %g%, %G%, %epsilon%, %maxitr%, %xin%, %xout% + %level%, %a%, %b%, %c%, %C%, %g%, %G%, %epsilon%, %maxitr%, %xin%, %xout% )%$$ $head Prototype$$ $srcfile%example/abs_normal/qp_box.hpp% - 0%// BEGIN PROTOTYPE%// END PROTOTYPE% + 0%// BEGIN PROTOTYPE%// END PROTOTYPE% 1%$$ $head Source$$ @@ -121,7 +122,7 @@ This argument has size $icode n$$ and is the initial point for the algorithm. It must strictly satisfy the constraints; i.e., $codei% - %a% < %xin%, %xin% < %b%, %C% * %xin% - %c% < 0 + %a% < %xin%, %xin% < %b%, %C% * %xin% - %c% < 0 %$$ $head xout$$ @@ -133,7 +134,7 @@ $head ok$$ If the return value $icode ok$$ is true, convergence is obtained; i.e., $latex \[ - | F ( x , y_a, s_a, y_b, s_b, y_c, s_c ) |_\infty < \varepsilon + | F ( x , y_a, s_a, y_b, s_b, y_c, s_c ) |_\infty < \varepsilon \] $$ where $latex |v|_\infty$$ is the infinity norm of the vector $latex v$$, $latex \varepsilon$$ is $icode epsilon$$, @@ -169,16 +170,15 @@ $latex y_c, s_c \in \B{R}_+^m$$. The KKT conditions for a solution of this problem is $latex \[ - F ( x , y_a, s_a, y_b, s_b, y_c, s_c ) = 0 + F ( x , y_a, s_a, y_b, s_b, y_c, s_c ) = 0 \] $$ $children%example/abs_normal/qp_box.cpp - %example/abs_normal/qp_box.omh + %example/abs_normal/qp_box.omh %$$ $head Example$$ The file $cref qp_box.cpp$$ contains an example and test of $code qp_box$$. -It returns true if the test passes and false otherwise. $end ----------------------------------------------------------------------------- @@ -191,99 +191,99 @@ // BEGIN PROTOTYPE template bool qp_box( - size_t level , - const Vector& a , - const Vector& b , - const Vector& c , - const Vector& C , - const Vector& g , - const Vector& G , - double epsilon , - size_t maxitr , - const Vector& xin , - Vector& xout ) + size_t level , + const Vector& a , + const Vector& b , + const Vector& c , + const Vector& C , + const Vector& g , + const Vector& G , + double epsilon , + size_t maxitr , + const Vector& xin , + Vector& xout ) // END PROTOTYPE -{ double inf = std::numeric_limits::infinity(); - // - size_t n = a.size(); - size_t m = c.size(); - // - CPPAD_ASSERT_KNOWN(level <= 2, "qp_interior: level is greater than 2"); - CPPAD_ASSERT_KNOWN( - size_t(b.size()) == n, "qp_box: size of b is not n" - ); - CPPAD_ASSERT_KNOWN( - size_t(C.size()) == m * n, "qp_box: size of C is not m * n" - ); - CPPAD_ASSERT_KNOWN( - size_t(g.size()) == n, "qp_box: size of g is not n" - ); - CPPAD_ASSERT_KNOWN( - size_t(G.size()) == n * n, "qp_box: size of G is not n * n" - ); - if( level > 0 ) - { std::cout << "start qp_box\n"; - CppAD::abs_print_mat("a", n, 1, a); - CppAD::abs_print_mat("b", n, 1, b); - CppAD::abs_print_mat("c", m, 1, c); - CppAD::abs_print_mat("C", m, n, C); - CppAD::abs_print_mat("g", 1, n, g); - CppAD::abs_print_mat("G", n, n, G); - CppAD::abs_print_mat("xin", n, 1, xin); - } - // - // count number of lower and upper limits - size_t n_limit = 0; - for(size_t j = 0; j < n; j++) - { CPPAD_ASSERT_KNOWN(G[j * n + j] >= 0.0, "qp_box: G_{j,j} < 0.0"); - if( -inf < a[j] ) - ++n_limit; - if( b[j] < inf ) - ++n_limit; - } - // - // C_int and c_int define the extended constraints - Vector C_int((m + n_limit) * n ), c_int(m + n_limit); - for(size_t i = 0; i < size_t(C_int.size()); i++) - C_int[i] = 0.0; - // - // put C * x + c <= 0 in C_int, c_int - for(size_t i = 0; i < m; i++) - { c_int[i] = c[i]; - for(size_t j = 0; j < n; j++) - C_int[i * n + j] = C[i * n + j]; - } - // - // put I * x - b <= 0 in C_int, c_int - size_t i_limit = 0; - for(size_t j = 0; j < n; j++) if( b[j] < inf ) - { c_int[m + i_limit] = - b[j]; - C_int[(m + i_limit) * n + j] = 1.0; - ++i_limit; - } - // - // put a - I * x <= 0 in C_int, c_int - for(size_t j = 0; j < n; j++) if( -inf < a[j] ) - { c_int[m + i_limit] = a[j]; - C_int[(m + i_limit) * n + j] = -1.0; - ++i_limit; - } - Vector yout(m + n_limit), sout(m + n_limit); - size_t level_int = 0; - if( level == 2 ) - level_int = 1; - bool ok = qp_interior( level_int, - c_int, C_int, g, G, epsilon, maxitr, xin, xout, yout, sout - ); - if( level > 0 ) - { if( level < 2 ) - CppAD::abs_print_mat("xout", n, 1, xout); - if( ok ) - std::cout << "end q_box: ok = true\n"; - else - std::cout << "end q_box: ok = false\n"; - } - return ok; +{ double inf = std::numeric_limits::infinity(); + // + size_t n = a.size(); + size_t m = c.size(); + // + CPPAD_ASSERT_KNOWN(level <= 2, "qp_interior: level is greater than 2"); + CPPAD_ASSERT_KNOWN( + size_t(b.size()) == n, "qp_box: size of b is not n" + ); + CPPAD_ASSERT_KNOWN( + size_t(C.size()) == m * n, "qp_box: size of C is not m * n" + ); + CPPAD_ASSERT_KNOWN( + size_t(g.size()) == n, "qp_box: size of g is not n" + ); + CPPAD_ASSERT_KNOWN( + size_t(G.size()) == n * n, "qp_box: size of G is not n * n" + ); + if( level > 0 ) + { std::cout << "start qp_box\n"; + CppAD::abs_print_mat("a", n, 1, a); + CppAD::abs_print_mat("b", n, 1, b); + CppAD::abs_print_mat("c", m, 1, c); + CppAD::abs_print_mat("C", m, n, C); + CppAD::abs_print_mat("g", 1, n, g); + CppAD::abs_print_mat("G", n, n, G); + CppAD::abs_print_mat("xin", n, 1, xin); + } + // + // count number of lower and upper limits + size_t n_limit = 0; + for(size_t j = 0; j < n; j++) + { CPPAD_ASSERT_KNOWN(G[j * n + j] >= 0.0, "qp_box: G_{j,j} < 0.0"); + if( -inf < a[j] ) + ++n_limit; + if( b[j] < inf ) + ++n_limit; + } + // + // C_int and c_int define the extended constraints + Vector C_int((m + n_limit) * n ), c_int(m + n_limit); + for(size_t i = 0; i < size_t(C_int.size()); i++) + C_int[i] = 0.0; + // + // put C * x + c <= 0 in C_int, c_int + for(size_t i = 0; i < m; i++) + { c_int[i] = c[i]; + for(size_t j = 0; j < n; j++) + C_int[i * n + j] = C[i * n + j]; + } + // + // put I * x - b <= 0 in C_int, c_int + size_t i_limit = 0; + for(size_t j = 0; j < n; j++) if( b[j] < inf ) + { c_int[m + i_limit] = - b[j]; + C_int[(m + i_limit) * n + j] = 1.0; + ++i_limit; + } + // + // put a - I * x <= 0 in C_int, c_int + for(size_t j = 0; j < n; j++) if( -inf < a[j] ) + { c_int[m + i_limit] = a[j]; + C_int[(m + i_limit) * n + j] = -1.0; + ++i_limit; + } + Vector yout(m + n_limit), sout(m + n_limit); + size_t level_int = 0; + if( level == 2 ) + level_int = 1; + bool ok = qp_interior( level_int, + c_int, C_int, g, G, epsilon, maxitr, xin, xout, yout, sout + ); + if( level > 0 ) + { if( level < 2 ) + CppAD::abs_print_mat("xout", n, 1, xout); + if( ok ) + std::cout << "end q_box: ok = true\n"; + else + std::cout << "end q_box: ok = false\n"; + } + return ok; } } // END_CPPAD_NAMESPACE diff -Nru cppad-2018.00.00.0/example/abs_normal/qp_box.omh cppad-2019.02.00.0/example/abs_normal/qp_box.omh --- cppad-2018.00.00.0/example/abs_normal/qp_box.omh 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/qp_box.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,23 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin qp_box.hpp$$ $spell - qp + qp $$ $section qp_box Source Code$$ $srcfile%example/abs_normal/qp_box.hpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 0%$$ $end diff -Nru cppad-2018.00.00.0/example/abs_normal/qp_interior.cpp cppad-2019.02.00.0/example/abs_normal/qp_interior.cpp --- cppad-2018.00.00.0/example/abs_normal/qp_interior.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/qp_interior.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,17 +1,18 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin qp_interior.cpp$$ $spell - qp + qp $$ $section abs_normal qp_interior: Example and Test$$ @@ -19,29 +20,29 @@ $head Problem$$ Our original problem is $latex \[ - \R{minimize} \; | u - 1| \; \R{w.r.t} \; u \in \B{R} + \R{minimize} \; | u - 1| \; \R{w.r.t} \; u \in \B{R} \] $$ We reformulate this as the following problem $latex \[ \begin{array}{rlr} - \R{minimize} & v & \R{w.r.t} \; (u,v) \in \B{R}^2 \\ - \R{subject \; to} & u - 1 \leq v \\ - & 1 - u \leq v + \R{minimize} & v & \R{w.r.t} \; (u,v) \in \B{R}^2 \\ + \R{subject \; to} & u - 1 \leq v \\ + & 1 - u \leq v \end{array} \] $$ This is equivalent to $latex \[ \begin{array}{rlr} - \R{minimize} - & (0, 1) \cdot (u, v)^T & \R{w.r.t} \; (u,v) \in \B{R}^2 \\ - \R{subject \; to} - & - \left( \begin{array}{cc} 1 & -1 \\ -1 & -1 \end{array} \right) - \left( \begin{array}{c} u \\ v \end{array} \right) - + - \left( \begin{array}{c} -1 \\ 1 \end{array} \right) - \leq - 0 + \R{minimize} + & (0, 1) \cdot (u, v)^T & \R{w.r.t} \; (u,v) \in \B{R}^2 \\ + \R{subject \; to} + & + \left( \begin{array}{cc} 1 & -1 \\ -1 & -1 \end{array} \right) + \left( \begin{array}{c} u \\ v \end{array} \right) + + + \left( \begin{array}{c} -1 \\ 1 \end{array} \right) + \leq + 0 \end{array} \] $$ which is in the form expected by $cref qp_interior$$. @@ -49,7 +50,7 @@ $head Source$$ $srcfile%example/abs_normal/qp_interior.cpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 1%$$ $end @@ -60,45 +61,45 @@ # include "qp_interior.hpp" bool qp_interior(void) -{ bool ok = true; - typedef CppAD::vector vector; - // - size_t n = 2; - size_t m = 2; - vector C(m*n), c(m), G(n*n), g(n), xin(n), xout(n), yout(m), sout(m); - C[ 0 * n + 0 ] = 1.0; // C(0,0) - C[ 0 * n + 1 ] = -1.0; // C(0,1) - C[ 1 * n + 0 ] = -1.0; // C(1,0) - C[ 1 * n + 1 ] = -1.0; // C(1,1) - // - c[0] = -1.0; - c[1] = 1.0; - // - g[0] = 0.0; - g[1] = 1.0; - // - // G = 0 - for(size_t i = 0; i < n * n; i++) - G[i] = 0.0; - // - // If (u, v) = (0,2), C * (u, v) + c = (-2,-2)^T + (1,-1)^T < 0 - // Hence (0, 2) is feasible. - xin[0] = 0.0; - xin[1] = 2.0; - // - double epsilon = 99.0 * std::numeric_limits::epsilon(); - size_t maxitr = 10; - size_t level = 0; - // - ok &= CppAD::qp_interior( - level, c, C, g, G, epsilon, maxitr, xin, xout, yout, sout - ); - // - // check optimal value for u - ok &= std::fabs( xout[0] - 1.0 ) < epsilon; - // check optimal value for v - ok &= std::fabs( xout[1] ) < epsilon; - // - return ok; +{ bool ok = true; + typedef CppAD::vector vector; + // + size_t n = 2; + size_t m = 2; + vector C(m*n), c(m), G(n*n), g(n), xin(n), xout(n), yout(m), sout(m); + C[ 0 * n + 0 ] = 1.0; // C(0,0) + C[ 0 * n + 1 ] = -1.0; // C(0,1) + C[ 1 * n + 0 ] = -1.0; // C(1,0) + C[ 1 * n + 1 ] = -1.0; // C(1,1) + // + c[0] = -1.0; + c[1] = 1.0; + // + g[0] = 0.0; + g[1] = 1.0; + // + // G = 0 + for(size_t i = 0; i < n * n; i++) + G[i] = 0.0; + // + // If (u, v) = (0,2), C * (u, v) + c = (-2,-2)^T + (1,-1)^T < 0 + // Hence (0, 2) is feasible. + xin[0] = 0.0; + xin[1] = 2.0; + // + double epsilon = 99.0 * std::numeric_limits::epsilon(); + size_t maxitr = 10; + size_t level = 0; + // + ok &= CppAD::qp_interior( + level, c, C, g, G, epsilon, maxitr, xin, xout, yout, sout + ); + // + // check optimal value for u + ok &= std::fabs( xout[0] - 1.0 ) < epsilon; + // check optimal value for v + ok &= std::fabs( xout[1] ) < epsilon; + // + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/qp_interior.hpp cppad-2019.02.00.0/example/abs_normal/qp_interior.hpp --- cppad-2018.00.00.0/example/abs_normal/qp_interior.hpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/qp_interior.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,27 +3,28 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin qp_interior$$ $spell - hpp - const - col - xout - yout - sout - cols - prog - maxitr - xin - qp + hpp + const + col + xout + yout + sout + cols + prog + maxitr + xin + qp $$ $section Solve a Quadratic Program Using Interior Point Method$$ @@ -35,7 +36,7 @@ $head Prototype$$ $srcfile%example/abs_normal/qp_interior.hpp% - 0%// BEGIN PROTOTYPE%// END PROTOTYPE% + 0%// BEGIN PROTOTYPE%// END PROTOTYPE% 1%$$ $head Source$$ @@ -124,7 +125,7 @@ $head ok$$ If the return value $icode ok$$ is true, convergence is obtained; i.e., $latex \[ - | F_0 (xout , yout, sout) |_\infty \leq epsilon + | F_0 (xout , yout, sout) |_\infty \leq epsilon \] $$ where $latex | v |_\infty$$ is the maximum absolute element for the vector $latex v$$ and $latex F_\mu (x, y, s)$$ is defined below. @@ -190,9 +191,9 @@ = - \left( \begin{array}{c} - r_x (x, y, s) \\ - r_y (x, y, s) \\ - r_s (x, y, s) + r_x (x, y, s) \\ + r_y (x, y, s) \\ + r_s (x, y, s) \end{array} \right) \] $$ @@ -209,9 +210,9 @@ = - \left( \begin{array}{c} - r_x (x, y, s) \\ - r_y (x, y, s) \\ - r_s (x, y, s) - D(y) r_y(x, y, s) + r_x (x, y, s) \\ + r_y (x, y, s) \\ + r_s (x, y, s) - D(y) r_y(x, y, s) \end{array} \right) \] $$ Multiplying the third row by $latex D(s)^{-1}$$ we obtain: @@ -225,9 +226,9 @@ = - \left( \begin{array}{c} - r_x (x, y, s) \\ - r_y (x, y, s) \\ - D(s)^{-1} r_s (x, y, s) - D(y/s) r_y(x, y, s) + r_x (x, y, s) \\ + r_y (x, y, s) \\ + D(s)^{-1} r_s (x, y, s) - D(y/s) r_y(x, y, s) \end{array} \right) \] $$ where $latex y/s$$ is the vector in $latex \B{R}^m$$ defined by @@ -243,10 +244,10 @@ = - \left( \begin{array}{c} - r_x (x, y, s) - - C^T D(s)^{-1} \left[ r_s (x, y, s) - D(y) r_y(x, y, s) \right] \\ - r_y (x, y, s) \\ - D(s)^{-1} r_s (x, y, s) - D(y/s) r_y(x, y, s) + r_x (x, y, s) + - C^T D(s)^{-1} \left[ r_s (x, y, s) - D(y) r_y(x, y, s) \right] \\ + r_y (x, y, s) \\ + D(s)^{-1} r_s (x, y, s) - D(y/s) r_y(x, y, s) \end{array} \right) \] $$ @@ -268,12 +269,11 @@ \] $$ $children%example/abs_normal/qp_interior.cpp - %example/abs_normal/qp_interior.omh + %example/abs_normal/qp_interior.omh %$$ $head Example$$ The file $cref qp_interior.cpp$$ contains an example and test of $code qp_interior$$. -It returns true if the test passes and false otherwise. $end ----------------------------------------------------------------------------- @@ -284,88 +284,88 @@ // BEGIN C++ namespace { - // ------------------------------------------------------------------------ - template - double qp_interior_max_abs(const Vector& v) - { double max_abs = 0.0; - for(size_t j = 0; j < size_t(v.size()); j++) - max_abs = std::max( max_abs, std::fabs(v[j]) ); - return max_abs; - } - // ------------------------------------------------------------------------ - template - void qp_interior_split( - const Vector& v, Vector& v_x, Vector& v_y, Vector& v_s - ) - { size_t n = v_x.size(); - size_t m = v_y.size(); - CPPAD_ASSERT_UNKNOWN( size_t(v_s.size()) == m ); - CPPAD_ASSERT_UNKNOWN( size_t(v.size()) == n + m + m ); - for(size_t i = 0; i < n; i++) - v_x[i] = v[i]; - for(size_t i = 0; i < m; i++) - { v_y[i] = v[n + i]; - v_s[i] = v[n + m + i]; - } - return; - } - // ------------------------------------------------------------------------ - template - void qp_interior_join( - Vector& v, const Vector& v_x, const Vector& v_y, const Vector& v_s - ) - { size_t n = v_x.size(); - size_t m = v_y.size(); - CPPAD_ASSERT_UNKNOWN( size_t(v_s.size()) == m ); - CPPAD_ASSERT_UNKNOWN( size_t(v.size()) == n + m + m ); - for(size_t i = 0; i < n; i++) - v[i] = v_x[i]; - for(size_t i = 0; i < m; i++) - v[n + i] = v_y[i]; - for(size_t i = 0; i < m; i++) - v[n + m + i] = v_s[i]; - return; - } - // ------------------------------------------------------------------------ - template - Vector qp_interior_F_0( - const Vector& c , - const Vector& C , - const Vector& g , - const Vector& G , - const Vector& x , - const Vector& y , - const Vector& s ) - { size_t n = g.size(); - size_t m = c.size(); - // compute r_x(x, y, s) = g + G x + y^T C - Vector r_x(n); - for(size_t j = 0; j < n; j++) - { r_x[j] = g[j]; - for(size_t i = 0; i < n; i++) - r_x[j] += G[j * n + i] * x[i]; - for(size_t i = 0; i < m; i++) - r_x[j] += y[i] * C[i * n + j]; - } - // compute r_y(x, y, s) = C x + c + s - Vector r_y(m); - for(size_t i = 0; i < m; i++) - { r_y[i] = c[i] + s[i]; - for(size_t j = 0; j < n; j++) - r_y[i] += C[i * n + j] * x[j]; - } - // compute r_s(x, y, s) = D(s) * D(y) * 1_m - mu * 1_m - // where mu = 0 - Vector r_s(m); - for(size_t i = 0; i < m; i++) - r_s[i] = s[i] * y[i]; - // - // combine into one vector - Vector F_0(n + m + m); - qp_interior_join(F_0, r_x, r_y, r_s); - // - return F_0; - } + // ------------------------------------------------------------------------ + template + double qp_interior_max_abs(const Vector& v) + { double max_abs = 0.0; + for(size_t j = 0; j < size_t(v.size()); j++) + max_abs = std::max( max_abs, std::fabs(v[j]) ); + return max_abs; + } + // ------------------------------------------------------------------------ + template + void qp_interior_split( + const Vector& v, Vector& v_x, Vector& v_y, Vector& v_s + ) + { size_t n = v_x.size(); + size_t m = v_y.size(); + CPPAD_ASSERT_UNKNOWN( size_t(v_s.size()) == m ); + CPPAD_ASSERT_UNKNOWN( size_t(v.size()) == n + m + m ); + for(size_t i = 0; i < n; i++) + v_x[i] = v[i]; + for(size_t i = 0; i < m; i++) + { v_y[i] = v[n + i]; + v_s[i] = v[n + m + i]; + } + return; + } + // ------------------------------------------------------------------------ + template + void qp_interior_join( + Vector& v, const Vector& v_x, const Vector& v_y, const Vector& v_s + ) + { size_t n = v_x.size(); + size_t m = v_y.size(); + CPPAD_ASSERT_UNKNOWN( size_t(v_s.size()) == m ); + CPPAD_ASSERT_UNKNOWN( size_t(v.size()) == n + m + m ); + for(size_t i = 0; i < n; i++) + v[i] = v_x[i]; + for(size_t i = 0; i < m; i++) + v[n + i] = v_y[i]; + for(size_t i = 0; i < m; i++) + v[n + m + i] = v_s[i]; + return; + } + // ------------------------------------------------------------------------ + template + Vector qp_interior_F_0( + const Vector& c , + const Vector& C , + const Vector& g , + const Vector& G , + const Vector& x , + const Vector& y , + const Vector& s ) + { size_t n = g.size(); + size_t m = c.size(); + // compute r_x(x, y, s) = g + G x + y^T C + Vector r_x(n); + for(size_t j = 0; j < n; j++) + { r_x[j] = g[j]; + for(size_t i = 0; i < n; i++) + r_x[j] += G[j * n + i] * x[i]; + for(size_t i = 0; i < m; i++) + r_x[j] += y[i] * C[i * n + j]; + } + // compute r_y(x, y, s) = C x + c + s + Vector r_y(m); + for(size_t i = 0; i < m; i++) + { r_y[i] = c[i] + s[i]; + for(size_t j = 0; j < n; j++) + r_y[i] += C[i * n + j] * x[j]; + } + // compute r_s(x, y, s) = D(s) * D(y) * 1_m - mu * 1_m + // where mu = 0 + Vector r_s(m); + for(size_t i = 0; i < m; i++) + r_s[i] = s[i] * y[i]; + // + // combine into one vector + Vector F_0(n + m + m); + qp_interior_join(F_0, r_x, r_y, r_s); + // + return F_0; + } } // BEGIN C++ namespace CppAD { // BEGIN_CPPAD_NAMESPACE @@ -373,218 +373,218 @@ // BEGIN PROTOTYPE template bool qp_interior( - size_t level , - const Vector& c , - const Vector& C , - const Vector& g , - const Vector& G , - double epsilon , - size_t maxitr , - const Vector& xin , - Vector& xout , - Vector& yout , - Vector& sout ) + size_t level , + const Vector& c , + const Vector& C , + const Vector& g , + const Vector& G , + double epsilon , + size_t maxitr , + const Vector& xin , + Vector& xout , + Vector& yout , + Vector& sout ) // END PROTOTYPE -{ size_t m = c.size(); - size_t n = g.size(); - CPPAD_ASSERT_KNOWN( - level <= 1, - "qp_interior: level is greater than one" - ); - CPPAD_ASSERT_KNOWN( - size_t(C.size()) == m * n, - "qp_interior: size of C is not m * n" - ); - CPPAD_ASSERT_KNOWN( - size_t(G.size()) == n * n, - "qp_interior: size of G is not n * n" - ); - if( level > 0 ) - { std::cout << "start qp_interior\n"; - CppAD::abs_print_mat("c", m, 1, c); - CppAD::abs_print_mat("C", m, n, C); - CppAD::abs_print_mat("g", n, 1, g); - CppAD::abs_print_mat("G", n, n, G); - CppAD::abs_print_mat("xin", n, 1, xin); - } - // - // compute the maximum absolute element of the problem vectors and matrices - double max_element = 0.0; - for(size_t i = 0; i < size_t(C.size()); i++) - max_element = std::max(max_element , std::fabs(C[i]) ); - for(size_t i = 0; i < size_t(c.size()); i++) - max_element = std::max(max_element , std::fabs(c[i]) ); - for(size_t i = 0; i < size_t(G.size()); i++) - max_element = std::max(max_element , std::fabs(G[i]) ); - for(size_t i = 0; i < size_t(g.size()); i++) - max_element = std::max(max_element , std::fabs(g[i]) ); - // - double mu = 1e-1 * max_element; - // - if( max_element == 0.0 ) - { if( level > 0 ) - std::cout << "end qp_interior: line_search failed\n"; - return false; - } - // - // initialize x, y, s - xout = xin; - for(size_t i = 0; i < m; i++) - { double sum = c[i]; - for(size_t j = 0; j < n; j++) - sum += C[ i * n + j ] * xout[j]; - if( sum > 0.0 ) - { if( level > 0 ) std::cout << - "end qp_interior: xin is not in interior of feasible set\n"; - return false; - } - // - sout[i] = std::sqrt(mu); - yout[i] = std::sqrt(mu); - } - // ---------------------------------------------------------------------- - // initialie F_0(xout, yout, sout) - Vector F_0 = qp_interior_F_0(c, C, g, G, xout, yout, sout); - double F_max_abs = qp_interior_max_abs( F_0 ); - for(size_t itr = 0; itr <= maxitr; itr++) - { - // check for convergence - if( F_max_abs <= epsilon ) - { if( level > 0 ) - std::cout << "end qp_interior: ok = true\n"; - return true; - } - if( itr == maxitr ) - { if( level > 0 ) std::cout << - "end qp_interior: max # iterations without convergence\n"; - return false; - } - // - // compute F_mu(xout, yout, sout) - Vector F_mu = F_0; - for(size_t i = 0; i < m; i++) - F_mu[n + m + i] -= mu; - // - // r_x, r_y, r_s (xout, yout, sout) - Vector r_x(n), r_y(m), r_s(m); - qp_interior_split(F_mu, r_x, r_y, r_s); - // - // tmp_m = D(s)^{-1} * [ r_s - D(y) r_y ] - Vector tmp_m(m); - for(size_t i = 0; i < m; i++) - tmp_m[i] = ( r_s[i] - yout[i] * r_y[i] ) / sout[i]; - // - // right_x = C^T * D(s)^{-1} * [ r_s - D(y) r_y ] - r_x - Vector right_x(n); - for(size_t j = 0; j < n; j++) - { right_x[j] = 0.0; - for(size_t i = 0; i < m; i++) - right_x[j] += C[ i * n + j ] * tmp_m[i]; - right_x[j] -= r_x[j]; - } - // - // Left_x = G + C^T * D(y / s) * C - Vector Left_x = G; - for(size_t i = 0; i < n; i++) - { for(size_t j = 0; j < n; j++) - { for(size_t k = 0; k < m; k++) - { double y_s = yout[k] / sout[k]; - Left_x[ i * n + j] += C[k * n + j] * y_s * C[k * n + i]; - } - } - } - // delta_x - Vector delta_x(n); - double logdet; - LuSolve(n, 1, Left_x, right_x, delta_x, logdet); - // - // C_delta_x = C * delta_x - Vector C_delta_x(m); - for(size_t i = 0; i < m; i++) - { C_delta_x[i] = 0.0; - for(size_t j = 0; j < n; j++) - C_delta_x[i] += C[ i * n + j ] * delta_x[j]; - } - // - // delta_y = D(s)^-1 * [D(y) * r_y - r_s + D(y) * C * delta_x] - Vector delta_y(m); - for(size_t i = 0; i < m; i++) - { delta_y[i] = yout[i] * r_y[i] - r_s[i] + yout[i] * C_delta_x[i]; - delta_y[i] /= sout[i]; - } - // delta_s = - r_y - C * delta_x - Vector delta_s(m); - for(size_t i = 0; i < m; i++) - delta_s[i] = - r_y[i] - C_delta_x[i]; - // - // delta_xys - Vector delta_xys(n + m + m); - qp_interior_join(delta_xys, delta_x, delta_y, delta_s); - // ------------------------------------------------------------------- - // - // The initial derivative in direction Delta_xys is equal to - // the negative of the norm square of F_mu - // - // line search parameter lam - Vector x(n), y(m), s(m); - double lam = 2.0; - bool lam_ok = false; - while( ! lam_ok && lam > 1e-5 ) - { lam = lam / 2.0; - for(size_t j = 0; j < n; j++) - x[j] = xout[j] + lam * delta_xys[j]; - lam_ok = true; - for(size_t i = 0; i < m; i++) - { y[i] = yout[i] + lam * delta_xys[n + i]; - s[i] = sout[i] + lam * delta_xys[n + m + i]; - lam_ok &= s[i] > 0.0 && y[i] > 0.0; - } - if( lam_ok ) - { Vector F_mu_tmp = qp_interior_F_0(c, C, g, G, x, y, s); - for(size_t i = 0; i < m; i++) - F_mu_tmp[n + m + i] -= mu; - // avoid cancellation roundoff in difference of norm squared - // |v + dv|^2 = v^T * v + 2 * v^T * dv + dv^T * dv - // |v + dv|^2 - |v|^2 = 2 * v^T * dv + dv^T * dv - double F_norm_sq = 0.0; - double diff_norm_sq = 0.0; - for(size_t i = 0; i < n + m + m; i++) - { double dv = F_mu_tmp[i] - F_mu[i]; - F_norm_sq += F_mu[i] * F_mu[i]; - diff_norm_sq += 2.0 * F_mu[i] * dv + dv * dv; - } - lam_ok &= diff_norm_sq < - lam * F_norm_sq / 4.0; - } - } - if( ! lam_ok ) - { if( level > 0 ) - std::cout << "end qp_interior: line search failed\n"; - return false; - } - // - // update current solution - xout = x; - yout = y; - sout = s; - // - // updage F_0 - F_0 = qp_interior_F_0(c, C, g, G, xout, yout, sout); - F_max_abs = qp_interior_max_abs( F_0 ); - // - // update mu - if( F_max_abs <= 1e1 * mu ) - mu = mu / 1e2; - if( level > 0 ) - { std::cout << "itr = " << itr - << ", mu = " << mu - << ", lam = " << lam - << ", F_max_abs = " << F_max_abs << "\n"; - abs_print_mat("xout", 1, n, xout); - } - } - if( level > 0 ) - std::cout << "end qp_interior: progam error\n"; - return false; +{ size_t m = c.size(); + size_t n = g.size(); + CPPAD_ASSERT_KNOWN( + level <= 1, + "qp_interior: level is greater than one" + ); + CPPAD_ASSERT_KNOWN( + size_t(C.size()) == m * n, + "qp_interior: size of C is not m * n" + ); + CPPAD_ASSERT_KNOWN( + size_t(G.size()) == n * n, + "qp_interior: size of G is not n * n" + ); + if( level > 0 ) + { std::cout << "start qp_interior\n"; + CppAD::abs_print_mat("c", m, 1, c); + CppAD::abs_print_mat("C", m, n, C); + CppAD::abs_print_mat("g", n, 1, g); + CppAD::abs_print_mat("G", n, n, G); + CppAD::abs_print_mat("xin", n, 1, xin); + } + // + // compute the maximum absolute element of the problem vectors and matrices + double max_element = 0.0; + for(size_t i = 0; i < size_t(C.size()); i++) + max_element = std::max(max_element , std::fabs(C[i]) ); + for(size_t i = 0; i < size_t(c.size()); i++) + max_element = std::max(max_element , std::fabs(c[i]) ); + for(size_t i = 0; i < size_t(G.size()); i++) + max_element = std::max(max_element , std::fabs(G[i]) ); + for(size_t i = 0; i < size_t(g.size()); i++) + max_element = std::max(max_element , std::fabs(g[i]) ); + // + double mu = 1e-1 * max_element; + // + if( max_element == 0.0 ) + { if( level > 0 ) + std::cout << "end qp_interior: line_search failed\n"; + return false; + } + // + // initialize x, y, s + xout = xin; + for(size_t i = 0; i < m; i++) + { double sum = c[i]; + for(size_t j = 0; j < n; j++) + sum += C[ i * n + j ] * xout[j]; + if( sum > 0.0 ) + { if( level > 0 ) std::cout << + "end qp_interior: xin is not in interior of feasible set\n"; + return false; + } + // + sout[i] = std::sqrt(mu); + yout[i] = std::sqrt(mu); + } + // ---------------------------------------------------------------------- + // initialie F_0(xout, yout, sout) + Vector F_0 = qp_interior_F_0(c, C, g, G, xout, yout, sout); + double F_max_abs = qp_interior_max_abs( F_0 ); + for(size_t itr = 0; itr <= maxitr; itr++) + { + // check for convergence + if( F_max_abs <= epsilon ) + { if( level > 0 ) + std::cout << "end qp_interior: ok = true\n"; + return true; + } + if( itr == maxitr ) + { if( level > 0 ) std::cout << + "end qp_interior: max # iterations without convergence\n"; + return false; + } + // + // compute F_mu(xout, yout, sout) + Vector F_mu = F_0; + for(size_t i = 0; i < m; i++) + F_mu[n + m + i] -= mu; + // + // r_x, r_y, r_s (xout, yout, sout) + Vector r_x(n), r_y(m), r_s(m); + qp_interior_split(F_mu, r_x, r_y, r_s); + // + // tmp_m = D(s)^{-1} * [ r_s - D(y) r_y ] + Vector tmp_m(m); + for(size_t i = 0; i < m; i++) + tmp_m[i] = ( r_s[i] - yout[i] * r_y[i] ) / sout[i]; + // + // right_x = C^T * D(s)^{-1} * [ r_s - D(y) r_y ] - r_x + Vector right_x(n); + for(size_t j = 0; j < n; j++) + { right_x[j] = 0.0; + for(size_t i = 0; i < m; i++) + right_x[j] += C[ i * n + j ] * tmp_m[i]; + right_x[j] -= r_x[j]; + } + // + // Left_x = G + C^T * D(y / s) * C + Vector Left_x = G; + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n; j++) + { for(size_t k = 0; k < m; k++) + { double y_s = yout[k] / sout[k]; + Left_x[ i * n + j] += C[k * n + j] * y_s * C[k * n + i]; + } + } + } + // delta_x + Vector delta_x(n); + double logdet; + LuSolve(n, 1, Left_x, right_x, delta_x, logdet); + // + // C_delta_x = C * delta_x + Vector C_delta_x(m); + for(size_t i = 0; i < m; i++) + { C_delta_x[i] = 0.0; + for(size_t j = 0; j < n; j++) + C_delta_x[i] += C[ i * n + j ] * delta_x[j]; + } + // + // delta_y = D(s)^-1 * [D(y) * r_y - r_s + D(y) * C * delta_x] + Vector delta_y(m); + for(size_t i = 0; i < m; i++) + { delta_y[i] = yout[i] * r_y[i] - r_s[i] + yout[i] * C_delta_x[i]; + delta_y[i] /= sout[i]; + } + // delta_s = - r_y - C * delta_x + Vector delta_s(m); + for(size_t i = 0; i < m; i++) + delta_s[i] = - r_y[i] - C_delta_x[i]; + // + // delta_xys + Vector delta_xys(n + m + m); + qp_interior_join(delta_xys, delta_x, delta_y, delta_s); + // ------------------------------------------------------------------- + // + // The initial derivative in direction Delta_xys is equal to + // the negative of the norm square of F_mu + // + // line search parameter lam + Vector x(n), y(m), s(m); + double lam = 2.0; + bool lam_ok = false; + while( ! lam_ok && lam > 1e-5 ) + { lam = lam / 2.0; + for(size_t j = 0; j < n; j++) + x[j] = xout[j] + lam * delta_xys[j]; + lam_ok = true; + for(size_t i = 0; i < m; i++) + { y[i] = yout[i] + lam * delta_xys[n + i]; + s[i] = sout[i] + lam * delta_xys[n + m + i]; + lam_ok &= s[i] > 0.0 && y[i] > 0.0; + } + if( lam_ok ) + { Vector F_mu_tmp = qp_interior_F_0(c, C, g, G, x, y, s); + for(size_t i = 0; i < m; i++) + F_mu_tmp[n + m + i] -= mu; + // avoid cancellation roundoff in difference of norm squared + // |v + dv|^2 = v^T * v + 2 * v^T * dv + dv^T * dv + // |v + dv|^2 - |v|^2 = 2 * v^T * dv + dv^T * dv + double F_norm_sq = 0.0; + double diff_norm_sq = 0.0; + for(size_t i = 0; i < n + m + m; i++) + { double dv = F_mu_tmp[i] - F_mu[i]; + F_norm_sq += F_mu[i] * F_mu[i]; + diff_norm_sq += 2.0 * F_mu[i] * dv + dv * dv; + } + lam_ok &= diff_norm_sq < - lam * F_norm_sq / 4.0; + } + } + if( ! lam_ok ) + { if( level > 0 ) + std::cout << "end qp_interior: line search failed\n"; + return false; + } + // + // update current solution + xout = x; + yout = y; + sout = s; + // + // updage F_0 + F_0 = qp_interior_F_0(c, C, g, G, xout, yout, sout); + F_max_abs = qp_interior_max_abs( F_0 ); + // + // update mu + if( F_max_abs <= 1e1 * mu ) + mu = mu / 1e2; + if( level > 0 ) + { std::cout << "itr = " << itr + << ", mu = " << mu + << ", lam = " << lam + << ", F_max_abs = " << F_max_abs << "\n"; + abs_print_mat("xout", 1, n, xout); + } + } + if( level > 0 ) + std::cout << "end qp_interior: progam error\n"; + return false; } } // END_CPPAD_NAMESPACE // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/qp_interior.omh cppad-2019.02.00.0/example/abs_normal/qp_interior.omh --- cppad-2018.00.00.0/example/abs_normal/qp_interior.omh 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/qp_interior.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,23 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin qp_interior.hpp$$ $spell - qp + qp $$ $section qp_interior Source Code$$ $srcfile%example/abs_normal/qp_interior.hpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 0%$$ $end diff -Nru cppad-2018.00.00.0/example/abs_normal/simplex_method.cpp cppad-2019.02.00.0/example/abs_normal/simplex_method.cpp --- cppad-2018.00.00.0/example/abs_normal/simplex_method.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/simplex_method.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,17 +1,18 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin simplex_method.cpp$$ $spell - qp + qp $$ $section abs_normal simplex_method: Example and Test$$ @@ -19,14 +20,14 @@ $head Problem$$ Our original problem is $latex \[ - \R{minimize} \; | u - 1| \; \R{w.r.t} \; u \in \B{R} + \R{minimize} \; | u - 1| \; \R{w.r.t} \; u \in \B{R} \] $$ We reformulate this as the following problem $latex \[ \begin{array}{rlr} - \R{minimize} & v & \R{w.r.t} \; (u,v) \in \B{R}^2 \\ - \R{subject \; to} & u - 1 \leq v \\ - & 1 - u \leq v + \R{minimize} & v & \R{w.r.t} \; (u,v) \in \B{R}^2 \\ + \R{subject \; to} & u - 1 \leq v \\ + & 1 - u \leq v \end{array} \] $$ We know that the value of $latex v$$ at the solution is greater than @@ -35,25 +36,25 @@ \begin{array}{rlr} \R{minimize} & v & \R{w.r.t} \; ( u_- , u_+ , v) \in \B{R}_+^3 \\ \R{subject \; to} & u_+ - u_- - 1 \leq v \\ - & 1 - u_+ + u_- \leq v + & 1 - u_+ + u_- \leq v \end{array} \] $$ This is equivalent to $latex \[ \begin{array}{rlr} - \R{minimize} - & (0, 0, 1) \cdot ( u_+, u_- , v)^T & \R{w.r.t} \; (u,v) \in \B{R}_+^3 \\ + \R{minimize} + & (0, 0, 1) \cdot ( u_+, u_- , v)^T & \R{w.r.t} \; (u,v) \in \B{R}_+^3 \\ \R{subject \; to} - & - \left( \begin{array}{ccc} - +1 & -1 & -1 \\ - -1 & +1 & +1 - \end{array} \right) - \left( \begin{array}{c} u_+ \\ u_- \\ v \end{array} \right) - + - \left( \begin{array}{c} -1 \\ 1 \end{array} \right) - \leq - 0 + & + \left( \begin{array}{ccc} + +1 & -1 & -1 \\ + -1 & +1 & +1 + \end{array} \right) + \left( \begin{array}{c} u_+ \\ u_- \\ v \end{array} \right) + + + \left( \begin{array}{c} -1 \\ 1 \end{array} \right) + \leq + 0 \end{array} \] $$ which is in the form expected by $cref simplex_method$$. @@ -61,7 +62,7 @@ $head Source$$ $srcfile%example/abs_normal/simplex_method.cpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 1%$$ $end @@ -72,39 +73,39 @@ # include "simplex_method.hpp" bool simplex_method(void) -{ bool ok = true; - typedef CppAD::vector vector; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - // - size_t n = 3; - size_t m = 2; - vector A(m * n), b(m), c(n), xout(n); - A[ 0 * n + 0 ] = 1.0; // A(0,0) - A[ 0 * n + 1 ] = -1.0; // A(0,1) - A[ 0 * n + 2 ] = -1.0; // A(0,2) - // - A[ 1 * n + 0 ] = -1.0; // A(1,0) - A[ 1 * n + 1 ] = +1.0; // A(1,1) - A[ 1 * n + 2 ] = -1.0; // A(1,2) - // - b[0] = -1.0; - b[1] = 1.0; - // - c[0] = 0.0; - c[1] = 0.0; - c[2] = 1.0; - // - size_t maxitr = 10; - size_t level = 0; - // - ok &= CppAD::simplex_method(level, A, b, c, maxitr, xout); - // - // check optimal value for u - ok &= std::fabs( xout[0] - 1.0 ) < eps99; - // - // check optimal value for v - ok &= std::fabs( xout[1] ) < eps99; - // - return ok; +{ bool ok = true; + typedef CppAD::vector vector; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + // + size_t n = 3; + size_t m = 2; + vector A(m * n), b(m), c(n), xout(n); + A[ 0 * n + 0 ] = 1.0; // A(0,0) + A[ 0 * n + 1 ] = -1.0; // A(0,1) + A[ 0 * n + 2 ] = -1.0; // A(0,2) + // + A[ 1 * n + 0 ] = -1.0; // A(1,0) + A[ 1 * n + 1 ] = +1.0; // A(1,1) + A[ 1 * n + 2 ] = -1.0; // A(1,2) + // + b[0] = -1.0; + b[1] = 1.0; + // + c[0] = 0.0; + c[1] = 0.0; + c[2] = 1.0; + // + size_t maxitr = 10; + size_t level = 0; + // + ok &= CppAD::simplex_method(level, A, b, c, maxitr, xout); + // + // check optimal value for u + ok &= std::fabs( xout[0] - 1.0 ) < eps99; + // + // check optimal value for v + ok &= std::fabs( xout[1] ) < eps99; + // + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/simplex_method.hpp cppad-2019.02.00.0/example/abs_normal/simplex_method.hpp --- cppad-2018.00.00.0/example/abs_normal/simplex_method.hpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/simplex_method.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,22 @@ # ifndef CPPAD_EXAMPLE_ABS_NORMAL_SIMPLEX_METHOD_HPP # define CPPAD_EXAMPLE_ABS_NORMAL_SIMPLEX_METHOD_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin simplex_method$$ $spell - hpp - maxitr - xout + hpp + maxitr + xout $$ $section abs_normal: Solve a Linear Program Using Simplex Method$$ @@ -26,7 +27,7 @@ $head Prototype$$ $srcfile%example/abs_normal/simplex_method.hpp% - 0%// BEGIN PROTOTYPE%// END PROTOTYPE% + 0%// BEGIN PROTOTYPE%// END PROTOTYPE% 1%$$ $head Source$$ @@ -85,12 +86,11 @@ If the return value $icode ok$$ is true, a solution has been found. $children%example/abs_normal/simplex_method.cpp - %example/abs_normal/simplex_method.omh + %example/abs_normal/simplex_method.omh %$$ $head Example$$ The file $cref simplex_method.cpp$$ contains an example and test of $code simplex_method$$. -It returns true if the test passes and false otherwise. $end ----------------------------------------------------------------------------- @@ -105,248 +105,248 @@ // BEGIN PROTOTYPE template bool simplex_method( - size_t level , - const Vector& A , - const Vector& b , - const Vector& c , - size_t maxitr , - Vector& xout ) + size_t level , + const Vector& A , + const Vector& b , + const Vector& c , + size_t maxitr , + Vector& xout ) // END PROTOTYPE -{ // number of equations - size_t ne = b.size(); - // number of x variables - size_t nx = c.size(); - CPPAD_ASSERT_UNKNOWN( size_t(A.size()) == ne * nx ); - CPPAD_ASSERT_UNKNOWN( level <= 2 ); - // - if( level > 0 ) - { std::cout << "start simplex_method\n"; - CppAD::abs_print_mat("A", ne, nx, A); - CppAD::abs_print_mat("b", ne, 1, b); - CppAD::abs_print_mat("c", nx, 1, c); - } - // - // variables (columns) in the Tableau: - // x: the original primary variables with size n - // s: slack variables, one for each equation - // a: auxillary variables, one for each negative right hand size - // r: right hand size for equations - // - // Determine number of auxillary variables - size_t na = 0; - for(size_t i = 0; i < ne; i++) - { if( b[i] > 0.0 ) - ++na; - } - // size of columns in the Tableau - size_t nc = nx + ne + na + 1; - - // number of rows in Tableau, the equations plust two objectives - size_t nr = ne + 2; - - // Initilize Tableau as zero - Vector T(nr * nc); - for(size_t i = 0; i < nr * nc; i++) - T[i] = 0.0; - - // initialize basic variable flag as false - CppAD::vector basic(nc); - for(size_t j = 0; j < nc; j++) - basic[j] = false; - - // For i = 0 , ... , m-1, place the Equations - // sum_j A_{i,j} * x_j + b_i <= 0 in Tableau - na = 0; // use as index of next auxillary variable - for(size_t i = 0; i < ne; i++) - { if( b[i] > 0.0) - { // convert to - sum_j A_{i,j} x_j - b_i >= 0 - for(size_t j = 0; j < nx; j++) - T[i * nc + j] = - A[i * nx + j]; - // slack variable has negative coefficient - T[i * nc + (nx + i)] = -1.0; - // auxillary variable is basic for this constraint - T[i * nc + (nx + ne + na)] = 1.0; - basic[nx + ne + na] = true; - // right hand side - T[i * nc + (nc - 1)] = b[i]; - // - ++na; - } - else - { // sum_j A_{i,j} x_j + b_i <= 0 - for(size_t j = 0; j < nx; j++) - T[i * nc + j] = A[i * nx + j]; - // slack variable is also basic - T[ i * nc + (nx + i) ] = 1.0; - basic[nx + i] = true; - // right hand side for equations - T[ i * nc + (nc - 1) ] = - b[i]; - } - } - // na is back to its original value - CPPAD_ASSERT_UNKNOWN( nc == nx + ne + na + 1 ); - // - // place the equation objective equation in Tablueau - // row ne corresponds to the equation z - sum_j c_j x_j = 0 - // column index for z is nx + ne + na - for(size_t j = 0; j < nx; j++) - T[ne * nc + j] = - c[j]; - // - // row ne+1 corresponds to the equation w - a_0 - ... - a_{na-1} = 0 - // column index for w is nx + ne + na +1 - for(size_t j = 0; j < na; j++) - T[(ne + 1) * nc + (nx + ne + j)] = -1.0; - // - // fix auxillary objective so coefficients in w - // for auxillary variables are zero - for(size_t k = 0; k < na; k++) - { size_t ja = nx + ne + k; - size_t ia = ne; - for(size_t i = 0; i < ne; i++) - { if( T[i * nc + ja] != 0.0 ) - { CPPAD_ASSERT_UNKNOWN( T[i * nc + ja] == 1.0 ); - CPPAD_ASSERT_UNKNOWN( T[(ne + 1) * nc + ja] == -1.0 ) - CPPAD_ASSERT_UNKNOWN( ia == ne ); - ia = i; - } - } - CPPAD_ASSERT_UNKNOWN( ia < ne ); - for(size_t j = 0; j < nc; j++) - T[(ne + 1) * nc + j] += T[ia * nc + j]; - // The result in column ja is zero, avoid roundoff - T[(ne + 1) * nc + ja] = 0.0; - } - // - // index of current objective - size_t iobj = ne; // original objective z - if( na > 0 ) - iobj = ne + 1; // auxillary objective w - // - // simplex interations - for(size_t itr = 0; itr < maxitr; itr++) - { // current value for xout - for(size_t j = 0; j < nx; j++) - { xout[j] = 0.0; - if( basic[j] ) - { // determine which row of column j is non-zero - xout[j] = std::numeric_limits::quiet_NaN(); - for(size_t i = 0; i < ne; i++) - { double T_ij = T[i * nc + j]; - CPPAD_ASSERT_UNKNOWN( T_ij == 0.0 || T_ij == 1.0 ); - if( T_ij == 1.0 ) - { // corresponding value in right hand side - xout[j] = T[ i * nc + (nc-1) ]; - } - } - } - } - if( level > 1 ) - CppAD::abs_print_mat("T", nr, nc, T); - if( level > 0 ) - { CppAD::abs_print_mat("x", nx, 1, xout); - std::cout << "itr = " << itr; - if( iobj > ne ) - std::cout << ", auxillary objective w = "; - else - std::cout << ", objective z = "; - std::cout << T[iobj * nc + (nc - 1)] << "\n"; - } - // - // number of variables depends on objective - size_t nv = nx + ne; // (x, s) - if( iobj == ne + 1 ) - { // check if we have solved the auxillary problem - bool done = true; - for(size_t k = 0; k < na; k++) - if( basic[nx + ne + k] ) - done = false; - if( done ) - { // switch to optimizing the original objective - iobj = ne; - } - else - nv = nx + ne + na; // (x, s, a) - } - // - // determine variable with maximuim coefficient in objective row - double cmax = 0.0; - size_t jmax = nv; - for(size_t j = 0; j < nv; j++) - { if( T[iobj * nc + j] > cmax ) - { CPPAD_ASSERT_UNKNOWN( ! basic[j] ); - cmax = T[ iobj * nc + j]; - jmax = j; - } - } - // check for solution - if( jmax == nv ) - { if( iobj == ne ) - { if( level > 0 ) - std::cout << "end simplex_method\n"; - return true; - } - if( level > 0 ) - std::cout << "end_simples_method: no feasible solution\n"; - return false; - } - // - // We will increase the j-th variable. - // Determine which row will be the pivot row. - double rmin = std::numeric_limits::infinity(); - size_t imin = ne; - for(size_t i = 0; i < ne; i++) - { if( T[i * nc + jmax] > 0.0 ) - { double r = T[i * nc + (nc-1) ] / T[i * nc + jmax]; - if( r < rmin ) - { rmin = r; - imin = i; - } - } - } - if( imin == ne ) - { // not auxillary objective - CPPAD_ASSERT_UNKNOWN( iobj == ne ); - if( level > 0 ) std::cout - << "end simplex_method: objective is unbounded below\n"; - return false; - } - double pivot = T[imin * nc + jmax]; - // - // Which variable is changing from basic to non-basic. - // Initilaize as not yet determined. - size_t basic2not = nc; - // - // Divide row imin by pivot element - for(size_t j = 0; j < nc; j++) - { if( basic[j] && T[imin * nc + j] == 1.0 ) - { CPPAD_ASSERT_UNKNOWN( basic2not == nc ); - basic2not = j; - } - T[imin * nc + j] /= pivot; - } - // The result in column jmax is one, avoid roundoff - T[imin * nc + jmax ] = 1.0; - // - // Check that we found the variable going from basic to non-basic - CPPAD_ASSERT_UNKNOWN( basic2not < nv && basic2not != jmax ); - // - // convert variable for column jmax to basic - // and for column basic2not to non-basic - for(size_t i = 0; i < nr; i++) if( i != imin ) - { double r = T[i * nc + jmax ] / T[imin * nc + jmax]; - // row_i = row_i - r * row_imin - for(size_t j = 0; j < nc; j++) - T[i * nc + j] -= r * T[imin * nc + j]; - // The result in column jmax is zero, avoid roundoff - T[i * nc + jmax] = 0.0; - } - // update flag for basic variables - basic[ basic2not ] = false; - basic[ jmax ] = true; - } - if( level > 0 ) std::cout - << "end simplex_method: maximum # iterations without solution\n"; - return false; +{ // number of equations + size_t ne = b.size(); + // number of x variables + size_t nx = c.size(); + CPPAD_ASSERT_UNKNOWN( size_t(A.size()) == ne * nx ); + CPPAD_ASSERT_UNKNOWN( level <= 2 ); + // + if( level > 0 ) + { std::cout << "start simplex_method\n"; + CppAD::abs_print_mat("A", ne, nx, A); + CppAD::abs_print_mat("b", ne, 1, b); + CppAD::abs_print_mat("c", nx, 1, c); + } + // + // variables (columns) in the Tableau: + // x: the original primary variables with size n + // s: slack variables, one for each equation + // a: auxillary variables, one for each negative right hand size + // r: right hand size for equations + // + // Determine number of auxillary variables + size_t na = 0; + for(size_t i = 0; i < ne; i++) + { if( b[i] > 0.0 ) + ++na; + } + // size of columns in the Tableau + size_t nc = nx + ne + na + 1; + + // number of rows in Tableau, the equations plust two objectives + size_t nr = ne + 2; + + // Initilize Tableau as zero + Vector T(nr * nc); + for(size_t i = 0; i < nr * nc; i++) + T[i] = 0.0; + + // initialize basic variable flag as false + CppAD::vector basic(nc); + for(size_t j = 0; j < nc; j++) + basic[j] = false; + + // For i = 0 , ... , m-1, place the Equations + // sum_j A_{i,j} * x_j + b_i <= 0 in Tableau + na = 0; // use as index of next auxillary variable + for(size_t i = 0; i < ne; i++) + { if( b[i] > 0.0) + { // convert to - sum_j A_{i,j} x_j - b_i >= 0 + for(size_t j = 0; j < nx; j++) + T[i * nc + j] = - A[i * nx + j]; + // slack variable has negative coefficient + T[i * nc + (nx + i)] = -1.0; + // auxillary variable is basic for this constraint + T[i * nc + (nx + ne + na)] = 1.0; + basic[nx + ne + na] = true; + // right hand side + T[i * nc + (nc - 1)] = b[i]; + // + ++na; + } + else + { // sum_j A_{i,j} x_j + b_i <= 0 + for(size_t j = 0; j < nx; j++) + T[i * nc + j] = A[i * nx + j]; + // slack variable is also basic + T[ i * nc + (nx + i) ] = 1.0; + basic[nx + i] = true; + // right hand side for equations + T[ i * nc + (nc - 1) ] = - b[i]; + } + } + // na is back to its original value + CPPAD_ASSERT_UNKNOWN( nc == nx + ne + na + 1 ); + // + // place the equation objective equation in Tablueau + // row ne corresponds to the equation z - sum_j c_j x_j = 0 + // column index for z is nx + ne + na + for(size_t j = 0; j < nx; j++) + T[ne * nc + j] = - c[j]; + // + // row ne+1 corresponds to the equation w - a_0 - ... - a_{na-1} = 0 + // column index for w is nx + ne + na +1 + for(size_t j = 0; j < na; j++) + T[(ne + 1) * nc + (nx + ne + j)] = -1.0; + // + // fix auxillary objective so coefficients in w + // for auxillary variables are zero + for(size_t k = 0; k < na; k++) + { size_t ja = nx + ne + k; + size_t ia = ne; + for(size_t i = 0; i < ne; i++) + { if( T[i * nc + ja] != 0.0 ) + { CPPAD_ASSERT_UNKNOWN( T[i * nc + ja] == 1.0 ); + CPPAD_ASSERT_UNKNOWN( T[(ne + 1) * nc + ja] == -1.0 ) + CPPAD_ASSERT_UNKNOWN( ia == ne ); + ia = i; + } + } + CPPAD_ASSERT_UNKNOWN( ia < ne ); + for(size_t j = 0; j < nc; j++) + T[(ne + 1) * nc + j] += T[ia * nc + j]; + // The result in column ja is zero, avoid roundoff + T[(ne + 1) * nc + ja] = 0.0; + } + // + // index of current objective + size_t iobj = ne; // original objective z + if( na > 0 ) + iobj = ne + 1; // auxillary objective w + // + // simplex interations + for(size_t itr = 0; itr < maxitr; itr++) + { // current value for xout + for(size_t j = 0; j < nx; j++) + { xout[j] = 0.0; + if( basic[j] ) + { // determine which row of column j is non-zero + xout[j] = std::numeric_limits::quiet_NaN(); + for(size_t i = 0; i < ne; i++) + { double T_ij = T[i * nc + j]; + CPPAD_ASSERT_UNKNOWN( T_ij == 0.0 || T_ij == 1.0 ); + if( T_ij == 1.0 ) + { // corresponding value in right hand side + xout[j] = T[ i * nc + (nc-1) ]; + } + } + } + } + if( level > 1 ) + CppAD::abs_print_mat("T", nr, nc, T); + if( level > 0 ) + { CppAD::abs_print_mat("x", nx, 1, xout); + std::cout << "itr = " << itr; + if( iobj > ne ) + std::cout << ", auxillary objective w = "; + else + std::cout << ", objective z = "; + std::cout << T[iobj * nc + (nc - 1)] << "\n"; + } + // + // number of variables depends on objective + size_t nv = nx + ne; // (x, s) + if( iobj == ne + 1 ) + { // check if we have solved the auxillary problem + bool done = true; + for(size_t k = 0; k < na; k++) + if( basic[nx + ne + k] ) + done = false; + if( done ) + { // switch to optimizing the original objective + iobj = ne; + } + else + nv = nx + ne + na; // (x, s, a) + } + // + // determine variable with maximuim coefficient in objective row + double cmax = 0.0; + size_t jmax = nv; + for(size_t j = 0; j < nv; j++) + { if( T[iobj * nc + j] > cmax ) + { CPPAD_ASSERT_UNKNOWN( ! basic[j] ); + cmax = T[ iobj * nc + j]; + jmax = j; + } + } + // check for solution + if( jmax == nv ) + { if( iobj == ne ) + { if( level > 0 ) + std::cout << "end simplex_method\n"; + return true; + } + if( level > 0 ) + std::cout << "end_simples_method: no feasible solution\n"; + return false; + } + // + // We will increase the j-th variable. + // Determine which row will be the pivot row. + double rmin = std::numeric_limits::infinity(); + size_t imin = ne; + for(size_t i = 0; i < ne; i++) + { if( T[i * nc + jmax] > 0.0 ) + { double r = T[i * nc + (nc-1) ] / T[i * nc + jmax]; + if( r < rmin ) + { rmin = r; + imin = i; + } + } + } + if( imin == ne ) + { // not auxillary objective + CPPAD_ASSERT_UNKNOWN( iobj == ne ); + if( level > 0 ) std::cout + << "end simplex_method: objective is unbounded below\n"; + return false; + } + double pivot = T[imin * nc + jmax]; + // + // Which variable is changing from basic to non-basic. + // Initilaize as not yet determined. + size_t basic2not = nc; + // + // Divide row imin by pivot element + for(size_t j = 0; j < nc; j++) + { if( basic[j] && T[imin * nc + j] == 1.0 ) + { CPPAD_ASSERT_UNKNOWN( basic2not == nc ); + basic2not = j; + } + T[imin * nc + j] /= pivot; + } + // The result in column jmax is one, avoid roundoff + T[imin * nc + jmax ] = 1.0; + // + // Check that we found the variable going from basic to non-basic + CPPAD_ASSERT_UNKNOWN( basic2not < nv && basic2not != jmax ); + // + // convert variable for column jmax to basic + // and for column basic2not to non-basic + for(size_t i = 0; i < nr; i++) if( i != imin ) + { double r = T[i * nc + jmax ] / T[imin * nc + jmax]; + // row_i = row_i - r * row_imin + for(size_t j = 0; j < nc; j++) + T[i * nc + j] -= r * T[imin * nc + j]; + // The result in column jmax is zero, avoid roundoff + T[i * nc + jmax] = 0.0; + } + // update flag for basic variables + basic[ basic2not ] = false; + basic[ jmax ] = true; + } + if( level > 0 ) std::cout + << "end simplex_method: maximum # iterations without solution\n"; + return false; } } // END_CPPAD_NAMESPACE // END C++ diff -Nru cppad-2018.00.00.0/example/abs_normal/simplex_method.omh cppad-2019.02.00.0/example/abs_normal/simplex_method.omh --- cppad-2018.00.00.0/example/abs_normal/simplex_method.omh 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/simplex_method.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin simplex_method.hpp$$ $spell @@ -15,7 +16,7 @@ $section simplex_method Source Code$$ $srcfile%example/abs_normal/simplex_method.hpp% - 0%// BEGIN C++%// END C++% + 0%// BEGIN C++%// END C++% 0%$$ $end diff -Nru cppad-2018.00.00.0/example/abs_normal/talk.tex cppad-2019.02.00.0/example/abs_normal/talk.tex --- cppad-2018.00.00.0/example/abs_normal/talk.tex 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/abs_normal/talk.tex 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,229 @@ +% ----------------------------------------------------------------------------- +% CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +% +% CppAD is distributed under the terms of the +% Eclipse Public License Version 2.0. +% +% This Source Code may also be made available under the following +% Secondary License when the conditions for such availability set forth +% in the Eclipse Public License, Version 2.0 are satisfied: +% GNU General Public License, Version 2.0 or later. +% ----------------------------------------------------------------------------- +\documentclass{beamer} + +% needed for fonts; see %https://tex.stackexchange.com/questions/58087/ +% how-to-remove-the-warnings-font-shape-ot1-cmss-m-n-in-size-4-not-available +\usepackage{lmodern}% http://ctan.org/pkg/lm + +% macros +\newcommand{\B}[1]{{\bf #1}} + + +\title[CppAD]{CppAD's Abs-normal Representation} +\institute{ + \begin{tabular}{c} + {\Large Bradley M. Bell} \\ + \\ + Applied Physics Laboratory and \\ + Institute for Health Metrics and Evaluation, \\ + University of Washington, \\ + \texttt{bradbell@uw.edu} \\ + \end{tabular} +} + +\begin{document} + +\begin{frame} + \titlepage +\end{frame} + + + +% ---------------------------------------------------------------------------- +\begin{frame}{Non-Smooth Functions} + +\begin{block}{$f(x)$} +$ f : \B{R}^n \rightarrow \B{R}^m $ where the only non-smooth +nodes in its computational graph are $| \cdot |$. +\end{block} +\pause + +\begin{block}{$a(x)$} +Let $s$ be number of $| \cdot |$ in $f$. +We define +$a : \B{R}^n \rightarrow \B{R}^s$ where +$a_i (x)$ is the result for the $i$-th absolute value. +\end{block} + +\end{frame} +% ---------------------------------------------------------------------------- +\begin{frame}{Smooth Functions} + +\begin{block}{$z(x,u)$} +There is a smooth +$z : \B{R}^{n + s} \rightarrow \B{R}^s$ where +$z_i (x, u)$ is argument to $i$-th absolute value +when $u_j = a_j (x)$ for $j < i$. +\end{block} +\pause + +\begin{block}{$y(x,u)$} +There is a smooth +$y : \B{R}^{n + s} \rightarrow \B{R}^m$ where +$y(x , u) = f(x)$ when $u = a (x)$ for all $i$. +\end{block} +\pause + +\begin{block}{$g(x,u)$} +The function +$g : \B{R}^{n + s} \rightarrow \B{R}^{m + s}$ is defined by +\[ +g(x, u) = \left[ \begin{array}{c} y(x, u) \\ z(x, y) \end{array} \right] +\] +\end{block} + +\end{frame} +% ---------------------------------------------------------------------------- +\begin{frame}{Approximating $a(x)$} + +\[ +z[ \hat{x} ]( x , u ) += +z ( \hat{x}, a( \hat{x} ) ) + + \partial_x z ( \hat{x}, a( \hat{x} ) ) ( x - \hat{x} ) + + \partial_u z ( \hat{x}, a( \hat{x} ) ) ( u - a( \hat{x} ) ) +\] +\pause + +Note that $z_0 ( x , u )$ does not depend on $u$: +\[ +a_0 [ \hat{x} ]( x ) += +\left| + z_0 ( \hat{x}, a( \hat{x} ) ) + + \partial_x z_0 ( \hat{x}, a( \hat{x} ) ) ( x - \hat{x} ) +\right| +\] +\pause + +\begin{eqnarray*} +a_i [ \hat{x} ]( x ) +& = & +\left | \vphantom{ \sum_{j < i} } z_i ( \hat{x}, a( \hat{x} ) ) + + \partial_x z_i ( \hat{x}, a( \hat{x} ) ) ( x - \hat{x} ) +\right. +\\ +& + & +\left. \sum_{j < i} \partial_{u(j)} z_i ( \hat{x}, a( \hat{x} ) ) + ( a_j [ \hat{x} ] ( x ) - a_j ( \hat{x} ) ) +\right| +\end{eqnarray*} +\pause + +\[ +a(x) = a[ \hat{x} ]( x ) + o( x - \hat{x} ) +\phantom{\rule{1in}{1pt}} +\] + + +\end{frame} +% ---------------------------------------------------------------------------- +\begin{frame}{Representation} + +\begin{block}{ \texttt{f.abs\_normal\_fun(g, a)} } +Given the \texttt{ADFun} object \texttt{f} for $f(x)$, +this creates the two \texttt{ADFun} objects \texttt{g}, \texttt{a} +for $g(x, u)$ and $a(x)$ respectively. +\end{block} +\pause + +\begin{block}{Advantages} +Any AD operation can be computed for the smooth function \texttt{g}; e.g., +any order forward and reverse mode, sparsity patterns, and sparse derivatives. +\end{block} + +\end{frame} +% ---------------------------------------------------------------------------- +\begin{frame}{Approximating $f(x)$} + +\[ +y[ \hat{x} ]( x , u ) += +y ( \hat{x}, a( \hat{x} ) ) + + \partial_x y ( \hat{x}, a( \hat{x} ) ) ( x - \hat{x} ) + + \partial_u y ( \hat{x}, a( \hat{x} ) ) ( u - a( \hat{x} ) ) +\] +\pause + + +\[ +f(x) = y[ \hat{x} ] ( x , a[ \hat{x} ] (x) ) + o ( x - \hat{x} ) +\phantom{\rule{1.3in}{1pt}} +\] + +\begin{block}{ \texttt{abs\_eval(n, m, s, g\_hat , g\_jac , delta\_x)} } +Evaluates $y[ \hat{x} ] ( x , a[ \hat{x} ] (x) )$ +\end{block} +\pause + +\begin{itemize} + +\item +\texttt{g\_hat} is $g[ \hat{x} , a( \hat{x} ) ]$ +\pause + +\item +\texttt{g\_jac} is $g^{(1)} [ \hat{x} , a( \hat{x} ) ]$ +\pause + +\item +\texttt{delta\_x} is $x - \hat{x}$ + +\end{itemize} + + +\end{frame} +% ---------------------------------------------------------------------------- + +\begin{frame}{ \texttt{abs\_min\_linear} } + +\begin{block}{Problem} +minimize $\tilde{f} ( x ) = y[ \hat{x} ] ( x , a( \hat{x} ) )$ w.r.t +$x$ subject to $-b \leq x \leq b$ using the assumption +that $\tilde{f} (x)$ is convex. +\end{block} +\pause + + +\begin{block}{Algorithm} +\begin{enumerate} + +\item +Start at with point $x = \hat{x}$ and $C$ an empty set of +cutting planes. +\pause + +\item +\label{NextIterationItem} +Add affine apprimation for $\tilde{f} ( x )$ at $x$ to $C$. +\pause + + +\item +Minimize w.r.t $x$ the maximum of the affine functions in $C$ +subject to $-b \leq x \leq b$ (this is an LP). +\pause + + +\item +If change in $x$ for this this iteration is small, return $x$ as solution. +Otherwise, goto step \ref{NextIterationItem}. + +\end{enumerate} +\end{block} + + +\end{frame} + + +\end{document} diff -Nru cppad-2018.00.00.0/example/atomic/atomic.cpp cppad-2019.02.00.0/example/atomic/atomic.cpp --- cppad-2018.00.00.0/example/atomic/atomic.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/atomic.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ - -// CPPAD_HAS_* defines -# include - -// system include files used for I/O -# include - -// C style asserts -# include - -// for thread_alloc -# include - -// test runner -# include - -// external complied tests -extern bool checkpoint(void); -extern bool eigen_cholesky(void); -extern bool eigen_mat_inv(void); -extern bool eigen_mat_mul(void); -extern bool extended_ode(void); -extern bool for_sparse_hes(void); -extern bool for_sparse_jac(void); -extern bool forward(void); -extern bool get_started(void); -extern bool mat_mul(void); -extern bool mul_level(void); -extern bool norm_sq(void); -extern bool ode(void); -extern bool reciprocal(void); -extern bool rev_sparse_hes(void); -extern bool rev_sparse_jac(void); -extern bool reverse(void); -extern bool set_sparsity(void); -extern bool tangent(void); - -// main program that runs all the tests -int main(void) -{ std::string group = "example/atomic"; - size_t width = 20; - CppAD::test_boolofvoid Run(group, width); - - // This line is used by test_one.sh - - // external compiled tests - Run( checkpoint, "checkpoint" ); - Run( extended_ode, "extended_ode" ); - Run( for_sparse_hes, "for_sparse_hes" ); - Run( for_sparse_jac, "for_sparse_jac" ); - Run( forward, "forward" ); - Run( get_started, "get_started" ); - Run( mat_mul, "mat_mul" ); - Run( mul_level, "mul_level" ); - Run( norm_sq, "norm_sq" ); - Run( ode, "ode" ); - Run( reciprocal, "reciprocal" ); - Run( rev_sparse_hes, "rev_sparse_hes" ); - Run( rev_sparse_jac, "rev_sparse_jac" ); - Run( reverse, "reverse" ); - Run( set_sparsity, "set_sparsity" ); - Run( tangent, "tangent" ); -# if CPPAD_HAS_EIGEN - Run( eigen_cholesky, "eigen_cholesky" ); - Run( eigen_mat_inv, "eigen_mat_inv" ); - Run( eigen_mat_mul, "eigen_mat_mul" ); -# endif - // check for memory leak - bool memory_ok = CppAD::thread_alloc::free_all(); - // print summary at end - bool ok = Run.summary(memory_ok); - // - return static_cast( ! ok ); -} diff -Nru cppad-2018.00.00.0/example/atomic/checkpoint.cpp cppad-2019.02.00.0/example/atomic/checkpoint.cpp --- cppad-2018.00.00.0/example/atomic/checkpoint.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/checkpoint.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,194 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 checkpoint.cpp$$ -$spell - checkpointing - Taylor -$$ - -$section Simple Checkpointing: Example and Test$$ - -$head Purpose$$ -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 -for this example there are only two. -The functions -$latex F : \B{R}^2 \rightarrow \B{R}^2$$ -and -$latex G : \B{R}^2 \rightarrow \B{R}^2$$ -defined by -$latex \[ - F(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} - x_0 \cdot x_0 \cdot x_0 - \\ - x_1 \cdot x_1 \cdot x_1 - \end{array} \right) -\] $$ - -$code -$srcfile%example/atomic/checkpoint.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - - -$end -*/ -// BEGIN C++ - -# include - -namespace { - using CppAD::AD; - typedef CPPAD_TESTVECTOR(AD) ADVector; - typedef CppAD::atomic_base::option_enum option_enum; - - 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 < 3; k++) - { y[0] *= x[0]; - y[1] *= x[1]; - } - return; - } - bool test_case( - option_enum f_sparsity, option_enum g_sparsity, bool optimize ) - { 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 because 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 / double(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)); - for(i = 0; i < m * (q + 1); i++) - w[i] = 1.0 / double(i + 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 &= r_not[i] == r_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; - - // 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, true); - ok &= test_case(pack_sparsity, bool_sparsity, false); - ok &= test_case(bool_sparsity, set_sparsity, true); - ok &= test_case(set_sparsity, set_sparsity, false); - - return ok; -} -// END C++ diff -Nru cppad-2018.00.00.0/example/atomic/CMakeLists.txt cppad-2019.02.00.0/example/atomic/CMakeLists.txt --- cppad-2018.00.00.0/example/atomic/CMakeLists.txt 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. -# ----------------------------------------------------------------------------- -# -# eigen_sources and CPPAD_HAS_EIGEN -IF( cppad_has_eigen ) - SET(eigen_sources eigen_mat_inv.cpp eigen_cholesky.cpp eigen_mat_mul.cpp) -ELSE( cppad_has_eigen ) - SET(eigen_sources "") -ENDIF( cppad_has_eigen ) -# -SET(source_list - ${eigen_sources} - atomic.cpp - checkpoint.cpp - extended_ode.cpp - for_sparse_hes.cpp - for_sparse_jac.cpp - forward.cpp - get_started.cpp - mat_mul.cpp - mul_level.cpp - norm_sq.cpp - ode.cpp - reciprocal.cpp - rev_sparse_hes.cpp - rev_sparse_jac.cpp - reverse.cpp - set_sparsity.cpp - tangent.cpp -) -set_compile_flags( example_atomic "${cppad_debug_which}" "${source_list}" ) -# -ADD_EXECUTABLE(example_atomic EXCLUDE_FROM_ALL ${source_list}) -# -# Add the check_example_atomic target -ADD_CUSTOM_TARGET(check_example_atomic - example_atomic - DEPENDS example_atomic -) -MESSAGE(STATUS "make check_example_atomic: available") -# -# add to check check_example_depends in parent environment -add_to_list(check_example_depends check_example_atomic) -SET(check_example_depends "${check_example_depends}" PARENT_SCOPE) diff -Nru cppad-2018.00.00.0/example/atomic/eigen_cholesky.cpp cppad-2019.02.00.0/example/atomic/eigen_cholesky.cpp --- cppad-2018.00.00.0/example/atomic/eigen_cholesky.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/eigen_cholesky.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,237 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_eigen_cholesky.cpp$$ -$spell - Eigen - Cholesky -$$ - -$section Atomic Eigen Cholesky Factorization: Example and Test$$ - -$head Description$$ -The $cref ADFun$$ function object $icode f$$ for this example is -$latex \[ -f(x) -= -\R{chol} \left( \begin{array}{cc} - x_0 & x_1 \\ - x_1 & x_2 -\end{array} \right) -= -\frac{1}{ \sqrt{x_0} } -\left( \begin{array}{cc} - x_0 & 0 \\ - x_1 & \sqrt{ x_0 x_2 - x_1 x_1 } -\end{array} \right) -\] $$ -where the matrix is positive definite; i.e., -$latex x_0 > 0$$, $latex x_2 > 0$$ and -$latex x_0 x_2 - x_1 x_1 > 0$$. - -$childtable%omh/appendix/theory/cholesky.omh - %cppad/example/eigen_cholesky.hpp -%$$ - -$head Use Atomic Function$$ -$srccode%cpp% */ -# include -# include - - -bool eigen_cholesky(void) -{ - typedef double scalar; - typedef typename atomic_eigen_cholesky::ad_scalar ad_scalar; - typedef typename atomic_eigen_cholesky::ad_matrix ad_matrix; - // - bool ok = true; - scalar eps = 10. * std::numeric_limits::epsilon(); - using CppAD::NearEqual; - // -/* %$$ -$subhead Constructor$$ -$srccode%cpp% */ - // ------------------------------------------------------------------- - // object that computes cholesky factor of a matrix - atomic_eigen_cholesky cholesky; - // ------------------------------------------------------------------- - // declare independent variable vector x - size_t n = 3; - CPPAD_TESTVECTOR(ad_scalar) ad_x(n); - ad_x[0] = 2.0; - ad_x[1] = 0.5; - ad_x[2] = 3.0; - CppAD::Independent(ad_x); - // ------------------------------------------------------------------- - // A = [ x[0] x[1] ] - // [ x[1] x[2] ] - size_t nr = 2; - ad_matrix ad_A(nr, nr); - ad_A(0, 0) = ad_x[0]; - ad_A(1, 0) = ad_x[1]; - ad_A(0, 1) = ad_x[1]; - ad_A(1, 1) = ad_x[2]; - // ------------------------------------------------------------------- - // use atomic operation to L such that A = L * L^T - ad_matrix ad_L = cholesky.op(ad_A); - // ------------------------------------------------------------------- - // declare the dependent variable vector y - size_t m = 3; - CPPAD_TESTVECTOR(ad_scalar) ad_y(m); - ad_y[0] = ad_L(0, 0); - ad_y[1] = ad_L(1, 0); - ad_y[2] = ad_L(1, 1); - CppAD::ADFun f(ad_x, ad_y); - // ------------------------------------------------------------------- - // check zero order forward mode - CPPAD_TESTVECTOR(scalar) x(n), y(m); - x[0] = 2.0; - x[1] = 0.5; - x[2] = 5.0; - y = f.Forward(0, x); - scalar check; - check = std::sqrt( x[0] ); - ok &= NearEqual(y[0], check, eps, eps); - check = x[1] / std::sqrt( x[0] ); - ok &= NearEqual(y[1], check, eps, eps); - check = std::sqrt( x[2] - x[1] * x[1] / x[0] ); - ok &= NearEqual(y[2], check, eps, eps); - // ------------------------------------------------------------------- - // check first order forward mode - CPPAD_TESTVECTOR(scalar) x1(n), y1(m); - // - // partial w.r.t. x[0] - x1[0] = 1.0; - x1[1] = 0.0; - x1[2] = 0.0; - // - y1 = f.Forward(1, x1); - check = 1.0 / (2.0 * std::sqrt( x[0] ) ); - ok &= NearEqual(y1[0], check, eps, eps); - // - check = - x[1] / (2.0 * x[0] * std::sqrt( x[0] ) ); - ok &= NearEqual(y1[1], check, eps, eps); - // - check = std::sqrt( x[2] - x[1] * x[1] / x[0] ); - check = x[1] * x[1] / (x[0] * x[0] * 2.0 * check); - ok &= NearEqual(y1[2], check, eps, eps); - // - // partial w.r.t. x[1] - x1[0] = 0.0; - x1[1] = 1.0; - x1[2] = 0.0; - // - y1 = f.Forward(1, x1); - ok &= NearEqual(y1[0], 0.0, eps, eps); - // - check = 1.0 / std::sqrt( x[0] ); - ok &= NearEqual(y1[1], check, eps, eps); - // - check = std::sqrt( x[2] - x[1] * x[1] / x[0] ); - check = - 2.0 * x[1] / (2.0 * check * x[0] ); - ok &= NearEqual(y1[2], check, eps, eps); - // - // partial w.r.t. x[2] - x1[0] = 0.0; - x1[1] = 0.0; - x1[2] = 1.0; - // - y1 = f.Forward(1, x1); - ok &= NearEqual(y1[0], 0.0, eps, eps); - ok &= NearEqual(y1[1], 0.0, eps, eps); - // - check = std::sqrt( x[2] - x[1] * x[1] / x[0] ); - check = 1.0 / (2.0 * check); - ok &= NearEqual(y1[2], check, eps, eps); - // ------------------------------------------------------------------- - // check second order forward mode - CPPAD_TESTVECTOR(scalar) x2(n), y2(m); - // - // second partial w.r.t x[2] - x2[0] = 0.0; - x2[1] = 0.0; - x2[2] = 0.0; - y2 = f.Forward(2, x2); - ok &= NearEqual(y2[0], 0.0, eps, eps); - ok &= NearEqual(y2[1], 0.0, eps, eps); - // - check = std::sqrt( x[2] - x[1] * x[1] / x[0] ); // funciton value - check = - 1.0 / ( 4.0 * check * check * check ); // second derivative - check = 0.5 * check; // taylor coefficient - ok &= NearEqual(y2[2], check, eps, eps); - // ------------------------------------------------------------------- - // check first order reverse mode - CPPAD_TESTVECTOR(scalar) w(m), d1w(n); - w[0] = 0.0; - w[1] = 0.0; - w[2] = 1.0; - d1w = f.Reverse(1, w); - // - // partial of f[2] w.r.t x[0] - scalar f2 = std::sqrt( x[2] - x[1] * x[1] / x[0] ); - scalar f2_x0 = x[1] * x[1] / (2.0 * f2 * x[0] * x[0] ); - ok &= NearEqual(d1w[0], f2_x0, eps, eps); - // - // partial of f[2] w.r.t x[1] - scalar f2_x1 = - x[1] / (f2 * x[0] ); - ok &= NearEqual(d1w[1], f2_x1, eps, eps); - // - // partial of f[2] w.r.t x[2] - scalar f2_x2 = 1.0 / (2.0 * f2 ); - ok &= NearEqual(d1w[2], f2_x2, eps, eps); - // ------------------------------------------------------------------- - // check second order reverse mode - CPPAD_TESTVECTOR(scalar) d2w(2 * n); - d2w = f.Reverse(2, w); - // - // check first order results - ok &= NearEqual(d2w[0 * 2 + 0], f2_x0, eps, eps); - ok &= NearEqual(d2w[1 * 2 + 0], f2_x1, eps, eps); - ok &= NearEqual(d2w[2 * 2 + 0], f2_x2, eps, eps); - // - // check second order results - scalar f2_x2_x0 = - 0.5 * f2_x0 / (f2 * f2 ); - ok &= NearEqual(d2w[0 * 2 + 1], f2_x2_x0, eps, eps); - scalar f2_x2_x1 = - 0.5 * f2_x1 / (f2 * f2 ); - ok &= NearEqual(d2w[1 * 2 + 1], f2_x2_x1, eps, eps); - scalar f2_x2_x2 = - 0.5 * f2_x2 / (f2 * f2 ); - ok &= NearEqual(d2w[2 * 2 + 1], f2_x2_x2, eps, eps); - // ------------------------------------------------------------------- - // check third order reverse mode - CPPAD_TESTVECTOR(scalar) d3w(3 * n); - d3w = f.Reverse(3, w); - // - // check first order results - ok &= NearEqual(d3w[0 * 3 + 0], f2_x0, eps, eps); - ok &= NearEqual(d3w[1 * 3 + 0], f2_x1, eps, eps); - ok &= NearEqual(d3w[2 * 3 + 0], f2_x2, eps, eps); - // - // check second order results - ok &= NearEqual(d3w[0 * 3 + 1], f2_x2_x0, eps, eps); - ok &= NearEqual(d3w[1 * 3 + 1], f2_x2_x1, eps, eps); - ok &= NearEqual(d3w[2 * 3 + 1], f2_x2_x2, eps, eps); - // ------------------------------------------------------------------- - scalar f2_x2_x2_x0 = - 0.5 * f2_x2_x0 / (f2 * f2); - f2_x2_x2_x0 += f2_x2 * f2_x0 / (f2 * f2 * f2); - ok &= NearEqual(d3w[0 * 3 + 2], 0.5 * f2_x2_x2_x0, eps, eps); - scalar f2_x2_x2_x1 = - 0.5 * f2_x2_x1 / (f2 * f2); - f2_x2_x2_x1 += f2_x2 * f2_x1 / (f2 * f2 * f2); - ok &= NearEqual(d3w[1 * 3 + 2], 0.5 * f2_x2_x2_x1, eps, eps); - scalar f2_x2_x2_x2 = - 0.5 * f2_x2_x2 / (f2 * f2); - f2_x2_x2_x2 += f2_x2 * f2_x2 / (f2 * f2 * f2); - ok &= NearEqual(d3w[2 * 3 + 2], 0.5 * f2_x2_x2_x2, eps, eps); - return ok; -} -/* %$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/eigen_mat_inv.cpp cppad-2019.02.00.0/example/atomic/eigen_mat_inv.cpp --- cppad-2018.00.00.0/example/atomic/eigen_mat_inv.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/eigen_mat_inv.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,187 +0,0 @@ -// $Id$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_eigen_mat_inv.cpp$$ -$spell - mul - Eigen -$$ - -$section Atomic Eigen Matrix Inverse: Example and Test$$ - -$head Description$$ -The $cref ADFun$$ function object $icode f$$ for this example is -$latex \[ -f(x) = -\left( \begin{array}{cc} - x_0 & 0 \\ - 0 & x_1 -\end{array} \right)^{-1} -\left( \begin{array}{c} - 0 \\ - x_2 -\end{array} \right) -= -\left( \begin{array}{c} - 0 \\ - x_2 / x_1 ) -\end{array} \right) -\] $$ - -$children% - cppad/example/eigen_mat_inv.hpp -%$$ - -$head Class Definition$$ -This example uses the file $cref atomic_eigen_mat_inv.hpp$$ -which defines matrix multiply as a $cref atomic_base$$ operation. - -$nospell - -$head Use Atomic Function$$ -$srccode%cpp% */ -# include -# include -# include - - -bool eigen_mat_inv(void) -{ - typedef double scalar; - typedef CppAD::AD ad_scalar; - typedef typename atomic_eigen_mat_inv::ad_matrix ad_matrix; - // - bool ok = true; - scalar eps = 10. * std::numeric_limits::epsilon(); - using CppAD::NearEqual; - // -/* %$$ -$subhead Constructor$$ -$srccode%cpp% */ - // ------------------------------------------------------------------- - // object that multiplies matrices - atomic_eigen_mat_mul mat_mul; - // ------------------------------------------------------------------- - // object that computes inverse of a square matrix - atomic_eigen_mat_inv mat_inv; - // ------------------------------------------------------------------- - // declare independent variable vector x - size_t n = 3; - CPPAD_TESTVECTOR(ad_scalar) ad_x(n); - for(size_t j = 0; j < n; j++) - ad_x[j] = ad_scalar(j + 1); - CppAD::Independent(ad_x); - // ------------------------------------------------------------------- - // left = [ x[0] 0 ] - // [ 0 x[1] ] - size_t nr_left = 2; - ad_matrix ad_left(nr_left, nr_left); - ad_left(0, 0) = ad_x[0]; - ad_left(0, 1) = ad_scalar(0.0); - ad_left(1, 0) = ad_scalar(0.0); - ad_left(1, 1) = ad_x[1]; - // ------------------------------------------------------------------- - // right = [ 0 , x[2] ]^T - size_t nc_right = 1; - ad_matrix ad_right(nr_left, nc_right); - ad_right(0, 0) = ad_scalar(0.0); - ad_right(1, 0) = ad_x[2]; - // ------------------------------------------------------------------- - // use atomic operation to compute left^{-1} - ad_matrix ad_left_inv = mat_inv.op(ad_left); - // use atomic operation to multiply left^{-1} * right - ad_matrix ad_result = mat_mul.op(ad_left_inv, ad_right); - // ------------------------------------------------------------------- - // declare the dependent variable vector y - size_t m = 2; - CPPAD_TESTVECTOR(ad_scalar) ad_y(2); - for(size_t i = 0; i < m; i++) - ad_y[i] = ad_result(i, 0); - CppAD::ADFun f(ad_x, ad_y); - // ------------------------------------------------------------------- - // check zero order forward mode - CPPAD_TESTVECTOR(scalar) x(n), y(m); - for(size_t i = 0; i < n; i++) - x[i] = scalar(i + 2); - y = f.Forward(0, x); - ok &= NearEqual(y[0], 0.0, eps, eps); - ok &= NearEqual(y[1], x[2] / x[1], eps, eps); - // ------------------------------------------------------------------- - // check first order forward mode - CPPAD_TESTVECTOR(scalar) x1(n), y1(m); - x1[0] = 1.0; - x1[1] = 0.0; - x1[2] = 0.0; - y1 = f.Forward(1, x1); - ok &= NearEqual(y1[0], 0.0, eps, eps); - ok &= NearEqual(y1[1], 0.0, eps, eps); - x1[0] = 0.0; - x1[1] = 0.0; - x1[2] = 1.0; - y1 = f.Forward(1, x1); - ok &= NearEqual(y1[0], 0.0, eps, eps); - ok &= NearEqual(y1[1], 1.0 / x[1], eps, eps); - x1[0] = 0.0; - x1[1] = 1.0; - x1[2] = 0.0; - y1 = f.Forward(1, x1); - ok &= NearEqual(y1[0], 0.0, eps, eps); - ok &= NearEqual(y1[1], - x[2] / (x[1]*x[1]), eps, eps); - // ------------------------------------------------------------------- - // check second order forward mode - CPPAD_TESTVECTOR(scalar) x2(n), y2(m); - x2[0] = 0.0; - x2[1] = 0.0; - x2[2] = 0.0; - scalar f1_x1_x1 = 2.0 * x[2] / (x[1] * x[1] * x[1] ); - y2 = f.Forward(2, x2); - ok &= NearEqual(y2[0], 0.0, eps, eps); - ok &= NearEqual(y2[1], f1_x1_x1 / 2.0, eps, eps); - // ------------------------------------------------------------------- - // check first order reverse - CPPAD_TESTVECTOR(scalar) w(m), d1w(n); - w[0] = 1.0; - w[1] = 0.0; - d1w = f.Reverse(1, w); - ok &= NearEqual(d1w[0], 0.0, eps, eps); - ok &= NearEqual(d1w[1], 0.0, eps, eps); - ok &= NearEqual(d1w[2], 0.0, eps, eps); - w[0] = 0.0; - w[1] = 1.0; - d1w = f.Reverse(1, w); - ok &= NearEqual(d1w[0], 0.0, eps, eps); - ok &= NearEqual(d1w[1], - x[2] / (x[1]*x[1]), eps, eps); - ok &= NearEqual(d1w[2], 1.0 / x[1], eps, eps); - // ------------------------------------------------------------------- - // check second order reverse - CPPAD_TESTVECTOR(scalar) d2w(2 * n); - d2w = f.Reverse(2, w); - // partial f_1 w.r.t x_0 - ok &= NearEqual(d2w[0 * 2 + 0], 0.0, eps, eps); - // partial f_1 w.r.t x_1 - ok &= NearEqual(d2w[1 * 2 + 0], - x[2] / (x[1]*x[1]), eps, eps); - // partial f_1 w.r.t x_2 - ok &= NearEqual(d2w[2 * 2 + 0], 1.0 / x[1], eps, eps); - // partial f_1 w.r.t x_1, x_0 - ok &= NearEqual(d2w[0 * 2 + 1], 0.0, eps, eps); - // partial f_1 w.r.t x_1, x_1 - ok &= NearEqual(d2w[1 * 2 + 1], f1_x1_x1, eps, eps); - // partial f_1 w.r.t x_1, x_2 - ok &= NearEqual(d2w[2 * 2 + 1], - 1.0 / (x[1]*x[1]), eps, eps); - // ------------------------------------------------------------------- - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/eigen_mat_mul.cpp cppad-2019.02.00.0/example/atomic/eigen_mat_mul.cpp --- cppad-2018.00.00.0/example/atomic/eigen_mat_mul.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/eigen_mat_mul.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,233 +0,0 @@ -// $Id$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_eigen_mat_mul.cpp$$ -$spell - mul - Eigen -$$ - -$section Atomic Eigen Matrix Multiply: Example and Test$$ - -$head Description$$ -The $cref ADFun$$ function object $icode f$$ for this example is -$latex \[ -f(x) = -\left( \begin{array}{cc} - 0 & 0 \\ - 1 & 2 \\ - x_0 & x_1 -\end{array} \right) -\left( \begin{array}{c} - x_0 \\ - x_1 -\end{array} \right) -= -\left( \begin{array}{c} - 0 \\ - x_0 + 2 x_1 \\ - x_0 x_0 + x_1 x_1 ) -\end{array} \right) -\] $$ - -$children% - cppad/example/eigen_mat_mul.hpp -%$$ - -$head Class Definition$$ -This example uses the file $cref atomic_eigen_mat_mul.hpp$$ -which defines matrix multiply as a $cref atomic_base$$ operation. - -$nospell - -$head Use Atomic Function$$ -$srccode%cpp% */ -# include -# include - -bool eigen_mat_mul(void) -{ // - typedef double scalar; - typedef CppAD::AD ad_scalar; - typedef typename atomic_eigen_mat_mul::ad_matrix ad_matrix; - // - bool ok = true; - scalar eps = 10. * std::numeric_limits::epsilon(); - using CppAD::NearEqual; - // -/* %$$ -$subhead Constructor$$ -$srccode%cpp% */ - // ------------------------------------------------------------------- - // object that multiplies arbitrary matrices - atomic_eigen_mat_mul mat_mul; - // ------------------------------------------------------------------- - // declare independent variable vector x - size_t n = 2; - CPPAD_TESTVECTOR(ad_scalar) ad_x(n); - for(size_t j = 0; j < n; j++) - ad_x[j] = ad_scalar(j); - CppAD::Independent(ad_x); - // ------------------------------------------------------------------- - // [ 0 0 ] - // left = [ 1 2 ] - // [ x[0] x[1] ] - size_t nr_left = 3; - size_t n_middle = 2; - ad_matrix ad_left(nr_left, n_middle); - ad_left(0, 0) = ad_scalar(0.0); - ad_left(0, 1) = ad_scalar(0.0); - ad_left(1, 0) = ad_scalar(1.0); - ad_left(1, 1) = ad_scalar(2.0); - ad_left(2, 0) = ad_x[0]; - ad_left(2, 1) = ad_x[1]; - // ------------------------------------------------------------------- - // right = [ x[0] , x[1] ]^T - size_t nc_right = 1; - ad_matrix ad_right(n_middle, nc_right); - ad_right(0, 0) = ad_x[0]; - ad_right(1, 0) = ad_x[1]; - // ------------------------------------------------------------------- - // use atomic operation to multiply left * right - ad_matrix ad_result = mat_mul.op(ad_left, ad_right); - // ------------------------------------------------------------------- - // check that first component of result is a parameter - // and the other components are varaibles. - ok &= Parameter( ad_result(0, 0) ); - ok &= Variable( ad_result(1, 0) ); - ok &= Variable( ad_result(2, 0) ); - // ------------------------------------------------------------------- - // declare the dependent variable vector y - size_t m = 3; - CPPAD_TESTVECTOR(ad_scalar) ad_y(m); - for(size_t i = 0; i < m; i++) - ad_y[i] = ad_result(i, 0); - CppAD::ADFun f(ad_x, ad_y); - // ------------------------------------------------------------------- - // check zero order forward mode - CPPAD_TESTVECTOR(scalar) x(n), y(m); - for(size_t i = 0; i < n; i++) - x[i] = scalar(i + 2); - y = f.Forward(0, x); - ok &= NearEqual(y[0], 0.0, eps, eps); - ok &= NearEqual(y[1], x[0] + 2.0 * x[1], eps, eps); - ok &= NearEqual(y[2], x[0] * x[0] + x[1] * x[1], eps, eps); - // ------------------------------------------------------------------- - // check first order forward mode - CPPAD_TESTVECTOR(scalar) x1(n), y1(m); - x1[0] = 1.0; - x1[1] = 0.0; - y1 = f.Forward(1, x1); - ok &= NearEqual(y1[0], 0.0, eps, eps); - ok &= NearEqual(y1[1], 1.0, eps, eps); - ok &= NearEqual(y1[2], 2.0 * x[0], eps, eps); - x1[0] = 0.0; - x1[1] = 1.0; - y1 = f.Forward(1, x1); - ok &= NearEqual(y1[0], 0.0, eps, eps); - ok &= NearEqual(y1[1], 2.0, eps, eps); - ok &= NearEqual(y1[2], 2.0 * x[1], eps, eps); - // ------------------------------------------------------------------- - // check second order forward mode - CPPAD_TESTVECTOR(scalar) x2(n), y2(m); - x2[0] = 0.0; - x2[1] = 0.0; - y2 = f.Forward(2, x2); - ok &= NearEqual(y2[0], 0.0, eps, eps); - ok &= NearEqual(y2[1], 0.0, eps, eps); - ok &= NearEqual(y2[2], 1.0, eps, eps); // 1/2 * f_1''(x) - // ------------------------------------------------------------------- - // check first order reverse mode - CPPAD_TESTVECTOR(scalar) w(m), d1w(n); - w[0] = 0.0; - w[1] = 1.0; - w[2] = 0.0; - d1w = f.Reverse(1, w); - ok &= NearEqual(d1w[0], 1.0, eps, eps); - ok &= NearEqual(d1w[1], 2.0, eps, eps); - w[0] = 0.0; - w[1] = 0.0; - w[2] = 1.0; - d1w = f.Reverse(1, w); - ok &= NearEqual(d1w[0], 2.0 * x[0], eps, eps); - ok &= NearEqual(d1w[1], 2.0 * x[1], eps, eps); - // ------------------------------------------------------------------- - // check second order reverse mode - CPPAD_TESTVECTOR(scalar) d2w(2 * n); - d2w = f.Reverse(2, w); - // partial f_2 w.r.t. x_0 - ok &= NearEqual(d2w[0 * 2 + 0], 2.0 * x[0], eps, eps); - // partial f_2 w.r.t x_1 - ok &= NearEqual(d2w[1 * 2 + 0], 2.0 * x[1], eps, eps); - // partial f_2 w.r.t x_1, x_0 - ok &= NearEqual(d2w[0 * 2 + 1], 0.0, eps, eps); - // partial f_2 w.r.t x_1, x_1 - ok &= NearEqual(d2w[1 * 2 + 1], 2.0, eps, eps); - // ------------------------------------------------------------------- - // check forward Jacobian sparsity - CPPAD_TESTVECTOR( std::set ) r(n), s(m); - std::set check_set; - for(size_t j = 0; j < n; j++) - r[j].insert(j); - s = f.ForSparseJac(n, r); - check_set.clear(); - ok &= s[0] == check_set; - check_set.insert(0); - check_set.insert(1); - ok &= s[1] == check_set; - ok &= s[2] == check_set; - // ------------------------------------------------------------------- - // check reverse Jacobian sparsity - r.resize(m); - for(size_t i = 0; i < m; i++) - r[i].insert(i); - s = f.RevSparseJac(m, r); - check_set.clear(); - ok &= s[0] == check_set; - check_set.insert(0); - check_set.insert(1); - ok &= s[1] == check_set; - ok &= s[2] == check_set; - // ------------------------------------------------------------------- - // check forward Hessian sparsity for f_2 (x) - CPPAD_TESTVECTOR( std::set ) r2(1), s2(1), h(n); - for(size_t j = 0; j < n; j++) - r2[0].insert(j); - s2[0].clear(); - s2[0].insert(2); - h = f.ForSparseHes(r2, s2); - check_set.clear(); - check_set.insert(0); - ok &= h[0] == check_set; - check_set.clear(); - check_set.insert(1); - ok &= h[1] == check_set; - // ------------------------------------------------------------------- - // check reverse Hessian sparsity for f_2 (x) - CPPAD_TESTVECTOR( std::set ) s3(1); - s3[0].clear(); - s3[0].insert(2); - h = f.RevSparseHes(n, s3); - check_set.clear(); - check_set.insert(0); - ok &= h[0] == check_set; - check_set.clear(); - check_set.insert(1); - ok &= h[1] == check_set; - // ------------------------------------------------------------------- - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/extended_ode.cpp cppad-2019.02.00.0/example/atomic/extended_ode.cpp --- cppad-2018.00.00.0/example/atomic/extended_ode.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/extended_ode.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,422 +0,0 @@ -// $Id$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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 checkpoint_extended_ode.cpp$$ -$spell - Checkpointing - Runge-Kutta - mul -$$ - -$section Checkpointing an Extended ODE Solver: Example and Test$$ -$index mul_level, checkpoint$$ - -$head See Also$$ -$cref checkpoint_ode.cpp$$, -$cref atomic_mul_level.cpp$$. - - -$head Discussion$$ -Suppose that we wish to extend an ODE to include derivatives with respect -to some parameter in the ODE. In addition, suppose we wish to -differentiate a function that depends on these derivatives. -Applying checkpointing to at the second level of AD would not work; -see $cref atomic_mul_level.cpp$$ -In this example we show how one can do this by -checkpointing an extended ODE solver. - -$head Problem$$ -We consider the initial value problem with parameter $latex x$$ defined by, -$latex z(0, x) = z_0 (x)$$, -$latex \[ - \partial_t z(t, x ) = h [ x , z(t, x) ] -\]$$ -Note that if $latex t$$ needs to be in the equation, one can define -the first component of $latex z(t, x)$$ to be equal to $latex t$$. - -$head ODE Solver$$ -For this example, we consider the Fourth order Runge-Kutta ODE solver. -Given an approximation solution at time $latex t_k$$ denoted by -$latex \tilde{z}_k (x)$$, and $latex \Delta t = t_{k+1} - t_k$$, -it defines the approximation solution $latex \tilde{z}_{k+1} (x)$$ -at time $latex t_{k+1}$$ by -$latex \[ -\begin{array}{rcl} -h_1 & = & h [ x , \tilde{z}_k (x) ] -\\ -h_2 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_1 / 2 ] -\\ -h_3 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_2 / 2 ] -\\ -h_4 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_3 ] -\\ -\tilde{z}_{k+1} (x) & = & - \tilde{z}_k (x) + \Delta t \; ( h_1 + 2 h_2 + 2 h_3 + h_4 ) / 6 -\end{array} -\] $$ -If $latex \tilde{z}_k (x) = z_k (x)$$, then -$latex \tilde{z}_{k+1} (x) = z_{k+1} (x) + O( \Delta t^5 )$$, then -Other ODE solvers can use a similar method to the one used below. - -$head ODE$$ -For this example the ODE is defined by -$latex z(0, x) = 0$$ and -$latex \[ - h[ x, z(t, x) ] = - \left( \begin{array}{c} - x_0 \\ - x_1 z_0 (t, x) \\ - \vdots \\ - x_{n-1} z_{n-2} (t, x) - \end{array} \right) - = - \left( \begin{array}{c} - \partial_t z_0 (t , x) \\ - \partial_t z_1 (t , x) \\ - \vdots \\ - \partial_t z_{n-1} (t , x) - \end{array} \right) -\] $$ - -$head Solution$$ -The solution of the ODE for this example, -which is used to check the results, -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 -$latex \[ - z(t, x) = - \left( \begin{array}{c} - x_0 t \\ - x_1 x_0 t^2 / 2 \\ - \vdots \\ - x_{n-1} x_{n-2} \ldots x_0 t^n / n ! - \end{array} \right) -\] $$ - - -$code -$srcfile%example/atomic/extended_ode.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ - -# include - -namespace { - using CppAD::AD; - typedef AD a1double; - typedef AD a2double; - // - typedef CPPAD_TESTVECTOR( double ) a0vector; - typedef CPPAD_TESTVECTOR( a1double ) a1vector; - typedef CPPAD_TESTVECTOR( a2double ) a2vector; - // - // set once by main and kept that way - double delta_t_ = std::numeric_limits::quiet_NaN(); - size_t n_ = 0; - // - // The function h( x , y) - template - FloatVector h(const FloatVector& x, const FloatVector& y) - { assert( size_t( x.size() ) == n_ ); - assert( size_t( y.size() ) == n_ ); - FloatVector result(n_); - result[0] = x[0]; - for(size_t i = 1; i < n_; i++) - result[i] = x[i] * y[i-1]; - return result; - } - - // The 4-th Order Runge-Kutta Step - template - FloatVector Runge4(const FloatVector& x, const FloatVector& z0 - ) - { assert( size_t( x.size() ) == n_ ); - assert( size_t( z0.size() ) == n_ ); - // - typedef typename FloatVector::value_type Float; - // - Float dt = Float(delta_t_); - size_t m = z0.size(); - // - FloatVector h1(m), h2(m), h3(m), h4(m), result(m); - h1 = h( x, z0 ); - // - for(size_t i = 0; i < m; i++) - h2[i] = z0[i] + dt * h1[i] / 2.0; - h2 = h( x, h2 ); - // - for(size_t i = 0; i < m; i++) - h3[i] = z0[i] + dt * h2[i] / 2.0; - h3 = h( x, h3 ); - // - for(size_t i = 0; i < m; i++) - h4[i] = z0[i] + dt * h3[i]; - h4 = h( x, h4 ); - // - for(size_t i = 0; i < m; i++) - { Float dz = dt * ( h1[i] + 2.0*h2[i] + 2.0*h3[i] + h4[i] ) / 6.0; - result[i] = z0[i] + dz; - } - return result; - } - - // Derivative of 4-th Order Runge-Kutta Step w.r.t x - a1vector Runge4_x(const a1vector& x, const a1vector& z0) - { assert( size_t( x.size() ) == n_ ); - assert( size_t( z0.size() ) == n_ ); - // - a2vector ax(n_); - for(size_t j = 0; j < n_; j++) - ax[j] = x[j]; - // - a2vector az0(n_); - for(size_t i = 0; i < n_; i++) - az0[i] = z0[i]; - // - CppAD::Independent(ax); - a2vector az(n_); - az = Runge4(ax, az0); - CppAD::ADFun f(ax, az); - // - a1vector result = f.Jacobian(x); - // - return result; - } - - // Derivative of 4-th Order Runge-Kutta Step w.r.t z0 - a1vector Runge4_z0(const a1vector& x, const a1vector& z0) - { assert( size_t( x.size() ) == n_ ); - assert( size_t( z0.size() ) == n_ ); - // - a2vector ax(n_); - for(size_t j = 0; j < n_; j++) - ax[j] = x[j]; - // - a2vector az0(n_); - for(size_t i = 0; i < n_; i++) - az0[i] = z0[i]; - // - CppAD::Independent(az0); - a2vector az(n_); - az = Runge4(ax, az0); - CppAD::ADFun f(az0, az); - // - a1vector result = f.Jacobian(z0); - // - return result; - } - - // pack an extended ode vector - template - void pack( - FloatVector& extended_ode , - const FloatVector& x , - const FloatVector& z , - const FloatVector& z_x ) - { assert( size_t( extended_ode.size() ) == n_ + n_ + n_ * n_ ); - assert( size_t( x.size() ) == n_ ); - assert( size_t( z.size() ) == n_ ); - assert( size_t( z_x.size() ) == n_ * n_ ); - // - size_t offset = 0; - for(size_t i = 0; i < n_; i++) - extended_ode[offset + i] = x[i]; - offset += n_; - for(size_t i = 0; i < n_; i++) - extended_ode[offset + i] = z[i]; - offset += n_; - for(size_t i = 0; i < n_; i++) - { for(size_t j = 0; j < n_; j++) - { // partial of z_i (t , x ) w.r.t x_j - extended_ode[offset + i * n_ + j] = z_x[i * n_ + j]; - } - } - } - - // unpack an extended ode vector - template - void unpack( - const FloatVector& extended_ode , - FloatVector& x , - FloatVector& z , - FloatVector& z_x ) - { assert( size_t( extended_ode.size() ) == n_ + n_ + n_ * n_ ); - assert( size_t( x.size() ) == n_ ); - assert( size_t( z.size() ) == n_ ); - assert( size_t( z_x.size() ) == n_ * n_ ); - // - size_t offset = 0; - for(size_t i = 0; i < n_; i++) - x[i] = extended_ode[offset + i]; - offset += n_; - for(size_t i = 0; i < n_; i++) - z[i] = extended_ode[offset + i]; - offset += n_; - for(size_t i = 0; i < n_; i++) - { for(size_t j = 0; j < n_; j++) - { // partial of z_i (t , x ) w.r.t x_j - z_x[i * n_ + j] = extended_ode[offset + i * n_ + j]; - } - } - } - - // Algorithm that advances the partial of z(t, x) w.r.t x - void ext_ode_algo(const a1vector& ext_ode_in, a1vector& ext_ode_out) - { assert( size_t( ext_ode_in.size() ) == n_ + n_ + n_ * n_ ); - assert( size_t( ext_ode_out.size() ) == n_ + n_ + n_ * n_ ); - // - // initial extended ode information - a1vector x(n_), z0(n_), z0_x(n_ * n_); - unpack(ext_ode_in, x, z0, z0_x); - // - // advance z(t, x) - a1vector z1 = Runge4(x, z0); - // - // partial of z1 w.r.t. x - a1vector z1_x = Runge4_x(x, z0); - // - // partial of z1 w.r.t. z0 - a1vector z1_z0 = Runge4_z0(x, z0); - // - // total derivative of z1 w.r.t x - for(size_t i = 0; i < n_; i++) - { for(size_t j = 0; j < n_; j++) - { a1double sum = 0.0; - for(size_t k = 0; k < n_; k++) - sum += z1_z0 [ i * n_ + k ] * z0_x [ k * n_ + j ]; - z1_x[ i * n_ + j] += sum; - } - } - // - // final extended ode information - pack(ext_ode_out, x, z1, z1_x); - // - return; - } -} -// -bool extended_ode(void) -{ bool ok = true; - using CppAD::NearEqual; - double eps = std::numeric_limits::epsilon(); - // - // number of terms in the differential equation - n_ = 6; - // - // step size for the differentiail equation - size_t n_step = 10; - double T = 1.0; - delta_t_ = T / double(n_step); - // - // set parameter value and initial value of the extended ode - a1vector ax(n_), az0(n_), az0_x(n_ * n_); - for(size_t i = 0; i < n_; i++) - { ax[i] = a1double(i + 1); - az0[i] = a1double(0); - for(size_t j = 0; j < n_; j++) - az0_x[ i * n_ + j ] = 0.0; - } - // - // pack into extended ode information input vector - size_t n_ext = n_ + n_ + n_ * n_; - a1vector aext_ode_in(n_ext); - pack(aext_ode_in, ax, az0, az0_x); - // - // create checkpoint version of the algorithm - a1vector aext_ode_out(n_ext); - CppAD::checkpoint ext_ode_check( - "ext_ode", ext_ode_algo, aext_ode_in, aext_ode_out - ); - // - // set the independent variables for recording - CppAD::Independent( ax ); - // - // repack to get dependence on ax - pack(aext_ode_in, ax, az0, az0_x); - // - // Now run the checkpoint algorithm n_step times - for(size_t k = 0; k < n_step; k++) - { ext_ode_check(aext_ode_in, aext_ode_out); - aext_ode_in = aext_ode_out; - } - // - // Unpack the results (must use ax1 so do not overwrite ax) - a1vector ax1(n_), az1(n_), az1_x(n_ * n_); - unpack(aext_ode_out, ax1, az1, az1_x); - // - // We could record a complicated funciton of x and z_x(T, x) in f, - // but make this example simpler we record x -> z_x(T, x). - CppAD::ADFun f(ax, az1_x); - // - // check function values - a0vector x(n_), z1(n_), z1_x(n_ * n_); - for(size_t j = 0; j < n_; j++) - x[j] = double(j + 1); - z1_x = f.Forward(0, x); - // - // use z(t, x) for checking solution - z1[0] = x[0] * T; - for(size_t i = 1; i < n_; i++) - z1[i] = x[i] * T * z1[i-1] / double(i+1); - // - // expected accuracy for each component of of z(t, x) - a0vector acc(n_); - for(size_t i = 0; i < n_; i++) - { if( i < 4 ) - { // Runge-Kutta methos is exact for this case - acc[i] = 10. * eps; - } - else - { acc[i] = 1.0; - for(size_t k = 0; k < 5; k++) - acc[i] *= x[k] * delta_t_; - } - } - // check z1(T, x) - for(size_t i = 0; i < n_; i++) - { for(size_t j = 0; j < n_; j++) - { // check partial of z1_i w.r.t x_j - double check = 0.0; - if( j <= i ) - check = z1[i] / x[j]; - ok &= NearEqual(z1_x[ i * n_ + j ] , check, acc[i], acc[i]); - } - } - // - // Now use f to compute a derivative. For this 'simple' example it is - // the derivative with respect to x of the - // parital with respect to x[n-1] of z_{n-1} (t , x) - a0vector w(n_ * n_), dw(n_); - for(size_t i = 0; i < n_; i++) - { for(size_t j = 0; j < n_; j++) - { w[ i * n_ + j ] = 0.0; - if( i == n_ - 1 && j == n_ - 1 ) - w[ i * n_ + j ] = 1.0; - } - } - dw = f.Reverse(1, w); - for(size_t j = 0; j < n_; j++) - { double check = 0.0; - if( j < n_ - 1 ) - check = z1[n_ - 1] / ( x[n_ - 1] * x[j] ); - ok &= NearEqual(dw[j] , check, acc[n_-1], acc[n_-1]); - } - // - return ok; -} -// END C++ diff -Nru cppad-2018.00.00.0/example/atomic/for_sparse_hes.cpp cppad-2019.02.00.0/example/atomic/for_sparse_hes.cpp --- cppad-2018.00.00.0/example/atomic/for_sparse_hes.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/for_sparse_hes.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,323 +0,0 @@ -// $Id$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_for_sparse_hes.cpp$$ - -$section Atomic Forward Hessian Sparsity: Example and Test$$ - -$head Purpose$$ -This example demonstrates calculation of the forward Hessian sparsity pattern -for an atomic operation. - -$head function$$ -For this example, the atomic function -$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by -$latex \[ -f( x ) = \left( \begin{array}{c} - x_2 * x_2 \\ - x_0 * x_1 -\end{array} \right) -\] $$ -The Hessians of the component functions are -$latex \[ -f_0^{(2)} ( x ) = \left( \begin{array}{ccc} - 0 & 0 & 0 \\ - 0 & 0 & 0 \\ - 0 & 0 & 2 -\end{array} \right) -\W{,} -f_1^{(2)} ( x ) = \left( \begin{array}{ccc} - 0 & 1 & 0 \\ - 1 & 0 & 0 \\ - 0 & 0 & 0 -\end{array} \right) -\] $$ - -$nospell - -$head Start Class Definition$$ -$srccode%cpp% */ -# include -namespace { // isolate items below to this file -using CppAD::vector; // abbreviate as vector -// -class atomic_for_sparse_hes : public CppAD::atomic_base { -/* %$$ -$head Constructor $$ -$srccode%cpp% */ -public: - // constructor (could use const char* for name) - atomic_for_sparse_hes(const std::string& name) : - // this example only uses pack sparsity patterns - CppAD::atomic_base(name, pack_sparsity_enum) - { } -private: -/* %$$ -$head forward$$ -$srccode%cpp% */ - // forward mode routine called by CppAD - virtual bool forward( - size_t p , - size_t q , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { -# ifndef NDEBUG - size_t n = tx.size() / (q + 1); - size_t m = ty.size() / (q + 1); -# endif - assert( n == 3 ); - assert( m == 2 ); - - // return flag - bool ok = q == 0; - if( ! ok ) - return ok; - - // check for defining variable information - // This case must always be implemented - if( vx.size() > 0 ) - { vy[0] = vx[0]; - vy[1] = vx[0] || vy[0]; - } - - // Order zero forward mode. - // This case must always be implemented - // f(x) = [ x_0 * x_0 ] - // [ x_0 * x_1 ] - assert( p <= 0 ); - if( p <= 0 ) - { ty[0] = tx[2] * tx[2]; - ty[1] = tx[0] * tx[1]; - } - return ok; - } -/* %$$ -$head for_sparse_jac$$ -$srccode%cpp% */ - // forward Jacobian sparsity routine called by CppAD - virtual bool for_sparse_jac( - size_t q , - const CppAD::vectorBool& r , - CppAD::vectorBool& s , - const vector& x ) - { // This function needed because we are using ForSparseHes - // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) -# ifndef NDEBUG - size_t n = r.size() / q; - size_t m = s.size() / q; -# endif - assert( x.size() == n ); - assert( n == 3 ); - assert( m == 2 ); - - - // f'(x) = [ 0, 0, 2 x_2 ] - // [ x_1, x_0, 0 ] - - // sparsity for first row of S(x) = f'(x) * R - size_t i = 0; - for(size_t j = 0; j < q; j++) - s[ i * q + j ] = r[ 2 * q + j ]; - - // sparsity for second row of S(x) = f'(x) * R - i = 1; - for(size_t j = 0; j < q; j++) - s[ i * q + j ] = r[ 0 * q + j ] | r[ 1 * q + j]; - - return true; - } -/* %$$ -$head rev_sparse_jac$$ -$srccode%cpp% */ - // reverse Jacobian sparsity routine called by CppAD - virtual bool rev_sparse_jac( - size_t q , - const CppAD::vectorBool& rt , - CppAD::vectorBool& st , - const vector& x ) - { // This function needed because we are using ForSparseHes - // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) -# ifndef NDEBUG - size_t m = rt.size() / q; - size_t n = st.size() / q; -# endif - assert( x.size() == n ); - assert( n == 3 ); - assert( m == 2 ); - - // [ 0, x_1 ] - // f'(x)^T = [ 0, x_0 ] - // [ 2 x_2, 0 ] - - // sparsity for first row of S(x)^T = f'(x)^T * R^T - size_t i = 0; - for(size_t j = 0; j < q; j++) - st[ i * q + j ] = rt[ 1 * q + j ]; - - // sparsity for second row of S(x)^T = f'(x)^T * R^T - i = 1; - for(size_t j = 0; j < q; j++) - st[ i * q + j ] = rt[ 1 * q + j ]; - - // sparsity for third row of S(x)^T = f'(x)^T * R^T - i = 2; - for(size_t j = 0; j < q; j++) - st[ i * q + j ] = rt[ 0 * q + j ]; - - return true; - } -/* %$$ -$head for_sparse_hes$$ -$srccode%cpp% */ - // forward Hessian sparsity routine called by CppAD - virtual bool for_sparse_hes( - const vector& vx, - const vector& r , - const vector& s , - CppAD::vectorBool& h , - const vector& x ) - { // This function needed because we are using RevSparseHes - // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) - size_t n = r.size(); -# ifndef NDEBUG - size_t m = s.size(); -# endif - assert( x.size() == n ); - assert( n == 3 ); - assert( m == 2 ); - assert( h.size() == n * n ); - - // [ 0 , 0 , 0 ] [ 0 , 1 , 0 ] - // f_0''(x) = [ 0 , 0 , 0 ] f_1^{(2)} (x) = [ 1 , 0 , 0 ] - // [ 0 , 0 , 2 ] [ 0 , 0 , 0 ] - - // initial entire matrix as false - for(size_t i = 0; i < n * n; i++) - h[i] = false; - - // component (2, 2) - h[ 2 * n + 2 ] = s[0] & r[2]; - - // components (1, 0) and (0, 1) - h[ 1 * n + 0 ] = s[1] & r[0] & r[1]; - h[ 0 * n + 1 ] = s[1] & r[0] & r[1]; - - return true; - } -}; // End of atomic_for_sparse_hes class - -/* %$$ -$head Use Atomic Function$$ -$srccode%cpp% */ -bool use_atomic_for_sparse_hes(bool x_1_variable) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * CppAD::numeric_limits::epsilon(); - // - // Create the atomic for_sparse_hes object - atomic_for_sparse_hes afun("atomic_for_sparse_hes"); - // - // Create the function f(u) - // - // domain space vector - size_t n = 3; - double x_0 = 1.00; - double x_1 = 2.00; - double x_2 = 3.00; - vector< AD > au(n); - au[0] = x_0; - au[1] = x_1; - au[2] = x_2; - - // declare independent variables and start tape recording - CppAD::Independent(au); - - // range space vector - size_t m = 2; - vector< AD > ay(m); - - // call user function - vector< AD > ax(n); - ax[0] = au[0]; - ax[2] = au[2]; - if( x_1_variable ) - ax[1] = au[1]; - else - ax[1] = x_1; - afun(ax, ay); // y = [ x_2 * x_2 , x_0 * x_1 ]^T - - // create f: u -> y and stop tape recording - CppAD::ADFun f; - f.Dependent (au, ay); // f(u) = y - // - // check function value - double check = x_2 * x_2; - ok &= NearEqual( Value(ay[0]) , check, eps, eps); - check = x_0 * x_1; - ok &= NearEqual( Value(ay[1]) , check, eps, eps); - - // check zero order forward mode - size_t q; - vector xq(n), yq(m); - q = 0; - xq[0] = x_0; - xq[1] = x_1; - xq[2] = x_2; - yq = f.Forward(q, xq); - check = x_2 * x_2; - ok &= NearEqual(yq[0] , check, eps, eps); - check = x_0 * x_1; - ok &= NearEqual(yq[1] , check, eps, eps); - - // forward sparse Hessian - CppAD::vectorBool r(n), s(m), h(n * n); - for(size_t j = 0; j < n; j++) - r[j] = true; - for(size_t i = 0; i < m; i++) - s[i] = true; - h = f.ForSparseHes(r, s); - - // check result - CppAD::vectorBool check_h(n * n); - for(size_t i = 0; i < n * n; i++) - check_h[i] = false; - check_h[ 2 * n + 2 ] = true; - if( x_1_variable ) - { check_h[0 * n + 1] = true; - check_h[1 * n + 0] = true; - } - for(size_t i = 0; i < n * n; i++) - ok &= h[ i ] == check_h[ i ]; - // - return ok; -} -} // End empty namespace -/* %$$ -$head Test with x_1 Both a Variable and a Parameter$$ -$srccode%cpp% */ -bool for_sparse_hes(void) -{ bool ok = true; - // test with x_1 a variable - ok &= use_atomic_for_sparse_hes(true); - // test with x_1 a parameter - ok &= use_atomic_for_sparse_hes(false); - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/for_sparse_jac.cpp cppad-2019.02.00.0/example/atomic/for_sparse_jac.cpp --- cppad-2018.00.00.0/example/atomic/for_sparse_jac.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/for_sparse_jac.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,240 +0,0 @@ -// $Id$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_for_sparse_jac.cpp$$ -$spell - Jacobian -$$ - -$section Atomic Forward Jacobian Sparsity: Example and Test$$ - -$head Purpose$$ -This example demonstrates calculation of the forward Jacobian sparsity pattern -for an atomic operation. - -$head function$$ -For this example, the atomic function -$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by -$latex \[ -f(x) = \left( \begin{array}{c} - x_2 * x_2 \\ - x_0 * x_1 -\end{array} \right) -\] $$ -The corresponding Jacobian is -$latex \[ -f^{(1)} (x) = \left( \begin{array}{ccc} - 0 & 0 & 2 x_2 \\ -x_1 & x_0 & 0 -\end{array} \right) -\] $$ - -$nospell - -$head Start Class Definition$$ -$srccode%cpp% */ -# include -namespace { // isolate items below to this file -using CppAD::vector; // abbreviate as vector -// -class atomic_for_sparse_jac : public CppAD::atomic_base { -/* %$$ -$head Constructor $$ -$srccode%cpp% */ -public: - // constructor (could use const char* for name) - atomic_for_sparse_jac(const std::string& name) : - // this example only uses pack sparsty patterns - CppAD::atomic_base(name, pack_sparsity_enum) - { } -private: -/* %$$ -$head forward$$ -$srccode%cpp% */ - // forward mode routine called by CppAD - virtual bool forward( - size_t p , - size_t q , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { -# ifndef NDEBUG - size_t n = tx.size() / (q + 1); - size_t m = ty.size() / (q + 1); -# endif - assert( n == 3 ); - assert( m == 2 ); - - // return flag - bool ok = q == 0; - if( ! ok ) - return ok; - - // check for defining variable information - // This case must always be implemented - if( vx.size() > 0 ) - { vy[0] = vx[2]; - vy[1] = vx[0] || vx[1]; - } - - // Order zero forward mode. - // This case must always be implemented - // f(x) = [ x_2 * x_2 ] - // [ x_0 * x_1 ] - assert( p <= 0 ); - if( p <= 0 ) - { ty[0] = tx[2] * tx[2]; - ty[1] = tx[0] * tx[1]; - } - return ok; - } -/* %$$ -$head for_sparse_jac$$ -$srccode%cpp% */ - // forward Jacobian sparsity routine called by CppAD - virtual bool for_sparse_jac( - size_t q , - const CppAD::vectorBool& r , - CppAD::vectorBool& s , - const vector& x ) - { // This function needed because we are using ForSparseJac - // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) -# ifndef NDEBUG - size_t n = r.size() / q; - size_t m = s.size() / q; -# endif - assert( x.size() == n ); - assert( n == 3 ); - assert( m == 2 ); - - // f'(x) = [ 0, 0, 2 x_2 ] - // [ x_1, x_0, 0 ] - - // sparsity for first row of S(x) = f'(x) * R - size_t i = 0; - for(size_t j = 0; j < q; j++) - s[ i * q + j ] = r[ 2 * q + j ]; - - // sparsity for second row of S(x) = f'(x) * R - i = 1; - for(size_t j = 0; j < q; j++) - s[ i * q + j ] = r[ 0 * q + j ] | r[ 1 * q + j]; - - return true; - } -}; // End of atomic_for_sparse_jac class - -/* %$$ -$head Use Atomic Function$$ -$srccode%cpp% */ -bool use_atomic_for_sparse_jac(bool x_1_variable) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * CppAD::numeric_limits::epsilon(); - // - // Create the atomic for_sparse_jac object - atomic_for_sparse_jac afun("atomic_for_sparse_jac"); - // - // Create the function f(u) - // - // domain space vector - size_t n = 3; - double x_0 = 1.00; - double x_1 = 2.00; - double x_2 = 3.00; - vector< AD > au(n); - au[0] = x_0; - au[1] = x_1; - au[2] = x_2; - - // declare independent variables and start tape recording - CppAD::Independent(au); - - // range space vector - size_t m = 2; - vector< AD > ay(m); - - // call user function - vector< AD > ax(n); - ax[0] = au[0]; - ax[2] = au[2]; - if( x_1_variable ) - ax[1] = au[1]; - else - ax[1] = x_1; - afun(ax, ay); // y = [ x_2 * x_2 , x_0 * x_1 ]^T - - // create f: u -> y and stop tape recording - CppAD::ADFun f; - f.Dependent (au, ay); // f(u) = y - // - // check function value - double check = x_2 * x_2; - ok &= NearEqual( Value(ay[0]) , check, eps, eps); - check = x_0 * x_1; - ok &= NearEqual( Value(ay[1]) , check, eps, eps); - - // check zero order forward mode - size_t q; - vector xq(n), yq(m); - q = 0; - xq[0] = x_0; - xq[1] = x_1; - xq[2] = x_2; - yq = f.Forward(q, xq); - check = x_2 * x_2; - ok &= NearEqual(yq[0] , check, eps, eps); - check = x_0 * x_1; - ok &= NearEqual(yq[1] , check, eps, eps); - - // forward sparse Jacobian - CppAD::vectorBool r(n * n), s(m * n); - // r = identity matrix - for(size_t i = 0; i < n; i++) - for(size_t j = 0; j < n; j++) - r[ i * n + j] = i == j; - s = f.ForSparseJac(n, r); - - // check result - CppAD::vectorBool check_s(m * n); - check_s[ 0 * n + 0 ] = false; - check_s[ 0 * n + 1 ] = false; - check_s[ 0 * n + 2 ] = true; - check_s[ 1 * n + 0 ] = true; - check_s[ 1 * n + 1 ] = x_1_variable; - check_s[ 1 * n + 2 ] = false; - // - for(size_t i = 0; i < m * n; i++) - ok &= s[ i ] == check_s[ i ]; - // - return ok; -} -} // End empty namespace -/* %$$ -$head Test with x_1 Both a Variable and a Parameter$$ -$srccode%cpp% */ -bool for_sparse_jac(void) -{ bool ok = true; - // test with x_1 a variable - ok &= use_atomic_for_sparse_jac(true); - // test with x_1 a parameter - ok &= use_atomic_for_sparse_jac(false); - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/forward.cpp cppad-2019.02.00.0/example/atomic/forward.cpp --- cppad-2018.00.00.0/example/atomic/forward.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/forward.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,298 +0,0 @@ -// $Id$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_forward.cpp$$ -$spell - Jacobian -$$ - -$section Atomic Forward: Example and Test$$ - -$head Purpose$$ -This example demonstrates forward mode derivative calculation -using an atomic operation. - -$head function$$ -For this example, the atomic function -$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by -$latex \[ -f(x) = \left( \begin{array}{c} - x_2 * x_2 \\ - x_0 * x_1 -\end{array} \right) -\] $$ -The corresponding Jacobian is -$latex \[ -f^{(1)} (x) = \left( \begin{array}{ccc} - 0 & 0 & 2 x_2 \\ -x_1 & x_0 & 0 -\end{array} \right) -\] $$ -The Hessians of the component functions are -$latex \[ -f_0^{(2)} ( x ) = \left( \begin{array}{ccc} - 0 & 0 & 0 \\ - 0 & 0 & 0 \\ - 0 & 0 & 2 -\end{array} \right) -\W{,} -f_1^{(2)} ( x ) = \left( \begin{array}{ccc} - 0 & 1 & 0 \\ - 1 & 0 & 0 \\ - 0 & 0 & 0 -\end{array} \right) -\] $$ - -$nospell - -$head Start Class Definition$$ -$srccode%cpp% */ -# include -namespace { // isolate items below to this file -using CppAD::vector; // abbreviate as vector -// -class atomic_forward : public CppAD::atomic_base { -/* %$$ -$head Constructor $$ -$srccode%cpp% */ -public: - // constructor (could use const char* for name) - atomic_forward(const std::string& name) : - // this example does not use sparsity patterns - CppAD::atomic_base(name) - { } -private: -/* %$$ -$head forward$$ -$srccode%cpp% */ - // forward mode routine called by CppAD - virtual bool forward( - size_t p , - size_t q , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { - size_t q1 = q + 1; -# ifndef NDEBUG - size_t n = tx.size() / q1; - size_t m = ty.size() / q1; -# endif - assert( n == 3 ); - assert( m == 2 ); - assert( p <= q ); - - // this example only implements up to second order forward mode - bool ok = q <= 2; - if( ! ok ) - return ok; - - // check for defining variable information - // This case must always be implemented - if( vx.size() > 0 ) - { vy[0] = vx[2]; - vy[1] = vx[0] || vx[1]; - } - // ------------------------------------------------------------------ - // Zero forward mode. - // This case must always be implemented - // f(x) = [ x_2 * x_2 ] - // [ x_0 * x_1 ] - // y^0 = f( x^0 ) - if( p <= 0 ) - { // y_0^0 = x_2^0 * x_2^0 - ty[0 * q1 + 0] = tx[2 * q1 + 0] * tx[2 * q1 + 0]; - // y_1^0 = x_0^0 * x_1^0 - ty[1 * q1 + 0] = tx[0 * q1 + 0] * tx[1 * q1 + 0]; - } - if( q <= 0 ) - return ok; - // ------------------------------------------------------------------ - // First order one forward mode. - // This case is needed if first order forward mode is used. - // f'(x) = [ 0, 0, 2 * x_2 ] - // [ x_1, x_0, 0 ] - // y^1 = f'(x^0) * x^1 - if( p <= 1 ) - { // y_0^1 = 2 * x_2^0 * x_2^1 - ty[0 * q1 + 1] = 2.0 * tx[2 * q1 + 0] * tx[2 * q1 + 1]; - // y_1^1 = x_1^0 * x_0^1 + x_0^0 * x_1^1 - ty[1 * q1 + 1] = tx[1 * q1 + 0] * tx[0 * q1 + 1]; - ty[1 * q1 + 1] += tx[0 * q1 + 0] * tx[1 * q1 + 1]; - } - if( q <= 1 ) - return ok; - // ------------------------------------------------------------------ - // Second order forward mode. - // This case is neede if second order forwrd mode is used. - // f'(x) = [ 0, 0, 2 x_2 ] - // [ x_1, x_0, 0 ] - // - // [ 0 , 0 , 0 ] [ 0 , 1 , 0 ] - // f_0''(x) = [ 0 , 0 , 0 ] f_1^{(2)} (x) = [ 1 , 0 , 0 ] - // [ 0 , 0 , 2 ] [ 0 , 0 , 0 ] - // - // y_0^2 = x^1 * f_0''( x^0 ) x^1 / 2! + f_0'( x^0 ) x^2 - // = ( x_2^1 * 2.0 * x_2^1 ) / 2! - // + 2.0 * x_2^0 * x_2^2 - ty[0 * q1 + 2] = tx[2 * q1 + 1] * tx[2 * q1 + 1]; - ty[0 * q1 + 2] += 2.0 * tx[2 * q + 0] * tx[2 * q1 + 2]; - // - // y_1^2 = x^1 * f_1''( x^0 ) x^1 / 2! + f_1'( x^0 ) x^2 - // = ( x_1^1 * x_0^1 + x_0^1 * x_1^1) / 2 - // + x_1^0 * x_0^2 + x_0^0 + x_1^2 - ty[1 * q1 + 2] = tx[1 * q1 + 1] * tx[0 * q1 + 1]; - ty[1 * q1 + 2] += tx[1 * q1 + 0] * tx[0 * q1 + 2]; - ty[1 * q1 + 2] += tx[0 * q1 + 0] * tx[1 * q1 + 2]; - // ------------------------------------------------------------------ - return ok; - } -}; -} // End empty namespace -/* %$$ -$head Use Atomic Function$$ -$srccode%cpp% */ -bool forward(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * CppAD::numeric_limits::epsilon(); - // - // Create the atomic_forward object - atomic_forward afun("atomic_forward"); - // - // Create the function f(u) - // - // domain space vector - size_t n = 3; - double x_0 = 1.00; - double x_1 = 2.00; - double x_2 = 3.00; - vector< AD > au(n); - au[0] = x_0; - au[1] = x_1; - au[2] = x_2; - - // declare independent variables and start tape recording - CppAD::Independent(au); - - // range space vector - size_t m = 2; - vector< AD > ay(m); - - // call user function - vector< AD > ax = au; - afun(ax, ay); - - // create f: u -> y and stop tape recording - CppAD::ADFun f; - f.Dependent (au, ay); // y = f(u) - // - // check function value - double check = x_2 * x_2; - ok &= NearEqual( Value(ay[0]) , check, eps, eps); - check = x_0 * x_1; - ok &= NearEqual( Value(ay[1]) , check, eps, eps); - - // -------------------------------------------------------------------- - // zero order forward - // - vector x0(n), y0(m); - x0[0] = x_0; - x0[1] = x_1; - x0[2] = x_2; - y0 = f.Forward(0, x0); - check = x_2 * x_2; - ok &= NearEqual(y0[0] , check, eps, eps); - check = x_0 * x_1; - ok &= NearEqual(y0[1] , check, eps, eps); - // -------------------------------------------------------------------- - // first order forward - // - // value of Jacobian of f - double check_jac[] = { - 0.0, 0.0, 2.0 * x_2, - x_1, x_0, 0.0 - }; - vector x1(n), y1(m); - // check first order forward mode - for(size_t j = 0; j < n; j++) - x1[j] = 0.0; - for(size_t j = 0; j < n; j++) - { // compute partial in j-th component direction - x1[j] = 1.0; - y1 = f.Forward(1, x1); - x1[j] = 0.0; - // check this direction - for(size_t i = 0; i < m; i++) - ok &= NearEqual(y1[i], check_jac[i * n + j], eps, eps); - } - // -------------------------------------------------------------------- - // second order forward - // - // value of Hessian of f_0 - double check_hes_0[] = { - 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, - 0.0, 0.0, 2.0 - }; - // - // value of Hessian of f_1 - double check_hes_1[] = { - 0.0, 1.0, 0.0, - 1.0, 0.0, 0.0, - 0.0, 0.0, 0.0 - }; - vector x2(n), y2(m); - for(size_t j = 0; j < n; j++) - x2[j] = 0.0; - // compute diagonal elements of the Hessian - for(size_t j = 0; j < n; j++) - { // first order forward in j-th direction - x1[j] = 1.0; - f.Forward(1, x1); - y2 = f.Forward(2, x2); - // check this element of Hessian diagonal - ok &= NearEqual(y2[0], check_hes_0[j * n + j] / 2.0, eps, eps); - ok &= NearEqual(y2[1], check_hes_1[j * n + j] / 2.0, eps, eps); - // - for(size_t k = 0; k < n; k++) if( k != j ) - { x1[k] = 1.0; - f.Forward(1, x1); - y2 = f.Forward(2, x2); - // - // y2 = (H_jj + H_kk + H_jk + H_kj) / 2.0 - // y2 = (H_jj + H_kk) / 2.0 + H_jk - // - double H_jj = check_hes_0[j * n + j]; - double H_kk = check_hes_0[k * n + k]; - double H_jk = y2[0] - (H_kk + H_jj) / 2.0; - ok &= NearEqual(H_jk, check_hes_0[j * n + k], eps, eps); - // - H_jj = check_hes_1[j * n + j]; - H_kk = check_hes_1[k * n + k]; - H_jk = y2[1] - (H_kk + H_jj) / 2.0; - ok &= NearEqual(H_jk, check_hes_1[j * n + k], eps, eps); - // - x1[k] = 0.0; - } - x1[j] = 0.0; - } - // -------------------------------------------------------------------- - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/get_started.cpp cppad-2019.02.00.0/example/atomic/get_started.cpp --- cppad-2018.00.00.0/example/atomic/get_started.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/get_started.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ -// $Id: get_started.cpp 3814 2016-04-18 14:26:10Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_get_started.cpp$$ - -$section Getting Started with Atomic Operations: Example and Test$$ - -$head Purpose$$ -This example demonstrates the minimal amount of information -necessary for a $cref atomic_base$$ operation. - -$nospell - -$head Start Class Definition$$ -$srccode%cpp% */ -# include -namespace { // isolate items below to this file -using CppAD::vector; // abbreviate as vector -class atomic_get_started : public CppAD::atomic_base { -/* %$$ - -$head Constructor$$ -$srccode%cpp% */ -public: - // constructor (could use const char* for name) - atomic_get_started(const std::string& name) : - // this example does not use any sparsity patterns - CppAD::atomic_base(name) - { } -private: -/* %$$ -$head forward$$ -$srccode%cpp% */ - // forward mode routine called by CppAD - virtual bool forward( - size_t p , - size_t q , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { -# ifndef NDEBUG - size_t n = tx.size() / (q + 1); - size_t m = ty.size() / (q + 1); -# endif - assert( n == 1 ); - assert( m == 1 ); - - // return flag - bool ok = q == 0; - if( ! ok ) - return ok; - - // check for defining variable information - // This case must always be implemented - if( vx.size() > 0 ) - vy[0] = vx[0]; - - // Order zero forward mode. - // This case must always be implemented - // y^0 = f( x^0 ) = 1 / x^0 - double f = 1. / tx[0]; - if( p <= 0 ) - ty[0] = f; - return ok; - } -/* %$$ -$head End Class Definition$$ -$srccode%cpp% */ -}; // End of atomic_get_started class -} // End empty namespace - -/* %$$ -$head Use Atomic Function$$ -$srccode%cpp% */ -bool get_started(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * CppAD::numeric_limits::epsilon(); -/* %$$ -$subhead Constructor$$ -$srccode%cpp% */ - // Create the atomic get_started object - atomic_get_started afun("atomic_get_started"); -/* %$$ -$subhead Recording$$ -$srccode%cpp% */ - // 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 get_started(x) in au[0] - vector< AD > au(m); - afun(ax, au); // u = 1 / x - - // now use AD division to invert to invert the operation - ay[0] = 1.0 / au[0]; // y = 1 / u = x - - // create f: x -> y and stop tape recording - CppAD::ADFun f; - f.Dependent (ax, ay); // f(x) = x -/* %$$ -$subhead forward$$ -$srccode%cpp% */ - // 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); - - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/makefile.am cppad-2019.02.00.0/example/atomic/makefile.am --- cppad-2018.00.00.0/example/atomic/makefile.am 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -# $Id: makefile.am 3922 2017-05-15 06:40:10Z bradbell $ -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. -# ----------------------------------------------------------------------------- -# automake input file -# -# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp -DEFS = -# -if CppAD_EIGEN_DIR -EIGEN_SRC_FILES = eigen_cholesky.cpp eigen_mat_inv.cpp eigen_mat_mul.cpp -EIGEN_EXTRA_FILES = -else -EIGEN_EXTEA_FILES = eigen_cholesky.cpp eigen_mat_inv.cpp eigen_mat_mul.cpp -EIGEN_SRC_FILES = -endif -# -EXTRA_DIST = \ - $(EIGEN_EXTRA_FILES) -# -check_PROGRAMS = atomic -# -AM_CXXFLAGS = -g $(CXX_FLAGS) -# -AM_CPPFLAGS = -I. \ - -I$(top_srcdir) \ - $(BOOST_INCLUDE) \ - $(EIGEN_INCLUDE) -# -atomic_SOURCES = \ - $(EIGEN_SRC_FILES) \ - atomic.cpp \ - checkpoint.cpp \ - extended_ode.cpp \ - for_sparse_hes.cpp \ - for_sparse_jac.cpp \ - forward.cpp \ - get_started.cpp \ - mat_mul.cpp \ - mul_level.cpp \ - norm_sq.cpp \ - ode.cpp \ - reciprocal.cpp \ - rev_sparse_hes.cpp \ - rev_sparse_jac.cpp \ - reverse.cpp \ - set_sparsity.cpp \ - tangent.cpp - -test: check - ./atomic diff -Nru cppad-2018.00.00.0/example/atomic/makefile.in cppad-2019.02.00.0/example/atomic/makefile.in --- cppad-2018.00.00.0/example/atomic/makefile.in 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/makefile.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,686 +0,0 @@ -# makefile.in generated by automake 1.15 from makefile.am. -# @configure_input@ - -# 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, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -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 \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -check_PROGRAMS = atomic$(EXEEXT) -subdir = example/atomic -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_SOURCES_DIST = eigen_cholesky.cpp eigen_mat_inv.cpp \ - eigen_mat_mul.cpp atomic.cpp checkpoint.cpp extended_ode.cpp \ - for_sparse_hes.cpp for_sparse_jac.cpp forward.cpp \ - get_started.cpp mat_mul.cpp mul_level.cpp norm_sq.cpp ode.cpp \ - reciprocal.cpp rev_sparse_hes.cpp rev_sparse_jac.cpp \ - reverse.cpp set_sparsity.cpp tangent.cpp -@CppAD_EIGEN_DIR_TRUE@am__objects_1 = eigen_cholesky.$(OBJEXT) \ -@CppAD_EIGEN_DIR_TRUE@ eigen_mat_inv.$(OBJEXT) \ -@CppAD_EIGEN_DIR_TRUE@ eigen_mat_mul.$(OBJEXT) -am_atomic_OBJECTS = $(am__objects_1) atomic.$(OBJEXT) \ - checkpoint.$(OBJEXT) extended_ode.$(OBJEXT) \ - for_sparse_hes.$(OBJEXT) for_sparse_jac.$(OBJEXT) \ - forward.$(OBJEXT) get_started.$(OBJEXT) mat_mul.$(OBJEXT) \ - mul_level.$(OBJEXT) norm_sq.$(OBJEXT) ode.$(OBJEXT) \ - reciprocal.$(OBJEXT) rev_sparse_hes.$(OBJEXT) \ - rev_sparse_jac.$(OBJEXT) reverse.$(OBJEXT) \ - set_sparsity.$(OBJEXT) tangent.$(OBJEXT) -atomic_OBJECTS = $(am_atomic_OBJECTS) -atomic_LDADD = $(LDADD) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -AM_V_CXX = $(am__v_CXX_@AM_V@) -am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) -am__v_CXX_0 = @echo " CXX " $@; -am__v_CXX_1 = -CXXLD = $(CXX) -CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ - -o $@ -AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) -am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) -am__v_CXXLD_0 = @echo " CXXLD " $@; -am__v_CXXLD_1 = -SOURCES = $(atomic_SOURCES) -DIST_SOURCES = $(am__atomic_SOURCES_DIST) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - 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@ -ACLOCAL = @ACLOCAL@ -ADOLC_DIR = @ADOLC_DIR@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BOOST_DIR = @BOOST_DIR@ -BOOST_INCLUDE = @BOOST_INCLUDE@ -BTHREAD_LIB = @BTHREAD_LIB@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPAD_IPOPT_LD_PATH = @CPPAD_IPOPT_LD_PATH@ -CPPAD_IPOPT_LIBS = @CPPAD_IPOPT_LIBS@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ -CYGPATH_W = @CYGPATH_W@ - -# $Id: makefile.in 3973 2017-08-30 13:38:26Z bradbell $ -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. -# ----------------------------------------------------------------------------- -# automake input file -# -# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp -DEFS = -DEPDIR = @DEPDIR@ -DL_LIB = @DL_LIB@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EIGEN_DIR = @EIGEN_DIR@ -EIGEN_INCLUDE = @EIGEN_INCLUDE@ -EXEEXT = @EXEEXT@ -FADBAD_DIR = @FADBAD_DIR@ -FC = @FC@ -FCFLAGS = @FCFLAGS@ -FCLIBS = @FCLIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -IPOPT_DIR = @IPOPT_DIR@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MAX_NUM_THREADS = @MAX_NUM_THREADS@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -OPENMP_FLAGS = @OPENMP_FLAGS@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -POSTFIX_DIR = @POSTFIX_DIR@ -PTHREAD_LIB = @PTHREAD_LIB@ -RANLIB = @RANLIB@ -SACADO_DIR = @SACADO_DIR@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -TAPE_ADDR_TYPE = @TAPE_ADDR_TYPE@ -TAPE_ID_TYPE = @TAPE_ID_TYPE@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_FC = @ac_ct_FC@ -adolc_prefix = @adolc_prefix@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ -cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ -cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ -cppad_cppadvector = @cppad_cppadvector@ -cppad_cxx_flags = @cppad_cxx_flags@ -cppad_deprecated_01 = @cppad_deprecated_01@ -cppad_description = @cppad_description@ -cppad_eigenvector = @cppad_eigenvector@ -cppad_has_adolc = @cppad_has_adolc@ -cppad_has_boost = @cppad_has_boost@ -cppad_has_colpack = @cppad_has_colpack@ -cppad_has_eigen = @cppad_has_eigen@ -cppad_has_fadbad = @cppad_has_fadbad@ -cppad_has_gettimeofday = @cppad_has_gettimeofday@ -cppad_has_ipopt = @cppad_has_ipopt@ -cppad_has_mkstemp = @cppad_has_mkstemp@ -cppad_has_sacado = @cppad_has_sacado@ -cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ -cppad_max_num_threads = @cppad_max_num_threads@ -cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ -cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ -cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ -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_version = @cppad_version@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -eigen_prefix = @eigen_prefix@ -exec_prefix = @exec_prefix@ -have_pkg_config = @have_pkg_config@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -@CppAD_EIGEN_DIR_FALSE@EIGEN_SRC_FILES = -# -@CppAD_EIGEN_DIR_TRUE@EIGEN_SRC_FILES = eigen_cholesky.cpp eigen_mat_inv.cpp eigen_mat_mul.cpp -@CppAD_EIGEN_DIR_TRUE@EIGEN_EXTRA_FILES = -@CppAD_EIGEN_DIR_FALSE@EIGEN_EXTEA_FILES = eigen_cholesky.cpp eigen_mat_inv.cpp eigen_mat_mul.cpp -# -EXTRA_DIST = \ - $(EIGEN_EXTRA_FILES) - -# -AM_CXXFLAGS = -g $(CXX_FLAGS) -# -AM_CPPFLAGS = -I. \ - -I$(top_srcdir) \ - $(BOOST_INCLUDE) \ - $(EIGEN_INCLUDE) - -# -atomic_SOURCES = \ - $(EIGEN_SRC_FILES) \ - atomic.cpp \ - checkpoint.cpp \ - extended_ode.cpp \ - for_sparse_hes.cpp \ - for_sparse_jac.cpp \ - forward.cpp \ - get_started.cpp \ - mat_mul.cpp \ - mul_level.cpp \ - norm_sq.cpp \ - ode.cpp \ - reciprocal.cpp \ - rev_sparse_hes.cpp \ - rev_sparse_jac.cpp \ - reverse.cpp \ - set_sparsity.cpp \ - tangent.cpp - -all: all-am - -.SUFFIXES: -.SUFFIXES: .cpp .o .obj -$(srcdir)/makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign example/atomic/makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign example/atomic/makefile -makefile: $(srcdir)/makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-checkPROGRAMS: - -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) - -atomic$(EXEEXT): $(atomic_OBJECTS) $(atomic_DEPENDENCIES) $(EXTRA_atomic_DEPENDENCIES) - @rm -f atomic$(EXEEXT) - $(AM_V_CXXLD)$(CXXLINK) $(atomic_OBJECTS) $(atomic_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atomic.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checkpoint.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eigen_cholesky.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eigen_mat_inv.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eigen_mat_mul.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extended_ode.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_sparse_hes.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_sparse_jac.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forward.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_started.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mat_mul.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_level.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/norm_sq.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reciprocal.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rev_sparse_hes.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rev_sparse_jac.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reverse.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_sparsity.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tangent.Po@am__quote@ - -.cpp.o: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< - -.cpp.obj: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) -check: check-am -all-am: makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ - clean-checkPROGRAMS clean-generic cscopelist-am ctags ctags-am \ - distclean distclean-compile distclean-generic distclean-tags \ - distdir dvi dvi-am html html-am info info-am install \ - install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am - -.PRECIOUS: makefile - - -test: check - ./atomic - -# 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. -.NOEXPORT: diff -Nru cppad-2018.00.00.0/example/atomic/mat_mul.cpp cppad-2019.02.00.0/example/atomic/mat_mul.cpp --- cppad-2018.00.00.0/example/atomic/mat_mul.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/mat_mul.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,278 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_mat_mul.cpp$$ -$spell - mul -$$ - -$section User Atomic Matrix Multiply: Example and Test$$ - -$head See Also$$ -$cref atomic_eigen_mat_mul.cpp$$ - -$children% - cppad/example/mat_mul.hpp -%$$ - -$head Class Definition$$ -This example uses the file $cref atomic_mat_mul.hpp$$ -which defines matrix multiply as a $cref atomic_base$$ operation. - -$nospell - -$head Use Atomic Function$$ -$srccode%cpp% */ -# include -# include - -bool mat_mul(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::vector; - size_t i, j; -/* %$$ -$subhead Constructor$$ -$srccode%cpp% */ - // ------------------------------------------------------------------- - // object that multiplies 2 x 2 matrices - atomic_mat_mul afun; -/* %$$ -$subhead Recording$$ -$srccode%cpp% */ - // start recording with four independent varables - size_t n = 4; - vector x(n); - vector< AD > ax(n); - for(j = 0; j < n; j++) - ax[j] = x[j] = double(j + 1); - CppAD::Independent(ax); - - // ------------------------------------------------------------------ - size_t nr_left = 2; - size_t n_middle = 2; - size_t nc_right = 2; - vector< AD > atom_x(3 + (nr_left + nc_right) * n_middle ); - - // matrix dimensions - atom_x[0] = AD( nr_left ); - atom_x[1] = AD( n_middle ); - atom_x[2] = AD( nc_right ); - - // left matrix - atom_x[3] = ax[0]; // left[0, 0] = x0 - atom_x[4] = ax[1]; // left[0, 1] = x1 - atom_x[5] = 5.; // left[1, 0] = 5 - atom_x[6] = 6.; // left[1, 1] = 6 - - // right matix - atom_x[7] = ax[2]; // right[0, 0] = x2 - atom_x[8] = 7.; // right[0, 1] = 7 - atom_x[9] = ax[3]; // right[1, 0] = x3 - atom_x[10] = 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 ] - */ - vector< AD > atom_y(nr_left * nc_right); - afun(atom_x, atom_y); - - ok &= (atom_y[0] == x[0]*x[2] + x[1]*x[3]) & Variable(atom_y[0]); - ok &= (atom_y[1] == x[0]*7. + x[1]*8. ) & Variable(atom_y[1]); - ok &= (atom_y[2] == 5.*x[2] + 6.*x[3]) & Variable(atom_y[2]); - ok &= (atom_y[3] == 5.*7. + 6.*8. ) & Parameter(atom_y[3]); - - // ------------------------------------------------------------------ - // define the function g : x -> atom_y - // g(x) = [ x0*x2 + x1*x3 , x0*7 + x1*8 , 5*x2 + 6*x3 , 5*7 + 6*8 ]^T - CppAD::ADFun g(ax, atom_y); -/* %$$ -$subhead forward$$ -$srccode%cpp% */ - // Test zero order forward mode evaluation of g(x) - size_t m = atom_y.size(); - vector y(m); - for(j = 0; j < n; j++) - x[j] = double(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(n), dy(m); - for(j = 0; j < n; j++) - dx[j] = double(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(n), ddy(m); - for(j = 0; j < n; 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.; -/* %$$ -$subhead reverse$$ -$srccode%cpp% */ - // Test second order reverse mode - CppAD::vector w(m), dw(2 * n); - 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.; -/* %$$ -$subhead option$$ -$srccode%cpp% */ - //---------------------------------------------------------------------- - // Test both the boolean and set sparsity at the atomic level - for(size_t sparse_index = 0; sparse_index < 2; sparse_index++) - { if( sparse_index == 0 ) - afun.option( CppAD::atomic_base::bool_sparsity_enum ); - else afun.option( CppAD::atomic_base::set_sparsity_enum ); -/* %$$ -$subhead for_sparse_jac$$ -$srccode%cpp% */ - // Test forward Jacobian sparsity pattern - /* - g(x) = [ x0*x2 + x1*x3 , x0*7 + x1*8 , 5*x2 + 6*x3 , 5*7 + 6*8 ]^T - 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(n), s(m); - for(j = 0; j < n; j++) - { assert( r[j].empty() ); - r[j].insert(j); - } - s = g.ForSparseJac(n, r); - for(j = 0; j < n; 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(); -/* %$$ -$subhead rev_sparse_jac$$ -$srccode%cpp% */ - // Test reverse Jacobian sparsity pattern - for(i = 0; i < m; i++) - { s[i].clear(); - s[i].insert(i); - } - r = g.RevSparseJac(m, s); - for(j = 0; j < n ; 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(); -/* %$$ -$subhead rev_sparse_hes$$ -$srccode%cpp% */ - /* 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(n), t(1); - t[0].clear(); - t[0].insert(0); - h = g.RevSparseHes(n, t); - size_t check[] = {2, 3, 0, 1}; - for(j = 0; j < n; 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 < n; j++) - t[0].insert(j); - h = g.RevSparseHes(n, t); - for(j = 0; j < n; j++) - { // h[j] = { } - for(i = 0; i < n; i++) - ok &= h[j].find(i) == h[j].end(); - } - - //----------------------------------------------------------------- - } // end for(size_t sparse_index ... - //----------------------------------------------------------------- - - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/mul_level.cpp cppad-2019.02.00.0/example/atomic/mul_level.cpp --- cppad-2018.00.00.0/example/atomic/mul_level.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/mul_level.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -// $Id$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_mul_level.cpp$$ -$spell - checkpointing -$$ - -$section Atomic Operations and Multiple-Levels of AD: Example and Test$$ - -$head Discussion$$ -One can use $cref checkpoint$$ or $cref atomic_base$$ to code -an $codei%AD<%Base%>%$$ operation as atomic. -This means that derivative computations that use the type $icode Base$$ -will call the corresponding $code atomic_base$$ member functions. -On the other hand, if $icode Base$$ is $codei%AD<%Other%>%$$ the -operations recorded at the $icode Base$$ level will not be atomic. -This is demonstrated in this example. - -$code -$srcfile%example/atomic/mul_level.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - - -$end -*/ -// BEGIN C++ - -# include - -namespace { - using CppAD::AD; - typedef AD a1double; - typedef AD a2double; - typedef CPPAD_TESTVECTOR(a1double) a1vector; - typedef CPPAD_TESTVECTOR(a2double) a2vector; - - void f_algo(const a2vector& x, a2vector& y) - { size_t n = x.size(); - y[0] = 0.0; - for(size_t j = 1; j < n; j++) - y[0] += x[j-1] * x[j]; - return; - } -} -// -bool mul_level(void) -{ bool ok = true; - using CppAD::checkpoint; - using CppAD::ADFun; - using CppAD::Independent; - - // domain dimension for this problem - size_t n = 10; - size_t m = 1; - - // checkpoint version of the function F(x) - a2vector a2x(n), a2y(m); - for(size_t j = 0; j < n; j++) - a2x[j] = a2double(j + 1); - // - // could also use bool_sparsity_enum or set_sparsity_enum - checkpoint atom_f("atom_f", f_algo, a2x, a2y); - // - // Record a version of y = f(x) without checkpointing - Independent(a2x); - f_algo(a2x, a2y); - ADFun check_not(a2x, a2y); - // - // number of variables in a tape of f_algo that does not use checkpointing - size_t size_not = check_not.size_var(); - // - // Record a version of y = f(x) with checkpointing - Independent(a2x); - atom_f(a2x, a2y); - ADFun check_yes(a2x, a2y); - // - // f_algo is represented by one atomic operation in this tape - ok &= check_yes.size_var() < size_not; - // - // now record operations at a1double level - a1vector a1x(n), a1y(m); - for(size_t j = 0; j < n; j++) - a1x[j] = a1double(j + 1); - // - // without checkpointing - Independent(a1x); - a1y = check_not.Forward(0, a1x); - ADFun with_not(a1x, a1y); - // - // should have the same size - ok &= with_not.size_var() == size_not; - // - // with checkpointing - Independent(a1x); - a1y = check_yes.Forward(0, a1x); - ADFun with_yes(a1x, a1y); - // - // f_algo is nolonger represented by one atomic operation in this tape - ok &= with_yes.size_var() == size_not; - // - return ok; -} -// END C++ diff -Nru cppad-2018.00.00.0/example/atomic/norm_sq.cpp cppad-2019.02.00.0/example/atomic/norm_sq.cpp --- cppad-2018.00.00.0/example/atomic/norm_sq.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/norm_sq.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,384 +0,0 @@ -// $Id: norm_sq.cpp 3821 2016-06-30 02:53:40Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_norm_sq.cpp$$ -$spell - sq - bool - enum -$$ - -$section Atomic Euclidean Norm Squared: Example and Test$$ -$mindex bool_sparsity_enum$$ - -$head Theory$$ -This example demonstrates using $cref atomic_base$$ -to define the operation -$latex f : \B{R}^n \rightarrow \B{R}^m$$ where -$latex n = 2$$, $latex m = 1$$, where -$latex \[ - f(x) = x_0^2 + x_1^2 -\] $$ - -$head sparsity$$ -This example only uses bool sparsity patterns. - -$nospell - -$head Start Class Definition$$ -$srccode%cpp% */ -# include -namespace { // isolate items below to this file -using CppAD::vector; // abbreviate as vector -// -class atomic_norm_sq : public CppAD::atomic_base { -/* %$$ -$head Constructor $$ -$srccode%cpp% */ -public: - // constructor (could use const char* for 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: -/* %$$ -$head forward$$ -$srccode%cpp% */ - // forward mode routine called by CppAD - virtual bool forward( - size_t p , - size_t q , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { -# ifndef NDEBUG - size_t n = tx.size() / (q+1); - size_t m = ty.size() / (q+1); -# endif - assert( n == 2 ); - assert( m == 1 ); - assert( p <= q ); - - // return flag - bool ok = q <= 1; - - // Variable information must always be implemented. - // y_0 is a variable if and only if x_0 or x_1 is a variable. - if( vx.size() > 0 ) - vy[0] = vx[0] | vx[1]; - - // Order zero forward mode must always be implemented. - // 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 ) - if( p <= 0 ) - ty[0] = f; // y_0^0 - if( q <= 0 ) - return ok; - assert( vx.size() == 0 ); - - // Order one forward mode. - // This case needed if first order forward mode is used. - // y^1 = f'( x^0 ) x^1 - double x_01 = tx[ 0*(q+1) + 1]; // x_0^1 - double x_11 = tx[ 1*(q+1) + 1]; // x_1^1 - double fp_0 = 2.0 * x_00; // partial f w.r.t x_0^0 - double fp_1 = 2.0 * x_10; // partial f w.r.t x_1^0 - if( p <= 1 ) - ty[1] = fp_0 * x_01 + fp_1 * x_11; // f'( x^0 ) * x^1 - if( q <= 1 ) - return ok; - - // Assume we are not using forward mode with order > 1 - assert( ! ok ); - return ok; - } -/* %$$ -$head reverse$$ -$srccode%cpp% */ - // reverse mode routine called by CppAD - virtual bool reverse( - size_t q , - const vector& tx , - const vector& ty , - vector& px , - const vector& py - ) - { -# ifndef NDEBUG - size_t n = tx.size() / (q+1); - size_t m = ty.size() / (q+1); -# endif - assert( px.size() == n * (q+1) ); - assert( py.size() == m * (q+1) ); - assert( n == 2 ); - assert( m == 1 ); - bool ok = q <= 1; - - double fp_0, fp_1; - switch(q) - { case 0: - // This case needed if first order reverse mode is used - // F ( {x} ) = f( x^0 ) = y^0 - fp_0 = 2.0 * tx[0]; // partial F w.r.t. x_0^0 - fp_1 = 2.0 * tx[1]; // partial F w.r.t. x_0^1 - px[0] = py[0] * fp_0;; // partial G w.r.t. x_0^0 - px[1] = py[0] * fp_1;; // partial G w.r.t. x_0^1 - assert(ok); - break; - - default: - // Assume we are not using reverse with order > 1 (q > 0) - assert(!ok); - } - return ok; - } -/* %$$ -$head for_sparse_jac$$ -$srccode%cpp% */ - // forward Jacobian bool sparsity routine called by CppAD - virtual bool for_sparse_jac( - size_t p , - const vector& r , - vector& s , - const vector& x ) - { // This function needed if using f.ForSparseJac - size_t n = r.size() / p; -# ifndef NDEBUG - size_t m = s.size() / p; -# endif - assert( n == x.size() ); - assert( n == 2 ); - assert( m == 1 ); - - // 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++) - { // Visual Studio 2013 generates warning without bool below - s[j] |= bool( r[i * p + j] ); - } - } - return true; - } -/* %$$ -$head rev_sparse_jac$$ -$srccode%cpp% */ - // reverse Jacobian bool sparsity routine called by CppAD - virtual bool rev_sparse_jac( - size_t p , - const vector& rt , - vector& st , - const vector& x ) - { // This function needed if using RevSparseJac or optimize - size_t n = st.size() / p; -# ifndef NDEBUG - size_t m = rt.size() / p; -# endif - assert( n == x.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 - for(size_t j = 0; j < p; j++) - for(size_t i = 0; i < n; i++) - st[i * p + j] = rt[j]; - - return true; - } -/* %$$ -$head rev_sparse_hes$$ -$srccode%cpp% */ - // 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 , - const vector& x ) - { // This function needed if using RevSparseHes -# ifndef NDEBUG - size_t m = s.size(); -# endif - size_t n = t.size(); - assert( x.size() == n ); - assert( r.size() == n * p ); - assert( u.size() == m * p ); - assert( v.size() == n * p ); - assert( n == 2 ); - assert( m == 1 ); - - // 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) - 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) - - // back propagate the sparsity for U - size_t j; - for(j = 0; j < p; j++) - for(size_t i = 0; i < n; i++) - v[ i * p + j] = u[j]; - - // include forward Jacobian sparsity in Hessian sparsity - // sparsity for g'(y) * f''(x) * R (Note f''(x) has same sparsity - // as the identity matrix) - if( s[0] ) - { for(j = 0; j < p; j++) - for(size_t i = 0; i < n; i++) - { // Visual Studio 2013 generates warning without bool below - v[ i * p + j] |= bool( r[ i * p + j] ); - } - } - - return true; - } -/* %$$ -$head End Class Definition$$ -$srccode%cpp% */ -}; // End of atomic_norm_sq class -} // End empty namespace - -/* %$$ -$head Use Atomic Function$$ -$srccode%cpp% */ -bool norm_sq(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * CppAD::numeric_limits::epsilon(); -/* %$$ -$subhead Constructor$$ -$srccode%cpp% */ - // -------------------------------------------------------------------- - // Create the atomic reciprocal object - atomic_norm_sq afun("atomic_norm_sq"); -/* %$$ -$subhead Recording$$ -$srccode%cpp% */ - // Create the function f(x) - // - // domain space vector - size_t n = 2; - double x0 = 0.25; - double x1 = 0.75; - vector< AD > ax(n); - ax[0] = x0; - ax[1] = x1; - - // 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 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); -/* %$$ -$subhead forward$$ -$srccode%cpp% */ - // check function value - double check = x0 * x0 + x1 * x1; - 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; - x_q[1] = x1; - 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] = 0.3; - x_q[1] = 0.7; - y_q = f.Forward(q, x_q); - check = 2.0 * x0 * x_q[0] + 2.0 * x1 * x_q[1]; - ok &= NearEqual(y_q[0] , check, eps, eps); - -/* %$$ -$subhead reverse$$ -$srccode%cpp% */ - // first order reverse mode - q = 1; - vector w(m), dw(n * q); - w[0] = 1.; - dw = f.Reverse(q, w); - check = 2.0 * x0; - ok &= NearEqual(dw[0] , check, eps, eps); - check = 2.0 * x1; - ok &= NearEqual(dw[1] , check, eps, eps); -/* %$$ -$subhead for_sparse_jac$$ -$srccode%cpp% */ - // forward mode sparstiy pattern - size_t p = n; - CppAD::vectorBool r1(n * p), s1(m * p); - r1[0] = true; r1[1] = false; // sparsity pattern identity - r1[2] = false; r1[3] = true; - // - 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] -/* %$$ -$subhead rev_sparse_jac$$ -$srccode%cpp% */ - // 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] - ok &= r2[1] == true; // f[0] depends on x[1] -/* %$$ -$subhead rev_sparse_hes$$ -$srccode%cpp% */ - // 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; // 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; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/ode.cpp cppad-2019.02.00.0/example/atomic/ode.cpp --- cppad-2018.00.00.0/example/atomic/ode.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/ode.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,318 +0,0 @@ -// $Id$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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 checkpoint_ode.cpp$$ -$spell - Checkpointing - Runge-Kutta -$$ - -$section Checkpointing an ODE Solver: Example and Test$$ - -$head See Also$$ -$cref checkpoint_extended_ode.cpp$$, - -$head Purpose$$ -In this example we $cref checkpoint$$ one step of an ODE solver. - -$head Problem$$ -We consider the initial value problem with parameter $latex x$$ defined by, -$latex z(0, x) = z_0 (x)$$, -$latex \[ - \partial_t z(t, x ) = h [ x , z(t, x) ] -\]$$ -Note that if $latex t$$ needs to be in the equation, one can define -the first component of $latex z(t, x)$$ to be equal to $latex t$$. - -$head ODE Solver$$ -For this example, we consider the Fourth order Runge-Kutta ODE solver. -Given an approximation solution at time $latex t_k$$ denoted by -$latex \tilde{z}_k (x)$$, and $latex \Delta t = t_{k+1} - t_k$$, -it defines the approximation solution $latex \tilde{z}_{k+1} (x)$$ -at time $latex t_{k+1}$$ by -$latex \[ -\begin{array}{rcl} -h_1 & = & h [ x , \tilde{z}_k (x) ] -\\ -h_2 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_1 / 2 ] -\\ -h_3 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_2 / 2 ] -\\ -h_4 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_3 ] -\\ -\tilde{z}_{k+1} (x) & = & - \tilde{z}_k (x) + \Delta t \; ( h_1 + 2 h_2 + 2 h_3 + h_4 ) / 6 -\end{array} -\] $$ -If $latex \tilde{z}_k (x) = z_k (x)$$, -$latex \tilde{z}_{k+1} (x) = z_{k+1} (x) + O( \Delta t^5 )$$. -Other ODE solvers can use a similar method to the one used below. - -$head ODE$$ -For this example the ODE is defined by -$latex z(0, x) = 0$$ and -$latex \[ - h[ x, z(t, x) ] = - \left( \begin{array}{c} - x_0 \\ - x_1 z_0 (t, x) \\ - \vdots \\ - x_{n-1} z_{n-2} (t, x) - \end{array} \right) - = - \left( \begin{array}{c} - \partial_t z_0 (t , x) \\ - \partial_t z_1 (t , x) \\ - \vdots \\ - \partial_t z_{n-1} (t , x) - \end{array} \right) -\] $$ - -$head Solution$$ -The solution of the ODE for this example, -which is used to check the results, -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 -$latex \[ - z(t, x) = - \left( \begin{array}{c} - x_0 t \\ - x_1 x_0 t^2 / 2 \\ - \vdots \\ - x_{n-1} x_{n-2} \ldots x_0 t^n / n ! - \end{array} \right) -\] $$ - - -$code -$srcfile%example/atomic/ode.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ - -# include - -namespace { - using CppAD::AD; - typedef AD a1double; - typedef AD a2double; - // - typedef CPPAD_TESTVECTOR( double ) a0vector; - typedef CPPAD_TESTVECTOR( a1double ) a1vector; - typedef CPPAD_TESTVECTOR( a2double ) a2vector; - // - // set once by main and kept that way - double delta_t_ = std::numeric_limits::quiet_NaN(); - size_t n_ = 0; - // - // The function h( x , y) - template - FloatVector h(const FloatVector& x, const FloatVector& y) - { assert( size_t( x.size() ) == n_ ); - assert( size_t( y.size() ) == n_ ); - FloatVector result(n_); - result[0] = x[0]; - for(size_t i = 1; i < n_; i++) - result[i] = x[i] * y[i-1]; - return result; - } - - // The 4-th Order Runge-Kutta Step - template - FloatVector Runge4(const FloatVector& x, const FloatVector& z0 - ) - { assert( size_t( x.size() ) == n_ ); - assert( size_t( z0.size() ) == n_ ); - // - typedef typename FloatVector::value_type Float; - // - Float dt = Float(delta_t_); - size_t m = z0.size(); - // - FloatVector h1(m), h2(m), h3(m), h4(m), result(m); - h1 = h( x, z0 ); - // - for(size_t i = 0; i < m; i++) - h2[i] = z0[i] + dt * h1[i] / 2.0; - h2 = h( x, h2 ); - // - for(size_t i = 0; i < m; i++) - h3[i] = z0[i] + dt * h2[i] / 2.0; - h3 = h( x, h3 ); - // - for(size_t i = 0; i < m; i++) - h4[i] = z0[i] + dt * h3[i]; - h4 = h( x, h4 ); - // - for(size_t i = 0; i < m; i++) - { Float dz = dt * ( h1[i] + 2.0*h2[i] + 2.0*h3[i] + h4[i] ) / 6.0; - result[i] = z0[i] + dz; - } - return result; - } - - // pack x and z into an ode_info vector - template - void pack( - FloatVector& ode_info , - const FloatVector& x , - const FloatVector& z ) - { assert( size_t( ode_info.size() ) == n_ + n_ ); - assert( size_t( x.size() ) == n_ ); - assert( size_t( z.size() ) == n_ ); - // - size_t offset = 0; - for(size_t i = 0; i < n_; i++) - ode_info[offset + i] = x[i]; - offset += n_; - for(size_t i = 0; i < n_; i++) - ode_info[offset + i] = z[i]; - } - - // unpack an ode_info vector - template - void unpack( - const FloatVector& ode_info , - FloatVector& x , - FloatVector& z ) - { assert( size_t( ode_info.size() ) == n_ + n_ ); - assert( size_t( x.size() ) == n_ ); - assert( size_t( z.size() ) == n_ ); - // - size_t offset = 0; - for(size_t i = 0; i < n_; i++) - x[i] = ode_info[offset + i]; - offset += n_; - for(size_t i = 0; i < n_; i++) - z[i] = ode_info[offset + i]; - } - - // Algorithm that z(t, x) - void ode_algo(const a1vector& ode_info_in, a1vector& ode_info_out) - { assert( size_t( ode_info_in.size() ) == n_ + n_ ); - assert( size_t( ode_info_out.size() ) == n_ + n_ ); - // - // initial ode information - a1vector x(n_), z0(n_); - unpack(ode_info_in, x, z0); - // - // advance z(t, x) - a1vector z1 = Runge4(x, z0); - // - // final ode information - pack(ode_info_out, x, z1); - // - return; - } -} -// -bool ode(void) -{ bool ok = true; - using CppAD::NearEqual; - double eps = std::numeric_limits::epsilon(); - // - // number of terms in the differential equation - n_ = 6; - // - // step size for the differentiail equation - size_t n_step = 10; - double T = 1.0; - delta_t_ = T / double(n_step); - // - // set parameter value and initial value of the ode - a1vector ax(n_), az0(n_); - for(size_t i = 0; i < n_; i++) - { ax[i] = a1double(i + 1); - az0[i] = a1double(0); - } - // - // pack ode information input vector - a1vector ode_info_in(2 * n_); - pack(ode_info_in, ax, az0); - // - // create checkpoint version of the algorithm - a1vector ode_info_out(2 * n_); - CppAD::checkpoint ode_check( - "ode", ode_algo, ode_info_in, ode_info_out - ); - // - // set the independent variables for recording - CppAD::Independent( ax ); - // - // repack to get dependence on ax - pack(ode_info_in, ax, az0); - // - // Now run the checkpoint algorithm n_step times - for(size_t k = 0; k < n_step; k++) - { ode_check(ode_info_in, ode_info_out); - ode_info_in = ode_info_out; - } - // - // Unpack the results (must use ax1 so do not overwrite ax) - a1vector ax1(n_), az1(n_); - unpack(ode_info_out, ax1, az1); - // - // We could record a complicated funciton of x and z(T, x) in f, - // but make this example simpler we record x -> z(T, x). - CppAD::ADFun f(ax, az1); - // - // check function values - a0vector x(n_), z1(n_); - for(size_t j = 0; j < n_; j++) - x[j] = double(j + 1); - z1 = f.Forward(0, x); - // - // separate calculation of z(t, x) - a0vector check_z1(n_); - check_z1[0] = x[0] * T; - for(size_t i = 1; i < n_; i++) - check_z1[i] = x[i] * T * check_z1[i-1] / double(i+1); - // - // expected accuracy for each component of of z(t, x) - a0vector acc(n_); - for(size_t i = 0; i < n_; i++) - { if( i < 4 ) - { // Runge-Kutta methos is exact for this case - acc[i] = 10. * eps; - } - else - { acc[i] = 1.0; - for(size_t k = 0; k < 5; k++) - acc[i] *= x[k] * delta_t_; - } - } - // check z1(T, x) - for(size_t i = 0; i < n_; i++) - ok &= NearEqual(z1[i] , check_z1[i], acc[i], acc[i]); - // - // Now use f to compute a derivative. For this 'simple' example it is - // the derivative of z_{n-1} (T, x) respect to x of the - a0vector w(n_), dw(n_); - for(size_t i = 0; i < n_; i++) - { w[i] = 0.0; - if( i == n_ - 1 ) - w[i] = 1.0; - } - dw = f.Reverse(1, w); - for(size_t j = 0; j < n_; j++) - { double check = z1[n_ - 1] / x[j]; - ok &= NearEqual(dw[j] , check, 100.*eps, 100.*eps); - } - // - return ok; -} -// END C++ diff -Nru cppad-2018.00.00.0/example/atomic/reciprocal.cpp cppad-2019.02.00.0/example/atomic/reciprocal.cpp --- cppad-2018.00.00.0/example/atomic/reciprocal.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/reciprocal.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,400 +0,0 @@ -// $Id: reciprocal.cpp 3821 2016-06-30 02:53:40Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_reciprocal.cpp$$ -$spell - enum -$$ - -$section Reciprocal as an Atomic Operation: Example and Test$$ -$mindex set_sparsity_enum$$ - -$head Theory$$ -This example demonstrates using $cref atomic_base$$ -to define the operation -$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$$ -$srccode%cpp% */ -# include -namespace { // isolate items below to this file -using CppAD::vector; // abbreviate as vector -// -// a utility to compute the union of two sets. -using CppAD::set_union; -// -class atomic_reciprocal : public CppAD::atomic_base { -/* %$$ -$head Constructor $$ -$srccode%cpp% */ -public: - // constructor (could use const char* for name) - atomic_reciprocal(const std::string& name) : - // this exmaple only uses set sparsity patterns - CppAD::atomic_base(name, atomic_base::set_sparsity_enum) - { } -private: -/* %$$ -$head forward$$ -$srccode%cpp% */ - // forward mode routine called by CppAD - virtual bool forward( - size_t p , - size_t q , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { -# ifndef NDEBUG - size_t n = tx.size() / (q + 1); - size_t m = ty.size() / (q + 1); -# endif - assert( n == 1 ); - assert( m == 1 ); - assert( p <= q ); - - // return flag - bool ok = q <= 2; - - // check for defining variable information - // This case must always be implemented - if( vx.size() > 0 ) - vy[0] = vx[0]; - - // Order zero forward mode. - // This case must always be implemented - // y^0 = f( x^0 ) = 1 / x^0 - double f = 1. / tx[0]; - if( p <= 0 ) - ty[0] = f; - if( q <= 0 ) - return ok; - assert( vx.size() == 0 ); - - // Order one forward mode. - // This case needed if first order forward mode is used. - // y^1 = f'( x^0 ) x^1 - double fp = - f / tx[0]; - if( p <= 1 ) - ty[1] = fp * tx[1]; - if( q <= 1 ) - return ok; - - // Order two forward mode. - // This case needed if second order forward mode is used. - // 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 - double fpp = - 2.0 * fp / tx[0]; - ty[2] = tx[1] * fpp * tx[1] / 2.0 + fp * tx[2]; - if( q <= 2 ) - return ok; - - // Assume we are not using forward mode with order > 2 - assert( ! ok ); - return ok; - } -/* %$$ -$head reverse$$ -$srccode%cpp% */ - // reverse mode routine called by CppAD - virtual bool reverse( - size_t q , - const vector& tx , - const vector& ty , - vector& px , - const vector& py - ) - { -# ifndef NDEBUG - size_t n = tx.size() / (q + 1); - size_t m = ty.size() / (q + 1); -# endif - assert( px.size() == n * (q + 1) ); - assert( py.size() == m * (q + 1) ); - assert( n == 1 ); - assert( m == 1 ); - bool ok = q <= 2; - - double f, fp, fpp, fppp; - switch(q) - { case 0: - // This case 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;; - assert(ok); - break; - - case 1: - // This case 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; - assert(ok); - break; - - case 2: - // This 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; - assert(ok); - break; - - default: - assert(!ok); - } - return ok; - } -/* %$$ -$head for_sparse_jac$$ -$srccode%cpp% */ - // 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 , - const vector& x ) - { // This function needed if using f.ForSparseJac -# ifndef NDEBUG - size_t n = r.size(); - size_t m = s.size(); -# endif - assert( n == x.size() ); - 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; - } -/* %$$ -$head rev_sparse_jac$$ -$srccode%cpp% */ - // 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 , - const vector& x ) - { // This function needed if using RevSparseJac or optimize -# ifndef NDEBUG - size_t n = st.size(); - size_t m = rt.size(); -# endif - assert( n == x.size() ); - assert( n == 1 ); - assert( m == 1 ); - - // sparsity for S(x)^T = f'(x)^T * R^T is same as sparsity for R^T - st[0] = rt[0]; - - return true; - } -/* %$$ -$head rev_sparse_hes$$ -$srccode%cpp% */ - // 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 , - const vector& x ) - { // This function needed if using RevSparseHes -# ifndef NDEBUG - size_t n = vx.size(); - size_t m = s.size(); -# endif - assert( x.size() == n ); - assert( t.size() == n ); - assert( r.size() == n ); - assert( u.size() == m ); - assert( v.size() == n ); - 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; - v[0] = u[0]; - - // include forward Jacobian sparsity in Hessian sparsity - // (note sparsty for f''(x) * R same as for R) - if( s[0] ) - v[0] = set_union(v[0], r[0] ); - - return true; - } -/* %$$ -$head End Class Definition$$ -$srccode%cpp% */ -}; // End of atomic_reciprocal class -} // End empty namespace - -/* %$$ -$head Use Atomic Function$$ -$srccode%cpp% */ -bool reciprocal(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * CppAD::numeric_limits::epsilon(); -/* %$$ -$subhead Constructor$$ -$srccode%cpp% */ - // -------------------------------------------------------------------- - // Create the atomic reciprocal object - atomic_reciprocal afun("atomic_reciprocal"); -/* %$$ -$subhead Recording$$ -$srccode%cpp% */ - // 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); - afun(ax, au); // u = 1 / x - - // now use AD division to invert to invert the operation - ay[0] = 1.0 / au[0]; // y = 1 / u = x - - // create f: x -> y and stop tape recording - CppAD::ADFun f; - f.Dependent (ax, ay); // f(x) = x -/* %$$ -$subhead forward$$ -$srccode%cpp% */ - // 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); -/* %$$ -$subhead reverse$$ -$srccode%cpp% */ - // 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); -/* %$$ -$subhead for_sparse_jac$$ -$srccode%cpp% */ - // 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] -/* %$$ -$subhead rev_sparse_jac$$ -$srccode%cpp% */ - // 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] -/* %$$ -$subhead rev_sparse_hes$$ -$srccode%cpp% */ - // 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 - // - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/reverse.cpp cppad-2019.02.00.0/example/atomic/reverse.cpp --- cppad-2018.00.00.0/example/atomic/reverse.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/reverse.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,349 +0,0 @@ -// $Id$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_reverse.cpp$$ -$spell - Jacobian -$$ - -$section Atomic Reverse: Example and Test$$ - -$head Purpose$$ -This example demonstrates reverse mode derivative calculation -using an atomic operation. - -$head function$$ -For this example, the atomic function -$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by -$latex \[ -f(x) = \left( \begin{array}{c} - x_2 * x_2 \\ - x_0 * x_1 -\end{array} \right) -\] $$ -The corresponding Jacobian is -$latex \[ -f^{(1)} (x) = \left( \begin{array}{ccc} - 0 & 0 & 2 x_2 \\ -x_1 & x_0 & 0 -\end{array} \right) -\] $$ -The Hessians of the component functions are -$latex \[ -f_0^{(2)} ( x ) = \left( \begin{array}{ccc} - 0 & 0 & 0 \\ - 0 & 0 & 0 \\ - 0 & 0 & 2 -\end{array} \right) -\W{,} -f_1^{(2)} ( x ) = \left( \begin{array}{ccc} - 0 & 1 & 0 \\ - 1 & 0 & 0 \\ - 0 & 0 & 0 -\end{array} \right) -\] $$ - -$nospell - -$head Start Class Definition$$ -$srccode%cpp% */ -# include -namespace { // isolate items below to this file -using CppAD::vector; // abbreviate as vector -// -class atomic_reverse : public CppAD::atomic_base { -/* %$$ -$head Constructor $$ -$srccode%cpp% */ -public: - // constructor (could use const char* for name) - atomic_reverse(const std::string& name) : - // this example does not use sparsity patterns - CppAD::atomic_base(name) - { } -private: -/* %$$ -$head forward$$ -$srccode%cpp% */ - // forward mode routine called by CppAD - virtual bool forward( - size_t p , - size_t q , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { - size_t q1 = q + 1; -# ifndef NDEBUG - size_t n = tx.size() / q1; - size_t m = ty.size() / q1; -# endif - assert( n == 3 ); - assert( m == 2 ); - assert( p <= q ); - - // this example only implements up to first order forward mode - bool ok = q <= 1; - if( ! ok ) - return ok; - - // check for defining variable information - // This case must always be implemented - if( vx.size() > 0 ) - { vy[0] = vx[2]; - vy[1] = vx[0] || vx[1]; - } - // ------------------------------------------------------------------ - // Zero forward mode. - // This case must always be implemented - // f(x) = [ x_2 * x_2 ] - // [ x_0 * x_1 ] - // y^0 = f( x^0 ) - if( p <= 0 ) - { // y_0^0 = x_2^0 * x_2^0 - ty[0 * q1 + 0] = tx[2 * q1 + 0] * tx[2 * q1 + 0]; - // y_1^0 = x_0^0 * x_1^0 - ty[1 * q1 + 0] = tx[0 * q1 + 0] * tx[1 * q1 + 0]; - } - if( q <= 0 ) - return ok; - // ------------------------------------------------------------------ - // First order one forward mode. - // This case is needed if first order forward mode is used. - // f'(x) = [ 0, 0, 2 * x_2 ] - // [ x_1, x_0, 0 ] - // y^1 = f'(x^0) * x^1 - if( p <= 1 ) - { // y_0^1 = 2 * x_2^0 * x_2^1 - ty[0 * q1 + 1] = 2.0 * tx[2 * q1 + 0] * tx[2 * q1 + 1]; - - // y_1^1 = x_1^0 * x_0^1 + x_0^0 * x_1^1 - ty[1 * q1 + 1] = tx[1 * q1 + 0] * tx[0 * q1 + 1]; - ty[1 * q1 + 1] += tx[0 * q1 + 0] * tx[1 * q1 + 1]; - } - return ok; - } -/* %$$ -$head reverse$$ -$srccode%cpp% */ - // reverse mode routine called by CppAD - virtual bool reverse( - size_t q , - const vector& tx , - const vector& ty , - vector& px , - const vector& py - ) - { - size_t q1 = q + 1; - size_t n = tx.size() / q1; -# ifndef NDEBUG - size_t m = ty.size() / q1; -# endif - assert( n == 3 ); - assert( m == 2 ); - - // this example only implements up to second order reverse mode - bool ok = q1 <= 2; - if( ! ok ) - return ok; - // - // initalize summation as zero - for(size_t j = 0; j < n; j++) - for(size_t k = 0; k < q; k++) - px[j * q1 + k] = 0.0; - // - if( q1 == 2 ) - { // -------------------------------------------------------------- - // Second order reverse first compute partials of first order - // We use the notation pf_ij^k for partial of F_i^1 w.r.t. x_j^k - // - // y_0^1 = 2 * x_2^0 * x_2^1 - // pf_02^0 = 2 * x_2^1 - // pf_02^1 = 2 * x_2^0 - // - // y_1^1 = x_1^0 * x_0^1 + x_0^0 * x_1^1 - // pf_10^0 = x_1^1 - // pf_11^0 = x_0^1 - // pf_10^1 = x_1^0 - // pf_11^1 = x_0^0 - // - // px_0^0 += py_0^1 * pf_00^0 + py_1^1 * pf_10^0 - // += py_1^1 * x_1^1 - px[0 * q1 + 0] += py[1 * q1 + 1] * tx[1 * q1 + 1]; - // - // px_0^1 += py_0^1 * pf_00^1 + py_1^1 * pf_10^1 - // += py_1^1 * x_1^0 - px[0 * q1 + 1] += py[1 * q1 + 1] * tx[1 * q1 + 0]; - // - // px_1^0 += py_0^1 * pf_01^0 + py_1^1 * pf_11^0 - // += py_1^1 * x_0^1 - px[1 * q1 + 0] += py[1 * q1 + 1] * tx[0 * q1 + 1]; - // - // px_1^1 += py_0^1 * pf_01^1 + py_1^1 * pf_11^1 - // += py_1^1 * x_0^0 - px[1 * q1 + 1] += py[1 * q1 + 1] * tx[0 * q1 + 0]; - // - // px_2^0 += py_0^1 * pf_02^0 + py_1^1 * pf_12^0 - // += py_0^1 * 2 * x_2^1 - px[2 * q1 + 0] += py[0 * q1 + 1] * 2.0 * tx[2 * q1 + 1]; - // - // px_2^1 += py_0^1 * pf_02^1 + py_1^1 * pf_12^1 - // += py_0^1 * 2 * x_2^0 - px[2 * q1 + 1] += py[0 * q1 + 1] * 2.0 * tx[2 * q1 + 0]; - } - // -------------------------------------------------------------- - // First order reverse computes partials of zero order coefficients - // We use the notation pf_ij for partial of F_i^0 w.r.t. x_j^0 - // - // y_0^0 = x_2^0 * x_2^0 - // pf_00 = 0, pf_01 = 0, pf_02 = 2 * x_2^0 - // - // y_1^0 = x_0^0 * x_1^0 - // pf_10 = x_1^0, pf_11 = x_0^0, pf_12 = 0 - // - // px_0^0 += py_0^0 * pf_00 + py_1^0 * pf_10 - // += py_1^0 * x_1^0 - px[0 * q1 + 0] += py[1 * q1 + 0] * tx[1 * q1 + 0]; - // - // px_1^0 += py_1^0 * pf_01 + py_1^0 * pf_11 - // += py_1^0 * x_0^0 - px[1 * q1 + 0] += py[1 * q1 + 0] * tx[0 * q1 + 0]; - // - // px_2^0 += py_1^0 * pf_02 + py_1^0 * pf_12 - // += py_0^0 * 2.0 * x_2^0 - px[2 * q1 + 0] += py[0 * q1 + 0] * 2.0 * tx[2 * q1 + 0]; - // -------------------------------------------------------------- - return ok; - } -}; -} // End empty namespace -/* %$$ -$head Use Atomic Function$$ -$srccode%cpp% */ -bool reverse(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * CppAD::numeric_limits::epsilon(); - // - // Create the atomic_reverse object - atomic_reverse afun("atomic_reverse"); - // - // Create the function f(u) - // - // domain space vector - size_t n = 3; - double x_0 = 1.00; - double x_1 = 2.00; - double x_2 = 3.00; - vector< AD > au(n); - au[0] = x_0; - au[1] = x_1; - au[2] = x_2; - - // declare independent variables and start tape recording - CppAD::Independent(au); - - // range space vector - size_t m = 2; - vector< AD > ay(m); - - // call user function - vector< AD > ax = au; - afun(ax, ay); - - // create f: u -> y and stop tape recording - CppAD::ADFun f; - f.Dependent (au, ay); // y = f(u) - // - // check function value - double check = x_2 * x_2; - ok &= NearEqual( Value(ay[0]) , check, eps, eps); - check = x_0 * x_1; - ok &= NearEqual( Value(ay[1]) , check, eps, eps); - - // -------------------------------------------------------------------- - // zero order forward - // - vector x0(n), y0(m); - x0[0] = x_0; - x0[1] = x_1; - x0[2] = x_2; - y0 = f.Forward(0, x0); - check = x_2 * x_2; - ok &= NearEqual(y0[0] , check, eps, eps); - check = x_0 * x_1; - ok &= NearEqual(y0[1] , check, eps, eps); - // -------------------------------------------------------------------- - // first order reverse - // - // value of Jacobian of f - double check_jac[] = { - 0.0, 0.0, 2.0 * x_2, - x_1, x_0, 0.0 - }; - vector w(m), dw(n); - // - // check derivative of f_0 (x) - for(size_t i = 0; i < m; i++) - { w[i] = 1.0; - w[1-i] = 0.0; - dw = f.Reverse(1, w); - for(size_t j = 0; j < n; j++) - { // compute partial in j-th component direction - ok &= NearEqual(dw[j], check_jac[i * n + j], eps, eps); - } - } - // -------------------------------------------------------------------- - // second order reverse - // - // value of Hessian of f_0 - double check_hes_0[] = { - 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, - 0.0, 0.0, 2.0 - }; - // - // value of Hessian of f_1 - double check_hes_1[] = { - 0.0, 1.0, 0.0, - 1.0, 0.0, 0.0, - 0.0, 0.0, 0.0 - }; - vector x1(n), dw2( 2 * n ); - for(size_t j = 0; j < n; j++) - { for(size_t j1 = 0; j1 < n; j1++) - x1[j1] = 0.0; - x1[j] = 1.0; - // first order forward - f.Forward(1, x1); - w[0] = 1.0; - w[1] = 0.0; - dw2 = f.Reverse(2, w); - for(size_t i = 0; i < n; i++) - ok &= NearEqual(dw2[i * 2 + 1], check_hes_0[i * n + j], eps, eps); - w[0] = 0.0; - w[1] = 1.0; - dw2 = f.Reverse(2, w); - for(size_t i = 0; i < n; i++) - ok &= NearEqual(dw2[i * 2 + 1], check_hes_1[i * n + j], eps, eps); - } - // -------------------------------------------------------------------- - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/rev_sparse_hes.cpp cppad-2019.02.00.0/example/atomic/rev_sparse_hes.cpp --- cppad-2018.00.00.0/example/atomic/rev_sparse_hes.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/rev_sparse_hes.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,351 +0,0 @@ -// $Id$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_rev_sparse_hes.cpp$$ - -$section Atomic Reverse Hessian Sparsity: Example and Test$$ - -$head Purpose$$ -This example demonstrates calculation of the reverse Hessian sparsity pattern -for an atomic operation. - -$head function$$ -For this example, the atomic function -$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by -$latex \[ -f( x ) = \left( \begin{array}{c} - x_2 * x_2 \\ - x_0 * x_1 -\end{array} \right) -\] $$ -The Hessians of the component functions are -$latex \[ -f_0^{(2)} ( x ) = \left( \begin{array}{ccc} - 0 & 0 & 0 \\ - 0 & 0 & 0 \\ - 0 & 0 & 2 -\end{array} \right) -\W{,} -f_1^{(2)} ( x ) = \left( \begin{array}{ccc} - 0 & 1 & 0 \\ - 1 & 0 & 0 \\ - 0 & 0 & 0 -\end{array} \right) -\] $$ - -$nospell - -$head Start Class Definition$$ -$srccode%cpp% */ -# include -namespace { // isolate items below to this file -using CppAD::vector; // abbreviate as vector -// -class atomic_rev_sparse_hes : public CppAD::atomic_base { -/* %$$ -$head Constructor $$ -$srccode%cpp% */ -public: - // constructor (could use const char* for name) - atomic_rev_sparse_hes(const std::string& name) : - // this example only uses pack sparsity patterns - CppAD::atomic_base(name, pack_sparsity_enum) - { } -private: -/* %$$ -$head forward$$ -$srccode%cpp% */ - // forward mode routine called by CppAD - virtual bool forward( - size_t p , - size_t q , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { -# ifndef NDEBUG - size_t n = tx.size() / (q + 1); - size_t m = ty.size() / (q + 1); -# endif - assert( n == 3 ); - assert( m == 2 ); - - // return flag - bool ok = q == 0; - if( ! ok ) - return ok; - - // check for defining variable information - // This case must always be implemented - if( vx.size() > 0 ) - { vy[0] = vx[0]; - vy[1] = vx[0] || vy[0]; - } - - // Order zero forward mode. - // This case must always be implemented - // f(x) = [ x_0 * x_0 ] - // [ x_0 * x_1 ] - assert( p <= 0 ); - if( p <= 0 ) - { ty[0] = tx[2] * tx[2]; - ty[1] = tx[0] * tx[1]; - } - return ok; - } -/* %$$ -$head for_sparse_jac$$ -$srccode%cpp% */ - // forward Jacobian sparsity routine called by CppAD - virtual bool for_sparse_jac( - size_t q , - const CppAD::vectorBool& r , - CppAD::vectorBool& s , - const vector& x ) - { // This function needed because we are using ForSparseHes - // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) -# ifndef NDEBUG - size_t n = r.size() / q; - size_t m = s.size() / q; -# endif - assert( n == x.size() ); - assert( n == 3 ); - assert( m == 2 ); - - - // f'(x) = [ 0, 0, 2 x_2 ] - // [ x_1, x_0, 0 ] - - // sparsity for first row of S(x) = f'(x) * R - size_t i = 0; - for(size_t j = 0; j < q; j++) - s[ i * q + j ] = r[ 2 * q + j ]; - - // sparsity for second row of S(x) = f'(x) * R - i = 1; - for(size_t j = 0; j < q; j++) - s[ i * q + j ] = r[ 0 * q + j ] | r[ 1 * q + j]; - - return true; - } -/* %$$ -$head rev_sparse_jac$$ -$srccode%cpp% */ - // reverse Jacobian sparsity routine called by CppAD - virtual bool rev_sparse_jac( - size_t q , - const CppAD::vectorBool& rt , - CppAD::vectorBool& st , - const vector& x ) - { // This function needed because we are using ForSparseHes - // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) -# ifndef NDEBUG - size_t m = rt.size() / q; - size_t n = st.size() / q; -# endif - assert( n == x.size() ); - assert( n == 3 ); - assert( m == 2 ); - - // [ 0, x_1 ] - // f'(x)^T = [ 0, x_0 ] - // [ 2 x_2, 0 ] - - // sparsity for first row of S(x)^T = f'(x)^T * R^T - size_t i = 0; - for(size_t j = 0; j < q; j++) - st[ i * q + j ] = rt[ 1 * q + j ]; - - // sparsity for second row of S(x)^T = f'(x)^T * R^T - i = 1; - for(size_t j = 0; j < q; j++) - st[ i * q + j ] = rt[ 1 * q + j ]; - - // sparsity for third row of S(x)^T = f'(x)^T * R^T - i = 2; - for(size_t j = 0; j < q; j++) - st[ i * q + j ] = rt[ 0 * q + j ]; - - return true; - } -/* %$$ -$head rev_sparse_hes$$ -$srccode%cpp% */ - // reverse Hessian sparsity routine called by CppAD - virtual bool rev_sparse_hes( - const vector& vx, - const vector& s , - vector& t , - size_t q , - const CppAD::vectorBool& r , - const CppAD::vectorBool& u , - CppAD::vectorBool& v , - const vector& x ) - { // This function needed because we are using RevSparseHes - // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) -# ifndef NDEBUG - size_t m = s.size(); - size_t n = t.size(); -# endif - assert( x.size() == n ); - assert( r.size() == n * q ); - assert( u.size() == m * q ); - assert( v.size() == n * q ); - assert( n == 3 ); - assert( m == 2 ); - // - // f'(x) = [ 0, 0, 2 x_2 ] - // [ x_1, x_0, 0 ] - // - // [ 0 , 0 , 0 ] [ 0 , 1 , 0 ] - // f_0''(x) = [ 0 , 0 , 0 ] f_1^{(2)} (x) = [ 1 , 0 , 0 ] - // [ 0 , 0 , 2 ] [ 0 , 0 , 0 ] - // ------------------------------------------------------------------ - // sparsity pattern for row vector T(x) = S(x) * f'(x) - t[0] = s[1]; - t[1] = s[1]; - t[2] = s[0]; - // ------------------------------------------------------------------ - // sparsity pattern for W(x) = f'(x)^T * U(x) - for(size_t j = 0; j < q; j++) - { v[ 0 * q + j ] = u[ 1 * q + j ]; - v[ 1 * q + j ] = u[ 1 * q + j ]; - v[ 2 * q + j ] = u[ 0 * q + j ]; - } - // ------------------------------------------------------------------ - // sparsity pattern for Q(x) = W(x) + S_0 (x) * f_0^{(2)} (x) * R - if( s[0] ) - { for(size_t j = 0; j < q; j++) - { // cannot use |= with vectorBool - v[ 2 * q + j ] = bool(v[ 2 * q + j ]) | bool(r[ 2 * q + j ]); - } - } - // ------------------------------------------------------------------ - // sparsity pattern for V(x) = Q(x) + S_1 (x) * f_1^{(2)} (x) * R - if( s[1] ) - { for(size_t j = 0; j < q; j++) - { // cannot use |= with vectorBool - v[ 0 * q + j ] = bool(v[ 0 * q + j ]) | bool(r[ 1 * q + j ]); - v[ 1 * q + j ] = bool(v[ 1 * q + j ]) | bool(r[ 0 * q + j ]); - } - } - return true; - } -}; // End of atomic_rev_sparse_hes class - -/* %$$ -$head Use Atomic Function$$ -$srccode%cpp% */ -bool use_atomic_rev_sparse_hes(bool x_1_variable) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * CppAD::numeric_limits::epsilon(); - // - // Create the atomic rev_sparse_hes object - atomic_rev_sparse_hes afun("atomic_rev_sparse_hes"); - // - // Create the function f(u) - // - // domain space vector - size_t n = 3; - double x_0 = 1.00; - double x_1 = 2.00; - double x_2 = 3.00; - vector< AD > au(n); - au[0] = x_0; - au[1] = x_1; - au[2] = x_2; - - // declare independent variables and start tape recording - CppAD::Independent(au); - - // range space vector - size_t m = 2; - vector< AD > ay(m); - - // call user function - vector< AD > ax(n); - ax[0] = au[0]; - ax[2] = au[2]; - if( x_1_variable ) - ax[1] = au[1]; - else - ax[1] = x_1; - afun(ax, ay); // y = [ x_2 * x_2 , x_0 * x_1 ]^T - - // create f: u -> y and stop tape recording - CppAD::ADFun f; - f.Dependent (au, ay); // f(u) = y - // - // check function value - double check = x_2 * x_2; - ok &= NearEqual( Value(ay[0]) , check, eps, eps); - check = x_0 * x_1; - ok &= NearEqual( Value(ay[1]) , check, eps, eps); - - // check zero order forward mode - size_t q; - vector xq(n), yq(m); - q = 0; - xq[0] = x_0; - xq[1] = x_1; - xq[2] = x_2; - yq = f.Forward(q, xq); - check = x_2 * x_2; - ok &= NearEqual(yq[0] , check, eps, eps); - check = x_0 * x_1; - ok &= NearEqual(yq[1] , check, eps, eps); - - // reverse sparse Hessian - CppAD::vectorBool r(n * n), s(m), h(n * n); - for(size_t i = 0; i < n; i++) - { for(size_t j = 0; j < n; j++) - r[i * n + j] = i == j; - } - for(size_t i = 0; i < m; i++) - s[i] = true; - f.ForSparseJac(n, r); - h = f.RevSparseHes(n, s); - - // check result - CppAD::vectorBool check_h(n * n); - for(size_t i = 0; i < n * n; i++) - check_h[i] = false; - check_h[ 2 * n + 2 ] = true; - if( x_1_variable ) - { check_h[0 * n + 1] = true; - check_h[1 * n + 0] = true; - } - for(size_t i = 0; i < n * n; i++) - ok &= h[ i ] == check_h[ i ]; - // - return ok; -} -} // End empty namespace -/* %$$ -$head Test with x_1 Both a Variable and a Parameter$$ -$srccode%cpp% */ -bool rev_sparse_hes(void) -{ bool ok = true; - // test with x_1 a variable - ok &= use_atomic_rev_sparse_hes(true); - // test with x_1 a parameter - ok &= use_atomic_rev_sparse_hes(false); - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/rev_sparse_jac.cpp cppad-2019.02.00.0/example/atomic/rev_sparse_jac.cpp --- cppad-2018.00.00.0/example/atomic/rev_sparse_jac.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/rev_sparse_jac.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,247 +0,0 @@ -// $Id$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_rev_sparse_jac.cpp$$ -$spell - Jacobian - Jacobians -$$ - -$section Atomic Reverse Jacobian Sparsity: Example and Test$$ - -$head Purpose$$ -This example demonstrates calculation of the -reverse Jacobians sparsity pattern for an atomic operation. - -$head function$$ -For this example, the atomic function -$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by -$latex \[ -f( x ) = \left( \begin{array}{c} - x_2 * x_2 \\ - x_0 * x_1 -\end{array} \right) -\] $$ -The corresponding Jacobian is -$latex \[ -f^{(1)} (x) = \left( \begin{array}{ccc} - 0 & 0 & 2 x_2 \\ -x_1 & x_0 & 0 -\end{array} \right) -\] $$ - -$nospell - -$head Start Class Definition$$ -$srccode%cpp% */ -# include -namespace { // isolate items below to this file -using CppAD::vector; // abbreviate as vector -// -class atomic_rev_sparse_jac : public CppAD::atomic_base { -/* %$$ -$head Constructor $$ -$srccode%cpp% */ -public: - // constructor (could use const char* for name) - atomic_rev_sparse_jac(const std::string& name) : - // this example only uses pack sparsity patterns - CppAD::atomic_base(name, pack_sparsity_enum) - { } -private: -/* %$$ -$head forward$$ -$srccode%cpp% */ - // forward mode routine called by CppAD - virtual bool forward( - size_t p , - size_t q , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty - ) - { -# ifndef NDEBUG - size_t n = tx.size() / (q + 1); - size_t m = ty.size() / (q + 1); -# endif - assert( n == 3 ); - assert( m == 2 ); - - // return flag - bool ok = q == 0; - if( ! ok ) - return ok; - - // check for defining variable information - // This case must always be implemented - if( vx.size() > 0 ) - { vy[0] = vx[0]; - vy[1] = vx[0] || vy[0]; - } - - // Order zero forward mode. - // This case must always be implemented - // f(x) = [ x_0 * x_0 ] - // [ x_0 * x_1 ] - assert( p <= 0 ); - if( p <= 0 ) - { ty[0] = tx[2] * tx[2]; - ty[1] = tx[0] * tx[1]; - } - return ok; - } -/* %$$ -$head rev_sparse_jac$$ -$srccode%cpp% */ - // reverse Jacobian sparsity routine called by CppAD - virtual bool rev_sparse_jac( - size_t q , - const CppAD::vectorBool& rt , - CppAD::vectorBool& st , - const vector& x ) - { // This function needed because we are using RevSparseHes - // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) -# ifndef NDEBUG - size_t m = rt.size() / q; - size_t n = st.size() / q; -# endif - assert( n == x.size() ); - assert( n == 3 ); - assert( m == 2 ); - - // [ 0, x_1 ] - // f'(x)^T = [ 0, x_0 ] - // [ 2 x_2, 0 ] - - // sparsity for first row of S(x)^T = f'(x)^T * R^T - size_t i = 0; - for(size_t j = 0; j < q; j++) - st[ i * q + j ] = rt[ 1 * q + j ]; - - // sparsity for second row of S(x)^T = f'(x)^T * R^T - i = 1; - for(size_t j = 0; j < q; j++) - st[ i * q + j ] = rt[ 1 * q + j ]; - - // sparsity for third row of S(x)^T = f'(x)^T * R^T - i = 2; - for(size_t j = 0; j < q; j++) - st[ i * q + j ] = rt[ 0 * q + j ]; - - return true; - } -}; // End of atomic_rev_sparse_jac class - -/* %$$ -$head Use Atomic Function$$ -$srccode%cpp% */ -bool use_atomic_rev_sparse_jac(bool x_1_variable) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * CppAD::numeric_limits::epsilon(); - // - // Create the atomic rev_sparse_jac object - atomic_rev_sparse_jac afun("atomic_rev_sparse_jac"); - // - // Create the function f(u) - // - // domain space vector - size_t n = 3; - double x_0 = 1.00; - double x_1 = 2.00; - double x_2 = 3.00; - vector< AD > au(n); - au[0] = x_0; - au[1] = x_1; - au[2] = x_2; - - // declare independent variables and start tape recording - CppAD::Independent(au); - - // range space vector - size_t m = 2; - vector< AD > ay(m); - - // call user function - vector< AD > ax(n); - ax[0] = au[0]; - ax[2] = au[2]; - if( x_1_variable ) - ax[1] = au[1]; - else - ax[1] = x_1; - afun(ax, ay); // y = [ x_2 * x_2 , x_0 * x_1 ]^T - - // create f: u -> y and stop tape recording - CppAD::ADFun f; - f.Dependent (au, ay); // f(u) = y - // - // check function value - double check = x_2 * x_2; - ok &= NearEqual( Value(ay[0]) , check, eps, eps); - check = x_0 * x_1; - ok &= NearEqual( Value(ay[1]) , check, eps, eps); - - // check zero order forward mode - size_t q; - vector xq(n), yq(m); - q = 0; - xq[0] = x_0; - xq[1] = x_1; - xq[2] = x_2; - yq = f.Forward(q, xq); - check = x_2 * x_2; - ok &= NearEqual(yq[0] , check, eps, eps); - check = x_0 * x_1; - ok &= NearEqual(yq[1] , check, eps, eps); - - // forward sparse Jacobian - CppAD::vectorBool r(m * m), s(m * n); - // r = identity matrix - for(size_t i = 0; i < m; i++) - for(size_t j = 0; j < m; j++) - r[ i * m + j] = i == j; - s = f.RevSparseJac(m, r); - - // check result - CppAD::vectorBool check_s(m * n); - check_s[ 0 * n + 0 ] = false; - check_s[ 0 * n + 1 ] = false; - check_s[ 0 * n + 2 ] = true; - check_s[ 1 * n + 0 ] = true; - check_s[ 1 * n + 1 ] = x_1_variable; - check_s[ 1 * n + 2 ] = false; - // - for(size_t i = 0; i < m * n; i++) - ok &= s[ i ] == check_s[ i ]; - // - return ok; -} -} // End empty namespace -/* %$$ -$head Test with x_1 Both a Variable and a Parameter$$ -$srccode%cpp% */ -bool rev_sparse_jac(void) -{ bool ok = true; - // test with x_1 a variable - ok &= use_atomic_rev_sparse_jac(true); - // test with x_1 a parameter - ok &= use_atomic_rev_sparse_jac(false); - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/set_sparsity.cpp cppad-2019.02.00.0/example/atomic/set_sparsity.cpp --- cppad-2018.00.00.0/example/atomic/set_sparsity.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/set_sparsity.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,342 +0,0 @@ -// $Id$ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_set_sparsity.cpp$$ -$spell - enum -$$ - -$section Atomic Sparsity with Set 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 ) = \left( \begin{array}{c} - x_2 \\ - x_0 * x_1 -\end{array} \right) -\] $$ - -$head set_sparsity_enum$$ -This example only uses set sparsity patterns. - -$nospell - -$head Start Class Definition$$ -$srccode%cpp% */ -# include -namespace { // isolate items below to this file -using CppAD::vector; // vector -typedef vector< std::set > set_vector; // atomic_sparsity -// -// a utility to compute the union of two sets. -using CppAD::set_union; -// -class atomic_set_sparsity : public CppAD::atomic_base { -/* %$$ -$head Constructor $$ -$srccode%cpp% */ -public: - // constructor - atomic_set_sparsity(const std::string& name) : - // this exampel only uses set sparsity patterns - CppAD::atomic_base(name, set_sparsity_enum ) - { } -private: -/* %$$ -$head forward$$ -$srccode%cpp% */ - // 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); -# ifndef NDEBUG - size_t m = ty.size() / (q + 1); -# endif - 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$$ -$srccode%cpp% */ - // for_sparse_jac - virtual bool for_sparse_jac( - size_t p , - const set_vector& r , - set_vector& s , - const vector& x ) - { // This function needed if using f.ForSparseJac -# ifndef NDEBUG - size_t n = r.size(); - size_t m = s.size(); -# endif - assert( n == x.size() ); - assert( n == 3 ); - assert( m == 2 ); - - // sparsity for S(x) = f'(x) * R = [ 0, 0, 1 ] * R - s[0] = r[2]; - // s[1] = union(r[0], r[1]) - s[1] = set_union(r[0], r[1]); - // - return true; - } -/* %$$ -$head rev_sparse_jac$$ -$srccode%cpp% */ - virtual bool rev_sparse_jac( - size_t p , - const set_vector& rt , - set_vector& st , - const vector& x ) - { // This function needed if using RevSparseJac or optimize -# ifndef NDEBUG - size_t n = st.size(); - size_t m = rt.size(); -# endif - assert( n == x.size() ); - assert( n == 3 ); - assert( m == 2 ); - - // [ 0, x1 ] - // sparsity for S(x)^T = f'(x)^T * R^T = [ 0, x0 ] * R^T - // [ 1, 0 ] - st[0] = rt[1]; - st[1] = rt[1]; - st[2] = rt[0]; - return true; - } -/* %$$ -$head for_sparse_hes$$ -$srccode%cpp% */ - virtual bool for_sparse_hes( - const vector& vx, - const vector& r , - const vector& s , - set_vector& h , - const vector& x ) - { - size_t n = r.size(); -# ifndef NDEBUG - size_t m = s.size(); -# endif - assert( x.size() == n ); - assert( h.size() == n ); - assert( n == 3 ); - assert( m == 2 ); - - // initialize h as empty - for(size_t i = 0; i < n; i++) - h[i].clear(); - - // only f_1 has a non-zero hessian - if( ! s[1] ) - return true; - - // only the cross term between x[0] and x[1] is non-zero - if( ! ( r[0] & r[1] ) ) - return true; - - // set the possibly non-zero terms in the hessian - h[0].insert(1); - h[1].insert(0); - - return true; - } -/* %$$ -$head rev_sparse_hes$$ -$srccode%cpp% */ - virtual bool rev_sparse_hes( - const vector& vx, - const vector& s , - vector& t , - size_t p , - const set_vector& r , - const set_vector& u , - set_vector& v , - const vector& x ) - { // This function needed if using RevSparseHes -# ifndef NDEBUG - size_t m = s.size(); - size_t n = t.size(); -# endif - assert( x.size() == n ); - assert( r.size() == n ); - assert( u.size() == m ); - assert( v.size() == n ); - 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 W(x) = f'(x)^T * U(x) = [ 0, x0 ] * U(x) - // [ 1, 0 ] - v[0] = u[1]; - v[1] = u[1]; - v[2] = u[0]; - // - // [ 0, 1, 0 ] - // sparsity for V(x) = W(x) + S_1 (x) * [ 1, 0, 0 ] * R - // [ 0, 0, 0 ] - if( s[1] ) - { // v[0] = union( v[0], r[1] ) - v[0] = set_union(v[0], r[1]); - // v[1] = union( v[1], r[0] ) - v[1] = set_union(v[1], r[0]); - } - return true; - } -/* %$$ -$head End Class Definition$$ -$srccode%cpp% */ -}; // End of atomic_set_sparsity class -} // End empty namespace - -/* %$$ -$head Test Atomic Function$$ -$srccode%cpp% */ -bool set_sparsity(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * std::numeric_limits::epsilon(); -/* %$$ -$subhead Constructor$$ -$srccode%cpp% */ - // Create the atomic get_started object - atomic_set_sparsity afun("atomic_set_sparsity"); -/* %$$ -$subhead Recording$$ -$srccode%cpp% */ - 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 for_sparse_jac$$ -$srccode%cpp% */ - // correct Jacobian result - set_vector check_s(m); - check_s[0].insert(2); - check_s[1].insert(0); - check_s[1].insert(1); - // compute and test forward mode - { set_vector r(n), s(m); - for(size_t i = 0; i < n; i++) - r[i].insert(i); - s = f.ForSparseJac(n, r); - for(size_t i = 0; i < m; i++) - ok &= s[i] == check_s[i]; - } -/* %$$ -$subhead rev_sparse_jac$$ -$srccode%cpp% */ - // compute and test reverse mode - { set_vector r(m), s(m); - for(size_t i = 0; i < m; i++) - r[i].insert(i); - s = f.RevSparseJac(m, r); - for(size_t i = 0; i < m; i++) - ok &= s[i] == check_s[i]; - } -/* %$$ -$subhead for_sparse_hes$$ -$srccode%cpp% */ - // correct Hessian result - set_vector check_h(n); - check_h[0].insert(1); - check_h[1].insert(0); - // compute and test forward mode - { set_vector r(1), s(1), h(n); - for(size_t i = 0; i < m; i++) - s[0].insert(i); - for(size_t j = 0; j < n; j++) - r[0].insert(j); - h = f.ForSparseHes(r, s); - for(size_t i = 0; i < n; i++) - ok &= h[i] == check_h[i]; - } -/* %$$ -$subhead rev_sparse_hes$$ -Note the previous call to $code ForSparseJac$$ above -stored its results in $icode f$$. -$srccode%cpp% */ - // compute and test reverse mode - { set_vector s(1), h(n); - for(size_t i = 0; i < m; i++) - s[0].insert(i); - h = f.RevSparseHes(n, s); - for(size_t i = 0; i < n; i++) - ok &= h[i] == check_h[i]; - } -/* %$$ -$subhead Test Result$$ -$srccode%cpp% */ - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic/tangent.cpp cppad-2019.02.00.0/example/atomic/tangent.cpp --- cppad-2018.00.00.0/example/atomic/tangent.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic/tangent.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,532 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_tangent.cpp$$ -$spell - Tanh - bool -$$ - -$section Tan and Tanh as User Atomic Operations: Example and Test$$ -$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$$ -$srccode%cpp% */ -# include -namespace { // Begin empty namespace -using CppAD::vector; -// -// a utility to compute the union of two sets. -using CppAD::set_union; -// -class atomic_tangent : public CppAD::atomic_base { -/* %$$ -$head Constructor $$ -$srccode%cpp% */ -private: - const bool hyperbolic_; // is this hyperbolic tangent -public: - // constructor - atomic_tangent(const char* name, bool hyperbolic) - : CppAD::atomic_base(name), - hyperbolic_(hyperbolic) - { } -private: -/* %$$ -$head forward$$ -$srccode%cpp% */ - // forward mode routine called by CppAD - bool forward( - size_t p , - size_t q , - const vector& vx , - vector& vzy , - const vector& tx , - vector& tzy - ) - { size_t q1 = q + 1; -# ifndef NDEBUG - size_t n = tx.size() / q1; - size_t m = tzy.size() / q1; -# endif - assert( n == 1 ); - assert( m == 2 ); - assert( p <= q ); - size_t j, k; - - // check if this is during the call to old_tan(id, ax, ay) - if( vx.size() > 0 ) - { // set variable flag for both y an z - vzy[0] = vx[0]; - vzy[1] = vx[0]; - } - - if( p == 0 ) - { // z^{(0)} = tan( x^{(0)} ) or tanh( x^{(0)} ) - if( hyperbolic_ ) - tzy[0] = float( tanh( tx[0] ) ); - else tzy[0] = float( tan( tx[0] ) ); - - // y^{(0)} = z^{(0)} * z^{(0)} - tzy[q1 + 0] = tzy[0] * tzy[0]; - - p++; - } - for(j = p; j <= q; j++) - { float j_inv = 1.f / float(j); - if( hyperbolic_ ) - 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[q1 + j-k] * float(k) * j_inv; - - // y^{(j)} = sum_{k=0}^j z^{(k)} z^{(j-k)} - tzy[q1 + j] = 0.; - for(k = 0; k <= j; k++) - tzy[q1 + j] += tzy[k] * tzy[j-k]; - } - - // All orders are implemented and there are no possible errors - return true; - } -/* %$$ -$head reverse$$ -$srccode%cpp% */ - // reverse mode routine called by CppAD - virtual bool reverse( - size_t q , - const vector& tx , - const vector& tzy , - vector& px , - const vector& pzy - ) - { size_t q1 = q + 1; -# ifndef NDEBUG - size_t n = tx.size() / q1; - size_t m = tzy.size() / q1; -# endif - assert( px.size() == n * q1 ); - assert( pzy.size() == m * q1 ); - assert( n == 1 ); - assert( m == 2 ); - - 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 < q1; k++) - px[k] = 0.; - - // eliminate positive orders - for(j = q; j > 0; j--) - { float j_inv = 1.f / float(j); - if( hyperbolic_ ) - 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[q1 + j-k] * float(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] * float(k) * j_inv; - - // 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; - } - - // eliminate order zero - if( hyperbolic_ ) - px[0] += qzy[0] * (1.f - tzy[q1 + 0]); - else - px[0] += qzy[0] * (1.f + tzy[q1 + 0]); - - return true; - } -/* %$$ -$head for_sparse_jac$$ -$srccode%cpp% */ - // forward Jacobian sparsity routine called by CppAD - virtual bool for_sparse_jac( - size_t p , - const vector& r , - vector& s , - const vector& x ) - { -# ifndef NDEBUG - size_t n = r.size() / p; - size_t m = s.size() / p; -# endif - assert( n == x.size() ); - assert( n == 1 ); - assert( m == 2 ); - - // sparsity for S(x) = f'(x) * R - for(size_t j = 0; j < p; j++) - { s[0 * p + j] = r[j]; - s[1 * p + j] = r[j]; - } - - return true; - } - // forward Jacobian sparsity routine called by CppAD - virtual bool for_sparse_jac( - size_t p , - const vector< std::set >& r , - vector< std::set >& s , - const vector& x ) - { -# ifndef NDEBUG - size_t n = r.size(); - size_t m = s.size(); -# endif - assert( n == x.size() ); - assert( n == 1 ); - assert( m == 2 ); - - // sparsity for S(x) = f'(x) * R - s[0] = r[0]; - s[1] = r[0]; - - return true; - } -/* %$$ -$head rev_sparse_jac$$ -$srccode%cpp% */ - // reverse Jacobian sparsity routine called by CppAD - virtual bool rev_sparse_jac( - size_t p , - const vector& rt , - vector& st , - const vector& x ) - { -# ifndef NDEBUG - size_t n = st.size() / p; - size_t m = rt.size() / p; -# endif - assert( n == 1 ); - assert( m == 2 ); - assert( n == x.size() ); - - // sparsity for S(x)^T = f'(x)^T * R^T - for(size_t j = 0; j < p; j++) - st[j] = rt[0 * p + j] | rt[1 * p + j]; - - return true; - } - // reverse Jacobian sparsity routine called by CppAD - virtual bool rev_sparse_jac( - size_t p , - const vector< std::set >& rt , - vector< std::set >& st , - const vector& x ) - { -# ifndef NDEBUG - size_t n = st.size(); - size_t m = rt.size(); -# endif - assert( n == 1 ); - assert( m == 2 ); - assert( n == x.size() ); - - // sparsity for S(x)^T = f'(x)^T * R^T - st[0] = set_union(rt[0], rt[1]); - return true; - } -/* %$$ -$head rev_sparse_hes$$ -$srccode%cpp% */ - // reverse Hessian 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 , - const vector& x ) - { -# ifndef NDEBUG - size_t m = s.size(); - size_t n = t.size(); -# endif - assert( x.size() == n ); - assert( r.size() == n * p ); - assert( u.size() == m * p ); - assert( v.size() == n * p ); - assert( n == 1 ); - assert( m == 2 ); - - // 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) - t[0] = s[0] | s[1]; - - // 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; - size_t j; - for(j = 0; j < p; j++) - v[j] = u[ 0 * p + j ] | u[ 1 * p + j ]; - - // include forward Jacobian sparsity in Hessian sparsity - // (note sparsty for f''(x) * R same as for R) - if( s[0] | s[1] ) - { for(j = 0; j < p; j++) - { // Visual Studio 2013 generates warning without bool below - v[j] |= bool( r[j] ); - } - } - - return true; - } - // reverse Hessian 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 , - const vector& x ) - { -# ifndef NDEBUG - size_t m = s.size(); - size_t n = t.size(); -# endif - assert( x.size() == n ); - assert( r.size() == n ); - assert( u.size() == m ); - assert( v.size() == n ); - assert( n == 1 ); - assert( m == 2 ); - - // 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) - t[0] = s[0] | s[1]; - - // 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] = set_union(u[0], u[1]); - - // include forward Jacobian sparsity in Hessian sparsity - // (note sparsty for f''(x) * R same as for R) - if( s[0] | s[1] ) - v[0] = set_union(v[0], r[0]); - - return true; - } -/* %$$ -$head End Class Definition$$ -$srccode%cpp% */ -}; // End of atomic_tangent class -} // End empty namespace - -/* %$$ -$head Use Atomic Function$$ -$srccode%cpp% */ -bool tangent(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - float eps = 10.f * CppAD::numeric_limits::epsilon(); -/* %$$ -$subhead Constructor$$ -$srccode%cpp% */ - // -------------------------------------------------------------------- - // Creater a tan and tanh object - atomic_tangent my_tan("my_tan", false), my_tanh("my_tanh", true); -/* %$$ -$subhead Recording$$ -$srccode%cpp% */ - // 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 computations - // (my_tan and my_tanh computes tan or tanh and its square) - CppAD::vector< AD > az(2); - - // call atomic tan function and store tan(x) in f[0] (ignore tan(x)^2) - my_tan(ax, az); - af[0] = az[0]; - - // call atomic tanh function and store tanh(x) in f[1] (ignore tanh(x)^2) - my_tanh(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.; - my_tanh(one, az); - af[2] = az[0]; - - // create f: x -> f and stop tape recording - CppAD::ADFun F; - F.Dependent(ax, af); -/* %$$ -$subhead forward$$ -$srccode%cpp% */ - // 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); -/* %$$ -$subhead reverse$$ -$srccode%cpp% */ - // 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); -/* %$$ -$subhead for_sparse_jac$$ -$srccode%cpp% */ - // 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] -/* %$$ -$subhead rev_sparse_jac$$ -$srccode%cpp% */ - // 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] -/* %$$ -$subhead rev_sparse_hes$$ -$srccode%cpp% */ - // 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 -/* %$$ -$subhead Large x Values$$ -$srccode%cpp% */ - // 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); - - return ok; -} -/* %$$ -$$ $comment end nospell$$ -$end -*/ diff -Nru cppad-2018.00.00.0/example/atomic_three/atomic_three.cpp cppad-2019.02.00.0/example/atomic_three/atomic_three.cpp --- cppad-2018.00.00.0/example/atomic_three/atomic_three.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/atomic_three.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,70 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// CPPAD_HAS_* defines +# include + +// system include files used for I/O +# include + +// C style asserts +# include + +// for thread_alloc +# include + +// test runner +# include + +// external compiled tests +extern bool mat_mul(void); +extern bool norm_sq(void); +extern bool tangent(void); +extern bool base2ad(void); +extern bool reciprocal(void); +extern bool dynamic(void); +extern bool forward(void); +extern bool get_started(void); +extern bool hes_sparsity(void); +extern bool jac_sparsity(void); +extern bool reverse(void); +extern bool rev_depend(void); + +// main program that runs all the tests +int main(void) +{ std::string group = "example/atomic"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + // external compiled tests + Run( mat_mul, "mat_mul" ); + Run( norm_sq, "norm_sq" ); + Run( tangent, "tangent" ); + Run( base2ad, "base2ad" ); + Run( reciprocal, "reciprocal" ); + Run( dynamic, "dynamic" ); + Run( forward, "forward" ); + Run( get_started, "get_started" ); + Run( hes_sparsity, "hes_sparsity" ); + Run( jac_sparsity, "jac_sparsity" ); + Run( reverse, "reverse" ); + Run( rev_depend, "rev_depend" ); + + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); +} diff -Nru cppad-2018.00.00.0/example/atomic_three/base2ad.cpp cppad-2019.02.00.0/example/atomic_three/base2ad.cpp --- cppad-2018.00.00.0/example/atomic_three/base2ad.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/base2ad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,231 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_three_base2ad.cpp$$ + +$section base2ad with Atomic Operations: Example and Test$$ + +$head Source Code$$ +$srcfile%example/atomic_three/base2ad.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ +# include +namespace { // isolate items below to this file +// +// abbreviations +using CppAD::AD; +using CppAD::vector; +// +class atomic_base2ad : public CppAD::atomic_three { +// +public: + atomic_base2ad(const std::string& name) : + CppAD::atomic_three(name) + { } +private: + // ------------------------------------------------------------------------ + // type + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = type_x.size() == 1; // n + ok &= type_y.size() == 1; // m + if( ! ok ) + return false; + type_y[0] = type_x[0]; + return true; + } + // ---------------------------------------------------------------------- + // forward mode + // ---------------------------------------------------------------------- + template + bool template_forward( + size_t p , + size_t q , + const vector& tx , + vector& ty ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( n == 1 ); + assert( m == 1 ); + + // return flag + bool ok = q == 0; + if( ! ok ) + return ok; + + // Order zero forward mode. + // This case must always be implemented + // y^0 = g( x^0 ) = 1 / x^0 + Scalar g = 1. / tx[0]; + if( p <= 0 ) + ty[0] = g; + return ok; + } + // forward mode routines called by ADFun objects + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t p , + size_t q , + const vector& tx , + vector& ty ) + { return template_forward(p, q, tx, ty); + } + // forward mode routines called by ADFun< AD , Base> objects + virtual bool forward( + const vector< AD >& aparameter_x , + const vector& type_x , + size_t need_y , + size_t p , + size_t q , + const vector< AD >& atx , + vector< AD >& aty ) + { return template_forward(p, q, atx, aty); + } + // ---------------------------------------------------------------------- + // reverse mode + // ---------------------------------------------------------------------- + template + bool template_reverse( + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( n == 1 ); + assert( m == 1 ); + + // return flag + bool ok = q == 0; + if( ! ok ) + return ok; + + // Order zero reverse mode. + // y^0 = g( x^0 ) = 1 / x^0 + // y^1 = g'( x^0 ) * x^1 = - x^1 / (x^0 * x^0) + px[0] = - py[0] / ( tx[0] * tx[0] ); + return ok; + } + // reverse mode routines called by ADFun objects + virtual bool reverse( + const vector& parameter_x , + const vector& type_x , + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py ) + { return template_reverse(q, tx, ty, px, py); + } + // reverse mode routines called by ADFun objects + virtual bool reverse( + const vector< AD >& aparameter_x , + const vector& type_x , + size_t q , + const vector< AD >& atx , + const vector< AD >& aty , + vector< AD >& apx , + const vector< AD >& apy ) + { return template_reverse(q, atx, aty, apx, apy); + } +}; // End of atomic_base2ad class +} // End empty namespace + +bool base2ad(void) +{ bool ok = true; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // Create the atomic base2ad object + atomic_base2ad afun("atomic_base2ad"); + // + // Create the function f(x) = 1 / g(x) = x + // + 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 > av(m); + + // call atomic function and store g(x) in au[0] + vector< AD > au(m); + afun(ax, au); // u = 1 / x + + // now use AD division to invert to invert the operation + av[0] = 1.0 / au[0]; // v = 1 / u = x + + // create f: x -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (ax, av); // g(x) = x + + // check function value + double check = x0; + ok &= NearEqual( Value(av[0]) , check, eps, eps); + + // check zero order forward mode + size_t q; + vector x_q(n), v_q(m); + q = 0; + x_q[0] = x0; + v_q = f.Forward(q, x_q); + ok &= NearEqual(v_q[0] , check, eps, eps); + + // check first order reverse + vector dw(n), w(m); + w[0] = 1.0; + dw = f.Reverse(q+1, w); + check = 1.0; + ok &= NearEqual(dw[0] , check, eps, eps); + + // create ag : x -> y + CppAD::ADFun< AD , double > af; + af = f.base2ad(); + + // check zero order forward mode + vector< AD > ax_q(n), av_q(m); + q = 0; + ax_q[0] = x0; + av_q = af.Forward(q, ax_q); + check = x0; + ok &= NearEqual( Value(av_q[0]) , check, eps, eps); + + // check first order reverse + vector< AD > adw(n), aw(m); + aw[0] = 1.0; + adw = af.Reverse(q+1, aw); + check = 1.0; + ok &= NearEqual( Value(adw[0]) , check, eps, eps); + + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/example/atomic_three/CMakeLists.txt cppad-2019.02.00.0/example/atomic_three/CMakeLists.txt --- cppad-2018.00.00.0/example/atomic_three/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,41 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# +SET(source_list + norm_sq.cpp + tangent.cpp + base2ad.cpp + reciprocal.cpp + atomic_three.cpp + mat_mul.cpp + dynamic.cpp + forward.cpp + get_started.cpp + hes_sparsity.cpp + jac_sparsity.cpp + reverse.cpp + rev_depend.cpp +) +set_compile_flags(example_atomic_three "${cppad_debug_which}" "${source_list}" ) +# +ADD_EXECUTABLE(example_atomic_three EXCLUDE_FROM_ALL ${source_list}) +# +# Add the check_example_atomic_three target +ADD_CUSTOM_TARGET(check_example_atomic_three + example_atomic_three + DEPENDS example_atomic_three +) +MESSAGE(STATUS "make check_example_atomic_three: available") +# +# add to check check_example_depends in parent environment +add_to_list(check_example_depends check_example_atomic_three) +SET(check_example_depends "${check_example_depends}" PARENT_SCOPE) diff -Nru cppad-2018.00.00.0/example/atomic_three/dynamic.cpp cppad-2019.02.00.0/example/atomic_three/dynamic.cpp --- cppad-2018.00.00.0/example/atomic_three/dynamic.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/dynamic.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,227 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_three_dynamic.cpp$$ + +$section Atomic Functions with Dynamic Parameters: Example and Test$$ + +$head Purpose$$ +This example demonstrates using dynamic parameters with an +$cref atomic_three$$ function. + +$head Function$$ +For this example, the atomic function +$latex g : \B{R}^3 \rightarrow \B{R}^3$$ is defined by +$latex g_0 (x) = x_0 * x_ 0$$, +$latex g_1 (x) = x_0 * x_ 1$$, +$latex g_2 (x) = x_1 * x_ 2$$. + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include // CppAD include file +namespace { // start empty namespace +using CppAD::vector; // abbreviate CppAD::vector using vector +// start definition of atomic derived class using atomic_three interface +class atomic_dynamic : public CppAD::atomic_three { +/* %$$ +$head Constructor$$ +$srccode%cpp% */ +public: + // can use const char* name when calling this constructor + atomic_dynamic(const std::string& name) : // can have more arguments + CppAD::atomic_three(name) // inform base class of name + { } + +private: +/* %$$ +$head for_type$$ +$srccode%cpp% */ + // calculate type_y + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = type_x.size() == 3; // n + ok &= type_y.size() == 3; // m + if( ! ok ) + return false; + type_y[0] = type_x[0]; + type_y[1] = std::max( type_x[0], type_x[1] ); + type_y[2] = std::max( type_x[1], type_x[2] ); + return true; + } +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector& taylor_x , + vector& taylor_y ) + { +# ifndef NDEBUG + size_t n = taylor_x.size() / (order_up + 1); + size_t m = taylor_y.size() / (order_up + 1); +# endif + assert( n == 3 ); + assert( m == 3 ); + assert( order_low <= order_up ); + + // return flag + bool ok = order_up == 0; + if( ! ok ) + return ok; + + // Order zero forward mode. + // This case must always be implemented + if( need_y > size_t(CppAD::variable_enum) ) + { // g_0 = x_0 * x_0 + taylor_y[0] = taylor_x[0] * taylor_x[0]; + // g_1 = x_0 * x_1 + taylor_y[1] = taylor_x[0] * taylor_x[1]; + // g_2 = x_1 * x_2 + taylor_y[2] = taylor_x[1] * taylor_x[2]; + } + else + { // This uses need_y to reduce amount of computation. + // It is probably faster, for this case, to ignore need_y. + vector type_y( taylor_y.size() ); + for_type(taylor_x, type_x, type_y); + // g_0 = x_0 * x_0 + if( size_t(type_y[0]) == need_y ) + taylor_y[0] = taylor_x[0] * taylor_x[0]; + // g_1 = x_0 * x_1 + if( size_t(type_y[1]) == need_y ) + taylor_y[1] = taylor_x[0] * taylor_x[1]; + // g_2 = x_1 * x_2 + if( size_t(type_y[2]) == need_y ) + taylor_y[2] = taylor_x[1] * taylor_x[2]; + } + + return ok; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_dynamic class +} // End empty namespace + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool dynamic(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // Create the atomic dynamic object corresponding to g(x) + atomic_dynamic afun("atomic_dynamic"); +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + // Create the function f(u) = g(c, p, u) for this example. + // + // constant parameter + double c_0 = 2.0; + // + // indepndent dynamic parameter vector + size_t np = 1; + CPPAD_TESTVECTOR(double) p(np); + CPPAD_TESTVECTOR( AD ) ap(np); + ap[0] = p[0] = 3.0; + // + // independent variable vector + size_t nu = 1; + double u_0 = 0.5; + CPPAD_TESTVECTOR( AD ) au(nu); + au[0] = u_0; + + // declare independent variables and start tape recording + size_t abort_op_index = 0; + bool record_compare = true; + CppAD::Independent(au, abort_op_index, record_compare, ap); + + // range space vector + size_t ny = 3; + CPPAD_TESTVECTOR( AD ) ay(ny); + + // call atomic function and store result in ay + // y = ( c * c, c * p, p * x ) + CPPAD_TESTVECTOR( AD ) ax(3); + ax[0] = c_0; // x_0 + ax[1] = ap[0]; // x_1 + ax[2] = au[0]; // x_2 + afun(ax, ay); + + // check type of result + ok &= Constant( ay[0] ); + ok &= Dynamic( ay[1] ); + ok &= Variable( ay[2] ); + + // create f: x -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // f(u) = (c * c, c * p, p * u) +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // check function value + double check = c_0 * c_0; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + check = c_0 * p[0]; + ok &= NearEqual( Value(ay[1]) , check, eps, eps); + check = p[0] * u_0; + ok &= NearEqual( Value(ay[2]) , check, eps, eps); + + // check zero order forward mode + size_t q; + CPPAD_TESTVECTOR( double ) u_q(nu), y_q(ny); + q = 0; + u_q[0] = u_0; + y_q = f.Forward(q, u_q); + check = c_0 * c_0; + ok &= NearEqual(y_q[0] , check, eps, eps); + check = c_0 * p[0]; + ok &= NearEqual(y_q[1] , check, eps, eps); + check = p[0] * u_0; + ok &= NearEqual(y_q[2] , check, eps, eps); + + // set new value for dynamic parameters + p[0] = 2.0 * p[0]; + f.new_dynamic(p); + y_q = f.Forward(q, u_q); + check = c_0 * c_0; + ok &= NearEqual(y_q[0] , check, eps, eps); + check = c_0 * p[0]; + ok &= NearEqual(y_q[1] , check, eps, eps); + check = p[0] * u_0; + ok &= NearEqual(y_q[2] , check, eps, eps); + +/* %$$ +$subhead Return Test Result$$ +$srccode%cpp% */ + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_three/forward.cpp cppad-2019.02.00.0/example/atomic_three/forward.cpp --- cppad-2018.00.00.0/example/atomic_three/forward.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/forward.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,311 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availabilitaylor_y set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three_forward.cpp$$ +$spell + Jacobian +$$ + +$section Atomic Functions and Forward Mode: Example and Test$$ + +$head Purpose$$ +This example demonstrates forward mode derivative calculation +using an $cref atomic_three$$ function. + +$head Function$$ +For this example, the atomic function +$latex g : \B{R}^3 \rightarrow \B{R}^2$$ is defined by +$latex \[ +g(x) = \left( \begin{array}{c} + x_2 * x_2 \\ + x_0 * x_1 +\end{array} \right) +\] $$ + +$head Jacobian$$ +The corresponding Jacobian is +$latex \[ +g^{(1)} (x) = \left( \begin{array}{ccc} + 0 & 0 & 2 x_2 \\ +x_1 & x_0 & 0 +\end{array} \right) +\] $$ + +$head Hessian$$ +The Hessians of the component functions are +$latex \[ +g_0^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 0 & 0 \\ + 0 & 0 & 0 \\ + 0 & 0 & 2 +\end{array} \right) +\W{,} +g_1^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 1 & 0 \\ + 1 & 0 & 0 \\ + 0 & 0 & 0 +\end{array} \right) +\] $$ + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // begin empty namespace +using CppAD::vector; // abbreviate CppAD::vector using vector +// +class atomic_forward : public CppAD::atomic_three { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + atomic_forward(const std::string& name) : + CppAD::atomic_three(name) + { } +private: +/* %$$ +$head for_type$$ +$srccode%cpp% */ + // calculate type_y + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = type_x.size() == 3; // n + ok &= type_y.size() == 2; // m + if( ! ok ) + return false; + type_y[0] = type_x[2]; + type_y[1] = std::max(type_x[0], type_x[1]); + return true; + } +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector& taylor_x , + vector& taylor_y ) + { + size_t q1 = order_up + 1; +# ifndef NDEBUG + size_t n = taylor_x.size() / q1; + size_t m = taylor_y.size() / q1; +# endif + assert( n == 3 ); + assert( m == 2 ); + assert( order_low <= order_up ); + + // this example only implements up to second order forward mode + bool ok = order_up <= 2; + if( ! ok ) + return ok; + + // ------------------------------------------------------------------ + // Zero forward mode. + // This case must always be implemented + // g(x) = [ x_2 * x_2 ] + // [ x_0 * x_1 ] + // y^0 = f( x^0 ) + if( order_low <= 0 ) + { // y_0^0 = x_2^0 * x_2^0 + taylor_y[0*q1+0] = taylor_x[2*q1+0] * taylor_x[2*q1+0]; + // y_1^0 = x_0^0 * x_1^0 + taylor_y[1*q1+0] = taylor_x[0*q1+0] * taylor_x[1*q1+0]; + } + if( order_up <= 0 ) + return ok; + // ------------------------------------------------------------------ + // First order forward mode. + // This case is needed if first order forward mode is used. + // g'(x) = [ 0, 0, 2 * x_2 ] + // [ x_1, x_0, 0 ] + // y^1 = f'(x^0) * x^1 + if( order_low <= 1 ) + { // y_0^1 = 2 * x_2^0 * x_2^1 + taylor_y[0*q1+1] = 2.0 * taylor_x[2*q1+0] * taylor_x[2*q1+1]; + // y_1^1 = x_1^0 * x_0^1 + x_0^0 * x_1^1 + taylor_y[1*q1+1] = taylor_x[1*q1+0] * taylor_x[0*q1+1]; + taylor_y[1*q1+1] += taylor_x[0*q1+0] * taylor_x[1*q1+1]; + } + if( order_up <= 1 ) + return ok; + // ------------------------------------------------------------------ + // Second order forward mode. + // This case is neede if second order forwrd mode is used. + // g'(x) = [ 0, 0, 2 x_2 ] + // [ x_1, x_0, 0 ] + // + // [ 0 , 0 , 0 ] [ 0 , 1 , 0 ] + // g_0''(x) = [ 0 , 0 , 0 ] g_1^{(2)} (x) = [ 1 , 0 , 0 ] + // [ 0 , 0 , 2 ] [ 0 , 0 , 0 ] + // + // y_0^2 = x^1 * g_0''( x^0 ) x^1 / 2! + g_0'( x^0 ) x^2 + // = ( x_2^1 * 2.0 * x_2^1 ) / 2! + // + 2.0 * x_2^0 * x_2^2 + taylor_y[0*q1+2] = taylor_x[2*q1+1] * taylor_x[2*q1+1]; + taylor_y[0*q1+2] += 2.0 * taylor_x[2*q1+0] * taylor_x[2*q1+2]; + // + // y_1^2 = x^1 * g_1''( x^0 ) x^1 / 2! + g_1'( x^0 ) x^2 + // = ( x_1^1 * x_0^1 + x_0^1 * x_1^1) / 2 + // + x_1^0 * x_0^2 + x_0^0 + x_1^2 + taylor_y[1*q1+2] = taylor_x[1*q1+1] * taylor_x[0*q1+1]; + taylor_y[1*q1+2] += taylor_x[1*q1+0] * taylor_x[0*q1+2]; + taylor_y[1*q1+2] += taylor_x[0*q1+0] * taylor_x[1*q1+2]; + // ------------------------------------------------------------------ + return ok; + } +}; +} // End empty namespace +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool forward(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // Create the atomic_forward object corresponding to g(x) + atomic_forward afun("atomic_forward"); + // + // Create the function f(u) = g(u) for this example. + // + // domain space vector + size_t n = 3; + double u_0 = 1.00; + double u_1 = 2.00; + double u_2 = 3.00; + vector< AD > au(n); + au[0] = u_0; + au[1] = u_1; + au[2] = u_2; + + // declare independent variables and start tape recording + CppAD::Independent(au); + + // range space vector + size_t m = 2; + vector< AD > ay(m); + + // call atomic function + vector< AD > ax = au; + afun(ax, ay); + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // y = f(u) + // + // check function value + double check = u_2 * u_2; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + check = u_0 * u_1; + ok &= NearEqual( Value(ay[1]) , check, eps, eps); + + // -------------------------------------------------------------------- + // zero order forward + // + vector u0(n), y0(m); + u0[0] = u_0; + u0[1] = u_1; + u0[2] = u_2; + y0 = f.Forward(0, u0); + check = u_2 * u_2; + ok &= NearEqual(y0[0] , check, eps, eps); + check = u_0 * u_1; + ok &= NearEqual(y0[1] , check, eps, eps); + // -------------------------------------------------------------------- + // first order forward + // + // value of Jacobian of f + double check_jac[] = { + 0.0, 0.0, 2.0 * u_2, + u_1, u_0, 0.0 + }; + vector u1(n), y1(m); + // check first order forward mode + for(size_t j = 0; j < n; j++) + u1[j] = 0.0; + for(size_t j = 0; j < n; j++) + { // compute partial in j-th component direction + u1[j] = 1.0; + y1 = f.Forward(1, u1); + u1[j] = 0.0; + // check this direction + for(size_t i = 0; i < m; i++) + ok &= NearEqual(y1[i], check_jac[i * n + j], eps, eps); + } + // -------------------------------------------------------------------- + // second order forward + // + // value of Hessian of g_0 + double check_hes_0[] = { + 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + 0.0, 0.0, 2.0 + }; + // + // value of Hessian of g_1 + double check_hes_1[] = { + 0.0, 1.0, 0.0, + 1.0, 0.0, 0.0, + 0.0, 0.0, 0.0 + }; + vector u2(n), y2(m); + for(size_t j = 0; j < n; j++) + u2[j] = 0.0; + // compute diagonal elements of the Hessian + for(size_t j = 0; j < n; j++) + { // first order forward in j-th direction + u1[j] = 1.0; + f.Forward(1, u1); + y2 = f.Forward(2, u2); + // check this element of Hessian diagonal + ok &= NearEqual(y2[0], check_hes_0[j * n + j] / 2.0, eps, eps); + ok &= NearEqual(y2[1], check_hes_1[j * n + j] / 2.0, eps, eps); + // + for(size_t k = 0; k < n; k++) if( k != j ) + { u1[k] = 1.0; + f.Forward(1, u1); + y2 = f.Forward(2, u2); + // + // y2 = (H_jj + H_kk + H_jk + H_kj) / 2.0 + // y2 = (H_jj + H_kk) / 2.0 + H_jk + // + double H_jj = check_hes_0[j * n + j]; + double H_kk = check_hes_0[k * n + k]; + double H_jk = y2[0] - (H_kk + H_jj) / 2.0; + ok &= NearEqual(H_jk, check_hes_0[j * n + k], eps, eps); + // + H_jj = check_hes_1[j * n + j]; + H_kk = check_hes_1[k * n + k]; + H_jk = y2[1] - (H_kk + H_jj) / 2.0; + ok &= NearEqual(H_jk, check_hes_1[j * n + k], eps, eps); + // + u1[k] = 0.0; + } + u1[j] = 0.0; + } + // -------------------------------------------------------------------- + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_three/get_started.cpp cppad-2019.02.00.0/example/atomic_three/get_started.cpp --- cppad-2018.00.00.0/example/atomic_three/get_started.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/get_started.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,161 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_three_get_started.cpp$$ + +$section Getting Started with Atomic Functions: Example and Test$$ + +$head Purpose$$ +This example demonstrates the minimal amount of information +necessary for a $cref atomic_three$$ function. + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include // CppAD include file +namespace { // start empty namespace +using CppAD::vector; // abbreviate CppAD::vector using vector +// start definition of atomic derived class using atomic_three interface +class atomic_get_started : public CppAD::atomic_three { +/* %$$ +$head Constructor$$ +$srccode%cpp% */ +public: + // can use const char* name when calling this constructor + atomic_get_started(const std::string& name) : // can have more arguments + CppAD::atomic_three(name) // inform base class of name + { } + +private: +/* %$$ +$head for_type$$ +$srccode%cpp% */ + // calculate type_y + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = type_x.size() == 1; // n + ok &= type_y.size() == 1; // m + if( ! ok ) + return false; + type_y[0] = type_x[0]; + return true; + } +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector& taylor_x , + vector& taylor_y ) + { +# ifndef NDEBUG + size_t n = taylor_x.size() / (order_up + 1); + size_t m = taylor_y.size() / (order_up + 1); +# endif + assert( n == 1 ); + assert( m == 1 ); + assert( order_low <= order_up ); + + // return flag + bool ok = order_up == 0; + if( ! ok ) + return ok; + + // Order zero forward mode. + // This case must always be implemented + // y^0 = g( x^0 ) = 1 / x^0 + taylor_y[0] = 1. / taylor_x[0]; + // + return ok; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_get_started class +} // End empty namespace + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool get_started(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // Create the atomic get_started object corresponding to g(x) + atomic_get_started afun("atomic_get_started"); +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + // Create the function f(x) which is eqaul to g(x) for this example. + // + // 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); + + // call atomic function and store result in au[0] + // u = 1 / x + CPPAD_TESTVECTOR( AD ) au(m); + afun(ax, au); + + // now use AD division to invert to invert the operation + ay[0] = 1.0 / au[0]; // y = 1 / u = x + + // create f: x -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (ax, ay); // f(x) = x +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // check function value + double check = x0; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + + // check zero order forward mode + size_t q; + CPPAD_TESTVECTOR( double ) 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); + +/* %$$ +$subhead Return Test Result$$ +$srccode%cpp% */ + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_three/hes_sparsity.cpp cppad-2019.02.00.0/example/atomic_three/hes_sparsity.cpp --- cppad-2018.00.00.0/example/atomic_three/hes_sparsity.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/hes_sparsity.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,400 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three_hes_sparsity.cpp$$ +$spell + Jacobian +$$ + +$section Atomic Forward Hessian Sparsity: Example and Test$$ + +$head Purpose$$ +This example demonstrates calculation of the Hessian sparsity pattern +for an atomic operation. + +$head Function$$ +For this example, the atomic function +$latex g : \B{R}^3 \rightarrow \B{R}^2$$ is defined by +$latex \[ +g( x ) = \left( \begin{array}{c} + x_2 * x_2 \\ + x_0 * x_1 +\end{array} \right) +\] $$ + +$head Jacobian$$ +The corresponding Jacobian is +$latex \[ +g^{(1)} (x) = \left( \begin{array}{ccc} + 0 & 0 & 2 x_2 \\ +x_1 & x_0 & 0 +\end{array} \right) +\] $$ + +$head Hessians$$ +The Hessians of the component functions are +$latex \[ +g_0^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 0 & 0 \\ + 0 & 0 & 0 \\ + 0 & 0 & 2 +\end{array} \right) +\W{,} +g_1^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 1 & 0 \\ + 1 & 0 & 0 \\ + 0 & 0 & 0 +\end{array} \right) +\] $$ + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // begin empty namespace +using CppAD::vector; // abbreviate CppAD::vector as vector +// +class atomic_hes_sparsity : public CppAD::atomic_three { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + atomic_hes_sparsity(const std::string& name) : + CppAD::atomic_three(name) + { } +private: +/* %$$ +$head for_type$$ +$srccode%cpp% */ + // calculate type_y + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = type_x.size() == 3; // n + ok &= type_y.size() == 2; // m + if( ! ok ) + return false; + + type_y[0] = type_x[2]; + type_y[1] = std::max(type_x[0], type_x[1]); + return true; + } +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector& taylor_x , + vector& taylor_y ) + { +# ifndef NDEBUG + size_t n = taylor_x.size() / (order_up + 1); + size_t m = taylor_y.size() / (order_up + 1); +# endif + assert( n == 3 ); + assert( m == 2 ); + assert( order_low <= order_up ); + + // return flag + bool ok = order_up == 0; + if( ! ok ) + return ok; + + // Order zero forward mode must always be implemented + taylor_y[0] = taylor_x[2] * taylor_x[2]; + taylor_y[1] = taylor_x[0] * taylor_x[1]; + + return ok; + } +/* %$$ +$head jac_sparsity$$ +$srccode%cpp% */ + // Jacobian sparsity routine called by CppAD + virtual bool jac_sparsity( + const vector& parameter_x , + const vector& type_x , + bool dependency , + const vector& select_x , + const vector& select_y , + CppAD::sparse_rc< vector >& pattern_out ) + { + size_t n = select_x.size(); + size_t m = select_y.size(); + assert( n == 3 ); + assert( m == 2 ); + assert( parameter_x.size() == n ); + + // count number of non-zeros in sparsity pattern + size_t nnz = 0; + // row 0 + if( select_y[0] & select_x[2] ) + ++nnz; + // row 1 + if( select_y[1] ) + { // column 0 + if( select_x[0] ) + ++nnz; + // column 1 + if( select_x[1] ) + ++nnz; + } + + // size of pattern_out + size_t nr = m; + size_t nc = n; + pattern_out.resize(nr, nc, nnz); + // + // set the values in pattern_out using index k + size_t k = 0; + // + // y_0 depends and has possibly non-zeron partial w.r.t x_2 + if( select_y[0] & select_x[2] ) + pattern_out.set(k++, 0, 2); + if( select_y[1] ) + { // y_1 depends and has possibly non-zero partial w.r.t x_0 + if( select_x[0] ) + pattern_out.set(k++, 1, 0); + // y_1 depends and has possibly non-zero partial w.r.t x_1 + if( select_x[1] ) + pattern_out.set(k++, 1, 1); + } + assert( k == nnz ); + // + return true; + } +/* %$$ +$head hes_sparsity$$ +$srccode%cpp% */ + // Hessian sparsity routine called by CppAD + virtual bool hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const vector& select_x , + const vector& select_y , + CppAD::sparse_rc< vector >& pattern_out ) + { assert( parameter_x.size() == select_x.size() ); + assert( select_y.size() == 2 ); + size_t n = select_x.size(); + assert( n == 3 ); + // + // [ 0 , 0 , 0 ] [ 0 , 1 , 0 ] + // g_0''(x) = [ 0 , 0 , 0 ] g_1^'' (x) = [ 1 , 0 , 0 ] + // [ 0 , 0 , 2 ] [ 0 , 0 , 0 ] + // + // + // count number of non-zeros in sparsity pattern + size_t nnz = 0; + if( select_y[0] ) + { if( select_x[2] ) + ++nnz; + } + if( select_y[1] ) + { if( select_x[0] & select_x[1] ) + nnz += 2; + } + // + // size of pattern_out + size_t nr = n; + size_t nc = n; + pattern_out.resize(nr, nc, nnz); + // + // set the values in pattern_out using index k + size_t k = 0; + // + // y[1] has possible non-zero second partial w.r.t. x[0], x[1] + if( select_y[1] ) + { if( select_x[0] & select_x[1] ) + { pattern_out.set(k++, 0, 1); + pattern_out.set(k++, 1, 0); + } + } + // + // y[0] has possibly non-zero second partial w.r.t x[2], x[2] + if( select_y[0] ) + { if( select_x[2] ) + pattern_out.set(k++, 2, 2); + } + return true; + } +}; // End of atomic_for_sparse_hes class + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool use_hes_sparsity(bool u_1_variable, bool forward) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // Create the atomic_hes_sparsity object correspnding to g(x) + atomic_hes_sparsity afun("atomic_hes_sparsity"); + // + // Create the function f(u) = g(u) for this example. + // + // domain space vector + size_t n = 3; + double u_0 = 1.00; + double u_1 = 2.00; + double u_2 = 3.00; + vector< AD > au(n); + au[0] = u_0; + au[1] = u_1; + au[2] = u_2; + + // declare independent variables and start tape recording + CppAD::Independent(au); + + // range space vector + size_t m = 2; + vector< AD > ay(m); + + // call atomic function + vector< AD > ax(n); + ax[0] = au[0]; + ax[2] = au[2]; + if( u_1_variable ) + { ok &= Variable( au[1] ); + ax[1] = au[1]; + } + else + { AD ap = u_1; + ok &= Parameter(ap); + ok &= ap == au[1]; + ax[1] = u_1; + } + // u_1_variable true: y = [ u_2 * u_2 , u_0 * u_1 ]^T + // u_1_variable false: y = [ u_2 * u_2 , u_0 * p ]^T + afun(ax, ay); + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // f(u) = y + // + // check function value + double check = u_2 * u_2; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + check = u_0 * u_1; + ok &= NearEqual( Value(ay[1]) , check, eps, eps); + + // check zero order forward mode + size_t q; + vector xq(n), yq(m); + q = 0; + xq[0] = u_0; + xq[1] = u_1; + xq[2] = u_2; + yq = f.Forward(q, xq); + check = u_2 * u_2; + ok &= NearEqual(yq[0] , check, eps, eps); + check = u_0 * u_1; + ok &= NearEqual(yq[1] , check, eps, eps); + + // select_u + CPPAD_TESTVECTOR(bool) select_u(n); + for(size_t j = 0; j < n; j++) + select_u[j] = true; + + // select_y + CPPAD_TESTVECTOR(bool) select_y(m); + for(size_t i = 0; i < m; i++) + select_y[i] = true; + + // for_hes_sparsity + bool internal_bool = false; + CppAD::sparse_rc< CPPAD_TESTVECTOR(size_t) > pattern_out; + if( forward ) + { f.for_hes_sparsity( + select_u, select_y, internal_bool, pattern_out + ); + } + else + { // pattern for indepentity matrix + CppAD::sparse_rc< CPPAD_TESTVECTOR(size_t) > pattern_in(n, n, n); + bool transpose = false; + bool dependency = false; + for(size_t k = 0; k < n; ++k) + pattern_in.set(k, k, k); + // for_jac_sparsity (ignore pattern_out) + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + // rev_jac_sparsity + f.rev_hes_sparsity( + select_y, transpose, internal_bool, pattern_out + ); + } + const CPPAD_TESTVECTOR(size_t)& row = pattern_out.row(); + const CPPAD_TESTVECTOR(size_t)& col = pattern_out.col(); + CPPAD_TESTVECTOR(size_t) row_major = pattern_out.row_major(); + // + // in row major order first element has index (0, 1) and second has + // index (1, 0). These are only included when u_1 is a variable. + size_t k = 0, r, c; + if( u_1_variable ) + { r = row[ row_major[k] ]; + c = col[ row_major[k] ]; + ok &= r == 0 && c == 1; + ++k; + r = row[ row_major[k] ]; + c = col[ row_major[k] ]; + ok &= r == 1 && c == 0; + ++k; + } + // in row major order next element, in lower triangle of Hessians, + // has index (2, 2). This element is always included + r = row[ row_major[k] ]; + c = col[ row_major[k] ]; + ok &= r == 2 && c == 2; + // + // k + 1 should be the number of values in sparsity pattern + ok &= k + 1 == pattern_out.nnz(); + // + return ok; +} +} // End empty namespace +/* %$$ +$head Test with u_1 Both a Variable and a Parameter$$ +$srccode%cpp% */ +bool hes_sparsity(void) +{ bool ok = true; + // + bool u_1_variable = true; + bool forward = true; + ok &= use_hes_sparsity(u_1_variable, forward); + // + u_1_variable = true; + forward = false; + ok &= use_hes_sparsity(u_1_variable, forward); + // + u_1_variable = false; + forward = true; + ok &= use_hes_sparsity(u_1_variable, forward); + // + u_1_variable = false; + forward = false; + ok &= use_hes_sparsity(u_1_variable, forward); + // + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_three/jac_sparsity.cpp cppad-2019.02.00.0/example/atomic_three/jac_sparsity.cpp --- cppad-2018.00.00.0/example/atomic_three/jac_sparsity.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/jac_sparsity.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,321 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availabilitaylor_y set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three_jac_sparsity.cpp$$ +$spell + Jacobian +$$ + +$section Atomic Function Jacobian Sparsity: Example and Test$$ + +$head Purpose$$ +This example demonstrates calculation of a Jacobian sparsity pattern +using an atomic operation. + +$head Function$$ +For this example, the atomic function +$latex g : \B{R}^3 \rightarrow \B{R}^2$$ is defined by +$latex \[ +g(x) = \left( \begin{array}{c} + x_2 * x_2 \\ + x_0 * x_1 +\end{array} \right) +\] $$ + +$head Jacobian$$ +The corresponding Jacobian is +$latex \[ +g^{(1)} (x) = \left( \begin{array}{ccc} + 0 & 0 & 2 x_2 \\ +x_1 & x_0 & 0 +\end{array} \right) +\] $$ + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // begin empty namespace +using CppAD::vector; // abbreviate CppAD::vector as vector +// +class atomic_jac_sparsity : public CppAD::atomic_three { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + atomic_jac_sparsity(const std::string& name) : + CppAD::atomic_three(name) + { } +private: +/* %$$ +$head for_type$$ +$srccode%cpp% */ + // calculate type_y + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = type_x.size() == 3; // n + ok &= type_y.size() == 2; // m + if( ! ok ) + return false; + + type_y[0] = type_x[2]; + type_y[1] = std::max(type_x[0], type_x[1]); + return true; + } +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector& taylor_x , + vector& taylor_y ) + { +# ifndef NDEBUG + size_t n = taylor_x.size() / (order_up + 1); + size_t m = taylor_y.size() / (order_up + 1); +# endif + assert( n == 3 ); + assert( m == 2 ); + assert( order_low <= order_up ); + + // return flag + bool ok = order_up == 0; + if( ! ok ) + return ok; + + // Order zero forward mode must always be implemented + taylor_y[0] = taylor_x[2] * taylor_x[2]; + taylor_y[1] = taylor_x[0] * taylor_x[1]; + + return ok; + } +/* %$$ +$head jac_sparsity$$ +$srccode%cpp% */ + // Jacobian sparsity routine called by CppAD + virtual bool jac_sparsity( + const vector& parameter_x , + const vector& type_x , + bool dependency , + const vector& select_x , + const vector& select_y , + CppAD::sparse_rc< vector >& pattern_out ) + { + size_t n = select_x.size(); + size_t m = select_y.size(); + assert( parameter_x.size() == n ); + assert( n == 3 ); + assert( m == 2 ); + + // count number of non-zeros in sparsity pattern + size_t nnz = 0; + // row 0 + if( select_y[0] & select_x[2] ) + ++nnz; + // row 1 + if( select_y[1] ) + { // column 0 + if( select_x[0] ) + ++nnz; + // column 1 + if( select_x[1] ) + ++nnz; + } + + // size of pattern_out + size_t nr = m; + size_t nc = n; + pattern_out.resize(nr, nc, nnz); + + // set the values in pattern_out using index k + size_t k = 0; + + // y_0 depends and has possibly non-zeron partial w.r.t x_2 + if( select_y[0] & select_x[2] ) + pattern_out.set(k++, 0, 2); + if( select_y[1] ) + { // y_1 depends and has possibly non-zero partial w.r.t x_0 + if( select_x[0] ) + pattern_out.set(k++, 1, 0); + // y_1 depends and has possibly non-zero partial w.r.t x_1 + if( select_x[1] ) + pattern_out.set(k++, 1, 1); + } + assert( k == nnz ); + // + return true; + } +}; // End of atomic_three_jac_sparsity class + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool use_jac_sparsity(bool x_1_variable, bool forward) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // Create the atomic_jac_sparsity object correspnding to g(x) + atomic_jac_sparsity afun("atomic_jac_sparsity"); + // + // Create the function f(u) = g(u) for this example. + // + // domain space vector + size_t n = 3; + double u_0 = 1.00; + double u_1 = 2.00; + double u_2 = 3.00; + vector< AD > au(n); + au[0] = u_0; + au[1] = u_1; + au[2] = u_2; + + // declare independent variables and start tape recording + CppAD::Independent(au); + + // range space vector + size_t m = 2; + vector< AD > ay(m); + + // call atomic function + vector< AD > ax(n); + ax[0] = au[0]; + ax[2] = au[2]; + if( x_1_variable ) + { ok &= Variable( au[1] ); + ax[1] = au[1]; + } + else + { AD ap = u_1; + ok &= Parameter(ap); + ok &= ap == au[1]; + ax[1] = u_1; + } + // x_1_variable true: y = [ u_2 * u_2 , u_0 * u_1 ]^T + // x_1_variable false: y = [ u_2 * u_2 , u_0 * p ]^T + afun(ax, ay); + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // f(u) = y + // + // check function value + double check = u_2 * u_2; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + check = u_0 * u_1; + ok &= NearEqual( Value(ay[1]) , check, eps, eps); + + // check zero order forward mode + size_t q; + vector xq(n), yq(m); + q = 0; + xq[0] = u_0; + xq[1] = u_1; + xq[2] = u_2; + yq = f.Forward(q, xq); + check = u_2 * u_2; + ok &= NearEqual(yq[0] , check, eps, eps); + check = u_0 * u_1; + ok &= NearEqual(yq[1] , check, eps, eps); + + // sparsity pattern for identity matrix + size_t nnz; + if( forward ) + nnz = n; + else + nnz = m; + CppAD::sparse_rc< CPPAD_TESTVECTOR(size_t) > pattern_in(nnz, nnz, nnz); + for(size_t k = 0; k < nnz; ++k) + pattern_in.set(k, k, k); + + // Jacobian sparsity for f(u) + bool transpose = false; + bool dependency = false; + bool internal_bool = false; + CppAD::sparse_rc< CPPAD_TESTVECTOR(size_t) > pattern_out; + if( forward ) + { f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + } + else + { f.rev_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + } + const CPPAD_TESTVECTOR(size_t)& row = pattern_out.row(); + const CPPAD_TESTVECTOR(size_t)& col = pattern_out.col(); + CPPAD_TESTVECTOR(size_t) row_major = pattern_out.row_major(); + // + // first element in row major order has index (0, 2) + size_t k = 0; + size_t r = row[ row_major[k] ]; + size_t c = col[ row_major[k] ]; + ok &= r == 0 && c == 2; + // + // second element in row major order has index (1, 0) + ++k; + r = row[ row_major[k] ]; + c = col[ row_major[k] ]; + ok &= r == 1 && c == 0; + // + if( x_1_variable ) + { // third element in row major order has index (1, 1) + ++k; + r = row[ row_major[k] ]; + c = col[ row_major[k] ]; + ok &= r == 1 && c == 1; + } + // k + 1 should be the number of values in sparsity pattern + ok &= k + 1 == pattern_out.nnz(); + // + return ok; +} +} // End empty namespace +/* %$$ +$head Test with u_1 Both a Variable and a Parameter$$ +$srccode%cpp% */ +bool jac_sparsity(void) +{ bool ok = true; + // + bool u_1_variable = true; + bool forward = true; + ok &= use_jac_sparsity(u_1_variable, forward); + // + u_1_variable = true; + forward = false; + ok &= use_jac_sparsity(u_1_variable, forward); + // + u_1_variable = false; + forward = true; + ok &= use_jac_sparsity(u_1_variable, forward); + // + u_1_variable = false; + forward = false; + ok &= use_jac_sparsity(u_1_variable, forward); + // + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_three/makefile.am cppad-2019.02.00.0/example/atomic_three/makefile.am --- cppad-2018.00.00.0/example/atomic_three/makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,43 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# automake input file +# +# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp +DEFS = +# +check_PROGRAMS = atomic +# +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) +# +# +atomic_SOURCES = \ + $(EIGEN_SRC_FILES) \ + atomic_three.cpp \ + mat_mul.cpp \ + norm_sq.cpp\ + tangent.cpp\ + base2ad.cpp\ + reciprocal.cpp \ + dynamic.cpp \ + forward.cpp \ + get_started.cpp \ + hes_sparsity.cpp \ + jac_sparsity.cpp \ + reverse.cpp \ + rev_depend.cpp + +test: check + ./atomic diff -Nru cppad-2018.00.00.0/example/atomic_three/makefile.in cppad-2019.02.00.0/example/atomic_three/makefile.in --- cppad-2018.00.00.0/example/atomic_three/makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,650 @@ +# makefile.in generated by automake 1.15.1 from makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2017 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +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 \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +check_PROGRAMS = atomic$(EXEEXT) +subdir = example/atomic_three +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_three.$(OBJEXT) mat_mul.$(OBJEXT) \ + norm_sq.$(OBJEXT) tangent.$(OBJEXT) base2ad.$(OBJEXT) \ + reciprocal.$(OBJEXT) dynamic.$(OBJEXT) forward.$(OBJEXT) \ + get_started.$(OBJEXT) hes_sparsity.$(OBJEXT) \ + jac_sparsity.$(OBJEXT) reverse.$(OBJEXT) rev_depend.$(OBJEXT) +atomic_OBJECTS = $(am_atomic_OBJECTS) +atomic_LDADD = $(LDADD) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(atomic_SOURCES) +DIST_SOURCES = $(atomic_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + 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@ +ACLOCAL = @ACLOCAL@ +ADOLC_DIR = @ADOLC_DIR@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BOOST_DIR = @BOOST_DIR@ +BOOST_INCLUDE = @BOOST_INCLUDE@ +BTHREAD_LIB = @BTHREAD_LIB@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPAD_IPOPT_LD_PATH = @CPPAD_IPOPT_LD_PATH@ +CPPAD_IPOPT_LIBS = @CPPAD_IPOPT_LIBS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXX_FLAGS@ +CYGPATH_W = @CYGPATH_W@ + +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# automake input file +# +# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp +DEFS = +DEPDIR = @DEPDIR@ +DL_LIB = @DL_LIB@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EIGEN_DIR = @EIGEN_DIR@ +EIGEN_INCLUDE = @EIGEN_INCLUDE@ +EXEEXT = @EXEEXT@ +FADBAD_DIR = @FADBAD_DIR@ +FC = @FC@ +FCFLAGS = @FCFLAGS@ +FCLIBS = @FCLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +IPOPT_DIR = @IPOPT_DIR@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAX_NUM_THREADS = @MAX_NUM_THREADS@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +OPENMP_FLAGS = @OPENMP_FLAGS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSTFIX_DIR = @POSTFIX_DIR@ +PTHREAD_LIB = @PTHREAD_LIB@ +RANLIB = @RANLIB@ +SACADO_DIR = @SACADO_DIR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TAPE_ADDR_TYPE = @TAPE_ADDR_TYPE@ +TAPE_ID_TYPE = @TAPE_ID_TYPE@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_FC = @ac_ct_FC@ +adolc_prefix = @adolc_prefix@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ +cppad_boostvector = @cppad_boostvector@ +cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ +cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated_01 = @cppad_deprecated_01@ +cppad_description = @cppad_description@ +cppad_eigenvector = @cppad_eigenvector@ +cppad_has_adolc = @cppad_has_adolc@ +cppad_has_boost = @cppad_has_boost@ +cppad_has_colpack = @cppad_has_colpack@ +cppad_has_eigen = @cppad_has_eigen@ +cppad_has_fadbad = @cppad_has_fadbad@ +cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_ipopt = @cppad_has_ipopt@ +cppad_has_mkstemp = @cppad_has_mkstemp@ +cppad_has_sacado = @cppad_has_sacado@ +cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ +cppad_max_num_threads = @cppad_max_num_threads@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ +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_version = @cppad_version@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +eigen_prefix = @eigen_prefix@ +exec_prefix = @exec_prefix@ +have_pkg_config = @have_pkg_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +ipopt_prefix = @ipopt_prefix@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +# +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + +# +# +atomic_SOURCES = \ + $(EIGEN_SRC_FILES) \ + atomic_three.cpp \ + mat_mul.cpp \ + norm_sq.cpp\ + tangent.cpp\ + base2ad.cpp\ + reciprocal.cpp \ + dynamic.cpp \ + forward.cpp \ + get_started.cpp \ + hes_sparsity.cpp \ + jac_sparsity.cpp \ + reverse.cpp \ + rev_depend.cpp + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign example/atomic_three/makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign example/atomic_three/makefile +makefile: $(srcdir)/makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) + +atomic$(EXEEXT): $(atomic_OBJECTS) $(atomic_DEPENDENCIES) $(EXTRA_atomic_DEPENDENCIES) + @rm -f atomic$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(atomic_OBJECTS) $(atomic_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atomic_three.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base2ad.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynamic.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forward.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_started.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hes_sparsity.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jac_sparsity.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)/reciprocal.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rev_depend.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reverse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tangent.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) +check: check-am +all-am: makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ + clean-checkPROGRAMS clean-generic cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +.PRECIOUS: makefile + + +test: check + ./atomic + +# 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. +.NOEXPORT: diff -Nru cppad-2018.00.00.0/example/atomic_three/mat_mul.cpp cppad-2019.02.00.0/example/atomic_three/mat_mul.cpp --- cppad-2018.00.00.0/example/atomic_three/mat_mul.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/mat_mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,272 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_three_mat_mul.cpp$$ +$spell + mul +$$ + +$section User Atomic Matrix Multiply: Example and Test$$ + +$head See Also$$ +$cref atomic_two_eigen_mat_mul.cpp$$ + +$children% + include/cppad/example/mat_mul.hpp +%$$ + +$head Class Definition$$ +This example uses the file $cref atomic_mat_mul.hpp$$ +which defines matrix multiply as a $cref atomic_three$$ operation. + +$nospell + +$head Use Atomic Function$$ +$srccode%cpp% */ +# include +# include + +bool mat_mul(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::vector; + size_t i, j; +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // ------------------------------------------------------------------- + // object that multiplies 2 x 2 matrices + atomic_mat_mul afun; +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + // start recording with four independent varables + size_t n = 4; + vector x(n); + vector< AD > ax(n); + for(j = 0; j < n; j++) + ax[j] = x[j] = double(j + 1); + CppAD::Independent(ax); + + // ------------------------------------------------------------------ + size_t nr_left = 2; + size_t n_middle = 2; + size_t nc_right = 2; + vector< AD > atom_x(3 + (nr_left + nc_right) * n_middle ); + + // matrix dimensions + atom_x[0] = AD( nr_left ); + atom_x[1] = AD( n_middle ); + atom_x[2] = AD( nc_right ); + + // left matrix + atom_x[3] = ax[0]; // left[0, 0] = x0 + atom_x[4] = ax[1]; // left[0, 1] = x1 + atom_x[5] = 5.; // left[1, 0] = 5 + atom_x[6] = 6.; // left[1, 1] = 6 + + // right matix + atom_x[7] = ax[2]; // right[0, 0] = x2 + atom_x[8] = 7.; // right[0, 1] = 7 + atom_x[9] = ax[3]; // right[1, 0] = x3 + atom_x[10] = 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 ] + */ + vector< AD > atom_y(nr_left * nc_right); + afun(atom_x, atom_y); + + ok &= (atom_y[0] == x[0]*x[2] + x[1]*x[3]) & Variable(atom_y[0]); + ok &= (atom_y[1] == x[0]*7. + x[1]*8. ) & Variable(atom_y[1]); + ok &= (atom_y[2] == 5.*x[2] + 6.*x[3]) & Variable(atom_y[2]); + ok &= (atom_y[3] == 5.*7. + 6.*8. ) & Parameter(atom_y[3]); + + // ------------------------------------------------------------------ + // define the function g : x -> atom_y + // g(x) = [ x0*x2 + x1*x3 , x0*7 + x1*8 , 5*x2 + 6*x3 , 5*7 + 6*8 ]^T + CppAD::ADFun g(ax, atom_y); +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // Test zero order forward mode evaluation of g(x) + size_t m = atom_y.size(); + vector y(m); + for(j = 0; j < n; j++) + x[j] = double(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(n), dy(m); + for(j = 0; j < n; j++) + dx[j] = double(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(n), ddy(m); + for(j = 0; j < n; 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.; +/* %$$ +$subhead reverse$$ +$srccode%cpp% */ + // Test second order reverse mode + CppAD::vector w(m), dw(2 * n); + 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.; +/* %$$ +$subhead jac_sparsity$$ +$srccode%cpp% */ + // sparsity pattern for the Jacobian + // g'(x) = [ x2, x3, x0, x1 ] + // [ 7, 8, 0, 0 ] + // [ 0, 0, 5, 6 ] + // [ 0, 0, 0, 0 ] + CppAD::sparse_rc< CPPAD_TESTVECTOR(size_t) > pattern_in, pattern_out; + bool transpose = false; + bool dependency = false; + bool internal_bool = false; + // test both forward and reverse mode + for(size_t forward_mode = 0; forward_mode <= 1; ++forward_mode) + { if( bool(forward_mode) ) + { pattern_in.resize(n, n, n); + for(j = 0; j < n; ++j) + pattern_in.set(j, j, j); + g.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + } + else + { pattern_in.resize(m, m, m); + for(i = 0; i < m; ++i) + pattern_in.set(i, i, i); + g.rev_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + } + const CPPAD_TESTVECTOR(size_t)& row = pattern_out.row(); + const CPPAD_TESTVECTOR(size_t)& col = pattern_out.col(); + CPPAD_TESTVECTOR(size_t) row_major = pattern_out.row_major(); + size_t k = 0; + for(j = 0; j < n; ++j) + { ok &= row[ row_major[k] ] == 0; // (0, j) + ok &= col[ row_major[k] ] == j; + ++k; + } + ok &= row[ row_major[k] ] == 1; // (1, 0) + ok &= col[ row_major[k] ] == 0; // + ++k; + ok &= row[ row_major[k] ] == 1; // (1, 1) + ok &= col[ row_major[k] ] == 1; // + ++k; + ok &= row[ row_major[k] ] == 2; // (2, 2) + ok &= col[ row_major[k] ] == 2; // + ++k; + ok &= row[ row_major[k] ] == 2; // (2, 3) + ok &= col[ row_major[k] ] == 3; // + ++k; + ok &= pattern_out.nnz() == k; + } +/* %$$ +$subhead hes_sparsity$$ +$srccode%cpp% */ + /* 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 ] + */ + CPPAD_TESTVECTOR(bool) select_x(n), select_y(m); + for(j = 0; j < n; ++j) + select_x[j] = true; + for(i = 0; i < m; ++i) + select_y[i] = true; + for(size_t forward_mode = 0; forward_mode <= 1; ++forward_mode) + { if( bool(forward_mode) ) + { g.for_hes_sparsity( + select_y, select_x, internal_bool, pattern_out + ); + } + else + { // results for for_jac_sparsity are stored in g + g.rev_hes_sparsity( + select_y, transpose, internal_bool, pattern_out + ); + } + const CPPAD_TESTVECTOR(size_t)& row = pattern_out.row(); + const CPPAD_TESTVECTOR(size_t)& col = pattern_out.col(); + CPPAD_TESTVECTOR(size_t) row_major = pattern_out.row_major(); + size_t k = 0; + ok &= row[ row_major[k] ] == 0; // (0, 2) + ok &= col[ row_major[k] ] == 2; + ++k; + ok &= row[ row_major[k] ] == 1; // (1, 3) + ok &= col[ row_major[k] ] == 3; + ++k; + ok &= row[ row_major[k] ] == 2; // (2, 0) + ok &= col[ row_major[k] ] == 0; + ++k; + ok &= row[ row_major[k] ] == 3; // (3, 1) + ok &= col[ row_major[k] ] == 1; + ++k; + ok &= pattern_out.nnz() == k; + } + + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_three/norm_sq.cpp cppad-2019.02.00.0/example/atomic_three/norm_sq.cpp --- cppad-2018.00.00.0/example/atomic_three/norm_sq.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/norm_sq.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,373 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_three_norm_sq.cpp$$ +$spell + sq + bool + enum +$$ + +$section Atomic Euclidean Norm Squared: Example and Test$$ + +$head Function$$ +This example demonstrates using $cref atomic_three$$ +to define the operation +$latex g : \B{R}^n \rightarrow \B{R}^m$$ where +$latex n = 2$$, $latex m = 1$$, where +$latex \[ + g(x) = x_0^2 + x_1^2 +\] $$ + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreivate CppAD::vector as vector +// +class atomic_norm_sq : public CppAD::atomic_three { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + atomic_norm_sq(const std::string& name) : + CppAD::atomic_three(name) + { } +private: +/* %$$ +$head for_type$$ +$srccode%cpp% */ + // calculate type_y + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = type_x.size() == 2; // n + ok &= type_y.size() == 1; // m + if( ! ok ) + return false; + type_y[0] = std::max(type_x[0], type_x[1]); + return true; + } +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t p , + size_t q , + const vector& tx , + vector& ty ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q+1); + size_t m = ty.size() / (q+1); +# endif + assert( type_x.size() == n ); + assert( n == 2 ); + assert( m == 1 ); + assert( p <= q ); + + // return flag + bool ok = q <= 1; + + // Order zero forward mode must always be implemented. + // y^0 = g( x^0 ) + double x_00 = tx[ 0*(q+1) + 0]; // x_0^0 + double x_10 = tx[ 1*(q+1) + 0]; // x_10 + double g = x_00 * x_00 + x_10 * x_10; // g( x^0 ) + if( p <= 0 ) + ty[0] = g; // y_0^0 + if( q <= 0 ) + return ok; + + // Order one forward mode. + // This case needed if first order forward mode is used. + // y^1 = g'( x^0 ) x^1 + double x_01 = tx[ 0*(q+1) + 1]; // x_0^1 + double x_11 = tx[ 1*(q+1) + 1]; // x_1^1 + double gp_0 = 2.0 * x_00; // partial f w.r.t x_0^0 + double gp_1 = 2.0 * x_10; // partial f w.r.t x_1^0 + if( p <= 1 ) + ty[1] = gp_0 * x_01 + gp_1 * x_11; // g'( x^0 ) * x^1 + if( q <= 1 ) + return ok; + + // Assume we are not using forward mode with order > 1 + assert( ! ok ); + return ok; + } +/* %$$ +$head reverse$$ +$srccode%cpp% */ + // reverse mode routine called by CppAD + virtual bool reverse( + const vector& parameter_x , + const vector& type_x , + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q+1); + size_t m = ty.size() / (q+1); +# endif + assert( px.size() == tx.size() ); + assert( py.size() == ty.size() ); + assert( n == 2 ); + assert( m == 1 ); + bool ok = q <= 1; + + double gp_0, gp_1; + switch(q) + { case 0: + // This case needed if first order reverse mode is used + // F ( {x} ) = g( x^0 ) = y^0 + gp_0 = 2.0 * tx[0]; // partial F w.r.t. x_0^0 + gp_1 = 2.0 * tx[1]; // partial F w.r.t. x_0^1 + px[0] = py[0] * gp_0;; // partial G w.r.t. x_0^0 + px[1] = py[0] * gp_1;; // partial G w.r.t. x_0^1 + assert(ok); + break; + + default: + // Assume we are not using reverse with order > 1 (q > 0) + assert(!ok); + } + return ok; + } +/* %$$ +$head jac_sparsity$$ +$srccode%cpp% */ + // Jacobian sparsity routine called by CppAD + virtual bool jac_sparsity( + const vector& parameter_x , + const vector& type_x , + bool dependency , + const vector& select_x , + const vector& select_y , + CppAD::sparse_rc< vector >& pattern_out ) + { size_t n = select_x.size(); + size_t m = select_y.size(); + assert( n == 2 ); + assert( m == 1 ); + assert( parameter_x.size() == select_x.size() ); + // + // count number non-zeros + size_t nnz = 0; + if( select_y[0] ) + { if( select_x[0] ) + ++nnz; + if( select_x[1] ) + ++nnz; + } + // sparsity pattern + pattern_out.resize(m, n, nnz); + size_t k = 0; + if( select_y[0] ) + { if( select_x[0] ) + pattern_out.set(k++, 0, 0); + if( select_x[1] ) + pattern_out.set(k++, 0, 1); + } + return true; + } +/* %$$ +$head hes_sparsity$$ +$srccode%cpp% */ + // Hessian sparsity routine called by CppAD + virtual bool hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const vector& select_x , + const vector& select_y , + CppAD::sparse_rc< vector >& pattern_out ) + { size_t n = select_x.size(); + assert( n == 2 ); + assert( select_y.size() == 1 ); // m + assert( parameter_x.size() == select_x.size() ); + // + // count number non-zeros + size_t nnz = 0; + if( select_y[0] ) + { if( select_x[0] ) + ++nnz; + if( select_x[1] ) + ++nnz; + } + // sparsity pattern + pattern_out.resize(n, n, nnz); + size_t k = 0; + if( select_y[0] ) + { if( select_x[0] ) + pattern_out.set(k++, 0, 0); + if( select_x[1] ) + pattern_out.set(k++, 1, 1); + } + return true; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_norm_sq class +} // End empty namespace + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool norm_sq(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // -------------------------------------------------------------------- + // Create the atomic reciprocal object + atomic_norm_sq afun("atomic_norm_sq"); +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + // Create the function f(x) = g(x) + // + // domain space vector + size_t n = 2; + double x0 = 0.25; + double x1 = 0.75; + vector< AD > ax(n); + ax[0] = x0; + ax[1] = x1; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // range space vector + size_t m = 1; + vector< AD > ay(m); + + // call atomic function and store norm_sq(x) in au[0] + afun(ax, ay); // y_0 = x_0 * x_0 + x_1 * x_1 + + // create g: x -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (ax, ay); +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // check function value + double check = x0 * x0 + x1 * x1; + 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; + x_q[1] = x1; + 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] = 0.3; + x_q[1] = 0.7; + y_q = f.Forward(q, x_q); + check = 2.0 * x0 * x_q[0] + 2.0 * x1 * x_q[1]; + ok &= NearEqual(y_q[0] , check, eps, eps); + +/* %$$ +$subhead reverse$$ +$srccode%cpp% */ + // first order reverse mode + q = 1; + vector w(m), dw(n * q); + w[0] = 1.; + dw = f.Reverse(q, w); + check = 2.0 * x0; + ok &= NearEqual(dw[0] , check, eps, eps); + check = 2.0 * x1; + ok &= NearEqual(dw[1] , check, eps, eps); +/* %$$ +$subhead rev_jac_sparsity$$ +$srccode%cpp% */ + // reverse mode Jacobian sparstiy pattern + CppAD::sparse_rc< CPPAD_TESTVECTOR(size_t) > pattern_in, pattern_out; + pattern_in.resize(m, m, m); + for(size_t i = 0; i < m; ++i) + pattern_in.set(i, i, i); + bool transpose = false; + bool dependency = false; + bool internal_bool = false; + f.rev_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + CPPAD_TESTVECTOR(size_t) row_major = pattern_out.row_major(); + // + // first element in row major order is (0, 0) + size_t k = 0; + size_t r = pattern_out.row()[ row_major[k] ]; + size_t c = pattern_out.col()[ row_major[k] ]; + ok &= r == 0 && c == 0; + // + // second element in row major order is (0, 1) + ++k; + r = pattern_out.row()[ row_major[k] ]; + c = pattern_out.col()[ row_major[k] ]; + ok &= r == 0 && c == 1; + // + // k + 1 should be number of values in sparsity pattern + ok &= k + 1 == pattern_out.nnz(); +/* %$$ +$subhead for_hes_sparsity$$ +$srccode%cpp% */ + // forward mode Hessian sparsity pattern + CPPAD_TESTVECTOR(bool) select_x(n), select_y(m); + for(size_t j = 0; j < n; ++j) + select_x[j] = true; + for(size_t i = 0; i < m; ++i) + select_y[i] = true; + f.for_hes_sparsity( + select_x, select_y, internal_bool, pattern_out + ); + CPPAD_TESTVECTOR(size_t) order = pattern_out.row_major(); + // + // first element in row major order is (0, 0) + k = 0; + r = pattern_out.row()[ order[k] ]; + c = pattern_out.col()[ order[k] ]; + ok &= r == 0 && c == 0; + // + // second element in row major order is (1, 1) + ++k; + r = pattern_out.row()[ order[k] ]; + c = pattern_out.col()[ order[k] ]; + ok &= r == 1 && c == 1; + // + // k + 1 should be number of values in sparsity pattern + ok &= k + 1 == pattern_out.nnz(); + // + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_three/reciprocal.cpp cppad-2019.02.00.0/example/atomic_three/reciprocal.cpp --- cppad-2018.00.00.0/example/atomic_three/reciprocal.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/reciprocal.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,397 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_three_reciprocal.cpp$$ +$spell + enum +$$ + +$section Reciprocal as an Atomic Operation: Example and Test$$ + +$head Function$$ +This example demonstrates using $cref atomic_three$$ +to define the operation +$latex g : \B{R}^n \rightarrow \B{R}^m$$ where +$latex n = 1$$, $latex m = 1$$, and $latex g(x) = 1 / x$$. + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreivate CppAD::vector as vector +// +class atomic_reciprocal : public CppAD::atomic_three { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + atomic_reciprocal(const std::string& name) : + CppAD::atomic_three(name) + { } +private: +/* %$$ +$head for_type$$ +$srccode%cpp% */ + // calculate type_y + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = type_x.size() == 1; // n + ok &= type_y.size() == 1; // m + if( ! ok ) + return false; + type_y[0] = type_x[0]; + return true; + } +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t p , + size_t q , + const vector& tx , + vector& ty ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( type_x.size() == n ); + assert( n == 1 ); + assert( m == 1 ); + assert( p <= q ); + + // return flag + bool ok = q <= 2; + + // Order zero forward mode. + // This case must always be implemented + // y^0 = g( x^0 ) = 1 / x^0 + double g = 1. / tx[0]; + if( p <= 0 ) + ty[0] = g; + if( q <= 0 ) + return ok; + + // Order one forward mode. + // This case needed if first order forward mode is used. + // y^1 = g'( x^0 ) x^1 + double gp = - g / tx[0]; + if( p <= 1 ) + ty[1] = gp * tx[1]; + if( q <= 1 ) + return ok; + + // Order two forward mode. + // This case needed if second order forward mode is used. + // Y''(t) = X'(t)^\R{T} g''[X(t)] X'(t) + g'[X(t)] X''(t) + // 2 y^2 = x^1 * g''( x^0 ) x^1 + 2 g'( x^0 ) x^2 + double gpp = - 2.0 * gp / tx[0]; + ty[2] = tx[1] * gpp * tx[1] / 2.0 + gp * tx[2]; + if( q <= 2 ) + return ok; + + // Assume we are not using forward mode with order > 2 + assert( ! ok ); + return ok; + } +/* %$$ +$head reverse$$ +$srccode%cpp% */ + // reverse mode routine called by CppAD + virtual bool reverse( + const vector& parameter_x , + const vector& type_x , + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( px.size() == tx.size() ); + assert( py.size() == ty.size() ); + assert( n == 1 ); + assert( m == 1 ); + bool ok = q <= 2; + + double g, gp, gpp, gppp; + switch(q) + { case 0: + // This case needed if first order reverse mode is used + // reverse: F^0 ( tx ) = y^0 = g( x^0 ) + g = ty[0]; + gp = - g / tx[0]; + px[0] = py[0] * gp;; + assert(ok); + break; + + case 1: + // This case needed if second order reverse mode is used + // reverse: F^1 ( tx ) = y^1 = g'( x^0 ) x^1 + g = ty[0]; + gp = - g / tx[0]; + gpp = - 2.0 * gp / tx[0]; + px[1] = py[1] * gp; + px[0] = py[1] * gpp * tx[1]; + // reverse: F^0 ( tx ) = y^0 = g( x^0 ); + px[0] += py[0] * gp; + assert(ok); + break; + + case 2: + // This needed if third order reverse mode is used + // reverse: F^2 ( tx ) = y^2 = + // = x^1 * g''( x^0 ) x^1 / 2 + g'( x^0 ) x^2 + g = ty[0]; + gp = - g / tx[0]; + gpp = - 2.0 * gp / tx[0]; + gppp = - 3.0 * gpp / tx[0]; + px[2] = py[2] * gp; + px[1] = py[2] * gpp * tx[1]; + px[0] = py[2] * tx[1] * gppp * tx[1] / 2.0 + gpp * tx[2]; + // reverse: F^1 ( tx ) = y^1 = g'( x^0 ) x^1 + px[1] += py[1] * gp; + px[0] += py[1] * gpp * tx[1]; + // reverse: F^0 ( tx ) = y^0 = g( x^0 ); + px[0] += py[0] * gp; + assert(ok); + break; + + default: + assert(!ok); + } + return ok; + } +/* %$$ +$head jac_sparsity$$ +$srccode%cpp% */ + // Jacobian sparsity routine called by CppAD + virtual bool jac_sparsity( + const vector& parameter_x , + const vector& type_x , + bool dependency , + const vector& select_x , + const vector& select_y , + CppAD::sparse_rc< vector >& pattern_out ) + { + size_t n = select_x.size(); + size_t m = select_y.size(); + assert( parameter_x.size() == n ); + assert( n == 1 ); + assert( m == 1 ); + + // size of pattern_out + size_t nr = m; + size_t nc = n; + size_t nnz = 0; + if( select_x[0] & select_y[0] ) + ++nnz; + pattern_out.resize(nr, nc, nnz); + + // set values in pattern_out + size_t k = 0; + if( select_x[0] & select_y[0] ) + pattern_out.set(k++, 0, 0); + assert( k == nnz ); + + return true; + } +/* %$$ +$head hes_sparsity$$ +$srccode%cpp% */ + // Hessian sparsity routine called by CppAD + virtual bool hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const vector& select_x , + const vector& select_y , + CppAD::sparse_rc< vector >& pattern_out ) + { + assert( parameter_x.size() == select_x.size() ); + assert( select_y.size() == 1 ); + size_t n = select_x.size(); + assert( n == 1 ); + + // size of pattern_out + size_t nr = n; + size_t nc = n; + size_t nnz = 0; + if( select_x[0] & select_y[0] ) + ++nnz; + pattern_out.resize(nr, nc, nnz); + + // set values in pattern_out + size_t k = 0; + if( select_x[0] & select_y[0] ) + pattern_out.set(k++, 0, 0); + assert( k == nnz ); + + return true; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_reciprocal class +} // End empty namespace + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool reciprocal(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // -------------------------------------------------------------------- + // Create the atomic reciprocal object + atomic_reciprocal afun("atomic_reciprocal"); +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + // Create the function f(x) = 1 / g(x) = 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 > av(m); + + // call atomic function and store g(x) in au[0] + vector< AD > au(m); + afun(ax, au); // u = 1 / x + + // now use AD division to invert to invert the operation + av[0] = 1.0 / au[0]; // v = 1 / u = x + + // create f: x -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (ax, av); // g(x) = x +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // check function value + double check = x0; + ok &= NearEqual( Value(av[0]) , check, eps, eps); + + // check zero order forward mode + size_t q; + vector x_q(n), v_q(m); + q = 0; + x_q[0] = x0; + v_q = f.Forward(q, x_q); + ok &= NearEqual(v_q[0] , check, eps, eps); + + // check first order forward mode + q = 1; + x_q[0] = 1; + v_q = f.Forward(q, x_q); + check = 1.0; + ok &= NearEqual(v_q[0] , check, eps, eps); + + // check second order forward mode + q = 2; + x_q[0] = 0; + v_q = f.Forward(q, x_q); + check = 0.; + ok &= NearEqual(v_q[0] , check, eps, eps); +/* %$$ +$subhead reverse$$ +$srccode%cpp% */ + // 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); +/* %$$ +$subhead for_jac_sparsity$$ +$srccode%cpp% */ + // forward mode Jacobian sparstiy pattern + CppAD::sparse_rc< CPPAD_TESTVECTOR(size_t) > pattern_in, pattern_out; + pattern_in.resize(1, 1, 1); + pattern_in.set(0, 0, 0); + bool transpose = false; + bool dependency = false; + bool internal_bool = false; + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + ok &= pattern_out.nnz() == 1; + ok &= pattern_out.row()[0] == 0; + ok &= pattern_out.col()[0] == 0; +/* %$$ +$subhead rev_sparse_jac$$ +$srccode%cpp% */ + // reverse mode Jacobian sparstiy pattern + f.rev_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + ok &= pattern_out.nnz() == 1; + ok &= pattern_out.row()[0] == 0; + ok &= pattern_out.col()[0] == 0; +/* %$$ +$subhead rev_sparse_hes$$ +$srccode%cpp% */ + // Hessian sparsity (using previous for_jac_sparsity call) + CPPAD_TESTVECTOR(bool) select_y(m); + select_y[0] = true; + f.rev_hes_sparsity( + select_y, transpose, internal_bool, pattern_out + ); + ok &= pattern_out.nnz() == 1; + ok &= pattern_out.row()[0] == 0; + ok &= pattern_out.col()[0] == 0; +/* %$$ +$subhead for_sparse_hes$$ +$srccode%cpp% */ + // Hessian sparsity + CPPAD_TESTVECTOR(bool) select_x(n); + select_x[0] = true; + f.for_hes_sparsity( + select_x, select_y, internal_bool, pattern_out + ); + ok &= pattern_out.nnz() == 1; + ok &= pattern_out.row()[0] == 0; + ok &= pattern_out.col()[0] == 0; + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_three/rev_depend.cpp cppad-2019.02.00.0/example/atomic_three/rev_depend.cpp --- cppad-2018.00.00.0/example/atomic_three/rev_depend.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/rev_depend.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,253 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_three_rev_depend.cpp$$ + +$section Atomic Functions Reverse Dependency Analysis: Example and Test$$ + +$head Purpose$$ +This example demonstrates using $cref atomic_three$$ function +in the definition of a function that is optimized. + +$head Function$$ +For this example, the atomic function +$latex g : \B{R}^3 \rightarrow \B{R}^3$$ is defined by +$latex g_0 (x) = x_0 * x_0$$, +$latex g_1 (x) = x_0 * x_1$$, +$latex g_2 (x) = x_1 * x_2$$. + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include // CppAD include file +namespace { // start empty namespace +using CppAD::vector; // abbreviate CppAD::vector using vector +// start definition of atomic derived class using atomic_three interface +class atomic_optimize : public CppAD::atomic_three { +/* %$$ +$head Constructor$$ +$srccode%cpp% */ +public: + // can use const char* name when calling this constructor + atomic_optimize(const std::string& name) : // can have more arguments + CppAD::atomic_three(name) // inform base class of name + { } + +private: +/* %$$ +$head for_type$$ +$srccode%cpp% */ + // calculate type_y + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = type_x.size() == 3; // n + ok &= type_y.size() == 3; // m + if( ! ok ) + return false; + type_y[0] = type_x[0]; + type_y[1] = std::max( type_x[0], type_x[1] ); + type_y[2] = std::max( type_x[1], type_x[2] ); + return true; + } +/* %$$ +$head rev_depend$$ +$srccode%cpp% */ + // calculate depend_x + virtual bool rev_depend( + const vector& parameter_x , + const vector& type_x , + vector& depend_x , + const vector& depend_y ) + { assert( parameter_x.size() == depend_x.size() ); + bool ok = depend_x.size() == 3; // n + ok &= depend_y.size() == 3; // m + if( ! ok ) + return false; + depend_x[0] = depend_y[0] | depend_y[1]; + depend_x[1] = depend_y[1] | depend_y[2]; + depend_x[2] = depend_y[2]; + return true; + } +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector& taylor_x , + vector& taylor_y + ) + { +# ifndef NDEBUG + size_t n = taylor_x.size() / (order_up + 1); + size_t m = taylor_y.size() / (order_up + 1); +# endif + assert( n == 3 ); + assert( m == 3 ); + assert( order_low <= order_up ); + + // return flag + bool ok = order_up == 0; + if( ! ok ) + return ok; + + // Order zero forward mode. + // This case must always be implemented + if( need_y > size_t(CppAD::variable_enum) ) + { // g_0 = x_0 * x_0 + taylor_y[0] = taylor_x[0] * taylor_x[0]; + // g_1 = x_0 * x_1 + taylor_y[1] = taylor_x[0] * taylor_x[1]; + // g_2 = x_1 * x_2 + taylor_y[2] = taylor_x[1] * taylor_x[2]; + } + else + { // This uses need_y to reduce amount of computation. + // It is probably faster, for this case, to ignore need_y. + vector type_y( taylor_y.size() ); + for_type(taylor_x, type_x, type_y); + // g_0 = x_0 * x_0 + if( size_t(type_y[0]) == need_y ) + taylor_y[0] = taylor_x[0] * taylor_x[0]; + // g_1 = x_0 * x_1 + if( size_t(type_y[1]) == need_y ) + taylor_y[1] = taylor_x[0] * taylor_x[1]; + // g_2 = x_1 * x_2 + if( size_t(type_y[2]) == need_y ) + taylor_y[2] = taylor_x[1] * taylor_x[2]; + } + + return ok; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_optimize class +} // End empty namespace + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool rev_depend(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // Create the atomic dynamic object corresponding to g(x) + atomic_optimize afun("atomic_optimize"); +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + // Create the function f(u) = g(c, p, u) for this example. + // + // constant parameter + double c_0 = 2.0; + // + // indepndent dynamic parameter vector + size_t np = 1; + CPPAD_TESTVECTOR(double) p(np); + CPPAD_TESTVECTOR( AD ) ap(np); + ap[0] = p[0] = 3.0; + // + // independent variable vector + size_t nu = 1; + double u_0 = 0.5; + CPPAD_TESTVECTOR( AD ) au(nu); + au[0] = u_0; + + // declare independent variables and start tape recording + size_t abort_op_index = 0; + bool record_compare = true; + CppAD::Independent(au, abort_op_index, record_compare, ap); + + // range space vector + size_t ny = 3; + CPPAD_TESTVECTOR( AD ) ay(ny); + + // call atomic function and store result in ay + // y = ( c * c, c * p, p * u ) + CPPAD_TESTVECTOR( AD ) ax(3); + ax[0] = c_0; // x_0 = c + ax[1] = ap[0]; // x_1 = p + ax[2] = au[0]; // x_2 = u + afun(ax, ay); + + // check type of result + ok &= Constant( ay[0] ); // c * c + ok &= Dynamic( ay[1] ); // c * p + ok &= Variable( ay[2] ); // p * u + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // f(u) = (c * c, c * p, p * u) +/* %$$ +$subhead optimize$$ +This operation does a callback to +$cref/rev_depend/atomic_three_rev_depend.cpp/rev_depend/$$ defined above +$srccode%cpp% */ + f.optimize(); +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // check function value + double check = c_0 * c_0; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + check = c_0 * p[0]; + ok &= NearEqual( Value(ay[1]) , check, eps, eps); + check = p[0] * u_0; + ok &= NearEqual( Value(ay[2]) , check, eps, eps); + + // check zero order forward mode + size_t q; + CPPAD_TESTVECTOR( double ) u_q(nu), y_q(ny); + q = 0; + u_q[0] = u_0; + y_q = f.Forward(q, u_q); + check = c_0 * c_0; + ok &= NearEqual(y_q[0] , check, eps, eps); + check = c_0 * p[0]; + ok &= NearEqual(y_q[1] , check, eps, eps); + check = p[0] * u_0; + ok &= NearEqual(y_q[2] , check, eps, eps); + + // set new value for dynamic parameters + p[0] = 2.0 * p[0]; + f.new_dynamic(p); + y_q = f.Forward(q, u_q); + check = c_0 * c_0; + ok &= NearEqual(y_q[0] , check, eps, eps); + check = c_0 * p[0]; + ok &= NearEqual(y_q[1] , check, eps, eps); + check = p[0] * u_0; + ok &= NearEqual(y_q[2] , check, eps, eps); + +/* %$$ +$subhead Return Test Result$$ +$srccode%cpp% */ + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_three/reverse.cpp cppad-2019.02.00.0/example/atomic_three/reverse.cpp --- cppad-2018.00.00.0/example/atomic_three/reverse.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/reverse.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,363 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availabilitaylor_y set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three_reverse.cpp$$ +$spell + Jacobian +$$ + +$section Atomic Functions and Reverse Mode: Example and Test$$ + +$head Purpose$$ +This example demonstrates reverse mode derivative calculation +using an $cref atomic_three$$ function. + +$head Function$$ +For this example, the atomic function +$latex g : \B{R}^3 \rightarrow \B{R}^2$$ is defined by +$latex \[ +g(x) = \left( \begin{array}{c} + x_2 * x_2 \\ + x_0 * x_1 +\end{array} \right) +\] $$ + +$head Jacobian$$ +The corresponding Jacobian is +$latex \[ +g^{(1)} (x) = \left( \begin{array}{ccc} + 0 & 0 & 2 x_2 \\ +x_1 & x_0 & 0 +\end{array} \right) +\] $$ + +$head Hessian$$ +The Hessians of the component functions are +$latex \[ +g_0^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 0 & 0 \\ + 0 & 0 & 0 \\ + 0 & 0 & 2 +\end{array} \right) +\W{,} +g_1^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 1 & 0 \\ + 1 & 0 & 0 \\ + 0 & 0 & 0 +\end{array} \right) +\] $$ + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreviate as vector +// +class atomic_reverse : public CppAD::atomic_three { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + atomic_reverse(const std::string& name) : + CppAD::atomic_three(name) + { } +private: +/* %$$ +$head for_type$$ +$srccode%cpp% */ + // calculate type_y + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = type_x.size() == 3; // n + ok &= type_y.size() == 2; // m + if( ! ok ) + return false; + type_y[0] = type_x[2]; + type_y[1] = std::max(type_x[0], type_x[1]); + return true; + } +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector& taylor_x , + vector& taylor_y ) + { + size_t q1 = order_up + 1; +# ifndef NDEBUG + size_t n = taylor_x.size() / q1; + size_t m = taylor_y.size() / q1; +# endif + assert( n == 3 ); + assert( m == 2 ); + assert( order_low <= order_up ); + + // this example only implements up to first order forward mode + bool ok = order_up <= 1; + if( ! ok ) + return ok; + + // ------------------------------------------------------------------ + // Zero forward mode. + // This case must always be implemented + // g(x) = [ x_2 * x_2 ] + // [ x_0 * x_1 ] + // y^0 = f( x^0 ) + if( order_low <= 0 ) + { // y_0^0 = x_2^0 * x_2^0 + taylor_y[0*q1+0] = taylor_x[2*q1+0] * taylor_x[2*q1+0]; + // y_1^0 = x_0^0 * x_1^0 + taylor_y[1*q1+0] = taylor_x[0*q1+0] * taylor_x[1*q1+0]; + } + if( order_up <= 0 ) + return ok; + // ------------------------------------------------------------------ + // First order one forward mode. + // This case is needed if first order forward mode is used. + // g'(x) = [ 0, 0, 2 * x_2 ] + // [ x_1, x_0, 0 ] + // y^1 = f'(x^0) * x^1 + if( order_low <= 1 ) + { // y_0^1 = 2 * x_2^0 * x_2^1 + taylor_y[0*q1+1] = 2.0 * taylor_x[2*q1+0] * taylor_x[2*q1+1]; + + // y_1^1 = x_1^0 * x_0^1 + x_0^0 * x_1^1 + taylor_y[1*q1+1] = taylor_x[1*q1+0] * taylor_x[0*q1+1]; + taylor_y[1*q1+1] += taylor_x[0*q1+0] * taylor_x[1*q1+1]; + } + return ok; + } +/* %$$ +$head reverse$$ +$srccode%cpp% */ + // reverse mode routine called by CppAD + virtual bool reverse( + const vector& parameter_x , + const vector& type_x , + size_t order_up , + const vector& taylor_x , + const vector& taylor_y , + vector& partial_x , + const vector& partial_y ) + { + size_t q1 = order_up + 1; + size_t n = taylor_x.size() / q1; +# ifndef NDEBUG + size_t m = taylor_y.size() / q1; +# endif + assert( n == 3 ); + assert( m == 2 ); + + // this example only implements up to second order reverse mode + bool ok = q1 <= 2; + if( ! ok ) + return ok; + // + // initalize summation as zero + for(size_t j = 0; j < n; j++) + for(size_t k = 0; k < q1; k++) + partial_x[j * q1 + k] = 0.0; + // + if( q1 == 2 ) + { // -------------------------------------------------------------- + // Second order reverse first compute partials of first order + // We use the notation pg_ij^k for partial of F_i^1 w.r.t. x_j^k + // + // y_0^1 = 2 * x_2^0 * x_2^1 + // pg_02^0 = 2 * x_2^1 + // pg_02^1 = 2 * x_2^0 + // + // y_1^1 = x_1^0 * x_0^1 + x_0^0 * x_1^1 + // pg_10^0 = x_1^1 + // pg_11^0 = x_0^1 + // pg_10^1 = x_1^0 + // pg_11^1 = x_0^0 + // + // px_0^0 += py_0^1 * pg_00^0 + py_1^1 * pg_10^0 + // += py_1^1 * x_1^1 + partial_x[0*q1+0] += partial_y[1*q1+1] * taylor_x[1*q1+1]; + // + // px_0^1 += py_0^1 * pg_00^1 + py_1^1 * pg_10^1 + // += py_1^1 * x_1^0 + partial_x[0*q1+1] += partial_y[1*q1+1] * taylor_x[1*q1+0]; + // + // px_1^0 += py_0^1 * pg_01^0 + py_1^1 * pg_11^0 + // += py_1^1 * x_0^1 + partial_x[1*q1+0] += partial_y[1*q1+1] * taylor_x[0*q1+1]; + // + // px_1^1 += py_0^1 * pg_01^1 + py_1^1 * pg_11^1 + // += py_1^1 * x_0^0 + partial_x[1*q1+1] += partial_y[1*q1+1] * taylor_x[0*q1+0]; + // + // px_2^0 += py_0^1 * pg_02^0 + py_1^1 * pg_12^0 + // += py_0^1 * 2 * x_2^1 + partial_x[2*q1+0] += partial_y[0*q1+1] * 2.0 * taylor_x[2*q1+1]; + // + // px_2^1 += py_0^1 * pg_02^1 + py_1^1 * pg_12^1 + // += py_0^1 * 2 * x_2^0 + partial_x[2*q1+1] += partial_y[0*q1+1] * 2.0 * taylor_x[2*q1+0]; + } + // -------------------------------------------------------------- + // First order reverse computes partials of zero order coefficients + // We use the notation pg_ij for partial of F_i^0 w.r.t. x_j^0 + // + // y_0^0 = x_2^0 * x_2^0 + // pg_00 = 0, pg_01 = 0, pg_02 = 2 * x_2^0 + // + // y_1^0 = x_0^0 * x_1^0 + // pg_10 = x_1^0, pg_11 = x_0^0, pg_12 = 0 + // + // px_0^0 += py_0^0 * pg_00 + py_1^0 * pg_10 + // += py_1^0 * x_1^0 + partial_x[0*q1+0] += partial_y[1*q1+0] * taylor_x[1*q1+0]; + // + // px_1^0 += py_1^0 * pg_01 + py_1^0 * pg_11 + // += py_1^0 * x_0^0 + partial_x[1*q1+0] += partial_y[1*q1+0] * taylor_x[0*q1+0]; + // + // px_2^0 += py_1^0 * pg_02 + py_1^0 * pg_12 + // += py_0^0 * 2.0 * x_2^0 + partial_x[2*q1+0] += partial_y[0*q1+0] * 2.0 * taylor_x[2*q1+0]; + // -------------------------------------------------------------- + return ok; + } +}; +} // End empty namespace +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool reverse(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // Create the atomic_reverse object corresponding to g(x) + atomic_reverse afun("atomic_reverse"); + // + // Create the function f(u) = g(u) for this example. + // + // domain space vector + size_t n = 3; + double u_0 = 1.00; + double u_1 = 2.00; + double u_2 = 3.00; + vector< AD > au(n); + au[0] = u_0; + au[1] = u_1; + au[2] = u_2; + + // declare independent variables and start tape recording + CppAD::Independent(au); + + // range space vector + size_t m = 2; + vector< AD > ay(m); + + // call atomic function + vector< AD > ax = au; + afun(ax, ay); + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // y = f(u) + // + // check function value + double check = u_2 * u_2; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + check = u_0 * u_1; + ok &= NearEqual( Value(ay[1]) , check, eps, eps); + + // -------------------------------------------------------------------- + // zero order forward + // + vector u0(n), y0(m); + u0[0] = u_0; + u0[1] = u_1; + u0[2] = u_2; + y0 = f.Forward(0, u0); + check = u_2 * u_2; + ok &= NearEqual(y0[0] , check, eps, eps); + check = u_0 * u_1; + ok &= NearEqual(y0[1] , check, eps, eps); + // -------------------------------------------------------------------- + // first order reverse + // + // value of Jacobian of f + double check_jac[] = { + 0.0, 0.0, 2.0 * u_2, + u_1, u_0, 0.0 + }; + vector w(m), dw(n); + // + // check derivative of f_0 (x) + for(size_t i = 0; i < m; i++) + { w[i] = 1.0; + w[1-i] = 0.0; + dw = f.Reverse(1, w); + for(size_t j = 0; j < n; j++) + { // compute partial in j-th component direction + ok &= NearEqual(dw[j], check_jac[i * n + j], eps, eps); + } + } + // -------------------------------------------------------------------- + // second order reverse + // + // value of Hessian of f_0 + double check_hes_0[] = { + 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + 0.0, 0.0, 2.0 + }; + // + // value of Hessian of f_1 + double check_hes_1[] = { + 0.0, 1.0, 0.0, + 1.0, 0.0, 0.0, + 0.0, 0.0, 0.0 + }; + vector u1(n), dw2( 2 * n ); + for(size_t j = 0; j < n; j++) + { for(size_t j1 = 0; j1 < n; j1++) + u1[j1] = 0.0; + u1[j] = 1.0; + // first order forward + f.Forward(1, u1); + w[0] = 1.0; + w[1] = 0.0; + dw2 = f.Reverse(2, w); + for(size_t i = 0; i < n; i++) + ok &= NearEqual(dw2[i * 2 + 1], check_hes_0[i * n + j], eps, eps); + w[0] = 0.0; + w[1] = 1.0; + dw2 = f.Reverse(2, w); + for(size_t i = 0; i < n; i++) + ok &= NearEqual(dw2[i * 2 + 1], check_hes_1[i * n + j], eps, eps); + } + // -------------------------------------------------------------------- + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_three/tangent.cpp cppad-2019.02.00.0/example/atomic_three/tangent.cpp --- cppad-2018.00.00.0/example/atomic_three/tangent.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_three/tangent.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,416 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_three_tangent.cpp$$ +$spell + Tanh + bool +$$ + +$section Tan and Tanh as User Atomic Operations: Example and Test$$ + +$head Discussion$$ +The code below uses the $cref tan_forward$$ and $cref tan_reverse$$ +to implement the tangent and hyperbolic tangent +functions as atomic function operations. +It also uses $code AD$$, +while most atomic examples use $code AD$$. + + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // Begin empty namespace +using CppAD::vector; +// +class atomic_tangent : public CppAD::atomic_three { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +private: + const bool hyperbolic_; // is this hyperbolic tangent +public: + // constructor + atomic_tangent(const char* name, bool hyperbolic) + : CppAD::atomic_three(name), + hyperbolic_(hyperbolic) + { } +private: +/* %$$ +$head for_type$$ +$srccode%cpp% */ + // calculate type_y + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = type_x.size() == 1; // n + ok &= type_y.size() == 2; // m + if( ! ok ) + return false; + type_y[0] = type_x[0]; + type_y[1] = type_x[0]; + return true; + } +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t p , + size_t q , + const vector& tx , + vector& tzy ) + { size_t q1 = q + 1; +# ifndef NDEBUG + size_t n = tx.size() / q1; + size_t m = tzy.size() / q1; +# endif + assert( type_x.size() == n ); + assert( n == 1 ); + assert( m == 2 ); + assert( p <= q ); + size_t j, k; + + if( p == 0 ) + { // z^{(0)} = tan( x^{(0)} ) or tanh( x^{(0)} ) + if( hyperbolic_ ) + tzy[0] = float( tanh( tx[0] ) ); + else + tzy[0] = float( tan( tx[0] ) ); + + // y^{(0)} = z^{(0)} * z^{(0)} + tzy[q1 + 0] = tzy[0] * tzy[0]; + + p++; + } + for(j = p; j <= q; j++) + { float j_inv = 1.f / float(j); + if( hyperbolic_ ) + 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[q1 + j-k] * float(k) * j_inv; + + // y^{(j)} = sum_{k=0}^j z^{(k)} z^{(j-k)} + tzy[q1 + j] = 0.; + for(k = 0; k <= j; k++) + tzy[q1 + j] += tzy[k] * tzy[j-k]; + } + + // All orders are implemented and there are no possible errors + return true; + } +/* %$$ +$head reverse$$ +$srccode%cpp% */ + // reverse mode routine called by CppAD + virtual bool reverse( + const vector& parameter_x , + const vector& type_x , + size_t q , + const vector& tx , + const vector& tzy , + vector& px , + const vector& pzy ) + { size_t q1 = q + 1; +# ifndef NDEBUG + size_t n = tx.size() / q1; + size_t m = tzy.size() / q1; +# endif + assert( px.size() == n * q1 ); + assert( pzy.size() == m * q1 ); + assert( n == 1 ); + assert( m == 2 ); + + 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 < q1; k++) + px[k] = 0.; + + // eliminate positive orders + for(j = q; j > 0; j--) + { float j_inv = 1.f / float(j); + if( hyperbolic_ ) + 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[q1 + j-k] * float(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] * float(k) * j_inv; + + // 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; + } + + // eliminate order zero + if( hyperbolic_ ) + px[0] += qzy[0] * (1.f - tzy[q1 + 0]); + else + px[0] += qzy[0] * (1.f + tzy[q1 + 0]); + + return true; + } +/* %$$ +$head jac_sparsity$$ +$srccode%cpp% */ + // Jacobian sparsity routine called by CppAD + virtual bool jac_sparsity( + const vector& parameter_x , + const vector& type_x , + bool dependency , + const vector& select_x , + const vector& select_y , + CppAD::sparse_rc< vector >& pattern_out ) + { + size_t n = select_x.size(); + size_t m = select_y.size(); + assert( parameter_x.size() == n ); + assert( n == 1 ); + assert( m == 2 ); + + // number of non-zeros in sparsity pattern + size_t nnz = 0; + if( select_x[0] ) + { if( select_y[0] ) + ++nnz; + if( select_y[1] ) + ++nnz; + } + + // sparsity pattern + pattern_out.resize(m, n, nnz); + size_t k = 0; + if( select_x[0] ) + { if( select_y[0] ) + pattern_out.set(k++, 0, 0); + if( select_y[1] ) + pattern_out.set(k++, 1, 0); + } + assert( k == nnz ); + + return true; + } +/* %$$ +$head hes_sparsity$$ +$srccode%cpp% */ + // Hessian sparsity routine called by CppAD + virtual bool hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const vector& select_x , + const vector& select_y , + CppAD::sparse_rc< vector >& pattern_out ) + { + assert( parameter_x.size() == select_x.size() ); + assert( select_y.size() == 2 ); + size_t n = select_x.size(); + assert( n == 1 ); + + // number of non-zeros in sparsity pattern + size_t nnz = 0; + if( select_x[0] & (select_y[0] | select_y[1]) ) + nnz = 1; + // sparsity pattern + pattern_out.resize(n, n, nnz); + if( select_x[0] & (select_y[0] | select_y[1]) ) + pattern_out.set(0, 0, 0); + + return true; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_tangent class +} // End empty namespace + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool tangent(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + float eps = 10.f * CppAD::numeric_limits::epsilon(); +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // -------------------------------------------------------------------- + // Creater a tan and tanh object + atomic_tangent my_tan("my_tan", false), my_tanh("my_tanh", true); +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + // 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 > av(m); + + // temporary vector for computations + // (my_tan and my_tanh computes tan or tanh and its square) + CppAD::vector< AD > au(2); + + // call atomic tan function and store tan(x) in f[0], ignore tan(x)^2 + my_tan(ax, au); + av[0] = au[0]; + + // call atomic tanh function and store tanh(x) in f[1], ignore tanh(x)^2 + my_tanh(ax, au); + av[1] = au[0]; + + // put a constant in f[2] = tanh(1.), for sparsity pattern testing + CppAD::vector< AD > one(1); + one[0] = 1.; + my_tanh(one, au); + av[2] = au[0]; + + // create f: x -> v and stop tape recording + CppAD::ADFun f; + f.Dependent(ax, av); +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // check function value + float tan = std::tan(x0); + ok &= NearEqual(av[0] , tan, eps, eps); + float tanh = std::tanh(x0); + ok &= NearEqual(av[1] , tanh, eps, eps); + + // check zero order forward + CppAD::vector x(n), v(m); + x[0] = x0; + v = f.Forward(0, x); + ok &= NearEqual(v[0] , tan, eps, eps); + ok &= NearEqual(v[1] , tanh, eps, eps); + + // 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; + + // compute first partial of f w.r.t. x[0] using forward mode + CppAD::vector dx(n), dv(m); + dx[0] = 1.; + dv = f.Forward(1, dx); + ok &= NearEqual(dv[0] , tanp, eps, eps); + ok &= NearEqual(dv[1] , tanhp, eps, eps); + ok &= NearEqual(dv[2] , 0.f, eps, eps); + + // 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; + + // compute second partial of f w.r.t. x[0] using forward mode + CppAD::vector ddx(n), ddv(m); + ddx[0] = 0.; + ddv = f.Forward(2, ddx); + ok &= NearEqual(two * ddv[0], tanpp, eps, eps); + ok &= NearEqual(two * ddv[1], tanhpp, eps, eps); + ok &= NearEqual(two * ddv[2], 0.f, eps, eps); + +/* %$$ +$subhead reverse$$ +$srccode%cpp% */ + // 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); + ok &= NearEqual(dw[0], w[0]*tanp + w[1]*tanhp, eps, eps); + + // compute second derivative of tan - tanh using reverse mode + CppAD::vector ddw(2); + ddw = f.Reverse(2, w); + ok &= NearEqual(ddw[0], w[0]*tanp + w[1]*tanhp , eps, eps); + ok &= NearEqual(ddw[1], w[0]*tanpp + w[1]*tanhpp, eps, eps); +/* %$$ +$subhead for_jac_sparsity$$ +$srccode%cpp% */ + // forward mode Jacobian sparstiy pattern + CppAD::sparse_rc< CPPAD_TESTVECTOR(size_t) > pattern_in, pattern_out; + pattern_in.resize(1, 1, 1); + pattern_in.set(0, 0, 0); + bool transpose = false; + bool dependency = false; + bool internal_bool = false; + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + // (0, 0) and (1, 0) are in sparsity pattern + ok &= pattern_out.nnz() == 2; + ok &= pattern_out.row()[0] == 0; + ok &= pattern_out.col()[0] == 0; + ok &= pattern_out.row()[1] == 1; + ok &= pattern_out.col()[1] == 0; +/* %$$ +$subhead rev_sparse_hes$$ +$srccode%cpp% */ + // Hesian sparsity (using previous for_jac_sparsity call) + CPPAD_TESTVECTOR(bool) select_y(m); + select_y[0] = true; + select_y[1] = false; + select_y[2] = false; + f.rev_hes_sparsity( + select_y, transpose, internal_bool, pattern_out + ); + ok &= pattern_out.nnz() == 1; + ok &= pattern_out.row()[0] == 0; + ok &= pattern_out.col()[0] == 0; +/* %$$ +$subhead Large x Values$$ +$srccode%cpp% */ + // check tanh results for a large value of x + x[0] = std::numeric_limits::max() / two; + v = f.Forward(0, x); + tanh = 1.; + ok &= NearEqual(v[1], tanh, eps, eps); + dv = f.Forward(1, dx); + tanhp = 0.; + ok &= NearEqual(dv[1], tanhp, eps, eps); + + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_two/atomic_two.cpp cppad-2019.02.00.0/example/atomic_two/atomic_two.cpp --- cppad-2018.00.00.0/example/atomic_two/atomic_two.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_two/atomic_two.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,53 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// CPPAD_HAS_* defines +# include + +// system include files used for I/O +# include + +// C style asserts +# include + +// for thread_alloc +# include + +// test runner +# include + +// external complied tests +extern bool eigen_cholesky(void); +extern bool eigen_mat_inv(void); +extern bool eigen_mat_mul(void); + +// main program that runs all the tests +int main(void) +{ std::string group = "example/atomic_two"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + // external compiled tests +# if CPPAD_HAS_EIGEN + Run( eigen_cholesky, "eigen_cholesky" ); + Run( eigen_mat_inv, "eigen_mat_inv" ); + Run( eigen_mat_mul, "eigen_mat_mul" ); +# endif + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); +} diff -Nru cppad-2018.00.00.0/example/atomic_two/CMakeLists.txt cppad-2019.02.00.0/example/atomic_two/CMakeLists.txt --- cppad-2018.00.00.0/example/atomic_two/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_two/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,37 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# +# eigen_sources and CPPAD_HAS_EIGEN +IF( cppad_has_eigen ) + SET(eigen_sources eigen_mat_inv.cpp eigen_cholesky.cpp eigen_mat_mul.cpp) +ELSE( cppad_has_eigen ) + SET(eigen_sources "") +ENDIF( cppad_has_eigen ) +# +SET(source_list + ${eigen_sources} + atomic_two.cpp +) +set_compile_flags( example_atomic_two "${cppad_debug_which}" "${source_list}" ) +# +ADD_EXECUTABLE(example_atomic_two EXCLUDE_FROM_ALL ${source_list}) +# +# Add the check_example_atomic_two target +ADD_CUSTOM_TARGET(check_example_atomic_two + example_atomic_two + DEPENDS example_atomic_two +) +MESSAGE(STATUS "make check_example_atomic_two: available") +# +# add to check check_example_depends in parent environment +add_to_list(check_example_depends check_example_atomic_two) +SET(check_example_depends "${check_example_depends}" PARENT_SCOPE) diff -Nru cppad-2018.00.00.0/example/atomic_two/eigen_cholesky.cpp cppad-2019.02.00.0/example/atomic_two/eigen_cholesky.cpp --- cppad-2018.00.00.0/example/atomic_two/eigen_cholesky.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_two/eigen_cholesky.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,238 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_two_eigen_cholesky.cpp$$ +$spell + Eigen + Cholesky +$$ + +$section Atomic Eigen Cholesky Factorization: Example and Test$$ + +$head Description$$ +The $cref ADFun$$ function object $icode f$$ for this example is +$latex \[ +f(x) += +\R{chol} \left( \begin{array}{cc} + x_0 & x_1 \\ + x_1 & x_2 +\end{array} \right) += +\frac{1}{ \sqrt{x_0} } +\left( \begin{array}{cc} + x_0 & 0 \\ + x_1 & \sqrt{ x_0 x_2 - x_1 x_1 } +\end{array} \right) +\] $$ +where the matrix is positive definite; i.e., +$latex x_0 > 0$$, $latex x_2 > 0$$ and +$latex x_0 x_2 - x_1 x_1 > 0$$. + +$childtable%omh/theory/cholesky.omh + %include/cppad/example/eigen_cholesky.hpp +%$$ + +$head Use Atomic Function$$ +$srccode%cpp% */ +# include +# include + + +bool eigen_cholesky(void) +{ + typedef double scalar; + typedef atomic_eigen_cholesky::ad_scalar ad_scalar; + typedef atomic_eigen_cholesky::ad_matrix ad_matrix; + // + bool ok = true; + scalar eps = 10. * std::numeric_limits::epsilon(); + using CppAD::NearEqual; + // +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // ------------------------------------------------------------------- + // object that computes cholesky factor of a matrix + atomic_eigen_cholesky cholesky; + // ------------------------------------------------------------------- + // declare independent variable vector x + size_t n = 3; + CPPAD_TESTVECTOR(ad_scalar) ad_x(n); + ad_x[0] = 2.0; + ad_x[1] = 0.5; + ad_x[2] = 3.0; + CppAD::Independent(ad_x); + // ------------------------------------------------------------------- + // A = [ x[0] x[1] ] + // [ x[1] x[2] ] + size_t nr = 2; + ad_matrix ad_A(nr, nr); + ad_A(0, 0) = ad_x[0]; + ad_A(1, 0) = ad_x[1]; + ad_A(0, 1) = ad_x[1]; + ad_A(1, 1) = ad_x[2]; + // ------------------------------------------------------------------- + // use atomic operation to L such that A = L * L^T + ad_matrix ad_L = cholesky.op(ad_A); + // ------------------------------------------------------------------- + // declare the dependent variable vector y + size_t m = 3; + CPPAD_TESTVECTOR(ad_scalar) ad_y(m); + ad_y[0] = ad_L(0, 0); + ad_y[1] = ad_L(1, 0); + ad_y[2] = ad_L(1, 1); + CppAD::ADFun f(ad_x, ad_y); + // ------------------------------------------------------------------- + // check zero order forward mode + CPPAD_TESTVECTOR(scalar) x(n), y(m); + x[0] = 2.0; + x[1] = 0.5; + x[2] = 5.0; + y = f.Forward(0, x); + scalar check; + check = std::sqrt( x[0] ); + ok &= NearEqual(y[0], check, eps, eps); + check = x[1] / std::sqrt( x[0] ); + ok &= NearEqual(y[1], check, eps, eps); + check = std::sqrt( x[2] - x[1] * x[1] / x[0] ); + ok &= NearEqual(y[2], check, eps, eps); + // ------------------------------------------------------------------- + // check first order forward mode + CPPAD_TESTVECTOR(scalar) x1(n), y1(m); + // + // partial w.r.t. x[0] + x1[0] = 1.0; + x1[1] = 0.0; + x1[2] = 0.0; + // + y1 = f.Forward(1, x1); + check = 1.0 / (2.0 * std::sqrt( x[0] ) ); + ok &= NearEqual(y1[0], check, eps, eps); + // + check = - x[1] / (2.0 * x[0] * std::sqrt( x[0] ) ); + ok &= NearEqual(y1[1], check, eps, eps); + // + check = std::sqrt( x[2] - x[1] * x[1] / x[0] ); + check = x[1] * x[1] / (x[0] * x[0] * 2.0 * check); + ok &= NearEqual(y1[2], check, eps, eps); + // + // partial w.r.t. x[1] + x1[0] = 0.0; + x1[1] = 1.0; + x1[2] = 0.0; + // + y1 = f.Forward(1, x1); + ok &= NearEqual(y1[0], 0.0, eps, eps); + // + check = 1.0 / std::sqrt( x[0] ); + ok &= NearEqual(y1[1], check, eps, eps); + // + check = std::sqrt( x[2] - x[1] * x[1] / x[0] ); + check = - 2.0 * x[1] / (2.0 * check * x[0] ); + ok &= NearEqual(y1[2], check, eps, eps); + // + // partial w.r.t. x[2] + x1[0] = 0.0; + x1[1] = 0.0; + x1[2] = 1.0; + // + y1 = f.Forward(1, x1); + ok &= NearEqual(y1[0], 0.0, eps, eps); + ok &= NearEqual(y1[1], 0.0, eps, eps); + // + check = std::sqrt( x[2] - x[1] * x[1] / x[0] ); + check = 1.0 / (2.0 * check); + ok &= NearEqual(y1[2], check, eps, eps); + // ------------------------------------------------------------------- + // check second order forward mode + CPPAD_TESTVECTOR(scalar) x2(n), y2(m); + // + // second partial w.r.t x[2] + x2[0] = 0.0; + x2[1] = 0.0; + x2[2] = 0.0; + y2 = f.Forward(2, x2); + ok &= NearEqual(y2[0], 0.0, eps, eps); + ok &= NearEqual(y2[1], 0.0, eps, eps); + // + check = std::sqrt( x[2] - x[1] * x[1] / x[0] ); // funciton value + check = - 1.0 / ( 4.0 * check * check * check ); // second derivative + check = 0.5 * check; // taylor coefficient + ok &= NearEqual(y2[2], check, eps, eps); + // ------------------------------------------------------------------- + // check first order reverse mode + CPPAD_TESTVECTOR(scalar) w(m), d1w(n); + w[0] = 0.0; + w[1] = 0.0; + w[2] = 1.0; + d1w = f.Reverse(1, w); + // + // partial of f[2] w.r.t x[0] + scalar f2 = std::sqrt( x[2] - x[1] * x[1] / x[0] ); + scalar f2_x0 = x[1] * x[1] / (2.0 * f2 * x[0] * x[0] ); + ok &= NearEqual(d1w[0], f2_x0, eps, eps); + // + // partial of f[2] w.r.t x[1] + scalar f2_x1 = - x[1] / (f2 * x[0] ); + ok &= NearEqual(d1w[1], f2_x1, eps, eps); + // + // partial of f[2] w.r.t x[2] + scalar f2_x2 = 1.0 / (2.0 * f2 ); + ok &= NearEqual(d1w[2], f2_x2, eps, eps); + // ------------------------------------------------------------------- + // check second order reverse mode + CPPAD_TESTVECTOR(scalar) d2w(2 * n); + d2w = f.Reverse(2, w); + // + // check first order results + ok &= NearEqual(d2w[0 * 2 + 0], f2_x0, eps, eps); + ok &= NearEqual(d2w[1 * 2 + 0], f2_x1, eps, eps); + ok &= NearEqual(d2w[2 * 2 + 0], f2_x2, eps, eps); + // + // check second order results + scalar f2_x2_x0 = - 0.5 * f2_x0 / (f2 * f2 ); + ok &= NearEqual(d2w[0 * 2 + 1], f2_x2_x0, eps, eps); + scalar f2_x2_x1 = - 0.5 * f2_x1 / (f2 * f2 ); + ok &= NearEqual(d2w[1 * 2 + 1], f2_x2_x1, eps, eps); + scalar f2_x2_x2 = - 0.5 * f2_x2 / (f2 * f2 ); + ok &= NearEqual(d2w[2 * 2 + 1], f2_x2_x2, eps, eps); + // ------------------------------------------------------------------- + // check third order reverse mode + CPPAD_TESTVECTOR(scalar) d3w(3 * n); + d3w = f.Reverse(3, w); + // + // check first order results + ok &= NearEqual(d3w[0 * 3 + 0], f2_x0, eps, eps); + ok &= NearEqual(d3w[1 * 3 + 0], f2_x1, eps, eps); + ok &= NearEqual(d3w[2 * 3 + 0], f2_x2, eps, eps); + // + // check second order results + ok &= NearEqual(d3w[0 * 3 + 1], f2_x2_x0, eps, eps); + ok &= NearEqual(d3w[1 * 3 + 1], f2_x2_x1, eps, eps); + ok &= NearEqual(d3w[2 * 3 + 1], f2_x2_x2, eps, eps); + // ------------------------------------------------------------------- + scalar f2_x2_x2_x0 = - 0.5 * f2_x2_x0 / (f2 * f2); + f2_x2_x2_x0 += f2_x2 * f2_x0 / (f2 * f2 * f2); + ok &= NearEqual(d3w[0 * 3 + 2], 0.5 * f2_x2_x2_x0, eps, eps); + scalar f2_x2_x2_x1 = - 0.5 * f2_x2_x1 / (f2 * f2); + f2_x2_x2_x1 += f2_x2 * f2_x1 / (f2 * f2 * f2); + ok &= NearEqual(d3w[1 * 3 + 2], 0.5 * f2_x2_x2_x1, eps, eps); + scalar f2_x2_x2_x2 = - 0.5 * f2_x2_x2 / (f2 * f2); + f2_x2_x2_x2 += f2_x2 * f2_x2 / (f2 * f2 * f2); + ok &= NearEqual(d3w[2 * 3 + 2], 0.5 * f2_x2_x2_x2, eps, eps); + return ok; +} +/* %$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_two/eigen_mat_inv.cpp cppad-2019.02.00.0/example/atomic_two/eigen_mat_inv.cpp --- cppad-2018.00.00.0/example/atomic_two/eigen_mat_inv.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_two/eigen_mat_inv.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,187 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_two_eigen_mat_inv.cpp$$ +$spell + mul + Eigen +$$ + +$section Atomic Eigen Matrix Inverse: Example and Test$$ + +$head Description$$ +The $cref ADFun$$ function object $icode f$$ for this example is +$latex \[ +f(x) = +\left( \begin{array}{cc} + x_0 & 0 \\ + 0 & x_1 +\end{array} \right)^{-1} +\left( \begin{array}{c} + 0 \\ + x_2 +\end{array} \right) += +\left( \begin{array}{c} + 0 \\ + x_2 / x_1 ) +\end{array} \right) +\] $$ + +$children% + include/cppad/example/eigen_mat_inv.hpp +%$$ + +$head Class Definition$$ +This example uses the file $cref atomic_eigen_mat_inv.hpp$$ +which defines matrix multiply as a $cref atomic_two$$ operation. + +$nospell + +$head Use Atomic Function$$ +$srccode%cpp% */ +# include +# include +# include + + +bool eigen_mat_inv(void) +{ + typedef double scalar; + typedef CppAD::AD ad_scalar; + typedef atomic_eigen_mat_inv::ad_matrix ad_matrix; + // + bool ok = true; + scalar eps = 10. * std::numeric_limits::epsilon(); + using CppAD::NearEqual; + // +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // ------------------------------------------------------------------- + // object that multiplies matrices + atomic_eigen_mat_mul mat_mul; + // ------------------------------------------------------------------- + // object that computes inverse of a square matrix + atomic_eigen_mat_inv mat_inv; + // ------------------------------------------------------------------- + // declare independent variable vector x + size_t n = 3; + CPPAD_TESTVECTOR(ad_scalar) ad_x(n); + for(size_t j = 0; j < n; j++) + ad_x[j] = ad_scalar(j + 1); + CppAD::Independent(ad_x); + // ------------------------------------------------------------------- + // left = [ x[0] 0 ] + // [ 0 x[1] ] + size_t nr_left = 2; + ad_matrix ad_left(nr_left, nr_left); + ad_left(0, 0) = ad_x[0]; + ad_left(0, 1) = ad_scalar(0.0); + ad_left(1, 0) = ad_scalar(0.0); + ad_left(1, 1) = ad_x[1]; + // ------------------------------------------------------------------- + // right = [ 0 , x[2] ]^T + size_t nc_right = 1; + ad_matrix ad_right(nr_left, nc_right); + ad_right(0, 0) = ad_scalar(0.0); + ad_right(1, 0) = ad_x[2]; + // ------------------------------------------------------------------- + // use atomic operation to compute left^{-1} + ad_matrix ad_left_inv = mat_inv.op(ad_left); + // use atomic operation to multiply left^{-1} * right + ad_matrix ad_result = mat_mul.op(ad_left_inv, ad_right); + // ------------------------------------------------------------------- + // declare the dependent variable vector y + size_t m = 2; + CPPAD_TESTVECTOR(ad_scalar) ad_y(2); + for(size_t i = 0; i < m; i++) + ad_y[i] = ad_result( long(i), 0); + CppAD::ADFun f(ad_x, ad_y); + // ------------------------------------------------------------------- + // check zero order forward mode + CPPAD_TESTVECTOR(scalar) x(n), y(m); + for(size_t i = 0; i < n; i++) + x[i] = scalar(i + 2); + y = f.Forward(0, x); + ok &= NearEqual(y[0], 0.0, eps, eps); + ok &= NearEqual(y[1], x[2] / x[1], eps, eps); + // ------------------------------------------------------------------- + // check first order forward mode + CPPAD_TESTVECTOR(scalar) x1(n), y1(m); + x1[0] = 1.0; + x1[1] = 0.0; + x1[2] = 0.0; + y1 = f.Forward(1, x1); + ok &= NearEqual(y1[0], 0.0, eps, eps); + ok &= NearEqual(y1[1], 0.0, eps, eps); + x1[0] = 0.0; + x1[1] = 0.0; + x1[2] = 1.0; + y1 = f.Forward(1, x1); + ok &= NearEqual(y1[0], 0.0, eps, eps); + ok &= NearEqual(y1[1], 1.0 / x[1], eps, eps); + x1[0] = 0.0; + x1[1] = 1.0; + x1[2] = 0.0; + y1 = f.Forward(1, x1); + ok &= NearEqual(y1[0], 0.0, eps, eps); + ok &= NearEqual(y1[1], - x[2] / (x[1]*x[1]), eps, eps); + // ------------------------------------------------------------------- + // check second order forward mode + CPPAD_TESTVECTOR(scalar) x2(n), y2(m); + x2[0] = 0.0; + x2[1] = 0.0; + x2[2] = 0.0; + scalar f1_x1_x1 = 2.0 * x[2] / (x[1] * x[1] * x[1] ); + y2 = f.Forward(2, x2); + ok &= NearEqual(y2[0], 0.0, eps, eps); + ok &= NearEqual(y2[1], f1_x1_x1 / 2.0, eps, eps); + // ------------------------------------------------------------------- + // check first order reverse + CPPAD_TESTVECTOR(scalar) w(m), d1w(n); + w[0] = 1.0; + w[1] = 0.0; + d1w = f.Reverse(1, w); + ok &= NearEqual(d1w[0], 0.0, eps, eps); + ok &= NearEqual(d1w[1], 0.0, eps, eps); + ok &= NearEqual(d1w[2], 0.0, eps, eps); + w[0] = 0.0; + w[1] = 1.0; + d1w = f.Reverse(1, w); + ok &= NearEqual(d1w[0], 0.0, eps, eps); + ok &= NearEqual(d1w[1], - x[2] / (x[1]*x[1]), eps, eps); + ok &= NearEqual(d1w[2], 1.0 / x[1], eps, eps); + // ------------------------------------------------------------------- + // check second order reverse + CPPAD_TESTVECTOR(scalar) d2w(2 * n); + d2w = f.Reverse(2, w); + // partial f_1 w.r.t x_0 + ok &= NearEqual(d2w[0 * 2 + 0], 0.0, eps, eps); + // partial f_1 w.r.t x_1 + ok &= NearEqual(d2w[1 * 2 + 0], - x[2] / (x[1]*x[1]), eps, eps); + // partial f_1 w.r.t x_2 + ok &= NearEqual(d2w[2 * 2 + 0], 1.0 / x[1], eps, eps); + // partial f_1 w.r.t x_1, x_0 + ok &= NearEqual(d2w[0 * 2 + 1], 0.0, eps, eps); + // partial f_1 w.r.t x_1, x_1 + ok &= NearEqual(d2w[1 * 2 + 1], f1_x1_x1, eps, eps); + // partial f_1 w.r.t x_1, x_2 + ok &= NearEqual(d2w[2 * 2 + 1], - 1.0 / (x[1]*x[1]), eps, eps); + // ------------------------------------------------------------------- + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_two/eigen_mat_mul.cpp cppad-2019.02.00.0/example/atomic_two/eigen_mat_mul.cpp --- cppad-2018.00.00.0/example/atomic_two/eigen_mat_mul.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_two/eigen_mat_mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,233 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_two_eigen_mat_mul.cpp$$ +$spell + mul + Eigen +$$ + +$section Atomic Eigen Matrix Multiply: Example and Test$$ + +$head Description$$ +The $cref ADFun$$ function object $icode f$$ for this example is +$latex \[ +f(x) = +\left( \begin{array}{cc} + 0 & 0 \\ + 1 & 2 \\ + x_0 & x_1 +\end{array} \right) +\left( \begin{array}{c} + x_0 \\ + x_1 +\end{array} \right) += +\left( \begin{array}{c} + 0 \\ + x_0 + 2 x_1 \\ + x_0 x_0 + x_1 x_1 ) +\end{array} \right) +\] $$ + +$children% + include/cppad/example/eigen_mat_mul.hpp +%$$ + +$head Class Definition$$ +This example uses the file $cref atomic_eigen_mat_mul.hpp$$ +which defines matrix multiply as a $cref atomic_two$$ operation. + +$nospell + +$head Use Atomic Function$$ +$srccode%cpp% */ +# include +# include + +bool eigen_mat_mul(void) +{ // + typedef double scalar; + typedef CppAD::AD ad_scalar; + typedef atomic_eigen_mat_mul::ad_matrix ad_matrix; + // + bool ok = true; + scalar eps = 10. * std::numeric_limits::epsilon(); + using CppAD::NearEqual; + // +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // ------------------------------------------------------------------- + // object that multiplies arbitrary matrices + atomic_eigen_mat_mul mat_mul; + // ------------------------------------------------------------------- + // declare independent variable vector x + size_t n = 2; + CPPAD_TESTVECTOR(ad_scalar) ad_x(n); + for(size_t j = 0; j < n; j++) + ad_x[j] = ad_scalar(j); + CppAD::Independent(ad_x); + // ------------------------------------------------------------------- + // [ 0 0 ] + // left = [ 1 2 ] + // [ x[0] x[1] ] + size_t nr_left = 3; + size_t n_middle = 2; + ad_matrix ad_left(nr_left, n_middle); + ad_left(0, 0) = ad_scalar(0.0); + ad_left(0, 1) = ad_scalar(0.0); + ad_left(1, 0) = ad_scalar(1.0); + ad_left(1, 1) = ad_scalar(2.0); + ad_left(2, 0) = ad_x[0]; + ad_left(2, 1) = ad_x[1]; + // ------------------------------------------------------------------- + // right = [ x[0] , x[1] ]^T + size_t nc_right = 1; + ad_matrix ad_right(n_middle, nc_right); + ad_right(0, 0) = ad_x[0]; + ad_right(1, 0) = ad_x[1]; + // ------------------------------------------------------------------- + // use atomic operation to multiply left * right + ad_matrix ad_result = mat_mul.op(ad_left, ad_right); + // ------------------------------------------------------------------- + // check that first component of result is a parameter + // and the other components are varaibles. + ok &= Parameter( ad_result(0, 0) ); + ok &= Variable( ad_result(1, 0) ); + ok &= Variable( ad_result(2, 0) ); + // ------------------------------------------------------------------- + // declare the dependent variable vector y + size_t m = 3; + CPPAD_TESTVECTOR(ad_scalar) ad_y(m); + for(size_t i = 0; i < m; i++) + ad_y[i] = ad_result(long(i), 0); + CppAD::ADFun f(ad_x, ad_y); + // ------------------------------------------------------------------- + // check zero order forward mode + CPPAD_TESTVECTOR(scalar) x(n), y(m); + for(size_t i = 0; i < n; i++) + x[i] = scalar(i + 2); + y = f.Forward(0, x); + ok &= NearEqual(y[0], 0.0, eps, eps); + ok &= NearEqual(y[1], x[0] + 2.0 * x[1], eps, eps); + ok &= NearEqual(y[2], x[0] * x[0] + x[1] * x[1], eps, eps); + // ------------------------------------------------------------------- + // check first order forward mode + CPPAD_TESTVECTOR(scalar) x1(n), y1(m); + x1[0] = 1.0; + x1[1] = 0.0; + y1 = f.Forward(1, x1); + ok &= NearEqual(y1[0], 0.0, eps, eps); + ok &= NearEqual(y1[1], 1.0, eps, eps); + ok &= NearEqual(y1[2], 2.0 * x[0], eps, eps); + x1[0] = 0.0; + x1[1] = 1.0; + y1 = f.Forward(1, x1); + ok &= NearEqual(y1[0], 0.0, eps, eps); + ok &= NearEqual(y1[1], 2.0, eps, eps); + ok &= NearEqual(y1[2], 2.0 * x[1], eps, eps); + // ------------------------------------------------------------------- + // check second order forward mode + CPPAD_TESTVECTOR(scalar) x2(n), y2(m); + x2[0] = 0.0; + x2[1] = 0.0; + y2 = f.Forward(2, x2); + ok &= NearEqual(y2[0], 0.0, eps, eps); + ok &= NearEqual(y2[1], 0.0, eps, eps); + ok &= NearEqual(y2[2], 1.0, eps, eps); // 1/2 * f_1''(x) + // ------------------------------------------------------------------- + // check first order reverse mode + CPPAD_TESTVECTOR(scalar) w(m), d1w(n); + w[0] = 0.0; + w[1] = 1.0; + w[2] = 0.0; + d1w = f.Reverse(1, w); + ok &= NearEqual(d1w[0], 1.0, eps, eps); + ok &= NearEqual(d1w[1], 2.0, eps, eps); + w[0] = 0.0; + w[1] = 0.0; + w[2] = 1.0; + d1w = f.Reverse(1, w); + ok &= NearEqual(d1w[0], 2.0 * x[0], eps, eps); + ok &= NearEqual(d1w[1], 2.0 * x[1], eps, eps); + // ------------------------------------------------------------------- + // check second order reverse mode + CPPAD_TESTVECTOR(scalar) d2w(2 * n); + d2w = f.Reverse(2, w); + // partial f_2 w.r.t. x_0 + ok &= NearEqual(d2w[0 * 2 + 0], 2.0 * x[0], eps, eps); + // partial f_2 w.r.t x_1 + ok &= NearEqual(d2w[1 * 2 + 0], 2.0 * x[1], eps, eps); + // partial f_2 w.r.t x_1, x_0 + ok &= NearEqual(d2w[0 * 2 + 1], 0.0, eps, eps); + // partial f_2 w.r.t x_1, x_1 + ok &= NearEqual(d2w[1 * 2 + 1], 2.0, eps, eps); + // ------------------------------------------------------------------- + // check forward Jacobian sparsity + CPPAD_TESTVECTOR( std::set ) r(n), s(m); + std::set check_set; + for(size_t j = 0; j < n; j++) + r[j].insert(j); + s = f.ForSparseJac(n, r); + check_set.clear(); + ok &= s[0] == check_set; + check_set.insert(0); + check_set.insert(1); + ok &= s[1] == check_set; + ok &= s[2] == check_set; + // ------------------------------------------------------------------- + // check reverse Jacobian sparsity + r.resize(m); + for(size_t i = 0; i < m; i++) + r[i].insert(i); + s = f.RevSparseJac(m, r); + check_set.clear(); + ok &= s[0] == check_set; + check_set.insert(0); + check_set.insert(1); + ok &= s[1] == check_set; + ok &= s[2] == check_set; + // ------------------------------------------------------------------- + // check forward Hessian sparsity for f_2 (x) + CPPAD_TESTVECTOR( std::set ) r2(1), s2(1), h(n); + for(size_t j = 0; j < n; j++) + r2[0].insert(j); + s2[0].clear(); + s2[0].insert(2); + h = f.ForSparseHes(r2, s2); + check_set.clear(); + check_set.insert(0); + ok &= h[0] == check_set; + check_set.clear(); + check_set.insert(1); + ok &= h[1] == check_set; + // ------------------------------------------------------------------- + // check reverse Hessian sparsity for f_2 (x) + CPPAD_TESTVECTOR( std::set ) s3(1); + s3[0].clear(); + s3[0].insert(2); + h = f.RevSparseHes(n, s3); + check_set.clear(); + check_set.insert(0); + ok &= h[0] == check_set; + check_set.clear(); + check_set.insert(1); + ok &= h[1] == check_set; + // ------------------------------------------------------------------- + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/example/atomic_two/makefile.am cppad-2019.02.00.0/example/atomic_two/makefile.am --- cppad-2018.00.00.0/example/atomic_two/makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_two/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,39 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# automake input file +# +# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp +DEFS = +# +if CppAD_EIGEN +EIGEN_SRC_FILES = eigen_cholesky.cpp eigen_mat_inv.cpp eigen_mat_mul.cpp +else +EIGEN_EXTEA_FILES = eigen_cholesky.cpp eigen_mat_inv.cpp eigen_mat_mul.cpp +EIGEN_SRC_FILES = +endif +# +# +check_PROGRAMS = atomic +# +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) +# +# +atomic_SOURCES = \ + $(EIGEN_SRC_FILES) \ + atomic_two.cpp + +test: check + ./atomic diff -Nru cppad-2018.00.00.0/example/atomic_two/makefile.in cppad-2019.02.00.0/example/atomic_two/makefile.in --- cppad-2018.00.00.0/example/atomic_two/makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/atomic_two/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,634 @@ +# makefile.in generated by automake 1.15.1 from makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2017 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +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 \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +check_PROGRAMS = atomic$(EXEEXT) +subdir = example/atomic_two +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_SOURCES_DIST = eigen_cholesky.cpp eigen_mat_inv.cpp \ + eigen_mat_mul.cpp atomic_two.cpp +@CppAD_EIGEN_TRUE@am__objects_1 = eigen_cholesky.$(OBJEXT) \ +@CppAD_EIGEN_TRUE@ eigen_mat_inv.$(OBJEXT) \ +@CppAD_EIGEN_TRUE@ eigen_mat_mul.$(OBJEXT) +am_atomic_OBJECTS = $(am__objects_1) atomic_two.$(OBJEXT) +atomic_OBJECTS = $(am_atomic_OBJECTS) +atomic_LDADD = $(LDADD) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(atomic_SOURCES) +DIST_SOURCES = $(am__atomic_SOURCES_DIST) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + 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@ +ACLOCAL = @ACLOCAL@ +ADOLC_DIR = @ADOLC_DIR@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BOOST_DIR = @BOOST_DIR@ +BOOST_INCLUDE = @BOOST_INCLUDE@ +BTHREAD_LIB = @BTHREAD_LIB@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPAD_IPOPT_LD_PATH = @CPPAD_IPOPT_LD_PATH@ +CPPAD_IPOPT_LIBS = @CPPAD_IPOPT_LIBS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXX_FLAGS@ +CYGPATH_W = @CYGPATH_W@ + +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# automake input file +# +# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp +DEFS = +DEPDIR = @DEPDIR@ +DL_LIB = @DL_LIB@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EIGEN_DIR = @EIGEN_DIR@ +EIGEN_INCLUDE = @EIGEN_INCLUDE@ +EXEEXT = @EXEEXT@ +FADBAD_DIR = @FADBAD_DIR@ +FC = @FC@ +FCFLAGS = @FCFLAGS@ +FCLIBS = @FCLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +IPOPT_DIR = @IPOPT_DIR@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAX_NUM_THREADS = @MAX_NUM_THREADS@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +OPENMP_FLAGS = @OPENMP_FLAGS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSTFIX_DIR = @POSTFIX_DIR@ +PTHREAD_LIB = @PTHREAD_LIB@ +RANLIB = @RANLIB@ +SACADO_DIR = @SACADO_DIR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TAPE_ADDR_TYPE = @TAPE_ADDR_TYPE@ +TAPE_ID_TYPE = @TAPE_ID_TYPE@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_FC = @ac_ct_FC@ +adolc_prefix = @adolc_prefix@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ +cppad_boostvector = @cppad_boostvector@ +cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ +cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated_01 = @cppad_deprecated_01@ +cppad_description = @cppad_description@ +cppad_eigenvector = @cppad_eigenvector@ +cppad_has_adolc = @cppad_has_adolc@ +cppad_has_boost = @cppad_has_boost@ +cppad_has_colpack = @cppad_has_colpack@ +cppad_has_eigen = @cppad_has_eigen@ +cppad_has_fadbad = @cppad_has_fadbad@ +cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_ipopt = @cppad_has_ipopt@ +cppad_has_mkstemp = @cppad_has_mkstemp@ +cppad_has_sacado = @cppad_has_sacado@ +cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ +cppad_max_num_threads = @cppad_max_num_threads@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ +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_version = @cppad_version@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +eigen_prefix = @eigen_prefix@ +exec_prefix = @exec_prefix@ +have_pkg_config = @have_pkg_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +ipopt_prefix = @ipopt_prefix@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +@CppAD_EIGEN_FALSE@EIGEN_SRC_FILES = +# +@CppAD_EIGEN_TRUE@EIGEN_SRC_FILES = eigen_cholesky.cpp eigen_mat_inv.cpp eigen_mat_mul.cpp +@CppAD_EIGEN_FALSE@EIGEN_EXTEA_FILES = eigen_cholesky.cpp eigen_mat_inv.cpp eigen_mat_mul.cpp +# +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + +# +# +atomic_SOURCES = \ + $(EIGEN_SRC_FILES) \ + atomic_two.cpp + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign example/atomic_two/makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign example/atomic_two/makefile +makefile: $(srcdir)/makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) + +atomic$(EXEEXT): $(atomic_OBJECTS) $(atomic_DEPENDENCIES) $(EXTRA_atomic_DEPENDENCIES) + @rm -f atomic$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(atomic_OBJECTS) $(atomic_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atomic_two.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eigen_cholesky.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eigen_mat_inv.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eigen_mat_mul.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) +check: check-am +all-am: makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ + clean-checkPROGRAMS clean-generic cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +.PRECIOUS: makefile + + +test: check + ./atomic + +# 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. +.NOEXPORT: diff -Nru cppad-2018.00.00.0/example/chkpoint_two/base2ad.cpp cppad-2019.02.00.0/example/chkpoint_two/base2ad.cpp --- cppad-2018.00.00.0/example/chkpoint_two/base2ad.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/chkpoint_two/base2ad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,133 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin chkpoint_two_base2ad.cpp$$ +$spell + checkpointing + Taylor +$$ + +$section Checkpointing With base2ad: Example and Test$$ + +$srcfile%example/chkpoint_two/base2ad.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ + +# include + +namespace { + using CppAD::AD; + typedef CPPAD_TESTVECTOR(AD) ADVector; + typedef CPPAD_TESTVECTOR(size_t) size_vector; + + // f(y) = ( 3*y[0], 3*y[1] ) + 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; + } + // g(x) = ( x[0]^3, x[1]^3 ) + void g_algo(const ADVector& x, ADVector& y) + { y[0] = 1.0; + y[1] = 1.0; + for(size_t k = 0; k < 3; k++) + { y[0] *= x[0]; + y[1] *= x[1]; + } + return; + } +} +bool base2ad(void) +{ bool ok = true; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // AD vectors holding x, y, and z values + size_t nx = 2, ny = 2, nz = 2; + ADVector ax(nx), ay(ny), az(nz); + + // record the function g_fun(x) + for(size_t j = 0; j < nx; j++) + ax[j] = double(j + 1); + Independent(ax); + g_algo(ax, ay); + CppAD::ADFun g_fun(ax, ay); + + // record the function f_fun(y) + Independent(ay); + f_algo(ay, az); + CppAD::ADFun f_fun(ay, az); + + // create checkpoint versions of f and g + bool internal_bool = true; + bool use_hes_sparsity = true; + bool use_base2ad = true; + bool use_in_parallel = false; + CppAD::chkpoint_two f_chk(f_fun, "f_chk", + internal_bool, use_hes_sparsity, use_base2ad, use_in_parallel + ); + CppAD::chkpoint_two g_chk(g_fun, "g_chk", + internal_bool, use_hes_sparsity, use_base2ad, use_in_parallel + ); + + // Record a version of z = f[g(x)] = h(x) with checkpointing + // h(x) = [ 3*x[0]^3 , 3*x[1]^3 ] + Independent(ax); + g_chk(ax, ay); + f_chk(ay, az); + CppAD::ADFun h_fun(ax, az); + + // Use base2ad to create and AD verison of h + CppAD::ADFun< AD, double> ah_fun = h_fun.base2ad(); + + // start recording AD operations + Independent(ax); + + // record evaluate derivative of h_0 (x) + az = ah_fun.Forward(0, ax); + ADVector aw(nz), adw(nx); + aw[0] = 1.0; + for(size_t i = 1; i < nz; ++i) + aw[i] = 0.0; + adw = ah_fun.Reverse(1, aw); + // k(x) = h_0 '(x) = [ 9*x[0]^2 , 0.0 ] + CppAD::ADFun k_fun(ax, adw); + + // Evaluate the Jacobian of k(x) + CPPAD_TESTVECTOR(double) x(nx); + for(size_t j = 0; j < nx; ++j) + x[j] = 2.0 + double(nx - j); + CPPAD_TESTVECTOR(double) J = k_fun.Jacobian(x); + + // check result + for(size_t i = 0; i < nz; ++i) + { for(size_t j = 0; j < nx; ++j) + { double Jij = J[i * nx + j]; + if( i == 0 && j == 0 ) + { double check = 18.0 * x[0]; + ok &= CppAD::NearEqual(Jij, check, eps99, eps99); + } + else + ok &= Jij == 0.0; + } + } + + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/example/chkpoint_two/chkpoint_two.cpp cppad-2019.02.00.0/example/chkpoint_two/chkpoint_two.cpp --- cppad-2018.00.00.0/example/chkpoint_two/chkpoint_two.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/chkpoint_two/chkpoint_two.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,56 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// CPPAD_HAS_* defines +# include + +// system include files used for I/O +# include + +// C style asserts +# include + +// for thread_alloc +# include + +// test runner +# include + +// external complied tests +extern bool base2ad(void); +extern bool compare(void); +extern bool dynamic(void); +extern bool get_started(void); +extern bool ode(void); + +// main program that runs all the tests +int main(void) +{ std::string group = "example/chkpoint_two"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + // external compiled tests + Run( base2ad, "base2ad" ); + Run( compare, "compare" ); + Run( dynamic, "dynamic" ); + Run( get_started, "get_started" ); + Run( ode, "ode" ); + // + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); +} diff -Nru cppad-2018.00.00.0/example/chkpoint_two/CMakeLists.txt cppad-2019.02.00.0/example/chkpoint_two/CMakeLists.txt --- cppad-2018.00.00.0/example/chkpoint_two/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/chkpoint_two/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,34 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# +SET(source_list + chkpoint_two.cpp + base2ad.cpp + compare.cpp + dynamic.cpp + get_started.cpp + ode.cpp +) +set_compile_flags( example_chkpoint_two "${cppad_debug_which}" "${source_list}" ) +# +ADD_EXECUTABLE(example_chkpoint_two EXCLUDE_FROM_ALL ${source_list}) +# +# Add the check_example_chkpoint_two target +ADD_CUSTOM_TARGET(check_example_chkpoint_two + example_chkpoint_two + DEPENDS example_chkpoint_two +) +MESSAGE(STATUS "make check_example_chkpoint_two: available") +# +# add to check check_example_depends in parent environment +add_to_list(check_example_depends check_example_chkpoint_two) +SET(check_example_depends "${check_example_depends}" PARENT_SCOPE) diff -Nru cppad-2018.00.00.0/example/chkpoint_two/compare.cpp cppad-2019.02.00.0/example/chkpoint_two/compare.cpp --- cppad-2018.00.00.0/example/chkpoint_two/compare.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/chkpoint_two/compare.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,198 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin chkpoint_two_compare.cpp$$ +$spell + checkpointing + Taylor +$$ + +$section Compare With and Without Checkpointing: Example and Test$$ + +$srcfile%example/chkpoint_two/compare.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ + +# include + +namespace { + using CppAD::AD; + typedef CPPAD_TESTVECTOR(AD) ADVector; + typedef CPPAD_TESTVECTOR(size_t) size_vector; + + 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 < 3; k++) + { y[0] *= x[0]; + y[1] *= x[1]; + } + return; + } + bool equal( + const CppAD::sparse_rc& pattern_left , + const CppAD::sparse_rc& pattern_right ) + { + size_vector row_major_left = pattern_left.row_major(); + size_vector row_major_right = pattern_right.row_major(); + bool ok = pattern_left.nnz() == pattern_right.nnz(); + if( ! ok ) + return ok; + for(size_t k = 0; k < pattern_left.nnz(); ++k) + { size_t r_left = pattern_left.row()[ row_major_left[k] ]; + size_t c_left = pattern_left.col()[ row_major_left[k] ]; + size_t r_right = pattern_right.row()[ row_major_right[k] ]; + size_t c_right = pattern_right.col()[ row_major_right[k] ]; + ok &= (r_left == r_right) && (c_left == c_right); + } + return ok; + } +} +bool compare(void) +{ bool ok = true; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // AD vectors holding x, y, and z values + size_t nx = 2, ny = 2, nz = 2; + ADVector ax(nx), ay(ny), az(nz); + + // record the function g_fun(x) + for(size_t j = 0; j < nx; j++) + ax[j] = double(j + 1); + Independent(ax); + g_algo(ax, ay); + CppAD::ADFun g_fun(ax, ay); + + // record the function f_fun(y) + Independent(ay); + f_algo(ay, az); + CppAD::ADFun f_fun(ay, az); + + // create checkpoint versions of f and g + bool internal_bool = true; + bool use_hes_sparsity = true; + bool use_base2ad = false; + bool use_in_parallel = false; + CppAD::chkpoint_two f_chk(f_fun, "f_chk", + internal_bool, use_hes_sparsity, use_base2ad, use_in_parallel + ); + CppAD::chkpoint_two g_chk(g_fun, "g_chk", + internal_bool, use_hes_sparsity, use_base2ad, use_in_parallel + ); + + // Record a version of z = f[g(x)] without checkpointing + Independent(ax); + g_algo(ax, ay); + f_algo(ay, az); + CppAD::ADFun check_not(ax, az); + + // Record a version of z = f[g(x)] with checkpointing + Independent(ax); + g_chk(ax, ay); + f_chk(ay, az); + CppAD::ADFun check_yes(ax, az); + + // checkpointing should use fewer operations + ok &= check_not.size_var() > check_yes.size_var(); + + // this does not really save space because f and g are only used once + ok &= check_not.size_var() <= check_yes.size_var() + + f_fun.size_var() + g_fun.size_var(); + + // compare forward mode results for orders 0, 1, 2 + size_t q1 = 3; // order_up + 1 + CPPAD_TESTVECTOR(double) x_q(nx*q1), z_not(nz*q1), z_yes(nz*q1); + for(size_t j = 0; j < nx; j++) + { for(size_t k = 0; k < q1; k++) + x_q[ j * q1 + k ] = 1.0 / double(q1 - k); + } + z_not = check_not.Forward(q1-1, x_q); + z_yes = check_yes.Forward(q1-1, x_q); + for(size_t i = 0; i < nz; i++) + { for(size_t k = 0; k < q1; k++) + { double zik_not = z_not[ i * q1 + k]; + double zik_yes = z_yes[ i * q1 + k]; + ok &= NearEqual(zik_not, zik_yes, eps99, eps99); + } + } + + // compare reverse mode results for orders 0, 1, 2 + CPPAD_TESTVECTOR(double) w(nz*q1), dw_not(nx*q1), dw_yes(nx*q1); + for(size_t i = 0; i < nz * q1; i++) + w[i] = 1.0 / double(i + 1); + dw_not = check_not.Reverse(q1, w); + dw_yes = check_yes.Reverse(q1, w); + for(size_t j = 0; j < nx; j++) + { for(size_t k = 0; k < q1; k++) + { double dwjk_not = dw_not[ j * q1 + k]; + double dwjk_yes = dw_yes[ j * q1 + k]; + ok &= NearEqual(dwjk_not, dwjk_yes, eps99, eps99); + } + } + + // compare Jacobian sparsity patterns + CppAD::sparse_rc pattern_in, pattern_not, pattern_yes; + pattern_in.resize(nx, nx, nx); + for(size_t k = 0; k < nx; ++k) + pattern_in.set(k, k, k); + bool transpose = false; + bool dependency = false; + internal_bool = false; + // for_jac_sparsity (not internal_bool is false) + check_not.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_not + ); + pattern_in.resize(nz, nz, nz); + for(size_t k = 0; k < nz; ++k) + pattern_in.set(k, k, k); + // forward and reverse Jacobian sparsity should give same answer + check_yes.rev_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_yes + ); + ok &= equal(pattern_not, pattern_yes ); + + // compare Hessian sparsity patterns + CPPAD_TESTVECTOR(bool) select_x(nx), select_z(nz); + for(size_t j = 0; j < nx; ++j) + select_x[j] = true; + for(size_t i = 0; i < nz; ++i) + select_z[i] = true; + transpose = false; + // Reverse should give same results as forward because + // previous for_jac_sparsity used identity for pattern_in. + // Note that internal_bool must be same as in call to for_sparse_jac. + check_not.rev_hes_sparsity( + select_z, transpose, internal_bool, pattern_yes + ); + // internal_bool need not be the same during a call to for_hes_sparsity + internal_bool = ! internal_bool; + check_yes.for_hes_sparsity( + select_x, select_z, internal_bool, pattern_not + ); + ok &= equal(pattern_not, pattern_yes); + // + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/example/chkpoint_two/dynamic.cpp cppad-2019.02.00.0/example/chkpoint_two/dynamic.cpp --- cppad-2018.00.00.0/example/chkpoint_two/dynamic.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/chkpoint_two/dynamic.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,117 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin chkpoint_two_dynamic.cpp$$ +$spell + +$$ + +$section Checkpoint Functions with Dynamic Parameters: Example and Test$$ + +$head Purpose$$ +This example demonstrates using dynamic parameters with a +$cref chkpoint_two$$ function. + +$head g(x)$$ +For this example, the checkpoint function +$latex g : \B{R}^2 \rightarrow \B{R}^3$$ is defined by +$latex \[ + g(x) + = + \left( \begin{array}{c} + x_0 \cdot p_0 \\ + x_0 \cdot x_ 0 \\ + x_1 \cdot x_ 0 + \end{array} \right) +\] $$ +where $latex p_0$$ is a dynamic parameter in the definition of $latex g(x)$$ + +$head f(x)$$ +The function $latex f(x) : \B{R}^2 \rightarrow \B{R}^3$$ +is defined by $latex f(x) = q_0 \cdot g(x)$$ where $latex q_0$$ +is a dynamic parameter in the definition of $latex f(x)$$. + +$head Source$$ +$srcfile%example/chkpoint_two/dynamic.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ +# include +bool dynamic(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * CppAD::numeric_limits::epsilon(); + // + // + // record the function g(x) + size_t nx = 2, ny = 3, np = 1, nq = 1; + CPPAD_TESTVECTOR( AD ) ax(nx), ay(ny), ap(np), aq(nq); + for(size_t j = 0; j < nx; j++) + ax[j] = double(j); + ap[0] = 2.0; + size_t abort_op_index = 0; + size_t record_compare = true; + Independent(ax, abort_op_index, record_compare, ap); + ay[0] = ax[0] * ap[0]; + ay[1] = ax[0] * ax[0]; + ay[2] = ax[1] * ax[0]; + CppAD::ADFun g_fun(ax, ay); + // + // make a checkpoint version of g + std::string name = "g(x)"; + bool internal_bool = true; + bool use_hes_sparsity = false; + bool use_base2ad = false; + bool use_in_parallel = false; + CppAD::chkpoint_two g_chk(g_fun, name, + internal_bool, use_hes_sparsity, use_base2ad, use_in_parallel + ); + // + // record f(x) using checkpoint version of g(x) + aq[0] = 3.0; + Independent(ax, abort_op_index, record_compare, aq); + g_chk(ax, ay); + for(size_t i = 0; i < ny; ++i) + ay[i] = aq[0] * ay[i]; + CppAD::ADFun f_fun(ax, ay); + // + // vecotrs of doubles + CPPAD_TESTVECTOR(double) x(nx), y(ny), p(np), q(nq); + // + // set dynamic parameters in g_chk + p[0] = 4.0; + g_chk.new_dynamic(p); + // + // set dynamic parmeters in f_fun + q[0] = 5.0; + f_fun.new_dynamic(q); + // + // evaluate f(x) + for(size_t j = 0; j < nx; ++j) + x[j] = 6.0 + double(j); + y = f_fun.Forward(0, x); + // + // check result + double check; + check = q[0] * x[0] * p[0]; + ok &= NearEqual(check, y[0], eps99, eps99); + check = q[0] * x[0] * x[0]; + ok &= NearEqual(check, y[1], eps99, eps99); + check = q[0] * x[1] * x[0]; + ok &= NearEqual(check, y[2], eps99, eps99); + // + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/example/chkpoint_two/get_started.cpp cppad-2019.02.00.0/example/chkpoint_two/get_started.cpp --- cppad-2018.00.00.0/example/chkpoint_two/get_started.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/chkpoint_two/get_started.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,157 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin chkpoint_two_get_started.cpp$$ +$spell + checkpointing + Taylor +$$ + +$section Get Started Checkpointing: Example and Test$$ + +$head Purpose$$ +Break a large computation into pieces and only store values at the +interface of the pieces. +In actual applications, there may many uses of each function +and many more functions. + +$head f$$ +The function $latex f : \B{R}^2 \rightarrow \B{R}^2$$ +is defined by +$latex \[ + f(y) = \left( \begin{array}{c} + y_0 + y_0 + y_0 + \\ + y_1 + y_1 + y_1 + \end{array} \right) +\] $$ + + +$head g$$ +The function $latex g : \B{R}^2 \rightarrow \B{R}^2$$ +defined by +$latex \[ + g(x) = \left( \begin{array}{c} + x_0 \cdot x_0 \cdot x_0 + \\ + x_1 \cdot x_1 \cdot x_1 + \end{array} \right) +\] $$ + +$head f[g(x)]$$ +The function $latex f[g(x)]$$ is given by +$latex \[ +f[g(x)] += +f \left[ \begin{array}{c} + x_0^3 \\ + x_1^3 +\end{array} \right] += +\left[ \begin{array}{c} + 3 x_0^3 \\ + 3 x_1^3 +\end{array} \right] +\] $$ + +$head Source Code$$ +$srcfile%example/chkpoint_two/get_started.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ + +# include + +namespace { + using CppAD::AD; + typedef CPPAD_TESTVECTOR(AD) ADVector; + + 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 < 3; k++) + { y[0] *= x[0]; + y[1] *= x[1]; + } + return; + } +} +bool get_started(void) +{ bool ok = true; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // AD vectors holding x, y, and z values + size_t nx = 2, ny = 2, nz = 2; + ADVector ax(nx), ay(ny), az(nz); + + // record the function g_fun(x) + for(size_t j = 0; j < nx; j++) + ax[j] = double(j + 1); + Independent(ax); + g_algo(ax, ay); + CppAD::ADFun g_fun(ax, ay); + + // record the function f_fun(y) + Independent(ay); + f_algo(ay, az); + CppAD::ADFun f_fun(ay, az); + + // create checkpoint versions of f and g + bool internal_bool = false; + bool use_hes_sparsity = false; + bool use_base2ad = false; + bool use_in_parallel = false; + CppAD::chkpoint_two f_chk( f_fun, "f_chk", + internal_bool, use_hes_sparsity, use_base2ad, use_in_parallel + ); + CppAD::chkpoint_two g_chk( g_fun, "g_chk", + internal_bool, use_hes_sparsity, use_base2ad, use_in_parallel + ); + + // Record a version of z = f[g(x)] using checkpointing + Independent(ax); + g_chk(ax, ay); + f_chk(ay, az); + CppAD::ADFun fg(ax, az); + + // zero order forward mode + CPPAD_TESTVECTOR(double) x(nx), z(nz); + for(size_t j = 0; j < nx; j++) + x[j] = 1.0 / double(1 + j); + z = fg.Forward(0, x); + for(size_t i = 0; i < nz; i++) + { double check = 3.0 * x[i] * x[i] * x[i]; + ok &= NearEqual(z[i], check, eps99, eps99); + } + + // optimize fg and check that results do not change + fg.optimize(); + for(size_t i = 0; i < nz; i++) + { double check = 3.0 * x[i] * x[i] * x[i]; + ok &= NearEqual(z[i], check, eps99, eps99); + } + // + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/example/chkpoint_two/makefile.am cppad-2019.02.00.0/example/chkpoint_two/makefile.am --- cppad-2018.00.00.0/example/chkpoint_two/makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/chkpoint_two/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,35 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# automake input file +# +# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp +DEFS = +# +check_PROGRAMS = checkpoint +# +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) +# +# +checkpoint_SOURCES = \ + chkpoint_two.cpp \ + base2ad.cpp \ + compare.cpp \ + dynamic.cpp \ + get_started.cpp \ + ode.cpp + +test: check + ./checkpoint diff -Nru cppad-2018.00.00.0/example/chkpoint_two/makefile.in cppad-2019.02.00.0/example/chkpoint_two/makefile.in --- cppad-2018.00.00.0/example/chkpoint_two/makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/chkpoint_two/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,633 @@ +# makefile.in generated by automake 1.15.1 from makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2017 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +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 \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +check_PROGRAMS = checkpoint$(EXEEXT) +subdir = example/chkpoint_two +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_checkpoint_OBJECTS = chkpoint_two.$(OBJEXT) base2ad.$(OBJEXT) \ + compare.$(OBJEXT) dynamic.$(OBJEXT) get_started.$(OBJEXT) \ + ode.$(OBJEXT) +checkpoint_OBJECTS = $(am_checkpoint_OBJECTS) +checkpoint_LDADD = $(LDADD) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(checkpoint_SOURCES) +DIST_SOURCES = $(checkpoint_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + 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@ +ACLOCAL = @ACLOCAL@ +ADOLC_DIR = @ADOLC_DIR@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BOOST_DIR = @BOOST_DIR@ +BOOST_INCLUDE = @BOOST_INCLUDE@ +BTHREAD_LIB = @BTHREAD_LIB@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPAD_IPOPT_LD_PATH = @CPPAD_IPOPT_LD_PATH@ +CPPAD_IPOPT_LIBS = @CPPAD_IPOPT_LIBS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXX_FLAGS@ +CYGPATH_W = @CYGPATH_W@ + +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# automake input file +# +# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp +DEFS = +DEPDIR = @DEPDIR@ +DL_LIB = @DL_LIB@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EIGEN_DIR = @EIGEN_DIR@ +EIGEN_INCLUDE = @EIGEN_INCLUDE@ +EXEEXT = @EXEEXT@ +FADBAD_DIR = @FADBAD_DIR@ +FC = @FC@ +FCFLAGS = @FCFLAGS@ +FCLIBS = @FCLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +IPOPT_DIR = @IPOPT_DIR@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAX_NUM_THREADS = @MAX_NUM_THREADS@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +OPENMP_FLAGS = @OPENMP_FLAGS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSTFIX_DIR = @POSTFIX_DIR@ +PTHREAD_LIB = @PTHREAD_LIB@ +RANLIB = @RANLIB@ +SACADO_DIR = @SACADO_DIR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TAPE_ADDR_TYPE = @TAPE_ADDR_TYPE@ +TAPE_ID_TYPE = @TAPE_ID_TYPE@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_FC = @ac_ct_FC@ +adolc_prefix = @adolc_prefix@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ +cppad_boostvector = @cppad_boostvector@ +cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ +cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated_01 = @cppad_deprecated_01@ +cppad_description = @cppad_description@ +cppad_eigenvector = @cppad_eigenvector@ +cppad_has_adolc = @cppad_has_adolc@ +cppad_has_boost = @cppad_has_boost@ +cppad_has_colpack = @cppad_has_colpack@ +cppad_has_eigen = @cppad_has_eigen@ +cppad_has_fadbad = @cppad_has_fadbad@ +cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_ipopt = @cppad_has_ipopt@ +cppad_has_mkstemp = @cppad_has_mkstemp@ +cppad_has_sacado = @cppad_has_sacado@ +cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ +cppad_max_num_threads = @cppad_max_num_threads@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ +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_version = @cppad_version@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +eigen_prefix = @eigen_prefix@ +exec_prefix = @exec_prefix@ +have_pkg_config = @have_pkg_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +ipopt_prefix = @ipopt_prefix@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +# +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + +# +# +checkpoint_SOURCES = \ + chkpoint_two.cpp \ + base2ad.cpp \ + compare.cpp \ + dynamic.cpp \ + get_started.cpp \ + ode.cpp + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign example/chkpoint_two/makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign example/chkpoint_two/makefile +makefile: $(srcdir)/makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) + +checkpoint$(EXEEXT): $(checkpoint_OBJECTS) $(checkpoint_DEPENDENCIES) $(EXTRA_checkpoint_DEPENDENCIES) + @rm -f checkpoint$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(checkpoint_OBJECTS) $(checkpoint_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base2ad.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chkpoint_two.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compare.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynamic.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_started.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) +check: check-am +all-am: makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ + clean-checkPROGRAMS clean-generic cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +.PRECIOUS: makefile + + +test: check + ./checkpoint + +# 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. +.NOEXPORT: diff -Nru cppad-2018.00.00.0/example/chkpoint_two/ode.cpp cppad-2019.02.00.0/example/chkpoint_two/ode.cpp --- cppad-2018.00.00.0/example/chkpoint_two/ode.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/chkpoint_two/ode.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,322 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin chkpoint_two_ode.cpp$$ +$spell + Checkpointing + Runge-Kutta +$$ + +$section Checkpointing an ODE Solver: Example and Test$$ + +$head Purpose$$ +In this example we $cref/checkpoint/chkpoint_two/$$ one step of an ODE solver. + +$head Problem$$ +We consider the initial value problem with parameter $latex x$$ defined by, +$latex z(0, x) = z_0 (x)$$, +$latex \[ + \partial_t z(t, x ) = h [ x , z(t, x) ] +\]$$ +Note that if $latex t$$ needs to be in the equation, one can define +the first component of $latex z(t, x)$$ to be equal to $latex t$$. + +$head ODE Solver$$ +For this example, we consider the Fourth order Runge-Kutta ODE solver. +Given an approximation solution at time $latex t_k$$ denoted by +$latex \tilde{z}_k (x)$$, and $latex \Delta t = t_{k+1} - t_k$$, +it defines the approximation solution $latex \tilde{z}_{k+1} (x)$$ +at time $latex t_{k+1}$$ by +$latex \[ +\begin{array}{rcl} +h_1 & = & h [ x , \tilde{z}_k (x) ] +\\ +h_2 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_1 / 2 ] +\\ +h_3 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_2 / 2 ] +\\ +h_4 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_3 ] +\\ +\tilde{z}_{k+1} (x) & = & + \tilde{z}_k (x) + \Delta t \; ( h_1 + 2 h_2 + 2 h_3 + h_4 ) / 6 +\end{array} +\] $$ +If $latex \tilde{z}_k (x) = z_k (x)$$, +$latex \tilde{z}_{k+1} (x) = z_{k+1} (x) + O( \Delta t^5 )$$. +Other ODE solvers can use a similar method to the one used below. + +$head ODE$$ +For this example the ODE is defined by +$latex z(0, x) = 0$$ and +$latex \[ + h[ x, z(t, x) ] = + \left( \begin{array}{c} + x_0 \\ + x_1 z_0 (t, x) \\ + \vdots \\ + x_{n-1} z_{n-2} (t, x) + \end{array} \right) + = + \left( \begin{array}{c} + \partial_t z_0 (t , x) \\ + \partial_t z_1 (t , x) \\ + \vdots \\ + \partial_t z_{n-1} (t , x) + \end{array} \right) +\] $$ + +$head Solution$$ +The solution of the ODE for this example, +which is used to check the results, +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 +$latex \[ + z(t, x) = + \left( \begin{array}{c} + x_0 t \\ + x_1 x_0 t^2 / 2 \\ + \vdots \\ + x_{n-1} x_{n-2} \ldots x_0 t^n / n ! + \end{array} \right) +\] $$ + + +$head Source$$ +$srcfile%example/chkpoint_two/ode.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ + +# include + +namespace { + using CppAD::AD; + typedef AD a1double; + typedef AD a2double; + // + typedef CPPAD_TESTVECTOR( double ) a0vector; + typedef CPPAD_TESTVECTOR( a1double ) a1vector; + typedef CPPAD_TESTVECTOR( a2double ) a2vector; + // + // set once by main and kept that way + double delta_t_ = std::numeric_limits::quiet_NaN(); + size_t n_ = 0; + // + // The function h( x , y) + template + FloatVector h(const FloatVector& x, const FloatVector& y) + { assert( size_t( x.size() ) == n_ ); + assert( size_t( y.size() ) == n_ ); + FloatVector result(n_); + result[0] = x[0]; + for(size_t i = 1; i < n_; i++) + result[i] = x[i] * y[i-1]; + return result; + } + + // The 4-th Order Runge-Kutta Step + template + FloatVector Runge4(const FloatVector& x, const FloatVector& z0 + ) + { assert( size_t( x.size() ) == n_ ); + assert( size_t( z0.size() ) == n_ ); + // + typedef typename FloatVector::value_type Float; + // + Float dt = Float(delta_t_); + size_t m = z0.size(); + // + FloatVector h1(m), h2(m), h3(m), h4(m), result(m); + h1 = h( x, z0 ); + // + for(size_t i = 0; i < m; i++) + h2[i] = z0[i] + dt * h1[i] / 2.0; + h2 = h( x, h2 ); + // + for(size_t i = 0; i < m; i++) + h3[i] = z0[i] + dt * h2[i] / 2.0; + h3 = h( x, h3 ); + // + for(size_t i = 0; i < m; i++) + h4[i] = z0[i] + dt * h3[i]; + h4 = h( x, h4 ); + // + for(size_t i = 0; i < m; i++) + { Float dz = dt * ( h1[i] + 2.0*h2[i] + 2.0*h3[i] + h4[i] ) / 6.0; + result[i] = z0[i] + dz; + } + return result; + } + + // pack x and z into an axz vector + template + void pack( + FloatVector& axz , + const FloatVector& x , + const FloatVector& z ) + { assert( size_t( axz.size() ) == n_ + n_ ); + assert( size_t( x.size() ) == n_ ); + assert( size_t( z.size() ) == n_ ); + // + size_t offset = 0; + for(size_t i = 0; i < n_; i++) + axz[offset + i] = x[i]; + offset += n_; + for(size_t i = 0; i < n_; i++) + axz[offset + i] = z[i]; + } + + // unpack an axz vector + template + void unpack( + const FloatVector& axz , + FloatVector& x , + FloatVector& z ) + { assert( size_t( axz.size() ) == n_ + n_ ); + assert( size_t( x.size() ) == n_ ); + assert( size_t( z.size() ) == n_ ); + // + size_t offset = 0; + for(size_t i = 0; i < n_; i++) + x[i] = axz[offset + i]; + offset += n_; + for(size_t i = 0; i < n_; i++) + z[i] = axz[offset + i]; + } + + // Algorithm that z(t, x) + void ode_algo(const a1vector& axz_in, a1vector& axz_out) + { assert( size_t( axz_in.size() ) == n_ + n_ ); + assert( size_t( axz_out.size() ) == n_ + n_ ); + // + // initial ode information + a1vector x(n_), z0(n_); + unpack(axz_in, x, z0); + // + // advance z(t, x) + a1vector z1 = Runge4(x, z0); + // + // final ode information + pack(axz_out, x, z1); + // + return; + } +} +// +bool ode(void) +{ bool ok = true; + using CppAD::NearEqual; + double eps = std::numeric_limits::epsilon(); + // + // number of terms in the differential equation + n_ = 6; + // + // step size for the differentiail equation + size_t n_step = 10; + double T = 1.0; + delta_t_ = T / double(n_step); + // + // set parameter value and initial value of the ode + a1vector ax(n_), az0(n_); + for(size_t i = 0; i < n_; i++) + { ax[i] = a1double(i + 1); + az0[i] = a1double(0); + } + // + // pack ode information input vector + // + // function corresponding to one step of the ode Algorithm + a1vector axz_in(2 * n_), axz_out(2 * n_); + pack(axz_in, ax, az0); + CppAD::Independent(axz_in); + ode_algo(axz_in, axz_out); + CppAD::ADFun ode_fun(axz_in, axz_out); + // + // create checkpoint version of the algorithm + bool internal_bool = false; + bool use_hes_sparsity = false; + bool use_base2ad = false; + bool use_in_parallel = false; + CppAD::chkpoint_two ode_check(ode_fun, "ode", + internal_bool, use_hes_sparsity, use_base2ad, use_in_parallel + ); + // + // set the independent variables for recording + CppAD::Independent( ax ); + // + // repack to get dependence on ax + pack(axz_in, ax, az0); + // + // Now run the checkpoint algorithm n_step times + for(size_t k = 0; k < n_step; k++) + { ode_check(axz_in, axz_out); + axz_in = axz_out; + } + // + // Unpack the results (must use ax1 so do not overwrite ax) + a1vector ax1(n_), az1(n_); + unpack(axz_out, ax1, az1); + // + // We could record a complicated funciton of x and z(T, x) in f, + // but make this example simpler we record x -> z(T, x). + CppAD::ADFun f(ax, az1); + // + // check function values + a0vector x(n_), z1(n_); + for(size_t j = 0; j < n_; j++) + x[j] = double(j + 1); + z1 = f.Forward(0, x); + // + // separate calculation of z(t, x) + a0vector check_z1(n_); + check_z1[0] = x[0] * T; + for(size_t i = 1; i < n_; i++) + check_z1[i] = x[i] * T * check_z1[i-1] / double(i+1); + // + // expected accuracy for each component of of z(t, x) + a0vector acc(n_); + for(size_t i = 0; i < n_; i++) + { if( i < 4 ) + { // Runge-Kutta methos is exact for this case + acc[i] = 10. * eps; + } + else + { acc[i] = 1.0; + for(size_t k = 0; k < 5; k++) + acc[i] *= x[k] * delta_t_; + } + } + // check z1(T, x) + for(size_t i = 0; i < n_; i++) + ok &= NearEqual(z1[i] , check_z1[i], acc[i], acc[i]); + // + // Now use f to compute a derivative. For this 'simple' example it is + // the derivative of z_{n-1} (T, x) respect to x of the + a0vector w(n_), dw(n_); + for(size_t i = 0; i < n_; i++) + { w[i] = 0.0; + if( i == n_ - 1 ) + w[i] = 1.0; + } + dw = f.Reverse(1, w); + for(size_t j = 0; j < n_; j++) + { double check = z1[n_ - 1] / x[j]; + ok &= NearEqual(dw[j] , check, 100.*eps, 100.*eps); + } + // + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/example/CMakeLists.txt cppad-2019.02.00.0/example/CMakeLists.txt --- cppad-2018.00.00.0/example/CMakeLists.txt 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the example directory tests # Inherit environment from ../CMakeList.txt @@ -18,10 +19,11 @@ ADD_SUBDIRECTORY(abs_normal) # atomic examples -ADD_SUBDIRECTORY(atomic) +ADD_SUBDIRECTORY(atomic_two) +ADD_SUBDIRECTORY(atomic_three) -# deprecated examples -ADD_SUBDIRECTORY(deprecated) +# checkpoint exmaples +ADD_SUBDIRECTORY(chkpoint_two) # general examples ADD_SUBDIRECTORY(general) @@ -31,7 +33,7 @@ # ipopt_solve examples IF( cppad_has_ipopt) - ADD_SUBDIRECTORY(ipopt_solve) + ADD_SUBDIRECTORY(ipopt_solve) ENDIF( cppad_has_ipopt) # multi_thread examples diff -Nru cppad-2018.00.00.0/example/deprecated/CMakeLists.txt cppad-2019.02.00.0/example/deprecated/CMakeLists.txt --- cppad-2018.00.00.0/example/deprecated/CMakeLists.txt 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 the example/deprecated tests -# -SET(source_list - deprecated.cpp - old_reciprocal.cpp - old_usead_1.cpp - old_usead_2.cpp - old_tan.cpp - old_mat_mul.cpp - omp_alloc.cpp - track_new_del.cpp - zdouble.cpp -) -set_compile_flags( example_deprecated "${cppad_debug_which}" "${source_list}" ) -# -ADD_EXECUTABLE(example_deprecated EXCLUDE_FROM_ALL ${source_list}) -# -# Add the check_example_deprecated target -ADD_CUSTOM_TARGET(check_example_deprecated - example_deprecated - DEPENDS - example_deprecated -) -MESSAGE(STATUS "make check_example_deprecated: available") -# -# Change check depends in parent environment -add_to_list(check_example_depends check_example_deprecated) -SET(check_example_depends "${check_example_depends}" PARENT_SCOPE) diff -Nru cppad-2018.00.00.0/example/deprecated/deprecated.cpp cppad-2019.02.00.0/example/deprecated/deprecated.cpp --- cppad-2018.00.00.0/example/deprecated/deprecated.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/deprecated.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ - -// CPPAD_HAS_* defines -# include - -// system include files used for I/O -# include - -// memory leak checker -# include - -// test runner -# include - -// prototype external compiled tests (this line expected by bin/new_test.sh) -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 track_new_del(void); -extern bool zdouble(void); - -// main program that runs all the tests -int main(void) -{ std::string group = "example/deprecated"; - size_t width = 20; - CppAD::test_boolofvoid Run(group, width); - - // This line is used by test_one.sh - - // run external compiled tests (this line expected by bin/new_test.sh) - Run( old_mat_mul, "old_mat_mul" ); - Run( old_reciprocal, "old_reciprocal" ); - Run( old_tan, "old_tan" ); - Run( old_usead_1, "old_usead_1" ); - Run( old_usead_2, "old_usead_2" ); - Run( omp_alloc, "omp_alloc" ); - Run( track_new_del, "track_new_del" ); - Run( zdouble, "zdouble" ); - // - // check for memory leak - bool memory_ok = CppAD::thread_alloc::free_all(); - // - // print summary at end - bool ok = Run.summary(memory_ok); - // - return static_cast( ! ok ); -} -// END PROGRAM diff -Nru cppad-2018.00.00.0/example/deprecated/makefile.am cppad-2019.02.00.0/example/deprecated/makefile.am --- cppad-2018.00.00.0/example/deprecated/makefile.am 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/makefile.am 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. -# ----------------------------------------------------------------------------- -# automake input file -# -# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp -DEFS = -# -check_PROGRAMS = deprecated -# -AM_CXXFLAGS = -g $(CXX_FLAGS) -# -AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) -# -deprecated_SOURCES = \ - deprecated.cpp \ - old_reciprocal.cpp \ - old_usead_1.cpp \ - old_usead_2.cpp \ - old_tan.cpp \ - old_mat_mul.cpp \ - old_mat_mul.hpp \ - omp_alloc.cpp \ - track_new_del.cpp \ - zdouble.cpp -# -test: check - ./deprecated diff -Nru cppad-2018.00.00.0/example/deprecated/makefile.in cppad-2019.02.00.0/example/deprecated/makefile.in --- cppad-2018.00.00.0/example/deprecated/makefile.in 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/makefile.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,652 +0,0 @@ -# makefile.in generated by automake 1.15 from makefile.am. -# @configure_input@ - -# 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, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ -VPATH = @srcdir@ -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 \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -check_PROGRAMS = deprecated$(EXEEXT) -subdir = example/deprecated -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_deprecated_OBJECTS = deprecated.$(OBJEXT) old_reciprocal.$(OBJEXT) \ - old_usead_1.$(OBJEXT) old_usead_2.$(OBJEXT) old_tan.$(OBJEXT) \ - old_mat_mul.$(OBJEXT) omp_alloc.$(OBJEXT) \ - track_new_del.$(OBJEXT) zdouble.$(OBJEXT) -deprecated_OBJECTS = $(am_deprecated_OBJECTS) -deprecated_LDADD = $(LDADD) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -am__mv = mv -f -CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -AM_V_CXX = $(am__v_CXX_@AM_V@) -am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) -am__v_CXX_0 = @echo " CXX " $@; -am__v_CXX_1 = -CXXLD = $(CXX) -CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ - -o $@ -AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) -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 = $(deprecated_SOURCES) -DIST_SOURCES = $(deprecated_SOURCES) -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - 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@ -ACLOCAL = @ACLOCAL@ -ADOLC_DIR = @ADOLC_DIR@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BOOST_DIR = @BOOST_DIR@ -BOOST_INCLUDE = @BOOST_INCLUDE@ -BTHREAD_LIB = @BTHREAD_LIB@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPAD_IPOPT_LD_PATH = @CPPAD_IPOPT_LD_PATH@ -CPPAD_IPOPT_LIBS = @CPPAD_IPOPT_LIBS@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ -CYGPATH_W = @CYGPATH_W@ - -# ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. -# ----------------------------------------------------------------------------- -# automake input file -# -# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp -DEFS = -DEPDIR = @DEPDIR@ -DL_LIB = @DL_LIB@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EIGEN_DIR = @EIGEN_DIR@ -EIGEN_INCLUDE = @EIGEN_INCLUDE@ -EXEEXT = @EXEEXT@ -FADBAD_DIR = @FADBAD_DIR@ -FC = @FC@ -FCFLAGS = @FCFLAGS@ -FCLIBS = @FCLIBS@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -IPOPT_DIR = @IPOPT_DIR@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MAX_NUM_THREADS = @MAX_NUM_THREADS@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -OPENMP_FLAGS = @OPENMP_FLAGS@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -POSTFIX_DIR = @POSTFIX_DIR@ -PTHREAD_LIB = @PTHREAD_LIB@ -RANLIB = @RANLIB@ -SACADO_DIR = @SACADO_DIR@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -TAPE_ADDR_TYPE = @TAPE_ADDR_TYPE@ -TAPE_ID_TYPE = @TAPE_ID_TYPE@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_FC = @ac_ct_FC@ -adolc_prefix = @adolc_prefix@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ -cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ -cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ -cppad_cppadvector = @cppad_cppadvector@ -cppad_cxx_flags = @cppad_cxx_flags@ -cppad_deprecated_01 = @cppad_deprecated_01@ -cppad_description = @cppad_description@ -cppad_eigenvector = @cppad_eigenvector@ -cppad_has_adolc = @cppad_has_adolc@ -cppad_has_boost = @cppad_has_boost@ -cppad_has_colpack = @cppad_has_colpack@ -cppad_has_eigen = @cppad_has_eigen@ -cppad_has_fadbad = @cppad_has_fadbad@ -cppad_has_gettimeofday = @cppad_has_gettimeofday@ -cppad_has_ipopt = @cppad_has_ipopt@ -cppad_has_mkstemp = @cppad_has_mkstemp@ -cppad_has_sacado = @cppad_has_sacado@ -cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ -cppad_max_num_threads = @cppad_max_num_threads@ -cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ -cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ -cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ -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_version = @cppad_version@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -eigen_prefix = @eigen_prefix@ -exec_prefix = @exec_prefix@ -have_pkg_config = @have_pkg_config@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -# -AM_CXXFLAGS = -g $(CXX_FLAGS) -# -AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) -# -deprecated_SOURCES = \ - deprecated.cpp \ - old_reciprocal.cpp \ - old_usead_1.cpp \ - old_usead_2.cpp \ - old_tan.cpp \ - old_mat_mul.cpp \ - old_mat_mul.hpp \ - omp_alloc.cpp \ - track_new_del.cpp \ - zdouble.cpp - -all: all-am - -.SUFFIXES: -.SUFFIXES: .cpp .o .obj -$(srcdir)/makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign example/deprecated/makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign example/deprecated/makefile -makefile: $(srcdir)/makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-checkPROGRAMS: - -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) - -deprecated$(EXEEXT): $(deprecated_OBJECTS) $(deprecated_DEPENDENCIES) $(EXTRA_deprecated_DEPENDENCIES) - @rm -f deprecated$(EXEEXT) - $(AM_V_CXXLD)$(CXXLINK) $(deprecated_OBJECTS) $(deprecated_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/deprecated.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)/track_new_del.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$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< - -.cpp.obj: -@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ -@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ -@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-am -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-am - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-am - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) -check: check-am -all-am: makefile -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: check-am install-am install-strip - -.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ - clean-checkPROGRAMS clean-generic cscopelist-am ctags ctags-am \ - distclean distclean-compile distclean-generic distclean-tags \ - distdir dvi dvi-am html html-am info info-am install \ - install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ - tags tags-am uninstall uninstall-am - -.PRECIOUS: makefile - -# -test: check - ./deprecated - -# 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. -.NOEXPORT: diff -Nru cppad-2018.00.00.0/example/deprecated/old_mat_mul.cpp cppad-2019.02.00.0/example/deprecated/old_mat_mul.cpp --- cppad-2018.00.00.0/example/deprecated/old_mat_mul.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/old_mat_mul.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,266 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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; -use $cref atomic_mat_mul.cpp$$ instead. - -$children% - example/deprecated/old_mat_mul.hpp -%$$ -$head Include File$$ -This routine uses the include file $cref old_mat_mul.hpp$$. - -$code -$srcfile%example/deprecated/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] = double(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] = double(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-2018.00.00.0/example/deprecated/old_mat_mul.hpp cppad-2019.02.00.0/example/deprecated/old_mat_mul.hpp --- cppad-2018.00.00.0/example/deprecated/old_mat_mul.hpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/old_mat_mul.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,425 +0,0 @@ -# ifndef CPPAD_EXAMPLE_DEPRECATED_OLD_MAT_MUL_HPP -# define CPPAD_EXAMPLE_DEPRECATED_OLD_MAT_MUL_HPP - -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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$$ -$srccode%cpp% */ -# include // Include CppAD definitions -namespace { // Begin empty namespace - using CppAD::vector; // Let vector denote CppAD::vector -/* %$$ - -$head Extra Call Information$$ -$srccode%cpp% */ - // 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$$ -$srccode%cpp% */ - // 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: -$srccode%cpp% */ - 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: -$srccode%cpp% */ - 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$$ -$srccode%cpp% */ - using CppAD::set_union; -/* %$$ - -$head CppAD User Atomic Callback Functions$$ -$srccode%cpp% */ - // ---------------------------------------------------------------------- - // 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] ) - s[ij_result] = set_union(s[ij_result], r[im_left]); - - // s[ij_result] = union( s[ij_result], r[mj_right] ) - s[ij_result] = set_union(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] ) - r[im_left] = set_union(r[im_left], s[ij_result]); - - // r[mj_right] = union( r[mj_right], s[ij_result] ) - r[mj_right] = set_union(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] ) - v[im_left] = set_union(v[im_left], u[ij_result] ); - v[mj_right] = set_union(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] ) - v[im_left] = set_union(v[im_left], r[mj_right] ); - // v[mj_right] = union( v[mj_right], r[im_left] ) - v[mj_right] = set_union(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$$): -$srccode%cpp% */ - 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-2018.00.00.0/example/deprecated/old_reciprocal.cpp cppad-2019.02.00.0/example/deprecated/old_reciprocal.cpp --- cppad-2018.00.00.0/example/deprecated/old_reciprocal.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/old_reciprocal.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,357 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 -$srcfile%example/deprecated/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. - using CppAD::set_union; - - // ---------------------------------------------------------------------- - // 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] ) - v[0] = set_union(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-2018.00.00.0/example/deprecated/old_tan.cpp cppad-2019.02.00.0/example/deprecated/old_tan.cpp --- cppad-2018.00.00.0/example/deprecated/old_tan.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/old_tan.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,409 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 -$srcfile%example/deprecated/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. - using CppAD::set_union; - - // ---------------------------------------------------------------------- - // 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] = float( tan( tx[0] ) ); - else tzy[0] = float( 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] * float(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] * float(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] * float(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] - r[0] = set_union(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, ... - v[0] = set_union(u[0], u[1]); - - // convert forward Jacobian sparsity to Hessian sparsity - // because tan and tanh are nonlinear - if( t[0] ) - v[0] = set_union(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-2018.00.00.0/example/deprecated/old_usead_1.cpp cppad-2019.02.00.0/example/deprecated/old_usead_1.cpp --- cppad-2018.00.00.0/example/deprecated/old_usead_1.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/old_usead_1.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,368 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 -$srcfile%example/deprecated/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-2018.00.00.0/example/deprecated/old_usead_2.cpp cppad-2019.02.00.0/example/deprecated/old_usead_2.cpp --- cppad-2018.00.00.0/example/deprecated/old_usead_2.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/old_usead_2.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,495 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 -$srcfile%example/deprecated/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] / double(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-2018.00.00.0/example/deprecated/omp_alloc.cpp cppad-2019.02.00.0/example/deprecated/omp_alloc.cpp --- cppad-2018.00.00.0/example/deprecated/omp_alloc.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/omp_alloc.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,190 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 -$srcfile%example/deprecated/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-2018.00.00.0/example/deprecated/track_new_del.cpp cppad-2019.02.00.0/example/deprecated/track_new_del.cpp --- cppad-2018.00.00.0/example/deprecated/track_new_del.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/track_new_del.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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.cpp$$ - -$section Tracking Use of New and Delete: Example and Test$$ -$mindex delete$$ - - - -$code -$srcfile%example/deprecated/track_new_del.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ - -# include - -bool track_new_del(void) -{ bool ok = true; - - // initial count - size_t count = CPPAD_TRACK_COUNT(); - - // allocate an array of length 5 - double *ptr = CPPAD_NULL; - size_t newlen = 5; - ptr = CPPAD_TRACK_NEW_VEC(newlen, ptr); - - // copy data into the array - size_t ncopy = newlen; - size_t i; - for(i = 0; i < ncopy; i++) - ptr[i] = double(i); - - // extend the buffer to be length 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++) - ok &= (ptr[i] == double(i)); - - // free the memory allocated since previous call to TrackCount - CPPAD_TRACK_DEL_VEC(ptr); - - // check for memory leak - ok &= (count == CPPAD_TRACK_COUNT()); - - return ok; -} - -// END C++ diff -Nru cppad-2018.00.00.0/example/deprecated/zdouble.cpp cppad-2019.02.00.0/example/deprecated/zdouble.cpp --- cppad-2018.00.00.0/example/deprecated/zdouble.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/deprecated/zdouble.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 -$srcfile%example/deprecated/zdouble.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ -# include - -namespace { - template bool test_one(void) - { bool ok = true; - Base eps99 = 99. * 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], eps99, eps99); - ok &= CppAD::NearEqual(z[1], - x[0]/(x[1]*x[1]), eps99, eps99); - - return ok; - } - bool test_two(void) - { bool ok = true; - using CppAD::zdouble; - // - zdouble eps = CppAD::numeric_limits::epsilon(); - ok &= eps == std::numeric_limits::epsilon(); - // - zdouble min = CppAD::numeric_limits::min(); - ok &= min == std::numeric_limits::min(); - // - zdouble max = CppAD::numeric_limits::max(); - ok &= max == std::numeric_limits::max(); - // - zdouble nan = CppAD::numeric_limits::quiet_NaN(); - ok &= nan != nan; - // - int digits10 = CppAD::numeric_limits::digits10; - ok &= digits10 == std::numeric_limits::digits10; - // - return ok; - } -} - -bool zdouble(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - using CppAD::zdouble; - // - ok &= test_one(); - ok &= test_one(); - // - ok &= test_two(); - // - return ok; -} -// END C++ diff -Nru cppad-2018.00.00.0/example/general/abort_recording.cpp cppad-2019.02.00.0/example/general/abort_recording.cpp --- cppad-2018.00.00.0/example/general/abort_recording.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/abort_recording.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin abort_recording.cpp$$ @@ -15,12 +16,9 @@ $$ $section Abort Current Recording: Example and Test$$ -$mindex recording$$ -$code $srcfile%example/general/abort_recording.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,57 +28,57 @@ # include bool abort_recording(void) -{ bool ok = true; - double eps = 10. * CppAD::numeric_limits::epsilon(); +{ bool ok = true; + double eps = 10. * CppAD::numeric_limits::epsilon(); - using CppAD::AD; + using CppAD::AD; - try - { // domain space vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = 0.; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // simulate an error during calculation of y and the execution - // stream was aborted - throw 1; - } - catch (int e) - { ok &= (e == 1); - - // do this incase throw occured after the call to Independent - // (for case above this is known, but in general it is unknown) - AD::abort_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; - CppAD::Independent(x); - - // 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); - - // forward computation of partials w.r.t. x[0] - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - dx[0] = 1.; - dy = f.Forward(1, dx); - ok &= CppAD::NearEqual(dy[0], 2., eps, eps); + try + { // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = 0.; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // simulate an error during calculation of y and the execution + // stream was aborted + throw 1; + } + catch (int e) + { ok &= (e == 1); + + // do this incase throw occured after the call to Independent + // (for case above this is known, but in general it is unknown) + AD::abort_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; + CppAD::Independent(x); + + // 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); + + // forward computation of partials w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= CppAD::NearEqual(dy[0], 2., eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/acos.cpp cppad-2019.02.00.0/example/general/acos.cpp --- cppad-2018.00.00.0/example/general/acos.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/acos.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin acos.cpp$$ $spell - cos - acos + cos + acos $$ $section The AD acos Function: Example and Test$$ -$code $srcfile%example/general/acos.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,59 +28,59 @@ # include bool acos(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; + using CppAD::AD; + using CppAD::NearEqual; - // 10 times machine epsilon - double eps = 10. * std::numeric_limits::epsilon(); + // 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 cos_of_x0 = CppAD::cos(x[0]); - - // 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); - - // 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 acos - CppAD::VecAD v(1); - AD zero(0); - v[zero] = cos_of_x0; - AD result = CppAD::acos(v[zero]); - ok &= NearEqual(result, x0, eps, eps); + // 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 cos_of_x0 = CppAD::cos(x[0]); + + // 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); + + // 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 acos + CppAD::VecAD v(1); + AD zero(0); + v[zero] = cos_of_x0; + AD result = CppAD::acos(v[zero]); + ok &= NearEqual(result, x0, eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/acosh.cpp cppad-2019.02.00.0/example/general/acosh.cpp --- cppad-2018.00.00.0/example/general/acosh.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/acosh.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin acosh.cpp$$ $spell - cosh - acosh + cosh + acosh $$ $section The AD acosh Function: Example and Test$$ -$code $srcfile%example/general/acosh.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,59 +28,59 @@ # include bool acosh(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; + using CppAD::AD; + using CppAD::NearEqual; - // 10 times machine epsilon - double eps = 10. * std::numeric_limits::epsilon(); + // 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); + // 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/ad_assign.cpp cppad-2019.02.00.0/example/general/ad_assign.cpp --- cppad-2018.00.00.0/example/general/ad_assign.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/ad_assign.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ad_assign.cpp$$ $spell - Cpp + Cpp $$ $section AD Assignment: Example and Test$$ -$mindex assign object$$ -$code $srcfile%example/general/ad_assign.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ @@ -29,29 +27,29 @@ # include bool ad_assign(void) -{ bool ok = true; // initialize test result flag - using CppAD::AD; // so can use AD in place of CppAD::AD +{ bool ok = true; // initialize test result flag + using CppAD::AD; // so can use AD in place of CppAD::AD - // assignment to base value - AD a; - a = 1.; - ok &= a == 1.; - - // assignment to a value that converts to the base type - a = 2; - ok &= a == 2.; - - // assignment to an AD - AD b(3.); - a = b; - ok &= a == 3.; - - // assignment to an VecAD element - CppAD::VecAD v(1); - v[0] = 4.; - a = v[0]; - ok &= a == 4.; + // assignment to base value + AD a; + a = 1.; + ok &= a == 1.; + + // assignment to a value that converts to the base type + a = 2; + ok &= a == 2.; + + // assignment to an AD + AD b(3.); + a = b; + ok &= a == 3.; + + // assignment to an VecAD element + CppAD::VecAD v(1); + v[0] = 4.; + a = v[0]; + ok &= a == 4.; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/ad_ctor.cpp cppad-2019.02.00.0/example/general/ad_ctor.cpp --- cppad-2018.00.00.0/example/general/ad_ctor.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/ad_ctor.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ad_ctor.cpp$$ $spell - Cpp + Cpp $$ $section AD Constructors: Example and Test$$ -$mindex constructor object$$ -$code $srcfile%example/general/ad_ctor.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ @@ -29,33 +27,33 @@ # include bool ad_ctor(void) -{ bool ok = true; // initialize test result flag - using CppAD::AD; // so can use AD in place of CppAD::AD +{ bool ok = true; // initialize test result flag + using CppAD::AD; // so can use AD in place of CppAD::AD - // default constructor - AD a; - a = 0.; - ok &= a == 0.; - - // constructor from base type - AD b(1.); - ok &= b == 1.; - - // constructor from another type that converts to the base type - AD c(2); - ok &= c == 2.; - - // constructor from AD - AD d(c); - ok &= d == 2.; - - // constructor from a VecAD element - CppAD::VecAD v(1); - v[0] = 3.; - AD e( v[0] ); - ok &= e == 3.; + // default constructor + AD a; + a = 0.; + ok &= a == 0.; + + // constructor from base type + AD b(1.); + ok &= b == 1.; + + // constructor from another type that converts to the base type + AD c(2); + ok &= c == 2.; + + // constructor from AD + AD d(c); + ok &= d == 2.; + + // constructor from a VecAD element + CppAD::VecAD v(1); + v[0] = 3.; + AD e( v[0] ); + ok &= e == 3.; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/add.cpp cppad-2019.02.00.0/example/general/add.cpp --- cppad-2018.00.00.0/example/general/add.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/add.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,22 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin add.cpp$$ $section AD Binary Addition: Example and Test$$ -$mindex + add plus$$ -$code $srcfile%example/general/add.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -26,59 +24,59 @@ # include bool Add(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * 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); - - // 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 - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = d + x[0]; // AD + AD - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // check value - ok &= NearEqual(y[0] , 2. * x0 + 10, eps99, eps99); - - // forward computation of partials 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], 2., eps99, eps99); - - // 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], 2., eps99, eps99); - - // use a VecAD::reference object with addition - CppAD::VecAD v(1); - AD zero(0); - v[zero] = a; - AD result = v[zero] + 2; - ok &= (result == b); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * 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); + + // 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 + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = d + x[0]; // AD + AD + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check value + ok &= NearEqual(y[0] , 2. * x0 + 10, eps99, eps99); + + // forward computation of partials 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], 2., eps99, eps99); + + // 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], 2., eps99, eps99); + + // use a VecAD::reference object with addition + CppAD::VecAD v(1); + AD zero(0); + v[zero] = a; + AD result = v[zero] + 2; + ok &= (result == b); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/add_eq.cpp cppad-2019.02.00.0/example/general/add_eq.cpp --- cppad-2018.00.00.0/example/general/add_eq.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/add_eq.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin AddEq.cpp$$ $section AD Compound Assignment Addition: Example and Test$$ -$mindex += add assign plus$$ -$code $srcfile%example/general/add_eq.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -27,60 +25,60 @@ # include bool AddEq(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - double x0 = .5; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // range space vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = x[0]; // initial value - y[0] += 2; // AD += int - y[0] += 4.; // AD += double - y[1] = y[0] += x[0]; // use the result of a compound assignment - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // check value - ok &= NearEqual(y[0] , x0+2.+4.+x0, eps99, eps99); - ok &= NearEqual(y[1] , y[0], eps99, eps99); - - // forward computation of partials 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], 2., eps99, eps99); - ok &= NearEqual(dy[1], 2., eps99, eps99); - - // reverse computation of derivative of y[0] - CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); - w[0] = 1.; - w[1] = 0.; - dw = f.Reverse(1, w); - ok &= NearEqual(dw[0], 2., eps99, eps99); - - // use a VecAD::reference object with computed addition - CppAD::VecAD v(1); - AD zero(0); - AD result = 1; - v[zero] = 2; - result += v[zero]; - ok &= (result == 3); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = .5; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // range space vector + size_t m = 2; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = x[0]; // initial value + y[0] += 2; // AD += int + y[0] += 4.; // AD += double + y[1] = y[0] += x[0]; // use the result of a compound assignment + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check value + ok &= NearEqual(y[0] , x0+2.+4.+x0, eps99, eps99); + ok &= NearEqual(y[1] , y[0], eps99, eps99); + + // forward computation of partials 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], 2., eps99, eps99); + ok &= NearEqual(dy[1], 2., eps99, eps99); + + // reverse computation of derivative of y[0] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + w[1] = 0.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], 2., eps99, eps99); + + // use a VecAD::reference object with computed addition + CppAD::VecAD v(1); + AD zero(0); + AD result = 1; + v[zero] = 2; + result += v[zero]; + ok &= (result == 3); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/ad_fun.cpp cppad-2019.02.00.0/example/general/ad_fun.cpp --- cppad-2018.00.00.0/example/general/ad_fun.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/ad_fun.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ad_fun.cpp$$ @@ -15,12 +16,9 @@ $$ $section Creating Your Own Interface to an ADFun Object$$ -$mindex example test$$ -$code $srcfile%example/general/ad_fun.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,100 +28,100 @@ namespace { - // 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. - template - my_ad_fun(const ADvector& x, const ADvector& y) - { f.Dependent(x, y); } - - // same as ADFun::Jacobian - template - 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); } - }; + // 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. + template + my_ad_fun(const ADvector& x, const ADvector& y) + { f.Dependent(x, y); } + + // same as ADFun::Jacobian + template + BaseVector jacobian(const BaseVector& x) + { return f.Jacobian(x); } + + // same as ADFun::Hessian + template + BaseVector hessian(const BaseVector &x, const BaseVector &w) + { return f.Hessian(x, w); } + }; } // End empty namespace bool ad_fun(void) -{ // This example is similar to example/jacobian.cpp, except that it - // uses my_ad_fun instead of ADFun. +{ // This example is similar to example/jacobian.cpp, except that it + // uses my_ad_fun instead of ADFun. - bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - using CppAD::exp; - using CppAD::sin; - using CppAD::cos; - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 1.; - X[1] = 2.; - - // declare independent variables and starting recording - CppAD::Independent(X); - - // a calculation between the domain and range values - AD Square = X[0] * X[0]; - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = Square * exp( X[1] ); - Y[1] = Square * sin( X[1] ); - Y[2] = Square * cos( X[1] ); - - // create f: X -> Y and stop tape recording - my_ad_fun f(X, Y); - - // new value for the independent variable vector - CPPAD_TESTVECTOR(double) x(n); - x[0] = 2.; - x[1] = 1.; - - // compute the derivative at this x - CPPAD_TESTVECTOR(double) jac( m * n ); - jac = f.jacobian(x); - - /* - F'(x) = [ 2 * x[0] * exp(x[1]) , x[0] * x[0] * exp(x[1]) ] - [ 2 * x[0] * sin(x[1]) , x[0] * x[0] * cos(x[1]) ] - [ 2 * x[0] * cos(x[1]) , -x[0] * x[0] * sin(x[i]) ] - */ - ok &= NearEqual( 2.*x[0]*exp(x[1]), jac[0*n+0], eps99, eps99); - ok &= NearEqual( 2.*x[0]*sin(x[1]), jac[1*n+0], eps99, eps99); - ok &= NearEqual( 2.*x[0]*cos(x[1]), jac[2*n+0], eps99, eps99); - - ok &= NearEqual( x[0] * x[0] *exp(x[1]), jac[0*n+1], eps99, eps99); - ok &= NearEqual( x[0] * x[0] *cos(x[1]), jac[1*n+1], eps99, eps99); - ok &= NearEqual(-x[0] * x[0] *sin(x[1]), jac[2*n+1], eps99, eps99); + bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + using CppAD::exp; + using CppAD::sin; + using CppAD::cos; + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 1.; + X[1] = 2.; + + // declare independent variables and starting recording + CppAD::Independent(X); + + // a calculation between the domain and range values + AD Square = X[0] * X[0]; + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = Square * exp( X[1] ); + Y[1] = Square * sin( X[1] ); + Y[2] = Square * cos( X[1] ); + + // create f: X -> Y and stop tape recording + my_ad_fun f(X, Y); + + // new value for the independent variable vector + CPPAD_TESTVECTOR(double) x(n); + x[0] = 2.; + x[1] = 1.; + + // compute the derivative at this x + CPPAD_TESTVECTOR(double) jac( m * n ); + jac = f.jacobian(x); + + /* + F'(x) = [ 2 * x[0] * exp(x[1]) , x[0] * x[0] * exp(x[1]) ] + [ 2 * x[0] * sin(x[1]) , x[0] * x[0] * cos(x[1]) ] + [ 2 * x[0] * cos(x[1]) , -x[0] * x[0] * sin(x[i]) ] + */ + ok &= NearEqual( 2.*x[0]*exp(x[1]), jac[0*n+0], eps99, eps99); + ok &= NearEqual( 2.*x[0]*sin(x[1]), jac[1*n+0], eps99, eps99); + ok &= NearEqual( 2.*x[0]*cos(x[1]), jac[2*n+0], eps99, eps99); + + ok &= NearEqual( x[0] * x[0] *exp(x[1]), jac[0*n+1], eps99, eps99); + ok &= NearEqual( x[0] * x[0] *cos(x[1]), jac[1*n+1], eps99, eps99); + ok &= NearEqual(-x[0] * x[0] *sin(x[1]), jac[2*n+1], eps99, eps99); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/example/general/ad_in_c.cpp cppad-2019.02.00.0/example/general/ad_in_c.cpp --- cppad-2018.00.00.0/example/general/ad_in_c.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/ad_in_c.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ad_in_c.cpp$$ $spell - CppAD + CppAD $$ $section Example and Test Linking CppAD to Languages Other than C++$$ -$mindex C AD algorithmic differentiation automatic link$$ -$code $srcfile%example/general/ad_in_c.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -35,14 +33,14 @@ /* void debug_print(const char *label, double d) -{ using std::printf; +{ using std::printf; - unsigned char *byte = reinterpret_cast(&d); - size_t n_byte = sizeof(d); - printf("%s", label); - for(size_t i = 0; i < n_byte; i++) - printf("%x", byte[i]); - printf("\n"); + unsigned char *byte = reinterpret_cast(&d); + size_t n_byte = sizeof(d); + printf("%s", label); + for(size_t i = 0; i < n_byte; i++) + printf("%x", byte[i]); + printf("\n"); } */ @@ -57,8 +55,8 @@ // type in C corresponding to a C AD unary operator typedef enum { - op_abs, op_acos, op_asin, op_atan, op_cos, op_cosh, - op_exp, op_log, op_sin, op_sinh, op_sqrt + 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; // -------------------------------------------------------------------------- @@ -69,33 +67,33 @@ using CppAD::NearEqual; 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 = - reinterpret_cast< AD* > (p_cad[j].p_void); - v[j] = *p_ad; - } +{ assert( n == v.size() ); + for(size_t j = 0; j < n; j++) + { AD* p_ad = + reinterpret_cast< AD* > (p_cad[j].p_void); + v[j] = *p_ad; + } } 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 = - reinterpret_cast< AD* > (p_cad[j].p_void); - *p_ad = v[j]; - } +{ assert( n == v.size() ); + for(size_t j = 0; j < n; j++) + { AD* p_ad = + reinterpret_cast< AD* > (p_cad[j].p_void); + *p_ad = v[j]; + } } void double2vector(size_t n, double* p_dbl, vector& v) -{ assert( n == v.size() ); - for(size_t j = 0; j < n; j++) - v[j] = p_dbl[j]; +{ assert( n == v.size() ); + for(size_t j = 0; j < n; j++) + v[j] = p_dbl[j]; } void vector2double(size_t n, vector& v, double *p_dbl) -{ assert( n == v.size() ); - for(size_t j = 0; j < n; j++) - p_dbl[j] = v[j]; +{ assert( n == v.size() ); + for(size_t j = 0; j < n; j++) + p_dbl[j] = v[j]; } std::list allocated; @@ -106,18 +104,18 @@ { } # else inline void push_allocated(void *p) -{ assert( p != 0 ); - allocated.push_front(p); +{ assert( p != 0 ); + allocated.push_front(p); } inline void pop_allocated(void *p) -{ std::list::iterator i; - for(i = allocated.begin(); i != allocated.end(); ++i) - { if( *i == p ) - { allocated.erase(i); - return; - } - } - assert( 0 ); +{ std::list::iterator i; + for(i = allocated.begin(); i != allocated.end(); ++i) + { if( *i == p ) + { allocated.erase(i); + return; + } + } + assert( 0 ); } # endif @@ -127,8 +125,8 @@ // extern "C" bool cad_near_equal(double x, double y) -{ double eps = 10. * std::numeric_limits::epsilon(); - return NearEqual(x, y, eps, 0.); +{ double eps = 10. * std::numeric_limits::epsilon(); + return NearEqual(x, y, eps, 0.); } // create a C++ AD object @@ -136,14 +134,14 @@ // p_cad->p_void: on input is 0, on output points to C++ AD object extern "C" void cad_new_ad(cad *p_cad, double value) -{ // make sure pointer is not currently allocated - assert( p_cad->p_void == 0 ); +{ // make sure pointer is not currently allocated + assert( p_cad->p_void == 0 ); - AD* p_ad = new AD(value); - p_cad->p_void = reinterpret_cast(p_ad); + AD* p_ad = new AD(value); + p_cad->p_void = reinterpret_cast(p_ad); - // put in list of allocate pointers - push_allocated( p_cad->p_void ); + // put in list of allocate pointers + push_allocated( p_cad->p_void ); } // delete a C++ AD object @@ -151,196 +149,196 @@ // p_cad->p_void: on input points to C++ AD object, on output is 0 extern "C" void cad_del_ad(cad* p_cad) -{ // make sure that p_cad has been allocated - pop_allocated( p_cad->p_void ); +{ // make sure that p_cad has been allocated + pop_allocated( p_cad->p_void ); - AD* p_ad = reinterpret_cast< AD* >( p_cad->p_void ); - delete p_ad; + AD* p_ad = reinterpret_cast< AD* >( p_cad->p_void ); + delete p_ad; - // special value for pointers that are not allocated - p_cad->p_void = 0; + // special value for pointers that are not allocated + p_cad->p_void = 0; } // extract the value from a C++ AD object // extern "C" double cad_value(cad* p_cad) -{ AD* p_ad = reinterpret_cast< AD* > (p_cad->p_void); - return Value( Var2Par(*p_ad) ); +{ AD* p_ad = reinterpret_cast< AD* > (p_cad->p_void); + return Value( Var2Par(*p_ad) ); } // preform a C AD unary operation extern "C" 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); - switch(op) - { - case op_abs: - *result = fabs( *operand ); - break; - - case op_acos: - *result = acos( *operand ); - break; - - case op_asin: - *result = asin( *operand ); - break; - - case op_atan: - *result = atan( *operand ); - break; - - case op_cos: - *result = cos( *operand ); - break; - - case op_cosh: - *result = cosh( *operand ); - break; - - case op_exp: - *result = exp( *operand ); - break; - - case op_log: - *result = log( *operand ); - break; - - case op_sin: - *result = sin( *operand ); - break; - - case op_sinh: - *result = sinh( *operand ); - break; - - case op_sqrt: - *result = sqrt( *operand ); - break; - - default: - // not a unary operator - assert(0); - break; +{ AD *operand, *result; + result = reinterpret_cast< AD* > (p_result->p_void); + operand = reinterpret_cast< AD* > (p_operand->p_void); + switch(op) + { + case op_abs: + *result = fabs( *operand ); + break; + + case op_acos: + *result = acos( *operand ); + break; + + case op_asin: + *result = asin( *operand ); + break; + + case op_atan: + *result = atan( *operand ); + break; + + case op_cos: + *result = cos( *operand ); + break; + + case op_cosh: + *result = cosh( *operand ); + break; + + case op_exp: + *result = exp( *operand ); + break; + + case op_log: + *result = log( *operand ); + break; + + case op_sin: + *result = sin( *operand ); + break; + + case op_sinh: + *result = sinh( *operand ); + break; + + case op_sqrt: + *result = sqrt( *operand ); + break; + + default: + // not a unary operator + assert(0); + break; - } - return; + } + return; } // 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; - 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); - break; - - case op_sub: - *result = *left - (*right); - break; - - case op_mul: - *result = *left * (*right); - break; - - case op_div: - *result = *left / (*right); - break; - - default: - // not a binary operator - assert(0); - } - return; +{ 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); + break; + + case op_sub: + *result = *left - (*right); + break; + + case op_mul: + *result = *left * (*right); + break; + + case op_div: + *result = *left / (*right); + break; + + default: + // not a binary operator + assert(0); + } + return; } // declare the independent variables in C++ extern "C" void cad_independent(size_t n, cad* px_cad) -{ vector< AD > x(n); - cad2vector(n, px_cad, x); - CppAD::Independent(x); - vector2cad(n, x, px_cad); +{ vector< AD > x(n); + cad2vector(n, px_cad, x); + CppAD::Independent(x); + vector2cad(n, x, px_cad); } // create an ADFun object in C++ extern "C" cad_fun cad_new_fun(size_t n, size_t m, cad* px_cad, cad* py_cad) -{ cad_fun fun; +{ cad_fun fun; - ADFun* p_adfun = new ADFun; - vector< AD > x(n); - vector< AD > y(m); - cad2vector(n, px_cad, x); - cad2vector(m, py_cad, y); - p_adfun->Dependent(x, y); + ADFun* p_adfun = new ADFun; + vector< AD > x(n); + vector< AD > y(m); + cad2vector(n, px_cad, x); + 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 ); + // put in list of allocate pointers + push_allocated( fun.p_void ); - return fun; + return fun; } // delete an AD function object in C extern "C" void cad_del_fun(cad_fun *fun) -{ // make sure this pointer has been allocated - pop_allocated( fun->p_void ); +{ // make sure this pointer has been allocated + pop_allocated( fun->p_void ); - ADFun* p_adfun - = reinterpret_cast< ADFun* > (fun->p_void); - delete p_adfun; + ADFun* p_adfun + = reinterpret_cast< ADFun* > (fun->p_void); + delete p_adfun; - // special value for pointers that are not allocated - fun->p_void = 0; + // special value for pointers that are not allocated + fun->p_void = 0; } // evaluate the Jacobian corresponding to a function object extern "C" void cad_jacobian(cad_fun fun, - size_t n, size_t m, double* px, double* pjac ) -{ assert( fun.p_void != 0 ); + size_t n, size_t m, double* px, double* pjac ) +{ assert( fun.p_void != 0 ); - ADFun* p_adfun = - reinterpret_cast< ADFun* >(fun.p_void); - vector x(n), jac(n * m); - - double2vector(n, px, x); - jac = p_adfun->Jacobian(x); - vector2double(n * m, jac, pjac); + ADFun* p_adfun = + reinterpret_cast< ADFun* >(fun.p_void); + vector x(n), jac(n * m); + + double2vector(n, px, x); + jac = p_adfun->Jacobian(x); + vector2double(n * m, jac, pjac); } // forward mode extern "C" void cad_forward(cad_fun fun, - size_t order, size_t n, size_t m, double* px, double* py ) -{ assert( fun.p_void != 0 ); + size_t order, size_t n, size_t m, double* px, double* py ) +{ assert( fun.p_void != 0 ); - ADFun* p_adfun = - reinterpret_cast< ADFun* >(fun.p_void); - vector x(n), y(m); - - double2vector(n, px, x); - y = p_adfun->Forward(order, x); - vector2double(m, y, py); + ADFun* p_adfun = + reinterpret_cast< ADFun* >(fun.p_void); + vector x(n), y(m); + + double2vector(n, px, x); + y = p_adfun->Forward(order, x); + vector2double(m, y, py); } // check that allocated list has been completely freed extern "C" bool cad_allocated_empty(void) -{ return allocated.empty(); +{ return allocated.empty(); } } // End empty namespace **************************************************** @@ -353,128 +351,128 @@ // ------------------------------------------------------------------------- // Here is the C code that uses the CppAD link above bool ad_in_c(void) -{ // This routine is intentionally coded as if it were written in C - // as an example of how you can link C, and other languages to CppAD - bool ok = true; - - // x vector of AD objects in C - double value; - size_t j, n = N; - cad X[N]; - for(j = 0; j < n; j++) - { value = (double) (j+1) / (double) n; - X[j].p_void = 0; - cad_new_ad(X + j, value); - } - - // y vector of AD objects in C - size_t i, m = M; - cad Y[M]; - for(i = 0; i < m; i++) - { value = 0.; // required, but not used - Y[i].p_void = 0; - cad_new_ad(Y + i, value); - } - - // declare X as the independent variable vector - cad_independent(n, X); - - // y[0] = x[0] + x[1] - cad_binary(op_add, X+0, X+1, Y+0); - ok &= cad_near_equal( cad_value(Y+0), cad_value(X+0)+cad_value(X+1) ); - - // y[1] = x[0] - x[1] - cad_binary(op_sub, X+0, X+1, Y+1); - ok &= cad_near_equal( cad_value(Y+1), cad_value(X+0)-cad_value(X+1) ); - - // y[2] = x[0] * x[1] - cad_binary(op_mul, X+0, X+1, Y+2); - ok &= cad_near_equal( cad_value(Y+2), cad_value(X+0)*cad_value(X+1) ); - - // y[3] = x[0] * x[1] - cad_binary(op_div, X+0, X+1, Y+3); - ok &= cad_near_equal( cad_value(Y+3), cad_value(X+0)/cad_value(X+1) ); - - // y[4] = sin(x[0]) + asin(sin(x[0])) - cad sin_x0 = { 0 }; // initialize p_void as zero - cad_new_ad( &sin_x0, 0.); - cad_unary(op_sin, X+0, &sin_x0); - ok &= cad_near_equal(cad_value(&sin_x0), sin(cad_value(X+0)) ); - - 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), - asin( cad_value(&sin_x0) ) - ); - - cad_binary(op_add, &sin_x0, &asin_sin_x0, Y+4); - ok &= cad_near_equal( - 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); - - // now use the function object - double x[N], jac[N * M]; - x[0] = 1.; - x[1] = .5; - - // compute the Jacobian - cad_jacobian(f, n, m, x, jac); - - // check the Jacobian values - size_t k = 0; - // partial y[0] w.r.t. x[0] - ok &= cad_near_equal(jac[k++], 1.); - // partial y[0] w.r.t. x[1] - ok &= cad_near_equal(jac[k++], 1.); - // partial y[1] w.r.t. x[0] - ok &= cad_near_equal(jac[k++], 1.); - // partial y[1] w.r.t. x[1] - ok &= cad_near_equal(jac[k++], -1.); - // partial y[2] w.r.t. x[0] - ok &= cad_near_equal(jac[k++], x[1]); - // partial y[2] w.r.t. x[1] - ok &= cad_near_equal(jac[k++], x[0]); - // partial y[3] w.r.t. x[0] - ok &= cad_near_equal(jac[k++], 1./x[1]); - // partial y[3] w.r.t. x[1] - ok &= cad_near_equal(jac[k++], -x[0]/(x[1]*x[1])); - // partial y[4] w.r.t x[0] - ok &= cad_near_equal(jac[k++], cos(x[0]) + 1.); - // partial y[4] w.r.t x[1] - ok &= cad_near_equal(jac[k++], 0.); - - // evaluate the function f at a different x - size_t order = 0; - double y[M]; - x[0] = .5; - x[1] = 1.; - cad_forward(f, order, n, m, x, y); - - // check the function values - ok &= cad_near_equal(y[0] , x[0] + x[1] ); - ok &= cad_near_equal(y[1] , x[0] - x[1] ); - ok &= cad_near_equal(y[2] , x[0] * x[1] ); - ok &= cad_near_equal(y[3] , x[0] / x[1] ); - ok &= cad_near_equal(y[4] , sin(x[0]) + asin(sin(x[0])) ); - - // delete All C++ copies of the AD objects - cad_del_fun( &f ); - cad_del_ad( &sin_x0 ); - cad_del_ad( &asin_sin_x0 ); - for(j = 0; j < n; j++) - cad_del_ad(X + j); - for(i = 0; i < m; i++) - cad_del_ad(Y + i); +{ // This routine is intentionally coded as if it were written in C + // as an example of how you can link C, and other languages to CppAD + bool ok = true; + + // x vector of AD objects in C + double value; + size_t j, n = N; + cad X[N]; + for(j = 0; j < n; j++) + { value = (double) (j+1) / (double) n; + X[j].p_void = 0; + cad_new_ad(X + j, value); + } + + // y vector of AD objects in C + size_t i, m = M; + cad Y[M]; + for(i = 0; i < m; i++) + { value = 0.; // required, but not used + Y[i].p_void = 0; + cad_new_ad(Y + i, value); + } + + // declare X as the independent variable vector + cad_independent(n, X); + + // y[0] = x[0] + x[1] + cad_binary(op_add, X+0, X+1, Y+0); + ok &= cad_near_equal( cad_value(Y+0), cad_value(X+0)+cad_value(X+1) ); + + // y[1] = x[0] - x[1] + cad_binary(op_sub, X+0, X+1, Y+1); + ok &= cad_near_equal( cad_value(Y+1), cad_value(X+0)-cad_value(X+1) ); + + // y[2] = x[0] * x[1] + cad_binary(op_mul, X+0, X+1, Y+2); + ok &= cad_near_equal( cad_value(Y+2), cad_value(X+0)*cad_value(X+1) ); + + // y[3] = x[0] * x[1] + cad_binary(op_div, X+0, X+1, Y+3); + ok &= cad_near_equal( cad_value(Y+3), cad_value(X+0)/cad_value(X+1) ); + + // y[4] = sin(x[0]) + asin(sin(x[0])) + cad sin_x0 = { 0 }; // initialize p_void as zero + cad_new_ad( &sin_x0, 0.); + cad_unary(op_sin, X+0, &sin_x0); + ok &= cad_near_equal(cad_value(&sin_x0), sin(cad_value(X+0)) ); + + 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), + asin( cad_value(&sin_x0) ) + ); + + cad_binary(op_add, &sin_x0, &asin_sin_x0, Y+4); + ok &= cad_near_equal( + 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); + + // now use the function object + double x[N], jac[N * M]; + x[0] = 1.; + x[1] = .5; + + // compute the Jacobian + cad_jacobian(f, n, m, x, jac); + + // check the Jacobian values + size_t k = 0; + // partial y[0] w.r.t. x[0] + ok &= cad_near_equal(jac[k++], 1.); + // partial y[0] w.r.t. x[1] + ok &= cad_near_equal(jac[k++], 1.); + // partial y[1] w.r.t. x[0] + ok &= cad_near_equal(jac[k++], 1.); + // partial y[1] w.r.t. x[1] + ok &= cad_near_equal(jac[k++], -1.); + // partial y[2] w.r.t. x[0] + ok &= cad_near_equal(jac[k++], x[1]); + // partial y[2] w.r.t. x[1] + ok &= cad_near_equal(jac[k++], x[0]); + // partial y[3] w.r.t. x[0] + ok &= cad_near_equal(jac[k++], 1./x[1]); + // partial y[3] w.r.t. x[1] + ok &= cad_near_equal(jac[k++], -x[0]/(x[1]*x[1])); + // partial y[4] w.r.t x[0] + ok &= cad_near_equal(jac[k++], cos(x[0]) + 1.); + // partial y[4] w.r.t x[1] + ok &= cad_near_equal(jac[k++], 0.); + + // evaluate the function f at a different x + size_t order = 0; + double y[M]; + x[0] = .5; + x[1] = 1.; + cad_forward(f, order, n, m, x, y); + + // check the function values + ok &= cad_near_equal(y[0] , x[0] + x[1] ); + ok &= cad_near_equal(y[1] , x[0] - x[1] ); + ok &= cad_near_equal(y[2] , x[0] * x[1] ); + ok &= cad_near_equal(y[3] , x[0] / x[1] ); + ok &= cad_near_equal(y[4] , sin(x[0]) + asin(sin(x[0])) ); + + // delete All C++ copies of the AD objects + cad_del_fun( &f ); + cad_del_ad( &sin_x0 ); + cad_del_ad( &asin_sin_x0 ); + for(j = 0; j < n; j++) + cad_del_ad(X + j); + for(i = 0; i < m; i++) + cad_del_ad(Y + i); - ok &= cad_allocated_empty(); - return ok; + ok &= cad_allocated_empty(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/ad_input.cpp cppad-2019.02.00.0/example/general/ad_input.cpp --- cppad-2018.00.00.0/example/general/ad_input.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/ad_input.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ad_input.cpp$$ $spell - Cpp - cstddef + Cpp + cstddef $$ $section AD Output Operator: Example and Test$$ -$mindex << input$$ -$code $srcfile%example/general/ad_input.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -34,29 +32,29 @@ # include // std::string bool ad_input(void) -{ bool ok = true; +{ bool ok = true; - // create the input string stream is. - std::string str ("123 456"); - std::istringstream is(str); - - // start and AD recording - CPPAD_TESTVECTOR( CppAD::AD ) x(1), y(1); - x[0] = 1.0; - CppAD::Independent(x); - CppAD::AD z = x[0]; - ok &= Variable(z); - - // 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 - CppAD::ADFun f(x, y); + // create the input string stream is. + std::string str ("123 456"); + std::istringstream is(str); + + // start and AD recording + CPPAD_TESTVECTOR( CppAD::AD ) x(1), y(1); + x[0] = 1.0; + CppAD::Independent(x); + CppAD::AD z = x[0]; + ok &= Variable(z); + + // 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 + CppAD::ADFun f(x, y); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/ad_output.cpp cppad-2019.02.00.0/example/general/ad_output.cpp --- cppad-2018.00.00.0/example/general/ad_output.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/ad_output.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ad_output.cpp$$ $spell - Cpp - cstddef + Cpp + cstddef $$ $section AD Output Operator: Example and Test$$ -$mindex <<$$ -$code $srcfile%example/general/ad_output.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -35,41 +33,41 @@ # include // std::setprecision, setw, setfill, right namespace { - template - void set_ostream(S &os) - { os - << std::setprecision(4) // 4 digits of precision - << std::setw(6) // 6 characters per field - << std::setfill(' ') // fill with spaces - << std::right; // adjust value to the right - } + template + void set_ostream(S &os) + { os + << std::setprecision(4) // 4 digits of precision + << std::setw(6) // 6 characters per field + << std::setfill(' ') // fill with spaces + << std::right; // adjust value to the right + } } bool ad_output(void) -{ bool ok = true; +{ bool ok = true; - // This output stream is an ostringstream for testing purposes. - // You can use << with other types of streams; i.e., std::cout. - std::ostringstream stream; - - // ouput an AD object - CppAD::AD pi = 4. * atan(1.); // 3.1415926536 - set_ostream(stream); - stream << pi; - - // ouput a VecAD::reference object - CppAD::VecAD v(1); - CppAD::AD zero(0); - v[zero] = exp(1.); // 2.7182818285 - set_ostream(stream); - stream << v[zero]; + // This output stream is an ostringstream for testing purposes. + // You can use << with other types of streams; i.e., std::cout. + std::ostringstream stream; + + // ouput an AD object + CppAD::AD pi = 4. * atan(1.); // 3.1415926536 + set_ostream(stream); + stream << pi; + + // ouput a VecAD::reference object + CppAD::VecAD v(1); + CppAD::AD zero(0); + v[zero] = exp(1.); // 2.7182818285 + set_ostream(stream); + stream << v[zero]; - // convert output from stream to string - std::string str = stream.str(); + // convert output from stream to string + std::string str = stream.str(); - // check the output - ok &= (str == " 3.142 2.718"); + // check the output + ok &= (str == " 3.142 2.718"); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/asin.cpp cppad-2019.02.00.0/example/general/asin.cpp --- cppad-2018.00.00.0/example/general/asin.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/asin.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin asin.cpp$$ $spell - sin - asin + sin + asin $$ $section The AD asin Function: Example and Test$$ -$code $srcfile%example/general/asin.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,59 +28,59 @@ # include bool asin(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; + using CppAD::AD; + using CppAD::NearEqual; - // 10 times machine epsilon - double eps = 10. * std::numeric_limits::epsilon(); + // 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 sin_of_x0 = CppAD::sin(x[0]); - - // 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); - - // 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 asin - CppAD::VecAD v(1); - AD zero(0); - v[zero] = sin_of_x0; - AD result = CppAD::asin(v[zero]); - ok &= NearEqual(result, x0, eps, eps); + // 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 sin_of_x0 = CppAD::sin(x[0]); + + // 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); + + // 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 asin + CppAD::VecAD v(1); + AD zero(0); + v[zero] = sin_of_x0; + AD result = CppAD::asin(v[zero]); + ok &= NearEqual(result, x0, eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/asinh.cpp cppad-2019.02.00.0/example/general/asinh.cpp --- cppad-2018.00.00.0/example/general/asinh.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/asinh.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin asinh.cpp$$ $spell - sinh - asinh + sinh + asinh $$ $section The AD asinh Function: Example and Test$$ -$code $srcfile%example/general/asinh.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,59 +28,59 @@ # include bool asinh(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; + using CppAD::AD; + using CppAD::NearEqual; - // 10 times machine epsilon - double eps = 10. * std::numeric_limits::epsilon(); + // 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); + // 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/atan2.cpp cppad-2019.02.00.0/example/general/atan2.cpp --- cppad-2018.00.00.0/example/general/atan2.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/general/atan2.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin atan2.cpp$$ $spell - tan - atan + tan + atan $$ $section The AD atan2 Function: Example and Test$$ -$code $srcfile%example/general/atan2.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,60 +29,60 @@ # include bool atan2(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * 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 sin_of_x0 = CppAD::sin(x[0]); - AD cos_of_x0 = CppAD::cos(x[0]); - - // 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); - - // check value - ok &= NearEqual(y[0] , x0, eps99, eps99); - - // 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., eps99, eps99); - - // 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., eps99, eps99); - - // use a VecAD::reference object with atan2 - CppAD::VecAD v(2); - AD zero(0); - AD one(1); - v[zero] = sin_of_x0; - v[one] = cos_of_x0; - AD result = CppAD::atan2(v[zero], v[one]); - ok &= NearEqual(result, x0, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * 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 sin_of_x0 = CppAD::sin(x[0]); + AD cos_of_x0 = CppAD::cos(x[0]); + + // 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); + + // check value + ok &= NearEqual(y[0] , x0, eps99, eps99); + + // 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., eps99, eps99); + + // 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., eps99, eps99); + + // use a VecAD::reference object with atan2 + CppAD::VecAD v(2); + AD zero(0); + AD one(1); + v[zero] = sin_of_x0; + v[one] = cos_of_x0; + AD result = CppAD::atan2(v[zero], v[one]); + ok &= NearEqual(result, x0, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/atan.cpp cppad-2019.02.00.0/example/general/atan.cpp --- cppad-2018.00.00.0/example/general/atan.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/atan.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin atan.cpp$$ $spell - tan - atan + tan + atan $$ $section The AD atan Function: Example and Test$$ -$code $srcfile%example/general/atan.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,57 +29,57 @@ # include bool atan(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * 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 tan_of_x0 = CppAD::tan(x[0]); - - // 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); - - // check value - ok &= NearEqual(y[0] , x0, eps99, eps99); - - // 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., eps99, eps99); - - // 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., eps99, eps99); - - // use a VecAD::reference object with atan - CppAD::VecAD v(1); - AD zero(0); - v[zero] = tan_of_x0; - AD result = CppAD::atan(v[zero]); - ok &= NearEqual(result, x0, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * 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 tan_of_x0 = CppAD::tan(x[0]); + + // 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); + + // check value + ok &= NearEqual(y[0] , x0, eps99, eps99); + + // 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., eps99, eps99); + + // 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., eps99, eps99); + + // use a VecAD::reference object with atan + CppAD::VecAD v(1); + AD zero(0); + v[zero] = tan_of_x0; + AD result = CppAD::atan(v[zero]); + ok &= NearEqual(result, x0, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/atanh.cpp cppad-2019.02.00.0/example/general/atanh.cpp --- cppad-2018.00.00.0/example/general/atanh.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/atanh.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin atanh.cpp$$ $spell - tanh - atanh + tanh + atanh $$ $section The AD atanh Function: Example and Test$$ -$code $srcfile%example/general/atanh.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,59 +28,59 @@ # include bool atanh(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; + using CppAD::AD; + using CppAD::NearEqual; - // 10 times machine epsilon - double eps = 10. * std::numeric_limits::epsilon(); + // 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); + // 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/azmul.cpp cppad-2019.02.00.0/example/general/azmul.cpp --- cppad-2018.00.00.0/example/general/azmul.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/azmul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin azmul.cpp$$ @@ -16,9 +17,7 @@ $section AD Absolute Zero Multiplication: Example and Test$$ -$code $srcfile%example/general/azmul.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -28,56 +27,56 @@ # include bool azmul(void) -{ bool ok = true; +{ 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; + 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/base2ad.cpp cppad-2019.02.00.0/example/general/base2ad.cpp --- cppad-2018.00.00.0/example/general/base2ad.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/general/base2ad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,268 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin base2ad.cpp$$ +$spell + Taylor + Cpp + const + std + Adolc + adouble +$$ + +$section Taylor's Ode Solver: base2ad Example and Test$$ + +$head See Also$$ +$cref taylor_ode.cpp$$, $cref mul_level_ode.cpp$$ + +$head Purpose$$ +This is a realistic example using $cref base2ad$$ to create +an $codei%AD<%Base%>%$$ function from an $icode Base$$ function. +The function represents an ordinary differential equation. +It is differentiated with respect to +its $cref/variables/glossary/Variable/$$. +These derivatives are used by the $cref taylor_ode$$ method. +This solution is then differentiated with respect to +the functions $cref/dynamic parameters/glossary/Parameter/Dynamic/$$. + +$head ODE$$ +For this example the function +$latex y : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ is defined by +$latex y(0, x) = 0$$ and +$latex \partial_t y(t, x) = g(y, x)$$ where +$latex g : \B{R}^n \times \B{R}^n \rightarrow \B{R}^n$$ is defined by +$latex \[ + g(y, x) = + \left( \begin{array}{c} + x_0 \\ + x_1 y_0 \\ + \vdots \\ + x_{n-1} y_{n-2} + \end{array} \right) +\] $$ + +$head ODE Solution$$ +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 +$latex \[ + y(t, x ) = + \left( \begin{array}{c} + x_0 t \\ + x_1 x_0 t^2 / 2 \\ + \vdots \\ + x_{n-1} x_{n-2} \ldots x_0 t^n / n ! + \end{array} \right) +\] $$ + +$head Derivative of ODE Solution$$ +Differentiating the solution above, +with respect to the parameter vector $latex x$$, +we notice that +$latex \[ +\partial_x y(t, x ) = +\left( \begin{array}{cccc} +y_0 (t,x) / x_0 & 0 & \cdots & 0 \\ +y_1 (t,x) / x_0 & y_1 (t,x) / x_1 & 0 & \vdots \\ +\vdots & \vdots & \ddots & 0 \\ +y_{n-1} (t,x) / x_0 & y_{n-1} (t,x) / x_1 & \cdots & y_{n-1} (t,x) / x_{n-1} +\end{array} \right) +\] $$ + +$head Taylor's Method Using AD$$ +We define the function $latex z(t, x)$$ by the equation +$latex \[ + z ( t , x ) = g[ y ( t , x ), x ] +\] $$ +see $cref taylor_ode$$ for the method used to compute the +Taylor coefficients w.r.t $latex t$$ of $latex y(t, x)$$. + +$head Source$$ +$srcfile%example/general/base2ad.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +-------------------------------------------------------------------------- +*/ +// BEGIN C++ + +# include + +// ========================================================================= +namespace { // BEGIN empty namespace + +typedef CppAD::AD a_double; + +typedef CPPAD_TESTVECTOR(double) d_vector; +typedef CPPAD_TESTVECTOR(a_double) a_vector; + +typedef CppAD::ADFun fun_double; +typedef CppAD::ADFun afun_double; + +// ------------------------------------------------------------------------- +// class definition for C++ function object that defines ODE +class Ode { +private: + // copy of x that is set by constructor and used by g(y) + a_vector x_; +public: + // constructor + Ode(const a_vector& x) : x_(x) + { } + // the function g(y) given the parameter vector x + a_vector operator() (const a_vector& y) const + { size_t n = y.size(); + a_vector g(n); + g[0] = x_[0]; + for(size_t i = 1; i < n; i++) + g[i] = x_[i] * y[i-1]; + // + return g; + } +}; + +// ------------------------------------------------------------------------- +// Routine that uses Taylor's method to solve ordinary differential equaitons +a_vector taylor_ode( + afun_double& fun_g , // function that defines the ODE + size_t order , // order of Taylor's method used + size_t nstep , // number of steps to take + const a_double& dt , // Delta t for each step + const a_vector& y_ini) // y(t) at the initial time +{ + // number of variables in the ODE + size_t n = y_ini.size(); + + // initialize y + a_vector y = y_ini; + + // loop with respect to each step of Taylors method + for(size_t s = 0; s < nstep; s++) + { + // initialize + a_vector y_k = y; + a_double dt_k = a_double(1.0); + a_vector next = y; + + for(size_t k = 0; k < order; k++) + { + // evaluate k-th order Taylor coefficient z^{(k)} (t) + a_vector z_k = fun_g.Forward(k, y_k); + + // dt^{k+1} + dt_k *= dt; + + // y^{(k+1)} + for(size_t i = 0; i < n; i++) + { // y^{(k+1)} + y_k[i] = z_k[i] / a_double(k + 1); + + // add term for k+1 Taylor coefficient + // to solution for next y + next[i] += y_k[i] * dt_k; + } + } + + // take step + y = next; + } + return y; +} +} // END empty namespace + +// ========================================================================== +// Routine that tests alogirhtmic differentiation of solutions computed +// by the routine taylor_ode. +bool base2ad(void) +{ bool ok = true; + double eps = 100. * std::numeric_limits::epsilon(); + + // number of components in differential equation + size_t n = 4; + + // record function g(y, x) + // with y as the independent variables and x as dynamic parameters + a_vector ay(n), ax(n); + for(size_t i = 0; i < n; i++) + ay[i] = ax[i] = double(i + 1); + size_t abort_op_index = 0; + bool record_compare = true; + CppAD::Independent(ay, abort_op_index, record_compare, ax); + + // fun_g + Ode G(ax); + a_vector ag = G(ay); + fun_double fun_g(ay, ag); + + + // afun_g + afun_double afun_g; + afun_g = fun_g.base2ad(); // differential equation + + // other arguments to taylor_ode + size_t order = n; // order of Taylor's method used + size_t nstep = 2; // number of steps to take + a_double adt = 1.; // Delta t for each step + a_vector ay_ini(n); // initial value of y + for(size_t i = 0; i < n; i++) + ay_ini[i] = 0.; + + // declare x as independent variables + CppAD::Independent(ax); + + // the independent variables if this function are + // the dynamic parameters in afun_g + afun_g.new_dynamic(ax); + + // integrate the differential equation + a_vector ay_final; + ay_final = taylor_ode(afun_g, order, nstep, adt, ay_ini); + + // define differentiable fucntion object f(x) = y_final(x) + // that computes its derivatives in double + CppAD::ADFun fun_f(ax, ay_final); + + // double version of ax + d_vector x(n); + for(size_t i = 0; i < n; i++) + x[i] = Value( ax[i] ); + + // check function values + double check = 1.; + double t = double(nstep) * Value(adt); + for(size_t i = 0; i < n; i++) + { check *= x[i] * t / double(i + 1); + ok &= CppAD::NearEqual(Value(ay_final[i]), check, eps, eps); + } + + // There appears to be a bug in g++ version 4.4.2 because it generates + // a warning for the equivalent form + // d_vector jac = fun_f.Jacobian(x); + d_vector jac ( fun_f.Jacobian(x) ); + + // check Jacobian + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n; j++) + { double jac_ij = jac[i * n + j]; + if( i < j ) + check = 0.; + else + check = Value( ay_final[i] ) / x[j]; + ok &= CppAD::NearEqual(jac_ij, check, eps, eps); + } + } + return ok; +} + +// END C++ diff -Nru cppad-2018.00.00.0/example/general/base_alloc.hpp cppad-2019.02.00.0/example/general/base_alloc.hpp --- cppad-2018.00.00.0/example/general/base_alloc.hpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/base_alloc.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,50 +1,51 @@ # ifndef CPPAD_EXAMPLE_GENERAL_BASE_ALLOC_HPP # define CPPAD_EXAMPLE_GENERAL_BASE_ALLOC_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin base_alloc.hpp$$ $spell - azmul - expm1 - atanh - acosh - asinh - Rel - Lt Le Eq Ge Gt - Cond - enum - geq - cos - sqrt - cppad.hpp - alloc - op - const - ptrdbl - bool - CppAD - sizeof - inline - atan - ostream - namespace - exp - tanh - acos - asin - std - fabs - erf - endif + azmul + expm1 + atanh + acosh + asinh + Rel + Lt Le Eq Ge Gt + Cond + enum + geq + cos + sqrt + cppad.hpp + alloc + op + const + ptrdbl + bool + CppAD + sizeof + inline + atan + ostream + namespace + exp + tanh + acos + asin + std + fabs + erf + endif $$ $section Example AD Where Base Constructor Allocates Memory$$ @@ -74,8 +75,8 @@ $code /=$$. $srccode%cpp% */ # define BASE_ALLOC_ASSIGN_OPERATOR(op) \ - void operator op (const base_alloc& x) \ - { *ptrdbl_ op *x.ptrdbl_; } + void operator op (const base_alloc& x) \ + { *ptrdbl_ op *x.ptrdbl_; } /* %$$ $head Binary Operator Macro$$ @@ -88,13 +89,13 @@ $code /$$. $srccode%cpp% */ # define BASE_ALLOC_BINARY_OPERATOR(op) const \ - base_alloc operator op (const base_alloc& x) const \ - { base_alloc result; \ - double dbl = *ptrdbl_; \ - double x_dbl = *x.ptrdbl_; \ - *result.ptrdbl_ = dbl op x_dbl; \ - return result; \ - } + base_alloc operator op (const base_alloc& x) const \ + { base_alloc result; \ + double dbl = *ptrdbl_; \ + double x_dbl = *x.ptrdbl_; \ + *result.ptrdbl_ = dbl op x_dbl; \ + return result; \ + } /* %$$ $head Boolean Operator Macro$$ @@ -110,11 +111,11 @@ $code >$$, $srccode%cpp% */ # define BASE_ALLOC_BOOL_OPERATOR(op) const \ - bool operator op (const base_alloc& x) const \ - { double dbl = *ptrdbl_; \ - double x_dbl = *x.ptrdbl_; \ - return dbl op x_dbl; \ - } + bool operator op (const base_alloc& x) const \ + { double dbl = *ptrdbl_; \ + double x_dbl = *x.ptrdbl_; \ + return dbl op x_dbl; \ + } /* %$$ $head Class Definition$$ @@ -126,51 +127,51 @@ class base_alloc { public: - double* ptrdbl_; + double* ptrdbl_; - base_alloc(void) - { size_t 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); - 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); - ptrdbl_ = static_cast(v); - *ptrdbl_ = *x.ptrdbl_; - } - ~base_alloc(void) - { void* v = static_cast(ptrdbl_); - CppAD::thread_alloc::return_memory(v); - } - base_alloc operator-(void) const - { base_alloc result; - *result.ptrdbl_ = - *ptrdbl_; - return result; - } - base_alloc operator+(void) const - { return *this; } - void operator=(const base_alloc& x) - { *ptrdbl_ = *x.ptrdbl_; } - BASE_ALLOC_ASSIGN_OPERATOR(+=) - BASE_ALLOC_ASSIGN_OPERATOR(-=) - BASE_ALLOC_ASSIGN_OPERATOR(*=) - BASE_ALLOC_ASSIGN_OPERATOR(/=) - BASE_ALLOC_BINARY_OPERATOR(+) - BASE_ALLOC_BINARY_OPERATOR(-) - BASE_ALLOC_BINARY_OPERATOR(*) - BASE_ALLOC_BINARY_OPERATOR(/) - BASE_ALLOC_BOOL_OPERATOR(==) - BASE_ALLOC_BOOL_OPERATOR(!=) - // The <= operator is not necessary for the base type requirements - // (needed so we can use NearEqual with base_alloc arguments). - BASE_ALLOC_BOOL_OPERATOR(<=) + base_alloc(void) + { size_t 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); + 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); + ptrdbl_ = static_cast(v); + *ptrdbl_ = *x.ptrdbl_; + } + ~base_alloc(void) + { void* v = static_cast(ptrdbl_); + CppAD::thread_alloc::return_memory(v); + } + base_alloc operator-(void) const + { base_alloc result; + *result.ptrdbl_ = - *ptrdbl_; + return result; + } + base_alloc operator+(void) const + { return *this; } + void operator=(const base_alloc& x) + { *ptrdbl_ = *x.ptrdbl_; } + BASE_ALLOC_ASSIGN_OPERATOR(+=) + BASE_ALLOC_ASSIGN_OPERATOR(-=) + BASE_ALLOC_ASSIGN_OPERATOR(*=) + BASE_ALLOC_ASSIGN_OPERATOR(/=) + BASE_ALLOC_BINARY_OPERATOR(+) + BASE_ALLOC_BINARY_OPERATOR(-) + BASE_ALLOC_BINARY_OPERATOR(*) + BASE_ALLOC_BINARY_OPERATOR(/) + BASE_ALLOC_BOOL_OPERATOR(==) + BASE_ALLOC_BOOL_OPERATOR(!=) + // The <= operator is not necessary for the base type requirements + // (needed so we can use NearEqual with base_alloc arguments). + BASE_ALLOC_BOOL_OPERATOR(<=) }; /* %$$ @@ -179,18 +180,18 @@ Hence its $code CondExpOp$$ function is defined by $srccode%cpp% */ namespace CppAD { - inline base_alloc CondExpOp( - enum CompareOp cop , - const base_alloc& left , - const base_alloc& right , - const base_alloc& exp_if_true , - const base_alloc& exp_if_false ) - { // not used - assert(false); - - // to void compiler error - return base_alloc(); - } + inline base_alloc CondExpOp( + enum CompareOp cop , + const base_alloc& left , + const base_alloc& right , + const base_alloc& exp_if_true , + const base_alloc& exp_if_false ) + { // not used + assert(false); + + // to void compiler error + return base_alloc(); + } } /* %$$ @@ -198,7 +199,7 @@ The $cref/CPPAD_COND_EXP_REL/base_cond_exp/CondExpRel/$$ macro invocation $srccode%cpp% */ namespace CppAD { - CPPAD_COND_EXP_REL(base_alloc) + CPPAD_COND_EXP_REL(base_alloc) } /* %$$ uses $code CondExpOp$$ above to @@ -210,8 +211,8 @@ The type $code base_alloc$$ is simple (in this respect) and so we define $srccode%cpp% */ namespace CppAD { - inline bool EqualOpSeq(const base_alloc& x, const base_alloc& y) - { return *x.ptrdbl_ == *y.ptrdbl_; } + inline bool EqualOpSeq(const base_alloc& x, const base_alloc& y) + { return *x.ptrdbl_ == *y.ptrdbl_; } } /* %$$ @@ -219,39 +220,39 @@ The type $code base_alloc$$ is simple (in this respect) and so we define $srccode%cpp% */ namespace CppAD { - inline bool IdenticalPar(const base_alloc& x) - { return true; } - inline bool IdenticalZero(const base_alloc& x) - { return (*x.ptrdbl_ == 0.0); } - inline bool IdenticalOne(const base_alloc& x) - { return (*x.ptrdbl_ == 1.0); } - inline bool IdenticalEqualPar(const base_alloc& x, const base_alloc& y) - { return (*x.ptrdbl_ == *y.ptrdbl_); } + inline bool IdenticalCon(const base_alloc& x) + { return true; } + inline bool IdenticalZero(const base_alloc& x) + { return (*x.ptrdbl_ == 0.0); } + inline bool IdenticalOne(const base_alloc& x) + { return (*x.ptrdbl_ == 1.0); } + inline bool IdenticalEqualCon(const base_alloc& x, const base_alloc& y) + { return (*x.ptrdbl_ == *y.ptrdbl_); } } /* %$$ $head Output Operator$$ $srccode%cpp% */ namespace CppAD { - std::ostream& operator << (std::ostream &os, const base_alloc& x) - { os << *x.ptrdbl_; - return os; - } + inline std::ostream& operator << (std::ostream &os, const base_alloc& x) + { os << *x.ptrdbl_; + return os; + } } /* %$$ $head Integer$$ $srccode%cpp% */ namespace CppAD { - inline int Integer(const base_alloc& x) - { return static_cast(*x.ptrdbl_); } + inline int Integer(const base_alloc& x) + { return static_cast(*x.ptrdbl_); } } /* %$$ $head azmul$$ $srccode%cpp% */ namespace CppAD { - CPPAD_AZMUL( base_alloc ) + CPPAD_AZMUL( base_alloc ) } /* %$$ @@ -259,16 +260,16 @@ The $code base_alloc$$ type supports ordered comparisons $srccode%cpp% */ namespace CppAD { - inline bool GreaterThanZero(const base_alloc& x) - { return *x.ptrdbl_ > 0.0; } - inline bool GreaterThanOrZero(const base_alloc& x) - { return *x.ptrdbl_ >= 0.0; } - inline bool LessThanZero(const base_alloc& x) - { return *x.ptrdbl_ < 0.0; } - inline bool LessThanOrZero(const base_alloc& x) - { return *x.ptrdbl_ <= 0.f; } - inline bool abs_geq(const base_alloc& x, const base_alloc& y) - { return std::fabs(*x.ptrdbl_) >= std::fabs(*y.ptrdbl_); } + inline bool GreaterThanZero(const base_alloc& x) + { return *x.ptrdbl_ > 0.0; } + inline bool GreaterThanOrZero(const base_alloc& x) + { return *x.ptrdbl_ >= 0.0; } + inline bool LessThanZero(const base_alloc& x) + { return *x.ptrdbl_ < 0.0; } + inline bool LessThanOrZero(const base_alloc& x) + { return *x.ptrdbl_ <= 0.f; } + inline bool abs_geq(const base_alloc& x, const base_alloc& y) + { return std::fabs(*x.ptrdbl_) >= std::fabs(*y.ptrdbl_); } } /* %$$ @@ -279,54 +280,54 @@ a special macro for this type: $srccode%cpp% */ # define BASE_ALLOC_STD_MATH(fun) \ - inline base_alloc fun (const base_alloc& x) \ - { return std::fun(*x.ptrdbl_); } + inline base_alloc fun (const base_alloc& x) \ + { return std::fun(*x.ptrdbl_); } /* %$$ The following invocations of the macro above define the $cref/unary standard math/base_std_math/Unary Standard Math/$$ functions (except for $code abs$$): $srccode%cpp% */ namespace CppAD { - BASE_ALLOC_STD_MATH(acos) - BASE_ALLOC_STD_MATH(asin) - BASE_ALLOC_STD_MATH(atan) - BASE_ALLOC_STD_MATH(cos) - BASE_ALLOC_STD_MATH(cosh) - BASE_ALLOC_STD_MATH(exp) - BASE_ALLOC_STD_MATH(fabs) - BASE_ALLOC_STD_MATH(log) - BASE_ALLOC_STD_MATH(log10) - BASE_ALLOC_STD_MATH(sin) - BASE_ALLOC_STD_MATH(sinh) - BASE_ALLOC_STD_MATH(sqrt) - BASE_ALLOC_STD_MATH(tan) - BASE_ALLOC_STD_MATH(tanh) + BASE_ALLOC_STD_MATH(acos) + BASE_ALLOC_STD_MATH(asin) + BASE_ALLOC_STD_MATH(atan) + BASE_ALLOC_STD_MATH(cos) + BASE_ALLOC_STD_MATH(cosh) + BASE_ALLOC_STD_MATH(exp) + BASE_ALLOC_STD_MATH(fabs) + BASE_ALLOC_STD_MATH(log) + BASE_ALLOC_STD_MATH(log10) + BASE_ALLOC_STD_MATH(sin) + BASE_ALLOC_STD_MATH(sinh) + BASE_ALLOC_STD_MATH(sqrt) + BASE_ALLOC_STD_MATH(tan) + BASE_ALLOC_STD_MATH(tanh) } /* %$$ The absolute value function is special because it $code std$$ name is $code fabs$$ $srccode%cpp% */ namespace CppAD { - inline base_alloc abs(const base_alloc& x) - { return fabs(x); } + inline base_alloc abs(const base_alloc& x) + { return fabs(x); } } /* %$$ $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 + /base_std_math + /erf, asinh, acosh, atanh, expm1, log1p /$$ functions required by $code AD$$: $srccode%cpp% */ # 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) + 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 /* %$$ @@ -335,13 +336,13 @@ is required to use $code AD$$: $srccode%cpp% */ namespace CppAD { - inline base_alloc sign(const base_alloc& x) - { if( *x.ptrdbl_ > 0.0 ) - return 1.0; - if( *x.ptrdbl_ == 0.0 ) - return 0.0; - return -1.0; - } + inline base_alloc sign(const base_alloc& x) + { if( *x.ptrdbl_ > 0.0 ) + return 1.0; + if( *x.ptrdbl_ == 0.0 ) + return 0.0; + return -1.0; + } } /* %$$ @@ -350,8 +351,8 @@ is required to use $code AD$$: $srccode%cpp% */ namespace CppAD { - inline base_alloc pow(const base_alloc& x, const base_alloc& y) - { return std::pow(*x.ptrdbl_, *y.ptrdbl_); } + inline base_alloc pow(const base_alloc& x, const base_alloc& y) + { return std::pow(*x.ptrdbl_, *y.ptrdbl_); } } /* %$$ @@ -360,7 +361,7 @@ for the type $code base_alloc$$: $srccode%cpp% */ namespace CppAD { - CPPAD_NUMERIC_LIMITS(double, base_alloc) + CPPAD_NUMERIC_LIMITS(double, base_alloc) } /* %$$ @@ -369,7 +370,7 @@ for the type $code base_alloc$$: $srccode%cpp% */ namespace CppAD { - CPPAD_TO_STRING(base_alloc) + CPPAD_TO_STRING(base_alloc) } /* %$$ @@ -379,18 +380,18 @@ have the same value. $srccode|cpp| */ namespace CppAD { - inline unsigned short hash_code(const base_alloc& x) - { unsigned short code = 0; - if( *x.ptrdbl_ == 0.0 ) - return code; - double log_x = log( std::fabs( *x.ptrdbl_ ) ); - // assume log( std::numeric_limits::max() ) is near 700 - code = static_cast( - (CPPAD_HASH_TABLE_SIZE / 700 + 1) * log_x - ); - code = code % CPPAD_HASH_TABLE_SIZE; - return code; - } + inline unsigned short hash_code(const base_alloc& x) + { unsigned short code = 0; + if( *x.ptrdbl_ == 0.0 ) + return code; + double log_x = log( std::fabs( *x.ptrdbl_ ) ); + // assume log( std::numeric_limits::max() ) is near 700 + code = static_cast( + (CPPAD_HASH_TABLE_SIZE / 700 + 1) * log_x + ); + code = code % CPPAD_HASH_TABLE_SIZE; + return code; + } } /* |$$ $end diff -Nru cppad-2018.00.00.0/example/general/base_require.cpp cppad-2019.02.00.0/example/general/base_require.cpp --- cppad-2018.00.00.0/example/general/base_require.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/base_require.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin base_require.cpp$$ $spell - alloc + alloc $$ $section Using a User Defined AD Base Type: Example and Test$$ -$mindex type$$ -$code $srcfile%example/general/base_require.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $head Purpose$$ The type $code base_alloc$$, defined in $cref base_alloc.hpp$$, @@ -38,35 +36,35 @@ # include bool base_require(void) -{ bool ok = true; - using CppAD::thread_alloc; - typedef CppAD::AD ad_base_alloc; - - // check the amount of memory inuse by this thread (thread zero) - size_t thread = thread_alloc::thread_num(); - ok &= thread == 0; - - // y = x^2 - size_t n = 1, m = 1; - CPPAD_TESTVECTOR(ad_base_alloc) a_x(n), a_y(m); - a_x[0] = ad_base_alloc(1.); - CppAD::Independent(a_x); - a_y[0] = a_x[0] * a_x[0]; - CppAD::ADFun f(a_x, a_y); - - // check function value f(x) = x^2 - CPPAD_TESTVECTOR(base_alloc) x(n), y(m); - base_alloc eps = - base_alloc(100.) * CppAD::numeric_limits::epsilon(); - x[0] = base_alloc(3.); - y = f.Forward(0, x); - ok &= CppAD::NearEqual(y[0], x[0] * x[0], eps, eps); - - // check derivative value f'(x) = 2 * x - CPPAD_TESTVECTOR(base_alloc) dy(m * n); - dy = f.Jacobian(x); - ok &= CppAD::NearEqual(dy[0], base_alloc(2.) * x[0], eps, eps); +{ bool ok = true; + using CppAD::thread_alloc; + typedef CppAD::AD ad_base_alloc; + + // check the amount of memory inuse by this thread (thread zero) + size_t thread = thread_alloc::thread_num(); + ok &= thread == 0; + + // y = x^2 + size_t n = 1, m = 1; + CPPAD_TESTVECTOR(ad_base_alloc) a_x(n), a_y(m); + a_x[0] = ad_base_alloc(1.); + CppAD::Independent(a_x); + a_y[0] = a_x[0] * a_x[0]; + CppAD::ADFun f(a_x, a_y); + + // check function value f(x) = x^2 + CPPAD_TESTVECTOR(base_alloc) x(n), y(m); + base_alloc eps = + base_alloc(100.) * CppAD::numeric_limits::epsilon(); + x[0] = base_alloc(3.); + y = f.Forward(0, x); + ok &= CppAD::NearEqual(y[0], x[0] * x[0], eps, eps); + + // check derivative value f'(x) = 2 * x + CPPAD_TESTVECTOR(base_alloc) dy(m * n); + dy = f.Jacobian(x); + ok &= CppAD::NearEqual(dy[0], base_alloc(2.) * x[0], eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/bender_quad.cpp cppad-2019.02.00.0/example/general/bender_quad.cpp --- cppad-2018.00.00.0/example/general/bender_quad.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/bender_quad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,22 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin bender_quad.cpp$$ $spell - argmin + argmin $$ $section BenderQuad: Example and Test$$ -$mindex BenderQuad$$ Define @@ -49,17 +49,15 @@ \\ & = & \left. - \sum_{i=1}^N z_i \sin ( x t_i ) - \right/ - \sum_{i=1}^N z_i \sin ( x * t_i )^2 + \sum_{i=1}^N z_i \sin ( x t_i ) + \right/ + \sum_{i=1}^N z_i \sin ( x * t_i )^2 \end{array} \] $$ -$code $srcfile%example/general/bender_quad.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -68,149 +66,149 @@ # include namespace { - using CppAD::AD; - typedef CPPAD_TESTVECTOR(double) BAvector; - typedef CPPAD_TESTVECTOR(AD) ADvector; - - class Fun { - private: - BAvector t_; // measurement times - BAvector z_; // measurement values - public: - // constructor - Fun(const BAvector &t, const BAvector &z) - : t_(t), z_(z) - { } - // Fun.f(x, y) = F(x, y) - ADvector f(const ADvector &x, const ADvector &y) - { size_t i; - size_t N = size_t(z_.size()); - - ADvector F(1); - F[0] = 0.; - - AD residual; - for(i = 0; i < N; i++) - { residual = y[0] * sin( x[0] * t_[i] ) - z_[i]; - F[0] += .5 * residual * residual; - } - return F; - } - // Fun.h(x, y) = H(x, y) = F_y (x, y) - ADvector h(const ADvector &x, const BAvector &y) - { size_t i; - size_t N = size_t(z_.size()); - - ADvector fy(1); - fy[0] = 0.; - - AD residual; - for(i = 0; i < N; i++) - { residual = y[0] * sin( x[0] * t_[i] ) - z_[i]; - fy[0] += residual * sin( x[0] * t_[i] ); - } - return fy; - } - // 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 ADvector &H ) - { size_t i; - size_t N = size_t(z_.size()); - - ADvector Dy(1); - AD fyy = 0.; - - for(i = 0; i < N; i++) - { fyy += sin( x[0] * t_[i] ) * sin( x[0] * t_[i] ); - } - Dy[0] = - H[0] / fyy; - - return Dy; - } - }; - - // Used to test calculation of Hessian of G - AD G(const ADvector& x, const BAvector& t, const BAvector& z) - { // compute Y(x) - AD numerator = 0.; - AD denominator = 0.; - 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] ); - } - AD y = numerator / denominator; - - // V(x) = F[x, Y(x)] - AD sum = 0; - for(k = 0; k < size_t(t.size()); k++) - { AD residual = y * sin( x[0] * t[k] ) - z[k]; - sum += .5 * residual * residual; - } - return sum; - } + using CppAD::AD; + typedef CPPAD_TESTVECTOR(double) BAvector; + typedef CPPAD_TESTVECTOR(AD) ADvector; + + class Fun { + private: + BAvector t_; // measurement times + BAvector z_; // measurement values + public: + // constructor + Fun(const BAvector &t, const BAvector &z) + : t_(t), z_(z) + { } + // Fun.f(x, y) = F(x, y) + ADvector f(const ADvector &x, const ADvector &y) + { size_t i; + size_t N = size_t(z_.size()); + + ADvector F(1); + F[0] = 0.; + + AD residual; + for(i = 0; i < N; i++) + { residual = y[0] * sin( x[0] * t_[i] ) - z_[i]; + F[0] += .5 * residual * residual; + } + return F; + } + // Fun.h(x, y) = H(x, y) = F_y (x, y) + ADvector h(const ADvector &x, const BAvector &y) + { size_t i; + size_t N = size_t(z_.size()); + + ADvector fy(1); + fy[0] = 0.; + + AD residual; + for(i = 0; i < N; i++) + { residual = y[0] * sin( x[0] * t_[i] ) - z_[i]; + fy[0] += residual * sin( x[0] * t_[i] ); + } + return fy; + } + // 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 ADvector &H ) + { size_t i; + size_t N = size_t(z_.size()); + + ADvector Dy(1); + AD fyy = 0.; + + for(i = 0; i < N; i++) + { fyy += sin( x[0] * t_[i] ) * sin( x[0] * t_[i] ); + } + Dy[0] = - H[0] / fyy; + + return Dy; + } + }; + + // Used to test calculation of Hessian of G + AD G(const ADvector& x, const BAvector& t, const BAvector& z) + { // compute Y(x) + AD numerator = 0.; + AD denominator = 0.; + 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] ); + } + AD y = numerator / denominator; + + // V(x) = F[x, Y(x)] + AD sum = 0; + for(k = 0; k < size_t(t.size()); k++) + { AD residual = y * sin( x[0] * t[k] ) - z[k]; + sum += .5 * residual * residual; + } + return sum; + } } bool BenderQuad(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - - // temporary indices - size_t i, j; - - // x space vector - size_t n = 1; - BAvector x(n); - x[0] = 2. * 3.141592653; - - // y space vector - size_t m = 1; - BAvector y(m); - y[0] = 1.; - - // t and z vectors - size_t N = 10; - BAvector t(N); - BAvector z(N); - for(i = 0; i < N; i++) - { t[i] = double(i) / double(N); // time of measurement - z[i] = y[0] * sin( x[0] * t[i] ); // data without noise - } - - // construct the function object - Fun fun(t, z); - - // evaluate the G(x), G'(x) and G''(x) - BAvector g(1), gx(n), gxx(n * n); - CppAD::BenderQuad(x, y, fun, g, gx, gxx); - - - // create ADFun object Gfun corresponding to G(x) - ADvector a_x(n), a_g(1); - for(j = 0; j < n; j++) - a_x[j] = x[j]; - Independent(a_x); - a_g[0] = G(a_x, t, z); - CppAD::ADFun Gfun(a_x, a_g); - - // accuracy for checks - double eps = 10. * CppAD::numeric_limits::epsilon(); - - // check Jacobian - BAvector check_gx = Gfun.Jacobian(x); - for(j = 0; j < n; j++) - ok &= NearEqual(gx[j], check_gx[j], eps, eps); - - // check Hessian - BAvector check_gxx = Gfun.Hessian(x, 0); - for(j = 0; j < n*n; j++) - ok &= NearEqual(gxx[j], check_gxx[j], eps, eps); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + + // temporary indices + size_t i, j; + + // x space vector + size_t n = 1; + BAvector x(n); + x[0] = 2. * 3.141592653; + + // y space vector + size_t m = 1; + BAvector y(m); + y[0] = 1.; + + // t and z vectors + size_t N = 10; + BAvector t(N); + BAvector z(N); + for(i = 0; i < N; i++) + { t[i] = double(i) / double(N); // time of measurement + z[i] = y[0] * sin( x[0] * t[i] ); // data without noise + } + + // construct the function object + Fun fun(t, z); + + // evaluate the G(x), G'(x) and G''(x) + BAvector g(1), gx(n), gxx(n * n); + CppAD::BenderQuad(x, y, fun, g, gx, gxx); + + + // create ADFun object Gfun corresponding to G(x) + ADvector a_x(n), a_g(1); + for(j = 0; j < n; j++) + a_x[j] = x[j]; + Independent(a_x); + a_g[0] = G(a_x, t, z); + CppAD::ADFun Gfun(a_x, a_g); + + // accuracy for checks + double eps = 10. * CppAD::numeric_limits::epsilon(); + + // check Jacobian + BAvector check_gx = Gfun.Jacobian(x); + for(j = 0; j < n; j++) + ok &= NearEqual(gx[j], check_gx[j], eps, eps); + + // check Hessian + BAvector check_gxx = Gfun.Hessian(x, 0); + for(j = 0; j < n*n; j++) + ok &= NearEqual(gxx[j], check_gxx[j], eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/bool_fun.cpp cppad-2019.02.00.0/example/general/bool_fun.cpp --- cppad-2018.00.00.0/example/general/bool_fun.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/bool_fun.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,27 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin bool_fun.cpp$$ $spell - bool - Geq - Cpp + bool + Geq + Cpp $$ $section AD Boolean Functions: Example and Test$$ -$mindex bool$$ -$code $srcfile%example/general/bool_fun.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -37,37 +35,37 @@ typedef std::complex Complex; namespace { - // a unary bool function with Complex argument - static bool IsReal(const Complex &x) - { return x.imag() == 0.; } - - // a binary bool function with Complex arguments - static bool AbsGeq(const Complex &x, const Complex &y) - { double axsq = x.real() * x.real() + x.imag() * x.imag(); - double aysq = y.real() * y.real() + y.imag() * y.imag(); - - return axsq >= aysq; - } - - // Create version of IsReal with AD argument - // inside of namespace and outside of any other function. - CPPAD_BOOL_UNARY(Complex, IsReal) - - // Create version of AbsGeq with AD arguments - // inside of namespace and outside of any other function. - CPPAD_BOOL_BINARY(Complex, AbsGeq) + // a unary bool function with Complex argument + static bool IsReal(const Complex &x) + { return x.imag() == 0.; } + + // a binary bool function with Complex arguments + static bool AbsGeq(const Complex &x, const Complex &y) + { double axsq = x.real() * x.real() + x.imag() * x.imag(); + double aysq = y.real() * y.real() + y.imag() * y.imag(); + + return axsq >= aysq; + } + + // Create version of IsReal with AD argument + // inside of namespace and outside of any other function. + CPPAD_BOOL_UNARY(Complex, IsReal) + + // Create version of AbsGeq with AD arguments + // inside of namespace and outside of any other function. + CPPAD_BOOL_BINARY(Complex, AbsGeq) } bool BoolFun(void) -{ bool ok = true; +{ bool ok = true; - CppAD::AD x = Complex(1., 0.); - CppAD::AD y = Complex(1., 1.); + CppAD::AD x = Complex(1., 0.); + CppAD::AD y = Complex(1., 1.); - ok &= IsReal(x); - ok &= ! AbsGeq(x, y); + ok &= IsReal(x); + ok &= ! AbsGeq(x, y); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/capacity_order.cpp cppad-2019.02.00.0/example/general/capacity_order.cpp --- cppad-2018.00.00.0/example/general/capacity_order.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/capacity_order.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin capacity_order.cpp$$ $spell - Taylor + Taylor $$ $section Controlling Taylor Coefficient Memory Allocation: Example and Test$$ -$mindex capacity_order$$ -$code $srcfile%example/general/capacity_order.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,92 +27,92 @@ # 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 - // 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); - - // check that this is master thread - size_t thread = thread_alloc::thread_num(); - ok &= thread == 0; // this should be master thread - - // The highest order forward mode calculation below is first order. - // This corresponds to two Taylor coefficient per variable,direction - // (orders zero and one). Preallocate memory for speed. - size_t inuse = thread_alloc::inuse(thread); - f.capacity_order(2); - ok &= thread_alloc::inuse(thread) > inuse; - - // zero order forward mode - CPPAD_TESTVECTOR(double) x(n), y(m); - x[0] = 0.5; - 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; + 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 + // 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); + + // check that this is master thread + size_t thread = thread_alloc::thread_num(); + ok &= thread == 0; // this should be master thread + + // The highest order forward mode calculation below is first order. + // This corresponds to two Taylor coefficient per variable,direction + // (orders zero and one). Preallocate memory for speed. + size_t inuse = thread_alloc::inuse(thread); + f.capacity_order(2); + ok &= thread_alloc::inuse(thread) > inuse; + + // zero order forward mode + CPPAD_TESTVECTOR(double) x(n), y(m); + x[0] = 0.5; + 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); + // turn off memory holding + thread_alloc::hold_memory(false); - return ok; - } + return ok; + } } bool capacity_order(void) -{ bool ok = true; - using CppAD::thread_alloc; +{ bool ok = true; + using CppAD::thread_alloc; - // original amount of memory inuse - size_t thread = thread_alloc::thread_num(); - ok &= thread == 0; // this should be master thread - size_t inuse = thread_alloc::inuse(thread); + // original amount of memory inuse + size_t thread = thread_alloc::thread_num(); + ok &= thread == 0; // this should be master thread + size_t inuse = thread_alloc::inuse(thread); - // do test in separate routine so all objects are destroyed - ok &= test(); + // do test in separate routine so all objects are destroyed + ok &= test(); - // check that the amount of memroy inuse has not changed - ok &= thread_alloc::inuse(thread) == inuse; + // 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/change_param.cpp cppad-2019.02.00.0/example/general/change_param.cpp --- cppad-2018.00.00.0/example/general/change_param.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/change_param.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include /* $begin change_param.cpp$$ $spell - Jacobian + 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 @@ -26,16 +26,16 @@ 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 ) + \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 ) + \cos( x_0 ) & 0 \\ + 0 & \cos( x_1 ) \end{array} \right) \] $$ In this example we use two levels of AD to avoid computing @@ -48,94 +48,94 @@ */ bool change_param(void) -{ bool ok = true; // initialize test result +{ bool ok = true; // initialize test result - typedef CppAD::AD a1type; // for first level of taping - typedef CppAD::AD a2type; // for second level of taping + 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; + 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; + return ok; } // END PROGRAM diff -Nru cppad-2018.00.00.0/example/general/check_for_nan.cpp cppad-2019.02.00.0/example/general/check_for_nan.cpp --- cppad-2018.00.00.0/example/general/check_for_nan.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/check_for_nan.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,21 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin check_for_nan.cpp$$ $section ADFun Checking For Nan: Example and Test$$ -$code $srcfile%example/general/check_for_nan.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -25,92 +24,92 @@ # include namespace { - void myhandler( - bool known , - int line , - const char *file , - const char *exp , - const char *msg ) - { // error handler must not return, so throw an exception - std::string message = msg; - throw message; - } + void myhandler( + bool known , + int line , + const char *file , + const char *exp , + const char *msg ) + { // error handler must not return, so throw an exception + 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] = 2.0; - ax[1] = 1.0; - CppAD::Independent(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] = -1.0; - - // use try / catch because this causes an exception - // (assuming that NDEBUG is not defined) - f.check_for_nan(true); - try { - y = f.Forward(0, x); +{ 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] = 2.0; + ax[1] = 1.0; + CppAD::Independent(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] = -1.0; + + // use try / catch because this causes an exception + // (assuming that NDEBUG is not defined) + f.check_for_nan(true); + try { + y = f.Forward(0, x); # ifndef NDEBUG - // When compiled with NDEBUG defined, - // CppAD does not spend time checking for nan. - ok = false; + // When compiled with NDEBUG defined, + // CppAD does not spend time checking for nan. + ok = false; # endif - } - catch(std::string msg) - { - // 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 variable 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 &= CppAD::NearEqual(y[0], std::sqrt(x[0]), eps, eps); - ok &= CppAD::isnan( y[1] ); + } + catch(std::string msg) + { + // 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 = size_t( std::atoi(number.c_str()) ); + ok &= vector_size == 2; + + // get and check first dependent variable 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 = size_t( 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 &= CppAD::NearEqual(y[0], std::sqrt(x[0]), eps, eps); + ok &= CppAD::isnan( y[1] ); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/CMakeLists.txt cppad-2019.02.00.0/example/general/CMakeLists.txt --- cppad-2018.00.00.0/example/general/CMakeLists.txt 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,139 +1,142 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the example/general directory tests # # adolc_sources, adolc_libs IF( cppad_has_adolc ) - SET(adolc_sources mul_level_adolc.cpp mul_level_adolc_ode.cpp) - SET(adolc_libs adolc) + SET(adolc_sources mul_level_adolc.cpp mul_level_adolc_ode.cpp) + SET(adolc_libs adolc) ELSE( cppad_has_adolc ) - SET(adolc_sources "") - SET(adolc_libs "") + SET(adolc_sources "") + SET(adolc_libs "") ENDIF( cppad_has_adolc ) # # eigen_sources IF( cppad_has_eigen ) - SET(eigen_sources eigen_det.cpp eigen_array.cpp) + SET(eigen_sources eigen_det.cpp eigen_array.cpp) ELSE( cppad_has_eigen ) - SET(eigen_sources "") + SET(eigen_sources "") ENDIF( cppad_has_eigen ) # SET(source_list - general.cpp - ${adolc_sources} - ${eigen_sources} - abort_recording.cpp - fabs.cpp - acos.cpp - acosh.cpp - ad_assign.cpp - ad_ctor.cpp - add.cpp - add_eq.cpp - ad_fun.cpp - ad_in_c.cpp - ad_input.cpp - ad_output.cpp - asin.cpp - asinh.cpp - atan2.cpp - atan.cpp - atanh.cpp - azmul.cpp - base_alloc.hpp - base_require.cpp - bender_quad.cpp - bool_fun.cpp - capacity_order.cpp - change_param.cpp - check_for_nan.cpp - compare_change.cpp - compare.cpp - complex_poly.cpp - cond_exp.cpp - cos.cpp - cosh.cpp - div.cpp - div_eq.cpp - equal_op_seq.cpp - erf.cpp - exp.cpp - expm1.cpp - for_one.cpp - for_two.cpp - forward.cpp - forward_dir.cpp - forward_order.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 - integer.cpp - interface2c.cpp - interp_onetape.cpp - interp_retape.cpp - jac_lu_det.cpp - jac_minor_det.cpp - jacobian.cpp - log10.cpp - log1p.cpp - log.cpp - lu_ratio.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 - near_equal_ext.cpp - number_skip.cpp - numeric_type.cpp - num_limits.cpp - ode_stiff.cpp - ode_taylor.cpp - opt_val_hes.cpp - par_var.cpp - poly.cpp - pow.cpp - pow_int.cpp - print_for.cpp - reverse_checkpoint.cpp - reverse_one.cpp - reverse_three.cpp - reverse_two.cpp - rev_one.cpp - rev_two.cpp - rosen_34.cpp - runge45_2.cpp - seq_property.cpp - sign.cpp - sin.cpp - sinh.cpp - sqrt.cpp - stack_machine.cpp - sub.cpp - sub_eq.cpp - tan.cpp - tanh.cpp - tape_index.cpp - unary_minus.cpp - unary_plus.cpp - value.cpp - var2par.cpp - vec_ad.cpp + general.cpp + ${adolc_sources} + ${eigen_sources} + abort_recording.cpp + fabs.cpp + acos.cpp + acosh.cpp + ad_assign.cpp + ad_ctor.cpp + add.cpp + add_eq.cpp + ad_fun.cpp + ad_in_c.cpp + ad_input.cpp + ad_output.cpp + asin.cpp + asinh.cpp + atan2.cpp + atan.cpp + atanh.cpp + azmul.cpp + base_alloc.hpp + base2ad.cpp + base_require.cpp + bender_quad.cpp + bool_fun.cpp + capacity_order.cpp + change_param.cpp + check_for_nan.cpp + compare_change.cpp + compare.cpp + complex_poly.cpp + cond_exp.cpp + cos.cpp + cosh.cpp + div.cpp + div_eq.cpp + equal_op_seq.cpp + erf.cpp + exp.cpp + expm1.cpp + for_one.cpp + for_two.cpp + forward.cpp + forward_dir.cpp + forward_order.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 + integer.cpp + interface2c.cpp + interp_onetape.cpp + interp_retape.cpp + jac_lu_det.cpp + jac_minor_det.cpp + jacobian.cpp + log10.cpp + log1p.cpp + log.cpp + lu_ratio.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 + near_equal_ext.cpp + new_dynamic.cpp + number_skip.cpp + numeric_type.cpp + num_limits.cpp + ode_stiff.cpp + taylor_ode.cpp + opt_val_hes.cpp + con_dyn_var.cpp + poly.cpp + pow.cpp + pow_int.cpp + print_for.cpp + reverse_checkpoint.cpp + reverse_one.cpp + reverse_three.cpp + reverse_two.cpp + rev_one.cpp + rev_two.cpp + rosen_34.cpp + runge45_2.cpp + seq_property.cpp + sign.cpp + sin.cpp + sinh.cpp + sqrt.cpp + stack_machine.cpp + sub.cpp + sub_eq.cpp + tan.cpp + tanh.cpp + tape_index.cpp + unary_minus.cpp + unary_plus.cpp + value.cpp + var2par.cpp + vec_ad.cpp ) set_compile_flags( example_general "${cppad_debug_which}" "${source_list}" ) # @@ -141,13 +144,13 @@ # # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(example_general - ${adolc_libs} + ${adolc_libs} ) # # Add the check_example_general target ADD_CUSTOM_TARGET(check_example_general - example_general - DEPENDS example_general + example_general + DEPENDS example_general ) MESSAGE(STATUS "make check_example_general: available") # diff -Nru cppad-2018.00.00.0/example/general/compare_change.cpp cppad-2019.02.00.0/example/general/compare_change.cpp --- cppad-2018.00.00.0/example/general/compare_change.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/compare_change.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin compare_change.cpp$$ $spell - Cpp + Cpp $$ $section CompareChange and Re-Tape: Example and Test$$ -$mindex compare change re-tape$$ -$code $srcfile%example/general/compare_change.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,155 +28,155 @@ # include namespace { // put this function in the empty namespace - 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; - } - 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; - } + 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; + } + 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 compare_change(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 3.; - ax[1] = 4.; - - // declare independent variables and start tape recording - CppAD::Independent(ax); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = Minimum(ax[0], ax[1]); - - // create f: x -> y and stop tape recording - 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 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.compare_change_number() == 0); - ok &= (f.compare_change_op_index() == 0); - - // 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.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]); + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 3.; + ax[1] = 4.; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = Minimum(ax[0], ax[1]); + + // create f: x -> y and stop tape recording + 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 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.compare_change_number() == 0); + ok &= (f.compare_change_op_index() == 0); + + // 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.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(); + // 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(); - } - } + } + 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(); + } + } # ifdef CPPAD_DEBUG_AND_RELEASE - if( missed_error ) - { // This routine is compiled for debugging, but the routine that checks - // operator indices was compiled for release. - missed_error = false; - AD::abort_recording(); - } + if( missed_error ) + { // This routine is compiled for debugging, but the routine that checks + // operator indices was compiled for release. + missed_error = false; + AD::abort_recording(); + } # endif - ok &= ! missed_error; + ok &= ! missed_error; - // 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); - - // 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.compare_change_number() == 0); - ok &= (f.compare_change_op_index() == 0); + // 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); + + // 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.compare_change_number() == 0); + ok &= (f.compare_change_op_index() == 0); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/example/general/compare.cpp cppad-2019.02.00.0/example/general/compare.cpp --- cppad-2018.00.00.0/example/general/compare.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/compare.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin compare.cpp$$ $spell - Cpp + Cpp $$ $section AD Binary Comparison Operators: Example and Test$$ -$mindex compare < <= > >= == !=$$ -$code $srcfile%example/general/compare.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,75 +28,81 @@ # include bool Compare(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // declare independent variables and start tape recording - size_t n = 2; - double x0 = 0.5; - double x1 = 1.5; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; - x[1] = x1; - CppAD::Independent(x); - - // some binary comparision operations - AD p; - if( x[0] < x[1] ) - p = x[0]; // values in x choose this case - else p = x[1]; - if( x[0] <= x[1] ) - p *= x[0]; // values in x choose this case - else p *= x[1]; - if( x[0] > x[1] ) - p *= x[0]; - else p *= x[1]; // values in x choose this case - if( x[0] >= x[1] ) - p *= x[0]; - else p *= x[1]; // values in x choose this case - if( x[0] == x[1] ) - 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]; - - // 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); - - // check value - ok &= NearEqual(y[0] , x0*x0*x1*x1*x1*x0, eps99, eps99); - - // forward computation of partials w.r.t. x[0] - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - dx[0] = 1.; - dx[1] = 0.; - dy = f.Forward(1, dx); - ok &= NearEqual(dy[0], 3.*x0*x0*x1*x1*x1, eps99, eps99); - - // forward computation of partials w.r.t. x[1] - dx[0] = 0.; - dx[1] = 1.; - dy = f.Forward(1, dx); - ok &= NearEqual(dy[0], 3.*x0*x0*x1*x1*x0, eps99, eps99); - - // 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], 3.*x0*x0*x1*x1*x1, eps99, eps99); - ok &= NearEqual(dw[1], 3.*x0*x0*x1*x1*x0, eps99, eps99); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // declare independent variables and start tape recording + size_t n = 2; + double x0 = 0.5; + double x1 = 1.5; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + x[1] = x1; + CppAD::Independent(x); + + // some binary comparision operations + AD p; + if( x[0] < x[1] ) + p = x[0]; // values in x choose this case + else + p = x[1]; + if( x[0] <= x[1] ) + p *= x[0]; // values in x choose this case + else + p *= x[1]; + if( x[0] > x[1] ) + p *= x[0]; + else + p *= x[1]; // values in x choose this case + if( x[0] >= x[1] ) + p *= x[0]; + else + p *= x[1]; // values in x choose this case + if( x[0] == x[1] ) + 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]; + + // 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); + + // check value + ok &= NearEqual(y[0] , x0*x0*x1*x1*x1*x0, eps99, eps99); + + // forward computation of partials w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dx[1] = 0.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 3.*x0*x0*x1*x1*x1, eps99, eps99); + + // forward computation of partials w.r.t. x[1] + dx[0] = 0.; + dx[1] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 3.*x0*x0*x1*x1*x0, eps99, eps99); + + // 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], 3.*x0*x0*x1*x1*x1, eps99, eps99); + ok &= NearEqual(dw[1], 3.*x0*x0*x1*x1*x0, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/complex_poly.cpp cppad-2019.02.00.0/example/general/complex_poly.cpp --- cppad-2018.00.00.0/example/general/complex_poly.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/complex_poly.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,30 +1,28 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin complex_poly.cpp$$ $spell - Cpp + Cpp $$ $section Complex Polynomial: Example and Test$$ -$mindex polynomial$$ $head Poly$$ Select this link to view specifications for $cref Poly$$: -$code $srcfile%example/general/complex_poly.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -36,50 +34,50 @@ # include bool complex_poly(void) -{ bool ok = true; - size_t deg = 4; +{ bool ok = true; + size_t deg = 4; - using CppAD::AD; - using CppAD::Poly; - typedef std::complex Complex; - - // polynomial coefficients - CPPAD_TESTVECTOR( Complex ) a (deg + 1); // coefficients for p(z) - CPPAD_TESTVECTOR(AD) A (deg + 1); - size_t i; - for(i = 0; i <= deg; i++) - A[i] = a[i] = Complex(double(i), double(i)); - - // independent variable vector - CPPAD_TESTVECTOR(AD) Z(1); - Complex z = Complex(1., 2.); - Z[0] = z; - Independent(Z); - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) P(1); - - // dependent variable values - P[0] = Poly(0, A, Z[0]); - - // create f: Z -> P and vectors used for derivative calculations - CppAD::ADFun f(Z, P); - CPPAD_TESTVECTOR(Complex) v( f.Domain() ); - CPPAD_TESTVECTOR(Complex) w( f.Range() ); - - // check first derivative w.r.t z - v[0] = 1.; - w = f.Forward(1, v); - Complex p = Poly(1, a, z); - ok &= ( w[0] == p ); - - // second derivative w.r.t z is 2 times its second order Taylor coeff - v[0] = 0.; - w = f.Forward(2, v); - p = Poly(2, a, z); - ok &= ( 2. * w[0] == p ); + using CppAD::AD; + using CppAD::Poly; + typedef std::complex Complex; + + // polynomial coefficients + CPPAD_TESTVECTOR( Complex ) a (deg + 1); // coefficients for p(z) + CPPAD_TESTVECTOR(AD) A (deg + 1); + size_t i; + for(i = 0; i <= deg; i++) + A[i] = a[i] = Complex(double(i), double(i)); + + // independent variable vector + CPPAD_TESTVECTOR(AD) Z(1); + Complex z = Complex(1., 2.); + Z[0] = z; + Independent(Z); + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) P(1); + + // dependent variable values + P[0] = Poly(0, A, Z[0]); + + // create f: Z -> P and vectors used for derivative calculations + CppAD::ADFun f(Z, P); + CPPAD_TESTVECTOR(Complex) v( f.Domain() ); + CPPAD_TESTVECTOR(Complex) w( f.Range() ); + + // check first derivative w.r.t z + v[0] = 1.; + w = f.Forward(1, v); + Complex p = Poly(1, a, z); + ok &= ( w[0] == p ); + + // second derivative w.r.t z is 2 times its second order Taylor coeff + v[0] = 0.; + w = f.Forward(2, v); + p = Poly(2, a, z); + ok &= ( 2. * w[0] == p ); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/cond_exp.cpp cppad-2019.02.00.0/example/general/cond_exp.cpp --- cppad-2018.00.00.0/example/general/cond_exp.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/cond_exp.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,20 +1,21 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin cond_exp.cpp$$ $spell - Cpp - cstddef - CondExp + Cpp + cstddef + CondExp $$ $section Conditional Expressions: Example and Test$$ @@ -26,7 +27,7 @@ $head Description$$ Use $code CondExp$$ to compute $latex \[ - f(x) = \sum_{j=0}^{m-1} x_j \log( x_j ) + f(x) = \sum_{j=0}^{m-1} x_j \log( x_j ) \] $$ and its derivative at various argument values ( where $latex x_j \geq 0$$ ) @@ -37,9 +38,7 @@ we need to handle the case $latex x_j = 0$$ in a special way to avoid multiplying zero by infinity. -$code $srcfile%example/general/cond_exp.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -49,84 +48,84 @@ # include bool CondExp(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::isnan; - using CppAD::AD; - using CppAD::NearEqual; - using CppAD::log; - double eps = 100. * CppAD::numeric_limits::epsilon(); - - // domain space vector - size_t n = 5; - CPPAD_TESTVECTOR(AD) ax(n); - size_t j; - for(j = 0; j < n; j++) - ax[j] = 1.; - - // declare independent variables and start tape recording - CppAD::Independent(ax); - - 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 - asum += CppAD::CondExpGt(ax[j], azero, ax[j] * log(ax[j]), azero); - } - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = asum; - - // 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) 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); - check += x[j] * log( x[j] ); - } - - // function value - y = f.Forward(0, x); - ok &= NearEqual(y[0], check, eps, eps); - - // compute derivative of y[0] - w[0] = 1.; - dw = f.Reverse(1, w); - for(j = 0; j < n; j++) - 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 - y = f.Forward(0, x); - ok &= NearEqual(y[0], check, eps, eps); - - // check derivative of y[0] - f.check_for_nan(false); - w[0] = 1.; - 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); - else - { // 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); - } - } + using CppAD::isnan; + using CppAD::AD; + using CppAD::NearEqual; + using CppAD::log; + double eps = 100. * CppAD::numeric_limits::epsilon(); + + // domain space vector + size_t n = 5; + CPPAD_TESTVECTOR(AD) ax(n); + size_t j; + for(j = 0; j < n; j++) + ax[j] = 1.; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + 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 + asum += CppAD::CondExpGt(ax[j], azero, ax[j] * log(ax[j]), azero); + } + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = asum; + + // 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) 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); + check += x[j] * log( x[j] ); + } + + // function value + y = f.Forward(0, x); + ok &= NearEqual(y[0], check, eps, eps); + + // compute derivative of y[0] + w[0] = 1.; + dw = f.Reverse(1, w); + for(j = 0; j < n; j++) + 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 + y = f.Forward(0, x); + ok &= NearEqual(y[0], check, eps, eps); + + // check derivative of y[0] + f.check_for_nan(false); + w[0] = 1.; + 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); + else + { // 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/con_dyn_var.cpp cppad-2019.02.00.0/example/general/con_dyn_var.cpp --- cppad-2018.00.00.0/example/general/con_dyn_var.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/general/con_dyn_var.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,106 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin con_dyn_var.cpp$$ + +$section AD Parameter and Variable Functions: Example and Test$$ + + + + +$srcfile%example/general/con_dyn_var.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ + +# include + +bool con_dyn_var(void) +{ bool ok = true; + + using CppAD::AD; + using CppAD::VecAD; + using CppAD::Parameter; + using CppAD::Variable; + + // No recording active + CPPAD_TESTVECTOR(AD) x(1), y(1), dynamic(1); + x[0] = 0.0; + y[0] = 1.0; + dynamic[0] = 2.0; + // + ok &= Constant(x[0]); + ok &= Parameter(x[0]); + ok &= ! Dynamic(x[0]); + ok &= ! Variable(x[0]); + // + ok &= Constant(y[0]); + ok &= Parameter(y[0]); + ok &= ! Dynamic(y[0]); + ok &= ! Variable(y[0]); + // + ok &= Constant(dynamic[0]); + ok &= Parameter(dynamic[0]); + ok &= ! Dynamic(dynamic[0]); + ok &= ! Variable(dynamic[0]); + + // declare independent variables and start recording + size_t abort_op_index = 0; + bool record_compare = true; + CppAD::Independent(x, abort_op_index, record_compare, dynamic); + // + ok &= Variable(x[0]); + ok &= ! Constant(x[0]); + ok &= ! Dynamic(x[0]); + ok &= ! Parameter(x[0]); + // + ok &= Constant(y[0]); + ok &= Parameter(y[0]); + ok &= ! Dynamic(y[0]); + ok &= ! Variable(y[0]); + // + ok &= Dynamic(dynamic[0]); + ok &= Parameter(dynamic[0]); + ok &= ! Constant(dynamic[0]); + ok &= ! Variable(dynamic[0]); + + // a dependent variable + y[0] = fabs(x[0]) * dynamic[0]; + ok &= Variable(y[0]); + ok &= ! Constant(y[0]); + ok &= ! Dynamic(y[0]); + ok &= ! Parameter(y[0]); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + // + ok &= Constant(x[0]); + ok &= Parameter(x[0]); + ok &= ! Dynamic(x[0]); + ok &= ! Variable(x[0]); + // + ok &= Constant(y[0]); + ok &= Parameter(y[0]); + ok &= ! Dynamic(y[0]); + ok &= ! Variable(y[0]); + // + ok &= Constant(dynamic[0]); + ok &= Parameter(dynamic[0]); + ok &= ! Dynamic(dynamic[0]); + ok &= ! Variable(dynamic[0]); + + return ok; +} + +// END C++ diff -Nru cppad-2018.00.00.0/example/general/cos.cpp cppad-2019.02.00.0/example/general/cos.cpp --- cppad-2018.00.00.0/example/general/cos.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/cos.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin cos.cpp$$ $spell - cos + cos $$ $section The AD cos Function: Example and Test$$ -$code $srcfile%example/general/cos.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,57 +29,57 @@ # include bool Cos(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * 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); - - // 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); - - // check value - double check = std::cos(x0); - ok &= NearEqual(y[0] , check, eps99, eps99); - - // 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::sin(x0); - ok &= NearEqual(dy[0], check, eps99, eps99); - - // 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, eps99, eps99); - - // use a VecAD::reference object with cos - CppAD::VecAD v(1); - AD zero(0); - v[zero] = x0; - AD result = CppAD::cos(v[zero]); - check = std::cos(x0); - ok &= NearEqual(result, check, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * 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); + + // 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); + + // check value + double check = std::cos(x0); + ok &= NearEqual(y[0] , check, eps99, eps99); + + // 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::sin(x0); + ok &= NearEqual(dy[0], check, eps99, eps99); + + // 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, eps99, eps99); + + // use a VecAD::reference object with cos + CppAD::VecAD v(1); + AD zero(0); + v[zero] = x0; + AD result = CppAD::cos(v[zero]); + check = std::cos(x0); + ok &= NearEqual(result, check, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/cosh.cpp cppad-2019.02.00.0/example/general/cosh.cpp --- cppad-2018.00.00.0/example/general/cosh.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/cosh.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin cosh.cpp$$ @@ -17,9 +18,7 @@ $section The AD cosh Function: Example and Test$$ -$code $srcfile%example/general/cosh.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,57 +28,57 @@ # include bool Cosh(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * 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); - - // 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); - - // check value - double check = std::cosh(x0); - ok &= NearEqual(y[0] , check, eps99, eps99); - - // 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::sinh(x0); - ok &= NearEqual(dy[0], check, eps99, eps99); - - // 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, eps99, eps99); - - // use a VecAD::reference object with cosh - CppAD::VecAD v(1); - AD zero(0); - v[zero] = x0; - AD result = CppAD::cosh(v[zero]); - check = std::cosh(x0); - ok &= NearEqual(result, check, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * 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); + + // 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); + + // check value + double check = std::cosh(x0); + ok &= NearEqual(y[0] , check, eps99, eps99); + + // 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::sinh(x0); + ok &= NearEqual(dy[0], check, eps99, eps99); + + // 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, eps99, eps99); + + // use a VecAD::reference object with cosh + CppAD::VecAD v(1); + AD zero(0); + v[zero] = x0; + AD result = CppAD::cosh(v[zero]); + check = std::cosh(x0); + ok &= NearEqual(result, check, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/div.cpp cppad-2019.02.00.0/example/general/div.cpp --- cppad-2018.00.00.0/example/general/div.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/div.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,22 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin div.cpp$$ $section AD Binary Division: Example and Test$$ -$mindex / divide quotient$$ -$code $srcfile%example/general/div.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -26,60 +24,60 @@ # include bool Div(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * 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); - - // 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 - - // 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); - - // check value - ok &= NearEqual(y[0], x0*x0*3.*2.*1./(4.*x0), eps99, eps99); - - // forward computation of partials 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], 3.*2.*1./4., eps99, eps99); - - // 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], 3.*2.*1./4., eps99, eps99); - - // use a VecAD::reference object with division - CppAD::VecAD v(1); - AD zero(0); - v[zero] = d; - AD result = (x[0] * x[0]) / v[zero]; - ok &= (result == y[0]); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * 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); + + // 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 + + // 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); + + // check value + ok &= NearEqual(y[0], x0*x0*3.*2.*1./(4.*x0), eps99, eps99); + + // forward computation of partials 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], 3.*2.*1./4., eps99, eps99); + + // 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], 3.*2.*1./4., eps99, eps99); + + // use a VecAD::reference object with division + CppAD::VecAD v(1); + AD zero(0); + v[zero] = d; + AD result = (x[0] * x[0]) / v[zero]; + ok &= (result == y[0]); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/div_eq.cpp cppad-2019.02.00.0/example/general/div_eq.cpp --- cppad-2018.00.00.0/example/general/div_eq.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/general/div_eq.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin div_eq.cpp$$ $section AD Compound Assignment Division: Example and Test$$ -$mindex /= divide assign plus add$$ -$code $srcfile%example/general/div_eq.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -27,60 +25,60 @@ # include bool DivEq(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - double x0 = .5; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // range space vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = x[0] * x[0]; // initial value - y[0] /= 2; // AD /= int - y[0] /= 4.; // AD /= double - y[1] = y[0] /= x[0]; // use the result of a compound assignment - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // check value - ok &= NearEqual(y[0] , x0*x0/(2.*4.*x0), eps99, eps99); - ok &= NearEqual(y[1] , y[0], eps99, eps99); - - // forward computation of partials 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./8., eps99, eps99); - ok &= NearEqual(dy[1], 1./8., eps99, eps99); - - // reverse computation of derivative of y[0] - CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); - w[0] = 1.; - w[1] = 0.; - dw = f.Reverse(1, w); - ok &= NearEqual(dw[0], 1./8., eps99, eps99); - - // use a VecAD::reference object with computed division - CppAD::VecAD v(1); - AD zero(0); - AD result = 2; - v[zero] = 1; - result /= v[zero]; - ok &= (result == 2); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = .5; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // range space vector + size_t m = 2; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = x[0] * x[0]; // initial value + y[0] /= 2; // AD /= int + y[0] /= 4.; // AD /= double + y[1] = y[0] /= x[0]; // use the result of a compound assignment + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check value + ok &= NearEqual(y[0] , x0*x0/(2.*4.*x0), eps99, eps99); + ok &= NearEqual(y[1] , y[0], eps99, eps99); + + // forward computation of partials 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./8., eps99, eps99); + ok &= NearEqual(dy[1], 1./8., eps99, eps99); + + // reverse computation of derivative of y[0] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + w[1] = 0.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], 1./8., eps99, eps99); + + // use a VecAD::reference object with computed division + CppAD::VecAD v(1); + AD zero(0); + AD result = 2; + v[zero] = 1; + result /= v[zero]; + ok &= (result == 2); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/eigen_array.cpp cppad-2019.02.00.0/example/general/eigen_array.cpp --- cppad-2018.00.00.0/example/general/eigen_array.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/eigen_array.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,81 +1,73 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin eigen_array.cpp$$ $spell - Eigen + Eigen $$ $section Using Eigen Arrays: Example and Test$$ -$mindex array$$ -$code $srcfile%example/general/eigen_array.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include # include -# include -# include bool eigen_array(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - using Eigen::Matrix; - using Eigen::Dynamic; - // - typedef Matrix< AD , Dynamic, 1 > a_vector; - // - // some temporary indices - size_t i, j; - - // domain and range space vectors - size_t n = 10, m = n; - a_vector a_x(n), a_y(m); - - // set and declare independent variables and start tape recording - for(j = 0; j < n; j++) - a_x[j] = double(1 + j); - CppAD::Independent(a_x); - - // evaluate a component wise function - a_y = a_x.array() + a_x.array().sin(); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(a_x, a_y); - - // compute the derivative of y w.r.t x using CppAD - CPPAD_TESTVECTOR(double) x(n); - for(j = 0; j < n; j++) - x[j] = double(j) + 1.0 / double(j+1); - CPPAD_TESTVECTOR(double) jac = f.Jacobian(x); - - // check Jacobian - double eps = 100. * CppAD::numeric_limits::epsilon(); - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - { double check = 1.0 + cos(x[i]); - if( i != j ) - check = 0.0; - ok &= NearEqual(jac[i * n + j], check, eps, eps); - } - } +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + // + typedef CppAD::eigen_vector< AD > a_vector; + // + // domain and range space vectors + size_t n = 10, m = n; + a_vector a_x(n), a_y(m); + + // set and declare independent variables and start tape recording + for(size_t j = 0; j < n; j++) + a_x[j] = double(1 + j); + CppAD::Independent(a_x); + + // evaluate a component wise function + for(size_t j = 0; j < n; j++) + a_y[j] = a_x[j] + sin( a_x[j] ); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(a_x, a_y); + + // compute the derivative of y w.r.t x using CppAD + CPPAD_TESTVECTOR(double) x(n); + for(size_t j = 0; j < n; j++) + x[j] = double(j) + 1.0 / double(j+1); + CPPAD_TESTVECTOR(double) jac = f.Jacobian(x); + + // check Jacobian + double eps = 100. * CppAD::numeric_limits::epsilon(); + for(size_t i = 0; i < m; i++) + { for(size_t j = 0; j < n; j++) + { double check = 1.0 + cos(x[i]); + if( i != j ) + check = 0.0; + ok &= NearEqual(jac[i * n + j], check, eps, eps); + } + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/eigen_det.cpp cppad-2019.02.00.0/example/general/eigen_det.cpp --- cppad-2018.00.00.0/example/general/eigen_det.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/eigen_det.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,25 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin eigen_det.cpp$$ $spell - Eigen + Eigen $$ $section Using Eigen To Compute Determinant: Example and Test$$ -$mindex determinant$$ -$code $srcfile%example/general/eigen_det.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,70 +29,76 @@ # include bool eigen_det(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - using Eigen::Matrix; - using Eigen::Dynamic; - // - typedef Matrix< double , Dynamic, Dynamic > matrix; - typedef Matrix< AD , Dynamic, Dynamic > a_matrix; - // - typedef Matrix< double , Dynamic , 1> vector; - typedef Matrix< AD , Dynamic , 1> a_vector; - // some temporary indices - size_t i, j; - - // domain and range space vectors - size_t size = 3, n = size * size, m = 1; - a_vector a_x(n), a_y(m); - vector x(n); - - // set and declare independent variables and start tape recording - for(i = 0; i < size; i++) - { for(j = 0; j < size; j++) - { // 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); - } - } - CppAD::Independent(a_x); - - // copy independent variable vector to a matrix - a_matrix a_X(size, size); - matrix X(size, size); - for(i = 0; i < size; i++) - { for(j = 0; j < size; j++) - { X(i, j) = x[i * size + j]; - // If we used a_X(i, j) = X(i, j), a_X would not depend on a_x. - a_X(i, j) = a_x[i * size + j]; - } - } - - // Compute the log of determinant of X - a_y[0] = log( a_X.determinant() ); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(a_x, a_y); - - // check function value - double eps = 100. * CppAD::numeric_limits::epsilon(); - 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 - vector jac = f.Jacobian(x); - - // check the derivative using the formula - // d/dX log(det(X)) = transpose( inv(X) ) - matrix inv_X = X.inverse(); - for(i = 0; i < size; i++) - { for(j = 0; j < size; j++) - ok &= NearEqual(jac[i * size + j], inv_X(j, i), eps, eps); - } +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + using Eigen::Matrix; + using Eigen::Dynamic; + using Eigen::Index; + // + typedef Matrix< double , Dynamic, Dynamic > matrix; + typedef Matrix< AD , Dynamic, Dynamic > a_matrix; + // + typedef CppAD::eigen_vector vector; + typedef CppAD::eigen_vector< AD > a_vector; + // + + // domain and range space vectors + size_t size = 3, n = size * size, m = 1; + a_vector a_x(n), a_y(m); + vector x(n); + + // set and declare independent variables and start tape recording + for(size_t i = 0; i < size; i++) + { for(size_t j = 0; j < size; j++) + { // 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); + } + } + CppAD::Independent(a_x); + + // copy independent variable vector to a matrix + Index Size = Index(size); + a_matrix a_X(Size, Size); + matrix X(Size, Size); + for(size_t i = 0; i < size; i++) + { for(size_t j = 0; j < size; j++) + { Index I = Index(i); + Index J = Index(j); + X(I ,J) = x[i * size + j]; + // If we used a_X(i, j) = X(i, j), a_X would not depend on a_x. + a_X(I, J) = a_x[i * size + j]; + } + } + + // Compute the log of determinant of X + a_y[0] = log( a_X.determinant() ); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(a_x, a_y); + + // check function value + double eps = 100. * CppAD::numeric_limits::epsilon(); + 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 + vector jac = f.Jacobian(x); + + // check the derivative using the formula + // d/dX log(det(X)) = transpose( inv(X) ) + matrix inv_X = X.inverse(); + for(size_t i = 0; i < size; i++) + { for(size_t j = 0; j < size; j++) + { Index I = Index(i); + Index J = Index(j); + ok &= NearEqual(jac[i * size + j], inv_X(J, I), eps, eps); + } + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/equal_op_seq.cpp cppad-2019.02.00.0/example/general/equal_op_seq.cpp --- cppad-2018.00.00.0/example/general/equal_op_seq.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/equal_op_seq.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin equal_op_seq.cpp$$ $spell - Op + Op $$ $section EqualOpSeq: Example and Test$$ -$mindex EqualOpSeq$$ -$code $srcfile%example/general/equal_op_seq.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,41 +27,41 @@ # include bool EqualOpSeq(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::EqualOpSeq; +{ bool ok = true; + using CppAD::AD; + using CppAD::EqualOpSeq; - // domain space vector - size_t n = 1; - double x0 = 1.; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; + // domain space vector + size_t n = 1; + double x0 = 1.; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; - // declare independent variables and start tape recording - CppAD::Independent(x); + // declare independent variables and start tape recording + CppAD::Independent(x); - AD a = 1. + x[0]; // this variable is 1 + x0 - AD b = 2. * x[0]; // this variable is 2 * x0 + AD a = 1. + x[0]; // this variable is 1 + x0 + AD b = 2. * x[0]; // this variable is 2 * x0 - // both a and b are variables - ok &= (a == b); // 1 + 1 == 2 * 1 - ok &= ! EqualOpSeq(a, b); // 1 + x[0] != 2 * x[0] + // both a and b are variables + ok &= (a == b); // 1 + 1 == 2 * 1 + ok &= ! EqualOpSeq(a, b); // 1 + x[0] != 2 * x[0] - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = a; + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = a; - // both y[0] and a are variables - EqualOpSeq(y[0], a); // 2 * x[0] == 2 * x[0] + // both y[0] and a are variables + EqualOpSeq(y[0], a); // 2 * x[0] == 2 * x[0] - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); + // create f: x -> y and stop tape recording + 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 + // both a and b are parameters (after the creation of f above) + ok &= EqualOpSeq(a, b); // 1 + 1 == 2 * 1 - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/erf.cpp cppad-2019.02.00.0/example/general/erf.cpp --- cppad-2018.00.00.0/example/general/erf.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/erf.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin erf.cpp$$ $spell - tan - erf + tan + erf $$ $section The AD erf Function: Example and Test$$ -$code $srcfile%example/general/erf.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -32,73 +31,73 @@ # include bool Erf(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * CppAD::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::erf(ax[0]); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // check relative erorr - double erf_x0 = 0.5204998778130465; - ok &= NearEqual(ay[0] , erf_x0, 0., 4e-4); + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::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::erf(ax[0]); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // check relative erorr + double erf_x0 = 0.5204998778130465; + ok &= NearEqual(ay[0] , erf_x0, 0., 4e-4); # if CPPAD_USE_CPLUSPLUS_2011 - double tmp = std::max(1e-15, eps); - ok &= NearEqual(ay[0] , erf_x0, 0., tmp); + double tmp = std::max(1e-15, eps); + ok &= NearEqual(ay[0] , erf_x0, 0., tmp); # endif - // value of derivative of erf at x0 - double pi = 4. * std::atan(1.); - double factor = 2. / sqrt(pi); - double check = factor * std::exp(-x0 * x0); - - // 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], check, 0., 1e-3); + // value of derivative of erf at x0 + double pi = 4. * std::atan(1.); + double factor = 2. / sqrt(pi); + double check = factor * std::exp(-x0 * x0); + + // 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], check, 0., 1e-3); # if CPPAD_USE_CPLUSPLUS_2011 - ok &= NearEqual(dy[0], check, 0., eps); + ok &= NearEqual(dy[0], check, 0., eps); # endif - // 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, 0., 1e-1); + // 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, 0., 1e-1); # if CPPAD_USE_CPLUSPLUS_2011 - ok &= NearEqual(dw[0], check, 0., eps); + ok &= NearEqual(dw[0], check, 0., eps); # endif - // use a VecAD::reference object with erf - CppAD::VecAD v(1); - AD zero(0); - v[zero] = x0; - AD result = CppAD::erf(v[zero]); - ok &= NearEqual(result, ay[0], eps, eps); + // use a VecAD::reference object with erf + CppAD::VecAD v(1); + AD zero(0); + v[zero] = x0; + AD result = CppAD::erf(v[zero]); + ok &= NearEqual(result, ay[0], eps, eps); - // use a double with erf - ok &= NearEqual(CppAD::erf(x0), ay[0], eps, eps); + // use a double with erf + ok &= NearEqual(CppAD::erf(x0), ay[0], eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/exp.cpp cppad-2019.02.00.0/example/general/exp.cpp --- cppad-2018.00.00.0/example/general/exp.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/exp.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp.cpp$$ $spell - exp + exp $$ $section The AD exp Function: Example and Test$$ -$code $srcfile%example/general/exp.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,55 +28,55 @@ # include bool exp(void) -{ bool ok = true; +{ 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::exp(ax[0]); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // check value - double check = std::exp(x0); - 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); - 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, 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, eps, eps); + 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::exp(ax[0]); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // check value + double check = std::exp(x0); + 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); + 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, 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, eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/expm1.cpp cppad-2019.02.00.0/example/general/expm1.cpp --- cppad-2018.00.00.0/example/general/expm1.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/expm1.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin expm1.cpp$$ $spell - exp + exp $$ $section The AD exp Function: Example and Test$$ -$code $srcfile%example/general/expm1.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,55 +28,55 @@ # include bool expm1(void) -{ bool ok = true; +{ 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); + 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/fabs.cpp cppad-2019.02.00.0/example/general/fabs.cpp --- cppad-2018.00.00.0/example/general/fabs.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/fabs.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin fabs.cpp$$ $spell - fabs - abs + fabs + abs $$ $section AD Absolute Value Function: Example and Test$$ -$mindex abs fabs$$ -$code $srcfile%example/general/fabs.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,94 +29,94 @@ # include bool fabs(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = 0.; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // range space vector - size_t m = 6; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = fabs(x[0] - 1.); - y[1] = fabs(x[0]); - y[2] = fabs(x[0] + 1.); - // - y[3] = fabs(x[0] - 1.); - y[4] = fabs(x[0]); - y[5] = fabs(x[0] + 1.); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // check values - ok &= (y[0] == 1.); - ok &= (y[1] == 0.); - ok &= (y[2] == 1.); - // - ok &= (y[3] == 1.); - ok &= (y[4] == 0.); - ok &= (y[5] == 1.); - - // forward computation of partials w.r.t. a positive x[0] direction - size_t p = 1; - CPPAD_TESTVECTOR(double) dx(n), dy(m); - dx[0] = 1.; - dy = f.Forward(p, dx); - ok &= (dy[0] == - dx[0]); - ok &= (dy[1] == 0. ); // used to be (dy[1] == + dx[0]); - ok &= (dy[2] == + dx[0]); - // - ok &= (dy[3] == - dx[0]); - ok &= (dy[4] == 0. ); // used to be (dy[1] == + dx[0]); - ok &= (dy[5] == + dx[0]); - - // forward computation of partials w.r.t. a negative x[0] direction - dx[0] = -1.; - dy = f.Forward(p, dx); - ok &= (dy[0] == - dx[0]); - ok &= (dy[1] == 0. ); // used to be (dy[1] == - dx[0]); - ok &= (dy[2] == + dx[0]); - // - ok &= (dy[3] == - dx[0]); - ok &= (dy[4] == 0. ); // used to be (dy[1] == - dx[0]); - ok &= (dy[5] == + dx[0]); - - // reverse computation of derivative of y[0] - p = 1; - CPPAD_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] - w[0] = 0.; w[1] = 1.; - dw = f.Reverse(p, w); - ok &= (dw[0] == 0.); - - // reverse computation of derivative of y[5] - w[1] = 0.; w[5] = 1.; - dw = f.Reverse(p, w); - ok &= (dw[0] == 1.); - - // use a VecAD::reference object with abs and fabs - CppAD::VecAD v(1); - AD zero(0); - v[zero] = -1; - AD result = fabs(v[zero]); - ok &= NearEqual(result, 1., eps99, eps99); - result = fabs(v[zero]); - ok &= NearEqual(result, 1., eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = 0.; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // range space vector + size_t m = 6; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = fabs(x[0] - 1.); + y[1] = fabs(x[0]); + y[2] = fabs(x[0] + 1.); + // + y[3] = fabs(x[0] - 1.); + y[4] = fabs(x[0]); + y[5] = fabs(x[0] + 1.); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check values + ok &= (y[0] == 1.); + ok &= (y[1] == 0.); + ok &= (y[2] == 1.); + // + ok &= (y[3] == 1.); + ok &= (y[4] == 0.); + ok &= (y[5] == 1.); + + // forward computation of partials w.r.t. a positive x[0] direction + size_t p = 1; + CPPAD_TESTVECTOR(double) dx(n), dy(m); + dx[0] = 1.; + dy = f.Forward(p, dx); + ok &= (dy[0] == - dx[0]); + ok &= (dy[1] == 0. ); // used to be (dy[1] == + dx[0]); + ok &= (dy[2] == + dx[0]); + // + ok &= (dy[3] == - dx[0]); + ok &= (dy[4] == 0. ); // used to be (dy[1] == + dx[0]); + ok &= (dy[5] == + dx[0]); + + // forward computation of partials w.r.t. a negative x[0] direction + dx[0] = -1.; + dy = f.Forward(p, dx); + ok &= (dy[0] == - dx[0]); + ok &= (dy[1] == 0. ); // used to be (dy[1] == - dx[0]); + ok &= (dy[2] == + dx[0]); + // + ok &= (dy[3] == - dx[0]); + ok &= (dy[4] == 0. ); // used to be (dy[1] == - dx[0]); + ok &= (dy[5] == + dx[0]); + + // reverse computation of derivative of y[0] + p = 1; + CPPAD_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] + w[0] = 0.; w[1] = 1.; + dw = f.Reverse(p, w); + ok &= (dw[0] == 0.); + + // reverse computation of derivative of y[5] + w[1] = 0.; w[5] = 1.; + dw = f.Reverse(p, w); + ok &= (dw[0] == 1.); + + // use a VecAD::reference object with abs and fabs + CppAD::VecAD v(1); + AD zero(0); + v[zero] = -1; + AD result = fabs(v[zero]); + ok &= NearEqual(result, 1., eps99, eps99); + result = fabs(v[zero]); + ok &= NearEqual(result, 1., eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/for_one.cpp cppad-2019.02.00.0/example/general/for_one.cpp --- cppad-2018.00.00.0/example/general/for_one.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/for_one.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin for_one.cpp$$ $spell - Cpp + Cpp $$ $section First Order Partial Driver: Example and Test$$ -$code $srcfile%example/general/for_one.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -28,65 +27,65 @@ # include namespace { // ------------------------------------------------------- // define the template function ForOneCases in empty namespace -template +template bool ForOneCases() -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - using CppAD::exp; - using CppAD::sin; - using CppAD::cos; - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 1.; - X[1] = 2.; - - // declare independent variables and starting recording - CppAD::Independent(X); - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0] * exp( X[1] ); - Y[1] = X[0] * sin( X[1] ); - Y[2] = X[0] * cos( X[1] ); - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - Vector x(n); - x[0] = 2.; - x[1] = 1.; - - // compute partial of y w.r.t x[0] - Vector dy(m); - dy = f.ForOne(x, 0); - ok &= NearEqual( dy[0], exp(x[1]), eps99, eps99); // for y[0] - ok &= NearEqual( dy[1], sin(x[1]), eps99, eps99); // for y[1] - ok &= NearEqual( dy[2], cos(x[1]), eps99, eps99); // for y[2] - - // compute partial of F w.r.t x[1] - dy = f.ForOne(x, 1); - ok &= NearEqual( dy[0], x[0]*exp(x[1]), eps99, eps99); - ok &= NearEqual( dy[1], x[0]*cos(x[1]), eps99, eps99); - ok &= NearEqual( dy[2], -x[0]*sin(x[1]), eps99, eps99); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + using CppAD::exp; + using CppAD::sin; + using CppAD::cos; + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 1.; + X[1] = 2.; + + // declare independent variables and starting recording + CppAD::Independent(X); + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0] * exp( X[1] ); + Y[1] = X[0] * sin( X[1] ); + Y[2] = X[0] * cos( X[1] ); + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + Vector x(n); + x[0] = 2.; + x[1] = 1.; + + // compute partial of y w.r.t x[0] + Vector dy(m); + dy = f.ForOne(x, 0); + ok &= NearEqual( dy[0], exp(x[1]), eps99, eps99); // for y[0] + ok &= NearEqual( dy[1], sin(x[1]), eps99, eps99); // for y[1] + ok &= NearEqual( dy[2], cos(x[1]), eps99, eps99); // for y[2] + + // compute partial of F w.r.t x[1] + dy = f.ForOne(x, 1); + ok &= NearEqual( dy[0], x[0]*exp(x[1]), eps99, eps99); + ok &= NearEqual( dy[1], x[0]*cos(x[1]), eps99, eps99); + ok &= NearEqual( dy[2], -x[0]*sin(x[1]), eps99, eps99); - return ok; + return ok; } } // End empty namespace # include # include bool ForOne(void) -{ bool ok = true; - // Run with Vector equal to three different cases - // all of which are Simple Vectors with elements of type double. - ok &= ForOneCases< CppAD::vector >(); - ok &= ForOneCases< std::vector >(); - ok &= ForOneCases< std::valarray >(); - return ok; +{ bool ok = true; + // Run with Vector equal to three different cases + // all of which are Simple Vectors with elements of type double. + ok &= ForOneCases< CppAD::vector >(); + ok &= ForOneCases< std::vector >(); + ok &= ForOneCases< std::valarray >(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/for_two.cpp cppad-2019.02.00.0/example/general/for_two.cpp --- cppad-2018.00.00.0/example/general/for_two.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/general/for_two.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin for_two.cpp$$ $spell - Cpp + Cpp $$ $section Subset of Second Order Partials: Example and Test$$ -$mindex partial$$ -$code $srcfile%example/general/for_two.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,88 +27,88 @@ # include namespace { // ----------------------------------------------------- // define the template function in empty namespace -// bool ForTwoCases(void) -template +// bool ForTwoCases(void) +template bool ForTwoCases() -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - using CppAD::exp; - using CppAD::sin; - using CppAD::cos; - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 1.; - X[1] = 2.; - - // declare independent variables and starting recording - CppAD::Independent(X); - - // a calculation between the domain and range values - AD Square = X[0] * X[0]; - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = Square * exp( X[1] ); - Y[1] = Square * sin( X[1] ); - Y[2] = Square * cos( X[1] ); - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - VectorBase x(n); - x[0] = 2.; - x[1] = 1.; - - // set j and k to compute specific second partials of y - size_t p = 2; - VectorSize_t j(p); - VectorSize_t k(p); - j[0] = 0; k[0] = 0; // for second partial w.r.t. x[0] and x[0] - j[1] = 0; k[1] = 1; // for second partial w.r.t x[0] and x[1] - - // 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]) ] - */ - // second partial of y w.r.t x[0] and x[1] - ok &= NearEqual( 2.*exp(x[1]), ddy[0*p+0], eps99, eps99); - ok &= NearEqual( 2.*sin(x[1]), ddy[1*p+0], eps99, eps99); - ok &= NearEqual( 2.*cos(x[1]), ddy[2*p+0], eps99, eps99); - - // second partial of F w.r.t x[0] and x[1] - ok &= NearEqual( 2.*x[0]*exp(x[1]), ddy[0*p+1], eps99, eps99); - ok &= NearEqual( 2.*x[0]*cos(x[1]), ddy[1*p+1], eps99, eps99); - ok &= NearEqual(-2.*x[0]*sin(x[1]), ddy[2*p+1], eps99, eps99); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + using CppAD::exp; + using CppAD::sin; + using CppAD::cos; + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 1.; + X[1] = 2.; + + // declare independent variables and starting recording + CppAD::Independent(X); + + // a calculation between the domain and range values + AD Square = X[0] * X[0]; + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = Square * exp( X[1] ); + Y[1] = Square * sin( X[1] ); + Y[2] = Square * cos( X[1] ); + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + BaseVector x(n); + x[0] = 2.; + x[1] = 1.; + + // set j and k to compute specific second partials of y + size_t p = 2; + SizeVector_t j(p); + SizeVector_t k(p); + j[0] = 0; k[0] = 0; // for second partial w.r.t. x[0] and x[0] + j[1] = 0; k[1] = 1; // for second partial w.r.t x[0] and x[1] + + // compute the second partials + BaseVector 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]) ] + */ + // second partial of y w.r.t x[0] and x[1] + ok &= NearEqual( 2.*exp(x[1]), ddy[0*p+0], eps99, eps99); + ok &= NearEqual( 2.*sin(x[1]), ddy[1*p+0], eps99, eps99); + ok &= NearEqual( 2.*cos(x[1]), ddy[2*p+0], eps99, eps99); + + // second partial of F w.r.t x[0] and x[1] + ok &= NearEqual( 2.*x[0]*exp(x[1]), ddy[0*p+1], eps99, eps99); + ok &= NearEqual( 2.*x[0]*cos(x[1]), ddy[1*p+1], eps99, eps99); + ok &= NearEqual(-2.*x[0]*sin(x[1]), ddy[2*p+1], eps99, eps99); - return ok; + return ok; } } // End empty namespace # include # include bool ForTwo(void) -{ bool ok = true; - // Run with VectorBase equal to three different cases +{ bool ok = true; + // Run with BaseVector equal to three different cases // all of which are Simple Vectors with elements of type double. - ok &= ForTwoCases< CppAD::vector , std::vector >(); - ok &= ForTwoCases< std::vector , std::vector >(); - ok &= ForTwoCases< std::valarray , std::vector >(); + ok &= ForTwoCases< CppAD::vector , std::vector >(); + ok &= ForTwoCases< std::vector , std::vector >(); + ok &= ForTwoCases< std::valarray , std::vector >(); - // Run with VectorSize_t equal to two other cases + // Run with SizeVector_t equal to two other cases // which are Simple Vectors with elements of type size_t. - ok &= ForTwoCases< std::vector , CppAD::vector >(); - ok &= ForTwoCases< std::vector , std::valarray >(); + ok &= ForTwoCases< std::vector , CppAD::vector >(); + ok &= ForTwoCases< std::vector , std::valarray >(); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/forward.cpp cppad-2019.02.00.0/example/general/forward.cpp --- cppad-2018.00.00.0/example/general/forward.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/forward.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin forward.cpp$$ $spell - Cpp + Cpp $$ $section Forward Mode: Example and Test$$ -$code $srcfile%example/general/forward.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,73 +29,73 @@ // define the template function ForwardCases in empty namespace template bool ForwardCases(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - - // 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[0] * ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // initially, the variable values during taping are stored in f - ok &= f.size_order() == 1; - - // zero order forward mode using notation in forward_zero - // use the template parameter Vector for the vector type - Vector x0(n), y0(m); - x0[0] = 3.; - x0[1] = 4.; - y0 = f.Forward(0, x0); - ok &= NearEqual(y0[0] , x0[0]*x0[0]*x0[1], eps, eps); - ok &= f.size_order() == 1; - - // first order forward mode using notation in forward_one - // X(t) = x0 + x1 * t - // Y(t) = F[X(t)] = y0 + y1 * t + o(t) - Vector x1(n), y1(m); - x1[0] = 1.; - x1[1] = 0.; - y1 = f.Forward(1, x1); // partial F w.r.t. x_0 - ok &= NearEqual(y1[0] , 2.*x0[0]*x0[1], eps, eps); - ok &= f.size_order() == 2; - - // second order forward mode using notation in forward_order - // X(t) = x0 + x1 * t + x2 * t^2 - // Y(t) = F[X(t)] = y0 + y1 * t + y2 * t^2 + o(t^3) - Vector x2(n), y2(m); - x2[0] = 0.; - x2[1] = 0.; - y2 = f.Forward(2, x2); - double F_00 = 2. * y2[0]; // second partial F w.r.t. x_0, x_0 - ok &= NearEqual(F_00, 2.*x0[1], eps, eps); - ok &= f.size_order() == 3; +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + + // 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[0] * ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // initially, the variable values during taping are stored in f + ok &= f.size_order() == 1; + + // zero order forward mode using notation in forward_zero + // use the template parameter Vector for the vector type + Vector x0(n), y0(m); + x0[0] = 3.; + x0[1] = 4.; + y0 = f.Forward(0, x0); + ok &= NearEqual(y0[0] , x0[0]*x0[0]*x0[1], eps, eps); + ok &= f.size_order() == 1; + + // first order forward mode using notation in forward_one + // X(t) = x0 + x1 * t + // Y(t) = F[X(t)] = y0 + y1 * t + o(t) + Vector x1(n), y1(m); + x1[0] = 1.; + x1[1] = 0.; + y1 = f.Forward(1, x1); // partial F w.r.t. x_0 + ok &= NearEqual(y1[0] , 2.*x0[0]*x0[1], eps, eps); + ok &= f.size_order() == 2; + + // second order forward mode using notation in forward_order + // X(t) = x0 + x1 * t + x2 * t^2 + // Y(t) = F[X(t)] = y0 + y1 * t + y2 * t^2 + o(t^3) + Vector x2(n), y2(m); + x2[0] = 0.; + x2[1] = 0.; + y2 = f.Forward(2, x2); + double F_00 = 2. * y2[0]; // second partial F w.r.t. x_0, x_0 + ok &= NearEqual(F_00, 2.*x0[1], eps, eps); + ok &= f.size_order() == 3; - return ok; + return ok; } } // End empty namespace # include # include bool Forward(void) -{ bool ok = true; - // Run with Vector equal to three different cases - // all of which are Simple Vectors with elements of type double. - ok &= ForwardCases< CppAD::vector >(); - ok &= ForwardCases< std::vector >(); - ok &= ForwardCases< std::valarray >(); - return ok; +{ bool ok = true; + // Run with Vector equal to three different cases + // all of which are Simple Vectors with elements of type double. + ok &= ForwardCases< CppAD::vector >(); + ok &= ForwardCases< std::vector >(); + ok &= ForwardCases< std::valarray >(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/forward_dir.cpp cppad-2019.02.00.0/example/general/forward_dir.cpp --- cppad-2018.00.00.0/example/general/forward_dir.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/forward_dir.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin forward_dir.cpp$$ $spell - Cpp + Cpp $$ $section Forward Mode: Example and Test of Multiple Directions$$ -$mindex orders order$$ -$code $srcfile%example/general/forward_dir.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -28,82 +26,82 @@ # include # include bool forward_dir(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * std::numeric_limits::epsilon(); - size_t j; - - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - ax[2] = 2.; - - // 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] * ax[2]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // initially, the variable values during taping are stored in f - ok &= f.size_order() == 1; - - // zero order Taylor coefficients - CPPAD_TESTVECTOR(double) x0(n), y0; - for(j = 0; j < n; j++) - x0[j] = double(j+1); - y0 = f.Forward(0, x0); - ok &= size_t( y0.size() ) == m; - double y_0 = 1.*2.*3.; - ok &= NearEqual(y0[0], y_0, eps, eps); - - // 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 + 1 + ell); - } - 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 ] = 0.0; - } - y2 = f.Forward(2, r, x2); - 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) - 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.; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - // check number of orders - ok &= f.size_order() == 3; - // - // check number of directions - ok &= f.size_direction() == 2; - // - return ok; +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); + size_t j; + + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + ax[2] = 2.; + + // 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] * ax[2]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // initially, the variable values during taping are stored in f + ok &= f.size_order() == 1; + + // zero order Taylor coefficients + CPPAD_TESTVECTOR(double) x0(n), y0; + for(j = 0; j < n; j++) + x0[j] = double(j+1); + y0 = f.Forward(0, x0); + ok &= size_t( y0.size() ) == m; + double y_0 = 1.*2.*3.; + ok &= NearEqual(y0[0], y_0, eps, eps); + + // 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 + 1 + ell); + } + 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 ] = 0.0; + } + y2 = f.Forward(2, r, x2); + 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) + 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.; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + // check number of orders + ok &= f.size_order() == 3; + // + // check number of directions + ok &= f.size_direction() == 2; + // + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/forward_order.cpp cppad-2019.02.00.0/example/general/forward_order.cpp --- cppad-2018.00.00.0/example/general/forward_order.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/forward_order.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin forward_order.cpp$$ $spell - Cpp + Cpp $$ $section Forward Mode: Example and Test of Multiple Orders$$ -$code $srcfile%example/general/forward_order.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -27,61 +26,61 @@ # include # include bool forward_order(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - - // 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[0] * ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // initially, the variable values during taping are stored in f - ok &= f.size_order() == 1; - - // Compute three forward orders at one - size_t q = 2, q1 = q+1; - CPPAD_TESTVECTOR(double) xq(n*q1), yq; - xq[q1*0 + 0] = 3.; xq[q1*1 + 0] = 4.; // x^0 (order zero) - 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 ] - yq = f.Forward(q, xq); - 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) - // - // check y^0 (order zero) - CPPAD_TESTVECTOR(double) x0(n); - x0[0] = xq[q1*0 + 0]; - x0[1] = xq[q1*1 + 0]; - ok &= NearEqual(yq[q1*0 + 0] , x0[0]*x0[0]*x0[1], eps, eps); - // - // check y^1 (order one) - ok &= NearEqual(yq[q1*0 + 1] , 2.*x0[0]*x0[1], eps, eps); - // - // check y^2 (order two) - double F_00 = 2. * yq[q1*0 + 2]; // second partial F w.r.t. x_0, x_0 - ok &= NearEqual(F_00, 2.*x0[1], eps, eps); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + + // 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[0] * ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // initially, the variable values during taping are stored in f + ok &= f.size_order() == 1; + + // Compute three forward orders at one + size_t q = 2, q1 = q+1; + CPPAD_TESTVECTOR(double) xq(n*q1), yq; + xq[q1*0 + 0] = 3.; xq[q1*1 + 0] = 4.; // x^0 (order zero) + 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 ] + yq = f.Forward(q, xq); + 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) + // + // check y^0 (order zero) + CPPAD_TESTVECTOR(double) x0(n); + x0[0] = xq[q1*0 + 0]; + x0[1] = xq[q1*1 + 0]; + ok &= NearEqual(yq[q1*0 + 0] , x0[0]*x0[0]*x0[1], eps, eps); + // + // check y^1 (order one) + ok &= NearEqual(yq[q1*0 + 1] , 2.*x0[0]*x0[1], eps, eps); + // + // check y^2 (order two) + double F_00 = 2. * yq[q1*0 + 2]; // second partial F w.r.t. x_0, x_0 + ok &= NearEqual(F_00, 2.*x0[1], eps, eps); - // check number of orders per variable - ok &= f.size_order() == 3; + // check number of orders per variable + ok &= f.size_order() == 3; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/fun_assign.cpp cppad-2019.02.00.0/example/general/fun_assign.cpp --- cppad-2018.00.00.0/example/general/fun_assign.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/fun_assign.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,22 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin fun_assign.cpp$$ $section ADFun Assignment: Example and Test$$ -$mindex assignment$$ -$code $srcfile%example/general/fun_assign.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -27,81 +25,84 @@ # include bool fun_assign(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t i, j; - - // ten times machine percision - double eps = 10. * CppAD::numeric_limits::epsilon(); - - // two ADFun objects - CppAD::ADFun g; - - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) x(n); - for(j = 0; j < n; j++) - x[j] = AD(j + 2); - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // range space vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = x[0] + x[0] * x[1]; - y[1] = x[1] * x[2] + x[2]; - - // Store operation sequence, and order zero forward results, in f. - CppAD::ADFun f(x, y); - - // sparsity pattern for the identity matrix - CPPAD_TESTVECTOR(std::set) r(n); - for(j = 0; j < n; j++) - r[j].insert(j); - - // Store forward mode sparsity pattern in f - f.ForSparseJac(n, r); - - // make a copy in g - g = f; - - // check values that should be equal - ok &= ( g.size_order() == f.size_order() ); - ok &= ( (g.size_forward_bool() > 0) == (f.size_forward_bool() > 0) ); - ok &= ( (g.size_forward_set() > 0) == (f.size_forward_set() > 0) ); - - // Use zero order Taylor coefficient from f for first order - // calculation using g. - CPPAD_TESTVECTOR(double) dx(n), dy(m); - for(i = 0; i < n; i++) - 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] - - // Use forward Jacobian sparsity pattern from f to calculate - // Hessian sparsity pattern using g. - CPPAD_TESTVECTOR(std::set) s(1), h(n); - 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] +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t i, j; + + // ten times machine percision + double eps = 10. * CppAD::numeric_limits::epsilon(); + + // an empty ADFun object + CppAD::ADFun g; + + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) x(n); + for(j = 0; j < n; j++) + x[j] = AD(j + 2); + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // range space vector + size_t m = 2; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = x[0] + x[0] * x[1]; + y[1] = x[1] * x[2] + x[2]; + + // Store operation sequence, and order zero forward results, in f. + // If CPPAD_USE_CPLUSPLUS_2011 in cppad/configure.hpp is 1, + // this assignment will use move semantics + CppAD::ADFun f; + f = CppAD::ADFun(x, y); + + // sparsity pattern for the identity matrix + CPPAD_TESTVECTOR(std::set) r(n); + for(j = 0; j < n; j++) + r[j].insert(j); + + // Store forward mode sparsity pattern in f + f.ForSparseJac(n, r); + + // make a copy of f in g + g = f; + + // check values that should be equal + ok &= ( g.size_order() == f.size_order() ); + ok &= ( (g.size_forward_bool() > 0) == (f.size_forward_bool() > 0) ); + ok &= ( (g.size_forward_set() > 0) == (f.size_forward_set() > 0) ); + + // Use zero order Taylor coefficient from f for first order + // calculation using g. + CPPAD_TESTVECTOR(double) dx(n), dy(m); + for(i = 0; i < n; i++) + 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] + + // Use forward Jacobian sparsity pattern from f to calculate + // Hessian sparsity pattern using g. + CPPAD_TESTVECTOR(std::set) s(1), h(n); + 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] - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/fun_check.cpp cppad-2019.02.00.0/example/general/fun_check.cpp --- cppad-2018.00.00.0/example/general/fun_check.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/fun_check.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,30 +1,28 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* ! WARNING: This file is used as an example by FunConstruct and Dependent $begin fun_check.cpp$$ $spell - abs + abs $$ $section ADFun Check and Re-Tape: Example and Test$$ -$mindex FunCheck Dependent$$ -$code $srcfile%example/general/fun_check.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -36,108 +34,109 @@ template class Fun { private: - size_t n; + size_t n; public: - // function constructor - Fun(size_t n_) : n(n_) - { } - // function evaluator - Vector operator() (const Vector &x) - { Vector y(n); - size_t i; - for(i = 0; i < n; i++) - { // This operaiton sequence depends on x - if( x[i] >= 0 ) - y[i] = exp(x[i]); - else y[i] = exp(-x[i]); - } - return y; - } + // function constructor + Fun(size_t n_) : n(n_) + { } + // function evaluator + Vector operator() (const Vector &x) + { Vector y(n); + size_t i; + for(i = 0; i < n; i++) + { // This operaiton sequence depends on x + if( x[i] >= 0 ) + y[i] = exp(x[i]); + else + y[i] = exp(-x[i]); + } + return y; + } }; // template function FunCheckCases in empty namespace template bool FunCheckCases(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::ADFun; - using CppAD::Independent; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // use the ADFun default constructor - ADFun f; - - // domain space vector - size_t n = 2; - ADVector X(n); - X[0] = -1.; - X[1] = 1.; - - // declare independent variables and starting recording - Independent(X); - - // create function object to use with AD - Fun< AD, ADVector > G(n); - - // range space vector - size_t m = n; - ADVector Y(m); - Y = G(X); - - // stop tape and store operation sequence in f : X -> Y - f.Dependent(X, Y); - ok &= (f.size_order() == 0); // no implicit forward operation - - // create function object to use with double - Fun g(n); - - // 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 = eps99; - double a = eps99; - ok &= FunCheck(f, g, x, a, r); - - // function values should not agree when the independent variable - // values are the negative of values during recording - for(j = 0; j < n; j++) - x[j] = - Value(X[j]); - ok &= ! FunCheck(f, g, x, a, r); - - // re-tape to obtain the new AD of double operation sequence - for(j = 0; j < n; j++) - X[j] = x[j]; - Independent(X); - Y = G(X); - - // stop tape and store operation sequence in f : X -> Y - f.Dependent(X, Y); - ok &= (f.size_order() == 0); // no implicit forward with this x +{ bool ok = true; + using CppAD::AD; + using CppAD::ADFun; + using CppAD::Independent; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // use the ADFun default constructor + ADFun f; + + // domain space vector + size_t n = 2; + ADVector X(n); + X[0] = -1.; + X[1] = 1.; + + // declare independent variables and starting recording + Independent(X); + + // create function object to use with AD + Fun< AD, ADVector > G(n); + + // range space vector + size_t m = n; + ADVector Y(m); + Y = G(X); + + // stop tape and store operation sequence in f : X -> Y + f.Dependent(X, Y); + ok &= (f.size_order() == 0); // no implicit forward operation + + // create function object to use with double + Fun g(n); + + // 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 = eps99; + double a = eps99; + ok &= FunCheck(f, g, x, a, r); + + // function values should not agree when the independent variable + // values are the negative of values during recording + for(j = 0; j < n; j++) + x[j] = - Value(X[j]); + ok &= ! FunCheck(f, g, x, a, r); + + // re-tape to obtain the new AD of double operation sequence + for(j = 0; j < n; j++) + X[j] = x[j]; + Independent(X); + Y = G(X); + + // stop tape and store operation sequence in f : X -> Y + f.Dependent(X, Y); + ok &= (f.size_order() == 0); // no implicit forward with this x - // function values should agree now - ok &= FunCheck(f, g, x, a, r); + // function values should agree now + ok &= FunCheck(f, g, x, a, r); - return ok; + return ok; } } // End empty namespace # include # include bool FunCheck(void) -{ bool ok = true; - typedef CppAD::vector Vector1; - typedef CppAD::vector< CppAD::AD > ADVector1; - typedef std::vector Vector2; - typedef std::vector< CppAD::AD > ADVector2; - 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 - // double and AD respectively. - ok &= FunCheckCases< Vector1, ADVector2 >(); - ok &= FunCheckCases< Vector2, ADVector3 >(); - ok &= FunCheckCases< Vector3, ADVector1 >(); - return ok; +{ bool ok = true; + typedef CppAD::vector Vector1; + typedef CppAD::vector< CppAD::AD > ADVector1; + typedef std::vector Vector2; + typedef std::vector< CppAD::AD > ADVector2; + 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 + // double and AD respectively. + ok &= FunCheckCases< Vector1, ADVector2 >(); + ok &= FunCheckCases< Vector2, ADVector3 >(); + ok &= FunCheckCases< Vector3, ADVector1 >(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/general.cpp cppad-2019.02.00.0/example/general/general.cpp --- cppad-2018.00.00.0/example/general/general.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/general.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,18 +1,19 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin general.cpp$$ $spell - Cpp + Cpp $$ $section CppAD Examples and Tests$$ @@ -20,9 +21,7 @@ $head Running Tests$$ To build this program and run its correctness tests see $cref cmake_check$$. -$code $srcfile%example/general/general.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -46,9 +45,8 @@ // test runner # include -// prototype external compiled tests (this line expected by bin/new_test.sh) +// BEGIN_SORT_THIS_LINE_PLUS_1 extern bool abort_recording(void); -extern bool fabs(void); extern bool acosh(void); extern bool acos(void); extern bool ad_assign(void); @@ -65,6 +63,7 @@ extern bool atanh(void); extern bool atan(void); extern bool azmul(void); +extern bool base2ad(void); extern bool base_require(void); extern bool BenderQuad(void); extern bool BoolFun(void); @@ -85,6 +84,7 @@ extern bool Erf(void); extern bool expm1(void); extern bool exp(void); +extern bool fabs(void); extern bool ForOne(void); extern bool ForTwo(void); extern bool forward_dir(void); @@ -117,13 +117,14 @@ extern bool mul_level(void); extern bool Mul(void); extern bool NearEqualExt(void); +extern bool new_dynamic(void); extern bool number_skip(void); extern bool NumericType(void); extern bool num_limits(void); extern bool OdeStiff(void); -extern bool ode_taylor(void); +extern bool taylor_ode(void); extern bool opt_val_hes(void); -extern bool ParVar(void); +extern bool con_dyn_var(void); extern bool Poly(void); extern bool pow_int(void); extern bool pow(void); @@ -152,131 +153,136 @@ extern bool Value(void); extern bool Var2Par(void); extern bool vec_ad(void); +// END_SORT_THIS_LINE_MINUS_1 // main program that runs all the tests int main(void) -{ std::string group = "example/general"; - size_t width = 20; - CppAD::test_boolofvoid Run(group, width); - - // This line is used by test_one.sh - - // run external compiled tests (this line expected by bin/new_test.sh) - Run( abort_recording, "abort_recording" ); - Run( fabs, "fabs" ); - Run( acos, "acos" ); - Run( acosh, "acosh" ); - Run( ad_assign, "ad_assign" ); - Run( ad_ctor, "ad_ctor" ); - Run( Add, "Add" ); - Run( AddEq, "AddEq" ); - Run( ad_fun, "ad_fun" ); - Run( ad_in_c, "ad_in_c" ); - Run( ad_input, "ad_input" ); - Run( ad_output, "ad_output" ); - Run( asin, "asin" ); - Run( asinh, "asinh" ); - Run( atan2, "atan2" ); - Run( atan, "atan" ); - Run( atanh, "atanh" ); - Run( azmul, "azmul" ); - Run( BenderQuad, "BenderQuad" ); - Run( BoolFun, "BoolFun" ); - Run( capacity_order, "capacity_order" ); - Run( change_param, "change_param" ); - Run( compare_change, "compare_change" ); - Run( Compare, "Compare" ); - Run( complex_poly, "complex_poly" ); - Run( CondExp, "CondExp" ); - Run( Cos, "Cos" ); - Run( Cosh, "Cosh" ); - Run( Div, "Div" ); - Run( DivEq, "DivEq" ); - Run( EqualOpSeq, "EqualOpSeq" ); - Run( Erf, "Erf" ); - Run( exp, "exp" ); - Run( expm1, "expm1" ); - Run( ForOne, "ForOne" ); - Run( ForTwo, "ForTwo" ); - Run( forward_dir, "forward_dir" ); - Run( Forward, "Forward" ); - Run( forward_order, "forward_order" ); - Run( fun_assign, "fun_assign" ); - Run( FunCheck, "FunCheck" ); - Run( HesLagrangian, "HesLagrangian" ); - Run( HesLuDet, "HesLuDet" ); - Run( HesMinorDet, "HesMinorDet" ); - Run( Hessian, "Hessian" ); - Run( HesTimesDir, "HesTimesDir" ); - Run( Independent, "Independent" ); - Run( Integer, "Integer" ); - Run( Interface2C, "Interface2C" ); - Run( interp_onetape, "interp_onetape" ); - Run( interp_retape, "interp_retape" ); - Run( JacLuDet, "JacLuDet" ); - Run( JacMinorDet, "JacMinorDet" ); - Run( Jacobian, "Jacobian" ); - Run( log10, "log10" ); - Run( log1p, "log1p" ); - Run( log, "log" ); - Run( LuRatio, "LuRatio" ); - Run( LuVecADOk, "LuVecADOk" ); - Run( MulEq, "MulEq" ); - Run( mul_level, "mul_level" ); - Run( mul_level_ode, "mul_level_ode" ); - Run( Mul, "Mul" ); - Run( NearEqualExt, "NearEqualExt" ); - Run( number_skip, "number_skip" ); - Run( NumericType, "NumericType" ); - Run( num_limits, "num_limits" ); - Run( OdeStiff, "OdeStiff" ); - Run( ode_taylor, "ode_taylor" ); - Run( opt_val_hes, "opt_val_hes" ); - Run( ParVar, "ParVar" ); - Run( Poly, "Poly" ); - Run( pow_int, "pow_int" ); - Run( pow, "pow" ); - Run( reverse_any, "reverse_any" ); - Run( reverse_one, "reverse_one" ); - Run( reverse_three, "reverse_three" ); - Run( reverse_two, "reverse_two" ); - Run( RevOne, "RevOne" ); - Run( RevTwo, "RevTwo" ); - Run( Rosen34, "Rosen34" ); - Run( runge_45_2, "runge_45_2" ); - Run( seq_property, "seq_property" ); - Run( sign, "sign" ); - Run( Sinh, "Sinh" ); - Run( Sin, "Sin" ); - Run( Sqrt, "Sqrt" ); - Run( StackMachine, "StackMachine" ); - Run( SubEq, "SubEq" ); - Run( Sub, "Sub" ); - Run( Tanh, "Tanh" ); - Run( Tan, "Tan" ); - Run( TapeIndex, "TapeIndex" ); - Run( UnaryMinus, "UnaryMinus" ); - Run( UnaryPlus, "UnaryPlus" ); - Run( Value, "Value" ); - Run( Var2Par, "Var2Par" ); - Run( vec_ad, "vec_ad" ); +{ std::string group = "example/general"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + // BEGIN_SORT_THIS_LINE_PLUS_1 + Run( abort_recording, "abort_recording" ); + Run( acos, "acos" ); + Run( acosh, "acosh" ); + Run( ad_assign, "ad_assign" ); + Run( ad_ctor, "ad_ctor" ); + Run( Add, "Add" ); + Run( AddEq, "AddEq" ); + Run( ad_fun, "ad_fun" ); + Run( ad_in_c, "ad_in_c" ); + Run( ad_input, "ad_input" ); + Run( ad_output, "ad_output" ); + Run( asin, "asin" ); + Run( asinh, "asinh" ); + Run( atan2, "atan2" ); + Run( atan, "atan" ); + Run( atanh, "atanh" ); + Run( azmul, "azmul" ); + Run( base2ad, "base2ad" ); + Run( base_require, "base_require" ); + Run( BenderQuad, "BenderQuad" ); + Run( BoolFun, "BoolFun" ); + Run( capacity_order, "capacity_order" ); + Run( change_param, "change_param" ); + Run( compare_change, "compare_change" ); + Run( Compare, "Compare" ); + Run( complex_poly, "complex_poly" ); + Run( CondExp, "CondExp" ); + Run( Cos, "Cos" ); + Run( Cosh, "Cosh" ); + Run( Div, "Div" ); + Run( DivEq, "DivEq" ); + Run( EqualOpSeq, "EqualOpSeq" ); + Run( Erf, "Erf" ); + Run( exp, "exp" ); + Run( expm1, "expm1" ); + Run( fabs, "fabs" ); + Run( ForOne, "ForOne" ); + Run( ForTwo, "ForTwo" ); + Run( forward_dir, "forward_dir" ); + Run( Forward, "Forward" ); + Run( forward_order, "forward_order" ); + Run( fun_assign, "fun_assign" ); + Run( FunCheck, "FunCheck" ); + Run( HesLagrangian, "HesLagrangian" ); + Run( HesLuDet, "HesLuDet" ); + Run( HesMinorDet, "HesMinorDet" ); + Run( Hessian, "Hessian" ); + Run( HesTimesDir, "HesTimesDir" ); + Run( Independent, "Independent" ); + Run( Integer, "Integer" ); + Run( Interface2C, "Interface2C" ); + Run( interp_onetape, "interp_onetape" ); + Run( interp_retape, "interp_retape" ); + Run( JacLuDet, "JacLuDet" ); + Run( JacMinorDet, "JacMinorDet" ); + Run( Jacobian, "Jacobian" ); + Run( log10, "log10" ); + Run( log1p, "log1p" ); + Run( log, "log" ); + Run( LuRatio, "LuRatio" ); + Run( LuVecADOk, "LuVecADOk" ); + Run( MulEq, "MulEq" ); + Run( mul_level, "mul_level" ); + Run( mul_level_ode, "mul_level_ode" ); + Run( Mul, "Mul" ); + Run( NearEqualExt, "NearEqualExt" ); + Run( new_dynamic, "new_dynamic" ); + Run( number_skip, "number_skip" ); + Run( NumericType, "NumericType" ); + Run( num_limits, "num_limits" ); + Run( OdeStiff, "OdeStiff" ); + Run( taylor_ode, "ode_taylor" ); + Run( opt_val_hes, "opt_val_hes" ); + Run( con_dyn_var, "con_dyn_var" ); + Run( Poly, "Poly" ); + Run( pow_int, "pow_int" ); + Run( pow, "pow" ); + Run( reverse_any, "reverse_any" ); + Run( reverse_one, "reverse_one" ); + Run( reverse_three, "reverse_three" ); + Run( reverse_two, "reverse_two" ); + Run( RevOne, "RevOne" ); + Run( RevTwo, "RevTwo" ); + Run( Rosen34, "Rosen34" ); + Run( runge_45_2, "runge_45_2" ); + Run( seq_property, "seq_property" ); + Run( sign, "sign" ); + Run( Sinh, "Sinh" ); + Run( Sin, "Sin" ); + Run( Sqrt, "Sqrt" ); + Run( StackMachine, "StackMachine" ); + Run( SubEq, "SubEq" ); + Run( Sub, "Sub" ); + Run( Tanh, "Tanh" ); + Run( Tan, "Tan" ); + Run( TapeIndex, "TapeIndex" ); + Run( UnaryMinus, "UnaryMinus" ); + Run( UnaryPlus, "UnaryPlus" ); + Run( Value, "Value" ); + Run( Var2Par, "Var2Par" ); + Run( vec_ad, "vec_ad" ); + // END_SORT_THIS_LINE_MINUS_1 # ifndef CPPAD_DEBUG_AND_RELEASE - Run( check_for_nan, "check_for_nan" ); + Run( check_for_nan, "check_for_nan" ); # endif # if CPPAD_HAS_ADOLC - Run( mul_level_adolc, "mul_level_adolc" ); - Run( mul_level_adolc_ode, "mul_level_adolc_ode" ); + Run( mul_level_adolc, "mul_level_adolc" ); + Run( mul_level_adolc_ode, "mul_level_adolc_ode" ); # endif # if CPPAD_HAS_EIGEN - Run( eigen_array, "eigen_array" ); - Run( eigen_det, "eigen_det" ); + Run( eigen_array, "eigen_array" ); + Run( eigen_det, "eigen_det" ); # endif - // - // check for memory leak - bool memory_ok = CppAD::thread_alloc::free_all(); - // print summary at end - bool ok = Run.summary(memory_ok); - // - return static_cast( ! ok ); + // + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); } // END C++ diff -Nru cppad-2018.00.00.0/example/general/hes_lagrangian.cpp cppad-2019.02.00.0/example/general/hes_lagrangian.cpp --- cppad-2018.00.00.0/example/general/hes_lagrangian.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/hes_lagrangian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,27 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin hes_lagrangian.cpp$$ $spell - Cpp - HesLagrangian + Cpp + HesLagrangian $$ $comment ! NOTE the title states that this example is used two places !$$ $section Hessian of Lagrangian and ADFun Default Constructor: Example and Test$$ -$code $srcfile%example/general/hes_lagrangian.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -32,208 +31,208 @@ # include namespace { - CppAD::AD Lagragian( - const CppAD::vector< CppAD::AD > &xyz ) - { using CppAD::AD; - assert( xyz.size() == 6 ); - - AD x0 = xyz[0]; - AD x1 = xyz[1]; - AD x2 = xyz[2]; - AD y0 = xyz[3]; - AD y1 = xyz[4]; - AD z = xyz[5]; - - // compute objective function - AD f = x0 * x0; - // compute constraint functions - AD g0 = 1. + 2.*x1 + 3.*x2; - 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 ) - { using CppAD::AD; - using CppAD::vector; - assert( x.size() == 3 ); - - vector< AD > fg(3); - fg[0] = x[0] * x[0]; - fg[1] = 1. + 2. * x[1] + 3. * x[2]; - fg[2] = log( x[0] * x[2] ); - - return fg; - } - bool CheckHessian( - CppAD::vector H , - double x0, double x1, double x2, double y0, double y1, double z ) - { using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - bool ok = true; - size_t n = 3; - assert( H.size() == n * n ); - /* - 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_00 = 2 * z - y1 / ( x0 * x0 ) - double check = 2. * z - y1 / (x0 * x0); - ok &= NearEqual(H[0 * n + 0], check, eps99, eps99); - // L_01 = L_10 = 0 - ok &= NearEqual(H[0 * n + 1], 0., eps99, eps99); - ok &= NearEqual(H[1 * n + 0], 0., eps99, eps99); - // L_02 = L_20 = 0 - ok &= NearEqual(H[0 * n + 2], 0., eps99, eps99); - ok &= NearEqual(H[2 * n + 0], 0., eps99, eps99); - // L_11 = 0 - ok &= NearEqual(H[1 * n + 1], 0., eps99, eps99); - // L_12 = L_21 = 0 - ok &= NearEqual(H[1 * n + 2], 0., eps99, eps99); - ok &= NearEqual(H[2 * n + 1], 0., eps99, eps99); - // L_22 = - y1 / (x2 * x2) - check = - y1 / (x2 * x2); - ok &= NearEqual(H[2 * n + 2], check, eps99, eps99); - - return ok; - } - bool UseL() - { using CppAD::AD; - using CppAD::vector; - - // double values corresponding to x, y, and z vectors - double x0(.5), x1(1e3), x2(1), y0(2.), y1(3.), z(4.); - - // domain space vector - size_t n = 3; - vector< AD > a_x(n); - a_x[0] = x0; - a_x[1] = x1; - a_x[2] = x2; - - // declare a_x as independent variable vector and start recording - CppAD::Independent(a_x); - - // vector including x, y, and z - vector< AD > a_xyz(n + 2 + 1); - a_xyz[0] = a_x[0]; - a_xyz[1] = a_x[1]; - a_xyz[2] = a_x[2]; - a_xyz[3] = y0; - a_xyz[4] = y1; - a_xyz[5] = z; - - // range space vector - size_t m = 1; - vector< AD > a_L(m); - a_L[0] = Lagragian(a_xyz); - - // create K: x -> L and stop tape recording. - // Use default ADFun construction for example purposes. - CppAD::ADFun K; - K.Dependent(a_x, a_L); - - // Operation sequence corresponding to K depends on - // value of y0, y1, and z. Must redo calculations above when - // y0, y1, or z changes. - - // declare independent variable vector and Hessian - vector x(n); - vector H( n * n ); - - // point at which we are computing the Hessian - // (must redo calculations below each time x changes) - x[0] = x0; - x[1] = x1; - x[2] = x2; - H = K.Hessian(x, 0); - - // check this Hessian calculation - return CheckHessian(H, x0, x1, x2, y0, y1, z); - } - bool Usefg() - { using CppAD::AD; - using CppAD::vector; - - // parameters defining problem - double x0(.5), x1(1e3), x2(1), y0(2.), y1(3.), z(4.); - - // domain space vector - size_t n = 3; - vector< AD > a_x(n); - a_x[0] = x0; - a_x[1] = x1; - a_x[2] = x2; - - // declare a_x as independent variable vector and start recording - CppAD::Independent(a_x); - - // range space vector - size_t m = 3; - vector< AD > a_fg(m); - a_fg = fg(a_x); - - // create K: x -> fg and stop tape recording - CppAD::ADFun K; - K.Dependent(a_x, a_fg); - - // 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 - vector x(n); - vector H( n * n ); - vector dx(n); - vector w(m); - vector dw(2*n); - - // compute Hessian at this value of x - // (must redo calculations below each time x changes) - x[0] = x0; - x[1] = x1; - x[2] = x2; - K.Forward(0, x); - - // set weights to Lagrange multiplier values - // (must redo calculations below each time y0, y1, or z changes) - w[0] = z; - w[1] = y0; - w[2] = y1; - - // initialize dx as zero - size_t i, j; - for(i = 0; i < n; i++) - dx[i] = 0.; - // loop over components of x - for(i = 0; i < n; i++) - { dx[i] = 1.; // dx is i-th elementary vector - K.Forward(1, dx); // partial w.r.t dx - dw = K.Reverse(2, w); // deritavtive of partial - for(j = 0; j < n; j++) - H[ i * n + j ] = dw[ j * 2 + 1 ]; - dx[i] = 0.; // dx is zero vector - } - - // check this Hessian calculation - return CheckHessian(H, x0, x1, x2, y0, y1, z); - } + CppAD::AD Lagragian( + const CppAD::vector< CppAD::AD > &xyz ) + { using CppAD::AD; + assert( xyz.size() == 6 ); + + AD x0 = xyz[0]; + AD x1 = xyz[1]; + AD x2 = xyz[2]; + AD y0 = xyz[3]; + AD y1 = xyz[4]; + AD z = xyz[5]; + + // compute objective function + AD f = x0 * x0; + // compute constraint functions + AD g0 = 1. + 2.*x1 + 3.*x2; + 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 ) + { using CppAD::AD; + using CppAD::vector; + assert( x.size() == 3 ); + + vector< AD > fg(3); + fg[0] = x[0] * x[0]; + fg[1] = 1. + 2. * x[1] + 3. * x[2]; + fg[2] = log( x[0] * x[2] ); + + return fg; + } + bool CheckHessian( + CppAD::vector H , + double x0, double x1, double x2, double y0, double y1, double z ) + { using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + bool ok = true; + size_t n = 3; + assert( H.size() == n * n ); + /* + 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_00 = 2 * z - y1 / ( x0 * x0 ) + double check = 2. * z - y1 / (x0 * x0); + ok &= NearEqual(H[0 * n + 0], check, eps99, eps99); + // L_01 = L_10 = 0 + ok &= NearEqual(H[0 * n + 1], 0., eps99, eps99); + ok &= NearEqual(H[1 * n + 0], 0., eps99, eps99); + // L_02 = L_20 = 0 + ok &= NearEqual(H[0 * n + 2], 0., eps99, eps99); + ok &= NearEqual(H[2 * n + 0], 0., eps99, eps99); + // L_11 = 0 + ok &= NearEqual(H[1 * n + 1], 0., eps99, eps99); + // L_12 = L_21 = 0 + ok &= NearEqual(H[1 * n + 2], 0., eps99, eps99); + ok &= NearEqual(H[2 * n + 1], 0., eps99, eps99); + // L_22 = - y1 / (x2 * x2) + check = - y1 / (x2 * x2); + ok &= NearEqual(H[2 * n + 2], check, eps99, eps99); + + return ok; + } + bool UseL() + { using CppAD::AD; + using CppAD::vector; + + // double values corresponding to x, y, and z vectors + double x0(.5), x1(1e3), x2(1), y0(2.), y1(3.), z(4.); + + // domain space vector + size_t n = 3; + vector< AD > a_x(n); + a_x[0] = x0; + a_x[1] = x1; + a_x[2] = x2; + + // declare a_x as independent variable vector and start recording + CppAD::Independent(a_x); + + // vector including x, y, and z + vector< AD > a_xyz(n + 2 + 1); + a_xyz[0] = a_x[0]; + a_xyz[1] = a_x[1]; + a_xyz[2] = a_x[2]; + a_xyz[3] = y0; + a_xyz[4] = y1; + a_xyz[5] = z; + + // range space vector + size_t m = 1; + vector< AD > a_L(m); + a_L[0] = Lagragian(a_xyz); + + // create K: x -> L and stop tape recording. + // Use default ADFun construction for example purposes. + CppAD::ADFun K; + K.Dependent(a_x, a_L); + + // Operation sequence corresponding to K depends on + // value of y0, y1, and z. Must redo calculations above when + // y0, y1, or z changes. + + // declare independent variable vector and Hessian + vector x(n); + vector H( n * n ); + + // point at which we are computing the Hessian + // (must redo calculations below each time x changes) + x[0] = x0; + x[1] = x1; + x[2] = x2; + H = K.Hessian(x, 0); + + // check this Hessian calculation + return CheckHessian(H, x0, x1, x2, y0, y1, z); + } + bool Usefg() + { using CppAD::AD; + using CppAD::vector; + + // parameters defining problem + double x0(.5), x1(1e3), x2(1), y0(2.), y1(3.), z(4.); + + // domain space vector + size_t n = 3; + vector< AD > a_x(n); + a_x[0] = x0; + a_x[1] = x1; + a_x[2] = x2; + + // declare a_x as independent variable vector and start recording + CppAD::Independent(a_x); + + // range space vector + size_t m = 3; + vector< AD > a_fg(m); + a_fg = fg(a_x); + + // create K: x -> fg and stop tape recording + CppAD::ADFun K; + K.Dependent(a_x, a_fg); + + // 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 + vector x(n); + vector H( n * n ); + vector dx(n); + vector w(m); + vector dw(2*n); + + // compute Hessian at this value of x + // (must redo calculations below each time x changes) + x[0] = x0; + x[1] = x1; + x[2] = x2; + K.Forward(0, x); + + // set weights to Lagrange multiplier values + // (must redo calculations below each time y0, y1, or z changes) + w[0] = z; + w[1] = y0; + w[2] = y1; + + // initialize dx as zero + size_t i, j; + for(i = 0; i < n; i++) + dx[i] = 0.; + // loop over components of x + for(i = 0; i < n; i++) + { dx[i] = 1.; // dx is i-th elementary vector + K.Forward(1, dx); // partial w.r.t dx + dw = K.Reverse(2, w); // deritavtive of partial + for(j = 0; j < n; j++) + H[ i * n + j ] = dw[ j * 2 + 1 ]; + dx[i] = 0.; // dx is zero vector + } + + // check this Hessian calculation + return CheckHessian(H, x0, x1, x2, y0, y1, z); + } } bool HesLagrangian(void) -{ bool ok = true; +{ bool ok = true; - // UseL is simpler, but must retape every time that y of z changes - ok &= UseL(); + // UseL is simpler, but must retape every time that y of z changes + ok &= UseL(); - // Usefg does not need to retape unless operation sequence changes - ok &= Usefg(); - return ok; + // Usefg does not need to retape unless operation sequence changes + ok &= Usefg(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/hes_lu_det.cpp cppad-2019.02.00.0/example/general/hes_lu_det.cpp --- cppad-2018.00.00.0/example/general/hes_lu_det.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/hes_lu_det.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin hes_lu_det.cpp$$ $spell - Lu - Cpp + Lu + Cpp $$ $section Gradient of Determinant Using LU Factorization: Example and Test$$ -$code $srcfile%example/general/hes_lu_det.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -34,65 +33,65 @@ // The AD complex case is used by this example so must // define a specializatgion of LeqZero,AbsGeq for the AD case namespace CppAD { - CPPAD_BOOL_BINARY( std::complex , AbsGeq ) - CPPAD_BOOL_UNARY( std::complex , LeqZero ) + CPPAD_BOOL_BINARY( std::complex , AbsGeq ) + CPPAD_BOOL_UNARY( std::complex , LeqZero ) } bool HesLuDet(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; - typedef std::complex Complex; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - size_t n = 2; - - // object for computing determinants - det_by_lu< AD > Det(n); - - // independent and dependent variable vectors - CPPAD_TESTVECTOR(AD) X(n * n); - CPPAD_TESTVECTOR(AD) D(1); - - // value of the independent variable - size_t i; - for(i = 0; i < n * n; i++) - X[i] = Complex(int(i), -int(i) ); - - // set the independent variables - Independent(X); - - D[0] = Det(X); - - // create the function object - ADFun f(X, D); - - // argument value - CPPAD_TESTVECTOR(Complex) x( n * n ); - for(i = 0; i < n * n; i++) - x[i] = Complex(2 * i, i); - - // first derivative of the determinant - CPPAD_TESTVECTOR(Complex) H( n * n * n * n ); - H = f.Hessian(x, 0); - - /* - f(x) = x[0] * x[3] - x[1] * x[2] - f'(x) = ( x[3], -x[2], -x[1], x[0] ) - */ - Complex zero(0., 0.); - Complex one(1., 0.); - Complex Htrue[] = { - zero, zero, zero, one, - zero, zero, -one, zero, - zero, -one, zero, zero, - one, zero, zero, zero - }; - for( i = 0; i < n*n*n*n; i++) - ok &= NearEqual( Htrue[i], H[i], eps99 , eps99 ); + using namespace CppAD; + typedef std::complex Complex; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + size_t n = 2; + + // object for computing determinants + det_by_lu< AD > Det(n); + + // independent and dependent variable vectors + CPPAD_TESTVECTOR(AD) X(n * n); + CPPAD_TESTVECTOR(AD) D(1); + + // value of the independent variable + size_t i; + for(i = 0; i < n * n; i++) + X[i] = Complex(int(i), -int(i) ); + + // set the independent variables + Independent(X); + + D[0] = Det(X); + + // create the function object + ADFun f(X, D); + + // argument value + CPPAD_TESTVECTOR(Complex) x( n * n ); + for(i = 0; i < n * n; i++) + x[i] = Complex(2 * i, i); + + // first derivative of the determinant + CPPAD_TESTVECTOR(Complex) H( n * n * n * n ); + H = f.Hessian(x, 0); + + /* + f(x) = x[0] * x[3] - x[1] * x[2] + f'(x) = ( x[3], -x[2], -x[1], x[0] ) + */ + Complex zero(0., 0.); + Complex one(1., 0.); + Complex Htrue[] = { + zero, zero, zero, one, + zero, zero, -one, zero, + zero, -one, zero, zero, + one, zero, zero, zero + }; + for( i = 0; i < n*n*n*n; i++) + ok &= NearEqual( Htrue[i], H[i], eps99 , eps99 ); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/hes_minor_det.cpp cppad-2019.02.00.0/example/general/hes_minor_det.cpp --- cppad-2018.00.00.0/example/general/hes_minor_det.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/hes_minor_det.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin hes_minor_det.cpp$$ $spell - Cpp + Cpp $$ $section Gradient of Determinant Using Expansion by Minors: Example and Test$$ -$mindex minors$$ -$code $srcfile%example/general/hes_minor_det.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -39,58 +37,58 @@ // ---------------------------------------------------------------------------- bool HesMinorDet(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - size_t n = 2; + size_t n = 2; - // object for computing determinants - det_by_minor Det(n); + // object for computing determinants + det_by_minor Det(n); - // independent and dependent variable vectors - CPPAD_TESTVECTOR(ADComplex) X(n * n); - CPPAD_TESTVECTOR(ADComplex) D(1); - - // value of the independent variable - size_t i; - for(i = 0; i < n * n; i++) - X[i] = Complex(int(i), -int(i)); - - // set the independent variables - Independent(X); - - // comupute the determinant - D[0] = Det(X); - - // create the function object - ADFun f(X, D); - - // argument value - CPPAD_TESTVECTOR(Complex) x( n * n ); - for(i = 0; i < n * n; i++) - x[i] = Complex(2 * i, i); - - // first derivative of the determinant - CPPAD_TESTVECTOR(Complex) H( n * n * n * n); - H = f.Hessian(x, 0); - - /* - f(x) = x[0] * x[3] - x[1] * x[2] - f'(x) = ( x[3], -x[2], -x[1], x[0] ) - */ - Complex zero(0., 0.); - Complex one(1., 0.); - Complex Htrue[] = { - zero, zero, zero, one, - zero, zero, -one, zero, - zero, -one, zero, zero, - one, zero, zero, zero - }; - for( i = 0; i < n*n*n*n; i++) - ok &= Htrue[i] == H[i]; + // independent and dependent variable vectors + CPPAD_TESTVECTOR(ADComplex) X(n * n); + CPPAD_TESTVECTOR(ADComplex) D(1); + + // value of the independent variable + size_t i; + for(i = 0; i < n * n; i++) + X[i] = Complex(int(i), -int(i)); + + // set the independent variables + Independent(X); + + // comupute the determinant + D[0] = Det(X); + + // create the function object + ADFun f(X, D); + + // argument value + CPPAD_TESTVECTOR(Complex) x( n * n ); + for(i = 0; i < n * n; i++) + x[i] = Complex(2 * i, i); + + // first derivative of the determinant + CPPAD_TESTVECTOR(Complex) H( n * n * n * n); + H = f.Hessian(x, 0); + + /* + f(x) = x[0] * x[3] - x[1] * x[2] + f'(x) = ( x[3], -x[2], -x[1], x[0] ) + */ + Complex zero(0., 0.); + Complex one(1., 0.); + Complex Htrue[] = { + zero, zero, zero, one, + zero, zero, -one, zero, + zero, -one, zero, zero, + one, zero, zero, zero + }; + for( i = 0; i < n*n*n*n; i++) + ok &= Htrue[i] == H[i]; - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/example/general/hessian.cpp cppad-2019.02.00.0/example/general/hessian.cpp --- cppad-2018.00.00.0/example/general/hessian.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/hessian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin hessian.cpp$$ $spell - Cpp - Hessian + Cpp + Hessian $$ $section Hessian: Example and Test$$ -$mindex Hessian$$ -$code $srcfile%example/general/hessian.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,71 +29,71 @@ # include namespace { // --------------------------------------------------------- // define the template function HessianCases in empty namespace -template +template bool HessianCases() -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - using CppAD::exp; - using CppAD::sin; - using CppAD::cos; - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 1.; - X[1] = 2.; - - // declare independent variables and starting recording - CppAD::Independent(X); - - // a calculation between the domain and range values - AD Square = X[0] * X[0]; - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = Square * exp( X[1] ); - Y[1] = Square * sin( X[1] ); - Y[2] = Square * cos( X[1] ); - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - Vector x(n); - x[0] = 2.; - x[1] = 1.; - - // second derivative of y[1] - Vector hes( n * n ); - hes = f.Hessian(x, 1); - /* - F_1 = x[0] * x[0] * sin(x[1]) - - F_1^{(1)} = [ 2 * x[0] * sin(x[1]) , x[0] * x[0] * cos(x[1]) ] - - F_1^{(2)} = [ 2 * sin(x[1]) , 2 * x[0] * cos(x[1]) ] - [ 2 * x[0] * cos(x[1]) , - x[0] * x[0] * sin(x[1]) ] - */ - ok &= NearEqual( 2.*sin(x[1]), hes[0*n+0], eps99, eps99); - ok &= NearEqual( 2.*x[0]*cos(x[1]), hes[0*n+1], eps99, eps99); - ok &= NearEqual( 2.*x[0]*cos(x[1]), hes[1*n+0], eps99, eps99); - ok &= NearEqual( - x[0]*x[0]*sin(x[1]), hes[1*n+1], eps99, eps99); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + using CppAD::exp; + using CppAD::sin; + using CppAD::cos; + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 1.; + X[1] = 2.; + + // declare independent variables and starting recording + CppAD::Independent(X); + + // a calculation between the domain and range values + AD Square = X[0] * X[0]; + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = Square * exp( X[1] ); + Y[1] = Square * sin( X[1] ); + Y[2] = Square * cos( X[1] ); + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + Vector x(n); + x[0] = 2.; + x[1] = 1.; + + // second derivative of y[1] + Vector hes( n * n ); + hes = f.Hessian(x, 1); + /* + F_1 = x[0] * x[0] * sin(x[1]) + + F_1^{(1)} = [ 2 * x[0] * sin(x[1]) , x[0] * x[0] * cos(x[1]) ] + + F_1^{(2)} = [ 2 * sin(x[1]) , 2 * x[0] * cos(x[1]) ] + [ 2 * x[0] * cos(x[1]) , - x[0] * x[0] * sin(x[1]) ] + */ + ok &= NearEqual( 2.*sin(x[1]), hes[0*n+0], eps99, eps99); + ok &= NearEqual( 2.*x[0]*cos(x[1]), hes[0*n+1], eps99, eps99); + ok &= NearEqual( 2.*x[0]*cos(x[1]), hes[1*n+0], eps99, eps99); + ok &= NearEqual( - x[0]*x[0]*sin(x[1]), hes[1*n+1], eps99, eps99); - return ok; + return ok; } } // End empty namespace # include # include bool Hessian(void) -{ bool ok = true; - // Run with Vector equal to three different cases - // all of which are Simple Vectors with elements of type double. - ok &= HessianCases< CppAD::vector >(); - ok &= HessianCases< std::vector >(); - ok &= HessianCases< std::valarray >(); - return ok; +{ bool ok = true; + // Run with Vector equal to three different cases + // all of which are Simple Vectors with elements of type double. + ok &= HessianCases< CppAD::vector >(); + ok &= HessianCases< std::vector >(); + ok &= HessianCases< std::valarray >(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/hes_times_dir.cpp cppad-2019.02.00.0/example/general/hes_times_dir.cpp --- cppad-2018.00.00.0/example/general/hes_times_dir.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/hes_times_dir.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin hes_times_dir.cpp$$ @@ -15,11 +16,8 @@ $$ $section Hessian Times Direction: Example and Test$$ -$mindex direction$$ -$code $srcfile%example/general/hes_times_dir.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,61 +28,61 @@ # include namespace { // put this function in the empty namespace - // F(x) = |x|^2 = x[0]^2 + ... + x[n-1]^2 - template - Type F(CPPAD_TESTVECTOR(Type) &x) - { Type sum = 0; - size_t i = x.size(); - while(i--) - sum += x[i] * x[i]; - return sum; - } + // F(x) = |x|^2 = x[0]^2 + ... + x[n-1]^2 + template + Type F(CPPAD_TESTVECTOR(Type) &x) + { Type sum = 0; + size_t i = x.size(); + while(i--) + sum += x[i] * x[i]; + return sum; + } } bool HesTimesDir(void) -{ bool ok = true; // initialize test result - size_t j; // a domain variable variable +{ bool ok = true; // initialize test result + size_t j; // a domain variable variable - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 5; - CPPAD_TESTVECTOR(AD) X(n); - for(j = 0; j < n; j++) - X[j] = AD(j); - - // declare independent variables and start recording - CppAD::Independent(X); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = F(X); - - // create f : X -> Y and stop recording - CppAD::ADFun f(X, Y); - - // choose a direction dx and compute dy(x) = F'(x) * dx - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - for(j = 0; j < n; j++) - dx[j] = double(n - j); - dy = f.Forward(1, dx); - - // compute ddw = F''(x) * dx - CPPAD_TESTVECTOR(double) w(m); - 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 - for(j = 0; j < n; j++) - ok &= NearEqual(ddw[j * 2 + 1], 2.*dx[j], eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 5; + CPPAD_TESTVECTOR(AD) X(n); + for(j = 0; j < n; j++) + X[j] = AD(j); + + // declare independent variables and start recording + CppAD::Independent(X); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = F(X); + + // create f : X -> Y and stop recording + CppAD::ADFun f(X, Y); + + // choose a direction dx and compute dy(x) = F'(x) * dx + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + for(j = 0; j < n; j++) + dx[j] = double(n - j); + dy = f.Forward(1, dx); + + // compute ddw = F''(x) * dx + CPPAD_TESTVECTOR(double) w(m); + 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 + for(j = 0; j < n; j++) + ok &= NearEqual(ddw[j * 2 + 1], 2.*dx[j], eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/independent.cpp cppad-2019.02.00.0/example/general/independent.cpp --- cppad-2018.00.00.0/example/general/independent.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/independent.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* WARNING: This file is used an an example by omh/FunConstruct.omh. @@ -17,9 +18,7 @@ $section Independent and ADFun Constructor: Example and Test$$ -$code $srcfile%example/general/independent.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -27,81 +26,81 @@ # include namespace { // -------------------------------------------------------- -// define the template function Test(void) in empty namespace -template +// define the template function Test(void) in empty namespace +template bool Test(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 2; - VectorAD X(n); // VectorAD is the template parameter in call to Test - X[0] = 0.; - X[1] = 1.; - - // declare independent variables and start recording - // use the template parameter VectorAD for the vector type - CppAD::Independent(X); - - AD a = X[0] + X[1]; // first AD operation - AD b = X[0] * X[1]; // second AD operation - - // range space vector - size_t m = 2; - VectorAD Y(m); // VectorAD is the template paraemter in call to Test - Y[0] = a; - Y[1] = b; - - // create f: X -> Y and stop tape recording - // use the template parameter VectorAD for the vector type - CppAD::ADFun f(X, Y); - - // check value - ok &= NearEqual(Y[0] , 1., eps99 , eps99); - ok &= NearEqual(Y[1] , 0., eps99 , eps99); - - // compute f(1, 2) - CPPAD_TESTVECTOR(double) x(n); - CPPAD_TESTVECTOR(double) y(m); - x[0] = 1.; - x[1] = 2.; - y = f.Forward(0, x); - ok &= NearEqual(y[0] , 3., eps99 , eps99); - ok &= NearEqual(y[1] , 2., eps99 , eps99); - - // compute partial of f w.r.t x[0] at (1, 2) - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - dx[0] = 1.; - dx[1] = 0.; - dy = f.Forward(1, dx); - ok &= NearEqual(dy[0] , 1., eps99 , eps99); - ok &= NearEqual(dy[1] , x[1], eps99 , eps99); - - // compute partial of f w.r.t x[1] at (1, 2) - dx[0] = 0.; - dx[1] = 1.; - dy = f.Forward(1, dx); - ok &= NearEqual(dy[0] , 1., eps99 , eps99); - ok &= NearEqual(dy[1] , x[0], eps99 , eps99); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 2; + ADVector X(n); // ADVector is the template parameter in call to Test + X[0] = 0.; + X[1] = 1.; + + // declare independent variables and start recording + // use the template parameter ADVector for the vector type + CppAD::Independent(X); + + AD a = X[0] + X[1]; // first AD operation + AD b = X[0] * X[1]; // second AD operation + + // range space vector + size_t m = 2; + ADVector Y(m); // ADVector is the template paraemter in call to Test + Y[0] = a; + Y[1] = b; + + // create f: X -> Y and stop tape recording + // use the template parameter ADVector for the vector type + CppAD::ADFun f(X, Y); + + // check value + ok &= NearEqual(Y[0] , 1., eps99 , eps99); + ok &= NearEqual(Y[1] , 0., eps99 , eps99); + + // compute f(1, 2) + CPPAD_TESTVECTOR(double) x(n); + CPPAD_TESTVECTOR(double) y(m); + x[0] = 1.; + x[1] = 2.; + y = f.Forward(0, x); + ok &= NearEqual(y[0] , 3., eps99 , eps99); + ok &= NearEqual(y[1] , 2., eps99 , eps99); + + // compute partial of f w.r.t x[0] at (1, 2) + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dx[1] = 0.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0] , 1., eps99 , eps99); + ok &= NearEqual(dy[1] , x[1], eps99 , eps99); + + // compute partial of f w.r.t x[1] at (1, 2) + dx[0] = 0.; + dx[1] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0] , 1., eps99 , eps99); + ok &= NearEqual(dy[1] , x[0], eps99 , eps99); - return ok; + return ok; } } // End of empty namespace ------------------------------------------- # include # include bool Independent(void) -{ bool ok = true; - typedef CppAD::AD ADdouble; - // Run with VectorAD equal to three different cases - // all of which are Simple Vectors with elements of type AD. - ok &= Test< CppAD::vector >(); - ok &= Test< std::vector >(); - ok &= Test< std::valarray >(); - return ok; +{ bool ok = true; + typedef CppAD::AD ADdouble; + // Run with ADVector equal to three different cases + // all of which are Simple Vectors with elements of type AD. + ok &= Test< CppAD::vector >(); + ok &= Test< std::vector >(); + ok &= Test< std::valarray >(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/integer.cpp cppad-2019.02.00.0/example/general/integer.cpp --- cppad-2018.00.00.0/example/general/integer.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/integer.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin integer.cpp$$ $spell - Cpp - cstddef + Cpp + cstddef $$ $section Convert From AD to Integer: Example and Test$$ -$mindex Integer$$ -$code $srcfile%example/general/integer.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,48 +29,48 @@ # include bool Integer(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::Integer; - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = 3.5; - x[1] = 4.5; - - // check integer before recording - ok &= (Integer(x[0]) == 3); - ok &= (Integer(x[1]) == 4); - - // start recording - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // check integer during recording - ok &= (Integer(x[0]) == 3); - ok &= (Integer(x[1]) == 4); - - // check integer for VecAD element - CppAD::VecAD v(1); - AD zero(0); - v[zero] = 2; - ok &= (Integer(v[zero]) == 2); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = - x[1]; - - // create f: x -> y and stop recording - CppAD::ADFun f(x, y); - - // check integer after recording - ok &= (Integer(x[0]) == 3.); - ok &= (Integer(x[1]) == 4.); - ok &= (Integer(y[0]) == -4.); +{ bool ok = true; + using CppAD::AD; + using CppAD::Integer; + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = 3.5; + x[1] = 4.5; + + // check integer before recording + ok &= (Integer(x[0]) == 3); + ok &= (Integer(x[1]) == 4); + + // start recording + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // check integer during recording + ok &= (Integer(x[0]) == 3); + ok &= (Integer(x[1]) == 4); + + // check integer for VecAD element + CppAD::VecAD v(1); + AD zero(0); + v[zero] = 2; + ok &= (Integer(v[zero]) == 2); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = - x[1]; + + // create f: x -> y and stop recording + CppAD::ADFun f(x, y); + + // check integer after recording + ok &= (Integer(x[0]) == 3.); + ok &= (Integer(x[1]) == 4.); + ok &= (Integer(y[0]) == -4.); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/interface2c.cpp cppad-2019.02.00.0/example/general/interface2c.cpp --- cppad-2018.00.00.0/example/general/interface2c.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/interface2c.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin interface2c.cpp$$ $spell @@ -15,11 +16,8 @@ $$ $section Interfacing to C: Example and Test$$ -$mindex C interface difference central$$ -$code $srcfile%example/general/interface2c.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,152 +28,152 @@ namespace { // Begin empty namespace /* Compute the value of a sum of Gaussians defined by a and evaluated at x - y = sum_{i=1}^n a[3*i] exp( (x - a[3*i+1])^2 / a[3*i+2])^2 ) + y = sum_{i=1}^n a[3*i] exp( (x - a[3*i+1])^2 / a[3*i+2])^2 ) where the floating point type is a template parameter */ template Float sumGauss(const Float &x, const CppAD::vector &a) { - // number of components in a - size_t na = a.size(); + // number of components in a + size_t na = a.size(); - // number of Gaussians - size_t n = na / 3; + // number of Gaussians + size_t n = na / 3; - // check the restricitons on na - assert( na == n * 3 ); + // check the restricitons on na + assert( na == n * 3 ); - // declare temporaries used inside of loop - Float ex, arg; - - // initialize sum - 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; - } - return y; + // declare temporaries used inside of loop + Float ex, arg; + + // initialize sum + 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; + } + return y; } /* Create a C function interface that computes both - y = sum_{i=1}^n a[3*i] exp( (x - a[3*i+1])^2 / a[3*i+2])^2 ) + y = sum_{i=1}^n a[3*i] exp( (x - a[3*i+1])^2 / a[3*i+2])^2 ) 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; - // for example, std::vector, std::valarray +{ // Note that any simple vector could replace CppAD::vector; + // for example, std::vector, std::valarray - // check the restrictions on na - assert( na % 3 == 0 ); // mod(na, 3) = 0 + // check the restrictions on na + assert( na % 3 == 0 ); // mod(na, 3) = 0 - // use the shorthand ADfloat for the type CppAD::AD - typedef CppAD::AD ADfloat; + // use the shorthand ADfloat for the type CppAD::AD + typedef CppAD::AD ADfloat; - // vector for indpendent variables - CppAD::vector A(na); // used with template function above - CppAD::vector acopy(na); // used for derivative calculations + // vector for indpendent variables + CppAD::vector A(na); // used with template function above + CppAD::vector acopy(na); // used for derivative calculations - // vector for the dependent variables (there is only one) - CppAD::vector Y(1); + // vector for the dependent variables (there is only one) + 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]; + // 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]; - // declare that A is the independent variable vector - CppAD::Independent(A); + // declare that A is the independent variable vector + CppAD::Independent(A); - // value of x as an ADfloat object - ADfloat X = x; + // value of x as an ADfloat object + ADfloat X = x; - // Evaluate template version of sumGauss with ADfloat as the template - // parameter. Set the independent variable to the resulting value - Y[0] = sumGauss(X, A); + // Evaluate template version of sumGauss with ADfloat as the template + // parameter. Set the independent variable to the resulting value + Y[0] = sumGauss(X, A); - // create the AD function object F : A -> Y - CppAD::ADFun F(A, Y); + // 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) - *y = CppAD::Value(Y[0]); + // use Value to convert Y[0] to float and return y = F(a) + *y = CppAD::Value(Y[0]); - // evaluate the derivative F'(a) - CppAD::vector J(na); - J = F.Jacobian(acopy); + // evaluate the derivative F'(a) + CppAD::vector J(na); + J = F.Jacobian(acopy); - // return the value of dyda = F'(a) as a C vector - for(i = 0; i < na; i++) - dyda[i] = J[i]; + // return the value of dyda = F'(a) as a C vector + for(i = 0; i < na; i++) + dyda[i] = J[i]; - return; + return; } /* Link CppAD::NearEqual so do not have to use namespace notation in Interface2C */ bool NearEqual(float x, float y, float r, float a) -{ return CppAD::NearEqual(x, y, r, a); +{ return CppAD::NearEqual(x, y, r, a); } } // End empty namespace 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; +{ // 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; - // declare variables - float x, a[6], y, dyda[6], tmp[6]; - size_t na, i; + // declare variables + float x, a[6], y, dyda[6], tmp[6]; + size_t na, i; - // number of parameters (3 for each Gaussian) - na = 6; + // number of parameters (3 for each Gaussian) + na = 6; - // number of Gaussians: n = na / 3; + // number of Gaussians: n = na / 3; - // value of x - x = 1.; + // value of x + x = 1.; - // value of the parameter vector a - for(i = 0; i < na; i++) - a[i] = (float) (i+1); + // value of the parameter vector a + for(i = 0; i < na; i++) + a[i] = (float) (i+1); - // evaulate function and derivative - sumGauss(x, a, &y, dyda, na); + // evaulate function and derivative + sumGauss(x, a, &y, dyda, na); - // compare dyda to central difference approximation for deriative - for(i = 0; i < na; i++) - { // local variables - float small, ai, yp, ym, dy_da; + // compare dyda to central difference approximation for deriative + for(i = 0; i < na; i++) + { // local variables + float eps, ai, yp, ym, dy_da; - // 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; + // We assume that the type float has at least 7 digits of + // precision, so we choose eps to be about pow(10., -7./2.). + eps = (float) 3e-4; - // value of this component of a - ai = a[i]; + // value of this component of a + ai = a[i]; - // evaluate F( a + small * ei ) - a[i] = ai + small; - sumGauss(x, a, &yp, tmp, na); + // evaluate F( a + eps * ei ) + a[i] = ai + eps; + sumGauss(x, a, &yp, tmp, na); - // evaluate F( a - small * ei ) - a[i] = ai - small; - sumGauss(x, a, &ym, tmp, na); + // evaluate F( a - eps * ei ) + a[i] = ai - eps; + sumGauss(x, a, &ym, tmp, na); - // evaluate central difference approximates for partial - dy_da = (yp - ym) / (2 * small); + // evaluate central difference approximates for partial + dy_da = (yp - ym) / (2 * eps); - // restore this component of a - a[i] = ai; + // restore this component of a + a[i] = ai; - ok &= NearEqual(dyda[i], dy_da, small, small); - } - return ok; + ok &= NearEqual(dyda[i], dy_da, eps, eps); + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/interp_onetape.cpp cppad-2019.02.00.0/example/general/interp_onetape.cpp --- cppad-2018.00.00.0/example/general/interp_onetape.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/interp_onetape.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin interp_onetape.cpp$$ $spell - retaping - retape + retaping + retape $$ $section Interpolation With Out Retaping: Example and Test$$ -$mindex interpolate tape retape$$ $head See Also$$ @@ -25,9 +25,7 @@ $pre $$ -$code $srcfile%example/general/interp_onetape.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -37,119 +35,119 @@ # include namespace { - double ArgumentValue[] = { - .0 , - .2 , - .4 , - .8 , - 1. - }; - double FunctionValue[] = { - std::sin( ArgumentValue[0] ) , - std::sin( ArgumentValue[1] ) , - std::sin( ArgumentValue[2] ) , - std::sin( ArgumentValue[3] ) , - std::sin( ArgumentValue[4] ) - }; - size_t TableLength = 5; - - size_t Index(const double &x) - { // determine the index j such that x is between - // ArgumentValue[j] and ArgumentValue[j+1] - static size_t j = 0; - while ( x < ArgumentValue[j] && j > 0 ) - j--; - while ( x > ArgumentValue[j+1] && j < TableLength - 2) - j++; - // assert conditions that must be true given logic above - assert( j >= 0 && j < TableLength - 1 ); - return j; - } - - double Argument(const double &x) - { size_t j = Index(x); - return ArgumentValue[j]; - } - double Function(const double &x) - { size_t j = Index(x); - return FunctionValue[j]; - } - - double Slope(const double &x) - { size_t j = Index(x); - double dx = ArgumentValue[j+1] - ArgumentValue[j]; - double dy = FunctionValue[j+1] - FunctionValue[j]; - return dy / dx; - } - CPPAD_DISCRETE_FUNCTION(double, Argument) - CPPAD_DISCRETE_FUNCTION(double, Function) - CPPAD_DISCRETE_FUNCTION(double, Slope) + double ArgumentValue[] = { + .0 , + .2 , + .4 , + .8 , + 1. + }; + double FunctionValue[] = { + std::sin( ArgumentValue[0] ) , + std::sin( ArgumentValue[1] ) , + std::sin( ArgumentValue[2] ) , + std::sin( ArgumentValue[3] ) , + std::sin( ArgumentValue[4] ) + }; + size_t TableLength = 5; + + size_t Index(const double &x) + { // determine the index j such that x is between + // ArgumentValue[j] and ArgumentValue[j+1] + static size_t j = 0; + while ( x < ArgumentValue[j] && j > 0 ) + j--; + while ( x > ArgumentValue[j+1] && j < TableLength - 2) + j++; + // assert conditions that must be true given logic above + assert( j >= 0 && j < TableLength - 1 ); + return j; + } + + double Argument(const double &x) + { size_t j = Index(x); + return ArgumentValue[j]; + } + double Function(const double &x) + { size_t j = Index(x); + return FunctionValue[j]; + } + + double Slope(const double &x) + { size_t j = Index(x); + double dx = ArgumentValue[j+1] - ArgumentValue[j]; + double dy = FunctionValue[j+1] - FunctionValue[j]; + return dy / dx; + } + CPPAD_DISCRETE_FUNCTION(double, Argument) + CPPAD_DISCRETE_FUNCTION(double, Function) + CPPAD_DISCRETE_FUNCTION(double, Slope) } bool interp_onetape(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = .4 * ArgumentValue[1] + .6 * ArgumentValue[2]; - - // declare independent variables and start tape recording - CppAD::Independent(X); - - // evaluate piecewise linear interpolant at X[0] - AD A = Argument(X[0]); - AD F = Function(X[0]); - AD S = Slope(X[0]); - AD I = F + (X[0] - A) * S; - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = I; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // 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) 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 - // 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; - ok &= NearEqual(Y[0], check, eps99, eps99); - - // evaluate f where x has different value - x[0] = .7 * ArgumentValue[2] + .3 * ArgumentValue[3]; - y = f.Forward(0, x); - - // check function value - delta = ArgumentValue[3] - ArgumentValue[2]; - check = FunctionValue[3] * (x[0] - ArgumentValue[2]) / delta - + FunctionValue[2] * (ArgumentValue[3] - x[0]) / delta; - ok &= NearEqual(y[0], check, eps99, eps99); - - // evaluate partials w.r.t. x[0] - dx[0] = 1.; - dy = f.Forward(1, dx); - - // check that the derivative is the slope - check = (FunctionValue[3] - FunctionValue[2]) - / (ArgumentValue[3] - ArgumentValue[2]); - ok &= NearEqual(dy[0], check, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = .4 * ArgumentValue[1] + .6 * ArgumentValue[2]; + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // evaluate piecewise linear interpolant at X[0] + AD A = Argument(X[0]); + AD F = Function(X[0]); + AD S = Slope(X[0]); + AD I = F + (X[0] - A) * S; + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = I; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // 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) 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 + // 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; + ok &= NearEqual(Y[0], check, eps99, eps99); + + // evaluate f where x has different value + x[0] = .7 * ArgumentValue[2] + .3 * ArgumentValue[3]; + y = f.Forward(0, x); + + // check function value + delta = ArgumentValue[3] - ArgumentValue[2]; + check = FunctionValue[3] * (x[0] - ArgumentValue[2]) / delta + + FunctionValue[2] * (ArgumentValue[3] - x[0]) / delta; + ok &= NearEqual(y[0], check, eps99, eps99); + + // evaluate partials w.r.t. x[0] + dx[0] = 1.; + dy = f.Forward(1, dx); + + // check that the derivative is the slope + check = (FunctionValue[3] - FunctionValue[2]) + / (ArgumentValue[3] - ArgumentValue[2]); + ok &= NearEqual(dy[0], check, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/interp_retape.cpp cppad-2019.02.00.0/example/general/interp_retape.cpp --- cppad-2018.00.00.0/example/general/interp_retape.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/interp_retape.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin interp_retape.cpp$$ $spell - Retaping - retape + Retaping + retape $$ $section Interpolation With Retaping: Example and Test$$ -$mindex interpolate tape retape$$ $head See Also$$ @@ -26,9 +26,7 @@ $pre $$ -$code $srcfile%example/general/interp_retape.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -38,110 +36,110 @@ # include namespace { - double ArgumentValue[] = { - .0 , - .2 , - .4 , - .8 , - 1. - }; - double FunctionValue[] = { - std::sin( ArgumentValue[0] ) , - std::sin( ArgumentValue[1] ) , - std::sin( ArgumentValue[2] ) , - std::sin( ArgumentValue[3] ) , - std::sin( ArgumentValue[4] ) - }; - size_t TableLength = 5; - - size_t Index(const CppAD::AD &x) - { // determine the index j such that x is between - // ArgumentValue[j] and ArgumentValue[j+1] - static size_t j = 0; - while ( x < ArgumentValue[j] && j > 0 ) - j--; - while ( x > ArgumentValue[j+1] && j < TableLength - 2) - j++; - // assert conditions that must be true given logic above - assert( j >= 0 && j < TableLength - 1 ); - return j; - } - double Argument(const CppAD::AD &x) - { size_t j = Index(x); - return ArgumentValue[j]; - } - double Function(const CppAD::AD &x) - { size_t j = Index(x); - return FunctionValue[j]; - } - double Slope(const CppAD::AD &x) - { size_t j = Index(x); - double dx = ArgumentValue[j+1] - ArgumentValue[j]; - double dy = FunctionValue[j+1] - FunctionValue[j]; - return dy / dx; - } + double ArgumentValue[] = { + .0 , + .2 , + .4 , + .8 , + 1. + }; + double FunctionValue[] = { + std::sin( ArgumentValue[0] ) , + std::sin( ArgumentValue[1] ) , + std::sin( ArgumentValue[2] ) , + std::sin( ArgumentValue[3] ) , + std::sin( ArgumentValue[4] ) + }; + size_t TableLength = 5; + + size_t Index(const CppAD::AD &x) + { // determine the index j such that x is between + // ArgumentValue[j] and ArgumentValue[j+1] + static size_t j = 0; + while ( x < ArgumentValue[j] && j > 0 ) + j--; + while ( x > ArgumentValue[j+1] && j < TableLength - 2) + j++; + // assert conditions that must be true given logic above + assert( j >= 0 && j < TableLength - 1 ); + return j; + } + double Argument(const CppAD::AD &x) + { size_t j = Index(x); + return ArgumentValue[j]; + } + double Function(const CppAD::AD &x) + { size_t j = Index(x); + return FunctionValue[j]; + } + double Slope(const CppAD::AD &x) + { size_t j = Index(x); + double dx = ArgumentValue[j+1] - ArgumentValue[j]; + double dy = FunctionValue[j+1] - FunctionValue[j]; + return dy / dx; + } } bool interp_retape(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) X(n); - - // loop over argument values - size_t k; - for(k = 0; k < TableLength - 1; k++) - { - X[0] = .4 * ArgumentValue[k] + .6 * ArgumentValue[k+1]; - - // declare independent variables and start tape recording - // (use a different tape for each argument value) - CppAD::Independent(X); - - // evaluate piecewise linear interpolant at X[0] - AD A = Argument(X[0]); - AD F = Function(X[0]); - AD S = Slope(X[0]); - AD I = F + (X[0] - A) * S; - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = I; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // 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) 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 - // ArgumentValue[k] and ArgumentValue[k+1] - double delta, check; - 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; - ok &= NearEqual(Y[0], check, eps99, eps99); - - // evaluate partials w.r.t. x[0] - dx[0] = 1.; - dy = f.Forward(1, dx); - - // check that the derivative is the slope - check = (FunctionValue[k+1] - FunctionValue[k]) - / (ArgumentValue[k+1] - ArgumentValue[k]); - ok &= NearEqual(dy[0], check, eps99, eps99); - } - return ok; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) X(n); + + // loop over argument values + size_t k; + for(k = 0; k < TableLength - 1; k++) + { + X[0] = .4 * ArgumentValue[k] + .6 * ArgumentValue[k+1]; + + // declare independent variables and start tape recording + // (use a different tape for each argument value) + CppAD::Independent(X); + + // evaluate piecewise linear interpolant at X[0] + AD A = Argument(X[0]); + AD F = Function(X[0]); + AD S = Slope(X[0]); + AD I = F + (X[0] - A) * S; + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = I; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // 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) 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 + // ArgumentValue[k] and ArgumentValue[k+1] + double delta, check; + 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; + ok &= NearEqual(Y[0], check, eps99, eps99); + + // evaluate partials w.r.t. x[0] + dx[0] = 1.; + dy = f.Forward(1, dx); + + // check that the derivative is the slope + check = (FunctionValue[k+1] - FunctionValue[k]) + / (ArgumentValue[k+1] - ArgumentValue[k]); + ok &= NearEqual(dy[0], check, eps99, eps99); + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/jac_lu_det.cpp cppad-2019.02.00.0/example/general/jac_lu_det.cpp --- cppad-2018.00.00.0/example/general/jac_lu_det.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/jac_lu_det.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin jac_lu_det.cpp$$ $spell - Lu - Cpp + Lu + Cpp $$ $section Gradient of Determinant Using Lu Factorization: Example and Test$$ -$code $srcfile%example/general/jac_lu_det.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -34,58 +33,58 @@ // The AD complex case is used by this example so must // define a specializatgion of LeqZero,AbsGeq for the AD case namespace CppAD { - CPPAD_BOOL_BINARY( std::complex , AbsGeq ) - CPPAD_BOOL_UNARY( std::complex , LeqZero ) + CPPAD_BOOL_BINARY( std::complex , AbsGeq ) + CPPAD_BOOL_UNARY( std::complex , LeqZero ) } bool JacLuDet(void) -{ bool ok = true; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); +{ bool ok = true; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); - typedef std::complex Complex; - typedef AD ADComplex; + typedef std::complex Complex; + typedef AD ADComplex; - size_t n = 2; + size_t n = 2; - // object for computing determinants - det_by_lu Det(n); + // object for computing determinants + det_by_lu Det(n); - // independent and dependent variable vectors - CPPAD_TESTVECTOR(ADComplex) X(n * n); - CPPAD_TESTVECTOR(ADComplex) D(1); + // independent and dependent variable vectors + CPPAD_TESTVECTOR(ADComplex) X(n * n); + CPPAD_TESTVECTOR(ADComplex) D(1); - // value of the independent variable - size_t i; - for(i = 0; i < n * n; i++) - X[i] = Complex(int(i), -int(i)); + // value of the independent variable + size_t i; + for(i = 0; i < n * n; i++) + X[i] = Complex(int(i), -int(i)); - // set the independent variables - Independent(X); + // set the independent variables + Independent(X); - // compute the determinant - D[0] = Det(X); + // compute the determinant + D[0] = Det(X); - // create the function object - ADFun f(X, D); + // create the function object + ADFun f(X, D); - // argument value - CPPAD_TESTVECTOR(Complex) x( n * n ); - for(i = 0; i < n * n; i++) - x[i] = Complex(2 * i, i); + // argument value + CPPAD_TESTVECTOR(Complex) x( n * n ); + for(i = 0; i < n * n; i++) + x[i] = Complex(2 * i, i); - // first derivative of the determinant - CPPAD_TESTVECTOR(Complex) J( n * n ); - J = f.Jacobian(x); + // first derivative of the determinant + CPPAD_TESTVECTOR(Complex) J( n * n ); + J = f.Jacobian(x); - /* - f(x) = x[0] * x[3] - x[1] * x[2] - */ - Complex Jtrue[] = { x[3], -x[2], -x[1], x[0] }; - for( i = 0; i < n*n; i++) - ok &= NearEqual( Jtrue[i], J[i], eps99 , eps99 ); + /* + f(x) = x[0] * x[3] - x[1] * x[2] + */ + Complex Jtrue[] = { x[3], -x[2], -x[1], x[0] }; + for( i = 0; i < n*n; i++) + ok &= NearEqual( Jtrue[i], J[i], eps99 , eps99 ); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/jac_minor_det.cpp cppad-2019.02.00.0/example/general/jac_minor_det.cpp --- cppad-2018.00.00.0/example/general/jac_minor_det.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/jac_minor_det.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin jac_minor_det.cpp$$ $spell - Cpp + Cpp $$ $section Gradient of Determinant Using Expansion by Minors: Example and Test$$ -$mindex minors$$ -$code $srcfile%example/general/jac_minor_det.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -40,51 +38,51 @@ // ---------------------------------------------------------------------------- bool JacMinorDet(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - size_t n = 2; + size_t n = 2; - // object for computing determinant - det_by_minor Det(n); + // object for computing determinant + det_by_minor Det(n); - // independent and dependent variable vectors - CPPAD_TESTVECTOR(ADComplex) X(n * n); - CPPAD_TESTVECTOR(ADComplex) D(1); + // independent and dependent variable vectors + CPPAD_TESTVECTOR(ADComplex) X(n * n); + CPPAD_TESTVECTOR(ADComplex) D(1); - // value of the independent variable - size_t i; - for(i = 0; i < n * n; i++) - X[i] = Complex(int(i), -int(i)); + // value of the independent variable + size_t i; + for(i = 0; i < n * n; i++) + X[i] = Complex(int(i), -int(i)); - // set the independent variables - Independent(X); + // set the independent variables + Independent(X); - // comupute the determinant - D[0] = Det(X); + // comupute the determinant + D[0] = Det(X); - // create the function object - ADFun f(X, D); + // create the function object + ADFun f(X, D); - // argument value - CPPAD_TESTVECTOR(Complex) x( n * n ); - for(i = 0; i < n * n; i++) - x[i] = Complex(2 * i, i); + // argument value + CPPAD_TESTVECTOR(Complex) x( n * n ); + for(i = 0; i < n * n; i++) + x[i] = Complex(2 * i, i); - // first derivative of the determinant - CPPAD_TESTVECTOR(Complex) J( n * n ); - J = f.Jacobian(x); + // first derivative of the determinant + CPPAD_TESTVECTOR(Complex) J( n * n ); + J = f.Jacobian(x); - /* - f(x) = x[0] * x[3] - x[1] * x[2] - f'(x) = ( x[3], -x[2], -x[1], x[0] ) - */ - Complex Jtrue[] = { x[3], -x[2], -x[1], x[0] }; - for(i = 0; i < n * n; i++) - ok &= Jtrue[i] == J[i]; + /* + f(x) = x[0] * x[3] - x[1] * x[2] + f'(x) = ( x[3], -x[2], -x[1], x[0] ) + */ + Complex Jtrue[] = { x[3], -x[2], -x[1], x[0] }; + for(i = 0; i < n * n; i++) + ok &= Jtrue[i] == J[i]; - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/example/general/jacobian.cpp cppad-2019.02.00.0/example/general/jacobian.cpp --- cppad-2018.00.00.0/example/general/jacobian.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/jacobian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin jacobian.cpp$$ $spell - Cpp - Jacobian + Cpp + Jacobian $$ $section Jacobian: Example and Test$$ -$mindex Jacobian$$ -$code $srcfile%example/general/jacobian.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,72 +29,72 @@ # include namespace { // --------------------------------------------------------- // define the template function JacobianCases in empty namespace -template +template bool JacobianCases() -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - using CppAD::exp; - using CppAD::sin; - using CppAD::cos; - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 1.; - X[1] = 2.; - - // declare independent variables and starting recording - CppAD::Independent(X); - - // a calculation between the domain and range values - AD Square = X[0] * X[0]; - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = Square * exp( X[1] ); - Y[1] = Square * sin( X[1] ); - Y[2] = Square * cos( X[1] ); - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - Vector x(n); - x[0] = 2.; - x[1] = 1.; - - // compute the derivative at this x - Vector jac( m * n ); - jac = f.Jacobian(x); - - /* - F'(x) = [ 2 * x[0] * exp(x[1]) , x[0] * x[0] * exp(x[1]) ] - [ 2 * x[0] * sin(x[1]) , x[0] * x[0] * cos(x[1]) ] - [ 2 * x[0] * cos(x[1]) , -x[0] * x[0] * sin(x[i]) ] - */ - ok &= NearEqual( 2.*x[0]*exp(x[1]), jac[0*n+0], eps99, eps99); - ok &= NearEqual( 2.*x[0]*sin(x[1]), jac[1*n+0], eps99, eps99); - ok &= NearEqual( 2.*x[0]*cos(x[1]), jac[2*n+0], eps99, eps99); - - ok &= NearEqual( x[0] * x[0] *exp(x[1]), jac[0*n+1], eps99, eps99); - ok &= NearEqual( x[0] * x[0] *cos(x[1]), jac[1*n+1], eps99, eps99); - ok &= NearEqual(-x[0] * x[0] *sin(x[1]), jac[2*n+1], eps99, eps99); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + using CppAD::exp; + using CppAD::sin; + using CppAD::cos; + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 1.; + X[1] = 2.; + + // declare independent variables and starting recording + CppAD::Independent(X); + + // a calculation between the domain and range values + AD Square = X[0] * X[0]; + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = Square * exp( X[1] ); + Y[1] = Square * sin( X[1] ); + Y[2] = Square * cos( X[1] ); + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + Vector x(n); + x[0] = 2.; + x[1] = 1.; + + // compute the derivative at this x + Vector jac( m * n ); + jac = f.Jacobian(x); + + /* + F'(x) = [ 2 * x[0] * exp(x[1]) , x[0] * x[0] * exp(x[1]) ] + [ 2 * x[0] * sin(x[1]) , x[0] * x[0] * cos(x[1]) ] + [ 2 * x[0] * cos(x[1]) , -x[0] * x[0] * sin(x[i]) ] + */ + ok &= NearEqual( 2.*x[0]*exp(x[1]), jac[0*n+0], eps99, eps99); + ok &= NearEqual( 2.*x[0]*sin(x[1]), jac[1*n+0], eps99, eps99); + ok &= NearEqual( 2.*x[0]*cos(x[1]), jac[2*n+0], eps99, eps99); + + ok &= NearEqual( x[0] * x[0] *exp(x[1]), jac[0*n+1], eps99, eps99); + ok &= NearEqual( x[0] * x[0] *cos(x[1]), jac[1*n+1], eps99, eps99); + ok &= NearEqual(-x[0] * x[0] *sin(x[1]), jac[2*n+1], eps99, eps99); - return ok; + return ok; } } // End empty namespace # include # include bool Jacobian(void) -{ bool ok = true; - // Run with Vector equal to three different cases - // all of which are Simple Vectors with elements of type double. - ok &= JacobianCases< CppAD::vector >(); - ok &= JacobianCases< std::vector >(); - ok &= JacobianCases< std::valarray >(); - return ok; +{ bool ok = true; + // Run with Vector equal to three different cases + // all of which are Simple Vectors with elements of type double. + ok &= JacobianCases< CppAD::vector >(); + ok &= JacobianCases< std::vector >(); + ok &= JacobianCases< std::valarray >(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/log10.cpp cppad-2019.02.00.0/example/general/log10.cpp --- cppad-2018.00.00.0/example/general/log10.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/log10.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin log10.cpp$$ $spell - log + log $$ $section The AD log10 Function: Example and Test$$ -$code $srcfile%example/general/log10.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,58 +28,58 @@ # include bool log10(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * 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); - - // ten raised to the x0 power - AD ten = 10.; - AD pow_10_x0 = CppAD::pow(ten, x[0]); - - // 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); - - // check value - ok &= NearEqual(y[0] , x0, eps99, eps99); - - // 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., eps99, eps99); - - // 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., eps99, eps99); - - // use a VecAD::reference object with log10 - CppAD::VecAD v(1); - AD zero(0); - v[zero] = pow_10_x0; - AD result = CppAD::log10(v[zero]); - ok &= NearEqual(result, x0, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * 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); + + // ten raised to the x0 power + AD ten = 10.; + AD pow_10_x0 = CppAD::pow(ten, x[0]); + + // 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); + + // check value + ok &= NearEqual(y[0] , x0, eps99, eps99); + + // 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., eps99, eps99); + + // 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., eps99, eps99); + + // use a VecAD::reference object with log10 + CppAD::VecAD v(1); + AD zero(0); + v[zero] = pow_10_x0; + AD result = CppAD::log10(v[zero]); + ok &= NearEqual(result, x0, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/log1p.cpp cppad-2019.02.00.0/example/general/log1p.cpp --- cppad-2018.00.00.0/example/general/log1p.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/log1p.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin log1p.cpp$$ $spell - expm1 - log1p + expm1 + log1p $$ $section The AD log1p Function: Example and Test$$ -$code $srcfile%example/general/log1p.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,59 +28,59 @@ # include bool log1p(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; + using CppAD::AD; + using CppAD::NearEqual; - // 10 times machine epsilon - double eps = 10. * std::numeric_limits::epsilon(); + // 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); + // 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/log.cpp cppad-2019.02.00.0/example/general/log.cpp --- cppad-2018.00.00.0/example/general/log.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/log.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin log.cpp$$ $spell - exp - log + exp + log $$ $section The AD log Function: Example and Test$$ -$code $srcfile%example/general/log.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,57 +29,57 @@ # include bool log(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * 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 exp_of_x0 = CppAD::exp(x[0]); - - // 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); - - // check value - ok &= NearEqual(y[0] , x0, eps99, eps99); - - // 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., eps99, eps99); - - // 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., eps99, eps99); - - // use a VecAD::reference object with log - CppAD::VecAD v(1); - AD zero(0); - v[zero] = exp_of_x0; - AD result = CppAD::log(v[zero]); - ok &= NearEqual(result, x0, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * 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 exp_of_x0 = CppAD::exp(x[0]); + + // 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); + + // check value + ok &= NearEqual(y[0] , x0, eps99, eps99); + + // 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., eps99, eps99); + + // 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., eps99, eps99); + + // use a VecAD::reference object with log + CppAD::VecAD v(1); + AD zero(0); + v[zero] = exp_of_x0; + AD result = CppAD::log(v[zero]); + ok &= NearEqual(result, x0, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/lu_ratio.cpp cppad-2019.02.00.0/example/general/lu_ratio.cpp --- cppad-2018.00.00.0/example/general/lu_ratio.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/lu_ratio.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,27 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin lu_ratio.cpp$$ $spell - Geq - Cpp - Lu + Geq + Cpp + Lu $$ $section LuRatio: Example and Test$$ -$mindex LuRatio$$ -$code $srcfile%example/general/lu_ratio.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -36,157 +34,157 @@ namespace { // Begin empty namespace CppAD::ADFun *NewFactor( - size_t n , - const CPPAD_TESTVECTOR(double) &x , - bool &ok , - CPPAD_TESTVECTOR(size_t) &ip , - CPPAD_TESTVECTOR(size_t) &jp ) -{ using CppAD::AD; - using CppAD::ADFun; - size_t i, j, k; - - // values for independent and dependent variables - CPPAD_TESTVECTOR(AD) Y(n*n+1), X(n*n); - - // values for the LU factor - CPPAD_TESTVECTOR(AD) LU(n*n); - - // record the LU factorization corresponding to this value of x - AD Ratio; - for(k = 0; k < n*n; k++) - X[k] = x[k]; - Independent(X); - for(k = 0; k < n*n; k++) - LU[k] = X[k]; - CppAD::LuRatio(ip, jp, LU, Ratio); - for(k = 0; k < n*n; k++) - Y[k] = LU[k]; - Y[n*n] = Ratio; - - // use a function pointer so can return ADFun object - ADFun *FunPtr = new ADFun(X, Y); - - // check value of ratio during recording - ok &= (Ratio == 1.); - - // check that ip and jp are permutations of the indices 0, ... , n-1 - for(i = 0; i < n; i++) - { ok &= (ip[i] < n); - ok &= (jp[i] < n); - for(j = 0; j < n; j++) - { if( i != j ) - { ok &= (ip[i] != ip[j]); - ok &= (jp[i] != jp[j]); - } - } - } - return FunPtr; + size_t n , + const CPPAD_TESTVECTOR(double) &x , + bool &ok , + CPPAD_TESTVECTOR(size_t) &ip , + CPPAD_TESTVECTOR(size_t) &jp ) +{ using CppAD::AD; + using CppAD::ADFun; + size_t i, j, k; + + // values for independent and dependent variables + CPPAD_TESTVECTOR(AD) Y(n*n+1), X(n*n); + + // values for the LU factor + CPPAD_TESTVECTOR(AD) LU(n*n); + + // record the LU factorization corresponding to this value of x + AD Ratio; + for(k = 0; k < n*n; k++) + X[k] = x[k]; + Independent(X); + for(k = 0; k < n*n; k++) + LU[k] = X[k]; + CppAD::LuRatio(ip, jp, LU, Ratio); + for(k = 0; k < n*n; k++) + Y[k] = LU[k]; + Y[n*n] = Ratio; + + // use a function pointer so can return ADFun object + ADFun *FunPtr = new ADFun(X, Y); + + // check value of ratio during recording + ok &= (Ratio == 1.); + + // check that ip and jp are permutations of the indices 0, ... , n-1 + for(i = 0; i < n; i++) + { ok &= (ip[i] < n); + ok &= (jp[i] < n); + for(j = 0; j < n; j++) + { if( i != j ) + { ok &= (ip[i] != ip[j]); + ok &= (jp[i] != jp[j]); + } + } + } + return FunPtr; } bool CheckLuFactor( - size_t n , - const CPPAD_TESTVECTOR(double) &x , - const CPPAD_TESTVECTOR(double) &y , - const CPPAD_TESTVECTOR(size_t) &ip , - const CPPAD_TESTVECTOR(size_t) &jp ) -{ bool ok = true; - - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - double sum; // element of L * U - double pij; // element of permuted x - size_t i, j, k; // temporary indices - - // L and U factors - CPPAD_TESTVECTOR(double) L(n*n), U(n*n); - - // Extract L from LU factorization - for(i = 0; i < n; i++) - { // elements along and below the diagonal - for(j = 0; j <= i; j++) - L[i * n + j] = y[ ip[i] * n + jp[j] ]; - // elements above the diagonal - for(j = i+1; j < n; j++) - L[i * n + j] = 0.; - } - - // Extract U from LU factorization - for(i = 0; i < n; i++) - { // elements below the diagonal - for(j = 0; j < i; j++) - U[i * n + j] = 0.; - // elements along the diagonal - U[i * n + i] = 1.; - // elements above the diagonal - for(j = i+1; j < n; j++) - U[i * n + j] = y[ ip[i] * n + jp[j] ]; - } - - // Compute L * U - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - { // compute element (i,j) entry in L * U - sum = 0.; - for(k = 0; k < n; k++) - sum += L[i * n + k] * U[k * n + j]; - // element (i,j) in permuted version of A - pij = x[ ip[i] * n + jp[j] ]; - // compare - ok &= NearEqual(pij, sum, eps99, eps99); - } - } - return ok; + size_t n , + const CPPAD_TESTVECTOR(double) &x , + const CPPAD_TESTVECTOR(double) &y , + const CPPAD_TESTVECTOR(size_t) &ip , + const CPPAD_TESTVECTOR(size_t) &jp ) +{ bool ok = true; + + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + double sum; // element of L * U + double pij; // element of permuted x + size_t i, j, k; // temporary indices + + // L and U factors + CPPAD_TESTVECTOR(double) L(n*n), U(n*n); + + // Extract L from LU factorization + for(i = 0; i < n; i++) + { // elements along and below the diagonal + for(j = 0; j <= i; j++) + L[i * n + j] = y[ ip[i] * n + jp[j] ]; + // elements above the diagonal + for(j = i+1; j < n; j++) + L[i * n + j] = 0.; + } + + // Extract U from LU factorization + for(i = 0; i < n; i++) + { // elements below the diagonal + for(j = 0; j < i; j++) + U[i * n + j] = 0.; + // elements along the diagonal + U[i * n + i] = 1.; + // elements above the diagonal + for(j = i+1; j < n; j++) + U[i * n + j] = y[ ip[i] * n + jp[j] ]; + } + + // Compute L * U + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { // compute element (i,j) entry in L * U + sum = 0.; + for(k = 0; k < n; k++) + sum += L[i * n + k] * U[k * n + j]; + // element (i,j) in permuted version of A + pij = x[ ip[i] * n + jp[j] ]; + // compare + ok &= NearEqual(pij, sum, eps99, eps99); + } + } + return ok; } } // end Empty namespace bool LuRatio(void) -{ bool ok = true; +{ bool ok = true; - size_t n = 2; // number rows in A - double ratio; + size_t n = 2; // number rows in A + double ratio; - // values for independent and dependent variables - CPPAD_TESTVECTOR(double) x(n*n), y(n*n+1); + // values for independent and dependent variables + CPPAD_TESTVECTOR(double) x(n*n), y(n*n+1); - // pivot vectors - CPPAD_TESTVECTOR(size_t) ip(n), jp(n); - - // set x equal to the identity matrix - x[0] = 1.; x[1] = 0; - x[2] = 0.; x[3] = 1.; - - // create a fnction object corresponding to this value of x - CppAD::ADFun *FunPtr = NewFactor(n, x, ok, ip, jp); - - // use function object to factor matrix - y = FunPtr->Forward(0, x); - ratio = y[n*n]; - ok &= (ratio == 1.); - ok &= CheckLuFactor(n, x, y, ip, jp); - - // set x so that the pivot ratio will be infinite - x[0] = 0. ; x[1] = 1.; - x[2] = 1. ; x[3] = 0.; - - // try to use old function pointer to factor matrix - y = FunPtr->Forward(0, x); - ratio = y[n*n]; - - // check to see if we need to refactor matrix - ok &= (ratio > 10.); - if( ratio > 10. ) - { delete FunPtr; // to avoid a memory leak - FunPtr = NewFactor(n, x, ok, ip, jp); - } - - // now we can use the function object to factor matrix - y = FunPtr->Forward(0, x); - ratio = y[n*n]; - ok &= (ratio == 1.); - ok &= CheckLuFactor(n, x, y, ip, jp); + // pivot vectors + CPPAD_TESTVECTOR(size_t) ip(n), jp(n); + + // set x equal to the identity matrix + x[0] = 1.; x[1] = 0; + x[2] = 0.; x[3] = 1.; + + // create a fnction object corresponding to this value of x + CppAD::ADFun *FunPtr = NewFactor(n, x, ok, ip, jp); + + // use function object to factor matrix + y = FunPtr->Forward(0, x); + ratio = y[n*n]; + ok &= (ratio == 1.); + ok &= CheckLuFactor(n, x, y, ip, jp); + + // set x so that the pivot ratio will be infinite + x[0] = 0. ; x[1] = 1.; + x[2] = 1. ; x[3] = 0.; + + // try to use old function pointer to factor matrix + y = FunPtr->Forward(0, x); + ratio = y[n*n]; + + // check to see if we need to refactor matrix + ok &= (ratio > 10.); + if( ratio > 10. ) + { delete FunPtr; // to avoid a memory leak + FunPtr = NewFactor(n, x, ok, ip, jp); + } + + // now we can use the function object to factor matrix + y = FunPtr->Forward(0, x); + ratio = y[n*n]; + ok &= (ratio == 1.); + ok &= CheckLuFactor(n, x, y, ip, jp); - delete FunPtr; // avoid memory leak - return ok; + delete FunPtr; // avoid memory leak + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/lu_vec_ad.cpp cppad-2019.02.00.0/example/general/lu_vec_ad.cpp --- cppad-2018.00.00.0/example/general/lu_vec_ad.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/general/lu_vec_ad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,47 +1,46 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin lu_vec_ad.cpp$$ -$escape #$$ $spell - signdet - Lu - Vec - Rhs - logdet - Cpp + signdet + Lu + Vec + Rhs + logdet + Cpp $$ $section Lu Factor and Solve with Recorded Pivoting$$ -$mindex LuVecAD linear equation determinant$$ $pre $$ $head Syntax$$ $codei%int LuVecAD( - size_t %n%, - size_t %m%, - VecAD<%double%> &%Matrix%, - VecAD<%double%> &%Rhs%, - VecAD<%double%> &%Result%, - AD<%double%> &%logdet%)%$$ + size_t %n%, + size_t %m%, + VecAD<%double%> &%Matrix%, + VecAD<%double%> &%Rhs%, + VecAD<%double%> &%Result%, + AD<%double%> &%logdet%)%$$ $head Purpose$$ Solves the linear equation $latex \[ - Matrix * Result = Rhs + Matrix * Result = Rhs \] $$ where $icode Matrix$$ is an $latex n \times n$$ matrix, $icode Rhs$$ is an $latex n x m$$ matrix, and @@ -73,7 +72,7 @@ and $latex j$$ is between zero and $latex m-1$$, $latex \[ - A_{i,j} = A[ i * m + j ] + A_{i,j} = A[ i * m + j ] \] $$ (The length of $latex A$$ must be equal to $latex n * m $$.) @@ -122,19 +121,18 @@ if $icode signdet$$ is the value returned by $code LuVecAD$$, the determinant of $icode Matrix$$ is given by the formula $latex \[ - det = signdet \exp( logdet ) + det = signdet \exp( logdet ) \] $$ This enables $code LuVecAD$$ to use logs of absolute values. $head Example$$ $children% - example/general/lu_vec_ad_ok.cpp + example/general/lu_vec_ad_ok.cpp %$$ The file $cref lu_vec_ad_ok.cpp$$ contains an example and test of $code LuVecAD$$. -It returns true if it succeeds and false otherwise. $end @@ -148,203 +146,203 @@ namespace CppAD { AD LuVecAD( - size_t n, - size_t m, - CppAD::VecAD &Matrix, - CppAD::VecAD &Rhs, - CppAD::VecAD &Result, - CppAD::AD &logdet) + size_t n, + size_t m, + CppAD::VecAD &Matrix, + CppAD::VecAD &Rhs, + CppAD::VecAD &Result, + CppAD::AD &logdet) { - using namespace CppAD; - typedef AD Type; + using namespace CppAD; + typedef AD Type; - // temporary index - Type index; - Type jndex; - - // index and maximum element value - Type imax; - Type jmax; - Type itmp; - Type jtmp; - Type emax; - - // some temporary indices - Type i; - Type j; - Type k; - - // count pivots - Type p; - - // sign of the determinant - Type signdet; - - // temporary values - Type etmp; - Type diff; - - // pivot element - Type pivot; - - // singular matrix - Type singular = 0.; - - // some constants - Type M(m); - Type N(n); - Type One(1); - Type Zero(0); - - // pivot row and column order in the matrix - VecAD ip(n); - VecAD jp(n); - - // ------------------------------------------------------- - - // initialize row and column order in matrix not yet pivoted - for(i = 0; i < N; i += 1.) - { ip[i] = i; - jp[i] = i; - } - - // initialize the log determinant - logdet = 0.; - signdet = 1; - - for(p = 0; p < N; p += 1.) - { - // determine row and column corresponding to element of - // maximum absolute value in remaining part of Matrix - imax = N; - jmax = N; - emax = 0.; - for(i = p; i < N; i += 1.) - { itmp = ip[i] * N; - for(j = p; j < N; j += 1.) - { assert( - (ip[i] < N) & (jp[j] < N) - ); - index = itmp + jp[j]; - etmp = Matrix[ index ]; - - // compute absolute value of element - etmp = fabs(etmp); - - // update maximum absolute value so far - emax = CondExpGe(etmp, emax, etmp, emax); - imax = CondExpGe(etmp, emax, i, imax); - jmax = CondExpGe(etmp, emax, j, jmax); - } - } - assert( (imax < N) & (jmax < N) ); - - - // switch rows so max absolute element is in row p - index = ip[p]; - ip[p] = ip[imax]; - ip[imax] = index; - - // if imax != p, switch sign of determinant - signdet = CondExpEq(imax, p, signdet, -signdet); - - // switch columns so max absolute element is in column p - jndex = jp[p]; - jp[p] = jp[jmax]; - jp[jmax] = jndex; - - // 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]; - pivot = Matrix[ index ]; - - // update the singular matrix flag - singular = CondExpEq(pivot, Zero, One, singular); - - // update the log of absolute determinant and its sign - etmp = fabs(pivot); - logdet = logdet + log( etmp ); - signdet = CondExpGe(pivot, Zero, signdet, - signdet); - - /* - 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 - */ - - // divide row number ip[p] by pivot element - for(j = p + 1.; j < N; j += 1.) - { - index = itmp + jp[j]; - Matrix[ index ] = Matrix[ index ] / pivot; - } - - // not used anymore so no need to set to 1 - // Matrix[ ip[p] * N + jp[p] ] = Type(1); - - // divide corresponding row of right hand side by pivot element - itmp = ip[p] * M; - for(k = 0; k < M; k += 1.) - { - index = itmp + k; - Rhs[ index ] = Rhs[ index ] / pivot; - } - - for(i = p + 1.; i < N; i += 1. ) - { itmp = ip[i] * N; - jtmp = ip[p] * N; - - index = itmp + jp[p]; - etmp = Matrix[ index ]; - - for(j = p + 1.; j < N; j += 1.) - { index = itmp + jp[j]; - jndex = jtmp + jp[j]; - Matrix[ index ] = Matrix[ index ] - - etmp * Matrix[ jndex ]; - } - - itmp = ip[i] * M; - jtmp = ip[p] * M; - for(k = 0; k < M; k += 1.) - { - index = itmp + k; - jndex = jtmp + k; - Rhs[ index ] = Rhs[ index ] - - etmp * Rhs[ jndex ]; - } - - // not used any more so no need to set to zero - // Matrix[ ip[i] * N + jp[p] ] = 0.; - } - - } - - // loop over equations - for(k = 0; k < M; k += 1.) - { // loop over variables - p = N; - while( p > 0. ) - { p -= 1.; - index = ip[p] * M + k; - jndex = jp[p] * M + k; - etmp = Rhs[ index ]; - Result[ jndex ] = etmp; - for(i = 0; i < p; i += 1. ) - { - index = ip[i] * M + k; - jndex = ip[i] * N + jp[p]; - Rhs[ index ] = Rhs[ index ] - - etmp * Matrix[ jndex ]; - } - } - } + // temporary index + Type index; + Type jndex; + + // index and maximum element value + Type imax; + Type jmax; + Type itmp; + Type jtmp; + Type emax; + + // some temporary indices + Type i; + Type j; + Type k; + + // count pivots + Type p; + + // sign of the determinant + Type signdet; + + // temporary values + Type etmp; + Type diff; + + // pivot element + Type pivot; + + // singular matrix + Type singular = 0.; + + // some constants + Type M(m); + Type N(n); + Type One(1); + Type Zero(0); + + // pivot row and column order in the matrix + VecAD ip(n); + VecAD jp(n); + + // ------------------------------------------------------- + + // initialize row and column order in matrix not yet pivoted + for(i = 0; i < N; i += 1.) + { ip[i] = i; + jp[i] = i; + } + + // initialize the log determinant + logdet = 0.; + signdet = 1; + + for(p = 0; p < N; p += 1.) + { + // determine row and column corresponding to element of + // maximum absolute value in remaining part of Matrix + imax = N; + jmax = N; + emax = 0.; + for(i = p; i < N; i += 1.) + { itmp = ip[i] * N; + for(j = p; j < N; j += 1.) + { assert( + (ip[i] < N) & (jp[j] < N) + ); + index = itmp + jp[j]; + etmp = Matrix[ index ]; + + // compute absolute value of element + etmp = fabs(etmp); + + // update maximum absolute value so far + emax = CondExpGe(etmp, emax, etmp, emax); + imax = CondExpGe(etmp, emax, i, imax); + jmax = CondExpGe(etmp, emax, j, jmax); + } + } + assert( (imax < N) & (jmax < N) ); + + + // switch rows so max absolute element is in row p + index = ip[p]; + ip[p] = ip[imax]; + ip[imax] = index; + + // if imax != p, switch sign of determinant + signdet = CondExpEq(imax, p, signdet, -signdet); + + // switch columns so max absolute element is in column p + jndex = jp[p]; + jp[p] = jp[jmax]; + jp[jmax] = jndex; + + // 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]; + pivot = Matrix[ index ]; + + // update the singular matrix flag + singular = CondExpEq(pivot, Zero, One, singular); + + // update the log of absolute determinant and its sign + etmp = fabs(pivot); + logdet = logdet + log( etmp ); + signdet = CondExpGe(pivot, Zero, signdet, - signdet); + + /* + 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 + */ + + // divide row number ip[p] by pivot element + for(j = p + 1.; j < N; j += 1.) + { + index = itmp + jp[j]; + Matrix[ index ] = Matrix[ index ] / pivot; + } + + // not used anymore so no need to set to 1 + // Matrix[ ip[p] * N + jp[p] ] = Type(1); + + // divide corresponding row of right hand side by pivot element + itmp = ip[p] * M; + for(k = 0; k < M; k += 1.) + { + index = itmp + k; + Rhs[ index ] = Rhs[ index ] / pivot; + } + + for(i = p + 1.; i < N; i += 1. ) + { itmp = ip[i] * N; + jtmp = ip[p] * N; + + index = itmp + jp[p]; + etmp = Matrix[ index ]; + + for(j = p + 1.; j < N; j += 1.) + { index = itmp + jp[j]; + jndex = jtmp + jp[j]; + Matrix[ index ] = Matrix[ index ] + - etmp * Matrix[ jndex ]; + } + + itmp = ip[i] * M; + jtmp = ip[p] * M; + for(k = 0; k < M; k += 1.) + { + index = itmp + k; + jndex = jtmp + k; + Rhs[ index ] = Rhs[ index ] + - etmp * Rhs[ jndex ]; + } + + // not used any more so no need to set to zero + // Matrix[ ip[i] * N + jp[p] ] = 0.; + } + + } + + // loop over equations + for(k = 0; k < M; k += 1.) + { // loop over variables + p = N; + while( p > 0. ) + { p -= 1.; + index = ip[p] * M + k; + jndex = jp[p] * M + k; + etmp = Rhs[ index ]; + Result[ jndex ] = etmp; + for(i = 0; i < p; i += 1. ) + { + index = ip[i] * M + k; + jndex = ip[i] * N + jp[p]; + Rhs[ index ] = Rhs[ index ] + - etmp * Matrix[ jndex ]; + } + } + } - // make sure return zero in the singular case - return (1. - singular) * signdet; + // make sure return zero in the singular case + return (1. - singular) * signdet; } } // END CppAD namespace diff -Nru cppad-2018.00.00.0/example/general/lu_vec_ad.hpp cppad-2019.02.00.0/example/general/lu_vec_ad.hpp --- cppad-2018.00.00.0/example/general/lu_vec_ad.hpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/lu_vec_ad.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,25 +3,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include namespace CppAD { - extern CppAD::AD LuVecAD( - size_t n, - size_t m, - CppAD::VecAD &Matrix, - CppAD::VecAD &Rhs, - CppAD::VecAD &Result, - CppAD::AD &logdet - ); + extern CppAD::AD LuVecAD( + size_t n, + size_t m, + CppAD::VecAD &Matrix, + CppAD::VecAD &Rhs, + CppAD::VecAD &Result, + CppAD::AD &logdet + ); } # endif diff -Nru cppad-2018.00.00.0/example/general/lu_vec_ad_ok.cpp cppad-2019.02.00.0/example/general/lu_vec_ad_ok.cpp --- cppad-2018.00.00.0/example/general/lu_vec_ad_ok.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/lu_vec_ad_ok.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,27 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin lu_vec_ad_ok.cpp$$ $spell - Geq - Cpp - Lu + Geq + Cpp + Lu $$ $section Lu Factor and Solve With Recorded Pivoting: Example and Test$$ -$mindex record pivot$$ -$code $srcfile%example/general/lu_vec_ad_ok.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -35,122 +33,122 @@ # include bool LuVecADOk(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; - typedef AD ADdouble; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - size_t n = 3; - size_t m = 2; - double a1[] = { - 3., 0., 0., // (1,1) is first pivot - 1., 2., 1., // (2,2) is second pivot - 1., 0., .5 // (3,3) is third pivot - }; - double a2[] = { - 1., 2., 1., // (1,2) is second pivot - 3., 0., 0., // (2,1) is first pivot - 1., 0., .5 // (3,3) is third pivot - }; - double rhs[] = { - 1., 3., - 2., 2., - 3., 1. - }; - - VecAD Copy (n * n); - VecAD Rhs (n * m); - VecAD Result (n * m); - ADdouble logdet; - ADdouble signdet; - - // routine for checking determinants using expansion by minors - det_by_minor Det(n); - - // matrix we are computing the determinant of - CPPAD_TESTVECTOR(ADdouble) A(n * n); - - // dependent variable values - CPPAD_TESTVECTOR(ADdouble) Y(1 + n * m); - - size_t i; - size_t j; - size_t k; - - // Original matrix - for(i = 0; i < n * n; i++) - A[i] = a1[i]; - - // right hand side - 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); - - // Copy the matrix - ADdouble index(0); - for(i = 0; i < n*n; i++) - { Copy[index] = A[i]; - index += 1.; - } - - // Solve the equation - signdet = LuVecAD(n, m, Copy, Rhs, Result, logdet); - - // Result is the first n * m dependent variables - index = 0.; - for(i = 0; i < n * m; i++) - { Y[i] = Result[index]; - index += 1.; - } - - // Determinant is last component of the solution - Y[ n * m ] = signdet * exp( logdet ); - - // construct f: A -> Y - ADFun f(A, Y); - - // check determinant using minors routine - ADdouble determinant = Det( A ); - ok &= NearEqual(Y[n * m], determinant, eps99, eps99); - - - // Check solution of Rhs = A * Result - double sum; - for(k = 0; k < m; k++) - { for(i = 0; i < n; i++) - { sum = 0.; - for(j = 0; j < n; j++) - sum += a1[i * n + j] * Value( Y[j * m + k] ); - ok &= NearEqual( rhs[i * m + k], sum, eps99, eps99); - } - } - - 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), eps99, eps99); - - // Check solution of Rhs = A2 * Result - for(k = 0; k < m; k++) - { for(i = 0; i < n; i++) - { sum = 0.; - for(j = 0; j < n; j++) - sum += a2[i * n + j] * y2[j * m + k]; - ok &= NearEqual( rhs[i * m + k], sum, eps99, eps99); - } - } + using namespace CppAD; + typedef AD ADdouble; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + size_t n = 3; + size_t m = 2; + double a1[] = { + 3., 0., 0., // (1,1) is first pivot + 1., 2., 1., // (2,2) is second pivot + 1., 0., .5 // (3,3) is third pivot + }; + double a2[] = { + 1., 2., 1., // (1,2) is second pivot + 3., 0., 0., // (2,1) is first pivot + 1., 0., .5 // (3,3) is third pivot + }; + double rhs[] = { + 1., 3., + 2., 2., + 3., 1. + }; + + VecAD Copy (n * n); + VecAD Rhs (n * m); + VecAD Result (n * m); + ADdouble logdet; + ADdouble signdet; + + // routine for checking determinants using expansion by minors + det_by_minor Det(n); + + // matrix we are computing the determinant of + CPPAD_TESTVECTOR(ADdouble) A(n * n); + + // dependent variable values + CPPAD_TESTVECTOR(ADdouble) Y(1 + n * m); + + size_t i; + size_t j; + size_t k; + + // Original matrix + for(i = 0; i < n * n; i++) + A[i] = a1[i]; + + // right hand side + 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); + + // Copy the matrix + ADdouble index(0); + for(i = 0; i < n*n; i++) + { Copy[index] = A[i]; + index += 1.; + } + + // Solve the equation + signdet = LuVecAD(n, m, Copy, Rhs, Result, logdet); + + // Result is the first n * m dependent variables + index = 0.; + for(i = 0; i < n * m; i++) + { Y[i] = Result[index]; + index += 1.; + } + + // Determinant is last component of the solution + Y[ n * m ] = signdet * exp( logdet ); + + // construct f: A -> Y + ADFun f(A, Y); + + // check determinant using minors routine + ADdouble determinant = Det( A ); + ok &= NearEqual(Y[n * m], determinant, eps99, eps99); + + + // Check solution of Rhs = A * Result + double sum; + for(k = 0; k < m; k++) + { for(i = 0; i < n; i++) + { sum = 0.; + for(j = 0; j < n; j++) + sum += a1[i * n + j] * Value( Y[j * m + k] ); + ok &= NearEqual( rhs[i * m + k], sum, eps99, eps99); + } + } + + 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), eps99, eps99); + + // Check solution of Rhs = A2 * Result + for(k = 0; k < m; k++) + { for(i = 0; i < n; i++) + { sum = 0.; + for(j = 0; j < n; j++) + sum += a2[i * n + j] * y2[j * m + k]; + ok &= NearEqual( rhs[i * m + k], sum, eps99, eps99); + } + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/makefile.am cppad-2019.02.00.0/example/general/makefile.am --- cppad-2018.00.00.0/example/general/makefile.am 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -15,65 +16,44 @@ # ------------------------------------------------------------------------- if CppAD_ADOLC 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 = -I$(ADOLC_DIR)/include else -ADOLC_EXTRA_FILES = mul_level_adolc.cpp mul_level_adolc_ode.cpp ADOLC_SRC_FILES = ADOLC_LIB = ADOLC_FLAGS = endif # ------------------------------------------------------------------------- -if CppAD_HAVE_AR -if CppAD_EIGEN_DIR -# make a special library so can have it's own compile flags (see configure.ac) -EIGEN_EXTRA_FILES = -noinst_LIBRARIES = libeigen.a -libeigen_a_SOURCES = eigen_det.cpp eigen_array.cpp -EIGEN_LIB = -L. -leigen +if CppAD_EIGEN +EIGEN_SRC_FILES = eigen_det.cpp eigen_array.cpp EIGEN_FLAGS = -libeigen_a_CXXFLAGS = \ - -g $(CXX_FLAGS_EIGEN) \ - -I$(EIGEN_DIR)/include else -EIGEN_EXTRA_FILES = eigen_det.cpp eigen_array.cpp -EIGEN_LIB = -EIGEN_FLAGS = -endif -else -EIGEN_EXTRA_FILES = eigen_det.cpp eigen_array.cpp -EIGEN_LIB = +EIGEN_SRC_FILES = EIGEN_FLAGS = endif # ------------------------------------------------------------------------- # autotools does not support use of colpack -EXTRA_DIST = \ - $(ADOLC_EXTRA_FILES) \ - $(EIGEN_EXTRA_FILES) # check_PROGRAMS = general # -if CppAD_MS_COMPILER -AM_CXXFLAGS = -EHsc -g $(ADOLC_FLAGS) $(EIGEN_FLAGS) $(CXX_FLAGS) -else -AM_CXXFLAGS = -g $(ADOLC_FLAGS) $(EIGEN_FLAGS) $(CXX_FLAGS) -endif -# -AM_CPPFLAGS = \ - -I. \ - -I$(top_srcdir) \ +AM_CXXFLAGS = \ + $(ADOLC_FLAGS) \ + $(EIGEN_FLAGS) \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ $(ADOLC_FLAGS) \ $(EIGEN_FLAGS) # -LDADD = $(ADOLC_LIB) $(BTHREAD_LIB) $(EIGEN_LIB) $(PTHREAD_LIB) +LDADD = $(ADOLC_LIB) # general_SOURCES = \ $(ADOLC_SRC_FILES) \ + $(EIGEN_SRC_FILES) \ \ abort_recording.cpp \ + base2ad.cpp \ fabs.cpp \ acos.cpp \ acosh.cpp \ @@ -143,13 +123,14 @@ mul_level.cpp \ mul_level_ode.cpp \ near_equal_ext.cpp \ + new_dynamic.cpp \ number_skip.cpp \ numeric_type.cpp \ num_limits.cpp \ ode_stiff.cpp \ - ode_taylor.cpp \ + taylor_ode.cpp \ opt_val_hes.cpp \ - par_var.cpp \ + con_dyn_var.cpp \ poly.cpp \ pow.cpp \ pow_int.cpp \ diff -Nru cppad-2018.00.00.0/example/general/makefile.in cppad-2019.02.00.0/example/general/makefile.in --- cppad-2018.00.00.0/example/general/makefile.in 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -13,7 +13,6 @@ # PARTICULAR PURPOSE. @SET_MAKE@ - VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ @@ -98,53 +97,45 @@ mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -LIBRARIES = $(noinst_LIBRARIES) -ARFLAGS = cru -AM_V_AR = $(am__v_AR_@AM_V@) -am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) -am__v_AR_0 = @echo " AR " $@; -am__v_AR_1 = -libeigen_a_AR = $(AR) $(ARFLAGS) -libeigen_a_LIBADD = -am__libeigen_a_SOURCES_DIST = eigen_det.cpp eigen_array.cpp -@CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@am_libeigen_a_OBJECTS = libeigen_a-eigen_det.$(OBJEXT) \ -@CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@ libeigen_a-eigen_array.$(OBJEXT) -libeigen_a_OBJECTS = $(am_libeigen_a_OBJECTS) am__general_SOURCES_DIST = mul_level_adolc.cpp mul_level_adolc_ode.cpp \ - abort_recording.cpp fabs.cpp acos.cpp acosh.cpp ad_assign.cpp \ - ad_ctor.cpp add.cpp add_eq.cpp ad_fun.cpp ad_in_c.cpp \ - ad_input.cpp ad_output.cpp asin.cpp asinh.cpp atan2.cpp \ - atan.cpp atanh.cpp azmul.cpp base_alloc.hpp base_require.cpp \ - bender_quad.cpp bool_fun.cpp capacity_order.cpp \ - change_param.cpp check_for_nan.cpp compare_change.cpp \ - compare.cpp complex_poly.cpp cond_exp.cpp cos.cpp cosh.cpp \ - div.cpp div_eq.cpp equal_op_seq.cpp erf.cpp general.cpp \ - exp.cpp expm1.cpp for_one.cpp for_two.cpp forward.cpp \ - forward_dir.cpp forward_order.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 integer.cpp \ - interface2c.cpp interp_onetape.cpp interp_retape.cpp \ - jac_lu_det.cpp jac_minor_det.cpp jacobian.cpp log10.cpp \ - log1p.cpp log.cpp lu_ratio.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 near_equal_ext.cpp number_skip.cpp \ - numeric_type.cpp num_limits.cpp ode_stiff.cpp ode_taylor.cpp \ - opt_val_hes.cpp par_var.cpp poly.cpp pow.cpp pow_int.cpp \ - print_for.cpp reverse_checkpoint.cpp reverse_one.cpp \ - reverse_three.cpp reverse_two.cpp rev_one.cpp rev_two.cpp \ - rosen_34.cpp runge45_2.cpp seq_property.cpp sign.cpp sin.cpp \ - sinh.cpp sqrt.cpp stack_machine.cpp sub.cpp sub_eq.cpp tan.cpp \ - tanh.cpp tape_index.cpp unary_minus.cpp unary_plus.cpp \ - value.cpp var2par.cpp vec_ad.cpp + eigen_det.cpp eigen_array.cpp abort_recording.cpp base2ad.cpp \ + fabs.cpp acos.cpp acosh.cpp ad_assign.cpp ad_ctor.cpp add.cpp \ + add_eq.cpp ad_fun.cpp ad_in_c.cpp ad_input.cpp ad_output.cpp \ + asin.cpp asinh.cpp atan2.cpp atan.cpp atanh.cpp azmul.cpp \ + base_alloc.hpp base_require.cpp bender_quad.cpp bool_fun.cpp \ + capacity_order.cpp change_param.cpp check_for_nan.cpp \ + compare_change.cpp compare.cpp complex_poly.cpp cond_exp.cpp \ + cos.cpp cosh.cpp div.cpp div_eq.cpp equal_op_seq.cpp erf.cpp \ + general.cpp exp.cpp expm1.cpp for_one.cpp for_two.cpp \ + forward.cpp forward_dir.cpp forward_order.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 integer.cpp interface2c.cpp interp_onetape.cpp \ + interp_retape.cpp jac_lu_det.cpp jac_minor_det.cpp \ + jacobian.cpp log10.cpp log1p.cpp log.cpp lu_ratio.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 near_equal_ext.cpp \ + new_dynamic.cpp number_skip.cpp numeric_type.cpp \ + num_limits.cpp ode_stiff.cpp taylor_ode.cpp opt_val_hes.cpp \ + con_dyn_var.cpp poly.cpp pow.cpp pow_int.cpp print_for.cpp \ + reverse_checkpoint.cpp reverse_one.cpp reverse_three.cpp \ + reverse_two.cpp rev_one.cpp rev_two.cpp rosen_34.cpp \ + runge45_2.cpp seq_property.cpp sign.cpp sin.cpp sinh.cpp \ + sqrt.cpp stack_machine.cpp sub.cpp sub_eq.cpp tan.cpp tanh.cpp \ + tape_index.cpp unary_minus.cpp unary_plus.cpp value.cpp \ + var2par.cpp vec_ad.cpp @CppAD_ADOLC_TRUE@am__objects_1 = mul_level_adolc.$(OBJEXT) \ @CppAD_ADOLC_TRUE@ mul_level_adolc_ode.$(OBJEXT) -am_general_OBJECTS = $(am__objects_1) abort_recording.$(OBJEXT) \ - fabs.$(OBJEXT) acos.$(OBJEXT) acosh.$(OBJEXT) \ - ad_assign.$(OBJEXT) ad_ctor.$(OBJEXT) add.$(OBJEXT) \ - add_eq.$(OBJEXT) ad_fun.$(OBJEXT) ad_in_c.$(OBJEXT) \ - ad_input.$(OBJEXT) ad_output.$(OBJEXT) asin.$(OBJEXT) \ - asinh.$(OBJEXT) atan2.$(OBJEXT) atan.$(OBJEXT) atanh.$(OBJEXT) \ - azmul.$(OBJEXT) base_require.$(OBJEXT) bender_quad.$(OBJEXT) \ +@CppAD_EIGEN_TRUE@am__objects_2 = eigen_det.$(OBJEXT) \ +@CppAD_EIGEN_TRUE@ eigen_array.$(OBJEXT) +am_general_OBJECTS = $(am__objects_1) $(am__objects_2) \ + abort_recording.$(OBJEXT) base2ad.$(OBJEXT) fabs.$(OBJEXT) \ + acos.$(OBJEXT) acosh.$(OBJEXT) ad_assign.$(OBJEXT) \ + ad_ctor.$(OBJEXT) add.$(OBJEXT) add_eq.$(OBJEXT) \ + ad_fun.$(OBJEXT) ad_in_c.$(OBJEXT) ad_input.$(OBJEXT) \ + ad_output.$(OBJEXT) asin.$(OBJEXT) asinh.$(OBJEXT) \ + atan2.$(OBJEXT) atan.$(OBJEXT) atanh.$(OBJEXT) azmul.$(OBJEXT) \ + base_require.$(OBJEXT) bender_quad.$(OBJEXT) \ bool_fun.$(OBJEXT) capacity_order.$(OBJEXT) \ change_param.$(OBJEXT) check_for_nan.$(OBJEXT) \ compare_change.$(OBJEXT) compare.$(OBJEXT) \ @@ -164,11 +155,11 @@ log.$(OBJEXT) lu_ratio.$(OBJEXT) lu_vec_ad.$(OBJEXT) \ lu_vec_ad_ok.$(OBJEXT) mul.$(OBJEXT) mul_eq.$(OBJEXT) \ mul_level.$(OBJEXT) mul_level_ode.$(OBJEXT) \ - near_equal_ext.$(OBJEXT) number_skip.$(OBJEXT) \ - numeric_type.$(OBJEXT) num_limits.$(OBJEXT) \ - ode_stiff.$(OBJEXT) ode_taylor.$(OBJEXT) opt_val_hes.$(OBJEXT) \ - par_var.$(OBJEXT) poly.$(OBJEXT) pow.$(OBJEXT) \ - pow_int.$(OBJEXT) print_for.$(OBJEXT) \ + near_equal_ext.$(OBJEXT) new_dynamic.$(OBJEXT) \ + number_skip.$(OBJEXT) numeric_type.$(OBJEXT) \ + num_limits.$(OBJEXT) ode_stiff.$(OBJEXT) taylor_ode.$(OBJEXT) \ + opt_val_hes.$(OBJEXT) con_dyn_var.$(OBJEXT) poly.$(OBJEXT) \ + pow.$(OBJEXT) pow_int.$(OBJEXT) print_for.$(OBJEXT) \ reverse_checkpoint.$(OBJEXT) reverse_one.$(OBJEXT) \ reverse_three.$(OBJEXT) reverse_two.$(OBJEXT) \ rev_one.$(OBJEXT) rev_two.$(OBJEXT) rosen_34.$(OBJEXT) \ @@ -181,8 +172,7 @@ general_OBJECTS = $(am_general_OBJECTS) general_LDADD = $(LDADD) am__DEPENDENCIES_1 = -general_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +general_DEPENDENCIES = $(am__DEPENDENCIES_1) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -199,10 +189,6 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) @@ -228,9 +214,8 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(libeigen_a_SOURCES) $(general_SOURCES) -DIST_SOURCES = $(am__libeigen_a_SOURCES_DIST) \ - $(am__general_SOURCES_DIST) +SOURCES = $(general_SOURCES) +DIST_SOURCES = $(am__general_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -282,19 +267,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -367,10 +351,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -389,9 +371,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -414,8 +398,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -438,54 +420,35 @@ @CppAD_ADOLC_FALSE@ADOLC_SRC_FILES = # ------------------------------------------------------------------------- @CppAD_ADOLC_TRUE@ADOLC_SRC_FILES = mul_level_adolc.cpp mul_level_adolc_ode.cpp -@CppAD_ADOLC_FALSE@ADOLC_EXTRA_FILES = mul_level_adolc.cpp mul_level_adolc_ode.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 = -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) -@CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@EIGEN_EXTRA_FILES = -@CppAD_HAVE_AR_FALSE@EIGEN_EXTRA_FILES = eigen_det.cpp eigen_array.cpp -@CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@noinst_LIBRARIES = libeigen.a -@CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@libeigen_a_SOURCES = eigen_det.cpp eigen_array.cpp -@CppAD_EIGEN_DIR_FALSE@@CppAD_HAVE_AR_TRUE@EIGEN_LIB = -@CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@EIGEN_LIB = -L. -leigen -@CppAD_HAVE_AR_FALSE@EIGEN_LIB = -@CppAD_EIGEN_DIR_FALSE@@CppAD_HAVE_AR_TRUE@EIGEN_FLAGS = -@CppAD_EIGEN_DIR_TRUE@@CppAD_HAVE_AR_TRUE@EIGEN_FLAGS = -@CppAD_HAVE_AR_FALSE@EIGEN_FLAGS = -@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@ -I$(EIGEN_DIR)/include - +@CppAD_EIGEN_FALSE@EIGEN_SRC_FILES = # ------------------------------------------------------------------------- -# autotools does not support use of colpack -EXTRA_DIST = \ - $(ADOLC_EXTRA_FILES) \ - $(EIGEN_EXTRA_FILES) - -@CppAD_MS_COMPILER_FALSE@AM_CXXFLAGS = -g $(ADOLC_FLAGS) $(EIGEN_FLAGS) $(CXX_FLAGS) +@CppAD_EIGEN_TRUE@EIGEN_SRC_FILES = eigen_det.cpp eigen_array.cpp +@CppAD_EIGEN_FALSE@EIGEN_FLAGS = +@CppAD_EIGEN_TRUE@EIGEN_FLAGS = # -@CppAD_MS_COMPILER_TRUE@AM_CXXFLAGS = -EHsc -g $(ADOLC_FLAGS) $(EIGEN_FLAGS) $(CXX_FLAGS) -# -AM_CPPFLAGS = \ - -I. \ - -I$(top_srcdir) \ +AM_CXXFLAGS = \ + $(ADOLC_FLAGS) \ + $(EIGEN_FLAGS) \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ $(ADOLC_FLAGS) \ $(EIGEN_FLAGS) # -LDADD = $(ADOLC_LIB) $(BTHREAD_LIB) $(EIGEN_LIB) $(PTHREAD_LIB) +LDADD = $(ADOLC_LIB) # general_SOURCES = \ $(ADOLC_SRC_FILES) \ + $(EIGEN_SRC_FILES) \ \ abort_recording.cpp \ + base2ad.cpp \ fabs.cpp \ acos.cpp \ acosh.cpp \ @@ -555,13 +518,14 @@ mul_level.cpp \ mul_level_ode.cpp \ near_equal_ext.cpp \ + new_dynamic.cpp \ number_skip.cpp \ numeric_type.cpp \ num_limits.cpp \ ode_stiff.cpp \ - ode_taylor.cpp \ + taylor_ode.cpp \ opt_val_hes.cpp \ - par_var.cpp \ + con_dyn_var.cpp \ poly.cpp \ pow.cpp \ pow_int.cpp \ @@ -625,14 +589,6 @@ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) - -libeigen.a: $(libeigen_a_OBJECTS) $(libeigen_a_DEPENDENCIES) $(EXTRA_libeigen_a_DEPENDENCIES) - $(AM_V_at)-rm -f libeigen.a - $(AM_V_AR)$(libeigen_a_AR) libeigen.a $(libeigen_a_OBJECTS) $(libeigen_a_LIBADD) - $(AM_V_at)$(RANLIB) libeigen.a - clean-checkPROGRAMS: -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) @@ -663,6 +619,7 @@ @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)/base2ad.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@ @@ -672,11 +629,14 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compare.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compare_change.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/complex_poly.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/con_dyn_var.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cond_exp.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@ @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)/eigen_array.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eigen_det.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/equal_op_seq.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@ @@ -703,8 +663,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jac_lu_det.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jac_minor_det.Po@am__quote@ @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)/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@ @@ -718,13 +676,12 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_level_adolc_ode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_level_ode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/near_equal_ext.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/new_dynamic.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_stiff.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode_taylor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/opt_val_hes.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/par_var.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poly.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pow_int.Po@am__quote@ @@ -748,6 +705,7 @@ @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)/taylor_ode.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@ @@ -770,34 +728,6 @@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` -libeigen_a-eigen_det.o: eigen_det.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -MT libeigen_a-eigen_det.o -MD -MP -MF $(DEPDIR)/libeigen_a-eigen_det.Tpo -c -o libeigen_a-eigen_det.o `test -f 'eigen_det.cpp' || echo '$(srcdir)/'`eigen_det.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeigen_a-eigen_det.Tpo $(DEPDIR)/libeigen_a-eigen_det.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='eigen_det.cpp' object='libeigen_a-eigen_det.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -c -o libeigen_a-eigen_det.o `test -f 'eigen_det.cpp' || echo '$(srcdir)/'`eigen_det.cpp - -libeigen_a-eigen_det.obj: eigen_det.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -MT libeigen_a-eigen_det.obj -MD -MP -MF $(DEPDIR)/libeigen_a-eigen_det.Tpo -c -o libeigen_a-eigen_det.obj `if test -f 'eigen_det.cpp'; then $(CYGPATH_W) 'eigen_det.cpp'; else $(CYGPATH_W) '$(srcdir)/eigen_det.cpp'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeigen_a-eigen_det.Tpo $(DEPDIR)/libeigen_a-eigen_det.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='eigen_det.cpp' object='libeigen_a-eigen_det.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -c -o libeigen_a-eigen_det.obj `if test -f 'eigen_det.cpp'; then $(CYGPATH_W) 'eigen_det.cpp'; else $(CYGPATH_W) '$(srcdir)/eigen_det.cpp'; fi` - -libeigen_a-eigen_array.o: eigen_array.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -MT libeigen_a-eigen_array.o -MD -MP -MF $(DEPDIR)/libeigen_a-eigen_array.Tpo -c -o libeigen_a-eigen_array.o `test -f 'eigen_array.cpp' || echo '$(srcdir)/'`eigen_array.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeigen_a-eigen_array.Tpo $(DEPDIR)/libeigen_a-eigen_array.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='eigen_array.cpp' object='libeigen_a-eigen_array.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -c -o libeigen_a-eigen_array.o `test -f 'eigen_array.cpp' || echo '$(srcdir)/'`eigen_array.cpp - -libeigen_a-eigen_array.obj: eigen_array.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -MT libeigen_a-eigen_array.obj -MD -MP -MF $(DEPDIR)/libeigen_a-eigen_array.Tpo -c -o libeigen_a-eigen_array.obj `if test -f 'eigen_array.cpp'; then $(CYGPATH_W) 'eigen_array.cpp'; else $(CYGPATH_W) '$(srcdir)/eigen_array.cpp'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeigen_a-eigen_array.Tpo $(DEPDIR)/libeigen_a-eigen_array.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='eigen_array.cpp' object='libeigen_a-eigen_array.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -c -o libeigen_a-eigen_array.obj `if test -f 'eigen_array.cpp'; then $(CYGPATH_W) 'eigen_array.cpp'; else $(CYGPATH_W) '$(srcdir)/eigen_array.cpp'; fi` - ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am @@ -883,7 +813,7 @@ check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) check: check-am -all-am: makefile $(LIBRARIES) +all-am: makefile installdirs: install: install-am install-exec: install-exec-am @@ -917,8 +847,7 @@ @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-checkPROGRAMS clean-generic clean-noinstLIBRARIES \ - mostlyclean-am +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) @@ -988,18 +917,17 @@ .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ - clean-checkPROGRAMS clean-generic clean-noinstLIBRARIES \ - cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am + clean-checkPROGRAMS clean-generic cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am .PRECIOUS: makefile diff -Nru cppad-2018.00.00.0/example/general/mul.cpp cppad-2019.02.00.0/example/general/mul.cpp --- cppad-2018.00.00.0/example/general/mul.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,21 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin mul.cpp$$ $section AD Binary Multiplication: Example and Test$$ -$mindex * multiply times$$ -$code $srcfile%example/general/mul.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -25,59 +23,59 @@ # include bool Mul(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - double x0 = .5; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // 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 - - // 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); - - // check value - ok &= NearEqual(y[0] , x0*(4.*3.*2.*1.)*x0, eps99 , eps99); - - // forward computation of partials 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], (4.*3.*2.*1.)*2.*x0, eps99 , eps99); - - // 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], (4.*3.*2.*1.)*2.*x0, eps99 , eps99); - - // use a VecAD::reference object with multiplication - CppAD::VecAD v(1); - AD zero(0); - v[zero] = c; - AD result = 4 * v[zero]; - ok &= (result == d); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = .5; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // 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 + + // 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); + + // check value + ok &= NearEqual(y[0] , x0*(4.*3.*2.*1.)*x0, eps99 , eps99); + + // forward computation of partials 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], (4.*3.*2.*1.)*2.*x0, eps99 , eps99); + + // 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], (4.*3.*2.*1.)*2.*x0, eps99 , eps99); + + // use a VecAD::reference object with multiplication + CppAD::VecAD v(1); + AD zero(0); + v[zero] = c; + AD result = 4 * v[zero]; + ok &= (result == d); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/mul_eq.cpp cppad-2019.02.00.0/example/general/mul_eq.cpp --- cppad-2018.00.00.0/example/general/mul_eq.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/mul_eq.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin mul_eq.cpp$$ $section AD Compound Assignment Multiplication: Example and Test$$ -$mindex *= multiply assign plus add$$ -$code $srcfile%example/general/mul_eq.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -27,60 +25,60 @@ # include bool MulEq(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - double x0 = .5; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // range space vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = x[0]; // initial value - y[0] *= 2; // AD *= int - y[0] *= 4.; // AD *= double - y[1] = y[0] *= x[0]; // use the result of a compound assignment - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // check value - ok &= NearEqual(y[0] , x0*2.*4.*x0, eps99, eps99); - ok &= NearEqual(y[1] , y[0], eps99, eps99); - - // forward computation of partials 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], 8.*2.*x0, eps99, eps99); - ok &= NearEqual(dy[1], 8.*2.*x0, eps99, eps99); - - // reverse computation of derivative of y[0] - CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); - w[0] = 1.; - w[1] = 0.; - dw = f.Reverse(1, w); - ok &= NearEqual(dw[0], 8.*2.*x0, eps99, eps99); - - // use a VecAD::reference object with computed multiplication - CppAD::VecAD v(1); - AD zero(0); - AD result = 1; - v[zero] = 2; - result *= v[zero]; - ok &= (result == 2); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = .5; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // range space vector + size_t m = 2; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = x[0]; // initial value + y[0] *= 2; // AD *= int + y[0] *= 4.; // AD *= double + y[1] = y[0] *= x[0]; // use the result of a compound assignment + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check value + ok &= NearEqual(y[0] , x0*2.*4.*x0, eps99, eps99); + ok &= NearEqual(y[1] , y[0], eps99, eps99); + + // forward computation of partials 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], 8.*2.*x0, eps99, eps99); + ok &= NearEqual(dy[1], 8.*2.*x0, eps99, eps99); + + // reverse computation of derivative of y[0] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + w[1] = 0.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], 8.*2.*x0, eps99, eps99); + + // use a VecAD::reference object with computed multiplication + CppAD::VecAD v(1); + AD zero(0); + AD result = 1; + v[zero] = 2; + result *= v[zero]; + ok &= (result == 2); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/mul_level_adolc.cpp cppad-2019.02.00.0/example/general/mul_level_adolc.cpp --- cppad-2018.00.00.0/example/general/mul_level_adolc.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/mul_level_adolc.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,20 +1,21 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin mul_level_adolc.cpp$$ $spell - CppAD - AdolcDir - adouble - Vec + CppAD + AdolcDir + adouble + Vec $$ $section Using Adolc with Multiple Levels of Taping: Example and Test$$ @@ -23,7 +24,7 @@ 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 $latex \[ - f(x) = \frac{1}{2} \left( x_0^2 + \cdots + x_{n-1}^2 \right) + f(x) = \frac{1}{2} \left( x_0^2 + \cdots + x_{n-1}^2 \right) \] $$ We then use Adolc's $code adouble$$ (level one taping) to compute the directional derivative @@ -39,7 +40,7 @@ The example $cref hes_times_dir.cpp$$ computes the same value more efficiently by using the identity: $latex \[ - \frac{d}{dx} \left[ f^{(1)} (x) * v \right] = f^{(2)} (x) * v + \frac{d}{dx} \left[ f^{(1)} (x) * v \right] = f^{(2)} (x) * v \] $$ The example $cref mul_level.cpp$$ computes the same values using $code AD< AD >$$ and $code AD$$. @@ -56,9 +57,7 @@ $cref cmake$$ command line. $head Source$$ -$code $srcfile%example/general/mul_level_adolc.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -78,94 +77,94 @@ # include namespace { - // f(x) = |x|^2 / 2 = .5 * ( x[0]^2 + ... + x[n-1]^2 ) - template - Type f(const CPPAD_TESTVECTOR(Type)& x) - { Type sum; - - sum = 0.; - size_t i = size_t(x.size()); - for(i = 0; i < size_t(x.size()); i++) - sum += x[i] * x[i]; + // f(x) = |x|^2 / 2 = .5 * ( x[0]^2 + ... + x[n-1]^2 ) + template + Type f(const CPPAD_TESTVECTOR(Type)& x) + { Type sum; + + sum = 0.; + size_t i = size_t(x.size()); + for(i = 0; i < size_t(x.size()); i++) + sum += x[i] * x[i]; - return .5 * sum; - } + return .5 * sum; + } } bool mul_level_adolc(void) -{ bool ok = true; // initialize test result - using CppAD::thread_alloc; // The CppAD memory allocator +{ bool ok = true; // initialize test result + using CppAD::thread_alloc; // The CppAD memory allocator - 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; - - // 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++) - a2x[j] = double(j); - // Declare the independent variable for taping f(x) - CppAD::Independent(a2x); - - // Use AD to tape the evaluation of f(x) - CPPAD_TESTVECTOR(a2type) a2y(1); - a2y[0] = f(a2x); - - // Declare a1f as the corresponding ADFun function f(x) - // (make sure we do not run zero order forward during constructor) - CppAD::ADFun a1f; - a1f.Dependent(a2x, a2y); - - // Value of the independent variables whitle taping f'(x) * v - int tag = 0; - int keep = 1; - trace_on(tag, keep); - for(j = 0; j < n; j++) - a1x[j] <<= double(j); - - // set the argument value x for computing f'(x) * v - a1f.Forward(0, a1x); - - // compute f'(x) * v - CPPAD_TESTVECTOR(a1type) a1v(n); - CPPAD_TESTVECTOR(a1type) a1df(1); - for(j = 0; j < n; j++) - a1v[j] = double(n - j); - a1df = a1f.Forward(1, a1v); - - // declare Adolc function corresponding to f'(x) * v - double df; - a1df[0] >>= df; - trace_off(); - - // compute the d/dx of f'(x) * v = f''(x) * v - size_t m = 1; // # dependent in f'(x) * v - - // w = new double[capacity] where capacity >= m - size_t 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 = a1v[j].value(); - ok &= CppAD::NearEqual(dw[j], vj, eps, eps); - } - - // make memory avaialble for other use by this thread - thread_alloc::delete_array(w); - thread_alloc::delete_array(dw); - return ok; + 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; + + // 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++) + a2x[j] = double(j); + // Declare the independent variable for taping f(x) + CppAD::Independent(a2x); + + // Use AD to tape the evaluation of f(x) + CPPAD_TESTVECTOR(a2type) a2y(1); + a2y[0] = f(a2x); + + // Declare a1f as the corresponding ADFun function f(x) + // (make sure we do not run zero order forward during constructor) + CppAD::ADFun a1f; + a1f.Dependent(a2x, a2y); + + // Value of the independent variables whitle taping f'(x) * v + short tag = 0; + int keep = 1; + trace_on(tag, keep); + for(j = 0; j < n; j++) + a1x[j] <<= double(j); + + // set the argument value x for computing f'(x) * v + a1f.Forward(0, a1x); + + // compute f'(x) * v + CPPAD_TESTVECTOR(a1type) a1v(n); + CPPAD_TESTVECTOR(a1type) a1df(1); + for(j = 0; j < n; j++) + a1v[j] = double(n - j); + a1df = a1f.Forward(1, a1v); + + // declare Adolc function corresponding to f'(x) * v + double df; + a1df[0] >>= df; + trace_off(); + + // compute the d/dx of f'(x) * v = f''(x) * v + size_t m = 1; // # dependent in f'(x) * v + + // w = new double[capacity] where capacity >= m + size_t 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 = a1v[j].value(); + ok &= CppAD::NearEqual(dw[j], vj, eps, eps); + } + + // make memory avaialble for other use by this thread + thread_alloc::delete_array(w); + thread_alloc::delete_array(dw); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/mul_level_adolc_ode.cpp cppad-2019.02.00.0/example/general/mul_level_adolc_ode.cpp --- cppad-2018.00.00.0/example/general/mul_level_adolc_ode.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/mul_level_adolc_ode.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,33 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin mul_level_adolc_ode.cpp$$ $spell - hpp - Taylor - Cpp - const - std - AdolcDir - adouble - Vec + hpp + Taylor + Cpp + const + std + AdolcDir + adouble + Vec $$ $section Taylor's Ode Solver: A Multi-Level Adolc Example and Test$$ +$head See Also$$ +$cref taylor_ode.cpp$$, $cref mul_level_ode.cpp$$ + $head Purpose$$ This is a realistic example using two levels of AD; see $cref mul_level$$. @@ -34,42 +38,22 @@ 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. -The example $cref mul_level_ode.cpp$$ computes the same values using -$code AD$$ and $code AD< AD >$$. -The example $cref ode_taylor.cpp$$ is a simpler applications -of Taylor's method for solving an ODE. + $head ODE$$ -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 +For this example the function +$latex y : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ is defined by +$latex y(0, x) = 0$$ and +$latex \partial_t y(t, x) = g(y, x)$$ where +$latex g : \B{R}^n \times \B{R}^n \rightarrow \B{R}^n$$ is defined by $latex \[ - 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) - \end{array} \right) -\] $$ -and the initial condition $latex y(0, x) = 0$$. -The value of $latex x$$ is fixed during the solution of the ODE -and the function $latex g : \B{R}^n \rightarrow \B{R}^n$$ is used to -define the ODE where -$latex \[ - g(y) = - \left( \begin{array}{c} - x_0 \\ - x_1 y_0 \\ - \vdots \\ - x_{n-1} y_{n-2} - \end{array} \right) + g(y, x) = + \left( \begin{array}{c} + x_0 \\ + x_1 y_0 \\ + \vdots \\ + x_{n-1} y_{n-2} + \end{array} \right) \] $$ $head ODE Solution$$ @@ -78,13 +62,13 @@ for the first row to solve the second and so on. Doing this we obtain $latex \[ - y(t, x ) = - \left( \begin{array}{c} - x_0 t \\ - x_1 x_0 t^2 / 2 \\ - \vdots \\ - x_{n-1} x_{n-2} \ldots x_0 t^n / n ! - \end{array} \right) + y(t, x ) = + \left( \begin{array}{c} + x_0 t \\ + x_1 x_0 t^2 / 2 \\ + \vdots \\ + x_{n-1} x_{n-2} \ldots x_0 t^n / n ! + \end{array} \right) \] $$ $head Derivative of ODE Solution$$ @@ -102,45 +86,12 @@ \] $$ $head Taylor's Method Using AD$$ -An $th m$$ order Taylor method for -approximating the solution of an -ordinary differential equations is -$latex \[ - 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^{(p)} (t , x ) \Delta t^p -\] $$ -where the Taylor coefficients $latex y^{(k)} (t, x)$$ are defined by -$latex \[ - y^{(k)} (t, x) = \partial_t^k y(t , x ) / k ! -\] $$ We define the function $latex z(t, x)$$ by the equation $latex \[ - z ( t , x ) = g[ y ( t , x ) ] = h [ x , y( t , x ) ] -\] $$ -It follows that -$latex \[ -\begin{array}{rcl} - \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) -\end{array} + z ( t , x ) = g[ y ( t , x ) ] = h [ x , y( t , x ) ] \] $$ -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 -$latex \[ - y^{(0)} (t , x) , \ldots , y^{(k)} ( t , x ) -\] $$ -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)$$. +see $cref taylor_ode$$ for the method used to compute the +Taylor coefficients w.r.t $latex t$$ of $latex y(t, x)$$. $head base_adolc.hpp$$ The file $cref base_adolc.hpp$$ is implements the @@ -162,9 +113,7 @@ $head Source$$ -$code $srcfile%example/general/mul_level_adolc_ode.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end -------------------------------------------------------------------------- @@ -192,177 +141,178 @@ // 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(a1type) a1x_; + // copy of a that is set by constructor and used by g(y) + CPPAD_TESTVECTOR(a1type) a1x_; public: - // constructor - Ode(const CPPAD_TESTVECTOR(a1type)& a1x) : a1x_(a1x) - { } - // the function g(y) is evaluated with two levels of taping - CPPAD_TESTVECTOR(a2type) operator() - ( const CPPAD_TESTVECTOR(a2type)& a2y) const - { size_t n = a2y.size(); - CPPAD_TESTVECTOR(a2type) a2g(n); - size_t i; - a2g[0] = a1x_[0]; - for(i = 1; i < n; i++) - a2g[i] = a1x_[i] * a2y[i-1]; + // constructor + Ode(const CPPAD_TESTVECTOR(a1type)& a1x) : a1x_(a1x) + { } + // the function g(y) is evaluated with two levels of taping + CPPAD_TESTVECTOR(a2type) operator() + ( const CPPAD_TESTVECTOR(a2type)& a2y) const + { size_t n = a2y.size(); + CPPAD_TESTVECTOR(a2type) a2g(n); + size_t i; + a2g[0] = a1x_[0]; + for(i = 1; i < n; i++) + a2g[i] = a1x_[i] * a2y[i-1]; - return a2g; - } + return a2g; + } }; // ------------------------------------------------------------------------- // Routine that uses Taylor's method to solve ordinary differential equaitons // 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 + 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; + // some temporary indices + size_t i, k, ell; - // number of variables in the ODE - size_t n = a1y_ini.size(); + // number of variables in the ODE + size_t n = a1y_ini.size(); - // copies of x and g(y) with two levels of taping - CPPAD_TESTVECTOR(a2type) a2y(n), Z(n); + // copies of x and g(y) with two levels of taping + CPPAD_TESTVECTOR(a2type) a2y(n), Z(n); - // y, y^{(k)} , z^{(k)}, and y^{(k+1)} - CPPAD_TESTVECTOR(a1type) a1y(n), a1y_k(n), a1z_k(n), a1y_kp(n); - - // initialize x - for(i = 0; i < n; 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 using a1type - for(i = 0; i < n; i++) - a2y[i] = a1y[i]; - CppAD::Independent(a2y); - - // evaluate ODE using a2type - Z = G(a2y); - - // define differentiable version of g: X -> Y - // that computes its derivatives using a1type - CppAD::ADFun a1g(a2y, Z); - - // Use Taylor's method to take a step - 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 - a1z_k = a1g.Forward(k, a1y_k); - - for(i = 0; i < n; i++) - { // convert to (k+1)-Taylor coefficient for x - a1y_kp[i] = a1z_k[i] / a1type(k + 1); - - // add term for to this Taylor coefficient - // to solution for y(t, x) - a1y[i] += a1y_kp[i] * dt_kp; - } - // next power of t - dt_kp *= a1dt; - // next Taylor coefficient - a1y_k = a1y_kp; - } - } - return a1y; + // y, y^{(k)} , z^{(k)}, and y^{(k+1)} + CPPAD_TESTVECTOR(a1type) a1y(n), a1y_k(n), a1z_k(n), a1y_kp(n); + + // initialize x + for(i = 0; i < n; 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 using a1type + for(i = 0; i < n; i++) + a2y[i] = a1y[i]; + CppAD::Independent(a2y); + + // evaluate ODE using a2type + Z = G(a2y); + + // define differentiable version of g: X -> Y + // that computes its derivatives using a1type + CppAD::ADFun a1g(a2y, Z); + + // Use Taylor's method to take a step + 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 + a1z_k = a1g.Forward(k, a1y_k); + + for(i = 0; i < n; i++) + { // convert to (k+1)-Taylor coefficient for x + a1y_kp[i] = a1z_k[i] / a1type(k + 1); + + // add term for to this Taylor coefficient + // to solution for y(t, x) + a1y[i] += a1y_kp[i] * dt_kp; + } + // next power of t + dt_kp *= a1dt; + // next Taylor coefficient + a1y_k = a1y_kp; + } + } + return a1y; } } // END empty namespace // ========================================================================== // Routine that tests algorithmic differentiation of solutions computed // by the routine taylor_ode. bool mul_level_adolc_ode(void) -{ bool ok = true; - double eps = 100. * std::numeric_limits::epsilon(); +{ bool ok = true; + double eps = 100. * std::numeric_limits::epsilon(); - // number of components in differential equation - size_t n = 4; + // number of components in differential equation + size_t n = 4; - // some temporary indices - size_t i, j; + // some temporary indices + size_t i, j; - // set up for thread_alloc memory allocator - using CppAD::thread_alloc; // the allocator - size_t capacity; // capacity of an allocation - - // the vector x with length n (or greater) in double - double* x = thread_alloc::create_array(n, capacity); - - // the vector x with length n in a1type - CPPAD_TESTVECTOR(a1type) a1x(n); - for(i = 0; i < n; i++) - 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++) - a1x[i] <<= double(i + 1); // a1x is independent for adouble type - - // 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 - a1type a1dt = 1.; // Delta t for each step - // value of y(t, x) at the initial time - CPPAD_TESTVECTOR(a1type) a1y_ini(n); - for(i = 0; i < n; i++) - a1y_ini[i] = 0.; - - // integrate the differential equation - CPPAD_TESTVECTOR(a1type) a1y_final(n); - a1y_final = taylor_ode_adolc(G, order, nstep, a1dt, a1y_ini); - - // declare the differentiable fucntion f : x -> y_final - // (corresponding to the tape of adouble operations) - double* y_final = thread_alloc::create_array(n, capacity); - for(i = 0; i < n; i++) - a1y_final[i] >>= y_final[i]; - trace_off(); - - // check function values - double check = 1.; - 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, eps, eps); - } - - // memory where Jacobian will be returned - 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 - 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, eps, eps); - } - } - - // make memroy avaiable for other use by this thread - thread_alloc::delete_array(x); - thread_alloc::delete_array(y_final); - thread_alloc::delete_array(jac_); - thread_alloc::delete_array(jac); - return ok; + // set up for thread_alloc memory allocator + using CppAD::thread_alloc; // the allocator + size_t capacity; // capacity of an allocation + + // the vector x with length n (or greater) in double + double* x = thread_alloc::create_array(n, capacity); + + // the vector x with length n in a1type + CPPAD_TESTVECTOR(a1type) a1x(n); + for(i = 0; i < n; i++) + a1x[i] = x[i] = double(i + 1); + + // declare the parameters as the independent variable + short tag = 0; // Adolc setup + int keep = 1; + trace_on(tag, keep); + for(i = 0; i < n; i++) + a1x[i] <<= double(i + 1); // a1x is independent for adouble type + + // 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 + a1type a1dt = 1.; // Delta t for each step + // value of y(t, x) at the initial time + CPPAD_TESTVECTOR(a1type) a1y_ini(n); + for(i = 0; i < n; i++) + a1y_ini[i] = 0.; + + // integrate the differential equation + CPPAD_TESTVECTOR(a1type) a1y_final(n); + a1y_final = taylor_ode_adolc(G, order, nstep, a1dt, a1y_ini); + + // declare the differentiable fucntion f : x -> y_final + // (corresponding to the tape of adouble operations) + double* y_final = thread_alloc::create_array(n, capacity); + for(i = 0; i < n; i++) + a1y_final[i] >>= y_final[i]; + trace_off(); + + // check function values + double check = 1.; + 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, eps, eps); + } + + // memory where Jacobian will be returned + 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 + 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, eps, eps); + } + } + + // make memroy avaiable for other use by this thread + thread_alloc::delete_array(x); + thread_alloc::delete_array(y_final); + thread_alloc::delete_array(jac_); + thread_alloc::delete_array(jac); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/mul_level.cpp cppad-2019.02.00.0/example/general/mul_level.cpp --- cppad-2018.00.00.0/example/general/mul_level.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/mul_level.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,22 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin mul_level.cpp$$ $spell - Adolc - adouble - CppAD - abs + Adolc + adouble + CppAD + abs $$ $section Multiple Level of AD: Example and Test$$ @@ -24,7 +25,7 @@ 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 $latex \[ - f(x) = \frac{1}{2} \left( x_0^2 + \cdots + x_{n-1}^2 \right) + f(x) = \frac{1}{2} \left( x_0^2 + \cdots + x_{n-1}^2 \right) \] $$ We then use $code AD$$ (level one taping) to compute the directional derivative @@ -40,16 +41,14 @@ The example $cref hes_times_dir.cpp$$ computes the same value more efficiently by using the identity: $latex \[ - \frac{d}{dx} \left[ f^{(1)} (x) * v \right] = f^{(2)} (x) * v + \frac{d}{dx} \left[ f^{(1)} (x) * v \right] = f^{(2)} (x) * v \] $$ 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 $srcfile%example/general/mul_level.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -58,80 +57,80 @@ # include namespace { - // f(x) = |x|^2 / 2 = .5 * ( x[0]^2 + ... + x[n-1]^2 ) - template - Type f(const CPPAD_TESTVECTOR(Type)& x) - { Type sum; - - sum = 0.; - size_t i = size_t(x.size()); - for(i = 0; i < size_t(x.size()); i++) - sum += x[i] * x[i]; + // f(x) = |x|^2 / 2 = .5 * ( x[0]^2 + ... + x[n-1]^2 ) + template + Type f(const CPPAD_TESTVECTOR(Type)& x) + { Type sum; + + sum = 0.; + size_t i = size_t(x.size()); + for(i = 0; i < size_t(x.size()); i++) + sum += x[i] * x[i]; - return .5 * sum; - } + return .5 * sum; + } } bool mul_level(void) -{ bool ok = true; // initialize test result +{ bool ok = true; // initialize test result - 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++) - a2x[j] = a1x[j] = x[j] = double(j); - // Declare the independent variable for taping f(x) - CppAD::Independent(a2x); - - // Use AD< AD > to tape the evaluation of f(x) - a2y[0] = f(a2x); - - // Declare a1f as the corresponding ADFun< AD > - // (make sure we do not run zero order forward during constructor) - 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 - // (Note we did not have to tape the creationg of a1f.) - CppAD::Independent(a1x); - - // set the argument value x for computing f'(x) * v - a1f.Forward(0, a1x); - // compute f'(x) * v - for(j = 0; j < n; j++) - a1v[j] = double(n - j); - a1dy = a1f.Forward(1, a1v); - - // 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 - g.optimize(); - - // Evaluate f'(x) * v - 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 = g.Reverse(1, w); + 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++) + a2x[j] = a1x[j] = x[j] = double(j); + // Declare the independent variable for taping f(x) + CppAD::Independent(a2x); + + // Use AD< AD > to tape the evaluation of f(x) + a2y[0] = f(a2x); + + // Declare a1f as the corresponding ADFun< AD > + // (make sure we do not run zero order forward during constructor) + 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 + // (Note we did not have to tape the creationg of a1f.) + CppAD::Independent(a1x); + + // set the argument value x for computing f'(x) * v + a1f.Forward(0, a1x); + // compute f'(x) * v + for(j = 0; j < n; j++) + a1v[j] = double(n - j); + a1dy = a1f.Forward(1, a1v); + + // 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 + g.optimize(); + + // Evaluate f'(x) * v + 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 = g.Reverse(1, w); - for(j = 0; j < n; j++) - ok &= CppAD::NearEqual(dw[j], a1v[j], eps, eps); + for(j = 0; j < n; j++) + ok &= CppAD::NearEqual(dw[j], a1v[j], eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/mul_level_ode.cpp cppad-2019.02.00.0/example/general/mul_level_ode.cpp --- cppad-2018.00.00.0/example/general/mul_level_ode.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/mul_level_ode.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,31 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin mul_level_ode.cpp$$ $spell - Taylor - Cpp - const - std - Adolc - adouble + Taylor + Cpp + const + std + Adolc + adouble $$ $section Taylor's Ode Solver: A Multi-Level AD Example and Test$$ +$head See Also$$ +$cref taylor_ode.cpp$$, $cref base2ad.cpp$$, $cref mul_level_adolc_ode.cpp$$ + $head Purpose$$ This is a realistic example using two levels of AD; see $cref mul_level$$. @@ -32,42 +36,21 @@ 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. -The example $cref mul_level_adolc_ode.cpp$$ computes the same values using -Adolc's type $code adouble$$ and CppAD's type $code AD$$. -The example $cref ode_taylor.cpp$$ is a simpler applications -of Taylor's method for solving an ODE. $head ODE$$ -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) ] = - \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) - \end{array} \right) -\] $$ -and the initial condition $latex y(0, x) = 0$$. -The value of $latex x$$ is fixed during the solution of the ODE -and the function $latex g : \B{R}^n \rightarrow \B{R}^n$$ is used to -define the ODE where +For this example the function +$latex y : \B{R} \times \B{R}^n \rightarrow \B{R}^n$$ is defined by +$latex y(0, x) = 0$$ and +$latex \partial_t y(t, x) = g(y, x)$$ where +$latex g : \B{R}^n \times \B{R}^n \rightarrow \B{R}^n$$ is defined by $latex \[ - g(y) = - \left( \begin{array}{c} - x_0 \\ - x_1 y_0 \\ - \vdots \\ - x_{n-1} y_{n-2} - \end{array} \right) + g(y, x) = + \left( \begin{array}{c} + x_0 \\ + x_1 y_0 \\ + \vdots \\ + x_{n-1} y_{n-2} + \end{array} \right) \] $$ $head ODE Solution$$ @@ -76,13 +59,13 @@ for the first row to solve the second and so on. Doing this we obtain $latex \[ - y(t, x ) = - \left( \begin{array}{c} - x_0 t \\ - x_1 x_0 t^2 / 2 \\ - \vdots \\ - x_{n-1} x_{n-2} \ldots x_0 t^n / n ! - \end{array} \right) + y(t, x ) = + \left( \begin{array}{c} + x_0 t \\ + x_1 x_0 t^2 / 2 \\ + \vdots \\ + x_{n-1} x_{n-2} \ldots x_0 t^n / n ! + \end{array} \right) \] $$ $head Derivative of ODE Solution$$ @@ -100,50 +83,15 @@ \] $$ $head Taylor's Method Using AD$$ -An $th m$$ order Taylor method for -approximating the solution of an -ordinary differential equations is -$latex \[ - 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^{(p)} (t , x ) \Delta t^p -\] $$ -where the Taylor coefficients $latex y^{(k)} (t, x)$$ are defined by -$latex \[ - y^{(k)} (t, x) = \partial_t^k y(t , x ) / k ! -\] $$ We define the function $latex z(t, x)$$ by the equation $latex \[ - z ( t , x ) = g[ y ( t , x ) ] = h [ x , y( t , x ) ] + z ( t , x ) = g[ y ( t , x ) ] = h [ x , y( t , x ) ] \] $$ -It follows that -$latex \[ -\begin{array}{rcl} - \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) -\end{array} -\] $$ -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 -$latex \[ - y^{(0)} (t , x) , \ldots , y^{(k)} ( t , x ) -\] $$ -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)$$. +see $cref taylor_ode$$ for the method used to compute the +Taylor coefficients w.r.t $latex t$$ of $latex y(t, x)$$. $head Source$$ -$code $srcfile%example/general/mul_level_ode.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end -------------------------------------------------------------------------- @@ -155,162 +103,168 @@ // ========================================================================= // define types for each level namespace { // BEGIN empty namespace -typedef CppAD::AD a1type; -typedef CppAD::AD a2type; + +typedef CppAD::AD a1double; +typedef CppAD::AD a2double; + +typedef CPPAD_TESTVECTOR(double) d_vector; +typedef CPPAD_TESTVECTOR(a1double) a1vector; +typedef CPPAD_TESTVECTOR(a2double) a2vector; // ------------------------------------------------------------------------- // 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(a1type) a1x_; + // copy of a that is set by constructor and used by g(y) + a1vector a1x_; public: - // constructor - Ode(const CPPAD_TESTVECTOR(a1type)& a1x) : a1x_(a1x) - { } - // the function g(y) is evaluated with two levels of taping - CPPAD_TESTVECTOR(a2type) operator() - ( const CPPAD_TESTVECTOR(a2type)& a2y) const - { size_t n = a2y.size(); - CPPAD_TESTVECTOR(a2type) a2g(n); - size_t i; - a2g[0] = a1x_[0]; - for(i = 1; i < n; i++) - a2g[i] = a1x_[i] * a2y[i-1]; + // constructor + Ode(const a1vector& a1x) : a1x_(a1x) + { } + // the function g(y) is evaluated with two levels of taping + a2vector operator() + ( const a2vector& a2y) const + { size_t n = a2y.size(); + a2vector a2g(n); + size_t i; + a2g[0] = a1x_[0]; + for(i = 1; i < n; i++) + a2g[i] = a1x_[i] * a2y[i-1]; - return a2g; - } + return a2g; + } }; // ------------------------------------------------------------------------- // Routine that uses Taylor's method to solve ordinary differential equaitons // 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 +a1vector 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 a1double& a1dt , // Delta t for each step + const a1vector& a1y_ini) // y(t) at the initial time { - // some temporary indices - size_t i, k, ell; + // some temporary indices + size_t i, k, ell; - // number of variables in the ODE - size_t n = a1y_ini.size(); + // number of variables in the ODE + size_t n = a1y_ini.size(); - // copies of x and g(y) with two levels of taping - CPPAD_TESTVECTOR(a2type) a2y(n), a2z(n); + // copies of x and g(y) with two levels of taping + a2vector a2y(n), a2z(n); - // y, y^{(k)} , z^{(k)}, and y^{(k+1)} - CPPAD_TESTVECTOR(a1type) a1y(n), a1y_k(n), a1z_k(n), a1y_kp(n); - - // initialize x - for(i = 0; i < n; 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 using a1type - for(i = 0; i < n; i++) - a2y[i] = a1y[i]; - CppAD::Independent(a2y); - - // evaluate ODE in a2type - a2z = G(a2y); - - // 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 - 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 - a1z_k = a1g.Forward(k, a1y_k); - - for(i = 0; i < n; i++) - { // convert to (k+1)-Taylor coefficient for x - a1y_kp[i] = a1z_k[i] / a1type(k + 1); - - // add term for to this Taylor coefficient - // to solution for y(t, x) - a1y[i] += a1y_kp[i] * a1dt_kp; - } - // next power of t - a1dt_kp *= a1dt; - // next Taylor coefficient - a1y_k = a1y_kp; - } - } - return a1y; + // y, y^{(k)} , z^{(k)}, and y^{(k+1)} + a1vector a1y(n), a1y_k(n), a1z_k(n), a1y_kp(n); + + // initialize x + for(i = 0; i < n; 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 using a1double + for(i = 0; i < n; i++) + a2y[i] = a1y[i]; + CppAD::Independent(a2y); + + // evaluate ODE in a2double + a2z = G(a2y); + + // define differentiable version of a1g: y -> z + // that computes its derivatives using a1double objects + CppAD::ADFun a1g(a2y, a2z); + + // Use Taylor's method to take a step + a1y_k = a1y; // initialize y^{(k)} + a1double a1dt_kp = a1dt; // initialize dt^(k+1) + for(k = 0; k <= order; k++) + { // evaluate k-th order Taylor coefficient of y + a1z_k = a1g.Forward(k, a1y_k); + + for(i = 0; i < n; i++) + { // convert to (k+1)-Taylor coefficient for x + a1y_kp[i] = a1z_k[i] / a1double(k + 1); + + // add term for to this Taylor coefficient + // to solution for y(t, x) + a1y[i] += a1y_kp[i] * a1dt_kp; + } + // next power of t + a1dt_kp *= a1dt; + // next Taylor coefficient + a1y_k = a1y_kp; + } + } + return a1y; } } // END empty namespace // ========================================================================== // Routine that tests alogirhtmic differentiation of solutions computed // by the routine taylor_ode. bool mul_level_ode(void) -{ bool ok = true; - double eps = 100. * std::numeric_limits::epsilon(); +{ bool ok = true; + double eps = 100. * std::numeric_limits::epsilon(); - // number of components in differential equation - size_t n = 4; + // number of components in differential equation + size_t n = 4; - // some temporary indices - size_t i, j; + // some temporary indices + size_t i, j; - // parameter vector in both double and a1type - CPPAD_TESTVECTOR(double) x(n); - CPPAD_TESTVECTOR(a1type) a1x(n); - for(i = 0; i < n; i++) - a1x[i] = x[i] = double(i + 1); - - // declare the parameters as the independent variable - CppAD::Independent(a1x); - - // 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 - a1type a1dt = double(1.); // Delta t for each step - // value of y(t, x) at the initial time - CPPAD_TESTVECTOR(a1type) a1y_ini(n); - for(i = 0; i < n; i++) - a1y_ini[i] = 0.; - - // integrate the differential equation - CPPAD_TESTVECTOR(a1type) a1y_final(n); - a1y_final = taylor_ode(G, order, nstep, a1dt, a1y_ini); - - // define differentiable fucntion object f : x -> y_final - // that computes its derivatives in double - CppAD::ADFun f(a1x, a1y_final); - - // check function values - double check = 1.; - double t = double(nstep) * Value(a1dt); - for(i = 0; i < n; i++) - { check *= x[i] * t / double(i + 1); - ok &= CppAD::NearEqual(Value(a1y_final[i]), check, eps, eps); - } - - // evaluate the Jacobian of h at a - CPPAD_TESTVECTOR(double) jac ( f.Jacobian(x) ); - // There appears to be a bug in g++ version 4.4.2 because it generates - // a warning for the equivalent form - // CPPAD_TESTVECTOR(double) jac = f.Jacobian(x); - - // check Jacobian - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - { double jac_ij = jac[i * n + j]; - if( i < j ) - check = 0.; - else check = Value( a1y_final[i] ) / x[j]; - ok &= CppAD::NearEqual(jac_ij, check, eps, eps); - } - } - return ok; + // parameter vector in both double and a1double + d_vector x(n); + a1vector a1x(n); + for(i = 0; i < n; i++) + a1x[i] = x[i] = double(i + 1); + + // declare the parameters as the independent variable + CppAD::Independent(a1x); + + // 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 + a1double a1dt = double(1.); // Delta t for each step + // value of y(t, x) at the initial time + a1vector a1y_ini(n); + for(i = 0; i < n; i++) + a1y_ini[i] = 0.; + + // integrate the differential equation + a1vector a1y_final(n); + a1y_final = taylor_ode(G, order, nstep, a1dt, a1y_ini); + + // define differentiable fucntion object f : x -> y_final + // that computes its derivatives in double + CppAD::ADFun f(a1x, a1y_final); + + // check function values + double check = 1.; + double t = double(nstep) * Value(a1dt); + for(i = 0; i < n; i++) + { check *= x[i] * t / double(i + 1); + ok &= CppAD::NearEqual(Value(a1y_final[i]), check, eps, eps); + } + + // evaluate the Jacobian of h at a + d_vector jac ( f.Jacobian(x) ); + // There appears to be a bug in g++ version 4.4.2 because it generates + // a warning for the equivalent form + // d_vector jac = f.Jacobian(x); + + // check Jacobian + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { double jac_ij = jac[i * n + j]; + if( i < j ) + check = 0.; + else + check = Value( a1y_final[i] ) / x[j]; + ok &= CppAD::NearEqual(jac_ij, check, eps, eps); + } + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/near_equal_ext.cpp cppad-2019.02.00.0/example/general/near_equal_ext.cpp --- cppad-2018.00.00.0/example/general/near_equal_ext.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/near_equal_ext.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin near_equal_ext.cpp$$ $spell - cpp - abs -o Microsoft + cpp + abs +o Microsoft $$ $section Compare AD with Base Objects: Example and Test$$ -$mindex NearEqualExt$$ -$code $srcfile%example/general/near_equal_ext.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -32,40 +30,40 @@ # include bool NearEqualExt(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - - // double - double x = 1.00000; - double y = 1.00001; - double a = .00005; - double r = .00005; - double zero = 0.; - - // AD - AD ax(x); - AD ay(y); - - ok &= NearEqual(ax, ay, zero, a); - ok &= NearEqual(ax, y, r, zero); - ok &= NearEqual(x, ay, r, a); - - // std::complex - AD cx(x); - AD cy(y); - - // AD< std::complex > - AD acx(x); - AD acy(y); - - ok &= NearEqual(acx, acy, zero, a); - ok &= NearEqual(acx, cy, r, zero); - ok &= NearEqual(acx, y, r, a); - ok &= NearEqual( cx, acy, r, a); - ok &= NearEqual( x, acy, r, a); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + + // double + double x = 1.00000; + double y = 1.00001; + double a = .00005; + double r = .00005; + double zero = 0.; + + // AD + AD ax(x); + AD ay(y); + + ok &= NearEqual(ax, ay, zero, a); + ok &= NearEqual(ax, y, r, zero); + ok &= NearEqual(x, ay, r, a); + + // std::complex + AD cx(x); + AD cy(y); + + // AD< std::complex > + AD acx(x); + AD acy(y); + + ok &= NearEqual(acx, acy, zero, a); + ok &= NearEqual(acx, cy, r, zero); + ok &= NearEqual(acx, y, r, a); + ok &= NearEqual( cx, acy, r, a); + ok &= NearEqual( x, acy, r, a); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/new_dynamic.cpp cppad-2019.02.00.0/example/general/new_dynamic.cpp --- cppad-2018.00.00.0/example/general/new_dynamic.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/general/new_dynamic.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,120 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin new_dynamic.cpp$$ +$spell + Cpp +$$ + +$section Dynamic Parameters: Example and Test$$ + +$srcfile%example/general/new_dynamic.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ +# include +# include + +bool new_dynamic(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); + + // independent dynamic parameter vector + size_t nd = 3; + CPPAD_TESTVECTOR(AD) adynamic(nd); + adynamic[0] = 1.0; + adynamic[1] = 1.0; + adynamic[2] = 1.0; + + // domain space vector + size_t nx = 2; + CPPAD_TESTVECTOR(AD) ax(nx); + ax[0] = 0.; + ax[1] = 1.; + + // declare independent variables, dynamic parammeters, starting recording + size_t abort_op_index = 0; + bool record_compare = true; + CppAD::Independent(ax, abort_op_index, record_compare, adynamic); + + // create a dependent dynamic parameter + AD adependent_dyn = adynamic[0] + 2.0; + + // check that elements of adynamic are currently dynamic parameters + for(size_t j = 0; j < nd; ++j) + ok &= Dynamic( adynamic[j] ); + ok &= Dynamic( adependent_dyn ); + + // range space vector + size_t ny = 1; + CPPAD_TESTVECTOR(AD) ay(ny); + ay[0] = adependent_dyn + ax[0]; + ay[0] *= adynamic[1] + ax[0]; + ay[0] *= adynamic[2] + ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // check the number of independent dynamic parameters in f + ok &= f.size_dyn_ind() == nd; + + // total number of dynamic parameters in f + ok &= f.size_dyn_par() == nd + 1; + + // check that these are no longer dynamic parameters + for(size_t j = 0; j < nd; ++j) + ok &= ! Dynamic( adynamic[j] ); + ok &= ! Dynamic( adependent_dyn ); + + // zero order forward mode + CPPAD_TESTVECTOR(double) x(nx), y(ny); + x[0] = 3.; + x[1] = 4.; + y = f.Forward(0, x); + ok &= f.size_order() == 1; + double check; + check = Value( adynamic[0] ) + 2.0 + x[0]; + check *= Value( adynamic[1] ) + x[0]; + check *= Value( adynamic[2] ) + x[1]; + ok &= NearEqual(y[0] , check, eps, eps); + + // change the dynamic parameter values + CPPAD_TESTVECTOR(double) dynamic(nd); + dynamic[0] = 2.0; + dynamic[1] = 3.0; + dynamic[2] = 4.0; + f.new_dynamic(dynamic); + ok &= f.size_order() == 0; + // + y = f.Forward(0, x); + ok &= f.size_order() == 1; + check = dynamic[0] + 2.0 + x[0]; + check *= dynamic[1] + x[0]; + check *= dynamic[2] + x[1]; + ok &= NearEqual(y[0] , check, eps, eps); + + // use first order foward mode to compute partial of f w.r.t x[0] + CPPAD_TESTVECTOR(double) dx(nx), dy(ny); + dx[0] = 1.0; + dx[1] = 0.0; + dy = f.Forward(1, dx); + ok &= f.size_order() == 2; + check = (dynamic[2] + x[1])*(dynamic[0] + 2.0 + x[0] + dynamic[1] + x[0]); + ok &= NearEqual(dy[0] , check, eps, eps); + // + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/example/general/number_skip.cpp cppad-2019.02.00.0/example/general/number_skip.cpp --- cppad-2018.00.00.0/example/general/number_skip.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/general/number_skip.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,82 +1,80 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin number_skip.cpp$$ $spell - Taylor + Taylor $$ $section Number of Variables That Can be Skipped: Example and Test$$ -$mindex number_skip optimize conditional expression condition$$ -$code $srcfile%example/general/number_skip.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include bool number_skip(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // independent variable vector - CppAD::vector< AD > ax(2); - 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) ] - 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]); - - // before call to optimize - ok &= f.number_skip() == 0; - size_t n_var = f.size_var(); - - // now optimize the operation sequence - f.optimize(); - - // after optimize, check forward mode result - x[0] = 4.; - x[1] = 3.; - y = f.Forward(0, x); - 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; + // independent variable vector + CppAD::vector< AD > ax(2); + 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) ] + 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]); + + // before call to optimize + ok &= f.number_skip() == 0; + size_t n_var = f.size_var(); + + // now optimize the operation sequence + f.optimize(); + + // after optimize, check forward mode result + x[0] = 4.; + x[1] = 3.; + y = f.Forward(0, x); + 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/numeric_type.cpp cppad-2019.02.00.0/example/general/numeric_type.cpp --- cppad-2018.00.00.0/example/general/numeric_type.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/numeric_type.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,21 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin numeric_type.cpp$$ $section The NumericType: Example and Test$$ -$mindex NumericType$$ -$code $srcfile%example/general/numeric_type.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -27,89 +25,89 @@ namespace { // Empty namespace - // ------------------------------------------------------------------- - class MyType { - private: - double d; - public: - // constructor from void - MyType(void) : d(0.) - { } - // constructor from an int - MyType(int d_) : d(d_) - { } - // copy constructor - MyType(const MyType &x) - { d = x.d; } - // assignment operator - void operator = (const MyType &x) - { d = x.d; } - // member function that converts to double - double Double(void) const - { return d; } - // unary plus - MyType operator + (void) const - { MyType x; - x.d = d; - return x; - } - // unary plus - MyType operator - (void) const - { MyType x; - x.d = - d; - return x; - } - // binary addition - MyType operator + (const MyType &x) const - { MyType y; - y.d = d + x.d ; - return y; - } - // binary subtraction - MyType operator - (const MyType &x) const - { MyType y; - y.d = d - x.d ; - return y; - } - // binary multiplication - MyType operator * (const MyType &x) const - { MyType y; - y.d = d * x.d ; - return y; - } - // binary division - MyType operator / (const MyType &x) const - { MyType y; - y.d = d / x.d ; - return y; - } - // compound assignment addition - void operator += (const MyType &x) - { d += x.d; } - // compound assignment subtraction - void operator -= (const MyType &x) - { d -= x.d; } - // compound assignment multiplication - void operator *= (const MyType &x) - { d *= x.d; } - // compound assignment division - void operator /= (const MyType &x) - { d /= x.d; } - }; + // ------------------------------------------------------------------- + class MyType { + private: + double d; + public: + // constructor from void + MyType(void) : d(0.) + { } + // constructor from an int + MyType(int d_) : d(d_) + { } + // copy constructor + MyType(const MyType &x) + { d = x.d; } + // assignment operator + void operator = (const MyType &x) + { d = x.d; } + // member function that converts to double + double Double(void) const + { return d; } + // unary plus + MyType operator + (void) const + { MyType x; + x.d = d; + return x; + } + // unary plus + MyType operator - (void) const + { MyType x; + x.d = - d; + return x; + } + // binary addition + MyType operator + (const MyType &x) const + { MyType y; + y.d = d + x.d ; + return y; + } + // binary subtraction + MyType operator - (const MyType &x) const + { MyType y; + y.d = d - x.d ; + return y; + } + // binary multiplication + MyType operator * (const MyType &x) const + { MyType y; + y.d = d * x.d ; + return y; + } + // binary division + MyType operator / (const MyType &x) const + { MyType y; + y.d = d / x.d ; + return y; + } + // compound assignment addition + void operator += (const MyType &x) + { d += x.d; } + // compound assignment subtraction + void operator -= (const MyType &x) + { d -= x.d; } + // compound assignment multiplication + void operator *= (const MyType &x) + { d *= x.d; } + // compound assignment division + void operator /= (const MyType &x) + { d /= x.d; } + }; } bool NumericType(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::CheckNumericType; - - CheckNumericType (); - - CheckNumericType (); - CheckNumericType (); - CheckNumericType< AD > (); - CheckNumericType< AD< AD > >(); +{ bool ok = true; + using CppAD::AD; + using CppAD::CheckNumericType; + + CheckNumericType (); + + CheckNumericType (); + CheckNumericType (); + CheckNumericType< AD > (); + CheckNumericType< AD< AD > >(); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/num_limits.cpp cppad-2019.02.00.0/example/general/num_limits.cpp --- cppad-2018.00.00.0/example/general/num_limits.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/general/num_limits.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin num_limits.cpp$$ @@ -16,9 +17,7 @@ $section Numeric Limits: Example and Test$$ -$code $srcfile%example/general/num_limits.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -27,8 +26,8 @@ # 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 +// 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 @@ -37,73 +36,73 @@ # 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 &= fabs(match / min - 1.0) > 3.0 * eps; - // - match = (min * 100.) / 100.; - ok &= fabs(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 &= fabs(match / max - 1.0) > 3.0 * eps; - // - match = (max / 100.) * 100.; - ok &= fabs(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 check_digits10(void) - { bool ok = true; - Float neg_log_eps = - - log10( CppAD::numeric_limits::epsilon() ); - int ceil_neg_log_eps = - Integer( neg_log_eps ); - ok &= ceil_neg_log_eps == CppAD::numeric_limits::digits10; - return ok; - } + 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 &= fabs(match / min - 1.0) > 3.0 * eps; + // + match = (min * 100.) / 100.; + ok &= fabs(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 &= fabs(match / max - 1.0) > 3.0 * eps; + // + match = (max / 100.) * 100.; + ok &= fabs(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 check_digits10(void) + { bool ok = true; + Float neg_log_eps = + - log10( CppAD::numeric_limits::epsilon() ); + int ceil_neg_log_eps = + Integer( neg_log_eps ); + ok &= ceil_neg_log_eps == CppAD::numeric_limits::digits10; + return ok; + } } bool num_limits(void) -{ bool ok = true; +{ bool ok = true; - ok &= check_epsilon(); - ok &= check_min(); - ok &= check_max(); - ok &= check_nan(); - ok &= check_digits10(); + ok &= check_epsilon(); + ok &= check_min(); + ok &= check_max(); + ok &= check_nan(); + ok &= check_digits10(); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/ode_stiff.cpp cppad-2019.02.00.0/example/general/ode_stiff.cpp --- cppad-2018.00.00.0/example/general/ode_stiff.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/general/ode_stiff.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,32 +1,32 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ode_stiff.cpp$$ $spell - Rosen + Rosen $$ $section A Stiff Ode: Example and Test$$ -$mindex ode$$ Define $latex x : \B{R} \rightarrow \B{R}^2$$ by $latex \[ \begin{array}{rcl} - x_0 (0) & = & 1 \\ - x_1 (0) & = & 0 \\ - x_0^\prime (t) & = & - a_0 x_0 (t) \\ - x_1^\prime (t) & = & + a_0 x_0 (t) - a_1 x_1 (t) + x_0 (0) & = & 1 \\ + x_1 (0) & = & 0 \\ + 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 @@ -39,9 +39,7 @@ \] $$ The example tests Rosen34 using the relations above: -$code $srcfile%example/general/ode_stiff.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -53,152 +51,152 @@ # define CPPAD_ODE_STIFF_PRINT 0 namespace { - // -------------------------------------------------------------- - class Fun { - private: - CPPAD_TESTVECTOR(double) a; - public: - // constructor - Fun(const CPPAD_TESTVECTOR(double)& a_) : a(a_) - { } - // compute f(t, x) - void Ode( - 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]; - } - // compute partial of f(t, x) w.r.t. t - void Ode_ind( - 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 - void Ode_dep( - const double &t, - const CPPAD_TESTVECTOR(double) &x, - CPPAD_TESTVECTOR(double) &f_x) - { f_x[0] = -a[0]; - f_x[1] = 0.; - f_x[2] = +a[0]; - f_x[3] = -a[1]; - } - }; - // -------------------------------------------------------------- - class RungeMethod { - private: - Fun F; - public: - // constructor - RungeMethod(const CPPAD_TESTVECTOR(double) &a_) : F(a_) - { } - void step( - double ta , - double tb , - CPPAD_TESTVECTOR(double) &xa , - CPPAD_TESTVECTOR(double) &xb , - CPPAD_TESTVECTOR(double) &eb ) - { xb = CppAD::Runge45(F, 1, ta, tb, xa, eb); - } - size_t order(void) - { return 5; } - }; - class RosenMethod { - private: - Fun F; - public: - // constructor - RosenMethod(const CPPAD_TESTVECTOR(double) &a_) : F(a_) - { } - void step( - double ta , - double tb , - CPPAD_TESTVECTOR(double) &xa , - CPPAD_TESTVECTOR(double) &xb , - CPPAD_TESTVECTOR(double) &eb ) - { xb = CppAD::Rosen34(F, 1, ta, tb, xa, eb); - } - size_t order(void) - { return 4; } - }; + // -------------------------------------------------------------- + class Fun { + private: + CPPAD_TESTVECTOR(double) a; + public: + // constructor + Fun(const CPPAD_TESTVECTOR(double)& a_) : a(a_) + { } + // compute f(t, x) + void Ode( + 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]; + } + // compute partial of f(t, x) w.r.t. t + void Ode_ind( + 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 + void Ode_dep( + const double &t, + const CPPAD_TESTVECTOR(double) &x, + CPPAD_TESTVECTOR(double) &f_x) + { f_x[0] = -a[0]; + f_x[1] = 0.; + f_x[2] = +a[0]; + f_x[3] = -a[1]; + } + }; + // -------------------------------------------------------------- + class RungeMethod { + private: + Fun F; + public: + // constructor + RungeMethod(const CPPAD_TESTVECTOR(double) &a_) : F(a_) + { } + void step( + double ta , + double tb , + CPPAD_TESTVECTOR(double) &xa , + CPPAD_TESTVECTOR(double) &xb , + CPPAD_TESTVECTOR(double) &eb ) + { xb = CppAD::Runge45(F, 1, ta, tb, xa, eb); + } + size_t order(void) + { return 5; } + }; + class RosenMethod { + private: + Fun F; + public: + // constructor + RosenMethod(const CPPAD_TESTVECTOR(double) &a_) : F(a_) + { } + void step( + double ta , + double tb , + CPPAD_TESTVECTOR(double) &xa , + CPPAD_TESTVECTOR(double) &xb , + CPPAD_TESTVECTOR(double) &eb ) + { xb = CppAD::Rosen34(F, 1, ta, tb, xa, eb); + } + size_t order(void) + { return 4; } + }; } bool OdeStiff(void) -{ bool ok = true; // initial return value +{ bool ok = true; // initial return value - CPPAD_TESTVECTOR(double) a(2); - a[0] = 1e3; - a[1] = 1.; - RosenMethod rosen(a); - RungeMethod runge(a); - Fun gear(a); - - CPPAD_TESTVECTOR(double) xi(2); - xi[0] = 1.; - xi[1] = 0.; - - CPPAD_TESTVECTOR(double) eabs(2); - eabs[0] = 1e-6; - eabs[1] = 1e-6; - - CPPAD_TESTVECTOR(double) ef(2); - CPPAD_TESTVECTOR(double) xf(2); - CPPAD_TESTVECTOR(double) maxabs(2); - size_t nstep; - - size_t k; - for(k = 0; k < 3; k++) - { - size_t M = 5; - double ti = 0.; - double tf = 1.; - double smin = 1e-7; - double sini = 1e-7; - double smax = 1.; - double scur = .5; - double erel = 0.; - - if( k == 0 ) - { 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, - xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); - } - else if( k == 2 ) - { xf = CppAD::OdeGearControl(gear, M, ti, tf, - xi, smin, smax, sini, eabs, erel, ef, maxabs, nstep); - } - double x0 = exp(-a[0]*tf); - ok &= CppAD::NearEqual(x0, xf[0], 0., eabs[0]); - ok &= CppAD::NearEqual(0., ef[0], 0., eabs[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]); + CPPAD_TESTVECTOR(double) a(2); + a[0] = 1e3; + a[1] = 1.; + RosenMethod rosen(a); + RungeMethod runge(a); + Fun gear(a); + + CPPAD_TESTVECTOR(double) xi(2); + xi[0] = 1.; + xi[1] = 0.; + + CPPAD_TESTVECTOR(double) eabs(2); + eabs[0] = 1e-6; + eabs[1] = 1e-6; + + CPPAD_TESTVECTOR(double) ef(2); + CPPAD_TESTVECTOR(double) xf(2); + CPPAD_TESTVECTOR(double) maxabs(2); + size_t nstep; + + size_t k; + for(k = 0; k < 3; k++) + { + size_t M = 5; + double ti = 0.; + double tf = 1.; + double smin = 1e-7; + double sini = 1e-7; + double smax = 1.; + double scur = .5; + double erel = 0.; + + if( k == 0 ) + { 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, + xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); + } + else if( k == 2 ) + { xf = CppAD::OdeGearControl(gear, M, ti, tf, + xi, smin, smax, sini, eabs, erel, ef, maxabs, nstep); + } + double x0 = exp(-a[0]*tf); + ok &= CppAD::NearEqual(x0, xf[0], 0., eabs[0]); + ok &= CppAD::NearEqual(0., ef[0], 0., eabs[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]); # if CPPAD_ODE_STIFF_PRINT - const char* method[]={ "Rosen34", "Runge45", "Gear5" }; - std::cout << std::endl; - std::cout << "method = " << method[k] << std::endl; - std::cout << "nstep = " << nstep << std::endl; - std::cout << "x0 = " << x0 << std::endl; - std::cout << "xf[0] = " << xf[0] << std::endl; - std::cout << "x0 - xf[0] = " << x0 - xf[0] << std::endl; - std::cout << "ef[0] = " << ef[0] << std::endl; - std::cout << "x1 = " << x1 << std::endl; - std::cout << "xf[1] = " << xf[1] << std::endl; - std::cout << "x1 - xf[1] = " << x1 - xf[1] << std::endl; - std::cout << "ef[1] = " << ef[1] << std::endl; + const char* method[]={ "Rosen34", "Runge45", "Gear5" }; + std::cout << std::endl; + std::cout << "method = " << method[k] << std::endl; + std::cout << "nstep = " << nstep << std::endl; + std::cout << "x0 = " << x0 << std::endl; + std::cout << "xf[0] = " << xf[0] << std::endl; + std::cout << "x0 - xf[0] = " << x0 - xf[0] << std::endl; + std::cout << "ef[0] = " << ef[0] << std::endl; + std::cout << "x1 = " << x1 << std::endl; + std::cout << "xf[1] = " << xf[1] << std::endl; + std::cout << "x1 - xf[1] = " << x1 - xf[1] << std::endl; + std::cout << "ef[1] = " << ef[1] << std::endl; # endif - } + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/ode_taylor.cpp cppad-2019.02.00.0/example/general/ode_taylor.cpp --- cppad-2018.00.00.0/example/general/ode_taylor.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/ode_taylor.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 ode_taylor.cpp$$ -$spell - Taylor - Cpp - const - std - Adolc - adouble -$$ - -$section Taylor's Ode Solver: An Example and Test$$ -$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 + - \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 -$latex \[ - Z^{(1)} (t) = H[ Z(t) ] = - \left( \begin{array}{c} - 1 \\ - Z_1 (t) \\ - \vdots \\ - 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 -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 -$latex \[ - Z(t) = - \left( \begin{array}{c} - t \\ - t^2 / 2 \\ - \vdots \\ - t^n / n ! - \end{array} \right) -\] $$ - -$head Forward Mode$$ -Given the Taylor coefficients for $latex k = 0 , \ldots , K$$ -$latex \[ - z^{(k)} = \frac{ Z^{(k)} }{ k !} (t) -\]$$ -we note that -$latex \[ -\begin{array}{rcl} -Z^{(1)} (t) -& = & -H( z^{(0)} + z^{(1)} t + \cdots + z^{(K)} t^K ) + O( t^{K+1} ) -\\ -& = & -h^{(0)} + h^{(1)} t + \cdots + h^{(K)} t^K + O( t^{K+1} ) -\end{array} -\] $$ -where $latex h^{(k)}$$ is the $th k$$ order Taylor coefficient for -$latex H( Z(t) )$$. -Taking $th K$$ order derivatives of both sides we obtain -$latex \[ -\begin{array}{rcl} -Z^{(K+1)} (t) & = & K ! h^{(K)} \\ -z^{(K+1)} & = & h^{(K)} / K -\end{array} -\] $$ -The code below uses this relationship to implement Taylor's -method for approximating the solution of an ODE. - -$code -$srcfile%example/general/ode_taylor.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end --------------------------------------------------------------------------- -*/ -// BEGIN C++ - -# include - -// ========================================================================= -// define types for each level -namespace { // BEGIN empty namespace - using CppAD::AD; - - CPPAD_TESTVECTOR( AD ) ode( - const CPPAD_TESTVECTOR( AD )& Z ) - { size_t n = Z.size(); - CPPAD_TESTVECTOR( AD ) y(n); - y[0] = 1; - for(size_t k = 1; k < n; k++) - y[k] = Z[k-1]; - return y; - } - -} - -// ------------------------------------------------------------------------- -// Example that uses Taylor's method to solve ordinary differential equaitons -bool ode_taylor(void) -{ // initialize the return value as true - bool ok = true; - - // some temporary indices - size_t i, j, k; - - // The ODE does not depend on the arugment values - // so only tape once, also note that ode does not depend on t - size_t n = 5; // number of independent and dependent variables - CPPAD_TESTVECTOR( AD ) a_x(n), a_y(n); - CppAD::Independent( a_x ); - a_y = ode(a_x); - CppAD::ADFun H(a_x, a_y); - - // initialize the solution vector at time zero - CPPAD_TESTVECTOR( double ) z(n); - for(j = 0; j < n; j++) - z[j] = 0.0; - - size_t order = n; // order of the Taylor method - size_t n_step = 4; // number of time steps - double dt = 0.5; // step size in time - // Taylor coefficients of order k - CPPAD_TESTVECTOR( double ) hk(n), zk(n); - - // loop with respect to each step of Taylor's method - for(size_t i_step = 0; i_step < n_step; i_step++) - { // Use Taylor's method to take a step - zk = z; // initialize z^{(k)} for k = 0 - double dt_kp = dt; // initialize dt^(k+1) for k = 0 - 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); - - // add term for to this Taylor coefficient - // to solution for y(t, x) - z[j] += zk[j] * dt_kp; - } - // next power of t - dt_kp *= dt; - } - } - - // 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.; - double t = double(n_step) * dt; - for(i = 0; i < n; i++) - { check *= t / double(i + 1); - ok &= CppAD::NearEqual(z[i], check, eps, eps); - } - - return ok; -} - -// END C++ diff -Nru cppad-2018.00.00.0/example/general/opt_val_hes.cpp cppad-2019.02.00.0/example/general/opt_val_hes.cpp --- cppad-2018.00.00.0/example/general/opt_val_hes.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/opt_val_hes.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,22 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin opt_val_hes.cpp$$ $spell - hes + hes $$ $section opt_val_hes: Example and Test$$ -$mindex opt_val_hes$$ Fix $latex z \in \B{R}^\ell$$ and define the functions @@ -52,16 +52,14 @@ - \sum_{k=0}^{\ell-1} \sin ( x * t_k ) z_k \\ Y(x) & = & \frac{ - \sum_{k=0}^{\ell-1} \sin( x * t_k ) z_k - }{ - \sum_{k=0}^{\ell-1} \sin ( x * t_k )^2 + \sum_{k=0}^{\ell-1} \sin( x * t_k ) z_k + }{ + \sum_{k=0}^{\ell-1} \sin ( x * t_k )^2 } \end{array} \] $$ -$code $srcfile%example/general/opt_val_hes.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -71,126 +69,126 @@ # include namespace { - using CppAD::AD; - typedef CPPAD_TESTVECTOR(double) BaseVector; - typedef CPPAD_TESTVECTOR(AD) ADVector; - - class Fun { - private: - const BaseVector t_; // measurement times - const BaseVector z_; // measurement values - public: - typedef ADVector ad_vector; - // constructor - Fun(const BaseVector &t, const BaseVector &z) - : t_(t) , z_(z) - { assert( t.size() == z.size() ); } - // ell - size_t ell(void) const - { return t_.size(); } - // Fun.s - AD s(size_t k, const ad_vector& x, const ad_vector& y) const - { - AD residual = y[0] * sin( x[0] * t_[k] ) - z_[k]; - AD s_k = .5 * residual * residual; - - return s_k; - } - // Fun.sy - ad_vector sy(size_t k, const ad_vector& x, const ad_vector& y) const - { assert( y.size() == 1); - ad_vector sy_k(1); - - AD residual = y[0] * sin( x[0] * t_[k] ) - z_[k]; - sy_k[0] = residual * sin( x[0] * t_[k] ); - - return sy_k; - } - }; - // Used to test calculation of Hessian of V - AD V(const ADVector& x, const BaseVector& t, const BaseVector& z) - { // compute Y(x) - AD numerator = 0.; - AD denominator = 0.; - 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] ); - } - AD y = numerator / denominator; - - // V(x) = F[x, Y(x)] - AD sum = 0; - for(k = 0; k < size_t(t.size()); k++) - { AD residual = y * sin( x[0] * t[k] ) - z[k]; - sum += .5 * residual * residual; - } - return sum; - } + using CppAD::AD; + typedef CPPAD_TESTVECTOR(double) BaseVector; + typedef CPPAD_TESTVECTOR(AD) ADVector; + + class Fun { + private: + const BaseVector t_; // measurement times + const BaseVector z_; // measurement values + public: + typedef ADVector ad_vector; + // constructor + Fun(const BaseVector &t, const BaseVector &z) + : t_(t) , z_(z) + { assert( t.size() == z.size() ); } + // ell + size_t ell(void) const + { return t_.size(); } + // Fun.s + AD s(size_t k, const ad_vector& x, const ad_vector& y) const + { + AD residual = y[0] * sin( x[0] * t_[k] ) - z_[k]; + AD s_k = .5 * residual * residual; + + return s_k; + } + // Fun.sy + ad_vector sy(size_t k, const ad_vector& x, const ad_vector& y) const + { assert( y.size() == 1); + ad_vector sy_k(1); + + AD residual = y[0] * sin( x[0] * t_[k] ) - z_[k]; + sy_k[0] = residual * sin( x[0] * t_[k] ); + + return sy_k; + } + }; + // Used to test calculation of Hessian of V + AD V(const ADVector& x, const BaseVector& t, const BaseVector& z) + { // compute Y(x) + AD numerator = 0.; + AD denominator = 0.; + 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] ); + } + AD y = numerator / denominator; + + // V(x) = F[x, Y(x)] + AD sum = 0; + for(k = 0; k < size_t(t.size()); k++) + { AD residual = y * sin( x[0] * t[k] ) - z[k]; + sum += .5 * residual * residual; + } + return sum; + } } bool opt_val_hes(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - - // temporary indices - size_t j, k; - - // x space vector - size_t n = 1; - BaseVector x(n); - x[0] = 2. * 3.141592653; - - // y space vector - size_t m = 1; - BaseVector y(m); - y[0] = 1.; - - // t and z vectors - size_t ell = 10; - BaseVector t(ell); - BaseVector z(ell); - for(k = 0; k < ell; k++) - { t[k] = double(k) / double(ell); // time of measurement - z[k] = y[0] * sin( x[0] * t[k] ); // data without noise - } +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + + // temporary indices + size_t j, k; + + // x space vector + size_t n = 1; + BaseVector x(n); + x[0] = 2. * 3.141592653; + + // y space vector + size_t m = 1; + BaseVector y(m); + y[0] = 1.; + + // t and z vectors + size_t ell = 10; + BaseVector t(ell); + BaseVector z(ell); + for(k = 0; k < ell; k++) + { t[k] = double(k) / double(ell); // time of measurement + z[k] = y[0] * sin( x[0] * t[k] ); // data without noise + } - // construct the function object - Fun fun(t, z); + // construct the function object + Fun fun(t, z); - // evaluate the Jacobian and Hessian - BaseVector jac(n), hes(n * n); + // evaluate the Jacobian and Hessian + BaseVector jac(n), hes(n * n); # ifndef NDEBUG - int signdet = + int signdet = # endif - CppAD::opt_val_hes(x, y, fun, jac, hes); + CppAD::opt_val_hes(x, y, fun, jac, hes); - // we know that F_yy is positive definate for this case - assert( signdet == 1 ); + // we know that F_yy is positive definate for this case + assert( signdet == 1 ); - // create ADFun object g corresponding to V(x) - ADVector a_x(n), a_v(1); - for(j = 0; j < n; j++) - a_x[j] = x[j]; - Independent(a_x); - a_v[0] = V(a_x, t, z); - CppAD::ADFun g(a_x, a_v); - - // accuracy for checks - double eps = 10. * CppAD::numeric_limits::epsilon(); - - // check Jacobian - BaseVector check_jac = g.Jacobian(x); - for(j = 0; j < n; j++) - ok &= NearEqual(jac[j], check_jac[j], eps, eps); - - // check Hessian - BaseVector check_hes = g.Hessian(x, 0); - for(j = 0; j < n*n; j++) - ok &= NearEqual(hes[j], check_hes[j], eps, eps); + // create ADFun object g corresponding to V(x) + ADVector a_x(n), a_v(1); + for(j = 0; j < n; j++) + a_x[j] = x[j]; + Independent(a_x); + a_v[0] = V(a_x, t, z); + CppAD::ADFun g(a_x, a_v); + + // accuracy for checks + double eps = 10. * CppAD::numeric_limits::epsilon(); + + // check Jacobian + BaseVector check_jac = g.Jacobian(x); + for(j = 0; j < n; j++) + ok &= NearEqual(jac[j], check_jac[j], eps, eps); + + // check Hessian + BaseVector check_hes = g.Hessian(x, 0); + for(j = 0; j < n*n; j++) + ok &= NearEqual(hes[j], check_hes[j], eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/par_var.cpp cppad-2019.02.00.0/example/general/par_var.cpp --- cppad-2018.00.00.0/example/general/par_var.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/par_var.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 par_var.cpp$$ - -$section AD Parameter and Variable Functions: Example and Test$$ - - - - -$code -$srcfile%example/general/par_var.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ - -$end -*/ -// BEGIN C++ - -# include - -bool ParVar(void) -{ bool ok = true; - - using CppAD::AD; - using CppAD::VecAD; - using CppAD::Parameter; - using CppAD::Variable; - - // declare independent variables and start tape recording - size_t n = 1; - CPPAD_TESTVECTOR(AD) x(n); - 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 - - // dependent variable vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = 2.; - ok &= Parameter(y[0]); // y[0] does not depend on x[0] - y[1] = fabs(x[0]); - ok &= Variable(y[1]); // y[1] does depends on x[0] - - // VecAD objects - VecAD z(2); - z[0] = 0.; - z[1] = 1.; - 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); - - // check that now all AD objects are parameters - ok &= Parameter(x[0]); ok &= ! Variable(x[0]); - ok &= Parameter(y[0]); ok &= ! Variable(y[0]); - ok &= Parameter(y[1]); ok &= ! Variable(y[1]); - - // check that the VecAD object is a parameter - ok &= Parameter(z); - - return ok; -} - -// END C++ diff -Nru cppad-2018.00.00.0/example/general/poly.cpp cppad-2019.02.00.0/example/general/poly.cpp --- cppad-2018.00.00.0/example/general/poly.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/poly.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin poly.cpp$$ @@ -15,9 +16,7 @@ $section Polynomial Evaluation: Example and Test$$ -$code $srcfile%example/general/poly.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -27,29 +26,29 @@ # include bool Poly(void) -{ bool ok = true; +{ bool ok = true; - // degree of the polynomial - size_t deg = 3; + // degree of the polynomial + size_t deg = 3; - // set the polynomial coefficients - CPPAD_TESTVECTOR(double) a(deg + 1); - size_t i; - for(i = 0; i <= deg; i++) - a[i] = 1.; - - // evaluate this polynomial - size_t k = 0; - double z = 2.; - double p = CppAD::Poly(k, a, z); - ok &= (p == 1. + z + z*z + z*z*z); - - // evaluate derivative - k = 1; - p = CppAD::Poly(k, a, z); - ok &= (p == 1 + 2.*z + 3.*z*z); + // set the polynomial coefficients + CPPAD_TESTVECTOR(double) a(deg + 1); + size_t i; + for(i = 0; i <= deg; i++) + a[i] = 1.; + + // evaluate this polynomial + size_t k = 0; + double z = 2.; + double p = CppAD::Poly(k, a, z); + ok &= (p == 1. + z + z*z + z*z*z); + + // evaluate derivative + k = 1; + p = CppAD::Poly(k, a, z); + ok &= (p == 1 + 2.*z + 3.*z*z); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/pow.cpp cppad-2019.02.00.0/example/general/pow.cpp --- cppad-2018.00.00.0/example/general/pow.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/pow.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin pow.cpp$$ @@ -16,9 +17,7 @@ $section The AD Power Function: Example and Test$$ -$code $srcfile%example/general/pow.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -28,81 +27,81 @@ # include bool pow(void) -{ bool ok = true; +{ 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) axy(n); - axy[0] = x; - axy[1] = y; - - // declare independent variables and start tape recording - CppAD::Independent(axy); - - // range space vector - size_t m = 3; - 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: axy -> az and stop tape recording - CppAD::ADFun f(axy, az); - - // check value - double check = std::pow(x, y); - size_t i; - for(i = 0; i < m; i++) - ok &= NearEqual(az[i] , check, eps, eps); - - // forward computation of first partial w.r.t. x - CPPAD_TESTVECTOR(double) dxy(n); - CPPAD_TESTVECTOR(double) dz(m); - dxy[0] = 1.; - dxy[1] = 0.; - dz = f.Forward(1, dxy); - check = y * std::pow(x, y-1.); - 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, 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); - CPPAD_TESTVECTOR(double) dw(n); - w[0] = 1.; - w[1] = 1.; - w[2] = 1.; - dw = f.Reverse(1, w); - check = y * std::pow(x, y-1.); - ok &= NearEqual(dw[0], 2. * check, eps, eps); - check = std::log(x) * std::pow(x, y); - 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] = axy[0]; - v[one] = axy[1]; - AD result = CppAD::pow(v[zero], v[one]); - ok &= NearEqual(result, az[0], eps, eps); + 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) axy(n); + axy[0] = x; + axy[1] = y; + + // declare independent variables and start tape recording + CppAD::Independent(axy); + + // range space vector + size_t m = 3; + 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: axy -> az and stop tape recording + CppAD::ADFun f(axy, az); + + // check value + double check = std::pow(x, y); + size_t i; + for(i = 0; i < m; i++) + ok &= NearEqual(az[i] , check, eps, eps); + + // forward computation of first partial w.r.t. x + CPPAD_TESTVECTOR(double) dxy(n); + CPPAD_TESTVECTOR(double) dz(m); + dxy[0] = 1.; + dxy[1] = 0.; + dz = f.Forward(1, dxy); + check = y * std::pow(x, y-1.); + 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, 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); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + w[1] = 1.; + w[2] = 1.; + dw = f.Reverse(1, w); + check = y * std::pow(x, y-1.); + ok &= NearEqual(dw[0], 2. * check, eps, eps); + check = std::log(x) * std::pow(x, y); + 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] = axy[0]; + v[one] = axy[1]; + AD result = CppAD::pow(v[zero], v[one]); + ok &= NearEqual(result, az[0], eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/pow_int.cpp cppad-2019.02.00.0/example/general/pow_int.cpp --- cppad-2018.00.00.0/example/general/pow_int.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/general/pow_int.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin pow_int.cpp$$ $spell - tan - atan + tan + atan $$ $section The Pow Integer Exponent: Example and Test$$ -$mindex int$$ -$code $srcfile%example/general/pow_int.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -32,59 +30,58 @@ # include bool pow_int(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // declare independent variables and start tape recording - size_t n = 1; - double x0 = -0.5; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; - CppAD::Independent(x); - - // dependent variable vector - size_t m = 7; - CPPAD_TESTVECTOR(AD) y(m); - int 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); - - // check value - double check; - for(i = 0; i < int(m); i++) - { check = std::pow(x0, double(i - 3)); - ok &= NearEqual(y[i] , check, eps99 , eps99); - } - - // 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); - for(i = 0; i < int(m); i++) - { check = double(i-3) * std::pow(x0, double(i - 4)); - ok &= NearEqual(dy[i] , check, eps99 , eps99); - } - - // reverse computation of derivative of y[i] - CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); - for(i = 0; i < int(m); i++) - w[i] = 0.; - 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, eps99 , eps99); - w[i] = 0.; - } +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // declare independent variables and start tape recording + size_t n = 1; + double x0 = -0.5; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + CppAD::Independent(x); + + // dependent variable vector + size_t m = 7; + CPPAD_TESTVECTOR(AD) y(m); + for(size_t i = 0; i < m; i++) + y[i] = CppAD::pow(x[0], int(i) - 3); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check value + double check; + for(size_t i = 0; i < m; i++) + { check = std::pow(x0, double(i) - 3.0); + ok &= NearEqual(y[i] , check, eps99 , eps99); + } + + // 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); + for(size_t i = 0; i < m; i++) + { check = (double(i) - 3.0) * std::pow(x0, double(i) - 4.0); + ok &= NearEqual(dy[i] , check, eps99 , eps99); + } + + // reverse computation of derivative of y[i] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + for(size_t i = 0; i < m; i++) + w[i] = 0.; + for(size_t i = 0; i < m; i++) + { w[i] = 1.; + dw = f.Reverse(1, w); + check = (double(i) - 3.0) * std::pow(x0, double(i) - 4.0); + ok &= NearEqual(dw[0] , check, eps99 , eps99); + w[i] = 0.; + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/print_for.cpp cppad-2019.02.00.0/example/general/print_for.cpp --- cppad-2018.00.00.0/example/general/print_for.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/print_for.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin print_for_string.cpp$$ $spell - Cpp + Cpp $$ $section Print During Zero Order Forward Mode: Example and Test$$ -$code $srcfile%example/general/print_for.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -27,54 +26,54 @@ # include namespace { - using std::endl; - using CppAD::AD; + using std::endl; + using CppAD::AD; - // use of PrintFor to check for invalid function arguments - AD check_log(const AD& y, std::ostream& s_out) - { // check AD value during recording - if( y <= 0 ) - s_out << "check_log: y == " << y << " which is <= 0\n"; + // use of PrintFor to check for invalid function arguments + AD check_log(const AD& y, std::ostream& s_out) + { // check AD value during recording + if( y <= 0 ) + s_out << "check_log: y == " << y << " which is <= 0\n"; - // check double value during zero order forward calculation - PrintFor(y, "check_log: y == ", y , " which is <= 0\n"); + // check double value during zero order forward calculation + PrintFor(y, "check_log: y == ", y , " which is <= 0\n"); - return log(y); - } + return log(y); + } } bool print_for(void) -{ bool ok = true; - using CppAD::PrintFor; - std::stringstream stream_out; - - // independent variable vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 1.; // value of the independent variable during recording - Independent(ax); - - // A log evaluations that is OK when x[0] = 1 but not when x[0] = 2. - AD var = 2. - ax[0]; - AD log_var = check_log(var, stream_out); - ok &= stream_out.str() == ""; - - // 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); - - // zero order forward with x[0] = 2 - CPPAD_TESTVECTOR(double) x(n); - x[0] = 2.; - f.Forward(0, x, stream_out); +{ bool ok = true; + using CppAD::PrintFor; + std::stringstream stream_out; + + // independent variable vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 1.; // value of the independent variable during recording + Independent(ax); + + // A log evaluations that is OK when x[0] = 1 but not when x[0] = 2. + AD var = 2. - ax[0]; + AD log_var = check_log(var, stream_out); + ok &= stream_out.str() == ""; + + // 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); + + // zero order forward with x[0] = 2 + CPPAD_TESTVECTOR(double) x(n); + x[0] = 2.; + 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"; + std::string string_out = stream_out.str(); + ok &= stream_out.str() == "check_log: y == 0 which is <= 0\n"; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/reverse_checkpoint.cpp cppad-2019.02.00.0/example/general/reverse_checkpoint.cpp --- cppad-2018.00.00.0/example/general/reverse_checkpoint.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/reverse_checkpoint.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,30 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin reverse_checkpoint.cpp$$ $spell - Checkpointing - Taylor + Checkpointing + Taylor $$ $section Reverse Mode General Case (Checkpointing): Example and Test$$ $head See Also$$ -$cref checkpoint$$ +$cref/checkpoint/chkpoint_one/$$ $head Purpose$$ 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$$). +interface of the pieces (this is much easier to do using $cref/checkpoint/chkpoint_one/$$). In actual applications, there may be many functions, but for this example there are only two. The functions @@ -32,9 +33,9 @@ $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) - \; , \; - G(y) = \left( \begin{array}{c} y_0 - y_1 \\ y_1 y_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) \] $$ $head Processing Steps$$ @@ -43,12 +44,12 @@ is defined by $latex \[ \begin{array}{rcl} - 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 ( 1 - x_0 + x_1 ) - x_1 + x_0 + 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 ( 1 - x_0 + x_1 ) - x_1 + x_0 \end{array} \] $$ Given the zero and first order Taylor coefficients @@ -57,15 +58,15 @@ for the corresponding functions; i.e., $latex \[ \begin{array}{rcl} - X(t) & = & x^{(0)} + x^{(1)} t - \\ - Y(t) & = & F[X(t)] = y^{(0)} + y^{(1)} t + O(t^2) - \\ - Z(t) & = & G \{ F [ X(t) ] \} = z^{(0)} + z^{(1)} t + O(t^2) - \\ - h^{(0)} & = & z^{(0)}_0 + z^{(0)}_1 - \\ - h^{(1)} & = & z^{(1)}_0 + z^{(1)}_1 + X(t) & = & x^{(0)} + x^{(1)} t + \\ + Y(t) & = & F[X(t)] = y^{(0)} + y^{(1)} t + O(t^2) + \\ + Z(t) & = & G \{ F [ X(t) ] \} = z^{(0)} + z^{(1)} t + O(t^2) + \\ + h^{(0)} & = & z^{(0)}_0 + z^{(0)}_1 + \\ + h^{(1)} & = & z^{(1)}_0 + z^{(1)}_1 \end{array} \] $$ Here are the processing steps: @@ -92,31 +93,29 @@ This uses the following relations: $latex \[ \begin{array}{rcl} - \partial_{x(0)} h^{(1)} [ x^{(0)} , x^{(1)} ] - & = & - \partial_{y(0)} h^{(1)} [ y^{(0)} , y^{(1)} ] - \partial_{x(0)} y^{(0)} [ x^{(0)} , x^{(1)} ] - \\ - & + & - \partial_{y(1)} h^{(1)} [ y^{(0)} , y^{(1)} ] - \partial_{x(0)} y^{(1)} [ x^{(0)} , x^{(1)} ] - \\ - \partial_{x(1)} h^{(1)} [ x^{(0)} , x^{(1)} ] - & = & - \partial_{y(0)} h^{(1)} [ y^{(0)} , y^{(1)} ] - \partial_{x(1)} y^{(0)} [ x^{(0)} , x^{(1)} ] - \\ - & + & - \partial_{y(1)} h^{(1)} [ y^{(0)} , y^{(1)} ] - \partial_{x(1)} y^{(1)} [ x^{(0)} , x^{(1)} ] + \partial_{x(0)} h^{(1)} [ x^{(0)} , x^{(1)} ] + & = & + \partial_{y(0)} h^{(1)} [ y^{(0)} , y^{(1)} ] + \partial_{x(0)} y^{(0)} [ x^{(0)} , x^{(1)} ] + \\ + & + & + \partial_{y(1)} h^{(1)} [ y^{(0)} , y^{(1)} ] + \partial_{x(0)} y^{(1)} [ x^{(0)} , x^{(1)} ] + \\ + \partial_{x(1)} h^{(1)} [ x^{(0)} , x^{(1)} ] + & = & + \partial_{y(0)} h^{(1)} [ y^{(0)} , y^{(1)} ] + \partial_{x(1)} y^{(0)} [ x^{(0)} , x^{(1)} ] + \\ + & + & + \partial_{y(1)} h^{(1)} [ y^{(0)} , y^{(1)} ] + \partial_{x(1)} y^{(1)} [ x^{(0)} , x^{(1)} ] \end{array} \] $$ where $latex \partial_{x(0)}$$ denotes the partial with respect to $latex x^{(0)}$$. -$code $srcfile%example/general/reverse_checkpoint.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end @@ -126,142 +125,142 @@ # include namespace { - template - Vector F(const Vector& x) - { Vector y(2); - y[0] = x[0] * x[1]; - y[1] = x[1] - x[0]; - return y; - } - template - Vector G(const Vector& y) - { Vector z(2); - z[0] = y[0] - y[1]; - z[1] = y[1] * y[0]; - return z; - } + template + Vector F(const Vector& x) + { Vector y(2); + y[0] = x[0] * x[1]; + y[1] = x[1] - x[0]; + return y; + } + template + Vector G(const Vector& y) + { Vector z(2); + z[0] = y[0] - y[1]; + z[1] = y[1] * y[0]; + return z; + } } namespace { - bool reverse_any_case(bool free_all) - { bool ok = true; - double eps = 10. * CppAD::numeric_limits::epsilon(); - - using CppAD::AD; - using CppAD::NearEqual; - CppAD::ADFun f, g, empty; - - // specify the Taylor coefficients for X(t) - size_t n = 2; - CPPAD_TESTVECTOR(double) x0(n), x1(n); - x0[0] = 1.; x0[1] = 2.; - x1[0] = 3.; x1[1] = 4.; - - // record the function F(x) - CPPAD_TESTVECTOR(AD) X(n), Y(n); - size_t i; - for(i = 0; i < n; i++) - X[i] = x0[i]; - CppAD::Independent(X); - Y = F(X); - f.Dependent(X, Y); - - // a fucntion object with an almost empty operation sequence - CppAD::Independent(X); - empty.Dependent(X, X); - - // compute the Taylor coefficients for Y(t) - CPPAD_TESTVECTOR(double) y0(n), y1(n); - y0 = f.Forward(0, x0); - y1 = f.Forward(1, x1); - if( free_all ) - f = empty; - else - { // free all the Taylor coefficients stored in f - f.capacity_order(0); - } - - // record the function G(x) - CPPAD_TESTVECTOR(AD) Z(n); - CppAD::Independent(Y); - Z = G(Y); - g.Dependent(Y, Z); - - // compute the Taylor coefficients for Z(t) - CPPAD_TESTVECTOR(double) z0(n), z1(n); - z0 = g.Forward(0, y0); - z1 = g.Forward(1, y1); - - // check zero order Taylor coefficient for h^0 = z_0^0 + z_1^0 - double check = x0[0] * x0[1] * (1. - x0[0] + x0[1]) - x0[1] + x0[0]; - double h0 = z0[0] + z0[1]; - ok &= NearEqual(h0, check, eps, eps); - - // check first order Taylor coefficient h^1 - check = x0[0] * x0[1] * (- x1[0] + x1[1]) - x1[1] + x1[0]; - check += x1[0] * x0[1] * (1. - x0[0] + x0[1]); - 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); - w[0*p+0] = 0.; // coefficient for z_0^0 - w[0*p+1] = 1.; // coefficient for z_0^1 - w[1*p+0] = 0.; // coefficient for z_1^0 - w[1*p+1] = 1.; // coefficient for z_1^1 - dw = g.Reverse(p, w); - - // We are done using g, so we can free its memory. - g = empty; - // We need to use f next. - if( free_all ) - { // we must again record the operation sequence for F(x) - CppAD::Independent(X); - Y = F(X); - f.Dependent(X, Y); - } - // now recompute the Taylor coefficients corresponding to F(x) - // (we already know the result; i.e., y0 and y1). - f.Forward(0, x0); - f.Forward(1, x1); - - // 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); - - // check partial of h^1 w.r.t x^0_0 - check = x0[1] * (- x1[0] + x1[1]); - check -= x1[0] * x0[1]; - check += x1[1] * (1. - x0[0] + x0[1]) - x0[0] * x1[1]; - ok &= NearEqual(dv[0*p+0], check, eps, eps); - - // 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 += x0[0] * x1[1]; - ok &= NearEqual(dv[1*p+0], check, eps, eps); - - // check partial of h^1 w.r.t x^1_0 - check = 1. - x0[0] * x0[1]; - check += x0[1] * (1. - x0[0] + x0[1]); - ok &= NearEqual(dv[0*p+1], check, eps, eps); - - // check partial of h^1 w.r.t x^1_1 - check = x0[0] * x0[1] - 1.; - check += x0[0] * (1. - x0[0] + x0[1]); - ok &= NearEqual(dv[1*p+1], check, eps, eps); + bool reverse_any_case(bool free_all) + { bool ok = true; + double eps = 10. * CppAD::numeric_limits::epsilon(); + + using CppAD::AD; + using CppAD::NearEqual; + CppAD::ADFun f, g, empty; + + // specify the Taylor coefficients for X(t) + size_t n = 2; + CPPAD_TESTVECTOR(double) x0(n), x1(n); + x0[0] = 1.; x0[1] = 2.; + x1[0] = 3.; x1[1] = 4.; + + // record the function F(x) + CPPAD_TESTVECTOR(AD) X(n), Y(n); + size_t i; + for(i = 0; i < n; i++) + X[i] = x0[i]; + CppAD::Independent(X); + Y = F(X); + f.Dependent(X, Y); + + // a fucntion object with an almost empty operation sequence + CppAD::Independent(X); + empty.Dependent(X, X); + + // compute the Taylor coefficients for Y(t) + CPPAD_TESTVECTOR(double) y0(n), y1(n); + y0 = f.Forward(0, x0); + y1 = f.Forward(1, x1); + if( free_all ) + f = empty; + else + { // free all the Taylor coefficients stored in f + f.capacity_order(0); + } + + // record the function G(x) + CPPAD_TESTVECTOR(AD) Z(n); + CppAD::Independent(Y); + Z = G(Y); + g.Dependent(Y, Z); + + // compute the Taylor coefficients for Z(t) + CPPAD_TESTVECTOR(double) z0(n), z1(n); + z0 = g.Forward(0, y0); + z1 = g.Forward(1, y1); + + // check zero order Taylor coefficient for h^0 = z_0^0 + z_1^0 + double check = x0[0] * x0[1] * (1. - x0[0] + x0[1]) - x0[1] + x0[0]; + double h0 = z0[0] + z0[1]; + ok &= NearEqual(h0, check, eps, eps); + + // check first order Taylor coefficient h^1 + check = x0[0] * x0[1] * (- x1[0] + x1[1]) - x1[1] + x1[0]; + check += x1[0] * x0[1] * (1. - x0[0] + x0[1]); + 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); + w[0*p+0] = 0.; // coefficient for z_0^0 + w[0*p+1] = 1.; // coefficient for z_0^1 + w[1*p+0] = 0.; // coefficient for z_1^0 + w[1*p+1] = 1.; // coefficient for z_1^1 + dw = g.Reverse(p, w); + + // We are done using g, so we can free its memory. + g = empty; + // We need to use f next. + if( free_all ) + { // we must again record the operation sequence for F(x) + CppAD::Independent(X); + Y = F(X); + f.Dependent(X, Y); + } + // now recompute the Taylor coefficients corresponding to F(x) + // (we already know the result; i.e., y0 and y1). + f.Forward(0, x0); + f.Forward(1, x1); + + // 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); + + // check partial of h^1 w.r.t x^0_0 + check = x0[1] * (- x1[0] + x1[1]); + check -= x1[0] * x0[1]; + check += x1[1] * (1. - x0[0] + x0[1]) - x0[0] * x1[1]; + ok &= NearEqual(dv[0*p+0], check, eps, eps); + + // 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 += x0[0] * x1[1]; + ok &= NearEqual(dv[1*p+0], check, eps, eps); + + // check partial of h^1 w.r.t x^1_0 + check = 1. - x0[0] * x0[1]; + check += x0[1] * (1. - x0[0] + x0[1]); + ok &= NearEqual(dv[0*p+1], check, eps, eps); + + // check partial of h^1 w.r.t x^1_1 + check = x0[0] * x0[1] - 1.; + check += x0[0] * (1. - x0[0] + x0[1]); + ok &= NearEqual(dv[1*p+1], check, eps, eps); - return ok; - } + return ok; + } } bool reverse_any(void) -{ bool ok = true; - ok &= reverse_any_case(true); - ok &= reverse_any_case(false); - return ok; +{ bool ok = true; + ok &= reverse_any_case(true); + ok &= reverse_any_case(false); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/reverse_one.cpp cppad-2019.02.00.0/example/general/reverse_one.cpp --- cppad-2018.00.00.0/example/general/reverse_one.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/reverse_one.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin reverse_one.cpp$$ $spell - Cpp + Cpp $$ $section First Order Reverse Mode: Example and Test$$ -$code $srcfile%example/general/reverse_one.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -28,65 +27,65 @@ # 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; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = ax[0] * ax[0] * ax[1]; - - // create f : x -> y and stop recording - CppAD::ADFun f(ax, ay); - - // use first order reverse mode to evaluate derivative of y[0] - // and use the values in x for the independent variables. - CPPAD_TESTVECTOR(double) w(m), dw(n); - w[0] = 1.; - dw = f.Reverse(1, w); - ok &= NearEqual(dw[0] , 2.*ax[0]*ax[1], eps99, eps99); - ok &= NearEqual(dw[1] , ax[0]*ax[0], eps99, eps99); - - // use zero order forward mode to evaluate y at x = (3, 4) - // and use the template parameter Vector for the vector type - Vector x(n), y(m); - x[0] = 3.; - x[1] = 4.; - y = f.Forward(0, x); - ok &= NearEqual(y[0] , x[0]*x[0]*x[1], eps99, eps99); - - // use first order reverse mode to evaluate derivative of y[0] - // and using the values in x for the independent variables. - w[0] = 1.; - dw = f.Reverse(1, w); - ok &= NearEqual(dw[0] , 2.*x[0]*x[1], eps99, eps99); - ok &= NearEqual(dw[1] , x[0]*x[0], eps99, eps99); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = ax[0] * ax[0] * ax[1]; + + // create f : x -> y and stop recording + CppAD::ADFun f(ax, ay); + + // use first order reverse mode to evaluate derivative of y[0] + // and use the values in x for the independent variables. + CPPAD_TESTVECTOR(double) w(m), dw(n); + w[0] = 1.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0] , 2.*ax[0]*ax[1], eps99, eps99); + ok &= NearEqual(dw[1] , ax[0]*ax[0], eps99, eps99); + + // use zero order forward mode to evaluate y at x = (3, 4) + // and use the template parameter Vector for the vector type + Vector x(n), y(m); + x[0] = 3.; + x[1] = 4.; + y = f.Forward(0, x); + ok &= NearEqual(y[0] , x[0]*x[0]*x[1], eps99, eps99); + + // use first order reverse mode to evaluate derivative of y[0] + // and using the values in x for the independent variables. + w[0] = 1.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0] , 2.*x[0]*x[1], eps99, eps99); + ok &= NearEqual(dw[1] , x[0]*x[0], eps99, eps99); - return ok; + return ok; } } // End empty namespace # include # include bool reverse_one(void) -{ bool ok = true; - // Run with Vector equal to three different cases - // all of which are Simple Vectors with elements of type double. - ok &= reverse_one_cases< CppAD::vector >(); - ok &= reverse_one_cases< std::vector >(); - ok &= reverse_one_cases< std::valarray >(); - return ok; +{ bool ok = true; + // Run with Vector equal to three different cases + // all of which are Simple Vectors with elements of type double. + ok &= reverse_one_cases< CppAD::vector >(); + ok &= reverse_one_cases< std::vector >(); + ok &= reverse_one_cases< std::valarray >(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/reverse_three.cpp cppad-2019.02.00.0/example/general/reverse_three.cpp --- cppad-2018.00.00.0/example/general/reverse_three.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/reverse_three.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin reverse_three.cpp$$ $spell - Taylor - Cpp + Taylor + Cpp $$ $section Third Order Reverse Mode: Example and Test$$ @@ -22,20 +23,18 @@ $head Taylor Coefficients$$ $latex \[ \begin{array}{rcl} - X(t) & = & x^{(0)} + x^{(1)} t + x^{(2)} t^2 - \\ - X^{(1)} (t) & = & x^{(1)} + 2 x^{(2)} t - \\ - X^{(2)} (t) & = & 2 x^{(2)} + X(t) & = & x^{(0)} + x^{(1)} t + x^{(2)} t^2 + \\ + X^{(1)} (t) & = & x^{(1)} + 2 x^{(2)} t + \\ + X^{(2)} (t) & = & 2 x^{(2)} \end{array} \] $$ Thus, we need to be careful to properly account for the fact that $latex X^{(2)} (0) = 2 x^{(2)}$$ (and similarly $latex Y^{(2)} (0) = 2 y^{(2)}$$). -$code $srcfile%example/general/reverse_three.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -43,105 +42,105 @@ # 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(); - using CppAD::AD; - using CppAD::NearEqual; - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; - X[1] = 1.; - - // declare independent variables and start recording - CppAD::Independent(X); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0] * X[1]; - - // create f : X -> Y and stop recording - CppAD::ADFun f(X, Y); - - // 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) - 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 - Vector x1(n), y1(m); - x1[0] = 4.; - x1[1] = 5.; - y1 = f.Forward(1, x1); - - // Y^1 (x) = partial_t F( x^0 + x^1 * t ) - // y^1 = Y^1 (0) - check = x1[0] * x0[1] + x0[0] * x1[1]; - ok &= NearEqual(y1[0], check, eps, eps); - - // define x^2 and compute y^2 using second order forward mode - Vector x2(n), y2(m); - x2[0] = 6.; - x2[1] = 7.; - y2 = f.Forward(2, x2); - - // Y^2 (x) = partial_tt F( x^0 + x^1 * t + x^2 * t^2 ) - // y^2 = (1/2) * Y^2 (0) - check = x2[0] * x0[1] + x1[0] * x1[1] + x0[0] * x2[1]; - ok &= NearEqual(y2[0], check, eps, eps); - - // W(x) = Y^0 (x) + 2 * Y^1 (x) + 3 * (1/2) * Y^2 (x) - size_t p = 3; - Vector dw(n*p), w(m*p); - w[0] = 1.; - w[1] = 2.; - w[2] = 3.; - dw = f.Reverse(p, w); - - // check partial w.r.t x^0_0 of W(x) - check = x0[1] + 2. * x1[1] + 3. * x2[1]; - ok &= NearEqual(dw[0*p+0], check, eps, eps); - - // check partial w.r.t x^0_1 of W(x) - check = x0[0] + 2. * x1[0] + 3. * x2[0]; - ok &= NearEqual(dw[1*p+0], check, eps, eps); - - // check partial w.r.t x^1_0 of W(x) - check = 2. * x0[1] + 3. * x1[1]; - ok &= NearEqual(dw[0*p+1], check, eps, eps); - - // check partial w.r.t x^1_1 of W(x) - check = 2. * x0[0] + 3. * x1[0]; - ok &= NearEqual(dw[1*p+1], check, eps, eps); - - // check partial w.r.t x^2_0 of W(x) - 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]; - ok &= NearEqual(dw[1*p+2], check, eps, eps); +{ bool ok = true; + double eps = 10. * CppAD::numeric_limits::epsilon(); + using CppAD::AD; + using CppAD::NearEqual; + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 0.; + X[1] = 1.; + + // declare independent variables and start recording + CppAD::Independent(X); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0] * X[1]; + + // create f : X -> Y and stop recording + CppAD::ADFun f(X, Y); + + // 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) + 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 + Vector x1(n), y1(m); + x1[0] = 4.; + x1[1] = 5.; + y1 = f.Forward(1, x1); + + // Y^1 (x) = partial_t F( x^0 + x^1 * t ) + // y^1 = Y^1 (0) + check = x1[0] * x0[1] + x0[0] * x1[1]; + ok &= NearEqual(y1[0], check, eps, eps); + + // define x^2 and compute y^2 using second order forward mode + Vector x2(n), y2(m); + x2[0] = 6.; + x2[1] = 7.; + y2 = f.Forward(2, x2); + + // Y^2 (x) = partial_tt F( x^0 + x^1 * t + x^2 * t^2 ) + // y^2 = (1/2) * Y^2 (0) + check = x2[0] * x0[1] + x1[0] * x1[1] + x0[0] * x2[1]; + ok &= NearEqual(y2[0], check, eps, eps); + + // W(x) = Y^0 (x) + 2 * Y^1 (x) + 3 * (1/2) * Y^2 (x) + size_t p = 3; + Vector dw(n*p), w(m*p); + w[0] = 1.; + w[1] = 2.; + w[2] = 3.; + dw = f.Reverse(p, w); + + // check partial w.r.t x^0_0 of W(x) + check = x0[1] + 2. * x1[1] + 3. * x2[1]; + ok &= NearEqual(dw[0*p+0], check, eps, eps); + + // check partial w.r.t x^0_1 of W(x) + check = x0[0] + 2. * x1[0] + 3. * x2[0]; + ok &= NearEqual(dw[1*p+0], check, eps, eps); + + // check partial w.r.t x^1_0 of W(x) + check = 2. * x0[1] + 3. * x1[1]; + ok &= NearEqual(dw[0*p+1], check, eps, eps); + + // check partial w.r.t x^1_1 of W(x) + check = 2. * x0[0] + 3. * x1[0]; + ok &= NearEqual(dw[1*p+1], check, eps, eps); + + // check partial w.r.t x^2_0 of W(x) + 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]; + ok &= NearEqual(dw[1*p+2], check, eps, eps); - return ok; + return ok; } } // End empty namespace # include # include bool reverse_three(void) -{ bool ok = true; - ok &= cases< CppAD::vector >(); - ok &= cases< std::vector >(); - ok &= cases< std::valarray >(); - return ok; +{ bool ok = true; + ok &= cases< CppAD::vector >(); + ok &= cases< std::vector >(); + ok &= cases< std::valarray >(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/reverse_two.cpp cppad-2019.02.00.0/example/general/reverse_two.cpp --- cppad-2018.00.00.0/example/general/reverse_two.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/reverse_two.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin reverse_two.cpp$$ $spell - Cpp + Cpp $$ $section Second Order Reverse ModeExample and Test$$ -$mindex example$$ -$code $srcfile%example/general/reverse_two.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,73 +27,73 @@ # 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; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; - X[1] = 1.; - - // declare independent variables and start recording - CppAD::Independent(X); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0] * X[0] * X[1]; - - // create f : X -> Y and stop recording - CppAD::ADFun f(X, Y); - - // use zero order forward mode to evaluate y at x = (3, 4) - // use the template parameter Vector for the vector type - Vector x(n), y(m); - x[0] = 3.; - x[1] = 4.; - y = f.Forward(0, x); - ok &= NearEqual(y[0] , x[0]*x[0]*x[1], eps99, eps99); - - // use first order forward mode in x[0] direction - // (all second order partials below involve x[0]) - Vector dx(n), dy(m); - dx[0] = 1.; - dx[1] = 1.; - dy = f.Forward(1, dx); - double check = 2.*x[0]*x[1]*dx[0] + x[0]*x[0]*dx[1]; - ok &= NearEqual(dy[0], check, eps99, eps99); - - // use second order reverse mode to evalaute second partials of y[0] - // with respect to (x[0], x[0]) and with respect to (x[0], x[1]) - Vector w(m), dw( n * 2 ); - w[0] = 1.; - dw = f.Reverse(2, w); - - // check derivative of f - ok &= NearEqual(dw[0*2+0] , 2.*x[0]*x[1], eps99, eps99); - ok &= NearEqual(dw[1*2+0] , x[0]*x[0], eps99, eps99); - - // 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, eps99, eps99); - check = 2.*x[0]*dx[1]; - ok &= NearEqual(dw[1*2+1] , check, eps99, eps99); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 0.; + X[1] = 1.; + + // declare independent variables and start recording + CppAD::Independent(X); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0] * X[0] * X[1]; + + // create f : X -> Y and stop recording + CppAD::ADFun f(X, Y); + + // use zero order forward mode to evaluate y at x = (3, 4) + // use the template parameter Vector for the vector type + Vector x(n), y(m); + x[0] = 3.; + x[1] = 4.; + y = f.Forward(0, x); + ok &= NearEqual(y[0] , x[0]*x[0]*x[1], eps99, eps99); + + // use first order forward mode in x[0] direction + // (all second order partials below involve x[0]) + Vector dx(n), dy(m); + dx[0] = 1.; + dx[1] = 1.; + dy = f.Forward(1, dx); + double check = 2.*x[0]*x[1]*dx[0] + x[0]*x[0]*dx[1]; + ok &= NearEqual(dy[0], check, eps99, eps99); + + // use second order reverse mode to evalaute second partials of y[0] + // with respect to (x[0], x[0]) and with respect to (x[0], x[1]) + Vector w(m), dw( n * 2 ); + w[0] = 1.; + dw = f.Reverse(2, w); + + // check derivative of f + ok &= NearEqual(dw[0*2+0] , 2.*x[0]*x[1], eps99, eps99); + ok &= NearEqual(dw[1*2+0] , x[0]*x[0], eps99, eps99); + + // 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, eps99, eps99); + check = 2.*x[0]*dx[1]; + ok &= NearEqual(dw[1*2+1] , check, eps99, eps99); - return ok; + return ok; } } // End empty namespace # include # include bool reverse_two(void) -{ bool ok = true; - ok &= reverse_two_cases< CppAD::vector >(); - ok &= reverse_two_cases< std::vector >(); - ok &= reverse_two_cases< std::valarray >(); - return ok; +{ bool ok = true; + ok &= reverse_two_cases< CppAD::vector >(); + ok &= reverse_two_cases< std::vector >(); + ok &= reverse_two_cases< std::valarray >(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/rev_one.cpp cppad-2019.02.00.0/example/general/rev_one.cpp --- cppad-2018.00.00.0/example/general/rev_one.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/rev_one.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin rev_one.cpp$$ $spell - Cpp + Cpp $$ $section First Order Derivative Driver: Example and Test$$ -$code $srcfile%example/general/rev_one.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -28,68 +27,68 @@ # include namespace { // ------------------------------------------------------- // define the template function RevOneCases in empty namespace -template +template bool RevOneCases() -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - using CppAD::exp; - using CppAD::sin; - using CppAD::cos; - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 1.; - X[1] = 2.; - - // declare independent variables and starting recording - CppAD::Independent(X); - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0] * exp( X[1] ); - Y[1] = X[0] * sin( X[1] ); - Y[2] = X[0] * cos( X[1] ); - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - Vector x(n); - x[0] = 2.; - x[1] = 1.; - - // compute and check derivative of y[0] - Vector dw(n); - dw = f.RevOne(x, 0); - ok &= NearEqual(dw[0], exp(x[1]), eps99, eps99); // w.r.t x[0] - ok &= NearEqual(dw[1], x[0]*exp(x[1]), eps99, eps99); // w.r.t x[1] - - // compute and check derivative of y[1] - dw = f.RevOne(x, 1); - ok &= NearEqual(dw[0], sin(x[1]), eps99, eps99); - ok &= NearEqual(dw[1], x[0]*cos(x[1]), eps99, eps99); - - // compute and check derivative of y[2] - dw = f.RevOne(x, 2); - ok &= NearEqual(dw[0], cos(x[1]), eps99, eps99); - ok &= NearEqual(dw[1], - x[0]*sin(x[1]), eps99, eps99); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + using CppAD::exp; + using CppAD::sin; + using CppAD::cos; + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 1.; + X[1] = 2.; + + // declare independent variables and starting recording + CppAD::Independent(X); + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0] * exp( X[1] ); + Y[1] = X[0] * sin( X[1] ); + Y[2] = X[0] * cos( X[1] ); + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + Vector x(n); + x[0] = 2.; + x[1] = 1.; + + // compute and check derivative of y[0] + Vector dw(n); + dw = f.RevOne(x, 0); + ok &= NearEqual(dw[0], exp(x[1]), eps99, eps99); // w.r.t x[0] + ok &= NearEqual(dw[1], x[0]*exp(x[1]), eps99, eps99); // w.r.t x[1] + + // compute and check derivative of y[1] + dw = f.RevOne(x, 1); + ok &= NearEqual(dw[0], sin(x[1]), eps99, eps99); + ok &= NearEqual(dw[1], x[0]*cos(x[1]), eps99, eps99); + + // compute and check derivative of y[2] + dw = f.RevOne(x, 2); + ok &= NearEqual(dw[0], cos(x[1]), eps99, eps99); + ok &= NearEqual(dw[1], - x[0]*sin(x[1]), eps99, eps99); - return ok; + return ok; } } // End empty namespace # include # include bool RevOne(void) -{ bool ok = true; - // Run with Vector equal to three different cases - // all of which are Simple Vectors with elements of type double. - ok &= RevOneCases< CppAD::vector >(); - ok &= RevOneCases< std::vector >(); - ok &= RevOneCases< std::valarray >(); - return ok; +{ bool ok = true; + // Run with Vector equal to three different cases + // all of which are Simple Vectors with elements of type double. + ok &= RevOneCases< CppAD::vector >(); + ok &= RevOneCases< std::vector >(); + ok &= RevOneCases< std::valarray >(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/rev_two.cpp cppad-2019.02.00.0/example/general/rev_two.cpp --- cppad-2018.00.00.0/example/general/rev_two.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/rev_two.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin rev_two.cpp$$ $spell - Cpp + Cpp $$ $section Second Partials Reverse Driver: Example and Test$$ -$code $srcfile%example/general/rev_two.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -28,83 +27,83 @@ # include namespace { // ----------------------------------------------------- // define the template function in empty namespace -// bool RevTwoCases(void) -template +// bool RevTwoCases(void) +template bool RevTwoCases() -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - using CppAD::exp; - using CppAD::sin; - using CppAD::cos; - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 1.; - X[1] = 2.; - - // declare independent variables and starting recording - CppAD::Independent(X); - - // a calculation between the domain and range values - AD Square = X[0] * X[0]; - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = Square * exp( X[1] ); - Y[1] = Square * sin( X[1] ); - Y[2] = Square * cos( X[1] ); - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - VectorBase x(n); - x[0] = 2.; - x[1] = 1.; - - // set i and j to compute specific second partials of y - size_t p = 2; - VectorSize_t i(p); - VectorSize_t j(p); - i[0] = 0; j[0] = 0; // for partials y[0] w.r.t x[0] and x[k] - i[1] = 1; j[1] = 1; // for partials y[1] w.r.t x[1] and x[k] - - // compute the second partials - VectorBase ddw(n * p); - 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 - ok &= NearEqual( 2.*exp(x[1]), ddw[0*p+0], eps99, eps99); - ok &= NearEqual( 2.*x[0]*exp(x[1]), ddw[1*p+0], eps99, eps99); - - // 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 - ok &= NearEqual( 2.*x[0]*cos(x[1]), ddw[0*p+1], eps99, eps99); - ok &= NearEqual( -x[0]*x[0]*sin(x[1]), ddw[1*p+1], eps99, eps99); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + using CppAD::exp; + using CppAD::sin; + using CppAD::cos; + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 1.; + X[1] = 2.; + + // declare independent variables and starting recording + CppAD::Independent(X); + + // a calculation between the domain and range values + AD Square = X[0] * X[0]; + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = Square * exp( X[1] ); + Y[1] = Square * sin( X[1] ); + Y[2] = Square * cos( X[1] ); + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + BaseVector x(n); + x[0] = 2.; + x[1] = 1.; + + // set i and j to compute specific second partials of y + size_t p = 2; + SizeVector_t i(p); + SizeVector_t j(p); + i[0] = 0; j[0] = 0; // for partials y[0] w.r.t x[0] and x[k] + i[1] = 1; j[1] = 1; // for partials y[1] w.r.t x[1] and x[k] + + // compute the second partials + BaseVector ddw(n * p); + 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 + ok &= NearEqual( 2.*exp(x[1]), ddw[0*p+0], eps99, eps99); + ok &= NearEqual( 2.*x[0]*exp(x[1]), ddw[1*p+0], eps99, eps99); + + // 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 + ok &= NearEqual( 2.*x[0]*cos(x[1]), ddw[0*p+1], eps99, eps99); + ok &= NearEqual( -x[0]*x[0]*sin(x[1]), ddw[1*p+1], eps99, eps99); - return ok; + return ok; } } // End empty namespace # include # include bool RevTwo(void) -{ bool ok = true; - // Run with VectorBase equal to three different cases +{ bool ok = true; + // Run with BaseVector equal to three different cases // all of which are Simple Vectors with elements of type double. - ok &= RevTwoCases< CppAD::vector , std::vector >(); - ok &= RevTwoCases< std::vector , std::vector >(); - ok &= RevTwoCases< std::valarray , std::vector >(); + ok &= RevTwoCases< CppAD::vector , std::vector >(); + ok &= RevTwoCases< std::vector , std::vector >(); + ok &= RevTwoCases< std::valarray , std::vector >(); - // Run with VectorSize_t equal to two other cases + // Run with SizeVector_t equal to two other cases // which are Simple Vectors with elements of type size_t. - ok &= RevTwoCases< std::vector , CppAD::vector >(); - ok &= RevTwoCases< std::vector , std::valarray >(); + ok &= RevTwoCases< std::vector , CppAD::vector >(); + ok &= RevTwoCases< std::vector , std::valarray >(); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/rosen_34.cpp cppad-2019.02.00.0/example/general/rosen_34.cpp --- cppad-2018.00.00.0/example/general/rosen_34.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/rosen_34.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,28 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin rosen_34.cpp$$ $spell - Rosen + Rosen $$ $section Rosen34: Example and Test$$ -$mindex Rosen34$$ Define $latex X : \B{R} \rightarrow \B{R}^n$$ by $latex \[ - X_i (t) = t^{i+1} + X_i (t) = t^{i+1} \] $$ for $latex i = 1 , \ldots , n-1$$. It follows that @@ -35,9 +35,7 @@ \] $$ The example tests Rosen34 using the relations above: -$code $srcfile%example/general/rosen_34.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -46,154 +44,155 @@ # include // For automatic differentiation namespace { - class Fun { - public: - // constructor - 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, - CPPAD_TESTVECTOR(Scalar) &f) - { size_t n = x.size(); - Scalar ti(1); - f[0] = Scalar(1); - size_t i; - for(i = 1; i < n; i++) - { ti *= t; - // convert int(size_t) to avoid warning - // on _MSC_VER systems - if( use_x ) - f[i] = int(i+1) * x[i-1]; - else f[i] = int(i+1) * ti; - } - } - - // compute partial of f(t, x) w.r.t. t using AD - void Ode_ind( - const double &t, - const CPPAD_TESTVECTOR(double) &x, - CPPAD_TESTVECTOR(double) &f_t) - { using namespace CppAD; - - size_t n = x.size(); - CPPAD_TESTVECTOR(AD) T(1); - CPPAD_TESTVECTOR(AD) X(n); - CPPAD_TESTVECTOR(AD) F(n); - - // set argument values - T[0] = t; - size_t i; - for(i = 0; i < n; i++) - X[i] = x[i]; - - // declare independent variables - Independent(T); - - // compute f(t, x) - this->Ode(T[0], X, F); - - // define AD function object - ADFun fun(T, F); - - // compute partial of f w.r.t t - CPPAD_TESTVECTOR(double) dt(1); - dt[0] = 1.; - f_t = fun.Forward(1, dt); - } - - // compute partial of f(t, x) w.r.t. x using AD - void Ode_dep( - const double &t, - const CPPAD_TESTVECTOR(double) &x, - CPPAD_TESTVECTOR(double) &f_x) - { using namespace CppAD; - - size_t n = x.size(); - CPPAD_TESTVECTOR(AD) T(1); - CPPAD_TESTVECTOR(AD) X(n); - CPPAD_TESTVECTOR(AD) F(n); - - // set argument values - T[0] = t; - size_t i, j; - for(i = 0; i < n; i++) - X[i] = x[i]; - - // declare independent variables - Independent(X); - - // compute f(t, x) - this->Ode(T[0], X, F); - - // define AD function object - ADFun fun(X, F); - - // compute partial of f w.r.t x - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) df(n); - for(j = 0; j < n; j++) - dx[j] = 0.; - for(j = 0; j < n; j++) - { dx[j] = 1.; - df = fun.Forward(1, dx); - for(i = 0; i < n; i++) - f_x [i * n + j] = df[i]; - dx[j] = 0.; - } - } + class Fun { + public: + // constructor + 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, + CPPAD_TESTVECTOR(Scalar) &f) + { size_t n = x.size(); + Scalar ti(1); + f[0] = Scalar(1); + size_t i; + for(i = 1; i < n; i++) + { ti *= t; + // convert int(size_t) to avoid warning + // on _MSC_VER systems + if( use_x ) + f[i] = int(i+1) * x[i-1]; + else + f[i] = int(i+1) * ti; + } + } + + // compute partial of f(t, x) w.r.t. t using AD + void Ode_ind( + const double &t, + const CPPAD_TESTVECTOR(double) &x, + CPPAD_TESTVECTOR(double) &f_t) + { using namespace CppAD; + + size_t n = x.size(); + CPPAD_TESTVECTOR(AD) T(1); + CPPAD_TESTVECTOR(AD) X(n); + CPPAD_TESTVECTOR(AD) F(n); + + // set argument values + T[0] = t; + size_t i; + for(i = 0; i < n; i++) + X[i] = x[i]; + + // declare independent variables + Independent(T); + + // compute f(t, x) + this->Ode(T[0], X, F); + + // define AD function object + ADFun fun(T, F); + + // compute partial of f w.r.t t + CPPAD_TESTVECTOR(double) dt(1); + dt[0] = 1.; + f_t = fun.Forward(1, dt); + } + + // compute partial of f(t, x) w.r.t. x using AD + void Ode_dep( + const double &t, + const CPPAD_TESTVECTOR(double) &x, + CPPAD_TESTVECTOR(double) &f_x) + { using namespace CppAD; + + size_t n = x.size(); + CPPAD_TESTVECTOR(AD) T(1); + CPPAD_TESTVECTOR(AD) X(n); + CPPAD_TESTVECTOR(AD) F(n); + + // set argument values + T[0] = t; + size_t i, j; + for(i = 0; i < n; i++) + X[i] = x[i]; + + // declare independent variables + Independent(X); + + // compute f(t, x) + this->Ode(T[0], X, F); + + // define AD function object + ADFun fun(X, F); + + // compute partial of f w.r.t x + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) df(n); + for(j = 0; j < n; j++) + dx[j] = 0.; + for(j = 0; j < n; j++) + { dx[j] = 1.; + df = fun.Forward(1, dx); + for(i = 0; i < n; i++) + f_x [i * n + j] = df[i]; + dx[j] = 0.; + } + } - private: - const bool use_x; + private: + const bool use_x; - }; + }; } bool Rosen34(void) -{ bool ok = true; // initial return value - size_t i; // temporary indices +{ bool ok = true; // initial return value + size_t i; // temporary indices - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); - 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 - - // xi = X(0) - CPPAD_TESTVECTOR(double) xi(n); - for(i = 0; i 0); - - // compute Rosen34 approximation for X(tf) - CPPAD_TESTVECTOR(double) xf(n), e(n); - xf = CppAD::Rosen34(F, M, ti, tf, xi, e); - - double check = tf; - for(i = 0; i < n; i++) - { // check that error is always positive - ok &= (e[i] >= 0.); - // 4th order method is exact for i < 4 - if( i < 4 ) ok &= - NearEqual(xf[i], check, eps99, eps99); - // 3rd order method is exact for i < 3 - if( i < 3 ) - ok &= (e[i] <= eps99); - - // check value for next i - check *= tf; - } - } - return ok; + 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 + + // xi = X(0) + CPPAD_TESTVECTOR(double) xi(n); + for(i = 0; i 0); + + // compute Rosen34 approximation for X(tf) + CPPAD_TESTVECTOR(double) xf(n), e(n); + xf = CppAD::Rosen34(F, M, ti, tf, xi, e); + + double check = tf; + for(i = 0; i < n; i++) + { // check that error is always positive + ok &= (e[i] >= 0.); + // 4th order method is exact for i < 4 + if( i < 4 ) ok &= + NearEqual(xf[i], check, eps99, eps99); + // 3rd order method is exact for i < 3 + if( i < 3 ) + ok &= (e[i] <= eps99); + + // check value for next i + check *= tf; + } + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/runge45_2.cpp cppad-2019.02.00.0/example/general/runge45_2.cpp --- cppad-2018.00.00.0/example/general/runge45_2.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/runge45_2.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,28 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin runge45_2.cpp$$ $spell - Runge + Runge $$ $section Runge45: Example and Test$$ -$mindex Runge45$$ 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) + X_j (b, t) = b \left( \sum_{k=0}^j t^k / k ! \right) \] $$ for $latex j = 0 , \ldots , n-1$$. It follows that @@ -31,8 +31,8 @@ X_j (b, 0) & = & b \\ \partial_t X_j (b, t) & = & b \left( \sum_{k=0}^{j-1} t^k / k ! \right) \\ \partial_t X_j (b, t) & = & \left\{ \begin{array}{ll} - 0 & {\rm if} \; j = 0 \\ - X_{j-1} (b, t) & {\rm otherwise} + 0 & {\rm if} \; j = 0 \\ + X_{j-1} (b, t) & {\rm otherwise} \end{array} \right. \end{array} \] $$ @@ -42,12 +42,10 @@ $latex f(b) = X(b, t_f )$$. We can then compute $latex f^{(1)} (b)$$ which is an approximation for $latex \[ - \partial_b X(b, t_f ) = \sum_{k=0}^j t_f^k / k ! + \partial_b X(b, t_f ) = \sum_{k=0}^j t_f^k / k ! \] $$ -$code $srcfile%example/general/runge45_2.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -59,93 +57,93 @@ namespace { - template - class Fun { - public: - // constructor - Fun(void) - { } - - // set return value to X'(t) - void Ode( - const Scalar &t, - const CPPAD_TESTVECTOR(Scalar) &x, - CPPAD_TESTVECTOR(Scalar) &f) - { size_t n = x.size(); - f[0] = 0.; - for(size_t k = 1; k < n; k++) - f[k] = x[k-1]; - } - }; + template + class Fun { + public: + // constructor + Fun(void) + { } + + // set return value to X'(t) + void Ode( + const Scalar &t, + const CPPAD_TESTVECTOR(Scalar) &x, + CPPAD_TESTVECTOR(Scalar) &f) + { size_t n = x.size(); + f[0] = 0.; + for(size_t k = 1; k < n; k++) + f[k] = x[k-1]; + } + }; } bool runge_45_2(void) -{ typedef CppAD::AD Scalar; - using CppAD::NearEqual; +{ typedef CppAD::AD Scalar; + using CppAD::NearEqual; - bool ok = true; // initial return value - size_t j; // temporary indices + bool ok = true; // initial return value + size_t j; // temporary indices - 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 - - // value of independent variable at which to record operations - CPPAD_TESTVECTOR(Scalar) ad_b(1); - ad_b[0] = 1.; - - // declare b to be the independent variable - Independent(ad_b); - - // object to evaluate ODE - Fun ad_F; - - // xi = X(0) - 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); - 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 - CppAD::ADFun f(ad_b, ad_xf); - - // evaluate f(b) - CPPAD_TESTVECTOR(double) b(1); - CPPAD_TESTVECTOR(double) xf(n); - b[0] = 1.; - xf = f.Forward(0, b); - - // check that f(b) = X(b, tf) - double tf = Value(ad_tf); - double term = 1; - double sum = 0; - double eps = 10. * CppAD::numeric_limits::epsilon(); - for(j = 0; j < n; j++) - { sum += term; - ok &= NearEqual(xf[j], b[0] * sum, eps, eps); - term *= tf; - term /= double(j+1); - } - - // evalute f'(b) - CPPAD_TESTVECTOR(double) d_xf(n); - d_xf = f.Jacobian(b); - - // check that f'(b) = partial of X(b, tf) w.r.t b - term = 1; - sum = 0; - for(j = 0; j < n; j++) - { sum += term; - ok &= NearEqual(d_xf[j], sum, eps, eps); - term *= tf; - term /= double(j+1); - } + 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 + + // value of independent variable at which to record operations + CPPAD_TESTVECTOR(Scalar) ad_b(1); + ad_b[0] = 1.; + + // declare b to be the independent variable + Independent(ad_b); + + // object to evaluate ODE + Fun ad_F; + + // xi = X(0) + 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); + 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 + CppAD::ADFun f(ad_b, ad_xf); + + // evaluate f(b) + CPPAD_TESTVECTOR(double) b(1); + CPPAD_TESTVECTOR(double) xf(n); + b[0] = 1.; + xf = f.Forward(0, b); + + // check that f(b) = X(b, tf) + double tf = Value(ad_tf); + double term = 1; + double sum = 0; + double eps = 10. * CppAD::numeric_limits::epsilon(); + for(j = 0; j < n; j++) + { sum += term; + ok &= NearEqual(xf[j], b[0] * sum, eps, eps); + term *= tf; + term /= double(j+1); + } + + // evalute f'(b) + CPPAD_TESTVECTOR(double) d_xf(n); + d_xf = f.Jacobian(b); + + // check that f'(b) = partial of X(b, tf) w.r.t b + term = 1; + sum = 0; + for(j = 0; j < n; j++) + { sum += term; + ok &= NearEqual(d_xf[j], sum, eps, eps); + term *= tf; + term /= double(j+1); + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/seq_property.cpp cppad-2019.02.00.0/example/general/seq_property.cpp --- cppad-2018.00.00.0/example/general/seq_property.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/seq_property.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,28 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin seq_property.cpp$$ $spell - op - arg - abs - var - VecAD + op + arg + abs + var + VecAD $$ $section ADFun Sequence Properties: Example and Test$$ -$mindex Domain Range Parameter size_var size_par size_op_arg size_VecAD$$ - - - -$code $srcfile%example/general/seq_property.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -35,109 +30,136 @@ # include +// Note that CPPAD_VEC_ENUM_TYPE is not part of CppAD API and may change +# define CPPAD_VEC_ENUM_TYPE unsigned char + bool seq_property(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // Use nvar to track the number of variables in the operation sequence. - // Start with one for the phantom variable at tape address zero. - size_t nvar = 1; - - // Use npar to track the number of parameters in the operation sequence. - size_t npar = 0; - - // Start with one for operator corresponding to phantom variable - size_t nop = 1; - - // Start with one for operator corresponding to phantom argument - size_t narg = 1; - - // Use ntext to track the number of characters used to label - // output generated using PrintFor commands. - size_t ntext = 0; - - // Use nvecad to track the number of VecAD vectors, plus the number - // of VecAD vector elements, in the operation sequence. - size_t nvecad = 0; - - // a VecAD vector - CppAD::VecAD v(2); - v[0] = 0; // requires the parameter 0, when becomes a variable - v[1] = 1; // requires the parameter 1, when becomes a variable - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = 0.; - x[1] = 1.; - - // declare independent variables and start tape recording - 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 - 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] - - // some operations that do not add to the operation sequence - AD u = x[0]; // use same variable as x[0] - AD w = x[1]; // use same variable as x[1] - - // a computation that adds to the operation sequence - 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 - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) y(m); - - // operations that do not add to the operation sequence - y[0] = 1.; // re-use the parameter 1 - y[1] = u; // use same variable as u - - // a computation that adds to the operation sequence - y[2] = w + 2.; - nop += 1; // requires a new add operator - npar += 1; // new parameter 2 is new, so it must be included - nvar += 1; // variable corresponding to the result - narg += 2; // operator has two arguments - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - nop += 1; // special operator for y[0] because 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] - nop += 1; // special operator at the end of operation sequence - - // check the sequence property functions - ok &= f.Domain() == n; - ok &= f.Range() == m; - ok &= f.Parameter(0) == true; - ok &= f.Parameter(1) == false; - ok &= f.Parameter(2) == false; - ok &= f.size_var() == nvar; - ok &= f.size_op() == nop; - ok &= f.size_op_arg() == narg; - ok &= f.size_par() == npar; - ok &= f.size_text() == ntext; - ok &= f.size_VecAD() == nvecad; - size_t sum = 0; - sum += nop * sizeof(CppAD::local::OpCode); - sum += narg * sizeof(CPPAD_TAPE_ADDR_TYPE); - sum += npar * sizeof(double); - sum += ntext * sizeof(char); - sum += nvecad * sizeof(CPPAD_TAPE_ADDR_TYPE); - sum += nop * sizeof(CPPAD_TAPE_ADDR_TYPE) * 3; - ok &= f.size_op_seq() == sum; + // Use nvar to track the number of variables in the operation sequence. + // Start with one for the phantom variable at tape address zero. + size_t nvar = 1; + + // Use npar to track the number of parameters in the operation sequence. + // Start with one for the phantom parameter at index zero. + size_t npar = 1; + + // Use ndyn to track the number of dynamic parameters. + size_t ndyn = 0; + + // Use ndyn to track number of arguments to dynamic parameter operators. + size_t ndyn_arg = 0; + + // Start with one for operator corresponding to phantom variable + size_t nop = 1; + + // Start with one for operator corresponding to phantom argument + size_t narg = 1; + + // Use ntext to track the number of characters used to label + // output generated using PrintFor commands. + size_t ntext = 0; + + // Use nvecad to track the number of VecAD vectors, plus the number + // of VecAD vector elements, in the operation sequence. + size_t nvecad = 0; + + // a VecAD vector + CppAD::VecAD v(2); + v[0] = 0; // requires the parameter 0, when becomes a variable + v[1] = 1; // requires the parameter 1, when becomes a variable + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = 0.; + x[1] = 1.; + + // dynamic parameter vector + CPPAD_TESTVECTOR(AD) dynamic(1); + dynamic[0] = 1.; + + + // declare independent variables and start tape recording + size_t abort_op_index = 0; + size_t record_compare = true; + CppAD::Independent(x, abort_op_index, record_compare, dynamic); + nvar += n; + nop += n; + ndyn += dynamic.size(); + npar += ndyn; + + // a computation that adds to the operation sequence + AD I = 0; + 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] + + // some operations that do not add to the operation sequence + AD u = x[0]; // use same variable as x[0] + AD w = x[1]; // use same variable as x[1] + + // a computation that adds to the operation sequence + 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 + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) y(m); + + // operations that do not add to the operation sequence + y[0] = 1.; // re-use the parameter 1 + y[1] = u; // use same variable as u + + // a computation that adds to the operation sequence + y[2] = w + 2.; + nop += 1; // requires a new add operator + npar += 1; // new parameter 2 is new, so it must be included + nvar += 1; // variable corresponding to the result + narg += 2; // operator has two arguments + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + nop += 1; // special operator for y[0] because 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] + nop += 1; // special operator at the end of operation sequence + + // check the sequence property functions + ok &= f.Domain() == n; + ok &= f.Range() == m; + ok &= f.Parameter(0) == true; + ok &= f.Parameter(1) == false; + ok &= f.Parameter(2) == false; + ok &= f.size_var() == nvar; + ok &= f.size_op() == nop; + ok &= f.size_op_arg() == narg; + ok &= f.size_par() == npar; + ok &= f.size_text() == ntext; + ok &= f.size_VecAD() == nvecad; + ok &= f.size_dyn_ind() == ndyn; + ok &= f.size_dyn_par() == ndyn; + ok &= f.size_dyn_arg() == ndyn_arg; + + // + size_t sum = 0; + sum += nop * sizeof(CPPAD_VEC_ENUM_TYPE); + sum += narg * sizeof(CPPAD_TAPE_ADDR_TYPE); + sum += npar * sizeof(double); + sum += npar * sizeof(bool); + sum += ndyn * sizeof(CPPAD_VEC_ENUM_TYPE); + sum += ndyn * sizeof(CPPAD_TAPE_ADDR_TYPE); + sum += ndyn_arg * sizeof(CPPAD_TAPE_ADDR_TYPE); + sum += ntext * sizeof(char); + sum += nvecad * sizeof(CPPAD_TAPE_ADDR_TYPE); + ok &= f.size_op_seq() == sum; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/sign.cpp cppad-2019.02.00.0/example/general/sign.cpp --- cppad-2018.00.00.0/example/general/sign.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/sign.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sign.cpp$$ @@ -17,9 +18,7 @@ $section Sign Function: Example and Test$$ -$code $srcfile%example/general/sign.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -28,60 +27,60 @@ # include bool sign(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; + using CppAD::AD; + using CppAD::NearEqual; - // create f: x -> y where f(x) = sign(x) - size_t n = 1; - size_t m = 1; - CPPAD_TESTVECTOR(AD) ax(n), ay(m); - ax[0] = 0.; - CppAD::Independent(ax); - ay[0] = sign(ax[0]); - CppAD::ADFun f(ax, ay); - - // check value during recording - ok &= (ay[0] == 0.); - - // 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.; - // - x[0] = 2.; - y = f.Forward(0, x); - ok &= (y[0] == 1.); - dy = f.Forward(1, dx); - ok &= (dy[0] == 0.); - dw = f.Reverse(1, w); - ok &= (dw[0] == 0.); - // - x[0] = 0.; - y = f.Forward(0, x); - ok &= (y[0] == 0.); - dy = f.Forward(1, dx); - ok &= (dy[0] == 0.); - dw = f.Reverse(1, w); - ok &= (dw[0] == 0.); - // - x[0] = -2.; - y = f.Forward(0, x); - ok &= (y[0] == -1.); - dy = f.Forward(1, dx); - ok &= (dy[0] == 0.); - dw = f.Reverse(1, w); - ok &= (dw[0] == 0.); - - // use a VecAD::reference object with sign - CppAD::VecAD v(1); - AD zero(0); - v[zero] = 2.; - AD result = sign(v[zero]); - ok &= (result == 1.); + // create f: x -> y where f(x) = sign(x) + size_t n = 1; + size_t m = 1; + CPPAD_TESTVECTOR(AD) ax(n), ay(m); + ax[0] = 0.; + CppAD::Independent(ax); + ay[0] = sign(ax[0]); + CppAD::ADFun f(ax, ay); + + // check value during recording + ok &= (ay[0] == 0.); + + // 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.; + // + x[0] = 2.; + y = f.Forward(0, x); + ok &= (y[0] == 1.); + dy = f.Forward(1, dx); + ok &= (dy[0] == 0.); + dw = f.Reverse(1, w); + ok &= (dw[0] == 0.); + // + x[0] = 0.; + y = f.Forward(0, x); + ok &= (y[0] == 0.); + dy = f.Forward(1, dx); + ok &= (dy[0] == 0.); + dw = f.Reverse(1, w); + ok &= (dw[0] == 0.); + // + x[0] = -2.; + y = f.Forward(0, x); + ok &= (y[0] == -1.); + dy = f.Forward(1, dx); + ok &= (dy[0] == 0.); + dw = f.Reverse(1, w); + ok &= (dw[0] == 0.); + + // use a VecAD::reference object with sign + CppAD::VecAD v(1); + AD zero(0); + v[zero] = 2.; + AD result = sign(v[zero]); + ok &= (result == 1.); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/sin.cpp cppad-2019.02.00.0/example/general/sin.cpp --- cppad-2018.00.00.0/example/general/sin.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/sin.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sin.cpp$$ $spell - sin + sin $$ $section The AD sin Function: Example and Test$$ -$code $srcfile%example/general/sin.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,57 +29,57 @@ # include bool Sin(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * 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); - - // 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); - - // check value - double check = std::sin(x0); - ok &= NearEqual(y[0] , check, eps99, eps99); - - // 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::cos(x0); - ok &= NearEqual(dy[0], check, eps99, eps99); - - // 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, eps99, eps99); - - // use a VecAD::reference object with sin - CppAD::VecAD v(1); - AD zero(0); - v[zero] = x0; - AD result = CppAD::sin(v[zero]); - check = std::sin(x0); - ok &= NearEqual(result, check, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * 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); + + // 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); + + // check value + double check = std::sin(x0); + ok &= NearEqual(y[0] , check, eps99, eps99); + + // 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::cos(x0); + ok &= NearEqual(dy[0], check, eps99, eps99); + + // 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, eps99, eps99); + + // use a VecAD::reference object with sin + CppAD::VecAD v(1); + AD zero(0); + v[zero] = x0; + AD result = CppAD::sin(v[zero]); + check = std::sin(x0); + ok &= NearEqual(result, check, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/sinh.cpp cppad-2019.02.00.0/example/general/sinh.cpp --- cppad-2018.00.00.0/example/general/sinh.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/sinh.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sinh.cpp$$ $spell - sinh + sinh $$ $section The AD sinh Function: Example and Test$$ -$code $srcfile%example/general/sinh.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,57 +29,57 @@ # include bool Sinh(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * 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); - - // 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); - - // check value - double check = std::sinh(x0); - ok &= NearEqual(y[0] , check, eps99, eps99); - - // 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::cosh(x0); - ok &= NearEqual(dy[0], check, eps99, eps99); - - // 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, eps99, eps99); - - // use a VecAD::reference object with sinh - CppAD::VecAD v(1); - AD zero(0); - v[zero] = x0; - AD result = CppAD::sinh(v[zero]); - check = std::sinh(x0); - ok &= NearEqual(result, check, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * 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); + + // 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); + + // check value + double check = std::sinh(x0); + ok &= NearEqual(y[0] , check, eps99, eps99); + + // 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::cosh(x0); + ok &= NearEqual(dy[0], check, eps99, eps99); + + // 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, eps99, eps99); + + // use a VecAD::reference object with sinh + CppAD::VecAD v(1); + AD zero(0); + v[zero] = x0; + AD result = CppAD::sinh(v[zero]); + check = std::sinh(x0); + ok &= NearEqual(result, check, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/sqrt.cpp cppad-2019.02.00.0/example/general/sqrt.cpp --- cppad-2018.00.00.0/example/general/sqrt.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/sqrt.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sqrt.cpp$$ $spell - sqrt + sqrt $$ $section The AD sqrt Function: Example and Test$$ -$code $srcfile%example/general/sqrt.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,57 +29,57 @@ # include bool Sqrt(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * 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); - - // 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); - - // check value - double check = std::sqrt(x0); - ok &= NearEqual(y[0] , check, eps99, eps99); - - // 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 = 1. / (2. * std::sqrt(x0) ); - ok &= NearEqual(dy[0], check, eps99, eps99); - - // 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, eps99, eps99); - - // use a VecAD::reference object with sqrt - CppAD::VecAD v(1); - AD zero(0); - v[zero] = x0; - AD result = CppAD::sqrt(v[zero]); - check = std::sqrt(x0); - ok &= NearEqual(result, check, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * 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); + + // 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); + + // check value + double check = std::sqrt(x0); + ok &= NearEqual(y[0] , check, eps99, eps99); + + // 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 = 1. / (2. * std::sqrt(x0) ); + ok &= NearEqual(dy[0], check, eps99, eps99); + + // 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, eps99, eps99); + + // use a VecAD::reference object with sqrt + CppAD::VecAD v(1); + AD zero(0); + v[zero] = x0; + AD result = CppAD::sqrt(v[zero]); + check = std::sqrt(x0); + ok &= NearEqual(result, check, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/stack_machine.cpp cppad-2019.02.00.0/example/general/stack_machine.cpp --- cppad-2018.00.00.0/example/general/stack_machine.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/stack_machine.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin stack_machine.cpp$$ $spell $$ $section Example Differentiating a Stack Machine Interpreter$$ -$mindex test$$ -$code $srcfile%example/general/stack_machine.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -38,179 +36,179 @@ // Begin empty namespace ------------------------------------------------ bool is_number( const std::string &s ) -{ char ch = s[0]; - bool number = (std::strchr("0123456789.", ch) != 0); - return number; +{ char ch = s[0]; + bool number = (std::strchr("0123456789.", ch) != 0); + return number; } bool is_binary( const std::string &s ) -{ char ch = s[0]; - bool binary = (strchr("+-*/.", ch) != 0); - return binary; +{ char ch = s[0]; + bool binary = (strchr("+-*/.", ch) != 0); + return binary; } bool is_variable( const std::string &s ) -{ char ch = s[0]; - bool variable = ('a' <= ch) & (ch <= 'z'); - return variable; +{ char ch = s[0]; + bool variable = ('a' <= ch) & (ch <= 'z'); + return variable; } void StackMachine( - std::stack< std::string > &token_stack , - CppAD::vector< CppAD::AD > &variable ) -{ using std::string; - using std::stack; - - using CppAD::AD; - - stack< AD > value_stack; - string token; - AD value_one; - AD value_two; - - while( ! token_stack.empty() ) - { string s = token_stack.top(); - token_stack.pop(); - - if( is_number(s) ) - { value_one = std::atof( s.c_str() ); - value_stack.push( value_one ); - } - else if( is_variable(s) ) - { value_one = variable[ size_t(s[0]) - size_t('a') ]; - value_stack.push( value_one ); - } - else if( is_binary(s) ) - { assert( value_stack.size() >= 2 ); - value_one = value_stack.top(); - value_stack.pop(); - value_two = value_stack.top(); - value_stack.pop(); - - switch( s[0] ) - { - case '+': - value_stack.push(value_one + value_two); - break; - - case '-': - value_stack.push(value_one - value_two); - break; - - case '*': - value_stack.push(value_one * value_two); - break; - - case '/': - value_stack.push(value_one / value_two); - break; - - default: - assert(0); - } - } - else if( s[0] == '=' ) - { assert( value_stack.size() >= 1 ); - assert( token_stack.size() >= 1 ); - // - s = token_stack.top(); - token_stack.pop(); - // - assert( is_variable( s ) ); - value_one = value_stack.top(); - value_stack.pop(); - // - variable[ size_t(s[0]) - size_t('a') ] = value_one; - } - else assert(0); - } - return; + std::stack< std::string > &token_stack , + CppAD::vector< CppAD::AD > &variable ) +{ using std::string; + using std::stack; + + using CppAD::AD; + + stack< AD > value_stack; + string token; + AD value_one; + AD value_two; + + while( ! token_stack.empty() ) + { string s = token_stack.top(); + token_stack.pop(); + + if( is_number(s) ) + { value_one = std::atof( s.c_str() ); + value_stack.push( value_one ); + } + else if( is_variable(s) ) + { value_one = variable[ size_t(s[0]) - size_t('a') ]; + value_stack.push( value_one ); + } + else if( is_binary(s) ) + { assert( value_stack.size() >= 2 ); + value_one = value_stack.top(); + value_stack.pop(); + value_two = value_stack.top(); + value_stack.pop(); + + switch( s[0] ) + { + case '+': + value_stack.push(value_one + value_two); + break; + + case '-': + value_stack.push(value_one - value_two); + break; + + case '*': + value_stack.push(value_one * value_two); + break; + + case '/': + value_stack.push(value_one / value_two); + break; + + default: + assert(0); + } + } + else if( s[0] == '=' ) + { assert( value_stack.size() >= 1 ); + assert( token_stack.size() >= 1 ); + // + s = token_stack.top(); + token_stack.pop(); + // + assert( is_variable( s ) ); + value_one = value_stack.top(); + value_stack.pop(); + // + variable[ size_t(s[0]) - size_t('a') ] = value_one; + } + else assert(0); + } + return; } // End empty namespace ------------------------------------------------------- } bool StackMachine(void) -{ bool ok = true; +{ bool ok = true; - using std::string; - using std::stack; + using std::string; + using std::stack; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - using CppAD::vector; - - // The users program in that stack machine language - const char *program[] = { - "1.0", "a", "+", "=", "b", // b = a + 1 - "2.0", "b", "*", "=", "c", // c = b * 2 - "3.0", "c", "-", "=", "d", // d = c - 3 - "4.0", "d", "/", "=", "e" // e = d / 4 - }; - size_t n_program = sizeof( program ) / sizeof( program[0] ); - - // put the program in the token stack - stack< string > token_stack; - size_t i = n_program; - while(i--) - token_stack.push( program[i] ); - - // domain space vector - size_t n = 1; - vector< AD > X(n); - X[0] = 0.; - - // 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]; - - // calculate the resutls of the program - StackMachine( token_stack , variable); - - // range space vector - size_t m = 4; - vector< AD > Y(m); - 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 - - // create f : X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // use forward mode to evaluate function at different argument value - size_t p = 0; - vector x(n); - vector y(m); - x[0] = 1.; - y = f.Forward(p, x); - - // check function values - ok &= (y[0] == x[0] + 1.); - ok &= (y[1] == (x[0] + 1.) * 2.); - ok &= (y[2] == (x[0] + 1.) * 2. - 3.); - ok &= (y[3] == ( (x[0] + 1.) * 2. - 3.) / 4.); - - // Use forward mode (because x is shorter than y) to calculate Jacobian - p = 1; - vector dx(n); - vector dy(m); - dx[0] = 1.; - dy = f.Forward(p, dx); - ok &= NearEqual(dy[0], 1., eps99, eps99); - ok &= NearEqual(dy[1], 2., eps99, eps99); - ok &= NearEqual(dy[2], 2., eps99, eps99); - ok &= NearEqual(dy[3], .5, eps99, eps99); - - // Use Jacobian routine (which automatically decides which mode to use) - dy = f.Jacobian(x); - ok &= NearEqual(dy[0], 1., eps99, eps99); - ok &= NearEqual(dy[1], 2., eps99, eps99); - ok &= NearEqual(dy[2], 2., eps99, eps99); - ok &= NearEqual(dy[3], .5, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + using CppAD::vector; + + // The users program in that stack machine language + const char *program[] = { + "1.0", "a", "+", "=", "b", // b = a + 1 + "2.0", "b", "*", "=", "c", // c = b * 2 + "3.0", "c", "-", "=", "d", // d = c - 3 + "4.0", "d", "/", "=", "e" // e = d / 4 + }; + size_t n_program = sizeof( program ) / sizeof( program[0] ); + + // put the program in the token stack + stack< string > token_stack; + size_t i = n_program; + while(i--) + token_stack.push( program[i] ); + + // domain space vector + size_t n = 1; + vector< AD > X(n); + X[0] = 0.; + + // 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]; + + // calculate the resutls of the program + StackMachine( token_stack , variable); + + // range space vector + size_t m = 4; + vector< AD > Y(m); + 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 + + // create f : X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // use forward mode to evaluate function at different argument value + size_t p = 0; + vector x(n); + vector y(m); + x[0] = 1.; + y = f.Forward(p, x); + + // check function values + ok &= (y[0] == x[0] + 1.); + ok &= (y[1] == (x[0] + 1.) * 2.); + ok &= (y[2] == (x[0] + 1.) * 2. - 3.); + ok &= (y[3] == ( (x[0] + 1.) * 2. - 3.) / 4.); + + // Use forward mode (because x is shorter than y) to calculate Jacobian + p = 1; + vector dx(n); + vector dy(m); + dx[0] = 1.; + dy = f.Forward(p, dx); + ok &= NearEqual(dy[0], 1., eps99, eps99); + ok &= NearEqual(dy[1], 2., eps99, eps99); + ok &= NearEqual(dy[2], 2., eps99, eps99); + ok &= NearEqual(dy[3], .5, eps99, eps99); + + // Use Jacobian routine (which automatically decides which mode to use) + dy = f.Jacobian(x); + ok &= NearEqual(dy[0], 1., eps99, eps99); + ok &= NearEqual(dy[1], 2., eps99, eps99); + ok &= NearEqual(dy[2], 2., eps99, eps99); + ok &= NearEqual(dy[3], .5, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/sub.cpp cppad-2019.02.00.0/example/general/sub.cpp --- cppad-2018.00.00.0/example/general/sub.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/sub.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,22 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sub.cpp$$ $section AD Binary Subtraction: Example and Test$$ -$mindex - subtract minus$$ -$code $srcfile%example/general/sub.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -26,58 +24,58 @@ # include bool Sub(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - double x0 = .5; - CPPAD_TESTVECTOR(AD) x(1); - x[0] = x0; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - 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 - - // 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); - - // check value - ok &= NearEqual(y[0], x0-4.+3.+2.-2.*x0+1., eps99, eps99); - - // forward computation of partials 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., eps99, eps99); - - // 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., eps99, eps99); - - // use a VecAD::reference object with subtraction - CppAD::VecAD v(1); - AD zero(0); - v[zero] = b; - AD result = 3. - v[zero]; - ok &= (result == c); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = .5; + CPPAD_TESTVECTOR(AD) x(1); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + 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 + + // 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); + + // check value + ok &= NearEqual(y[0], x0-4.+3.+2.-2.*x0+1., eps99, eps99); + + // forward computation of partials 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., eps99, eps99); + + // 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., eps99, eps99); + + // use a VecAD::reference object with subtraction + CppAD::VecAD v(1); + AD zero(0); + v[zero] = b; + AD result = 3. - v[zero]; + ok &= (result == c); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/sub_eq.cpp cppad-2019.02.00.0/example/general/sub_eq.cpp --- cppad-2018.00.00.0/example/general/sub_eq.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/sub_eq.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sub_eq.cpp$$ $section AD Compound Assignment Subtraction: Example and Test$$ -$mindex -= subtract assign plus add$$ -$code $srcfile%example/general/sub_eq.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -27,60 +25,60 @@ # include bool SubEq(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - double x0 = .5; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // range space vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = 3. * x[0]; // initial value - y[0] -= 2; // AD -= int - y[0] -= 4.; // AD -= double - y[1] = y[0] -= x[0]; // use the result of a compound assignment - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // check value - ok &= NearEqual(y[0] , 3.*x0-(2.+4.+x0), eps99, eps99); - ok &= NearEqual(y[1] , y[0], eps99, eps99); - - // forward computation of partials 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], 2., eps99, eps99); - ok &= NearEqual(dy[1], 2., eps99, eps99); - - // reverse computation of derivative of y[0] - CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); - w[0] = 1.; - w[1] = 0.; - dw = f.Reverse(1, w); - ok &= NearEqual(dw[0], 2., eps99, eps99); - - // use a VecAD::reference object with computed subtraction - CppAD::VecAD v(1); - AD zero(0); - AD result = 1; - v[zero] = 2; - result -= v[zero]; - ok &= (result == -1); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = .5; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // range space vector + size_t m = 2; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = 3. * x[0]; // initial value + y[0] -= 2; // AD -= int + y[0] -= 4.; // AD -= double + y[1] = y[0] -= x[0]; // use the result of a compound assignment + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check value + ok &= NearEqual(y[0] , 3.*x0-(2.+4.+x0), eps99, eps99); + ok &= NearEqual(y[1] , y[0], eps99, eps99); + + // forward computation of partials 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], 2., eps99, eps99); + ok &= NearEqual(dy[1], 2., eps99, eps99); + + // reverse computation of derivative of y[0] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + w[1] = 0.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], 2., eps99, eps99); + + // use a VecAD::reference object with computed subtraction + CppAD::VecAD v(1); + AD zero(0); + AD result = 1; + v[zero] = 2; + result -= v[zero]; + ok &= (result == -1); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/tan.cpp cppad-2019.02.00.0/example/general/tan.cpp --- cppad-2018.00.00.0/example/general/tan.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/tan.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin tan.cpp$$ $spell - tan - tan + tan + tan $$ $section The AD tan Function: Example and Test$$ -$code $srcfile%example/general/tan.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -32,57 +31,57 @@ # include bool Tan(void) -{ bool ok = true; +{ 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; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // 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); - - // check value - double check = std::tan(x0); - ok &= NearEqual(y[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 = 1. + std::tan(x0) * std::tan(x0); - 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, eps, eps); - - // use a VecAD::reference object with tan - CppAD::VecAD v(1); - AD zero(0); - v[zero] = x0; - AD result = CppAD::tan(v[zero]); - check = std::tan(x0); - ok &= NearEqual(result, check, eps, eps); + 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; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // 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); + + // check value + double check = std::tan(x0); + ok &= NearEqual(y[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 = 1. + std::tan(x0) * std::tan(x0); + 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, eps, eps); + + // use a VecAD::reference object with tan + CppAD::VecAD v(1); + AD zero(0); + v[zero] = x0; + AD result = CppAD::tan(v[zero]); + check = std::tan(x0); + ok &= NearEqual(result, check, eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/tanh.cpp cppad-2019.02.00.0/example/general/tanh.cpp --- cppad-2018.00.00.0/example/general/tanh.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/tanh.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin tanh.cpp$$ $spell - tanh + tanh $$ $section The AD tanh Function: Example and Test$$ -$code $srcfile%example/general/tanh.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,57 +30,57 @@ # include bool Tanh(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * CppAD::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); - - // 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); - - // check value - double check = std::tanh(x0); - ok &= NearEqual(y[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 = 1. - std::tanh(x0) * std::tanh(x0); - 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, eps, eps); - - // use a VecAD::reference object with tan - CppAD::VecAD v(1); - AD zero(0); - v[zero] = x0; - AD result = CppAD::tanh(v[zero]); - check = std::tanh(x0); - ok &= NearEqual(result, check, eps, eps); + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::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); + + // 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); + + // check value + double check = std::tanh(x0); + ok &= NearEqual(y[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 = 1. - std::tanh(x0) * std::tanh(x0); + 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, eps, eps); + + // use a VecAD::reference object with tan + CppAD::VecAD v(1); + AD zero(0); + v[zero] = x0; + AD result = CppAD::tanh(v[zero]); + check = std::tanh(x0); + ok &= NearEqual(result, check, eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/tape_index.cpp cppad-2019.02.00.0/example/general/tape_index.cpp --- cppad-2018.00.00.0/example/general/tape_index.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/tape_index.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,22 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin tape_index.cpp$$ $section Taping Array Index Operation: Example and Test$$ -$mindex tape operation$$ -$code $srcfile%example/general/tape_index.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -26,74 +24,74 @@ # include namespace { - double Array(const double &index) - { static double array[] = { - 5., - 4., - 3., - 2., - 1. - }; - static size_t number = sizeof(array) / sizeof(array[0]); - if( index < 0. ) - return array[0]; - - size_t i = static_cast(index); - if( i >= number ) - return array[number-1]; - - return array[i]; - } - // in empty namespace and outside any other routine - CPPAD_DISCRETE_FUNCTION(double, Array) + double Array(const double &index) + { static double array[] = { + 5., + 4., + 3., + 2., + 1. + }; + static size_t number = sizeof(array) / sizeof(array[0]); + if( index < 0. ) + return array[0]; + + size_t i = static_cast(index); + if( i >= number ) + return array[number-1]; + + return array[i]; + } + // in empty namespace and outside any other routine + CPPAD_DISCRETE_FUNCTION(double, Array) } bool TapeIndex(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 2.; // array index value - X[1] = 3.; // multiplier of array index value - - // declare independent variables and start tape recording - CppAD::Independent(X); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[1] * Array( X[0] ); - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // 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) dw(n); // derivative of weighted function - - // check function value - x[0] = Value(X[0]); - x[1] = Value(X[1]); - y[0] = Value(Y[0]); - ok &= y[0] == x[1] * Array(x[0]); - - // evaluate f where x has different values - x[0] = x[0] + 1.; // new array index value - x[1] = x[1] + 1.; // new multiplier value - y = f.Forward(0, x); - ok &= y[0] == x[1] * Array(x[0]); - - // evaluate derivaitve of y[0] - w[0] = 1.; - dw = f.Reverse(1, w); - ok &= dw[0] == 0.; // partial w.r.t array index - ok &= dw[1] == Array(x[0]); // partial w.r.t multiplier + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 2.; // array index value + X[1] = 3.; // multiplier of array index value + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[1] * Array( X[0] ); + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // 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) dw(n); // derivative of weighted function + + // check function value + x[0] = Value(X[0]); + x[1] = Value(X[1]); + y[0] = Value(Y[0]); + ok &= y[0] == x[1] * Array(x[0]); + + // evaluate f where x has different values + x[0] = x[0] + 1.; // new array index value + x[1] = x[1] + 1.; // new multiplier value + y = f.Forward(0, x); + ok &= y[0] == x[1] * Array(x[0]); + + // evaluate derivaitve of y[0] + w[0] = 1.; + dw = f.Reverse(1, w); + ok &= dw[0] == 0.; // partial w.r.t array index + ok &= dw[1] == Array(x[0]); // partial w.r.t multiplier - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/taylor_ode.cpp cppad-2019.02.00.0/example/general/taylor_ode.cpp --- cppad-2018.00.00.0/example/general/taylor_ode.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/general/taylor_ode.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,151 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin taylor_ode.cpp$$ +$spell + Taylor + Cpp + const + std + Adolc + adouble +$$ + +$section Taylor's Ode Solver: An Example and Test$$ + +$head Purpose$$ +This example uses the method described in $cref taylor_ode$$ +to solve an ODE. + +$head ODE$$ +The ODE is defined by +$latex y(0) = 0$$ and $latex y^1 (t) = g[ y(t) ]$$ +where the function +$latex g : \B{R}^n \rightarrow \B{R}^n$$ is defined by +$latex \[ + g(y) + = + \left( \begin{array}{c} + 1 \\ + y_1 \\ + \vdots \\ + y_{n-1} + \end{array} \right) +\] $$ +and the initial condition is $latex z(0) = 0$$. + +$head ODE Solution$$ +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 +$latex \[ + y(t) = + \left( \begin{array}{c} + t \\ + t^2 / 2 \\ + \vdots \\ + t^n / n ! + \end{array} \right) +\] $$ + +$srcfile%example/general/taylor_ode.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +-------------------------------------------------------------------------- +*/ +// BEGIN C++ + +# include + +// ========================================================================= +// define types for each level +namespace { // BEGIN empty namespace + + typedef CppAD::AD a_double; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR(a_double) a_vector; + + a_vector ode(const a_vector y) + { size_t n = y.size(); + a_vector g(n); + g[0] = 1; + for(size_t k = 1; k < n; k++) + g[k] = y[k-1]; + return g; + } + +} + +// ------------------------------------------------------------------------- +// use Taylor's method to solve this ordinary differential equaiton +bool taylor_ode(void) +{ // initialize the return value as true + bool ok = true; + + // The ODE does not depend on the arugment values + // so only tape once, also note that ode does not depend on t + size_t n = 5; // number of independent and dependent variables + a_vector ay(n), ag(n); + CppAD::Independent( ay ); + ag = ode(ay); + CppAD::ADFun g(ay, ag); + + // initialize the solution vector at time zero + d_vector y(n); + for(size_t j = 0; j < n; j++) + y[j] = 0.0; + + size_t order = n; // order of the Taylor method + size_t n_step = 4; // number of time steps + double dt = 0.5; // step size in time + + // Taylor coefficients of order k + d_vector yk(n), zk(n); + + // loop with respect to each step of Taylor's method + for(size_t i_step = 0; i_step < n_step; i_step++) + { // Use Taylor's method to take a step + yk = y; // initialize y^{(k)} for k = 0 + double dt_kp = dt; // initialize dt^(k+1) for k = 0 + for(size_t k = 0; k < order; k++) + { // evaluate k-th order Taylor coefficient of z(t) = g(y(t)) + zk = g.Forward(k, yk); + + for(size_t j = 0; j < n; j++) + { // convert to (k+1)-Taylor coefficient for y + yk[j] = zk[j] / double(k + 1); + + // add term for to this Taylor coefficient + // to solution for y(t, x) + y[j] += yk[j] * dt_kp; + } + // next power of t + dt_kp *= dt; + } + } + + // 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.; + double t = double(n_step) * dt; + for(size_t i = 0; i < n; i++) + { check *= t / double(i + 1); + ok &= CppAD::NearEqual(y[i], check, eps, eps); + } + + return ok; +} + +// END C++ diff -Nru cppad-2018.00.00.0/example/general/unary_minus.cpp cppad-2019.02.00.0/example/general/unary_minus.cpp --- cppad-2018.00.00.0/example/general/unary_minus.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/unary_minus.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin unary_minus.cpp$$ $spell - Cpp - cstddef + Cpp + cstddef $$ $section AD Unary Minus Operator: Example and Test$$ -$code $srcfile%example/general/unary_minus.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,51 +29,51 @@ # include bool UnaryMinus(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = 3.; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = - x[0]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // check values - ok &= ( y[0] == -3. ); - - // forward computation of partials w.r.t. x[0] - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - size_t p = 1; - dx[0] = 1.; - dy = f.Forward(p, dx); - ok &= ( dy[0] == -1. ); // dy[0] / dx[0] - - // reverse computation of dertivative of y[0] - CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); - w[0] = 1.; - dw = f.Reverse(p, w); - ok &= ( dw[0] == -1. ); // dy[0] / dx[0] - - // use a VecAD::reference object with unary minus - CppAD::VecAD v(1); - AD zero(0); - v[zero] = x[0]; - AD result = - v[zero]; - ok &= (result == y[0]); + // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = 3.; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = - x[0]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check values + ok &= ( y[0] == -3. ); + + // forward computation of partials w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + size_t p = 1; + dx[0] = 1.; + dy = f.Forward(p, dx); + ok &= ( dy[0] == -1. ); // dy[0] / dx[0] + + // reverse computation of dertivative of y[0] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + dw = f.Reverse(p, w); + ok &= ( dw[0] == -1. ); // dy[0] / dx[0] + + // use a VecAD::reference object with unary minus + CppAD::VecAD v(1); + AD zero(0); + v[zero] = x[0]; + AD result = - v[zero]; + ok &= (result == y[0]); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/unary_plus.cpp cppad-2019.02.00.0/example/general/unary_plus.cpp --- cppad-2018.00.00.0/example/general/unary_plus.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/general/unary_plus.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin unary_plus.cpp$$ $spell - Cpp - cstddef + Cpp + cstddef $$ $section AD Unary Plus Operator: Example and Test$$ -$code $srcfile%example/general/unary_plus.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,51 +29,51 @@ # include bool UnaryPlus(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = 3.; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = + x[0]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // check values - ok &= ( y[0] == 3. ); - - // forward computation of partials w.r.t. x[0] - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - size_t p = 1; - dx[0] = 1.; - dy = f.Forward(p, dx); - ok &= ( dy[0] == 1. ); // dy[0] / dx[0] - - // reverse computation of dertivative of y[0] - CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); - w[0] = 1.; - dw = f.Reverse(p, w); - ok &= ( dw[0] == 1. ); // dy[0] / dx[0] - - // use a VecAD::reference object with unary plus - CppAD::VecAD v(1); - AD zero(0); - v[zero] = x[0]; - AD result = + v[zero]; - ok &= (result == y[0]); + // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = 3.; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = + x[0]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check values + ok &= ( y[0] == 3. ); + + // forward computation of partials w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + size_t p = 1; + dx[0] = 1.; + dy = f.Forward(p, dx); + ok &= ( dy[0] == 1. ); // dy[0] / dx[0] + + // reverse computation of dertivative of y[0] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + dw = f.Reverse(p, w); + ok &= ( dw[0] == 1. ); // dy[0] / dx[0] + + // use a VecAD::reference object with unary plus + CppAD::VecAD v(1); + AD zero(0); + v[zero] = x[0]; + AD result = + v[zero]; + ok &= (result == y[0]); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/value.cpp cppad-2019.02.00.0/example/general/value.cpp --- cppad-2018.00.00.0/example/general/value.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/value.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin value.cpp$$ $spell - Cpp - cstddef + Cpp + cstddef $$ $section Convert From AD to its Base Type: Example and Test$$ -$mindex Value record$$ -$code $srcfile%example/general/value.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,40 +29,40 @@ # include bool Value(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::Value; - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = 3.; - x[1] = 4.; - - // check value before recording - ok &= (Value(x[0]) == 3.); - ok &= (Value(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] = - x[1]; - - // cannot call Value(x[j]) or Value(y[0]) here (currently variables) - AD p = 5.; // p is a parameter (does not depend on x) - ok &= (Value(p) == 5.); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // can call Value(x[j]) or Value(y[0]) here (currently parameters) - ok &= (Value(x[0]) == 3.); - ok &= (Value(x[1]) == 4.); - ok &= (Value(y[0]) == -4.); +{ bool ok = true; + using CppAD::AD; + using CppAD::Value; + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = 3.; + x[1] = 4.; + + // check value before recording + ok &= (Value(x[0]) == 3.); + ok &= (Value(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] = - x[1]; + + // cannot call Value(x[j]) or Value(y[0]) here (currently variables) + AD p = 5.; // p is a parameter (does not depend on x) + ok &= (Value(p) == 5.); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // can call Value(x[j]) or Value(y[0]) here (currently parameters) + ok &= (Value(x[0]) == 3.); + ok &= (Value(x[1]) == 4.); + ok &= (Value(y[0]) == -4.); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/var2par.cpp cppad-2019.02.00.0/example/general/var2par.cpp --- cppad-2018.00.00.0/example/general/var2par.cpp 2018-01-01 08:32:16.000000000 +0000 +++ cppad-2019.02.00.0/example/general/var2par.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin var2par.cpp$$ $spell - Var - Cpp + Var + Cpp $$ $section Convert an AD Variable to a Parameter: Example and Test$$ -$mindex Var2Par Value during taping$$ -$code $srcfile%example/general/var2par.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -32,46 +30,46 @@ bool Var2Par(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::Value; - using CppAD::Var2Par; - - // 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] = - 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. ); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // can call Value(x[j]) or Value(y[0]) here (currently parameters) - ok &= (Value(x[0]) == 3.); - ok &= (Value(x[1]) == 4.); - ok &= (Value(y[0]) == -12.); - - // evaluate derivative of y w.r.t x - CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); - w[0] = 1.; - dw = f.Reverse(1, w); - ok &= (dw[0] == 0.); // derivative of y[0] w.r.t x[0] is zero - ok &= (dw[1] == -3.); // derivative of y[0] w.r.t x[1] is 3 +{ bool ok = true; + using CppAD::AD; + using CppAD::Value; + using CppAD::Var2Par; + + // 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] = - 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. ); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // can call Value(x[j]) or Value(y[0]) here (currently parameters) + ok &= (Value(x[0]) == 3.); + ok &= (Value(x[1]) == 4.); + ok &= (Value(y[0]) == -12.); + + // evaluate derivative of y w.r.t x + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + dw = f.Reverse(1, w); + ok &= (dw[0] == 0.); // derivative of y[0] w.r.t x[0] is zero + ok &= (dw[1] == -3.); // derivative of y[0] w.r.t x[1] is 3 - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/general/vec_ad.cpp cppad-2019.02.00.0/example/general/vec_ad.cpp --- cppad-2018.00.00.0/example/general/vec_ad.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/general/vec_ad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,27 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin vec_ad.cpp$$ $spell - Vec - Cpp - cstddef + Vec + Cpp + cstddef $$ $section AD Vectors that Record Index Operations: Example and Test$$ -$mindex VecAD vec_ad.cpp$$ -$code $srcfile%example/general/vec_ad.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -33,144 +31,144 @@ # include namespace { - // 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); - - // copy the vector b into the VecAD object B - 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); - for(u = 0; u < 4; u += 1.) - A[u] = a [ Integer(u) ]; - - // tape AD operation sequence that determines the row of A - // with maximum absolute element in column zero - AD zero(0), one(1); - AD rmax = CondExpGt(fabs(a[0]), fabs(a[2]), zero, one); - - // divide row rmax by A(rmax, 0) - A[rmax * 2 + 1] = A[rmax * 2 + 1] / A[rmax * 2 + 0]; - B[rmax] = B[rmax] / A[rmax * 2 + 0]; - A[rmax * 2 + 0] = one; - - // subtract A(other,0) times row A(rmax, *) from row A(other,*) - AD other = one - rmax; - A[other * 2 + 1] = A[other * 2 + 1] - - A[other * 2 + 0] * A[rmax * 2 + 1]; - B[other] = B[other] - - A[other * 2 + 0] * B[rmax]; - A[other * 2 + 0] = zero; - - // back substitute to compute the solution vector x. - // Note that the columns of A correspond to rows of x. - // Also note that A[rmax * 2 + 0] is equal to one. - CPPAD_TESTVECTOR(AD) x(2); - x[1] = B[other] / A[other * 2 + 1]; - x[0] = B[rmax] - A[rmax * 2 + 1] * x[1]; + // 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); + + // copy the vector b into the VecAD object B + VecAD B(2); + AD u; + for(u = 0; u < 2; u += 1.) + B[u] = b[ size_t( Integer(u) ) ]; + + // copy the matrix a into the VecAD object A + VecAD A(4); + for(u = 0; u < 4; u += 1.) + A[u] = a [ size_t( Integer(u) ) ]; + + // tape AD operation sequence that determines the row of A + // with maximum absolute element in column zero + AD zero(0), one(1); + AD rmax = CondExpGt(fabs(a[0]), fabs(a[2]), zero, one); + + // divide row rmax by A(rmax, 0) + A[rmax * 2 + 1] = A[rmax * 2 + 1] / A[rmax * 2 + 0]; + B[rmax] = B[rmax] / A[rmax * 2 + 0]; + A[rmax * 2 + 0] = one; + + // subtract A(other,0) times row A(rmax, *) from row A(other,*) + AD other = one - rmax; + A[other * 2 + 1] = A[other * 2 + 1] + - A[other * 2 + 0] * A[rmax * 2 + 1]; + B[other] = B[other] + - A[other * 2 + 0] * B[rmax]; + A[other * 2 + 0] = zero; + + // back substitute to compute the solution vector x. + // Note that the columns of A correspond to rows of x. + // Also note that A[rmax * 2 + 0] is equal to one. + CPPAD_TESTVECTOR(AD) x(2); + x[1] = B[other] / A[other * 2 + 1]; + x[0] = B[rmax] - A[rmax * 2 + 1] * x[1]; - return x; - } + return x; + } } bool vec_ad(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 4; - 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.; - - // declare independent variables and start tape recording - CppAD::Independent(X); - - // define the vector b - CPPAD_TESTVECTOR(double) b(2); - CPPAD_TESTVECTOR(AD) B(2); - B[0] = b[0] = 0.; - B[1] = b[1] = 1.; - - // range space vector solves X * Y = b - size_t m = 2; - CPPAD_TESTVECTOR(AD) Y(m); - Y = Solve(X, B); - - // create f: X -> Y and stop tape recording - 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 - ok &= NearEqual(Y[0] , num0 / den, eps99, eps99); - ok &= NearEqual(Y[1] , num1 / den, eps99, eps99); - - // forward computation of partials w.r.t. x[0] - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - dx[0] = 1.; dx[1] = 0.; - dx[2] = 0.; dx[3] = 0.; - dy = f.Forward(1, dx); - ok &= NearEqual(dy[0], 0. - num0 * x[3] / dsq, eps99, eps99); - ok &= NearEqual(dy[1], b[1] / den - num1 * x[3] / dsq, eps99, eps99); - - // compute the solution for a new x matrix such that pivioting - // on the original rmax row would divide by zero - CPPAD_TESTVECTOR(double) y(m); - x[0] = 0.; x[1] = 2.; - x[2] = 2.; x[3] = 0.; - - // new values for Cramer's rule - den = x[0] * x[3] - x[1] * x[2]; - dsq = den * den; - num0 = b[0] * x[3] - x[1] * b[1]; - num1 = x[0] * b[1] - b[0] * x[2]; - - // check values - y = f.Forward(0, x); - ok &= NearEqual(y[0] , num0 / den, eps99, eps99); - ok &= NearEqual(y[1] , num1 / den, eps99, eps99); - - // forward computation of partials w.r.t. x[1] - dx[0] = 0.; dx[1] = 1.; - dx[2] = 0.; dx[3] = 0.; - dy = f.Forward(1, dx); - ok &= NearEqual(dy[0],-b[1] / den + num0 * x[2] / dsq, eps99, eps99); - ok &= NearEqual(dy[1], 0. + num1 * x[2] / dsq, eps99, eps99); - - // reverse computation of derivative of y[0] w.r.t x - CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); - w[0] = 1.; w[1] = 0.; - dw = f.Reverse(1, w); - ok &= NearEqual(dw[0], 0. - num0 * x[3] / dsq, eps99, eps99); - ok &= NearEqual(dw[1],-b[1] / den + num0 * x[2] / dsq, eps99, eps99); - ok &= NearEqual(dw[2], 0. + num0 * x[1] / dsq, eps99, eps99); - ok &= NearEqual(dw[3], b[0] / den - num0 * x[0] / dsq, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 4; + 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.; + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // define the vector b + CPPAD_TESTVECTOR(double) b(2); + CPPAD_TESTVECTOR(AD) B(2); + B[0] = b[0] = 0.; + B[1] = b[1] = 1.; + + // range space vector solves X * Y = b + size_t m = 2; + CPPAD_TESTVECTOR(AD) Y(m); + Y = Solve(X, B); + + // create f: X -> Y and stop tape recording + 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 + ok &= NearEqual(Y[0] , num0 / den, eps99, eps99); + ok &= NearEqual(Y[1] , num1 / den, eps99, eps99); + + // forward computation of partials w.r.t. x[0] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; dx[1] = 0.; + dx[2] = 0.; dx[3] = 0.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 0. - num0 * x[3] / dsq, eps99, eps99); + ok &= NearEqual(dy[1], b[1] / den - num1 * x[3] / dsq, eps99, eps99); + + // compute the solution for a new x matrix such that pivioting + // on the original rmax row would divide by zero + CPPAD_TESTVECTOR(double) y(m); + x[0] = 0.; x[1] = 2.; + x[2] = 2.; x[3] = 0.; + + // new values for Cramer's rule + den = x[0] * x[3] - x[1] * x[2]; + dsq = den * den; + num0 = b[0] * x[3] - x[1] * b[1]; + num1 = x[0] * b[1] - b[0] * x[2]; + + // check values + y = f.Forward(0, x); + ok &= NearEqual(y[0] , num0 / den, eps99, eps99); + ok &= NearEqual(y[1] , num1 / den, eps99, eps99); + + // forward computation of partials w.r.t. x[1] + dx[0] = 0.; dx[1] = 1.; + dx[2] = 0.; dx[3] = 0.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0],-b[1] / den + num0 * x[2] / dsq, eps99, eps99); + ok &= NearEqual(dy[1], 0. + num1 * x[2] / dsq, eps99, eps99); + + // reverse computation of derivative of y[0] w.r.t x + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; w[1] = 0.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], 0. - num0 * x[3] / dsq, eps99, eps99); + ok &= NearEqual(dw[1],-b[1] / den + num0 * x[2] / dsq, eps99, eps99); + ok &= NearEqual(dw[2], 0. + num0 * x[1] / dsq, eps99, eps99); + ok &= NearEqual(dw[3], b[0] / den - num0 * x[0] / dsq, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/get_started/CMakeLists.txt cppad-2019.02.00.0/example/get_started/CMakeLists.txt --- cppad-2018.00.00.0/example/get_started/CMakeLists.txt 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/get_started/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the example/get_started directory tests # @@ -18,8 +19,8 @@ # # Add the check for this target ADD_CUSTOM_TARGET(check_example_get_started - example_get_started - DEPENDS example_get_started + example_get_started + DEPENDS example_get_started ) MESSAGE(STATUS "make check_example_get_started: available") # diff -Nru cppad-2018.00.00.0/example/get_started/get_started.cpp cppad-2019.02.00.0/example/get_started/get_started.cpp --- cppad-2018.00.00.0/example/get_started/get_started.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/get_started/get_started.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,34 +1,32 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin get_started.cpp$$ $spell - cppad.hpp - http://www.coin-or.org/CppAD/ - getstarted - namespace - iostream - const - std - powx - Jacobian - jac - endl - da - cout + cppad.hpp + http://www.coin-or.org/CppAD/ + namespace + iostream + const + std + Jacobian + jac + endl + cout + cmake $$ $section Getting Started Using CppAD to Compute Derivatives$$ -$mindex simple example start$$ $head Purpose$$ Demonstrate the use of CppAD by computing the derivative @@ -37,14 +35,14 @@ $head Function$$ 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} + f(x) = a_0 + a_1 * x^1 + \cdots + a_{k-1} * x^{k-1} \] $$ where $icode a$$ is a fixed vector of length $icode k$$. $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$$ @@ -54,104 +52,127 @@ $latex x = 3$$. If follows that $latex \[ - f' ( 3 ) = 1 + 2 * 3 + 3 * 3^2 + 4 * 3^3 = 142 + f' ( 3 ) = 1 + 2 * 3 + 3 * 3^2 + 4 * 3^3 = 142 \] $$ +$head Include File$$ +The following command, in the program below, includes the CppAD package: +$codei% + # include +%$$ + $head Poly$$ -The routine $code Poly$$ is defined below for this particular application. +The routine $code Poly$$, defined below, evaluates a polynomial. A general purpose polynomial evaluation routine is documented and -distributed with CppAD (see $cref Poly$$). - -$head Exercises$$ -Modify the program below to accomplish the following tasks -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$$. -$lnext -Compute and print the derivative of $latex f(x) = 1 + x + x^2 / 2$$ -at the point $latex x = .5$$. -$lnext -Compute and print the derivative of $latex f(x) = \exp (x) - 1 - x - x^2 / 2$$ -at the point $latex x = .5$$. -$lend +distributed with CppAD; see $cref Poly$$. +$head CppAD Namespace$$ +All of the functions and objects defined by CppAD are in the +$code CppAD$$ namespace. In the example below, +$codei% + using CppAD::AD; +%$$ +enables one to abbreviate $code CppAD::AD$$ using just $code AD$$. + +$head CppAD Preprocessor Symbols$$ +All the $cref preprocessor$$ symbols defined by CppAD begin with +$code CPPAD_$$ (some deprecated symbols begin with $code CppAD_$$). +The preprocessor symbol $cref/CPPAD_TESTVECTOR/testvector/$$ +is used in the example below. $head Program$$ $srccode%cpp% */ -#include // standard input/output -#include // standard vector -#include // the CppAD package http://www.coin-or.org/CppAD/ - -namespace { - // define y(x) = Poly(a, x) in the empty namespace - template - Type Poly(const std::vector &a, const Type &x) - { size_t k = a.size(); - Type y = 0.; // initialize summation - Type x_i = 1.; // initialize x^i - size_t i; - for(i = 0; i < k; i++) - { y += a[i] * x_i; // y = y + a_i * x^i - x_i *= x; // x_i = x_i * x - } - return y; - } +# include // standard input/output +# include // standard vector +# include // the CppAD package + +namespace { // begin the empty namespace + // define the function Poly(a, x) = a[0] + a[1]*x[1] + ... + a[k-1]*x[k-1] + template + Type Poly(const CPPAD_TESTVECTOR(double) &a, const Type &x) + { size_t k = a.size(); + Type y = 0.; // initialize summation + Type x_i = 1.; // initialize x^i + for(size_t i = 0; i < k; i++) + { y += a[i] * x_i; // y = y + a_i * x^i + x_i *= x; // x_i = x_i * x + } + return y; + } } // main program int main(void) -{ using CppAD::AD; // use AD as abbreviation for CppAD::AD - using std::vector; // use vector as abbreviation for std::vector - size_t i; // a temporary index - - // vector of polynomial coefficients - size_t k = 5; // number of polynomial coefficients - vector a(k); // vector of polynomial coefficients - for(i = 0; i < k; i++) - a[i] = 1.; // value of polynomial coefficients - - // domain space vector - size_t n = 1; // number of domain space variables - vector< AD > X(n); // vector of domain space variables - X[0] = 3.; // value corresponding to operation sequence - - // declare independent variables and start recording operation sequence - CppAD::Independent(X); - - // range space vector - size_t m = 1; // number of ranges space variables - vector< AD > Y(m); // vector of ranges space variables - Y[0] = Poly(a, X[0]); // value during recording of operations - - // store operation sequence in f: X -> Y and stop recording - CppAD::ADFun f(X, Y); - - // compute derivative using operation sequence stored in f - vector jac(m * n); // Jacobian of f (m by n matrix) - vector x(n); // domain space vector - x[0] = 3.; // argument value for derivative - jac = f.Jacobian(x); // Jacobian for operation sequence - - // print the results - std::cout << "f'(3) computed by CppAD = " << jac[0] << std::endl; - - // check if the derivative is correct - int error_code; - if( jac[0] == 142. ) - error_code = 0; // return code for correct case - else error_code = 1; // return code for incorrect case +{ using CppAD::AD; // use AD as abbreviation for CppAD::AD + using std::vector; // use vector as abbreviation for std::vector - return error_code; + // vector of polynomial coefficients + size_t k = 5; // number of polynomial coefficients + CPPAD_TESTVECTOR(double) a(k); // vector of polynomial coefficients + for(size_t i = 0; i < k; i++) + a[i] = 1.; // value of polynomial coefficients + + // domain space vector + size_t n = 1; // number of domain space variables + vector< AD > ax(n); // vector of domain space variables + ax[0] = 3.; // value at which function is recorded + + // declare independent variables and start recording operation sequence + CppAD::Independent(ax); + + // range space vector + size_t m = 1; // number of ranges space variables + vector< AD > ay(m); // vector of ranges space variables + ay[0] = Poly(a, ax[0]); // record operations that compute ay[0] + + // store operation sequence in f: X -> Y and stop recording + CppAD::ADFun f(ax, ay); + + // compute derivative using operation sequence stored in f + vector jac(m * n); // Jacobian of f (m by n matrix) + vector x(n); // domain space vector + x[0] = 3.; // argument value for computing derivative + jac = f.Jacobian(x); // Jacobian for operation sequence + + // print the results + std::cout << "f'(3) computed by CppAD = " << jac[0] << std::endl; + + // check if the derivative is correct + int error_code; + if( jac[0] == 142. ) + error_code = 0; // return code for correct case + else error_code = 1; // return code for incorrect case + + return error_code; } /* %$$ $head Output$$ Executing the program above will generate the following output: $codep - f'(3) computed by CppAD = 142 + f'(3) computed by CppAD = 142 $$ $head Running$$ -To build and run this program see $cref cmake_check$$. +After you configure your system using the $cref cmake$$ command, +you compile and run this example by executing the command +$codei% + make check_example_get_started +%$$ +in the build directory; i.e., the directory where the cmake command +was executed. + +$head Exercises$$ +Modify the program above to accomplish the following tasks +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$$. +$lnext +Compute and print the derivative of $latex f(x) = 1 + x + x^2 / 2$$ +at the point $latex x = .5$$. +$lnext +Compute and print the derivative of $latex f(x) = \exp (x) - 1 - x - x^2 / 2$$ +at the point $latex x = .5$$. +$lend $end */ diff -Nru cppad-2018.00.00.0/example/get_started/makefile.am cppad-2019.02.00.0/example/get_started/makefile.am --- cppad-2018.00.00.0/example/get_started/makefile.am 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/get_started/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # automake input file @@ -16,8 +17,11 @@ # check_PROGRAMS = get_started # -AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) # get_started_SOURCES = get_started.cpp # diff -Nru cppad-2018.00.00.0/example/get_started/makefile.in cppad-2019.02.00.0/example/get_started/makefile.in --- cppad-2018.00.00.0/example/get_started/makefile.in 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/example/get_started/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -182,19 +182,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # automake input file @@ -268,10 +267,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -290,9 +287,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -315,8 +314,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -337,8 +334,12 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # -AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + # get_started_SOURCES = get_started.cpp all: all-am diff -Nru cppad-2018.00.00.0/example/ipopt_solve/CMakeLists.txt cppad-2019.02.00.0/example/ipopt_solve/CMakeLists.txt --- cppad-2018.00.00.0/example/ipopt_solve/CMakeLists.txt 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/ipopt_solve/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the example/ipopt_solve directory tests @@ -14,10 +15,10 @@ LINK_DIRECTORIES( ${ipopt_LIBRARY_DIRS} ) # SET(source_list - get_started.cpp - ipopt_solve.cpp - ode_inverse.cpp - retape.cpp + get_started.cpp + ipopt_solve.cpp + ode_inverse.cpp + retape.cpp ) set_compile_flags( example_ipopt_solve "${cppad_debug_which}" "${source_list}" ) # @@ -26,15 +27,15 @@ # libraries to be linked into the specified target, # as determined by pkg-config for ipopt TARGET_LINK_LIBRARIES(example_ipopt_solve - ${cppad_lib} - ${ipopt_LIBRARIES} - ${colpack_libs} + ${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 + example_ipopt_solve + DEPENDS example_ipopt_solve ) MESSAGE(STATUS "make check_example_ipopt_solve: available") diff -Nru cppad-2018.00.00.0/example/ipopt_solve/get_started.cpp cppad-2019.02.00.0/example/ipopt_solve/get_started.cpp --- cppad-2018.00.00.0/example/ipopt_solve/get_started.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/ipopt_solve/get_started.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ -// $Id: get_started.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ipopt_solve_get_started.cpp$$ $spell - cppad_nlp - IpoptDir - CppAD + cppad_nlp + IpoptDir + CppAD $$ $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 @@ -42,9 +41,7 @@ This example will be compiled and tested provided that $cref ipopt_prefix$$ is specified on the $cref cmake$$ command line. -$code $srcfile%example/ipopt_solve/get_started.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -52,107 +49,107 @@ # include namespace { - using CppAD::AD; + using CppAD::AD; - class FG_eval { - public: - typedef CPPAD_TESTVECTOR( AD ) ADvector; - void operator()(ADvector& fg, const ADvector& x) - { assert( fg.size() == 3 ); - assert( x.size() == 4 ); - - // Fortran style indexing - AD x1 = x[0]; - AD x2 = x[1]; - AD x3 = x[2]; - AD x4 = x[3]; - // f(x) - fg[0] = x1 * x4 * (x1 + x2 + x3) + x3; - // g_1 (x) - fg[1] = x1 * x2 * x3 * x4; - // g_2 (x) - fg[2] = x1 * x1 + x2 * x2 + x3 * x3 + x4 * x4; - // - return; - } - }; + class FG_eval { + public: + typedef CPPAD_TESTVECTOR( AD ) ADvector; + void operator()(ADvector& fg, const ADvector& x) + { assert( fg.size() == 3 ); + assert( x.size() == 4 ); + + // Fortran style indexing + AD x1 = x[0]; + AD x2 = x[1]; + AD x3 = x[2]; + AD x4 = x[3]; + // f(x) + fg[0] = x1 * x4 * (x1 + x2 + x3) + x3; + // g_1 (x) + fg[1] = x1 * x2 * x3 * x4; + // g_2 (x) + fg[2] = x1 * x1 + x2 * x2 + x3 * x3 + x4 * x4; + // + return; + } + }; } 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; - // number of constraints (range dimension for g) - size_t ng = 2; - // initial value of the independent variables - Dvector xi(nx); - xi[0] = 1.0; - xi[1] = 5.0; - xi[2] = 5.0; - xi[3] = 1.0; - // lower and upper limits for x - Dvector xl(nx), xu(nx); - for(i = 0; i < nx; i++) - { xl[i] = 1.0; - xu[i] = 5.0; - } - // 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; - - // object that computes objective and constraints - FG_eval fg_eval; - - // options - std::string options; - // turn off any printing - 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, - // 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., - // when evaluation finite diff - options += "Numeric point_perturbation_radius 0.\n"; - - // place to return solution - CppAD::ipopt::solve_result solution; - - // solve the problem - CppAD::ipopt::solve( - options, xi, xl, xu, gl, gu, fg_eval, solution - ); - // - // 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 }; - double check_zl[] = { 1.087871, 0., 0., 0. }; - double check_zu[] = { 0., 0., 0., 0. }; - double rel_tol = 1e-6; // relative tolerance - double abs_tol = 1e-6; // absolute tolerance - for(i = 0; i < nx; i++) - { ok &= CppAD::NearEqual( - check_x[i], solution.x[i], rel_tol, abs_tol - ); - ok &= CppAD::NearEqual( - check_zl[i], solution.zl[i], rel_tol, abs_tol - ); - ok &= CppAD::NearEqual( - check_zu[i], solution.zu[i], rel_tol, abs_tol - ); - } +{ 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; + // number of constraints (range dimension for g) + size_t ng = 2; + // initial value of the independent variables + Dvector xi(nx); + xi[0] = 1.0; + xi[1] = 5.0; + xi[2] = 5.0; + xi[3] = 1.0; + // lower and upper limits for x + Dvector xl(nx), xu(nx); + for(i = 0; i < nx; i++) + { xl[i] = 1.0; + xu[i] = 5.0; + } + // 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; + + // object that computes objective and constraints + FG_eval fg_eval; + + // options + std::string options; + // turn off any printing + 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, + // 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., + // when evaluation finite diff + options += "Numeric point_perturbation_radius 0.\n"; + + // place to return solution + CppAD::ipopt::solve_result solution; + + // solve the problem + CppAD::ipopt::solve( + options, xi, xl, xu, gl, gu, fg_eval, solution + ); + // + // 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 }; + double check_zl[] = { 1.087871, 0., 0., 0. }; + double check_zu[] = { 0., 0., 0., 0. }; + double rel_tol = 1e-6; // relative tolerance + double abs_tol = 1e-6; // absolute tolerance + for(i = 0; i < nx; i++) + { ok &= CppAD::NearEqual( + check_x[i], solution.x[i], rel_tol, abs_tol + ); + ok &= CppAD::NearEqual( + check_zl[i], solution.zl[i], rel_tol, abs_tol + ); + ok &= CppAD::NearEqual( + check_zu[i], solution.zu[i], rel_tol, abs_tol + ); + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/ipopt_solve/ipopt_solve.cpp cppad-2019.02.00.0/example/ipopt_solve/ipopt_solve.cpp --- cppad-2018.00.00.0/example/ipopt_solve/ipopt_solve.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/ipopt_solve/ipopt_solve.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // system include files used for I/O # include @@ -28,21 +29,21 @@ // main program that runs all the tests int main(void) -{ std::string group = "example/ipopt_solve"; - size_t width = 20; - CppAD::test_boolofvoid Run(group, width); - - // This line is used by test_one.sh - - // external compiled tests - Run( get_started, "get_started" ); - Run( ode_inverse, "ode_inverse" ); - Run( retape, "retape" ); - // - // check for memory leak - bool memory_ok = CppAD::thread_alloc::free_all(); - // print summary at end - bool ok = Run.summary(memory_ok); - // - return static_cast( ! ok ); +{ std::string group = "example/ipopt_solve"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + // external compiled tests + Run( get_started, "get_started" ); + Run( ode_inverse, "ode_inverse" ); + Run( retape, "retape" ); + // + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); } diff -Nru cppad-2018.00.00.0/example/ipopt_solve/makefile.am cppad-2019.02.00.0/example/ipopt_solve/makefile.am --- cppad-2018.00.00.0/example/ipopt_solve/makefile.am 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/ipopt_solve/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,13 @@ -# $Id: makefile.am 3803 2016-03-19 05:07:48Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -16,14 +16,14 @@ # check_PROGRAMS = solve # -AM_CXXFLAGS = -g $(CXX_FLAGS) -# -AM_CPPFLAGS = -I. \ - -I$(top_srcdir) \ +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ -I$(IPOPT_DIR)/include # +# LDADD = \ $(CPPAD_IPOPT_LIBS) \ $(FCLIBS) \ diff -Nru cppad-2018.00.00.0/example/ipopt_solve/makefile.in cppad-2019.02.00.0/example/ipopt_solve/makefile.in --- cppad-2018.00.00.0/example/ipopt_solve/makefile.in 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/ipopt_solve/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -187,20 +187,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3973 2017-08-30 13:38:26Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -273,10 +271,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -295,9 +291,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -320,8 +318,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -342,15 +338,15 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # -AM_CXXFLAGS = -g $(CXX_FLAGS) -# -AM_CPPFLAGS = -I. \ - -I$(top_srcdir) \ +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ -I$(IPOPT_DIR)/include # +# LDADD = \ $(CPPAD_IPOPT_LIBS) \ $(FCLIBS) \ diff -Nru cppad-2018.00.00.0/example/ipopt_solve/ode_inverse.cpp cppad-2019.02.00.0/example/ipopt_solve/ode_inverse.cpp --- cppad-2018.00.00.0/example/ipopt_solve/ode_inverse.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/ipopt_solve/ode_inverse.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,20 @@ -// $Id: ode_inverse.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ipopt_solve_ode_inverse.cpp$$ $spell $$ $section ODE Inverse Problem Definitions: Source Code$$ -$mindex example$$ $head Purpose$$ @@ -26,14 +25,14 @@ 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_1 (t , a ) & = & + a_1 * y_0 (t, a ) - a_2 * y_1 (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: Given $latex a \in \B{R}^3$$ @@ -45,7 +44,7 @@ and a measurement vector $latex z \in \B{R}^4$$ and for $latex i = 0, \ldots, 3$$, we model $latex z_i$$ by $latex \[ - z_i = y_1 ( s_{i+1} , a) + e_i + z_i = y_1 ( s_{i+1} , a) + e_i \] $$ where $latex e_{i-1} \sim {\bf N} (0 , \sigma^2 )$$ is the measurement noise, @@ -56,33 +55,33 @@ to simulate a data set: $latex \[ \begin{array}{rcl} - y_0 (t , a) & = & a_0 * \exp( - a_1 * t ) - \\ - y_1 (t , a) & = & - a_0 * a_1 * \frac{\exp( - a_2 * t ) - \exp( -a_1 * t )}{ a_1 - a_2 } + y_0 (t , a) & = & a_0 * \exp( - a_1 * t ) + \\ + 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)$$ + initial value of $latex y_0 (t, a)$$ $rnext $latex \bar{a}_1 = 2$$ $pre $$ $cnext - transfer rate from compartment zero to compartment one + transfer rate from compartment zero to compartment one $rnext $latex \bar{a}_2 = 1$$ $pre $$ $cnext - transfer rate from compartment one to outside world + transfer rate from compartment one to outside world $rnext $latex \sigma = 0$$ $pre $$ $cnext - standard deviation of measurement noise + standard deviation of measurement noise $rnext $latex e_i = 0$$ $pre $$ $cnext - simulated measurement noise, $latex i = 1 , \ldots , Nz$$ + simulated measurement noise, $latex i = 1 , \ldots , Nz$$ $rnext $latex s_i = i * .5$$ $pre $$ $cnext - time corresponding to the $th i$$ measurement, - $latex i = 0 , \ldots , 3$$ + time corresponding to the $th i$$ measurement, + $latex i = 0 , \ldots , 3$$ $tend $subhead Simulated Measurement Values$$ @@ -94,8 +93,8 @@ \\ & = & \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 } + \frac{\exp( - \bar{a}_2 * s_i ) - \exp( -\bar{a}_1 * s_i )} + { \bar{a}_1 - \bar{a}_2 } \end{array} \] $$ for $latex i = 0, \ldots , 3$$. @@ -107,8 +106,8 @@ $latex \[ \begin{array}{rcl} {\rm minimize} \; - & \sum_{i=0}^3 ( z_i - y_1 ( s_{i+1} , a ) )^2 - & \;{\rm w.r.t} \; a \in \B{R}^3 + & \sum_{i=0}^3 ( z_i - y_1 ( s_{i+1} , a ) )^2 + & \;{\rm w.r.t} \; a \in \B{R}^3 \end{array} \] $$ @@ -119,7 +118,7 @@ $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$$. @@ -133,9 +132,9 @@ where $latex G : \B{R}^2 \times \B{R}^3 \rightarrow \B{R}^2$$ is defined by $latex \[ \begin{array}{rcl} - G_0 ( y , a ) & = & - a_1 * y_0 - \\ - G_1 ( y , a ) & = & + a_1 * y_0 - a_2 * y_1 + G_0 ( y , a ) & = & - a_1 * y_0 + \\ + G_1 ( y , a ) & = & + a_1 * y_0 - a_2 * y_1 \end{array} \] $$ @@ -148,33 +147,31 @@ {\rm minimize} & \sum_{i=0}^3 ( z_i - y_1^{(i+1) \cdot np} )^2 & \; {\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 + \; 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} - - \frac{G( y^k , a ) + G( y^{k-1} , a ) }{2} (t_k - t_{k-1}) - & \; {\rm for} \; k = 1 , \ldots , 4 \cdot np + 0 = y^0 - ( a_0 , 0 )^\R{T} + \\ + & 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 $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$$ The following source code implements the ODE inversion method proposed above: -$code $srcfile%example/ipopt_solve/ode_inverse.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end ------------------------------------------------------------------------------ @@ -183,150 +180,150 @@ # include namespace { - using CppAD::AD; + using CppAD::AD; - // 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]); - - // function used to simulate data - double yone(double t) - { return - a_[0]*a_[1] * (exp(-a_[2]*t) - exp(-a_[1]*t)) / (a_[1] - a_[2]); - } - - // time points were we have data (no data at first point) - 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])}; - size_t nz_ = sizeof(z_) / sizeof(z_[0]); - - // number of trapozoidal approximation points per measurement interval - size_t np_ = 40; - - - class FG_eval - { - private: - public: - // derived class part of constructor - typedef CPPAD_TESTVECTOR( AD ) ADvector; - - // Evaluation of the objective f(x), and constraints g(x) - void operator()(ADvector& fg, const ADvector& x) - { CPPAD_TESTVECTOR( AD ) a(na_); - size_t i, j, k; - - // extract the vector a - for(i = 0; i < na_; i++) - a[i] = x[i]; - - // compute the object f(x) - fg[0] = 0.0; - for(i = 0; i < nz_; i++) - { k = (i + 1) * np_; - 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 - fg[1] = x[na_+0] - a[0]; - fg[2] = x[na_+1] - 0.0; - - // 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_); - for(j = 1; j <= np_; j++) - { k = i * np_ + j; - // compute derivative at y^k - AD y_0 = x[na_ + 2 * k + 0]; - AD y_1 = x[na_ + 2 * k + 1]; - AD G_0 = - a[1] * y_0; - AD G_1 = + a[1] * y_0 - a[2] * y_1; - - // compute derivative at y^{k-1} - AD ym_0 = x[na_ + 2 * (k-1) + 0]; - AD ym_1 = x[na_ + 2 * (k-1) + 1]; - AD Gm_0 = - a[1] * ym_0; - AD Gm_1 = + a[1] * ym_0 - a[2] * ym_1; - - // constraint should be zero - fg[1 + 2*k ] = y_0 - ym_0 - dt*(G_0 + Gm_0)/2.; - fg[2 + 2*k ] = y_1 - ym_1 - dt*(G_1 + Gm_1)/2.; - - // scale g(x) so it has similar size as f(x) - fg[1 + 2*k ] /= dt; - fg[2 + 2*k ] /= dt; - } - } - } - }; + // 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]); + + // function used to simulate data + double yone(double t) + { return + a_[0]*a_[1] * (exp(-a_[2]*t) - exp(-a_[1]*t)) / (a_[1] - a_[2]); + } + + // time points were we have data (no data at first point) + 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])}; + size_t nz_ = sizeof(z_) / sizeof(z_[0]); + + // number of trapozoidal approximation points per measurement interval + size_t np_ = 40; + + + class FG_eval + { + private: + public: + // derived class part of constructor + typedef CPPAD_TESTVECTOR( AD ) ADvector; + + // Evaluation of the objective f(x), and constraints g(x) + void operator()(ADvector& fg, const ADvector& x) + { CPPAD_TESTVECTOR( AD ) a(na_); + size_t i, j, k; + + // extract the vector a + for(i = 0; i < na_; i++) + a[i] = x[i]; + + // compute the object f(x) + fg[0] = 0.0; + for(i = 0; i < nz_; i++) + { k = (i + 1) * np_; + 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 + fg[1] = x[na_+0] - a[0]; + fg[2] = x[na_+1] - 0.0; + + // 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_); + for(j = 1; j <= np_; j++) + { k = i * np_ + j; + // compute derivative at y^k + AD y_0 = x[na_ + 2 * k + 0]; + AD y_1 = x[na_ + 2 * k + 1]; + AD G_0 = - a[1] * y_0; + AD G_1 = + a[1] * y_0 - a[2] * y_1; + + // compute derivative at y^{k-1} + AD ym_0 = x[na_ + 2 * (k-1) + 0]; + AD ym_1 = x[na_ + 2 * (k-1) + 1]; + AD Gm_0 = - a[1] * ym_0; + AD Gm_1 = + a[1] * ym_0 - a[2] * ym_1; + + // constraint should be zero + fg[1 + 2*k ] = y_0 - ym_0 - dt*(G_0 + Gm_0)/2.; + fg[2 + 2*k ] = y_1 - ym_1 - dt*(G_1 + Gm_1)/2.; + + // scale g(x) so it has similar size as f(x) + fg[1 + 2*k ] /= dt; + fg[2 + 2*k ] /= dt; + } + } + } + }; } bool ode_inverse(void) -{ bool ok = true; - size_t i; - typedef CPPAD_TESTVECTOR( double ) Dvector; - - // number of components in the function g - size_t ng = (np_ * nz_ + 1) * 2; - // number of independent variables - size_t nx = na_ + ng; - // initial vlaue for the variables we are optimizing w.r.t - Dvector xi(nx), xl(nx), xu(nx); - for(i = 0; i < nx; i++) - { xi[i] = 0.0; // initial value - xl[i] = -1e19; // no lower limit - xu[i] = +1e19; // no upper limit - } - for(i = 0; i < na_; i++) - xi[0] = 1.5; // initial value for a - - // all the difference equations are constrainted to be zero - Dvector gl(ng), gu(ng); - for(i = 0; i < ng; i++) - { gl[i] = 0.0; - gu[i] = 0.0; - } - // object defining both f(x) and g(x) - FG_eval fg_eval; - - // 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 += "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, - // Pages 25-57, Equation (6) - options += "Numeric tol 1e-6\n"; - - // place to return solution - CppAD::ipopt::solve_result solution; - - // solve the problem - CppAD::ipopt::solve( - options, xi, xl, xu, gl, gu, fg_eval, solution - ); - // - // Check some of the solution values - // - ok &= solution.status == CppAD::ipopt::solve_result::success; - // - double rel_tol = 1e-4; // relative tolerance - double abs_tol = 1e-4; // absolute tolerance - for(i = 0; i < na_; i++) - ok &= CppAD::NearEqual( a_[i], solution.x[i], rel_tol, abs_tol); +{ bool ok = true; + size_t i; + typedef CPPAD_TESTVECTOR( double ) Dvector; + + // number of components in the function g + size_t ng = (np_ * nz_ + 1) * 2; + // number of independent variables + size_t nx = na_ + ng; + // initial vlaue for the variables we are optimizing w.r.t + Dvector xi(nx), xl(nx), xu(nx); + for(i = 0; i < nx; i++) + { xi[i] = 0.0; // initial value + xl[i] = -1e19; // no lower limit + xu[i] = +1e19; // no upper limit + } + for(i = 0; i < na_; i++) + xi[0] = 1.5; // initial value for a + + // all the difference equations are constrainted to be zero + Dvector gl(ng), gu(ng); + for(i = 0; i < ng; i++) + { gl[i] = 0.0; + gu[i] = 0.0; + } + // object defining both f(x) and g(x) + FG_eval fg_eval; + + // 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 += "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, + // Pages 25-57, Equation (6) + options += "Numeric tol 1e-6\n"; + + // place to return solution + CppAD::ipopt::solve_result solution; + + // solve the problem + CppAD::ipopt::solve( + options, xi, xl, xu, gl, gu, fg_eval, solution + ); + // + // Check some of the solution values + // + ok &= solution.status == CppAD::ipopt::solve_result::success; + // + double rel_tol = 1e-4; // relative tolerance + double abs_tol = 1e-4; // absolute tolerance + for(i = 0; i < na_; i++) + ok &= CppAD::NearEqual( a_[i], solution.x[i], rel_tol, abs_tol); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/ipopt_solve/retape.cpp cppad-2019.02.00.0/example/ipopt_solve/retape.cpp --- cppad-2018.00.00.0/example/ipopt_solve/retape.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/ipopt_solve/retape.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,35 +1,33 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ipopt_solve_retape.cpp$$ $spell - Retaping - retape - cppad_nlp - IpoptDir - CppAD + Retaping + retape + cppad_nlp + IpoptDir + CppAD $$ $section Nonlinear Programming Retaping: Example and Test$$ -$mindex retape ipopt_solve$$ $head Purpose$$ This example program demonstrates a case were the $code ipopt::solve$$ argument $cref/retape/ipopt_solve/options/Retape/$$ should be true. -$code $srcfile%example/ipopt_solve/retape.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -37,81 +35,81 @@ # include namespace { - using CppAD::AD; + using CppAD::AD; - class FG_eval { - public: - typedef CPPAD_TESTVECTOR( AD ) ADvector; - void operator()(ADvector& fg, const ADvector& x) - { assert( fg.size() == 1 ); - assert( x.size() == 1 ); - - // compute the Huber function using a conditional - // statement that depends on the value of x. - double eps = 0.1; - if( fabs(x[0]) <= eps ) - fg[0] = x[0] * x[0] / (2.0 * eps); - else - fg[0] = fabs(x[0]) - eps / 2.0; - - return; - } - }; + class FG_eval { + public: + typedef CPPAD_TESTVECTOR( AD ) ADvector; + void operator()(ADvector& fg, const ADvector& x) + { assert( fg.size() == 1 ); + assert( x.size() == 1 ); + + // compute the Huber function using a conditional + // statement that depends on the value of x. + double eps = 0.1; + if( fabs(x[0]) <= eps ) + fg[0] = x[0] * x[0] / (2.0 * eps); + else + fg[0] = fabs(x[0]) - eps / 2.0; + + return; + } + }; } bool retape(void) -{ bool ok = true; - typedef CPPAD_TESTVECTOR( double ) Dvector; +{ bool ok = true; + typedef CPPAD_TESTVECTOR( double ) Dvector; - // number of independent variables (domain dimension for f and g) - 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 - Dvector xi(nx), xl(nx), xu(nx); - xi[0] = 2.0; - xl[0] = -1e+19; - xu[0] = +1e+19; - // lower and upper limits for g - Dvector gl(ng), gu(ng); - - // object that computes objective and constraints - FG_eval fg_eval; - - // 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 += "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, - // 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., - // when evaluation finite diff - options += "Numeric point_perturbation_radius 0.\n"; - - // place to return solution - CppAD::ipopt::solve_result solution; - - // solve the problem - CppAD::ipopt::solve( - options, xi, xl, xu, gl, gu, fg_eval, solution - ); - // - // 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 - ok &= CppAD::NearEqual( solution.x[0], 0.0, rel_tol, abs_tol); + // number of independent variables (domain dimension for f and g) + 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 + Dvector xi(nx), xl(nx), xu(nx); + xi[0] = 2.0; + xl[0] = -1e+19; + xu[0] = +1e+19; + // lower and upper limits for g + Dvector gl(ng), gu(ng); + + // object that computes objective and constraints + FG_eval fg_eval; + + // 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 += "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, + // 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., + // when evaluation finite diff + options += "Numeric point_perturbation_radius 0.\n"; + + // place to return solution + CppAD::ipopt::solve_result solution; + + // solve the problem + CppAD::ipopt::solve( + options, xi, xl, xu, gl, gu, fg_eval, solution + ); + // + // 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 + ok &= CppAD::NearEqual( solution.x[0], 0.0, rel_tol, abs_tol); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/ipopt_solve/test.sh.in cppad-2019.02.00.0/example/ipopt_solve/test.sh.in --- cppad-2018.00.00.0/example/ipopt_solve/test.sh.in 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/ipopt_solve/test.sh.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,14 +1,14 @@ #! /bin/bash -e -# $Id: test.sh.in 2655 2012-12-27 13:51:34Z 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. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- export LD_LIBRARY_PATH=@CPPAD_IPOPT_LD_PATH@ ./solve diff -Nru cppad-2018.00.00.0/example/multi_thread/bthread/a11c_bthread.cpp cppad-2019.02.00.0/example/multi_thread/bthread/a11c_bthread.cpp --- cppad-2018.00.00.0/example/multi_thread/bthread/a11c_bthread.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/bthread/a11c_bthread.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,31 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin a11c_bthread.cpp$$ $spell - bthread - bthreads - CppAD - const + bthread + bthreads + CppAD + const $$ $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. $head Source Code$$ -$code $srcfile%example/multi_thread/bthread/a11c_bthread.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end ---------------------------------------------------------------------------- */ @@ -39,87 +37,87 @@ # define NUMBER_THREADS 4 namespace { // Begin empty namespace - class worker_t - { - private: - int n_; - float* a_; - float* b_; - public: - void setup(size_t n, float* a, float* b) - { n_ = static_cast(n); - a_ = a; - b_ = b; - } - // Beginning of Example A.1.1.1c of OpenMP 2.5 standard document - void a1(int n, float *a, float *b) - { int i; - // for some reason this function is missing on some systems - // assert( bthread_is_multithreaded_np() > 0 ); - for(i = 1; i < n; i++) - b[i] = (a[i] + a[i-1]) / 2.0f; - return; - } - // End of Example A.1.1.1c of OpenMP 2.5 standard document - void operator()() - { a1(n_, a_, b_); } - }; + class worker_t + { + private: + int n_; + float* a_; + float* b_; + public: + void setup(size_t n, float* a, float* b) + { n_ = static_cast(n); + a_ = a; + b_ = b; + } + // Beginning of Example A.1.1.1c of OpenMP 2.5 standard document + void a1(int n, float *a, float *b) + { int i; + // for some reason this function is missing on some systems + // assert( bthread_is_multithreaded_np() > 0 ); + for(i = 1; i < n; i++) + b[i] = (a[i] + a[i-1]) / 2.0f; + return; + } + // End of Example A.1.1.1c of OpenMP 2.5 standard document + void operator()() + { a1(n_, a_, b_); } + }; } bool a11c(void) -{ bool ok = true; +{ bool ok = true; - // Test setup - size_t i, j, n_total = 10; - float *a = new float[n_total]; - float *b = new float[n_total]; - for(i = 0; i < n_total; i++) - a[i] = float(i); - - // number of threads - size_t number_threads = NUMBER_THREADS; - - // set of workers - worker_t worker[NUMBER_THREADS]; - // threads for each worker - boost::thread* bthread[NUMBER_THREADS]; - - // Break the work up into sub work for each thread - size_t n = n_total / number_threads; - size_t n_tmp = n; - float* a_tmp = a; - float* b_tmp = b; - worker[0].setup(n_tmp, a_tmp, b_tmp); - for(j = 1; j < number_threads; j++) - { 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); - - // create this thread - bthread[j] = new boost::thread(worker[j]); - } - - // do this threads protion of the work - worker[0](); - - // wait for other threads to finish - for(j = 1; j < number_threads; j++) - { bthread[j]->join(); - delete bthread[j]; - } - - // check the result - float eps = 100.f * std::numeric_limits::epsilon(); - for(i = 1; i < n ; i++) - ok &= std::fabs( (2. * b[i] - a[i] - a[i-1]) / b[i] ) <= eps; + // Test setup + size_t i, j, n_total = 10; + float *a = new float[n_total]; + float *b = new float[n_total]; + for(i = 0; i < n_total; i++) + a[i] = float(i); + + // number of threads + size_t number_threads = NUMBER_THREADS; + + // set of workers + worker_t worker[NUMBER_THREADS]; + // threads for each worker + boost::thread* bthread[NUMBER_THREADS]; + + // Break the work up into sub work for each thread + size_t n = n_total / number_threads; + size_t n_tmp = n; + float* a_tmp = a; + float* b_tmp = b; + worker[0].setup(n_tmp, a_tmp, b_tmp); + for(j = 1; j < number_threads; j++) + { 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); + + // create this thread + bthread[j] = new boost::thread(worker[j]); + } + + // do this threads protion of the work + worker[0](); + + // wait for other threads to finish + for(j = 1; j < number_threads; j++) + { bthread[j]->join(); + delete bthread[j]; + } + + // check the result + float eps = 100.f * std::numeric_limits::epsilon(); + for(i = 1; i < n ; i++) + ok &= std::fabs( (2. * b[i] - a[i] - a[i-1]) / b[i] ) <= eps; - delete [] a; - delete [] b; + delete [] a; + delete [] b; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/bthread/CMakeLists.txt cppad-2019.02.00.0/example/multi_thread/bthread/CMakeLists.txt --- cppad-2018.00.00.0/example/multi_thread/bthread/CMakeLists.txt 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/bthread/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the example/multi_thread/bthread directory tests # Inherit build type from ../CMakeList.txt @@ -18,14 +19,15 @@ # source1 source2 ... sourceN # ) SET(source_list ../thread_test.cpp - ${CMAKE_SOURCE_DIR}/speed/src/microsoft_timer.cpp - ../team_example.cpp - ../harmonic.cpp - ../multi_atomic.cpp - ../multi_newton.cpp - a11c_bthread.cpp - simple_ad_bthread.cpp - team_bthread.cpp + ${CMAKE_SOURCE_DIR}/speed/src/microsoft_timer.cpp + ../team_example.cpp + ../harmonic.cpp + ../multi_atomic.cpp + ../multi_checkpoint.cpp + ../multi_newton.cpp + a11c_bthread.cpp + simple_ad_bthread.cpp + team_bthread.cpp ) set_compile_flags( example_multi_thread_bthread "${cppad_debug_which}" "${source_list}" ) # @@ -40,8 +42,8 @@ # Add the check_example_multi_thread_bthread target ADD_CUSTOM_TARGET(check_example_multi_thread_bthread - example_multi_thread_bthread simple_ad - DEPENDS example_multi_thread_bthread + example_multi_thread_bthread simple_ad + DEPENDS example_multi_thread_bthread ) MESSAGE(STATUS "make check_example_multi_thread_bthread: available") diff -Nru cppad-2018.00.00.0/example/multi_thread/bthread/simple_ad_bthread.cpp cppad-2019.02.00.0/example/multi_thread/bthread/simple_ad_bthread.cpp --- cppad-2018.00.00.0/example/multi_thread/bthread/simple_ad_bthread.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/bthread/simple_ad_bthread.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin simple_ad_bthread.cpp$$ $spell - bthread - CppAD + bthread + CppAD $$ $section A Simple Boost Threading AD: Example and Test$$ -$mindex thread AD$$ $head Purpose$$ @@ -25,9 +25,7 @@ boost multi-threading environment. $head Source Code$$ -$code $srcfile%example/multi_thread/bthread/simple_ad_bthread.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end ------------------------------------------------------------------------------ @@ -38,208 +36,208 @@ # define NUMBER_THREADS 4 namespace { - // structure with problem specific information - typedef struct { - // function argument (worker input) - double x; - // This structure would also have return information in it, - // but this example only returns the ok flag - } problem_specific; - // ===================================================================== - // General purpose code you can copy to your application - // ===================================================================== - using CppAD::thread_alloc; - // ------------------------------------------------------------------ - // thread specific point to the thread number (initialize as null) - void cleanup(size_t*) - { return; } - boost::thread_specific_ptr thread_num_ptr_(cleanup); - - // Are we in sequential mode; i.e., other threads are waiting for - // master thread to set up next job ? - bool sequential_execution_ = true; - - // used to inform CppAD when we are in parallel execution mode - bool in_parallel(void) - { return ! sequential_execution_; } - - // used to inform CppAD of current thread number thread_number() - size_t thread_number(void) - { // return thread_all_[thread_num].thread_num - return *thread_num_ptr_.get(); - } - // --------------------------------------------------------------------- - // structure with information for one thread - typedef struct { - // number for this thread (thread specific points here) - size_t thread_num; - // pointer to this boost thread - boost::thread* bthread; - // false if an error occurs, true otherwise - bool ok; - // pointer to problem specific information - problem_specific* info; - } thread_one_t; - // vector with information for all threads - thread_one_t thread_all_[NUMBER_THREADS]; - // -------------------------------------------------------------------- - // function that initializes the thread and then calls actual worker - bool worker(size_t thread_num, problem_specific* info); - void run_one_worker(size_t thread_num) - { bool ok = true; - - // The master thread should call worker directly - 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 - // of this threads number. - // We must do this before calling thread_alloc::thread_num(). - thread_num_ptr_.reset(& thread_all_[thread_num].thread_num); - - // Check the value of thread_alloc::thread_num(). - ok = thread_num == thread_alloc::thread_num(); - - // Now do the work - ok &= worker(thread_num, thread_all_[thread_num].info); - - // pass back ok information for this thread - thread_all_[thread_num].ok = ok; - - // no return value - return; - } - // ---------------------------------------------------------------------- - // function that calls all the workers - bool run_all_workers(size_t num_threads, problem_specific* info_all[]) - { bool ok = true; - - // initialize thread_all_ (execpt for pthread_id) - size_t thread_num; - for(thread_num = 0; thread_num < num_threads; thread_num++) - { // pointed to by thread specific info for this thread - thread_all_[thread_num].thread_num = thread_num; - // initialize as false to make sure worker gets called by other - // threads. Note that thread_all_[0].ok does not get used - thread_all_[thread_num].ok = false; - // problem specific information - thread_all_[thread_num].info = info_all[thread_num]; - } - - // master bthread number - thread_num_ptr_.reset(& thread_all_[0].thread_num); - - // Now thread_number() has necessary information for this thread - // (number zero), and while still in sequential mode, - // call setup for using CppAD::AD in parallel mode. - thread_alloc::parallel_setup( - num_threads, in_parallel, thread_number - ); - thread_alloc::hold_memory(true); - CppAD::parallel_ad(); - - // 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 = - new boost::thread(run_one_worker, thread_num); - } - - // now call worker for the master thread - thread_num = thread_alloc::thread_num(); - ok &= thread_num == 0; - ok &= worker(thread_num, thread_all_[thread_num].info); - - // 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; - thread_all_[thread_num].bthread = CPPAD_NULL; - } - - // Inform CppAD that we now are definately back to sequential mode - sequential_execution_ = true; - - // now inform CppAD that there is only one thread - thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL); - thread_alloc::hold_memory(false); - CppAD::parallel_ad(); - - // check to ok flag returned by during calls to work by other threads - for(thread_num = 1; thread_num < num_threads; thread_num++) - ok &= thread_all_[thread_num].ok; - - return ok; - } - // ===================================================================== - // End of General purpose code - // ===================================================================== - // function that does the work for one thread - bool worker(size_t thread_num, problem_specific* info) - { bool ok = true; - - // CppAD::vector uses the CppAD fast multi-threading allocator - CppAD::vector< CppAD::AD > ax(1), ay(1); - ax[0] = info->x; - Independent(ax); - ay[0] = sqrt( ax[0] * ax[0] ); - CppAD::ADFun f(ax, ay); - - // Check function value corresponds to the identity - double eps = 10. * CppAD::numeric_limits::epsilon(); - ok &= CppAD::NearEqual(ay[0], ax[0], eps, eps); - - // Check derivative value corresponds to the identity. - CppAD::vector d_x(1), d_y(1); - d_x[0] = 1.; - d_y = f.Forward(1, d_x); - ok &= CppAD::NearEqual(d_x[0], 1., eps, eps); + // structure with problem specific information + typedef struct { + // function argument (worker input) + double x; + // This structure would also have return information in it, + // but this example only returns the ok flag + } problem_specific; + // ===================================================================== + // General purpose code you can copy to your application + // ===================================================================== + using CppAD::thread_alloc; + // ------------------------------------------------------------------ + // thread specific point to the thread number (initialize as null) + void cleanup(size_t*) + { return; } + boost::thread_specific_ptr thread_num_ptr_(cleanup); + + // Are we in sequential mode; i.e., other threads are waiting for + // master thread to set up next job ? + bool sequential_execution_ = true; + + // used to inform CppAD when we are in parallel execution mode + bool in_parallel(void) + { return ! sequential_execution_; } + + // used to inform CppAD of current thread number thread_number() + size_t thread_number(void) + { // return thread_all_[thread_num].thread_num + return *thread_num_ptr_.get(); + } + // --------------------------------------------------------------------- + // structure with information for one thread + typedef struct { + // number for this thread (thread specific points here) + size_t thread_num; + // pointer to this boost thread + boost::thread* bthread; + // false if an error occurs, true otherwise + bool ok; + // pointer to problem specific information + problem_specific* info; + } thread_one_t; + // vector with information for all threads + thread_one_t thread_all_[NUMBER_THREADS]; + // -------------------------------------------------------------------- + // function that initializes the thread and then calls actual worker + bool worker(size_t thread_num, problem_specific* info); + void run_one_worker(size_t thread_num) + { bool ok = true; + + // The master thread should call worker directly + 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 + // of this threads number. + // We must do this before calling thread_alloc::thread_num(). + thread_num_ptr_.reset(& thread_all_[thread_num].thread_num); + + // Check the value of thread_alloc::thread_num(). + ok = thread_num == thread_alloc::thread_num(); + + // Now do the work + ok &= worker(thread_num, thread_all_[thread_num].info); + + // pass back ok information for this thread + thread_all_[thread_num].ok = ok; + + // no return value + return; + } + // ---------------------------------------------------------------------- + // function that calls all the workers + bool run_all_workers(size_t num_threads, problem_specific* info_all[]) + { bool ok = true; + + // initialize thread_all_ (execpt for pthread_id) + size_t thread_num; + for(thread_num = 0; thread_num < num_threads; thread_num++) + { // pointed to by thread specific info for this thread + thread_all_[thread_num].thread_num = thread_num; + // initialize as false to make sure worker gets called by other + // threads. Note that thread_all_[0].ok does not get used + thread_all_[thread_num].ok = false; + // problem specific information + thread_all_[thread_num].info = info_all[thread_num]; + } + + // master bthread number + thread_num_ptr_.reset(& thread_all_[0].thread_num); + + // Now thread_number() has necessary information for this thread + // (number zero), and while still in sequential mode, + // call setup for using CppAD::AD in parallel mode. + thread_alloc::parallel_setup( + num_threads, in_parallel, thread_number + ); + thread_alloc::hold_memory(true); + CppAD::parallel_ad(); + + // 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 = + new boost::thread(run_one_worker, thread_num); + } + + // now call worker for the master thread + thread_num = thread_alloc::thread_num(); + ok &= thread_num == 0; + ok &= worker(thread_num, thread_all_[thread_num].info); + + // 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; + thread_all_[thread_num].bthread = CPPAD_NULL; + } + + // Inform CppAD that we now are definately back to sequential mode + sequential_execution_ = true; + + // now inform CppAD that there is only one thread + thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL); + thread_alloc::hold_memory(false); + CppAD::parallel_ad(); + + // check to ok flag returned by during calls to work by other threads + for(thread_num = 1; thread_num < num_threads; thread_num++) + ok &= thread_all_[thread_num].ok; + + return ok; + } + // ===================================================================== + // End of General purpose code + // ===================================================================== + // function that does the work for one thread + bool worker(size_t thread_num, problem_specific* info) + { bool ok = true; + + // CppAD::vector uses the CppAD fast multi-threading allocator + CppAD::vector< CppAD::AD > ax(1), ay(1); + ax[0] = info->x; + Independent(ax); + ay[0] = sqrt( ax[0] * ax[0] ); + CppAD::ADFun f(ax, ay); + + // Check function value corresponds to the identity + double eps = 10. * CppAD::numeric_limits::epsilon(); + ok &= CppAD::NearEqual(ay[0], ax[0], eps, eps); + + // Check derivative value corresponds to the identity. + CppAD::vector d_x(1), d_y(1); + d_x[0] = 1.; + d_y = f.Forward(1, d_x); + ok &= CppAD::NearEqual(d_x[0], 1., eps, eps); - return ok; - } + return ok; + } } bool simple_ad(void) -{ bool ok = true; - size_t num_threads = NUMBER_THREADS; +{ bool ok = true; + size_t num_threads = NUMBER_THREADS; - // Check that no memory is in use or avialable at start - // (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; - } - - // initialize info_all - problem_specific *info, *info_all[NUMBER_THREADS]; - for(thread_num = 0; thread_num < num_threads; thread_num++) - { // problem specific information - size_t min_bytes(sizeof(info)), cap_bytes; - void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); - info = static_cast(v_ptr); - info->x = double(thread_num) + 1.; - info_all[thread_num] = info; - } - - ok &= run_all_workers(num_threads, info_all); - - // go down so that free memory for other threads before memory for master - thread_num = num_threads; - while(thread_num--) - { // delete problem specific information - 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; - // return all memory being held for future use by this thread - thread_alloc::free_available(thread_num); - } + // Check that no memory is in use or avialable at start + // (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; + } + + // initialize info_all + problem_specific *info, *info_all[NUMBER_THREADS]; + for(thread_num = 0; thread_num < num_threads; thread_num++) + { // problem specific information + size_t min_bytes(sizeof(info)), cap_bytes; + void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); + info = static_cast(v_ptr); + info->x = double(thread_num) + 1.; + info_all[thread_num] = info; + } + + ok &= run_all_workers(num_threads, info_all); + + // go down so that free memory for other threads before memory for master + thread_num = num_threads; + while(thread_num--) + { // delete problem specific information + 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; + // return all memory being held for future use by this thread + thread_alloc::free_available(thread_num); + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/bthread/team_bthread.cpp cppad-2019.02.00.0/example/multi_thread/bthread/team_bthread.cpp --- cppad-2018.00.00.0/example/multi_thread/bthread/team_bthread.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/bthread/team_bthread.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin team_bthread.cpp$$ $spell - bthread + bthread $$ $section Boost Thread Implementation of a Team of AD Threads$$ -$mindex bthread$$ See $cref team_thread.hpp$$ for this routines specifications. -$code $srcfile%example/multi_thread/bthread/team_bthread.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -32,236 +30,236 @@ # define MAX_NUMBER_THREADS 48 namespace { - using CppAD::thread_alloc; + using CppAD::thread_alloc; - // number of threads in the team - size_t num_threads_ = 1; + // number of threads in the team + size_t num_threads_ = 1; - // no need to cleanup up thread specific data - void cleanup(size_t*) - { return; } - - // thread specific pointer the thread number (initialize as null) - boost::thread_specific_ptr thread_num_ptr_(cleanup); - - // type of the job currently being done by each thread - enum thread_job_t { init_enum, work_enum, join_enum } thread_job_; - - // barrier used to wait for other threads to finish work - boost::barrier* wait_for_work_ = CPPAD_NULL; - - // barrier used to wait for master thread to set next job - boost::barrier* wait_for_job_ = CPPAD_NULL; - - // Are we in sequential mode; i.e., other threads are waiting for - // master thread to set up next job ? - bool sequential_execution_ = true; - - // structure with information for one thread - typedef struct { - // The thread - boost::thread* bthread; - // CppAD thread number as global (pointed to by thread_num_ptr_) - size_t thread_num; - // true if no error for this thread, false otherwise. - bool ok; - } thread_one_t; - - // vector with information for all threads - thread_one_t thread_all_[MAX_NUMBER_THREADS]; - - // pointer to function that does the work for one thread - void (* worker_)(void) = CPPAD_NULL; - - // --------------------------------------------------------------------- - // in_parallel() - bool in_parallel(void) - { return ! sequential_execution_; } - - // --------------------------------------------------------------------- - // thread_number() - size_t thread_number(void) - { // return thread_all_[thread_num].thread_num - return *thread_num_ptr_.get(); - } - // -------------------------------------------------------------------- - // function that gets called by boost thread constructor - void thread_work(size_t thread_num) - { bool ok = wait_for_work_ != CPPAD_NULL; - ok &= wait_for_job_ != CPPAD_NULL; - ok &= thread_num != 0; - - // thread specific storage of thread number for this thread - thread_num_ptr_.reset(& thread_all_[thread_num].thread_num ); - - while( true ) - { - // Use wait_for_jog_ to give master time in sequential mode - // (so it can change global information like thread_job_) - wait_for_job_->wait(); - - // case where we are terminating this thread (no more work) - if( thread_job_ == join_enum) - break; - - // only other case once wait_for_job_ has been completed (so far) - ok &= thread_job_ == work_enum; - worker_(); - - // Use wait_for_work_ to inform master that our work is done and - // that this thread will not use global infromation until - // passing its barrier wait_for_job_ above. - wait_for_work_->wait(); - - } - thread_all_[thread_num].ok &= ok; - return; - } + // no need to cleanup up thread specific data + void cleanup(size_t*) + { return; } + + // thread specific pointer the thread number (initialize as null) + boost::thread_specific_ptr thread_num_ptr_(cleanup); + + // type of the job currently being done by each thread + enum thread_job_t { init_enum, work_enum, join_enum } thread_job_; + + // barrier used to wait for other threads to finish work + boost::barrier* wait_for_work_ = CPPAD_NULL; + + // barrier used to wait for master thread to set next job + boost::barrier* wait_for_job_ = CPPAD_NULL; + + // Are we in sequential mode; i.e., other threads are waiting for + // master thread to set up next job ? + bool sequential_execution_ = true; + + // structure with information for one thread + typedef struct { + // The thread + boost::thread* bthread; + // CppAD thread number as global (pointed to by thread_num_ptr_) + size_t thread_num; + // true if no error for this thread, false otherwise. + bool ok; + } thread_one_t; + + // vector with information for all threads + thread_one_t thread_all_[MAX_NUMBER_THREADS]; + + // pointer to function that does the work for one thread + void (* worker_)(void) = CPPAD_NULL; + + // --------------------------------------------------------------------- + // in_parallel() + bool in_parallel(void) + { return ! sequential_execution_; } + + // --------------------------------------------------------------------- + // thread_number() + size_t thread_number(void) + { // return thread_all_[thread_num].thread_num + return *thread_num_ptr_.get(); + } + // -------------------------------------------------------------------- + // function that gets called by boost thread constructor + void thread_work(size_t thread_num) + { bool ok = wait_for_work_ != CPPAD_NULL; + ok &= wait_for_job_ != CPPAD_NULL; + ok &= thread_num != 0; + + // thread specific storage of thread number for this thread + thread_num_ptr_.reset(& thread_all_[thread_num].thread_num ); + + while( true ) + { + // Use wait_for_jog_ to give master time in sequential mode + // (so it can change global information like thread_job_) + wait_for_job_->wait(); + + // case where we are terminating this thread (no more work) + if( thread_job_ == join_enum) + break; + + // only other case once wait_for_job_ has been completed (so far) + ok &= thread_job_ == work_enum; + worker_(); + + // Use wait_for_work_ to inform master that our work is done and + // that this thread will not use global infromation until + // passing its barrier wait_for_job_ above. + wait_for_work_->wait(); + + } + thread_all_[thread_num].ok &= ok; + return; + } } bool team_create(size_t num_threads) -{ bool ok = true;; +{ bool ok = true;; - if( num_threads > MAX_NUMBER_THREADS ) - { std::cerr << "team_create: num_threads greater than "; - std::cerr << MAX_NUMBER_THREADS << std::endl; - exit(1); - } - // check that we currently do not have multiple threads running - ok = num_threads_ == 1; - ok &= wait_for_work_ == CPPAD_NULL; - ok &= wait_for_job_ == CPPAD_NULL; - ok &= sequential_execution_; - - size_t thread_num; - for(thread_num = 0; thread_num < num_threads; thread_num++) - { // Each thread gets a pointer to its version of this thread_num - // so it knows which section of thread_all it is working with - thread_all_[thread_num].thread_num = thread_num; - - // initialize - thread_all_[thread_num].ok = true; - thread_all_[0].bthread = CPPAD_NULL; - } - // Finish setup of thread_all_ for this thread - thread_num_ptr_.reset(& thread_all_[0].thread_num); - - // Now that thread_number() has necessary information for the case - // num_threads_ == 1, and while still in sequential mode, - // call setup for using CppAD::AD in parallel mode. - thread_alloc::parallel_setup(num_threads, in_parallel, thread_number); - thread_alloc::hold_memory(true); - CppAD::parallel_ad(); - - // now change num_threads_ to its final value. - num_threads_ = num_threads; - - // initialize two barriers, one for work done, one for new job ready - wait_for_work_ = new boost::barrier( (unsigned int) num_threads ); - wait_for_job_ = new boost::barrier( (unsigned int) num_threads ); - - // initial job for the threads - thread_job_ = init_enum; - if( num_threads > 1 ) - sequential_execution_ = false; - - // 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_all_[thread_num].bthread = - new boost::thread(thread_work, thread_num); - } - - // Current state is other threads are at wait_for_job_. - // This master thread (thread zero) has not completed wait_for_job_ - sequential_execution_ = true; - return ok; + if( num_threads > MAX_NUMBER_THREADS ) + { std::cerr << "team_create: num_threads greater than "; + std::cerr << MAX_NUMBER_THREADS << std::endl; + exit(1); + } + // check that we currently do not have multiple threads running + ok = num_threads_ == 1; + ok &= wait_for_work_ == CPPAD_NULL; + ok &= wait_for_job_ == CPPAD_NULL; + ok &= sequential_execution_; + + size_t thread_num; + for(thread_num = 0; thread_num < num_threads; thread_num++) + { // Each thread gets a pointer to its version of this thread_num + // so it knows which section of thread_all it is working with + thread_all_[thread_num].thread_num = thread_num; + + // initialize + thread_all_[thread_num].ok = true; + thread_all_[0].bthread = CPPAD_NULL; + } + // Finish setup of thread_all_ for this thread + thread_num_ptr_.reset(& thread_all_[0].thread_num); + + // Now that thread_number() has necessary information for the case + // num_threads_ == 1, and while still in sequential mode, + // call setup for using CppAD::AD in parallel mode. + thread_alloc::parallel_setup(num_threads, in_parallel, thread_number); + thread_alloc::hold_memory(true); + CppAD::parallel_ad(); + + // now change num_threads_ to its final value. + num_threads_ = num_threads; + + // initialize two barriers, one for work done, one for new job ready + wait_for_work_ = new boost::barrier( (unsigned int) num_threads ); + wait_for_job_ = new boost::barrier( (unsigned int) num_threads ); + + // initial job for the threads + thread_job_ = init_enum; + if( num_threads > 1 ) + sequential_execution_ = false; + + // 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_all_[thread_num].bthread = + new boost::thread(thread_work, thread_num); + } + + // Current state is other threads are at wait_for_job_. + // This master thread (thread zero) has not completed wait_for_job_ + sequential_execution_ = true; + return ok; } bool team_work(void worker(void)) { - // Current state is other threads are at wait_for_job_. - // This master thread (thread zero) has not completed wait_for_job_ - bool ok = sequential_execution_; - ok &= thread_number() == 0; - ok &= wait_for_work_ != CPPAD_NULL; - ok &= wait_for_job_ != CPPAD_NULL; - - // set global version of this work routine - worker_ = worker; - - // set the new job that other threads are waiting for - thread_job_ = work_enum; - - // Enter parallel exectuion when master thread calls wait_for_job_ - if( num_threads_ > 1 ) - sequential_execution_ = false; - wait_for_job_->wait(); - - // Now do the work in this thread and then wait - // until all threads have completed wait_for_work_ - worker(); - wait_for_work_->wait(); - - // Current state is other threads are at wait_for_job_. - // This master thread (thread zero) has not completed wait_for_job_ - sequential_execution_ = true; - - size_t thread_num; - for(thread_num = 0; thread_num < num_threads_; thread_num++) - ok &= thread_all_[thread_num].ok; - return ok; + // Current state is other threads are at wait_for_job_. + // This master thread (thread zero) has not completed wait_for_job_ + bool ok = sequential_execution_; + ok &= thread_number() == 0; + ok &= wait_for_work_ != CPPAD_NULL; + ok &= wait_for_job_ != CPPAD_NULL; + + // set global version of this work routine + worker_ = worker; + + // set the new job that other threads are waiting for + thread_job_ = work_enum; + + // Enter parallel exectuion when master thread calls wait_for_job_ + if( num_threads_ > 1 ) + sequential_execution_ = false; + wait_for_job_->wait(); + + // Now do the work in this thread and then wait + // until all threads have completed wait_for_work_ + worker(); + wait_for_work_->wait(); + + // Current state is other threads are at wait_for_job_. + // This master thread (thread zero) has not completed wait_for_job_ + sequential_execution_ = true; + + size_t thread_num; + for(thread_num = 0; thread_num < num_threads_; thread_num++) + ok &= thread_all_[thread_num].ok; + return ok; } bool team_destroy(void) -{ // Current state is other threads are at wait_for_job_. - // This master thread (thread zero) has not completed wait_for_job_ - bool ok = sequential_execution_; - ok &= thread_number() == 0; - ok &= wait_for_work_ != CPPAD_NULL; - ok &= wait_for_job_ != CPPAD_NULL; - - // 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_ - if( num_threads_ > 1 ) - sequential_execution_ = false; - wait_for_job_->wait(); - - // now wait for the other threads to be destroyed - size_t thread_num; - ok &= thread_all_[0].bthread == CPPAD_NULL; - for(thread_num = 1; thread_num < num_threads_; thread_num++) - { thread_all_[thread_num].bthread->join(); - delete thread_all_[thread_num].bthread; - thread_all_[thread_num].bthread = CPPAD_NULL; - } - // now we are down to just the master thread (thread zero) - sequential_execution_ = true; - - // destroy wait_for_work_ - delete wait_for_work_; - wait_for_work_ = CPPAD_NULL; - - // destroy wait_for_job_ - delete wait_for_job_; - wait_for_job_ = CPPAD_NULL; - - // check ok before changing num_threads_ - for(thread_num = 0; thread_num < num_threads_; thread_num++) - ok &= thread_all_[thread_num].ok; - - // now inform CppAD that there is only one thread - num_threads_ = 1; - thread_alloc::parallel_setup(num_threads_, CPPAD_NULL, CPPAD_NULL); - thread_alloc::hold_memory(false); - CppAD::parallel_ad(); +{ // Current state is other threads are at wait_for_job_. + // This master thread (thread zero) has not completed wait_for_job_ + bool ok = sequential_execution_; + ok &= thread_number() == 0; + ok &= wait_for_work_ != CPPAD_NULL; + ok &= wait_for_job_ != CPPAD_NULL; + + // 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_ + if( num_threads_ > 1 ) + sequential_execution_ = false; + wait_for_job_->wait(); + + // now wait for the other threads to be destroyed + size_t thread_num; + ok &= thread_all_[0].bthread == CPPAD_NULL; + for(thread_num = 1; thread_num < num_threads_; thread_num++) + { thread_all_[thread_num].bthread->join(); + delete thread_all_[thread_num].bthread; + thread_all_[thread_num].bthread = CPPAD_NULL; + } + // now we are down to just the master thread (thread zero) + sequential_execution_ = true; + + // destroy wait_for_work_ + delete wait_for_work_; + wait_for_work_ = CPPAD_NULL; + + // destroy wait_for_job_ + delete wait_for_job_; + wait_for_job_ = CPPAD_NULL; + + // check ok before changing num_threads_ + for(thread_num = 0; thread_num < num_threads_; thread_num++) + ok &= thread_all_[thread_num].ok; + + // now inform CppAD that there is only one thread + num_threads_ = 1; + thread_alloc::parallel_setup(num_threads_, CPPAD_NULL, CPPAD_NULL); + thread_alloc::hold_memory(false); + CppAD::parallel_ad(); - return ok; + return ok; } const char* team_name(void) -{ return "bthread"; } +{ return "bthread"; } // END C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/CMakeLists.txt cppad-2019.02.00.0/example/multi_thread/CMakeLists.txt --- cppad-2018.00.00.0/example/multi_thread/CMakeLists.txt 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # initialize list as empty @@ -14,18 +15,16 @@ # Define the operation # CHECK_LIBRARY_EXISTS (LIBRARY FUNCTION LOCATION VARIABLE) -# LIBRARY - the name of the library you are looking for -# FUNCTION - the name of the function -# LOCATION - location where the library should be found -# VARIABLE - variable to store the result +# LIBRARY - the name of the library you are looking for +# FUNCTION - the name of the function +# LOCATION - location where the library should be found +# VARIABLE - variable to store the result INCLUDE(CheckLibraryExists) -# If openmp found, set OpenMP_CXX_FLAGS and process its subdirectory -# -FIND_PACKAGE(OpenMP) +# If openmp found, set process its subdirectory IF ( OPENMP_FOUND ) - # OpenMP_CXX_FLAGS - flags to add to the CXX compiler for OpenMP support - ADD_SUBDIRECTORY(openmp) + # OpenMP_CXX_FLAGS - flags to add to the CXX compiler for OpenMP support + ADD_SUBDIRECTORY(openmp) ENDIF ( OPENMP_FOUND ) # If pthreads found, set pthread_lib and pthread_lib_path and process subdir @@ -35,62 +34,62 @@ FIND_LIBRARY(pthread_lib_path pthread) MESSAGE(STATUS "pthread library path = ${pthread_lib_path}") IF ( pthread_lib_path ) - CHECK_LIBRARY_EXISTS( - pthread pthread_barrier_wait ${pthread_lib_path} pthread_ok - ) - IF ( pthread_ok ) - ADD_SUBDIRECTORY(pthread) - ENDIF ( pthread_ok ) + CHECK_LIBRARY_EXISTS( + pthread pthread_barrier_wait ${pthread_lib_path} pthread_ok + ) + IF ( pthread_ok ) + ADD_SUBDIRECTORY(pthread) + ENDIF ( pthread_ok ) ENDIF ( pthread_lib_path ) # 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(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 " + 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; -}" ) - 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( bthread_lib ) - ADD_SUBDIRECTORY(bthread) - 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 ) +{ boost::barrier wait(1); + return 0; +}" ) + 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( bthread_lib ) + ADD_SUBDIRECTORY(bthread) + 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 ) IF( NOT( "${check_example_multi_thread_depends}" STREQUAL "" ) ) - # check_example_multi_thread - ADD_CUSTOM_TARGET(check_example_multi_thread DEPENDS ${check_example_multi_thread_depends}) - MESSAGE(STATUS "make check_example_multi_thread: available") - - # Change check depends in parent environment - add_to_list(check_depends check_example_multi_thread) - SET(check_depends "${check_depends}" PARENT_SCOPE) + # check_example_multi_thread + ADD_CUSTOM_TARGET(check_example_multi_thread DEPENDS ${check_example_multi_thread_depends}) + MESSAGE(STATUS "make check_example_multi_thread: available") + + # Change check depends in parent environment + add_to_list(check_depends check_example_multi_thread) + SET(check_depends "${check_depends}" PARENT_SCOPE) ENDIF( NOT( "${check_example_multi_thread_depends}" STREQUAL "" ) ) diff -Nru cppad-2018.00.00.0/example/multi_thread/harmonic.cpp cppad-2019.02.00.0/example/multi_thread/harmonic.cpp --- cppad-2018.00.00.0/example/multi_thread/harmonic.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/harmonic.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,18 +1,19 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin harmonic_common$$ $spell - inv - num + inv + num $$ $section Common Variables Used by Multi-threading Sum of 1/i$$ @@ -22,12 +23,12 @@ include files, defines, and variables that are used by the summation that defines the harmonic series $latex \[ - 1 + 1/2 + 1/3 + ... + 1/n + 1 + 1/2 + 1/3 + ... + 1/n \] $$ $head Source$$ $srcfile%example/multi_thread/harmonic.cpp%0 - %// BEGIN COMMON C++%// END COMMON C++% + %// BEGIN COMMON C++%// END COMMON C++% 1%$$ @@ -42,42 +43,42 @@ # define MAX_NUMBER_THREADS 48 namespace { - using CppAD::thread_alloc; // fast multi-threadeding memory allocator + using CppAD::thread_alloc; // fast multi-threadeding memory allocator - // Number of threads, set by previous call to harmonic_time - // (zero means one thread with no multi-threading setup) - size_t num_threads_ = 0; - - // value of mega_sum, set by previous call to harmonic_time. - size_t mega_sum_; - - // structure with information for one thread - typedef struct { - // index to start summation at (worker input) - // set by previous call to harmonic_setup - size_t start; - // index to end summation at (worker input) - // set by previous call to harmonic_setup - size_t stop; - // summation for this thread - // set by worker - double sum; - // false if an error occurs, true otherwise - // set by worker - bool ok; - } work_one_t; - - // vector with information for all threads - // (use pointers instead of values to avoid false sharing) - work_one_t* work_all_[MAX_NUMBER_THREADS]; + // Number of threads, set by previous call to harmonic_time + // (zero means one thread with no multi-threading setup) + size_t num_threads_ = 0; + + // value of mega_sum, set by previous call to harmonic_time. + size_t mega_sum_; + + // structure with information for one thread + typedef struct { + // index to start summation at (worker input) + // set by previous call to harmonic_setup + size_t start; + // index to end summation at (worker input) + // set by previous call to harmonic_setup + size_t stop; + // summation for this thread + // set by worker + double sum; + // false if an error occurs, true otherwise + // set by worker + bool ok; + } work_one_t; + + // vector with information for all threads + // (use pointers instead of values to avoid false sharing) + work_one_t* work_all_[MAX_NUMBER_THREADS]; } // END COMMON C++ /* ------------------------------------------------------------------------------ $begin harmonic_setup$$ $spell - inv - num + inv + num $$ $section Set Up Multi-threading Sum of 1/i$$ @@ -90,7 +91,7 @@ This routine does the setup for splitting the summation that defines the harmonic series $latex \[ - 1 + 1/2 + 1/3 + ... + 1/n + 1 + 1/2 + 1/3 + ... + 1/n \] $$ into separate parts for each thread. @@ -101,13 +102,13 @@ $head num_sum$$ The argument $icode num_sum$$ has prototype $codei% - size_t %num_sum% + size_t %num_sum% %$$ It specifies the value of $latex n$$ in the summation. $head Source$$ $srcfile%example/multi_thread/harmonic.cpp%0 - %// BEGIN SETUP C++%// END SETUP C++% + %// BEGIN SETUP C++%// END SETUP C++% 1%$$ $end @@ -115,31 +116,31 @@ // BEGIN SETUP C++ namespace { bool harmonic_setup(size_t num_sum) -{ // sum = 1/num_sum + 1/(num_sum-1) + ... + 1 - size_t num_threads = std::max(num_threads_, size_t(1)); - bool ok = num_threads == thread_alloc::num_threads(); - ok &= thread_alloc::thread_num() == 0; - ok &= num_sum >= num_threads; - // - for(size_t thread_num = 0; thread_num < num_threads; thread_num++) - { // allocate separate memory for this thread to avoid false sharing - size_t min_bytes(sizeof(work_one_t)), cap_bytes; - void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); - work_all_[thread_num] = static_cast(v_ptr); - // - // in case this thread's worker does not get called - work_all_[thread_num]->ok = false; - // parameters that define the work for this and previous thread - if( thread_num == 0 ) - 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]->start = index; - } - } - work_all_[num_threads-1]->stop = num_sum + 1; - return ok; +{ // sum = 1/num_sum + 1/(num_sum-1) + ... + 1 + size_t num_threads = std::max(num_threads_, size_t(1)); + bool ok = num_threads == thread_alloc::num_threads(); + ok &= thread_alloc::thread_num() == 0; + ok &= num_sum >= num_threads; + // + for(size_t thread_num = 0; thread_num < num_threads; thread_num++) + { // allocate separate memory for this thread to avoid false sharing + size_t min_bytes(sizeof(work_one_t)), cap_bytes; + void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); + work_all_[thread_num] = static_cast(v_ptr); + // + // in case this thread's worker does not get called + work_all_[thread_num]->ok = false; + // parameters that define the work for this and previous thread + if( thread_num == 0 ) + 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]->start = index; + } + } + work_all_[num_threads-1]->stop = num_sum + 1; + return ok; } } // END SETUP C++ @@ -147,8 +148,8 @@ ------------------------------------------------------------------------------- $begin harmonic_worker$$ $spell - inv - num + inv + num $$ $section Do One Thread's Work for Sum of 1/i$$ @@ -162,19 +163,19 @@ This routines computes the sum the summation that defines the harmonic series $codei% - 1/%start% + 1/(%start%+1) + ... + 1/(%end%-1) + 1/%start% + 1/(%start%+1) + ... + 1/(%end%-1) %$$ $head start$$ This is the value of the $cref harmonic_common$$ information $codei% - %start% = work_all_[%thread_num%]->start + %start% = work_all_[%thread_num%]->start %$$ $head end$$ This is the value of the $cref harmonic_common$$ information $codei% - %end% = work_all_[%thread_num%]->end + %end% = work_all_[%thread_num%]->end %$$ $head thread_num$$ @@ -183,7 +184,7 @@ $head Source$$ $srcfile%example/multi_thread/harmonic.cpp%0 - %// BEGIN WORKER C++%// END WORKER C++% + %// BEGIN WORKER C++%// END WORKER C++% 1%$$ $end @@ -191,23 +192,23 @@ // BEGIN WORKER C++ namespace { void harmonic_worker(void) -{ // sum = 1/(stop-1) + 1/(stop-2) + ... + 1/start - size_t thread_num = thread_alloc::thread_num(); - size_t num_threads = std::max(num_threads_, size_t(1)); - bool ok = thread_num < num_threads; - size_t start = work_all_[thread_num]->start; - size_t stop = work_all_[thread_num]->stop; - double sum = 0.; - - ok &= stop > start; - size_t i = stop; - while( i > start ) - { i--; - sum += 1. / double(i); - } +{ // sum = 1/(stop-1) + 1/(stop-2) + ... + 1/start + size_t thread_num = thread_alloc::thread_num(); + size_t num_threads = std::max(num_threads_, size_t(1)); + bool ok = thread_num < num_threads; + size_t start = work_all_[thread_num]->start; + size_t stop = work_all_[thread_num]->stop; + double sum = 0.; + + ok &= stop > start; + size_t i = stop; + while( i > start ) + { i--; + sum += 1. / double(i); + } - work_all_[thread_num]->sum = sum; - work_all_[thread_num]->ok = ok; + work_all_[thread_num]->sum = sum; + work_all_[thread_num]->ok = ok; } } // END WORKER C++ @@ -215,8 +216,8 @@ ------------------------------------------------------------------------------- $begin harmonic_takedown$$ $spell - inv - num + inv + num $$ $section Take Down Multi-threading Sum of 1/i$$ @@ -229,7 +230,7 @@ This routine does the takedown for splitting the summation that defines the harmonic series $latex \[ - s = 1 + 1/2 + 1/3 + ... + 1/n + s = 1 + 1/2 + 1/3 + ... + 1/n \] $$ into separate parts for each thread; see $cref harmonic_setup$$. @@ -240,14 +241,14 @@ $head sum$$ This argument has prototype $codei% - double& %sum% + double& %sum% %$$ The input value of the argument does not matter. Upon return it is the value of the summation; i.e. $latex s$$. $head Source$$ $srcfile%example/multi_thread/harmonic.cpp%0 - %// BEGIN TAKEDOWN C++%// END TAKEDOWN C++% + %// BEGIN TAKEDOWN C++%// END TAKEDOWN C++% 1%$$ $end @@ -255,33 +256,33 @@ // BEGIN TAKEDOWN C++ namespace { bool harmonic_takedown(double& sum) -{ // sum = 1/num_sum + 1/(num_sum-1) + ... + 1 - bool ok = true; - ok &= thread_alloc::thread_num() == 0; - size_t num_threads = std::max(num_threads_, size_t(1)); - sum = 0.; - // - // go down so that free memory for other threads before memory for master - size_t thread_num = num_threads; - while(thread_num--) - { // check that this tread was ok with the work it did - ok &= work_all_[thread_num]->ok; - // - // add this threads contribution to the sum - sum += work_all_[thread_num]->sum; - // - // 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 - // (for general applications, the master might still be using memory) - ok &= thread_alloc::inuse(thread_num) == 0; - // - // return all memory being held for future use by this thread - thread_alloc::free_available(thread_num); - } - return ok; +{ // sum = 1/num_sum + 1/(num_sum-1) + ... + 1 + bool ok = true; + ok &= thread_alloc::thread_num() == 0; + size_t num_threads = std::max(num_threads_, size_t(1)); + sum = 0.; + // + // go down so that free memory for other threads before memory for master + size_t thread_num = num_threads; + while(thread_num--) + { // check that this tread was ok with the work it did + ok &= work_all_[thread_num]->ok; + // + // add this threads contribution to the sum + sum += work_all_[thread_num]->sum; + // + // 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 + // (for general applications, the master might still be using memory) + ok &= thread_alloc::inuse(thread_num) == 0; + // + // return all memory being held for future use by this thread + thread_alloc::free_available(thread_num); + } + return ok; } } // END TAKEDOWN C++ @@ -289,9 +290,9 @@ ------------------------------------------------------------------------------ $begin harmonic_sum$$ $spell - inv - num - bool + inv + num + bool $$ @@ -303,7 +304,7 @@ $head Purpose$$ Multi-threaded computation of the summation that defines the harmonic series $latex \[ - s = 1 + 1/2 + 1/3 + ... + 1/n + s = 1 + 1/2 + 1/3 + ... + 1/n \] $$ $head Thread$$ @@ -313,14 +314,14 @@ $head ok$$ This return value has prototype $codei% - bool %ok% + bool %ok% %$$ If this return value is false, an error occurred during $code harmonic$$. $head sum$$ This argument has prototype $codei% - double& %sum% + double& %sum% %$$ The input value of the argument does not matter. Upon return it is the value of the summation; i.e. $latex s$$. @@ -328,13 +329,13 @@ $head num_sum$$ This argument has prototype $codei% - size_t %num_sum% + size_t %num_sum% %$$ It specifies the number of terms in the summation; i.e. $latex n$$. $head Source$$ $srcfile%example/multi_thread/harmonic.cpp%0 - %// BEGIN SUM C++%// END SUM C++% + %// BEGIN SUM C++%// END SUM C++% 1%$$ $end @@ -342,22 +343,23 @@ // BEGIN SUM C++ namespace { bool harmonic_sum(double& sum, size_t num_sum) -{ // sum = 1/num_sum + 1/(num_sum-1) + ... + 1 - bool ok = true; - ok &= thread_alloc::thread_num() == 0; - - // setup the work for multi-threading - ok &= harmonic_setup(num_sum); - - // now do the work for each thread - if( num_threads_ > 0 ) - team_work( harmonic_worker ); - else harmonic_worker(); +{ // sum = 1/num_sum + 1/(num_sum-1) + ... + 1 + bool ok = true; + ok &= thread_alloc::thread_num() == 0; + + // setup the work for multi-threading + ok &= harmonic_setup(num_sum); + + // now do the work for each thread + if( num_threads_ > 0 ) + team_work( harmonic_worker ); + else + harmonic_worker(); - // combine the result for each thread and takedown the multi-threading. - ok &= harmonic_takedown(sum); + // combine the result for each thread and takedown the multi-threading. + ok &= harmonic_takedown(sum); - return ok; + return ok; } } // END SUM C++ @@ -365,15 +367,15 @@ ------------------------------------------------------------------------------- $begin harmonic_time$$ $spell - openmp - pthreads - alloc - num - bool - mega - inv - CppAD - parallelize + openmp + pthreads + alloc + num + bool + mega + inv + CppAD + parallelize $$ @@ -381,14 +383,14 @@ $head Syntax$$ $icode%ok% = harmonic_time( - %time_out%, %test_time%, %num_threads%, %mega_sum% + %time_out%, %test_time%, %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 $latex \[ - 1 + 1/2 + 1/3 + ... + 1/n + 1 + 1/2 + 1/3 + ... + 1/n \] $$ $head Thread$$ @@ -398,7 +400,7 @@ $head ok$$ This return value has prototype $codei% - bool %ok% + bool %ok% %$$ If it is true, $code harmonic_time$$ passed the correctness test. @@ -407,7 +409,7 @@ $head time_out$$ This argument has prototype $codei% - double& %time_out% + double& %time_out% %$$ The input value of the argument does not matter. Upon return it is the number of wall clock seconds required for @@ -423,24 +425,24 @@ $head num_threads$$ This argument has prototype $codei% - size_t %num_threads% + size_t %num_threads% %$$ It specifies the number of threads that are available for this test. If it is zero, the test is run without the multi-threading environment and $codei% - 1 == thread_alloc::num_threads() + 1 == 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% = thread_alloc::num_threads() + %num_threads% = thread_alloc::num_threads() %$$ when $code harmonic_time$$ is called. $head mega_sum$$ This argument has prototype $codei% - size_t& %mega_sum% + size_t& %mega_sum% %$$ and is greater than zero. The value $latex n$$ in the summation @@ -448,7 +450,7 @@ $head Source$$ $srcfile%example/multi_thread/harmonic.cpp%0 - %// BEGIN TIME C++%// END TIME C++% + %// BEGIN TIME C++%// END TIME C++% 1%$$ $end @@ -465,69 +467,69 @@ # include namespace { - // value of sum resulting from most recent call to test_once - double sum_ = 0.; - // - void test_once(void) - { if( mega_sum_ < 1 ) - { std::cerr << "harmonic_time: mega_sum < 1" << std::endl; - exit(1); - } - size_t num_sum = mega_sum_ * 1000000; - bool ok = harmonic_sum(sum_, num_sum); - if( ! ok ) - { std::cerr << "harmonic: error" << std::endl; - exit(1); - } - return; - } - // - void test_repeat(size_t repeat) - { size_t i; - for(i = 0; i < repeat; i++) - test_once(); - return; - } + // value of sum resulting from most recent call to test_once + double sum_ = 0.; + // + void test_once(void) + { if( mega_sum_ < 1 ) + { std::cerr << "harmonic_time: mega_sum < 1" << std::endl; + exit(1); + } + size_t num_sum = mega_sum_ * 1000000; + bool ok = harmonic_sum(sum_, num_sum); + if( ! ok ) + { std::cerr << "harmonic: error" << std::endl; + exit(1); + } + return; + } + // + void test_repeat(size_t repeat) + { size_t i; + for(i = 0; i < repeat; i++) + test_once(); + return; + } } // This is the only routine that is accessible outside of this file bool harmonic_time( - double& time_out, double test_time, size_t num_threads, size_t mega_sum) -{ bool ok = true; - ok &= thread_alloc::thread_num() == 0; - - // arguments passed to harmonic_sum - num_threads_ = num_threads; - mega_sum_ = mega_sum; - - // create team of threads - ok &= thread_alloc::in_parallel() == false; - if( num_threads > 0 ) - { team_create(num_threads); - ok &= num_threads == thread_alloc::num_threads(); - } - else - { ok &= 1 == thread_alloc::num_threads(); - } - - // run the test case and set the time return value - time_out = CppAD::time_test(test_repeat, test_time); - - // destroy team of threads - if( num_threads > 0 ) - team_destroy(); - ok &= thread_alloc::in_parallel() == false; - - // Correctness check - double eps1000 = - double(mega_sum_) * 1e3 * std::numeric_limits::epsilon(); - size_t i = mega_sum_ * 1000000; - double check = 0.; - while(i) - check += 1. / double(i--); - ok &= std::fabs(sum_ - check) <= eps1000; + double& time_out, double test_time, size_t num_threads, size_t mega_sum) +{ bool ok = true; + ok &= thread_alloc::thread_num() == 0; + + // arguments passed to harmonic_sum + num_threads_ = num_threads; + mega_sum_ = mega_sum; + + // create team of threads + ok &= thread_alloc::in_parallel() == false; + if( num_threads > 0 ) + { team_create(num_threads); + ok &= num_threads == thread_alloc::num_threads(); + } + else + { ok &= 1 == thread_alloc::num_threads(); + } + + // run the test case and set the time return value + time_out = CppAD::time_test(test_repeat, test_time); + + // destroy team of threads + if( num_threads > 0 ) + team_destroy(); + ok &= thread_alloc::in_parallel() == false; + + // Correctness check + double eps1000 = + double(mega_sum_) * 1e3 * std::numeric_limits::epsilon(); + size_t i = mega_sum_ * 1000000; + double check = 0.; + while(i) + check += 1. / double(i--); + ok &= std::fabs(sum_ - check) <= eps1000; - return ok; + return ok; } // END TIME C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/harmonic.hpp cppad-2019.02.00.0/example/multi_thread/harmonic.hpp --- cppad-2018.00.00.0/example/multi_thread/harmonic.hpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/harmonic.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,16 +3,17 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ bool harmonic_time( - double& time_out, double test_time, size_t num_threads, size_t mega_sum + double& time_out, double test_time, size_t num_threads, size_t mega_sum ); # endif diff -Nru cppad-2018.00.00.0/example/multi_thread/harmonic.omh cppad-2019.02.00.0/example/multi_thread/harmonic.omh --- cppad-2018.00.00.0/example/multi_thread/harmonic.omh 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/harmonic.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,16 +1,17 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin harmonic.cpp$$ $spell - cpp + cpp $$ $section Multi-Threading Harmonic Summation Example / Test$$ @@ -18,7 +19,7 @@ $head Source File$$ All of the routines below are located in the file $codep - example/multi_thread/harmonic.cpp + example/multi_thread/harmonic.cpp $$ $childtable%example/multi_thread/harmonic.cpp%$$ diff -Nru cppad-2018.00.00.0/example/multi_thread/makefile.am cppad-2019.02.00.0/example/multi_thread/makefile.am --- cppad-2018.00.00.0/example/multi_thread/makefile.am 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -39,21 +40,14 @@ # 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) -else -# AM_CXXFLAGS = -g $(CXX_FLAGS) -AM_CXXFLAGS = -DNDEBUG -O2 $(CXX_FLAGS) -endif -# -AM_CPPFLAGS = \ - -I. \ - -I$(top_srcdir) \ +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ $(OPENMP_FLAGS) # +# AM_LDFLAGS = $(OPENMP_FLAGS) LDADD = $(BOOST_LIB) $(BTHREAD_LIB) $(PTHREAD_LIB) # @@ -64,7 +58,8 @@ \ harmonic.omh harmonic.cpp harmonic.hpp \ multi_atomic.omh multi_atomic.cpp multi_atomic.hpp \ - multi_newton.omh multi_newton.cpp multi_newton.hpp + multi_newton.omh multi_newton.cpp multi_newton.hpp \ + multi_checkpoint.omh multi_checkpoint.cpp multi_checkpoint.hpp # bthread_test_SOURCES = \ $(SHARED_SRC) \ diff -Nru cppad-2018.00.00.0/example/multi_thread/makefile.in cppad-2019.02.00.0/example/multi_thread/makefile.in --- cppad-2018.00.00.0/example/multi_thread/makefile.in 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -104,7 +104,7 @@ @CppAD_PTHREAD_TRUE@am__EXEEXT_3 = pthread_test$(EXEEXT) am__objects_1 = thread_test.$(OBJEXT) team_example.$(OBJEXT) \ harmonic.$(OBJEXT) multi_atomic.$(OBJEXT) \ - multi_newton.$(OBJEXT) + multi_newton.$(OBJEXT) multi_checkpoint.$(OBJEXT) am__dirstamp = $(am__leading_dot)dirstamp am_bthread_test_OBJECTS = $(am__objects_1) \ bthread/team_bthread.$(OBJEXT) bthread/a11c_bthread.$(OBJEXT) \ @@ -224,19 +224,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -309,10 +308,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -331,9 +328,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -356,8 +355,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -390,20 +387,16 @@ @CppAD_PTHREAD_FALSE@PTHREAD_TEST = # @CppAD_PTHREAD_TRUE@PTHREAD_TEST = pthread_test -# 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_CPPFLAGS = \ - -I. \ - -I$(top_srcdir) \ +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ $(OPENMP_FLAGS) # +# AM_LDFLAGS = $(OPENMP_FLAGS) LDADD = $(BOOST_LIB) $(BTHREAD_LIB) $(PTHREAD_LIB) # @@ -414,7 +407,8 @@ \ harmonic.omh harmonic.cpp harmonic.hpp \ multi_atomic.omh multi_atomic.cpp multi_atomic.hpp \ - multi_newton.omh multi_newton.cpp multi_newton.hpp + multi_newton.omh multi_newton.cpp multi_newton.hpp \ + multi_checkpoint.omh multi_checkpoint.cpp multi_checkpoint.hpp # bthread_test_SOURCES = \ @@ -535,6 +529,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/harmonic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi_atomic.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi_checkpoint.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/multi_newton.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/team_example.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread_test.Po@am__quote@ diff -Nru cppad-2018.00.00.0/example/multi_thread/multi_atomic.cpp cppad-2019.02.00.0/example/multi_thread/multi_atomic.cpp --- cppad-2018.00.00.0/example/multi_thread/multi_atomic.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/multi_atomic.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,23 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin multi_atomic_user$$ $spell - au - const - ADvector - num - itr + au + const + ADvector + num + itr $$ $section Defines a User Atomic Operation that Computes Square Root$$ @@ -27,13 +28,13 @@ $icode%a_square_root%(%au%, %ay%)%$$ $head Purpose$$ -This user atomic operation computes a square root using Newton's method. +This atomic function operation computes a square root using Newton's method. It is meant to be very inefficient in order to demonstrate timing results. $head au$$ This argument has prototype $codei% - const %ADvector%& %au% + const %ADvector%& %au% %$$ where $icode ADvector$$ is a $cref/simple vector class/SimpleVector/$$ with elements @@ -43,7 +44,7 @@ $subhead num_itr$$ We use the notation $codei% - %num_itr% = size_t( Integer( %au%[0] ) ) + %num_itr% = size_t( Integer( %au%[0] ) ) %$$ for the number of Newton iterations in the computation of the square root function. The component $icode%au%[0]%$$ must be a @@ -52,21 +53,21 @@ $subhead y_initial$$ We use the notation $codei% - %y_initial% = %au%[1] + %y_initial% = %au%[1] %$$ for the initial value of the Newton iterate. $subhead y_squared$$ We use the notation $codei% - %y_squared% = %au%[2] + %y_squared% = %au%[2] %$$ for the value we are taking the square root of. $head ay$$ This argument has prototype $codei% - %ADvector%& %ay% + %ADvector%& %ay% %$$ The size of $icode ay$$ is one and $icode%ay%[0]%$$ is the square root of $icode y_squared$$. @@ -77,7 +78,7 @@ $head Source$$ $srcfile%example/multi_thread/multi_atomic.cpp%0 - %// BEGIN USER C++%// END USER C++% + %// BEGIN USER C++%// END USER C++% 1%$$ $end @@ -94,54 +95,54 @@ class atomic_user : public CppAD::atomic_base { public: - // ctor - atomic_user(void) - : CppAD::atomic_base("atomic_square_root") - { } + // ctor + atomic_user(void) + : CppAD::atomic_base("atomic_square_root") + { } private: - // forward mode routine called by CppAD - virtual bool forward( - size_t p , - size_t q , - const vector& vu , - vector& vy , - const vector& tu , - vector& ty ) - { + // forward mode routine called by CppAD + virtual bool forward( + size_t p , + size_t q , + const vector& vu , + vector& vy , + const vector& tu , + vector& ty ) + { # ifndef NDEBUG - size_t n = tu.size() / (q + 1); - size_t m = ty.size() / (q + 1); - assert( n == 3 ); - assert( m == 1 ); + size_t n = tu.size() / (q + 1); + size_t m = ty.size() / (q + 1); + assert( n == 3 ); + assert( m == 1 ); # endif - // only implementing zero order forward for this example - if( q != 0 ) - return false; - - // extract components of argument vector - size_t num_itr = size_t( tu[0] ); - double y_initial = tu[1]; - double y_squared = tu[2]; - - // check for setting variable information - if( vu.size() > 0 ) - { if( vu[0] ) - return false; - vy[0] = vu[1] || vu[2]; - } - - // Use Newton's method to solve f(y) = y^2 = y_squared - double y_itr = y_initial; - for(size_t itr = 0; itr < num_itr; itr++) - { // solve (y - y_itr) * f'(y_itr) = y_squared - y_itr^2 - double fp_itr = 2.0 * y_itr; - y_itr = y_itr + (y_squared - y_itr * y_itr) / fp_itr; - } - - // return the Newton approximation for f(y) = y_squared - ty[0] = y_itr; - return true; - } + // only implementing zero order forward for this example + if( q != 0 ) + return false; + + // extract components of argument vector + size_t num_itr = size_t( tu[0] ); + double y_initial = tu[1]; + double y_squared = tu[2]; + + // check for setting variable information + if( vu.size() > 0 ) + { if( vu[0] ) + return false; + vy[0] = vu[1] || vu[2]; + } + + // Use Newton's method to solve f(y) = y^2 = y_squared + double y_itr = y_initial; + for(size_t itr = 0; itr < num_itr; itr++) + { // solve (y - y_itr) * f'(y_itr) = y_squared - y_itr^2 + double fp_itr = 2.0 * y_itr; + y_itr = y_itr + (y_squared - y_itr * y_itr) / fp_itr; + } + + // return the Newton approximation for f(y) = y_squared + ty[0] = y_itr; + return true; + } }; } // END USER C++ @@ -158,55 +159,55 @@ $head Source$$ $srcfile%example/multi_thread/multi_atomic.cpp%0 - %// BEGIN COMMON C++%// END COMMON C++% + %// BEGIN COMMON C++%// END COMMON C++% 1%$$ $end */ // BEGIN COMMON C++ namespace { - // Number of threads, set by multi_atomic_time - // (zero means one thread with no multi-threading setup) - size_t num_threads_ = 0; - - // Number of Newton iterations, set by multi_atomic_time - size_t num_itr_; - - // We can use one atomic_user function for all threads because - // there is no member data that gets changed during worker call. - // This needs to stay in scope for as long as a recording will use it. - // We cannot be in parallel mode when this object is created or deleted. - // We use a pointer so that there is no left over memory in thread zero. - atomic_user* a_square_root_ = 0; - - // structure with information for one thread - typedef struct { - // used by worker to compute the square root, set by multi_atomic_setup - CppAD::ADFun* fun; - // - // value we are computing square root of, set by multi_atomic_setup - vector* y_squared; - // - // square root, set by worker - vector* square_root; - // - // false if an error occurs, true otherwise, set by worker - bool ok; - } work_one_t; - // - // Vector with information for all threads - // (uses pointers instead of values to avoid false sharing) - // allocated by multi_atomic_setup, freed by multi_atomic_takedown - work_one_t* work_all_[CPPAD_MAX_NUM_THREADS]; + // Number of threads, set by multi_atomic_time + // (zero means one thread with no multi-threading setup) + size_t num_threads_ = 0; + + // Number of Newton iterations, set by multi_atomic_time + size_t num_itr_; + + // We can use one atomic_atomic function for all threads because + // there is no member data that gets changed during worker call. + // This needs to stay in scope for as long as a recording will use it. + // We cannot be in parallel mode when this object is created or deleted. + // We use a pointer so that there is no left over memory in thread zero. + atomic_user* a_square_root_ = 0; + + // structure with information for one thread + typedef struct { + // used by worker to compute the square root, set by multi_atomic_setup + CppAD::ADFun* fun; + // + // value we are computing square root of, set by multi_atomic_setup + vector* y_squared; + // + // square root, set by worker + vector* square_root; + // + // false if an error occurs, true otherwise, set by worker + bool ok; + } work_one_t; + // + // Vector with information for all threads + // (uses pointers instead of values to avoid false sharing) + // allocated by multi_atomic_setup, freed by multi_atomic_takedown + work_one_t* work_all_[CPPAD_MAX_NUM_THREADS]; } // END COMMON C++ /* ------------------------------------------------------------------------------- $begin multi_atomic_setup$$ $spell - const - CppAD - bool + const + CppAD + bool $$ $section Multi-Threaded User Atomic Set Up$$. @@ -224,7 +225,7 @@ $head y_squared$$ This argument has prototype $codei% - const vector& %y_squared% + const vector& %y_squared% %$$ and its size is equal to the number of equations to solve. It is the values that we are computing the square root of. @@ -232,14 +233,14 @@ $head ok$$ This return value has prototype $codei% - bool %ok% + bool %ok% %$$ If it is false, $code multi_atomic_setup$$ detected an error. $head Source$$ $srcfile%example/multi_thread/multi_atomic.cpp%0 - %// BEGIN SETUP C++%// END SETUP C++% + %// BEGIN SETUP C++%// END SETUP C++% 1%$$ $end @@ -247,60 +248,60 @@ // BEGIN SETUP C++ namespace { bool multi_atomic_setup(const vector& y_squared) -{ using CppAD::AD; - size_t num_threads = std::max(num_threads_, size_t(1)); - bool ok = num_threads == thread_alloc::num_threads(); - ok &= thread_alloc::thread_num() == 0; - // - // declare independent variable variable vector - vector< AD > ax(1); - ax[0] = 2.0; - CppAD::Independent(ax); - // - // argument and result for atomic function - vector< AD > au(3), ay(1); - au[0] = AD( num_itr_ ); // num_itr - au[1] = ax[0]; // y_initial - au[2] = ax[0]; // y_squared - // put user atomic operation in recording - (*a_square_root_)(au, ay); - // - // f(u) = sqrt(u) - CppAD::ADFun fun(ax, ay); - // - // number of square roots for each thread - size_t per_thread = (y_squared.size() + num_threads - 1) / num_threads; - size_t y_index = 0; - // - for(size_t thread_num = 0; thread_num < num_threads; thread_num++) - { // allocate separate memory for each thread to avoid false sharing - size_t min_bytes(sizeof(work_one_t)), cap_bytes; - void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); - work_all_[thread_num] = static_cast(v_ptr); - // - // Run constructor on work_all_[thread_num]->fun - work_all_[thread_num]->fun = new CppAD::ADFun; - // - // Run constructor on work_all_[thread_num] vectors - work_all_[thread_num]->y_squared = new vector; - work_all_[thread_num]->square_root = new vector; - // - // Each worker gets a separate copy of fun. This is necessary because - // the Taylor coefficients will be set by each thread. - *(work_all_[thread_num]->fun) = fun; - // - // values we are computing square root of for this thread - ok &= 0 == work_all_[thread_num]->y_squared->size(); - for(size_t i = 0; i < per_thread; i++) - if( y_index < y_squared.size() ) - work_all_[thread_num]->y_squared->push_back(y_squared[y_index++]); - // - // set to false in case this thread's worker does not get called - work_all_[thread_num]->ok = false; - } - ok &= y_index == y_squared.size(); - // - return ok; +{ using CppAD::AD; + size_t num_threads = std::max(num_threads_, size_t(1)); + bool ok = num_threads == thread_alloc::num_threads(); + ok &= thread_alloc::thread_num() == 0; + // + // declare independent variable variable vector + vector< AD > ax(1); + ax[0] = 2.0; + CppAD::Independent(ax); + // + // argument and result for atomic function + vector< AD > au(3), ay(1); + au[0] = AD( num_itr_ ); // num_itr + au[1] = ax[0]; // y_initial + au[2] = ax[0]; // y_squared + // put atomic function operation in recording + (*a_square_root_)(au, ay); + // + // f(u) = sqrt(u) + CppAD::ADFun fun(ax, ay); + // + // number of square roots for each thread + size_t per_thread = (y_squared.size() + num_threads - 1) / num_threads; + size_t y_index = 0; + // + for(size_t thread_num = 0; thread_num < num_threads; thread_num++) + { // allocate separate memory for each thread to avoid false sharing + size_t min_bytes(sizeof(work_one_t)), cap_bytes; + void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); + work_all_[thread_num] = static_cast(v_ptr); + // + // Run constructor on work_all_[thread_num]->fun + work_all_[thread_num]->fun = new CppAD::ADFun; + // + // Run constructor on work_all_[thread_num] vectors + work_all_[thread_num]->y_squared = new vector; + work_all_[thread_num]->square_root = new vector; + // + // Each worker gets a separate copy of fun. This is necessary because + // the Taylor coefficients will be set by each thread. + *(work_all_[thread_num]->fun) = fun; + // + // values we are computing square root of for this thread + ok &= 0 == work_all_[thread_num]->y_squared->size(); + for(size_t i = 0; i < per_thread; i++) + if( y_index < y_squared.size() ) + work_all_[thread_num]->y_squared->push_back(y_squared[y_index++]); + // + // set to false in case this thread's worker does not get called + work_all_[thread_num]->ok = false; + } + ok &= y_index == y_squared.size(); + // + return ok; } } // END SETUP C++ @@ -317,7 +318,7 @@ $head Source$$ $srcfile%example/multi_thread/multi_atomic.cpp%0 - %// BEGIN WORKER C++%// END WORKER C++% + %// BEGIN WORKER C++%// END WORKER C++% 1%$$ $end @@ -325,20 +326,20 @@ // BEGIN WORKER C++ namespace { void multi_atomic_worker(void) -{ size_t thread_num = thread_alloc::thread_num(); - size_t num_threads = std::max(num_threads_, size_t(1)); - bool ok = thread_num < num_threads; - // - vector x(1), y(1); - size_t n = work_all_[thread_num]->y_squared->size(); - work_all_[thread_num]->square_root->resize(n); - for(size_t i = 0; i < n; i++) - { x[0] = (* work_all_[thread_num]->y_squared )[i]; - y = work_all_[thread_num]->fun->Forward(0, x); - // - (* work_all_[thread_num]->square_root )[i] = y[0]; - } - work_all_[thread_num]->ok = ok; +{ size_t thread_num = thread_alloc::thread_num(); + size_t num_threads = std::max(num_threads_, size_t(1)); + bool ok = thread_num < num_threads; + // + vector x(1), y(1); + size_t n = work_all_[thread_num]->y_squared->size(); + work_all_[thread_num]->square_root->resize(n); + for(size_t i = 0; i < n; i++) + { x[0] = (* work_all_[thread_num]->y_squared )[i]; + y = work_all_[thread_num]->fun->Forward(0, x); + // + (* work_all_[thread_num]->square_root )[i] = y[0]; + } + work_all_[thread_num]->ok = ok; } } // END WORKER C++ @@ -346,8 +347,8 @@ ------------------------------------------------------------------------------ $begin multi_atomic_takedown$$ $spell - CppAD - bool + CppAD + bool $$ $section Multi-Threaded User Atomic Take Down$$ @@ -366,7 +367,7 @@ $head square_root$$ This argument has prototype $codei% - vector& %square_root% + vector& %square_root% %$$ The input value of $icode square_root$$ does not matter. Upon return, @@ -376,14 +377,14 @@ $head ok$$ This return value has prototype $codei% - bool %ok% + bool %ok% %$$ If it is false, $code multi_atomic_takedown$$ detected an error. $head Source$$ $srcfile%example/multi_thread/multi_atomic.cpp%0 - %// BEGIN TAKEDOWN C++%// END TAKEDOWN C++% + %// BEGIN TAKEDOWN C++%// END TAKEDOWN C++% 1%$$ $end @@ -391,54 +392,54 @@ // BEGIN TAKEDOWN C++ namespace { bool multi_atomic_takedown(vector& square_root) -{ bool ok = true; - ok &= thread_alloc::thread_num() == 0; - size_t num_threads = std::max(num_threads_, size_t(1)); - // - // extract square roots in original order - square_root.resize(0); - for(size_t thread_num = 0; thread_num < num_threads; thread_num++) - { // results for this thread - size_t n = work_all_[thread_num]->square_root->size(); - for(size_t i = 0; i < n; i++) - square_root.push_back((* work_all_[thread_num]->square_root )[i]); - } - // - // go down so that free memory for other threads before memory for master - size_t thread_num = num_threads; - while(thread_num--) - { // check that this tread was ok with the work it did - ok &= work_all_[thread_num]->ok; - // - // run destructor on vector object for this thread - delete work_all_[thread_num]->y_squared; - delete work_all_[thread_num]->square_root; - // - // run destructor on function object for this thread - delete work_all_[thread_num]->fun; - // - // 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 - if( thread_num > 0 ) - { ok &= 0 == thread_alloc::inuse(thread_num); - // - // return all memory being held for future use by this thread - thread_alloc::free_available(thread_num); - } - } - return ok; +{ bool ok = true; + ok &= thread_alloc::thread_num() == 0; + size_t num_threads = std::max(num_threads_, size_t(1)); + // + // extract square roots in original order + square_root.resize(0); + for(size_t thread_num = 0; thread_num < num_threads; thread_num++) + { // results for this thread + size_t n = work_all_[thread_num]->square_root->size(); + for(size_t i = 0; i < n; i++) + square_root.push_back((* work_all_[thread_num]->square_root )[i]); + } + // + // go down so that free memory for other threads before memory for master + size_t thread_num = num_threads; + while(thread_num--) + { // check that this tread was ok with the work it did + ok &= work_all_[thread_num]->ok; + // + // run destructor on vector object for this thread + delete work_all_[thread_num]->y_squared; + delete work_all_[thread_num]->square_root; + // + // run destructor on function object for this thread + delete work_all_[thread_num]->fun; + // + // 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 + if( thread_num > 0 ) + { ok &= 0 == thread_alloc::inuse(thread_num); + // + // return all memory being held for future use by this thread + thread_alloc::free_available(thread_num); + } + } + return ok; } } // END TAKEDOWN C++ /* $begin multi_atomic_run$$ $spell - const - CppAD - bool + const + CppAD + bool $$ $section Run Multi-Threaded User Atomic Calculation$$ @@ -453,7 +454,7 @@ $head y_squared$$ This argument has prototype $codei% - const vector& %y_squared% + const vector& %y_squared% %$$ and its size is equal to the number of threads. It is the values that we are computing the square root of. @@ -461,7 +462,7 @@ $head square_root$$ This argument has prototype $codei% - vector& %square_root% + vector& %square_root% %$$ The input value of $icode square_root$$ does not matter. Upon return, @@ -471,14 +472,14 @@ $head ok$$ This return value has prototype $codei% - bool %ok% + bool %ok% %$$ If it is false, $code multi_atomic_run$$ detected an error. $head Source$$ $srcfile%example/multi_thread/multi_atomic.cpp%0 - %// BEGIN RUN C++%// END RUN C++% + %// BEGIN RUN C++%// END RUN C++% 1%$$ $end @@ -487,24 +488,25 @@ // BEGIN RUN C++ namespace { bool multi_atomic_run( - const vector& y_squared , - vector& square_root ) + const vector& y_squared , + vector& square_root ) { - bool ok = true; - ok &= thread_alloc::thread_num() == 0; + bool ok = true; + ok &= thread_alloc::thread_num() == 0; - // setup the work for multi-threading - ok &= multi_atomic_setup(y_squared); + // setup the work for multi-threading + ok &= multi_atomic_setup(y_squared); - // now do the work for each thread - if( num_threads_ > 0 ) - team_work( multi_atomic_worker ); - else multi_atomic_worker(); + // now do the work for each thread + if( num_threads_ > 0 ) + team_work( multi_atomic_worker ); + else + multi_atomic_worker(); - // combine the result for each thread and takedown the multi-threading. - ok &= multi_atomic_takedown(square_root); + // combine the result for each thread and takedown the multi-threading. + ok &= multi_atomic_takedown(square_root); - return ok; + return ok; } } // END RUN C++ @@ -512,17 +514,17 @@ ------------------------------------------------------------------------------ $begin multi_atomic_time$$ $spell - num_itr - alloc - bool - CppAD + num + alloc + bool + CppAD $$ $section Timing Test for Multi-Threaded User Atomic Calculation$$ $head Syntax$$ $icode%ok% = multi_atomic_time( - %time_out%, %test_time%, %num_threads%, %num_itr% + %time_out%, %test_time%, %num_threads%, %num_solve% )%$$ @@ -533,7 +535,7 @@ $head time_out$$ This argument has prototype $codei% - double& %time_out% + double& %time_out% %$$ Its input value of the argument does not matter. Upon return it is the number of wall clock seconds @@ -542,7 +544,7 @@ $head test_time$$ This argument has prototype $codei% - double %test_time% + double %test_time% %$$ and 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 @@ -553,16 +555,16 @@ $head num_threads$$ This argument has prototype $codei% - size_t %num_threads% + size_t %num_threads% %$$ It specifies the number of threads that are available for this test. If it is zero, the test is run without the multi-threading environment and $codei% - 1 == thread_alloc::num_threads() + 1 == thread_alloc::num_threads() %$$ If it is non-zero, the test is run with the multi-threading and $codei% - %num_threads% = thread_alloc::num_threads() + %num_threads% = thread_alloc::num_threads() %$$ $head num_solve$$ @@ -571,7 +573,7 @@ $head ok$$ The return value has prototype $codei% - bool %ok% + bool %ok% %$$ If it is true, $code harmonic_time$$ passed the correctness test and @@ -583,87 +585,87 @@ // BEGIN TIME C++ namespace { - // values we are taking the square root of - vector y_squared_; + // values we are taking the square root of + vector y_squared_; - // results of the square root calculations - vector square_root_; - // - void test_once(void) - { bool ok = multi_atomic_run(y_squared_, square_root_); - if( ! ok ) - { std::cerr << "multi_atomic_run: error" << std::endl; - exit(1); - } - return; - } - // - void test_repeat(size_t repeat) - { size_t i; - for(i = 0; i < repeat; i++) - test_once(); - return; - } + // results of the square root calculations + vector square_root_; + // + void test_once(void) + { bool ok = multi_atomic_run(y_squared_, square_root_); + if( ! ok ) + { std::cerr << "multi_atomic_run: error" << std::endl; + exit(1); + } + return; + } + // + void test_repeat(size_t repeat) + { size_t i; + for(i = 0; i < repeat; i++) + test_once(); + return; + } } // This is the only routine that is accessible outside of this file bool multi_atomic_time( - double& time_out, double test_time, size_t num_threads, size_t num_solve + double& time_out, double test_time, size_t num_threads, size_t num_solve ) -{ bool ok = true; - // - size_t initial_inuse = thread_alloc::inuse(0); - - // number of threads, zero for no multi-threading - num_threads_ = num_threads; - - // number of Newton iterations - num_itr_ = 20; - - // values we are talking the square root of - y_squared_.resize(num_solve); - for(size_t i_solve = 0; i_solve < num_solve; i_solve++) - y_squared_[i_solve] = double(i_solve) + 2.0; - - // must create a_square_root_ sequential mode - a_square_root_ = new atomic_user; - - // create team of threads - ok &= thread_alloc::in_parallel() == false; - if( num_threads > 0 ) - { team_create(num_threads); - ok &= num_threads == thread_alloc::num_threads(); - } - else - { ok &= 1 == thread_alloc::num_threads(); - } - - // run the test case and set the time return value - time_out = CppAD::time_test(test_repeat, test_time); - - // destroy team of threads - if( num_threads > 0 ) - team_destroy(); - ok &= thread_alloc::in_parallel() == false; - - // must delete a_square_root_ in sequential mode - delete a_square_root_; - - // free static variables in atomic_base class - CppAD::atomic_base::clear(); - - // correctness check - ok &= square_root_.size() == num_solve; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - for(size_t i = 0; i < num_solve; i++) - { double check = std::sqrt( y_squared_[i] ); - ok &= std::fabs( square_root_[i] / check - 1.0 ) <= eps99; - } - y_squared_.clear(); - square_root_.clear(); - // - // check that no static variables in this file are holding onto memory - ok &= initial_inuse == thread_alloc::inuse(0); - // - return ok; +{ bool ok = true; + // + size_t initial_inuse = thread_alloc::inuse(0); + + // number of threads, zero for no multi-threading + num_threads_ = num_threads; + + // number of Newton iterations + num_itr_ = 20; + + // values we are talking the square root of + y_squared_.resize(num_solve); + for(size_t i_solve = 0; i_solve < num_solve; i_solve++) + y_squared_[i_solve] = double(i_solve) + 2.0; + + // must create a_square_root_ sequential mode + a_square_root_ = new atomic_user; + + // create team of threads + ok &= thread_alloc::in_parallel() == false; + if( num_threads > 0 ) + { team_create(num_threads); + ok &= num_threads == thread_alloc::num_threads(); + } + else + { ok &= 1 == thread_alloc::num_threads(); + } + + // run the test case and set the time return value + time_out = CppAD::time_test(test_repeat, test_time); + + // destroy team of threads + if( num_threads > 0 ) + team_destroy(); + ok &= thread_alloc::in_parallel() == false; + + // must delete a_square_root_ in sequential mode + delete a_square_root_; + + // free static variables in atomic_base class + CppAD::atomic_base::clear(); + + // correctness check + ok &= square_root_.size() == num_solve; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + for(size_t i = 0; i < num_solve; i++) + { double check = std::sqrt( y_squared_[i] ); + ok &= std::fabs( square_root_[i] / check - 1.0 ) <= eps99; + } + y_squared_.clear(); + square_root_.clear(); + // + // check that no static variables in this file are holding onto memory + ok &= initial_inuse == thread_alloc::inuse(0); + // + return ok; } // END TIME C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/multi_atomic.hpp cppad-2019.02.00.0/example/multi_thread/multi_atomic.hpp --- cppad-2018.00.00.0/example/multi_thread/multi_atomic.hpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/multi_atomic.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,18 +1,19 @@ # ifndef CPPAD_EXAMPLE_MULTI_THREAD_MULTI_ATOMIC_HPP # define CPPAD_EXAMPLE_MULTI_THREAD_MULTI_ATOMIC_HPP /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ bool multi_atomic_time( - double& time_out, double test_time, size_t num_threads, size_t num_itr + double& time_out, double test_time, size_t num_threads, size_t num_solve ); # endif diff -Nru cppad-2018.00.00.0/example/multi_thread/multi_atomic.omh cppad-2019.02.00.0/example/multi_thread/multi_atomic.omh --- cppad-2018.00.00.0/example/multi_thread/multi_atomic.omh 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/multi_atomic.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,16 +1,17 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin multi_atomic.cpp$$ $spell - cpp + cpp $$ $section Multi-Threading User Atomic Example / Test$$ @@ -18,7 +19,7 @@ $head Source File$$ All of the routines below are located in the file $codep - example/multi_thread/multi_atomic.cpp + example/multi_thread/multi_atomic.cpp $$ $childtable%example/multi_thread/multi_atomic.cpp%$$ diff -Nru cppad-2018.00.00.0/example/multi_thread/multi_checkpoint.cpp cppad-2019.02.00.0/example/multi_thread/multi_checkpoint.cpp --- cppad-2018.00.00.0/example/multi_thread/multi_checkpoint.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/multi_checkpoint.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,631 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin multi_checkpoint_algo$$ +$spell + au + const + ADvector + num + itr + algo +$$ + +$section Defines an Algorithm that Computes Square Root$$ + +$head Syntax$$ +$icode%checkpoint_algo%(%au%, %ay%)%$$ + +$head Purpose$$ +This algorithm computes a square root using Newton's method. +It is meant to be very inefficient in order to demonstrate timing results. + +$head au$$ +This argument has prototype +$codei% + const %ADvector%& %au% +%$$ +where $icode ADvector$$ is a +$cref/simple vector class/SimpleVector/$$ with elements +of type $code AD$$. +The size of $icode au$$ is three. + +$subhead y_initial$$ +We use the notation +$codei% + %y_initial% = %au%[0] +%$$ +for the initial value of the Newton iterate. + +$subhead y_squared$$ +We use the notation +$codei% + %y_squared% = %au%[1] +%$$ +for the value we are taking the square root of. + +$head ay$$ +This argument has prototype +$codei% + %ADvector%& %ay% +%$$ +The size of $icode ay$$ is one and +$icode%ay%[0]%$$ is the square root of $icode y_squared$$. + +$head Source$$ +$srcfile%example/multi_thread/multi_checkpoint.cpp%0 + %// BEGIN ALGO C++%// END ALGO C++% +1%$$ + +$end +*/ +// BEGIN ALGO C++ +// includes used by all source code in multi_checkpoint.cpp file +# include +# include "multi_checkpoint.hpp" +# include "team_thread.hpp" +// +namespace { + using CppAD::thread_alloc; // fast multi-threading memory allocator + using CppAD::vector; // uses thread_alloc + // + typedef CppAD::AD a_double; + + void checkpoint_algo(const vector& au , vector& ay) + { + // extract components of argument vector + a_double y_initial = au[0]; + a_double y_squared = au[1]; + + // Use Newton's method to solve f(y) = y^2 = y_squared + a_double y_itr = y_initial; + for(size_t itr = 0; itr < 20; itr++) + { // solve (y - y_itr) * f'(y_itr) = y_squared - y_itr^2 + a_double fp_itr = 2.0 * y_itr; + y_itr = y_itr + (y_squared - y_itr * y_itr) / fp_itr; + } + + // return the Newton approximation for f(y) = y_squared + ay[0] = y_itr; + } +} +// END ALGO C++ + +/* +$begin multi_checkpoint_common$$ +$spell +$$ + +$section Multi-Threaded Checkpoint Common Information$$ + +$head Purpose$$ +This source code defines the common variables that are used by +the $codei%multi_checkpoint_%name%$$ functions. + +$head Source$$ +$srcfile%example/multi_thread/multi_checkpoint.cpp%0 + %// BEGIN COMMON C++%// END COMMON C++% +1%$$ + +$end +*/ +// BEGIN COMMON C++ +namespace { + // Number of threads, set by multi_checkpoint_time + // (zero means one thread with no multi-threading setup) + size_t num_threads_ = 0; + + // We can use one checkpoint function for all threads because + // there is no member data that gets changed during worker call. + // This needs to stay in scope for as long as a recording will use it. + // We cannot be in parallel mode when this object is created or deleted. + // We use a pointer so that there is no left over memory in thread zero. + CppAD::checkpoint* a_square_root_ = CPPAD_NULL; + + // structure with information for one thread + typedef struct { + // used by worker to compute the square root, + // set by multi_checkpoint_setup + CppAD::ADFun* fun; + // + // value we are computing square root of, set by multi_checkpoint_setup + vector* y_squared; + // + // square root, set by worker + vector* square_root; + // + // false if an error occurs, true otherwise, set by worker + bool ok; + } work_one_t; + // + // Vector with information for all threads + // (uses pointers instead of values to avoid false sharing) + // allocated by multi_checkpoint_setup, freed by multi_checkpoint_takedown + work_one_t* work_all_[CPPAD_MAX_NUM_THREADS]; +} +// END COMMON C++ +/* +------------------------------------------------------------------------------- +$begin multi_checkpoint_setup$$ +$spell + const + CppAD + bool +$$ + +$section Multi-Threaded Checkpoint Set Up$$. + +$head Syntax$$ +$icode%ok% = multi_checkpoint_setup(%y_squared%)%$$ + +$head Purpose$$ +This routine splits up the computation into the individual threads. + +$head Thread$$ +It is assumed that this function is called by thread zero +and all the other threads are blocked (waiting). + +$head y_squared$$ +This argument has prototype +$codei% + const vector& %y_squared% +%$$ +and its size is equal to the number of equations to solve. +It is the values that we are computing the square root of. + +$head ok$$ +This return value has prototype +$codei% + bool %ok% +%$$ +If it is false, +$code multi_checkpoint_setup$$ detected an error. + +$head Source$$ +$srcfile%example/multi_thread/multi_checkpoint.cpp%0 + %// BEGIN SETUP C++%// END SETUP C++% +1%$$ + +$end +*/ +// BEGIN SETUP C++ +namespace { +bool multi_checkpoint_setup(const vector& y_squared) +{ size_t num_threads = std::max(num_threads_, size_t(1)); + bool ok = num_threads == thread_alloc::num_threads(); + ok &= thread_alloc::thread_num() == 0; + // + // declare independent variable variable vector + vector ax(1); + ax[0] = 2.0; + CppAD::Independent(ax); + // + // argument and result for checkpoint algorithm + vector au(2), ay(1); + au[0] = ax[0]; // y_initial + au[1] = ax[0]; // y_squared + + // put user checkpoint function in recording + (*a_square_root_)(au, ay); + + // f(u) = sqrt(u) + CppAD::ADFun fun(ax, ay); + // + // number of square roots for each thread + size_t per_thread = (y_squared.size() + num_threads - 1) / num_threads; + size_t y_index = 0; + // + for(size_t thread_num = 0; thread_num < num_threads; thread_num++) + { // allocate separate memory for each thread to avoid false sharing + size_t min_bytes(sizeof(work_one_t)), cap_bytes; + void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); + work_all_[thread_num] = static_cast(v_ptr); + // + // Run constructor on work_all_[thread_num]->fun + work_all_[thread_num]->fun = new CppAD::ADFun; + // + // Run constructor on work_all_[thread_num] vectors + work_all_[thread_num]->y_squared = new vector; + work_all_[thread_num]->square_root = new vector; + // + // Each worker gets a separate copy of fun. This is necessary because + // the Taylor coefficients will be set by each thread. + *(work_all_[thread_num]->fun) = fun; + // + // values we are computing square root of for this thread + ok &= 0 == work_all_[thread_num]->y_squared->size(); + for(size_t i = 0; i < per_thread; i++) + if( y_index < y_squared.size() ) + work_all_[thread_num]->y_squared->push_back(y_squared[y_index++]); + // + // set to false in case this thread's worker does not get called + work_all_[thread_num]->ok = false; + } + ok &= y_index == y_squared.size(); + // + return ok; +} +} +// END SETUP C++ +/* +------------------------------------------------------------------------------ +$begin multi_checkpoint_worker$$ +$spell +$$ + +$section Multi-Threaded Checkpoint Worker$$ + +$head Purpose$$ +This routine does the computation for one thread. + +$head Source$$ +$srcfile%example/multi_thread/multi_checkpoint.cpp%0 + %// BEGIN WORKER C++%// END WORKER C++% +1%$$ + +$end +*/ +// BEGIN WORKER C++ +namespace { +void multi_checkpoint_worker(void) +{ size_t thread_num = thread_alloc::thread_num(); + size_t num_threads = std::max(num_threads_, size_t(1)); + bool ok = thread_num < num_threads; + // + vector x(1), y(1); + size_t n = work_all_[thread_num]->y_squared->size(); + work_all_[thread_num]->square_root->resize(n); + for(size_t i = 0; i < n; i++) + { x[0] = (* work_all_[thread_num]->y_squared )[i]; + y = work_all_[thread_num]->fun->Forward(0, x); + // + (* work_all_[thread_num]->square_root )[i] = y[0]; + } + work_all_[thread_num]->ok = ok; +} +} +// END WORKER C++ +/* +------------------------------------------------------------------------------ +$begin multi_checkpoint_takedown$$ +$spell + CppAD + bool +$$ + +$section Multi-Threaded Checkpoint Take Down$$ + +$head Syntax$$ +$icode%ok% = multi_checkpoint_takedown(%square_root%)%$$ + +$head Purpose$$ +This routine gathers up the results for each thread and +frees memory that was allocated by $cref multi_checkpoint_setup$$. + +$head Thread$$ +It is assumed that this function is called by thread zero +and all the other threads are blocked (waiting). + +$head square_root$$ +This argument has prototype +$codei% + vector& %square_root% +%$$ +The input value of $icode square_root$$ does not matter. +Upon return, +it has the same size and is the element by element square root of +$cref/y_squared/multi_checkpoint_setup/y_squared/$$. + +$head ok$$ +This return value has prototype +$codei% + bool %ok% +%$$ +If it is false, +$code multi_checkpoint_takedown$$ detected an error. + +$head Source$$ +$srcfile%example/multi_thread/multi_checkpoint.cpp%0 + %// BEGIN TAKEDOWN C++%// END TAKEDOWN C++% +1%$$ + +$end +*/ +// BEGIN TAKEDOWN C++ +namespace { +bool multi_checkpoint_takedown(vector& square_root) +{ bool ok = true; + ok &= thread_alloc::thread_num() == 0; + size_t num_threads = std::max(num_threads_, size_t(1)); + // + // extract square roots in original order + square_root.resize(0); + for(size_t thread_num = 0; thread_num < num_threads; thread_num++) + { // results for this thread + size_t n = work_all_[thread_num]->square_root->size(); + for(size_t i = 0; i < n; i++) + square_root.push_back((* work_all_[thread_num]->square_root )[i]); + } + // + // go down so that free memory for other threads before memory for master + size_t thread_num = num_threads; + while(thread_num--) + { // check that this tread was ok with the work it did + ok &= work_all_[thread_num]->ok; + // + // run destructor on vector object for this thread + delete work_all_[thread_num]->y_squared; + delete work_all_[thread_num]->square_root; + // + // run destructor on function object for this thread + delete work_all_[thread_num]->fun; + // + // delete problem specific information + void* v_ptr = static_cast( work_all_[thread_num] ); + thread_alloc::return_memory( v_ptr ); + // + // Note that checkpoint object has memory connect to each thread + // thread_alloc::inuse(thread_num) cannot be zero until it is deleted + if( thread_num > 0 ) + { ok &= thread_alloc::inuse(thread_num) > 0; + // + // return all memory that is not in use and + // but being held for future use by this thread + thread_alloc::free_available(thread_num); + } + } + return ok; +} +} +// END TAKEDOWN C++ +/* +$begin multi_checkpoint_run$$ +$spell + const + CppAD + bool +$$ + +$section Run Multi-Threaded Checkpoint Calculation$$ + +$head Syntax$$ +$icode%ok% = multi_checkpoint_run(%y_squared%, %square_root%)%$$ + +$head Thread$$ +It is assumed that this function is called by thread zero +and all the other threads are blocked (waiting). + +$head y_squared$$ +This argument has prototype +$codei% + const vector& %y_squared% +%$$ +and its size is equal to the number of threads. +It is the values that we are computing the square root of. + +$head square_root$$ +This argument has prototype +$codei% + vector& %square_root% +%$$ +The input value of $icode square_root$$ does not matter. +Upon return, +it has the same size and +is the element by element square root of $icode y_squared$$. + +$head ok$$ +This return value has prototype +$codei% + bool %ok% +%$$ +If it is false, +$code multi_checkpoint_run$$ detected an error. + +$head Source$$ +$srcfile%example/multi_thread/multi_checkpoint.cpp%0 + %// BEGIN RUN C++%// END RUN C++% +1%$$ + +$end +------------------------------------------------------------------------------ +*/ +// BEGIN RUN C++ +namespace { +bool multi_checkpoint_run( + const vector& y_squared , + vector& square_root ) +{ + bool ok = true; + ok &= thread_alloc::thread_num() == 0; + + // setup the work for multi-threading + ok &= multi_checkpoint_setup(y_squared); + + // now do the work for each thread + if( num_threads_ > 0 ) + team_work( multi_checkpoint_worker ); + else + multi_checkpoint_worker(); + + // combine the result for each thread and takedown the multi-threading. + ok &= multi_checkpoint_takedown(square_root); + + return ok; +} +} +// END RUN C++ +/* +------------------------------------------------------------------------------ +$begin multi_checkpoint_time$$ +$spell + num + alloc + bool + CppAD +$$ + +$section Timing Test for Multi-Threaded Checkpoint Calculation$$ + +$head Syntax$$ +$icode%ok% = multi_checkpoint_time( + %time_out%, %test_time%, %num_threads%, %num_solve% +)%$$ + + +$head Thread$$ +It is assumed that this function is called by thread zero in sequential +mode; i.e., not $cref/in_parallel/ta_in_parallel/$$. + +$head time_out$$ +This argument has prototype +$codei% + double& %time_out% +%$$ +Its input value of the argument does not matter. +Upon return it is the number of wall clock seconds +used by $cref multi_checkpoint_run$$. + +$head test_time$$ +This argument has prototype +$codei% + double %test_time% +%$$ +and 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. +The reported $icode time_out$$ is the total wall clock time divided by the +number of repeats. + +$head num_threads$$ +This argument has prototype +$codei% + size_t %num_threads% +%$$ +It specifies the number of threads that are available for this test. +If it is zero, the test is run without the multi-threading environment and +$codei% + 1 == thread_alloc::num_threads() +%$$ +If it is non-zero, the test is run with the multi-threading and +$codei% + %num_threads% = thread_alloc::num_threads() +%$$ + +$head num_solve$$ +This specifies the number of square roots that will be solved for. + +$head ok$$ +The return value has prototype +$codei% + bool %ok% +%$$ +If it is true, +$code harmonic_time$$ passed the correctness test and +$code multi_checkpoint_time$$ did not detect an error. +Otherwise it is false. + +$end +*/ + +// BEGIN TIME C++ +namespace { + // values we are taking the square root of + vector y_squared_; + + // results of the square root calculations + vector square_root_; + // + void test_once(void) + { bool ok = multi_checkpoint_run(y_squared_, square_root_); + if( ! ok ) + { std::cerr << "multi_checkpoint_run: error" << std::endl; + exit(1); + } + return; + } + // + void test_repeat(size_t repeat) + { size_t i; + for(i = 0; i < repeat; i++) + test_once(); + return; + } +} +// This is the only routine that is accessible outside of this file +bool multi_checkpoint_time( + double& time_out, double test_time, size_t num_threads, size_t num_solve +) +{ bool ok = true; + // + size_t initial_inuse = thread_alloc::inuse(0); + + // number of threads, zero for no multi-threading + num_threads_ = num_threads; + + // values we are talking the square root of + y_squared_.resize(num_solve); + for(size_t i_solve = 0; i_solve < num_solve; i_solve++) + y_squared_[i_solve] = double(i_solve) + 2.0; + + // must create a_square_root_ in sequential mode + vector au(2), ay(1); + au[0] = 2.0; + au[1] = 2.0; + a_square_root_ = new CppAD::checkpoint( + "square_root", checkpoint_algo, au, ay + ); + + // create team of threads + ok &= thread_alloc::in_parallel() == false; + if( num_threads > 0 ) + { team_create(num_threads); + ok &= num_threads == thread_alloc::num_threads(); + } + else + { ok &= 1 == thread_alloc::num_threads(); + } + + // run the test case and set the time return value + time_out = CppAD::time_test(test_repeat, test_time); + + // destroy team of threads + if( num_threads > 0 ) + team_destroy(); + ok &= thread_alloc::in_parallel() == false; + + // must delete a_square_root_ in sequential mode + delete a_square_root_; + + // free static variables in atomic_base class + CppAD::atomic_base::clear(); + + // correctness check + ok &= square_root_.size() == num_solve; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + for(size_t i = 0; i < num_solve; i++) + { double check = std::sqrt( y_squared_[i] ); + ok &= std::fabs( square_root_[i] / check - 1.0 ) <= eps99; + } + // + // free memory in CppAD vectors that are still in scope + y_squared_.clear(); + square_root_.clear(); + au.clear(); + ay.clear(); + // + // check that no static variables in this file are holding onto memory + ok &= initial_inuse == thread_alloc::inuse(0); + // + return ok; +} +// END TIME C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/multi_checkpoint.hpp cppad-2019.02.00.0/example/multi_thread/multi_checkpoint.hpp --- cppad-2018.00.00.0/example/multi_thread/multi_checkpoint.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/multi_checkpoint.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,19 @@ +# ifndef CPPAD_EXAMPLE_MULTI_THREAD_MULTI_CHECKPOINT_HPP +# define CPPAD_EXAMPLE_MULTI_THREAD_MULTI_CHECKPOINT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +bool multi_checkpoint_time( + double& time_out, double test_time, size_t num_threads, size_t num_solve +); + +# endif diff -Nru cppad-2018.00.00.0/example/multi_thread/multi_checkpoint.omh cppad-2019.02.00.0/example/multi_thread/multi_checkpoint.omh --- cppad-2018.00.00.0/example/multi_thread/multi_checkpoint.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/multi_checkpoint.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,27 @@ +------------------------------------------------------------------------------- + CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +------------------------------------------------------------------------------- +$begin multi_checkpoint.cpp$$ +$spell + cpp +$$ + +$section Multi-Threading Checkpoint Example / Test$$ + +$head Source File$$ +All of the routines below are located in the file +$codep + example/multi_thread/multi_checkpoint.cpp +$$ + +$childtable%example/multi_thread/multi_checkpoint.cpp%$$ + +$end diff -Nru cppad-2018.00.00.0/example/multi_thread/multi_newton.cpp cppad-2019.02.00.0/example/multi_thread/multi_newton.cpp --- cppad-2018.00.00.0/example/multi_thread/multi_newton.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/multi_newton.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin multi_newton_common$$ @@ -20,7 +21,7 @@ $head Source$$ $srcfile%example/multi_thread/multi_newton.cpp% - 0%// BEGIN COMMON C++%// END COMMON C++% + 0%// BEGIN COMMON C++%// END COMMON C++% 1%$$ @@ -37,45 +38,45 @@ # define USE_THREAD_ALLOC_FOR_WORK_ALL 1 namespace { - using CppAD::thread_alloc; // fast multi-threadeding memory allocator - using CppAD::vector; // uses thread_alloc + using CppAD::thread_alloc; // fast multi-threadeding memory allocator + using CppAD::vector; // uses thread_alloc - // number of threads, set by multi_newton_time. - size_t num_threads_ = 0; + // number of threads, set by multi_newton_time. + size_t num_threads_ = 0; - // function we are finding zeros of, set by multi_newton_time - void (*fun_)(double x, double& f, double& df) = 0; + // function we are finding zeros of, set by multi_newton_time + void (*fun_)(double x, double& f, double& df) = 0; - // convergence criteria, set by multi_newton_setup - double epsilon_ = 0.; - - // maximum number of iterations, set by multi_newton_setup - size_t max_itr_ = 0; - - // length for all sub-intervals - double sub_length_ = 0.; - - // structure with information for one thread - typedef struct { - // number of sub intervals (worker input) - size_t num_sub; - // beginning of interval (worker input) - double xlow; - // end of interval (worker input) - 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_takedown: x.size() == 0 - vector x; - // false if an error occurs, true otherwise (worker output) - bool ok; - } work_one_t; - // vector with information for all threads - // after call to multi_newton_setup: work_all.size() == num_threads - // after call to multi_newton_takedown: work_all.size() == 0 - // (use pointers instead of values to avoid false sharing) - vector work_all_; + // convergence criteria, set by multi_newton_setup + double epsilon_ = 0.; + + // maximum number of iterations, set by multi_newton_setup + size_t max_itr_ = 0; + + // length for all sub-intervals + double sub_length_ = 0.; + + // structure with information for one thread + typedef struct { + // number of sub intervals (worker input) + size_t num_sub; + // beginning of interval (worker input) + double xlow; + // end of interval (worker input) + 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_takedown: x.size() == 0 + vector x; + // false if an error occurs, true otherwise (worker output) + bool ok; + } work_one_t; + // vector with information for all threads + // after call to multi_newton_setup: work_all.size() == num_threads + // after call to multi_newton_takedown: work_all.size() == 0 + // (use pointers instead of values to avoid false sharing) + vector work_all_; } // END COMMON C++ /* @@ -84,17 +85,17 @@ $section Set Up Multi-Threaded Newton Method$$ $spell - num - xlow - xup - itr - xout + num + xlow + xup + itr + xout $$ $head Syntax$$ $icode%ok% = multi_newton_setup( - %num_sub%, %xlow%, %xup%, %epsilon%, %max_itr%, %num_threads% + %num_sub%, %xlow%, %xup%, %epsilon%, %max_itr%, %num_threads% )%$$ $head Purpose$$ @@ -126,7 +127,7 @@ $head Source$$ $srcfile%example/multi_thread/multi_newton.cpp% - 0%// BEGIN SETUP C++%// END SETUP C++% + 0%// BEGIN SETUP C++%// END SETUP C++% 1%$$ $end @@ -134,77 +135,78 @@ // BEGIN SETUP C++ namespace { bool multi_newton_setup( - size_t num_sub , - double xlow , - double xup , - double epsilon , - size_t max_itr , - size_t num_threads ) + size_t num_sub , + double xlow , + double xup , + double epsilon , + size_t max_itr , + size_t num_threads ) { - num_threads = std::max(num_threads_, size_t(1)); - bool ok = num_threads == thread_alloc::num_threads(); - ok &= thread_alloc::thread_num() == 0; - - // inputs that are same for all threads - epsilon_ = epsilon; - max_itr_ = max_itr; - - // resize the work vector to accomidate the number of threads - ok &= work_all_.size() == 0; - work_all_.resize(num_threads); - - // length of each sub interval - 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_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; - for(thread_num = 0; thread_num < num_threads; thread_num++) - { + num_threads = std::max(num_threads_, size_t(1)); + bool ok = num_threads == thread_alloc::num_threads(); + ok &= thread_alloc::thread_num() == 0; + + // inputs that are same for all threads + epsilon_ = epsilon; + max_itr_ = max_itr; + + // resize the work vector to accomidate the number of threads + ok &= work_all_.size() == 0; + work_all_.resize(num_threads); + + // length of each sub interval + 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_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; + for(thread_num = 0; thread_num < num_threads; thread_num++) + { # if USE_THREAD_ALLOC_FOR_WORK_ALL - // allocate separate memory for this thread to avoid false sharing - size_t min_bytes(sizeof(work_one_t)), cap_bytes; - void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); - work_all_[thread_num] = static_cast(v_ptr); - - // thread_alloc is a raw memory allocator; i.e., it does not call - // the constructor for the objects it creates. The vector - // class requires it's constructor to be called so we do it here - new(& (work_all_[thread_num]->x) ) vector(); + // allocate separate memory for this thread to avoid false sharing + size_t min_bytes(sizeof(work_one_t)), cap_bytes; + void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); + work_all_[thread_num] = static_cast(v_ptr); + + // thread_alloc is a raw memory allocator; i.e., it does not call + // the constructor for the objects it creates. The vector + // class requires it's constructor to be called so we do it here + new(& (work_all_[thread_num]->x) ) vector(); # else - work_all_[thread_num] = new work_one_t; + work_all_[thread_num] = new work_one_t; # endif - // number of sub-intervalse for this thread - if( thread_num < num_more ) - num_sub_thread = num_min + 1; - else num_sub_thread = num_min; - - // when thread_num == 0, xlow_thread == xlow - double xlow_thread = xlow + double(sum_num) * sub_length_; - - // when thread_num == num_threads - 1, xup_thread = xup - double xup_thread = - xlow + double(sum_num + num_sub_thread) * sub_length_; - if( thread_num == num_threads - 1 ) - xup_thread = xup; - - // update sum_num for next time through loop - sum_num += num_sub_thread; - - // input information specific to this thread - work_all_[thread_num]->num_sub = num_sub_thread; - work_all_[thread_num]->xlow = xlow_thread; - work_all_[thread_num]->xup = xup_thread; - ok &= work_all_[thread_num]->x.size() == 0; - - // in case this thread does not get called - work_all_[thread_num]->ok = false; - } - ok &= sum_num == num_sub; - return ok; + // number of sub-intervalse for this thread + if( thread_num < num_more ) + num_sub_thread = num_min + 1; + else + num_sub_thread = num_min; + + // when thread_num == 0, xlow_thread == xlow + double xlow_thread = xlow + double(sum_num) * sub_length_; + + // when thread_num == num_threads - 1, xup_thread = xup + double xup_thread = + xlow + double(sum_num + num_sub_thread) * sub_length_; + if( thread_num == num_threads - 1 ) + xup_thread = xup; + + // update sum_num for next time through loop + sum_num += num_sub_thread; + + // input information specific to this thread + work_all_[thread_num]->num_sub = num_sub_thread; + work_all_[thread_num]->xlow = xlow_thread; + work_all_[thread_num]->xup = xup_thread; + ok &= work_all_[thread_num]->x.size() == 0; + + // in case this thread does not get called + work_all_[thread_num]->ok = false; + } + ok &= sum_num == num_sub; + return ok; } } // END SETUP C++ @@ -212,10 +214,10 @@ ------------------------------------------------------------------------------ $begin multi_newton_worker$$ $spell - num - xlow - xup - xout + num + xlow + xup + xout $$ $section Do One Thread's Work for Multi-Threaded Newton Method$$ @@ -230,13 +232,13 @@ $head low$$ This is the value of the $cref multi_newton_common$$ information $codei% - %low% = work_all_[%thread_num%]->xlow + %low% = work_all_[%thread_num%]->xlow %$$ $head up$$ This is the value of the $cref multi_newton_common$$ information $codei% - %up% = work_all_[%thread_num%]->xup + %up% = work_all_[%thread_num%]->xup %$$ $head thread_num$$ @@ -245,7 +247,7 @@ $head Source$$ $srcfile%example/multi_thread/multi_newton.cpp%0 - %// BEGIN WORKER C++%// END WORKER C++% + %// BEGIN WORKER C++%// END WORKER C++% 1%$$ $end */ @@ -253,85 +255,85 @@ namespace { void multi_newton_worker(void) { - // Split [xlow, xup] into num_sub intervales and - // look for one zero in each sub-interval. - size_t thread_num = thread_alloc::thread_num(); - size_t num_threads = std::max(num_threads_, size_t(1)); - bool ok = thread_num < num_threads; - size_t num_sub = work_all_[thread_num]->num_sub; - double xlow = work_all_[thread_num]->xlow; - double xup = work_all_[thread_num]->xup; - vector& x = work_all_[thread_num]->x; - - // check arguments - ok &= max_itr_ > 0; - ok &= num_sub > 0; - ok &= xlow < xup; - ok &= x.size() == 0; - - // check for special case where there is nothing for this thread to do - if( num_sub == 0 ) - { work_all_[thread_num]->ok = ok; - return; - } - - // check for a zero on each sub-interval - size_t i; - double xlast = xlow - 2.0 * sub_length_; // over sub_length_ away from x_low - double flast = 2.0 * epsilon_; // any value > epsilon_ would do - for(i = 0; i < num_sub; i++) - { - // note that when i == 0, xlow_i == xlow (exactly) - double xlow_i = xlow + double(i) * sub_length_; - - // note that when i == num_sub - 1, xup_i = xup (exactly) - double xup_i = xup - double(num_sub - i - 1) * sub_length_; - - // initial point for Newton iterations - double xcur = (xup_i + xlow_i) / 2.; - - // Newton iterations - bool more_itr = true; - size_t itr = 0; - // initialize these values to avoid MSC C++ warning - double fcur=0.0, dfcur=0.0; - while( more_itr ) - { fun_(xcur, fcur, dfcur); - - // check end of iterations - if( fabs(fcur) <= epsilon_ ) - more_itr = false; - if( (xcur == xlow_i ) & (fcur * dfcur > 0.) ) - more_itr = false; - if( (xcur == xup_i) & (fcur * dfcur < 0.) ) - more_itr = false; - - // next Newton iterate - if( more_itr ) - { xcur = xcur - fcur / dfcur; - // keep in bounds - xcur = std::max(xcur, xlow_i); - xcur = std::min(xcur, xup_i); - - more_itr = ++itr < max_itr_; - } - } - if( fabs( fcur ) <= epsilon_ ) - { // 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; - flast = fcur; - } - } - } - work_all_[thread_num]->ok = ok; + // Split [xlow, xup] into num_sub intervales and + // look for one zero in each sub-interval. + size_t thread_num = thread_alloc::thread_num(); + size_t num_threads = std::max(num_threads_, size_t(1)); + bool ok = thread_num < num_threads; + size_t num_sub = work_all_[thread_num]->num_sub; + double xlow = work_all_[thread_num]->xlow; + double xup = work_all_[thread_num]->xup; + vector& x = work_all_[thread_num]->x; + + // check arguments + ok &= max_itr_ > 0; + ok &= num_sub > 0; + ok &= xlow < xup; + ok &= x.size() == 0; + + // check for special case where there is nothing for this thread to do + if( num_sub == 0 ) + { work_all_[thread_num]->ok = ok; + return; + } + + // check for a zero on each sub-interval + size_t i; + double xlast = xlow - 2.0 * sub_length_; // over sub_length_ away from x_low + double flast = 2.0 * epsilon_; // any value > epsilon_ would do + for(i = 0; i < num_sub; i++) + { + // note that when i == 0, xlow_i == xlow (exactly) + double xlow_i = xlow + double(i) * sub_length_; + + // note that when i == num_sub - 1, xup_i = xup (exactly) + double xup_i = xup - double(num_sub - i - 1) * sub_length_; + + // initial point for Newton iterations + double xcur = (xup_i + xlow_i) / 2.; + + // Newton iterations + bool more_itr = true; + size_t itr = 0; + // initialize these values to avoid MSC C++ warning + double fcur=0.0, dfcur=0.0; + while( more_itr ) + { fun_(xcur, fcur, dfcur); + + // check end of iterations + if( fabs(fcur) <= epsilon_ ) + more_itr = false; + if( (xcur == xlow_i ) & (fcur * dfcur > 0.) ) + more_itr = false; + if( (xcur == xup_i) & (fcur * dfcur < 0.) ) + more_itr = false; + + // next Newton iterate + if( more_itr ) + { xcur = xcur - fcur / dfcur; + // keep in bounds + xcur = std::max(xcur, xlow_i); + xcur = std::min(xcur, xup_i); + + more_itr = ++itr < max_itr_; + } + } + if( fabs( fcur ) <= epsilon_ ) + { // 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; + flast = fcur; + } + } + } + work_all_[thread_num]->ok = ok; } } // END WORKER C++ @@ -339,7 +341,7 @@ ------------------------------------------------------------------------------- $begin multi_newton_takedown$$ $spell - xout + xout $$ $section Take Down Multi-threaded Newton Method$$ @@ -361,7 +363,7 @@ $head Source$$ $srcfile%example/multi_thread/multi_newton.cpp%0 - %// BEGIN TAKEDOWN C++%// END TAKEDOWN C++% + %// BEGIN TAKEDOWN C++%// END TAKEDOWN C++% 1%$$ $end @@ -369,68 +371,68 @@ // BEGIN TAKEDOWN C++ namespace { bool multi_newton_takedown(vector& xout) -{ // number of threads in the calculation - size_t num_threads = std::max(num_threads_, size_t(1)); +{ // number of threads in the calculation + size_t num_threads = std::max(num_threads_, size_t(1)); - // remove duplicates and points that are not solutions - xout.resize(0); - bool ok = true; - ok &= thread_alloc::thread_num() == 0; - - // initialize as more that sub_length_ / 2 from any possible solution - double xlast = - sub_length_; - for(size_t thread_num = 0; thread_num < num_threads; thread_num++) - { vector& x = work_all_[thread_num]->x; - - size_t i; - 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_ ) - { xout.push_back( x[i] ); - xlast = x[i]; - } - else - { double fcur, flast, df; - fun_(x[i], fcur, df); - fun_(xlast, flast, df); - if( fabs(fcur) < fabs(flast) ) - { xout[ xout.size() - 1] = x[i]; - xlast = x[i]; - } - } - } - // check that this thread was ok with the work it did - ok &= work_all_[thread_num]->ok; - } - - // go down so free memory for other threads before memory for master - size_t thread_num = num_threads; - while(thread_num--) - { + // remove duplicates and points that are not solutions + xout.resize(0); + bool ok = true; + ok &= thread_alloc::thread_num() == 0; + + // initialize as more that sub_length_ / 2 from any possible solution + double xlast = - sub_length_; + for(size_t thread_num = 0; thread_num < num_threads; thread_num++) + { vector& x = work_all_[thread_num]->x; + + size_t i; + 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_ ) + { xout.push_back( x[i] ); + xlast = x[i]; + } + else + { double fcur, flast, df; + fun_(x[i], fcur, df); + fun_(xlast, flast, df); + if( fabs(fcur) < fabs(flast) ) + { xout[ xout.size() - 1] = x[i]; + xlast = x[i]; + } + } + } + // check that this thread was ok with the work it did + ok &= work_all_[thread_num]->ok; + } + + // go down so free memory for other threads before memory for master + size_t thread_num = num_threads; + while(thread_num--) + { # if USE_THREAD_ALLOC_FOR_WORK_ALL - // call the destructor for vector destructor - work_all_[thread_num]->x.~vector(); - // delete the raw memory allocation - void* v_ptr = static_cast( work_all_[thread_num] ); - thread_alloc::return_memory( v_ptr ); + // call the destructor for vector destructor + work_all_[thread_num]->x.~vector(); + // 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]; + 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). - if( thread_num > 0 ) - { // check that there is no longer any memory inuse by this thread - ok &= thread_alloc::inuse(thread_num) == 0; - // return all memory being held for future use by this thread - thread_alloc::free_available(thread_num); - } - } - // now we are done with the work_all_ vector so free its memory - // (because it is a static variable) - work_all_.clear(); + // Note that xout corresponds to memroy that is inuse by master + // (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; + // return all memory being held for future use by this thread + thread_alloc::free_available(thread_num); + } + } + // now we are done with the work_all_ vector so free its memory + // (because it is a static variable) + work_all_.clear(); - return ok; + return ok; } } // END TAKEDOWN C++ @@ -438,14 +440,14 @@ ------------------------------------------------------------------------------ $begin multi_newton_run$$ $spell - CppAD - xout - num - xlow - xup - itr - bool - df + CppAD + xout + num + xlow + xup + itr + bool + df $$ @@ -453,7 +455,7 @@ $head Syntax$$ $icode%ok% = %multi_newton_run(%xout%, - %fun%, %num_sub%, %xlow%, %xup%, %epsilon%, %max_itr%, %num_threads% + %fun%, %num_sub%, %xlow%, %xup%, %epsilon%, %max_itr%, %num_threads% )%$$ $head Purpose$$ @@ -469,12 +471,12 @@ 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} + g_i = a \frac{n - i}{n} + b \frac{i}{n} \] $$ 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} ] + I_i = [ g_i , g_{i+1} ] \] $$ Newton's method is applied starting at the center of each of the sub-intervals $latex I_i$$ for @@ -484,21 +486,21 @@ $head ok$$ The return value $icode ok$$ has prototype $codei% - bool %ok% + bool %ok% %$$ If an error occurs, it is false, otherwise it is true. $head xout$$ The argument $icode xout$$ has the prototype $codei% - vector& %xout% + vector& %xout% %$$ 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 number of sub-intervals $latex n$$ and $latex \[ - | f( xout[i] ) | \leq epsilon + | 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 @@ -508,19 +510,19 @@ $head fun$$ The argument $icode fun$$ has prototype $codei% - void %fun% (double %x%, double& %f%, double& %df%) + void %fun% (double %x%, double& %f%, double& %df%) %$$ This function must evaluate $latex f(x)$$, and its derivative $latex f^{(1)} (x)$$, using the syntax $codei% - %fun%(%x%, %f%, %df%) + %fun%(%x%, %f%, %df%) %$$ where the arguments to $icode fun$$ have the prototypes $codei% - double %x% - double& %f% - double& %df% + double %x% + double& %f% + double& %df% %$$. The input values of $icode f$$ and $icode df$$ do not matter. Upon return they are $latex f(x)$$ and $latex f^{(1)} (x)$$ respectively. @@ -528,28 +530,28 @@ $head num_sub$$ The argument $icode num_sub$$ has prototype $codei% - size_t %num_sub% + size_t %num_sub% %$$ It specifies the number of sub-intervals; i.e., $latex n$$. $head xlow$$ The argument $icode xlow$$ has prototype $codei% - double %xlow% + double %xlow% %$$ It specifies the lower limit for the entire search interval; i.e., $latex a$$. $head xup$$ The argument $icode xup$$ has prototype $codei% - double %xup% + double %xup% %$$ It specifies the upper limit for the entire search interval; i.e., $latex b$$. $head epsilon$$ The argument $icode epsilon$$ has prototype $codei% - double %epsilon% + double %epsilon% %$$ It specifies the convergence criteria for Newton's method in terms of how small the function value must be. @@ -557,7 +559,7 @@ $head max_itr$$ The argument $icode max_itr$$ has prototype $codei% - size_t %max_itr% + size_t %max_itr% %$$ It specifies the maximum number of iterations of Newton's method to try before giving up on convergence (on each sub-interval). @@ -565,14 +567,14 @@ $head num_threads$$ This argument has prototype $codei% - size_t %num_threads% + size_t %num_threads% %$$ It specifies the number of threads that are available for this test. If it is zero, the test is run without the multi-threading environment. $head Source$$ $srcfile%example/multi_thread/multi_newton.cpp% - 0%// BEGIN SOLVE C++%// END SOLVE C++% + 0%// BEGIN SOLVE C++%// END SOLVE C++% 1%$$ $end @@ -581,32 +583,33 @@ // BEGIN SOLVE C++ namespace { bool multi_newton_run( - 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 ) + 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; - ok &= thread_alloc::thread_num() == 0; + bool ok = true; + ok &= thread_alloc::thread_num() == 0; - // setup the work for num_threads threads - ok &= multi_newton_setup( - num_sub, xlow, xup, epsilon, max_itr, num_threads - ); - - // now do the work for each thread - if( num_threads > 0 ) - team_work( multi_newton_worker ); - else multi_newton_worker(); + // setup the work for num_threads threads + ok &= multi_newton_setup( + num_sub, xlow, xup, epsilon, max_itr, num_threads + ); + + // now do the work for each thread + if( num_threads > 0 ) + team_work( multi_newton_worker ); + else + multi_newton_worker(); - // now combine the results for all the threads - ok &= multi_newton_takedown(xout); + // now combine the results for all the threads + ok &= multi_newton_takedown(xout); - return ok; + return ok; } } // END SOLVE C++ @@ -614,11 +617,11 @@ ----------------------------------------------------------------------------- $begin multi_newton_time$$ $spell - num - Cpp - bool - alloc - openmp + num + Cpp + bool + alloc + openmp $$ . @@ -626,7 +629,7 @@ $head Syntax$$ $icode%ok% = multi_newton_time(%time_out%, %test_time%, %num_threads%, - %num_zero%, %num_sub%, %num_sum%, %use_ad% + %num_zero%, %num_sub%, %num_sum%, %use_ad% )%$$ $head Purpose$$ @@ -645,7 +648,7 @@ $head ok$$ This return value has prototype $codei% - bool %ok% + bool %ok% %$$ If it is true, $code multi_newton_time$$ passed the correctness test. @@ -654,7 +657,7 @@ $head time_out$$ This argument has prototype $codei% - double& %time_out% + double& %time_out% %$$ The input value of the argument does not matter. Upon return it is the number of wall clock seconds required for @@ -670,25 +673,25 @@ $head num_threads$$ This argument has prototype $codei% - size_t %num_threads% + size_t %num_threads% %$$ It specifies the number of threads that are available for this test. If it is zero, the test is run without multi-threading and $codei% - 1 == thread_alloc::num_threads() + 1 == thread_alloc::num_threads() %$$ when $code multi_newton_time$$ is called. If it is non-zero, the test is run with multi-threading and $codei% - %num_threads% == thread_alloc::num_threads() + %num_threads% == thread_alloc::num_threads() %$$ when $code multi_newton_time$$ is called. $head num_zero$$ This argument has prototype $codei% - size_t %num_zero% + size_t %num_zero% %$$ and it must be greater than one. It specifies the actual number of zeros in the test function @@ -697,13 +700,13 @@ all of the values of $latex x$$ for which $latex \sin(x) = 0 $$ and $latex x$$ is in the interval $codei% - [ 0 , (%num_zero% - 1) * %pi% ] + [ 0 , (%num_zero% - 1) * %pi% ] %$$. $head num_sub$$ This argument has prototype $codei% - size_t %num_sub% + size_t %num_sub% %$$ It specifies the number of sub-intervals to divide the total interval into. It must be greater than $icode num_zero$$ @@ -712,12 +715,12 @@ $head num_sum$$ This argument has prototype $codei% - size_t %num_sum% + size_t %num_sum% %$$ and must be greater than zero. The actual function used by the Newton method is $latex \[ - f(x) = \frac{1}{n} \sum_{i=1}^{n} \sin (x) + f(x) = \frac{1}{n} \sum_{i=1}^{n} \sin (x) \] $$ where $latex n$$ is equal to $icode num_sum$$. Larger values of $icode num_sum$$ simulate a case where the @@ -726,7 +729,7 @@ $head use_ad$$ This argument has prototype $codei% - bool %user_ad% + bool %user_ad% %$$ If $icode use_ad$$ is $code true$$, then derivatives will be computed using CppAD. @@ -741,7 +744,7 @@ $head Source$$ $srcfile%example/multi_thread/multi_newton.cpp% - 0%// BEGIN TIME C++%// END TIME C++% + 0%// BEGIN TIME C++%// END TIME C++% 1%$$ $end @@ -750,159 +753,160 @@ namespace { // empty namespace - // values correspond to arguments in previous call 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 - - // value of xout corresponding to most recent call to test_once - vector xout_; - - // A version of the sine function that can be made as slow as we like - template - Float f_eval(Float x) - { Float sum = 0.; - size_t i; - for(i = 0; i < num_sum_; i++) - sum += sin(x); - - return sum / Float(num_sum_); - } - - // Direct calculation of derivative with same number of floating point - // operations as for f_eval. - double df_direct(double x) - { double sum = 0.; - size_t i; - for(i = 0; i < num_sum_; i++) - sum += cos(x); - - return sum / double(num_sum_); - } - - // AD calculation of detivative - void fun_ad(double x, double& f, double& df) - { using CppAD::AD; - - // use vector because it uses fast multi-threaded memory alloc - vector< AD > X(1), Y(1); - X[0] = x; - CppAD::Independent(X); - Y[0] = f_eval(X[0]); - CppAD::ADFun F(X, Y); - vector dx(1), dy(1); - dx[0] = 1.; - dy = F.Forward(1, dx); - f = Value( Y[0] ); - df = dy[0]; - return; - } - - // evaulate the function and its derivative - void fun_no(double x, double& f, double& df) - { f = f_eval(x); - df = df_direct(x); - return; - } - - - // Run computation of all the zeros once - void test_once(void) - { if( num_zero_ == 0 ) - { std::cerr << "multi_newton_time: num_zero == 0" << std::endl; - exit(1); - } - double pi = 4. * std::atan(1.); - double xlow = 0.; - double xup = double(num_zero_ - 1) * pi; - double eps = - xup * 100. * CppAD::numeric_limits::epsilon(); - size_t max_itr = 20; - - // note that fun_ is set to fun_ad or fun_no by multi_newton_time - bool ok = multi_newton_run( - xout_ , - fun_ , - num_sub_ , - xlow , - xup , - eps , - max_itr , - num_threads_ - ); - if( ! ok ) - { std::cerr << "multi_newton: error" << std::endl; - exit(1); - } - return; - } - - // Repeat computation of all the zeros a specied number of times - void test_repeat(size_t repeat) - { size_t i; - for(i = 0; i < repeat; i++) - test_once(); - return; - } + // values correspond to arguments in previous call 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 + + // value of xout corresponding to most recent call to test_once + vector xout_; + + // A version of the sine function that can be made as slow as we like + template + Float f_eval(Float x) + { Float sum = 0.; + size_t i; + for(i = 0; i < num_sum_; i++) + sum += sin(x); + + return sum / Float(num_sum_); + } + + // Direct calculation of derivative with same number of floating point + // operations as for f_eval. + double df_direct(double x) + { double sum = 0.; + size_t i; + for(i = 0; i < num_sum_; i++) + sum += cos(x); + + return sum / double(num_sum_); + } + + // AD calculation of detivative + void fun_ad(double x, double& f, double& df) + { using CppAD::AD; + + // use vector because it uses fast multi-threaded memory alloc + vector< AD > X(1), Y(1); + X[0] = x; + CppAD::Independent(X); + Y[0] = f_eval(X[0]); + CppAD::ADFun F(X, Y); + vector dx(1), dy(1); + dx[0] = 1.; + dy = F.Forward(1, dx); + f = Value( Y[0] ); + df = dy[0]; + return; + } + + // evaulate the function and its derivative + void fun_no(double x, double& f, double& df) + { f = f_eval(x); + df = df_direct(x); + return; + } + + + // Run computation of all the zeros once + void test_once(void) + { if( num_zero_ == 0 ) + { std::cerr << "multi_newton_time: num_zero == 0" << std::endl; + exit(1); + } + double pi = 4. * std::atan(1.); + double xlow = 0.; + double xup = double(num_zero_ - 1) * pi; + double eps = + xup * 100. * CppAD::numeric_limits::epsilon(); + size_t max_itr = 20; + + // note that fun_ is set to fun_ad or fun_no by multi_newton_time + bool ok = multi_newton_run( + xout_ , + fun_ , + num_sub_ , + xlow , + xup , + eps , + max_itr , + num_threads_ + ); + if( ! ok ) + { std::cerr << "multi_newton: error" << std::endl; + exit(1); + } + return; + } + + // Repeat computation of all the zeros a specied number of times + void test_repeat(size_t repeat) + { size_t i; + for(i = 0; i < repeat; i++) + test_once(); + return; + } } // end empty namespace // This is the only routine that is accessible outside of this file bool multi_newton_time( - double& time_out , - double test_time , - size_t num_threads , - size_t num_zero , - size_t num_sub , - size_t num_sum , - bool use_ad + double& time_out , + double test_time , + size_t num_threads , + size_t num_zero , + size_t num_sub , + size_t num_sum , + bool use_ad ) { - bool ok = true; - ok &= thread_alloc::thread_num() == 0; - ok &= num_sub > num_zero; - - // Set local namespace environment variables - num_threads_ = num_threads; - if( use_ad ) - fun_ = fun_ad; - else fun_ = fun_no; - // - num_zero_ = num_zero; - num_sub_ = num_sub; - num_sum_ = num_sum; - - // create team of threads - ok &= thread_alloc::in_parallel() == false; - if( num_threads > 0 ) - { team_create(num_threads); - ok &= num_threads == thread_alloc::num_threads(); - } - else - { ok &= 1 == thread_alloc::num_threads(); - } - - // run the test case and set time return value - time_out = CppAD::time_test(test_repeat, test_time); - - // destroy team of threads - if( num_threads > 0 ) - team_destroy(); - ok &= thread_alloc::in_parallel() == false; - // - // correctness check - double pi = 4. * std::atan(1.); - double xup = double(num_zero_ - 1) * pi; - double eps = xup * 100. * CppAD::numeric_limits::epsilon(); - ok &= (xout_.size() == num_zero); - size_t i = 0; - for(i = 0; i < xout_.size(); i++) - ok &= std::fabs( xout_[i] - pi * double(i)) <= 2 * eps; + bool ok = true; + ok &= thread_alloc::thread_num() == 0; + ok &= num_sub > num_zero; + + // Set local namespace environment variables + num_threads_ = num_threads; + if( use_ad ) + fun_ = fun_ad; + else + fun_ = fun_no; + // + num_zero_ = num_zero; + num_sub_ = num_sub; + num_sum_ = num_sum; + + // create team of threads + ok &= thread_alloc::in_parallel() == false; + if( num_threads > 0 ) + { team_create(num_threads); + ok &= num_threads == thread_alloc::num_threads(); + } + else + { ok &= 1 == thread_alloc::num_threads(); + } + + // run the test case and set time return value + time_out = CppAD::time_test(test_repeat, test_time); + + // destroy team of threads + if( num_threads > 0 ) + team_destroy(); + ok &= thread_alloc::in_parallel() == false; + // + // correctness check + double pi = 4. * std::atan(1.); + double xup = double(num_zero_ - 1) * pi; + double eps = xup * 100. * CppAD::numeric_limits::epsilon(); + ok &= (xout_.size() == num_zero); + size_t i = 0; + for(i = 0; i < xout_.size(); i++) + ok &= std::fabs( xout_[i] - pi * double(i)) <= 2 * eps; - // xout_ is a static variable, so clear it to free its memory - xout_.clear(); + // xout_ is a static variable, so clear it to free its memory + xout_.clear(); - // return correctness check result - return ok; + // return correctness check result + return ok; } // END TIME C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/multi_newton.hpp cppad-2019.02.00.0/example/multi_thread/multi_newton.hpp --- cppad-2018.00.00.0/example/multi_thread/multi_newton.hpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/multi_newton.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,22 +3,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ bool multi_newton_time( - double& time_out , - double test_time , - size_t num_threads , - size_t num_zero , - size_t num_sub , - size_t num_sum , - bool use_ad + double& time_out , + double test_time , + size_t num_threads , + size_t num_zero , + size_t num_sub , + size_t num_sum , + bool use_ad ); # endif diff -Nru cppad-2018.00.00.0/example/multi_thread/multi_newton.omh cppad-2019.02.00.0/example/multi_thread/multi_newton.omh --- cppad-2018.00.00.0/example/multi_thread/multi_newton.omh 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/multi_newton.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,16 +1,17 @@ ------------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin multi_newton.cpp$$ $spell - cpp + cpp $$ $section Multi-Threaded Newton Method Example / Test$$ @@ -18,7 +19,7 @@ $head Source File$$ All of the routines below are located in the file $codep - example/multi_thread/multi_newton.cpp + example/multi_thread/multi_newton.cpp $$ $childtable%example/multi_thread/multi_newton.cpp%$$ diff -Nru cppad-2018.00.00.0/example/multi_thread/openmp/a11c_openmp.cpp cppad-2019.02.00.0/example/multi_thread/openmp/a11c_openmp.cpp --- cppad-2018.00.00.0/example/multi_thread/openmp/a11c_openmp.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/openmp/a11c_openmp.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,31 +1,29 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin a11c_openmp.cpp$$ $spell - CppAD - const + CppAD + const $$ $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. $head Source Code$$ -$code $srcfile%example/multi_thread/openmp/a11c_openmp.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end ---------------------------------------------------------------------------- */ @@ -37,41 +35,41 @@ # define NUMBER_THREADS 4 namespace { - // Beginning of Example A.1.1.1c of OpenMP 2.5 standard document --------- - void a1(int n, float *a, float *b) - { int i; - # 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]) / float(2); - } - } - // End of Example A.1.1.1c of OpenMP 2.5 standard document --------------- + // Beginning of Example A.1.1.1c of OpenMP 2.5 standard document --------- + void a1(int n, float *a, float *b) + { int i; + # 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]) / float(2); + } + } + // End of Example A.1.1.1c of OpenMP 2.5 standard document --------------- } bool a11c(void) -{ bool ok = true; +{ bool ok = true; - // Test setup - int i, n = 1000; - float *a = new float[n]; - float *b = new float[n]; - for(i = 0; i < n; i++) - a[i] = float(i); - - 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 - - a1(n, a, b); - - // check the result - float eps = float(100) * std::numeric_limits::epsilon(); - for(i = 1; i < n ; i++) - ok &= std::fabs( (float(2) * b[i] - a[i] - a[i-1]) / b[i] ) <= eps; + // Test setup + int i, n = 1000; + float *a = new float[n]; + float *b = new float[n]; + for(i = 0; i < n; i++) + a[i] = float(i); + + 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 + + a1(n, a, b); + + // check the result + float eps = float(100) * std::numeric_limits::epsilon(); + for(i = 1; i < n ; i++) + ok &= std::fabs( (float(2) * b[i] - a[i] - a[i-1]) / b[i] ) <= eps; - delete [] a; - delete [] b; + delete [] a; + delete [] b; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/openmp/CMakeLists.txt cppad-2019.02.00.0/example/multi_thread/openmp/CMakeLists.txt --- cppad-2018.00.00.0/example/multi_thread/openmp/CMakeLists.txt 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/openmp/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the example/multi_thread/openmp directory tests # Inherit build type from ../CMakeList.txt @@ -22,14 +23,15 @@ # source1 source2 ... sourceN # ) SET(source_list ../thread_test.cpp - ${CMAKE_SOURCE_DIR}/speed/src/microsoft_timer.cpp - ../team_example.cpp - ../harmonic.cpp - ../multi_atomic.cpp - ../multi_newton.cpp - a11c_openmp.cpp - simple_ad_openmp.cpp - team_openmp.cpp + ${CMAKE_SOURCE_DIR}/speed/src/microsoft_timer.cpp + ../team_example.cpp + ../harmonic.cpp + ../multi_atomic.cpp + ../multi_checkpoint.cpp + ../multi_newton.cpp + a11c_openmp.cpp + simple_ad_openmp.cpp + team_openmp.cpp ) set_compile_flags( example_multi_thread_openmp "${cppad_debug_which}" "${source_list}" ) # @@ -40,8 +42,8 @@ # Add the check_example_multi_thread_openmp target ADD_CUSTOM_TARGET(check_example_multi_thread_openmp - example_multi_thread_openmp simple_ad - DEPENDS example_multi_thread_openmp + example_multi_thread_openmp simple_ad + DEPENDS example_multi_thread_openmp ) MESSAGE(STATUS "make check_example_multi_thread_openmp: available") diff -Nru cppad-2018.00.00.0/example/multi_thread/openmp/simple_ad_openmp.cpp cppad-2019.02.00.0/example/multi_thread/openmp/simple_ad_openmp.cpp --- cppad-2018.00.00.0/example/multi_thread/openmp/simple_ad_openmp.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/openmp/simple_ad_openmp.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin simple_ad_openmp.cpp$$ $spell - openmp - CppAD + openmp + CppAD $$ $section A Simple OpenMP AD: Example and Test$$ -$mindex AD$$ $head Purpose$$ @@ -25,9 +25,7 @@ OpenMP multi-threading environment. $head Source Code$$ -$code $srcfile%example/multi_thread/openmp/simple_ad_openmp.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end ------------------------------------------------------------------------------ @@ -38,145 +36,145 @@ # define NUMBER_THREADS 4 namespace { - // structure with problem specific information - typedef struct { - // function argument (worker input) - double x; - // This structure would also have return information in it, - // but this example only returns the ok flag - } problem_specific; - // ===================================================================== - // General purpose code you can copy to your application - // ===================================================================== - using CppAD::thread_alloc; - // ------------------------------------------------------------------ - // used to inform CppAD when we are in parallel execution mode - bool in_parallel(void) - { return omp_in_parallel() != 0; } - // ------------------------------------------------------------------ - // used to inform CppAD of the current thread number - size_t thread_number(void) - { return static_cast( omp_get_thread_num() ); } - // ------------------------------------------------------------------ - // structure with information for one thread - typedef struct { - // false if an error occurs, true otherwise (worker output) - bool ok; - } thread_one_t; - // vector with information for all threads - thread_one_t thread_all_[NUMBER_THREADS]; - // ------------------------------------------------------------------ - // function that calls all the workers - bool worker(problem_specific* info); - bool run_all_workers(size_t num_threads, problem_specific* info_all[]) - { bool ok = true; - - // 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 - thread_all_[thread_num].ok = false; - } - - // turn off dynamic thread adjustment - omp_set_dynamic(0); - - // set the number of OpenMP threads - omp_set_num_threads( int_num_threads ); - - // setup for using CppAD::AD in parallel - thread_alloc::parallel_setup( - num_threads, in_parallel, thread_number - ); - thread_alloc::hold_memory(true); - CppAD::parallel_ad(); + // structure with problem specific information + typedef struct { + // function argument (worker input) + double x; + // This structure would also have return information in it, + // but this example only returns the ok flag + } problem_specific; + // ===================================================================== + // General purpose code you can copy to your application + // ===================================================================== + using CppAD::thread_alloc; + // ------------------------------------------------------------------ + // used to inform CppAD when we are in parallel execution mode + bool in_parallel(void) + { return omp_in_parallel() != 0; } + // ------------------------------------------------------------------ + // used to inform CppAD of the current thread number + size_t thread_number(void) + { return static_cast( omp_get_thread_num() ); } + // ------------------------------------------------------------------ + // structure with information for one thread + typedef struct { + // false if an error occurs, true otherwise (worker output) + bool ok; + } thread_one_t; + // vector with information for all threads + thread_one_t thread_all_[NUMBER_THREADS]; + // ------------------------------------------------------------------ + // function that calls all the workers + bool worker(problem_specific* info); + bool run_all_workers(size_t num_threads, problem_specific* info_all[]) + { bool ok = true; + + // 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 + thread_all_[thread_num].ok = false; + } + + // turn off dynamic thread adjustment + omp_set_dynamic(0); + + // set the number of OpenMP threads + omp_set_num_threads( int_num_threads ); + + // setup for using CppAD::AD in parallel + thread_alloc::parallel_setup( + num_threads, in_parallel, thread_number + ); + thread_alloc::hold_memory(true); + CppAD::parallel_ad(); - // execute worker in parallel + // execute worker in parallel # pragma omp parallel for - for(thread_num = 0; thread_num < int_num_threads; thread_num++) - thread_all_[thread_num].ok = worker(info_all[thread_num]); + for(thread_num = 0; thread_num < int_num_threads; thread_num++) + thread_all_[thread_num].ok = worker(info_all[thread_num]); // end omp parallel for - // set the number of OpenMP threads to one - omp_set_num_threads(1); + // set the number of OpenMP threads to one + omp_set_num_threads(1); - // now inform CppAD that there is only one thread - thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL); - thread_alloc::hold_memory(false); - CppAD::parallel_ad(); - - // check to ok flag returned by during calls to work by other threads - for(thread_num = 1; thread_num < int_num_threads; thread_num++) - ok &= thread_all_[thread_num].ok; - - return ok; - } - // ===================================================================== - // End of General purpose code - // ===================================================================== - // function that does the work for one thread - bool worker(problem_specific* info) - { using CppAD::NearEqual; - using CppAD::AD; - bool ok = true; - - // CppAD::vector uses the CppAD fast multi-threading allocator - CppAD::vector< AD > ax(1), ay(1); - ax[0] = info->x; - Independent(ax); - ay[0] = sqrt( ax[0] * ax[0] ); - CppAD::ADFun f(ax, ay); - - // Check function value corresponds to the identity - double eps = 10. * CppAD::numeric_limits::epsilon(); - ok &= NearEqual(ay[0], ax[0], eps, eps); - - // Check derivative value corresponds to the identity. - CppAD::vector d_x(1), d_y(1); - d_x[0] = 1.; - d_y = f.Forward(1, d_x); - ok &= NearEqual(d_x[0], 1., eps, eps); + // now inform CppAD that there is only one thread + thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL); + thread_alloc::hold_memory(false); + CppAD::parallel_ad(); + + // check to ok flag returned by during calls to work by other threads + for(thread_num = 1; thread_num < int_num_threads; thread_num++) + ok &= thread_all_[thread_num].ok; + + return ok; + } + // ===================================================================== + // End of General purpose code + // ===================================================================== + // function that does the work for one thread + bool worker(problem_specific* info) + { using CppAD::NearEqual; + using CppAD::AD; + bool ok = true; + + // CppAD::vector uses the CppAD fast multi-threading allocator + CppAD::vector< AD > ax(1), ay(1); + ax[0] = info->x; + Independent(ax); + ay[0] = sqrt( ax[0] * ax[0] ); + CppAD::ADFun f(ax, ay); + + // Check function value corresponds to the identity + double eps = 10. * CppAD::numeric_limits::epsilon(); + ok &= NearEqual(ay[0], ax[0], eps, eps); + + // Check derivative value corresponds to the identity. + CppAD::vector d_x(1), d_y(1); + d_x[0] = 1.; + d_y = f.Forward(1, d_x); + ok &= NearEqual(d_x[0], 1., eps, eps); - return ok; - } + return ok; + } } bool simple_ad(void) -{ bool ok = true; - size_t num_threads = NUMBER_THREADS; +{ bool ok = true; + size_t num_threads = NUMBER_THREADS; - // Check that no memory is in use or avialable at start - // (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; - } - - // initialize info_all - problem_specific *info, *info_all[NUMBER_THREADS]; - for(thread_num = 0; thread_num < num_threads; thread_num++) - { // problem specific information - size_t min_bytes(sizeof(info)), cap_bytes; - void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); - info = static_cast(v_ptr); - info->x = double(thread_num) + 1.; - info_all[thread_num] = info; - } - - ok &= run_all_workers(num_threads, info_all); - - // go down so that free memory for other threads before memory for master - thread_num = num_threads; - while(thread_num--) - { // delete problem specific information - 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; - // return all memory being held for future use by this thread - thread_alloc::free_available(thread_num); - } + // Check that no memory is in use or avialable at start + // (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; + } + + // initialize info_all + problem_specific *info, *info_all[NUMBER_THREADS]; + for(thread_num = 0; thread_num < num_threads; thread_num++) + { // problem specific information + size_t min_bytes(sizeof(info)), cap_bytes; + void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); + info = static_cast(v_ptr); + info->x = double(thread_num) + 1.; + info_all[thread_num] = info; + } + + ok &= run_all_workers(num_threads, info_all); + + // go down so that free memory for other threads before memory for master + thread_num = num_threads; + while(thread_num--) + { // delete problem specific information + 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; + // return all memory being held for future use by this thread + thread_alloc::free_available(thread_num); + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/openmp/team_openmp.cpp cppad-2019.02.00.0/example/multi_thread/openmp/team_openmp.cpp --- cppad-2018.00.00.0/example/multi_thread/openmp/team_openmp.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/openmp/team_openmp.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin team_openmp.cpp$$ $spell - openmp + openmp $$ $section OpenMP Implementation of a Team of AD Threads$$ See $cref team_thread.hpp$$ for this routines specifications. -$code $srcfile%example/multi_thread/openmp/team_openmp.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,77 +29,77 @@ # include "../team_thread.hpp" namespace { - using CppAD::thread_alloc; + using CppAD::thread_alloc; - // number of threads in this team - size_t num_threads_; + // number of threads in this team + size_t num_threads_; - // used to inform CppAD when we are in parallel execution mode - bool in_parallel(void) - { 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() ); } + // used to inform CppAD when we are in parallel execution mode + bool in_parallel(void) + { 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() ); } } bool team_create(size_t num_threads) { - bool ok = ! in_parallel(); - ok &= thread_num() == 0;; - ok &= num_threads > 0; + bool ok = ! in_parallel(); + ok &= thread_num() == 0;; + ok &= num_threads > 0; - // Turn off dynamic thread adjustment - omp_set_dynamic(0); + // Turn off dynamic thread adjustment + omp_set_dynamic(0); - // Set the number of OpenMP threads - omp_set_num_threads( int(num_threads) ); + // Set the number of OpenMP threads + omp_set_num_threads( int(num_threads) ); - // 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(); + // 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(); - // inform team_work of number of threads - num_threads_ = num_threads; + // inform team_work of number of threads + num_threads_ = num_threads; - return ok; + return ok; } bool team_work(void worker(void)) -{ bool ok = ! in_parallel(); - ok &= thread_num() == 0;; - ok &= num_threads_ > 0; +{ bool ok = ! in_parallel(); + ok &= thread_num() == 0;; + ok &= num_threads_ > 0; - int number_threads = int(num_threads_); - int thread_num; + int number_threads = int(num_threads_); + int thread_num; # pragma omp parallel for - for(thread_num = 0; thread_num < number_threads; thread_num++) - worker(); + for(thread_num = 0; thread_num < number_threads; thread_num++) + worker(); // end omp parallel for - return ok; + return ok; } bool team_destroy(void) -{ bool ok = ! in_parallel(); - ok &= thread_num() == 0;; - ok &= num_threads_ > 0; - - // inform team_work of number of threads - num_threads_ = 1; - - // Set the number of OpenMP threads to one - omp_set_num_threads( int(num_threads_) ); - - // inform CppAD no longer in multi-threading mode - thread_alloc::parallel_setup(num_threads_, CPPAD_NULL, CPPAD_NULL); - thread_alloc::hold_memory(false); - CppAD::parallel_ad(); +{ bool ok = ! in_parallel(); + ok &= thread_num() == 0;; + ok &= num_threads_ > 0; + + // inform team_work of number of threads + num_threads_ = 1; + + // Set the number of OpenMP threads to one + omp_set_num_threads( int(num_threads_) ); + + // inform CppAD no longer in multi-threading mode + thread_alloc::parallel_setup(num_threads_, CPPAD_NULL, CPPAD_NULL); + thread_alloc::hold_memory(false); + CppAD::parallel_ad(); - return ok; + return ok; } const char* team_name(void) -{ return "openmp"; } +{ return "openmp"; } // END C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/pthread/a11c_pthread.cpp cppad-2019.02.00.0/example/multi_thread/pthread/a11c_pthread.cpp --- cppad-2018.00.00.0/example/multi_thread/pthread/a11c_pthread.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/pthread/a11c_pthread.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,31 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin a11c_pthread.cpp$$ $spell - pthread - pthreads - CppAD - const + pthread + pthreads + CppAD + const $$ $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. $head Source Code$$ -$code $srcfile%example/multi_thread/pthread/a11c_pthread.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end ---------------------------------------------------------------------------- */ @@ -53,81 +51,81 @@ # define CHECK_ZERO(expression) assert( expression == 0 ); # endif namespace { - // Beginning of Example A.1.1.1c of OpenMP 2.5 standard document --------- - void a1(int n, float *a, float *b) - { int i; - // for some reason this function is missing on some systems - // assert( pthread_is_multithreaded_np() > 0 ); - for(i = 1; i < n; i++) - b[i] = (a[i] + a[i-1]) / 2.0f; - return; - } - // End of Example A.1.1.1c of OpenMP 2.5 standard document --------------- - struct start_arg { int n; float* a; float* b; }; - void* start_routine(void* arg_vptr) - { start_arg* arg = static_cast( arg_vptr ); - a1(arg->n, arg->a, arg->b); + // Beginning of Example A.1.1.1c of OpenMP 2.5 standard document --------- + void a1(int n, float *a, float *b) + { int i; + // for some reason this function is missing on some systems + // assert( pthread_is_multithreaded_np() > 0 ); + for(i = 1; i < n; i++) + b[i] = (a[i] + a[i-1]) / 2.0f; + return; + } + // End of Example A.1.1.1c of OpenMP 2.5 standard document --------------- + struct start_arg { int n; float* a; float* b; }; + void* start_routine(void* arg_vptr) + { start_arg* arg = static_cast( arg_vptr ); + a1(arg->n, arg->a, arg->b); - void* no_status = CPPAD_NULL; - pthread_exit(no_status); + void* no_status = CPPAD_NULL; + pthread_exit(no_status); - return no_status; - } + return no_status; + } } bool a11c(void) -{ bool ok = true; +{ bool ok = true; - // Test setup - int i, j, n_total = 10; - float *a = new float[n_total]; - float *b = new float[n_total]; - for(i = 0; i < n_total; i++) - a[i] = float(i); - - // number of threads - int n_thread = NUMBER_THREADS; - // the threads - pthread_t thread[NUMBER_THREADS]; - // arguments to start_routine - struct start_arg arg[NUMBER_THREADS]; - // attr - pthread_attr_t attr; - CHECK_ZERO( pthread_attr_init( &attr ) ); - CHECK_ZERO( pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE) ); - // - // Break the work up into sub work for each thread - int n = n_total / n_thread; - arg[0].n = n; - arg[0].a = a; - arg[0].b = b; - for(j = 1; j < n_thread; j++) - { arg[j].n = n + 1; - arg[j].a = arg[j-1].a + n - 1; - arg[j].b = arg[j-1].b + n - 1; - if( j == (n_thread - 1) ) - arg[j].n = n_total - j * n + 1; - } - for(j = 0; j < n_thread; j++) - { // inform each thread of which block it is working on - void* arg_vptr = static_cast( &arg[j] ); - CHECK_ZERO( pthread_create( - &thread[j], &attr, start_routine, arg_vptr - ) ); - } - for(j = 0; j < n_thread; j++) - { void* no_status = CPPAD_NULL; - CHECK_ZERO( pthread_join(thread[j], &no_status) ); - } - - // check the result - float eps = 100.0f * std::numeric_limits::epsilon(); - for(i = 1; i < n ; i++) - ok &= std::fabs( (2. * b[i] - a[i] - a[i-1]) / b[i] ) <= eps; + // Test setup + int i, j, n_total = 10; + float *a = new float[n_total]; + float *b = new float[n_total]; + for(i = 0; i < n_total; i++) + a[i] = float(i); + + // number of threads + int n_thread = NUMBER_THREADS; + // the threads + pthread_t thread[NUMBER_THREADS]; + // arguments to start_routine + struct start_arg arg[NUMBER_THREADS]; + // attr + pthread_attr_t attr; + CHECK_ZERO( pthread_attr_init( &attr ) ); + CHECK_ZERO( pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE) ); + // + // Break the work up into sub work for each thread + int n = n_total / n_thread; + arg[0].n = n; + arg[0].a = a; + arg[0].b = b; + for(j = 1; j < n_thread; j++) + { arg[j].n = n + 1; + arg[j].a = arg[j-1].a + n - 1; + arg[j].b = arg[j-1].b + n - 1; + if( j == (n_thread - 1) ) + arg[j].n = n_total - j * n + 1; + } + for(j = 0; j < n_thread; j++) + { // inform each thread of which block it is working on + void* arg_vptr = static_cast( &arg[j] ); + CHECK_ZERO( pthread_create( + &thread[j], &attr, start_routine, arg_vptr + ) ); + } + for(j = 0; j < n_thread; j++) + { void* no_status = CPPAD_NULL; + CHECK_ZERO( pthread_join(thread[j], &no_status) ); + } + + // check the result + float eps = 100.0f * std::numeric_limits::epsilon(); + for(i = 1; i < n ; i++) + ok &= std::fabs( (2. * b[i] - a[i] - a[i-1]) / b[i] ) <= eps; - delete [] a; - delete [] b; + delete [] a; + delete [] b; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/pthread/CMakeLists.txt cppad-2019.02.00.0/example/multi_thread/pthread/CMakeLists.txt --- cppad-2018.00.00.0/example/multi_thread/pthread/CMakeLists.txt 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/pthread/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the example/multi_thread/pthread directory tests # Inherit build type from ../CMakeList.txt @@ -18,14 +19,15 @@ # source1 source2 ... sourceN # ) SET(source_list ../thread_test.cpp - ${CMAKE_SOURCE_DIR}/speed/src/microsoft_timer.cpp - ../team_example.cpp - ../harmonic.cpp - ../multi_atomic.cpp - ../multi_newton.cpp - a11c_pthread.cpp - simple_ad_pthread.cpp - team_pthread.cpp + ${CMAKE_SOURCE_DIR}/speed/src/microsoft_timer.cpp + ../team_example.cpp + ../harmonic.cpp + ../multi_atomic.cpp + ../multi_checkpoint.cpp + ../multi_newton.cpp + a11c_pthread.cpp + simple_ad_pthread.cpp + team_pthread.cpp ) set_compile_flags( example_multi_thread_pthread "${cppad_debug_which}" "${source_list}" ) # @@ -40,8 +42,8 @@ # Add the check_example_multi_thread_pthread target ADD_CUSTOM_TARGET(check_example_multi_thread_pthread - example_multi_thread_pthread simple_ad - DEPENDS example_multi_thread_pthread + example_multi_thread_pthread simple_ad + DEPENDS example_multi_thread_pthread ) MESSAGE(STATUS "make check_example_multi_thread_pthread: available") diff -Nru cppad-2018.00.00.0/example/multi_thread/pthread/simple_ad_pthread.cpp cppad-2019.02.00.0/example/multi_thread/pthread/simple_ad_pthread.cpp --- cppad-2018.00.00.0/example/multi_thread/pthread/simple_ad_pthread.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/pthread/simple_ad_pthread.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin simple_ad_pthread.cpp$$ $spell - pthread - CppAD + pthread + CppAD $$ $section A Simple pthread AD: Example and Test$$ -$mindex AD$$ $head Purpose$$ @@ -25,9 +25,7 @@ pthread multi-threading environment. $head Source Code$$ -$code $srcfile%example/multi_thread/pthread/simple_ad_pthread.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end ------------------------------------------------------------------------------ @@ -38,254 +36,254 @@ # define NUMBER_THREADS 4 namespace { - // structure with problem specific information - typedef struct { - // function argument (worker input) - double x; - // This structure would also have return information in it, - // but this example only returns the ok flag - } problem_specific; - // ===================================================================== - // General purpose code you can copy to your application - // ===================================================================== - using CppAD::thread_alloc; - // ------------------------------------------------------------------ - // key for accessing thread specific information - pthread_key_t thread_specific_key_; - - // no need to destroy thread specific information - void thread_specific_destructor(void* thread_num_vptr) - { return; } - - // Are we in sequential mode; i.e., other threads are waiting for - // master thread to set up next job ? - bool sequential_execution_ = true; - - // used to inform CppAD when we are in parallel execution mode - bool in_parallel(void) - { return ! sequential_execution_; } - - // 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_); - size_t* thread_num_ptr = static_cast(thread_num_vptr); - size_t thread_num = *thread_num_ptr; - return thread_num; - } - // --------------------------------------------------------------------- - // structure with information for one thread - typedef struct { - // number for this thread (thread specific points here) - size_t thread_num; - // pthread unique identifier for this thread - pthread_t pthread_id; - // false if an error occurs, true otherwise - bool ok; - // pointer to problem specific information - problem_specific* info; - } thread_one_t; - // vector with information for all threads - thread_one_t thread_all_[NUMBER_THREADS]; - // -------------------------------------------------------------------- - // function that initializes the thread and then calls the actual worker - bool worker(size_t thread_num, problem_specific* info); - void* run_one_worker(void* thread_num_vptr) - { bool ok = true; - - // thread_num for this thread - size_t thread_num = *static_cast(thread_num_vptr); - - // The master thread should call worker directly - 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 - // of this threads number. - // We must do this before calling thread_alloc::thread_num(). - int rc = pthread_setspecific( - thread_specific_key_, - thread_num_vptr - ); - ok &= rc == 0; - - // check the value of thread_alloc::thread_num(). - ok = thread_num == thread_alloc::thread_num(); - - // Now do the work - ok &= worker(thread_num, thread_all_[thread_num].info); - - // pass back ok information for this thread - thread_all_[thread_num].ok = ok; - - // no return value - return CPPAD_NULL; - } - // -------------------------------------------------------------------- - // function that calls all the workers - bool run_all_workers(size_t num_threads, problem_specific* info_all[]) - { bool ok = true; - - // initialize thread_all_ (execpt for pthread_id) - size_t thread_num; - for(thread_num = 0; thread_num < num_threads; thread_num++) - { // pointed to by thread specific info for this thread - thread_all_[thread_num].thread_num = thread_num; - // initialize as false to make sure worker gets called by other - // threads. Note that thread_all_[0].ok does not get used - thread_all_[thread_num].ok = false; - // problem specific information - thread_all_[thread_num].info = info_all[thread_num]; - } - - // master pthread_id - thread_all_[0].pthread_id = pthread_self(); - - // error flag for calls to pthread library - int rc; - - // 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) - void* thread_num_vptr = static_cast( - &(thread_all_[0].thread_num) - ); - rc = pthread_setspecific(thread_specific_key_, thread_num_vptr); - ok &= (rc == 0); - - // Now thread_number() has necessary information for this thread - // (number zero), and while still in sequential mode, - // call setup for using CppAD::AD in parallel mode. - thread_alloc::parallel_setup( - num_threads, in_parallel, thread_number - ); - thread_alloc::hold_memory(true); - CppAD::parallel_ad(); - - // 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 - pthread_attr_t* no_attr= CPPAD_NULL; - - // 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) - ); - rc = pthread_create( - &pthread_id , - no_attr , - run_one_worker, - thread_num_vptr - ); - thread_all_[thread_num].pthread_id = pthread_id; - ok &= (rc == 0); - } - - // now call worker for the master thread - thread_num = thread_alloc::thread_num(); - ok &= thread_num == 0; - ok &= worker(thread_num, thread_all_[thread_num].info); - - // 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( - thread_all_[thread_num].pthread_id, &no_status - ); - ok &= (rc == 0); - } - - // Inform CppAD that we now are definately back to sequential mode - sequential_execution_ = true; - - // now inform CppAD that there is only one thread - thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL); - thread_alloc::hold_memory(false); - CppAD::parallel_ad(); - - // destroy the key for thread specific data - pthread_key_delete(thread_specific_key_); - - // check to ok flag returned by during calls to work by other threads - for(thread_num = 1; thread_num < num_threads; thread_num++) - ok &= thread_all_[thread_num].ok; - - return ok; - } - // ===================================================================== - // End of General purpose code - // ===================================================================== - // function that does the work for one thread - bool worker(size_t thread_num, problem_specific* info) - { bool ok = true; - - // CppAD::vector uses the CppAD fast multi-threading allocator - CppAD::vector< CppAD::AD > ax(1), ay(1); - ax[0] = info->x; - Independent(ax); - ay[0] = sqrt( ax[0] * ax[0] ); - CppAD::ADFun f(ax, ay); - - // Check function value corresponds to the identity - double eps = 10. * CppAD::numeric_limits::epsilon(); - ok &= CppAD::NearEqual(ay[0], ax[0], eps, eps); - - // Check derivative value corresponds to the identity. - CppAD::vector d_x(1), d_y(1); - d_x[0] = 1.; - d_y = f.Forward(1, d_x); - ok &= CppAD::NearEqual(d_x[0], 1., eps, eps); + // structure with problem specific information + typedef struct { + // function argument (worker input) + double x; + // This structure would also have return information in it, + // but this example only returns the ok flag + } problem_specific; + // ===================================================================== + // General purpose code you can copy to your application + // ===================================================================== + using CppAD::thread_alloc; + // ------------------------------------------------------------------ + // key for accessing thread specific information + pthread_key_t thread_specific_key_; + + // no need to destroy thread specific information + void thread_specific_destructor(void* thread_num_vptr) + { return; } + + // Are we in sequential mode; i.e., other threads are waiting for + // master thread to set up next job ? + bool sequential_execution_ = true; + + // used to inform CppAD when we are in parallel execution mode + bool in_parallel(void) + { return ! sequential_execution_; } + + // 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_); + size_t* thread_num_ptr = static_cast(thread_num_vptr); + size_t thread_num = *thread_num_ptr; + return thread_num; + } + // --------------------------------------------------------------------- + // structure with information for one thread + typedef struct { + // number for this thread (thread specific points here) + size_t thread_num; + // pthread unique identifier for this thread + pthread_t pthread_id; + // false if an error occurs, true otherwise + bool ok; + // pointer to problem specific information + problem_specific* info; + } thread_one_t; + // vector with information for all threads + thread_one_t thread_all_[NUMBER_THREADS]; + // -------------------------------------------------------------------- + // function that initializes the thread and then calls the actual worker + bool worker(size_t thread_num, problem_specific* info); + void* run_one_worker(void* thread_num_vptr) + { bool ok = true; + + // thread_num for this thread + size_t thread_num = *static_cast(thread_num_vptr); + + // The master thread should call worker directly + 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 + // of this threads number. + // We must do this before calling thread_alloc::thread_num(). + int rc = pthread_setspecific( + thread_specific_key_, + thread_num_vptr + ); + ok &= rc == 0; + + // check the value of thread_alloc::thread_num(). + ok = thread_num == thread_alloc::thread_num(); + + // Now do the work + ok &= worker(thread_num, thread_all_[thread_num].info); + + // pass back ok information for this thread + thread_all_[thread_num].ok = ok; + + // no return value + return CPPAD_NULL; + } + // -------------------------------------------------------------------- + // function that calls all the workers + bool run_all_workers(size_t num_threads, problem_specific* info_all[]) + { bool ok = true; + + // initialize thread_all_ (execpt for pthread_id) + size_t thread_num; + for(thread_num = 0; thread_num < num_threads; thread_num++) + { // pointed to by thread specific info for this thread + thread_all_[thread_num].thread_num = thread_num; + // initialize as false to make sure worker gets called by other + // threads. Note that thread_all_[0].ok does not get used + thread_all_[thread_num].ok = false; + // problem specific information + thread_all_[thread_num].info = info_all[thread_num]; + } + + // master pthread_id + thread_all_[0].pthread_id = pthread_self(); + + // error flag for calls to pthread library + int rc; + + // 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) + void* thread_num_vptr = static_cast( + &(thread_all_[0].thread_num) + ); + rc = pthread_setspecific(thread_specific_key_, thread_num_vptr); + ok &= (rc == 0); + + // Now thread_number() has necessary information for this thread + // (number zero), and while still in sequential mode, + // call setup for using CppAD::AD in parallel mode. + thread_alloc::parallel_setup( + num_threads, in_parallel, thread_number + ); + thread_alloc::hold_memory(true); + CppAD::parallel_ad(); + + // 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 + pthread_attr_t* no_attr= CPPAD_NULL; + + // 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) + ); + rc = pthread_create( + &pthread_id , + no_attr , + run_one_worker, + thread_num_vptr + ); + thread_all_[thread_num].pthread_id = pthread_id; + ok &= (rc == 0); + } + + // now call worker for the master thread + thread_num = thread_alloc::thread_num(); + ok &= thread_num == 0; + ok &= worker(thread_num, thread_all_[thread_num].info); + + // 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( + thread_all_[thread_num].pthread_id, &no_status + ); + ok &= (rc == 0); + } + + // Inform CppAD that we now are definately back to sequential mode + sequential_execution_ = true; + + // now inform CppAD that there is only one thread + thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL); + thread_alloc::hold_memory(false); + CppAD::parallel_ad(); + + // destroy the key for thread specific data + pthread_key_delete(thread_specific_key_); + + // check to ok flag returned by during calls to work by other threads + for(thread_num = 1; thread_num < num_threads; thread_num++) + ok &= thread_all_[thread_num].ok; + + return ok; + } + // ===================================================================== + // End of General purpose code + // ===================================================================== + // function that does the work for one thread + bool worker(size_t thread_num, problem_specific* info) + { bool ok = true; + + // CppAD::vector uses the CppAD fast multi-threading allocator + CppAD::vector< CppAD::AD > ax(1), ay(1); + ax[0] = info->x; + Independent(ax); + ay[0] = sqrt( ax[0] * ax[0] ); + CppAD::ADFun f(ax, ay); + + // Check function value corresponds to the identity + double eps = 10. * CppAD::numeric_limits::epsilon(); + ok &= CppAD::NearEqual(ay[0], ax[0], eps, eps); + + // Check derivative value corresponds to the identity. + CppAD::vector d_x(1), d_y(1); + d_x[0] = 1.; + d_y = f.Forward(1, d_x); + ok &= CppAD::NearEqual(d_x[0], 1., eps, eps); - return ok; - } + return ok; + } } bool simple_ad(void) -{ bool ok = true; - size_t num_threads = NUMBER_THREADS; +{ bool ok = true; + size_t num_threads = NUMBER_THREADS; - // Check that no memory is in use or avialable at start - // (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; - } - - // initialize info_all - problem_specific *info, *info_all[NUMBER_THREADS]; - for(thread_num = 0; thread_num < num_threads; thread_num++) - { // problem specific information - size_t min_bytes(sizeof(info)), cap_bytes; - void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); - info = static_cast(v_ptr); - info->x = double(thread_num) + 1.; - info_all[thread_num] = info; - } - - ok &= run_all_workers(num_threads, info_all); - - // go down so that free memory for other threads before memory for master - thread_num = num_threads; - while(thread_num--) - { // delete problem specific information - 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; - // return all memory being held for future use by this thread - thread_alloc::free_available(thread_num); - } + // Check that no memory is in use or avialable at start + // (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; + } + + // initialize info_all + problem_specific *info, *info_all[NUMBER_THREADS]; + for(thread_num = 0; thread_num < num_threads; thread_num++) + { // problem specific information + size_t min_bytes(sizeof(info)), cap_bytes; + void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); + info = static_cast(v_ptr); + info->x = double(thread_num) + 1.; + info_all[thread_num] = info; + } + + ok &= run_all_workers(num_threads, info_all); + + // go down so that free memory for other threads before memory for master + thread_num = num_threads; + while(thread_num--) + { // delete problem specific information + 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; + // return all memory being held for future use by this thread + thread_alloc::free_available(thread_num); + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/pthread/team_pthread.cpp cppad-2019.02.00.0/example/multi_thread/pthread/team_pthread.cpp --- cppad-2018.00.00.0/example/multi_thread/pthread/team_pthread.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/pthread/team_pthread.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin team_pthread.cpp$$ $spell - Cygwin - pthread + Cygwin + 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$$ @@ -32,9 +32,7 @@ $srccode%cpp% */ # define DEMONSTRATE_BUG_IN_CYGWIN 0 /* %$$ -$code $srcfile%example/multi_thread/pthread/team_pthread.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -48,295 +46,295 @@ // to its original value and it can be used again, but where is this // stated in the pthreads speicifcations ? namespace { - using CppAD::thread_alloc; + using CppAD::thread_alloc; - // number of threads in the team - size_t num_threads_ = 1; + // number of threads in the team + size_t num_threads_ = 1; - // key for accessing thread specific information - pthread_key_t thread_specific_key_; + // key for accessing thread specific information + pthread_key_t thread_specific_key_; - // no need to destroy thread specific information - void thread_specific_destructor(void* thread_num_vptr) - { return; } - - // type of the job currently being done by each thread - enum thread_job_t { init_enum, work_enum, join_enum } thread_job_; - - // barrier used to wait for other threads to finish work - pthread_barrier_t wait_for_work_; - - // barrier used to wait for master thread to set next job - pthread_barrier_t wait_for_job_; - - // Are we in sequential mode; i.e., other threads are waiting for - // master thread to set up next job ? - bool sequential_execution_ = true; - - // structure with information for one thread - typedef struct { - // cppad unique identifier for thread that uses this struct - size_t thread_num; - // pthread unique identifier for thread that uses this struct - pthread_t pthread_id; - // true if no error for this thread, false otherwise. - bool ok; - } thread_one_t; - - // vector with information for all threads - thread_one_t thread_all_[MAX_NUMBER_THREADS]; - - // pointer to function that does the work for one thread - void (* worker_)(void) = CPPAD_NULL; - - // --------------------------------------------------------------------- - // in_parallel() - bool in_parallel(void) - { return ! sequential_execution_; } - - // --------------------------------------------------------------------- - // thread_number() - size_t thread_number(void) - { // get thread specific information - 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_ ) - { std::cerr << "thread_number: program error" << std::endl; - exit(1); - } - return thread_num; - } - // -------------------------------------------------------------------- - // function that gets called by pthread_create - void* thread_work(void* thread_num_vptr) - { int rc; - bool ok = true; - - // Set thread specific data where other routines can access it - rc = pthread_setspecific(thread_specific_key_, thread_num_vptr); - ok &= rc == 0; - - // thread_num to problem specific information for this thread - size_t thread_num = *static_cast(thread_num_vptr); - - // master thread does not use this routine - ok &= thread_num > 0; - - while( true ) - { - // Use wait_for_job_ to give master time in sequential mode - // (so it can change global infromation like thread_job_) - rc = pthread_barrier_wait(&wait_for_job_); - ok &= (rc == 0 || rc == PTHREAD_BARRIER_SERIAL_THREAD); - - // case where we are terminating this thread (no more work) - if( thread_job_ == join_enum ) - break; - - // only other case once wait_for_job_ barrier is passed (so far) - ok &= thread_job_ == work_enum; - worker_(); - - // Use wait_for_work_ to inform master that our work is done and - // 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); - } - thread_all_[thread_num].ok = ok; + // no need to destroy thread specific information + void thread_specific_destructor(void* thread_num_vptr) + { return; } + + // type of the job currently being done by each thread + enum thread_job_t { init_enum, work_enum, join_enum } thread_job_; + + // barrier used to wait for other threads to finish work + pthread_barrier_t wait_for_work_; + + // barrier used to wait for master thread to set next job + pthread_barrier_t wait_for_job_; + + // Are we in sequential mode; i.e., other threads are waiting for + // master thread to set up next job ? + bool sequential_execution_ = true; + + // structure with information for one thread + typedef struct { + // cppad unique identifier for thread that uses this struct + size_t thread_num; + // pthread unique identifier for thread that uses this struct + pthread_t pthread_id; + // true if no error for this thread, false otherwise. + bool ok; + } thread_one_t; + + // vector with information for all threads + thread_one_t thread_all_[MAX_NUMBER_THREADS]; + + // pointer to function that does the work for one thread + void (* worker_)(void) = CPPAD_NULL; + + // --------------------------------------------------------------------- + // in_parallel() + bool in_parallel(void) + { return ! sequential_execution_; } + + // --------------------------------------------------------------------- + // thread_number() + size_t thread_number(void) + { // get thread specific information + 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_ ) + { std::cerr << "thread_number: program error" << std::endl; + exit(1); + } + return thread_num; + } + // -------------------------------------------------------------------- + // function that gets called by pthread_create + void* thread_work(void* thread_num_vptr) + { int rc; + bool ok = true; + + // Set thread specific data where other routines can access it + rc = pthread_setspecific(thread_specific_key_, thread_num_vptr); + ok &= rc == 0; + + // thread_num to problem specific information for this thread + size_t thread_num = *static_cast(thread_num_vptr); + + // master thread does not use this routine + ok &= thread_num > 0; + + while( true ) + { + // Use wait_for_job_ to give master time in sequential mode + // (so it can change global infromation like thread_job_) + rc = pthread_barrier_wait(&wait_for_job_); + ok &= (rc == 0 || rc == PTHREAD_BARRIER_SERIAL_THREAD); + + // case where we are terminating this thread (no more work) + if( thread_job_ == join_enum ) + break; + + // only other case once wait_for_job_ barrier is passed (so far) + ok &= thread_job_ == work_enum; + worker_(); + + // Use wait_for_work_ to inform master that our work is done and + // 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); + } + thread_all_[thread_num].ok = ok; # if DEMONSTRATE_BUG_IN_CYGWIN - // Terminate this thread - void* no_status = CPPAD_NULL; - pthread_exit(no_status); + // Terminate this thread + void* no_status = CPPAD_NULL; + pthread_exit(no_status); # endif - return CPPAD_NULL; - } + return CPPAD_NULL; + } } bool team_create(size_t num_threads) -{ bool ok = true;; - int rc; +{ bool ok = true;; + int rc; - if( num_threads > MAX_NUMBER_THREADS ) - { std::cerr << "team_create: num_threads greater than "; - std::cerr << MAX_NUMBER_THREADS << std::endl; - exit(1); - } - // check that we currently do not have multiple threads running - ok = num_threads_ == 1; - ok &= sequential_execution_; - - size_t thread_num; - for(thread_num = 0; thread_num < num_threads; thread_num++) - { // Each thread gets a pointer to its version of this thread_num - // so it knows which section of thread_all_ it is working with - thread_all_[thread_num].thread_num = thread_num; - - // initialize - thread_all_[thread_num].ok = true; - } - // Finish setup of thread_all_ for this thread - thread_all_[0].pthread_id = pthread_self(); - - // 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) - void* thread_num_vptr = static_cast(&(thread_all_[0].thread_num)); - rc = pthread_setspecific(thread_specific_key_, thread_num_vptr); - ok &= (rc == 0); - - // Now that thread_number() has necessary information for this thread - // (number zero), and while still in sequential mode, - // call setup for using CppAD::AD in parallel mode. - thread_alloc::parallel_setup(num_threads, in_parallel, thread_number); - thread_alloc::hold_memory(true); - CppAD::parallel_ad(); - - // 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; - - // initialize two barriers, one for work done, one for new job ready - pthread_barrierattr_t* no_barrierattr = CPPAD_NULL; - rc = pthread_barrier_init( - &wait_for_work_, no_barrierattr, (unsigned int) num_threads - ); - ok &= (rc == 0); - rc = pthread_barrier_init( - &wait_for_job_, no_barrierattr, (unsigned int) num_threads - ); - ok &= (rc == 0); - - // structure used to create the threads - pthread_t pthread_id; - // default for pthread_attr_setdetachstate is PTHREAD_CREATE_JOINABLE - pthread_attr_t* no_attr= CPPAD_NULL; - - // initial job for the threads - thread_job_ = init_enum; - if( num_threads > 1 ) - sequential_execution_ = false; - - // 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) - ); - rc = pthread_create( - &pthread_id , - no_attr , - thread_work , - thread_num_vptr - ); - thread_all_[thread_num].pthread_id = pthread_id; - ok &= (rc == 0); - } - - // Current state is other threads are at wait_for_job_. - // This master thread (thread zero) has not completed wait_for_job_ - sequential_execution_ = true; - return ok; + if( num_threads > MAX_NUMBER_THREADS ) + { std::cerr << "team_create: num_threads greater than "; + std::cerr << MAX_NUMBER_THREADS << std::endl; + exit(1); + } + // check that we currently do not have multiple threads running + ok = num_threads_ == 1; + ok &= sequential_execution_; + + size_t thread_num; + for(thread_num = 0; thread_num < num_threads; thread_num++) + { // Each thread gets a pointer to its version of this thread_num + // so it knows which section of thread_all_ it is working with + thread_all_[thread_num].thread_num = thread_num; + + // initialize + thread_all_[thread_num].ok = true; + } + // Finish setup of thread_all_ for this thread + thread_all_[0].pthread_id = pthread_self(); + + // 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) + void* thread_num_vptr = static_cast(&(thread_all_[0].thread_num)); + rc = pthread_setspecific(thread_specific_key_, thread_num_vptr); + ok &= (rc == 0); + + // Now that thread_number() has necessary information for this thread + // (number zero), and while still in sequential mode, + // call setup for using CppAD::AD in parallel mode. + thread_alloc::parallel_setup(num_threads, in_parallel, thread_number); + thread_alloc::hold_memory(true); + CppAD::parallel_ad(); + + // 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; + + // initialize two barriers, one for work done, one for new job ready + pthread_barrierattr_t* no_barrierattr = CPPAD_NULL; + rc = pthread_barrier_init( + &wait_for_work_, no_barrierattr, (unsigned int) num_threads + ); + ok &= (rc == 0); + rc = pthread_barrier_init( + &wait_for_job_, no_barrierattr, (unsigned int) num_threads + ); + ok &= (rc == 0); + + // structure used to create the threads + pthread_t pthread_id; + // default for pthread_attr_setdetachstate is PTHREAD_CREATE_JOINABLE + pthread_attr_t* no_attr= CPPAD_NULL; + + // initial job for the threads + thread_job_ = init_enum; + if( num_threads > 1 ) + sequential_execution_ = false; + + // 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) + ); + rc = pthread_create( + &pthread_id , + no_attr , + thread_work , + thread_num_vptr + ); + thread_all_[thread_num].pthread_id = pthread_id; + ok &= (rc == 0); + } + + // Current state is other threads are at wait_for_job_. + // This master thread (thread zero) has not completed wait_for_job_ + sequential_execution_ = true; + return ok; } bool team_work(void worker(void)) -{ int rc; +{ int rc; - // Current state is other threads are at wait_for_job_. - // This master thread (thread zero) has not completed wait_for_job_ - bool ok = sequential_execution_; - ok &= thread_number() == 0; - - // set global version of this work routine - worker_ = worker; - - - // 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_ - if( num_threads_ > 1 ) - sequential_execution_ = false; - - // wait until all threads have completed wait_for_job_ - rc = pthread_barrier_wait(&wait_for_job_); - ok &= (rc == 0 || rc == PTHREAD_BARRIER_SERIAL_THREAD); - - // Now do the work in this thread and then wait - // until all threads have completed wait_for_work_ - worker(); - rc = pthread_barrier_wait(&wait_for_work_); - ok &= (rc == 0 || rc == PTHREAD_BARRIER_SERIAL_THREAD); - - // Current state is other threads are at wait_for_job_. - // This master thread (thread zero) has not completed wait_for_job_ - sequential_execution_ = true; - - size_t thread_num; - for(thread_num = 0; thread_num < num_threads_; thread_num++) - ok &= thread_all_[thread_num].ok; - return ok; + // Current state is other threads are at wait_for_job_. + // This master thread (thread zero) has not completed wait_for_job_ + bool ok = sequential_execution_; + ok &= thread_number() == 0; + + // set global version of this work routine + worker_ = worker; + + + // 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_ + if( num_threads_ > 1 ) + sequential_execution_ = false; + + // wait until all threads have completed wait_for_job_ + rc = pthread_barrier_wait(&wait_for_job_); + ok &= (rc == 0 || rc == PTHREAD_BARRIER_SERIAL_THREAD); + + // Now do the work in this thread and then wait + // until all threads have completed wait_for_work_ + worker(); + rc = pthread_barrier_wait(&wait_for_work_); + ok &= (rc == 0 || rc == PTHREAD_BARRIER_SERIAL_THREAD); + + // Current state is other threads are at wait_for_job_. + // This master thread (thread zero) has not completed wait_for_job_ + sequential_execution_ = true; + + size_t thread_num; + for(thread_num = 0; thread_num < num_threads_; thread_num++) + ok &= thread_all_[thread_num].ok; + return ok; } bool team_destroy(void) -{ int rc; +{ int rc; - // Current state is other threads are at wait_for_job_. - // This master thread (thread zero) has not completed wait_for_job_ - bool ok = sequential_execution_; - ok &= thread_number() == 0; - - // 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_ - 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 - size_t thread_num; - for(thread_num = 1; thread_num < num_threads_; thread_num++) - { void* no_status = CPPAD_NULL; - rc = pthread_join( - thread_all_[thread_num].pthread_id, &no_status - ); - ok &= (rc == 0); - } - - // now we are down to just the master thread (thread zero) - sequential_execution_ = true; - - // destroy the key for thread specific data - pthread_key_delete(thread_specific_key_); - - // destroy wait_for_work_ - rc = pthread_barrier_destroy(&wait_for_work_); - ok &= (rc == 0); - - // destroy wait_for_job_ - rc = pthread_barrier_destroy(&wait_for_job_); - ok &= (rc == 0); - - // check ok before changing num_threads_ - for(thread_num = 0; thread_num < num_threads_; thread_num++) - ok &= thread_all_[thread_num].ok; - - // now inform CppAD that there is only one thread - num_threads_ = 1; - thread_alloc::parallel_setup(num_threads_, CPPAD_NULL, CPPAD_NULL); - thread_alloc::hold_memory(false); - CppAD::parallel_ad(); + // Current state is other threads are at wait_for_job_. + // This master thread (thread zero) has not completed wait_for_job_ + bool ok = sequential_execution_; + ok &= thread_number() == 0; + + // 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_ + 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 + size_t thread_num; + for(thread_num = 1; thread_num < num_threads_; thread_num++) + { void* no_status = CPPAD_NULL; + rc = pthread_join( + thread_all_[thread_num].pthread_id, &no_status + ); + ok &= (rc == 0); + } + + // now we are down to just the master thread (thread zero) + sequential_execution_ = true; + + // destroy the key for thread specific data + pthread_key_delete(thread_specific_key_); + + // destroy wait_for_work_ + rc = pthread_barrier_destroy(&wait_for_work_); + ok &= (rc == 0); + + // destroy wait_for_job_ + rc = pthread_barrier_destroy(&wait_for_job_); + ok &= (rc == 0); + + // check ok before changing num_threads_ + for(thread_num = 0; thread_num < num_threads_; thread_num++) + ok &= thread_all_[thread_num].ok; + + // now inform CppAD that there is only one thread + num_threads_ = 1; + thread_alloc::parallel_setup(num_threads_, CPPAD_NULL, CPPAD_NULL); + thread_alloc::hold_memory(false); + CppAD::parallel_ad(); - return ok; + return ok; } const char* team_name(void) -{ return "pthread"; } +{ return "pthread"; } // END C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/team_example.cpp cppad-2019.02.00.0/example/multi_thread/team_example.cpp --- cppad-2018.00.00.0/example/multi_thread/team_example.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/team_example.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,22 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin team_example.cpp$$ $spell - CppAD + CppAD $$ $section Using a Team of AD Threads: Example and Test$$ -$mindex thread$$ $head Purpose$$ @@ -32,9 +32,7 @@ $tend $head Source Code$$ -$code $srcfile%example/multi_thread/team_example.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end ------------------------------------------------------------------------------ @@ -45,92 +43,92 @@ # define NUMBER_THREADS 4 namespace { - using CppAD::thread_alloc; + using CppAD::thread_alloc; - // structure with information for one thread - typedef struct { - // function argument (worker input) - double x; - // false if an error occurs, true otherwise (worker output) - bool ok; - } work_one_t; - // vector with information for all threads - // (use pointers instead of values to avoid false sharing) - work_one_t* work_all_[NUMBER_THREADS]; - // -------------------------------------------------------------------- - // function that does the work for one thread - void worker(void) - { using CppAD::NearEqual; - using CppAD::AD; - bool ok = true; - size_t thread_num = thread_alloc::thread_num(); - - // CppAD::vector uses the CppAD fast multi-threading allocator - CppAD::vector< AD > ax(1), ay(1); - ax[0] = work_all_[thread_num]->x; - Independent(ax); - ay[0] = sqrt( ax[0] * ax[0] ); - CppAD::ADFun f(ax, ay); - - // Check function value corresponds to the identity - double eps = 10. * CppAD::numeric_limits::epsilon(); - ok &= NearEqual(ay[0], ax[0], eps, eps); - - // Check derivative value corresponds to the identity. - CppAD::vector d_x(1), d_y(1); - d_x[0] = 1.; - d_y = f.Forward(1, d_x); - ok &= NearEqual(d_x[0], 1., eps, eps); - - // pass back ok information for this thread - work_all_[thread_num]->ok = ok; - } + // structure with information for one thread + typedef struct { + // function argument (worker input) + double x; + // false if an error occurs, true otherwise (worker output) + bool ok; + } work_one_t; + // vector with information for all threads + // (use pointers instead of values to avoid false sharing) + work_one_t* work_all_[NUMBER_THREADS]; + // -------------------------------------------------------------------- + // function that does the work for one thread + void worker(void) + { using CppAD::NearEqual; + using CppAD::AD; + bool ok = true; + size_t thread_num = thread_alloc::thread_num(); + + // CppAD::vector uses the CppAD fast multi-threading allocator + CppAD::vector< AD > ax(1), ay(1); + ax[0] = work_all_[thread_num]->x; + Independent(ax); + ay[0] = sqrt( ax[0] * ax[0] ); + CppAD::ADFun f(ax, ay); + + // Check function value corresponds to the identity + double eps = 10. * CppAD::numeric_limits::epsilon(); + ok &= NearEqual(ay[0], ax[0], eps, eps); + + // Check derivative value corresponds to the identity. + CppAD::vector d_x(1), d_y(1); + d_x[0] = 1.; + d_y = f.Forward(1, d_x); + ok &= NearEqual(d_x[0], 1., eps, eps); + + // pass back ok information for this thread + work_all_[thread_num]->ok = ok; + } } // This test routine is only called by the master thread (thread_num = 0). bool team_example(void) -{ bool ok = true; +{ bool ok = true; - size_t num_threads = NUMBER_THREADS; + size_t num_threads = NUMBER_THREADS; - // Check that no memory is in use or avialable at start - // (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; - } - - // initialize work_all_ - for(thread_num = 0; thread_num < num_threads; thread_num++) - { // allocate separate memory for this thread to avoid false sharing - size_t min_bytes(sizeof(work_one_t)), cap_bytes; - void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); - 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 - work_all_[thread_num]->x = double(thread_num) + 1.; - } - - ok &= team_create(num_threads); - ok &= team_work(worker); - ok &= team_destroy(); - - // go down so that free memrory for other threads before memory for master - thread_num = num_threads; - while(thread_num--) - { // check that this thread was ok with the work it did - ok &= work_all_[thread_num]->ok; - // 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 - // (for general applications, the master might still be using memory) - ok &= thread_alloc::inuse(thread_num) == 0; - // return all memory being held for future use by this thread - thread_alloc::free_available(thread_num); - } - return ok; + // Check that no memory is in use or avialable at start + // (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; + } + + // initialize work_all_ + for(thread_num = 0; thread_num < num_threads; thread_num++) + { // allocate separate memory for this thread to avoid false sharing + size_t min_bytes(sizeof(work_one_t)), cap_bytes; + void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); + 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 + work_all_[thread_num]->x = double(thread_num) + 1.; + } + + ok &= team_create(num_threads); + ok &= team_work(worker); + ok &= team_destroy(); + + // go down so that free memrory for other threads before memory for master + thread_num = num_threads; + while(thread_num--) + { // check that this thread was ok with the work it did + ok &= work_all_[thread_num]->ok; + // 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 + // (for general applications, the master might still be using memory) + ok &= thread_alloc::inuse(thread_num) == 0; + // return all memory being held for future use by this thread + thread_alloc::free_available(thread_num); + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/multi_thread/team_example.hpp cppad-2019.02.00.0/example/multi_thread/team_example.hpp --- cppad-2018.00.00.0/example/multi_thread/team_example.hpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/team_example.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,13 +3,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ extern bool team_example(void); diff -Nru cppad-2018.00.00.0/example/multi_thread/team_thread.hpp cppad-2019.02.00.0/example/multi_thread/team_thread.hpp --- cppad-2018.00.00.0/example/multi_thread/team_thread.hpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/team_thread.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,26 +3,27 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin team_thread.hpp$$ $spell - pthreads - const - cstddef - bool - pthread - initializes - hpp - num - CppAD - ta + pthreads + const + cstddef + bool + pthread + initializes + hpp + num + CppAD + ta $$ $section Specifications for A Team of AD Threads$$ @@ -76,14 +77,14 @@ This routine terminates all the other threads except for thread number zero; i.e., it terminates the threads corresponding to $codei% - %thread_num% = 1 , ... , %num_threads%-1 + %thread_num% = 1 , ... , %num_threads%-1 %$$ $head team_name$$ This routines returns a name that identifies this thread_team. The return value has prototype $codei% - const char* %name% + const char* %name% %$$ and is a statically allocated $code '\0'$$ terminated C string. @@ -94,9 +95,9 @@ Otherwise it is $code true$$. $children% - example/multi_thread/openmp/team_openmp.cpp% - example/multi_thread/bthread/team_bthread.cpp% - example/multi_thread/pthread/team_pthread.cpp + example/multi_thread/openmp/team_openmp.cpp% + example/multi_thread/bthread/team_bthread.cpp% + example/multi_thread/pthread/team_pthread.cpp %$$ $head Example Use$$ diff -Nru cppad-2018.00.00.0/example/multi_thread/test.sh cppad-2019.02.00.0/example/multi_thread/test.sh --- cppad-2018.00.00.0/example/multi_thread/test.sh 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/test.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,51 +1,54 @@ #! /bin/sh -e # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # script used by */makefile.am to run a default case for all the the tests # -------------------------------------------------------------------------- # setup next_program() { - i_program=`expr $i_program + 1` - if [ $i_program -ge $n_program ] - then - i_program='0' - fi - case $i_program in - 0) - program=`echo "$program_list" | sed -e 's| \([^ ]*\).*|\1|'` - ;; + i_program=`expr $i_program + 1` + if [ $i_program -ge $n_program ] + then + i_program='0' + fi + case $i_program in + 0) + program=`echo "$program_list" | sed -e 's| *\([^ ]*\).*|\1|'` + ;; - 1) - program=`echo "$program_list" | sed -e 's| [^ ]* \([^ ]*\).*|\1|'` - ;; + 1) + program=`echo "$program_list" | sed -e 's| *[^ ]* *\([^ ]*\).*|\1|'` + ;; - 2) - program=`echo "$program_list" | sed -e 's| [^ ]* [^ ]* ||'` - ;; - esac + 2) + program=`echo "$program_list" | sed -e 's| *[^ ]* [^ ]* *||'` + ;; + esac } -n_program='3' -program_list=' openmp_test pthread_test bthread_test' +n_program='0' +program_list='' for program in openmp_test pthread_test bthread_test do - if [ ! -e "$program" ] - then - program_list=`echo "$program_list" | sed -e "s| $program||"` - n_program=`expr $n_program - 1` - fi + if [ -e "$program" ] + then + program_list="$program $program_list" + n_program=`expr $n_program + 1` + fi done +echo "program_list = $program_list" +echo "n_program = $n_program" if [ "$n_program" = '0' ] then - echo "example/multi_thread/test.sh: nothing to test" - exit 0 + echo "example/multi_thread/test.sh: nothing to test" + exit 0 fi i_program='0' next_program @@ -65,13 +68,13 @@ # fast cases, do all programs for program in openmp_test pthread_test bthread_test do - if [ -e "$program" ] - then - ./$program a11c - echo - ./$program simple_ad - echo - ./$program team_example - echo - fi + if [ -e "$program" ] + then + ./$program a11c + echo + ./$program simple_ad + echo + ./$program team_example + echo + fi done diff -Nru cppad-2018.00.00.0/example/multi_thread/thread_test.cpp cppad-2019.02.00.0/example/multi_thread/thread_test.cpp --- cppad-2018.00.00.0/example/multi_thread/thread_test.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/multi_thread/thread_test.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,26 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin thread_test.cpp$$ -$escape $$ $spell - inv - mega - cpp - num - pthread - pthreads - openmp - bthread + inv + mega + cpp + num + pthread + pthreads + openmp + bthread $$ @@ -42,19 +42,19 @@ $head program$$ We use the notation $icode program$$ for $icode% - example_multi_thread_%threading% + example_multi_thread_%threading% %$$ $head Running Tests$$ You can build this program and run the default version of its test parameters by executing the following commands: $codei% - cd %build% - make check_%program% + cd %build% + make check_%program% %$$ After this operation, in the directory $codei% - %build%/example/multi_thread/%threading% + %build%/example/multi_thread/%threading% %$$ you can execute the following commands: $codei%. @@ -62,25 +62,27 @@ ./%program% simple_ad ./%program% team_example ./%program% harmonic %test_time% %max_threads% %mega_sum% +./%program% multi_atomic %test_time% %max_threads% %num_solve% ./%program% multi_newton %test_time% %max_threads% \ - %num_zero% %num_sub% %num_sum% %use_ad% + %num_zero% %num_sub% %num_sum% %use_ad% %$$ $children% - example/multi_thread/openmp/a11c_openmp.cpp% - example/multi_thread/bthread/a11c_bthread.cpp% - example/multi_thread/pthread/a11c_pthread.cpp% - - example/multi_thread/openmp/simple_ad_openmp.cpp% - example/multi_thread/bthread/simple_ad_bthread.cpp% - example/multi_thread/pthread/simple_ad_pthread.cpp% - - example/multi_thread/team_example.cpp% - example/multi_thread/harmonic.omh% - example/multi_thread/multi_atomic.omh% - example/multi_thread/multi_newton.omh% + example/multi_thread/openmp/a11c_openmp.cpp% + example/multi_thread/bthread/a11c_bthread.cpp% + example/multi_thread/pthread/a11c_pthread.cpp% + + example/multi_thread/openmp/simple_ad_openmp.cpp% + example/multi_thread/bthread/simple_ad_bthread.cpp% + example/multi_thread/pthread/simple_ad_pthread.cpp% + + example/multi_thread/team_example.cpp% + example/multi_thread/harmonic.omh% + example/multi_thread/multi_atomic.omh% + example/multi_thread/multi_checkpoint.omh% + example/multi_thread/multi_newton.omh% - example/multi_thread/team_thread.hpp + example/multi_thread/team_thread.hpp %$$ $head a11c$$ @@ -125,7 +127,7 @@ the maximum number of threads to use for the test. The specified test is run with the following number of threads: $codei% - %num_threads% = 0 , %...% , %max_threads% + %num_threads% = 0 , %...% , %max_threads% %$$ The value of zero corresponds to not using the multi-threading system. @@ -133,6 +135,33 @@ 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/harmonic_time/mega_sum/$$. +$comment ------------------------------------------------------------------- $$ + +$head multi_atomic$$ +The $cref multi_atomic_time$$ routine +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. +The reported time is the total wall clock time divided by the +number of repeats. + +$subhead max_threads$$ +If the argument $icode max_threads$$ is a non-negative integer specifying +the maximum number of threads to use for the test. +The specified test is run with the following number of threads: +$codei% + %num_threads% = 0 , %...% , %max_threads% +%$$ +The value of zero corresponds to not using the multi-threading system. + +$subhead num_solve$$ +The command line argument $icode num_solve$$ +is an integer specifying the number of solves; see +$cref/num_solve/multi_atomic_time/num_solve/$$ in $code multi_atomic_time$$. $comment ------------------------------------------------------------------- $$ @@ -153,7 +182,7 @@ the maximum number of threads to use for the test. The specified test is run with the following number of threads: $codei% - %num_threads% = 0 , %...% , %max_threads% + %num_threads% = 0 , %...% , %max_threads% %$$ The value of zero corresponds to not using the multi-threading system. @@ -189,9 +218,7 @@ $tend $head Source$$ -$code $srcfile%example/multi_thread/thread_test.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -205,216 +232,234 @@ # include "team_example.hpp" # include "harmonic.hpp" # include "multi_atomic.hpp" +# include "multi_checkpoint.hpp" # include "multi_newton.hpp" extern bool a11c(void); extern bool simple_ad(void); namespace { - size_t arg2size_t( - const char* arg , - int limit , - const char* error_msg ) - { int i = std::atoi(arg); - if( i >= limit ) - return size_t(i); - std::cerr << "value = " << i << std::endl; - std::cerr << error_msg << std::endl; - exit(1); - } - double arg2double( - const char* arg , - double limit , - const char* error_msg ) - { double d = std::atof(arg); - if( d >= limit ) - return d; - std::cerr << "value = " << d << std::endl; - std::cerr << error_msg << std::endl; - exit(1); - } + size_t arg2size_t( + const char* arg , + int limit , + const char* error_msg ) + { int i = std::atoi(arg); + if( i >= limit ) + return size_t(i); + std::cerr << "value = " << i << std::endl; + std::cerr << error_msg << std::endl; + exit(1); + } + double arg2double( + const char* arg , + double limit , + const char* error_msg ) + { double d = std::atof(arg); + if( d >= limit ) + return d; + std::cerr << "value = " << d << std::endl; + std::cerr << error_msg << std::endl; + exit(1); + } } int main(int argc, char *argv[]) -{ using CppAD::thread_alloc; - bool ok = true; - using std::cout; - using std::endl; - - // commnd line usage message - const char* usage = - "./_test a11c\n" - "./_test simple_ad\n" - "./_test team_example\n" - "./_test harmonic test_time max_threads mega_sum\n" - "./_test multi_atomic test_time max_threads num_solve\n" - "./_test multi_newton test_time max_threads \\\n" - " num_zero num_sub num_sum use_ad\\\n" - "where is bthread, openmp, or pthread"; - - // command line argument values (assign values to avoid compiler warnings) - size_t num_zero=0, num_sub=0, num_sum=0; - bool use_ad=true; - - // put the date and time in the output file - std::time_t rawtime; - std::time( &rawtime ); - 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++) - if( gmt[i] != '\n' ) cout << gmt[i]; - cout << "';" << endl; - - // CppAD version number - cout << "cppad_version = '" << CPPAD_PACKAGE_STRING << "';" << endl; - - // put the team name in the output file - cout << "team_name = '" << team_name() << "';" << endl; - - // print command line as valid matlab/octave - cout << "command = '" << argv[0]; - for(int i = 1; i < argc; i++) - cout << " " << argv[i]; - cout << "';" << endl; - - ok = false; - const char* test_name = ""; - if( argc > 1 ) - test_name = *++argv; - bool run_a11c = std::strcmp(test_name, "a11c") == 0; - bool run_simple_ad = std::strcmp(test_name, "simple_ad") == 0; - bool run_team_example = std::strcmp(test_name, "team_example") == 0; - bool run_harmonic = std::strcmp(test_name, "harmonic") == 0; - bool run_multi_atomic = std::strcmp(test_name, "multi_atomic") == 0; - bool run_multi_newton = std::strcmp(test_name, "multi_newton") == 0; - if( run_a11c || run_simple_ad || run_team_example ) - ok = (argc == 2); - else if( run_harmonic || run_multi_atomic ) - 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 << usage << endl; - exit(1); - } - if( run_a11c || run_simple_ad || run_team_example ) - { if( run_a11c ) - ok = a11c(); - else if( run_simple_ad ) - ok = simple_ad(); - else ok = team_example(); - if( thread_alloc::free_all() ) - cout << "free_all = true;" << endl; - else - { ok = false; - cout << "free_all = false;" << endl; - } - if( ok ) - cout << "OK = true;" << endl; - else cout << "OK = false;" << endl; - return ! ok; - } - - // 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, - "run: max_threads is less than zero" - ); - - size_t mega_sum = 0; // assignment to avoid compiler warning - size_t num_solve = 0; - if( run_harmonic ) - { // mega_sum - mega_sum = arg2size_t( *++argv, 1, - "run: mega_sum is less than one" - ); - } - else if( run_multi_atomic ) - { // num_solve - num_solve = arg2size_t( *++argv, 1, - "run: num_solve is less than one" - ); - } - else - { ok &= run_multi_newton; - - // num_zero - num_zero = arg2size_t( *++argv, 2, - "run: num_zero is less than two" - ); - - // num_sub - num_sub = arg2size_t( *++argv, 1, - "run: num_sub is less than one" - ); - - // num_sum - num_sum = arg2size_t( *++argv, 1, - "run: num_sum is less than one" - ); - - // use_ad - ++argv; - if( std::strcmp(*argv, "true") == 0 ) - use_ad = true; - else if( std::strcmp(*argv, "false") == 0 ) - use_ad = false; - else - { std::cerr << "run: use_ad = '" << *argv; - std::cerr << "' is not true or false" << endl; - exit(1); - } - } - - // run the test for each number of threads - cout << "time_all = [" << endl; - for(size_t num_threads = 0; num_threads <= max_threads; num_threads++) - { double time_out; - - // run the requested test - if( run_harmonic ) ok &= - harmonic_time(time_out, test_time, num_threads, mega_sum); - else if( run_multi_atomic ) ok &= - multi_atomic_time(time_out, test_time, num_threads, num_solve); - else - { ok &= run_multi_newton; - ok &= multi_newton_time( - time_out , - test_time , - num_threads , - num_zero , - num_sub , - num_sum , - use_ad - ); - } - // time_out - cout << "\t" << time_out << " % "; - // num_threads - if( num_threads == 0 ) - cout << "no threading" << endl; - else cout << num_threads << " threads" << endl; - } - cout << "];" << endl; - // - if( thread_alloc::free_all() ) - cout << "free_all = true;" << endl; - else - { ok = false; - cout << "free_all = false;" << endl; - } - if( ok ) - cout << "OK = true;" << endl; - else cout << "OK = false;" << endl; +{ using CppAD::thread_alloc; + bool ok = true; + using std::cout; + using std::endl; + + // commnd line usage message + const char* usage = + "./_test a11c\n" + "./_test simple_ad\n" + "./_test team_example\n" + "./_test harmonic test_time max_threads mega_sum\n" + "./_test multi_atomic test_time max_threads num_solve\n" + "./_test checkpoint test_time max_threads num_solve\n" + "./_test multi_newton test_time max_threads \\\n" + " num_zero num_sub num_sum use_ad\\\n" + "where is bthread, openmp, or pthread"; + + // command line argument values (assign values to avoid compiler warnings) + size_t num_zero=0, num_sub=0, num_sum=0; + bool use_ad=true; + + // put the date and time in the output file + std::time_t rawtime; + std::time( &rawtime ); + 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++) + if( gmt[i] != '\n' ) cout << gmt[i]; + cout << "';" << endl; + + // CppAD version number + cout << "cppad_version = '" << CPPAD_PACKAGE_STRING << "';" << endl; + + // put the team name in the output file + cout << "team_name = '" << team_name() << "';" << endl; + + // print command line as valid matlab/octave + cout << "command = '" << argv[0]; + for(int i = 1; i < argc; i++) + cout << " " << argv[i]; + cout << "';" << endl; + + ok = false; + const char* test_name = ""; + if( argc > 1 ) + test_name = *++argv; + bool run_a11c = std::strcmp(test_name, "a11c") == 0; + bool run_simple_ad = std::strcmp(test_name, "simple_ad") == 0; + bool run_team_example = std::strcmp(test_name, "team_example") == 0; + bool run_harmonic = std::strcmp(test_name, "harmonic") == 0; + bool run_multi_atomic = std::strcmp(test_name, "multi_atomic") == 0; + bool run_checkpoint = std::strcmp(test_name, "checkpoint") == 0; + bool run_multi_newton = std::strcmp(test_name, "multi_newton") == 0; + if( run_a11c || run_simple_ad || run_team_example ) + ok = (argc == 2); + else if( run_harmonic || run_multi_atomic || run_checkpoint ) + 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 << usage << endl; + exit(1); + } + if( run_a11c || run_simple_ad || run_team_example ) + { if( run_a11c ) + ok = a11c(); + else if( run_simple_ad ) + ok = simple_ad(); + else + ok = team_example(); + if( thread_alloc::free_all() ) + cout << "free_all = true;" << endl; + else + { ok = false; + cout << "free_all = false;" << endl; + } + if( ok ) + cout << "OK = true;" << endl; + else cout << "OK = false;" << endl; + return ! ok; + } + + // 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, + "run: max_threads is less than zero" + ); + + size_t mega_sum = 0; // assignment to avoid compiler warning + size_t num_solve = 0; + if( run_harmonic ) + { // mega_sum + mega_sum = arg2size_t( *++argv, 1, + "run: mega_sum is less than one" + ); + } + else if( run_multi_atomic || run_checkpoint ) + { // num_solve + num_solve = arg2size_t( *++argv, 1, + "run: num_solve is less than one" + ); + } + else + { ok &= run_multi_newton; + if( ! ok ) + { cout << "thread_test: program error\n"; + return ! ok; + } + + // num_zero + num_zero = arg2size_t( *++argv, 2, + "run: num_zero is less than two" + ); + + // num_sub + num_sub = arg2size_t( *++argv, 1, + "run: num_sub is less than one" + ); + + // num_sum + num_sum = arg2size_t( *++argv, 1, + "run: num_sum is less than one" + ); + + // use_ad + ++argv; + if( std::strcmp(*argv, "true") == 0 ) + use_ad = true; + else if( std::strcmp(*argv, "false") == 0 ) + use_ad = false; + else + { std::cerr << "run: use_ad = '" << *argv; + std::cerr << "' is not true or false" << endl; + exit(1); + } + } + + // run the test for each number of threads + cout << "time_all = [" << endl; + for(size_t num_threads = 0; num_threads <= max_threads; num_threads++) + { double time_out; + bool this_ok; + + // run the requested test + if( run_harmonic ) this_ok = + harmonic_time(time_out, test_time, num_threads, mega_sum); + else if( run_multi_atomic ) this_ok = + multi_atomic_time(time_out, test_time, num_threads, num_solve); + else if( run_checkpoint ) this_ok = + multi_checkpoint_time(time_out, test_time, num_threads, num_solve); + else + { this_ok = run_multi_newton; + this_ok &= multi_newton_time( + time_out , + test_time , + num_threads , + num_zero , + num_sub , + num_sum , + use_ad + ); + } + // time_out + cout << std::setw(20) << time_out << " % "; + // num_threads + if( num_threads == 0 ) + cout << "no threading"; + else + cout << num_threads << " threads"; + if( this_ok ) + cout << " ok" << endl; + else + cout << " error" << endl; + // + ok &= this_ok; + } + cout << "];" << endl; + // + if( thread_alloc::free_all() ) + cout << "free_all = true;" << endl; + else + { ok = false; + cout << "free_all = false;" << endl; + } + if( ok ) + cout << "OK = true;" << endl; + else cout << "OK = false;" << endl; - return ! ok; + return ! ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/optimize/CMakeLists.txt cppad-2019.02.00.0/example/optimize/CMakeLists.txt --- cppad-2018.00.00.0/example/optimize/CMakeLists.txt 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/optimize/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,26 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the example/optimize directory tests # # SET(source_list - conditional_skip.cpp - compare_op.cpp - cumulative_sum.cpp - forward_active.cpp - nest_conditional.cpp - print_for.cpp - optimize.cpp - reverse_active.cpp + conditional_skip.cpp + compare_op.cpp + cumulative_sum.cpp + forward_active.cpp + nest_conditional.cpp + print_for.cpp + optimize.cpp + reverse_active.cpp ) set_compile_flags( example_optimize "${cppad_debug_which}" "${source_list}" ) # @@ -27,8 +28,8 @@ # Add the check_example_optimize target ADD_CUSTOM_TARGET(check_example_optimize - example_optimize - DEPENDS example_optimize + example_optimize + DEPENDS example_optimize ) MESSAGE(STATUS "make check_example_optimize: available") diff -Nru cppad-2018.00.00.0/example/optimize/compare_op.cpp cppad-2019.02.00.0/example/optimize/compare_op.cpp --- cppad-2018.00.00.0/example/optimize/compare_op.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/optimize/compare_op.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,14 +1,14 @@ -// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin optimize_compare_op.cpp$$ @@ -17,123 +17,121 @@ $head See Also$$ $cref cond_exp.cpp$$ -$code $srcfile%example/optimize/compare_op.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include namespace { - struct tape_size { size_t n_var; size_t n_op; }; + struct tape_size { size_t n_var; size_t n_op; }; - template void fun( - const std::string& options , - const Vector& x, Vector& y, tape_size& before, tape_size& after - ) - { typedef typename Vector::value_type scalar; - - // phantom variable with index 0 and independent variables - // begin operator, independent variable operators and end operator - before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); - after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); - - // Create a variable that is is only used in the comparision operation - // It is not used when the comparison operator is not included - scalar one = 1. / x[0]; - before.n_var += 1; before.n_op += 1; - after.n_var += 0; after.n_op += 0; - // If we keep comparision operators, we must compute their operands - if( options.find("no_compare_op") == std::string::npos ) - { after.n_var += 1; after.n_op += 1; - } - - // Create a variable that is used by the result - scalar two = x[0] * 5.; - before.n_var += 1; before.n_op += 1; - after.n_var += 1; after.n_op += 1; - - // Only one variable created for this comparison operation - // but the value depends on which branch is taken. - scalar three; - if( one < x[0] ) // comparison operator - three = two / 2.0; // division operator - else - three = 2.0 * two; // multiplication operator - // comparison and either division of multiplication operator - before.n_var += 1; before.n_op += 2; - // comparison operator depends on optimization options - after.n_var += 1; after.n_op += 1; - // check if we are keeping the comparison operator - if( options.find("no_compare_op") == std::string::npos ) - after.n_op += 1; - - // results for this operation sequence - y[0] = three; - before.n_var += 0; before.n_op += 0; - after.n_var += 0; after.n_op += 0; - } + template void fun( + const std::string& options , + const Vector& x, Vector& y, tape_size& before, tape_size& after + ) + { typedef typename Vector::value_type scalar; + + // phantom variable with index 0 and independent variables + // begin operator, independent variable operators and end operator + before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); + after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); + + // Create a variable that is is only used in the comparision operation + // It is not used when the comparison operator is not included + scalar one = 1. / x[0]; + before.n_var += 1; before.n_op += 1; + after.n_var += 0; after.n_op += 0; + // If we keep comparision operators, we must compute their operands + if( options.find("no_compare_op") == std::string::npos ) + { after.n_var += 1; after.n_op += 1; + } + + // Create a variable that is used by the result + scalar two = x[0] * 5.; + before.n_var += 1; before.n_op += 1; + after.n_var += 1; after.n_op += 1; + + // Only one variable created for this comparison operation + // but the value depends on which branch is taken. + scalar three; + if( one < x[0] ) // comparison operator + three = two / 2.0; // division operator + else + three = 2.0 * two; // multiplication operator + // comparison and either division of multiplication operator + before.n_var += 1; before.n_op += 2; + // comparison operator depends on optimization options + after.n_var += 1; after.n_op += 1; + // check if we are keeping the comparison operator + if( options.find("no_compare_op") == std::string::npos ) + after.n_op += 1; + + // results for this operation sequence + y[0] = three; + before.n_var += 0; before.n_op += 0; + after.n_var += 0; after.n_op += 0; + } } bool compare_op(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) ay(m); - - for(size_t k = 0; k < 2; k++) - { // optimization options - std::string options = ""; - if( k == 0 ) - options = "no_compare_op"; - - // declare independent variables and start tape recording - CppAD::Independent(ax); - - // compute function value - tape_size before, after; - fun(options, ax, ay, before, after); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - ok &= f.size_var() == before.n_var; - ok &= f.size_op() == before.n_op; - - // Optimize the operation sequence - f.optimize(options); - ok &= f.size_var() == after.n_var; - ok &= f.size_op() == after.n_op; - - // 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); - if ( options == "" ) - ok &= f.compare_change_number() == 0; - fun(options, x, check, before, after); - ok &= NearEqual(y[0], check[0], eps10, eps10); - - // Check case where result of the comparision is differnent - // (hence one needs to re-tape to get correct result) - x[0] = 2.0; - y = f.Forward(0, x); - if ( options == "" ) - ok &= f.compare_change_number() == 1; - fun(options, x, check, before, after); - ok &= std::fabs(y[0] - check[0]) > 0.5; - } - return ok; +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.5; + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + + for(size_t k = 0; k < 2; k++) + { // optimization options + std::string options = ""; + if( k == 0 ) + options = "no_compare_op"; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // compute function value + tape_size before, after; + fun(options, ax, ay, before, after); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + ok &= f.size_var() == before.n_var; + ok &= f.size_op() == before.n_op; + + // Optimize the operation sequence + f.optimize(options); + ok &= f.size_var() == after.n_var; + ok &= f.size_op() == after.n_op; + + // 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); + if ( options == "" ) + ok &= f.compare_change_number() == 0; + fun(options, x, check, before, after); + ok &= NearEqual(y[0], check[0], eps10, eps10); + + // Check case where result of the comparision is differnent + // (hence one needs to re-tape to get correct result) + x[0] = 2.0; + y = f.Forward(0, x); + if ( options == "" ) + ok &= f.compare_change_number() == 1; + fun(options, x, check, before, after); + ok &= std::fabs(y[0] - check[0]) > 0.5; + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/optimize/conditional_skip.cpp cppad-2019.02.00.0/example/optimize/conditional_skip.cpp --- cppad-2018.00.00.0/example/optimize/conditional_skip.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/optimize/conditional_skip.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,14 +1,14 @@ -// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin optimize_conditional_skip.cpp$$ @@ -17,132 +17,130 @@ $head See Also$$ $cref cond_exp.cpp$$ -$code $srcfile%example/optimize/conditional_skip.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include namespace { - struct tape_size { size_t n_var; size_t n_op; }; + struct tape_size { size_t n_var; size_t n_op; }; - template void fun( - const std::string& options , - const Vector& x, Vector& y, tape_size& before, tape_size& after - ) - { typedef typename Vector::value_type scalar; - - - // phantom variable with index 0 and independent variables - // begin operator, independent variable operators and end operator - before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); - after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); - - // Create a variable that is is only used as left operand - // in the comparision operation - scalar left = 1. / x[0]; - before.n_var += 1; before.n_op += 1; - after.n_var += 1; after.n_op += 1; - - // right operand in comparison operation - scalar right = x[0]; - before.n_var += 0; before.n_op += 0; - after.n_var += 0; after.n_op += 0; - - // Note that the left and right operand in the CondExpLt comparison - // are determined at this point. Hence the conditional skip operator - // will be inserted here so that the operations mentioned below can - // also be skipped during zero order foward mode. - if( options.find("no_conditional_skip") == std::string::npos ) - after.n_op += 1; // for conditional skip operation - - // Create a variable that is only used when comparison result is true - // (can be skipped when the comparison result is false) - scalar if_true = x[0] * 5.0; - before.n_var += 1; before.n_op += 1; - after.n_var += 1; after.n_op += 1; - - // Create two variables only used when the comparison result is false - // (can be skipped when the comparison result is true) - scalar temp = 5.0 + x[0]; - scalar if_false = temp * 3.0; - before.n_var += 2; before.n_op += 2; - after.n_var += 2; after.n_op += 2; - - // conditional comparision is 1 / x[0] < x[0] - scalar value = CppAD::CondExpLt(left, right, if_true, if_false); - before.n_var += 1; before.n_op += 1; - after.n_var += 1; after.n_op += 1; - - // results for this operation sequence - y[0] = value; - before.n_var += 0; before.n_op += 0; - after.n_var += 0; after.n_op += 0; - } + template void fun( + const std::string& options , + const Vector& x, Vector& y, tape_size& before, tape_size& after + ) + { typedef typename Vector::value_type scalar; + + + // phantom variable with index 0 and independent variables + // begin operator, independent variable operators and end operator + before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); + after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); + + // Create a variable that is is only used as left operand + // in the comparision operation + scalar left = 1. / x[0]; + before.n_var += 1; before.n_op += 1; + after.n_var += 1; after.n_op += 1; + + // right operand in comparison operation + scalar right = x[0]; + before.n_var += 0; before.n_op += 0; + after.n_var += 0; after.n_op += 0; + + // Note that the left and right operand in the CondExpLt comparison + // are determined at this point. Hence the conditional skip operator + // will be inserted here so that the operations mentioned below can + // also be skipped during zero order foward mode. + if( options.find("no_conditional_skip") == std::string::npos ) + after.n_op += 1; // for conditional skip operation + + // Create a variable that is only used when comparison result is true + // (can be skipped when the comparison result is false) + scalar if_true = x[0] * 5.0; + before.n_var += 1; before.n_op += 1; + after.n_var += 1; after.n_op += 1; + + // Create two variables only used when the comparison result is false + // (can be skipped when the comparison result is true) + scalar temp = 5.0 + x[0]; + scalar if_false = temp * 3.0; + before.n_var += 2; before.n_op += 2; + after.n_var += 2; after.n_op += 2; + + // conditional comparision is 1 / x[0] < x[0] + scalar value = CppAD::CondExpLt(left, right, if_true, if_false); + before.n_var += 1; before.n_op += 1; + after.n_var += 1; after.n_op += 1; + + // results for this operation sequence + y[0] = value; + before.n_var += 0; before.n_op += 0; + after.n_var += 0; after.n_op += 0; + } } bool conditional_skip(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) ay(m); - - for(size_t k = 0; k < 2; k++) - { // optimization options - std::string options = ""; - if( k == 0 ) - options = "no_conditional_skip"; - - // declare independent variables and start tape recording - CppAD::Independent(ax); - - // compute function computation - tape_size before, after; - fun(options, ax, ay, before, after); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - ok &= f.size_var() == before.n_var; - ok &= f.size_op() == before.n_op; - - // Optimize the operation sequence - f.optimize(options); - ok &= f.size_var() == after.n_var; - ok &= f.size_op() == after.n_op; - - // Check case where result of the comparison is true (x[0] > 1.0). - CPPAD_TESTVECTOR(double) x(n), y(m), check(m); - x[0] = 1.75; - y = f.Forward(0, x); - fun(options, x, check, before, after); - ok &= NearEqual(y[0], check[0], eps10, eps10); - if( options == "" ) - ok &= f.number_skip() == 2; - else - ok &= f.number_skip() == 0; - - // Check case where result of the comparision is false (x[0] <= 1.0) - x[0] = 0.5; - y = f.Forward(0, x); - fun(options, x, check, before, after); - ok &= NearEqual(y[0], check[0], eps10, eps10); - if( options == "" ) - ok &= f.number_skip() == 1; - else - ok &= f.number_skip() == 0; - } - return ok; +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.5; + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + + for(size_t k = 0; k < 2; k++) + { // optimization options + std::string options = ""; + if( k == 0 ) + options = "no_conditional_skip"; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // compute function computation + tape_size before, after; + fun(options, ax, ay, before, after); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + ok &= f.size_var() == before.n_var; + ok &= f.size_op() == before.n_op; + + // Optimize the operation sequence + f.optimize(options); + ok &= f.size_var() == after.n_var; + ok &= f.size_op() == after.n_op; + + // Check case where result of the comparison is true (x[0] > 1.0). + CPPAD_TESTVECTOR(double) x(n), y(m), check(m); + x[0] = 1.75; + y = f.Forward(0, x); + fun(options, x, check, before, after); + ok &= NearEqual(y[0], check[0], eps10, eps10); + if( options == "" ) + ok &= f.number_skip() == 2; + else + ok &= f.number_skip() == 0; + + // Check case where result of the comparision is false (x[0] <= 1.0) + x[0] = 0.5; + y = f.Forward(0, x); + fun(options, x, check, before, after); + ok &= NearEqual(y[0], check[0], eps10, eps10); + if( options == "" ) + ok &= f.number_skip() == 1; + else + ok &= f.number_skip() == 0; + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/optimize/cumulative_sum.cpp cppad-2019.02.00.0/example/optimize/cumulative_sum.cpp --- cppad-2018.00.00.0/example/optimize/cumulative_sum.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/optimize/cumulative_sum.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,21 @@ -// $Id$ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin optimize_cumulative_sum.cpp$$ $section Example Optimization and Cumulative Sum Operations$$ -$code $srcfile%example/optimize/cumulative_sum.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -25,83 +23,83 @@ # include namespace { - struct tape_size { size_t n_var; size_t n_op; }; + struct tape_size { size_t n_var; size_t n_op; }; - template void fun( - const Vector& x, Vector& y, tape_size& before, tape_size& after - ) - { typedef typename Vector::value_type scalar; - - // phantom variable with index 0 and independent variables - // begin operator, independent variable operators and end operator - before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); - after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); - - // operators that are identical, and that will be made part of the - // cummulative summation. Make sure do not replace second variable - // using the first and then remove the first as part of the - // cumulative summation. - scalar first = x[0] + x[1]; - scalar second = x[0] + x[1]; - before.n_var += 2; before.n_op += 2; - after.n_var += 0; after.n_op += 0; - - // test that subtractions are also included in cumulative summations - scalar third = x[1] - 2.0; - before.n_var += 1; before.n_op += 1; - after.n_var += 0; after.n_op += 0; - - // the finial summation is converted to a cumulative summation - // the other is removed. - scalar csum = first + second + third; - before.n_var += 2; before.n_op += 2; - after.n_var += 1; after.n_op += 1; - - // results for this operation sequence - y[0] = csum; - before.n_var += 0; before.n_op += 0; - after.n_var += 0; after.n_op += 0; - } + template void fun( + const Vector& x, Vector& y, tape_size& before, tape_size& after + ) + { typedef typename Vector::value_type scalar; + + // phantom variable with index 0 and independent variables + // begin operator, independent variable operators and end operator + before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); + after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); + + // operators that are identical, and that will be made part of the + // cumulative summation. Make sure do not replace second variable + // using the first and then remove the first as part of the + // cumulative summation. + scalar first = x[0] + x[1]; + scalar second = x[0] + x[1]; + before.n_var += 2; before.n_op += 2; + after.n_var += 0; after.n_op += 0; + + // test that subtractions are also included in cumulative summations + scalar third = x[1] - 2.0; + before.n_var += 1; before.n_op += 1; + after.n_var += 0; after.n_op += 0; + + // the finial summation is converted to a cumulative summation + // the other is removed. + scalar csum = first + second + third; + before.n_var += 2; before.n_op += 2; + after.n_var += 1; after.n_op += 1; + + // results for this operation sequence + y[0] = csum; + before.n_var += 0; before.n_op += 0; + after.n_var += 0; after.n_op += 0; + } } bool cumulative_sum(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - ax[1] = 1.5; - - // declare independent variables and start tape recording - CppAD::Independent(ax); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) ay(m); - tape_size before, after; - fun(ax, ay, before, after); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - ok &= f.size_var() == before.n_var; - ok &= f.size_op() == before.n_op; - - // Optimize the operation sequence - f.optimize(); - ok &= f.size_var() == after.n_var; - ok &= f.size_op() == after.n_op; - - // Check result for a zero order calculation for a different x, - CPPAD_TESTVECTOR(double) x(n), y(m), check(m); - x[0] = 0.75; - x[1] = 2.25; - y = f.Forward(0, x); - fun(x, check, before, after); - ok &= CppAD::NearEqual(y[0], check[0], eps10, eps10); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.5; + ax[1] = 1.5; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + tape_size before, after; + fun(ax, ay, before, after); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + ok &= f.size_var() == before.n_var; + ok &= f.size_op() == before.n_op; + + // Optimize the operation sequence + f.optimize(); + ok &= f.size_var() == after.n_var; + ok &= f.size_op() == after.n_op; + + // Check result for a zero order calculation for a different x, + CPPAD_TESTVECTOR(double) x(n), y(m), check(m); + x[0] = 0.75; + x[1] = 2.25; + y = f.Forward(0, x); + fun(x, check, before, after); + ok &= CppAD::NearEqual(y[0], check[0], eps10, eps10); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/optimize/forward_active.cpp cppad-2019.02.00.0/example/optimize/forward_active.cpp --- cppad-2018.00.00.0/example/optimize/forward_active.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/optimize/forward_active.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,136 +1,134 @@ -// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin optimize_forward_active.cpp$$ $section Example Optimization and Forward Activity Analysis$$ -$code $srcfile%example/optimize/forward_active.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include namespace { - struct tape_size { size_t n_var; size_t n_op; }; + struct tape_size { size_t n_var; size_t n_op; }; - template void fun( - const Vector& x, Vector& y, tape_size& before, tape_size& after - ) - { typedef typename Vector::value_type scalar; - - // phantom variable with index 0 and independent variables - // begin operator, independent variable operators and end operator - before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); - after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); - - // adding the constant zero does not take any operations - scalar zero = 0.0 + x[0]; - before.n_var += 0; before.n_op += 0; - after.n_var += 0; after.n_op += 0; - - // multiplication by the constant one does not take any operations - scalar one = 1.0 * x[1]; - before.n_var += 0; before.n_op += 0; - after.n_var += 0; after.n_op += 0; - - // multiplication by the constant zero does not take any operations - // and results in the constant zero. - scalar two = 0.0 * x[0]; - - // operations that only involve constants do not take any operations - scalar three = (1.0 + two) * 3.0; - before.n_var += 0; before.n_op += 0; - after.n_var += 0; after.n_op += 0; - - // The optimizer will reconize that zero + one = one + zero - // for all values of x. - scalar four = zero + one; - scalar five = one + zero; - before.n_var += 2; before.n_op += 2; - after.n_var += 1; after.n_op += 1; - - // The optimizer will reconize that sin(x[3]) = sin(x[3]) - // for all values of x. Note that, for computation of derivatives, - // sin(x[3]) and cos(x[3]) are stored on the tape as a pair. - scalar six = sin(x[2]); - scalar seven = sin(x[2]); - before.n_var += 4; before.n_op += 2; - after.n_var += 2; after.n_op += 1; - - // If we used addition here, five + seven = zero + one + seven - // which would get converted to a cumulative summation operator. - scalar eight = five * seven; - before.n_var += 1; before.n_op += 1; - after.n_var += 1; after.n_op += 1; - - // Use two, three, four and six in order to avoid a compiler warning - // Note that addition of two and three does not take any operations. - // Also note that optimizer reconizes four * six == five * seven. - scalar nine = eight + four * six * (two + three); - before.n_var += 3; before.n_op += 3; - after.n_var += 2; after.n_op += 2; - - // results for this operation sequence - y[0] = nine; - before.n_var += 0; before.n_op += 0; - after.n_var += 0; after.n_op += 0; - } + template void fun( + const Vector& x, Vector& y, tape_size& before, tape_size& after + ) + { typedef typename Vector::value_type scalar; + + // phantom variable with index 0 and independent variables + // begin operator, independent variable operators and end operator + before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); + after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); + + // adding the constant zero does not take any operations + scalar zero = 0.0 + x[0]; + before.n_var += 0; before.n_op += 0; + after.n_var += 0; after.n_op += 0; + + // multiplication by the constant one does not take any operations + scalar one = 1.0 * x[1]; + before.n_var += 0; before.n_op += 0; + after.n_var += 0; after.n_op += 0; + + // multiplication by the constant zero does not take any operations + // and results in the constant zero. + scalar two = 0.0 * x[0]; + + // operations that only involve constants do not take any operations + scalar three = (1.0 + two) * 3.0; + before.n_var += 0; before.n_op += 0; + after.n_var += 0; after.n_op += 0; + + // The optimizer will reconize that zero + one = one + zero + // for all values of x. + scalar four = zero + one; + scalar five = one + zero; + before.n_var += 2; before.n_op += 2; + after.n_var += 1; after.n_op += 1; + + // The optimizer will reconize that sin(x[3]) = sin(x[3]) + // for all values of x. Note that, for computation of derivatives, + // sin(x[3]) and cos(x[3]) are stored on the tape as a pair. + scalar six = sin(x[2]); + scalar seven = sin(x[2]); + before.n_var += 4; before.n_op += 2; + after.n_var += 2; after.n_op += 1; + + // If we used addition here, five + seven = zero + one + seven + // which would get converted to a cumulative summation operator. + scalar eight = five * seven; + before.n_var += 1; before.n_op += 1; + after.n_var += 1; after.n_op += 1; + + // Use two, three, four and six in order to avoid a compiler warning + // Note that addition of two and three does not take any operations. + // Also note that optimizer reconizes four * six == five * seven. + scalar nine = eight + four * six * (two + three); + before.n_var += 3; before.n_op += 3; + after.n_var += 2; after.n_op += 2; + + // results for this operation sequence + y[0] = nine; + before.n_var += 0; before.n_op += 0; + after.n_var += 0; after.n_op += 0; + } } bool forward_active(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - ax[1] = 1.5; - ax[2] = 2.0; - - // declare independent variables and start tape recording - CppAD::Independent(ax); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) ay(m); - tape_size before, after; - fun(ax, ay, before, after); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - ok &= f.size_var() == before.n_var; - ok &= f.size_op() == before.n_op; - - // Optimize the operation sequence - // Note that, for this case, all the optimization was done during - // the recording and there is no benifit to the optimization. - f.optimize(); - ok &= f.size_var() == after.n_var; - ok &= f.size_op() == after.n_op; - - // check zero order forward with different argument value - CPPAD_TESTVECTOR(double) x(n), y(m), check(m); - for(size_t i = 0; i < n; i++) - x[i] = double(i + 2); - y = f.Forward(0, x); - fun(x, check, before, after); - ok &= NearEqual(y[0], check[0], eps10, eps10); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.5; + ax[1] = 1.5; + ax[2] = 2.0; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + tape_size before, after; + fun(ax, ay, before, after); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + ok &= f.size_var() == before.n_var; + ok &= f.size_op() == before.n_op; + + // Optimize the operation sequence + // Note that, for this case, all the optimization was done during + // the recording and there is no benifit to the optimization. + f.optimize(); + ok &= f.size_var() == after.n_var; + ok &= f.size_op() == after.n_op; + + // check zero order forward with different argument value + CPPAD_TESTVECTOR(double) x(n), y(m), check(m); + for(size_t i = 0; i < n; i++) + x[i] = double(i + 2); + y = f.Forward(0, x); + fun(x, check, before, after); + ok &= NearEqual(y[0], check[0], eps10, eps10); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/optimize/makefile.am cppad-2019.02.00.0/example/optimize/makefile.am --- cppad-2018.00.00.0/example/optimize/makefile.am 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/optimize/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,13 @@ -# $Id$ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -16,13 +16,13 @@ # check_PROGRAMS = optimize # -AM_CXXFLAGS = -g $(CXX_FLAGS) -# -AM_CPPFLAGS = -I. \ - -I$(top_srcdir) \ +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) # +# optimize_SOURCES = \ compare_op.cpp \ conditional_skip.cpp \ diff -Nru cppad-2018.00.00.0/example/optimize/makefile.in cppad-2019.02.00.0/example/optimize/makefile.in --- cppad-2018.00.00.0/example/optimize/makefile.in 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/optimize/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -185,20 +185,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id$ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -271,10 +269,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -293,9 +289,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -318,8 +316,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -340,14 +336,14 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # -AM_CXXFLAGS = -g $(CXX_FLAGS) -# -AM_CPPFLAGS = -I. \ - -I$(top_srcdir) \ +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) # +# optimize_SOURCES = \ compare_op.cpp \ conditional_skip.cpp \ diff -Nru cppad-2018.00.00.0/example/optimize/nest_conditional.cpp cppad-2019.02.00.0/example/optimize/nest_conditional.cpp --- cppad-2018.00.00.0/example/optimize/nest_conditional.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/optimize/nest_conditional.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,14 +1,14 @@ -// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin optimize_nest_conditional.cpp$$ @@ -17,164 +17,162 @@ $head See Also$$ $cref cond_exp.cpp$$ -$code $srcfile%example/optimize/nest_conditional.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include namespace { - struct tape_size { size_t n_var; size_t n_op; }; + struct tape_size { size_t n_var; size_t n_op; }; - template void fun( - const std::string& options , - const Vector& x, Vector& y, tape_size& before, tape_size& after - ) - { typedef typename Vector::value_type scalar; - - // phantom variable with index 0 and independent variables - // begin operator, independent variable operators and end operator - before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); - after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); - - // Create a variable that is is only used in the second comparision - scalar two = 1. + x[0]; - before.n_var += 1; before.n_op += 1; - after.n_var += 1; after.n_op += 1; - - // Conditional skip for second comparison will be inserted here. - if( options.find("no_conditional_skip") == std::string::npos ) - after.n_op += 1; // for conditional skip operation - - // Create a variable that is is only used in the first comparision - // (can be skipped when second comparison result is false) - scalar one = 1. / x[0]; - before.n_var += 1; before.n_op += 1; - after.n_var += 1; after.n_op += 1; - - // Conditional skip for first comparison will be inserted here. - if( options.find("no_conditional_skip") == std::string::npos ) - after.n_op += 1; // for conditional skip operation - - // value when first comparison if false - scalar one_false = 5.0; - - // Create a variable that is only used when second comparison is true - // (can be skipped when it is false) - scalar one_true = x[0] / 5.0; - before.n_var += 1; before.n_op += 1; - after.n_var += 1; after.n_op += 1; - - // value when second comparison is false - scalar two_false = 3.0; - - // First conditional compaison is 1 / x[0] < x[0] - // is only used when second conditional expression is true - // (can be skipped when it is false) - scalar two_true = CppAD::CondExpLt(one, x[0], one_true, one_false); - before.n_var += 1; before.n_op += 1; - after.n_var += 1; after.n_op += 1; - - // Second conditional compaison is 1 + x[0] < x[1] - scalar two_value = CppAD::CondExpLt(two, x[1], two_true, two_false); - before.n_var += 1; before.n_op += 1; - after.n_var += 1; after.n_op += 1; - - // results for this operation sequence - y[0] = two_value; - before.n_var += 0; before.n_op += 0; - after.n_var += 0; after.n_op += 0; - } + template void fun( + const std::string& options , + const Vector& x, Vector& y, tape_size& before, tape_size& after + ) + { typedef typename Vector::value_type scalar; + + // phantom variable with index 0 and independent variables + // begin operator, independent variable operators and end operator + before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); + after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); + + // Create a variable that is is only used in the second comparision + scalar two = 1. + x[0]; + before.n_var += 1; before.n_op += 1; + after.n_var += 1; after.n_op += 1; + + // Conditional skip for second comparison will be inserted here. + if( options.find("no_conditional_skip") == std::string::npos ) + after.n_op += 1; // for conditional skip operation + + // Create a variable that is is only used in the first comparision + // (can be skipped when second comparison result is false) + scalar one = 1. / x[0]; + before.n_var += 1; before.n_op += 1; + after.n_var += 1; after.n_op += 1; + + // Conditional skip for first comparison will be inserted here. + if( options.find("no_conditional_skip") == std::string::npos ) + after.n_op += 1; // for conditional skip operation + + // value when first comparison if false + scalar one_false = 5.0; + + // Create a variable that is only used when second comparison is true + // (can be skipped when it is false) + scalar one_true = x[0] / 5.0; + before.n_var += 1; before.n_op += 1; + after.n_var += 1; after.n_op += 1; + + // value when second comparison is false + scalar two_false = 3.0; + + // First conditional compaison is 1 / x[0] < x[0] + // is only used when second conditional expression is true + // (can be skipped when it is false) + scalar two_true = CppAD::CondExpLt(one, x[0], one_true, one_false); + before.n_var += 1; before.n_op += 1; + after.n_var += 1; after.n_op += 1; + + // Second conditional compaison is 1 + x[0] < x[1] + scalar two_value = CppAD::CondExpLt(two, x[1], two_true, two_false); + before.n_var += 1; before.n_op += 1; + after.n_var += 1; after.n_op += 1; + + // results for this operation sequence + y[0] = two_value; + before.n_var += 0; before.n_op += 0; + after.n_var += 0; after.n_op += 0; + } } bool nest_conditional(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.5; - ax[1] = 0.5; - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) ay(m); - - for(size_t k = 0; k < 2; k++) - { // optimization options - std::string options = ""; - if( k == 0 ) - options = "no_conditional_skip"; - - // declare independent variables and start tape recording - CppAD::Independent(ax); - - // compute function computation - tape_size before, after; - fun(options, ax, ay, before, after); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - ok &= f.size_var() == before.n_var; - ok &= f.size_op() == before.n_op; - - // Optimize the operation sequence - f.optimize(options); - ok &= f.size_var() == after.n_var; - ok &= f.size_op() == after.n_op; - - // Check case where result of the second comparison is true - // and first comparison is true - CPPAD_TESTVECTOR(double) x(n), y(m), check(m); - x[0] = 1.75; - x[1] = 4.0; - y = f.Forward(0, x); - fun(options, x, check, before, after); - ok &= NearEqual(y[0], check[0], eps10, eps10); - ok &= f.number_skip() == 0; - - // Check case where result of the second comparison is true - // and first comparison is false - x[0] = 0.5; - x[1] = 4.0; - y = f.Forward(0, x); - fun(options, x, check, before, after); - ok &= NearEqual(y[0], check[0], eps10, eps10); - if( options == "" ) - ok &= f.number_skip() == 1; - else - ok &= f.number_skip() == 0; - - // Check case where result of the second comparison is false - // and first comparison is true - x[0] = 1.75; - x[1] = 0.0; - y = f.Forward(0, x); - fun(options, x, check, before, after); - ok &= NearEqual(y[0], check[0], eps10, eps10); - if( options == "" ) - ok &= f.number_skip() == 3; - else - ok &= f.number_skip() == 0; - - // Check case where result of the second comparison is false - // and first comparison is false - x[0] = 0.5; - x[1] = 0.0; - y = f.Forward(0, x); - fun(options, x, check, before, after); - ok &= NearEqual(y[0], check[0], eps10, eps10); - if( options == "" ) - ok &= f.number_skip() == 3; - else - ok &= f.number_skip() == 0; - } - return ok; +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.5; + ax[1] = 0.5; + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + + for(size_t k = 0; k < 2; k++) + { // optimization options + std::string options = ""; + if( k == 0 ) + options = "no_conditional_skip"; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // compute function computation + tape_size before, after; + fun(options, ax, ay, before, after); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + ok &= f.size_var() == before.n_var; + ok &= f.size_op() == before.n_op; + + // Optimize the operation sequence + f.optimize(options); + ok &= f.size_var() == after.n_var; + ok &= f.size_op() == after.n_op; + + // Check case where result of the second comparison is true + // and first comparison is true + CPPAD_TESTVECTOR(double) x(n), y(m), check(m); + x[0] = 1.75; + x[1] = 4.0; + y = f.Forward(0, x); + fun(options, x, check, before, after); + ok &= NearEqual(y[0], check[0], eps10, eps10); + ok &= f.number_skip() == 0; + + // Check case where result of the second comparison is true + // and first comparison is false + x[0] = 0.5; + x[1] = 4.0; + y = f.Forward(0, x); + fun(options, x, check, before, after); + ok &= NearEqual(y[0], check[0], eps10, eps10); + if( options == "" ) + ok &= f.number_skip() == 1; + else + ok &= f.number_skip() == 0; + + // Check case where result of the second comparison is false + // and first comparison is true + x[0] = 1.75; + x[1] = 0.0; + y = f.Forward(0, x); + fun(options, x, check, before, after); + ok &= NearEqual(y[0], check[0], eps10, eps10); + if( options == "" ) + ok &= f.number_skip() == 3; + else + ok &= f.number_skip() == 0; + + // Check case where result of the second comparison is false + // and first comparison is false + x[0] = 0.5; + x[1] = 0.0; + y = f.Forward(0, x); + fun(options, x, check, before, after); + ok &= NearEqual(y[0], check[0], eps10, eps10); + if( options == "" ) + ok &= f.number_skip() == 3; + else + ok &= f.number_skip() == 0; + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/optimize/optimize.cpp cppad-2019.02.00.0/example/optimize/optimize.cpp --- cppad-2018.00.00.0/example/optimize/optimize.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/optimize/optimize.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // system include files used for I/O # include @@ -31,25 +32,25 @@ // main program that runs all the tests int main(void) -{ std::string group = "example/optimize"; - size_t width = 20; - CppAD::test_boolofvoid Run(group, width); - - // This line is used by test_one.sh - - // external compiled tests - Run( cumulative_sum, "compare_op" ); - Run( cumulative_sum, "cumulative_sum" ); - Run( conditional_skip, "conditional_skip" ); - Run( forward_active, "forward_active" ); - Run( nest_conditional, "nest_conditional" ); - Run( print_for, "print_for" ); - Run( reverse_active, "reverse_active" ); - // - // check for memory leak - bool memory_ok = CppAD::thread_alloc::free_all(); - // print summary at end - bool ok = Run.summary(memory_ok); - // - return static_cast( ! ok ); +{ std::string group = "example/optimize"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + // external compiled tests + Run( cumulative_sum, "compare_op" ); + Run( cumulative_sum, "cumulative_sum" ); + Run( conditional_skip, "conditional_skip" ); + Run( forward_active, "forward_active" ); + Run( nest_conditional, "nest_conditional" ); + Run( print_for, "print_for" ); + Run( reverse_active, "reverse_active" ); + // + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); } diff -Nru cppad-2018.00.00.0/example/optimize/print_for.cpp cppad-2019.02.00.0/example/optimize/print_for.cpp --- cppad-2018.00.00.0/example/optimize/print_for.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/optimize/print_for.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,24 @@ -// $Id$ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin optimize_print_for.cpp$$ $spell - Cpp + Cpp $$ $section Example Optimization and Print Forward Operators$$ -$code $srcfile%example/optimize/print_for.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -28,93 +26,93 @@ # include namespace { - struct tape_size { size_t n_var; size_t n_op; }; + struct tape_size { size_t n_var; size_t n_op; }; - void PrintFor( - double pos, const char* before, double var, const char* after - ) - { if( pos <= 0.0 ) - std::cout << before << var << after; - return; - } - template void fun( - const std::string& options , - const Vector& x, Vector& y, tape_size& before, tape_size& after - ) - { typedef typename Vector::value_type scalar; - - // phantom variable with index 0 and independent variables - // begin operator, independent variable operators and end operator - before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); - after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); - - // Argument to PrintFor is only needed - // if we are keeping print forward operators - scalar minus_one = x[0] - 1.0; - before.n_var += 1; before.n_op += 1; - if( options.find("no_print_for_op") == std::string::npos ) - { after.n_var += 1; after.n_op += 1; - } - - // print argument to log function minus one, if it is <= 0 - PrintFor(minus_one, "minus_one == ", minus_one , " is <= 0\n"); - before.n_var += 0; before.n_op += 1; - if( options.find("no_print_for_op") == std::string::npos ) - { after.n_var += 0; after.n_op += 1; - } - - // now compute log - y[0] = log( x[0] ); - before.n_var += 1; before.n_op += 1; - after.n_var += 1; after.n_op += 1; - } + void PrintFor( + double pos, const char* before, double var, const char* after + ) + { if( pos <= 0.0 ) + std::cout << before << var << after; + return; + } + template void fun( + const std::string& options , + const Vector& x, Vector& y, tape_size& before, tape_size& after + ) + { typedef typename Vector::value_type scalar; + + // phantom variable with index 0 and independent variables + // begin operator, independent variable operators and end operator + before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); + after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); + + // Argument to PrintFor is only needed + // if we are keeping print forward operators + scalar minus_one = x[0] - 1.0; + before.n_var += 1; before.n_op += 1; + if( options.find("no_print_for_op") == std::string::npos ) + { after.n_var += 1; after.n_op += 1; + } + + // print argument to log function minus one, if it is <= 0 + PrintFor(minus_one, "minus_one == ", minus_one , " is <= 0\n"); + before.n_var += 0; before.n_op += 1; + if( options.find("no_print_for_op") == std::string::npos ) + { after.n_var += 0; after.n_op += 1; + } + + // now compute log + y[0] = log( x[0] ); + before.n_var += 1; before.n_op += 1; + after.n_var += 1; after.n_op += 1; + } } bool print_for(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 1.5; - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) ay(m); - - for(size_t k = 0; k < 2; k++) - { // optimization options - std::string options = ""; - if( k == 0 ) - options = "no_print_for_op"; - - // declare independent variables and start tape recording - CppAD::Independent(ax); - - // compute function value - tape_size before, after; - fun(options, ax, ay, before, after); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - ok &= f.size_var() == before.n_var; - ok &= f.size_op() == before.n_op; - - // Optimize the operation sequence - f.optimize(options); - ok &= f.size_var() == after.n_var; - ok &= f.size_op() == after.n_op; - - // Check result for a zero order calculation for a different x - CPPAD_TESTVECTOR(double) x(n), y(m), check(m); - x[0] = 2.75; - y = f.Forward(0, x); - fun(options, x, check, before, after); - ok &= NearEqual(y[0], check[0], eps10, eps10); - } - return ok; +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 1.5; + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + + for(size_t k = 0; k < 2; k++) + { // optimization options + std::string options = ""; + if( k == 0 ) + options = "no_print_for_op"; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // compute function value + tape_size before, after; + fun(options, ax, ay, before, after); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + ok &= f.size_var() == before.n_var; + ok &= f.size_op() == before.n_op; + + // Optimize the operation sequence + f.optimize(options); + ok &= f.size_var() == after.n_var; + ok &= f.size_op() == after.n_op; + + // Check result for a zero order calculation for a different x + CPPAD_TESTVECTOR(double) x(n), y(m), check(m); + x[0] = 2.75; + y = f.Forward(0, x); + fun(options, x, check, before, after); + ok &= NearEqual(y[0], check[0], eps10, eps10); + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/optimize/reverse_active.cpp cppad-2019.02.00.0/example/optimize/reverse_active.cpp --- cppad-2018.00.00.0/example/optimize/reverse_active.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/optimize/reverse_active.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,108 +1,107 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin optimize_reverse_active.cpp$$ $section Example Optimization and Reverse Activity Analysis$$ -$code $srcfile%example/optimize/reverse_active.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include namespace { - struct tape_size { size_t n_var; size_t n_op; }; + struct tape_size { size_t n_var; size_t n_op; }; - template void fun( - const Vector& x, Vector& y, tape_size& before, tape_size& after - ) - { typedef typename Vector::value_type scalar; - - // phantom variable with index 0 and independent variables - // begin operator, independent variable operators and end operator - before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); - after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); - - // initilized product of even and odd variables - scalar prod_even = x[0]; - scalar prod_odd = x[1]; - before.n_var += 0; before.n_op += 0; - after.n_var += 0; after.n_op += 0; - // - // compute product of even and odd variables - for(size_t i = 2; i < size_t( x.size() ); i++) - { if( i % 2 == 0 ) - { // prod_even will affect dependent variable - prod_even = prod_even * x[i]; - before.n_var += 1; before.n_op += 1; - after.n_var += 1; after.n_op += 1; - } - else - { // prod_odd will not affect dependent variable - prod_odd = prod_odd * x[i]; - before.n_var += 1; before.n_op += 1; - after.n_var += 0; after.n_op += 0; - } - } - - // dependent variable for this operation sequence - y[0] = prod_even; - before.n_var += 0; before.n_op += 0; - after.n_var += 0; after.n_op += 0; - } + template void fun( + const Vector& x, Vector& y, tape_size& before, tape_size& after + ) + { typedef typename Vector::value_type scalar; + + // phantom variable with index 0 and independent variables + // begin operator, independent variable operators and end operator + before.n_var = 1 + x.size(); before.n_op = 2 + x.size(); + after.n_var = 1 + x.size(); after.n_op = 2 + x.size(); + + // initilized product of even and odd variables + scalar prod_even = x[0]; + scalar prod_odd = x[1]; + before.n_var += 0; before.n_op += 0; + after.n_var += 0; after.n_op += 0; + // + // compute product of even and odd variables + for(size_t i = 2; i < size_t( x.size() ); i++) + { if( i % 2 == 0 ) + { // prod_even will affect dependent variable + prod_even = prod_even * x[i]; + before.n_var += 1; before.n_op += 1; + after.n_var += 1; after.n_op += 1; + } + else + { // prod_odd will not affect dependent variable + prod_odd = prod_odd * x[i]; + before.n_var += 1; before.n_op += 1; + after.n_var += 0; after.n_op += 0; + } + } + + // dependent variable for this operation sequence + y[0] = prod_even; + before.n_var += 0; before.n_op += 0; + after.n_var += 0; after.n_op += 0; + } } bool reverse_active(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 6; - CPPAD_TESTVECTOR(AD) ax(n); - for(size_t i = 0; i < n; i++) - ax[i] = AD(i + 1); - - // declare independent variables and start tape recording - CppAD::Independent(ax); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) ay(m); - tape_size before, after; - fun(ax, ay, before, after); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - ok &= f.size_var() == before.n_var; - ok &= f.size_op() == before.n_op; - - // Optimize the operation sequence - f.optimize(); - ok &= f.size_var() == after.n_var; - ok &= f.size_op() == after.n_op; - - // check zero order forward with different argument value - CPPAD_TESTVECTOR(double) x(n), y(m), check(m); - for(size_t i = 0; i < n; i++) - x[i] = double(i + 2); - y = f.Forward(0, x); - fun(x, check, before, after); - ok &= NearEqual(y[0], check[0], eps10, eps10); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 6; + CPPAD_TESTVECTOR(AD) ax(n); + for(size_t i = 0; i < n; i++) + ax[i] = AD(i + 1); + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + tape_size before, after; + fun(ax, ay, before, after); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + ok &= f.size_var() == before.n_var; + ok &= f.size_op() == before.n_op; + + // Optimize the operation sequence + f.optimize(); + ok &= f.size_var() == after.n_var; + ok &= f.size_op() == after.n_op; + + // check zero order forward with different argument value + CPPAD_TESTVECTOR(double) x(n), y(m), check(m); + for(size_t i = 0; i < n; i++) + x[i] = double(i + 2); + y = f.Forward(0, x); + fun(x, check, before, after); + ok &= NearEqual(y[0], check[0], eps10, eps10); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/print_for/CMakeLists.txt cppad-2019.02.00.0/example/print_for/CMakeLists.txt --- cppad-2018.00.00.0/example/print_for/CMakeLists.txt 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/print_for/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the example/print_for directory tests # @@ -18,9 +19,9 @@ # check_example_print_for target ADD_CUSTOM_TARGET(check_example_print_for - example_print_for - DEPENDS - example_print_for + example_print_for + DEPENDS + example_print_for ) MESSAGE(STATUS "make check_example_print_for: available") diff -Nru cppad-2018.00.00.0/example/print_for/makefile.am cppad-2019.02.00.0/example/print_for/makefile.am --- cppad-2018.00.00.0/example/print_for/makefile.am 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/print_for/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -14,23 +15,18 @@ DEFS = # # Make sure that ../cppad-uninstalled.pc works for determining cflags -if CppAD_PKG_CONFIG -CPPAD_INCLUDE = `( \ - export PKG_CONFIG_PATH=$(top_builddir)/pkgconfig ; \ - pkg-config --cflags cppad \ -)` -else -CPPAD_INCLUDE = -I$(top_srcdir) -endif +CPPAD_INCLUDE = -I$(top_srcdir)/include # # Microsoft project files -EXTRA_DIST = test.sh # check_PROGRAMS = print_for # -AM_CPPFLAGS = -I. $(CPPAD_INCLUDE) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + $(CPPAD_INCLUDE) \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) # print_for_SOURCES = print_for.cpp diff -Nru cppad-2018.00.00.0/example/print_for/makefile.in cppad-2019.02.00.0/example/print_for/makefile.in --- cppad-2018.00.00.0/example/print_for/makefile.in 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/print_for/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -182,19 +182,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -267,10 +266,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -289,9 +286,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -314,8 +313,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -335,21 +332,17 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -@CppAD_PKG_CONFIG_FALSE@CPPAD_INCLUDE = -I$(top_srcdir) # # Make sure that ../cppad-uninstalled.pc works for determining cflags -@CppAD_PKG_CONFIG_TRUE@CPPAD_INCLUDE = `( \ -@CppAD_PKG_CONFIG_TRUE@ export PKG_CONFIG_PATH=$(top_builddir)/pkgconfig ; \ -@CppAD_PKG_CONFIG_TRUE@ pkg-config --cflags cppad \ -@CppAD_PKG_CONFIG_TRUE@)` - -# -# Microsoft project files -EXTRA_DIST = test.sh +CPPAD_INCLUDE = -I$(top_srcdir)/include # -AM_CPPFLAGS = -I. $(CPPAD_INCLUDE) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + $(CPPAD_INCLUDE) \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + # print_for_SOURCES = print_for.cpp all: all-am diff -Nru cppad-2018.00.00.0/example/print_for/print_for.cpp cppad-2019.02.00.0/example/print_for/print_for.cpp --- cppad-2018.00.00.0/example/print_for/print_for.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/print_for/print_for.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,36 +1,36 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin print_for_cout.cpp$$ $spell - const - var - av - num - inuse - bool - makefile - CppAD - cppad.hpp - std::cout - endl - namespace - newline - \nv - VecAD + const + var + av + num + inuse + bool + makefile + CppAD + cppad.hpp + std::cout + endl + namespace + newline + \nv + VecAD $$ $section Printing During Forward Mode: Example and Test$$ -$mindex mode print$$ $head Running$$ @@ -41,89 +41,89 @@ # include namespace { - using std::cout; - using std::endl; - using CppAD::AD; - - // use of PrintFor to check for invalid function arguments - AD check_log(const AD& y) - { // check during recording - if( y <= 0. ) - cout << "check_log: y = " << y << " is <= 0" << endl; + using std::cout; + using std::endl; + using CppAD::AD; + + // use of PrintFor to check for invalid function arguments + AD check_log(const AD& y) + { // check during recording + if( y <= 0. ) + cout << "check_log: y = " << y << " is <= 0" << endl; - // check during zero order forward calculation - PrintFor(y, "check_log: y == ", y , " which is <= 0\n"); + // check during zero order forward calculation + PrintFor(y, "check_log: y == ", y , " which is <= 0\n"); - return log(y); - } + return log(y); + } } void print_for(void) -{ using CppAD::PrintFor; +{ using CppAD::PrintFor; - // independent variable vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 1.; - Independent(ax); - - // print a VecAD::reference object that is a parameter - CppAD::VecAD av(1); - AD Zero(0); - av[Zero] = 0.; - 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]); - - // A conditional print that will not generate output when x[0] = 2. - PrintFor(ax[0], "\n 2. + x[0] = ", 2. + ax[0], "\n"); - - // A conditional print that will generate output when x[0] = 2. - PrintFor(ax[0] - 2., "\n 3. + x[0] = ", 3. + ax[0], "\n"); - - // A log evaluations that will result in an error message when x[0] = 2. - AD var = 2. - ax[0]; - AD log_var = check_log(var); - - // 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); - - // 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 << "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); + // independent variable vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 1.; + Independent(ax); + + // print a VecAD::reference object that is a parameter + CppAD::VecAD av(1); + AD Zero(0); + av[Zero] = 0.; + 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]); + + // A conditional print that will not generate output when x[0] = 2. + PrintFor(ax[0], "\n 2. + x[0] = ", 2. + ax[0], "\n"); + + // A conditional print that will generate output when x[0] = 2. + PrintFor(ax[0] - 2., "\n 3. + x[0] = ", 3. + ax[0], "\n"); + + // A log evaluations that will result in an error message when x[0] = 2. + AD var = 2. - ax[0]; + AD log_var = check_log(var); + + // 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); + + // 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 << "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); - return; + return; } int main(void) -{ print_for(); +{ print_for(); - return 0; + return 0; } /* %$$ $head Output$$ Executing the program above generates the following output: $codep - v[0] = 0 - v[0] + x[0] = 2 - Test passes if two lines above repeat below: - v[0] = 0 - v[0] + x[0] = 2 + v[0] = 0 + v[0] + x[0] = 2 + Test passes if two lines above repeat below: + v[0] = 0 + v[0] + x[0] = 2 $$ $end */ diff -Nru cppad-2018.00.00.0/example/print_for/test.sh cppad-2019.02.00.0/example/print_for/test.sh --- cppad-2018.00.00.0/example/print_for/test.sh 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/print_for/test.sh 2019-01-31 12:35:17.000000000 +0000 @@ -2,12 +2,13 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- ./print_for | tee test.log sed -e '/^Test passes/,\$$d' < test.log > test.1 diff -Nru cppad-2018.00.00.0/example/sparse/CMakeLists.txt cppad-2019.02.00.0/example/sparse/CMakeLists.txt --- cppad-2018.00.00.0/example/sparse/CMakeLists.txt 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,60 +1,65 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # BEGIN_SORT_THIS_LINE_PLUS_2 SET(source_list sparse.cpp - colpack_hes.cpp - colpack_hessian.cpp - colpack_jac.cpp - colpack_jacobian.cpp - conj_grad.cpp - dependency.cpp - for_hes_sparsity.cpp - for_jac_sparsity.cpp - for_sparse_hes.cpp - for_sparse_jac.cpp - rc_sparsity.cpp - rev_hes_sparsity.cpp - rev_jac_sparsity.cpp - rev_sparse_hes.cpp - rev_sparse_jac.cpp - sparse_hes.cpp - sparse_hessian.cpp - sparse_jac_for.cpp - sparse_jacobian.cpp - sparse_jac_rev.cpp - sparse_sub_hes.cpp - sparsity_sub.cpp - subgraph_hes2jac.cpp - subgraph_jac_rev.cpp - subgraph_reverse.cpp - subgraph_sparsity.cpp - sub_sparse_hes.cpp + colpack_hes.cpp + colpack_hessian.cpp + colpack_jac.cpp + colpack_jacobian.cpp + conj_grad.cpp + dependency.cpp + for_hes_sparsity.cpp + for_jac_sparsity.cpp + for_sparse_hes.cpp + for_sparse_jac.cpp + rc_sparsity.cpp + rev_hes_sparsity.cpp + rev_jac_sparsity.cpp + rev_sparse_hes.cpp + rev_sparse_jac.cpp + sparse_hes.cpp + sparse_hessian.cpp + sparse_jac_for.cpp + sparse_jacobian.cpp + sparse_jac_rev.cpp + sparse_sub_hes.cpp + sparsity_sub.cpp + subgraph_hes2jac.cpp + subgraph_jac_rev.cpp + subgraph_reverse.cpp + subgraph_sparsity.cpp + sub_sparse_hes.cpp ) # END_SORT_THIS_LINE_MINUS_2 +IF( cppad_has_eigen ) + SET(source_list sparse2eigen.cpp ${source_list} ) +ENDIF( cppad_has_eigen ) + set_compile_flags( example_sparse "${cppad_debug_which}" "${source_list}" ) # ADD_EXECUTABLE(example_sparse EXCLUDE_FROM_ALL ${source_list}) # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(example_sparse - ${cppad_lib} - ${colpack_libs} + ${cppad_lib} + ${colpack_libs} ) # Add the check_example_sparse target ADD_CUSTOM_TARGET(check_example_sparse - example_sparse - DEPENDS example_sparse + example_sparse + DEPENDS example_sparse ) MESSAGE(STATUS "make check_example_sparse: available") diff -Nru cppad-2018.00.00.0/example/sparse/colpack_hes.cpp cppad-2019.02.00.0/example/sparse/colpack_hes.cpp --- cppad-2018.00.00.0/example/sparse/colpack_hes.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/colpack_hes.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin colpack_hes.cpp$$ $spell - colpack_hes - jacobian + colpack_hes + jacobian $$ $section ColPack: Sparse Hessian Example and Test$$ -$code $srcfile%example/sparse/colpack_hes.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,141 +28,141 @@ # 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; - typedef CppAD::sparse_rc sparsity; - typedef CppAD::sparse_rcv sparse_matrix; - double eps = 10. * CppAD::numeric_limits::epsilon(); - // - // domain space vector - size_t n = 5; - 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); - - // 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(size_t 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(size_t 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(size_t 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 ] - */ - // Normally one would use CppAD to compute sparsity pattern, but for this - // example we set it directly - size_t nr = n; - size_t nc = n; - size_t nnz = n + 2 * (n - 1); - sparsity pattern(nr, nc, nnz); - for(size_t k = 0; k < n; k++) - { size_t r = k; - size_t c = k; - pattern.set(k, r, c); - } - for(size_t i = 1; i < n; i++) - { size_t k = n + 2 * (i - 1); - size_t r = i; - size_t c = 0; - pattern.set(k, r, c); - pattern.set(k+1, c, r); - } - - // subset of elements to compute - // (only compute lower traingle) - nnz = n + (n - 1); - sparsity lower_triangle(nr, nc, nnz); - d_vector check(nnz); - for(size_t k = 0; k < n; k++) - { size_t r = k; - size_t c = k; - lower_triangle.set(k, r, c); - check[k] = 2.0 * x[k]; - if( k > 0 ) - check[k] += x[0]; - } - for(size_t j = 1; j < n; j++) - { size_t k = n + (j - 1); - size_t r = 0; - size_t c = j; - lower_triangle.set(k, r, c); - check[k] = x[c]; - } - sparse_matrix subset( lower_triangle ); - - // check results for both CppAD and Colpack - for(size_t i_method = 0; i_method < 4; i_method++) - { // coloring method - std::string coloring; - switch(i_method) - { case 0: - coloring = "cppad.symmetric"; - break; - - case 1: - coloring = "cppad.general"; - break; - - case 2: - coloring = "colpack.symmetric"; - break; - - case 3: - coloring = "colpack.general"; - break; - } - // - // compute Hessian - CppAD::sparse_hes_work work; - d_vector w(m); - w[0] = 1.0; - size_t n_sweep = f.sparse_hes( - x, w, subset, pattern, coloring, work - ); - // - // check result - const d_vector& hes( subset.val() ); - for(size_t k = 0; k < nnz; k++) - ok &= NearEqual(check[k], hes[k], eps, eps); - if( - coloring == "cppad.symmetric" - || coloring == "colpack.symmetric" - ) - ok &= n_sweep == 2; - else - ok &= n_sweep == 5; - } +{ 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; + typedef CppAD::sparse_rc sparsity; + typedef CppAD::sparse_rcv sparse_matrix; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // domain space vector + size_t n = 5; + 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); + + // 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(size_t 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(size_t 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(size_t 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 ] + */ + // Normally one would use CppAD to compute sparsity pattern, but for this + // example we set it directly + size_t nr = n; + size_t nc = n; + size_t nnz = n + 2 * (n - 1); + sparsity pattern(nr, nc, nnz); + for(size_t k = 0; k < n; k++) + { size_t r = k; + size_t c = k; + pattern.set(k, r, c); + } + for(size_t i = 1; i < n; i++) + { size_t k = n + 2 * (i - 1); + size_t r = i; + size_t c = 0; + pattern.set(k, r, c); + pattern.set(k+1, c, r); + } + + // subset of elements to compute + // (only compute lower traingle) + nnz = n + (n - 1); + sparsity lower_triangle(nr, nc, nnz); + d_vector check(nnz); + for(size_t k = 0; k < n; k++) + { size_t r = k; + size_t c = k; + lower_triangle.set(k, r, c); + check[k] = 2.0 * x[k]; + if( k > 0 ) + check[k] += x[0]; + } + for(size_t j = 1; j < n; j++) + { size_t k = n + (j - 1); + size_t r = 0; + size_t c = j; + lower_triangle.set(k, r, c); + check[k] = x[c]; + } + sparse_matrix subset( lower_triangle ); + + // check results for both CppAD and Colpack + for(size_t i_method = 0; i_method < 4; i_method++) + { // coloring method + std::string coloring; + switch(i_method) + { case 0: + coloring = "cppad.symmetric"; + break; + + case 1: + coloring = "cppad.general"; + break; + + case 2: + coloring = "colpack.symmetric"; + break; + + case 3: + coloring = "colpack.general"; + break; + } + // + // compute Hessian + CppAD::sparse_hes_work work; + d_vector w(m); + w[0] = 1.0; + size_t n_sweep = f.sparse_hes( + x, w, subset, pattern, coloring, work + ); + // + // check result + const d_vector& hes( subset.val() ); + for(size_t k = 0; k < nnz; k++) + ok &= NearEqual(check[k], hes[k], eps, eps); + if( + coloring == "cppad.symmetric" + || coloring == "colpack.symmetric" + ) + ok &= n_sweep == 2; + else + ok &= n_sweep == 5; + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/colpack_hessian.cpp cppad-2019.02.00.0/example/sparse/colpack_hessian.cpp --- cppad-2018.00.00.0/example/sparse/colpack_hessian.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/colpack_hessian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin colpack_hessian.cpp$$ $spell - colpack_hessian - jacobian + colpack_hessian + jacobian $$ $section ColPack: Sparse Hessian Example and Test$$ -$code $srcfile%example/sparse/colpack_hessian.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,142 +28,142 @@ # include bool colpack_hessian(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 lower triangle - if( j <= i ) - { row.push_back(i); - col.push_back(j); - } - } - } - } - size_t K = row.size(); - d_vector hes(K); - - // default coloring method is cppad.symmetric - CppAD::sparse_hessian_work work; - ok &= work.color_method == "cppad.symmetric"; - - // contrast and check results for both CppAD and Colpack - for(size_t i_method = 0; i_method < 4; i_method++) - { // empty work structure - switch(i_method) - { case 0: - work.color_method = "cppad.symmetric"; - break; - - case 1: - work.color_method = "cppad.general"; - break; - - case 2: - work.color_method = "colpack.symmetric"; - break; - - case 3: - work.color_method = "colpack.general"; - break; - } - - // 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.symmetric" - || work.color_method == "colpack.symmetric" - ) - 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"; - } +{ 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 lower triangle + if( j <= i ) + { row.push_back(i); + col.push_back(j); + } + } + } + } + size_t K = row.size(); + d_vector hes(K); + + // default coloring method is cppad.symmetric + CppAD::sparse_hessian_work work; + ok &= work.color_method == "cppad.symmetric"; + + // contrast and check results for both CppAD and Colpack + for(size_t i_method = 0; i_method < 4; i_method++) + { // empty work structure + switch(i_method) + { case 0: + work.color_method = "cppad.symmetric"; + break; + + case 1: + work.color_method = "cppad.general"; + break; + + case 2: + work.color_method = "colpack.symmetric"; + break; + + case 3: + work.color_method = "colpack.general"; + break; + } + + // 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.symmetric" + || work.color_method == "colpack.symmetric" + ) + 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/colpack_jac.cpp cppad-2019.02.00.0/example/sparse/colpack_jac.cpp --- cppad-2018.00.00.0/example/sparse/colpack_jac.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/colpack_jac.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin colpack_jac.cpp$$ $spell - colpack_jac - jacobian + colpack_jac + jacobian $$ $section ColPack: Sparse Jacobian Example and Test$$ -$code $srcfile%example/sparse/colpack_jac.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,101 +28,101 @@ # 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; - typedef CppAD::sparse_rc sparsity; - typedef CppAD::sparse_rcv sparse_matrix; - - // domain space vector - size_t n = 4; - 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); - - 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(size_t j = 0; j < n; j++) - x[j] = double(j); - - /* - [ 1 1 0 0 ] - jac = [ 0 0 1 1 ] - [ 1 1 1 x_3] - */ - // Normally one would use CppAD to compute sparsity pattern, but for this - // example we set it directly - size_t nr = m; - size_t nc = n; - size_t nnz = 8; - sparsity pattern(nr, nc, nnz); - d_vector check(nnz); - for(size_t k = 0; k < nnz; k++) - { size_t r, c; - if( k < 2 ) - { r = 0; - c = k; - } - else if( k < 4 ) - { r = 1; - c = k; - } - else - { r = 2; - c = k - 4; - } - pattern.set(k, r, c); - if( k == nnz - 1 ) - check[k] = x[3]; - else - check[k] = 1.0; - } - - // using row and column indices to compute non-zero in rows 1 and 2 - sparse_matrix subset( pattern ); - - // check results for both CppAD and Colpack - for(size_t i_method = 0; i_method < 4; i_method++) - { // coloring method - std::string coloring; - if( i_method % 2 == 0 ) - coloring = "cppad"; - else - coloring = "colpack"; - // - CppAD::sparse_jac_work work; - size_t group_max = 1; - if( i_method / 2 == 0 ) - { size_t n_sweep = f.sparse_jac_for( - group_max, x, subset, pattern, coloring, work - ); - ok &= n_sweep == 4; - } - else - { size_t n_sweep = f.sparse_jac_rev( - x, subset, pattern, coloring, work - ); - ok &= n_sweep == 2; - } - const d_vector& hes( subset.val() ); - for(size_t k = 0; k < nnz; k++) - ok &= check[k] == hes[k]; - } - return ok; +{ 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; + typedef CppAD::sparse_rc sparsity; + typedef CppAD::sparse_rcv sparse_matrix; + + // domain space vector + size_t n = 4; + 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); + + 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(size_t j = 0; j < n; j++) + x[j] = double(j); + + /* + [ 1 1 0 0 ] + jac = [ 0 0 1 1 ] + [ 1 1 1 x_3] + */ + // Normally one would use CppAD to compute sparsity pattern, but for this + // example we set it directly + size_t nr = m; + size_t nc = n; + size_t nnz = 8; + sparsity pattern(nr, nc, nnz); + d_vector check(nnz); + for(size_t k = 0; k < nnz; k++) + { size_t r, c; + if( k < 2 ) + { r = 0; + c = k; + } + else if( k < 4 ) + { r = 1; + c = k; + } + else + { r = 2; + c = k - 4; + } + pattern.set(k, r, c); + if( k == nnz - 1 ) + check[k] = x[3]; + else + check[k] = 1.0; + } + + // using row and column indices to compute non-zero in rows 1 and 2 + sparse_matrix subset( pattern ); + + // check results for both CppAD and Colpack + for(size_t i_method = 0; i_method < 4; i_method++) + { // coloring method + std::string coloring; + if( i_method % 2 == 0 ) + coloring = "cppad"; + else + coloring = "colpack"; + // + CppAD::sparse_jac_work work; + size_t group_max = 1; + if( i_method / 2 == 0 ) + { size_t n_sweep = f.sparse_jac_for( + group_max, x, subset, pattern, coloring, work + ); + ok &= n_sweep == 4; + } + else + { size_t n_sweep = f.sparse_jac_rev( + x, subset, pattern, coloring, work + ); + ok &= n_sweep == 2; + } + const d_vector& hes( subset.val() ); + for(size_t k = 0; k < nnz; k++) + ok &= check[k] == hes[k]; + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/colpack_jacobian.cpp cppad-2019.02.00.0/example/sparse/colpack_jacobian.cpp --- cppad-2018.00.00.0/example/sparse/colpack_jacobian.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/colpack_jacobian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin colpack_jacobian.cpp$$ $spell - colpack_jac - jacobian + colpack_jac + jacobian $$ $section ColPack: Sparse Jacobian Example and Test$$ -$code $srcfile%example/sparse/colpack_jacobian.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -28,92 +27,92 @@ # include bool colpack_jacobian(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; +{ 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/conj_grad.cpp cppad-2019.02.00.0/example/sparse/conj_grad.cpp --- cppad-2018.00.00.0/example/sparse/conj_grad.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/conj_grad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin conj_grad.cpp$$ $spell - checkpointing - goto + checkpointing + goto $$ $section Differentiate Conjugate Gradient Algorithm: Example and Test$$ @@ -89,9 +90,7 @@ goto Convergence Check. $lend -$code $srcfile%example/sparse/conj_grad.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -101,191 +100,191 @@ # include namespace { // Begin empty namespace - using CppAD::AD; + using CppAD::AD; - // 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 - void mat_mul(size_t n, const Vector& a, const Vector& b, Vector& c) - { typedef typename Vector::value_type scalar; - - size_t m, p; - m = a.size() / n; - p = b.size() / n; - - assert( m * n == a.size() ); - assert( n * p == b.size() ); - assert( m * p == c.size() ); - - size_t i, j, k, ij; - for(i = 0; i < m; i++) - { for(j = 0; j < p; j++) - { ij = i * p + j; - c[ij] = scalar(0); - for(k = 0; k < n; k++) - c[ij] = c[ij] + a[i * m + k] * b[k * p + j]; - } - } - return; - } - - // Solve A * x == b to tolerance epsilon or terminate at m interations. - template // a simple vector class - size_t conjugate_gradient( - size_t m , // input - double epsilon , // input - const Vector& A , // input - const Vector& b , // input - Vector& x ) // input / output - { typedef typename Vector::value_type scalar; - scalar mu, s_previous; - size_t i, k; - - size_t n = x.size(); - assert( A.size() == n * n ); - assert( b.size() == n ); - - Vector g(n), d(n), s(1), Ad(n), dAd(1); - - // g = A * x - mat_mul(n, A, x, g); - for(i = 0; i < n; i++) - { // g = A * x - b - g[i] = g[i] - b[i]; - - // d = - g - d[i] = -g[i]; - } - // s = g^T * g - mat_mul(n, g, g, s); - - for(k = 0; k < m; k++) - { s_previous = s[0]; - if( s_previous < epsilon ) - return k; - - // Ad = A * d - mat_mul(n, A, d, Ad); - - // dAd = d^T * A * d - mat_mul(n, d, Ad, dAd); - - // mu = s / d^T * A * d - mu = s_previous / dAd[0]; - - // 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]; - } - - // s = g^T * g - mat_mul(n, g, g, s); - - // d = - g + (s / s_previous) * d - for(i = 0; i < n; i++) - d[i] = - g[i] + ( s[0] / s_previous) * d[i]; - } - return m; - } + // 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 + void mat_mul(size_t n, const Vector& a, const Vector& b, Vector& c) + { typedef typename Vector::value_type scalar; + + size_t m, p; + m = a.size() / n; + p = b.size() / n; + + assert( m * n == a.size() ); + assert( n * p == b.size() ); + assert( m * p == c.size() ); + + size_t i, j, k, ij; + for(i = 0; i < m; i++) + { for(j = 0; j < p; j++) + { ij = i * p + j; + c[ij] = scalar(0); + for(k = 0; k < n; k++) + c[ij] = c[ij] + a[i * m + k] * b[k * p + j]; + } + } + return; + } + + // Solve A * x == b to tolerance epsilon or terminate at m interations. + template // a simple vector class + size_t conjugate_gradient( + size_t m , // input + double epsilon , // input + const Vector& A , // input + const Vector& b , // input + Vector& x ) // input / output + { typedef typename Vector::value_type scalar; + scalar mu, s_previous; + size_t i, k; + + size_t n = x.size(); + assert( A.size() == n * n ); + assert( b.size() == n ); + + Vector g(n), d(n), s(1), Ad(n), dAd(1); + + // g = A * x + mat_mul(n, A, x, g); + for(i = 0; i < n; i++) + { // g = A * x - b + g[i] = g[i] - b[i]; + + // d = - g + d[i] = -g[i]; + } + // s = g^T * g + mat_mul(n, g, g, s); + + for(k = 0; k < m; k++) + { s_previous = s[0]; + if( s_previous < epsilon ) + return k; + + // Ad = A * d + mat_mul(n, A, d, Ad); + + // dAd = d^T * A * d + mat_mul(n, d, Ad, dAd); + + // mu = s / d^T * A * d + mu = s_previous / dAd[0]; + + // 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]; + } + + // s = g^T * g + mat_mul(n, g, g, s); + + // d = - g + (s / s_previous) * d + for(i = 0; i < n; i++) + d[i] = - g[i] + ( s[0] / s_previous) * d[i]; + } + return m; + } } // End empty namespace bool conj_grad(void) -{ bool ok = true; +{ bool ok = true; - // ---------------------------------------------------------------------- - // Setup - // ---------------------------------------------------------------------- - using CppAD::AD; - using CppAD::NearEqual; - using CppAD::vector; - using std::cout; - using std::endl; - size_t i, j; - - - // 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); - - // D = diagonally dominant matrix - // c = vector of ones - for(i = 0; i < n; i++) - { c[i] = 1.; - double sum = 0; - for(j = 0; j < n; j++) if( i != j ) - { D[ i * n + j ] = std::rand() / double(RAND_MAX); - Dt[j * n + i ] = D[i * n + j ]; - sum += D[i * n + j ]; - } - Dt[ i * n + i ] = D[ i * n + i ] = sum * 1.1; - } - - // A = D^T * D - mat_mul(n, Dt, D, A); - - // b = D^T * c - mat_mul(n, Dt, c, b); - - // copy from double to AD - for(i = 0; i < n; i++) - { a_b[i] = b[i]; - for(j = 0; j < n; j++) - a_A[ i * n + j ] = A[ i * n + j ]; - } - - // --------------------------------------------------------------------- - // Record the function f : b -> x - // --------------------------------------------------------------------- - // Make b the independent variable vector - Independent(a_b); - - // Solve A * x = b using conjugate gradient method - double epsilon = 1e-7; - for(i = 0; i < n; i++) - a_x[i] = AD(0); - size_t m = n + 1; - size_t k = conjugate_gradient(m, epsilon, a_A, a_b, a_x); - - // create f_cg: b -> x and stop tape recording - CppAD::ADFun f(a_b, a_x); - - // --------------------------------------------------------------------- - // Check for correctness - // --------------------------------------------------------------------- - - // conjugate gradient should converge with in n iterations - ok &= (k <= n); - - // accuracy to which we expect values to agree - double delta = 10. * epsilon * std::sqrt( double(n) ); - - // copy x from AD to double - for(i = 0; i < n; i++) - x[i] = Value( a_x[i] ); - - // check c = A * x - mat_mul(n, A, x, c); - for(i = 0; i < n; i++) - ok &= NearEqual(c[i] , b[i], delta , delta); - - // forward computation of partials w.r.t. b[0] - vector db(n), dx(n); - for(j = 0; j < n; j++) - db[j] = 0.; - db[0] = 1.; - - // check db = A * dx - delta = 5. * delta; - dx = f.Forward(1, db); - mat_mul(n, A, dx, c); - for(i = 0; i < n; i++) - ok &= NearEqual(c[i], db[i], delta, delta); + // ---------------------------------------------------------------------- + // Setup + // ---------------------------------------------------------------------- + using CppAD::AD; + using CppAD::NearEqual; + using CppAD::vector; + using std::cout; + using std::endl; + size_t i, j; + + + // 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); + + // D = diagonally dominant matrix + // c = vector of ones + for(i = 0; i < n; i++) + { c[i] = 1.; + double sum = 0; + for(j = 0; j < n; j++) if( i != j ) + { D[ i * n + j ] = std::rand() / double(RAND_MAX); + Dt[j * n + i ] = D[i * n + j ]; + sum += D[i * n + j ]; + } + Dt[ i * n + i ] = D[ i * n + i ] = sum * 1.1; + } + + // A = D^T * D + mat_mul(n, Dt, D, A); + + // b = D^T * c + mat_mul(n, Dt, c, b); + + // copy from double to AD + for(i = 0; i < n; i++) + { a_b[i] = b[i]; + for(j = 0; j < n; j++) + a_A[ i * n + j ] = A[ i * n + j ]; + } + + // --------------------------------------------------------------------- + // Record the function f : b -> x + // --------------------------------------------------------------------- + // Make b the independent variable vector + Independent(a_b); + + // Solve A * x = b using conjugate gradient method + double epsilon = 1e-7; + for(i = 0; i < n; i++) + a_x[i] = AD(0); + size_t m = n + 1; + size_t k = conjugate_gradient(m, epsilon, a_A, a_b, a_x); + + // create f_cg: b -> x and stop tape recording + CppAD::ADFun f(a_b, a_x); + + // --------------------------------------------------------------------- + // Check for correctness + // --------------------------------------------------------------------- + + // conjugate gradient should converge with in n iterations + ok &= (k <= n); + + // accuracy to which we expect values to agree + double delta = 10. * epsilon * std::sqrt( double(n) ); + + // copy x from AD to double + for(i = 0; i < n; i++) + x[i] = Value( a_x[i] ); + + // check c = A * x + mat_mul(n, A, x, c); + for(i = 0; i < n; i++) + ok &= NearEqual(c[i] , b[i], delta , delta); + + // forward computation of partials w.r.t. b[0] + vector db(n), dx(n); + for(j = 0; j < n; j++) + db[j] = 0.; + db[0] = 1.; + + // check db = A * dx + delta = 5. * delta; + dx = f.Forward(1, db); + mat_mul(n, A, dx, c); + for(i = 0; i < n; i++) + ok &= NearEqual(c[i], db[i], delta, delta); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/dependency.cpp cppad-2019.02.00.0/example/sparse/dependency.cpp --- cppad-2018.00.00.0/example/sparse/dependency.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/dependency.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin dependency.cpp$$ $spell - CppAD - Jac + CppAD + Jac $$ $section Computing Dependency: Example and Test$$ @@ -25,9 +26,9 @@ $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 + +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$$ @@ -47,110 +48,108 @@ $cref/RevSparseJac/RevSparseJac/dependency/$$ is a flag that signals that the dependency pattern (instead of the sparsity pattern) is computed. -$code $srcfile%example/sparse/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) + 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; - typedef CPPAD_TESTVECTOR(size_t) SizeVector; - typedef CppAD::sparse_rc sparsity; - - // 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); - // Note that ay[m1 - j] depends on ax[j] - 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); - - // sparsity pattern for n by n identity matrix - size_t nr = n; - size_t nc = n; - size_t nnz = n; - sparsity pattern_in(nr, nc, nnz); - for(size_t k = 0; k < nnz; k++) - { size_t r = k; - size_t c = k; - pattern_in.set(k, r, c); - } - - // compute dependency pattern - bool transpose = false; - bool dependency = true; // would transpose dependency pattern - bool internal_bool = true; // does not affect result - sparsity pattern_out; - f.for_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, pattern_out - ); - const SizeVector& row( pattern_out.row() ); - const SizeVector& col( pattern_out.col() ); - SizeVector col_major = pattern_out.col_major(); - - // check result - ok &= pattern_out.nr() == n; - ok &= pattern_out.nc() == n; - ok &= pattern_out.nnz() == n; - for(size_t k = 0; k < n; k++) - { ok &= row[ col_major[k] ] == m1 - k; - ok &= col[ col_major[k] ] == k; - } - // ----------------------------------------------------------- - // 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); - } - 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; +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + typedef CPPAD_TESTVECTOR(size_t) SizeVector; + typedef CppAD::sparse_rc sparsity; + + // 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); + // Note that ay[m1 - j] depends on ax[j] + 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); + + // sparsity pattern for n by n identity matrix + size_t nr = n; + size_t nc = n; + size_t nnz = n; + sparsity pattern_in(nr, nc, nnz); + for(size_t k = 0; k < nnz; k++) + { size_t r = k; + size_t c = k; + pattern_in.set(k, r, c); + } + + // compute dependency pattern + bool transpose = false; + bool dependency = true; // would transpose dependency pattern + bool internal_bool = true; // does not affect result + sparsity pattern_out; + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + const SizeVector& row( pattern_out.row() ); + const SizeVector& col( pattern_out.col() ); + SizeVector col_major = pattern_out.col_major(); + + // check result + ok &= pattern_out.nr() == n; + ok &= pattern_out.nc() == n; + ok &= pattern_out.nnz() == n; + for(size_t k = 0; k < n; k++) + { ok &= row[ col_major[k] ] == m1 - k; + ok &= col[ col_major[k] ] == k; + } + // ----------------------------------------------------------- + // 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); + } + 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-2018.00.00.0/example/sparse/for_hes_sparsity.cpp cppad-2019.02.00.0/example/sparse/for_hes_sparsity.cpp --- cppad-2018.00.00.0/example/sparse/for_hes_sparsity.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/for_hes_sparsity.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin for_hes_sparsity.cpp$$ $spell - Hessian - Cpp + Hessian + Cpp $$ $section Forward Mode Hessian Sparsity: Example and Test$$ -$code $srcfile%example/sparse/for_hes_sparsity.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,73 +28,73 @@ # include bool for_hes_sparsity(void) -{ bool ok = true; - using CppAD::AD; - typedef CPPAD_TESTVECTOR(size_t) SizeVector; - typedef CppAD::sparse_rc sparsity; - // - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - ax[2] = 2.; - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = sin( ax[2] ); - ay[1] = ax[0] * ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // include all x components in sparsity pattern - CPPAD_TESTVECTOR(bool) select_domain(n); - for(size_t j = 0; j < n; j++) - select_domain[j] = true; - - // compute sparsity pattern for H(x) = F_1''(x) - CPPAD_TESTVECTOR(bool) select_range(m); - select_range[0] = false; - select_range[1] = true; - bool internal_bool = true; - sparsity pattern_out; - f.for_hes_sparsity( - select_domain, select_range, internal_bool, pattern_out - ); - size_t nnz = pattern_out.nnz(); - ok &= nnz == 2; - ok &= pattern_out.nr() == n; - ok &= pattern_out.nc() == n; - { // check results - const SizeVector& row( pattern_out.row() ); - const SizeVector& col( pattern_out.col() ); - SizeVector row_major = pattern_out.row_major(); - // - ok &= row[ row_major[0] ] == 0 && col[ row_major[0] ] == 1; - ok &= row[ row_major[1] ] == 1 && col[ row_major[1] ] == 0; - } - // - // compute sparsity pattern for H(x) = F_0''(x) - select_range[0] = true; - select_range[1] = false; - f.for_hes_sparsity( - select_domain, select_range, internal_bool, pattern_out - ); - nnz = pattern_out.nnz(); - ok &= nnz == 1; - ok &= pattern_out.nr() == n; - ok &= pattern_out.nc() == n; - { // check results - const SizeVector& row( pattern_out.row() ); - const SizeVector& col( pattern_out.col() ); - // - ok &= row[0] == 2 && col[0] == 2; - } - return ok; +{ bool ok = true; + using CppAD::AD; + typedef CPPAD_TESTVECTOR(size_t) SizeVector; + typedef CppAD::sparse_rc sparsity; + // + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + ax[2] = 2.; + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 2; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = sin( ax[2] ); + ay[1] = ax[0] * ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // include all x components in sparsity pattern + CPPAD_TESTVECTOR(bool) select_domain(n); + for(size_t j = 0; j < n; j++) + select_domain[j] = true; + + // compute sparsity pattern for H(x) = F_1''(x) + CPPAD_TESTVECTOR(bool) select_range(m); + select_range[0] = false; + select_range[1] = true; + bool internal_bool = true; + sparsity pattern_out; + f.for_hes_sparsity( + select_domain, select_range, internal_bool, pattern_out + ); + size_t nnz = pattern_out.nnz(); + ok &= nnz == 2; + ok &= pattern_out.nr() == n; + ok &= pattern_out.nc() == n; + { // check results + const SizeVector& row( pattern_out.row() ); + const SizeVector& col( pattern_out.col() ); + SizeVector row_major = pattern_out.row_major(); + // + ok &= row[ row_major[0] ] == 0 && col[ row_major[0] ] == 1; + ok &= row[ row_major[1] ] == 1 && col[ row_major[1] ] == 0; + } + // + // compute sparsity pattern for H(x) = F_0''(x) + select_range[0] = true; + select_range[1] = false; + f.for_hes_sparsity( + select_domain, select_range, internal_bool, pattern_out + ); + nnz = pattern_out.nnz(); + ok &= nnz == 1; + ok &= pattern_out.nr() == n; + ok &= pattern_out.nc() == n; + { // check results + const SizeVector& row( pattern_out.row() ); + const SizeVector& col( pattern_out.col() ); + // + ok &= row[0] == 2 && col[0] == 2; + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/for_jac_sparsity.cpp cppad-2019.02.00.0/example/sparse/for_jac_sparsity.cpp --- cppad-2018.00.00.0/example/sparse/for_jac_sparsity.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/for_jac_sparsity.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,28 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin for_jac_sparsity.cpp$$ $spell - Jacobian - Jac - Dep - Cpp + Jacobian + Jac + Dep + Cpp $$ $section Forward Mode Jacobian Sparsity: Example and Test$$ -$code $srcfile%example/sparse/for_jac_sparsity.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,92 +30,92 @@ # include bool for_jac_sparsity(void) -{ bool ok = true; - using CppAD::AD; - typedef CPPAD_TESTVECTOR(size_t) SizeVector; - typedef CppAD::sparse_rc sparsity; - // - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = ax[0]; - ay[1] = ax[0] * ax[1]; - ay[2] = ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // sparsity pattern for the identity matrix - size_t nr = n; - size_t nc = n; - size_t nnz_in = n; - sparsity pattern_in(nr, nc, nnz_in); - for(size_t k = 0; k < nnz_in; k++) - { size_t r = k; - size_t c = k; - pattern_in.set(k, r, c); - } - // - // Compute sparsity pattern for J(x) = F'(x) - bool transpose = false; - bool dependency = false; - bool internal_bool = false; - sparsity pattern_out; - f.for_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, pattern_out - ); - size_t nnz = pattern_out.nnz(); - ok &= nnz == 4; - ok &= pattern_out.nr() == m; - ok &= pattern_out.nc() == n; - { // check results - const SizeVector& row( pattern_out.row() ); - const SizeVector& col( pattern_out.col() ); - SizeVector col_major = pattern_out.col_major(); - // - ok &= row[ col_major[0] ] == 0 && col[ col_major[0] ] == 0; - ok &= row[ col_major[1] ] == 1 && col[ col_major[1] ] == 0; - ok &= row[ col_major[2] ] == 1 && col[ col_major[2] ] == 1; - ok &= row[ col_major[3] ] == 2 && col[ col_major[3] ] == 1; - // - // check that set and not boolean values are stored - ok &= (f.size_forward_set() > 0); - ok &= (f.size_forward_bool() == 0); - } - // - // note that the transpose of the identity is the identity - transpose = true; - internal_bool = true; - f.for_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, pattern_out - ); - nnz = pattern_out.nnz(); - ok &= nnz == 4; - ok &= pattern_out.nr() == n; - ok &= pattern_out.nc() == m; - { // check results - const SizeVector& row( pattern_out.row() ); - const SizeVector& col( pattern_out.col() ); - SizeVector row_major = pattern_out.row_major(); - // - ok &= col[ row_major[0] ] == 0 && row[ row_major[0] ] == 0; - ok &= col[ row_major[1] ] == 1 && row[ row_major[1] ] == 0; - ok &= col[ row_major[2] ] == 1 && row[ row_major[2] ] == 1; - ok &= col[ row_major[3] ] == 2 && row[ row_major[3] ] == 1; - // - // check that set and not boolean values are stored - ok &= (f.size_forward_set() == 0); - ok &= (f.size_forward_bool() > 0); - } - return ok; +{ bool ok = true; + using CppAD::AD; + typedef CPPAD_TESTVECTOR(size_t) SizeVector; + typedef CppAD::sparse_rc sparsity; + // + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = ax[0]; + ay[1] = ax[0] * ax[1]; + ay[2] = ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // sparsity pattern for the identity matrix + size_t nr = n; + size_t nc = n; + size_t nnz_in = n; + sparsity pattern_in(nr, nc, nnz_in); + for(size_t k = 0; k < nnz_in; k++) + { size_t r = k; + size_t c = k; + pattern_in.set(k, r, c); + } + // + // Compute sparsity pattern for J(x) = F'(x) + bool transpose = false; + bool dependency = false; + bool internal_bool = false; + sparsity pattern_out; + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + size_t nnz = pattern_out.nnz(); + ok &= nnz == 4; + ok &= pattern_out.nr() == m; + ok &= pattern_out.nc() == n; + { // check results + const SizeVector& row( pattern_out.row() ); + const SizeVector& col( pattern_out.col() ); + SizeVector col_major = pattern_out.col_major(); + // + ok &= row[ col_major[0] ] == 0 && col[ col_major[0] ] == 0; + ok &= row[ col_major[1] ] == 1 && col[ col_major[1] ] == 0; + ok &= row[ col_major[2] ] == 1 && col[ col_major[2] ] == 1; + ok &= row[ col_major[3] ] == 2 && col[ col_major[3] ] == 1; + // + // check that set and not boolean values are stored + ok &= (f.size_forward_set() > 0); + ok &= (f.size_forward_bool() == 0); + } + // + // note that the transpose of the identity is the identity + transpose = true; + internal_bool = true; + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + nnz = pattern_out.nnz(); + ok &= nnz == 4; + ok &= pattern_out.nr() == n; + ok &= pattern_out.nc() == m; + { // check results + const SizeVector& row( pattern_out.row() ); + const SizeVector& col( pattern_out.col() ); + SizeVector row_major = pattern_out.row_major(); + // + ok &= col[ row_major[0] ] == 0 && row[ row_major[0] ] == 0; + ok &= col[ row_major[1] ] == 1 && row[ row_major[1] ] == 0; + ok &= col[ row_major[2] ] == 1 && row[ row_major[2] ] == 1; + ok &= col[ row_major[3] ] == 2 && row[ row_major[3] ] == 1; + // + // check that set and not boolean values are stored + ok &= (f.size_forward_set() == 0); + ok &= (f.size_forward_bool() > 0); + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/for_sparse_hes.cpp cppad-2019.02.00.0/example/sparse/for_sparse_hes.cpp --- cppad-2018.00.00.0/example/sparse/for_sparse_hes.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/for_sparse_hes.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,31 +1,29 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin for_sparse_hes.cpp$$ $spell - Hessian - Jac - Hes - Dep - Cpp + Hessian + Jac + Hes + Dep + Cpp $$ $section Forward Mode Hessian Sparsity: Example and Test$$ -$mindex ForSparseHes sparsity$$ -$code $srcfile%example/sparse/for_sparse_hes.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -36,168 +34,168 @@ // expected sparsity pattern bool check_f0[] = { - false, false, false, // partials w.r.t x0 and (x0, x1, x2) - false, false, false, // partials w.r.t x1 and (x0, x1, x2) - false, false, true // partials w.r.t x2 and (x0, x1, x2) + false, false, false, // partials w.r.t x0 and (x0, x1, x2) + false, false, false, // partials w.r.t x1 and (x0, x1, x2) + false, false, true // partials w.r.t x2 and (x0, x1, x2) }; bool check_f1[] = { - false, true, false, // partials w.r.t x0 and (x0, x1, x2) - true, false, false, // partials w.r.t x1 and (x0, x1, x2) - false, false, false // partials w.r.t x2 and (x0, x1, x2) + false, true, false, // partials w.r.t x0 and (x0, x1, x2) + true, false, false, // partials w.r.t x1 and (x0, x1, x2) + false, false, false // partials w.r.t x2 and (x0, x1, x2) }; // define the template function BoolCases in empty namespace -template // vector class, elements of type bool +template // vector class, elements of type bool bool BoolCases(bool optimize) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - ax[2] = 2.; - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = sin( ax[2] ) + ax[0] + ax[1] + ax[2]; - ay[1] = ax[0] * ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - if( optimize ) - f.optimize(); - - // sparsity pattern for diagonal of identity matrix - Vector r(n); - size_t i, j; - for(i = 0; i < n; i++) - r[ i ] = true; - - // compute sparsity pattern for H(x) = F_0^{(2)} (x) - Vector s(m); - for(i = 0; i < m; i++) - s[i] = false; - s[0] = true; - Vector h(n * n); - h = f.ForSparseHes(r, s); - - // check values - for(i = 0; i < n; i++) - 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) - for(i = 0; i < m; i++) - s[i] = false; - s[1] = true; - h = f.ForSparseHes(r, s); - - // check values - for(i = 0; i < n; i++) - for(j = 0; j < n; j++) - ok &= (h[ i * n + j ] == check_f1[ i * n + j ] ); + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + ax[2] = 2.; + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 2; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = sin( ax[2] ) + ax[0] + ax[1] + ax[2]; + ay[1] = ax[0] * ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + if( optimize ) + f.optimize(); + + // sparsity pattern for diagonal of identity matrix + Vector r(n); + size_t i, j; + for(i = 0; i < n; i++) + r[ i ] = true; + + // compute sparsity pattern for H(x) = F_0^{(2)} (x) + Vector s(m); + for(i = 0; i < m; i++) + s[i] = false; + s[0] = true; + Vector h(n * n); + h = f.ForSparseHes(r, s); + + // check values + for(i = 0; i < n; i++) + 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) + for(i = 0; i < m; i++) + s[i] = false; + s[1] = true; + h = f.ForSparseHes(r, s); + + // check values + for(i = 0; i < n; i++) + for(j = 0; j < n; j++) + ok &= (h[ i * n + j ] == check_f1[ i * n + j ] ); - return ok; + return ok; } // define the template function SetCases in empty namespace -template // vector class, elements of type std::set +template // vector class, elements of type std::set bool SetCases(bool optimize) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - ax[2] = 2.; - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = sin( ax[2] ); - ay[1] = ax[0] * ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - if( optimize ) - f.optimize(); - - // sparsity pattern for the diagonal of the identity matrix - Vector r(1); - size_t i; - for(i = 0; i < n; i++) - r[0].insert(i); - - // compute sparsity pattern for H(x) = F_0^{(2)} (x) - Vector s(1); - assert( s[0].empty() ); - s[0].insert(0); - Vector h(n); - h = f.ForSparseHes(r, s); - - // check values - std::set::iterator itr; - size_t j; - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - { bool found = h[i].find(j) != h[i].end(); - ok &= (found == check_f0[i * n + j]); - } - } - - // compute sparsity pattern for H(x) = F_1^{(2)} (x) - s[0].clear(); - assert( s[0].empty() ); - s[0].insert(1); - h = f.ForSparseHes(r, s); - - // check values - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - { bool found = h[i].find(j) != h[i].end(); - ok &= (found == check_f1[i * n + j]); - } - } + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + ax[2] = 2.; + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 2; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = sin( ax[2] ); + ay[1] = ax[0] * ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + if( optimize ) + f.optimize(); + + // sparsity pattern for the diagonal of the identity matrix + Vector r(1); + size_t i; + for(i = 0; i < n; i++) + r[0].insert(i); + + // compute sparsity pattern for H(x) = F_0^{(2)} (x) + Vector s(1); + assert( s[0].empty() ); + s[0].insert(0); + Vector h(n); + h = f.ForSparseHes(r, s); + + // check values + std::set::iterator itr; + size_t j; + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { bool found = h[i].find(j) != h[i].end(); + ok &= (found == check_f0[i * n + j]); + } + } + + // compute sparsity pattern for H(x) = F_1^{(2)} (x) + s[0].clear(); + assert( s[0].empty() ); + s[0].insert(1); + h = f.ForSparseHes(r, s); + + // check values + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { bool found = h[i].find(j) != h[i].end(); + ok &= (found == check_f1[i * n + j]); + } + } - return ok; + return ok; } } // End empty namespace # include # include bool for_sparse_hes(void) -{ bool ok = true; - for(size_t k = 0; k < 2; k++) - { bool optimize = bool(k); - - // Run with Vector equal to four different cases - // all of which are Simple Vectors with elements of type bool. - ok &= BoolCases< CppAD::vector >(optimize); - ok &= BoolCases< CppAD::vectorBool >(optimize); - ok &= BoolCases< std::vector >(optimize); - ok &= BoolCases< std::valarray >(optimize); - - // 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 >(optimize); - ok &= SetCases< std::vector >(optimize); - - // Do not use valarray because its element access in the const case - // returns a copy instead of a reference - // ok &= SetCases< std::valarray >(optimize); - } - return ok; +{ bool ok = true; + for(size_t k = 0; k < 2; k++) + { bool optimize = bool(k); + + // Run with Vector equal to four different cases + // all of which are Simple Vectors with elements of type bool. + ok &= BoolCases< CppAD::vector >(optimize); + ok &= BoolCases< CppAD::vectorBool >(optimize); + ok &= BoolCases< std::vector >(optimize); + ok &= BoolCases< std::valarray >(optimize); + + // 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 >(optimize); + ok &= SetCases< std::vector >(optimize); + + // Do not use valarray because its element access in the const case + // returns a copy instead of a reference + // ok &= SetCases< std::valarray >(optimize); + } + return ok; } diff -Nru cppad-2018.00.00.0/example/sparse/for_sparse_jac.cpp cppad-2019.02.00.0/example/sparse/for_sparse_jac.cpp --- cppad-2018.00.00.0/example/sparse/for_sparse_jac.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/for_sparse_jac.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,30 +1,28 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin for_sparse_jac.cpp$$ $spell - Jacobian - Jac - Dep - Cpp + Jacobian + Jac + Dep + Cpp $$ $section Forward Mode Jacobian Sparsity: Example and Test$$ -$mindex ForSparseJac sparsity$$ -$code $srcfile%example/sparse/for_sparse_jac.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -35,183 +33,183 @@ namespace { // ------------------------------------------------------------- // define the template function BoolCases -template // vector class, elements of type bool +template // vector class, elements of type bool bool BoolCases(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; - X[1] = 1.; - - // declare independent variables and start recording - CppAD::Independent(X); - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0]; - Y[1] = X[0] * X[1]; - Y[2] = X[1]; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // sparsity pattern for the identity matrix - Vector r(n * n); - size_t i, j; - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - r[ i * n + j ] = (i == j); - } - - // sparsity pattern for F'(x) - Vector s(m * n); - s = f.ForSparseJac(n, r); - - // check values - ok &= (s[ 0 * n + 0 ] == true); // Y[0] does depend on X[0] - ok &= (s[ 0 * n + 1 ] == false); // Y[0] does not depend on X[1] - ok &= (s[ 1 * n + 0 ] == true); // Y[1] does depend on X[0] - ok &= (s[ 1 * n + 1 ] == true); // Y[1] does depend on X[1] - ok &= (s[ 2 * n + 0 ] == false); // Y[2] does not depend on X[0] - ok &= (s[ 2 * n + 1 ] == true); // Y[2] does depend on X[1] - - // check that values are stored - ok &= (f.size_forward_bool() > 0); - ok &= (f.size_forward_set() == 0); - - // sparsity pattern for F'(x)^T, note R is the identity, so R^T = R - bool transpose = true; - Vector st(n * m); - st = f.ForSparseJac(n, r, transpose); - - // check values - ok &= (st[ 0 * m + 0 ] == true); // Y[0] does depend on X[0] - ok &= (st[ 1 * m + 0 ] == false); // Y[0] does not depend on X[1] - ok &= (st[ 0 * m + 1 ] == true); // Y[1] does depend on X[0] - ok &= (st[ 1 * m + 1 ] == true); // Y[1] does depend on X[1] - ok &= (st[ 0 * m + 2 ] == false); // Y[2] does not depend on X[0] - ok &= (st[ 1 * m + 2 ] == true); // Y[2] does depend on X[1] - - // check that values are stored - ok &= (f.size_forward_bool() > 0); - ok &= (f.size_forward_set() == 0); - - // free values from forward calculation - f.size_forward_bool(0); - ok &= (f.size_forward_bool() == 0); + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 0.; + X[1] = 1.; + + // declare independent variables and start recording + CppAD::Independent(X); + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0]; + Y[1] = X[0] * X[1]; + Y[2] = X[1]; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // sparsity pattern for the identity matrix + Vector r(n * n); + size_t i, j; + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + r[ i * n + j ] = (i == j); + } + + // sparsity pattern for F'(x) + Vector s(m * n); + s = f.ForSparseJac(n, r); + + // check values + ok &= (s[ 0 * n + 0 ] == true); // Y[0] does depend on X[0] + ok &= (s[ 0 * n + 1 ] == false); // Y[0] does not depend on X[1] + ok &= (s[ 1 * n + 0 ] == true); // Y[1] does depend on X[0] + ok &= (s[ 1 * n + 1 ] == true); // Y[1] does depend on X[1] + ok &= (s[ 2 * n + 0 ] == false); // Y[2] does not depend on X[0] + ok &= (s[ 2 * n + 1 ] == true); // Y[2] does depend on X[1] + + // check that values are stored + ok &= (f.size_forward_bool() > 0); + ok &= (f.size_forward_set() == 0); + + // sparsity pattern for F'(x)^T, note R is the identity, so R^T = R + bool transpose = true; + Vector st(n * m); + st = f.ForSparseJac(n, r, transpose); + + // check values + ok &= (st[ 0 * m + 0 ] == true); // Y[0] does depend on X[0] + ok &= (st[ 1 * m + 0 ] == false); // Y[0] does not depend on X[1] + ok &= (st[ 0 * m + 1 ] == true); // Y[1] does depend on X[0] + ok &= (st[ 1 * m + 1 ] == true); // Y[1] does depend on X[1] + ok &= (st[ 0 * m + 2 ] == false); // Y[2] does not depend on X[0] + ok &= (st[ 1 * m + 2 ] == true); // Y[2] does depend on X[1] + + // check that values are stored + ok &= (f.size_forward_bool() > 0); + ok &= (f.size_forward_set() == 0); + + // free values from forward calculation + f.size_forward_bool(0); + ok &= (f.size_forward_bool() == 0); - return ok; + return ok; } // define the template function SetCases -template // vector class, elements of type std::set +template // vector class, elements of type std::set bool SetCases(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; - X[1] = 1.; - - // declare independent variables and start recording - CppAD::Independent(X); - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0]; - Y[1] = X[0] * X[1]; - Y[2] = X[1]; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // sparsity pattern for the identity matrix - Vector r(n); - size_t i; - for(i = 0; i < n; i++) - { assert( r[i].empty() ); - r[i].insert(i); - } - - // sparsity pattern for F'(x) - Vector s(m); - s = f.ForSparseJac(n, r); - - // an interator to a standard set - std::set::iterator itr; - bool found; - - // Y[0] does depend on X[0] - 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 ); - // Y[1] does depend on X[0] - 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 ); - // Y[2] does not depend on X[0] - 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 ); - - // check that values are stored - ok &= (f.size_forward_set() > 0); - ok &= (f.size_forward_bool() == 0); - - - // sparsity pattern for F'(x)^T - bool transpose = true; - Vector st(n); - st = f.ForSparseJac(n, r, transpose); - - // Y[0] does depend on X[0] - 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 ); - // Y[1] does depend on X[0] - 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 ); - // Y[2] does not depend on X[0] - 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 ); - - // check that values are stored - ok &= (f.size_forward_set() > 0); - ok &= (f.size_forward_bool() == 0); + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 0.; + X[1] = 1.; + + // declare independent variables and start recording + CppAD::Independent(X); + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0]; + Y[1] = X[0] * X[1]; + Y[2] = X[1]; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // sparsity pattern for the identity matrix + Vector r(n); + size_t i; + for(i = 0; i < n; i++) + { assert( r[i].empty() ); + r[i].insert(i); + } + + // sparsity pattern for F'(x) + Vector s(m); + s = f.ForSparseJac(n, r); + + // an interator to a standard set + std::set::iterator itr; + bool found; + + // Y[0] does depend on X[0] + 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 ); + // Y[1] does depend on X[0] + 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 ); + // Y[2] does not depend on X[0] + 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 ); + + // check that values are stored + ok &= (f.size_forward_set() > 0); + ok &= (f.size_forward_bool() == 0); + + + // sparsity pattern for F'(x)^T + bool transpose = true; + Vector st(n); + st = f.ForSparseJac(n, r, transpose); + + // Y[0] does depend on X[0] + 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 ); + // Y[1] does depend on X[0] + 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 ); + // Y[2] does not depend on X[0] + 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 ); + + // check that values are stored + ok &= (f.size_forward_set() > 0); + ok &= (f.size_forward_bool() == 0); - return ok; + return ok; } } // End empty namespace # include # include bool ForSparseJac(void) -{ bool ok = true; - // Run with Vector equal to four different cases - // 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 >(); - - // 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 >(); - - // Do not use valarray because its element access in the const case - // returns a copy instead of a reference - // ok &= SetCases< std::valarray >(); +{ bool ok = true; + // Run with Vector equal to four different cases + // 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 >(); + + // 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 >(); + + // Do not use valarray because its element access in the const case + // returns a copy instead of a reference + // ok &= SetCases< std::valarray >(); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/makefile.am cppad-2019.02.00.0/example/sparse/makefile.am --- cppad-2018.00.00.0/example/sparse/makefile.am 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -15,11 +16,22 @@ # check_PROGRAMS = sparse # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) # -AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # +if CppAD_EIGEN +EIGEN_SRC_FILES = sparse2eigen.cpp +else +EIGEN_SRC_FILES = +endif +# +# BEGIN_SORT_THIS_LINE_PLUS_3 sparse_SOURCES = sparse.cpp \ + $(EIGEN_SRC_FILES) \ colpack_hes.cpp \ colpack_hessian.cpp \ colpack_jac.cpp \ @@ -35,7 +47,6 @@ rev_jac_sparsity.cpp \ rev_sparse_hes.cpp \ rev_sparse_jac.cpp \ - subgraph_reverse.cpp \ sparse_hes.cpp \ sparse_hessian.cpp \ sparse_jac_for.cpp \ @@ -43,10 +54,12 @@ sparse_jac_rev.cpp \ sparse_sub_hes.cpp \ sparsity_sub.cpp \ - sub_sparse_hes.cpp \ subgraph_hes2jac.cpp \ subgraph_jac_rev.cpp \ - subgraph_sparsity.cpp + subgraph_reverse.cpp \ + subgraph_sparsity.cpp \ + sub_sparse_hes.cpp +# END_SORT_THIS_LINE_MINUS_1 # test: check ./sparse diff -Nru cppad-2018.00.00.0/example/sparse/makefile.in cppad-2019.02.00.0/example/sparse/makefile.in --- cppad-2018.00.00.0/example/sparse/makefile.in 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -97,20 +97,32 @@ mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -am_sparse_OBJECTS = sparse.$(OBJEXT) colpack_hes.$(OBJEXT) \ - colpack_hessian.$(OBJEXT) colpack_jac.$(OBJEXT) \ - colpack_jacobian.$(OBJEXT) conj_grad.$(OBJEXT) \ - dependency.$(OBJEXT) for_hes_sparsity.$(OBJEXT) \ - for_jac_sparsity.$(OBJEXT) for_sparse_hes.$(OBJEXT) \ - for_sparse_jac.$(OBJEXT) rc_sparsity.$(OBJEXT) \ - rev_hes_sparsity.$(OBJEXT) rev_jac_sparsity.$(OBJEXT) \ - rev_sparse_hes.$(OBJEXT) rev_sparse_jac.$(OBJEXT) \ - subgraph_reverse.$(OBJEXT) sparse_hes.$(OBJEXT) \ +am__sparse_SOURCES_DIST = sparse.cpp sparse2eigen.cpp colpack_hes.cpp \ + colpack_hessian.cpp colpack_jac.cpp colpack_jacobian.cpp \ + conj_grad.cpp dependency.cpp for_hes_sparsity.cpp \ + for_jac_sparsity.cpp for_sparse_hes.cpp for_sparse_jac.cpp \ + rc_sparsity.cpp rev_hes_sparsity.cpp rev_jac_sparsity.cpp \ + rev_sparse_hes.cpp rev_sparse_jac.cpp sparse_hes.cpp \ + sparse_hessian.cpp sparse_jac_for.cpp sparse_jacobian.cpp \ + sparse_jac_rev.cpp sparse_sub_hes.cpp sparsity_sub.cpp \ + subgraph_hes2jac.cpp subgraph_jac_rev.cpp subgraph_reverse.cpp \ + subgraph_sparsity.cpp sub_sparse_hes.cpp +@CppAD_EIGEN_TRUE@am__objects_1 = sparse2eigen.$(OBJEXT) +am_sparse_OBJECTS = sparse.$(OBJEXT) $(am__objects_1) \ + colpack_hes.$(OBJEXT) colpack_hessian.$(OBJEXT) \ + colpack_jac.$(OBJEXT) colpack_jacobian.$(OBJEXT) \ + conj_grad.$(OBJEXT) dependency.$(OBJEXT) \ + for_hes_sparsity.$(OBJEXT) for_jac_sparsity.$(OBJEXT) \ + for_sparse_hes.$(OBJEXT) for_sparse_jac.$(OBJEXT) \ + rc_sparsity.$(OBJEXT) rev_hes_sparsity.$(OBJEXT) \ + rev_jac_sparsity.$(OBJEXT) rev_sparse_hes.$(OBJEXT) \ + rev_sparse_jac.$(OBJEXT) sparse_hes.$(OBJEXT) \ sparse_hessian.$(OBJEXT) sparse_jac_for.$(OBJEXT) \ sparse_jacobian.$(OBJEXT) sparse_jac_rev.$(OBJEXT) \ sparse_sub_hes.$(OBJEXT) sparsity_sub.$(OBJEXT) \ - sub_sparse_hes.$(OBJEXT) subgraph_hes2jac.$(OBJEXT) \ - subgraph_jac_rev.$(OBJEXT) subgraph_sparsity.$(OBJEXT) + subgraph_hes2jac.$(OBJEXT) subgraph_jac_rev.$(OBJEXT) \ + subgraph_reverse.$(OBJEXT) subgraph_sparsity.$(OBJEXT) \ + sub_sparse_hes.$(OBJEXT) sparse_OBJECTS = $(am_sparse_OBJECTS) sparse_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) @@ -143,7 +155,7 @@ am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = SOURCES = $(sparse_SOURCES) -DIST_SOURCES = $(sparse_SOURCES) +DIST_SOURCES = $(am__sparse_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -195,19 +207,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -280,10 +291,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -302,9 +311,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -327,8 +338,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -349,11 +358,20 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + +@CppAD_EIGEN_FALSE@EIGEN_SRC_FILES = +# # -AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) +@CppAD_EIGEN_TRUE@EIGEN_SRC_FILES = sparse2eigen.cpp # +# BEGIN_SORT_THIS_LINE_PLUS_3 sparse_SOURCES = sparse.cpp \ + $(EIGEN_SRC_FILES) \ colpack_hes.cpp \ colpack_hessian.cpp \ colpack_jac.cpp \ @@ -369,7 +387,6 @@ rev_jac_sparsity.cpp \ rev_sparse_hes.cpp \ rev_sparse_jac.cpp \ - subgraph_reverse.cpp \ sparse_hes.cpp \ sparse_hessian.cpp \ sparse_jac_for.cpp \ @@ -377,10 +394,11 @@ sparse_jac_rev.cpp \ sparse_sub_hes.cpp \ sparsity_sub.cpp \ - sub_sparse_hes.cpp \ subgraph_hes2jac.cpp \ subgraph_jac_rev.cpp \ - subgraph_sparsity.cpp + subgraph_reverse.cpp \ + subgraph_sparsity.cpp \ + sub_sparse_hes.cpp all: all-am @@ -445,6 +463,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rev_sparse_hes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rev_sparse_jac.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse2eigen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_hes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_hessian.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sparse_jac_for.Po@am__quote@ @@ -677,6 +696,7 @@ .PRECIOUS: makefile +# END_SORT_THIS_LINE_MINUS_1 # test: check ./sparse diff -Nru cppad-2018.00.00.0/example/sparse/rc_sparsity.cpp cppad-2019.02.00.0/example/sparse/rc_sparsity.cpp --- cppad-2018.00.00.0/example/sparse/rc_sparsity.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/rc_sparsity.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin rc_sparsity.cpp$$ $spell - Bool - Jacobians + Bool + Jacobians $$ $section Preferred Sparsity Patterns: Row and Column Indices: Example and Test$$ @@ -24,325 +25,323 @@ This became the preferred way to represent sparsity on $cref/2017-02-09/whats_new_17/02-09/$$. -$code $srcfile%example/sparse/rc_sparsity.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include namespace { - using CppAD::sparse_rc; - using CppAD::sparse_rcv; - using CppAD::NearEqual; - // - typedef CPPAD_TESTVECTOR(bool) b_vector; - typedef CPPAD_TESTVECTOR(size_t) s_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR( CppAD::AD ) a_vector; - // - double eps99 = 99.0 * std::numeric_limits::epsilon(); - // ----------------------------------------------------------------------- - // function f(x) that we are computing sparse results for - // ----------------------------------------------------------------------- - a_vector fun(const a_vector& x) - { size_t n = x.size(); - a_vector ret(n + 1); - for(size_t i = 0; i < n; i++) - { size_t j = (i + 1) % n; - ret[i] = x[i] * x[i] * x[j]; - } - ret[n] = 0.0; - return ret; - } - // ----------------------------------------------------------------------- - // Jacobian - // ----------------------------------------------------------------------- - bool check_jac( - const d_vector& x , - const sparse_rcv& subset ) - { bool ok = true; - size_t n = x.size(); - // - ok &= subset.nnz() == 2 * n; - const s_vector& row( subset.row() ); - const s_vector& col( subset.col() ); - const d_vector& val( subset.val() ); - s_vector row_major = subset.row_major(); - for(size_t i = 0; i < n; i++) - { size_t j = (i + 1) % n; - size_t k = 2 * i; - // - ok &= row[ row_major[k] ] == i; - ok &= row[ row_major[k+1] ] == i; - // - size_t ck = col[ row_major[k] ]; - size_t ckp = col[ row_major[k+1] ]; - double vk = val[ row_major[k] ]; - double vkp = val[ row_major[k+1] ]; - // - // put diagonal element first - if( j < i ) - { std::swap(ck, ckp); - std::swap(vk, vkp); - } - // diagonal element - ok &= ck == i; - ok &= NearEqual( vk, 2.0 * x[i] * x[j], eps99, eps99 ); - // off diagonal element - ok &= ckp == j; - ok &= NearEqual( vkp, x[i] * x[i], eps99, eps99 ); - } - return ok; - } - // Use forward mode for Jacobian and sparsity pattern - bool forward_jac(CppAD::ADFun& f) - { bool ok = true; - size_t n = f.Domain(); - // - // sparsity pattern for identity matrix - sparse_rc pattern_in(n, n, n); - for(size_t k = 0; k < n; k++) - pattern_in.set(k, k, k); - // - // sparsity pattern for Jacobian - bool transpose = false; - bool dependency = false; - bool internal_bool = false; - sparse_rc pattern_out; - f.for_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, pattern_out - ); - // - // compute entire Jacobian - size_t group_max = 1; - std::string coloring = "cppad"; - sparse_rcv subset( pattern_out ); - CppAD::sparse_jac_work work; - d_vector x(n); - for(size_t j = 0; j < n; j++) - x[j] = double(j + 2); - size_t n_sweep = f.sparse_jac_for( - group_max, x, subset, pattern_out, coloring, work - ); - // - // check Jacobian - ok &= check_jac(x, subset); - ok &= n_sweep == 2; - // - return ok; - } - // Use reverse mode for Jacobian and sparsity pattern - bool reverse_jac(CppAD::ADFun& f) - { bool ok = true; - size_t n = f.Domain(); - size_t m = f.Range(); - // - // sparsity pattern for identity matrix - sparse_rc pattern_in(m, m, m); - for(size_t k = 0; k < m; k++) - pattern_in.set(k, k, k); - // - // sparsity pattern for Jacobian - bool transpose = false; - bool dependency = false; - bool internal_bool = false; - sparse_rc pattern_out; - f.rev_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, pattern_out - ); - // - // compute entire Jacobian - std::string coloring = "cppad"; - sparse_rcv subset( pattern_out ); - CppAD::sparse_jac_work work; - d_vector x(n); - for(size_t j = 0; j < n; j++) - x[j] = double(j + 2); - size_t n_sweep = f.sparse_jac_rev( - x, subset, pattern_out, coloring, work - ); - // - // check Jacobian - ok &= check_jac(x, subset); - ok &= n_sweep == 2; - // - return ok; - } - // ------------------------------------------------------------------------ - // Hessian - // ------------------------------------------------------------------------ - bool check_hes( - size_t i , - const d_vector& x , - const sparse_rcv& subset ) - { bool ok = true; - size_t n = x.size(); - size_t j = (i + 1) % n; - // - ok &= subset.nnz() == 3; - const s_vector& row( subset.row() ); - const s_vector& col( subset.col() ); - const d_vector& val( subset.val() ); - s_vector row_major = subset.row_major(); - // - double v0 = val[ row_major[0] ]; - double v1 = val[ row_major[1] ]; - double v2 = val[ row_major[2] ]; - if( j < i ) - { ok &= row[ row_major[0] ] == j; - ok &= col[ row_major[0] ] == i; - ok &= NearEqual( v0, 2.0 * x[i], eps99, eps99 ); - // - ok &= row[ row_major[1] ] == i; - ok &= col[ row_major[1] ] == j; - ok &= NearEqual( v1, 2.0 * x[i], eps99, eps99 ); - // - ok &= row[ row_major[2] ] == i; - ok &= col[ row_major[2] ] == i; - ok &= NearEqual( v2, 2.0 * x[j], eps99, eps99 ); - } - else - { ok &= row[ row_major[0] ] == i; - ok &= col[ row_major[0] ] == i; - ok &= NearEqual( v0, 2.0 * x[j], eps99, eps99 ); - // - ok &= row[ row_major[1] ] == i; - ok &= col[ row_major[1] ] == j; - ok &= NearEqual( v1, 2.0 * x[i], eps99, eps99 ); - // - ok &= row[ row_major[2] ] == j; - ok &= col[ row_major[2] ] == i; - ok &= NearEqual( v2, 2.0 * x[i], eps99, eps99 ); - } - return ok; - } - // Use forward mode for Hessian and sparsity pattern - bool forward_hes(CppAD::ADFun& f) - { bool ok = true; - size_t n = f.Domain(); - size_t m = f.Range(); - // - b_vector select_domain(n); - for(size_t j = 0; j < n; j++) - select_domain[j] = true; - sparse_rc pattern_out; - // - for(size_t i = 0; i < m; i++) - { // select i-th component of range - b_vector select_range(m); - d_vector w(m); - for(size_t k = 0; k < m; k++) - { select_range[k] = k == i; - w[k] = 0.0; - if( k == i ) - w[k] = 1.0; - } - // - bool internal_bool = false; - f.for_hes_sparsity( - select_domain, select_range, internal_bool, pattern_out - ); - // - // compute Hessian for i-th component function - std::string coloring = "cppad.symmetric"; - sparse_rcv subset( pattern_out ); - CppAD::sparse_hes_work work; - d_vector x(n); - for(size_t j = 0; j < n; j++) - x[j] = double(j + 2); - size_t n_sweep = f.sparse_hes( - x, w, subset, pattern_out, coloring, work - ); - // - // check Hessian - if( i == n ) - ok &= subset.nnz() == 0; - else - { ok &= check_hes(i, x, subset); - ok &= n_sweep == 1; - } - } - return ok; - } - // Use reverse mode for Hessian and sparsity pattern - bool reverse_hes(CppAD::ADFun& f) - { bool ok = true; - size_t n = f.Domain(); - size_t m = f.Range(); - // - // n by n identity matrix - sparse_rc pattern_in(n, n, n); - for(size_t j = 0; j < n; j++) - pattern_in.set(j, j, j); - // - bool transpose = false; - bool dependency = false; - bool internal_bool = true; - sparse_rc pattern_out; - // - f.for_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, pattern_out - ); - // - for(size_t i = 0; i < m; i++) - { // select i-th component of range - b_vector select_range(m); - d_vector w(m); - for(size_t k = 0; k < m; k++) - { select_range[k] = k == i; - w[k] = 0.0; - if( k == i ) - w[k] = 1.0; - } - // - f.rev_hes_sparsity( - select_range, transpose, internal_bool, pattern_out - ); - // - // compute Hessian for i-th component function - std::string coloring = "cppad.symmetric"; - sparse_rcv subset( pattern_out ); - CppAD::sparse_hes_work work; - d_vector x(n); - for(size_t j = 0; j < n; j++) - x[j] = double(j + 2); - size_t n_sweep = f.sparse_hes( - x, w, subset, pattern_out, coloring, work - ); - // - // check Hessian - if( i == n ) - ok &= subset.nnz() == 0; - else - { ok &= check_hes(i, x, subset); - ok &= n_sweep == 1; - } - } - return ok; - } + using CppAD::sparse_rc; + using CppAD::sparse_rcv; + using CppAD::NearEqual; + // + typedef CPPAD_TESTVECTOR(bool) b_vector; + typedef CPPAD_TESTVECTOR(size_t) s_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR( CppAD::AD ) a_vector; + // + double eps99 = 99.0 * std::numeric_limits::epsilon(); + // ----------------------------------------------------------------------- + // function f(x) that we are computing sparse results for + // ----------------------------------------------------------------------- + a_vector fun(const a_vector& x) + { size_t n = x.size(); + a_vector ret(n + 1); + for(size_t i = 0; i < n; i++) + { size_t j = (i + 1) % n; + ret[i] = x[i] * x[i] * x[j]; + } + ret[n] = 0.0; + return ret; + } + // ----------------------------------------------------------------------- + // Jacobian + // ----------------------------------------------------------------------- + bool check_jac( + const d_vector& x , + const sparse_rcv& subset ) + { bool ok = true; + size_t n = x.size(); + // + ok &= subset.nnz() == 2 * n; + const s_vector& row( subset.row() ); + const s_vector& col( subset.col() ); + const d_vector& val( subset.val() ); + s_vector row_major = subset.row_major(); + for(size_t i = 0; i < n; i++) + { size_t j = (i + 1) % n; + size_t k = 2 * i; + // + ok &= row[ row_major[k] ] == i; + ok &= row[ row_major[k+1] ] == i; + // + size_t ck = col[ row_major[k] ]; + size_t ckp = col[ row_major[k+1] ]; + double vk = val[ row_major[k] ]; + double vkp = val[ row_major[k+1] ]; + // + // put diagonal element first + if( j < i ) + { std::swap(ck, ckp); + std::swap(vk, vkp); + } + // diagonal element + ok &= ck == i; + ok &= NearEqual( vk, 2.0 * x[i] * x[j], eps99, eps99 ); + // off diagonal element + ok &= ckp == j; + ok &= NearEqual( vkp, x[i] * x[i], eps99, eps99 ); + } + return ok; + } + // Use forward mode for Jacobian and sparsity pattern + bool forward_jac(CppAD::ADFun& f) + { bool ok = true; + size_t n = f.Domain(); + // + // sparsity pattern for identity matrix + sparse_rc pattern_in(n, n, n); + for(size_t k = 0; k < n; k++) + pattern_in.set(k, k, k); + // + // sparsity pattern for Jacobian + bool transpose = false; + bool dependency = false; + bool internal_bool = false; + sparse_rc pattern_out; + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + // + // compute entire Jacobian + size_t group_max = 1; + std::string coloring = "cppad"; + sparse_rcv subset( pattern_out ); + CppAD::sparse_jac_work work; + d_vector x(n); + for(size_t j = 0; j < n; j++) + x[j] = double(j + 2); + size_t n_sweep = f.sparse_jac_for( + group_max, x, subset, pattern_out, coloring, work + ); + // + // check Jacobian + ok &= check_jac(x, subset); + ok &= n_sweep == 2; + // + return ok; + } + // Use reverse mode for Jacobian and sparsity pattern + bool reverse_jac(CppAD::ADFun& f) + { bool ok = true; + size_t n = f.Domain(); + size_t m = f.Range(); + // + // sparsity pattern for identity matrix + sparse_rc pattern_in(m, m, m); + for(size_t k = 0; k < m; k++) + pattern_in.set(k, k, k); + // + // sparsity pattern for Jacobian + bool transpose = false; + bool dependency = false; + bool internal_bool = false; + sparse_rc pattern_out; + f.rev_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + // + // compute entire Jacobian + std::string coloring = "cppad"; + sparse_rcv subset( pattern_out ); + CppAD::sparse_jac_work work; + d_vector x(n); + for(size_t j = 0; j < n; j++) + x[j] = double(j + 2); + size_t n_sweep = f.sparse_jac_rev( + x, subset, pattern_out, coloring, work + ); + // + // check Jacobian + ok &= check_jac(x, subset); + ok &= n_sweep == 2; + // + return ok; + } + // ------------------------------------------------------------------------ + // Hessian + // ------------------------------------------------------------------------ + bool check_hes( + size_t i , + const d_vector& x , + const sparse_rcv& subset ) + { bool ok = true; + size_t n = x.size(); + size_t j = (i + 1) % n; + // + ok &= subset.nnz() == 3; + const s_vector& row( subset.row() ); + const s_vector& col( subset.col() ); + const d_vector& val( subset.val() ); + s_vector row_major = subset.row_major(); + // + double v0 = val[ row_major[0] ]; + double v1 = val[ row_major[1] ]; + double v2 = val[ row_major[2] ]; + if( j < i ) + { ok &= row[ row_major[0] ] == j; + ok &= col[ row_major[0] ] == i; + ok &= NearEqual( v0, 2.0 * x[i], eps99, eps99 ); + // + ok &= row[ row_major[1] ] == i; + ok &= col[ row_major[1] ] == j; + ok &= NearEqual( v1, 2.0 * x[i], eps99, eps99 ); + // + ok &= row[ row_major[2] ] == i; + ok &= col[ row_major[2] ] == i; + ok &= NearEqual( v2, 2.0 * x[j], eps99, eps99 ); + } + else + { ok &= row[ row_major[0] ] == i; + ok &= col[ row_major[0] ] == i; + ok &= NearEqual( v0, 2.0 * x[j], eps99, eps99 ); + // + ok &= row[ row_major[1] ] == i; + ok &= col[ row_major[1] ] == j; + ok &= NearEqual( v1, 2.0 * x[i], eps99, eps99 ); + // + ok &= row[ row_major[2] ] == j; + ok &= col[ row_major[2] ] == i; + ok &= NearEqual( v2, 2.0 * x[i], eps99, eps99 ); + } + return ok; + } + // Use forward mode for Hessian and sparsity pattern + bool forward_hes(CppAD::ADFun& f) + { bool ok = true; + size_t n = f.Domain(); + size_t m = f.Range(); + // + b_vector select_domain(n); + for(size_t j = 0; j < n; j++) + select_domain[j] = true; + sparse_rc pattern_out; + // + for(size_t i = 0; i < m; i++) + { // select i-th component of range + b_vector select_range(m); + d_vector w(m); + for(size_t k = 0; k < m; k++) + { select_range[k] = k == i; + w[k] = 0.0; + if( k == i ) + w[k] = 1.0; + } + // + bool internal_bool = false; + f.for_hes_sparsity( + select_domain, select_range, internal_bool, pattern_out + ); + // + // compute Hessian for i-th component function + std::string coloring = "cppad.symmetric"; + sparse_rcv subset( pattern_out ); + CppAD::sparse_hes_work work; + d_vector x(n); + for(size_t j = 0; j < n; j++) + x[j] = double(j + 2); + size_t n_sweep = f.sparse_hes( + x, w, subset, pattern_out, coloring, work + ); + // + // check Hessian + if( i == n ) + ok &= subset.nnz() == 0; + else + { ok &= check_hes(i, x, subset); + ok &= n_sweep == 1; + } + } + return ok; + } + // Use reverse mode for Hessian and sparsity pattern + bool reverse_hes(CppAD::ADFun& f) + { bool ok = true; + size_t n = f.Domain(); + size_t m = f.Range(); + // + // n by n identity matrix + sparse_rc pattern_in(n, n, n); + for(size_t j = 0; j < n; j++) + pattern_in.set(j, j, j); + // + bool transpose = false; + bool dependency = false; + bool internal_bool = true; + sparse_rc pattern_out; + // + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + // + for(size_t i = 0; i < m; i++) + { // select i-th component of range + b_vector select_range(m); + d_vector w(m); + for(size_t k = 0; k < m; k++) + { select_range[k] = k == i; + w[k] = 0.0; + if( k == i ) + w[k] = 1.0; + } + // + f.rev_hes_sparsity( + select_range, transpose, internal_bool, pattern_out + ); + // + // compute Hessian for i-th component function + std::string coloring = "cppad.symmetric"; + sparse_rcv subset( pattern_out ); + CppAD::sparse_hes_work work; + d_vector x(n); + for(size_t j = 0; j < n; j++) + x[j] = double(j + 2); + size_t n_sweep = f.sparse_hes( + x, w, subset, pattern_out, coloring, work + ); + // + // check Hessian + if( i == n ) + ok &= subset.nnz() == 0; + else + { ok &= check_hes(i, x, subset); + ok &= n_sweep == 1; + } + } + return ok; + } } // driver for all of the cases above bool rc_sparsity(void) -{ bool ok = true; - // - // record the funcion - size_t n = 20; - size_t m = n + 1; - a_vector x(n), y(m); - for(size_t j = 0; j < n; j++) - x[j] = CppAD::AD(j+1); - CppAD::Independent(x); - y = fun(x); - CppAD::ADFun f(x, y); - // - // run the example / tests - ok &= forward_jac(f); - ok &= reverse_jac(f); - ok &= forward_hes(f); - ok &= reverse_hes(f); - // - return ok; +{ bool ok = true; + // + // record the funcion + size_t n = 20; + size_t m = n + 1; + a_vector x(n), y(m); + for(size_t j = 0; j < n; j++) + x[j] = CppAD::AD(j+1); + CppAD::Independent(x); + y = fun(x); + CppAD::ADFun f(x, y); + // + // run the example / tests + ok &= forward_jac(f); + ok &= reverse_jac(f); + ok &= forward_hes(f); + ok &= reverse_hes(f); + // + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/rev_hes_sparsity.cpp cppad-2019.02.00.0/example/sparse/rev_hes_sparsity.cpp --- cppad-2018.00.00.0/example/sparse/rev_hes_sparsity.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/rev_hes_sparsity.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin rev_hes_sparsity.cpp$$ $spell - Hessian - Cpp + Hessian + Cpp $$ $section Reverse Mode Hessian Sparsity: Example and Test$$ -$code $srcfile%example/sparse/rev_hes_sparsity.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -29,85 +28,85 @@ # include bool rev_hes_sparsity(void) -{ bool ok = true; - using CppAD::AD; - typedef CPPAD_TESTVECTOR(size_t) SizeVector; - typedef CppAD::sparse_rc sparsity; - // - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - ax[2] = 2.; - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = sin( ax[2] ); - ay[1] = ax[0] * ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // sparsity pattern for the identity matrix - size_t nr = n; - size_t nc = n; - size_t nnz_in = n; - sparsity pattern_in(nr, nc, nnz_in); - for(size_t k = 0; k < nnz_in; k++) - { size_t r = k; - size_t c = k; - pattern_in.set(k, r, c); - } - // compute sparsity pattern for J(x) = F'(x) - bool transpose = false; - bool dependency = false; - bool internal_bool = false; - sparsity pattern_out; - f.for_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, pattern_out - ); - // - // compute sparsity pattern for H(x) = F_1''(x) - CPPAD_TESTVECTOR(bool) select_range(m); - select_range[0] = false; - select_range[1] = true; - f.rev_hes_sparsity( - select_range, transpose, internal_bool, pattern_out - ); - size_t nnz = pattern_out.nnz(); - ok &= nnz == 2; - ok &= pattern_out.nr() == n; - ok &= pattern_out.nc() == n; - { // check results - const SizeVector& row( pattern_out.row() ); - const SizeVector& col( pattern_out.col() ); - SizeVector row_major = pattern_out.row_major(); - // - ok &= row[ row_major[0] ] == 0 && col[ row_major[0] ] == 1; - ok &= row[ row_major[1] ] == 1 && col[ row_major[1] ] == 0; - } - // - // compute sparsity pattern for H(x) = F_0''(x) - select_range[0] = true; - select_range[1] = false; - f.rev_hes_sparsity( - select_range, transpose, internal_bool, pattern_out - ); - nnz = pattern_out.nnz(); - ok &= nnz == 1; - ok &= pattern_out.nr() == n; - ok &= pattern_out.nc() == n; - { // check results - const SizeVector& row( pattern_out.row() ); - const SizeVector& col( pattern_out.col() ); - // - ok &= row[0] == 2 && col[0] == 2; - } - return ok; +{ bool ok = true; + using CppAD::AD; + typedef CPPAD_TESTVECTOR(size_t) SizeVector; + typedef CppAD::sparse_rc sparsity; + // + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + ax[2] = 2.; + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 2; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = sin( ax[2] ); + ay[1] = ax[0] * ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // sparsity pattern for the identity matrix + size_t nr = n; + size_t nc = n; + size_t nnz_in = n; + sparsity pattern_in(nr, nc, nnz_in); + for(size_t k = 0; k < nnz_in; k++) + { size_t r = k; + size_t c = k; + pattern_in.set(k, r, c); + } + // compute sparsity pattern for J(x) = F'(x) + bool transpose = false; + bool dependency = false; + bool internal_bool = false; + sparsity pattern_out; + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + // + // compute sparsity pattern for H(x) = F_1''(x) + CPPAD_TESTVECTOR(bool) select_range(m); + select_range[0] = false; + select_range[1] = true; + f.rev_hes_sparsity( + select_range, transpose, internal_bool, pattern_out + ); + size_t nnz = pattern_out.nnz(); + ok &= nnz == 2; + ok &= pattern_out.nr() == n; + ok &= pattern_out.nc() == n; + { // check results + const SizeVector& row( pattern_out.row() ); + const SizeVector& col( pattern_out.col() ); + SizeVector row_major = pattern_out.row_major(); + // + ok &= row[ row_major[0] ] == 0 && col[ row_major[0] ] == 1; + ok &= row[ row_major[1] ] == 1 && col[ row_major[1] ] == 0; + } + // + // compute sparsity pattern for H(x) = F_0''(x) + select_range[0] = true; + select_range[1] = false; + f.rev_hes_sparsity( + select_range, transpose, internal_bool, pattern_out + ); + nnz = pattern_out.nnz(); + ok &= nnz == 1; + ok &= pattern_out.nr() == n; + ok &= pattern_out.nc() == n; + { // check results + const SizeVector& row( pattern_out.row() ); + const SizeVector& col( pattern_out.col() ); + // + ok &= row[0] == 2 && col[0] == 2; + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/rev_jac_sparsity.cpp cppad-2019.02.00.0/example/sparse/rev_jac_sparsity.cpp --- cppad-2018.00.00.0/example/sparse/rev_jac_sparsity.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/rev_jac_sparsity.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,28 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin rev_jac_sparsity.cpp$$ $spell - Jacobian - Jac - Dep - Cpp + Jacobian + Jac + Dep + Cpp $$ $section Reverse Mode Jacobian Sparsity: Example and Test$$ -$code $srcfile%example/sparse/rev_jac_sparsity.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,82 +30,82 @@ # include bool rev_jac_sparsity(void) -{ bool ok = true; - using CppAD::AD; - typedef CPPAD_TESTVECTOR(size_t) SizeVector; - typedef CppAD::sparse_rc sparsity; - // - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = ax[0]; - ay[1] = ax[0] * ax[1]; - ay[2] = ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // sparsity pattern for the identity matrix - size_t nr = m; - size_t nc = m; - size_t nnz_in = m; - sparsity pattern_in(nr, nc, nnz_in); - for(size_t k = 0; k < nnz_in; k++) - { size_t r = k; - size_t c = k; - pattern_in.set(k, r, c); - } - // compute sparsite pattern for J(x) = F'(x) - bool transpose = false; - bool dependency = false; - bool internal_bool = false; - sparsity pattern_out; - f.rev_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, pattern_out - ); - size_t nnz = pattern_out.nnz(); - ok &= nnz == 4; - ok &= pattern_out.nr() == m; - ok &= pattern_out.nc() == n; - { // check results - const SizeVector& row( pattern_out.row() ); - const SizeVector& col( pattern_out.col() ); - SizeVector col_major = pattern_out.col_major(); - // - ok &= row[ col_major[0] ] == 0 && col[ col_major[0] ] == 0; - ok &= row[ col_major[1] ] == 1 && col[ col_major[1] ] == 0; - ok &= row[ col_major[2] ] == 1 && col[ col_major[2] ] == 1; - ok &= row[ col_major[3] ] == 2 && col[ col_major[3] ] == 1; - } - // note that the transpose of the identity is the identity - transpose = true; - internal_bool = true; - f.rev_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, pattern_out - ); - nnz = pattern_out.nnz(); - ok &= nnz == 4; - ok &= pattern_out.nr() == n; - ok &= pattern_out.nc() == m; - { // check results - const SizeVector& row( pattern_out.row() ); - const SizeVector& col( pattern_out.col() ); - SizeVector row_major = pattern_out.row_major(); - // - ok &= col[ row_major[0] ] == 0 && row[ row_major[0] ] == 0; - ok &= col[ row_major[1] ] == 1 && row[ row_major[1] ] == 0; - ok &= col[ row_major[2] ] == 1 && row[ row_major[2] ] == 1; - ok &= col[ row_major[3] ] == 2 && row[ row_major[3] ] == 1; - } - return ok; +{ bool ok = true; + using CppAD::AD; + typedef CPPAD_TESTVECTOR(size_t) SizeVector; + typedef CppAD::sparse_rc sparsity; + // + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = ax[0]; + ay[1] = ax[0] * ax[1]; + ay[2] = ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // sparsity pattern for the identity matrix + size_t nr = m; + size_t nc = m; + size_t nnz_in = m; + sparsity pattern_in(nr, nc, nnz_in); + for(size_t k = 0; k < nnz_in; k++) + { size_t r = k; + size_t c = k; + pattern_in.set(k, r, c); + } + // compute sparsite pattern for J(x) = F'(x) + bool transpose = false; + bool dependency = false; + bool internal_bool = false; + sparsity pattern_out; + f.rev_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + size_t nnz = pattern_out.nnz(); + ok &= nnz == 4; + ok &= pattern_out.nr() == m; + ok &= pattern_out.nc() == n; + { // check results + const SizeVector& row( pattern_out.row() ); + const SizeVector& col( pattern_out.col() ); + SizeVector col_major = pattern_out.col_major(); + // + ok &= row[ col_major[0] ] == 0 && col[ col_major[0] ] == 0; + ok &= row[ col_major[1] ] == 1 && col[ col_major[1] ] == 0; + ok &= row[ col_major[2] ] == 1 && col[ col_major[2] ] == 1; + ok &= row[ col_major[3] ] == 2 && col[ col_major[3] ] == 1; + } + // note that the transpose of the identity is the identity + transpose = true; + internal_bool = true; + f.rev_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + nnz = pattern_out.nnz(); + ok &= nnz == 4; + ok &= pattern_out.nr() == n; + ok &= pattern_out.nc() == m; + { // check results + const SizeVector& row( pattern_out.row() ); + const SizeVector& col( pattern_out.col() ); + SizeVector row_major = pattern_out.row_major(); + // + ok &= col[ row_major[0] ] == 0 && row[ row_major[0] ] == 0; + ok &= col[ row_major[1] ] == 1 && row[ row_major[1] ] == 0; + ok &= col[ row_major[2] ] == 1 && row[ row_major[2] ] == 1; + ok &= col[ row_major[3] ] == 2 && row[ row_major[3] ] == 1; + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/rev_sparse_hes.cpp cppad-2019.02.00.0/example/sparse/rev_sparse_hes.cpp --- cppad-2018.00.00.0/example/sparse/rev_sparse_hes.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/rev_sparse_hes.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,31 +1,29 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin rev_sparse_hes.cpp$$ $spell - Hessian - Jac - Hes - Dep - Cpp + Hessian + Jac + Hes + Dep + Cpp $$ $section Reverse Mode Hessian Sparsity: Example and Test$$ -$mindex RevSparseHes sparsity$$ -$code $srcfile%example/sparse/rev_sparse_hes.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -36,192 +34,192 @@ // expected sparsity pattern bool check_f0[] = { - false, false, false, // partials w.r.t x0 and (x0, x1, x2) - false, false, false, // partials w.r.t x1 and (x0, x1, x2) - false, false, true // partials w.r.t x2 and (x0, x1, x2) + false, false, false, // partials w.r.t x0 and (x0, x1, x2) + false, false, false, // partials w.r.t x1 and (x0, x1, x2) + false, false, true // partials w.r.t x2 and (x0, x1, x2) }; bool check_f1[] = { - false, true, false, // partials w.r.t x0 and (x0, x1, x2) - true, false, false, // partials w.r.t x1 and (x0, x1, x2) - false, false, false // partials w.r.t x2 and (x0, x1, x2) + false, true, false, // partials w.r.t x0 and (x0, x1, x2) + true, false, false, // partials w.r.t x1 and (x0, x1, x2) + false, false, false // partials w.r.t x2 and (x0, x1, x2) }; // define the template function BoolCases in empty namespace -template // vector class, elements of type bool +template // vector class, elements of type bool bool BoolCases(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - ax[2] = 2.; - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = sin( ax[2] ); - ay[1] = ax[0] * ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // sparsity pattern for the identity matrix - Vector r(n * n); - size_t i, j; - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - r[ i * n + j ] = (i == j); - } - - // compute sparsity pattern for J(x) = F^{(1)} (x) - f.ForSparseJac(n, r); - - // compute sparsity pattern for H(x) = F_0^{(2)} (x) - Vector s(m); - for(i = 0; i < m; i++) - s[i] = false; - s[0] = true; - Vector h(n * n); - h = f.RevSparseHes(n, s); - - // check values - for(i = 0; i < n; i++) - 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) - for(i = 0; i < m; i++) - s[i] = false; - s[1] = true; - h = f.RevSparseHes(n, s); - - // check values - for(i = 0; i < n; i++) - for(j = 0; j < n; j++) - ok &= (h[ i * n + j ] == check_f1[ i * n + j ] ); - - // call that transposed the result - bool transpose = true; - h = f.RevSparseHes(n, s, transpose); - - // This h is symmetric, because R is symmetric, not really testing here - for(i = 0; i < n; i++) - for(j = 0; j < n; j++) - ok &= (h[ j * n + i ] == check_f1[ i * n + j ] ); + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + ax[2] = 2.; + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 2; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = sin( ax[2] ); + ay[1] = ax[0] * ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // sparsity pattern for the identity matrix + Vector r(n * n); + size_t i, j; + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + r[ i * n + j ] = (i == j); + } + + // compute sparsity pattern for J(x) = F^{(1)} (x) + f.ForSparseJac(n, r); + + // compute sparsity pattern for H(x) = F_0^{(2)} (x) + Vector s(m); + for(i = 0; i < m; i++) + s[i] = false; + s[0] = true; + Vector h(n * n); + h = f.RevSparseHes(n, s); + + // check values + for(i = 0; i < n; i++) + 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) + for(i = 0; i < m; i++) + s[i] = false; + s[1] = true; + h = f.RevSparseHes(n, s); + + // check values + for(i = 0; i < n; i++) + for(j = 0; j < n; j++) + ok &= (h[ i * n + j ] == check_f1[ i * n + j ] ); + + // call that transposed the result + bool transpose = true; + h = f.RevSparseHes(n, s, transpose); + + // This h is symmetric, because R is symmetric, not really testing here + for(i = 0; i < n; i++) + for(j = 0; j < n; j++) + ok &= (h[ j * n + i ] == check_f1[ i * n + j ] ); - return ok; + return ok; } // define the template function SetCases in empty namespace -template // vector class, elements of type std::set +template // vector class, elements of type std::set bool SetCases(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - ax[2] = 2.; - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = sin( ax[2] ); - ay[1] = ax[0] * ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // sparsity pattern for the identity matrix - Vector r(n); - size_t i; - for(i = 0; i < n; i++) - { assert( r[i].empty() ); - r[i].insert(i); - } - - // compute sparsity pattern for J(x) = F^{(1)} (x) - f.ForSparseJac(n, r); - - // compute sparsity pattern for H(x) = F_0^{(2)} (x) - Vector s(1); - assert( s[0].empty() ); - s[0].insert(0); - Vector h(n); - h = f.RevSparseHes(n, s); - - // check values - std::set::iterator itr; - size_t j; - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - { bool found = h[i].find(j) != h[i].end(); - ok &= (found == check_f0[i * n + j]); - } - } - - // compute sparsity pattern for H(x) = F_1^{(2)} (x) - s[0].clear(); - assert( s[0].empty() ); - s[0].insert(1); - h = f.RevSparseHes(n, s); - - // check values - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - { bool found = h[i].find(j) != h[i].end(); - ok &= (found == check_f1[i * n + j]); - } - } - - // call that transposed the result - bool transpose = true; - h = f.RevSparseHes(n, s, transpose); - - // This h is symmetric, because R is symmetric, not really testing here - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - { bool found = h[j].find(i) != h[j].end(); - ok &= (found == check_f1[i * n + j]); - } - } + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + ax[2] = 2.; + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 2; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = sin( ax[2] ); + ay[1] = ax[0] * ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // sparsity pattern for the identity matrix + Vector r(n); + size_t i; + for(i = 0; i < n; i++) + { assert( r[i].empty() ); + r[i].insert(i); + } + + // compute sparsity pattern for J(x) = F^{(1)} (x) + f.ForSparseJac(n, r); + + // compute sparsity pattern for H(x) = F_0^{(2)} (x) + Vector s(1); + assert( s[0].empty() ); + s[0].insert(0); + Vector h(n); + h = f.RevSparseHes(n, s); + + // check values + std::set::iterator itr; + size_t j; + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { bool found = h[i].find(j) != h[i].end(); + ok &= (found == check_f0[i * n + j]); + } + } + + // compute sparsity pattern for H(x) = F_1^{(2)} (x) + s[0].clear(); + assert( s[0].empty() ); + s[0].insert(1); + h = f.RevSparseHes(n, s); + + // check values + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { bool found = h[i].find(j) != h[i].end(); + ok &= (found == check_f1[i * n + j]); + } + } + + // call that transposed the result + bool transpose = true; + h = f.RevSparseHes(n, s, transpose); + + // This h is symmetric, because R is symmetric, not really testing here + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { bool found = h[j].find(i) != h[j].end(); + ok &= (found == check_f1[i * n + j]); + } + } - return ok; + return ok; } } // End empty namespace # include # include bool rev_sparse_hes(void) -{ bool ok = true; - // Run with Vector equal to four different cases - // 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 >(); - - // 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 >(); - - // Do not use valarray because its element access in the const case - // returns a copy instead of a reference - // ok &= SetCases< std::valarray >(); +{ bool ok = true; + // Run with Vector equal to four different cases + // 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 >(); + + // 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 >(); + + // Do not use valarray because its element access in the const case + // returns a copy instead of a reference + // ok &= SetCases< std::valarray >(); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/example/sparse/rev_sparse_jac.cpp cppad-2019.02.00.0/example/sparse/rev_sparse_jac.cpp --- cppad-2018.00.00.0/example/sparse/rev_sparse_jac.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/rev_sparse_jac.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,30 +1,28 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin rev_sparse_jac.cpp$$ $spell - Jacobian - Jac - Dep - Cpp + Jacobian + Jac + Dep + Cpp $$ $section Reverse Mode Jacobian Sparsity: Example and Test$$ -$mindex RevSparseJac sparsity$$ -$code $srcfile%example/sparse/rev_sparse_jac.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -33,162 +31,162 @@ # include namespace { // ------------------------------------------------------------- // define the template function BoolCases -template // vector class, elements of type bool +template // vector class, elements of type bool bool BoolCases(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = ax[0]; - ay[1] = ax[0] * ax[1]; - ay[2] = ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // sparsity pattern for the identity matrix - Vector r(m * m); - size_t i, j; - for(i = 0; i < m; i++) - { for(j = 0; j < m; j++) - r[ i * m + j ] = (i == j); - } - - // sparsity pattern for F'(x) - Vector s(m * n); - s = f.RevSparseJac(m, r); - - // check values - ok &= (s[ 0 * n + 0 ] == true); // y[0] does depend on x[0] - ok &= (s[ 0 * n + 1 ] == false); // y[0] does not depend on x[1] - ok &= (s[ 1 * n + 0 ] == true); // y[1] does depend on x[0] - ok &= (s[ 1 * n + 1 ] == true); // y[1] does depend on x[1] - ok &= (s[ 2 * n + 0 ] == false); // y[2] does not depend on x[0] - ok &= (s[ 2 * n + 1 ] == true); // y[2] does depend on x[1] - - // sparsity pattern for F'(x)^T, note R is the identity, so R^T = R - bool transpose = true; - Vector st(n * m); - st = f.RevSparseJac(m, r, transpose); - - // check values - ok &= (st[ 0 * m + 0 ] == true); // y[0] does depend on x[0] - ok &= (st[ 1 * m + 0 ] == false); // y[0] does not depend on x[1] - ok &= (st[ 0 * m + 1 ] == true); // y[1] does depend on x[0] - ok &= (st[ 1 * m + 1 ] == true); // y[1] does depend on x[1] - ok &= (st[ 0 * m + 2 ] == false); // y[2] does not depend on x[0] - ok &= (st[ 1 * m + 2 ] == true); // y[2] does depend on x[1] + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = ax[0]; + ay[1] = ax[0] * ax[1]; + ay[2] = ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // sparsity pattern for the identity matrix + Vector r(m * m); + size_t i, j; + for(i = 0; i < m; i++) + { for(j = 0; j < m; j++) + r[ i * m + j ] = (i == j); + } + + // sparsity pattern for F'(x) + Vector s(m * n); + s = f.RevSparseJac(m, r); + + // check values + ok &= (s[ 0 * n + 0 ] == true); // y[0] does depend on x[0] + ok &= (s[ 0 * n + 1 ] == false); // y[0] does not depend on x[1] + ok &= (s[ 1 * n + 0 ] == true); // y[1] does depend on x[0] + ok &= (s[ 1 * n + 1 ] == true); // y[1] does depend on x[1] + ok &= (s[ 2 * n + 0 ] == false); // y[2] does not depend on x[0] + ok &= (s[ 2 * n + 1 ] == true); // y[2] does depend on x[1] + + // sparsity pattern for F'(x)^T, note R is the identity, so R^T = R + bool transpose = true; + Vector st(n * m); + st = f.RevSparseJac(m, r, transpose); + + // check values + ok &= (st[ 0 * m + 0 ] == true); // y[0] does depend on x[0] + ok &= (st[ 1 * m + 0 ] == false); // y[0] does not depend on x[1] + ok &= (st[ 0 * m + 1 ] == true); // y[1] does depend on x[0] + ok &= (st[ 1 * m + 1 ] == true); // y[1] does depend on x[1] + ok &= (st[ 0 * m + 2 ] == false); // y[2] does not depend on x[0] + ok &= (st[ 1 * m + 2 ] == true); // y[2] does depend on x[1] - return ok; + return ok; } // define the template function SetCases -template // vector class, elements of type std::set +template // vector class, elements of type std::set bool SetCases(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = ax[0]; - ay[1] = ax[0] * ax[1]; - ay[2] = ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // sparsity pattern for the identity matrix - Vector r(m); - size_t i; - for(i = 0; i < m; i++) - { assert( r[i].empty() ); - r[i].insert(i); - } - - // sparsity pattern for F'(x) - Vector s(m); - s = f.RevSparseJac(m, r); - - // check values - bool found; - - // y[0] does depend on x[0] - 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); - // y[1] does depend on x[0] - 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); - // y[2] does not depend on x[0] - 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); - - // sparsity pattern for F'(x)^T - bool transpose = true; - Vector st(n); - st = f.RevSparseJac(m, r, transpose); - - // y[0] does depend on x[0] - 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); - // y[1] does depend on x[0] - 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); - // y[2] does not depend on x[0] - 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); + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = ax[0]; + ay[1] = ax[0] * ax[1]; + ay[2] = ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // sparsity pattern for the identity matrix + Vector r(m); + size_t i; + for(i = 0; i < m; i++) + { assert( r[i].empty() ); + r[i].insert(i); + } + + // sparsity pattern for F'(x) + Vector s(m); + s = f.RevSparseJac(m, r); + + // check values + bool found; + + // y[0] does depend on x[0] + 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); + // y[1] does depend on x[0] + 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); + // y[2] does not depend on x[0] + 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); + + // sparsity pattern for F'(x)^T + bool transpose = true; + Vector st(n); + st = f.RevSparseJac(m, r, transpose); + + // y[0] does depend on x[0] + 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); + // y[1] does depend on x[0] + 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); + // y[2] does not depend on x[0] + 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); - return ok; + return ok; } } // End empty namespace # include # include bool RevSparseJac(void) -{ bool ok = true; - // Run with Vector equal to four different cases - // 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 >(); - - - // 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 >(); - - // Do not use valarray because its element access in the const case - // returns a copy instead of a reference - // ok &= SetCases< std::valarray >(); +{ bool ok = true; + // Run with Vector equal to four different cases + // 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 >(); + + + // 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 >(); + + // Do not use valarray because its element access in the const case + // returns a copy instead of a reference + // ok &= SetCases< std::valarray >(); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/sparse2eigen.cpp cppad-2019.02.00.0/example/sparse/sparse2eigen.cpp --- cppad-2018.00.00.0/example/sparse/sparse2eigen.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/sparse2eigen.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,128 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin sparse2eigen.cpp$$ +$spell + Eigen + Cpp +$$ + +$section Converting CppAD Sparse Matrix to Eigen Format: Example and Test$$ + + +$srcfile%example/sparse/sparse2eigen.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ +# include +bool sparse2eigen(void) +{ bool ok = true; + // + typedef CppAD::vector s_vector; + typedef CppAD::vector d_vector; + typedef CppAD::sparse_rc sparse_rc; + typedef CppAD::sparse_rcv sparse_rcv; + // + // sparsity pattern + size_t nr = 3; + size_t nc = 4; + size_t nnz = 2 * nr; + sparse_rc pattern(nr, nc, nnz); + for(size_t i = 0; i < nr; i++) + { for(size_t j = i; j <= i + 1; j++) + { size_t k = i + j; + pattern.set(k, i, j); + } + } + // + // sparse matrix + sparse_rcv source(pattern); + for(size_t i = 0; i < nr; i++) + { for(size_t j = i; j <= i + 1; j++) + { size_t k = i + j; + double v = double(k) / 2.0; + source.set(k, v); + } + } + // + // example using row major order + { Eigen::SparseMatrix destination; + CppAD::sparse2eigen(source, destination); + // + typedef + Eigen::SparseMatrix::InnerIterator iterator; + // + // check result + const double* d_value = destination.valuePtr(); + size_t k = 0; + for(int i = 0; i < destination.outerSize(); ++i) + { + for(iterator itr(destination, i); itr; ++itr) + { // check row + ok &= itr.row() == i; + // + // check column + if( k % 2 == 0 ) + ok &= itr.col() == i; + else + ok &= itr.col() == (i+1); + // + // check value + ok &= itr.value() == double( itr.row() + itr.col() ) / 2.0; + ok &= itr.value() == d_value[k]; + // + ++k; + } + } + ok &= k == nnz; + } + // + // example using column major order + { Eigen::SparseMatrix destination; + CppAD::sparse2eigen(source, destination); + // + typedef + Eigen::SparseMatrix::InnerIterator iterator; + // + // check result + const double* d_value = destination.valuePtr(); + size_t k = 0; + for(int j = 0; j < destination.outerSize(); ++j) + { for(iterator itr(destination, j); itr; ++itr) + { // check column + ok &= itr.col() == j; + // + // check row + if( j == 0 ) + { assert( k == 0 ); + ok &= itr.row() == 0; + } + else if( k % 2 == 1 ) + ok &= itr.row() == j - 1; + else + ok &= itr.row() == j; + // + // check value + ok &= itr.value() == double( itr.row() + itr.col() ) / 2.0; + ok &= itr.value() == d_value[k]; + // + ++k; + } + } + ok &= k == nnz; + } + // + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/example/sparse/sparse.cpp cppad-2019.02.00.0/example/sparse/sparse.cpp --- cppad-2018.00.00.0/example/sparse/sparse.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/sparse.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // CPPAD_HAS_* defines # include @@ -41,6 +42,7 @@ extern bool rev_jac_sparsity(void); extern bool rev_sparse_hes(void); extern bool RevSparseJac(void); +extern bool sparse2eigen(void); extern bool sparse_hessian(void); extern bool sparse_hes(void); extern bool sparse_jac_for(void); @@ -57,50 +59,53 @@ // main program that runs all the tests int main(void) -{ std::string group = "example/sparse"; - size_t width = 20; - CppAD::test_boolofvoid Run(group, width); - - // This line is used by test_one.sh - - // BEGIN_SORT_THIS_LINE_PLUS_2 - // external compiled tests - Run( conj_grad, "conj_grad" ); - Run( dependency, "dependency" ); - Run( for_hes_sparsity, "for_hes_sparsity" ); - Run( for_jac_sparsity, "for_jac_sparsity" ); - Run( for_sparse_hes, "for_sparse_hes" ); - Run( ForSparseJac, "ForSparseJac" ); - Run( rc_sparsity, "rc_sparsity" ); - Run( rev_hes_sparsity, "rev_hes_sparsity" ); - Run( rev_jac_sparsity, "rev_jac_sparsity" ); - Run( rev_sparse_hes, "rev_sparse_hes" ); - Run( RevSparseJac, "RevSparseJac" ); - Run( sparse_hessian, "sparse_hessian" ); - Run( sparse_hes, "sparse_hes" ); - Run( sparse_jac_for, "sparse_jac_for" ); - Run( sparse_jacobian, "sparse_jacobian" ); - Run( sparse_jac_rev, "sparse_jac_rev" ); - Run( sparse_sub_hes, "sparse_sub_hes" ); - Run( sparsity_sub, "sparsity_sub" ); - Run( subgraph_hes2jac, "subgraph_hes2jac" ); - Run( subgraph_jac_rev, "subgraph_jac_rev" ); - Run( subgraph_reverse, "reverse_subgraph"); - Run( subgraph_sparsity, "subgraph_sparsity" ); - Run( sub_sparse_hes, "sub_sparse_hes" ); - // END_SORT_THIS_LINE_MINUS_1 - // +{ std::string group = "example/sparse"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + // BEGIN_SORT_THIS_LINE_PLUS_2 + // external compiled tests + Run( conj_grad, "conj_grad" ); + Run( dependency, "dependency" ); + Run( for_hes_sparsity, "for_hes_sparsity" ); + Run( for_jac_sparsity, "for_jac_sparsity" ); + Run( for_sparse_hes, "for_sparse_hes" ); + Run( ForSparseJac, "ForSparseJac" ); + Run( rc_sparsity, "rc_sparsity" ); + Run( rev_hes_sparsity, "rev_hes_sparsity" ); + Run( rev_jac_sparsity, "rev_jac_sparsity" ); + Run( rev_sparse_hes, "rev_sparse_hes" ); + Run( RevSparseJac, "RevSparseJac" ); + Run( sparse_hessian, "sparse_hessian" ); + Run( sparse_hes, "sparse_hes" ); + Run( sparse_jac_for, "sparse_jac_for" ); + Run( sparse_jacobian, "sparse_jacobian" ); + Run( sparse_jac_rev, "sparse_jac_rev" ); + Run( sparse_sub_hes, "sparse_sub_hes" ); + Run( sparsity_sub, "sparsity_sub" ); + Run( subgraph_hes2jac, "subgraph_hes2jac" ); + Run( subgraph_jac_rev, "subgraph_jac_rev" ); + Run( subgraph_reverse, "reverse_subgraph"); + Run( subgraph_sparsity, "subgraph_sparsity" ); + Run( sub_sparse_hes, "sub_sparse_hes" ); + // END_SORT_THIS_LINE_MINUS_1 + // # if CPPAD_HAS_COLPACK - Run( colpack_jac, "colpack_jac" ); - Run( colpack_jacobian, "colpack_jacobian" ); - Run( colpack_hes, "colpack_hes" ); - Run( colpack_hessian, "colpack_hessian" ); + Run( colpack_jac, "colpack_jac" ); + Run( colpack_jacobian, "colpack_jacobian" ); + Run( colpack_hes, "colpack_hes" ); + Run( colpack_hessian, "colpack_hessian" ); +# endif +# if CPPAD_HAS_EIGEN + Run( sparse2eigen, "sparse2eigen" ); # endif - // - // check for memory leak - bool memory_ok = CppAD::thread_alloc::free_all(); - // print summary at end - bool ok = Run.summary(memory_ok); - // - return static_cast( ! ok ); + // + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); } diff -Nru cppad-2018.00.00.0/example/sparse/sparse_hes.cpp cppad-2019.02.00.0/example/sparse/sparse_hes.cpp --- cppad-2018.00.00.0/example/sparse/sparse_hes.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/sparse_hes.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,111 +1,110 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sparse_hes.cpp$$ $spell - Cpp - Hessian + Cpp + Hessian $$ $section Computing Sparse Hessian: Example and Test$$ -$code $srcfile%example/sparse/sparse_hes.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include bool sparse_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_TESTVECTOR(size_t) s_vector; - typedef CPPAD_TESTVECTOR(bool) b_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] = a_x[0] * a_x[1]; - for(size_t j = 0; j < n; j++) - a_y[0] += a_x[j] * 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); - // - // new value for the independent variable vector, and weighting vector - d_vector w(m), x(n); - for(size_t j = 0; j < n; j++) - x[j] = double(j); - w[0] = 1.0; - // - // vector used to check the value of the hessian - d_vector check(n * n); - size_t ij = 0 * n + 1; - for(ij = 0; ij < n * n; ij++) - check[ij] = 0.0; - ij = 0 * n + 1; - check[ij] = 1.0; - ij = 1 * n + 0; - check[ij] = 1.0 ; - for(size_t j = 0; j < n; j++) - { ij = j * n + j; - check[ij] = 6.0 * x[j]; - } - // - // compute Hessian sparsity pattern - b_vector select_domain(n), select_range(m); - for(size_t j = 0; j < n; j++) - select_domain[j] = true; - select_range[0] = true; - // - CppAD::sparse_rc hes_pattern; - bool internal_bool = false; - f.for_hes_sparsity( - select_domain, select_range, internal_bool, hes_pattern - ); - // - // compute entire sparse Hessian (really only need lower triangle) - CppAD::sparse_rcv subset( hes_pattern ); - CppAD::sparse_hes_work work; - std::string coloring = "cppad.symmetric"; - size_t n_sweep = f.sparse_hes(x, w, subset, hes_pattern, coloring, work); - ok &= n_sweep == 2; - // - const s_vector row( subset.row() ); - const s_vector col( subset.col() ); - const d_vector val( subset.val() ); - size_t nnz = subset.nnz(); - ok &= nnz == n + 2; - for(size_t k = 0; k < nnz; k++) - { ij = row[k] * n + col[k]; - ok &= val[k] == check[ij]; - } - return ok; +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + // + typedef CPPAD_TESTVECTOR(AD) a_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR(size_t) s_vector; + typedef CPPAD_TESTVECTOR(bool) b_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] = a_x[0] * a_x[1]; + for(size_t j = 0; j < n; j++) + a_y[0] += a_x[j] * 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); + // + // new value for the independent variable vector, and weighting vector + d_vector w(m), x(n); + for(size_t j = 0; j < n; j++) + x[j] = double(j); + w[0] = 1.0; + // + // vector used to check the value of the hessian + d_vector check(n * n); + size_t ij = 0 * n + 1; + for(ij = 0; ij < n * n; ij++) + check[ij] = 0.0; + ij = 0 * n + 1; + check[ij] = 1.0; + ij = 1 * n + 0; + check[ij] = 1.0 ; + for(size_t j = 0; j < n; j++) + { ij = j * n + j; + check[ij] = 6.0 * x[j]; + } + // + // compute Hessian sparsity pattern + b_vector select_domain(n), select_range(m); + for(size_t j = 0; j < n; j++) + select_domain[j] = true; + select_range[0] = true; + // + CppAD::sparse_rc hes_pattern; + bool internal_bool = false; + f.for_hes_sparsity( + select_domain, select_range, internal_bool, hes_pattern + ); + // + // compute entire sparse Hessian (really only need lower triangle) + CppAD::sparse_rcv subset( hes_pattern ); + CppAD::sparse_hes_work work; + std::string coloring = "cppad.symmetric"; + size_t n_sweep = f.sparse_hes(x, w, subset, hes_pattern, coloring, work); + ok &= n_sweep == 2; + // + const s_vector row( subset.row() ); + const s_vector col( subset.col() ); + const d_vector val( subset.val() ); + size_t nnz = subset.nnz(); + ok &= nnz == n + 2; + for(size_t k = 0; k < nnz; k++) + { ij = row[k] * n + col[k]; + ok &= val[k] == check[ij]; + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/sparse_hessian.cpp cppad-2019.02.00.0/example/sparse/sparse_hessian.cpp --- cppad-2018.00.00.0/example/sparse/sparse_hessian.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/sparse_hessian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,171 +1,170 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sparse_hessian.cpp$$ $spell - Cpp - Hessian + Cpp + Hessian $$ $section Sparse Hessian: Example and Test$$ -$code $srcfile%example/sparse/sparse_hessian.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include bool sparse_hessian(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t i, j, k, ell; - typedef CPPAD_TESTVECTOR(AD) a_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR(size_t) i_vector; - typedef CPPAD_TESTVECTOR(bool) b_vector; - typedef CPPAD_TESTVECTOR(std::set) s_vector; - double eps = 10. * CppAD::numeric_limits::epsilon(); - - // domain space vector - size_t n = 12; // must be greater than or equal 3; see n_sweep below - 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); - - // range space vector - size_t m = 1; - a_vector a_y(m); - a_y[0] = a_x[0]*a_x[1]; - for(j = 0; j < n; j++) - a_y[0] += a_x[j] * 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); - - // new value for the independent variable vector, and weighting vector - d_vector w(m), x(n); - for(j = 0; j < n; j++) - x[j] = double(j); - w[0] = 1.0; - - // vector used to check the value of the hessian - d_vector check(n * n); - for(ell = 0; ell < n * n; ell++) - check[ell] = 0.0; - ell = 0 * n + 1; - check[ell] = 1.0; - ell = 1 * n + 0; - check[ell] = 1.0 ; - for(j = 0; j < n; j++) - { ell = j * n + j; - check[ell] = 6.0 * x[j]; - } - - // ------------------------------------------------------------------- - // second derivative of y[0] w.r.t x - d_vector hes(n * n); - hes = f.SparseHessian(x, w); - for(ell = 0; ell < n * n; ell++) - ok &= NearEqual(w[0] * check[ell], hes[ell], eps, eps ); - - // -------------------------------------------------------------------- - // example using vectors of bools to compute sparsity pattern for Hessian - b_vector r_bool(n * n); - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - r_bool[i * n + j] = false; - r_bool[i * n + i] = true; - } - f.ForSparseJac(n, r_bool); - // - b_vector s_bool(m); - for(i = 0; i < m; i++) - s_bool[i] = w[i] != 0; - b_vector p_bool = f.RevSparseHes(n, s_bool); - - hes = f.SparseHessian(x, w, p_bool); - for(ell = 0; ell < n * n; ell++) - ok &= NearEqual(w[0] * check[ell], hes[ell], eps, eps ); - - // -------------------------------------------------------------------- - // example using vectors of sets to compute sparsity pattern for Hessian - s_vector r_set(n); - for(i = 0; i < n; i++) - r_set[i].insert(i); - f.ForSparseJac(n, r_set); - // - s_vector s_set(m); - for(i = 0; i < m; i++) - if( w[i] != 0. ) - s_set[0].insert(i); - s_vector p_set = f.RevSparseHes(n, s_set); - - // example passing sparsity pattern to SparseHessian - hes = f.SparseHessian(x, w, p_set); - for(ell = 0; ell < n * n; ell++) - ok &= NearEqual(w[0] * check[ell], hes[ell], eps, eps ); - - // -------------------------------------------------------------------- - // use row and column indices to specify upper triangle of - // non-zero elements of Hessian - size_t K = n + 1; - i_vector row(K), col(K); - hes.resize(K); - k = 0; - for(j = 0; j < n; j++) - { // diagonal of Hessian - row[k] = j; - col[k] = j; - k++; - } - // only off diagonal non-zero elemenet in upper triangle - row[k] = 0; - col[k] = 1; - k++; - ok &= k == K; - CppAD::sparse_hessian_work work; - - // can use p_set or p_bool. - size_t n_sweep = f.SparseHessian(x, w, p_set, 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; - - // now recompute at a different x and w (using work from previous call - w[0] = 2.0; - x[1] = 0.5; - ell = 1 * n + 1; - check[ell] = 6.0 * x[1]; - 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; +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t i, j, k, ell; + typedef CPPAD_TESTVECTOR(AD) a_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR(size_t) i_vector; + typedef CPPAD_TESTVECTOR(bool) b_vector; + typedef CPPAD_TESTVECTOR(std::set) s_vector; + double eps = 10. * CppAD::numeric_limits::epsilon(); + + // domain space vector + size_t n = 12; // must be greater than or equal 3; see n_sweep below + 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); + + // range space vector + size_t m = 1; + a_vector a_y(m); + a_y[0] = a_x[0]*a_x[1]; + for(j = 0; j < n; j++) + a_y[0] += a_x[j] * 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); + + // new value for the independent variable vector, and weighting vector + d_vector w(m), x(n); + for(j = 0; j < n; j++) + x[j] = double(j); + w[0] = 1.0; + + // vector used to check the value of the hessian + d_vector check(n * n); + for(ell = 0; ell < n * n; ell++) + check[ell] = 0.0; + ell = 0 * n + 1; + check[ell] = 1.0; + ell = 1 * n + 0; + check[ell] = 1.0 ; + for(j = 0; j < n; j++) + { ell = j * n + j; + check[ell] = 6.0 * x[j]; + } + + // ------------------------------------------------------------------- + // second derivative of y[0] w.r.t x + d_vector hes(n * n); + hes = f.SparseHessian(x, w); + for(ell = 0; ell < n * n; ell++) + ok &= NearEqual(w[0] * check[ell], hes[ell], eps, eps ); + + // -------------------------------------------------------------------- + // example using vectors of bools to compute sparsity pattern for Hessian + b_vector r_bool(n * n); + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + r_bool[i * n + j] = false; + r_bool[i * n + i] = true; + } + f.ForSparseJac(n, r_bool); + // + b_vector s_bool(m); + for(i = 0; i < m; i++) + s_bool[i] = w[i] != 0; + b_vector p_bool = f.RevSparseHes(n, s_bool); + + hes = f.SparseHessian(x, w, p_bool); + for(ell = 0; ell < n * n; ell++) + ok &= NearEqual(w[0] * check[ell], hes[ell], eps, eps ); + + // -------------------------------------------------------------------- + // example using vectors of sets to compute sparsity pattern for Hessian + s_vector r_set(n); + for(i = 0; i < n; i++) + r_set[i].insert(i); + f.ForSparseJac(n, r_set); + // + s_vector s_set(m); + for(i = 0; i < m; i++) + if( w[i] != 0. ) + s_set[0].insert(i); + s_vector p_set = f.RevSparseHes(n, s_set); + + // example passing sparsity pattern to SparseHessian + hes = f.SparseHessian(x, w, p_set); + for(ell = 0; ell < n * n; ell++) + ok &= NearEqual(w[0] * check[ell], hes[ell], eps, eps ); + + // -------------------------------------------------------------------- + // use row and column indices to specify upper triangle of + // non-zero elements of Hessian + size_t K = n + 1; + i_vector row(K), col(K); + hes.resize(K); + k = 0; + for(j = 0; j < n; j++) + { // diagonal of Hessian + row[k] = j; + col[k] = j; + k++; + } + // only off diagonal non-zero elemenet in upper triangle + row[k] = 0; + col[k] = 1; + k++; + ok &= k == K; + CppAD::sparse_hessian_work work; + + // can use p_set or p_bool. + size_t n_sweep = f.SparseHessian(x, w, p_set, 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; + + // now recompute at a different x and w (using work from previous call + w[0] = 2.0; + x[1] = 0.5; + ell = 1 * n + 1; + check[ell] = 6.0 * x[1]; + 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/sparse_jac_for.cpp cppad-2019.02.00.0/example/sparse/sparse_jac_for.cpp --- cppad-2018.00.00.0/example/sparse/sparse_jac_for.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/sparse_jac_for.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,157 +1,156 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sparse_jac_for.cpp$$ $spell - Cpp - Jacobian + Cpp + Jacobian $$ $section Computing Sparse Jacobian Using Forward Mode: Example and Test$$ -$code $srcfile%example/sparse/sparse_jac_for.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include bool sparse_jac_for(void) -{ bool ok = true; - // - using CppAD::AD; - using CppAD::NearEqual; - using CppAD::sparse_rc; - using CppAD::sparse_rcv; - // - typedef CPPAD_TESTVECTOR(AD) a_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR(size_t) s_vector; - // - // domain space vector - size_t n = 3; - 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); - // - size_t m = 4; - a_vector a_y(m); - a_y[0] = a_x[0] + a_x[2]; - a_y[1] = a_x[0] + a_x[2]; - a_y[2] = a_x[1] + a_x[2]; - a_y[3] = a_x[1] + a_x[2] * a_x[2] / 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(size_t j = 0; j < n; j++) - x[j] = double(j); - /* - [ 1 0 1 ] - J(x) = [ 1 0 1 ] - [ 0 1 1 ] - [ 0 1 x_2 ] - */ - d_vector check(m * n); - // - // column-major order values of J(x) - size_t nnz = 8; - s_vector check_row(nnz), check_col(nnz); - d_vector check_val(nnz); - for(size_t k = 0; k < nnz; k++) - { // check_val - if( k < 7 ) - check_val[k] = 1.0; - else - check_val[k] = x[2]; - // - // check_row and check_col - check_row[k] = k; - if( k < 2 ) - check_col[k] = 0; - else if( k < 4 ) - check_col[k] = 1; - else - { check_col[k] = 2; - check_row[k] = k - 4; - } - } - // - // n by n identity matrix sparsity - sparse_rc pattern_in; - pattern_in.resize(n, n, n); - for(size_t k = 0; k < n; k++) - pattern_in.set(k, k, k); - // - // sparsity for J(x) - bool transpose = false; - bool dependency = false; - bool internal_bool = true; - sparse_rc pattern_jac; - f.for_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, pattern_jac - ); - // - // compute entire forward mode Jacobian - sparse_rcv subset( pattern_jac ); - CppAD::sparse_jac_work work; - std::string coloring = "cppad"; - size_t group_max = 10; - size_t n_sweep = f.sparse_jac_for( - group_max, x, subset, pattern_jac, coloring, work - ); - ok &= n_sweep == 2; - // - const s_vector row( subset.row() ); - const s_vector col( subset.col() ); - const d_vector val( subset.val() ); - s_vector col_major = subset.col_major(); - ok &= subset.nnz() == nnz; - for(size_t k = 0; k < nnz; k++) - { ok &= row[ col_major[k] ] == check_row[k]; - ok &= col[ col_major[k] ] == check_col[k]; - ok &= val[ col_major[k] ] == check_val[k]; - } - // compute non-zero in row 3 only - sparse_rc pattern_row3; - pattern_row3.resize(m, n, 2); // nr = m, nc = n, nnz = 2 - pattern_row3.set(0, 3, 1); // row[0] = 3, col[0] = 1 - pattern_row3.set(1, 3, 2); // row[1] = 3, col[1] = 2 - sparse_rcv subset_row3( pattern_row3 ); - work.clear(); - n_sweep = f.sparse_jac_for( - group_max, x, subset_row3, pattern_jac, coloring, work - ); - ok &= n_sweep == 2; - // - const s_vector row_row3( subset_row3.row() ); - const s_vector col_row3( subset_row3.col() ); - const d_vector val_row3( subset_row3.val() ); - ok &= subset_row3.nnz() == 2; - // - ok &= row_row3[0] == 3; - ok &= col_row3[0] == 1; - ok &= val_row3[0] == 1.0; - // - ok &= row_row3[1] == 3; - ok &= col_row3[1] == 2; - ok &= val_row3[1] == x[2]; - // - return ok; +{ bool ok = true; + // + using CppAD::AD; + using CppAD::NearEqual; + using CppAD::sparse_rc; + using CppAD::sparse_rcv; + // + typedef CPPAD_TESTVECTOR(AD) a_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR(size_t) s_vector; + // + // domain space vector + size_t n = 3; + 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); + // + size_t m = 4; + a_vector a_y(m); + a_y[0] = a_x[0] + a_x[2]; + a_y[1] = a_x[0] + a_x[2]; + a_y[2] = a_x[1] + a_x[2]; + a_y[3] = a_x[1] + a_x[2] * a_x[2] / 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(size_t j = 0; j < n; j++) + x[j] = double(j); + /* + [ 1 0 1 ] + J(x) = [ 1 0 1 ] + [ 0 1 1 ] + [ 0 1 x_2 ] + */ + d_vector check(m * n); + // + // column-major order values of J(x) + size_t nnz = 8; + s_vector check_row(nnz), check_col(nnz); + d_vector check_val(nnz); + for(size_t k = 0; k < nnz; k++) + { // check_val + if( k < 7 ) + check_val[k] = 1.0; + else + check_val[k] = x[2]; + // + // check_row and check_col + check_row[k] = k; + if( k < 2 ) + check_col[k] = 0; + else if( k < 4 ) + check_col[k] = 1; + else + { check_col[k] = 2; + check_row[k] = k - 4; + } + } + // + // n by n identity matrix sparsity + sparse_rc pattern_in; + pattern_in.resize(n, n, n); + for(size_t k = 0; k < n; k++) + pattern_in.set(k, k, k); + // + // sparsity for J(x) + bool transpose = false; + bool dependency = false; + bool internal_bool = true; + sparse_rc pattern_jac; + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_jac + ); + // + // compute entire forward mode Jacobian + sparse_rcv subset( pattern_jac ); + CppAD::sparse_jac_work work; + std::string coloring = "cppad"; + size_t group_max = 10; + size_t n_sweep = f.sparse_jac_for( + group_max, x, subset, pattern_jac, coloring, work + ); + ok &= n_sweep == 2; + // + const s_vector row( subset.row() ); + const s_vector col( subset.col() ); + const d_vector val( subset.val() ); + s_vector col_major = subset.col_major(); + ok &= subset.nnz() == nnz; + for(size_t k = 0; k < nnz; k++) + { ok &= row[ col_major[k] ] == check_row[k]; + ok &= col[ col_major[k] ] == check_col[k]; + ok &= val[ col_major[k] ] == check_val[k]; + } + // compute non-zero in row 3 only + sparse_rc pattern_row3; + pattern_row3.resize(m, n, 2); // nr = m, nc = n, nnz = 2 + pattern_row3.set(0, 3, 1); // row[0] = 3, col[0] = 1 + pattern_row3.set(1, 3, 2); // row[1] = 3, col[1] = 2 + sparse_rcv subset_row3( pattern_row3 ); + work.clear(); + n_sweep = f.sparse_jac_for( + group_max, x, subset_row3, pattern_jac, coloring, work + ); + ok &= n_sweep == 2; + // + const s_vector row_row3( subset_row3.row() ); + const s_vector col_row3( subset_row3.col() ); + const d_vector val_row3( subset_row3.val() ); + ok &= subset_row3.nnz() == 2; + // + ok &= row_row3[0] == 3; + ok &= col_row3[0] == 1; + ok &= val_row3[0] == 1.0; + // + ok &= row_row3[1] == 3; + ok &= col_row3[1] == 2; + ok &= val_row3[1] == x[2]; + // + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/sparse_jacobian.cpp cppad-2019.02.00.0/example/sparse/sparse_jacobian.cpp --- cppad-2018.00.00.0/example/sparse/sparse_jacobian.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/sparse_jacobian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sparse_jacobian.cpp$$ $spell - Cpp - Jacobian + Cpp + Jacobian $$ $section Sparse Jacobian: Example and Test$$ -$code $srcfile%example/sparse/sparse_jacobian.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,237 +29,237 @@ # include namespace { // --------------------------------------------------------- bool reverse() -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - typedef CPPAD_TESTVECTOR(AD) a_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR(size_t) 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); - - // Jacobian of y without sparsity pattern - d_vector jac(m * n); - jac = f.SparseJacobian(x); - /* - [ 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]; - for(ell = 0; ell < size_t(check.size()); ell++) - ok &= NearEqual(check[ell], jac[ell], eps, eps ); - - // using packed boolean sparsity patterns - CppAD::vectorBool s_b(m * m), p_b(m * n); - for(i = 0; i < m; i++) - { for(ell = 0; ell < m; ell++) - s_b[i * m + ell] = false; - s_b[i * m + i] = true; - } - p_b = f.RevSparseJac(m, s_b); - jac = f.SparseJacobian(x, p_b); - for(ell = 0; ell < size_t(check.size()); ell++) - ok &= NearEqual(check[ell], jac[ell], eps, eps ); - - // using vector of sets sparsity patterns - std::vector< std::set > s_s(m), p_s(m); - for(i = 0; i < m; i++) - s_s[i].insert(i); - p_s = f.RevSparseJac(m, s_s); - jac = f.SparseJacobian(x, p_s); - for(ell = 0; ell < size_t(check.size()); ell++) - 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). - size_t K = 6; - i_vector row(K), col(K); - jac.resize(K); - k = 0; - for(j = 0; j < n; j++) - { for(i = 1; i < m; i++) - { ell = i * n + j; - if( p_b[ell] ) - { ok &= check[ell] != 0.; - row[k] = i; - col[k] = j; - k++; - } - } - } - ok &= k == K; - - // empty work structure - CppAD::sparse_jacobian_work work; - - // 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]; - ok &= NearEqual(check[ell], jac[k], eps, eps); - } - ok &= n_sweep == 2; - - // now recompute at a different x value (using work from previous call) - check[11] = x[3] = 10.; - 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); - } - ok &= n_sweep == 2; +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + typedef CPPAD_TESTVECTOR(AD) a_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR(size_t) 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); + + // Jacobian of y without sparsity pattern + d_vector jac(m * n); + jac = f.SparseJacobian(x); + /* + [ 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]; + for(ell = 0; ell < size_t(check.size()); ell++) + ok &= NearEqual(check[ell], jac[ell], eps, eps ); + + // using packed boolean sparsity patterns + CppAD::vectorBool s_b(m * m), p_b(m * n); + for(i = 0; i < m; i++) + { for(ell = 0; ell < m; ell++) + s_b[i * m + ell] = false; + s_b[i * m + i] = true; + } + p_b = f.RevSparseJac(m, s_b); + jac = f.SparseJacobian(x, p_b); + for(ell = 0; ell < size_t(check.size()); ell++) + ok &= NearEqual(check[ell], jac[ell], eps, eps ); + + // using vector of sets sparsity patterns + std::vector< std::set > s_s(m), p_s(m); + for(i = 0; i < m; i++) + s_s[i].insert(i); + p_s = f.RevSparseJac(m, s_s); + jac = f.SparseJacobian(x, p_s); + for(ell = 0; ell < size_t(check.size()); ell++) + 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). + size_t K = 6; + i_vector row(K), col(K); + jac.resize(K); + k = 0; + for(j = 0; j < n; j++) + { for(i = 1; i < m; i++) + { ell = i * n + j; + if( p_b[ell] ) + { ok &= check[ell] != 0.; + row[k] = i; + col[k] = j; + k++; + } + } + } + ok &= k == K; + + // empty work structure + CppAD::sparse_jacobian_work work; + + // 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]; + ok &= NearEqual(check[ell], jac[k], eps, eps); + } + ok &= n_sweep == 2; + + // now recompute at a different x value (using work from previous call) + check[11] = x[3] = 10.; + 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); + } + ok &= n_sweep == 2; - return ok; + return ok; } bool forward() -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - typedef CPPAD_TESTVECTOR(AD) a_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR(size_t) i_vector; - size_t i, j, k, ell; - double eps = 10. * CppAD::numeric_limits::epsilon(); - - // domain space vector - size_t n = 3; - 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 = 4; - a_vector a_y(m); - a_y[0] = a_x[0] + a_x[2]; - a_y[1] = a_x[0] + a_x[2]; - a_y[2] = a_x[1] + a_x[2]; - a_y[3] = a_x[1] + a_x[2] * a_x[2] / 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); - - // Jacobian of y without sparsity pattern - d_vector jac(m * n); - jac = f.SparseJacobian(x); - /* - [ 1 0 1 ] - jac = [ 1 0 1 ] - [ 0 1 1 ] - [ 0 1 x_2 ] - */ - d_vector check(m * n); - 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[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 ); - - // test using packed boolean vectors for sparsity pattern - CppAD::vectorBool r_b(n * n), p_b(m * n); - for(j = 0; j < n; j++) - { for(ell = 0; ell < n; ell++) - r_b[j * n + ell] = false; - r_b[j * n + j] = true; - } - p_b = f.ForSparseJac(n, r_b); - jac = f.SparseJacobian(x, p_b); - for(ell = 0; ell < size_t(check.size()); ell++) - ok &= NearEqual(check[ell], jac[ell], eps, eps ); - - // test using vector of sets for sparsity pattern - std::vector< std::set > r_s(n), p_s(m); - for(j = 0; j < n; j++) - r_s[j].insert(j); - p_s = f.ForSparseJac(n, r_s); - jac = f.SparseJacobian(x, p_s); - for(ell = 0; ell < size_t(check.size()); ell++) - ok &= NearEqual(check[ell], jac[ell], eps, eps ); - - // using row and column indices to compute non-zero elements excluding - // row 0 and column 0. - size_t K = 5; - i_vector row(K), col(K); - jac.resize(K); - k = 0; - for(i = 1; i < m; i++) - { for(j = 1; j < n; j++) - { ell = i * n + j; - if( p_b[ell] ) - { ok &= check[ell] != 0.; - row[k] = i; - col[k] = j; - k++; - } - } - } - ok &= k == K; - - // empty work structure - CppAD::sparse_jacobian_work work; - - // 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]; - ok &= NearEqual(check[ell], jac[k], eps, eps); - } - ok &= n_sweep == 2; - - // now recompute at a different x value (using work from previous call) - check[11] = x[2] = 10.; - n_sweep = f.SparseJacobianForward(x, p_s, 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; +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + typedef CPPAD_TESTVECTOR(AD) a_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR(size_t) i_vector; + size_t i, j, k, ell; + double eps = 10. * CppAD::numeric_limits::epsilon(); + + // domain space vector + size_t n = 3; + 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 = 4; + a_vector a_y(m); + a_y[0] = a_x[0] + a_x[2]; + a_y[1] = a_x[0] + a_x[2]; + a_y[2] = a_x[1] + a_x[2]; + a_y[3] = a_x[1] + a_x[2] * a_x[2] / 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); + + // Jacobian of y without sparsity pattern + d_vector jac(m * n); + jac = f.SparseJacobian(x); + /* + [ 1 0 1 ] + jac = [ 1 0 1 ] + [ 0 1 1 ] + [ 0 1 x_2 ] + */ + d_vector check(m * n); + 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[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 ); + + // test using packed boolean vectors for sparsity pattern + CppAD::vectorBool r_b(n * n), p_b(m * n); + for(j = 0; j < n; j++) + { for(ell = 0; ell < n; ell++) + r_b[j * n + ell] = false; + r_b[j * n + j] = true; + } + p_b = f.ForSparseJac(n, r_b); + jac = f.SparseJacobian(x, p_b); + for(ell = 0; ell < size_t(check.size()); ell++) + ok &= NearEqual(check[ell], jac[ell], eps, eps ); + + // test using vector of sets for sparsity pattern + std::vector< std::set > r_s(n), p_s(m); + for(j = 0; j < n; j++) + r_s[j].insert(j); + p_s = f.ForSparseJac(n, r_s); + jac = f.SparseJacobian(x, p_s); + for(ell = 0; ell < size_t(check.size()); ell++) + ok &= NearEqual(check[ell], jac[ell], eps, eps ); + + // using row and column indices to compute non-zero elements excluding + // row 0 and column 0. + size_t K = 5; + i_vector row(K), col(K); + jac.resize(K); + k = 0; + for(i = 1; i < m; i++) + { for(j = 1; j < n; j++) + { ell = i * n + j; + if( p_b[ell] ) + { ok &= check[ell] != 0.; + row[k] = i; + col[k] = j; + k++; + } + } + } + ok &= k == K; + + // empty work structure + CppAD::sparse_jacobian_work work; + + // 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]; + ok &= NearEqual(check[ell], jac[k], eps, eps); + } + ok &= n_sweep == 2; + + // now recompute at a different x value (using work from previous call) + check[11] = x[2] = 10.; + n_sweep = f.SparseJacobianForward(x, p_s, 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; + return ok; } } // End empty namespace bool sparse_jacobian(void) -{ bool ok = true; - ok &= forward(); - ok &= reverse(); +{ bool ok = true; + ok &= forward(); + ok &= reverse(); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/sparse_jac_rev.cpp cppad-2019.02.00.0/example/sparse/sparse_jac_rev.cpp --- cppad-2018.00.00.0/example/sparse/sparse_jac_rev.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/sparse_jac_rev.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,159 +1,158 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sparse_jac_rev.cpp$$ $spell - Cpp - Jacobian + Cpp + Jacobian $$ $section Computing Sparse Jacobian Using Reverse Mode: Example and Test$$ -$code $srcfile%example/sparse/sparse_jac_rev.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include bool sparse_jac_rev(void) -{ bool ok = true; - // - using CppAD::AD; - using CppAD::NearEqual; - using CppAD::sparse_rc; - using CppAD::sparse_rcv; - // - typedef CPPAD_TESTVECTOR(AD) a_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR(size_t) s_vector; - // - // domain space vector - size_t n = 4; - 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); - // - 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(size_t j = 0; j < n; j++) - x[j] = double(j); - /* - [ 1 1 0 0 ] - J(x) = [ 0 0 1 1 ] - [ 1 1 1 x_3] - */ - // - // row-major order values of J(x) - size_t nnz = 8; - s_vector check_row(nnz), check_col(nnz); - d_vector check_val(nnz); - for(size_t k = 0; k < nnz; k++) - { // check_val - if( k < 7 ) - check_val[k] = 1.0; - else - check_val[k] = x[3]; - // - // check_row and check_col - check_col[k] = k; - if( k < 2 ) - check_row[k] = 0; - else if( k < 4 ) - check_row[k] = 1; - else - { check_row[k] = 2; - check_col[k] = k - 4; - } - } - // - // m by m identity matrix sparsity - sparse_rc pattern_in(m, m, m); - for(size_t k = 0; k < m; k++) - pattern_in.set(k, k, k); - // - // sparsity for J(x) - bool transpose = false; - bool dependency = false; - bool internal_bool = true; - sparse_rc pattern_jac; - f.rev_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, pattern_jac - ); - // - // compute entire reverse mode Jacobian - sparse_rcv subset( pattern_jac ); - CppAD::sparse_jac_work work; - std::string coloring = "cppad"; - size_t n_sweep = f.sparse_jac_rev(x, subset, pattern_jac, coloring, work); - ok &= n_sweep == 2; - // - const s_vector row( subset.row() ); - const s_vector col( subset.col() ); - const d_vector val( subset.val() ); - s_vector row_major = subset.row_major(); - ok &= subset.nnz() == nnz; - for(size_t k = 0; k < nnz; k++) - { ok &= row[ row_major[k] ] == check_row[k]; - ok &= col[ row_major[k] ] == check_col[k]; - ok &= val[ row_major[k] ] == check_val[k]; - } - // - // test using work stored by previous sparse_jac_rev - sparse_rc pattern_not_used; - std::string coloring_not_used; - n_sweep = f.sparse_jac_rev(x, subset, pattern_jac, coloring, work); - ok &= n_sweep == 2; - for(size_t k = 0; k < nnz; k++) - { ok &= row[ row_major[k] ] == check_row[k]; - ok &= col[ row_major[k] ] == check_col[k]; - ok &= val[ row_major[k] ] == check_val[k]; - } - // - // compute non-zero in col 3 only, nr = m, nc = n, nnz = 2 - sparse_rc pattern_col3(m, n, 2); - pattern_col3.set(0, 1, 3); // row[0] = 1, col[0] = 3 - pattern_col3.set(1, 2, 3); // row[1] = 2, col[1] = 3 - sparse_rcv subset_col3( pattern_col3 ); - work.clear(); - n_sweep = f.sparse_jac_rev(x, subset_col3, pattern_jac, coloring, work); - ok &= n_sweep == 2; - // - const s_vector row_col3( subset_col3.row() ); - const s_vector col_col3( subset_col3.col() ); - const d_vector val_col3( subset_col3.val() ); - ok &= subset_col3.nnz() == 2; - // - ok &= row_col3[0] == 1; - ok &= col_col3[0] == 3; - ok &= val_col3[0] == 1.0; - // - ok &= row_col3[1] == 2; - ok &= col_col3[1] == 3; - ok &= val_col3[1] == x[3]; - // - return ok; +{ bool ok = true; + // + using CppAD::AD; + using CppAD::NearEqual; + using CppAD::sparse_rc; + using CppAD::sparse_rcv; + // + typedef CPPAD_TESTVECTOR(AD) a_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR(size_t) s_vector; + // + // domain space vector + size_t n = 4; + 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); + // + 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(size_t j = 0; j < n; j++) + x[j] = double(j); + /* + [ 1 1 0 0 ] + J(x) = [ 0 0 1 1 ] + [ 1 1 1 x_3] + */ + // + // row-major order values of J(x) + size_t nnz = 8; + s_vector check_row(nnz), check_col(nnz); + d_vector check_val(nnz); + for(size_t k = 0; k < nnz; k++) + { // check_val + if( k < 7 ) + check_val[k] = 1.0; + else + check_val[k] = x[3]; + // + // check_row and check_col + check_col[k] = k; + if( k < 2 ) + check_row[k] = 0; + else if( k < 4 ) + check_row[k] = 1; + else + { check_row[k] = 2; + check_col[k] = k - 4; + } + } + // + // m by m identity matrix sparsity + sparse_rc pattern_in(m, m, m); + for(size_t k = 0; k < m; k++) + pattern_in.set(k, k, k); + // + // sparsity for J(x) + bool transpose = false; + bool dependency = false; + bool internal_bool = true; + sparse_rc pattern_jac; + f.rev_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_jac + ); + // + // compute entire reverse mode Jacobian + sparse_rcv subset( pattern_jac ); + CppAD::sparse_jac_work work; + std::string coloring = "cppad"; + size_t n_sweep = f.sparse_jac_rev(x, subset, pattern_jac, coloring, work); + ok &= n_sweep == 2; + // + const s_vector row( subset.row() ); + const s_vector col( subset.col() ); + const d_vector val( subset.val() ); + s_vector row_major = subset.row_major(); + ok &= subset.nnz() == nnz; + for(size_t k = 0; k < nnz; k++) + { ok &= row[ row_major[k] ] == check_row[k]; + ok &= col[ row_major[k] ] == check_col[k]; + ok &= val[ row_major[k] ] == check_val[k]; + } + // + // test using work stored by previous sparse_jac_rev + sparse_rc pattern_not_used; + std::string coloring_not_used; + n_sweep = f.sparse_jac_rev(x, subset, pattern_jac, coloring, work); + ok &= n_sweep == 2; + for(size_t k = 0; k < nnz; k++) + { ok &= row[ row_major[k] ] == check_row[k]; + ok &= col[ row_major[k] ] == check_col[k]; + ok &= val[ row_major[k] ] == check_val[k]; + } + // + // compute non-zero in col 3 only, nr = m, nc = n, nnz = 2 + sparse_rc pattern_col3(m, n, 2); + pattern_col3.set(0, 1, 3); // row[0] = 1, col[0] = 3 + pattern_col3.set(1, 2, 3); // row[1] = 2, col[1] = 3 + sparse_rcv subset_col3( pattern_col3 ); + work.clear(); + n_sweep = f.sparse_jac_rev(x, subset_col3, pattern_jac, coloring, work); + ok &= n_sweep == 2; + // + const s_vector row_col3( subset_col3.row() ); + const s_vector col_col3( subset_col3.col() ); + const d_vector val_col3( subset_col3.val() ); + ok &= subset_col3.nnz() == 2; + // + ok &= row_col3[0] == 1; + ok &= col_col3[0] == 3; + ok &= val_col3[0] == 1.0; + // + ok &= row_col3[1] == 2; + ok &= col_col3[1] == 3; + ok &= val_col3[1] == x[3]; + // + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/sparse_sub_hes.cpp cppad-2019.02.00.0/example/sparse/sparse_sub_hes.cpp --- cppad-2018.00.00.0/example/sparse/sparse_sub_hes.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/sparse_sub_hes.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sparse_sub_hes.cpp$$ @@ -24,126 +25,124 @@ $head See Also$$ $cref sub_sparse_hes.cpp$$ -$code $srcfile%example/sparse/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_TESTVECTOR(size_t) SizeVector; - typedef CPPAD_TESTVECTOR(double) DoubleVector; - typedef CppAD::sparse_rc sparsity; - // - // domain space vector - size_t n = 4; - CPPAD_TESTVECTOR(AD) ax(n); - for(size_t j = 0; j < n; j++) - ax[j] = double(j); - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = 0.0; - for(size_t j = 0; j < n; j++) - ay[0] += double(j+1) * ax[0] * ax[j]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - // sparsity pattern for the identity matrix - size_t nr = n; - size_t nc = n; - size_t nnz_in = n; - sparsity pattern_in(nr, nc, nnz_in); - for(size_t k = 0; k < nnz_in; k++) - { size_t r = k; - size_t c = k; - pattern_in.set(k, r, c); - } - // compute sparsity pattern for J(x) = f'(x) - bool transpose = false; - bool dependency = false; - bool internal_bool = false; - sparsity pattern_out; - f.for_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, pattern_out - ); - // - // compute sparsity pattern for H(x) = f''(x) - CPPAD_TESTVECTOR(bool) select_range(m); - select_range[0] = true; - CppAD::sparse_hes_work work; - f.rev_hes_sparsity( - select_range, transpose, internal_bool, pattern_out - ); - size_t nnz = pattern_out.nnz(); - ok &= nnz == 7; - ok &= pattern_out.nr() == n; - ok &= pattern_out.nc() == n; - { // check results - const SizeVector& row( pattern_out.row() ); - const SizeVector& col( pattern_out.col() ); - SizeVector row_major = pattern_out.row_major(); - // - ok &= row[ row_major[0] ] == 0 && col[ row_major[0] ] == 0; - ok &= row[ row_major[1] ] == 0 && col[ row_major[1] ] == 1; - ok &= row[ row_major[2] ] == 0 && col[ row_major[2] ] == 2; - ok &= row[ row_major[3] ] == 0 && col[ row_major[3] ] == 3; - // - ok &= row[ row_major[4] ] == 1 && col[ row_major[4] ] == 0; - ok &= row[ row_major[5] ] == 2 && col[ row_major[5] ] == 0; - ok &= row[ row_major[6] ] == 3 && col[ row_major[6] ] == 0; - } - // - // Only interested in cross-terms. Since we are not computing rwo 0, - // we do not need sparsity entries in row 0. - CppAD::sparse_rc subset_pattern(n, n, 3); - for(size_t k = 0; k < 3; k++) - subset_pattern.set(k, k+1, 0); - CppAD::sparse_rcv subset( subset_pattern ); - // - // argument and weight values for computation - CPPAD_TESTVECTOR(double) x(n), w(m); - for(size_t j = 0; j < n; j++) - x[j] = double(n) / double(j+1); - w[0] = 1.0; - // - std::string coloring = "cppad.general"; - size_t n_sweep = f.sparse_hes( - x, w, subset, subset_pattern, coloring, work - ); - ok &= n_sweep == 1; - for(size_t k = 0; k < 3; k++) - { size_t i = k + 1; - ok &= subset.val()[k] == double(i + 1); - } - // - // convert subset from lower triangular to upper triangular - for(size_t k = 0; k < 3; k++) - subset_pattern.set(k, 0, k+1); - subset = CppAD::sparse_rcv( subset_pattern ); - // - // This will require more work because the Hessian is computed - // column by column (not row by row). - work.clear(); - n_sweep = f.sparse_hes( - x, w, subset, subset_pattern, coloring, work - ); - ok &= n_sweep == 3; - // - // but it will get the right answer - for(size_t k = 0; k < 3; k++) - { size_t i = k + 1; - ok &= subset.val()[k] == double(i + 1); - } - return ok; +{ bool ok = true; + using CppAD::AD; + typedef CPPAD_TESTVECTOR(size_t) SizeVector; + typedef CPPAD_TESTVECTOR(double) DoubleVector; + typedef CppAD::sparse_rc sparsity; + // + // domain space vector + size_t n = 4; + CPPAD_TESTVECTOR(AD) ax(n); + for(size_t j = 0; j < n; j++) + ax[j] = double(j); + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = 0.0; + for(size_t j = 0; j < n; j++) + ay[0] += double(j+1) * ax[0] * ax[j]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // sparsity pattern for the identity matrix + size_t nr = n; + size_t nc = n; + size_t nnz_in = n; + sparsity pattern_in(nr, nc, nnz_in); + for(size_t k = 0; k < nnz_in; k++) + { size_t r = k; + size_t c = k; + pattern_in.set(k, r, c); + } + // compute sparsity pattern for J(x) = f'(x) + bool transpose = false; + bool dependency = false; + bool internal_bool = false; + sparsity pattern_out; + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_out + ); + // + // compute sparsity pattern for H(x) = f''(x) + CPPAD_TESTVECTOR(bool) select_range(m); + select_range[0] = true; + CppAD::sparse_hes_work work; + f.rev_hes_sparsity( + select_range, transpose, internal_bool, pattern_out + ); + size_t nnz = pattern_out.nnz(); + ok &= nnz == 7; + ok &= pattern_out.nr() == n; + ok &= pattern_out.nc() == n; + { // check results + const SizeVector& row( pattern_out.row() ); + const SizeVector& col( pattern_out.col() ); + SizeVector row_major = pattern_out.row_major(); + // + ok &= row[ row_major[0] ] == 0 && col[ row_major[0] ] == 0; + ok &= row[ row_major[1] ] == 0 && col[ row_major[1] ] == 1; + ok &= row[ row_major[2] ] == 0 && col[ row_major[2] ] == 2; + ok &= row[ row_major[3] ] == 0 && col[ row_major[3] ] == 3; + // + ok &= row[ row_major[4] ] == 1 && col[ row_major[4] ] == 0; + ok &= row[ row_major[5] ] == 2 && col[ row_major[5] ] == 0; + ok &= row[ row_major[6] ] == 3 && col[ row_major[6] ] == 0; + } + // + // Only interested in cross-terms. Since we are not computing rwo 0, + // we do not need sparsity entries in row 0. + CppAD::sparse_rc subset_pattern(n, n, 3); + for(size_t k = 0; k < 3; k++) + subset_pattern.set(k, k+1, 0); + CppAD::sparse_rcv subset( subset_pattern ); + // + // argument and weight values for computation + CPPAD_TESTVECTOR(double) x(n), w(m); + for(size_t j = 0; j < n; j++) + x[j] = double(n) / double(j+1); + w[0] = 1.0; + // + std::string coloring = "cppad.general"; + size_t n_sweep = f.sparse_hes( + x, w, subset, subset_pattern, coloring, work + ); + ok &= n_sweep == 1; + for(size_t k = 0; k < 3; k++) + { size_t i = k + 1; + ok &= subset.val()[k] == double(i + 1); + } + // + // convert subset from lower triangular to upper triangular + for(size_t k = 0; k < 3; k++) + subset_pattern.set(k, 0, k+1); + subset = CppAD::sparse_rcv( subset_pattern ); + // + // This will require more work because the Hessian is computed + // column by column (not row by row). + work.clear(); + n_sweep = f.sparse_hes( + x, w, subset, subset_pattern, coloring, work + ); + ok &= n_sweep == 3; + // + // but it will get the right answer + for(size_t k = 0; k < 3; k++) + { size_t i = k + 1; + ok &= subset.val()[k] == double(i + 1); + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/sparsity_sub.cpp cppad-2019.02.00.0/example/sparse/sparsity_sub.cpp --- cppad-2018.00.00.0/example/sparse/sparsity_sub.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/sparsity_sub.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sparsity_sub.cpp$$ $spell - Jac - Jacobian - Hes + Jac + Jacobian + Hes $$ $section Sparsity Patterns For a Subset of Variables: Example and Test$$ @@ -31,9 +32,7 @@ sparsity for both the full Hessian (see $icode h$$) and a subset of the Hessian (see $icode h2$$). -$code $srcfile%example/sparse/sparsity_sub.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -41,63 +40,63 @@ # 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; +{ // 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-2018.00.00.0/example/sparse/subgraph_hes2jac.cpp cppad-2019.02.00.0/example/sparse/subgraph_hes2jac.cpp --- cppad-2018.00.00.0/example/sparse/subgraph_hes2jac.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/subgraph_hes2jac.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,129 +1,132 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin subgraph_hes2jac.cpp$$ $spell - Hessian - Subgraphs - Jacobian + Hessian + Subgraphs + Jacobian $$ $section Sparse Hessian Using Subgraphs and Jacobian: Example and Test$$ -$code $srcfile%example/sparse/subgraph_hes2jac.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include bool subgraph_hes2jac(void) -{ bool ok = true; - using CppAD::NearEqual; - typedef CppAD::AD a1double; - typedef CppAD::AD a2double; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR(a1double) a1vector; - typedef CPPAD_TESTVECTOR(a2double) a2vector; - typedef CPPAD_TESTVECTOR(size_t) s_vector; - typedef CPPAD_TESTVECTOR(bool) b_vector; - typedef CppAD::sparse_rcv sparse_matrix; - // - double eps = 10. * CppAD::numeric_limits::epsilon(); - // - // double version of x - size_t n = 12; - d_vector x(n); - for(size_t j = 0; j < n; j++) - x[j] = double(j + 2); - // - // a1double version of x - a1vector a1x(n); - for(size_t j = 0; j < n; j++) - a1x[j] = x[j]; - // - // a2double version of x - a2vector a2x(n); - for(size_t j = 0; j < n; j++) - a2x[j] = a1x[j]; - // - // declare independent variables and starting recording - CppAD::Independent(a2x); - // - // a2double version of y = f(x) = 5 * x0 * x1 + sum_j xj^3 - size_t m = 1; - a2vector a2y(m); - a2y[0] = 5.0 * a2x[0] * a2x[1]; - for(size_t j = 0; j < n; j++) - a2y[0] += a2x[j] * a2x[j] * a2x[j]; - // - // create a1double version of f: x -> y and stop tape recording - // (without executing zero order forward calculation) - CppAD::ADFun a1f; - a1f.Dependent(a2x, a2y); - // - // Optimize this function to reduce future computations. - // Perhaps only one optimization at the end would be faster. - a1f.optimize(); - // - // declare independent variables and start recording g(x) = f'(x) - Independent(a1x); - // - // Use one reverse mode pass to compute z = f'(x) - a1vector a1w(m), a1z(n); - a1w[0] = 1.0; - a1f.Forward(0, a1x); - a1z = a1f.Reverse(1, a1w); - // - // create double version of g : x -> f'(x) - CppAD::ADFun g; - g.Dependent(a1x, a1z); - // - // Optimize this function to reduce future computations. - // Perhaps no optimization would be faster. - g.optimize(); - // - // compute f''(x) = g'(x) - b_vector select_domain(n), select_range(n); - for(size_t j = 0; j < n; ++j) - { select_domain[j] = true; - select_range[j] = true; - } - sparse_matrix hessian; - g.subgraph_jac_rev(select_domain, select_range, x, hessian); - // ------------------------------------------------------------------- - // check number of non-zeros in the Hessian - // (only x0 * x1 generates off diagonal terms) - ok &= hessian.nnz() == n + 2; - // - for(size_t k = 0; k < hessian.nnz(); ++k) - { size_t r = hessian.row()[k]; - size_t c = hessian.col()[k]; - double v = hessian.val()[k]; - // - if( r == c ) - { // a diagonal element - double check = 6.0 * x[r]; - ok &= NearEqual(v, check, eps, eps); - } - else - { // off diagonal element - ok &= (r == 0 && c == 1) || (r == 1 && c == 0); - double check = 5.0; - ok &= NearEqual(v, check, eps, eps); - } - } - return ok; +{ bool ok = true; + using CppAD::NearEqual; + typedef CppAD::AD a1double; + typedef CppAD::AD a2double; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR(a1double) a1vector; + typedef CPPAD_TESTVECTOR(a2double) a2vector; + typedef CPPAD_TESTVECTOR(size_t) s_vector; + typedef CPPAD_TESTVECTOR(bool) b_vector; + typedef CppAD::sparse_rcv sparse_matrix; + // + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // double version of x + size_t n = 12; + d_vector x(n); + for(size_t j = 0; j < n; j++) + x[j] = double(j + 2); + // + // a1double version of x + a1vector a1x(n); + for(size_t j = 0; j < n; j++) + a1x[j] = x[j]; + // + // a2double version of x + a2vector a2x(n); + for(size_t j = 0; j < n; j++) + a2x[j] = a1x[j]; + // + // declare independent variables and starting recording + CppAD::Independent(a2x); + // + // a2double version of y = f(x) = 5 * x0 * x1 + sum_j xj^3 + size_t m = 1; + a2vector a2y(m); + a2y[0] = 5.0 * a2x[0] * a2x[1]; + for(size_t j = 0; j < n; j++) + a2y[0] += a2x[j] * a2x[j] * a2x[j]; + // + // create a1double version of f: x -> y and stop tape recording + // (without executing zero order forward calculation) + CppAD::ADFun a1f; + a1f.Dependent(a2x, a2y); + // + // Optimize this function to reduce future computations. + // Perhaps only one optimization at the end would be faster. + a1f.optimize(); + // + // declare independent variables and start recording g(x) = f'(x) + Independent(a1x); + // + // Use one reverse mode pass to compute z = f'(x) + a1vector a1w(m), a1z(n); + a1w[0] = 1.0; + a1f.Forward(0, a1x); + a1z = a1f.Reverse(1, a1w); + // + // create double version of g : x -> f'(x) + CppAD::ADFun g; + g.Dependent(a1x, a1z); + ok &= g.size_random() == 0; + // + // Optimize this function to reduce future computations. + // Perhaps no optimization would be faster. + g.optimize(); + // + // compute f''(x) = g'(x) + b_vector select_domain(n), select_range(n); + for(size_t j = 0; j < n; ++j) + { select_domain[j] = true; + select_range[j] = true; + } + sparse_matrix hessian; + g.subgraph_jac_rev(select_domain, select_range, x, hessian); + // ------------------------------------------------------------------- + // check number of non-zeros in the Hessian + // (only x0 * x1 generates off diagonal terms) + ok &= hessian.nnz() == n + 2; + // + for(size_t k = 0; k < hessian.nnz(); ++k) + { size_t r = hessian.row()[k]; + size_t c = hessian.col()[k]; + double v = hessian.val()[k]; + // + if( r == c ) + { // a diagonal element + double check = 6.0 * x[r]; + ok &= NearEqual(v, check, eps, eps); + } + else + { // off diagonal element + ok &= (r == 0 && c == 1) || (r == 1 && c == 0); + double check = 5.0; + ok &= NearEqual(v, check, eps, eps); + } + } + ok &= g.size_random() > 0; + g.clear_subgraph(); + ok &= g.size_random() == 0; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/subgraph_jac_rev.cpp cppad-2019.02.00.0/example/sparse/subgraph_jac_rev.cpp --- cppad-2018.00.00.0/example/sparse/subgraph_jac_rev.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/subgraph_jac_rev.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,138 +1,141 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin subgraph_jac_rev.cpp$$ $spell - Cpp - Jacobian + Cpp + Jacobian $$ $section Computing Sparse Jacobian Using Reverse Mode: Example and Test$$ -$code $srcfile%example/sparse/subgraph_jac_rev.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include bool subgraph_jac_rev(void) -{ bool ok = true; - // - using CppAD::AD; - using CppAD::NearEqual; - using CppAD::sparse_rc; - using CppAD::sparse_rcv; - // - typedef CPPAD_TESTVECTOR(AD) a_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR(size_t) s_vector; - typedef CPPAD_TESTVECTOR(bool) b_vector; - // - // domain space vector - size_t n = 4; - 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); - // - 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(size_t j = 0; j < n; j++) - x[j] = double(j); - /* - [ 1 1 0 0 ] - J(x) = [ 0 0 1 1 ] - [ 1 1 1 x_3] - */ - // - // row-major order values of J(x) - size_t nnz = 8; - s_vector check_row(nnz), check_col(nnz); - d_vector check_val(nnz); - for(size_t k = 0; k < nnz; k++) - { // check_val - if( k < 7 ) - check_val[k] = 1.0; - else - check_val[k] = x[3]; - // - // check_row and check_col - check_col[k] = k; - if( k < 2 ) - check_row[k] = 0; - else if( k < 4 ) - check_row[k] = 1; - else - { check_row[k] = 2; - check_col[k] = k - 4; - } - } - // - // select all range components of domain and range - b_vector select_domain(n), select_range(m); - for(size_t j = 0; j < n; ++j) - select_domain[j] = true; - for(size_t i = 0; i < m; ++i) - select_range[i] = true; - // ----------------------------------------------------------------------- - // Compute Jacobian using f.subgraph_jac_rev(x, subset) - // ----------------------------------------------------------------------- - // - // get sparsity pattern - bool transpose = false; - sparse_rc pattern_jac; - f.subgraph_sparsity( - select_domain, select_range, transpose, pattern_jac - ); - // f.subgraph_jac_rev(x, subset) - sparse_rcv subset( pattern_jac ); - f.subgraph_jac_rev(x, subset); - // - // check result - ok &= subset.nnz() == nnz; - s_vector row_major = subset.row_major(); - for(size_t k = 0; k < nnz; k++) - { ok &= subset.row()[ row_major[k] ] == check_row[k]; - ok &= subset.col()[ row_major[k] ] == check_col[k]; - ok &= subset.val()[ row_major[k] ] == check_val[k]; - } - // ----------------------------------------------------------------------- - // f.subgraph_jac_rev(select_domain, select_range, x, matrix_out) - // ----------------------------------------------------------------------- - sparse_rcv matrix_out; - f.subgraph_jac_rev(select_domain, select_range, x, matrix_out); - // - // check result - ok &= matrix_out.nnz() == nnz; - row_major = matrix_out.row_major(); - for(size_t k = 0; k < nnz; k++) - { ok &= matrix_out.row()[ row_major[k] ] == check_row[k]; - ok &= matrix_out.col()[ row_major[k] ] == check_col[k]; - ok &= matrix_out.val()[ row_major[k] ] == check_val[k]; - } - // - return ok; +{ bool ok = true; + // + using CppAD::AD; + using CppAD::NearEqual; + using CppAD::sparse_rc; + using CppAD::sparse_rcv; + // + typedef CPPAD_TESTVECTOR(AD) a_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR(size_t) s_vector; + typedef CPPAD_TESTVECTOR(bool) b_vector; + // + // domain space vector + size_t n = 4; + 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); + // + 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); + ok &= f.size_random() == 0; + // + // new value for the independent variable vector + d_vector x(n); + for(size_t j = 0; j < n; j++) + x[j] = double(j); + /* + [ 1 1 0 0 ] + J(x) = [ 0 0 1 1 ] + [ 1 1 1 x_3] + */ + // + // row-major order values of J(x) + size_t nnz = 8; + s_vector check_row(nnz), check_col(nnz); + d_vector check_val(nnz); + for(size_t k = 0; k < nnz; k++) + { // check_val + if( k < 7 ) + check_val[k] = 1.0; + else + check_val[k] = x[3]; + // + // check_row and check_col + check_col[k] = k; + if( k < 2 ) + check_row[k] = 0; + else if( k < 4 ) + check_row[k] = 1; + else + { check_row[k] = 2; + check_col[k] = k - 4; + } + } + // + // select all range components of domain and range + b_vector select_domain(n), select_range(m); + for(size_t j = 0; j < n; ++j) + select_domain[j] = true; + for(size_t i = 0; i < m; ++i) + select_range[i] = true; + // ----------------------------------------------------------------------- + // Compute Jacobian using f.subgraph_jac_rev(x, subset) + // ----------------------------------------------------------------------- + // + // get sparsity pattern + bool transpose = false; + sparse_rc pattern_jac; + f.subgraph_sparsity( + select_domain, select_range, transpose, pattern_jac + ); + // f.subgraph_jac_rev(x, subset) + sparse_rcv subset( pattern_jac ); + f.subgraph_jac_rev(x, subset); + // + // check result + ok &= subset.nnz() == nnz; + s_vector row_major = subset.row_major(); + for(size_t k = 0; k < nnz; k++) + { ok &= subset.row()[ row_major[k] ] == check_row[k]; + ok &= subset.col()[ row_major[k] ] == check_col[k]; + ok &= subset.val()[ row_major[k] ] == check_val[k]; + } + // ----------------------------------------------------------------------- + // f.subgraph_jac_rev(select_domain, select_range, x, matrix_out) + // ----------------------------------------------------------------------- + sparse_rcv matrix_out; + f.subgraph_jac_rev(select_domain, select_range, x, matrix_out); + // + // check result + ok &= matrix_out.nnz() == nnz; + row_major = matrix_out.row_major(); + for(size_t k = 0; k < nnz; k++) + { ok &= matrix_out.row()[ row_major[k] ] == check_row[k]; + ok &= matrix_out.col()[ row_major[k] ] == check_col[k]; + ok &= matrix_out.val()[ row_major[k] ] == check_val[k]; + } + // + ok &= f.size_random() > 0; + f.clear_subgraph(); + ok &= f.size_random() == 0; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/subgraph_reverse.cpp cppad-2019.02.00.0/example/sparse/subgraph_reverse.cpp --- cppad-2018.00.00.0/example/sparse/subgraph_reverse.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/subgraph_reverse.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,116 +1,119 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin subgraph_reverse.cpp$$ $spell - Subgraphs + Subgraphs $$ $section Computing Reverse Mode on Subgraphs: Example and Test$$ -$code $srcfile%example/sparse/subgraph_reverse.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ // BEGIN C++ # include bool subgraph_reverse(void) -{ bool ok = true; - // - using CppAD::AD; - using CppAD::NearEqual; - using CppAD::sparse_rc; - using CppAD::sparse_rcv; - // - typedef CPPAD_TESTVECTOR(AD) a_vector; - typedef CPPAD_TESTVECTOR(double) d_vector; - typedef CPPAD_TESTVECTOR(bool) b_vector; - typedef CPPAD_TESTVECTOR(size_t) s_vector; - // - double eps99 = 99.0 * std::numeric_limits::epsilon(); - // - // domain space vector - size_t n = 4; - 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); - // - 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(size_t j = 0; j < n; j++) - x[j] = double(j); - f.Forward(0, x); - /* - [ 1 1 0 0 ] - J(x) = [ 0 0 1 1 ] - [ 1 1 1 x_3] - */ - double J[] = { - 1.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 1.0, - 1.0, 1.0, 1.0, 0.0 - }; - J[11] = x[3]; - // - // exclude x[0] from the calculations - b_vector select_domain(n); - select_domain[0] = false; - for(size_t j = 1; j < n; j++) - select_domain[j] = true; - // - // initilaize for reverse mode derivatives computation on subgraphs - f.subgraph_reverse(select_domain); - // - // compute the derivative for each range component - for(size_t i = 0; i < m; i++) - { d_vector dw; - s_vector col; - size_t q = 1; // derivative of one Taylor coefficient (zero order) - f.subgraph_reverse(q, i, col, dw); - // - // check order in col - for(size_t c = 1; c < size_t( col.size() ); c++) - ok &= col[c] > col[c-1]; - // - // check that x[0] has been excluded by select_domain - if( size_t( col.size() ) > 0 ) - ok &= col[0] != 0; - // - // check derivatives for i-th row of J(x) - // note that dw is only specified for j in col - size_t c = 0; - for(size_t j = 1; j < n; j++) - { while( c < size_t( col.size() ) && col[c] < j ) - ++c; - if( c < size_t( col.size() ) && col[c] == j ) - ok &= NearEqual(dw[j], J[i * n + j], eps99, eps99); - else - ok &= NearEqual(0.0, J[i * n + j], eps99, eps99); - } - } - return ok; +{ bool ok = true; + // + using CppAD::AD; + using CppAD::NearEqual; + using CppAD::sparse_rc; + using CppAD::sparse_rcv; + // + typedef CPPAD_TESTVECTOR(AD) a_vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR(bool) b_vector; + typedef CPPAD_TESTVECTOR(size_t) s_vector; + // + double eps99 = 99.0 * std::numeric_limits::epsilon(); + // + // domain space vector + size_t n = 4; + 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); + // + 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); + ok &= f.size_random() == 0; + // + // new value for the independent variable vector + d_vector x(n); + for(size_t j = 0; j < n; j++) + x[j] = double(j); + f.Forward(0, x); + /* + [ 1 1 0 0 ] + J(x) = [ 0 0 1 1 ] + [ 1 1 1 x_3] + */ + double J[] = { + 1.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 1.0, + 1.0, 1.0, 1.0, 0.0 + }; + J[11] = x[3]; + // + // exclude x[0] from the calculations + b_vector select_domain(n); + select_domain[0] = false; + for(size_t j = 1; j < n; j++) + select_domain[j] = true; + // + // initilaize for reverse mode derivatives computation on subgraphs + f.subgraph_reverse(select_domain); + // + // compute the derivative for each range component + for(size_t i = 0; i < m; i++) + { d_vector dw; + s_vector col; + size_t q = 1; // derivative of one Taylor coefficient (zero order) + f.subgraph_reverse(q, i, col, dw); + // + // check order in col + for(size_t c = 1; c < size_t( col.size() ); c++) + ok &= col[c] > col[c-1]; + // + // check that x[0] has been excluded by select_domain + if( size_t( col.size() ) > 0 ) + ok &= col[0] != 0; + // + // check derivatives for i-th row of J(x) + // note that dw is only specified for j in col + size_t c = 0; + for(size_t j = 1; j < n; j++) + { while( c < size_t( col.size() ) && col[c] < j ) + ++c; + if( c < size_t( col.size() ) && col[c] == j ) + ok &= NearEqual(dw[j], J[i * n + j], eps99, eps99); + else + ok &= NearEqual(0.0, J[i * n + j], eps99, eps99); + } + } + ok &= f.size_random() > 0; + f.clear_subgraph(); + ok &= f.size_random() == 0; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/subgraph_sparsity.cpp cppad-2019.02.00.0/example/sparse/subgraph_sparsity.cpp --- cppad-2018.00.00.0/example/sparse/subgraph_sparsity.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/subgraph_sparsity.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin subgraph_sparsity.cpp$$ $spell - Subgraph + Subgraph $$ $section Subgraph Dependency Sparsity Patterns: Example and Test$$ -$code $srcfile%example/sparse/subgraph_sparsity.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -28,75 +27,77 @@ # include bool subgraph_sparsity(void) -{ bool ok = true; - using CppAD::AD; - typedef CPPAD_TESTVECTOR(size_t) SizeVector; - typedef CppAD::sparse_rc sparsity; - // - // domain space vector - size_t n = 2; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 0.; - ax[1] = 1.; - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - size_t m = 3; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = ax[0]; - ay[1] = ax[0] * ax[1]; - ay[2] = ax[1]; - - // create f: x -> y and stop tape recording - CppAD::ADFun f(ax, ay); - - - - // compute sparsite pattern for F'(x) - CPPAD_TESTVECTOR(bool) select_domain(n), select_range(m); - for(size_t j = 0; j < n; j++) - select_domain[j] = true; - for(size_t i = 0; i < m; i++) - select_range[i] = true; - bool transpose = false; - sparsity pattern_out; - f.subgraph_sparsity(select_domain, select_range, transpose, pattern_out); - - // check sparsity pattern - size_t nnz = pattern_out.nnz(); - ok &= nnz == 4; - ok &= pattern_out.nr() == m; - ok &= pattern_out.nc() == n; - { // check results - const SizeVector& row( pattern_out.row() ); - const SizeVector& col( pattern_out.col() ); - SizeVector col_major = pattern_out.col_major(); - // - ok &= row[ col_major[0] ] == 0 && col[ col_major[0] ] == 0; - ok &= row[ col_major[1] ] == 1 && col[ col_major[1] ] == 0; - ok &= row[ col_major[2] ] == 1 && col[ col_major[2] ] == 1; - ok &= row[ col_major[3] ] == 2 && col[ col_major[3] ] == 1; - } - // note that the transpose of the identity is the identity - transpose = true; - f.subgraph_sparsity(select_domain, select_range, transpose, pattern_out); - // - nnz = pattern_out.nnz(); - ok &= nnz == 4; - ok &= pattern_out.nr() == n; - ok &= pattern_out.nc() == m; - { // check results - const SizeVector& row( pattern_out.row() ); - const SizeVector& col( pattern_out.col() ); - SizeVector row_major = pattern_out.row_major(); - // - ok &= col[ row_major[0] ] == 0 && row[ row_major[0] ] == 0; - ok &= col[ row_major[1] ] == 1 && row[ row_major[1] ] == 0; - ok &= col[ row_major[2] ] == 1 && row[ row_major[2] ] == 1; - ok &= col[ row_major[3] ] == 2 && row[ row_major[3] ] == 1; - } - return ok; +{ bool ok = true; + using CppAD::AD; + typedef CPPAD_TESTVECTOR(size_t) SizeVector; + typedef CppAD::sparse_rc sparsity; + // + // domain space vector + size_t n = 2; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 0.; + ax[1] = 1.; + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + size_t m = 3; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = ax[0]; + ay[1] = ax[0] * ax[1]; + ay[2] = ax[1]; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + ok &= f.size_random() == 0; + + // compute sparsite pattern for F'(x) + CPPAD_TESTVECTOR(bool) select_domain(n), select_range(m); + for(size_t j = 0; j < n; j++) + select_domain[j] = true; + for(size_t i = 0; i < m; i++) + select_range[i] = true; + bool transpose = false; + sparsity pattern_out; + f.subgraph_sparsity(select_domain, select_range, transpose, pattern_out); + + // check sparsity pattern + size_t nnz = pattern_out.nnz(); + ok &= nnz == 4; + ok &= pattern_out.nr() == m; + ok &= pattern_out.nc() == n; + { // check results + const SizeVector& row( pattern_out.row() ); + const SizeVector& col( pattern_out.col() ); + SizeVector col_major = pattern_out.col_major(); + // + ok &= row[ col_major[0] ] == 0 && col[ col_major[0] ] == 0; + ok &= row[ col_major[1] ] == 1 && col[ col_major[1] ] == 0; + ok &= row[ col_major[2] ] == 1 && col[ col_major[2] ] == 1; + ok &= row[ col_major[3] ] == 2 && col[ col_major[3] ] == 1; + } + // note that the transpose of the identity is the identity + transpose = true; + f.subgraph_sparsity(select_domain, select_range, transpose, pattern_out); + // + nnz = pattern_out.nnz(); + ok &= nnz == 4; + ok &= pattern_out.nr() == n; + ok &= pattern_out.nc() == m; + { // check results + const SizeVector& row( pattern_out.row() ); + const SizeVector& col( pattern_out.col() ); + SizeVector row_major = pattern_out.row_major(); + // + ok &= col[ row_major[0] ] == 0 && row[ row_major[0] ] == 0; + ok &= col[ row_major[1] ] == 1 && row[ row_major[1] ] == 0; + ok &= col[ row_major[2] ] == 1 && row[ row_major[2] ] == 1; + ok &= col[ row_major[3] ] == 2 && row[ row_major[3] ] == 1; + } + ok &= f.size_random() > 0; + f.clear_subgraph(); + ok &= f.size_random() == 0; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/sparse/sub_sparse_hes.cpp cppad-2019.02.00.0/example/sparse/sub_sparse_hes.cpp --- cppad-2018.00.00.0/example/sparse/sub_sparse_hes.cpp 2018-01-01 08:32:17.000000000 +0000 +++ cppad-2019.02.00.0/example/sparse/sub_sparse_hes.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sub_sparse_hes.cpp$$ @@ -35,16 +36,14 @@ $head Subset$$ Suppose that we are only interested computing the function $latex \[ - H(u, v) = \partial_u \partial_u f (u, v) + 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 $srcfile%example/sparse/sub_sparse_hes.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -52,109 +51,109 @@ # 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; - } + 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; +{ 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-2018.00.00.0/example/utility/check_numeric_type.cpp cppad-2019.02.00.0/example/utility/check_numeric_type.cpp --- cppad-2018.00.00.0/example/utility/check_numeric_type.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/check_numeric_type.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,21 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin check_numeric_type.cpp$$ $section The CheckNumericType Function: Example and Test$$ -$mindex check NumericType$$ -$code $srcfile%example/utility/check_numeric_type.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -33,160 +31,160 @@ namespace { // Empty namespace - // ------------------------------------------------------------------- - class MyType { - private: - double d; - public: - // constructor from void - MyType(void) : d(0.) - { } - // constructor from an int - MyType(int d_) : d(d_) - { } - // copy constuctor - MyType(const MyType &x) - { d = x.d; } - // assignment operator - void operator = (const MyType &x) - { d = x.d; } - // member function that converts to double - double Double(void) const - { return d; } + // ------------------------------------------------------------------- + class MyType { + private: + double d; + public: + // constructor from void + MyType(void) : d(0.) + { } + // constructor from an int + MyType(int d_) : d(d_) + { } + // copy constuctor + MyType(const MyType &x) + { d = x.d; } + // assignment operator + void operator = (const MyType &x) + { d = x.d; } + // member function that converts to double + double Double(void) const + { return d; } # if CppADMyTypeOmit != 1 - // unary plus - MyType operator + (void) const - { MyType x; - x.d = d; - return x; - } + // unary plus + MyType operator + (void) const + { MyType x; + x.d = d; + return x; + } # endif # if CppADMyTypeOmit != 2 - // unary plus - MyType operator - (void) const - { MyType x; - x.d = - d; - return x; - } + // unary plus + MyType operator - (void) const + { MyType x; + x.d = - d; + return x; + } # endif # if CppADMyTypeOmit != 3 - // binary addition - MyType operator + (const MyType &x) const - { MyType y; - y.d = d + x.d ; - return y; - } + // binary addition + MyType operator + (const MyType &x) const + { MyType y; + y.d = d + x.d ; + return y; + } # endif # if CppADMyTypeOmit != 4 - // binary subtraction - MyType operator - (const MyType &x) const - { MyType y; - y.d = d - x.d ; - return y; - } + // binary subtraction + MyType operator - (const MyType &x) const + { MyType y; + y.d = d - x.d ; + return y; + } # endif # if CppADMyTypeOmit != 5 - // binary multiplication - MyType operator * (const MyType &x) const - { MyType y; - y.d = d * x.d ; - return y; - } + // binary multiplication + MyType operator * (const MyType &x) const + { MyType y; + y.d = d * x.d ; + return y; + } # endif # if CppADMyTypeOmit != 6 - // binary division - MyType operator / (const MyType &x) const - { MyType y; - y.d = d / x.d ; - return y; - } + // binary division + MyType operator / (const MyType &x) const + { MyType y; + y.d = d / x.d ; + return y; + } # endif # if CppADMyTypeOmit != 7 - // compound assignment addition - void operator += (const MyType &x) - { d += x.d; } + // compound assignment addition + void operator += (const MyType &x) + { d += x.d; } # endif # if CppADMyTypeOmit != 8 - // compound assignment subtraction - void operator -= (const MyType &x) - { d -= x.d; } + // compound assignment subtraction + void operator -= (const MyType &x) + { d -= x.d; } # endif # if CppADMyTypeOmit != 9 - // compound assignment multiplication - void operator *= (const MyType &x) - { d *= x.d; } + // compound assignment multiplication + void operator *= (const MyType &x) + { d *= x.d; } # endif # if CppADMyTypeOmit != 10 - // compound assignment division - void operator /= (const MyType &x) - { d /= x.d; } -# endif - }; - // ------------------------------------------------------------------- - /* - 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) - { - // make sure NumericType satisfies its conditions - CppAD::CheckNumericType(); - - // copy b to x - x[0] = b[0]; - x[1] = b[1]; - - // copy A to work space - NumericType W[4]; - W[0] = A[0]; - W[1] = A[1]; - W[2] = A[2]; - W[3] = A[3]; - - // divide first row by W(1,1) - W[1] /= W[0]; - x[0] /= W[0]; - W[0] = NumericType(1); - - // subtract W(2,1) times first row from second row - W[3] -= W[2] * W[1]; - x[1] -= W[2] * x[0]; - W[2] = NumericType(0); - - // divide second row by W(2, 2) - x[1] /= W[3]; - W[3] = NumericType(1); - - // use first row to solve for x[0] - x[0] -= W[1] * x[1]; - } + // compound assignment division + void operator /= (const MyType &x) + { d /= x.d; } +# endif + }; + // ------------------------------------------------------------------- + /* + 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) + { + // make sure NumericType satisfies its conditions + CppAD::CheckNumericType(); + + // copy b to x + x[0] = b[0]; + x[1] = b[1]; + + // copy A to work space + NumericType W[4]; + W[0] = A[0]; + W[1] = A[1]; + W[2] = A[2]; + W[3] = A[3]; + + // divide first row by W(1,1) + W[1] /= W[0]; + x[0] /= W[0]; + W[0] = NumericType(1); + + // subtract W(2,1) times first row from second row + W[3] -= W[2] * W[1]; + x[1] -= W[2] * x[0]; + W[2] = NumericType(0); + + // divide second row by W(2, 2) + x[1] /= W[3]; + W[3] = NumericType(1); + + // use first row to solve for x[0] + x[0] -= W[1] * x[1]; + } } // End Empty namespace bool CheckNumericType(void) -{ bool ok = true; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); +{ bool ok = true; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); - MyType A[4]; - A[0] = MyType(1); A[1] = MyType(2); - A[2] = MyType(3); A[3] = MyType(4); + MyType A[4]; + A[0] = MyType(1); A[1] = MyType(2); + A[2] = MyType(3); A[3] = MyType(4); - MyType b[2]; - b[0] = MyType(1); - b[1] = MyType(2); + MyType b[2]; + b[0] = MyType(1); + b[1] = MyType(2); - MyType x[2]; - Solve(A, x, b); + MyType x[2]; + Solve(A, x, b); - MyType sum; - sum = A[0] * x[0] + A[1] * x[1]; - ok &= NearEqual(sum.Double(), b[0].Double(), eps99, eps99); + MyType sum; + sum = A[0] * x[0] + A[1] * x[1]; + ok &= NearEqual(sum.Double(), b[0].Double(), eps99, eps99); - sum = A[2] * x[0] + A[3] * x[1]; - ok &= NearEqual(sum.Double(), b[1].Double(), eps99, eps99); + sum = A[2] * x[0] + A[3] * x[1]; + ok &= NearEqual(sum.Double(), b[1].Double(), eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/check_simple_vector.cpp cppad-2019.02.00.0/example/utility/check_simple_vector.cpp --- cppad-2018.00.00.0/example/utility/check_simple_vector.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/check_simple_vector.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,21 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin check_simple_vector.cpp$$ $section The CheckSimpleVector Function: Example and Test$$ -$mindex check SimpleVector$$ -$code $srcfile%example/utility/check_simple_vector.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -38,17 +36,17 @@ template class MyElement { private: - Scalar *element; + Scalar *element; public: - // element constructor - MyElement(Scalar *e) - { element = e; } - // an example element assignment that returns void - void operator = (const Scalar &s) - { *element = s; } - // conversion to Scalar - operator Scalar() const - { return *element; } + // element constructor + MyElement(Scalar *e) + { element = e; } + // an example element assignment that returns void + void operator = (const Scalar &s) + { *element = s; } + // conversion to Scalar + operator Scalar() const + { return *element; } }; @@ -56,80 +54,83 @@ template class MyVector { private: - size_t length; - Scalar * data; + size_t length; + Scalar * data; public: # if CppADMyVectorOmit != 1 - // type of the elements in the vector - typedef Scalar value_type; + // type of the elements in the vector + typedef Scalar value_type; # endif # if CppADMyVectorOmit != 2 - // default constructor - inline MyVector(void) : length(0) , data(0) - { } + // default constructor + MyVector(void) : length(0) , data(0) + { } # endif # if CppADMyVectorOmit != 3 - // constructor with a specified size - inline MyVector(size_t n) : length(n) - { if( length == 0 ) - data = 0; - else data = new Scalar[length]; - } + // constructor with a specified size + MyVector(size_t n) : length(n) + { if( length == 0 ) + data = 0; + else + data = new Scalar[length]; + } # endif # if CppADMyVectorOmit != 4 - // copy constructor - inline MyVector(const MyVector &x) : length(x.length) - { size_t i; - if( length == 0 ) - data = 0; - else data = new Scalar[length]; - - for(i = 0; i < length; i++) - data[i] = x.data[i]; - } + // copy constructor + MyVector(const MyVector &x) : length(x.length) + { size_t i; + if( length == 0 ) + data = 0; + else + data = new Scalar[length]; + + for(i = 0; i < length; i++) + data[i] = x.data[i]; + } # endif # if CppADMyVectorOmit != 4 # if CppADMyVectorOmit != 7 - // destructor (it is not safe to delete the pointer in cases 4 and 7) - ~MyVector(void) - { delete [] data; } + // destructor (it is not safe to delete the pointer in cases 4 and 7) + ~MyVector(void) + { delete [] data; } # endif # endif # if CppADMyVectorOmit != 5 - // size function - inline size_t size(void) const - { return length; } + // size function + size_t size(void) const + { return length; } # endif # if CppADMyVectorOmit != 6 - // resize function - inline void resize(size_t n) - { if( length > 0 ) - delete [] data; - length = n; - if( length > 0 ) - data = new Scalar[length]; - else data = 0; - } + // resize function + void resize(size_t n) + { if( length > 0 ) + delete [] data; + length = n; + if( length > 0 ) + data = new Scalar[length]; + else + data = 0; + } # endif # if CppADMyVectorOmit != 7 - // assignment operator - inline MyVector & operator=(const MyVector &x) - { size_t i; - for(i = 0; i < length; i++) - data[i] = x.data[i]; - return *this; - } + // assignment operator + MyVector & operator=(const MyVector &x) + { size_t i; + for(i = 0; i < length; i++) + data[i] = x.data[i]; + return *this; + } # endif # if CppADMyVectorOmit != 8 - // non-constant element access - MyElement operator[](size_t i) - { return data + i; } + // non-constant element access + MyElement operator[](size_t i) + { return data + i; } # endif # if CppADMyVectorOmit != 9 - // constant element access - const Scalar & operator[](size_t i) const - { return data[i]; } + // constant element access + const Scalar & operator[](size_t i) const + { return data[i]; } # endif }; // ------------------------------------------------------------------------- @@ -140,42 +141,42 @@ the types agree. */ namespace { // Empty namespace - template - Vector Sscal(const Scalar &a, const Vector &v) - { - // 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]; + template + Vector Sscal(const Scalar &a, const Vector &v) + { + // 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; - } + return r; + } } bool CheckSimpleVector(void) -{ bool ok = true; - using CppAD::vector; +{ bool ok = true; + using CppAD::vector; - // -------------------------------------------------------- - // If you change double to float in the next statement, - // CheckSimpleVector will generate an error message at compile time. - double a = 3.; - // -------------------------------------------------------- - - size_t n = 2; - MyVector v(n); - v[0] = 1.; - v[1] = 2.; - MyVector r = Sscal(a, v); - ok &= (r[0] == 3.); - ok &= (r[1] == 6.); + // -------------------------------------------------------- + // If you change double to float in the next statement, + // CheckSimpleVector will generate an error message at compile time. + double a = 3.; + // -------------------------------------------------------- + + size_t n = 2; + MyVector v(n); + v[0] = 1.; + v[1] = 2.; + MyVector r = Sscal(a, v); + ok &= (r[0] == 3.); + ok &= (r[1] == 6.); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/CMakeLists.txt cppad-2019.02.00.0/example/utility/CMakeLists.txt --- cppad-2018.00.00.0/example/utility/CMakeLists.txt 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,40 +1,41 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # SET(source_list - check_numeric_type.cpp - check_simple_vector.cpp - cppad_vector.cpp - error_handler.cpp - index_sort.cpp - lu_factor.cpp - lu_invert.cpp - lu_solve.cpp - nan.cpp - near_equal.cpp - ode_err_control.cpp - ode_err_maxabs.cpp - ode_gear_control.cpp - ode_gear.cpp - romberg_mul.cpp - romberg_one.cpp - runge45_1.cpp - set_union.cpp - simple_vector.cpp - sparse_rc.cpp - sparse_rcv.cpp - thread_alloc.cpp - to_string.cpp - utility.cpp - vector_bool.cpp + check_numeric_type.cpp + check_simple_vector.cpp + cppad_vector.cpp + error_handler.cpp + index_sort.cpp + lu_factor.cpp + lu_invert.cpp + lu_solve.cpp + nan.cpp + near_equal.cpp + ode_err_control.cpp + ode_err_maxabs.cpp + ode_gear_control.cpp + ode_gear.cpp + romberg_mul.cpp + romberg_one.cpp + runge45_1.cpp + set_union.cpp + simple_vector.cpp + sparse_rc.cpp + sparse_rcv.cpp + thread_alloc.cpp + to_string.cpp + utility.cpp + vector_bool.cpp ) set_compile_flags( example_utility "${cppad_debug_which}" "${source_list}" ) # @@ -42,8 +43,8 @@ # # Add the check_example_utility target ADD_CUSTOM_TARGET(check_example_utility - example_utility - DEPENDS example_utility + example_utility + DEPENDS example_utility ) MESSAGE(STATUS "make check_example_utility: available") diff -Nru cppad-2018.00.00.0/example/utility/cppad_vector.cpp cppad-2019.02.00.0/example/utility/cppad_vector.cpp --- cppad-2018.00.00.0/example/utility/cppad_vector.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/cppad_vector.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin cppad_vector.cpp$$ $spell - Cpp + Cpp $$ $section CppAD::vector Template Class: Example and Test$$ -$mindex vector CppAD$$ -$code $srcfile%example/utility/cppad_vector.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -33,85 +31,85 @@ # include bool CppAD_vector(void) -{ bool ok = true; - 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 - ok &= (x.size() == 0); - - x.resize(2); // resize and set element assignment - ok &= (x.size() == 2); - 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(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(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= "{ 1, 2 }"; - std::string str; - std::ostringstream buf; - buf << z; - str = buf.str(); - ok &= (str == correct); - - // test resize(1), resize(0), capacity, and clear - size_t i = x.capacity(); - ok &= i >= 2; - x.resize(1); - ok &= x[0] == Type(1); - ok &= i == x.capacity(); - x.resize(0); - ok &= i == x.capacity(); - x.clear(); - ok &= 0 == x.capacity(); - - // test of push_back scalar and capacity - size_t N = 100; - for(i = 0; i < N; i++) - { 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(); - } - for(i = 0; i < N; i++) - ok &= ( x[i] == Type(i) ); - - // test of data - Type* data = x.data(); - for(i = 0; i < N; i++) - { ok &= data[i] == Type(i); - data[i] = Type(N - i); - ok &= x[i] == Type(N - i); - } - - // test of push_vector - x.push_vector(x); - ok &= (x.size() == 2 * N); - for(i = 0; i < N; i++) - { ok &= x[i] == Type(N - i); - ok &= x[i+N] == Type(N - i); - } +{ bool ok = true; + 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 + ok &= (x.size() == 0); + + x.resize(2); // resize and set element assignment + ok &= (x.size() == 2); + 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(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(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= "{ 1, 2 }"; + std::string str; + std::ostringstream buf; + buf << z; + str = buf.str(); + ok &= (str == correct); + + // test resize(1), resize(0), capacity, and clear + size_t i = x.capacity(); + ok &= i >= 2; + x.resize(1); + ok &= x[0] == Type(1); + ok &= i == x.capacity(); + x.resize(0); + ok &= i == x.capacity(); + x.clear(); + ok &= 0 == x.capacity(); + + // test of push_back scalar and capacity + size_t N = 100; + for(i = 0; i < N; i++) + { 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(); + } + for(i = 0; i < N; i++) + ok &= ( x[i] == Type(i) ); + + // test of data + Type* data = x.data(); + for(i = 0; i < N; i++) + { ok &= data[i] == Type(i); + data[i] = Type(N - i); + ok &= x[i] == Type(N - i); + } + + // test of push_vector + x.push_vector(x); + ok &= (x.size() == 2 * N); + for(i = 0; i < N; i++) + { ok &= x[i] == Type(N - i); + ok &= x[i+N] == Type(N - i); + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/error_handler.cpp cppad-2019.02.00.0/example/utility/error_handler.cpp --- cppad-2018.00.00.0/example/utility/error_handler.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/error_handler.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin error_handler.cpp$$ $spell - CppAD + CppAD $$ $section Replacing The CppAD Error Handler: Example and Test$$ -$mindex handler$$ -$code $srcfile%example/utility/error_handler.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,51 +28,51 @@ # include namespace { - void myhandler( - bool known , - int line , - const char *file , - const char *exp , - const char *msg ) - { // error handler must not return, so throw an exception - throw line; - } + void myhandler( + bool known , + int line , + const char *file , + const char *exp , + const char *msg ) + { // error handler must not return, so throw an exception + throw line; + } } bool ErrorHandler(void) -{ using CppAD::ErrorHandler; +{ using CppAD::ErrorHandler; - int lineMinusFive = 0; + int lineMinusFive = 0; - // replace the default CppAD error handler - ErrorHandler info(myhandler); + // replace the default CppAD error handler + ErrorHandler info(myhandler); - // set ok to false unless catch block is executed - bool ok = false; - - // use try / catch because handler throws an exception - 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 - __LINE__ , // current source code line number - __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 - ok = (line == lineMinusFive + 5); - } - - // info drops out of scope and the default CppAD error handler - // is restored when this routine returns. - return ok; + // set ok to false unless catch block is executed + bool ok = false; + + // use try / catch because handler throws an exception + 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 + __LINE__ , // current source code line number + __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 + ok = (line == lineMinusFive + 5); + } + + // info drops out of scope and the default CppAD error handler + // is restored when this routine returns. + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/index_sort.cpp cppad-2019.02.00.0/example/utility/index_sort.cpp --- cppad-2018.00.00.0/example/utility/index_sort.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/index_sort.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,22 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin index_sort.cpp$$ $section Index Sort: Example and Test$$ -$mindex index_sort$$ -$code $srcfile%example/utility/index_sort.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,67 +28,68 @@ namespace{ - // class that uses < to compare a pair of size_t values - class Key { - public: - size_t first_; - size_t second_; - // - Key(void) - { } - // - Key(size_t first, size_t second) - : first_(first), second_(second) - { } - // - bool operator<(const Key& other) const - { if( first_ == other.first_ ) - return second_ < other.second_; - return first_ < other.first_; - } - }; - - template - bool vector_case(void) - { bool ok = true; - size_t i, j; - 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] ]; - } + // class that uses < to compare a pair of size_t values + class Key { + public: + size_t first_; + size_t second_; + // + Key(void) + { } + // + Key(size_t first, size_t second) + : first_(first), second_(second) + { } + // + bool operator<(const Key& other) const + { if( first_ == other.first_ ) + return second_ < other.second_; + return first_ < other.first_; + } + }; + + template + bool vector_case(void) + { bool ok = true; + size_t i, j; + 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]); + + KeyVector keys(size); + for(i = 0; i < size; i++) + keys[i] = Key(first[i], second[i]); + + SizeVector 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; - } + return ok; + } } bool index_sort(void) -{ bool ok = true; +{ bool ok = true; - // some example simple vector template classes - ok &= vector_case< std::vector, std::valarray >(); - ok &= vector_case< std::valarray, CppAD::vector >(); - ok &= vector_case< CppAD::vector, std::vector >(); + // some example simple vector template classes + ok &= vector_case< std::vector, std::valarray >(); + ok &= vector_case< std::valarray, CppAD::vector >(); + ok &= vector_case< CppAD::vector, std::vector >(); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/lu_factor.cpp cppad-2019.02.00.0/example/utility/lu_factor.cpp --- cppad-2018.00.00.0/example/utility/lu_factor.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/lu_factor.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,27 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin lu_factor.cpp$$ $spell - Geq - Cpp - Lu + Geq + Cpp + Lu $$ $section LuFactor: Example and Test$$ -$mindex LuFactor$$ -$code $srcfile%example/utility/lu_factor.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -35,86 +33,86 @@ # include // for CppAD::vector bool LuFactor(void) -{ bool ok = true; +{ bool ok = true; # ifndef _MSC_VER - using std::rand; - using std::srand; + using std::rand; + using std::srand; # endif - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); - 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 - size_t i, j, k; // temporary indices - - // A is an n by n matrix - CppAD::vector A(n*n), LU(n*n), L(n*n), U(n*n); - - // set A equal to an n by n random matrix - for(i = 0; i < n; i++) - for(j = 0; j < n; j++) - A[i * n + j] = rand() / rand_max; - - // pivot vectors - CppAD::vector ip(n); - CppAD::vector jp(n); - - // factor the matrix A - LU = A; - CppAD::LuFactor(ip, jp, LU); - - // check that ip and jp are permutations of the indices 0, ... , n-1 - for(i = 0; i < n; i++) - { ok &= (ip[i] < n); - ok &= (jp[i] < n); - for(j = 0; j < n; j++) - { if( i != j ) - { ok &= (ip[i] != ip[j]); - ok &= (jp[i] != jp[j]); - } - } - } - - // Extract L from LU - for(i = 0; i < n; i++) - { // elements along and below the diagonal - for(j = 0; j <= i; j++) - L[i * n + j] = LU[ ip[i] * n + jp[j] ]; - // elements above the diagonal - 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 - for(j = 0; j < i; j++) - U[i * n + j] = 0.; - // elements along the diagonal - U[i * n + i] = 1.; - // elements above the diagonal - for(j = i+1; j < n; j++) - U[i * n + j] = LU[ ip[i] * n + jp[j] ]; - } - - // Compute L * U - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - { // compute element (i,j) entry in L * U - sum = 0.; - for(k = 0; k < n; k++) - sum += L[i * n + k] * U[k * n + j]; - // element (i,j) in permuted version of A - pij = A[ ip[i] * n + jp[j] ]; - // compare - ok &= NearEqual(pij, sum, eps99, eps99); - } - } + 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 + size_t i, j, k; // temporary indices + + // A is an n by n matrix + CppAD::vector A(n*n), LU(n*n), L(n*n), U(n*n); + + // set A equal to an n by n random matrix + for(i = 0; i < n; i++) + for(j = 0; j < n; j++) + A[i * n + j] = rand() / rand_max; + + // pivot vectors + CppAD::vector ip(n); + CppAD::vector jp(n); + + // factor the matrix A + LU = A; + CppAD::LuFactor(ip, jp, LU); + + // check that ip and jp are permutations of the indices 0, ... , n-1 + for(i = 0; i < n; i++) + { ok &= (ip[i] < n); + ok &= (jp[i] < n); + for(j = 0; j < n; j++) + { if( i != j ) + { ok &= (ip[i] != ip[j]); + ok &= (jp[i] != jp[j]); + } + } + } + + // Extract L from LU + for(i = 0; i < n; i++) + { // elements along and below the diagonal + for(j = 0; j <= i; j++) + L[i * n + j] = LU[ ip[i] * n + jp[j] ]; + // elements above the diagonal + 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 + for(j = 0; j < i; j++) + U[i * n + j] = 0.; + // elements along the diagonal + U[i * n + i] = 1.; + // elements above the diagonal + for(j = i+1; j < n; j++) + U[i * n + j] = LU[ ip[i] * n + jp[j] ]; + } + + // Compute L * U + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { // compute element (i,j) entry in L * U + sum = 0.; + for(k = 0; k < n; k++) + sum += L[i * n + k] * U[k * n + j]; + // element (i,j) in permuted version of A + pij = A[ ip[i] * n + jp[j] ]; + // compare + ok &= NearEqual(pij, sum, eps99, eps99); + } + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/lu_invert.cpp cppad-2019.02.00.0/example/utility/lu_invert.cpp --- cppad-2018.00.00.0/example/utility/lu_invert.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/lu_invert.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,27 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin lu_invert.cpp$$ $spell - Geq - Cpp - Lu + Geq + Cpp + Lu $$ $section LuInvert: Example and Test$$ -$mindex LuInvert$$ -$code $srcfile%example/utility/lu_invert.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -36,96 +34,96 @@ # include // for CppAD::vector bool LuInvert(void) -{ bool ok = true; +{ bool ok = true; # ifndef _MSC_VER - using std::rand; - using std::srand; + using std::rand; + using std::srand; # endif - double eps200 = 200.0 * std::numeric_limits::epsilon(); + double eps200 = 200.0 * std::numeric_limits::epsilon(); - 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 - 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); - - // pivot vectors - CppAD::vector ip(n); - CppAD::vector jp(n); - - // set pivot vectors - for(i = 0; i < n; i++) - { ip[i] = (i + 2) % n; // ip = 2 , 3, ... , n-1, 0, 1 - jp[i] = (n + 2 - i) % n; // jp = 2 , 1, n-1, n-2, ... , 3 - } - - // chose L, a random lower triangular matrix - for(i = 0; i < n; i++) - { for(j = 0; j <= i; j++) - L [i * n + j] = rand() / rand_max; - for(j = i+1; j < n; j++) - L [i * n + j] = 0.; - } - // 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 + i ] = 1.; - for(j = i+1; j < n; j++) - U [i * n + j] = rand() / rand_max; - } - // chose X, a random matrix - for(i = 0; i < n; i++) - { for(k = 0; k < m; k++) - X[i * m + k] = rand() / rand_max; - } - // set LU to a permuted combination of both L and U - for(i = 0; i < n; i++) - { for(j = 0; j <= i; j++) - LU [ ip[i] * n + jp[j] ] = L[i * n + j]; - 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 - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - { // compute (i,j) entry in permuted matrix - sum = 0.; - for(k = 0; k < n; k++) - sum += L[i * n + k] * U[k * n + j]; - A[ ip[i] * n + jp[j] ] = sum; - } - } - // set B to A * X - for(i = 0; i < n; i++) - { for(k = 0; k < m; k++) - { // compute (i,k) entry of B - sum = 0.; - for(j = 0; j < n; j++) - sum += A[i * n + j] * X[j * m + k]; - B[i * m + k] = sum; - } - } - // solve for X - CppAD::LuInvert(ip, jp, LU, B); - - // check result - for(i = 0; i < n; i++) - { for(k = 0; k < m; k++) - { ok &= CppAD::NearEqual( - X[i * m + k], B[i * m + k], eps200, eps200 - ); - } - } - return ok; + 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 + 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); + + // pivot vectors + CppAD::vector ip(n); + CppAD::vector jp(n); + + // set pivot vectors + for(i = 0; i < n; i++) + { ip[i] = (i + 2) % n; // ip = 2 , 3, ... , n-1, 0, 1 + jp[i] = (n + 2 - i) % n; // jp = 2 , 1, n-1, n-2, ... , 3 + } + + // chose L, a random lower triangular matrix + for(i = 0; i < n; i++) + { for(j = 0; j <= i; j++) + L [i * n + j] = rand() / rand_max; + for(j = i+1; j < n; j++) + L [i * n + j] = 0.; + } + // 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 + i ] = 1.; + for(j = i+1; j < n; j++) + U [i * n + j] = rand() / rand_max; + } + // chose X, a random matrix + for(i = 0; i < n; i++) + { for(k = 0; k < m; k++) + X[i * m + k] = rand() / rand_max; + } + // set LU to a permuted combination of both L and U + for(i = 0; i < n; i++) + { for(j = 0; j <= i; j++) + LU [ ip[i] * n + jp[j] ] = L[i * n + j]; + 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 + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { // compute (i,j) entry in permuted matrix + sum = 0.; + for(k = 0; k < n; k++) + sum += L[i * n + k] * U[k * n + j]; + A[ ip[i] * n + jp[j] ] = sum; + } + } + // set B to A * X + for(i = 0; i < n; i++) + { for(k = 0; k < m; k++) + { // compute (i,k) entry of B + sum = 0.; + for(j = 0; j < n; j++) + sum += A[i * n + j] * X[j * m + k]; + B[i * m + k] = sum; + } + } + // solve for X + CppAD::LuInvert(ip, jp, LU, B); + + // check result + for(i = 0; i < n; i++) + { for(k = 0; k < m; k++) + { ok &= CppAD::NearEqual( + X[i * m + k], B[i * m + k], eps200, eps200 + ); + } + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/lu_solve.cpp cppad-2019.02.00.0/example/utility/lu_solve.cpp --- cppad-2018.00.00.0/example/utility/lu_solve.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/lu_solve.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,27 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin lu_solve.cpp$$ $spell - Geq - Cpp - Lu + Geq + Cpp + Lu $$ $section LuSolve With Complex Arguments: Example and Test$$ -$code $srcfile%example/utility/lu_solve.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -36,57 +35,57 @@ typedef std::complex Complex; // define the Complex type bool LuSolve(void) -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - size_t n = 3; // number rows in A and B - size_t m = 2; // number columns in B, X and S + size_t n = 3; // number rows in A and B + size_t m = 2; // number columns in B, X and S - // A is an n by n matrix, B, X, and S are n by m matrices - CppAD::vector A(n * n), B(n * m), X(n * m) , S(n * m); + // A is an n by n matrix, B, X, and S are n by m matrices + CppAD::vector A(n * n), B(n * m), X(n * m) , S(n * m); - Complex logdet; // log of determinant of A - int signdet; // zero if A is singular - Complex det; // determinant of A - size_t i, j, k; // some temporary indices - - // set A equal to the n by n Hilbert Matrix - for(i = 0; i < n; i++) - for(j = 0; j < n; j++) - A[i * n + j] = 1. / (double) (i + j + 1); - - // set S to the solution of the equation we will solve - for(j = 0; j < n; j++) - for(k = 0; k < m; k++) - S[ j * m + k ] = Complex(double(j), double(j + k)); - - // set B = A * S - size_t ik; - Complex sum; - for(k = 0; k < m; k++) - { for(i = 0; i < n; i++) - { sum = 0.; - for(j = 0; j < n; j++) - sum += A[i * n + j] * S[j * m + k]; - B[i * m + k] = sum; - } - } - - // solve the equation A * X = B and compute determinant of A - signdet = CppAD::LuSolve(n, m, A, B, X, logdet); - det = Complex( signdet ) * exp( logdet ); - - double cond = 4.62963e-4; // condition number of A when n = 3 - double determinant = 1. / 2160.; // determinant of A when n = 3 - double delta = 1e-14 / cond; // accuracy expected in X - - // check determinant - ok &= CppAD::NearEqual(det, determinant, delta, delta); - - // check solution - for(ik = 0; ik < n * m; ik++) - ok &= CppAD::NearEqual(X[ik], S[ik], delta, delta); + Complex logdet; // log of determinant of A + int signdet; // zero if A is singular + Complex det; // determinant of A + size_t i, j, k; // some temporary indices + + // set A equal to the n by n Hilbert Matrix + for(i = 0; i < n; i++) + for(j = 0; j < n; j++) + A[i * n + j] = 1. / (double) (i + j + 1); + + // set S to the solution of the equation we will solve + for(j = 0; j < n; j++) + for(k = 0; k < m; k++) + S[ j * m + k ] = Complex(double(j), double(j + k)); + + // set B = A * S + size_t ik; + Complex sum; + for(k = 0; k < m; k++) + { for(i = 0; i < n; i++) + { sum = 0.; + for(j = 0; j < n; j++) + sum += A[i * n + j] * S[j * m + k]; + B[i * m + k] = sum; + } + } + + // solve the equation A * X = B and compute determinant of A + signdet = CppAD::LuSolve(n, m, A, B, X, logdet); + det = Complex( signdet ) * exp( logdet ); + + double cond = 4.62963e-4; // condition number of A when n = 3 + double determinant = 1. / 2160.; // determinant of A when n = 3 + double delta = 1e-14 / cond; // accuracy expected in X + + // check determinant + ok &= CppAD::NearEqual(det, determinant, delta, delta); + + // check solution + for(ik = 0; ik < n * m; ik++) + ok &= CppAD::NearEqual(X[ik], S[ik], delta, delta); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/makefile.am cppad-2019.02.00.0/example/utility/makefile.am --- cppad-2018.00.00.0/example/utility/makefile.am 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -15,9 +16,12 @@ # check_PROGRAMS = utility # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) # -AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # utility_SOURCES = \ check_numeric_type.cpp \ diff -Nru cppad-2018.00.00.0/example/utility/makefile.in cppad-2019.02.00.0/example/utility/makefile.in --- cppad-2018.00.00.0/example/utility/makefile.in 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -192,19 +192,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -277,10 +276,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -299,9 +296,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -324,8 +323,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -346,9 +343,13 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + # -AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # utility_SOURCES = \ check_numeric_type.cpp \ diff -Nru cppad-2018.00.00.0/example/utility/nan.cpp cppad-2019.02.00.0/example/utility/nan.cpp --- cppad-2018.00.00.0/example/utility/nan.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/nan.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin nan.cpp$$ @@ -15,9 +16,7 @@ $section nan: Example and Test$$ -$code $srcfile%example/utility/nan.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -28,30 +27,30 @@ # include bool nan(void) -{ bool ok = true; +{ bool ok = true; - // get a nan - double double_zero = 0.; - double double_nan = std::numeric_limits::quiet_NaN(); - - // create a simple vector with no nans - std::vector v(2); - v[0] = double_zero; - v[1] = double_zero; - - // check that zero is not nan - ok &= ! CppAD::isnan(double_zero); - ok &= ! CppAD::hasnan(v); - - // check that nan is a nan - v[1] = double_nan; - ok &= CppAD::isnan(double_nan); - ok &= CppAD::hasnan(v); + // get a nan + double double_zero = 0.; + double double_nan = std::numeric_limits::quiet_NaN(); + + // create a simple vector with no nans + std::vector v(2); + v[0] = double_zero; + v[1] = double_zero; + + // check that zero is not nan + ok &= ! CppAD::isnan(double_zero); + ok &= ! CppAD::hasnan(v); + + // check that nan is a nan + v[1] = double_nan; + ok &= CppAD::isnan(double_nan); + ok &= CppAD::hasnan(v); - // check that nan is not equal to itself - ok &= (double_nan != double_nan); + // check that nan is not equal to itself + ok &= (double_nan != double_nan); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/near_equal.cpp cppad-2019.02.00.0/example/utility/near_equal.cpp --- cppad-2018.00.00.0/example/utility/near_equal.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/near_equal.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,20 +1,21 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin near_equal.cpp$$ $spell - cpp - abs -o Microsoft + cpp + abs +o Microsoft $$ $section NearEqual Function: Example and Test$$ @@ -25,9 +26,7 @@ to avoid a name conflict with $code ../lib/NearEqual.cpp$$ in the corresponding Microsoft project file. -$code $srcfile%example/utility/near_equal.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -38,44 +37,44 @@ # include bool Near_Equal(void) -{ bool ok = true; - typedef std::complex Complex; - using CppAD::NearEqual; - - // double - double x = 1.00000; - double y = 1.00001; - double a = .00003; - double r = .00003; - double zero = 0.; - double inf = 1. / zero; - double nan = 0. / zero; - - ok &= NearEqual(x, y, zero, a); - ok &= NearEqual(x, y, r, zero); - ok &= NearEqual(x, y, r, a); - - ok &= ! NearEqual(x, y, r / 10., a / 10.); - ok &= ! NearEqual(inf, inf, r, a); - ok &= ! NearEqual(-inf, -inf, r, a); - ok &= ! NearEqual(nan, nan, r, a); - - // complex - Complex X(x, x / 2.); - Complex Y(y, y / 2.); - Complex Inf(inf, zero); - Complex Nan(zero, nan); - - ok &= NearEqual(X, Y, zero, a); - ok &= NearEqual(X, Y, r, zero); - ok &= NearEqual(X, Y, r, a); - - ok &= ! NearEqual(X, Y, r / 10., a / 10.); - ok &= ! NearEqual(Inf, Inf, r, a); - ok &= ! NearEqual(-Inf, -inf, r, a); - ok &= ! NearEqual(Nan, Nan, r, a); +{ bool ok = true; + typedef std::complex Complex; + using CppAD::NearEqual; + + // double + double x = 1.00000; + double y = 1.00001; + double a = .00003; + double r = .00003; + double zero = 0.; + double inf = 1. / zero; + double nan = 0. / zero; + + ok &= NearEqual(x, y, zero, a); + ok &= NearEqual(x, y, r, zero); + ok &= NearEqual(x, y, r, a); + + ok &= ! NearEqual(x, y, r / 10., a / 10.); + ok &= ! NearEqual(inf, inf, r, a); + ok &= ! NearEqual(-inf, -inf, r, a); + ok &= ! NearEqual(nan, nan, r, a); + + // complex + Complex X(x, x / 2.); + Complex Y(y, y / 2.); + Complex Inf(inf, zero); + Complex Nan(zero, nan); + + ok &= NearEqual(X, Y, zero, a); + ok &= NearEqual(X, Y, r, zero); + ok &= NearEqual(X, Y, r, a); + + ok &= ! NearEqual(X, Y, r / 10., a / 10.); + ok &= ! NearEqual(Inf, Inf, r, a); + ok &= ! NearEqual(-Inf, -inf, r, a); + ok &= ! NearEqual(Nan, Nan, r, a); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/ode_err_control.cpp cppad-2019.02.00.0/example/utility/ode_err_control.cpp --- cppad-2018.00.00.0/example/utility/ode_err_control.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/ode_err_control.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ode_err_control.cpp$$ @@ -21,10 +22,10 @@ $latex X : \B{R} \rightarrow \B{R}^2$$ by $latex \[ \begin{array}{rcl} - X_0 (0) & = & 1 \\ - X_1 (0) & = & 0 \\ - X_0^{(1)} (t) & = & - \alpha X_0 (t) \\ - X_1^{(1)} (t) & = & 1 / X_0 (t) + X_0 (0) & = & 1 \\ + X_1 (0) & = & 0 \\ + X_0^{(1)} (t) & = & - \alpha X_0 (t) \\ + X_1^{(1)} (t) & = & 1 / X_0 (t) \end{array} \] $$ It follows that @@ -45,9 +46,7 @@ $code OdeErrControl$$ that its is taking to large a step. -$code $srcfile%example/utility/ode_err_control.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -62,91 +61,91 @@ # include // CppAD::Runge45 namespace { - // -------------------------------------------------------------- - class Fun { - private: - const double alpha_; - public: - // constructor - Fun(double alpha) : alpha_(alpha) - { } - - // set f = x'(t) - void Ode( - const double &t, - const CppAD::vector &x, - CppAD::vector &f) - { f[0] = - alpha_ * x[0]; - f[1] = 1. / x[0]; - // case where ODE does not make sense - if( x[0] < 0. ) - f[1] = std::numeric_limits::quiet_NaN(); - } - - }; - - // -------------------------------------------------------------- - class Method { - private: - Fun F; - public: - // constructor - Method(double alpha) : F(alpha) - { } - void step( - double ta, - double tb, - CppAD::vector &xa , - CppAD::vector &xb , - CppAD::vector &eb ) - { xb = CppAD::Runge45(F, 1, ta, tb, xa, eb); - } - size_t order(void) - { return 4; } - }; + // -------------------------------------------------------------- + class Fun { + private: + const double alpha_; + public: + // constructor + Fun(double alpha) : alpha_(alpha) + { } + + // set f = x'(t) + void Ode( + const double &t, + const CppAD::vector &x, + CppAD::vector &f) + { f[0] = - alpha_ * x[0]; + f[1] = 1. / x[0]; + // case where ODE does not make sense + if( x[0] < 0. ) + f[1] = std::numeric_limits::quiet_NaN(); + } + + }; + + // -------------------------------------------------------------- + class Method { + private: + Fun F; + public: + // constructor + Method(double alpha) : F(alpha) + { } + void step( + double ta, + double tb, + CppAD::vector &xa , + CppAD::vector &xb , + CppAD::vector &eb ) + { xb = CppAD::Runge45(F, 1, ta, tb, xa, eb); + } + size_t order(void) + { return 4; } + }; } bool OdeErrControl(void) -{ bool ok = true; // initial return value +{ bool ok = true; // initial return value - double alpha = 10.; - Method method(alpha); + double alpha = 10.; + Method method(alpha); - CppAD::vector xi(2); - xi[0] = 1.; - xi[1] = 0.; - - CppAD::vector eabs(2); - eabs[0] = 1e-4; - eabs[1] = 1e-4; - - // inputs - double ti = 0.; - double tf = 1.; - double smin = 1e-4; - double smax = 1.; - double scur = 1.; - double erel = 0.; - - // outputs - CppAD::vector ef(2); - CppAD::vector xf(2); - CppAD::vector maxabs(2); - size_t nstep; - - - xf = OdeErrControl(method, - ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); - - double x0 = exp(-alpha*tf); - ok &= CppAD::NearEqual(x0, xf[0], 1e-4, 1e-4); - ok &= CppAD::NearEqual(0., ef[0], 1e-4, 1e-4); - - double x1 = (exp(alpha*tf) - 1) / alpha; - ok &= CppAD::NearEqual(x1, xf[1], 1e-4, 1e-4); - ok &= CppAD::NearEqual(0., ef[1], 1e-4, 1e-4); + CppAD::vector xi(2); + xi[0] = 1.; + xi[1] = 0.; + + CppAD::vector eabs(2); + eabs[0] = 1e-4; + eabs[1] = 1e-4; + + // inputs + double ti = 0.; + double tf = 1.; + double smin = 1e-4; + double smax = 1.; + double scur = 1.; + double erel = 0.; + + // outputs + CppAD::vector ef(2); + CppAD::vector xf(2); + CppAD::vector maxabs(2); + size_t nstep; + + + xf = OdeErrControl(method, + ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); + + double x0 = exp(-alpha*tf); + ok &= CppAD::NearEqual(x0, xf[0], 1e-4, 1e-4); + ok &= CppAD::NearEqual(0., ef[0], 1e-4, 1e-4); + + double x1 = (exp(alpha*tf) - 1) / alpha; + ok &= CppAD::NearEqual(x1, xf[1], 1e-4, 1e-4); + ok &= CppAD::NearEqual(0., ef[1], 1e-4, 1e-4); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/ode_err_maxabs.cpp cppad-2019.02.00.0/example/utility/ode_err_maxabs.cpp --- cppad-2018.00.00.0/example/utility/ode_err_maxabs.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/ode_err_maxabs.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ode_err_maxabs.cpp$$ $spell - Runge - Maxabs + Runge + Maxabs $$ $section OdeErrControl: Example and Test Using Maxabs Argument$$ -$mindex OdeErrControl$$ Define @@ -31,17 +31,15 @@ It follows that $latex X_0 (0) = 1$$, $latex X_1 (0) = 0$$ and $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_0^{(1)} (t) & = & - w_0 X_0 (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, $latex X_0 (t)$$ is near zero. This example tests OdeErrControl using the $icode maxabs$$ argument. -$code $srcfile%example/utility/ode_err_maxabs.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -55,94 +53,94 @@ # include // CppAD::Runge45 namespace { - // -------------------------------------------------------------- - class Fun { - private: - CppAD::vector w; - public: - // constructor - Fun(const CppAD::vector &w_) : w(w_) - { } - - // set f = x'(t) - void Ode( - 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]; - } - }; - - // -------------------------------------------------------------- - class Method { - private: - Fun F; - public: - // constructor - Method(const CppAD::vector &w_) : F(w_) - { } - void step( - double ta, - double tb, - CppAD::vector &xa , - CppAD::vector &xb , - CppAD::vector &eb ) - { xb = CppAD::Runge45(F, 1, ta, tb, xa, eb); - } - size_t order(void) - { return 4; } - }; + // -------------------------------------------------------------- + class Fun { + private: + CppAD::vector w; + public: + // constructor + Fun(const CppAD::vector &w_) : w(w_) + { } + + // set f = x'(t) + void Ode( + 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]; + } + }; + + // -------------------------------------------------------------- + class Method { + private: + Fun F; + public: + // constructor + Method(const CppAD::vector &w_) : F(w_) + { } + void step( + double ta, + double tb, + CppAD::vector &xa , + CppAD::vector &xb , + CppAD::vector &eb ) + { xb = CppAD::Runge45(F, 1, ta, tb, xa, eb); + } + size_t order(void) + { return 4; } + }; } bool OdeErrMaxabs(void) -{ bool ok = true; // initial return value +{ bool ok = true; // initial return value - CppAD::vector w(2); - w[0] = 10.; - w[1] = 1.; - Method method(w); - - CppAD::vector xi(2); - xi[0] = 1.; - xi[1] = 0.; - - CppAD::vector eabs(2); - eabs[0] = 0.; - eabs[1] = 0.; - - CppAD::vector ef(2); - CppAD::vector xf(2); - CppAD::vector maxabs(2); - - double ti = 0.; - double tf = 1.; - double smin = .5; - double smax = 1.; - double scur = .5; - double erel = 1e-4; - - bool accurate = false; - while( ! accurate ) - { xf = OdeErrControl(method, - ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs); - accurate = true; - size_t i; - for(i = 0; i < 2; i++) - 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.); - ok &= CppAD::NearEqual(0., ef[0], erel, erel); - - double x1 = w[0] * (exp(-w[0]*tf) - exp(-w[1]*tf))/(w[1] - w[0]); - ok &= CppAD::NearEqual(x1, xf[1], erel, 0.); - ok &= CppAD::NearEqual(0., ef[1], erel, erel); + CppAD::vector w(2); + w[0] = 10.; + w[1] = 1.; + Method method(w); + + CppAD::vector xi(2); + xi[0] = 1.; + xi[1] = 0.; + + CppAD::vector eabs(2); + eabs[0] = 0.; + eabs[1] = 0.; + + CppAD::vector ef(2); + CppAD::vector xf(2); + CppAD::vector maxabs(2); + + double ti = 0.; + double tf = 1.; + double smin = .5; + double smax = 1.; + double scur = .5; + double erel = 1e-4; + + bool accurate = false; + while( ! accurate ) + { xf = OdeErrControl(method, + ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs); + accurate = true; + size_t i; + for(i = 0; i < 2; i++) + 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.); + ok &= CppAD::NearEqual(0., ef[0], erel, erel); + + double x1 = w[0] * (exp(-w[0]*tf) - exp(-w[1]*tf))/(w[1] - w[0]); + ok &= CppAD::NearEqual(x1, xf[1], erel, 0.); + ok &= CppAD::NearEqual(0., ef[1], erel, erel); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/ode_gear_control.cpp cppad-2019.02.00.0/example/utility/ode_gear_control.cpp --- cppad-2018.00.00.0/example/utility/ode_gear_control.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/ode_gear_control.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,22 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ode_gear_control.cpp$$ $spell - Runge + Runge $$ $section OdeGearControl: Example and Test$$ -$mindex OdeGearControl$$ Define @@ -30,15 +30,13 @@ It follows that $latex X_0 (0) = 1$$, $latex X_1 (0) = 0$$ and $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_0^{(1)} (t) & = & - w_0 X_0 (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: -$code $srcfile%example/utility/ode_gear_control.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -48,112 +46,112 @@ # include // CppAD::OdeGearControl namespace { - // -------------------------------------------------------------- - class Fun { - private: - CPPAD_TESTVECTOR(double) w; - 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, - CPPAD_TESTVECTOR(Scalar) &f) - { f[0] = - w[0] * x[0]; - f[1] = + w[0] * x[0] - w[1] * x[1]; - } - - void Ode_dep( - const double &t, - const CPPAD_TESTVECTOR(double) &x, - CPPAD_TESTVECTOR(double) &f_x) - { using namespace CppAD; - - size_t n = x.size(); - CPPAD_TESTVECTOR(AD) T(1); - CPPAD_TESTVECTOR(AD) X(n); - CPPAD_TESTVECTOR(AD) F(n); - - // set argument values - T[0] = t; - size_t i, j; - for(i = 0; i < n; i++) - X[i] = x[i]; - - // declare independent variables - Independent(X); - - // compute f(t, x) - this->Ode(T[0], X, F); - - // define AD function object - ADFun fun(X, F); - - // compute partial of f w.r.t x - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) df(n); - for(j = 0; j < n; j++) - dx[j] = 0.; - for(j = 0; j < n; j++) - { dx[j] = 1.; - df = fun.Forward(1, dx); - for(i = 0; i < n; i++) - f_x [i * n + j] = df[i]; - dx[j] = 0.; - } - } - }; + // -------------------------------------------------------------- + class Fun { + private: + CPPAD_TESTVECTOR(double) w; + 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, + CPPAD_TESTVECTOR(Scalar) &f) + { f[0] = - w[0] * x[0]; + f[1] = + w[0] * x[0] - w[1] * x[1]; + } + + void Ode_dep( + const double &t, + const CPPAD_TESTVECTOR(double) &x, + CPPAD_TESTVECTOR(double) &f_x) + { using namespace CppAD; + + size_t n = x.size(); + CPPAD_TESTVECTOR(AD) T(1); + CPPAD_TESTVECTOR(AD) X(n); + CPPAD_TESTVECTOR(AD) F(n); + + // set argument values + T[0] = t; + size_t i, j; + for(i = 0; i < n; i++) + X[i] = x[i]; + + // declare independent variables + Independent(X); + + // compute f(t, x) + this->Ode(T[0], X, F); + + // define AD function object + ADFun fun(X, F); + + // compute partial of f w.r.t x + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) df(n); + for(j = 0; j < n; j++) + dx[j] = 0.; + for(j = 0; j < n; j++) + { dx[j] = 1.; + df = fun.Forward(1, dx); + for(i = 0; i < n; i++) + f_x [i * n + j] = df[i]; + dx[j] = 0.; + } + } + }; } bool OdeGearControl(void) -{ bool ok = true; // initial return value - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - CPPAD_TESTVECTOR(double) w(2); - w[0] = 10.; - w[1] = 1.; - Fun F(w); - - CPPAD_TESTVECTOR(double) xi(2); - xi[0] = 1.; - xi[1] = 0.; - - CPPAD_TESTVECTOR(double) eabs(2); - eabs[0] = 1e-4; - eabs[1] = 1e-4; - - // return values - CPPAD_TESTVECTOR(double) ef(2); - CPPAD_TESTVECTOR(double) maxabs(2); - CPPAD_TESTVECTOR(double) xf(2); - size_t nstep; - - // input values - size_t M = 5; - double ti = 0.; - double tf = 1.; - double smin = 1e-8; - double smax = 1.; - double sini = eps99; - double erel = 0.; - - xf = CppAD::OdeGearControl(F, M, - ti, tf, xi, smin, smax, sini, eabs, erel, ef, maxabs, nstep); - - double x0 = exp(-w[0]*tf); - ok &= NearEqual(x0, xf[0], 1e-4, 1e-4); - ok &= NearEqual(0., ef[0], 1e-4, 1e-4); - - double x1 = w[0] * (exp(-w[0]*tf) - exp(-w[1]*tf))/(w[1] - w[0]); - ok &= NearEqual(x1, xf[1], 1e-4, 1e-4); - ok &= NearEqual(0., ef[1], 1e-4, 1e-4); +{ bool ok = true; // initial return value + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + CPPAD_TESTVECTOR(double) w(2); + w[0] = 10.; + w[1] = 1.; + Fun F(w); + + CPPAD_TESTVECTOR(double) xi(2); + xi[0] = 1.; + xi[1] = 0.; + + CPPAD_TESTVECTOR(double) eabs(2); + eabs[0] = 1e-4; + eabs[1] = 1e-4; + + // return values + CPPAD_TESTVECTOR(double) ef(2); + CPPAD_TESTVECTOR(double) maxabs(2); + CPPAD_TESTVECTOR(double) xf(2); + size_t nstep; + + // input values + size_t M = 5; + double ti = 0.; + double tf = 1.; + double smin = 1e-8; + double smax = 1.; + double sini = eps99; + double erel = 0.; + + xf = CppAD::OdeGearControl(F, M, + ti, tf, xi, smin, smax, sini, eabs, erel, ef, maxabs, nstep); + + double x0 = exp(-w[0]*tf); + ok &= NearEqual(x0, xf[0], 1e-4, 1e-4); + ok &= NearEqual(0., ef[0], 1e-4, 1e-4); + + double x1 = w[0] * (exp(-w[0]*tf) - exp(-w[1]*tf))/(w[1] - w[0]); + ok &= NearEqual(x1, xf[1], 1e-4, 1e-4); + ok &= NearEqual(0., ef[1], 1e-4, 1e-4); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/ode_gear.cpp cppad-2019.02.00.0/example/utility/ode_gear.cpp --- cppad-2018.00.00.0/example/utility/ode_gear.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/ode_gear.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,28 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ode_gear.cpp$$ $spell - Rosen + Rosen $$ $section OdeGear: Example and Test$$ -$mindex OdeGear$$ Define $latex x : \B{R} \rightarrow \B{R}^n$$ by $latex \[ - x_i (t) = t^{i+1} + x_i (t) = t^{i+1} \] $$ for $latex i = 1 , \ldots , n-1$$. It follows that @@ -35,9 +35,7 @@ \] $$ The example tests OdeGear using the relations above: -$code $srcfile%example/utility/ode_gear.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -47,131 +45,132 @@ # include // For automatic differentiation namespace { - class Fun { - public: - // constructor - 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, - CPPAD_TESTVECTOR(Scalar) &f) - { size_t n = x.size(); - Scalar ti(1); - f[0] = Scalar(1); - size_t i; - for(i = 1; i < n; i++) - { ti *= t; - // convert int(size_t) to avoid warning - // on _MSC_VER systems - if( use_x ) - f[i] = int(i+1) * x[i-1]; - else f[i] = int(i+1) * ti; - } - } - - void Ode_dep( - const double &t, - const CPPAD_TESTVECTOR(double) &x, - CPPAD_TESTVECTOR(double) &f_x) - { using namespace CppAD; - - size_t n = x.size(); - CPPAD_TESTVECTOR(AD) T(1); - CPPAD_TESTVECTOR(AD) X(n); - CPPAD_TESTVECTOR(AD) F(n); - - // set argument values - T[0] = t; - size_t i, j; - for(i = 0; i < n; i++) - X[i] = x[i]; - - // declare independent variables - Independent(X); - - // compute f(t, x) - this->Ode(T[0], X, F); - - // define AD function object - ADFun fun(X, F); - - // compute partial of f w.r.t x - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) df(n); - for(j = 0; j < n; j++) - dx[j] = 0.; - for(j = 0; j < n; j++) - { dx[j] = 1.; - df = fun.Forward(1, dx); - for(i = 0; i < n; i++) - f_x [i * n + j] = df[i]; - dx[j] = 0.; - } - } + class Fun { + public: + // constructor + 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, + CPPAD_TESTVECTOR(Scalar) &f) + { size_t n = x.size(); + Scalar ti(1); + f[0] = Scalar(1); + size_t i; + for(i = 1; i < n; i++) + { ti *= t; + // convert int(size_t) to avoid warning + // on _MSC_VER systems + if( use_x ) + f[i] = int(i+1) * x[i-1]; + else + f[i] = int(i+1) * ti; + } + } + + void Ode_dep( + const double &t, + const CPPAD_TESTVECTOR(double) &x, + CPPAD_TESTVECTOR(double) &f_x) + { using namespace CppAD; + + size_t n = x.size(); + CPPAD_TESTVECTOR(AD) T(1); + CPPAD_TESTVECTOR(AD) X(n); + CPPAD_TESTVECTOR(AD) F(n); + + // set argument values + T[0] = t; + size_t i, j; + for(i = 0; i < n; i++) + X[i] = x[i]; + + // declare independent variables + Independent(X); + + // compute f(t, x) + this->Ode(T[0], X, F); + + // define AD function object + ADFun fun(X, F); + + // compute partial of f w.r.t x + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) df(n); + for(j = 0; j < n; j++) + dx[j] = 0.; + for(j = 0; j < n; j++) + { dx[j] = 1.; + df = fun.Forward(1, dx); + for(i = 0; i < n; i++) + f_x [i * n + j] = df[i]; + dx[j] = 0.; + } + } - private: - const bool use_x; + private: + const bool use_x; - }; + }; } bool OdeGear(void) -{ bool ok = true; // initial return value - size_t i, j; // temporary indices - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - size_t m = 4; // index of next value in X - size_t n = m; // number of components in x(t) - - // vector of times - CPPAD_TESTVECTOR(double) T(m+1); - double step = .1; - T[0] = 0.; - for(j = 1; j <= m; j++) - { T[j] = T[j-1] + step; - step = 2. * step; - } - - // initial values for x( T[m-j] ) - CPPAD_TESTVECTOR(double) X((m+1) * n); - for(j = 0; j < m; j++) - { double ti = T[j]; - for(i = 0; i < n; i++) - { X[ j * n + i ] = ti; - ti *= T[j]; - } - } - - // error bound - CPPAD_TESTVECTOR(double) e(n); - - 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); - - // compute OdeGear approximation for x( T[m] ) - CppAD::OdeGear(F, m, n, T, X, e); - - double check = T[m]; - for(i = 0; i < n; i++) - { // method is exact up to order m and x[i] = t^{i+1} - if( i + 1 <= m ) ok &= CppAD::NearEqual( - X[m * n + i], check, eps99, eps99 - ); - // error bound should be zero up to order m-1 - if( i + 1 < m ) ok &= CppAD::NearEqual( - e[i], 0., eps99, eps99 - ); - // check value for next i - check *= T[m]; - } - } - return ok; +{ bool ok = true; // initial return value + size_t i, j; // temporary indices + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + size_t m = 4; // index of next value in X + size_t n = m; // number of components in x(t) + + // vector of times + CPPAD_TESTVECTOR(double) T(m+1); + double step = .1; + T[0] = 0.; + for(j = 1; j <= m; j++) + { T[j] = T[j-1] + step; + step = 2. * step; + } + + // initial values for x( T[m-j] ) + CPPAD_TESTVECTOR(double) X((m+1) * n); + for(j = 0; j < m; j++) + { double ti = T[j]; + for(i = 0; i < n; i++) + { X[ j * n + i ] = ti; + ti *= T[j]; + } + } + + // error bound + CPPAD_TESTVECTOR(double) e(n); + + 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); + + // compute OdeGear approximation for x( T[m] ) + CppAD::OdeGear(F, m, n, T, X, e); + + double check = T[m]; + for(i = 0; i < n; i++) + { // method is exact up to order m and x[i] = t^{i+1} + if( i + 1 <= m ) ok &= CppAD::NearEqual( + X[m * n + i], check, eps99, eps99 + ); + // error bound should be zero up to order m-1 + if( i + 1 < m ) ok &= CppAD::NearEqual( + e[i], 0., eps99, eps99 + ); + // check value for next i + check *= T[m]; + } + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/romberg_mul.cpp cppad-2019.02.00.0/example/utility/romberg_mul.cpp --- cppad-2018.00.00.0/example/utility/romberg_mul.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/romberg_mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin Rombergmul.cpp$$ $spell - Romberg + Romberg $$ $section One Dimensional Romberg Integration: Example and Test$$ -$code $srcfile%example/utility/romberg_mul.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -33,92 +32,92 @@ namespace { - class TestFun { - private: - const CppAD::vector deg; - public: - // constructor - TestFun(const CppAD::vector deg_) - : deg(deg_) - { } - - // function F(x) = x[0]^deg[0] * x[1]^deg[1] - double operator () (const CppAD::vector &x) - { size_t i; - double f = 1; - for(i = 0; i < deg[0]; i++) - f *= x[0]; - for(i = 0; i < deg[1]; i++) - f *= x[1]; - return f; - } - }; + class TestFun { + private: + const CppAD::vector deg; + public: + // constructor + TestFun(const CppAD::vector deg_) + : deg(deg_) + { } + + // function F(x) = x[0]^deg[0] * x[1]^deg[1] + double operator () (const CppAD::vector &x) + { size_t i; + double f = 1; + for(i = 0; i < deg[0]; i++) + f *= x[0]; + for(i = 0; i < deg[1]; i++) + f *= x[1]; + return f; + } + }; } bool RombergMul(void) -{ bool ok = true; - size_t i; - size_t k; - - CppAD::vector deg(2); - deg[0] = 5; - deg[1] = 3; - TestFun F(deg); - - CppAD::RombergMul< - TestFun , - CppAD::vector, - CppAD::vector, - 2 > RombergMulTest; - - // arugments to RombergMul - CppAD::vector a(2); - CppAD::vector b(2); - CppAD::vector n(2); - CppAD::vector p(2); - for(i = 0; i < 2; i++) - { a[i] = 0.; - b[i] = 1.; - } - n[0] = 4; - n[1] = 3; - 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) - double bpow = 1.; - double apow = 1.; - for(i = 0; i <= deg[0]; i++) - { bpow *= b[0]; - apow *= a[0]; - } - double check = (bpow - apow) / double(deg[0]+1); - bpow = 1.; - apow = 1.; - for(i = 0; i <= deg[1]; i++) - { bpow *= b[1]; - apow *= a[1]; - } - check *= (bpow - apow) / double(deg[1]+1); - - double step = (b[1] - a[1]) / exp(log(2.)*double(n[1]-1)); - double spow = 1; - for(k = 0; k <= n[1]; k++) - { spow = spow * step * step; - double bnd = 3 * double(deg[1] + 1) * spow; - - for(i = 0; i < 2; i++) - p[i] = k; - r = RombergMulTest(F, a, b, n, p, e); +{ bool ok = true; + size_t i; + size_t k; + + CppAD::vector deg(2); + deg[0] = 5; + deg[1] = 3; + TestFun F(deg); + + CppAD::RombergMul< + TestFun , + CppAD::vector, + CppAD::vector, + 2 > RombergMulTest; + + // arugments to RombergMul + CppAD::vector a(2); + CppAD::vector b(2); + CppAD::vector n(2); + CppAD::vector p(2); + for(i = 0; i < 2; i++) + { a[i] = 0.; + b[i] = 1.; + } + n[0] = 4; + n[1] = 3; + 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) + double bpow = 1.; + double apow = 1.; + for(i = 0; i <= deg[0]; i++) + { bpow *= b[0]; + apow *= a[0]; + } + double check = (bpow - apow) / double(deg[0]+1); + bpow = 1.; + apow = 1.; + for(i = 0; i <= deg[1]; i++) + { bpow *= b[1]; + apow *= a[1]; + } + check *= (bpow - apow) / double(deg[1]+1); + + double step = (b[1] - a[1]) / exp(log(2.)*double(n[1]-1)); + double spow = 1; + for(k = 0; k <= n[1]; k++) + { spow = spow * step * step; + double bnd = 3 * double(deg[1] + 1) * spow; + + for(i = 0; i < 2; i++) + p[i] = k; + r = RombergMulTest(F, a, b, n, p, e); - ok &= e < bnd; - ok &= CppAD::NearEqual(check, r, 0., e); + ok &= e < bnd; + ok &= CppAD::NearEqual(check, r, 0., e); - } + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/romberg_one.cpp cppad-2019.02.00.0/example/utility/romberg_one.cpp --- cppad-2018.00.00.0/example/utility/romberg_one.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/romberg_one.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin romberg_one.cpp$$ $spell - Romberg + Romberg $$ $section One Dimensional Romberg Integration: Example and Test$$ -$code $srcfile%example/utility/romberg_one.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,66 +30,66 @@ # include namespace { - class Fun { - private: - const size_t degree; - public: - // constructor - Fun(size_t degree_) : degree(degree_) - { } - - // function F(x) = x^degree - template - Type operator () (const Type &x) - { size_t i; - Type f = 1; - for(i = 0; i < degree; i++) - f *= x; - return f; - } - }; + class Fun { + private: + const size_t degree; + public: + // constructor + Fun(size_t degree_) : degree(degree_) + { } + + // function F(x) = x^degree + template + Type operator () (const Type &x) + { size_t i; + Type f = 1; + for(i = 0; i < degree; i++) + f *= x; + return f; + } + }; } bool RombergOne(void) -{ bool ok = true; - size_t i; +{ bool ok = true; + size_t i; - size_t degree = 4; - Fun F(degree); + size_t degree = 4; + Fun F(degree); - // arguments to RombergOne - double a = 0.; - double b = 1.; - size_t n = 4; - size_t p; - double r, e; - - // 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) / double(degree+1); - - // step size corresponding to r - double step = (b - a) / exp(log(2.)*double(n-1)); - // step size corresponding to error estimate - step *= 2.; - // step size raised to a power - double spow = 1; - - for(p = 0; p < n; p++) - { spow = spow * step * step; - - r = CppAD::RombergOne(F, a, b, n, p, e); - - ok &= e < double(degree+1) * spow; - ok &= CppAD::NearEqual(check, r, 0., e); - } + // arguments to RombergOne + double a = 0.; + double b = 1.; + size_t n = 4; + size_t p; + double r, e; + + // 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) / double(degree+1); + + // step size corresponding to r + double step = (b - a) / exp(log(2.)*double(n-1)); + // step size corresponding to error estimate + step *= 2.; + // step size raised to a power + double spow = 1; + + for(p = 0; p < n; p++) + { spow = spow * step * step; + + r = CppAD::RombergOne(F, a, b, n, p, e); + + ok &= e < double(degree+1) * spow; + ok &= CppAD::NearEqual(check, r, 0., e); + } - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/runge45_1.cpp cppad-2019.02.00.0/example/utility/runge45_1.cpp --- cppad-2018.00.00.0/example/utility/runge45_1.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/runge45_1.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,28 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin runge45_1.cpp$$ $spell - Runge + Runge $$ $section Runge45: Example and Test$$ -$mindex Runge45$$ Define $latex X : \B{R} \rightarrow \B{R}^n$$ by $latex \[ - X_i (t) = t^{i+1} + X_i (t) = t^{i+1} \] $$ for $latex i = 1 , \ldots , n-1$$. It follows that @@ -35,9 +35,7 @@ \] $$ The example tests Runge45 using the relations above: -$code $srcfile%example/utility/runge45_1.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -53,76 +51,77 @@ # include // for fabs without std in front namespace { - class Fun { - public: - // constructor - Fun(bool use_x_) : use_x(use_x_) - { } - - // set f = x'(t) - void Ode( - const double &t, - const CppAD::vector &x, - CppAD::vector &f) - { size_t n = x.size(); - double ti = 1.; - f[0] = 1.; - size_t i; - for(i = 1; i < n; i++) - { ti *= t; - if( use_x ) - f[i] = double(i+1) * x[i-1]; - else f[i] = double(i+1) * ti; - } - } - private: - const bool use_x; + class Fun { + public: + // constructor + Fun(bool use_x_) : use_x(use_x_) + { } + + // set f = x'(t) + void Ode( + const double &t, + const CppAD::vector &x, + CppAD::vector &f) + { size_t n = x.size(); + double ti = 1.; + f[0] = 1.; + size_t i; + for(i = 1; i < n; i++) + { ti *= t; + if( use_x ) + f[i] = double(i+1) * x[i-1]; + else + f[i] = double(i+1) * ti; + } + } + private: + const bool use_x; - }; + }; } bool runge_45_1(void) -{ bool ok = true; // initial return value - size_t i; // temporary indices +{ bool ok = true; // initial return value + size_t i; // temporary indices - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); - 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 - - // xi = X(0) - CppAD::vector xi(n); - for(i = 0; i 0); - - // compute Runge45 approximation for X(tf) - CppAD::vector xf(n), e(n); - xf = CppAD::Runge45(F, M, ti, tf, xi, e); - - double check = tf; - for(i = 0; i < n; i++) - { // check that error is always positive - ok &= (e[i] >= 0.); - // 5th order method is exact for i < 5 - if( i < 5 ) ok &= - NearEqual(xf[i], check, eps99, eps99); - // 4th order method is exact for i < 4 - if( i < 4 ) - ok &= (e[i] <= eps99); - - // check value for next i - check *= tf; - } - } - return ok; + 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 + + // xi = X(0) + CppAD::vector xi(n); + for(i = 0; i 0); + + // compute Runge45 approximation for X(tf) + CppAD::vector xf(n), e(n); + xf = CppAD::Runge45(F, M, ti, tf, xi, e); + + double check = tf; + for(i = 0; i < n; i++) + { // check that error is always positive + ok &= (e[i] >= 0.); + // 5th order method is exact for i < 5 + if( i < 5 ) ok &= + NearEqual(xf[i], check, eps99, eps99); + // 4th order method is exact for i < 4 + if( i < 4 ) + ok &= (e[i] <= eps99); + + // check value for next i + check *= tf; + } + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/set_union.cpp cppad-2019.02.00.0/example/utility/set_union.cpp --- cppad-2018.00.00.0/example/utility/set_union.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/set_union.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin set_union.cpp$$ @@ -15,9 +16,7 @@ $section Set Union: Example and Test$$ -$code $srcfile%example/utility/set_union.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -25,30 +24,30 @@ # include bool set_union(void) -{ bool ok = true; +{ bool ok = true; - // create empty sets - std::set left, right, result; + // create empty sets + std::set left, right, result; - // set left = {1, 2} - left.insert(1); - left.insert(2); + // set left = {1, 2} + left.insert(1); + left.insert(2); - // set right = {2, 3} - right.insert(2); - right.insert(3); + // set right = {2, 3} + right.insert(2); + right.insert(3); - // set result = {1, 2} U {2, 3} - result = CppAD::set_union(left, right); + // set result = {1, 2} U {2, 3} + result = CppAD::set_union(left, right); - // expected result - size_t check_vec[] = {1, 2, 3}; - std::set check_set(check_vec, check_vec + 3); + // expected result + size_t check_vec[] = {1, 2, 3}; + std::set check_set(check_vec, check_vec + 3); - // check result - ok &= result == check_set; + // check result + ok &= result == check_set; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/simple_vector.cpp cppad-2019.02.00.0/example/utility/simple_vector.cpp --- cppad-2018.00.00.0/example/utility/simple_vector.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/simple_vector.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin simple_vector.cpp$$ $spell - Cpp + Cpp $$ $section Simple Vector Template Class: Example and Test$$ -$code $srcfile%example/utility/simple_vector.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end -------------------------------------------------------------------------- @@ -32,57 +31,57 @@ # include // CppAD::vector # include // CppAD::CheckSimpleVector namespace { - template - bool Ok(void) - { // type corresponding to elements of Vector - typedef typename Vector::value_type Scalar; - - bool ok = true; // initialize testing flag - - Vector x; // use the default constructor - ok &= (x.size() == 0); // test size for an empty vector - Vector y(2); // use the sizing constructor - ok &= (y.size() == 2); // size for an vector with elements - - // non-const access to the elements of y - size_t i; - for(i = 0; i < 2; i++) - y[i] = Scalar(i); - - const Vector z(y); // copy constructor - x.resize(2); // resize - x = z; // vector assignment - - // use the const access to the elements of x - // and test the values of elements of x, y, z - for(i = 0; i < 2; i++) - { ok &= (x[i] == Scalar(i)); - ok &= (y[i] == Scalar(i)); - ok &= (z[i] == Scalar(i)); - } - return ok; - } + template + bool Ok(void) + { // type corresponding to elements of Vector + typedef typename Vector::value_type Scalar; + + bool ok = true; // initialize testing flag + + Vector x; // use the default constructor + ok &= (x.size() == 0); // test size for an empty vector + Vector y(2); // use the sizing constructor + ok &= (y.size() == 2); // size for an vector with elements + + // non-const access to the elements of y + size_t i; + for(i = 0; i < 2; i++) + y[i] = Scalar(i); + + const Vector z(y); // copy constructor + x.resize(2); // resize + x = z; // vector assignment + + // use the const access to the elements of x + // and test the values of elements of x, y, z + for(i = 0; i < 2; i++) + { ok &= (x[i] == Scalar(i)); + ok &= (y[i] == Scalar(i)); + ok &= (z[i] == Scalar(i)); + } + return ok; + } } bool SimpleVector (void) -{ bool ok = true; +{ bool ok = true; - // use routine above to check these cases - ok &= Ok< std::vector >(); - ok &= Ok< std::valarray >(); - ok &= Ok< CppAD::vector >(); + // use routine above to check these cases + ok &= Ok< std::vector >(); + 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) - ok &= Ok< std::vector >(); - ok &= Ok< CppAD::vector >(); + // 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 - // use CheckSimpleVector for more extensive testing - CppAD::CheckSimpleVector >(); - CppAD::CheckSimpleVector >(); - CppAD::CheckSimpleVector >(); - CppAD::CheckSimpleVector >(); - CppAD::CheckSimpleVector >(); + // use CheckSimpleVector for more extensive testing + CppAD::CheckSimpleVector >(); + CppAD::CheckSimpleVector >(); + CppAD::CheckSimpleVector >(); + CppAD::CheckSimpleVector >(); + CppAD::CheckSimpleVector >(); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/sparse_rc.cpp cppad-2019.02.00.0/example/utility/sparse_rc.cpp --- cppad-2018.00.00.0/example/utility/sparse_rc.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/sparse_rc.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sparse_rc.cpp$$ $spell - rc + rc $$ $section sparse_rc: Example and Test$$ -$code $srcfile%example/utility/sparse_rc.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,64 +29,64 @@ # include bool sparse_rc(void) -{ bool ok = true; - typedef std::vector SizeVector; +{ bool ok = true; + typedef std::vector SizeVector; - // 3 by 3 identity matrix - size_t nr = 3; - size_t nc = 3; - size_t nnz = 3; - CppAD::sparse_rc pattern(nr, nc, nnz); - for(size_t k = 0; k < nnz; k++) - pattern.set(k, k, k); - - // row and column vectors corresponding to pattern - const SizeVector& row( pattern.row() ); - const SizeVector& col( pattern.row() ); - - // check pattern - ok &= pattern.nnz() == nnz; - ok &= pattern.nr() == nr; - ok &= pattern.nc() == nc; - for(size_t k = 0; k < nnz; k++) - { ok &= row[k] == k; - ok &= col[k] == k; - } - - // change to sparsity pattern for a 5 by 5 diagonal matrix - nr = 5; - nc = 5; - nnz = 5; - pattern.resize(nr, nc, nnz); - for(size_t k = 0; k < nnz; k++) - { size_t r = nnz - k - 1; // reverse or row-major order - size_t c = nnz - k - 1; - pattern.set(k, r, c); - } - SizeVector row_major = pattern.row_major(); - - // check row and column - for(size_t k = 0; k < nnz; k++) - { ok &= row[ row_major[k] ] == k; - ok &= col[ row_major[k] ] == k; - } - - // create an empty pattern - CppAD::sparse_rc target; - ok &= target.nnz() == 0; - ok &= target.nr() == 0; - ok &= target.nc() == 0; - - // now use it as the target for an assignment statement - target = pattern; - ok &= target.nr() == pattern.nr(); - ok &= target.nc() == pattern.nc(); - ok &= target.nnz() == pattern.nnz(); - for(size_t k = 0; k < nnz; k++) - { ok &= target.row()[k] == row[k]; - ok &= target.col()[k] == col[k]; - } - return ok; + // 3 by 3 identity matrix + size_t nr = 3; + size_t nc = 3; + size_t nnz = 3; + CppAD::sparse_rc pattern(nr, nc, nnz); + for(size_t k = 0; k < nnz; k++) + pattern.set(k, k, k); + + // row and column vectors corresponding to pattern + const SizeVector& row( pattern.row() ); + const SizeVector& col( pattern.row() ); + + // check pattern + ok &= pattern.nnz() == nnz; + ok &= pattern.nr() == nr; + ok &= pattern.nc() == nc; + for(size_t k = 0; k < nnz; k++) + { ok &= row[k] == k; + ok &= col[k] == k; + } + + // change to sparsity pattern for a 5 by 5 diagonal matrix + nr = 5; + nc = 5; + nnz = 5; + pattern.resize(nr, nc, nnz); + for(size_t k = 0; k < nnz; k++) + { size_t r = nnz - k - 1; // reverse or row-major order + size_t c = nnz - k - 1; + pattern.set(k, r, c); + } + SizeVector row_major = pattern.row_major(); + + // check row and column + for(size_t k = 0; k < nnz; k++) + { ok &= row[ row_major[k] ] == k; + ok &= col[ row_major[k] ] == k; + } + + // create an empty pattern + CppAD::sparse_rc target; + ok &= target.nnz() == 0; + ok &= target.nr() == 0; + ok &= target.nc() == 0; + + // now use it as the target for an assignment statement + target = pattern; + ok &= target.nr() == pattern.nr(); + ok &= target.nc() == pattern.nc(); + ok &= target.nnz() == pattern.nnz(); + for(size_t k = 0; k < nnz; k++) + { ok &= target.row()[k] == row[k]; + ok &= target.col()[k] == col[k]; + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/sparse_rcv.cpp cppad-2019.02.00.0/example/utility/sparse_rcv.cpp --- cppad-2018.00.00.0/example/utility/sparse_rcv.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/sparse_rcv.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sparse_rcv.cpp$$ $spell - rc - rcv + rc + rcv $$ $section sparse_rcv: Example and Test$$ -$code $srcfile%example/utility/sparse_rcv.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,58 +30,68 @@ # include bool sparse_rcv(void) -{ bool ok = true; - typedef std::vector SizeVector; - typedef std::vector ValueVector; - - // sparsity pattern for a 5 by 5 diagonal matrix - size_t nr = 5; - size_t nc = 5; - size_t nnz = 5; - CppAD::sparse_rc pattern(nr, nc, nnz); - for(size_t k = 0; k < nnz; k++) - { size_t r = nnz - k - 1; // reverse or column-major order - size_t c = nnz - k - 1; - pattern.set(k, r, c); - } - - // sparse matrix - CppAD::sparse_rcv matrix(pattern); - for(size_t k = 0; k < nnz; k++) - { double v = double(k); - matrix.set(nnz - k - 1, v); - } - - // row, column, and value vectors - const SizeVector& row( matrix.row() ); - const SizeVector& col( matrix.row() ); - const ValueVector& val( matrix.val() ); - SizeVector col_major = matrix.col_major(); - - // check row, column, and value - for(size_t k = 0; k < nnz; k++) - { ok &= row[ col_major[k] ] == k; - ok &= col[ col_major[k] ] == k; - ok &= val[ col_major[k] ] == double(k); - } - - // create an empty matrix - CppAD::sparse_rcv target; - ok &= target.nnz() == 0; - ok &= target.nr() == 0; - ok &= target.nc() == 0; - - // now use it as the target for an assignment statement - target = matrix; - ok &= target.nr() == matrix.nr(); - ok &= target.nc() == matrix.nc(); - ok &= target.nnz() == matrix.nnz(); - for(size_t k = 0; k < nnz; k++) - { ok &= target.row()[k] == row[k]; - ok &= target.col()[k] == col[k]; - ok &= target.val()[k] == val[k]; - } - return ok; +{ bool ok = true; + typedef std::vector SizeVector; + typedef std::vector ValueVector; + + // sparsity pattern for a 5 by 5 diagonal matrix + size_t nr = 5; + size_t nc = 5; + size_t nnz = 5; + CppAD::sparse_rc pattern(nr, nc, nnz); + for(size_t k = 0; k < nnz; k++) + { size_t r = nnz - k - 1; // reverse or column-major order + size_t c = nnz - k - 1; + pattern.set(k, r, c); + } + + // sparse matrix + CppAD::sparse_rcv matrix(pattern); + for(size_t k = 0; k < nnz; k++) + { double v = double(k); + matrix.set(nnz - k - 1, v); + } + + // row, column, and value vectors + const SizeVector& row( matrix.row() ); + const SizeVector& col( matrix.row() ); + const ValueVector& val( matrix.val() ); + SizeVector col_major = matrix.col_major(); + + // check row, column, and value + for(size_t k = 0; k < nnz; k++) + { ok &= row[ col_major[k] ] == k; + ok &= col[ col_major[k] ] == k; + ok &= val[ col_major[k] ] == double(k); + } + + // pat + const CppAD::sparse_rc pat( matrix.pat() ); + ok &= nnz == pat.nnz(); + ok &= nr == pat.nr(); + ok &= nc == pat.nc(); + for(size_t k = 0; k < nnz; k++) + { ok &= row[k] == pat.row()[k]; + ok &= col[k] == pat.col()[k]; + } + + // create an empty matrix + CppAD::sparse_rcv target; + ok &= target.nnz() == 0; + ok &= target.nr() == 0; + ok &= target.nc() == 0; + + // now use it as the target for an assignment statement + target = matrix; + ok &= target.nr() == matrix.nr(); + ok &= target.nc() == matrix.nc(); + ok &= target.nnz() == matrix.nnz(); + for(size_t k = 0; k < nnz; k++) + { ok &= target.row()[k] == row[k]; + ok &= target.col()[k] == col[k]; + ok &= target.val()[k] == val[k]; + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/thread_alloc.cpp cppad-2019.02.00.0/example/utility/thread_alloc.cpp --- cppad-2018.00.00.0/example/utility/thread_alloc.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/thread_alloc.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin thread_alloc.cpp$$ $spell - pthread - openmp + pthread + openmp $$ $section Fast Multi-Threading Memory Allocator: Example and Test$$ -$mindex openmp allocation pthread boost multi-thread$$ -$code $srcfile%example/utility/thread_alloc.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -37,203 +35,203 @@ bool raw_allocate(void) -{ bool ok = true; - using CppAD::thread_alloc; - size_t thread; - - // check that no memory is initilaly inuse - ok &= thread_alloc::free_all(); - - // amount of static memory used by thread zero - size_t static_inuse = 0; - - // 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; - 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. - std::vector v_ptr(n_inner); - // 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]); - // 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(size_t k = 0; k < cap_size_t; k++) - new(ptr + k) size_t(i + j + k); - // check that the constructor worked - 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 - thread = thread_alloc::thread_num(); - ok &= thread_alloc::inuse(thread) == n_inner*cap_bytes + static_inuse; - ok &= thread_alloc::available(thread) == 0; - // return the memrory to thread_alloc - 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 - ok &= thread_alloc::inuse(thread) == static_inuse; - ok &= thread_alloc::available(thread) == n_inner * cap_bytes; - } - thread_alloc::free_available(thread); +{ bool ok = true; + using CppAD::thread_alloc; + size_t thread; + + // check that no memory is initilaly inuse + ok &= thread_alloc::free_all(); + + // amount of static memory used by thread zero + size_t static_inuse = 0; + + // 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; + 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. + std::vector v_ptr(n_inner); + // 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]); + // 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(size_t k = 0; k < cap_size_t; k++) + new(ptr + k) size_t(i + j + k); + // check that the constructor worked + 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 + thread = thread_alloc::thread_num(); + ok &= thread_alloc::inuse(thread) == n_inner*cap_bytes + static_inuse; + ok &= thread_alloc::available(thread) == 0; + // return the memrory to thread_alloc + 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 + ok &= thread_alloc::inuse(thread) == static_inuse; + ok &= thread_alloc::available(thread) == n_inner * cap_bytes; + } + thread_alloc::free_available(thread); - // check that the tests have not held onto memory - ok &= thread_alloc::free_all(); + // check that the tests have not held onto memory + ok &= thread_alloc::free_all(); - return ok; + return ok; } class my_char { public: - char ch_ ; - my_char(void) : ch_(' ') - { } - my_char(const my_char& my_ch) : ch_(my_ch.ch_) - { } + char ch_ ; + my_char(void) : ch_(' ') + { } + my_char(const my_char& my_ch) : ch_(my_ch.ch_) + { } }; bool type_allocate(void) -{ bool ok = true; - using CppAD::thread_alloc; - size_t i; - - // check initial memory values - size_t thread = thread_alloc::thread_num(); - ok &= thread == 0; - ok &= thread_alloc::free_all(); - size_t static_inuse = 0; - - // initial allocation of an array - size_t size_min = 3; - size_t size_one; - my_char *array_one = - thread_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 = - thread_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 &= thread_alloc::inuse(thread) - check < sizeof(my_char); - ok &= thread_alloc::available(thread) == 0; - - // delete the arrays - thread_alloc::delete_array(array_one); - thread_alloc::delete_array(array_two); - ok &= thread_alloc::inuse(thread) == static_inuse; - check = sizeof(my_char)*(size_one + size_two); - ok &= thread_alloc::available(thread) - check < sizeof(my_char); +{ bool ok = true; + using CppAD::thread_alloc; + size_t i; + + // check initial memory values + size_t thread = thread_alloc::thread_num(); + ok &= thread == 0; + ok &= thread_alloc::free_all(); + size_t static_inuse = 0; + + // initial allocation of an array + size_t size_min = 3; + size_t size_one; + my_char *array_one = + thread_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 = + thread_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 &= thread_alloc::inuse(thread) - check < sizeof(my_char); + ok &= thread_alloc::available(thread) == 0; + + // delete the arrays + thread_alloc::delete_array(array_one); + thread_alloc::delete_array(array_two); + ok &= thread_alloc::inuse(thread) == static_inuse; + check = sizeof(my_char)*(size_one + size_two); + ok &= thread_alloc::available(thread) - check < sizeof(my_char); - // free the memory for use by this thread - thread_alloc::free_available(thread); + // free the memory for use by this thread + thread_alloc::free_available(thread); - // check that the tests have not held onto memory - ok &= thread_alloc::free_all(); + // check that the tests have not held onto memory + ok &= thread_alloc::free_all(); - return ok; + return ok; } } // End empty namespace bool check_alignment(void) -{ bool ok = true; - using CppAD::thread_alloc; +{ bool ok = true; + using CppAD::thread_alloc; - // number of binary digits in a size_t value - size_t n_digit = std::numeric_limits::digits; + // number of binary digits in a size_t value + size_t n_digit = std::numeric_limits::digits; - // must be a multiple of 8 - ok &= (n_digit % 8) == 0; + // must be a multiple of 8 + ok &= (n_digit % 8) == 0; - // number of bytes in a size_t value - size_t n_byte = n_digit / 8; + // number of bytes in a size_t value + size_t n_byte = n_digit / 8; - // check raw allocation ------------------------------------------------- - size_t min_bytes = 1; - size_t cap_bytes; - void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); + // check raw allocation ------------------------------------------------- + size_t min_bytes = 1; + size_t cap_bytes; + void* v_ptr = thread_alloc::get_memory(min_bytes, cap_bytes); - // convert to a size_t value - size_t v_size_t = reinterpret_cast(v_ptr); + // convert to a size_t value + size_t v_size_t = reinterpret_cast(v_ptr); - // check that it is aligned - ok &= (v_size_t % n_byte) == 0; + // check that it is aligned + ok &= (v_size_t % n_byte) == 0; - // return memory to available pool - thread_alloc::return_memory(v_ptr); + // 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 = - thread_alloc::create_array(size_min, size_out); + // check array allocation ---------------------------------------------- + size_t size_min = 1; + size_t size_out; + my_char *array_ptr = + thread_alloc::create_array(size_min, size_out); - // convert to a size_t value - size_t array_size_t = reinterpret_cast(array_ptr); + // convert to a size_t value + size_t array_size_t = reinterpret_cast(array_ptr); - // check that it is aligned - ok &= (array_size_t % n_byte) == 0; + // check that it is aligned + ok &= (array_size_t % n_byte) == 0; - // return memory to avialable pool - thread_alloc::delete_array(array_ptr); + // return memory to avialable pool + thread_alloc::delete_array(array_ptr); - return ok; + return ok; } bool thread_alloc(void) -{ bool ok = true; - using CppAD::thread_alloc; +{ bool ok = true; + using CppAD::thread_alloc; - // check that there is only on thread - ok &= thread_alloc::num_threads() == 1; - // so thread number must be zero - ok &= thread_alloc::thread_num() == 0; - // and we are in sequential execution mode - ok &= thread_alloc::in_parallel() == false; - - // Instruct thread_alloc to hold onto memory. This makes memory - // allocation faster (especially when there are multiple threads). - thread_alloc::hold_memory(true); - - // run raw allocation tests - ok &= raw_allocate(); - - // run typed allocation tests - ok &= type_allocate(); - - // check alignment - ok &= check_alignment(); - - // return allocator to its default mode - thread_alloc::hold_memory(false); - return ok; + // check that there is only on thread + ok &= thread_alloc::num_threads() == 1; + // so thread number must be zero + ok &= thread_alloc::thread_num() == 0; + // and we are in sequential execution mode + ok &= thread_alloc::in_parallel() == false; + + // Instruct thread_alloc to hold onto memory. This makes memory + // allocation faster (especially when there are multiple threads). + thread_alloc::hold_memory(true); + + // run raw allocation tests + ok &= raw_allocate(); + + // run typed allocation tests + ok &= type_allocate(); + + // check alignment + ok &= check_alignment(); + + // return allocator to its default mode + thread_alloc::hold_memory(false); + return ok; } diff -Nru cppad-2018.00.00.0/example/utility/to_string.cpp cppad-2019.02.00.0/example/utility/to_string.cpp --- cppad-2018.00.00.0/example/utility/to_string.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/to_string.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,21 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin to_string.cpp$$ $section to_string: Example and Test$$ -$code $srcfile%example/utility/to_string.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -25,107 +24,107 @@ // Examples with fundamental types # include namespace { - template - Integer string2signed(const std::string& s) - { Integer result = 0; - size_t index = 0; - if( s[0] == '-' ) - ++index; - while( index < s.size() ) - result = Integer(10 * result + s[index++] - '0'); - if( s[0] == '-' ) - return - result; - return result; - } - template - Integer string2unsigned(const std::string& s) - { Integer result = 0; - size_t index = 0; - while( index < s.size() ) - result = Integer(10 * result + s[index++] - '0'); - return result; - } - template - bool signed_integer(void) - { bool ok = true; - // - Integer max = std::numeric_limits::max(); - std::string s = CppAD::to_string(max); - Integer check = string2signed(s); - ok &= max == check; - // - Integer min = std::numeric_limits::min(); - s = CppAD::to_string(min); - check = string2signed(s); - ok &= min == check; - // - return ok; - } - template - bool unsigned_integer(void) - { bool ok = true; - // - Integer max = std::numeric_limits::max(); - std::string s = CppAD::to_string(max); - Integer check = string2unsigned(s); - ok &= max == check; - ok &= std::numeric_limits::min() == 0; - // - return ok; - } - template - bool floating(void) - { bool ok = true; - Float eps = std::numeric_limits::epsilon(); - Float pi = Float( 4.0 * std::atan(1.0) ); - // - std::string s = CppAD::to_string( pi ); - Float check = Float( std::atof( s.c_str() ) ); - ok &= std::fabs( check / pi - 1.0 ) <= 2.0 * eps; - // - return ok; - } + template + Integer string2signed(const std::string& s) + { Integer result = 0; + size_t index = 0; + if( s[0] == '-' ) + ++index; + while( index < s.size() ) + result = Integer(10 * result + s[index++] - '0'); + if( s[0] == '-' ) + return - result; + return result; + } + template + Integer string2unsigned(const std::string& s) + { Integer result = 0; + size_t index = 0; + while( index < s.size() ) + result = Integer(10 * result + Integer(s[index++]) - '0'); + return result; + } + template + bool signed_integer(void) + { bool ok = true; + // + Integer max = std::numeric_limits::max(); + std::string s = CppAD::to_string(max); + Integer check = string2signed(s); + ok &= max == check; + // + Integer min = std::numeric_limits::min(); + s = CppAD::to_string(min); + check = string2signed(s); + ok &= min == check; + // + return ok; + } + template + bool unsigned_integer(void) + { bool ok = true; + // + Integer max = std::numeric_limits::max(); + std::string s = CppAD::to_string(max); + Integer check = string2unsigned(s); + ok &= max == check; + ok &= std::numeric_limits::min() == 0; + // + return ok; + } + template + bool floating(void) + { bool ok = true; + Float eps = std::numeric_limits::epsilon(); + Float pi = Float( 4.0 * std::atan(1.0) ); + // + std::string s = CppAD::to_string( pi ); + Float check = Float( std::atof( s.c_str() ) ); + ok &= std::fabs( check / pi - 1.0 ) <= 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 = Base( 4.0 * std::atan(1.0) ); - // - std::string s = CppAD::to_string( CppAD::AD( pi ) ); - Base check = Base( std::atof( s.c_str() ) ); - ok &= fabs( check / pi - Base(1.0) ) <= Base( 2.0 ) * eps; - // - return ok; - } + template + bool ad_floating(void) + { bool ok = true; + Base eps = std::numeric_limits::epsilon(); + Base pi = Base( 4.0 * std::atan(1.0) ); + // + std::string s = CppAD::to_string( CppAD::AD( pi ) ); + Base check = Base( std::atof( s.c_str() ) ); + ok &= fabs( check / pi - Base(1.0) ) <= Base( 2.0 ) * eps; + // + return ok; + } } // Test driver bool to_string(void) -{ bool ok = true; +{ bool ok = true; - ok &= unsigned_integer(); - ok &= signed_integer(); - // - ok &= unsigned_integer(); - ok &= signed_integer(); + ok &= unsigned_integer(); + ok &= signed_integer(); + // + ok &= unsigned_integer(); + ok &= signed_integer(); # if CPPAD_USE_CPLUSPLUS_2011 - ok &= unsigned_integer(); - ok &= signed_integer(); + ok &= unsigned_integer(); + ok &= signed_integer(); # endif - // - ok &= floating(); - ok &= floating(); - ok &= floating(); - // - ok &= ad_floating(); - ok &= ad_floating(); - // - return ok; + // + ok &= floating(); + ok &= floating(); + ok &= floating(); + // + ok &= ad_floating(); + ok &= ad_floating(); + // + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/example/utility/utility.cpp cppad-2019.02.00.0/example/utility/utility.cpp --- cppad-2018.00.00.0/example/utility/utility.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/utility.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // system include files used for I/O # include @@ -49,42 +50,42 @@ // main program that runs all the tests int main(void) -{ std::string group = "example/utility"; - size_t width = 20; - CppAD::test_boolofvoid Run(group, width); - - // This line is used by test_one.sh - - // external compiled tests - Run( CheckNumericType, "CheckNumericType" ); - Run( CheckSimpleVector, "CheckSimpleVector" ); - Run( CppAD_vector, "CppAD_vector" ); - Run( ErrorHandler, "ErrorHandler" ); - Run( index_sort, "index_sort" ); - Run( LuFactor, "LuFactor" ); - Run( LuInvert, "LuInvert" ); - Run( LuSolve, "LuSolve" ); - Run( nan, "nan" ); - Run( Near_Equal, "Near_Equal" ); - Run( OdeErrControl, "OdeErrControl" ); - Run( OdeErrMaxabs, "OdeErrMaxabs" ); - Run( OdeGearControl, "OdeGearControl" ); - Run( OdeGear, "OdeGear" ); - Run( RombergMul, "RombergMul" ); - Run( RombergOne, "RombergOne" ); - Run( runge_45_1, "runge_45_1" ); - Run( set_union, "set_union" ); - Run( SimpleVector, "SimpleVector" ); - Run( thread_alloc, "thread_alloc" ); - Run( sparse_rc, "sparse_rc" ); - Run( sparse_rcv, "sparse_rcv" ); - Run( to_string, "to_string" ); - Run( vectorBool, "vectorBool" ); - // - // check for memory leak - bool memory_ok = CppAD::thread_alloc::free_all(); - // print summary at end - bool ok = Run.summary(memory_ok); - // - return static_cast( ! ok ); +{ std::string group = "example/utility"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + // external compiled tests + Run( CheckNumericType, "CheckNumericType" ); + Run( CheckSimpleVector, "CheckSimpleVector" ); + Run( CppAD_vector, "CppAD_vector" ); + Run( ErrorHandler, "ErrorHandler" ); + Run( index_sort, "index_sort" ); + Run( LuFactor, "LuFactor" ); + Run( LuInvert, "LuInvert" ); + Run( LuSolve, "LuSolve" ); + Run( nan, "nan" ); + Run( Near_Equal, "Near_Equal" ); + Run( OdeErrControl, "OdeErrControl" ); + Run( OdeErrMaxabs, "OdeErrMaxabs" ); + Run( OdeGearControl, "OdeGearControl" ); + Run( OdeGear, "OdeGear" ); + Run( RombergMul, "RombergMul" ); + Run( RombergOne, "RombergOne" ); + Run( runge_45_1, "runge_45_1" ); + Run( set_union, "set_union" ); + Run( SimpleVector, "SimpleVector" ); + Run( thread_alloc, "thread_alloc" ); + Run( sparse_rc, "sparse_rc" ); + Run( sparse_rcv, "sparse_rcv" ); + Run( to_string, "to_string" ); + Run( vectorBool, "vectorBool" ); + // + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); } diff -Nru cppad-2018.00.00.0/example/utility/vector_bool.cpp cppad-2019.02.00.0/example/utility/vector_bool.cpp --- cppad-2018.00.00.0/example/utility/vector_bool.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/example/utility/vector_bool.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin vector_bool.cpp$$ $spell - Cpp - bool + Cpp + bool $$ $section CppAD::vectorBool Class: Example and Test$$ -$mindex bool vectorBool CppAD$$ -$code $srcfile%example/utility/vector_bool.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -34,76 +32,76 @@ # include bool vectorBool(void) -{ bool ok = true; - using CppAD::vectorBool; +{ bool ok = true; + using CppAD::vectorBool; - vectorBool x; // default constructor - ok &= (x.size() == 0); + vectorBool x; // default constructor + ok &= (x.size() == 0); - x.resize(2); // resize and set element assignment to bool - ok &= (x.size() == 2); - x[0] = false; - x[1] = true; - - vectorBool y(2); // sizing constructor - ok &= (y.size() == 2); - - const vectorBool z(x); // copy constructor and const element access - ok &= (z.size() == 2); - ok &= ( (z[0] == false) && (z[1] == true) ); - - x[0] = true; // modify, assignment changes x - ok &= (x[0] == true); - - // 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) ); - - // test of push_vector - y.push_vector(z); - ok &= y.size() == 4; - ok &= ( (y[0] == false) && (y[1] == true) ); - ok &= ( (y[2] == false) && (y[3] == true) ); - - y[1] = false; // element assignment to another element - x[0] = y[1]; - ok &= (x[0] == false); - - // test of output - std::string correct= "01"; - std::string str; - std::ostringstream buf; - buf << z; - str = buf.str(); - ok &= (str == correct); - - // test resize(0), capacity, and clear - size_t i = x.capacity(); - ok &= i > 0; - x.resize(0); - ok &= i == x.capacity(); - x.clear(); - ok &= 0 == x.capacity(); - - // test of push_back element - for(i = 0; i < 100; i++) - x.push_back( (i % 3) != 0 ); - ok &= (x.size() == 100); - for(i = 0; i < 100; i++) - ok &= ( x[i] == ((i % 3) != 0) ); - - // is that boolvector is - // a simple vector class with elements of type bool - CppAD::CheckSimpleVector< bool, vectorBool >(); + x.resize(2); // resize and set element assignment to bool + ok &= (x.size() == 2); + x[0] = false; + x[1] = true; + + vectorBool y(2); // sizing constructor + ok &= (y.size() == 2); + + const vectorBool z(x); // copy constructor and const element access + ok &= (z.size() == 2); + ok &= ( (z[0] == false) && (z[1] == true) ); + + x[0] = true; // modify, assignment changes x + ok &= (x[0] == true); + + // 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) ); + + // test of push_vector + y.push_vector(z); + ok &= y.size() == 4; + ok &= ( (y[0] == false) && (y[1] == true) ); + ok &= ( (y[2] == false) && (y[3] == true) ); + + y[1] = false; // element assignment to another element + x[0] = y[1]; + ok &= (x[0] == false); + + // test of output + std::string correct= "01"; + std::string str; + std::ostringstream buf; + buf << z; + str = buf.str(); + ok &= (str == correct); + + // test resize(0), capacity, and clear + size_t i = x.capacity(); + ok &= i > 0; + x.resize(0); + ok &= i == x.capacity(); + x.clear(); + ok &= 0 == x.capacity(); + + // test of push_back element + for(i = 0; i < 100; i++) + x.push_back( (i % 3) != 0 ); + ok &= (x.size() == 100); + for(i = 0; i < 100; i++) + ok &= ( x[i] == ((i % 3) != 0) ); + + // is that boolvector is + // a simple vector class with elements of type bool + CppAD::CheckSimpleVector< bool, vectorBool >(); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/.gitignore cppad-2019.02.00.0/.gitignore --- cppad-2018.00.00.0/.gitignore 2017-12-08 14:50:56.000000000 +0000 +++ cppad-2019.02.00.0/.gitignore 2019-01-31 12:35:17.000000000 +0000 @@ -1,30 +1,34 @@ +# ---------------------------------------------------------------------------- # specific files /aclocal.m4 /ar-lib /autom4te.cache /bin/test_one.sh -/cppad/configure.hpp -/cppad/local/is_pod.hpp +/include/cppad/configure.hpp +/include/cppad/local/is_pod.hpp /doxyfile /git_commit.sh /test_one.cpp /test_one.exe +# ---------------------------------------------------------------------------- # specific directories -/bug/build/ /build/ -/doc/ /doxydoc/ -# specific extensions in all directories -*.err -*.log -*.swp -*.tmp -# all new directories /new/ /new.*/ -# all junk files and direcrories +# directory that is ignored by master, but not by gh-pages +/doc/ +# ---------------------------------------------------------------------------- +# specific extensions in top direcotry +/*.err +/*.log +/*.warn +# ---------------------------------------------------------------------------- +# vim swap files in any directory +*.swp +# ---------------------------------------------------------------------------- +# junk and temp files in any directory junk junk.* -# all temp files and directories temp temp.* diff -Nru cppad-2018.00.00.0/gpl-3.0.txt cppad-2019.02.00.0/gpl-3.0.txt --- cppad-2018.00.00.0/gpl-3.0.txt 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/gpl-3.0.txt 1970-01-01 00:00:00.000000000 +0000 @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 3 of the License, 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff -Nru cppad-2018.00.00.0/include/cppad/base_require.hpp cppad-2019.02.00.0/include/cppad/base_require.hpp --- cppad-2018.00.00.0/include/cppad/base_require.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/base_require.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,177 @@ +# ifndef CPPAD_BASE_REQUIRE_HPP +# define CPPAD_BASE_REQUIRE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin base_require$$ +$spell + azmul + ostream + alloc + eps + std + cppad.hpp + namespace + bool + const + CppAD + enum + inline + Op + std + CondExp +$$ + +$section AD Requirements for a CppAD Base Type$$ + +$head Syntax$$ +$code # include $$ + +$head Purpose$$ +This section lists the requirements for the type +$icode Base$$ so that the type $codei%AD<%Base%>%$$ can be used. + +$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$$, +or $codei%AD<%Other%>%$$, +these requirements are provided by including the file +$code cppad/cppad.hpp$$. +In the documentation, The notation $latex \B{R}$$ denotes +the field corresponding to the base type. +Multiplication must be commutative for this field, +but it need not be the reals; e.g., the complex numbers. + +$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, +and then include the file $code cppad/cppad.hpp$$. + +$head Numeric Type$$ +The type $icode Base$$ must support all the operations for a +$cref NumericType$$. + +$head Output Operator$$ +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 +$cref/base_alloc/base_alloc.hpp/Output Operator/$$. + +$head Integer$$ +The type $icode Base$$ must support the syntax +$codei% + %i% = CppAD::Integer(%x%) +%$$ +which converts $icode x$$ to an $code int$$. +The argument $icode x$$ has prototype +$codei% + const %Base%& %x% +%$$ +and the return value $icode i$$ has prototype +$codei% + int %i% +%$$ + +$subhead Suggestion$$ +In many cases, the $icode Base$$ version of the $code Integer$$ function +can be defined by +$codei% +namespace CppAD { + inline int Integer(const %Base%& x) + { return static_cast(x); } +} +%$$ +For example, see +$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 +$srccode%cpp% */ +# 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_require/base_member.omh% + include/cppad/core/base_cond_exp.hpp% + omh/base_require/base_identical.omh% + omh/base_require/base_ordered.omh% + include/cppad/core/base_std_math.hpp% + include/cppad/core/base_limits.hpp% + include/cppad/core/base_to_string.hpp% + include/cppad/core/base_hash.hpp% + omh/base_require/base_example.omh +%$$ + +$end +*/ + +// definitions that must come before base implementations +# include +# include +# include +# include + +// grouping documentation by feature +# include +# include +# include +# include +# include + +// must define template class numeric_limits before the base cases +# include +# include // deprecated + +// base cases that come with CppAD +# include +# include +# include + +// deprecated base type +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/CMakeLists.txt cppad-2019.02.00.0/include/cppad/CMakeLists.txt --- cppad-2018.00.00.0/include/cppad/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,288 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# Configure the CppAD include file directory +# ----------------------------------------------------------------------------- +# check_match +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) + ELSE( match_flag ) + SET(${output_variable} 0) + ENDIF( match_flag ) + print_variable(${output_variable}) +ENDMACRO(check_match) +# ----------------------------------------------------------------------------- +# compiler_has_conversion_warn +SET( clang_or_gnu 0 ) +IF( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + SET(clang_or_gnu 1) +ENDIF( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) +IF( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) + SET(clang_or_gnu 1) +ENDIF( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) +IF( clang_or_gnu ) + SET(backup "${cppad_cxx_flags}") + SET(cppad_cxx_flags "${backup} -Wfloat-conversion -Wconversion -Werror") + # + SET(source "int main(void) { return 0; }") + check_source_runs("${source}" compiler_has_conversion_warn ) + # + SET(cppad_cxx_flags "${backup}") +ELSE( clang_or_gnu ) + SET( compiler_has_conversion_warn 0 ) +ENDIF( clang_or_gnu ) +# ----------------------------------------------------------------------------- +# cppad_boostvector, cppad_cppadvector, cppad_eigenvector, cppad_stdvector +# +check_match(cppad_testvector boost cppad_boostvector) +check_match(cppad_testvector cppad cppad_cppadvector) +check_match(cppad_testvector eigen cppad_eigenvector) +check_match(cppad_testvector std cppad_stdvector) +IF( NOT cppad_boostvector ) +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." +) +ENDIF( NOT cppad_stdvector ) +ENDIF( NOT cppad_eigenvector ) +ENDIF( NOT cppad_cppadvector ) +ENDIF( NOT cppad_boostvector ) + +IF( cppad_boostvector ) + # FIND_PACKAGE(Boost) done by ../CMakeLists.txt + IF( NOT Boost_FOUND ) + MESSAGE(FATAL_ERROR +"cppad_testvector == boost but cannot find boost include files" + ) + ENDIF( NOT Boost_FOUND ) +ENDIF( cppad_boostvector ) +# +IF( cppad_eigenvector ) + IF( NOT eigen_prefix ) + 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 +# +SET(source " +int main(void) +{ int&& value = 1 + 2; + 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 +# +SET(source " +int main(void) +{ char *c = nullptr; + return 0; +}" +) +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_long_long +# +SET(source " +template 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) +{ return 0; } +" +) +check_source_runs("${source}" cppad_has_long_long) +IF( NOT cppad_has_long_long ) + SET(cppad_cplusplus_201100_ok 0) +ENDIF( NOT cppad_has_long_long ) +# ----------------------------------------------------------------------------- +# 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; +} +" +) +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_has_steady_clock +# +SET(source " +# include +# include +# include +int main(void) +{ std::chrono::time_point start, end; + start = std::chrono::steady_clock::now(); + std::this_thread::sleep_for( std::chrono::milliseconds(1) ); + end = std::chrono::steady_clock::now(); + std::chrono::duration difference = end - start; + double elapsed_seconds = difference.count(); + if( elapsed_seconds >= 0.9e-3 ) // 1e-3 = one millisecond + return 0; + return 1; +} +" +) +check_source_runs("${source}" cppad_has_steady_clock) +IF( NOT cppad_has_steady_clock ) + SET(cppad_cplusplus_201100_ok 0) +ENDIF( NOT cppad_has_steady_clock ) +# ============================================================================= +# End C++11 features +# +print_variable(cppad_cplusplus_201100_ok) +# ----------------------------------------------------------------------------- +# cppad_has_gettimeofday +# +SET(source " +# include +int main(void) +{ struct timeval time; + gettimeofday(&time, 0); + return 0; +}" +) +check_source_runs("${source}" cppad_has_gettimeofday) +# ----------------------------------------------------------------------------- +# cppad_tape_addr_type, cppad_tape_id_type +# +FOREACH(cmake_var cppad_tape_id_type cppad_tape_addr_type ) + SET(source " +# include +int main(void) +{ bool is_unsigned = ! std::numeric_limits<${${cmake_var}}>::is_signed; + return int(! is_unsigned); +} +" + ) + 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_unsigned STREQUAL 0 ) +ENDFOREACH( cmake_var ) +# ----------------------------------------------------------------------------- +# check that cppad_max_num_threads is >= 4 +# +SET(CMAKE_REQUIRED_INCLUDES "") +SET(CMAKE_REQUIRED_LIBRARIES "") +SET(CMAKE_REQUIRED_FLAGS ) +SET(source " +int main(void) +{ const char* number = \"${cppad_max_num_threads}\"; + int value = 0; + while( *number == ' ' ) + number++; + while( '0' <= *number && *number <= '9' ) + { value = 10 * value + (int)(*number - '0'); + number++; + } + while( *number == ' ' ) + number++; + if( *number != char(0) ) + return 1; + if( value < 4 ) + return 1; + 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 + "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 ) +# ----------------------------------------------------------------------------- +# configure.hpp +CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/configure.hpp.in + ${CMAKE_CURRENT_SOURCE_DIR}/configure.hpp +) +# ----------------------------------------------------------------------------- +# configure files in local subdirectory +ADD_SUBDIRECTORY(local) diff -Nru cppad-2018.00.00.0/include/cppad/configure.hpp.in cppad-2019.02.00.0/include/cppad/configure.hpp.in --- cppad-2018.00.00.0/include/cppad/configure.hpp.in 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/configure.hpp.in 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,209 @@ +# ifndef CPPAD_CONFIGURE_HPP +# define CPPAD_CONFIGURE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/*! + \file configure.hpp +Replacement for config.h so that all preprocessor symbols begin with CPPAD_ +*/ + +/*! +\def CPPAD_COMPILER_HAS_CONVERSION_WARN +is the compiler a variant of g++ and has conversion warnings +*/ +# define CPPAD_COMPILER_HAS_CONVERSION_WARN @compiler_has_conversion_warn@ + +/*! +\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_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 +cppad-yyyymmdd as a C string where yyyy is year, mm is month, and dd is day. +*/ +# define CPPAD_PACKAGE_STRING "cppad-@cppad_version@" + +/*! +def CPPAD_HAS_ADOLC +Was a adolc_prefix specified on the cmake command line. +*/ +# define CPPAD_HAS_ADOLC @cppad_has_adolc@ + +/*! +def CPPAD_HAS_COLPACK +Was a colpack_prefix specified on the cmake command line. +*/ +# define CPPAD_HAS_COLPACK @cppad_has_colpack@ + +/*! +def CPPAD_HAS_EIGEN +Was a eigen_prefix specified on the cmake command line. +*/ +# define CPPAD_HAS_EIGEN @cppad_has_eigen@ + +/*! +def CPPAD_HAS_IPOPT +Was a ipopt_prefix specified on the cmake command line. +*/ +# define CPPAD_HAS_IPOPT @cppad_has_ipopt@ + +/*! +\def CPPAD_DEPRECATED +This symbol is not currently being used. +*/ +# define CPPAD_DEPRECATED @cppad_deprecated_01@ + +/*! +\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, +we are not using boost vector for CPPAD_TESTVECTOR. +*/ +# define CPPAD_BOOSTVECTOR @cppad_boostvector@ + +/*! +\def CPPAD_CPPADVECTOR +If this symbol is one, +we are using CppAD vector for CPPAD_TESTVECTOR. +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, +we are using standard vector for CPPAD_TESTVECTOR. +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, +we are using Eigen vector for CPPAD_TESTVECTOR. +If this symbol is zero, +we are not using Eigen vector for CPPAD_TESTVECTOR. +*/ +# define CPPAD_EIGENVECTOR @cppad_eigenvector@ + +/*! +\def CPPAD_HAS_GETTIMEOFDAY +If this symbol is one, and _MSC_VER is not defined, +this system supports the gettimeofday funcgtion. +Otherwise, this smybol should be zero. +*/ +# define CPPAD_HAS_GETTIMEOFDAY @cppad_has_gettimeofday@ + +/*! +\def CPPAD_TAPE_ADDR_TYPE +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 std::numeric_limits, +the <= operator, +and conversion to size_t. +Make sure that the type chosen returns true for is_pod +in pod_vector.hpp. +This type is later defined as addr_t in the CppAD namespace. +*/ +# define CPPAD_TAPE_ADDR_TYPE @cppad_tape_addr_type@ + +/*! +\def CPPAD_TAPE_ID_TYPE +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 std::numeric_limits, +the <= operator, +and conversion to size_t. +Make sure that the type chosen returns true for is_pod +in pod_vector.hpp. +This type is later defined as 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 +(must be greater than or equal four). + +The user may define CPPAD_MAX_NUM_THREADS before including any of the CppAD +header files. If it is not yet defined, +*/ +# ifndef CPPAD_MAX_NUM_THREADS +# 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-2018.00.00.0/include/cppad/core/abort_recording.hpp cppad-2019.02.00.0/include/cppad/core/abort_recording.hpp --- cppad-2018.00.00.0/include/cppad/core/abort_recording.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/abort_recording.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,58 @@ +# ifndef CPPAD_CORE_ABORT_RECORDING_HPP +# define CPPAD_CORE_ABORT_RECORDING_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin abort_recording$$ +$spell +$$ + +$section Abort Recording of an Operation Sequence$$ + + +$head Syntax$$ +$codei%AD<%Base%>::abort_recording()%$$ + +$head Purpose$$ +Sometimes it is necessary to abort the recording of an operation sequence +that started with a call of the form +$codei% + Independent(%x%) +%$$ +If such a recording is currently in progress, +$code abort_recording$$ will stop the recording and delete the +corresponding information. +Otherwise, $code abort_recording$$ has no effect. + +$children% + example/general/abort_recording.cpp +%$$ +$head Example$$ +The file +$cref abort_recording.cpp$$ +contains an example and test of this operation. + +$end +---------------------------------------------------------------------------- +*/ + + +namespace CppAD { + template + void AD::abort_recording(void) + { local::ADTape* tape = AD::tape_ptr(); + if( tape != CPPAD_NULL ) + AD::tape_manage(delete_tape_manage); + } +} + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/abs.hpp cppad-2019.02.00.0/include/cppad/core/abs.hpp --- cppad-2018.00.00.0/include/cppad/core/abs.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/abs.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,132 @@ +# ifndef CPPAD_CORE_ABS_HPP +# define CPPAD_CORE_ABS_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin abs$$ +$spell + fabs + Vec + std + faq + Taylor + Cpp + namespace + const + abs +$$ + +$section AD Absolute Value Functions: abs, fabs$$ + +$head Syntax$$ +$icode%y% = abs(%x%) +%$$ +$icode%y% = fabs(%x%)%$$ + +$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 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/$$). + +$head Derivative$$ +CppAD defines the derivative of the $code abs$$ function is +the $cref sign$$ function; i.e., +$latex \[ +{\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. +\] $$ +The result for $icode%x% == 0%$$ used to be a directional derivative. + +$head Example$$ +$children% + example/general/fabs.cpp +%$$ +The file +$cref fabs.cpp$$ +contains an example and test of this function. + +$end +------------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +template +AD AD::abs_me (void) const +{ + AD result; + result.value_ = abs(value_); + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); + + // check if there is a recording in progress + local::ADTape* tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return result; + + // check if operand is a constant parameter + if( tape_id_ != tape->id_ ) + return result; + + if(ad_type_ == dynamic_enum) + { // dynamic paramter argument + result.taddr_ = tape->Rec_.put_dyn_par( + result.value_, local::abs_dyn, taddr_ + ); + result.tape_id_ = tape_id_; + result.ad_type_ = dynamic_enum; + } + else + { // variable argument + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::AbsOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::AbsOp) == 1 ); + + // corresponding operand address + tape->Rec_.PutArg(taddr_); + + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::AbsOp); + + // make result a variable + result.tape_id_ = tape_id_; + result.ad_type_ = variable_enum; + } + return result; +} + +template +AD abs(const AD &x) +{ return x.abs_me(); } + +template +AD abs(const VecAD_reference &x) +{ return x.ADBase().abs_me(); } + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/abs_normal_fun.hpp cppad-2019.02.00.0/include/cppad/core/abs_normal_fun.hpp --- cppad-2018.00.00.0/include/cppad/core/abs_normal_fun.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/abs_normal_fun.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,929 @@ +# ifndef CPPAD_CORE_ABS_NORMAL_FUN_HPP +# define CPPAD_CORE_ABS_NORMAL_FUN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin abs_normal_fun$$ +$spell + const +$$ + + +$section Create An Abs-normal Representation of a Function$$ + +$head Syntax$$ +$icode%f%.abs_normal_fun(%g%, %a%)%$$ + +$head f$$ +The object $icode f$$ has prototype +$codei% + const ADFun<%Base%>& %f% +%$$ +It represents a function $latex f : \B{R}^n \rightarrow \B{R}^m$$. +We assume that the only non-smooth terms in the representation are +absolute value functions and use $latex s \in \B{Z}_+$$ +to represent the number of these terms. + +$subhead n$$ +We use $icode n$$ to denote the dimension of the domain space for $icode f$$. + +$subhead m$$ +We use $icode m$$ to denote the dimension of the range space for $icode f$$. + +$subhead s$$ +We use $icode s$$ to denote the number of absolute value terms in $icode f$$. + + +$head a$$ +The object $icode a$$ has prototype +$codei% + ADFun<%Base%> %a% +%$$ +The initial function representation in $icode a$$ is lost. +Upon return it represents the result of the absolute terms +$latex a : \B{R}^n \rightarrow \B{R}^s$$; see $latex a(x)$$ defined below. +Note that $icode a$$ is constructed by copying $icode f$$ +and then changing the dependent variables. There may +be many calculations in this representation that are not necessary +and can be removed using +$codei% + %a%.optimize() +%$$ +This optimization is not done automatically by $code abs_normal_fun$$ +because it may take a significant amount of time. + +$subhead zeta$$ +Let $latex \zeta_0 ( x )$$ +denote the argument for the first absolute value term in $latex f(x)$$, +$latex \zeta_1 ( x , |\zeta_0 (x)| )$$ for the second term, and so on. + +$subhead a(x)$$ +For $latex i = 0 , \ldots , {s-1}$$ define +$latex \[ +a_i (x) += +| \zeta_i ( x , a_0 (x) , \ldots , a_{i-1} (x ) ) | +\] $$ +This defines $latex a : \B{R}^n \rightarrow \B{R}^s$$. + +$head g$$ +The object $icode g$$ has prototype +$codei% + ADFun<%Base%> %g% +%$$ +The initial function representation in $icode g$$ is lost. +Upon return it represents the smooth function +$latex g : \B{R}^{n + s} \rightarrow \B{R}^{m + s}$$ is defined by +$latex \[ +g( x , u ) += +\left[ \begin{array}{c} y(x, u) \\ z(x, u) \end{array} \right] +\] $$ +were $latex y(x, u)$$ and $latex z(x, u)$$ are defined below. + +$subhead z(x, u)$$ +Define the smooth function +$latex z : \B{R}^{n + s} \rightarrow \B{R}^s$$ by +$latex \[ +z_i ( x , u ) = \zeta_i ( x , u_0 , \ldots , u_{i-1} ) +\] $$ +Note that the partial of $latex z_i$$ with respect to $latex u_j$$ is zero +for $latex j \geq i$$. + +$subhead y(x, u)$$ +There is a smooth function +$latex y : \B{R}^{n + s} \rightarrow \B{R}^m$$ +such that $latex y( x , u ) = f(x)$$ whenever $latex u = a(x)$$. + +$head Affine Approximation$$ +We define the affine approximations +$latex \[ +\begin{array}{rcl} +y[ \hat{x} ]( x , u ) +& = & +y ( \hat{x}, a( \hat{x} ) ) + + \partial_x y ( \hat{x}, a( \hat{x} ) ) ( x - \hat{x} ) + + \partial_u y ( \hat{x}, a( \hat{x} ) ) ( u - a( \hat{x} ) ) +\\ +z[ \hat{x} ]( x , u ) +& = & +z ( \hat{x}, a( \hat{x} ) ) + + \partial_x z ( \hat{x}, a( \hat{x} ) ) ( x - \hat{x} ) + + \partial_u z ( \hat{x}, a( \hat{x} ) ) ( u - a( \hat{x} ) ) +\end{array} +\] $$ +It follows that +$latex \[ +\begin{array}{rcl} +y( x , u ) +& = & +y[ \hat{x} ]( x , u ) + o ( x - \hat{x}, u - a( \hat{x} ) ) +\\ +z( x , u ) +& = & +z[ \hat{x} ]( x , u ) + o ( x - \hat{x}, u - a( \hat{x} ) ) +\end{array} +\] $$ + +$head Abs-normal Approximation$$ + +$subhead Approximating a(x)$$ +The function $latex a(x)$$ is not smooth, but it is equal to +$latex | z(x, u) |$$ when $latex u = a(x)$$. +Furthermore +$latex \[ +z[ \hat{x} ]( x , u ) += +z ( \hat{x}, a( \hat{x} ) ) + + \partial_x z ( \hat{x}, a( \hat{x} ) ) ( x - \hat{x} ) + + \partial_u z ( \hat{x}, a( \hat{x} ) ) ( u - a( \hat{x} ) ) +\] $$ +The partial of $latex z_i$$ with respect to $latex u_j$$ is zero +for $latex j \geq i$$. It follows that +$latex \[ +z_i [ \hat{x} ]( x , u ) += +z_i ( \hat{x}, a( \hat{x} ) ) + + \partial_x z_i ( \hat{x}, a( \hat{x} ) ) ( x - \hat{x} ) + + \sum_{j < i} \partial_{u(j)} + z_i ( \hat{x}, a( \hat{x} ) ) ( u_j - a_j ( \hat{x} ) ) +\] $$ +Considering the case $latex i = 0$$ we define +$latex \[ +a_0 [ \hat{x} ]( x ) += +| z_0 [ \hat{x} ]( x , u ) | += +\left| + z_0 ( \hat{x}, a( \hat{x} ) ) + + \partial_x z_0 ( \hat{x}, a( \hat{x} ) ) ( x - \hat{x} ) +\right| +\] $$ +It follows that +$latex \[ + a_0 (x) = a_0 [ \hat{x} ]( x ) + o ( x - \hat{x} ) +\] $$ +In general, we define $latex a_i [ \hat{x} ]$$ using +$latex a_j [ \hat{x} ]$$ for $latex j < i$$ as follows: +$latex \[ +a_i [ \hat{x} ]( x ) += +\left | + z_i ( \hat{x}, a( \hat{x} ) ) + + \partial_x z_i ( \hat{x}, a( \hat{x} ) ) ( x - \hat{x} ) + + \sum_{j < i} \partial_{u(j)} + z_i ( \hat{x}, a( \hat{x} ) ) + ( a_j [ \hat{x} ] ( x ) - a_j ( \hat{x} ) ) +\right| +\] $$ +It follows that +$latex \[ + a (x) = a[ \hat{x} ]( x ) + o ( x - \hat{x} ) +\] $$ +Note that in the case where $latex z(x, u)$$ and $latex y(x, u)$$ are +affine, +$latex \[ + a[ \hat{x} ]( x ) = a( x ) +\] $$ + + +$subhead Approximating f(x)$$ +$latex \[ +f(x) += +y ( x , a(x ) ) += +y [ \hat{x} ] ( x , a[ \hat{x} ] ( x ) ) ++ o( x - \hat{x} ) +\] $$ + +$head Correspondence to Literature$$ +Using the notation +$latex Z = \partial_x z(\hat{x}, \hat{u})$$, +$latex L = \partial_u z(\hat{x}, \hat{u})$$, +$latex J = \partial_x y(\hat{x}, \hat{u})$$, +$latex Y = \partial_u y(\hat{x}, \hat{u})$$, +the approximation for $latex z$$ and $latex y$$ are +$latex \[ +\begin{array}{rcl} +z[ \hat{x} ]( x , u ) +& = & +z ( \hat{x}, a( \hat{x} ) ) + Z ( x - \hat{x} ) + L ( u - a( \hat{x} ) ) +\\ +y[ \hat{x} ]( x , u ) +& = & +y ( \hat{x}, a( \hat{x} ) ) + J ( x - \hat{x} ) + Y ( u - a( \hat{x} ) ) +\end{array} +\] $$ +Moving the terms with $latex \hat{x}$$ together, we have +$latex \[ +\begin{array}{rcl} +z[ \hat{x} ]( x , u ) +& = & +z ( \hat{x}, a( \hat{x} ) ) - Z \hat{x} - L a( \hat{x} ) + Z x + L u +\\ +y[ \hat{x} ]( x , u ) +& = & +y ( \hat{x}, a( \hat{x} ) ) - J \hat{x} - Y a( \hat{x} ) + J x + Y u +\end{array} +\] $$ +Using the notation +$latex c = z ( \hat{x}, \hat{u} ) - Z \hat{x} - L \hat{u}$$, +$latex b = y ( \hat{x}, \hat{u} ) - J \hat{x} - Y \hat{u}$$, +we have +$latex \[ +\begin{array}{rcl} +z[ \hat{x} ]( x , u ) & = & c + Z x + L u +\\ +y[ \hat{x} ]( x , u ) & = & b + J x + Y u +\end{array} +\] $$ +Considering the affine case, where the approximations are exact, +and choosing $latex u = a(x) = |z(x, u)|$$, we obtain +$latex \[ +\begin{array}{rcl} +z( x , a(x ) ) & = & c + Z x + L |z( x , a(x ) )| +\\ +y( x , a(x ) ) & = & b + J x + Y |z( x , a(x ) )| +\end{array} +\] $$ +This is Equation (2) of the +$cref/reference/abs_normal/Reference/$$. + +$children%example/abs_normal/get_started.cpp +%$$ +$head Example$$ +The file $cref abs_get_started.cpp$$ contains +an example and test using this operation. + +$end +------------------------------------------------------------------------------- +*/ +/*! +file abs_normal_fun.hpp +Create an abs-normal representation of a function +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +Create an abs-normal representation of an ADFun object. + +\tparam Base +base type for this abs-normal form and for the function beging represented; +i.e., f. + +\param f +is the function that this object will represent in abs-normal form. +This is effectively const except that the play back state play_ +is used. +*/ + +# ifndef NDEBUG +# define CPPAD_J_PAR_EQUAL_REC j_par = (size_t) rec +# else +# define CPPAD_J_PAR_EQUAL_REC rec +# endif + +template +void ADFun::abs_normal_fun(ADFun& g, ADFun& a) const +{ using namespace local; + + // ----------------------------------------------------------------------- + // Forward sweep to determine number of absolute value operations in f + // ----------------------------------------------------------------------- + // The argument and result index in f for each absolute value operator + CppAD::vector f_abs_arg; + CppAD::vector f_abs_res; + // + OpCode op; // this operator + const addr_t* arg = CPPAD_NULL; // arguments for this operator + size_t i_var; // variable index for this operator + local::play::const_sequential_iterator itr = play_.begin(); + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == BeginOp ); + // + bool more_operators = true; + while( op != EndOp ) + { + // next op + (++itr).op_info(op, arg, i_var); + switch( op ) + { // absolute value operator + case AbsOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + f_abs_arg.push_back( arg[0] ); + f_abs_res.push_back( i_var ); + break; + + default: + break; + } + } + // ------------------------------------------------------------------------ + // Forward sweep to create new recording + // ------------------------------------------------------------------------ + // dynamic parameter information in player + const pod_vector& dyn_par_is( play_.dyn_par_is() ); + const pod_vector& dyn_par_op( play_.dyn_par_op() ); + const pod_vector& dyn_par_arg( play_.dyn_par_arg() ); + // + // recorder for new operation sequence + recorder rec; + // + // number of parameters in both operation sequences + size_t num_par = play_.num_par_rec(); + // + // number of independent dynamic parameters + size_t num_dynamic_ind = play_.num_dynamic_par(); + rec.set_num_dynamic_ind(num_dynamic_ind); + // + // set all parameter to be exactly the same in rec as in play + size_t i_dyn = 0; // dynamic parameter index + size_t i_arg = 0; // dynamic parameter operator argument index + for(size_t i_par = 0; i_par < num_par; ++i_par) + { +# ifndef NDEBUG + size_t j_par = 0; +# endif + // value of this parameter + Base par = play_.GetPar(i_par); + if( ! dyn_par_is[i_par] ) + CPPAD_J_PAR_EQUAL_REC.put_con_par(par); + else + { // operator for this dynamic parameter + op_code_dyn op_dyn = op_code_dyn( dyn_par_op[i_dyn] ); + // + // number of arguments for this dynamic parameter + size_t n_arg = num_arg_dyn(op_dyn); + // + switch(n_arg) + { case 0: + CPPAD_J_PAR_EQUAL_REC.put_dyn_par(par, op_dyn); + break; + + case 1: + CPPAD_J_PAR_EQUAL_REC.put_dyn_par(par, op_dyn, + dyn_par_arg[i_arg + 0] + ); + break; + + case 2: + CPPAD_J_PAR_EQUAL_REC.put_dyn_par(par, op_dyn, + dyn_par_arg[i_arg + 0] , + dyn_par_arg[i_arg + 1] + ); + break; + + case 5: + CPPAD_J_PAR_EQUAL_REC.put_dyn_cond_exp(par, + CompareOp( dyn_par_arg[i_arg + 0] ) , + dyn_par_arg[i_arg + 1] , + dyn_par_arg[i_arg + 2] , + dyn_par_arg[i_arg + 3] , + dyn_par_arg[i_arg + 4] + ); + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + } + ++i_dyn; + i_arg += n_arg; + } + CPPAD_ASSERT_UNKNOWN( j_par == i_par ); + } + // + // number of variables in both operation sequences + // (the AbsOp operators are replace by InvOp operators) + const size_t num_var = play_.num_var_rec(); + // + // mapping from old variable index to new variable index + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= num_var + ); + CppAD::vector f2g_var(num_var); + for(i_var = 0; i_var < num_var; i_var++) + f2g_var[i_var] = addr_t( num_var ); // invalid (should not be used) + // + // record the independent variables in f + itr = play_.begin(); + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == BeginOp ); + more_operators = true; + while( more_operators ) + { switch( op ) + { + // phantom variable + case BeginOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + CPPAD_ASSERT_UNKNOWN( arg[0] == 0 ); + rec.PutArg(0); + f2g_var[i_var] = rec.PutOp(op); + break; + + // independent variables + case InvOp: + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + f2g_var[i_var] = rec.PutOp(op); + break; + + // end of independent variables + default: + more_operators = false; + break; + } + if( more_operators ) + (++itr).op_info(op, arg, i_var); + } + // add one for the phantom variable + CPPAD_ASSERT_UNKNOWN( 1 + Domain() == i_var ); + // + // record the independent variables corresponding AbsOp results + size_t index_abs; + for(index_abs = 0; index_abs < f_abs_res.size(); index_abs++) + f2g_var[ f_abs_res[index_abs] ] = rec.PutOp(InvOp); + // + // used to hold new argument vector + addr_t new_arg[6]; + // + // now loop through the rest of the + more_operators = true; + index_abs = 0; + while( more_operators ) + { addr_t mask; // temporary used in some switch cases + switch( op ) + { + // check setting of f_abs_arg and f_abs_res; + case AbsOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + CPPAD_ASSERT_UNKNOWN( f_abs_arg[index_abs] == arg[0] ); + CPPAD_ASSERT_UNKNOWN( f_abs_res[index_abs] == i_var ); + CPPAD_ASSERT_UNKNOWN( f2g_var[i_var] > 0 ); + ++index_abs; + break; + + // These operators come at beginning of take and are handled above + case InvOp: + CPPAD_ASSERT_UNKNOWN(false); + break; + + // --------------------------------------------------------------- + // Unary operators, argument a parameter, one result + case ParOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + new_arg[0] = arg[0]; // parameter + rec.PutArg( new_arg[0] ); + f2g_var[i_var] = rec.PutOp(op); + break; + + // -------------------------------------------------------------- + // Unary operators, argument a variable, one result + // (excluding the absolute value operator 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: + case SqrtOp: + case TanOp: + case TanhOp: + // some of these operators have an auxillary result; e.g., + // sine and cosine are computed togeather. + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 || NumRes(op) == 2 ); + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[0] ] ) < num_var ); + new_arg[0] = f2g_var[ arg[0] ]; + rec.PutArg( new_arg[0] ); + f2g_var[i_var] = rec.PutOp( op ); + break; + + case ErfOp: + CPPAD_ASSERT_NARG_NRES(op, 3, 5); + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[0] ] ) < num_var ); + // Error function is a special case + // second argument is always the parameter 0 + // third argument is always the parameter 2 / sqrt(pi) + rec.PutArg( arg[1] ); // parameter + rec.PutArg( arg[2] ); // parameter + f2g_var[i_var] = rec.PutOp(op); + break; + // -------------------------------------------------------------- + // Binary operators, left variable, right parameter, one result + case SubvpOp: + case DivvpOp: + case PowvpOp: + case ZmulvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[0] ] ) < num_var ); + new_arg[0] = f2g_var[ arg[0] ]; + new_arg[1] = arg[1]; // parameter + rec.PutArg( new_arg[0], new_arg[1] ); + f2g_var[i_var] = rec.PutOp(op); + break; + // --------------------------------------------------- + // Binary operators, left index, right variable, one result + case DisOp: + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[1] ] ) < num_var ); + new_arg[0] = arg[0]; + new_arg[1] = f2g_var[ arg[1] ]; + rec.PutArg( new_arg[0], new_arg[1] ); + f2g_var[i_var] = rec.PutOp(op); + break; + + // -------------------------------------------------------------- + // Binary operators, left parameter, right variable, one result + case AddpvOp: + case SubpvOp: + case MulpvOp: + case DivpvOp: + case PowpvOp: + case ZmulpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[1] ] ) < num_var ); + new_arg[0] = arg[0]; // parameter + new_arg[1] = f2g_var[ arg[1] ]; + rec.PutArg( new_arg[0], new_arg[1] ); + f2g_var[i_var] = rec.PutOp(op); + break; + // -------------------------------------------------------------- + // Binary operators, left and right variables, one result + case AddvvOp: + case SubvvOp: + case MulvvOp: + case DivvvOp: + case ZmulvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[0] ] ) < num_var ); + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[1] ] ) < num_var ); + new_arg[0] = f2g_var[ arg[0] ]; + new_arg[1] = f2g_var[ arg[1] ]; + rec.PutArg( new_arg[0], new_arg[1] ); + f2g_var[i_var] = rec.PutOp(op); + break; + // --------------------------------------------------- + // Conditional expression operators + case CExpOp: + CPPAD_ASSERT_NARG_NRES(op, 6, 1); + new_arg[0] = arg[0]; + new_arg[1] = arg[1]; + mask = 1; + for(size_t i = 2; i < 6; i++) + { if( arg[1] & mask ) + { CPPAD_ASSERT_UNKNOWN( size_t(f2g_var[arg[i]]) < num_var ); + new_arg[i] = f2g_var[ arg[i] ]; + } + else + new_arg[i] = arg[i]; // parameter + mask = mask << 1; + } + rec.PutArg( + new_arg[0] , + new_arg[1] , + new_arg[2] , + new_arg[3] , + new_arg[4] , + new_arg[5] + ); + f2g_var[i_var] = rec.PutOp(op); + break; + + // -------------------------------------------------- + // Operators with no arguments and no results + case EndOp: + CPPAD_ASSERT_NARG_NRES(op, 0, 0); + rec.PutOp(op); + more_operators = false; + 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] = arg[0]; // parameter + new_arg[1] = f2g_var[ arg[1] ]; + 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] = f2g_var[ arg[0] ]; + new_arg[1] = arg[1]; // parameter + 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] = f2g_var[ arg[0] ]; + new_arg[1] = f2g_var[ arg[1] ]; + rec.PutArg(new_arg[0], new_arg[1]); + rec.PutOp(op); + break; + + // --------------------------------------------------- + // print forward operator + case PriOp: + CPPAD_ASSERT_NARG_NRES(op, 5, 0); + // + // arg[0] + new_arg[0] = arg[0]; + // + // arg[1] + if( arg[0] & 1 ) + { + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[1] ] ) < num_var ); + new_arg[1] = f2g_var[ arg[1] ]; + } + else + { new_arg[1] = arg[1]; // parameter + } + // + // arg[3] + if( arg[0] & 2 ) + { + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[3] ] ) < num_var ); + new_arg[3] = f2g_var[ arg[3] ]; + } + else + { new_arg[3] = arg[3]; // parameter + } + new_arg[2] = rec.PutTxt( play_.GetTxt(size_t(arg[2])) ); + new_arg[4] = rec.PutTxt( play_.GetTxt(size_t(arg[4])) ); + // + rec.PutArg( + new_arg[0] , + new_arg[1] , + new_arg[2] , + new_arg[3] , + new_arg[4] + ); + // no result + rec.PutOp(op); + break; + + // --------------------------------------------------- + // VecAD operators + + // Load using a parameter index + case LdpOp: + CPPAD_ASSERT_NARG_NRES(op, 3, 1); + new_arg[0] = arg[0]; + new_arg[1] = arg[1]; + new_arg[2] = arg[2]; + rec.PutArg( + new_arg[0], + new_arg[1], + new_arg[2] + ); + f2g_var[i_var] = rec.PutLoadOp(op); + break; + + // Load using a variable index + case LdvOp: + CPPAD_ASSERT_NARG_NRES(op, 3, 1); + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[1] ] ) < num_var ); + new_arg[0] = arg[0]; + new_arg[1] = f2g_var[ arg[1] ]; + new_arg[2] = arg[2]; + rec.PutArg( + new_arg[0], + new_arg[1], + new_arg[2] + ); + f2g_var[i_var] = rec.PutLoadOp(op); + break; + + // Store a parameter using a parameter index + case StppOp: + CPPAD_ASSERT_NARG_NRES(op, 3, 0); + new_arg[0] = arg[0]; + new_arg[1] = arg[1]; // parameter + new_arg[2] = arg[2]; // parameter + rec.PutArg( + new_arg[0], + new_arg[1], + new_arg[2] + ); + rec.PutOp(op); + break; + + // Store a parameter using a variable index + case StvpOp: + CPPAD_ASSERT_NARG_NRES(op, 3, 0); + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[1] ] ) < num_var ); + new_arg[0] = arg[0]; + new_arg[1] = f2g_var[ arg[1] ]; + new_arg[2] = arg[2]; // parameter + rec.PutArg( + new_arg[0], + new_arg[1], + new_arg[2] + ); + rec.PutOp(op); + break; + + // Store a variable using a parameter index + case StpvOp: + CPPAD_ASSERT_NARG_NRES(op, 3, 0); + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[2] ] ) < num_var ); + new_arg[0] = arg[0]; + new_arg[1] = arg[1]; // parameter + new_arg[2] = f2g_var[ arg[2] ]; + rec.PutArg( + new_arg[0], + new_arg[1], + new_arg[2] + ); + rec.PutOp(op); + break; + + // Store a variable using a variable index + case StvvOp: + CPPAD_ASSERT_NARG_NRES(op, 3, 0); + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[1] ] ) < num_var ); + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[ arg[2] ] ) < num_var ); + new_arg[0] = arg[0]; + new_arg[1] = f2g_var[ arg[1] ]; + new_arg[2] = f2g_var[ arg[2] ]; + rec.PutArg( + new_arg[0], + new_arg[1], + new_arg[2] + ); + break; + + // ----------------------------------------------------------- + // atomic function call operators + + case AFunOp: + CPPAD_ASSERT_NARG_NRES(op, 4, 0); + // atom_index, atom_old, atom_n, atom_m + rec.PutArg(arg[0], arg[1], arg[2], arg[3]); + rec.PutOp(AFunOp); + break; + + case FunapOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + new_arg[0] = arg[0]; // parameter + rec.PutArg(new_arg[0]); + rec.PutOp(FunapOp); + break; + + case FunavOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + CPPAD_ASSERT_UNKNOWN( size_t( f2g_var[arg[0]] ) < num_var ); + new_arg[0] = f2g_var[ arg[0] ]; + rec.PutArg(new_arg[0]); + rec.PutOp(FunavOp); + break; + + case FunrpOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + new_arg[0] = arg[0]; // parameter + rec.PutArg(new_arg[0]); + rec.PutOp(FunrpOp); + break; + + case FunrvOp: + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + f2g_var[i_var] = rec.PutOp(FunrvOp); + break; + // --------------------------------------------------- + + // all cases should be handled above + default: + CPPAD_ASSERT_UNKNOWN(false); + } + if( more_operators ) + (++itr).op_info(op, arg, i_var); + } + // Check a few expected results + CPPAD_ASSERT_UNKNOWN( rec.num_op_rec() == play_.num_op_rec() ); + CPPAD_ASSERT_UNKNOWN( rec.num_var_rec() == play_.num_var_rec() ); + CPPAD_ASSERT_UNKNOWN( rec.num_load_op_rec() == play_.num_load_op_rec() ); + + // ----------------------------------------------------------------------- + // Use rec to create the function g + // ----------------------------------------------------------------------- + + // number of variables in the recording + g.num_var_tape_ = rec.num_var_rec(); + + // dimension cskip_op vector to number of operators + g.cskip_op_.resize( rec.num_op_rec() ); + + // independent variables in g: (x, u) + size_t s = f_abs_res.size(); + size_t n = Domain(); + g.ind_taddr_.resize(n + s); + // (x, u) + for(size_t j = 0; j < n; j++) + { g.ind_taddr_[j] = size_t( f2g_var[ ind_taddr_[j] ] ); + CPPAD_ASSERT_UNKNOWN( g.ind_taddr_[j] == j + 1 ); + } + for(size_t j = 0; j < s; j++) + { g.ind_taddr_[n + j] = size_t( f2g_var[ f_abs_res[j] ] ); + CPPAD_ASSERT_UNKNOWN( g.ind_taddr_[n + j] == n + j + 1 ); + } + + // dependent variable in g: (y, z) + CPPAD_ASSERT_UNKNOWN( s == f_abs_arg.size() ); + size_t m = Range(); + g.dep_taddr_.resize(m + s); + for(size_t i = 0; i < m; i++) + { g.dep_taddr_[i] = size_t( f2g_var[ dep_taddr_[i] ] ); + CPPAD_ASSERT_UNKNOWN( g.dep_taddr_[i] < num_var ); + } + for(size_t i = 0; i < s; i++) + { g.dep_taddr_[m + i] = size_t( f2g_var[ f_abs_arg[i] ] ); + CPPAD_ASSERT_UNKNOWN( g.dep_taddr_[m + i] < num_var ); + } + + // which dependent variables are parameters + g.dep_parameter_.resize(m + s); + for(size_t i = 0; i < m; i++) + g.dep_parameter_[i] = dep_parameter_[i]; + for(size_t i = 0; i < s; i++) + g.dep_parameter_[m + i] = false; + + // free memory allocated for sparse Jacobian calculation + // (the resutls are no longer valid) + g.for_jac_sparse_pack_.resize(0, 0); + g.for_jac_sparse_set_.resize(0, 0); + + // free taylor coefficient memory + g.taylor_.clear(); + g.num_order_taylor_ = 0; + g.cap_order_taylor_ = 0; + + // Transferring the recording swaps its vectors so do this last + // replace the recording in g (this ADFun object) + g.play_.get_recording(rec, n + s); + + // resize subgraph_info_ + g.subgraph_info_.resize( + g.ind_taddr_.size(), // n_ind + g.dep_taddr_.size(), // n_dep + g.play_.num_op_rec(), // n_op + g.play_.num_var_rec() // n_var + ); + + // ------------------------------------------------------------------------ + // Create the function a + // ------------------------------------------------------------------------ + + // start with a copy of f + a = *this; + + // dependent variables in a(x) + CPPAD_ASSERT_UNKNOWN( s == f_abs_arg.size() ); + a.dep_taddr_.resize(s); + for(size_t i = 0; i < s; i++) + { a.dep_taddr_[i] = f_abs_res[i]; + CPPAD_ASSERT_UNKNOWN( a.dep_taddr_[i] < num_var ); + } + + // free memory allocated for sparse Jacobian calculation + // (the resutls are no longer valid) + a.for_jac_sparse_pack_.resize(0, 0); + a.for_jac_sparse_set_.resize(0, 0); + + // free taylor coefficient memory + a.taylor_.clear(); + a.num_order_taylor_ = 0; + a.cap_order_taylor_ = 0; +} + +// preprocessor symbols that are local to this file +# undef CPPAD_J_PAR_EQUAL_REC + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/acosh.hpp cppad-2019.02.00.0/include/cppad/core/acosh.hpp --- cppad-2018.00.00.0/include/cppad/core/acosh.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/acosh.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,94 @@ +# ifndef CPPAD_CORE_ACOSH_HPP +# define CPPAD_CORE_ACOSH_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$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/general/acosh.cpp +%$$ +The file +$cref acosh.cpp$$ +contains an example and test of this function. + +$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 +AD acosh(const AD &x) +{ return acosh_template(x); } + +template +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-2018.00.00.0/include/cppad/core/ad_assign.hpp cppad-2019.02.00.0/include/cppad/core/ad_assign.hpp --- cppad-2018.00.00.0/include/cppad/core/ad_assign.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/ad_assign.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,144 @@ +# ifndef CPPAD_CORE_AD_ASSIGN_HPP +# define CPPAD_CORE_AD_ASSIGN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------ + +$begin ad_assign$$ +$spell + Vec + const +$$ + + +$section AD Assignment Operator$$ + +$head Syntax$$ +$icode%y% = %x%$$ + +$head Purpose$$ +Assigns the value in $icode x$$ to the object $icode y$$. +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 an implicit constructor of the form +$icode%Base%(%x%)%$$. + +$head y$$ +The target $icode y$$ has prototype +$codei% + AD<%Base%> %y% +%$$ + +$head Example$$ +$children% + example/general/ad_assign.cpp +%$$ +The file $cref ad_assign.cpp$$ contain examples and tests of these operations. +It test returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------ +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +\file ad_assign.hpp +AD constructors and and copy operations. +*/ + +/*! +\page AD_default_assign +Use default assignment operator +because they may be optimized better than the code below: +\code +template +AD& AD::operator=(const AD &right) +{ value_ = right.value_; + tape_id_ = right.tape_id_; + taddr_ = right.taddr_; + ad_type_ = right.ad_type_; + + return *this; +} +\endcode +*/ + +/*! +Assignment to Base type value. + +\tparam Base +Base type for this AD object. + +\param b +is the Base type value being assignment to this AD object. +The tape identifier will be an invalid tape identifier, +so this object is initially a parameter. +*/ +template +AD& AD::operator=(const Base &b) +{ value_ = b; + tape_id_ = 0; + // + CPPAD_ASSERT_UNKNOWN( ! ( Variable(*this) | Dynamic(*this) ) ); + return *this; +} + +/*! +Assignment to an ADVec element drops the vector information. + +\tparam Base +Base type for this AD object. +*/ +template +AD& AD::operator=(const VecAD_reference &x) +{ *this = x.ADBase(); + CPPAD_ASSERT_UNKNOWN( ! Dynamic(*this) ); + return *this; +} + +/*! +Assignment from any other type, converts to Base type, and then uses assignment +from Base type. + +\tparam Base +Base type for this AD object. + +\tparam T +is the the type that is being assigned to AD. +There must be an assignment for Base from Type. + +\param t +is the object that is being assigned to an AD object. +*/ +template +template +AD& AD::operator=(const T &t) +{ *this = Base(t); + CPPAD_ASSERT_UNKNOWN( ! ( Variable(*this) | Dynamic(*this) ) ); + return *this; +} + + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/ad_binary.hpp cppad-2019.02.00.0/include/cppad/core/ad_binary.hpp --- cppad-2018.00.00.0/include/cppad/core/ad_binary.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/ad_binary.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,143 @@ +# ifndef CPPAD_CORE_AD_BINARY_HPP +# define CPPAD_CORE_AD_BINARY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin ad_binary$$ +$spell + Op + VecAD + const +$$ + +$section AD Binary Arithmetic Operators$$ + + + + + + + +$head Syntax$$ +$icode%z% = %x% %Op% %y%$$ + +$head Purpose$$ +Performs arithmetic operations where either $icode x$$ or $icode y$$ +has type +$codei%AD<%Base%>%$$ or +$cref%VecAD::reference%VecAD%VecAD::reference%$$. + +$head Op$$ +The operator $icode Op$$ is one of the following +$table +$bold Op$$ $cnext $bold Meaning$$ $rnext +$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$$ +$tend + +$head Base$$ +The type $icode Base$$ is determined by the operand that +has type $codei%AD<%Base%>%$$ or $codei%VecAD<%Base%>::reference%$$. + +$head x$$ +The operand $icode x$$ has the following prototype +$codei% + const %Type% &%x% +%$$ +where $icode Type$$ is +$codei%VecAD<%Base%>::reference%$$, +$codei%AD<%Base%>%$$, +$icode Base$$, or +$code double$$. + +$head y$$ +The operand $icode y$$ has the following prototype +$codei% + const %Type% &%y% +%$$ +where $icode Type$$ is +$codei%VecAD<%Base%>::reference%$$, +$codei%AD<%Base%>%$$, +$icode Base$$, or +$code double$$. + + +$head z$$ +The result $icode z$$ has the following prototype +$codei% + %Type% %z% +%$$ +where $icode Type$$ is +$codei%AD<%Base%>%$$. + +$head Operation Sequence$$ +This is an $cref/atomic_base/glossary/Operation/Atomic/$$ +$cref/AD of Base/glossary/AD of Base/$$ operation +and hence it is part of the current +AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$. + +$children% + example/general/add.cpp% + example/general/sub.cpp% + example/general/mul.cpp% + example/general/div.cpp +%$$ + +$head Example$$ +The following files contain examples and tests of these functions. +Each test returns true if it succeeds and false otherwise. +$table +$rref add.cpp$$ +$rref sub.cpp$$ +$rref mul.cpp$$ +$rref div.cpp$$ +$tend + +$head Derivative$$ +If $latex f$$ and $latex g$$ are +$cref/Base functions/glossary/Base Function/$$ + +$subhead Addition$$ +$latex \[ + \D{[ f(x) + g(x) ]}{x} = \D{f(x)}{x} + \D{g(x)}{x} +\] $$ + +$subhead Subtraction$$ +$latex \[ + \D{[ f(x) - g(x) ]}{x} = \D{f(x)}{x} - \D{g(x)}{x} +\] $$ + +$subhead Multiplication$$ +$latex \[ + \D{[ f(x) * g(x) ]}{x} = g(x) * \D{f(x)}{x} + f(x) * \D{g(x)}{x} +\] $$ + +$subhead Division$$ +$latex \[ + \D{[ f(x) / g(x) ]}{x} = + [1/g(x)] * \D{f(x)}{x} - [f(x)/g(x)^2] * \D{g(x)}{x} +\] $$ + +$end +----------------------------------------------------------------------------- +*/ +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/ad_ctor.hpp cppad-2019.02.00.0/include/cppad/core/ad_ctor.hpp --- cppad-2018.00.00.0/include/cppad/core/ad_ctor.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/ad_ctor.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,199 @@ +# ifndef CPPAD_CORE_AD_CTOR_HPP +# define CPPAD_CORE_AD_CTOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------ + +$begin ad_ctor$$ +$spell + cppad + ctor + initializes + Vec + const +$$ + + +$section AD Constructors $$ + +$head Syntax$$ +$codei%AD<%Base%> %y%() +%$$ +$codei%AD<%Base%> %y%(%x%) +%$$ + +$head Purpose$$ +creates a new $codei%AD<%Base%>%$$ object $icode y$$ +and initializes its value as equal to $icode x$$. + +$head x$$ + +$subhead implicit$$ +There is an implicit constructor where $icode x$$ has one of the following +prototypes: +$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%)%$$. + +$head y$$ +The target $icode y$$ has prototype +$codei% + AD<%Base%> %y% +%$$ + +$head Example$$ +$children% + example/general/ad_ctor.cpp +%$$ +The files $cref ad_ctor.cpp$$ contain examples and tests of these operations. +It test returns true if it succeeds and false otherwise. + +$end +------------------------------------------------------------------------------ +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +\file ad_ctor.hpp +AD constructors and and copy operations. +*/ + +/*! +\page AD_default_ctor +Use default copy constructor +because they may be optimized better than the code below: +\code +template +AD::AD(const AD &x) +{ + value_ = x.value_; + tape_id_ = x.tape_id_; + taddr_ = x.taddr_; + ad_type_ = x.ad_type_; + + return; +} +\endcode +*/ + +/*! +Default Constructor. + +\tparam Base +Base type for this AD object. +*/ +template +AD::AD(void) +: value_() +, tape_id_(0) +, taddr_(0) +, ad_type_(constant_enum) +{ } + +// -------------------------------------------------------------------------- +# ifdef CPPAD_FOR_TMB +/*! +Constructor from double. + +\param d +is value corresponding to this AD object. +The tape identifier will be an invalid tape identifier, +so this object is initially a parameter. + +\par CPPAD_FOR_TMB +This constructor is defined when CPPAD_FOR_TMB is defined. +*/ +template +AD::AD(const double &d) +: value_( Base(d) ) +, tape_id_(0) +, taddr_(0) +, ad_type_(constant_enum) +{ // check that this is a parameter + CPPAD_ASSERT_UNKNOWN( Parameter(*this) ); +} +// -------------------------------------------------------------------------- +# else +// -------------------------------------------------------------------------- +/*! +Constructor from Base type. + +\tparam Base +Base type for this AD object. + +\param b +is the Base type value corresponding to this AD object. +The tape identifier will be an invalid tape identifier, +so this object is initially a parameter. + +\par CPPAD_FOR_TMB +This constructor is defined when CPPAD_FOR_TMB is not defined. +*/ +template +AD::AD(const Base &b) +: value_(b) +, tape_id_(0) +, taddr_(0) +, ad_type_(constant_enum) +{ // check that this is a parameter + CPPAD_ASSERT_UNKNOWN( Parameter(*this) ); +} +# endif +// -------------------------------------------------------------------------- + +/*! +Constructor from an ADVec element drops the vector information. + +\tparam Base +Base type for this AD object. +*/ +template +AD::AD(const VecAD_reference &x) +{ *this = x.ADBase(); } + +/*! +Constructor from any other type, converts to Base type, and uses constructor +from Base type. + +\tparam Base +Base type for this AD object. + +\tparam T +is the the type that is being converted to AD. +There must be a constructor for Base from Type. + +\param t +is the object that is being converted from T to AD. +*/ +template +template +AD::AD(const T &t) +: value_(Base(t)) +, tape_id_(0) +, taddr_(0) +, ad_type_(constant_enum) +{ } + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/add_eq.hpp cppad-2019.02.00.0/include/cppad/core/add_eq.hpp --- cppad-2018.00.00.0/include/cppad/core/add_eq.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/add_eq.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,128 @@ +# ifndef CPPAD_CORE_ADD_EQ_HPP +# define CPPAD_CORE_ADD_EQ_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN CppAD namespace +namespace CppAD { + +template +AD& AD::operator += (const AD &right) +{ + // compute the Base part + Base left; + left = value_; + value_ += right.value_; + + // check if there is a recording in progress + local::ADTape* tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return *this; + 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 ); + + // check if left and right tapes match + bool match_left = tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "+= : AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // this = variable + variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::AddvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::AddvvOp) == 2 ); + + // put operand addresses in tape + tape->Rec_.PutArg(taddr_, right.taddr_); + // put operator in the tape + taddr_ = tape->Rec_.PutOp(local::AddvvOp); + // check that this is a variable + CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); + CPPAD_ASSERT_UNKNOWN( ad_type_ == variable_enum); + } + else if( dyn_right | (! IdenticalZero(right.value_) ) ) + { // this = variable + parameter + // = parameter + variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::AddpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::AddpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + tape->Rec_.PutArg(p, taddr_); + // put operator in the tape + taddr_ = tape->Rec_.PutOp(local::AddpvOp); + // check that this is a variable + CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); + CPPAD_ASSERT_UNKNOWN( ad_type_ == variable_enum); + } + } + else if( var_right ) + { if( (! dyn_left) & IdenticalZero(left) ) + { // this = 0 + right + make_variable(right.tape_id_, right.taddr_); + } + else + { // this = parameter + variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::AddpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::AddpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left); + tape->Rec_.PutArg(p, right.taddr_); + + // put operator in the tape + taddr_ = tape->Rec_.PutOp(local::AddpvOp); + + // make this a variable + tape_id_ = tape_id; + ad_type_ = variable_enum; + } + } + else if( dyn_left | dyn_right ) + { addr_t arg0 = taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + // parameters with a dynamic parameter results + taddr_ = tape->Rec_.put_dyn_par( + value_, local::add_dyn, arg0, arg1 + ); + tape_id_ = tape_id; + ad_type_ = dynamic_enum; + } + return *this; +} + +CPPAD_FOLD_ASSIGNMENT_OPERATOR(+=) + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/add.hpp cppad-2019.02.00.0/include/cppad/core/add.hpp --- cppad-2018.00.00.0/include/cppad/core/add.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/add.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,131 @@ +# ifndef CPPAD_CORE_ADD_HPP +# define CPPAD_CORE_ADD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN CppAD namespace +namespace CppAD { + +template +AD operator + (const AD &left , const AD &right) +{ + // compute the Base part of this AD object + AD result; + result.value_ = left.value_ + right.value_; + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); + + // check if there is a recording in progress + local::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 ); + + // check if left and right tapes match + bool match_left = left.tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (left.ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (left.ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + left.tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "Add: AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // result = variable + variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::AddvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::AddvvOp) == 2 ); + + // put operand addresses in tape + tape->Rec_.PutArg(left.taddr_, right.taddr_); + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::AddvvOp); + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + else if( (! dyn_right) & IdenticalZero(right.value_) ) + { // result = variable + 0 + result.make_variable(left.tape_id_, left.taddr_); + } + else + { // result = variable + parameter + // = parameter + variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::AddpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::AddpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + tape->Rec_.PutArg(p, left.taddr_); + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::AddpvOp); + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + } + else if( var_right ) + { if( (! dyn_left) & IdenticalZero(left.value_) ) + { // result = 0 + variable + result.make_variable(right.tape_id_, right.taddr_); + } + else + { // result = parameter + variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::AddpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::AddpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = left.taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left.value_); + tape->Rec_.PutArg(p, right.taddr_); + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::AddpvOp); + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + } + else if( dyn_left | dyn_right ) + { addr_t arg0 = left.taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left.value_); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + // parameters with a dynamic parameter result + result.taddr_ = tape->Rec_.put_dyn_par( + result.value_, local::add_dyn, arg0, arg1 + ); + result.tape_id_ = tape_id; + result.ad_type_ = dynamic_enum; + } + return result; +} + +// convert other cases into the case above +CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(+) + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/ad_fun.hpp cppad-2019.02.00.0/include/cppad/core/ad_fun.hpp --- cppad-2018.00.00.0/include/cppad/core/ad_fun.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/ad_fun.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,847 @@ +# ifndef CPPAD_CORE_AD_FUN_HPP +# define CPPAD_CORE_AD_FUN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin ADFun$$ +$spell + xk + Ind + bool + taylor_ + sizeof + const + std + ind_taddr_ + dep_taddr_ +$$ + +$spell +$$ + +$section ADFun Objects$$ + + +$head Purpose$$ +An AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$ +is stored in an $code ADFun$$ object by its $cref FunConstruct$$. +The $code ADFun$$ object can then be used to calculate function values, +derivative values, and other values related to the corresponding function. + +$childtable% + omh/adfun.omh% + include/cppad/core/optimize.hpp% + example/abs_normal/abs_normal.omh% + include/cppad/core/fun_check.hpp% + include/cppad/core/check_for_nan.hpp +%$$ + +$end +*/ +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file ad_fun.hpp +File used to define the ADFun class. +*/ + +/*! +Class used to hold function objects + +\tparam Base +A function object has a recording of AD operations. +It does it calculations using Base operations. +*/ + + +template +class ADFun { + // ADFun must be a friend of ADFun< AD > for base2ad to work. + template friend class ADFun; +private: + // ------------------------------------------------------------ + // Private member variables + // ------------------------------------------------------------ + + /// Is this function obejct a base2ad return value + /// (special becasue some compliers need copy constructor in this case) + bool base2ad_return_value_; + + /// 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_; + + /// 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_; + + /// maximum number of orders that will fit in taylor_ + size_t cap_order_taylor_; + + /// number of directions stored in taylor_ + size_t num_direction_taylor_; + + /// number of variables in the recording (play_) + size_t num_var_tape_; + + /// tape address for the independent variables + local::pod_vector ind_taddr_; + + /// tape address and parameter flag for the dependent variables + local::pod_vector dep_taddr_; + + /// which dependent variables are actually parameters + local::pod_vector dep_parameter_; + + /// results of the forward mode calculations + local::pod_vector_maybe taylor_; + + /// which operations can be conditionally skipped + /// Set during forward pass of order zero + local::pod_vector cskip_op_; + + /// Variable on the tape corresponding to each vecad load operation + /// (if zero, the operation corresponds to a parameter). + local::pod_vector load_op_; + + /// the operation sequence corresponding to this object + local::player play_; + + /// Packed results of the forward mode Jacobian sparsity calculations. + /// for_jac_sparse_pack_.n_set() != 0 implies other sparsity results + /// are empty + local::sparse_pack for_jac_sparse_pack_; + + /// Set results of the forward mode Jacobian sparsity calculations + /// for_jac_sparse_set_.n_set() != 0 implies for_sparse_pack_ is empty. + local::sparse_list for_jac_sparse_set_; + + /// subgraph information for this object + local::subgraph::subgraph_info subgraph_info_; + + /// used for subgraph reverse mode calculations. + /// Declared here to avoid reallocation for each call to subgraph_reverse. + /// Not in subgraph_info_ because it depends on Base. + local::pod_vector_maybe subgraph_partial_; + + // ------------------------------------------------------------ + // Private member functions + // ------------------------------------------------------------ + + /// change the operation sequence corresponding to this object + template + void Dependent(local::ADTape *tape, const ADvector &y); + + // vector of bool version of ForSparseJac + // (doxygen in cppad/core/for_sparse_jac.hpp) + template + void ForSparseJacCase( + bool set_type , + bool transpose , + bool dependency, + size_t q , + const SetVector& r , + SetVector& s + ); + + // vector of std::set version of ForSparseJac + // (doxygen in cppad/core/for_sparse_jac.hpp) + template + void ForSparseJacCase( + const std::set& set_type , + bool transpose , + bool dependency, + size_t q , + const SetVector& r , + SetVector& s + ); + + // vector of bool version of RevSparseJac + // (doxygen in cppad/core/rev_sparse_jac.hpp) + template + void RevSparseJacCase( + bool set_type , + bool transpose , + bool dependency, + size_t p , + const SetVector& s , + SetVector& r + ); + + // vector of std::set version of RevSparseJac + // (doxygen in cppad/core/rev_sparse_jac.hpp) + template + void RevSparseJacCase( + const std::set& set_type , + bool transpose , + bool dependency, + size_t p , + const SetVector& s , + SetVector& r + ); + + // vector of bool version of ForSparseHes + // (doxygen in cppad/core/for_sparse_hes.hpp) + template + void ForSparseHesCase( + bool set_type , + const SetVector& r , + const SetVector& s , + SetVector& h + ); + + // vector of std::set version of ForSparseHes + // (doxygen in cppad/core/for_sparse_hes.hpp) + template + void ForSparseHesCase( + const std::set& set_type , + const SetVector& r , + const SetVector& s , + SetVector& h + ); + + // vector of bool version of RevSparseHes + // (doxygen in cppad/core/rev_sparse_hes.hpp) + template + void RevSparseHesCase( + bool set_type , + bool transpose , + size_t q , + const SetVector& s , + SetVector& h + ); + + // vector of std::set version of RevSparseHes + // (doxygen in cppad/core/rev_sparse_hes.hpp) + template + void RevSparseHesCase( + const std::set& set_type , + bool transpose , + size_t q , + const SetVector& s , + SetVector& h + ); + + // Forward mode version of SparseJacobian + // (doxygen in cppad/core/sparse_jacobian.hpp) + template + size_t SparseJacobianFor( + const BaseVector& x , + SetVector& p_transpose , + const SizeVector& row , + const SizeVector& col , + BaseVector& jac , + sparse_jacobian_work& work + ); + + // Reverse mode version of SparseJacobian + // (doxygen in cppad/core/sparse_jacobian.hpp) + template + size_t SparseJacobianRev( + const BaseVector& x , + SetVector& p , + const SizeVector& row , + const SizeVector& col , + BaseVector& jac , + sparse_jacobian_work& work + ); + + // combined sparse_list and sparse_pack version of SparseHessian + // (doxygen in cppad/core/sparse_hessian.hpp) + template + size_t SparseHessianCompute( + const BaseVector& x , + const BaseVector& w , + SetVector& sparsity , + const SizeVector& row , + const SizeVector& col , + BaseVector& hes , + sparse_hessian_work& work + ); + +public: + /// default constructor + ADFun(void); + + /// copy constructor + ADFun(const ADFun& g); + + // assignment operator + // (doxygen in cppad/core/fun_construct.hpp) + void operator=(const ADFun& f); +# if CPPAD_USE_CPLUSPLUS_2011 + // assignment operator with move semantics + void operator=(ADFun&& f); +# endif + + // create ADFun< AD > from this ADFun + // (doxygen in cppad/core/base2ad.hpp) + ADFun< AD, RecBase > base2ad(void) const; + + /// sequence constructor + template + ADFun(const ADvector &x, const ADvector &y); + + /// destructor + ~ADFun(void) + { } + + /// set check_for_nan + void check_for_nan(bool value); + + /// get check_for_nan + bool check_for_nan(void) const; + + /// assign a new operation sequence + template + void Dependent(const ADvector &x, const ADvector &y); + + /// new_dynamic user API + template + void new_dynamic(const BaseVector& dynamic); + + /// forward mode user API, one order multiple directions. + template + BaseVector Forward(size_t q, size_t r, const BaseVector& x); + + /// forward mode user API, multiple directions one order. + template + BaseVector Forward(size_t q, + const BaseVector& x, std::ostream& s = std::cout + ); + + /// reverse mode sweep + template + BaseVector Reverse(size_t p, const BaseVector &v); + + // forward Jacobian sparsity pattern + // (doxygen in cppad/core/for_sparse_jac.hpp) + template + SetVector ForSparseJac( + size_t q, const SetVector &r, bool transpose = false, + bool dependency = false + ); + + // reverse Jacobian sparsity pattern + // (doxygen in cppad/core/rev_sparse_jac.hpp) + template + SetVector RevSparseJac( + size_t q, const SetVector &s, bool transpose = false, + bool dependency = false + ); + + // subgraph_reverse: select domain + // (doxygen in cppad/core/subgraph_reverse.hpp) + template + void subgraph_reverse( + const BoolVector& select_domain + ); + + // subgraph_reverse: compute derivative + // (doxygen in cppad/core/subgraph_reverse.hpp) + template + void subgraph_reverse_helper( + size_t q , + size_t ell , + SizeVector& col , + BaseVector& dw + ); + + // subgraph_reverse: compute derivative + // (doxygen in cppad/core/subgraph_reverse.hpp) + template + void subgraph_reverse( + size_t q , + size_t ell , + SizeVector& col , + BaseVector& dw + ); + + // subgraph_jac_rev: compute Jacobian + // (doxygen in cppad/core/subgraph_jac_rev.hpp) + template + void subgraph_jac_rev( + const BaseVector& x , + sparse_rcv& subset + ); + + // subgraph_jac_rev: compute Jacobian + // (doxygen missing in cppad/core/subgraph_jac_rev.hpp) + template + void subgraph_jac_rev( + const BoolVector& select_domain , + const BoolVector& select_range , + const BaseVector& x , + sparse_rcv& matrix_out + ); + + + // compute sparse Jacobian using forward mode + // (doxygen in cppad/core/sparse_jac.hpp) + template + size_t sparse_jac_for( + size_t group_max , + const BaseVector& x , + sparse_rcv& subset , + const sparse_rc& pattern , + const std::string& coloring , + sparse_jac_work& work + ); + + // compute sparse Jacobian using reverse mode + // (doxygen in cppad/core/sparse_jac.hpp) + template + size_t sparse_jac_rev( + const BaseVector& x , + sparse_rcv& subset , + const sparse_rc& pattern , + const std::string& coloring , + sparse_jac_work& work + ); + + // compute sparse Hessian + // (doxygen in cppad/core/sparse_hes.hpp) + template + size_t sparse_hes( + const BaseVector& x , + const BaseVector& w , + sparse_rcv& subset , + const sparse_rc& pattern , + const std::string& coloring , + sparse_hes_work& work + ); + + // compute sparsity pattern using subgraphs + // (doxygen in cppad/core/subgraph_sparsity.hpp) + template + void subgraph_sparsity( + const BoolVector& select_domain , + const BoolVector& select_range , + bool transpose , + sparse_rc& pattern_out + ); + + + // forward mode Jacobian sparsity pattern + // (doxygen in cppad/core/for_jac_sparsity.hpp) + template + void for_jac_sparsity( + const sparse_rc& pattern_in , + bool transpose , + bool dependency , + bool internal_bool , + sparse_rc& pattern_out + ); + + // reverse mode Jacobian sparsity pattern + // (doxygen in cppad/core/for_jac_sparsity.hpp) + template + void rev_jac_sparsity( + const sparse_rc& pattern_in , + bool transpose , + bool dependency , + bool internal_bool , + sparse_rc& pattern_out + ); + + // reverse mode Hessian sparsity pattern + // (doxygen in cppad/core/rev_hes_sparsity.hpp) + template + void rev_hes_sparsity( + const BoolVector& select_range , + bool transpose , + bool internal_bool , + sparse_rc& pattern_out + ); + + // forward mode Hessian sparsity pattern + // (doxygen in cppad/core/for_hes_sparsity.hpp) + template + void for_hes_sparsity( + const BoolVector& select_domain , + const BoolVector& select_range , + bool internal_bool , + sparse_rc& pattern_out + ); + + // forward mode Hessian sparsity pattern + // (see doxygen in cppad/core/for_sparse_hes.hpp) + template + SetVector ForSparseHes( + const SetVector &r, const SetVector &s + ); + + // internal set sparsity version of ForSparseHes + // (used by checkpoint functions only) + void ForSparseHesCheckpoint( + vector& r , + vector& s , + local::sparse_list& h + ); + + // reverse mode Hessian sparsity pattern + // (see doxygen in cppad/core/rev_sparse_hes.hpp) + template + SetVector RevSparseHes( + size_t q, const SetVector &s, bool transpose = false + ); + + // internal set sparsity version of RevSparseHes + // (doxygen in cppad/core/rev_sparse_hes.hpp) + // (used by checkpoint functions only) + void RevSparseHesCheckpoint( + size_t q , + vector& s , + bool transpose , + local::sparse_list& h + ); + + // internal set sparsity version of RevSparseJac + // (doxygen in cppad/core/rev_sparse_jac.hpp) + // (used by checkpoint functions only) + void RevSparseJacCheckpoint( + size_t q , + const local::sparse_list& r , + bool transpose , + bool dependency , + local::sparse_list& s + ); + + // internal set sparsity version of RevSparseJac + // (doxygen in cppad/core/for_sparse_jac.hpp) + // (used by checkpoint functions only) + void ForSparseJacCheckpoint( + size_t q , + const local::sparse_list& r , + bool transpose , + bool dependency , + local::sparse_list& s + ); + + /// amount of memory used for boolean Jacobain sparsity pattern + size_t size_forward_bool(void) const + { return for_jac_sparse_pack_.memory(); } + + /// 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); + } + + /// amount of memory used for vector of set Jacobain sparsity pattern + size_t size_forward_set(void) const + { return for_jac_sparse_set_.memory(); } + + /// 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); + } + + /// number of operators in the operation sequence + size_t size_op(void) const + { return play_.num_op_rec(); } + + /// number of operator arguments in the operation sequence + size_t size_op_arg(void) const + { return play_.num_op_arg_rec(); } + + /// amount of memory required for the operation sequence + size_t size_op_seq(void) const + { return play_.size_op_seq(); } + + /// amount of memory currently allocated for random access + /// of the operation sequence + size_t size_random(void) const + { return play_.size_random(); } + + /// number of parameters in the operation sequence + size_t size_par(void) const + { return play_.num_par_rec(); } + + /// number of independent dynamic parameters + size_t size_dyn_ind(void) const + { return play_.num_dynamic_ind(); } + + /// number of dynamic parameters + size_t size_dyn_par(void) const + { return play_.num_dynamic_par(); } + + /// number of dynamic parameters arguments + size_t size_dyn_arg(void) const + { return play_.num_dynamic_arg(); } + + /// number taylor coefficient orders calculated + size_t size_order(void) const + { return num_order_taylor_; } + + /// number taylor coefficient directions calculated + size_t size_direction(void) const + { return num_direction_taylor_; } + + /// number of characters in the operation sequence + size_t size_text(void) const + { return play_.num_text_rec(); } + + /// number of variables in opertion sequence + size_t size_var(void) const + { return num_var_tape_; } + + /// number of VecAD indices in the operation sequence + size_t size_VecAD(void) const + { return play_.num_vec_ind_rec(); } + + /// set number of orders currently allocated (user API) + void capacity_order(size_t c); + + /// set number of orders and directions currently allocated + void capacity_order(size_t c, size_t r); + + /// number of variables in conditional expressions that can be skipped + size_t number_skip(void); + + /// number of independent variables + size_t Domain(void) const + { return ind_taddr_.size(); } + + /// number of dependent variables + size_t Range(void) const + { return dep_taddr_.size(); } + + /// is variable a parameter + bool Parameter(size_t i) + { CPPAD_ASSERT_KNOWN( + i < dep_taddr_.size(), + "Argument to Parameter is >= dimension of range space" + ); + return dep_parameter_[i]; + } + + /// 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_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 + BaseVector Jacobian(const BaseVector &x); + + /// calculate Hessian for one component of f + template + BaseVector Hessian(const BaseVector &x, const BaseVector &w); + template + BaseVector Hessian(const BaseVector &x, size_t i); + + /// forward mode calculation of partial w.r.t one domain component + template + BaseVector ForOne( + const BaseVector &x , + size_t j ); + + /// reverse mode calculation of derivative of one range component + template + BaseVector RevOne( + const BaseVector &x , + size_t i ); + + /// forward mode calculation of a subset of second order partials + template + BaseVector ForTwo( + const BaseVector &x , + const SizeVector_t &J , + const SizeVector_t &K ); + + /// reverse mode calculation of a subset of second order partials + template + BaseVector RevTwo( + const BaseVector &x , + const SizeVector_t &I , + const SizeVector_t &J ); + + /// calculate sparse Jacobians + template + BaseVector SparseJacobian( + const BaseVector &x + ); + template + BaseVector SparseJacobian( + const BaseVector &x , + const SetVector &p + ); + template + size_t SparseJacobianForward( + const BaseVector& x , + const SetVector& p , + const SizeVector& r , + const SizeVector& c , + BaseVector& jac , + sparse_jacobian_work& work + ); + template + size_t SparseJacobianReverse( + const BaseVector& x , + const SetVector& p , + const SizeVector& r , + const SizeVector& c , + BaseVector& jac , + sparse_jacobian_work& work + ); + + /// calculate sparse Hessians + template + BaseVector SparseHessian( + const BaseVector& x , + const BaseVector& w + ); + template + BaseVector SparseHessian( + const BaseVector& x , + const BaseVector& w , + const BoolVector& p + ); + template + size_t SparseHessian( + const BaseVector& x , + const BaseVector& w , + const SetVector& p , + const SizeVector& r , + const SizeVector& c , + BaseVector& hes , + sparse_hessian_work& work + ); + + // Optimize the tape + // (see doxygen documentation in optimize.hpp) + void optimize( const std::string& options = "" ); + + // create abs-normal representation of the function f(x) + void abs_normal_fun( ADFun& g, ADFun& a ) const; + + // clear all subgraph information + void clear_subgraph(void); + // ------------------- Deprecated ----------------------------- + + /// deprecated: assign a new operation sequence + template + void Dependent(const ADvector &y); + + /// Deprecated: number of variables in opertion sequence + size_t Size(void) const + { return num_var_tape_; } + + /// 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 + /// Note that an approximation is used for the std::set memory + size_t Memory(void) const + { size_t pervar = cap_order_taylor_ * sizeof(Base) + + for_jac_sparse_pack_.memory() + + for_jac_sparse_set_.memory(); + size_t total = num_var_tape_ * pervar; + total += play_.size_op_seq(); + total += play_.size_random(); + total += subgraph_info_.memory(); + return total; + } + + /// Deprecated: # taylor_ coefficient orderss stored + /// (per variable,direction) + size_t taylor_size(void) const + { return num_order_taylor_; } + + /// 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 + /// (per variable,direction) + size_t size_taylor(void) const + { return num_order_taylor_; } + + /// Deprecated: set number of orders currently allocated + /// (per variable,direction) + void capacity_taylor(size_t per_var); +}; +// --------------------------------------------------------------------------- + +} // END_CPPAD_NAMESPACE + +// non-user interfaces +# include +# include +# include +# include +# include +# include +# include +# include + +// user interfaces +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/ad.hpp cppad-2019.02.00.0/include/cppad/core/ad.hpp --- cppad-2018.00.00.0/include/cppad/core/ad.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/ad.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,313 @@ +# ifndef CPPAD_CORE_AD_HPP +# define CPPAD_CORE_AD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// simple AD operations that must be defined for AD as well as base class +# include +# include + +// define the template classes that are used by the AD template class +# include +# include +# include +# include +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +// tape_manage_enum +typedef enum { + new_tape_manage, + delete_tape_manage +} +tape_manage_enum; + +template +class AD { +private : + // ----------------------------------------------------------------------- + // Base type value for this object + Base value_; + // + // tape for this object + tape_id_t tape_id_; + // + // tape address for this object + // (when tape_id is current tape for AD) + addr_t taddr_; + // + // sub-type for this object + // (when tape_id is current tape for AD) + ad_type_enum ad_type_; + // ----------------------------------------------------------------------- + + // enable use of AD in parallel mode + template + friend void parallel_ad(void); + + // template friend functions where template parameter is not bound + template + friend void Independent( + ADVector& x , + size_t abort_op_index , + bool record_compare , + ADVector& dynamic + ); + + // one argument functions + friend bool Constant (const AD &u); + friend bool Constant (const VecAD &u); + // + friend bool Dynamic (const AD &u); + friend bool Dynamic (const VecAD &u); + // + friend bool Parameter (const AD &u); + friend bool Parameter (const VecAD &u); + // + friend bool Variable (const AD &u); + friend bool Variable (const VecAD &u); + // + friend int Integer (const AD &u); + friend AD Var2Par (const AD &u); + // + friend unsigned short hash_code (const AD &u); + // + // power function + 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); + friend bool LessThanZero (const AD &x); + friend bool LessThanOrZero (const AD &x); + friend bool abs_geq + (const AD& x, const AD& y); + + // The identical property functions, see identical.hpp + friend bool IdenticalCon (const AD &x); + friend bool IdenticalZero (const AD &x); + friend bool IdenticalOne (const AD &x); + friend bool IdenticalEqualCon + (const AD &x, const AD &y); + + // EqualOpSeq function + friend bool EqualOpSeq + (const AD &u, const AD &v); + + // NearEqual function + friend bool NearEqual ( + const AD &x, const AD &y, const Base &r, const Base &a); + + friend bool NearEqual ( + const Base &x, const AD &y, const Base &r, const Base &a); + + friend bool NearEqual ( + const AD &x, const Base &y, const Base &r, const Base &a); + + // CondExp function + friend AD CondExpOp ( + enum CompareOp cop , + const AD &left , + const AD &right , + const AD &trueCase , + const AD &falseCase + ); + + // classes + friend class local::ADTape; + friend class local::recorder; + friend class ADFun; + friend class atomic_base; + friend class atomic_three; + friend class discrete; + friend class VecAD; + friend class VecAD_reference; + + // arithematic binary operators + friend AD operator + + (const AD &left, const AD &right); + friend AD operator - + (const AD &left, const AD &right); + friend AD operator * + (const AD &left, const AD &right); + friend AD operator / + (const AD &left, const AD &right); + + // comparison operators + friend bool operator < + (const AD &left, const AD &right); + friend bool operator <= + (const AD &left, const AD &right); + friend bool operator > + (const AD &left, const AD &right); + friend bool operator >= + (const AD &left, const AD &right); + friend bool operator == + (const AD &left, const AD &right); + friend bool operator != + (const AD &left, const AD &right); + + // input operator + friend std::istream& operator >> + (std::istream &is, AD &x); + + // output operations + friend std::ostream& operator << + (std::ostream &os, const AD &x); + friend void PrintFor ( + const AD& flag , + const char* before , + const AD& var , + const char* after + ); +public: + // type of value + typedef Base value_type; + + // implicit default constructor + AD(void); + + // destructor + ~AD(void) { } + + // use default implicit copy constructor + // AD(const AD &x); + +# ifdef CPPAD_FOR_TMB + // TMB would rather have implicit construction from double, + // CppAD uses default constructor and assignment to double instead. + AD(const double &d); +# else + // implicit construction from base type + AD(const Base &b); +# endif + + // implicit contructor from VecAD::reference + AD(const VecAD_reference &x); + + // explicit construction from some other type (depricated) + template explicit AD(const T &t); + + // conversion from AD to Base type + friend Base Value (const AD &x); + + // use default assignment operator + // AD& operator=(const AD &x); + + // assingment from base type + AD& operator=(const Base &b); + + // assignment from VecAD::reference + AD& operator=(const VecAD_reference &x); + + // assignment from some other type + template AD& operator=(const T &right); + + // compound assignment operators + AD& operator += (const AD &right); + AD& operator -= (const AD &right); + AD& operator *= (const AD &right); + AD& operator /= (const AD &right); + + // unary operators + AD operator +(void) const; + AD operator -(void) const; + + // interface so these functions need not be friends + AD abs_me(void) const; + AD acos_me(void) const; + AD asin_me(void) const; + AD atan_me(void) const; + AD cos_me(void) const; + AD cosh_me(void) const; + AD exp_me(void) const; + AD fabs_me(void) const; + AD log_me(void) const; + AD sin_me(void) const; + AD sign_me(void) const; + AD sinh_me(void) const; + AD sqrt_me(void) const; + AD tan_me(void) const; + AD tanh_me(void) const; +# if CPPAD_USE_CPLUSPLUS_2011 + AD erf_me(void) const; + AD asinh_me(void) const; + AD acosh_me(void) const; + AD atanh_me(void) const; + AD expm1_me(void) const; + AD log1p_me(void) const; +# endif + + // ---------------------------------------------------------- + // static public member functions + + // abort current AD recording + static void abort_recording(void); + + // set the maximum number of OpenMP threads (deprecated) + static void omp_max_thread(size_t number); + + // These functions declared public so can be accessed by user through + // a macro interface and are not intended for direct use. + // The macro interface is documented in bool_fun.hpp. + // Developer documentation for these fucntions is in bool_fun.hpp + static bool UnaryBool( + bool FunName(const Base &x), + const AD &x + ); + static bool BinaryBool( + bool FunName(const Base &x, const Base &y), + const AD &x , const AD &y + ); + +private: + // ----------------------------------------------------------------- + // Make this parameter a new variable + void make_variable(tape_id_t id, addr_t taddr) + { CPPAD_ASSERT_UNKNOWN( Parameter(*this) ); // currently a par + CPPAD_ASSERT_UNKNOWN( taddr > 0 ); // sure valid taddr + + tape_id_ = id; + taddr_ = taddr; + ad_type_ = variable_enum; + } + // --------------------------------------------------------------- + // tape linking functions + // + // not static + local::ADTape* tape_this(void) const; + // + // static + static tape_id_t* tape_id_ptr(size_t thread); + static local::ADTape** tape_handle(size_t thread); + static local::ADTape* tape_manage(tape_manage_enum job); + static local::ADTape* tape_ptr(void); + static local::ADTape* tape_ptr(tape_id_t tape_id); +}; +// --------------------------------------------------------------------------- + +} // END_CPPAD_NAMESPACE + +// tape linking private functions +# include + +// operations that expect the AD template class to be defined + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/ad_io.hpp cppad-2019.02.00.0/include/cppad/core/ad_io.hpp --- cppad-2018.00.00.0/include/cppad/core/ad_io.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/ad_io.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,219 @@ +# ifndef CPPAD_CORE_AD_IO_HPP +# define CPPAD_CORE_AD_IO_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin ad_input$$ +$spell + VecAD + std + istream + const +$$ + + +$section AD Output Stream Operator$$ + +$head Syntax$$ +$icode%is% >> %x%$$ + + +$head Purpose$$ +Sets $icode x$$ to a $cref/parameter/glossary/Parameter/$$ +with value $icode b$$ corresponding to +$codei% + %is% >> %b% +%$$ +where $icode b$$ is a $icode Base$$ object. +It is assumed that this $icode Base$$ input operation returns +a reference to $icode is$$. + +$head is$$ +The operand $icode is$$ has prototype +$codei% + std::istream& %is% +%$$ + +$head x$$ +The operand $icode x$$ has one of the following prototypes +$codei% + AD<%Base%>& %x% +%$$ + +$head Result$$ +The result of this operation can be used as a reference to $icode is$$. +For example, if the operand $icode y$$ has prototype +$codei% + AD<%Base%> %y% +%$$ +then the syntax +$codei% + %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$$. + +$head Operation Sequence$$ +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 Example$$ +$children% + example/general/ad_input.cpp +%$$ +The file +$cref ad_input.cpp$$ +contains an example and test of this operation. + +$end +------------------------------------------------------------------------------ +$begin ad_output$$ +$spell + VecAD + std + ostream + const +$$ + + +$section AD Output Stream Operator$$ + +$head Syntax$$ +$icode%os% << %x%$$ + + +$head Purpose$$ +Writes the $icode Base$$ value, corresponding to $icode x$$, +to the output stream $icode os$$. + +$head Assumption$$ +If $icode b$$ is a $icode Base$$ object, +$codei% + %os% << %b% +%$$ +returns a reference to $icode os$$. + +$head os$$ +The operand $icode os$$ has prototype +$codei% + std::ostream& %os% +%$$ + +$head x$$ +The operand $icode x$$ has one of the following prototypes +$codei% + const AD<%Base%>& %x% + const VecAD<%Base%>::reference& %x% +%$$ + +$head Result$$ +The result of this operation can be used as a reference to $icode os$$. +For example, if the operand $icode y$$ has prototype +$codei% + AD<%Base%> %y% +%$$ +then the syntax +$codei% + %os% << %x% << %y% +%$$ +will output the value corresponding to $icode x$$ +followed by the value corresponding to $icode y$$. + +$head Operation Sequence$$ +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 Example$$ +$children% + example/general/ad_output.cpp +%$$ +The file +$cref ad_output.cpp$$ +contains an example and test of this operation. + +$end +------------------------------------------------------------------------------ +*/ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file ad_io.hpp +AD input and ouput stream operators. +*/ +// --------------------------------------------------------------------------- +/*! +Read an AD object from an input stream. + +\tparam Base +Base type for the AD object. + +\param is [in,out] +Is the input stream from which that value is read. + +\param x [out] +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. +*/ +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +std::istream& operator >> (std::istream& is, AD& x) +{ // like assignment to a base type value + x.tape_id_ = 0; + CPPAD_ASSERT_UNKNOWN( Parameter(x) ); + return (is >> x.value_); +} +// --------------------------------------------------------------------------- +/*! +Write an AD object to an output stream. + +\tparam Base +Base type for the AD object. + +\param os [in,out] +Is the output stream to which that value is written. + +\param x +is the object that is being written 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_); } +// --------------------------------------------------------------------------- +/*! +Write a VecAD_reference object to an output stream. + +\tparam Base +Base type for the VecAD_reference object. + +\param os [in,out] +Is the output stream to which that value is written. + +\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. +*/ +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +std::ostream& operator << (std::ostream &os, const VecAD_reference &x) +{ return (os << x.ADBase()); } + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/ad_to_string.hpp cppad-2019.02.00.0/include/cppad/core/ad_to_string.hpp --- cppad-2018.00.00.0/include/cppad/core/ad_to_string.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/ad_to_string.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,70 @@ +# ifndef CPPAD_CORE_AD_TO_STRING_HPP +# define CPPAD_CORE_AD_TO_STRING_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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. + +$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-2018.00.00.0/include/cppad/core/ad_type.hpp cppad-2019.02.00.0/include/cppad/core/ad_type.hpp --- cppad-2018.00.00.0/include/cppad/core/ad_type.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/ad_type.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,30 @@ +# ifndef CPPAD_CORE_AD_TYPE_HPP +# define CPPAD_CORE_AD_TYPE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file ad_type.hpp +Define the enum type ad_type_enum +*/ + +/// The ad_type_enum type +typedef enum { + constant_enum, + dynamic_enum, + variable_enum +} +ad_type_enum; + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/ad_valued.hpp cppad-2019.02.00.0/include/cppad/core/ad_valued.hpp --- cppad-2018.00.00.0/include/cppad/core/ad_valued.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/ad_valued.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,50 @@ +# ifndef CPPAD_CORE_AD_VALUED_HPP +# define CPPAD_CORE_AD_VALUED_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin ADValued$$ +$spell +$$ + + +$section AD Valued Operations and Functions$$ + +$comment atomic.omh includes atomic_two.hpp$$ +$childtable% + include/cppad/core/arithmetic.hpp% + include/cppad/core/standard_math.hpp% + include/cppad/core/cond_exp.hpp% + include/cppad/core/discrete.hpp% + include/cppad/core/numeric_limits.hpp% + include/cppad/core/atomic/atomic.omh +%$$ + +$end +*/ + +// 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 +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/arithmetic.hpp cppad-2019.02.00.0/include/cppad/core/arithmetic.hpp --- cppad-2018.00.00.0/include/cppad/core/arithmetic.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/arithmetic.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,42 @@ +# ifndef CPPAD_CORE_ARITHMETIC_HPP +# define CPPAD_CORE_ARITHMETIC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin Arithmetic$$ +$spell + Op + const +$$ + + + +$section AD Arithmetic Operators and Compound Assignments$$ + +$childtable% + include/cppad/core/unary_plus.hpp% + include/cppad/core/unary_minus.hpp% + include/cppad/core/ad_binary.hpp% + include/cppad/core/compound_assign.hpp +%$$ + +$end +------------------------------------------------------------------------------- +*/ +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/asinh.hpp cppad-2019.02.00.0/include/cppad/core/asinh.hpp --- cppad-2018.00.00.0/include/cppad/core/asinh.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/asinh.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,95 @@ +# ifndef CPPAD_CORE_ASINH_HPP +# define CPPAD_CORE_ASINH_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- + +$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/general/asinh.cpp +%$$ +The file +$cref asinh.cpp$$ +contains an example and test of this function. + +$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 +AD asinh(const AD &x) +{ return asinh_template(x); } + +template +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-2018.00.00.0/include/cppad/core/atan2.hpp cppad-2019.02.00.0/include/cppad/core/atan2.hpp --- cppad-2018.00.00.0/include/cppad/core/atan2.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atan2.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,139 @@ +# ifndef CPPAD_CORE_ATAN2_HPP +# define CPPAD_CORE_ATAN2_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin atan2$$ +$spell + Vec + CppAD + namespace + std + atan + const +$$ + + +$section AD Two Argument Inverse Tangent Function$$ + +$head Syntax$$ +$icode%theta% = atan2(%y%, %x%)%$$ + + +$head Purpose$$ +Determines an angle $latex \theta \in [ - \pi , + \pi ]$$ +such that +$latex \[ +\begin{array}{rcl} + \sin ( \theta ) & = & y / \sqrt{ x^2 + y^2 } \\ + \cos ( \theta ) & = & x / \sqrt{ x^2 + y^2 } +\end{array} +\] $$ + +$head y$$ +The argument $icode y$$ has one of the following prototypes +$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 +$codei% + AD<%Base%> %theta% +%$$ + +$head Operation Sequence$$ +The AD of $icode Base$$ +operation sequence used to calculate $icode theta$$ is +$cref/independent/glossary/Operation/Independent/$$ +of $icode x$$ and $icode y$$. + +$head Example$$ +$children% + example/general/atan2.cpp +%$$ +The file +$cref atan2.cpp$$ +contains an example and test of this function. + +$end +------------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN CppAD namespace + +inline float atan2(float x, float y) +{ return std::atan2(x, y); } + +inline double atan2(double x, double y) +{ return std::atan2(x, y); } + +// The code below is used as an example by the CondExp documentation. +// BEGIN CondExp +template +AD atan2 (const AD &y, const AD &x) +{ AD alpha; + AD beta; + AD theta; + + AD zero(0.); + AD pi2(2. * atan(1.)); + AD pi(2. * pi2); + + AD ax = fabs(x); + AD ay = fabs(y); + + // if( ax > ay ) + // 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 = CondExpLe(x, zero, pi - theta, theta); // use of CondExp + + // if( y <= 0 ) + // theta = - theta; + theta = CondExpLe(y, zero, -theta, theta); // use of CondExp + + return theta; +} +// END CondExp + +template +AD atan2 (const VecAD_reference &y, const AD &x) +{ return atan2( y.ADBase() , x ); } + +template +AD atan2 (const AD &y, const VecAD_reference &x) +{ return atan2( y , x.ADBase() ); } + +template +AD atan2 +(const VecAD_reference &y, const VecAD_reference &x) +{ return atan2( y.ADBase() , x.ADBase() ); } + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atanh.hpp cppad-2019.02.00.0/include/cppad/core/atanh.hpp --- cppad-2018.00.00.0/include/cppad/core/atanh.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atanh.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,95 @@ +# ifndef CPPAD_CORE_ATANH_HPP +# define CPPAD_CORE_ATANH_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$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/general/atanh.cpp +%$$ +The file +$cref atanh.cpp$$ +contains an example and test of this function. + +$end +------------------------------------------------------------------------------- +*/ +# include +# if ! CPPAD_USE_CPLUSPLUS_2011 + +// BEGIN CppAD namespace +namespace CppAD { + +template +Type atanh_template(const Type &x) +{ return CppAD::log( (Type(1) + x) / (Type(1) - x) ) / Type(2); +} + +inline float atanh(const float &x) +{ return atanh_template(x); } + +inline double atanh(const double &x) +{ return atanh_template(x); } + +template +AD atanh(const AD &x) +{ return atanh_template(x); } + +template +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-2018.00.00.0/include/cppad/core/atomic/atomic.omh cppad-2019.02.00.0/include/cppad/core/atomic/atomic.omh --- cppad-2018.00.00.0/include/cppad/core/atomic/atomic.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/atomic.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,26 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ +$begin atomic$$ + +$section Atomic AD Functions$$ + +$childtable% + include/cppad/core/atomic/atomic_three.hpp% + include/cppad/core/chkpoint_two/chkpoint_two.hpp +%$$ + +$head Deprecated Atomic Function$$ +$cref atomic_one$$, +$cref atomic_two$$, +$cref chkpoint_one$$. + +$end diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/atomic_one.hpp cppad-2019.02.00.0/include/cppad/core/atomic/atomic_one.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/atomic_one.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/atomic_one.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1058 @@ +# ifndef CPPAD_CORE_ATOMIC_ATOMIC_ONE_HPP +# define CPPAD_CORE_ATOMIC_ATOMIC_ONE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_one$$ +$spell + hes + std + Jacobian + jac + Tvector + afun + vx + vy + bool + namespace + CppAD + const + Taylor + tx + ty + px + py +$$ + +$section Defining Atomic Functions: First Generation$$ + +$head Deprecated 2013-05-27$$ +Using $code CPPAD_USER_ATOMIC$$ has been deprecated. +Use $cref atomic_three$$ instead. + +$head Syntax Function$$ +$codei%CPPAD_USER_ATOMIC(%afun%, %Tvector%, %Base%, + %forward%, %reverse%, %for_jac_sparse%, %rev_jac_sparse%, %rev_hes_sparse% +) +%$$ + +$subhead Use Function$$ +$icode%afun%(%id%, %ax%, %ay%) +%$$ + +$subhead Callback Routines$$ +$icode%ok% = %forward%(%id%, %k%, %n%, %m%, %vx%, %vy%, %tx%, %ty%) +%$$ +$icode%ok% = %reverse%(%id%, %k%, %n%, %m%, %tx%, %ty%, %px%, %py%) +%$$ +$icode%ok% = %for_jac_sparse%(%id%, %n%, %m%, %q%, %r%, %s%) +%$$ +$icode%ok% = %rev_jac_sparse%(%id%, %n%, %m%, %q%, %r%, %s%) +%$$ +$icode%ok% = %rev_hes_sparse%(%id%, %n%, %m%, %q%, %r%, %s%, %t%, %u%, %v%) +%$$ + +$subhead Free Static Memory$$ +$codei%user_atomic<%Base%>::clear()%$$ + +$head Purpose$$ +In some cases, the user knows how to compute the derivative +of a function +$latex \[ + y = f(x) \; {\rm where} \; f : \B{R}^n \rightarrow \B{R}^m +\] $$ +more efficiently than by coding it using $codei%AD<%Base%>%$$ +$cref/atomic_base/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. +$pre + +$$ +Another possible purpose is to reduce the size of the tape. + +$head Partial Implementation$$ +The routines +$cref/forward/atomic_one/forward/$$, +$cref/reverse/atomic_one/reverse/$$, +$cref/for_jac_sparse/atomic_one/for_jac_sparse/$$, +$cref/rev_jac_sparse/atomic_one/rev_jac_sparse/$$, and +$cref/rev_hes_sparse/atomic_one/rev_hes_sparse/$$, +must be defined by the user. +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). +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$$ +The macro +$codei% +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) +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 +$icode afun$$. + +$subhead Base$$ +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 +by this macro to an $codei%AD<%Base>%$$ operation sequence. + +$head ok$$ +For all routines documented below, +the return value $icode ok$$ has prototype +$codei% + bool %ok% +%$$ +If it is $code true$$, the corresponding evaluation succeeded, +otherwise it failed. + +$head id$$ +For all routines documented below, +the argument $icode id$$ has prototype +$codei% + size_t %id% +%$$ +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$$. + +$head k$$ +For all routines documented below, the argument $icode k$$ has prototype +$codei% + size_t %k% +%$$ +The value $icode%k%$$ is the order of the Taylor coefficient that +we are evaluating ($cref/forward/atomic_one/forward/$$) +or taking the derivative of ($cref/reverse/atomic_one/reverse/$$). + +$head n$$ +For all routines documented below, +the argument $icode n$$ has prototype +$codei% + size_t %n% +%$$ +It is the size of the vector $icode ax$$ in the corresponding call to +$icode%afun%(%id%, %ax%, %ay%)%$$; i.e., +the dimension of the domain space for $latex y = f(x)$$. + +$head m$$ +For all routines documented below, the argument $icode m$$ has prototype +$codei% + size_t %m% +%$$ +It is the size of the vector $icode ay$$ in the corresponding call to +$icode%afun%(%id%, %ax%, %ay%)%$$; i.e., +the dimension of the range space for $latex y = f(x)$$. + +$head tx$$ +For all routines documented below, +the argument $icode tx$$ has prototype +$codei% + const CppAD::vector<%Base%>& %tx% +%$$ +and $icode%tx%.size() >= (%k% + 1) * %n%$$. +For $latex j = 0 , \ldots , n-1$$ and $latex \ell = 0 , \ldots , k$$, +we use the Taylor coefficient notation +$latex \[ +\begin{array}{rcl} + x_j^\ell & = & tx [ j * ( k + 1 ) + \ell ] + \\ + X_j (t) & = & x_j^0 + x_j^1 t^1 + \cdots + x_j^k t^k +\end{array} +\] $$ +If $icode%tx%.size() > (%k% + 1) * %n%$$, +the other components of $icode tx$$ are not specified and should not be used. +Note that superscripts represent an index for $latex x_j^\ell$$ +and an exponent for $latex t^\ell$$. +Also note that the Taylor coefficients for $latex X(t)$$ correspond +to the derivatives of $latex X(t)$$ at $latex t = 0$$ in the following way: +$latex \[ + x_j^\ell = \frac{1}{ \ell ! } X_j^{(\ell)} (0) +\] $$ + +$head ty$$ +In calls to $cref/forward/atomic_one/forward/$$, +the argument $icode ty$$ has prototype +$codei% + CppAD::vector<%Base%>& %ty% +%$$ +while in calls to $cref/reverse/atomic_one/reverse/$$ it has prototype +$codei% + const CppAD::vector<%Base%>& %ty% +%$$ +For all calls, $icode%tx%.size() >= (%k% + 1) * %m%$$. +For $latex i = 0 , \ldots , m-1$$ and $latex \ell = 0 , \ldots , k$$, +we use the Taylor coefficient notation +$latex \[ +\begin{array}{rcl} + y_i^\ell & = & ty [ i * ( k + 1 ) + \ell ] + \\ + Y_i (t) & = & y_i^0 + y_i^1 t^1 + \cdots + y_i^k t^k + o ( t^k ) +\end{array} +\] $$ +where $latex o( t^k ) / t^k \rightarrow 0$$ as $latex t \rightarrow 0$$. +If $icode%ty%.size() > (%k% + 1) * %m%$$, +the other components of $icode ty$$ are not specified and should not be used. +Note that superscripts represent an index for $latex y_j^\ell$$ +and an exponent for $latex t^\ell$$. +Also note that the Taylor coefficients for $latex Y(t)$$ correspond +to the derivatives of $latex Y(t)$$ at $latex t = 0$$ in the following way: +$latex \[ + y_j^\ell = \frac{1}{ \ell ! } Y_j^{(\ell)} (0) +\] $$ + +$subhead forward$$ +In the case of $icode forward$$, +for $latex i = 0 , \ldots , m-1$$, $latex ty[ i *( k + 1) + k ]$$ is an output +and all the other components of $icode ty$$ are inputs. + +$subhead reverse$$ +In the case of $icode reverse$$, +all the components of $icode ty$$ are inputs. + +$head afun$$ +The macro argument $icode afun$$, +is the name of the AD function corresponding to this atomic +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 +$codei% + %afun%(%id%, %ax%, %ay%) +%$$ +where the argument are vectors with elements of type $codei%AD<%Base%>%$$. + +$subhead ax$$ +The $icode afun$$ argument $icode ax$$ has prototype +$codei% + const %Tvector%< AD<%Base%> >& %ax% +%$$ +It is the argument vector $latex x \in \B{R}^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/atomic_one/n/$$ $codei%= %ax%.size()%$$, +which must be greater than zero. + +$subhead ay$$ +The $icode afun$$ result $icode ay$$ has prototype +$codei% + %Tvector%< AD<%Base%> >& %ay% +%$$ +The input values of its elements +are not specified (must not matter). +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/atomic_one/m/$$ $codei%= %ay%.size()%$$, +which must be greater than zero. + +$subhead Parallel Mode$$ +The first call to +$codei% + %afun%(%id%, %ax%, %ay%) +%$$ +must not be in $cref/parallel/ta_in_parallel/$$ mode. +In addition, the +$cref/atomic_one clear/atomic_one/clear/$$ +routine cannot be called while in parallel mode. + +$head forward$$ +The macro argument $icode forward$$ is a +user defined function +$codei% + %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$$ +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 +$icode k$$ order Taylor coefficients for $latex y$$ using the definition +$latex Y(t) = f[ X(t) ]$$. +For example, for $latex i = 0 , \ldots , m-1$$, +$latex \[ +\begin{array}{rcl} +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^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 + + f_i^{(1)} ( x^0 ) x^2 +\end{array} +\] $$ +Then, for $latex i = 0 , \ldots , m-1$$, it sets +$latex \[ + ty [ i * (k + 1) + k ] = y_i^k +\] $$ +The other components of $icode ty$$ must be left unchanged. + +$subhead Usage$$ +This routine is used, +with $icode%vx%.size() > 0%$$ and $icode%k% == 0%$$, +by calls to $icode afun$$. +It is used, +with $icode%vx%.size() = 0%$$ and +$icode k$$ equal to the order of the derivative begin computed, +by calls to $cref/forward/forward_order/$$. + +$subhead vx$$ +The $icode forward$$ argument $icode vx$$ has prototype +$codei% + const CppAD::vector& %vx% +%$$ +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 +the corresponding $icode id$$ +(such as the elements of $icode vx$$). +If $icode%vx%.size() > 0%$$ then +$icode%k% == 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/$$. +$pre + +$$ +If $icode%vx%.size() == 0%$$, +then $icode%vy%.size() == 0%$$ and neither of these vectors +should be used. + +$subhead vy$$ +The $icode forward$$ argument $icode vy$$ has prototype +$codei% + CppAD::vector& %vy% +%$$ +If $icode%vy%.size() == 0%$$, it should not be used. +Otherwise, +$icode%k% == 0%$$ and $icode%vy%.size() >= %m%$$. +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 +$icode%ay%[%j%]%$$ is a variable. +(CppAD uses $icode vy$$ to reduce the necessary computations.) + +$head reverse$$ +The macro argument $icode reverse$$ +is a user defined function +$codei% + %ok% = %reverse%(%id%, %k%, %n%, %m%, %tx%, %ty%, %px%, %py%) +%$$ +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. +We use the $latex \{ x_j^\ell \}$$ and $latex \{ y_i^\ell \}$$ +to denote these Taylor coefficients where the implicit range indices are +$latex i = 0 , \ldots , m-1$$, +$latex j = 0 , \ldots , n-1$$, +$latex \ell = 0 , \ldots , k$$. +Using the calculations done by $cref/forward/atomic_one/forward/$$, +the Taylor coefficients $latex \{ y_i^\ell \}$$ are a function of the Taylor +coefficients for $latex \{ x_j^\ell \}$$; i.e., given $latex y = f(x)$$ +we define the function +$latex F : \B{R}^{n \times (k+1)} \rightarrow \B{R}^{m \times (k+1)}$$ by +$latex \[ +y_i^\ell = F_i^\ell ( \{ x_j^\ell \} ) +\] $$ +We use $latex G : \B{R}^{m \times (k+1)} \rightarrow \B{R}$$ +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 +$latex \{ y_i^\ell \}$$ and computes its derivative with respect +to $latex \{ x_j^\ell \}$$. + +$subhead Usage$$ +This routine is used, +with $icode%k% + 1%$$ equal to the order of the derivative being calculated, +by calls to $cref/reverse/reverse_any/$$. + +$subhead py$$ +The $icode reverse$$ argument $icode py$$ has prototype +$codei% + const CppAD::vector<%Base%>& %py% +%$$ +and $icode%py%.size() >= (%k% + 1) * %m%$$. +For $latex i = 0 , \ldots , m-1$$ and $latex \ell = 0 , \ldots , k$$, +$latex \[ + py[ i * (k + 1 ) + \ell ] = \partial G / \partial y_i^\ell +\] $$ +If $icode%py%.size() > (%k% + 1) * %m%$$, +the other components of $icode py$$ are not specified and should not be used. + +$subhead px$$ +We define the function +$latex \[ +H ( \{ x_j^\ell \} ) = G[ F( \{ x_j^\ell \} ) ] +\] $$ +The $icode reverse$$ argument $icode px$$ has prototype +$codei% + CppAD::vector<%Base%>& %px% +%$$ +and $icode%px%.size() >= (%k% + 1) * %n%$$. +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$$, +$latex \[ +\begin{array}{rcl} +px [ j * (k + 1) + p ] & = & \partial H / \partial x_j^p +\\ +& = & +( \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} +\] $$ +Note that we have used the fact that for $latex \ell < p$$, +$latex \partial F_i^\ell / \partial x_j^p = 0$$. +If $icode%px%.size() > (%k% + 1) * %n%$$, +the other components of $icode px$$ are not specified and should not be used. + +$head for_jac_sparse$$ +The macro argument $icode for_jac_sparse$$ +is a user defined function +$codei% + %ok% = %for_jac_sparse%(%id%, %n%, %m%, %q%, %r%, %s%) +%$$ +that is used to compute results during a forward Jacobian sparsity sweep. +For a fixed $latex n \times q$$ matrix $latex R$$, +the Jacobian of $latex f( x + R * u)$$ with respect to $latex u \in \B{R}^q$$ is +$latex \[ + S(x) = f^{(1)} (x) * R +\] $$ +Given a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for $latex R$$, +$icode for_jac_sparse$$ computes a sparsity pattern for $latex S(x)$$. + +$subhead Usage$$ +This routine is used by calls to $cref ForSparseJac$$. + +$subhead q$$ +The $icode for_jac_sparse$$ argument $icode q$$ has prototype +$codei% + size_t %q% +%$$ +It specifies the number of columns in +$latex R \in \B{R}^{n \times q}$$ and the Jacobian +$latex S(x) \in \B{R}^{m \times q}$$. + +$subhead r$$ +The $icode for_jac_sparse$$ argument $icode r$$ has prototype +$codei% + const CppAD::vector< std::set >& %r% +%$$ +and $icode%r%.size() >= %n%$$. +For $latex j = 0 , \ldots , n-1$$, +all the elements of $icode%r%[%j%]%$$ are between +zero and $icode%q%-1%$$ inclusive. +This specifies a sparsity pattern for the matrix $latex R$$. + +$subhead s$$ +The $icode for_jac_sparse$$ return value $icode s$$ has prototype +$codei% + CppAD::vector< std::set >& %s% +%$$ +and $icode%s%.size() >= %m%%$$. +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. +This represents a sparsity pattern for the matrix $latex S(x)$$. + +$head rev_jac_sparse$$ +The macro argument $icode rev_jac_sparse$$ +is a user defined function +$codei% + %ok% = %rev_jac_sparse%(%id%, %n%, %m%, %q%, %r%, %s%) +%$$ +that is used to compute results during a reverse Jacobian sparsity sweep. +For a fixed $latex q \times m$$ matrix $latex S$$, +the Jacobian of $latex S * f( x )$$ with respect to $latex x \in \B{R}^n$$ is +$latex \[ + R(x) = S * f^{(1)} (x) +\] $$ +Given a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for $latex S$$, +$icode rev_jac_sparse$$ computes a sparsity pattern for $latex R(x)$$. + +$subhead Usage$$ +This routine is used by calls to $cref RevSparseJac$$ +and to $cref optimize$$. + + +$subhead q$$ +The $icode rev_jac_sparse$$ argument $icode q$$ has prototype +$codei% + size_t %q% +%$$ +It specifies the number of rows in +$latex S \in \B{R}^{q \times m}$$ and the Jacobian +$latex R(x) \in \B{R}^{q \times n}$$. + +$subhead s$$ +The $icode rev_jac_sparse$$ argument $icode s$$ has prototype +$codei% + const CppAD::vector< std::set >& %s% +%$$ +and $icode%s%.size() >= %m%$$. +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}$$. + +$subhead r$$ +The $icode rev_jac_sparse$$ return value $icode r$$ has prototype +$codei% + CppAD::vector< std::set >& %r% +%$$ +and $icode%r%.size() >= %n%$$. +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%]%$$ +are between zero and $icode%q%-1%$$ inclusive. +This represents a sparsity pattern for the matrix $latex R(x)^\R{T}$$. + +$head rev_hes_sparse$$ +The macro argument $icode rev_hes_sparse$$ +is a user defined function +$codei% + %ok% = %rev_hes_sparse%(%id%, %n%, %m%, %q%, %r%, %s%, %t%, %u%, %v%) +%$$ +There is an unspecified scalar valued function +$latex g : \B{R}^m \rightarrow \B{R}$$. +Given a sparsity pattern for $latex R$$ +and information about the function $latex z = g(y)$$, +this routine computes the sparsity pattern for +$latex \[ + V(x) = (g \circ f)^{(2)}( x ) R +\] $$ + +$subhead Usage$$ +This routine is used by calls to $cref RevSparseHes$$. + +$subhead q$$ +The $icode rev_hes_sparse$$ argument $icode q$$ has prototype +$codei% + size_t %q% +%$$ +It specifies the number of columns in the sparsity patterns. + +$subhead r$$ +The $icode rev_hes_sparse$$ argument $icode r$$ has prototype +$codei% + const CppAD::vector< std::set >& %r% +%$$ +and $icode%r%.size() >= %n%$$. +For $latex j = 0 , \ldots , n-1$$, +all the elements of $icode%r%[%j%]%$$ are between +zero and $icode%q%-1%$$ inclusive. +This specifies a sparsity pattern for the matrix $latex R \in \B{R}^{n \times q}$$. + +$subhead s$$ +The $icode rev_hes_sparse$$ argument $icode s$$ has prototype +$codei% + const CppAD::vector& %s% +%$$ +and $icode%s%.size() >= %m%$$. +This specifies a sparsity pattern for the matrix +$latex S(x) = g^{(1)} (y) \in \B{R}^{1 \times m}$$. + +$subhead t$$ +The $icode rev_hes_sparse$$ argument $icode t$$ has prototype +$codei% + CppAD::vector& %t% +%$$ +and $icode%t%.size() >= %n%$$. +The input values of its elements +are not specified (must not matter). +Upon return it represents a sparsity pattern for the matrix +$latex T(x) \in \B{R}^{1 \times n}$$ defined by +$latex \[ +T(x) = (g \circ f)^{(1)} (x) = S(x) * f^{(1)} (x) +\] $$ + +$subhead u$$ +The $icode rev_hes_sparse$$ argument $icode u$$ has prototype +$codei% + const CppAD::vector< std::set >& %u% +%$$ +and $icode%u%.size() >= %m%$$. +For $latex i = 0 , \ldots , m-1$$, +all the elements of $icode%u%[%i%]%$$ +are between zero and $icode%q%-1%$$ inclusive. +This specifies a sparsity pattern +for the matrix $latex U(x) \in \B{R}^{m \times q}$$ 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} +\\ +& = & +g^{(2)} (y) f^{(1)} (x) R +\end{array} +\] $$ + +$subhead v$$ +The $icode rev_hes_sparse$$ argument $icode v$$ has prototype +$codei% + CppAD::vector< std::set >& %v% +%$$ +and $icode%v%.size() >= %n%$$. +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 +$latex V(x) \in \B{R}^{n \times q}$$ defined by +$latex \[ +\begin{array}{rcl} +V(x) +& = & +\partial_u [ \partial_x (g \circ f) ( x + R u ) ]_{u=0} +\\ +& = & +\partial_u [ (g \circ f)^{(1)}( x + R u ) ]_{u=0} +\\ +& = & +(g \circ f)^{(2)}( x ) R +\\ +& = & +f^{(1)} (x)^\R{T} g^{(2)} ( y ) f^{(1)} (x) R ++ +\sum_{i=1}^m [ g^{(1)} (y) ]_i \; f_i^{(2)} (x) R +\\ +& = & +f^{(1)} (x)^\R{T} U(x) ++ +\sum_{i=1}^m S(x)_i \; f_i^{(2)} (x) R +\end{array} +\] $$ + +$head clear$$ +User atomic functions hold onto static work space in order to +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 +atomic functions for a specific value of $icode Base$$. + +$subhead Restriction$$ +The atomic function $code clear$$ routine cannot be called +while in $cref/parallel/ta_in_parallel/$$ execution mode. + +$end +------------------------------------------------------------------------------ +*/ +# include +# include + +// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic_one.hpp +user defined atomic operations. +*/ + +/*! +\def CPPAD_USER_ATOMIC(afun, Tvector, + forward, reverse, for_jac_sparse, rev_jac_sparse, rev_hes_sparse +) +Defines the function afun(id, ax, ay) +where id is ax and ay are vectors with AD elements. + +\par Tvector +the Simple Vector template class for this function. + +\par Base +the base type for the atomic operation. + +\par afun +name of the CppAD defined function that corresponding to this operation. +Note that afun, preceeded by a pound sign, +is a version of afun with quotes arround it. + +\par forward +name of the user defined function that computes corresponding +results during forward mode. + +\par reverse +name of the user defined function that computes corresponding +results during reverse mode. + +\par for_jac_sparse +name of the user defined routine that computes corresponding +results during forward mode jacobian sparsity sweeps. + +\par rev_jac_sparse +name of the user defined routine that computes corresponding +results during reverse mode jacobian sparsity sweeps. + +\par rev_hes_sparse +name of the user defined routine that computes corresponding +results during reverse mode Hessian sparsity sweeps. + +\par memory allocation +Note that atomic_one is used as a static object, so its objects +do note get deallocated until the program terminates. +*/ +# define CPPAD_USER_ATOMIC( \ + afun , \ + Tvector , \ + Base , \ + forward , \ + reverse , \ + for_jac_sparse , \ + rev_jac_sparse , \ + rev_hes_sparse \ +) \ +inline void afun ( \ + size_t id , \ + const Tvector< CppAD::AD >& ax , \ + Tvector< CppAD::AD >& ay \ +) \ +{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; \ + static CppAD::atomic_one fun( \ + #afun , \ + forward , \ + reverse , \ + for_jac_sparse , \ + rev_jac_sparse , \ + rev_hes_sparse \ + ); \ + fun(id, ax, ay); \ +} + +/// link so that user_atomic::clear() still works +template class user_atomic : public atomic_base { +}; + +/*! +Class that actually implements the afun(id, ax, ay) calls. + +A new atomic_one object is generated each time the user invokes +the CPPAD_USER_ATOMIC macro; see static object in that macro. +*/ +template +class atomic_one : public atomic_base { +public: + /// disable atomic_one::clear(void) + static void clear(void) + { CPPAD_ASSERT_KNOWN( + false, + "Depreacted API uses user_atomic::clear()" + ); + } + /// type for user routine that computes forward mode results + typedef bool (*F) ( + size_t id , + size_t k , + size_t n , + size_t m , + const vector& vx , + vector& vy , + 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 , + const vector& ty , + vector& px , + const vector& py + ); + /// type for user routine that computes forward mode Jacobian sparsity + typedef bool (*FJS) ( + size_t id , + size_t n , + size_t m , + size_t q , + const vector< std::set >& r , + vector< std::set >& s + ); + /// type for user routine that computes reverse mode Jacobian sparsity + typedef bool (*RJS) ( + size_t id , + size_t n , + size_t m , + size_t q , + vector< std::set >& r , + const vector< std::set >& s + ); + /// type for user routine that computes reverse mode Hessian sparsity + typedef bool (*RHS) ( + size_t id , + size_t n , + size_t m , + size_t q , + const vector< std::set >& r , + const vector& s , + vector& t , + const vector< std::set >& u , + vector< std::set >& v + ); +private: + /// id value corresponding to next virtual callback + size_t id_; + /// user's implementation of forward mode + const F f_; + /// user's implementation of reverse mode + const R r_; + /// user's implementation of forward jacobian sparsity calculations + const FJS fjs_; + /// user's implementation of reverse jacobian sparsity calculations + const RJS rjs_; + /// user's implementation of reverse Hessian sparsity calculations + const RHS rhs_; + +public: + /*! + 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_. + + \param afun + is the user's name for the AD version of this atomic operation. + + \param f + user routine that does forward mode calculations for this operation. + + \param r + user routine that does reverse mode calculations for this operation. + + \param fjs + user routine that does forward Jacobian sparsity calculations. + + \param rjs + user routine that does reverse Jacobian sparsity calculations. + + \param rhs + user routine that does reverse Hessian sparsity calculations. + + \par + This constructor can not be used in parallel mode because + atomic_base has this restriction. + */ + atomic_one(const char* afun, F f, R r, FJS fjs, RJS rjs, RHS rhs) : + atomic_base(afun) // name = afun + , f_(f) + , r_(r) + , fjs_(fjs) + , rjs_(rjs) + , rhs_(rhs) + { this->option( atomic_base::set_sparsity_enum ); + } + /*! + Implement the user call to afun(id, ax, ay). + + \tparam ADVector + A simple vector class with elements of type AD. + + \param id + extra information vector that is just passed through by CppAD, + and possibly used by user's routines. + + \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. + */ + template + void operator()(size_t id, const ADVector& ax, ADVector& ay) + { // call atomic_base function object + this->atomic_base::operator()(ax, ay, id); + return; + } + /*! + Store id for next virtual function callback + + \param id + id value corresponding to next virtual callback + */ + virtual void set_old(size_t id) + { id_ = id; } + /*! + Link from atomic_one to forward mode + + \copydetails atomic_base::forward + */ + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty ) + { 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); + size_t i, j, k, ell; + + vector x(n * (q+1)); + vector y(m * (q+1)); + vector empty; + + // atomic_one interface can only handel one order at a time + // so must just throuh hoops to get multiple orders at one time. + bool ok = true; + for(k = p; k <= q; k++) + { for(j = 0; j < n; j++) + for(ell = 0; ell <= k; ell++) + x[ j * (k+1) + ell ] = tx[ j * (q+1) + ell ]; + for(i = 0; i < m; i++) + for(ell = 0; ell < k; ell++) + y[ i * (k+1) + ell ] = ty[ i * (q+1) + ell ]; + if( k == 0 ) + ok &= f_(id_, k, n, m, vx, vy, x, y); + else + ok &= f_(id_, k, n, m, empty, empty, x, y); + for(i = 0; i < m; i++) + ty[ i * (q+1) + k ] = y[ i * (k+1) + k]; + } + return ok; + } + /*! + Link from atomic_one to reverse mode + + \copydetails atomic_base::reverse + */ + virtual bool reverse( + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py ) + { 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 = r_(id_, q, n, m, tx, ty, px, py); + return ok; + } + /*! + Link from forward Jacobian sparsity sweep to atomic_one + + \copydetails atomic_base::for_sparse_jac + */ + virtual bool for_sparse_jac( + size_t q , + const vector< std::set >& r , + vector< std::set >& s , + const vector& x ) + { size_t n = r.size(); + size_t m = s.size(); + bool ok = fjs_(id_, n, m, q, r, s); + return ok; + } + + /*! + Link from reverse Jacobian sparsity sweep to atomic_one. + + \copydetails atomic_base::rev_sparse_jac + */ + virtual bool rev_sparse_jac( + size_t q , + const vector< std::set >& rt , + vector< std::set >& st , + const vector& x ) + { size_t n = st.size(); + size_t m = rt.size(); + bool ok = rjs_(id_, n, m, q, st, rt); + return ok; + } + /*! + Link from reverse Hessian sparsity sweep to atomic_one + + \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 , + const vector& x ) + { size_t m = u.size(); + size_t n = v.size(); + CPPAD_ASSERT_UNKNOWN( r.size() == n ); + CPPAD_ASSERT_UNKNOWN( s.size() == m ); + CPPAD_ASSERT_UNKNOWN( t.size() == n ); + // + // old interface used id instead of vx + bool ok = rhs_(id_, n, m, q, r, s, t, u, v); + return ok; + } +}; + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/atomic_three.hpp cppad-2019.02.00.0/include/cppad/core/atomic/atomic_three.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/atomic_three.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/atomic_three.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,471 @@ +# ifndef CPPAD_CORE_ATOMIC_ATOMIC_THREE_HPP +# define CPPAD_CORE_ATOMIC_ATOMIC_THREE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three$$ +$spell + taylor + ctor + afun + arg + jac + hes + CppAD + enum + mul + hpp + const +$$ + +$section Defining Atomic Functions: Third Generation$$ + +$head Syntax$$ + +$subhead Atomic Constructor$$ +$icode%atomic_derived% %afun%(%ctor_arg_list%)%$$ + +$subhead Use Atomic Function$$ +$icode%afun%(%ax%, %ay%)%$$ + +$subhead Callback Functions$$ +$icode%ok% = %afun%.for_type( + %parameter_x%, %type_x%, %type_y% +) +%ok% = %afun%.forward( + %parameter_x%, %type_x%, + %need_y%, %order_low%, %order_up%, %taylor_x%, %taylor_y% +) +%ok% = %afun%.reverse( + %parameter_x%, %type_x%, + %order_up%, %taylor_x%, %taylor_y%, %partial_x%, %partial_y% +) +%ok% = %afun%.jac_sparsity( + %parameter_x%, %type_x%, %dependency%, %select_x% %select_y%, %pattern_out% +) +%ok% = %afun%.hes_sparsity( + %parameter_x%, %type_x%, %select_x% %select_y%, %pattern_out% +) +%ok% = %afun%.rev_depend( + %parameter_x%, %type_x%, %depend_x%, %depend_y% +)%$$ + +$head See Also$$ +$cref chkpoint_two$$, $cref atomic_two$$ + +$head Purpose$$ + +$subhead Speed$$ +In some cases, it is possible to compute derivatives of a function +$latex \[ + y = g(x) \; {\rm where} \; g : \B{R}^n \rightarrow \B{R}^m +\] $$ +more efficiently than by coding it using $codei%AD<%Base%>%$$ +$cref/atomic/glossary/Operation/Atomic/$$ operations +and letting CppAD do the rest. +The class $codei%atomic_three%<%Base%>%$$ is used to +create a new atomic operation corresponding to a function $latex g(x)$$ +where the user specifies how to compute the derivatives +and sparsity patterns for $latex g(x)$$. + +$subhead Reduce Memory$$ +If the function $latex g(x)$$ is many times during the recording +of an $cref ADFun$$ object, +using an atomic version of $latex g(x)$$ removed the need for repeated +copies of the corresponding $codei%AD<%Base%>%$$ operations and variables +in the recording. + +$head ad_type$$ +The type $code CppAD::ad_type_enum$$ +is used to specify if an AD object is a +$cref/constant parameter/glossary/Parameter/Constant/$$ +$cref/dynamic parameter/glossary/Parameter/Dynamic/$$ +or $cref/variable/glossary/Variable/$$. +It has the following possible values: +$center +$table +$icode ad_type_enum$$ $pre $$ $cnext Meaning $rnext +$code constant_enum$$ $pre $$ $cnext constant parameter $rnext +$code dynamic_enum$$ $pre $$ $cnext dynamic parameter $rnext +$code variable_enum$$ $pre $$ $cnext variable +$tend +$$ +In addition, +$code constant_enum < dynamic_enum < variable_enum$$. + +$head Virtual Functions$$ +The $cref/callback functions/atomic_three/Syntax/Callback Functions/$$ +are implemented by defining the virtual functions in the +$icode atomic_derived$$ class. +These functions compute derivatives, +sparsity patterns, and dependency relations. +Each virtual function has a default implementation +that returns $icode%ok% == false%$$. +The $cref/for_type/atomic_three_for_type/$$ +and $cref/forward/atomic_three_forward/$$ function +(for the case $icode%order_up% == 0%$$) must be implemented. +Otherwise, only those functions and orders +required by the your calculations need to be implemented. +For example, +$icode forward$$ for the case $icode%order_up% == 2%$$ can just return +$icode%ok% == false%$$ unless you require +forward mode calculation of second derivatives. + +$head Base$$ +This is the type of the elements of +$cref/ax/atomic_three_afun/ax/$$ and $cref/ay/atomic_three_afun/ay/$$ +in the corresponding $icode%afun%(%ax%, %ay%)%$$ call. + +$head parameter_x$$ +All the virtual functions include this argument which has prototype +$codei% + const CppAD::vector<%Base%> %parameter_x% +%$$ +Its size is equal to $icode%n% = %ax%.size()%$$ +in corresponding $icode%afun%(%ax%, %ay%)%$$ call. +For $icode%j% =0,%...%,%n%-1%$$, +if $icode%ax%[%j%]%$$ is a parameter, +$codei% + %parameter_x%[%j%] == %ax%[%j%] +%$$ +If $icode%ax%[%j%]%$$ is a variable, +the value of $icode%parameter_x%[%j%]%$$ is not specified. +See the +$cref/atomic_mat_mul.hpp/atomic_mat_mul.hpp/Purpose/parameter_x/$$ +for an example using $icode parameter_x$$. + +$head type_x$$ +All the virtual functions include this argument. +Its size is equal to $icode%n% = %ax%.size()%$$ +in corresponding $icode%afun%(%ax%, %ay%)%$$ call. +For $icode%j% =0,%...%,%n%-1%$$, +if $icode%ax%[%j%]%$$ is a constant parameter, +$codei% + %type_x%[%j%] == CppAD::constant_enum +%$$ +if $icode%ax%[%j%]%$$ is a dynamic parameter, +$codei% + %type_x%[%j%] == CppAD::dynamic_enum +%$$ +if $icode%ax%[%j%]%$$ is a variable, +$codei% + %type_x%[%j%] == CppAD::variable_enum +%$$ +See the +$cref/atomic_mat_mul.hpp/atomic_mat_mul.hpp/Purpose/type_x/$$ +for an example using $icode type_x$$. + + +$childtable%include/cppad/core/atomic/three_ctor.hpp + %include/cppad/core/atomic/three_afun.hpp + %include/cppad/core/atomic/three_for_type.hpp + %include/cppad/core/atomic/three_forward.hpp + %include/cppad/core/atomic/three_reverse.hpp + %include/cppad/core/atomic/three_jac_sparsity.hpp + %include/cppad/core/atomic/three_hes_sparsity.hpp + %include/cppad/core/atomic/three_rev_depend.hpp +%$$ + +$end +------------------------------------------------------------------------------- +$begin atomic_three_example$$ + +$section Example Defining Atomic Functions: Third Generation$$ + +$childtable%example/atomic_three/get_started.cpp + %example/atomic_three/norm_sq.cpp + %example/atomic_three/tangent.cpp + %example/atomic_three/base2ad.cpp + %example/atomic_three/reciprocal.cpp + %example/atomic_three/mat_mul.cpp +%$$ + +$end +------------------------------------------------------------------------------- +*/ + +# include +# include +# include + +// needed before one can use in_parallel +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic_three.hpp +Base class for atomic function operations. +*/ + +template +class atomic_three { +// =================================================================== +private: + // ------------------------------------------------------ + // constants + // + /// index of this object in lcal::atomic_index + /// (set by constructor and not changed; i.e., effectively const) + size_t index_; + // + // ----------------------------------------------------- + // + /// temporary work space used by member functions, declared here to avoid + // memory allocation/deallocation for each usage + struct work_struct { + vector type_x; + vector type_y; + // + vector taylor_x; + vector taylor_y; + // + vector< AD > ataylor_x; + vector< AD > ataylor_y; + // + sparse_rc< vector > pattern; + }; + // Use pointers, to avoid false sharing between threads. + // Not using: vector work_; + // so that deprecated atomic examples do not result in a memory leak. + work_struct* work_[CPPAD_MAX_NUM_THREADS]; + // ----------------------------------------------------- +public: + // ===================================================================== + // In User API + // ===================================================================== + // + // --------------------------------------------------------------------- + // ctor: doxygen in atomic/three_ctor.hpp + atomic_three(void); + atomic_three(const std::string& name); + + // ------------------------------------------------------------------------ + // operator(): see doxygen in atomic_three/afun.hpp + template + void operator()( + const ADVector& ax , + ADVector& ay + ); + // ------------------------------------------------------------------------ + // type: doxygen in atomic/three_for_type.hpp + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y + ); + // ------------------------------------------------------------------------ + // type: doxygen in atomic/three_rev_depend.hpp + virtual bool rev_depend( + const vector& parameter_x , + const vector& type_x , + vector& depend_x , + const vector& depend_y + ); + // ------------------------------------------------------------------------ + // forward: see docygen in atomic/three_forward.hpp + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector& taylor_x , + vector& taylor_y + ); + virtual bool forward( + const vector< AD >& aparameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector< AD >& ataylor_x , + vector< AD >& ataylor_y + ); + // ------------------------------------------------------------------------ + // reverse: see docygen in atomic/three_reverse.hpp + virtual bool reverse( + const vector& parameter_x , + const vector& type_x , + size_t order_up , + const vector& taylor_x , + const vector& taylor_y , + vector& partial_x , + const vector& partial_y + ); + virtual bool reverse( + const vector< AD >& aparameter_x , + const vector& type_x , + size_t order_up , + const vector< AD >& ataylor_x , + const vector< AD >& ataylor_y , + vector< AD >& apartial_x , + const vector< AD >& apartial_y + ); + // ------------------------------------------------------------ + // jac_sparsity: see doxygen in atomic/three_jac_sparsity.hpp + virtual bool jac_sparsity( + const vector& parameter_x , + const vector& type_x , + bool dependency , + const vector& select_x , + const vector& select_y , + sparse_rc< vector >& pattern_out + ); + template + bool for_jac_sparsity( + bool dependency , + const vector& parameter_x , + const vector& type_x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + InternalSparsity& var_sparsity + ); + template + bool rev_jac_sparsity( + bool dependency , + const vector& parameter_x , + const vector& type_x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + InternalSparsity& var_sparsity + ); + // ------------------------------------------------------------ + // hes_sparsity: see doxygen in atomic/three_jac_sparsity.hpp + virtual bool hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const vector& select_x , + const vector& select_y , + sparse_rc< vector >& pattern_out + ); + template + bool for_hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + const InternalSparsity& for_jac_sparsity , + const InternalSparsity& rev_jac_sparsity , + InternalSparsity& hes_sparsity + ); + template + bool rev_hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + const InternalSparsity& for_jac_sparsity , + bool* rev_jac_flag , + InternalSparsity& hes_sparsity + ); + + // ===================================================================== + // Not in User API + // ===================================================================== + + /// Name corresponding to a atomic_three object + const std::string afun_name(void) const + { bool set_null = false; + size_t type = 0; // set to avoid warning + std::string name; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, index_, type, &name, v_ptr); + CPPAD_ASSERT_UNKNOWN( type == 3 ); + return name; + } + /// destructor informs CppAD that this atomic function with this index + /// has dropped out of scope by setting its pointer to null + virtual ~atomic_three(void) + { // change object pointer to null, but leave name for error reporting + bool set_null = true; + size_t type = 0; // set to avoid warning + std::string* name = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, index_, type, name, v_ptr); + CPPAD_ASSERT_UNKNOWN( type == 3 ); + // + // free temporary work memory + for(size_t thread = 0; thread < CPPAD_MAX_NUM_THREADS; thread++) + free_work(thread); + } + /// allocates work_ for a specified thread + void allocate_work(size_t thread) + { if( work_[thread] == CPPAD_NULL ) + { // allocate the raw memory + size_t min_bytes = sizeof(work_struct); + size_t num_bytes; + void* v_ptr = thread_alloc::get_memory(min_bytes, num_bytes); + // save in work_ + work_[thread] = reinterpret_cast( v_ptr ); + // call constructor + new( work_[thread] ) work_struct; + } + return; + } + /// frees work_ for a specified thread + void free_work(size_t thread) + { if( work_[thread] != CPPAD_NULL ) + { // call destructor + work_[thread]->~work_struct(); + // return memory to avialable pool for this thread + thread_alloc::return_memory( + reinterpret_cast(work_[thread]) + ); + // mark this thread as not allocated + work_[thread] = CPPAD_NULL; + } + return; + } + /// atomic_three function object corresponding to a certain index + static atomic_three* class_object(size_t index) + { bool set_null = false; + size_t type = 0; // set to avoid warning + std::string* name = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, index, type, name, v_ptr); + CPPAD_ASSERT_UNKNOWN( type == 3 ); + return reinterpret_cast( v_ptr ); + } + /// atomic_three function name corresponding to a certain index + static const std::string class_name(size_t index) + { bool set_null = false; + size_t type = 0; // set to avoid warning + std::string name; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, index, type, &name, v_ptr); + CPPAD_ASSERT_UNKNOWN( type == 3 ); + return name; + } + + /*! + Set value of id (used by deprecated atomic_one class) + + This function is called just before calling any of the virtual function + and has the corresponding id of the corresponding virtual call. + */ + virtual void set_old(size_t id) + { } +// --------------------------------------------------------------------------- +}; +} // END_CPPAD_NAMESPACE + +// member functions +# include +# include +# include +# include +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/atomic_two.hpp cppad-2019.02.00.0/include/cppad/core/atomic/atomic_two.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/atomic_two.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/atomic_two.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,612 @@ +# ifndef CPPAD_CORE_ATOMIC_ATOMIC_TWO_HPP +# define CPPAD_CORE_ATOMIC_ATOMIC_TWO_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two$$ +$spell + ctor + afun + arg + vx + vy + tx + ty + px + py + jac + hes + CppAD + checkpointing +$$ + +$section Defining Atomic Functions: Second Generation$$ + +$head Deprecated 2019-01-01$$ +Using the $code atomic_base$$ class has been deprecated. +Use $cref atomic_three$$ instead. + + +$head Syntax$$ + +$codei% +%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%) +%ok% = %afun%.for_sparse_jac(%q%, %r%, %s%, %x%) +%ok% = %afun%.rev_sparse_jac(%q%, %r%, %s%, %x%) +%ok% = %afun%.for_sparse_hes(%vx%, %r%, %s%, %h%, %x%) +%ok% = %afun%.rev_sparse_hes(%vx%, %s%, %t%, %q%, %r%, %u%, %v%, %x%) +atomic_base<%Base%>::clear()%$$ + +$head See Also$$ +$cref/checkpoint/chkpoint_one/$$ + +$head Purpose$$ + +$subhead Speed$$ +In some cases, the user knows how to compute derivatives of a function +$latex \[ + y = f(x) \; {\rm where} \; f : \B{R}^n \rightarrow \B{R}^m +\] $$ +more efficiently than by coding it using $codei%AD<%Base%>%$$ +$cref/atomic_base/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. + +$subhead Reduce Memory$$ +If the function $latex f(x)$$ is used often, +using an atomic version of $latex f(x)$$ remove the need for repeated +copies of the corresponding $codei%AD<%Base%>%$$ operations. + +$head Virtual Functions$$ +User defined derivatives are implemented by defining the +following virtual functions in the $icode atomic_base$$ class: +$cref/forward/atomic_two_forward/$$, +$cref/reverse/atomic_two_reverse/$$, +$cref/for_sparse_jac/atomic_two_for_sparse_jac/$$, +$cref/rev_sparse_jac/atomic_two_rev_sparse_jac/$$, and +$cref/rev_sparse_hes/atomic_two_rev_sparse_hes/$$. +These virtual functions have a default implementation +that returns $icode%ok% == false%$$. +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, +$icode forward$$ for the case $icode%q% == 2%$$ can just return +$icode%ok% == false%$$ unless you require +forward mode calculation of second derivatives. + +$head Examples$$ +See $cref atomic_two_example$$. + +$childtable% + include/cppad/core/atomic/two_ctor.hpp% + include/cppad/core/atomic/two_option.hpp% + include/cppad/core/atomic/two_afun.hpp% + include/cppad/core/atomic/two_forward.hpp% + include/cppad/core/atomic/two_reverse.hpp% + include/cppad/core/atomic/two_for_sparse_jac.hpp% + include/cppad/core/atomic/two_rev_sparse_jac.hpp% + include/cppad/core/atomic/two_for_sparse_hes.hpp% + include/cppad/core/atomic/two_rev_sparse_hes.hpp% + include/cppad/core/atomic/two_clear.hpp +%$$ + +$end +------------------------------------------------------------------------------- +$begin atomic_two_example$$ + +$section Example Defining Atomic Functions: Second Generation$$ + +$head Getting Started$$ +that shows the minimal amount of information required to create +a user defined atomic operation. + +$head Scalar Function$$ +where the user provides the code for computing derivatives. +This example is simple because the domain and range are scalars. + +$head Vector Range$$ +where the user provides the code for computing derivatives. +This example is more complex because the range has two components. + +$head Hessian Sparsity Patterns$$ +where the user provides the code for computing Hessian sparsity patterns. + +$childtable% + example/atomic_two/eigen_mat_mul.cpp% + example/atomic_two/eigen_mat_inv.cpp% + example/atomic_two/eigen_cholesky.cpp +%$$ + +$end +------------------------------------------------------------------------------- +*/ + +# include +# include +# include +# include + +// needed before one can use in_parallel +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic_two.hpp +Base class for atomic function operations. +*/ + +template +class atomic_base { +// =================================================================== +public: + enum option_enum { + pack_sparsity_enum , + bool_sparsity_enum , + set_sparsity_enum + }; +private: + // ------------------------------------------------------ + // constants + // + /// index of this object in local::atomic_index + /// (set by constructor and not changed; i.e., effectively const) + size_t index_; + // + // ----------------------------------------------------- + // variables + // + /// sparsity pattern this object is currently using + /// (set by constructor and option member functions) + option_enum sparsity_; + // + /// temporary work space used by member functions, declared here to avoid + // memory allocation/deallocation for each usage + struct work_struct { + vector vx; + vector vy; + // + vector tx; + vector ty; + // + vector< AD > atx; + vector< AD > aty; + // + vector bool_t; + // + vectorBool pack_h; + vectorBool pack_r; + vectorBool pack_s; + vectorBool pack_u; + // + vector bool_h; + vector bool_r; + vector bool_s; + vector bool_u; + // + vector< std::set > set_h; + vector< std::set > set_r; + vector< std::set > set_s; + vector< std::set > set_u; + }; + // Use pointers, to avoid false sharing between threads. + // Not using: vector work_; + // so that deprecated atomic examples do not result in a memory leak. + work_struct* work_[CPPAD_MAX_NUM_THREADS]; +public: + // ===================================================================== + // In User API + // ===================================================================== + // + // --------------------------------------------------------------------- + // ctor: doxygen in atomic_base/ctor.hpp + atomic_base(void); + atomic_base( + const std::string& name, + option_enum sparsity = bool_sparsity_enum + ); + + // option: see doxygen in atomic_base/option.hpp + void option(enum option_enum option_value); + + // operator(): see doxygen in atomic_base/afun.hpp + template + void operator()( + const ADVector& ax , + ADVector& ay , + size_t id = 0 + ); + + // ------------------------------------------------------------------------ + // base_two version of forward + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ); + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector< AD >& atx , + vector< AD >& aty + ); + // base_three version of forward + bool forward( + size_t order_low , + size_t order_up , + const vector& type_x , + vector& type_y , + const vector& taylor_x , + vector& taylor_y + ); + bool forward( + size_t order_low , + size_t order_up , + const vector& type_x , + vector& type_y , + const vector< AD >& ataylor_x , + vector< AD >& ataylor_y + ); + // ------------------------------------------------------------------------ + // reverse: see doxygen in atomic_base/reverse.hpp + virtual bool reverse( + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py + ); + virtual bool reverse( + size_t q , + const vector< AD >& atx , + const vector< AD >& aty , + vector< AD >& apx , + const vector< AD >& apy + ); + + // ------------------------------------------------------------ + // for_sparse_jac: see doxygen in atomic_base/for_sparse_jac.hpp + virtual bool for_sparse_jac( + size_t q , + const vector< std::set >& r , + vector< std::set >& s , + const vector& x + ); + virtual bool for_sparse_jac( + size_t q , + const vector& r , + vector& s , + const vector& x + ); + virtual bool for_sparse_jac( + size_t q , + const vectorBool& r , + vectorBool& s , + const vector& x + ); + template + bool for_sparse_jac( + const vector& x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + InternalSparsity& var_sparsity + ); + // deprecated versions + virtual bool for_sparse_jac( + size_t q , + const vector< std::set >& r , + vector< std::set >& s + ); + virtual bool for_sparse_jac( + size_t q , + const vector& r , + vector& s + ); + virtual bool for_sparse_jac( + size_t q , + const vectorBool& r , + vectorBool& s + ); + // ------------------------------------------------------------ + // rev_sparse_jac: see doxygen in atomic_base/rev_sparse_jac.hpp + virtual bool rev_sparse_jac( + size_t q , + const vector< std::set >& rt , + vector< std::set >& st , + const vector& x + ); + virtual bool rev_sparse_jac( + size_t q , + const vector& rt , + vector& st , + const vector& x + ); + virtual bool rev_sparse_jac( + size_t q , + const vectorBool& rt , + vectorBool& st , + const vector& x + ); + template + bool rev_sparse_jac( + const vector& x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + InternalSparsity& var_sparsity + ); + // deprecated versions + virtual bool rev_sparse_jac( + size_t q , + const vector< std::set >& rt , + vector< std::set >& st + ); + virtual bool rev_sparse_jac( + size_t q , + const vector& rt , + vector& st + ); + virtual bool rev_sparse_jac( + size_t q , + const vectorBool& rt , + vectorBool& st + ); + // ------------------------------------------------------------ + // for_sparse_hes: see doxygen in atomic_base/for_sparse_hes.hpp + virtual bool for_sparse_hes( + const vector& vx , + const vector& r , + const vector& s , + vector< std::set >& h , + const vector& x + ); + virtual bool for_sparse_hes( + const vector& vx , + const vector& r , + const vector& s , + vector& h , + const vector& x + ); + virtual bool for_sparse_hes( + const vector& vx , + const vector& r , + const vector& s , + vectorBool& h , + const vector& x + ); + template + bool for_sparse_hes( + const vector& x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + const InternalSparsity& for_jac_sparsity , + const InternalSparsity& rev_jac_sparsity , + InternalSparsity& for_hes_sparsity + ); + // deprecated versions + virtual bool for_sparse_hes( + const vector& vx , + const vector& r , + const vector& s , + vector< std::set >& h + ); + virtual bool for_sparse_hes( + const vector& vx , + const vector& r , + const vector& s , + vector& h + ); + virtual bool for_sparse_hes( + const vector& vx , + const vector& r , + const vector& s , + vectorBool& h + ); + // ------------------------------------------------------------ + // rev_sparse_hes: see doxygen in atomic_base/rev_sparse_hes.hpp + 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 , + const vector& x + ); + virtual bool rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const vector& r , + const vector& u , + vector& v , + const vector& x + ); + virtual bool rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const vectorBool& r , + const vectorBool& u , + vectorBool& v , + const vector& x + ); + template + bool rev_sparse_hes( + const vector& x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + const InternalSparsity& for_jac_sparsity , + bool* rev_jac_flag , + InternalSparsity& rev_hes_sparsity + ); + // deprecated + 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 + ); + virtual bool rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const vector& r , + const vector& u , + vector& v + ); + virtual bool rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const vectorBool& r , + const vectorBool& u , + vectorBool& v + ); + // ------------------------------------------------------------ + // atomic_three like interface for reverse dependency analysis + bool rev_depend( + const vector& parameter_x , + const vector& type_x , + vector& depend_x , + const vector& depend_y + ); + // ------------------------------------------------------------ + // clear: see doxygen in atomic_base/clear.hpp + static void clear(void); + + // ===================================================================== + // Not in User API + // ===================================================================== + + /// current sparsity setting + option_enum sparsity(void) const + { return sparsity_; } + + /// Name corresponding to a atomic_base object + const std::string afun_name(void) const + { bool set_null = false; + size_t type = 0; // set to avoid warning + std::string name; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, index_, type, &name, v_ptr); + CPPAD_ASSERT_UNKNOWN( type == 2 ); + return name; + } + /// destructor informs CppAD that this atomic function with this index + /// has dropped out of scope by setting its pointer to null + virtual ~atomic_base(void) + { // change object pointer to null, but leave name for error reporting + bool set_null = true; + size_t type = 0; // set to avoid warning + std::string* name = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, index_, type, name, v_ptr); + CPPAD_ASSERT_UNKNOWN( type == 2 ); + // + // free temporary work memory + for(size_t thread = 0; thread < CPPAD_MAX_NUM_THREADS; thread++) + free_work(thread); + } + /// allocates work_ for a specified thread + void allocate_work(size_t thread) + { if( work_[thread] == CPPAD_NULL ) + { // allocate the raw memory + size_t min_bytes = sizeof(work_struct); + size_t num_bytes; + void* v_ptr = thread_alloc::get_memory(min_bytes, num_bytes); + // save in work_ + work_[thread] = reinterpret_cast( v_ptr ); + // call constructor + new( work_[thread] ) work_struct; + } + return; + } + /// frees work_ for a specified thread + void free_work(size_t thread) + { if( work_[thread] != CPPAD_NULL ) + { // call destructor + work_[thread]->~work_struct(); + // return memory to avialable pool for this thread + thread_alloc::return_memory( + reinterpret_cast(work_[thread]) + ); + // mark this thread as not allocated + work_[thread] = CPPAD_NULL; + } + return; + } + /// atomic_base function object corresponding to a certain index + static atomic_base* class_object(size_t index) + { bool set_null = false; + size_t type = 0; // set to avoid warning + std::string* name = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, index, type, name, v_ptr); + CPPAD_ASSERT_UNKNOWN( type == 2 ); + return reinterpret_cast( v_ptr ); + } + /// atomic_base function name corresponding to a certain index + static const std::string class_name(size_t index) + { bool set_null = false; + size_t type = 0; // set to avoid warning + std::string name; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, index, type, &name, v_ptr); + CPPAD_ASSERT_UNKNOWN( type == 2 ); + return name; + } + + /*! + Set value of id (used by deprecated atomic_one class) + + This function is called just before calling any of the virtual function + and has the corresponding id of the corresponding virtual call. + */ + virtual void set_old(size_t id) + { } +// --------------------------------------------------------------------------- +}; +} // END_CPPAD_NAMESPACE + +// functitons implemented in cppad/core/atomic_base files +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/three_afun.hpp cppad-2019.02.00.0/include/cppad/core/atomic/three_afun.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/three_afun.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/three_afun.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,294 @@ +# ifndef CPPAD_CORE_ATOMIC_THREE_AFUN_HPP +# define CPPAD_CORE_ATOMIC_THREE_AFUN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three_afun$$ + +$spell + sq + mul + afun + const + CppAD + mat_mul.cpp +$$ + +$section Using AD Version of an Atomic Function$$ + +$head Syntax$$ +$icode%afun%(%ax%, %ay%)%$$ + +$head Prototype$$ +$srcfile%include/cppad/core/atomic/three_afun.hpp% + 0%// BEGIN_PROTOTYPE%// END_PROTOTYPE%1 +%$$ + +$head Purpose$$ +Given $icode ax$$, 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/$$. + +$head Base$$ +This is the $icode Base$$ type of the elements of $icode ax$$ and $icode ay$$ +in the call to the $icode afun$$ atomic operation. +To be specific, the elements of $icode ax$$ and $icode ay$$ have type +$codei%AD%<%Base%>%$$. + +$head ADVector$$ +The type $icode ADVector$$ must be a +$cref/simple vector class/SimpleVector/$$ with elements of type +$codei%AD<%Base%>%$$. + +$head afun$$ +is a $cref/atomic_user/atomic_three_ctor/atomic_user/$$ object +and this $icode afun$$ function call is implemented by the +$cref/atomic_three/atomic_three_ctor/atomic_three/$$ class. + +$head ax$$ +This argument has prototype +$codei% + const %ADVector%& %ax% +%$$ +and size must be equal to $icode n$$. +It specifies vector $latex x \in \B{R}^n$$ +at which an $codei%AD<%Base%>%$$ version of +$latex y = g(x)$$ is to be evaluated; see +$cref/Base/atomic_three_ctor/atomic_three/Base/$$. + +$head ay$$ +This argument has prototype +$codei% + %ADVector%& %ay% +%$$ +and size must be equal to $icode m$$. +The input values of its elements +are not specified (must not matter). +Upon return, it is an $codei%AD<%Base%>%$$ version of +$latex y = g(x)$$. + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/three_afun.hpp +Implement user call to an atomic_three function. +*/ + +/*! +Implement the user call to afun(ax, ay) + +\tparam ADVector +A simple vector class with elements of type AD. + +\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. +*/ +// BEGIN_PROTOTYPE +template +template +void atomic_three::operator()( + const ADVector& ax , + ADVector& ay ) +// END_PROTOTYPE +{ + + size_t n = ax.size(); + size_t m = ay.size(); +# ifndef NDEBUG + bool ok = true; + std::string msg = "atomic_three: " + afun_name() + ".eval: "; + if( (n == 0) | (m == 0) ) + { msg += "ax.size() or ay.size() is zero"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# endif + size_t thread = thread_alloc::thread_num(); + allocate_work(thread); + vector& taylor_x = work_[thread]->taylor_x; + vector& taylor_y = work_[thread]->taylor_y; + vector& type_x = work_[thread]->type_x; + vector& type_y = work_[thread]->type_y; + // + type_x.resize(n); + taylor_x.resize(n); + // + type_y.resize(m); + taylor_y.resize(m); + // + // Determine tape corresponding to variables in ax + tape_id_t tape_id = 0; + local::ADTape* tape = CPPAD_NULL; + for(size_t j = 0; j < n; j++) + { taylor_x[j] = ax[j].value_; + if( Constant( ax[j] ) ) + type_x[j] = constant_enum; + else + { type_x[j] = ax[j].ad_type_; + if( tape_id == 0 ) + { tape = ax[j].tape_this(); + tape_id = ax[j].tape_id_; + CPPAD_ASSERT_UNKNOWN( tape != CPPAD_NULL ); + } +# ifndef NDEBUG + if( Dynamic( ax[j] ) ) + { CPPAD_ASSERT_UNKNOWN( type_x[j] == dynamic_enum ); + } + else + { CPPAD_ASSERT_UNKNOWN( Variable( ax[j] ) ); + CPPAD_ASSERT_UNKNOWN( type_x[j] == variable_enum ); + } + if( tape_id != ax[j].tape_id_ ) + { msg += afun_name() + + ": ax contains non-constant values from different threads."; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } +# endif + } + } + // Use zero order forward mode to compute all the components of y + size_t need_y = size_t(variable_enum) + 1; + size_t order_low = 0; + size_t order_up = 0; + CPPAD_ASSERT_UNKNOWN( need_y > size_t(variable_enum) ); +# ifdef NDEBUG + forward(taylor_x, type_x, need_y, order_low, order_up, taylor_x, taylor_y); + for(size_t j = 0; j < n; ++j) + if( type_x[j] == variable_enum ) + taylor_x[j] = CppAD::numeric_limits::quiet_NaN(); + for_type(taylor_x, type_x, type_y); +# else + ok &= forward( + taylor_x, type_x, need_y, order_low, order_up, taylor_x, taylor_y + ); + for(size_t j = 0; j < n; ++j) + if( type_x[j] == variable_enum ) + taylor_x[j] = CppAD::numeric_limits::quiet_NaN(); + ok &= for_type(taylor_x, type_x, type_y); + if( ! ok ) + { msg += afun_name() + ": ok is false for " + "type or zero order forward mode calculation."; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } +# endif + bool record_dynamic = false; + bool record_variable = false; + // + // set ay to be vector of constant parameters with correct value + for(size_t i = 0; i < m; i++) + { // pass back values + ay[i].value_ = taylor_y[i]; + + // initialize entire vector as constants + ay[i].tape_id_ = 0; + ay[i].taddr_ = 0; + + // we need to record this operation if + // any of the elemnts of ay are dynamics or variables, + record_dynamic |= type_y[i] == dynamic_enum; + record_variable |= type_y[i] == variable_enum; + } +# ifndef NDEBUG + if( (record_dynamic || record_variable) && tape == CPPAD_NULL ) + { msg += + "all elements of x are constants but y contains a non-constant"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# endif + if( record_dynamic) + { tape->Rec_.put_dyn_atomic(tape_id, index_, type_x, type_y, ax, ay); + } + // case where result contains a variable + if( record_variable ) + { // atomic_two uses old_id to implement atomic_one interface + addr_t old_id = 0; + // + // Operator that marks beginning of this atomic operation + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::AFunOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::AFunOp) == 4 ); + CPPAD_ASSERT_KNOWN( + size_t( std::numeric_limits::max() ) >= + std::max( std::max(index_, n), m ), + "atomic_three: cppad_tape_addr_type maximum not large enough" + ); + tape->Rec_.PutArg(addr_t(index_), old_id, addr_t(n), addr_t(m)); + tape->Rec_.PutOp(local::AFunOp); + + // Now put n operators, one for each element of argument vector + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::FunavOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::FunapOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::FunavOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::FunapOp) == 1 ); + for(size_t j = 0; j < n; j++) + { if( type_x[j] == variable_enum ) + { // information for an argument that is a variable + tape->Rec_.PutArg(ax[j].taddr_); + tape->Rec_.PutOp(local::FunavOp); + } + else + { // information for an argument that is parameter + addr_t par = ax[j].taddr_; + if( type_x[j] == constant_enum ) + par = tape->Rec_.put_con_par(ax[j].value_); + tape->Rec_.PutArg(par); + tape->Rec_.PutOp(local::FunapOp); + } + } + + // Now put m operators, one for each element of result vector + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::FunrpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::FunrpOp) == 0 ); + for(size_t i = 0; i < m; i++) + { if( type_y[i] == variable_enum ) + { CPPAD_ASSERT_NARG_NRES(local::FunrvOp, 0, 1); + ay[i].taddr_ = tape->Rec_.PutOp(local::FunrvOp); + ay[i].tape_id_ = tape_id; + ay[i].ad_type_ = variable_enum; + CPPAD_ASSERT_UNKNOWN( Variable( ay[i] ) ); + } + else + { CPPAD_ASSERT_NARG_NRES(local::FunrpOp, 1, 0); + addr_t par = ay[i].taddr_; + if( type_y[i] == constant_enum ) + { Constant( ay[i] ); + par = tape->Rec_.put_con_par( ay[i].value_ ); + } + else + { Dynamic( ay[i] ); + } + tape->Rec_.PutArg(par); + tape->Rec_.PutOp(local::FunrpOp); + } + } + + // Put a duplicate AFunOp at end of AFunOp sequence + CPPAD_ASSERT_KNOWN( + size_t( std::numeric_limits::max() ) >= + std::max( std::max(index_, n), m ), + "atomic_three: cppad_tape_addr_type maximum not large enough" + ); + tape->Rec_.PutArg(addr_t(index_), old_id, addr_t(n), addr_t(m)); + tape->Rec_.PutOp(local::AFunOp); + } + return; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/three_ctor.hpp cppad-2019.02.00.0/include/cppad/core/atomic/three_ctor.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/three_ctor.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/three_ctor.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,161 @@ +# ifndef CPPAD_CORE_ATOMIC_THREE_CTOR_HPP +# define CPPAD_CORE_ATOMIC_THREE_CTOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three_ctor$$ +$spell + enum + sq + std + afun + arg + CppAD + bool + ctor + const + mat_mul_xam.cpp + hpp +$$ + +$section Atomic Function Constructor$$ + +$head Syntax$$ +$icode%atomic_user afun%(%ctor_arg_list%) +%$$ +$codei%atomic_three<%Base%>(%name%) +%$$ + +$head Prototype$$ +$srcfile%include/cppad/core/atomic/three_ctor.hpp% + 0%// BEGIN_PROTOTYPE%// END_PROTOTYPE%1 +%$$ + +$head atomic_user$$ + +$subhead ctor_arg_list$$ +Is a list of arguments for the $icode atomic_user$$ constructor. + +$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 +$cref/operation sequence/glossary/Operation/Sequence/$$. + +$subhead Implementation$$ +The user defined $icode atomic_user$$ class is a publicly derived class of +$codei%atomic_three<%Base%>%$$. +It should be declared as follows: +$codei% + class %atomic_user% : public CppAD::atomic_three<%Base%> { + public: + %atomic_user%(%ctor_arg_list%) : atomic_three<%Base%>(%name%) + %...% + }; +%$$ +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_three$$ implementations replaced by +$icode atomic_user$$ implementations. + +$head atomic_three$$ + +$subhead Restrictions$$ +The $code atomic_three$$ constructor and destructor cannot be called in +$cref/parallel/ta_in_parallel/$$ mode. + +$subhead Base$$ +The template parameter determines the +$cref/Base/atomic_three_afun/Base/$$ +type for this $codei%AD<%Base%>%$$ atomic operation. + +$subhead name$$ +This $code atomic_three$$ constructor argument has the following prototype +$codei% + 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. + +$head Example$$ + +$subhead Define Constructor$$ +The following is an example of a atomic function constructor definition: +$cref%get_started.cpp%atomic_three_get_started.cpp%Constructor%$$. + +$subhead Use Constructor$$ +The following is an example using a atomic function constructor: +$cref%get_started.cpp + %atomic_three_get_started.cpp + %Use Atomic Function%Constructor +%$$. + +$end +------------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/three_ctor.hpp +Constructors for atomic_three class. +*/ + +/*! +Base class for atomic_atomic functions. + +\tparam Base +This class is used for defining an AD atomic operation y = g(x). + +\par +make sure user does not invoke the default constructor +*/ +template +atomic_three::atomic_three(void) +{ CPPAD_ASSERT_KNOWN(false, + "Attempt to use the atomic_three default constructor" + ); +} +/*! +Constructor + +\param name +name used for error reporting +*/ +// BEGIN_PROTOTYPE +template +atomic_three::atomic_three(const std::string& name ) +// END_PROTOTYPE +{ CPPAD_ASSERT_KNOWN( + ! thread_alloc::in_parallel() , + "atomic_three: constructor cannot be called in parallel mode." + ); + // + // atomic_index + bool set_null = false; + size_t index = 0; + size_t type = 3; + std::string copy_name = name; + void* copy_this = reinterpret_cast( this ); + index_ = local::atomic_index( + set_null, index, type, ©_name, copy_this + ); + // initialize work pointers as null; + for(size_t thread = 0; thread < CPPAD_MAX_NUM_THREADS; thread++) + work_[thread] = CPPAD_NULL; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/three_for_type.hpp cppad-2019.02.00.0/include/cppad/core/atomic/three_for_type.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/three_for_type.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/three_for_type.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,118 @@ +# ifndef CPPAD_CORE_ATOMIC_THREE_FOR_TYPE_HPP +# define CPPAD_CORE_ATOMIC_THREE_FOR_TYPE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three_for_type$$ +$spell + afun + enum + cpp +$$ + +$section Atomic Function Forward Type Calculation$$ + +$head Syntax$$ +$icode%ok% = %afun%.for_type(%parameter_x%, %type_x%, %type_y%)%$$ + +$subhead Prototype$$ +$srcfile%include/cppad/core/atomic/three_for_type.hpp + %0%// BEGIN_PROTOTYPE%// END_PROTOTYPE%1 +%$$ + +$head Dependency Analysis$$ +This calculation is sometimes referred to as a forward dependency analysis. + +$head Usage$$ +This syntax and prototype are used by +$codei% + %afun%(%ax%, %ay%) +%$$ +where $cref/afun/atomic_three_ctor/atomic_user/afun/$$ +is a user defined atomic function. + +$head Implementation$$ +This virtual function must be defined by the +$cref/atomic_user/atomic_three_ctor/atomic_user/$$ class. + +$head Base$$ +See $cref/Base/atomic_three/Base/$$. + +$head parameter_x$$ +See $cref/parameter_x/atomic_three/parameter_x/$$. + +$head type_x$$ +See $cref/type_x/atomic_three/type_x/$$. + +$head type_y$$ +This vector has size equal to the number of results for this atomic function; +i.e. $icode%m%=%ay%.size()%$$. +The input values of the elements of $icode type_y$$ +are not specified (must not matter). +Upon return, for $latex i = 0 , \ldots , m-1$$, +$icode%type_y%[%i%]%$$ is set to one of the following values: +$list number$$ +It is $code constant_enum$$ if $icode%ay%[%i%]%$$ only depends on +the arguments that are constants. +$lnext +It is $code dynamic_enum$$ if $icode%ay%[%i%]%$$ depends on +a dynamic parameter and does not depend on any variables. +$lnext +It is $code variable_enum$$ if $icode%ay%[%i%]%$$ depends on +a variable. +$lend + +$head ok$$ +If this calculation succeeded, $icode ok$$ is true. +Otherwise, it is false. + +$head Example$$ +The following is an example of a atomic function $code for_type$$ definition: +$cref%get_started.cpp%atomic_three_get_started.cpp%for_type%$$. + + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/three_for_type.hpp +Third generation atomic type computation. +*/ +/*! +Link from atomic_three to type calculation + +\param parameter_x [in] +is the value of the parameters in the corresponding function call +afun(ax, ay). + +\param type_x [in] +specifies which components of x are +constants, dynamics, and variables + +\param type_y [out] +specifies which components of y are +constants, dynamics, and variables +*/ +// BEGIN_PROTOTYPE +template +bool atomic_three::for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) +// END_PROTOTYPE +{ return false; } + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/three_forward.hpp cppad-2019.02.00.0/include/cppad/core/atomic/three_forward.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/three_forward.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/three_forward.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,325 @@ +# ifndef CPPAD_CORE_ATOMIC_THREE_FORWARD_HPP +# define CPPAD_CORE_ATOMIC_THREE_FORWARD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three_forward$$ +$spell + taylor + ataylor + af + afun + enum + CppAD + aparameter +$$ + +$section Atomic Function Forward Mode$$ + +$head Base$$ +This syntax and prototype are used by +$cref/afun(ax, ay)/atomic_three_afun/$$; see +$cref/Base/atomic_three_afun/Base/$$. +They are also used by +$icode%f%.Forward%$$ and $icode%f%.new_dynamic%$$ +where $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +and $icode afun$$ is used during the recording of $icode f$$. + +$subhead Syntax$$ +$icode%ok% = %afun%.forward( + %parameter_x%, %type_x%, + %need_y%, %order_low%, %order_up%, %type_x%, %taylor_x%, %taylor_y% +)%$$ + +$subhead Prototype$$ +$srcfile%include/cppad/core/atomic/three_forward.hpp + %0%// BEGIN_PROTOTYPE_BASE%// END_PROTOTYPE_BASE%1 +%$$ + +$head AD$$ +This syntax and prototype are used by +$icode%af%.Forward%$$ and $icode%af%.new_dynamic%$$ +where $icode af$$ has prototype +$codei% + ADFun< AD<%Base%> , %Base% > %af% +%$$ +and $icode afun$$ is used in $icode af$$ (see $cref base2ad$$). + +$subhead Syntax$$ +$icode%ok% = %afun%.forward( + %parameter_x%, %type_x%, + %need_y%, %order_low%, %order_up%, %type_x%, %ataylor_x%, %ataylor_y% +)%$$ + +$subhead Prototype$$ +$srcfile%include/cppad/core/atomic/three_forward.hpp + %0%// BEGIN_PROTOTYPE_AD_BASE%// END_PROTOTYPE_AD_BASE%1 +%$$ + +$head Implementation$$ +The $icode taylor_x$$, $icode taylor_y$$ version of this function +must be defined by the +$cref/atomic_user/atomic_three_ctor/atomic_user/$$ class. +It can just return $icode%ok% == false%$$ +(and not compute anything) for values +of $icode%order_up%$$ that are greater than those used by your +$cref/forward/Forward/$$ mode calculations +(order zero must be implemented). + +$head parameter_x$$ +See $cref/parameter_x/atomic_three/parameter_x/$$. + +$head aparameter_x$$ +The specifications for $icode aparameter_x$$ +is the same as for $cref/parameter_x/atomic_three/parameter_x/$$ +(only the type of $icode ataylor_x$$ is different). + +$head type_x$$ +See $cref/type_x/atomic_three/type_x/$$. + +$head need_y$$ +One can ignore this argument and compute all the $icode taylor_y$$ +Taylor coefficient. +Often, this is not necessary and $icode need_y$$ is used to specify this. +The value $cref/type_y/atomic_three_for_type/type_y/$$ is used +to determine which coefficients are necessary as follows: + +$subhead Dynamic Parameters$$ +If $icode%need_y == size_t(dynamic_enum)%$$, +then only the taylor coefficients +for $latex Y_i (t)$$ where $icode%type_y%[%i%] == dynamic_enum%$$ +are necessary. +This is the case during an $cref new_dynamic$$ operation. + +$subhead Variables$$ +If $icode%need_y == size_t(variable_enum)%$$, +If $codei%ad_type_enum(%need_y%)% == variable_enum%$$, +then only the taylor coefficients +for $latex Y_i (t)$$ where $icode%type_y%[%i%] == variable_enum%$$ +are necessary. +This is the case during a $cref/f.Forward/Forward/$$ operation. +T + +$subhead All$$ +If $icode%need_y > size_t(variable_enum)%$$, +then the taylor coefficients for all $latex Y_i (t)$$ are necessary. +This is the case during an $icode%afun%(%ax%, %ay%)%$$ operation. + + +$head order_low$$ +This argument +specifies the lowest order Taylor coefficient that we are computing. + +$subhead p$$ +We sometimes use the notation $icode%p% = %order_low%$$ below. + +$head order_up$$ +This argument +specifies the highest order Taylor coefficient that we are computing +($icode%order_low% <= %order_up%$$). + +$subhead q$$ +We sometimes use the notation $icode%q% = %order_up%$$ below. + +$head taylor_x$$ +The size of $icode taylor_x$$ is $codei%(%q%+1)*%n%$$. +For $latex j = 0 , \ldots , n-1$$ and $latex k = 0 , \ldots , q$$, +we use the Taylor coefficient notation +$latex \[ +\begin{array}{rcl} + x_j^k & = & \R{taylor\_x} [ j * ( q + 1 ) + k ] + \\ + X_j (t) & = & x_j^0 + x_j^1 t^1 + \cdots + x_j^q t^q +\end{array} +\] $$ +Note that superscripts represent an index for $latex x_j^k$$ +and an exponent for $latex t^k$$. +Also note that the Taylor coefficients for $latex X(t)$$ correspond +to the derivatives of $latex X(t)$$ at $latex t = 0$$ in the following way: +$latex \[ + x_j^k = \frac{1}{ k ! } X_j^{(k)} (0) +\] $$ + +$head ataylor_x$$ +The specifications for $icode ataylor_x$$ is the same as for $icode taylor_x$$ +(only the type of $icode ataylor_x$$ is different). + +$head taylor_y$$ +The size of $icode taylor_y$$ is $codei%(%q%+1)*%m%$$. +Upon return, +For $latex i = 0 , \ldots , m-1$$ and $latex k = 0 , \ldots , q$$, +$latex \[ +\begin{array}{rcl} + Y_i (t) & = & g_i [ X(t) ] + \\ + Y_i (t) & = & y_i^0 + y_i^1 t^1 + \cdots + y_i^q t^q + o ( t^q ) + \\ + \R{taylor\_y} [ i * ( q + 1 ) + k ] & = & y_i^k +\end{array} +\] $$ +where $latex o( t^q ) / t^q \rightarrow 0$$ as $latex t \rightarrow 0$$. +Note that superscripts represent an index for $latex y_j^k$$ +and an exponent for $latex t^k$$. +Also note that the Taylor coefficients for $latex Y(t)$$ correspond +to the derivatives of $latex Y(t)$$ at $latex t = 0$$ in the following way: +$latex \[ + y_j^k = \frac{1}{ k ! } Y_j^{(k)} (0) +\] $$ +If $latex p > 0$$, +for $latex i = 0 , \ldots , m-1$$ and $latex k = 0 , \ldots , p-1$$, +the input of $icode taylor_y$$ satisfies +$latex \[ + \R{taylor\_y} [ i * ( q + 1 ) + k ] = y_i^k +\]$$ +These values do not need to be recalculated +and can be used during the computation of the higher order coefficients. + +$head ataylor_y$$ +The specifications for $icode ataylor_y$$ is the same as for $icode taylor_y$$ +(only the type of $icode ataylor_y$$ is different). + +$head ok$$ +If this calculation succeeded, $icode ok$$ is true. +Otherwise, it is false. + +$head Discussion$$ +For example, suppose that $icode%order_up% == 2%$$, +and you know how to compute the function $latex g(x)$$, +its first derivative $latex f^{(1)} (x)$$, +and it component wise Hessian $latex g_i^{(2)} (x)$$. +Then you can compute $icode taylor_x$$ using the following formulas: +$latex \[ +\begin{array}{rcl} +y_i^0 & = & Y(0) + = g_i ( x^0 ) +\\ +y_i^1 & = & Y^{(1)} ( 0 ) + = g_i^{(1)} ( x^0 ) X^{(1)} ( 0 ) + = g_i^{(1)} ( x^0 ) x^1 +\\ +y_i^2 +& = & \frac{1}{2 !} Y^{(2)} (0) +\\ +& = & \frac{1}{2} X^{(1)} (0)^\R{T} g_i^{(2)} ( x^0 ) X^{(1)} ( 0 ) + + \frac{1}{2} g_i^{(1)} ( x^0 ) X^{(2)} ( 0 ) +\\ +& = & \frac{1}{2} (x^1)^\R{T} g_i^{(2)} ( x^0 ) x^1 + + g_i^{(1)} ( x^0 ) x^2 +\end{array} +\] $$ +For $latex i = 0 , \ldots , m-1$$, and $latex k = 0 , 1 , 2$$, +$latex \[ + \R{taylor\_y} [ i * (q + 1) + k ] = y_i^k +\] $$ + +$children% + example/atomic_three/forward.cpp% + example/atomic_three/dynamic.cpp +%$$ +$head Examples$$ +The files +$cref atomic_three_forward.cpp$$ and $cref atomic_three_dynamic.cpp$$ +contain examples and tests that uses this routine. + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/three_forward.hpp +Third generation atomic forward mode. +*/ +/*! +Link from atomic_three to forward mode + +\param parameter_x [in] +contains the values, in afun(ax, ay), for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param need_y [in] +specifies which components of taylor_y are needed, + +\param order_low [in] +lowerest order for this forward mode calculation. + +\param order_up [in] +highest order for this forward mode calculation. + +\param taylor_x [in] +Taylor coefficients corresponding to x for this calculation. + +\param taylor_y [out] +Taylor coefficient corresponding to y for this calculation + +See the forward mode in user's documentation for atomic_three +*/ +// BEGIN_PROTOTYPE_BASE +template +bool atomic_three::forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector& taylor_x , + vector& taylor_y ) +// END_PROTOTYPE_BASE +{ return false; } + +/*! +Link from atomic_three to forward mode + +\param aparameter_x [in] +contains the values, in afun(ax, ay), for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param need_y [in] +specifies which components of taylor_y are needed, + +\param order_low [in] +lowerest order for this forward mode calculation. + +\param order_up [in] +highest order for this forward mode calculation. + +\param ataylor_x [in] +Taylor coefficients corresponding to x for this calculation. + +\param ataylor_y [out] +Taylor coefficient corresponding to y for this calculation + +See the forward mode in user's documentation for base_three +*/ +// BEGIN_PROTOTYPE_AD_BASE +template +bool atomic_three::forward( + const vector< AD >& aparameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector< AD >& ataylor_x , + vector< AD >& ataylor_y ) +// END_PROTOTYPE_AD_BASE +{ return false; } + + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/three_hes_sparsity.hpp cppad-2019.02.00.0/include/cppad/core/atomic/three_hes_sparsity.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/three_hes_sparsity.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/three_hes_sparsity.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,382 @@ +# ifndef CPPAD_CORE_ATOMIC_THREE_HES_SPARSITY_HPP +# define CPPAD_CORE_ATOMIC_THREE_HES_SPARSITY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three_hes_sparsity$$ +$spell + Hessian + afun + hes +$$ + +$section Atomic Function Hessian Sparsity Patterns$$ + +$head Syntax$$ +$icode%ok% = %afun%.hes_sparsity( + %parameter_x%, %type_x%, %select_x%, %select_y%, %pattern_out% +)%$$ + +$head Prototype$$ +$srcfile%include/cppad/core/atomic/three_hes_sparsity.hpp + %0%// BEGIN_PROTOTYPE%// END_PROTOTYPE%1 +%$$ + +$head Implementation$$ +This function must be defined if +$cref/afun/atomic_three_ctor/atomic_user/afun/$$ is +used to define an $cref ADFun$$ object $icode f$$, +and Hessian sparsity patterns are computed for $icode f$$. + +$head Base$$ +See $cref/Base/atomic_three_afun/Base/$$. + +$head parameter_x$$ +See $cref/parameter_x/atomic_three/parameter_x/$$. + +$head type_x$$ +See $cref/type_x/atomic_three/type_x/$$. + +$head select_x$$ +This argument has size equal to the number of arguments to this +atomic function; i.e. the size of $icode ax$$. +It specifies which domain components are included in +the calculation of $icode pattern_out$$. +If $icode%select_x%[%j%]%$$ is false, then there will be no indices +$icode k$$ such that either of the following hold: +$codei% + %pattern_out%.row()[%k%] == %j% + %pattern_out%.col()[%k%] == %j% +%$$. + +$head select_y$$ +This argument has size equal to the number of results to this +atomic function; i.e. the size of $icode ay$$. +It specifies which range component functions $latex g_i (x)$$ are included in +of $icode pattern_out$$. + +$head pattern_out$$ +This input value of $icode pattern_out$$ does not matter. +Upon return it is the union, +with respect to $icode i$$ such that $icode%select_y%[%i%]%$$ is true, +of the sparsity pattern for Hessian of $latex g_i (x)$$. +To be specific, there are non-negative indices +$icode i$$, $icode r$$, $icode c$$, and $icode k$$ such that +$codei% + %pattern_out%.row()[%k%] == %r% + %pattern_out%.col()[%k%] == %c% +%$$ +if and only if +$icode%select_y%[%i%]%$$ is true, +$icode%select_x%[%r%]%$$ is true, +$icode%select_x%[%c%]%$$ is true, +and +$latex \[ + \partial_{x(r)} \partial_{x(c)} g_i(x) +\] $$ +is possibly non-zero. +Note that the sparsity pattern should be symmetric. + +$head ok$$ +If this calculation succeeded, $icode ok$$ is true. +Otherwise it is false. + +$children% + example/atomic_three/hes_sparsity.cpp +%$$ +$head Examples$$ +The file $cref atomic_three_hes_sparsity.cpp$$ contains an example and test +that uses this routine. +$end +----------------------------------------------------------------------------- +*/ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/three_hes_sparsity.hpp +Third generation atomic Hessian dependency and sparsity patterns. +*/ +/*! +atomic_three to Hessian dependency and sparsity calculations. + +\param parameter_x [in] +contains the values for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param select_x [in] +which domain components to include in the dependency or sparsity pattern. + +\param select_y [in] +which range components to include in the dependency or sparsity pattern. + +\param pattern_out [out] +is the sparsity pattern for Hessian. +*/ +// BEGIN_PROTOTYPE +template +bool atomic_three::hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const vector& select_x , + const vector& select_y , + sparse_rc< vector >& pattern_out ) +// END_PROTOTYPE +{ return false; } +/*! +Link from forward Hessian sweep to atomic_three. + +\tparam InternalSparsity +Is the used internaly for sparsity calculations; i.e., +sparse_pack or sparse_list. + +\param parameter_x +is parameter arguments to the function, other components are nan. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param x_index +is the variable index, on the tape, for the arguments to this function. +This size of x_index is n, the number of arguments to this function. +The index zero is used for parameters. + +\param y_index +is the variable index, on the tape, for the results for this function. +This size of y_index is m, the number of results for this function. +The index zero is used for parameters. + +\param for_jac_sparsity +On input, for j = 0, ... , n-1, the sparsity pattern with index x_index[j], +is the forward Jacobian sparsity for the j-th argument to this atomic function. + +\param rev_jac_sparsity +On input, for i = 0, ... , m-1, the sparsity pattern with index y_index[i], +is the reverse Jacobian sparsity for the i-th result to this atomic function. +This shows which components of the result affect the function we are +computing the Hessian of. + +\param hes_sparsity_for +This is the sparsity pattern for the Hessian. On input, the non-linear +terms in the atomic fuction have not been included. Upon return, they +have been included. +*/ +template +template +bool atomic_three::for_hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + const InternalSparsity& for_jac_sparsity , + const InternalSparsity& rev_jac_sparsity , + InternalSparsity& hes_sparsity_for ) +{ typedef typename InternalSparsity::const_iterator const_iterator; + CPPAD_ASSERT_UNKNOWN( rev_jac_sparsity.end() == 1 ); + size_t n = x_index.size(); + size_t m = y_index.size(); + // + // select_x + vector select_x(n); + for(size_t j = 0; j < n; j++) + { // check if should compute pattern w.r.t x[j] + const_iterator itr(for_jac_sparsity, x_index[j]); + size_t i = *itr; + select_x[j] = i < for_jac_sparsity.end(); + CPPAD_ASSERT_UNKNOWN( x_index[j] > 0 || ! select_x[j] ); + } + // + // bool select_y + vector select_y(m); + for(size_t i = 0; i < m; i++) + { // check if we should include y[i] + select_y[i] = rev_jac_sparsity.is_element(y_index[i], 0); + CPPAD_ASSERT_UNKNOWN( y_index[i] > 0 || ! select_y[i] ); + } + // + // call user's version of atomic function + sparse_rc< vector > pattern_out; + bool ok = hes_sparsity( + parameter_x, type_x, select_x, select_y, pattern_out + ); + if( ! ok ) + return ok; + // + // add new elements to Hessian sparisty in calling routine + const vector& row( pattern_out.row() ); + const vector& col( pattern_out.col() ); + for(size_t k = 0; k < pattern_out.nnz(); ++k) + { size_t r = row[k]; + size_t c = col[k]; + CPPAD_ASSERT_KNOWN( + select_x[r] & select_x[c], + "atomic: hes_sparsity: pattern_out not in select_x range" + ); + const_iterator itr_1(for_jac_sparsity, x_index[r]); + size_t v1 = *itr_1; + while( v1 < for_jac_sparsity.end() ) + { hes_sparsity_for.binary_union( + v1, v1, x_index[c], for_jac_sparsity + ); + v1 = *(++itr_1); + } + // no need to add same elements twice + if( c != r ) + { const_iterator itr_2(for_jac_sparsity, x_index[c]); + size_t v2 = *itr_2; + while( v2 < for_jac_sparsity.end() ) + { hes_sparsity_for.binary_union( + v2, v2, x_index[r], for_jac_sparsity + ); + v2 = *(++itr_2); + } + } + } + return ok; +} +/*! +Link from for_reverse Hessian sweep to atomic_three. + +\tparam InternalSparsity +Is the used internaly for sparsity calculations; i.e., +sparse_pack or sparse_list. + +\param parameter_x +is parameter arguments to the function, other components are nan. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param x_index +is the variable index, on the tape, for the arguments to this function. +This size of x_index is n, the number of arguments to this function. +The index zero is used for parameters. + +\param y_index +is the variable index, on the tape, for the results for this function. +This size of y_index is m, the number of results for this function. +The index zero is used for parameters. + +\param for_jac_sparsity +On input, for j = 0, ... , n-1, the sparsity pattern with index x_index[j], +is the forward Jacobian sparsity for the j-th argument to this atomic function. + +\param rev_jac_flag +On input, for i = 0, ... , m-1, rev_jac_flag[ y_index[i] ] is true +if the function we are computing the Hessian of has possibly non-zero Jacobian +w.r.t varialbe y_index[i]. +On output, for j = 0, ... , n, rev_jac_flag[ x_index[j] ] is set to true +if the varialbe with index x_index[j] has possible non-zero Jacobian +with repect to one of the true y_index[i] cases. +Otherwise, rev_jac_flag [ x_inde[j] ] is not changed. + +\param hes_sparsity_rev +Is the reverse mode sparsity pattern for the Hessian. On input, the non-linear +terms in the atomic fuction have not been included. Upon return, they +have been included. +*/ +template +template +bool atomic_three::rev_hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + const InternalSparsity& for_jac_sparsity , + bool* rev_jac_flag , + InternalSparsity& hes_sparsity_rev ) +{ typedef typename InternalSparsity::const_iterator const_iterator; + size_t n = x_index.size(); + size_t m = y_index.size(); + // + // select_x + vector select_x(n); + for(size_t j = 0; j < n; j++) + { // check if should compute pattern w.r.t x[j] + const_iterator itr(for_jac_sparsity, x_index[j]); + size_t i = *itr; + select_x[j] = i < for_jac_sparsity.end(); + CPPAD_ASSERT_UNKNOWN( x_index[j] > 0 || ! select_x[j] ); + } + // + // bool select_y + vector select_y(m); + for(size_t i = 0; i < m; i++) + { // check if we should include y[i] + select_y[i] = rev_jac_flag[ y_index[i] ]; + CPPAD_ASSERT_UNKNOWN( y_index[i] > 0 || ! select_y[i] ); + } + // + // call atomic function for Jacobain sparsity + bool dependency = false; + sparse_rc< vector > pattern_jac; + bool ok = jac_sparsity( + parameter_x, type_x, dependency, select_x, select_y, pattern_jac + ); + const vector& row_jac( pattern_jac.row() ); + const vector& col_jac( pattern_jac.col() ); + size_t nnz_jac = pattern_jac.nnz(); + if( ! ok ) + return ok; + // + // call atomic function for Hessian sparsity + sparse_rc< vector > pattern_hes; + ok = hes_sparsity(parameter_x, type_x, select_x, select_y, pattern_hes); + const vector& row_hes( pattern_hes.row() ); + const vector& col_hes( pattern_hes.col() ); + size_t nnz_hes = pattern_hes.nnz(); + if( ! ok ) + return ok; + // + // propagate Hessian sparsity through the Jacobian + for(size_t k = 0; k < nnz_jac; ++k) + { size_t i = row_jac[k]; + size_t j = col_jac[k]; + CPPAD_ASSERT_KNOWN( + select_y[i] & select_x[j] , + "atomic: jac_sparsity: pattern_out not in " + "select_x or select_y range" + ); + // from y_index[i] to x_index[j] + hes_sparsity_rev.binary_union( + x_index[j], x_index[j], y_index[i], hes_sparsity_rev + ); + } + // + // propagate rev_jac_flag through the Jacobian + // (seems OK to exclude variables with zero forward jacobian) + for(size_t k = 0; k < nnz_jac; ++k) + { size_t j = col_jac[k]; + rev_jac_flag[ x_index[j] ] = true; + } + // + // new hessian sparsity terms between y and x + for(size_t k = 0; k < nnz_hes; ++k) + { size_t r = row_hes[k]; + size_t c = col_hes[k]; + CPPAD_ASSERT_KNOWN( + select_x[r] & select_x[c] , + "atomic: hes_sparsity: pattern_out not in select_x range" + ); + hes_sparsity_rev.binary_union( + x_index[r], x_index[r], x_index[c], for_jac_sparsity + ); + hes_sparsity_rev.binary_union( + x_index[c], x_index[c], x_index[r], for_jac_sparsity + ); + } + return ok; +} + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/three_jac_sparsity.hpp cppad-2019.02.00.0/include/cppad/core/atomic/three_jac_sparsity.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/three_jac_sparsity.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/three_jac_sparsity.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,356 @@ +# ifndef CPPAD_CORE_ATOMIC_THREE_JAC_SPARSITY_HPP +# define CPPAD_CORE_ATOMIC_THREE_JAC_SPARSITY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three_jac_sparsity$$ +$spell + Jacobian + afun + jac +$$ + +$section Atomic Function Jacobian Sparsity Patterns$$ + +$head Syntax$$ +$icode%ok% = %afun%.jac_sparsity( + %parameter_x%, %type_x%, %dependency%, %select_x%, %select_y%, %pattern_out% +)%$$ + +$head Prototype$$ +$srcfile%include/cppad/core/atomic/three_jac_sparsity.hpp + %0%// BEGIN_PROTOTYPE%// END_PROTOTYPE%1 +%$$ + +$head Implementation$$ +This function must be defined if +$cref/afun/atomic_three_ctor/atomic_user/afun/$$ is +used to define an $cref ADFun$$ object $icode f$$, +and Jacobian sparsity patterns are computed for $icode f$$. +(Computing Hessian sparsity patterns and optimizing +requires Jacobian sparsity patterns.) + +$head Base$$ +See $cref/Base/atomic_three_afun/Base/$$. + +$head parameter_x$$ +See $cref/parameter_x/atomic_three/parameter_x/$$. + +$head type_x$$ +See $cref/type_x/atomic_three/type_x/$$. + +$head dependency$$ +If $icode dependency$$ is true, +then $icode pattern_out$$ is a +$cref/dependency pattern/dependency.cpp/Dependency Pattern/$$ +for this atomic function. +Otherwise it is a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for the +derivative of the atomic function. + +$head select_x$$ +This argument has size equal to the number of arguments to this +atomic function; i.e. the size of $icode ax$$. +It specifies which domain components are included in +the calculation of $icode pattern_out$$. +If $icode%select_x%[%j%]%$$ is false, then there will be no indices +$icode k$$ such that +$codei% + %pattern_out%.col()[%k%] == %j% +%$$. + +$head select_y$$ +This argument has size equal to the number of results to this +atomic function; i.e. the size of $icode ay$$. +It specifies which range components are included in +the calculation of $icode pattern_out$$. +If $icode%select_y%[%i%]%$$ is false, then there will be no indices +$icode k$$ such that +$codei% + %pattern_out%.row()[%k%] == %i% +%$$. + +$head pattern_out$$ +This input value of $icode pattern_out$$ does not matter. +Upon return it is a +dependency or sparsity pattern for the Jacobian of $latex g(x)$$, +the function corresponding to +$cref/afun/atomic_three_ctor/atomic_user/afun/$$; +$icode dependency$$ above. +To be specific, there are non-negative indices +$icode i$$, $icode j$$, $icode k$$ such that +$codei% + %pattern_out%.row()[%k%] == %i% + %pattern_out%.col()[%k%] == %j% +%$$ +if and only if +$icode%select_x%[%j%]%$$ is true, +$icode%select_y%[%j%]%$$ is true, +and $latex g_i(x)$$ depends on the value of $latex x_j$$ +(and the partial of $latex g_i(x)$$ with respect to +$latex x_j$$ is possibly non-zero). + +$head ok$$ +If this calculation succeeded, $icode ok$$ is true. +Otherwise it is false. + + +$children% + example/atomic_three/jac_sparsity.cpp +%$$ +$head Examples$$ +The file $cref atomic_three_jac_sparsity.cpp$$ contains an example and test +that uses this routine. +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/three_jac_sparsity.hpp +Third generation atomic Jacobian dependency and sparsity patterns. +*/ +/*! +atomic_three to Jacobian dependency and sparsity calculations. + +\param parameter_x [in] +contains the values for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param dependency [in] +if true, calculate dependency pattern, +otherwise calcuate sparsity pattern. + +\param select_x [in] +which domain components to include in the dependency or sparsity pattern. +The index zero is used for parameters. + +\param select_y [in] +which range components to include in the dependency or sparsity pattern. +The index zero is used for parameters. + +\param pattern_out [out] +is the dependency or sparsity pattern. +*/ +// BEGIN_PROTOTYPE +template +bool atomic_three::jac_sparsity( + const vector& parameter_x , + const vector& type_x , + bool dependency , + const vector& select_x , + const vector& select_y , + sparse_rc< vector >& pattern_out ) +// END_PROTOTYPE +{ return false; } +/*! +Link from forward Jacobian sparsity calcuations to atomic_three + +\tparam InternalSparsity +Is the type used for internal sparsity calculations; i.e., +sparse_pack or sparse_list. + +\param dependency +if true, calcuate dependency pattern, +otherwise calcuate sparsity pattern. + +\param parameter_x +is parameter arguments to the function, other components are nan. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param x_index +is the variable index, on the tape, for the arguments to this atomic function. +This size of x_index is n, the number of arguments to this atomic function. +The index zero is used for parameters. + +\param y_index +is the variable index, on the tape, for the results for this atomic function. +This size of y_index is m, the number of results for this atomic function. +The index zero is used for parameters. + +\param var_sparsity +On input, for j = 0, ... , n-1, the sparsity pattern with index x_index[j], +is the sparsity for the j-th argument to this atomic function. +On output, for i = 0, ... , m-1, the sparsity pattern with index y_index[i], +is the sparsity for the i-th result for this atomic function. + +\return +is true if the computation succeeds. +*/ +template +template +bool atomic_three::for_jac_sparsity( + bool dependency , + const vector& parameter_x , + const vector& type_x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + InternalSparsity& var_sparsity ) +{ typedef typename InternalSparsity::const_iterator iterator; + + // number of arguments and resutls for this atomic function + size_t n = x_index.size(); + size_t m = y_index.size(); + + // select_y + vector select_y(m); + for(size_t i = 0; i < m; ++i) + select_y[i] = y_index[i] != 0; + + // determine select_x + vector select_x(n); + for(size_t j = 0; j < n; ++j) + { // check if x_j depends on any previous variable + iterator itr(var_sparsity, x_index[j]); + size_t ell = *itr; + select_x[j] = ell < var_sparsity.end(); + CPPAD_ASSERT_UNKNOWN( x_index[j] > 0 || ! select_x[j] ); + } + sparse_rc< vector > pattern_out; + bool ok = jac_sparsity( + parameter_x, type_x, dependency, select_x, select_y, pattern_out + ); + if( ! ok ) + return false; + // + // transfer sparsity patterns from pattern_out to var_sparsity + size_t nnz = pattern_out.nnz(); + const vector& row( pattern_out.row() ); + const vector& col( pattern_out.col() ); + for(size_t k = 0; k < nnz; ++k) + { size_t i = row[k]; + size_t j = col[k]; + CPPAD_ASSERT_KNOWN( + select_y[i] & select_x[j], + "atomic: jac_sparsity: pattern_out not in " + "select_x or select_y range" + ); + iterator itr(var_sparsity, x_index[j]); + size_t ell = *itr; + while( ell < var_sparsity.end() ) + { var_sparsity.post_element( y_index[i], ell ); + ell = *(++itr); + } + } + for(size_t i = 0; i < m; ++i) + var_sparsity.process_post( y_index[i] ); + // + return true; +} +/*! +Link from reverse Jacobian sparsity calcuations to atomic_three + +\tparam InternalSparsity +Is the type used for internal sparsity calculations; i.e., +sparse_pack or sparse_list. + +\param dependency +if true, calcuate dependency pattern, +otherwise calcuate sparsity pattern. + +\param parameter_x +is parameter arguments to the function, other components are nan. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param x_index +is the variable index, on the tape, for the arguments to this atomic function. +This size of x_index is n, the number of arguments to this atomic function. + +\param y_index +is the variable index, on the tape, for the results for this atomic function. +This size of y_index is m, the number of results for this atomic function. + +\param var_sparsity +On input, for i = 0, ... , m-1, the sparsity pattern with index y_index[i], +is the sparsity of the outter function with respect to the i-th +result for this atomic function. +On input, for j = 0, ... , n-1, the sparsity pattern with index x_index[j], +is the sparsity for the outter function with repsect to the j-th +argument to this atomic function. +On output, for j = 0, ... , n-1, the sparsity pattern with index x_index[j], +is the sparsity for the outter function with repsect to the j-th +argument to this atomic function with the atomic function results +removed as arguments to the outter function. + +\return +is true if the computation succeeds. +*/ +template +template +bool atomic_three::rev_jac_sparsity( + bool dependency , + const vector& parameter_x , + const vector& type_x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + InternalSparsity& var_sparsity ) +{ typedef typename InternalSparsity::const_iterator iterator; + + // number of arguments and resutls for this atomic function + size_t n = x_index.size(); + size_t m = y_index.size(); + + // selection vectors + vector select_x(n), select_y(m); + + // 2DO: perhaps we could use for_type(type_x, type_y) + // to reduce the true components in select_x + for(size_t j = 0; j < n; ++j) + select_x[j] = true; + + // determine select_y + for(size_t i = 0; i < m; ++i) + { // check if y_i has sparsity is non-empty + iterator itr(var_sparsity, y_index[i]); + size_t ell = *itr; + select_y[i] = ell < var_sparsity.end(); + } + sparse_rc< vector > pattern_out; + bool ok = jac_sparsity( + parameter_x, type_x, dependency, select_x, select_y, pattern_out + ); + if( ! ok ) + return false; + // + // transfer sparsity patterns from pattern_out to var_sparsity + size_t nnz = pattern_out.nnz(); + const vector& row( pattern_out.row() ); + const vector& col( pattern_out.col() ); + for(size_t k = 0; k < nnz; ++k) + { size_t i = row[k]; + size_t j = col[k]; + CPPAD_ASSERT_KNOWN( + select_y[i] & select_x[j], + "atomic: jac_sparsity: pattern_out not in " + "select_x or select_y range" + ); + iterator itr(var_sparsity, y_index[i]); + size_t ell = *itr; + while( ell < var_sparsity.end() ) + { var_sparsity.post_element( x_index[j], ell ); + ell = *(++itr); + } + } + for(size_t j = 0; j < n; ++j) + var_sparsity.process_post( x_index[j] ); + // + return true; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/three_rev_depend.hpp cppad-2019.02.00.0/include/cppad/core/atomic/three_rev_depend.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/three_rev_depend.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/three_rev_depend.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,126 @@ +# ifndef CPPAD_CORE_ATOMIC_THREE_REV_DEPEND_HPP +# define CPPAD_CORE_ATOMIC_THREE_REV_DEPEND_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three_rev_depend$$ +$spell + afun + enum + cpp + taylor.hpp +$$ + +$section Atomic Function Reverse Dependency Calculation$$ + +$head Syntax$$ +$icode%ok% = %afun%.rev_depend( + %parameter_x%, %type_x%, %depend_x%, %depend_y% +)%$$ + +$subhead Prototype$$ +$srcfile%include/cppad/core/atomic/three_rev_depend.hpp + %0%// BEGIN_PROTOTYPE%// END_PROTOTYPE%1 +%$$ + +$head Dependency Analysis$$ +This calculation is sometimes referred to as a reverse dependency analysis. + +$head Implementation$$ +This function must be defined if +$cref/afun/atomic_three_ctor/atomic_user/afun/$$ is +used to define an $cref ADFun$$ object $icode f$$, +and $cref/f.optimize()/optimize/$$ is used. + +$head Base$$ +See $cref/Base/atomic_three_afun/Base/$$. + +$head parameter_x$$ +See $cref/parameter_x/atomic_three/parameter_x/$$. + +$head type_x$$ +See $cref/type_x/atomic_three/type_x/$$. + +$head depend_x$$ +This vector has size equal to the number of arguments for this atomic function; +i.e. $icode%n%=%ax%.size()%$$. +The input values of the elements of $icode depend_x$$ +are not specified (must not matter). +Upon return, for $latex j = 0 , \ldots , n-1$$, +$icode%depend_x%[%j%]%$$ is true if the values of interest depend +on the value of $cref/ax[j]/atomic_three_afun/ax/$$ in the corresponding +$icode%afun%(%ax%, %ay%)%$$ call. +Note that parameters and variables, +that the values of interest do not depend on, +may get removed by $cref/optimization/optimize/$$. +The corresponding values in $cref/parameter_x/atomic_three/parameter_x/$$, +and $cref/taylor_x/atomic_three_forward/taylor_x/$$ +(after optimization has removed them) are not specified. + +$head depend_y$$ +This vector has size equal to the number of results for this atomic function; +i.e. $icode%m%=%ay%.size()%$$. +For $latex i = 0 , \ldots , m-1$$, +$icode%depend_y%[%i%]%$$ is true if the values of interest depend +on the value of $cref/ay[i]/atomic_three_afun/ay/$$ in the corresponding +$icode%afun%(%ax%, %ay%)%$$ call. + +$head ok$$ +If this calculation succeeded, $icode ok$$ is true. +Otherwise, it is false. + +$childtable% + example/atomic_three/rev_depend.cpp +%$$ +$head Example$$ +The following is an example of a atomic function $code rev_depend$$ definition: +$cref atomic_three_rev_depend.cpp$$. + + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/three_rev_depend.hpp +Third generation atomic type computation. +*/ +/*! +Link from atomic_three to reverse dependency calculation + +\param parameter_x [in] +is the value of the parameters in the corresponding function call +afun(ax, ay). + +\param type_x [in] +is the value for each of the components of x. + +\param depend_x [out] +specifies which components of x affect values of interest. + +\param depend_y [in] +specifies which components of y affect values of interest. +*/ +// BEGIN_PROTOTYPE +template +bool atomic_three::rev_depend( + const vector& parameter_x , + const vector& type_x , + vector& depend_x , + const vector& depend_y ) +// END_PROTOTYPE +{ return false; } + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/three_reverse.hpp cppad-2019.02.00.0/include/cppad/core/atomic/three_reverse.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/three_reverse.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/three_reverse.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,339 @@ +# ifndef CPPAD_CORE_ATOMIC_THREE_REVERSE_HPP +# define CPPAD_CORE_ATOMIC_THREE_REVERSE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_three_reverse$$ +$spell + sq + mul.hpp + afun + ty + px + py + Taylor + const + CppAD + atx + aty + apx + apy + af + aparameter +$$ + +$section Atomic Function Reverse Mode$$ +$spell + ataylor + apartial +$$ + +$head Base$$ +This syntax is used by $icode%f%.Reverse%$$ where $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +and $icode afun$$ is used in $icode f$$; +see $cref/Base/atomic_three_afun/Base/$$. + +$subhead Syntax$$ +$icode%ok% = %afun%.reverse( + %parameter_x%, %type_x%, + %order_up%, %taylor_x%, %taylor_y%, %partial_x%, %partial_y% +) +%$$ + +$subhead Prototype$$ +$srcfile%include/cppad/core/atomic/three_reverse.hpp + %0%// BEGIN_PROTOTYPE_BASE%// END_PROTOTYPE_BASE%1 +%$$ + +$head AD$$ +This syntax is used by $icode%af%.Reverse%$$ where $icode af$$ has prototype +$codei% + ADFun< AD<%Base%> , %Base% > %af% +%$$ +and $icode afun$$ is used in $icode af$$ (see $cref base2ad$$). + +$subhead Syntax$$ +$icode%ok% = %afun%.reverse( + %aparameter_x%, %type_x%, + %order_up%, %ataylor_x%, %ataylor_y%, %apartial_x%, %apartial_y% +) +%$$ + +$subhead Prototype$$ +$srcfile%include/cppad/core/atomic/three_reverse.hpp + %0%// BEGIN_PROTOTYPE_AD_BASE%// END_PROTOTYPE_AD_BASE%1 +%$$ + +$head Implementation$$ +This function must be defined if +$cref/afun/atomic_three_ctor/atomic_user/afun/$$ is +used to define an $cref ADFun$$ object $icode f$$, +and reverse mode derivatives are computed for $icode f$$. +It can return $icode%ok% == false%$$ +(and not compute anything) for values +of $icode order_up$$ that are greater than those used by your +$cref/reverse/Reverse/$$ mode calculations. + +$head parameter_x$$ +See $cref/parameter_x/atomic_three/parameter_x/$$. + +$head aparameter_x$$ +The specifications for $icode aparameter_x$$ +is the same as for $cref/parameter_x/atomic_three/parameter_x/$$ +(only the type of $icode ataylor_x$$ is different). + +$head type_x$$ +See $cref/type_x/atomic_three/type_x/$$. + +$head order_up$$ +This argument specifies the highest order Taylor coefficient that +computing the derivative of. + +$head taylor_x$$ +The size of $icode taylor_x$$ is $codei%(%q%+1)*%n%$$. +For $latex j = 0 , \ldots , n-1$$ and $latex k = 0 , \ldots , q$$, +we use the Taylor coefficient notation +$latex \[ +\begin{array}{rcl} + x_j^k & = & \R{taylor\_x} [ j * ( q + 1 ) + k ] + \\ + X_j (t) & = & x_j^0 + x_j^1 t^1 + \cdots + x_j^q t^q +\end{array} +\] $$ +Note that superscripts represent an index for $latex x_j^k$$ +and an exponent for $latex t^k$$. +Also note that the Taylor coefficients for $latex X(t)$$ correspond +to the derivatives of $latex X(t)$$ at $latex t = 0$$ in the following way: +$latex \[ + x_j^k = \frac{1}{ k ! } X_j^{(k)} (0) +\] $$ + +$head ataylor_x$$ +The specifications for $icode ataylor_x$$ is the same as for $icode taylor_x$$ +(only the type of $icode ataylor_x$$ is different). + +$head taylor_y$$ +The size of $icode taylor_y$$ is $codei%(%q%+1)*%m%$$. +Upon return, +For $latex i = 0 , \ldots , m-1$$ and $latex k = 0 , \ldots , q$$, +we use the Taylor coefficient notation +$latex \[ +\begin{array}{rcl} + Y_i (t) & = & g_i [ X(t) ] + \\ + Y_i (t) & = & y_i^0 + y_i^1 t^1 + \cdots + y_i^q t^q + o ( t^q ) + \\ + y_i^k & = & \R{taylor\_y} [ i * ( q + 1 ) + k ] +\end{array} +\] $$ +where $latex o( t^q ) / t^q \rightarrow 0$$ as $latex t \rightarrow 0$$. +Note that superscripts represent an index for $latex y_j^k$$ +and an exponent for $latex t^k$$. +Also note that the Taylor coefficients for $latex Y(t)$$ correspond +to the derivatives of $latex Y(t)$$ at $latex t = 0$$ in the following way: +$latex \[ + y_j^k = \frac{1}{ k ! } Y_j^{(k)} (0) +\] $$ + +$head ataylor_y$$ +The specifications for $icode ataylor_y$$ is the same as for $icode taylor_y$$ +(only the type of $icode ataylor_y$$ is different). + +$head F$$ +We use the notation $latex \{ x_j^k \} \in \B{R}^{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{R}^{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{R}^{n \times (q+1)} \rightarrow \B{R}^{m \times (q+1)}$$ by +$latex \[ + y_i^k = F_i^k [ \{ x_j^k \} ] +\] $$ +Note that +$latex \[ + F_i^0 ( \{ x_j^k \} ) = g_i ( X(0) ) = g_i ( x^0 ) +\] $$ +We also note that +$latex F_i^\ell ( \{ x_j^k \} )$$ is a function of +$latex x^0 , \ldots , x^\ell$$ +and is determined by the derivatives of $latex g_i (x)$$ +up to order $latex \ell$$. + +$head G, H$$ +We use $latex G : \B{R}^{m \times (q+1)} \rightarrow \B{R}$$ +to denote an arbitrary scalar valued function of $latex \{ y_i^k \}$$. +We use $latex H : \B{R}^{n \times (q+1)} \rightarrow \B{R}$$ +defined by +$latex \[ + H ( \{ x_j^k \} ) = G[ F( \{ x_j^k \} ) ] +\] $$ + +$head partial_y$$ +The size of $icode partial_y$$ is $codei%(%q%+1)*%m%%$$. +For $latex i = 0 , \ldots , m-1$$, $latex k = 0 , \ldots , q$$, +$latex \[ + \R{partial\_y} [ i * (q + 1 ) + k ] = \partial G / \partial y_i^k +\] $$ + +$head apartial_y$$ +The specifications for $icode apartial_y$$ is the same as for +$icode partial_y$$ (only the type of $icode apartial_y$$ is different). + +$head partial_x$$ +The size of $icode partial_x$$ is $codei%(%q%+1)*%n%%$$. +The input values of the elements of $icode partial_x$$ +are not specified (must not matter). +Upon return, +for $latex j = 0 , \ldots , n-1$$ and $latex \ell = 0 , \ldots , q$$, +$latex \[ +\begin{array}{rcl} +\R{partial\_x} [ j * (q + 1) + \ell ] & = & \partial H / \partial x_j^\ell +\\ +& = & +( \partial G / \partial \{ y_i^k \} ) \cdot + ( \partial \{ y_i^k \} / \partial x_j^\ell ) +\\ +& = & +\sum_{k=0}^q +\sum_{i=0}^{m-1} +( \partial G / \partial y_i^k ) ( \partial y_i^k / \partial x_j^\ell ) +\\ +& = & +\sum_{k=\ell}^q +\sum_{i=0}^{m-1} +\R{partial\_y}[ i * (q + 1 ) + k ] ( \partial F_i^k / \partial x_j^\ell ) +\end{array} +\] $$ +Note that we have used the fact that for $latex k < \ell$$, +$latex \partial F_i^k / \partial x_j^\ell = 0$$. + +$subhead Short Circuit Operations$$ +Note that if +$codei%IdenticalZero(%partial_y%[%i%*(%q%+1)+%k%])%$$ is true, +one does not need to compute $latex ( \partial F_i^k / \partial x_j^\ell )$$; +see $cref base_identical$$. +This can be used, +in a similar way to $cref/need_y/atomic_three_forward/need_y/$$, +to avoid unnecessary operations. + +$head apartial_x$$ +The specifications for $icode apartial_x$$ is the same as for +$icode partial_x$$ (only the type of $icode apartial_x$$ is different). + +$head ok$$ +If this calculation succeeded, $icode ok$$ is true. +Otherwise it is false. + +$children% + example/atomic_three/reverse.cpp +%$$ +$head Examples$$ +The file $cref atomic_three_reverse.cpp$$ contains an example and test +that uses this routine. + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/three_reverse.hpp +Third Generation Atomic reverse mode. +*/ +/*! +Link from reverse mode sweep to users routine. + +\param parameter_x [in] +contains the values, in afun(ax, ay), for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param order_up [in] +highest order for this reverse mode calculation. + +\param taylor_x [in] +Taylor coefficients corresponding to x for this calculation. + +\param taylor_y [in] +Taylor coefficient corresponding to y for this calculation + +\param partial_x [out] +Partials w.r.t. the x Taylor coefficients. + +\param partial_y [in] +Partials w.r.t. the y Taylor coefficients. + +See atomic_three_reverse mode use documentation +*/ +// BEGIN_PROTOTYPE_BASE +template +bool atomic_three::reverse( + const vector& parameter_x , + const vector& type_x , + size_t order_up , + const vector& taylor_x , + const vector& taylor_y , + vector& partial_x , + const vector& partial_y ) +// END_PROTOTYPE_BASE +{ return false; } + +/*! +Link from reverse mode sweep to users routine. + +\param aparameter_x [in] +contains the values, in afun(ax, ay), for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + + +\param order_up [in] +highest order for this reverse mode calculation. + +\param ataylor_x [in] +Taylor coefficients corresponding to x for this calculation. + +\param ataylor_y [in] +Taylor coefficient corresponding to y for this calculation + +\param apartial_x [out] +Partials w.r.t. the x Taylor coefficients. + +\param apartial_y [in] +Partials w.r.t. the y Taylor coefficients. + +See atomic_three_reverse mode use documentation +*/ +// BEGIN_PROTOTYPE_AD_BASE +template +bool atomic_three::reverse( + const vector< AD >& aparameter_x , + const vector& type_x , + size_t order_up , + const vector< AD >& ataylor_x , + const vector< AD >& ataylor_y , + vector< AD >& apartial_x , + const vector< AD >& apartial_y ) +// END_PROTOTYPE_AD_BASE +{ return false; } + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/two_afun.hpp cppad-2019.02.00.0/include/cppad/core/atomic/two_afun.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/two_afun.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/two_afun.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,258 @@ +# ifndef CPPAD_CORE_ATOMIC_TWO_AFUN_HPP +# define CPPAD_CORE_ATOMIC_TWO_AFUN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_afun$$ + +$spell + sq + mul + afun + const + CppAD + mat_mul.cpp +$$ + +$section Using AD Version of Atomic Function$$ + +$head Syntax$$ +$icode%afun%(%ax%, %ay%)%$$ + +$head Purpose$$ +Given $icode ax$$, +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/$$. + +$head ADVector$$ +The type $icode ADVector$$ must be a +$cref/simple vector class/SimpleVector/$$ with elements of type +$codei%AD<%Base%>%$$; see $cref/Base/atomic_two_ctor/atomic_base/Base/$$. + +$head afun$$ +is a $cref/atomic_user/atomic_two_ctor/atomic_user/$$ object +and this $icode afun$$ function call is implemented by the +$cref/atomic/atomic_two_ctor/atomic_base/$$ class. + +$head ax$$ +This argument has prototype +$codei% + const %ADVector%& %ax% +%$$ +and size must be equal to $icode n$$. +It specifies vector $latex x \in \B{R}^n$$ +at which an $codei%AD<%Base%>%$$ version of +$latex y = f(x)$$ is to be evaluated; see +$cref/Base/atomic_two_ctor/atomic_base/Base/$$. + +$head ay$$ +This argument has prototype +$codei% + %ADVector%& %ay% +%$$ +and size must be equal to $icode m$$. +The input values of its elements +are not specified (must not matter). +Upon return, it is an $codei%AD<%Base%>%$$ version of +$latex y = f(x)$$. + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/two_afun.hpp +Implement user call to an atomic_two function. +*/ + +/*! +Implement the user call to afun(ax, ay) and atomic_one call to +afun(ax, ay, id). + +\tparam ADVector +A simple vector class with elements of type AD. + +\param id +optional extra information vector that is just passed through by CppAD, +and used by atomic_one derived class (not other derived classes). +This is an extra parameter to the virtual callbacks for atomic_one; +see the set_old member function. + +\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. +*/ +template +template +void atomic_base::operator()( + const ADVector& ax , + ADVector& ay , + size_t id ) +{ size_t i, j; + size_t n = ax.size(); + size_t m = ay.size(); +# ifndef NDEBUG + bool ok; + std::string msg = "atomic_base: " + afun_name() + ".eval: "; + if( (n == 0) | (m == 0) ) + { msg += "ax.size() or ay.size() is zero"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# endif + size_t thread = thread_alloc::thread_num(); + allocate_work(thread); + vector & tx = work_[thread]->tx; + vector & ty = work_[thread]->ty; + vector & vx = work_[thread]->vx; + vector & vy = work_[thread]->vy; + // + if( vx.size() != n ) + { vx.resize(n); + tx.resize(n); + } + if( vy.size() != m ) + { vy.resize(m); + ty.resize(m); + } + // + // Determine tape corresponding to variables in ax + tape_id_t tape_id = 0; + local::ADTape* tape = CPPAD_NULL; + for(j = 0; j < n; j++) + { tx[j] = ax[j].value_; + vx[j] = ! Constant( ax[j] ); + if( vx[j] ) + { + if( tape_id == 0 ) + { tape = ax[j].tape_this(); + tape_id = ax[j].tape_id_; + CPPAD_ASSERT_UNKNOWN( tape != CPPAD_NULL ); + } +# ifndef NDEBUG + if( tape_id != ax[j].tape_id_ ) + { msg += afun_name() + + ": ax contains variables from different threads."; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } +# endif + } + } + // Use zero order forward mode to compute values + size_t p = 0, q = 0; + set_old(id); +# ifdef NDEBUG + forward(p, q, vx, vy, tx, ty); +# else + ok = forward(p, q, vx, vy, tx, ty); + if( ! ok ) + { msg += afun_name() + ": ok is false for " + "zero order forward mode calculation."; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } +# endif + bool record_operation = false; + for(i = 0; i < m; i++) + { + // pass back values + ay[i].value_ = ty[i]; + + // initialize entire vector parameters (not in tape) + ay[i].tape_id_ = 0; + ay[i].taddr_ = 0; + + // we need to record this operation if + // any of the elemnts of ay are variables, + record_operation |= vy[i]; + } +# ifndef NDEBUG + if( record_operation & (tape == CPPAD_NULL) ) + { msg += + "all elements of vx are false but vy contains a true element"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# endif + // if tape is not null, ay is on the tape + if( record_operation ) + { + // Operator that marks beginning of this atomic operation + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::AFunOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::AFunOp) == 4 ); + CPPAD_ASSERT_KNOWN( + size_t( std::numeric_limits::max() ) >= + std::max( std::max( std::max(index_, id), n), m ), + "atomic_base: cppad_tape_addr_type maximum not large enough" + ); + tape->Rec_.PutArg(addr_t(index_), addr_t(id), addr_t(n), addr_t(m)); + tape->Rec_.PutOp(local::AFunOp); + + // Now put n operators, one for each element of argument vector + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::FunavOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::FunapOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::FunavOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::FunapOp) == 1 ); + for(j = 0; j < n; j++) + { if( Variable(ax[j]) ) + { // information for an argument that is a variable + tape->Rec_.PutArg(ax[j].taddr_); + tape->Rec_.PutOp(local::FunavOp); + } + else + { // information for an argument that is parameter + addr_t par = ax[j].taddr_; + if( ! Dynamic( ax[j] ) ) + par = tape->Rec_.put_con_par(ax[j].value_); + tape->Rec_.PutArg(par); + tape->Rec_.PutOp(local::FunapOp); + } + } + + // Now put m operators, one for each element of result vector + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::FunrpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::FunrpOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::FunrvOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::FunrvOp) == 1 ); + for(i = 0; i < m; i++) + { if( vy[i] ) + { ay[i].taddr_ = tape->Rec_.PutOp(local::FunrvOp); + ay[i].tape_id_ = tape_id; + ay[i].ad_type_ = variable_enum; + } + else + { CPPAD_ASSERT_UNKNOWN( ! Dynamic( ay[i] ) ); + addr_t par = tape->Rec_.put_con_par(ay[i].value_); + tape->Rec_.PutArg(par); + tape->Rec_.PutOp(local::FunrpOp); + } + } + + // Put a duplicate AFunOp at end of AFunOp sequence + CPPAD_ASSERT_KNOWN( + size_t( std::numeric_limits::max() ) >= + std::max( std::max( std::max(index_, id), n), m ), + "atomic_base: cppad_tape_addr_type maximum not large enough" + ); + tape->Rec_.PutArg(addr_t(index_), addr_t(id), addr_t(n), addr_t(m)); + tape->Rec_.PutOp(local::AFunOp); + } + return; +} + + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/two_clear.hpp cppad-2019.02.00.0/include/cppad/core/atomic/two_clear.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/two_clear.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/two_clear.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,91 @@ +# ifndef CPPAD_CORE_ATOMIC_TWO_CLEAR_HPP +# define CPPAD_CORE_ATOMIC_TWO_CLEAR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_clear$$ +$spell + sq + alloc +$$ + +$section Free Static Variables$$ + +$head Syntax$$ +$codei%atomic_base<%Base%>::clear()%$$ + +$head Purpose$$ +Each $code atomic_base$$ objects holds onto work space in order to +avoid repeated memory allocation calls and thereby increase speed +(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. +Calling this $code clear$$ function will free all the +memory currently being held onto by the +$codei%atomic_base<%Base%>%$$ class. + +$head Future Use$$ +If there is future use of an $code atomic_base$$ object, +after a call to $code clear$$, +the work space will be reallocated and held onto. + +$head Restriction$$ +This routine cannot be called +while in $cref/parallel/ta_in_parallel/$$ execution mode. + +$end +------------------------------------------------------------------------------ +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/two_clear.hpp +Free static variables in atomic_base class. +*/ +/*! +Free all thread_alloc static memory held by atomic_base (avoids reallocations). +(This does not include class_object() which is an std::vector.) +*/ +template +void atomic_base::clear(void) +{ CPPAD_ASSERT_KNOWN( + ! thread_alloc::in_parallel() , + "cannot use atomic_base clear during parallel execution" + ); + bool set_null = true; + size_t index = 0; + size_t type = 0; // set to avoid warning + std::string* name = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + size_t n_atomic = local::atomic_index( + set_null, index, type, name, v_ptr + ); + // + set_null = false; + for(index = 1; index <= n_atomic; ++index) + { local::atomic_index(set_null, index, type, name, v_ptr); + if( type == 2 ) + { atomic_base* op = reinterpret_cast(v_ptr); + if( op != CPPAD_NULL ) + { for(size_t thread = 0; thread < CPPAD_MAX_NUM_THREADS; thread++) + op->free_work(thread); + } + } + } + return; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/two_ctor.hpp cppad-2019.02.00.0/include/cppad/core/atomic/two_ctor.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/two_ctor.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/two_ctor.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,173 @@ +# ifndef CPPAD_CORE_ATOMIC_TWO_CTOR_HPP +# define CPPAD_CORE_ATOMIC_TWO_CTOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_ctor$$ +$spell + enum + sq + std + afun + arg + CppAD + bool + ctor + const + mat_mul_xam.cpp + hpp +$$ + +$section Atomic Function Constructor$$ + +$head Syntax$$ +$icode%atomic_user afun%(%ctor_arg_list%) +%$$ +$codei%atomic_base<%Base%>(%name%, %sparsity%) +%$$ + +$head atomic_user$$ + +$subhead ctor_arg_list$$ +Is a list of arguments for the $icode atomic_user$$ constructor. + +$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 +$cref/operation sequence/glossary/Operation/Sequence/$$. + +$subhead Implementation$$ +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%, %sparsity%) + %...% + }; +%$$ +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 +$icode atomic_user$$ implementations. + +$head atomic_base$$ + +$subhead Restrictions$$ +The $code atomic_base$$ constructor and destructor cannot be called in +$cref/parallel/ta_in_parallel/$$ mode. + +$subhead Base$$ +The template parameter determines the +$icode Base$$ type for this $codei%AD<%Base%>%$$ atomic operation. + +$subhead name$$ +This $code atomic_base$$ constructor argument has the following prototype +$codei% + 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). + +$end +------------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/two_ctor.hpp +Constructors for atomic_base class. +*/ + +/*! +Base class for atomic_atomic functions. + +\tparam Base +This class is used for defining an AD atomic operation y = f(x). + +\par +make sure user does not invoke the default constructor +*/ +template +atomic_base::atomic_base(void) +{ CPPAD_ASSERT_KNOWN(false, + "Attempt to use the atomic_base default constructor" + ); +} +/*! +Constructor + +\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. +*/ +template +atomic_base::atomic_base( + const std::string& name, + option_enum sparsity +) : +sparsity_( sparsity ) +{ CPPAD_ASSERT_KNOWN( + ! thread_alloc::in_parallel() , + "atomic_base: constructor cannot be called in parallel mode." + ); + CPPAD_ASSERT_UNKNOWN( constant_enum < dynamic_enum ); + CPPAD_ASSERT_UNKNOWN( dynamic_enum < variable_enum ); + // + // atomic_index + bool set_null = false; + size_t index = 0; + size_t type = 2; + std::string copy_name = name; + void* copy_this = reinterpret_cast( this ); + index_ = local::atomic_index( + set_null, index, type, ©_name, copy_this + ); + // initialize work pointers as null; + for(size_t thread = 0; thread < CPPAD_MAX_NUM_THREADS; thread++) + work_[thread] = CPPAD_NULL; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/two_for_sparse_hes.hpp cppad-2019.02.00.0/include/cppad/core/atomic/two_for_sparse_hes.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/two_for_sparse_hes.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/two_for_sparse_hes.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,351 @@ +# ifndef CPPAD_CORE_ATOMIC_TWO_FOR_SPARSE_HES_HPP +# define CPPAD_CORE_ATOMIC_TWO_FOR_SPARSE_HES_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_for_sparse_hes$$ +$spell + sq + mul.hpp + vx + afun + Jacobian + jac + CppAD + std + bool + hes + const +$$ + +$section Atomic Forward Hessian Sparsity Patterns$$ + +$head Syntax$$ +$icode%ok% = %afun%.for_sparse_hes(%vx%, %r%, %s%, %h%, %x%)%$$ + +$head Deprecated 2016-06-27$$ +$icode%ok% = %afun%.for_sparse_hes(%vx%, %r%, %s%, %h%)%$$ + +$head Purpose$$ +This function is used by $cref ForSparseHes$$ to compute +Hessian sparsity patterns. +If you are using $cref ForSparseHes$$, +one of the versions of this +virtual function must be defined by the +$cref/atomic_user/atomic_two_ctor/atomic_user/$$ class. +$pre + +$$ +Given a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for +a diagonal matrix $latex R \in \B{R}^{n \times n}$$, and +a row vector $latex S \in \B{R}^{1 \times m}$$, +this routine computes the sparsity pattern for +$latex \[ + H(x) = R^\R{T} \cdot (S \cdot f)^{(2)}( x ) \cdot R +\] $$ + +$head Implementation$$ +If you are using and $cref ForSparseHes$$, +this virtual function must be defined by the +$cref/atomic_user/atomic_two_ctor/atomic_user/$$ class. + +$subhead vx$$ +The argument $icode vx$$ has prototype +$codei% + const CppAD:vector& %vx% +%$$ +$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/$$ +or $cref/dynamic parameter/glossary/Parameter/Dynamic/$$ +in the corresponding call to +$codei% + %afun%(%ax%, %ay%) +%$$ + +$subhead r$$ +This argument has prototype +$codei% + const CppAD:vector& %r% +%$$ +and is a $cref/atomic_sparsity/atomic_two_option/atomic_sparsity/$$ pattern for +the diagonal of $latex R \in \B{R}^{n \times n}$$. + +$subhead s$$ +The argument $icode s$$ has prototype +$codei% + const CppAD:vector& %s% +%$$ +and its size is $icode m$$. +It is a sparsity pattern for $latex S \in \B{R}^{1 \times m}$$. + +$subhead h$$ +This argument has prototype +$codei% + %atomic_sparsity%& %h% +%$$ +The input value of its elements +are not specified (must not matter). +Upon return, $icode h$$ is a +$cref/atomic_sparsity/atomic_two_option/atomic_sparsity/$$ pattern for +$latex H(x) \in \B{R}^{n \times n}$$ which is defined above. + +$subhead x$$ +$index deprecated$$ +The argument has prototype +$codei% + const CppAD::vector<%Base%>& %x% +%$$ +and size is equal to the $icode n$$. +This is the $cref Value$$ value corresponding to the parameters in the +vector $cref/ax/atomic_two_afun/ax/$$ (when the atomic function was called). +To be specific, if +$codei% + if( Parameter(%ax%[%i%]) == true ) + %x%[%i%] = Value( %ax%[%i%] ); + else + %x%[%i%] = CppAD::numeric_limits<%Base%>::quiet_NaN(); +%$$ +The version of this function with out the $icode x$$ argument is deprecated; +i.e., you should include the argument even if you do not use it. + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/two_for_sparse_hes.hpp +Atomic forward mode Hessian sparsity patterns. +*/ +/*! +Link, after case split, from for_hes_sweep to atomic_base. + +\param vx [in] +which componens of x are variables. + +\param r [in] +is the forward Jacobian sparsity pattern w.r.t the argument vector x. + +\param s [in] +is the reverse Jacobian sparsity pattern w.r.t the result vector y. + +\param h [out] +is the Hessian sparsity pattern w.r.t the argument vector x. + +\param x +is the integer value of the x arguments that are parameters. +*/ +template +bool atomic_base::for_sparse_hes( + const vector& vx , + const vector& r , + const vector& s , + vector< std::set >& h , + const vector& x ) +{ return false; } +template +bool atomic_base::for_sparse_hes( + const vector& vx , + const vector& r , + const vector& s , + vector& h , + const vector& x ) +{ return false; } +template +bool atomic_base::for_sparse_hes( + const vector& vx , + const vector& r , + const vector& s , + vectorBool& h , + const vector& x ) +// deprecated versions +{ return false; } +template +bool atomic_base::for_sparse_hes( + const vector& vx , + const vector& r , + const vector& s , + vector< std::set >& h ) +{ return false; } +template +bool atomic_base::for_sparse_hes( + const vector& vx , + const vector& r , + const vector& s , + vector& h ) +{ return false; } +template +bool atomic_base::for_sparse_hes( + const vector& vx , + const vector& r , + const vector& s , + vectorBool& h ) +{ return false; } +/*! +Link, before case split, from for_hes_sweep to atomic_base. + +\tparam InternalSparsity +Is the used internaly for sparsity calculations; i.e., +sparse_pack or sparse_list. + +\param x +is parameter arguments to the function, other components are nan. + +\param x_index +is the variable index, on the tape, for the arguments to this function. +This size of x_index is n, the number of arguments to this function. + +\param y_index +is the variable index, on the tape, for the results for this function. +This size of y_index is m, the number of results for this function. + +\param for_jac_sparsity +On input, for j = 0, ... , n-1, the sparsity pattern with index x_index[j], +is the forward Jacobian sparsity for the j-th argument to this atomic function. + +\param rev_jac_sparsity +On input, for i = 0, ... , m-1, the sparsity pattern with index y_index[i], +is the reverse Jacobian sparsity for the i-th result to this atomic function. +This shows which components of the result affect the function we are +computing the Hessian of. + +\param for_hes_sparsity +This is the sparsity pattern for the Hessian. On input, the non-linear +terms in the atomic fuction have not been included. Upon return, they +have been included. +*/ +template +template +bool atomic_base::for_sparse_hes( + const vector& x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + const InternalSparsity& for_jac_sparsity , + const InternalSparsity& rev_jac_sparsity , + InternalSparsity& for_hes_sparsity ) +{ typedef typename InternalSparsity::const_iterator const_iterator; + CPPAD_ASSERT_UNKNOWN( rev_jac_sparsity.end() == 1 ); + size_t n = x_index.size(); + size_t m = y_index.size(); + bool ok = false; + size_t thread = thread_alloc::thread_num(); + allocate_work(thread); + // + // vx + vector vx(n); + for(size_t j = 0; j < n; j++) + vx[j] = x_index[j] != 0; + // + // bool_r + vector& bool_r( work_[thread]->bool_r ); + bool_r.resize(n); + for(size_t j = 0; j < n; j++) + { // check if we must compute row and column j of h + const_iterator itr(for_jac_sparsity, x_index[j]); + size_t i = *itr; + bool_r[j] = i < for_jac_sparsity.end(); + } + // + // bool s + vector& bool_s( work_[thread]->bool_s ); + bool_s.resize(m); + for(size_t i = 0; i < m; i++) + { // check if row i of result is included in h + bool_s[i] = rev_jac_sparsity.is_element(y_index[i], 0); + } + // + // h + vectorBool& pack_h( work_[thread]->pack_h ); + vector& bool_h( work_[thread]->bool_h ); + vector< std::set >& set_h( work_[thread]->set_h ); + // + // call user's version of atomic function + std::string msg = ": atomic_base.for_sparse_hes: returned false"; + if( sparsity_ == pack_sparsity_enum ) + { pack_h.resize(n * n); + ok = for_sparse_hes(vx, bool_r, bool_s, pack_h, x); + if( ! ok ) + ok = for_sparse_hes(vx, bool_r, bool_s, pack_h); + if( ! ok ) + { msg = afun_name() + msg + " sparsity = pack_sparsity_enum"; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } + } + else if( sparsity_ == bool_sparsity_enum ) + { bool_h.resize(n * n); + ok = for_sparse_hes(vx, bool_r, bool_s, bool_h, x); + if( ! ok ) + ok = for_sparse_hes(vx, bool_r, bool_s, bool_h); + if( ! ok ) + { msg = afun_name() + msg + " sparsity = bool_sparsity_enum"; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } + } + else + { CPPAD_ASSERT_UNKNOWN( sparsity_ == set_sparsity_enum ) + set_h.resize(n); + ok = for_sparse_hes(vx, bool_r, bool_s, set_h, x); + if( ! ok ) + ok = for_sparse_hes(vx, bool_r, bool_s, set_h); + if( ! ok ) + { msg = afun_name() + msg + " sparsity = set_sparsity_enum"; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } + } + CPPAD_ASSERT_UNKNOWN( ok ); + // + // modify hessian in calling routine + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n; j++) + { if( (x_index[i] > 0) & (x_index[j] > 0) ) + { bool flag = false; + switch( sparsity_ ) + { case pack_sparsity_enum: + flag = pack_h[i * n + j]; + break; + // + case bool_sparsity_enum: + flag = bool_h[i * n + j]; + break; + // + case set_sparsity_enum: + flag = set_h[i].find(j) != set_h[i].end(); + break; + } + if( flag ) + { const_iterator itr_i(for_jac_sparsity, x_index[i]); + size_t i_x = *itr_i; + while( i_x < for_jac_sparsity.end() ) + { for_hes_sparsity.binary_union( + i_x, i_x, x_index[j], for_jac_sparsity + ); + i_x = *(++itr_i); + } + const_iterator itr_j(for_jac_sparsity, x_index[j]); + size_t j_x = *itr_j; + while( j_x < for_jac_sparsity.end() ) + { for_hes_sparsity.binary_union( + j_x, j_x, x_index[i], for_jac_sparsity + ); + j_x = *(++itr_j); + } + } + } + } + } + return ok; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/two_for_sparse_jac.hpp cppad-2019.02.00.0/include/cppad/core/atomic/two_for_sparse_jac.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/two_for_sparse_jac.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/two_for_sparse_jac.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,283 @@ +# ifndef CPPAD_CORE_ATOMIC_TWO_FOR_SPARSE_JAC_HPP +# define CPPAD_CORE_ATOMIC_TWO_FOR_SPARSE_JAC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_for_sparse_jac$$ +$spell + sq + mul.hpp + afun + Jacobian + jac + const + CppAD + std + bool + std +$$ + +$section Atomic Forward Jacobian Sparsity Patterns$$ + +$head Syntax$$ +$icode%ok% = %afun%.for_sparse_jac(%q%, %r%, %s%, %x%) +%$$ + +$head Deprecated 2016-06-27$$ +$icode%ok% = %afun%.for_sparse_jac(%q%, %r%, %s%) +%$$ + +$head Purpose$$ +This function is used by $cref ForSparseJac$$ to compute +Jacobian sparsity patterns. +For a fixed matrix $latex R \in \B{R}^{n \times q}$$, +the Jacobian of $latex f( x + R * u)$$ with respect to $latex u \in \B{R}^q$$ is +$latex \[ + S(x) = f^{(1)} (x) * R +\] $$ +Given a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for $latex R$$, +$code for_sparse_jac$$ computes a sparsity pattern for $latex S(x)$$. + +$head Implementation$$ +If you are using +$cref ForSparseJac$$, +$cref ForSparseHes$$, or +$cref RevSparseHes$$, +one of the versions of this +virtual function must be defined by the +$cref/atomic_user/atomic_two_ctor/atomic_user/$$ class. + +$subhead q$$ +The argument $icode q$$ has prototype +$codei% + size_t %q% +%$$ +It specifies the number of columns in +$latex R \in \B{R}^{n \times q}$$ and the Jacobian +$latex S(x) \in \B{R}^{m \times q}$$. + +$subhead r$$ +This argument has prototype +$codei% + const %atomic_sparsity%& %r% +%$$ +and is a $cref/atomic_sparsity/atomic_two_option/atomic_sparsity/$$ pattern for +$latex R \in \B{R}^{n \times q}$$. + +$subhead s$$ +This argument has prototype +$codei% + %atomic_sparsity%& %s% +%$$ +The input values of its elements +are not specified (must not matter). +Upon return, $icode s$$ is a +$cref/atomic_sparsity/atomic_two_option/atomic_sparsity/$$ pattern for +$latex S(x) \in \B{R}^{m \times q}$$. + +$subhead x$$ +$index deprecated$$ +The argument has prototype +$codei% + const CppAD::vector<%Base%>& %x% +%$$ +and size is equal to the $icode n$$. +This is the $cref Value$$ value corresponding to the parameters in the +vector $cref/ax/atomic_two_afun/ax/$$ (when the atomic function was called). +To be specific, if +$codei% + if( Parameter(%ax%[%i%]) == true ) + %x%[%i%] = Value( %ax%[%i%] ); + else + %x%[%i%] = CppAD::numeric_limits<%Base%>::quiet_NaN(); +%$$ +The version of this function with out the $icode x$$ argument is deprecated; +i.e., you should include the argument even if you do not use it. + +$head ok$$ +The return value $icode ok$$ has prototype +$codei% + bool %ok% +%$$ +If it is $code true$$, the corresponding evaluation succeeded, +otherwise it failed. + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/two_for_sparse_jac.hpp +Atomic forward Jacobian sparsity pattern. +*/ +/*! +Link, after case split, from for_jac_sweep to atomic_base. + +\param q +is the column dimension for the Jacobian sparsity partterns. + +\param r +is the Jacobian sparsity pattern for the argument vector x + +\param s +is the Jacobian sparsity pattern for the result vector y + +\param x +is the integer value for x arguments that are parameters. +*/ +template +bool atomic_base::for_sparse_jac( + size_t q , + const vector< std::set >& r , + vector< std::set >& s , + const vector& x ) +{ return false; } +template +bool atomic_base::for_sparse_jac( + size_t q , + const vector& r , + vector& s , + const vector& x ) +{ return false; } +template +bool atomic_base::for_sparse_jac( + size_t q , + const vectorBool& r , + vectorBool& s , + const vector& x ) +{ return false; } +// deprecated versions +template +bool atomic_base::for_sparse_jac( + size_t q , + const vector< std::set >& r , + vector< std::set >& s ) +{ return false; } +template +bool atomic_base::for_sparse_jac( + size_t q , + const vector& r , + vector& s ) +{ return false; } +template +bool atomic_base::for_sparse_jac( + size_t q , + const vectorBool& r , + vectorBool& s ) +{ return false; } + +/*! +Link, before case split, from for_jac_sweep to atomic_base. + +\tparam InternalSparsity +Is the type used for internal sparsity calculations; i.e., +sparse_pack or sparse_list. + +\param x +is parameter arguments to the function, other components are nan. + +\param x_index +is the variable index, on the tape, for the arguments to this function. +This size of x_index is n, the number of arguments to this function. + +\param y_index +is the variable index, on the tape, for the results for this function. +This size of y_index is m, the number of results for this function. + +\param var_sparsity +On input, for j = 0, ... , n-1, the sparsity pattern with index x_index[j], +is the sparsity for the j-th argument to this atomic function. +On output, for i = 0, ... , m-1, the sparsity pattern with index y_index[i], +is the sparsity for the i-th result for this atomic function. +*/ +template +template +bool atomic_base::for_sparse_jac( + const vector& x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + InternalSparsity& var_sparsity ) +{ + // intial results are empty during forward mode + size_t q = var_sparsity.end(); + bool input_empty = true; + bool zero_empty = true; + bool transpose = false; + size_t m = y_index.size(); + bool ok = false; + size_t thread = thread_alloc::thread_num(); + allocate_work(thread); + // + std::string msg = ": atomic_base.for_sparse_jac: returned false"; + if( sparsity_ == pack_sparsity_enum ) + { vectorBool& pack_r ( work_[thread]->pack_r ); + vectorBool& pack_s ( work_[thread]->pack_s ); + local::get_internal_sparsity( + transpose, x_index, var_sparsity, pack_r + ); + // + pack_s.resize(m * q ); + ok = for_sparse_jac(q, pack_r, pack_s, x); + if( ! ok ) + ok = for_sparse_jac(q, pack_r, pack_s); + if( ! ok ) + { msg = afun_name() + msg + " sparsity = pack_sparsity_enum"; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } + local::set_internal_sparsity(zero_empty, input_empty, + transpose, y_index, var_sparsity, pack_s + ); + } + else if( sparsity_ == bool_sparsity_enum ) + { vector& bool_r ( work_[thread]->bool_r ); + vector& bool_s ( work_[thread]->bool_s ); + local::get_internal_sparsity( + transpose, x_index, var_sparsity, bool_r + ); + bool_s.resize(m * q ); + ok = for_sparse_jac(q, bool_r, bool_s, x); + if( ! ok ) + ok = for_sparse_jac(q, bool_r, bool_s); + if( ! ok ) + { msg = afun_name() + msg + " sparsity = bool_sparsity_enum"; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } + local::set_internal_sparsity(zero_empty, input_empty, + transpose, y_index, var_sparsity, bool_s + ); + } + else + { CPPAD_ASSERT_UNKNOWN( sparsity_ == set_sparsity_enum ); + vector< std::set >& set_r ( work_[thread]->set_r ); + vector< std::set >& set_s ( work_[thread]->set_s ); + local::get_internal_sparsity( + transpose, x_index, var_sparsity, set_r + ); + // + set_s.resize(m); + ok = for_sparse_jac(q, set_r, set_s, x); + if( ! ok ) + ok = for_sparse_jac(q, set_r, set_s); + if( ! ok ) + { msg = afun_name() + msg + " sparsity = set_sparsity_enum"; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } + local::set_internal_sparsity(zero_empty, input_empty, + transpose, y_index, var_sparsity, set_s + ); + } + return ok; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/two_forward.hpp cppad-2019.02.00.0/include/cppad/core/atomic/two_forward.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/two_forward.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/two_forward.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,402 @@ +# ifndef CPPAD_CORE_ATOMIC_TWO_FORWARD_HPP +# define CPPAD_CORE_ATOMIC_TWO_FORWARD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_forward$$ +$spell + sq + mul.hpp + hes + afun + vx + vy + ty + Taylor + const + CppAD + bool + atx + aty + af +$$ + +$section Atomic Forward Mode$$ + + +$head Syntax$$ + +$subhead Base$$ +$icode%ok% = %afun%.forward(%p%, %q%, %vx%, %vy%, %tx%, %ty%) +%$$ +This syntax is used by $icode%f%.Forward%$$ where $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +and $icode afun$$ is used in $icode f$$. + +$subhead AD$$ +$icode%ok% = %afun%.forward(%p%, %q%, %vx%, %vy%, %atx%, %aty%) +%$$ +This syntax is used by $icode%af%.Forward%$$ where $icode af$$ has prototype +$codei% + ADFun< AD<%Base%> , %Base% > %af% +%$$ +and $icode afun$$ is used in $icode af$$ (see $cref base2ad$$). + +$head Purpose$$ +This virtual function is used by $cref atomic_two_afun$$ +to evaluate function values. +It is also used buy +$cref/f.Forward/Forward/$$ (and $icode%af%.Forward%$$) +to compute function vales and derivatives. + +$head Implementation$$ +This virtual function must be defined by the +$cref/atomic_user/atomic_two_ctor/atomic_user/$$ class. +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. + +$head p$$ +The argument $icode p$$ has prototype +$codei% + size_t %p% +%$$ +It specifies the lowest order Taylor coefficient that we are evaluating. +During calls to $cref atomic_two_afun$$, $icode%p% == 0%$$. + +$head q$$ +The argument $icode q$$ has prototype +$codei% + size_t %q% +%$$ +It specifies the highest order Taylor coefficient that we are evaluating. +During calls to $cref atomic_two_afun$$, $icode%q% == 0%$$. + +$head vx$$ +The $code forward$$ argument $icode vx$$ has prototype +$codei% + const CppAD::vector& %vx% +%$$ +The case $icode%vx%.size() > 0%$$ only occurs while evaluating a call to +$cref atomic_two_afun$$. +In this case, +$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/$$ +or $cref/dynamic parameter/glossary/Parameter/Dynamic/$$ +in the corresponding call to +$codei% + %afun%(%ax%, %ay%) +%$$ +If $icode%vx%.size() == 0%$$, +then $icode%vy%.size() == 0%$$ and neither of these vectors +should be used. + +$head vy$$ +The $code forward$$ argument $icode vy$$ has prototype +$codei% + CppAD::vector& %vy% +%$$ +If $icode%vy%.size() == 0%$$, it should not be used. +Otherwise, +$icode%q% == 0%$$ and $icode%vy%.size() == %m%$$. +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 +$icode%ay%[%i%]%$$ is a variable +or dynamic parameter +(CppAD uses $icode vy$$ to reduce the necessary computations). + +$head tx$$ +The argument $icode tx$$ has prototype +$codei% + const CppAD::vector<%Base%>& %tx% +%$$ +and $icode%tx%.size() == (%q%+1)*%n%$$. +It is used by $icode%f%.Forward%$$ where $icode f$$ has type +$codei%ADFun<%Base%> %f%$$ and $icode afun$$ is used in $icode f$$. +For $latex j = 0 , \ldots , n-1$$ and $latex k = 0 , \ldots , q$$, +we use the Taylor coefficient notation +$latex \[ +\begin{array}{rcl} + x_j^k & = & tx [ j * ( q + 1 ) + k ] + \\ + X_j (t) & = & x_j^0 + x_j^1 t^1 + \cdots + x_j^q t^q +\end{array} +\] $$ +Note that superscripts represent an index for $latex x_j^k$$ +and an exponent for $latex t^k$$. +Also note that the Taylor coefficients for $latex X(t)$$ correspond +to the derivatives of $latex X(t)$$ at $latex t = 0$$ in the following way: +$latex \[ + x_j^k = \frac{1}{ k ! } X_j^{(k)} (0) +\] $$ + +$head atx$$ +The argument $icode atx$$ has prototype +$codei% + const CppAD::vector< AD<%Base%> >& %atx% +%$$ +Otherwise, $icode atx$$ specifications are the same as for $icode tx$$. + +$head ty$$ +The argument $icode ty$$ has prototype +$codei% + CppAD::vector<%Base%>& %ty% +%$$ +and $icode%tx%.size() == (%q%+1)*%m%$$. +It is set by $icode%f%.Forward%$$ where $icode f$$ has type +$codei%ADFun<%Base%> %f%$$ and $icode afun$$ is used in $icode f$$. +Upon return, +For $latex i = 0 , \ldots , m-1$$ and $latex k = 0 , \ldots , q$$, +$latex \[ +\begin{array}{rcl} + Y_i (t) & = & f_i [ X(t) ] + \\ + Y_i (t) & = & y_i^0 + y_i^1 t^1 + \cdots + y_i^q t^q + o ( t^q ) + \\ + ty [ i * ( q + 1 ) + k ] & = & y_i^k +\end{array} +\] $$ +where $latex o( t^q ) / t^q \rightarrow 0$$ as $latex t \rightarrow 0$$. +Note that superscripts represent an index for $latex y_j^k$$ +and an exponent for $latex t^k$$. +Also note that the Taylor coefficients for $latex Y(t)$$ correspond +to the derivatives of $latex Y(t)$$ at $latex t = 0$$ in the following way: +$latex \[ + y_j^k = \frac{1}{ k ! } Y_j^{(k)} (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 \[ + ty [ i * ( q + 1 ) + k ] = y_i^k +\]$$ +and hence the corresponding elements need not be recalculated. + +$head aty$$ +The argument $icode aty$$ has prototype +$codei% + const CppAD::vector< AD<%Base%> >& %aty% +%$$ +Otherwise, $icode aty$$ specifications are the same as for $icode ty$$. + +$head ok$$ +If the required results are calculated, $icode ok$$ should be true. +Otherwise, it should be false. + +$head Discussion$$ +For example, suppose that $icode%q% == 2%$$, +and you know how to compute the function $latex f(x)$$, +its first derivative $latex f^{(1)} (x)$$, +and it component wise Hessian $latex f_i^{(2)} (x)$$. +Then you can compute $icode ty$$ using the following formulas: +$latex \[ +\begin{array}{rcl} +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^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 + + f_i^{(1)} ( x^0 ) x^2 +\end{array} +\] $$ +For $latex i = 0 , \ldots , m-1$$, and $latex k = 0 , 1 , 2$$, +$latex \[ + ty [ i * (q + 1) + k ] = y_i^k +\] $$ + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/two_forward.hpp +Atomic forward mode +*/ +/*! +Link from atomic_base to forward mode (for replacement by derived class) + +\param p [in] +lowerest order for this forward mode calculation. + +\param q [in] +highest order for this forward mode calculation. + +\param vx [in] +if size not zero, which components of x are variables + +\param vy [out] +if size not zero, which components of y are variables + +\param tx [in] +Taylor coefficients corresponding to x for this calculation. + +\param ty [out] +Taylor coefficient corresponding to y for this calculation + +See the forward mode in user's documentation for atomic_two +*/ +template +bool atomic_base::forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty ) +{ return false; } +/*! +Link from atomic_base to forward mode (for replacement by derived class) + +\param p [in] +lowerest order for this forward mode calculation. + +\param q [in] +highest order for this forward mode calculation. + +\param vx [in] +if size not zero, which components of x are variables + +\param vy [out] +if size not zero, which components of y are variables + +\param atx [in] +Taylor coefficients corresponding to x for this calculation. + +\param aty [out] +Taylor coefficient corresponding to y for this calculation + +See the forward mode in user's documentation for atomic_two +*/ +template +bool atomic_base::forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector< AD >& atx , + vector< AD >& aty ) +{ return false; } +/*! +Convert atomic_three interface to atomic_two interface + +\param order_low [in] +lowerest order for this forward mode calculation. + +\param order_up [in] +highest order for this forward mode calculation. + +\param type_x [in] +if size not zero, which components of x are variables + +\param type_y [out] +if size not zero, which components of y are variables + +\param taylor_x [in] +Taylor coefficients corresponding to x for this calculation. + +\param taylor_y [out] +Taylor coefficient corresponding to y for this calculation + +See the forward mode in user's documentation for atomic_three +*/ +# define CPPAD_ATOMIC_BASE_MUSTDO 0 +template +bool atomic_base::forward( + size_t order_low , + size_t order_up , + const vector& type_x , + vector& type_y , + const vector& taylor_x , + vector& taylor_y ) +{ // + // atomic_base::afun(ax, ay) calls bool version directly + CPPAD_ASSERT_UNKNOWN( type_x.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( type_y.size() == 0 ); + // +# if CPPAD_ATOMIC_BASE_MUSTDO + size_t thread = thread_alloc::thread_num(); + allocate_work(thread); + vector & vx = work_[thread]->vx; + vector & vy = work_[thread]->vy; + vx.resize(type_x.size()); + vy.resize(type_y.size()); +# else + vector vx, vy; +# endif + // + bool ok = forward(order_low, order_up, vx, vy, taylor_x, taylor_y); + // + return ok; +} +# undef CPPAD_ATOMIC_BASE_MUSTDO +/*! +Convert atomic_three interface to atomic_two interface + +\param order_low [in] +lowerest order for this forward mode calculation. + +\param order_up [in] +highest order for this forward mode calculation. + +\param type_x [in] +if size not zero, which components of x are variables + +\param type_y [out] +if size not zero, which components of y are variables + +\param ataylor_x [in] +Taylor coefficients corresponding to x for this calculation. + +\param ataylor_y [out] +Taylor coefficient corresponding to y for this calculation + +See the forward mode in user's documentation for atomic_three +*/ +template +bool atomic_base::forward( + size_t order_low , + size_t order_up , + const vector& type_x , + vector& type_y , + const vector< AD >& ataylor_x , + vector< AD >& ataylor_y ) +{ // + // atomic_base::afun(ax, ay) calls bool version directly + CPPAD_ASSERT_UNKNOWN( type_x.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( type_y.size() == 0 ); + // + vector vx, vy; + bool ok = forward(order_low, order_up, vx, vy, ataylor_x, ataylor_y); + // + return ok; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/two_option.hpp cppad-2019.02.00.0/include/cppad/core/atomic/two_option.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/two_option.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/two_option.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,113 @@ +# ifndef CPPAD_CORE_ATOMIC_TWO_OPTION_HPP +# define CPPAD_CORE_ATOMIC_TWO_OPTION_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_option$$ +$spell + sq + enum + afun + bool + CppAD + std + typedef +$$ + +$section Set Atomic Function Options$$ + +$head Syntax$$ +$icode%afun%.option(%option_value%)%$$ + +$head Scope$$ +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$$ +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{R}^{p \times q}$$: +$icode%r%.size() == %p% * %q%$$. + +$subhead 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 +for a matrix $latex R \in \B{R}^{p \times q}$$: +$icode%r%.size() == %p% * %q%$$. + +$subhead 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 +for a matrix $latex R \in \B{R}^{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. + +$end +------------------------------------------------------------------------------ +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/two_option.hpp +Setting atomic_base options. +*/ + +/*! +Setting atomic_base options. + +\param option_value +new option value. +*/ +template +void atomic_base::option(enum option_enum option_value) +{ switch( option_value ) + { case pack_sparsity_enum: + case bool_sparsity_enum: + case set_sparsity_enum: + sparsity_ = option_value; + break; + + default: + CPPAD_ASSERT_KNOWN( + false, + "atoic_base::option: option_value is not valid" + ); + } + return; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/two_rev_depend.hpp cppad-2019.02.00.0/include/cppad/core/atomic/two_rev_depend.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/two_rev_depend.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/two_rev_depend.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,99 @@ +# ifndef CPPAD_CORE_ATOMIC_TWO_REV_DEPEND_HPP +# define CPPAD_CORE_ATOMIC_TWO_REV_DEPEND_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/two_rev_depend.hpp +Third generation atomic type computation. +*/ +/*! +Link from atomic_two to reverse dependency calculation + +\param parameter_x [in] +is the value of the parameters in the corresponding function call +afun(ax, ay). + +\param type_x [in] +is the type for each component of ax in the corresponding function call +afun(ax, ay). + +\param depend_x [out] +specifies which components of x affect values of interest. + +\param depend_y [in] +specifies which components of y affect values of interest. +*/ +// BEGIN_PROTOTYPE +template +bool atomic_base::rev_depend( + const vector& parameter_x , + const vector& type_x , + vector& depend_x , + const vector& depend_y ) +// END_PROTOTYPE +{ bool ok = true; + CPPAD_ASSERT_UNKNOWN( depend_x.size() == parameter_x.size() ); + size_t n = depend_x.size(); + size_t m = depend_y.size(); + // + size_t thread = thread_alloc::thread_num(); + allocate_work(thread); + // + if( sparsity_ == pack_sparsity_enum ) + { vectorBool& rt ( work_[thread]->pack_r ); + vectorBool& st ( work_[thread]->pack_s ); + // + st.resize(n * 1 ); + rt.resize(m * 1 ); + for(size_t i = 0; i < m; ++i) + rt[i] = depend_y[i]; + ok = rev_sparse_jac(1, rt, st, parameter_x); + if( ! ok ) + ok = rev_sparse_jac(1, rt, st); + if( ! ok ) + return false; + for(size_t j = 0; j < n; ++j) + depend_x[j] = st[j]; + } + else if( sparsity_ == bool_sparsity_enum ) + { + ok = rev_sparse_jac(1, depend_y, depend_x, parameter_x); + if( ! ok ) + ok = rev_sparse_jac(m, depend_y, depend_x); + if( ! ok ) + return false; + } + else + { CPPAD_ASSERT_UNKNOWN( sparsity_ == set_sparsity_enum ); + vector< std::set >& rt ( work_[thread]->set_r ); + vector< std::set >& st ( work_[thread]->set_s ); + rt.resize(m); + st.resize(n); + for(size_t i = 0; i < m; ++i) + { if( depend_y[i] ) + rt[i].insert(0); + } + ok = rev_sparse_jac(m, rt, st, parameter_x); + if( ! ok ) + ok = rev_sparse_jac(m, rt, st); + if( ! ok ) + return false; + for(size_t j = 0; j < n; ++j) + depend_x[j] = ! st[j].empty(); + } + return ok; +} + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/two_reverse.hpp cppad-2019.02.00.0/include/cppad/core/atomic/two_reverse.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/two_reverse.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/two_reverse.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,291 @@ +# ifndef CPPAD_CORE_ATOMIC_TWO_REVERSE_HPP +# define CPPAD_CORE_ATOMIC_TWO_REVERSE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_reverse$$ +$spell + sq + mul.hpp + afun + ty + px + py + Taylor + const + CppAD + atx + aty + apx + apy + af +$$ + +$section Atomic Reverse Mode$$ +$spell + bool +$$ + +$head Syntax$$ + +$subhead Base$$ +$icode%ok% = %afun%.reverse(%q%, %tx%, %ty%, %px%, %py%) +%$$ +This syntax is used by $icode%f%.Forward%$$ where $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +and $icode afun$$ is used in $icode f$$. + +$subhead AD$$ +$icode%ok% = %afun%.reverse(%q%, %atx%, %aty%, %apx%, %apy%) +%$$ +This syntax is used by $icode%af%.Forward%$$ where $icode af$$ has prototype +$codei% + ADFun< AD<%Base%> , %Base% > %af% +%$$ +and $icode afun$$ is used in $icode af$$ (see $cref base2ad$$). + +$head Purpose$$ +This function is used by $cref/reverse/Reverse/$$ +to compute derivatives. + +$head Implementation$$ +If you are using +$cref/reverse/Reverse/$$ mode, +this virtual function must be defined by the +$cref/atomic_user/atomic_two_ctor/atomic_user/$$ class. +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. + +$head q$$ +The argument $icode q$$ has prototype +$codei% + size_t %q% +%$$ +It specifies the highest order Taylor coefficient that +computing the derivative of. + +$head tx$$ +The argument $icode tx$$ has prototype +$codei% + const CppAD::vector<%Base%>& %tx% +%$$ +and $icode%tx%.size() == (%q%+1)*%n%$$. +For $latex j = 0 , \ldots , n-1$$ and $latex k = 0 , \ldots , q$$, +we use the Taylor coefficient notation +$latex \[ +\begin{array}{rcl} + x_j^k & = & tx [ j * ( q + 1 ) + k ] + \\ + X_j (t) & = & x_j^0 + x_j^1 t^1 + \cdots + x_j^q t^q +\end{array} +\] $$ +Note that superscripts represent an index for $latex x_j^k$$ +and an exponent for $latex t^k$$. +Also note that the Taylor coefficients for $latex X(t)$$ correspond +to the derivatives of $latex X(t)$$ at $latex t = 0$$ in the following way: +$latex \[ + x_j^k = \frac{1}{ k ! } X_j^{(k)} (0) +\] $$ + +$head atx$$ +The argument $icode atx$$ has prototype +$codei% + const CppAD::vector< AD<%Base%> >& %atx% +%$$ +Otherwise, $icode atx$$ specifications are the same as for $icode tx$$. + +$head ty$$ +The argument $icode ty$$ has prototype +$codei% + const CppAD::vector<%Base%>& %ty% +%$$ +and $icode%tx%.size() == (%q%+1)*%m%$$. +For $latex i = 0 , \ldots , m-1$$ and $latex k = 0 , \ldots , q$$, +we use the Taylor coefficient notation +$latex \[ +\begin{array}{rcl} + Y_i (t) & = & f_i [ X(t) ] + \\ + Y_i (t) & = & y_i^0 + y_i^1 t^1 + \cdots + y_i^q t^q + o ( t^q ) + \\ + y_i^k & = & ty [ i * ( q + 1 ) + k ] +\end{array} +\] $$ +where $latex o( t^q ) / t^q \rightarrow 0$$ as $latex t \rightarrow 0$$. +Note that superscripts represent an index for $latex y_j^k$$ +and an exponent for $latex t^k$$. +Also note that the Taylor coefficients for $latex Y(t)$$ correspond +to the derivatives of $latex Y(t)$$ at $latex t = 0$$ in the following way: +$latex \[ + y_j^k = \frac{1}{ k ! } Y_j^{(k)} (0) +\] $$ + +$head aty$$ +The argument $icode aty$$ has prototype +$codei% + const CppAD::vector< AD<%Base%> >& %aty% +%$$ +Otherwise, $icode aty$$ specifications are the same as for $icode ty$$. + + +$head F$$ +We use the notation $latex \{ x_j^k \} \in \B{R}^{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{R}^{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{R}^{n \times (q+1)} \rightarrow \B{R}^{m \times (q+1)}$$ by +$latex \[ + y_i^k = F_i^k [ \{ x_j^k \} ] +\] $$ +Note that +$latex \[ + F_i^0 ( \{ x_j^k \} ) = f_i ( X(0) ) = f_i ( x^0 ) +\] $$ +We also note that +$latex F_i^\ell ( \{ x_j^k \} )$$ is a function of +$latex x^0 , \ldots , x^\ell$$ +and is determined by the derivatives of $latex f_i (x)$$ +up to order $latex \ell$$. + + +$head G, H$$ +We use $latex G : \B{R}^{m \times (q+1)} \rightarrow \B{R}$$ +to denote an arbitrary scalar valued function of $latex \{ y_i^k \}$$. +We use $latex H : \B{R}^{n \times (q+1)} \rightarrow \B{R}$$ +defined by +$latex \[ + H ( \{ x_j^k \} ) = G[ F( \{ x_j^k \} ) ] +\] $$ + +$head py$$ +The argument $icode py$$ has prototype +$codei% + const CppAD::vector<%Base%>& %py% +%$$ +and $icode%py%.size() == m * (%q%+1)%$$. +For $latex i = 0 , \ldots , m-1$$, $latex k = 0 , \ldots , q$$, +$latex \[ + py[ i * (q + 1 ) + k ] = \partial G / \partial y_i^k +\] $$ + +$head apy$$ +The argument $icode apy$$ has prototype +$codei% + const CppAD::vector< AD<%Base%> >& %apy% +%$$ +Otherwise, $icode apy$$ specifications are the same as for $icode py$$. + +$subhead px$$ +The $icode px$$ has prototype +$codei% + CppAD::vector<%Base%>& %px% +%$$ +and $icode%px%.size() == n * (%q%+1)%$$. +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$$, +$latex \[ +\begin{array}{rcl} +px [ j * (q + 1) + \ell ] & = & \partial H / \partial x_j^\ell +\\ +& = & +( \partial G / \partial \{ y_i^k \} ) \cdot + ( \partial \{ y_i^k \} / \partial x_j^\ell ) +\\ +& = & +\sum_{k=0}^q +\sum_{i=0}^{m-1} +( \partial G / \partial y_i^k ) ( \partial y_i^k / \partial x_j^\ell ) +\\ +& = & +\sum_{k=\ell}^q +\sum_{i=0}^{m-1} +py[ i * (q + 1 ) + k ] ( \partial F_i^k / \partial x_j^\ell ) +\end{array} +\] $$ +Note that we have used the fact that for $latex k < \ell$$, +$latex \partial F_i^k / \partial x_j^\ell = 0$$. + +$head apx$$ +The argument $icode apx$$ has prototype +$codei% + CppAD::vector< AD<%Base%> >& %apx% +%$$ +Otherwise, $icode apx$$ specifications are the same as for $icode px$$. + +$head ok$$ +The return value $icode ok$$ has prototype +$codei% + bool %ok% +%$$ +If it is $code true$$, the corresponding evaluation succeeded, +otherwise it failed. + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/two_reverse.hpp +Atomic reverse mode. +*/ +/*! +Link from reverse mode sweep to users routine. + +\param q [in] +highest order for this reverse mode calculation. + +\param tx [in] +Taylor coefficients corresponding to x for this calculation. + +\param ty [in] +Taylor coefficient corresponding to y for this calculation + +\param px [out] +Partials w.r.t. the x Taylor coefficients. + +\param py [in] +Partials w.r.t. the y Taylor coefficients. + +See atomic_reverse mode use documentation +*/ +template +bool atomic_base::reverse( + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py ) +{ return false; } + +template +bool atomic_base::reverse( + size_t q , + const vector< AD >& atx , + const vector< AD >& aty , + vector< AD >& apx , + const vector< AD >& apy ) +{ return false; } + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/two_rev_sparse_hes.hpp cppad-2019.02.00.0/include/cppad/core/atomic/two_rev_sparse_hes.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/two_rev_sparse_hes.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/two_rev_sparse_hes.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,451 @@ +# ifndef CPPAD_CORE_ATOMIC_TWO_REV_SPARSE_HES_HPP +# define CPPAD_CORE_ATOMIC_TWO_REV_SPARSE_HES_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_rev_sparse_hes$$ +$spell + sq + mul.hpp + vx + afun + Jacobian + jac + CppAD + std + bool + hes + const +$$ + +$section Atomic Reverse Hessian Sparsity Patterns$$ + +$head Syntax$$ +$icode%ok% = %afun%.rev_sparse_hes(%vx%, %s%, %t%, %q%, %r%, %u%, %v%, %x%)%$$ + +$head Deprecated 2016-06-27$$ +$icode%ok% = %afun%.rev_sparse_hes(%vx%, %s%, %t%, %q%, %r%, %u%, %v%)%$$ + +$head Purpose$$ +This function is used by $cref RevSparseHes$$ to compute +Hessian sparsity patterns. +If you are using $cref RevSparseHes$$ to compute +one of the versions of this +virtual function muse be defined by the +$cref/atomic_user/atomic_two_ctor/atomic_user/$$ class. +$pre + +$$ +There is an unspecified scalar valued function +$latex g : \B{R}^m \rightarrow \B{R}$$. +Given a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for +$latex R \in \B{R}^{n \times q}$$, +and information about the function $latex z = g(y)$$, +this routine computes the sparsity pattern for +$latex \[ + V(x) = (g \circ f)^{(2)}( x ) R +\] $$ + +$head Implementation$$ +If you are using and $cref RevSparseHes$$, +this virtual function must be defined by the +$cref/atomic_user/atomic_two_ctor/atomic_user/$$ class. + +$subhead vx$$ +The argument $icode vx$$ has prototype +$codei% + const CppAD:vector& %vx% +%$$ +$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/$$ +or $cref/dynamic parameter/glossary/Parameter/Dynamic/$$ +in the corresponding call to +$codei% + %afun%(%ax%, %ay%) +%$$ + +$subhead s$$ +The argument $icode s$$ has prototype +$codei% + const CppAD:vector& %s% +%$$ +and its size is $icode m$$. +It is a sparsity pattern for +$latex S(x) = g^{(1)} [ f(x) ] \in \B{R}^{1 \times m}$$. + +$subhead t$$ +This argument has prototype +$codei% + CppAD:vector& %t% +%$$ +and its size is $icode m$$. +The input values of its elements +are not specified (must not matter). +Upon return, $icode t$$ is a +sparsity pattern for +$latex T(x) \in \B{R}^{1 \times n}$$ where +$latex \[ + T(x) = (g \circ f)^{(1)} (x) = S(x) * f^{(1)} (x) +\]$$ + +$subhead q$$ +The argument $icode q$$ has prototype +$codei% + size_t %q% +%$$ +It specifies the number of columns in +$latex R \in \B{R}^{n \times q}$$, +$latex U(x) \in \B{R}^{m \times q}$$, and +$latex V(x) \in \B{R}^{n \times q}$$. + +$subhead r$$ +This argument has prototype +$codei% + const %atomic_sparsity%& %r% +%$$ +and is a $cref/atomic_sparsity/atomic_two_option/atomic_sparsity/$$ pattern for +$latex R \in \B{R}^{n \times q}$$. + +$head u$$ +This argument has prototype +$codei% + const %atomic_sparsity%& %u% +%$$ +and is a $cref/atomic_sparsity/atomic_two_option/atomic_sparsity/$$ pattern for +$latex U(x) \in \B{R}^{m \times q}$$ which is defined by +$latex \[ +\begin{array}{rcl} +U(x) +& = & +\{ \partial_u \{ \partial_y g[ y + f^{(1)} (x) R u ] \}_{y=f(x)} \}_{u=0} +\\ +& = & +\partial_u \{ g^{(1)} [ f(x) + f^{(1)} (x) R u ] \}_{u=0} +\\ +& = & +g^{(2)} [ f(x) ] f^{(1)} (x) R +\end{array} +\] $$ + +$subhead v$$ +This argument has prototype +$codei% + %atomic_sparsity%& %v% +%$$ +The input value of its elements +are not specified (must not matter). +Upon return, $icode v$$ is a +$cref/atomic_sparsity/atomic_two_option/atomic_sparsity/$$ pattern for +$latex V(x) \in \B{R}^{n \times q}$$ which is defined by +$latex \[ +\begin{array}{rcl} +V(x) +& = & +\partial_u [ \partial_x (g \circ f) ( x + R u ) ]_{u=0} +\\ +& = & +\partial_u [ (g \circ f)^{(1)}( x + R u ) ]_{u=0} +\\ +& = & +(g \circ f)^{(2)}( x ) R +\\ +& = & +f^{(1)} (x)^\R{T} g^{(2)} [ f(x) ] f^{(1)} (x) R ++ +\sum_{i=1}^m g_i^{(1)} [ f(x) ] \; f_i^{(2)} (x) R +\\ +& = & +f^{(1)} (x)^\R{T} U(x) ++ +\sum_{i=1}^m S_i (x) \; f_i^{(2)} (x) R +\end{array} +\] $$ + +$subhead x$$ +$index deprecated$$ +The argument has prototype +$codei% + const CppAD::vector<%Base%>& %x% +%$$ +and size is equal to the $icode n$$. +This is the $cref Value$$ value corresponding to the parameters in the +vector $cref/ax/atomic_two_afun/ax/$$ (when the atomic function was called). +To be specific, if +$codei% + if( Parameter(%ax%[%i%]) == true ) + %x%[%i%] = Value( %ax%[%i%] ); + else + %x%[%i%] = CppAD::numeric_limits<%Base%>::quiet_NaN(); +%$$ +The version of this function with out the $icode x$$ argument is deprecated; +i.e., you should include the argument even if you do not use it. + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/two_rev_sparse_hes.hpp +Atomic reverse mode Hessian sparsity patterns. +*/ +/*! +Link from reverse Hessian sparsity sweep to atomic_base + +\param vx [in] +which componens of x are variables. + +\param s [in] +is the reverse Jacobian sparsity pattern w.r.t the result vector y. + +\param t [out] +is the reverse Jacobian sparsity pattern w.r.t the argument vector x. + +\param q [in] +is the column dimension for the sparsity partterns. + +\param r [in] +is the forward Jacobian sparsity pattern w.r.t the argument vector x + +\param u [in] +is the Hessian sparsity pattern w.r.t the result vector y. + +\param v [out] +is the Hessian sparsity pattern w.r.t the argument vector x. + +\param x [in] +is the integer value of the x arguments that are parameters. +*/ +template +bool atomic_base::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 , + const vector& x ) +{ return false; } +template +bool atomic_base::rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const vector& r , + const vector& u , + vector& v , + const vector& x ) +{ return false; } +template +bool atomic_base::rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const vectorBool& r , + const vectorBool& u , + vectorBool& v , + const vector& x ) +{ return false; } +// deprecated +template +bool atomic_base::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 ) +{ return false; } +template +bool atomic_base::rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const vector& r , + const vector& u , + vector& v ) +{ return false; } +template +bool atomic_base::rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const vectorBool& r , + const vectorBool& u , + vectorBool& v ) +{ return false; } +/*! +Link, before case split, from rev_hes_sweep to atomic_base. + +\tparam InternalSparsity +Is the used internaly for sparsity calculations; i.e., +sparse_pack or sparse_list. + +\param x +is parameter arguments to the function, other components are nan. + +\param x_index +is the variable index, on the tape, for the arguments to this function. +This size of x_index is n, the number of arguments to this function. + +\param y_index +is the variable index, on the tape, for the results for this function. +This size of y_index is m, the number of results for this function. + +\param for_jac_sparsity +On input, for j = 0, ... , n-1, the sparsity pattern with index x_index[j], +is the forward Jacobian sparsity for the j-th argument to this atomic function. + +\param rev_jac_flag +This shows which variables affect the function we are +computing the Hessian of. +On input, for i = 0, ... , m-1, the rev_jac_flag[ y_index[i] ] is true +if the Jacobian of function (we are computing sparsity for) is no-zero. +Upon return, for j = 0, ... , n-1, rev_jac_flag [ x_index[j] ] +as been adjusted to accound removing this atomic function. + +\param rev_hes_sparsity +This is the sparsity pattern for the Hessian. +On input, for i = 0, ... , m-1, row y_index[i] is the reverse Hessian sparsity +with one of the partials with respect to to y_index[i]. +*/ +template +template +bool atomic_base::rev_sparse_hes( + const vector& x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + const InternalSparsity& for_jac_sparsity , + bool* rev_jac_flag , + InternalSparsity& rev_hes_sparsity ) +{ CPPAD_ASSERT_UNKNOWN( for_jac_sparsity.end() == rev_hes_sparsity.end() ); + size_t q = rev_hes_sparsity.end(); + size_t n = x_index.size(); + size_t m = y_index.size(); + bool ok = false; + size_t thread = thread_alloc::thread_num(); + allocate_work(thread); + bool zero_empty = true; + bool input_empty = false; + bool transpose = false; + // + // vx + vector vx(n); + for(size_t j = 0; j < n; j++) + vx[j] = x_index[j] != 0; + // + // note that s and t are vectors so transpose does not matter for bool case + vector bool_s( work_[thread]->bool_s ); + vector bool_t( work_[thread]->bool_t ); + // + bool_s.resize(m); + bool_t.resize(n); + // + for(size_t i = 0; i < m; i++) + { if( y_index[i] > 0 ) + bool_s[i] = rev_jac_flag[ y_index[i] ]; + } + // + std::string msg = ": atomic_base.rev_sparse_hes: returned false"; + if( sparsity_ == pack_sparsity_enum ) + { vectorBool& pack_r( work_[thread]->pack_r ); + vectorBool& pack_u( work_[thread]->pack_u ); + vectorBool& pack_v( work_[thread]->pack_h ); + // + pack_v.resize(n * q); + // + local::get_internal_sparsity( + transpose, x_index, for_jac_sparsity, pack_r + ); + local::get_internal_sparsity( + transpose, y_index, rev_hes_sparsity, pack_u + ); + // + ok = rev_sparse_hes(vx, bool_s, bool_t, q, pack_r, pack_u, pack_v, x); + if( ! ok ) + ok = rev_sparse_hes(vx, bool_s, bool_t, q, pack_r, pack_u, pack_v); + if( ! ok ) + { msg = afun_name() + msg + " sparsity = pack_sparsity_enum"; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } + local::set_internal_sparsity(zero_empty, input_empty, + transpose, x_index, rev_hes_sparsity, pack_v + ); + } + else if( sparsity_ == bool_sparsity_enum ) + { vector& bool_r( work_[thread]->bool_r ); + vector& bool_u( work_[thread]->bool_u ); + vector& bool_v( work_[thread]->bool_h ); + // + bool_v.resize(n * q); + // + local::get_internal_sparsity( + transpose, x_index, for_jac_sparsity, bool_r + ); + local::get_internal_sparsity( + transpose, y_index, rev_hes_sparsity, bool_u + ); + // + ok = rev_sparse_hes(vx, bool_s, bool_t, q, bool_r, bool_u, bool_v, x); + if( ! ok ) + ok = rev_sparse_hes(vx, bool_s, bool_t, q, bool_r, bool_u, bool_v); + if( ! ok ) + { msg = afun_name() + msg + " sparsity = bool_sparsity_enum"; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } + local::set_internal_sparsity(zero_empty, input_empty, + transpose, x_index, rev_hes_sparsity, bool_v + ); + } + else + { CPPAD_ASSERT_UNKNOWN( sparsity_ == set_sparsity_enum ); + vector< std::set >& set_r( work_[thread]->set_r ); + vector< std::set >& set_u( work_[thread]->set_u ); + vector< std::set >& set_v( work_[thread]->set_h ); + // + set_v.resize(n); + // + local::get_internal_sparsity( + transpose, x_index, for_jac_sparsity, set_r + ); + local::get_internal_sparsity( + transpose, y_index, rev_hes_sparsity, set_u + ); + // + ok = rev_sparse_hes(vx, bool_s, bool_t, q, set_r, set_u, set_v, x); + if( ! ok ) + ok = rev_sparse_hes(vx, bool_s, bool_t, q, set_r, set_u, set_v); + if( ! ok ) + { msg = afun_name() + msg + " sparsity = set_sparsity_enum"; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } + local::set_internal_sparsity(zero_empty, input_empty, + transpose, x_index, rev_hes_sparsity, set_v + ); + } + for(size_t j = 0; j < n; j++) + { if( x_index[j] > 0 ) + rev_jac_flag[ x_index[j] ] |= bool_t[j]; + } + return ok; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/atomic/two_rev_sparse_jac.hpp cppad-2019.02.00.0/include/cppad/core/atomic/two_rev_sparse_jac.hpp --- cppad-2018.00.00.0/include/cppad/core/atomic/two_rev_sparse_jac.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/atomic/two_rev_sparse_jac.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,289 @@ +# ifndef CPPAD_CORE_ATOMIC_TWO_REV_SPARSE_JAC_HPP +# define CPPAD_CORE_ATOMIC_TWO_REV_SPARSE_JAC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_rev_sparse_jac$$ +$spell + sq + mul.hpp + rt + afun + Jacobian + jac + CppAD + std + bool + const + hes +$$ + +$section Atomic Reverse Jacobian Sparsity Patterns$$ + +$head Syntax$$ +$icode%ok% = %afun%.rev_sparse_jac(%q%, %rt%, %st%, %x%) +%$$ + +$head Deprecated 2016-06-27$$ +$icode%ok% = %afun%.rev_sparse_jac(%q%, %rt%, %st%) +%$$ + +$head Purpose$$ +This function is used by +$cref RevSparseJac$$ to compute +Jacobian sparsity patterns. +If you are using $cref RevSparseJac$$, +one of the versions of this +virtual function must be defined by the +$cref/atomic_user/atomic_two_ctor/atomic_user/$$ class. +$pre + +$$ +For a fixed matrix $latex R \in \B{R}^{q \times m}$$, +the Jacobian of $latex R * f( x )$$ with respect to $latex x \in \B{R}^n$$ is +$latex \[ + S(x) = R * f^{(1)} (x) +\] $$ +Given a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for $latex R$$, +$code rev_sparse_jac$$ computes a sparsity pattern for $latex S(x)$$. + +$head Implementation$$ +If you are using +$cref RevSparseJac$$ or $cref ForSparseHes$$, +this virtual function must be defined by the +$cref/atomic_user/atomic_two_ctor/atomic_user/$$ class. + +$subhead q$$ +The argument $icode q$$ has prototype +$codei% + size_t %q% +%$$ +It specifies the number of rows in +$latex R \in \B{R}^{q \times m}$$ and the Jacobian +$latex S(x) \in \B{R}^{q \times n}$$. + +$subhead rt$$ +This argument has prototype +$codei% + const %atomic_sparsity%& %rt% +%$$ +and is a +$cref/atomic_sparsity/atomic_two_option/atomic_sparsity/$$ pattern for +$latex R^\R{T} \in \B{R}^{m \times q}$$. + +$subhead st$$ +This argument has prototype +$codei% + %atomic_sparsity%& %st% +%$$ +The input value of its elements +are not specified (must not matter). +Upon return, $icode s$$ is a +$cref/atomic_sparsity/atomic_two_option/atomic_sparsity/$$ pattern for +$latex S(x)^\R{T} \in \B{R}^{n \times q}$$. + +$subhead x$$ +$index deprecated$$ +The argument has prototype +$codei% + const CppAD::vector<%Base%>& %x% +%$$ +and size is equal to the $icode n$$. +This is the $cref Value$$ corresponding to the parameters in the +vector $cref/ax/atomic_two_afun/ax/$$ (when the atomic function was called). +To be specific, if +$codei% + if( Parameter(%ax%[%i%]) == true ) + %x%[%i%] = Value( %ax%[%i%] ); + else + %x%[%i%] = CppAD::numeric_limits<%Base%>::quiet_NaN(); +%$$ +The version of this function with out the $icode x$$ argument is deprecated; +i.e., you should include the argument even if you do not use it. + +$head ok$$ +The return value $icode ok$$ has prototype +$codei% + bool %ok% +%$$ +If it is $code true$$, the corresponding evaluation succeeded, +otherwise it failed. + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file atomic/two_rev_sparse_jac.hpp +Atomic reverse mode Jacobian sparsity patterns. +*/ +/*! +Link, after case split, from rev_jac_sweep to atomic_base + +\param q [in] +is the row dimension for the Jacobian sparsity partterns + +\param rt [out] +is the tansposed Jacobian sparsity pattern w.r.t to range variables y + +\param st [in] +is the tansposed Jacobian sparsity pattern for the argument variables x + +\param x +is the integer value for x arguments that are parameters. +*/ +template +bool atomic_base::rev_sparse_jac( + size_t q , + const vector< std::set >& rt , + vector< std::set >& st , + const vector& x ) +{ return false; } +template +bool atomic_base::rev_sparse_jac( + size_t q , + const vector& rt , + vector& st , + const vector& x ) +{ return false; } +template +bool atomic_base::rev_sparse_jac( + size_t q , + const vectorBool& rt , + vectorBool& st , + const vector& x ) +{ return false; } +// deprecated versions +template +bool atomic_base::rev_sparse_jac( + size_t q , + const vector< std::set >& rt , + vector< std::set >& st ) +{ return false; } +template +bool atomic_base::rev_sparse_jac( + size_t q , + const vector& rt , + vector& st ) +{ return false; } +template +bool atomic_base::rev_sparse_jac( + size_t q , + const vectorBool& rt , + vectorBool& st ) +{ return false; } + +/*! +Link, before case split, from rev_jac_sweep to atomic_base. + +\tparam InternalSparsity +Is the used internaly for sparsity calculations; i.e., +sparse_pack or sparse_list. + +\param x +is parameter arguments to the function, other components are nan. + +\param x_index +is the variable index, on the tape, for the arguments to this function. +This size of x_index is n, the number of arguments to this function. + +\param y_index +is the variable index, on the tape, for the results for this function. +This size of y_index is m, the number of results for this function. + +\param var_sparsity +On input, for i = 0, ... , m-1, the sparsity pattern with index y_index[i], +is the sparsity for the i-th argument to this atomic function. +On output, for j = 0, ... , n-1, the sparsity pattern with index x_index[j], +the sparsity has been updated to remove y as a function of x. +*/ +template +template +bool atomic_base::rev_sparse_jac( + const vector& x , + const local::pod_vector& x_index , + const local::pod_vector& y_index , + InternalSparsity& var_sparsity ) +{ + // initial results may be non-empty during reverse mode + size_t q = var_sparsity.end(); + bool input_empty = false; + bool zero_empty = true; + bool transpose = false; + size_t n = x_index.size(); + bool ok = false; + size_t thread = thread_alloc::thread_num(); + allocate_work(thread); + // + std::string msg = ": atomic_base.rev_sparse_jac: returned false"; + if( sparsity_ == pack_sparsity_enum ) + { vectorBool& pack_rt ( work_[thread]->pack_r ); + vectorBool& pack_st ( work_[thread]->pack_s ); + local::get_internal_sparsity( + transpose, y_index, var_sparsity, pack_rt + ); + // + pack_st.resize(n * q ); + ok = rev_sparse_jac(q, pack_rt, pack_st, x); + if( ! ok ) + ok = rev_sparse_jac(q, pack_rt, pack_st); + if( ! ok ) + { msg = afun_name() + msg + " sparsity = pack_sparsity_enum"; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } + local::set_internal_sparsity(zero_empty, input_empty, + transpose, x_index, var_sparsity, pack_st + ); + } + else if( sparsity_ == bool_sparsity_enum ) + { vector& bool_rt ( work_[thread]->bool_r ); + vector& bool_st ( work_[thread]->bool_s ); + local::get_internal_sparsity( + transpose, y_index, var_sparsity, bool_rt + ); + bool_st.resize(n * q ); + ok = rev_sparse_jac(q, bool_rt, bool_st, x); + if( ! ok ) + ok = rev_sparse_jac(q, bool_rt, bool_st); + if( ! ok ) + { msg = afun_name() + msg + " sparsity = bool_sparsity_enum"; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } + local::set_internal_sparsity(zero_empty, input_empty, + transpose, x_index, var_sparsity, bool_st + ); + } + else + { CPPAD_ASSERT_UNKNOWN( sparsity_ == set_sparsity_enum ); + vector< std::set >& set_rt ( work_[thread]->set_r ); + vector< std::set >& set_st ( work_[thread]->set_s ); + local::get_internal_sparsity( + transpose, y_index, var_sparsity, set_rt + ); + set_st.resize(n); + ok = rev_sparse_jac(q, set_rt, set_st, x); + if( ! ok ) + ok = rev_sparse_jac(q, set_rt, set_st); + if( ! ok ) + { msg = afun_name() + msg + " sparsity = set_sparsity_enum"; + CPPAD_ASSERT_KNOWN(false, msg.c_str()); + } + local::set_internal_sparsity(zero_empty, input_empty, + transpose, x_index, var_sparsity, set_st + ); + } + return ok; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/azmul.hpp cppad-2019.02.00.0/include/cppad/core/azmul.hpp --- cppad-2018.00.00.0/include/cppad/core/azmul.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/azmul.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,247 @@ +# ifndef CPPAD_CORE_AZMUL_HPP +# define CPPAD_CORE_AZMUL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$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/general/azmul.cpp +%$$ +The file +$cref azmul.cpp$$ +is an examples and tests of this function. + +$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 + local::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 ); + + // check if x and y tapes match + bool match_x = x.tape_id_ == tape_id; + bool match_y = y.tape_id_ == tape_id; + + // check if x and y are dynamic parameters + bool dyn_x = match_x & (x.ad_type_ == dynamic_enum); + bool dyn_y = match_y & (y.ad_type_ == dynamic_enum); + + // check if x and y are variables + bool var_x = match_x & (x.ad_type_ != dynamic_enum); + bool var_y = match_y & (y.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + x.tape_id_ == y.tape_id_ || ! match_x || ! match_y , + "azmul: AD variables or dynamic parameters on different threads." + ); + if( var_x ) + { if( var_y ) + { // result = azmul(variable, variable) + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::ZmulvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::ZmulvvOp) == 2 ); + + // put operand addresses in tape + tape->Rec_.PutArg(x.taddr_, y.taddr_); + + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::ZmulvvOp); + + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + 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( local::NumRes(local::ZmulvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::ZmulvpOp) == 2 ); + + // put operand addresses in tape + addr_t p = y.taddr_; + if( ! dyn_y ) + p = tape->Rec_.put_con_par(y.value_); + tape->Rec_.PutArg(x.taddr_, p); + + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::ZmulvpOp); + + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + } + 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( local::NumRes(local::ZmulpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::ZmulpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = x.taddr_; + if( ! dyn_x ) + p = tape->Rec_.put_con_par(x.value_); + tape->Rec_.PutArg(p, y.taddr_); + + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::ZmulpvOp); + + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + } + else if( dyn_x | dyn_y ) + { addr_t arg0 = x.taddr_; + addr_t arg1 = y.taddr_; + if( ! dyn_x ) + arg0 = tape->Rec_.put_con_par(x.value_); + if( ! dyn_y ) + arg1 = tape->Rec_.put_con_par(y.value_); + // + // parameters with a dynamic parameter result + result.taddr_ = tape->Rec_.put_dyn_par( + result.value_, local::zmul_dyn, arg0, arg1 + ); + result.tape_id_ = tape_id; + result.ad_type_ = dynamic_enum; + } + 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-2018.00.00.0/include/cppad/core/base2ad.hpp cppad-2019.02.00.0/include/cppad/core/base2ad.hpp --- cppad-2018.00.00.0/include/cppad/core/base2ad.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/base2ad.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,117 @@ +# ifndef CPPAD_CORE_BASE2AD_HPP +# define CPPAD_CORE_BASE2AD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin base2ad$$ +$spell + af + Taylor +$$ + +$spell +$$ + +$section Create an AD Function From a Base Function$$ + +$head Syntax$$ +$icode%af% = %f%.base2ad()%$$ + +$head Base$$ +This is the base type used to recorded the operation sequence in $icode f$$ +and $icode af$$; i.e., the type $codei%AD<%Base%>%$$ was used to record +the operation sequence. + +$head f$$ +This object has prototype +$codei% + ADFun<%Base%> %f% +%$$ +It does it's derivative calculations using the type $icode Base$$. + +$head af$$ +This object has prototype +$codei% + ADFun< AD<%Base%> , %Base% > %af% +%$$ +It has the same operation sequence as $icode f$$, +but it does it's derivative calculations using the type +$codei%AD<%Base>%$$. +This enables one to record new functions that are defined +using derivatives of the function $icode f$$. +Initially, there are no Taylor coefficients stored in $icode af$$ and +$cref%af.size_order()%size_order%$$ is zero. + +$children% + example/general/base2ad.cpp +%$$ +$head Example$$ +The file $cref base2ad.cpp$$ +contains an example and test of this operation. + +$end +---------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file base2ad.hpp +*/ +/// Create an ADFun< AD, Base > from this ADFun +template +ADFun< AD, RecBase > ADFun::base2ad(void) const +{ ADFun< AD, RecBase > fun; + // + // This is a base2ad return value and only case where this flag is true + fun.base2ad_return_value_ = true; + // + // bool values + fun.has_been_optimized_ = has_been_optimized_; + fun.check_for_nan_ = check_for_nan_; + // + // size_t values + fun.compare_change_count_ = compare_change_count_; + fun.compare_change_number_ = compare_change_number_; + fun.compare_change_op_index_ = compare_change_op_index_; + CPPAD_ASSERT_UNKNOWN( fun.num_order_taylor_ == 0 ) ; + CPPAD_ASSERT_UNKNOWN( fun.cap_order_taylor_ == 0 ); + CPPAD_ASSERT_UNKNOWN( fun.num_direction_taylor_ == 0 ); + fun.num_var_tape_ = num_var_tape_; + // + // pod_vector objects + fun.ind_taddr_ = ind_taddr_; + fun.dep_taddr_ = dep_taddr_; + fun.dep_parameter_ = dep_parameter_; + fun.cskip_op_ = cskip_op_; + fun.load_op_ = load_op_; + // + // pod_maybe_vector< AD > = pod_maybe_vector + CPPAD_ASSERT_UNKNOWN( fun.taylor_.size() == 0 ); + // + // player + // (uses move semantics when CPPAD_USE_CPLUSPLUS_2011 is 1) + fun.play_ = play_.base2ad(); + // + // subgraph + fun.subgraph_info_ = subgraph_info_; + // + // sparse_pack + fun.for_jac_sparse_pack_ = for_jac_sparse_pack_; + // + // sparse_list + fun.for_jac_sparse_set_ = for_jac_sparse_set_; + // + return fun; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/base_complex.hpp cppad-2019.02.00.0/include/cppad/core/base_complex.hpp --- cppad-2018.00.00.0/include/cppad/core/base_complex.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/base_complex.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,384 @@ +# ifndef CPPAD_CORE_BASE_COMPLEX_HPP +# define CPPAD_CORE_BASE_COMPLEX_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include +# include + +// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL +# include + +/* +$begin base_complex.hpp$$ +$spell + azmul + expm1 + atanh + acosh + asinh + endif + eps + abs_geq + Rel + Lt Le Eq Ge Gt + imag + gcc + isnan + cppad.hpp + sqrt + exp + cos + std + const + CppAD + Op + inline + enum + undef + acos + asin + atan + erf + Cond + namespace + bool +$$ + + +$section Enable use of AD where Base is std::complex$$ + +$children%example/general/complex_poly.cpp +%$$ +$head Example$$ +The file $cref complex_poly.cpp$$ contains an example use of +$code std::complex$$ type for a CppAD $icode Base$$ type. + +$head Include Order$$ +This file is included before $code $$ +so it is necessary to define the error handler +in addition to including +$cref/base_require.hpp/base_require/Include Order/$$ +$srccode%cpp% */ +# include +# include +# include +# include + +/* %$$ + +$head CondExpOp$$ +The type $code std::complex$$ does not supports the +$code <$$, $code <=$$, $code ==$$, $code >=$$, and $code >$$ operators; see +$cref/not ordered/base_cond_exp/CondExpTemplate/Not Ordered/$$. +Hence its $code CondExpOp$$ function is defined by +$srccode%cpp% */ +namespace CppAD { + inline std::complex CondExpOp( + enum CppAD::CompareOp cop , + const std::complex &left , + const std::complex &right , + const std::complex &trueCase , + const std::complex &falseCase ) + { CppAD::ErrorHandler::Call( + true , __LINE__ , __FILE__ , + "std::complex CondExpOp(...)", + "Error: cannot use CondExp with a complex type" + ); + return std::complex(0); + } +} +/* %$$ + +$head CondExpRel$$ +The $cref/CPPAD_COND_EXP_REL/base_cond_exp/CondExpRel/$$ macro invocation +$srccode%cpp% */ +namespace CppAD { + CPPAD_COND_EXP_REL( std::complex ) +} +/* %$$ +used $code CondExpOp$$ above to +define $codei%CondExp%Rel%$$ for $code std::complex$$ arguments +and $icode%Rel%$$ equal to +$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. +$srccode%cpp% */ +namespace CppAD { + inline bool EqualOpSeq( + const std::complex &x , + const std::complex &y ) + { return x == y; + } +} +/* %$$ + +$head Identical$$ +Complex numbers do not carry operation sequence information. +Thus they are all parameters so the identical functions just check values. +$srccode%cpp% */ +namespace CppAD { + inline bool IdenticalCon(const std::complex &x) + { return true; } + inline bool IdenticalZero(const std::complex &x) + { return (x == std::complex(0., 0.) ); } + inline bool IdenticalOne(const std::complex &x) + { return (x == std::complex(1., 0.) ); } + inline bool IdenticalEqualCon( + const std::complex &x, const std::complex &y) + { return (x == y); } +} +/* %$$ + +$head Ordered$$ +Complex types do not support comparison operators, +$srccode%cpp% */ +# undef CPPAD_USER_MACRO +# define CPPAD_USER_MACRO(Fun) \ +inline bool Fun(const std::complex& x) \ +{ CppAD::ErrorHandler::Call( \ + true , __LINE__ , __FILE__ , \ + #Fun"(x)", \ + "Error: cannot use " #Fun " with x complex " \ + ); \ + return false; \ +} +namespace CppAD { + CPPAD_USER_MACRO(LessThanZero) + CPPAD_USER_MACRO(LessThanOrZero) + CPPAD_USER_MACRO(GreaterThanOrZero) + CPPAD_USER_MACRO(GreaterThanZero) + inline bool abs_geq( + const std::complex& x , + const std::complex& y ) + { return std::abs(x) >= std::abs(y); } +} +/* %$$ + +$head Integer$$ +The implementation of this function must agree +with the CppAD user specifications for complex arguments to the +$cref/Integer/Integer/x/Complex Types/$$ function: +$srccode%cpp% */ +namespace CppAD { + inline int Integer(const std::complex &x) + { return static_cast( x.real() ); } +} +/* %$$ + +$head azmul$$ +$srccode%cpp% */ +namespace CppAD { + CPPAD_AZMUL( std::complex ) +} +/* %$$ + +$head isnan$$ +The gcc 4.1.1 complier defines the function +$codei% + int std::complex::isnan( std::complex %z% ) +%$$ +(which is not specified in the C++ 1998 standard ISO/IEC 14882). +This causes an ambiguity between the function above and the CppAD +$cref/isnan/nan/$$ template function. +We avoid this ambiguity by defining a non-template version of +this function in the CppAD namespace. +$srccode%cpp% */ +namespace CppAD { + inline bool isnan(const std::complex& z) + { return (z != z); + } +} +/* %$$ + +$head Valid Unary Math$$ +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 >$$. +$srccode%cpp% */ +namespace CppAD { + CPPAD_STANDARD_MATH_UNARY(std::complex, cos) + CPPAD_STANDARD_MATH_UNARY(std::complex, cosh) + CPPAD_STANDARD_MATH_UNARY(std::complex, exp) + CPPAD_STANDARD_MATH_UNARY(std::complex, log) + CPPAD_STANDARD_MATH_UNARY(std::complex, sin) + CPPAD_STANDARD_MATH_UNARY(std::complex, sinh) + CPPAD_STANDARD_MATH_UNARY(std::complex, sqrt) +} +/* %$$ + +$head Invalid Unary Math$$ +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 >$$. +$srccode%cpp% */ +# undef CPPAD_USER_MACRO +# define CPPAD_USER_MACRO(Fun) \ +inline std::complex Fun(const std::complex& x) \ +{ CppAD::ErrorHandler::Call( \ + true , __LINE__ , __FILE__ , \ + #Fun"(x)", \ + "Error: cannot use " #Fun " with x complex " \ + ); \ + return std::complex(0); \ +} +namespace CppAD { + CPPAD_USER_MACRO(abs) + CPPAD_USER_MACRO(fabs) + CPPAD_USER_MACRO(acos) + 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 +} +/* %$$ + +$head pow $$ +The following defines a $code CppAD::pow$$ function that +is required to use $code AD< std::complex >$$: +$srccode%cpp% */ +namespace CppAD { + inline std::complex pow( + const std::complex &x , + const std::complex &y ) + { return std::pow(x, y); } +} +/* %$$ + +$head numeric_limits$$ +The following defines the CppAD $cref numeric_limits$$ +for the type $code std::complex$$: +$srccode%cpp% */ +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$$: +$srccode%cpp% */ +namespace CppAD { + CPPAD_TO_STRING(std::complex) +} +/* %$$ +$end +*/ +# undef CPPAD_USER_MACRO_ONE +# define CPPAD_USER_MACRO_ONE(Fun) \ +inline bool Fun(const std::complex& x) \ +{ CppAD::ErrorHandler::Call( \ + true , __LINE__ , __FILE__ , \ + #Fun"(x)", \ + "Error: cannot use " #Fun " with x complex " \ + ); \ + return false; \ +} +# undef CPPAD_USER_MACRO_TWO +# define CPPAD_USER_MACRO_TWO(Fun) \ +inline std::complex Fun(const std::complex& x) \ +{ CppAD::ErrorHandler::Call( \ + true , __LINE__ , __FILE__ , \ + #Fun"(x)", \ + "Error: cannot use " #Fun " with x complex " \ + ); \ + return std::complex(0); \ +} +namespace CppAD { + // CondExpOp ------------------------------------------------------ + inline std::complex CondExpOp( + enum CppAD::CompareOp cop , + const std::complex &left , + const std::complex &right , + const std::complex &trueCase , + const std::complex &falseCase ) + { CppAD::ErrorHandler::Call( + true , __LINE__ , __FILE__ , + "std::complex CondExpOp(...)", + "Error: cannot use CondExp with a complex type" + ); + return std::complex(0); + } + // CondExpRel -------------------------------------------------------- + CPPAD_COND_EXP_REL( std::complex ) + // EqualOpSeq ----------------------------------------------------- + inline bool EqualOpSeq( + const std::complex &x , + const std::complex &y ) + { return x == y; + } + // Identical ------------------------------------------------------ + inline bool IdenticalCon(const std::complex &x) + { return true; } + inline bool IdenticalZero(const std::complex &x) + { return (x == std::complex(0., 0.) ); } + inline bool IdenticalOne(const std::complex &x) + { return (x == std::complex(1., 0.) ); } + inline bool IdenticalEqualCon( + const std::complex &x, const std::complex &y) + { return (x == y); } + // Ordered -------------------------------------------------------- + CPPAD_USER_MACRO_ONE(LessThanZero) + CPPAD_USER_MACRO_ONE(LessThanOrZero) + CPPAD_USER_MACRO_ONE(GreaterThanOrZero) + CPPAD_USER_MACRO_ONE(GreaterThanZero) + inline bool abs_geq( + const std::complex& x , + const std::complex& y ) + { return std::abs(x) >= std::abs(y); } + // Integer ------------------------------------------------------ + inline int Integer(const std::complex &x) + { return static_cast( x.real() ); } + // isnan ------------------------------------------------------------- + inline bool isnan(const std::complex& z) + { return (z != z); + } + // Valid standard math functions -------------------------------- + CPPAD_STANDARD_MATH_UNARY(std::complex, cos) + CPPAD_STANDARD_MATH_UNARY(std::complex, cosh) + CPPAD_STANDARD_MATH_UNARY(std::complex, exp) + CPPAD_STANDARD_MATH_UNARY(std::complex, log) + CPPAD_STANDARD_MATH_UNARY(std::complex, sin) + CPPAD_STANDARD_MATH_UNARY(std::complex, sinh) + CPPAD_STANDARD_MATH_UNARY(std::complex, sqrt) + // Invalid standrd math functions ------------------------------- + CPPAD_USER_MACRO_TWO(abs) + CPPAD_USER_MACRO_TWO(acos) + CPPAD_USER_MACRO_TWO(asin) + CPPAD_USER_MACRO_TWO(atan) + CPPAD_USER_MACRO_TWO(sign) + // The pow function + inline std::complex pow( + const std::complex &x , + const std::complex &y ) + { return std::pow(x, y); } + // numeric_limits ------------------------------------------------- + CPPAD_NUMERIC_LIMITS(float, std::complex) + // to_string ------------------------------------------------- + CPPAD_TO_STRING(std::complex) +} + +// undefine macros only used by this file +# undef CPPAD_USER_MACRO +# undef CPPAD_USER_MACRO_ONE +# undef CPPAD_USER_MACRO_TWO + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/base_cond_exp.hpp cppad-2019.02.00.0/include/cppad/core/base_cond_exp.hpp --- cppad-2018.00.00.0/include/cppad/core/base_cond_exp.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/base_cond_exp.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,284 @@ +# ifndef CPPAD_CORE_BASE_COND_EXP_HPP +# define CPPAD_CORE_BASE_COND_EXP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin base_cond_exp$$ +$spell + alloc + Rel + hpp + enum + namespace + Op + Lt + Le + Eq + Ge + Gt + Ne + cond + exp + const + adolc + CppAD + inline +$$ + +$section Base Type Requirements for Conditional Expressions$$ + +$head Purpose$$ +These definitions are required by the user's code to support the +$codei%AD<%Base%>%$$ type for $cref CondExp$$ operations: + +$head CompareOp$$ +The following $code enum$$ type is used in the specifications below: +$codep +namespace CppAD { + // The conditional expression operator enum type + enum CompareOp + { CompareLt, // less than + CompareLe, // less than or equal + CompareEq, // equal + CompareGe, // greater than or equal + CompareGt, // greater than + CompareNe // not equal + }; +} +$$ + +$head CondExpTemplate$$ +The type $icode Base$$ must support the syntax +$codei% + %result% = CppAD::CondExpOp( + %cop%, %left%, %right%, %exp_if_true%, %exp_if_false% + ) +%$$ +which computes implements the corresponding $cref CondExp$$ +function when the result has prototype +$codei% + %Base% %result% +%$$ +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%& %exp_if_true% + const %Base%& %exp_if_false% +%$$ + +$subhead Ordered Type$$ +If $icode Base$$ is a relatively simple type +that supports +$code <$$, $code <=$$, $code ==$$, $code >=$$, and $code >$$ operators +its $code CondExpOp$$ function can be defined by +$codei% +namespace CppAD { + inline %Base% CondExpOp( + enum CppAD::CompareOp cop , + const %Base% &left , + const %Base% &right , + const %Base% &exp_if_true , + const %Base% &exp_if_false ) + { return CondExpTemplate( + cop, left, right, trueCase, falseCase); + } +} +%$$ +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, +the $code CondExpOp$$ function does not make sense. +In this case one might (but need not) define $code CondExpOp$$ as follows: +$codei% +namespace CppAD { + inline %Base% CondExpOp( + enum CompareOp cop , + const %Base% &left , + const %Base% &right , + const %Base% &exp_if_true , + const %Base% &exp_if_false ) + { // attempt to use CondExp with a %Base% argument + assert(0); + return %Base%(0); + } +} +%$$ +For example, see +$cref/complex CondExpOp/base_complex.hpp/CondExpOp/$$. + +$head CondExpRel$$ +The macro invocation +$codei% + CPPAD_COND_EXP_REL(%Base%) +%$$ +uses $code CondExpOp$$ above to define the following functions +$codei% + CondExpLt(%left%, %right%, %exp_if_true%, %exp_if_false%) + CondExpLe(%left%, %right%, %exp_if_true%, %exp_if_false%) + CondExpEq(%left%, %right%, %exp_if_true%, %exp_if_false%) + CondExpGe(%left%, %right%, %exp_if_true%, %exp_if_false%) + CondExpGt(%left%, %right%, %exp_if_true%, %exp_if_false%) +%$$ +where the arguments have type $icode Base$$. +This should be done inside of the CppAD namespace. +For example, see +$cref/base_alloc/base_alloc.hpp/CondExpRel/$$. + +$end +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +\file base_cond_exp.hpp +CondExp operations that aid in meeting Base type requirements. +*/ + +/*! +\def CPPAD_COND_EXP_BASE_REL(Type, Rel, Op) +This macro defines the operation +\verbatim + CondExpRel(left, right, exp_if_true, exp_if_false) +\endverbatim +The argument Type is the Base type for this base require operation. +The argument Rel is one of Lt, Le, Eq, Ge, Gt. +The argument Op is the corresponding CompareOp value. +*/ +# define CPPAD_COND_EXP_BASE_REL(Type, Rel, Op) \ + inline Type CondExp##Rel( \ + const Type& left , \ + const Type& right , \ + const Type& exp_if_true , \ + const Type& exp_if_false ) \ + { return CondExpOp(Op, left, right, exp_if_true, exp_if_false); \ + } + +/*! +\def CPPAD_COND_EXP_REL(Type) +The macro defines the operations +\verbatim + CondExpLt(left, right, exp_if_true, exp_if_false) + CondExpLe(left, right, exp_if_true, exp_if_false) + CondExpEq(left, right, exp_if_true, exp_if_false) + CondExpGe(left, right, exp_if_true, exp_if_false) + CondExpGt(left, right, exp_if_true, exp_if_false) +\endverbatim +The argument Type is the Base type for this base require operation. +*/ +# define CPPAD_COND_EXP_REL(Type) \ + CPPAD_COND_EXP_BASE_REL(Type, Lt, CompareLt) \ + CPPAD_COND_EXP_BASE_REL(Type, Le, CompareLe) \ + CPPAD_COND_EXP_BASE_REL(Type, Eq, CompareEq) \ + CPPAD_COND_EXP_BASE_REL(Type, Ge, CompareGe) \ + CPPAD_COND_EXP_BASE_REL(Type, Gt, CompareGt) + +/*! +Template function to implement Conditional Expressions for simple types +that have comparision operators. + +\tparam CompareType +is the type of the left and right operands to the comparision operator. + +\tparam ResultType +is the type of the result, which is the same as CompareType except +during forward and reverse mode sparese calculations. + +\param cop +specifices which comparision to use; i.e., +$code <$$, +$code <=$$, +$code ==$$, +$code >=$$, +$code >$$, or +$code !=$$. + +\param left +is the left operand to the comparision operator. + +\param right +is the right operand to the comparision operator. + +\param exp_if_true +is the return value is the comparision results in true. + +\param exp_if_false +is the return value is the comparision results in false. + +\return +see exp_if_true and exp_if_false above. +*/ +template +ResultType CondExpTemplate( + enum CompareOp cop , + const CompareType& left , + const CompareType& right , + const ResultType& exp_if_true , + const ResultType& exp_if_false ) +{ ResultType returnValue; + switch( cop ) + { + case CompareLt: + if( left < right ) + returnValue = exp_if_true; + else + returnValue = exp_if_false; + break; + + case CompareLe: + if( left <= right ) + returnValue = exp_if_true; + else + returnValue = exp_if_false; + break; + + case CompareEq: + if( left == right ) + returnValue = exp_if_true; + else + returnValue = exp_if_false; + break; + + case CompareGe: + if( left >= right ) + returnValue = exp_if_true; + else + returnValue = exp_if_false; + break; + + case CompareGt: + if( left > right ) + returnValue = exp_if_true; + else + returnValue = exp_if_false; + break; + + default: + CPPAD_ASSERT_UNKNOWN(0); + returnValue = exp_if_true; + } + return returnValue; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/base_double.hpp cppad-2019.02.00.0/include/cppad/core/base_double.hpp --- cppad-2018.00.00.0/include/cppad/core/base_double.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/base_double.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,229 @@ +# ifndef CPPAD_CORE_BASE_DOUBLE_HPP +# define CPPAD_CORE_BASE_DOUBLE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include + +/* +$begin base_double.hpp$$ +$spell + namespaces + cppad + hpp + azmul + expm1 + atanh + acosh + asinh + erf + endif + abs_geq + acos + asin + atan + cos + sqrt + tanh + std + fabs + bool + Lt Le Eq Ge Gt + Rel + CppAD + CondExpOp + namespace + inline + enum + const + exp + const +$$ + + +$section Enable use of AD where Base is double$$ + +$head CondExpOp$$ +The type $code double$$ is a relatively simple type that supports +$code <$$, $code <=$$, $code ==$$, $code >=$$, and $code >$$ operators; see +$cref/ordered type/base_cond_exp/CondExpTemplate/Ordered Type/$$. +Hence its $code CondExpOp$$ function is defined by +$srccode%cpp% */ +namespace CppAD { + inline double CondExpOp( + enum CompareOp cop , + const double& left , + const double& right , + const double& exp_if_true , + const double& exp_if_false ) + { return CondExpTemplate(cop, left, right, exp_if_true, exp_if_false); + } +} +/* %$$ + +$head CondExpRel$$ +The $cref/CPPAD_COND_EXP_REL/base_cond_exp/CondExpRel/$$ macro invocation +$srccode%cpp% */ +namespace CppAD { + CPPAD_COND_EXP_REL(double) +} +/* %$$ +uses $code CondExpOp$$ above to +define $codei%CondExp%Rel%$$ for $code double$$ arguments +and $icode%Rel%$$ equal to +$code Lt$$, $code Le$$, $code Eq$$, $code Ge$$, and $code Gt$$. + +$head EqualOpSeq$$ +The type $code double$$ is simple (in this respect) and so we define +$srccode%cpp% */ +namespace CppAD { + inline bool EqualOpSeq(const double& x, const double& y) + { return x == y; } +} +/* %$$ + +$head Identical$$ +The type $code double$$ is simple (in this respect) and so we define +$srccode%cpp% */ +namespace CppAD { + inline bool IdenticalCon(const double& x) + { return true; } + inline bool IdenticalZero(const double& x) + { return (x == 0.); } + inline bool IdenticalOne(const double& x) + { return (x == 1.); } + inline bool IdenticalEqualCon(const double& x, const double& y) + { return (x == y); } +} +/* %$$ + +$head Integer$$ +$srccode%cpp% */ +namespace CppAD { + inline int Integer(const double& x) + { return static_cast(x); } +} +/* %$$ + +$head azmul$$ +$srccode%cpp% */ +namespace CppAD { + CPPAD_AZMUL( double ) +} +/* %$$ + +$head Ordered$$ +The $code double$$ type supports ordered comparisons +$srccode%cpp% */ +namespace CppAD { + inline bool GreaterThanZero(const double& x) + { return x > 0.; } + inline bool GreaterThanOrZero(const double& x) + { return x >= 0.; } + inline bool LessThanZero(const double& x) + { return x < 0.; } + inline bool LessThanOrZero(const double& x) + { return x <= 0.; } + inline bool abs_geq(const double& x, const double& y) + { return std::fabs(x) >= std::fabs(y); } +} +/* %$$ + +$head Unary Standard Math$$ +The following macro invocations import the $code double$$ versions of +the unary standard math functions into the $code CppAD$$ namespace. +Importing avoids ambiguity errors when using both the +$code CppAD$$ and $code std$$ namespaces. +Note this also defines the $cref/float/base_float.hpp/Unary Standard Math/$$ +versions of these functions. +$srccode%cpp% */ +namespace CppAD { + using std::acos; + using std::asin; + using std::atan; + using std::cos; + using std::cosh; + using std::exp; + using std::fabs; + using std::log; + using std::log10; + using std::sin; + using std::sinh; + using std::sqrt; + using std::tan; + using std::tanh; +# if CPPAD_USE_CPLUSPLUS_2011 + using std::erf; + using std::asinh; + using std::acosh; + using std::atanh; + using std::expm1; + using std::log1p; +# endif +} +/* %$$ +The absolute value function is special because its $code std$$ name is +$code fabs$$ +$srccode%cpp% */ +namespace CppAD { + inline double abs(const double& x) + { return std::fabs(x); } +} +/* %$$ + +$head sign$$ +The following defines the $code CppAD::sign$$ function that +is required to use $code AD$$: +$srccode%cpp% */ +namespace CppAD { + inline double sign(const double& x) + { if( x > 0. ) + return 1.; + if( x == 0. ) + return 0.; + return -1.; + } +} +/* %$$ + +$head pow$$ +The following defines a $code CppAD::pow$$ function that +is required to use $code AD$$. +As with the unary standard math functions, +this has the exact same signature as $code std::pow$$, +so use it instead of defining another function. +$srccode%cpp% */ +namespace CppAD { + using std::pow; +} +/* %$$ + +$head numeric_limits$$ +The following defines the CppAD $cref numeric_limits$$ +for the type $code double$$: +$srccode%cpp% */ +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 +*/ + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/base_float.hpp cppad-2019.02.00.0/include/cppad/core/base_float.hpp --- cppad-2018.00.00.0/include/cppad/core/base_float.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/base_float.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,230 @@ +# ifndef CPPAD_CORE_BASE_FLOAT_HPP +# define CPPAD_CORE_BASE_FLOAT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include + +/* +$begin base_float.hpp$$ +$spell + namespaces + cppad + hpp + azmul + expm1 + atanh + acosh + asinh + erf + endif + abs_geq + acos + asin + atan + cos + sqrt + tanh + std + fabs + bool + Lt Le Eq Ge Gt + Rel + CppAD + CondExpOp + namespace + inline + enum + const + exp + const +$$ + + +$section Enable use of AD where Base is float$$ + +$head CondExpOp$$ +The type $code float$$ is a relatively simple type that supports +$code <$$, $code <=$$, $code ==$$, $code >=$$, and $code >$$ operators; see +$cref/ordered type/base_cond_exp/CondExpTemplate/Ordered Type/$$. +Hence its $code CondExpOp$$ function is defined by +$srccode%cpp% */ +namespace CppAD { + inline float CondExpOp( + enum CompareOp cop , + const float& left , + const float& right , + const float& exp_if_true , + const float& exp_if_false ) + { return CondExpTemplate(cop, left, right, exp_if_true, exp_if_false); + } +} +/* %$$ + +$head CondExpRel$$ +The $cref/CPPAD_COND_EXP_REL/base_cond_exp/CondExpRel/$$ macro invocation +$srccode%cpp% */ +namespace CppAD { + CPPAD_COND_EXP_REL(float) +} +/* %$$ +uses $code CondExpOp$$ above to +define $codei%CondExp%Rel%$$ for $code float$$ arguments +and $icode%Rel%$$ equal to +$code Lt$$, $code Le$$, $code Eq$$, $code Ge$$, and $code Gt$$. + +$head EqualOpSeq$$ +The type $code float$$ is simple (in this respect) and so we define +$srccode%cpp% */ +namespace CppAD { + inline bool EqualOpSeq(const float& x, const float& y) + { return x == y; } +} +/* %$$ + +$head Identical$$ +The type $code float$$ is simple (in this respect) and so we define +$srccode%cpp% */ +namespace CppAD { + inline bool IdenticalCon(const float& x) + { return true; } + inline bool IdenticalZero(const float& x) + { return (x == 0.f); } + inline bool IdenticalOne(const float& x) + { return (x == 1.f); } + inline bool IdenticalEqualCon(const float& x, const float& y) + { return (x == y); } +} +/* %$$ + +$head Integer$$ +$srccode%cpp% */ +namespace CppAD { + inline int Integer(const float& x) + { return static_cast(x); } +} +/* %$$ + +$head azmul$$ +$srccode%cpp% */ +namespace CppAD { + CPPAD_AZMUL( float ) +} +/* %$$ + +$head Ordered$$ +The $code float$$ type supports ordered comparisons +$srccode%cpp% */ +namespace CppAD { + inline bool GreaterThanZero(const float& x) + { return x > 0.f; } + inline bool GreaterThanOrZero(const float& x) + { return x >= 0.f; } + inline bool LessThanZero(const float& x) + { return x < 0.f; } + inline bool LessThanOrZero(const float& x) + { return x <= 0.f; } + inline bool abs_geq(const float& x, const float& y) + { return std::fabs(x) >= std::fabs(y); } +} +/* %$$ + +$head Unary Standard Math$$ +The following macro invocations import the $code float$$ versions of +the unary standard math functions into the $code CppAD$$ namespace. +Importing avoids ambiguity errors when using both the +$code CppAD$$ and $code std$$ namespaces. +Note this also defines the $cref/double/base_double.hpp/Unary Standard Math/$$ +versions of these functions. +$srccode%cpp% */ +namespace CppAD { + using std::acos; + using std::asin; + using std::atan; + using std::cos; + using std::cosh; + using std::exp; + using std::fabs; + using std::log; + using std::log10; + using std::sin; + using std::sinh; + using std::sqrt; + using std::tan; + using std::tanh; +# if CPPAD_USE_CPLUSPLUS_2011 + using std::erf; + using std::asinh; + using std::acosh; + using std::atanh; + using std::expm1; + using std::log1p; +# endif +} + +/* %$$ +The absolute value function is special because its $code std$$ name is +$code fabs$$ +$srccode%cpp% */ +namespace CppAD { + inline float abs(const float& x) + { return std::fabs(x); } +} +/* %$$ + +$head sign$$ +The following defines the $code CppAD::sign$$ function that +is required to use $code AD$$: +$srccode%cpp% */ +namespace CppAD { + inline float sign(const float& x) + { if( x > 0.f ) + return 1.f; + if( x == 0.f ) + return 0.f; + return -1.f; + } +} +/* %$$ +$head pow$$ +The following defines a $code CppAD::pow$$ function that +is required to use $code AD$$. +As with the unary standard math functions, +this has the exact same signature as $code std::pow$$, +so use it instead of defining another function. +$srccode%cpp% */ +namespace CppAD { + using std::pow; +} +/* %$$ + +$head numeric_limits$$ +The following defines the CppAD $cref numeric_limits$$ +for the type $code float$$: +$srccode%cpp% */ +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 +*/ + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/base_hash.hpp cppad-2019.02.00.0/include/cppad/core/base_hash.hpp --- cppad-2018.00.00.0/include/cppad/core/base_hash.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/base_hash.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,84 @@ +# ifndef CPPAD_CORE_BASE_HASH_HPP +# define CPPAD_CORE_BASE_HASH_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin base_hash$$ +$spell + alloc + Cpp + adouble + valgrind + const + inline +$$ + +$section Base Type Requirements for Hash Coding Values$$ + +$head Syntax$$ +$icode%code% = hash_code(%x%)%$$ + +$head Purpose$$ +CppAD uses a table of $icode Base$$ type values when recording +$codei%AD<%Base%>%$$ operations. +A hashing function is used to reduce number of values stored in this table; +for example, it is not necessary to store the value 3.0 every +time it is used as a $cref/parameter/con_dyn_var/Parameter/$$. + +$head Default$$ +The default hashing function works with the set of bits that correspond +to a $icode Base$$ value. +In most cases this works well, but in some cases +it does not. For example, in the +$cref base_adolc.hpp$$ case, an $code adouble$$ value can have +fields that are not initialized and $code valgrind$$ reported an error +when these are used to form the hash code. + +$head x$$ +This argument has prototype +$codei% + const %Base%& %x +%$$ +It is the value we are forming a hash code for. + +$head code$$ +The return value $icode code$$ has prototype +$codei% + unsigned short %code% +%$$ +It is the hash code corresponding to $icode x$$. This intention is the +commonly used values will have different hash codes. +The hash code must satisfy +$codei% + %code% < CPPAD_HASH_TABLE_SIZE +%$$ +so that it is a valid index into the hash code table. + +$head inline$$ +If you define this function, it should declare it to be $code inline$$, +so that you do not get multiple definitions from different compilation units. + +$head Example$$ +See the $code base_alloc$$ $cref/hash_code/base_alloc.hpp/hash_code/$$ +and the $code adouble$$ $cref/hash_code/base_adolc.hpp/hash_code/$$. + +$end +*/ + +/*! +\def CPPAD_HASH_TABLE_SIZE +the codes retruned by hash_code are between zero and CPPAD_HASH_TABLE_SIZE +minus one. +*/ +# define CPPAD_HASH_TABLE_SIZE 10000 + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/base_limits.hpp cppad-2019.02.00.0/include/cppad/core/base_limits.hpp --- cppad-2018.00.00.0/include/cppad/core/base_limits.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/base_limits.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,67 @@ +# ifndef CPPAD_CORE_BASE_LIMITS_HPP +# define CPPAD_CORE_BASE_LIMITS_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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 +$srccode%cpp% */ +# 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() ); }\ + static const int digits10 = std::numeric_limits::digits10;\ +}; +/* %$$ +$end +*/ + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/base_std_math.hpp cppad-2019.02.00.0/include/cppad/core/base_std_math.hpp --- cppad-2018.00.00.0/include/cppad/core/base_std_math.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/base_std_math.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,185 @@ +# ifndef CPPAD_CORE_BASE_STD_MATH_HPP +# define CPPAD_CORE_BASE_STD_MATH_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin base_std_math$$ +$spell + expm1 + atanh + acosh + asinh + inline + fabs + isnan + alloc + std + acos + asin + atan + cos + exp + sqrt + const + CppAD + namespace + erf +$$ + +$section Base Type Requirements for Standard Math Functions$$ + +$head Purpose$$ +These definitions are required for the user's code to use the type +$codei%AD<%Base%>%$$: + +$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$$ +$rnext +$icode%y% = abs(%x%)%$$ $cnext absolute value $rnext +$icode%y% = acos(%x%)%$$ $cnext inverse cosine $rnext +$icode%y% = asin(%x%)%$$ $cnext inverse sine $rnext +$icode%y% = atan(%x%)%$$ $cnext inverse tangent $rnext +$icode%y% = cos(%x%)%$$ $cnext cosine $rnext +$icode%y% = cosh(%x%)%$$ $cnext hyperbolic cosine $rnext +$icode%y% = exp(%x%)%$$ $cnext exponential $rnext +$icode%y% = fabs(%x%)%$$ $cnext absolute value $rnext +$icode%y% = log(%x%)%$$ $cnext natural logarithm $rnext +$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 +$tend +where the arguments and return value have the prototypes +$codei% + const %Base%& %x% + %Base% %y% +%$$ +For example, +$cref/base_alloc/base_alloc.hpp/Unary Standard Math/$$, + + +$head CPPAD_STANDARD_MATH_UNARY$$ +The macro invocation, within the CppAD namespace, +$codei% + CPPAD_STANDARD_MATH_UNARY(%Base%, %Fun%) +%$$ +defines the syntax +$codei% + %y% = CppAD::%Fun%(%x%) +%$$ +This macro uses the functions $codei%std::%Fun%$$ which +must be defined and have the same prototype as $codei%CppAD::%Fun%$$. +For example, +$cref/float/base_float.hpp/Unary Standard Math/$$. + +$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% + const %Base%& %x% + %Base% %y% +%$$ + +$head sign$$ +The type $icode Base$$ must support the syntax +$codei% + %y% = CppAD::sign(%x%) +%$$ +which computes +$latex \[ +y = \left\{ \begin{array}{ll} + +1 & {\rm if} \; x > 0 \\ + 0 & {\rm if} \; x = 0 \\ + -1 & {\rm if} \; x < 0 +\end{array} \right. +\] $$ +where $icode x$$ and $icode y$$ have the same prototype as above. +For example, see +$cref/base_alloc/base_alloc.hpp/sign/$$. +Note that, if ordered comparisons are not defined for the type $icode Base$$, +the $code code sign$$ function should generate an assert if it is used; see +$cref/complex invalid unary math/base_complex.hpp/Invalid Unary Math/$$. + +$head pow$$ +The type $icode Base$$ must support the syntax +$codei% + %z% = CppAD::pow(%x%, %y%) +%$$ +which computes $latex z = x^y$$. +The arguments $icode x$$ and $icode y$$ have prototypes +$codei% + const %Base%& %x% + const %Base%& %y% +%$$ +and the return value $icode z$$ has prototype +$codei% + %Base% %z% +%$$ +For example, see +$cref/base_alloc/base_alloc.hpp/pow/$$. + + +$head 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). +For example, see +$cref/base_complex/base_complex.hpp/isnan/$$. + + +$end +------------------------------------------------------------------------------- +*/ + +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +\file base_std_math.hpp +Defintions that aid meeting Base type requirements for standard math functions. +*/ + +/*! +\def CPPAD_STANDARD_MATH_UNARY(Type, Fun) +This macro defines the function +\verbatim + y = CppAD:Fun(x) +\endverbatim +where the argument x and return value y have type Type +using the corresponding function std::Fun. +*/ +# define CPPAD_STANDARD_MATH_UNARY(Type, Fun) \ + inline Type Fun(const Type& x) \ + { return std::Fun(x); } + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/base_to_string.hpp cppad-2019.02.00.0/include/cppad/core/base_to_string.hpp --- cppad-2018.00.00.0/include/cppad/core/base_to_string.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/base_to_string.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,65 @@ +# ifndef CPPAD_CORE_BASE_TO_STRING_HPP +# define CPPAD_CORE_BASE_TO_STRING_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$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: +$srccode%cpp% */ +# define CPPAD_TO_STRING(Base) \ +template <> struct to_string_struct\ +{ std::string operator()(const Base& value) \ + { std::stringstream os;\ + int n_digits = 1 + CppAD::numeric_limits::digits10; \ + os << std::setprecision(n_digits);\ + os << value;\ + return os.str();\ + }\ +}; +/* %$$ +$end +------------------------------------------------------------------------------ +*/ +// make sure to_string has been included +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/bender_quad.hpp cppad-2019.02.00.0/include/cppad/core/bender_quad.hpp --- cppad-2018.00.00.0/include/cppad/core/bender_quad.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/bender_quad.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,402 @@ +# ifndef CPPAD_CORE_BENDER_QUAD_HPP +# define CPPAD_CORE_BENDER_QUAD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin BenderQuad$$ +$spell + cppad.hpp + BAvector + gx + gxx + CppAD + Fy + dy + Jacobian + ADvector + const + dg + ddg +$$ + + +$section Computing Jacobian and Hessian of Bender's Reduced Objective$$ + +$head Syntax$$ +$codei% +# include +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 +$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 +type $icode ADvector$$. + +$head Purpose$$ +We are given the optimization problem +$latex \[ +\begin{array}{rcl} +{\rm minimize} & F(x, y) & {\rm w.r.t.} \; (x, y) \in \B{R}^n \times \B{R}^m +\end{array} +\] $$ +that is convex with respect to $latex y$$. +In addition, we are given a set of equations $latex H(x, y)$$ +such that +$latex \[ + H[ x , Y(x) ] = 0 \;\; \Rightarrow \;\; F_y [ x , Y(x) ] = 0 +\] $$ +(In fact, it is often the case that $latex H(x, y) = F_y (x, y)$$.) +Furthermore, it is easy to calculate a Newton step for these equations; i.e., +$latex \[ + dy = - [ \partial_y H(x, y)]^{-1} H(x, y) +\] $$ +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) ] +\] $$ +Note that if only the value and Jacobian are needed, they can be +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 +$codei% + const %BAvector% &%x% +%$$ +(see $cref/BAvector/BenderQuad/BAvector/$$ below) +and its size must be equal to $icode n$$. +It specifies the point at which we evaluating +the reduced objective function and its derivatives. + + +$head y$$ +The $code BenderQuad$$ argument $icode y$$ has prototype +$codei% + const %BAvector% &%y% +%$$ +and its size must be equal to $icode m$$. +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} + {\rm minimize} & F(x, y) & {\rm w.r.t.} \; y \in \B{R}^m +\end{array} +\] $$ + +$head 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). + +$subhead fun.f$$ +The $code BenderQuad$$ argument $icode fun$$ supports the syntax +$codei% + %f% = %fun%.f(%x%, %y%) +%$$ +The $icode%fun%.f%$$ argument $icode x$$ has prototype +$codei% + const %ADvector% &%x% +%$$ +(see $cref/ADvector/BenderQuad/ADvector/$$ below) +and its size must be equal to $icode n$$. +The $icode%fun%.f%$$ argument $icode y$$ has prototype +$codei% + const %ADvector% &%y% +%$$ +and its size must be equal to $icode m$$. +The $icode%fun%.f%$$ result $icode f$$ has prototype +$codei% + %ADvector% %f% +%$$ +and its size must be equal to one. +The value of $icode f$$ is +$latex \[ + f = F(x, y) +\] $$. + +$subhead fun.h$$ +The $code BenderQuad$$ argument $icode fun$$ supports the syntax +$codei% + %h% = %fun%.h(%x%, %y%) +%$$ +The $icode%fun%.h%$$ argument $icode x$$ has prototype +$codei% + const %ADvector% &%x% +%$$ +and its size must be equal to $icode n$$. +The $icode%fun%.h%$$ argument $icode y$$ has prototype +$codei% + const %BAvector% &%y% +%$$ +and its size must be equal to $icode m$$. +The $icode%fun%.h%$$ result $icode h$$ has prototype +$codei% + %ADvector% %h% +%$$ +and its size must be equal to $icode m$$. +The value of $icode h$$ is +$latex \[ + h = H(x, y) +\] $$. + +$subhead fun.dy$$ +The $code BenderQuad$$ argument $icode fun$$ supports the syntax +$codei% + %dy% = %fun%.dy(%x%, %y%, %h%) + +%x% +%$$ +The $icode%fun%.dy%$$ argument $icode x$$ has prototype +$codei% + const %BAvector% &%x% +%$$ +and its size must be equal to $icode n$$. +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% + +%y% +%$$ +The $icode%fun%.dy%$$ argument $icode y$$ has prototype +$codei% + const %BAvector% &%y% +%$$ +and its size must be equal to $icode m$$. +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% + +%h% +%$$ +The $icode%fun%.dy%$$ argument $icode h$$ has prototype +$codei% + const %ADvector% &%h% +%$$ +and its size must be equal to $icode m$$. +$codei% + +%dy% +%$$ +The $icode%fun%.dy%$$ result $icode dy$$ has prototype +$codei% + %ADvector% %dy% +%$$ +and its size must be equal to $icode m$$. +The return value $icode dy$$ is given by +$latex \[ + dy = - [ \partial_y H (x , y) ]^{-1} h +\] $$ +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., +$latex y + dy$$ is an approximate solution for the equation +$latex H (x, y + dy) = 0$$. + +$head g$$ +The argument $icode g$$ has prototype +$codei% + %BAvector% &%g% +%$$ +and has size one. +The input value of its element does not matter. +On output, +it contains the value of $latex G (x)$$; i.e., +$latex \[ + g[0] = G (x) +\] $$ + +$head gx$$ +The argument $icode gx$$ has prototype +$codei% + %BAvector% &%gx% +%$$ +and has size $latex n $$. +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$$, +$latex \[ + gx[ j ] = G^{(1)} (x)_j +\] $$ + +$head gxx$$ +The argument $icode gx$$ has prototype +$codei% + %BAvector% &%gxx% +%$$ +and has size $latex n \times n$$. +The input values of its elements do not matter. +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 \[ + 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 +$icode BAvector$$; i.e., +$codei% + %BAvector%::value_type +%$$ + +$head ADvector$$ +The type $icode ADvector$$ must be a +$cref SimpleVector$$ class with elements of type +$codei%AD<%Base%>%$$; i.e., +$codei% + %ADvector%::value_type +%$$ +must be the same type as +$codei% + AD< %BAvector%::value_type > +%$$. + + +$head Example$$ +$children% + example/general/bender_quad.cpp +%$$ +The file +$cref bender_quad.cpp$$ +contains an example and test of this operation. + + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN CppAD namespace + +template +void BenderQuad( + const BAvector &x , + const BAvector &y , + Fun fun , + BAvector &g , + BAvector &gx , + BAvector &gxx ) +{ // determine the base type + typedef typename BAvector::value_type Base; + + // check that BAvector is a SimpleVector class + CheckSimpleVector(); + + // declare the ADvector type + typedef CPPAD_TESTVECTOR(AD) ADvector; + + // size of the x and y spaces + size_t n = size_t(x.size()); + size_t m = size_t(y.size()); + + // check the size of gx and gxx + CPPAD_ASSERT_KNOWN( + g.size() == 1, + "BenderQuad: size of the vector g is not equal to 1" + ); + CPPAD_ASSERT_KNOWN( + size_t(gx.size()) == n, + "BenderQuad: size of the vector gx is not equal to n" + ); + CPPAD_ASSERT_KNOWN( + size_t(gxx.size()) == n * n, + "BenderQuad: size of the vector gxx is not equal to n * n" + ); + + // some temporary indices + size_t i, j; + + // variable versions x + ADvector vx(n); + for(j = 0; j < n; j++) + vx[j] = x[j]; + + // declare the independent variables + Independent(vx); + + // evaluate h = H(x, y) + ADvector h(m); + h = fun.h(vx, y); + + // evaluate dy (x) = Newton step as a function of x through h only + ADvector dy(m); + dy = fun.dy(x, y, h); + + // variable version of y + ADvector vy(m); + for(j = 0; j < m; j++) + vy[j] = y[j] + dy[j]; + + // 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.optimize(); + + // value of G(x) + g = Gtilde.Forward(0, x); + + // initial forward direction vector as zero + BAvector dx(n); + for(j = 0; j < n; j++) + dx[j] = Base(0.0); + + // weight, first and second order derivative values + BAvector dg(1), w(1), ddw(2 * n); + w[0] = 1.; + + + // Jacobian and Hessian of G(x) is equal Jacobian and Hessian of Gtilde + for(j = 0; j < n; j++) + { // compute partials in x[j] direction + dx[j] = Base(1.0); + dg = Gtilde.Forward(1, dx); + gx[j] = dg[0]; + + // restore the dx vector to zero + dx[j] = Base(0.0); + + // compute second partials w.r.t x[j] and x[l] for l = 1, n + ddw = Gtilde.Reverse(2, w); + for(i = 0; i < n; i++) + gxx[ i * n + j ] = ddw[ i * 2 + 1 ]; + } + + return; +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/bool_fun.hpp cppad-2019.02.00.0/include/cppad/core/bool_fun.hpp --- cppad-2018.00.00.0/include/cppad/core/bool_fun.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/bool_fun.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,241 @@ +# ifndef CPPAD_CORE_BOOL_FUN_HPP +# define CPPAD_CORE_BOOL_FUN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin BoolFun$$ +$spell + namespace + bool + CppAD + const +$$ + + +$section AD Boolean Functions$$ + +$head Syntax$$ +$codei%CPPAD_BOOL_UNARY(%Base%, %unary_name%) +%$$ +$icode%b% = %unary_name%(%u%) +%$$ +$icode%b% = %unary_name%(%x%) +%$$ +$codei%CPPAD_BOOL_BINARY(%Base%, %binary_name%) +%$$ +$icode%b% = %binary_name%(%u%, %v%) +%$$ +$icode%b% = %binary_name%(%x%, %y%)%$$ + + +$head Purpose$$ +Create a $code bool$$ valued function that has $codei%AD<%Base%>%$$ arguments. + +$head unary_name$$ +This is the name of the $code bool$$ valued function with one argument +(as it is used in the source code). +The user must provide a version of $icode unary_name$$ where +the argument has type $icode Base$$. +CppAD uses this to create a version of $icode unary_name$$ where the +argument has type $codei%AD<%Base%>%$$. + +$head u$$ +The argument $icode u$$ has prototype +$codei% + const %Base% &%u% +%$$ +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 +user provided version of $icode binary_name$$. + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const AD<%Base%> &%x% +%$$ +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 +CppAD provided version of $icode binary_name$$. + +$head b$$ +The result $icode b$$ has prototype +$codei% + bool %b% +%$$ + +$head Create 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 +(not the $code CppAD$$ namespace) +but must be outside of any routine. + +$head binary_name$$ +This is the name of the $code bool$$ valued function with two arguments +(as it is used in the source code). +The user must provide a version of $icode binary_name$$ where +the arguments have type $icode Base$$. +CppAD uses this to create a version of $icode binary_name$$ where the +arguments have type $codei%AD<%Base%>%$$. + +$head v$$ +The argument $icode v$$ has prototype +$codei% + const %Base% &%v% +%$$ +It is the second argument to +the user provided version of $icode binary_name$$. + +$head y$$ +The argument $icode x$$ has prototype +$codei% + const AD<%Base%> &%y% +%$$ +It is the second argument to +the CppAD provided version of $icode binary_name$$. + +$head Create 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 +(not the $code CppAD$$ namespace) +but must be outside of any routine. + + +$head Operation Sequence$$ +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 Example$$ +$children% + example/general/bool_fun.cpp +%$$ +The file +$cref bool_fun.cpp$$ +contains an example and test of these operations. + +$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). + +$end +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file bool_fun.hpp +Routines and macros that implement functions from AD to bool. +*/ + +/*! +Macro that defines a unary function bool F(AD x) +using bool F(Base x). + +\param Base +base for the AD type of arguments to this unary bool valued function. + +\param unary_name +name of this unary function; i.e., F. +*/ +# define CPPAD_BOOL_UNARY(Base, unary_name) \ + inline bool unary_name (const CppAD::AD &x) \ + { \ + return CppAD::AD::UnaryBool(unary_name, x); \ + } + +/*! +Deprecated name for CPPAD_BOOL_UNARY +*/ +# define CppADCreateUnaryBool CPPAD_BOOL_UNARY + +/*! +Link a function name, and AD value pair to function call with base argument +and bool retrun value. + +\param FunName +is the name of the function that we are linking. + +\param x +is the argument where we are evaluating the function. +*/ +template +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) +using bool F(Base x, Base y). + +\param Base +base for the AD type of arguments to this binary bool valued function. + +\param binary_name +name of this binary function; i.e., F. +*/ + +# define CPPAD_BOOL_BINARY(Base, binary_name) \ + inline bool binary_name ( \ + const CppAD::AD &x, const CppAD::AD &y) \ + { \ + return CppAD::AD::BinaryBool(binary_name, x, y); \ + } +/*! +Deprecated name for CPPAD_BOOL_BINARY +*/ +# define CppADCreateBinaryBool CPPAD_BOOL_BINARY + + +/*! +Link a function name, and two AD values to function call with base arguments +and bool retrun value. + +\param FunName +is the name of the function that we are linking. + +\param x +is the first argument where we are evaluating the function at. + +\param y +is the second argument where we are evaluating the function at. +*/ +template +bool AD::BinaryBool( + bool FunName(const Base &x, const Base &y), + const AD &x, const AD &y +) +{ + return FunName(x.value_, y.value_); +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/bool_valued.hpp cppad-2019.02.00.0/include/cppad/core/bool_valued.hpp --- cppad-2018.00.00.0/include/cppad/core/bool_valued.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/bool_valued.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,49 @@ +# ifndef CPPAD_CORE_BOOL_VALUED_HPP +# define CPPAD_CORE_BOOL_VALUED_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin BoolValued$$ +$spell + Bool +$$ + + +$section Bool Valued Operations and Functions with AD Arguments$$ + +$children% + include/cppad/core/compare.hpp% + include/cppad/core/near_equal_ext.hpp% + include/cppad/core/bool_fun.hpp% + include/cppad/core/con_dyn_var.hpp% + include/cppad/core/equal_op_seq.hpp +%$$ +$table +$rref Compare$$ +$rref NearEqualExt$$ +$rref BoolFun$$ +$rref con_dyn_var$$ +$rref EqualOpSeq$$ +$tend + + +$end +*/ + +# include +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/capacity_order.hpp cppad-2019.02.00.0/include/cppad/core/capacity_order.hpp --- cppad-2018.00.00.0/include/cppad/core/capacity_order.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/capacity_order.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,256 @@ +# ifndef CPPAD_CORE_CAPACITY_ORDER_HPP +# define CPPAD_CORE_CAPACITY_ORDER_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin capacity_order$$ +$spell + var + taylor_ + xq + yq +$$ + + +$section Controlling Taylor Coefficients Memory Allocation$$ + +$head Syntax$$ +$icode%f%.capacity_order(%c%)%$$ + +$subhead See Also$$ +$cref seq_property$$ + +$head Purpose$$ +The Taylor coefficients calculated by $cref Forward$$ mode calculations +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 $icode%xq%.size() == %f%.Domain()%$$, +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 +(to hold $code Forward$$ results for subsequent calculations). + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ + +$head c$$ +The argument $icode c$$ has prototype +$codei% + size_t %c% +%$$ +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 +$icode q$$ equal to $icode Q$$, +it should be faster to pre-allocate memory for these calls using +$codei% + %f%.capacity_order(%c%) +%$$ +with $icode c$$ equal to $latex Q + 1$$. +If you do no do this, $code Forward$$ will automatically allocate memory +and will copy the results to a larger buffer, when necessary. +$pre + +$$ +Note that each call to $cref Dependent$$ frees the old memory +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$$), +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. + +$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 +the value of the +$cref/independent variables/glossary/Tape/Independent Variable/$$ +when the AD operation sequence was recorded. +This corresponds to $icode%c% == 1%$$. + +$children% + example/general/capacity_order.cpp +%$$ +$head Example$$ +The file +$cref capacity_order.cpp$$ +contains an example and test of these operations. + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file capacity_order.hpp +Control of number of orders allocated. +\} +*/ + +/*! +Control of number of orders and directions allocated. + +\tparam Base +The type used during the forward mode computations; i.e., the corresponding +recording of operations used the type AD. + +\param c +is the number of orders to allocate memory for. +If c == 0 then r must also be zero. +In this case num_order_taylor_, cap_order_taylor_, and num_direction_taylor_ +are all set to zero. +In addition, taylor_.clear() is called. + +\param r +is the number of directions to allocate memory for. +If c == 1 then r must also be one. +In all cases, it must hold that + + r == num_direction_taylor_ || num_order_taylor <= 1 + +Upon return, num_direction_taylor_ is equal to r. + +\par num_order_taylor_ +The output value of num_order_taylor_ is the mininumum of its input +value and c. This minimum is the number of orders that are copied to the +new taylor coefficient buffer. + +\par num_direction_taylor_ +The output value of num_direction_taylor_ is equal to r. +*/ + +template +void ADFun::capacity_order(size_t c, size_t r) +{ // temporary indices + size_t i, k, ell; + + if( (c == cap_order_taylor_) & (r == num_direction_taylor_) ) + return; + + if( c == 0 ) + { CPPAD_ASSERT_UNKNOWN( r == 0 ); + taylor_.clear(); + num_order_taylor_ = 0; + cap_order_taylor_ = 0; + num_direction_taylor_ = r; + return; + } + CPPAD_ASSERT_UNKNOWN(r==num_direction_taylor_ || num_order_taylor_<=1); + + // Allocate new taylor with requested number of orders and directions + size_t new_len = ( (c-1)*r + 1 ) * num_var_tape_; + local::pod_vector_maybe new_taylor(new_len); + + // number of orders to copy + size_t p = std::min(num_order_taylor_, c); + if( p > 0 ) + { + // old order capacity + size_t C = cap_order_taylor_; + + // old number of directions + size_t R = num_direction_taylor_; + + // copy the old data into the new matrix + CPPAD_ASSERT_UNKNOWN( p == 1 || r == R ); + for(i = 0; i < num_var_tape_; i++) + { // copy zero order + size_t old_index = ((C-1) * R + 1) * i + 0; + size_t new_index = ((c-1) * r + 1) * i + 0; + new_taylor[ new_index ] = taylor_[ old_index ]; + // copy higher orders + for(k = 1; k < p; k++) + { for(ell = 0; ell < R; ell++) + { old_index = ((C-1) * R + 1) * i + (k-1) * R + ell + 1; + new_index = ((c-1) * r + 1) * i + (k-1) * r + ell + 1; + new_taylor[ new_index ] = taylor_[ old_index ]; + } + } + } + } + + // replace taylor_ by new_taylor + taylor_.swap(new_taylor); + cap_order_taylor_ = c; + num_order_taylor_ = p; + num_direction_taylor_ = r; + + // note that the destructor for new_taylor will free the old taylor memory + return; +} + +/*! +User API control of number of orders allocated. + +\tparam Base +The type used during the forward mode computations; i.e., the corresponding +recording of operations used the type AD. + +\param c +is the number of orders to allocate memory for. +If c == 0, +num_order_taylor_, cap_order_taylor_, and num_direction_taylor_ +are all set to zero. +In addition, taylor_.clear() is called. + +\par num_order_taylor_ +The output value of num_order_taylor_ is the mininumum of its input +value and c. This minimum is the number of orders that are copied to the +new taylor coefficient buffer. + +\par num_direction_taylor_ +If is zero (one), num_direction_taylor_ is set to zero (one). +Otherwise, if num_direction_taylor_ is zero, it is set to one. +Othwerwise, num_direction_taylor_ is not modified. +*/ + +template +void ADFun::capacity_order(size_t c) +{ size_t r; + if( (c == 0) | (c == 1) ) + { r = c; + capacity_order(c, r); + return; + } + r = num_direction_taylor_; + if( r == 0 ) + r = 1; + capacity_order(c, r); + return; +} + +} // END CppAD namespace + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/check_for_nan.hpp cppad-2019.02.00.0/include/cppad/core/check_for_nan.hpp --- cppad-2018.00.00.0/include/cppad/core/check_for_nan.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/check_for_nan.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,240 @@ +# ifndef CPPAD_CORE_CHECK_FOR_NAN_HPP +# define CPPAD_CORE_CHECK_FOR_NAN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$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/general/check_for_nan.cpp +%$$ +The file +$cref check_for_nan.cpp$$ +contains an example and test of these operations. + +$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 + +/*! +Set check_for_nan + +\param value +new value for this flag. +*/ +template +void ADFun::check_for_nan(bool value) +{ check_for_nan_ = value; } + +/*! +Get check_for_nan + +\return +current value of check_for_nan_. +*/ +template +bool ADFun::check_for_nan(void) const +{ return check_for_nan_; } + +/*! +Stores a vector in a file when nans occur. + +\param vec [in] +is the vector that is stored. + +\param [out] file_name +is the file where the vector is stored +*/ +template +void put_check_for_nan(const CppAD::vector& vec, std::string& file_name) +{ + size_t char_size = sizeof(Base) * vec.size(); + // 2DO: add vec.data() to C11 tests and use it when C11 true + // const char* char_ptr = reinterpret_cast( vec.data() ); + const char* char_ptr = reinterpret_cast( &vec[0] ); + +# 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 ) + if( tmpnam_s( &name[0], L_tmpnam_s ) != 0 ) + { CPPAD_ASSERT_KNOWN( + false, + "Cannot create a temporary file name" + ); + } + // file_name = name.data(); + file_name = &name[0]; +# 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; +} + +/*! +Gets a vector that was stored by put_check_for_nan. + +\param vec [out] +is the vector that is stored. + +\param file_name [in] +is the file where the vector is stored +*/ +template +void get_check_for_nan(CppAD::vector& vec, const std::string& file_name) +{ // + std::streamsize char_size = std::streamsize( sizeof(Base) * vec.size() ); + // char* char_ptr = reinterpret_cast( vec.data() ); + char* char_ptr = reinterpret_cast( &vec[0] ); + // + 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-2018.00.00.0/include/cppad/core/chkpoint_one/chkpoint_one.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_one/chkpoint_one.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_one/chkpoint_one.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_one/chkpoint_one.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,621 @@ +# ifndef CPPAD_CORE_CHKPOINT_ONE_CHKPOINT_ONE_HPP +# define CPPAD_CORE_CHKPOINT_ONE_CHKPOINT_ONE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file chkpoint_one.hpp +First generation checkpoint functions. +*/ + +/* +$begin chkpoint_one$$ +$spell + mul + chkpoint + alloc + inuse + sv + var + cppad.hpp + CppAD + checkpoint + checkpointing + algo + atom_fun + const + enum + bool + recomputed +$$ + +$section Checkpoint Functions: First Generation$$ + +$head Deprecated 2019-01-14$$ +Using the $code checkpoint$$ class has been deprecated. +Use $cref chkpoint_two$$ instead. + +$head Syntax$$ +$codei%checkpoint<%Base%> %atom_fun%( + %name%, %algo%, %ax%, %ay%, %sparsity%, %optimize% +) +%sv% = %atom_fun%.size_var() +%atom_fun%.option(%option_value%) +%algo%(%ax%, %ay%) +%atom_fun%(%ax%, %ay%) +checkpoint<%Base%>::clear()%$$ + +$head See Also$$ +$cref atomic_two$$, $cref reverse_checkpoint.cpp$$ + +$head Purpose$$ + +$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{R}^n \rightarrow \B{R}^m$$. + +$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. + +$subhead Repeating Forward$$ +Normally, CppAD store $cref forward$$ mode results until they freed +using $cref capacity_order$$ or the corresponding $cref ADFun$$ object is +deleted. This is not true for checkpoint functions because a checkpoint +function may be used repeatedly with different arguments in the same tape. +Thus, forward mode results are recomputed each time a checkpoint function +is used during a forward or reverse mode sweep. + +$subhead Restriction$$ +The $cref/operation sequence/glossary/Operation/Sequence/$$ +representing $latex f(x)$$ cannot depend on the value of $latex x$$. +The approach in the $cref reverse_checkpoint.cpp$$ example case be applied +when the operation sequence depends on $latex x$$. + +$subhead Multiple Level AD$$ +If $icode Base$$ is an AD type, it is possible to record $icode Base$$ +operations. +Note that $icode atom_fun$$ will treat $icode algo$$ as an atomic +operation while recording $codei%AD%<%Base%>%$$ operations, but not while +recording $icode Base$$ operations. +See the $code chkpoint_one_mul_level.cpp$$ example. + + +$head Method$$ +The $code checkpoint$$ class is derived from $code atomic_base$$ +and makes this easy. +It implements all the $code atomic_base$$ +$cref/virtual functions/atomic_two/Virtual Functions/$$ +and hence its source code $code cppad/core/chkpoint_one/chkpoint_one.hpp$$ +provides an example implementation of $cref atomic_two$$. +The difference is that $code chkpoint_one.hpp$$ uses AD +instead of user provided derivatives. + +$head constructor$$ +The syntax for the checkpoint constructor is +$codei% + checkpoint<%Base%> %atom_fun%(%name%, %algo%, %ax%, %ay%) +%$$ +$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/atomic_two_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. + +$head ADVector$$ +The type $icode ADVector$$ must be a +$cref/simple vector class/SimpleVector/$$ with elements of type +$codei%AD<%Base%>%$$. + +$head name$$ +This $icode checkpoint$$ constructor argument has prototype +$codei% + const char* %name% +%$$ +It is the name used for error reporting. +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 +$codei% + const %ADVector%& %ax% +%$$ +and size must be equal to $icode n$$. +It specifies vector $latex x \in \B{R}^n$$ +at which an $codei%AD<%Base%>%$$ version of +$latex y = f(x)$$ is to be evaluated. + +$head ay$$ +This argument has prototype +$codei% + %ADVector%& %ay% +%$$ +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 +$latex y = f(x)$$. + +$head sparsity$$ +This argument has prototype +$codei% + atomic_base<%Base%>::option_enum %sparsity% +%$$ +It specifies $cref/sparsity/atomic_two_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 optimize$$ +This argument has prototype +$codei% + bool %optimize% +%$$ +It specifies if the recording corresponding to the atomic function +should be $cref/optimized/optimize/$$. +One expects to use a checkpoint function many times, so it should +be worth the time to optimize its operation sequence. +For debugging purposes, it may be useful to use the +original operation sequence (before optimization) +because it corresponds more closely to $icode algo$$. +This argument is optional and its default value is true. + + +$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 atom_fun$$. +This is an $codei%atomic_base<%Base%>%$$ function and its documentation +can be found at $cref atomic_two_option$$. + +$head algo$$ +The type of $icode algo$$ is arbitrary, except for the fact that +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 +$cref/operation sequence/glossary/Operation/Sequence/$$ +does not depend on the value of $icode ax$$. + +$head atom_fun$$ +Given $icode ax$$ it computes the corresponding value of $icode ay$$ +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 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 Memory$$ + +$subhead Restriction$$ +The $code clear$$ routine cannot be called +while in $cref/parallel/ta_in_parallel/$$ execution mode. + +$head Parallel Mode$$ +The CppAD checkpoint function delays the caching of certain calculations +until they are needed. +In $cref/parallel model/ta_parallel_setup/$$, +this may result in $cref/thread_alloc::inuse(thread)/ta_inuse/$$ +being non-zero even though the specified thread is no longer active. +This memory will be freed when the checkpoint object is deleted. + +$subhead clear$$ +The $code atomic_base$$ class holds onto static work space +that is not connected to a particular object +(in order to 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 +atomic functions for a specific value of $icode Base$$. + +$end +*/ + +template +class checkpoint : public atomic_base { +// --------------------------------------------------------------------------- +private: + /// same as option_enum in base class + typedef typename atomic_base::option_enum option_enum; + // + // ------------------------------------------------------------------------ + // member_ + // ------------------------------------------------------------------------ + // same checkpoint object can be used by multiple threads + struct member_struct { + // + /// AD function corresponding to this checkpoint object + ADFun f_; + ADFun< AD, Base > af_; + // + /// sparsity for entire Jacobian f(x)^{(1)} + /// does not change so can cache it + local::sparse_list jac_sparse_set_; + vectorBool jac_sparse_bool_; + // + /// sparsity for sum_i f_i(x)^{(2)} does not change so can cache it + local::sparse_list hes_sparse_set_; + vectorBool hes_sparse_bool_; + }; + /// This version of work is const except during constructor + member_struct const_member_; + + /// use pointers and allocate memory to avoid false sharing + member_struct* member_[CPPAD_MAX_NUM_THREADS]; + // + /// allocate member_ for this thread + void allocate_member(size_t thread) + { if( member_[thread] == CPPAD_NULL ) + { member_[thread] = new member_struct; + // The function is recorded in sequential mode and placed in + // const_member_.f_, other threads have copy. + member_[thread]->f_ = const_member_.f_; + } + return; + } + // + /// free member_ for this thread + void free_member(size_t thread) + { if( member_[thread] != CPPAD_NULL ) + { delete member_[thread]; + member_[thread] = CPPAD_NULL; + } + return; + } + // ------------------------------------------------------------------------ + option_enum sparsity(void) + { return static_cast< atomic_base* >(this)->sparsity(); } + // ------------------------------------------------------------------------ + /// set jac_sparse_set_ + void set_jac_sparse_set(void); + /// set jac_sparse_bool_ + void set_jac_sparse_bool(void); + // ------------------------------------------------------------------------ + /// set hes_sparse_set_ + void set_hes_sparse_set(void); + /// set hes_sparse_bool_ + void set_hes_sparse_bool(void); + // ------------------------------------------------------------------------ + /*! + 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 , + const vector& x + ); + // ------------------------------------------------------------------------ + /*! + 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 , + const vector& x + ); + /*! + 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 , + const vector& x + ); +public: + // ------------------------------------------------------------------------ + /*! + Constructor of a checkpoint object + + \param name [in] + is the user's name for the AD version of this atomic operation. + + \param algo [in/out] + user routine that compute AD function values + (not const because state may change during evaluation). + + \param ax [in] + argument value where algo operation sequence is taped. + + \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. + + \param optimize [in] + should the operation sequence corresponding to the algo be optimized. + The default value is true, but it is + sometimes useful to use false for debugging purposes. + */ + template + checkpoint( + const char* name , + Algo& algo , + const ADVector& ax , + ADVector& ay , + option_enum sparsity = + atomic_base::pack_sparsity_enum , + bool optimize = true + ); + /// destructor + ~checkpoint(void) + { +# ifndef NDEBUG + if( thread_alloc::in_parallel() ) + { std::string msg = atomic_base::afun_name(); + msg += ": checkpoint destructor called in parallel mode."; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# endif + for(size_t thread = 0; thread < CPPAD_MAX_NUM_THREADS; ++thread) + free_member(thread); + } + // ------------------------------------------------------------------------ + /*! + Implement the user call to atom_fun.size_var(). + */ + size_t size_var(void) + { // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + return member_[thread]->f_.size_var(); + } + // ------------------------------------------------------------------------ + /*! + 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. + */ + template + void operator()(const ADVector& ax, ADVector& ay, size_t id = 0) + { CPPAD_ASSERT_KNOWN( + id == 0, + "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 + + \copydetails atomic_base::forward + */ + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ); + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector< AD >& atx , + vector< AD >& aty + ); + // ------------------------------------------------------------------------ + /*! + 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 + ); + virtual bool reverse( + size_t q , + const vector< AD >& atx , + const vector< AD >& aty , + vector< AD >& apx , + const vector< AD >& apy + ); + // ------------------------------------------------------------------------ + /*! + Link from user_atomic to forward sparse Jacobian pack + + \copydetails atomic_base::for_sparse_jac + */ + virtual bool for_sparse_jac( + size_t q , + const vectorBool& r , + vectorBool& s , + const vector& x + ); + /*! + 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 , + const vector& x + ); + /*! + 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 , + const vector& x + ); + // ------------------------------------------------------------------------ + /*! + Link from user_atomic to reverse sparse Jacobian pack + + \copydetails atomic_base::rev_sparse_jac + */ + virtual bool rev_sparse_jac( + size_t q , + const vectorBool& rt , + vectorBool& st , + const vector& x + ); + /*! + 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 , + const vector& x + ); + /*! + Link from user_atomic to reverse Jacobian sets + + \copydetails atomic_base::rev_sparse_jac + */ + virtual bool rev_sparse_jac( + size_t q , + const vector< std::set >& rt , + vector< std::set >& st , + const vector& x + ); + // ------------------------------------------------------------------------ + /*! + 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 vectorBool& r , + const vectorBool& u , + vectorBool& v , + const vector& x + ); + /*! + 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 , + vector& t , + size_t q , + const vector& r , + const vector& u , + vector& v , + const vector& x + ); + /*! + 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 , + const vector& x + ); +}; + +} // END_CPPAD_NAMESPACE + +// functions implemented in cppad/core/checkpoint files +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_one/ctor.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_one/ctor.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_one/ctor.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_one/ctor.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,62 @@ +# ifndef CPPAD_CORE_CHKPOINT_ONE_CTOR_HPP +# define CPPAD_CORE_CHKPOINT_ONE_CTOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +template +template +checkpoint::checkpoint( + const char* name , + Algo& algo , + const ADVector& ax , + ADVector& ay , + option_enum sparsity , + bool optimize +) : atomic_base(name, sparsity) +{ +# ifndef NDEBUG + if( thread_alloc::in_parallel() ) + { std::string msg = name; + msg += ": checkpoint constructor called in parallel mode."; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# endif + for(size_t thread = 0; thread < CPPAD_MAX_NUM_THREADS; ++thread) + member_[thread] = CPPAD_NULL; + // + 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); + // record mapping from x_tmp to ay + algo(x_tmp, ay); + // create function f_ : x -> y + const_member_.f_.Dependent(ay); + if( optimize ) + { // suppress checking for nan in f_ results + // (see optimize documentation for atomic functions) + const_member_.f_.check_for_nan(false); + // + // now optimize + const_member_.f_.optimize(); + } + // now disable checking of comparison operations + // 2DO: add a debugging mode that checks for changes and aborts + const_member_.f_.compare_change_count(0); +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_one/for_sparse_jac.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_one/for_sparse_jac.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_one/for_sparse_jac.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_one/for_sparse_jac.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,135 @@ +# ifndef CPPAD_CORE_CHKPOINT_ONE_FOR_SPARSE_JAC_HPP +# define CPPAD_CORE_CHKPOINT_ONE_FOR_SPARSE_JAC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +template +template +bool checkpoint::for_sparse_jac( + size_t q , + const sparsity_type& r , + sparsity_type& s , + const vector& x ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + // during user sparsity calculations + size_t m = member_[thread]->f_.Range(); + size_t n = member_[thread]->f_.Domain(); + if( member_[thread]->jac_sparse_bool_.size() == 0 ) + set_jac_sparse_bool(); + if( member_[thread]->jac_sparse_set_.n_set() != 0 ) + member_[thread]->jac_sparse_set_.resize(0, 0); + CPPAD_ASSERT_UNKNOWN( member_[thread]->jac_sparse_bool_.size() == m * n ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->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++) + { for(size_t k = 0; k < q; k++) + { // initialize sparsity for S(i,k) + bool s_ik = false; + // S(i,k) = sum_j J(i,j) * R(j,k) + for(size_t j = 0; j < n; j++) + { bool J_ij = member_[thread]->jac_sparse_bool_[ i * n + j]; + bool R_jk = r[j * q + k ]; + s_ik |= ( J_ij & R_jk ); + } + s[i * q + k] = s_ik; + } + } + return ok; +} +template +bool checkpoint::for_sparse_jac( + size_t q , + const vectorBool& r , + vectorBool& s , + const vector& x ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + return for_sparse_jac< vectorBool >(q, r, s, x); +} +template +bool checkpoint::for_sparse_jac( + size_t q , + const vector& r , + vector& s , + const vector& x ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + return for_sparse_jac< vector >(q, r, s, x); +} +template +bool checkpoint::for_sparse_jac( + size_t q , + const vector< std::set >& r , + vector< std::set >& s , + const vector& x ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + // during user sparsity calculations + size_t m = member_[thread]->f_.Range(); + size_t n = member_[thread]->f_.Domain(); + if( member_[thread]->jac_sparse_bool_.size() != 0 ) + member_[thread]->jac_sparse_bool_.clear(); + if( member_[thread]->jac_sparse_set_.n_set() == 0 ) + set_jac_sparse_set(); + CPPAD_ASSERT_UNKNOWN( member_[thread]->jac_sparse_bool_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->jac_sparse_set_.n_set() == m ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->jac_sparse_set_.end() == n ); + CPPAD_ASSERT_UNKNOWN( r.size() == n ); + CPPAD_ASSERT_UNKNOWN( s.size() == m ); + + bool ok = true; + for(size_t i = 0; i < m; i++) + s[i].clear(); + + // sparsity for s = jac_sparse_set_ * r + for(size_t i = 0; i < m; i++) + { // compute row i of the return pattern + local::sparse_list::const_iterator set_itr( + member_[thread]->jac_sparse_set_, i + ); + size_t j = *set_itr; + 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 = *(++set_itr); + } + } + + return ok; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_one/forward.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_one/forward.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_one/forward.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_one/forward.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,170 @@ +# ifndef CPPAD_CORE_CHKPOINT_ONE_FORWARD_HPP +# define CPPAD_CORE_CHKPOINT_ONE_FORWARD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +// --------------------------------------------------------------------------- +template +bool checkpoint::forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + size_t n = member_[thread]->f_.Domain(); + size_t m = member_[thread]->f_.Range(); + // + CPPAD_ASSERT_UNKNOWN( member_[thread]->f_.size_var() > 0 ); + CPPAD_ASSERT_UNKNOWN( tx.size() % (q+1) == 0 ); + CPPAD_ASSERT_UNKNOWN( ty.size() % (q+1) == 0 ); + 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( member_[thread]->jac_sparse_set_.n_set() != 0 ) + member_[thread]->jac_sparse_set_.resize(0,0); + if( member_[thread]->jac_sparse_bool_.size() != 0 ) + member_[thread]->jac_sparse_bool_.clear(); + // + if( member_[thread]->hes_sparse_set_.n_set() != 0 ) + member_[thread]->hes_sparse_set_.resize(0,0); + if( member_[thread]->hes_sparse_bool_.size() != 0 ) + member_[thread]->hes_sparse_bool_.clear(); + } + if( vx.size() > 0 ) + { // need Jacobian sparsity pattern to determine variable relation + // during user recording using checkpoint functions + if( sparsity() == atomic_base::set_sparsity_enum ) + { if( member_[thread]->jac_sparse_set_.n_set() == 0 ) + set_jac_sparse_set(); + CPPAD_ASSERT_UNKNOWN( + member_[thread]->jac_sparse_set_.n_set() == m + ); + CPPAD_ASSERT_UNKNOWN( + member_[thread]->jac_sparse_set_.end() == n + ); + // + for(size_t i = 0; i < m; i++) + { vy[i] = false; + local::sparse_list::const_iterator set_itr( + member_[thread]->jac_sparse_set_, i + ); + size_t j = *set_itr; + 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 = *(++set_itr); + } + } + } + else + { if( member_[thread]->jac_sparse_set_.n_set() != 0 ) + member_[thread]->jac_sparse_set_.resize(0, 0); + if( member_[thread]->jac_sparse_bool_.size() == 0 ) + set_jac_sparse_bool(); + CPPAD_ASSERT_UNKNOWN( + member_[thread]->jac_sparse_set_.n_set() == 0 + ); + CPPAD_ASSERT_UNKNOWN( + member_[thread]->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( member_[thread]->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] ); + } + } + } + } + } + // compute forward results for orders zero through q + ty = member_[thread]->f_.Forward(q, tx); + + // 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; + member_[thread]->f_.capacity_order(c, r); + return ok; +} + +// --------------------------------------------------------------------------- +template +bool checkpoint::forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector< AD >& atx , + vector< AD >& aty ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + // make sure af_ is defined + if( member_[thread]->af_.size_var() == 0 ) + member_[thread]->af_ = member_[thread]->f_.base2ad(); + // +# ifndef NDEBUG + size_t n = member_[thread]->f_.Domain(); + size_t m = member_[thread]->f_.Range(); +# endif + // + CPPAD_ASSERT_UNKNOWN( member_[thread]->f_.size_var() > 0 ); + CPPAD_ASSERT_UNKNOWN( atx.size() % (q+1) == 0 ); + CPPAD_ASSERT_UNKNOWN( aty.size() % (q+1) == 0 ); + CPPAD_ASSERT_UNKNOWN( n == atx.size() / (q+1) ); + CPPAD_ASSERT_UNKNOWN( m == aty.size() / (q+1) ); + CPPAD_ASSERT_UNKNOWN( vx.size() == 0 ) + bool ok = true; + // + // during user forward mode + if( member_[thread]->jac_sparse_set_.n_set() != 0 ) + member_[thread]->jac_sparse_set_.resize(0,0); + if( member_[thread]->jac_sparse_bool_.size() != 0 ) + member_[thread]->jac_sparse_bool_.clear(); + // + if( member_[thread]->hes_sparse_set_.n_set() != 0 ) + member_[thread]->hes_sparse_set_.resize(0,0); + if( member_[thread]->hes_sparse_bool_.size() != 0 ) + member_[thread]->hes_sparse_bool_.clear(); + // + // compute forward results for orders zero through q + aty = member_[thread]->af_.Forward(q, atx); + + // no longer need the Taylor coefficients in af_ + // (have to reconstruct them every time) + // Hold onto sparsity pattern because it is always good. + size_t c = 0; + size_t r = 0; + member_[thread]->af_.capacity_order(c, r); + // + return ok; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_one/reverse.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_one/reverse.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_one/reverse.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_one/reverse.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,125 @@ +# ifndef CPPAD_CORE_CHKPOINT_ONE_REVERSE_HPP +# define CPPAD_CORE_CHKPOINT_ONE_REVERSE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +// --------------------------------------------------------------------------- +template +bool checkpoint::reverse( + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + +# ifndef NDEBUG + size_t n = member_[thread]->f_.Domain(); + size_t m = member_[thread]->f_.Range(); +# endif + CPPAD_ASSERT_UNKNOWN( member_[thread]->f_.size_var() > 0 ); + CPPAD_ASSERT_UNKNOWN( n == tx.size() / (q+1) ); + CPPAD_ASSERT_UNKNOWN( m == ty.size() / (q+1) ); + CPPAD_ASSERT_UNKNOWN( tx.size() % (q+1) == 0 ); + CPPAD_ASSERT_UNKNOWN( ty.size() % (q+1) == 0 ); + CPPAD_ASSERT_UNKNOWN( px.size() == n * (q+1) ); + CPPAD_ASSERT_UNKNOWN( py.size() == m * (q+1) ); + bool ok = true; + + // put proper forward mode coefficients in f_ +# ifdef NDEBUG + // compute forward results for orders zero through q + member_[thread]->f_.Forward(q, tx); +# else + size_t i, j, k; + // + // compute forward results for orders zero through q + vector check_ty = member_[thread]->f_.Forward(q, tx); + for(i = 0; i < m; i++) + { for(k = 0; k <= q; k++) + { j = i * (q+1) + k; + CPPAD_ASSERT_UNKNOWN( check_ty[j] == ty[j] ); + } + } +# endif + // now can run reverse mode + px = member_[thread]->f_.Reverse(q+1, py); + + // no longer need the Taylor coefficients in f_ + // (have to reconstruct them every time) + size_t c = 0; + size_t r = 0; + member_[thread]->f_.capacity_order(c, r); + return ok; +} +// --------------------------------------------------------------------------- +template +bool checkpoint::reverse( + size_t q , + const vector< AD >& atx , + const vector< AD >& aty , + vector< AD >& apx , + const vector< AD >& apy ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + // make sure af_ is defined + if( member_[thread]->af_.size_var() == 0 ) + member_[thread]->af_ = member_[thread]->f_.base2ad(); +# ifndef NDEBUG + size_t n = member_[thread]->f_.Domain(); + size_t m = member_[thread]->f_.Range(); +# endif + CPPAD_ASSERT_UNKNOWN( member_[thread]->f_.size_var() > 0 ); + CPPAD_ASSERT_UNKNOWN( n == atx.size() / (q+1) ); + CPPAD_ASSERT_UNKNOWN( m == aty.size() / (q+1) ); + CPPAD_ASSERT_UNKNOWN( atx.size() % (q+1) == 0 ); + CPPAD_ASSERT_UNKNOWN( aty.size() % (q+1) == 0 ); + CPPAD_ASSERT_UNKNOWN( apx.size() == n * (q+1) ); + CPPAD_ASSERT_UNKNOWN( apy.size() == m * (q+1) ); + bool ok = true; + + // put proper forward mode coefficients in f_ +# ifdef NDEBUG + // compute forward results for orders zero through q + member_[thread]->af_.Forward(q, atx); +# else + size_t i, j, k; + // + // compute forward results for orders zero through q + vector< AD > check_aty = member_[thread]->af_.Forward(q, atx); + for(i = 0; i < m; i++) + { for(k = 0; k <= q; k++) + { j = i * (q+1) + k; + CPPAD_ASSERT_UNKNOWN( check_aty[j] == aty[j] ); + } + } +# endif + // now can run reverse mode + apx = member_[thread]->af_.Reverse(q+1, apy); + + // no longer need the Taylor coefficients in f_ + // (have to reconstruct them every time) + size_t c = 0; + size_t r = 0; + member_[thread]->af_.capacity_order(c, r); + return ok; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_one/rev_sparse_hes.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_one/rev_sparse_hes.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_one/rev_sparse_hes.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_one/rev_sparse_hes.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,214 @@ +# ifndef CPPAD_CORE_CHKPOINT_ONE_REV_SPARSE_HES_HPP +# define CPPAD_CORE_CHKPOINT_ONE_REV_SPARSE_HES_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +template +template +bool checkpoint::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 , + const vector& x ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + size_t n = member_[thread]->f_.Domain(); +# ifndef NDEBUG + size_t m = member_[thread]->f_.Range(); +# endif + 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( member_[thread]->hes_sparse_bool_.size() == 0 ) + set_hes_sparse_bool(); + if( member_[thread]->hes_sparse_set_.n_set() != 0 ) + member_[thread]->hes_sparse_set_.resize(0, 0); + CPPAD_ASSERT_UNKNOWN( member_[thread]->hes_sparse_bool_.size() == n * n ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->hes_sparse_set_.n_set() == 0 ); + + + // compute sparsity pattern for T(x) = S(x) * f'(x) + t = member_[thread]->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 = member_[thread]->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++) + { // initialize sparsity pattern for H(i,k) + bool h_ik = false; + // H(i,k) = sum_j f''(i,j) * R(j,k) + for(size_t j = 0; j < n; j++) + { bool f_ij = member_[thread]->hes_sparse_bool_[i * n + j]; + bool r_jk = r[j * q + k]; + h_ik |= ( f_ij & r_jk ); + } + // sparsity for H(i,k) + v[i * q + k] = h_ik; + } + } + + // 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; +} +template +bool checkpoint::rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const vectorBool& r , + const vectorBool& u , + vectorBool& v , + const vector& x ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + return rev_sparse_hes< vectorBool >(vx, s, t, q, r, u, v, x); +} +template +bool checkpoint::rev_sparse_hes( + const vector& vx , + const vector& s , + vector& t , + size_t q , + const vector& r , + const vector& u , + vector& v , + const vector& x ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + return rev_sparse_hes< vector >(vx, s, t, q, r, u, v, x); +} +template +bool checkpoint::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 , + const vector& x ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + size_t n = member_[thread]->f_.Domain(); +# ifndef NDEBUG + size_t m = member_[thread]->f_.Range(); +# endif + 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; + + // make sure hes_sparse_set_ has been set + if( member_[thread]->hes_sparse_bool_.size() != 0 ) + member_[thread]->hes_sparse_bool_.clear(); + if( member_[thread]->hes_sparse_set_.n_set() == 0 ) + set_hes_sparse_set(); + CPPAD_ASSERT_UNKNOWN( member_[thread]->hes_sparse_bool_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->hes_sparse_set_.n_set() == n ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->hes_sparse_set_.end() == n ); + + // compute sparsity pattern for T(x) = S(x) * f'(x) + t = member_[thread]->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) + // 2DO: change a to use INTERNAL_SPARSE_SET + bool transpose = true; + vector< std::set > a(n); + a = member_[thread]->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++) + { v[i].clear(); + local::sparse_list::const_iterator set_itr( + member_[thread]->hes_sparse_set_, i + ); + size_t j = *set_itr; + 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 = *(++set_itr); + } + } + // compute sparsity pattern for V(x) = A(x) + H(x) + 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); + } + } + + return ok; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_one/rev_sparse_jac.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_one/rev_sparse_jac.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_one/rev_sparse_jac.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_one/rev_sparse_jac.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,139 @@ +# ifndef CPPAD_CORE_CHKPOINT_ONE_REV_SPARSE_JAC_HPP +# define CPPAD_CORE_CHKPOINT_ONE_REV_SPARSE_JAC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +template +template +bool checkpoint::rev_sparse_jac( + size_t q , + const sparsity_type& rt , + sparsity_type& st , + const vector& x ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + // during user sparsity calculations + size_t m = member_[thread]->f_.Range(); + size_t n = member_[thread]->f_.Domain(); + if( member_[thread]->jac_sparse_bool_.size() == 0 ) + set_jac_sparse_bool(); + if( member_[thread]->jac_sparse_set_.n_set() != 0 ) + member_[thread]->jac_sparse_set_.resize(0, 0); + CPPAD_ASSERT_UNKNOWN( member_[thread]->jac_sparse_bool_.size() == m * n ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->jac_sparse_set_.n_set() == 0 ); + CPPAD_ASSERT_UNKNOWN( rt.size() == m * q ); + CPPAD_ASSERT_UNKNOWN( st.size() == n * q ); + bool ok = true; + // + // S = R * J where J is jacobian + for(size_t i = 0; i < q; i++) + { for(size_t j = 0; j < n; j++) + { // initialize sparsity for S(i,j) + bool s_ij = false; + // S(i,j) = sum_k R(i,k) * J(k,j) + for(size_t k = 0; k < m; k++) + { // sparsity for R(i, k) + bool R_ik = rt[ k * q + i ]; + bool J_kj = member_[thread]->jac_sparse_bool_[ k * n + j ]; + s_ij |= (R_ik & J_kj); + } + // set sparsity for S^T + st[ j * q + i ] = s_ij; + } + } + return ok; +} +template +bool checkpoint::rev_sparse_jac( + size_t q , + const vectorBool& rt , + vectorBool& st , + const vector& x ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + return rev_sparse_jac< vectorBool >(q, rt, st, x); +} +template +bool checkpoint::rev_sparse_jac( + size_t q , + const vector& rt , + vector& st , + const vector& x ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + return rev_sparse_jac< vector >(q, rt, st, x); +} +template +bool checkpoint::rev_sparse_jac( + size_t q , + const vector< std::set >& rt , + vector< std::set >& st , + const vector& x ) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + // during user sparsity calculations + size_t m = member_[thread]->f_.Range(); + size_t n = member_[thread]->f_.Domain(); + if( member_[thread]->jac_sparse_bool_.size() != 0 ) + member_[thread]->jac_sparse_bool_.clear(); + if( member_[thread]->jac_sparse_set_.n_set() == 0 ) + set_jac_sparse_set(); + CPPAD_ASSERT_UNKNOWN( member_[thread]->jac_sparse_bool_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->jac_sparse_set_.n_set() == m ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->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 + local::sparse_list::const_iterator set_itr( + member_[thread]->jac_sparse_set_, i + ); + size_t j = *set_itr; + while( j < n ) + { // j is row index in jac_sparse_set^T + st[j].insert(k); + j = *(++set_itr); + } + } + } + + return ok; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_one/set_hes_sparse_bool.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_one/set_hes_sparse_bool.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_one/set_hes_sparse_bool.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_one/set_hes_sparse_bool.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,53 @@ +# ifndef CPPAD_CORE_CHKPOINT_ONE_SET_HES_SPARSE_BOOL_HPP +# define CPPAD_CORE_CHKPOINT_ONE_SET_HES_SPARSE_BOOL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +template +void checkpoint::set_hes_sparse_bool(void) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + CPPAD_ASSERT_UNKNOWN( member_[thread]->hes_sparse_bool_.size() == 0 ); + size_t n = member_[thread]->f_.Domain(); + size_t m = member_[thread]->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; + member_[thread]->f_.ForSparseJac(n, identity, transpose, dependency); + member_[thread]->hes_sparse_bool_ = member_[thread]->f_.RevSparseHes(n, all_one, transpose); + CPPAD_ASSERT_UNKNOWN( member_[thread]->hes_sparse_bool_.size() == n * n ); + // + // drop the forward sparsity results from f_ + member_[thread]->f_.size_forward_bool(0); + CPPAD_ASSERT_UNKNOWN( member_[thread]->f_.size_forward_bool() == 0 ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->f_.size_forward_set() == 0 ); +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_one/set_hes_sparse_set.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_one/set_hes_sparse_set.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_one/set_hes_sparse_set.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_one/set_hes_sparse_set.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,57 @@ +# ifndef CPPAD_CORE_CHKPOINT_ONE_SET_HES_SPARSE_SET_HPP +# define CPPAD_CORE_CHKPOINT_ONE_SET_HES_SPARSE_SET_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +template +void checkpoint::set_hes_sparse_set(void) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + CPPAD_ASSERT_UNKNOWN( member_[thread]->hes_sparse_set_.n_set() == 0 ); + size_t n = member_[thread]->f_.Domain(); + size_t m = member_[thread]->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 + local::sparse_list identity; + identity.resize(n, n); + for(size_t j = 0; j < n; j++) + { // use add_element because only adding one element per set + identity.add_element(j, j); + } + + // compute sparsity pattern for H(x) = sum_i f_i(x)^{(2)} + bool transpose = false; + bool dependency = false; + member_[thread]->f_.ForSparseJacCheckpoint( + n, identity, transpose, dependency, member_[thread]->jac_sparse_set_ + ); + member_[thread]->f_.RevSparseHesCheckpoint( + n, all_one, transpose, member_[thread]->hes_sparse_set_ + ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->hes_sparse_set_.n_set() == n ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->hes_sparse_set_.end() == n ); + // + // drop the forward sparsity results from f_ + member_[thread]->f_.size_forward_set(0); +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_one/set_jac_sparse_bool.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_one/set_jac_sparse_bool.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_one/set_jac_sparse_bool.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_one/set_jac_sparse_bool.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,56 @@ +# ifndef CPPAD_CORE_CHKPOINT_ONE_SET_JAC_SPARSE_BOOL_HPP +# define CPPAD_CORE_CHKPOINT_ONE_SET_JAC_SPARSE_BOOL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +template +void checkpoint::set_jac_sparse_bool(void) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + CPPAD_ASSERT_UNKNOWN( member_[thread]->jac_sparse_bool_.size() == 0 ); + bool transpose = false; + bool dependency = true; + size_t n = member_[thread]->f_.Domain(); + size_t m = member_[thread]->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); + } + member_[thread]->jac_sparse_bool_ = member_[thread]->f_.ForSparseJac( + n, identity, transpose, dependency + ); + member_[thread]->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); + } + member_[thread]->jac_sparse_bool_ = member_[thread]->f_.RevSparseJac( + m, identity, transpose, dependency + ); + } + CPPAD_ASSERT_UNKNOWN( member_[thread]->f_.size_forward_bool() == 0 ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->f_.size_forward_set() == 0 ); +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_one/set_jac_sparse_set.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_one/set_jac_sparse_set.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_one/set_jac_sparse_set.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_one/set_jac_sparse_set.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,58 @@ +# ifndef CPPAD_CORE_CHKPOINT_ONE_SET_JAC_SPARSE_SET_HPP +# define CPPAD_CORE_CHKPOINT_ONE_SET_JAC_SPARSE_SET_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +template +void checkpoint::set_jac_sparse_set(void) +{ // make sure member_ is allocated for this thread + size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + // + CPPAD_ASSERT_UNKNOWN( member_[thread]->jac_sparse_set_.n_set() == 0 ); + bool transpose = false; + bool dependency = true; + size_t n = member_[thread]->f_.Domain(); + size_t m = member_[thread]->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 ) + { local::sparse_list identity; + identity.resize(n, n); + for(size_t j = 0; j < n; j++) + { // use add_element because only adding one element per set + identity.add_element(j, j); + } + member_[thread]->f_.ForSparseJacCheckpoint( + n, identity, transpose, dependency, member_[thread]->jac_sparse_set_ + ); + member_[thread]->f_.size_forward_set(0); + } + else + { local::sparse_list identity; + identity.resize(m, m); + for(size_t i = 0; i < m; i++) + { // use add_element because only adding one element per set + identity.add_element(i, i); + } + member_[thread]->f_.RevSparseJacCheckpoint( + m, identity, transpose, dependency, member_[thread]->jac_sparse_set_ + ); + } + CPPAD_ASSERT_UNKNOWN( member_[thread]->f_.size_forward_set() == 0 ); + CPPAD_ASSERT_UNKNOWN( member_[thread]->f_.size_forward_bool() == 0 ); +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_two/chk_fun.omh cppad-2019.02.00.0/include/cppad/core/chkpoint_two/chk_fun.omh --- cppad-2018.00.00.0/include/cppad/core/chkpoint_two/chk_fun.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_two/chk_fun.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,65 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ +$begin chkpoint_two_chk_fun$$ + +$spell + const + chk + chkpoint +$$ + +$section Using Checkpoint Functions$$ + +$head Syntax$$ +$icode%chk_fun%(%ax%, %ay%)%$$ + +$head Purpose$$ +Given $icode ax$$, +this call computes the corresponding value of $icode ay$$. +If $codei%AD<%Base%>%$$ operations are being recorded, +it enters the computation as an $cref atomic_three$$ +operation in the recording; +see $cref/start recording/Independent/Start Recording/$$. + +$head chk_fun$$ +This object must have been created using the +$cref/chkpoint_two/chkpoint_two_ctor/chk_fun/$$ constructor. + +$head ADVector$$ +The type $icode ADVector$$ must be a +$cref/simple vector class/SimpleVector/$$ with elements of type +$codei%AD<%Base%>%$$. + +$head ax$$ +This argument has prototype +$codei% + const %ADVector%& ax +%$$ +and its size equal to $icode%n% = %fun%.Domain()%$$ +where $cref/fun/chkpoint_two_ctor/fun/$$ is the $codei%ADFun<%Base%>%$$ +function in used the constructor for $icode chk_fun$$. +It specifies vector $latex x \in \B{R}^n$$ +at which we are computing an $codei%AD<%Base%>%$$ version of +$latex y = g(x)$$. + +$head ay$$ +This argument has prototype +$codei% + %ADVector%& ay +%$$ +and its size must be equal to $icode%m% = %fun%.Range()%$$. +The input values of its elements do not matter. +Upon return, it is an $codei%AD<%Base%>%$$ version of +$latex y = g(x)$$. + + +$end diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_two/chkpoint_two.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_two/chkpoint_two.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_two/chkpoint_two.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_two/chkpoint_two.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,294 @@ +# ifndef CPPAD_CORE_CHKPOINT_TWO_CHKPOINT_TWO_HPP +# define CPPAD_CORE_CHKPOINT_TWO_CHKPOINT_TWO_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file chkpoint_two.hpp +Second generation checkpoint functions. +*/ + +/* +$begin chkpoint_two$$ +$spell + CppAD + chk + chkpoint + hpp + cppad + bool + hes +$$ + +$section Checkpoint Functions: Second Generation$$ + +$head Syntax$$ +$codei%chkpoint_two<%Base%> %chk_fun%( %fun%, %name%, + %internal_bool%, %use_hes_sparsity%, %use_base2ad%, %use_in_parallel% +)%$$ +$codei% +%chk_fun%(%ax%, %ay%) +%$$ +$icode%chk_fun%.new_dynamic(%dynamic%) +%$$ + +$head Reduce Memory$$ +You can reduce the size of the tape and memory required for AD +using a checkpoint representation of a function +$latex g : \B{R}^n \rightarrow \B{R}^m$$. + +$head Faster Recording$$ +It may also reduce the time to make a recording if the same $latex g(x)$$ +is used many times (with different values) during the +recording of an $codei%ADFun<%Base%>%$$ object. + +$head Repeating Forward$$ +Normally, CppAD stores $cref forward$$ mode results, +until they freed using $cref capacity_order$$, +or the corresponding $cref ADFun$$ object is deleted. +This is not true for $code chkpoint_two$$ functions +because the same checkpoint function may be used repeatedly +with different arguments during a single forward mode operation. +Thus, forward mode results are computed for each use of $icode chk_fun$$ +in a forward mode sweep. + +$head Operation Sequence$$ +The $cref/operation sequence/glossary/Operation/Sequence/$$ +representing $latex g(x)$$ is fixed; i.e., +it cannot depend on the value of $latex x$$. + +$head atomic_three$$ +The $code chkpoint_two$$ class is derived from $code atomic_three$$, +hence some of its error message will refer to atomic operations. +The $code chkpoint_two$$ class implements all the +$cref/virtual functions/atomic_three/Virtual Functions/$$ +and hence its source code, +$codei% + include/cppad/core/chkpoint_two/chkpoint_two.hpp +%$$ +provides an example for $cref atomic_three$$ operations. +The difference is that $code chkpoint_two.hpp$$ uses AD +instead of user provided derivatives. + +$head Base$$ +The type $icode Base$$ specifies the base type for AD operations; +i.e., $icode chk_fun$$ can be used during the recording of +$codei%AD<%Base%>%$$ operations. + + +$childtable%include/cppad/core/chkpoint_two/ctor.hpp + %include/cppad/core/chkpoint_two/chk_fun.omh + %include/cppad/core/chkpoint_two/dynamic.hpp + %example/chkpoint_two/get_started.cpp + %example/chkpoint_two/compare.cpp + %example/chkpoint_two/base2ad.cpp + %example/chkpoint_two/dynamic.cpp + %example/chkpoint_two/ode.cpp +%$$ + +$end +*/ + +template +class chkpoint_two : public atomic_three { +// --------------------------------------------------------------------------- +private: + /// are sparsity calculations using bools or sets of integers + const bool internal_bool_; + // + /// can this checkpoint function calculate Hessian sparsity patterns + const bool use_hes_sparsity_; + // + /// can this checkpoint function be used in base2ad recordings + const bool use_base2ad_; + // + /// can this checkpoint function be used in parallel mode + const bool use_in_parallel_; + // + /// Jacobian sparsity for g(x) with dependncy true. + /// This is set by the constructor and constant after that. + sparse_rc< vector > jac_sparsity_; + // + /// Hessian sparsity for g(x). If use_hes_sparsity_ is true, + /// This is set by the constructor and constant after that. + sparse_rc< vector > hes_sparsity_; + // + /// Function corresponding to this checkpoint object. + /// If use_in_parallel_, this is constant after the constructor. + ADFun g_; + // + /// AD version of function corresponding to this checkpoint object + /// If use_in_parallel_, this is constant after the constructor. + ADFun< AD, Base> ag_; + // ------------------------------------------------------------------------ + // member_ + // ------------------------------------------------------------------------ + /// If use_in_parallel_ is true, must have a separate copy member data + /// that is not constant. + struct member_struct { + // + /// function corresponding to this checkpoint object + ADFun g_; + // + /// AD version of this function object + ADFun< AD, Base > ag_; + // + }; + /// use pointers and allocate memory to avoid false sharing + /// (initialized to null by constructor) + member_struct* member_[CPPAD_MAX_NUM_THREADS]; + // + // ------------------------------------------------------------------------ + /// allocate member_ for this thread + void allocate_member(size_t thread) + { CPPAD_ASSERT_UNKNOWN( use_in_parallel_ ); + if( member_[thread] == CPPAD_NULL ) + { // Other threds have copy of corresponding informaiton. + member_[thread]->g_ = g_; + member_[thread]->ag_ = ag_; + } + return; + } + // + // ------------------------------------------------------------------------ + /// free member_ for this thread + void free_member(size_t thread) + { if( member_[thread] != CPPAD_NULL ) + { delete member_[thread]; + member_[thread] = CPPAD_NULL; + } + return; + } + // ----------------------------------------------------------------------- + // atomic_three virtual functions + // ------------------------------------------------------------------------ + // type + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y + ); + // forward + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector& taylor_x , + vector& taylor_y + ); + // AD forward + virtual bool forward( + const vector< AD >& aparameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector< AD >& ataylor_x , + vector< AD >& ataylor_y + ); + // reverse + virtual bool reverse( + const vector& parameter_x , + const vector& type_x , + size_t order_up , + const vector& taylor_x , + const vector& taylor_y , + vector& partial_x , + const vector& partial_y + ); + // AD reverse + virtual bool reverse( + const vector< AD >& aparameter_x , + const vector& type_x , + size_t order_up , + const vector< AD >& ataylor_x , + const vector< AD >& ataylor_y , + vector< AD >& apartial_x , + const vector< AD >& apartial_y + ); + // jac_sparsity + virtual bool jac_sparsity( + const vector& parameter_x , + const vector& type_x , + bool dependency , + const vector& select_x , + const vector& select_y , + sparse_rc< vector >& pattern_out + ); + // hes_sparsity + virtual bool hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const vector& select_x , + const vector& select_y , + sparse_rc< vector >& pattern_out + ); + // rev_depend + virtual bool rev_depend( + const vector& parameter_x , + const vector& type_x , + vector& depend_x , + const vector& depend_y + ); +public: + // ctor + chkpoint_two( + const ADFun& fun , + const std::string& name , + bool internal_bool , + bool use_hes_sparsity , + bool use_base2ad , + bool use_in_parallel + ); + // + // destructor + ~chkpoint_two(void); + // + // assignment operator + void operator=(const chkpoint_two& other) + { CPPAD_ASSERT_KNOWN(false, + "cannot use chkpoint_two assignment operator" + ); + } + // copy constructor + chkpoint_two(const chkpoint_two& other) + : + internal_bool_ ( other.internal_bool_ ) , + use_hes_sparsity_ ( other.use_hes_sparsity_ ) , + use_base2ad_ ( other.use_base2ad_ ) , + use_in_parallel_ ( other.use_in_parallel_ ) , + jac_sparsity_ ( other.jac_sparsity_ ) , + hes_sparsity_ ( other.hes_sparsity_ ) + { g_ = other.g_; + ag_ = other.ag_; + } + // + // new_dynamic + template + void new_dynamic(const BaseVector& dynamic); +}; + +} // END_CPPAD_NAMESPACE + +# include +# include +# include +# include +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_two/ctor.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_two/ctor.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_two/ctor.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_two/ctor.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,222 @@ +# ifndef CPPAD_CORE_CHKPOINT_TWO_CTOR_HPP +# define CPPAD_CORE_CHKPOINT_TWO_CTOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin chkpoint_two_ctor$$ +$spell + chkpoint + chk + bool + hes +$$ + +$section Checkpoint Function Constructor$$ + +$head Syntax$$ +$codei%chkpoint_two<%Base%> %chk_fun%( %fun%, %name%, + %internal_bool%, %use_hes_sparsity%, %use_base2ad%, %use_in_parallel% +)%$$ + +$head Prototype$$ +$srcfile%include/cppad/core/chkpoint_two/ctor.hpp% + 0%// BEGIN_PROTOTYPE%// END_PROTOTYPE%1 +%$$ + +$head Parallel$$ +This constructor, and its corresponding destructor, must not be called in +$cref/parallel/ta_in_parallel/$$ mode. +The object $icode chk_fun$$ should not be destructed for as long as there is +an $codei%ADFun<%Base%>%$$ object the has $icode chk_fun$$ in its recording. + +$head Base$$ +The type $icode Base$$ specifies the base type for AD operations. + +$head fun$$ +This specifies the function $latex g(x)$$. +Note that $icode fun$$ may or may not have been +$cref/optimized/optimize/$$ before calling the constructor. +This will determine if the internal representation for $icode g(x)$$ +is optimized. + +$head name$$ +is the name used for reporting errors using this checkpoint function. + +$head internal_bool$$ +If true, sparsity calculations are done with sets represented +by vectors of boolean values. +Otherwise, vectors of sets are used for sparsity patterns. + +$head use_hes_sparsity$$ +If true, Hessian sparsity patterns can be calculated for +$codei%ADFun<%Base%>%$$ objects that have uses of $icode chk_fun$$ +in their recording. +This requires some extra memory and extra computation during the constructor. + +$head use_base2ad$$ +If this is true, $icode chk_fun$$ can be used during the recording +of $codei%ADFun<%Base%>%$$ objects that get converted to +$codei%ADFun< AD<%Base%> >%$$ objects using $cref base2ad$$. +This requires some extra memory and extra computation during the constructor. + +$head use_in_parallel$$ +If this is true, $icode chk_fun$$ can be used +$cref/in_parallel/ta_parallel_setup/in_parallel/$$. +This requires some extra memory for a constant copy of the $icode fun$$ +information and a separate copy (that changes) for each thread. + +$head chk_fun$$ +This is a checkpoint function representation of $latex g(x)$$ +that can be used during the recording of $codei%AD<%Base%>%$$ operations. + +$end +*/ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file chkpoint_two/ctor.hpp +Constructor for chkpoint_two class. +*/ + +/*! +Constructor + +\tparam Base +base class for recording AD operations using this checkpoint object. + +\param fun +is the function g(x) corresponding to this checkpoint object. + +\param name +is the name used for error reporting. + +\param internal_bool +should sparisity calculations be done using bools (or sets). + +\param use_hes_sparsity +will this checkpoint function be used with Hessian sparsity calculations. + +\param use_base2ad +will this checkpoint function be used with base2ad. + +\param use_in_parallel +will this checkpoint function be used in parallel mode. +*/ + +// BEGIN_PROTOTYPE +template +chkpoint_two::chkpoint_two( + const ADFun& fun , + const std::string& name , + bool internal_bool , + bool use_hes_sparsity , + bool use_base2ad , + bool use_in_parallel ) +// END_PROTOTYPE +: +atomic_three(name) , +internal_bool_( internal_bool ) , +use_hes_sparsity_( use_hes_sparsity ) , +use_base2ad_ ( use_base2ad ) , +use_in_parallel_ ( use_in_parallel ) +{ CPPAD_ASSERT_KNOWN( + ! thread_alloc::in_parallel() , + "chkpoint_two: constructor cannot be called in parallel mode." + ); + // initialize member pointers as null; + for(size_t thread = 0; thread < CPPAD_MAX_NUM_THREADS; thread++) + member_[thread] = CPPAD_NULL; + // + // g_ + g_ = fun; + // + // suppress check for nan because chkpoint_two object can be used in a + // function that gets optimized and some checkpoint results may not matter. + g_.check_for_nan(false); + // + // ag_ + if( use_base2ad ) + ag_ = g_.base2ad(); + // + // jac_sparsity__ + size_t n = g_.Domain(); + size_t m = g_.Range(); + sparse_rc< vector > pattern_in; + bool transpose = false; + bool dependency = true; + if( n <= m || use_hes_sparsity ) + { // use forward mode + pattern_in.resize(n, n, n); + for(size_t k = 0; k < n; ++k) + pattern_in.set(k, k, k); + g_.for_jac_sparsity( + pattern_in, + transpose, + dependency, + internal_bool, + jac_sparsity_ + ); + } + else + { // use reverse mode + pattern_in.resize(m, m, m); + for(size_t k = 0; k < m; ++k) + pattern_in.set(k, k, k); + g_.rev_jac_sparsity( + pattern_in, + transpose, + dependency, + internal_bool, + jac_sparsity_ + ); + } + // + // hes_sparsity_ + if( use_hes_sparsity ) + { vector select_y(m), select_x(n); + for(size_t i = 0; i < m; ++i) + select_y[i] = true; + if( n <= m ) + { for(size_t j = 0; j < n; ++j) + select_x[j] = true; + g_.for_hes_sparsity( + select_x, select_y, internal_bool, hes_sparsity_ + ); + } + else + { // forward jacobian sparsity is stored in g_ + g_.rev_hes_sparsity( + select_y, transpose, internal_bool, hes_sparsity_ + ); + } + } + // free memory holding forward Jacobian sparsity + if( internal_bool ) + g_.size_forward_bool(0); + else + g_.size_forward_set(0); +} +/// destructor +template +chkpoint_two::~chkpoint_two(void) +{ +# ifndef NDEBUG + if( thread_alloc::in_parallel() ) + { std::string msg = atomic_three::afun_name(); + msg += ": chkpoint_two destructor called in parallel mode."; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# endif + for(size_t thread = 0; thread < CPPAD_MAX_NUM_THREADS; ++thread) + free_member(thread); + } +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_two/dynamic.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_two/dynamic.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_two/dynamic.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_two/dynamic.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,102 @@ +# ifndef CPPAD_CORE_CHKPOINT_TWO_DYNAMIC_HPP +# define CPPAD_CORE_CHKPOINT_TWO_DYNAMIC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin chkpoint_two_dynamic$$ +$spell + chk + chkpoint + dyn_ind +$$ + +$section Dynamic Parameters in Checkpoint Functions$$ + +$head Syntax$$ +$icode%chk_fun%.new_dynamic(%dynamic%)%$$ + +$head Prototype$$ +$srcfile%include/cppad/core/chkpoint_two/dynamic.hpp% + 0%// BEGIN_PROTOTYPE%// END_PROTOTYPE%1 +%$$ + +$head chk_fun$$ +This object must have been created using the +$cref/chkpoint_two/chkpoint_two_ctor/chk_fun/$$ constructor. + +$subhead Base$$ +This is the $cref/Base/chkpoint_two_ctor/Base/$$ type +in the $icode chk_fun$$ constructor. + +$subhead fun$$ +This is the function $cref/fun/chkpoint_two_ctor/fun/$$ +in the $icode chk_fun$$ constructor. + +$head BaseVector$$ +This must be a $cref SimpleVector$$ with elements of type $icode Base$$. + +$head dynamic$$ +This is a vector with new values for the dynamic parameters +in the function $icode fun$$. +Is size must be equal to +$cref/fun.size_dyn_ind()/seq_property/size_dyn_par/$$. +This only affects the copy of $icode fun$$ used by $icode chk_fun$$. + +$head Multi-Threading$$ +If one is using $cref/in_parallel/ta_in_parallel/$$, +there is a separate copy of $icode fun$$ for each thread. +In this case, only the dynamic parameters in the copy for the current +$cref/thread number/ta_thread_num/$$ are changed. + + +$end +*/ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file chkpoint_two/dynamic.hpp +Change the dynnamic parameter in a checkpoint function. +*/ + +/*! +Constructor + +\tparam Base +base class for recording AD operations using this checkpoint object. + +\param dynamic +is the new values for the dynamic parameters in the function +defining this checkpoint object. +*/ + +// BEGIN_PROTOTYPE +template +template +void chkpoint_two::new_dynamic(const BaseVector& dynamic) +// END_PROTOTYPE +{ ADFun* g_ptr = &g_; + if( use_in_parallel_ ) + { size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + g_ptr = &(member_[thread]->g_); + } +# ifndef NDEBUG + else if( thread_alloc::in_parallel() ) + { std::string msg = atomic_three::afun_name(); + msg += ": use_in_parallel is false and in_parallel() is true"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# endif + g_ptr->new_dynamic(dynamic); +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_two/for_type.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_two/for_type.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_two/for_type.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_two/for_type.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,63 @@ +# ifndef CPPAD_CORE_CHKPOINT_TWO_FOR_TYPE_HPP +# define CPPAD_CORE_CHKPOINT_TWO_FOR_TYPE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file chkpoint_two/for_type.hpp +Second generation checkpoint type computation. +*/ +/*! +Link from atomic_three to type calculation + +\param parameter_x [in] +is the value of the parameters in the corresponding function call +afun(ax, ay). + +\param type_x [in] +specifies which components of x are +constants, dynamics, and variables + +\param type_y [out] +specifies which components of y are +constants, dynamics, and variables +*/ +template +bool chkpoint_two::for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) +{ size_t nr = jac_sparsity_.nr(); + size_t nnz = jac_sparsity_.nnz(); + const vector& row( jac_sparsity_.row() ); + const vector& col( jac_sparsity_.col() ); + // + CPPAD_ASSERT_UNKNOWN( jac_sparsity_.nr() == type_y.size() ); + CPPAD_ASSERT_UNKNOWN( jac_sparsity_.nc() == type_x.size() ); + // + // initialize type_y as constant_enum + for(size_t i = 0; i < nr; ++i) + type_y[i] = constant_enum; + // + // loop over entries in Dependency pattern + for(size_t k = 0; k < nnz; ++k) + { size_t i = row[k]; + size_t j = col[k]; + type_y[i] = std::max(type_y[i], type_x[j]); + } + return true; +} + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_two/forward.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_two/forward.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_two/forward.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_two/forward.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,130 @@ +# ifndef CPPAD_CORE_CHKPOINT_TWO_FORWARD_HPP +# define CPPAD_CORE_CHKPOINT_TWO_FORWARD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file chkpoint_two/forward.hpp +Second generation checkpoint forward mode. +*/ +/*! +Link from chkpoint_two to forward mode + +\param parameter_x [in] +contains the values, in afun(ax, ay), for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param need_y [in] +specifies which components of taylor_y are needed, + +\param order_low [in] +lowerest order for this forward mode calculation. + +\param order_up [in] +highest order for this forward mode calculation. + +\param taylor_x [in] +Taylor coefficients corresponding to x for this calculation. + +\param taylor_y [out] +Taylor coefficient corresponding to y for this calculation + +See the forward mode in user's documentation for atomic_three +*/ +template +bool chkpoint_two::forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector& taylor_x , + vector& taylor_y ) +{ ADFun* g_ptr = &g_; + if( use_in_parallel_ ) + { size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + g_ptr = &(member_[thread]->g_); + } +# ifndef NDEBUG + else if( thread_alloc::in_parallel() ) + { std::string msg = atomic_three::afun_name(); + msg += ": use_in_parallel is false and in_parallel() is true"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# endif + // compute forward mode results for all values and orders + taylor_y = g_ptr->Forward(order_up, taylor_x); + // + return true; +} +/*! +Link from chkpoint_two to AD forward mode + +\param aparameter_x [in] +contains the values, in afun(ax, ay), for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param need_y [in] +specifies which components of taylor_y are needed, + +\param order_low [in] +lowerest order for this forward mode calculation. + +\param order_up [in] +highest order for this forward mode calculation. + +\param ataylor_x [in] +Taylor coefficients corresponding to x for this calculation. + +\param ataylor_y [out] +Taylor coefficient corresponding to y for this calculation + +See the forward mode in user's documentation for atomic_three +*/ +template +bool chkpoint_two::forward( + const vector< AD >& aparameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector< AD >& ataylor_x , + vector< AD >& ataylor_y ) +{ if( ! use_base2ad_ ) + return false; + // + ADFun< AD, Base >* ag_ptr = &ag_; + if( use_in_parallel_ ) + { size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + ag_ptr = &(member_[thread]->ag_); + } +# ifndef NDEBUG + else if( thread_alloc::in_parallel() ) + { std::string msg = atomic_three::afun_name(); + msg += ": use_in_parallel is false and in_parallel() is true"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# endif + // compute forward mode results for all values and orders + ataylor_y = ag_ptr->Forward(order_up, ataylor_x); + // + return true; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_two/hes_sparsity.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_two/hes_sparsity.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_two/hes_sparsity.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_two/hes_sparsity.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,82 @@ +# ifndef CPPAD_CORE_CHKPOINT_TWO_HES_SPARSITY_HPP +# define CPPAD_CORE_CHKPOINT_TWO_HES_SPARSITY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file chkpoint_two/hes_sparsity.hpp +Second generation checkpoint Jacobian sparsity patterns. +*/ +/*! +chkpoint_two to Jacobian sparsity calculations. + +\param parameter_x [in] +contains the values for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param select_x [in] +which domain components to include in the dependency or sparsity pattern. +The index zero is used for parameters. + +\param select_y [in] +which range components to include in the dependency or sparsity pattern. +The index zero is used for parameters. + +\param pattern_out [out] +is the dependency or sparsity pattern. +*/ +// BEGIN_PROTOTYPE +template +bool chkpoint_two::hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const vector& select_x , + const vector& select_y , + sparse_rc< vector >& pattern_out ) +// END_PROTOTYPE +{ CPPAD_ASSERT_UNKNOWN( hes_sparsity_.nr() == select_x.size() ); + CPPAD_ASSERT_UNKNOWN( hes_sparsity_.nc() == select_x.size() ); + if( ! use_hes_sparsity_ ) + return false; + + // count number of non-zeros + size_t nnz = hes_sparsity_.nnz(); + size_t nr = hes_sparsity_.nr(); + size_t nc = hes_sparsity_.nc(); + const vector& row = hes_sparsity_.row(); + const vector& col = hes_sparsity_.col(); + size_t nnz_out = 0; + for(size_t k = 0; k < nnz; ++k) + { size_t i = row[k]; + size_t j = col[k]; + if( select_x[j] & select_y[i] ) + ++nnz_out; + } + + // set the output sparsity pattern + pattern_out.resize(nr, nc, nnz_out); + size_t ell = 0; + for(size_t k = 0; k < nnz; ++k) + { size_t i = row[k]; + size_t j = col[k]; + if( select_x[j] & select_y[i] ) + pattern_out.set(ell++, i, j); + } + CPPAD_ASSERT_UNKNOWN( ell == nnz_out ); + // + return true; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_two/jac_sparsity.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_two/jac_sparsity.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_two/jac_sparsity.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_two/jac_sparsity.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,86 @@ +# ifndef CPPAD_CORE_CHKPOINT_TWO_JAC_SPARSITY_HPP +# define CPPAD_CORE_CHKPOINT_TWO_JAC_SPARSITY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file chkpoint_two/jac_sparsity.hpp +Second generation checkpoint Jacobian sparsity patterns. +*/ +/*! +chkpoint_two to Jacobian sparsity calculations. + +\param dependency [in] +This argument is ignored. +The return pattern is always a dependency pattern which is a correct, +but possibly not efficient, sparsity pattern. + +\param parameter_x [in] +contains the values for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param select_x [in] +which domain components to include in the dependency or sparsity pattern. +The index zero is used for parameters. + +\param select_y [in] +which range components to include in the dependency or sparsity pattern. +The index zero is used for parameters. + +\param pattern_out [out] +is the dependency or sparsity pattern. +*/ +// BEGIN_PROTOTYPE +template +bool chkpoint_two::jac_sparsity( + const vector& parameter_x , + const vector& type_x , + bool dependency , + const vector& select_x , + const vector& select_y , + sparse_rc< vector >& pattern_out ) +// END_PROTOTYPE +{ CPPAD_ASSERT_UNKNOWN( jac_sparsity_.nr() == select_y.size() ); + CPPAD_ASSERT_UNKNOWN( jac_sparsity_.nc() == select_x.size() ); + + // count number of non-zeros + size_t nnz = jac_sparsity_.nnz(); + size_t nr = jac_sparsity_.nr(); + size_t nc = jac_sparsity_.nc(); + const vector& row = jac_sparsity_.row(); + const vector& col = jac_sparsity_.col(); + size_t nnz_out = 0; + for(size_t k = 0; k < nnz; ++k) + { size_t i = row[k]; + size_t j = col[k]; + if( select_x[j] & select_y[i] ) + ++nnz_out; + } + + // set the output sparsity pattern + pattern_out.resize(nr, nc, nnz_out); + size_t ell = 0; + for(size_t k = 0; k < nnz; ++k) + { size_t i = row[k]; + size_t j = col[k]; + if( select_x[j] & select_y[i] ) + pattern_out.set(ell++, i, j); + } + CPPAD_ASSERT_UNKNOWN( ell == nnz_out ); + // + return true; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_two/rev_depend.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_two/rev_depend.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_two/rev_depend.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_two/rev_depend.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,66 @@ +# ifndef CPPAD_CORE_CHKPOINT_TWO_REV_DEPEND_HPP +# define CPPAD_CORE_CHKPOINT_TWO_REV_DEPEND_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file chkpoint_two/rev_depend.hpp +Second generation checkpoint type computation. +*/ +/*! +Link from atomic_three to dependency calculation + +\param parameter_x [in] +is the value of the parameters in the corresponding function call +afun(ax, ay). + +\param type_x [in] +is the AD type for ax in the corresponding afun(ax, ay) call. + +\param depend_x [out] +specifies which components of x affect the values of interest + +\param depend_y [in] +specifies which components of y affect the vlaues of interest +*/ +template +bool chkpoint_two::rev_depend( + const vector& parameter_x , + const vector& type_x , + vector& depend_x , + const vector& depend_y ) +{ size_t nc = jac_sparsity_.nc(); + size_t nnz = jac_sparsity_.nnz(); + const vector& row( jac_sparsity_.row() ); + const vector& col( jac_sparsity_.col() ); + // + CPPAD_ASSERT_UNKNOWN( jac_sparsity_.nr() == depend_y.size() ); + CPPAD_ASSERT_UNKNOWN( jac_sparsity_.nc() == depend_x.size() ); + // + // initialize depend_x as false + for(size_t j = 0; j < nc; ++j) + depend_x[j] = false; + // + // loop over entries in Dependency pattern + for(size_t k = 0; k < nnz; ++k) + { size_t i = row[k]; + size_t j = col[k]; + if( depend_y[i] ) + depend_x[j] = true; + } + return true; +} + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/chkpoint_two/reverse.hpp cppad-2019.02.00.0/include/cppad/core/chkpoint_two/reverse.hpp --- cppad-2018.00.00.0/include/cppad/core/chkpoint_two/reverse.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/chkpoint_two/reverse.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,139 @@ +# ifndef CPPAD_CORE_CHKPOINT_TWO_REVERSE_HPP +# define CPPAD_CORE_CHKPOINT_TWO_REVERSE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file chkpoint_two/reverse.hpp +Second generation checkpoint reverse mode. +*/ +/*! +Link from chkpoint_two to reverse mode + +\param parameter_x [in] +contains the values, in afun(ax, ay), for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param order_up [in] +highest order Taylor coefficient aht we are computing derivative of + +\param taylor_x [in] +Taylor coefficients corresponding to x for this calculation. + +\param taylor_y [in] +Taylor coefficient corresponding to y for this calculation + +\param partial_x [out] +Partials w.r.t. the x Taylor coefficients. + +\param partial_y [in] +Partials w.r.t. the y Taylor coefficients. + +See the reverse mode in user's documentation for atomic_three +*/ +template +bool chkpoint_two::reverse( + const vector& parameter_x , + const vector& type_x , + size_t order_up , + const vector& taylor_x , + const vector& taylor_y , + vector& partial_x , + const vector& partial_y ) + +{ ADFun* g_ptr = &g_; + if( use_in_parallel_ ) + { size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + g_ptr = &(member_[thread]->g_); + } +# ifndef NDEBUG + else if( thread_alloc::in_parallel() ) + { std::string msg = atomic_three::afun_name(); + msg += ": use_in_parallel is false and in_parallel() is true"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# endif + // compute forward mode Taylor coefficient orders 0 through order_up +# ifdef NDEBUG + g_ptr->Forward(order_up, taylor_x); +# else + vector check = g_ptr->Forward(order_up, taylor_x); + CPPAD_ASSERT_UNKNOWN( taylor_y.size() == check.size() ) + for(size_t i = 0; i < taylor_y.size(); ++i) + CPPAD_ASSERT_UNKNOWN( taylor_y[i] == check[i] ); +# endif + // now can run reverse mode + partial_x = g_ptr->Reverse(order_up+1, partial_y); + // + return true; +} +/*! +Link from chkpoint_two to AD reverse mode + +\param aparameter_x [in] +contains the values, in afun(ax, ay), for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param order_up [in] +highest order Taylor coefficient aht we are computing derivative of + +\param ataylor_x [in] +Taylor coefficients corresponding to x for this calculation. + +\param ataylor_y [in] +Taylor coefficient corresponding to y for this calculation + +\param apartial_x [out] +Partials w.r.t. the x Taylor coefficients. + +\param apartial_y [in] +Partials w.r.t. the y Taylor coefficients. + +See the reverse mode in user's documentation for atomic_three +*/ +template +bool chkpoint_two::reverse( + const vector< AD >& aparameter_x , + const vector& type_x , + size_t order_up , + const vector< AD >& ataylor_x , + const vector< AD >& ataylor_y , + vector< AD >& apartial_x , + const vector< AD >& apartial_y ) +{ ADFun< AD, Base >* ag_ptr = &ag_; + if( use_in_parallel_ ) + { size_t thread = thread_alloc::thread_num(); + allocate_member(thread); + ag_ptr = &(member_[thread]->ag_); + } + // compute forward mode Taylor coefficient orders 0 through order_up +# ifdef NDEBUG + ag_ptr->Forward(order_up, ataylor_x); +# else + vector< AD > acheck = ag_ptr->Forward(order_up, ataylor_x); + CPPAD_ASSERT_UNKNOWN( ataylor_y.size() == acheck.size() ) + for(size_t i = 0; i < ataylor_y.size(); ++i) + CPPAD_ASSERT_UNKNOWN( ataylor_y[i] == acheck[i] ); +# endif + // now can run reverse mode + apartial_x = ag_ptr->Reverse(order_up+1, apartial_y); + // + return true; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/compare.hpp cppad-2019.02.00.0/include/cppad/core/compare.hpp --- cppad-2018.00.00.0/include/cppad/core/compare.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/compare.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,677 @@ +# ifndef CPPAD_CORE_COMPARE_HPP +# define CPPAD_CORE_COMPARE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin Compare$$ +$spell + cos + Op + bool + const +$$ + + + +$section AD Binary Comparison Operators$$ + + +$head Syntax$$ + +$icode%b% = %x% %Op% %y%$$ + + +$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 $icode Base$$ type. + + +$head Op$$ +The operator $icode Op$$ is one of the following: +$table +$bold Op$$ $pre $$ $cnext $bold Meaning$$ $rnext +$code <$$ $cnext is $icode x$$ less than $icode y$$ $rnext +$code <=$$ $cnext is $icode x$$ less than or equal $icode y$$ $rnext +$code >$$ $cnext is $icode x$$ greater than $icode y$$ $rnext +$code >=$$ $cnext is $icode x$$ greater than or equal $icode y$$ $rnext +$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% + const %Type% &%x% +%$$ +where $icode Type$$ is $codei%AD<%Base%>%$$, $icode Base$$, or $code int$$. + +$head y$$ +The operand $icode y$$ has prototype +$codei% + const %Type% &%y% +%$$ +where $icode Type$$ is $codei%AD<%Base%>%$$, $icode Base$$, or $code int$$. + +$head b$$ +The result $icode b$$ has type +$codei% + bool %b% +%$$ + +$head Operation Sequence$$ +The result of this operation is a $code bool$$ value +(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/$$. +$pre + +$$ +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, +and the subsequent code is +$codei% + if( %b% ) + %y% = cos(%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/$$, +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/$$ +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 +$icode Base$$. + +$head Example$$ +$children% + example/general/compare.cpp +%$$ +The file +$cref compare.cpp$$ +contains an example and test of these operations. + +$end +------------------------------------------------------------------------------- +*/ +// BEGIN CppAD namespace +namespace CppAD { +// -------------------------------- < -------------------------- +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool operator < (const AD &left , const AD &right) +{ bool result = (left.value_ < right.value_); + // + // check if we are recording compare operators + local::ADTape *tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return result; + if( ! tape->Rec_.get_record_compare() ) + 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 ); + + // check if left and right tapes match + bool match_left = left.tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (left.ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (left.ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + left.tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "< : AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // variable < variable + if( result ) + { tape->Rec_.PutOp(local::LtvvOp); + tape->Rec_.PutArg(left.taddr_, right.taddr_); + } + else + { tape->Rec_.PutOp(local::LevvOp); + tape->Rec_.PutArg(right.taddr_, left.taddr_); + } + } + else + { // variable < parameter + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + if( result ) + { tape->Rec_.PutOp(local::LtvpOp); + tape->Rec_.PutArg(left.taddr_, p); + } + else + { tape->Rec_.PutOp(local::LepvOp); + tape->Rec_.PutArg(p, left.taddr_); + } + } + } + else if ( var_right ) + { // parameter < variable + addr_t p = left.taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left.value_); + if( result ) + { tape->Rec_.PutOp(local::LtpvOp); + tape->Rec_.PutArg(p, right.taddr_); + } + else + { tape->Rec_.PutOp(local::LevpOp); + tape->Rec_.PutArg(right.taddr_, p); + } + } + else if( dyn_left | dyn_right ) + { // parameter < parameter + addr_t arg0 = left.taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left.value_); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + if( result ) + { tape->Rec_.PutOp(local::LtppOp); + tape->Rec_.PutArg(arg0, arg1); + } + else + { tape->Rec_.PutOp(local::LeppOp); + tape->Rec_.PutArg(arg1, arg0); + } + } + return result; +} +// convert other cases into the case above +CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(<) + +// -------------------------------- <= -------------------------- +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool operator <= (const AD &left , const AD &right) +{ bool result = (left.value_ <= right.value_); + // + // check if we are recording compare operators + local::ADTape *tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return result; + if( ! tape->Rec_.get_record_compare() ) + 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 ); + + // check if left and right tapes match + bool match_left = left.tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (left.ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (left.ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + left.tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "<= : AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // variable <= variable + if( result ) + { tape->Rec_.PutOp(local::LevvOp); + tape->Rec_.PutArg(left.taddr_, right.taddr_); + } + else + { tape->Rec_.PutOp(local::LtvvOp); + tape->Rec_.PutArg(right.taddr_, left.taddr_); + } + } + else + { // variable <= parameter + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + if( result ) + { tape->Rec_.PutOp(local::LevpOp); + tape->Rec_.PutArg(left.taddr_, p); + } + else + { tape->Rec_.PutOp(local::LtpvOp); + tape->Rec_.PutArg(p, left.taddr_); + } + } + } + else if ( var_right ) + { // parameter <= variable + addr_t p = left.taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left.value_); + if( result ) + { tape->Rec_.PutOp(local::LepvOp); + tape->Rec_.PutArg(p, right.taddr_); + } + else + { tape->Rec_.PutOp(local::LtvpOp); + tape->Rec_.PutArg(right.taddr_, p); + } + } + else if( dyn_left | dyn_right ) + { // parameter <= parameter + addr_t arg0 = left.taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left.value_); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + if( result ) + { tape->Rec_.PutOp(local::LeppOp); + tape->Rec_.PutArg(arg0, arg1); + } + else + { tape->Rec_.PutOp(local::LtppOp); + tape->Rec_.PutArg(arg1, arg0); + } + } + return result; +} +// convert other cases into the case above +CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(<=) + +// -------------------------------- > -------------------------- +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool operator > (const AD &left , const AD &right) +{ bool result = (left.value_ > right.value_); + // + // check if we are recording compare operators + local::ADTape *tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return result; + if( ! tape->Rec_.get_record_compare() ) + 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 ); + + // check if left and right tapes match + bool match_left = left.tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (left.ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (left.ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + left.tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "> : AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // variable > variable + if( result ) + { tape->Rec_.PutOp(local::LtvvOp); + tape->Rec_.PutArg(right.taddr_, left.taddr_); + } + else + { tape->Rec_.PutOp(local::LevvOp); + tape->Rec_.PutArg(left.taddr_, right.taddr_); + } + } + else + { // variable > parameter + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + if( result ) + { tape->Rec_.PutOp(local::LtpvOp); + tape->Rec_.PutArg(p, left.taddr_); + } + else + { tape->Rec_.PutOp(local::LevpOp); + tape->Rec_.PutArg(left.taddr_, p); + } + } + } + else if ( var_right ) + { // parameter > variable + addr_t p = left.taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left.value_); + if( result ) + { tape->Rec_.PutOp(local::LtvpOp); + tape->Rec_.PutArg(right.taddr_, p); + } + else + { tape->Rec_.PutOp(local::LepvOp); + tape->Rec_.PutArg(p, right.taddr_); + } + } + else if( dyn_left | dyn_right ) + { // parameter > parameter + addr_t arg0 = left.taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left.value_); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + if( result ) + { tape->Rec_.PutOp(local::LtppOp); + tape->Rec_.PutArg(arg1, arg0); + } + else + { tape->Rec_.PutOp(local::LeppOp); + tape->Rec_.PutArg(arg0, arg1); + } + } + return result; +} +// convert other cases into the case above +CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(>) + +// -------------------------------- >= -------------------------- +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool operator >= (const AD &left , const AD &right) +{ bool result = (left.value_ >= right.value_); + // + // check if we are recording compare operators + local::ADTape *tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return result; + if( ! tape->Rec_.get_record_compare() ) + 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 ); + + // check if left and right tapes match + bool match_left = left.tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (left.ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (left.ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + left.tape_id_ == right.tape_id_ || ! match_left || ! match_right , + ">= : AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // variable >= variable + if( result ) + { tape->Rec_.PutOp(local::LevvOp); + tape->Rec_.PutArg(right.taddr_, left.taddr_); + } + else + { tape->Rec_.PutOp(local::LtvvOp); + tape->Rec_.PutArg(left.taddr_, right.taddr_); + } + } + else + { // variable >= parameter + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + if( result ) + { tape->Rec_.PutOp(local::LepvOp); + tape->Rec_.PutArg(p, left.taddr_); + } + else + { tape->Rec_.PutOp(local::LtvpOp); + tape->Rec_.PutArg(left.taddr_, p); + } + } + } + else if ( var_right ) + { // parameter >= variable + addr_t p = left.taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left.value_); + if( result ) + { tape->Rec_.PutOp(local::LevpOp); + tape->Rec_.PutArg(right.taddr_, p); + } + else + { tape->Rec_.PutOp(local::LtpvOp); + tape->Rec_.PutArg(p, right.taddr_); + } + } + else if( dyn_left | dyn_right ) + { // parameter >= parameter + addr_t arg0 = left.taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left.value_); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + if( result ) + { tape->Rec_.PutOp(local::LeppOp); + tape->Rec_.PutArg(arg1, arg0); + } + else + { tape->Rec_.PutOp(local::LtppOp); + tape->Rec_.PutArg(arg0, arg1); + } + } + return result; +} +// convert other cases into the case above +CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(>=) + +// -------------------------------- == ------------------------- +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool operator == (const AD &left , const AD &right) +{ bool result = (left.value_ == right.value_); + // + // check if we are recording compare operators + local::ADTape *tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return result; + if( ! tape->Rec_.get_record_compare() ) + 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 ); + + // check if left and right tapes match + bool match_left = left.tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (left.ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (left.ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + left.tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "==: AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // variable == variable + tape->Rec_.PutArg(left.taddr_, right.taddr_); + if( result ) + tape->Rec_.PutOp(local::EqvvOp); + else + tape->Rec_.PutOp(local::NevvOp); + } + else + { // variable == parameter + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + tape->Rec_.PutArg(p, left.taddr_); + if( result ) + tape->Rec_.PutOp(local::EqpvOp); + else + tape->Rec_.PutOp(local::NepvOp); + } + } + else if ( var_right ) + { // parameter == variable + addr_t p = left.taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left.value_); + tape->Rec_.PutArg(p, right.taddr_); + if( result ) + tape->Rec_.PutOp(local::EqpvOp); + else + tape->Rec_.PutOp(local::NepvOp); + } + else if( dyn_left | dyn_right ) + { // parameter == parameter + addr_t arg0 = left.taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left.value_); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + tape->Rec_.PutArg(arg0, arg1); + if( result ) + tape->Rec_.PutOp(local::EqppOp); + else + tape->Rec_.PutOp(local::NeppOp); + } + return result; +} +// convert other cases into the case above +CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(==) + +// -------------------------------- != ------------------------- +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool operator != (const AD &left , const AD &right) +{ bool result = (left.value_ != right.value_); + // + // check if we are recording compare operators + local::ADTape *tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return result; + if( ! tape->Rec_.get_record_compare() ) + 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 ); + + // check if left and right tapes match + bool match_left = left.tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (left.ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (left.ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + left.tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "!=: AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // variable == variable + tape->Rec_.PutArg(left.taddr_, right.taddr_); + if( result ) + tape->Rec_.PutOp(local::NevvOp); + else + tape->Rec_.PutOp(local::EqvvOp); + } + else + { // variable == parameter + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + tape->Rec_.PutArg(p, left.taddr_); + if( result ) + tape->Rec_.PutOp(local::NepvOp); + else + tape->Rec_.PutOp(local::EqpvOp); + } + } + else if ( var_right ) + { // parameter == variable + addr_t p = left.taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left.value_); + tape->Rec_.PutArg(p, right.taddr_); + if( result ) + tape->Rec_.PutOp(local::NepvOp); + else + tape->Rec_.PutOp(local::EqpvOp); + } + else if( dyn_left | dyn_right ) + { // parameter == parameter + addr_t arg0 = left.taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left.value_); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + tape->Rec_.PutArg(arg0, arg1); + if( result ) + tape->Rec_.PutOp(local::NeppOp); + else + tape->Rec_.PutOp(local::EqppOp); + } + return result; +} +// convert other cases into the case above +CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(!=) + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/compound_assign.hpp cppad-2019.02.00.0/include/cppad/core/compound_assign.hpp --- cppad-2018.00.00.0/include/cppad/core/compound_assign.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/compound_assign.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,141 @@ +# ifndef CPPAD_CORE_COMPOUND_ASSIGN_HPP +# define CPPAD_CORE_COMPOUND_ASSIGN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin compound_assign$$ +$spell + Op + VecAD + const +$$ + +$section AD Compound Assignment Operators$$ + + + + + + +$head Syntax$$ +$icode%x% %Op% %y%$$ + +$head Purpose$$ +Performs compound assignment operations +where either $icode x$$ has type +$codei%AD<%Base%>%$$. + +$head Op$$ +The operator $icode Op$$ is one of the following +$table +$bold Op$$ $cnext $bold Meaning$$ $rnext +$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$$ +$tend + +$head Base$$ +The type $icode Base$$ is determined by the operand $icode x$$. + +$head x$$ +The operand $icode x$$ has the following prototype +$codei% + AD<%Base%> &%x% +%$$ + +$head y$$ +The operand $icode y$$ has the following prototype +$codei% + const %Type% &%y% +%$$ +where $icode Type$$ is +$codei%VecAD<%Base%>::reference%$$, +$codei%AD<%Base%>%$$, +$icode Base$$, or +$code double$$. + +$head Result$$ +The result of this assignment +can be used as a reference to $icode x$$. +For example, if $icode z$$ has the following type +$codei% + AD<%Base%> %z% +%$$ +then the syntax +$codei% + %z% = %x% += %y% +%$$ +will compute $icode x$$ plus $icode y$$ +and then assign this value to both $icode x$$ and $icode z$$. + + +$head Operation Sequence$$ +This is an $cref/atomic_base/glossary/Operation/Atomic/$$ +$cref/AD of Base/glossary/AD of Base/$$ operation +and hence it is part of the current +AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$. + +$children% + example/general/add_eq.cpp% + example/general/sub_eq.cpp% + example/general/mul_eq.cpp% + example/general/div_eq.cpp +%$$ + +$head Example$$ +The following files contain examples and tests of these functions. +Each test returns true if it succeeds and false otherwise. +$table +$rref AddEq.cpp$$ +$rref sub_eq.cpp$$ +$rref mul_eq.cpp$$ +$rref div_eq.cpp$$ +$tend + +$head Derivative$$ +If $latex f$$ and $latex g$$ are +$cref/Base functions/glossary/Base Function/$$ + +$subhead Addition$$ +$latex \[ + \D{[ f(x) + g(x) ]}{x} = \D{f(x)}{x} + \D{g(x)}{x} +\] $$ + +$subhead Subtraction$$ +$latex \[ + \D{[ f(x) - g(x) ]}{x} = \D{f(x)}{x} - \D{g(x)}{x} +\] $$ + +$subhead Multiplication$$ +$latex \[ + \D{[ f(x) * g(x) ]}{x} = g(x) * \D{f(x)}{x} + f(x) * \D{g(x)}{x} +\] $$ + +$subhead Division$$ +$latex \[ + \D{[ f(x) / g(x) ]}{x} = + [1/g(x)] * \D{f(x)}{x} - [f(x)/g(x)^2] * \D{g(x)}{x} +\] $$ + +$end +----------------------------------------------------------------------------- +*/ +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/cond_exp.hpp cppad-2019.02.00.0/include/cppad/core/cond_exp.hpp --- cppad-2018.00.00.0/include/cppad/core/cond_exp.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/cond_exp.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,276 @@ +# ifndef CPPAD_CORE_COND_EXP_HPP +# define CPPAD_CORE_COND_EXP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin CondExp$$ +$spell + Atan2 + CondExp + Taylor + std + Cpp + namespace + inline + const + abs + Rel + bool + Lt + Le + Eq + Ge + Gt +$$ + + +$section AD Conditional Expressions$$ + +$head Syntax$$ +$icode%result% = CondExp%Rel%(%left%, %right%, %if_true%, %if_false%)%$$ + + +$head Purpose$$ +Record, +as part of an AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$, +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: +$codei% + %Rel% Lt Le Eq Ge Gt + %Cop% < <= == >= > +%$$ +If $icode f$$ is the $cref ADFun$$ object corresponding to the +AD operation sequence, +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 +$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. + +$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$$. +As in the table above, +$icode Rel$$ determines which comparison operator $icode Cop$$ is used +when comparing $icode left$$ and $icode right$$. + +$head Type$$ +These functions are defined in the CppAD namespace for arguments of +$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% + const %Type%& %right% +%$$ +It specifies the value for the right side of the comparison operator. + +$head if_true$$ +The argument $icode if_true$$ has prototype +$codei% + const %Type%& %if_true% +%$$ +It specifies the return value if the result of the comparison is true. + +$head if_false$$ +The argument $icode if_false$$ has prototype +$codei% + const %Type%& %if_false% +%$$ +It specifies the return value if the result of the comparison is false. + +$head result$$ +The $icode result$$ has prototype +$codei% + %Type%& %if_false% +%$$ + +$head Optimize$$ +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, +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. +This optimization is done for the rest of zero order forward mode +as well as forward and reverse derivatives calculations. + +$head Deprecate 2005-08-07$$ +Previous versions of CppAD used +$codei% + CondExp(%flag%, %if_true%, %if_false%) +%$$ +for the same meaning as +$codei% + CondExpGt(%flag%, %Type%(0), %if_true%, %if_false%) +%$$ +Use of $code CondExp$$ is deprecated, but continues to be supported. + +$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 Example$$ + +$head Test$$ +$children% + example/general/cond_exp.cpp +%$$ +The file +$cref cond_exp.cpp$$ +contains an example and test of this function. + +$head Atan2$$ +The following implementation of the +AD $cref atan2$$ function is a more complex +example of using conditional expressions: +$srcfile%include/cppad/core/atan2.hpp%0%BEGIN CondExp%// END CondExp%$$ + + +$end +------------------------------------------------------------------------------- +*/ +// BEGIN CppAD namespace +namespace CppAD { + +template +AD CondExpOp( + enum CompareOp cop , + const AD &left , + const AD &right , + const AD &if_true , + const AD &if_false ) +{ + AD result; + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); + + // check first case where do not need to tape + if( IdenticalCon(left) & IdenticalCon(right) ) + { switch( cop ) + { + case CompareLt: + if( left.value_ < right.value_ ) + result = if_true; + else + result = if_false; + break; + + case CompareLe: + if( left.value_ <= right.value_ ) + result = if_true; + else + result = if_false; + break; + + case CompareEq: + if( left.value_ == right.value_ ) + result = if_true; + else + result = if_false; + break; + + case CompareGe: + if( left.value_ >= right.value_ ) + result = if_true; + else + result = if_false; + break; + + case CompareGt: + if( left.value_ > right.value_ ) + result = if_true; + else + result = if_false; + break; + + default: + CPPAD_ASSERT_UNKNOWN(0); + result = if_true; + } + return result; + } + + // must use CondExp incase Base is an AD type and recording + result.value_ = CondExpOp(cop, + left.value_, right.value_, if_true.value_, if_false.value_); + + local::ADTape *tape = AD::tape_ptr(); + + // add this operation to the tape + if( tape != CPPAD_NULL ) tape->Rec_.cond_exp( + tape->id_, cop, result, left, right, if_true, if_false + ); + + return result; +} + +// ------------ CondExpOp(left, right, if_true, if_false) ---------------- + +# define CPPAD_COND_EXP(Name) \ + template \ + CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION \ + AD CondExp##Name( \ + const AD &left , \ + const AD &right , \ + const AD &if_true , \ + const AD &if_false ) \ + { \ + return CondExpOp(Compare##Name, \ + left, right, if_true, if_false); \ + } + +// AD +CPPAD_COND_EXP(Lt) +CPPAD_COND_EXP(Le) +CPPAD_COND_EXP(Eq) +CPPAD_COND_EXP(Ge) +CPPAD_COND_EXP(Gt) +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +AD CondExp( + 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 diff -Nru cppad-2018.00.00.0/include/cppad/core/con_dyn_var.hpp cppad-2019.02.00.0/include/cppad/core/con_dyn_var.hpp --- cppad-2018.00.00.0/include/cppad/core/con_dyn_var.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/con_dyn_var.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,171 @@ +# ifndef CPPAD_CORE_CON_DYN_VAR_HPP +# define CPPAD_CORE_CON_DYN_VAR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +--------------------------------------------------------------------------- + +$begin con_dyn_var$$ +$spell + VecAD + const + bool +$$ + +$section Constant, Dynamic, Parameter, and Variable$$ + +$head Syntax$$ +$icode%b% = Constant(%x%) +%$$ +$icode%b% = Dynamic(%x%) +%$$ +$icode%b% = Parameter(%x%) +%$$ +$icode%b% = Variable(%x%) +%$$ + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const AD<%Base%> &%x% + const VecAD<%Base%> &%x% +%$$ + +$head b$$ +The return value $icode b$$ has prototype +$codei% + bool %b% +%$$ + +$head Constant$$ +The return value for $code Constant$$ is true +is true if and only if $icode x$$ is +a $cref/constant/glossary/Parameter/Constant/$$ parameter. +A $cref/VecAD/VecAD/$$ object is a constant parameter +if no element of the vector depends on the independent variables. + +$head Dynamic$$ +The return value for $code Dynamic$$ is true +is true if and only if $icode x$$ is +a $cref/dynamic/glossary/Parameter/Dynamic/$$ parameter. +No element of a $cref/VecAD/VecAD/$$ object +can depend on the dynamic parameters and this function returns false +for these objects. + +$head Parameter$$ +The return value for $code Parameter$$ is true +is true if and only if $icode x$$ is +a $cref/parameter/glossary/Parameter/$$. +A $cref/VecAD/VecAD/$$ object is a parameter +if no element of the vector depends on the independent variables. + +$head Variable$$ +The return value for $code Variable$$ is true +is true if and only if $icode x$$ is +a $cref/variable/glossary/Variable/$$. +A $cref/VecAD/VecAD/$$ object is a variable +if any element of the vector depends on the independent variables. + +$head Operation Sequence$$ +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 Example$$ +$children% + example/general/con_dyn_var.cpp +%$$ +The file +$cref con_dyn_var.cpp$$ +contains an example and test of these functions. + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { + // ----------------------------------------------------------------------- + // Constant + template + bool Constant(const AD &x) + { CPPAD_ASSERT_UNKNOWN( x.tape_id_==0 || x.ad_type_!=constant_enum ); + 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); + } + template + bool Constant(const VecAD &x) + { return Parameter(x); } + + // ----------------------------------------------------------------------- + // Dynamic + template + bool Dynamic(const AD &x) + { CPPAD_ASSERT_UNKNOWN( x.tape_id_==0 || x.ad_type_!=constant_enum ); + if( (x.tape_id_ == 0) | (x.ad_type_ != dynamic_enum) ) + return false; + // + size_t thread = size_t(x.tape_id_ % CPPAD_MAX_NUM_THREADS); + return x.tape_id_ == *AD::tape_id_ptr(thread); + } + template + bool Dynamic(const VecAD &x) + { return false; } + + // ----------------------------------------------------------------------- + // Parameter + template + bool Parameter(const AD &x) + { CPPAD_ASSERT_UNKNOWN( x.tape_id_==0 || x.ad_type_!=constant_enum ); + if( (x.tape_id_ == 0) | (x.ad_type_ == dynamic_enum) ) + return true; + // + size_t thread = size_t(x.tape_id_ % CPPAD_MAX_NUM_THREADS); + return x.tape_id_ != *AD::tape_id_ptr(thread); + } + template + bool Parameter(const VecAD &x) + { 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); + } + + // ----------------------------------------------------------------------- + // Variable + template + bool Variable(const AD &x) + { CPPAD_ASSERT_UNKNOWN( x.tape_id_==0 || x.ad_type_!=constant_enum ); + if( (x.tape_id_ == 0) | (x.ad_type_ != variable_enum) ) + return false; + // + size_t thread = size_t(x.tape_id_ % CPPAD_MAX_NUM_THREADS); + return x.tape_id_ == *AD::tape_id_ptr(thread); + } + template + bool Variable(const VecAD &x) + { 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); + } +} +// END CppAD namespace + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/convert.hpp cppad-2019.02.00.0/include/cppad/core/convert.hpp --- cppad-2018.00.00.0/include/cppad/core/convert.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/convert.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,50 @@ +# ifndef CPPAD_CORE_CONVERT_HPP +# define CPPAD_CORE_CONVERT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin Convert$$ +$spell +$$ + + +$section Conversion and I/O of AD Objects$$ + +$children% + include/cppad/core/value.hpp% + include/cppad/core/integer.hpp% + include/cppad/core/ad_to_string.hpp% + include/cppad/core/ad_io.hpp% + include/cppad/core/print_for.hpp% + include/cppad/core/var2par.hpp +%$$ +$table +$rref Value$$ +$rref Integer$$ +$rref ad_output$$ +$rref PrintFor$$ +$rref Var2Par$$ +$tend + + +$end +*/ + +# include +# include +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/cppad_assert.hpp cppad-2019.02.00.0/include/cppad/core/cppad_assert.hpp --- cppad-2018.00.00.0/include/cppad/core/cppad_assert.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/cppad_assert.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,188 @@ +# ifndef CPPAD_CORE_CPPAD_ASSERT_HPP +# define CPPAD_CORE_CPPAD_ASSERT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/*! +\file cppad_assert.hpp +Define the CppAD error checking macros (all of which begin with CPPAD_ASSERT_) +*/ + +/* +------------------------------------------------------------------------------- +$begin cppad_assert$$ +$spell + CppAD + exp + const + bool +$$ + + +$section CppAD Assertions During Execution$$ + +$head Syntax$$ +$codei%CPPAD_ASSERT_KNOWN(%exp%, %msg%) +%$$ +$codei%CPPAD_ASSERT_UNKNOWN(%exp%)%$$ + + +$head Purpose$$ +These CppAD macros are used to detect and report errors. +They are documented here because they correspond to the C++ +source code that the error is reported at. + +$head NDEBUG$$ +If the preprocessor symbol +$cref/NDEBUG/Faq/Speed/NDEBUG/$$ is defined, +these macros do nothing; i.e., they are optimized out. + +$head Restriction$$ +The CppAD user should not uses these macros. +You can however write your own macros that do not begin with $code CPPAD$$ +and that call the $cref/CppAD error handler/ErrorHandler/$$. + +$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. + +$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 +occurred; for example, the user may have written past the end +of an allocated array. + +$head Exp$$ +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 +(including zero times) so it must have not side effects. + +$head Msg$$ +The argument $icode msg$$ has prototype +$codei% + const char *%msg% +%$$ +and contains a $code '\0'$$ terminated character string. +This string is a description of the error +corresponding to $icode exp$$ being false. + +$head Error Handler$$ +These macros use the +$cref/CppAD error handler/ErrorHandler/$$ to report errors. +This error handler can be replaced by the user. + +$end +------------------------------------------------------------------------------ +*/ + +# include +# include +# include + +/*! +\def CPPAD_ASSERT_KNOWN(exp, msg) +Check that exp is true, if not print msg and terminate execution. + +The C++ expression exp is expected to be true. +If it is false, +the CppAD use has made an error that is described by msg. +If the preprocessor symbol NDEBUG is not defined, +and exp is false, +this macro will report the source code line number at +which this expected result occurred. +In addition, it will print the specified error message msg. +*/ +# ifdef NDEBUG +# define CPPAD_ASSERT_KNOWN(exp, msg) // do nothing +# else +# define CPPAD_ASSERT_KNOWN(exp, msg) \ +{ if( ! ( exp ) ) \ + CppAD::ErrorHandler::Call( \ + true , \ + __LINE__ , \ + __FILE__ , \ + #exp , \ + msg ); \ +} +# endif + +/*! +\def CPPAD_ASSERT_UNKNOWN(exp) +Check that exp is true, if not terminate execution. + +The C++ expression exp is expected to be true. +If it is false, +CppAD has detected an error but does not know the cause of the error. +If the preprocessor symbol NDEBUG is not defined, +and exp is false, +this macro will report the source code line number at +which this expected result occurred. +*/ +# ifdef NDEBUG +# define CPPAD_ASSERT_UNKNOWN(exp) // do nothing +# else +# define CPPAD_ASSERT_UNKNOWN(exp) \ +{ if( ! ( exp ) ) \ + CppAD::ErrorHandler::Call( \ + false , \ + __LINE__ , \ + __FILE__ , \ + #exp , \ + "" ); \ +} +# endif + +/*! +\def CPPAD_ASSERT_NARG_NRES(op, n_arg, n_res) +Check that operator op has the specified number of of arguments and results. + +If 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 ) + +/*! +\def CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL +Check that the first call to a routine is not during parallel execution mode. + +If NDEBUG is defined, this macro has no effect +(not even the definition of (assert_first_call). +Otherwise, the variable +\code + static bool assert_first_call +\endcode +is defined and if the first call is executed in parallel mode, +execution is terminated and the source code line number is reported. +*/ +# ifdef NDEBUG +# define CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL +# else +# define CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL \ + static bool assert_first_call = true; \ + if( assert_first_call ) \ + { CPPAD_ASSERT_KNOWN( \ + ! (CppAD::thread_alloc::in_parallel() ), \ + "In parallel mode and parallel_setup has not been called." \ + ); \ + assert_first_call = false; \ + } +# endif + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/dependent.hpp cppad-2019.02.00.0/include/cppad/core/dependent.hpp --- cppad-2018.00.00.0/include/cppad/core/dependent.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/dependent.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,338 @@ +# ifndef CPPAD_CORE_DEPENDENT_HPP +# define CPPAD_CORE_DEPENDENT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin Dependent$$ +$spell + alloc + num + taylor_ + ADvector + const +$$ + +$spell +$$ + +$section Stop Recording and Store Operation Sequence$$ + + +$head Syntax$$ +$icode%f%.Dependent(%x%, %y%)%$$ + +$head Purpose$$ +Stop recording and the AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$ +that started with the call +$codei% + Independent(%x%) +%$$ +and store the operation sequence in $icode f$$. +The operation sequence defines an +$cref/AD function/glossary/AD Function/$$ +$latex \[ + F : \B{R}^n \rightarrow \B{R}^m +\] $$ +where $latex B$$ is the space corresponding to objects of type $icode Base$$. +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 +$cref/range/seq_property/Range/$$ space for the operation sequence +(which is determined by the size of $icode y$$). + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +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. + +$head 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 +between calling +$codei% + Independent(%x%) +%$$ +and +$codei% + %f%.Dependent(%x%, %y%) +%$$. + +$head y$$ +The vector $icode y$$ has prototype +$codei% + const %ADvector% &%y% +%$$ +(see $cref/ADvector/FunConstruct/$$ below). +The length of $icode y$$ must be greater than zero +and is the dimension of the range space for $icode f$$. + +$head ADvector$$ +The type $icode ADvector$$ must be a $cref SimpleVector$$ class with +$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 Taping$$ +The tape, +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. + +$head Forward$$ +No $cref Forward$$ calculation is preformed during this operation. +Thus, directly after this operation, +$codei% + %f%.size_order() +%$$ +is zero (see $cref size_order$$). + +$head Parallel Mode$$ +The call to $code Independent$$, +and the corresponding call to +$codei% + ADFun<%Base%> %f%( %x%, %y%) +%$$ +or +$codei% + %f%.Dependent( %x%, %y%) +%$$ +or $cref abort_recording$$, +must be preformed by the same thread; i.e., +$cref/thread_alloc::thread_num/ta_thread_num/$$ must be the same. + +$head Example$$ +The file +$cref fun_check.cpp$$ +contains an example and test of this operation. + +$end +---------------------------------------------------------------------------- +*/ + + +// BEGIN CppAD namespace +namespace CppAD { + +/*! +\file dependent.hpp +Different versions of Dependent function. +*/ + +/*! +Determine the tape corresponding to this exeuction thread and then use +Dependent(tape, y) to store this tapes recording in a function. + +\param y [in] +The dependent variable vector for the corresponding function. +*/ +template +template +void ADFun::Dependent(const ADvector &y) +{ local::ADTape* tape = AD::tape_ptr(); + CPPAD_ASSERT_KNOWN( + tape != CPPAD_NULL, + "Can't store current operation sequence in this ADFun object" + "\nbecause there is no active tape (for this thread)." + ); + + // code above just determines the tape and checks for errors + Dependent(tape, y); +} + + +/*! +Determine the tape corresponding to this exeuction thread and then use +Dependent(tape, y) to store this tapes recording in a function. + +\param x [in] +The independent variable vector for this tape. This informaiton is +also stored in the tape so a check is done to make sure it is correct +(if NDEBUG is not defined). + +\param y [in] +The dependent variable vector for the corresponding function. +*/ +template +template +void ADFun::Dependent(const ADvector &x, const ADvector &y) +{ + CPPAD_ASSERT_KNOWN( + x.size() > 0, + "Dependent: independent variable vector has size zero." + ); + CPPAD_ASSERT_KNOWN( + Variable(x[0]), + "Dependent: independent variable vector has been changed." + ); + local::ADTape *tape = AD::tape_ptr(x[0].tape_id_); + CPPAD_ASSERT_KNOWN( + tape->size_independent_ == size_t( x.size() ), + "Dependent: independent variable vector has been changed." + ); +# ifndef NDEBUG + size_t i, j; + for(j = 0; j < size_t(x.size()); j++) + { CPPAD_ASSERT_KNOWN( + size_t(x[j].taddr_) == (j+1), + "ADFun: independent variable vector has been changed." + ); + CPPAD_ASSERT_KNOWN( + x[j].tape_id_ == x[0].tape_id_, + "ADFun: independent variable vector has been changed." + ); + } + for(i = 0; i < size_t(y.size()); i++) + { CPPAD_ASSERT_KNOWN( + CppAD::Parameter( y[i] ) | (y[i].tape_id_ == x[0].tape_id_) , + "ADFun: dependent vector contains a variable for" + "\na different tape (thread) than the independent variables." + ); + } +# endif + + // code above just determines the tape and checks for errors + Dependent(tape, y); +} + +/*! +Replace the floationg point operations sequence for this function object. + +\param tape +is a tape that contains the new floating point operation sequence +for this function. +After this operation, all memory allocated for this tape is deleted. + +\param y +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 +new tape except for check_for_nan_. +*/ + +template +template +void ADFun::Dependent(local::ADTape *tape, const ADvector &y) +{ + size_t m = y.size(); + size_t n = tape->size_independent_; + + // check ADvector is Simple Vector class with AD elements + CheckSimpleVector< AD, ADvector>(); + + CPPAD_ASSERT_KNOWN( + y.size() > 0, + "ADFun operation sequence dependent variable size is zero size" + ); + // --------------------------------------------------------------------- + // Begin setting ad_fun.hpp private member data + // --------------------------------------------------------------------- + // dep_parameter_, dep_taddr_ + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::ParOp) == 1 ); + dep_parameter_.resize(m); + dep_taddr_.resize(m); + for(size_t i = 0; i < m; i++) + { dep_parameter_[i] = CppAD::Parameter(y[i]); + addr_t y_taddr; + if( dep_parameter_[i] ) + { // make a tape copy of dependent variables that are parameters, + y_taddr = tape->RecordParOp( y[i] ); + } + else + y_taddr = y[i].taddr_; + + CPPAD_ASSERT_UNKNOWN( y_taddr > 0 ); + dep_taddr_[i] = size_t( y_taddr ); + } + + // put an EndOp at the end of the tape + tape->Rec_.PutOp(local::EndOp); + + // bool values in this object except check_for_nan_ + base2ad_return_value_ = false; + has_been_optimized_ = false; + // + // size_t values in this object except for num_var_tape_ + compare_change_count_ = 1; + compare_change_number_ = 0; + compare_change_op_index_ = 0; + num_order_taylor_ = 0; + cap_order_taylor_ = 0; + num_direction_taylor_ = 0; + + // num_var_tape_ + // Now that all the variables are in the tape, we can set this value. + num_var_tape_ = tape->Rec_.num_var_rec(); + + // taylor_ + taylor_.resize(0); + + // cskip_op_ + cskip_op_.resize( tape->Rec_.num_op_rec() ); + + // load_op_ + load_op_.resize( tape->Rec_.num_load_op_rec() ); + + // 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 + // recording to the player and and erase the recording; i.e. ERASE Rec_. + play_.get_recording(tape->Rec_, n); + + // ind_taddr_ + // Note that play_ has been set, we can use it to check operators + ind_taddr_.resize(n); + CPPAD_ASSERT_UNKNOWN( n < num_var_tape_); + for(size_t j = 0; j < n; j++) + { CPPAD_ASSERT_UNKNOWN( play_.GetOp(j+1) == local::InvOp ); + ind_taddr_[j] = j+1; + } + + // for_jac_sparse_pack_, for_jac_sparse_set_ + for_jac_sparse_pack_.resize(0, 0); + for_jac_sparse_set_.resize(0,0); + + // resize subgraph_info_ + subgraph_info_.resize( + ind_taddr_.size(), // n_dep + dep_taddr_.size(), // n_ind + play_.num_op_rec(), // n_op + play_.num_var_rec() // n_var + ); + // --------------------------------------------------------------------- + // End set ad_fun.hpp private member data + // --------------------------------------------------------------------- + + // now we can delete the tape + AD::tape_manage(delete_tape_manage); + + // 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 + CPPAD_ASSERT_UNKNOWN( num_var_tape_ > 0 ); + +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/discrete.hpp cppad-2019.02.00.0/include/cppad/core/discrete.hpp --- cppad-2018.00.00.0/include/cppad/core/discrete.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/discrete.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,340 @@ +# ifndef CPPAD_CORE_DISCRETE_HPP +# define CPPAD_CORE_DISCRETE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin Discrete$$ +$spell + retaping + namespace + std + Eq + Cpp + const + inline + Geq +$$ + +$section Discrete AD Functions$$ + + +$head Syntax$$ +$codei%CPPAD_DISCRETE_FUNCTION(%Base%, %name%) +%$$ +$icode%y% = %name%(%x%) +%$$ +$icode%ay% = %name%(%ax%) +%$$ + + +$head Purpose$$ +Record the evaluation of a discrete function as part +of an $codei%AD<%Base%>%$$ +$cref/operation sequence/glossary/Operation/Sequence/$$. +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. + +$head Base$$ +This is the +$cref/base type/base_require/$$ +corresponding to the operations sequence; +i.e., use of the $icode name$$ with arguments of type +$codei%AD<%Base%>%$$ can be recorded in an operation sequence. + +$head name$$ +This is the name of the function (as it is used in the source code). +The user must provide a version of $icode name$$ +where the argument has type $icode Base$$. +CppAD uses this to create a version of $icode name$$ +where the argument has type $codei%AD<%Base%>%$$. + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %Base%& %x% +%$$ +It is the value at which the user provided version of $icode name$$ +is to be evaluated. + +$head y$$ +The result $icode y$$ has prototype +$codei% + %Base% %y% +%$$ +It is the return value for the user provided version of $icode name$$. + +$head ax$$ +The argument $icode ax$$ has prototype +$codei% + const AD<%Base%>& %ax% +%$$ +It is the value at which the CppAD provided version of $icode name$$ +is to be evaluated. + +$head ay$$ +The result $icode ay$$ has prototype +$codei% + AD<%Base%> %ay% +%$$ +It is the return value for the CppAD provided version of $icode name$$. + + +$head Create AD Version$$ +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) +but must be outside of any routine. + +$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 Derivatives$$ +During a zero order $cref Forward$$ operation, +an $cref ADFun$$ object will compute the value of $icode name$$ +using the user provided $icode Base$$ version of this routine. +All the derivatives of $icode name$$ will be evaluated as zero. + +$head Parallel Mode$$ +The first call to +$codei% + %ay% = %name%(%ax%) +%$$ +must not be in $cref/parallel/ta_in_parallel/$$ execution mode. + + +$head Example$$ +$children% + example/general/tape_index.cpp% + example/general/interp_onetape.cpp% + example/general/interp_retape.cpp +%$$ +The file +$cref tape_index.cpp$$ +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$$ +contains an example and test that uses discrete +functions to avoid retaping a calculation that requires interpolation. +(The file +$cref interp_retape.cpp$$ +shows how interpolation can be done with retaping.) + +$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. + +$end +------------------------------------------------------------------------------ +*/ +# include +# include + +// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file discrete.hpp +user define discrete functions +*/ + +/*! +\def CPPAD_DISCRETE_FUNCTION(Base, name) +Defines the function name(ax, ay) +where ax and ay are vectors with AD elements. + +\par Base +is the base type for the discrete function. + +\par name +is the name of the user defined function that corresponding to this operation. +*/ + +# define CPPAD_DISCRETE_FUNCTION(Base, name) \ +inline CppAD::AD name (const CppAD::AD& ax) \ +{ \ + static CppAD::discrete fun(#name, name); \ + \ + return fun.ad(ax); \ +} +# define CppADCreateDiscrete CPPAD_DISCRETE_FUNCTION + + +/* +Class that acutally implemnets the ay = name(ax) call. + +A new discrete function is generated for ech time the user invokes +the CPPAD_DISCRETE_FUNCTION macro; see static object in that macro. +*/ +template +class discrete { + /// parallel_ad needs to call List to initialize static + template + friend void parallel_ad(void); + + /// type for the user routine that computes function values + typedef Base (*F) (const Base& x); +private: + /// name of this user defined function + const std::string name_; + /// user's implementation of the function for Base operations + const F f_; + /// index of this objec in the vector of all objects for this class + const size_t index_; + + /*! + List of all objects in this class. + + 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. + */ + static std::vector& List(void) + { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + static std::vector list; + return list; + } +public: + /*! + Constructor called for each invocation of CPPAD_DISCRETE_FUNCTION. + + Put this object in the list of all objects for this class and set + the constant private data name_, f_, and index_. + + \param Name + is the user's name for this discrete function. + + \param f + user routine that implements this function for Base class. + + \par + This constructor can ont be used in parallel mode because it changes + the static object List. + */ + discrete(const char* Name, F f) : + name_(Name) + , f_(f) + , index_( List().size() ) + { + CPPAD_ASSERT_KNOWN( + ! thread_alloc::in_parallel() , + "discrete: First call the function *Name is in parallel mode." + ); + List().push_back(this); + } + + /*! + Implement the user call to ay = name(ax). + + \param ax + is the argument for this call. + + \return + the return value is called ay above. + */ + AD ad(const AD &ax) const + { + CPPAD_ASSERT_KNOWN( + size_t( std::numeric_limits::max() ) >= index_, + "discrete: cppad_tape_addr_type maximum not large enough" + ); + // + AD ay; + ay.value_ = f_(ax.value_); + // + // check if there is a recording in progress + local::ADTape* tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return ay; + // + // check if argument is a constant parameter + if( ax.tape_id_ != tape->id_ ) + return ay; + // + if( ax.ad_type_ == dynamic_enum ) + { + // tape dynamic paramter operation + ay.taddr_ = tape->Rec_.put_dyn_par( + ay.value_, local::dis_dyn, addr_t(index_), ax.taddr_ + ); + ay.tape_id_ = ax.tape_id_; + ay.ad_type_ = dynamic_enum; + + // make result a dynamic parameter + ay.tape_id_ = tape->id_; + ay.ad_type_ = dynamic_enum; + + CPPAD_ASSERT_UNKNOWN( Dynamic(ay) ); + } + else if( ax.ad_type_ == variable_enum ) + { + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::DisOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::DisOp) == 2 ); + + // put operand addresses in the tape + CPPAD_ASSERT_KNOWN( + size_t( std::numeric_limits::max() ) >= index_, + "discrete: cppad_tape_addr_type maximum not large enough" + ); + tape->Rec_.PutArg(addr_t(index_), ax.taddr_); + // put operator in the tape + ay.taddr_ = tape->Rec_.PutOp(local::DisOp); + // make result a variable + ay.tape_id_ = tape->id_; + ay.ad_type_ = variable_enum; + + CPPAD_ASSERT_UNKNOWN( Variable(ay) ); + } + else + { // other types not yet being used and should have this tape id + CPPAD_ASSERT_UNKNOWN(false); + } + return ay; + } + + /// Name corresponding to a discrete object + static const char* name(size_t index) + { return List()[index]->name_.c_str(); } + + /*! + Link from forward mode sweep to users routine + + \param index + index for this function in the list of all discrete object + + \param x + argument value at which to evaluate this function + */ + static Base eval(size_t index, const Base& x) + { + CPPAD_ASSERT_UNKNOWN(index < List().size() ); + + return List()[index]->f_(x); + } +}; + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/div_eq.hpp cppad-2019.02.00.0/include/cppad/core/div_eq.hpp --- cppad-2018.00.00.0/include/cppad/core/div_eq.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/div_eq.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,129 @@ +# ifndef CPPAD_CORE_DIV_EQ_HPP +# define CPPAD_CORE_DIV_EQ_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN CppAD namespace +namespace CppAD { + +template +AD& AD::operator /= (const AD &right) +{ + // compute the Base part + Base left; + left = value_; + value_ /= right.value_; + + // check if there is a recording in progress + local::ADTape* tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return *this; + 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 ); + + // check if left and right tapes match + bool match_left = tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "/= : AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // this = variable / variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::DivvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::DivvvOp) == 2 ); + + // put operand addresses in tape + tape->Rec_.PutArg(taddr_, right.taddr_); + // put operator in the tape + taddr_ = tape->Rec_.PutOp(local::DivvvOp); + // check that this is a variable + CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); + CPPAD_ASSERT_UNKNOWN( ad_type_ == variable_enum); + } + else if( (! dyn_right) & IdenticalOne(right.value_) ) + { // this = variable * 1 + } + else + { // this = variable / parameter + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::DivvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::DivvpOp) == 2 ); + + // put operand addresses in tape + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + tape->Rec_.PutArg(taddr_, p); + // put operator in the tape + taddr_ = tape->Rec_.PutOp(local::DivvpOp); + // check that this is a variable + CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); + CPPAD_ASSERT_UNKNOWN( ad_type_ == variable_enum); + } + } + else if( var_right ) + { if( (! dyn_left) & IdenticalZero(left) ) + { // this = 0 / variable + } + else + { // this = parameter / variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::DivpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::DivpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left); + tape->Rec_.PutArg(p, right.taddr_); + + // put operator in the tape + taddr_ = tape->Rec_.PutOp(local::DivpvOp); + + // make this a variable + tape_id_ = tape_id; + ad_type_ = variable_enum; + } + } + else if( dyn_left | dyn_right ) + { addr_t arg0 = taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + // parameters with a dynamic parameter results + taddr_ = tape->Rec_.put_dyn_par( + value_, local::div_dyn, arg0, arg1 + ); + tape_id_ = tape_id; + ad_type_ = dynamic_enum; + } + return *this; +} + +CPPAD_FOLD_ASSIGNMENT_OPERATOR(/=) + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/div.hpp cppad-2019.02.00.0/include/cppad/core/div.hpp --- cppad-2018.00.00.0/include/cppad/core/div.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/div.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,130 @@ +# ifndef CPPAD_CORE_DIV_HPP +# define CPPAD_CORE_DIV_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN CppAD namespace +namespace CppAD { + +template +AD operator / (const AD &left , const AD &right) +{ + // compute the Base part + AD result; + result.value_ = left.value_ / right.value_; + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); + + // check if there is a recording in progress + local::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 ); + + // check if left and right tapes match + bool match_left = left.tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (left.ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (left.ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + left.tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "Divide: AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // result = variable / variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::DivvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::DivvvOp) == 2 ); + + // put operand addresses in tape + tape->Rec_.PutArg(left.taddr_, right.taddr_); + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::DivvvOp); + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + else if( (! dyn_right) & IdenticalOne(right.value_) ) + { // result = variable / 1 + result.make_variable(left.tape_id_, left.taddr_); + } + else + { // result = variable / parameter + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::DivvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::DivvpOp) == 2 ); + + // put operand addresses in tape + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + tape->Rec_.PutArg(left.taddr_, p); + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::DivvpOp); + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + } + else if( var_right ) + { if( (! dyn_left) & IdenticalZero(left.value_) ) + { // result = 0 / variable + } + else + { // result = parameter / variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::DivpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::DivpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = left.taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left.value_); + tape->Rec_.PutArg(p, right.taddr_); + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::DivpvOp); + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + } + else if( dyn_left | dyn_right ) + { addr_t arg0 = left.taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left.value_); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + // parameters with a dynamic parameter result + result.taddr_ = tape->Rec_.put_dyn_par( + result.value_, local::div_dyn, arg0, arg1 + ); + result.tape_id_ = tape_id; + result.ad_type_ = dynamic_enum; + } + return result; +} + +// convert other cases into the case above +CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(/) + + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/drivers.hpp cppad-2019.02.00.0/include/cppad/core/drivers.hpp --- cppad-2018.00.00.0/include/cppad/core/drivers.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/drivers.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,22 @@ +# ifndef CPPAD_CORE_DRIVERS_HPP +# define CPPAD_CORE_DRIVERS_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/epsilon.hpp cppad-2019.02.00.0/include/cppad/core/epsilon.hpp --- cppad-2018.00.00.0/include/cppad/core/epsilon.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/epsilon.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,60 @@ +# ifndef CPPAD_CORE_EPSILON_HPP +# define CPPAD_CORE_EPSILON_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------ +$begin epsilon$$ +$spell + std + eps + CppAD + namespace + const +$$ + +$section Machine Epsilon For AD Types$$ + +$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%>()%$$ + +$head Purpose$$ +Obtain the value of machine epsilon corresponding +to the type $icode%Float%$$. + +$head Float$$ +this type can either be $codei%AD<%Base%>%$$, +or it can be $icode Base$$ for any $codei%AD<%Base%>%$$ type. + +$head eps$$ +The result $icode eps$$ has prototype +$codei% + %Float% eps +%$$ + +$end +------------------------------------------------------------------------------ +*/ + +namespace CppAD { + + template + inline Type epsilon(void) + { return Type ( numeric_limits::epsilon() ); } + +} +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/equal_op_seq.hpp cppad-2019.02.00.0/include/cppad/core/equal_op_seq.hpp --- cppad-2018.00.00.0/include/cppad/core/equal_op_seq.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/equal_op_seq.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,118 @@ +# ifndef CPPAD_CORE_EQUAL_OP_SEQ_HPP +# define CPPAD_CORE_EQUAL_OP_SEQ_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------ +$begin EqualOpSeq$$ +$spell + Op + const + bool +$$ + + +$section Check if Two Value are Identically Equal$$ + +$head Syntax$$ +$icode%b% = EqualOpSeq(%x%, %y%)%$$ + +$head Purpose$$ +Determine if two $icode x$$ and $icode y$$ are identically equal; i.e., +not only is $icode%x% == %y%$$ true, but +if they are $cref/variables/glossary/Variable/$$, +they correspond have the same +$cref/operation sequence/glossary/Operation/Sequence/$$. + +$head Motivation$$ +Sometimes it is useful to cache information +and only recalculate when a function's arguments change. +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/$$ +by the same operation sequence. +After the assignment +$codei% + %y% = %x% +%$$ +these two AD objects would not only have equal values, +but would also correspond to the same operation sequence. + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const AD<%Base%> &%x% +%$$ + +$head y$$ +The argument $icode y$$ has prototype +$codei% + const AD<%Base%> &%y% +%$$ + +$head b$$ +The result $icode b$$ has prototype +$codei% + bool %b% +%$$ +The result is true if and only if one of the following cases holds: + +$list number$$ +Both $icode x$$ and $icode y$$ are variables +and correspond to the same operation sequence. +$lnext +Both $icode x$$ and $icode y$$ are parameters, +$icode Base$$ is an AD type, +and $codei%EqualOpSeq( Value(%x%) , Value(%y%) )%$$ is true. +$lnext +Both $icode x$$ and $icode y$$ are parameters, +$icode Base$$ is not an AD type, +and $icode%x% == %y%%$$ is true. +$lend + + +$head Example$$ +$children% + example/general/equal_op_seq.cpp +%$$ +The file +$cref equal_op_seq.cpp$$ +contains an example and test of $code EqualOpSeq$$. + + +$end +------------------------------------------------------------------------------ +*/ + + +namespace CppAD { + 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_); + else + return false; + } + else if( Parameter(y) ) + return false; + + return (x.taddr_ == y.taddr_); + } + +} + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/erf.hpp cppad-2019.02.00.0/include/cppad/core/erf.hpp --- cppad-2018.00.00.0/include/cppad/core/erf.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/erf.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,105 @@ +# ifndef CPPAD_CORE_ERF_HPP +# define CPPAD_CORE_ERF_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin erf$$ +$spell + erf + const + Vec + std + cmath + CppAD + Vedder +$$ +$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, 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, +p 762-3. + +$head Example$$ +$children% + example/general/erf.cpp +%$$ +The file +$cref erf.cpp$$ +contains an example and test of this function. + +$end +------------------------------------------------------------------------------- +*/ +# include +# if ! CPPAD_USE_CPLUSPLUS_2011 + +// BEGIN CppAD namespace +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.); + + return tanh( (a + b * x * x) * x ); +} + +inline float erf(const float &x) +{ return erf_template(x); } + +inline double erf(const double &x) +{ return erf_template(x); } + +template +AD erf(const AD &x) +{ return erf_template(x); } + +template +AD erf(const VecAD_reference &x) +{ return erf_template( x.ADBase() ); } + + +} // END CppAD namespace + +# endif // CPPAD_USE_CPLUSPLUS_2011 +# endif // CPPAD_ERF_INCLUDED diff -Nru cppad-2018.00.00.0/include/cppad/core/expm1.hpp cppad-2019.02.00.0/include/cppad/core/expm1.hpp --- cppad-2018.00.00.0/include/cppad/core/expm1.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/expm1.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,95 @@ +# ifndef CPPAD_CORE_EXPM1_HPP +# define CPPAD_CORE_EXPM1_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$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/general/expm1.cpp +%$$ +The file +$cref expm1.cpp$$ +contains an example and test of this function. + +$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 +AD expm1(const AD &x) +{ return expm1_template(x); } + +template +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-2018.00.00.0/include/cppad/core/for_hes_sparsity.hpp cppad-2019.02.00.0/include/cppad/core/for_hes_sparsity.hpp --- cppad-2018.00.00.0/include/cppad/core/for_hes_sparsity.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/for_hes_sparsity.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,320 @@ +# ifndef CPPAD_CORE_FOR_HES_SPARSITY_HPP +# define CPPAD_CORE_FOR_HES_SPARSITY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin for_hes_sparsity$$ +$spell + Andrea Walther + Jacobian + Hessian + jac + hes + bool + const + rc + cpp +$$ + +$section Forward Mode Hessian Sparsity Patterns$$ + +$head Syntax$$ +$icode%f%.for_hes_sparsity( + %select_domain%, %select_range%, %internal_bool%, %pattern_out% +)%$$ + +$head Purpose$$ +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the +$cref/AD function/glossary/AD Function/$$ corresponding to +the operation sequence stored in $icode f$$. +Fix a diagonal matrix $latex D \in \B{R}^{n \times n}$$, +a vector $latex s \in \B{R}^m$$ and define the function +$latex \[ + H(x) = D ( s^\R{T} F )^{(2)} ( x ) D +\] $$ +Given the sparsity for $latex D$$ and $latex s$$, +$code for_hes_sparsity$$ computes a sparsity pattern for $latex H(x)$$. + +$head x$$ +Note that the sparsity pattern $latex H(x)$$ corresponds to the +operation sequence stored in $icode f$$ and does not depend on +the argument $icode x$$. + +$head BoolVector$$ +The type $icode BoolVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code bool$$. + +$head SizeVector$$ +The type $icode SizeVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ + +$head select_domain$$ +The argument $icode select_domain$$ has prototype +$codei% + const %BoolVector%& %select_domain% +%$$ +It has size $latex n$$ and specifies which components of the diagonal of +$latex D$$ are non-zero; i.e., $icode%select_domain%[%j%]%$$ is true +if and only if $latex D_{j,j}$$ is possibly non-zero. + + +$head select_range$$ +The argument $icode select_range$$ has prototype +$codei% + const %BoolVector%& %select_range% +%$$ +It has size $latex m$$ and specifies which components of the vector +$latex s$$ are non-zero; i.e., $icode%select_range%[%i%]%$$ is true +if and only if $latex s_i$$ is possibly non-zero. + +$head internal_bool$$ +If this is true, calculations are done with sets represented by a vector +of boolean values. Otherwise, a vector of sets of integers is used. + +$head pattern_out$$ +This argument has prototype +$codei% + sparse_rc<%SizeVector%>& %pattern_out% +%$$ +This input value of $icode pattern_out$$ does not matter. +Upon return $icode pattern_out$$ is a sparsity pattern for $latex H(x)$$. + +$head Sparsity for Entire Hessian$$ +Suppose that $latex R$$ is the $latex n \times n$$ identity matrix. +In this case, $icode pattern_out$$ is a sparsity pattern for +$latex (s^\R{T} F) F^{(2)} ( x )$$. + +$head Algorithm$$ +See Algorithm II in +$italic Computing sparse Hessians with automatic differentiation$$ +by Andrea Walther. +Note that $icode s$$ provides the information so that +'dead ends' are not included in the sparsity pattern. + +$head Example$$ +$children% + example/sparse/for_hes_sparsity.cpp +%$$ +The file $cref for_hes_sparsity.cpp$$ +contains an example and test of this operation. + +$end +----------------------------------------------------------------------------- +*/ +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +Forward Hessian sparsity patterns. + +\tparam Base +is the base type for this recording. + +\tparam BoolVector +is the simple vector with elements of type bool that is used for +sparsity for the vector s. + +\tparam SizeVector +is the simple vector with elements of type size_t that is used for +row, column index sparsity patterns. + +\param select_domain +is a sparsity pattern for for the diagonal of D. + +\param select_range +is a sparsity pattern for for s. + +\param internal_bool +If this is true, calculations are done with sets represented by a vector +of boolean values. Otherwise, a vector of standard sets is used. + +\param pattern_out +The return value is a sparsity pattern for H(x) where +\f[ + H(x) = D * F^{(1)} (x) * D +\f] +Here F is the function corresponding to the operation sequence +and x is any argument value. +*/ +template +template +void ADFun::for_hes_sparsity( + const BoolVector& select_domain , + const BoolVector& select_range , + bool internal_bool , + sparse_rc& pattern_out ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + size_t n = Domain(); + size_t m = Range(); + // + CPPAD_ASSERT_KNOWN( + size_t( select_domain.size() ) == n, + "for_hes_sparsity: size of select_domain is not equal to " + "number of independent variables" + ); + CPPAD_ASSERT_KNOWN( + size_t( select_range.size() ) == m, + "for_hes_sparsity: size of select_range is not equal to " + "number of dependent variables" + ); + // do not need transpose or depenency + bool transpose = false; + bool dependency = false; + // + sparse_rc pattern_tmp; + if( internal_bool ) + { // forward Jacobian sparsity pattern for independent variables + local::sparse_pack internal_for_jac; + internal_for_jac.resize(num_var_tape_, n + 1 ); + for(size_t j = 0; j < n; j++) if( select_domain[j] ) + { CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] < n + 1 ); + // use add_element when only adding one element per set + internal_for_jac.add_element( ind_taddr_[j] , ind_taddr_[j] ); + } + // forward Jacobian sparsity for all variables on tape + local::sweep::for_jac( + &play_, + dependency, + n, + num_var_tape_, + internal_for_jac, + not_used_rec_base + + ); + // reverse Jacobian sparsity pattern for select_range + local::sparse_pack internal_rev_jac; + internal_rev_jac.resize(num_var_tape_, 1); + for(size_t i = 0; i < m; i++) if( select_range[i] ) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + // use add_element when only adding one element per set + internal_rev_jac.add_element( dep_taddr_[i] , 0 ); + } + // reverse Jacobian sparsity for all variables on tape + local::sweep::rev_jac( + &play_, + dependency, + n, + num_var_tape_, + internal_rev_jac, + not_used_rec_base + ); + // internal vector of sets that will hold Hessian + local::sparse_pack internal_for_hes; + internal_for_hes.resize(n + 1, n + 1); + // + // compute forward Hessian sparsity pattern + local::sweep::for_hes( + &play_, + n, + num_var_tape_, + internal_for_jac, + internal_rev_jac, + internal_for_hes, + not_used_rec_base + + ); + // + // put the result in pattern_tmp + get_internal_sparsity( + transpose, ind_taddr_, internal_for_hes, pattern_tmp + ); + } + else + { // forward Jacobian sparsity pattern for independent variables + // (corresponds to D) + local::sparse_list internal_for_jac; + internal_for_jac.resize(num_var_tape_, n + 1 ); + for(size_t j = 0; j < n; j++) if( select_domain[j] ) + { CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] < n + 1 ); + // use add_element when only adding one element per set + internal_for_jac.add_element( ind_taddr_[j] , ind_taddr_[j] ); + } + // forward Jacobian sparsity for all variables on tape + local::sweep::for_jac( + &play_, + dependency, + n, + num_var_tape_, + internal_for_jac, + not_used_rec_base + + ); + // reverse Jacobian sparsity pattern for select_range + // (corresponds to s) + local::sparse_list internal_rev_jac; + internal_rev_jac.resize(num_var_tape_, 1); + for(size_t i = 0; i < m; i++) if( select_range[i] ) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + // use add_element when only adding one element per set + internal_rev_jac.add_element( dep_taddr_[i] , 0 ); + } + // reverse Jacobian sparsity for all variables on tape + local::sweep::rev_jac( + &play_, + dependency, + n, + num_var_tape_, + internal_rev_jac, + not_used_rec_base + + ); + // internal vector of sets that will hold Hessian + local::sparse_list internal_for_hes; + internal_for_hes.resize(n + 1, n + 1); + // + // compute forward Hessian sparsity pattern + local::sweep::for_hes( + &play_, + n, + num_var_tape_, + internal_for_jac, + internal_rev_jac, + internal_for_hes, + not_used_rec_base + + ); + // + // put the result in pattern_tmp + get_internal_sparsity( + transpose, ind_taddr_, internal_for_hes, pattern_tmp + ); + } + // subtract 1 from all column values + CPPAD_ASSERT_UNKNOWN( pattern_tmp.nr() == n ); + CPPAD_ASSERT_UNKNOWN( pattern_tmp.nc() == n + 1 ); + const SizeVector& row( pattern_tmp.row() ); + const SizeVector& col( pattern_tmp.col() ); + size_t nr = n; + size_t nc = n; + size_t nnz = pattern_tmp.nnz(); + pattern_out.resize(nr, nc, nnz); + for(size_t k = 0; k < nnz; k++) + { CPPAD_ASSERT_UNKNOWN( 0 < col[k] ); + pattern_out.set(k, row[k], col[k] - 1); + } + return; +} +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/for_jac_sparsity.hpp cppad-2019.02.00.0/include/cppad/core/for_jac_sparsity.hpp --- cppad-2018.00.00.0/include/cppad/core/for_jac_sparsity.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/for_jac_sparsity.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,305 @@ +# ifndef CPPAD_CORE_FOR_JAC_SPARSITY_HPP +# define CPPAD_CORE_FOR_JAC_SPARSITY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin for_jac_sparsity$$ +$spell + Jacobian + jac + bool + const + rc + cpp +$$ + +$section Forward Mode Jacobian Sparsity Patterns$$ + +$head Syntax$$ +$icode%f%.for_jac_sparsity( + %pattern_in%, %transpose%, %dependency%, %internal_bool%, %pattern_out% +)%$$ + +$head Purpose$$ +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the +$cref/AD function/glossary/AD Function/$$ corresponding to +the operation sequence stored in $icode f$$. +Fix $latex R \in \B{R}^{n \times \ell}$$ and define the function +$latex \[ + J(x) = F^{(1)} ( x ) * R +\] $$ +Given the $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for $latex R$$, +$code for_jac_sparsity$$ computes a sparsity pattern for $latex J(x)$$. + +$head x$$ +Note that the sparsity pattern $latex J(x)$$ corresponds to the +operation sequence stored in $icode f$$ and does not depend on +the argument $icode x$$. +(The operation sequence may contain +$cref CondExp$$ and $cref VecAD$$ operations.) + +$head SizeVector$$ +The type $icode SizeVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +The $cref ADFun$$ object $icode f$$ is not $code const$$. +After a call to $code for_jac_sparsity$$, a sparsity pattern +for each of the variables in the operation sequence +is held in $icode f$$ for possible later use during +reverse Hessian sparsity calculations. + +$subhead size_forward_bool$$ +After $code for_jac_sparsity$$, if $icode k$$ is a $code size_t$$ object, +$codei% + %k% = %f%.size_forward_bool() +%$$ +sets $icode k$$ to the amount of memory (in unsigned character units) +used to store the +$cref/boolean vector/glossary/Sparsity Pattern/Boolean Vector/$$ +sparsity patterns. +If $icode internal_bool$$ if false, $icode k$$ will be zero. +Otherwise it will be non-zero. +If you do not need this information for $cref RevSparseHes$$ +calculations, it can be deleted +(and the corresponding memory freed) using +$codei% + %f%.size_forward_bool(0) +%$$ +after which $icode%f%.size_forward_bool()%$$ will return zero. + +$subhead size_forward_set$$ +After $code for_jac_sparsity$$, if $icode k$$ is a $code size_t$$ object, +$codei% + %k% = %f%.size_forward_set() +%$$ +sets $icode k$$ to the amount of memory (in unsigned character units) +used to store the +$cref/vector of sets/glossary/Sparsity Pattern/Vector of Sets/$$ +sparsity patterns. +If $icode internal_bool$$ if true, $icode k$$ will be zero. +Otherwise it will be non-zero. +If you do not need this information for future $cref rev_hes_sparsity$$ +calculations, it can be deleted +(and the corresponding memory freed) using +$codei% + %f%.size_forward_set(0) +%$$ +after which $icode%f%.size_forward_set()%$$ will return zero. + +$head pattern_in$$ +The argument $icode pattern_in$$ has prototype +$codei% + const sparse_rc<%SizeVector%>& %pattern_in% +%$$ +see $cref sparse_rc$$. +If $icode transpose$$ it is false (true), +$icode pattern_in$$ is a sparsity pattern for $latex R$$ ($latex R^\R{T}$$). + +$head transpose$$ +This argument has prototype +$codei% + bool %transpose% +%$$ +See $cref/pattern_in/for_jac_sparsity/pattern_in/$$ above and +$cref/pattern_out/for_jac_sparsity/pattern_out/$$ below. + +$head dependency$$ +This argument has prototype +$codei% + bool %dependency% +%$$ +see $cref/pattern_out/for_jac_sparsity/pattern_out/$$ below. + +$head internal_bool$$ +This argument has prototype +$codei% + bool %internal_bool% +%$$ +If this is true, calculations are done with sets represented by a vector +of boolean values. Otherwise, a vector of sets of integers is used. + +$head pattern_out$$ +This argument has prototype +$codei% + sparse_rc<%SizeVector%>& %pattern_out% +%$$ +This input value of $icode pattern_out$$ does not matter. +If $icode transpose$$ it is false (true), +upon return $icode pattern_out$$ is a sparsity pattern for +$latex J(x)$$ ($latex J(x)^\R{T}$$). +If $icode dependency$$ is true, $icode pattern_out$$ is a +$cref/dependency pattern/dependency.cpp/Dependency Pattern/$$ +instead of sparsity pattern. + +$head Sparsity for Entire Jacobian$$ +Suppose that +$latex R$$ is the $latex n \times n$$ identity matrix. +In this case, $icode pattern_out$$ is a sparsity pattern for +$latex F^{(1)} ( x )$$ ( $latex F^{(1)} (x)^\R{T}$$ ) +if $icode transpose$$ is false (true). + +$head Example$$ +$children% + example/sparse/for_jac_sparsity.cpp +%$$ +The file +$cref for_jac_sparsity.cpp$$ +contains an example and test of this operation. + +$end +----------------------------------------------------------------------------- +*/ +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +Forward Jacobian sparsity patterns. + +\tparam Base +is the base type for this recording. + +\tparam SizeVector +is the simple vector with elements of type size_t that is used for +row, column index sparsity patterns. + +\param pattern_in +is the sparsity pattern for for R or R^T depending on transpose. + +\param transpose +Is the input and returned sparsity pattern 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 internal_bool +If this is true, calculations are done with sets represented by a vector +of boolean values. Othewise, a vector of standard sets is used. + +\param pattern_out +The value of transpose is false (true), +the return value is a sparsity pattern for J(x) ( J(x)^T ) where +\f[ + J(x) = F^{(1)} (x) * R +\f] +Here F is the function corresponding to the operation sequence +and x is any argument value. +*/ +template +template +void ADFun::for_jac_sparsity( + const sparse_rc& pattern_in , + bool transpose , + bool dependency , + bool internal_bool , + sparse_rc& pattern_out ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + // number or rows, columns, and non-zeros in pattern_in + size_t nr_in = pattern_in.nr(); + size_t nc_in = pattern_in.nc(); + // + size_t n = nr_in; + size_t ell = nc_in; + if( transpose ) + std::swap(n, ell); + // + CPPAD_ASSERT_KNOWN( + n == Domain() , + "for_jac_sparsity: number rows in R " + "is not equal number of independent variables." + ); + bool zero_empty = true; + bool input_empty = true; + if( internal_bool ) + { // allocate memory for bool sparsity calculation + // (sparsity pattern is emtpy after a resize) + for_jac_sparse_pack_.resize(num_var_tape_, ell); + for_jac_sparse_set_.resize(0, 0); + // + // set sparsity patttern for independent variables + local::set_internal_sparsity( + zero_empty , + input_empty , + transpose , + ind_taddr_ , + for_jac_sparse_pack_ , + pattern_in + ); + + // compute sparsity for other variables + local::sweep::for_jac( + &play_, + dependency, + n, + num_var_tape_, + for_jac_sparse_pack_, + not_used_rec_base + + ); + // set the output pattern + local::get_internal_sparsity( + transpose, dep_taddr_, for_jac_sparse_pack_, pattern_out + ); + } + else + { + // allocate memory for set sparsity calculation + // (sparsity pattern is emtpy after a resize) + for_jac_sparse_set_.resize(num_var_tape_, ell); + for_jac_sparse_pack_.resize(0, 0); + // + // set sparsity patttern for independent variables + local::set_internal_sparsity( + zero_empty , + input_empty , + transpose , + ind_taddr_ , + for_jac_sparse_set_ , + pattern_in + ); + + // compute sparsity for other variables + local::sweep::for_jac( + &play_, + dependency, + n, + num_var_tape_, + for_jac_sparse_set_, + not_used_rec_base + + ); + // get the ouput pattern + local::get_internal_sparsity( + transpose, dep_taddr_, for_jac_sparse_set_, pattern_out + ); + } + return; +} + + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/for_one.hpp cppad-2019.02.00.0/include/cppad/core/for_one.hpp --- cppad-2018.00.00.0/include/cppad/core/for_one.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/for_one.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,163 @@ +# ifndef CPPAD_CORE_FOR_ONE_HPP +# define CPPAD_CORE_FOR_ONE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin ForOne$$ +$spell + dy + typename + Taylor + const +$$ + + + + +$section First Order Partial Derivative: Driver Routine$$ + +$head Syntax$$ +$icode%dy% = %f%.ForOne(%x%, %j%)%$$ + + +$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$$. +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) +\right] +\] $$ + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the $cref ADFun$$ object $icode f$$ is not $code const$$ +(see $cref/ForOne Uses Forward/ForOne/ForOne Uses Forward/$$ below). + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %Vector% &%x% +%$$ +(see $cref/Vector/ForOne/Vector/$$ below) +and its size +must be equal to $icode n$$, the dimension of the +$cref/domain/seq_property/Domain/$$ space for $icode f$$. +It specifies +that point at which to evaluate the partial derivative. + +$head j$$ +The argument $icode j$$ has prototype +$codei% + size_t %j% +%$$ +an is less than $icode n$$, +$cref/domain/seq_property/Domain/$$ space for $icode f$$. +It specifies the component of $icode F$$ +for which we are computing the partial derivative. + +$head dy$$ +The result $icode dy$$ has prototype +$codei% + %Vector% %dy% +%$$ +(see $cref/Vector/ForOne/Vector/$$ below) +and its size is $latex m$$, the dimension of the +$cref/range/seq_property/Range/$$ space for $icode f$$. +The value of $icode dy$$ is the partial of $latex F$$ with respect to +$latex x_j$$ evaluated at $icode x$$; i.e., +for $latex i = 0 , \ldots , m - 1$$ +$latex \[. + dy[i] = \D{ F_i }{ x_j } ( x ) +\] $$ + + +$head Vector$$ +The type $icode Vector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$icode Base$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head ForOne Uses Forward$$ +After each call to $cref Forward$$, +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 +$icode%f%.Forward(0,%x%)%$$ +and the other coefficients are unspecified. + +$head Example$$ +$children% + example/general/for_one.cpp +%$$ +The routine +$cref/ForOne/for_one.cpp/$$ is both an example and test. +It returns $code true$$, if it succeeds and $code false$$ otherwise. + +$end +----------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +template +template +Vector ADFun::ForOne(const Vector &x, size_t j) +{ size_t j1; + + size_t n = Domain(); + size_t m = Range(); + + // check Vector is Simple Vector class with Base type elements + CheckSimpleVector(); + + 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" + ); + + // point at which we are evaluating the second partials + Forward(0, x); + + // direction in which are are taking the derivative + Vector dx(n); + for(j1 = 0; j1 < n; j1++) + dx[j1] = Base(0.0); + dx[j] = Base(1.0); + + // dimension the return value + Vector dy(m); + + // compute the return value + dy = Forward(1, dx); + + return dy; +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/for_sparse_hes.hpp cppad-2019.02.00.0/include/cppad/core/for_sparse_hes.hpp --- cppad-2018.00.00.0/include/cppad/core/for_sparse_hes.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/for_sparse_hes.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,594 @@ +# ifndef CPPAD_CORE_FOR_SPARSE_HES_HPP +# define CPPAD_CORE_FOR_SPARSE_HES_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin ForSparseHes$$ +$spell + Andrea Walther + std + VecAD + Jacobian + Jac + Hessian + Hes + const + Bool + Dep + proportional + var + cpp +$$ + +$section Hessian Sparsity Pattern: Forward Mode$$ + +$head Syntax$$ +$icode%h% = %f%.ForSparseHes(%r%, %s%) +%$$ + +$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$$. +we define +$latex \[ +\begin{array}{rcl} +H(x) +& = & \partial_x \left[ \partial_u S \cdot F[ x + R \cdot u ] \right]_{u=0} +\\ +& = & R^\R{T} \cdot (S \cdot F)^{(2)} ( x ) \cdot R +\end{array} +\] $$ +Where $latex R \in \B{R}^{n \times n}$$ is a diagonal matrix +and $latex S \in \B{R}^{1 \times m}$$ is a row vector. +Given a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +for the diagonal of $latex R$$ and the vector $latex S$$, +$code ForSparseHes$$ returns a sparsity pattern for the $latex H(x)$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + const ADFun<%Base%> %f% +%$$ + +$head x$$ +If the operation sequence in $icode f$$ is +$cref/independent/glossary/Operation/Independent/$$ of +the independent variables in $latex x \in \B{R}^n$$, +the sparsity pattern is valid for all values of +(even if it has $cref CondExp$$ or $cref VecAD$$ operations). + +$head r$$ +The argument $icode r$$ has prototype +$codei% + const %SetVector%& %r% +%$$ +(see $cref/SetVector/ForSparseHes/SetVector/$$ below) +If it has elements of type $code bool$$, +its size is $latex n$$. +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 n - 1$$. +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +for the diagonal of $latex R$$. +The fewer non-zero elements in this sparsity pattern, +the faster the calculation should be and the more sparse +$latex H(x)$$ should be. + +$head s$$ +The argument $icode s$$ has prototype +$codei% + const %SetVector%& %s% +%$$ +(see $cref/SetVector/ForSparseHes/SetVector/$$ below) +If it has elements of type $code bool$$, +its size is $latex m$$. +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/$$ +for the vector $icode S$$. +The fewer non-zero elements in this sparsity pattern, +the faster the calculation should be and the more sparse +$latex H(x)$$ should be. + +$head h$$ +The result $icode h$$ has prototype +$codei% + %SetVector%& %h% +%$$ +(see $cref/SetVector/ForSparseHes/SetVector/$$ below). +If $icode h$$ has elements of type $code bool$$, +its size is $latex n * n$$. +If it has elements of type $code std::set$$, +its size is $latex n$$ and all the set elements are between +zero and $icode%n%-1%$$ inclusive. +It specifies a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +for the matrix $latex H(x)$$. + +$head SetVector$$ +The type $icode SetVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code bool$$ or $code std::set$$; +see $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for a discussion +of the difference. +The type of the elements of +$cref/SetVector/ForSparseHes/SetVector/$$ must be the +same as the type of the elements of $icode r$$. + +$head Algorithm$$ +See Algorithm II in +$italic Computing sparse Hessians with automatic differentiation$$ +by Andrea Walther. +Note that $icode s$$ provides the information so that +'dead ends' are not included in the sparsity pattern. + +$head Example$$ +$children% + example/sparse/for_sparse_hes.cpp +%$$ +The file +$cref for_sparse_hes.cpp$$ +contains an example and test of this operation. + +$end +----------------------------------------------------------------------------- +*/ +# include +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file core/for_sparse_hes.hpp +Forward mode Hessian sparsity patterns. +*/ +// =========================================================================== +// ForSparseHesCase +/*! +Private helper function for ForSparseHes(q, s) bool sparsity. + +All of the description in the public member function ForSparseHes(q, s) +applies. + +\param set_type +is a bool value. This argument is used to dispatch to the proper source +code depending on the vlaue of SetVector::value_type. + +\param r +See ForSparseHes(r, s). + +\param s +See ForSparseHes(r, s). + +\param h +is the return value for the corresponging call to ForSparseJac(q, s). +*/ +template +template +void ADFun::ForSparseHesCase( + bool set_type , + const SetVector& r , + const SetVector& s , + SetVector& h ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + size_t n = Domain(); + size_t m = Range(); + // + // check Vector is Simple SetVector class with bool elements + CheckSimpleVector(); + // + CPPAD_ASSERT_KNOWN( + size_t(r.size()) == n, + "ForSparseHes: size of r is not equal to\n" + "domain dimension for ADFun object." + ); + CPPAD_ASSERT_KNOWN( + size_t(s.size()) == m, + "ForSparseHes: size of s is not equal to\n" + "range dimension for ADFun object." + ); + // + // sparsity pattern corresponding to r + local::sparse_pack for_jac_pattern; + for_jac_pattern.resize(num_var_tape_, n + 1); + for(size_t i = 0; i < n; i++) + { CPPAD_ASSERT_UNKNOWN( ind_taddr_[i] < n + 1 ); + // ind_taddr_[i] is operator taddr for i-th independent variable + CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[i] ) == local::InvOp ); + // + // Use add_element when only adding one element per set is added. + if( r[i] ) + for_jac_pattern.add_element( ind_taddr_[i], ind_taddr_[i] ); + } + // compute forward Jacobiain sparsity pattern + bool dependency = false; + local::sweep::for_jac( + &play_, + dependency, + n, + num_var_tape_, + for_jac_pattern, + not_used_rec_base + + ); + // sparsity pattern correspnding to s + local::sparse_pack rev_jac_pattern; + rev_jac_pattern.resize(num_var_tape_, 1); + for(size_t i = 0; i < m; i++) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + // + // Use add_element when only adding one element per set is added. + if( s[i] ) + rev_jac_pattern.add_element( dep_taddr_[i], 0); + } + // compute reverse sparsity pattern for dependency analysis + // (note that we are only want non-zero derivatives not true dependency) + local::sweep::rev_jac( + &play_, + dependency, + n, + num_var_tape_, + rev_jac_pattern, + not_used_rec_base + + ); + // vector of sets that will hold the forward Hessain values + local::sparse_pack for_hes_pattern; + for_hes_pattern.resize(n+1, n+1); + // + // compute the Hessian sparsity patterns + local::sweep::for_hes( + &play_, + n, + num_var_tape_, + for_jac_pattern, + rev_jac_pattern, + for_hes_pattern, + not_used_rec_base + + ); + // initialize return values corresponding to independent variables + h.resize(n * n); + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n; j++) + h[ i * n + j ] = false; + } + // copy to result pattern + CPPAD_ASSERT_UNKNOWN( for_hes_pattern.end() == n+1 ); + for(size_t i = 0; i < n; i++) + { // ind_taddr_[i] is operator taddr for i-th independent variable + CPPAD_ASSERT_UNKNOWN( ind_taddr_[i] == i + 1 ); + CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[i] ) == local::InvOp ); + + // extract the result from for_hes_pattern + local::sparse_pack::const_iterator itr(for_hes_pattern, ind_taddr_[i] ); + size_t j = *itr; + while( j < for_hes_pattern.end() ) + { CPPAD_ASSERT_UNKNOWN( 0 < j ) + h[ i * n + (j-1) ] = true; + j = *(++itr); + } + } +} +/*! +Private helper function for ForSparseHes(q, s) set sparsity. + +All of the description in the public member function ForSparseHes(q, s) +applies. + +\param set_type +is a std::set value. +This argument is used to dispatch to the proper source +code depending on the vlaue of SetVector::value_type. + +\param r +See ForSparseHes(r, s). + +\param s +See ForSparseHes(q, s). + +\param h +is the return value for the corresponging call to ForSparseJac(q, s). +*/ +template +template +void ADFun::ForSparseHesCase( + const std::set& set_type , + const SetVector& r , + const SetVector& s , + SetVector& h ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + size_t n = Domain(); +# ifndef NDEBUG + size_t m = Range(); +# endif + std::set::const_iterator itr_1; + // + // check SetVector is Simple Vector class with sets for elements + CheckSimpleVector, SetVector>( + local::one_element_std_set(), local::two_element_std_set() + ); + CPPAD_ASSERT_KNOWN( + r.size() == 1, + "ForSparseHes: size of s is not equal to one." + ); + CPPAD_ASSERT_KNOWN( + s.size() == 1, + "ForSparseHes: size of s is not equal to one." + ); + // + // sparsity pattern corresponding to r + local::sparse_list for_jac_pattern; + for_jac_pattern.resize(num_var_tape_, n + 1); + itr_1 = r[0].begin(); + while( itr_1 != r[0].end() ) + { size_t i = *itr_1++; + CPPAD_ASSERT_UNKNOWN( ind_taddr_[i] < n + 1 ); + // ind_taddr_[i] is operator taddr for i-th independent variable + CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[i] ) == local::InvOp ); + // + // Use add_element when only adding one element per set is added. + for_jac_pattern.add_element( ind_taddr_[i], ind_taddr_[i] ); + } + // compute forward Jacobiain sparsity pattern + bool dependency = false; + local::sweep::for_jac( + &play_, + dependency, + n, + num_var_tape_, + for_jac_pattern, + not_used_rec_base + + ); + // sparsity pattern correspnding to s + local::sparse_list rev_jac_pattern; + rev_jac_pattern.resize(num_var_tape_, 1); + itr_1 = s[0].begin(); + while( itr_1 != s[0].end() ) + { size_t i = *itr_1++; + CPPAD_ASSERT_KNOWN( + i < m, + "ForSparseHes: an element of the set s[0] has value " + "greater than or equal m" + ); + CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + // + // Use add_element when only adding one element per set is added. + rev_jac_pattern.add_element( dep_taddr_[i], 0); + } + // + // compute reverse sparsity pattern for dependency analysis + // (note that we are only want non-zero derivatives not true dependency) + local::sweep::rev_jac( + &play_, + dependency, + n, + num_var_tape_, + rev_jac_pattern, + not_used_rec_base + + ); + // + // vector of sets that will hold reverse Hessain values + local::sparse_list for_hes_pattern; + for_hes_pattern.resize(n+1, n+1); + // + // compute the Hessian sparsity patterns + local::sweep::for_hes( + &play_, + n, + num_var_tape_, + for_jac_pattern, + rev_jac_pattern, + for_hes_pattern, + not_used_rec_base + + ); + // return values corresponding to independent variables + // j is index corresponding to reverse mode partial + h.resize(n); + CPPAD_ASSERT_UNKNOWN( for_hes_pattern.end() == n+1 ); + for(size_t i = 0; i < n; i++) + { CPPAD_ASSERT_UNKNOWN( ind_taddr_[i] == i + 1 ); + CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[i] ) == local::InvOp ); + + // extract the result from for_hes_pattern + local::sparse_list::const_iterator itr_2(for_hes_pattern, ind_taddr_[i] ); + size_t j = *itr_2; + while( j < for_hes_pattern.end() ) + { CPPAD_ASSERT_UNKNOWN( 0 < j ) + h[i].insert(j-1); + j = *(++itr_2); + } + } +} + +// =========================================================================== +// ForSparseHes + +/*! +User API for Hessian sparsity patterns using reverse mode. + +The C++ source code corresponding to this operation is +\verbatim + h = f.ForSparseHes(q, r) +\endverbatim + +\tparam Base +is the base type for this recording. + +\tparam SetVector +is a simple vector with elements of type bool +or std::set. + +\param r +is a vector with size n that specifies the sparsity pattern +for the diagonal of the matrix \f$ R \f$, +where n is the number of independent variables +corresponding to the operation sequence stored in play. + +\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. + +\return +The return vector is a sparsity pattern for \f$ H(x) \f$ +\f[ + H(x) = R^T ( S * F)^{(2)} (x) R +\f] +where \f$ F \f$ is the function corresponding to the operation sequence +and x is any argument value. +*/ + +template +template +SetVector ADFun::ForSparseHes( + const SetVector& r, const SetVector& s +) +{ + SetVector h; + typedef typename SetVector::value_type Set_type; + + // Should check to make sure q is same as in previous call to + // forward sparse Jacobian. + ForSparseHesCase( + Set_type() , + r , + s , + h + ); + + return h; +} +// =========================================================================== +// ForSparseHesCheckpoint +/*! +Hessian sparsity patterns calculation used by checkpoint functions. + +\tparam Base +is the base type for this recording. + +\param r +is a vector with size n that specifies the sparsity pattern +for the diagonal of \f$ R \f$, +where n is the number of independent variables +corresponding to the operation sequence stored in play_. + +\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) R \f$. + +\par Assumptions +The forward jacobian sparsity pattern must be currently stored +in this ADFUN object. +*/ + +// The checkpoint class is not yet using forward sparse Hessians. +# ifdef CPPAD_NOT_DEFINED +template +void ADFun::ForSparseHesCheckpoint( + vector& r , + vector& s , + local::sparse_list& h ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + + 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() == 0 ); + CPPAD_ASSERT_UNKNOWN( s.size() == m ); + + // Array that holds the reverse Jacobiain dependcy flags. + // Initialize as true for dependent variables, flase for others. + local::pod_vector RevJac(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 forward Hessian sparsity pattern for all variables + local::sparse_list for_hes_pattern; + for_hes_pattern.resize(n+1, n+1); + + // compute Hessian sparsity pattern for all variables + local::sweep::for_hes( + &play_, + n, + num_var_tape_, + for_jac_sparse_set_, + RevJac.data(), + for_hes_pattern, + not_used_rec_base + + ); + + // dimension the return value + if( transpose ) + h.resize(n, n); + else + h.resize(n, 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] ) == local::InvOp ); + + // extract the result from for_hes_pattern + CPPAD_ASSERT_UNKNOWN( for_hes_pattern.end() == q ); + local::sparse_list::const_iterator itr(for_hes_pattern, .j + 1); + size_t i = *itr; + while( i < q ) + { if( transpose ) + h.post_element(j, i); + else + h.post_element(i, j); + i = *(++itr); + } + } + // process posts + for(size_t i = 0; i < n; ++i) + h.process_post(i); +} +# endif + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/for_sparse_jac.hpp cppad-2019.02.00.0/include/cppad/core/for_sparse_jac.hpp --- cppad-2018.00.00.0/include/cppad/core/for_sparse_jac.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/for_sparse_jac.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,764 @@ +# ifndef CPPAD_CORE_FOR_SPARSE_JAC_HPP +# define CPPAD_CORE_FOR_SPARSE_JAC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin ForSparseJac$$ +$spell + std + var + Jacobian + Jac + const + Bool + proportional + VecAD + CondExpRel + optimizer + cpp +$$ + +$section Jacobian Sparsity Pattern: Forward Mode$$ + +$head Syntax$$ +$icode%s% = %f%.ForSparseJac(%q%, %r%) +%$$ +$icode%s% = %f%.ForSparseJac(%q%, %r%, %transpose%, %dependency%)%$$ + +$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 $latex n \times q$$ matrix $latex R$$, +the Jacobian of $latex F[ x + R * u ]$$ +with respect to $latex u$$ at $latex u = 0$$ is +$latex \[ + S(x) = F^{(1)} ( x ) * R +\] $$ +Given a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +for $latex R$$, +$code ForSparseJac$$ returns a sparsity pattern for the $latex S(x)$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the $cref ADFun$$ object $icode f$$ is not $code const$$. +After a call to $code ForSparseJac$$, the sparsity pattern +for each of the variables in the operation sequence +is held in $icode f$$ (for possible later use by $cref RevSparseHes$$). +These sparsity patterns are stored with elements of type $code bool$$ +or elements of type $code std::set$$ +(see $cref/SetVector/ForSparseJac/SetVector/$$ below). + +$subhead size_forward_bool$$ +After $code ForSparseJac$$, if $icode k$$ is a $code size_t$$ object, +$codei% + %k% = %f%.size_forward_bool() +%$$ +sets $icode k$$ to the amount of memory (in unsigned character units) +used to store the sparsity pattern with elements of type $code bool$$ +in the function object $icode f$$. +If the sparsity patterns for the previous $code ForSparseJac$$ used +elements of type $code bool$$, +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 +$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, +$codei% + %k% = %f%.size_forward_set() +%$$ +sets $icode k$$ to the amount of memory (in unsigned character units) +used to store the +$cref/vector of sets/glossary/Sparsity Pattern/Vector of Sets/$$ +sparsity patterns. +If the sparsity patterns for this operation use elements of type $code bool$$, +the return value for $code size_forward_set$$ will be zero. +Otherwise, its return value will be non-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 +$codei% + %f%.size_forward_set(0) +%$$ +After this call, $icode%f%.size_forward_set()%$$ will return zero. + +$head x$$ +If the operation sequence in $icode f$$ is +$cref/independent/glossary/Operation/Independent/$$ of +the independent variables in $latex x \in \B{R}^n$$, +the sparsity pattern is valid for all values of +(even if it has $cref CondExp$$ or $cref VecAD$$ operations). + +$head q$$ +The argument $icode q$$ has prototype +$codei% + size_t %q% +%$$ +It specifies the number of columns in +$latex R \in \B{R}^{n \times q}$$ and the Jacobian +$latex S(x) \in \B{R}^{m \times q}$$. + +$head transpose$$ +The argument $icode transpose$$ has prototype +$codei% + bool %transpose% +%$$ +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 +$codei% + const %SetVector%& %r% +%$$ +see $cref/SetVector/ForSparseJac/SetVector/$$ below. + +$subhead transpose false$$ +If $icode r$$ has elements of type $code bool$$, +its size is $latex n * q$$. +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 $latex R \in \B{R}^{n \times q}$$. + +$subhead transpose true$$ +If $icode r$$ has elements of type $code bool$$, +its size is $latex q * n$$. +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 $latex R^\R{T} \in \B{R}^{q \times n}$$. + +$head s$$ +The return value $icode s$$ has prototype +$codei% + %SetVector% %s% +%$$ +see $cref/SetVector/ForSparseJac/SetVector/$$ below. + +$subhead transpose false$$ +If $icode s$$ has elements of type $code bool$$, +its size is $latex m * q$$. +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/$$ +for the matrix $latex S(x) \in \B{R}^{m \times q}$$. + +$subhead transpose true$$ +If $icode s$$ has elements of type $code bool$$, +its size is $latex q * m$$. +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/$$ +for the matrix $latex S(x)^\R{T} \in \B{R}^{q \times m}$$. + +$head SetVector$$ +The type $icode SetVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code bool$$ or $code std::set$$; +see $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for a discussion +of the difference. + +$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 +sparsity pattern for the Jacobian $latex S(x) = F^{(1)} ( x )$$. + +$head Example$$ +$children% + example/sparse/for_sparse_jac.cpp +%$$ +The file +$cref for_sparse_jac.cpp$$ +contains an example and test of this operation. +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 +----------------------------------------------------------------------------- +*/ + +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file core/for_sparse_jac.hpp +Forward mode Jacobian sparsity patterns. +*/ +// --------------------------------------------------------------------------- +/*! +Private helper function for ForSparseJac(q, r) boolean sparsity patterns. + +All of the description in the public member function ForSparseJac(q, r) +applies. + +\param set_type +is a bool value. This argument is used to dispatch to the proper source +code depending on the value of SetVector::value_type. + +\param transpose +See ForSparseJac(q, r, transpose, dependency). + +\param dependency +See ForSparseJac(q, r, transpose, dependency). + +\param q +See ForSparseJac(q, r, transpose, dependency). + +\param r +See ForSparseJac(q, r, transpose, dependency). + +\param s +is the return value for the corresponding call to ForSparseJac(q, r). +*/ + +template +template +void ADFun::ForSparseJacCase( + bool set_type , + bool transpose , + bool dependency , + size_t q , + const SetVector& r , + SetVector& s ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + size_t m = Range(); + size_t n = Domain(); + + // check SetVector is Simple Vector class with bool elements + CheckSimpleVector(); + + // dimension size of result vector + s.resize( m * q ); + + CPPAD_ASSERT_KNOWN( + q > 0, + "ForSparseJac: q is not greater than zero" + ); + 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." + ); + // + // allocate memory for the requested sparsity calculation result + for_jac_sparse_pack_.resize(num_var_tape_, q); + + // set values corresponding to independent variables + for(size_t i = 0; i < n; i++) + { CPPAD_ASSERT_UNKNOWN( ind_taddr_[i] < num_var_tape_ ); + // ind_taddr_[i] is operator taddr for i-th independent variable + CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[i] ) == local::InvOp ); + + // set bits that are true + if( transpose ) + { for(size_t j = 0; j < q; j++) if( r[ j * n + i ] ) + for_jac_sparse_pack_.post_element( ind_taddr_[i], j); + } + else + { for(size_t j = 0; j < q; j++) if( r[ i * q + j ] ) + for_jac_sparse_pack_.post_element( ind_taddr_[i], j); + } + } + // process posts + for(size_t j = 0; j < n; j++) + for_jac_sparse_pack_.process_post( ind_taddr_[j] ); + + // evaluate the sparsity patterns + local::sweep::for_jac( + &play_, + dependency, + n, + num_var_tape_, + for_jac_sparse_pack_, + not_used_rec_base + + ); + + // return values corresponding to dependent variables + CPPAD_ASSERT_UNKNOWN( size_t(s.size()) == m * q ); + for(size_t i = 0; i < m; i++) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + + // extract the result from for_jac_sparse_pack_ + if( transpose ) + { for(size_t j = 0; j < q; j++) + s[ j * m + i ] = false; + } + else + { for(size_t j = 0; j < q; j++) + s[ i * q + j ] = false; + } + CPPAD_ASSERT_UNKNOWN( for_jac_sparse_pack_.end() == q ); + local::sparse_pack::const_iterator + itr(for_jac_sparse_pack_, dep_taddr_[i] ); + size_t j = *itr; + while( j < q ) + { if( transpose ) + s[j * m + i] = true; + else + s[i * q + j] = true; + j = *(++itr); + } + } +} +// --------------------------------------------------------------------------- +/*! +Private helper function for ForSparseJac(q, r) set sparsity. + +All of the description in the public member function ForSparseJac(q, r) +applies. + +\param set_type +is a std::set object. +This argument is used to dispatch to the proper source +code depending on the value of SetVector::value_type. + +\param transpose +See ForSparseJac(q, r, transpose, dependency). + +\param dependency +See ForSparseJac(q, r, transpose, dependency). + +\param q +See ForSparseJac(q, r, transpose, dependency). + +\param r +See ForSparseJac(q, r, transpose, dependency). + +\param s +is the return value for the corresponding call to ForSparseJac(q, r). +*/ +template +template +void ADFun::ForSparseJacCase( + const std::set& set_type , + bool transpose , + bool dependency , + size_t q , + const SetVector& r , + SetVector& s ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + size_t m = Range(); + size_t n = Domain(); + + // check SetVector is Simple Vector class with sets for elements + CheckSimpleVector, SetVector>( + local::one_element_std_set(), local::two_element_std_set() + ); + + // dimension size of result vector + if( transpose ) + s.resize(q); + else + s.resize( m ); + + // temporary iterator + std::set::const_iterator itr_1; + + CPPAD_ASSERT_KNOWN( + q > 0, + "ForSparseJac: q is not greater than zero" + ); + CPPAD_ASSERT_KNOWN( + size_t(r.size()) == n || transpose, + "ForSparseJac: size of r is not equal to n and transpose is false." + ); + CPPAD_ASSERT_KNOWN( + size_t(r.size()) == q || ! transpose, + "ForSparseJac: size of r is not equal to q and transpose is true." + ); + // + // allocate memory for the requested sparsity calculation + for_jac_sparse_set_.resize(num_var_tape_, q); + + // set values corresponding to independent variables + if( transpose ) + { for(size_t i = 0; i < q; i++) + { // add the elements that are present + itr_1 = r[i].begin(); + while( itr_1 != r[i].end() ) + { size_t j = *itr_1++; + CPPAD_ASSERT_KNOWN( + j < n, + "ForSparseJac: transpose is true and element of the set\n" + "r[j] has value greater than or equal n." + ); + CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] < num_var_tape_ ); + // operator for j-th independent variable + CPPAD_ASSERT_UNKNOWN( + play_.GetOp( ind_taddr_[j] ) == local::InvOp + ); + for_jac_sparse_set_.post_element( ind_taddr_[j], i); + } + } + } + else + { for(size_t i = 0; i < n; i++) + { CPPAD_ASSERT_UNKNOWN( ind_taddr_[i] < num_var_tape_ ); + // ind_taddr_[i] is operator taddr for i-th independent variable + CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[i] ) == local::InvOp ); + + // add the elements that are present + itr_1 = r[i].begin(); + while( itr_1 != r[i].end() ) + { size_t j = *itr_1++; + CPPAD_ASSERT_KNOWN( + j < q, + "ForSparseJac: an element of the set r[i] " + "has value greater than or equal q." + ); + for_jac_sparse_set_.post_element( ind_taddr_[i], j); + } + } + } + // process posts + for(size_t j = 0; j < n; j++) + for_jac_sparse_set_.process_post( ind_taddr_[j] ); + + // evaluate the sparsity patterns + local::sweep::for_jac( + &play_, + dependency, + n, + num_var_tape_, + for_jac_sparse_set_, + not_used_rec_base + + ); + + // return values corresponding to dependent variables + CPPAD_ASSERT_UNKNOWN( size_t(s.size()) == m || transpose ); + CPPAD_ASSERT_UNKNOWN( size_t(s.size()) == q || ! transpose ); + for(size_t i = 0; i < m; i++) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + + // extract results from for_jac_sparse_set_ + // and add corresponding elements to sets in s + CPPAD_ASSERT_UNKNOWN( for_jac_sparse_set_.end() == q ); + local::sparse_list::const_iterator + itr_2(for_jac_sparse_set_, dep_taddr_[i] ); + size_t j = *itr_2; + while( j < q ) + { if( transpose ) + s[j].insert(i); + else + s[i].insert(j); + j = *(++itr_2); + } + } +} +// --------------------------------------------------------------------------- + +/*! +User API for Jacobian sparsity patterns using forward mode. + +The C++ source code corresponding to this operation is +\verbatim + s = f.ForSparseJac(q, r, transpose, dependency) +\endverbatim + +\tparam Base +is the base type for this recording. + +\tparam SetVector +is a simple vector with elements of type bool +or std::set. + +\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 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 transpose is false (true), +the return value is a sparsity pattern for \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 x is any argument value. +If SetVector::value_type is bool, +the return value has size \f$ m * q \f$ (\f$ q * m \f$). +where m is the number of dependent variables +corresponding to the operation sequence stored in f. +If SetVector::value_type is std::set, +the return value has size \f$ m \f$ ( \f$ q \f$ ) +and with all its elements between zero and +\f$ q - 1 \f$ ( \f$ m - 1 \f$). + +\par Side Effects +If SetVector::value_type is bool, +the forward sparsity pattern for all of the variables on the +tape is stored in 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 SetVector::value_type is std::set, +the forward sparsity pattern for all of the variables on the +tape is stored in 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 +template +SetVector ADFun::ForSparseJac( + size_t q , + const SetVector& r , + bool transpose , + bool dependency ) +{ + SetVector s; + typedef typename SetVector::value_type Set_type; + + // free all memory currently in sparsity patterns + for_jac_sparse_pack_.resize(0, 0); + for_jac_sparse_set_.resize(0, 0); + + ForSparseJacCase( + Set_type() , + transpose , + dependency , + q , + r , + s + ); + + 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 SetVector::value_type is bool, +the forward sparsity pattern for all of the variables on the +tape is stored in 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 SetVector::value_type is std::set, +the forward sparsity pattern for all of the variables on the +tape is stored in 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 , + const local::sparse_list& r , + bool transpose , + bool dependency , + local::sparse_list& s ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + 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] ) == local::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++) + { local::sparse_list::const_iterator itr(r, i); + size_t j = *itr; + while( j < n ) + { for_jac_sparse_set_.post_element( ind_taddr_[j], i ); + j = *(++itr); + } + } + } + else + { for(size_t j = 0; j < n; j++) + { local::sparse_list::const_iterator itr(r, j); + size_t i = *itr; + while( i < q ) + { for_jac_sparse_set_.post_element( ind_taddr_[j], i ); + i = *(++itr); + } + } + } + // process posts + for(size_t j = 0; j < n; j++) + for_jac_sparse_set_.process_post( ind_taddr_[j] ); + + // evaluate the sparsity pattern for all variables + local::sweep::for_jac( + &play_, + dependency, + n, + num_var_tape_, + for_jac_sparse_set_, + not_used_rec_base + + ); + + // 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 ); + local::sparse_list::const_iterator + itr(for_jac_sparse_set_, dep_taddr_[i] ); + size_t j = *itr; + while( j < q ) + { if( transpose ) + s.post_element(j, i); + else + s.post_element(i, j); + j = *(++itr); + } + } + // process posts + for(size_t i = 0; i < s.n_set(); ++i) + s.process_post(i); + +} + + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/for_two.hpp cppad-2019.02.00.0/include/cppad/core/for_two.hpp --- cppad-2018.00.00.0/include/cppad/core/for_two.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/for_two.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,254 @@ +# ifndef CPPAD_CORE_FOR_TWO_HPP +# define CPPAD_CORE_FOR_TWO_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin ForTwo$$ +$spell + ddy + typename + Taylor + const +$$ + + + + + +$section Forward Mode Second Partial Derivative Driver$$ + +$head Syntax$$ +$icode%ddy% = %f%.ForTwo(%x%, %j%, %k%)%$$ + + +$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$$. +The syntax above sets +$latex \[ + ddy [ i * p + \ell ] + = + \DD{ F_i }{ x_{j[ \ell ]} }{ x_{k[ \ell ]} } (x) +\] $$ +for $latex i = 0 , \ldots , m-1$$ +and $latex \ell = 0 , \ldots , p$$, +where $latex p$$ is the size of the vectors $icode j$$ and $icode k$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the $cref ADFun$$ object $icode f$$ is not $code const$$ +(see $cref/ForTwo Uses Forward/ForTwo/ForTwo Uses Forward/$$ below). + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %BaseVector% &%x% +%$$ +(see $cref/BaseVector/ForTwo/BaseVector/$$ below) +and its size +must be equal to $icode n$$, the dimension of the +$cref/domain/seq_property/Domain/$$ space for $icode f$$. +It specifies +that point at which to evaluate the partial derivatives listed above. + +$head j$$ +The argument $icode j$$ has prototype +$codei% + const %SizeVector_t% &%j% +%$$ +(see $cref/SizeVector_t/ForTwo/SizeVector_t/$$ below) +We use $icode p$$ to denote the size of the vector $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$$. + +$head k$$ +The argument $icode k$$ has prototype +$codei% + const %SizeVector_t% &%k% +%$$ +(see $cref/SizeVector_t/ForTwo/SizeVector_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$$ +must be less than $icode n$$; i.e., +for $latex \ell = 0 , \ldots , p-1$$, $latex k[ \ell ] < n$$. + +$head ddy$$ +The result $icode ddy$$ has prototype +$codei% + %BaseVector% %ddy% +%$$ +(see $cref/BaseVector/ForTwo/BaseVector/$$ below) +and its size is $latex m * p$$. +It contains the requested partial derivatives; to be specific, +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) +\] $$ + +$head BaseVector$$ +The type $icode BaseVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type Base/SimpleVector/Elements of Specified Type/$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head SizeVector_t$$ +The type $icode SizeVector_t$$ 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 ForTwo Uses Forward$$ +After each call to $cref Forward$$, +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 +$icode%f%.Forward(0, %x%)%$$ +and the other coefficients are unspecified. + +$head Examples$$ +$children% + example/general/for_two.cpp +%$$ +The routine +$cref/ForTwo/for_two.cpp/$$ is both an example and test. +It returns $code true$$, if it succeeds and $code false$$ otherwise. + +$end +----------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +template +template +BaseVector ADFun::ForTwo( + const BaseVector &x, + const SizeVector_t &j, + const SizeVector_t &k) +{ size_t i; + size_t j1; + size_t k1; + size_t l; + + size_t n = Domain(); + size_t m = Range(); + size_t p = j.size(); + + // check BaseVector is Simple Vector class with Base type elements + CheckSimpleVector(); + + // check SizeVector_t is Simple Vector class with size_t elements + CheckSimpleVector(); + + 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." + ); + // point at which we are evaluating the second partials + Forward(0, x); + + + // dimension the return value + BaseVector ddy(m * p); + + // allocate memory to hold all possible diagonal Taylor coefficients + // (for large sparse cases, this is not efficient) + BaseVector D(m * n); + + // boolean flag for which diagonal coefficients are computed + CppAD::vector c(n); + for(j1 = 0; j1 < n; j1++) + c[j1] = false; + + // direction vector in argument space + BaseVector dx(n); + for(j1 = 0; j1 < n; j1++) + dx[j1] = Base(0.0); + + // result vector in range space + BaseVector dy(m); + + // compute the diagonal coefficients that are needed + for(l = 0; l < p; l++) + { j1 = j[l]; + k1 = k[l]; + CPPAD_ASSERT_KNOWN( + j1 < n, + "ForTwo: an element of j not less than domain dimension for f." + ); + CPPAD_ASSERT_KNOWN( + k1 < n, + "ForTwo: an element of k not less than domain dimension for f." + ); + size_t count = 2; + while(count) + { count--; + if( ! c[j1] ) + { // diagonal term in j1 direction + c[j1] = true; + dx[j1] = Base(1.0); + Forward(1, dx); + + dx[j1] = Base(0.0); + dy = Forward(2, dx); + for(i = 0; i < m; i++) + D[i * n + j1 ] = dy[i]; + } + j1 = k1; + } + } + // compute all the requested cross partials + for(l = 0; l < p; l++) + { j1 = j[l]; + k1 = k[l]; + if( j1 == k1 ) + { for(i = 0; i < m; i++) + ddy[i * p + l] = Base(2.0) * D[i * n + j1]; + } + else + { + // cross term in j1 and k1 directions + dx[j1] = Base(1.0); + dx[k1] = Base(1.0); + Forward(1, dx); + + dx[j1] = Base(0.0); + dx[k1] = Base(0.0); + dy = Forward(2, dx); + + // place result in return value + for(i = 0; i < m; i++) + ddy[i * p + l] = dy[i] - D[i*n+j1] - D[i*n+k1]; + + } + } + return ddy; +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/forward.hpp cppad-2019.02.00.0/include/cppad/core/forward.hpp --- cppad-2018.00.00.0/include/cppad/core/forward.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/forward.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,445 @@ +# ifndef CPPAD_CORE_FORWARD_HPP +# define CPPAD_CORE_FORWARD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// documened after Forward but included here so easy to see +# include +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file core/forward.hpp +User interface to forward mode computations. +*/ + +/*! +Multiple orders, one direction, forward mode Taylor coefficieints. + +\tparam Base +The type used during the forward mode computations; i.e., the corresponding +recording of operations used the type AD. + +\tparam BaseVector +is a Simple Vector class with eleements of type Base. + +\param q +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. +For j = 0 , ... , n-1, +k = p, ... , q, are +xq[ (q+1-p)*j + k - p ] +is the k-th order coefficient for the j-th independent variable. + +\param s +Is the stream where output corresponding to PriOp operations will written. + +\return +contains Taylor coefficients for the dependent variables. +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)] +is the k-th order coefficient for the i-th dependent variable. + +\par taylor_ +The Taylor coefficients up to order p-1 are inputs +and the coefficents from order p through q are outputs. +Let N = num_var_tape_, and +C = cap_order_taylor_. +Note that for +i = 1 , ..., N-1, +k = 0 , ..., q, +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 +and there is no variable with index zero.) +*/ + +template +template +BaseVector ADFun::Forward( + size_t q , + const BaseVector& xq , + std::ostream& s ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + + // temporary indices + size_t i, j, k; + + // number of independent variables + size_t n = ind_taddr_.size(); + + // number of dependent variables + size_t m = dep_taddr_.size(); + + // check Vector is Simple Vector class with Base type elements + CheckSimpleVector(); + + + CPPAD_ASSERT_KNOWN( + size_t(xq.size()) == n || size_t(xq.size()) == n*(q+1), + "Forward(q, xq): xq.size() is not equal n or n*(q+1)" + ); + + // lowest order we are computing + size_t p = q + 1 - size_t(xq.size()) / n; + CPPAD_ASSERT_UNKNOWN( p == 0 || p == q ); + CPPAD_ASSERT_KNOWN( + 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" + " and number of directions is not one." + "\nMust use Forward(q, r, xq) for this case" + ); + // does taylor_ need more orders or fewer directions + if( (cap_order_taylor_ <= q) | (num_direction_taylor_ != 1) ) + { if( p == 0 ) + { // no need to copy old values during capacity_order + num_order_taylor_ = 0; + } + else + num_order_taylor_ = q; + size_t c = std::max(q + 1, cap_order_taylor_); + size_t r = 1; + capacity_order(c, r); + } + CPPAD_ASSERT_UNKNOWN( cap_order_taylor_ > q ); + CPPAD_ASSERT_UNKNOWN( num_direction_taylor_ == 1 ); + + // short hand notation for order capacity + size_t C = cap_order_taylor_; + + // The optimizer may skip a step that does not affect dependent variables. + // Initilaizing zero order coefficients avoids following valgrind warning: + // "Conditional jump or move depends on uninitialised value(s)". + for(j = 0; j < num_var_tape_; j++) + { for(k = p; k <= q; k++) + taylor_[C * j + k] = CppAD::numeric_limits::quiet_NaN(); + } + + // set Taylor coefficients for independent variables + for(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( play_.GetOp( ind_taddr_[j] ) == local::InvOp ); + + if( p == q ) + taylor_[ C * ind_taddr_[j] + q] = xq[j]; + else + { for(k = 0; k <= q; k++) + taylor_[ C * ind_taddr_[j] + k] = xq[ (q+1)*j + k]; + } + } + + // evaluate the derivatives + CPPAD_ASSERT_UNKNOWN( cskip_op_.size() == play_.num_op_rec() ); + CPPAD_ASSERT_UNKNOWN( load_op_.size() == play_.num_load_op_rec() ); + if( q == 0 ) + { + local::sweep::forward0(&play_, s, true, + n, num_var_tape_, C, + taylor_.data(), cskip_op_.data(), load_op_, + compare_change_count_, + compare_change_number_, + compare_change_op_index_, + not_used_rec_base + ); + } + else + { local::sweep::forward1(&play_, s, true, p, q, + n, num_var_tape_, C, + taylor_.data(), cskip_op_.data(), load_op_, + compare_change_count_, + compare_change_number_, + compare_change_op_index_, + not_used_rec_base + ); + } + + // return Taylor coefficients for dependent variables + BaseVector yq; + if( p == q ) + { yq.resize(m); + for(i = 0; i < m; i++) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + yq[i] = taylor_[ C * dep_taddr_[i] + q]; + } + } + else + { yq.resize(m * (q+1) ); + for(i = 0; i < m; i++) + { for(k = 0; k <= q; 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 ? + 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, + "with the value nan." + ); + if( 0 < q ) + { for(i = 0; i < m; i++) + { for(k = p; k <= q; k++) + { // Studio 2012, CppAD required in front of isnan ? + ok &= ! CppAD::isnan( yq[ (q+1-p)*i + k-p ] ); + } + } + } + CPPAD_ASSERT_KNOWN(ok, + "yq = f.Forward(q, xq): has a non-zero order Taylor coefficient\n" + "with the value nan (but zero order coefficients are not nan)." + ); + } +# endif + + // now we have q + 1 taylor_ coefficient orders per variable + num_order_taylor_ = q + 1; + + return yq; +} + +/*! +One order, multiple directions, forward mode Taylor coefficieints. + +\tparam Base +The type used during the forward mode computations; i.e., the corresponding +recording of operations used the type AD. + +\tparam BaseVector +is a Simple Vector class with eleements of type Base. + +\param q +is the order for this forward mode computation, +q > 0. +There must be at least q Taylor coefficients +per variable before this call. +After this call there will be q+1 +Taylor coefficients per variable. + +\param r +is the number of directions for this calculation. +If q != 1, r must be the same as in the previous +call to Forward where q was equal to one. + +\param xq +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, +xq[ ( r*j + ell ] +is the q-th order coefficient for the j-th independent variable +and the ell-th direction. + +\return +contains Taylor coefficients for the dependent variables. +The size of the return value y is r*m. +For i = 0, ... , m-1, +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. + +\par taylor_ +The Taylor coefficients up to order q-1 are inputs +and the coefficents of order q are outputs. +Let N = num_var_tape_, and +C = cap_order_taylor_. +Note that for +i = 1 , ..., N-1, +taylor_[ (C-1)*r*i + i + 0 ] +is the zero order cofficent, +for the i-th varaible, and all directions. +For i = 1 , ..., N-1, +k = 1 , ..., q, +ell = 0 , ..., r-1, +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 +and there is no variable with index zero.) +*/ + +template +template +BaseVector ADFun::Forward( + size_t q , + size_t r , + const BaseVector& xq ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + + // temporary indices + size_t i, j, ell; + + // number of independent variables + size_t n = ind_taddr_.size(); + + // number of dependent variables + size_t m = dep_taddr_.size(); + + // check Vector is Simple Vector class with Base type elements + CheckSimpleVector(); + + CPPAD_ASSERT_KNOWN( q > 0, "Forward(q, r, xq): q == 0" ); + CPPAD_ASSERT_KNOWN( + size_t(xq.size()) == r * n, + "Forward(q, r, xq): xq.size() is not equal r * n" + ); + CPPAD_ASSERT_KNOWN( + 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 ) + num_order_taylor_ = 1; + + size_t c = std::max(q + 1, cap_order_taylor_); + capacity_order(c, r); + } + CPPAD_ASSERT_UNKNOWN( cap_order_taylor_ > q ); + CPPAD_ASSERT_UNKNOWN( num_direction_taylor_ == r ) + + // short hand notation for order capacity + size_t c = cap_order_taylor_; + + // set Taylor coefficients for independent variables + for(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( play_.GetOp( ind_taddr_[j] ) == local::InvOp ); + + for(ell = 0; ell < r; ell++) + { size_t index = ((c-1)*r + 1)*ind_taddr_[j] + (q-1)*r + ell + 1; + taylor_[ index ] = xq[ r * j + ell ]; + } + } + + // evaluate the derivatives + CPPAD_ASSERT_UNKNOWN( cskip_op_.size() == play_.num_op_rec() ); + CPPAD_ASSERT_UNKNOWN( load_op_.size() == play_.num_load_op_rec() ); + local::sweep::forward2( + &play_, + q, + r, + n, + num_var_tape_, + c, + taylor_.data(), + cskip_op_.data(), + load_op_, + not_used_rec_base + ); + + // return Taylor coefficients for dependent variables + BaseVector yq; + yq.resize(r * m); + for(i = 0; i < m; i++) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + for(ell = 0; ell < r; ell++) + { size_t index = ((c-1)*r + 1)*dep_taddr_[i] + (q-1)*r + ell + 1; + yq[ r * i + ell ] = taylor_[ index ]; + } + } +# ifndef NDEBUG + if( check_for_nan_ ) + { bool ok = true; + for(i = 0; i < m; i++) + { for(ell = 0; ell < r; ell++) + { // Studio 2012, CppAD required in front of isnan ? + ok &= ! CppAD::isnan( yq[ r * i + ell ] ); + } + } + CPPAD_ASSERT_KNOWN(ok, + "yq = f.Forward(q, r, xq): has a non-zero order Taylor coefficient\n" + "with the value nan (but zero order coefficients are not nan)." + ); + } +# endif + + // now we have q + 1 taylor_ coefficient orders per variable + num_order_taylor_ = q + 1; + + return yq; +} + + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/fun_check.hpp cppad-2019.02.00.0/include/cppad/core/fun_check.hpp --- cppad-2018.00.00.0/include/cppad/core/fun_check.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/fun_check.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,210 @@ +# ifndef CPPAD_CORE_FUN_CHECK_HPP +# define CPPAD_CORE_FUN_CHECK_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin FunCheck$$ +$spell + exp + bool + const + Taylor +$$ + + +$section Check an ADFun Sequence of Operations$$ + +$head Syntax$$ +$icode%ok% = FunCheck(%f%, %g%, %x%, %r%, %a%)%$$ +$pre +$$ +$bold See Also$$ +$cref CompareChange$$ + + +$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$$. +We use $latex G : \B{R}^n \rightarrow \B{R}^m$$ to denote the +function corresponding to the C++ function object $icode g$$. +This routine check if +$latex \[ + F(x) = G(x) +\]$$ +If $latex F(x) \neq G(x)$$, the +$cref/operation sequence/glossary/Operation/Sequence/$$ +corresponding to $icode f$$ does not represents the algorithm used +by $icode g$$ to calculate values for $latex G$$ +(see $cref/Discussion/FunCheck/Discussion/$$ below). + +$head f$$ +The $code FunCheck$$ argument $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the $cref ADFun$$ object $icode f$$ is not $code const$$ +(see $cref/Forward/FunCheck/FunCheck Uses Forward/$$ below). + +$head g$$ +The $code FunCheck$$ argument $icode g$$ has prototype +$codei% + %Fun% &%g% +%$$ +($icode Fun$$ is defined the properties of $icode g$$). +The C++ function object $icode g$$ supports the syntax +$codei% + %y% = %g%(%x%) +%$$ +which computes $latex y = G(x)$$. + +$subhead x$$ +The $icode g$$ argument $icode x$$ has prototype +$codei% + const %Vector% &%x% +%$$ +(see $cref/Vector/FunCheck/Vector/$$ below) +and its size +must be equal to $icode n$$, the dimension of the +$cref/domain/seq_property/Domain/$$ space for $icode f$$. + +$head y$$ +The $icode g$$ result $icode y$$ has prototype +$codei% + %Vector% %y% +%$$ +and its value is $latex G(x)$$. +The size of $icode y$$ +is equal to $icode m$$, the dimension of the +$cref/range/seq_property/Range/$$ space for $icode f$$. + +$head x$$ +The $code FunCheck$$ argument $icode x$$ has prototype +$codei% + const %Vector% &%x% +%$$ +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$$. + +$head r$$ +The $code FunCheck$$ argument $icode r$$ has prototype +$codei% + const %Base% &%r% +%$$ +It specifies the relative error the element by element +comparison of the value of $latex F(x)$$ and $latex G(x)$$. + +$head a$$ +The $code FunCheck$$ argument $icode a$$ has prototype +$codei% + const %Base% &%a% +%$$ +It specifies the absolute error the element by element +comparison of the value of $latex F(x)$$ and $latex G(x)$$. + +$head ok$$ +The $code FunCheck$$ result $icode ok$$ has prototype +$codei% + bool %ok% +%$$ +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) | ) +\] $$ +or the absolute error bound is satisfied +$latex \[ + | F_i (x) - G_i (x) | \leq a +\] $$ +It is false if for some $latex (i, j)$$ neither +of these bounds is satisfied. + +$head Vector$$ +The type $icode Vector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$icode Base$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head FunCheck Uses Forward$$ +After each call to $cref Forward$$, +the object $icode f$$ contains the corresponding +$cref/Taylor coefficients/glossary/Taylor Coefficient/$$. +After $code FunCheck$$, +the previous calls to $cref Forward$$ are undefined. + +$head Discussion$$ +Suppose that the algorithm corresponding to $icode g$$ contains +$codei% + if( %x% >= 0 ) + %y% = exp(%x%) + else + %y% = exp(-%x%) +%$$ +where $icode x$$ and $icode y$$ are $codei%AD%$$ objects. +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$$, +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 +(and hence the object $icode f$$ does not represent the function +$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$$ +(so AD operation sequence properly represents the algorithm +for this value of independent variables). + + +$head Example$$ +$children% + example/general/fun_check.cpp +%$$ +The file +$cref fun_check.cpp$$ +contains an example and test of this function. + +$end +--------------------------------------------------------------------------- +*/ + +namespace CppAD { + template + bool FunCheck( + 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 yg = g(x); + + size_t i; + for(i = 0; i < m; i++) + ok &= NearEqual(yf[i], yg[i], r, a); + return ok; + } +} + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/fun_construct.hpp cppad-2019.02.00.0/include/cppad/core/fun_construct.hpp --- cppad-2018.00.00.0/include/cppad/core/fun_construct.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/fun_construct.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,539 @@ +# ifndef CPPAD_CORE_FUN_CONSTRUCT_HPP +# define CPPAD_CORE_FUN_CONSTRUCT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin FunConstruct$$ +$spell + alloc + num + Jac + bool + taylor + var + ADvector + const + Jacobian +$$ + +$spell +$$ + +$section Construct an ADFun Object and Stop Recording$$ + + +$head Syntax$$ +$codei%ADFun<%Base%> %f%(%x%, %y%); +%$$ +$codei%ADFun<%Base%> %g% +%$$ +$icode%g% = %f%$$ + + +$head Purpose$$ +The $codei%ADFun<%Base%>%$$ object $icode f$$ +stores an AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$. +It can then be used to calculate derivatives of the corresponding +$cref/AD function/glossary/AD Function/$$ +$latex \[ + F : \B{R}^n \rightarrow \B{R}^m +\] $$ +where $latex B$$ is the space corresponding to objects of type $icode Base$$. + +$head x$$ +If the argument $icode x$$ is present, it has prototype +$codei% + const %ADVector% &%x% +%$$ +It must be the vector argument in the previous call to +$cref Independent$$. +Neither its size, or any of its values, are allowed to change +between calling +$codei% + Independent(%x%) +%$$ +and +$codei% + ADFun<%Base%> %f%(%x%, %y%) +%$$ + +$head y$$ +If the argument $icode y$$ is present, it has prototype +$codei% + const %ADVector% &%y% +%$$ +The sequence of operations that map $icode x$$ +to $icode y$$ are stored in the ADFun object $icode f$$. + +$head ADVector$$ +The type $icode ADVector$$ must be a $cref SimpleVector$$ class with +$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$$ +The default constructor +$codei% + ADFun<%Base%> %g% +%$$ +creates an +$codei%AD<%Base%>%$$ object with no corresponding operation sequence; i.e., +$codei% + %g%.size_var() +%$$ +returns the value zero (see $cref/size_var/seq_property/size_var/$$). + +$head Sequence Constructor$$ +The sequence constructor +$codei% + ADFun<%Base%> %f%(%x%, %y%) +%$$ +creates the $codei%AD<%Base%>%$$ object $icode f$$, +stops the recording of AD of $icode Base$$ operations +corresponding to the call +$codei% + Independent(%x%) +%$$ +and stores the corresponding operation sequence in the object $icode f$$. +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: + +$list number$$ +Create $icode f$$ with the default constructor +$codei% + ADFun<%Base%> %f%; +%$$ +$lnext +Stop the tape and storing the operation sequence using +$codei% + %f%.Dependent(%x%, %y%); +%$$ +(see $cref Dependent$$). +$lnext +Calculate the zero order Taylor coefficients for all +the variables in the operation sequence using +$codei% + %f%.Forward(%p%, %x_p%) +%$$ +with $icode p$$ equal to zero and the elements of $icode x_p$$ +equal to the corresponding elements of $icode x$$ +(see $cref Forward$$). +$lend + +$head Copy Constructor$$ +It is an error to attempt to use the $codei%ADFun<%Base%>%$$ copy constructor; +i.e., the following syntax is not allowed: +$codei% + ADFun<%Base%> %g%(%f%) +%$$ +where $icode f$$ is an $codei%ADFun<%Base%>%$$ object. +Use its $cref/default constructor/FunConstruct/Default Constructor/$$ instead +and its assignment operator. + +$head Assignment Operator$$ +The $codei%ADFun<%Base%>%$$ assignment operation +$codei% + %g% = %f% +%$$ +makes a copy of the operation sequence currently stored in $icode f$$ +in the object $icode g$$. +The object $icode f$$ is not affected by this operation and +can be $code const$$. +All of information (state) stored in $icode f$$ is copied to $icode g$$ +and any information originally in $icode g$$ is lost. + +$subhead Move Semantics$$ +In the special case where $icode f$$ is a temporary object +(and enough C++11 features are supported by the compiler) +this assignment will use move semantics. +This avoids the overhead of the copying all the information from +$icode f$$ to $icode g$$. + +$subhead Taylor Coefficients$$ +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% + %g%.size_order() == %f%.size_order() +%$$ + +$subhead Sparsity Patterns$$ +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% + %g%.size_forward_bool() == %f%.size_forward_bool() + %g%.size_forward_set() == %f%.size_forward_set() +%$$ + +$head Parallel Mode$$ +The call to $code Independent$$, +and the corresponding call to +$codei% + ADFun<%Base%> %f%( %x%, %y%) +%$$ +or +$codei% + %f%.Dependent( %x%, %y%) +%$$ +or $cref abort_recording$$, +must be preformed by the same thread; i.e., +$cref/thread_alloc::thread_num/ta_thread_num/$$ must be the same. + +$head Example$$ + +$subhead Sequence Constructor$$ +The file +$cref independent.cpp$$ +contains an example and test of the sequence constructor. + +$subhead Default Constructor$$ +The files +$cref fun_check.cpp$$ +and +$cref hes_lagrangian.cpp$$ +contain an examples and tests using the default constructor. +They return true if they succeed and false otherwise. + +$children% + example/general/fun_assign.cpp +%$$ +$subhead Assignment Operator$$ +The file +$cref fun_assign.cpp$$ +contains an example and test of the $codei%ADFun<%Base%>%$$ +assignment operator. + +$end +---------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file fun_construct.hpp +ADFun function constructors and assignment operator. +*/ + +/*! +ADFun default constructor + +The C++ syntax for this operation is +\verbatim + ADFun f +\endverbatim +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. + +\tparam Base +is the base for the recording that can be stored in this ADFun object; +i.e., operation sequences that were recorded using the type AD. +*/ +template +ADFun::ADFun(void) : +base2ad_return_value_(false), +has_been_optimized_(false), +check_for_nan_(true) , +compare_change_count_(0), +compare_change_number_(0), +compare_change_op_index_(0), +num_order_taylor_(0), +cap_order_taylor_(0), +num_direction_taylor_(0), +num_var_tape_(0) +{ } + +/*! +ADFun copy constructor + +This is only alowed for a base2ad return value and is required +by some compilers to support the following syntax: +\verbatim + ADFun< AD, Base > af; + af = f.base2ad(); +\endverbatim + +*/ +template +ADFun::ADFun(const ADFun& g) +{ if( g.base2ad_return_value_ ) + *this = g; + else + { CppAD::ErrorHandler::Call( + true, + __LINE__, + __FILE__, + "ADFun(const ADFun& g)", + "Attempting to use the ADFun copy constructor.\n" + "Perhaps you are passing an ADFun object " + "by value instead of by reference." + ); + } +} +/*! +ADFun assignment operator + +The C++ syntax for this operation is +\verbatim + g = f +\endverbatim +where g and f are ADFun ADFun objects. +A copy of the the operation sequence currently stored in f +is placed in this ADFun object (called g above). +Any information currently stored in this ADFun object is lost. + +\tparam Base +is the base for the recording that can be stored in this ADFun object; +i.e., operation sequences that were recorded using the type AD. + +\param f +ADFun object containing the operation sequence to be copied. +*/ +template +void ADFun::operator=(const ADFun& f) +{ + // go through member variables in ad_fun.hpp order + // + // bool objects + base2ad_return_value_ = false; + has_been_optimized_ = f.has_been_optimized_; + check_for_nan_ = f.check_for_nan_; + // + // size_t objects + 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_; + num_var_tape_ = f.num_var_tape_; + // + // pod_vector objects + ind_taddr_ = f.ind_taddr_; + dep_taddr_ = f.dep_taddr_; + dep_parameter_ = f.dep_parameter_; + cskip_op_ = f.cskip_op_; + load_op_ = f.load_op_; + // + // pod_vector_maybe_vectors + taylor_ = f.taylor_; + subgraph_partial_ = f.subgraph_partial_; + // + // player + play_ = f.play_; + // + // subgraph + subgraph_info_ = f.subgraph_info_; + // + // sparse_pack + for_jac_sparse_pack_ = f.for_jac_sparse_pack_; + // + // sparse_list + for_jac_sparse_set_ = f.for_jac_sparse_set_; +} +# if CPPAD_USE_CPLUSPLUS_2011 +/// Move semantics version of assignment operator +template +void ADFun::operator=(ADFun&& f) +{ + // bool objects + base2ad_return_value_ = false; // f might be, but this is not + has_been_optimized_ = f.has_been_optimized_; + check_for_nan_ = f.check_for_nan_; + // + // size_t objects + 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_; + num_var_tape_ = f.num_var_tape_; + // + // pod_vector objects + ind_taddr_.swap( f.ind_taddr_); + dep_taddr_.swap( f.dep_taddr_); + dep_parameter_.swap( f.dep_parameter_); + taylor_.swap( f.taylor_); + cskip_op_.swap( f.cskip_op_); + load_op_.swap( f.load_op_); + // + // player + play_.swap(f.play_); + // + // subgraph_info + subgraph_info_.swap(f.subgraph_info_); + // + // sparse_pack + for_jac_sparse_pack_.swap( f.for_jac_sparse_pack_); + // + // sparse_list + for_jac_sparse_set_.swap( f.for_jac_sparse_set_); +} +# endif + +/*! +ADFun constructor from an operation sequence. + +The C++ syntax for this operation is +\verbatim + ADFun f(x, y) +\endverbatim +The operation sequence that started with the previous call + Independent(x), and that ends with this operation, is stored +in this ADFun object f. + +\tparam Base +is the base for the recording that will be stored in the object f; +i.e., the operations were recorded using the type AD. + +\tparam ADVector +is a simple vector class with elements of typea AD. + +\param x +is the independent variable vector for this ADFun object. +The domain dimension of this object will be the size of x. + +\param y +is the dependent variable vector for this ADFun object. +The range dimension of this object will be the size of y. + +\par Taylor Coefficients +A zero order forward mode sweep is done, +and if NDEBUG is not defined the resulting values for the +depenedent variables are checked against the values in y. +Thus, the zero order Taylor coefficients +corresponding to the value of the x vector +are stored in this ADFun object. +*/ +template +template +ADFun::ADFun(const ADVector &x, const ADVector &y) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + + CPPAD_ASSERT_KNOWN( + x.size() > 0, + "ADFun: independent variable vector has size zero." + ); + CPPAD_ASSERT_KNOWN( + Variable(x[0]), + "ADFun: independent variable vector has been changed." + ); + local::ADTape* tape = AD::tape_ptr(x[0].tape_id_); + CPPAD_ASSERT_KNOWN( + tape->size_independent_ == size_t ( x.size() ), + "ADFun: independent variable vector has been changed." + ); + size_t j, n = x.size(); +# ifndef NDEBUG + size_t i, m = y.size(); + for(j = 0; j < n; j++) + { CPPAD_ASSERT_KNOWN( + size_t(x[j].taddr_) == (j+1), + "ADFun: independent variable vector has been changed." + ); + CPPAD_ASSERT_KNOWN( + x[j].tape_id_ == x[0].tape_id_, + "ADFun: independent variable vector has been changed." + ); + } + for(i = 0; i < m; i++) + { CPPAD_ASSERT_KNOWN( + CppAD::Parameter( y[i] ) | (y[i].tape_id_ == x[0].tape_id_) , + "ADFun: dependent vector contains variables for" + "\na different tape than the independent variables." + ); + } +# endif + + // stop the tape and store the operation sequence + Dependent(tape, y); + + + // ad_fun.hpp member values not set by dependent + check_for_nan_ = true; + + // allocate memory for one zero order taylor_ coefficient + CPPAD_ASSERT_UNKNOWN( num_order_taylor_ == 0 ); + CPPAD_ASSERT_UNKNOWN( num_direction_taylor_ == 0 ); + size_t c = 1; + size_t r = 1; + capacity_order(c, r); + CPPAD_ASSERT_UNKNOWN( cap_order_taylor_ == c ); + CPPAD_ASSERT_UNKNOWN( num_direction_taylor_ == r ); + + // set zero order coefficients corresponding to indpendent variables + CPPAD_ASSERT_UNKNOWN( n == ind_taddr_.size() ); + for(j = 0; j < n; j++) + { CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] == (j+1) ); + CPPAD_ASSERT_UNKNOWN( size_t(x[j].taddr_) == (j+1) ); + taylor_[ ind_taddr_[j] ] = x[j].value_; + } + + // 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() ); + local::sweep::forward0(&play_, std::cout, false, + n, num_var_tape_, cap_order_taylor_, taylor_.data(), + cskip_op_.data(), load_op_, + compare_change_count_, + compare_change_number_, + compare_change_op_index_, + not_used_rec_base + ); + 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++) + 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 = " + << y[i].value_ << endl + << "Tape evaluation value = " + << taylor_[dep_taddr_[i]] << endl + << "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, + msg_char_star + ); + } +# endif +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/fun_eval.hpp cppad-2019.02.00.0/include/cppad/core/fun_eval.hpp --- cppad-2018.00.00.0/include/cppad/core/fun_eval.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/fun_eval.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,20 @@ +# ifndef CPPAD_CORE_FUN_EVAL_HPP +# define CPPAD_CORE_FUN_EVAL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/hash_code.hpp cppad-2019.02.00.0/include/cppad/core/hash_code.hpp --- cppad-2018.00.00.0/include/cppad/core/hash_code.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/hash_code.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,70 @@ +# ifndef CPPAD_CORE_HASH_CODE_HPP +# define CPPAD_CORE_HASH_CODE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file core/hash_code.hpp +CppAD hashing utility. +*/ +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +General purpose hash code for an arbitrary value. + +\tparam Value +is the type of the argument being hash coded. +It should be a plain old data class; i.e., +the values included in the equality operator in the object and +not pointed to by the object. + +\param value +the value that we are generating a hash code for. +All of the fields in value should have been set before the hash code +is computed (otherwise undefined values are used). + +\return +is a hash code that is between zero and CPPAD_HASH_TABLE_SIZE - 1. + +\par Checked Assertions +\li std::numeric_limits::max() >= CPPAD_HASH_TABLE_SIZE +\li sizeof(value) is even +\li sizeof(unsigned short) == 2 +*/ +template +unsigned short hash_code(const Value& value) +{ return local::local_hash_code(value); } + +/*! +hash code for an AD object. + +\tparam Base +is the base type for this AD value. + +\param u +the AD value that we are generating a hash code for. + +\return +is a hash code that is between zero and CPPAD_HASH_TABLE_SIZE - 1. +*/ +template +unsigned short hash_code(const AD& u) +{ size_t code = hash_code(u.value_); + code += size_t(u.taddr_); + code += size_t(u.ad_type_ == dynamic_enum); + return (unsigned short)(code % CPPAD_HASH_TABLE_SIZE); +} + +} // END_CPPAD_NAMESPACE + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/hessian.hpp cppad-2019.02.00.0/include/cppad/core/hessian.hpp --- cppad-2018.00.00.0/include/cppad/core/hessian.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/hessian.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,213 @@ +# ifndef CPPAD_CORE_HESSIAN_HPP +# define CPPAD_CORE_HESSIAN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin Hessian$$ +$spell + hes + typename + Taylor + HesLuDet + const +$$ + + +$section Hessian: Easy Driver$$ + +$head Syntax$$ +$icode%hes% = %f%.Hessian(%x%, %w%) +%$$ +$icode%hes% = %f%.Hessian(%x%, %l%) +%$$ + + +$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$$. +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) +\] $$ +The routine $cref sparse_hessian$$ may be faster in the case +where the Hessian is sparse. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the $cref ADFun$$ object $icode f$$ is not $code const$$ +(see $cref/Hessian Uses Forward/Hessian/Hessian Uses Forward/$$ below). + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %Vector% &%x% +%$$ +(see $cref/Vector/Hessian/Vector/$$ below) +and its size +must be equal to $icode n$$, the dimension of the +$cref/domain/seq_property/Domain/$$ space for $icode f$$. +It specifies +that point at which to evaluate the Hessian. + +$head l$$ +If the argument $icode l$$ is present, it has prototype +$codei% + size_t %l% +%$$ +and is less than $icode m$$, the dimension of the +$cref/range/seq_property/Range/$$ space for $icode f$$. +It specifies the component of $icode F$$ +for which we are evaluating the Hessian. +To be specific, in the case where the argument $icode l$$ is present, +$latex \[ + w_i = \left\{ \begin{array}{ll} + 1 & i = l \\ + 0 & {\rm otherwise} + \end{array} \right. +\] $$ + +$head w$$ +If the argument $icode w$$ is present, it has prototype +$codei% + const %Vector% &%w% +%$$ +and size $latex m$$. +It specifies the value of $latex w_i$$ in the expression +for $icode h$$. + +$head hes$$ +The result $icode hes$$ has prototype +$codei% + %Vector% %hes% +%$$ +(see $cref/Vector/Hessian/Vector/$$ below) +and its size is $latex n * n$$. +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 ) +\] $$ + +$head Vector$$ +The type $icode Vector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$icode Base$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head Hessian Uses Forward$$ +After each call to $cref Forward$$, +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 +$icode%f%.Forward(0, %x%)%$$ +and the other coefficients are unspecified. + +$head Example$$ +$children% + example/general/hessian.cpp% + example/general/hes_lagrangian.cpp +%$$ +The routines +$cref hessian.cpp$$ and +$cref hes_lagrangian.cpp$$ +are examples and tests of $code Hessian$$. +They return $code true$$, if they succeed and $code false$$ otherwise. + + +$end +----------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +template +template +Vector ADFun::Hessian(const Vector &x, size_t l) +{ size_t i, m = Range(); + CPPAD_ASSERT_KNOWN( + l < m, + "Hessian: index i is not less than range dimension for f" + ); + + Vector w(m); + for(i = 0; i < m; i++) + w[i] = Base(0.0); + w[l] = Base(1.0); + + return Hessian(x, w); +} + + +template +template +Vector ADFun::Hessian(const Vector &x, const Vector &w) +{ size_t j; + size_t k; + + size_t n = Domain(); + + // check Vector is Simple Vector class with Base type elements + CheckSimpleVector(); + + 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" + ); + + // point at which we are evaluating the Hessian + Forward(0, x); + + // define the return value + Vector hes(n * n); + + // direction vector for calls to forward + Vector u(n); + for(j = 0; j < n; j++) + u[j] = Base(0.0); + + + // location for return values from Reverse + Vector ddw(n * 2); + + // loop over forward directions + for(j = 0; j < n; j++) + { // evaluate partials of entire function w.r.t. j-th coordinate + u[j] = Base(1.0); + Forward(1, u); + u[j] = Base(0.0); + + // evaluate derivative of partial corresponding to F_i + ddw = Reverse(2, w); + + // return desired components + for(k = 0; k < n; k++) + hes[k * n + j] = ddw[k * 2 + 1]; + } + + return hes; +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/identical.hpp cppad-2019.02.00.0/include/cppad/core/identical.hpp --- cppad-2018.00.00.0/include/cppad/core/identical.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/identical.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,100 @@ +# ifndef CPPAD_CORE_IDENTICAL_HPP +# define CPPAD_CORE_IDENTICAL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file identical.hpp +Check if certain properties is true for any possible AD tape play back. +*/ + +// --------------------------------------------------------------------------- +/*! +Determine if an AD object is a parameter, and could never have +a different value during any tape playback. + +An AD object x is identically a parameter if and only if +all of the objects in the following chain are parameters: +\code + x , x.value , x.value.value , ... +\endcode +In such a case, the value of the object will always be the same +no matter what the independent variable values are at any level. + +\param x +values that we are checking for identically a pamameter. + +\return +returns true iff x is identically a parameter. +*/ +template +bool IdenticalCon(const AD &x) +{ return Constant(x) & IdenticalCon(x.value_); } +// Zero ============================================================== +/*! +Determine if an AD is equal to zero, +and must be equal zero during any tape playback. + +\param x +object that we are checking. + +\return +returns true if and only if + x is equals zero and is identically a parameter \ref CppAD::IdenticalCon. +*/ +template +bool IdenticalZero(const AD &x) +{ return Constant(x) & IdenticalZero(x.value_); } +// One ============================================================== +/*! +Determine if an AD is equal to one, +and must be equal one during any tape playback. + +\param x +object that we are checking. + +\return +returns true if and only if + x is equals one and is identically a parameter \ref CppAD::IdenticalCon. +*/ +template +bool IdenticalOne(const AD &x) +{ return Constant(x) & IdenticalOne(x.value_); } +// Equal =================================================================== +/*! +Determine if two AD objects are equal, +and must be equal during any tape playback. + +\param x +first of two objects we are checking for equal. + +\param y +second of two objects we are checking for equal. + +\return +returns true if and only if +the arguments are equal and both identically parameters \ref CppAD::IdenticalCon. +*/ +template +bool IdenticalEqualCon +(const AD &x, const AD &y) +{ bool constant; + constant = Constant(x) & Constant(y); + return constant & IdenticalEqualCon(x.value_, y.value_); +} +// ========================================================================== + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/independent.hpp cppad-2019.02.00.0/include/cppad/core/independent.hpp --- cppad-2018.00.00.0/include/cppad/core/independent.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/independent.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,269 @@ +# ifndef CPPAD_CORE_INDEPENDENT_HPP +# define CPPAD_CORE_INDEPENDENT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +--------------------------------------------------------------------------- + +$begin Independent$$ +$spell + op + alloc + num + Cpp + bool + const + var + typename +$$ + +$section Declare Independent Variables and Start Recording$$ + +$head Syntax$$ +$codei%Independent(%x%) +%$$ +$codei%Independent(%x%, %abort_op_index%) +%$$ +$codei%Independent(%x%, %abort_op_index%, %record_compare%) +%$$ +$codei%Independent(%x%, %abort_op_index%, %record_compare%, %dynamic%) +%$$ + +$head Start Recording$$ +The syntax above starts recording +$cref/AD of Base/glossary/AD of Base/$$ operations +with $icode x$$ as the independent variable vector. +Once the +$cref/operation sequence/glossary/Operation/Sequence/$$ is completed, +it must be transferred to a function object or aborted; see below. + +$head Stop Recording$$ +The recording is stopped, +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%) +%$$ +or the $cref/dependent variable specifier/Dependent/$$ +$codei% + %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$$, +and the values that depend on the elements of $icode x$$, +as $codei%AD<%Base%>%$$ variables. + +$head x$$ +The vector $icode x$$ has prototype +$codei% + %ADVector% &%x% +%$$ +(see $icode ADVector$$ below). +The size of the vector $icode x$$, must be greater than zero, +and is the number of independent variables for this +AD operation sequence. + +$head abort_op_index$$ +If this argument is present, +it specifies the operator index at which the execution will 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/$$ for $icode op_index$$ +and $cref/NDEBUG/Faq/Speed/NDEBUG/$$. +No abort will occur if $icode abort_op_index$$ is zero. +If this argument is not present, the default value zero is used +for $icode abort_index$$. + +$head record_compare$$ +This argument has prototype +$codei% + bool %record_compare% +%$$ +If it is present, +it specifies if AD $cref compare$$ operations are recorded. +It takes extra time and memory to record these operations. +On the other hand, they can be useful for detecting when and why +a functions recording would change; see $icode abort_op_index$$ above and +$cref compare_change$$. +If this argument is not present, the default value $code true$$ is used +for $icode record_compare$$. +If this argument is false, $icode abort_op_index$$ must be zero. + +$head dynamic$$ +If this argument is present, it has prototype +$codei% + const %ADVector%& %dynamic% +%$$ +(see $icode Vector$$ below). +It specifies the independent +$cref/dynamic/glossary/Parameter/Dynamic/$$ parameters. +The value of these parameters, +in the $cref ADFun$$ object $icode f$$, +that can be changed using $cref new_dynamic$$. + +$subhead Efficiency$$ +Any operations that use dynamic parameters will be recorded. +We use other dynamic parameters to denote parameters that depend on +the independent dynamic parameters $icode dynamic$$, +and do not depend on $icode x$$. +It is more efficient to compute other dynamic parameters before calling +$code Independent$$ and include them in the +independent dynamic parameter vector $icode dynamic$$. + +$head ADVector$$ +The type $icode ADVector$$ must be a $cref SimpleVector$$ class with +$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 Parallel Mode$$ +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 +$codei% + %f%.Dependent( %x%, %y%) +%$$ +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$$ +$children% + example/general/independent.cpp +%$$ +The file +$cref independent.cpp$$ +contains an example and test of this operation. + +$end +----------------------------------------------------------------------------- +*/ +# include +/*! +\file core/independent.hpp +Declare the independent variables +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +Declaration of independent variables. + +\tparam ADVector +This is simple vector type with elements of type AD. + +\param x +Vector of the independent variablers. + +\param abort_op_index +operator index at which execution will be aborted (during the recording +of operations). The value zero corresponds to not aborting (will not match). + +\param record_compare +should comparison operators be recorded. + +\param dynamic +is the dynamic parameter vector. +*/ +template +void Independent( + ADVector& x , + size_t abort_op_index , + bool record_compare , + ADVector& dynamic ) +{ CPPAD_ASSERT_KNOWN( + abort_op_index == 0 || record_compare, + "Independent: abort_op_index is non-zero and record_compare is false." + ); + typedef typename ADVector::value_type ADBase; + typedef typename ADBase::value_type Base; + CPPAD_ASSERT_KNOWN( + ADBase::tape_ptr() == CPPAD_NULL, + "Independent: cannot create a new tape because\n" + "a previous tape is still active (for this thread).\n" + "AD::abort_recording() would abort this previous recording." + ); + local::ADTape* tape = ADBase::tape_manage(new_tape_manage); + tape->Independent(x, abort_op_index, record_compare, dynamic); +} +// --------------------------------------------------------------------------- +/*! +Declare independent variables using default for dynamic. + +\tparam ADVector +This is simple vector type with elements of type AD. + +\param x +Vector of the independent variablers. + +\param abort_op_index +operator index at which execution will be aborted (during the recording +of operations). The value zero corresponds to not aborting (will not match). + +\param record_compare +should comparison operators be recorded. +*/ +template +void Independent(ADVector &x, size_t abort_op_index, bool record_compare) +{ ADVector dynamic(0); // empty vector + Independent(x, abort_op_index, record_compare, dynamic); +} +// --------------------------------------------------------------------------- +/*! +Declare independent variables using default for record_compare and dynamic. + +\tparam ADVector +This is simple vector type with elements of type AD. + +\param x +Vector of the independent variablers. + +\param abort_op_index +operator index at which execution will be aborted (during the recording +of operations). The value zero corresponds to not aborting (will not match). +*/ +template +void Independent(ADVector &x, size_t abort_op_index) +{ bool record_compare = true; + ADVector dynamic(0); // empty vector + Independent(x, abort_op_index, record_compare, dynamic); +} +// --------------------------------------------------------------------------- +/*! +Declare independent variables using default for +record_compare, abort_op_index, and dynamic. + +\tparam ADVector +This is simple vector type with elements of type AD. + +\param x +Vector of the independent variablers. +*/ +template +void Independent(ADVector &x) +{ size_t abort_op_index = 0; + bool record_compare = true; + ADVector dynamic(0); // empty vector + Independent(x, abort_op_index, record_compare, dynamic); +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/integer.hpp cppad-2019.02.00.0/include/cppad/core/integer.hpp --- cppad-2018.00.00.0/include/cppad/core/integer.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/integer.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,111 @@ +# ifndef CPPAD_CORE_INTEGER_HPP +# define CPPAD_CORE_INTEGER_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------ +$begin Integer$$ +$spell + std + VecAD + CppAD + namespace + const + bool +$$ + + + +$section Convert From AD to Integer$$ + +$head Syntax$$ +$icode%i% = Integer(%x%)%$$ + + +$head Purpose$$ +Converts from an AD type to the corresponding integer value. + +$head i$$ +The result $icode i$$ has prototype +$codei% + int %i% +%$$ + +$head x$$ + +$subhead Real Types$$ +If the argument $icode x$$ has either of the following prototypes: +$codei% + const float %% &%x% + const double %% &%x% +%$$ +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 +greatest integer less than or equal $icode x$$. +If $latex x \leq 0$$, $icode i$$ is the +smallest integer greater than or equal $icode x$$. + +$subhead Complex Types$$ +If the argument $icode x$$ has either of the following prototypes: +$codei% + const std::complex %% &%x% + const std::complex %% &%x% +%$$ +The result $icode i$$ is given by +$codei% + %i% = Integer(%x%.real()) +%$$ + +$subhead AD Types$$ +If the argument $icode x$$ has either of the following prototypes: +$codei% + const AD<%Base%> &%x% + const VecAD<%Base%>::reference &%x% +%$$ +$icode Base$$ must support the $code Integer$$ function and +the conversion has the same meaning as for $icode Base$$. + +$head Operation Sequence$$ +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 Example$$ +$children% + example/general/integer.cpp +%$$ +The file +$cref integer.cpp$$ +contains an example and test of this operation. + +$end +------------------------------------------------------------------------------ +*/ + + +namespace CppAD { + + template + CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION + int Integer(const AD &x) + { return Integer(x.value_); } + + template + CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION + int Integer(const VecAD_reference &x) + { return Integer( x.ADBase() ); } +} +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/jacobian.hpp cppad-2019.02.00.0/include/cppad/core/jacobian.hpp --- cppad-2018.00.00.0/include/cppad/core/jacobian.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/jacobian.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,237 @@ +# ifndef CPPAD_CORE_JACOBIAN_HPP +# define CPPAD_CORE_JACOBIAN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin Jacobian$$ +$spell + jac + typename + Taylor + Jacobian + DetLu + const +$$ + + +$section Jacobian: Driver Routine$$ + +$head Syntax$$ +$icode%jac% = %f%.Jacobian(%x%)%$$ + + +$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$$. +The syntax above sets $icode jac$$ to the +Jacobian of $icode F$$ evaluated at $icode x$$; i.e., +$latex \[ + jac = F^{(1)} (x) +\] $$ + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the $cref ADFun$$ object $icode f$$ is not $code const$$ +(see $cref/Forward or Reverse/Jacobian/Forward or Reverse/$$ below). + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %Vector% &%x% +%$$ +(see $cref/Vector/Jacobian/Vector/$$ below) +and its size +must be equal to $icode n$$, the dimension of the +$cref/domain/seq_property/Domain/$$ space for $icode f$$. +It specifies +that point at which to evaluate the Jacobian. + +$head jac$$ +The result $icode jac$$ has prototype +$codei% + %Vector% %jac% +%$$ +(see $cref/Vector/Jacobian/Vector/$$ below) +and its size is $latex m * n$$; i.e., the product of the +$cref/domain/seq_property/Domain/$$ +and +$cref/range/seq_property/Range/$$ +dimensions for $icode f$$. +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 ) +\] $$ + + +$head Vector$$ +The type $icode Vector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$icode Base$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head Forward or Reverse$$ +This will use order zero Forward mode and either +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 +$cref/Taylor coefficients/glossary/Taylor Coefficient/$$. +After a call to $code Jacobian$$, +the zero order Taylor coefficients correspond to +$icode%f%.Forward(0, %x%)%$$ +and the other coefficients are unspecified. + +$head Example$$ +$children% + example/general/jacobian.cpp +%$$ +The routine +$cref/Jacobian/jacobian.cpp/$$ is both an example and test. +It returns $code true$$, if it succeeds and $code false$$ otherwise. + +$end +----------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +template +void JacobianFor(ADFun &f, const Vector &x, Vector &jac) +{ size_t i; + size_t j; + + size_t n = f.Domain(); + size_t m = f.Range(); + + // check Vector is Simple Vector class with Base type elements + CheckSimpleVector(); + + CPPAD_ASSERT_UNKNOWN( size_t(x.size()) == f.Domain() ); + CPPAD_ASSERT_UNKNOWN( size_t(jac.size()) == f.Range() * f.Domain() ); + + // argument and result for forward mode calculations + Vector u(n); + Vector v(m); + + // initialize all the components + for(j = 0; j < n; j++) + u[j] = Base(0.0); + + // loop through the different coordinate directions + for(j = 0; j < n; j++) + { // set u to the j-th coordinate direction + u[j] = Base(1.0); + + // compute the partial of f w.r.t. this coordinate direction + v = f.Forward(1, u); + + // reset u to vector of all zeros + u[j] = Base(0.0); + + // return the result + for(i = 0; i < m; i++) + jac[ i * n + j ] = v[i]; + } +} +template +void JacobianRev(ADFun &f, const Vector &x, Vector &jac) +{ size_t i; + size_t j; + + size_t n = f.Domain(); + size_t m = f.Range(); + + CPPAD_ASSERT_UNKNOWN( size_t(x.size()) == f.Domain() ); + CPPAD_ASSERT_UNKNOWN( size_t(jac.size()) == f.Range() * f.Domain() ); + + // argument and result for reverse mode calculations + Vector u(n); + Vector v(m); + + // initialize all the components + for(i = 0; i < m; i++) + v[i] = Base(0.0); + + // loop through the different coordinate directions + for(i = 0; i < m; i++) + { if( f.Parameter(i) ) + { // return zero for this component of f + for(j = 0; j < n; j++) + jac[ i * n + j ] = Base(0.0); + } + else + { + // set v to the i-th coordinate direction + v[i] = Base(1.0); + + // compute the derivative of this component of f + u = f.Reverse(1, v); + + // reset v to vector of all zeros + v[i] = Base(0.0); + + // return the result + for(j = 0; j < n; j++) + jac[ i * n + j ] = u[j]; + } + } +} + +template +template +Vector ADFun::Jacobian(const Vector &x) +{ size_t i; + size_t n = Domain(); + size_t m = Range(); + + 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; + + // work factor for reverse mode + size_t workReverse = 0; + for(i = 0; i < m; i++) + { if( ! Parameter(i) ) + ++workReverse; + } + + // choose the method with the least work + Vector jac( n * m ); +# ifdef CPPAD_FOR_TMB + if( workForward < workReverse ) +# else + if( workForward <= workReverse ) +# endif + JacobianFor(*this, x, jac); + else + JacobianRev(*this, x, jac); + + return jac; +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/log1p.hpp cppad-2019.02.00.0/include/cppad/core/log1p.hpp --- cppad-2018.00.00.0/include/cppad/core/log1p.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/log1p.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,90 @@ +# ifndef CPPAD_CORE_LOG1P_HPP +# define CPPAD_CORE_LOG1P_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$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/general/log1p.cpp +%$$ +The file +$cref log1p.cpp$$ +contains an example and test of this function. + +$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 +AD log1p(const AD &x) +{ return log1p_template(x); } + +template +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-2018.00.00.0/include/cppad/core/lu_ratio.hpp cppad-2019.02.00.0/include/cppad/core/lu_ratio.hpp --- cppad-2018.00.00.0/include/cppad/core/lu_ratio.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/lu_ratio.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,335 @@ +# ifndef CPPAD_CORE_LU_RATIO_HPP +# define CPPAD_CORE_LU_RATIO_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin LuRatio$$ +$spell + cppad.hpp + xk + Cpp + Lu + bool + const + ip + jp + std + ADvector +$$ + + +$section LU Factorization of A Square Matrix and Stability Calculation$$ + +$head Syntax$$ +$code# include $$ +$pre +$$ +$icode%sign% = LuRatio(%ip%, %jp%, %LU%, %ratio%)%$$ + + +$head Description$$ +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 +used as part of an $cref ADFun$$ object. + +$head Include$$ +This routine is designed to be used with AD objects and +requires the $code cppad/cppad.hpp$$ file to be included. + +$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% + %ADvector% &%LU% +%$$ +and the size of $icode LU$$ must equal $latex n * n$$ +(see description of $cref/ADvector/LuRatio/ADvector/$$ 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 ratio$$ +The argument $icode ratio$$ has prototype +$codei% + AD<%Base%> &%ratio% +%$$ +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 +$latex (n-p) \times (n-p)$$ sub-matrix. +The ratio of each element of sub-matrix divided by the pivot element +is computed. +The return value of $icode ratio$$ is the maximum absolute value of +such ratios over with respect to all elements and all the pivots. + +$subhead Purpose$$ +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% + %F%.Forward(%k%, %xk%) +%$$ +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), +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 +starting with the $cref Independent$$ variable values +that correspond to the vector $icode xk$$. + +$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 ADvector$$ +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 +if this is not the case. + + +$head Example$$ +$children% + example/general/lu_ratio.cpp +%$$ +The file $cref lu_ratio.cpp$$ +contains an example and test of using $code LuRatio$$. + +$end +-------------------------------------------------------------------------- +*/ +namespace CppAD { // BEGIN CppAD namespace + +// 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; // + + // 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 = size_t(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; + // initialize the ratio // + ratio = Float(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; + } + } + } + for(i = p; i < n; i++) // + { for(j = p; j < n; j++) // + { etmp = fabs(LU[ ip[i] * n + jp[j] ] / emax); // + ratio = // + CondExpGt(etmp, ratio, etmp, ratio); // + } // + } // + CPPAD_ASSERT_KNOWN( + (imax < n) & (jmax < n) , + "AbsGeq must return true when second argument is zero" + ); + 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 + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/mul_eq.hpp cppad-2019.02.00.0/include/cppad/core/mul_eq.hpp --- cppad-2018.00.00.0/include/cppad/core/mul_eq.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/mul_eq.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,138 @@ +# ifndef CPPAD_CORE_MUL_EQ_HPP +# define CPPAD_CORE_MUL_EQ_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN CppAD namespace +namespace CppAD { + +template +AD& AD::operator *= (const AD &right) +{ + // compute the Base part + Base left; + left = value_; + value_ *= right.value_; + + // check if there is a recording in progress + local::ADTape* tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return *this; + 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 ); + + // check if left and right tapes match + bool match_left = tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "*= : AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // this = variable * variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::MulvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::MulvvOp) == 2 ); + + // put operand addresses in tape + tape->Rec_.PutArg(taddr_, right.taddr_); + // put operator in the tape + taddr_ = tape->Rec_.PutOp(local::MulvvOp); + // check that this is a variable + CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); + CPPAD_ASSERT_UNKNOWN( ad_type_ == variable_enum); + } + else if( (! dyn_right) & IdenticalOne(right.value_) ) + { // this = variable * 1 + } + else if( (! dyn_right) & IdenticalZero(right.value_) ) + { // this = variable * 0 + tape_id_ = 0; // not in current tape + } + else + { // this = variable * parameter + // = parameter * variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::MulpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::MulpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + tape->Rec_.PutArg(p, taddr_); + // put operator in the tape + taddr_ = tape->Rec_.PutOp(local::MulpvOp); + // check that this is a variable + CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); + CPPAD_ASSERT_UNKNOWN( ad_type_ == variable_enum); + } + } + else if( var_right ) + { if( (! dyn_left) & IdenticalZero(left) ) + { // this = 0 * right + } + else if( (! dyn_left) & IdenticalOne(left) ) + { // this = 1 * right + make_variable(right.tape_id_, right.taddr_); + } + else + { // this = parameter * variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::MulpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::MulpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left); + tape->Rec_.PutArg(p, right.taddr_); + + // put operator in the tape + taddr_ = tape->Rec_.PutOp(local::MulpvOp); + + // make this a variable + tape_id_ = tape_id; + ad_type_ = variable_enum; + } + } + else if( dyn_left | dyn_right ) + { addr_t arg0 = taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + // parameters with a dynamic parameter results + taddr_ = tape->Rec_.put_dyn_par( + value_, local::mul_dyn, arg0, arg1 + ); + tape_id_ = tape_id; + ad_type_ = dynamic_enum; + } + return *this; +} + +CPPAD_FOLD_ASSIGNMENT_OPERATOR(*=) + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/mul.hpp cppad-2019.02.00.0/include/cppad/core/mul.hpp --- cppad-2018.00.00.0/include/cppad/core/mul.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/mul.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,136 @@ +# ifndef CPPAD_CORE_MUL_HPP +# define CPPAD_CORE_MUL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN CppAD namespace +namespace CppAD { + +template +AD operator * (const AD &left , const AD &right) +{ + // compute the Base part + AD result; + result.value_ = left.value_ * right.value_; + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); + + // check if there is a recording in progress + local::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 ); + + // check if left and right tapes match + bool match_left = left.tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (left.ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (left.ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + left.tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "Multiply: AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // result = variable * variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::MulvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::MulvvOp) == 2 ); + + // put operand addresses in tape + tape->Rec_.PutArg(left.taddr_, right.taddr_); + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::MulvvOp); + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + else if( (! dyn_right) & IdenticalZero(right.value_) ) + { // result = variable * 0 + } + else if( (! dyn_right) & IdenticalOne(right.value_) ) + { // result = variable * 1 + result.make_variable(left.tape_id_, left.taddr_); + } + else + { // result = variable * parameter + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::MulpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::MulpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + tape->Rec_.PutArg(p, left.taddr_); + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::MulpvOp); + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + } + else if( var_right ) + { if( (! dyn_left) & IdenticalZero(left.value_) ) + { // result = 0 * variable + } + else if( (! dyn_left) & IdenticalOne(left.value_) ) + { // result = 1 * variable + result.make_variable(right.tape_id_, right.taddr_); + } + else + { // result = parameter * variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::MulpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::MulpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = left.taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left.value_); + tape->Rec_.PutArg(p, right.taddr_); + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::MulpvOp); + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + } + else if( dyn_left | dyn_right ) + { addr_t arg0 = left.taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left.value_); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + // parameters with a dynamic parameter result + result.taddr_ = tape->Rec_.put_dyn_par( + result.value_, local::mul_dyn, arg0, arg1 + ); + result.tape_id_ = tape_id; + result.ad_type_ = dynamic_enum; + } + return result; +} + +// convert other cases into the case above +CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(*) + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/near_equal_ext.hpp cppad-2019.02.00.0/include/cppad/core/near_equal_ext.hpp --- cppad-2018.00.00.0/include/cppad/core/near_equal_ext.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/near_equal_ext.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,187 @@ +# ifndef CPPAD_CORE_NEAR_EQUAL_EXT_HPP +# define CPPAD_CORE_NEAR_EQUAL_EXT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin NearEqualExt$$ +$spell + cout + endl + Microsoft + std + Cpp + namespace + const + bool +$$ + +$section Compare AD and Base Objects for Nearly Equal$$ + + +$head Syntax$$ +$icode%b% = NearEqual(%x%, %y%, %r%, %a%)%$$ + + +$head Purpose$$ +The routine $cref NearEqual$$ determines if two objects of +the same type are nearly. +This routine is extended to the case where one object can have type +$icode Type$$ while the other can have type +$codei%AD<%Type%>%$$ or +$codei%AD< std::complex<%Type%> >%$$. + +$head x$$ +The arguments $icode x$$ +has one of the following possible prototypes: +$codei% + const %Type% &%x% + const AD<%Type%> &%x% + const AD< std::complex<%Type%> > &%x% +%$$ + +$head y$$ +The arguments $icode y$$ +has one of the following possible prototypes: +$codei% + const %Type% &%y% + const AD<%Type%> &%y% + const AD< std::complex<%Type%> > &%x% +%$$ + + +$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 \[ + \frac{ | x - y | } { |x| + |y| } \leq r +\] $$ + +$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. +If $icode a$$ and $icode b$$ have type $icode Type$$, +the following operation must be defined +$table +$bold Operation$$ $cnext + $bold Description$$ $rnext +$icode%a% <= %b%$$ $cnext + less that or equal operator (returns a $code bool$$ object) +$tend + +$head Operation Sequence$$ +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 Example$$ +$children% + example/general/near_equal_ext.cpp +%$$ +The file $cref near_equal_ext.cpp$$ contains an example +and test of this extension of $cref NearEqual$$. +It return true if it succeeds and false otherwise. + +$end + +*/ +// BEGIN CppAD namespace +namespace CppAD { +// ------------------------------------------------------------------------ + +// fold into base type and then use +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool NearEqual( +const AD &x, const AD &y, const Base &r, const Base &a) +{ return NearEqual(x.value_, y.value_, r, a); +} + +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool NearEqual( +const Base &x, const AD &y, const Base &r, const Base &a) +{ return NearEqual(x, y.value_, r, a); +} + +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool NearEqual( +const AD &x, const Base &y, const Base &r, const Base &a) +{ return NearEqual(x.value_, y, r, a); +} + +// fold into AD type and then use cases above +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool NearEqual( + 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, + 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, + 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, + 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, + const Base &r, const Base &a) +{ return NearEqual(x, y.ADBase(), r, a); +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/new_dynamic.hpp cppad-2019.02.00.0/include/cppad/core/new_dynamic.hpp --- cppad-2018.00.00.0/include/cppad/core/new_dynamic.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/new_dynamic.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,139 @@ +# ifndef CPPAD_CORE_NEW_DYNAMIC_HPP +# define CPPAD_CORE_NEW_DYNAMIC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin new_dynamic$$ +$spell + const + Taylor + cpp + dyn + ind +$$ + +$section Change the Dynamic Parameters$$ + +$head Syntax$$ +$icode%f%.new_dynamic(%dynamic%)%$$ + +$head Purpose$$ +Often one is only interested in computing derivatives with respect +to a subset of arguments to a function. +In this case, it is easier to make all the arguments to the function +$cref/independent variables/glossary/Tape/Independent Variable/$$. +It is more efficient, +will use less memory and be faster, +if the only the argument were are computing derivatives with respect to +are independent variables and the other arguments are +$cref/dynamic/glossary/Parameter/Dynamic/$$ parameters. +The $code new_dynamic$$ method is used to change the value +of the dynamic parameters in $icode f$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the $cref ADFun$$ object $icode f$$ is not $code const$$. + +$head dynamic$$ +This argument has prototype +$codei% + const %BaseVector%& %dynamic% +%$$ +(see $icode BaseVector$$ below). +It specifies a new value for the independent +$cref/dynamic/glossary/Parameter/Dynamic/$$ parameters. +It size must be the same as the size of the independent +$cref/dynamic/Independent/dynamic/$$ parameter vector +in the call to $code Independent$$ that started +the recording for $icode f$$; see +$cref/size_dyn_ind/seq_property/size_dyn_ind/$$. + +$head BaseVector$$ +The type $icode BaseVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$icode Base$$. + +$head Taylor Coefficients$$ +The Taylor coefficients computed by previous calls to +$cref/f.Forward/Forward/$$ are lost after this operation; including the +order zero coefficients (because they may depend on the dynamic parameters). +In order words; +$cref/f.size_order/size_order/$$ returns zero directly after +$icode%f%.new_dynamic%$$ is called. + +$children% + example/general/new_dynamic.cpp +%$$ +$head Example$$ +The file $cref new_dynamic.cpp$$ +contains an example and test of this operation. + +$end +*/ +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file new_dynamic.hpp +User interface to ADFun dynamic_parameter member function. +*/ + +/*! +Change the dynamic parameters in this ADFun object + +\param dynamic +is the vector of new values for the dynamic parameters. +*/ +template +template +void ADFun::new_dynamic(const BaseVector& dynamic) +{ using local::pod_vector; + CPPAD_ASSERT_KNOWN( + size_t( dynamic.size() ) == play_.num_dynamic_ind() , + "f.new_dynamic: dynamic.size() different from corresponding " + "call to Independent" + ); + // check BaseVector is Simple Vector class with Base elements + CheckSimpleVector(); + + // retrieve player information about the dynamic parameters + local::pod_vector_maybe& all_par_vec( play_.all_par_vec() ); + const pod_vector& dyn_par_is ( play_.dyn_par_is() ); + const pod_vector& dyn_par_op ( play_.dyn_par_op() ); + const pod_vector& dyn_par_arg( play_.dyn_par_arg() ); + const pod_vector& dyn_ind2par_ind ( play_.dyn_ind2par_ind() ); + + // set the dependent dynamic parameters + RecBase not_used_rec_base; + local::sweep::dynamic( + all_par_vec , + dynamic , + dyn_par_is , + dyn_ind2par_ind , + dyn_par_op , + dyn_par_arg , + not_used_rec_base + ); + + // the existing Taylor coefficients are no longer valid + num_order_taylor_ = 0; + + return; +} + + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/numeric_limits.hpp cppad-2019.02.00.0/include/cppad/core/numeric_limits.hpp --- cppad-2018.00.00.0/include/cppad/core/numeric_limits.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/numeric_limits.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,215 @@ +# ifndef CPPAD_CORE_NUMERIC_LIMITS_HPP +# define CPPAD_CORE_NUMERIC_LIMITS_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------ +$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() +%$$ +$codei%numeric_limits<%Float%>::digits10%$$ + +$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$$. +(Note that $code digits10$$ is member variable and not a function.) + +$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 digits10$$ +The member variable $code digits10$$ has prototype +$codei% + static const int numeric_limits<%Float%>::digits10 +%$$ +It is the number of decimal digits that can be represented by a +$icode Float$$ value. A number with this many decimal digits can be +converted to $icode Float$$ and back to a string, +without change due to rounding or overflow. + + +$head Example$$ +$children% + example/general/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 +*/ + +/// All tthese defaults correspond to errors +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); + } + /// number of decimal digits + static const int digits10 = -1; +}; + +/// 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() ); } + /// not a number + static AD quiet_NaN(void) + { return AD( numeric_limits::quiet_NaN() ); } + /// number of decimal digits + static const int digits10 = numeric_limits::digits10; +}; + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/num_skip.hpp cppad-2019.02.00.0/include/cppad/core/num_skip.hpp --- cppad-2018.00.00.0/include/cppad/core/num_skip.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/num_skip.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,124 @@ +# ifndef CPPAD_CORE_NUM_SKIP_HPP +# define CPPAD_CORE_NUM_SKIP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin number_skip$$ +$spell + optimizer + var + taylor_ +$$ + + +$section Number of Variables that Can be Skipped$$ + +$head Syntax$$ +$icode%n% = %f%.number_skip()%$$ + +$subhead See Also$$ +$cref seq_property$$ + +$head Purpose$$ +The $cref/conditional expressions/CondExp/$$ use either the +$cref/if_true/CondExp/$$ or $cref/if_false/CondExp/$$. +Hence, 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 +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 +(given the independent variable values specified by the previous call to +$cref/f.Forward/Forward/$$ for order zero). + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ + +$children% + example/general/number_skip.cpp +%$$ +$head Example$$ +The file $cref number_skip.cpp$$ +contains an example and test of this function. + +$end +----------------------------------------------------------------------------- +*/ + +# include + +// BEGIN CppAD namespace +namespace CppAD { + +// This routine is not const because it runs through the operations sequence +// 2DO: compute this value during zero order forward operations. +template +size_t ADFun::number_skip(void) +{ // must pass through operation sequence to map operations to variables + + // information defined by atomic forward + size_t atom_index=0, atom_old=0, atom_m=0, atom_n=0; + + // number of variables skipped + size_t num_var_skip = 0; + + // start playback + local::play::const_sequential_iterator itr = play_.begin(); + local::OpCode op; + size_t i_var; + const addr_t* arg; + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN(op == local::BeginOp) + while(op != local::EndOp) + { // next op + (++itr).op_info(op, arg, i_var); + // + if( op == local::AFunOp ) + { // skip only appears at front or back AFunOp of atomic function call + bool skip_call = cskip_op_[ itr.op_index() ]; + local::play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 0 ); + size_t num_op = atom_m + atom_n + 1; + for(size_t i = 0; i < num_op; i++) + { CPPAD_ASSERT_UNKNOWN( + op != local::CSkipOp && op != local::CSumOp + ); + (++itr).op_info(op, arg, i_var); + if( skip_call ) + num_var_skip += NumRes(op); + } + CPPAD_ASSERT_UNKNOWN( op == local::AFunOp ); + } + else + { if( cskip_op_[ itr.op_index() ] ) + num_var_skip += NumRes(op); + // + if( (op == local::CSkipOp) | (op == local::CSumOp) ) + itr.correct_before_increment(); + } + } + return num_var_skip; +} + +} // END CppAD namespace + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/omp_max_thread.hpp cppad-2019.02.00.0/include/cppad/core/omp_max_thread.hpp --- cppad-2018.00.00.0/include/cppad/core/omp_max_thread.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/omp_max_thread.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,93 @@ +# ifndef CPPAD_CORE_OMP_MAX_THREAD_HPP +# define CPPAD_CORE_OMP_MAX_THREAD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin omp_max_thread$$ +$spell + alloc + num + omp + OpenMp + CppAD +$$ + +$section OpenMP Parallel Setup$$ + +$head Deprecated 2011-06-23$$ +Use $cref/thread_alloc::parallel_setup/ta_parallel_setup/$$ +to set the number of threads. + +$head Syntax$$ +$codei%AD<%Base%>::omp_max_thread(%number%) +%$$ + +$head Purpose$$ +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 +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. + +$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 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 +must be preformed by the same OpenMP thread. +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 +$cref/active/glossary/Tape/Active/$$ when this function is called. + +$end +----------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +template +void AD::omp_max_thread(size_t number) +{ +# ifdef _OPENMP + thread_alloc::parallel_setup( + number, omp_alloc::in_parallel, omp_alloc::get_thread_num + ); +# else + CPPAD_ASSERT_KNOWN( + number == 1, + "omp_max_thread: number > 1 and _OPENMP is not defined" + ); +# endif + parallel_ad(); +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/optimize.hpp cppad-2019.02.00.0/include/cppad/core/optimize.hpp --- cppad-2018.00.00.0/include/cppad/core/optimize.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/optimize.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,349 @@ +# ifndef CPPAD_CORE_OPTIMIZE_HPP +# define CPPAD_CORE_OPTIMIZE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# define CPPAD_CORE_OPTIMIZE_PRINT_RESULT 0 + +/* +$begin optimize$$ +$spell + enum + jac + bool + Taylor + CppAD + cppad + std + const + onetape + op +$$ + +$section Optimize an ADFun Object Tape$$ + + +$head Syntax$$ +$icode%f%.optimize() +%$$ +$icode%f%.optimize(%options%) +%$$ + +$head Purpose$$ +The operation sequence corresponding to an $cref ADFun$$ object can +be very large and involve many operations; see the +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. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ + +$head options$$ +This argument has prototype +$codei% + const std::string& %options% +%$$ +The default for $icode options$$ is the empty string. +If it is present, it must consist of one or more of the options below +separated by a single space character. + +$subhead no_conditional_skip$$ +The $code optimize$$ function can create conditional skip operators +to improve the speed of conditional expressions; see +$cref/optimize/CondExp/Optimize/$$. +If the sub-string $code no_conditional_skip$$ appears in $icode options$$, +conditional skip operations are not be generated. +This may make the optimize routine use significantly less memory +and take less time to optimize $icode f$$. +If conditional skip operations are generated, +it may save a significant amount of time when +using $icode f$$ for $cref forward$$ or $cref reverse$$ mode calculations; +see $cref number_skip$$. + +$subhead no_compare_op$$ +If the sub-string $code no_compare_op$$ appears in $icode options$$, +comparison operators will be removed from the optimized function. +These operators are necessary for the +$cref compare_change$$ functions to be meaningful. +On the other hand, they are not necessary, and take extra time, +when the compare_change functions are not used. + +$subhead no_print_for_op$$ +If the sub-string $code no_compare_op$$ appears in $icode options$$, +$cref PrintFor$$ operations will be removed form the optimized function. +These operators are useful for reporting problems evaluating derivatives +at independent variable values different from those used to record a function. + +$head Examples$$ +$children% + example/optimize/forward_active.cpp + %example/optimize/reverse_active.cpp + %example/optimize/compare_op.cpp + %example/optimize/print_for.cpp + %example/optimize/conditional_skip.cpp + %example/optimize/nest_conditional.cpp + %example/optimize/cumulative_sum.cpp +%$$ +$table +$cref/forward_active.cpp/optimize_forward_active.cpp/$$ $cnext + $title optimize_forward_active.cpp$$ +$rnext +$cref/reverse_active.cpp/optimize_reverse_active.cpp/$$ $cnext + $title optimize_reverse_active.cpp$$ +$rnext +$cref/compare_op.cpp/optimize_compare_op.cpp/$$ $cnext + $title optimize_compare_op.cpp$$ +$rnext +$cref/print_for_op.cpp/optimize_print_for.cpp/$$ $cnext + $title optimize_print_for.cpp$$ +$rnext +$cref/conditional_skip.cpp/optimize_conditional_skip.cpp/$$ $cnext + $title optimize_conditional_skip.cpp$$ +$rnext +$cref/nest_conditional.cpp/optimize_nest_conditional.cpp/$$ $cnext + $title optimize_nest_conditional.cpp$$ +$rnext +$cref/cumulative_sum.cpp/optimize_cumulative_sum.cpp/$$ $cnext + $title optimize_cumulative_sum.cpp$$ +$tend + +$head Efficiency$$ +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 +$codei% + ADFun<%Base%> %f%; + %f%.Dependent(%x%, %y%); + %f%.optimize(); +%$$ +instead of +$codei% + ADFun<%Base%> %f%(%x%, %y%) + %f%.optimize(); +%$$ +See the discussion about +$cref/sequence constructors/FunConstruct/Sequence Constructor/$$. + +$head Speed Testing$$ +You can run the CppAD $cref/speed/speed_main/$$ tests and see +the corresponding changes in number of variables and execution time. +Note that there is an interaction between using +$cref/optimize/speed_main/Global Options/optimize/$$ and +$cref/onetape/speed_main/Global Options/onetape/$$. +If $icode onetape$$ is true and $icode optimize$$ is true, +the optimized tape will be reused many times. +If $icode onetape$$ is false and $icode optimize$$ is true, +the tape will be re-optimized for each test. + +$head Atomic Functions$$ +There are some subtitle issue with optimized $cref atomic$$ functions +$latex v = g(u)$$: + +$subhead rev_sparse_jac$$ +The $cref atomic_two_rev_sparse_jac$$ function is be used to determine +which components of $icode u$$ affect the dependent variables of $icode f$$. +For each atomic operation, the current +$cref/atomic_sparsity/atomic_two_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 +the dependent variables for $icode f$$, +the value of $icode%u%[%i%]%$$ is set to $cref nan$$. + +$head Checking Optimization$$ +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 +of $icode f$$ and the results are checked to see that they are +the same as before. +If they are not the same, the +$cref ErrorHandler$$ is called with a known error message +related to $icode%f%.optimize()%$$. + +$end +----------------------------------------------------------------------------- +*/ +# include +/*! +\file optimize.hpp +Optimize a player object operation sequence +*/ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +Optimize a player object operation sequence + +The operation sequence for this object is replaced by one with fewer operations +but the same funcition and derivative values. + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD and computations by this routine are done using type + Base. + +\param options +\li +If the sub-string "no_conditional_skip" appears, +conditional skip operations will not be generated. +This may make the optimize routine use significantly less memory +and take significantly less time. +\li +If the sub-string "no_compare_op" appears, +then comparison operators will be removed from the optimized tape. +These operators are necessary for the compare_change function to be +be meaningful in the resulting recording. +On the other hand, they are not necessary and take extra time +when compare_change is not used. +*/ +template +void ADFun::optimize(const std::string& options) +{ +# if CPPAD_CORE_OPTIMIZE_PRINT_RESULT + // size of operation sequence before optimizatiton + size_t size_op_before = size_op(); +# endif + + // place to store the optimized version of the recording + local::recorder rec; + + // number of independent variables + size_t n = ind_taddr_.size(); + +# ifndef NDEBUG + size_t i, j, m = dep_taddr_.size(); + CppAD::vector x(n), y(m), check(m); + Base max_taylor(0); + bool check_zero_order = num_order_taylor_ > 0; + if( check_zero_order ) + { // zero order coefficients for independent vars + for(j = 0; j < n; j++) + { CPPAD_ASSERT_UNKNOWN( play_.GetOp(j+1) == local::InvOp ); + CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] == j+1 ); + x[j] = taylor_[ ind_taddr_[j] * cap_order_taylor_ + 0]; + } + // zero order coefficients for dependent vars + for(i = 0; i < m; i++) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + y[i] = taylor_[ dep_taddr_[i] * cap_order_taylor_ + 0]; + } + // maximum zero order coefficient not counting BeginOp at beginning + // (which is correpsonds to uninitialized memory). + for(i = 1; i < num_var_tape_; i++) + { if( abs_geq(taylor_[i*cap_order_taylor_+0] , max_taylor) ) + max_taylor = taylor_[i*cap_order_taylor_+0]; + } + } +# endif + + // create the optimized recording + switch( play_.address_type() ) + { + case local::play::unsigned_short_enum: + local::optimize::optimize_run( + options, n, dep_taddr_, &play_, &rec + ); + break; + + case local::play::unsigned_int_enum: + local::optimize::optimize_run( + options, n, dep_taddr_, &play_, &rec + ); + break; + + case local::play::size_t_enum: + local::optimize::optimize_run( + options, n, dep_taddr_, &play_, &rec + ); + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + } + + // number of variables in the recording + num_var_tape_ = rec.num_var_rec(); + + // now replace the recording + play_.get_recording(rec, n); + + // 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); + for_jac_sparse_set_.resize(0,0); + + // free old Taylor coefficient memory + taylor_.clear(); + num_order_taylor_ = 0; + cap_order_taylor_ = 0; + + // resize and initilaize conditional skip vector + // (must use player size because it now has the recoreder information) + cskip_op_.resize( play_.num_op_rec() ); + + // resize subgraph_info_ + subgraph_info_.resize( + ind_taddr_.size(), // n_ind + dep_taddr_.size(), // n_dep + play_.num_op_rec(), // n_op + play_.num_var_rec() // n_var + ); + +# ifndef NDEBUG + if( check_zero_order ) + { std::stringstream s; + // + // zero order forward calculation using new operation sequence + check = Forward(0, x, s); + + // check results + Base eps99 = Base(99) * CppAD::numeric_limits::epsilon(); + for(i = 0; i < m; i++) + if( ! abs_geq( eps99 * max_taylor , check[i] - y[i] ) ) + { std::string msg = "Error during check of f.optimize()."; + msg += "\neps99 * max_taylor = " + to_string(eps99 * max_taylor); + msg += "\ncheck[i] = " + to_string(check[i]); + msg += "\ny[i] = " + to_string(y[i]); + CPPAD_ASSERT_KNOWN( + abs_geq( eps99 * max_taylor , check[i] - y[i] ) , + msg.c_str() + ); + } + + // Erase memory that this calculation was done so NDEBUG gives + // same final state for this object (from users perspective) + num_order_taylor_ = 0; + } +# endif +# if CPPAD_CORE_OPTIMIZE_PRINT_RESULT + // size of operation sequence after optimizatiton + size_t size_op_after = size_op(); + std::cout << "optimize: size_op: before = " << + size_op_before << ", after = " << size_op_after << "\n"; +# endif +} + +} // END_CPPAD_NAMESPACE + +# undef CPPAD_CORE_OPTIMIZE_PRINT_RESULT +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/opt_val_hes.hpp cppad-2019.02.00.0/include/cppad/core/opt_val_hes.hpp --- cppad-2018.00.00.0/include/cppad/core/opt_val_hes.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/opt_val_hes.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,522 @@ +# ifndef CPPAD_CORE_OPT_VAL_HES_HPP +# define CPPAD_CORE_OPT_VAL_HES_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin opt_val_hes$$ +$spell + hes + sy + Jacobian + hes + signdet + jac + Bradley + const + CppAD +$$ + + + +$section Jacobian and Hessian of Optimal Values$$ + +$head Syntax$$ +$icode%signdet% = opt_val_hes(%x%, %y%, %fun%, %jac%, %hes%)%$$ + +$head See Also$$ +$cref BenderQuad$$ + +$head Reference$$ +Algorithmic differentiation of implicit functions and optimal values, +Bradley M. Bell and James V. Burke, Advances in Automatic Differentiation, +2008, Springer. + +$head Purpose$$ +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) + \\ + V(x) & = & F [ x , Y(x) ] + \\ + 0 & = & \partial_y F [x , Y(x) ] +\end{array} +\] $$ +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 +$icode BaseVector$$; i.e., +$codei% + %BaseVector%::value_type +%$$ + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %BaseVector%& %x% +%$$ +and its size must be equal to $icode n$$. +It specifies the point at which we evaluating +the Jacobian $latex V^{(1)} (x)$$ +(and possibly the Hessian $latex V^{(2)} (x)$$). + + +$head y$$ +The argument $icode y$$ has prototype +$codei% + const %BaseVector%& %y% +%$$ +and its size must be equal to $icode m$$. +It must be equal to $latex Y(x)$$; i.e., +it must solve the implicit equation +$latex \[ + 0 = \partial_y F ( x , y) +\] $$ + +$head 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. +These member functions must not stop such a recording; e.g., +they must not call $cref/AD::abort_recording/abort_recording/$$. + +$subhead Fun::ad_vector$$ +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 +%$$ +is equal to $codei%AD<%Base%>%$$. + +$subhead fun.ell$$ +The type $icode Fun$$ must support the syntax +$codei% + %ell% = %fun%.ell() +%$$ +where $icode ell$$ has prototype +$codei% + size_t %ell% +%$$ +and is the value of $latex \ell$$; i.e., +the number of terms in the summation. +$pre + +$$ +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)$$, +(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 +of separate simpler functions may reduce the amount of memory necessary for +algorithmic differentiation and there by speed up the process. + +$subhead fun.s$$ +The type $icode Fun$$ must support the syntax +$codei% + %s_k% = %fun%.s(%k%, %x%, %y%) +%$$ +The $icode%fun%.s%$$ argument $icode k$$ has prototype +$codei% + size_t %k% +%$$ +and is between zero and $icode%ell% - 1%$$. +The argument $icode x$$ to $icode%fun%.s%$$ has prototype +$codei% + const %Fun%::ad_vector& %x% +%$$ +and its size must be equal to $icode n$$. +The argument $icode y$$ to $icode%fun%.s%$$ has prototype +$codei% + const %Fun%::ad_vector& %y% +%$$ +and its size must be equal to $icode m$$. +The $icode%fun%.s%$$ result $icode s_k$$ has prototype +$codei% + AD<%Base%> %s_k% +%$$ +and its value must be given by $latex s_k = S_k ( x , y )$$. + +$subhead fun.sy$$ +The type $icode Fun$$ must support the syntax +$codei% + %sy_k% = %fun%.sy(%k%, %x%, %y%) +%$$ +The argument $icode k$$ to $icode%fun%.sy%$$ has prototype +$codei% + size_t %k% +%$$ +The argument $icode x$$ to $icode%fun%.sy%$$ has prototype +$codei% + const %Fun%::ad_vector& %x% +%$$ +and its size must be equal to $icode n$$. +The argument $icode y$$ to $icode%fun%.sy%$$ has prototype +$codei% + const %Fun%::ad_vector& %y% +%$$ +and its size must be equal to $icode m$$. +The $icode%fun%.sy%$$ result $icode sy_k$$ has prototype +$codei% + %Fun%::ad_vector %sy_k% +%$$ +its size must be equal to $icode m$$, +and its value must be given by $latex sy_k = \partial_y S_k ( x , y )$$. + +$head jac$$ +The argument $icode jac$$ has prototype +$codei% + %BaseVector%& %jac% +%$$ +and has size $icode n$$ or zero. +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$$, +$latex \[ + jac[ j ] = V^{(1)} (x)_j +\] $$ +where $icode x$$ is the first argument to $code opt_val_hes$$. + +$head hes$$ +The argument $icode hes$$ has prototype +$codei% + %BaseVector%& %hes% +%$$ +and has size $icode%n% * %n%$$ or zero. +The input values of its elements do not matter. +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 \[ + hes[ i * n + j ] = V^{(2)} (x)_{i,j} +\] $$ + + +$head signdet$$ +If $icode%hes%$$ has size zero, $icode signdet$$ is not defined. +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 +the Hessian is not computed ($icode hes$$ is not changed). + +$head Example$$ +$children% + example/general/opt_val_hes.cpp +%$$ +The file +$cref opt_val_hes.cpp$$ +contains an example and test of this operation. + +$end +----------------------------------------------------------------------------- +*/ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file opt_val_hes.hpp +\brief Computing Jabobians and Hessians of Optimal Values +*/ + +/*! +Computing Jabobians and Hessians of Optimal Values + +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 \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) + \\ + V(x) & = & F [ x , Y(x) ] + \\ + 0 & = & \partial_y F [x , Y(x) ] +\end{array} +\f] +We wish to compute the Jacobian +and possibly also the Hessian, of \f$ V (x) \f$. + +\tparam BaseVector +The type BaseVector must be a SimpleVector class. +We use Base to refer to the type of the elements of + BaseVector; i.e., +BaseVector::value_type. + +\param x +is a vector with size n. +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 m. +It must be equal to \f$ Y(x) \f$; i.e., +it must solve the implicit equation +\f[ + 0 = \partial_y F ( x , y) +\f] + +\param fun +The argument fun is an object of type Fun +wich must support the member functions listed below. +CppAD will may be recording operations of the type AD +when these member functions are called. +These member functions must not stop such a recording; e.g., +they must not call AD::abort_recording. + +\par Fun::ad_vector +The type Fun::ad_vector must be a +SimpleVector class with elements of type AD; i.e. +Fun::ad_vector::value_type +is equal to AD. + +\par fun.ell +the type Fun must support the syntax +\verbatim + ell = fun.ell() +\endverbatim +where ell is a size_t value that is set to \f$ \ell \f$; i.e., +the number of terms in the summation. + +\par fun.s +The type Fun must support the syntax +\verbatim + s_k = fun.s(k, x, y) +\endverbatim +The argument k has prototype size_t k. +The argument x has prototype const Fun::ad_vector& x +and its size must be equal to n. +The argument y has prototype const Fun::ad_vector& y +and its size must be equal to m. +The return value s_k has prototype AD s_k +and its value must be given by \f$ s_k = S_k ( x , y ) \f$. + +\par fun.sy +The type Fun must support the syntax +\verbatim + sy_k = fun.sy(k, x, y) +\endverbatim +The argument k has prototype size_t k. +The argument x has prototype const Fun::ad_vector& x +and its size must be equal to n. +The argument y has prototype const Fun::ad_vector& y +and its size must be equal to m. +The return value sy_k has prototype Fun::ad_vector& sy_k, +its size is m +and its value must be given by \f$ sy_k = \partial_y S_k ( x , y ) \f$. + +\param jac +is a vector with size n or zero. +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$, +\f[ + jac[ j ] = V^{(1)} (x)_j +\f] $$ +where x is the first argument to opt_val_hes. + +\param hes +is a vector with size n * n or zero. +The input values of its elements do not matter. +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[ + hes[ i * n + j ] = V^{(2)} (x)_{i,j} +\f] + +\return +If hes.size() == 0, the return value is not defined. +Otherwise, +the return value is the sign of the determinant for +\f$ \partial_{yy}^2 F(x , y) \f$$. +If it is zero, then the matrix is singular and hes is not set +to its specified value. +*/ + + +template +int opt_val_hes( + const BaseVector& x , + const BaseVector& y , + Fun fun , + BaseVector& jac , + BaseVector& hes ) +{ // determine the base type + typedef typename BaseVector::value_type Base; + + // check that BaseVector is a SimpleVector class with Base elements + CheckSimpleVector(); + + // determine the AD vector type + typedef typename Fun::ad_vector ad_vector; + + // check that ad_vector is a SimpleVector class with AD elements + CheckSimpleVector< AD , ad_vector >(); + + // size of the x and y spaces + size_t n = size_t(x.size()); + size_t m = size_t(y.size()); + + // number of terms in the summation + size_t ell = fun.ell(); + + // check size of return values + CPPAD_ASSERT_KNOWN( + size_t(jac.size()) == n || jac.size() == 0, + "opt_val_hes: size of the vector jac is not equal to n or zero" + ); + CPPAD_ASSERT_KNOWN( + size_t(hes.size()) == n * n || hes.size() == 0, + "opt_val_hes: size of the vector hes is not equal to n * n or zero" + ); + + // some temporary indices + size_t i, j, k; + + // AD version of S_k(x, y) + ad_vector s_k(1); + + // ADFun version of S_k(x, y) + ADFun S_k; + + // 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 + // to \partial_x F (x, y) (see Thoerem 2 of the reference). + + // copy x and y to AD version + for(j = 0; j < n; j++) + a_x[j] = x[j]; + for(j = 0; j < m; j++) + a_y[j] = y[j]; + + // initialize summation + for(j = 0; j < n; j++) + jac[j] = Base(0.); + + // add in \partial_x S_k (x, y) + for(k = 0; k < ell; k++) + { // start recording + Independent(a_x); + // record + s_k[0] = fun.s(k, a_x, a_y); + // stop recording and store in S_k + S_k.Dependent(a_x, s_k); + // compute partial of S_k with respect to x + 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]; + } + } + // check if we are done + if( hes.size() == 0 ) + return 0; + + /* + In this case, we need to compute the Hessian. Using Theorem 1 of the + 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) + */ + // 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]; + for(j = 0; j < m; 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); + + // add in Hessian of S_k to hes + for(k = 0; k < ell; k++) + { // start recording + Independent(a_xy); + // split out x + for(j = 0; j < n; j++) + a_x[j] = a_xy[j]; + // split out y + for(j = 0; j < m; j++) + a_y[j] = a_xy[n+j]; + // record + s_k[0] = fun.s(k, a_x, a_y); + // stop recording and store in S_k + 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 + 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]; + } + // 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); + Base logdet; + int signdet = CppAD::LuSolve(m, n, F_yy, F_yx, neg_Y_x, logdet); + if( signdet == 0 ) + return signdet; + + // 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 ]; + for(k = 0; k < m; k++) + hes[i*n+j] -= F_hes[i*(n+m) + k+n] * neg_Y_x[k*n+j]; + } + } + return signdet; +} + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/ordered.hpp cppad-2019.02.00.0/include/cppad/core/ordered.hpp --- cppad-2018.00.00.0/include/cppad/core/ordered.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/ordered.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,100 @@ +# ifndef CPPAD_CORE_ORDERED_HPP +# define CPPAD_CORE_ORDERED_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +\file ordered.hpp +Check and AD values ordering properties relative to zero. +*/ + +// GreaterThanZero ============================================================ +/*! +Check if an AD is greater than zero. + +\param x +value we are checking. + +\return +returns true iff the x is greater than zero. +*/ +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool GreaterThanZero(const AD &x) +{ return GreaterThanZero(x.value_); } +// GreaterThanOrZero ========================================================= +/*! +Check if an AD is greater than or equal zero. + +\param x +value we are checking. + +\return +returns true iff the x is greater than or equal zero. +*/ +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool GreaterThanOrZero(const AD &x) +{ return GreaterThanOrZero(x.value_); } +// LessThanZero ============================================================ +/*! +Check if an AD is less than zero. + +\param x +value we are checking. + +\return +returns true iff the x is less than zero. +*/ +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool LessThanZero(const AD &x) +{ return LessThanZero(x.value_); } +// LessThanOrZero ========================================================= +/*! +Check if an AD is less than or equal zero. + +\param x +value we are checking. + +\return +returns true iff the x is less than or equal zero. +*/ +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool LessThanOrZero(const AD &x) +{ return LessThanOrZero(x.value_); } +// abs_geq ========================================================= +/*! +Check if absolute value of one AD is greater or equal another. + +\param x +value we are checking if it is greater than or equal other. + +\param y +value we are checking if it is less than other. + +\return +returns true iff the absolute value of x is greater than or equal +absolute value of y. +*/ +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +bool abs_geq(const AD& x, const AD& y) +{ return abs_geq(x.value_, y.value_); } +// ============================================================================ +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/parallel_ad.hpp cppad-2019.02.00.0/include/cppad/core/parallel_ad.hpp --- cppad-2018.00.00.0/include/cppad/core/parallel_ad.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/parallel_ad.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,117 @@ +# ifndef CPPAD_CORE_PARALLEL_AD_HPP +# define CPPAD_CORE_PARALLEL_AD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin parallel_ad$$ +$spell + CppAD + num + std +$$ + +$section Enable AD Calculations During Parallel Mode$$ + +$head Syntax$$ +$codei%parallel_ad<%Base%>()%$$ + +$head Purpose$$ +The function +$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 +the multiple $codei%AD<%Base%>%$$ tapes required for parallel execution. + +$head Discussion$$ +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. +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 +(and teardown) for the particular $icode Base$$ type. + +$head CheckSimpleVector$$ +This routine has the side effect of calling the routines +$codei% + CheckSimpleVector< %Type%, CppAD::vector<%Type%> >() +%$$ +where $icode Type$$ is $icode Base$$ and $codei%AD<%Base%>%$$. + +$head Example$$ +The files +$cref team_openmp.cpp$$, +$cref team_bthread.cpp$$, and +$cref team_pthread.cpp$$, +contain examples and tests that implement this function. + +$head Restriction$$ +This routine cannot be called in parallel mode or while +there is a tape recording $codei%AD<%Base%>%$$ operations. + +$end +----------------------------------------------------------------------------- +*/ + +# include + +// BEGIN CppAD namespace +namespace CppAD { + +/*! +Enable parallel execution mode with AD by initializing +static variables that my be used. +*/ + +template +void parallel_ad(void) +{ CPPAD_ASSERT_KNOWN( + ! thread_alloc::in_parallel() , + "parallel_ad must be called before entering parallel execution mode." + ); + CPPAD_ASSERT_KNOWN( + AD::tape_ptr() == CPPAD_NULL , + "parallel_ad cannot be called while a tape recording is in progress" + ); + + // ensure statics in following functions are initialized + elapsed_seconds(); + ErrorHandler::Current(); + local::NumArg(local::BeginOp); + local::NumRes(local::BeginOp); + local::one_element_std_set(); + local::two_element_std_set(); + + // the sparse_pack class has member functions with static data + local::sparse_pack sp; + sp.resize(1, 1); // so can call add_element + sp.add_element(0, 0); // has static data + sp.clear(0); // has static data + sp.is_element(0, 0); // has static data + local::sparse_pack::const_iterator itr(sp, 0); // has static data + ++itr; // has static data + + // statics that depend on the value of Base + AD::tape_id_ptr(0); + AD::tape_handle(0); + discrete::List(); + CheckSimpleVector< Base, CppAD::vector >(); + CheckSimpleVector< AD, CppAD::vector< AD > >(); + +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/pow.hpp cppad-2019.02.00.0/include/cppad/core/pow.hpp --- cppad-2018.00.00.0/include/cppad/core/pow.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/pow.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,295 @@ +# ifndef CPPAD_CORE_POW_HPP +# define CPPAD_CORE_POW_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin pow$$ +$spell + Vec + std + namespace + CppAD + const +$$ + + +$section The AD Power Function$$ + +$head Syntax$$ +$icode%z% = pow(%x%, %y%)%$$ + +$head See Also$$ +$cref pow_int$$ + + +$head Purpose$$ +Determines the value of the power function which is defined by +$latex \[ + {\rm pow} (x, y) = x^y +\] $$ +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). +(This will work even if $icode x$$ is less than or equal zero.) + +$head x$$ +The argument $icode x$$ has one of the following prototypes +$codei% + const %Base%& %x% + const AD<%Base%>& %x% + const VecAD<%Base%>::reference& %x% +%$$ + +$head y$$ +The argument $icode y$$ has one of the following prototypes +$codei% + const %Base%& %y% + const AD<%Base%>& %y% + const VecAD<%Base%>::reference& %y% +%$$ + +$head z$$ +If both $icode x$$ and $icode y$$ are $icode Base$$ objects, +the result $icode z$$ is also a $icode Base$$ object. +Otherwise, it has prototype +$codei% + AD<%Base%> %z% +%$$ + +$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 Example$$ +$children% + example/general/pow.cpp +%$$ +The file +$cref pow.cpp$$ +is an examples and tests of this function. + +$end +------------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +// case where x and y are AD ----------------------------------------- +template AD +pow(const AD& x, const AD& y) +{ + // compute the Base part + AD result; + result.value_ = pow(x.value_, y.value_); + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); + + // check if there is a recording in progress + local::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 ); + + // check if x and y tapes match + bool match_x = x.tape_id_ == tape_id; + bool match_y = y.tape_id_ == tape_id; + + // check if x and y are dynamic parameters + bool dyn_x = match_x & (x.ad_type_ == dynamic_enum); + bool dyn_y = match_y & (y.ad_type_ == dynamic_enum); + + // check if x and y are variables + bool var_x = match_x & (x.ad_type_ != dynamic_enum); + bool var_y = match_y & (y.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + x.tape_id_ == y.tape_id_ || ! match_x || ! match_y , + "pow: AD variables or dynamic parameters on different threads." + ); + if( var_x ) + { if( var_y ) + { // result = variable^variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::PowvvOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::PowvvOp) == 2 ); + + // put operand addresses in tape + tape->Rec_.PutArg(x.taddr_, y.taddr_); + + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::PowvvOp); + + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + else if( IdenticalZero( y.value_ ) ) + { // result = variable^0 + } + else + { // result = variable^parameter + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::PowvpOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::PowvpOp) == 2 ); + + // put operand addresses in tape + addr_t p = y.taddr_; + if( ! dyn_y ) + p = tape->Rec_.put_con_par(y.value_); + tape->Rec_.PutArg(x.taddr_, p); + + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::PowvpOp); + + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + } + else if( var_y ) + { if( IdenticalZero(x.value_) ) + { // result = 0^variable + } + else + { // result = parameter^variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::PowpvOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::PowpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = x.taddr_; + if( ! dyn_x ) + p = tape->Rec_.put_con_par(x.value_); + tape->Rec_.PutArg(p, y.taddr_); + + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::PowpvOp); + + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + } + else if( dyn_x | dyn_y ) + { addr_t arg0 = x.taddr_; + addr_t arg1 = y.taddr_; + if( ! dyn_x ) + arg0 = tape->Rec_.put_con_par(x.value_); + if( ! dyn_y ) + arg1 = tape->Rec_.put_con_par(y.value_); + // + // parameters with a dynamic parameter result + result.taddr_ = tape->Rec_.put_dyn_par( + result.value_, local::pow_dyn, arg0, arg1 + ); + result.tape_id_ = tape_id; + result.ad_type_ = dynamic_enum; + } + else + { CPPAD_ASSERT_KNOWN( ! (dyn_x | dyn_y) , + "pow: one operand is a dynamic parameter and other not a variable" + ); + } + return result; +} +// ========================================================================= +// Fold operations in same way as CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(Op) +// ------------------------------------------------------------------------- +// Operations with VecAD_reference and AD only + +template AD +pow(const AD& x, const VecAD_reference& y) +{ return pow(x, y.ADBase()); } + +template AD +pow(const VecAD_reference& x, const VecAD_reference& y) +{ return pow(x.ADBase(), y.ADBase()); } + +template AD +pow(const VecAD_reference& x, const AD& y) +{ return pow(x.ADBase(), y); } +// ------------------------------------------------------------------------- +// Operations with Base + +template AD +pow(const Base& x, const AD& y) +{ return pow(AD(x), y); } + +template AD +pow(const Base& x, const VecAD_reference& y) +{ return pow(AD(x), y.ADBase()); } + +template AD +pow(const AD& x, const Base& y) +{ return pow(x, AD(y)); } + +template AD +pow(const VecAD_reference& x, const Base& y) +{ return pow(x.ADBase(), AD(y)); } +// ------------------------------------------------------------------------- +// Operations with double + +template AD +pow(const double& x, const AD& y) +{ return pow(AD(x), y); } + +template AD +pow(const double& x, const VecAD_reference& y) +{ return pow(AD(x), y.ADBase()); } + +template AD +pow(const AD& x, const double& y) +{ return pow(x, AD(y)); } + +template AD +pow(const VecAD_reference& x, const double& y) +{ return pow(x.ADBase(), AD(y)); } +// ------------------------------------------------------------------------- +// Special case to avoid ambuigity when Base is double + +inline AD +pow(const double& x, const AD& y) +{ return pow(AD(x), y); } + +inline AD +pow(const double& x, const VecAD_reference& y) +{ return pow(AD(x), y.ADBase()); } + +inline AD +pow(const AD& x, const double& y) +{ return pow(x, AD(y)); } + +inline AD +pow(const VecAD_reference& x, const double& y) +{ return pow(x.ADBase(), AD(y)); } + +// ========================================================================= +// Fold operations for the cases where x is an int, +// but let cppad/utility/pow_int.hpp handle the cases where y is an int. +// ------------------------------------------------------------------------- +template AD pow +(const int& x, const VecAD_reference& y) +{ return pow(AD(x), y.ADBase()); } + +template AD pow +(const int& x, const AD& y) +{ return pow(AD(x), y); } + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/print_for.hpp cppad-2019.02.00.0/include/cppad/core/print_for.hpp --- cppad-2018.00.00.0/include/cppad/core/print_for.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/print_for.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,219 @@ +# ifndef CPPAD_CORE_PRINT_FOR_HPP +# define CPPAD_CORE_PRINT_FOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin PrintFor$$ +$spell + pos + var + VecAD + std + cout + const +$$ + + +$section Printing AD Values During Forward Mode$$ + +$head Syntax$$ +$icode%f%.Forward(0, %x%) +%$$ +$codei%PrintFor(%before%, %value%) +%$$ +$codei%PrintFor(%pos%, %before%, %value%, %after%) +%$$ + +$head Purpose$$ +The $cref/zero order forward/forward_zero/$$ mode command +$codei% + %f%.Forward(0, %x%) +%$$ +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 +$cref/operation sequence/glossary/Operation/Sequence/$$ corresponding +to $icode f$$. +Putting a $code PrintFor$$ in the operation sequence will +cause the value of $icode var$$, corresponding to $icode x$$, +to be printed during zero order forward operations. + +$head f.Forward(0, x)$$ +The objects $icode f$$, $icode x$$, and the purpose +for this operation, are documented in $cref Forward$$. + +$head pos$$ +If present, the argument $icode pos$$ has one of the following prototypes +$codei% + const AD<%Base%>& %pos% + const VecAD<%Base%>::reference& %pos% +%$$ +In this case +the text and $icode var$$ will be printed if and only if +$icode pos$$ is not greater than zero and a finite number. + +$head before$$ +The argument $icode before$$ has prototype +$codei% + const char* %before% +%$$ +This text is written to $code std::cout$$ before $icode var$$. + +$head value$$ +The argument $icode value$$ has one of the following prototypes +$codei% + const AD<%Base%>& %var% + const VecAD<%Base%>::reference& %var% +%$$ +The value of $icode value$$, that corresponds to $icode x$$, +is written to $code std::cout$$ during the execution of +$codei% + %f%.Forward(0, %x%) +%$$ +Note that $icode value$$ may be a +$cref/variable/glossary/Variable/$$ or +$cref/parameter/glossary/Parameter/$$. +If a parameter is +$cref/dynamic/glossary/Parameter/Dynamic/$$ its value +will depend on the previous call to $cref new_dynamic$$. + +$head after$$ +The argument $icode after$$ has prototype +$codei% + const char* %after% +%$$ +This text is written to $code std::cout$$ after $icode var$$. + +$head Redirecting Output$$ +You can redirect this output to any standard output stream; see the +$cref/s/forward_order/s/$$ in the forward mode documentation. + +$head Discussion$$ +This is helpful for understanding why tape evaluations +have trouble. +For example, if one of the operations in $icode f$$ is +$codei%log(%var%)%$$ and $icode%var% <= 0%$$, +the corresponding result will be $cref nan$$. + +$head Alternative$$ +The $cref ad_output$$ section describes the normal +printing of values; i.e., printing when the corresponding +code is executed. + +$head Example$$ +$children% + example/print_for/print_for.cpp% + example/general/print_for.cpp +%$$ +The program +$cref print_for_cout.cpp$$ +is an example and test that prints to standard output. +The output of this program +states the conditions for passing and failing the test. +The function +$cref print_for_string.cpp$$ +is an example and test that prints to an standard string stream. +This function automatically check for correct output. + +$end +------------------------------------------------------------------------------ +*/ + +# include + +namespace CppAD { + template + void PrintFor(const AD& pos, + const char *before, const AD& var, const char* after) + { CPPAD_ASSERT_NARG_NRES(local::PriOp, 5, 0); + + // check for case where we are not recording operations + local::ADTape* tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return; + + CPPAD_ASSERT_KNOWN( + std::strlen(before) <= 1000 , + "PrintFor: length of before is greater than 1000 characters" + ); + CPPAD_ASSERT_KNOWN( + std::strlen(after) <= 1000 , + "PrintFor: length of after is greater than 1000 characters" + ); + addr_t arg0, arg1, arg2, arg3, arg4; + + // arg[0] = base 2 representation of the value [Var(pos), Var(var)] + arg0 = 0; + + // arg[1] = address for pos + if( Parameter(pos) ) + arg1 = tape->Rec_.put_con_par(pos.value_); + else + { arg0 += 1; + arg1 = pos.taddr_; + } + + // arg[2] = address of before + arg2 = tape->Rec_.PutTxt(before); + + // arg[3] = address for var + if( Parameter(var) ) + arg3 = tape->Rec_.put_con_par(var.value_); + else + { arg0 += 2; + arg3 = var.taddr_; + } + + // arg[4] = address of after + arg4 = tape->Rec_.PutTxt(after); + + // put the operator in the tape + tape->Rec_.PutArg(arg0, arg1, arg2, arg3, arg4); + tape->Rec_.PutOp(local::PriOp); + } + // Fold all other cases into the case above + template + void PrintFor(const char* before, const AD& var) + { PrintFor(AD(0), before, var, "" ); } + // + template + void PrintFor(const char* before, const VecAD_reference& var) + { PrintFor(AD(0), before, var.ADBase(), "" ); } + // + template + void PrintFor( + const VecAD_reference& pos , + const char *before , + const VecAD_reference& var , + const char *after ) + { PrintFor(pos.ADBase(), before, var.ADBase(), after); } + // + template + void PrintFor( + const VecAD_reference& pos , + const char *before , + const AD& var , + const char *after ) + { PrintFor(pos.ADBase(), before, var, after); } + // + template + void PrintFor( + const AD& pos , + const char *before , + const VecAD_reference& var , + const char *after ) + { PrintFor(pos, before, var.ADBase(), after); } +} + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/reverse.hpp cppad-2019.02.00.0/include/cppad/core/reverse.hpp --- cppad-2018.00.00.0/include/cppad/core/reverse.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/reverse.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,209 @@ +# ifndef CPPAD_CORE_REVERSE_HPP +# define CPPAD_CORE_REVERSE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file core/reverse.hpp +Compute derivatives using reverse mode. +*/ + + +/*! +Use reverse mode to compute derivative of forward mode Taylor coefficients. + +The function +\f$ X : {\bf R} \times {\bf R}^{n \times q} \rightarrow {\bf R} \f$ +is defined by +\f[ +X(t , u) = \sum_{k=0}^{q-1} u^{(k)} t^k +\f] +The function +\f$ Y : {\bf R} \times {\bf R}^{n \times q} \rightarrow {\bf R} \f$ +is defined by +\f[ +Y(t , u) = F[ X(t, u) ] +\f] +The function +\f$ W : {\bf R}^{n \times q} \rightarrow {\bf R} \f$ is defined by +\f[ +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< Base > and computations by this routine are done using type + Base. + +\tparam BaseVector +is a Simple Vector class with elements of type Base. + +\param q +is the number of the number of Taylor coefficients that are being +differentiated (per variable). + +\param w +is the weighting for each of the Taylor coefficients corresponding +to dependent variables. +If the argument w has size m * q , +for \f$ k = 0 , \ldots , q-1 \f$ and \f$ i = 0, \ldots , m-1 \f$, +\f[ + w_i^{(k)} = w [ i * q + k ] +\f] +If the argument w has size m , +for \f$ k = 0 , \ldots , q-1 \f$ and \f$ i = 0, \ldots , m-1 \f$, +\f[ +w_i^{(k)} = \left\{ \begin{array}{ll} + w [ i ] & {\rm if} \; k = q-1 + \\ + 0 & {\rm otherwise} +\end{array} \right. +\f] + +\return +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[ + dw[ j * q + k ] = W^{(1)} ( x )_{j,k} +\f] +where the matrix \f$ x \f$ is the value for \f$ u \f$ +that corresponding to the forward mode Taylor coefficients +for the independent variables as specified by previous calls to Forward. + +*/ +template +template +BaseVector ADFun::Reverse(size_t q, const BaseVector &w) +{ // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + + // constants + const Base zero(0); + + // temporary indices + size_t i, j, k; + + // number of independent variables + size_t n = ind_taddr_.size(); + + // number of dependent variables + size_t m = dep_taddr_.size(); + + // check BaseVector is Simple Vector class with Base type elements + CheckSimpleVector(); + + CPPAD_ASSERT_KNOWN( + size_t(w.size()) == m || size_t(w.size()) == (m * q), + "Argument w to Reverse does not have length equal to\n" + "the dimension of the range or dimension of range times q." + ); + CPPAD_ASSERT_KNOWN( + q > 0, + "The first argument to Reverse must be greater than zero." + ); + CPPAD_ASSERT_KNOWN( + num_order_taylor_ >= q, + "Less than 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) ) + { num_order_taylor_ = 1; // number of orders to copy + size_t c = cap_order_taylor_; // keep the same capacity setting + size_t r = 1; // only keep one direction + capacity_order(c, r); + } + CPPAD_ASSERT_KNOWN( + num_direction_taylor_ == 1, + "Reverse mode for Forward(q, r, xq) with more than one direction" + "\n(r > 1) is not yet supported for q > 1." + ); + + // initialize entire Partial matrix to zero + local::pod_vector_maybe Partial(num_var_tape_ * q); + for(i = 0; i < num_var_tape_; i++) + for(j = 0; j < q; j++) + Partial[i * q + j] = zero; + + // set the dependent variable direction + // (use += because two dependent variables can point to same location) + for(i = 0; i < m; i++) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + if( size_t(w.size()) == m ) + Partial[dep_taddr_[i] * q + q - 1] += w[i]; + else + { for(k = 0; k < q; k++) + // ? should use += here, first make test to demonstrate bug + Partial[ dep_taddr_[i] * q + k ] = w[i * q + k ]; + } + } + + // evaluate the derivatives + CPPAD_ASSERT_UNKNOWN( cskip_op_.size() == play_.num_op_rec() ); + CPPAD_ASSERT_UNKNOWN( load_op_.size() == play_.num_load_op_rec() ); + local::play::const_sequential_iterator play_itr = play_.end(); + local::sweep::reverse( + q - 1, + n, + num_var_tape_, + &play_, + cap_order_taylor_, + taylor_.data(), + q, + Partial.data(), + cskip_op_.data(), + load_op_, + play_itr, + not_used_rec_base + ); + + // return the derivative values + BaseVector value(n * q); + for(j = 0; j < n; j++) + { CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] < num_var_tape_ ); + + // independent variable taddr equals its operator taddr + CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[j] ) == local::InvOp ); + + // 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 ] = + Partial[ind_taddr_[j] * q + q - 1 - k]; + } + else + { for(k = 0; k < q; k++) + value[j * q + k ] = + Partial[ind_taddr_[j] * q + k]; + } + } + CPPAD_ASSERT_KNOWN( ! ( hasnan(value) && check_for_nan_ ) , + "dw = f.Reverse(q, w): has a nan,\n" + "but none of its Taylor coefficents are nan." + ); + + return value; +} + + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/rev_hes_sparsity.hpp cppad-2019.02.00.0/include/cppad/core/rev_hes_sparsity.hpp --- cppad-2018.00.00.0/include/cppad/core/rev_hes_sparsity.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/rev_hes_sparsity.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,253 @@ +# ifndef CPPAD_CORE_REV_HES_SPARSITY_HPP +# define CPPAD_CORE_REV_HES_SPARSITY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin rev_hes_sparsity$$ +$spell + Jacobian + Hessian + jac + hes + bool + const + rc + cpp +$$ + +$section Reverse Mode Hessian Sparsity Patterns$$ + +$head Syntax$$ +$icode%f%.rev_hes_sparsity( + %select_range%, %transpose%, %internal_bool%, %pattern_out% +)%$$ + +$head Purpose$$ +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the +$cref/AD function/glossary/AD Function/$$ corresponding to +the operation sequence stored in $icode f$$. +Fix $latex R \in \B{R}^{n \times \ell}$$, $latex s \in \B{R}^m$$ +and define the function +$latex \[ + H(x) = ( s^\R{T} F )^{(2)} ( x ) R +\] $$ +Given a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for $latex R$$ +and for the vector $latex s$$, +$code rev_hes_sparsity$$ computes a sparsity pattern for $latex H(x)$$. + +$head x$$ +Note that the sparsity pattern $latex H(x)$$ corresponds to the +operation sequence stored in $icode f$$ and does not depend on +the argument $icode x$$. + +$head BoolVector$$ +The type $icode BoolVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code bool$$. + +$head SizeVector$$ +The type $icode SizeVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ + +$head R$$ +The sparsity pattern for the matrix $latex R$$ is specified by +$cref/pattern_in/for_jac_sparsity/pattern_in/$$ in the previous call +$codei% + %f%.for_jac_sparsity( + %pattern_in%, %transpose%, %dependency%, %internal_bool%, %pattern_out% +)%$$ + +$head select_range$$ +The argument $icode select_range$$ has prototype +$codei% + const %BoolVector%& %select_range% +%$$ +It has size $latex m$$ and specifies which components of the vector +$latex s$$ are non-zero; i.e., $icode%select_range%[%i%]%$$ is true +if and only if $latex s_i$$ is possibly non-zero. + +$head transpose$$ +This argument has prototype +$codei% + bool %transpose% +%$$ +See $cref/pattern_out/rev_hes_sparsity/pattern_out/$$ below. + +$head internal_bool$$ +If this is true, calculations are done with sets represented by a vector +of boolean values. Otherwise, a vector of sets of integers is used. +This must be the same as in the previous call to +$icode%f%.for_jac_sparsity%$$. + +$head pattern_out$$ +This argument has prototype +$codei% + sparse_rc<%SizeVector%>& %pattern_out% +%$$ +This input value of $icode pattern_out$$ does not matter. +If $icode transpose$$ it is false (true), +upon return $icode pattern_out$$ is a sparsity pattern for +$latex H(x)$$ ($latex H(x)^\R{T}$$). + +$head Sparsity for Entire Hessian$$ +Suppose that $latex R$$ is the $latex n \times n$$ identity matrix. +In this case, $icode pattern_out$$ is a sparsity pattern for +$latex (s^\R{T} F) F^{(2)} ( x )$$. + +$head Example$$ +$children% + example/sparse/rev_hes_sparsity.cpp +%$$ +The file +$cref rev_hes_sparsity.cpp$$ +contains an example and test of this operation. + +$end +----------------------------------------------------------------------------- +*/ +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +Reverse Hessian sparsity patterns. + +\tparam Base +is the base type for this recording. + +\tparam BoolVector +is the simple vector with elements of type bool that is used for +sparsity for the vector s. + +\tparam SizeVector +is the simple vector with elements of type size_t that is used for +row, column index sparsity patterns. + +\param select_range +is a sparsity pattern for for s. + +\param transpose +Is the returned sparsity pattern transposed. + +\param internal_bool +If this is true, calculations are done with sets represented by a vector +of boolean values. Otherwise, a vector of standard sets is used. + +\param pattern_out +The value of transpose is false (true), +the return value is a sparsity pattern for H(x) ( H(x)^T ) where +\f[ + H(x) = R * F^{(1)} (x) +\f] +Here F is the function corresponding to the operation sequence +and x is any argument value. +*/ +template +template +void ADFun::rev_hes_sparsity( + const BoolVector& select_range , + bool transpose , + bool internal_bool , + sparse_rc& pattern_out ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + size_t n = Domain(); + size_t m = Range(); + // + CPPAD_ASSERT_KNOWN( + size_t( select_range.size() ) == m, + "rev_hes_sparsity: size of select_range is not equal to " + "number of dependent variables" + ); + // + // vector that holds reverse Jacobian sparsity flag + local::pod_vector rev_jac_pattern(num_var_tape_); + for(size_t i = 0; i < num_var_tape_; i++) + rev_jac_pattern[i] = false; + // + // initialize rev_jac_pattern for dependent variables + for(size_t i = 0; i < m; i++) + rev_jac_pattern[ dep_taddr_[i] ] = select_range[i]; + // + // + if( internal_bool ) + { CPPAD_ASSERT_KNOWN( + for_jac_sparse_pack_.n_set() > 0, + "rev_hes_sparsity: previous call to for_jac_sparsity did not " + "use bool for interanl sparsity patterns." + ); + // column dimension of internal sparstiy pattern + size_t ell = for_jac_sparse_pack_.end(); + // + // allocate memory for bool sparsity calculation + // (sparsity pattern is emtpy after a resize) + local::sparse_pack internal_hes; + internal_hes.resize(num_var_tape_, ell); + // + // compute the Hessian sparsity pattern + local::sweep::rev_hes( + &play_, + n, + num_var_tape_, + for_jac_sparse_pack_, + rev_jac_pattern.data(), + internal_hes, + not_used_rec_base + ); + // get sparstiy pattern for independent variables + local::get_internal_sparsity( + transpose, ind_taddr_, internal_hes, pattern_out + ); + } + else + { CPPAD_ASSERT_KNOWN( + for_jac_sparse_set_.n_set() > 0, + "rev_hes_sparsity: previous call to for_jac_sparsity did not " + "use bool for interanl sparsity patterns." + ); + // column dimension of internal sparstiy pattern + size_t ell = for_jac_sparse_set_.end(); + // + // allocate memory for bool sparsity calculation + // (sparsity pattern is emtpy after a resize) + local::sparse_list internal_hes; + internal_hes.resize(num_var_tape_, ell); + // + // compute the Hessian sparsity pattern + local::sweep::rev_hes( + &play_, + n, + num_var_tape_, + for_jac_sparse_set_, + rev_jac_pattern.data(), + internal_hes, + not_used_rec_base + ); + // get sparstiy pattern for independent variables + local::get_internal_sparsity( + transpose, ind_taddr_, internal_hes, pattern_out + ); + } + return; +} +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/rev_jac_sparsity.hpp cppad-2019.02.00.0/include/cppad/core/rev_jac_sparsity.hpp --- cppad-2018.00.00.0/include/cppad/core/rev_jac_sparsity.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/rev_jac_sparsity.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,258 @@ +# ifndef CPPAD_CORE_REV_JAC_SPARSITY_HPP +# define CPPAD_CORE_REV_JAC_SPARSITY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin rev_jac_sparsity$$ +$spell + Jacobian + jac + bool + const + rc + cpp +$$ + +$section Reverse Mode Jacobian Sparsity Patterns$$ + +$head Syntax$$ +$icode%f%.rev_jac_sparsity( + %pattern_in%, %transpose%, %dependency%, %internal_bool%, %pattern_out% +)%$$ + +$head Purpose$$ +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the +$cref/AD function/glossary/AD Function/$$ corresponding to +the operation sequence stored in $icode f$$. +Fix $latex R \in \B{R}^{\ell \times m}$$ and define the function +$latex \[ + J(x) = R * F^{(1)} ( x ) +\] $$ +Given the $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for $latex R$$, +$code rev_jac_sparsity$$ computes a sparsity pattern for $latex J(x)$$. + +$head x$$ +Note that the sparsity pattern $latex J(x)$$ corresponds to the +operation sequence stored in $icode f$$ and does not depend on +the argument $icode x$$. +(The operation sequence may contain +$cref CondExp$$ and $cref VecAD$$ operations.) + +$head SizeVector$$ +The type $icode SizeVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ + +$head pattern_in$$ +The argument $icode pattern_in$$ has prototype +$codei% + const sparse_rc<%SizeVector%>& %pattern_in% +%$$ +see $cref sparse_rc$$. +If $icode transpose$$ it is false (true), +$icode pattern_in$$ is a sparsity pattern for $latex R$$ ($latex R^\R{T}$$). + +$head transpose$$ +This argument has prototype +$codei% + bool %transpose% +%$$ +See $cref/pattern_in/rev_jac_sparsity/pattern_in/$$ above and +$cref/pattern_out/rev_jac_sparsity/pattern_out/$$ below. + +$head dependency$$ +This argument has prototype +$codei% + bool %dependency% +%$$ +see $cref/pattern_out/rev_jac_sparsity/pattern_out/$$ below. + +$head internal_bool$$ +If this is true, calculations are done with sets represented by a vector +of boolean values. Otherwise, a vector of sets of integers is used. + +$head pattern_out$$ +This argument has prototype +$codei% + sparse_rc<%SizeVector%>& %pattern_out% +%$$ +This input value of $icode pattern_out$$ does not matter. +If $icode transpose$$ it is false (true), +upon return $icode pattern_out$$ is a sparsity pattern for +$latex J(x)$$ ($latex J(x)^\R{T}$$). +If $icode dependency$$ is true, $icode pattern_out$$ is a +$cref/dependency pattern/dependency.cpp/Dependency Pattern/$$ +instead of sparsity pattern. + +$head Sparsity for Entire Jacobian$$ +Suppose that +$latex R$$ is the $latex m \times m$$ identity matrix. +In this case, $icode pattern_out$$ is a sparsity pattern for +$latex F^{(1)} ( x )$$ ( $latex F^{(1)} (x)^\R{T}$$ ) +if $icode transpose$$ is false (true). + +$head Example$$ +$children% + example/sparse/rev_jac_sparsity.cpp +%$$ +The file +$cref rev_jac_sparsity.cpp$$ +contains an example and test of this operation. + +$end +----------------------------------------------------------------------------- +*/ +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +Reverse Jacobian sparsity patterns. + +\tparam Base +is the base type for this recording. + +\tparam SizeVector +is the simple vector with elements of type size_t that is used for +row, column index sparsity patterns. + +\param pattern_in +is the sparsity pattern for for R or R^T depending on transpose. + +\param transpose +Is the input and returned sparsity pattern 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 internal_bool +If this is true, calculations are done with sets represented by a vector +of boolean values. Otherwise, a vector of standard sets is used. + +\param pattern_out +The value of transpose is false (true), +the return value is a sparsity pattern for J(x) ( J(x)^T ) where +\f[ + J(x) = R * F^{(1)} (x) +\f] +Here F is the function corresponding to the operation sequence +and x is any argument value. +*/ +template +template +void ADFun::rev_jac_sparsity( + const sparse_rc& pattern_in , + bool transpose , + bool dependency , + bool internal_bool , + sparse_rc& pattern_out ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + // number or rows, columns, and non-zeros in pattern_in + size_t nr_in = pattern_in.nr(); + size_t nc_in = pattern_in.nc(); + // + size_t ell = nr_in; + size_t m = nc_in; + if( transpose ) + std::swap(ell, m); + // + CPPAD_ASSERT_KNOWN( + m == Range() , + "rev_jac_sparsity: number columns in R " + "is not equal number of dependent variables." + ); + // number of independent variables + size_t n = Domain(); + // + bool zero_empty = true; + bool input_empty = true; + if( internal_bool ) + { // allocate memory for bool sparsity calculation + // (sparsity pattern is emtpy after a resize) + local::sparse_pack internal_jac; + internal_jac.resize(num_var_tape_, ell); + // + // set sparsity patttern for dependent variables + local::set_internal_sparsity( + zero_empty , + input_empty , + ! transpose , + dep_taddr_ , + internal_jac , + pattern_in + ); + + // compute sparsity for other variables + local::sweep::rev_jac( + &play_, + dependency, + n, + num_var_tape_, + internal_jac, + not_used_rec_base + + ); + // get sparstiy pattern for independent variables + local::get_internal_sparsity( + ! transpose, ind_taddr_, internal_jac, pattern_out + ); + } + else + { // allocate memory for bool sparsity calculation + // (sparsity pattern is emtpy after a resize) + local::sparse_list internal_jac; + internal_jac.resize(num_var_tape_, ell); + // + // set sparsity patttern for dependent variables + local::set_internal_sparsity( + zero_empty , + input_empty , + ! transpose , + dep_taddr_ , + internal_jac , + pattern_in + ); + + // compute sparsity for other variables + local::sweep::rev_jac( + &play_, + dependency, + n, + num_var_tape_, + internal_jac, + not_used_rec_base + + ); + // get sparstiy pattern for independent variables + local::get_internal_sparsity( + ! transpose, ind_taddr_, internal_jac, pattern_out + ); + } + return; +} +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/rev_one.hpp cppad-2019.02.00.0/include/cppad/core/rev_one.hpp --- cppad-2018.00.00.0/include/cppad/core/rev_one.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/rev_one.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,161 @@ +# ifndef CPPAD_CORE_REV_ONE_HPP +# define CPPAD_CORE_REV_ONE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin RevOne$$ +$spell + dw + Taylor + const +$$ + + + + +$section First Order Derivative: Driver Routine$$ + +$head Syntax$$ +$icode%dw% = %f%.RevOne(%x%, %i%)%$$ + + +$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$$. +The syntax above sets $icode dw$$ to the +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) +\right] +\] $$ + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the $cref ADFun$$ object $icode f$$ is not $code const$$ +(see $cref/RevOne Uses Forward/RevOne/RevOne Uses Forward/$$ below). + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %Vector% &%x% +%$$ +(see $cref/Vector/RevOne/Vector/$$ below) +and its size +must be equal to $icode n$$, the dimension of the +$cref/domain/seq_property/Domain/$$ space for $icode f$$. +It specifies +that point at which to evaluate the derivative. + +$head i$$ +The index $icode i$$ has prototype +$codei% + size_t %i% +%$$ +and is less than $latex m$$, the dimension of the +$cref/range/seq_property/Range/$$ space for $icode f$$. +It specifies the +component of $latex F$$ that we are computing the derivative of. + +$head dw$$ +The result $icode dw$$ has prototype +$codei% + %Vector% %dw% +%$$ +(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$$ +evaluated at $icode x$$; i.e., +for $latex j = 0 , \ldots , n - 1 $$ +$latex \[. + dw[ j ] = \D{ F_i }{ x_j } ( x ) +\] $$ + +$head Vector$$ +The type $icode Vector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$icode Base$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head RevOne Uses Forward$$ +After each call to $cref Forward$$, +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 +$icode%f%.Forward(0, %x%)%$$ +and the other coefficients are unspecified. + +$head Example$$ +$children% + example/general/rev_one.cpp +%$$ +The routine +$cref/RevOne/rev_one.cpp/$$ is both an example and test. +It returns $code true$$, if it succeeds and $code false$$ otherwise. + +$end +----------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +template +template +Vector ADFun::RevOne(const Vector &x, size_t i) +{ size_t i1; + + size_t n = Domain(); + size_t m = Range(); + + // check Vector is Simple Vector class with Base type elements + CheckSimpleVector(); + + 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" + ); + + // point at which we are evaluating the derivative + Forward(0, x); + + // component which are are taking the derivative of + Vector w(m); + for(i1 = 0; i1 < m; i1++) + w[i1] = 0.; + w[i] = Base(1.0); + + // dimension the return value + Vector dw(n); + + // compute the return value + dw = Reverse(1, w); + + return dw; +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/rev_sparse_hes.hpp cppad-2019.02.00.0/include/cppad/core/rev_sparse_hes.hpp --- cppad-2018.00.00.0/include/cppad/core/rev_sparse_hes.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/rev_sparse_hes.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,643 @@ +# ifndef CPPAD_CORE_REV_SPARSE_HES_HPP +# define CPPAD_CORE_REV_SPARSE_HES_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin RevSparseHes$$ +$spell + std + VecAD + Jacobian + Jac + Hessian + Hes + const + Bool + Dep + proportional + var + cpp +$$ + +$section Hessian Sparsity Pattern: Reverse Mode$$ + +$head Syntax$$ +$icode%h% = %f%.RevSparseHes(%q%, %s%) +%$$ +$icode%h% = %f%.RevSparseHes(%q%, %s%, %transpose%)%$$ + +$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}$$ +and a fixed vector $latex S \in \B{R}^{1 \times m}$$, +we define +$latex \[ +\begin{array}{rcl} +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} +& = & (S * F)^{(2)} ( x ) * R +\end{array} +\] $$ +Given a +$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)$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + const ADFun<%Base%> %f% +%$$ + +$head x$$ +If the operation sequence in $icode f$$ is +$cref/independent/glossary/Operation/Independent/$$ of +the independent variables in $latex x \in \B{R}^n$$, +the sparsity pattern is valid for all values of +(even if it has $cref CondExp$$ or $cref VecAD$$ operations). + +$head q$$ +The argument $icode q$$ has prototype +$codei% + size_t %q% +%$$ +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 +$codei% + %f%.ForSparseJac(%q%, %r%, %r_transpose%) +%$$ +Note that if $icode r_transpose$$ is true, $icode r$$ in the call above +corresponding to $latex R^\R{T} \in \B{R}^{q \times n}$$ + +$head transpose$$ +The argument $icode transpose$$ has prototype +$codei% + bool %transpose% +%$$ +The default value $code false$$ is used when $icode transpose$$ is not present. + + +$head r$$ +The matrix $latex R$$ is specified by the previous call +$codei% + %f%.ForSparseJac(%q%, %r%, %transpose%) +%$$ +see $cref/r/ForSparseJac/r/$$. +The type of the elements of +$cref/SetVector/RevSparseHes/SetVector/$$ must be the +same as the type of the elements of $icode r$$. + +$head s$$ +The argument $icode s$$ has prototype +$codei% + const %SetVector%& %s% +%$$ +(see $cref/SetVector/RevSparseHes/SetVector/$$ below) +If it has elements of type $code bool$$, +its size is $latex m$$. +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/$$ +for the vector $icode S$$. + +$head h$$ +The result $icode h$$ has prototype +$codei% + %SetVector%& %h% +%$$ +(see $cref/SetVector/RevSparseHes/SetVector/$$ below). + +$subhead transpose false$$ +If $icode h$$ has elements of type $code bool$$, +its size is $latex q * n$$. +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/$$ +for the matrix $latex H(x)$$. + +$subhead transpose true$$ +If $icode h$$ has elements of type $code bool$$, +its size is $latex n * q$$. +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/$$ +for the matrix $latex H(x)^\R{T}$$. + +$head SetVector$$ +The type $icode SetVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code bool$$ or $code std::set$$; +see $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for a discussion +of the difference. +The type of the elements of +$cref/SetVector/RevSparseHes/SetVector/$$ must be the +same as the type of the elements of $icode r$$. + +$head Entire Sparsity Pattern$$ +Suppose that $latex q = n$$ and +$latex R \in \B{R}^{n \times n}$$ is the $latex n \times n$$ identity matrix. +Further suppose that the $latex S$$ is the $th k$$ +$cref/elementary vector/glossary/Elementary Vector/$$; i.e. +$latex \[ +S_j = \left\{ \begin{array}{ll} + 1 & {\rm if} \; j = k + \\ + 0 & {\rm otherwise} +\end{array} \right. +\] $$ +In this case, +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/sparse/rev_sparse_hes.cpp + %example/sparse/sparsity_sub.cpp +%$$ +The file +$cref rev_sparse_hes.cpp$$ +contains an example and test of this operation. +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 +----------------------------------------------------------------------------- +*/ +# include +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file core/rev_sparse_hes.hpp +Reverse mode Hessian sparsity patterns. +*/ +// =========================================================================== +// RevSparseHesCase +/*! +Private helper function for RevSparseHes(q, s) bool sparsity. + +All of the description in the public member function RevSparseHes(q, s) +applies. + +\param set_type +is a bool value. This argument is used to dispatch to the proper source +code depending on the vlaue of SetVector::value_type. + +\param transpose +See RevSparseHes(q, s). + +\param q +See RevSparseHes(q, s). + +\param s +See RevSparseHes(q, s). + +\param h +is the return value for the corresponging call to RevSparseJac(q, s). +*/ +template +template +void ADFun::RevSparseHesCase( + bool set_type , + bool transpose , + size_t q , + const SetVector& s , + SetVector& h ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + size_t n = Domain(); + size_t m = Range(); + // + h.resize(q * n ); + + 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_ ); + // + // temporary indices + size_t i, j; + + // check Vector is Simple SetVector class with bool elements + CheckSimpleVector(); + + CPPAD_ASSERT_KNOWN( + q == for_jac_sparse_pack_.end(), + "RevSparseHes: q is not equal to its value\n" + "in the previous call to ForSparseJac with this ADFun object." + ); + CPPAD_ASSERT_KNOWN( + size_t(s.size()) == m, + "RevSparseHes: size of s is not equal to\n" + "range dimension for ADFun object." + ); + + // Array that will hold reverse Jacobian dependency flag. + // Initialize as true for the dependent variables. + local::pod_vector RevJac(num_var_tape_); + for(i = 0; i < num_var_tape_; i++) + RevJac[i] = false; + for(i = 0; i < m; i++) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + RevJac[ dep_taddr_[i] ] = s[i]; + } + + // vector of sets that will hold reverse Hessain values + local::sparse_pack rev_hes_pattern; + rev_hes_pattern.resize(num_var_tape_, q); + + // compute the Hessian sparsity patterns + local::sweep::rev_hes( + &play_, + n, + num_var_tape_, + for_jac_sparse_pack_, + RevJac.data(), + rev_hes_pattern, + not_used_rec_base + + ); + + // 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++) + { if( transpose ) + h[ j * q + i ] = false; + else + h[ i * n + j ] = false; + } + } + + // j is index corresponding to reverse mode partial + for(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] ) == local::InvOp ); + + // extract the result from rev_hes_pattern + CPPAD_ASSERT_UNKNOWN( rev_hes_pattern.end() == q ); + local::sparse_pack::const_iterator itr(rev_hes_pattern, j + 1); + i = *itr; + while( i < q ) + { if( transpose ) + h[ j * q + i ] = true; + else + h[ i * n + j ] = true; + i = *(++itr); + } + } +} +/*! +Private helper function for RevSparseHes(q, s) set sparsity. + +All of the description in the public member function RevSparseHes(q, s) +applies. + +\param set_type +is a std::set value. +This argument is used to dispatch to the proper source +code depending on the vlaue of SetVector::value_type. + +\param transpose +See RevSparseHes(q, s). + +\param q +See RevSparseHes(q, s). + +\param s +See RevSparseHes(q, s). + +\param h +is the return value for the corresponging call to RevSparseJac(q, s). +*/ +template +template +void ADFun::RevSparseHesCase( + const std::set& set_type , + bool transpose , + size_t q , + const SetVector& s , + SetVector& h ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + size_t n = Domain(); +# ifndef NDEBUG + size_t m = Range(); +# endif + // + if( transpose ) + h.resize(n); + else + h.resize(q); + + 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_ ); + // + // temporary indices + size_t i, j; + std::set::const_iterator itr_1; + + // check SetVector is Simple Vector class with sets for elements + CheckSimpleVector, SetVector>( + local::one_element_std_set(), local::two_element_std_set() + ); + + CPPAD_ASSERT_KNOWN( + q == for_jac_sparse_set_.end(), + "RevSparseHes: q is not equal to its value\n" + "in the previous call to ForSparseJac with this ADFun object." + ); + CPPAD_ASSERT_KNOWN( + s.size() == 1, + "RevSparseHes: size of s is not equal to one." + ); + + // Array that will hold reverse Jacobian dependency flag. + // Initialize as true for the dependent variables. + local::pod_vector RevJac(num_var_tape_); + for(i = 0; i < num_var_tape_; i++) + RevJac[i] = false; + itr_1 = s[0].begin(); + while( itr_1 != s[0].end() ) + { i = *itr_1++; + CPPAD_ASSERT_KNOWN( + i < m, + "RevSparseHes: an element of the set s[0] has value " + "greater than or equal m" + ); + CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + RevJac[ dep_taddr_[i] ] = true; + } + + + // vector of sets that will hold reverse Hessain values + local::sparse_list rev_hes_pattern; + rev_hes_pattern.resize(num_var_tape_, q); + + // compute the Hessian sparsity patterns + local::sweep::rev_hes( + &play_, + n, + num_var_tape_, + for_jac_sparse_set_, + RevJac.data(), + rev_hes_pattern, + not_used_rec_base + + ); + + // return values corresponding to independent variables + // j is index corresponding to reverse mode partial + CPPAD_ASSERT_UNKNOWN( size_t(h.size()) == q || transpose ); + CPPAD_ASSERT_UNKNOWN( size_t(h.size()) == n || ! transpose ); + for(j = 0; j < n; j++) + { CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] < num_var_tape_ ); + CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] == j + 1 ); + CPPAD_ASSERT_UNKNOWN( play_.GetOp( ind_taddr_[j] ) == local::InvOp ); + + // extract the result from rev_hes_pattern + // and add corresponding elements to result sets in h + CPPAD_ASSERT_UNKNOWN( rev_hes_pattern.end() == q ); + local::sparse_list::const_iterator itr_2(rev_hes_pattern, j+1); + i = *itr_2; + while( i < q ) + { if( transpose ) + h[j].insert(i); + else + h[i].insert(j); + i = *(++itr_2); + } + } +} + +// =========================================================================== +// RevSparseHes + +/*! +User API for Hessian sparsity patterns using reverse mode. + +The C++ source code corresponding to this operation is +\verbatim + h = f.RevSparseHes(q, r) +\endverbatim + +\tparam Base +is the base type for this recording. + +\tparam SetVector +is a simple vector with elements of type bool +or std::set. + +\param transpose +is true (false) if is 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 x 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, packed) +\endverbatim +The value r in this call is a sparsity pattern for the matrix \f$ R \f$. +The type of the element of r for the previous call to ForSparseJac +must be the same as the type of the elements of s. + +\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. + +\return +If 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) +\f] +where \f$ F \f$ is the function corresponding to the operation sequence +and x is any argument value. +*/ + +template +template +SetVector ADFun::RevSparseHes( + size_t q, const SetVector& s, bool transpose +) +{ + SetVector h; + typedef typename SetVector::value_type Set_type; + + // Should check to make sure q is same as in previous call to + // forward sparse Jacobian. + RevSparseHesCase( + Set_type() , + transpose , + q , + s , + h + ); + + return h; +} +// =========================================================================== +// 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 , + local::sparse_list& h ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + 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. + local::pod_vector RevJac(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 + local::sparse_list rev_hes_pattern; + rev_hes_pattern.resize(num_var_tape_, q); + + // compute Hessian sparsity pattern for all variables + local::sweep::rev_hes( + &play_, + n, + num_var_tape_, + for_jac_sparse_set_, + RevJac.data(), + rev_hes_pattern, + not_used_rec_base + + ); + + // 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] ) == local::InvOp ); + + // extract the result from rev_hes_pattern + CPPAD_ASSERT_UNKNOWN( rev_hes_pattern.end() == q ); + local::sparse_list::const_iterator itr(rev_hes_pattern, j + 1); + size_t i = *itr; + while( i < q ) + { if( transpose ) + h.post_element(j, i); + else + h.post_element(i, j); + i = *(++itr); + } + } + for(size_t i = 0; i < h.n_set(); ++i) + h.process_post(i); +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/rev_sparse_jac.hpp cppad-2019.02.00.0/include/cppad/core/rev_sparse_jac.hpp --- cppad-2018.00.00.0/include/cppad/core/rev_sparse_jac.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/rev_sparse_jac.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,654 @@ +# ifndef CPPAD_CORE_REV_SPARSE_JAC_HPP +# define CPPAD_CORE_REV_SPARSE_JAC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin RevSparseJac$$ +$spell + optimizer + nz + CondExpRel + std + VecAD + var + Jacobian + Jac + const + Bool + Dep + proportional +$$ + +$section Jacobian Sparsity Pattern: Reverse Mode$$ + +$head Syntax$$ +$icode%s% = %f%.RevSparseJac(%q%, %r%) +%$$ +$icode%s% = %f%.RevSparseJac(%q%, %r%, %transpose%, %dependency%)%$$ + +$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}^{q \times m}$$, +the Jacobian of $latex R * F( x )$$ +with respect to $latex x$$ is +$latex \[ + S(x) = R * F^{(1)} ( x ) +\] $$ +Given a +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ +for $latex R$$, +$code RevSparseJac$$ returns a sparsity pattern for the $latex S(x)$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ + +$head x$$ +If the operation sequence in $icode f$$ is +$cref/independent/glossary/Operation/Independent/$$ of +the independent variables in $latex x \in \B{R}^n$$, +the sparsity pattern is valid for all values of +(even if it has $cref CondExp$$ or $cref VecAD$$ operations). + +$head q$$ +The argument $icode q$$ has prototype +$codei% + size_t %q% +%$$ +It specifies the number of rows in +$latex R \in \B{R}^{q \times m}$$ and the +Jacobian $latex S(x) \in \B{R}^{q \times n}$$. + +$head transpose$$ +The argument $icode transpose$$ has prototype +$codei% + bool %transpose% +%$$ +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 s$$ has prototype +$codei% + const %SetVector%& %r% +%$$ +see $cref/SetVector/RevSparseJac/SetVector/$$ below. + +$subhead transpose false$$ +If $icode r$$ has elements of type $code bool$$, +its size is $latex q * m$$. +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/$$ +for the matrix $latex R \in \B{R}^{q \times m}$$. + +$subhead transpose true$$ +If $icode r$$ has elements of type $code bool$$, +its size is $latex m * q$$. +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/$$ +for the matrix $latex R^\R{T} \in \B{R}^{m \times q}$$. + +$head s$$ +The return value $icode s$$ has prototype +$codei% + %SetVector% %s% +%$$ +see $cref/SetVector/RevSparseJac/SetVector/$$ below. + +$subhead transpose false$$ +If it has elements of type $code bool$$, +its size is $latex q * n$$. +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/$$ +for the matrix $latex S(x) \in {q \times n}$$. + +$subhead transpose true$$ +If it has elements of type $code bool$$, +its size is $latex n * q$$. +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/$$ +for the matrix $latex S(x)^\R{T} \in {n \times q}$$. + +$head SetVector$$ +The type $icode SetVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code bool$$ or $code std::set$$; +see $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for a discussion +of the difference. + +$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 +sparsity pattern for the Jacobian $latex S(x) = F^{(1)} ( x )$$. + +$head Example$$ +$children% + example/sparse/rev_sparse_jac.cpp +%$$ +The file +$cref rev_sparse_jac.cpp$$ +contains an example and test of this operation. + +$end +----------------------------------------------------------------------------- +*/ + +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file core/rev_sparse_jac.hpp +Reverse mode Jacobian sparsity patterns. +*/ +// ========================================================================= +// RevSparseJacCase + +/*! +Private helper function for RevSparseJac(q, r, transpose) boolean sparsity. + +All of the description in the public member function + RevSparseJac(q, r, transpose) apply. + +\param set_type +is a bool value. +This argument is used to dispatch to the proper source code +depending on the value of SetVector::value_type. + +\param transpose +See RevSparseJac(q, r, transpose, dependency) + +\param dependency +See RevSparseJac(q, r, transpose, dependency) + +\param q +See RevSparseJac(q, r, transpose, dependency) + +\param r +See RevSparseJac(q, r, transpose, dependency) + +\param s +is the return value for the corresponding call to +RevSparseJac(q, r, transpose). +*/ + +template +template +void ADFun::RevSparseJacCase( + bool set_type , + bool transpose , + bool dependency , + size_t q , + const SetVector& r , + SetVector& s ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + size_t n = Domain(); + size_t m = Range(); + + // dimension of the result vector + s.resize( q * n ); + + // check SetVector is Simple Vector class with bool elements + CheckSimpleVector(); + // + CPPAD_ASSERT_KNOWN( + q > 0, + "RevSparseJac: q is not greater than zero" + ); + CPPAD_ASSERT_KNOWN( + size_t(r.size()) == q * m, + "RevSparseJac: size of r is not equal to\n" + "q times range dimension for ADFun object." + ); + // + // vector of sets that will hold the results + local::sparse_pack var_sparsity; + var_sparsity.resize(num_var_tape_, q); + + // The sparsity pattern corresponding to the dependent variables + for(size_t i = 0; i < m; i++) + { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + if( transpose ) + { for(size_t j = 0; j < q; j++) if( r[ i * q + j ] ) + var_sparsity.post_element( dep_taddr_[i], j ); + } + else + { for(size_t j = 0; j < q; j++) if( r[ j * m + i ] ) + var_sparsity.post_element( dep_taddr_[i], j ); + } + } + // process posts + for(size_t i = 0; i < m; i++) + var_sparsity.process_post( dep_taddr_[i] ); + + // evaluate the sparsity patterns + local::sweep::rev_jac( + &play_, + dependency, + n, + num_var_tape_, + var_sparsity, + not_used_rec_base + + ); + + // return values corresponding to dependent variables + CPPAD_ASSERT_UNKNOWN( size_t(s.size()) == q * n ); + 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] ) == local::InvOp ); + + // extract the result from var_sparsity + if( transpose ) + { for(size_t i = 0; i < q; i++) + s[ j * q + i ] = false; + } + else + { for(size_t i = 0; i < q; i++) + s[ i * n + j ] = false; + } + CPPAD_ASSERT_UNKNOWN( var_sparsity.end() == q ); + local::sparse_pack::const_iterator itr(var_sparsity, j+1); + size_t i = *itr; + while( i < q ) + { if( transpose ) + s[ j * q + i ] = true; + else + s[ i * n + j ] = true; + i = *(++itr); + } + } +} + +/*! +Private helper function for RevSparseJac(q, r, transpose) set sparsity + +All of the description in the public member function + RevSparseJac(q, r, transpose) apply. + +\param set_type +is a std::set object. +This argument is used to dispatch to the proper source code +depending on the value of SetVector::value_type. + +\param transpose +See RevSparseJac(q, r, transpose, dependency) + +\param dependency +See RevSparseJac(q, r, transpose, dependency) + +\param q +See RevSparseJac(q, r, transpose, dependency) + +\param r +See RevSparseJac(q, r, transpose, dependency) + +\param s +is the return value for the corresponding call to RevSparseJac(q, r, transpose) +*/ + +template +template +void ADFun::RevSparseJacCase( + const std::set& set_type , + bool transpose , + bool dependency , + size_t q , + const SetVector& r , + SetVector& s ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + // dimension of the result vector + if( transpose ) + s.resize( Domain() ); + else + s.resize( q ); + + // temporary indices + std::set::const_iterator itr_1; + + // check SetVector is Simple Vector class with sets for elements + CheckSimpleVector, SetVector>( + local::one_element_std_set(), local::two_element_std_set() + ); + + // domain dimensions for F + size_t n = ind_taddr_.size(); + size_t m = dep_taddr_.size(); + + CPPAD_ASSERT_KNOWN( + q > 0, + "RevSparseJac: q is not greater than zero" + ); + CPPAD_ASSERT_KNOWN( + size_t(r.size()) == q || transpose, + "RevSparseJac: size of r is not equal to q and transpose is false." + ); + CPPAD_ASSERT_KNOWN( + size_t(r.size()) == m || ! transpose, + "RevSparseJac: size of r is not equal to m and transpose is true." + ); + + // vector of lists that will hold the results + local::sparse_list var_sparsity; + var_sparsity.resize(num_var_tape_, q); + + // The sparsity pattern corresponding to the dependent variables + if( transpose ) + { for(size_t i = 0; i < m; i++) + { itr_1 = r[i].begin(); + while(itr_1 != r[i].end()) + { size_t j = *itr_1++; + CPPAD_ASSERT_KNOWN( + j < q, + "RevSparseJac: transpose is true and element of the set\n" + "r[i] has value greater than or equal q." + ); + CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < num_var_tape_ ); + var_sparsity.post_element( dep_taddr_[i], j ); + } + } + } + else + { for(size_t i = 0; i < q; i++) + { itr_1 = r[i].begin(); + while(itr_1 != r[i].end()) + { size_t j = *itr_1++; + CPPAD_ASSERT_KNOWN( + j < m, + "RevSparseJac: transpose is false and element of the set\n" + "r[i] has value greater than or equal range dimension." + ); + CPPAD_ASSERT_UNKNOWN( dep_taddr_[j] < num_var_tape_ ); + var_sparsity.post_element( dep_taddr_[j], i ); + } + } + } + // process posts + for(size_t i = 0; i < m; i++) + var_sparsity.process_post( dep_taddr_[i] ); + + // evaluate the sparsity patterns + local::sweep::rev_jac( + &play_, + dependency, + n, + num_var_tape_, + var_sparsity, + not_used_rec_base + + ); + + // return values corresponding to dependent variables + CPPAD_ASSERT_UNKNOWN( size_t(s.size()) == q || transpose ); + CPPAD_ASSERT_UNKNOWN( size_t(s.size()) == n || ! transpose ); + 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] ) == local::InvOp ); + + CPPAD_ASSERT_UNKNOWN( var_sparsity.end() == q ); + local::sparse_list::const_iterator itr_2(var_sparsity, j+1); + size_t i = *itr_2; + while( i < q ) + { if( transpose ) + s[j].insert(i); + else + s[i].insert(j); + i = *(++itr_2); + } + } +} + +// ========================================================================= +// 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, dependency) +\endverbatim + +\tparam Base +is the base type for this recording. + +\tparam SetVector +is a simple vector with elements of type bool. +or std::set. + +\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. + + +\return +If transpose is false (true), the return value is a sparsity pattern +for \f$ S(x) \f$ (\f$ S(x)^T \f$) where +\f[ + S(x) = R * F^{(1)} (x) +\f] +and \f$ F \f$ is the function corresponding to the operation sequence +and x is any argument value. +If SetVector::value_type is bool, +the return value has size \f$ q * n \f$ ( \f$ n * q \f$). +If SetVector::value_type is std::set, +the return value has size \f$ q \f$ ( \f$ n \f$) +and with all its elements between zero and \f$ n - 1 \f$ (\f$ q - 1 \f$). +*/ +template +template +SetVector ADFun::RevSparseJac( + size_t q , + const SetVector& r , + bool transpose , + bool dependency ) +{ + SetVector s; + typedef typename SetVector::value_type Set_type; + + RevSparseJacCase( + Set_type() , + transpose , + 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 , + const local::sparse_list& r , + bool transpose , + bool dependency , + local::sparse_list& s ) +{ + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + 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 + local::sparse_list 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++) + { local::sparse_list::const_iterator itr(r, i); + size_t j = *itr; + while( j < q ) + { var_sparsity.post_element( dep_taddr_[i], j ); + j = *(++itr); + } + } + } + else + { for(size_t j = 0; j < q; j++) + { local::sparse_list::const_iterator itr(r, j); + size_t i = *itr; + while( i < m ) + { var_sparsity.post_element( dep_taddr_[i], j ); + i = *(++itr); + } + } + } + // process posts + for(size_t i = 0; i < m; i++) + var_sparsity.process_post( dep_taddr_[i] ); + + // evaluate the sparsity pattern for all variables + local::sweep::rev_jac( + &play_, + dependency, + n, + num_var_tape_, + var_sparsity, + not_used_rec_base + + ); + + // 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] ) == local::InvOp ); + + // extract the result from var_sparsity + CPPAD_ASSERT_UNKNOWN( var_sparsity.end() == q ); + local::sparse_list::const_iterator itr(var_sparsity, j+1); + size_t i = *itr; + while( i < q ) + { if( transpose ) + s.post_element(j, i); + else + s.post_element(i, j); + i = *(++itr); + } + } + // process posts + for(size_t i = 0; i < s.n_set(); i++) + s.process_post(i); + +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/rev_two.hpp cppad-2019.02.00.0/include/cppad/core/rev_two.hpp --- cppad-2018.00.00.0/include/cppad/core/rev_two.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/rev_two.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,234 @@ +# ifndef CPPAD_CORE_REV_TWO_HPP +# define CPPAD_CORE_REV_TWO_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin RevTwo$$ +$spell + ddw + typename + Taylor + const +$$ + + + + + +$section Reverse Mode Second Partial Derivative Driver$$ + +$head Syntax$$ +$icode%ddw% = %f%.RevTwo(%x%, %i%, %j%)%$$ + + +$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$$. +The syntax above sets +$latex \[ + ddw [ k * p + \ell ] + = + \DD{ F_{i[ \ell ]} }{ x_{j[ \ell ]} }{ x_k } (x) +\] $$ +for $latex k = 0 , \ldots , n-1$$ +and $latex \ell = 0 , \ldots , p$$, +where $latex p$$ is the size of the vectors $icode i$$ and $icode j$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the $cref ADFun$$ object $icode f$$ is not $code const$$ +(see $cref/RevTwo Uses Forward/RevTwo/RevTwo Uses Forward/$$ below). + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %BaseVector% &%x% +%$$ +(see $cref/BaseVector/RevTwo/BaseVector/$$ below) +and its size +must be equal to $icode n$$, the dimension of the +$cref/domain/seq_property/Domain/$$ space for $icode f$$. +It specifies +that point at which to evaluate the partial derivatives listed above. + +$head i$$ +The argument $icode i$$ has prototype +$codei% + const %SizeVector_t% &%i% +%$$ +(see $cref/SizeVector_t/RevTwo/SizeVector_t/$$ below) +We use $icode p$$ to denote the size of the vector $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$$. + +$head j$$ +The argument $icode j$$ has prototype +$codei% + const %SizeVector_t% &%j% +%$$ +(see $cref/SizeVector_t/RevTwo/SizeVector_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$$ +must be less than $icode n$$; i.e., +for $latex \ell = 0 , \ldots , p-1$$, $latex j[ \ell ] < n$$. + +$head ddw$$ +The result $icode ddw$$ has prototype +$codei% + %BaseVector% %ddw% +%$$ +(see $cref/BaseVector/RevTwo/BaseVector/$$ below) +and its size is $latex n * p$$. +It contains the requested partial derivatives; to be specific, +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) +\] $$ + +$head BaseVector$$ +The type $icode BaseVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type Base/SimpleVector/Elements of Specified Type/$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head SizeVector_t$$ +The type $icode SizeVector_t$$ 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 RevTwo Uses Forward$$ +After each call to $cref Forward$$, +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 +$icode%f%.Forward(0, %x%)%$$ +and the other coefficients are unspecified. + +$head Examples$$ +$children% + example/general/rev_two.cpp +%$$ +The routine +$cref/RevTwo/rev_two.cpp/$$ is both an example and test. +It returns $code true$$, if it succeeds and $code false$$ otherwise. + +$end +----------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +template +template +BaseVector ADFun::RevTwo( + const BaseVector &x, + const SizeVector_t &i, + const SizeVector_t &j) +{ size_t i1; + size_t j1; + size_t k; + size_t l; + + size_t n = Domain(); + size_t m = Range(); + size_t p = i.size(); + + // check BaseVector is Simple Vector class with Base elements + CheckSimpleVector(); + + // check SizeVector_t is Simple Vector class with size_t elements + CheckSimpleVector(); + + 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." + ); + // point at which we are evaluating the second partials + Forward(0, x); + + // dimension the return value + BaseVector ddw(n * p); + + // direction vector in argument space + BaseVector dx(n); + for(j1 = 0; j1 < n; j1++) + dx[j1] = Base(0.0); + + // direction vector in range space + BaseVector w(m); + for(i1 = 0; i1 < m; i1++) + w[i1] = Base(0.0); + + // place to hold the results of a reverse calculation + BaseVector r(n * 2); + + // check the indices in i and j + for(l = 0; l < p; l++) + { i1 = i[l]; + j1 = j[l]; + CPPAD_ASSERT_KNOWN( + i1 < m, + "RevTwo: an eleemnt of i not less than range dimension for f." + ); + CPPAD_ASSERT_KNOWN( + j1 < n, + "RevTwo: an element of j not less than domain dimension for f." + ); + } + + // 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 ) + { first_done = true; + + // first order forward mode in j1 direction + dx[j1] = Base(1.0); + Forward(1, dx); + dx[j1] = Base(0.0); + } + // execute a reverse in this component direction + i1 = i[l]; + w[i1] = Base(1.0); + r = Reverse(2, w); + w[i1] = Base(0.0); + + // place the reverse result in return value + for(k = 0; k < n; k++) + ddw[k * p + l] = r[k * 2 + 1]; + } + } + return ddw; +} + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/sign.hpp cppad-2019.02.00.0/include/cppad/core/sign.hpp --- cppad-2018.00.00.0/include/cppad/core/sign.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/sign.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,121 @@ +# ifndef CPPAD_CORE_SIGN_HPP +# define CPPAD_CORE_SIGN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin sign$$ +$spell + CppAD + Dirac +$$ +$section The Sign: sign$$ + +$head Syntax$$ +$icode%y% = sign(%x%)%$$ + +$head Description$$ +Evaluates the $code sign$$ function which is defined by +$latex \[ +{\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. +\] $$ + +$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$$ +CppAD computes the derivative of the $code sign$$ function as zero for all +argument values $icode x$$. +The correct mathematical derivative is different and +is given by +$latex \[ + {\rm sign}^{(1)} (x) = 2 \delta (x) +\] $$ +where $latex \delta (x)$$ is the Dirac Delta function. + +$head Example$$ +$children% + example/general/sign.cpp +%$$ +The file +$cref sign.cpp$$ +contains an example and test of this function. + +$end +------------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +template +AD AD::sign_me (void) const +{ + AD result; + result.value_ = sign(value_); + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); + + // check if there is a recording in progress + local::ADTape* tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return result; + + // check if operand is a constant parameter + if( tape_id_ != tape->id_ ) + return result; + + if(ad_type_ == dynamic_enum) + { // dynamic paramter argument + result.taddr_ = tape->Rec_.put_dyn_par( + result.value_, local::sign_dyn, taddr_ + ); + result.tape_id_ = tape_id_; + result.ad_type_ = dynamic_enum; + } + else + { // variable argument + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::SignOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::SignOp) == 1 ); + + // corresponding operand address + tape->Rec_.PutArg(taddr_); + + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::SignOp); + + // make result a variable + result.tape_id_ = tape->id_; + result.ad_type_ = variable_enum; + } + return result; +} + +template +AD sign(const AD &x) +{ return x.sign_me(); +} +template +AD sign(const VecAD_reference &x) +{ return x.ADBase().sign_me(); } + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/sparse_hes.hpp cppad-2019.02.00.0/include/cppad/core/sparse_hes.hpp --- cppad-2018.00.00.0/include/cppad/core/sparse_hes.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/sparse_hes.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,544 @@ +# ifndef CPPAD_CORE_SPARSE_HES_HPP +# define CPPAD_CORE_SPARSE_HES_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin sparse_hes$$ +$spell + const + Taylor + rc + rcv + nr + nc + hes + std + cppad + colpack + cmake + Jacobian +$$ + +$section Computing Sparse Hessians$$ + +$head Syntax$$ +$icode%n_sweep% = %f%.sparse_hes( + %x%, %w%, %subset%, %pattern%, %coloring%, %work% +)%$$ + +$head Purpose$$ +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the +function corresponding to $icode f$$. +Here $icode n$$ is the $cref/domain/seq_property/Domain/$$ size, +and $icode m$$ is the $cref/range/seq_property/Range/$$ size, or $icode f$$. +The syntax above takes advantage of sparsity when computing the Hessian +$latex \[ + H(x) = \dpow{2}{x} \sum_{i=0}^{m-1} w_i F_i (x) +\] $$ +In the sparse case, this should be faster and take less memory than +$cref Hessian$$. +The matrix element $latex H_{i,j} (x)$$ is the second partial of +$latex w^\R{T} F (x)$$ with respect to $latex x_i$$ and $latex x_j$$. + +$head SizeVector$$ +The type $icode SizeVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. + +$head BaseVector$$ +The type $icode BaseVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. + +$head f$$ +This object has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the Taylor coefficients stored in $icode f$$ are affected +by this operation; see +$cref/uses forward/sparse_hes/Uses Forward/$$ below. + +$head x$$ +This argument has prototype +$codei% + const %BaseVector%& %x% +%$$ +and its size is $icode n$$. +It specifies the point at which to evaluate the Hessian +$latex H(x)$$. + +$head w$$ +This argument has prototype +$codei% + const %BaseVector%& %w% +%$$ +and its size is $icode m$$. +It specifies the weight for each of the components of $latex F(x)$$; +i.e. $latex w_i$$ is the weight for $latex F_i (x)$$. + +$head subset$$ +This argument has prototype +$codei% + sparse_rcv<%SizeVector%, %BaseVector%>& %subset% +%$$ +Its row size and column size is $icode n$$; i.e., +$icode%subset%.nr() == %n%$$ and $icode%subset%.nc() == %n%$$. +It specifies which elements of the Hessian are computed. +$list number$$ +The input value of its value vector +$icode%subset%.val()%$$ does not matter. +Upon return it contains the value of the corresponding elements +of the Hessian. +$lnext +All of the row, column pairs in $icode subset$$ must also appear in +$icode pattern$$; i.e., they must be possibly non-zero. +$lnext +The Hessian is symmetric, so one has a choice as to which off diagonal +elements to put in $icode subset$$. +It will probably be more efficient if one makes this choice so that +the there are more entries in each non-zero column of $icode subset$$; +see $cref/n_sweep/sparse_hes/n_sweep/$$ below. +$lend + +$head pattern$$ +This argument has prototype +$codei% + const sparse_rc<%SizeVector%>& %pattern% +%$$ +Its row size and column size is $icode n$$; i.e., +$icode%pattern%.nr() == %n%$$ and $icode%pattern%.nc() == %n%$$. +It is a sparsity pattern for the Hessian $latex H(x)$$. +If the $th i$$ row ($th j$$ column) does not appear in $icode subset$$, +the $th i$$ row ($th j$$ column) of $icode pattern$$ does not matter +and need not be computed. +This argument is not used (and need not satisfy any conditions), +when $cref/work/sparse_hes/work/$$ is non-empty. + +$subhead subset$$ +If the $th i$$ row and $th i$$ column do not appear in $icode subset$$, +the $th i$$ row and column of $icode pattern$$ do not matter. +In this case the $th i-th$$ row and column may have no entries in +$icode pattern$$ even though they are possibly non-zero in $latex H(x)$$. +(This can be used to reduce the amount of computation required to find +$icode pattern$$.) + +$head coloring$$ +The coloring algorithm determines which rows and columns +can be computed during the same sweep. +This field has prototype +$codei% + const std::string& %coloring% +%$$ +This value only matters when work is empty; i.e., +after the $icode work$$ constructor or $icode%work%.clear()%$$. + +$subhead cppad.symmetric$$ +This coloring takes advantage of the fact that the Hessian matrix +is symmetric when find a coloring that requires fewer +$cref/sweeps/sparse_hes/n_sweep/$$. + +$subhead cppad.general$$ +This is the same as the sparse Jacobian +$cref/cppad/sparse_jac/coloring/cppad/$$ method +which does not take advantage of symmetry. + +$subhead colpack.symmetric$$ +If $cref colpack_prefix$$ was specified on the +$cref/cmake command/cmake/CMake Command/$$ line, +you can set $icode coloring$$ to $code colpack.symmetric$$. +This also takes advantage of the fact that the Hessian matrix is symmetric. + +$subhead colpack.general$$ +If $cref colpack_prefix$$ was specified on the +$cref/cmake command/cmake/CMake Command/$$ line, +you can set $icode coloring$$ to $code colpack.general$$. +This is the same as the sparse Jacobian +$cref/colpack/sparse_jac/coloring/colpack/$$ method +which does not take advantage of symmetry. + +$subhead colpack.star Deprecated 2017-06-01$$ +The $code colpack.star$$ method is deprecated. +It is the same as the $code colpack.symmetric$$ method +which should be used instead. + + +$head work$$ +This argument has prototype +$codei% + sparse_hes_work& %work% +%$$ +We refer to its initial value, +and its value after $icode%work%.clear()%$$, as empty. +If it is empty, information is stored in $icode work$$. +This can be used to reduce computation when +a future call is for the same object $icode f$$, +and the same subset of the Hessian. +In fact, it can be used with a different $icode f$$ +and a different $icode subset$$ provided that Hessian sparsity pattern +for $icode f$$ and the sparsity pattern in $icode subset$$ are the same. +If either of these values change, use $icode%work%.clear()%$$ to +empty this structure. + +$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 +used to compute the requested Hessian values. +Each first forward sweep is followed by a second order reverse sweep +so it is also the number of reverse sweeps. +It is also the number of colors determined by the coloring method +mentioned above. +This is proportional to the total computational work, +not counting the zero order forward sweep, +or combining multiple columns and rows into a single sweep. + +$head Uses Forward$$ +After each call to $cref Forward$$, +the object $icode f$$ contains the corresponding +$cref/Taylor coefficients/glossary/Taylor Coefficient/$$. +After a call to $code sparse_hes$$ +the zero order coefficients correspond to +$codei% + %f%.Forward(0, %x%) +%$$ +All the other forward mode coefficients are unspecified. + +$head Example$$ +$children% + example/sparse/sparse_hes.cpp +%$$ +The files $cref sparse_hes.cpp$$ +is an example and test of $code sparse_hes$$. +It returns $code true$$, if it succeeds, and $code false$$ otherwise. + +$head Subset Hessian$$ +The routine +$cref sparse_sub_hes.cpp$$ +is an example and test that compute a subset of a sparse Hessian. +It returns $code true$$, for success, and $code false$$ otherwise. + +$end +*/ +# include +# include +# include +# include + +/*! +\file sparse_hes.hpp +Sparse Hessian calculation routines. +*/ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +Class used to hold information used by Sparse Hessian routine in this file, +so it does not need to be recomputed every time. +*/ +class sparse_hes_work { + public: + /// row and column indicies for return values + /// (some may be reflected by symmetric coloring algorithms) + CppAD::vector row; + CppAD::vector col; + /// indices that sort the row and col arrays by color + CppAD::vector order; + /// results of the coloring algorithm + CppAD::vector color; + + /// constructor + sparse_hes_work(void) + { } + /// inform CppAD that this information needs to be recomputed + void clear(void) + { + row.clear(); + col.clear(); + order.clear(); + color.clear(); + } +}; +// ---------------------------------------------------------------------------- +/*! +Calculate sparse Hessians using forward mode + +\tparam Base +the base type for the recording that is stored in the ADFun object. + +\tparam SizeVector +a simple vector class with elements of type size_t. + +\tparam BaseVector +a simple vector class with elements of type Base. + +\param x +a vector of length n, the number of independent variables in f +(this ADFun object). + +\param w +a vector of length m, the number of dependent variables in f +(this ADFun object). + +\param subset +specifices the subset of the sparsity pattern where the Hessian is evaluated. +subset.nr() == n, +subset.nc() == n. + +\param pattern +is a sparsity pattern for the Hessian of w^T * f; +pattern.nr() == n, +pattern.nc() == n, +where m is number of dependent variables in f. + +\param coloring +determines which coloring algorithm is used. +This must be cppad.symmetric, cppad.general, colpack.symmetic, +or colpack.star. + +\param work +this structure must be empty, or contain the information stored +by a previous call to sparse_hes. +The previous call must be for the same ADFun object f +and the same subset. + +\return +This is the number of first order forward +(and second order reverse) sweeps used to compute thhe Hessian. +*/ +template +template +size_t ADFun::sparse_hes( + const BaseVector& x , + const BaseVector& w , + sparse_rcv& subset , + const sparse_rc& pattern , + const std::string& coloring , + sparse_hes_work& work ) +{ size_t n = Domain(); + // + CPPAD_ASSERT_KNOWN( + subset.nr() == n, + "sparse_hes: subset.nr() not equal domain dimension for f" + ); + CPPAD_ASSERT_KNOWN( + subset.nc() == n, + "sparse_hes: subset.nc() not equal domain dimension for f" + ); + CPPAD_ASSERT_KNOWN( + size_t( x.size() ) == n, + "sparse_hes: x.size() not equal domain dimension for f" + ); + CPPAD_ASSERT_KNOWN( + size_t( w.size() ) == Range(), + "sparse_hes: w.size() not equal range dimension for f" + ); + // + // work information + vector& row(work.row); + vector& col(work.col); + vector& color(work.color); + vector& order(work.order); + // + // subset information + const SizeVector& subset_row( subset.row() ); + const SizeVector& subset_col( subset.col() ); + // + // point at which we are evaluationg the Hessian + Forward(0, x); + // + // number of elements in the subset + size_t K = subset.nnz(); + // + // check for case were there is nothing to do + // (except for call to Forward(0, x) + if( K == 0 ) + return 0; + // +# ifndef NDEBUG + if( color.size() != 0 ) + { CPPAD_ASSERT_KNOWN( + color.size() == n, + "sparse_hes: work is non-empty and conditions have changed" + ); + CPPAD_ASSERT_KNOWN( + row.size() == K, + "sparse_hes: work is non-empty and conditions have changed" + ); + CPPAD_ASSERT_KNOWN( + col.size() == K, + "sparse_hes: work is non-empty and conditions have changed" + ); + // + for(size_t k = 0; k < K; k++) + { bool ok = row[k] == subset_row[k] && col[k] == subset_col[k]; + ok |= row[k] == subset_col[k] && col[k] == subset_row[k]; + CPPAD_ASSERT_KNOWN( + ok, + "sparse_hes: work is non-empty and conditions have changed" + ); + } + } +# endif + // + // check for case where input work is empty + if( color.size() == 0 ) + { // compute work color and order vectors + CPPAD_ASSERT_KNOWN( + pattern.nr() == n, + "sparse_hes: pattern.nr() not equal domain dimension for f" + ); + CPPAD_ASSERT_KNOWN( + pattern.nc() == n, + "sparse_hes: pattern.nc() not equal domain dimension for f" + ); + // + // initialize work row, col to be same as subset row, col + row.resize(K); + col.resize(K); + // cannot assign vectors becasue may be of different types + // (SizeVector and CppAD::vector) + for(size_t k = 0; k < K; k++) + { row[k] = subset_row[k]; + col[k] = subset_col[k]; + } + // + // convert pattern to an internal version of its transpose + local::pod_vector internal_index(n); + for(size_t j = 0; j < n; j++) + internal_index[j] = j; + bool transpose = true; + bool zero_empty = false; + bool input_empty = true; + local::sparse_list internal_pattern; + internal_pattern.resize(n, n); + local::set_internal_sparsity(zero_empty, input_empty, + transpose, internal_index, internal_pattern, pattern + ); + // + // execute coloring algorithm + // (we are using transpose becasue coloring groups rows, not columns) + color.resize(n); + if( coloring == "cppad.general" ) + local::color_general_cppad(internal_pattern, col, row, color); + else if( coloring == "cppad.symmetric" ) + local::color_symmetric_cppad(internal_pattern, col, row, color); + else if( coloring == "colpack.general" ) + { +# if CPPAD_HAS_COLPACK + local::color_general_colpack(internal_pattern, col, row, color); +# else + CPPAD_ASSERT_KNOWN( + false, + "sparse_hes: coloring = colpack.star " + "and colpack_prefix not in cmake command line." + ); +# endif + } + else if( + coloring == "colpack.symmetric" || + coloring == "colpack.star" + ) + { +# if CPPAD_HAS_COLPACK + local::color_symmetric_colpack(internal_pattern, col, row, color); +# else + CPPAD_ASSERT_KNOWN( + false, + "sparse_hes: coloring = colpack.symmetic or colpack.star " + "and colpack_prefix not in cmake command line." + ); +# endif + } + else CPPAD_ASSERT_KNOWN( + false, + "sparse_hes: coloring is not valid." + ); + // + // put sorting indices in color order + SizeVector key(K); + order.resize(K); + for(size_t k = 0; k < K; k++) + key[k] = color[ col[k] ]; + index_sort(key, order); + } + // Base versions of zero and one + Base one(1.0); + Base zero(0.0); + // + size_t n_color = 1; + for(size_t j = 0; j < n; j++) if( color[j] < n ) + n_color = std::max(n_color, color[j] + 1); + // + // initialize the return Hessian values as zero + for(size_t k = 0; k < K; k++) + subset.set(k, zero); + // + // direction vector for calls to first order forward + BaseVector dx(n); + // + // return values for calls to second order reverse + BaseVector ddw(2 * n); + // + // loop over colors + size_t k = 0; + for(size_t ell = 0; ell < n_color; ell++) + if( k == K ) + { // kludge because colpack returns colors that are not used + // (it does not know about the subset corresponding to row, col) + CPPAD_ASSERT_UNKNOWN( + coloring == "colpack.general" || + coloring == "colpack.symmetric" || + coloring == "colpack.star" + ); + } + else if( color[ col[ order[k] ] ] != ell ) + { // kludge because colpack returns colors that are not used + // (it does not know about the subset corresponding to row, col) + CPPAD_ASSERT_UNKNOWN( + coloring == "colpack.general" || + coloring == "colpack.symmetic" || + coloring == "colpack.star" + ); + } + else + { CPPAD_ASSERT_UNKNOWN( color[ col[ order[k] ] ] == ell ); + // + // combine all columns with this color + for(size_t j = 0; j < n; j++) + { dx[j] = zero; + if( color[j] == ell ) + dx[j] = one; + } + // call forward mode for all these rows at once + Forward(1, dx); + // + // evaluate derivative of w^T * F'(x) * dx + ddw = Reverse(2, w); + // + // set the corresponding components of the result + while( k < K && color[ col[order[k]] ] == ell ) + { size_t index = row[ order[k] ] * 2 + 1; + subset.set(order[k], ddw[index] ); + k++; + } + } + // check that all the required entries have been set + CPPAD_ASSERT_UNKNOWN( k == K ); + return n_color; +} + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/sparse_hessian.hpp cppad-2019.02.00.0/include/cppad/core/sparse_hessian.hpp --- cppad-2018.00.00.0/include/cppad/core/sparse_hessian.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/sparse_hessian.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,861 @@ +# ifndef CPPAD_CORE_SPARSE_HESSIAN_HPP +# define CPPAD_CORE_SPARSE_HESSIAN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin sparse_hessian$$ +$spell + jacobian + recomputed + CppAD + valarray + std + Bool + hes + const + Taylor + cppad + cmake + colpack +$$ + +$section Sparse Hessian$$ + +$head Syntax$$ +$icode%hes% = %f%.SparseHessian(%x%, %w%) +%hes% = %f%.SparseHessian(%x%, %w%, %p%) +%n_sweep% = %f%.SparseHessian(%x%, %w%, %p%, %row%, %col%, %hes%, %work%) +%$$ + +$head Purpose$$ +We use $latex n$$ for the $cref/domain/seq_property/Domain/$$ size, +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 +$latex \[ + 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. +If $icode row$$ and $icode col$$ are present, it also takes +advantage of the reduced set of elements of the Hessian that +need to be computed. +One can use speed tests (e.g. $cref speed_test$$) +to verify that results are computed faster +than when using the routine $cref Hessian$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the $cref ADFun$$ object $icode f$$ is not $code const$$ +(see $cref/Uses Forward/sparse_hessian/Uses Forward/$$ below). + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %BaseVector%& %x% +%$$ +(see $cref/BaseVector/sparse_hessian/BaseVector/$$ below) +and its size +must be equal to $icode n$$, the dimension of the +$cref/domain/seq_property/Domain/$$ space for $icode f$$. +It specifies +that point at which to evaluate the Hessian. + +$head w$$ +The argument $icode w$$ has prototype +$codei% + const %BaseVector%& %w% +%$$ +and size $latex m$$. +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 +the calculation of $icode hes$$ may be). + +$head p$$ +The argument $icode p$$ is optional and has prototype +$codei% + const %SetVector%& %p% +%$$ +(see $cref/SetVector/sparse_hessian/SetVector/$$ below) +If it has elements of type $code bool$$, +its size is $latex n * n$$. +If it has elements of type $code std::set$$, +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/$$ +for the Hessian $latex H(x)$$. + +$subhead Purpose$$ +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$$. +If you specify $icode p$$, CppAD will use the same +type of sparsity representation +(vectors of $code bool$$ or vectors of $code std::set$$) +for its internal calculations. +Otherwise, the representation +for the internal calculations is unspecified. + +$subhead work$$ +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. + +$subhead Column Subset$$ +If the arguments $icode row$$ and $icode col$$ are present, +and $cref/color_method/sparse_hessian/work/color_method/$$ is +$code cppad.general$$ or $code cppad.symmetric$$, +it is not necessary to compute the entire sparsity pattern. +Only the following subset of column values will matter: +$codei% + { %col%[%k%] : %k% = 0 , %...% , %K%-1 } +%$$. + + +$head row, col$$ +The arguments $icode row$$ and $icode col$$ are optional and have prototype +$codei% + const %SizeVector%& %row% + const %SizeVector%& %col% +%$$ +(see $cref/SizeVector/sparse_hessian/SizeVector/$$ below). +They specify which rows and columns of $latex H (x)$$ are +returned and in what order. +We use $latex K$$ to denote the value $icode%hes%.size()%$$ +which must also equal the size of $icode row$$ and $icode col$$. +Furthermore, +for $latex k = 0 , \ldots , K-1$$, it must hold that +$latex row[k] < n$$ and $latex col[k] < n$$. +In addition, +all of the $latex (row[k], col[k])$$ pairs must correspond to a true value +in the sparsity pattern $icode p$$. + +$head hes$$ +The result $icode hes$$ has prototype +$codei% + %BaseVector% %hes% +%$$ +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 $$ +and $latex ell = 0 , \ldots , n - 1$$ +$latex \[ + hes [ j * n + \ell ] = \DD{ w^{\rm T} F }{ x_j }{ x_\ell } ( x ) +\] $$ +$pre + +$$ +In the case where the arguments $icode row$$ and $icode col$$ are present, +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 \[ + hes [ k ] = \DD{ w^{\rm T} F }{ x_j }{ x_\ell } (x) + \; , \; + \; {\rm where} \; + j = row[k] + \; {\rm and } \; + \ell = col[k] +\] $$ + +$head work$$ +If this argument is present, it has prototype +$codei% + sparse_hessian_work& %work% +%$$ +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$$ +with the same $icode f$$, $icode p$$, $icode row$$, and $icode col$$. +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.symmetric" +%$$ +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. +$codei% + +"colpack.general" +%$$ +This is the same as the $code "colpack"$$ method for the +$cref/sparse_jacobian/sparse_jacobian/work/color_method/$$ calculation. + +$subhead colpack.star Deprecated 2017-06-01$$ +The $code colpack.star$$ method is deprecated. +It is the same as the $code colpack.symmetric$$ +which should be used instead. + +$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 +used to compute the requested Hessian values. +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 +forward-reverse sweep pair. + +$head BaseVector$$ +The type $icode BaseVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$icode Base$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head SetVector$$ +The type $icode SetVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code bool$$ or $code std::set$$; +see $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for a discussion +of the difference. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$subhead Restrictions$$ +If $icode SetVector$$ has elements of $code std::set$$, +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. + +$head SizeVector$$ +The type $icode SizeVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head Uses Forward$$ +After each call to $cref Forward$$, +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. + +$children% + example/sparse/sparse_hessian.cpp% + example/sparse/sub_sparse_hes.cpp% + example/sparse/sparse_sub_hes.cpp +%$$ + +$head Example$$ +The routine +$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 routine +$cref sub_sparse_hes.cpp$$ +is an example and test that compute a sparse Hessian +for a subset of the variables. +It returns $code true$$, for success, and $code false$$ otherwise. + +$end +----------------------------------------------------------------------------- +*/ +# include +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file sparse_hessian.hpp +Sparse Hessian driver routine and helper functions. +*/ +// =========================================================================== +/*! +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) + { color_method = "cppad.symmetric"; + row.clear(); + col.clear(); + order.clear(); + color.clear(); + } +}; +// =========================================================================== +/*! +Private helper function that does computation for all Sparse Hessian cases. + +\tparam Base +is the base type for the recording that is stored in this ADFun. + +\tparam SizeVector +is sparse_pack or sparse_list. + +\param x [in] +is a vector specifing the point at which to compute the Hessian. + +\param w [in] +is the weighting vector that defines a scalar valued function by +a weighted sum of the components of the vector valued function +$latex F(x)$$. + +\param sparsity [in] +is the sparsity pattern for the Hessian that we are calculating. + +\param user_row [in] +is the vector of row indices for the returned Hessian values. + +\param user_col [in] +is the vector of columns indices for the returned Hessian values. +It must have the same size as user_row. + +\param hes [out] +is the vector of Hessian values. +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 SparseHessianCompute. +If the sparsity pattern, row vector, or col vectors +are not the same between calls to SparseHessianCompute, + work.clear() must be called to reinitialize work. + +\return +Is the number of first order forward sweeps used to compute the +requested Hessian values. +(This is also equal to the number of second order reverse sweeps.) +The total work, not counting the zero order +forward sweep, or the time to combine computations, is proportional to this +return value. +*/ +template +template +size_t ADFun::SparseHessianCompute( + const BaseVector& x , + const BaseVector& w , + SetVector& sparsity , + const SizeVector& user_row , + const SizeVector& user_col , + BaseVector& 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); + + size_t n = Domain(); + + // some values + const Base zero(0); + const Base one(1); + + // check BaseVector 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 ); + + + // Point at which we are evaluating the Hessian + Forward(0, x); + + // check for case where nothing (except Forward above) to do + if( K == 0 ) + return 0; + + // Rows of the Hessian (i below) correspond to the forward mode index + // and columns (j below) correspond to the reverse mode index. + if( color.size() == 0 ) + { + 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); + if( work.color_method == "cppad.general" ) + local::color_general_cppad(sparsity, row, col, color); + else if( work.color_method == "cppad.symmetric" ) + local::color_symmetric_cppad(sparsity, row, col, color); + else if( work.color_method == "colpack.general" ) + { +# if CPPAD_HAS_COLPACK + local::color_general_colpack(sparsity, row, col, color); +# else + CPPAD_ASSERT_KNOWN( + false, + "SparseHessian: work.color_method = colpack.general " + "and colpack_prefix missing from cmake command line." + ); +# endif + } + else if( + work.color_method == "colpack.symmetric" || + work.color_method == "colpack.star" + ) + { +# if CPPAD_HAS_COLPACK + local::color_symmetric_colpack(sparsity, row, col, color); +# else + CPPAD_ASSERT_KNOWN( + false, + "SparseHessian: work.color_method is " + "colpack.symmetric or colpack.star\n" + "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 + SizeVector key(K); + order.resize(K); + for(k = 0; k < K; k++) + key[k] = color[ row[k] ]; + index_sort(key, order); + + } + size_t n_color = 1; + for(ell = 0; ell < n; ell++) if( color[ell] < n ) + n_color = std::max(n_color, color[ell] + 1); + + // direction vector for calls to forward (rows of the Hessian) + BaseVector u(n); + + // location for return values from reverse (columns of the Hessian) + BaseVector ddw(2 * n); + + // initialize the return value + for(k = 0; k < K; k++) + hes[k] = zero; + + // loop over colors +# ifndef NDEBUG + const std::string& coloring = work.color_method; +# endif + k = 0; + for(ell = 0; ell < n_color; ell++) + if( k == K ) + { // kludge because colpack returns colors that are not used + // (it does not know about the subset corresponding to row, col) + CPPAD_ASSERT_UNKNOWN( + coloring == "colpack.general" || + coloring == "colpack.symmetic" || + coloring == "colpack.star" + ); + } + else if( color[ row[ order[k] ] ] != ell ) + { // kludge because colpack returns colors that are not used + // (it does not know about the subset corresponding to row, col) + CPPAD_ASSERT_UNKNOWN( + coloring == "colpack.general" || + coloring == "colpack.symmetic" || + coloring == "colpack.star" + ); + } + else + { CPPAD_ASSERT_UNKNOWN( color[ row[ order[k] ] ] == ell ); + + // combine all rows with this color + for(i = 0; i < n; i++) + { u[i] = zero; + if( color[i] == ell ) + u[i] = one; + } + // call forward mode for all these rows at once + Forward(1, u); + + // evaluate derivative of w^T * F'(x) * u + ddw = Reverse(2, w); + + // set the corresponding components of the result + while( k < K && color[ row[ order[k] ] ] == ell ) + { hes[ order[k] ] = ddw[ col[ order[k] ] * 2 + 1 ]; + k++; + } + } + return n_color; +} +// =========================================================================== +// Public Member Functions +// =========================================================================== +/*! +Compute user specified subset of a sparse Hessian. + +The C++ source code corresponding to this operation is +\verbatim + SparceHessian(x, w, p, row, col, hes, work) +\endverbatim + +\tparam Base +is the base type for the recording that is stored in this ADFun. + +\tparam SizeVector +is a simple vector class with elements of type size_t. + +\param x [in] +is a vector specifing the point at which to compute the Hessian. + +\param w [in] +is the weighting vector that defines a scalar valued function by +a weighted sum of the components of the vector valued function +$latex F(x)$$. + +\param p [in] +is the sparsity pattern for the Hessian that we are calculating. + +\param row [in] +is the vector of row indices for the returned Hessian values. + +\param col [in] +is the vector of columns indices for the returned Hessian values. +It must have the same size are r. + +\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 +\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 SparseHessianCompute. +If the sparsity pattern, row vector, or col vectors +are not the same between calls to SparseHessian, + work.clear() must be called to reinitialize work. + +\return +Is the number of first order forward sweeps used to compute the +requested Hessian values. +(This is also equal to the number of second order reverse sweeps.) +The total work, not counting the zero order +forward sweep, or the time to combine computations, is proportional to this +return value. +*/ +template +template +size_t ADFun::SparseHessian( + const BaseVector& x , + const BaseVector& w , + const SetVector& p , + const SizeVector& row , + const SizeVector& col , + BaseVector& hes , + sparse_hessian_work& work ) +{ + size_t n = Domain(); + size_t K = hes.size(); +# ifndef NDEBUG + 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." + ); + for(k = 0; k < K; k++) + { CPPAD_ASSERT_KNOWN( + row[k] < n, + "SparseHessian: invalid value in r." + ); + CPPAD_ASSERT_KNOWN( + col[k] < n, + "SparseHessian: invalid value in c." + ); + } + if( work.color.size() != 0 ) + for(size_t j = 0; j < n; j++) CPPAD_ASSERT_KNOWN( + work.color[j] <= n, + "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 SetVector::value_type Set_type; + typedef typename local::internal_sparsity::pattern_type Pattern_type; + Pattern_type s; + if( work.color.size() == 0 ) + { bool transpose = false; + const char* error_msg = "SparseHessian: sparsity pattern" + " does not have proper row or column dimension"; + sparsity_user2internal(s, p, n, n, transpose, error_msg); + } + n_sweep = SparseHessianCompute(x, w, s, row, col, hes, work); + return n_sweep; +} +/*! +Compute a sparse Hessian. + +The C++ source code coresponding to this operation is +\verbatim + hes = SparseHessian(x, w, p) +\endverbatim + + +\tparam Base +is the base type for the recording that is stored in this +ADFun. + +\param x [in] +is a vector specifing the point at which to compute the Hessian. + +\param w [in] +The Hessian is computed for a weighted sum of the components +of the function corresponding to this ADFun object. +The argument w specifies the weights for each component. +It must have size equal to the range dimension for this ADFun object. + +\param p [in] +is a sparsity pattern for the Hessian. + +\return +Will be a vector of size n * n containing the Hessian of +at the point specified by x +(where n is the domain dimension for this ADFun object). +*/ +template +template +BaseVector ADFun::SparseHessian( + const BaseVector& x, const BaseVector& w, const SetVector& p +) +{ size_t i, j, k; + + size_t n = Domain(); + BaseVector hes(n * n); + + CPPAD_ASSERT_KNOWN( + size_t(x.size()) == n, + "SparseHessian: size of x not equal domain size for f." + ); + + typedef typename SetVector::value_type Set_type; + typedef typename local::internal_sparsity::pattern_type Pattern_type; + + // initialize the return value as zero + Base zero(0); + for(i = 0; i < n; i++) + for(j = 0; j < n; j++) + hes[i * n + j] = zero; + + // arguments to SparseHessianCompute + Pattern_type s; + CppAD::vector row; + CppAD::vector col; + sparse_hessian_work work; + bool transpose = false; + const char* error_msg = "SparseHessian: sparsity pattern" + " does not have proper row or column dimension"; + sparsity_user2internal(s, p, n, n, transpose, error_msg); + k = 0; + for(i = 0; i < n; i++) + { typename Pattern_type::const_iterator itr(s, i); + j = *itr; + while( j != s.end() ) + { row.push_back(i); + col.push_back(j); + k++; + j = *(++itr); + } + } + size_t K = k; + BaseVector H(K); + + // now we have folded this into the following case + SparseHessianCompute(x, w, s, row, col, H, work); + + // now set the non-zero return values + for(k = 0; k < K; k++) + hes[ row[k] * n + col[k] ] = H[k]; + + return hes; +} +/*! +Compute a sparse Hessian + +The C++ source code coresponding to this operation is +\verbatim + hes = SparseHessian(x, w) +\endverbatim + + +\tparam Base +is the base type for the recording that is stored in this +ADFun object. +The argument w specifies the weights for each component. +It must have size equal to the range dimension for this ADFun object. + +\return +Will be a vector of size n * n containing the Hessian of +at the point specified by x +(where n is the domain dimension for this ADFun object). +*/ +template +template +BaseVector ADFun::SparseHessian(const BaseVector &x, const BaseVector &w) +{ size_t i, j, k; + typedef CppAD::vectorBool BoolVector; + + size_t m = Range(); + size_t n = Domain(); + + // determine the sparsity pattern p for Hessian of w^T F + BoolVector r(n * n); + for(j = 0; j < n; j++) + { for(k = 0; k < n; k++) + r[j * n + k] = false; + r[j * n + j] = true; + } + ForSparseJac(n, r); + // + BoolVector s(m); + for(i = 0; i < m; i++) + s[i] = w[i] != 0; + BoolVector p = RevSparseHes(n, s); + + // compute sparse Hessian + return SparseHessian(x, w, p); +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/sparse.hpp cppad-2019.02.00.0/include/cppad/core/sparse.hpp --- cppad-2018.00.00.0/include/cppad/core/sparse.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/sparse.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,38 @@ +# ifndef CPPAD_CORE_SPARSE_HPP +# define CPPAD_CORE_SPARSE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// +# include +# include +// +# include +# include +// +# include +# include +// +# include +# include +// +# include +# include +// +# include +# include +// +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/sparse_jac.hpp cppad-2019.02.00.0/include/cppad/core/sparse_jac.hpp --- cppad-2018.00.00.0/include/cppad/core/sparse_jac.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/sparse_jac.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,626 @@ +# ifndef CPPAD_CORE_SPARSE_JAC_HPP +# define CPPAD_CORE_SPARSE_JAC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin sparse_jac$$ +$spell + Jacobian + Jacobians + const + jac + Taylor + rc + rcv + nr + nc + std + Cppad + Colpack + cmake +$$ + +$section Computing Sparse Jacobians$$ + +$head Syntax$$ +$icode%n_sweep% = %f%.sparse_jac_for( + %group_max%, %x%, %subset%, %pattern%, %coloring%, %work% +) +%$$ +$icode%n_sweep% = %f%.sparse_jac_rev( + %x%, %subset%, %pattern%, %coloring%, %work% +)%$$ + +$head Purpose$$ +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the +function corresponding to $icode f$$. +Here $icode n$$ is the $cref/domain/seq_property/Domain/$$ size, +and $icode m$$ is the $cref/range/seq_property/Range/$$ size, or $icode f$$. +The syntax above takes advantage of sparsity when computing the Jacobian +$latex \[ + J(x) = F^{(1)} (x) +\] $$ +In the sparse case, this should be faster and take less memory than +$cref Jacobian$$. +We use the notation $latex J_{i,j} (x)$$ to denote the partial of +$latex F_i (x)$$ with respect to $latex x_j$$. + +$head SizeVector$$ +The type $icode SizeVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. + +$head BaseVector$$ +The type $icode BaseVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. + +$head sparse_jac_for$$ +This function uses first order forward mode sweeps $cref forward_one$$ +to compute multiple columns of the Jacobian at the same time. + +$head sparse_jac_rev$$ +This uses function first order reverse mode sweeps $cref reverse_one$$ +to compute multiple rows of the Jacobian at the same time. + +$head f$$ +This object has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the Taylor coefficients stored in $icode f$$ are affected +by this operation; see +$cref/uses forward/sparse_jac/Uses Forward/$$ below. + +$head group_max$$ +This argument has prototype +$codei% + size_t %group_max% +%$$ +and must be greater than zero. +It specifies the maximum number of colors to group during +a single forward sweep. +If a single color is in a group, +a single direction for of first order forward mode +$cref forward_one$$ is used for each color. +If multiple colors are in a group, +the multiple direction for of first order forward mode +$cref forward_dir$$ is used with one direction for each color. +This uses separate memory for each direction (more memory), +but my be significantly faster. + +$head x$$ +This argument has prototype +$codei% + const %BaseVector%& %x% +%$$ +and its size is $icode n$$. +It specifies the point at which to evaluate the Jacobian +$latex J(x)$$. + +$head subset$$ +This argument has prototype +$codei% + sparse_rcv<%SizeVector%, %BaseVector%>& %subset% +%$$ +Its row size is $icode%subset%.nr() == %m%$$, +and its column size is $icode%subset%.nc() == %n%$$. +It specifies which elements of the Jacobian are computed. +The input value of its value vector +$icode%subset%.val()%$$ does not matter. +Upon return it contains the value of the corresponding elements +of the Jacobian. +All of the row, column pairs in $icode subset$$ must also appear in +$icode pattern$$; i.e., they must be possibly non-zero. + +$head pattern$$ +This argument has prototype +$codei% + const sparse_rc<%SizeVector%>& %pattern% +%$$ +Its row size is $icode%pattern%.nr() == %m%$$, +and its column size is $icode%pattern%.nc() == %n%$$. +It is a sparsity pattern for the Jacobian $latex J(x)$$. +This argument is not used (and need not satisfy any conditions), +when $cref/work/sparse_jac/work/$$ is non-empty. + +$head coloring$$ +The coloring algorithm determines which rows (reverse) or columns (forward) +can be computed during the same sweep. +This field has prototype +$codei% + const std::string& %coloring% +%$$ +This value only matters when work is empty; i.e., +after the $icode work$$ constructor or $icode%work%.clear()%$$. + +$subhead cppad$$ +This uses a general purpose coloring algorithm written for Cppad. + +$subhead colpack$$ +If $cref colpack_prefix$$ is specified on the +$cref/cmake command/cmake/CMake Command/$$ line, +you can set $icode coloring$$ to $code colpack$$. +This uses a general purpose coloring algorithm that is part of Colpack. + +$head work$$ +This argument has prototype +$codei% + sparse_jac_work& %work% +%$$ +We refer to its initial value, +and its value after $icode%work%.clear()%$$, as empty. +If it is empty, information is stored in $icode work$$. +This can be used to reduce computation when +a future call is for the same object $icode f$$, +the same member function $code sparse_jac_for$$ or $code sparse_jac_rev$$, +and the same subset of the Jacobian. +In fact, it can be used with a different $icode f$$ +and a different $icode subset$$ provided that Jacobian sparsity pattern +for $icode f$$ and the sparsity pattern in $icode subset$$ are the same. +If any of these values change, use $icode%work%.clear()%$$ to +empty this structure. + +$head n_sweep$$ +The return value $icode n_sweep$$ has prototype +$codei% + size_t %n_sweep% +%$$ +If $code sparse_jac_for$$ ($code sparse_jac_rev$$) is used, +$icode n_sweep$$ is the number of first order forward (reverse) sweeps +used to compute the requested Jacobian values. +It is also the number of colors determined by the coloring method +mentioned above. +This is proportional to the total computational work, +not counting the zero order forward sweep, +or combining multiple columns (rows) into a single sweep. + +$head Uses Forward$$ +After each call to $cref Forward$$, +the object $icode f$$ contains the corresponding +$cref/Taylor coefficients/glossary/Taylor Coefficient/$$. +After a call to $code sparse_jac_forward$$ or $code sparse_jac_rev$$, +the zero order coefficients correspond to +$codei% + %f%.Forward(0, %x%) +%$$ +All the other forward mode coefficients are unspecified. + +$head Example$$ +$children% + example/sparse/sparse_jac_for.cpp% + example/sparse/sparse_jac_rev.cpp +%$$ +The files $cref sparse_jac_for.cpp$$ and $cref sparse_jac_rev.cpp$$ +are examples and tests of $code sparse_jac_for$$ and $code sparse_jac_rev$$. +They return $code true$$, if they succeed, and $code false$$ otherwise. + +$end +*/ +# include +# include +# include +# include + +/*! +\file sparse_jac.hpp +Sparse Jacobian calculation routines. +*/ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +Class used to hold information used by Sparse Jacobian routines in this file, +so they do not need to be recomputed every time. +*/ +class sparse_jac_work { + public: + /// indices that sort the user row and col arrays by color + CppAD::vector order; + /// results of the coloring algorithm + CppAD::vector color; + // + /// constructor + sparse_jac_work(void) + { } + /// reset work to empty. + /// This informs CppAD that color and order need to be recomputed + void clear(void) + { order.clear(); + color.clear(); + } +}; +// ---------------------------------------------------------------------------- +/*! +Calculate sparse Jacobains using forward mode + +\tparam Base +the base type for the recording that is stored in the ADFun object. + +\tparam SizeVector +a simple vector class with elements of type size_t. + +\tparam BaseVector +a simple vector class with elements of type Base. + +\param group_max +specifies the maximum number of colors to group during a single forward sweep. +This must be greater than zero and group_max = 1 minimizes memory usage. + +\param x +a vector of length n, the number of independent variables in f +(this ADFun object). + +\param subset +specifices the subset of the sparsity pattern where the Jacobian is evaluated. +subset.nr() == m, +subset.nc() == n. + +\param pattern +is a sparsity pattern for the Jacobian of f; +pattern.nr() == m, +pattern.nc() == n, +where m is number of dependent variables in f. + +\param coloring +determines which coloring algorithm is used. +This must be cppad or colpack. + +\param work +this structure must be empty, or contain the information stored +by a previous call to sparse_jac_for. +The previous call must be for the same ADFun object f +and the same subset. + +\return +This is the number of first order forward sweeps used to compute +the Jacobian. +*/ +template +template +size_t ADFun::sparse_jac_for( + size_t group_max , + const BaseVector& x , + sparse_rcv& subset , + const sparse_rc& pattern , + const std::string& coloring , + sparse_jac_work& work ) +{ size_t m = Range(); + size_t n = Domain(); + // + CPPAD_ASSERT_KNOWN( + subset.nr() == m, + "sparse_jac_for: subset.nr() not equal range dimension for f" + ); + CPPAD_ASSERT_KNOWN( + subset.nc() == n, + "sparse_jac_for: subset.nc() not equal domain dimension for f" + ); + // + // row and column vectors in subset + const SizeVector& row( subset.row() ); + const SizeVector& col( subset.col() ); + // + vector& color(work.color); + vector& order(work.order); + CPPAD_ASSERT_KNOWN( + color.size() == 0 || color.size() == n, + "sparse_jac_for: work is non-empty and conditions have changed" + ); + // + // point at which we are evaluationg the Jacobian + Forward(0, x); + // + // number of elements in the subset + size_t K = subset.nnz(); + // + // check for case were there is nothing to do + // (except for call to Forward(0, x) + if( K == 0 ) + return 0; + // + // check for case where input work is empty + if( color.size() == 0 ) + { // compute work color and order vectors + CPPAD_ASSERT_KNOWN( + pattern.nr() == m, + "sparse_jac_for: pattern.nr() not equal range dimension for f" + ); + CPPAD_ASSERT_KNOWN( + pattern.nc() == n, + "sparse_jac_for: pattern.nc() not equal domain dimension for f" + ); + // + // convert pattern to an internal version of its transpose + local::pod_vector internal_index(n); + for(size_t j = 0; j < n; j++) + internal_index[j] = j; + bool transpose = true; + bool zero_empty = false; + bool input_empty = true; + local::sparse_list pattern_transpose; + pattern_transpose.resize(n, m); + local::set_internal_sparsity(zero_empty, input_empty, + transpose, internal_index, pattern_transpose, pattern + ); + // + // execute coloring algorithm + // (we are using transpose because coloring groups rows, not columns). + color.resize(n); + if( coloring == "cppad" ) + local::color_general_cppad(pattern_transpose, col, row, color); + else if( coloring == "colpack" ) + { +# if CPPAD_HAS_COLPACK + local::color_general_colpack(pattern_transpose, col, row, color); +# else + CPPAD_ASSERT_KNOWN( + false, + "sparse_jac_for: coloring = colpack " + "and colpack_prefix missing from cmake command line." + ); +# endif + } + else CPPAD_ASSERT_KNOWN( + false, + "sparse_jac_for: coloring is not valid." + ); + // + // put sorting indices in color order + SizeVector key(K); + order.resize(K); + for(size_t k = 0; k < K; k++) + key[k] = color[ col[k] ]; + index_sort(key, order); + } + // Base versions of zero and one + Base one(1.0); + Base zero(0.0); + // + size_t n_color = 1; + for(size_t j = 0; j < n; j++) if( color[j] < n ) + n_color = std::max(n_color, color[j] + 1); + // + // initialize the return Jacobian values as zero + for(size_t k = 0; k < K; k++) + subset.set(k, zero); + // + // index in subset + size_t k = 0; + // number of colors computed so far + size_t color_count = 0; + // + while( color_count < n_color ) + { // number of colors that will be in this group + size_t group_size = std::min(group_max, n_color - color_count); + // + // forward mode values for independent and dependent variables + BaseVector dx(n * group_size), dy(m * group_size); + // + // set dx + for(size_t ell = 0; ell < group_size; ell++) + { // combine all columns with this color + for(size_t j = 0; j < n; j++) + { dx[j * group_size + ell] = zero; + if( color[j] == ell + color_count ) + dx[j * group_size + ell] = one; + } + } + if( group_size == 1 ) + dy = Forward(1, dx); + else + dy = Forward(1, group_size, dx); + // + // store results in subset + for(size_t ell = 0; ell < group_size; ell++) + { // color with index ell + color_count is in this group + while(k < K && color[ col[ order[k] ] ] == ell + color_count ) + { // subset element with index order[k] is included in this color + size_t r = row[ order[k] ]; + subset.set( order[k], dy[ r * group_size + ell ] ); + ++k; + } + } + // advance color count + color_count += group_size; + } + CPPAD_ASSERT_UNKNOWN( color_count == n_color ); + // + return n_color; +} +// ---------------------------------------------------------------------------- +/*! +Calculate sparse Jacobains using reverse mode + +\tparam Base +the base type for the recording that is stored in the ADFun object. + +\tparam SizeVector +a simple vector class with elements of type size_t. + +\tparam BaseVector +a simple vector class with elements of type Base. + +\param x +a vector of length n, the number of independent variables in f +(this ADFun object). + +\param subset +specifices the subset of the sparsity pattern where the Jacobian is evaluated. +subset.nr() == m, +subset.nc() == n. + +\param pattern +is a sparsity pattern for the Jacobian of f; +pattern.nr() == m, +pattern.nc() == n, +where m is number of dependent variables in f. + +\param coloring +determines which coloring algorithm is used. +This must be cppad or colpack. + +\param work +this structure must be empty, or contain the information stored +by a previous call to sparse_jac_rev. +The previous call must be for the same ADFun object f +and the same subset. + +\return +This is the number of first order reverse sweeps used to compute +the Jacobian. +*/ +template +template +size_t ADFun::sparse_jac_rev( + const BaseVector& x , + sparse_rcv& subset , + const sparse_rc& pattern , + const std::string& coloring , + sparse_jac_work& work ) +{ size_t m = Range(); + size_t n = Domain(); + // + CPPAD_ASSERT_KNOWN( + subset.nr() == m, + "sparse_jac_rev: subset.nr() not equal range dimension for f" + ); + CPPAD_ASSERT_KNOWN( + subset.nc() == n, + "sparse_jac_rev: subset.nc() not equal domain dimension for f" + ); + // + // row and column vectors in subset + const SizeVector& row( subset.row() ); + const SizeVector& col( subset.col() ); + // + vector& color(work.color); + vector& order(work.order); + CPPAD_ASSERT_KNOWN( + color.size() == 0 || color.size() == m, + "sparse_jac_rev: work is non-empty and conditions have changed" + ); + // + // point at which we are evaluationg the Jacobian + Forward(0, x); + // + // number of elements in the subset + size_t K = subset.nnz(); + // + // check for case were there is nothing to do + // (except for call to Forward(0, x) + if( K == 0 ) + return 0; + // + // check for case where input work is empty + if( color.size() == 0 ) + { // compute work color and order vectors + CPPAD_ASSERT_KNOWN( + pattern.nr() == m, + "sparse_jac_rev: pattern.nr() not equal range dimension for f" + ); + CPPAD_ASSERT_KNOWN( + pattern.nc() == n, + "sparse_jac_rev: pattern.nc() not equal domain dimension for f" + ); + // + // convert pattern to an internal version + local::pod_vector internal_index(m); + for(size_t i = 0; i < m; i++) + internal_index[i] = i; + bool transpose = false; + bool zero_empty = false; + bool input_empty = true; + local::sparse_list internal_pattern; + internal_pattern.resize(m, n); + local::set_internal_sparsity(zero_empty, input_empty, + transpose, internal_index, internal_pattern, pattern + ); + // + // execute coloring algorithm + color.resize(m); + if( coloring == "cppad" ) + local::color_general_cppad(internal_pattern, row, col, color); + else if( coloring == "colpack" ) + { +# if CPPAD_HAS_COLPACK + local::color_general_colpack(internal_pattern, row, col, color); +# else + CPPAD_ASSERT_KNOWN( + false, + "sparse_jac_rev: coloring = colpack " + "and colpack_prefix missing from cmake command line." + ); +# endif + } + else CPPAD_ASSERT_KNOWN( + false, + "sparse_jac_rev: coloring is not valid." + ); + // + // put sorting indices in color order + SizeVector key(K); + order.resize(K); + for(size_t k = 0; k < K; k++) + key[k] = color[ row[k] ]; + index_sort(key, order); + } + // Base versions of zero and one + Base one(1.0); + Base zero(0.0); + // + size_t n_color = 1; + for(size_t i = 0; i < m; i++) if( color[i] < m ) + n_color = std::max(n_color, color[i] + 1); + // + // initialize the return Jacobian values as zero + for(size_t k = 0; k < K; k++) + subset.set(k, zero); + // + // weighting vector and return values for calls to Reverse + BaseVector w(m), dw(n); + // + // loop over colors + size_t k = 0; + for(size_t ell = 0; ell < n_color; ell++) + if( k == K ) + { // kludge because colpack returns colors that are not used + // (it does not know about the subset corresponding to row, col) + CPPAD_ASSERT_UNKNOWN( coloring == "colpack" ); + } + else if( color[ row[ order[k] ] ] != ell ) + { // kludge because colpack returns colors that are not used + // (it does not know about the subset corresponding to row, col) + CPPAD_ASSERT_UNKNOWN( coloring == "colpack" ); + } + else + { CPPAD_ASSERT_UNKNOWN( color[ row[ order[k] ] ] == ell ); + // + // combine all rows with this color + for(size_t i = 0; i < m; i++) + { w[i] = zero; + if( color[i] == ell ) + w[i] = one; + } + // call reverse mode for all these rows at once + dw = Reverse(1, w); + // + // set the corresponding components of the result + while( k < K && color[ row[order[k]] ] == ell ) + { subset.set(order[k], dw[col[order[k]]] ); + k++; + } + } + return n_color; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/sparse_jacobian.hpp cppad-2019.02.00.0/include/cppad/core/sparse_jacobian.hpp --- cppad-2018.00.00.0/include/cppad/core/sparse_jacobian.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/sparse_jacobian.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1086 @@ +# ifndef CPPAD_CORE_SPARSE_JACOBIAN_HPP +# define CPPAD_CORE_SPARSE_JACOBIAN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// maximum number of sparse directions to compute at the same time + +// # define CPPAD_SPARSE_JACOBIAN_MAX_MULTIPLE_DIRECTION 1 +# define CPPAD_SPARSE_JACOBIAN_MAX_MULTIPLE_DIRECTION 64 + +/* +$begin sparse_jacobian$$ +$spell + cppad + colpack + cmake + recomputed + valarray + std + CppAD + Bool + jac + Jacobian + Jacobians + const + Taylor +$$ + +$section Sparse Jacobian$$ + +$head Syntax$$ +$icode%jac% = %f%.SparseJacobian(%x%) +%jac% = %f%.SparseJacobian(%x%, %p%) +%n_sweep% = %f%.SparseJacobianForward(%x%, %p%, %row%, %col%, %jac%, %work%) +%n_sweep% = %f%.SparseJacobianReverse(%x%, %p%, %row%, %col%, %jac%, %work%) +%$$ + +$head Purpose$$ +We use $latex n$$ for the $cref/domain/seq_property/Domain/$$ size, +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 +$latex \[ + jac = F^{(1)} (x) +\] $$ +This routine takes advantage of the sparsity of the Jacobian +in order to reduce the amount of computation necessary. +If $icode row$$ and $icode col$$ are present, it also takes +advantage of the reduced set of elements of the Jacobian that +need to be computed. +One can use speed tests (e.g. $cref speed_test$$) +to verify that results are computed faster +than when using the routine $cref Jacobian$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the $cref ADFun$$ object $icode f$$ is not $code const$$ +(see $cref/Uses Forward/sparse_jacobian/Uses Forward/$$ below). + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %BaseVector%& %x% +%$$ +(see $cref/BaseVector/sparse_jacobian/BaseVector/$$ below) +and its size +must be equal to $icode n$$, the dimension of the +$cref/domain/seq_property/Domain/$$ space for $icode f$$. +It specifies +that point at which to evaluate the Jacobian. + +$head p$$ +The argument $icode p$$ is optional and has prototype +$codei% + const %SetVector%& %p% +%$$ +(see $cref/SetVector/sparse_jacobian/SetVector/$$ below). +If it has elements of type $code bool$$, +its size is $latex m * n$$. +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/$$ +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 +(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 +(vectors of $code bool$$ or vectors of $code std::set$$) +for its internal calculations. +Otherwise, the representation +for the internal calculations is unspecified. + +$head row, col$$ +The arguments $icode row$$ and $icode col$$ are optional and have prototype +$codei% + const %SizeVector%& %row% + const %SizeVector%& %col% +%$$ +(see $cref/SizeVector/sparse_jacobian/SizeVector/$$ below). +They specify which rows and columns of $latex F^{(1)} (x)$$ are +computes and in what order. +Not all the non-zero entries in $latex F^{(1)} (x)$$ need be computed, +but all the entries specified by $icode row$$ and $icode col$$ +must be possibly non-zero in the sparsity pattern. +We use $latex K$$ to denote the value $icode%jac%.size()%$$ +which must also equal the size of $icode row$$ and $icode col$$. +Furthermore, +for $latex k = 0 , \ldots , K-1$$, it must hold that +$latex row[k] < m$$ and $latex col[k] < n$$. + +$head jac$$ +The result $icode jac$$ has prototype +$codei% + %BaseVector%& %jac% +%$$ +In the case where the arguments $icode row$$ and $icode col$$ are not present, +the size of $icode jac$$ is $latex m * n$$ and +for $latex i = 0 , \ldots , m-1$$, +$latex j = 0 , \ldots , n-1$$, +$latex \[ + jac [ i * n + j ] = \D{ F_i }{ x_j } (x) +\] $$ +$pre + +$$ +In the case where the arguments $icode row$$ and $icode col$$ are present, +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 \[ + jac [ k ] = \D{ F_i }{ x_j } (x) + \; , \; + \; {\rm where} \; + i = row[k] + \; {\rm and } \; + j = col[k] +\] $$ + +$head work$$ +If this argument is present, it has prototype +$codei% + sparse_jacobian_work& %work% +%$$ +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), +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, +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 columns (forward mode) +or rows (reverse mode) can be computed during the same sweep. +This field has prototype +$codei% + std::string %work%.color_method +%$$ +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$$ +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. +(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, +or the work to combine multiple columns (rows) into a single sweep. + +$head BaseVector$$ +The type $icode BaseVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$icode Base$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head SetVector$$ +The type $icode SetVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code bool$$ or $code std::set$$; +see $cref/sparsity pattern/glossary/Sparsity Pattern/$$ for a discussion +of the difference. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$subhead Restrictions$$ +If $icode SetVector$$ has elements of $code std::set$$, +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. + +$head SizeVector$$ +The type $icode SizeVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head Uses Forward$$ +After each call to $cref Forward$$, +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 +$icode%f%.Forward(0, %x%)%$$ +and the other coefficients are unspecified. + +After $code SparseJacobian$$, +the previous calls to $cref Forward$$ are undefined. + +$head Example$$ +$children% + example/sparse/sparse_jacobian.cpp +%$$ +The routine +$cref sparse_jacobian.cpp$$ +is examples and tests of $code sparse_jacobian$$. +It return $code true$$, if it succeeds and $code false$$ otherwise. + +$end +============================================================================== +*/ +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file sparse_jacobian.hpp +Sparse Jacobian driver routine and helper functions. +*/ +// =========================================================================== +/*! +class used by SparseJacobian to hold information so it does not need to be +recomputed. +*/ +class sparse_jacobian_work { + public: + /// 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 + CppAD::vector order; + /// results of the coloring algorithm + CppAD::vector color; + + /// constructor + sparse_jacobian_work(void) : color_method("cppad") + { } + /// reset coloring method to its default and + /// inform CppAD that color and order need to be recomputed + void clear(void) + { color_method = "cppad"; + order.clear(); + color.clear(); + } +}; +// =========================================================================== +/*! +Private helper function forward mode cases + +\tparam Base +is the base type for the recording that is stored in this +ADFun object. + +\tparam BaseVector +is a simple vector class with elements of type Base. + +\tparam SetVector +is either sparse_pack or sparse_list. + +\tparam SizeVector +is a simple vector class with elements of type size_t. + +\param x [in] +is a vector specifing the point at which to compute the Jacobian. + +\param p_transpose [in] +If work.color.size() != 0, +then p_transpose is not used. +Otherwise, it is a +sparsity pattern for the transpose of the Jacobian of this ADFun object. +Note that we do not change the values in p_transpose, +but is not const because we use its iterator facility. + +\param row [in] +is the vector of row indices for the returned Jacobian values. + +\param col [in] +is the vector of columns indices for the returned Jacobian values. +It must have the same size as row. + +\param jac [out] +is the vector of Jacobian values. We use K to denote the size of jac. +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 +work.color_method is an input. The rest of +this structure contains information that is computed by SparseJacobainFor. +If the sparsity pattern, row vector, or col vectors +are not the same between calls to SparseJacobianFor, + work.clear() must be called to reinitialize work. + +\return +Is the number of first order forward sweeps used to compute the +requested Jacobian values. The total work, not counting the zero order +forward sweep, or the time to combine computations, is proportional to this +return value. +*/ +template +template +size_t ADFun::SparseJacobianFor( + const BaseVector& x , + SetVector& p_transpose , + const SizeVector& row , + const SizeVector& col , + BaseVector& jac , + sparse_jacobian_work& work ) +{ + size_t j, k, ell; + + CppAD::vector& order(work.order); + CppAD::vector& color(work.color); + + size_t m = Range(); + size_t n = Domain(); + + // some values + const Base zero(0); + const Base one(1); + + // check BaseVector is Simple Vector class with Base type elements + CheckSimpleVector(); + + CPPAD_ASSERT_UNKNOWN( size_t(x.size()) == n ); + CPPAD_ASSERT_UNKNOWN( color.size() == 0 || color.size() == n ); + + // number of components of Jacobian that are required + size_t K = size_t(jac.size()); + 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); + + // check for case where nothing (except Forward above) to do + if( K == 0 ) + return 0; + + if( color.size() == 0 ) + { + CPPAD_ASSERT_UNKNOWN( p_transpose.n_set() == n ); + CPPAD_ASSERT_UNKNOWN( p_transpose.end() == m ); + + // execute coloring algorithm + color.resize(n); + if( work.color_method == "cppad" ) + local::color_general_cppad(p_transpose, col, row, color); + else if( work.color_method == "colpack" ) + { +# if CPPAD_HAS_COLPACK + local::color_general_colpack(p_transpose, col, row, color); +# else + CPPAD_ASSERT_KNOWN( + false, + "SparseJacobianForward: work.color_method = colpack " + "and colpack_prefix missing from cmake command line." + ); +# endif + } + else CPPAD_ASSERT_KNOWN( + false, + "SparseJacobianForward: work.color_method is not valid." + ); + + // put sorting indices in color order + SizeVector key(K); + order.resize(K); + for(k = 0; k < K; k++) + key[k] = color[ col[k] ]; + index_sort(key, order); + } + size_t n_color = 1; + for(j = 0; j < n; j++) if( color[j] < n ) + n_color = std::max(n_color, color[j] + 1); + + // initialize the return value + for(k = 0; k < K; k++) + jac[k] = zero; + +# if CPPAD_SPARSE_JACOBIAN_MAX_MULTIPLE_DIRECTION == 1 + // direction vector and return values for calls to forward + BaseVector dx(n), dy(m); + + // loop over colors + k = 0; + for(ell = 0; ell < n_color; ell++) + { CPPAD_ASSERT_UNKNOWN( color[ col[ order[k] ] ] == ell ); + + // combine all columns with this color + for(j = 0; j < n; j++) + { dx[j] = zero; + if( color[j] == ell ) + dx[j] = one; + } + // call forward mode for all these columns at once + dy = Forward(1, dx); + + // set the corresponding components of the result + while( k < K && color[ col[order[k]] ] == ell ) + { jac[ order[k] ] = dy[row[order[k]]]; + k++; + } + } +# else + // abbreviation for this value + size_t max_r = CPPAD_SPARSE_JACOBIAN_MAX_MULTIPLE_DIRECTION; + CPPAD_ASSERT_UNKNOWN( max_r > 1 ); + + // count the number of colors done so far + size_t count_color = 0; + // count the sparse matrix entries done so far + k = 0; + while( count_color < n_color ) + { // number of colors we will do this time + size_t r = std::min(max_r , n_color - count_color); + BaseVector dx(n * r), dy(m * r); + + // loop over colors we will do this tme + for(ell = 0; ell < r; ell++) + { // combine all columns with this color + for(j = 0; j < n; j++) + { dx[j * r + ell] = zero; + if( color[j] == ell + count_color ) + dx[j * r + ell] = one; + } + } + size_t q = 1; + dy = Forward(q, r, dx); + + // store results + 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 ) + { jac[ order[k] ] = dy[ row[order[k]] * r + ell ]; + k++; + } + } + count_color += r; + } +# endif + return n_color; +} +/*! +Private helper function for reverse mode cases. + +\tparam Base +is the base type for the recording that is stored in this +ADFun object. + +\tparam BaseVector +is a simple vector class with elements of type Base. + +\tparam SetVector +is either sparse_pack or sparse_list. + +\tparam SizeVector +is a simple vector class with elements of type size_t. + +\param x [in] +is a vector specifing the point at which to compute the Jacobian. + +\param p [in] +If work.color.size() != 0, then p is not used. +Otherwise, it is a +sparsity pattern for the Jacobian of this ADFun object. +Note that we do not change the values in p, +but is not const because we use its iterator facility. + +\param row [in] +is the vector of row indices for the returned Jacobian values. + +\param col [in] +is the vector of columns indices for the returned Jacobian values. +It must have the same size as row. + +\param jac [out] +is the vector of Jacobian values. +It must have the same size as 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 +work.color_method is an input. The rest of +This structure contains information that is computed by SparseJacobainRev. +If the sparsity pattern, row vector, or col vectors +are not the same between calls to SparseJacobianRev, + work.clear() must be called to reinitialize work. + +\return +Is the number of first order reverse sweeps used to compute the +reverse Jacobian values. The total work, not counting the zero order +forward sweep, or the time to combine computations, is proportional to this +return value. +*/ +template +template +size_t ADFun::SparseJacobianRev( + const BaseVector& x , + SetVector& p , + const SizeVector& row , + const SizeVector& col , + BaseVector& jac , + sparse_jacobian_work& work ) +{ + size_t i, k, ell; + + CppAD::vector& order(work.order); + CppAD::vector& color(work.color); + + size_t m = Range(); + size_t n = Domain(); + + // some values + const Base zero(0); + const Base one(1); + + // check BaseVector is Simple Vector class with Base type elements + CheckSimpleVector(); + + CPPAD_ASSERT_UNKNOWN( size_t(x.size()) == n ); + CPPAD_ASSERT_UNKNOWN (color.size() == m || color.size() == 0 ); + + // number of components of Jacobian that are required + size_t K = size_t(jac.size()); + 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); + + // check for case where nothing (except Forward above) to do + if( K == 0 ) + return 0; + + if( color.size() == 0 ) + { + CPPAD_ASSERT_UNKNOWN( p.n_set() == m ); + CPPAD_ASSERT_UNKNOWN( p.end() == n ); + + // execute the coloring algorithm + color.resize(m); + if( work.color_method == "cppad" ) + local::color_general_cppad(p, row, col, color); + else if( work.color_method == "colpack" ) + { +# if CPPAD_HAS_COLPACK + local::color_general_colpack(p, row, col, color); +# else + CPPAD_ASSERT_KNOWN( + false, + "SparseJacobianReverse: work.color_method = colpack " + "and colpack_prefix missing from cmake command line." + ); +# endif + } + else CPPAD_ASSERT_KNOWN( + false, + "SparseJacobianReverse: work.color_method is not valid." + ); + + // put sorting indices in color order + SizeVector key(K); + order.resize(K); + for(k = 0; k < K; k++) + key[k] = color[ row[k] ]; + index_sort(key, order); + } + size_t n_color = 1; + 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 + BaseVector w(m); + + // location for return values from Reverse + BaseVector dw(n); + + // initialize the return value + for(k = 0; k < K; k++) + jac[k] = zero; + + // loop over colors + k = 0; + for(ell = 0; ell < n_color; ell++) + { CPPAD_ASSERT_UNKNOWN( color[ row[ order[k] ] ] == ell ); + + // combine all the rows with this color + for(i = 0; i < m; i++) + { w[i] = zero; + if( color[i] == ell ) + w[i] = one; + } + // call reverse mode for all these rows at once + dw = Reverse(1, w); + + // set the corresponding components of the result + while( k < K && color[ row[order[k]] ] == ell ) + { jac[ order[k] ] = dw[col[order[k]]]; + k++; + } + } + return n_color; +} +// ========================================================================== +// Public Member functions +// ========================================================================== +/*! +Compute user specified subset of a sparse Jacobian using forward mode. + +The C++ source code corresponding to this operation is +\verbatim + SparceJacobianForward(x, p, row, col, jac, work) +\endverbatim + +\tparam Base +is the base type for the recording that is stored in this +ADFun object. + +\tparam BaseVector +is a simple vector class with elements of type Base. + +\tparam SetVector +is a simple vector class with elements of type + bool or std::set. + +\tparam SizeVector +is a simple vector class with elements of type size_t. + +\param x [in] +is a vector specifing the point at which to compute the Jacobian. + +\param p [in] +is the sparsity pattern for the Jacobian that we are calculating. + +\param row [in] +is the vector of row indices for the returned Jacobian values. + +\param col [in] +is the vector of columns indices for the returned Jacobian values. +It must have the same size as row. + +\param jac [out] +is the vector of Jacobian values. +It must have the same size as 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, +sparsity pattern, row vector, and col vector. +If they are not the same between calls to SparseJacobianForward, + work.clear() must be called to reinitialize them. + +\return +Is the number of first order forward sweeps used to compute the +requested Jacobian values. The total work, not counting the zero order +forward sweep, or the time to combine computations, is proportional to this +return value. +*/ +template +template +size_t ADFun::SparseJacobianForward( + const BaseVector& x , + const SetVector& p , + const SizeVector& row , + const SizeVector& col , + BaseVector& jac , + sparse_jacobian_work& work ) +{ + size_t n = Domain(); + size_t m = Range(); + size_t K = jac.size(); +# ifndef NDEBUG + 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." + ); + for(k = 0; k < K; k++) + { CPPAD_ASSERT_KNOWN( + row[k] < m, + "SparseJacobianForward: invalid value in r." + ); + CPPAD_ASSERT_KNOWN( + col[k] < n, + "SparseJacobianForward: invalid value in c." + ); + } + if( work.color.size() != 0 ) + for(size_t j = 0; j < n; j++) CPPAD_ASSERT_KNOWN( + work.color[j] <= n, + "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 SetVector::value_type Set_type; + typedef typename local::internal_sparsity::pattern_type Pattern_type; + Pattern_type s_transpose; + if( work.color.size() == 0 ) + { bool transpose = true; + const char* error_msg = "SparseJacobianForward: transposed sparsity" + " pattern does not have proper row or column dimension"; + sparsity_user2internal(s_transpose, p, n, m, transpose, error_msg); + } + n_sweep = SparseJacobianFor(x, s_transpose, row, col, jac, work); + return n_sweep; +} +/*! +Compute user specified subset of a sparse Jacobian using forward mode. + +The C++ source code corresponding to this operation is +\verbatim + SparceJacobianReverse(x, p, row, col, jac, work) +\endverbatim + +\tparam Base +is the base type for the recording that is stored in this +ADFun object. + +\tparam BaseVector +is a simple vector class with elements of type Base. + +\tparam SetVector +is a simple vector class with elements of type + bool or std::set. + +\tparam SizeVector +is a simple vector class with elements of type size_t. + +\param x [in] +is a vector specifing the point at which to compute the Jacobian. + +\param p [in] +is the sparsity pattern for the Jacobian that we are calculating. + +\param row [in] +is the vector of row indices for the returned Jacobian values. + +\param col [in] +is the vector of columns indices for the returned Jacobian values. +It must have the same size as row. + +\param jac [out] +is the vector of Jacobian values. +It must have the same size as 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, +sparsity pattern, row vector, and col vector. +If they are not the same between calls to SparseJacobianReverse, + work.clear() must be called to reinitialize them. + +\return +Is the number of first order reverse sweeps used to compute the +reverse Jacobian values. The total work, not counting the zero order +forward sweep, or the time to combine computations, is proportional to this +return value. +*/ +template +template +size_t ADFun::SparseJacobianReverse( + const BaseVector& x , + const SetVector& p , + const SizeVector& row , + const SizeVector& col , + BaseVector& jac , + sparse_jacobian_work& work ) +{ + size_t m = Range(); + size_t n = Domain(); + size_t K = jac.size(); +# ifndef NDEBUG + 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." + ); + for(k = 0; k < K; k++) + { CPPAD_ASSERT_KNOWN( + row[k] < m, + "SparseJacobianReverse: invalid value in r." + ); + CPPAD_ASSERT_KNOWN( + col[k] < n, + "SparseJacobianReverse: invalid value in c." + ); + } + if( work.color.size() != 0 ) + for(size_t i = 0; i < m; i++) CPPAD_ASSERT_KNOWN( + work.color[i] <= m, + "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 SetVector::value_type Set_type; + typedef typename local::internal_sparsity::pattern_type Pattern_type; + Pattern_type s; + if( work.color.size() == 0 ) + { bool transpose = false; + const char* error_msg = "SparseJacobianReverse: sparsity" + " pattern does not have proper row or column dimension"; + sparsity_user2internal(s, p, m, n, transpose, error_msg); + } + n_sweep = SparseJacobianRev(x, s, row, col, jac, work); + return n_sweep; +} +/*! +Compute a sparse Jacobian. + +The C++ source code corresponding to this operation is +\verbatim + jac = SparseJacobian(x, p) +\endverbatim + +\tparam Base +is the base type for the recording that is stored in this +ADFun object. + +\tparam BaseVector +is a simple vector class with elements of type Base. + +\tparam SetVector +is a simple vector class with elements of type + bool or std::set. + +\param x [in] +is a vector specifing the point at which to compute the Jacobian. + +\param p [in] +is the sparsity pattern for the Jacobian that we are calculating. + +\return +Will be a vector if size m * n containing the Jacobian at the +specified point (in row major order). +*/ +template +template +BaseVector ADFun::SparseJacobian( + const BaseVector& x, const SetVector& p +) +{ size_t i, j, k; + + size_t m = Range(); + size_t n = Domain(); + BaseVector jac(m * n); + + CPPAD_ASSERT_KNOWN( + size_t(x.size()) == n, + "SparseJacobian: size of x not equal domain size for f." + ); + CheckSimpleVector(); + + typedef typename SetVector::value_type Set_type; + typedef typename local::internal_sparsity::pattern_type Pattern_type; + + // initialize the return value as zero + Base zero(0); + for(i = 0; i < m; i++) + for(j = 0; j < n; j++) + jac[i * n + j] = zero; + + sparse_jacobian_work work; + CppAD::vector row; + CppAD::vector col; + if( n <= m ) + { + // need an internal copy of sparsity pattern + Pattern_type s_transpose; + bool transpose = true; + const char* error_msg = "SparseJacobian: transposed sparsity" + " pattern does not have proper row or column dimension"; + sparsity_user2internal(s_transpose, p, n, m, transpose, error_msg); + + k = 0; + for(j = 0; j < n; j++) + { typename Pattern_type::const_iterator itr(s_transpose, j); + i = *itr; + while( i != s_transpose.end() ) + { row.push_back(i); + col.push_back(j); + k++; + i = *(++itr); + } + } + size_t K = k; + BaseVector J(K); + + // now we have folded this into the following case + SparseJacobianFor(x, s_transpose, row, col, J, work); + + // now set the non-zero return values + for(k = 0; k < K; k++) + jac[ row[k] * n + col[k] ] = J[k]; + } + else + { + // need an internal copy of sparsity pattern + Pattern_type s; + bool transpose = false; + const char* error_msg = "SparseJacobian: sparsity" + " pattern does not have proper row or column dimension"; + sparsity_user2internal(s, p, m, n, transpose, error_msg); + + k = 0; + for(i = 0; i < m; i++) + { typename Pattern_type::const_iterator itr(s, i); + j = *itr; + while( j != s.end() ) + { row.push_back(i); + col.push_back(j); + k++; + j = *(++itr); + } + } + size_t K = k; + BaseVector J(K); + + // now we have folded this into the following case + SparseJacobianRev(x, s, row, col, J, work); + + // now set the non-zero return values + for(k = 0; k < K; k++) + jac[ row[k] * n + col[k] ] = J[k]; + } + + return jac; +} + +/*! +Compute a sparse Jacobian. + +The C++ source code corresponding to this operation is +\verbatim + jac = SparseJacobian(x) +\endverbatim + +\tparam Base +is the base type for the recording that is stored in this +ADFun object. + +\tparam BaseVector +is a simple vector class with elements of the Base. + +\param x [in] +is a vector specifing the point at which to compute the Jacobian. + +\return +Will be a vector of size m * n containing the Jacobian at the +specified point (in row major order). +*/ +template +template +BaseVector ADFun::SparseJacobian( const BaseVector& x ) +{ typedef CppAD::vectorBool BoolVector; + + size_t m = Range(); + size_t n = Domain(); + + // sparsity pattern for Jacobian + BoolVector p(m * n); + + if( n <= m ) + { size_t j, k; + + // use forward mode + BoolVector r(n * n); + for(j = 0; j < n; j++) + { for(k = 0; k < n; k++) + r[j * n + k] = false; + r[j * n + j] = true; + } + p = ForSparseJac(n, r); + } + else + { size_t i, k; + + // use reverse mode + BoolVector s(m * m); + for(i = 0; i < m; i++) + { for(k = 0; k < m; k++) + s[i * m + k] = false; + s[i * m + i] = true; + } + p = RevSparseJac(m, s); + } + return SparseJacobian(x, p); +} + +} // END_CPPAD_NAMESPACE +# undef CPPAD_SPARSE_JACOBIAN_MAX_MULTIPLE_DIRECTION +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/standard_math.hpp cppad-2019.02.00.0/include/cppad/core/standard_math.hpp --- cppad-2018.00.00.0/include/cppad/core/standard_math.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/standard_math.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,130 @@ +# ifndef CPPAD_CORE_STANDARD_MATH_HPP +# define CPPAD_CORE_STANDARD_MATH_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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%include/cppad/core/std_math_98.hpp + %include/cppad/core/abs.hpp + %include/cppad/core/acosh.hpp + %include/cppad/core/asinh.hpp + %include/cppad/core/atanh.hpp + %include/cppad/core/erf.hpp + %include/cppad/core/expm1.hpp + %include/cppad/core/log1p.hpp + %include/cppad/core/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 + +/* +$begin binary_math$$ + +$section The Binary Math Functions$$ + +$childtable%include/cppad/core/atan2.hpp + %include/cppad/core/pow.hpp + %include/cppad/core/azmul.hpp +%$$ + +$end +*/ +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/std_math_98.hpp cppad-2019.02.00.0/include/cppad/core/std_math_98.hpp --- cppad-2018.00.00.0/include/cppad/core/std_math_98.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/std_math_98.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,624 @@ +# ifndef CPPAD_CORE_STD_MATH_98_HPP +# define CPPAD_CORE_STD_MATH_98_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +------------------------------------------------------------------------------- +$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/general/acos.cpp +%$$ +The file +$cref acos.cpp$$ +contains an example and test of this function. + +$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/general/asin.cpp +%$$ +The file +$cref asin.cpp$$ +contains an example and test of this function. + +$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/general/atan.cpp +%$$ +The file +$cref atan.cpp$$ +contains an example and test of this function. + +$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/general/cos.cpp +%$$ +The file +$cref cos.cpp$$ +contains an example and test of this function. + +$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/general/cosh.cpp +%$$ +The file +$cref cosh.cpp$$ +contains an example and test of this function. + +$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/general/exp.cpp +%$$ +The file +$cref exp.cpp$$ +contains an example and test of this function. + +$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/general/log.cpp +%$$ +The file +$cref log.cpp$$ +contains an example and test of this function. + +$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/general/log10.cpp +%$$ +The file +$cref log10.cpp$$ +contains an example and test of this function. + +$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/general/sin.cpp +%$$ +The file +$cref sin.cpp$$ +contains an example and test of this function. + +$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/general/sinh.cpp +%$$ +The file +$cref sinh.cpp$$ +contains an example and test of this function. + +$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/general/sqrt.cpp +%$$ +The file +$cref sqrt.cpp$$ +contains an example and test of this function. + +$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/general/tan.cpp +%$$ +The file +$cref tan.cpp$$ +contains an example and test of this function. + +$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/general/tanh.cpp +%$$ +The file +$cref tanh.cpp$$ +contains an example and test of this function. + +$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##_me(); \ + } \ + template \ + inline AD AD::Name##_me (void) const \ + { \ + AD result; \ + result.value_ = CppAD::Name(value_); \ + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); \ + \ + local::ADTape* tape = AD::tape_ptr(); \ + if( tape == CPPAD_NULL ) \ + return result; \ + \ + if( tape_id_ != tape->id_ ) \ + return result; \ + \ + if(ad_type_ == dynamic_enum) \ + { result.taddr_ = tape->Rec_.put_dyn_par( \ + result.value_, local::Name##_dyn, taddr_ \ + ); \ + result.tape_id_ = tape_id_; \ + result.ad_type_ = dynamic_enum; \ + } \ + else \ + { CPPAD_ASSERT_UNKNOWN( NumArg(Op) == 1 ); \ + tape->Rec_.PutArg(taddr_); \ + result.taddr_ = tape->Rec_.PutOp(Op); \ + result.tape_id_ = tape->id_; \ + result.ad_type_ = variable_enum; \ + } \ + return result; \ + } \ + template \ + inline AD Name(const VecAD_reference &x) \ + { return x.ADBase().Name##_me(); } + +// BEGIN CppAD namespace +namespace CppAD { + + CPPAD_STANDARD_MATH_UNARY_AD(acos, local::AcosOp) + CPPAD_STANDARD_MATH_UNARY_AD(asin, local::AsinOp) + CPPAD_STANDARD_MATH_UNARY_AD(atan, local::AtanOp) + CPPAD_STANDARD_MATH_UNARY_AD(cos, local::CosOp) + CPPAD_STANDARD_MATH_UNARY_AD(cosh, local::CoshOp) + CPPAD_STANDARD_MATH_UNARY_AD(exp, local::ExpOp) + CPPAD_STANDARD_MATH_UNARY_AD(fabs, local::AbsOp) + CPPAD_STANDARD_MATH_UNARY_AD(log, local::LogOp) + CPPAD_STANDARD_MATH_UNARY_AD(sin, local::SinOp) + CPPAD_STANDARD_MATH_UNARY_AD(sinh, local::SinhOp) + CPPAD_STANDARD_MATH_UNARY_AD(sqrt, local::SqrtOp) + CPPAD_STANDARD_MATH_UNARY_AD(tan, local::TanOp) + CPPAD_STANDARD_MATH_UNARY_AD(tanh, local::TanhOp) + +# if CPPAD_USE_CPLUSPLUS_2011 + CPPAD_STANDARD_MATH_UNARY_AD(asinh, local::AsinhOp) + CPPAD_STANDARD_MATH_UNARY_AD(acosh, local::AcoshOp) + CPPAD_STANDARD_MATH_UNARY_AD(atanh, local::AtanhOp) + CPPAD_STANDARD_MATH_UNARY_AD(expm1, local::Expm1Op) + CPPAD_STANDARD_MATH_UNARY_AD(log1p, local::Log1pOp) +# endif + +# if CPPAD_USE_CPLUSPLUS_2011 + // Error function is a special case + template + inline AD erf(const AD &x) + { return x.erf_me(); + } + template + inline AD AD::erf_me (void) const + { + AD result; + result.value_ = CppAD::erf(value_); + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); + + // check if there is a recording in progress + local::ADTape* tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return result; + + // check if operand is a constant parameter + if( tape_id_ != tape->id_ ) + return result; + + if(ad_type_ == dynamic_enum) + { // dynamic paramter argument + result.taddr_ = tape->Rec_.put_dyn_par( + result.value_, local::erf_dyn, taddr_ + ); + result.tape_id_ = tape_id_; + result.ad_type_ = dynamic_enum; + } + else + { // variable argument + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::ErfOp) == 3 ); + + // arg[0] = argument to erf function + tape->Rec_.PutArg(taddr_); + + // arg[1] = zero + addr_t p = tape->Rec_.put_con_par( Base(0.0) ); + tape->Rec_.PutArg(p); + + // arg[2] = 2 / sqrt(pi) + p = tape->Rec_.put_con_par(Base( + 1.0 / std::sqrt( std::atan(1.0) ) + )); + tape->Rec_.PutArg(p); + // + result.taddr_ = tape->Rec_.PutOp(local::ErfOp); + result.tape_id_ = tape->id_; + result.ad_type_ = variable_enum; + } + return result; + } + template + inline AD erf(const VecAD_reference &x) + { return x.ADBase().erf_me(); } +# 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-2018.00.00.0/include/cppad/core/sub_eq.hpp cppad-2019.02.00.0/include/cppad/core/sub_eq.hpp --- cppad-2018.00.00.0/include/cppad/core/sub_eq.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/sub_eq.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,124 @@ +# ifndef CPPAD_CORE_SUB_EQ_HPP +# define CPPAD_CORE_SUB_EQ_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN CppAD namespace +namespace CppAD { + +template +AD& AD::operator -= (const AD &right) +{ + // compute the Base part + Base left; + left = value_; + value_ -= right.value_; + + // check if there is a recording in progress + local::ADTape* tape = AD::tape_ptr(); + if( tape == CPPAD_NULL ) + return *this; + 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 ); + + // check if left and right tapes match + bool match_left = tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + CPPAD_ASSERT_KNOWN( + tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "-= : AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // this = variable - variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::SubvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::SubvvOp) == 2 ); + + // put operand addresses in tape + tape->Rec_.PutArg(taddr_, right.taddr_); + // put operator in the tape + taddr_ = tape->Rec_.PutOp(local::SubvvOp); + // check that this is a variable + CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); + CPPAD_ASSERT_UNKNOWN( ad_type_ == variable_enum); + } + else if( (! dyn_right) & IdenticalZero(right.value_) ) + { // this = variable - 0 + } + else + { // this = variable - parameter + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::SubvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::SubvpOp) == 2 ); + + // put operand addresses in tape + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + tape->Rec_.PutArg(taddr_, p); + // put operator in the tape + taddr_ = tape->Rec_.PutOp(local::SubvpOp); + // check that this is a variable + CPPAD_ASSERT_UNKNOWN( tape_id_ == tape_id ); + CPPAD_ASSERT_UNKNOWN( ad_type_ == variable_enum); + } + } + else if( var_right ) + { // this = parameter - variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::SubpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::SubpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left); + tape->Rec_.PutArg(p, right.taddr_); + + // put operator in the tape + taddr_ = tape->Rec_.PutOp(local::SubpvOp); + + // make this a variable + tape_id_ = tape_id; + ad_type_ = variable_enum; + } + else if( dyn_left | dyn_right ) + { addr_t arg0 = taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + // parameters with a dynamic parameter results + taddr_ = tape->Rec_.put_dyn_par( + value_, local::sub_dyn, arg0, arg1 + ); + tape_id_ = tape_id; + ad_type_ = dynamic_enum; + } + return *this; +} + +CPPAD_FOLD_ASSIGNMENT_OPERATOR(-=) + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/subgraph_jac_rev.hpp cppad-2019.02.00.0/include/cppad/core/subgraph_jac_rev.hpp --- cppad-2018.00.00.0/include/cppad/core/subgraph_jac_rev.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/subgraph_jac_rev.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,345 @@ +# ifndef CPPAD_CORE_SUBGRAPH_JAC_REV_HPP +# define CPPAD_CORE_SUBGRAPH_JAC_REV_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin subgraph_jac_rev$$ +$spell + Jacobians + Jacobian + Subgraphs + subgraph + jac + rcv + Taylor + rev + nr + nc + const + Bool + nnz +$$ + +$section Compute Sparse Jacobians Using Subgraphs$$ + +$head Syntax$$ +$icode%f%.subgraph_jac_rev(%x%, %subset%) +%$$ +$icode%f%.subgraph_jac_rev( + %select_domain%, %select_range%, %x%, %matrix_out% +)%$$ + +$head See Also$$ +$cref/clear_subgraph/subgraph_reverse/clear_subgraph/$$. + +$head Purpose$$ +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the +function corresponding to $icode f$$. +Here $icode n$$ is the $cref/domain/seq_property/Domain/$$ size, +and $icode m$$ is the $cref/range/seq_property/Range/$$ size, or $icode f$$. +The syntax above takes advantage of sparsity when computing the Jacobian +$latex \[ + J(x) = F^{(1)} (x) +\] $$ +The first syntax computes the sparsity pattern and the value +of the Jacobian at the same time. +If one only wants the sparsity pattern, +it should be faster to use $cref subgraph_sparsity$$. + +$head Method$$ +This routine uses a subgraph technique. To be specific, +for each dependent variable, +it creates a subgraph of the operation sequence +containing the variables that affect the dependent variable. +This avoids the overhead of performing set operations +that is inherent in other methods for computing sparsity patterns. + +$head BaseVector$$ +The type $icode BaseVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$icode Base$$. + +$head SizeVector$$ +The type $icode SizeVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. + +$head BoolVector$$ +The type $icode BoolVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code bool$$. + +$head f$$ +This object has prototype +$codei% + ADFun<%Base%> %f% +%$$ +Note that the Taylor coefficients stored in $icode f$$ are affected +by this operation; see +$cref/uses forward/sparse_jac/Uses Forward/$$ below. + +$head x$$ +This argument has prototype +$codei% + const %BaseVector%& %x% +%$$ +It is the value of $icode x$$ at which we are computing the Jacobian. + +$head Uses Forward$$ +After each call to $cref Forward$$, +the object $icode f$$ contains the corresponding +$cref/Taylor coefficients/glossary/Taylor Coefficient/$$. +After a call to $code sparse_jac_forward$$ or $code sparse_jac_rev$$, +the zero order coefficients correspond to +$codei% + %f%.Forward(0, %x%) +%$$ +All the other forward mode coefficients are unspecified. + +$head subset$$ +This argument has prototype +$codei% + sparse_rcv<%SizeVector%, %BaseVector%>& %subset% +%$$ +Its row size is $icode%subset%.nr() == %m%$$, +and its column size is $icode%subset%.nc() == %n%$$. +It specifies which elements of the Jacobian are computed. +The input elements in its value vector +$icode%subset%.val()%$$ do not matter. +Upon return it contains the value of the corresponding elements +of the Jacobian. + +$head select_domain$$ +The argument $icode select_domain$$ has prototype +$codei% + const %BoolVector%& %select_domain% +%$$ +It has size $latex n$$ and specifies which independent variables +to include. + +$head select_range$$ +The argument $icode select_range$$ has prototype +$codei% + const %BoolVector%& %select_range% +%$$ +It has size $latex m$$ and specifies which components of the range +to include in the calculation. +A subgraph is built for each dependent variable and the selected set +of independent variables. + +$head matrix_out$$ +This argument has prototype +$codei% + sparse_rcv<%SizeVector%, %BaseVector%>& %matrix_out% +%$$ +This input value of $icode matrix_out$$ does not matter. +Upon return $icode matrix_out$$ is +$cref/sparse matrix/sparse_rcv/$$ representation of $latex F^{(1)} (x)$$. +The matrix has $latex m$$ rows, $latex n$$ columns. +If $icode%select_domain%[%j%]%$$ is true, +$icode%select_range%[%i%]%$$ is true, and +$latex F_i (x)$$ depends on $latex x_j$$, +then the pair $latex (i, j)$$ is in $icode matrix_out$$. +For each $icode%k% = 0 , %...%, %matrix_out%.nnz()%$$, let +$codei% + %i% = %matrix_out%.row()[%k%] + %j% = %matrix_out%.col()[%k%] + %v% = %matrix_out%.val()[%k%] +%$$ +It follows that the partial of $latex F_i (x)$$ with respect to +$latex x_j$$ is equal to $latex v$$. + + +$head Example$$ +$children% + example/sparse/subgraph_jac_rev.cpp% + example/sparse/subgraph_hes2jac.cpp +%$$ +The files $cref subgraph_jac_rev.cpp$$ and $cref subgraph_hes2jac.cpp$$ +are examples and tests using $code subgraph_jac_rev$$. +They returns $code true$$ for success and $code false$$ for failure. + +$end +----------------------------------------------------------------------------- +*/ +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +Subgraph sparsity patterns. + +\tparam Base +is the base type for this recording. + +\tparam SizeVector +is the simple vector with elements of type size_t that is used for +row, column index sparsity patterns. + +\tparam BaseVector +a simple vector class with elements of type Base. + +\param x +a vector of length n, the number of independent variables in f +(this ADFun object). + +\param subset +specifices the subset of the sparsity pattern where the Jacobian is evaluated. +subset.nr() == m, +subset.nc() == n. +*/ +template +template +void ADFun::subgraph_jac_rev( + const BaseVector& x , + sparse_rcv& subset ) +{ size_t m = Range(); + size_t n = Domain(); + // + CPPAD_ASSERT_KNOWN( + subset.nr() == m, + "subgraph_jac_rev: subset.nr() not equal range dimension for f" + ); + CPPAD_ASSERT_KNOWN( + subset.nc() == n, + "subgraph_jac_rev: subset.nc() not equal domain dimension for f" + ); + // + // point at which we are evaluating Jacobian + Forward(0, x); + // + // nnz and row, column, and row_major vectors for subset + size_t nnz = subset.nnz(); + const SizeVector& row( subset.row() ); + const SizeVector& col( subset.col() ); + SizeVector row_major = subset.row_major(); + // + // determine set of independent variabels + local::pod_vector select_domain(n); + for(size_t j = 0; j < n; j++) + select_domain[j] = false; + for(size_t k = 0; k < nnz; k++) + select_domain[ col[k] ] = true; + // + // initialize reverse mode computation on subgraphs + subgraph_reverse(select_domain); + // + // memory used to hold subgraph_reverse results + BaseVector dw; + SizeVector dw_col; + // + // initialize index in row_major + size_t k = 0; + Base zero(0); + while(k < nnz ) + { size_t q = 1; + size_t i_dep = row[ row_major[k] ]; + size_t i_ind = col[ row_major[k] ]; + size_t ell = i_dep; + subgraph_reverse(q, ell, dw_col, dw); + // + size_t c = 0; + while( i_dep == ell ) + { // check that subgraph_reverse has retured this value + if( c < size_t( dw_col.size() ) ) + { if( i_ind == dw_col[c++] ) + subset.set( row_major[k], dw[i_ind] ); + else + subset.set( row_major[k], zero); + } + else + subset.set( row_major[k], zero); + ++k; + if( k == nnz ) + { i_dep = m; + i_ind = n; + } + else + { i_dep = row[ row_major[k] ]; + i_ind = col[ row_major[k] ]; + } + } + } + return; +} +template +template +void ADFun::subgraph_jac_rev( + const BoolVector& select_domain , + const BoolVector& select_range , + const BaseVector& x , + sparse_rcv& matrix_out ) +{ size_t m = Range(); + size_t n = Domain(); + // + // point at which we are evaluating Jacobian + Forward(0, x); + // + // nnz and row, column, and row_major vectors for subset + local::pod_vector row_out; + local::pod_vector col_out; + local::pod_vector_maybe val_out; + // + // initialize reverse mode computation on subgraphs + subgraph_reverse(select_domain); + // + // memory used to hold subgraph_reverse results + BaseVector dw; + SizeVector col; + // + // loop through selected independent variables + for(size_t i = 0; i < m; ++i) if( select_range[i] ) + { // compute Jacobian and sparsity for this dependent variable + size_t q = 1; + subgraph_reverse(q, i, col, dw); + CPPAD_ASSERT_UNKNOWN( size_t( dw.size() ) == n ); + // + // offset for this dependent variable + size_t index = row_out.size(); + CPPAD_ASSERT_UNKNOWN( col_out.size() == index ); + CPPAD_ASSERT_UNKNOWN( val_out.size() == index ); + // + // extend vectors to hold results for this dependent variable + size_t col_size = size_t( col.size() ); + row_out.extend( col_size ); + col_out.extend( col_size ); + val_out.extend( col_size ); + // + // store results for this dependent variable + for(size_t c = 0; c < col_size; ++c) + { row_out[index + c] = i; + col_out[index + c] = col[c]; + val_out[index + c] = dw[ col[c] ]; + } + } + // + // create sparsity pattern corresponding to row_out, col_out + size_t nr = m; + size_t nc = n; + size_t nnz = row_out.size(); + sparse_rc pattern(nr, nc, nnz); + for(size_t k = 0; k < nnz; ++k) + pattern.set(k, row_out[k], col_out[k]); + // + // create sparse matrix + sparse_rcv matrix(pattern); + for(size_t k = 0; k < nnz; ++k) + matrix.set(k, val_out[k]); + // + // return matrix + matrix_out = matrix; + // + return; +} +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/subgraph_reverse.hpp cppad-2019.02.00.0/include/cppad/core/subgraph_reverse.hpp --- cppad-2018.00.00.0/include/cppad/core/subgraph_reverse.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/subgraph_reverse.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,494 @@ +# ifndef CPPAD_CORE_SUBGRAPH_REVERSE_HPP +# define CPPAD_CORE_SUBGRAPH_REVERSE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin subgraph_reverse$$ +$spell + resize + subgraph + Subgraphs + dw + Taylor + Bool + const +$$ + +$section Reverse Mode Using Subgraphs$$ + +$head Syntax$$ +$icode%f%.subgraph_reverse(%select_domain%) +%$$ +$icode%f%.subgraph_reverse(%q%, %ell%, %col%, %dw%) +%$$ +$icode%f%.clear_subgraph() +%$$ + +$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$$. +Reverse mode computes the derivative of the $cref Forward$$ mode +$cref/Taylor coefficients/glossary/Taylor Coefficient/$$ +with respect to the domain variable $latex x$$. + +$head Notation$$ +We use the reverse mode +$cref/notation/reverse_any/Notation/$$ with the following change: +the vector +$cref/w^(k)/reverse_any/Notation/w^(k)/$$ is defined +$latex \[ +w_i^{(k)} = \left\{ \begin{array}{ll} + 1 & {\rm if} \; k = q-1 \; \R{and} \; i = \ell + \\ + 0 & {\rm otherwise} +\end{array} \right. +\] $$ + +$head BaseVector$$ +The type $icode BaseVector$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$icode Base$$. +The routine $cref CheckSimpleVector$$ will generate an error message +if this is not the case. + +$head BoolVector$$ +The type $icode BoolVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code bool$$. + +$head SizeVector$$ +The type $icode SizeVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. + +$head select_domain$$ +The argument $icode select_domain$$ has prototype +$codei% + const %BoolVector%& %select_domain% +%$$ +It has size $latex n$$ and specifies which independent variables +to include in future $code subgraph_reverse$$ calculations. +If $icode%select_domain%[%j%]%$$ is false, +it is assumed that $latex u^{(k)}_j = 0$$ for $latex k > 0$$; i.e., +the $th j$$ component of the Taylor coefficient for $latex x$$, +with order greater that zero, are zero; see +$cref/u^(k)/reverse_any/Notation/u^(k)/$$. + +$head q$$ +The argument $icode q$$ has prototype +$codei% + size_t %q% +%$$ +and specifies the number of Taylor coefficient orders to be differentiated. + +$head ell$$ +The argument $icode ell$$ has prototype +$codei% + size_t %ell% +%$$ +and specifies the dependent variable index that we are computing +the derivatives for; i.e. $latex \ell$$. +This index can only be used once per, and after, a call that selects +the independent variables using $icode select_domain$$. + +$head col$$ +This argument $icode col$$ has prototype +$codei% + %SizeVector% %col% +%$$ +The input size and value of its elements do not matter. +The $icode%col%.resize%$$ member function is used to change its size +to the number the number of possible non-zero derivative components. +For each $icode c$$, +$codei% + %select_domain%[ %col%[%c%] ] == true + %col%[%c%+1] >= %col%[%c%] +%$$ +and the derivative with respect to the $th j$$ independent +variable is possibly non-zero where +$icode%j% = %col%[%c%]%$$. + +$head dw$$ +The argument $icode dw$$ has prototype +$codei% + %Vector% %dw% +%$$ +Its input size and value does not matter. +Upon return, +it is a vector with size $latex n \times q$$. +For $latex c = 0 , \ldots , %col%.size()-1$$, +and $latex k = 0, \ldots , q-1$$, +$latex \[ + dw[ j * q + k ] = W^{(1)} ( x )_{j,k} +\] $$ +is the derivative of the specified Taylor coefficients w.r.t the $th j$$ +independent variable where $icode%j% = %col%[%c%]%$$. +Note that this corresponds to the $cref reverse_any$$ convention when +$cref/w/reverse_any/w/$$ has size $icode%m% * %q%$$. + +$head clear_subgraph$$ +Calling this routine will free memory that holds +information between calls to subgraph calculations so that +it does not need to be recalculated. +(This memory is automatically freed when $icode f$$ is deleted.) +You cannot free this memory between calls that select the domain +and corresponding calls that compute reverse mode derivatives. +Some of this information is also used by $cref subgraph_sparsity$$. + +$head Example$$ +$children% + example/sparse/subgraph_reverse.cpp +%$$ +The file +$cref subgraph_reverse.cpp$$ +contains an example and test of this operation. + +$end +*/ +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file subgraph_reverse.hpp +Compute derivatvies using reverse mode and subgraphs. +*/ + +/// clear all subgraph information +template +void ADFun::clear_subgraph(void) +{ play_.clear_random(); + subgraph_info_.clear(); + subgraph_partial_.clear(); +} + +/*! +Initialize reverse mode derivative computation on subgraphs. + +\param select_domain +is a vector with size equal to the dimension of the domain for this function. +Only derivatives w.r.t. the components that are true will be computed. + +\par subgraph_info_.map_user_op() +If the input size of this vector is zero, +its value for this player (play_) is computed. + +\par subgraph_info.in_subgraph_ +This vector is initialized for a reverse mode computation on subgraphs. + +\par subgraph_info.select_domain() +This vector is set equal to the select_domain argument. + +\par subgraph_info.process_range() +This vector is initialized to have size Range() and its elements are false. +*/ + +template +template +void ADFun::subgraph_reverse( const BoolVector& select_domain ) +{ using local::pod_vector; + // + CPPAD_ASSERT_UNKNOWN( + dep_taddr_.size() == subgraph_info_.n_dep() + ); + CPPAD_ASSERT_UNKNOWN( + size_t( select_domain.size() ) == subgraph_info_.n_ind() + ); + + // map_user_op + if( subgraph_info_.map_user_op().size() == 0 ) + subgraph_info_.set_map_user_op(&play_); + else + { CPPAD_ASSERT_UNKNOWN( subgraph_info_.check_map_user_op(&play_) ); + } + CPPAD_ASSERT_UNKNOWN( + subgraph_info_.map_user_op().size() == play_.num_op_rec() + ); + + // initialize for reverse mode subgraph computations + switch( play_.address_type() ) + { + case local::play::unsigned_short_enum: + subgraph_info_.init_rev(&play_, select_domain); + break; + + case local::play::unsigned_int_enum: + subgraph_info_.init_rev(&play_, select_domain); + break; + + case local::play::size_t_enum: + subgraph_info_.init_rev(&play_, select_domain); + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + } + CPPAD_ASSERT_UNKNOWN( + subgraph_info_.in_subgraph().size() == play_.num_op_rec() + ); + + return; +} + + +/*! +Use reverse mode to compute derivative of Taylor coefficients on a subgraph. + +The function +\f$ X : {\bf R} \times {\bf R}^{n \times q} \rightarrow {\bf R} \f$ +is defined by +\f[ +X(t , u) = \sum_{k=0}^{q-1} u^{(k)} t^k +\f] +The function +\f$ Y : {\bf R} \times {\bf R}^{n \times q} \rightarrow {\bf R} \f$ +is defined by +\f[ +Y(t , u) = F[ X(t, u) ] +\f] +The function +\f$ W : {\bf R}^{n \times q} \rightarrow {\bf R} \f$ is defined by +\f[ +W(u) = \sum_{k=0}^{q-1} ( w^{(k)} )^{\rm T} +\frac{1}{k !} \frac{ \partial^k } { t^k } Y(0, u) +\f] + +\param q +is the number of Taylor coefficient we are differentiating. + +\param ell +is the component of the range that is selected for differentiation. + +\param col +is the set of indices j = col[c] where the return value is defined. +If an index j is not in col, then either its derivative is zero, +or it is not in select_domain. + +\param dw +Is a vector \f$ dw \f$ such that +for j = col[c], +\f$ k = 0 , \ldots , q-1 \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$ +that corresponding to the forward mode Taylor coefficients +for the independent variables as specified by previous calls to Forward. + +\par subgraph_info.process_range() +The element process_range[ell] is set to true by this operation. + +\par subgraph_info.in_subgraph_ +some of the elements of this vector are set to have value ell +(so it can not longer be used to determine the subgraph corresponding to +the ell-th dependent variable). +*/ +template +template +void ADFun::subgraph_reverse_helper( + size_t q , + size_t ell , + SizeVector& col , + BaseVector& dw ) +{ using local::pod_vector; + // used to identify the RecBase type in calls to sweeps + RecBase not_used_rec_base; + // + // get a random iterator for this player + play_.template setup_random(); + typename local::play::const_random_iterator random_itr = + play_.template get_random(); + + // check BaseVector is Simple Vector class with Base type elements + CheckSimpleVector(); + CPPAD_ASSERT_KNOWN( + q > 0, + "The second argument to Reverse must be greater than zero." + ); + CPPAD_ASSERT_KNOWN( + num_order_taylor_ >= q, + "Less than q Taylor coefficients are currently stored" + " in this ADFun object." + ); + CPPAD_ASSERT_KNOWN( + num_direction_taylor_ == 1, + "reverse mode for Forward(q, r, xq) with more than one direction" + "\n(r > 1) is not yet supported." + ); + CPPAD_ASSERT_KNOWN( + ell < dep_taddr_.size(), + "dependent variable index in to large for this function" + ); + CPPAD_ASSERT_KNOWN( + subgraph_info_.process_range()[ell] == false, + "This dependent variable index has already been processed\n" + "after the previous subgraph_reverse(select_domain)." + ); + + // subgraph of operators connected to dependent variable ell + pod_vector subgraph; + subgraph_info_.get_rev( + random_itr, dep_taddr_, addr_t(ell), subgraph + ); + + // Add all the atomic function call operators + // for calls that have first operator in the subgraph + local::subgraph::entire_call(random_itr, subgraph); + + // First add the BeginOp and EndOp to the subgraph and then sort it + // sort the subgraph + addr_t i_op_begin_op = 0; + addr_t i_op_end_op = addr_t( play_.num_op_rec() - 1); + subgraph.push_back(i_op_begin_op); + subgraph.push_back(i_op_end_op); + std::sort( subgraph.data(), subgraph.data() + subgraph.size() ); + CPPAD_ASSERT_UNKNOWN( subgraph[0] == i_op_begin_op ); + CPPAD_ASSERT_UNKNOWN( subgraph[subgraph.size()-1] == i_op_end_op ); + /* + // Use this printout for debugging + std::cout << "{ "; + for(size_t k = 0; k < subgraph.size(); k++) + { if( k > 0 ) + std::cout << ", "; + std::cout << subgraph[k]; + } + std::cout << "}\n"; + */ + + // initialize subgraph_partial_ matrix to zero on subgraph + Base zero(0); + subgraph_partial_.resize(num_var_tape_ * q); + for(size_t k = 0; k < subgraph.size(); ++k) + { + size_t i_op = size_t( subgraph[k] ); + local::OpCode op; + const addr_t* arg; + size_t i_var; + random_itr.op_info(i_op, op, arg, i_var); + if( NumRes(op) == 0 ) + { CPPAD_ASSERT_UNKNOWN( + op == local::AFunOp || + op == local::FunapOp || + op == local::FunavOp || + op == local::FunrpOp || + op == local::EndOp + ); + } + else if( op != local::BeginOp ) + { CPPAD_ASSERT_UNKNOWN( i_var >= NumRes(op) ); + size_t j_var = i_var + 1 - NumRes(op); + for(size_t i = j_var; i <= i_var; ++i) + { for(size_t j = 0; j < q; ++j) + subgraph_partial_[i * q + j] = zero; + } + } + } + + // set partial to one for component we are differentiating + subgraph_partial_[ dep_taddr_[ell] * q + q - 1] = Base(1); + + // evaluate the derivatives + CPPAD_ASSERT_UNKNOWN( cskip_op_.size() == play_.num_op_rec() ); + CPPAD_ASSERT_UNKNOWN( load_op_.size() == play_.num_load_op_rec() ); + size_t n = Domain(); + // + local::play::const_subgraph_iterator subgraph_itr = + play_.end_subgraph(random_itr, &subgraph); + // + local::sweep::reverse( + q - 1, + n, + num_var_tape_, + &play_, + cap_order_taylor_, + taylor_.data(), + q, + subgraph_partial_.data(), + cskip_op_.data(), + load_op_, + subgraph_itr, + not_used_rec_base + ); + + // number of non-zero in return value + size_t col_size = 0; + size_t subgraph_index = 0; + CPPAD_ASSERT_UNKNOWN( subgraph[subgraph_index] == 0 ); + // Skip BeginOp + ++subgraph_index; + while( subgraph_index < subgraph.size() ) + { // check for InvOp + if( subgraph[subgraph_index] > addr_t(n) ) + subgraph_index = subgraph.size(); + else + { ++col_size; + ++subgraph_index; + } + } + col.resize(col_size); + + // return the derivative values + dw.resize(n * q); + for(size_t c = 0; c < col_size; ++c) + { size_t i_op = size_t( subgraph[c + 1] ); + CPPAD_ASSERT_UNKNOWN( play_.GetOp(i_op) == local::InvOp ); + // + size_t j = i_op - 1; + CPPAD_ASSERT_UNKNOWN( i_op == random_itr.var2op( ind_taddr_[j] ) ); + // + // return paritial for this independent variable + col[c] = j; + for(size_t k = 0; k < q; k++) + dw[j * q + k ] = subgraph_partial_[ind_taddr_[j] * q + k]; + } + // + CPPAD_ASSERT_KNOWN( ! ( hasnan(dw) && check_for_nan_ ) , + "f.subgraph_reverse(dw, q, ell): dw has a nan,\n" + "but none of f's Taylor coefficents are nan." + ); + // + return; +} +/*! +\copydoc subgraph_reverse_helper + +*/ +template +template +void ADFun::subgraph_reverse( + size_t q , + size_t ell , + SizeVector& col , + BaseVector& dw ) +{ using local::pod_vector; + // + // call proper version of helper function + switch( play_.address_type() ) + { + case local::play::unsigned_short_enum: + subgraph_reverse_helper(q, ell, col, dw); + break; + + case local::play::unsigned_int_enum: + subgraph_reverse_helper(q, ell, col, dw); + break; + + case local::play::size_t_enum: + subgraph_reverse_helper(q, ell, col, dw); + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + } + // + return; +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/subgraph_sparsity.hpp cppad-2019.02.00.0/include/cppad/core/subgraph_sparsity.hpp --- cppad-2018.00.00.0/include/cppad/core/subgraph_sparsity.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/subgraph_sparsity.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,242 @@ +# ifndef CPPAD_CORE_SUBGRAPH_SPARSITY_HPP +# define CPPAD_CORE_SUBGRAPH_SPARSITY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin subgraph_sparsity$$ +$spell + const + subgraph + subgraphs + rc + Jacobian + bool +$$ + +$section Subgraph Dependency Sparsity Patterns$$ + +$head Syntax$$ +$icode%f%.subgraph_sparsity( + %select_domain%, %select_range%, %transpose%, %pattern_out% +)%$$ + +$head See Also$$ +$cref/clear_subgraph/subgraph_reverse/clear_subgraph/$$. + +$head Notation$$ +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the +$cref/AD function/glossary/AD Function/$$ corresponding to +the operation sequence stored in $icode f$$. + + +$head Method$$ +This routine uses a subgraph technique. To be specific, +for each dependent variable, +it creates a subgraph of the operation sequence +containing the variables that affect the dependent variable. +This avoids the overhead of performing set operations +that is inherent in other methods for computing sparsity patterns. + +$head Atomic Function$$ +The sparsity calculation for +$cref/atomic functions/atomic_two_afun/$$ in the $icode f$$ operation sequence +are not efficient. To be specific, each atomic function is treated as if +all of its outputs depend on all of its inputs. +This may be improved upon in the future; see the +$cref/subgraph sparsity/wish_list/Subgraph/Sparsity/$$ +wish list item. + +$head BoolVector$$ +The type $icode BoolVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code bool$$. + +$head SizeVector$$ +The type $icode SizeVector$$ is a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. + +$head f$$ +The object $icode f$$ has prototype +$codei% + ADFun<%Base%> %f% +%$$ + +$head select_domain$$ +The argument $icode select_domain$$ has prototype +$codei% + const %BoolVector%& %select_domain% +%$$ +It has size $latex n$$ and specifies which independent variables +to include in the calculation. +If not all the independent variables are included in the calculation, +a forward pass on the operation sequence is used to determine which +nodes may be in the subgraphs. + +$head select_range$$ +The argument $icode select_range$$ has prototype +$codei% + const %BoolVector%& %select_range% +%$$ +It has size $latex m$$ and specifies which components of the range +to include in the calculation. +A subgraph is built for each dependent variable +and the selected set of independent variables. + +$head transpose$$ +This argument has prototype +$codei% + bool %transpose% +%$$ +If $icode transpose$$ it is false (true), +upon return $icode pattern_out$$ is a sparsity pattern for +$latex J(x)$$ ($latex J(x)^\R{T}$$) defined below. + +$head pattern_out$$ +This argument has prototype +$codei% + sparse_rc<%SizeVector%>& %pattern_out% +%$$ +This input value of $icode pattern_out$$ does not matter. +Upon return $icode pattern_out$$ is a +$cref/dependency pattern/dependency.cpp/Dependency Pattern/$$ +for $latex F(x)$$. +The pattern has $latex m$$ rows, $latex n$$ columns. +If $icode%select_domain%[%j%]%$$ is true, +$icode%select_range%[%i%]%$$ is true, and +$latex F_i (x)$$ depends on $latex x_j$$, +then the pair $latex (i, j)$$ is in $icode pattern_out$$. +Not that this is also a sparsity pattern for the Jacobian +$latex \[ + J(x) = R F^{(1)} (x) D +\] $$ +where $latex D$$ ($latex R$$) is the diagonal matrix corresponding +to $icode select_domain$$ ($icode select_range$$). + +$head Example$$ +$children% + example/sparse/subgraph_sparsity.cpp +%$$ +The file +$cref subgraph_sparsity.cpp$$ +contains an example and test of this operation. + +$end +----------------------------------------------------------------------------- +*/ +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/*! +Subgraph sparsity patterns. + +\tparam Base +is the base type for this recording. + +\tparam SizeVector +is the simple vector with elements of type size_t that is used for +row, column index sparsity patterns. + +\param select_domain +sparsity pattern for the diagonal of the square matrix D. + +\param select_range +sparsity pattern for the diagnoal of the square matrix R + +\param transpose +If true, the return is a dependency sparsity pattern for +\f$ D F^{(1)} (x)^T R \f$ + +\param pattern_out +The input value does not matter. +The return value is a dependency sparsity pattern for \f$ R F^{(1)} (x) D \f$ +where F is the function corresponding to the operation sequence +and x is any argument value. +is the sparsity pattern transposed. +*/ +template +template +void ADFun::subgraph_sparsity( + const BoolVector& select_domain , + const BoolVector& select_range , + bool transpose , + sparse_rc& pattern_out ) +{ + // compute the sparsity pattern in row, col + local::pod_vector row; + local::pod_vector col; + + // create the optimized recording + switch( play_.address_type() ) + { + case local::play::unsigned_short_enum: + local::subgraph::subgraph_sparsity( + &play_, + subgraph_info_, + dep_taddr_, + select_domain, + select_range, + row, + col + ); + break; + + case local::play::unsigned_int_enum: + local::subgraph::subgraph_sparsity( + &play_, + subgraph_info_, + dep_taddr_, + select_domain, + select_range, + row, + col + ); + break; + + case local::play::size_t_enum: + local::subgraph::subgraph_sparsity( + &play_, + subgraph_info_, + dep_taddr_, + select_domain, + select_range, + row, + col + ); + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + } + + CPPAD_ASSERT_UNKNOWN( row.size() == col.size() ); + + // return the sparsity pattern + size_t nr = dep_taddr_.size(); + size_t nc = ind_taddr_.size(); + size_t nnz = row.size(); + if( transpose ) + { pattern_out.resize(nc, nr, nnz); + for(size_t k = 0; k < nnz; k++) + pattern_out.set(k, col[k], row[k]); + } + else + { pattern_out.resize(nr, nc, nnz); + for(size_t k = 0; k < nnz; k++) + pattern_out.set(k, row[k], col[k]); + } + return; +} +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/sub.hpp cppad-2019.02.00.0/include/cppad/core/sub.hpp --- cppad-2018.00.00.0/include/cppad/core/sub.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/sub.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,125 @@ +# ifndef CPPAD_CORE_SUB_HPP +# define CPPAD_CORE_SUB_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN CppAD namespace +namespace CppAD { + +template +AD operator - (const AD &left , const AD &right) +{ + // compute the Base part + AD result; + result.value_ = left.value_ - right.value_; + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); + + // check if there is a recording in progress + local::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 ); + + // check if left and right tapes match + bool match_left = left.tape_id_ == tape_id; + bool match_right = right.tape_id_ == tape_id; + + // check if left and right are dynamic parameters + bool dyn_left = match_left & (left.ad_type_ == dynamic_enum); + bool dyn_right = match_right & (right.ad_type_ == dynamic_enum); + + // check if left and right are variables + bool var_left = match_left & (left.ad_type_ != dynamic_enum); + bool var_right = match_right & (right.ad_type_ != dynamic_enum); + + + CPPAD_ASSERT_KNOWN( + left.tape_id_ == right.tape_id_ || ! match_left || ! match_right , + "Subtract: AD variables or dynamic parameters on different threads." + ); + if( var_left ) + { if( var_right ) + { // result = variable - variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::SubvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::SubvvOp) == 2 ); + + // put operand addresses in tape + tape->Rec_.PutArg(left.taddr_, right.taddr_); + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::SubvvOp); + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + else if( (! dyn_right) & IdenticalZero(right.value_) ) + { // result = variable - 0 + result.make_variable(left.tape_id_, left.taddr_); + } + else + { // result = variable - parameter + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::SubvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::SubvpOp) == 2 ); + + // put operand addresses in tape + addr_t p = right.taddr_; + if( ! dyn_right ) + p = tape->Rec_.put_con_par(right.value_); + tape->Rec_.PutArg(left.taddr_, p); + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::SubvpOp); + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + } + else if( var_right ) + { // result = parameter - variable + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::SubpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::SubpvOp) == 2 ); + + // put operand addresses in tape + addr_t p = left.taddr_; + if( ! dyn_left ) + p = tape->Rec_.put_con_par(left.value_); + tape->Rec_.PutArg(p, right.taddr_); + // put operator in the tape + result.taddr_ = tape->Rec_.PutOp(local::SubpvOp); + // make result a variable + result.tape_id_ = tape_id; + result.ad_type_ = variable_enum; + } + else if( dyn_left | dyn_right ) + { addr_t arg0 = left.taddr_; + addr_t arg1 = right.taddr_; + if( ! dyn_left ) + arg0 = tape->Rec_.put_con_par(left.value_); + if( ! dyn_right ) + arg1 = tape->Rec_.put_con_par(right.value_); + // + // parameters with a dynamic parameter result + result.taddr_ = tape->Rec_.put_dyn_par( + result.value_, local::sub_dyn, arg0, arg1 + ); + result.tape_id_ = tape_id; + result.ad_type_ = dynamic_enum; + } + return result; +} + +// convert other cases into the case above +CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(-) + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/tape_link.hpp cppad-2019.02.00.0/include/cppad/core/tape_link.hpp --- cppad-2018.00.00.0/include/cppad/core/tape_link.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/tape_link.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,265 @@ +# ifndef CPPAD_CORE_TAPE_LINK_HPP +# define CPPAD_CORE_TAPE_LINK_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include + +// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file tape_link.hpp +Routines that Link AD and local::ADTape Objects. + +The routines that connect the AD class to the corresponding tapes +(one for each thread). +*/ + +/*! +Pointer to the tape identifier for this AD class and the specific thread. + +\tparam Base +is the base type for this AD class. + +\param thread +is the thread number. The following condition must hold +\code +(! thread_alloc::in_parallel()) || thread == thread_alloc::thread_num() +\endcode + +\return +is a pointer to the tape identifier for this thread and AD class. +*/ +template +tape_id_t* AD::tape_id_ptr(size_t thread) +{ 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() + ); + return tape_id_table + thread; +} + +/*! +Handle for the tape for this AD class and the specific thread. + +\tparam Base +is the base type for this AD class. + + +\param thread +is the thread number; i.e., +\code +(! thread_alloc::in_parallel()) || thread == thread_alloc::thread_num() +\endcode + +\return +is a handle for the tape for this AD class and the specified thread. +*/ +template +local::ADTape** AD::tape_handle(size_t thread) +{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + static local::ADTape* tape_table[CPPAD_MAX_NUM_THREADS]; + CPPAD_ASSERT_UNKNOWN( + (! thread_alloc::in_parallel()) || thread == thread_alloc::thread_num() + ); + return tape_table + thread; +} + +/*! +Pointer for the tape for this AD class and the current thread. + +\code +thread == thread_alloc::thread_num() +\endcode + +\tparam Base +is the base type corresponding to AD operations. + +\return +is a pointer to the tape that is currently recording AD operations +for the current thread. +If this value is CPPAD_NULL, there is no tape currently +recording AD operations for this thread. +*/ +template +local::ADTape* AD::tape_ptr(void) +{ size_t thread = thread_alloc::thread_num(); + return *tape_handle(thread); +} + +/*! +Pointer for the tape for this AD class and the specified tape +identifier. + +\tparam Base +is the base type corresponding to AD operations. + +\param tape_id +is the identifier for the tape that is currently recording +AD operations for the current thread. +It must hold that the current thread is +\code + thread = size_t( tape_id % CPPAD_MAX_NUM_THREADS ) +\endcode +and that there is a tape recording AD operations +for this 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. + +\return +is a pointer to the tape that is currently recording AD operations +for the current thread (and it is not CPPAD_NULL). + +\par Restrictions +This routine should only be called if there is a tape recording operaitons +for the specified thread. +*/ +template +local::ADTape* AD::tape_ptr(tape_id_t tape_id) +{ size_t thread = size_t( tape_id % CPPAD_MAX_NUM_THREADS ); + CPPAD_ASSERT_KNOWN( + thread == thread_alloc::thread_num(), + "Attempt to use an AD variable with two different threads." + ); + CPPAD_ASSERT_UNKNOWN( tape_id == *tape_id_ptr(thread) ); + CPPAD_ASSERT_UNKNOWN( *tape_handle(thread) != CPPAD_NULL ); + return *tape_handle(thread); +} + +/*! +Create and delete tapes that record AD operations for current thread. + +\par thread +the current thread is given by +\code +thread = thread_alloc::thread_num() +\endcode + +\tparam Base +is the base type corresponding to AD operations. + +\param job +This argument determines if we are creating a new tape, or deleting an +old one. + +- new_tape_manage : +Creates and a new tape. +It is assumed that there is no tape recording AD operations +for this thread when tape_manage is called. + +- delete_tape_manage : +It is assumed that there is a tape recording AD operations +for this thread when tape_manage is called. +The value of *tape_id_ptr(thread) will be advanced by + CPPAD_MAX_NUM_THREADS. + + +\return +- job == new_tape_manage: a pointer to the new tape is returned. +- job == delete_tape_manage: the value CPPAD_NULL is returned. +*/ +template +local::ADTape* AD::tape_manage(tape_manage_enum job) +{ + CPPAD_ASSERT_UNKNOWN( + job == new_tape_manage || job == delete_tape_manage + ); + // thread, tape_id, and tape for this call + size_t thread = thread_alloc::thread_num(); + tape_id_t* tape_id_p = tape_id_ptr(thread); + local::ADTape** tape_h = tape_handle(thread); + + + // ----------------------------------------------------------------------- + // new_tape_manage + if( job == new_tape_manage ) + { + // tape for this thread must be null at the start + CPPAD_ASSERT_UNKNOWN( *tape_h == CPPAD_NULL ); + + // allocate separate memroy to avoid false sharing + *tape_h = new local::ADTape(); + + // if tape id is zero, initialize it so that + // thread == tape id % CPPAD_MAX_NUM_THREADS + if( *tape_id_p == 0 ) + { size_t new_tape_id = thread + CPPAD_MAX_NUM_THREADS; + CPPAD_ASSERT_KNOWN( + size_t( std::numeric_limits::max() ) >= new_tape_id, + "cppad_tape_id_type maximum value has been execeeded" + ); + *tape_id_p = static_cast( new_tape_id ); + } + // make sure tape_id value is valid for this thread + CPPAD_ASSERT_UNKNOWN( + size_t( *tape_id_p % CPPAD_MAX_NUM_THREADS ) == thread + ); + // set the tape_id for this tape + (*tape_h)->id_ = *tape_id_p; + } + // ----------------------------------------------------------------------- + // delete_tape_manage + if( job == delete_tape_manage ) + { // delete this tape + CPPAD_ASSERT_UNKNOWN( *tape_h != CPPAD_NULL ); + delete *tape_h; + *tape_h = CPPAD_NULL; + // + // advance tape_id so that all AD variables become parameters + CPPAD_ASSERT_KNOWN( + std::numeric_limits::max() + - CPPAD_MAX_NUM_THREADS > *tape_id_p, + "To many different tapes given the type used for " + "CPPAD_TAPE_ID_TYPE" + ); + *tape_id_p += CPPAD_MAX_NUM_THREADS; + } + // ----------------------------------------------------------------------- + return *tape_h; +} + +/*! +Get a pointer to tape that records AD operations for the current thread. + +\tparam Base +is the base type corresponding to AD operations. + +\par thread +The current thread must be given by +\code + thread = this->tape_id_ % CPPAD_MAX_NUM_THREADS +\endcode + +\return +is a pointer to the tape that is currently recording AD operations +for the current thread. +This value must not be CPPAD_NULL; i.e., there must be a tape currently +recording AD operations for this thread. +*/ + +template +local::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 ); + return *tape_handle(thread); +} + +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/test_vector.hpp cppad-2019.02.00.0/include/cppad/core/test_vector.hpp --- cppad-2018.00.00.0/include/cppad/core/test_vector.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/test_vector.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,135 @@ +# ifndef CPPAD_CORE_TEST_VECTOR_HPP +# define CPPAD_CORE_TEST_VECTOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin test_vector$$ +$spell + autotools + ifdef + undef + Microsofts + CppADvector + hpp + std + endif + ublas + Dir + valarray + stdvector +$$ + + +$section Choosing The Vector Testing Template Class$$ + +$head Deprecated 2012-07-03$$ +The $code CPPAD_TEST_VECTOR$$ macro has been deprecated, +use $cref/CPPAD_TESTVECTOR/testvector/$$ instead. + +$head Syntax$$ +$codei%CPPAD_TEST_VECTOR<%Scalar%> +%$$ + +$head Introduction$$ +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/$$. + +$head MS Windows$$ +The include path for boost is not defined in the Windows project files. +If we are using Microsofts compiler, the following code overrides the setting +of $code CPPAD_BOOSTVECTOR$$: +$srccode%cpp% */ +// The next 7 lines are C++ source code. +# ifdef _MSC_VER +# if CPPAD_BOOSTVECTOR +# undef CPPAD_BOOSTVECTOR +# define CPPAD_BOOSTVECTOR 0 +# undef CPPAD_CPPADVECTOR +# define CPPAD_CPPADVECTOR 1 +# endif +# endif +/* %$$ + +$head CppAD::vector$$ +By default $code CPPAD_CPPADVECTOR$$ is true +and $code CPPAD_TEST_VECTOR$$ is defined by the following source code +$srccode%cpp% */ +// The next 3 line are C++ source code. +# if CPPAD_CPPADVECTOR +# define CPPAD_TEST_VECTOR CppAD::vector +# endif +/* %$$ +If you specify $code --with-eigenvector$$ on the +$cref/configure/autotools/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) +so $code CppAD::vector$$ is used in this case +$srccode%cpp% */ +// The next 3 line are C++ source code. +# if CPPAD_EIGENVECTOR +# define CPPAD_TEST_VECTOR CppAD::vector +# endif +/* %$$ + + +$head std::vector$$ +If you specify $code --with-stdvector$$ on the +$cref/configure/autotools/Configure/$$ +command line during CppAD installation, +$code CPPAD_STDVECTOR$$ is true +and $code CPPAD_TEST_VECTOR$$ is defined by the following source code +$srccode%cpp% */ +// The next 4 lines are C++ source code. +# if CPPAD_STDVECTOR +# include +# define CPPAD_TEST_VECTOR std::vector +# endif +/* %$$ +In this case CppAD will use $code std::vector$$ for its examples and tests. +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. + +$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 +and $code CPPAD_TEST_VECTOR$$ is defined by the following source code +$srccode%cpp% */ +// The next 4 lines are C++ source code. +# if CPPAD_BOOSTVECTOR +# include +# define CPPAD_TEST_VECTOR boost::numeric::ublas::vector +# endif +/* %$$ +In this case CppAD will use Ublas vectors for its examples and tests. +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. + +$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: +$srccode%cpp% */ +# define CppADvector CPPAD_TEST_VECTOR +/* %$$ +$end +------------------------------------------------------------------------ +*/ + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/testvector.hpp cppad-2019.02.00.0/include/cppad/core/testvector.hpp --- cppad-2018.00.00.0/include/cppad/core/testvector.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/testvector.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,116 @@ +# ifndef CPPAD_CORE_TESTVECTOR_HPP +# define CPPAD_CORE_TESTVECTOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin testvector$$ +$spell + CppAD + cmake + testvector + cppad + Eigen + ifdef + hpp + std + endif + ublas +$$ + + +$section Using The CppAD Test Vector Template Class$$ + +$head Syntax$$ +$codei%CPPAD_TESTVECTOR(%Scalar%) +%$$ + +$head Choice$$ +The user can choose, during the install procedure, +which template class to use in the examples and tests; see below. +This shows that any +$cref/simple vector/SimpleVector/$$ class can be used in place of +$codei% + CPPAD_TESTVECTOR(%Type%) +%$$ +When writing their own code, +users can choose a specific simple vector they prefer; for example, +$codei% + CppAD::vector<%Type%> +%$$ + + +$head CppAD::vector$$ +If in the $cref/cmake command/cmake/CMake Command/$$ +you specify $cref cppad_testvector$$ to be $code cppad$$, +$code CPPAD_CPPADVECTOR$$ will be true. +In this case, +$code CPPAD_TESTVECTOR$$ is defined by the following source code: +$srccode%cpp% */ +# if CPPAD_CPPADVECTOR +# define CPPAD_TESTVECTOR(Scalar) CppAD::vector< Scalar > +# endif +/* %$$ +In this case CppAD will use its own vector for +many of its examples and tests. + +$head std::vector$$ +If in the cmake command +you specify $icode cppad_testvector$$ to be $code std$$, +$code CPPAD_STDVECTOR$$ will be true. +In this case, +$code CPPAD_TESTVECTOR$$ is defined by the following source code: +$srccode%cpp% */ +# if CPPAD_STDVECTOR +# include +# define CPPAD_TESTVECTOR(Scalar) std::vector< Scalar > +# endif +/* %$$ +In this case CppAD will use standard vector for +many of its examples and tests. + +$head boost::numeric::ublas::vector$$ +If in the cmake command +you specify $icode cppad_testvector$$ to be $code boost$$, +$code CPPAD_BOOSTVECTOR$$ will be true. +In this case, +$code CPPAD_TESTVECTOR$$ is defined by the following source code: +$srccode%cpp% */ +# if CPPAD_BOOSTVECTOR +# include +# define CPPAD_TESTVECTOR(Scalar) boost::numeric::ublas::vector< Scalar > +# endif +/* %$$ +In this case CppAD will use this boost vector for +many of its examples and tests. + +$head CppAD::eigen_vector$$ +If in the cmake command +you specify $icode cppad_testvector$$ to be $code eigen$$, +$code CPPAD_EIGENVECTOR$$ will be true. +In this case, +$code CPPAD_TESTVECTOR$$ is defined by the following source code: +$srccode%cpp% */ +# if CPPAD_EIGENVECTOR +# include +# define CPPAD_TESTVECTOR(Scalar) CppAD::eigen_vector< Scalar > +# endif +/* %$$ +see $cref/eigen_vector/cppad_eigen.hpp/eigen_vector/$$. +In this case CppAD will use the Eigen vector +for many of its examples and tests. + +$end +------------------------------------------------------------------------ +*/ + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/unary_minus.hpp cppad-2019.02.00.0/include/cppad/core/unary_minus.hpp --- cppad-2018.00.00.0/include/cppad/core/unary_minus.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/unary_minus.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,100 @@ +# ifndef CPPAD_CORE_UNARY_MINUS_HPP +# define CPPAD_CORE_UNARY_MINUS_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin UnaryMinus$$ +$spell + Vec + const + inline +$$ + + +$section AD Unary Minus Operator$$ + +$head Syntax$$ + +$icode%y% = - %x%$$ + + +$head Purpose$$ +Computes the negative of $icode x$$. + +$head Base$$ +The operation in the syntax above must be supported for the case where +the operand is a $code const$$ $icode Base$$ object. + +$head x$$ +The operand $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 type +$codei% + AD<%Base%> %y% +%$$ +It is equal to the negative of the operand $icode x$$. + +$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 Derivative$$ +If $latex f$$ is a +$cref/Base function/glossary/Base Function/$$, +$latex \[ + \D{[ - f(x) ]}{x} = - \D{f(x)}{x} +\] $$ + +$head Example$$ +$children% + example/general/unary_minus.cpp +%$$ +The file +$cref unary_minus.cpp$$ +contains an example and test of this operation. + +$end +------------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +// Broken g++ compiler inhibits declaring unary minus a member or friend +template +AD AD::operator - (void) const +{ // 2DO: make a more efficient by adding unary minus to op_code.h (some day) + // + AD result(0); + result -= *this; + return result; +} + + +template +AD operator - (const VecAD_reference &right) +{ return - right.ADBase(); } + +} +// END CppAD namespace + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/unary_plus.hpp cppad-2019.02.00.0/include/cppad/core/unary_plus.hpp --- cppad-2018.00.00.0/include/cppad/core/unary_plus.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/unary_plus.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,97 @@ +# ifndef CPPAD_CORE_UNARY_PLUS_HPP +# define CPPAD_CORE_UNARY_PLUS_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin UnaryPlus$$ +$spell + Vec + const + inline +$$ + + +$section AD Unary Plus Operator$$ + +$head Syntax$$ + +$icode%y% = + %x%$$ + + +$head Purpose$$ +Performs the unary plus operation +(the result $icode y$$ is equal to the operand $icode x$$). + + +$head x$$ +The operand $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 type +$codei% + AD<%Base%> %y% +%$$ +It is equal to the operand $icode x$$. + +$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 Derivative$$ +If $latex f$$ is a +$cref/Base function/glossary/Base Function/$$, +$latex \[ + \D{[ + f(x) ]}{x} = \D{f(x)}{x} +\] $$ + + + +$head Example$$ +$children% + example/general/unary_plus.cpp +%$$ +The file +$cref unary_plus.cpp$$ +contains an example and test of this operation. + +$end +------------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +template +AD AD::operator + (void) const +{ AD result(*this); + + return result; +} + + +template +AD operator + (const VecAD_reference &right) +{ return right.ADBase(); } + +} +// END CppAD namespace + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/undef.hpp cppad-2019.02.00.0/include/cppad/core/undef.hpp --- cppad-2018.00.00.0/include/cppad/core/undef.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/undef.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,95 @@ +# ifndef CPPAD_CORE_UNDEF_HPP +# define CPPAD_CORE_UNDEF_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +---------------------------------------------------------------------------- +Preprecessor definitions that presist after cppad/cppad.hpp is included: + +# undef CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL used by CPPAD_USER_ATOMIC +# undef CPPAD_ASSERT_KNOWN used by cppad_ipopt +# undef CPPAD_ASSERT_UNKNOWN used by cppad_ipopt +# undef CPPAD_HASH_TABLE_SIZE used by test_more/optimize.cpp +# undef EIGEN_MATRIXBASE_PLUGIN example use of Eigen with CppAD +# undef CPPAD_HAS_COLPACK used by speed/cppad/sparse_*.cpp + +# undef CPPAD_BOOL_BINARY in user api +# undef CPPAD_BOOL_UNARY in user api +# undef CPPAD_DEBUG_AND_RELEASE in user api +# undef CPPAD_DISCRETE_FUNCTION in user api +# undef CPPAD_EIGENVECTOR 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 +# undef CPPAD_TRACK_EXTEND in deprecated api +# undef CPPAD_TRACK_NEW_VEC in deprecated api +# undef CPPAD_USER_ATOMIC in deprecated api + +# undef CPPAD_TEST_VECTOR deprecated verssion of CPPAD_TESTVECTOR +# undef CppADCreateBinaryBool deprecated version of CPPAD_BOOL_BINARY +# undef CppADCreateDiscrete deprecated version of CPPAD_DISCRETE_FUNCTION +# undef CppADCreateUnaryBool deprecated version of CPPAD_BOOL_UNARY +# undef CppADTrackCount deprecated version of CPPAD_TRACK_COUNT +# undef CppADTrackDelVec deprecated version of CPPAD_TRACK_DEL_VEC +# undef CppADTrackExtend deprecated version of CPPAD_TRACK_EXTEND +# undef CppADTrackNewVec deprecated version of CPPAD_TRACK_NEW_VEC +# undef CppADvector deprecated version of CPPAD_TEST_VECTOR + +// for conditional testing when implicit conversion is not present +# undef CPPAD_DEPRECATED +----------------------------------------------------------------------------- +*/ +// Preprecessor definitions that do not presist +# undef CPPAD_ASSERT_NARG_NRES +# undef CPPAD_AZMUL +# undef CPPAD_BOOSTVECTOR +# undef CPPAD_COMPILER_HAS_CONVERSION_WARN +# undef CPPAD_COND_EXP +# undef CPPAD_COND_EXP_BASE_REL +# undef CPPAD_COND_EXP_REL +# undef CPPAD_CPPADVECTOR +# undef CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR +# undef CPPAD_FOLD_ASSIGNMENT_OPERATOR +# undef CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR +# undef CPPAD_HAS_ADOLC +# undef CPPAD_HAS_EIGEN +# undef CPPAD_HAS_GETTIMEOFDAY +# undef CPPAD_HAS_IPOPT +# 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_STANDARD_MATH_UNARY_AD +# undef CPPAD_STDVECTOR +# undef CPPAD_TRACE_CAPACITY +# undef CPPAD_TRACE_THREAD +# undef CPPAD_TRACK_DEBUG +# undef CPPAD_USER_MACRO +# undef CPPAD_USER_MACRO_ONE +# undef CPPAD_USER_MACRO_TWO +# undef CPPAD_VEC_AD_COMPUTED_ASSIGNMENT +# undef CPPAD_VEC_ENUM_TYPE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/user_ad.hpp cppad-2019.02.00.0/include/cppad/core/user_ad.hpp --- cppad-2018.00.00.0/include/cppad/core/user_ad.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/user_ad.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,71 @@ +# ifndef CPPAD_CORE_USER_AD_HPP +# define CPPAD_CORE_USER_AD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +--------------------------------------------------------------------------- + +$begin AD$$ +$spell + std + bool + cos + Cpp +$$ + +$section AD Objects$$ + + +$head Purpose$$ +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 +function and derivative values. + +$head Base Type Requirements$$ +The $icode Base$$ requirements are provided by the CppAD package +for the following base types: +$code float$$, +$code double$$, +$code std::complex$$, +$code std::complex$$. +Otherwise, see $cref base_require$$. + + +$childtable% + include/cppad/core/ad_ctor.hpp% + include/cppad/core/ad_assign.hpp% + include/cppad/core/convert.hpp% + include/cppad/core/ad_valued.hpp% + include/cppad/core/bool_valued.hpp% + include/cppad/core/vec_ad.hpp% + include/cppad/base_require.hpp +%$$ + +$end +--------------------------------------------------------------------------- +*/ + +# include +# include +# include +# include +# include +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/value.hpp cppad-2019.02.00.0/include/cppad/core/value.hpp --- cppad-2018.00.00.0/include/cppad/core/value.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/value.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,95 @@ +# ifndef CPPAD_CORE_VALUE_HPP +# define CPPAD_CORE_VALUE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin Value$$ +$spell + const +$$ + + + +$section Convert From an AD Type to its Base Type$$ + +$head Syntax$$ +$icode%b% = Value(%x%)%$$ + +$head See Also$$ +$cref var2par$$ + + +$head Purpose$$ +Converts from an AD type to the corresponding +$cref/base type/glossary/Base Type/$$. + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const AD<%Base%> &%x% +%$$ + +$head b$$ +The return value $icode b$$ has prototype +$codei% + %Base% %b% +%$$ + +$head Operation Sequence$$ +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$$ +The argument $icode x$$ must not be a +$cref/variable/glossary/Variable/$$ or +$cref/dynamic/glossary/Parameter/Dynamic/$$ parameter +because its dependency information +would not be included in the $code Value$$ result $icode b$$. + +$head Example$$ +$children% + example/general/value.cpp +%$$ +The file +$cref value.cpp$$ +contains an example and test of this operation. + +$end +------------------------------------------------------------------------------- +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +Base Value(const AD &x) +{ Base result; + // + CPPAD_ASSERT_KNOWN( + ! ( Variable(x) | Dynamic(x) ) , + "Value: argument is a variable or dynamic parameter" + ); + // + result = x.value_; + return result; +} + +} +// END CppAD namespace + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/var2par.hpp cppad-2019.02.00.0/include/cppad/core/var2par.hpp --- cppad-2018.00.00.0/include/cppad/core/var2par.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/var2par.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,88 @@ +# ifndef CPPAD_CORE_VAR2PAR_HPP +# define CPPAD_CORE_VAR2PAR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------ + +$begin Var2Par$$ +$spell + var + const +$$ + + +$section Convert an AD Variable to a Parameter$$ + +$head Syntax$$ +$icode%y% = Var2Par(%x%)%$$ + +$head See Also$$ +$cref value$$ + +$head Purpose$$ +Returns a +$cref/parameter/glossary/Parameter/$$ $icode y$$ +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, parameter, or dynamic parameter. + + +$head y$$ +The result $icode y$$ has prototype +$codei% + AD<%Base%> &y +%$$ +The return value $icode y$$ will be a parameter. + + +$head Example$$ +$children% + example/general/var2par.cpp +%$$ +The file +$cref var2par.cpp$$ +contains an example and test of this operation. + +$end +------------------------------------------------------------------------------ +*/ + +// BEGIN CppAD namespace +namespace CppAD { + +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +AD Var2Par(const AD &x) +{ AD y(x.value_); + return y; +} + + +template +CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +AD Var2Par(const VecAD_reference &x) +{ AD y(x.ADBase()); + y.id_ = 0; +} + + +} // END CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/vec_ad.hpp cppad-2019.02.00.0/include/cppad/core/vec_ad.hpp --- cppad-2018.00.00.0/include/cppad/core/vec_ad.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/vec_ad.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,760 @@ +# ifndef CPPAD_CORE_VEC_AD_HPP +# define CPPAD_CORE_VEC_AD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin VecAD$$ +$spell + cppad.hpp + CondExpGt + grep + Ld + vp + Lu + wc + op + Ldp + Ldv + Taylor + VecAD + const + Cpp +$$ + + +$section AD Vectors that Record Index Operations$$ + + +$head Syntax$$ +$codei%VecAD<%Base%> %v%(%n%)%$$ +$pre +$$ +$icode%v%.size()%$$ +$pre +$$ +$icode%b% = %v%[%i%]%$$ +$pre +$$ +$icode%r% = %v%[%x%]%$$ + +$head Purpose$$ +If either $icode v$$ or $icode x$$ is a +$cref/variable/glossary/Variable/$$, +the indexing operation +$codei% + %r% = %v%[%x%] +%$$ +is recorded in the corresponding +AD of $icode Base$$ +$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/$$. +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 +respect to $icode x$$ as zero. + +$head Alternatives$$ +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, +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$$ +The result $icode r$$ has type +$codei% + VecAD<%Base%>::reference +%$$ +which is very much like the $codei%AD<%Base%>%$$ type +with some notable exceptions: + +$subhead Exceptions$$ +$list number$$ +The object $icode r$$ cannot be used with the +$cref Value$$ function to compute the corresponding $icode Base$$ value. +If $icode v$$ and $icode i$$ are not $cref/variables/glossary/Variable/$$ +$codei% + %b% = v[%i%] +%$$ +can be used to compute the corresponding $icode Base$$ value. + +$lnext +The object $icode r$$ cannot be used +with the $cref/compound assignments operators/Arithmetic/$$ +$code +=$$, +$code -=$$, +$code *=$$, or +$code /=$$. +For example, the following syntax is not valid: +$codei% + %v%[%x%] += %z%; +%$$ +no matter what the types of $icode z$$. + +$lnext +Assignment to $icode r$$ returns a $code void$$. +For example, the following syntax is not valid: +$codei% + %z% = %v%[%x%] = %u%; +%$$ +no matter what the types of $icode z$$, and $icode u$$. + +$lnext +The $cref CondExp$$ functions do not accept +$codei%VecAD<%Base%>::reference%$$ arguments. +For example, the following syntax is not valid: +$codei% + CondExpGt(%v%[%x%], %z%, %u%, %v%) +%$$ +no matter what the types of $icode z$$, $icode u$$, and $icode v$$. + +$lnext +The $cref/Parameter/con_dyn_var/Parameter/$$ +and $cref/Variable/con_dyn_var/Variable/$$ functions cannot be used with +$codei%VecAD<%Base%>::reference%$$ arguments like $icode r$$, +use the entire $codei%VecAD<%Base%>%$$ vector instead; i.e. $icode v$$. + +$lnext +The vectors passed to $cref Independent$$ must have elements +of type $codei%AD<%Base%>%$$; i.e., $cref VecAD$$ vectors +cannot be passed to $code Independent$$. + +$lnext +If one uses this type in a +AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$, +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ calculations +($cref sparsity_pattern$$) +are less efficient because the dependence of different +elements of the vector cannot be separated. + +$lend + +$head Constructor$$ + +$subhead v$$ +The syntax +$codei% + VecAD<%Base%> %v%(%n%) +%$$ +creates an $code VecAD$$ object $icode v$$ with +$icode n$$ elements. +The initial value of the elements of $icode v$$ is unspecified. + +$head n$$ +The argument $icode n$$ has prototype +$codei% + size_t %n% +%$$ + +$head size$$ +The syntax +$codei% + %v%.size() +%$$ +returns the number of elements in the vector $icode v$$; +i.e., the value of $icode n$$ when it was constructed. + +$head size_t Indexing$$ +We refer to the syntax +$codei% + %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 +$cref/parameter/con_dyn_var/Parameter/$$; i.e., +it does not depend on the independent variables. + +$subhead i$$ +The operand $icode i$$ has prototype +$codei% + size_t %i% +%$$ +It must be greater than or equal zero +and less than $icode n$$; i.e., less than +the number of elements in $icode v$$. + +$subhead b$$ +The result $icode b$$ has prototype +$codei% + %Base% %b% +%$$ +and is a reference to the $th i$$ element in the vector $icode v$$. +It can be used to change the element value; +for example, +$codei% + %v%[%i%] = %c% +%$$ +is valid where $icode c$$ is a $icode Base$$ object. +The reference $icode b$$ is no longer valid once the +destructor for $icode v$$ is called; for example, +when $icode v$$ falls out of scope. + +$head AD Indexing$$ +We refer to the syntax +$codei% + %r% = %v%[%x%] +%$$ +as AD indexing of a $code VecAD$$ object. + +$subhead x$$ +The argument $icode x$$ has prototype +$codei% + const AD<%Base%> &%x% +%$$ +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$$. + +$subhead r$$ +The result $icode r$$ has prototype +$codei% + VecAD<%Base%>::reference %r% +%$$ +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 +element with index $latex {\rm floor} (x)$$ in the vector $icode v$$ +($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, +$codei% + %v%[%x%] = %z% +%$$ +is valid where $icode z$$ is an +$codei%VecAD<%Base%>::reference%$$ object. +As a reference, $icode r$$ is no longer valid once the +destructor for $icode v$$ is called; for example, +when $icode v$$ falls out of scope. + +$head Dynamic Parameters$$ +The index $icode x$$, +and the value $icode z$$ assigned to +$icode%v%[%x%]%$$ or $icode%v%[%i%]%$$, +cannot be $cref/dynamic parameters/glossary/Parameter/Dynamic/$$. + +$head Example$$ +$children% + example/general/vec_ad.cpp +%$$ +The file +$cref vec_ad.cpp$$ +contains an example and test using $code VecAD$$ vectors. + + +$head Speed and Memory$$ +The $cref VecAD$$ vector type is inefficient because every +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 +$cref/parameters/glossary/Parameter/$$). +The effect of this can be seen by executing the following steps: + +$list number$$ +In the file $code cppad/local/forward1sweep.h$$, +change the definition of $code CPPAD_FORWARD1SWEEP_TRACE$$ to +$codep + # define CPPAD_FORWARD1SWEEP_TRACE 1 +$$ +$lnext +In the $code Example$$ directory, execute the command +$codep + ./test_one.sh lu_vec_ad_ok.cpp lu_vec_ad.cpp -DNDEBUG > lu_vec_ad_ok.log +$$ +This will write a trace of all the forward tape operations, +for the test case $cref lu_vec_ad_ok.cpp$$, +to the file $code lu_vec_ad_ok.log$$. +$lnext +In the $code Example$$ directory execute the commands +$codep + grep "op=" lu_vec_ad_ok.log | wc -l + grep "op=Ld[vp]" lu_vec_ad_ok.log | wc -l + grep "op=St[vp][vp]" lu_vec_ad_ok.log | wc -l +$$ +The first command counts the number of operators in the tracing, +the second counts the number of VecAD load operations, +and the third counts the number of VecAD store operations. +(For CppAD version 05-11-20 these counts were 956, 348, and 118 +respectively.) +$lend + +$end +------------------------------------------------------------------------ +*/ +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +/*! +\file vec_ad.hpp +Defines the VecAD class. +*/ + +/*! +\def CPPAD_VEC_AD_COMPUTED_ASSIGNMENT(op, name) +Prints an error message if the correspinding compound assignment is used. + +THis macro is used to print an error message if any of the +compound assignments are used with the VecAD_reference class. +The argument op is one of the following: ++= , -= , *= , /=. +The argument name, is a string literal with the name of the +compound assignment op. +*/ +# define CPPAD_VEC_AD_COMPUTED_ASSIGNMENT(op, name) \ +VecAD_reference& operator op (const VecAD_reference &right) \ +{ CPPAD_ASSERT_KNOWN( \ + false, \ + "Cannot use a ADVec element on left side of" name \ + ); \ + return *this; \ +} \ +VecAD_reference& operator op (const AD &right) \ +{ CPPAD_ASSERT_KNOWN( \ + false, \ + "Cannot use a ADVec element on left side of" name \ + ); \ + return *this; \ +} \ +VecAD_reference& operator op (const Base &right) \ +{ CPPAD_ASSERT_KNOWN( \ + false, \ + "Cannot use a ADVec element on left side of" name \ + ); \ + return *this; \ +} + +/*! +Class used to hold a reference to an element of a VecAD object. + +\tparam Base +Elements of this class act like an AD (in a restricted sense), +in addition they track (on the tape) the index they correspond to. +*/ +template +class VecAD_reference { + friend bool Parameter (const VecAD &vec); + friend bool Variable (const VecAD &vec); + friend class VecAD; + friend class local::ADTape; + +private: + /// pointer to vecad vector that this is a element of + VecAD *vec_; + /// index in vecad vector that this element corresponds to + AD ind_; // index for this element +public: + /*! + consructor + + \param vec + value of vec_ + + \param ind + value of ind_ + */ + VecAD_reference(VecAD *vec, const AD& ind) + : vec_( vec ) , ind_(ind) + { CPPAD_ASSERT_KNOWN( ! Dynamic(ind), + "index for element of this VecAD object is a dynamic paramerer" + ); + } + + // assignment operators + void operator = (const VecAD_reference &right); + void operator = (const AD &right); + void operator = (const Base &right); + void operator = (int right); + + // compound assignments + CPPAD_VEC_AD_COMPUTED_ASSIGNMENT( += , " += " ) + CPPAD_VEC_AD_COMPUTED_ASSIGNMENT( -= , " -= " ) + CPPAD_VEC_AD_COMPUTED_ASSIGNMENT( *= , " *= " ) + CPPAD_VEC_AD_COMPUTED_ASSIGNMENT( /= , " /= " ) + + + /// Conversion from VecAD_reference to AD. + /// puts the correspond vecad load instruction in the tape. + AD ADBase(void) const + { // start with default construtor (hence dynamic_ is false). + AD result; + + size_t i = static_cast( Integer(ind_) ); + CPPAD_ASSERT_UNKNOWN( i < vec_->length_ ); + + // AD value corresponding to this element + result.value_ = vec_->data_[i]; + + // this address will be recorded in tape and must be + // zero for parameters + CPPAD_ASSERT_UNKNOWN( Parameter(result) ); + result.taddr_ = 0; + + // index corresponding to this element + if( Variable(*vec_) ) + { + local::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( IdenticalCon(ind_) ) + { CPPAD_ASSERT_UNKNOWN( local::NumRes(local::LdpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::LdpOp) == 3 ); + + // put operand addresses in tape + tape->Rec_.PutArg( + (addr_t) vec_->offset_, (addr_t) i, (addr_t) load_op_index + ); + // put operator in the tape, ind_ is a parameter + result.taddr_ = tape->Rec_.PutLoadOp(local::LdpOp); + + // change result to variable for this load + result.tape_id_ = tape->id_; + result.ad_type_ = variable_enum; + } + else + { CPPAD_ASSERT_UNKNOWN( local::NumRes(local::LdvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( local::NumArg(local::LdvOp) == 3 ); + addr_t ind_taddr; + if( Parameter(ind_) ) + { // kludge that should not be needed + // if ind_ instead of i is used for index + // in the tape + ind_taddr = tape->RecordParOp( + ind_.value_ + ); + } + else + ind_taddr = ind_.taddr_; + CPPAD_ASSERT_UNKNOWN( ind_taddr > 0 ); + + // put operand addresses in tape + tape->Rec_.PutArg( + (addr_t) vec_->offset_, + (addr_t) ind_taddr, + (addr_t) load_op_index + ); + // put operator in the tape, ind_ is a variable + result.taddr_ = tape->Rec_.PutLoadOp(local::LdvOp); + + // change result to variable for this load + result.tape_id_ = tape->id_; + result.ad_type_ = variable_enum; + } + } + return result; + } +}; + +/*! +Vector of AD objects that tracks indexing operations on the tape. +*/ +template +class VecAD { + friend bool Parameter (const VecAD &vec); + friend bool Variable (const VecAD &vec); + friend class local::ADTape; + friend class VecAD_reference; + + friend std::ostream& operator << + (std::ostream &os, const VecAD &vec_); +private: + /// size of this VecAD vector + const size_t length_; + + /// elements of this vector + local::pod_vector_maybe data_; + + /// offset in cummulate vector corresponding to this object + size_t offset_; + + /// tape id corresponding to the offset + tape_id_t tape_id_; +public: + /// declare the user's view of this type here + typedef VecAD_reference reference; + + /// default constructor + /// initialize tape_id_ same as for default constructor; see default.hpp + VecAD(void) + : length_(0) + , offset_(0) + , tape_id_(0) + { CPPAD_ASSERT_UNKNOWN( Parameter(*this) ); } + + /// sizing constructor + /// initialize tape_id_ same as for parameters; see ad_copy.hpp + VecAD(size_t n) + : length_(n) + , offset_(0) + , tape_id_(0) + { if( length_ > 0 ) + { size_t i; + Base zero(0); + data_.extend(length_); + + // Initialize data to zero so all have same value. + // This uses less memory and avoids a valgrind error + // during TapeRec::PutPar + for(i = 0; i < length_; i++) + data_[i] = zero; + } + CPPAD_ASSERT_UNKNOWN( Parameter(*this) ); + } + + /// destructor + ~VecAD(void) + { } + + /// number of elements in the vector + size_t size(void) + { return length_; } + + /// element access (not taped) + /// + /// \param i + /// element index + Base &operator[](size_t i) + { + CPPAD_ASSERT_KNOWN( + Parameter(*this), + "VecAD: cannot use size_t indexing because this" + " VecAD vector is a variable." + ); + CPPAD_ASSERT_KNOWN( + i < length_, + "VecAD: element index is >= vector length" + ); + + return data_[i]; + } + + /*! 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) + { + CPPAD_ASSERT_KNOWN( + 0 <= Integer(x), + "VecAD: element index is less than zero" + ); + CPPAD_ASSERT_KNOWN( + static_cast( Integer(x) ) < length_, + "VecAD: element index is >= vector length" + ); + + // if no need to track indexing operation, return now + if( Parameter(*this) & Parameter(x) ) + return VecAD_reference(this, x); + + CPPAD_ASSERT_KNOWN( + Parameter(*this) | Parameter(x) | (tape_id_ == x.tape_id_), + "VecAD: vector and index are variables for" + " different tapes." + ); + + if( Parameter(*this) ) + { // must place a copy of vector in tape + 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 length at begining (so is always > 0) + offset_++; + + // tape id corresponding to this offest + tape_id_ = x.tape_id_; + } + + return VecAD_reference(this, x); + } + +}; + + +/*! +Taped setting of element to a value. + +\param y +value that element is set to. +*/ +template +void VecAD_reference::operator=(const AD &y) +{ + CPPAD_ASSERT_KNOWN( ! Dynamic(y), + "value assigned to element of VecAD object is a dynamic paramerer" + ); + + if( Parameter(y) ) + { // fold into the Base type assignment + *this = y.value_; + return; + } + CPPAD_ASSERT_UNKNOWN( y.taddr_ > 0 ); + + CPPAD_ASSERT_KNOWN( + Parameter(*vec_) | (vec_->tape_id_ == y.tape_id_), + "VecAD assignment: vector and new element value are variables" + "\nfor different tapes." + ); + + local::ADTape* tape = AD::tape_ptr(y.tape_id_); + CPPAD_ASSERT_UNKNOWN( tape != CPPAD_NULL ); + if( Parameter(*vec_) ) + { // must place a copy of vector in tape + vec_->offset_ = tape->AddVec(vec_->length_, vec_->data_); + + // advance offset to be start of vector plus one + (vec_->offset_)++; + + // tape id corresponding to this offest + vec_->tape_id_ = y.tape_id_; + } + CPPAD_ASSERT_UNKNOWN( Variable(*vec_) ); + + + // index in vector for this element + size_t i = static_cast( Integer(ind_) ); + CPPAD_ASSERT_UNKNOWN( i < vec_->length_ ); + + // assign value for this element (as an AD object) + vec_->data_[i] = y.value_; + + // record the setting of this array element + CPPAD_ASSERT_UNKNOWN( vec_->offset_ > 0 ); + if( Parameter(ind_) ) + { CPPAD_ASSERT_UNKNOWN( local::NumArg(local::StpvOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::StpvOp) == 0 ); + + // put operand addresses in tape + tape->Rec_.PutArg((addr_t) vec_->offset_, (addr_t) i, y.taddr_); + + // put operator in the tape, ind_ is parameter, y is variable + tape->Rec_.PutOp(local::StpvOp); + } + else + { CPPAD_ASSERT_UNKNOWN( local::NumArg(local::StvvOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::StvvOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( ind_.taddr_ > 0 ); + + // put operand addresses in tape + tape->Rec_.PutArg((addr_t) vec_->offset_, ind_.taddr_, y.taddr_); + + // put operator in the tape, ind_ is variable, y is variable + tape->Rec_.PutOp(local::StvvOp); + } +} + + +/*! +Taped setting of element to a value. + +\param y +value that element is set to. +*/ +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 + vec_->data_[i] = y; + + // check if this ADVec object is a parameter + if( Parameter(*vec_) ) + return; + + local::ADTape* tape = AD::tape_ptr(vec_->tape_id_); + CPPAD_ASSERT_UNKNOWN( tape != CPPAD_NULL ); + + // put value of the parameter y in the tape + addr_t p = tape->Rec_.put_con_par(y); + + // record the setting of this array element + CPPAD_ASSERT_UNKNOWN( vec_->offset_ > 0 ); + if( Parameter(ind_) ) + { CPPAD_ASSERT_UNKNOWN( local::NumArg(local::StppOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::StppOp) == 0 ); + + // put operand addresses in tape + tape->Rec_.PutArg((addr_t) vec_->offset_, (addr_t) i, p); + + // put operator in the tape, ind_ is parameter, y is parameter + tape->Rec_.PutOp(local::StppOp); + } + else + { CPPAD_ASSERT_UNKNOWN( local::NumArg(local::StvpOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( local::NumRes(local::StvpOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( ind_.taddr_ > 0 ); + + // put operand addresses in tape + tape->Rec_.PutArg((addr_t) vec_->offset_, ind_.taddr_, p); + + // put operator in the tape, ind_ is variable, y is parameter + tape->Rec_.PutOp(local::StvpOp); + } +} + +/*! +Taped setting of element to a value. + +\param y +value that element is set to. + +\par +this case gets folded into case where value is AD. +*/ +template +void VecAD_reference::operator= +(const VecAD_reference &y) +{ *this = y.ADBase(); } + +/*! +Taped setting of element to a value. + +\param y +value that element is set to. + +\par +this case gets folded into case where value is Base. +*/ +template +void VecAD_reference::operator=(int y) +{ *this = Base(y); } + + +} // END_CPPAD_NAMESPACE + +// preprocessor symbols that are local to this file +# undef CPPAD_VEC_AD_COMPUTED_ASSIGNMENT + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/core/zdouble.hpp cppad-2019.02.00.0/include/cppad/core/zdouble.hpp --- cppad-2018.00.00.0/include/cppad/core/zdouble.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/core/zdouble.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,529 @@ +# ifndef CPPAD_CORE_ZDOUBLE_HPP +# define CPPAD_CORE_ZDOUBLE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$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/$$. + +$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 compound 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 compound 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) + fabs(z1) + pow(z1, z2) + fabs_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 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 compound assignment + CPPAD_ZDOUBLE_NORMAL_ASSIGN_OPERATOR(+=) + /// Normal compound 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 IdenticalCon(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 IdenticalEqualCon(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 fabs(x); } + +/// 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 +CPPAD_NUMERIC_LIMITS(double, zdouble) + +} // 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-2018.00.00.0/include/cppad/cppad.hpp cppad-2019.02.00.0/include/cppad/cppad.hpp --- cppad-2018.00.00.0/include/cppad/cppad.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/cppad.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,74 @@ +# ifndef CPPAD_CPPAD_HPP +# define CPPAD_CPPAD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file cppad.hpp +\brief includes the entire CppAD package in the necessary order. + +\namespace CppAD +\brief contains all the variables and functions defined by the CppAD package. +*/ + +# include // all base type requirements +// --------------------------------------------------------------------------- +// CppAD general purpose library routines (can be included separately) +# include +// -------------------------------------------------------------------------- +// System routines that can be used by rest of CppAD with out including + +# include +# include +# include +# include + +// --------------------------------------------------------------------------- +// definitions needed by rest of includes + +// definitions that come from the installation +# include + +// definitions that are local to the CppAD include files +# include + +// vectors used with CppAD +# include + +// deprecated vectors used with CppAD +# include + +// Declare classes and fucntions that are used before defined +# include + +// --------------------------------------------------------------------------- +// declare the AD template class + +# include + +// --------------------------------------------------------------------------- + +# include // AD class methods available to the user +// tape that tape for AD acts as a user of Base operations +// so user_ad.hpp must come before op.hpp +# include // executes taped operations +# include // ADFun objects + +// --------------------------------------------------------------------------- +// library routines that require the rest of CppAD +# include +# include +# include + +// undo definitions in Define.h +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/example/base_adolc.hpp cppad-2019.02.00.0/include/cppad/example/base_adolc.hpp --- cppad-2018.00.00.0/include/cppad/example/base_adolc.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/example/base_adolc.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,363 @@ +# ifndef CPPAD_EXAMPLE_BASE_ADOLC_HPP +# define CPPAD_EXAMPLE_BASE_ADOLC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin base_adolc.hpp$$ +$spell + stringstream + struct + string + setprecision + str + valgrind + azmul + expm1 + atanh + acosh + asinh + erf + ifndef + define + endif + Rel + codassign + eps + std + abs_geq + fabs + cppad.hpp + undef + Lt + Le + Eq + Ge + Gt + namespace + cassert + condassign + hpp + bool + const + Adolc + adouble + CondExpOp + inline + enum + CppAD + pow + acos + asin + atan + cos + cosh + exp + sqrt +$$ + + +$section Enable use of AD where Base is Adolc's adouble Type$$ + +$head Syntax$$ +$codei%# include +%$$ +$children% + example/general/mul_level_adolc.cpp +%$$ + +$head Example$$ +The file $cref mul_level_adolc.cpp$$ contains an example use of +Adolc's $code adouble$$ type for a CppAD $icode Base$$ type. +The file $cref mul_level_adolc_ode.cpp$$ contains a more realistic +(and complex) example. + +$head Include Files$$ +This file $code base_adolc.hpp$$ requires $code adouble$$ to be defined. +In addition, it is included before $code $$, +but it needs to include parts of CppAD that are used by this file. +This is done with the following include commands: +$srccode%cpp% */ +# include +# include +/* %$$ + +$head CondExpOp$$ +The type $code adouble$$ supports a conditional assignment function +with the syntax +$codei% + condassign(%a%, %b%, %c%, %d%) +%$$ +which evaluates to +$codei% + %a% = (%b% > 0) ? %c% : %d%; +%$$ +This enables one to include conditionals in the recording of +$code adouble$$ operations and later evaluation for different +values of the independent variables +(in the same spirit as the CppAD $cref CondExp$$ function). +$srccode%cpp% */ +namespace CppAD { + inline adouble CondExpOp( + enum CppAD::CompareOp cop , + const adouble &left , + const adouble &right , + const adouble &trueCase , + const adouble &falseCase ) + { adouble result; + switch( cop ) + { + case CompareLt: // left < right + condassign(result, right - left, trueCase, falseCase); + break; + + case CompareLe: // left <= right + condassign(result, left - right, falseCase, trueCase); + break; + + case CompareEq: // left == right + condassign(result, left - right, falseCase, trueCase); + condassign(result, right - left, falseCase, result); + break; + + case CompareGe: // left >= right + condassign(result, right - left, falseCase, trueCase); + break; + + case CompareGt: // left > right + condassign(result, left - right, trueCase, falseCase); + break; + default: + CppAD::ErrorHandler::Call( + true , __LINE__ , __FILE__ , + "CppAD::CondExp", + "Error: for unknown reason." + ); + result = trueCase; + } + return result; + } +} +/* %$$ + +$head CondExpRel$$ +The $cref/CPPAD_COND_EXP_REL/base_cond_exp/CondExpRel/$$ macro invocation +$srccode%cpp% */ +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. +Make $code EqualOpSeq$$ an error if it gets used: +$srccode%cpp% */ +namespace CppAD { + inline bool EqualOpSeq(const adouble &x, const adouble &y) + { CppAD::ErrorHandler::Call( + true , __LINE__ , __FILE__ , + "CppAD::EqualOpSeq(x, y)", + "Error: adouble does not support EqualOpSeq." + ); + return false; + } +} +/* %$$ + +$head Identical$$ +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. +$srccode%cpp% */ +namespace CppAD { + inline bool IdenticalCon(const adouble &x) + { return false; } + inline bool IdenticalZero(const adouble &x) + { return false; } + inline bool IdenticalOne(const adouble &x) + { return false; } + inline bool IdenticalEqualCon(const adouble &x, const adouble &y) + { return false; } +} +/* %$$ + +$head Integer$$ +$srccode%cpp% */ + inline int Integer(const adouble &x) + { return static_cast( x.getValue() ); } +/* %$$ + +$head azmul$$ +$srccode%cpp% */ +namespace CppAD { + CPPAD_AZMUL( adouble ) +} +/* %$$ + +$head Ordered$$ +$srccode%cpp% */ +namespace CppAD { + inline bool GreaterThanZero(const adouble &x) + { return (x > 0); } + inline bool GreaterThanOrZero(const adouble &x) + { return (x >= 0); } + inline bool LessThanZero(const adouble &x) + { return (x < 0); } + inline bool LessThanOrZero(const adouble &x) + { return (x <= 0); } + inline bool abs_geq(const adouble& x, const adouble& y) + { return fabs(x) >= fabs(y); } +} +/* %$$ + +$head Unary Standard Math$$ +The following $cref/required/base_require/$$ functions +are defined by the Adolc package for the $code adouble$$ base case: +$pre +$$ +$code acos$$, +$code asin$$, +$code atan$$, +$code cos$$, +$code cosh$$, +$code exp$$, +$code fabs$$, +$code log$$, +$code sin$$, +$code sinh$$, +$code sqrt$$, +$code tan$$. + +$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: +$srccode%cpp% */ +namespace CppAD { +# 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 +$code codassign$$ function so that its $code adouble$$ operation sequence +does not depend on the value of $icode x$$. +$srccode%cpp% */ +namespace CppAD { + inline adouble sign(const adouble& x) + { adouble s_plus, s_minus, half(.5); + // set s_plus to sign(x)/2, except for case x == 0, s_plus = -.5 + condassign(s_plus, +x, -half, +half); + // set s_minus to -sign(x)/2, except for case x == 0, s_minus = -.5 + condassign(s_minus, -x, -half, +half); + // set s to sign(x) + return s_plus - s_minus; + } +} +/* %$$ + +$head abs$$ +This $cref/required/base_require/$$ function uses the adolc $code fabs$$ +function: +$srccode%cpp% */ +namespace CppAD { + inline adouble abs(const adouble& x) + { return fabs(x); } +} +/* %$$ + +$head pow$$ +This $cref/required/base_require/$$ function +is defined by the Adolc package for the $code adouble$$ base case. + +$head numeric_limits$$ +The following defines the CppAD $cref numeric_limits$$ +for the type $code adouble$$: +$srccode%cpp% */ +namespace CppAD { + CPPAD_NUMERIC_LIMITS(double, adouble) +} +/* %$$ + +$head to_string$$ +The following defines the CppAD $cref to_string$$ function +for the type $code adouble$$: +$srccode%cpp% */ +namespace CppAD { + template <> struct to_string_struct + { std::string operator()(const adouble& x) + { std::stringstream os; + int n_digits = 1 + std::numeric_limits::digits10; + os << std::setprecision(n_digits); + os << x.value(); + return os.str(); + } + }; +} +/* %$$ + +$head hash_code$$ +It appears that an $code adouble$$ object can have fields +that are not initialized. +This results in a $code valgrind$$ error when these fields are used by the +$cref/default/base_hash/Default/$$ hashing function. +For this reason, the $code adouble$$ class overrides the default definition. +$srccode|cpp| */ +namespace CppAD { + inline unsigned short hash_code(const adouble& x) + { unsigned short code = 0; + double value = x.value(); + if( value == 0.0 ) + return code; + double log_x = std::log( fabs( value ) ); + // assume log( std::numeric_limits::max() ) is near 700 + code = static_cast( + (CPPAD_HASH_TABLE_SIZE / 700 + 1) * log_x + ); + code = code % CPPAD_HASH_TABLE_SIZE; + return code; + } +} +/* |$$ +Note that after the hash codes match, the +$cref/Identical/base_adolc.hpp/Identical/$$ function will be used +to make sure two values are the same and one can replace the other. +A more sophisticated implementation of the $code Identical$$ function +would detect which $code adouble$$ values depend on the +$code adouble$$ independent variables (and hence can change). + + +$end +*/ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/example/cppad_eigen.hpp cppad-2019.02.00.0/include/cppad/example/cppad_eigen.hpp --- cppad-2018.00.00.0/include/cppad/example/cppad_eigen.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/example/cppad_eigen.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,195 @@ +# ifndef CPPAD_EXAMPLE_CPPAD_EIGEN_HPP +# define CPPAD_EXAMPLE_CPPAD_EIGEN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +// cppad.hpp gets included at the end +# define EIGEN_MATRIXBASE_PLUGIN +# include + +/* +$begin cppad_eigen.hpp$$ +$spell + impl + typename + Real Real + inline + neg + eps + atan + Num + acos + asin + CppAD + std::numeric + enum + Mul + Eigen + cppad.hpp + namespace + struct + typedef + const + imag + sqrt + exp + cos +$$ +$section Enable Use of Eigen Linear Algebra Package with CppAD$$ + +$head Syntax$$ +$codei%# include +%$$ +$children% + include/cppad/example/eigen_plugin.hpp% + example/general/eigen_array.cpp% + example/general/eigen_det.cpp +%$$ + +$head Purpose$$ +Enables the use of the $cref/eigen/eigen_prefix/$$ +linear algebra package with the type $icode%AD<%Base%>%$$; see +$href% + https://eigen.tuxfamily.org/dox/TopicCustomizing_CustomScalar.html% + custom scalar types +%$$. + +$head Example$$ +The files $cref eigen_array.cpp$$ and $cref eigen_det.cpp$$ +contain an example and test of this include file. +They return true if they succeed and false otherwise. + +$head Include Files$$ +The file $code $$ is included before +these definitions and $code $$ is included after. + +$head CppAD Declarations$$ +First declare some items that are defined by cppad.hpp: +$srccode%cpp% */ +namespace CppAD { + // AD + template class AD; + // numeric_limits + template class numeric_limits; +} +/* %$$ +$head Eigen NumTraits$$ +Eigen needs the following definitions to work properly +with $codei%AD<%Base%>%$$ scalars: +$srccode%cpp% */ +namespace Eigen { + template struct NumTraits< CppAD::AD > + { // type that corresponds to the real part of an AD value + typedef CppAD::AD Real; + // type for AD operations that result in non-integer values + typedef CppAD::AD NonInteger; + // type to use for numeric literals such as "2" or "0.5". + typedef CppAD::AD Literal; + // type for nested value inside an AD expression tree + typedef CppAD::AD Nested; + + enum { + // does not support complex Base types + IsComplex = 0 , + // does not support integer Base types + IsInteger = 0 , + // only support signed Base types + IsSigned = 1 , + // must initialize an AD object + RequireInitialization = 1 , + // computational cost of the corresponding operations + ReadCost = 1 , + AddCost = 2 , + MulCost = 2 + }; + + // machine epsilon with type of real part of x + // (use assumption that Base is not complex) + static CppAD::AD epsilon(void) + { return CppAD::numeric_limits< CppAD::AD >::epsilon(); } + + // 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(); + } + + // minimum normalized positive value + static CppAD::AD lowest(void) + { return CppAD::numeric_limits< CppAD::AD >::min(); } + + // maximum finite value + static CppAD::AD highest(void) + { return CppAD::numeric_limits< CppAD::AD >::max(); } + + // number of decimal digits that can be represented without change. + static int digits10(void) + { return CppAD::numeric_limits< CppAD::AD >::digits10; } + }; +} +/* %$$ +$head CppAD Namespace$$ +Eigen also needs the following definitions to work properly +with $codei%AD<%Base%>%$$ scalars: +$srccode%cpp% */ +namespace CppAD { + // functions that return references + template const AD& conj(const AD& x) + { return x; } + template const AD& real(const AD& x) + { return x; } + + // functions that return values (note abs is defined by cppad.hpp) + template AD imag(const AD& x) + { return CppAD::AD(0.); } + template AD abs2(const AD& x) + { return x * x; } +} + +/* %$$ +$head eigen_vector$$ +The class $code CppAD::eigen_vector$$ is a wrapper for Eigen column vectors +so that they are $cref/simple vectors/SimpleVector/$$. +To be specific, it converts $code Eigen::Index$$ arguments and +return values to $code size_t$$. +$srccode%cpp% */ +namespace CppAD { + template + class eigen_vector : public Eigen::Matrix { + private: + // base_class + typedef Eigen::Matrix base_class; + public: + // constructor + eigen_vector(size_t n) : base_class( Eigen::Index(n) ) + { } + eigen_vector(void) : base_class() + { } + // operator[] + Scalar& operator[](size_t i) + { return base_class::operator[]( Eigen::Index(i) ); } + const Scalar& operator[](size_t i) const + { return base_class::operator[]( Eigen::Index(i) ); } + // size + size_t size(void) const + { return size_t( base_class::size() ); } + // resize + void resize(size_t n) + { base_class::resize( Eigen::Index(n) ); } + }; +} +// +# include +/* %$$ +$end +*/ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/example/eigen_cholesky.hpp cppad-2019.02.00.0/include/cppad/example/eigen_cholesky.hpp --- cppad-2018.00.00.0/include/cppad/example/eigen_cholesky.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/example/eigen_cholesky.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,376 @@ +# ifndef CPPAD_EXAMPLE_EIGEN_CHOLESKY_HPP +# define CPPAD_EXAMPLE_EIGEN_CHOLESKY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_eigen_cholesky.hpp$$ +$spell + Eigen + Taylor + Cholesky + op +$$ + +$section Atomic Eigen Cholesky Factorization Class$$ + +$head Purpose$$ +Construct an atomic operation that computes a lower triangular matrix +$latex L $$ such that $latex L L^\R{T} = A$$ +for any positive integer $latex p$$ +and symmetric positive definite matrix $latex A \in \B{R}^{p \times p}$$. + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +# include + + +/* %$$ +$head Public$$ + +$subhead Types$$ +$srccode%cpp% */ +namespace { // BEGIN_EMPTY_NAMESPACE + +template +class atomic_eigen_cholesky : public CppAD::atomic_base { +public: + // ----------------------------------------------------------- + // type of elements during calculation of derivatives + typedef Base scalar; + // type of elements during taping + typedef CppAD::AD ad_scalar; + // + // type of matrix during calculation of derivatives + typedef Eigen::Matrix< + scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> matrix; + // type of matrix during taping + typedef Eigen::Matrix< + ad_scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ad_matrix; + // + // lower triangular scalar matrix + typedef Eigen::TriangularView lower_view; +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // constructor + atomic_eigen_cholesky(void) : CppAD::atomic_base( + "atom_eigen_cholesky" , + CppAD::atomic_base::set_sparsity_enum + ) + { } +/* %$$ +$subhead op$$ +$srccode%cpp% */ + // use atomic operation to invert an AD matrix + ad_matrix op(const ad_matrix& arg) + { size_t nr = size_t( arg.rows() ); + size_t ny = ( (nr + 1 ) * nr ) / 2; + size_t nx = 1 + ny; + assert( nr == size_t( arg.cols() ) ); + // ------------------------------------------------------------------- + // packed version of arg + CPPAD_TESTVECTOR(ad_scalar) packed_arg(nx); + size_t index = 0; + packed_arg[index++] = ad_scalar( nr ); + // lower triangle of symmetric matrix A + for(size_t i = 0; i < nr; i++) + { for(size_t j = 0; j <= i; j++) + packed_arg[index++] = arg( long(i), long(j) ); + } + assert( index == nx ); + // ------------------------------------------------------------------- + // packed version of result = arg^{-1}. + // This is an atomic_base function call that CppAD uses to + // store the atomic operation on the tape. + CPPAD_TESTVECTOR(ad_scalar) packed_result(ny); + (*this)(packed_arg, packed_result); + // ------------------------------------------------------------------- + // unpack result matrix L + ad_matrix result = ad_matrix::Zero( long(nr), long(nr) ); + index = 0; + for(size_t i = 0; i < nr; i++) + { for(size_t j = 0; j <= i; j++) + result( long(i), long(j) ) = packed_result[index++]; + } + return result; + } + /* %$$ +$head Private$$ + +$subhead Variables$$ +$srccode%cpp% */ +private: + // ------------------------------------------------------------- + // one forward mode vector of matrices for argument and result + CppAD::vector f_arg_, f_result_; + // one reverse mode vector of matrices for argument and result + CppAD::vector r_arg_, r_result_; + // ------------------------------------------------------------- +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + // lowest order Taylor coefficient we are evaluating + size_t p , + // highest order Taylor coefficient we are evaluating + size_t q , + // which components of x are variables + const CppAD::vector& vx , + // which components of y are variables + CppAD::vector& vy , + // tx [ j * (q+1) + k ] is x_j^k + const CppAD::vector& tx , + // ty [ i * (q+1) + k ] is y_i^k + CppAD::vector& ty + ) + { size_t n_order = q + 1; + size_t nr = size_t( CppAD::Integer( tx[ 0 * n_order + 0 ] ) ); + size_t ny = ((nr + 1) * nr) / 2; +# ifndef NDEBUG + size_t nx = 1 + ny; +# endif + assert( vx.size() == 0 || nx == vx.size() ); + assert( vx.size() == 0 || ny == vy.size() ); + assert( nx * n_order == tx.size() ); + assert( ny * n_order == ty.size() ); + // + // ------------------------------------------------------------------- + // make sure f_arg_ and f_result_ are large enough + assert( f_arg_.size() == f_result_.size() ); + if( f_arg_.size() < n_order ) + { f_arg_.resize(n_order); + f_result_.resize(n_order); + // + for(size_t k = 0; k < n_order; k++) + { f_arg_[k].resize( long(nr), long(nr) ); + f_result_[k].resize( long(nr), long(nr) ); + } + } + // ------------------------------------------------------------------- + // unpack tx into f_arg_ + for(size_t k = 0; k < n_order; k++) + { size_t index = 1; + // unpack arg values for this order + for(long i = 0; i < long(nr); i++) + { for(long j = 0; j <= i; j++) + { f_arg_[k](i, j) = tx[ index * n_order + k ]; + f_arg_[k](j, i) = f_arg_[k](i, j); + index++; + } + } + } + // ------------------------------------------------------------------- + // result for each order + // (we could avoid recalculting f_result_[k] for k=0,...,p-1) + // + Eigen::LLT cholesky(f_arg_[0]); + f_result_[0] = cholesky.matrixL(); + lower_view L_0 = f_result_[0].template triangularView(); + for(size_t k = 1; k < n_order; k++) + { // initialize sum as A_k + matrix f_sum = f_arg_[k]; + // compute A_k - B_k + for(size_t ell = 1; ell < k; ell++) + f_sum -= f_result_[ell] * f_result_[k-ell].transpose(); + // compute L_0^{-1} * (A_k - B_k) * L_0^{-T} + matrix temp = L_0.template solve(f_sum); + temp = L_0.transpose().template solve(temp); + // divide the diagonal by 2 + for(long i = 0; i < long(nr); i++) + temp(i, i) /= scalar(2.0); + // L_k = L_0 * low[ L_0^{-1} * (A_k - B_k) * L_0^{-T} ] + lower_view view = temp.template triangularView(); + f_result_[k] = f_result_[0] * view; + } + // ------------------------------------------------------------------- + // pack result_ into ty + for(size_t k = 0; k < n_order; k++) + { size_t index = 0; + for(long i = 0; i < long(nr); i++) + { for(long j = 0; j <= i; j++) + { ty[ index * n_order + k ] = f_result_[k](i, j); + index++; + } + } + } + // ------------------------------------------------------------------- + // check if we are computing vy + if( vx.size() == 0 ) + return true; + // ------------------------------------------------------------------ + // This is a very dumb algorithm that over estimates which + // elements of the inverse are variables (which is not efficient). + bool var = false; + for(size_t i = 0; i < ny; i++) + var |= vx[1 + i]; + for(size_t i = 0; i < ny; i++) + vy[i] = var; + // + return true; + } +/* %$$ +$subhead reverse$$ +$srccode%cpp% */ + // reverse mode routine called by CppAD + virtual bool reverse( + // highest order Taylor coefficient that we are computing derivative of + size_t q , + // forward mode Taylor coefficients for x variables + const CppAD::vector& tx , + // forward mode Taylor coefficients for y variables + const CppAD::vector& ty , + // upon return, derivative of G[ F[ {x_j^k} ] ] w.r.t {x_j^k} + CppAD::vector& px , + // derivative of G[ {y_i^k} ] w.r.t. {y_i^k} + const CppAD::vector& py + ) + { size_t n_order = q + 1; + size_t nr = size_t( CppAD::Integer( tx[ 0 * n_order + 0 ] ) ); +# ifndef NDEBUG + size_t ny = ( (nr + 1 ) * nr ) / 2; + size_t nx = 1 + ny; +# endif + // + assert( nx * n_order == tx.size() ); + assert( ny * n_order == ty.size() ); + assert( px.size() == tx.size() ); + assert( py.size() == ty.size() ); + // ------------------------------------------------------------------- + // make sure f_arg_ is large enough + assert( f_arg_.size() == f_result_.size() ); + // must have previous run forward with order >= n_order + assert( f_arg_.size() >= n_order ); + // ------------------------------------------------------------------- + // make sure r_arg_, r_result_ are large enough + assert( r_arg_.size() == r_result_.size() ); + if( r_arg_.size() < n_order ) + { r_arg_.resize(n_order); + r_result_.resize(n_order); + // + for(size_t k = 0; k < n_order; k++) + { r_arg_[k].resize( long(nr), long(nr) ); + r_result_[k].resize( long(nr), long(nr) ); + } + } + // ------------------------------------------------------------------- + // unpack tx into f_arg_ + for(size_t k = 0; k < n_order; k++) + { size_t index = 1; + // unpack arg values for this order + for(long i = 0; i < long(nr); i++) + { for(long j = 0; j <= i; j++) + { f_arg_[k](i, j) = tx[ index * n_order + k ]; + f_arg_[k](j, i) = f_arg_[k](i, j); + index++; + } + } + } + // ------------------------------------------------------------------- + // unpack py into r_result_ + for(size_t k = 0; k < n_order; k++) + { r_result_[k] = matrix::Zero( long(nr), long(nr) ); + size_t index = 0; + for(long i = 0; i < long(nr); i++) + { for(long j = 0; j <= i; j++) + { r_result_[k](i, j) = py[ index * n_order + k ]; + index++; + } + } + } + // ------------------------------------------------------------------- + // initialize r_arg_ as zero + for(size_t k = 0; k < n_order; k++) + r_arg_[k] = matrix::Zero( long(nr), long(nr) ); + // ------------------------------------------------------------------- + // matrix reverse mode calculation + lower_view L_0 = f_result_[0].template triangularView(); + // + for(size_t k1 = n_order; k1 > 1; k1--) + { size_t k = k1 - 1; + // + // L_0^T * bar{L}_k + matrix tmp1 = L_0.transpose() * r_result_[k]; + // + //low[ L_0^T * bar{L}_k ] + for(long i = 0; i < long(nr); i++) + tmp1(i, i) /= scalar(2.0); + matrix tmp2 = tmp1.template triangularView(); + // + // L_0^{-T} low[ L_0^T * bar{L}_k ] + tmp1 = L_0.transpose().template solve( tmp2 ); + // + // M_k = L_0^{-T} * low[ L_0^T * bar{L}_k ]^{T} L_0^{-1} + matrix M_k = L_0.transpose().template + solve( tmp1.transpose() ); + // + // remove L_k and compute bar{B}_k + matrix barB_k = scalar(0.5) * ( M_k + M_k.transpose() ); + r_arg_[k] += barB_k; + barB_k = scalar(-1.0) * barB_k; + // + // 2.0 * lower( bar{B}_k L_k ) + matrix temp = scalar(2.0) * barB_k * f_result_[k]; + temp = temp.template triangularView(); + // + // remove C_k + r_result_[0] += temp; + // + // remove B_k + for(size_t ell = 1; ell < k; ell++) + { // bar{L}_ell = 2 * lower( \bar{B}_k * L_{k-ell} ) + temp = scalar(2.0) * barB_k * f_result_[k-ell]; + r_result_[ell] += temp.template triangularView(); + } + } + // M_0 = L_0^{-T} * low[ L_0^T * bar{L}_0 ]^{T} L_0^{-1} + matrix M_0 = L_0.transpose() * r_result_[0]; + for(long i = 0; i < long(nr); i++) + M_0(i, i) /= scalar(2.0); + M_0 = M_0.template triangularView(); + M_0 = L_0.template solve( M_0 ); + M_0 = L_0.transpose().template solve( M_0 ); + // remove L_0 + r_arg_[0] += scalar(0.5) * ( M_0 + M_0.transpose() ); + // ------------------------------------------------------------------- + // pack r_arg into px + // note that only the lower triangle of barA_k is stored in px + for(size_t k = 0; k < n_order; k++) + { size_t index = 0; + px[ index * n_order + k ] = 0.0; + index++; + for(long i = 0; i < long(nr); i++) + { for(long j = 0; j < i; j++) + { px[ index * n_order + k ] = 2.0 * r_arg_[k](i, j); + index++; + } + px[ index * n_order + k] = r_arg_[k](i, i); + index++; + } + } + // ------------------------------------------------------------------- + return true; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_eigen_cholesky class + +} // END_EMPTY_NAMESPACE +/* %$$ +$end +*/ + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/example/eigen_mat_inv.hpp cppad-2019.02.00.0/include/cppad/example/eigen_mat_inv.hpp --- cppad-2018.00.00.0/include/cppad/example/eigen_mat_inv.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/example/eigen_mat_inv.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,395 @@ +# ifndef CPPAD_EXAMPLE_EIGEN_MAT_INV_HPP +# define CPPAD_EXAMPLE_EIGEN_MAT_INV_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_eigen_mat_inv.hpp$$ +$spell + Eigen + Taylor +$$ + +$section Atomic Eigen Matrix Inversion Class$$ + +$head Purpose$$ +Construct an atomic operation that computes the matrix inverse +$latex R = A^{-1}$$ +for any positive integer $latex p$$ +and invertible matrix $latex A \in \B{R}^{p \times p}$$. + +$head Matrix Dimensions$$ +This example puts the matrix dimension $latex p$$ +in the atomic function arguments, +instead of the $cref/constructor/atomic_two_ctor/$$, +so it can be different for different calls to the atomic function. + +$head Theory$$ + +$subhead Forward$$ +The zero order forward mode Taylor coefficient is give by +$latex \[ + R_0 = A_0^{-1} +\]$$ +For $latex k = 1 , \ldots$$, +the $th k$$ order Taylor coefficient of $latex A R$$ is given by +$latex \[ + 0 = \sum_{\ell=0}^k A_\ell R_{k-\ell} +\] $$ +Solving for $latex R_k$$ in terms of the coefficients +for $latex A$$ and the lower order coefficients for $latex R$$ we have +$latex \[ + R_k = - R_0 \left( \sum_{\ell=1}^k A_\ell R_{k-\ell} \right) +\] $$ +Furthermore, once we have $latex R_k$$ we can compute the sum using +$latex \[ + A_0 R_k = - \left( \sum_{\ell=1}^k A_\ell R_{k-\ell} \right) +\] $$ + + +$subhead Product of Three Matrices$$ +Suppose $latex \bar{E}$$ is the derivative of the +scalar value function $latex s(E)$$ with respect to $latex E$$; i.e., +$latex \[ + \bar{E}_{i,j} = \frac{ \partial s } { \partial E_{i,j} } +\] $$ +Also suppose that $latex t$$ is a scalar valued argument and +$latex \[ + E(t) = B(t) C(t) D(t) +\] $$ +It follows that +$latex \[ + E'(t) = B'(t) C(t) D(t) + B(t) C'(t) D(t) + B(t) C(t) D'(t) +\] $$ + +$latex \[ + (s \circ E)'(t) + = + \R{tr} [ \bar{E}^\R{T} E'(t) ] +\] $$ +$latex \[ + = + \R{tr} [ \bar{E}^\R{T} B'(t) C(t) D(t) ] + + \R{tr} [ \bar{E}^\R{T} B(t) C'(t) D(t) ] + + \R{tr} [ \bar{E}^\R{T} B(t) C(t) D'(t) ] +\] $$ +$latex \[ + = + \R{tr} [ B(t) D(t) \bar{E}^\R{T} B'(t) ] + + \R{tr} [ D(t) \bar{E}^\R{T} B(t) C'(t) ] + + \R{tr} [ \bar{E}^\R{T} B(t) C(t) D'(t) ] +\] $$ +$latex \[ + \bar{B} = \bar{E} (C D)^\R{T} \W{,} + \bar{C} = \B{R}^\R{T} \bar{E} D^\R{T} \W{,} + \bar{D} = (B C)^\R{T} \bar{E} +\] $$ + +$subhead Reverse$$ +For $latex k > 0$$, reverse mode +eliminates $latex R_k$$ and expresses the function values +$latex s$$ in terms of the coefficients of $latex A$$ +and the lower order coefficients of $latex R$$. +The effect on $latex \bar{R}_0$$ +(of eliminating $latex R_k$$) is +$latex \[ +\bar{R}_0 += \bar{R}_0 - \bar{R}_k \left( \sum_{\ell=1}^k A_\ell R_{k-\ell} \right)^\R{T} += \bar{R}_0 + \bar{R}_k ( A_0 R_k )^\R{T} +\] $$ +For $latex \ell = 1 , \ldots , k$$, +the effect on $latex \bar{R}_{k-\ell}$$ and $latex A_\ell$$ +(of eliminating $latex R_k$$) is +$latex \[ +\bar{A}_\ell = \bar{A}_\ell - R_0^\R{T} \bar{R}_k R_{k-\ell}^\R{T} +\] $$ +$latex \[ +\bar{R}_{k-\ell} = \bar{R}_{k-\ell} - ( R_0 A_\ell )^\R{T} \bar{R}_k +\] $$ +We note that +$latex \[ + R_0 '(t) A_0 (t) + R_0 (t) A_0 '(t) = 0 +\] $$ +$latex \[ + R_0 '(t) = - R_0 (t) A_0 '(t) R_0 (t) +\] $$ +The reverse mode formula that eliminates $latex R_0$$ is +$latex \[ + \bar{A}_0 + = \bar{A}_0 - R_0^\R{T} \bar{R}_0 R_0^\R{T} +\]$$ + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +# include +# include + + + +/* %$$ +$head Public$$ + +$subhead Types$$ +$srccode%cpp% */ +namespace { // BEGIN_EMPTY_NAMESPACE + +template +class atomic_eigen_mat_inv : public CppAD::atomic_base { +public: + // ----------------------------------------------------------- + // type of elements during calculation of derivatives + typedef Base scalar; + // type of elements during taping + typedef CppAD::AD ad_scalar; + // type of matrix during calculation of derivatives + typedef Eigen::Matrix< + scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> matrix; + // type of matrix during taping + typedef Eigen::Matrix< + ad_scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ad_matrix; +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // constructor + atomic_eigen_mat_inv(void) : CppAD::atomic_base( + "atom_eigen_mat_inv" , + CppAD::atomic_base::set_sparsity_enum + ) + { } +/* %$$ +$subhead op$$ +$srccode%cpp% */ + // use atomic operation to invert an AD matrix + ad_matrix op(const ad_matrix& arg) + { size_t nr = size_t( arg.rows() ); + size_t ny = nr * nr; + size_t nx = 1 + ny; + assert( nr == size_t( arg.cols() ) ); + // ------------------------------------------------------------------- + // packed version of arg + CPPAD_TESTVECTOR(ad_scalar) packed_arg(nx); + packed_arg[0] = ad_scalar( nr ); + for(size_t i = 0; i < ny; i++) + packed_arg[1 + i] = arg.data()[i]; + // ------------------------------------------------------------------- + // packed version of result = arg^{-1}. + // This is an atomic_base function call that CppAD uses to + // store the atomic operation on the tape. + CPPAD_TESTVECTOR(ad_scalar) packed_result(ny); + (*this)(packed_arg, packed_result); + // ------------------------------------------------------------------- + // unpack result matrix + ad_matrix result(nr, nr); + for(size_t i = 0; i < ny; i++) + result.data()[i] = packed_result[i]; + return result; + } + /* %$$ +$head Private$$ + +$subhead Variables$$ +$srccode%cpp% */ +private: + // ------------------------------------------------------------- + // one forward mode vector of matrices for argument and result + CppAD::vector f_arg_, f_result_; + // one reverse mode vector of matrices for argument and result + CppAD::vector r_arg_, r_result_; + // ------------------------------------------------------------- +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + // lowest order Taylor coefficient we are evaluating + size_t p , + // highest order Taylor coefficient we are evaluating + size_t q , + // which components of x are variables + const CppAD::vector& vx , + // which components of y are variables + CppAD::vector& vy , + // tx [ j * (q+1) + k ] is x_j^k + const CppAD::vector& tx , + // ty [ i * (q+1) + k ] is y_i^k + CppAD::vector& ty + ) + { size_t n_order = q + 1; + size_t nr = size_t( CppAD::Integer( tx[ 0 * n_order + 0 ] ) ); + size_t ny = nr * nr; +# ifndef NDEBUG + size_t nx = 1 + ny; +# endif + assert( vx.size() == 0 || nx == vx.size() ); + assert( vx.size() == 0 || ny == vy.size() ); + assert( nx * n_order == tx.size() ); + assert( ny * n_order == ty.size() ); + // + // ------------------------------------------------------------------- + // make sure f_arg_ and f_result_ are large enough + assert( f_arg_.size() == f_result_.size() ); + if( f_arg_.size() < n_order ) + { f_arg_.resize(n_order); + f_result_.resize(n_order); + // + for(size_t k = 0; k < n_order; k++) + { f_arg_[k].resize( long(nr), long(nr) ); + f_result_[k].resize( long(nr), long(nr) ); + } + } + // ------------------------------------------------------------------- + // unpack tx into f_arg_ + for(size_t k = 0; k < n_order; k++) + { // unpack arg values for this order + for(size_t i = 0; i < ny; i++) + f_arg_[k].data()[i] = tx[ (1 + i) * n_order + k ]; + } + // ------------------------------------------------------------------- + // result for each order + // (we could avoid recalculting f_result_[k] for k=0,...,p-1) + // + f_result_[0] = f_arg_[0].inverse(); + for(size_t k = 1; k < n_order; k++) + { // initialize sum + matrix f_sum = matrix::Zero( long(nr), long(nr) ); + // compute sum + for(size_t ell = 1; ell <= k; ell++) + f_sum -= f_arg_[ell] * f_result_[k-ell]; + // result_[k] = arg_[0]^{-1} * sum_ + f_result_[k] = f_result_[0] * f_sum; + } + // ------------------------------------------------------------------- + // pack result_ into ty + for(size_t k = 0; k < n_order; k++) + { for(size_t i = 0; i < ny; i++) + ty[ i * n_order + k ] = f_result_[k].data()[i]; + } + // ------------------------------------------------------------------- + // check if we are computing vy + if( vx.size() == 0 ) + return true; + // ------------------------------------------------------------------ + // This is a very dumb algorithm that over estimates which + // elements of the inverse are variables (which is not efficient). + bool var = false; + for(size_t i = 0; i < ny; i++) + var |= vx[1 + i]; + for(size_t i = 0; i < ny; i++) + vy[i] = var; + return true; + } +/* %$$ +$subhead reverse$$ +$srccode%cpp% */ + // reverse mode routine called by CppAD + virtual bool reverse( + // highest order Taylor coefficient that we are computing derivative of + size_t q , + // forward mode Taylor coefficients for x variables + const CppAD::vector& tx , + // forward mode Taylor coefficients for y variables + const CppAD::vector& ty , + // upon return, derivative of G[ F[ {x_j^k} ] ] w.r.t {x_j^k} + CppAD::vector& px , + // derivative of G[ {y_i^k} ] w.r.t. {y_i^k} + const CppAD::vector& py + ) + { size_t n_order = q + 1; + size_t nr = size_t( CppAD::Integer( tx[ 0 * n_order + 0 ] ) ); + size_t ny = nr * nr; +# ifndef NDEBUG + size_t nx = 1 + ny; +# endif + // + assert( nx * n_order == tx.size() ); + assert( ny * n_order == ty.size() ); + assert( px.size() == tx.size() ); + assert( py.size() == ty.size() ); + // ------------------------------------------------------------------- + // make sure f_arg_ is large enough + assert( f_arg_.size() == f_result_.size() ); + // must have previous run forward with order >= n_order + assert( f_arg_.size() >= n_order ); + // ------------------------------------------------------------------- + // make sure r_arg_, r_result_ are large enough + assert( r_arg_.size() == r_result_.size() ); + if( r_arg_.size() < n_order ) + { r_arg_.resize(n_order); + r_result_.resize(n_order); + // + for(size_t k = 0; k < n_order; k++) + { r_arg_[k].resize( long(nr), long(nr) ); + r_result_[k].resize( long(nr), long(nr) ); + } + } + // ------------------------------------------------------------------- + // unpack tx into f_arg_ + for(size_t k = 0; k < n_order; k++) + { // unpack arg values for this order + for(size_t i = 0; i < ny; i++) + f_arg_[k].data()[i] = tx[ (1 + i) * n_order + k ]; + } + // ------------------------------------------------------------------- + // unpack py into r_result_ + for(size_t k = 0; k < n_order; k++) + { for(size_t i = 0; i < ny; i++) + r_result_[k].data()[i] = py[ i * n_order + k ]; + } + // ------------------------------------------------------------------- + // initialize r_arg_ as zero + for(size_t k = 0; k < n_order; k++) + r_arg_[k] = matrix::Zero( long(nr), long(nr) ); + // ------------------------------------------------------------------- + // matrix reverse mode calculation + // + for(size_t k1 = n_order; k1 > 1; k1--) + { size_t k = k1 - 1; + // bar{R}_0 = bar{R}_0 + bar{R}_k (A_0 R_k)^T + r_result_[0] += + r_result_[k] * f_result_[k].transpose() * f_arg_[0].transpose(); + // + for(size_t ell = 1; ell <= k; ell++) + { // bar{A}_l = bar{A}_l - R_0^T bar{R}_k R_{k-l}^T + r_arg_[ell] -= f_result_[0].transpose() + * r_result_[k] * f_result_[k-ell].transpose(); + // bar{R}_{k-l} = bar{R}_{k-1} - (R_0 A_l)^T bar{R}_k + r_result_[k-ell] -= f_arg_[ell].transpose() + * f_result_[0].transpose() * r_result_[k]; + } + } + r_arg_[0] -= + f_result_[0].transpose() * r_result_[0] * f_result_[0].transpose(); + // ------------------------------------------------------------------- + // pack r_arg into px + for(size_t k = 0; k < n_order; k++) + { for(size_t i = 0; i < ny; i++) + px[ (1 + i) * n_order + k ] = r_arg_[k].data()[i]; + } + // + return true; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_eigen_mat_inv class + +} // END_EMPTY_NAMESPACE +/* %$$ +$$ $comment end nospell$$ +$end +*/ + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/example/eigen_mat_mul.hpp cppad-2019.02.00.0/include/cppad/example/eigen_mat_mul.hpp --- cppad-2018.00.00.0/include/cppad/example/eigen_mat_mul.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/example/eigen_mat_mul.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,658 @@ +# ifndef CPPAD_EXAMPLE_EIGEN_MAT_MUL_HPP +# define CPPAD_EXAMPLE_EIGEN_MAT_MUL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_eigen_mat_mul.hpp$$ +$spell + Eigen + Taylor + nr + nc +$$ + +$section Atomic Eigen Matrix Multiply Class$$ + +$head See Also$$ +$cref atomic_mat_mul.hpp$$ + +$head Purpose$$ +Construct an atomic operation that computes the matrix product, +$latex R = A \times \B{R}$$ +for any positive integers $latex r$$, $latex m$$, $latex c$$, +and any $latex A \in \B{R}^{r \times m}$$, +$latex B \in \B{R}^{m \times c}$$. + +$head Matrix Dimensions$$ +This example puts the matrix dimensions in the atomic function arguments, +instead of the $cref/constructor/atomic_two_ctor/$$, so that they can +be different for different calls to the atomic function. +These dimensions are: +$table +$icode nr_left$$ + $cnext number of rows in the left matrix; i.e, $latex r$$ $rend +$icode n_middle$$ + $cnext rows in the left matrix and columns in right; i.e, $latex m$$ $rend +$icode nc_right$$ + $cnext number of columns in the right matrix; i.e., $latex c$$ +$tend + +$head Theory$$ + +$subhead Forward$$ +For $latex k = 0 , \ldots $$, the $th k$$ order Taylor coefficient +$latex R_k$$ is given by +$latex \[ + R_k = \sum_{\ell = 0}^{k} A_\ell B_{k-\ell} +\] $$ + +$subhead Product of Two Matrices$$ +Suppose $latex \bar{E}$$ is the derivative of the +scalar value function $latex s(E)$$ with respect to $latex E$$; i.e., +$latex \[ + \bar{E}_{i,j} = \frac{ \partial s } { \partial E_{i,j} } +\] $$ +Also suppose that $latex t$$ is a scalar valued argument and +$latex \[ + E(t) = C(t) D(t) +\] $$ +It follows that +$latex \[ + E'(t) = C'(t) D(t) + C(t) D'(t) +\] $$ + +$latex \[ + (s \circ E)'(t) + = + \R{tr} [ \bar{E}^\R{T} E'(t) ] +\] $$ +$latex \[ + = + \R{tr} [ \bar{E}^\R{T} C'(t) D(t) ] + + \R{tr} [ \bar{E}^\R{T} C(t) D'(t) ] +\] $$ +$latex \[ + = + \R{tr} [ D(t) \bar{E}^\R{T} C'(t) ] + + \R{tr} [ \bar{E}^\R{T} C(t) D'(t) ] +\] $$ +$latex \[ + \bar{C} = \bar{E} D^\R{T} \W{,} + \bar{D} = C^\R{T} \bar{E} +\] $$ + +$subhead Reverse$$ +Reverse mode eliminates $latex R_k$$ as follows: +for $latex \ell = 0, \ldots , k-1$$, +$latex \[ +\bar{A}_\ell = \bar{A}_\ell + \bar{R}_k B_{k-\ell}^\R{T} +\] $$ +$latex \[ +\bar{B}_{k-\ell} = \bar{B}_{k-\ell} + A_\ell^\R{T} \bar{R}_k +\] $$ + + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +# include + + +/* %$$ +$head Public$$ + +$subhead Types$$ +$srccode%cpp% */ +namespace { // BEGIN_EMPTY_NAMESPACE + +template +class atomic_eigen_mat_mul : public CppAD::atomic_base { +public: + // ----------------------------------------------------------- + // type of elements during calculation of derivatives + typedef Base scalar; + // type of elements during taping + typedef CppAD::AD ad_scalar; + // type of matrix during calculation of derivatives + typedef Eigen::Matrix< + scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> matrix; + // type of matrix during taping + typedef Eigen::Matrix< + ad_scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > ad_matrix; +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // constructor + atomic_eigen_mat_mul(void) : CppAD::atomic_base( + "atom_eigen_mat_mul" , + CppAD::atomic_base::set_sparsity_enum + ) + { } +/* %$$ +$subhead op$$ +$srccode%cpp% */ + // use atomic operation to multiply two AD matrices + ad_matrix op( + const ad_matrix& left , + const ad_matrix& right ) + { size_t nr_left = size_t( left.rows() ); + size_t n_middle = size_t( left.cols() ); + size_t nc_right = size_t( right.cols() ); + assert( n_middle == size_t( right.rows() ) ); + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t ny = nr_left * nc_right; + size_t n_left = nr_left * n_middle; + size_t n_right = n_middle * nc_right; + size_t n_result = nr_left * nc_right; + // + assert( 3 + n_left + n_right == nx ); + assert( n_result == ny ); + // ----------------------------------------------------------------- + // packed version of left and right + CPPAD_TESTVECTOR(ad_scalar) packed_arg(nx); + // + packed_arg[0] = ad_scalar( nr_left ); + packed_arg[1] = ad_scalar( n_middle ); + packed_arg[2] = ad_scalar( nc_right ); + for(size_t i = 0; i < n_left; i++) + packed_arg[3 + i] = left.data()[i]; + for(size_t i = 0; i < n_right; i++) + packed_arg[ 3 + n_left + i ] = right.data()[i]; + // ------------------------------------------------------------------ + // Packed version of result = left * right. + // This as an atomic_base funciton call that CppAD uses + // to store the atomic operation on the tape. + CPPAD_TESTVECTOR(ad_scalar) packed_result(ny); + (*this)(packed_arg, packed_result); + // ------------------------------------------------------------------ + // unpack result matrix + ad_matrix result(nr_left, nc_right); + for(size_t i = 0; i < n_result; i++) + result.data()[i] = packed_result[ i ]; + // + return result; + } +/* %$$ +$head Private$$ + +$subhead Variables$$ +$srccode%cpp% */ +private: + // ------------------------------------------------------------- + // one forward mode vector of matrices for left, right, and result + CppAD::vector f_left_, f_right_, f_result_; + // one reverse mode vector of matrices for left, right, and result + CppAD::vector r_left_, r_right_, r_result_; + // ------------------------------------------------------------- +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + // lowest order Taylor coefficient we are evaluating + size_t p , + // highest order Taylor coefficient we are evaluating + size_t q , + // which components of x are variables + const CppAD::vector& vx , + // which components of y are variables + CppAD::vector& vy , + // tx [ 3 + j * (q+1) + k ] is x_j^k + const CppAD::vector& tx , + // ty [ i * (q+1) + k ] is y_i^k + CppAD::vector& ty + ) + { size_t n_order = q + 1; + size_t nr_left = size_t( CppAD::Integer( tx[ 0 * n_order + 0 ] ) ); + size_t n_middle = size_t( CppAD::Integer( tx[ 1 * n_order + 0 ] ) ); + size_t nc_right = size_t( CppAD::Integer( tx[ 2 * n_order + 0 ] ) ); +# ifndef NDEBUG + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t ny = nr_left * nc_right; +# endif + // + assert( vx.size() == 0 || nx == vx.size() ); + assert( vx.size() == 0 || ny == vy.size() ); + assert( nx * n_order == tx.size() ); + assert( ny * n_order == ty.size() ); + // + size_t n_left = nr_left * n_middle; + size_t n_right = n_middle * nc_right; + size_t n_result = nr_left * nc_right; + assert( 3 + n_left + n_right == nx ); + assert( n_result == ny ); + // + // ------------------------------------------------------------------- + // make sure f_left_, f_right_, and f_result_ are large enough + assert( f_left_.size() == f_right_.size() ); + assert( f_left_.size() == f_result_.size() ); + if( f_left_.size() < n_order ) + { f_left_.resize(n_order); + f_right_.resize(n_order); + f_result_.resize(n_order); + // + for(size_t k = 0; k < n_order; k++) + { f_left_[k].resize( long(nr_left), long(n_middle) ); + f_right_[k].resize( long(n_middle), long(nc_right) ); + f_result_[k].resize( long(nr_left), long(nc_right) ); + } + } + // ------------------------------------------------------------------- + // unpack tx into f_left and f_right + for(size_t k = 0; k < n_order; k++) + { // unpack left values for this order + for(size_t i = 0; i < n_left; i++) + f_left_[k].data()[i] = tx[ (3 + i) * n_order + k ]; + // + // unpack right values for this order + for(size_t i = 0; i < n_right; i++) + f_right_[k].data()[i] = tx[ ( 3 + n_left + i) * n_order + k ]; + } + // ------------------------------------------------------------------- + // result for each order + // (we could avoid recalculting f_result_[k] for k=0,...,p-1) + for(size_t k = 0; k < n_order; k++) + { // result[k] = sum_ell left[ell] * right[k-ell] + f_result_[k] = matrix::Zero( long(nr_left), long(nc_right) ); + for(size_t ell = 0; ell <= k; ell++) + f_result_[k] += f_left_[ell] * f_right_[k-ell]; + } + // ------------------------------------------------------------------- + // pack result_ into ty + for(size_t k = 0; k < n_order; k++) + { for(size_t i = 0; i < n_result; i++) + ty[ i * n_order + k ] = f_result_[k].data()[i]; + } + // ------------------------------------------------------------------ + // check if we are computing vy + if( vx.size() == 0 ) + return true; + // ------------------------------------------------------------------ + // compute variable information for y; i.e., vy + // (note that the constant zero times a variable is a constant) + scalar zero(0.0); + assert( n_order == 1 ); + for(size_t i = 0; i < nr_left; i++) + { for(size_t j = 0; j < nc_right; j++) + { bool var = false; + for(size_t ell = 0; ell < n_middle; ell++) + { // left information + size_t index = 3 + i * n_middle + ell; + bool var_left = vx[index]; + bool nz_left = var_left | + (f_left_[0]( long(i), long(ell) ) != zero); + // right information + index = 3 + n_left + ell * nc_right + j; + bool var_right = vx[index]; + bool nz_right = var_right | + (f_right_[0]( long(ell), long(j) ) != zero); + // effect of result + var |= var_left & nz_right; + var |= nz_left & var_right; + } + size_t index = i * nc_right + j; + vy[index] = var; + } + } + return true; + } +/* %$$ +$subhead reverse$$ +$srccode%cpp% */ + // reverse mode routine called by CppAD + virtual bool reverse( + // highest order Taylor coefficient that we are computing derivative of + size_t q , + // forward mode Taylor coefficients for x variables + const CppAD::vector& tx , + // forward mode Taylor coefficients for y variables + const CppAD::vector& ty , + // upon return, derivative of G[ F[ {x_j^k} ] ] w.r.t {x_j^k} + CppAD::vector& px , + // derivative of G[ {y_i^k} ] w.r.t. {y_i^k} + const CppAD::vector& py + ) + { size_t n_order = q + 1; + size_t nr_left = size_t( CppAD::Integer( tx[ 0 * n_order + 0 ] ) ); + size_t n_middle = size_t( CppAD::Integer( tx[ 1 * n_order + 0 ] ) ); + size_t nc_right = size_t( CppAD::Integer( tx[ 2 * n_order + 0 ] ) ); +# ifndef NDEBUG + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t ny = nr_left * nc_right; +# endif + // + assert( nx * n_order == tx.size() ); + assert( ny * n_order == ty.size() ); + assert( px.size() == tx.size() ); + assert( py.size() == ty.size() ); + // + size_t n_left = nr_left * n_middle; + size_t n_right = n_middle * nc_right; + size_t n_result = nr_left * nc_right; + assert( 3 + n_left + n_right == nx ); + assert( n_result == ny ); + // ------------------------------------------------------------------- + // make sure f_left_, f_right_ are large enough + assert( f_left_.size() == f_right_.size() ); + assert( f_left_.size() == f_result_.size() ); + // must have previous run forward with order >= n_order + assert( f_left_.size() >= n_order ); + // ------------------------------------------------------------------- + // make sure r_left_, r_right_, and r_result_ are large enough + assert( r_left_.size() == r_right_.size() ); + assert( r_left_.size() == r_result_.size() ); + if( r_left_.size() < n_order ) + { r_left_.resize(n_order); + r_right_.resize(n_order); + r_result_.resize(n_order); + // + for(size_t k = 0; k < n_order; k++) + { r_left_[k].resize( long(nr_left), long(n_middle) ); + r_right_[k].resize( long(n_middle), long(nc_right) ); + r_result_[k].resize( long(nr_left), long(nc_right) ); + } + } + // ------------------------------------------------------------------- + // unpack tx into f_left and f_right + for(size_t k = 0; k < n_order; k++) + { // unpack left values for this order + for(size_t i = 0; i < n_left; i++) + f_left_[k].data()[i] = tx[ (3 + i) * n_order + k ]; + // + // unpack right values for this order + for(size_t i = 0; i < n_right; i++) + f_right_[k].data()[i] = tx[ (3 + n_left + i) * n_order + k ]; + } + // ------------------------------------------------------------------- + // unpack py into r_result_ + for(size_t k = 0; k < n_order; k++) + { for(size_t i = 0; i < n_result; i++) + r_result_[k].data()[i] = py[ i * n_order + k ]; + } + // ------------------------------------------------------------------- + // initialize r_left_ and r_right_ as zero + for(size_t k = 0; k < n_order; k++) + { r_left_[k] = matrix::Zero( long(nr_left), long(n_middle) ); + r_right_[k] = matrix::Zero( long(n_middle), long(nc_right) ); + } + // ------------------------------------------------------------------- + // matrix reverse mode calculation + for(size_t k1 = n_order; k1 > 0; k1--) + { size_t k = k1 - 1; + for(size_t ell = 0; ell <= k; ell++) + { // nr x nm = nr x nc * nc * nm + r_left_[ell] += r_result_[k] * f_right_[k-ell].transpose(); + // nm x nc = nm x nr * nr * nc + r_right_[k-ell] += f_left_[ell].transpose() * r_result_[k]; + } + } + // ------------------------------------------------------------------- + // pack r_left and r_right int px + for(size_t k = 0; k < n_order; k++) + { // dimensions are integer constants + px[ 0 * n_order + k ] = 0.0; + px[ 1 * n_order + k ] = 0.0; + px[ 2 * n_order + k ] = 0.0; + // + // pack left values for this order + for(size_t i = 0; i < n_left; i++) + px[ (3 + i) * n_order + k ] = r_left_[k].data()[i]; + // + // pack right values for this order + for(size_t i = 0; i < n_right; i++) + px[ (3 + i + n_left) * n_order + k] = r_right_[k].data()[i]; + } + // + return true; + } +/* %$$ +$subhead for_sparse_jac$$ +$srccode%cpp% */ + // forward Jacobian sparsity routine called by CppAD + virtual bool for_sparse_jac( + // number of columns in the matrix R + size_t q , + // sparsity pattern for the matrix R + const CppAD::vector< std::set >& r , + // sparsity pattern for the matrix S = f'(x) * R + CppAD::vector< std::set >& s , + const CppAD::vector& x ) + { + size_t nr_left = size_t( CppAD::Integer( x[0] ) ); + size_t n_middle = size_t( CppAD::Integer( x[1] ) ); + size_t nc_right = size_t( CppAD::Integer( x[2] ) ); +# ifndef NDEBUG + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t ny = nr_left * nc_right; +# endif + // + assert( nx == r.size() ); + assert( ny == s.size() ); + // + size_t n_left = nr_left * n_middle; + for(size_t i = 0; i < nr_left; i++) + { for(size_t j = 0; j < nc_right; j++) + { // pack index for entry (i, j) in result + size_t i_result = i * nc_right + j; + s[i_result].clear(); + for(size_t ell = 0; ell < n_middle; ell++) + { // pack index for entry (i, ell) in left + size_t i_left = 3 + i * n_middle + ell; + // pack index for entry (ell, j) in right + size_t i_right = 3 + n_left + ell * nc_right + j; + // check if result of for this product is alwasy zero + // note that x is nan for commponents that are variables + bool zero = x[i_left] == Base(0.0) || x[i_right] == Base(0); + if( ! zero ) + { s[i_result] = + CppAD::set_union(s[i_result], r[i_left] ); + s[i_result] = + CppAD::set_union(s[i_result], r[i_right] ); + } + } + } + } + return true; + } +/* %$$ +$subhead rev_sparse_jac$$ +$srccode%cpp% */ + // reverse Jacobian sparsity routine called by CppAD + virtual bool rev_sparse_jac( + // number of columns in the matrix R^T + size_t q , + // sparsity pattern for the matrix R^T + const CppAD::vector< std::set >& rt , + // sparsoity pattern for the matrix S^T = f'(x)^T * R^T + CppAD::vector< std::set >& st , + const CppAD::vector& x ) + { + size_t nr_left = size_t( CppAD::Integer( x[0] ) ); + size_t n_middle = size_t( CppAD::Integer( x[1] ) ); + size_t nc_right = size_t( CppAD::Integer( x[2] ) ); + size_t nx = 3 + (nr_left + nc_right) * n_middle; +# ifndef NDEBUG + size_t ny = nr_left * nc_right; +# endif + // + assert( nx == st.size() ); + assert( ny == rt.size() ); + // + // initialize S^T as empty + for(size_t i = 0; i < nx; i++) + st[i].clear(); + + // sparsity for S(x)^T = f'(x)^T * R^T + size_t n_left = nr_left * n_middle; + for(size_t i = 0; i < nr_left; i++) + { for(size_t j = 0; j < nc_right; j++) + { // pack index for entry (i, j) in result + size_t i_result = i * nc_right + j; + st[i_result].clear(); + for(size_t ell = 0; ell < n_middle; ell++) + { // pack index for entry (i, ell) in left + size_t i_left = 3 + i * n_middle + ell; + // pack index for entry (ell, j) in right + size_t i_right = 3 + n_left + ell * nc_right + j; + // + st[i_left] = CppAD::set_union(st[i_left], rt[i_result]); + st[i_right] = CppAD::set_union(st[i_right], rt[i_result]); + } + } + } + return true; + } +/* %$$ +$subhead for_sparse_hes$$ +$srccode%cpp% */ + virtual bool for_sparse_hes( + // which components of x are variables for this call + const CppAD::vector& vx, + // sparsity pattern for the diagonal of R + const CppAD::vector& r , + // sparsity pattern for the vector S + const CppAD::vector& s , + // sparsity patternfor the Hessian H(x) + CppAD::vector< std::set >& h , + const CppAD::vector& x ) + { + size_t nr_left = size_t( CppAD::Integer( x[0] ) ); + size_t n_middle = size_t( CppAD::Integer( x[1] ) ); + size_t nc_right = size_t( CppAD::Integer( x[2] ) ); + size_t nx = 3 + (nr_left + nc_right) * n_middle; +# ifndef NDEBUG + size_t ny = nr_left * nc_right; +# endif + // + assert( vx.size() == nx ); + assert( r.size() == nx ); + assert( s.size() == ny ); + assert( h.size() == nx ); + // + // initilize h as empty + for(size_t i = 0; i < nx; i++) + h[i].clear(); + // + size_t n_left = nr_left * n_middle; + for(size_t i = 0; i < nr_left; i++) + { for(size_t j = 0; j < nc_right; j++) + { // pack index for entry (i, j) in result + size_t i_result = i * nc_right + j; + if( s[i_result] ) + { for(size_t ell = 0; ell < n_middle; ell++) + { // pack index for entry (i, ell) in left + size_t i_left = 3 + i * n_middle + ell; + // pack index for entry (ell, j) in right + size_t i_right = 3 + n_left + ell * nc_right + j; + if( r[i_left] & r[i_right] ) + { h[i_left].insert(i_right); + h[i_right].insert(i_left); + } + } + } + } + } + return true; + } +/* %$$ +$subhead rev_sparse_hes$$ +$srccode%cpp% */ + // reverse Hessian sparsity routine called by CppAD + virtual bool rev_sparse_hes( + // which components of x are variables for this call + const CppAD::vector& vx, + // sparsity pattern for S(x) = g'[f(x)] + const CppAD::vector& s , + // sparsity pattern for d/dx g[f(x)] = S(x) * f'(x) + CppAD::vector& t , + // number of columns in R, U(x), and V(x) + size_t q , + // sparsity pattern for R + const CppAD::vector< std::set >& r , + // sparsity pattern for U(x) = g^{(2)} [ f(x) ] * f'(x) * R + const CppAD::vector< std::set >& u , + // sparsity pattern for + // V(x) = f'(x)^T * U(x) + sum_{i=0}^{m-1} S_i(x) f_i^{(2)} (x) * R + CppAD::vector< std::set >& v , + // parameters as integers + const CppAD::vector& x ) + { + size_t nr_left = size_t( CppAD::Integer( x[0] ) ); + size_t n_middle = size_t( CppAD::Integer( x[1] ) ); + size_t nc_right = size_t( CppAD::Integer( x[2] ) ); + size_t nx = 3 + (nr_left + nc_right) * n_middle; +# ifndef NDEBUG + size_t ny = nr_left * nc_right; +# endif + // + assert( vx.size() == nx ); + assert( s.size() == ny ); + assert( t.size() == nx ); + assert( r.size() == nx ); + assert( v.size() == nx ); + // + // initilaize return sparsity patterns as false + for(size_t j = 0; j < nx; j++) + { t[j] = false; + v[j].clear(); + } + // + size_t n_left = nr_left * n_middle; + for(size_t i = 0; i < nr_left; i++) + { for(size_t j = 0; j < nc_right; j++) + { // pack index for entry (i, j) in result + size_t i_result = i * nc_right + j; + for(size_t ell = 0; ell < n_middle; ell++) + { // pack index for entry (i, ell) in left + size_t i_left = 3 + i * n_middle + ell; + // pack index for entry (ell, j) in right + size_t i_right = 3 + n_left + ell * nc_right + j; + // + // back propagate T(x) = S(x) * f'(x). + t[i_left] |= bool( s[i_result] ); + t[i_right] |= bool( s[i_result] ); + // + // V(x) = f'(x)^T * U(x) + sum_i S_i(x) * f_i''(x) * R + // U(x) = g''[ f(x) ] * f'(x) * R + // S_i(x) = g_i'[ f(x) ] + // + // back propagate f'(x)^T * U(x) + v[i_left] = CppAD::set_union(v[i_left], u[i_result] ); + v[i_right] = CppAD::set_union(v[i_right], u[i_result] ); + // + // back propagate S_i(x) * f_i''(x) * R + // (here is where we use vx to check for cross terms) + if( s[i_result] & vx[i_left] & vx[i_right] ) + { v[i_left] = CppAD::set_union(v[i_left], r[i_right] ); + v[i_right] = CppAD::set_union(v[i_right], r[i_left] ); + } + } + } + } + return true; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_eigen_mat_mul class + +} // END_EMPTY_NAMESPACE +/* %$$ +$$ $comment end nospell$$ +$end +*/ + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/example/eigen_plugin.hpp cppad-2019.02.00.0/include/cppad/example/eigen_plugin.hpp --- cppad-2018.00.00.0/include/cppad/example/eigen_plugin.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/example/eigen_plugin.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,28 @@ +# ifndef CPPAD_EXAMPLE_EIGEN_PLUGIN_HPP +# define CPPAD_EXAMPLE_EIGEN_PLUGIN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*$ +$begin eigen_plugin.hpp$$ +$spell + eigen_plugin.hpp + typedef +$$ + +$section Source Code for eigen_plugin.hpp$$ +$srccode%cpp% */ +// Declaration needed, before eigen-3.3.3, so Eigen vector is a simple vector +typedef Scalar value_type; +/* %$$ +$end +*/ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/example/mat_mul.hpp cppad-2019.02.00.0/include/cppad/example/mat_mul.hpp --- cppad-2018.00.00.0/include/cppad/example/mat_mul.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/example/mat_mul.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,661 @@ +# ifndef CPPAD_EXAMPLE_MAT_MUL_HPP +# define CPPAD_EXAMPLE_MAT_MUL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_mat_mul.hpp$$ +$spell + Taylor + ty + px + CppAD + jac + hes + nr + nc + afun + mul +$$ + +$section Matrix Multiply as an Atomic Operation$$ + +$head See Also$$ +$cref atomic_eigen_mat_mul.hpp$$ + +$head Purpose$$ +Compute the matrix product $icode%result% = %left% * %right%$$ +as an $code AD$$ operation. + +$subhead parameter_x$$ +This example demonstrates the use of the +$cref/parameter_x/atomic_three/parameter_x/$$ +argument to the $cref atomic_three$$ virtual functions. + +$subhead type_x$$ +This example also demonstrates the use of the +$cref/type_x/atomic_three/type_x/$$ +argument to the $cref atomic_three$$ virtual functions. + +$head Matrix Dimensions$$ +The first three components of the argument vector $icode ax$$ +in the call $icode%afun%(%ax%, %ay%)%$$ +are parameters and contain the matrix dimensions. +This enables them to be different for each use of the same atomic +function $icode afun$$. +These dimensions are: +$table +$icode%ax%[0]%$$ $pre $$ + $cnext $icode nr_left$$ $pre $$ + $cnext number of rows in the left matrix and result matrix +$rend +$icode%ax%[1]%$$ $pre $$ + $cnext $icode n_middle$$ $pre $$ + $cnext columns in the left matrix and rows in right matrix +$rend +$icode%ax%[2]%$$ $pre $$ + $cnext $icode nc_right$$ $pre $$ + $cnext number of columns in the right matrix and result matrix +$tend + + +$head Left Matrix$$ +The number of elements in the left matrix is +$codei% + %n_left% = %nr_left% * %n_middle% +%$$ +The elements are in +$icode%ax%[3]%$$ through $icode%ax%[2+%n_left%]%$$ in row major order. + +$head Right Matrix$$ +The number of elements in the right matrix is +$codei% + %n_right% = %n_middle% * %nc_right% +%$$ +The elements are in +$icode%ax%[3+%n_left%]%$$ through +$icode%ax%[2+%n_left%+%n_right%]%$$ in row major order. + +$head Result Matrix$$ +The number of elements in the result matrix is +$codei% + %n_result% = %nr_left% * %nc_right% +%$$ +The elements are in +$icode%ay%[0]%$$ through $icode%ay%[%n_result%-1]%$$ in row major order. + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // Begin empty namespace +using CppAD::vector; +// +// matrix result = left * right +class atomic_mat_mul : public CppAD::atomic_three { +/* %$$ +$head Constructor$$ +$srccode%cpp% */ +public: + // --------------------------------------------------------------------- + // constructor + atomic_mat_mul(void) : CppAD::atomic_three("mat_mul") + { } +private: +/* %$$ +$head Left Operand Element Index$$ +Index in the Taylor coefficient matrix $icode tx$$ of a left matrix element. +$srccode%cpp% */ + size_t left( + 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 nr_left , // rows in left matrix + size_t n_middle , // rows in left and columns in right + size_t nc_right ) // columns in right matrix + { assert( i < nr_left ); + assert( j < n_middle ); + return (3 + i * n_middle + j) * nk + k; + } +/* %$$ +$head Right Operand Element Index$$ +Index in the Taylor coefficient matrix $icode tx$$ of a right matrix element. +$srccode%cpp% */ + size_t right( + 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 nr_left , // rows in left matrix + size_t n_middle , // rows in left and columns in right + size_t nc_right ) // columns in right matrix + { assert( i < n_middle ); + assert( j < nc_right ); + size_t offset = 3 + nr_left * n_middle; + return (offset + i * nc_right + j) * nk + k; + } +/* %$$ +$head Result Element Index$$ +Index in the Taylor coefficient matrix $icode ty$$ of a result matrix element. +$srccode%cpp% */ + size_t result( + size_t i , // result matrix row index + size_t j , // result matrix column index + size_t k , // Taylor coeffocient order + size_t nk , // number of Taylor coefficients in ty + size_t nr_left , // rows in left matrix + size_t n_middle , // rows in left and columns in right + size_t nc_right ) // columns in right matrix + { assert( i < nr_left ); + assert( j < nc_right ); + return (i * nc_right + j) * nk + k; + } +/* %$$ +$head Forward Matrix Multiply$$ +Forward mode multiply Taylor coefficients in $icode tx$$ and sum into +$icode ty$$ (for one pair of left and right orders) +$srccode%cpp% */ + void forward_multiply( + 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 + size_t nr_left , // rows in left matrix + size_t n_middle , // rows in left and columns in right + size_t nc_right ) // columns in right matrix + { + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t nk = tx.size() / nx; +# ifndef NDEBUG + size_t ny = nr_left * nc_right; + assert( nk == ty.size() / ny ); +# endif + // + size_t k_result = k_left + k_right; + assert( k_result < nk ); + // + for(size_t i = 0; i < nr_left; i++) + { for(size_t j = 0; j < nc_right; j++) + { double sum = 0.0; + for(size_t ell = 0; ell < n_middle; ell++) + { size_t i_left = left( + i, ell, k_left, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k_right, nk, nr_left, n_middle, nc_right + ); + sum += tx[i_left] * tx[i_right]; + } + size_t i_result = result( + i, j, k_result, nk, nr_left, n_middle, nc_right + ); + ty[i_result] += sum; + } + } + } +/* %$$ +$head Reverse Matrix Multiply$$ +Reverse mode partials of Taylor coefficients and sum into $icode px$$ +(for one pair of left and right orders) +$srccode%cpp% */ + void reverse_multiply( + 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 + vector& px , // partials w.r.t. tx + const vector& py , // partials w.r.t. ty + size_t nr_left , // rows in left matrix + size_t n_middle , // rows in left and columns in right + size_t nc_right ) // columns in right matrix + { + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t nk = tx.size() / nx; +# ifndef NDEBUG + size_t ny = nr_left * nc_right; + assert( nk == ty.size() / ny ); +# endif + assert( tx.size() == px.size() ); + assert( ty.size() == py.size() ); + // + size_t k_result = k_left + k_right; + assert( k_result < nk ); + // + for(size_t i = 0; i < nr_left; i++) + { for(size_t j = 0; j < nc_right; j++) + { size_t i_result = result( + i, j, k_result, nk, nr_left, n_middle, nc_right + ); + for(size_t ell = 0; ell < n_middle; ell++) + { size_t i_left = left( + i, ell, k_left, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k_right, nk, nr_left, n_middle, nc_right + ); + // sum += tx[i_left] * tx[i_right]; + px[i_left] += tx[i_right] * py[i_result]; + px[i_right] += tx[i_left] * py[i_result]; + } + } + } + return; + } +/* %$$ +$head for_type$$ +Routine called by CppAD during $cref/afun(ax, ay)/atomic_three_afun/$$. +$srccode%cpp% */ + // calculate type_y + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = true; + ok &= type_x[0] == CppAD::constant_enum; + ok &= type_x[1] == CppAD::constant_enum; + ok &= type_x[2] == CppAD::constant_enum; + if( ! ok ) + return false; + // + size_t nr_left = size_t( parameter_x[0] ); + size_t n_middle = size_t( parameter_x[1] ); + size_t nc_right = size_t( parameter_x[2] ); + // + ok &= type_x.size() == 3 + (nr_left + nc_right) * n_middle; + ok &= type_y.size() == n_middle * nc_right; + if( ! ok ) + return false; + // + // commpute type_y + size_t nk = 1; // number of orders + size_t k = 0; // order + for(size_t i = 0; i < nr_left; ++i) + { for(size_t j = 0; j < nc_right; ++j) + { // compute type for result[i, j] + CppAD::ad_type_enum type_yij = CppAD::constant_enum; + for(size_t ell = 0; ell < n_middle; ++ell) + { // index for left(i, ell) + size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + // indx for right(ell, j) + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + // multiplication on left or right by the constant zero + // always results in a constant + bool zero_left = type_x[i_left] == CppAD::constant_enum; + zero_left &= parameter_x[i_left] == 0.0; + bool zero_right = type_x[i_right] == CppAD::constant_enum; + zero_right &= parameter_x[i_right] == 0.0; + if( ! (zero_left | zero_right) ) + { type_yij = std::max(type_yij, type_x[i_left] ); + type_yij = std::max(type_yij, type_x[i_right] ); + } + } + size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + type_y[i_result] = type_yij; + } + } + return true; + } +/* %$$ +$head forward$$ +Routine called by CppAD during $cref Forward$$ mode. +$srccode%cpp% */ + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t q , + size_t p , + const vector& tx , + vector& ty ) + { size_t n_order = p + 1; + size_t nr_left = size_t( tx[ 0 * n_order + 0 ] ); + size_t n_middle = size_t( tx[ 1 * n_order + 0 ] ); + size_t nc_right = size_t( tx[ 2 * n_order + 0 ] ); +# ifndef NDEBUG + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t ny = nr_left * nc_right; +# endif + assert( nx * n_order == tx.size() ); + assert( ny * n_order == ty.size() ); + size_t i, j, ell; + + // initialize result as zero + size_t k; + for(i = 0; i < nr_left; i++) + { for(j = 0; j < nc_right; j++) + { for(k = q; k <= p; k++) + { size_t i_result = result( + i, j, k, n_order, nr_left, n_middle, nc_right + ); + ty[i_result] = 0.0; + } + } + } + for(k = q; k <= p; k++) + { // sum the produces that result in order k + for(ell = 0; ell <= k; ell++) + forward_multiply( + ell, k - ell, tx, ty, nr_left, n_middle, nc_right + ); + } + + // all orders are implemented, so always return true + return true; + } +/* %$$ +$head reverse$$ +Routine called by CppAD during $cref Reverse$$ mode. +$srccode%cpp% */ + virtual bool reverse( + const vector& parameter_x , + const vector& type_x , + size_t p , + const vector& tx , + const vector& ty , + vector& px , + const vector& py ) + { size_t n_order = p + 1; + size_t nr_left = size_t( tx[ 0 * n_order + 0 ] ); + size_t n_middle = size_t( tx[ 1 * n_order + 0 ] ); + size_t nc_right = size_t( tx[ 2 * n_order + 0 ] ); +# ifndef NDEBUG + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t ny = nr_left * nc_right; +# endif + assert( nx * n_order == tx.size() ); + assert( ny * n_order == ty.size() ); + assert( px.size() == tx.size() ); + assert( py.size() == ty.size() ); + + // initialize summation + for(size_t i = 0; i < px.size(); i++) + px[i] = 0.0; + + // number of orders to differentiate + size_t k = n_order; + while(k--) + { // differentiate the produces that result in order k + for(size_t ell = 0; ell <= k; ell++) + reverse_multiply( + ell, k - ell, tx, ty, px, py, nr_left, n_middle, nc_right + ); + } + + // all orders are implented, so always return true + return true; + } +/* %$$ +$head jac_sparsity$$ +$srccode%cpp% */ + // Jacobian sparsity routine called by CppAD + virtual bool jac_sparsity( + const vector& parameter_x , + const vector& type_x , + bool dependency , + const vector& select_x , + const vector& select_y , + CppAD::sparse_rc< vector >& pattern_out ) + { + size_t n = select_x.size(); + size_t m = select_y.size(); + assert( parameter_x.size() == n ); + assert( type_x.size() == n ); + // + size_t nr_left = size_t( parameter_x[0] ); + size_t n_middle = size_t( parameter_x[1] ); + size_t nc_right = size_t( parameter_x[2] ); + size_t nk = 1; // only one order + size_t k = 0; // order zero + // + // count number of non-zeros in sparsity pattern + size_t nnz = 0; + for(size_t i = 0; i < nr_left; ++i) + { for(size_t j = 0; j < nc_right; ++j) + { size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + if( select_y[i_result] ) + { for(size_t ell = 0; ell < n_middle; ++ell) + { size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + bool zero_left = + type_x[i_left] == CppAD::constant_enum; + zero_left &= parameter_x[i_left] == 0.0; + bool zero_right = + type_x[i_right] == CppAD::constant_enum; + zero_right &= parameter_x[i_right] == 0.0; + if( ! (zero_left | zero_right ) ) + { bool var_left = + type_x[i_left] == CppAD::variable_enum; + bool var_right = + type_x[i_right] == CppAD::variable_enum; + if( select_x[i_left] & var_left ) + ++nnz; + if( select_x[i_right] & var_right ) + ++nnz; + } + } + } + } + } + // + // fill in the sparsity pattern + pattern_out.resize(m, n, nnz); + size_t idx = 0; + for(size_t i = 0; i < nr_left; ++i) + { for(size_t j = 0; j < nc_right; ++j) + { size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + if( select_y[i_result] ) + { for(size_t ell = 0; ell < n_middle; ++ell) + { size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + bool zero_left = + type_x[i_left] == CppAD::constant_enum; + zero_left &= parameter_x[i_left] == 0.0; + bool zero_right = + type_x[i_right] == CppAD::constant_enum; + zero_right &= parameter_x[i_right] == 0.0; + if( ! (zero_left | zero_right ) ) + { bool var_left = + type_x[i_left] == CppAD::variable_enum; + bool var_right = + type_x[i_right] == CppAD::variable_enum; + if( select_x[i_left] & var_left ) + pattern_out.set(idx++, i_result, i_left); + if( select_x[i_right] & var_right ) + pattern_out.set(idx++, i_result, i_right); + } + } + } + } + } + assert( idx == nnz ); + // + return true; + } +/* %$$ +$head hes_sparsity$$ +$srccode%cpp% */ + // Jacobian sparsity routine called by CppAD + virtual bool hes_sparsity( + const vector& parameter_x , + const vector& type_x , + const vector& select_x , + const vector& select_y , + CppAD::sparse_rc< vector >& pattern_out ) + { + size_t n = select_x.size(); + assert( parameter_x.size() == n ); + assert( type_x.size() == n ); + // + size_t nr_left = size_t( parameter_x[0] ); + size_t n_middle = size_t( parameter_x[1] ); + size_t nc_right = size_t( parameter_x[2] ); + size_t nk = 1; // only one order + size_t k = 0; // order zero + // + // count number of non-zeros in sparsity pattern + size_t nnz = 0; + for(size_t i = 0; i < nr_left; ++i) + { for(size_t j = 0; j < nc_right; ++j) + { size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + if( select_y[i_result] ) + { for(size_t ell = 0; ell < n_middle; ++ell) + { // i_left depends on i, ell + size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + // i_right depens on ell, j + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + bool var_left = select_x[i_left] & + (type_x[i_left] == CppAD::variable_enum); + bool var_right = select_x[i_right] & + (type_x[i_right] == CppAD::variable_enum); + if( var_left & var_right ) + nnz += 2; + } + } + } + } + // + // fill in the sparsity pattern + pattern_out.resize(n, n, nnz); + size_t idx = 0; + for(size_t i = 0; i < nr_left; ++i) + { for(size_t j = 0; j < nc_right; ++j) + { size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + if( select_y[i_result] ) + { for(size_t ell = 0; ell < n_middle; ++ell) + { size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + bool var_left = select_x[i_left] & + (type_x[i_left] == CppAD::variable_enum); + bool var_right = select_x[i_right] & + (type_x[i_right] == CppAD::variable_enum); + if( var_left & var_right ) + { // Cannot possibly set the same (i_left, i_right) + // pair twice. + assert( i_left != i_right ); + pattern_out.set(idx++, i_left, i_right); + pattern_out.set(idx++, i_right, i_left); + } + } + } + } + } + assert( idx == nnz ); + // + return true; + } +/* %$$ +$head rev_depend$$ +Routine called when a function using $code mat_mul$$ is optimized. +$srccode%cpp% */ + // calculate depend_x + virtual bool rev_depend( + const vector& parameter_x , + const vector& type_x , + vector& depend_x , + const vector& depend_y ) + { assert( parameter_x.size() == depend_x.size() ); + assert( parameter_x.size() == type_x.size() ); + bool ok = true; + // + size_t nr_left = size_t( parameter_x[0] ); + size_t n_middle = size_t( parameter_x[1] ); + size_t nc_right = size_t( parameter_x[2] ); + // + ok &= depend_x.size() == 3 + (nr_left + nc_right) * n_middle; + ok &= depend_y.size() == n_middle * nc_right; + if( ! ok ) + return false; + // + // initialize depend_x + for(size_t ell = 0; ell < 3; ++ell) + depend_x[ell] = true; // always need these parameters + for(size_t ell = 3; ell < depend_x.size(); ++ell) + depend_x[ell] = false; // initialize as false + // + // commpute depend_x + size_t nk = 1; // number of orders + size_t k = 0; // order + for(size_t i = 0; i < nr_left; ++i) + { for(size_t j = 0; j < nc_right; ++j) + { // check depend for result[i, j] + size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + if( depend_y[i_result] ) + { for(size_t ell = 0; ell < n_middle; ++ell) + { // index for left(i, ell) + size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + // indx for right(ell, j) + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + bool zero_left = + type_x[i_left] == CppAD::constant_enum; + zero_left &= parameter_x[i_left] == 0.0; + bool zero_right = + type_x[i_right] == CppAD::constant_enum; + zero_right &= parameter_x[i_right] == 0.0; + if( ! zero_right ) + depend_x[i_left] = true; + if( ! zero_left ) + depend_x[i_right] = true; + } + } + } + } + return true; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of mat_mul class +} // End empty namespace +/* %$$ +$comment end nospell$$ +$end +*/ + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/ipopt/solve_callback.hpp cppad-2019.02.00.0/include/cppad/ipopt/solve_callback.hpp --- cppad-2018.00.00.0/include/cppad/ipopt/solve_callback.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/ipopt/solve_callback.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1192 @@ +# ifndef CPPAD_IPOPT_SOLVE_CALLBACK_HPP +# define CPPAD_IPOPT_SOLVE_CALLBACK_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +namespace ipopt { +/*! +\file solve_callback.hpp +\brief Class that connects ipopt::solve to Ipopt +*/ + +/*! +Class that Ipopt uses for obtaining information about this problem. + + +\section 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 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. +*/ +template +class solve_callback : public Ipopt::TNLP +{ +private: + // ------------------------------------------------------------------ + // Types used by this class + // ------------------------------------------------------------------ + /// A Scalar value used by Ipopt + typedef Ipopt::Number Number; + /// An index value used by Ipopt + typedef Ipopt::Index Index; + /// Indexing style used in Ipopt sparsity structure + typedef Ipopt::TNLP::IndexStyleEnum IndexStyleEnum; + // ------------------------------------------------------------------ + // Values directly passed in to constuctor + // ------------------------------------------------------------------ + /// dimension of the range space for f(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) + const size_t nx_; + /// dimension of the range space for g(x) + const size_t ng_; + /// initial value for x + const Dvector& xi_; + /// lower limit for x + const Dvector& xl_; + /// upper limit for x + const Dvector& xu_; + /// lower limit for g(x) + const Dvector& gl_; + /// upper limit for g(x) + const Dvector& gu_; + /// object that evaluates f(x) and g(x) + FG_eval& fg_eval_; + /// 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. + bool sparse_forward_; + /// Should sparse methods be used to compute Jacobians and Hessians + /// 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 + // ------------------------------------------------------------------ + /// AD function object that evaluates x -> [ f(x) , g(x) ] + /// If retape is false, this object is initialzed by constructor + /// otherwise it is set by cache_new_x each time it is called. + CppAD::ADFun adfun_; + /// value of x corresponding to previous new_x + Dvector x0_; + /// value of fg corresponding to previous new_x + Dvector fg0_; + // ---------------------------------------------------------------------- + // Jacobian information + // ---------------------------------------------------------------------- + /// 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::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_; + /// Column indices for Jacobian of g(x), same order as row_jac_. + /// (Set by constructor and not changed.) + CppAD::vector col_jac_; + /// col_order_jac_ sorts row_jac_ and col_jac_ in column order. + /// (Set by constructor and not changed.) + CppAD::vector col_order_jac_; + /// Work vector used by SparseJacobian, stored here to avoid recalculation. + CppAD::sparse_jacobian_work work_jac_; + // ---------------------------------------------------------------------- + // Hessian information + // ---------------------------------------------------------------------- + /// Sparsity pattern for Hessian of Lagragian + /// \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::vectorBool pattern_hes_; + /// Row indices of Hessian lower left triangle in row order. + /// (Set by constructor and not changed.) + CppAD::vector row_hes_; + /// Column indices of Hessian left triangle in same order as row_hes_. + /// (Set by constructor and not changed.) + CppAD::vector col_hes_; + /// Work vector used by SparseJacobian, stored here to avoid recalculation. + CppAD::sparse_hessian_work work_hes_; + // ------------------------------------------------------------------ + // Private member functions + // ------------------------------------------------------------------ + /*! + Cache information for a new value of x. + + \param x + is the new value for x. + + \par x0_ + the elements of this vector are set to the new value for x. + + \par fg0_ + the elements of this vector are set to the new value for [f(x), g(x)] + + \par adfun_ + If retape is true, the operation sequence for this function + 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. + */ + void cache_new_x(const Number* x) + { size_t i; + if( retape_ ) + { // make adfun_, as well as x0_ and fg0_ correspond to this x + ADvector a_x(nx_), a_fg(nf_ + ng_); + for(i = 0; i < nx_; i++) + { x0_[i] = x[i]; + a_x[i] = x[i]; + } + CppAD::Independent(a_x); + fg_eval_(a_fg, a_x); + adfun_.Dependent(a_x, a_fg); + } + else + { // make x0_ and fg0_ correspond to this x + for(i = 0; i < nx_; i++) + x0_[i] = x[i]; + } + fg0_ = adfun_.Forward(0, x0_); + } +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). + + \param fg_eval + function object that evaluations f(x) and g(x) using fg_eval(fg, x) + + \param retape + should the operation sequence be retaped for each argument value. + + \param sparse_forward + should sparse matrix computations be used for Jacobians and Hessians + with forward mode for Jacobian. + + \param sparse_reverse + 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 ng , + const Dvector& xi , + const Dvector& xl , + const Dvector& xu , + const Dvector& gl , + const Dvector& gu , + FG_eval& fg_eval , + bool retape , + bool sparse_forward , + bool sparse_reverse , + solve_result& solution ) : + nf_ ( nf ), + nx_ ( nx ), + ng_ ( ng ), + xi_ ( xi ), + xl_ ( xl ), + xu_ ( xu ), + gl_ ( gl ), + gu_ ( gu ), + fg_eval_ ( fg_eval ), + retape_ ( retape ), + sparse_forward_ ( sparse_forward ), + sparse_reverse_ ( sparse_reverse ), + solution_ ( solution ) + { CPPAD_ASSERT_UNKNOWN( ! ( sparse_forward_ & sparse_reverse_ ) ); + + size_t i, j; + size_t nfg = nf_ + ng_; + + // initialize x0_ and fg0_ wih proper dimensions and value nan + x0_.resize(nx); + fg0_.resize(nfg); + for(i = 0; i < nx_; i++) + x0_[i] = CppAD::nan(0.0); + for(i = 0; i < nfg; i++) + fg0_[i] = CppAD::nan(0.0); + + if( ! retape_ ) + { // make adfun_ correspond to x -> [ f(x), g(x) ] + ADvector a_x(nx_), a_fg(nfg); + for(i = 0; i < nx_; i++) + a_x[i] = xi_[i]; + CppAD::Independent(a_x); + fg_eval_(a_fg, a_x); + adfun_.Dependent(a_x, a_fg); + // optimize because we will make repeated use of this tape + adfun_.optimize(); + } + if( sparse_forward_ | sparse_reverse_ ) + { CPPAD_ASSERT_UNKNOWN( ! retape ); + size_t m = nf_ + ng_; + // + // ----------------------------------------------------------- + // Jacobian + pattern_jac_.resize( m * nx_ ); + if( nx_ <= m ) + { // use forward mode to compute sparsity + + // 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]; + } + } + } + } + else + { // use reverse mode to compute sparsity + + // 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++) + { 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. + for(i = nf_; i < nfg; i++) + { 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_ * nx_); + + // 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), 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++) + { 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); + } + } + } + } + else + { // Set row and column indices in Jacoian of [f(x), g(x)] + // for Jacobian of g(x). These indices are in row major order. + for(i = nf_; i < nfg; i++) + { for(j = 0; j < nx_; j++) + { row_jac_.push_back(i); + col_jac_.push_back(j); + } + } + // Set row and column indices for lower triangle of Hessian. + // These indices are in row major order. + for(i = 0; i < nx_; i++) + { for(j = 0; j <= i; j++) + { row_hes_.push_back(i); + col_hes_.push_back(j); + } + } + } + + // Column order indirect sort of the Jacobian indices + col_order_jac_.resize( col_jac_.size() ); + index_sort( col_jac_, col_order_jac_ ); + } + // ----------------------------------------------------------------------- + /*! + 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) + + \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& nnz_jac_g , + 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); + CPPAD_ASSERT_UNKNOWN( nnz == ng_ * nx_); + // + nnz = static_cast(nnz_h_lag); + CPPAD_ASSERT_UNKNOWN( nnz == (nx_ * (nx_ + 1)) / 2 ); + } +# endif + + // 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 , + Number* x_u , + 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 + 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]; + x_u[i] = xu_[i]; + } + for(i = 0; i < ng_; i++) + { 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 , + Number* x , + bool init_z , + Number* z_L , + Number* z_U , + 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 + \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 , + Number& obj_value ) + { size_t i; + if( new_x ) + cache_new_x(x); + // + double sum = 0.0; + for(i = 0; i < nf_; i++) + sum += fg0_[i]; + obj_value = static_cast(sum); + return true; + } + // ----------------------------------------------------------------------- + /*! + 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 + \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) + 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 , + Number* grad_f ) + { size_t i; + if( new_x ) + cache_new_x(x); + // + Dvector w(nf_ + ng_), dw(nx_); + for(i = 0; i < nf_; i++) + w[i] = 1.0; + for(i = 0; i < ng_; i++) + w[nf_ + i] = 0.0; + dw = adfun_.Reverse(1, w); + for(i = 0; i < nx_; i++) + grad_f[i] = dw[i]; + return true; + } + // ----------------------------------------------------------------------- + /*! + 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 + \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 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 , + Number* g ) + { size_t i; + if( new_x ) + cache_new_x(x); + // + for(i = 0; i < ng_; i++) + g[i] = fg0_[nf_ + i]; + return true; + } + // ----------------------------------------------------------------------- + /*! + Evaluate the Jacobian of g(x). + + \param[in] n + 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 + \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[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 + 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 + k-th possibly non-zero entry in the Jacobian of g(x). + + \param values + if values is not NULL, values + is a vector with size 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 + 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, + bool new_x, + + Index m, + Index nele_jac, + Index* iRow, + Index *jCol, + + Number* values) + { size_t i, j, k, ell; + CPPAD_ASSERT_UNKNOWN(static_cast(m) == ng_ ); + CPPAD_ASSERT_UNKNOWN(static_cast(n) == nx_ ); + // + size_t nk = row_jac_.size(); + CPPAD_ASSERT_UNKNOWN( static_cast(nele_jac) == nk ); + // + if( new_x ) + cache_new_x(x); + + if( values == NULL ) + { for(k = 0; k < nk; k++) + { i = row_jac_[k]; + j = col_jac_[k]; + CPPAD_ASSERT_UNKNOWN( i >= nf_ ); + iRow[k] = static_cast(i - nf_); + jCol[k] = static_cast(j); + } + return true; + } + // + if( nk == 0 ) + return true; + // + if( sparse_forward_ ) + { Dvector jac(nk); + adfun_.SparseJacobianForward( + x0_ , pattern_jac_, row_jac_, col_jac_, jac, work_jac_ + ); + for(k = 0; k < nk; k++) + values[k] = jac[k]; + } + else if( sparse_reverse_ ) + { Dvector jac(nk); + adfun_.SparseJacobianReverse( + x0_ , pattern_jac_, row_jac_, col_jac_, jac, work_jac_ + ); + for(k = 0; k < nk; k++) + values[k] = jac[k]; + } + else if( nx_ < ng_ ) + { // use forward mode + Dvector x1(nx_), fg1(nf_ + ng_); + for(j = 0; j < nx_; j++) + x1[j] = 0.0; + // index in col_order_jac_ of next entry + ell = 0; + k = col_order_jac_[ell]; + for(j = 0; j < nx_; j++) + { // compute j-th column of Jacobian of g(x) + x1[j] = 1.0; + fg1 = adfun_.Forward(1, x1); + while( ell < nk && col_jac_[k] <= j ) + { CPPAD_ASSERT_UNKNOWN( col_jac_[k] == j ); + i = row_jac_[k]; + CPPAD_ASSERT_UNKNOWN( i >= nf_ ) + values[k] = fg1[i]; + ell++; + if( ell < nk ) + k = col_order_jac_[ell]; + } + x1[j] = 0.0; + } + } + else + { // user reverse mode + size_t nfg = nf_ + ng_; + // user reverse mode + Dvector w(nfg), dw(nx_); + for(i = 0; i < nfg; i++) + w[i] = 0.0; + // index in row_jac_ of next entry + k = 0; + for(i = nf_; i < nfg; i++) + { // compute i-th row of Jacobian of g(x) + w[i] = 1.0; + dw = adfun_.Reverse(1, w); + while( k < nk && row_jac_[k] <= i ) + { CPPAD_ASSERT_UNKNOWN( row_jac_[k] == i ); + j = col_jac_[k]; + values[k] = dw[j]; + k++; + } + w[i] = 0.0; + } + } + return true; + } + // ----------------------------------------------------------------------- + /*! + 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 ) + = + \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); + 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 + \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); + 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 + 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 + 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 + 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 + 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 , + bool new_x , + Number obj_factor , + Index m , + const Number* lambda , + bool new_lambda , + Index nele_hess , + Index* iRow , + 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 ); + // + if( new_x ) + cache_new_x(x); + // + if( values == NULL ) + { for(k = 0; k < nk; k++) + { i = row_hes_[k]; + j = col_hes_[k]; + iRow[k] = static_cast(i); + jCol[k] = static_cast(j); + } + return true; + } + // + if( nk == 0 ) + return true; + + // weigting vector for Lagragian + Dvector w(nf_ + ng_); + for(i = 0; i < nf_; i++) + w[i] = obj_factor; + for(i = 0; i < ng_; i++) + w[i + nf_] = lambda[i]; + // + if( sparse_forward_ | sparse_reverse_ ) + { Dvector hes(nk); + adfun_.SparseHessian( + x0_, w, pattern_hes_, row_hes_, col_hes_, hes, work_hes_ + ); + for(k = 0; k < nk; k++) + values[k] = hes[k]; + } + else + { Dvector hes(nx_ * nx_); + hes = adfun_.Hessian(x0_, w); + for(k = 0; k < nk; k++) + { i = row_hes_[k]; + j = col_hes_[k]; + values[k] = hes[i * nx_ + j]; + } + } + return true; + } + // ---------------------------------------------------------------------- + /*! + 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 + \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 + + \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 + + \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 + + \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 + + \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. + The results are stored here + (see documentation above). + */ + virtual void finalize_solution( + Ipopt::SolverReturn status , + Index n , + const Number* x , + const Number* z_L , + const Number* z_U , + 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 = + solve_result::maxiter_exceeded; + break; + + case Ipopt::STOP_AT_TINY_STEP: + solution_.status = + solve_result::stop_at_tiny_step; + break; + + case Ipopt::STOP_AT_ACCEPTABLE_POINT: + solution_.status = + solve_result::stop_at_acceptable_point; + break; + + case Ipopt::LOCAL_INFEASIBILITY: + solution_.status = + solve_result::local_infeasibility; + break; + + case Ipopt::USER_REQUESTED_STOP: + solution_.status = + solve_result::user_requested_stop; + break; + + case Ipopt::DIVERGING_ITERATES: + solution_.status = + solve_result::diverging_iterates; + break; + + case Ipopt::RESTORATION_FAILURE: + solution_.status = + solve_result::restoration_failure; + break; + + case Ipopt::ERROR_IN_STEP_COMPUTATION: + solution_.status = + solve_result::error_in_step_computation; + break; + + case Ipopt::INVALID_NUMBER_DETECTED: + solution_.status = + solve_result::invalid_number_detected; + break; + + case Ipopt::INTERNAL_ERROR: + solution_.status = + solve_result::internal_error; + break; + + default: + solution_.status = + solve_result::unknown; + } + + solution_.x.resize(nx_); + solution_.zl.resize(nx_); + solution_.zu.resize(nx_); + for(j = 0; j < nx_; j++) + { solution_.x[j] = x[j]; + solution_.zl[j] = z_L[j]; + solution_.zu[j] = z_U[j]; + } + solution_.g.resize(ng_); + solution_.lambda.resize(ng_); + for(i = 0; i < ng_; i++) + { solution_.g[i] = g[i]; + solution_.lambda[i] = lambda[i]; + } + solution_.obj_value = obj_value; + return; + } +}; + +} // end namespace ipopt +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/ipopt/solve.hpp cppad-2019.02.00.0/include/cppad/ipopt/solve.hpp --- cppad-2018.00.00.0/include/cppad/ipopt/solve.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/ipopt/solve.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,644 @@ +# ifndef CPPAD_IPOPT_SOLVE_HPP +# define CPPAD_IPOPT_SOLVE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin ipopt_solve$$ +$spell + Jacobian + Jacobians + retape + Bvector + bool + infeasibility + const + cpp + cppad + doesn't + ADvector + eval + fg + gl + gu + hpp + inf + ipopt + maxiter + naninf + nf + ng + nx + obj + optimizer + std + xi + xl + xu + zl + zu +$$ + +$section Use Ipopt to Solve a Nonlinear Programming Problem$$ + +$head Syntax$$ +$codei%# include +%$$ +$codei%ipopt::solve( + %options%, %xi%, %xl%, %xu%, %gl%, %gu%, %fg_eval%, %solution% +)%$$ + +$head Purpose$$ +The function $code ipopt::solve$$ solves nonlinear programming +problems of the form +$latex \[ +\begin{array}{rll} +{\rm minimize} & f (x) +\\ +{\rm subject \; to} & gl \leq g(x) \leq gu +\\ + & xl \leq x \leq xu +\end{array} +\] $$ +This is done using +$href% + http://www.coin-or.org/projects/Ipopt.xml% + Ipopt +%$$ +optimizer and CppAD for the derivative and sparsity calculations. + +$head Include File$$ +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, +if you are using $code ipopt::solve$$ you should use +$codei% + # include +%$$ +which in turn will also include $code $$. + +$head Bvector$$ +The type $icode Bvector$$ must be a $cref SimpleVector$$ class with +$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/$$ +$code double$$. + +$head options$$ +The argument $icode options$$ has prototype +$codei% + const std::string %options% +%$$ +It contains a list of options. +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. + +$subhead Retape$$ +You can set the retape flag with the following syntax: +$codei% + Retape %value% +%$$ +If the value is $code true$$, $code ipopt::solve$$ with retape the +$cref/operation sequence/glossary/Operation/Sequence/$$ for each +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. +The default value is $code false$$. + +$subhead Sparse$$ +You can set the sparse Jacobian and Hessian flag with the following syntax: +$codei% + Sparse %value% %direction% +%$$ +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 +these calculations. +The default for $icode value$$ is $code false$$. +If sparse is true, retape must be false. +$pre + +$$ +It is unclear if $cref sparse_jacobian$$ would be faster user +forward or reverse mode so you are able to choose the direction. +If +$codei% + %value% == true && %direction% == forward +%$$ +the Jacobians will be calculated using $code SparseJacobianForward$$. +If +$codei% + %value% == true && %direction% == reverse +%$$ +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 +and $icode value$$ is its setting. + +$subhead Numeric$$ +You can set any Ipopt numeric option using a line with the following syntax: +$codei% + Numeric %name% %value% +%$$ +Here $icode name$$ is any valid Ipopt numeric option +and $icode value$$ is its setting. + +$subhead Integer$$ +You can set any Ipopt integer option using a line with the following syntax: +$codei% + Integer %name% %value% +%$$ +Here $icode name$$ is any valid Ipopt integer option +and $icode value$$ is its setting. + +$head xi$$ +The argument $icode xi$$ has prototype +$codei% + const %Vector%& %xi% +%$$ +and its size is equal to $icode nx$$. +It specifies the initial point where Ipopt starts the optimization process. + +$head xl$$ +The argument $icode xl$$ has prototype +$codei% + const %Vector%& %xl% +%$$ +and its size is equal to $icode nx$$. +It specifies the lower limits for the argument in the optimization problem. + +$head xu$$ +The argument $icode xu$$ has prototype +$codei% + const %Vector%& %xu% +%$$ +and its size is equal to $icode nx$$. +It specifies the upper limits for the argument in the optimization problem. + +$head gl$$ +The argument $icode gl$$ has prototype +$codei% + const %Vector%& %gl% +%$$ +and its size is equal to $icode ng$$. +It specifies the lower limits for the constraints in the optimization problem. + +$head gu$$ +The argument $icode gu$$ has prototype +$codei% + const %Vector%& %gu% +%$$ +and its size is equal to $icode ng$$. +It specifies the upper limits for the constraints in the optimization problem. + +$head fg_eval$$ +The argument $icode fg_eval$$ has prototype +$codei% + %FG_eval% %fg_eval% +%$$ +where the class $icode FG_eval$$ is unspecified except for the fact that +it supports the syntax +$codei% + %FG_eval%::ADvector + %fg_eval%(%fg%, %x%) +%$$ +The type $icode ADvector$$ +and the arguments to $icode fg$$, $icode x$$ have the following meaning: + +$subhead ADvector$$ +The type $icode%FG_eval%::ADvector%$$ must be a $cref SimpleVector$$ class with +$cref/elements of type/SimpleVector/Elements of Specified Type/$$ +$code AD$$. + +$subhead x$$ +The $icode fg_eval$$ argument $icode x$$ has prototype +$codei% + const %ADvector%& %x% +%$$ +where $icode%nx% = %x%.size()%$$. + +$subhead fg$$ +The $icode fg_eval$$ argument $icode fg$$ has prototype +$codei% + %ADvector%& %fg% +%$$ +where $codei%1 + %ng% = %fg%.size()%$$. +The input value of the elements of $icode fg$$ does not matter. +Upon return from $icode fg_eval$$, +$codei% + %fg%[0] =%$$ $latex f (x)$$ $codei% +%$$ +and for $latex i = 0, \ldots , ng-1$$, +$codei% + %fg%[1 + %i%] =%$$ $latex g_i (x)$$ + +$head solution$$ +The argument $icode solution$$ has prototype +$codei% + ipopt::solve_result<%Dvector%>& %solution% +%$$ +After the optimization process is completed, $icode solution$$ contains +the following information: + +$subhead status$$ +The $icode status$$ field of $icode solution$$ has prototype +$codei% + ipopt::solve_result<%Dvector%>::status_type %solution%.status +%$$ +It is the final Ipopt status for the optimizer. +Here is a list of the possible values for the status: + +$table +$icode status$$ $cnext Meaning +$rnext +not_defined $cnext +The optimizer did not return a final status for this problem. +$rnext +unknown $cnext +The status returned by the optimizer is not defined in the Ipopt +documentation for $code finalize_solution$$. +$rnext +success $cnext +Algorithm terminated successfully at a point satisfying the convergence +tolerances (see Ipopt options). +$rnext +maxiter_exceeded $cnext +The maximum number of iterations was exceeded (see Ipopt options). +$rnext +stop_at_tiny_step $cnext +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 +(see Ipopt options). +$rnext +local_infeasibility $cnext +Algorithm converged to a non-feasible point +(problem may have no solution). +$rnext +user_requested_stop $cnext +This return value should not happen. +$rnext +diverging_iterates $cnext +It the iterates are diverging. +$rnext +restoration_failure $cnext +Restoration phase failed, algorithm doesn't know how to proceed. +$rnext +error_in_step_computation $cnext +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$$) +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$$). +$rnext +internal_error $cnext +An unknown Ipopt internal error occurred. +Contact the Ipopt authors through the mailing list. +$tend + +$subhead x$$ +The $code x$$ field of $icode solution$$ has prototype +$codei% + %Vector% %solution%.x +%$$ +and its size is equal to $icode nx$$. +It is the final $latex x$$ value for the optimizer. + +$subhead zl$$ +The $code zl$$ field of $icode solution$$ has prototype +$codei% + %Vector% %solution%.zl +%$$ +and its size is equal to $icode nx$$. +It is the final Lagrange multipliers for the +lower bounds on $latex x$$. + +$subhead zu$$ +The $code zu$$ field of $icode solution$$ has prototype +$codei% + %Vector% %solution%.zu +%$$ +and its size is equal to $icode nx$$. +It is the final Lagrange multipliers for the +upper bounds on $latex x$$. + +$subhead g$$ +The $code g$$ field of $icode solution$$ has prototype +$codei% + %Vector% %solution%.g +%$$ +and its size is equal to $icode ng$$. +It is the final value for the constraint function $latex g(x)$$. + +$subhead lambda$$ +The $code lambda$$ field of $icode solution$$ has prototype +$codei% + %Vector%> %solution%.lambda +%$$ +and its size is equal to $icode ng$$. +It is the final value for the +Lagrange multipliers corresponding to the constraint function. + +$subhead obj_value$$ +The $code obj_value$$ field of $icode solution$$ has prototype +$codei% + double %solution%.obj_value +%$$ +It is the final value of the objective function $latex f(x)$$. + +$children% + example/ipopt_solve/get_started.cpp% + example/ipopt_solve/retape.cpp% + example/ipopt_solve/ode_inverse.cpp +%$$ +$head Example$$ +All the examples return true if it succeeds and false otherwise. + +$subhead get_started$$ +The file +$cref%example/ipopt_solve/get_started.cpp%ipopt_solve_get_started.cpp%$$ +is an example and test of $code ipopt::solve$$ +taken from the Ipopt manual. + +$subhead retape$$ +The file +$cref%example/ipopt_solve/retape.cpp%ipopt_solve_retape.cpp%$$ +demonstrates when it is necessary to specify +$cref/retape/ipopt_solve/options/Retape/$$ as true. + +$subhead ode_inverse$$ +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 +------------------------------------------------------------------------------- +*/ +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +namespace ipopt { +/*! +\file solve.hpp +\brief Implement the ipopt::solve Nonlinear Programming Solver +*/ + +/*! +Use Ipopt to Solve a Nonlinear Programming Problem + +\tparam Bvector +simple vector class with elements of type bool. + +\tparam Dvector +simple vector class with elements of type double. + +\tparam FG_eval +function object used to evaluate f(x) and g(x); see fg_eval below. +It must also support +\code + FG_eval::ADvector +\endcode +to dentify the type used for the arguments to fg_eval. + +\param options +list of options, one for each line. +Ipopt options (are optional) and have one of the following forms +\code + String name value + Numeric name value + Integer name value +\endcode +The following other possible options are listed below: +\code + Retape value +\endcode + + +\param xi +initial argument value to start optimization procedure at. + +\param xl +lower limit for argument during optimization + +\param xu +upper limit for argument during optimization + +\param gl +lower limit for g(x) during optimization. + +\param gu +upper limit for g(x) during optimization. + +\param fg_eval +function that evaluates the objective and constraints using the syntax +\code + fg_eval(fg, x) +\endcode + +\param solution +structure that holds the solution of the optimization. +*/ +template +void solve( + const std::string& options , + const Dvector& xi , + const Dvector& xl , + const Dvector& xu , + const Dvector& gl , + const Dvector& gu , + FG_eval& fg_eval , + ipopt::solve_result& solution ) +{ bool ok = true; + + typedef typename FG_eval::ADvector ADvector; + + CPPAD_ASSERT_KNOWN( + xi.size() == xl.size() && xi.size() == xu.size() , + "ipopt::solve: size of xi, xl, and xu are not all equal." + ); + CPPAD_ASSERT_KNOWN( + gl.size() == gu.size() , + "ipopt::solve: size of gl and gu are not equal." + ); + size_t nx = xi.size(); + size_t ng = gl.size(); + + // Create an IpoptApplication + using Ipopt::IpoptApplication; + Ipopt::SmartPtr app = new IpoptApplication(); + + // process the options argument + size_t begin_1, end_1, begin_2, end_2, begin_3, end_3; + begin_1 = 0; + bool retape = false; + bool sparse_forward = false; + bool sparse_reverse = false; + while( begin_1 < options.size() ) + { // split this line into tokens + while( options[begin_1] == ' ') + begin_1++; + end_1 = options.find_first_of(" \n", begin_1); + begin_2 = end_1; + while( options[begin_2] == ' ') + begin_2++; + end_2 = options.find_first_of(" \n", begin_2); + begin_3 = end_2; + while( options[begin_3] == ' ') + begin_3++; + 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) & + (end_3 != std::string::npos) , + "ipopt::solve: missing '\\n' at end of an option line" + ); + CPPAD_ASSERT_KNOWN( + (end_1 > begin_1) & (end_2 > begin_2) , + "ipopt::solve: an option line does not have two tokens" + ); + + // get first two tokens + std::string tok_1 = options.substr(begin_1, end_1 - begin_1); + std::string tok_2 = options.substr(begin_2, end_2 - begin_2); + + // get third token + std::string tok_3; + bool three_tok = false; + three_tok |= tok_1 == "Sparse"; + three_tok |= tok_1 == "String"; + three_tok |= tok_1 == "Numeric"; + three_tok |= tok_1 == "Integer"; + 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." + ); + tok_3 = options.substr(begin_3, end_3 - begin_3); + } + + // switch on option type + if( tok_1 == "Retape" ) + { CPPAD_ASSERT_KNOWN( + (tok_2 == "true") | (tok_2 == "false") , + "ipopt::solve: Retape value is not true or false" + ); + retape = (tok_2 == "true"); + } + else if( tok_1 == "Sparse" ) + { CPPAD_ASSERT_KNOWN( + (tok_2 == "true") | (tok_2 == "false") , + "ipopt::solve: Sparse value is not true or false" + ); + CPPAD_ASSERT_KNOWN( + (tok_3 == "forward") | (tok_3 == "reverse") , + "ipopt::solve: Sparse direction is not forward or reverse" + ); + if( tok_2 == "false" ) + { sparse_forward = false; + sparse_reverse = false; + } + else + { sparse_forward = tok_3 == "forward"; + sparse_reverse = tok_3 == "reverse"; + } + } + 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() ); + app->Options()->SetNumericValue(tok_2.c_str(), value); + } + else if ( tok_1 == "Integer" ) + { Ipopt::Index value = std::atoi( tok_3.c_str() ); + app->Options()->SetIntegerValue(tok_2.c_str(), value); + } + else + CPPAD_ASSERT_KNOWN( + false, + "ipopt::solve: First token is not one of\n" + "Retape, Sparse, String, Numeric, Integer" + ); + + begin_1 = end_3; + while( options[begin_1] == ' ') + begin_1++; + if( options[begin_1] != '\n' ) CPPAD_ASSERT_KNOWN( + false, + "ipopt::solve: either more than three tokens " + "or no '\\n' at end of a line" + ); + begin_1++; + } + CPPAD_ASSERT_KNOWN( + ! ( retape & (sparse_forward | sparse_reverse) ) , + "ipopt::solve: retape and sparse both true is not supported." + ); + + // Initialize the IpoptApplication and process the options + Ipopt::ApplicationReturnStatus status = app->Initialize(); + ok &= status == Ipopt::Solve_Succeeded; + if( ! ok ) + { 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 = + new CppAD::ipopt::solve_callback( + nf, + nx, + ng, + xi, + xl, + xu, + gl, + gu, + fg_eval, + retape, + sparse_forward, + sparse_reverse, + solution + ); + + // Run the IpoptApplication + app->OptimizeTNLP(cppad_nlp); + + return; +} + +} // end ipopt namespace +} // END_CPPAD_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/ipopt/solve_result.hpp cppad-2019.02.00.0/include/cppad/ipopt/solve_result.hpp --- cppad-2018.00.00.0/include/cppad/ipopt/solve_result.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/ipopt/solve_result.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,73 @@ +# ifndef CPPAD_IPOPT_SOLVE_RESULT_HPP +# define CPPAD_IPOPT_SOLVE_RESULT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE +namespace ipopt { +/*! +\file solve_result.hpp +Class that contains information about solve problem result +*/ + +/*! +Class that contains information about solve problem result + +\tparam Dvector +a simple vector with elements of type double +*/ +template +class solve_result +{ +public: + /// possible values for the result status + enum status_type { + not_defined, + success, + maxiter_exceeded, + stop_at_tiny_step, + stop_at_acceptable_point, + local_infeasibility, + user_requested_stop, + feasible_point_found, + diverging_iterates, + restoration_failure, + error_in_step_computation, + invalid_number_detected, + too_few_degrees_of_freedom, + internal_error, + unknown + }; + + /// possible values for solution status + status_type status; + /// the approximation solution + Dvector x; + /// Lagrange multipliers corresponding to lower bounds on x + Dvector zl; + /// Lagrange multipliers corresponding to upper bounds on x + Dvector zu; + /// value of g(x) + Dvector g; + /// Lagrange multipliers correspondiing constraints on g(x) + Dvector lambda; + /// value of f(x) + double obj_value; + /// constructor initializes solution status as not yet defined + solve_result(void) + { status = not_defined; } +}; + +} // end namespace ipopt +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/abs_op.hpp cppad-2019.02.00.0/include/cppad/local/abs_op.hpp --- cppad-2018.00.00.0/include/cppad/local/abs_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/abs_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,160 @@ +# ifndef CPPAD_LOCAL_ABS_OP_HPP +# define CPPAD_LOCAL_ABS_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file abs_op.hpp +Forward and reverse mode calculations for z = fabs(x). +*/ + +/*! +Compute forward mode Taylor coefficient for result of op = AbsOp. + +The C++ source code corresponding to this operation is +\verbatim + z = fabs(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op +*/ +template +void forward_abs_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(AbsOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AbsOp) == 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; + + for(size_t j = p; j <= q; j++) + z[j] = sign(x[0]) * x[j]; +} + +/*! +Multiple directions forward mode Taylor coefficient for op = AbsOp. + +The C++ source code corresponding to this operation is +\verbatim + z = fabs(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op_dir +*/ +template +void forward_abs_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(AbsOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AbsOp) == 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] = sign(x[0]) * x[m + ell]; +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = AbsOp. + +The C++ source code corresponding to this operation is +\verbatim + z = fabs(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op_0 +*/ +template +void forward_abs_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AbsOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AbsOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + + // Taylor coefficients corresponding to argument and result + Base x0 = *(taylor + i_x * cap_order); + Base* z = taylor + i_z * cap_order; + + z[0] = fabs(x0); +} +/*! +Compute reverse mode partial derivatives for result of op = AbsOp. + +The C++ source code corresponding to this operation is +\verbatim + z = fabs(x) +\endverbatim + +\copydetails CppAD::local::reverse_unary1_op +*/ + +template +void reverse_abs_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; + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AbsOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AbsOp) == 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 + Base* pz = partial + i_z * nc_partial; + + // do not need azmul because sign is either +1, -1, or zero + for(j = 0; j <= d; j++) + px[j] += sign(x[0]) * pz[j]; +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/acosh_op.hpp cppad-2019.02.00.0/include/cppad/local/acosh_op.hpp --- cppad-2018.00.00.0/include/cppad/local/acosh_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/acosh_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,266 @@ +# ifndef CPPAD_LOCAL_ACOSH_OP_HPP +# define CPPAD_LOCAL_ACOSH_OP_HPP +# if CPPAD_USE_CPLUSPLUS_2011 + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_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 CppAD::local::forward_unary2_op +*/ +template +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.0); + b[0] = sqrt( uj ); + p++; + } + for(size_t j = p; j <= q; j++) + { uj = Base(0.0); + for(k = 0; k <= j; k++) + uj += x[k] * x[j-k]; + b[j] = Base(0.0); + z[j] = Base(0.0); + for(k = 1; k < j; k++) + { b[j] -= Base(double(k)) * b[k] * b[j-k]; + z[j] -= Base(double(k)) * z[k] * b[j-k]; + } + b[j] /= Base(double(j)); + z[j] /= Base(double(j)); + // + b[j] += uj / Base(2.0); + 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 CppAD::local::forward_unary2_op_dir +*/ +template +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.0); + z[m+ell] = Base(0.0); + for(k = 1; k < q; k++) + { b[m+ell] += Base(double(k)) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + z[m+ell] += Base(double(k)) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + } + b[m+ell] = ( uq / Base(2.0) - b[m+ell] / Base(double(q)) ) / b[0]; + z[m+ell] = ( x[m+ell] - z[m+ell] / Base(double(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 CppAD::local::forward_unary2_op_0 +*/ +template +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.0) ); +} +/*! +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 CppAD::local::reverse_unary2_op +*/ + +template +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.0) / 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(double(j)); + + for(k = 1; k < j; k++) + { // update partials w.r.t b^(j-k) + pb[j-k] -= Base(double(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(double(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_LOCAL_NAMESPACE +# endif +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/acos_op.hpp cppad-2019.02.00.0/include/cppad/local/acos_op.hpp --- cppad-2018.00.00.0/include/cppad/local/acos_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/acos_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,263 @@ +# ifndef CPPAD_LOCAL_ACOS_OP_HPP +# define CPPAD_LOCAL_ACOS_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file acos_op.hpp +Forward and reverse mode calculations for z = acos(x). +*/ + + +/*! +Compute forward mode Taylor coefficient for result of op = AcosOp. + +The C++ source code corresponding to this operation is +\verbatim + z = acos(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 CppAD::local::forward_unary2_op +*/ +template +void forward_acos_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(AcosOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AcosOp) == 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] = acos( x[0] ); + uj = Base(1.0) - x[0] * x[0]; + b[0] = sqrt( uj ); + p++; + } + for(size_t j = p; j <= q; j++) + { uj = Base(0.0); + for(k = 0; k <= j; k++) + uj -= x[k] * x[j-k]; + b[j] = Base(0.0); + z[j] = Base(0.0); + for(k = 1; k < j; k++) + { b[j] -= Base(double(k)) * b[k] * b[j-k]; + z[j] -= Base(double(k)) * z[k] * b[j-k]; + } + b[j] /= Base(double(j)); + z[j] /= Base(double(j)); + // + b[j] += uj / Base(2.0); + z[j] -= x[j]; + // + b[j] /= b[0]; + z[j] /= b[0]; + } +} +/*! +Multiple directions forward mode Taylor coefficient for op = AcosOp. + +The C++ source code corresponding to this operation is +\verbatim + z = acos(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 CppAD::local::forward_unary2_op_dir +*/ +template +void forward_acos_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.0); + z[m+ell] = Base(0.0); + for(k = 1; k < q; k++) + { b[m+ell] += Base(double(k)) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + z[m+ell] += Base(double(k)) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + } + b[m+ell] = ( uq / Base(2.0) - b[m+ell] / Base(double(q)) ) / b[0]; + z[m+ell] = -( x[m+ell] + z[m+ell] / Base(double(q)) ) / b[0]; + } +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = AcosOp. + +The C++ source code corresponding to this operation is +\verbatim + z = acos(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 CppAD::local::forward_unary2_op_0 +*/ +template +void forward_acos_op_0( + 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 < 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] = acos( x[0] ); + b[0] = sqrt( Base(1.0) - x[0] * x[0] ); +} +/*! +Compute reverse mode partial derivatives for result of op = AcosOp. + +The C++ source code corresponding to this operation is +\verbatim + z = acos(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 CppAD::local::reverse_unary2_op +*/ + +template +void reverse_acos_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(AcosOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AcosOp) == 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.0) / 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(double(j)); + + for(k = 1; k < j; k++) + { // update partials w.r.t b^(j-k) + pb[j-k] -= Base(double(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(double(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_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/add_op.hpp cppad-2019.02.00.0/include/cppad/local/add_op.hpp --- cppad-2018.00.00.0/include/cppad/local/add_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/add_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,338 @@ +# ifndef CPPAD_LOCAL_ADD_OP_HPP +# define CPPAD_LOCAL_ADD_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file add_op.hpp +Forward and reverse mode calculations for z = x + y. +*/ + +// --------------------------- Addvv ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = AddvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x + y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_binary_op +*/ + +template +void forward_addvv_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(AddvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AddvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + for(size_t j = p; j <= q; j++) + z[j] = x[j] + y[j]; +} +/*! +Multiple directions forward mode Taylor coefficients for op = AddvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x + y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_binary_op_dir +*/ + +template +void forward_addvv_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(AddvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AddvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + + // Taylor coefficients corresponding to arguments and result + size_t num_taylor_per_var = (cap_order-1) * r + 1; + Base* x = taylor + size_t(arg[0]) * num_taylor_per_var; + Base* y = taylor + size_t(arg[1]) * 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] = x[m+ell] + y[m+ell]; +} + +/*! +Compute zero order forward mode Taylor coefficients for result of op = AddvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x + y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_binary_op_0 +*/ + +template +void forward_addvv_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(AddvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AddvvOp) == 1 ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = x[0] + y[0]; +} + +/*! +Compute reverse mode partial derivatives for result of op = AddvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x + y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::reverse_binary_op +*/ + +template +void reverse_addvv_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(AddvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AddvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Partial derivatives corresponding to arguments and result + Base* px = partial + size_t(arg[0]) * nc_partial; + Base* py = partial + size_t(arg[1]) * nc_partial; + Base* pz = partial + i_z * nc_partial; + + // number of indices to access + size_t i = d + 1; + while(i) + { --i; + px[i] += pz[i]; + py[i] += pz[i]; + } +} + +// --------------------------- Addpv ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = AddpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x + y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_binary_op +*/ +template +void forward_addpv_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(AddpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AddpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + if( p == 0 ) + { // Paraemter value + Base x = parameter[ arg[0] ]; + z[0] = x + y[0]; + p++; + } + for(size_t j = p; j <= q; j++) + z[j] = y[j]; +} +/*! +Multiple directions forward mode Taylor coefficients for op = AddpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x + y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_binary_op_dir +*/ +template +void forward_addpv_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(AddpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AddpvOp) == 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 + size_t(arg[1]) * num_taylor_per_var + m; + Base* z = taylor + i_z * num_taylor_per_var + m; + + for(size_t ell = 0; ell < r; ell++) + z[ell] = y[ell]; +} +/*! +Compute zero order forward mode Taylor coefficient for result of op = AddpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x + y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_binary_op_0 +*/ + +template +void forward_addpv_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(AddpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AddpvOp) == 1 ); + + // Paraemter value + Base x = parameter[ arg[0] ]; + + // Taylor coefficients corresponding to arguments and result + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = x + y[0]; +} + +/*! +Compute reverse mode partial derivative for result of op = AddpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x + y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::reverse_binary_op +*/ + +template +void reverse_addpv_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(AddvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AddvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Partial derivatives corresponding to arguments and result + Base* py = partial + size_t(arg[1]) * nc_partial; + Base* pz = partial + i_z * nc_partial; + + // number of indices to access + size_t i = d + 1; + while(i) + { --i; + py[i] += pz[i]; + } +} + + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/ad_tape.hpp cppad-2019.02.00.0/include/cppad/local/ad_tape.hpp --- cppad-2018.00.00.0/include/cppad/local/ad_tape.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/ad_tape.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,222 @@ +# ifndef CPPAD_LOCAL_AD_TAPE_HPP +# define CPPAD_LOCAL_AD_TAPE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL__NAMESPACE + +/*! +Class used to hold tape that records AD operations. + +\tparam Base +An AD object is used to recording AD operations. +*/ + +template +class ADTape { + // Friends ============================================================= + + // classes ------------------------------------------------------------- + friend class AD; + friend class ADFun; + friend class atomic_base; + friend class atomic_three; + friend class discrete; + friend class VecAD; + friend class VecAD_reference; + + // functions ----------------------------------------------------------- + // PrintFor + friend void CppAD::PrintFor ( + const AD& flag , + const char* before , + const AD& var , + const char* after + ); + // CondExpOp + friend AD CppAD::CondExpOp ( + enum CompareOp cop , + const AD &left , + const AD &right , + const AD &trueCase , + const AD &falseCase + ); + // pow + friend AD CppAD::pow + (const AD &x, const AD &y); + // azmul + friend AD CppAD::azmul + (const AD &x, const AD &y); + // Parameter + friend bool CppAD::Parameter + (const AD &u); + // Variable + friend bool CppAD::Variable + (const AD &u); + // operators ----------------------------------------------------------- + // arithematic binary operators + friend AD CppAD::operator + + (const AD &left, const AD &right); + friend AD CppAD::operator - + (const AD &left, const AD &right); + friend AD CppAD::operator * + (const AD &left, const AD &right); + friend AD CppAD::operator / + (const AD &left, const AD &right); + + // comparison operators + friend bool CppAD::operator < + (const AD &left, const AD &right); + friend bool CppAD::operator <= + (const AD &left, const AD &right); + friend bool CppAD::operator > + (const AD &left, const AD &right); + friend bool CppAD::operator >= + (const AD &left, const AD &right); + friend bool CppAD::operator == + (const AD &left, const AD &right); + friend bool CppAD::operator != + (const AD &left, const AD &right); + // ====================================================================== + +// -------------------------------------------------------------------------- +private: + // ---------------------------------------------------------------------- + // 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 + number for this tape. Set by Independent and effectively const + */ + tape_id_t id_; + /// Number of independent variables in this tapes reconding. + /// Set by Independent and effectively const + size_t size_independent_; + /// This is where the information is recorded. + local::recorder Rec_; + // ---------------------------------------------------------------------- + // private functions + // + // add a parameter to the tape + addr_t RecordParOp(const AD& y); + + // see CondExp.h + void RecordCondExp( + enum CompareOp cop , + AD &returnValue , + const AD &left , + const AD &right , + const AD &trueCase , + const AD &falseCase + ); + + // place a VecAD object in the tape + size_t AddVec( + size_t length, + const pod_vector_maybe& data + ); + +public: + // public function only used by CppAD::Independent + template + void Independent( + ADBaseVector& x , + size_t abort_op_index , + bool record_compare , + ADBaseVector& dynamic + ); + +}; +// --------------------------------------------------------------------------- +// Private functions +// + +/*! +Place a parameter in the tape as a variable. + +On rare occations it is necessary to place a parameter in the tape; e.g., +when it is one of the dependent variabes. + +\param y +value of the parameter that we are placing in the tape as a variable. + +\return +variable index (for this recording) correpsonding to the parameter. + +\par 2DO +All these operates are preformed in Rec_, so we should +move this routine from ADTape to recorder. +*/ +template +addr_t ADTape::RecordParOp(const AD& y) +{ CPPAD_ASSERT_UNKNOWN( NumRes(ParOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumArg(ParOp) == 1 ); + addr_t z_taddr = Rec_.PutOp(ParOp); + if( Dynamic(y) ) + { addr_t ind = y.taddr_; + Rec_.PutArg(ind); + } + else + { addr_t ind = Rec_.put_con_par(y.value_); + Rec_.PutArg(ind); + } + return z_taddr; +} + +/*! +Put initialization for a VecAD object in the tape. + +This routine should be called once for each VecAD object when just +before it changes from a parameter to a variable. + +\param length +size of the VecAD object. + +\param data +initial values for the VecAD object +(values before it becomes a variable). + +\return +index of the start of this vector in the list of vector indices. +The value for this vector index is the length of the vector. +There are 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. + +\par 2DO +All these operates are preformed in Rec_, so we should +move this routine from ADTape to recorder. +*/ +template +size_t ADTape::AddVec(size_t length, const pod_vector_maybe& data) +{ CPPAD_ASSERT_UNKNOWN( length > 0 ); + + // store the length in VecInd + addr_t start = Rec_.PutVecInd( addr_t(length) ); + + // store indices of the values in VecInd + for(size_t i = 0; i < length; i++) + { + addr_t value_index = Rec_.put_con_par( data[i] ); + Rec_.PutVecInd( value_index ); + } + + // return the taddr of the length (where the vector starts) + return size_t(start); +} + +} } // END_CPPAD_LOCAL_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/asinh_op.hpp cppad-2019.02.00.0/include/cppad/local/asinh_op.hpp --- cppad-2018.00.00.0/include/cppad/local/asinh_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/asinh_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,266 @@ +# ifndef CPPAD_LOCAL_ASINH_OP_HPP +# define CPPAD_LOCAL_ASINH_OP_HPP +# if CPPAD_USE_CPLUSPLUS_2011 + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_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 CppAD::local::forward_unary2_op +*/ +template +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.0) + x[0] * x[0]; + b[0] = sqrt( uj ); + p++; + } + for(size_t j = p; j <= q; j++) + { uj = Base(0.0); + for(k = 0; k <= j; k++) + uj += x[k] * x[j-k]; + b[j] = Base(0.0); + z[j] = Base(0.0); + for(k = 1; k < j; k++) + { b[j] -= Base(double(k)) * b[k] * b[j-k]; + z[j] -= Base(double(k)) * z[k] * b[j-k]; + } + b[j] /= Base(double(j)); + z[j] /= Base(double(j)); + // + b[j] += uj / Base(2.0); + 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 CppAD::local::forward_unary2_op_dir +*/ +template +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.0); + z[m+ell] = Base(0.0); + for(k = 1; k < q; k++) + { b[m+ell] += Base(double(k)) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + z[m+ell] += Base(double(k)) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + } + b[m+ell] = ( uq / Base(2.0) - b[m+ell] / Base(double(q)) ) / b[0]; + z[m+ell] = ( x[m+ell] - z[m+ell] / Base(double(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 CppAD::local::forward_unary2_op_0 +*/ +template +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.0) + 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 CppAD::local::reverse_unary2_op +*/ + +template +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.0) / 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(double(j)); + + for(k = 1; k < j; k++) + { // update partials w.r.t b^(j-k) + pb[j-k] -= Base(double(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(double(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_LOCAL_NAMESPACE +# endif +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/asin_op.hpp cppad-2019.02.00.0/include/cppad/local/asin_op.hpp --- cppad-2018.00.00.0/include/cppad/local/asin_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/asin_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,263 @@ +# ifndef CPPAD_LOCAL_ASIN_OP_HPP +# define CPPAD_LOCAL_ASIN_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file asin_op.hpp +Forward and reverse mode calculations for z = asin(x). +*/ + + +/*! +Compute forward mode Taylor coefficient for result of op = AsinOp. + +The C++ source code corresponding to this operation is +\verbatim + z = asin(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 CppAD::local::forward_unary2_op +*/ +template +void forward_asin_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(AsinOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AsinOp) == 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] = asin( x[0] ); + uj = Base(1.0) - x[0] * x[0]; + b[0] = sqrt( uj ); + p++; + } + for(size_t j = p; j <= q; j++) + { uj = Base(0.0); + for(k = 0; k <= j; k++) + uj -= x[k] * x[j-k]; + b[j] = Base(0.0); + z[j] = Base(0.0); + for(k = 1; k < j; k++) + { b[j] -= Base(double(k)) * b[k] * b[j-k]; + z[j] -= Base(double(k)) * z[k] * b[j-k]; + } + b[j] /= Base(double(j)); + z[j] /= Base(double(j)); + // + b[j] += uj / Base(2.0); + z[j] += x[j]; + // + b[j] /= b[0]; + z[j] /= b[0]; + } +} +/*! +Multiple directions forward mode Taylor coefficient for op = AsinOp. + +The C++ source code corresponding to this operation is +\verbatim + z = asin(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 CppAD::local::forward_unary2_op_dir +*/ +template +void forward_asin_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.0); + z[m+ell] = Base(0.0); + for(k = 1; k < q; k++) + { b[m+ell] += Base(double(k)) * b[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + z[m+ell] += Base(double(k)) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + } + b[m+ell] = ( uq / Base(2.0) - b[m+ell] / Base(double(q)) ) / b[0]; + z[m+ell] = ( x[m+ell] - z[m+ell] / Base(double(q)) ) / b[0]; + } +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = AsinOp. + +The C++ source code corresponding to this operation is +\verbatim + z = asin(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 CppAD::local::forward_unary2_op_0 +*/ +template +void forward_asin_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AsinOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AsinOp) == 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] = asin( x[0] ); + b[0] = sqrt( Base(1.0) - x[0] * x[0] ); +} +/*! +Compute reverse mode partial derivatives for result of op = AsinOp. + +The C++ source code corresponding to this operation is +\verbatim + z = asin(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 CppAD::local::reverse_unary2_op +*/ + +template +void reverse_asin_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(AsinOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AsinOp) == 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.0) / 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(double(j)); + + for(k = 1; k < j; k++) + { // update partials w.r.t b^(j-k) + pb[j-k] -= Base(double(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(double(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_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/atanh_op.hpp cppad-2019.02.00.0/include/cppad/local/atanh_op.hpp --- cppad-2018.00.00.0/include/cppad/local/atanh_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/atanh_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,238 @@ +# ifndef CPPAD_LOCAL_ATANH_OP_HPP +# define CPPAD_LOCAL_ATANH_OP_HPP +# if CPPAD_USE_CPLUSPLUS_2011 + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_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 CppAD::local::forward_unary2_op +*/ +template +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.0) - x[0] * x[0]; + p++; + } + for(size_t j = p; j <= q; j++) + { + b[j] = - Base(2.0) * x[0] * x[j]; + z[j] = Base(0.0); + for(k = 1; k < j; k++) + { b[j] -= x[k] * x[j-k]; + z[j] -= Base(double(k)) * z[k] * b[j-k]; + } + z[j] /= Base(double(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 CppAD::local::forward_unary2_op_dir +*/ +template +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.0) * x[m+ell] * x[0]; + z[m+ell] = Base(double(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(double(k)) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + } + z[m+ell] /= ( Base(double(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 CppAD::local::forward_unary2_op_0 +*/ +template +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.0) - 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 CppAD::local::reverse_unary2_op +*/ + +template +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.0) / 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.0); + + 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(double(j)); + + for(k = 1; k < j; k++) + { pb[j-k] -= Base(double(k)) * azmul(pz[j], z[k]); + pz[k] -= Base(double(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.0) * azmul(pb[0], x[0]); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/atan_op.hpp cppad-2019.02.00.0/include/cppad/local/atan_op.hpp --- cppad-2018.00.00.0/include/cppad/local/atan_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/atan_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,235 @@ +# ifndef CPPAD_LOCAL_ATAN_OP_HPP +# define CPPAD_LOCAL_ATAN_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file atan_op.hpp +Forward and reverse mode calculations for z = atan(x). +*/ + + +/*! +Forward mode Taylor coefficient for result of op = AtanOp. + +The C++ source code corresponding to this operation is +\verbatim + z = atan(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 CppAD::local::forward_unary2_op +*/ +template +void forward_atan_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(AtanOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AtanOp) == 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] = atan( x[0] ); + b[0] = Base(1.0) + x[0] * x[0]; + p++; + } + for(size_t j = p; j <= q; j++) + { + b[j] = Base(2.0) * x[0] * x[j]; + z[j] = Base(0.0); + for(k = 1; k < j; k++) + { b[j] += x[k] * x[j-k]; + z[j] -= Base(double(k)) * z[k] * b[j-k]; + } + z[j] /= Base(double(j)); + z[j] += x[j]; + z[j] /= b[0]; + } +} + +/*! +Multiple direction Taylor coefficient for op = AtanOp. + +The C++ source code corresponding to this operation is +\verbatim + z = atan(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 CppAD::local::forward_unary2_op_dir +*/ +template +void forward_atan_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(AtanOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AtanOp) == 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.0) * x[m+ell] * x[0]; + z[m+ell] = Base(double(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(double(k)) * z[(k-1)*r+1+ell] * b[(q-k-1)*r+1+ell]; + } + z[m+ell] /= ( Base(double(q)) * b[0] ); + } +} + +/*! +Zero order forward mode Taylor coefficient for result of op = AtanOp. + +The C++ source code corresponding to this operation is +\verbatim + z = atan(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 CppAD::local::forward_unary2_op_0 +*/ +template +void forward_atan_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(AtanOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AtanOp) == 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] = atan( x[0] ); + b[0] = Base(1.0) + x[0] * x[0]; +} +/*! +Reverse mode partial derivatives for result of op = AtanOp. + +The C++ source code corresponding to this operation is +\verbatim + z = atan(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 CppAD::local::reverse_unary2_op +*/ + +template +void reverse_atan_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(AtanOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(AtanOp) == 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.0) / 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.0); + + 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(double(j)); + + for(k = 1; k < j; k++) + { pb[j-k] -= Base(double(k)) * azmul(pz[j], z[k]); + pz[k] -= Base(double(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.0) * azmul(pb[0], x[0]); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/atomic_index.hpp cppad-2019.02.00.0/include/cppad/local/atomic_index.hpp --- cppad-2018.00.00.0/include/cppad/local/atomic_index.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/atomic_index.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,122 @@ +# ifndef CPPAD_LOCAL_ATOMIC_INDEX_HPP +# define CPPAD_LOCAL_ATOMIC_INDEX_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +Store and retrieve atomic function information by and index. + +\tparam Base +Is the base type for the tape +that will use index values to identify atomic functions. + +\par special case +In the special case (not included in the documentation below) +set_null it is true and index is zero. +For this case, number of atomic functions stored in atomic_index, +is returned and not other changes are made. +In this case, the atomic functions correspond to indices from +1 to the return value inclusive. + +\param set_null +This value should only be true during a call to an atomic function destructor. +If it is true, the pointer corresponding to index is set to null. + +\param index +This value should only be zero during a call to an atomic function constructor. +If it is zero, a copy of the +type, *name, and ptr are stored and the corresponding index +is the value retured by atomic_index2object. +Otherwise, +the information corresponding to this index is returned. + +\param type +If index is zero, type is an input. +Otherwise it is set to the type correponding to index. +This is intended to be 2 for atomic_two, and 3 for atomic_three. + +\param name +If index is zero, name is an input (and must not be null). +Otherwise, if name is not null, *name is set to the name correponding to index. +Allowing for name to be null avoids a string copy when it is not necessary. + +\param ptr +If index is zero, ptr is an input. +Otherwise it is set to the pointer correponding to index. +If set_null is true, the null value is returned for ptr +(and for all future calls with this index). + +\return +If index is zero, the return value is the index +corresponding to type, *name, and ptr (and is not zero). +Otherwise, the return value is zero. +*/ +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file atomic_index.hpp +Map indices to atomic function information +*/ + +struct atomic_index_info { + size_t type; + std::string name; + void* ptr; +}; + +template +size_t atomic_index( + bool set_null , + const size_t& index , + size_t& type , + std::string* name , + void*& ptr ) +{ // + // information for each index + static std::vector vec; +# ifndef NDEBUG + if( index == 0 || set_null ) + { CPPAD_ASSERT_KNOWN( ! thread_alloc::in_parallel(), + "calling atomic function constructor or destructor in parallel mode" + ); + } +# endif + if( set_null & (index == 0) ) + return vec.size(); + // + // case were we are retreving informaiton for an atomic function + if( 0 < index ) + { CPPAD_ASSERT_UNKNOWN( index <= vec.size() ) + // + // case where we are setting the pointer to null + if( set_null ) + vec[index-1].ptr = CPPAD_NULL; + // + atomic_index_info& entry = vec[index - 1]; + type = entry.type; + ptr = entry.ptr; + if( name != CPPAD_NULL ) + *name = entry.name; + return 0; + } + // + // case where we are storing information for an atomic function + atomic_index_info entry; + entry.type = type; + entry.name = *name; + entry.ptr = ptr; + vec.push_back(entry); + // + return vec.size(); +} + +} } // END_CPPAD_LOCAL_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/atom_state.hpp cppad-2019.02.00.0/include/cppad/local/atom_state.hpp --- cppad-2018.00.00.0/include/cppad/local/atom_state.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/atom_state.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,32 @@ +# ifndef CPPAD_LOCAL_ATOM_STATE_HPP +# define CPPAD_LOCAL_ATOM_STATE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE + +enum enum_atom_state { + /// next AFunOp marks beginning of a atomic function call + start_atom, + + /// next FunapOp (FunavOp) is a parameter (variable) argument + arg_atom, + + /// next FunrpOp (FunrvOp) is a parameter (variable) result + ret_atom, + + /// next AFunOp marks end of a atomic function call + end_atom +}; + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/CMakeLists.txt cppad-2019.02.00.0/include/cppad/local/CMakeLists.txt --- cppad-2018.00.00.0/include/cppad/local/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,76 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# Build the cppad/local/is_pod.hpp file. +# ----------------------------------------------------------------------------- +# is_pod_main +SET(is_pod_main " + int main(void) { return 0; }" +) +# is_pod_default +SET(is_pod_default + "template inline bool is_pod(void) { return false; }" +) +# ----------------------------------------------------------------------------- +# is_pod_specialize_98 +SET(is_pod_specialize_98 "") +SET(pod_type_list "bool" "char" "wchar_t" "float" "double" "long double") +FOREACH(base_type "char" "short" "int" "long" ) + FOREACH(sign signed unsigned) + add_to_list(pod_type_list "${sign} ${base_type}") + ENDFOREACH(sign signed unsigned) +ENDFOREACH(base_type) +# +FOREACH(pod_type ${pod_type_list}) + STRING(REPLACE " " "_" pod_type_var "${pod_type}") + SET(pod_type_var "pod_type_${pod_type_var}") + SET(line " + template <> inline bool is_pod<${pod_type}>(void) { return true; }" + ) + SET(source + "${is_pod_default} ${is_pod_specialize_98} ${line} ${is_pod_main}" + ) + CHECK_CXX_SOURCE_RUNS("${source}" ${pod_type_var} ) + IF( ${pod_type_var} ) + SET(is_pod_specialize_98 "${is_pod_specialize_98}${line}") + ENDIF( ${pod_type_var} ) +ENDFOREACH(pod_type) +# ----------------------------------------------------------------------------- +# is_pod_specialize_11 +SET(is_pod_specialize_11 "") +SET(pod_type_list "char16_t" "char32_t") +FOREACH(base_type "long long" ) + FOREACH(sign signed unsigned) + add_to_list(pod_type_list "${sign} ${base_type}") + ENDFOREACH(sign signed unsigned) +ENDFOREACH(base_type) +# +FOREACH(pod_type ${pod_type_list}) + STRING(REPLACE " " "_" pod_type_var "${pod_type}") + SET(pod_type_var "pod_type_${pod_type_var}") + SET(line " + template <> inline bool is_pod<${pod_type}>(void) { return true; }" + ) + SET(source + "${is_pod_default} ${is_pod_specialize_98} ${is_pod_specialize_11} + ${line} ${is_pod_main}" + ) + CHECK_CXX_SOURCE_RUNS("${source}" ${pod_type_var} ) + IF( ${pod_type_var} ) + SET(is_pod_specialize_11 "${is_pod_specialize_11}${line}") + ENDIF( ${pod_type_var} ) +ENDFOREACH(pod_type) +# ----------------------------------------------------------------------------- +# is_pod.hpp +CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/is_pod.hpp.in + ${CMAKE_CURRENT_SOURCE_DIR}/is_pod.hpp +) diff -Nru cppad-2018.00.00.0/include/cppad/local/color_general.hpp cppad-2019.02.00.0/include/cppad/local/color_general.hpp --- cppad-2018.00.00.0/include/cppad/local/color_general.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/color_general.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,271 @@ +# ifndef CPPAD_LOCAL_COLOR_GENERAL_HPP +# define CPPAD_LOCAL_COLOR_GENERAL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file color_general.hpp +Coloring algorithm for a general sparse matrix. +*/ +// -------------------------------------------------------------------------- +/*! +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 SizeVector +is a simple vector class with elements of type size_t. + +\tparam SetVector +is vector_of_sets class. + +\param pattern [in] +Is a representation of the sparsity pattern for the matrix. + +\param row [in] +is a vector specifying which row indices to compute. + +\param col [in] +is a vector, with the same size as row, +that specifies which column indices to compute. +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 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 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 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 k, of color[ row[k] ] +(not counting the indices k for which row[k] == m). +*/ +template +void color_general_cppad( + const SetVector& pattern , + const SizeVector& row , + const SizeVector& col , + CppAD::vector& color ) +{ + size_t K = row.size(); + size_t m = pattern.n_set(); + size_t n = pattern.end(); + + 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. + + // initialize rows that appear + CppAD::vector row_appear(m); + for(size_t i = 0; i < m; i++) + row_appear[i] = false; + + // rows and columns that appear + SetVector c2r_appear, r2c_appear; + c2r_appear.resize(n, m); + r2c_appear.resize(m, n); + for(size_t k = 0; k < K; k++) + { CPPAD_ASSERT_UNKNOWN( pattern.is_element(row[k], col[k]) ); + row_appear[ row[k] ] = true; + c2r_appear.post_element(col[k], row[k]); + r2c_appear.post_element(row[k], col[k]); + } + // process posts + for(size_t j = 0; j < n; ++j) + c2r_appear.process_post(j); + for(size_t i = 0; i < m; ++i) + r2c_appear.process_post(i); + + // for each column, which rows are non-zero and do not appear + SetVector not_appear; + not_appear.resize(n, m); + for(size_t i = 0; i < m; i++) + { typename SetVector::const_iterator pattern_itr(pattern, i); + size_t j = *pattern_itr; + while( j != pattern.end() ) + { if( ! c2r_appear.is_element(j , i) ) + not_appear.post_element(j, i); + j = *(++pattern_itr); + } + } + // process posts + for(size_t j = 0; j < n; ++j) + not_appear.process_post(j); + + // initial coloring + color.resize(m); + size_t ell = 0; + for(size_t i = 0; i < m; i++) + { if( row_appear[i] ) + color[i] = ell++; + else + color[i] = m; + } + /* + See GreedyPartialD2Coloring Algorithm Section 3.6.2 of + 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 + row and col need to be computed. + */ + CppAD::vector forbidden(m); + for(size_t i = 1; i < m; i++) // for each row that appears + if( color[i] < m ) + { + // initial all colors as ok for this row + // (value of forbidden for ell > initial color[i] does not matter) + for(ell = 0; ell <= color[i]; ell++) + forbidden[ell] = false; + + // ----------------------------------------------------- + // Forbid colors for which this row would destroy results: + // + // for each column that is non-zero for this row + typename SetVector::const_iterator pattern_itr(pattern, i); + size_t j = *pattern_itr; + while( j != pattern.end() ) + { // for each row that appears with this column + typename SetVector::const_iterator c2r_itr(c2r_appear, j); + size_t r = *c2r_itr; + while( r != c2r_appear.end() ) + { // if this is not the same row, forbid its color + if( (r < i) & (color[r] < m) ) + forbidden[ color[r] ] = true; + r = *(++c2r_itr); + } + j = *(++pattern_itr); + } + + + // ----------------------------------------------------- + // Forbid colors that destroy results needed for this row. + // + // for each column that appears with this row + typename SetVector::const_iterator r2c_itr(r2c_appear, i); + j = *r2c_itr; + while( j != r2c_appear.end() ) + { // For each row that is non-zero for this column + // (the appear rows have already been checked above). + typename SetVector::const_iterator not_itr(not_appear, j); + size_t r = *not_itr; + while( r != not_appear.end() ) + { // if this is not the same row, forbid its color + if( (r < i) & (color[r] < m) ) + forbidden[ color[r] ] = true; + r = *(++not_itr); + } + j = *(++r2c_itr); + } + + // pick the color with smallest index + ell = 0; + while( forbidden[ell] ) + { ell++; + CPPAD_ASSERT_UNKNOWN( ell <= color[i] ); + } + color[i] = ell; + } + return; +} + +# if CPPAD_HAS_COLPACK +/*! +Colpack version of determining which rows of a sparse matrix +can be computed together. + +\copydetails color_general +*/ +template +void color_general_colpack( + const SetVector& pattern , + const SizeVector& row , + const SizeVector& col , + CppAD::vector& color ) +{ + size_t m = pattern.n_set(); + size_t n = pattern.end(); + + // Determine number of non-zero entries in each row + CppAD::vector n_nonzero(m); + size_t n_nonzero_total = 0; + for(size_t i = 0; i < m; i++) + { n_nonzero[i] = 0; + typename SetVector::const_iterator pattern_itr(pattern, i); + size_t j = *pattern_itr; + while( j != pattern.end() ) + { n_nonzero[i]++; + j = *(++pattern_itr); + } + 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(size_t i = 0; i < m; i++) + { adolc_pattern[i] = adolc_memory.data() + i_memory; + CPPAD_ASSERT_KNOWN( + std::numeric_limits::max() >= n_nonzero[i], + "Matrix is too large for colpack" + ); + adolc_pattern[i][0] = static_cast( n_nonzero[i] ); + typename SetVector::const_iterator pattern_itr(pattern, i); + size_t j = *pattern_itr; + size_t k = 1; + while(j != pattern.end() ) + { + CPPAD_ASSERT_KNOWN( + std::numeric_limits::max() >= j, + "Matrix is too large for colpack" + ); + adolc_pattern[i][k++] = static_cast( j ); + j = *(++pattern_itr); + } + 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_general(color, m, n, adolc_pattern); + + return; +} +# endif // CPPAD_HAS_COLPACK + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/color_symmetric.hpp cppad-2019.02.00.0/include/cppad/local/color_symmetric.hpp --- cppad-2018.00.00.0/include/cppad/local/color_symmetric.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/color_symmetric.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,309 @@ +# ifndef CPPAD_LOCAL_COLOR_SYMMETRIC_HPP +# define CPPAD_LOCAL_COLOR_SYMMETRIC_HPP +# include +# include + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\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 SizeVector +is a simple vector class with elements of type size_t. + +\tparam SetVector +is a vector_of_sets class. + +\param pattern [in] +Is a representation of the sparsity pattern for the matrix. + +\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 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 there 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( + const SetVector& pattern , + CppAD::vector& row , + CppAD::vector& col , + CppAD::vector& color ) +{ + 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(size_t 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(size_t 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(size_t o1 = 0; o1 < m; o1++) + row2order[ order2row[o1] ] = o1; + + // initial coloring + color.resize(m); + size_t c1 = 0; + for(size_t o1 = 0; o1 < m; o1++) + { size_t 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(size_t o1 = 0; o1 < m; o1++) // for each row that appears (in order) + if( color[ order2row[o1] ] < m ) + { size_t i1 = order2row[o1]; + c1 = color[i1]; + + // initial all colors as ok for this row + // (value of forbidden for c > c1 does not matter) + for(size_t 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 + size_t 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) + typename SetVector::const_iterator pattern_itr(pattern, j1); + size_t i2 = *pattern_itr; + while( i2 != pattern.end() ) + { size_t c2 = color[i2]; + if( c2 < c1 ) + forbidden[c2] = true; + i2 = *(++pattern_itr); + } + itr1++; + } + // ----------------------------------------------------- + // Forbid grouping with rows that this row would destroy results for + for(size_t o2 = 0; o2 < o1; o2++) + { size_t i2 = order2row[o2]; + size_t c2 = color[i2]; + itr2 = pair_needed[i2].begin(); + while( itr2 != pair_needed[i2].end() ) + { size_t 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 + size_t 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() ) + { size_t 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(size_t k1 = 0; k1 < row.size(); k1++) + { size_t i1 = row[k1]; + size_t 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 CppAD::local::color_symmetric_cppad +*/ +template +void color_symmetric_colpack( + const SetVector& 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; + typename SetVector::const_iterator pattern_itr(pattern, i); + j = *pattern_itr; + while( j != pattern.end() ) + { n_nonzero[i]++; + j = *(++pattern_itr); + } + 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; + CPPAD_ASSERT_KNOWN( + std::numeric_limits::max() >= n_nonzero[i], + "Matrix is too large for colpack" + ); + adolc_pattern[i][0] = static_cast( n_nonzero[i] ); + typename SetVector::const_iterator pattern_itr(pattern, i); + j = *pattern_itr; + k = 1; + while(j != pattern.end() ) + { + CPPAD_ASSERT_KNOWN( + std::numeric_limits::max() >= j, + "Matrix is too large for colpack" + ); + adolc_pattern[i][k++] = static_cast( j ); + j = *(++pattern_itr); + } + 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 + for(size_t k1 = 0; k1 < row.size(); k1++) + { size_t i1 = row[k1]; + size_t j1 = col[k1]; + bool reflect = false; + for(size_t i2 = 0; i2 < m; i2++) + if( (i1 != i2) & (color[i1]==color[i2]) ) + { for(size_t k2 = 1; k2 <= adolc_pattern[i2][0]; k2++) + { size_t j2 = adolc_pattern[i2][k2]; + reflect |= (j1 == j2); + } + } + if( reflect ) + { row[k1] = j1; + col[k1] = i1; + } + } + return; +# endif // CPPAD_HAS_COLPACK +} + +} } // END_CPPAD_LOCAL_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/comp_op.hpp cppad-2019.02.00.0/include/cppad/local/comp_op.hpp --- cppad-2018.00.00.0/include/cppad/local/comp_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/comp_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,420 @@ +# ifndef CPPAD_LOCAL_COMP_OP_HPP +# define CPPAD_LOCAL_COMP_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file comp_op.hpp +Zero order forward mode check how many comparisons changed. +*/ + +// -------------------------------- <= ----------------------------------- +/*! +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 +parameter[ arg[0] ] is the left operand and +parameter[ arg[1] ] is the right operand. + +\param parameter +vector of parameter values. +*/ +template +void forward_lepp_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(LeppOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LeppOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base x = parameter[ arg[0] ]; + Base y = parameter[ arg[1] ]; + + count += size_t( GreaterThanZero(x - y) ); +} +/*! +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 +parameter[ arg[0] ] is the left operand and +taylor[ size_t(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 +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 + size_t(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[ size_t(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 +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 + size_t(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 +It the condition is not true, ths counter is incremented by one. + +\param arg +taylor[ size_t(arg[0]) * cap_order + 0 ] is the zero order Taylor coefficient +for the left operand and +taylor[ size_t(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 +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 + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + + count += GreaterThanZero(x[0] - 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 +parameter[ arg[0] ] is the left operand and +parameter[ arg[1] ] is the right operand. + +\param parameter +vector of parameter values. +*/ +template +void forward_ltpp_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(LtppOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LtppOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base x = parameter[ arg[0] ]; + Base y = parameter[ arg[1] ]; + + count += GreaterThanOrZero(x - y); +} +/*! +Zero order forward mode comparison check that left < right + +\copydetails CppAD::local::forward_lepv_op_0 +*/ +template +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 + size_t(arg[1]) * cap_order; + + count += GreaterThanOrZero(x - y[0]); +} +/*! +Zero order forward mode comparison check that left < right + +\copydetails CppAD::local::forward_levp_op_0 +*/ +template +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 + size_t(arg[0]) * cap_order; + Base y = parameter[ arg[1] ]; + + count += GreaterThanOrZero(x[0] - y); +} +/*! +Zero order forward mode comparison check that left < right + +\copydetails CppAD::local::forward_levv_op_0 +*/ +template +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 + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + + count += GreaterThanOrZero(x[0] - 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 +parameter[ arg[0] ] is the left operand and +parameter[ arg[1] ] is the right operand. + +\param parameter +vector of parameter values. +*/ +template +void forward_eqpp_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(EqppOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(EqppOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base x = parameter[ arg[0] ]; + Base y = parameter[ arg[1] ]; + + count += size_t(x != y); +} +/*! +Zero order forward mode comparison check that left == right + +\copydetails CppAD::local::forward_lepv_op_0 +*/ +template +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 + size_t(arg[1]) * cap_order; + + count += size_t(x != y[0]); +} +/*! +Zero order forward mode comparison check that left == right + +\copydetails CppAD::local::forward_levv_op_0 +*/ +template +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 + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + + count += size_t(x[0] != 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 +parameter[ arg[0] ] is the left operand and +parameter[ arg[1] ] is the right operand. + +\param parameter +vector of parameter values. +*/ +template +void forward_nepp_op_0( + size_t& count , + const addr_t* arg , + const Base* parameter ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(NeppOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(NeppOp) == 0 ); + + // Taylor coefficients corresponding to arguments and result + Base x = parameter[ arg[0] ]; + Base y = parameter[ arg[1] ]; + + count += size_t(x == y); +} +/*! +Zero order forward mode comparison check that left != right + +\copydetails CppAD::local::forward_lepv_op_0 +*/ +template +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 + size_t(arg[1]) * cap_order; + + count += size_t(x == y[0]); +} +/*! +Zero order forward mode comparison check that left != right + +\copydetails CppAD::local::forward_levv_op_0 +*/ +template +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 + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + + count += size_t(x[0] == y[0]); +} + + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/cond_op.hpp cppad-2019.02.00.0/include/cppad/local/cond_op.hpp --- cppad-2018.00.00.0/include/cppad/local/cond_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/cond_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1317 @@ +# ifndef CPPAD_LOCAL_COND_OP_HPP +# define CPPAD_LOCAL_COND_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file cond_op.hpp +Forward, reverse, and sparse operations for conditional expressions. +*/ + +/*! +Shared documentation for conditional expressions (not called). + + +The C++ source code coresponding to this operation is +\verbatim + z = CondExpRel(y_0, y_1, y_2, y_3) +\endverbatim +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< Base > and computations by this routine are done using type + Base. + +\param i_z +is the AD variable index corresponding to the variable z. + +\param arg +\n + 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. +Note that arg[0] cannot be equal to CompareNe. +\n +\n + arg[1] & 1 +\n +If this is zero, y_0 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 2 +\n +If this is zero, y_1 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 4 +\n +If this is zero, y_2 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 8 +\n +If this is zero, y_3 is a parameter. Otherwise it is a variable. +\n +\n + arg[2 + j ] for j = 0, 1, 2, 3 +\n +is the index corresponding to y_j. + +\param num_par +is the total number of values in the vector parameter. + +\param parameter +For j = 0, 1, 2, 3, +if y_j is a parameter, parameter [ arg[2 + j] ] is its value. + +\param cap_order +number of columns in the matrix containing the Taylor coefficients. + +\par Checked Assertions +\li NumArg(CExpOp) == 6 +\li NumRes(CExpOp) == 1 +\li arg[0] < static_cast ( CompareNe ) +\li arg[1] != 0; i.e., not all of y_0, y_1, y_2, y_3 are parameters. +\li For j = 0, 1, 2, 3 if y_j is a parameter, arg[2+j] < num_par. + +*/ +template +void conditional_exp_op( + size_t i_z , + const addr_t* arg , + size_t num_par , + const Base* parameter , + size_t cap_order ) +{ // This routine is only for documentation, it should never be used + CPPAD_ASSERT_UNKNOWN( false ); +} + +/*! +Shared documentation for conditional expression sparse operations (not called). + + +The C++ source code coresponding to this operation is +\verbatim + z = CondExpRel(y_0, y_1, y_2, y_3) +\endverbatim +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 +sparse_pack or sparse_list. + +\param i_z +is the AD variable index corresponding to the variable z. + +\param arg +\n + 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. +Note that arg[0] cannot be equal to CompareNe. +\n +\n + arg[1] & 1 +\n +If this is zero, y_0 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 2 +\n +If this is zero, y_1 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 4 +\n +If this is zero, y_2 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 8 +\n +If this is zero, y_3 is a parameter. Otherwise it is a variable. +\n +\n + arg[2 + j ] for j = 0, 1, 2, 3 +\n +is the index corresponding to y_j. + +\param num_par +is the total number of values in the vector parameter. + +\par Checked Assertions +\li NumArg(CExpOp) == 6 +\li NumRes(CExpOp) == 1 +\li arg[0] < static_cast ( CompareNe ) +\li arg[1] != 0; i.e., not all of y_0, y_1, y_2, y_3 are parameters. +\li For j = 0, 1, 2, 3 if y_j is a parameter, arg[2+j] < num_par. + +*/ +template +void sparse_conditional_exp_op( + size_t i_z , + const addr_t* arg , + size_t num_par ) +{ // This routine is only for documentation, it should never be used + CPPAD_ASSERT_UNKNOWN( false ); +} + +/*! +Compute forward mode Taylor coefficients for op = CExpOp. + + +The C++ source code coresponding to this operation is +\verbatim + z = CondExpRel(y_0, y_1, y_2, y_3) +\endverbatim +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< Base > and computations by this routine are done using type + Base. + +\param i_z +is the AD variable index corresponding to the variable z. + +\param arg +\n + 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. +Note that arg[0] cannot be equal to CompareNe. +\n +\n + arg[1] & 1 +\n +If this is zero, y_0 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 2 +\n +If this is zero, y_1 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 4 +\n +If this is zero, y_2 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 8 +\n +If this is zero, y_3 is a parameter. Otherwise it is a variable. +\n +\n + arg[2 + j ] for j = 0, 1, 2, 3 +\n +is the index corresponding to y_j. + +\param num_par +is the total number of values in the vector parameter. + +\param parameter +For j = 0, 1, 2, 3, +if y_j is a parameter, parameter [ arg[2 + j] ] is its value. + +\param cap_order +number of columns in the matrix containing the Taylor coefficients. + +\par Checked Assertions +\li NumArg(CExpOp) == 6 +\li NumRes(CExpOp) == 1 +\li arg[0] < static_cast ( CompareNe ) +\li arg[1] != 0; i.e., not all of y_0, y_1, y_2, y_3 are parameters. +\li For j = 0, 1, 2, 3 if y_j is a parameter, arg[2+j] < num_par. + + +\param p +is the lowest order of the Taylor coefficient of z that we are computing. + +\param q +is the highest order of the Taylor coefficient of z that we are computing. + +\param taylor +\b Input: +For j = 0, 1, 2, 3 and k = 0 , ... , q, +if y_j is a variable then +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 ] +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. + +*/ +template +void forward_cond_op( + size_t p , + size_t q , + size_t i_z , + const addr_t* arg , + size_t num_par , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ Base y_0, y_1, y_2, y_3; + Base zero(0); + Base* z = taylor + i_z * cap_order; + + 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 ); + + if( arg[1] & 1 ) + { + y_0 = taylor[ size_t(arg[2]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); + y_0 = parameter[ arg[2] ]; + } + if( arg[1] & 2 ) + { + y_1 = taylor[ size_t(arg[3]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); + y_1 = parameter[ arg[3] ]; + } + if( p == 0 ) + { if( arg[1] & 4 ) + { + y_2 = taylor[ size_t(arg[4]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[4]) < num_par ); + y_2 = parameter[ arg[4] ]; + } + if( arg[1] & 8 ) + { + y_3 = taylor[ size_t(arg[5]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[5]) < num_par ); + y_3 = parameter[ arg[5] ]; + } + z[0] = CondExpOp( + CompareOp( arg[0] ), + y_0, + y_1, + y_2, + y_3 + ); + p++; + } + for(size_t d = p; d <= q; d++) + { if( arg[1] & 4 ) + { + y_2 = taylor[ size_t(arg[4]) * cap_order + d]; + } + else + y_2 = zero; + if( arg[1] & 8 ) + { + y_3 = taylor[ size_t(arg[5]) * cap_order + d]; + } + else + y_3 = zero; + z[d] = CondExpOp( + CompareOp( arg[0] ), + y_0, + y_1, + y_2, + y_3 + ); + } + return; +} + +/*! +Multiple directions forward mode Taylor coefficients for op = CExpOp. + + +The C++ source code coresponding to this operation is +\verbatim + z = CondExpRel(y_0, y_1, y_2, y_3) +\endverbatim +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< Base > and computations by this routine are done using type + Base. + +\param i_z +is the AD variable index corresponding to the variable z. + +\param arg +\n + 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. +Note that arg[0] cannot be equal to CompareNe. +\n +\n + arg[1] & 1 +\n +If this is zero, y_0 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 2 +\n +If this is zero, y_1 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 4 +\n +If this is zero, y_2 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 8 +\n +If this is zero, y_3 is a parameter. Otherwise it is a variable. +\n +\n + arg[2 + j ] for j = 0, 1, 2, 3 +\n +is the index corresponding to y_j. + +\param num_par +is the total number of values in the vector parameter. + +\param parameter +For j = 0, 1, 2, 3, +if y_j is a parameter, parameter [ arg[2 + j] ] is its value. + +\param cap_order +number of columns in the matrix containing the Taylor coefficients. + +\par Checked Assertions +\li NumArg(CExpOp) == 6 +\li NumRes(CExpOp) == 1 +\li arg[0] < static_cast ( CompareNe ) +\li arg[1] != 0; i.e., not all of y_0, y_1, y_2, y_3 are parameters. +\li For j = 0, 1, 2, 3 if y_j is a parameter, arg[2+j] < num_par. + + +\param q +is order of the Taylor coefficient of z that we are computing. + +\param r +is the number of Taylor coefficient directions that we are computing. + +\par tpv +We use the notation +tpv = (cap_order-1) * r + 1 +which is the number of Taylor coefficients per variable + +\param taylor +\b Input: +For j = 0, 1, 2, 3, k = 1, ..., q, +if y_j is a variable then +taylor [ arg[2+j] * tpv + 0 ] +is the zero order Taylor coefficient corresponding to y_j and +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: +For j = 0, 1, 2, 3, k = 1, ..., q-1, +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. +*/ +template +void forward_cond_op_dir( + size_t q , + size_t r , + size_t i_z , + const addr_t* arg , + size_t num_par , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ Base y_0, y_1, y_2, y_3; + Base zero(0); + size_t num_taylor_per_var = (cap_order-1) * r + 1; + Base* z = taylor + i_z * num_taylor_per_var; + + 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 ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + + if( arg[1] & 1 ) + { + y_0 = taylor[ size_t(arg[2]) * num_taylor_per_var + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); + y_0 = parameter[ arg[2] ]; + } + if( arg[1] & 2 ) + { + y_1 = taylor[ size_t(arg[3]) * num_taylor_per_var + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); + y_1 = parameter[ arg[3] ]; + } + size_t m = (q-1) * r + 1; + for(size_t ell = 0; ell < r; ell++) + { if( arg[1] & 4 ) + { + y_2 = taylor[ size_t(arg[4]) * num_taylor_per_var + m + ell]; + } + else + y_2 = zero; + if( arg[1] & 8 ) + { + y_3 = taylor[ size_t(arg[5]) * num_taylor_per_var + m + ell]; + } + else + y_3 = zero; + z[m+ell] = CondExpOp( + CompareOp( arg[0] ), + y_0, + y_1, + y_2, + y_3 + ); + } + return; +} + +/*! +Compute zero order forward mode Taylor coefficients for op = CExpOp. + + +The C++ source code coresponding to this operation is +\verbatim + z = CondExpRel(y_0, y_1, y_2, y_3) +\endverbatim +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< Base > and computations by this routine are done using type + Base. + +\param i_z +is the AD variable index corresponding to the variable z. + +\param arg +\n + 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. +Note that arg[0] cannot be equal to CompareNe. +\n +\n + arg[1] & 1 +\n +If this is zero, y_0 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 2 +\n +If this is zero, y_1 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 4 +\n +If this is zero, y_2 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 8 +\n +If this is zero, y_3 is a parameter. Otherwise it is a variable. +\n +\n + arg[2 + j ] for j = 0, 1, 2, 3 +\n +is the index corresponding to y_j. + +\param num_par +is the total number of values in the vector parameter. + +\param parameter +For j = 0, 1, 2, 3, +if y_j is a parameter, parameter [ arg[2 + j] ] is its value. + +\param cap_order +number of columns in the matrix containing the Taylor coefficients. + +\par Checked Assertions +\li NumArg(CExpOp) == 6 +\li NumRes(CExpOp) == 1 +\li arg[0] < static_cast ( CompareNe ) +\li arg[1] != 0; i.e., not all of y_0, y_1, y_2, y_3 are parameters. +\li For j = 0, 1, 2, 3 if y_j is a parameter, arg[2+j] < num_par. + + +\param taylor +\b Input: +For j = 0, 1, 2, 3, +if y_j is a variable then + taylor [ arg[2+j] * cap_order + 0 ] +is the zero order Taylor coefficient corresponding to y_j. +\n +\b Output: taylor [ i_z * cap_order + 0 ] +is the zero order Taylor coefficient corresponding to z. +*/ +template +void forward_cond_op_0( + size_t i_z , + const addr_t* arg , + size_t num_par , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ Base y_0, y_1, y_2, y_3; + Base* z; + + 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 ); + + if( arg[1] & 1 ) + { + y_0 = taylor[ size_t(arg[2]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); + y_0 = parameter[ arg[2] ]; + } + if( arg[1] & 2 ) + { + y_1 = taylor[ size_t(arg[3]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); + y_1 = parameter[ arg[3] ]; + } + if( arg[1] & 4 ) + { + y_2 = taylor[ size_t(arg[4]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[4]) < num_par ); + y_2 = parameter[ arg[4] ]; + } + if( arg[1] & 8 ) + { + y_3 = taylor[ size_t(arg[5]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[5]) < num_par ); + y_3 = parameter[ arg[5] ]; + } + z = taylor + i_z * cap_order; + z[0] = CondExpOp( + CompareOp( arg[0] ), + y_0, + y_1, + y_2, + y_3 + ); + return; +} + +/*! +Compute reverse mode Taylor coefficients for op = CExpOp. + +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 +\verbatim + H( y , x , w , u , ... ) = G[ z(y) , y , x , w , u , ... ] +\endverbatim +where y above represents y_0, y_1, y_2, y_3. + + +The C++ source code coresponding to this operation is +\verbatim + z = CondExpRel(y_0, y_1, y_2, y_3) +\endverbatim +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< Base > and computations by this routine are done using type + Base. + +\param i_z +is the AD variable index corresponding to the variable z. + +\param arg +\n + 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. +Note that arg[0] cannot be equal to CompareNe. +\n +\n + arg[1] & 1 +\n +If this is zero, y_0 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 2 +\n +If this is zero, y_1 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 4 +\n +If this is zero, y_2 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 8 +\n +If this is zero, y_3 is a parameter. Otherwise it is a variable. +\n +\n + arg[2 + j ] for j = 0, 1, 2, 3 +\n +is the index corresponding to y_j. + +\param num_par +is the total number of values in the vector parameter. + +\param parameter +For j = 0, 1, 2, 3, +if y_j is a parameter, parameter [ arg[2 + j] ] is its value. + +\param cap_order +number of columns in the matrix containing the Taylor coefficients. + +\par Checked Assertions +\li NumArg(CExpOp) == 6 +\li NumRes(CExpOp) == 1 +\li arg[0] < static_cast ( CompareNe ) +\li arg[1] != 0; i.e., not all of y_0, y_1, y_2, y_3 are parameters. +\li For j = 0, 1, 2, 3 if y_j is a parameter, arg[2+j] < num_par. + + +\param d +is the order of the Taylor coefficient of z that we are computing. + +\param taylor +\b Input: +For j = 0, 1, 2, 3 and k = 0 , ... , d, +if y_j is a variable then + taylor [ arg[2+j] * cap_order + k ] +is the k-th order Taylor coefficient corresponding to y_j. +\n + taylor [ i_z * cap_order + k ] +for k = 0 , ... , d +is the k-th order Taylor coefficient corresponding to z. + +\param nc_partial +number of columns in the matrix containing the Taylor coefficients. + +\param partial +\b Input: +For j = 0, 1, 2, 3 and k = 0 , ... , d, +if y_j is a variable then + partial [ arg[2+j] * nc_partial + k ] +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: partial [ i_z * cap_order + k ] +for k = 0 , ... , d +is the partial derivative of G( z , y , x , w , u , ... ) +with respect to the k-th order Taylor coefficient corresponding to z. +\n +\b Output: +For j = 0, 1, 2, 3 and k = 0 , ... , d, +if y_j is a variable then + partial [ arg[2+j] * nc_partial + k ] +is the partial derivative of H( y , x , w , u , ... ) +with respect to the k-th order Taylor coefficient corresponding to y_j. + +*/ +template +void reverse_cond_op( + size_t d , + size_t i_z , + const addr_t* arg , + size_t num_par , + const Base* parameter , + size_t cap_order , + const Base* taylor , + size_t nc_partial , + Base* partial ) +{ Base y_0, y_1; + Base zero(0); + Base* pz; + Base* py_2; + Base* py_3; + + 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 ); + + pz = partial + i_z * nc_partial + 0; + if( arg[1] & 1 ) + { + y_0 = taylor[ size_t(arg[2]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); + y_0 = parameter[ arg[2] ]; + } + if( arg[1] & 2 ) + { + y_1 = taylor[ size_t(arg[3]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); + y_1 = parameter[ arg[3] ]; + } + if( arg[1] & 4 ) + { + py_2 = partial + size_t(arg[4]) * nc_partial; + size_t j = d + 1; + while(j--) + { py_2[j] += CondExpOp( + CompareOp( arg[0] ), + y_0, + y_1, + pz[j], + zero + ); + } + } + if( arg[1] & 8 ) + { + py_3 = partial + size_t(arg[5]) * nc_partial; + size_t j = d + 1; + while(j--) + { py_3[j] += CondExpOp( + CompareOp( arg[0] ), + y_0, + y_1, + zero, + pz[j] + ); + } + } + return; +} + +/*! +Compute forward Jacobian sparsity patterns for op = CExpOp. + + +The C++ source code coresponding to this operation is +\verbatim + z = CondExpRel(y_0, y_1, y_2, y_3) +\endverbatim +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 +sparse_pack or sparse_list. + +\param i_z +is the AD variable index corresponding to the variable z. + +\param arg +\n + 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. +Note that arg[0] cannot be equal to CompareNe. +\n +\n + arg[1] & 1 +\n +If this is zero, y_0 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 2 +\n +If this is zero, y_1 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 4 +\n +If this is zero, y_2 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 8 +\n +If this is zero, y_3 is a parameter. Otherwise it is a variable. +\n +\n + arg[2 + j ] for j = 0, 1, 2, 3 +\n +is the index corresponding to y_j. + +\param num_par +is the total number of values in the vector parameter. + +\par Checked Assertions +\li NumArg(CExpOp) == 6 +\li NumRes(CExpOp) == 1 +\li arg[0] < static_cast ( CompareNe ) +\li arg[1] != 0; i.e., not all of y_0, y_1, y_2, y_3 are parameters. +\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 +the sparsity pattern corresponding to y_2. +This identifies which of the independent variables the variable y_2 +depends on. +\n +\b Input: +if y_3 is a variable, the set with index t is +the sparsity pattern corresponding to y_3. +This identifies which of the independent variables the variable y_3 +depends on. +\n +\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. +*/ +template +void forward_sparse_jacobian_cond_op( + bool dependency , + size_t i_z , + 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 + addr_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 + sparsity.clear(i_z); + if( dependency ) + { if( arg[1] & 1 ) + sparsity.binary_union(i_z, i_z, size_t(arg[2]), sparsity); + if( arg[1] & 2 ) + sparsity.binary_union(i_z, i_z, size_t(arg[3]), sparsity); + } + if( arg[1] & 4 ) + sparsity.binary_union(i_z, i_z, size_t(arg[4]), sparsity); + if( arg[1] & 8 ) + sparsity.binary_union(i_z, i_z, size_t(arg[5]), sparsity); + return; +} + +/*! +Compute reverse Jacobian sparsity patterns for op = CExpOp. + +This routine is given the sparsity patterns +for a function G(z, y, x, ... ) +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 +where y represents the combination of y_0, y_1, y_2, and y_3. + + +The C++ source code coresponding to this operation is +\verbatim + z = CondExpRel(y_0, y_1, y_2, y_3) +\endverbatim +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 +sparse_pack or sparse_list. + +\param i_z +is the AD variable index corresponding to the variable z. + +\param arg +\n + 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. +Note that arg[0] cannot be equal to CompareNe. +\n +\n + arg[1] & 1 +\n +If this is zero, y_0 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 2 +\n +If this is zero, y_1 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 4 +\n +If this is zero, y_2 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 8 +\n +If this is zero, y_3 is a parameter. Otherwise it is a variable. +\n +\n + arg[2 + j ] for j = 0, 1, 2, 3 +\n +is the index corresponding to y_j. + +\param num_par +is the total number of values in the vector parameter. + +\par Checked Assertions +\li NumArg(CExpOp) == 6 +\li NumRes(CExpOp) == 1 +\li arg[0] < static_cast ( CompareNe ) +\li arg[1] != 0; i.e., not all of y_0, y_1, y_2, y_3 are parameters. +\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 +if y_2 is a variable, the set with index t is +the sparsity pattern corresponding to y_2. +This identifies which of the dependent variables depend on the variable y_2. +On input, this pattern corresponds to the function G. +On ouput, it corresponds to the function H. +\n +\n +if y_3 is a variable, the set with index t is +the sparsity pattern corresponding to y_3. +This identifies which of the dependent variables depeond on the variable y_3. +On input, this pattern corresponds to the function G. +On ouput, it corresponds to the function H. +\n +\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. +On input and output, this pattern corresponds to the function G. +*/ +template +void reverse_sparse_jacobian_cond_op( + bool dependency , + size_t i_z , + 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 + addr_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( dependency ) + { if( arg[1] & 1 ) + sparsity.binary_union( size_t(arg[2]), size_t(arg[2]), i_z, sparsity); + if( arg[1] & 2 ) + sparsity.binary_union( size_t(arg[3]), size_t(arg[3]), i_z, sparsity); + } + // -------------------------------------------------------------------- + if( arg[1] & 4 ) + sparsity.binary_union( size_t(arg[4]), size_t(arg[4]), i_z, sparsity); + if( arg[1] & 8 ) + sparsity.binary_union( size_t(arg[5]), size_t(arg[5]), i_z, sparsity); + return; +} + +/*! +Compute reverse Hessian sparsity patterns for op = CExpOp. + +This routine is given the sparsity patterns +for a function G(z, y, x, ... ) +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 +where y represents the combination of y_0, y_1, y_2, and y_3. + + +The C++ source code coresponding to this operation is +\verbatim + z = CondExpRel(y_0, y_1, y_2, y_3) +\endverbatim +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 +sparse_pack or sparse_list. + +\param i_z +is the AD variable index corresponding to the variable z. + +\param arg +\n + 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. +Note that arg[0] cannot be equal to CompareNe. +\n +\n + arg[1] & 1 +\n +If this is zero, y_0 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 2 +\n +If this is zero, y_1 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 4 +\n +If this is zero, y_2 is a parameter. Otherwise it is a variable. +\n +\n + arg[1] & 8 +\n +If this is zero, y_3 is a parameter. Otherwise it is a variable. +\n +\n + arg[2 + j ] for j = 0, 1, 2, 3 +\n +is the index corresponding to y_j. + +\param num_par +is the total number of values in the vector parameter. + +\par Checked Assertions +\li NumArg(CExpOp) == 6 +\li NumRes(CExpOp) == 1 +\li arg[0] < static_cast ( CompareNe ) +\li arg[1] != 0; i.e., not all of y_0, y_1, y_2, y_3 are parameters. +\li For j = 0, 1, 2, 3 if y_j is a parameter, arg[2+j] < num_par. + + + +\param jac_reverse + 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 + jac_reverse[ arg[4] ] +If y_2 is a variable, + 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 + jac_reverse[ arg[5] ] +If y_3 is a variable, + 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 i_z in 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 arg[4] in 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 arg[5] in 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. +*/ +template +void reverse_sparse_hessian_cond_op( + size_t i_z , + 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 + addr_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( size_t(arg[4]), size_t(arg[4]), i_z, hes_sparsity); + jac_reverse[ arg[4] ] |= jac_reverse[i_z]; + } + if( arg[1] & 8 ) + { + hes_sparsity.binary_union( size_t(arg[5]), size_t(arg[5]), i_z, hes_sparsity); + jac_reverse[ arg[5] ] |= jac_reverse[i_z]; + } + return; +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/cosh_op.hpp cppad-2019.02.00.0/include/cppad/local/cosh_op.hpp --- cppad-2018.00.00.0/include/cppad/local/cosh_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/cosh_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,238 @@ +# ifndef CPPAD_LOCAL_COSH_OP_HPP +# define CPPAD_LOCAL_COSH_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file cosh_op.hpp +Forward and reverse mode calculations for z = cosh(x). +*/ + + +/*! +Compute forward mode Taylor coefficient for result of op = CoshOp. + +The C++ source code corresponding to this operation is +\verbatim + z = cosh(x) +\endverbatim +The auxillary result is +\verbatim + y = sinh(x) +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails CppAD::local::forward_unary2_op +*/ +template +void forward_cosh_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(CoshOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(CoshOp) == 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* c = taylor + i_z * cap_order; + Base* s = c - cap_order; + + // rest of this routine is identical for the following cases: + // forward_sin_op, forward_cos_op, forward_sinh_op, forward_cosh_op. + // (except that there is a sign difference for hyperbolic case). + size_t k; + if( p == 0 ) + { s[0] = sinh( x[0] ); + c[0] = cosh( x[0] ); + p++; + } + for(size_t j = p; j <= q; j++) + { + s[j] = Base(0.0); + c[j] = Base(0.0); + for(k = 1; k <= j; k++) + { s[j] += Base(double(k)) * x[k] * c[j-k]; + c[j] += Base(double(k)) * x[k] * s[j-k]; + } + s[j] /= Base(double(j)); + c[j] /= Base(double(j)); + } +} +/*! +Compute forward mode Taylor coefficient for result of op = CoshOp. + +The C++ source code corresponding to this operation is +\verbatim + z = cosh(x) +\endverbatim +The auxillary result is +\verbatim + y = sinh(x) +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails CppAD::local::forward_unary2_op_dir +*/ +template +void forward_cosh_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(CoshOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(CoshOp) == 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* s = taylor + i_z * num_taylor_per_var; + Base* c = s - num_taylor_per_var; + + + // rest of this routine is identical for the following cases: + // forward_sin_op, forward_cos_op, forward_sinh_op, forward_cosh_op + // (except that there is a sign difference for the hyperbolic case). + size_t m = (q-1) * r + 1; + for(size_t ell = 0; ell < r; ell++) + { s[m+ell] = Base(double(q)) * x[m + ell] * c[0]; + c[m+ell] = Base(double(q)) * x[m + ell] * s[0]; + for(size_t k = 1; k < q; k++) + { s[m+ell] += Base(double(k)) * x[(k-1)*r+1+ell] * c[(q-k-1)*r+1+ell]; + c[m+ell] += Base(double(k)) * x[(k-1)*r+1+ell] * s[(q-k-1)*r+1+ell]; + } + s[m+ell] /= Base(double(q)); + c[m+ell] /= Base(double(q)); + } +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = CoshOp. + +The C++ source code corresponding to this operation is +\verbatim + z = cosh(x) +\endverbatim +The auxillary result is +\verbatim + y = sinh(x) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails CppAD::local::forward_unary2_op_0 +*/ +template +void forward_cosh_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(CoshOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(CoshOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* c = taylor + i_z * cap_order; // called z in documentation + Base* s = c - cap_order; // called y in documentation + + c[0] = cosh( x[0] ); + s[0] = sinh( x[0] ); +} +/*! +Compute reverse mode partial derivatives for result of op = CoshOp. + +The C++ source code corresponding to this operation is +\verbatim + z = cosh(x) +\endverbatim +The auxillary result is +\verbatim + y = sinh(x) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails CppAD::local::reverse_unary2_op +*/ + +template +void reverse_cosh_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(CoshOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(CoshOp) == 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* c = taylor + i_z * cap_order; // called z in doc + Base* pc = partial + i_z * nc_partial; + + // Taylor coefficients and partials corresponding to auxillary result + 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; + size_t k; + while(j) + { + ps[j] /= Base(double(j)); + pc[j] /= Base(double(j)); + for(k = 1; k <= j; k++) + { + px[k] += Base(double(k)) * azmul(ps[j], c[j-k]); + px[k] += Base(double(k)) * azmul(pc[j], s[j-k]); + + ps[j-k] += Base(double(k)) * azmul(pc[j], x[k]); + pc[j-k] += Base(double(k)) * azmul(ps[j], x[k]); + + } + --j; + } + px[0] += azmul(ps[0], c[0]); + px[0] += azmul(pc[0], s[0]); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/cos_op.hpp cppad-2019.02.00.0/include/cppad/local/cos_op.hpp --- cppad-2018.00.00.0/include/cppad/local/cos_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/cos_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,238 @@ +# ifndef CPPAD_LOCAL_COS_OP_HPP +# define CPPAD_LOCAL_COS_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file cos_op.hpp +Forward and reverse mode calculations for z = cos(x). +*/ + +/*! +Compute forward mode Taylor coefficient for result of op = CosOp. + +The C++ source code corresponding to this operation is +\verbatim + z = cos(x) +\endverbatim +The auxillary result is +\verbatim + y = sin(x) +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails CppAD::local::forward_unary2_op +*/ +template +void forward_cos_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(CosOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(CosOp) == 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* c = taylor + i_z * cap_order; + Base* s = c - cap_order; + + + // rest of this routine is identical for the following cases: + // forward_sin_op, forward_cos_op, forward_sinh_op, forward_cosh_op. + // (except that there is a sign difference for the hyperbolic case). + size_t k; + if( p == 0 ) + { s[0] = sin( x[0] ); + c[0] = cos( x[0] ); + p++; + } + for(size_t j = p; j <= q; j++) + { + s[j] = Base(0.0); + c[j] = Base(0.0); + for(k = 1; k <= j; k++) + { s[j] += Base(double(k)) * x[k] * c[j-k]; + c[j] -= Base(double(k)) * x[k] * s[j-k]; + } + s[j] /= Base(double(j)); + c[j] /= Base(double(j)); + } +} +/*! +Compute forward mode Taylor coefficient for result of op = CosOp. + +The C++ source code corresponding to this operation is +\verbatim + z = cos(x) +\endverbatim +The auxillary result is +\verbatim + y = sin(x) +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails CppAD::local::forward_unary2_op_dir +*/ +template +void forward_cos_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(CosOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(CosOp) == 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* c = taylor + i_z * num_taylor_per_var; + Base* s = c - num_taylor_per_var; + + + // rest of this routine is identical for the following cases: + // forward_sin_op, forward_cos_op, forward_sinh_op, forward_cosh_op + // (except that there is a sign difference for the hyperbolic case). + size_t m = (q-1) * r + 1; + for(size_t ell = 0; ell < r; ell++) + { s[m+ell] = Base(double(q)) * x[m + ell] * c[0]; + c[m+ell] = - Base(double(q)) * x[m + ell] * s[0]; + for(size_t k = 1; k < q; k++) + { s[m+ell] += Base(double(k)) * x[(k-1)*r+1+ell] * c[(q-k-1)*r+1+ell]; + c[m+ell] -= Base(double(k)) * x[(k-1)*r+1+ell] * s[(q-k-1)*r+1+ell]; + } + s[m+ell] /= Base(double(q)); + c[m+ell] /= Base(double(q)); + } +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = CosOp. + +The C++ source code corresponding to this operation is +\verbatim + z = cos(x) +\endverbatim +The auxillary result is +\verbatim + y = sin(x) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails CppAD::local::forward_unary2_op_0 +*/ +template +void forward_cos_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(CosOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(CosOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* c = taylor + i_z * cap_order; // called z in documentation + Base* s = c - cap_order; // called y in documentation + + c[0] = cos( x[0] ); + s[0] = sin( x[0] ); +} +/*! +Compute reverse mode partial derivatives for result of op = CosOp. + +The C++ source code corresponding to this operation is +\verbatim + z = cos(x) +\endverbatim +The auxillary result is +\verbatim + y = sin(x) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails CppAD::local::reverse_unary2_op +*/ + +template +void reverse_cos_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(CosOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(CosOp) == 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* c = taylor + i_z * cap_order; // called z in doc + Base* pc = partial + i_z * nc_partial; + + // Taylor coefficients and partials corresponding to auxillary result + 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; + size_t k; + while(j) + { + ps[j] /= Base(double(j)); + pc[j] /= Base(double(j)); + for(k = 1; k <= j; k++) + { + px[k] += Base(double(k)) * azmul(ps[j], c[j-k]); + px[k] -= Base(double(k)) * azmul(pc[j], s[j-k]); + + ps[j-k] -= Base(double(k)) * azmul(pc[j], x[k]); + pc[j-k] += Base(double(k)) * azmul(ps[j], x[k]); + + } + --j; + } + px[0] += azmul(ps[0], c[0]); + px[0] -= azmul(pc[0], s[0]); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/cppad_colpack.hpp cppad-2019.02.00.0/include/cppad/local/cppad_colpack.hpp --- cppad-2018.00.00.0/include/cppad/local/cppad_colpack.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/cppad_colpack.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,104 @@ +# ifndef CPPAD_LOCAL_CPPAD_COLPACK_HPP +# define CPPAD_LOCAL_CPPAD_COLPACK_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# if CPPAD_HAS_COLPACK + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file cppad_colpack.hpp +External interface to Colpack routines used by cppad. +*/ +// --------------------------------------------------------------------------- +/*! +Link from CppAD to ColPack used for general sparse matrices. + +This CppAD library routine is necessary because +ColPack/ColPackHeaders.h has a +using namespace std at the global level. + +\param m [in] +is the number of rows in the sparse matrix + +\param n [in] +is the nubmer of columns in the sparse matrix. + +\param adolc_pattern [in] +This vector has size m, +adolc_pattern[i][0] is the number of non-zeros in row i. +For j = 1 , ... , adolc_sparsity[i], +adolc_pattern[i][j] is the column index (base zero) for the +non-zeros in row i. + +\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. +\n +\n +If for some i, color[i] == m, then +adolc_pattern[i][0] == 0. +Otherwise, color[i] < m. +\n +\n +Suppose two differen rows, i != r have the same color. +It follows that for all column indices j; +it is not the case that both +(i, j) and (r, j) appear in the sparsity pattern. +\n +\n +This routine tries to minimize, with respect to the choice of colors, +the number of colors. +*/ +extern void cppad_colpack_general( + CppAD::vector& color , + size_t m , + size_t n , + const CppAD::vector& adolc_pattern +); + +/*! +Link from CppAD to ColPack used for symmetric sparse matrices +(not yet used or tested). + +This CppAD library routine is necessary because +ColPack/ColPackHeaders.h has a +using namespace std at the global level. + +\param n [in] +is the nubmer of rows and columns in the symmetric sparse matrix. + +\param adolc_pattern [in] +This vector has size n, +adolc_pattern[i][0] is the number of non-zeros in row i. +For j = 1 , ... , adolc_sparsity[i], +adolc_pattern[i][j] is the column index (base zero) for the +non-zeros in row i. + +\param color [out] +The input value of its elements does not matter. +Upon return, it is a coloring for the rows of the sparse matrix. +The properties of this coloring have not yet been determined; see +Efficient Computation of Sparse Hessians Using Coloring +and Automatic Differentiation (pdf/ad/gebemedhin14.pdf) +*/ +extern void cppad_colpack_symmetric( + CppAD::vector& color , + size_t n , + const CppAD::vector& adolc_pattern +); + +} } // END_CPPAD_LOCAL_NAMESPACE + +# endif +# endif + diff -Nru cppad-2018.00.00.0/include/cppad/local/cskip_op.hpp cppad-2019.02.00.0/include/cppad/local/cskip_op.hpp --- cppad-2018.00.00.0/include/cppad/local/cskip_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/cskip_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,199 @@ +# ifndef CPPAD_LOCAL_CSKIP_OP_HPP +# define CPPAD_LOCAL_CSKIP_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file cskip_op.hpp +Zero order forward mode set which operations to skip. +*/ + +/*! +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 and computations by this routine are done using type Base. + +\param i_z +variable index corresponding to the result of the previous operation. +This is used for error checking. To be specific, +the left and right operands for the CExpOp operation must have indexes +less than or equal this value. + +\param arg [in] +\n + 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. +Note that arg[0] cannot be equal to CompareNe. +\n +\n + arg[1] & 1 +\n +If this is zero, left is an AD parameter. +Otherwise it is an AD variable. +\n +\n + arg[1] & 2 +\n +If this is zero, right is an AD parameter. +Otherwise it is an AD variable. +\n + arg[2] +is the index corresponding to left in comparision. +\n + arg[3] +is the index corresponding to right in comparision. +\n + arg[4] +is the number of operations to skip if the comparision result is true. +\n + 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 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 and both left and right are +identically Base parameters. + +\param num_par [in] +is the total number of values in the vector parameter. + +\param parameter [in] +If left is an AD parameter, +parameter [ arg[2] ] is its value. +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 an AD variable, +taylor [ size_t(arg[2]) * cap_order + 0 ] +is the zeroth order Taylor coefficient corresponding to left. +If right is an AD variable, +taylor [ size_t(arg[3]) * cap_order + 0 ] +is the zeroth order Taylor coefficient corresponding to right. + +\param cskip_op [in,out] +is vector specifying which operations are at this point are know to be +unecessary and can be skipped. +This is both an input and an output. +*/ +template +void forward_cskip_op_0( + size_t i_z , + const addr_t* arg , + size_t num_par , + const Base* parameter , + size_t cap_order , + Base* taylor , + bool* cskip_op ) +{ + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < size_t(CompareNe) ); + CPPAD_ASSERT_UNKNOWN( arg[1] != 0 ); + + Base left, right; + if( arg[1] & 1 ) + { // If variable arg[2] <= i_z, it has already been computed, + // but it will be skipped for higher orders. + CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) <= i_z ); + left = taylor[ size_t(arg[2]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); + left = parameter[ arg[2] ]; + } + if( arg[1] & 2 ) + { // If variable arg[3] <= i_z, it has already been computed, + // but it will be skipped for higher orders. + CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) <= i_z ); + right = taylor[ size_t(arg[3]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); + right = parameter[ arg[3] ]; + } + bool ok_to_skip = IdenticalCon(left) & IdenticalCon(right); + if( ! ok_to_skip ) + return; + + // initialize to avoid compiler warning + bool true_case = false; + Base diff = left - right; + switch( CompareOp( arg[0] ) ) + { + case CompareLt: + true_case = LessThanZero(diff); + break; + + case CompareLe: + true_case = LessThanOrZero(diff); + break; + + case CompareEq: + true_case = IdenticalZero(diff); + break; + + case CompareGe: + true_case = GreaterThanOrZero(diff); + break; + + case CompareGt: + true_case = GreaterThanZero(diff); + break; + + case CompareNe: + true_case = ! IdenticalZero(diff); + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + } + if( true_case ) + { for(addr_t i = 0; i < arg[4]; i++) + cskip_op[ arg[6+i] ] = true; + } + else + { for(addr_t i = 0; i < arg[5]; i++) + cskip_op[ arg[6+arg[4]+i] ] = true; + } + return; +} +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/csum_op.hpp cppad-2019.02.00.0/include/cppad/local/csum_op.hpp --- cppad-2018.00.00.0/include/cppad/local/csum_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/csum_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,609 @@ +# ifndef CPPAD_LOCAL_CSUM_OP_HPP +# define CPPAD_LOCAL_CSUM_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file csum_op.hpp +Forward, reverse and sparsity calculations for cummulative summation. +*/ + +/*! +Compute forward mode Taylor coefficients for result of op = CsumOp. + +This operation is +\verbatim + z = s + x(0) + ... + x(m-1) - y(0) - ... - y(n-1). +\endverbatim + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type +Base. + +\param p +lowest order of the Taylor coefficient that we are computing. + +\param q +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 taylor corresponding to z. + +\param arg +-- arg[0] +parameter[arg[0]] is the parameter value s in this cummunative summation. + +-- arg[1] +end in arg of addition variables in summation. +arg[5] , ... , arg[arg[1]-1] correspond to x(0), ... , x(m-1) + +-- arg[2] +end in arg of subtraction variables in summation. +arg[arg[1]] , ... , arg[arg[2]-1] correspond to y(0), ... , y(n-1) + +-- arg[3] +end in arg of addition dynamic parameters in summation. + +-- arg[4] +end in arg of subtraction dynamic parameters in summation. + +\param num_par +is the number of parameters in parameter. + +\param parameter +is the parameter vector for this operation sequence. + +\param cap_order +number of colums in the matrix containing all the Taylor coefficients. + +\param taylor +\b Input: taylor [ arg[5+i] * cap_order + k ] +for i = 0, ..., m-1 +and k = 0 , ... , q +is the k-th order Taylor coefficient corresponding to x(i) +\n +\b Input: taylor [ arg[arg[1]+1] * cap_order + k ] +for i = 0, ..., n-1 +and k = 0 , ... , q +is the k-th order Taylor coefficient corresponding to y(i) +\n +\b Input: taylor [ i_z * cap_order + k ] +for k = 0 , ... , p, +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. +*/ +template +void forward_csum_op( + size_t p , + size_t q , + size_t i_z , + const addr_t* arg , + size_t num_par , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ Base zero(0); + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumRes(CSumOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + CPPAD_ASSERT_UNKNOWN( + arg[arg[4]] == arg[4] + ); + + // Taylor coefficients corresponding to result + Base* z = taylor + i_z * cap_order; + for(size_t k = p; k <= q; k++) + z[k] = zero; + if( p == 0 ) + { // normal parameters in the sum + z[p] = parameter[ arg[0] ]; + // addition dynamic parameters + for(size_t i = size_t(arg[2]); i < size_t(arg[3]); ++i) + z[p] += parameter[ arg[i] ]; + // subtraction dynamic parameters + for(size_t i = size_t(arg[3]); i < size_t(arg[4]); ++i) + z[p] -= parameter[ arg[i] ]; + } + Base* x; + for(size_t i = 5; i < size_t(arg[1]); ++i) + { CPPAD_ASSERT_UNKNOWN( size_t(arg[i]) < i_z ); + x = taylor + size_t(arg[i]) * cap_order; + for(size_t k = p; k <= q; k++) + z[k] += x[k]; + } + for(size_t i = size_t(arg[1]); i < size_t(arg[2]); ++i) + { CPPAD_ASSERT_UNKNOWN( size_t(arg[i]) < i_z ); + x = taylor + size_t(arg[i]) * cap_order; + for(size_t k = p; k <= q; k++) + z[k] -= x[k]; + } +} + +/*! +Multiple direction forward mode Taylor coefficients for op = CsumOp. + +This operation is +\verbatim + z = s + x(0) + ... + x(m-1) - y(0) - ... - y(n-1). +\endverbatim + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD and computations by this routine are done using type +Base. + +\param q +order ot the Taylor coefficients that we are computing. + +\param r +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 taylor corresponding to z. + +\param arg +-- arg[0] +parameter[arg[0]] is the parameter value s in this cummunative summation. + +-- arg[1] +end in arg of addition variables in summation. +arg[5] , ... , arg[arg[1]-1] correspond to x(0), ... , x(m-1) + +-- arg[2] +end in arg of subtraction variables in summation. +arg[arg[1]] , ... , arg[arg[2]-1] correspond to y(0), ... , y(n-1) + +-- arg[3] +end in arg of addition dynamic parameters in summation. + +-- arg[4] +end in arg of subtraction dynamic parameters in summation. + +\param num_par +is the number of parameters in parameter. + +\param parameter +is the parameter vector for this operation sequence. + +\param cap_order +number of colums in the matrix containing all the Taylor coefficients. + +\param taylor +\b Input: taylor [ arg[5+i]*((cap_order-1)*r + 1) + 0 ] +for i = 0, ..., m-1 +is the 0-th order Taylor coefficient corresponding to x(i) and +taylor [ arg[5+i]*((cap_order-1)*r + 1) + (q-1)*r + ell + 1 ] +for i = 0, ..., m-1, +ell = 0 , ... , r-1 +is the q-th order Taylor coefficient corresponding to x(i) +and direction ell. +\n +\b Input: taylor [ arg[arg[1]+1]*((cap_order-1)*r + 1) + 0 ] +for i = 0, ..., n-1 +is the 0-th order Taylor coefficient corresponding to y(i) and +taylor [ arg[arg[1]+1]*((cap_order-1)*r + 1) + (q-1)*r + ell + 1 ] +for i = 0, ..., n-1, +ell = 0 , ... , r-1 +is the q-th order Taylor coefficient corresponding to y(i) +and direction ell. +\n +\b Output: taylor [ i_z*((cap_order-1)*r+1) + (q-1)*r + ell + 1 ] +is the q-th order Taylor coefficient corresponding to z +for direction ell = 0 , ... , r-1. +*/ +template +void forward_csum_op_dir( + size_t q , + size_t r , + size_t i_z , + const addr_t* arg , + size_t num_par , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ Base zero(0); + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumRes(CSumOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + CPPAD_ASSERT_UNKNOWN( + arg[arg[4]] == arg[4] + ); + + // Taylor coefficients corresponding to result + size_t num_taylor_per_var = (cap_order-1) * r + 1; + size_t m = (q-1)*r + 1; + Base* z = taylor + i_z * num_taylor_per_var + m; + for(size_t ell = 0; ell < r; ell++) + z[ell] = zero; + Base* x; + for(size_t i = 5; i < size_t(arg[1]); ++i) + { CPPAD_ASSERT_UNKNOWN( size_t(arg[i]) < i_z ); + x = taylor + size_t(arg[i]) * num_taylor_per_var + m; + for(size_t ell = 0; ell < r; ell++) + z[ell] += x[ell]; + } + for(size_t i = size_t(arg[1]); i < size_t(arg[2]); ++i) + { CPPAD_ASSERT_UNKNOWN( size_t(arg[i]) < i_z ); + x = taylor + size_t(arg[i]) * num_taylor_per_var + m; + for(size_t ell = 0; ell < r; ell++) + z[ell] -= x[ell]; + } +} + +/*! +Compute reverse mode Taylor coefficients for result of op = CsumOp. + +This operation is +\verbatim + z = q + x(0) + ... + x(m-1) - y(0) - ... - y(n-1). + H(y, x, w, ...) = G[ z(x, y), y, x, w, ... ] +\endverbatim + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type +Base. + +\param d +order the highest order Taylor coefficient that 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 taylor corresponding to z. + +\param arg +-- arg[0] +parameter[arg[0]] is the parameter value s in this cummunative summation. + +-- arg[1] +end in arg of addition variables in summation. +arg[5] , ... , arg[arg[1]-1] correspond to x(0), ... , x(m-1) + +-- arg[2] +end in arg of subtraction variables in summation. +arg[arg[1]] , ... , arg[arg[2]-1] correspond to y(0), ... , y(n-1) + +-- arg[3] +end in arg of addition dynamic parameters in summation. + +-- arg[4] +end in arg of subtraction dynamic parameters in summation. + +\param nc_partial +number of colums in the matrix containing all the partial derivatives. + +\param partial +\b Input: partial [ arg[5+i] * nc_partial + k ] +for i = 0, ..., m-1 +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[arg[1]+1] * nc_partial + k ] +for i = 0, ..., n-1 +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 = 0, ..., n-1 +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 z. +\n +\b Output: partial [ arg[5+i] * nc_partial + k ] +for i = 0, ..., m-1 +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[arg[1]+1] * nc_partial + k ] +for i = 0, ..., n-1 +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) +*/ + +template +void reverse_csum_op( + size_t d , + size_t i_z , + const addr_t* arg , + size_t nc_partial , + Base* partial ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumRes(CSumOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Taylor coefficients and partial derivative corresponding to result + Base* pz = partial + i_z * nc_partial; + Base* px; + size_t d1 = d + 1; + for(size_t i = 5; i < size_t(arg[1]); ++i) + { CPPAD_ASSERT_UNKNOWN( size_t(arg[i]) < i_z ); + px = partial + size_t(arg[i]) * nc_partial; + size_t k = d1; + while(k--) + px[k] += pz[k]; + } + for(size_t i = size_t(arg[1]); i < size_t(arg[2]); ++i) + { CPPAD_ASSERT_UNKNOWN( size_t(arg[i]) < i_z ); + px = partial + size_t(arg[i]) * nc_partial; + size_t k = d1; + while(k--) + px[k] -= pz[k]; + } +} + + +/*! +Forward mode Jacobian sparsity pattern for CSumOp operator. + +This operation is +\verbatim + z = q + x(0) + ... + x(m-1) - y(0) - ... - y(n-1). +\endverbatim + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or sparse_list. + +\param i_z +variable index corresponding to the result for this operation; +i.e. the index in sparsity corresponding to z. + +\param arg +-- arg[0] +parameter[arg[0]] is the parameter value s in this cummunative summation. + +-- arg[1] +end in arg of addition variables in summation. +arg[5] , ... , arg[arg[1]-1] correspond to x(0), ... , x(m-1) + +-- arg[2] +end in arg of subtraction variables in summation. +arg[arg[1]] , ... , arg[arg[2]-1] correspond to y(0), ... , y(n-1) + +-- arg[3] +end in arg of addition dynamic parameters in summation. + +-- arg[4] +end in arg of subtraction dynamic parameters in summation. + +\param sparsity +\b Input: +For i = 0, ..., m-1, +the set with index arg[5+i] in sparsity +is the sparsity bit pattern for x(i). +This identifies which of the independent variables the variable +x(i) depends on. +\n +\b Input: +For i = 0, ..., n-1, +the set with index arg[2+arg[0]+i] in sparsity +is the sparsity bit pattern for x(i). +This identifies which of the independent variables the variable +y(i) depends on. +\n +\b Output: +The set with index i_z in sparsity +is the sparsity bit pattern for z. +This identifies which of the independent variables the variable z +depends on. +*/ + +template +void forward_sparse_jacobian_csum_op( + size_t i_z , + const addr_t* arg , + Vector_set& sparsity ) +{ sparsity.clear(i_z); + + for(size_t i = 5; i < size_t(arg[2]); ++i) + { CPPAD_ASSERT_UNKNOWN( size_t(arg[i]) < i_z ); + sparsity.binary_union( + i_z , // index in sparsity for result + i_z , // index in sparsity for left operand + size_t(arg[i]), // index for right operand + sparsity // sparsity vector for right operand + ); + } +} + +/*! +Reverse mode Jacobian sparsity pattern for CSumOp operator. + +This operation is +\verbatim + z = q + x(0) + ... + x(m-1) - y(0) - ... - y(n-1). + H(y, x, w, ...) = G[ z(x, y), y, x, w, ... ] +\endverbatim + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or sparse_list. + +\param i_z +variable index corresponding to the result for this operation; +i.e. the index in sparsity corresponding to z. + +\param arg +-- arg[0] +parameter[arg[0]] is the parameter value s in this cummunative summation. + +-- arg[1] +end in arg of addition variables in summation. +arg[5] , ... , arg[arg[1]-1] correspond to x(0), ... , x(m-1) + +-- arg[2] +end in arg of subtraction variables in summation. +arg[arg[1]] , ... , arg[arg[2]-1] correspond to y(0), ... , y(n-1) + +-- arg[3] +end in arg of addition dynamic parameters in summation. + +-- arg[4] +end in arg of subtraction dynamic parameters in summation. + +\param sparsity +For i = 0, ..., m-1, +the set with index arg[5+i] in sparsity +is the sparsity bit pattern for x(i). +This identifies which of the dependent variables depend on x(i). +On input, the sparsity patter corresponds to G, +and on ouput it corresponds to H. +\n +For i = 0, ..., m-1, +the set with index arg[2+arg[0]+i] in sparsity +is the sparsity bit pattern for y(i). +This identifies which of the dependent variables depend on y(i). +On input, the sparsity patter corresponds to G, +and on ouput it corresponds to H. +\n +\b Input: +The set with index i_z in sparsity +is the sparsity bit pattern for z. +On input it corresponds to G and on output it is undefined. +*/ + +template +void reverse_sparse_jacobian_csum_op( + size_t i_z , + const addr_t* arg , + Vector_set& sparsity ) +{ + for(size_t i = 5; i < size_t(arg[2]); ++i) + { + CPPAD_ASSERT_UNKNOWN( size_t(arg[i]) < i_z ); + sparsity.binary_union( + size_t(arg[i]), // index in sparsity for result + size_t(arg[i]), // index in sparsity for left operand + i_z , // index for right operand + sparsity // sparsity vector for right operand + ); + } +} +/*! +Reverse mode Hessian sparsity pattern for CSumOp operator. + +This operation is +\verbatim + z = q + x(0) + ... + x(m-1) - y(0) - ... - y(n-1). + H(y, x, w, ...) = G[ z(x, y), y, x, w, ... ] +\endverbatim + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or sparse_list. + +\param i_z +variable index corresponding to the result for this operation; +i.e. the index in sparsity corresponding to z. + +\param arg +-- arg[0] +parameter[arg[0]] is the parameter value s in this cummunative summation. + +-- arg[1] +end in arg of addition variables in summation. +arg[5] , ... , arg[arg[1]-1] correspond to x(0), ... , x(m-1) + +-- arg[2] +end in arg of subtraction variables in summation. +arg[arg[1]] , ... , arg[arg[2]-1] correspond to y(0), ... , y(n-1) + +-- arg[3] +end in arg of addition dynamic parameters in summation. + +-- arg[4] +end in arg of subtraction dynamic parameters in summation. + +\param rev_jacobian +rev_jacobian[i_z] +is all false (true) if the Jabobian of G with respect to z must be zero +(may be non-zero). +\n +\n +For i = 0, ..., m-1 +rev_jacobian[ arg[5+i] ] +is all false (true) if the Jacobian with respect to x(i) +is zero (may be non-zero). +On input, it corresponds to the function G, +and on output it corresponds to the function H. +\n +\n +For i = 0, ..., n-1 +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). +On input, it corresponds to the function G, +and on output it corresponds to the function H. + +\param rev_hes_sparsity +The set with index i_z in in rev_hes_sparsity +is the Hessian sparsity pattern for the fucntion G +where one of the partials derivative is with respect to z. +\n +\n +For i = 0, ..., m-1 +The set with index arg[5+i] in rev_hes_sparsity +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 = 0, ..., n-1 +The set with index arg[2+arg[0]+i] in rev_hes_sparsity +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. +*/ + +template +void reverse_sparse_hessian_csum_op( + size_t i_z , + const addr_t* arg , + bool* rev_jacobian , + Vector_set& rev_hes_sparsity ) +{ + for(size_t i = 5; i < size_t(arg[2]); ++i) + { + CPPAD_ASSERT_UNKNOWN( size_t(arg[i]) < i_z ); + rev_hes_sparsity.binary_union( + size_t(arg[i]), // index in sparsity for result + size_t(arg[i]), // index in sparsity for left operand + i_z , // index for right operand + rev_hes_sparsity // sparsity vector for right operand + ); + rev_jacobian[arg[i]] |= rev_jacobian[i_z]; + } +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/declare_ad.hpp cppad-2019.02.00.0/include/cppad/local/declare_ad.hpp --- cppad-2018.00.00.0/include/cppad/local/declare_ad.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/declare_ad.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,185 @@ +# ifndef CPPAD_LOCAL_DECLARE_AD_HPP +# define CPPAD_LOCAL_DECLARE_AD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# if CPPAD_USE_CPLUSPLUS_2011 +# include +# endif + +/*! +\file declare_ad.hpp CppAD forward declarations; i.e., before definition +*/ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE + +template class ADTape; +template class player; +template class recorder; + +} } // END_CPPAD_LOCAL_NAMESPACE + +namespace CppAD { + // The conditional expression operator enum type + enum CompareOp + { CompareLt, // less than + CompareLe, // less than or equal + CompareEq, // equal + CompareGe, // greater than or equal + CompareGt, // greater than + CompareNe // not equal + }; + + // simple typedefs + typedef CPPAD_TAPE_ADDR_TYPE addr_t; + typedef CPPAD_TAPE_ID_TYPE tape_id_t; + + // classes + class sparse_hes_work; + class sparse_jac_work; + class sparse_jacobian_work; + class sparse_hessian_work; + template class AD; + template class ADFun; + template class atomic_base; + template class atomic_three; + template class discrete; + template class VecAD; + template class VecAD_reference; + + // functions with one VecAD argument + template bool Constant (const VecAD &u); + template bool Dynamic (const VecAD &u); + template bool Parameter (const VecAD &u); + template bool Variable (const VecAD &u); + + // functions with one AD argument + template bool Constant (const AD &u); + template bool Dynamic (const AD &u); + template bool Parameter (const AD &u); + template bool Variable (const AD &u); + // + template int Integer (const AD &u); + template bool IdenticalZero (const AD &u); + template bool IdenticalOne (const AD &u); + template bool IdenticalCon (const AD &u); + template bool LessThanZero (const AD &u); + template bool LessThanOrZero (const AD &u); + template bool GreaterThanZero (const AD &u); + template bool GreaterThanOrZero (const AD &u); + template AD Var2Par (const AD &u); + template AD abs (const AD &u); + template AD acos (const AD &u); + template AD asin (const AD &u); + template AD atan (const AD &u); + template AD cos (const AD &u); + template AD cosh (const AD &u); + template AD exp (const AD &u); + template AD log (const AD &u); + template AD log10 (const AD &u); + template AD sin (const AD &u); + template AD sinh (const AD &u); + template AD sqrt (const AD &u); + template AD tan (const AD &u); + // + template unsigned short hash_code(const AD& u); + + // arithematic operators + template AD operator + ( + const AD &left, const AD &right); + template AD operator - ( + const AD &left, const AD &right); + template AD operator * ( + const AD &left, const AD &right); + template AD operator / ( + const AD &left, const AD &right); + + // comparison operators + template bool operator < ( + const AD &left, const AD &right); + template bool operator <= ( + const AD &left, const AD &right); + template bool operator > ( + const AD &left, const AD &right); + template bool operator >= ( + const AD &left, const AD &right); + template bool operator == ( + const AD &left, const AD &right); + template bool operator != ( + const AD &left, const AD &right); + + // pow + 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); + + template bool NearEqual( + const Base &x, const AD &y, const Base &r, const Base &a); + + 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 + ); + + // IdenticalEqualCon + template + bool IdenticalEqualCon (const AD &u, const AD &v); + + // EqualOpSeq + template + bool EqualOpSeq (const AD &u, const AD &v); + + // PrintFor + template + void PrintFor( + const AD& flag , + const char* before , + const AD& var , + const char* after + ); + + // Value + template Base Value(const AD &x); + + // Pow function + template AD pow + (const AD &x, const AD &y); + + // input operator + template std::istream& + operator >> (std::istream &is, AD &x); + + // output operator + template std::ostream& + operator << (std::ostream &os, const AD &x); + template std::ostream& + operator << (std::ostream &os, const VecAD_reference &e); + template std::ostream& + operator << (std::ostream &os, const VecAD &vec); +} + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/define.hpp cppad-2019.02.00.0/include/cppad/local/define.hpp --- cppad-2018.00.00.0/include/cppad/local/define.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/define.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,321 @@ +# ifndef CPPAD_LOCAL_DEFINE_HPP +# define CPPAD_LOCAL_DEFINE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/*! +\file define.hpp +Define processor symbols and macros that are used by CppAD. +*/ + +/*! +\def CPPAD_VEC_ENUM_TYPE +Is the type used to store vectors of enum values when the vector +may be large and we want to conserve memory. The following must hold for +any enum_value that is stored using the type CPPAD_VEC_ENUM_TYPE: + + size_t(enum_value) <= std::numeric_limits::max() + && is_pod + +*/ +# define CPPAD_VEC_ENUM_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). +The warning identifier is +\verbatim + warning C4396 +\endverbatim +and it contains the text +\verbatim + 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. +This macro is defined as empty for Microsoft compilers. +*/ +# ifdef _MSC_VER +# define CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION +# else +# define CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION inline +# endif + +// ---------------------------------------------------------------------------- +/*! +\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_LIB_EXPORT __declspec(dllimport) +# endif // cppad_lib_EXPORTS +# else // _MSC_VER +# define CPPAD_LIB_EXPORT +# endif + + +// ============================================================================ +/*! +\def CPPAD_FOLD_ASSIGNMENT_OPERATOR(Op) +Declares automatic coercion for certain AD assignment operations. + +This macro assumes that the operator +\verbatim + left Op right +\endverbatim +is defined for the case where left and right have type AD. +It uses this case to define the cases where +left has type AD and right has type +VecAD_reference, +Base, or +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. +*/ + +# define CPPAD_FOLD_ASSIGNMENT_OPERATOR(Op) \ +/* ----------------------------------------------------------------*/ \ +template \ +AD& operator Op \ +(AD &left, double right) \ +{ return left Op AD(right); } \ + \ +template \ +AD& operator Op \ +(AD &left, const Base &right) \ +{ return left Op AD(right); } \ + \ +inline AD& operator Op \ +(AD &left, const double &right) \ +{ return left Op AD(right); } \ + \ +template \ +AD& operator Op \ +(AD &left, const VecAD_reference &right) \ +{ return left Op right.ADBase(); } + +// ===================================================================== +/*! +\def CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(Op) +Declares automatic coercion for certain binary operations with AD result. + +This macro assumes that the operator +\verbatim + left Op right +\endverbatim +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 +and the type of the other operand is one of the following: +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. +*/ +# define CPPAD_FOLD_AD_VALUED_BINARY_OPERATOR(Op) \ +/* ----------------------------------------------------------------*/ \ +/* Operations with VecAD_reference and AD only*/ \ + \ +template \ +AD operator Op \ +(const AD &left, const VecAD_reference &right) \ +{ return left Op right.ADBase(); } \ + \ +template \ +AD operator Op \ +(const VecAD_reference &left, const VecAD_reference &right)\ +{ return left.ADBase() Op right.ADBase(); } \ + \ +template \ +AD operator Op \ + (const VecAD_reference &left, const AD &right) \ +{ return left.ADBase() Op right; } \ +/* ----------------------------------------------------------------*/ \ +/* Operations Base */ \ + \ +template \ +AD operator Op \ + (const Base &left, const AD &right) \ +{ return AD(left) Op right; } \ + \ +template \ +AD operator Op \ + (const Base &left, const VecAD_reference &right) \ +{ return AD(left) Op right.ADBase(); } \ + \ +template \ +AD operator Op \ + (const AD &left, const Base &right) \ +{ return left Op AD(right); } \ + \ +template \ +AD operator Op \ + (const VecAD_reference &left, const Base &right) \ +{ return left.ADBase() Op AD(right); } \ + \ +/* ----------------------------------------------------------------*/ \ +/* Operations double */ \ + \ +template \ +AD operator Op \ + (const double &left, const AD &right) \ +{ return AD(left) Op right; } \ + \ +template \ +AD operator Op \ + (const double &left, const VecAD_reference &right) \ +{ return AD(left) Op right.ADBase(); } \ + \ +template \ +AD operator Op \ + (const AD &left, const double &right) \ +{ return left Op AD(right); } \ + \ +template \ +AD operator Op \ + (const VecAD_reference &left, const double &right) \ +{ return left.ADBase() Op AD(right); } \ +/* ----------------------------------------------------------------*/ \ +/* Special case to avoid ambuigity when Base is double */ \ + \ +inline AD operator Op \ + (const double &left, const AD &right) \ +{ return AD(left) Op right; } \ + \ +inline AD operator Op \ + (const double &left, const VecAD_reference &right) \ +{ return AD(left) Op right.ADBase(); } \ + \ +inline AD operator Op \ + (const AD &left, const double &right) \ +{ return left Op AD(right); } \ + \ +inline AD operator Op \ + (const VecAD_reference &left, const double &right) \ +{ return left.ADBase() Op AD(right); } + +// ======================================================================= + +/*! +\def CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(Op) +Declares automatic coercion for certain binary operations with bool result. + +This macro assumes that the operator +\verbatim + left Op right +\endverbatim +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 +VecAD_reference or AD +and the type of the other operand is one of the following: +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. +*/ +# define CPPAD_FOLD_BOOL_VALUED_BINARY_OPERATOR(Op) \ +/* ----------------------------------------------------------------*/ \ +/* Operations with VecAD_reference and AD only*/ \ + \ +template \ +bool operator Op \ +(const AD &left, const VecAD_reference &right) \ +{ return left Op right.ADBase(); } \ + \ +template \ +bool operator Op \ +(const VecAD_reference &left, const VecAD_reference &right)\ +{ return left.ADBase() Op right.ADBase(); } \ + \ +template \ +bool operator Op \ + (const VecAD_reference &left, const AD &right) \ +{ return left.ADBase() Op right; } \ +/* ----------------------------------------------------------------*/ \ +/* Operations Base */ \ + \ +template \ +bool operator Op \ + (const Base &left, const AD &right) \ +{ return AD(left) Op right; } \ + \ +template \ +bool operator Op \ + (const Base &left, const VecAD_reference &right) \ +{ return AD(left) Op right.ADBase(); } \ + \ +template \ +bool operator Op \ + (const AD &left, const Base &right) \ +{ return left Op AD(right); } \ + \ +template \ +bool operator Op \ + (const VecAD_reference &left, const Base &right) \ +{ return left.ADBase() Op AD(right); } \ + \ +/* ----------------------------------------------------------------*/ \ +/* Operations double */ \ + \ +template \ +bool operator Op \ + (const double &left, const AD &right) \ +{ return AD(left) Op right; } \ + \ +template \ +bool operator Op \ + (const double &left, const VecAD_reference &right) \ +{ return AD(left) Op right.ADBase(); } \ + \ +template \ +bool operator Op \ + (const AD &left, const double &right) \ +{ return left Op AD(right); } \ + \ +template \ +bool operator Op \ + (const VecAD_reference &left, const double &right) \ +{ return left.ADBase() Op AD(right); } \ +/* ----------------------------------------------------------------*/ \ +/* Special case to avoid ambuigity when Base is double */ \ + \ +inline bool operator Op \ + (const double &left, const AD &right) \ +{ return AD(left) Op right; } \ + \ +inline bool operator Op \ + (const double &left, const VecAD_reference &right) \ +{ return AD(left) Op right.ADBase(); } \ + \ +inline bool operator Op \ + (const AD &left, const double &right) \ +{ return left Op AD(right); } \ + \ +inline bool operator Op \ + (const VecAD_reference &left, const double &right) \ +{ return left.ADBase() Op AD(right); } + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/discrete_op.hpp cppad-2019.02.00.0/include/cppad/local/discrete_op.hpp --- cppad-2018.00.00.0/include/cppad/local/discrete_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/discrete_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,121 @@ +# ifndef CPPAD_LOCAL_DISCRETE_OP_HPP +# define CPPAD_LOCAL_DISCRETE_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file discrete_op.hpp +Forward mode for z = f(x) where f is piecewise constant. +*/ + + +/*! +forward mode Taylor coefficient for result of op = DisOp. + +The C++ source code corresponding to this operation is +\verbatim + z = f(x) +\endverbatim +where f is a piecewise constant function (and it's derivative is always +calculated as zero). + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base . + +\param p +is the lowest order Taylor coefficient that will be calculated. + +\param q +is the highest order Taylor coefficient that will be calculated. + +\param r +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 taylor corresponding to z. + +\param arg + arg[0] +\n +is the index, in the order of the discrete functions defined by the user, +for this discrete function. +\n +\n + arg[1] +variable index corresponding to the argument for this operator; +i.e. the row index in taylor corresponding to x. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\par tpv +We use the notation +tpv = (cap_order-1) * r + 1 +which is the number of Taylor coefficients per variable + +\param taylor +\b Input: taylor [ arg[1] * tpv + 0 ] +is the zero order Taylor coefficient corresponding to x. +\n +\b Output: if p == 0 +taylor [ i_z * tpv + 0 ] +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 +(which is zero). + +\par Checked Assertions where op is the unary operator with one result: +\li NumArg(op) == 2 +\li NumRes(op) == 1 +\li q < cap_order +\li 0 < r +*/ +template +void forward_dis_op( + size_t p , + size_t q , + size_t r , + size_t i_z , + const addr_t* arg , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(DisOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DisOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( 0 < r ); + + // Taylor coefficients corresponding to argument and result + size_t num_taylor_per_var = (cap_order-1) * r + 1; + Base* x = taylor + size_t(arg[1]) * num_taylor_per_var; + Base* z = taylor + i_z * num_taylor_per_var; + + if( p == 0 ) + { z[0] = discrete::eval(size_t(arg[0]), x[0]); + p++; + } + for(size_t ell = 0; ell < r; ell++) + for(size_t k = p; k <= q; k++) + z[ (k-1) * r + 1 + ell ] = Base(0.0); +} + + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/div_op.hpp cppad-2019.02.00.0/include/cppad/local/div_op.hpp --- cppad-2018.00.00.0/include/cppad/local/div_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/div_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,574 @@ +# ifndef CPPAD_LOCAL_DIV_OP_HPP +# define CPPAD_LOCAL_DIV_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file div_op.hpp +Forward and reverse mode calculations for z = x / y. +*/ + +// --------------------------- Divvv ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = DivvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x / y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_binary_op +*/ + +template +void forward_divvv_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(DivvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DivvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + + // Using CondExp, it can make sense to divide by zero, + // so do not make it an error. + size_t k; + for(size_t d = p; d <= q; d++) + { z[d] = x[d]; + for(k = 1; k <= d; k++) + z[d] -= z[d-k] * y[k]; + z[d] /= y[0]; + } +} +/*! +Multiple directions forward mode Taylor coefficients for op = DivvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x / y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_binary_op_dir +*/ + +template +void forward_divvv_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(DivvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DivvvOp) == 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 + size_t(arg[0]) * num_taylor_per_var; + Base* y = taylor + size_t(arg[1]) * num_taylor_per_var; + Base* z = taylor + i_z * num_taylor_per_var; + + + // Using CondExp, 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++) + { z[m+ell] = x[m+ell] - z[0] * y[m+ell]; + 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]; + } +} + + +/*! +Compute zero order forward mode Taylor coefficients for result of op = DivvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x / y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_binary_op_0 +*/ + +template +void forward_divvv_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(DivvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DivvvOp) == 1 ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = x[0] / y[0]; +} + +/*! +Compute reverse mode partial derivatives for result of op = DivvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x / y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::reverse_binary_op +*/ + +template +void reverse_divvv_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(DivvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DivvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Arguments + const Base* y = taylor + size_t(arg[1]) * cap_order; + const Base* z = taylor + i_z * cap_order; + + // Partial derivatives corresponding to arguments and result + Base* px = partial + size_t(arg[0]) * nc_partial; + Base* py = partial + size_t(arg[1]) * nc_partial; + Base* pz = partial + i_z * nc_partial; + + // Using CondExp, it can make sense to divide by zero + // so do not make it an error. + Base inv_y0 = Base(1.0) / y[0]; + + size_t k; + // number of indices to access + size_t j = d + 1; + while(j) + { --j; + // scale partial w.r.t. z[j] + pz[j] = azmul(pz[j], inv_y0); + + px[j] += pz[j]; + for(k = 1; k <= j; k++) + { pz[j-k] -= azmul(pz[j], y[k] ); + py[k] -= azmul(pz[j], z[j-k]); + } + py[0] -= azmul(pz[j], z[j]); + } +} + +// --------------------------- Divpv ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = DivpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x / y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_binary_op +*/ + +template +void forward_divpv_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(DivpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DivpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + // Paraemter value + Base x = parameter[ arg[0] ]; + + // Using CondExp, it can make sense to divide by zero, + // so do not make it an error. + size_t k; + if( p == 0 ) + { z[0] = x / y[0]; + p++; + } + for(size_t d = p; d <= q; d++) + { z[d] = Base(0.0); + for(k = 1; k <= d; k++) + z[d] -= z[d-k] * y[k]; + z[d] /= y[0]; + } +} +/*! +Multiple directions forward mode Taylor coefficients for op = DivpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x / y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_binary_op_dir +*/ + +template +void forward_divpv_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(DivpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DivpvOp) == 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* y = taylor + size_t(arg[1]) * num_taylor_per_var; + Base* z = taylor + i_z * num_taylor_per_var; + + // Using CondExp, 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++) + { z[m+ell] = - z[0] * y[m+ell]; + 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]; + } +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = DivpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x / y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_binary_op_0 +*/ + +template +void forward_divpv_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(DivpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DivpvOp) == 1 ); + + // Paraemter value + Base x = parameter[ arg[0] ]; + + // Taylor coefficients corresponding to arguments and result + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = x / y[0]; +} + +/*! +Compute reverse mode partial derivative for result of op = DivpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x / y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::reverse_binary_op +*/ + +template +void reverse_divpv_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(DivvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DivvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Arguments + const Base* y = taylor + size_t(arg[1]) * cap_order; + const Base* z = taylor + i_z * cap_order; + + // Partial derivatives corresponding to arguments and result + Base* py = partial + size_t(arg[1]) * nc_partial; + Base* pz = partial + i_z * nc_partial; + + // Using CondExp, it can make sense to divide by zero so do not + // make it an error. + Base inv_y0 = Base(1.0) / y[0]; + + size_t k; + // number of indices to access + size_t j = d + 1; + while(j) + { --j; + // scale partial w.r.t z[j] + pz[j] = azmul(pz[j], inv_y0); + + for(k = 1; k <= j; k++) + { pz[j-k] -= azmul(pz[j], y[k] ); + py[k] -= azmul(pz[j], z[j-k] ); + } + py[0] -= azmul(pz[j], z[j]); + } +} + + +// --------------------------- Divvp ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = DivvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x / y +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::forward_binary_op +*/ + +template +void forward_divvp_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(DivvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DivvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* z = taylor + i_z * cap_order; + + // Parameter value + Base y = parameter[ arg[1] ]; + + // 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; +} +/*! +Multiple direction forward mode Taylor coefficients for op = DivvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x / y +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::forward_binary_op_dir +*/ + +template +void forward_divvp_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(DivvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DivvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + + // Taylor coefficients corresponding to arguments and result + size_t num_taylor_per_var = (cap_order-1) * r + 1; + Base* x = taylor + size_t(arg[0]) * num_taylor_per_var; + Base* z = taylor + i_z * num_taylor_per_var; + + // Parameter value + Base y = parameter[ arg[1] ]; + + // 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++) + z[m + ell] = x[m + ell] / y; +} + + +/*! +Compute zero order forward mode Taylor coefficients for result of op = DivvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x / y +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::forward_binary_op_0 +*/ + +template +void forward_divvp_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(DivvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DivvpOp) == 1 ); + + // Parameter value + Base y = parameter[ arg[1] ]; + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = x[0] / y; +} + +/*! +Compute reverse mode partial derivative for result of op = DivvpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x / y +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::reverse_binary_op +*/ + +template +void reverse_divvp_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(DivvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(DivvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Argument values + Base y = parameter[ arg[1] ]; + + // Partial derivatives corresponding to arguments and result + Base* px = partial + size_t(arg[0]) * nc_partial; + Base* pz = partial + i_z * nc_partial; + + // Using CondExp, it can make sense to divide by zero + // so do not make it an error. + Base inv_y = Base(1.0) / y; + + // number of indices to access + size_t j = d + 1; + while(j) + { --j; + px[j] += azmul(pz[j], inv_y); + } +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/erf_op.hpp cppad-2019.02.00.0/include/cppad/local/erf_op.hpp --- cppad-2018.00.00.0/include/cppad/local/erf_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/erf_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,573 @@ +# ifndef CPPAD_LOCAL_ERF_OP_HPP +# define CPPAD_LOCAL_ERF_OP_HPP +# if CPPAD_USE_CPLUSPLUS_2011 + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file erf_op.hpp +Forward and reverse mode calculations for z = erf(x). +*/ + +/*! +Forward mode Taylor coefficient for result of op = ErfOp. + +The C++ source code corresponding to this operation is +\verbatim + z = erf(x) +\endverbatim + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param p +lowest order of the Taylor coefficients that we are computing. + +\param q +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 taylor corresponding to z. +The auxillary results are called y_j have index i_z - j. + +\param arg +arg[0]: is the variable index corresponding to x. +\n +arg[1]: is the parameter index corresponding to the value zero. +\n +arg[2]: is the parameter index correspodning to the value 2 / sqrt(pi). + +\param parameter +parameter[ arg[1] ] is the value zero, +and parameter[ arg[2] ] is the value 2 / sqrt(pi). + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor +\b Input: +taylor [ size_t(arg[0]) * 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 ] +for k = 0 , ... , p - 1, +is the k-th order Taylor coefficient corresponding to z. +\n +\b Input: +taylor [ ( i_z - j) * cap_order + k ] +for k = 0 , ... , p-1, +and j = 0 , ... , 4, +is the k-th order Taylor coefficient corresponding to the j-th result for z. +\n +\b Output: +taylor [ (i_z-j) * cap_order + k ], +for k = p , ... , q, +and j = 0 , ... , 4, +is the k-th order Taylor coefficient corresponding to the j-th result for z. + +\par Checked Assertions +\li NumArg(op) == 3 +\li NumRes(op) == 5 +\li q < cap_order +\li p <= q +\li std::numeric_limits::max() >= i_z + 2 +*/ +template +void forward_erf_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(ErfOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ErfOp) == 5 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= i_z + 2 + ); + + // array used to pass parameter values for sub-operations + addr_t addr[2]; + + // convert from final result to first result + i_z -= 4; // 4 = NumRes(ErfOp) - 1; + + // z_0 = x * x + addr[0] = arg[0]; // x + addr[1] = arg[0]; // x + forward_mulvv_op(p, q, i_z+0, addr, parameter, cap_order, taylor); + + // z_1 = - x * x + addr[0] = arg[1]; // zero + addr[1] = addr_t( i_z ); // z_0 + forward_subpv_op(p, q, i_z+1, addr, parameter, cap_order, taylor); + + // z_2 = exp( - x * x ) + forward_exp_op(p, q, i_z+2, i_z+1, cap_order, taylor); + + // z_3 = (2 / sqrt(pi)) * exp( - x * x ) + addr[0] = arg[2]; // 2 / sqrt(pi) + addr[1] = addr_t( i_z + 2 ); // z_2 + forward_mulpv_op(p, q, i_z+3, addr, parameter, cap_order, taylor); + + // pointers to taylor coefficients for x , z_3, and z_4 + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* z_3 = taylor + (i_z+3) * cap_order; + Base* z_4 = taylor + (i_z+4) * cap_order; + + // calculte z_4 coefficients + if( p == 0 ) + { // z4 (t) = erf[x(t)] + z_4[0] = erf(x[0]); + p++; + } + for(size_t j = p; j <= q; j++) + { // z_4' (t) = erf'[x(t)] * x'(t) = z3(t) * x'(t) + // z_4[1] + 2 * z_4[2] * t + ... = + // (z_3[0] + z_3[1] * t + ...) * (x[1] + 2 * x[2] * t + ...) + Base base_j = static_cast(double(j)); + z_4[j] = static_cast(0); + for(size_t k = 1; k <= j; k++) + z_4[j] += (Base(double(k)) / base_j) * x[k] * z_3[j-k]; + } +} + +/*! +Zero order Forward mode Taylor coefficient for result of op = ErfOp. + +The C++ source code corresponding to this operation is +\verbatim + z = erf(x) +\endverbatim + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param i_z +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in taylor corresponding to z. +The auxillary results are called y_j have index i_z - j. + +\param arg +arg[0]: is the variable index corresponding to x. +\n +arg[1]: is the parameter index corresponding to the value zero. +\n +arg[2]: is the parameter index correspodning to the value 2 / sqrt(pi). + +\param parameter +parameter[ arg[1] ] is the value zero, +and parameter[ arg[2] ] is the value 2 / sqrt(pi). + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor +\b Input: +taylor [ size_t(arg[0]) * cap_order + 0 ] +is the zero order Taylor coefficient corresponding to x. +\n +\b Input: +taylor [ i_z * cap_order + 0 ] +is the zero order Taylor coefficient corresponding to z. +\n +\b Output: +taylor [ (i_z-j) * cap_order + 0 ], +for j = 0 , ... , 4, +is the zero order Taylor coefficient for j-th result corresponding to z. + +\par Checked Assertions +\li NumArg(op) == 3 +\li NumRes(op) == 5 +\li q < cap_order +\li p <= q +\li std::numeric_limits::max() >= i_z + 2 +*/ +template +void forward_erf_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(ErfOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ErfOp) == 5 ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= i_z + 2 + ); + + // array used to pass parameter values for sub-operations + addr_t addr[2]; + + // convert from final result to first result + i_z -= 4; // 4 = NumRes(ErfOp) - 1; + + // z_0 = x * x + addr[0] = arg[0]; // x + addr[1] = arg[0]; // x + forward_mulvv_op_0(i_z+0, addr, parameter, cap_order, taylor); + + // z_1 = - x * x + addr[0] = arg[1]; // zero + addr[1] = addr_t(i_z); // z_0 + forward_subpv_op_0(i_z+1, addr, parameter, cap_order, taylor); + + // z_2 = exp( - x * x ) + forward_exp_op_0(i_z+2, i_z+1, cap_order, taylor); + + // z_3 = (2 / sqrt(pi)) * exp( - x * x ) + addr[0] = arg[2]; // 2 / sqrt(pi) + addr[1] = addr_t(i_z + 2); // z_2 + forward_mulpv_op_0(i_z+3, addr, parameter, cap_order, taylor); + + // zero order Taylor coefficient for z_4 + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* z_4 = taylor + (i_z + 4) * cap_order; + z_4[0] = erf(x[0]); +} +/*! +Forward mode Taylor coefficient for result of op = ErfOp. + +The C++ source code corresponding to this operation is +\verbatim + z = erf(x) +\endverbatim + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param q +order of the Taylor coefficients that we are computing. + +\param r +number of directions for the Taylor coefficients that we afre computing. + +\param i_z +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in taylor corresponding to z. +The auxillary results have index i_z - j for j = 0 , ... , 4 +(and include z). + +\param arg +arg[0]: is the variable index corresponding to x. +\n +arg[1]: is the parameter index corresponding to the value zero. +\n +arg[2]: is the parameter index correspodning to the value 2 / sqrt(pi). + +\param parameter +parameter[ arg[1] ] is the value zero, +and parameter[ arg[2] ] is the value 2 / sqrt(pi). + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\par tpv +We use the notation +tpv = (cap_order-1) * r + 1 +which is the number of Taylor coefficients per variable + +\param taylor +\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 ], +for k = 1 , ... , q, +ell = 0, ..., r-1, +is the k-th order Taylor coefficient +corresponding to x and the ell-th direction. +\n +\b Input: +taylor [ (i_z - j) * tpv + 0 ] +is the zero order Taylor coefficient for all directions and the +j-th result for z. +for k = 1 , ... , q-1, +ell = 0, ... , r-1, + +taylor[ (i_z - j) * tpv + (k-1)*r + ell + 1] + +is the Taylor coefficient for the k-th order, ell-th direction, +and j-th auzillary result. +\n +\b Output: +taylor [ (i_z-j) * tpv + (q-1)*r + ell + 1 ], +for ell = 0 , ... , r-1, +is the Taylor coefficient for the q-th order, ell-th direction, +and j-th auzillary result. + +\par Checked Assertions +\li NumArg(op) == 3 +\li NumRes(op) == 5 +\li 0 < q < cap_order +*/ +template +void forward_erf_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(ErfOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ErfOp) == 5 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= i_z + 2 + ); + + // array used to pass parameter values for sub-operations + addr_t addr[2]; + + // convert from final result to first result + i_z -= 4; // 4 = NumRes(ErfOp) - 1; + + // z_0 = x * x + addr[0] = arg[0]; // x + addr[1] = arg[0]; // x + forward_mulvv_op_dir(q, r, i_z+0, addr, parameter, cap_order, taylor); + + // z_1 = - x * x + addr[0] = arg[1]; // zero + addr[1] = addr_t( i_z ); // z_0 + forward_subpv_op_dir(q, r, i_z+1, addr, parameter, cap_order, taylor); + + // z_2 = exp( - x * x ) + forward_exp_op_dir(q, r, i_z+2, i_z+1, cap_order, taylor); + + // z_3 = (2 / sqrt(pi)) * exp( - x * x ) + addr[0] = arg[2]; // 2 / sqrt(pi) + addr[1] = addr_t( i_z + 2 ); // z_2 + forward_mulpv_op_dir(q, r, i_z+3, addr, parameter, cap_order, taylor); + + // pointers to taylor coefficients for x , z_3, and z_4 + size_t num_taylor_per_var = (cap_order - 1) * r + 1; + Base* x = taylor + size_t(arg[0]) * num_taylor_per_var; + Base* z_3 = taylor + (i_z+3) * num_taylor_per_var; + Base* z_4 = taylor + (i_z+4) * num_taylor_per_var; + + // z_4' (t) = erf'[x(t)] * x'(t) = z3(t) * x'(t) + // z_4[1] + 2 * z_4[2] * t + ... = + // (z_3[0] + z_3[1] * t + ...) * (x[1] + 2 * x[2] * t + ...) + Base base_q = static_cast(double(q)); + for(size_t ell = 0; ell < r; ell++) + { // index in z_4 and x for q-th order term + size_t m = (q-1)*r + ell + 1; + // initialize q-th order term summation + z_4[m] = z_3[0] * x[m]; + for(size_t k = 1; k < q; k++) + { size_t x_index = (k-1)*r + ell + 1; + size_t z3_index = (q-k-1)*r + ell + 1; + z_4[m] += (Base(double(k)) / base_q) * x[x_index] * z_3[z3_index]; + } + } +} + +/*! +Compute reverse mode partial derivatives for result of op = ErfOp. + +The C++ source code corresponding to this operation is +\verbatim + z = erf(x) +\endverbatim + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param d +highest order Taylor of the Taylor coefficients that 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 taylor corresponding to z. +The auxillary results are called y_j have index i_z - j. + +\param arg +arg[0]: is the variable index corresponding to x. +\n +arg[1]: is the parameter index corresponding to the value zero. +\n +arg[2]: is the parameter index correspodning to the value 2 / sqrt(pi). + +\param parameter +parameter[ arg[1] ] is the value zero, +and parameter[ arg[2] ] is the value 2 / sqrt(pi). + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor +\b Input: +taylor [ size_t(arg[0]) * cap_order + k ] +for k = 0 , ... , d, +is the k-th order Taylor coefficient corresponding to x. +\n +taylor [ (i_z - j) * cap_order + k ] +for k = 0 , ... , d, +and for j = 0 , ... , 4, +is the k-th order Taylor coefficient corresponding to the j-th result +for this operation. + +\param nc_partial +number of columns in the matrix containing all the partial derivatives + +\param partial +\b Input: +partial [ size_t(arg[0]) * nc_partial + k ] +for k = 0 , ... , d, +is the partial derivative of G( z , x , w , u , ... ) with respect to +the k-th order Taylor coefficient for x. +\n +\b Input: +partial [ (i_z - j) * nc_partial + k ] +for k = 0 , ... , d, +and for j = 0 , ... , 4, +is the partial derivative of G( z , x , w , u , ... ) with respect to +the k-th order Taylor coefficient for the j-th result of this operation. +\n +\b Output: +partial [ size_t(arg[0]) * nc_partial + k ] +for k = 0 , ... , d, +is the partial derivative of H( x , w , u , ... ) with respect to +the k-th order Taylor coefficient for x. +\n +\b Output: +partial [ (i_z-j) * nc_partial + k ] +for k = 0 , ... , d, +and for j = 0 , ... , 4, +may be used as work space; i.e., may change in an unspecified manner. + +\par Checked Assertions +\li NumArg(op) == 3 +\li NumRes(op) == 5 +\li q < cap_order +\li p <= q +*/ +template +void reverse_erf_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(ErfOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ErfOp) == 5 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= i_z + 2 + ); + + // 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; + + // Taylor coefficients and partials corresponding to x + const Base* x = taylor + size_t(arg[0]) * cap_order; + Base* px = partial + size_t(arg[0]) * nc_partial; + + // Taylor coefficients and partials corresponding to z_3 + const Base* z_3 = taylor + (i_z+3) * cap_order; + Base* pz_3 = partial + (i_z+3) * nc_partial; + + // Taylor coefficients and partials corresponding to z_4 + Base* pz_4 = partial + (i_z+4) * nc_partial; + + // Reverse z_4 + size_t j = d; + while(j) + { pz_4[j] /= Base(double(j)); + for(size_t k = 1; k <= j; k++) + { px[k] += azmul(pz_4[j], z_3[j-k]) * Base(double(k)); + pz_3[j-k] += azmul(pz_4[j], x[k]) * Base(double(k)); + } + j--; + } + px[0] += azmul(pz_4[0], z_3[0]); + + // z_3 = (2 / sqrt(pi)) * exp( - x * x ) + addr[0] = arg[2]; // 2 / sqrt(pi) + addr[1] = addr_t( i_z + 2 ); // z_2 + reverse_mulpv_op( + d, i_z+3, addr, parameter, cap_order, taylor, nc_partial, partial + ); + + // z_2 = exp( - x * x ) + reverse_exp_op( + d, i_z+2, i_z+1, cap_order, taylor, nc_partial, partial + ); + + // z_1 = - x * x + addr[0] = arg[1]; // zero + addr[1] = addr_t( i_z ); // z_0 + reverse_subpv_op( + d, i_z+1, addr, parameter, cap_order, taylor, nc_partial, partial + ); + + // z_0 = x * x + addr[0] = arg[0]; // x + addr[1] = arg[0]; // x + reverse_mulvv_op( + d, i_z+0, addr, parameter, cap_order, taylor, nc_partial, partial + ); + +} + + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif // CPPAD_USE_CPLUSPLUS_2011 +# endif // CPPAD_ERF_OP_INCLUDED diff -Nru cppad-2018.00.00.0/include/cppad/local/expm1_op.hpp cppad-2019.02.00.0/include/cppad/local/expm1_op.hpp --- cppad-2018.00.00.0/include/cppad/local/expm1_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/expm1_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,201 @@ +# ifndef CPPAD_LOCAL_EXPM1_OP_HPP +# define CPPAD_LOCAL_EXPM1_OP_HPP +# if CPPAD_USE_CPLUSPLUS_2011 + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_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 CppAD::local::forward_unary1_op +*/ +template +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(double(k)) * x[k] * z[j-k]; + z[j] /= Base(double(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 CppAD::local::forward_unary1_op_dir +*/ +template +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(double(q)) * x[m+ell] * z[0]; + for(size_t k = 1; k < q; k++) + z[m+ell] += Base(double(k)) * x[(k-1)*r+ell+1] * z[(q-k-1)*r+ell+1]; + z[m+ell] /= Base(double(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 CppAD::local::forward_unary1_op_0 +*/ +template +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 CppAD::local::reverse_unary1_op +*/ + +template +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(double(j)); + + for(k = 1; k <= j; k++) + { px[k] += Base(double(k)) * azmul(pz[j], z[j-k]); + pz[j-k] += Base(double(k)) * azmul(pz[j], x[k]); + } + --j; + } + px[0] += pz[0] + azmul(pz[0], z[0]); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/exp_op.hpp cppad-2019.02.00.0/include/cppad/local/exp_op.hpp --- cppad-2018.00.00.0/include/cppad/local/exp_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/exp_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,194 @@ +# ifndef CPPAD_LOCAL_EXP_OP_HPP +# define CPPAD_LOCAL_EXP_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file exp_op.hpp +Forward and reverse mode calculations for z = exp(x). +*/ + + +/*! +Forward mode Taylor coefficient for result of op = ExpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = exp(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op +*/ +template +void forward_exp_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(ExpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ExpOp) == 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] = exp( 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(double(k)) * x[k] * z[j-k]; + z[j] /= Base(double(j)); + } +} + + +/*! +Multiple direction forward mode Taylor coefficient for op = ExpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = exp(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op_dir +*/ +template +void forward_exp_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(ExpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ExpOp) == 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(double(q)) * x[m+ell] * z[0]; + for(size_t k = 1; k < q; k++) + z[m+ell] += Base(double(k)) * x[(k-1)*r+ell+1] * z[(q-k-1)*r+ell+1]; + z[m+ell] /= Base(double(q)); + } +} + +/*! +Zero order forward mode Taylor coefficient for result of op = ExpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = exp(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op_0 +*/ +template +void forward_exp_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ExpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ExpOp) == 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] = exp( x[0] ); +} +/*! +Reverse mode partial derivatives for result of op = ExpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = exp(x) +\endverbatim + +\copydetails CppAD::local::reverse_unary1_op +*/ + +template +void reverse_exp_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(ExpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ExpOp) == 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) + { // scale partial w.r.t z[j] + pz[j] /= Base(double(j)); + + for(k = 1; k <= j; k++) + { px[k] += Base(double(k)) * azmul(pz[j], z[j-k]); + pz[j-k] += Base(double(k)) * azmul(pz[j], x[k]); + } + --j; + } + px[0] += azmul(pz[0], z[0]); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/hash_code.hpp cppad-2019.02.00.0/include/cppad/local/hash_code.hpp --- cppad-2018.00.00.0/include/cppad/local/hash_code.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/hash_code.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,243 @@ +# ifndef CPPAD_LOCAL_HASH_CODE_HPP +# define CPPAD_LOCAL_HASH_CODE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +/*! +\file local/hash_code.hpp +CppAD hashing utility. +*/ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +General purpose hash code for an arbitrary value. + +\tparam Value +is the type of the argument being hash coded. +It should be a plain old data class; i.e., +the values included in the equality operator in the object and +not pointed to by the object. + +\param value +the value that we are generating a hash code for. +All of the fields in value should have been set before the hash code +is computed (otherwise undefined values are used). + +\return +is a hash code that is between zero and CPPAD_HASH_TABLE_SIZE - 1. + +\par Checked Assertions +\li std::numeric_limits::max() >= CPPAD_HASH_TABLE_SIZE +\li sizeof(value) is even +\li sizeof(unsigned short) == 2 +*/ +template +unsigned short local_hash_code(const Value& value) +{ CPPAD_ASSERT_UNKNOWN( + std::numeric_limits::max() + >= + CPPAD_HASH_TABLE_SIZE + ); + CPPAD_ASSERT_UNKNOWN( sizeof(unsigned short) == 2 ); + CPPAD_ASSERT_UNKNOWN( sizeof(value) % 2 == 0 ); + // + const unsigned short* v + = reinterpret_cast(& value); + // + size_t i = sizeof(value) / 2 - 1; + // + size_t sum = v[i]; + // + while(i--) + sum += v[i]; + // + unsigned short code = static_cast( + sum % CPPAD_HASH_TABLE_SIZE + ); + return code; +} + +/*! +Specialized hash code for a CppAD operator and its arguments. + +\param op +is the operator that we are computing a hash code for. +If it is not one of the following operartors, the operator is not +hash coded and zero is returned: + +\li unary operators: +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, ZmulpvOp + +\li binary operators where second argument is a parameter: +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, ZmulvvOp + +\param arg +is a vector of length NumArg(op) or 2 (which ever is smaller), +containing the corresponding argument indices for this operator. + +\param npar +is the number of parameters corresponding to this operation sequence. + +\param par +is a vector of length npar containing the parameters +for this operation sequence; i.e., +given a parameter index of i, the corresponding parameter value is + par[i]. + + +\return +is a hash code that is between zero and CPPAD_HASH_TABLE_SIZE - 1. + +\par Checked Assertions + op must be one of the operators specified above. In addition, +\li std::numeric_limits::max() >= CPPAD_HASH_TABLE_SIZE +\li sizeof(size_t) is even +\li sizeof(Base) is even +\li sizeof(unsigned short) == 2 +\li 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. +*/ + +template +unsigned short local_hash_code( + OpCode op , + const addr_t* arg , + size_t npar , + const Base* par ) +{ CPPAD_ASSERT_UNKNOWN( + std::numeric_limits::max() + >= + CPPAD_HASH_TABLE_SIZE + ); + CPPAD_ASSERT_UNKNOWN( size_t (op) < size_t(NumberOp) ); + CPPAD_ASSERT_UNKNOWN( sizeof(unsigned short) == 2 ); + CPPAD_ASSERT_UNKNOWN( sizeof(addr_t) % 2 == 0 ); + CPPAD_ASSERT_UNKNOWN( sizeof(Base) % 2 == 0 ); + unsigned short op_fac = static_cast ( + CPPAD_HASH_TABLE_SIZE / static_cast(NumberOp) + ); + CPPAD_ASSERT_UNKNOWN( op_fac > 0 ); + + // number of shorts per addr_t value + size_t short_addr_t = sizeof(addr_t) / 2; + + // initialize with value that separates operators as much as possible + unsigned short code = static_cast( + static_cast(op) * op_fac + ); + + // now code in the operands + size_t i; + const unsigned short* v; + + // first argument + switch(op) + { // Binary operators where first arugment is a parameter. + // Code parameters by value instead of + // by index for two reasons. One, it gives better separation. + // Two, different indices can be same parameter value. + case AddpvOp: + case DivpvOp: + case MulpvOp: + case PowpvOp: + case SubpvOp: + case ZmulpvOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); + code += hash_code( par[arg[0]] ); + // + v = reinterpret_cast(arg + 1); + i = short_addr_t; + while(i--) + code += v[i]; + break; + + // Binary operator where first argument is an index and + // second is a variable (same as both variables). + case DisOp: + + // Binary operators where both arguments are variables + case AddvvOp: + case DivvvOp: + case MulvvOp: + case PowvvOp: + case SubvvOp: + case ZmulvvOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); + v = reinterpret_cast(arg + 0); + i = 2 * short_addr_t; + while(i--) + code += v[i]; + break; + + // Binary operators where second arugment is a parameter. + case DivvpOp: + case PowvpOp: + case SubvpOp: + case ZmulvpOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); + v = reinterpret_cast(arg + 0); + i = short_addr_t; + while(i--) + code += v[i]; + code += hash_code( par[arg[1]] ); + break; + + // 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--) + code += v[i]; + break; + + // should have been one of he cases above + default: + CPPAD_ASSERT_UNKNOWN(false); + } + + return code % CPPAD_HASH_TABLE_SIZE; +} + +} } // END_CPPAD_LOCAL_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/independent.hpp cppad-2019.02.00.0/include/cppad/local/independent.hpp --- cppad-2018.00.00.0/include/cppad/local/independent.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/independent.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,119 @@ +# ifndef CPPAD_LOCAL_INDEPENDENT_HPP +# define CPPAD_LOCAL_INDEPENDENT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/* +\file local/independent.hpp +Start recording AD operations. +*/ + +/*! +Start recording AD operations: Implementation in local namespace. + +\tparam ADVector +This is simple vector type with elements of type AD. + +\param x +Vector of the independent variables. + +\param abort_op_index +operator index at which execution will be aborted (during the recording + +\param record_compare +should comparison operators be recorded. +of operations). The value zero corresponds to not aborting (will not match). + +\param dynamic +Vector of dynamic parameters. +*/ +template +template +void ADTape::Independent( + ADVector& x , + size_t abort_op_index , + bool record_compare , + ADVector& dynamic +) { + // check ADVector is Simple Vector class with AD elements + CheckSimpleVector< AD, ADVector>(); + + // dimension of the domain space + size_t n = x.size(); + CPPAD_ASSERT_KNOWN( + n > 0, + "Indepdendent: the argument vector x has zero size" + ); + CPPAD_ASSERT_UNKNOWN( Rec_.num_var_rec() == 0 ); + CPPAD_ASSERT_UNKNOWN( Rec_.get_abort_op_index() == 0 ); + CPPAD_ASSERT_UNKNOWN( Rec_.get_record_compare() == true ); + CPPAD_ASSERT_UNKNOWN( Rec_.get_num_dynamic_ind() == 0 ); + + // set record_compare and abort_op_index before doing anything else + Rec_.set_record_compare(record_compare); + Rec_.set_abort_op_index(abort_op_index); + Rec_.set_num_dynamic_ind( dynamic.size() ); + + // 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); + Rec_.PutArg(0); + + // place each of the independent variables in the tape + CPPAD_ASSERT_NARG_NRES(InvOp, 0, 1); + for(size_t j = 0; j < n; j++) + { // tape address for this independent variable + CPPAD_ASSERT_UNKNOWN( ! Variable(x[j] ) ); + x[j].taddr_ = Rec_.PutOp(InvOp); + x[j].tape_id_ = id_; + x[j].ad_type_ = variable_enum; + CPPAD_ASSERT_UNKNOWN( size_t(x[j].taddr_) == j+1 ); + CPPAD_ASSERT_UNKNOWN( Variable(x[j] ) ); + } + + // done specifying all of the independent variables + size_independent_ = n; + + // parameter index zero is used by dynamic parameter tape + // to indicate that an argument is a variable + Base nan = CppAD::numeric_limits::quiet_NaN(); +# ifndef NDEBUG + CPPAD_ASSERT_UNKNOWN( Rec_.put_con_par(nan) == 0 ); +# else + Rec_.put_con_par(nan); +# endif + + // Place independent dynamic parameters at beginning of parameter vector, + // just after the nan at index zero. + for(size_t j = 0; j < Rec_.get_num_dynamic_ind(); ++j) + { CPPAD_ASSERT_UNKNOWN( ! Dynamic( dynamic[j] ) ); + CPPAD_ASSERT_UNKNOWN( Parameter( dynamic[j] ) ); + // + // dynamic parameters are placed at the end, so i == j +# ifndef NDEBUG + addr_t i = Rec_.put_dyn_par(dynamic[j].value_ , ind_dyn); + CPPAD_ASSERT_UNKNOWN( size_t(i) == j+1 ); +# else + Rec_.put_dyn_par(dynamic[j].value_ , ind_dyn); +# endif + // + // make this parameter dynamic + dynamic[j].taddr_ = static_cast(j+1); + dynamic[j].tape_id_ = id_; + dynamic[j].ad_type_ = dynamic_enum; + CPPAD_ASSERT_UNKNOWN( Dynamic( dynamic[j] ) ); + } +} +} } // END_CPPAD_LOCAL_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/is_pod.hpp.in cppad-2019.02.00.0/include/cppad/local/is_pod.hpp.in --- cppad-2018.00.00.0/include/cppad/local/is_pod.hpp.in 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/is_pod.hpp.in 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,43 @@ +# ifndef CPPAD_LOCAL_IS_POD_HPP +# define CPPAD_LOCAL_IS_POD_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +// make sure size_t is defined because autotools version of +// is_pod_specialize_98 uses it +# include + +/*! +\file is_pod.hpp +File that defines is_pod(void) +*/ +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +Is this type plain old data; i.e., its constructor need not be called. + +The default definition is false. This include file defines it as true +for all the fundamental types except for void and nullptr_t. +*/ +template bool is_pod(void) { return false; } +// The following command suppresses doxygen processing for the code below +/// \cond +// C++98 Fundamental types +@is_pod_specialize_98@ + +# if CPPAD_USE_CPLUSPLUS_2011 +// C++11 Fundamental types +@is_pod_specialize_11@ +# endif + +/// \endcond +} } // END_CPPAD_LOCAL_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/load_op.hpp cppad-2019.02.00.0/include/cppad/local/load_op.hpp --- cppad-2018.00.00.0/include/cppad/local/load_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/load_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,693 @@ +# ifndef CPPAD_LOCAL_LOAD_OP_HPP +# define CPPAD_LOCAL_LOAD_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\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 +op = LdpOp or LdvOp (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 = 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 +using AD and computations by this routine are done using type Base. + +\param play +is the tape that this operation appears in. +This is for error detection and not used when NDEBUG is defined. + +\param i_z +is the AD variable index corresponding to the variable z. + +\param arg +\n +arg[0] +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 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), +i_vec is defined by +\verbatim + i_vec = floor( taylor[ size_t(arg[1]) * cap_order + 0 ] ) +\endverbatim +where floor(c) is the greatest integer less that or equal c. +\n +\n +arg[2] +Is the index of this vecad load instruction in the +var_by_load_op array. + +\param parameter +If v[x] is a parameter, parameter[ i_v_x ] is its value. +This vector has size play->num_par_rec(). + +\param cap_order +number of columns in the matrix containing the Taylor coefficients. + +\param taylor +\n +Input +\n +In LdvOp case, taylor[ size_t(arg[1]) * cap_order + 0 ] +is used to compute the index in the definition of i_vec above. +If v[x] is a variable, taylor[ i_v_x * cap_order + 0 ] +is the zero order Taylor coefficient for v[x]. +\n +\n +Output +\n +taylor[ i_z * cap_order + 0 ] +is set to the zero order Taylor coefficient for the variable z. + +\param isvar_by_ind +If isvar_by_ind[ arg[0] + i_vec ] is true, +v[x] is a variable. Otherwise it is a parameter. +This vector has size play->num_vec_ind_rec(). + +\param index_by_ind +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 +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 +instruction. +In the case where the index is zero, +the instruction corresponds to a parameter (not variable). +This array has size play->num_load_op_rec(). + +\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, +the corresponding vector index and it does not change. +In this case, the error above should be detected during tape recording. +*/ +template +void forward_load_op_0( + const local::player* play, + size_t i_z , + const Addr* arg , + const Base* parameter , + size_t cap_order , + Base* taylor , + bool* isvar_by_ind , + size_t* index_by_ind , + Addr* var_by_load_op ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} +/*! +Shared documentation for sparsity operations corresponding to +op = LdpOp or LdvOp (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 = 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 +sparse_pack or sparse_list. + +\param op +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., +the set with index i_z in var_sparsity is the sparsity pattern +correpsonding to z. + +\param arg +\n + 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 + combined[ arg[0] - 1 ] +is the index of the set corresponding to the vector v in vecad_sparsity. +We use the notation i_v for this value; i.e., +\verbatim + i_v = combined[ arg[0] - 1 ] +\endverbatim + +\param var_sparsity +The set with index i_z in 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 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 < arg[0] +\li arg[0] < num_combined +\li i_v < vecad_sparsity.n_set() +*/ +template +void sparse_load_op( + OpCode op , + size_t i_z , + const Addr* arg , + size_t num_combined , + const size_t* combined , + Vector_set& var_sparsity , + Vector_set& vecad_sparsity ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + + +/*! +Zero order forward mode implementation of op = LdpOp. + +\copydetails CppAD::local::forward_load_op_0 +*/ +template +void forward_load_p_op_0( + const local::player* play, + size_t i_z , + const Addr* arg , + const Base* parameter , + size_t cap_order , + Base* taylor , + bool* isvar_by_ind , + size_t* index_by_ind , + Addr* var_by_load_op ) +{ CPPAD_ASSERT_UNKNOWN( NumArg(LdpOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LdpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < play->num_load_op_rec() ); + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= i_z + ); + + // Because the index is a parameter, this indexing error should have been + // caught and reported to the user when the tape is recording. + addr_t i_vec = arg[1]; + CPPAD_ASSERT_UNKNOWN( size_t(i_vec) < index_by_ind[ arg[0] - 1 ] ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0] + i_vec) < play->num_vec_ind_rec() ); + + 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 ); + var_by_load_op[ arg[2] ] = addr_t( i_v_x ); + Base* v_x = taylor + i_v_x * cap_order; + z[0] = v_x[0]; + } + else + { CPPAD_ASSERT_UNKNOWN( i_v_x < play->num_par_rec() ); + var_by_load_op[ arg[2] ] = 0; + Base v_x = parameter[i_v_x]; + z[0] = v_x; + } +} + +/*! +Zero order forward mode implementation of op = LdvOp. + +\copydetails CppAD::local::forward_load_op_0 +*/ +template +void forward_load_v_op_0( + const local::player* play, + size_t i_z , + const Addr* arg , + const Base* parameter , + size_t cap_order , + Base* taylor , + bool* isvar_by_ind , + size_t* index_by_ind , + Addr* var_by_load_op ) +{ CPPAD_ASSERT_UNKNOWN( NumArg(LdvOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LdvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < play->num_load_op_rec() ); + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= i_z + ); + + addr_t i_vec = addr_t(Integer(taylor[ size_t(arg[1]) * cap_order + 0 ] )); + CPPAD_ASSERT_KNOWN( + size_t(i_vec) < index_by_ind[ arg[0] - 1 ] , + "VecAD: index during zero order forward sweep is out of range" + ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0] + i_vec) < play->num_vec_ind_rec() ); + + 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 ); + var_by_load_op[ arg[2] ] = addr_t( i_v_x ); + Base* v_x = taylor + i_v_x * cap_order; + z[0] = v_x[0]; + } + else + { CPPAD_ASSERT_UNKNOWN( i_v_x < play->num_par_rec() ); + var_by_load_op[ arg[2] ] = 0; + Base v_x = parameter[i_v_x]; + z[0] = v_x; + } +} + +/*! +Forward mode, except for zero order, for op = LdpOp or op = LdvOp + + + +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: + + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD and computations by this routine are done using type Base. + +\param play +is the tape that this operation appears in. +This is for error detection and not used when NDEBUG is defined. + +\param op +is the code corresponding to this operator; i.e., LdpOp or LdvOp +(only used for error checking). + +\param p +is the lowest order of the Taylor coefficient that we are computing. + +\param q +is the highest order of the Taylor coefficient that we are computing. + +\param r +is the number of directions for the Taylor coefficients that we +are computing. + +\param cap_order +number of columns in the matrix containing the Taylor coefficients. + +\par tpv +We use the notation +tpv = (cap_order-1) * r + 1 +which is the number of Taylor coefficients per variable + +\param i_z +is the AD variable index corresponding to the variable z. + +\param arg +arg[2] +Is the index of this vecad load instruction in the var_by_load_op array. + +\param var_by_load_op +is a vector with size play->num_load_op_rec(). +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). + +\par i_var +We use the notation +\verbatim + i_var = size_t( var_by_load_op[ arg[2] ] ) +\endverbatim + +\param taylor +\n +Input +\n +If i_var > 0, v[x] is a variable and +for k = 1 , ... , q +taylor[ i_var * tpv + (k-1)*r+1+ell ] +is the k-th order coefficient for v[x] in the ell-th direction, +\n +\n +Output +\n +for k = p , ... , q, +taylor[ i_z * tpv + (k-1)*r+1+ell ] +is set to the k-order Taylor coefficient for z in the ell-th direction. +*/ +template +void forward_load_op( + const local::player* play, + OpCode op , + size_t p , + size_t q , + size_t r , + size_t cap_order , + size_t i_z , + const Addr* arg , + const Addr* var_by_load_op , + Base* taylor ) +{ + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( 0 < r); + CPPAD_ASSERT_UNKNOWN( 0 < p); + CPPAD_ASSERT_UNKNOWN( p <= q ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < play->num_load_op_rec() ); + + size_t i_var = size_t( var_by_load_op[ arg[2] ] ); + CPPAD_ASSERT_UNKNOWN( i_var < i_z ); + + size_t num_taylor_per_var = (cap_order-1) * r + 1; + Base* z = taylor + i_z * num_taylor_per_var; + if( i_var > 0 ) + { Base* v_x = taylor + i_var * num_taylor_per_var; + for(size_t ell = 0; ell < r; ell++) + { for(size_t k = p; k <= q; k++) + { size_t m = (k-1) * r + 1 + ell; + z[m] = v_x[m]; + } + } + } + else + { for(size_t ell = 0; ell < r; ell++) + { for(size_t k = p; k <= q; k++) + { size_t m = (k-1) * r + 1 + ell; + z[m] = Base(0.0); + } + } + } +} + +/*! +Reverse mode for op = LdpOp or LdvOp. + + +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: + + +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 +\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< Base > and computations by this routine are done using type + Base. + +\param op +is the code corresponding to this operator; i.e., LdpOp or LdvOp +(only used for error checking). + +\param d +highest order the Taylor coefficient that we are computing the partial +derivative with respect to. + +\param i_z +is the AD variable index corresponding to the variable z. + +\param arg + arg[2] +Is the index of this vecad load instruction in the +var_by_load_op array. + +\param cap_order +number of columns in the matrix containing the Taylor coefficients +(not used). + +\param taylor +matrix of Taylor coefficients (not used). + +\param nc_partial +number of colums in the matrix containing all the partial derivatives +(not used if arg[2] is zero). + +\param partial +If arg[2] is zero, y[x] is a parameter +and no values need to be modified; i.e., partial is not used. +Otherwise, y[x] is a variable and: +\n +\n + partial [ i_z * nc_partial + k ] +for k = 0 , ... , d +is the partial derivative of G +with respect to the k-th order Taylor coefficient for z. +\n +\n +If arg[2] is not zero, + partial [ arg[2] * nc_partial + k ] +for k = 0 , ... , d +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. + +\param var_by_load_op +is a vector with size play->num_load_op_rec(). +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). + +\par Checked Assertions +\li NumArg(op) == 3 +\li NumRes(op) == 1 +\li d < cap_order +\li size_t(arg[2]) < i_z +*/ +template +void reverse_load_op( + OpCode op , + size_t d , + size_t i_z , + const Addr* arg , + size_t cap_order , + const Base* taylor , + size_t nc_partial , + Base* partial , + const Addr* var_by_load_op ) +{ size_t i_load = size_t( var_by_load_op[ arg[2] ] ); + + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( i_load < i_z ); + + if( i_load > 0 ) + { + Base* pz = partial + i_z * nc_partial; + Base* py_x = partial + i_load * nc_partial; + size_t j = d + 1; + while(j--) + py_x[j] += pz[j]; + } +} + + +/*! +Forward mode sparsity operations for LdpOp and LdvOp + +\param dependency +is this a dependency (or sparsity) calculation. + +\copydetails CppAD::local::sparse_load_op +*/ +template +void forward_sparse_load_op( + bool dependency , + OpCode op , + size_t i_z , + const Addr* arg , + size_t num_combined , + const size_t* combined , + Vector_set& var_sparsity , + Vector_set& vecad_sparsity ) +{ + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_combined ); + size_t i_v = combined[ arg[0] - 1 ]; + 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, size_t(arg[1]), var_sparsity); + + return; +} + + +/*! +Reverse mode Jacobian sparsity operations for LdpOp and LdvOp + +\param dependency +is this a dependency (or sparsity) calculation. + +\copydetails CppAD::local::sparse_load_op +*/ +template +void reverse_sparse_jacobian_load_op( + bool dependency , + OpCode op , + size_t i_z , + const Addr* arg , + size_t num_combined , + const size_t* combined , + Vector_set& var_sparsity , + Vector_set& vecad_sparsity ) +{ + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_combined ); + size_t i_v = combined[ arg[0] - 1 ]; + 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( size_t(arg[1]), size_t(arg[1]), i_z, var_sparsity); + + return; +} + + +/*! +Reverse mode Hessian sparsity operations for LdpOp and LdvOp + +\copydetails CppAD::local::sparse_load_op + +\param var_jacobian + 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 + 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. + +*/ +template +void reverse_sparse_hessian_load_op( + OpCode op , + size_t i_z , + const Addr* arg , + size_t num_combined , + const size_t* combined , + Vector_set& var_sparsity , + Vector_set& vecad_sparsity , + bool* var_jacobian , + bool* vecad_jacobian ) +{ + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_combined ); + size_t i_v = combined[ arg[0] - 1 ]; + CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() ); + + vecad_sparsity.binary_union(i_v, i_v, i_z, var_sparsity); + + vecad_jacobian[i_v] |= var_jacobian[i_z]; + + return; +} + + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/log1p_op.hpp cppad-2019.02.00.0/include/cppad/local/log1p_op.hpp --- cppad-2018.00.00.0/include/cppad/local/log1p_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/log1p_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,205 @@ +# ifndef CPPAD_LOCAL_LOG1P_OP_HPP +# define CPPAD_LOCAL_LOG1P_OP_HPP +# if CPPAD_USE_CPLUSPLUS_2011 + +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_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 CppAD::local::forward_unary1_op +*/ +template +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.0) + 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(double(k)) * z[k] * x[j-k]; + z[j] /= Base(double(j)); + z[j] += x[j]; + z[j] /= (Base(1.0) + x[0]); + } +} + +/*! +Muiltiple directions Taylor coefficient for op = Log1pOp. + +The C++ source code corresponding to this operation is +\verbatim + z = log1p(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op_dir +*/ +template +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(double(q)) * x[m+ell]; + for(size_t k = 1; k < q; k++) + z[m+ell] -= Base(double(k)) * z[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; + z[m+ell] /= (Base(double(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 CppAD::local::forward_unary1_op_0 +*/ +template +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 CppAD::local::reverse_unary1_op +*/ + +template +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.0) / (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(double(j)); + + for(k = 1; k < j; k++) + { pz[k] -= Base(double(k)) * azmul(pz[j], x[j-k]); + px[j-k] -= Base(double(k)) * azmul(pz[j], z[k]); + } + --j; + } + px[0] += azmul(pz[0], inv_1px0); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/log_op.hpp cppad-2019.02.00.0/include/cppad/local/log_op.hpp --- cppad-2018.00.00.0/include/cppad/local/log_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/log_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,202 @@ +# ifndef CPPAD_LOCAL_LOG_OP_HPP +# define CPPAD_LOCAL_LOG_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file log_op.hpp +Forward and reverse mode calculations for z = log(x). +*/ + +/*! +Compute forward mode Taylor coefficient for result of op = LogOp. + +The C++ source code corresponding to this operation is +\verbatim + z = log(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op +*/ +template +void forward_log_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(LogOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LogOp) == 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] = log( x[0] ); + p++; + if( q == 0 ) + return; + } + if ( p == 1 ) + { z[1] = x[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(double(k)) * z[k] * x[j-k]; + z[j] /= Base(double(j)); + z[j] += x[j]; + z[j] /= x[0]; + } +} + +/*! +Muiltiple directions Taylor coefficient for op = LogOp. + +The C++ source code corresponding to this operation is +\verbatim + z = log(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op_dir +*/ +template +void forward_log_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(LogOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LogOp) == 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(double(q)) * x[m+ell]; + for(size_t k = 1; k < q; k++) + z[m+ell] -= Base(double(k)) * z[(k-1)*r+1+ell] * x[(q-k-1)*r+1+ell]; + z[m+ell] /= (Base(double(q)) * x[0]); + } +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = LogOp. + +The C++ source code corresponding to this operation is +\verbatim + z = log(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op_0 +*/ +template +void forward_log_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(LogOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LogOp) == 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] = log( x[0] ); +} + +/*! +Compute reverse mode partial derivatives for result of op = LogOp. + +The C++ source code corresponding to this operation is +\verbatim + z = log(x) +\endverbatim + +\copydetails CppAD::local::reverse_unary1_op +*/ + +template +void reverse_log_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(LogOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(LogOp) == 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_x0 = Base(1.0) / x[0]; + + j = d; + while(j) + { // scale partial w.r.t z[j] + pz[j] = azmul(pz[j] , inv_x0); + + px[0] -= azmul(pz[j], z[j]); + px[j] += pz[j]; + + // further scale partial w.r.t. z[j] + pz[j] /= Base(double(j)); + + for(k = 1; k < j; k++) + { pz[k] -= Base(double(k)) * azmul(pz[j], x[j-k]); + px[j-k] -= Base(double(k)) * azmul(pz[j], z[k]); + } + --j; + } + px[0] += azmul(pz[0], inv_x0); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/mul_op.hpp cppad-2019.02.00.0/include/cppad/local/mul_op.hpp --- cppad-2018.00.00.0/include/cppad/local/mul_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/mul_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,359 @@ +# ifndef CPPAD_LOCAL_MUL_OP_HPP +# define CPPAD_LOCAL_MUL_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file mul_op.hpp +Forward and reverse mode calculations for z = x * y. +*/ + +// --------------------------- Mulvv ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = MulvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x * y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_binary_op +*/ + +template +void forward_mulvv_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(MulvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(MulvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(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.0); + for(k = 0; k <= d; k++) + z[d] += x[d-k] * y[k]; + } +} +/*! +Multiple directions forward mode Taylor coefficients for op = MulvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x * y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_binary_op_dir +*/ + +template +void forward_mulvv_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(MulvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(MulvvOp) == 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 + size_t(arg[0]) * num_taylor_per_var; + Base* y = taylor + size_t(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] = 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]; + } +} + +/*! +Compute zero order forward mode Taylor coefficients for result of op = MulvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x * y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_binary_op_0 +*/ + +template +void forward_mulvv_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(MulvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(MulvvOp) == 1 ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = x[0] * y[0]; +} + +/*! +Compute reverse mode partial derivatives for result of op = MulvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x * y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::reverse_binary_op +*/ + +template +void reverse_mulvv_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(MulvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(MulvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Arguments + const Base* x = taylor + size_t(arg[0]) * cap_order; + const Base* y = taylor + size_t(arg[1]) * cap_order; + + // Partial derivatives corresponding to arguments and result + Base* px = partial + size_t(arg[0]) * nc_partial; + Base* py = partial + size_t(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]); + } + } +} +// --------------------------- Mulpv ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = MulpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x * y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_binary_op +*/ + +template +void forward_mulpv_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(MulpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(MulpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* y = taylor + size_t(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] = x * y[d]; +} +/*! +Multiple directions forward mode Taylor coefficients for op = MulpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x * y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_binary_op_dir +*/ + +template +void forward_mulpv_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(MulpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(MulpvOp) == 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 + size_t(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] = x * y[ell]; +} +/*! +Compute zero order forward mode Taylor coefficient for result of op = MulpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x * y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_binary_op_0 +*/ + +template +void forward_mulpv_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(MulpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(MulpvOp) == 1 ); + + // Paraemter value + Base x = parameter[ arg[0] ]; + + // Taylor coefficients corresponding to arguments and result + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = x * y[0]; +} + +/*! +Compute reverse mode partial derivative for result of op = MulpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x * y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::reverse_binary_op +*/ + +template +void reverse_mulpv_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(MulpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(MulpvOp) == 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 + size_t(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); + } +} + + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/op_code_dyn.hpp cppad-2019.02.00.0/include/cppad/local/op_code_dyn.hpp --- cppad-2018.00.00.0/include/cppad/local/op_code_dyn.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/op_code_dyn.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,171 @@ +# ifndef CPPAD_LOCAL_OP_CODE_DYN_HPP +# define CPPAD_LOCAL_OP_CODE_DYN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file op_code_dyn.hpp +Defines the op_code_dyn enum type + +*/ + +/// Parameter only op codes, at least one operand is a dynamic parameter. +/// The following dynamic parameter operators as in the OpCode enum type: +/// EqppOp, NeppOp, LtppOp, LeppOp +enum op_code_dyn { + abs_dyn, // abs(parameter) + acos_dyn, // acos(parameter) + acosh_dyn, // acosh(parameter) + add_dyn, // parameter + parameter + asin_dyn, // asin(parameter) + asinh_dyn, // asinh(parameter) + atan_dyn, // atan(parameter) + atanh_dyn, // atanh(parameter) + call_dyn, // atomic function call + // arg[0] = atom_index for this function; see call_atomic. + // arg[1] = n ia number of arguments to this atomic function + // arg[2] = m is number of results for this atomic function + // arg[3] = n_dyn is number of results that are dynamic parameters + // arg[4+j] = atomic argument parameter index for j = 0, ..., n + // arg[4+n+i] = atomic result parameter index for i = 0, ..., m + // arg[4+n+m] = 5 + n + m = number arguments to this operator + cond_exp_dyn, // cond_exp(cop, left, right, if_true, if_false) + cos_dyn, // cos(parameter) + cosh_dyn, // cosh(parameter) + dis_dyn, // discrete function (index, parameter) + div_dyn, // parameter / parameter + erf_dyn, // erf(parameter) + exp_dyn, // exp(parameter) + expm1_dyn, // expm1(parameter) + fabs_dyn, // fabs(parameter) + ind_dyn, // independent parameter + log_dyn, // log(parameter) + log1p_dyn, // log1p(parameter) + mul_dyn, // parameter * parameter + pow_dyn, // pow(parameter, parameter) + result_dyn, // atomic function result + sign_dyn, // sign(parameter) + sin_dyn, // sin(parameter) + sinh_dyn, // sinh(parameter) + sqrt_dyn, // sqrt(parameter) + sub_dyn, // parameter - parameter + tan_dyn, // tan(parameter) + tanh_dyn, // tan(parameter) + zmul_dyn, // azmul(parameter, parameter) + number_dyn // number of operator codes (not an operator) +}; +// 2DO: Following operators in OpCode need to be extended to parameter only: +// CExpOp, AFunOp + + +/// number of arguments for each dynamic parameter operator +inline size_t num_arg_dyn(op_code_dyn op) +{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + + static const size_t num_arg_table[] = { + 1, // abs_dyn + 1, // acos_dyn + 1, // acosh_dyn + 2, // add_dyn + 1, // asin_dyn + 1, // asinh_dyn + 1, // atan_dyn + 1, // atanh_dyn + 0, // call_dyn: this operator has a variable number of arguments + 5, // cond_exp_dyn + 1, // cos_dyn + 1, // cosh_dyn + 2, // dis_dyn + 2, // div_dyn + 1, // erf_dyn + 1, // exp_dyn + 1, // expm1_dyn + 1, // fabs_dyn + 0, // ind_dyn + 1, // log_dyn + 1, // log1p_dyn + 2, // mul_dyn + 2, // pow_dyn + 0, // result_dyn + 1, // sign_dyn + 1, // sin_dyn + 1, // sinh_dyn + 1, // sqrt_dyn + 2, // sub_dyn + 1, // tan_dyn + 1, // tanh_dyn + 2, // zmul_dyn + 0 // number_dyn (not used) + }; + static bool first = true; + if( first ) + { CPPAD_ASSERT_UNKNOWN( + size_t(number_dyn)+1 == sizeof(num_arg_table)/sizeof(num_arg_table[0]) + ); + first = false; + } + return num_arg_table[op]; +} + +/// name for each operator +inline const char* op_name_dyn(op_code_dyn op) +{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + + static const char* op_name_table[] = { + "abs", + "acos", + "acosh", + "add", + "asin", + "asinh", + "atan", + "atanh", + "call", + "cond_exp", + "cos", + "cosh", + "dis", + "div", + "erf", + "exp", + "expm1", + "fabs", + "ind", + "log", + "log1p", + "mul", + "pow", + "result", + "sign", + "sin", + "sinh", + "sqrt", + "sub", + "tan", + "tanh", + "zmul", + "number" + }; + static bool first = true; + if( first ) + { CPPAD_ASSERT_UNKNOWN( + size_t(number_dyn)+1 == sizeof(op_name_table)/sizeof(op_name_table[0]) + ); + first = false; + } + return op_name_table[op]; +} + +} } // END_CPPAD_LOCAL_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/op_code.hpp cppad-2019.02.00.0/include/cppad/local/op_code.hpp --- cppad-2018.00.00.0/include/cppad/local/op_code.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/op_code.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1191 @@ +# ifndef CPPAD_LOCAL_OP_CODE_HPP +# define CPPAD_LOCAL_OP_CODE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include +# include + +# include +# include +# include +# include + +// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL +# include + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file op_code.hpp +Defines the OpCode enum type and functions related to it. + +*/ + +/// type used to store OpCodes in vectors +typedef CPPAD_VEC_ENUM_TYPE opcode_t; + + +/*! +Type used to distinguish different AD< Base > atomic operations. + +Each of the operators ends with the characters Op. Ignoring the Op at the end, +the operators appear in alphabetical order. Binary operation where both +operands have type AD< Base > use the following convention for thier endings: +\verbatim + Ending Left-Operand Right-Operand + 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, // fabs(variable) + AcosOp, // acos(variable) + AcoshOp, // acosh(variable) + AddpvOp, // parameter + variable + AddvvOp, // variable + variable + // atomic function operation codes + AFunOp, // start of a atomic function operaiton + // arg[0] = index for this function; see call_atomic. + // arg[1] = extra information passed through by deprecated old atomic class + // arg[2] = number of arguments to this atomic function + // arg[3] = number of results for this atomic function + 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 + // arg[1] & 1 = is left a variable + // 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 + 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[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 + // arg[0] = index of parameter that initializes summation + // arg[1] = end in arg of addition variables in summation + // arg[2] = end in arg of subtraction variables in summation + // arg[3] = end in arg of addition dynamic parameters in summation + // arg[4] = end in arg of subtraction dynamic parameters in summation + // arg[5], ... , arg[arg[1]-1]: indices for addition variables + // arg[arg[1]], ... , arg[arg[2]-1]: indices for subtraction variables + // arg[arg[2]], ... , arg[arg[3]-1]: indices for additon dynamics + // arg[arg[3]], ... , arg[arg[4]-1]: indices for subtraction dynamics + // arg[arg[4]] = arg[4] + DisOp, // discrete::eval(index, variable) + DivpvOp, // parameter / variable + DivvpOp, // variable / parameter + DivvvOp, // variable / variable + EndOp, // used to mark the end of the tape + EqppOp, // parameter == parameter + EqpvOp, // parameter == variable + EqvvOp, // variable == variable + ErfOp, // erf(variable) + ExpOp, // exp(variable) + Expm1Op, // expm1(variable) + FunapOp, // this atomic function argument is a parameter + FunavOp, // this atomic function argument is a variable + FunrpOp, // this atomic function result is a parameter + FunrvOp, // this atomic function result is a variable + InvOp, // independent variable + LdpOp, // z[parameter] (parameter converted to index) + LdvOp, // z[variable] + LeppOp, // parameter <= parameter + LepvOp, // parameter <= variable + LevpOp, // variable <= parameter + LevvOp, // variable <= variable + LogOp, // log(variable) + Log1pOp, // log1p(variable) + LtppOp, // parameter < parameter + LtpvOp, // parameter < variable + LtvpOp, // variable < parameter + LtvvOp, // variable < variable + MulpvOp, // parameter * variable + MulvvOp, // variable * variable + NeppOp, // parameter != parameter + NepvOp, // parameter != variable + NevvOp, // variable != variable + ParOp, // parameter + PowpvOp, // pow(parameter, variable) + PowvpOp, // pow(variable, parameter) + PowvvOp, // pow(variable, variable) + PriOp, // PrintFor(pos, before, value, after) + // arg[0] & 1 = is pos a variable + // arg[0] & 2 = is value a varialbe + // arg[1] = index corresponding to pos + // arg[2] = index corresponding to before + // arg[3] = index corresponding to value + // arg[4] = index corresponding to after + SignOp, // sign(variable) + SinOp, // sin(variable) + SinhOp, // sinh(variable) + SqrtOp, // sqrt(variable) + StppOp, // z[parameter] = parameter (first parameter converted to index) + StpvOp, // z[parameter] = variable (parameter converted to index) + StvpOp, // z[variable] = parameter + StvvOp, // z[variable] = variable + SubpvOp, // parameter - variable + SubvpOp, // variable - parameter + SubvvOp, // variable - variable + TanOp, // tan(variable) + TanhOp, // tan(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 NumberOp occurs +// at the end of this list and only at the end of this list. + +/*! +Number of arguments for a specified operator. + +\return +Number of arguments corresponding to the specified operator. + +\param op +Operator for which we are fetching the number of arugments. + +\par NumArgTable +this table specifes the number of arguments stored for each +occurance of the operator that is the i-th value in the OpCode enum type. +For example, for the first three OpCode enum values we have +\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 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. +*/ +inline size_t NumArg( OpCode op) +{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + + // agreement with OpCode is checked by bin/check_op_code.sh + static const size_t NumArgTable[] = { + 1, // AbsOp + 1, // AcosOp + 1, // AcoshOp + 2, // AddpvOp + 2, // AddvvOp + 4, // AFunOp + 1, // AsinOp + 1, // AsinhOp + 1, // AtanOp + 1, // AtanhOp + 1, // BeginOp offset first real argument to have index 1 + 6, // CExpOp + 1, // CosOp + 1, // CoshOp + 0, // CSkipOp (actually has a variable number of arguments, not zero) + 0, // CSumOp (actually has a variable number of arguments, not zero) + 2, // DisOp + 2, // DivpvOp + 2, // DivvpOp + 2, // DivvvOp + 0, // EndOp + 2, // EqppOp + 2, // EqpvOp + 2, // EqvvOp + 3, // ErfOp + 1, // ExpOp + 1, // Expm1Op + 1, // FunapOp + 1, // FunavOp + 1, // FunrpOp + 0, // FunrvOp + 0, // InvOp + 3, // LdpOp + 3, // LdvOp + 2, // LeppOp + 2, // LepvOp + 2, // LevpOp + 2, // LevvOp + 1, // LogOp + 1, // Log1pOp + 2, // LtppOp + 2, // LtpvOp + 2, // LtvpOp + 2, // LtvvOp + 2, // MulpvOp + 2, // MulvvOp + 2, // NeppOp + 2, // NepvOp + 2, // NevvOp + 1, // ParOp + 2, // PowpvOp + 2, // PowvpOp + 2, // PowvvOp + 5, // PriOp + 1, // SignOp + 1, // SinOp + 1, // SinhOp + 1, // SqrtOp + 3, // StppOp + 3, // StpvOp + 3, // StvpOp + 3, // StvvOp + 2, // SubpvOp + 2, // SubvpOp + 2, // SubvvOp + 1, // TanOp + 1, // TanhOp + 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 ) + { first = false; + // check that NumberOp is last value in op code table + CPPAD_ASSERT_UNKNOWN( + size_t(NumberOp) + 1 == sizeof(NumArgTable)/sizeof(NumArgTable[0]) + ); + //Check that the type CPPAD_VEC_ENUM_TYPE as required by define.hpp + CPPAD_ASSERT_UNKNOWN( is_pod() ); + CPPAD_ASSERT_UNKNOWN( + size_t(NumberOp) < std::numeric_limits::max() + ); + } + // do this check every time + CPPAD_ASSERT_UNKNOWN( size_t(op) < size_t(NumberOp) ); +# endif + + return NumArgTable[op]; +} + +/*! +Number of variables resulting from the specified operation. + +\param op +Operator for which we are fecching the number of results. + +\par NumResTable +table specifes the number of varibles that result for each +occurance of the operator that is the i-th value in the OpCode enum type. +For example, for the first three OpCode enum values we have +\verbatim +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 +AcoshOp 2 2 acosh(x) and sqrt(x*x-1) are required for this op +\endverbatim +*/ +inline size_t NumRes(OpCode op) +{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + + // agreement with OpCode is checked by bin/check_op_code.sh + static const size_t NumResTable[] = { + 1, // AbsOp + 2, // AcosOp + 2, // AcoshOp + 1, // AddpvOp + 1, // AddvvOp + 0, // AFunOp + 2, // AsinOp + 2, // AsinhOp + 2, // AtanOp + 2, // AtanhOp + 1, // BeginOp offsets first variable to have index one (not zero) + 1, // CExpOp + 2, // CosOp + 2, // CoshOp + 0, // CSkipOp + 1, // CSumOp + 1, // DisOp + 1, // DivpvOp + 1, // DivvpOp + 1, // DivvvOp + 0, // EndOp + 0, // EqppOp + 0, // EqpvOp + 0, // EqvvOp + 5, // ErfOp + 1, // ExpOp + 1, // Expm1Op + 0, // FunapOp + 0, // FunavOp + 0, // FunrpOp + 1, // FunrvOp + 1, // InvOp + 1, // LdpOp + 1, // LdvOp + 0, // LeppOp + 0, // LepvOp + 0, // LevpOp + 0, // LevvOp + 1, // LogOp + 1, // Log1pOp + 0, // LtppOp + 0, // LtpvOp + 0, // LtvpOp + 0, // LtvvOp + 1, // MulpvOp + 1, // MulvvOp + 0, // NeppOp + 0, // NepvOp + 0, // NevvOp + 1, // ParOp + 3, // PowpvOp + 3, // PowvpOp + 3, // PowvvOp + 0, // PriOp + 1, // SignOp + 2, // SinOp + 2, // SinhOp + 1, // SqrtOp + 0, // StppOp + 0, // StpvOp + 0, // StvpOp + 0, // StvvOp + 1, // SubpvOp + 1, // SubvpOp + 1, // SubvvOp + 2, // TanOp + 2, // TanhOp + 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) + 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) ); + + return NumResTable[op]; +} + + +/*! +Fetch the name for a specified operation. + +\return +name of the specified operation. + +\param op +Operator for which we are fetching the name +*/ +inline const char* OpName(OpCode op) +{ // agreement with OpCode is checked by bin/check_op_code.sh + static const char *OpNameTable[] = { + "Abs" , + "Acos" , + "Acosh" , + "Addpv" , + "Addvv" , + "AFun" , + "Asin" , + "Asinh" , + "Atan" , + "Atanh" , + "Begin" , + "CExp" , + "Cos" , + "Cosh" , + "CSkip" , + "CSum" , + "Dis" , + "Divpv" , + "Divvp" , + "Divvv" , + "End" , + "Eqpp" , + "Eqpv" , + "Eqvv" , + "Erf" , + "Exp" , + "Expm1" , + "Funap" , + "Funav" , + "Funrp" , + "Funrv" , + "Inv" , + "Ldp" , + "Ldv" , + "Lepp" , + "Lepv" , + "Levp" , + "Levv" , + "Log" , + "Log1p" , + "Ltpp" , + "Ltpv" , + "Ltvp" , + "Ltvv" , + "Mulpv" , + "Mulvv" , + "Nepp" , + "Nepv" , + "Nevv" , + "Par" , + "Powpv" , + "Powvp" , + "Powvv" , + "Pri" , + "Sign" , + "Sin" , + "Sinh" , + "Sqrt" , + "Stpp" , + "Stpv" , + "Stvp" , + "Stvv" , + "Subpv" , + "Subvp" , + "Subvv" , + "Tan" , + "Tanh" , + "Zmulpv", + "Zmulvp", + "Zmulvv", + "Number" // not used + }; + // check ensuring conversion to size_t is as expected + 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) ); + + return OpNameTable[op]; +} + +/*! +Prints a single field corresponding to an operator. + +A specified leader is printed in front of the value +and then the value is left justified in the following width character. + +\tparam Type +is the type of the value we are printing. + +\param os +is the stream that we are printing to. + +\param leader +are characters printed before the value. + +\param value +is the value being printed. + +\param width +is the number of character to print the value in. +If the value does not fit in the width, the value is replace +by width '*' characters. +*/ +template +void printOpField( + std::ostream &os , + const char * leader , + const Type &value , + size_t width ) +{ + std::ostringstream buffer; + std::string str; + + // first print the leader + os << leader; + + // print the value into an internal buffer + buffer << std::setw( int(width) ) << value; + str = buffer.str(); + + // length of the string + size_t len = str.size(); + if( len > width ) + { + for(size_t i = 0; i < width-1; i++) + os << str[i]; + os << "*"; + return; + } + + // count number of spaces at begining + size_t nspace = 0; + while(str[nspace] == ' ' && nspace < len) + nspace++; + + // left justify the string + size_t i = nspace; + while( i < len ) + os << str[i++]; + + i = width - len + nspace; + while(i--) + os << " "; +} + +/*! +Prints a single operator and its operands + +\tparam Base +Is the base type for these AD< Base > operations. + +\param os +is the output stream that the information is printed on. + +\param play +Is the entire recording for the tape that this operator is in. + +\param i_op +is the index for the operator corresponding to this operation. + +\param i_var +is the index for the variable corresponding to the result of this operation +(if NumRes(op) > 0). + +\param op +The operator code (OpCode) for this operation. + +\param arg +is the vector of argument indices for this operation +(must have NumArg(op) elements). +*/ +template +void printOp( + std::ostream& os , + const local::player* play, + size_t i_op , + size_t i_var , + OpCode op , + const addr_t* arg ) +{ + CPPAD_ASSERT_KNOWN( + ! thread_alloc::in_parallel() , + "cannot print trace of AD operations in parallel mode" + ); + static const char *CompareOpName[] = + { "Lt", "Le", "Eq", "Ge", "Gt", "Ne" }; + + // print operator + printOpField(os, "o=", i_op, 5); + if( NumRes(op) > 0 && op != BeginOp ) + printOpField(os, "v=", i_var, 5); + else + printOpField(os, "v=", "", 5); + if( op == CExpOp || op == CSkipOp ) + { printOpField(os, "", OpName(op), 5); + printOpField(os, "", CompareOpName[ arg[0] ], 3); + } + else + printOpField(os, "", OpName(op), 8); + + // print other fields + size_t ncol = 5; + switch( op ) + { + case CSkipOp: + /* + 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[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] + */ + CPPAD_ASSERT_UNKNOWN( arg[6+arg[4]+arg[5]] == arg[4]+arg[5] ); + CPPAD_ASSERT_UNKNOWN(arg[1] != 0); + if( arg[1] & 1 ) + printOpField(os, " vl=", arg[2], ncol); + else + printOpField(os, " pl=", play->GetPar(arg[2]), ncol); + if( arg[1] & 2 ) + printOpField(os, " vr=", arg[3], ncol); + else + printOpField(os, " pr=", play->GetPar(arg[3]), ncol); + if( size_t(arg[4]) < 3 ) + { for(addr_t i = 0; i < arg[4]; i++) + printOpField(os, " ot=", arg[6+i], ncol); + } + else + { printOpField(os, "\n\tot=", arg[6+0], ncol); + for(addr_t i = 1; i < arg[4]; i++) + printOpField(os, " ot=", arg[6+i], ncol); + } + if( size_t(arg[5]) < 3 ) + { for(addr_t i = 0; i < arg[5]; i++) + printOpField(os, " of=", arg[6+arg[4]+i], ncol); + } + else + { printOpField(os, "\n\tof=", arg[6+arg[4]+0], ncol); + { for(addr_t i = 1; i < arg[5]; i++) + printOpField(os, " of=", arg[6+arg[4]+i], ncol); + } + } + break; + + case CSumOp: + /* + arg[0] = index of parameter that initializes summation + arg[1] = end in arg of addition variables in summation + arg[2] = end in arg of subtraction variables in summation + arg[3] = end in arg of addition dynamic parameters in summation + arg[4] = end in arg of subtraction dynamic parameters in summation + arg[5], ... , arg[arg[1]-1]: indices for addition variables + arg[arg[1]], ... , arg[arg[2]-1]: indices for subtraction variables + arg[arg[2]], ... , arg[arg[3]-1]: indices for additon dynamics + arg[arg[3]], ... , arg[arg[4]-1]: indices for subtraction dynamics + arg[arg[4]] = arg[4] + */ + CPPAD_ASSERT_UNKNOWN( arg[arg[4]] == arg[4] ); + printOpField(os, " pr=", play->GetPar(arg[0]), ncol); + for(addr_t i = 5; i < arg[1]; i++) + printOpField(os, " +v=", arg[i], ncol); + for(addr_t i = arg[1]; i < arg[2]; i++) + printOpField(os, " -v=", arg[i], ncol); + for(addr_t i = arg[2]; i < arg[3]; i++) + printOpField(os, " +d=", play->GetPar(arg[i]), ncol); + for(addr_t i = arg[3]; i < arg[4]; i++) + printOpField(os, " -d=", play->GetPar(arg[i]), ncol); + break; + + case LdpOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + printOpField(os, "off=", arg[0], ncol); + printOpField(os, "idx=", arg[1], ncol); + break; + + case LdvOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + printOpField(os, "off=", arg[0], ncol); + printOpField(os, " v=", arg[1], ncol); + break; + + case StppOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + printOpField(os, "off=", arg[0], ncol); + printOpField(os, "idx=", arg[1], ncol); + printOpField(os, " pr=", play->GetPar(arg[2]), ncol); + break; + + case StpvOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + printOpField(os, "off=", arg[0], ncol); + printOpField(os, "idx=", arg[1], ncol); + printOpField(os, " vr=", arg[2], ncol); + break; + + case StvpOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + printOpField(os, "off=", arg[0], ncol); + printOpField(os, " vl=", arg[1], ncol); + printOpField(os, " pr=", play->GetPar(arg[2]), ncol); + break; + + case StvvOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + printOpField(os, "off=", arg[0], ncol); + printOpField(os, " vl=", arg[1], ncol); + printOpField(os, " vr=", arg[2], ncol); + break; + + 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=", arg[0], ncol); + printOpField(os, " vr=", arg[1], ncol); + break; + + case AddpvOp: + case EqpvOp: + case DivpvOp: + case LepvOp: + case LtpvOp: + case NepvOp: + case SubpvOp: + case MulpvOp: + case PowpvOp: + case ZmulpvOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); + printOpField(os, " pl=", play->GetPar(arg[0]), ncol); + printOpField(os, " vr=", arg[1], ncol); + break; + + case DivvpOp: + case LevpOp: + case LtvpOp: + case PowvpOp: + case SubvpOp: + case ZmulvpOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); + printOpField(os, " vl=", arg[0], ncol); + printOpField(os, " pr=", play->GetPar(arg[1]), ncol); + break; + + 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: + case SqrtOp: + case FunavOp: + case TanOp: + case TanhOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + printOpField(os, " v=", arg[0], ncol); + break; + + case ErfOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + // arg[1] points to the parameter 0 + // arg[2] points to the parameter 2 / sqrt(pi) + printOpField(os, " v=", arg[0], ncol); + break; + + case ParOp: + case FunapOp: + case FunrpOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + printOpField(os, " p=", play->GetPar(arg[0]), ncol); + break; + + case AFunOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 4 ); + { + // get the name of this atomic function + bool set_null = false; + size_t atom_index = size_t( arg[0] ); + size_t type = 0; // set to avoid warning + std::string name; + void* v_ptr = CPPAD_NULL; // set to avoid warning + atomic_index(set_null, atom_index, type, &name, v_ptr); + printOpField(os, " f=", name.c_str(), ncol); + printOpField(os, " i=", arg[1], ncol); + printOpField(os, " n=", arg[2], ncol); + printOpField(os, " m=", arg[3], ncol); + } + break; + + case PriOp: + CPPAD_ASSERT_NARG_NRES(op, 5, 0); + if( arg[0] & 1 ) + printOpField(os, " v=", arg[1], ncol); + else + printOpField(os, " p=", play->GetPar(arg[1]), ncol); + os << "before=\"" << play->GetTxt(arg[2]) << "\""; + if( arg[0] & 2 ) + printOpField(os, " v=", arg[3], ncol); + else + printOpField(os, " p=", play->GetPar(arg[3]), ncol); + os << "after=\"" << play->GetTxt(arg[4]) << "\""; + break; + + case BeginOp: + // argument not used (created by independent) + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + break; + + case EndOp: + case InvOp: + case FunrvOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 0 ); + break; + + case DisOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); + { const char* name = discrete::name(arg[0]); + printOpField(os, " f=", name, ncol); + printOpField(os, " x=", arg[1], ncol); + } + break; + + + case CExpOp: + CPPAD_ASSERT_UNKNOWN(arg[1] != 0); + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 6 ); + if( arg[1] & 1 ) + printOpField(os, " vl=", arg[2], ncol); + else + printOpField(os, " pl=", play->GetPar(arg[2]), ncol); + if( arg[1] & 2 ) + printOpField(os, " vr=", arg[3], ncol); + else + printOpField(os, " pr=", play->GetPar(arg[3]), ncol); + if( arg[1] & 4 ) + printOpField(os, " vt=", arg[4], ncol); + else + printOpField(os, " pt=", play->GetPar(arg[4]), ncol); + if( arg[1] & 8 ) + printOpField(os, " vf=", arg[5], ncol); + else + printOpField(os, " pf=", play->GetPar(arg[5]), ncol); + break; + + case EqppOp: + case LeppOp: + case LtppOp: + case NeppOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); + printOpField(os, " pl=", play->GetPar(arg[0]), ncol); + printOpField(os, " pr=", play->GetPar(arg[1]), ncol); + break; + + default: + CPPAD_ASSERT_UNKNOWN(0); + } +} + +/*! +Prints the result values correspnding to an operator. + +\tparam Base +Is the base type for these AD< Base > operations. + +\tparam Value +Determines the type of the values that we are printing. + +\param os +is the output stream that the information is printed on. + +\param nfz +is the number of forward sweep calculated values of type Value +that correspond to this operation +(ignored if NumRes(op) == 0). + +\param fz +points to the first forward calculated value +that correspond to this operation +(ignored if NumRes(op) == 0). + +\param nrz +is the number of reverse sweep calculated values of type Value +that correspond to this operation +(ignored if NumRes(op) == 0). + +\param rz +points to the first reverse calculated value +that correspond to this operation +(ignored if NumRes(op) == 0). +*/ +template +void printOpResult( + std::ostream &os , + size_t nfz , + const Value *fz , + size_t nrz , + const Value *rz ) +{ + size_t k; + for(k = 0; k < nfz; k++) + os << "| fz[" << k << "]=" << fz[k]; + for(k = 0; k < nrz; k++) + os << "| rz[" << k << "]=" << rz[k]; +} + +/*! +Determines which arguments are variaibles for an operator. + +\param op +is the operator. Note that CSkipOp and CSumOp are special cases +because the true number of arguments is not equal to NumArg(op) +and the true number of arguments num_arg can be large. +It may be more efficient to handle these cases separately +(see below). + +\param arg +is the argument vector for this operator. + +\param is_variable +If the input value of the elements in this vector do not matter. +Upon return, resize has been used to set its size to the true number +of arguments to this operator. +If op != CSkipOp and op != CSumOp, is_variable.size() = NumArg(op). +The j-th argument for this operator is a +variable index if and only if is_variable[j] is true. Note that the variable +index 0, for the BeginOp, does not correspond to a real variable and false +is returned for this case. + +\par CSkipOp +In the case of CSkipOp, +\code + is_variable.size() = 7 + arg[4] + arg[5]; + is_variable[2] = (arg[1] & 1) != 0; + is_variable[3] = (arg[1] & 2) != 0; +\endcode +and all the other is_variable[j] values are false. + +\par CSumOp +In the case of CSumOp, +\code + is_variable.size() = arg[4] + for(size_t j = 5; j < arg[2]; ++j) + is_variable[j] = true; +\endcode +and all the other is_variable values are false. +*/ +template +void arg_is_variable( + OpCode op , + const Addr* arg , + pod_vector& is_variable ) +{ size_t num_arg = NumArg(op); + is_variable.resize( num_arg ); + // + switch(op) + { + // ------------------------------------------------------------------- + // cases where true number of arugments = NumArg(op) == 0 + + case EndOp: + case InvOp: + case FunrvOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 0 ); + break; + + // ------------------------------------------------------------------- + // cases where NumArg(op) == 1 + case AbsOp: + case AcoshOp: + case AcosOp: + case AsinhOp: + case AsinOp: + case AtanhOp: + case AtanOp: + case CoshOp: + case CosOp: + case Expm1Op: + case ExpOp: + case Log1pOp: + case LogOp: + case SignOp: + case SinhOp: + case SinOp: + case SqrtOp: + case TanhOp: + case TanOp: + case FunavOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + is_variable[0] = true; + break; + + case BeginOp: + case ParOp: + case FunapOp: + case FunrpOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + is_variable[0] = false; + break; + + + // ------------------------------------------------------------------- + // cases where NumArg(op) == 2 + + case AddpvOp: + case DisOp: + case DivpvOp: + case EqpvOp: + case LepvOp: + case LtpvOp: + case MulpvOp: + case NepvOp: + case PowpvOp: + case SubpvOp: + case ZmulpvOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); + is_variable[0] = false; + is_variable[1] = true; + break; + + case DivvpOp: + case LevpOp: + case LtvpOp: + case PowvpOp: + case SubvpOp: + case ZmulvpOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); + is_variable[0] = true; + is_variable[1] = false; + break; + + case AddvvOp: + case DivvvOp: + case EqvvOp: + case LevvOp: + case LtvvOp: + case MulvvOp: + case NevvOp: + case PowvvOp: + case SubvvOp: + case ZmulvvOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); + is_variable[0] = true; + is_variable[1] = true; + break; + + case ErfOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + is_variable[0] = true; + is_variable[1] = false; // parameter index corresponding to zero + is_variable[2] = false; // parameter index corresponding to one + break; + + // -------------------------------------------------------------------- + // cases where NumArg(op) == 3 + + case LdpOp: + case StppOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + is_variable[0] = false; + is_variable[1] = false; + is_variable[2] = false; + break; + + case LdvOp: + case StvpOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + is_variable[0] = false; + is_variable[1] = true; + is_variable[2] = false; + break; + + case StpvOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + is_variable[0] = false; + is_variable[1] = false; + is_variable[2] = true; + break; + + case StvvOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + is_variable[0] = false; + is_variable[1] = true; + is_variable[2] = true; + break; + + // -------------------------------------------------------------------- + // case where NumArg(op) == 4 + case AFunOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 4 ); + for(size_t i = 0; i < 4; i++) + is_variable[i] = false; + break; + + // -------------------------------------------------------------------- + // case where NumArg(op) == 5 + case PriOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 5 ); + is_variable[0] = false; + is_variable[1] = (arg[0] & 1) != 0; + is_variable[2] = false; + is_variable[3] = (arg[0] & 2) != 0; + is_variable[4] = false; + break; + + // -------------------------------------------------------------------- + // case where NumArg(op) == 6 + case CExpOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 6 ); + is_variable[0] = false; + is_variable[1] = false; + is_variable[2] = (arg[0] & 1) != 0; + is_variable[3] = (arg[0] & 2) != 0; + is_variable[4] = (arg[0] & 4) != 0; + is_variable[5] = (arg[0] & 8) != 0; + break; + + // ------------------------------------------------------------------- + // CSkipOp: + case CSkipOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 0 ) + // + // true number of arguments + num_arg = size_t(7 + arg[4] + arg[5]); + is_variable.resize(num_arg); + is_variable[0] = false; + is_variable[1] = false; + is_variable[2] = (arg[1] & 1) != 0; + is_variable[3] = (arg[1] & 2) != 0; + for(size_t i = 4; i < num_arg; ++i) + is_variable[i] = false; + break; + + // ------------------------------------------------------------------- + // CSumOp: + case CSumOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 0 ) + // + // true number of arguments + num_arg = size_t(arg[4]); + // + is_variable.resize( num_arg ); + for(size_t i = 0; i < num_arg; ++i) + is_variable[i] = (5 <= i) & (i < size_t(arg[2])); + break; + + case EqppOp: + case LeppOp: + case LtppOp: + case NeppOp: + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); + is_variable[0] = false; + is_variable[1] = false; + break; + + // -------------------------------------------------------------------- + default: + CPPAD_ASSERT_UNKNOWN(false); + break; + } + return; +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/op.hpp cppad-2019.02.00.0/include/cppad/local/op.hpp --- cppad-2018.00.00.0/include/cppad/local/op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,59 @@ +# ifndef CPPAD_LOCAL_OP_HPP +# define CPPAD_LOCAL_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// used by the sparse operators +# include + +// operations +# 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 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/cexp_info.hpp cppad-2019.02.00.0/include/cppad/local/optimize/cexp_info.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/cexp_info.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/cexp_info.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,77 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_CEXP_INFO_HPP +# define CPPAD_LOCAL_OPTIMIZE_CEXP_INFO_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include // defines CompareOp +# include + +/*! +\file cexp_info.hpp +Information about one conditional expression. +*/ + +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { +/*! +Information about one conditional expression. +*/ +struct struct_cexp_info { + /// The operator index for this conditional expression operation + addr_t i_op; + + /// variable or parameter index for left comparison operand + addr_t left; + + /// variable or parameter index for right comparison operand + addr_t right; + + /// maximum variable index between left and right (ignoring parameters). + addr_t max_left_right; + + /// set of operator that are not used when comparison result is true + /// Note that FunapOp, FunavOp, FunrpOp, and FunrvOp, are not in this + /// vector and should be skipped when the corresponding AFunOp are skipped. + CppAD::vector skip_op_true; + + /// set of variables that are not used when comparison result is false + /// Note that FunapOp, FunavOp, FunrpOp, and FunrvOp, are not in this + /// vector and should be skipped when the corresponding AFunOp are skipped. + CppAD::vector skip_op_false; + + /// comparision operator for this conditional expression + CompareOp cop; + + /// (flag & 1) is true if and only if left is a variable + /// (flag & 2) is true if and only if right is a variable + unsigned char flag; +}; + +// Information about the conditional skip in the new operation sequence +struct struct_cskip_new { + /// new variable or parameter index for left comparison operand + size_t left; + /// new variable or parameter index for right comparison operand + size_t right; + /// maximum variable index between left and right (ignoring parameters). + size_t max_left_right; + /// index where this conditional skips arguments start + size_t i_arg; +}; + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + +namespace CppAD { namespace local { + template <> inline bool is_pod(void) + { return true; } +} } + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/csum_op_info.hpp cppad-2019.02.00.0/include/cppad/local/optimize/csum_op_info.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/csum_op_info.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/csum_op_info.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,42 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_CSUM_OP_INFO_HPP +# define CPPAD_LOCAL_OPTIMIZE_CSUM_OP_INFO_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include // defines addr_t + +/*! +\file csum_op_info.hpp +Information about one old variable that is part of a new CSumOp operation. +*/ + +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { +/*! +Information about one old variable that is part of a new CSumOp operation. +*/ +struct struct_csum_op_info { + /// Pointer to first argument (child) for this old operator. + /// Set by the reverse sweep at beginning of optimization. + const addr_t* arg; + + /// Was this old variable added to the summation + /// (if not it was subtracted) + bool add; + + /// Operator for which this old variable is the result, NumRes(op) > 0. + OpCode op; +}; + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/csum_stacks.hpp cppad-2019.02.00.0/include/cppad/local/optimize/csum_stacks.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/csum_stacks.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/csum_stacks.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,47 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_CSUM_STACKS_HPP +# define CPPAD_LOCAL_OPTIMIZE_CSUM_STACKS_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include + +/*! +\file csum_stacks.hpp +Information about one cumulative summation operation. +*/ + +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { +/*! +Information about one cumulative summation operation. +*/ +struct struct_csum_stacks { + + /// old operator indices for this cummulative summation + std::stack op_info; + + /// old variable indices to be added + std::stack add_var; + + /// old variable indices to be subtracted + std::stack sub_var; + + /// dynamic parameter indices to be added + std::stack add_dyn; + + /// dynamic parameter indices to be subtracted + std::stack sub_dyn; +}; + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/get_cexp_info.hpp cppad-2019.02.00.0/include/cppad/local/optimize/get_cexp_info.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/get_cexp_info.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/get_cexp_info.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,223 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_GET_CEXP_INFO_HPP +# define CPPAD_LOCAL_OPTIMIZE_GET_CEXP_INFO_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file get_cexp_info.hpp +Create operator information tables +*/ + +# include +# include +# include + +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { + +/*! +Convert conditional expression skip information from sets for each +operation to sets for each conditional expression operator. +Do not call this routine unless you are optimizing conditional expressions +and there are conditional expressions in the operation sequence. + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param play +This is the old operation sequence. + +\param random_itr +This is a random iterator for the old operation sequence. + +\param cexp2op +This is the number of conditional expressions in the operation sequence +and must be non-zero. + +\param cexp_set +This is a vector of sets that is empty on input. +Otherwise, set[i] is a set of elements for the i-th operator. +Suppose that e is an element of set[i], j = e / 2, k = e % 2. +If the comparision for the j-th conditional expression is equal to bool(k), +the i-th operator can be skipped (is not used by any of the results). +Note the the j indexs the CExpOp operators in the operation sequence. + +\param cexp_info +The input size of this vector must be zero. +Otherwise, +upon return cexp_info has size equal to the number of conditional expressions +in the operation sequence; i.e., the number of CExpOp operators. +The value cexp_info[j] is the information corresponding to the j-th +conditional expression in the operation sequence. +This vector is in the same order as the operation sequence; i.e. +if j1 > j2, cexp_info[j1].i_op > cexp_info[j2].i_op. +Note that skip_op_true and skip_op_false could be part of this structure, +but then we would allocate and deallocate two vectors for each conditonal +expression in the operation sequence. + +\param skip_op_true +This vector of sets is empty on input. +Upon return, the j-th set is the operators that are not used when +comparison result for cexp_info[j] is true. +Note that FunapOp, FunavOp, FunrpOp, and FunrvOp, are not in this +set and should be skipped when the corresponding AFunOp are skipped. + +\param skip_op_false +This vector of sets is empty on input. +Upon return, the j-th set is the operators that are not used when +comparison result for cexp_info[j] is false. +Note that FunapOp, FunavOp, FunrpOp, and FunrvOp, are not in this +set and should be skipped when the corresponding AFunOp are skipped. + +\param op_previous +The input size of this vector must be zero. +Upon return it has size equal to the number of operators +in the operation sequence; i.e., num_op = play->nun_var_rec(). +If op_previous[i] == 0, no replacement was found for the i-th operator. +If op_previous[i] != 0, op_usage[ op_previous[i] ] == usage_t(yes_usage). + +\param op_usage +The input size of this vector must be zero. +Upon return it has size equal to the number of operators +in the operation sequence; i.e., num_op = play->nun_var_rec(). +The value op_usage[i] +have been set to the usage for +the i-th operator in the operation sequence. +*/ + +template +void get_cexp_info( + const player* play , + const play::const_random_iterator& random_itr , + const pod_vector& op_previous , + const pod_vector& op_usage , + const pod_vector& cexp2op , + const sparse_list& cexp_set , + vector& cexp_info , + sparse_list& skip_op_true , + sparse_list& skip_op_false ) +{ + CPPAD_ASSERT_UNKNOWN( cexp_set.n_set() > 0 ); + CPPAD_ASSERT_UNKNOWN( cexp_info.size() == 0 ); + + // number of operators in the tape + const size_t num_op = play->num_op_rec(); + CPPAD_ASSERT_UNKNOWN( op_usage.size() == num_op ); + CPPAD_ASSERT_UNKNOWN( op_previous.size() == num_op ); + // + // number of conditional expressions in the tape + size_t num_cexp_op = cexp2op.size(); + // + // initialize mapping from variable index to operator index + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= num_op + ); + // ---------------------------------------------------------------------- + // compute cexp_info + // ---------------------------------------------------------------------- + // + // initialize information for each conditional expression + cexp_info.resize(num_cexp_op); + skip_op_true.resize(num_cexp_op, num_op); + skip_op_false.resize(num_cexp_op, num_op); + // + for(size_t i = 0; i < num_cexp_op; i++) + { size_t i_op = size_t( cexp2op[i] ); + CPPAD_ASSERT_UNKNOWN( + op_previous[i_op] == 0 || op_usage[i_op] == usage_t(yes_usage) + ); + OpCode op; // operator + const addr_t* arg; // arguments + size_t i_var; // variable index of first result + random_itr.op_info(i_op, op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == CExpOp ); + // + struct_cexp_info info; + info.i_op = addr_t(i_op); + info.cop = CompareOp( arg[0] ); + info.flag = static_cast(arg[1]); + info.left = arg[2]; + info.right = arg[3]; + // + // max_left_right + addr_t index = 0; + if( arg[1] & 1 ) + index = std::max(index, info.left); + if( arg[1] & 2 ) + index = std::max(index, info.right); + CPPAD_ASSERT_UNKNOWN( index > 0 ); + info.max_left_right = index; + // + cexp_info[i] = info; + }; + // Determine which operators can be conditionally skipped + size_t i_op = 0; + while(i_op < num_op) + { size_t j_op = i_op; + bool keep = op_usage[i_op] != usage_t(no_usage); + keep &= op_usage[i_op] != usage_t(csum_usage); + keep &= op_previous[i_op] == 0; + if( keep ) + { sparse_list_const_iterator itr(cexp_set, i_op); + if( *itr != cexp_set.end() ) + { if( play->GetOp(i_op) == AFunOp ) + { // i_op is the first operations in this atomic function call. + // Find the last operation in this call. + ++j_op; + while( play->GetOp(j_op) != AFunOp ) + { switch( play->GetOp(j_op) ) + { case FunapOp: + case FunavOp: + case FunrpOp: + case FunrvOp: + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + } + ++j_op; + } + } + } + while( *itr != cexp_set.end() ) + { size_t element = *itr; + size_t index = element / 2; + bool compare = bool( element % 2 ); + if( compare == false ) + { // cexp_info[index].skip_op_false.push_back(i_op); + skip_op_false.add_element(index, i_op); + if( j_op != i_op ) + { // cexp_info[index].skip_op_false.push_back(j_op); + skip_op_false.add_element(index, j_op); + } + } + else + { // cexp_info[index].skip_op_true.push_back(i_op); + skip_op_true.add_element(index, i_op); + if( j_op != i_op ) + { // cexp_info[index].skip_op_true.push_back(j_op); + skip_op_true.add_element(index, j_op); + } + } + ++itr; + } + } + CPPAD_ASSERT_UNKNOWN( i_op <= j_op ); + i_op += (1 + j_op) - i_op; + } + return; +} + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/get_dyn_previous.hpp cppad-2019.02.00.0/include/cppad/local/optimize/get_dyn_previous.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/get_dyn_previous.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/get_dyn_previous.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,441 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_GET_DYN_PREVIOUS_HPP +# define CPPAD_LOCAL_OPTIMIZE_GET_DYN_PREVIOUS_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file get_cexp_info.hpp +Create operator information tables +*/ + +# include +# include +# include + +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { + +/*! +mapping from a dynamic parameter index to its arguments + +\param i_dyn +is the dynamic parameter index + +\param dyn_ind2par_ind +is the mapping from dynamic parameter index to parameter index +(size is number of dynamic parameters). + +\param dyn_par_is +i-th element is true (false) if i-th parameter is (is not) dynamic +(size is number of parameters). + +\param dyn_arg_offset +j-th element is the offset in dyn_par_arg of the first argument for j-th +dynamic parameter's operator (size is number of dynamic parameters). +This is only defined for dynamic parameters indices less than or equal i_dyn. + +\param dyn_par_arg +it the vector of arguments for all the dynamic parameter operators. +This is only defined for dynamic parameters indices less than or equal i_dyn. + +\param par_ind2dyn_ind +is the mapping from parameter index to dynamic parameter index +(size is number of parameters). This is only defined for parameter +indices less than or equal the parameter index corresponding to i_dyn. + +\param dyn_previous +is the mapping from dynamic parameter index to previous dynamic parameter +that can be used as a replacement (size is number of dynamic parameters). +This is only defined for dynamic parameters indices less than or equal i_dyn. + +\param arg_match +Size of this vector must be number of arguments for operator for i_dyn. +The input value of its elements does not matter. +Upn return it containts the parameter indices for the arguments +to use when matching this operator +Arguments that are dynamic prarameters, and have previous matches, +have been replaced by their previous matches. +*/ +inline void dyn_arg_match( + size_t i_dyn , + const pod_vector& dyn_ind2par_ind , + const pod_vector & dyn_par_is , + const pod_vector& dyn_arg_offset , + const pod_vector& dyn_par_arg , + const pod_vector& par_ind2dyn_ind , + const pod_vector& dyn_previous , + pod_vector& arg_match ) +{ + // number of dynamic parameters + addr_t num_dynamic_par = addr_t( dyn_ind2par_ind.size() ); + // + // check some assumptions + CPPAD_ASSERT_UNKNOWN( size_t( num_dynamic_par ) == dyn_arg_offset.size() ); + CPPAD_ASSERT_UNKNOWN( size_t( num_dynamic_par ) == dyn_previous.size() ); + CPPAD_ASSERT_UNKNOWN( dyn_par_is.size() == par_ind2dyn_ind.size() ); + // + // number of arguments for this operator + addr_t n_arg = addr_t( arg_match.size() ); + // + // index in dyn_par_arg of first argument for this operator + addr_t i_arg = dyn_arg_offset[i_dyn]; + // + // loop over arguments for this operator + for(addr_t j = 0; j < n_arg; ++j) + { // parameter index for this argument + addr_t j_par = dyn_par_arg[i_arg + j]; + CPPAD_ASSERT_UNKNOWN( j_par < dyn_ind2par_ind[i_dyn] ); + // + // map dynamic parameters arguments to previous matches + if( dyn_par_is[j_par] ) + { addr_t j_dyn = par_ind2dyn_ind[j_par]; + if( dyn_previous[j_dyn] != num_dynamic_par ) + { CPPAD_ASSERT_UNKNOWN( dyn_previous[j_dyn] < j_dyn ); + // previous dynamic parameter + j_dyn = dyn_previous[j_dyn]; + // correspoding parameter + j_par = dyn_ind2par_ind[j_dyn]; + } + } + arg_match[j] = j_par; + } + return; +} + +/*! +Get mapping from each dynamic parameter to a previous dynamic parameter +that can be used to replace it (if one exists). + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param play +This is the old operation sequence. + +\param random_itr +This is a random iterator for the old operation sequence. + +\param par_usage +The size of this vector is the number of parameters in the +operation sequence.i.e., play->nun_var_rec(). +It is the usage counting previous operator optimization of operators. + +\param dyn_previous +The input size of this vector must be zero. +Upon return it has size equal to the number of dynamic parameters in the +operation sequence; i.e., num_dyn = play->num_dynamic_par(). +Let k = dyn_parvious[j]. If k == num_dyn, no replacement was found for the +j-th dynamic parameter. If k != num_dyn, the k-th dynamic parameter can be +used in place of the j-th dynamic parameter, k < j, dyn_previous[k] != num_dyn, +par_usage[dyn_ind2par_ind[k]] == true. +*/ + +template +void get_dyn_previous( + const player* play , + const play::const_random_iterator& random_itr , + pod_vector& par_usage , + pod_vector& dyn_previous ) +{ + // number of parameters in the recording + size_t num_par = play->num_par_rec(); + + // number of dynamic parameters in the recording + size_t num_dynamic_par = play->num_dynamic_par(); + + // number of independent dynamic parameters in the recording + size_t num_dynamic_ind = play->num_dynamic_ind(); + + // check some assumptions + CPPAD_ASSERT_UNKNOWN( dyn_previous.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( par_usage.size() == num_par ); + CPPAD_ASSERT_UNKNOWN( num_dynamic_par <= num_par ); + CPPAD_ASSERT_UNKNOWN( num_dynamic_ind <= num_dynamic_par ); + CPPAD_ASSERT_UNKNOWN( num_arg_dyn( ind_dyn ) == 0 ); + + // dynamic parameter information + dyn_previous.resize( num_dynamic_par ); + const pod_vector& dyn_ind2par_ind( play->dyn_ind2par_ind() ); + const pod_vector& dyn_par_is( play->dyn_par_is() ); + const pod_vector& dyn_par_op( play->dyn_par_op() ); + const pod_vector& dyn_par_arg( play->dyn_par_arg() ); + + // mapping from parameter index to dynamic parameter index + // only defined when dyn_par_is is true + pod_vector par_ind2dyn_ind(num_par); + + // mapping from dynamic parameter index to first argument index + pod_vector dyn_arg_offset(num_dynamic_par); + + // ---------------------------------------------------------------------- + // compute dyn_previous + // ---------------------------------------------------------------------- + sparse_list hash_table_dyn; + hash_table_dyn.resize(CPPAD_HASH_TABLE_SIZE, num_dynamic_par); + // + // Initialize in dyn_par_arg + // (independent dynamic parameters do not have any arguments) + size_t i_arg = 0; + // + // independent dynamic parameters + for(size_t i_dyn = 0; i_dyn < num_dynamic_ind; ++i_dyn) + { // parameter index + size_t i_par = size_t( dyn_ind2par_ind[i_dyn] ); + // dynamic parameter index is one greater because phantom parameter + // at index 0 is not dynamic + CPPAD_ASSERT_UNKNOWN( i_par == i_dyn + 1 ); + // mapping from parameter index to dynamic parameter index + par_ind2dyn_ind[i_par] = addr_t( i_dyn ); + // never get optimized out + dyn_previous[i_dyn] = addr_t( num_dynamic_par ); + } + // + // other dynamic parameters + for(size_t i_dyn = num_dynamic_ind; i_dyn < num_dynamic_par; ++i_dyn) + { // Initialize previous for this dynamic parameter. This is only + // defined for dynamic parameter indices less than or equal i_dyn + dyn_previous[i_dyn] = addr_t( num_dynamic_par ); + // + // mapping from dynamic parameter index to argument offset + // is only defined for j_dyn <= i_dyn + dyn_arg_offset[i_dyn] = addr_t( i_arg ); + // + // parameter index for this dynamic parameter + size_t i_par = size_t( dyn_ind2par_ind[i_dyn] ); + // + // mapping from parameter indices to dynamic parameter indices + // is only defined when dyn_par_is[i_par] is true and for parameter + // indices less than or equal i_par + CPPAD_ASSERT_UNKNOWN( dyn_par_is[i_par] ); + par_ind2dyn_ind[i_par] = addr_t( i_dyn ); + // + // operator for this dynamic parameter + op_code_dyn op = op_code_dyn( dyn_par_op[i_dyn] ); + // + // temporary used below and decaled here to reduce memory allocation + pod_vector arg_match; + // + // temporaries used below and decaled here to reduce indentation level + bool match; + size_t code; + size_t count; + // + // check for a previous match for i_dyn + if( par_usage[i_par] ) switch( op ) + { + // --------------------------------------------------------------- + // unary operators + case abs_dyn: + case acos_dyn: + case acosh_dyn: + case asin_dyn: + case asinh_dyn: + case atan_dyn: + case atanh_dyn: + case cos_dyn: + case cosh_dyn: + case erf_dyn: + case exp_dyn: + case expm1_dyn: + case fabs_dyn: + case log_dyn: + case log1p_dyn: + case sign_dyn: + case sin_dyn: + case sinh_dyn: + case sqrt_dyn: + case tan_dyn: + case tanh_dyn: + CPPAD_ASSERT_UNKNOWN( num_arg_dyn(op) == 1); + CPPAD_ASSERT_UNKNOWN( dyn_par_is[i_par] ); + { size_t num_arg = 1; + arg_match.resize(num_arg); + dyn_arg_match( + i_dyn, + dyn_ind2par_ind, + dyn_par_is, + dyn_arg_offset, + dyn_par_arg, + par_ind2dyn_ind, + dyn_previous, + arg_match + ); + opcode_t op_t = opcode_t(op); + code = optimize_hash_code( + op_t, num_arg, arg_match.data() + ); + // + // iterator for the set with this hash code + sparse_list_const_iterator itr(hash_table_dyn, code); + // + // check for a match + count = 0; + match = false; + while( ! match && *itr != num_dynamic_par ) + { ++count; + // + // candidate for current dynamic parameter + size_t k_dyn = *itr; + CPPAD_ASSERT_UNKNOWN( k_dyn < i_dyn ); + // + // argument offset for the candidate + addr_t k_arg = dyn_arg_offset[k_dyn]; + // + match = op_t == dyn_par_op[k_dyn]; + match &= arg_match[0] == dyn_par_arg[k_arg + 0]; + if( ! match ) + ++itr; + } + if( match ) + { size_t k_dyn = *itr; + CPPAD_ASSERT_UNKNOWN( k_dyn < i_dyn ); + dyn_previous[i_dyn] = addr_t( k_dyn ); + } + else + { CPPAD_ASSERT_UNKNOWN( count < 11 ); + if( count == 10 ) + { // restart list for this hash code + hash_table_dyn.clear(code); + } + // add the entry to hash table + hash_table_dyn.add_element(code, i_dyn); + } + } + break; + + // --------------------------------------------------------------- + // binary operators + case add_dyn: + case div_dyn: + case mul_dyn: + case pow_dyn: + case sub_dyn: + case zmul_dyn: + CPPAD_ASSERT_UNKNOWN( num_arg_dyn(op) == 2); + CPPAD_ASSERT_UNKNOWN( dyn_par_is[i_par] ); + match = false; + { size_t num_arg = 2; + arg_match.resize(num_arg); + dyn_arg_match( + i_dyn, + dyn_ind2par_ind, + dyn_par_is, + dyn_arg_offset, + dyn_par_arg , + par_ind2dyn_ind, + dyn_previous, + arg_match + ); + opcode_t op_t = opcode_t(op); + code = optimize_hash_code( + op_t, num_arg, arg_match.data() + ); + // + // iterator for the set with this hash code + sparse_list_const_iterator itr(hash_table_dyn, code); + // + // check for a match + count = 0; + while( ! match && *itr != num_dynamic_par ) + { ++count; + // + // candidate for current dynamic parameter + size_t k_dyn = *itr; + CPPAD_ASSERT_UNKNOWN( k_dyn < i_dyn ); + // + // argument offset for the candidate + addr_t k_arg = dyn_arg_offset[k_dyn]; + // + match = op_t == dyn_par_op[k_dyn]; + match &= arg_match[0] == dyn_par_arg[k_arg + 0]; + match &= arg_match[1] == dyn_par_arg[k_arg + 1]; + if( ! match ) + ++itr; + } + if( match ) + { size_t k_dyn = *itr; + CPPAD_ASSERT_UNKNOWN( k_dyn < i_dyn ); + dyn_previous[i_dyn] = addr_t( k_dyn ); + } + } + if( (! match) & ( (op == add_dyn) | (op == mul_dyn) ) ) + { size_t num_arg = 2; + std::swap( arg_match[0], arg_match[1] ); + opcode_t op_t = opcode_t(op); + size_t code_swp = optimize_hash_code( + op_t, num_arg, arg_match.data() + ); + // + // iterator for the set with this hash code + sparse_list_const_iterator itr(hash_table_dyn, code_swp); + // + // check for a match + while( ! match && *itr != num_dynamic_par ) + { // + // candidate for current dynamic parameter + size_t k_dyn = *itr; + CPPAD_ASSERT_UNKNOWN( k_dyn < i_dyn ); + // + // argument offset for the candidate + addr_t k_arg = dyn_arg_offset[k_dyn]; + // + match = op_t == dyn_par_op[k_dyn]; + match &= arg_match[0] == dyn_par_arg[k_arg + 0]; + match &= arg_match[1] == dyn_par_arg[k_arg + 1]; + if( ! match ) + ++itr; + } + if( match ) + { size_t k_dyn = *itr; + CPPAD_ASSERT_UNKNOWN( k_dyn < i_dyn ); + dyn_previous[i_dyn] = addr_t( k_dyn ); + } + } + if( ! match ) + { CPPAD_ASSERT_UNKNOWN( count < 11 ); + if( count == 10 ) + { // restart list for this hash code + hash_table_dyn.clear(code); + } + // add the entry to hash table + hash_table_dyn.add_element(code, i_dyn); + } + + // -------------------------------------------------------------- + // skipping these cases for now + case dis_dyn: + case cond_exp_dyn: + case call_dyn: + case result_dyn: + break; + + + // -------------------------------------------------------------- + // should be no other cases; e.g., no ind_dyn or number_dyn. + default: + CPPAD_ASSERT_UNKNOWN(false); + break; + } + i_arg += num_arg_dyn(op); + if( op == call_dyn ) + { size_t n = size_t( dyn_par_arg[i_arg + 1] ); + size_t m = size_t( dyn_par_arg[i_arg + 2] ); + size_t n_arg = 5 + n + m; + i_arg += n_arg; + } + } +} + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/get_op_previous.hpp cppad-2019.02.00.0/include/cppad/local/optimize/get_op_previous.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/get_op_previous.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/get_op_previous.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,208 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_GET_OP_PREVIOUS_HPP +# define CPPAD_LOCAL_OPTIMIZE_GET_OP_PREVIOUS_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file get_cexp_info.hpp +Create operator information tables +*/ + +# include +# include + +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { + +/*! +Get mapping from each variable to a previous variable +that can be used to replace it (if one exists). + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param play +This is the old operation sequence. + +\param random_itr +This is a random iterator for the old operation sequence. + +\param cexp_set +set[i] is a set of elements for the i-th operator. +Suppose that e is an element of set[i], j = e / 2, k = e % 2. +If the comparision for the j-th conditional expression is equal to bool(k), +the i-th operator can be skipped (is not used by any of the results). +Note the the j indexs the CExpOp operators in the operation sequence. +On input, cexp_set is does not count previous optimization. +On output, it does count previous optimization. + +\param op_previous +The input size of this vector must be zero. +Upon return it has size equal to the number of operators +in the operation sequence; i.e., num_op = play->nun_var_rec(). +Let j = op_previous[i]. It j = 0, no replacement was found for i-th operator. +Otherwise, j < i, op_previous[j] == 0, op_usage[j] == usage_t(yes_usage), +i-th operator has NumArg(op) <= 3, 0 < NumRes(op), is not one of the following: + - PriOp, ParOp, InvOp, EndOp, CexpOp, BeginOp. + + - it is not one of the load store op + LtpvOp, LtvpOp, LtvvOp, StppOp, StpvOp, StvpOp, StvvOp. + + - it is not a atomic function fucntion op + AFunOp, FunapOp, FunavOp, FunrpOp, FunrvOp. + +\param op_usage +The size of this vector is the number of operators in the +operation sequence.i.e., play->nun_var_rec(). +On input, op_usage[i] is the usage for +the i-th operator in the operation sequence not counting previous +optimization. +On output, it is the usage counting previous operator optimization. +*/ + +template +void get_op_previous( + const player* play , + const play::const_random_iterator& random_itr , + sparse_list& cexp_set , + pod_vector& op_previous , + pod_vector& op_usage ) +{ + // number of operators in the tape + const size_t num_op = random_itr.num_op(); + CPPAD_ASSERT_UNKNOWN( op_previous.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( op_usage.size() == num_op ); + op_previous.resize( num_op ); + // + // number of conditional expressions in the tape + // + // initialize mapping from variable index to operator index + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= num_op + ); + // ---------------------------------------------------------------------- + // compute op_previous + // ---------------------------------------------------------------------- + sparse_list hash_table_op; + hash_table_op.resize(CPPAD_HASH_TABLE_SIZE, num_op); + // + pod_vector work_bool; + pod_vector work_addr_t; + for(size_t i_op = 0; i_op < num_op; ++i_op) + { op_previous[i_op] = 0; + + if( op_usage[i_op] == usage_t(yes_usage) ) + switch( random_itr.get_op(i_op) ) + { + // ---------------------------------------------------------------- + // these operators never match pevious operators + case BeginOp: + case CExpOp: + case CSkipOp: + case CSumOp: + case EndOp: + case InvOp: + case LdpOp: + case LdvOp: + case ParOp: + case PriOp: + case StppOp: + case StpvOp: + case StvpOp: + case StvvOp: + case AFunOp: + case FunapOp: + case FunavOp: + case FunrpOp: + case FunrvOp: + break; + + // ---------------------------------------------------------------- + // check for a previous match + case AbsOp: + case AcosOp: + case AcoshOp: + case AddpvOp: + case AddvvOp: + case AsinOp: + case AsinhOp: + case AtanOp: + case AtanhOp: + case CosOp: + case CoshOp: + case DisOp: + case DivpvOp: + case DivvpOp: + case DivvvOp: + case EqpvOp: + case EqvvOp: + case ErfOp: + case ExpOp: + case Expm1Op: + case LepvOp: + case LevpOp: + case LevvOp: + case LogOp: + case Log1pOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case MulpvOp: + case MulvvOp: + case NepvOp: + case NevvOp: + case PowpvOp: + case PowvpOp: + case PowvvOp: + case SignOp: + case SinOp: + case SinhOp: + case SqrtOp: + case SubpvOp: + case SubvpOp: + case SubvvOp: + case TanOp: + case TanhOp: + case ZmulpvOp: + case ZmulvpOp: + case ZmulvvOp: + match_op( + random_itr, + op_previous, + i_op, + hash_table_op, + work_bool, + work_addr_t + ); + if( op_previous[i_op] != 0 ) + { // like a unary operator that assigns i_op equal to previous. + size_t previous = size_t( op_previous[i_op] ); + bool sum_op = false; + CPPAD_ASSERT_UNKNOWN( previous < i_op ); + op_inc_arg_usage( + play, sum_op, i_op, previous, op_usage, cexp_set + ); + } + break; + + // ---------------------------------------------------------------- + default: + CPPAD_ASSERT_UNKNOWN(false); + break; + } + } +} + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/get_op_usage.hpp cppad-2019.02.00.0/include/cppad/local/optimize/get_op_usage.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/get_op_usage.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/get_op_usage.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,785 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_GET_OP_USAGE_HPP +# define CPPAD_LOCAL_OPTIMIZE_GET_OP_USAGE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file get_cexp_info.hpp +Create operator information tables +*/ + +# include +# include +# include + +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { + +/// Is this an addition or subtraction operator +inline bool op_add_or_sub( + OpCode op ///< operator we are checking +) +{ bool result; + switch(op) + { + case AddpvOp: + case AddvvOp: + case SubpvOp: + case SubvpOp: + case SubvvOp: + result = true; + break; + + default: + result = false; + break; + } + return result; +} + +/*! +Increarse argument usage and propagate cexp_set from result to argument. + +\param play +is the player for the old operation sequence. + +\param sum_result +is result an addition or subtraction operator (passed for speed so +do not need to call op_add_or_sub for result). + +\param i_result +is the operator index for the result operator. + +\param i_arg +is the operator index for the argument to the result operator. + +\param op_usage +structure that holds the information for each of the operators. +The output value of op_usage[i_arg] is increased; to be specific, +If sum_result is true and the input value of op_usage[i_arg] +is usage_t(no_usage), its output value is usage_t(csum_usage). +Otherwise, the output value of op_usage[i_arg] is usage_t(yes_usage). + +\param cexp_set +This is a vector of sets with one set for each operator. We denote +the i-th set by set[i]. + +\li +In the special case where cexp_set.n_set() is zero, +cexp_set is not changed. + +\li +If cexp_set.n_set() != 0 and op_usage[i_arg] == usage_t(no_usage), +the input value of set[i_arg] must be empty. +In this case the output value if set[i_arg] is equal to set[i_result] +(which may also be empty). + +\li +If cexp_set.n_set() != 0 and op_usage[i_arg] != usage_t(no_usage), +the output value of set[i_arg] is the intersection of +its input value and set[i_result]. +*/ +template +void op_inc_arg_usage( + const player* play , + bool sum_result , + size_t i_result , + size_t i_arg , + pod_vector& op_usage , + sparse_list& cexp_set ) +{ // value of argument input on input to this routine + enum_usage arg_usage = enum_usage( op_usage[i_arg] ); + // + // new value for usage + op_usage[i_arg] = usage_t(yes_usage); + if( sum_result ) + { if( arg_usage == no_usage ) + { OpCode op_a = play->GetOp(i_arg); + if( op_add_or_sub( op_a ) ) + { op_usage[i_arg] = usage_t(csum_usage); + } + } + } + // + // cexp_set + if( cexp_set.n_set() == 0 ) + return; + // + if( arg_usage == no_usage ) + { // set[i_arg] = set[i_result] + cexp_set.assignment(i_arg, i_result, cexp_set); + } + else + { // set[i_arg] = set[i_arg] intersect set[i_result] + cexp_set.binary_intersection(i_arg, i_arg, i_result, cexp_set); + } + // + return; +} + +/*! +Use reverse activity analysis to get usage information for each operator. + +\tparam Base +Base type for the operator; i.e., this operation was recorded +using AD and computations by this routine are done using type Base. + +\tparam Addr +Type used by random iterator for the player. + +\param conditional_skip +If conditional_skip this is true, the conditional expression information +cexp_info will be calculated. +This may be time intensive and may not have much benefit in the optimized +recording. + +\param compare_op +if this is true, arguments are considered used if they appear in compare +operators. This is a side effect because compare operators have boolean +results (and the result is not in the tape; i.e. NumRes(op) is zero +for these operators. (This is an example of a side effect.) + +\param print_for_op +if this is true, arguments are considered used if they appear in +print forward operators; i.e., PriOp. +This is also a side effect; i.e. NumRes(PriOp) is zero. + +\param play +This is the operation sequence. + +\param random_itr +This is a random iterator for the operation sequence. + +\param dep_taddr +is a vector of indices for the dependent variables +(where the reverse activity analysis starts). + +\param cexp2op +The input size of this vector must be zero. +Upon retun it has size equal to the number of conditional expressions, +CExpOp operators. The value $icode%cexp2op[%j%]%$$ is the operator +index corresponding to the $th j$$ operator. + +\param cexp_set +This is a vector of sets that is empty on input. +If conditional_skip is false, cexp_usage is not modified. +Otherwise, set[i] is a set of elements for the i-th operator. +Suppose that e is an element of set[i], j = e / 2, k = e % 2. +If the comparision for the j-th conditional expression is equal to bool(k), +the i-th operator can be skipped (is not used by any of the results). +Note the the j indexs the CExpOp operators in the operation sequence. + +\param vecad_used +The input size of this vector must be zero. +Upon retun it has size equal to the number of VecAD vectors +in the operations sequences; i.e., play->num_vecad_vec_rec(). +The VecAD vectors are indexed in the order that thier indices apprear +in the one large play->GetVecInd that holds all the VecAD vectors. + +\param op_usage +The input size of this vector must be zero. +Upon return it has size equal to the number of operators +in the operation sequence; i.e., num_op = play->nun_var_rec(). +The value op_usage[i] have been set to the usage for +the i-th operator in the operation sequence. +Atomic function calls are a special case, +the first and second AFunOp have usage corresponding to the entire call. +The arguments have the usage for particular parameter or variable. +This usage is only for creating variables, not for creating +dynamic parameters. +*/ + +template +void get_op_usage( + bool conditional_skip , + bool compare_op , + bool print_for_op , + const player* play , + const play::const_random_iterator& random_itr , + const pod_vector& dep_taddr , + pod_vector& cexp2op , + sparse_list& cexp_set , + pod_vector& vecad_used , + pod_vector& op_usage ) +{ + CPPAD_ASSERT_UNKNOWN( cexp_set.n_set() == 0 ); + CPPAD_ASSERT_UNKNOWN( vecad_used.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( op_usage.size() == 0 ); + + // number of operators in the tape + const size_t num_op = play->num_op_rec(); + // + // initialize mapping from variable index to operator index + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= num_op + ); + // ----------------------------------------------------------------------- + // information about current operator + OpCode op; // operator + const addr_t* arg; // arguments + size_t i_op; // operator index + size_t i_var; // variable index of first result + // ----------------------------------------------------------------------- + // information about atomic function calls + size_t atom_index=0, atom_old=0, atom_m=0, atom_n=0, atom_i=0, atom_j=0; + enum_atom_state atom_state; + // + // work space used by user atomic functions + vector atom_x; // value of parameters in x + vector type_x; // type for each argument + vector atom_ix; // variables indices for argument vector + vector depend_y; // results that are used + vector depend_x; // arguments that are used + // + // parameter information (used by atomic function calls) + size_t num_par = play->num_par_rec(); + const Base* parameter = CPPAD_NULL; + if( num_par > 0 ) + parameter = play->GetPar(); + // ----------------------------------------------------------------------- + // vecad information + size_t num_vecad = play->num_vecad_vec_rec(); + size_t num_vecad_ind = play->num_vec_ind_rec(); + // + vecad_used.resize(num_vecad); + for(size_t i = 0; i < num_vecad; i++) + vecad_used[i] = false; + // + vector arg2vecad(num_vecad_ind); + for(size_t i = 0; i < num_vecad_ind; i++) + arg2vecad[i] = num_vecad; // invalid value + size_t arg_0 = 1; // value of arg[0] for theh first vecad + for(size_t i = 0; i < num_vecad; i++) + { + // mapping from arg[0] value to index for this vecad object. + arg2vecad[arg_0] = i; + // + // length of this vecad object + size_t length = play->GetVecInd(arg_0 - 1); + // + // set to proper index in GetVecInd for next VecAD arg[0] value + arg_0 += length + 1; + } + CPPAD_ASSERT_UNKNOWN( arg_0 == num_vecad_ind + 1 ); + // ----------------------------------------------------------------------- + // conditional expression information + // + size_t num_cexp_op = 0; + if( conditional_skip ) + { for(i_op = 0; i_op < num_op; ++i_op) + { if( random_itr.get_op(i_op) == CExpOp ) + { // count the number of conditional expressions. + ++num_cexp_op; + } + } + } + // + cexp2op.resize( num_cexp_op ); + // + // number of sets + size_t num_set = 0; + if( conditional_skip && num_cexp_op > 0) + num_set = num_op; + // + // conditional expression index = element / 2 + // conditional expression compare = bool ( element % 2) + size_t end_set = 2 * num_cexp_op; + // + if( num_set > 0 ) + cexp_set.resize(num_set, end_set); + // ----------------------------------------------------------------------- + // initilaize operator usage for reverse dependency analysis. + op_usage.resize( num_op ); + for(i_op = 0; i_op < num_op; ++i_op) + op_usage[i_op] = usage_t(no_usage); + for(size_t i = 0; i < dep_taddr.size(); i++) + { i_op = random_itr.var2op(dep_taddr[i]); + op_usage[i_op] = usage_t(yes_usage); // dependent variables + } + // ---------------------------------------------------------------------- + // Reverse pass to compute usage and cexp_set for each operator + // ---------------------------------------------------------------------- + // + // Initialize reverse pass + size_t last_atom_i_op = 0; + size_t cexp_index = num_cexp_op; + atom_state = end_atom; + i_op = num_op; + while(i_op != 0 ) + { --i_op; + // + // this operator information + random_itr.op_info(i_op, op, arg, i_var); + // + // Is the result of this operation used. + // (This only makes sense when NumRes(op) > 0.) + usage_t use_result = op_usage[i_op]; + // + bool sum_op = false; + switch( op ) + { + // ============================================================= + // normal operators + // ============================================================= + + // Only one variable with index arg[0] + case SubvpOp: + sum_op = true; + // + 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: + case SinhOp: + case SqrtOp: + case TanOp: + case TanhOp: + case ZmulvpOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); + if( use_result != usage_t(no_usage) ) + { size_t j_op = random_itr.var2op(size_t(arg[0])); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + } + break; // -------------------------------------------- + + // Only one variable with index arg[1] + case AddpvOp: + case SubpvOp: + sum_op = true; + // + case DisOp: + case DivpvOp: + case MulpvOp: + case PowpvOp: + case ZmulpvOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); + if( use_result != usage_t(no_usage) ) + { size_t j_op = random_itr.var2op(size_t(arg[1])); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + } + break; // -------------------------------------------- + + // arg[0] and arg[1] are the only variables + case AddvvOp: + case SubvvOp: + sum_op = true; + // + case DivvvOp: + case MulvvOp: + case PowvvOp: + case ZmulvvOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); + if( use_result != usage_t(no_usage) ) + { for(size_t i = 0; i < 2; i++) + { size_t j_op = random_itr.var2op(size_t(arg[i])); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + } + } + break; // -------------------------------------------- + + // Conditional expression operators + // arg[2], arg[3], arg[4], arg[5] are parameters or variables + case CExpOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); + if( conditional_skip ) + { --cexp_index; + cexp2op[ cexp_index ] = addr_t(i_op); + } + if( use_result != usage_t(no_usage) ) + { CPPAD_ASSERT_UNKNOWN( NumArg(CExpOp) == 6 ); + // propgate from result to left argument + if( arg[1] & 1 ) + { size_t j_op = random_itr.var2op(size_t(arg[2])); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + } + // propgate from result to right argument + if( arg[1] & 2 ) + { size_t j_op = random_itr.var2op(size_t(arg[3])); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + } + // are if_true and if_false cases the same variable + bool same_variable = (arg[1] & 4) != 0; + same_variable &= (arg[1] & 8) != 0; + same_variable &= arg[4] == arg[5]; + // + // if_true + if( arg[1] & 4 ) + { size_t j_op = random_itr.var2op(size_t(arg[4])); + bool can_skip = conditional_skip & (! same_variable); + can_skip &= op_usage[j_op] == usage_t(no_usage); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + if( can_skip ) + { // j_op corresponds to the value used when the + // comparison result is true. It can be skipped when + // the comparison is false (0). + size_t element = 2 * cexp_index + 0; + cexp_set.add_element(j_op, element); + // + op_usage[j_op] = usage_t(yes_usage); + } + } + // + // if_false + if( arg[1] & 8 ) + { size_t j_op = random_itr.var2op(size_t(arg[5])); + bool can_skip = conditional_skip & (! same_variable); + can_skip &= op_usage[j_op] == usage_t(no_usage); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + if( can_skip ) + { // j_op corresponds to the value used when the + // comparison result is false. It can be skipped when + // the comparison is true (0). + size_t element = 2 * cexp_index + 1; + cexp_set.add_element(j_op, element); + // + op_usage[j_op] = usage_t(yes_usage); + } + } + } + break; // -------------------------------------------- + + // Operations that are never used + // (new CSkip options are generated if conditional_skip is true) + case CSkipOp: + case ParOp: + break; + + // Operators that are always used + case InvOp: + case BeginOp: + case EndOp: + op_usage[i_op] = usage_t(yes_usage); + break; // ----------------------------------------------- + + // The print forward operator + case PriOp: + CPPAD_ASSERT_NARG_NRES(op, 5, 0); + if( print_for_op ) + { op_usage[i_op] = usage_t(yes_usage); + if( arg[0] & 1 ) + { // arg[1] is a variable + size_t j_op = random_itr.var2op(size_t(arg[1])); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + } + if( arg[0] & 2 ) + { // arg[3] is a variable + size_t j_op = random_itr.var2op(size_t(arg[3])); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + } + } + break; // ----------------------------------------------------- + + // ============================================================= + // Comparison operators + // ============================================================= + + // Compare operators where arg[1] is only variable + case LepvOp: + case LtpvOp: + case EqpvOp: + case NepvOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 0 ); + if( compare_op ) + { op_usage[i_op] = usage_t(yes_usage); + // + size_t j_op = random_itr.var2op(size_t(arg[1])); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + } + break; // ---------------------------------------------- + + // Compare operators where arg[0] is only variable + case LevpOp: + case LtvpOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 0 ); + if( compare_op ) + { op_usage[i_op] = usage_t(yes_usage); + // + size_t j_op = random_itr.var2op(size_t(arg[0])); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + } + break; // ---------------------------------------------- + + // Compare operators where arg[0] and arg[1] are variables + case LevvOp: + case LtvvOp: + case EqvvOp: + case NevvOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 0 ); + if( compare_op ) + { op_usage[i_op] = usage_t(yes_usage); + // + for(size_t i = 0; i < 2; i++) + { size_t j_op = random_itr.var2op(size_t(arg[i])); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + } + } + break; // ---------------------------------------------- + + // ============================================================= + // VecAD operators + // ============================================================= + + // load operator using a parameter index + case LdpOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); + if( use_result != usage_t(no_usage) ) + { size_t i_vec = arg2vecad[ arg[0] ]; + vecad_used[i_vec] = true; + } + break; // -------------------------------------------- + + // load operator using a variable index + case LdvOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); + if( use_result != usage_t(no_usage) ) + { size_t i_vec = arg2vecad[ arg[0] ]; + vecad_used[i_vec] = true; + // + size_t j_op = random_itr.var2op(size_t(arg[1])); + op_usage[j_op] = usage_t(yes_usage); + } + break; // -------------------------------------------- + + // Store a variable using a parameter index + case StpvOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 0 ); + if( vecad_used[ arg2vecad[ arg[0] ] ] ) + { op_usage[i_op] = usage_t(yes_usage); + // + size_t j_op = random_itr.var2op(size_t(arg[2])); + op_usage[j_op] = usage_t(yes_usage); + } + break; // -------------------------------------------- + + // Store a variable using a variable index + case StvvOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 0 ); + if( vecad_used[ arg2vecad[ arg[0] ] ] ) + { op_usage[i_op] = usage_t(yes_usage); + // + size_t j_op = random_itr.var2op(size_t(arg[1])); + op_usage[j_op] = usage_t(yes_usage); + size_t k_op = random_itr.var2op(size_t(arg[2])); + op_usage[k_op] = usage_t(yes_usage); + } + break; // ----------------------------------------------------- + + // ============================================================= + // cumulative summation operator + // ============================================================ + case CSumOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 ); + { + for(size_t i = 5; i < size_t(arg[2]); i++) + { size_t j_op = random_itr.var2op(size_t(arg[i])); + op_inc_arg_usage( + play, sum_op, i_op, j_op, op_usage, cexp_set + ); + } + } + // ============================================================= + // user defined atomic operators + // ============================================================ + + case AFunOp: + // start or end atomic operation sequence + if( atom_state == end_atom ) + { // reverse_user using random_itr instead of play + atom_index = size_t(arg[0]); + atom_old = size_t(arg[1]); + atom_n = size_t(arg[2]); + atom_m = size_t(arg[3]); + atom_j = atom_n; + atom_i = atom_m; + atom_state = ret_atom; + // ------------------------------------------------------- + last_atom_i_op = i_op; + CPPAD_ASSERT_UNKNOWN( i_op > atom_n + atom_m + 1 ); + CPPAD_ASSERT_UNKNOWN( + op_usage[last_atom_i_op] == usage_t(no_usage) + ); +# ifndef NDEBUG + if( cexp_set.n_set() > 0 ) + { sparse_list_const_iterator itr(cexp_set, last_atom_i_op); + CPPAD_ASSERT_UNKNOWN( *itr == cexp_set.end() ); + } +# endif + // + atom_x.resize( atom_n ); + type_x.resize( atom_n ); + atom_ix.resize( atom_n ); + // + depend_y.resize( atom_m ); + depend_x.resize( atom_n ); + for(size_t i = 0; i < atom_m; i++) + depend_y[ i ] = false; + } + else + { // reverse_user using random_itr instead of play + CPPAD_ASSERT_UNKNOWN( atom_state == start_atom ); + CPPAD_ASSERT_UNKNOWN( atom_n == size_t(arg[2]) ); + CPPAD_ASSERT_UNKNOWN( atom_m == size_t(arg[3]) ); + CPPAD_ASSERT_UNKNOWN( atom_j == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + atom_state = end_atom; + // ------------------------------------------------------- + CPPAD_ASSERT_UNKNOWN( + i_op + atom_n + atom_m + 1 == last_atom_i_op + ); + if( op_usage[last_atom_i_op] != usage_t(no_usage) ) + { // call atomic function for this operation + sweep::call_atomic_rev_depend( + atom_index, atom_old, atom_x, type_x, depend_x, depend_y + ); + for(size_t j = 0; j < atom_n; j++) + if( depend_x[j] ) + { // The parameter or variable correspnding to the j-th + // argument gets used + op_usage[i_op + 1 + j] = true; + if( type_x[j] == variable_enum ) + { CPPAD_ASSERT_UNKNOWN( atom_ix[j] > 0 ); + if( depend_x[j] ) + { size_t j_op = random_itr.var2op(atom_ix[j]); + op_inc_arg_usage(play, sum_op, + last_atom_i_op, j_op, op_usage, cexp_set + ); + } + } + } + } + // copy set infomation from last to first + if( cexp_set.n_set() > 0 ) + cexp_set.assignment(i_op, last_atom_i_op, cexp_set); + // copy usage information from last to first + op_usage[i_op] = op_usage[last_atom_i_op]; + } + break; // ------------------------------------------------------- + + case FunapOp: + // parameter argument in an atomic operation sequence + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + // + // reverse_user using random_itr instead of play + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + CPPAD_ASSERT_UNKNOWN( 0 < atom_j && atom_j <= atom_n ); + --atom_j; + if( atom_j == 0 ) + atom_state = start_atom; + // ------------------------------------------------------------- + atom_ix[atom_j] = 0; + // + // parameter arguments + atom_x[atom_j] = parameter[arg[0]]; + if( play->dyn_par_is()[arg[0]] ) + type_x[atom_j] = dynamic_enum; + else + type_x[atom_j] = constant_enum; + // + break; + + case FunavOp: + // variable argument in an atomic operation sequence + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + // + // reverse_user using random_itr instead of play + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + CPPAD_ASSERT_UNKNOWN( 0 < atom_j && atom_j <= atom_n ); + --atom_j; + if( atom_j == 0 ) + atom_state = start_atom; + // ------------------------------------------------------------- + atom_ix[atom_j] = size_t(arg[0]); + // + // variable arguments as parameters + atom_x[atom_j] = CppAD::numeric_limits::quiet_NaN(); + type_x[atom_j] = variable_enum; + // + break; + + case FunrvOp: + // variable result in an atomic operation sequence + // + // reverse_user using random_itr instead of play + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + CPPAD_ASSERT_UNKNOWN( 0 < atom_i && atom_i <= atom_m ); + --atom_i; + if( atom_i == 0 ) + atom_state = arg_atom; + // ------------------------------------------------------------- + if( use_result ) + { depend_y[atom_i] = true; + op_inc_arg_usage( + play, sum_op, i_op, last_atom_i_op, op_usage, cexp_set + ); + } + break; // -------------------------------------------------------- + + case FunrpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + // + // reverse_user using random_itr instead of play + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + CPPAD_ASSERT_UNKNOWN( 0 < atom_i && atom_i <= atom_m ); + --atom_i; + if( atom_i == 0 ) + atom_state = arg_atom; + break; + // ============================================================ + + // all cases should be handled above + default: + CPPAD_ASSERT_UNKNOWN(0); + } + } + return; +} + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/get_par_usage.hpp cppad-2019.02.00.0/include/cppad/local/optimize/get_par_usage.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/get_par_usage.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/get_par_usage.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,485 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_GET_PAR_USAGE_HPP +# define CPPAD_LOCAL_OPTIMIZE_GET_PAR_USAGE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file get_cexp_info.hpp +Create operator information tables +*/ +# include + +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { + +/*! +Use reverse activity analysis to get usage for each parameters. + +\tparam Base +Base type for the operator; i.e., this operation was recorded +using AD and computations by this routine are done using type Base. + +\tparam Addr +Type used by random iterator for the player. + +\param play +This is the operation sequence. + +\param random_itr +This is a random iterator for the operation sequence. + +\param op_usage +This argument has size equal to the number of operators +in the operation sequence; i.e., num_op = play->nun_var_rec(). +The value op_usage[i] have been set to the usage for +the i-th operator in the operation sequence. + +\param vecad_used +This argument has size equal to the number of VecAD vectors +in the operations sequences; i.e., play->num_vecad_vec_rec(). +The VecAD vectors are indexed in the order that thier indices apprear +in the one large play->GetVecInd that holds all the VecAD vectors. + +\param par_usage +Upon return it has size equal to the number of parameters +in the operation sequence; i.e., play->num_par_rec(); +The value par_usage[i] is true if an only if +the i-th parameter is used to compute a variable. +The nan at the beginning of the parameter vector +and the independent dynamic parameters are always used. +*/ + +template +void get_par_usage( + const player* play , + const play::const_random_iterator& random_itr , + const pod_vector& op_usage , + pod_vector& vecad_used , + pod_vector& par_usage ) +{ + CPPAD_ASSERT_UNKNOWN( op_usage.size() == play->num_op_rec() ); + CPPAD_ASSERT_UNKNOWN( par_usage.size() == 0 ); + // + // number of operators in the tape + const size_t num_op = play->num_op_rec(); + // + // number of parameters in the tape + const size_t num_par = play->num_par_rec(); + // + // number of dynamic parameters + const size_t num_dynamic_par = play->num_dynamic_par(); + // + // number of independent dynamic parameters + size_t num_dynamic_ind = play->num_dynamic_ind(); + // + // number of VecAD vectors + size_t num_vecad_vec = play->num_vecad_vec_rec(); + // + // dynamic parameter information + const pod_vector& dyn_par_is( play->dyn_par_is() ); + const pod_vector& dyn_par_op( play->dyn_par_op() ); + const pod_vector& dyn_par_arg( play->dyn_par_arg() ); + const pod_vector& dyn_ind2par_ind( play->dyn_ind2par_ind() ); + const pod_vector_maybe& all_par_vec( play->all_par_vec() ); + // ----------------------------------------------------------------------- + // initialize par_usage + par_usage.resize(num_par); + par_usage[0] = true; // true for nan at beginning of parameter vector + for(size_t i_par = 1; i_par <= num_dynamic_ind; ++i_par) + par_usage[i_par] = true; // true for independent dynamic parameters + for(size_t i_par = num_dynamic_ind+1; i_par < num_par; ++i_par) + par_usage[i_par] = false; // initialize as false for other parameters + // + // ----------------------------------------------------------------------- + // set usage to true for VecAD parameters that get used + size_t start_this_vector = 0; + for(size_t i_vec = 0; i_vec < num_vecad_vec; ++i_vec) + { // length of this vector (note length is not a parameter) + size_t length = play->GetVecInd(start_this_vector); + // + if( vecad_used[i_vec] ) + { // this vector gets used + for(size_t k = 1; k <= length; ++k) + { // index of parameter used by this VecAD vector + size_t i_par = play->GetVecInd(start_this_vector + k); + // must not be a dynamic parameter + CPPAD_ASSERT_UNKNOWN( ! dyn_par_is[i_par] ); + // set usage for this parameter + par_usage[i_par] = true; + } + } + start_this_vector += length + 1; + } + CPPAD_ASSERT_UNKNOWN( start_this_vector == play->num_vec_ind_rec() ); + // + // ----------------------------------------------------------------------- + // forward pass to mark which parameters are used by necessary operators + // ----------------------------------------------------------------------- + // + // information about atomic function calls + size_t atom_index=0, atom_old=0, atom_m=0, atom_n=0, atom_i=0, atom_j=0; + enum_atom_state atom_state = start_atom; + // + // work space used by user atomic functions + vector parameter_x; // value of parameters in x + vector type_x; // type for each component of z + vector atom_ix; // variables indices for argument vector + vector depend_y; // results that are used + vector depend_x; // arguments that are used + // + for(size_t i_op = 0; i_op < num_op; ++i_op) + { + // information about current operator + OpCode op; // operator + const addr_t* arg; // arguments + size_t i_var; // variable index of first result + random_itr.op_info(i_op, op, arg, i_var); + // + bool skip = op_usage[i_op] == usage_t(no_usage); + skip &= atom_state == start_atom; + if( ! skip ) switch( op ) + { + // add or subtract with left a parameter and right a variable + case AddpvOp: + case SubpvOp: + if( dyn_par_is[ arg[0] ] ) + par_usage[ arg[0] ] = true; + else + { // determine if this parameter will be absorbed by csum + if( ! (op_usage[i_op] == csum_usage) ) + { // determine operator corresponding to variable + size_t j_op = random_itr.var2op(size_t(arg[1])); + CPPAD_ASSERT_UNKNOWN( op_usage[j_op] != no_usage ); + if( op_usage[j_op] != csum_usage ) + par_usage[ arg[0] ] = true; + } + } + break; + + // subtract with left a variable and right a parameter + case SubvpOp: + if( dyn_par_is[ arg[1] ] ) + par_usage[ arg[1] ] = true; + else + { // determine if this parameter will be absorbed by csum + if( ! (op_usage[i_op] == csum_usage) ) + { // determine operator corresponding to variable + size_t j_op = random_itr.var2op(size_t(arg[0])); + CPPAD_ASSERT_UNKNOWN( op_usage[j_op] != no_usage ); + if( op_usage[j_op] != csum_usage ) + par_usage[ arg[1] ] = true; + } + } + break; + + + + // cases with no parameter arguments + case AbsOp: + case AcosOp: + case AcoshOp: + case AddvvOp: + case AsinOp: + case AsinhOp: + case AtanOp: + case AtanhOp: + case BeginOp: + case CosOp: + case CoshOp: + case CSkipOp: + case DisOp: + case DivvvOp: + case EndOp: + case EqvvOp: + case ExpOp: + case Expm1Op: + case InvOp: + case LdpOp: + case LdvOp: + case LevvOp: + case LogOp: + case Log1pOp: + case LtvvOp: + case MulvvOp: + case NevvOp: + case PowvvOp: + case SignOp: + case SinOp: + case SinhOp: + case SqrtOp: + case StpvOp: + case StvvOp: + case SubvvOp: + case TanOp: + case TanhOp: + case ZmulvvOp: + break; + + // cases where first and second arguments are parameters + case EqppOp: + case LeppOp: + case LtppOp: + case NeppOp: + CPPAD_ASSERT_UNKNOWN( 2 <= NumArg(op) ) + par_usage[arg[0]] = true; + par_usage[arg[1]] = true; + break; + + + // cases where only first argument is a parameter + case CSumOp: + case EqpvOp: + case DivpvOp: + case LepvOp: + case LtpvOp: + case MulpvOp: + case NepvOp: + case ParOp: + case PowpvOp: + case ZmulpvOp: + CPPAD_ASSERT_UNKNOWN( 1 <= NumArg(op) ) + par_usage[arg[0]] = true; + break; + + // cases where only second argument is a parameter + case DivvpOp: + case LevpOp: + case LtvpOp: + case PowvpOp: + case ZmulvpOp: + CPPAD_ASSERT_UNKNOWN( 2 <= NumArg(op) ) + par_usage[arg[1]] = true; + break; + + // cases where only third argument is a parameter + case StppOp: + case StvpOp: + par_usage[arg[2]] = true; + break; + + // conditional expression operator + case CExpOp: + CPPAD_ASSERT_UNKNOWN( 6 == NumArg(op) ) + if( (arg[1] & 1) == 0 ) + par_usage[arg[2]] = true; + if( (arg[1] & 2) == 0 ) + par_usage[arg[3]] = true; + if( (arg[1] & 4) == 0 ) + par_usage[arg[4]] = true; + if( (arg[1] & 8) == 0 ) + par_usage[arg[5]] = true; + break; + + // erf function is special + case ErfOp: + CPPAD_ASSERT_UNKNOWN( 3 == NumArg(op) ) + par_usage[arg[1]] = true; + par_usage[arg[2]] = true; + break; + + // print function + case PriOp: + if( (arg[0] & 1) == 0 ) + par_usage[arg[1]] = true; + if( (arg[0] & 2) == 0 ) + par_usage[arg[3]] = true; + CPPAD_ASSERT_UNKNOWN( 5 == NumArg(op) ) + break; + + // -------------------------------------------------------------- + // atomic function calls + case AFunOp: + if( atom_state == start_atom ) + { atom_index = size_t(arg[0]); + atom_old = size_t(arg[1]); + atom_n = size_t(arg[2]); + atom_m = size_t(arg[3]); + atom_j = 0; + atom_i = 0; + atom_state = arg_atom; + // ------------------------------------------------------- + parameter_x.resize( atom_n ); + type_x.resize( atom_n ); + atom_ix.resize( atom_n ); + // + depend_y.resize( atom_m ); + depend_x.resize( atom_n ); + } + else + { CPPAD_ASSERT_UNKNOWN( atom_state == end_atom ); + CPPAD_ASSERT_UNKNOWN( atom_n == size_t(arg[2]) ); + CPPAD_ASSERT_UNKNOWN( atom_m == size_t(arg[3]) ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + CPPAD_ASSERT_UNKNOWN( atom_i == atom_m ); + atom_state = start_atom; + // + // call atomic function for this operation + sweep::call_atomic_rev_depend( + atom_index, atom_old, parameter_x, type_x, depend_x, depend_y + ); + for(size_t j = 0; j < atom_n; j++) + if( depend_x[j] && type_x[j] != variable_enum ) + { // This user argument is a parameter that is needed + + CPPAD_ASSERT_UNKNOWN( atom_ix[j] > 0 ); + par_usage[ atom_ix[j] ] = true; + } + } + break; + + case FunavOp: + // this argument is a variable + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + atom_ix[atom_j] = 0; + parameter_x[atom_j] = all_par_vec[0]; // variables get value nan + type_x[atom_j] = variable_enum; + ++atom_j; + if( atom_j == atom_n ) + atom_state = ret_atom; + break; + + case FunapOp: + // this argument is a parameter + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + atom_ix[atom_j] = size_t( arg[0] ); + parameter_x[atom_j] = all_par_vec[arg[0]]; // parameter value + if( dyn_par_is[arg[0]] ) + type_x[atom_j] = dynamic_enum; + else + type_x[atom_j] = dynamic_enum; + ++atom_j; + if( atom_j == atom_n ) + atom_state = ret_atom; + break; + + case FunrpOp: + // this result is a parameter + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + depend_y[atom_i] = op_usage[i_op] != usage_t(no_usage); + ++atom_i; + if( atom_i == atom_m ) + atom_state = end_atom; + break; + + case FunrvOp: + // this result is a variable + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + depend_y[atom_i] = op_usage[i_op] != usage_t(no_usage); + ++atom_i; + if( atom_i == atom_m ) + atom_state = end_atom; + break; + // -------------------------------------------------------------- + + + default: + CPPAD_ASSERT_UNKNOWN(false); + } + } + // ----------------------------------------------------------------------- + // reverse pass to determine which dynamic parameters are necessary + // ----------------------------------------------------------------------- + size_t i_arg = dyn_par_arg.size(); // index in dyn_par_arg + size_t i_dyn = num_dynamic_par; // index in dyn_ind2par_ind + while(i_dyn) + { // next dynamic parameter in reverse order + --i_dyn; + op_code_dyn op = op_code_dyn( dyn_par_op[i_dyn] ); + while( op == result_dyn ) + { --i_dyn; + op = op_code_dyn( dyn_par_op[i_dyn] ); + CPPAD_ASSERT_UNKNOWN( op == result_dyn || op == call_dyn ); + } + if( op == call_dyn ) + { // number of arguments for this operator + size_t n_arg = size_t( dyn_par_arg[i_arg - 1] ); + // + // index of first argument for this operation + i_arg -= n_arg; + // + atom_index = size_t( dyn_par_arg[i_arg + 0] ); + size_t n = size_t( dyn_par_arg[i_arg + 1] ); + size_t m = size_t( dyn_par_arg[i_arg + 2] ); + CPPAD_ASSERT_UNKNOWN( n_arg == 5 + n + m ); + // + // parameter_x, type_x + parameter_x.resize(n); + type_x.resize(n); + for(size_t j = 0; j < n; ++j) + { // parameter index zero is used for variable + CPPAD_ASSERT_UNKNOWN( isnan( all_par_vec[0] ) ); + addr_t arg_j = dyn_par_arg[i_arg + 4 + j]; + parameter_x[j] = all_par_vec[arg_j]; + if( arg_j == 0 ) + type_x[j] = variable_enum; + else if( dyn_par_is[arg_j] ) + type_x[j] = dynamic_enum; + else + type_x[j] = constant_enum; + } + // + // depend_y + depend_y.resize(m); + for(size_t i = 0; i < m; ++i) + { // a constant prameter cannot depend on a dynamic parameter + // so do not worry about constant parameters in depend_y + size_t i_par = size_t( dyn_par_arg[i_arg + 4 + n + i] ); + depend_y[i] = par_usage[i_par]; + } + // + // call back to atomic function for this operation + depend_x.resize(n); + atom_old = 0; // not used with dynamic parameters + sweep::call_atomic_rev_depend( + atom_index, atom_old, parameter_x, type_x, depend_x, depend_y + ); + // + // transfer depend_x to par_usage + for(size_t j = 0; j < n; ++j) + { size_t i_par = size_t( dyn_par_arg[i_arg + 4 + j] ); + par_usage[i_par] = par_usage[i_par] | depend_x[j]; + } + } + else + { // corresponding parameter index + size_t i_par = size_t( dyn_ind2par_ind[i_dyn] ); + CPPAD_ASSERT_UNKNOWN( dyn_par_is[i_par] ); + // + // number of argumens to this operator + size_t n_arg = num_arg_dyn(op); + // + // index of first argument for this operator + i_arg -= n_arg; + // + // if this dynamic parameter is needed + if( par_usage[i_par] ) + { // neeed dynamic parameters that are used to generate this one + if( op == cond_exp_dyn ) + { // special case + CPPAD_ASSERT_UNKNOWN( n_arg == 5 ); + for(size_t i = 1; i < 5; ++i) + par_usage[ dyn_par_arg[i_arg + i] ] = true; + } + else + { for(size_t i = 0; i < n_arg; ++i) + par_usage[ dyn_par_arg[i_arg + i] ] = true; + } + } + } + } + CPPAD_ASSERT_UNKNOWN( i_arg == 0 ); + // + return; +} + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/hash_code.hpp cppad-2019.02.00.0/include/cppad/local/optimize/hash_code.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/hash_code.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/hash_code.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,54 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_HASH_CODE_HPP +# define CPPAD_LOCAL_OPTIMIZE_HASH_CODE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file local/optimize/hash_code.hpp +CppAD hashing utility. +*/ + + +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { +/*! +Specialized hash code for a CppAD operator and its arguments +(used during optimization). + +\param op +is the operator that we are computing a hash code for. + +\param num_arg +number of elements of arg to include in the hash code. + +\param arg +is a vector of length num_arg +containing the corresponding argument indices for this operator. + +\return +is a hash code that is between zero and CPPAD_HASH_TABLE_SIZE - 1. +*/ + +inline size_t optimize_hash_code( + opcode_t op , + size_t num_arg , + const addr_t* arg ) +{ + size_t sum = size_t(op); + for(size_t i = 0; i < num_arg; i++) + sum += size_t(arg[i]); + // + return sum % CPPAD_HASH_TABLE_SIZE; +} + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/match_op.hpp cppad-2019.02.00.0/include/cppad/local/optimize/match_op.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/match_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/match_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,230 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_MATCH_OP_HPP +# define CPPAD_LOCAL_OPTIMIZE_MATCH_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +/*! +\file match_op.hpp +Check if current operator matches a previous operator. +*/ +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { +/*! +Search for a previous operator that matches the current one. + +If an argument for the current operator is a variable, +and the argument has previous match, +the previous match for the argument is used when checking for a match +for the current operator. + +\param random_itr +is a random iterator for the old operation sequence. + +\param op_previous +Mapping from operator index to previous operator that can replace this one. +The input value of op_previous[current] is assumed to be zero. +If a match if found, +the output value of op_previous[current] is set to the +matching operator index, otherwise it is left as is. +Note that op_previous[current] < current and +op_previous[ op_previous[current] ] = 0. + +\param current +is the index of the current operator which must be an unary +or binary operator with NumRes(op) > 0. +Note that NumArg(ErfOp) == 3 but it is effectivey +a unary operator and is allowed otherwise +NumArg( random_itr.get_op[current]) < 3. +It is assumed that hash_table_op is initialized as a vector of emtpy +sets. After this initialization, the value of current inceases with +each call to match_op. + +\li +This must be a unary or binary +operator; hence, NumArg( random_itr.get_op[current] ) is one or two. +There is one exception, NumRes( ErfOp ) == 3, but arg[0] +is the only true arguments (the others are always the same). + +\li +This must not be a VecAD load or store operation; i.e., +LtpvOp, LtvpOp, LtvvOp, StppOp, StpvOp, StvpOp, StvvOp. +It also must not be an independent variable operator InvOp. + +\param hash_table_op +is a vector of sets, +hash_table_op.n_set() == CPPAD_HASH_TABLE_SIZE and +hash_table_op.end() == op_previous.size(). +If i_op is an element of set[j], +then the operation op_previous[i_op] has hash code j, +and op_previous[i_op] does not match any other element of set[j]. +An entry to set[j] is added each time match_op is called +and a match for the current operator is not found. + +\param work_bool +work space that is used by match_op between calls to increase speed. +Should be empty on first call for this forward passs of the operation +sequence and not modified untill forward pass is done + +\param work_addr_t +work space that is used by match_op between calls to increase speed. +Should be empty on first call for this forward passs of the operation +sequence and not modified untill forward pass is done + +*/ +template +void match_op( + const play::const_random_iterator& random_itr , + pod_vector& op_previous , + size_t current , + sparse_list& hash_table_op , + pod_vector& work_bool , + pod_vector& work_addr_t ) +{ // + // num_op + size_t num_op = random_itr.num_op(); + // + // num_var + size_t num_var = random_itr.num_var(); + // + // variable is a reference to, and better name for, work_bool + pod_vector& variable(work_bool); + // + // var2previous_var is a reference to, and better name for, work_addr_t + pod_vector& var2previous_var(work_addr_t); + if( var2previous_var.size() == 0 ) + { var2previous_var.resize(num_var); + for(size_t i = 0; i < num_var; ++i) + var2previous_var[i] = addr_t(i); + } + // + CPPAD_ASSERT_UNKNOWN( var2previous_var.size() == num_var ); + CPPAD_ASSERT_UNKNOWN( num_op == op_previous.size() ); + CPPAD_ASSERT_UNKNOWN( op_previous[current] == 0 ); + CPPAD_ASSERT_UNKNOWN( + hash_table_op.n_set() == CPPAD_HASH_TABLE_SIZE + ); + CPPAD_ASSERT_UNKNOWN( hash_table_op.end() == num_op ); + CPPAD_ASSERT_UNKNOWN( current < num_op ); + // + // op, arg, i_var + OpCode op; + const addr_t* arg; + size_t i_var; + random_itr.op_info(current, op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( 0 < NumArg(op) ); + // + // num_arg + size_t num_arg = NumArg(op); + CPPAD_ASSERT_UNKNOWN( num_arg <= 3 ); + // + arg_is_variable(op, arg, variable); + CPPAD_ASSERT_UNKNOWN( variable.size() == num_arg ); + // + // If j-th argument to this operator is a variable, and a previous + // variable will be used in its place, use the previous variable for + // hash coding and matching. + addr_t arg_match[3]; + for(size_t j = 0; j < num_arg; ++j) + { arg_match[j] = arg[j]; + if( variable[j] ) + arg_match[j] = var2previous_var[ arg[j] ]; + } + // + size_t code = optimize_hash_code(opcode_t(op), num_arg, arg_match); + // + // iterator for the set with this hash code + sparse_list_const_iterator itr(hash_table_op, code); + // + // check for a match + size_t count = 0; + while( *itr != num_op ) + { ++count; + // + // candidate previous for current operator + size_t candidate = *itr; + CPPAD_ASSERT_UNKNOWN( candidate < current ); + CPPAD_ASSERT_UNKNOWN( op_previous[candidate] == 0 ); + // + OpCode op_c; + const addr_t* arg_c; + size_t i_var_c; + random_itr.op_info(candidate, op_c, arg_c, i_var_c); + // + // check for a match + bool match = op == op_c; + size_t j = 0; + while( match & (j < num_arg) ) + { if( variable[j] ) + match &= arg_match[j] == var2previous_var[ arg_c[j] ]; + else + match &= arg_match[j] == arg_c[j]; + ++j; + } + if( match ) + { op_previous[current] = static_cast( candidate ); + if( NumRes(op) > 0 ) + { CPPAD_ASSERT_UNKNOWN( i_var_c < i_var ); + var2previous_var[i_var] = addr_t( i_var_c ); + } + return; + } + ++itr; + } + + // special case where operator is commutative + if( (op == AddvvOp) | (op == MulvvOp ) ) + { CPPAD_ASSERT_UNKNOWN( NumArg(op) == 2 ); + std::swap( arg_match[0], arg_match[1] ); + // + code = optimize_hash_code(opcode_t(op), num_arg, arg_match); + sparse_list_const_iterator itr_swap(hash_table_op, code); + while( *itr_swap != num_op ) + { + size_t candidate = *itr_swap; + CPPAD_ASSERT_UNKNOWN( candidate < current ); + CPPAD_ASSERT_UNKNOWN( op_previous[candidate] == 0 ); + // + OpCode op_c; + const addr_t* arg_c; + size_t i_var_c; + random_itr.op_info(candidate, op_c, arg_c, i_var_c); + // + bool match = op == op_c; + size_t j = 0; + while( match & (j < num_arg) ) + { CPPAD_ASSERT_UNKNOWN( variable[j] ) + match &= arg_match[j] == var2previous_var[ arg_c[j] ]; + ++j; + } + if( match ) + { op_previous[current] = static_cast(candidate); + if( NumRes(op) > 0 ) + { CPPAD_ASSERT_UNKNOWN( i_var_c < i_var ); + var2previous_var[i_var] = addr_t( i_var_c ); + } + return; + } + ++itr_swap; + } + } + CPPAD_ASSERT_UNKNOWN( count < 11 ); + if( count == 10 ) + { // restart the list + hash_table_op.clear(code); + } + // no match was found, add this operator the the set for this hash code + hash_table_op.add_element(code, current); +} + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/optimize_run.hpp cppad-2019.02.00.0/include/cppad/local/optimize/optimize_run.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/optimize_run.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/optimize_run.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1246 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_OPTIMIZE_RUN_HPP +# define CPPAD_LOCAL_OPTIMIZE_OPTIMIZE_RUN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +/*! +\file optimize_run.hpp +Convert a player object to an optimized recorder object +*/ + +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { + +/*! +Convert a player object to an optimized recorder object + +\tparam Addr +Type to use with player random iterators. Must correspond to the +result for play->addr_type(). + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD and computations by this routine are done using type +Base. + +\param options +\li +If the sub-string "no_conditional_skip" appears, +conditional skip operations will not be generated. +This may make the optimize routine use significantly less memory +and take significantly less time. +\li +If the sub-string "no_compare_op" appears, +then comparison operators will be removed from the optimized tape. +These operators are necessary for the compare_change function to be +be meaningful in the resulting recording. +On the other hand, they are not necessary and take extra time +when compare_change is not used. +\li +If the sub-string "no_print_for" appears, +then print forward (PriOp) operators will be removed from the optimized tape. +These operators are useful for reporting problems evaluating derivatives +at independent variable values different from those used to record a function. + +\param n +is the number of independent variables on the tape. + +\param dep_taddr +On input this vector contains the indices for each of the dependent +variable values in the operation sequence corresponding to play. +Upon return it contains the indices for the same variables but in +the operation sequence corresponding to rec. + +\param play +This is the operation sequence that we are optimizing. +It is const except for the fact that play->setup_random is called. + +\param rec +The input contents of this recording must be empty; i.e., +it corresponds to directly after the default constructor. +Upon return, it contains an optimized verison of the +operation sequence corresponding to play. +*/ + +template +void optimize_run( + const std::string& options , + size_t n , + pod_vector& dep_taddr , + player* play , + recorder* rec ) +{ // check that recorder is empty + CPPAD_ASSERT_UNKNOWN( rec->num_op_rec() == 0 ); + // + // get a random iterator for this player + play->template setup_random(); + local::play::const_random_iterator random_itr = + play->template get_random(); + + bool conditional_skip = true; + bool compare_op = true; + bool print_for_op = true; + size_t index = 0; + while( index < options.size() ) + { while( index < options.size() && options[index] == ' ' ) + ++index; + std::string option; + while( index < options.size() && options[index] != ' ' ) + option += options[index++]; + if( option != "" ) + { if( option == "no_conditional_skip" ) + conditional_skip = false; + else if( option == "no_compare_op" ) + compare_op = false; + else if( option == "no_print_for_op" ) + print_for_op = false; + else + { option += " is not a valid optimize option"; + CPPAD_ASSERT_KNOWN( false , option.c_str() ); + } + } + } + // number of operators in the player + const size_t num_op = play->num_op_rec(); + CPPAD_ASSERT_UNKNOWN( + num_op < size_t( std::numeric_limits::max() ) + ); + + // number of variables in the player + const size_t num_var = play->num_var_rec(); + + // number of parameter in the player + const size_t num_par = play->num_par_rec(); + + // number of VecAD indices + size_t num_vecad_ind = play->num_vec_ind_rec(); + + // number of VecAD vectors + size_t num_vecad_vec = play->num_vecad_vec_rec(); + + // number of independent dynamic parameters + size_t num_dynamic_ind = play->num_dynamic_ind(); + + // number of dynamic parameters + size_t num_dynamic_par = play->num_dynamic_par(); + + // mapping from dynamic parameter index to paramemter index + const pod_vector& dyn_ind2par_ind( play->dyn_ind2par_ind() ); + + // number of dynamic parameters + CPPAD_ASSERT_UNKNOWN( num_dynamic_ind <= play->num_dynamic_par () ); + + // ----------------------------------------------------------------------- + // operator information + pod_vector cexp2op; + sparse_list cexp_set; + pod_vector vecad_used; + pod_vector op_usage; + get_op_usage( + conditional_skip, + compare_op, + print_for_op, + play, + random_itr, + dep_taddr, + cexp2op, + cexp_set, + vecad_used, + op_usage + ); + pod_vector op_previous; + get_op_previous( + play, + random_itr, + cexp_set, + op_previous, + op_usage + ); + size_t num_cexp = cexp2op.size(); + CPPAD_ASSERT_UNKNOWN( conditional_skip || num_cexp == 0 ); + vector cexp_info; // struct_cexp_info not POD + sparse_list skip_op_true; + sparse_list skip_op_false; + // + if( cexp2op.size() > 0 ) get_cexp_info( + play, + random_itr, + op_previous, + op_usage, + cexp2op, + cexp_set, + cexp_info, + skip_op_true, + skip_op_false + ); + + // We no longer need cexp_set, and cexp2op, so free their memory + cexp_set.resize(0, 0); + cexp2op.clear(); + // ----------------------------------------------------------------------- + // dynamic parameter information + pod_vector par_usage; + get_par_usage( + play, + random_itr, + op_usage, + vecad_used, + par_usage + ); + pod_vector dyn_previous; + get_dyn_previous( + play , + random_itr , + par_usage , + dyn_previous + ); + // ----------------------------------------------------------------------- + + // nan with type Base + Base base_nan = Base( std::numeric_limits::quiet_NaN() ); + + // ------------------------------------------------------------- + // conditional expression information + // + // Size of the conditional expression information structure. + // This is equal to the number of conditional expressions when + // conditional_skip is true, otherwise it is zero. + // + // sort the conditional expression information by max_left_right + // this is the conditional skip order + vector cskip_order(num_cexp); + if( num_cexp > 0 ) + { vector keys(num_cexp); + for(size_t i = 0; i < num_cexp; i++) + keys[i] = size_t( cexp_info[i].max_left_right ); + CppAD::index_sort(keys, cskip_order); + } + // initial index in conditional skip order + size_t cskip_order_next = 0; + // + // initialize index in conditional expression order + size_t cexp_next = 0; + + // mapping from conditional expression index to conditional skip + // information on new tape + pod_vector cskip_new(num_cexp); + // + // flag used to indicate that there is no conditional skip + // for this conditional expression + for(size_t i = 0; i < num_cexp; i++) + cskip_new[i].i_arg = 0; + // ======================================================================= + // Create new recording + // ======================================================================= + // + // dynamic parameter information in player + const pod_vector& dyn_par_is( play->dyn_par_is() ); + const pod_vector& dyn_par_op( play->dyn_par_op() ); + const pod_vector& dyn_par_arg( play->dyn_par_arg() ); + // + // start mapping from old parameter indices to new parameter indices + // for all parameters that get used. + pod_vector new_par( num_par ); + addr_t addr_t_max = std::numeric_limits::max(); + for(size_t i_par = 0; i_par < num_par; ++i_par) + new_par[i_par] = addr_t_max; // initialize as not used + // + // start new recording + CPPAD_ASSERT_UNKNOWN( rec->num_op_rec() == 0 ); + rec->set_num_dynamic_ind(num_dynamic_ind); + rec->set_abort_op_index(0); + rec->set_record_compare( compare_op ); + + // copy parameters with index 0 + CPPAD_ASSERT_UNKNOWN( ! dyn_par_is[0] && isnan( play->GetPar(0) ) ); + rec->put_con_par( play->GetPar(0) ); + new_par[0] = 0; + + // set new_par for the independent dynamic parameters + for(size_t i_par = 1; i_par <= num_dynamic_ind; i_par++) + { CPPAD_ASSERT_UNKNOWN( dyn_par_is[i_par] ); + addr_t i = rec->put_dyn_par(play->GetPar(i_par), ind_dyn); + CPPAD_ASSERT_UNKNOWN( size_t(i) == i_par ); + new_par[i_par] = i; + } + + // set new_par for the constant parameters that are used + for(size_t i_par = num_dynamic_ind + 1; i_par < num_par; ++i_par) + if( ! dyn_par_is[i_par] ) + { CPPAD_ASSERT_UNKNOWN( i_par == 0 || num_dynamic_ind < i_par ); + if( par_usage[i_par] ) + { // value of this parameter + Base par = play->GetPar(i_par); + new_par[i_par] = rec->put_con_par(par); + } + } + + // set new_par for the dependent dynamic parameters + size_t i_dyn = num_dynamic_ind; // dynamic parmaeter index + size_t i_arg = 0; // dynamic parameter argument index + pod_vector arg_vec; + for(size_t i_par = num_dynamic_ind + 1; i_par < num_par; ++i_par) + if( dyn_par_is[i_par] ) + { // operator for this dynamic parameter + op_code_dyn op = op_code_dyn( dyn_par_op[i_dyn] ); + // + // number of arguments for this dynamic parameter + size_t n_arg = num_arg_dyn(op); + // + // number of dynamic parameter results for this operator + size_t n_dyn = 1; + // + if( op == call_dyn ) + { size_t atom_index = size_t( dyn_par_arg[i_arg + 0] ); + size_t atom_n = size_t( dyn_par_arg[i_arg + 1] ); + size_t atom_m = size_t( dyn_par_arg[i_arg + 2] ); + n_dyn = size_t( dyn_par_arg[i_arg + 3] ); + n_arg = 5 + atom_n + atom_m; + // + // check if any dynamic parameter result for this operator is used + bool call_used = false; +# ifndef NDEBUG + bool found_i_par = false; + for(size_t i = 0; i < atom_m; ++i) + { size_t j_par = size_t( dyn_par_arg[i_arg + 4 + atom_n + i] ); + if( dyn_par_is[j_par] ) + { call_used |= par_usage[j_par]; + CPPAD_ASSERT_UNKNOWN( j_par == i_par || found_i_par ); + // j_par > i_par corresponds to result_dyn operator + CPPAD_ASSERT_UNKNOWN( j_par >= i_par ); + found_i_par |= j_par == i_par; + } + } + CPPAD_ASSERT_UNKNOWN( found_i_par ); +# else + for(size_t i = 0; i < atom_m; ++i) + { size_t j_par = size_t( dyn_par_arg[i_arg + 4 + atom_n + i] ); + if( dyn_par_is[j_par] ) + call_used |= par_usage[j_par]; + } +# endif + if( call_used ) + { arg_vec.resize(0); + arg_vec.push_back( addr_t( atom_index ) ); + arg_vec.push_back( addr_t( atom_n ) ); + arg_vec.push_back( addr_t( atom_m ) ); + arg_vec.push_back( addr_t( n_dyn ) ); + for(size_t j = 0; j < atom_n; ++j) + { addr_t arg_j = dyn_par_arg[i_arg + 4 + j]; + if( arg_j > 0 && par_usage[arg_j] ) + arg_vec.push_back( new_par[ arg_j ] ); + else + arg_vec.push_back(0); + } + bool first_dynamic_result = true; + for(size_t i = 0; i < atom_m; ++i) + { addr_t res_i = dyn_par_arg[i_arg + 4 + atom_n + i]; + CPPAD_ASSERT_UNKNOWN( dyn_par_is[res_i] || res_i == 0 ); + // + if( dyn_par_is[res_i] ) + { Base par = play->GetPar( size_t(res_i) ); + if( first_dynamic_result ) + { first_dynamic_result = false; + new_par[res_i] = rec->put_dyn_par(par, call_dyn); + } + else + new_par[res_i] = rec->put_dyn_par(par, result_dyn); + arg_vec.push_back( new_par[res_i] ); + } + else + { // this result is a constant parameter + if( new_par[res_i] != addr_t_max ) + arg_vec.push_back( new_par[res_i] ); + else + { // this constant parameter is not used + arg_vec.push_back(0); // phantom parameter + } + } + } + arg_vec.push_back( addr_t(5 + atom_n + atom_m ) ); + rec->put_dyn_arg_vec( arg_vec ); + } + } + else if( par_usage[i_par] & (op != result_dyn) ) + { size_t j_dyn = size_t( dyn_previous[i_dyn] ); + if( j_dyn != num_dynamic_par ) + { size_t j_par = size_t( dyn_ind2par_ind[j_dyn] ); + CPPAD_ASSERT_UNKNOWN( j_par < i_par ); + new_par[i_par] = new_par[j_par]; + } + else + { + // value of this parameter + Base par = play->GetPar(i_par); + // + if( op == cond_exp_dyn ) + { // cond_exp_dyn + CPPAD_ASSERT_UNKNOWN( num_dynamic_ind <= i_par ); + CPPAD_ASSERT_UNKNOWN( n_arg = 5 ); + new_par[i_par] = rec->put_dyn_cond_exp( + par , // par + CompareOp( dyn_par_arg[i_arg + 0] ), // cop + new_par[ dyn_par_arg[i_arg + 1] ] , // left + new_par[ dyn_par_arg[i_arg + 2] ] , // right + new_par[ dyn_par_arg[i_arg + 3] ] , // if_true + new_par[ dyn_par_arg[i_arg + 4] ] // if_false + ); + } + else if( op == dis_dyn ) + { // dis_dyn + CPPAD_ASSERT_UNKNOWN( n_arg = 2 ); + new_par[i_par] = rec->put_dyn_par( + par , // par + op , // op + dyn_par_arg[i_arg + 0] , // index + new_par[ dyn_par_arg[i_arg + 1] ] // parameter + ); + } + else if( n_arg == 1 ) + { // cases with one argument + CPPAD_ASSERT_UNKNOWN( num_dynamic_ind <= i_par ); + new_par[i_par] = rec->put_dyn_par( par, op, + new_par[ dyn_par_arg[i_arg + 0] ] + ); + } + else if( n_arg == 2 ) + { // cases with two arguments + CPPAD_ASSERT_UNKNOWN( num_dynamic_ind <= i_par ); + new_par[i_par] = rec->put_dyn_par( par, op, + new_par[ dyn_par_arg[i_arg + 0] ], + new_par[ dyn_par_arg[i_arg + 1] ] + ); + } + else + { // independent dynamic parmaeter case + CPPAD_ASSERT_UNKNOWN( op == ind_dyn ) + CPPAD_ASSERT_UNKNOWN( i_par <= num_dynamic_ind ); + CPPAD_ASSERT_UNKNOWN( n_arg == 0 ); + new_par[i_par] = rec->put_dyn_par( par, op); + } + } + } + ++i_dyn; + i_arg += n_arg; + } + // ----------------------------------------------------------------------- + // There is an additional constant parameter for each cumulative summation + // (that does not have a corresponding old parameter index). + // ------------------------------------------------------------------------ + // initialize mapping from old VecAD index to new VecAD index + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= num_vecad_ind + ); + pod_vector new_vecad_ind(num_vecad_ind); + for(size_t i = 0; i < num_vecad_ind; i++) + new_vecad_ind[i] = addr_t( num_vecad_ind ); // invalid index + { + size_t j = 0; // index into the old set of indices + for(size_t i = 0; i < num_vecad_vec; i++) + { // length of this VecAD + size_t length = play->GetVecInd(j); + if( vecad_used[i] ) + { // Put this VecAD vector in new recording + CPPAD_ASSERT_UNKNOWN(length < num_vecad_ind); + new_vecad_ind[j] = rec->PutVecInd( addr_t(length) ); + for(size_t k = 1; k <= length; k++) new_vecad_ind[j+k] = + rec->PutVecInd( + new_par[ play->GetVecInd(j+k) ] + ); + } + // start of next VecAD + j += length + 1; + } + CPPAD_ASSERT_UNKNOWN( j == num_vecad_ind ); + } + + // temporary buffer for new argument values + addr_t new_arg[6]; + + // temporary work space used by record_csum + // (decalared here to avoid realloaction of memory) + struct_csum_stacks csum_work; + + // tempory used to hold a size_pair + struct_size_pair size_pair; + // + // Mapping from old operator index to new variable index, + // zero is invalid except for new_var[0]. + pod_vector new_var(num_op); + // + // Mapping from old operator index to new operator index will share + // memory with op_previous. Must get op_previous[i_op] for this operator + // before over writting it with new_op[i_op]. + pod_vector& new_op( op_previous ); + CPPAD_ASSERT_UNKNOWN( new_op.size() == num_op ); + // ------------------------------------------------------------- + // information for current operator + size_t i_op; // index + OpCode op; // operator + const addr_t* arg; // arguments + size_t i_var; // variable index of primary (last) result + // + // information about atomic function + enum_atom_state atom_state = start_atom; + size_t atom_i = 0; + size_t atom_j = 0; + // + i_var = 0; + for(i_op = 0; i_op < num_op; ++i_op) + { // if non-zero, use previous result in place of this operator. + // Must get this information before writing new_op[i_op]. + size_t previous = size_t( op_previous[i_op] ); + // + // zero is invalid except for new_op[0]. + new_op[i_op] = 0; + // + // Zero is invalid except for new_var[0] and previous is zero unless + // this operator is replace by a previous operator. + new_var[i_op] = 0; + if( op_usage[i_op] == usage_t(yes_usage) ) + new_var[i_op] = new_var[previous]; + // + // temporary used in some switch cases + addr_t mask; + // + // this operator information + size_t i_tmp; + random_itr.op_info(i_op, op, arg, i_tmp); + if( NumRes(op) > 0 ) + i_var = i_tmp; + // + // determine if we should insert a conditional skip here + bool skip = conditional_skip; + if( skip ) + { skip &= cskip_order_next < num_cexp; + skip &= op != BeginOp; + skip &= op != InvOp; + skip &= atom_state == start_atom; + if( skip ) + { size_t j = cskip_order[cskip_order_next]; + if( NumRes(op) > 0 ) + skip &= size_t( cexp_info[j].max_left_right ) < i_var; + else + skip &= size_t( cexp_info[j].max_left_right ) <= i_var; + } + if( skip ) + { size_t j = cskip_order[cskip_order_next]; + cskip_order_next++; + size_t n_true = skip_op_true.number_elements(j); + size_t n_false = skip_op_false.number_elements(j); + skip &= n_true > 0 || n_false > 0; + if( skip ) + { CPPAD_ASSERT_UNKNOWN( NumRes(CSkipOp) == 0 ); + size_t n_arg = 7 + size_t(n_true) + size_t(n_false); + // reserve space for the arguments to this operator but + // delay setting them until we have all the new addresses + cskip_new[j].i_arg = rec->ReserveArg(n_arg); + // i_arg == 0 is used to check if conditional expression + // has been skipped. + CPPAD_ASSERT_UNKNOWN( cskip_new[j].i_arg > 0 ); + // There is no corresponding old operator in this case + rec->PutOp(CSkipOp); + } + } + } + // + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= rec->num_op_rec() + ); + // + // For each call, first and second AFunOp will have same op_usage + skip = op_usage[i_op] != usage_t( yes_usage ); + skip &= atom_state != arg_atom && atom_state != ret_atom; + if( skip ) + { if( op == CExpOp ) + ++cexp_next; + // + if( op == AFunOp ) + { if( atom_state == start_atom ) + atom_state = end_atom; + else + { CPPAD_ASSERT_UNKNOWN( atom_state == end_atom ); + atom_state = start_atom; + } + } + } + else switch( op ) + { // op_usage[i_op] == usage_t(yes_usage) + + case BeginOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + // Put BeginOp at beginning of recording + new_op[i_op] = addr_t( rec->num_op_rec() ); + new_var[i_op] = rec->PutOp(BeginOp); + rec->PutArg(arg[0]); + break; + + // -------------------------------------------------------------- + // Unary operators, argument a variable, one result + 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: + if( previous == 0 ) + { // + new_arg[0] = new_var[ random_itr.var2op(size_t(arg[0])) ]; + rec->PutArg( new_arg[0] ); + // + new_op[i_op] = addr_t( rec->num_op_rec() ); + new_var[i_op] = rec->PutOp(op); + CPPAD_ASSERT_UNKNOWN( + new_arg[0] < new_var[random_itr.var2op(i_var)] + ); + if( op == ErfOp ) + { CPPAD_ASSERT_NARG_NRES(op, 3, 5); + // 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->put_con_par( Base(0.0) ) ); + rec->PutArg( rec->put_con_par( + Base( 1.0 / std::sqrt( std::atan(1.0) ) ) + ) ); + } + else + { // some of these operators have an auxillary result; + // e.g. sine and cosine are computed together. + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(op) ==1 || NumRes(op) == 2 ); + } + } + break; + // --------------------------------------------------- + // Binary operators, left variable, right parameter, one result + case SubvpOp: + // check if this is the top of a csum connection + if( op_usage[ random_itr.var2op(size_t(arg[0])) ] == usage_t(csum_usage) ) + { CPPAD_ASSERT_UNKNOWN( previous == 0 ); + // + // convert to a sequence of summation operators + size_pair = record_csum( + play , + random_itr , + op_usage , + new_par , + new_var , + i_var , + rec , + csum_work + ); + new_op[i_op] = addr_t( size_pair.i_op ); + new_var[i_op] = addr_t( size_pair.i_var ); + // abort rest of this case + break; + } + case DivvpOp: + case PowvpOp: + case ZmulvpOp: + if( previous == 0 ) + { // + size_pair = record_vp( + play , + random_itr , + new_par , + new_var , + i_op , + rec + ); + new_op[i_op] = addr_t( size_pair.i_op ); + new_var[i_op] = addr_t( size_pair.i_var ); + } + break; + // --------------------------------------------------- + // Binary operators, left index, right variable, one result + case DisOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + if( previous == 0 ) + { // + new_arg[0] = arg[0]; + new_arg[1] = new_var[ random_itr.var2op(size_t(arg[1])) ]; + rec->PutArg( new_arg[0], new_arg[1] ); + // + new_op[i_op] = addr_t( rec->num_op_rec() ); + new_var[i_op] = rec->PutOp(op); + CPPAD_ASSERT_UNKNOWN( + new_arg[1] < new_var[random_itr.var2op(i_var)] + ); + } + break; + + // --------------------------------------------------- + // Binary operators, left parameter, right variable, one result + case SubpvOp: + case AddpvOp: + // check if this is the top of a csum connection + if( op_usage[ random_itr.var2op(size_t(arg[1])) ] == usage_t(csum_usage) ) + { CPPAD_ASSERT_UNKNOWN( previous == 0 ); + // + // convert to a sequence of summation operators + size_pair = record_csum( + play , + random_itr , + op_usage , + new_par , + new_var , + i_var , + rec , + csum_work + ); + new_op[i_op] = addr_t( size_pair.i_op ); + new_var[i_op] = addr_t( size_pair.i_var ); + // abort rest of this case + break; + } + case DivpvOp: + case MulpvOp: + case PowpvOp: + case ZmulpvOp: + if( previous == 0 ) + { // + size_pair = record_pv( + play , + random_itr , + new_par , + new_var , + i_op , + rec + ); + new_op[i_op] = addr_t( size_pair.i_op ); + new_var[i_op] = addr_t( size_pair.i_var ); + } + break; + // --------------------------------------------------- + // Binary operator, left and right variables, one result + case AddvvOp: + case SubvvOp: + // check if this is the top of a csum connection + if( + op_usage[ random_itr.var2op(size_t(arg[0])) ] == usage_t(csum_usage) + || + op_usage[ random_itr.var2op(size_t(arg[1])) ] == usage_t(csum_usage) + ) + { CPPAD_ASSERT_UNKNOWN( previous == 0 ); + // + // convert to a sequence of summation operators + size_pair = record_csum( + play , + random_itr , + op_usage , + new_par , + new_var , + i_var , + rec , + csum_work + ); + new_op[i_op] = addr_t( size_pair.i_op ); + new_var[i_op] = addr_t( size_pair.i_var ); + // abort rest of this case + break; + } + case DivvvOp: + case MulvvOp: + case PowvvOp: + case ZmulvvOp: + if( previous == 0 ) + { // + size_pair = record_vv( + play , + random_itr , + new_var , + i_op , + rec + ); + new_op[i_op] = addr_t( size_pair.i_op ); + new_var[i_op] = addr_t( size_pair.i_var ); + } + break; + // --------------------------------------------------- + // Conditional expression operators + case CExpOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 6, 1); + new_arg[0] = arg[0]; + new_arg[1] = arg[1]; + mask = 1; + for(size_t i = 2; i < 6; i++) + { if( arg[1] & mask ) + { new_arg[i] = new_var[ random_itr.var2op(size_t(arg[i])) ]; + CPPAD_ASSERT_UNKNOWN( + size_t(new_arg[i]) < num_var + ); + } + else + new_arg[i] = new_par[ arg[i] ]; + mask = mask << 1; + } + rec->PutArg( + new_arg[0] , + new_arg[1] , + new_arg[2] , + new_arg[3] , + new_arg[4] , + new_arg[5] + ); + new_op[i_op] = addr_t( rec->num_op_rec() ); + new_var[i_op] = rec->PutOp(op); + // + // 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. + if( conditional_skip ) + { CPPAD_ASSERT_UNKNOWN( cexp_next < num_cexp ); + CPPAD_ASSERT_UNKNOWN( + size_t( cexp_info[cexp_next].i_op ) == i_op + ); + cskip_new[ cexp_next ].left = size_t( new_arg[2] ); + cskip_new[ cexp_next ].right = size_t( new_arg[3] ); + ++cexp_next; + } + break; + // --------------------------------------------------- + // Operations with no arguments and no results + case EndOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 0, 0); + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(op); + break; + // --------------------------------------------------- + // Comparison operations: two arguments and no results + case LepvOp: + case LtpvOp: + case EqpvOp: + case NepvOp: + CPPAD_ASSERT_UNKNOWN( compare_op ); + CPPAD_ASSERT_NARG_NRES(op, 2, 0); + if( previous == 0 ) + { new_arg[0] = new_par[ arg[0] ]; + new_arg[1] = new_var[ random_itr.var2op(size_t(arg[1])) ]; + rec->PutArg(new_arg[0], new_arg[1]); + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(op); + } + break; + // + case LevpOp: + case LtvpOp: + CPPAD_ASSERT_UNKNOWN( compare_op ); + CPPAD_ASSERT_NARG_NRES(op, 2, 0); + if( previous == 0 ) + { new_arg[0] = new_var[ random_itr.var2op(size_t(arg[0])) ]; + new_arg[1] = new_par[ arg[1] ]; + rec->PutArg(new_arg[0], new_arg[1]); + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(op); + } + break; + // + case LevvOp: + case LtvvOp: + case EqvvOp: + case NevvOp: + CPPAD_ASSERT_UNKNOWN( compare_op ); + CPPAD_ASSERT_NARG_NRES(op, 2, 0); + if( previous == 0 ) + { new_arg[0] = new_var[ random_itr.var2op(size_t(arg[0])) ]; + new_arg[1] = new_var[ random_itr.var2op(size_t(arg[1])) ]; + rec->PutArg(new_arg[0], new_arg[1]); + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(op); + } + break; + + // --------------------------------------------------- + // Operations with no arguments and one result + case InvOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + new_op[i_op] = addr_t( rec->num_op_rec() ); + new_var[i_op] = rec->PutOp(op); + break; + + // --------------------------------------------------- + // Unary operators, argument a parameter, one result + case ParOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + new_arg[0] = new_par[ arg[0] ]; + rec->PutArg( new_arg[0] ); + // + new_op[i_op] = addr_t( rec->num_op_rec() ); + new_var[i_op] = rec->PutOp(op); + break; + + // --------------------------------------------------- + // print forward operator + case PriOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 5, 0); + // arg[0] + new_arg[0] = arg[0]; + // + // arg[1] + if( arg[0] & 1 ) + { new_arg[1] = new_var[ random_itr.var2op(size_t(arg[1])) ]; + CPPAD_ASSERT_UNKNOWN( size_t(new_arg[1]) < num_var ); + } + else + { new_arg[1] = new_par[ arg[1] ]; + } + // + // arg[3] + if( arg[0] & 2 ) + { new_arg[3] = new_var[ random_itr.var2op(size_t(arg[3])) ]; + CPPAD_ASSERT_UNKNOWN( size_t(new_arg[3]) < num_var ); + } + else + { new_arg[3] = new_par[ arg[3] ]; + } + new_arg[2] = rec->PutTxt( play->GetTxt(size_t(arg[2])) ); + new_arg[4] = rec->PutTxt( play->GetTxt(size_t(arg[4])) ); + // + rec->PutArg( + new_arg[0] , + new_arg[1] , + new_arg[2] , + new_arg[3] , + new_arg[4] + ); + // new operator + new_op[i_op] = addr_t( rec->num_op_rec() ); + // no new variable + rec->PutOp(op); + break; + + // --------------------------------------------------- + // VecAD operators + + // Load using a parameter index + case LdpOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 3, 1); + new_arg[0] = new_vecad_ind[ arg[0] ]; + new_arg[1] = arg[1]; + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= rec->num_load_op_rec() + ); + new_arg[2] = addr_t( rec->num_load_op_rec() ); + CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < num_vecad_ind ); + rec->PutArg( + new_arg[0], + new_arg[1], + new_arg[2] + ); + new_op[i_op] = addr_t( rec->num_op_rec() ); + new_var[i_op] = rec->PutLoadOp(op); + break; + + // Load using a variable index + case LdvOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 3, 1); + new_arg[0] = new_vecad_ind[ arg[0] ]; + new_arg[1] = new_var[ random_itr.var2op(size_t(arg[1])) ]; + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= rec->num_load_op_rec() + ); + new_arg[2] = addr_t( 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], + new_arg[2] + ); + new_op[i_op] = addr_t( rec->num_op_rec() ); + new_var[i_op] = rec->PutLoadOp(op); + break; + + // Store a parameter using a parameter index + case StppOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 3, 0); + new_arg[0] = new_vecad_ind[ arg[0] ]; + new_arg[1] = new_par[ arg[1] ]; + new_arg[2] = new_par[ arg[2] ]; + CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < num_vecad_ind ); + rec->PutArg( + new_arg[0], + new_arg[1], + new_arg[2] + ); + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(op); + break; + + // Store a parameter using a variable index + case StvpOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 3, 0); + new_arg[0] = new_vecad_ind[ arg[0] ]; + new_arg[1] = new_var[ random_itr.var2op(size_t(arg[1])) ]; + new_arg[2] = new_par[ arg[2] ]; + 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[2] + ); + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(op); + break; + + // Store a variable using a parameter index + case StpvOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 3, 0); + new_arg[0] = new_vecad_ind[ arg[0] ]; + new_arg[1] = new_par[ arg[1] ]; + new_arg[2] = new_var[ random_itr.var2op(size_t(arg[2])) ]; + CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < num_vecad_ind ); + CPPAD_ASSERT_UNKNOWN( size_t(new_arg[2]) < num_var ); + rec->PutArg( + new_arg[0], + new_arg[1], + new_arg[2] + ); + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(op); + break; + + // Store a variable using a variable index + case StvvOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 3, 0); + new_arg[0] = new_vecad_ind[ arg[0] ]; + new_arg[1] = new_var[ random_itr.var2op(size_t(arg[1])) ]; + new_arg[2] = new_var[ random_itr.var2op(size_t(arg[2])) ]; + CPPAD_ASSERT_UNKNOWN( size_t(new_arg[0]) < num_vecad_ind ); + 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[2] + ); + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(op); + break; + + // ----------------------------------------------------------- + // atomic function call operators + + case AFunOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 4, 0); + // atom_index, atom_old, atom_n, atom_m + rec->PutArg(arg[0], arg[1], arg[2], arg[3]); + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(AFunOp); + if( atom_state == start_atom ) + { atom_state = arg_atom; + atom_j = size_t( arg[2] ); // just for counting arguments + atom_i = size_t( arg[3] ); // just for counting results + CPPAD_ASSERT_UNKNOWN( atom_j > 0 ); + CPPAD_ASSERT_UNKNOWN( atom_i > 0 ); + } + else + { CPPAD_ASSERT_UNKNOWN( atom_state == end_atom ); + atom_state = start_atom; + } + break; + + case FunapOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + new_arg[0] = new_par[ arg[0] ]; + if( new_arg[0] != addr_t_max ) + rec->PutArg(new_arg[0]); + else + rec->PutArg(0); // argument not used + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(FunapOp); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + --atom_j; + if( atom_j == 0 ) + atom_state = ret_atom; + break; + + case FunavOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + new_arg[0] = new_var[ random_itr.var2op(size_t(arg[0])) ]; + if( size_t(new_arg[0]) < num_var ) + { rec->PutArg(new_arg[0]); + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(FunavOp); + } + else + { // This argument does not affect the result and + // has been optimized out so use nan in its place. + new_arg[0] = rec->put_con_par( base_nan ); + rec->PutArg(new_arg[0]); + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(FunapOp); + } + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + --atom_j; + if( atom_j == 0 ) + atom_state = ret_atom; + break; + + case FunrpOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + new_arg[0] = new_par[ arg[0] ]; + if( new_arg[0] != addr_t_max ) + { // This parameter is used, but may not by this operation + rec->PutArg(new_arg[0]); + } + else + { // This parameter is not used here or anywhere. + CPPAD_ASSERT_UNKNOWN( op_usage[i_op] == usage_t(no_usage) ); + rec->PutArg(0); // result not used + } + new_op[i_op] = addr_t( rec->num_op_rec() ); + rec->PutOp(FunrpOp); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + --atom_i; + if( atom_i == 0 ) + atom_state = end_atom; + break; + + case FunrvOp: + CPPAD_ASSERT_UNKNOWN( previous == 0 ); + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + new_op[i_op] = addr_t( rec->num_op_rec() ); + if( op_usage[i_op] == usage_t(yes_usage) ) + new_var[i_op] = rec->PutOp(FunrvOp); + else + { // change FunrvOp -> FunrpOp to avoid creating new variable + CPPAD_ASSERT_UNKNOWN( op_usage[i_op] == usage_t(no_usage) ); + CPPAD_ASSERT_NARG_NRES(FunrpOp, 1, 0); + rec->PutArg(0); // result not used + rec->PutOp(FunrpOp); + } + + --atom_i; + if( atom_i == 0 ) + atom_state = end_atom; + break; + // --------------------------------------------------- + + // all cases should be handled above + default: + CPPAD_ASSERT_UNKNOWN(false); + + } + } + // modify the dependent variable vector to new indices + for(size_t i = 0; i < dep_taddr.size(); i++ ) + { dep_taddr[i] = size_t(new_var[ random_itr.var2op(dep_taddr[i]) ]); + CPPAD_ASSERT_UNKNOWN( size_t(dep_taddr[i]) < num_var ); + } + +# ifndef NDEBUG + for(i_op = 0; i_op < num_op; i_op++) + { random_itr.op_info(i_op, op, arg, i_var); + if( NumRes(op) > 0 ) + CPPAD_ASSERT_UNKNOWN( + size_t(new_op[i_op]) < rec->num_op_rec() + ); + } +# endif + // make sure that all the conditional expressions have been + // checked to see if they are still present + CPPAD_ASSERT_UNKNOWN( cskip_order_next == num_cexp ); + // fill in the arguments for the CSkip operations + for(size_t i = 0; i < num_cexp; i++) + { // if cskip_new[i].i_arg == 0, this conditional expression was skipped + if( cskip_new[i].i_arg > 0 ) + { // size_t i_arg + struct_cexp_info info = cexp_info[i]; + addr_t n_true = addr_t( skip_op_true.number_elements(i) ); + addr_t n_false = addr_t( skip_op_false.number_elements(i) ); + i_arg = cskip_new[i].i_arg; + addr_t left = addr_t( cskip_new[i].left ); + addr_t right = addr_t( cskip_new[i].right ); + rec->ReplaceArg(i_arg++, addr_t(info.cop) ); + rec->ReplaceArg(i_arg++, addr_t(info.flag) ); + rec->ReplaceArg(i_arg++, left ); + rec->ReplaceArg(i_arg++, right ); + rec->ReplaceArg(i_arg++, n_true ); + rec->ReplaceArg(i_arg++, n_false ); + sparse_list::const_iterator itr_true(skip_op_true, i); + while( *itr_true != skip_op_true.end() ) + { i_op = *itr_true; + // op_usage[i_op] == usage_t(yes_usage) + CPPAD_ASSERT_UNKNOWN( new_op[i_op] != 0 ); + rec->ReplaceArg(i_arg++, new_op[i_op] ); + // + ++itr_true; + } + sparse_list::const_iterator itr_false(skip_op_false, i); + while( *itr_false != skip_op_false.end() ) + { i_op = *itr_false; + // op_usage[i_op] == usage_t(yes_usage) + CPPAD_ASSERT_UNKNOWN( new_op[i_op] != 0 ); + rec->ReplaceArg(i_arg++, new_op[i_op] ); + // + ++itr_false; + } + rec->ReplaceArg(i_arg++, n_true + n_false); +# ifndef NDEBUG + size_t n_arg = 7 + size_t(n_true) + size_t(n_false); + CPPAD_ASSERT_UNKNOWN( cskip_new[i].i_arg + n_arg == i_arg ); +# endif + } + } +} + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/record_csum.hpp cppad-2019.02.00.0/include/cppad/local/optimize/record_csum.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/record_csum.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/record_csum.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,330 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_RECORD_CSUM_HPP +# define CPPAD_LOCAL_OPTIMIZE_RECORD_CSUM_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file record_csum.hpp +Recording a cummulative cummulative summation. +*/ + +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { +/*! +Recording a cummulative cummulative summation. + +\param play +player object corresponding to the old recroding. + +\param random_itr +is a random iterator corresponding to the old operation sequence. + +\param op_usage +mapping from old index to how it is used. + +\param new_par +mapping from old parameter index to parameter index in new recording. + +\param new_var +mapping from old operator index to variable index in new recording. + +\param current +is the index in the old operation sequence for +the variable corresponding to the result for the current operator. +We use the notation i_op = random_itr.var2op(current). +It follows that NumRes( random_itr.get_op[i_op] ) > 0. +If 0 < j_op < i_op, either op_usage[j_op] == usage_t(csum_usage), +op_usage[j_op] = usage_t(no_usage), or new_var[j_op] != 0. + +\param rec +is the object that will record the new operations. + +\return +is the operator and variable indices in the new operation sequence. + +\param stack +Is temporary work space. On input and output, +stack.op_info, stack.add_var, and stack.sub_var, are all empty. +These stacks are passed in so that they are created once +and then be reused with calls to record_csum. + +\par Assumptions +random_itr.get_op[i_op] +must be one of AddpvOp, AddvvOp, SubpvOp, SubvpOp, SubvvOp. +op_usage[i_op] != usage_t(no_usage) and ! op_usage[i_op] == usage_type(csum_usage). +Furthermore op_usage[j_op] == usage_t(csum_usage) is true from some +j_op that corresponds to a variable that is an argument to +random_itr.get_op[i_op]. +*/ + +template +struct_size_pair record_csum( + const player* play , + const play::const_random_iterator& random_itr , + const pod_vector& op_usage , + const pod_vector& new_par , + const pod_vector& new_var , + size_t current , + recorder* rec , + // local information passed so stacks need not be allocated for every call + struct_csum_stacks& stack ) +{ +# ifndef NDEBUG + // number of parameters corresponding to the old operation sequence. + size_t npar = play->num_par_rec(); +# endif + + // vector of length npar containing the parameters the old operation + // sequence; i.e., given a parameter index i < npar, the corresponding + // parameter value is par[i]. + const Base* par = play->GetPar(); + + // which parameters are dynamic + const pod_vector& dyn_par_is( play->dyn_par_is() ); + + // check assumption about work space + CPPAD_ASSERT_UNKNOWN( stack.op_info.empty() ); + CPPAD_ASSERT_UNKNOWN( stack.add_var.empty() ); + CPPAD_ASSERT_UNKNOWN( stack.sub_var.empty() ); + // + size_t i_op = random_itr.var2op(current); + CPPAD_ASSERT_UNKNOWN( ! ( op_usage[i_op] == usage_t(csum_usage) ) ); + // + // information corresponding to the root node in the cummulative summation + struct struct_csum_op_info info; + size_t not_used; + random_itr.op_info(i_op, info.op, info.arg, not_used); + info.add = true; // was parrent operator positive or negative + // + // initialize stack as containing this one operator + stack.op_info.push( info ); + // + // initialize sum of parameter values as zero + Base sum_par(0); + // +# ifndef NDEBUG + bool ok = false; + if( info.op == SubvpOp ) ok = + op_usage[ random_itr.var2op(size_t(info.arg[0])) ] == usage_t(csum_usage); + // + if( info.op == AddpvOp || info.op == SubpvOp ) ok = + op_usage[ random_itr.var2op(size_t(info.arg[1])) ] == usage_t(csum_usage); + // + if( info.op == AddvvOp || info.op == SubvvOp ) + { ok = + op_usage[ random_itr.var2op(size_t(info.arg[0])) ] == usage_t(csum_usage); + // + ok |= + op_usage[ random_itr.var2op(size_t(info.arg[1])) ] == usage_t(csum_usage); + // + } + CPPAD_ASSERT_UNKNOWN( ok ); +# endif + // + // while there are operators left on the stack + while( ! stack.op_info.empty() ) + { // get this summation operator + info = stack.op_info.top(); + stack.op_info.pop(); + OpCode op = info.op; + const addr_t* arg = info.arg; + bool add = info.add; + // ------------------------------------------------------------------- + // process first argument to this operator + // (first argument has same sign as parent node) + // ------------------------------------------------------------------- + switch(op) + { // cases where first argument is a parameter + case AddpvOp: + case SubpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < npar ); + // + if( dyn_par_is[ arg[0] ] ) + { // first argument is a dynamic parameter + // (can't yet be a result, so no nodes below) + if( add ) + stack.add_dyn.push(arg[0]); + else + stack.sub_dyn.push(arg[0]); + } + else + { // first argument is not a dynamic parameter + if( add ) + sum_par += par[arg[0]]; + else + sum_par -= par[arg[0]]; + } + break; + + // cases where first argument is a variable + case AddvvOp: + case SubvpOp: + case SubvvOp: + // + // check if the first argument has csum usage + if( op_usage[random_itr.var2op(size_t(arg[0]))] == usage_t(csum_usage) ) + { CPPAD_ASSERT_UNKNOWN( + size_t( new_var[ random_itr.var2op(size_t(arg[0])) ]) == 0 + ); + // push the operator corresponding to the first argument + size_t i_op_tmp = random_itr.var2op(size_t(arg[0])); + random_itr.op_info(i_op_tmp, info.op, info.arg, not_used); + info.add = add; + stack.op_info.push( info ); + } + else + { // there are no nodes below this one + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < current ); + if( add ) + stack.add_var.push(arg[0]); + else + stack.sub_var.push(arg[0]); + } + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + } + // ------------------------------------------------------------------- + // process second argument to this operator + // (second arugment switches sign if subtracting) + // ------------------------------------------------------------------- + switch(op) + { // cases where second argument is a parameter + case SubvpOp: + // second argument has opposite sign of parent node + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < npar ); + // + if( dyn_par_is[ arg[1] ] ) + { // second argument is a dynamic parmaeter + // (can't yet be a result, so no nodes below) + if( add ) + stack.sub_dyn.push(arg[1]); + else + stack.add_dyn.push(arg[1]); + } + else + { // second argument is not a dynamic parameter + if( add ) + sum_par -= par[arg[1]]; + else + sum_par += par[arg[1]]; + } + break; + + // cases where second argument is a variable and has opposite sign + case SubvvOp: + case SubpvOp: + add = ! add; + + // cases where second argument is a variable and has same sign + case AddvvOp: + case AddpvOp: + // check if the second argument has csum usage + if( op_usage[random_itr.var2op(size_t(arg[1]))] == usage_t(csum_usage) ) + { CPPAD_ASSERT_UNKNOWN( + size_t( new_var[ random_itr.var2op(size_t(arg[1])) ]) == 0 + ); + // push the operator corresoponding to the second arugment + size_t i_op_tmp = random_itr.var2op(size_t(arg[1])); + random_itr.op_info(i_op_tmp, info.op, info.arg, not_used); + info.add = add; + stack.op_info.push( info ); + } + else + { // there are no nodes below this one + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < current ); + if( add ) + stack.add_var.push(arg[1]); + else + stack.sub_var.push(arg[1]); + } + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + } + } + // number of variables to add in this cummulative sum operator + size_t n_add_var = stack.add_var.size(); + + // number of variables to subtract in this cummulative sum operator + size_t n_sub_var = stack.sub_var.size(); + + // number of dynamics to add in this cummulative sum operator + size_t n_add_dyn = stack.add_dyn.size(); + + // number of dynamics to subtract in this cummulative sum operator + size_t n_sub_dyn = stack.sub_dyn.size(); + + // first five arguments to cumulative sum operator + addr_t new_arg = rec->put_con_par(sum_par); + rec->PutArg(new_arg); // arg[0]: initial sum + size_t end = n_add_var + 5; + rec->PutArg( addr_t(end) ); // arg[1]: end for add variables + end += n_sub_var; + rec->PutArg( addr_t(end) ); // arg[2]: end for sub variables + end += n_add_dyn; + rec->PutArg( addr_t(end) ); // arg[3]: end for add dynamics + end += n_sub_dyn; + rec->PutArg( addr_t(end) ); // arg[4]: end for sub dynamics + + // addition variable arguments + for(size_t i = 0; i < n_add_var; i++) + { CPPAD_ASSERT_UNKNOWN( ! stack.add_var.empty() ); + addr_t old_arg = stack.add_var.top(); + new_arg = new_var[ random_itr.var2op(size_t(old_arg)) ]; + CPPAD_ASSERT_UNKNOWN( 0 < new_arg && size_t(new_arg) < current ); + rec->PutArg(new_arg); // arg[5+i] + stack.add_var.pop(); + } + + // subtraction variable arguments + for(size_t i = 0; i < n_sub_var; i++) + { CPPAD_ASSERT_UNKNOWN( ! stack.sub_var.empty() ); + addr_t old_arg = stack.sub_var.top(); + new_arg = new_var[ random_itr.var2op(size_t(old_arg)) ]; + CPPAD_ASSERT_UNKNOWN( 0 < new_arg && size_t(new_arg) < current ); + rec->PutArg(new_arg); // arg[arg[1] + i] + stack.sub_var.pop(); + } + + // addition dynamic arguments + for(size_t i = 0; i < n_add_dyn; ++i) + { addr_t old_arg = stack.add_dyn.top(); + new_arg = new_par[ old_arg ]; + rec->PutArg(new_arg); // arg[arg[2] + i] + stack.add_dyn.pop(); + } + + // subtraction dynamic arguments + for(size_t i = 0; i < n_sub_dyn; ++i) + { addr_t old_arg = stack.sub_dyn.top(); + new_arg = new_par[ old_arg ]; + rec->PutArg(new_arg); // arg[arg[3] + i] + stack.sub_dyn.pop(); + } + + // number of additions plus number of subtractions + rec->PutArg( addr_t(end) ); // arg[arg[4]] = arg[4] + // + // return value + struct_size_pair ret; + ret.i_op = rec->num_op_rec(); + ret.i_var = size_t(rec->PutOp(CSumOp)); + // + return ret; +} + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/record_pv.hpp cppad-2019.02.00.0/include/cppad/local/optimize/record_pv.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/record_pv.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/record_pv.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,102 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_RECORD_PV_HPP +# define CPPAD_LOCAL_OPTIMIZE_RECORD_PV_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file record_pv.hpp +Record an operation of the form (parameter op variable). +*/ +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { + +/*! +Record an operation of the form (parameter op variable). + +\param play +player object corresponding to the old recroding. + +\param random_itr +random iterator corresponding to old recording. + +\param new_par +mapping from old parameter index to parameter index in new recording. + +\param new_var +mapping from old operator index to variable index in new recording. + +\param i_op +is the index in the old operation sequence for this operator. +The operator must be one of the following: +AddpvOp, DivpvOp, MulpvOp, PowpvOp, SubpvOp, ZmulpvOp. + +\param rec +is the object that will record the new operations. + +\return +is the operator and variable indices in the new operation sequence. +*/ +template +struct_size_pair record_pv( + const player* play , + const play::const_random_iterator& random_itr , + const pod_vector& new_par , + const pod_vector& new_var , + size_t i_op , + recorder* rec ) +{ + // get_op_info + OpCode op; + const addr_t* arg; + size_t i_var; + random_itr.op_info(i_op, op, arg, i_var); + // +# ifndef NDEBUG + switch(op) + { case AddpvOp: + case DivpvOp: + case MulpvOp: + case PowpvOp: + case SubpvOp: + case ZmulpvOp: + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + } + // number of parameters corresponding to the old operation sequence. + size_t npar = play->num_par_rec(); +# endif + // + // vector of length npar containing the parameters the old operation + // sequence; i.e., given a parameter index i < npar, the corresponding + // parameter value is par[i]. + // + CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < npar ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_var ); // DAG condition + // + addr_t new_arg[2]; + new_arg[0] = new_par[ arg[0] ]; + new_arg[1] = new_var[ random_itr.var2op(size_t(arg[1])) ]; + rec->PutArg( new_arg[0], new_arg[1] ); + // + struct_size_pair ret; + ret.i_op = rec->num_op_rec(); + ret.i_var = size_t(rec->PutOp(op)); + CPPAD_ASSERT_UNKNOWN( 0 < new_arg[1] && size_t(new_arg[1]) < ret.i_var ); + return ret; +} + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/record_vp.hpp cppad-2019.02.00.0/include/cppad/local/optimize/record_vp.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/record_vp.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/record_vp.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,101 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_RECORD_VP_HPP +# define CPPAD_LOCAL_OPTIMIZE_RECORD_VP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file record_vp.hpp +Record an operation of the form (variable op parameter). +*/ +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { + + +/*! +Record an operation of the form (variable op parameter). + +\param play +player object corresponding to the old recroding. + +\param random_itr +is a random iterator corresponding to the old recording. + +\param new_par +mapping from old parameter index to parameter index in new recording. + +\param new_var +mapping from old operator index to variable index in new recording. + +\param i_op +is the index in the old operation sequence for this operator. +the must be one of the following: +DivvpOp, PowvpOp, SubvpOp, ZmulvpOp. + +\param rec +is the object that will record the new operations. + +\return +is the operator and variable indices in the new operation sequence. +*/ +template +struct_size_pair record_vp( + const player* play , + const play::const_random_iterator& random_itr , + const pod_vector& new_par , + const pod_vector& new_var , + size_t i_op , + recorder* rec ) +{ + // get_op_info + OpCode op; + const addr_t* arg; + size_t i_var; + random_itr.op_info(i_op, op, arg, i_var); + // +# ifndef NDEBUG + switch(op) + { case DivvpOp: + case PowvpOp: + case SubvpOp: + case ZmulvpOp: + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + } + // number of parameters corresponding to the old operation sequence. + size_t npar = play->num_par_rec(); +# endif + + // vector of length npar containing the parameters the old operation + // sequence; i.e., given a parameter index i < npar, the corresponding + // parameter value is par[i]. + // + CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_var ); // DAG condition + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < npar ); + // + addr_t new_arg[2]; + new_arg[0] = new_var[ random_itr.var2op(size_t(arg[0])) ]; + new_arg[1] = new_par[ arg[1] ]; + rec->PutArg( new_arg[0], new_arg[1] ); + // + struct_size_pair ret; + ret.i_op = rec->num_op_rec(); + ret.i_var = size_t(rec->PutOp(op)); + CPPAD_ASSERT_UNKNOWN( 0 < new_arg[0] && size_t(new_arg[0]) < ret.i_var ); + return ret; +} + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/record_vv.hpp cppad-2019.02.00.0/include/cppad/local/optimize/record_vv.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/record_vv.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/record_vv.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,91 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_RECORD_VV_HPP +# define CPPAD_LOCAL_OPTIMIZE_RECORD_VV_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file record_vv.hpp +Record an operation of the form (variable op variable). +*/ +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { +/*! +Record an operation of the form (variable op variable). + +\param play +player object corresponding to the old recroding. + +\param random_itr +random iterator corresponding to the old recording. + +\param new_var +mapping from old operator index to variable index in new recording. + +\param i_op +is the index in the old operation sequence for this operator. +the must be one of the following: +AddvvOp, DivvvOp, MulvvOp, PowvvOp, SubvvOp, ZmulvvOp. + +\param rec +is the object that will record the new operations. + +\return +is the operator and variable indices in the new operation sequence. +*/ +template +struct_size_pair record_vv( + const player* play , + const play::const_random_iterator& random_itr , + const pod_vector& new_var , + size_t i_op , + recorder* rec ) +{ + // get_op_info + OpCode op; + const addr_t* arg; + size_t i_var; + random_itr.op_info(i_op, op, arg, i_var); + // +# ifndef NDEBUG + switch(op) + { case AddvvOp: + case DivvvOp: + case MulvvOp: + case PowvvOp: + case SubvvOp: + case ZmulvvOp: + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + } +# endif + CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_var ); // DAG condition + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_var ); // DAG condition + // + addr_t new_arg[2]; + new_arg[0] = new_var[ random_itr.var2op(size_t(arg[0])) ]; + new_arg[1] = new_var[ random_itr.var2op(size_t(arg[1])) ]; + rec->PutArg( new_arg[0], new_arg[1] ); + // + struct_size_pair ret; + ret.i_op = rec->num_op_rec(); + ret.i_var = size_t(rec->PutOp(op)); + CPPAD_ASSERT_UNKNOWN( 0 < new_arg[0] && size_t(new_arg[0]) < ret.i_var ); + CPPAD_ASSERT_UNKNOWN( 0 < new_arg[1] && size_t(new_arg[1]) < ret.i_var ); + return ret; +} + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/size_pair.hpp cppad-2019.02.00.0/include/cppad/local/optimize/size_pair.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/size_pair.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/size_pair.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,32 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_SIZE_PAIR_HPP +# define CPPAD_LOCAL_OPTIMIZE_SIZE_PAIR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/*! +\file size_pair.hpp +Information for one variable and one operation sequence. +*/ +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { + +/*! +\file size_pair.hpp +Information for one variable in one operation sequence. +*/ +struct struct_size_pair { + size_t i_op; /// operator index for this variable + size_t i_var; /// variable index for this variable +}; + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/optimize/usage.hpp cppad-2019.02.00.0/include/cppad/local/optimize/usage.hpp --- cppad-2018.00.00.0/include/cppad/local/optimize/usage.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/optimize/usage.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,39 @@ +# ifndef CPPAD_LOCAL_OPTIMIZE_USAGE_HPP +# define CPPAD_LOCAL_OPTIMIZE_USAGE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include + +// BEGIN_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +namespace CppAD { namespace local { namespace optimize { + +typedef CPPAD_VEC_ENUM_TYPE usage_t; + +enum enum_usage { + /// This operator is not used. + no_usage, + + /// This operator is used one or more times. + yes_usage, + + /*! + This operator is only used once, it is a summation operator, + and its parrent is a summation operator. Furthermore, its result is not + a dependent variable. Hence case it can be removed as part of a + cumulative summation starting at its parent or above. + */ + csum_usage +}; + + +} } } // END_CPPAD_LOCAL_OPTIMIZE_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/parameter_op.hpp cppad-2019.02.00.0/include/cppad/local/parameter_op.hpp --- cppad-2018.00.00.0/include/cppad/local/parameter_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/parameter_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,89 @@ +# ifndef CPPAD_LOCAL_PARAMETER_OP_HPP +# define CPPAD_LOCAL_PARAMETER_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file parameter_op.hpp +Zero order forward mode for ParOp +*/ + + +/*! +Compute zero order forward mode Taylor coefficient for result of op = ParOp. + +The C++ source code corresponding to this operation is one of the following +\verbatim + ADFun f(x, y) + f.Dependent(x, y) +\endverbatim +where some of the components of the vector y are parameters. + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base . + +\param i_z +variable index corresponding to the result for this operation; +i.e. the row index in taylor corresponding to the component of y +that is a parameter. + +\param arg + arg[0] +\n +index corresponding to the parameter value for this operator. + +\param num_par +is the number of parameters in parameter. + +\param parameter +\b Input: parameter[ arg[0] ] is the value of a component +of y that is a parameter. + +\param cap_order +number of colums in the matrix containing all the Taylor coefficients. + +\param taylor +\b Output: taylor [ i_z * 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 size_t(arg[0]) < num_par +\li 0 < cap_order +*/ +template +void forward_par_op_0( + size_t i_z , + const addr_t* arg , + size_t num_par , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(ParOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(ParOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + + Base* z = taylor + i_z * cap_order; + + z[0] = parameter[ arg[0] ]; +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/play/addr_enum.hpp cppad-2019.02.00.0/include/cppad/local/play/addr_enum.hpp --- cppad-2018.00.00.0/include/cppad/local/play/addr_enum.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/play/addr_enum.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,30 @@ +# ifndef CPPAD_LOCAL_PLAY_ADDR_ENUM_HPP +# define CPPAD_LOCAL_PLAY_ADDR_ENUM_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN_CPPAD_LOCAL_PLAY_NAMESPACE +namespace CppAD { namespace local { namespace play { + +/*! +\file addr_enum.hpp +*/ +/// enum corresponding to type used for addressing iterators for a player +enum addr_enum { + unsigned_short_enum , + unsigned_int_enum , + size_t_enum +}; + +} } } // BEGIN_CPPAD_LOCAL_PLAY_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/play/atom_op_info.hpp cppad-2019.02.00.0/include/cppad/local/play/atom_op_info.hpp --- cppad-2018.00.00.0/include/cppad/local/play/atom_op_info.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/play/atom_op_info.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,89 @@ +# ifndef CPPAD_LOCAL_PLAY_ATOM_OP_INFO_HPP +# define CPPAD_LOCAL_PLAY_ATOM_OP_INFO_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN_CPPAD_LOCAL_PLAY_NAMESPACE +namespace CppAD { namespace local { namespace play { + +/*! +\file atom_op_info.hpp +*/ + +/*! +\brief +Unpack extra information corresponding to a AFunOp + +\param op [in] +must be a AFunOp + +\param op_arg [in] +is the arguments for this operator + +\param atom_old [out] +is the extra information passed to the old style atomic functions. + +\param atom_index [out] +is the index in local::atomic_index corresponding to this atomic functions. + +\param atom_m [out] +is the number of results for this user atmoic function. + +\param atom_n [out] +is the number of arguments for this user atmoic function. + +\return +Is a pointer to this atomic function. +*/ +// MUSTDO: change return to void once all sweeps switch to use call_atomic. +template +atomic_base* atom_op_info( + const OpCode op , + const addr_t* op_arg , + size_t& atom_index , + size_t& atom_old , + size_t& atom_m , + size_t& atom_n ) +{ atomic_base* atom_fun; + // + CPPAD_ASSERT_UNKNOWN( op == AFunOp ); + CPPAD_ASSERT_NARG_NRES(op, 4, 0); + // + atom_index = size_t(op_arg[0]); + atom_old = size_t(op_arg[1]); + atom_n = size_t(op_arg[2]); + atom_m = size_t(op_arg[3]); + CPPAD_ASSERT_UNKNOWN( atom_n > 0 ); + // + bool set_null = false; + size_t type = 0; // set to avoid warning + std::string* name_ptr = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, atom_index, type, name_ptr, v_ptr); + if( type == 3 ) + return CPPAD_NULL; +# ifndef NDEBUG + if( v_ptr == CPPAD_NULL ) + { // atom_fun is null so cannot use atom_fun->afun_name() + std::string msg = atomic_base::class_name(atom_index) + + ": atomic_base function has been deleted"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# endif + // the atomic_base object corresponding to this atomic function + atom_fun = reinterpret_cast< atomic_base* >( v_ptr ); + return atom_fun; +} + +} } } // END_CPPAD_LOCAL_PLAY_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/play/player.hpp cppad-2019.02.00.0/include/cppad/local/play/player.hpp --- cppad-2018.00.00.0/include/cppad/local/play/player.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/play/player.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,872 @@ +# ifndef CPPAD_LOCAL_PLAY_PLAYER_HPP +# define CPPAD_LOCAL_PLAY_PLAYER_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include +# include +# include +# include + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file player.hpp +File used to define the player class. +*/ + +/*! +Class used to store and play back an operation sequence recording. + +\tparam Base +These were AD< Base > operations when recorded. Operations during playback +are done using the type Base . +*/ + +template +class player { + // player must be a friend of player< AD > for base2ad to work + template friend class player; +private: + // ---------------------------------------------------------------------- + // information that defines the recording + + /// Number of independent dynamic parameters + size_t num_dynamic_ind_; + + /// Number of variables in the recording. + size_t num_var_rec_; + + /// number of vecad load opeations in the reconding + size_t num_load_op_rec_; + + /// Number of VecAD vectors in the recording + size_t num_vecad_vec_rec_; + + /// The operators in the recording. + pod_vector op_vec_; + + /// The operation argument indices in the recording + pod_vector arg_vec_; + + /// Character strings ('\\0' terminated) in the recording. + pod_vector text_vec_; + + /// The VecAD indices in the recording. + pod_vector vecad_ind_vec_; + + /// All of the parameters in the recording. + /// Use pod_maybe because Base may not be plain old data. + pod_vector_maybe all_par_vec_; + + /// Which elements of all_par_vec_ are dynamic parameters + /// (size equal number of parametrers) + pod_vector dyn_par_is_; + + /// mapping from dynamic parameter index to parameter index + /// 1: size equal to number of dynamic parameters + /// 2: dyn_ind2par_ind_[j] < dyn_ind2par_ind_[j+1] + pod_vector dyn_ind2par_ind_; + + /// operators for just the dynamic parameters + /// (size equal number of dynamic parameters) + pod_vector dyn_par_op_; + + /// arguments for the dynamic parameter operators + pod_vector dyn_par_arg_; + + // ---------------------------------------------------------------------- + // Information needed to use member functions that begin with random_ + // and for using const_subgraph_iterator. + + /// index in arg_vec_ corresonding to the first argument for each operator + pod_vector op2arg_vec_; + + /*! + Index of the result variable for each operator. If the operator has + no results, this is not defined. The invalid index num_var_rec_ is used + when NDEBUG is not defined. If the operator has more than one result, this + is the primary result; i.e., the last result. Auxillary are only used by + the operator and not used by other operators. + */ + pod_vector op2var_vec_; + + /// Mapping from primary variable index to corresponding operator index. + /// This is used to traverse sub-graphs of the operation sequence. + /// This value is valid (invalid) for primary (auxillary) variables. + pod_vector var2op_vec_; + +public: + // ================================================================= + /// default constructor + // set all scalars to zero to avoid valgraind warning when ani assignment + // occures before values get set. + player(void) : + num_dynamic_ind_(0) , + num_var_rec_(0) , + num_load_op_rec_(0) , + num_vecad_vec_rec_(0) + { } + // ================================================================= + /// copy constructor (needed for base2ad) + player(const player& play) + { // 2DO: want to use move semantics here because it is a temporary + // in base2ad case. + *this = play; + } + + // ================================================================= + /// destructor + ~player(void) + { } + // ====================================================================== + /// type used for addressing iterators for this player + play::addr_enum address_type(void) const + { + // required + size_t required = 0; + required = std::max(required, num_var_rec_ ); // number variables + required = std::max(required, op_vec_.size() ); // number operators + required = std::max(required, arg_vec_.size() ); // number arguments + // + // unsigned short + if( required <= std::numeric_limits::max() ) + return play::unsigned_short_enum; + // + // unsigned int + if( required <= std::numeric_limits::max() ) + return play::unsigned_int_enum; + // + // unsigned size_t + CPPAD_ASSERT_UNKNOWN( + required <= std::numeric_limits::max() + ); + return play::size_t_enum; + } + // =============================================================== + /*! + Moving an operation sequence from a recorder to this player + + \param rec + 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 pod_vector member variables in this have been swapped with rec. + + \param n_ind + the number of independent variables (only used for error checking + when NDEBUG is not defined). + + \par + Use an assert to check that the length of the following vectors is + less than the maximum possible value for addr_t; i.e., that an index + in these vectors can be represented using the type addr_t: + op_vec_, vecad_ind_vec_, arg_vec_, test_vec_, all_par_vec_, text_vec_, + dyn_par_arg_. + */ + void get_recording(recorder& rec, size_t n_ind) + { +# ifndef NDEBUG + size_t addr_t_max = size_t( std::numeric_limits::max() ); +# endif + // just set size_t values + num_dynamic_ind_ = rec.num_dynamic_ind_; + num_var_rec_ = rec.num_var_rec_; + num_load_op_rec_ = rec.num_load_op_rec_; + + // op_vec_ + op_vec_.swap(rec.op_vec_); + CPPAD_ASSERT_UNKNOWN(op_vec_.size() < addr_t_max ); + + // op_arg_vec_ + arg_vec_.swap(rec.arg_vec_); + CPPAD_ASSERT_UNKNOWN(arg_vec_.size() < addr_t_max ); + + // all_par_vec_ + all_par_vec_.swap(rec.all_par_vec_); + CPPAD_ASSERT_UNKNOWN(all_par_vec_.size() < addr_t_max ); + + // dyn_par_is_, dyn_par_op_, dyn_par_arg_ + dyn_par_is_.swap( rec.dyn_par_is_ ); + dyn_par_op_.swap( rec.dyn_par_op_ ); + dyn_par_arg_.swap( rec.dyn_par_arg_ ); + CPPAD_ASSERT_UNKNOWN(dyn_par_arg_.size() < addr_t_max ); + + // text_rec_ + text_vec_.swap(rec.text_vec_); + CPPAD_ASSERT_UNKNOWN(text_vec_.size() < addr_t_max ); + + // vecad_ind_vec_ + vecad_ind_vec_.swap(rec.vecad_ind_vec_); + CPPAD_ASSERT_UNKNOWN(vecad_ind_vec_.size() < addr_t_max ); + + // num_vecad_vec_rec_ + num_vecad_vec_rec_ = 0; + { // vecad_ind_vec_ contains size of each VecAD followed by + // the parameter indices used to inialize it. + size_t i = 0; + while( i < vecad_ind_vec_.size() ) + { num_vecad_vec_rec_++; + i += size_t( vecad_ind_vec_[i] ) + 1; + } + CPPAD_ASSERT_UNKNOWN( i == vecad_ind_vec_.size() ); + } + + // mapping from dynamic parameter index to parameter index + dyn_ind2par_ind_.resize( dyn_par_op_.size() ); + size_t i_dyn = 0; + for(size_t i_par = 0; i_par < all_par_vec_.size(); ++i_par) + { if( dyn_par_is_[i_par] ) + { dyn_ind2par_ind_[i_dyn] = addr_t( i_par ); + ++i_dyn; + } + } + CPPAD_ASSERT_UNKNOWN( i_dyn == dyn_ind2par_ind_.size() ); + + // random access information + clear_random(); + + // some checks + check_inv_op(n_ind); + check_variable_dag(); + check_dynamic_dag(); + } + // ---------------------------------------------------------------------- + /*! + Check that InvOp operators start with second operator and are contiguous, + and there are n_ind of them. + */ +# ifdef NDEBUG + void check_inv_op(size_t n_ind) const + { return; } +# else + void check_inv_op(size_t n_ind) const + { play::const_sequential_iterator itr = begin(); + OpCode op; + const addr_t* op_arg; + size_t var_index; + itr.op_info(op, op_arg, var_index); + CPPAD_ASSERT_UNKNOWN( op = BeginOp ); + size_t i_op = 0; + while( op != EndOp ) + { // start at second operator + (++itr).op_info(op, op_arg, var_index); + ++i_op; + CPPAD_ASSERT_UNKNOWN( (op == InvOp) == (i_op <= n_ind) ); + } + return; + } +# endif + // ---------------------------------------------------------------------- + /*! + Check variable graph to make sure arguments have value less + than or equal to the previously created variable. This is the directed + acyclic graph condition (DAG). + */ +# ifdef NDEBUG + void check_variable_dag(void) const + { return; } +# else + void check_variable_dag(void) const + { play::const_sequential_iterator itr = begin(); + OpCode op; + const addr_t* op_arg; + size_t var_index; + itr.op_info(op, op_arg, var_index); + CPPAD_ASSERT_UNKNOWN( op = BeginOp ); + // + addr_t arg_var_bound = 0; + while( op != EndOp ) + { (++itr).op_info(op, op_arg, var_index); + switch(op) + { + // cases where nothing to do + case BeginOp: + case EndOp: + case EqppOp: + case InvOp: + case LdpOp: + case LeppOp: + case NeppOp: + case ParOp: + case AFunOp: + case FunapOp: + case FunrpOp: + case FunrvOp: + case StppOp: + break; + + // only first argument is a variable + 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 LevpOp: + case LogOp: + case Log1pOp: + case LtvpOp: + case PowvpOp: + case SignOp: + case SinOp: + case SinhOp: + case SqrtOp: + case SubvpOp: + case TanOp: + case TanhOp: + case FunavOp: + case ZmulvpOp: + CPPAD_ASSERT_UNKNOWN(op_arg[0] <= arg_var_bound ); + break; + + // only second argument is a variable + case AddpvOp: + case DisOp: + case DivpvOp: + case EqpvOp: + case LdvOp: + case LepvOp: + case LtppOp: + case LtpvOp: + case MulpvOp: + case NepvOp: + case PowpvOp: + case StvpOp: + case SubpvOp: + case ZmulpvOp: + CPPAD_ASSERT_UNKNOWN(op_arg[1] <= arg_var_bound ); + break; + + // only first and second arguments are variables + case AddvvOp: + case DivvvOp: + case EqvvOp: + case LevvOp: + case LtvvOp: + case MulvvOp: + case NevvOp: + case PowvvOp: + case SubvvOp: + case ZmulvvOp: + CPPAD_ASSERT_UNKNOWN(op_arg[0] <= arg_var_bound ); + CPPAD_ASSERT_UNKNOWN(op_arg[1] <= arg_var_bound ); + break; + + // StpvOp + case StpvOp: + CPPAD_ASSERT_UNKNOWN(op_arg[2] <= arg_var_bound ); + break; + + // StvvOp + case StvvOp: + CPPAD_ASSERT_UNKNOWN(op_arg[1] <= arg_var_bound ); + CPPAD_ASSERT_UNKNOWN(op_arg[2] <= arg_var_bound ); + break; + + // CSumOp + case CSumOp: + { CPPAD_ASSERT_UNKNOWN( 5 < op_arg[2] ); + for(addr_t j = 5; j < op_arg[2]; j++) + CPPAD_ASSERT_UNKNOWN(op_arg[j] <= arg_var_bound); + } + itr.correct_before_increment(); + break; + + // CExpOp + case CExpOp: + if( op_arg[1] & 1 ) + CPPAD_ASSERT_UNKNOWN( op_arg[2] <= arg_var_bound); + if( op_arg[1] & 2 ) + CPPAD_ASSERT_UNKNOWN( op_arg[3] <= arg_var_bound); + if( op_arg[1] & 4 ) + CPPAD_ASSERT_UNKNOWN( op_arg[4] <= arg_var_bound); + if( op_arg[1] & 8 ) + CPPAD_ASSERT_UNKNOWN( op_arg[5] <= arg_var_bound); + break; + + // PriOp + case PriOp: + if( op_arg[0] & 1 ) + CPPAD_ASSERT_UNKNOWN( op_arg[1] <= arg_var_bound); + if( op_arg[0] & 2 ) + CPPAD_ASSERT_UNKNOWN( op_arg[3] <= arg_var_bound); + break; + + // CSkipOp + case CSkipOp: + if( op_arg[1] & 1 ) + CPPAD_ASSERT_UNKNOWN( op_arg[2] <= arg_var_bound); + if( op_arg[1] & 2 ) + CPPAD_ASSERT_UNKNOWN( op_arg[3] <= arg_var_bound); + itr.correct_before_increment(); + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + break; + + + } + if( NumRes(op) > 0 ) + { if( var_index > 0 ) + { CPPAD_ASSERT_UNKNOWN(size_t(arg_var_bound) < var_index); + } + else + { CPPAD_ASSERT_UNKNOWN(size_t(arg_var_bound) == var_index); + } + // + arg_var_bound = addr_t(var_index); + } + } + return; + } +# endif + // ---------------------------------------------------------------------- + /*! + Check dynamic parameter graph to make sure arguments have value less + than or equal to the previously created dynamic parameter. + This is the directed acyclic graph condition (DAG). + */ +# ifdef NDEBUG + void check_dynamic_dag(void) const + { return; } +# else + void check_dynamic_dag(void) const + { // number of dynamic parameters + size_t num_dyn = dyn_par_op_.size(); + // + size_t i_arg = 0; // initialize dynamic parameter argument index + for(size_t i_dyn = 0; i_dyn < num_dyn; ++i_dyn) + { // i_par is parameter index + addr_t i_par = dyn_ind2par_ind_[i_dyn]; + CPPAD_ASSERT_UNKNOWN( dyn_par_is_[i_par] ); + // + // operator for this dynamic parameter + op_code_dyn op = op_code_dyn( dyn_par_op_[i_dyn] ); + // + // number of arguments for this dynamic parameter + size_t n_arg = num_arg_dyn(op); + // + if( (op == cond_exp_dyn) | (op == dis_dyn ) ) + { // for these two cases, first argument not a parameter index + for(size_t i = 1; i < n_arg; ++i) CPPAD_ASSERT_UNKNOWN( + dyn_par_arg_[i_arg + i] < i_par + ); + } + else + { for(size_t i = 0; i < n_arg; ++i) CPPAD_ASSERT_UNKNOWN( + dyn_par_arg_[i_arg + i] < i_par + ); + } + // + // next dynamic parameter + i_arg += n_arg; + } + return; + } +# endif + // =============================================================== + /*! + Copy a player to another player + + \param play + object that contains the operatoion sequence to copy. + */ + void operator=(const player& play) + { + // size_t objects + num_dynamic_ind_ = play.num_dynamic_ind_; + num_var_rec_ = play.num_var_rec_; + num_load_op_rec_ = play.num_load_op_rec_; + num_vecad_vec_rec_ = play.num_vecad_vec_rec_; + // + // pod_vectors + op_vec_ = play.op_vec_; + arg_vec_ = play.arg_vec_; + text_vec_ = play.text_vec_; + vecad_ind_vec_ = play.vecad_ind_vec_; + dyn_par_is_ = play.dyn_par_is_; + dyn_ind2par_ind_ = play.dyn_ind2par_ind_; + dyn_par_op_ = play.dyn_par_op_; + dyn_par_arg_ = play.dyn_par_arg_; + op2arg_vec_ = play.op2arg_vec_; + op2var_vec_ = play.op2var_vec_; + var2op_vec_ = play.var2op_vec_; + // + // pod_maybe_vectors + all_par_vec_ = play.all_par_vec_; + } + // =============================================================== +# if CPPAD_USE_CPLUSPLUS_2011 + // move semantics version of assignment operator + void operator=(player&& play) + { + // size_t objects + num_dynamic_ind_ = play.num_dynamic_ind_; + num_var_rec_ = play.num_var_rec_; + num_load_op_rec_ = play.num_load_op_rec_; + num_vecad_vec_rec_ = play.num_vecad_vec_rec_; + // + // pod_vectors + op_vec_.swap( play.op_vec_); + arg_vec_.swap( play.arg_vec_); + text_vec_.swap( play.text_vec_); + vecad_ind_vec_.swap( play.vecad_ind_vec_); + dyn_par_is_.swap( play.dyn_par_is_); + dyn_ind2par_ind_.swap( play.dyn_ind2par_ind_); + dyn_par_op_.swap( play.dyn_par_op_); + dyn_par_arg_.swap( play.dyn_par_arg_); + op2arg_vec_.swap( play.op2arg_vec_); + op2var_vec_.swap( play.op2var_vec_); + var2op_vec_.swap( play.var2op_vec_); + // + // pod_maybe_vectors + all_par_vec_.swap( play.all_par_vec_); + } +# endif + // =============================================================== + /// Create a player< AD > from this player + player< AD > base2ad(void) const + { player< AD > play; + // + // size_t objects + play.num_dynamic_ind_ = num_dynamic_ind_; + play.num_var_rec_ = num_var_rec_; + play.num_load_op_rec_ = num_load_op_rec_; + play.num_vecad_vec_rec_ = num_vecad_vec_rec_; + // + // pod_vectors + play.op_vec_ = op_vec_; + play.arg_vec_ = arg_vec_; + play.text_vec_ = text_vec_; + play.vecad_ind_vec_ = vecad_ind_vec_; + play.dyn_par_is_ = dyn_par_is_; + play.dyn_ind2par_ind_ = dyn_ind2par_ind_; + play.dyn_par_op_ = dyn_par_op_; + play.dyn_par_arg_ = dyn_par_arg_; + play.op2arg_vec_ = op2arg_vec_; + play.op2var_vec_ = op2var_vec_; + play.var2op_vec_ = var2op_vec_; + // + // pod_maybe_vector< AD > = pod_maybe_vector + play.all_par_vec_.resize( all_par_vec_.size() ); + for(size_t i = 0; i < all_par_vec_.size(); ++i) + play.all_par_vec_[i] = all_par_vec_[i]; + // + return play; + } + // =============================================================== + /// swap this recording with another recording + /// (used for move semantics version of ADFun assignment operation) + void swap(player& other) + { // size_t objects + std::swap(num_dynamic_ind_, other.num_dynamic_ind_); + std::swap(num_var_rec_, other.num_var_rec_); + std::swap(num_load_op_rec_, other.num_load_op_rec_); + std::swap(num_vecad_vec_rec_, other.num_vecad_vec_rec_); + // + // pod_vectors + op_vec_.swap( other.op_vec_); + arg_vec_.swap( other.arg_vec_); + text_vec_.swap( other.text_vec_); + vecad_ind_vec_.swap( other.vecad_ind_vec_); + dyn_par_is_.swap( other.dyn_par_is_); + dyn_ind2par_ind_.swap(other.dyn_ind2par_ind_); + dyn_par_op_.swap( other.dyn_par_op_); + dyn_par_arg_.swap( other.dyn_par_arg_); + op2arg_vec_.swap( other.op2arg_vec_); + op2var_vec_.swap( other.op2var_vec_); + var2op_vec_.swap( other.var2op_vec_); + // + // pod_maybe_vectors + all_par_vec_.swap( other.all_par_vec_); + } + // ================================================================= + /// Enable use of const_subgraph_iterator and member functions that begin + // with random_(no work if already setup). + template + void setup_random(void) + { play::random_setup( + num_var_rec_ , + op_vec_ , + arg_vec_ , + op2arg_vec_.pod_vector_ptr() , + op2var_vec_.pod_vector_ptr() , + var2op_vec_.pod_vector_ptr() + ); + } + /// Free memory used for functions that begin with random_ + /// and random iterators and subgraph iterators + void clear_random(void) + { + op2arg_vec_.clear(); + op2var_vec_.clear(); + var2op_vec_.clear(); + CPPAD_ASSERT_UNKNOWN( op2arg_vec_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( op2var_vec_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( var2op_vec_.size() == 0 ); + } + /// get non-const version of all_par_vec + pod_vector_maybe& all_par_vec(void) + { return all_par_vec_; } + /// get non-const version of all_par_vec + const pod_vector_maybe& all_par_vec(void) const + { return all_par_vec_; } + // ================================================================ + // const functions that retrieve infromation from this player + // ================================================================ + /// const version of dynamic parameter flag + const pod_vector& dyn_par_is(void) const + { return dyn_par_is_; } + /// const version of dynamic parameter index to parameter index + const pod_vector& dyn_ind2par_ind(void) const + { return dyn_ind2par_ind_; } + /// const version of dynamic parameter operator + const pod_vector& dyn_par_op(void) const + { return dyn_par_op_; } + /// const version of dynamic parameter arguments + const pod_vector& dyn_par_arg(void) const + { return dyn_par_arg_; } + /*! + \brief + fetch an operator from the recording. + + \return + the i-th operator in the recording. + + \param i + the index of the operator in recording + */ + OpCode GetOp (size_t i) const + { return OpCode(op_vec_[i]); } + + /*! + \brief + Fetch a VecAD index from the recording. + + \return + the i-th VecAD index in the recording. + + \param i + the index of the VecAD index in recording + */ + size_t GetVecInd (size_t i) const + { return size_t( vecad_ind_vec_[i] ); } + + /*! + \brief + Fetch a parameter from the recording. + + \return + the i-th parameter in the recording. + + \param i + the index of the parameter in recording + */ + Base GetPar(size_t i) const + { return all_par_vec_[i]; } + + /*! + \brief + Fetch entire parameter vector from the recording. + + \return + the entire parameter vector. + + */ + const Base* GetPar(void) const + { return all_par_vec_.data(); } + + /*! + \brief + Fetch a '\\0' terminated string from the recording. + + \return + the beginning of the string. + + \param i + the index where the string begins. + */ + const char *GetTxt(size_t i) const + { CPPAD_ASSERT_UNKNOWN(i < text_vec_.size() ); + return text_vec_.data() + i; + } + + /// Fetch number of independent dynamic parameters in the recording + size_t num_dynamic_ind(void) const + { return num_dynamic_ind_; } + + /// Fetch number of dynamic parameters in the recording + size_t num_dynamic_par(void) const + { return dyn_par_op_.size(); } + + /// Fetch number of dynamic parameters operator arguments in the recording + size_t num_dynamic_arg(void) const + { return dyn_par_arg_.size(); } + + /// Fetch number of variables in the recording. + size_t num_var_rec(void) const + { return num_var_rec_; } + + /// Fetch number of vecad load operations + size_t num_load_op_rec(void) const + { return num_load_op_rec_; } + + /// Fetch number of operators in the recording. + size_t num_op_rec(void) const + { return op_vec_.size(); } + + /// Fetch number of VecAD indices in the recording. + size_t num_vec_ind_rec(void) const + { return vecad_ind_vec_.size(); } + + /// Fetch number of VecAD vectors in the recording + size_t num_vecad_vec_rec(void) const + { return num_vecad_vec_rec_; } + + /// Fetch number of argument indices in the recording. + size_t num_op_arg_rec(void) const + { return arg_vec_.size(); } + + /// Fetch number of parameters in the recording. + size_t num_par_rec(void) const + { return all_par_vec_.size(); } + + /// Fetch number of characters (representing strings) in the recording. + size_t num_text_rec(void) const + { return text_vec_.size(); } + + /// A measure of amount of memory used to store + /// the operation sequence, just lengths, not capacities. + /// In user api as f.size_op_seq(); see the file seq_property.omh. + size_t size_op_seq(void) const + { // check assumptions made by ad_fun::size_op_seq() + CPPAD_ASSERT_UNKNOWN( op_vec_.size() == num_op_rec() ); + CPPAD_ASSERT_UNKNOWN( arg_vec_.size() == num_op_arg_rec() ); + CPPAD_ASSERT_UNKNOWN( all_par_vec_.size() == num_par_rec() ); + CPPAD_ASSERT_UNKNOWN( text_vec_.size() == num_text_rec() ); + CPPAD_ASSERT_UNKNOWN( vecad_ind_vec_.size() == num_vec_ind_rec() ); + return op_vec_.size() * sizeof(opcode_t) + + arg_vec_.size() * sizeof(addr_t) + + all_par_vec_.size() * sizeof(Base) + + dyn_par_is_.size() * sizeof(bool) + + dyn_ind2par_ind_.size() * sizeof(addr_t) + + dyn_par_op_.size() * sizeof(opcode_t) + + dyn_par_arg_.size() * sizeof(addr_t) + + text_vec_.size() * sizeof(char) + + vecad_ind_vec_.size() * sizeof(addr_t) + ; + } + /// A measure of amount of memory used for random access routine + /// In user api as f.size_random(); see the file seq_property.omh. + size_t size_random(void) const + { +# ifndef NDEBUG + if( op2arg_vec_.size() == 0 ) + { CPPAD_ASSERT_UNKNOWN( op2var_vec_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( var2op_vec_.size() == 0 ); + } + else + { size_t size = 0; + switch( address_type() ) + { case play::unsigned_short_enum: + size = sizeof(unsigned short); + break; + // + case play::unsigned_int_enum: + size = sizeof(unsigned int); + break; + // + case play::size_t_enum: + size = sizeof(size_t); + break; + + default: + CPPAD_ASSERT_UNKNOWN(false); + break; + } + CPPAD_ASSERT_UNKNOWN( op2arg_vec_.size()/size == num_op_rec() ); + CPPAD_ASSERT_UNKNOWN( op2var_vec_.size()/size == num_op_rec() ); + CPPAD_ASSERT_UNKNOWN( var2op_vec_.size()/size == num_var_rec() ); + } +# endif + CPPAD_ASSERT_UNKNOWN( sizeof(unsigned char) == 1 ); + return op2arg_vec_.size() + + op2var_vec_.size() + + var2op_vec_.size() + ; + } + // ----------------------------------------------------------------------- + /// const sequential iterator begin + play::const_sequential_iterator begin(void) const + { size_t op_index = 0; + size_t num_var = num_var_rec_; + return play::const_sequential_iterator( + num_var, &op_vec_, &arg_vec_, op_index + ); + } + /// const sequential iterator end + play::const_sequential_iterator end(void) const + { size_t op_index = op_vec_.size() - 1; + size_t num_var = num_var_rec_; + return play::const_sequential_iterator( + num_var, &op_vec_, &arg_vec_, op_index + ); + } + // ----------------------------------------------------------------------- + /// const subgraph iterator begin + play::const_subgraph_iterator begin_subgraph( + const play::const_random_iterator& random_itr , + const pod_vector* subgraph ) const + { size_t subgraph_index = 0; + return play::const_subgraph_iterator( + random_itr, + subgraph, + subgraph_index + ); + } + /// const subgraph iterator end + template + play::const_subgraph_iterator end_subgraph( + const play::const_random_iterator& random_itr , + const pod_vector* subgraph ) const + { size_t subgraph_index = subgraph->size() - 1; + return play::const_subgraph_iterator( + random_itr, + subgraph, + subgraph_index + ); + } + // ----------------------------------------------------------------------- + /// const random iterator + template + play::const_random_iterator get_random(void) const + { return play::const_random_iterator( + op_vec_, + arg_vec_, + op2arg_vec_.pod_vector_ptr(), + op2var_vec_.pod_vector_ptr(), + var2op_vec_.pod_vector_ptr() + ); + } +}; + +} } // END_CPPAD_lOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/play/random_iterator.hpp cppad-2019.02.00.0/include/cppad/local/play/random_iterator.hpp --- cppad-2018.00.00.0/include/cppad/local/play/random_iterator.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/play/random_iterator.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,152 @@ +# ifndef CPPAD_LOCAL_PLAY_RANDOM_ITERATOR_HPP +# define CPPAD_LOCAL_PLAY_RANDOM_ITERATOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN_CPPAD_LOCAL_PLAY_NAMESPACE +namespace CppAD { namespace local { namespace play { + +/*! +\file random_iterator.hpp +*/ + +/*! +Constant random iterator for a player object. + +\tparam Addr +An integer type capable of representing the largest value in the vectors +arg_vec, op2arg_vec, op2var_vec, var2op_vec. +*/ +template +class const_random_iterator { +private: + /// vector of operators on the tape + const pod_vector* op_vec_; + + /// vector of arguments for all the operators + /// (note that this is same type as used in recorder; i.e., addr_t) + const pod_vector* arg_vec_; + + /// mapping from operator index to index of first argument in arg_vec_ + const pod_vector* op2arg_vec_; + + /// mapping from operator index to index of primary (last) result + const pod_vector* op2var_vec_; + + /// mapping from primary variable index to operator index + /// (only specified for primary variables) + const pod_vector* var2op_vec_; + +public: + /// default constructor + const_random_iterator(void) : + op_vec_(CPPAD_NULL) , + arg_vec_(CPPAD_NULL) , + op2arg_vec_(CPPAD_NULL) , + op2var_vec_(CPPAD_NULL) , + var2op_vec_(CPPAD_NULL) + { } + /// default assignment operator + void operator=(const const_random_iterator& rhs) + { + op_vec_ = rhs.op_vec_; + op2arg_vec_ = rhs.op2arg_vec_; + op2var_vec_ = rhs.op2var_vec_; + var2op_vec_ = rhs.var2op_vec_; + return; + } + /*! + Create a random iterator + + \par var2op_vec + This variable is not needed and can be null if the var2op member + function is not used. + */ + const_random_iterator( + const pod_vector& op_vec , ///< op_vec_ + const pod_vector& arg_vec , ///< arg_vec_ + const pod_vector* op2arg_vec , ///< op2ar_vec_ + const pod_vector* op2var_vec , ///< op2var_vec_ + const pod_vector* var2op_vec ) ///< var2op_vec_ + : + op_vec_ ( &op_vec ) , + arg_vec_ ( &arg_vec ) , + op2arg_vec_ ( op2arg_vec ) , + op2var_vec_ ( op2var_vec ) , + var2op_vec_ ( var2op_vec ) + { } + /*! + \brief + fetch the information corresponding to an operator + + \param op_index + index for this operator [in] + + \param op [out] + op code for this operator. + + \param op_arg [out] + pointer to the first arguement to this operator. + + \param var_index [out] + index of the last variable (primary variable) for this operator. + If there is no primary variable for this operator, i_var not sepcified + and could have any value. + */ + void op_info( + size_t op_index , + OpCode& op , + const addr_t*& op_arg , + size_t& var_index ) const + { op = OpCode( (*op_vec_)[op_index] ); + op_arg = (*op2arg_vec_)[op_index] + arg_vec_->data(); + var_index = (*op2var_vec_)[op_index]; + return; + } + /*! + \brief + map variable index to operator index. + + \param var_index + must be the index of a primary variable. + + \return + is the index of the operator corresponding to this primary variable. + */ + size_t var2op(size_t var_index) const + { // check that var2op_vec was not null in constructor + CPPAD_ASSERT_UNKNOWN( var2op_vec_ != CPPAD_NULL ); + // + // operator index + size_t op_index = size_t( (*var2op_vec_)[var_index] ); + // + // check that var_index is a primary variable index (see random_setup) + CPPAD_ASSERT_UNKNOWN( op_index < op_vec_->size() ); + // + return op_index; + } + /// get operator corresponding to operator index + OpCode get_op(size_t op_index) const + { return OpCode( (*op_vec_)[op_index] ); + } + /// number of operators + size_t num_op(void) const + { return op_vec_->size(); } + // + /// number of variables + size_t num_var(void) const + { return var2op_vec_->size(); } +}; + +} } } // BEGIN_CPPAD_LOCAL_PLAY_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/play/random_setup.hpp cppad-2019.02.00.0/include/cppad/local/play/random_setup.hpp --- cppad-2018.00.00.0/include/cppad/local/play/random_setup.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/play/random_setup.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,144 @@ +# ifndef CPPAD_LOCAL_PLAY_RANDOM_SETUP_HPP +# define CPPAD_LOCAL_PLAY_RANDOM_SETUP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN_CPPAD_LOCAL_PLAY_NAMESPACE +namespace CppAD { namespace local { namespace play { + +/*! +\file random_setup.hpp +*/ + +/*! +Set up random access to a player object. + +\tparam Addr +An integer type capable of representing the largest value in the vectors +arg_vec, op2arg_vec, op2var_vec, var2op_vec. + +\param num_var +num_var is the number of variables in this operation sequence. + +\param op_vec +The mapping +op = OpCode[ op_vec[op_index] ] +maps from operator index op_index to the operator op. + +\param arg_vec +is a vector of all the arguments for all the operators. +The mapping op2arg_vec will map from operator indices +to index in this vector. + +\param op2arg_vec +On input, op2arg_vec is either the empty vector +(or contains the proper result from a previous call to random_setup). +Upon return it maps each operator index to the index in op_arg_vec of its +first argument for the operator. + +\param op2var_vec +On input, op2var_vec is either the empty vector +(or contains the proper result from a previous call to random_setup). +Upon return it maps each operator index to the primary (last) +result for the operator. If there are no results for the operator, +the return value map value is not specified. + +\param var2op_vec +On input, var2op_vec is either the empty vector +(or contains the proper result from a previous call to random_setup). +Upon return it maps each primary variable index to the corresponding +operator index. The value of the map is only specifed for primary variable +indices. +*/ +template +void random_setup( + size_t num_var , + const pod_vector& op_vec , + const pod_vector& arg_vec , + pod_vector* op2arg_vec , + pod_vector* op2var_vec , + pod_vector* var2op_vec ) +{ + if( op2arg_vec->size() != 0 ) + { CPPAD_ASSERT_UNKNOWN( op2arg_vec->size() == op_vec.size() ); + CPPAD_ASSERT_UNKNOWN( op2var_vec->size() == op_vec.size() ); + CPPAD_ASSERT_UNKNOWN( var2op_vec->size() == num_var ); + return; + } + CPPAD_ASSERT_UNKNOWN( op2var_vec->size() == 0 ); + CPPAD_ASSERT_UNKNOWN( op2var_vec->size() == 0 ); + CPPAD_ASSERT_UNKNOWN( var2op_vec->size() == 0 ); + CPPAD_ASSERT_UNKNOWN( OpCode( op_vec[0] ) == BeginOp ); + CPPAD_ASSERT_NARG_NRES(BeginOp, 1, 1); + // + size_t num_op = op_vec.size(); + size_t var_index = 0; + size_t arg_index = 0; + // + op2arg_vec->resize( num_op ); + op2var_vec->resize( num_op ); + var2op_vec->resize( num_var ); +# ifndef NDEBUG + // value of var2op for auxillary variables is num_op (invalid) + for(size_t i_var = 0; i_var < num_var; ++i_var) + (*var2op_vec)[i_var] = Addr( num_op ); + // value of op2var is num_var (invalid) when NumRes(op) = 0 + for(size_t i_op = 0; i_op < num_op; ++i_op) + (*op2var_vec)[i_op] = Addr( num_var ); +# endif + for(size_t i_op = 0; i_op < num_op; ++i_op) + { OpCode op = OpCode( op_vec[i_op] ); + // + // index of first argument for this operator + (*op2arg_vec)[i_op] = Addr( arg_index ); + arg_index += NumArg(op); + // + // index of first result for next operator + var_index += NumRes(op); + if( NumRes(op) > 0 ) + { // index of last (primary) result for this operator + (*op2var_vec)[i_op] = Addr( var_index - 1 ); + // + // mapping from primary variable to its operator + (*var2op_vec)[var_index - 1] = Addr( i_op ); + } + // CSumOp + if( op == CSumOp ) + { CPPAD_ASSERT_UNKNOWN( NumArg(CSumOp) == 0 ); + // + // pointer to first argument for this operator + const addr_t* op_arg = arg_vec.data() + arg_index; + // + // The actual number of arugments for this operator is + // op_arg[4] + 1 + // Correct index of first argument for next operator + arg_index += size_t(op_arg[4] + 1); + } + // + // CSkip + if( op == CSkipOp ) + { CPPAD_ASSERT_UNKNOWN( NumArg(CSumOp) == 0 ); + // + // pointer to first argument for this operator + const addr_t* op_arg = arg_vec.data() + arg_index; + // + // The actual number of arugments for this operator is + // 7 + op_arg[4] + op_arg[5]. + // Correct index of first argument for next operator. + arg_index += size_t(7 + op_arg[4] + op_arg[5]); + } + } +} + +} } } // BEGIN_CPPAD_LOCAL_PLAY_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/play/sequential_iterator.hpp cppad-2019.02.00.0/include/cppad/local/play/sequential_iterator.hpp --- cppad-2018.00.00.0/include/cppad/local/play/sequential_iterator.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/play/sequential_iterator.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,290 @@ +# ifndef CPPAD_LOCAL_PLAY_SEQUENTIAL_ITERATOR_HPP +# define CPPAD_LOCAL_PLAY_SEQUENTIAL_ITERATOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// BEGIN_CPPAD_LOCAL_PLAY_NAMESPACE +namespace CppAD { namespace local { namespace play { + +/*! +\file sequential_iterator.hpp +*/ + +/*! +Constant sequential iterator for a player object. + +\tparam Addr +An integer type capable of representing the largest value in the vectors +arg_vec, op2arg_vec, op2var_vec, var2op_vec. + +\par +Except for constructor, the public API for this class is the same as +for the subgraph_iterator class. +*/ +class const_sequential_iterator { +private: + /// pointer to the first operator in the player, BeginOp = *op_begin_ + const opcode_t* op_begin_; + + /// pointer one past last operator in the player, EndOp = *(op_end_ - 1) + const opcode_t* op_end_; + + /// pointer to the first argument for the first operator + const addr_t* arg_begin_; + + /// pointer on past last argumemnt for last operator + const addr_t* arg_end_; + + /// pointer to current operator + const opcode_t* op_cur_; + + /// pointer to first argument for current operator + const addr_t* arg_; + + /// number of variables in tape (not const for assignment operator) + size_t num_var_; + + /// index of last result for current operator + size_t var_index_; + + /// value of current operator; i.e. op_ = *op_cur_ + OpCode op_; +public: + /// default constructor + const_sequential_iterator(void) : + op_begin_(CPPAD_NULL) , + op_end_(CPPAD_NULL) , + arg_begin_(CPPAD_NULL) , + arg_end_(CPPAD_NULL) , + op_cur_(CPPAD_NULL) , + arg_(CPPAD_NULL) , + num_var_(0) , + var_index_(0) , + op_(NumberOp) + { } + /// assignment operator + void operator=(const const_sequential_iterator& rhs) + { + op_begin_ = rhs.op_begin_; + op_end_ = rhs.op_end_; + arg_begin_ = rhs.arg_begin_; + arg_end_ = rhs.arg_end_; + op_cur_ = rhs.op_cur_; + arg_ = rhs.arg_; + num_var_ = rhs.num_var_; + var_index_ = rhs.var_index_; + op_ = rhs.op_; + return; + } + /*! + Create a sequential iterator starting either at beginning or end of tape + + \param num_var + is the number of variables in the tape. + + \param op_vec + is the vector of operators on the tape. + + \param arg_vec + is the vector of arguments for all the operators + + \param op_index + is the operator index that iterator will start at. + It must be zero or op_vec_->size() - 1. + + \par Assumptions + - OpCode(op_vec_[0]) == BeginOp + - OpCode(op_vec_[op_vec_->size() - 1]) == EndOp + */ + const_sequential_iterator( + size_t num_var , + const pod_vector* op_vec , + const pod_vector* arg_vec , + size_t op_index ) + : + op_begin_ ( op_vec->data() ) , + op_end_ ( op_vec->data() + op_vec->size() ) , + arg_begin_ ( arg_vec->data() ) , + arg_end_ ( arg_vec->data() + arg_vec->size() ), + num_var_ ( num_var ) + { if( op_index == 0 ) + { + // index of last result for BeginOp + var_index_ = 0; + // + // first argument to BeginOp + arg_ = arg_vec->data(); + // + // BeginOp + op_cur_ = op_begin_; + op_ = OpCode( *op_cur_ ); + CPPAD_ASSERT_UNKNOWN( op_ == BeginOp ); + CPPAD_ASSERT_NARG_NRES(op_, 1, 1); + } + else + { CPPAD_ASSERT_UNKNOWN(op_index == op_vec->size()-1); + // + // index of last result for EndOp + var_index_ = num_var - 1; + // + // first argument to EndOp (has no arguments) + arg_ = arg_vec->data() + arg_vec->size(); + // + // EndOp + op_cur_ = op_end_ - 1; + op_ = OpCode( *op_cur_ ); + CPPAD_ASSERT_UNKNOWN( op_ == EndOp ); + CPPAD_ASSERT_NARG_NRES(op_, 0, 0); + } + } + /*! + Advance iterator to next operator + */ + const_sequential_iterator& operator++(void) + { + // first argument for next operator + arg_ += NumArg(op_); + // + // next operator + ++op_cur_; + op_ = OpCode( *op_cur_ ); + // + // last result for next operator + var_index_ += NumRes(op_); + // + return *this; + } + /*! + Correction applied before ++ operation when current operator + is CSumOp or CSkipOp. + */ + void correct_before_increment(void) + { // number of arguments for this operator depends on argument data + CPPAD_ASSERT_UNKNOWN( NumArg(op_) == 0 ); + const addr_t* arg = arg_; + // + // CSumOp + if( op_ == CSumOp ) + { // add actual number of arguments to arg_ + arg_ += arg[4] + 1; + } + // + // CSkip + else + { CPPAD_ASSERT_UNKNOWN( op_ == CSkipOp ); + // + CPPAD_ASSERT_UNKNOWN( arg + 5 < arg_end_ ); + addr_t n_skip = arg[4] + arg[5]; + CPPAD_ASSERT_UNKNOWN( n_skip == arg[6 + n_skip] ); + // + // add actual number of arguments to arg_ + arg_ += 7 + n_skip; + } + return; + } + /*! + Backup iterator to previous operator + */ + const_sequential_iterator& operator--(void) + { // + // last result for next operator + var_index_ -= NumRes(op_); + // + // next operator + --op_cur_; + op_ = OpCode( *op_cur_ ); + // + // first argument for next operator + arg_ -= NumArg(op_); + // + return *this; + } + /*! + Correction applied after -- operation when current operator + is CSumOp or CSkipOp. + + \param arg [out] + corrected point to arguments for this operation. + */ + void correct_after_decrement(const addr_t*& arg) + { // number of arguments for this operator depends on argument data + CPPAD_ASSERT_UNKNOWN( NumArg(op_) == 0 ); + // + // infromation for number of arguments is stored in arg_ - 1 + CPPAD_ASSERT_UNKNOWN( arg_begin_ < arg_ ); + // + // CSumOp + if( op_ == CSumOp ) + { // index of arg[4] + addr_t arg_4 = *(arg_ - 1); + // + // corrected index of first argument to this operator + arg = arg_ -= arg_4 + 1; + // + CPPAD_ASSERT_UNKNOWN( arg[arg[4] ] == arg[4] ); + } + // + // CSkip + else + { CPPAD_ASSERT_UNKNOWN( op_ == CSkipOp ); + // + // number to possibly skip is stored in last argument + addr_t n_skip = *(arg_ - 1); + // + // corrected index of frist argument to this operator + arg = arg_ -= 7 + n_skip; + // + CPPAD_ASSERT_UNKNOWN( arg[4] + arg[5] == n_skip ); + } + CPPAD_ASSERT_UNKNOWN( arg_begin_ <= arg ); + CPPAD_ASSERT_UNKNOWN( arg + NumArg(op_) <= arg_end_ ); + } + /*! + \brief + Get information corresponding to current operator. + + \param op [out] + op code for this operator. + + \param arg [out] + pointer to the first arguement to this operator. + + \param var_index [out] + index of the last variable (primary variable) for this operator. + If there is no primary variable for this operator, var_index + is not sepcified and could have any value. + */ + void op_info( + OpCode& op , + const addr_t*& arg , + size_t& var_index ) const + { // op + CPPAD_ASSERT_UNKNOWN( op_begin_ <= op_cur_ && op_cur_ < op_end_ ) + op = op_; + // + // arg + arg = arg_; + CPPAD_ASSERT_UNKNOWN( arg_begin_ <= arg ); + CPPAD_ASSERT_UNKNOWN( arg + NumArg(op) <= arg_end_ ); + // + // var_index + CPPAD_ASSERT_UNKNOWN( var_index_ < num_var_ || NumRes(op) == 0 ); + var_index = var_index_; + } + /// current operator index + size_t op_index(void) + { return size_t(op_cur_ - op_begin_); } +}; + +} } } // BEGIN_CPPAD_LOCAL_PLAY_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/play/subgraph_iterator.hpp cppad-2019.02.00.0/include/cppad/local/play/subgraph_iterator.hpp --- cppad-2018.00.00.0/include/cppad/local/play/subgraph_iterator.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/play/subgraph_iterator.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,132 @@ +# ifndef CPPAD_LOCAL_PLAY_SUBGRAPH_ITERATOR_HPP +# define CPPAD_LOCAL_PLAY_SUBGRAPH_ITERATOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include + +// BEGIN_CPPAD_LOCAL_PLAY_NAMESPACE +namespace CppAD { namespace local { namespace play { + +/*! +\file random_iterator.hpp +*/ + +/*! +Constant subgraph iterator for a player object. + +\tparam Addr +An integer type capable of representing the largest value in the vectors +arg_vec, op2arg_vec, op2var_vec, var2op_vec. + +Except for constructor, the public API for this class is the same as +for the sequential iterator class. +*/ +template +class const_subgraph_iterator { +private: + /// a random iterator used to access player information + const const_random_iterator* random_itr_; + + /// sorted subset of operator indices that we will include + const pod_vector* subgraph_; + + /// index in subgraph of current operator + /// The initial value for this index must be zero or subgraph.size()-1. + size_t subgraph_index_; + +public: + /// default constructor + const_subgraph_iterator(void) : + random_itr_(CPPAD_NULL) , + subgraph_(CPPAD_NULL) , + subgraph_index_(0) + { } + /// default assignment operator + void operator=(const const_subgraph_iterator& rhs) + { + random_itr_ = rhs.random_itr_; + subgraph_ = rhs.subgraph_; + subgraph_index_ = rhs.subgraph_index_; + return; + } + /*! + Create a subgraph iterator starting either at beginning or end of subgraph + */ + const_subgraph_iterator( + const const_random_iterator& random_itr , ///< random_itr_ + const pod_vector* subgraph , ///< subgraph_ + size_t subgraph_index ) ///< subgraph_index_ + : + random_itr_ ( &random_itr ) , + subgraph_ ( subgraph ) , + subgraph_index_ ( subgraph_index ) + { CPPAD_ASSERT_UNKNOWN( + subgraph_index == 0 || subgraph_index == subgraph->size() - 1 + ); + } + /*! + Advance iterator to next operator + */ + const_subgraph_iterator& operator++(void) + { ++subgraph_index_; + return *this; + } + /// No correction necessary when using random access to player + void correct_before_increment(void) + { return; } + /*! + Backup iterator to previous operator + */ + const_subgraph_iterator& operator--(void) + { --subgraph_index_; + return *this; + } + /*! + No correction necessary when using random access to player. + + \param op_arg + not used or modified. + */ + void correct_after_decrement(const addr_t*& op_arg) + { return; } + /*! + \brief + Get information corresponding to current operator. + + \param op [out] + op code for this operator. + + \param op_arg [out] + pointer to the first arguement to this operator. + + \param var_index [out] + index of the last variable (primary variable) for this operator. + If there is no primary variable for this operator, var_index + is not sepcified and could have any value. + */ + void op_info( + OpCode& op , + const addr_t*& op_arg , + size_t& var_index ) const + { // op + size_t op_index = size_t( (*subgraph_)[subgraph_index_] ); + random_itr_->op_info(op_index, op, op_arg, var_index); + } + /// current operator index + size_t op_index(void) + { return size_t( (*subgraph_)[subgraph_index_] ); } +}; + +} } } // BEGIN_CPPAD_LOCAL_PLAY_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/pod_vector.hpp cppad-2019.02.00.0/include/cppad/local/pod_vector.hpp --- cppad-2018.00.00.0/include/cppad/local/pod_vector.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/pod_vector.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,565 @@ +# ifndef CPPAD_LOCAL_POD_VECTOR_HPP +# define CPPAD_LOCAL_POD_VECTOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# if CPPAD_CSTDINT_HAS_8_TO_64 +# include +# endif +# include +# include +# include +# include +# include + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file pod_vector.hpp +File used to define pod_vector classes +*/ +// --------------------------------------------------------------------------- +/*! +A vector class with that does not use element constructors or destructors +(elements are Plain Old Data; i.e., is_pod must be true). + +*/ +template +class pod_vector { +private: + /// maximum number of bytes current allocation can hold + size_t byte_capacity_; + + /// number of bytes currently in this vector + size_t byte_length_; + + /// pointer to the first type elements + /// (not defined and should not be used when byte_capacity_ = 0) + Type *data_; + + /// do not use the copy constructor + explicit pod_vector(const pod_vector& ) + { CPPAD_ASSERT_UNKNOWN(false); } +public: + /// default constructor sets byte_capacity_ = byte_length_ = data_ = 0 + pod_vector(void) + : byte_capacity_(0), byte_length_(0), data_(CPPAD_NULL) + { CPPAD_ASSERT_UNKNOWN( is_pod() ); + } + + /// sizing constructor + pod_vector( + /// number of elements in this vector + size_t n ) + : byte_capacity_(0), byte_length_(0), data_(CPPAD_NULL) + { CPPAD_ASSERT_UNKNOWN( is_pod() ); + extend(n); + } + + /// Destructor: returns allocated memory to thread_alloc; + /// see extend and resize. If this is not plain old data, + /// the destructor for each element is called. + ~pod_vector(void) + { if( byte_capacity_ > 0 ) + { + void* v_ptr = reinterpret_cast( data_ ); + thread_alloc::return_memory(v_ptr); + } + } + + /* + Return a pointer to a pod_vector with a different type of element. + + - This vector and the other share the same memory. + + - The the other vector should not be deleted. + + - The following operations work the same for this and the other vector: + swap, clear, assignment. + */ + template + pod_vector* pod_vector_ptr(void) + { return reinterpret_cast< pod_vector* >(this); + } + template + const pod_vector* pod_vector_ptr(void) const + { return reinterpret_cast< const pod_vector* >(this); + } + + /// current number of elements in this vector. + size_t size(void) const + { return byte_length_ / sizeof(Type); } + + /// current capacity (amount of allocated storage) for this vector. + size_t capacity(void) const + { return byte_capacity_ / sizeof(Type); } + + /// current data pointer is no longer valid after any of the following: + /// extend, resize, erase, clear, assignment and destructor. + Type* data(void) + { return data_; } + + /// const version of data pointer (see non-const documentation) + const Type* data(void) const + { return data_; } + + // ---------------------------------------------------------------------- + /// 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_UNKNOWN( i * sizeof(Type) < byte_length_ ); + return data_[i]; + } + /// non-constant element access; i.e., we can change this element value + template + Type& operator[]( + /// element index, must be less than length and convertable to size_t + Index i + ) + { return (*this)[size_t(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_UNKNOWN( i * sizeof(Type) < byte_length_ ); + return data_[i]; + } + /// constant element access; i.e., we cannot change this element value + template + const Type& operator[]( + /// element index, must be less than length and convertable to size_t + Index i + ) const + { return (*this)[size_t(i)]; } + // ---------------------------------------------------------------------- + + /*! + Add an element to theh back of this vector + + \param e + is the element we are adding to the back of the vector. + */ + void push_back(const Type& e) + { size_t i = extend(1); + data_[i] = e; + } + + /*! + Swap all properties of this vector with another. + This is useful when moving a vector that grows after it has reached + its final size (without copying every element). + + \param other + is the other vector that we are swapping this vector with. + */ + void swap(pod_vector& other) + { std::swap(byte_capacity_, other.byte_capacity_); + std::swap(byte_length_, other.byte_length_); + std::swap(data_, other.data_); + } + // ---------------------------------------------------------------------- + /*! + Increase the number of elements the end of this vector + (existing elements are always preserved). + + \param n + is the number of elements to add to end of this vector. + + \return + is the number of elements in the vector before it was extended. + This is the index of the first new element added to the vector. + + - If 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. + + - This and resize are the only routine that allocate memory for + pod_vector. They uses thread_alloc for this allocation. + */ + size_t extend(size_t n) + { size_t old_length = byte_length_; + byte_length_ += n * sizeof(Type); + + // check if we can use current memory + if( byte_length_ <= byte_capacity_ ) + return old_length / sizeof(Type); + + // save more old information + size_t old_capacity = byte_capacity_; + void* old_v_ptr = reinterpret_cast(data_); + + // get new memory and set capacity + void* v_ptr = thread_alloc::get_memory(byte_length_, byte_capacity_); + data_ = reinterpret_cast(v_ptr); + + // copy old data to new + if( old_length > 0 ) + std::memcpy(v_ptr, old_v_ptr, old_length); + + // return old memory to available pool + if( old_capacity > 0 ) + thread_alloc::return_memory(old_v_ptr); + + // return value for extend(n) is the old length + CPPAD_ASSERT_UNKNOWN( byte_length_ <= byte_capacity_ ); + return old_length / sizeof(Type); + } + // ---------------------------------------------------------------------- + /*! + resize the vector (existing elements preserved when n <= capacity() ). + + \param n + is the new size for this vector. + + \par + if n <= capacity(), no memory is freed or allocated, the capacity + is not changed, and existing elements are preserved. + If n > capacity(), new memory is allocates and all the + data in the vector is lost. + + - If 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. + + - This and extend are the only routine that allocate memory for + pod_vector. They uses thread_alloc for this allocation. + */ + void resize(size_t n) + { byte_length_ = n * sizeof(Type); + + // check if we must allocate new memory + if( byte_capacity_ < byte_length_ ) + { void* v_ptr; + // + if( byte_capacity_ > 0 ) + { // return old memory to available pool + v_ptr = reinterpret_cast( data_ ); + thread_alloc::return_memory(v_ptr); + } + // + // get new memory and set capacity + v_ptr = thread_alloc::get_memory(byte_length_, byte_capacity_); + data_ = reinterpret_cast(v_ptr); + // + } + CPPAD_ASSERT_UNKNOWN( byte_length_ <= byte_capacity_ ); + } + // ---------------------------------------------------------------------- + /*! + Remove all the elements from this vector and free its memory. + */ + void clear(void) + { if( byte_capacity_ > 0 ) + { + void* v_ptr = reinterpret_cast( data_ ); + thread_alloc::return_memory(v_ptr); + } + data_ = CPPAD_NULL; + byte_capacity_ = 0; + byte_length_ = 0; + } + // ----------------------------------------------------------------------- + /// vector assignment operator + void operator=( + /// right hand size of the assingment operation + const pod_vector& x + ) + { CPPAD_ASSERT_UNKNOWN( x.byte_length_ % sizeof(Type) == 0 ); + resize( x.byte_length_ / sizeof(Type) ); + if( byte_length_ > 0 ) + { + void* v_ptr = reinterpret_cast( data_ ); + void* v_ptr_x = reinterpret_cast( x.data_ ); + std::memcpy(v_ptr, v_ptr_x, byte_length_); + } + + } +}; +// --------------------------------------------------------------------------- +/*! +A vector class with that does not use element constructors or destructors +when is_pod is true. +*/ +template +class pod_vector_maybe { +private: + /// maximum number of Type elements current allocation can hold + size_t capacity_; + + /// number of 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_; + + /// do not use the copy constructor + explicit pod_vector_maybe(const pod_vector_maybe& ) + { CPPAD_ASSERT_UNKNOWN(false); } +public: + /// default constructor sets capacity_ = length_ = data_ = 0 + pod_vector_maybe(void) + : capacity_(0), length_(0), data_(CPPAD_NULL) + { CPPAD_ASSERT_UNKNOWN( is_pod() ); + } + + /// sizing constructor + pod_vector_maybe( + /// number of elements in this vector + size_t n ) + : capacity_(0), length_(0), data_(CPPAD_NULL) + { extend(n); } + + + /// Destructor: returns allocated memory to thread_alloc; + /// see extend and resize. If this is not plain old data, + /// the destructor for each element is called. + ~pod_vector_maybe(void) + { if( capacity_ > 0 ) + { if( ! is_pod() ) + { // call destructor for each element + for(size_t i = 0; i < capacity_; i++) + (data_ + i)->~Type(); + } + void* v_ptr = reinterpret_cast( data_ ); + thread_alloc::return_memory(v_ptr); + } + } + + /// current number of elements in this vector. + size_t size(void) const + { return length_; } + + /// current capacity (amount of allocated storage) for this vector. + size_t capacity(void) const + { return capacity_; } + + /// current data pointer is no longer valid after any of the following: + /// extend, resize, erase, clear, assignment, and destructor. + Type* data(void) + { return data_; } + + /// const version of data pointer (see non-const documentation) + const Type* data(void) const + { return data_; } + // ---------------------------------------------------------------------- + /// 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_UNKNOWN( i < length_ ); + return data_[i]; + } + /// non-constant element access; i.e., we can change this element value + template + Type& operator[]( + /// element index, must be less than length and convertable to size_t + Index i + ) + { return (*this)[size_t(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_UNKNOWN( i < length_ ); + return data_[i]; + } + /// constant element access; i.e., we cannot change this element value + template + const Type& operator[]( + /// element index, must be less than length and convertable to size_t + Index i + ) const + { return (*this)[size_t(i)]; } + + // ---------------------------------------------------------------------- + /*! + Add an element to theh back of this vector + + \param e + is the element we are adding to the back of the vector. + */ + void push_back(const Type& e) + { size_t i = extend(1); + data_[i] = e; + } + + /*! + Swap all properties of this vector with another. + This is useful when moving a vector that grows after it has reached + its final size (without copying every element). + + \param other + is the other vector that we are swapping this vector with. + */ + void swap(pod_vector_maybe& other) + { std::swap(capacity_, other.capacity_); + std::swap(length_, other.length_); + std::swap(data_, other.data_); + } + // ---------------------------------------------------------------------- + /*! + Increase the number of elements the end of this vector + (existing elements are always preserved). + + \param n + is the number of elements to add to end of this vector. + + \return + is the number of elements in the vector before it was extended. + This is the index of the first new element added to the vector. + + - If 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. + + - This and resize are the only routine that allocate memory for + pod_vector_maybe. They uses thread_alloc for this allocation. + */ + size_t extend(size_t n) + { size_t old_length = length_; + length_ += n; + + // check if we can use current memory + if( length_ <= capacity_ ) + return old_length; + + // save more old information + size_t old_capacity = capacity_; + Type* old_data = data_; + + // get new memory and set capacity + size_t length_bytes = length_ * sizeof(Type); + size_t capacity_bytes; + void* v_ptr = thread_alloc::get_memory(length_bytes, capacity_bytes); + capacity_ = capacity_bytes / sizeof(Type); + data_ = reinterpret_cast(v_ptr); + + if( ! is_pod() ) + { // call constructor for each new element + for(size_t i = 0; i < capacity_; i++) + new(data_ + i) Type(); + } + + // copy old data to new + for(size_t i = 0; i < old_length; i++) + data_[i] = old_data[i]; + + // return old memory to available pool + if( old_capacity > 0 ) + { if( ! is_pod() ) + { for(size_t i = 0; i < old_capacity; i++) + (old_data + i)->~Type(); + } + v_ptr = reinterpret_cast( old_data ); + thread_alloc::return_memory(v_ptr); + } + + // return value for extend(n) is the old length + CPPAD_ASSERT_UNKNOWN( length_ <= capacity_ ); + return old_length; + } + // ---------------------------------------------------------------------- + /*! + resize the vector (existing elements preserved when n <= capacity_). + + \param n + is the new size for this vector. + + \par + if n <= capacity(), no memory is freed or allocated, the capacity + is not changed, and existing elements are preserved. + If n > capacity(), new memory is allocates and all the + data in the vector is lost. + + - If 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. + + - This and extend are the only routine that allocate memory for + pod_vector_maybe. They uses thread_alloc for this allocation. + */ + void resize(size_t n) + { length_ = n; + + // check if we must allocate new memory + if( capacity_ < length_ ) + { void* v_ptr; + // + // return old memory to available pool + if( capacity_ > 0 ) + { if( ! is_pod() ) + { // call destructor for each old element + for(size_t i = 0; i < capacity_; i++) + (data_ + i)->~Type(); + } + v_ptr = reinterpret_cast( data_ ); + thread_alloc::return_memory(v_ptr); + } + // + // get new memory and set capacity + size_t length_bytes = length_ * sizeof(Type); + size_t capacity_bytes; + v_ptr = thread_alloc::get_memory(length_bytes, capacity_bytes); + capacity_ = capacity_bytes / sizeof(Type); + data_ = reinterpret_cast(v_ptr); + // + CPPAD_ASSERT_UNKNOWN( length_ <= capacity_ ); + // + if( ! is_pod() ) + { // call constructor for each new element + for(size_t i = 0; i < capacity_; i++) + new(data_ + i) Type(); + } + } + } + // ---------------------------------------------------------------------- + /*! + Remove all the elements from this vector and free its memory. + */ + void clear(void) + { if( capacity_ > 0 ) + { if( ! is_pod() ) + { // call destructor for each element + for(size_t i = 0; i < capacity_; i++) + (data_ + i)->~Type(); + } + void* v_ptr = reinterpret_cast( data_ ); + thread_alloc::return_memory(v_ptr); + } + data_ = CPPAD_NULL; + capacity_ = 0; + length_ = 0; + } + // ----------------------------------------------------------------------- + /// vector assignment operator + void operator=( + /// right hand size of the assingment operation + const pod_vector_maybe& x + ) + { resize( x.length_ ); + // + CPPAD_ASSERT_UNKNOWN( length_ == x.length_ ); + for(size_t i = 0; i < length_; i++) + { data_[i] = x.data_[i]; } + } +}; + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/pow_op.hpp cppad-2019.02.00.0/include/cppad/local/pow_op.hpp --- cppad-2018.00.00.0/include/cppad/local/pow_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/pow_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,672 @@ +# ifndef CPPAD_LOCAL_POW_OP_HPP +# define CPPAD_LOCAL_POW_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file pow_op.hpp +Forward and reverse mode calculations for z = pow(x, y). +*/ + +// --------------------------- Powvv ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = PowvvOp. + +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_pow_op +*/ + +template +void forward_powvv_op( + size_t p , + size_t q , + 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(PowvvOp) - 1; + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(PowvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(PowvvOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= i_z + ); + + // z_0 = log(x) + forward_log_op(p, q, i_z, size_t(arg[0]), cap_order, taylor); + + // z_1 = z_0 * y + addr_t adr[2]; + adr[0] = addr_t( i_z ); + adr[1] = arg[1]; + forward_mulvv_op(p, q, i_z+1, adr, parameter, cap_order, taylor); + + // z_2 = exp(z_1) + // final result for zero order case is exactly the same as for Base + if( p == 0 ) + { // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z_2 = taylor + (i_z+2) * cap_order; + + z_2[0] = pow(x[0], y[0]); + p++; + } + if( p <= q ) + forward_exp_op(p, q, i_z+2, i_z+1, cap_order, taylor); +} +/*! +Multiple directions forward mode Taylor coefficients for op = PowvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = pow(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::forward_pow_op_dir +*/ + +template +void forward_powvv_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 ) +{ + // convert from final result to first result + i_z -= 2; // 2 = NumRes(PowvvOp) - 1 + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(PowvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(PowvvOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= i_z + ); + + // z_0 = log(x) + forward_log_op_dir(q, r, i_z, size_t(arg[0]), cap_order, taylor); + + // z_1 = y * z_0 + addr_t adr[2]; + adr[0] = addr_t( i_z ); + adr[1] = arg[1]; + forward_mulvv_op_dir(q, r, i_z+1, adr, parameter, cap_order, taylor); + + // z_2 = exp(z_1) + forward_exp_op_dir(q, r, i_z+2, i_z+1, cap_order, taylor); +} +/*! +Compute zero order forward mode Taylor coefficients for result of op = PowvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = pow(x, y) +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_pow_op_0 +*/ + +template +void forward_powvv_op_0( + 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; // NumRes(PowvvOp) - 1; + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(PowvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(PowvvOp) == 3 ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z_0 = taylor + i_z * cap_order; + Base* z_1 = z_0 + cap_order; + Base* z_2 = z_1 + cap_order; + + z_0[0] = log( x[0] ); + z_1[0] = z_0[0] * y[0]; + z_2[0] = pow(x[0], y[0]); + +} + +/*! +Compute reverse mode partial derivatives for result of op = PowvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = pow(x, y) +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::reverse_pow_op +*/ + +template +void reverse_powvv_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 ) +{ + // convert from final result to first result + i_z -= 2; // NumRes(PowvvOp) - 1; + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(PowvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(PowvvOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= i_z + ); + + // z_2 = exp(z_1) + reverse_exp_op( + d, i_z+2, i_z+1, cap_order, taylor, nc_partial, partial + ); + + // z_1 = z_0 * y + addr_t adr[2]; + adr[0] = addr_t( i_z ); + adr[1] = arg[1]; + reverse_mulvv_op( + d, i_z+1, adr, parameter, cap_order, taylor, nc_partial, partial + ); + + // z_0 = log(x) + reverse_log_op( + d, i_z, size_t(arg[0]), cap_order, taylor, nc_partial, partial + ); +} + +// --------------------------- Powpv ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = PowpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = pow(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_pow_op +*/ + +template +void forward_powpv_op( + size_t p , + size_t q , + 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; + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(PowpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(PowpvOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* z_0 = taylor + i_z * cap_order; + + // z_0 = log(x) + Base x = parameter[ arg[0] ]; + size_t d; + for(d = p; d <= q; d++) + { if( d == 0 ) + z_0[d] = log(x); + else + z_0[d] = Base(0.0); + } + + // 2DO: remove requirement that i_z * cap_order <= max addr_t value + CPPAD_ASSERT_KNOWN( + size_t( std::numeric_limits::max() ) >= i_z * cap_order, + "cppad_tape_addr_type maximum value has been exceeded\n" + "This is due to a kludge in the pow operation and should be fixed." + ); + + // 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] = addr_t( 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 + forward_mulpv_op(p, q, i_z+1, adr, taylor, cap_order, taylor); + + // z_2 = exp(z_1) + // zero order case exactly same as Base type operation + if( p == 0 ) + { Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z_2 = taylor + (i_z+2) * cap_order; + z_2[0] = pow(x, y[0]); + p++; + } + if( p <= q ) + forward_exp_op(p, q, i_z+2, i_z+1, cap_order, taylor); +} +/*! +Multiple directions forward mode Taylor coefficients for op = PowpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = pow(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_pow_op_dir +*/ + +template +void forward_powpv_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 ) +{ + // convert from final result to first result + i_z -= 2; // 2 = NumRes(PowpvOp) - 1; + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(PowpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(PowpvOp) == 3 ); + 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* z_0 = taylor + i_z * num_taylor_per_var; + + // z_0 = log(x) + size_t m = (q-1) * r + 1; + for(size_t ell = 0; ell < r; ell++) + z_0[m+ell] = Base(0.0); + + // 2DO: remove requirement i_z * num_taylor_per_var <= max addr_t value + CPPAD_ASSERT_KNOWN( + size_t( std::numeric_limits::max() ) >= i_z * num_taylor_per_var, + "cppad_tape_addr_type maximum value has been exceeded\n" + "This is due to a kludge in the pow operation and should be fixed." + ); + + // z_1 = z_0 * y + addr_t adr[2]; + // offset of z_0 in taylor (as if it were a parameter); i.e., log(x) + adr[0] = addr_t( i_z * num_taylor_per_var ); + // ofset of y in taylor (as a variable) + adr[1] = arg[1]; + + // 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) + forward_exp_op_dir(q, r, i_z+2, i_z+1, cap_order, taylor); +} +/*! +Compute zero order forward mode Taylor coefficient for result of op = PowpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = pow(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_pow_op_0 +*/ + +template +void forward_powpv_op_0( + 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; // NumRes(PowpvOp) - 1; + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(PowpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(PowpvOp) == 3 ); + + // Paraemter value + Base x = parameter[ arg[0] ]; + + // Taylor coefficients corresponding to arguments and result + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z_0 = taylor + i_z * cap_order; + Base* z_1 = z_0 + cap_order; + Base* z_2 = z_1 + cap_order; + + // z_0 = log(x) + z_0[0] = log(x); + + // z_1 = z_0 * y + z_1[0] = z_0[0] * y[0]; + + // z_2 = exp(z_1) + // zero order case exactly same as Base type operation + z_2[0] = pow(x, y[0]); +} + +/*! +Compute reverse mode partial derivative for result of op = PowpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = pow(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::reverse_pow_op +*/ + +template +void reverse_powpv_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 ) +{ + // convert from final result to first result + i_z -= 2; // NumRes(PowpvOp) - 1; + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(PowvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(PowvvOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // z_2 = exp(z_1) + reverse_exp_op( + d, i_z+2, i_z+1, cap_order, taylor, nc_partial, partial + ); + + // 2DO: remove requirement that i_z * cap_order <= max addr_t value + CPPAD_ASSERT_KNOWN( + size_t( std::numeric_limits::max() ) >= i_z * cap_order, + "cppad_tape_addr_type maximum value has been exceeded\n" + "This is due to a kludge in the pow operation and should be fixed." + ); + + // z_1 = z_0 * y + addr_t adr[2]; + adr[0] = addr_t( 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( + d, i_z+1, adr, taylor, cap_order, taylor, nc_partial, partial + ); + + // z_0 = log(x) + // x is a parameter +} + +// --------------------------- Powvp ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = PowvpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = pow(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::forward_pow_op +*/ + +template +void forward_powvp_op( + size_t p , + size_t q , + 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(PowvpOp) - 1 + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(PowvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(PowvpOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= i_z + ); + + // z_0 = log(x) + forward_log_op(p, q, i_z, size_t(arg[0]), cap_order, taylor); + + // z_1 = y * z_0 + addr_t adr[2]; + adr[0] = arg[1]; + adr[1] = addr_t( i_z ); + forward_mulpv_op(p, q, i_z+1, adr, parameter, cap_order, taylor); + + // z_2 = exp(z_1) + // zero order case exactly same as Base type operation + if( p == 0 ) + { Base* z_2 = taylor + (i_z+2) * cap_order; + Base* x = taylor + size_t(arg[0]) * cap_order; + Base y = parameter[ arg[1] ]; + z_2[0] = pow(x[0], y); + p++; + } + if( p <= q ) + forward_exp_op(p, q, i_z+2, i_z+1, cap_order, taylor); +} +/*! +Multiple directions forward mode Taylor coefficients for op = PowvpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = pow(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::forward_pow_op_dir +*/ + +template +void forward_powvp_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 ) +{ + // convert from final result to first result + i_z -= 2; // 2 = NumRes(PowvpOp) - 1 + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(PowvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(PowvpOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( 0 < q ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= i_z + ); + + // z_0 = log(x) + forward_log_op_dir(q, r, i_z, size_t(arg[0]), cap_order, taylor); + + // z_1 = y * z_0 + addr_t adr[2]; + adr[0] = arg[1]; + adr[1] = addr_t( i_z ); + forward_mulpv_op_dir(q, r, i_z+1, adr, parameter, cap_order, taylor); + + // z_2 = exp(z_1) + forward_exp_op_dir(q, r, i_z+2, i_z+1, cap_order, taylor); +} + +/*! +Compute zero order forward mode Taylor coefficients for result of op = PowvpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = pow(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::forward_pow_op_0 +*/ + +template +void forward_powvp_op_0( + 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; // NumRes(PowvpOp) - 1; + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(PowvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(PowvpOp) == 3 ); + + // Paraemter value + Base y = parameter[ arg[1] ]; + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* z_0 = taylor + i_z * cap_order; + Base* z_1 = z_0 + cap_order; + Base* z_2 = z_1 + cap_order; + + // z_0 = log(x) + z_0[0] = log(x[0]); + + // z_1 = z_0 * y + z_1[0] = z_0[0] * y; + + // z_2 = exp(z_1) + // zero order case exactly same as Base type operation + z_2[0] = pow(x[0], y); +} + +/*! +Compute reverse mode partial derivative for result of op = PowvpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = pow(x, y) +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::reverse_pow_op +*/ + +template +void reverse_powvp_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 ) +{ + // convert from final result to first result + i_z -= 2; // NumRes(PowvpOp) - 1; + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(PowvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(PowvpOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + CPPAD_ASSERT_UNKNOWN( + size_t( std::numeric_limits::max() ) >= i_z + ); + + // z_2 = exp(z_1) + reverse_exp_op( + d, i_z+2, i_z+1, cap_order, taylor, nc_partial, partial + ); + + // z_1 = y * z_0 + addr_t adr[2]; + adr[0] = arg[1]; + adr[1] = addr_t( i_z ); + reverse_mulpv_op( + d, i_z+1, adr, parameter, cap_order, taylor, nc_partial, partial + ); + + // z_0 = log(x) + reverse_log_op( + d, i_z, size_t(arg[0]), cap_order, taylor, nc_partial, partial + ); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/print_op.hpp cppad-2019.02.00.0/include/cppad/local/print_op.hpp --- cppad-2018.00.00.0/include/cppad/local/print_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/print_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,147 @@ +# ifndef CPPAD_LOCAL_PRINT_OP_HPP +# define CPPAD_LOCAL_PRINT_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +Print operation for parameters; i.e., op = PriOp. + +The C++ source code corresponding to this operation is +\verbatim + f.Forward(0, x) + PrintFor(before, var) + PrintFor(pos, before, var, after) +\endverbatim +The PrintFor call puts the print operation on the tape +and the print occurs during the zero order forward mode computation. + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base . + +\param s_out +the results are printed on this output stream. + +\param arg + arg[0] & 1 +\n +If this is zero, pos is a parameter. Otherwise it is a variable. +\n + arg[0] & 2 +\n +If this is zero, var is a parameter. Otherwise it is a variable. +\n +\n + arg[1] +\n +If pos is a parameter, parameter[arg[1]] is its value. +Othwise taylor[ size_t(arg[1]) * cap_order + 0 ] is the zero +order Taylor coefficient for pos. +\n +\n + arg[2] +\n +index of the text to be printed before var +if pos is not a positive value. +\n +\n + arg[3] +\n +If var is a parameter, parameter[arg[3]] is its value. +Othwise taylor[ size_t(arg[3]) * cap_order + 0 ] is the zero +order Taylor coefficient for var. +\n +\n + arg[4] +\n +index of the text to be printed after var +if pos is not a positive value. + +\param num_text +is the total number of text characters on the tape +(only used for error checking). + +\param text +\b Input: text[arg[1]] is the first character of the text +that will be printed. All the characters from there to (but not including) +the first '\\0' are printed. + +\param num_par +is the total number of values in the parameter vector + +\param parameter +Contains the value of parameters. + +\param cap_order +number of colums in the matrix containing all the Taylor coefficients. + +\param taylor +Contains the value of variables. + +\par Checked Assertions: +\li NumArg(PriOp) == 5 +\li NumRes(PriOp) == 0 +\li text != CPPAD_NULL +\li arg[1] < num_text +\li if pos is a parameter, arg[1] < num_par +\li if var is a parameter, arg[3] < num_par +*/ +template +void forward_pri_0( + std::ostream& s_out , + const addr_t* arg , + size_t num_text , + const char* text , + size_t num_par , + const Base* parameter , + size_t cap_order , + const Base* taylor ) +{ Base pos, var; + const char* before; + const char* after; + CPPAD_ASSERT_NARG_NRES(PriOp, 5, 0); + + // pos + if( arg[0] & 1 ) + { pos = taylor[ size_t(arg[1]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + pos = parameter[ arg[1] ]; + } + + // before + CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_text ); + before = text + arg[2]; + + // var + if( arg[0] & 2 ) + { var = taylor[ size_t(arg[3]) * cap_order + 0 ]; + } + else + { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); + var = parameter[ arg[3] ]; + } + + // after + CPPAD_ASSERT_UNKNOWN( size_t(arg[4]) < num_text ); + after = text + arg[4]; + + if( ! GreaterThanZero( pos ) ) + s_out << before << var << after; +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/prototype_op.hpp cppad-2019.02.00.0/include/cppad/local/prototype_op.hpp --- cppad-2018.00.00.0/include/cppad/local/prototype_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/prototype_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1458 @@ +# ifndef CPPAD_LOCAL_PROTOTYPE_OP_HPP +# define CPPAD_LOCAL_PROTOTYPE_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file prototype_op.hpp +Documentation for generic cases (these generic cases are never used). +*/ + +// ==================== Unary operators with one result ==================== + + +/*! +Prototype for forward mode unary operator with one result (not used). + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param p +lowest order of the Taylor coefficient that we are computing. + +\param q +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 taylor corresponding to z. + +\param i_x +variable index corresponding to the argument for this operator; +i.e. the row index in taylor corresponding to x. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor +\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 ], +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. + +\par Checked Assertions +\li NumArg(op) == 1 +\li NumRes(op) == 1 +\li q < cap_order +\li p <= q +*/ +template +void forward_unary1_op( + size_t p , + size_t q , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + +/*! +Prototype for multiple direction forward mode unary operator with one result +(not used). + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param q +order of the Taylor coefficients that we are computing. + +\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 taylor corresponding to z. + +\param i_x +variable index corresponding to the argument for this operator; +i.e. the row index in taylor corresponding to x. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\par tpv +We use the notation +tpv = (cap_order-1) * r + 1 +which is the number of Taylor coefficients per variable + +\param taylor +\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 ], +for k = 1 , ... , q, +ell = 0, ..., r-1, +is the k-th order Taylor coefficient +corresponding to x and the ell-th direction. +\n +\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 ], +for k = 1 , ... , q-1, +ell = 0, ..., r-1, +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], +ell = 0, ..., r-1, +is the q-th order Taylor coefficient +corresponding to z and the ell-th direction. + +\par Checked Assertions +\li NumArg(op) == 1 +\li NumRes(op) == 2 +\li i_x < i_z +\li 0 < q +\li q < cap_order +*/ +template +void forward_unary1_op_dir( + size_t q , + size_t r , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + +/*! +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< Base > and computations by this routine are done using type + Base . + +\param i_z +variable index corresponding to the result for this operation; +i.e. the row index in taylor corresponding to z. + +\param i_x +variable index corresponding to the argument for this operator; +i.e. the row index in taylor corresponding to x. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor +\b Input: taylor [ i_x * cap_order + 0 ] +is the zero order Taylor coefficient corresponding to x. +\n +\b Output: taylor [ i_z * cap_order + 0 ] +is the zero order Taylor coefficient corresponding to z. + +\par Checked Assertions +\li NumArg(op) == 1 +\li NumRes(op) == 1 +\li i_x < i_z +\li 0 < cap_order +*/ +template +void forward_unary1_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + +/*! +Prototype for reverse mode unary operator with one result (not used). + +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 +\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< Base > and computations by this routine are done using type + Base . + +\param d +highest order Taylor coefficient that +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 taylor to z. + +\param i_x +variable index corresponding to the argument for this operation; +i.e. the row index in taylor corresponding to x. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor + taylor [ i_x * cap_order + k ] +for k = 0 , ... , d +is the k-th order Taylor coefficient corresponding to x. +\n + taylor [ i_z * cap_order + k ] +for k = 0 , ... , d +is the k-th order Taylor coefficient corresponding to z. + +\param nc_partial +number of colums in the matrix containing all the partial derivatives. + +\param partial +\b Input: partial [ i_x * nc_partial + k ] +for k = 0 , ... , d +is the partial derivative of G( z , x , w , u , ... ) with respect to +the k-th order Taylor coefficient for x. +\n +\b Input: partial [ i_z * nc_partial + k ] +for k = 0 , ... , d +is the partial derivative of G( z , x , w , u , ... ) with respect to +the k-th order Taylor coefficient for z. +\n +\b Output: partial [ i_x * nc_partial + k ] +for k = 0 , ... , d +is the partial derivative of H( x , w , u , ... ) with respect to +the k-th order Taylor coefficient for x. +\n +\b Output: partial [ i_z * nc_partial + k ] +for k = 0 , ... , 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 i_x < i_z +\li d < cap_order +\li d < nc_partial +*/ +template +void reverse_unary1_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 ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + +// ==================== Unary operators with two results ==================== + +/*! +Prototype for forward mode unary operator with two results (not used). + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param p +lowest order of the Taylor coefficients that we are computing. + +\param q +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 taylor corresponding to z. +The auxillary result is called y has index i_z - 1. + +\param i_x +variable index corresponding to the argument for this operator; +i.e. the row index in taylor corresponding to x. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor +\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 ] +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 ] +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. +\n +\b Output: taylor [ ( i_z - 1 ) * cap_order + k ], +for k = p , ... , q, +is the k-th order Taylor coefficient corresponding to +the autillary result y. + +\par Checked Assertions +\li NumArg(op) == 1 +\li NumRes(op) == 2 +\li i_x + 1 < i_z +\li q < cap_order +\li p <= q +*/ +template +void forward_unary2_op( + size_t p , + size_t q , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + +/*! +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< Base > and computations by this routine are done using type + Base. + +\param q +order of the Taylor coefficients that we are computing. + +\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 taylor corresponding to z. +The auxillary result is called y has index i_z - 1. + +\param i_x +variable index corresponding to the argument for this operator; +i.e. the row index in taylor corresponding to x. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\par tpv +We use the notation +tpv = (cap_order-1) * r + 1 +which is the number of Taylor coefficients per variable + +\param taylor +\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 +corresponding to x and the ell-th direction. +\n +\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 ], +for k = 1 , ... , q-1, +ell = 0, ..., r-1, +is the k-th order Taylor coefficient +corresponding to z and the ell-th direction. +\n +\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 ], +for k = 1 , ... , q-1, +ell = 0, ..., r-1, +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], +ell = 0, ..., r-1, +is the q-th order Taylor coefficient +corresponding to z and the ell-th direction. + +\par Checked Assertions +\li NumArg(op) == 1 +\li NumRes(op) == 2 +\li i_x + 1 < i_z +\li 0 < q +\li q < cap_order +*/ +template +void forward_unary2_op_dir( + size_t q , + size_t r , + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + +/*! +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< Base > and computations by this routine are done using type + Base . + +\param i_z +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in taylor corresponding to z. +The auxillary result is called y and has index i_z - 1. + +\param i_x +variable index corresponding to the argument for this operator; +i.e. the row index in taylor corresponding to x. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor +\b Input: taylor [ i_x * cap_order + 0 ] +is the zero order Taylor coefficient corresponding to x. +\n +\b Output: taylor [ i_z * cap_order + 0 ] +is the zero order Taylor coefficient corresponding to z. +\n +\b Output: taylor [ ( i_z - 1 ) * 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 i_x + 1 < i_z +\li j < cap_order +*/ +template +void forward_unary2_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + +/*! +Prototype for reverse mode unary operator with two results (not used). + +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 +\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< Base > and computations by this routine are done using type + Base . + +\param d +highest order Taylor coefficient that +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 taylor to z. +The auxillary result is called y and has index i_z - 1. + +\param i_x +variable index corresponding to the argument for this operation; +i.e. the row index in taylor corresponding to x. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor + taylor [ i_x * cap_order + k ] +for k = 0 , ... , d +is the k-th order Taylor coefficient corresponding to x. +\n + taylor [ i_z * cap_order + k ] +for k = 0 , ... , d +is the k-th order Taylor coefficient corresponding to z. +\n + taylor [ ( i_z - 1) * cap_order + k ] +for k = 0 , ... , d +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: partial [ i_x * nc_partial + k ] +for k = 0 , ... , d +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: partial [ i_z * nc_partial + k ] +for k = 0 , ... , d +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: partial [ ( i_z - 1) * nc_partial + k ] +for k = 0 , ... , d +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: partial [ i_x * nc_partial + k ] +for k = 0 , ... , d +is the partial derivative of H( x , w , u , ... ) with respect to +the k-th order Taylor coefficient for x. +\n +\b Output: partial [ ( i_z - j ) * nc_partial + k ] +for j = 0 , 1 , and for k = 0 , ... , 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 i_x + 1 < i_z +\li d < cap_order +\li d < nc_partial +*/ +template +void reverse_unary2_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 ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} +// =================== Binary operators with one result ==================== + +/*! +Prototype forward mode x op y (not used) + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param p +lowest order of the Taylor coefficient that we are computing. + +\param q +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 taylor corresponding to z. + +\param arg + arg[0] +index corresponding to the left operand for this operator; +i.e. the index corresponding to x. +\n + arg[1] +index corresponding to the right operand for this operator; +i.e. the index corresponding to y. + +\param parameter +If x is a parameter, parameter [ arg[0] ] +is the value corresponding to x. +\n +If y is a parameter, parameter [ arg[1] ] +is the value corresponding to y. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor +\b Input: If x is a variable, +taylor [ size_t(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 [ size_t(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 ], +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. + +\par Checked Assertions +\li NumArg(op) == 2 +\li NumRes(op) == 1 +\li q < cap_order +\li p <= q +*/ +template +void forward_binary_op( + size_t p , + size_t q , + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + +/*! +Prototype multiple direction forward mode x op y (not used) + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param q +is the order of the Taylor coefficients that we are computing. + +\param r +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 taylor corresponding to z. + +\param arg + arg[0] +index corresponding to the left operand for this operator; +i.e. the index corresponding to x. +\n + arg[1] +index corresponding to the right operand for this operator; +i.e. the index corresponding to y. + +\param parameter +If x is a parameter, parameter [ arg[0] ] +is the value corresponding to x. +\n +If y is a parameter, parameter [ arg[1] ] +is the value corresponding to y. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\par tpv +We use the notation +tpv = (cap_order-1) * r + 1 +which is the number of Taylor coefficients per variable + +\param taylor +\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 ], +for k = 1 , ... , q, +ell = 0, ..., r-1, +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 ], +is the zero order Taylor coefficient for all directions and +taylor [ arg[1] * tpv + (k-1)*r + ell + 1 ], +for k = 1 , ... , q, +ell = 0, ..., r-1, +is the k-th order Taylor coefficient +corresponding to y and the ell-th direction. +\n +\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 ], +for k = 1 , ... , q-1, +ell = 0, ..., r-1, +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], +ell = 0, ..., r-1, +is the q-th order Taylor coefficient +corresponding to z and the ell-th direction. + +\par Checked Assertions +\li NumArg(op) == 2 +\li NumRes(op) == 1 +\li 0 < q < cap_order +*/ +template +void forward_binary_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 ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + + +/*! +Prototype zero order forward mode x op y (not used) + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param i_z +variable index corresponding to the result for this operation; +i.e. the row index in taylor corresponding to z. + +\param arg + arg[0] +index corresponding to the left operand for this operator; +i.e. the index corresponding to x. +\n + arg[1] +index corresponding to the right operand for this operator; +i.e. the index corresponding to y. + +\param parameter +If x is a parameter, parameter [ arg[0] ] +is the value corresponding to x. +\n +If y is a parameter, parameter [ arg[1] ] +is the value corresponding to y. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor +\b Input: If x is a variable, taylor [ arg[0] * cap_order + 0 ] +is the zero order Taylor coefficient corresponding to x. +\n +\b Input: If y is a variable, taylor [ arg[1] * cap_order + 0 ] +is the zero order Taylor coefficient corresponding to y. +\n +\b Output: taylor [ i_z * cap_order + 0 ] +is the zero order Taylor coefficient corresponding to z. + +\par Checked Assertions +\li NumArg(op) == 2 +\li NumRes(op) == 1 +*/ +template +void forward_binary_op_0( + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + +/*! +Prototype for reverse mode binary operator x op y (not used). + +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 +\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< Base > and computations by this routine are done using type + Base . + +\param d +highest order Taylor coefficient that +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 taylor corresponding to z. + +\param arg + arg[0] +index corresponding to the left operand for this operator; +i.e. the index corresponding to x. +\n + arg[1] +index corresponding to the right operand for this operator; +i.e. the index corresponding to y. + +\param parameter +If x is a parameter, parameter [ arg[0] ] +is the value corresponding to x. +\n +If y is a parameter, parameter [ arg[1] ] +is the value corresponding to y. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor + taylor [ i_z * cap_order + k ] +for k = 0 , ... , d +is the k-th order Taylor coefficient corresponding to z. +\n +If x is a variable, taylor [ arg[0] * cap_order + k ] +for k = 0 , ... , d +is the k-th order Taylor coefficient corresponding to x. +\n +If y is a variable, taylor [ arg[1] * cap_order + k ] +for k = 0 , ... , d +is the k-th order Taylor coefficient corresponding to y. + +\param nc_partial +number of colums in the matrix containing all the partial derivatives. + +\param partial +\b Input: partial [ i_z * nc_partial + k ] +for k = 0 , ... , d +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, partial [ arg[0] * nc_partial + k ] +for k = 0 , ... , d +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, partial [ arg[1] * nc_partial + k ] +for k = 0 , ... , d +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, partial [ arg[0] * nc_partial + k ] +for k = 0 , ... , d +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, partial [ arg[1] * nc_partial + k ] +for k = 0 , ... , 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: partial [ i_z * nc_partial + k ] +for k = 0 , ... , 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 If x is a variable, arg[0] < i_z +\li If y is a variable, arg[1] < i_z +\li d < cap_order +\li d < nc_partial +*/ +template +void reverse_binary_op( + size_t d , + size_t i_z , + addr_t* arg , + const Base* parameter , + size_t cap_order , + const Base* taylor , + size_t nc_partial , + Base* partial ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} +// ======================= Pow Function =================================== +/*! +Prototype for forward mode z = pow(x, y) (not used). + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param p +lowest order of the Taylor coefficient that we are computing. + +\param q +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 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 + z_0 = log(x) + 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). + +\param arg + arg[0] +index corresponding to the left operand for this operator; +i.e. the index corresponding to x. +\n + arg[1] +index corresponding to the right operand for this operator; +i.e. the index corresponding to y. + +\param parameter +If x is a parameter, parameter [ arg[0] ] +is the value corresponding to x. +\n +If y is a parameter, parameter [ arg[1] ] +is the value corresponding to y. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor +\b Input: If x is a variable, +taylor [ size_t(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 [ size_t(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-2+j) * cap_order + k ], +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 ], +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 y is a variable, arg[1] < i_z - 2 +\li q < cap_order +\li p <= q +*/ +template +void forward_pow_op( + size_t p , + size_t q , + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} +/*! +Prototype for multiple direction forward mode z = pow(x, y) (not used). + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param q +order of the Taylor coefficient that we are computing. + +\param r +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 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 + z_0 = log(x) + 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). + +\param arg + arg[0] +index corresponding to the left operand for this operator; +i.e. the index corresponding to x. +\n + arg[1] +index corresponding to the right operand for this operator; +i.e. the index corresponding to y. + +\param parameter +If x is a parameter, parameter [ arg[0] ] +is the value corresponding to x. +\n +If y is a parameter, parameter [ arg[1] ] +is the value corresponding to y. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\par tpv +We use the notation +tpv = (cap_order-1) * r + 1 +which is the number of Taylor coefficients per variable + +\param taylor +\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 ] +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 ] +is the zero order coefficient corresponding to y and +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: +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 ], +for j = 0, 1, 2 , k = 0 , ... , q-1, ell = 0, ... , r-1, +is the k-th order Taylor coefficient corresponding to z_j +for the ell-th direction. +\n +\n +\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 +for the ell-th direction. + +\par Checked Assertions +\li NumArg(op) == 2 +\li NumRes(op) == 3 +\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 +*/ +template +void forward_pow_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 ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} +/*! +Prototype for zero order forward mode z = pow(x, y) (not used). + +\tparam Base +base type for the operator; i.e., this operation was recorded +using AD< Base > and computations by this routine are done using type + Base. + +\param i_z +variable index corresponding to the last (primary) result for this operation; +i.e. the row index in 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 + z_0 = log(x) + 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). + +\param arg + arg[0] +index corresponding to the left operand for this operator; +i.e. the index corresponding to x. +\n + arg[1] +index corresponding to the right operand for this operator; +i.e. the index corresponding to y. + +\param parameter +If x is a parameter, parameter [ arg[0] ] +is the value corresponding to x. +\n +If y is a parameter, parameter [ arg[1] ] +is the value corresponding to y. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor +\b Input: If x is a variable, taylor [ arg[0] * cap_order + 0 ] +is the zero order Taylor coefficient corresponding to x. +\n +\b Input: If y is a variable, taylor [ arg[1] * cap_order + 0 ] +is the k-th order Taylor coefficient corresponding to y. +\n +\b Output: taylor [ (i_z - 2 + j) * 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, arg[0] < i_z - 2 +\li If y is a variable, arg[1] < i_z - 2 +*/ +template +void forward_pow_op_0( + size_t i_z , + const addr_t* arg , + const Base* parameter , + size_t cap_order , + Base* taylor ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} +/*! +Prototype for reverse mode z = pow(x, y) (not used). + +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 +\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< Base > and computations by this routine are done using type + Base . + +\param d +highest order Taylor coefficient that +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 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 + z_0 = log(x) + 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). + +\param arg + arg[0] +index corresponding to the left operand for this operator; +i.e. the index corresponding to x. +\n + arg[1] +index corresponding to the right operand for this operator; +i.e. the index corresponding to y. + +\param parameter +If x is a parameter, parameter [ arg[0] ] +is the value corresponding to x. +\n +If y is a parameter, parameter [ arg[1] ] +is the value corresponding to y. + +\param cap_order +maximum number of orders that will fit in the taylor array. + +\param taylor + taylor [ (i_z - 2 + j) * cap_order + k ] +for j = 0, 1, 2 and k = 0 , ... , d +is the k-th order Taylor coefficient corresponding to z_j. +\n +If x is a variable, taylor [ arg[0] * cap_order + k ] +for k = 0 , ... , d +is the k-th order Taylor coefficient corresponding to x. +\n +If y is a variable, taylor [ arg[1] * cap_order + k ] +for k = 0 , ... , d +is the k-th order Taylor coefficient corresponding to y. + +\param nc_partial +number of colums in the matrix containing all the partial derivatives. + +\param partial +\b Input: partial [ (i_z - 2 + j) * nc_partial + k ] +for j = 0, 1, 2, and k = 0 , ... , d +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, partial [ arg[0] * nc_partial + k ] +for k = 0 , ... , d +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, partial [ arg[1] * nc_partial + k ] +for k = 0 , ... , d +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, partial [ arg[0] * nc_partial + k ] +for k = 0 , ... , d +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, partial [ arg[1] * nc_partial + k ] +for k = 0 , ... , 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: partial [ ( i_z - j ) * nc_partial + k ] +for j = 0 , 1 , 2 and for k = 0 , ... , 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) == 3 +\li If x is a variable, arg[0] < i_z - 2 +\li If y is a variable, arg[1] < i_z - 2 +\li d < cap_order +\li d < nc_partial +*/ +template +void reverse_pow_op( + size_t d , + size_t i_z , + addr_t* arg , + const Base* parameter , + size_t cap_order , + const Base* taylor , + size_t nc_partial , + Base* partial ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + +// ==================== Sparsity Calculations ============================== +/*! +Prototype for reverse mode Hessian sparsity unary operators. + +This routine is given the forward mode Jacobian sparsity patterns for x. +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 +\verbatim + H( x , w , u , ... ) = G[ z(x) , x , w , u , ... ] +\endverbatim + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or sparse_list. + +\param i_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 + 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 + 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 i_x in for_jac_sparsity +is the forward mode Jacobian sparsity pattern for the variable x. + +\param rev_hes_sparsity +The set with index i_z in in rev_hes_sparsity +is the Hessian sparsity pattern for the fucntion G +where one of the partials derivative is with respect to z. +\n +\n +The set with index i_x in rev_hes_sparsity +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 i_x < i_z +*/ + +template +void reverse_sparse_hessian_unary_op( + size_t i_z , + size_t i_x , + 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 ); +} + +/*! +Prototype for reverse mode Hessian sparsity binary operators. + +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 +\verbatim + H( y, x, w , u , ... ) = G[ z(x,y) , y , x , w , u , ... ] +\endverbatim + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or sparse_list. + +\param i_z +variable index corresponding to the result for this operation; +i.e. the row index in sparsity corresponding to z. + +\param arg + arg[0] +variable index corresponding to the left operand for this operator; +i.e. the set with index arg[0] in var_sparsity +is the spasity pattern correspoding to x. +\n +\n arg[1] +variable index corresponding to the right operand for this operator; +i.e. the row index in sparsity patterns corresponding to y. + +\param jac_reverse + 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 + jac_reverse[ 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 + jac_reverse[ 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. + +\param for_jac_sparsity +The set with index arg[0] in for_jac_sparsity for the +is the forward Jacobian sparsity pattern for x. +\n +\n +The set with index arg[1] in for_jac_sparsity +is the forward sparsity pattern for y. + +\param rev_hes_sparsity +The set wiht index i_x in 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 arg[0] in 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 arg[1] in 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 arg[0] < i_z +\li arg[1] < i_z +*/ +template +void reverse_sparse_hessian_binary_op( + size_t i_z , + const addr_t* arg , + 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 ); +} + + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/recorder.hpp cppad-2019.02.00.0/include/cppad/local/recorder.hpp --- cppad-2018.00.00.0/include/cppad/local/recorder.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/recorder.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1070 @@ +# ifndef CPPAD_LOCAL_RECORDER_HPP +# define CPPAD_LOCAL_RECORDER_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include +# include + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file recorder.hpp +File used to define the recorder class. +*/ + +/*! +Class used to store an operation sequence while it is being recorded +(the operation sequence is copied to the player class for playback). + +\tparam Base +This is an AD< Base > operation sequence recording; i.e., +it records operations of type AD< Base >. +*/ +template +class recorder { + friend class player; + +private: + /// are comparison operators being recorded + bool record_compare_; + + /// operator index at which to abort recording with an error + /// (do not abort when zero) + size_t abort_op_index_; + + /// Number of variables in the recording. + size_t num_var_rec_; + + /// Number of dynamic parameters in the recording + size_t num_dynamic_ind_; + + /// Number vecad load operations (LdpOp or LdvOp) currently in recording. + size_t num_load_op_rec_; + + /// The operators in the recording. + pod_vector op_vec_; + + /// The VecAD indices in the recording. + pod_vector vecad_ind_vec_; + + /// The argument indices in the recording + pod_vector arg_vec_; + + /// Character strings ('\\0' terminated) in the recording. + pod_vector text_vec_; + + /// Hash table to reduced number of duplicate parameters in all_par_vec_ + pod_vector par_hash_table_; + + /// Vector containing all the parameters in the recording. + /// Use pod_vector_maybe because Base may not be plain old data. + pod_vector_maybe all_par_vec_; + + /// Which elements of all_par_vec_ are dynamic parameters + /// (same size are all_par_vec_) + pod_vector dyn_par_is_; + + /// operators for just the dynamic parameters in all_par_vec_ + pod_vector dyn_par_op_; + + /// arguments for the dynamic parameter operators + pod_vector dyn_par_arg_; + +// ---------------------- Public Functions ----------------------------------- +public: + /// Default constructor + recorder(void) : + num_var_rec_(0) , + num_dynamic_ind_(0) , + num_load_op_rec_(0) , + par_hash_table_( CPPAD_HASH_TABLE_SIZE ) + { record_compare_ = true; + abort_op_index_ = 0; + // It does not matter if unitialized hash codes match but this + // initilaization is here to avoid valgrind warnings. + void* ptr = static_cast( par_hash_table_.data() ); + int value = 0; + size_t num = CPPAD_HASH_TABLE_SIZE * sizeof(addr_t); + std::memset(ptr, value, num); + } + + /// Set record_compare option + void set_record_compare(bool record_compare) + { record_compare_ = record_compare; } + + /// Set the abort index + void set_abort_op_index(size_t abort_op_index) + { abort_op_index_ = abort_op_index; } + + /// Set number of independent dynamic parameters + void set_num_dynamic_ind(size_t num_dynamic_ind) + { num_dynamic_ind_ = num_dynamic_ind; } + + /// Get record_compare option + bool get_record_compare(void) const + { return record_compare_; } + + /// Get the abort_op_index + size_t get_abort_op_index(void) const + { return abort_op_index_; } + + /// Get number of independent dynamic parameters + size_t get_num_dynamic_ind(void) const + { return num_dynamic_ind_; } + + /// Destructor + ~recorder(void) + { } + + /// Put a dynamic parameter in all_par_vec_. + addr_t put_dyn_par(const Base &par, op_code_dyn op + ); + addr_t put_dyn_par(const Base &par, op_code_dyn op, + addr_t arg0 + ); + addr_t put_dyn_par(const Base &par, op_code_dyn op, + addr_t arg0, addr_t arg1 + ); + addr_t put_dyn_cond_exp(const Base &par, CompareOp cop, + addr_t left, addr_t right, addr_t if_true, addr_t if_false + ); + /// Put a vector of dynamic parameter arguments at end of tape + void put_dyn_arg_vec(const pod_vector& arg); + + + /// Put next operator in the operation sequence. + addr_t PutOp(OpCode op); + /// Put a vecad load operator in the operation sequence (special case) + addr_t PutLoadOp(OpCode op); + /// Add a value to the end of the current vector of VecAD indices. + addr_t PutVecInd(addr_t vec_ind); + /// Find or add a constant parameter to the vector of all parameters. + addr_t put_con_par(const Base &par); + /// Put one operation argument index in the recording + void PutArg(addr_t arg0); + /// Put two operation argument index in the recording + void PutArg(addr_t arg0, addr_t arg1); + /// Put three operation argument index in the recording + void PutArg(addr_t arg0, addr_t arg1, addr_t arg2); + /// Put four operation argument index in the recording + void PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3); + /// Put five operation argument index in the recording + void PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3, + addr_t arg4); + /// Put six operation argument index in the recording + void PutArg(addr_t arg0, addr_t arg1, addr_t arg2, addr_t arg3, + addr_t arg4, addr_t arg5); + template + void put_dyn_atomic( + tape_id_t tape_id , + size_t atom_index , + const vector& type_x , + const vector& type_y , + const VectorAD& ax , + VectorAD& ay + ); + + // Reserve space for a specified number of arguments + size_t ReserveArg(size_t n_arg); + + // Replace an argument value + void ReplaceArg(size_t i_arg, addr_t value); + + /// Put a character string in the text for this recording. + addr_t PutTxt(const char *text); + + /// record a conditional expression + void cond_exp( + tape_id_t tape_id , + enum CompareOp cop , + AD &result , + const AD &left , + const AD &right , + const AD &if_true , + const AD &if_false + ); + + // ----------------------------------------------------------------------- + // functions implemented here + + /// Number of variables currently stored in the recording. + size_t num_var_rec(void) const + { return num_var_rec_; } + + /// Number of LdpOp and LdvOp operations currently in the recording. + size_t num_load_op_rec(void) const + { return num_load_op_rec_; } + + /// Number of operators currently stored in the recording. + size_t num_op_rec(void) const + { return op_vec_.size(); } + + /// Approximate amount of memory used by the recording + size_t Memory(void) const + { return op_vec_.capacity() * sizeof(opcode_t) + + vecad_ind_vec_.capacity() * sizeof(size_t) + + arg_vec_.capacity() * sizeof(addr_t) + + all_par_vec_.capacity() * sizeof(Base) + + text_vec_.capacity() * sizeof(char); + } + +}; + +/*! +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 +\verbatim + NumArg(op) +\endverbatim +argument indices in the recording. + +\param op +Is the op code corresponding to the the operation that is being +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 number of variables corresponding to the operation is given by +\verbatim + NumRes(op) +\endverbatim +With each call to PutOp or PutLoadOp, +the return index increases by the number of variables corresponding +to the call. +This index starts at zero after the default constructor. +*/ +template +addr_t recorder::PutOp(OpCode op) +{ size_t i = op_vec_.extend(1); + CPPAD_ASSERT_KNOWN( + (abort_op_index_ == 0) || (abort_op_index_ != i), + "Operator index equals abort_op_index in Independent" + ); + op_vec_[i] = static_cast(op); + CPPAD_ASSERT_UNKNOWN( op_vec_.size() == i + 1 ); + CPPAD_ASSERT_UNKNOWN( (op != LdpOp) & (op != LdvOp) ); + + // first operator should be a BeginOp and NumRes( BeginOp ) > 0 + num_var_rec_ += NumRes(op); + CPPAD_ASSERT_UNKNOWN( num_var_rec_ > 0 ); + + // index of last variable corresponding to this operation + // (if NumRes(op) > 0) + CPPAD_ASSERT_KNOWN( + (size_t) std::numeric_limits::max() >= num_var_rec_ - 1, + "cppad_tape_addr_type maximum value has been exceeded" + ) + + return static_cast( num_var_rec_ - 1 ); +} + +/*! +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 +\verbatim + NumArg(op) +\endverbatim +argument indices in the recording. + +\param op +Is the op code corresponding to the the operation that is being +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 number of variables corresponding to the operation is given by +\verbatim + NumRes(op) +\endverbatim +which must be one for this operation. +With each call to PutLoadOp or PutOp, +the return index increases by the number of variables corresponding +to this call to the call. +This index starts at zero after the default constructor. + +\par num_load_op_rec() +The return value for num_load_op_rec() +increases by one after each call to this function. +*/ +template +addr_t recorder::PutLoadOp(OpCode op) +{ size_t i = op_vec_.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_vec_[i] = op; + CPPAD_ASSERT_UNKNOWN( op_vec_.size() == i + 1 ); + CPPAD_ASSERT_UNKNOWN( (op == LdpOp) | (op == LdvOp) ); + + // first operator should be a BeginOp and NumRes( BeginOp ) > 0 + num_var_rec_ += NumRes(op); + CPPAD_ASSERT_UNKNOWN( num_var_rec_ > 0 ); + + // count this vecad load operation + num_load_op_rec_++; + + // index of last variable corresponding to this operation + // (if NumRes(op) > 0) + CPPAD_ASSERT_KNOWN( + (size_t) std::numeric_limits::max() >= num_var_rec_ - 1, + "cppad_tape_addr_type maximum value has been exceeded" + ) + return static_cast( num_var_rec_ - 1 ); +} + +/*! +Add a value to the end of the current vector of VecAD indices. + +For each VecAD vector, this routine is used to store the length +of the vector followed by the parameter index corresponding to each +value in the vector. +This value for the elements of the VecAD vector corresponds to the +beginning of the operation sequence. + +\param vec_ind +is the index to be palced at the end of the vector of VecAD indices. + +\return +is the index in the vector of VecAD indices corresponding to this value. +This index starts at zero after the recorder default constructor. +It increments by one for each call to PutVecInd.. +*/ +template +addr_t recorder::PutVecInd(addr_t vec_ind) +{ size_t i = vecad_ind_vec_.extend(1); + CPPAD_ASSERT_UNKNOWN( + std::numeric_limits::max() >= vec_ind + ); + vecad_ind_vec_[i] = vec_ind; + CPPAD_ASSERT_UNKNOWN( vecad_ind_vec_.size() == i + 1 ); + + CPPAD_ASSERT_KNOWN( + size_t( std::numeric_limits::max() ) >= i, + "cppad_tape_addr_type maximum value has been exceeded" + ); + return static_cast( i ); +} + + +/*! +Put a dynamic parameter at the end of the vector for all parameters. + +\param par +is value of dynamic parameter to be placed at the end of the vector. + +\param op +is the operator for this dynamic parameter. +There are no arguments to this operator, so numarg(op) == 0. + +\return +is the index in all_par_vec_ corresponding to this dynamic parameter value. +*/ +template +addr_t recorder::put_dyn_par(const Base &par, op_code_dyn op) +{ // independent parameters come first + CPPAD_ASSERT_UNKNOWN( + op == ind_dyn || op == result_dyn || op == call_dyn + ); + CPPAD_ASSERT_UNKNOWN( num_arg_dyn(op) == 0 ); + all_par_vec_.push_back( par ); + dyn_par_is_.push_back(true); + dyn_par_op_.push_back( opcode_t(op) ); + return static_cast( all_par_vec_.size() - 1 ); +} +/*! +Put a dynamic parameter at the end of the vector for all parameters. + +\param par +is value of dynamic parameter to be placed at the end of the vector. + +\param op +is the operator for this dynamic parameter. +There is one argument to this operator, so numarg(op) == 1. + +\param arg0 +this is the argument to the operator represented +as an index in the all_par_vec_ vector. + +\return +is the index in all_par_vec_ corresponding to this dynamic parameter value. +*/ +template +addr_t recorder::put_dyn_par( + const Base &par, op_code_dyn op, addr_t arg0 +) +{ // independent parameters come first + CPPAD_ASSERT_UNKNOWN( num_arg_dyn(op) == 1 ); + all_par_vec_.push_back( par ); + dyn_par_is_.push_back(true); + dyn_par_op_.push_back( opcode_t(op) ); + dyn_par_arg_.push_back(arg0); + return static_cast( all_par_vec_.size() - 1 ); +} +/*! +Put a dynamic parameter at the end of the vector for all parameters. + +\param par +is value of dynamic parameter to be placed at the end of the vector. + +\param op +is the operator for this dynamic parameter. +There are two arguments to this operator, so numarg(op) == 2. + +\param arg0 +this is the first argument to the operator represented +as an index in the all_par_vec_ vector. + +\param arg1 +this is the second argument to the operator represented +as an index in the all_par_vec_ vector. +One of the two arguments must be a dynamic parameter. + +\return +is the index in all_par_vec_ corresponding to this dynamic parameter value. +*/ +template +addr_t recorder::put_dyn_par( + const Base &par, op_code_dyn op, addr_t arg0, addr_t arg1 +) +{ // independent parameters come first + CPPAD_ASSERT_UNKNOWN( num_arg_dyn(op) == 2 ); + all_par_vec_.push_back( par ); + dyn_par_is_.push_back(true); + dyn_par_op_.push_back( opcode_t(op) ); + dyn_par_arg_.push_back(arg0); + dyn_par_arg_.push_back(arg1); + return static_cast( all_par_vec_.size() - 1 ); +} +/*! +Put a dynamic parameter, that is result of conditional expression, +at the end of the vector for all parameters. + +\param par +is value of dynamic parameter to be placed at the end of the vector. + +\param cop +is the operator comparision operator; i.e., Lt, Le, Eq, Ge, Gt, Ne. + +\param left +is the left argument in conditional expression (which is a parameter). + +\param right +is the right argument in conditional expression (which is a parameter). + +\param if_true +is the if_true argument in conditional expression (which is a parameter). + +\param if_false +is the if_false argument in conditional expression (which is a parameter). + +\return +is the index in all_par_vec_ corresponding to this dynamic parameter value. +*/ +template +addr_t recorder::put_dyn_cond_exp(const Base &par, CompareOp cop, + addr_t left, addr_t right, addr_t if_true, addr_t if_false +) +{ // independent parameters come first + CPPAD_ASSERT_UNKNOWN( num_arg_dyn(cond_exp_dyn) == 5 ); + addr_t ret = addr_t( all_par_vec_.size() ); + all_par_vec_.push_back( par ); + dyn_par_is_.push_back(true); + dyn_par_op_.push_back( opcode_t(cond_exp_dyn) ); + dyn_par_arg_.push_back( addr_t(cop) ); + dyn_par_arg_.push_back(left); + dyn_par_arg_.push_back(right); + dyn_par_arg_.push_back(if_true); + dyn_par_arg_.push_back(if_false); + return ret; +} +// --------------------------------------------------------------------------- +/*! +Puts a vector of arguments at the end of the current dynamic parameter tape + +\param arg_vec [in] +is the vector of values to be added at the end of the tape. +*/ +template +void recorder::put_dyn_arg_vec(const pod_vector& arg_vec) +{ for(size_t i = 0; i < arg_vec.size(); ++i) + dyn_par_arg_.push_back( arg_vec[i] ); +} +// --------------------------------------------------------------------------- +/*! +Puts atomic call operators, and corresponding dynamic parameter values, +at the end of the vector for all parameters + +\param tape_id [in] +identifies the tape that this recording corresponds to +(hence must be non-zero). + +\param atom_index [in] +is the index in atomic_index for this atomic function; see call_atomic. + +\param type_x [in] +is the ad_type_enum for each of the atomic function arguments + +\param type_y [in] +is the ad_type_enum for each of the atomic function results. + +\param ax [in] +is the the atomic function arguments + +\param ay [in/out] +is the atomic function results. +Upon input, all of the arguments are constant parameters and +ay.value_ is the result of the atomic function. +Upon return, if type_y[i] is dynamic_enum, +ay[i].ad_type_ = dynamic_enum, +ay[i].tape_id_ = tape_id, +and ay[2].taddr_ is the index in the parameter vector +for this dynamic parameter. +*/ +template +template +void recorder::put_dyn_atomic( + tape_id_t tape_id , + size_t atom_index , + const vector& type_x , + const vector& type_y , + const VectorAD& ax , + VectorAD& ay ) +{ CPPAD_ASSERT_UNKNOWN( tape_id != 0 ); + CPPAD_ASSERT_UNKNOWN( ax.size() == type_x.size() ); + CPPAD_ASSERT_UNKNOWN( ay.size() == type_y.size() ); + size_t n = ax.size(); + size_t m = ay.size(); + size_t num_dyn = 0; + for(size_t i = 0; i < m; ++i) + if( type_y[i] == dynamic_enum ) + ++num_dyn; + CPPAD_ASSERT_UNKNOWN( num_dyn > 0 ); + // + dyn_par_arg_.push_back( addr_t( atom_index ) ); // arg[0] = atom_index + dyn_par_arg_.push_back( addr_t( n ) ); // arg[1] = n + dyn_par_arg_.push_back( addr_t( m ) ); // arg[2] = m + dyn_par_arg_.push_back( addr_t( num_dyn ) ); // arg[3] = num_dyn + // arg[4 + j] for j = 0, ... , n-1 + for(size_t j = 0; j < n; ++j) + { addr_t arg = 0; + switch( type_x[j] ) + { case constant_enum: + arg = put_con_par( ax[j].value_ ); + break; + + case dynamic_enum: + arg = ax[j].taddr_; + break; + + case variable_enum: + arg = 0; // phantom parameter index + CPPAD_ASSERT_UNKNOWN( isnan( all_par_vec_[arg] ) ) + break; + + default: + arg = 0; + CPPAD_ASSERT_UNKNOWN( false ); + } + dyn_par_arg_.push_back( arg ); // arg[4 + j] + } + // arg[4 + n + i] for i = 0, ... , m-1 + bool first_dynamic_result = true; + for(size_t i = 0; i < m; ++i) + { CPPAD_ASSERT_UNKNOWN( Constant( ay[i] ) ); + addr_t arg; + switch( type_y[i] ) + { case constant_enum: + arg = 0; // phantom parameter index + break; + + case dynamic_enum: + // one operator for each dynamic parameter result + // so number of operators is equal number of dynamic parameters + if( first_dynamic_result ) + arg = put_dyn_par(ay[i].value_, call_dyn ); // call_dyn + else + arg = put_dyn_par(ay[i].value_, result_dyn ); // result_dyn + ay[i].ad_type_ = dynamic_enum; + ay[i].taddr_ = arg; + ay[i].tape_id_ = tape_id; + CPPAD_ASSERT_UNKNOWN( Dynamic( ay[i] ) ); + first_dynamic_result = false; + break; + + case variable_enum: + arg = 0; // phantom parameter (has value nan) + break; + + default: + arg = 0; + CPPAD_ASSERT_UNKNOWN( false ); + } + dyn_par_arg_.push_back( arg ); // arg[4 + n + i] + } + dyn_par_arg_.push_back( addr_t(5 + n + m) ); // arg[4 + n + m] +} + +// --------------------------------------------------------------------------- +/*! +Find or add a constant parameter to the current vector of all parameters. + +\param par +is the parameter to be found or placed in the vector of parameters. + +\return +is the index in the parameter vector corresponding to this parameter value. +This value is not necessarily placed at the end of the vector +(because values that are identically equal may be reused). +*/ +template +addr_t recorder::put_con_par(const Base &par) +{ +# ifndef NDEBUG + // index zero is used to signify that a value is not a parameter; + // i.e., it is a variable. + if( all_par_vec_.size() == 0 ) + CPPAD_ASSERT_UNKNOWN( isnan(par) ); +# endif + // --------------------------------------------------------------------- + // check for a match with a previous parameter + // + // get hash code for this value + size_t code = static_cast( hash_code(par) ); + + // current index in all_par_vec_ corresponding to this hash code + size_t index = static_cast( par_hash_table_[code] ); + + // check if the old parameter matches the new one + if( (0 < index) & (index < all_par_vec_.size()) ) + { if( ! dyn_par_is_[index] ) + if( IdenticalEqualCon(all_par_vec_[index], par) ) + return static_cast( index ); + } + // --------------------------------------------------------------------- + // put paramerter in all_par_vec_ and replace hash entry for this codee + // + index = all_par_vec_.size(); + all_par_vec_.push_back( par ); + dyn_par_is_.push_back(false); + // + // change the hash table for this code to point to new value + par_hash_table_[code] = static_cast( index ); + // + // return the parameter index + CPPAD_ASSERT_KNOWN( + static_cast( std::numeric_limits::max() ) >= index, + "cppad_tape_addr_type maximum value has been exceeded" + ) + return static_cast( index ); +} +// -------------------------- PutArg -------------------------------------- +/*! +Prototype for putting operation argument indices in the recording. + +The following syntax +\verbatim + rec.PutArg(arg0) + rec.PutArg(arg0, arg1) + . + . + . + rec.PutArg(arg0, arg1, ..., arg5) +\endverbatim +places the values passed to PutArg at the current end of the +operation argument indices for the recording. + arg0 comes before arg1, etc. +The proper number of operation argument indices +corresponding to the operation code op is given by +\verbatim + NumArg(op) +\endverbatim +The number of the operation argument indices starts at zero +after the default constructor. +*/ +inline void prototype_put_arg(void) +{ // This routine should not be called + CPPAD_ASSERT_UNKNOWN(false); +} +/*! +Put one operation argument index in the recording + +\param arg0 +The operation argument index + +\copydetails prototype_put_arg +*/ +template +void recorder::PutArg(addr_t arg0) +{ + size_t i = arg_vec_.extend(1); + arg_vec_[i] = arg0; + CPPAD_ASSERT_UNKNOWN( arg_vec_.size() == i + 1 ); +} +/*! +Put two operation argument index in the recording + +\param arg0 +First operation argument index. + +\param arg1 +Second operation argument index. + +\copydetails prototype_put_arg +*/ +template +void recorder::PutArg(addr_t arg0, addr_t arg1) +{ + size_t i = arg_vec_.extend(2); + arg_vec_[i++] = arg0; + arg_vec_[i] = arg1; + CPPAD_ASSERT_UNKNOWN( arg_vec_.size() == i + 1 ); +} +/*! +Put three operation argument index in the recording + +\param arg0 +First operation argument index. + +\param arg1 +Second operation argument index. + +\param arg2 +Third operation argument index. + +\copydetails prototype_put_arg +*/ +template +void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2) +{ + size_t i = arg_vec_.extend(3); + arg_vec_[i++] = arg0; + arg_vec_[i++] = arg1; + arg_vec_[i] = arg2; + CPPAD_ASSERT_UNKNOWN( arg_vec_.size() == i + 1 ); +} +/*! +Put four operation argument index in the recording + +\param arg0 +First operation argument index. + +\param arg1 +Second operation argument index. + +\param arg2 +Third operation argument index. + +\param arg3 +Fourth operation argument index. + +\copydetails prototype_put_arg +*/ +template +void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2, + addr_t arg3) +{ + size_t i = arg_vec_.extend(4); + arg_vec_[i++] = arg0; + arg_vec_[i++] = arg1; + arg_vec_[i++] = arg2; + arg_vec_[i] = arg3; + CPPAD_ASSERT_UNKNOWN( arg_vec_.size() == i + 1 ); + +} +/*! +Put five operation argument index in the recording + +\param arg0 +First operation argument index. + +\param arg1 +Second operation argument index. + +\param arg2 +Third operation argument index. + +\param arg3 +Fourth operation argument index. + +\param arg4 +Fifth operation argument index. + +\copydetails prototype_put_arg +*/ +template +void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2, + addr_t arg3, addr_t arg4) +{ + size_t i = arg_vec_.extend(5); + arg_vec_[i++] = arg0; + arg_vec_[i++] = arg1; + arg_vec_[i++] = arg2; + arg_vec_[i++] = arg3; + arg_vec_[i] = arg4; + CPPAD_ASSERT_UNKNOWN( arg_vec_.size() == i + 1 ); + +} +/*! +Put six operation argument index in the recording + +\param arg0 +First operation argument index. + +\param arg1 +Second operation argument index. + +\param arg2 +Third operation argument index. + +\param arg3 +Fourth operation argument index. + +\param arg4 +Fifth operation argument index. + +\param arg5 +Sixth operation argument index. + +\copydetails prototype_put_arg +*/ +template +void recorder::PutArg(addr_t arg0, addr_t arg1, addr_t arg2, + addr_t arg3, addr_t arg4, addr_t arg5) +{ + size_t i = arg_vec_.extend(6); + arg_vec_[i++] = arg0; + arg_vec_[i++] = arg1; + arg_vec_[i++] = arg2; + arg_vec_[i++] = arg3; + arg_vec_[i++] = arg4; + arg_vec_[i] = arg5; + CPPAD_ASSERT_UNKNOWN( arg_vec_.size() == i + 1 ); +} +// -------------------------------------------------------------------------- +/*! +Reserve space for arguments, but delay placing values there. + +\param n_arg +number of arguements to reserve space for + +\return +is the index in the argument vector corresponding to the +first of the arguments being reserved. +*/ +template +size_t recorder::ReserveArg(size_t n_arg) +{ + size_t i = arg_vec_.extend(n_arg); + CPPAD_ASSERT_UNKNOWN( arg_vec_.size() == i + n_arg ); + return i; +} + +/*! +\brief +Replace an argument value in the recording +(intended to fill in reserved values). + +\param i_arg +is the index, in argument vector, for the value that is replaced. + +\param value +is the new value for the argument with the specified index. +*/ +template +void recorder::ReplaceArg(size_t i_arg, addr_t value) +{ arg_vec_[i_arg] = value; } +// -------------------------------------------------------------------------- +/*! +Put a character string in the text for this recording. + +\param text +is a '\\0' terminated character string that is to be put in the +vector of characters corresponding to this recording. +The terminator '\\0' will be included. + +\return +is the offset with in the text vector for this recording at which +the character string starts. +*/ +template +addr_t recorder::PutTxt(const char *text) +{ + // determine length of the text including terminating '\0' + size_t n = 0; + while( text[n] != '\0' ) + n++; + CPPAD_ASSERT_UNKNOWN( n <= 1000 ); + n++; + CPPAD_ASSERT_UNKNOWN( text[n-1] == '\0' ); + + // copy text including terminating '\0' + size_t i = text_vec_.extend(n); + size_t j; + for(j = 0; j < n; j++) + text_vec_[i + j] = text[j]; + CPPAD_ASSERT_UNKNOWN( text_vec_.size() == i + n ); + + CPPAD_ASSERT_KNOWN( + size_t( std::numeric_limits::max() ) >= i, + "cppad_tape_addr_type maximum value has been exceeded" + ); + // + return static_cast( i ); +} +// ------------------------------------------------------------------------- +/*! +Record a conditional expression + +\tparam Base +Base type for this recording. + +\param tape_id +identifier for the tape that this operation is being recorded on. +Passing tape_id avoids having to call tape_ptr() in case where +left, right, if_true, and if_false are all all be constant at this AD level +(but left and right are not identically constant). + +\param cop +Which comparision operator: <, <=, ==, >=, >, or !=. + +\param result +the result for this operation. +The result.value_ is an input and result must be a constant on input. +All of the fields, except result.value_, are outputs. + +\param left +value of the left operand in the comparison. + +\param right +value of the right operand in the comparison. + +\param if_true +value of the result if the comparision value is true. + +\param if_false +value of the result if the comparision value is false. +*/ +template +void recorder::cond_exp( + tape_id_t tape_id , + enum CompareOp cop , + AD &result , + const AD &left , + const AD &right , + const AD &if_true , + const AD &if_false ) +{ // check for invalid tape_id + CPPAD_ASSERT_UNKNOWN( tape_id != 0 ); + + // check input result + CPPAD_ASSERT_UNKNOWN( Constant(result) ); + + // arg[0] = cop + addr_t arg0 = addr_t( cop ); + + // arg[1] = base 2 represenation of the value + // [Var(left), Var(right), Var(if_true), Var(if_false)] + addr_t arg1 = 0; + + // arg[2] = left address + // set first bit in arg1 + addr_t arg2 = left.taddr_; + if( Constant(left) ) + arg2 = put_con_par(left.value_); + else + { CPPAD_ASSERT_KNOWN( tape_id == left.tape_id_ , + "CondExpRel: arguments are variables or dynamics for different thread" + ); + if(left.ad_type_ != dynamic_enum) + arg1 += 1; + } + + // arg[3] = right address + // set second bit in arg1 + addr_t arg3 = right.taddr_; + if( Constant(right) ) + arg3 = put_con_par(right.value_); + else + { CPPAD_ASSERT_KNOWN( tape_id == right.tape_id_ , + "CondExpRel: arguments are variables or dynamics for different thread" + ); + if(right.ad_type_ != dynamic_enum) + arg1 += 2; + } + + // arg[4] = if_true address + // set third bit in arg1 + addr_t arg4 = if_true.taddr_; + if( Constant(if_true) ) + arg4 = put_con_par(if_true.value_); + else + { CPPAD_ASSERT_KNOWN( tape_id == if_true.tape_id_ , + "CondExpRel: arguments are variables or dynamics for different thread" + ); + if(if_true.ad_type_ != dynamic_enum) + arg1 += 4; + } + + // arg[5] = if_false address + // set fourth bit in arg1 + addr_t arg5 = if_false.taddr_; + if( Constant(if_false) ) + arg5 = put_con_par(if_false.value_); + else + { CPPAD_ASSERT_KNOWN( tape_id == if_false.tape_id_ , + "CondExpRel: arguments are variables or dynamics for different thread" + ); + if(if_false.ad_type_ != dynamic_enum) + arg1 += 8; + } + if( arg1 == 0 ) + { // none of the arguments are variables, record cond_exp_dyn + + // put the result at the end of the parameter vector as dynamic + // put_dyn_cond_exp(par, cop, left, right, if_true, if_false) + result.taddr_ = put_dyn_cond_exp( + result.value_, CompareOp(arg0), arg2, arg3, arg4, arg5 + ); + result.ad_type_ = dynamic_enum; + result.tape_id_ = tape_id; + + // check that result is a dynamic parameter + CPPAD_ASSERT_UNKNOWN( Dynamic(result) ); + } + else + { CPPAD_ASSERT_UNKNOWN( NumArg(CExpOp) == 6 ); + CPPAD_ASSERT_UNKNOWN( NumRes(CExpOp) == 1 ); + + // put operator in tape + result.taddr_ = PutOp(CExpOp); + PutArg(arg0, arg1, arg2, arg3, arg4, arg5); + + // make result a variable + CPPAD_ASSERT_UNKNOWN( result.ad_type_ == constant_enum ); + result.ad_type_ = variable_enum; + result.tape_id_ = tape_id; + + // check that result is a variable + CPPAD_ASSERT_UNKNOWN( Variable(result) ); + } +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/set_get_in_parallel.hpp cppad-2019.02.00.0/include/cppad/local/set_get_in_parallel.hpp --- cppad-2018.00.00.0/include/cppad/local/set_get_in_parallel.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/set_get_in_parallel.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,66 @@ +# ifndef CPPAD_LOCAL_SET_GET_IN_PARALLEL_HPP +# define CPPAD_LOCAL_SET_GET_IN_PARALLEL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_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_LOCAL_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sign_op.hpp cppad-2019.02.00.0/include/cppad/local/sign_op.hpp --- cppad-2018.00.00.0/include/cppad/local/sign_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sign_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,153 @@ +# ifndef CPPAD_LOCAL_SIGN_OP_HPP +# define CPPAD_LOCAL_SIGN_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file sign_op.hpp +Forward and reverse mode calculations for z = sign(x). +*/ + +/*! +Compute forward mode Taylor coefficient for result of op = SignOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sign(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op +*/ +template +void forward_sign_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(SignOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SignOp) == 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] = sign(x[0]); + p++; + } + for(size_t j = p; j <= q; j++) + z[j] = Base(0.); +} +/*! +Multiple direction forward mode Taylor coefficient for op = SignOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sign(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op_dir +*/ +template +void forward_sign_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(SignOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SignOp) == 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; + size_t m = (q - 1) * r + 1; + Base* z = taylor + i_z * num_taylor_per_var; + + for(size_t ell = 0; ell < r; ell++) + z[m+ell] = Base(0.); +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = SignOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sign(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op_0 +*/ +template +void forward_sign_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(SignOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SignOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + + // Taylor coefficients corresponding to argument and result + Base x0 = *(taylor + i_x * cap_order); + Base* z = taylor + i_z * cap_order; + + z[0] = sign(x0); +} +/*! +Compute reverse mode partial derivatives for result of op = SignOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sign(x) +\endverbatim + +\copydetails CppAD::local::reverse_unary1_op +*/ + +template +void reverse_sign_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(SignOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SignOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // nothing to do because partials of sign are zero + return; +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sinh_op.hpp cppad-2019.02.00.0/include/cppad/local/sinh_op.hpp --- cppad-2018.00.00.0/include/cppad/local/sinh_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sinh_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,239 @@ +# ifndef CPPAD_LOCAL_SINH_OP_HPP +# define CPPAD_LOCAL_SINH_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file sinh_op.hpp +Forward and reverse mode calculations for z = sinh(x). +*/ + + +/*! +Compute forward mode Taylor coefficient for result of op = SinhOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sinh(x) +\endverbatim +The auxillary result is +\verbatim + y = cosh(x) +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails CppAD::local::forward_unary2_op +*/ +template +void forward_sinh_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(SinhOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SinhOp) == 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* s = taylor + i_z * cap_order; + Base* c = s - cap_order; + + + // rest of this routine is identical for the following cases: + // forward_sin_op, forward_cos_op, forward_sinh_op, forward_cosh_op + // (except that there is a sign difference for hyperbolic case). + size_t k; + if( p == 0 ) + { s[0] = sinh( x[0] ); + c[0] = cosh( x[0] ); + p++; + } + for(size_t j = p; j <= q; j++) + { + s[j] = Base(0.0); + c[j] = Base(0.0); + for(k = 1; k <= j; k++) + { s[j] += Base(double(k)) * x[k] * c[j-k]; + c[j] += Base(double(k)) * x[k] * s[j-k]; + } + s[j] /= Base(double(j)); + c[j] /= Base(double(j)); + } +} +/*! +Compute forward mode Taylor coefficient for result of op = SinhOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sinh(x) +\endverbatim +The auxillary result is +\verbatim + y = cosh(x) +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails CppAD::local::forward_unary2_op_dir +*/ +template +void forward_sinh_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(SinhOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SinhOp) == 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* s = taylor + i_z * num_taylor_per_var; + Base* c = s - num_taylor_per_var; + + + // rest of this routine is identical for the following cases: + // forward_sin_op, forward_cos_op, forward_sinh_op, forward_cosh_op + // (except that there is a sign difference for the hyperbolic case). + size_t m = (q-1) * r + 1; + for(size_t ell = 0; ell < r; ell++) + { s[m+ell] = Base(double(q)) * x[m + ell] * c[0]; + c[m+ell] = Base(double(q)) * x[m + ell] * s[0]; + for(size_t k = 1; k < q; k++) + { s[m+ell] += Base(double(k)) * x[(k-1)*r+1+ell] * c[(q-k-1)*r+1+ell]; + c[m+ell] += Base(double(k)) * x[(k-1)*r+1+ell] * s[(q-k-1)*r+1+ell]; + } + s[m+ell] /= Base(double(q)); + c[m+ell] /= Base(double(q)); + } +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = SinhOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sinh(x) +\endverbatim +The auxillary result is +\verbatim + y = cosh(x) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails CppAD::local::forward_unary2_op_0 +*/ +template +void forward_sinh_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(SinhOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SinhOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* s = taylor + i_z * cap_order; // called z in documentation + Base* c = s - cap_order; // called y in documentation + + s[0] = sinh( x[0] ); + c[0] = cosh( x[0] ); +} +/*! +Compute reverse mode partial derivatives for result of op = SinhOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sinh(x) +\endverbatim +The auxillary result is +\verbatim + y = cosh(x) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails CppAD::local::reverse_unary2_op +*/ + +template +void reverse_sinh_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(SinhOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SinhOp) == 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* s = taylor + i_z * cap_order; // called z in doc + Base* ps = partial + i_z * nc_partial; + + // Taylor coefficients and partials corresponding to auxillary result + 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; + size_t k; + while(j) + { + ps[j] /= Base(double(j)); + pc[j] /= Base(double(j)); + for(k = 1; k <= j; k++) + { + px[k] += Base(double(k)) * azmul(ps[j], c[j-k]); + px[k] += Base(double(k)) * azmul(pc[j], s[j-k]); + + ps[j-k] += Base(double(k)) * azmul(pc[j], x[k]); + pc[j-k] += Base(double(k)) * azmul(ps[j], x[k]); + + } + --j; + } + px[0] += azmul(ps[0], c[0]); + px[0] += azmul(pc[0], s[0]); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sin_op.hpp cppad-2019.02.00.0/include/cppad/local/sin_op.hpp --- cppad-2018.00.00.0/include/cppad/local/sin_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sin_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,240 @@ +# ifndef CPPAD_LOCAL_SIN_OP_HPP +# define CPPAD_LOCAL_SIN_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file sin_op.hpp +Forward and reverse mode calculations for z = sin(x). +*/ + + +/*! +Compute forward mode Taylor coefficient for result of op = SinOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sin(x) +\endverbatim +The auxillary result is +\verbatim + y = cos(x) +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails CppAD::local::forward_unary2_op +*/ +template +void forward_sin_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(SinOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SinOp) == 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* s = taylor + i_z * cap_order; + Base* c = s - cap_order; + + // rest of this routine is identical for the following cases: + // forward_sin_op, forward_cos_op, forward_sinh_op, forward_cosh_op. + // (except that there is a sign difference for the hyperbolic case). + size_t k; + if( p == 0 ) + { s[0] = sin( x[0] ); + c[0] = cos( x[0] ); + p++; + } + for(size_t j = p; j <= q; j++) + { + s[j] = Base(0.0); + c[j] = Base(0.0); + for(k = 1; k <= j; k++) + { s[j] += Base(double(k)) * x[k] * c[j-k]; + c[j] -= Base(double(k)) * x[k] * s[j-k]; + } + s[j] /= Base(double(j)); + c[j] /= Base(double(j)); + } +} +/*! +Compute forward mode Taylor coefficient for result of op = SinOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sin(x) +\endverbatim +The auxillary result is +\verbatim + y = cos(x) +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails CppAD::local::forward_unary2_op_dir +*/ +template +void forward_sin_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(SinOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SinOp) == 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* s = taylor + i_z * num_taylor_per_var; + Base* c = s - num_taylor_per_var; + + + // rest of this routine is identical for the following cases: + // forward_sin_op, forward_cos_op, forward_sinh_op, forward_cosh_op + // (except that there is a sign difference for the hyperbolic case). + size_t m = (q-1) * r + 1; + for(size_t ell = 0; ell < r; ell++) + { s[m+ell] = Base(double(q)) * x[m + ell] * c[0]; + c[m+ell] = - Base(double(q)) * x[m + ell] * s[0]; + for(size_t k = 1; k < q; k++) + { s[m+ell] += Base(double(k)) * x[(k-1)*r+1+ell] * c[(q-k-1)*r+1+ell]; + c[m+ell] -= Base(double(k)) * x[(k-1)*r+1+ell] * s[(q-k-1)*r+1+ell]; + } + s[m+ell] /= Base(double(q)); + c[m+ell] /= Base(double(q)); + } +} + + +/*! +Compute zero order forward mode Taylor coefficient for result of op = SinOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sin(x) +\endverbatim +The auxillary result is +\verbatim + y = cos(x) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails CppAD::local::forward_unary2_op_0 +*/ +template +void forward_sin_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(SinOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SinOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); + + // Taylor coefficients corresponding to argument and result + Base* x = taylor + i_x * cap_order; + Base* s = taylor + i_z * cap_order; // called z in documentation + Base* c = s - cap_order; // called y in documentation + + s[0] = sin( x[0] ); + c[0] = cos( x[0] ); +} + +/*! +Compute reverse mode partial derivatives for result of op = SinOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sin(x) +\endverbatim +The auxillary result is +\verbatim + y = cos(x) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails CppAD::local::reverse_unary2_op +*/ + +template +void reverse_sin_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(SinOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SinOp) == 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* s = taylor + i_z * cap_order; // called z in doc + Base* ps = partial + i_z * nc_partial; + + // Taylor coefficients and partials corresponding to auxillary result + 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; + size_t k; + while(j) + { + ps[j] /= Base(double(j)); + pc[j] /= Base(double(j)); + for(k = 1; k <= j; k++) + { + px[k] += Base(double(k)) * azmul(ps[j], c[j-k]); + px[k] -= Base(double(k)) * azmul(pc[j], s[j-k]); + + ps[j-k] -= Base(double(k)) * azmul(pc[j], x[k]); + pc[j-k] += Base(double(k)) * azmul(ps[j], x[k]); + + } + --j; + } + px[0] += azmul(ps[0], c[0]); + px[0] -= azmul(pc[0], s[0]); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sparse_binary_op.hpp cppad-2019.02.00.0/include/cppad/local/sparse_binary_op.hpp --- cppad-2018.00.00.0/include/cppad/local/sparse_binary_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sparse_binary_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,525 @@ +# ifndef CPPAD_LOCAL_SPARSE_BINARY_OP_HPP +# define CPPAD_LOCAL_SPARSE_BINARY_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file sparse_binary_op.hpp +Forward and reverse mode sparsity patterns for 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, +or it has the form +\verbatim + z = x op y +\endverbatim +where op is a C++ binary unary operator and both x and y are variables. + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or sparse_list. + +\param i_z +variable index corresponding to the result for this operation; +i.e., z. + +\param arg + arg[0] +variable index corresponding to the left operand for this operator; +i.e., x. +\n +\n arg[1] +variable index corresponding to the right operand for this operator; +i.e., y. + +\param sparsity +\b Input: +The set with index arg[0] in sparsity +is the sparsity bit pattern for x. +This identifies which of the independent variables the variable x +depends on. +\n +\n +\b Input: +The set with index arg[1] in sparsity +is the sparsity bit pattern for y. +This identifies which of the independent variables the variable y +depends on. +\n +\n +\b Output: +The set with index i_z in sparsity +is the sparsity bit pattern for z. +This identifies which of the independent variables the variable z +depends on. + +\par Checked Assertions: +\li arg[0] < i_z +\li arg[1] < i_z +*/ + +template +void forward_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 ); + + sparsity.binary_union(i_z, size_t(arg[0]), size_t(arg[1]), sparsity); + + return; +} + +/*! +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, +or it has the form +\verbatim + z = x op y +\endverbatim +where op is a C++ bianry operator and x and y are variables. + +This routine is given the sparsity patterns +for a function G(z, y, x, ... ) +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 + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or sparse_list. + +\param i_z +variable index corresponding to the result for this operation; +i.e., z. + +\param arg + arg[0] +variable index corresponding to the left operand for this operator; +i.e., x. + +\n +\n arg[1] +variable index corresponding to the right operand for this operator; +i.e., y. + +\param sparsity +The set with index i_z in sparsity +is the sparsity pattern for z corresponding ot the function G. +\n +\n +The set with index arg[0] in 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 arg[1] in sparsity +is the sparsity pattern for y. +On input, it corresponds to the function G, +and on output it corresponds to H. +\n +\n + +\par Checked Assertions: +\li arg[0] < i_z +\li arg[1] < i_z +*/ +template +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 ); + + sparsity.binary_union( size_t(arg[0]), size_t(arg[0]), i_z, sparsity); + sparsity.binary_union( size_t(arg[1]), size_t(arg[1]), i_z, sparsity); + + return; +} +// --------------------------------------------------------------------------- +/*! +Reverse mode Hessian sparsity pattern for add and subtract operators. + +The C++ source code corresponding to a unary operation has the form +\verbatim + z = x op y +\endverbatim +where op is + or - and x, y are variables. + +\copydetails CppAD::local::reverse_sparse_hessian_binary_op +*/ +template +void reverse_sparse_hessian_addsub_op( + size_t i_z , + const addr_t* arg , + bool* jac_reverse , + const 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 ); + + // check for no effect + if( ! jac_reverse[i_z] ) + return; + + // propagate hessian sparsity from i_z to arg[0] and arg[1] + rev_hes_sparsity.binary_union( + size_t(arg[0]), size_t(arg[0]), i_z, rev_hes_sparsity + ); + rev_hes_sparsity.binary_union( + size_t(arg[1]), size_t(arg[1]), i_z, rev_hes_sparsity + ); + + jac_reverse[arg[0]] = true; + jac_reverse[arg[1]] = true; + + return; +} + +/*! +Reverse mode Hessian sparsity pattern for multiplication operator. + +The C++ source code corresponding to a unary operation has the form +\verbatim + z = x * y +\endverbatim +where x and y are variables. + +\copydetails CppAD::local::reverse_sparse_hessian_binary_op +*/ +template +void reverse_sparse_hessian_mul_op( + size_t i_z , + const addr_t* arg , + bool* jac_reverse , + const 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 ); + + // check for no effect + if( ! jac_reverse[i_z] ) + return; + + // progagate hessian sparsity from i_z to arg[0] and arg[1] + rev_hes_sparsity.binary_union( + size_t(arg[0]), size_t(arg[0]), i_z, rev_hes_sparsity + ); + rev_hes_sparsity.binary_union( + size_t(arg[1]), size_t(arg[1]), i_z, rev_hes_sparsity + ); + + // new hessian sparsity terms between i_z and arg[0], arg[1] + rev_hes_sparsity.binary_union( + size_t(arg[0]), size_t(arg[0]), size_t(arg[1]), for_jac_sparsity + ); + rev_hes_sparsity.binary_union( + size_t(arg[1]), size_t(arg[1]), size_t(arg[0]), for_jac_sparsity + ); + + jac_reverse[arg[0]] = true; + jac_reverse[arg[1]] = true; + return; +} + +/*! +Reverse mode Hessian sparsity pattern for division operator. + +The C++ source code corresponding to a unary operation has the form +\verbatim + z = x / y +\endverbatim +where x and y are variables. + +\copydetails CppAD::local::reverse_sparse_hessian_binary_op +*/ +template +void reverse_sparse_hessian_div_op( + size_t i_z , + const addr_t* arg , + bool* jac_reverse , + const 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 ); + + // check for no effect + if( ! jac_reverse[i_z] ) + return; + + // propagate hessian sparsity from i_z to arg[0] and arg[1] + rev_hes_sparsity.binary_union( + size_t(arg[0]), size_t(arg[0]), i_z, rev_hes_sparsity + ); + rev_hes_sparsity.binary_union( + size_t(arg[1]), size_t(arg[1]), i_z, rev_hes_sparsity + ); + + // new hessian sparsity terms between i_z and arg[0], arg[1] + rev_hes_sparsity.binary_union( + size_t(arg[0]), size_t(arg[0]), size_t(arg[1]), for_jac_sparsity + ); + rev_hes_sparsity.binary_union( + size_t(arg[1]), size_t(arg[1]), size_t(arg[0]), for_jac_sparsity + ); + rev_hes_sparsity.binary_union( + size_t(arg[1]), size_t(arg[1]), size_t(arg[1]), for_jac_sparsity + ); + + jac_reverse[arg[0]] = true; + jac_reverse[arg[1]] = true; + return; +} + +/*! +Reverse mode Hessian sparsity pattern for power function. + +The C++ source code corresponding to a unary operation has the form +\verbatim + z = pow(x, y) +\endverbatim +where x and y are variables. + +\copydetails CppAD::local::reverse_sparse_hessian_binary_op +*/ +template +void reverse_sparse_hessian_pow_op( + size_t i_z , + const addr_t* arg , + bool* jac_reverse , + const 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 ); + + // check for no effect + if( ! jac_reverse[i_z] ) + return; + + // propigate hessian sparsity from i_z to arg[0] and arg[1] + rev_hes_sparsity.binary_union( + size_t(arg[0]), size_t(arg[0]), i_z, rev_hes_sparsity + ); + rev_hes_sparsity.binary_union( + size_t(arg[1]), size_t(arg[1]), i_z, rev_hes_sparsity + ); + + // new hessian sparsity terms between i_z and arg[0], arg[1] + rev_hes_sparsity.binary_union( + size_t(arg[0]), size_t(arg[0]), size_t(arg[0]), for_jac_sparsity + ); + rev_hes_sparsity.binary_union( + size_t(arg[0]), size_t(arg[0]), size_t(arg[1]), for_jac_sparsity + ); + rev_hes_sparsity.binary_union( + size_t(arg[1]), size_t(arg[1]), size_t(arg[0]), for_jac_sparsity + ); + rev_hes_sparsity.binary_union( + size_t(arg[1]), size_t(arg[1]), size_t(arg[1]), for_jac_sparsity + ); + + // I cannot think of a case where this is necessary, but it including + // it makes it like the other cases. + jac_reverse[arg[0]] = true; + jac_reverse[arg[1]] = true; + return; +} +// --------------------------------------------------------------------------- +/*! +Forward mode Hessian sparsity pattern for multiplication operator. + +The C++ source code corresponding to this operation is +\verbatim + w(x) = v0(x) * v1(x) +\endverbatim + +\param arg +is the index of the argument vector for the multiplication operation; i.e., +arg[0], arg[1] are the left and right operands. + +\param for_jac_sparsity +for_jac_sparsity(arg[0]) constains the Jacobian sparsity for v0(x), +for_jac_sparsity(arg[1]) constains the Jacobian sparsity for v1(x). + +\param for_hes_sparsity +On input, for_hes_sparsity includes the Hessian sparsity for v0(x) +and v1(x); i.e., the sparsity can be a super set. +Upon return it includes the Hessian sparsity for w(x) +*/ +template +void forward_sparse_hessian_mul_op( + const addr_t* arg , + const Vector_set& for_jac_sparsity , + Vector_set& for_hes_sparsity ) +{ // -------------------------------------------------- + // set of independent variables that v0 depends on + typename Vector_set::const_iterator itr_0(for_jac_sparsity, size_t(arg[0])); + + // loop over dependent variables with non-zero partial + size_t i_x = *itr_0; + while( i_x < for_jac_sparsity.end() ) + { // N(i_x) = N(i_x) union L(v1) + for_hes_sparsity.binary_union(i_x, i_x, size_t(arg[1]), for_jac_sparsity); + i_x = *(++itr_0); + } + // -------------------------------------------------- + // set of independent variables that v1 depends on + typename Vector_set::const_iterator itr_1(for_jac_sparsity, size_t(arg[1])); + + // loop over dependent variables with non-zero partial + i_x = *itr_1; + while( i_x < for_jac_sparsity.end() ) + { // N(i_x) = N(i_x) union L(v0) + for_hes_sparsity.binary_union(i_x, i_x, size_t(arg[0]), for_jac_sparsity); + i_x = *(++itr_1); + } + return; +} +/*! +Forward mode Hessian sparsity pattern for division operator. + +The C++ source code corresponding to this operation is +\verbatim + w(x) = v0(x) / v1(x) +\endverbatim + +\param arg +is the index of the argument vector for the division operation; i.e., +arg[0], arg[1] are the left and right operands. + +\param for_jac_sparsity +for_jac_sparsity(arg[0]) constains the Jacobian sparsity for v0(x), +for_jac_sparsity(arg[1]) constains the Jacobian sparsity for v1(x). + +\param for_hes_sparsity +On input, for_hes_sparsity includes the Hessian sparsity for v0(x) +and v1(x); i.e., the sparsity can be a super set. +Upon return it includes the Hessian sparsity for w(x) +*/ +template +void forward_sparse_hessian_div_op( + const addr_t* arg , + const Vector_set& for_jac_sparsity , + Vector_set& for_hes_sparsity ) +{ // -------------------------------------------------- + // set of independent variables that v0 depends on + typename Vector_set::const_iterator itr_0(for_jac_sparsity, size_t(arg[0])); + + // loop over dependent variables with non-zero partial + size_t i_x = *itr_0; + while( i_x < for_jac_sparsity.end() ) + { // N(i_x) = N(i_x) union L(v1) + for_hes_sparsity.binary_union(i_x, i_x, size_t(arg[1]), for_jac_sparsity); + i_x = *(++itr_0); + } + // -------------------------------------------------- + // set of independent variables that v1 depends on + typename Vector_set::const_iterator itr_1(for_jac_sparsity, size_t(arg[1])); + + // loop over dependent variables with non-zero partial + i_x = *itr_1; + while( i_x < for_jac_sparsity.end() ) + { // N(i_x) = N(i_x) union L(v0) + for_hes_sparsity.binary_union(i_x, i_x, size_t(arg[0]), for_jac_sparsity); + // N(i_x) = N(i_x) union L(v1) + for_hes_sparsity.binary_union(i_x, i_x, size_t(arg[1]), for_jac_sparsity); + i_x = *(++itr_1); + } + return; +} +/*! +Forward mode Hessian sparsity pattern for power operator. + +The C++ source code corresponding to this operation is +\verbatim + w(x) = pow( v0(x) , v1(x) ) +\endverbatim + +\param arg +is the index of the argument vector for the power operation; i.e., +arg[0], arg[1] are the left and right operands. + +\param for_jac_sparsity +for_jac_sparsity(arg[0]) constains the Jacobian sparsity for v0(x), +for_jac_sparsity(arg[1]) constains the Jacobian sparsity for v1(x). + +\param for_hes_sparsity +On input, for_hes_sparsity includes the Hessian sparsity for v0(x) +and v1(x); i.e., the sparsity can be a super set. +Upon return it includes the Hessian sparsity for w(x) +*/ +template +void forward_sparse_hessian_pow_op( + const addr_t* arg , + const Vector_set& for_jac_sparsity , + Vector_set& for_hes_sparsity ) +{ // -------------------------------------------------- + // set of independent variables that v0 depends on + typename Vector_set::const_iterator itr_0(for_jac_sparsity, size_t(arg[0])); + + // loop over dependent variables with non-zero partial + size_t i_x = *itr_0; + while( i_x < for_jac_sparsity.end() ) + { // N(i_x) = N(i_x) union L(v0) + for_hes_sparsity.binary_union(i_x, i_x, size_t(arg[0]), for_jac_sparsity); + // N(i_x) = N(i_x) union L(v1) + for_hes_sparsity.binary_union(i_x, i_x, size_t(arg[1]), for_jac_sparsity); + i_x = *(++itr_0); + } + // -------------------------------------------------- + // set of independent variables that v1 depends on + typename Vector_set::const_iterator itr_1(for_jac_sparsity, size_t(arg[1])); + + // loop over dependent variables with non-zero partial + i_x = *itr_1; + while( i_x < for_jac_sparsity.end() ) + { // N(i_x) = N(i_x) union L(v0) + for_hes_sparsity.binary_union(i_x, i_x, size_t(arg[0]), for_jac_sparsity); + // N(i_x) = N(i_x) union L(v1) + for_hes_sparsity.binary_union(i_x, i_x, size_t(arg[1]), for_jac_sparsity); + i_x = *(++itr_1); + } + return; +} +// --------------------------------------------------------------------------- +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sparse_internal.hpp cppad-2019.02.00.0/include/cppad/local/sparse_internal.hpp --- cppad-2018.00.00.0/include/cppad/local/sparse_internal.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sparse_internal.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,453 @@ +# ifndef CPPAD_LOCAL_SPARSE_INTERNAL_HPP +# define CPPAD_LOCAL_SPARSE_INTERNAL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// necessary definitions +# include +# include +# include +# include + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file sparse_internal.hpp +Routines that enable code to be independent of which internal spasity pattern +is used. +*/ +// --------------------------------------------------------------------------- +/*! +Template structure used obtain the internal sparsity pattern type +form the corresponding element type. +The general form is not valid, must use a specialization. + +\tparam Element_type +type of an element in the sparsity structrue. + +\par internal_sparsity::pattern_type +is the type of the corresponding internal sparsity pattern. +*/ +template struct internal_sparsity; +/// Specilization for bool elements. +template <> +struct internal_sparsity +{ + typedef sparse_pack pattern_type; +}; +/// Specilization for std::set elements. +template <> +struct internal_sparsity< std::set > +{ + typedef sparse_list pattern_type; +}; +// --------------------------------------------------------------------------- +/*! +Update the internal sparsity pattern for a sub-set of rows + +\tparam SizeVector +The type used for index sparsity patterns. This is a simple vector +with elements of type size_t. + +\tparam InternalSparsitiy +The type used for intenal sparsity patterns. This can be either +sparse_pack or sparse_list. + +\param zero_empty +If this is true, the internal sparstity pattern corresponds to row zero +must be empty on input and will be emtpy output; i.e., any corresponding +values in pattern_in will be ignored. + +\param input_empty +If this is true, the initial sparsity pattern for row +internal_index[i] is empty for all i. +In this case, one is setting the sparsity patterns; i.e., +the output pattern in row internal_index[i] is the corresponding +entries in pattern. + +\param transpose +If this is true, pattern_in is transposed. + +\param internal_index +This specifies the sub-set of rows in internal_sparsity that we are updating. +If traspose is false (true), +this is the mapping from row (column) index in pattern_in to the corresponding +row index in the internal_pattern. + +\param internal_pattern +On input, the number of sets internal_pattern.n_set(), +and possible elements internal_pattern.end(), have been set. +If input_empty is true, and all of the sets +in internal_index are empty on input. +On output, the entries in pattern_in are added to internal_pattern. +To be specific, suppose transpose is false, and (i, j) is a possibly +non-zero entry in pattern_in, the entry (internal_index[i], j) is added +to internal_pattern. +On the other hand, if transpose is true, +the entry (internal_index[j], i) is added to internal_pattern. + +\param pattern_in +This is the sparsity pattern for variables, +or its transpose, depending on the value of transpose. +*/ +template +void set_internal_sparsity( + bool zero_empty , + bool input_empty , + bool transpose , + const pod_vector& internal_index , + InternalSparsity& internal_pattern , + const sparse_rc& pattern_in ) +{ + size_t nr = internal_index.size(); +# ifndef NDEBUG + size_t nc = internal_pattern.end(); + if( transpose ) + { CPPAD_ASSERT_UNKNOWN( pattern_in.nr() == nc ); + CPPAD_ASSERT_UNKNOWN( pattern_in.nc() == nr ); + } + else + { CPPAD_ASSERT_UNKNOWN( pattern_in.nr() == nr ); + CPPAD_ASSERT_UNKNOWN( pattern_in.nc() == nc ); + } + if( input_empty ) for(size_t i = 0; i < nr; i++) + { size_t i_var = internal_index[i]; + CPPAD_ASSERT_UNKNOWN( internal_pattern.number_elements(i_var) == 0 ); + } +# endif + const SizeVector& row( pattern_in.row() ); + const SizeVector& col( pattern_in.col() ); + size_t nnz = row.size(); + for(size_t k = 0; k < nnz; k++) + { size_t r = row[k]; + size_t c = col[k]; + if( transpose ) + std::swap(r, c); + // + size_t i_var = internal_index[r]; + CPPAD_ASSERT_UNKNOWN( i_var < internal_pattern.n_set() ); + CPPAD_ASSERT_UNKNOWN( c < nc ); + bool ignore = zero_empty && i_var == 0; + if( ! ignore ) + internal_pattern.post_element( internal_index[r], c ); + } + // process posts + for(size_t i = 0; i < nr; ++i) + internal_pattern.process_post( internal_index[i] ); +} +template +void set_internal_sparsity( + bool zero_empty , + bool input_empty , + bool transpose , + const pod_vector& internal_index , + InternalSparsity& internal_pattern , + const vectorBool& pattern_in ) +{ size_t nr = internal_index.size(); + size_t nc = internal_pattern.end(); +# ifndef NDEBUG + CPPAD_ASSERT_UNKNOWN( pattern_in.size() == nr * nc ); + if( input_empty ) for(size_t i = 0; i < nr; i++) + { size_t i_var = internal_index[i]; + CPPAD_ASSERT_UNKNOWN( internal_pattern.number_elements(i_var) == 0 ); + } +# endif + for(size_t i = 0; i < nr; i++) + { for(size_t j = 0; j < nc; j++) + { bool flag = pattern_in[i * nc + j]; + if( transpose ) + flag = pattern_in[j * nr + i]; + if( flag ) + { size_t i_var = internal_index[i]; + CPPAD_ASSERT_UNKNOWN( i_var < internal_pattern.n_set() ); + CPPAD_ASSERT_UNKNOWN( j < nc ); + bool ignore = zero_empty && i_var == 0; + if( ! ignore ) + internal_pattern.post_element( i_var, j); + } + } + } + // process posts + for(size_t i = 0; i < nr; ++i) + internal_pattern.process_post( internal_index[i] ); + return; +} +template +void set_internal_sparsity( + bool zero_empty , + bool input_empty , + bool transpose , + const pod_vector& internal_index , + InternalSparsity& internal_pattern , + const vector& pattern_in ) +{ size_t nr = internal_index.size(); + size_t nc = internal_pattern.end(); +# ifndef NDEBUG + CPPAD_ASSERT_UNKNOWN( pattern_in.size() == nr * nc ); + if( input_empty ) for(size_t i = 0; i < nr; i++) + { size_t i_var = internal_index[i]; + CPPAD_ASSERT_UNKNOWN( internal_pattern.number_elements(i_var) == 0 ); + } +# endif + for(size_t i = 0; i < nr; i++) + { for(size_t j = 0; j < nc; j++) + { bool flag = pattern_in[i * nc + j]; + if( transpose ) + flag = pattern_in[j * nr + i]; + if( flag ) + { size_t i_var = internal_index[i]; + CPPAD_ASSERT_UNKNOWN( i_var < internal_pattern.n_set() ); + CPPAD_ASSERT_UNKNOWN( j < nc ); + bool ignore = zero_empty && i_var == 0; + if( ! ignore ) + internal_pattern.post_element( i_var, j); + } + } + } + // process posts + for(size_t i = 0; i < nr; ++i) + internal_pattern.process_post( internal_index[i] ); + return; +} +template +void set_internal_sparsity( + bool zero_empty , + bool input_empty , + bool transpose , + const pod_vector& internal_index , + InternalSparsity& internal_pattern , + const vector< std::set >& pattern_in ) +{ size_t nr = internal_index.size(); + size_t nc = internal_pattern.end(); +# ifndef NDEBUG + if( input_empty ) for(size_t i = 0; i < nr; i++) + { size_t i_var = internal_index[i]; + CPPAD_ASSERT_UNKNOWN( internal_pattern.number_elements(i_var) == 0 ); + } +# endif + if( transpose ) + { CPPAD_ASSERT_UNKNOWN( pattern_in.size() == nc ); + for(size_t j = 0; j < nc; j++) + { std::set::const_iterator itr( pattern_in[j].begin() ); + while( itr != pattern_in[j].end() ) + { size_t i = *itr; + size_t i_var = internal_index[i]; + CPPAD_ASSERT_UNKNOWN( i_var < internal_pattern.n_set() ); + CPPAD_ASSERT_UNKNOWN( j < nc ); + bool ignore = zero_empty && i_var == 0; + if( ! ignore ) + internal_pattern.post_element( i_var, j); + ++itr; + } + } + } + else + { CPPAD_ASSERT_UNKNOWN( pattern_in.size() == nr ); + for(size_t i = 0; i < nr; i++) + { std::set::const_iterator itr( pattern_in[i].begin() ); + while( itr != pattern_in[i].end() ) + { size_t j = *itr; + size_t i_var = internal_index[i]; + CPPAD_ASSERT_UNKNOWN( i_var < internal_pattern.n_set() ); + CPPAD_ASSERT_UNKNOWN( j < nc ); + bool ignore = zero_empty && i_var == 0; + if( ! ignore ) + internal_pattern.post_element( i_var, j); + ++itr; + } + } + } + // process posts + for(size_t i = 0; i < nr; ++i) + internal_pattern.process_post( internal_index[i] ); + return; +} +// --------------------------------------------------------------------------- +/*! +Get sparsity pattern for a sub-set of variables + +\tparam SizeVector +The type used for index sparsity patterns. This is a simple vector +with elements of type size_t. + +\tparam InternalSparsitiy +The type used for intenal sparsity patterns. This can be either +sparse_pack or sparse_list. + +\param transpose +If this is true, pattern_out is transposed. + +\param internal_index +If transpose is false (true) +this is the mapping from row (column) an index in pattern_out +to the corresponding row index in internal_pattern. + +\param internal_pattern +This is the internal sparsity pattern. + +\param pattern_out +The input value of pattern_out does not matter. +Upon return it is an index sparsity pattern for each of the variables +in internal_index, or its transpose, depending on the value of transpose. +*/ +template +void get_internal_sparsity( + bool transpose , + const pod_vector& internal_index , + const InternalSparsity& internal_pattern , + sparse_rc& pattern_out ) +{ typedef typename InternalSparsity::const_iterator iterator; + // number variables + size_t nr = internal_index.size(); + // column size of interanl sparstiy pattern + size_t nc = internal_pattern.end(); + // determine nnz, the number of possibly non-zero index pairs + size_t nnz = 0; + for(size_t i = 0; i < nr; i++) + { CPPAD_ASSERT_UNKNOWN( internal_index[i] < internal_pattern.n_set() ); + iterator itr(internal_pattern, internal_index[i]); + size_t j = *itr; + while( j < nc ) + { ++nnz; + j = *(++itr); + } + } + // transposed + if( transpose ) + { pattern_out.resize(nc, nr, nnz); + // + size_t k = 0; + for(size_t i = 0; i < nr; i++) + { iterator itr(internal_pattern, internal_index[i]); + size_t j = *itr; + while( j < nc ) + { pattern_out.set(k++, j, i); + j = *(++itr); + } + } + return; + } + // not transposed + pattern_out.resize(nr, nc, nnz); + // + size_t k = 0; + for(size_t i = 0; i < nr; i++) + { iterator itr(internal_pattern, internal_index[i]); + size_t j = *itr; + while( j < nc ) + { pattern_out.set(k++, i, j); + j = *(++itr); + } + } + return; +} +template +void get_internal_sparsity( + bool transpose , + const pod_vector& internal_index , + const InternalSparsity& internal_pattern , + vectorBool& pattern_out ) +{ typedef typename InternalSparsity::const_iterator iterator; + // number variables + size_t nr = internal_index.size(); + // + // column size of interanl sparstiy pattern + size_t nc = internal_pattern.end(); + // + pattern_out.resize(nr * nc); + for(size_t ij = 0; ij < nr * nc; ij++) + pattern_out[ij] = false; + // + for(size_t i = 0; i < nr; i++) + { CPPAD_ASSERT_UNKNOWN( internal_index[i] < internal_pattern.n_set() ); + iterator itr(internal_pattern, internal_index[i]); + size_t j = *itr; + while( j < nc ) + { if( transpose ) + pattern_out[j * nr + i] = true; + else + pattern_out[i * nc + j] = true; + j = *(++itr); + } + } + return; +} +template +void get_internal_sparsity( + bool transpose , + const pod_vector& internal_index , + const InternalSparsity& internal_pattern , + vector& pattern_out ) +{ typedef typename InternalSparsity::const_iterator iterator; + // number variables + size_t nr = internal_index.size(); + // + // column size of interanl sparstiy pattern + size_t nc = internal_pattern.end(); + // + pattern_out.resize(nr * nc); + for(size_t ij = 0; ij < nr * nc; ij++) + pattern_out[ij] = false; + // + for(size_t i = 0; i < nr; i++) + { CPPAD_ASSERT_UNKNOWN( internal_index[i] < internal_pattern.n_set() ); + iterator itr(internal_pattern, internal_index[i]); + size_t j = *itr; + while( j < nc ) + { if( transpose ) + pattern_out[j * nr + i] = true; + else + pattern_out[i * nc + j] = true; + j = *(++itr); + } + } + return; +} +template +void get_internal_sparsity( + bool transpose , + const pod_vector& internal_index , + const InternalSparsity& internal_pattern , + vector< std::set >& pattern_out ) +{ typedef typename InternalSparsity::const_iterator iterator; + // number variables + size_t nr = internal_index.size(); + // + // column size of interanl sparstiy pattern + size_t nc = internal_pattern.end(); + // + if( transpose ) + pattern_out.resize(nc); + else + pattern_out.resize(nr); + for(size_t k = 0; k < pattern_out.size(); k++) + pattern_out[k].clear(); + // + for(size_t i = 0; i < nr; i++) + { CPPAD_ASSERT_UNKNOWN( internal_index[i] < internal_pattern.n_set() ); + iterator itr(internal_pattern, internal_index[i]); + size_t j = *itr; + while( j < nc ) + { if( transpose ) + pattern_out[j].insert(i); + else + pattern_out[i].insert(j); + j = *(++itr); + } + } + return; +} + + + +} } // END_CPPAD_LOCAL_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sparse_list.hpp cppad-2019.02.00.0/include/cppad/local/sparse_list.hpp --- cppad-2018.00.00.0/include/cppad/local/sparse_list.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sparse_list.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1485 @@ +# ifndef CPPAD_LOCAL_SPARSE_LIST_HPP +# define CPPAD_LOCAL_SPARSE_LIST_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include +# include + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file sparse_list.hpp +Vector of sets of positive integers stored as singly linked lists +with the element values strictly increasing. +*/ +class sparse_list_const_iterator; + +// ========================================================================= +/*! +Vector of sets of positive integers, each set stored as a singly +linked list. + +All the public members for this class are also in the +sparse_pack and sparse_vecsize classes. +This defines the CppAD vector_of_sets concept. +*/ +class sparse_list { + friend class sparse_list_const_iterator; +private: + // ----------------------------------------------------------------- + /// type used for each entry in a singly linked list. + struct pair_size_t { + /// For the first entry in each list, this is the reference count. + /// For the other entries in the list this is an element of the set. + size_t value; + + /// This is the data index of the next entry in the list. + /// If there are no more entries in the list, this value is zero. + /// (The first entry in data_ is not used.) + size_t next; + }; + friend bool is_pod(void); + // ----------------------------------------------------------------- + /// Possible elements in each set are 0, 1, ..., end_ - 1; + size_t end_; + + /// number of elements in data_ that are not being used. + size_t number_not_used_; + + /// list of elements of data_ that are not being used. + size_t data_not_used_; + + /// The data for all the singly linked lists. + pod_vector data_; + + /*! + Starting point for i-th set is start_[i]. + + \li + If the i-th set has no elements, start_[i] is zero. + Otherwise the conditions below hold. + + \li + data_[ start_[i] ].value is the reference count for this list. + This element is not in the list. + + \li + data_[ start_[i] ].next point the the first element in the list + and is not zero because there is at least one entry in this list. + + \li + For all lists, the last pair in the list has data_ index zero, + data_[0].value == end_ and data_[0].next = 0, and is not in the set. + */ + pod_vector start_; + + /*! + Vectors of elements that have not yet been added to corresponding sets. + + \li + If all the post_element calls for the i-th set have been added, + post_[i] is zero. Otherwise the conditions below hold. + + \li + data_[ post_[i] ].value is the first element that has been posted, + but not yet added, to set i. + + \li + For all lists, the last pair in the list has data_ index zero, + data_[0].value == end_ and data_[0].next = 0, and is not in the posted + elements. + */ + pod_vector post_; + + /*! + A temporary vector used by member functions that keeps its capacity. + */ + pod_vector temporary_; + + // ----------------------------------------------------------------- + /*! + Counts references to sets. + + \param i + is the index of the set that we are counting the references to. + + \return + if the set is empty, the return value is zero. + Otherwise it is the number of sets that share the same linked list + */ + size_t reference_count(size_t i) const + { // start data index + size_t start = start_[i]; + if( start == 0 ) + return 0; + // + // reference count + return data_[start].value; + } + // ----------------------------------------------------------------- + /*! + drop a set and its postings (no longer being used). + + \param i + is the index of the set that will be dropped. + + \par reference_count + if the set is non-empty, + the reference count data_[ start_[i] ] will be decremented. + + \par start_ + The value start_[i] is set to zero. + + \par post_ + the value post_[i] will be set to zero. + + \par data_not_used_ + the eleemmnts of data_ that are dropped are added to this list. + + \return + is the additional number of elements of data_ that are not used. + This is non-zero when the initial reference count is one. + */ + size_t drop(size_t i) + { // inialize count of addition elements not being used. + size_t number_drop = 0; + + // the elements in the post list will no longer be used + size_t post = post_[i]; + if( post != 0 ) + { // drop this posting + post_[i] = 0; + // + // count elements in this posting + ++number_drop; + size_t previous = post; + size_t next = data_[previous].next; + while( next != 0 ) + { previous = next; + next = data_[previous].next; + ++number_drop; + } + // + // add the posting elements to data_not_used_ + data_[previous].next = data_not_used_; + data_not_used_ = post; + } + + // check for empty set + size_t start = start_[i]; + if( start == 0 ) + return number_drop; + + // decrement reference counter + CPPAD_ASSERT_UNKNOWN( data_[start].value > 0 ); + data_[start].value--; + + // set this set to empty + start_[i] = 0; + + // If new reference count is positive, the list corresponding to + // start is still being used. + if( data_[start].value > 0 ) + return number_drop; + + // + // count elements representing this set + ++number_drop; + size_t previous = start; + size_t next = data_[previous].next; + while( next != 0 ) + { previous = next; + next = data_[previous].next; + ++number_drop; + } + // + // add representing this set to data_not_used_ + data_[previous].next = data_not_used_; + data_not_used_ = start; + // + return number_drop; + } + // ----------------------------------------------------------------- + /*! + get a new data_ element for use. + + \par number_not_used_ + if this is non-zero, it is decremented by one. + + \par data_not_used_ + if this list is non-empty, one element is removed from it. + + \return + is the index in data_ of the new element. + */ + size_t get_data_index(void) + { size_t index; + if( data_not_used_ > 0 ) + { CPPAD_ASSERT_UNKNOWN( number_not_used_ > 0 ); + --number_not_used_; + index = data_not_used_; + data_not_used_ = data_[index].next; + } + else + { index = data_.extend(1); + } + return index; + } + // ----------------------------------------------------------------- + /*! + Checks data structure + (effectively const, but modifies and restores values) + */ +# ifdef NDEBUG + void check_data_structure(void) + { return; } +# else + void check_data_structure(void) + { // number of sets + CPPAD_ASSERT_UNKNOWN( post_.size() == start_.size() ); + size_t n_set = start_.size(); + if( n_set == 0 ) + { CPPAD_ASSERT_UNKNOWN( end_ == 0 ); + CPPAD_ASSERT_UNKNOWN( number_not_used_ == 0 ); + CPPAD_ASSERT_UNKNOWN( data_not_used_ == 0 ); + CPPAD_ASSERT_UNKNOWN( data_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( start_.size() == 0 ); + return; + } + // check data index zero + CPPAD_ASSERT_UNKNOWN( data_[0].value == end_ ); + CPPAD_ASSERT_UNKNOWN( data_[0].next == 0 ); + // ----------------------------------------------------------- + // save the reference counters + pod_vector ref_count(n_set); + for(size_t i = 0; i < n_set; i++) + ref_count[i] = reference_count(i); + // ----------------------------------------------------------- + // number of entries in data used by sets and posts + size_t number_used_by_sets = 1; + // ----------------------------------------------------------- + // count the number of entries in data_ that are used by sets + for(size_t i = 0; i < n_set; i++) + { size_t start = start_[i]; + if( start > 0 ) + { // check structure for this non-empty set + size_t reference_count = data_[start].value; + size_t next = data_[start].next; + CPPAD_ASSERT_UNKNOWN( reference_count > 0 ); + CPPAD_ASSERT_UNKNOWN( next != 0 ); + CPPAD_ASSERT_UNKNOWN( data_[next].value < end_ ); + // + // decrement the reference counter + data_[start].value--; + // + // count the entries when find last reference + if( data_[start].value == 0 ) + { + // restore reference count + data_[start].value = ref_count[i]; + + // number of data entries used for this set + number_used_by_sets += number_elements(i) + 1; + /* + number of elements checks that value < end_ + each pair in the list except for the start pair + and the pair with index zero. + */ + } + } + } + // ------------------------------------------------------------------ + // count the number of entries in data_ that are used by posts + size_t number_used_by_posts = 0; + for(size_t i = 0; i < n_set; i++) + { size_t post = post_[i]; + if( post > 0 ) + { size_t value = data_[post].value; + size_t next = data_[post].next; + CPPAD_ASSERT_UNKNOWN( value < end_ ); + // + while( value < end_ ) + { ++number_used_by_posts; + value = data_[next].value; + next = data_[next].next; + } + } + } + // ------------------------------------------------------------------ + // count number of entries in data_not_used_ + size_t count = 0; + size_t next = data_not_used_; + while( next != 0 ) + { ++count; + next = data_[next].next; + } + CPPAD_ASSERT_UNKNOWN( number_not_used_ == count ); + // ------------------------------------------------------------------ + size_t number_used = number_used_by_sets + number_used_by_posts; + CPPAD_ASSERT_UNKNOWN( + number_used + number_not_used_ == data_.size() + ); + return; + } +# endif + // ----------------------------------------------------------------- + /*! + Check if one of two sets is a subset of the other set + + \param one_this + is the index in this sparse_sizevec object of the first set. + + \param two_other + is the index in other sparse_sizevec object of the second set. + + \param other + is the other sparse_sizevec object which may be the same as this object. + + \return + If zero, niether set is a subset of the other. + If one, then one is a subset of two and they are not equal. + If two, then two is a subset of one and they are not equal. + If three, then the sets are equal. + */ + size_t is_subset( + size_t one_this , + size_t two_other , + const sparse_list& other ) const + { + CPPAD_ASSERT_UNKNOWN( one_this < start_.size() ); + CPPAD_ASSERT_UNKNOWN( two_other < other.start_.size() ); + CPPAD_ASSERT_UNKNOWN( end_ == other.end_ ); + // + // start + size_t start_one = start_[one_this]; + size_t start_two = other.start_[two_other]; + // + if( start_one == 0 ) + { // set one is empty + if( start_two == 0 ) + { // set two is empty + return 3; + } + return 1; + } + if( start_two == 0 ) + { // set two is empty and one is not empty + return 2; + } + // + // next + size_t next_one = data_[start_one].next; + size_t next_two = other.data_[start_two].next; + // + // value + size_t value_one = data_[next_one].value; + size_t value_two = other.data_[next_two].value; + // + bool one_subset = true; + bool two_subset = true; + // + size_t value_union = std::min(value_one, value_two); + while( (one_subset | two_subset) & (value_union < end_) ) + { if( value_one > value_union ) + two_subset = false; + else + { next_one = data_[next_one].next; + value_one = data_[next_one].value; + } + if( value_two > value_union ) + one_subset = false; + else + { next_two = other.data_[next_two].next; + value_two = other.data_[next_two].value; + } + value_union = std::min(value_one, value_two); + } + if( one_subset ) + { if( two_subset ) + { // sets are equal + return 3; + } + // one is a subset of two + return 1; + } + if( two_subset ) + { // two is a subset of one + return 2; + } + // + // neither is a subset + return 0; + } + // ----------------------------------------------------------------- + /*! + Assign a set equal to the union of a set and a vector; + + \param target + is the index in this sparse_list object of the set being assinged. + + \param left + is the index in this sparse_list object of the + left operand for the union operation. + It is OK for target and left to be the same value. + + \param right + is a vector of size_t, sorted in accending order. + right operand for the union operation. + Elements can be repeated in right, but are not be repeated in the + resulting set. + All of the elements must have value less than end(); + */ + void binary_union( + size_t target , + size_t left , + const pod_vector& right ) + { CPPAD_ASSERT_UNKNOWN( post_[left] == 0 ); + // + CPPAD_ASSERT_UNKNOWN( target < start_.size() ); + CPPAD_ASSERT_UNKNOWN( left < start_.size() ); + + // get start indices before drop modifies modify start_ in case target + // and left are the same. + size_t start_left = start_[left]; + + // ------------------------------------------------------------------- + // Check if right is a subset of left so that we used reference count + // and not copies of identical sets. + // + // initialize index for left and right sets + size_t current_left = start_left; + size_t current_right = 0; + // + // initialize value_left + size_t value_left = end_; + if( current_left > 0 ) + { // advance from reference counter to data + current_left = data_[current_left].next; + CPPAD_ASSERT_UNKNOWN( current_left != 0 ) + // + value_left = data_[current_left].value; + CPPAD_ASSERT_UNKNOWN( value_left < end_); + } + // + // initialize value_right + size_t value_right = end_; + if( right.size() > 0 ) + value_right = right[current_right]; + // + bool subset = true; + while( subset & (value_right < end_) ) + { while( value_left < value_right ) + { // advance left + current_left = data_[current_left].next; + value_left = data_[current_left].value; + } + if( value_right < value_left ) + subset = false; + else + { // advance right + ++current_right; + if( current_right == right.size() ) + value_right = end_; + else + value_right = right[current_right]; + } + } + // + if( subset ) + { // target = left will use reference count for identical sets + assignment(target, left, *this); + return; + } + + // ------------------------------------------------------------------- + + // start new version of target + size_t start = get_data_index(); + data_[start].value = 1; // reference count + // + // previous index for new set + size_t previous_target = start; + // + // initialize index for left and right sets + current_left = start_left; + current_right = 0; + // + // initialize value_left + value_left = end_; + if( current_left > 0 ) + { // advance from reference counter to data + current_left = data_[current_left].next; + CPPAD_ASSERT_UNKNOWN( current_left != 0 ) + // + value_left = data_[current_left].value; + CPPAD_ASSERT_UNKNOWN( value_left < end_); + } + // + // initialize value_right + value_right = end_; + if( right.size() > 0 ) + value_right = right[current_right]; + // + // merge + while( (value_left < end_) | (value_right < end_) ) + { if( value_left == value_right) + { // advance left so left and right are no longer equal + current_left = data_[current_left].next; + value_left = data_[current_left].value; + CPPAD_ASSERT_UNKNOWN( value_right < value_left ); + } + // place to put new element + size_t current_target = get_data_index(); + data_[previous_target].next = current_target; + // + if( value_left < value_right ) + { // value_left case + CPPAD_ASSERT_UNKNOWN( value_left < end_ ); + data_[current_target].value = value_left; + // + // advance left + current_left = data_[current_left].next; + value_left = data_[current_left].value; + } + else + { CPPAD_ASSERT_UNKNOWN( value_right < value_left ) + // value_right case + CPPAD_ASSERT_UNKNOWN( value_right < end_); + data_[current_target].value = value_right; + // + // advance right (skip values equal to this one) + size_t previous_value = value_right; + while( value_right == previous_value ) + { ++current_right; + if( current_right == right.size() ) + value_right = end_; + else + { value_right = right[current_right]; + CPPAD_ASSERT_UNKNOWN( value_right < end_ ); + } + } + } + // done setting current target value + previous_target = current_target; + } + // make end of target list + data_[previous_target].next = 0; + + // adjust number_not_used_ + size_t number_drop = drop(target); + number_not_used_ += number_drop; + + // set the new start value for target + start_[target] = start; + + return; + } +// =========================================================================== +public: + /// declare a const iterator + typedef sparse_list_const_iterator const_iterator; + // ----------------------------------------------------------------- + /*! + Default constructor (no sets) + */ + sparse_list(void) : + end_(0) , + number_not_used_(0) , + data_not_used_(0) , + data_(0) , + start_(0) , + post_(0) + { } + // ----------------------------------------------------------------- + /// Destructor + ~sparse_list(void) + { check_data_structure(); + } + // ----------------------------------------------------------------- + /*! + Using copy constructor is a programing (not user) error + + \param v + vector of sets that we are attempting to make a copy of. + */ + sparse_list(const sparse_list& v) + { // Error: Probably a sparse_list argument has been passed by value + CPPAD_ASSERT_UNKNOWN(false); + } + // ----------------------------------------------------------------- + /*! + Assignement operator. + + \param other + this sparse_list with be set to a deep copy of other. + + \par vector_of_sets + This public member function is not yet part of + the vector_of_sets concept. + */ + void operator=(const sparse_list& other) + { end_ = other.end_; + number_not_used_ = other.number_not_used_; + data_not_used_ = other.data_not_used_; + data_ = other.data_; + start_ = other.start_; + post_ = other.post_; + } + // ----------------------------------------------------------------- + /*! + swap (used by move semantics version of ADFun assignment operator) + + \param other + this sparse_list with be swapped with other. + + \par vector_of_sets + This public member function is not yet part of + the vector_of_sets concept. + */ + void swap(sparse_list& other) + { // size_t objects + std::swap(end_ , other.end_); + std::swap(number_not_used_ , other.number_not_used_); + std::swap(data_not_used_ , other.data_not_used_); + + // pod_vectors + data_.swap( other.data_); + start_.swap( other.start_); + post_.swap( other.post_); + temporary_.swap( other.temporary_); + } + // ----------------------------------------------------------------- + /*! + Start a new vector of sets. + + \param n_set + is the number of sets in this vector of sets. + \li + If n_set is zero, any memory currently allocated for this object + is freed. + \li + If n_set is non-zero, a vector of n_set sets is created and all + the sets are initilaized as empty. + + \param end + is the maximum element plus one (the minimum element is 0). + If n_set is zero, end must also be zero. + */ + void resize(size_t n_set, size_t end) + { check_data_structure(); + + if( n_set == 0 ) + { CPPAD_ASSERT_UNKNOWN( end == 0 ); + // + // restore object to start after constructor + // (no memory allocated for this object) + data_.clear(); + start_.clear(); + post_.clear(); + number_not_used_ = 0; + data_not_used_ = 0; + end_ = 0; + // + return; + } + end_ = end; + // + start_.resize(n_set); + post_.resize(n_set); + // + for(size_t i = 0; i < n_set; i++) + { start_[i] = 0; + post_[i] = 0; + } + // + // last element, marks the end for all lists + data_.resize(1); + data_[0].value = end_; + data_[0].next = 0; + // + number_not_used_ = 0; + data_not_used_ = 0; + } + // ----------------------------------------------------------------- + /*! + Count number of elements in a set. + + \param i + is the index of the set we are counting the elements of. + + \par + number of elements checks that value < end_ for each element of the set. + */ + size_t number_elements(size_t i) const + { CPPAD_ASSERT_UNKNOWN( post_[i] == 0 ); + + // check if the set is empty + size_t start = start_[i]; + if( start == 0 ) + return 0; + + // initialize counter + size_t count = 0; + + // advance to the first element in the set + size_t next = data_[start].next; + while( next != 0 ) + { CPPAD_ASSERT_UNKNOWN( data_[next].value < end_ ); + count++; + next = data_[next].next; + } + CPPAD_ASSERT_UNKNOWN( count > 0 ); + return count; + } + /*! + Post an element for delayed addition to a set. + + \param i + is the index for this set in the vector of sets. + + \param element + is the value of the element that we are posting. + The same element may be posted multiple times. + + \par + It is faster to post multiple elements to set i and then call + process_post(i) then to add each element individually. + It is an error to call any member function, + that depends on the value of set i, + before processing the posts to set i. + */ + void post_element(size_t i, size_t element) + { CPPAD_ASSERT_UNKNOWN( i < start_.size() ); + CPPAD_ASSERT_UNKNOWN( element < end_ ); + + // put element at the front of this list + size_t next = post_[i]; + size_t post = get_data_index(); + post_[i] = post; + data_[post].value = element; + data_[post].next = next; + + return; + } + // ----------------------------------------------------------------- + /*! + process post entries for a specific set. + + \param i + index of the set for which we are processing the post entries. + + \par post_ + Upon call, post_[i] is location in data_ of the elements that get + added to the i-th set. Upon return, post_[i] is zero. + */ + void process_post(size_t i) + { // post + size_t post = post_[i]; + // + // check if there are no elements to process + if( post == 0 ) + return; + // + // check if there is only one element to process + size_t next = data_[post].next; + if( next == 0 ) + { // done with this posting + size_t value = data_[post].value; + post_[i] = 0; + data_[post].next = data_not_used_; + data_not_used_ = post; + ++number_not_used_; + // + add_element(i, value); + // + return; + } + // + // copy the elements that need to be processed into temporary + temporary_.resize(0); + size_t previous = post; + size_t value = data_[previous].value; + CPPAD_ASSERT_UNKNOWN( value < end_ ); + temporary_.push_back(value); + while( next != 0 ) + { previous = next; + value = data_[previous].value; + CPPAD_ASSERT_UNKNOWN( value < end_ ); + temporary_.push_back(value); + next = data_[previous].next; + } + size_t number_post = temporary_.size(); + // + // done with this posting + post_[i] = 0; + data_[previous].next = data_not_used_; + data_not_used_ = post; + number_not_used_ += number_post;; + // + // sort temporary_ + CPPAD_ASSERT_UNKNOWN( number_post > 1 ); + std::sort( temporary_.data(), temporary_.data() + number_post); + // + // add the elements to the set + binary_union(i, i, temporary_); + // + return; + } + // ----------------------------------------------------------------- + /*! + Add one element to a set. + + \param i + is the index for this set in the vector of sets. + + \param element + is the element we are adding to the set. + */ + void add_element(size_t i, size_t element) + { CPPAD_ASSERT_UNKNOWN( i < start_.size() ); + CPPAD_ASSERT_UNKNOWN( element < end_ ); + + // check for case where starting set is empty + size_t start = start_[i]; + if( start == 0 ) + { start = get_data_index(); + start_[i] = start; + data_[start].value = 1; // reference count + // + size_t next = get_data_index(); + data_[start].next = next; + // + data_[next].value = element; + data_[next].next = 0; + return; + } + // + // start of set with this index + size_t previous = start_[i]; + // + // first entry in this set + size_t next = data_[previous].next; + size_t value = data_[next].value; + // + // locate place to insert this element + while( value < element ) + { previous = next; + next = data_[next].next; + value = data_[next].value; + } + // + // check for case where element is in the set + if( value == element ) + return; + // + // + // check for case where this is the only reference to this set + CPPAD_ASSERT_UNKNOWN( element < value ); + if( data_[start].value == 1 ) + { size_t insert = get_data_index(); + data_[insert].next = next; + data_[insert].value = element; + data_[previous].next = insert; + // + return; + } + // + // must make a separate copy with new element inserted + CPPAD_ASSERT_UNKNOWN( data_[start].value > 1 ); + data_[start].value--; // reverence counter for old list + // + size_t start_new = get_data_index(); + data_[start_new].value = 1; // reference counter for new list + size_t previous_new = start_new; + // + // start of old set with this index + previous = start_[i]; + // + // first entry in old set + next = data_[previous].next; + value = data_[next].value; + // + // locate place to insert this element + while( value < element ) + { // copy to new list + size_t next_new = get_data_index(); + data_[previous_new].next = next_new; + data_[next_new].value = value; + previous_new = next_new; + // + // get next value + previous = next; + next = data_[next].next; + value = data_[next].value; + } + CPPAD_ASSERT_UNKNOWN( element < value ); + // + // insert the element + size_t next_new = get_data_index(); + data_[previous_new].next = next_new; + data_[next_new].value = element; + previous_new = next_new; + // + // copy rest of the old set + while( value < end_ ) + { // copy to new list + next_new = get_data_index(); + data_[previous_new].next = next_new; + data_[next_new].value = value; + previous_new = next_new; + // + // get next value + previous = next; + next = data_[next].next; + value = data_[next].value; + } + CPPAD_ASSERT_UNKNOWN( next == 0 ); + data_[previous_new].next = 0; + // + // hook up new list + start_[i] = start_new; + return; + } + // ----------------------------------------------------------------- + /*! + check an element is in a set. + + \param i + is the index for this set in the vector of sets. + + \param element + is the element we are checking to see if it is in the set. + */ + bool is_element(size_t i, size_t element) const + { CPPAD_ASSERT_UNKNOWN( post_[i] == 0 ); + CPPAD_ASSERT_UNKNOWN( element < end_ ); + // + size_t start = start_[i]; + if( start == 0 ) + return false; + // + size_t next = data_[start].next; + size_t value = data_[next].value; + while( value < element ) + { next = data_[next].next; + value = data_[next].value; + } + return element == value; + } + // ----------------------------------------------------------------- + /*! + Assign the empty set to one of the sets. + + \param target + is the index of the set we are setting to the empty set. + + \par number_not_used_ + increments this value by additional number of data_ elements that are + no longer being used. + */ + void clear(size_t target) + { CPPAD_ASSERT_UNKNOWN( target < start_.size() ); + + // adjust number_not_used_ + size_t number_drop = drop(target); + number_not_used_ += number_drop; + + return; + } + // ----------------------------------------------------------------- + /*! + Assign one set equal to another set. + + \param this_target + is the index in this sparse_list object of the set being assinged. + + \param other_source + is the index in the other sparse_list object of the + set that we are using as the value to assign to the target set. + + \param other + is the other sparse_list object (which may be the same as this + sparse_list object). This must have the same value for end_. + + \par number_not_used_ + increments this value by additional number of elements not being used. + */ + void assignment( + size_t this_target , + size_t other_source , + const sparse_list& other ) + { CPPAD_ASSERT_UNKNOWN( other.post_[ other_source ] == 0 ); + // + CPPAD_ASSERT_UNKNOWN( this_target < start_.size() ); + CPPAD_ASSERT_UNKNOWN( other_source < other.start_.size() ); + CPPAD_ASSERT_UNKNOWN( end_ == other.end_ ); + + // check if we are assigning a set to itself + if( (this == &other) & (this_target == other_source) ) + return; + + // set depending on cases below + size_t this_start; + + // If this and other are the same, use another reference to same list + size_t other_start = other.start_[other_source]; + if( this == &other ) + { this_start = other_start; + if( other_start != 0 ) + { data_[other_start].value++; // increment reference count + CPPAD_ASSERT_UNKNOWN( data_[other_start].value > 1 ); + } + } + else if( other_start == 0 ) + { this_start = 0; + } + else + { // make a copy of the other list in this sparse_list + this_start = get_data_index(); + size_t this_next = get_data_index(); + data_[this_start].value = 1; // reference count + data_[this_start].next = this_next; + // + size_t next = other.data_[other_start].next; + CPPAD_ASSERT_UNKNOWN( next != 0 ); + while( next != 0 ) + { data_[this_next].value = other.data_[next].value; + next = other.data_[next].next; + if( next == 0 ) + data_[this_next].next = 0; + else + { size_t tmp = get_data_index(); + data_[this_next].next = tmp; + this_next = tmp; + } + } + } + + // adjust number_not_used_ + size_t number_drop = drop(this_target); + number_not_used_ += number_drop; + + // set the new start value for this_target + start_[this_target] = this_start; + + return; + } + // ----------------------------------------------------------------- + /*! + Assign a set equal to the union of two other sets. + + \param this_target + is the index in this sparse_list object of the set being assinged. + + \param this_left + is the index in this sparse_list object of the + left operand for the union operation. + It is OK for this_target and this_left to be the same value. + + \param other_right + is the index in the other sparse_list object of the + right operand for the union operation. + It is OK for this_target and other_right to be the same value. + + \param other + is the other sparse_list object (which may be the same as this + sparse_list object). + */ + void binary_union( + size_t this_target , + size_t this_left , + size_t other_right , + const sparse_list& other ) + { CPPAD_ASSERT_UNKNOWN( post_[this_left] == 0 ); + CPPAD_ASSERT_UNKNOWN( other.post_[ other_right ] == 0 ); + // + CPPAD_ASSERT_UNKNOWN( this_target < start_.size() ); + CPPAD_ASSERT_UNKNOWN( this_left < start_.size() ); + CPPAD_ASSERT_UNKNOWN( other_right < other.start_.size() ); + CPPAD_ASSERT_UNKNOWN( end_ == other.end_ ); + + // check if one of the two operands is a subset of the the other + size_t subset = is_subset(this_left, other_right, other); + + // case where right is a subset of left or right and left are equal + if( subset == 2 || subset == 3 ) + { assignment(this_target, this_left, *this); + return; + } + // case where the left is a subset of right and they are not equal + if( subset == 1 ) + { assignment(this_target, other_right, other); + return; + } + // if niether case holds, then both left and right are non-empty + CPPAD_ASSERT_UNKNOWN( reference_count(this_left) > 0 ); + CPPAD_ASSERT_UNKNOWN( other.reference_count(other_right) > 0 ); + + // must get all the start indices before modify start_this + // (incase start_this is the same as start_left or start_right) + size_t start_left = start_[this_left]; + size_t start_right = other.start_[other_right]; + + // start the new list + size_t start = get_data_index(); + size_t next = start; + data_[start].value = 1; // reference count + + // next for left and right lists + size_t next_left = data_[start_left].next; + size_t next_right = other.data_[start_right].next; + + // value for left and right sets + size_t value_left = data_[next_left].value; + size_t value_right = other.data_[next_right].value; + + CPPAD_ASSERT_UNKNOWN( value_left < end_ && value_right < end_ ); + while( (value_left < end_) | (value_right < end_) ) + { if( value_left == value_right ) + { // advance right so left and right are no longer equal + next_right = other.data_[next_right].next; + value_right = other.data_[next_right].value; + } + if( value_left < value_right ) + { size_t tmp = get_data_index(); + data_[next].next = tmp; + next = tmp; + data_[next].value = value_left; + // advance left to its next element + next_left = data_[next_left].next; + value_left = data_[next_left].value; + } + else + { CPPAD_ASSERT_UNKNOWN( value_right < value_left ) + size_t tmp = get_data_index(); + data_[next].next = tmp; + next = tmp; + data_[next].value = value_right; + // advance right to its next element + next_right = other.data_[next_right].next; + value_right = other.data_[next_right].value; + } + } + data_[next].next = 0; + + // adjust number_not_used_ + size_t number_drop = drop(this_target); + number_not_used_ += number_drop; + + // set the new start value for this_target + start_[this_target] = start; + + return; + } + // ----------------------------------------------------------------- + /*! + Assign a set equal to the intersection of two other sets. + + \param this_target + is the index in this sparse_list object of the set being assinged. + + \param this_left + is the index in this sparse_list object of the + left operand for the intersection operation. + It is OK for this_target and this_left to be the same value. + + \param other_right + is the index in the other sparse_list object of the + right operand for the intersection operation. + It is OK for this_target and other_right to be the same value. + + \param other + is the other sparse_list object (which may be the same as this + sparse_list object). + */ + void binary_intersection( + size_t this_target , + size_t this_left , + size_t other_right , + const sparse_list& other ) + { CPPAD_ASSERT_UNKNOWN( post_[this_left] == 0 ); + CPPAD_ASSERT_UNKNOWN( other.post_[ other_right ] == 0 ); + // + CPPAD_ASSERT_UNKNOWN( this_target < start_.size() ); + CPPAD_ASSERT_UNKNOWN( this_left < start_.size() ); + CPPAD_ASSERT_UNKNOWN( other_right < other.start_.size() ); + CPPAD_ASSERT_UNKNOWN( end_ == other.end_ ); + // + // check if one of the two operands is a subset of the the other + size_t subset = is_subset(this_left, other_right, other); + + // case where left is a subset of right or left and right are equal + if( subset == 1 || subset == 3 ) + { assignment(this_target, this_left, *this); + return; + } + // case where the right is a subset of left and they are not equal + if( subset == 2 ) + { assignment(this_target, other_right, other); + return; + } + // if niether case holds, then both left and right are non-empty + CPPAD_ASSERT_UNKNOWN( reference_count(this_left) > 0 ); + CPPAD_ASSERT_UNKNOWN( other.reference_count(other_right) > 0 ); + + // must get all the start indices before modify start_this + // (incase start_this is the same as start_left or start_right) + size_t start_left = start_[this_left]; + size_t start_right = other.start_[other_right]; + + // start the new list as emptyh + size_t start = 0; + size_t next = start; + + // next for left and right lists + size_t next_left = data_[start_left].next; + size_t next_right = other.data_[start_right].next; + + // value for left and right sets + size_t value_left = data_[next_left].value; + size_t value_right = other.data_[next_right].value; + + CPPAD_ASSERT_UNKNOWN( value_left < end_ && value_right < end_ ); + while( (value_left < end_) & (value_right < end_) ) + { if( value_left == value_right ) + { if( start == 0 ) + { // this is the first element in the intersection + start = get_data_index(); + next = start; + start_[this_target] = start; + data_[start].value = 1; // reference count + CPPAD_ASSERT_UNKNOWN( start > 0 ); + } + size_t tmp = get_data_index(); + data_[next].next = tmp; + next = tmp; + data_[next].value = value_left; + // + // advance left + next_left = data_[next_left].next; + value_left = data_[next_left].value; + // + } + if( value_left > value_right ) + { // advance right + next_right = other.data_[next_right].next; + value_right = other.data_[next_right].value; + } + if( value_right > value_left ) + { // advance left + next_left = data_[next_left].next; + value_left = data_[next_left].value; + } + } + if( start != 0 ) + { CPPAD_ASSERT_UNKNOWN( next != 0 ); + data_[next].next = 0; + } + + // adjust number_not_used_ + size_t number_drop = drop(this_target); + number_not_used_ += number_drop; + + // set new start for this_target + start_[this_target] = start; + + return; + } + // ----------------------------------------------------------------- + /*! 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 start_.size(); } + // ----------------------------------------------------------------- + /*! 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_; } + // ----------------------------------------------------------------- + /*! 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 data_.capacity() * sizeof(pair_size_t); + } + /*! + Print the vector of sets (used for debugging) + */ + void print(void) const; +}; +// ========================================================================= +/*! +cons_iterator for one set of positive integers in a sparse_list object. + +All the public members for this class are also in the +sparse_pack_const_iterator and sparse_sizevec_const_iterator classes. +This defines the CppAD vector_of_sets iterator concept. +*/ +class sparse_list_const_iterator { +private: + /// type used by sparse_list to represent one element of the list + typedef sparse_list::pair_size_t pair_size_t; + + /// data for the entire vector of sets + const pod_vector& data_; + + /// Possible elements in a list are 0, 1, ..., end_ - 1; + const size_t end_; + + /// next element in the singly linked list + /// (next_pair_.value == end_ for past end of list) + pair_size_t next_pair_; +public: + /// construct a const_iterator for a list in a sparse_list object + sparse_list_const_iterator (const sparse_list& list, size_t i) + : + data_( list.data_ ) , + end_ ( list.end_ ) + { CPPAD_ASSERT_UNKNOWN( list.post_[i] == 0 ); + // + size_t start = list.start_[i]; + if( start == 0 ) + { next_pair_.next = 0; + next_pair_.value = end_; + } + else + { // value for this entry is reference count for list + CPPAD_ASSERT_UNKNOWN( data_[start].value > 0 ); + + // data index where list truely starts + size_t next = data_[start].next; + CPPAD_ASSERT_UNKNOWN( next != 0 ); + + // true first entry in the list + next_pair_ = data_[next]; + CPPAD_ASSERT_UNKNOWN( next_pair_.value < end_ ); + } + } + + /// advance to next element in this list + sparse_list_const_iterator& operator++(void) + { next_pair_ = data_[next_pair_.next]; + return *this; + } + + /// obtain value of this element of the set of positive integers + /// (end_ for no such element) + size_t operator*(void) + { return next_pair_.value; } +}; +// ========================================================================= +/*! +Print the vector of sets (used for debugging) +*/ +inline void sparse_list::print(void) const +{ std::cout << "sparse_list:\n"; + for(size_t i = 0; i < n_set(); i++) + { std::cout << "set[" << i << "] = {"; + const_iterator itr(*this, i); + while( *itr != end() ) + { std::cout << *itr; + if( *(++itr) != end() ) + std::cout << ","; + } + std::cout << "}\n"; + } + return; +} +// ========================================================================= +// 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 SetVector +is a simple vector with elements of type std::set. + +\param internal +The input value of sparisty does not matter. +Upon return it contains the same sparsity pattern as user +(or the transposed sparsity pattern). + +\param user +sparsity pattern that we are placing internal. + +\param n_set +number of sets (rows) in the internal sparsity pattern. + +\param end +end of set value (number of columns) in the interanl sparsity pattern. + +\param transpose +if true, the user sparsity patter is the transposed. + +\param error_msg +is the error message to display if some values in the user sparstiy +pattern are not valid. +*/ +template +void sparsity_user2internal( + sparse_list& internal , + const SetVector& user , + size_t n_set , + size_t end , + bool transpose , + const char* error_msg ) +{ +# ifndef NDEBUG + if( transpose ) + CPPAD_ASSERT_KNOWN( end == size_t( user.size() ), error_msg); + if( ! transpose ) + CPPAD_ASSERT_KNOWN( n_set == size_t( user.size() ), error_msg); +# endif + + // iterator for user set + std::set::const_iterator itr; + + // size of internal sparsity pattern + internal.resize(n_set, end); + + if( transpose ) + { // transposed pattern case + for(size_t j = 0; j < end; j++) + { itr = user[j].begin(); + while(itr != user[j].end()) + { size_t i = *itr++; + CPPAD_ASSERT_KNOWN(i < n_set, error_msg); + internal.add_element(i, j); + } + } + } + else + { for(size_t i = 0; i < n_set; i++) + { itr = user[i].begin(); + while(itr != user[i].end()) + { size_t j = *itr++; + CPPAD_ASSERT_KNOWN( j < end, error_msg); + internal.add_element(i, j); + } + } + } + return; +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sparse_pack.hpp cppad-2019.02.00.0/include/cppad/local/sparse_pack.hpp --- cppad-2018.00.00.0/include/cppad/local/sparse_pack.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sparse_pack.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,653 @@ +# ifndef CPPAD_LOCAL_SPARSE_PACK_HPP +# define CPPAD_LOCAL_SPARSE_PACK_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file sparse_pack.hpp +Vector of sets of positive integers stored as a packed array of bools. +*/ +class sparse_pack_const_iterator; + +// ========================================================================== +/*! +Vector of sets of postivie integers, each set stored as a packed boolean array. + +All the public members for this class are also in the +sparse_list and sparse_vecsize classes. +This defines the CppAD vector_of_sets concept. +*/ + +class sparse_pack { + friend class sparse_pack_const_iterator; +private: + /// Type used to pack elements (should be the same as corresponding + /// typedef in multiple_n_bit() in test_more/sparse_hacobian.cpp) + typedef size_t Pack; + /// Number of bits per Pack value + const size_t n_bit_; + /// 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 + /// (set by constructor and resize). + size_t end_; + /// Number of Pack values necessary to represent end_ bits. + /// (set by constructor and resize). + size_t n_pack_; + /// Data for all the sets. + pod_vector data_; +// ============================================================================ + /*! + Assign a set equal to the union of a set and a vector; + + \param target + is the index in this sparse_list object of the set being assinged. + + \param left + is the index in this sparse_list object of the + left operand for the union operation. + It is OK for target and left to be the same value. + + \param right + is a vector of size_t, sorted in accending order. + right operand for the union operation. + Elements can be repeated in right, but are not be repeated in the + resulting set. + All of the elements must have value less than end(); + */ + void binary_union( + size_t target , + size_t left , + const pod_vector& right ) + { + // initialize target = left + size_t t = target * n_pack_; + size_t l = left * n_pack_; + size_t j = n_pack_; + while(j--) + data_[t++] = data_[l++]; + + // add the elements in right + for(size_t i = 0; i < right.size(); ++i) + add_element(target, right[i]); + } +public: + /// declare a const iterator + typedef sparse_pack_const_iterator const_iterator; + // ----------------------------------------------------------------- + /*! + Default constructor (no sets) + */ + sparse_pack(void) : + n_bit_( std::numeric_limits::digits ), + n_set_(0) , + end_(0) , + n_pack_(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) : + n_bit_( std::numeric_limits::digits ) + { // Error: + // Probably a sparse_pack argument has been passed by value + CPPAD_ASSERT_UNKNOWN(0); + } + // ----------------------------------------------------------------- + /*! + Assignment operator. + + \param other + this sparse_pack will be set to a deep copyof other. + + */ + void operator=(const sparse_pack& other) + { CPPAD_ASSERT_UNKNOWN( n_bit_ == other.n_bit_); + n_set_ = other.n_set_; + end_ = other.end_; + n_pack_ = other.n_pack_; + data_ = other.data_; + } + // ----------------------------------------------------------------- + /*! + swap (used by move semantics version of ADFun assignment operator) + + \param other + this sparse_pack will be swapped with other. + */ + void swap(sparse_pack& other) + { // size_t objects + CPPAD_ASSERT_UNKNOWN( n_bit_ == other.n_bit_); + std::swap(n_set_ , other.n_set_); + std::swap(end_ , other.end_); + std::swap(n_pack_ , other.n_pack_); + // + // pod_vectors + data_.swap(other.data_); + } + // ----------------------------------------------------------------- + /*! + Destructor + */ + ~sparse_pack(void) + { } + // ----------------------------------------------------------------- + /*! + Change number of sets, set end, and initialize all sets as empty + + If n_set 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 + is the number of sets in this vector of sets. + + \param end + is the maximum element plus one. The minimum element is 0 and + end must be greater than zero (unless n_set is also zero). + If n_set is zero, end must also be zero. + */ + void resize(size_t n_set, size_t end) + { + n_set_ = n_set; + end_ = end; + if( n_set_ == 0 ) + { CPPAD_ASSERT_UNKNOWN( end == 0 ); + data_.clear(); + return; + } + // now start a new vector with empty sets + Pack zero(0); + + n_pack_ = ( 1 + (end_ - 1) / n_bit_ ); + size_t i = n_set_ * n_pack_; + + data_.resize(i); + while(i--) + data_[i] = zero; + } + // ----------------------------------------------------------------- + /*! + Count number of elements in a set. + + \param i + is the index in of the set we are counting the elements of. + */ + size_t number_elements(size_t i) const + { static Pack one(1); + CPPAD_ASSERT_UNKNOWN( i < n_set_ ); + size_t count = 0; + for(size_t k = 0; k < n_pack_; k++) + { Pack unit = data_[ i * n_pack_ + k ]; + Pack mask = one; + size_t n = std::min(n_bit_, end_ - n_bit_ * k); + for(size_t bit = 0; bit < n; bit++) + { CPPAD_ASSERT_UNKNOWN( mask > one || bit == 0); + if( mask & unit ) + ++count; + mask = mask << 1; + } + } + return count; + } + /*! + Post an element for delayed addition to a set. + + \param i + is the index for this set in the vector of sets. + + \param element + is the value of the element that we are posting. + The same element may be posted multiple times. + + \par + It is faster to post multiple elements to set i and then call + process_post(i) then to add each element individually. + It is an error to call any member function, + that depends on the value of set i, + before processing the posts to set i. + */ + void post_element(size_t i, size_t element) + { add_element(i, element); } + // ----------------------------------------------------------------- + /*! + process post entries for a specific set. + + \param i + index of the set for which we are processing the post entries. + + \par post_ + Upon call, post_[i] is location in data_ of the elements that get + added to the i-th set. Upon return, post_[i] is zero. + */ + void process_post(size_t i) + { return; } + // ----------------------------------------------------------------- + /*! + Add one element to a set. + + \param i + is the index for this set in the vector of sets. + + \param element + is the element we are adding to the set. + */ + void add_element(size_t i, size_t element) + { static Pack one(1); + CPPAD_ASSERT_UNKNOWN( i < n_set_ ); + CPPAD_ASSERT_UNKNOWN( element < end_ ); + size_t j = element / n_bit_; + size_t k = element - j * n_bit_; + Pack mask = one << k; + data_[ i * n_pack_ + j] |= mask; + } + // ----------------------------------------------------------------- + /*! + Is an element of a set. + + \param i + is the index for this set in the vector of sets. + + \param element + is the element we are checking to see if it is in the set. + */ + bool is_element(size_t i, size_t element) const + { static Pack one(1); + static Pack zero(0); + CPPAD_ASSERT_UNKNOWN( i < n_set_ ); + CPPAD_ASSERT_UNKNOWN( element < end_ ); + size_t j = element / n_bit_; + size_t k = element - j * n_bit_; + Pack mask = one << k; + return (data_[ i * n_pack_ + j] & mask) != zero; + } + // ----------------------------------------------------------------- + /*! + Assign the empty set to one of the sets. + + \param target + is the index of the set we are setting to the empty set. + + \par Checked Assertions + \li target < n_set_ + */ + void clear(size_t target) + { // value with all its bits set to false + static Pack zero(0); + CPPAD_ASSERT_UNKNOWN( target < n_set_ ); + size_t t = target * n_pack_; + + size_t j = n_pack_; + while(j--) + data_[t++] = zero; + } + // ----------------------------------------------------------------- + /*! + Assign one set equal to another set. + + \param this_target + is the index (in this sparse_pack object) of the set being assinged. + + \param other_value + is the index (in the other sparse_pack object) of the + that we are using as the value to assign to the target set. + + \param other + is the other sparse_pack object (which may be the same as this + sparse_pack object). + + \par Checked Assertions + \li this_target < n_set_ + \li other_value < other.n_set_ + \li n_pack_ == other.n_pack_ + */ + void assignment( + 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_ ); + CPPAD_ASSERT_UNKNOWN( n_pack_ == other.n_pack_ ); + size_t t = this_target * n_pack_; + size_t v = other_value * n_pack_; + + size_t j = n_pack_; + while(j--) + data_[t++] = other.data_[v++]; + } + // ----------------------------------------------------------------- + /*! + Assing a set equal to the union of two other sets. + + \param this_target + is the index (in this sparse_pack object) of the set being assinged. + + \param this_left + is the index (in this sparse_pack object) of the + left operand for the union operation. + It is OK for this_target and this_left to be the same value. + + \param other_right + is the index (in the other sparse_pack object) of the + right operand for the union operation. + It is OK for this_target and other_right to be the same value. + + \param other + is the other sparse_pack object (which may be the same as this + sparse_pack object). + + \par Checked Assertions + \li this_target < n_set_ + \li this_left < n_set_ + \li other_right < other.n_set_ + \li n_pack_ == other.n_pack_ + */ + void binary_union( + 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_ ); + CPPAD_ASSERT_UNKNOWN( other_right < other.n_set_ ); + CPPAD_ASSERT_UNKNOWN( n_pack_ == other.n_pack_ ); + + size_t t = this_target * n_pack_; + size_t l = this_left * n_pack_; + size_t r = other_right * n_pack_; + + size_t j = n_pack_; + while(j--) + data_[t++] = ( data_[l++] | other.data_[r++] ); + } + // ----------------------------------------------------------------- + /*! + Assing a set equal to the intersection of two other sets. + + \param this_target + is the index (in this sparse_pack object) of the set being assinged. + + \param this_left + is the index (in this sparse_pack object) of the + left operand for the intersection operation. + It is OK for this_target and this_left to be the same value. + + \param other_right + is the index (in the other sparse_pack object) of the + right operand for the intersection operation. + It is OK for this_target and other_right to be the same value. + + \param other + is the other sparse_pack object (which may be the same as this + sparse_pack object). + + \par Checked Assertions + \li this_target < n_set_ + \li this_left < n_set_ + \li other_right < other.n_set_ + \li n_pack_ == other.n_pack_ + */ + void binary_intersection( + 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_ ); + CPPAD_ASSERT_UNKNOWN( other_right < other.n_set_ ); + CPPAD_ASSERT_UNKNOWN( n_pack_ == other.n_pack_ ); + + size_t t = this_target * n_pack_; + size_t l = this_left * n_pack_; + size_t r = other_right * n_pack_; + + size_t j = n_pack_; + while(j--) + data_[t++] = ( data_[l++] & other.data_[r++] ); + } + // ----------------------------------------------------------------- + /*! + 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. + + \return + is the maximum element value plus one (the minimum element value is 0). + */ + size_t end(void) const + { return end_; } + // ----------------------------------------------------------------- + /*! + 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 data_.capacity() * sizeof(Pack); + } + /*! + Print the vector of sets (used for debugging) + */ + void print(void) const; +}; +// ========================================================================== +/*! +cons_iterator for one set of positive integers in a sparse_pack object. + +All the public members for this class are also in the +sparse_list_const_iterator and sparse_sizevec_const_iterator classes. +This defines the CppAD vector_of_sets iterator concept. +*/ +class sparse_pack_const_iterator { +private: + /// Type used to pack elements in sparse_pack + typedef sparse_pack::Pack Pack; + + /// data for the entire vector of sets + const pod_vector& data_; + + /// Number of bits per Pack value + const size_t n_bit_; + + /// Number of Pack values necessary to represent end_ bits. + const size_t n_pack_; + + /// Possible elements in each set are 0, 1, ..., end_ - 1; + const size_t end_; + + /// index of this set in the vector of sets; + const size_t set_index_; + + /// value of the next element in this set + /// (use end_ for no such element exists; i.e., past end of the set). + size_t next_element_; +public: + /// construct a const_iterator for a set in a sparse_pack object + sparse_pack_const_iterator (const sparse_pack& pack, size_t set_index) + : + data_ ( pack.data_ ) , + n_bit_ ( pack.n_bit_ ) , + n_pack_ ( pack.n_pack_ ) , + end_ ( pack.end_ ) , + set_index_ ( set_index ) + { static Pack one(1); + CPPAD_ASSERT_UNKNOWN( set_index_ < pack.n_set_ ); + // + next_element_ = 0; + if( next_element_ < end_ ) + { Pack check = data_[ set_index_ * n_pack_ + 0 ]; + if( check & one ) + return; + } + // element with index zero is not in this set of integers, + // advance to first element or end + ++(*this); + } + + /// advance to next element in this set + sparse_pack_const_iterator& operator++(void) + { static Pack one(1); + CPPAD_ASSERT_UNKNOWN( next_element_ <= end_ ); + if( next_element_ == end_ ) + return *this; + // + ++next_element_; + if( next_element_ == end_ ) + return *this; + // + // initialize packed data index + size_t j = next_element_ / n_bit_; + + // initialize bit index + size_t k = next_element_ - j * n_bit_; + + // initialize mask + size_t mask = one << k; + + // start search at this packed value + Pack check = data_[ set_index_ * n_pack_ + j ]; + // + while( true ) + { // check if this element is in the set + if( check & mask ) + return *this; + + // increment next element before checking this one + next_element_++; + if( next_element_ == end_ ) + return *this; + + // shift mask to left one bit so corresponds to next_element_ + // (use mask <<= 1. not one << k, so compiler knows value) + k++; + mask <<= 1; + CPPAD_ASSERT_UNKNOWN( k <= n_bit_ ); + + // check if we must go to next packed data index + if( k == n_bit_ ) + { // get next packed value + k = 0; + mask = one; + j++; + CPPAD_ASSERT_UNKNOWN( j < n_pack_ ); + check = data_[ set_index_ * n_pack_ + j ]; + } + } + // should never get here + CPPAD_ASSERT_UNKNOWN(false); + return *this; + } + + /// obtain value of this element of the set of positive integers + /// (end_ for no such element) + size_t operator*(void) const + { return next_element_; } +}; +// ========================================================================= +/*! +Print the vector of sets (used for debugging) +*/ +inline void sparse_pack::print(void) const +{ std::cout << "sparse_pack:\n"; + for(size_t i = 0; i < n_set(); i++) + { std::cout << "set[" << i << "] = {"; + const_iterator itr(*this, i); + while( *itr != end() ) + { std::cout << *itr; + if( *(++itr) != end() ) + std::cout << ","; + } + std::cout << "}\n"; + } + return; +} + +// ========================================================================== + +/*! +Copy a user vector of sets sparsity pattern to an internal sparse_pack object. + +\tparam SetVector +is a simple vector with elements of type std::set. + +\param internal +The input value of sparisty does not matter. +Upon return it contains the same sparsity pattern as user +(or the transposed sparsity pattern). + +\param user +sparsity pattern that we are placing internal. + +\param n_set +number of sets (rows) in the internal sparsity pattern. + +\param end +end of set value (number of columns) in the interanl sparsity pattern. + +\param transpose +if true, the user sparsity patter is the transposed. + +\param error_msg +is the error message to display if some values in the user sparstiy +pattern are not valid. +*/ +template +void sparsity_user2internal( + sparse_pack& internal , + const SetVector& user , + size_t n_set , + size_t end , + bool transpose , + const char* error_msg ) +{ CPPAD_ASSERT_KNOWN(size_t( user.size() ) == n_set * end, error_msg ); + + // size of internal sparsity pattern + internal.resize(n_set, end); + + if( transpose ) + { // transposed pattern case + for(size_t j = 0; j < end; j++) + { for(size_t i = 0; i < n_set; i++) + { if( user[ j * n_set + i ] ) + internal.add_element(i, j); + } + } + return; + } + else + { for(size_t i = 0; i < n_set; i++) + { for(size_t j = 0; j < end; j++) + { if( user[ i * end + j ] ) + internal.add_element(i, j); + } + } + } + return; +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sparse_sizevec.hpp cppad-2019.02.00.0/include/cppad/local/sparse_sizevec.hpp --- cppad-2018.00.00.0/include/cppad/local/sparse_sizevec.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sparse_sizevec.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1480 @@ +# ifndef CPPAD_LOCAL_SPARSE_SIZEVEC_HPP +# define CPPAD_LOCAL_SPARSE_SIZEVEC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include +# include + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file sparse_sizevec.hpp +Vector of sets of positive integers stored as size_t vector +with the element values strictly increasing. +*/ +class sparse_sizevec_const_iterator; + +// ========================================================================= +/*! +Vector of sets of positive integers, each set stored as a size_t vector. + +All the public members for this class are also in the +sparse_pack and sparse_list classes. +This defines the CppAD vector_of_sets concept. +*/ +class sparse_sizevec { + friend class sparse_sizevec_const_iterator; +private: + /// Possible elements in each set are 0, 1, ..., end_ - 1; + size_t end_; + + /// number of elements in data_ that have been allocated + /// and are no longer being used. + size_t data_not_used_; + + /// The data for all the singly linked lists. + pod_vector data_; + + /*! + Starting point for i-th set is start_[i]. + + \li + If the i-th set has no elements, start_[i] is zero. + Othersize the conditions below hold. + + \li + data_[ start_[i] ] is the reference count for this set + + \li + data_[ start_[i] + 1 ] is the first element in this set. + + \li + data_[ start_[i] + 2 ] is the first element in this set. + + \li + data_[ start_[i] + 2 + n ] = end_ where n is the number of + elements in this set + */ + pod_vector start_; + + /*! + Vectors of elements that have not yet been added to corresponding sets. + + \li + If all the post_element calls for the i-th set have been added, + post_[i] is zero. Otherwise the conditions below hold. + + \li + data_[ post_[i] ] the number of elements that have been posted, + but not yet added, to set i. + + \li + data_[ post_[i] + 1 ] is the capacity for holding elements + which is greater than or equal the number of elements. + + \li + data_[ post_[i] + 2 ] is the first element that has been posted, + but not yet added, to set i. + + \li + data_[ post_[i] + 1 + n] is the last element that has been posted, + but not yet added, to set i. + Here n is the number of elements that are posted and not yet added + to set i. + */ + pod_vector post_; + // ----------------------------------------------------------------- + /*! + Counts references to a set. + + \param i + is the index of the set that we are counting the references to. + + \return + if the set is empty, the return value is zero. + Otherwise it is the number of sets that share the same vector. + */ + size_t reference_count(size_t i) const + { // start data index + size_t start = start_[i]; + if( start == 0 ) + return 0; + // + // reference count + return data_[start]; + } + // ----------------------------------------------------------------- + /*! + drop a set. + + \param i + is the index of the set that will be dropped. + + \par reference_count + if the set is non-empty, + the reference count corresponding to index will be decremented. + + \return + is the number of elements of data_ that will be lost when the set is + dropped. This is non-zero when the initial reference count is one. + */ + size_t drop(size_t i) + { + // reference count + size_t ref_count = reference_count(i); + + // empty set case + if( ref_count == 0 ) + return 0; + + // start + size_t start = start_[i]; + CPPAD_ASSERT_UNKNOWN( data_[start] == ref_count ); + + // decrement reference counter + data_[start]--; + + // nothing lost unless new reference count is zero + if( ref_count != 1 ) + return 0; + + // number of elements in the set + size_t length = data_[start + 1]; + + // reference count, length, end marker, plus elements in set + size_t number_lost = 3 + length; + + // number_lost + return number_lost; + } + // ----------------------------------------------------------------- + /*! + Checks data structure + (effectively const, but modifies and restores values) + */ +# ifdef NDEBUG + void check_data_structure(void) + { return; } +# else + void check_data_structure(void) + { // number of sets + CPPAD_ASSERT_UNKNOWN( post_.size() == start_.size() ); + size_t n_set = start_.size(); + if( n_set == 0 ) + { CPPAD_ASSERT_UNKNOWN( end_ == 0 ); + CPPAD_ASSERT_UNKNOWN( data_not_used_ == 0 ); + CPPAD_ASSERT_UNKNOWN( data_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( start_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( post_.size() == 0 ); + return; + } + // ------------------------------------------------------------------ + // save the reference counters + pod_vector ref_count(n_set); + for(size_t i = 0; i < n_set; i++) + ref_count[i] = reference_count(i); + // ------------------------------------------------------------------ + + // ------------------------------------------------------------------ + // count the number of entries in data_ that are used by sets + size_t data_used_by_sets = 0; + for(size_t i = 0; i < n_set; i++) + { size_t start = start_[i]; + if( start > 0 ) + { // check structure for this non-empty set + size_t reference_count = data_[start + 0]; + size_t length = data_[start + 1]; + size_t first = data_[start + 2]; + size_t last = data_[start + 2 + length]; + CPPAD_ASSERT_UNKNOWN( reference_count > 0 ); + CPPAD_ASSERT_UNKNOWN( length > 0 ); + CPPAD_ASSERT_UNKNOWN( first < end_); + CPPAD_ASSERT_UNKNOWN( last == end_); + // + // decrement the reference counter + data_[start]--; + // + // count the entries when find last reference + if( data_[start] == 0 ) + { + // restore reference count + data_[start] = ref_count[i]; + + // number of data_ entries used for this set + data_used_by_sets += number_elements(i) + 3; + } + } + } + // ------------------------------------------------------------------ + // count the number of entries in data_ that are used by posts + size_t data_used_by_posts = 0; + for(size_t i = 0; i < n_set; i++) + { size_t post = post_[i]; + if( post > 0 ) + { CPPAD_ASSERT_UNKNOWN( data_[post] > 0 ); + CPPAD_ASSERT_UNKNOWN( data_[post + 1] > 0 ); + CPPAD_ASSERT_UNKNOWN( data_[post + 2] < end_ ); + // + size_t capacity = data_[post + 1]; + data_used_by_posts += capacity + 2; + } + } + // ------------------------------------------------------------------ + size_t data_used = data_used_by_sets + data_used_by_posts; + CPPAD_ASSERT_UNKNOWN( + data_used + data_not_used_ == data_.size() + ); + return; + } +# endif + // ----------------------------------------------------------------- + /*! + Check if one of two sets is a subset of the other set + + \param one_this + is the index in this sparse_sizevec object of the first set. + + \param two_other + is the index in other sparse_sizevec object of the second set. + + \param other + is the other sparse_sizevec object which may be the same as this object. + + \return + If zero, niether set is a subset of the other. + If one, then one is a subset of two and they are not equal. + If two, then two is a subset of one and they are not equal. + If three, then the sets are equal. + */ + size_t is_subset( + size_t one_this , + size_t two_other , + const sparse_sizevec& other ) const + { + CPPAD_ASSERT_UNKNOWN( one_this < start_.size() ); + CPPAD_ASSERT_UNKNOWN( two_other < other.start_.size() ); + CPPAD_ASSERT_UNKNOWN( end_ == other.end_ ); + // + // start + size_t start_one = start_[one_this]; + size_t start_two = other.start_[two_other]; + // + if( start_one == 0 ) + { // set one is empty + if( start_two == 0 ) + { // set two is empty + return 3; + } + // set one is empty and two is not empty + return 1; + } + if( start_two == 0 ) + { // set two is empty and one is not empty + return 2; + } + // + // data index + size_t index_one = start_one + 2; + size_t index_two = start_two + 2; + // + // value + size_t value_one = data_[index_one]; + size_t value_two = other.data_[index_two]; + // + bool one_subset = true; + bool two_subset = true; + // + size_t value_union = std::min(value_one, value_two); + while( (one_subset | two_subset) & (value_union < end_) ) + { // + if( value_one > value_union ) + two_subset = false; + else + { // value_one <= value_two and value_one < end_ + value_one = data_[++index_one]; + } + // + if( value_two > value_union ) + one_subset = false; + else + { // value_two <= value_one and value_two < end_ + value_two = other.data_[++index_two]; + } + value_union = std::min(value_one, value_two); + } + if( one_subset ) + { if( two_subset ) + { // sets are equal + return 3; + } + // one is a subset of two + return 1; + } + if( two_subset ) + { // two is a subset of one + return 2; + } + // + // neither is a subset + return 0; + } + // ----------------------------------------------------------------- + /*! + Does garbage collection when indicated. + + This routine should be called when more entries are not being used. + If a significant propotion are not being used, the data structure + will be compacted. + + The size of data_ should equal the number of entries used by the sets + plus the number of entries that are not being used data_not_used_. + Note that data_[0] never gets used. + */ + void collect_garbage(void) + { if( data_not_used_ < data_.size() / 2 + 100) + return; + check_data_structure(); + // + // number of sets including empty ones + size_t n_set = start_.size(); + // + // use temporary to hold copy of data_ and start_ + pod_vector data_tmp(1); // data_tmp[0] will not be used + pod_vector start_tmp(n_set); + // + for(size_t i = 0; i < n_set; i++) + { size_t start = start_[i]; + if( start == 0 ) + start_tmp[i] = 0; + else + { // check if this set has already been copied + if( data_[start] == 0 ) + { // starting address in data_tmp has been stored here + start_tmp[i] = data_[start + 1]; + } + else + { size_t tmp_start = data_tmp.extend(2); + start_tmp[i] = tmp_start; + data_tmp[tmp_start + 0] = data_[start + 0]; + data_tmp[tmp_start + 1] = data_[start + 1]; + // + for(size_t j = 2; data_[start + j] != end_; ++j) + data_tmp.push_back( data_[start + j] ); + data_tmp.push_back(end_); + // + // flag that indicates this set already copied + data_[start] = 0; + // + // store the starting address here + data_[start + 1] = tmp_start; + } + } + } + + // swap the tmp and old data vectors + start_.swap(start_tmp); + data_.swap(data_tmp); + + // all of the elements, except the first, are used + data_not_used_ = 1; + } + // ----------------------------------------------------------------- + /*! + Assign a set equal to the union of a set and a vector; + + \param target + is the index in this sparse_sizevec object of the set being assinged. + + \param left + is the index in this sparse_sizevec object of the + left operand for the union operation. + It is OK for target and left to be the same value. + + \param right + is a vector of size_t, sorted in accending order. + right operand for the union operation. + Elements can be repeated in right, but are not be repeated in the + resulting set. + All of the elements must have value less than end(); + */ + void binary_union( + size_t target , + size_t left , + const pod_vector& right ) + { CPPAD_ASSERT_UNKNOWN( post_[left] == 0 ); + // + CPPAD_ASSERT_UNKNOWN( target < start_.size() ); + CPPAD_ASSERT_UNKNOWN( left < start_.size() ); + + size_t start_left = start_[left]; + // ------------------------------------------------------------------- + // Check if right is a subset of left so that we used reference count + // and not make copies of identical sets. + // + // initialize index for left and right sets + size_t current_left = start_left; + size_t current_right = 0; + // + // initialize value_left + size_t value_left = end_; + if( current_left > 0 ) + { // advance from reference counter to data + current_left = current_left + 2; + value_left = data_[current_left]; + CPPAD_ASSERT_UNKNOWN( value_left < end_); + } + // + // initialize value_right + size_t value_right = end_; + if( right.size() > 0 ) + value_right = right[current_right]; + // + bool subset = true; + while( subset & (value_right < end_) ) + { while( value_left < value_right ) + { // advance left + value_left = data_[++current_left]; + } + if( value_right < value_left ) + subset = false; + else + { // advance right + ++current_right; + if( current_right == right.size() ) + value_right = end_; + else + value_right = right[current_right]; + } + } + // + if( subset ) + { // target = left will use reference count for identical sets + assignment(target, left, *this); + return; + } + + // ------------------------------------------------------------------- + // number of elements that will be deleted by removing old version + // of target + size_t number_lost = drop(target); + + // drop any posting for the target set + size_t post = post_[target]; + if( post > 0 ) + { CPPAD_ASSERT_UNKNOWN( target != left ); + size_t capacity = data_[post + 1]; + number_lost += capacity + 2; + post_[target] = 0; + } + // + // start new version of target + size_t start = data_.extend(2); + start_[target] = start; + data_[start] = 1; // reference count + // data_[start + 1] = length is not yet known + // + // initialize value_left + current_left = start_left; + value_left = end_; + if( current_left > 0 ) + { // advance from reference counter to data + current_left = current_left + 2; + value_left = data_[current_left]; + CPPAD_ASSERT_UNKNOWN( value_left < end_); + } + // + // initialize value_right + value_right = end_; + if( right.size() > 0 ) + value_right = right[current_right]; + // + // merge + while( (value_left < end_) | (value_right < end_) ) + { if( value_left == value_right) + { // advance left so left and right are no longer equal + ++current_left; + value_left = data_[current_left]; + CPPAD_ASSERT_UNKNOWN( value_right < value_left ); + } + // + if( value_left < value_right ) + { // value_left case + CPPAD_ASSERT_UNKNOWN( value_left < end_ ); + data_.push_back( value_left ); + // + // advance left + ++current_left; + value_left = data_[current_left]; + } + else + { CPPAD_ASSERT_UNKNOWN( value_right < value_left ) + // value_right case + CPPAD_ASSERT_UNKNOWN( value_right < end_); + data_.push_back( value_right ); + // + // advance right (skip values equal to this one) + size_t previous_value = value_right; + while( value_right == previous_value ) + { ++current_right; + if( current_right == right.size() ) + value_right = end_; + else + { value_right = right[current_right]; + CPPAD_ASSERT_UNKNOWN( value_right < end_ ); + } + } + } + } + // make end of target list + data_.push_back( end_ ); + // + // reference count, length, and end_ are not elements of set + CPPAD_ASSERT_UNKNOWN( data_.size() > start + 3 ); + size_t length = data_.size() - (start + 3); + data_[start + 1] = length; + // + + // adjust data_not_used_ + data_not_used_ += number_lost; + collect_garbage(); + } +public: + /// declare a const iterator + typedef sparse_sizevec_const_iterator const_iterator; + // ----------------------------------------------------------------- + /*! + Default constructor (no sets) + */ + sparse_sizevec(void) : + end_(0) , + data_not_used_(0) , + data_(0) , + start_(0) , + post_(0) + { } + // ----------------------------------------------------------------- + /// Destructor + ~sparse_sizevec(void) + { check_data_structure(); + } + // ----------------------------------------------------------------- + /*! + Using copy constructor is a programing (not user) error + + \param v + vector of sets that we are attempting to make a copy of. + */ + sparse_sizevec(const sparse_sizevec& v) + { // Error: Probably a sparse_sizevec argument has been passed by value + CPPAD_ASSERT_UNKNOWN(false); + } + // ----------------------------------------------------------------- + /*! + Assignement operator. + + \param other + this sparse_sizevec with be set to a deep copy of other. + */ + void operator=(const sparse_sizevec& other) + { end_ = other.end_; + data_not_used_ = other.data_not_used_; + data_ = other.data_; + start_ = other.start_; + post_ = other.post_; + } + // ----------------------------------------------------------------- + /*! + Start a new vector of sets. + + \param n_set + is the number of sets in this vector of sets. + \li + If n_set is zero, any memory currently allocated for this object + is freed. + \li + If n_set is non-zero, a vector of n_set sets is created and all + the sets are initilaized as empty. + + \param end + is the maximum element plus one (the minimum element is 0). + If n_set is zero, end must also be zero. + */ + void resize(size_t n_set, size_t end) + { check_data_structure(); + + if( n_set == 0 ) + { CPPAD_ASSERT_UNKNOWN(end == 0 ); + // + // restore object to start after constructor + // (no memory allocated for this object) + data_.clear(); + start_.clear(); + post_.clear(); + data_not_used_ = 0; + end_ = 0; + // + return; + } + end_ = end; + // + start_.resize(n_set); + post_.resize(n_set); + for(size_t i = 0; i < n_set; i++) + { start_[i] = 0; + post_[i] = 0; + } + // + data_.resize(1); // first element is not used + data_not_used_ = 1; + } + // ----------------------------------------------------------------- + /*! + Return number of elements in a set. + + \param i + is the index of the set we are checking number of the elements of. + */ + size_t number_elements(size_t i) const + { CPPAD_ASSERT_UNKNOWN( post_[i] == 0 ); + // + size_t start = start_[i]; + if( start == 0 ) + return 0; + return data_[start + 1]; + } + // ------------------------------------------------------------------ + /*! + Post an element for delayed addition to a set. + + \param i + is the index for this set in the vector of sets. + + \param element + is the value of the element that we are posting. + The same element may be posted multiple times. + + \par + It is faster to post multiple elements to set i and then call + process_post(i) then to add each element individually. + It is an error to call any member function, + that depends on the value of set i, + before processing the posts to set i. + */ + void post_element(size_t i, size_t element) + { CPPAD_ASSERT_UNKNOWN( i < start_.size() ); + CPPAD_ASSERT_UNKNOWN( element < end_ ); + + size_t post = post_[i]; + if( post == 0 ) + { // minimum capacity for an post vector + size_t min_capacity = 10; + size_t post_new = data_.extend(min_capacity + 2); + data_[post_new] = 1; // length + data_[post_new + 1] = min_capacity; // capacity + data_[post_new + 2] = element; + post_[i] = post_new; + } + else + { size_t length = data_[post]; + size_t capacity = data_[post + 1]; + if( length == capacity ) + { + size_t post_new = data_.extend( 2 * capacity ); + // + data_[post_new] = length + 1; + data_[post_new + 1] = 2 * capacity; + // + for(size_t j = 0; j < length; j++) + data_[post_new + 2 + j] = data_[post + 2 + j]; + data_[post_new + 2 + length] = element; + // + post_[i] = post_new; + size_t number_lost = length + 2; + data_not_used_ += number_lost; + } + else + { data_[post] = length + 1; + data_[post + 2 + length] = element; + } + } + + // check amount of data_not_used_ + collect_garbage(); + + return; + } + // ----------------------------------------------------------------- + /*! + process post entries for a specific set. + + \param i + index of the set for which we are processing the post entries. + + \par post_ + Upon call, post_[i] is location in data_ of the elements that get + added to the i-th set. Upon return, post_[i] is zero. + */ + void process_post(size_t i) + { // start + size_t start = start_[i]; + // post + size_t post = post_[i]; + // + // check if there are no elements to process + if( post == 0 ) + return; + // + // sort the elements that need to be processed + size_t length_post = data_[post]; + size_t capacity_post = data_[post + 1]; + size_t* first_post = data_.data() + post + 2; + size_t* last_post = first_post + length_post; + std::sort(first_post, last_post); + // ------------------------------------------------------------------- + // check if posted elements are a subset of set + // + // first element of the set + size_t current_set = start; + size_t value_set = end_; + if( start > 0 ) + { current_set = start + 2; + value_set = data_[current_set]; + } + // + // first element to post + size_t* current_post = first_post; + size_t value_post = *current_post; + // + bool subset = true; + while( subset & (value_post != end_) ) + { while( value_set < value_post ) + value_set = data_[++current_set]; + if( value_post < value_set ) + subset = false; + else + { ++current_post; + if( current_post == last_post ) + value_post = end_; + else + value_post = *current_post; + } + } + // + if( subset ) + { // drop the post_ elements + post_[i] = 0; + // + size_t number_lost = capacity_post + 2; + data_not_used_ += number_lost; + collect_garbage(); + // + // nothing else to do + return; + } + // ------------------------------------------------------------------- + // number of element that will be lost by removing old i-th set + size_t number_lost = drop(i); + + // start new version of i-th set + size_t start_new = data_.extend(2); + start_[i] = start_new; + data_[start_new] = 1; // reference count + // data[start_new + 1] = length_new is not yet known + // + // first element of the set + current_set = start; + value_set = end_; + if( start > 0 ) + { current_set = start + 2; + value_set = data_[current_set]; + } + // + // first element to process + current_post = first_post; + value_post = *current_post; + // + // merge + while( (value_set < end_) | (current_post != last_post ) ) + { if( value_set == value_post ) + { // advance left so left and right are no longer equal + ++current_set; + value_set = data_[current_set]; + CPPAD_ASSERT_UNKNOWN( value_post < value_set ); + } + // + if( value_set < value_post ) + { // add value_set + CPPAD_ASSERT_UNKNOWN( value_set < end_ ); + data_.push_back( value_set ); + // + // advance set + ++current_set; + value_set = data_[current_set]; + } + else + { CPPAD_ASSERT_UNKNOWN( value_post < value_set ) + // add value_post + CPPAD_ASSERT_UNKNOWN( value_post < end_); + data_.push_back( value_post ); + // + // advance post (skip values equal to this one) + size_t value_previous = value_post; + while( value_post == value_previous ) + { ++current_post; + if( current_post == last_post ) + value_post = end_; + else + value_post = *current_post; + } + } + } + // make end of target list + data_.push_back( end_ ); + // + // reference count, length, and end_ are not elements of set + CPPAD_ASSERT_UNKNOWN( data_.size() > start_new + 3 ); + size_t length_new = data_.size() - (start_new + 3); + data_[start_new + 1] = length_new; + CPPAD_ASSERT_UNKNOWN( data_[start_new + length_new + 2] == end_ ); + // + // drop to post_ elements for this set + post_[i] = 0; + // + number_lost += capacity_post + 2; + data_not_used_ += number_lost; + collect_garbage(); + // + return; + } + // ----------------------------------------------------------------- + /*! + Add one element to a set. + + \param i + is the index for this set in the vector of sets. + + \param element + is the element we are adding to the set. + */ + void add_element(size_t i, size_t element) + { CPPAD_ASSERT_UNKNOWN( i < start_.size() ); + CPPAD_ASSERT_UNKNOWN( element < end_ ); + + // check if element is already in the set + if( is_element(i, element) ) + return; + + // check for case where old set is empty + size_t start = start_[i]; + if( start == 0 ) + { start = data_.extend(4); + start_[i] = start; + data_[start] = 1; // reference count + data_[start + 1] = 1; // length + data_[start + 2] = element; // the element + data_[start + 3] = end_; // end marker + return; + } + // + size_t number_lost = drop(i); + // + // start of new set + size_t length = data_[start + 1]; + size_t new_start = data_.extend(2); + data_[new_start] = 1; // reference count + data_[new_start + 1] = length + 1; // new length + // + size_t count = 0; + size_t value = data_[start + 2 + count]; + // before new element + while( value < element) + { data_.push_back( value ); + ++count; + value = data_[start + 2 + count]; + } + CPPAD_ASSERT_UNKNOWN( element < value ) + // new element + data_.push_back( element ); + // after new element + while( value < end_ ) + { data_.push_back( value ); + ++count; + value = data_[start + 2 + count]; + } + data_.push_back( end_ ); + + // + // connect up new set + start_[i] = new_start; + + // adjust data_not_used_ + data_not_used_ += number_lost; + collect_garbage(); + // + return; + } + // ----------------------------------------------------------------- + /*! + Check if an element is in a set. + + \param i + is the index for this set in the vector of sets. + + \param element + is the element we are checking to see if it is in the set. + */ + bool is_element(size_t i, size_t element) const + { CPPAD_ASSERT_UNKNOWN( post_[i] == 0 ); + CPPAD_ASSERT_UNKNOWN( element < end_ ); + // + size_t start = start_[i]; + if( start == 0 ) + return false; + // + size_t length = data_[start + 1]; + const size_t* first = data_.data() + start + 2; + const size_t* last = first + length; + if( length < 10 ) + { bool result = false; + while( last > first ) + result |= *(--last) == element; + return result; + } + // + return std::binary_search(first, last, element); + } + // ----------------------------------------------------------------- + /*! + Assign the empty set to one of the sets. + + \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 data_ elements that are lost + (unlinked) by this operation. + */ + void clear(size_t target) + { + // number of data_ elements used for this set + size_t number_lost = drop( target ); + + // set target to empty set + start_[target] = 0; + + // drop the posted elements + if( post_[target] != 0 ) + { size_t capacity = post_[target + 1]; + number_lost += capacity + 2; + // + post_[target] = 0; + } + + // adjust data_not_used_ + data_not_used_ += number_lost; + collect_garbage(); + } + // ----------------------------------------------------------------- + /*! + Assign one set equal to another set. + + \param this_target + is the index in this sparse_sizevec object of the set being assinged. + + \param other_source + is the index in the other sparse_sizevec object of the + set that we are using as the value to assign to the target set. + + \param other + is the other sparse_sizevec object (which may be the same as this + sparse_sizevec object). This must have the same value for end_. + + \par data_not_used_ + increments this value by number of elements lost. + */ + void assignment( + size_t this_target , + size_t other_source , + const sparse_sizevec& other ) + { CPPAD_ASSERT_UNKNOWN( other.post_[ other_source ] == 0 ); + // + CPPAD_ASSERT_UNKNOWN( this_target < start_.size() ); + CPPAD_ASSERT_UNKNOWN( other_source < other.start_.size() ); + 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_lost = drop(this_target); + + // drop any posting for the target set + size_t post = post_[this_target]; + if( post > 0 ) + { // do not need to worry about target being same as source + size_t capacity = data_[post + 1]; + number_lost += capacity + 2; + post_[this_target] = 0; + } + + // If this and other are the same, use another reference to same list + size_t other_start = other.start_[other_source]; + if( this == &other ) + { CPPAD_ASSERT_UNKNOWN( this_target != other_source ); + start_[this_target] = other_start; + if( other_start != 0 ) + { // increment reference count + data_[other_start]++; + } + } + else if( other_start == 0 ) + { // the target list is empty + start_[this_target] = 0; + } + else + { // make a copy of the other list in this sparse_sizevec + size_t length = other.data_[other_start + 1]; + size_t this_start = data_.extend(2); + start_[this_target] = this_start; + data_[this_start] = 1; // reference count + data_[this_start + 1] = length; // length + for(size_t j = 0; j < length; ++j) + data_.push_back( other.data_[other_start + 2 + j] ); + data_.push_back(end_); + } + + // adjust data_not_used_ + data_not_used_ += number_lost; + collect_garbage(); + } + // ----------------------------------------------------------------- + /*! + Assign a set equal to the union of two other sets. + + \param this_target + is the index in this sparse_sizevec object of the set being assinged. + + \param this_left + is the index in this sparse_sizevec object of the + left operand for the union operation. + It is OK for this_target and this_left to be the same value. + + \param other_right + is the index in the other sparse_sizevec object of the + right operand for the union operation. + It is OK for this_target and other_right to be the same value. + + \param other + is the other sparse_sizevec object (which may be the same as this + sparse_sizevec object). + */ + void binary_union( + size_t this_target , + size_t this_left , + size_t other_right , + const sparse_sizevec& other ) + { CPPAD_ASSERT_UNKNOWN( post_[this_left] == 0 ); + CPPAD_ASSERT_UNKNOWN( other.post_[ other_right ] == 0 ); + // + CPPAD_ASSERT_UNKNOWN( this_target < start_.size() ); + CPPAD_ASSERT_UNKNOWN( this_left < start_.size() ); + CPPAD_ASSERT_UNKNOWN( other_right < other.start_.size() ); + CPPAD_ASSERT_UNKNOWN( end_ == other.end_ ); + + // check if one of the two operands is a subset of the the other + size_t subset = is_subset(this_left, other_right, other); + + // case where right is a subset of left or right and left are equal + if( subset == 2 || subset == 3 ) + { assignment(this_target, this_left, *this); + return; + } + // case where the left is a subset of right and they are not equal + if( subset == 1 ) + { assignment(this_target, other_right, other); + return; + } + // if niether case holds, then both left and right are non-empty + CPPAD_ASSERT_UNKNOWN( reference_count(this_left) > 0 ); + CPPAD_ASSERT_UNKNOWN( other.reference_count(other_right) > 0 ); + + // must get all the start indices before modify start_this + // (incase start_this is the same as start_left or start_right) + size_t start_left = start_[this_left]; + size_t start_right = other.start_[other_right]; + + // number of list elements that will be deleted by this operation + size_t number_lost = drop(this_target); + + // drop any posting for the target set + size_t post = post_[this_target]; + if( post > 0 ) + { // do not need to worry about target being same as left or right + size_t capacity = data_[post + 1]; + number_lost += capacity + 2; + post_[this_target] = 0; + } + + // start the new list + size_t start = data_.extend(2); + start_[this_target] = start; + data_[start] = 1; // reference count + // data_[start + 1] = length is not yet known + + // initilaize left + CPPAD_ASSERT_UNKNOWN( start_left != 0 ); + size_t current_left = start_left + 2; + size_t value_left = data_[current_left]; + CPPAD_ASSERT_UNKNOWN( value_left < end_ ); + + // initilaize right + CPPAD_ASSERT_UNKNOWN( start_right != 0 ); + size_t current_right = start_right + 2; + size_t value_right = other.data_[current_right]; + CPPAD_ASSERT_UNKNOWN( value_right < end_ ); + + + CPPAD_ASSERT_UNKNOWN( value_left < end_ && value_right < end_ ); + while( (value_left < end_) | (value_right < end_) ) + { if( value_left == value_right ) + { // advance right so left and right are no longer equal + ++current_right; + value_right = other.data_[current_right]; + } + if( value_left < value_right ) + { data_.push_back( value_left ); + // advance left to its next element + ++current_left; + value_left = data_[current_left]; + } + else + { CPPAD_ASSERT_UNKNOWN( value_right < value_left ) + data_.push_back( value_right ); + // advance right to its next element + ++current_right; + value_right = other.data_[current_right]; + } + } + // make end of target list + data_.push_back( end_ ); + // + // reference count, length, and end_ are not elements of set + CPPAD_ASSERT_UNKNOWN( data_.size() > start + 3 ); + size_t length = data_.size() - (start + 3); + data_[start + 1] = length; + + // adjust data_not_used_ + data_not_used_ += number_lost; + collect_garbage(); + } + // ----------------------------------------------------------------- + /*! + Assign a set equal to the intersection of two other sets. + + \param this_target + is the index in this sparse_sizevec object of the set being assinged. + + \param this_left + is the index in this sparse_sizevec object of the + left operand for the intersection operation. + It is OK for this_target and this_left to be the same value. + + \param other_right + is the index in the other sparse_sizevec object of the + right operand for the intersection operation. + It is OK for this_target and other_right to be the same value. + + \param other + is the other sparse_sizevec object (which may be the same as this + sparse_sizevec object). + */ + void binary_intersection( + size_t this_target , + size_t this_left , + size_t other_right , + const sparse_sizevec& other ) + { CPPAD_ASSERT_UNKNOWN( post_[this_left] == 0 ); + CPPAD_ASSERT_UNKNOWN( other.post_[ other_right ] == 0 ); + // + CPPAD_ASSERT_UNKNOWN( this_target < start_.size() ); + CPPAD_ASSERT_UNKNOWN( this_left < start_.size() ); + CPPAD_ASSERT_UNKNOWN( other_right < other.start_.size() ); + CPPAD_ASSERT_UNKNOWN( end_ == other.end_ ); + // + // check if one of the two operands is a subset of the the other + size_t subset = is_subset(this_left, other_right, other); + + // case where left is a subset of right or left and right are equal + if( subset == 1 || subset == 3 ) + { assignment(this_target, this_left, *this); + return; + } + // case where the right is a subset of left and they are not equal + if( subset == 2 ) + { assignment(this_target, other_right, other); + return; + } + // if niether case holds, then both left and right are non-empty + CPPAD_ASSERT_UNKNOWN( reference_count(this_left) > 0 ); + CPPAD_ASSERT_UNKNOWN( other.reference_count(other_right) > 0 ); + + // must get all the start indices before modify start_this + // (incase start_this is the same as start_left or start_right) + size_t start_left = start_[this_left]; + size_t start_right = other.start_[other_right]; + + + // number of list elements that will be deleted by this operation + size_t number_lost = drop(this_target); + + // drop any posting for the target set + size_t post = post_[this_target]; + if( post > 0 ) + { // do not need to worry about target being same as left or right + size_t capacity = data_[post + 1]; + number_lost += capacity + 2; + post_[this_target] = 0; + } + + // initialize intersection as empty + size_t start = 0; + start_[this_target] = start; + + // initilaize left + CPPAD_ASSERT_UNKNOWN( start_left != 0 ); + size_t current_left = start_left + 2; + size_t value_left = data_[current_left]; + CPPAD_ASSERT_UNKNOWN( value_left < end_ ); + + // initilaize right + CPPAD_ASSERT_UNKNOWN( start_right != 0 ); + size_t current_right = start_right + 2; + size_t value_right = other.data_[current_right]; + CPPAD_ASSERT_UNKNOWN( value_right < end_ ); + + while( (value_left < end_) & (value_right < end_) ) + { if( value_left == value_right ) + { if( start == 0 ) + { // this is the first element in the intersection + start = data_.extend(2); + start_[this_target] = start; + data_[start] = 1; // reference count + // data_[start + 1] = length is not yet known + } + data_.push_back( value_left ); + // + // advance left to its next element + ++current_left; + value_left = data_[current_left]; + } + if( value_left > value_right ) + { // advance right + ++current_right; + value_right = other.data_[current_right]; + } + if( value_right > value_left ) + { // advance left + ++current_left; + value_left = data_[current_left]; + } + } + if( start != 0 ) + { data_.push_back(end_); + CPPAD_ASSERT_UNKNOWN( data_.size() > start + 3 ); + size_t length = data_.size() - (start + 3); + data_[start + 1] = length; + } + + // adjust data_not_used_ + data_not_used_ += number_lost; + collect_garbage(); + } + // ----------------------------------------------------------------- + /*! 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 start_.size(); } + // ----------------------------------------------------------------- + /*! 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_; } + // ----------------------------------------------------------------- + /*! 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 data_.capacity() * sizeof(size_t); + } + /*! + Print the vector of sets (used for debugging) + */ + void print(void) const; +}; +// ========================================================================= +/*! +cons_iterator for one set of positive integers in a sparse_sizevec object. + +All the public member functions for this class are also in the +sparse_pack_const_iterator and sparse_list_const_iterator classes. +This defines the CppAD vector_of_sets iterator concept. +*/ +class sparse_sizevec_const_iterator { +private: + /// data for the entire vector of sets + const pod_vector& data_; + + /// Possible elements in a list are 0, 1, ..., end_ - 1; + const size_t end_; + + /// data index of next entry, zero for no more entries + size_t data_index_; +public: + /// construct a const_iterator for a set in a sparse_sizevec object + sparse_sizevec_const_iterator (const sparse_sizevec& vec_set, size_t i) + : + data_( vec_set.data_ ) , + end_ ( vec_set.end_ ) + { CPPAD_ASSERT_UNKNOWN( vec_set.post_[i] == 0 ); + // + size_t start = vec_set.start_[i]; + if( start == 0 ) + { data_index_ = 0; + } + else + { // data index of the first element in the set + data_index_ = start + 2; + CPPAD_ASSERT_UNKNOWN( data_[data_index_] < end_ ); + } + } + + /// advance to next element in this list + sparse_sizevec_const_iterator& operator++(void) + { if( data_index_ != 0 ) + { ++data_index_; + if( data_[data_index_] == end_ ) + data_index_ = 0; + } + return *this; + } + + /// obtain value of this element of the set of positive integers + /// (end_ for no such element) + size_t operator*(void) + { if( data_index_ == 0 ) + return end_; + return data_[data_index_]; + } +}; +// ========================================================================= +/*! +Print the vector of sets (used for debugging) +*/ +inline void sparse_sizevec::print(void) const +{ std::cout << "sparse_sizevec:\n"; + for(size_t i = 0; i < n_set(); i++) + { std::cout << "set[" << i << "] = {"; + const_iterator itr(*this, i); + while( *itr != end() ) + { std::cout << *itr; + if( *(++itr) != end() ) + std::cout << ","; + } + std::cout << "}\n"; + } + return; +} + +/*! +Copy a user vector of sets sparsity pattern to an internal sparse_sizevec object. + +\tparam SetVector +is a simple vector with elements of type std::set. + +\param internal +The input value of sparisty does not matter. +Upon return it contains the same sparsity pattern as user +(or the transposed sparsity pattern). + +\param user +sparsity pattern that we are placing internal. + +\param n_set +number of sets (rows) in the internal sparsity pattern. + +\param end +end of set value (number of columns) in the interanl sparsity pattern. + +\param transpose +if true, the user sparsity patter is the transposed. + +\param error_msg +is the error message to display if some values in the user sparstiy +pattern are not valid. +*/ +template +void sparsity_user2internal( + sparse_sizevec& internal , + const SetVector& user , + size_t n_set , + size_t end , + bool transpose , + const char* error_msg ) +{ +# ifndef NDEBUG + if( transpose ) + CPPAD_ASSERT_KNOWN( end == size_t( user.size() ), error_msg); + if( ! transpose ) + CPPAD_ASSERT_KNOWN( n_set == size_t( user.size() ), error_msg); +# endif + + // iterator for user set + std::set::const_iterator itr; + + // size of internal sparsity pattern + internal.resize(n_set, end); + + if( transpose ) + { // transposed pattern case + for(size_t j = 0; j < end; j++) + { itr = user[j].begin(); + while(itr != user[j].end()) + { size_t i = *itr++; + CPPAD_ASSERT_KNOWN(i < n_set, error_msg); + internal.add_element(i, j); + } + } + } + else + { for(size_t i = 0; i < n_set; i++) + { itr = user[i].begin(); + while(itr != user[i].end()) + { size_t j = *itr++; + CPPAD_ASSERT_KNOWN( j < end, error_msg); + internal.add_element(i, j); + } + } + } + return; +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sparse_unary_op.hpp cppad-2019.02.00.0/include/cppad/local/sparse_unary_op.hpp --- cppad-2018.00.00.0/include/cppad/local/sparse_unary_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sparse_unary_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,257 @@ +# ifndef CPPAD_LOCAL_SPARSE_UNARY_OP_HPP +# define CPPAD_LOCAL_SPARSE_UNARY_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file sparse_unary_op.hpp +Forward and reverse mode sparsity patterns for unary operators. +*/ + + +/*! +Forward mode Jacobian sparsity pattern for all unary operators. + +The C++ source code corresponding to a unary operation has the form +\verbatim + z = fun(x) +\endverbatim +where fun is a C++ unary function, or it has the form +\verbatim + z = x op q +\endverbatim +where op is a C++ binary unary operator and q is a parameter. + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or sparse_list. + +\param i_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; +i.e., x. + + +\param sparsity +\b Input: The set with index arg[0] in sparsity +is the sparsity bit pattern for x. +This identifies which of the independent variables the variable x +depends on. +\n +\n +\b Output: The set with index i_z in sparsity +is the sparsity bit pattern for z. +This identifies which of the independent variables the variable z +depends on. +\n + +\par Checked Assertions: +\li i_x < i_z +*/ + +template +void forward_sparse_jacobian_unary_op( + 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. + +The C++ source code corresponding to a unary operation has the form +\verbatim + z = fun(x) +\endverbatim +where fun is a C++ unary function, or it has the form +\verbatim + z = x op q +\endverbatim +where op is a C++ bianry operator and q is a parameter. + +This routine is given the sparsity patterns +for a function G(z, y, ... ) +and it uses them to compute the sparsity patterns for +\verbatim + H( x , w , u , ... ) = G[ z(x) , x , w , u , ... ] +\endverbatim + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or sparse_list. + + +\param i_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 i_z in sparsity +is the sparsity bit pattern for G with respect to the variable z. +\n +\b Input: +The set with index i_x in sparsity +is the sparsity bit pattern for G with respect to the variable x. +\n +\b Output: +The set with index i_x in sparsity +is the sparsity bit pattern for H with respect to the variable x. + +\par Checked Assertions: +\li i_x < i_z +*/ + +template +void reverse_sparse_jacobian_unary_op( + 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. + +The C++ source code corresponding to this operation is +\verbatim + z = fun(x) +\endverbatim +where fun is a linear functions; e.g. abs, or +\verbatim + z = x op q +\endverbatim +where op is a C++ binary operator and q is a parameter. + +\copydetails CppAD::local::reverse_sparse_hessian_unary_op +*/ +template +void reverse_sparse_hessian_linear_unary_op( + size_t i_z , + size_t i_x , + bool* rev_jacobian , + const Vector_set& for_jac_sparsity , + Vector_set& rev_hes_sparsity ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( i_x < i_z ); + + // check for no effect + if( ! rev_jacobian[i_z] ) + return; + + rev_hes_sparsity.binary_union(i_x, i_x, i_z, rev_hes_sparsity); + + rev_jacobian[i_x] = true; + return; +} + +/*! +Reverse mode Hessian sparsity pattern for non-linear unary operators. + +The C++ source code corresponding to this operation is +\verbatim + z = fun(x) +\endverbatim +where fun is a non-linear functions; e.g. sin. or +\verbatim + z = q / x +\endverbatim +where q is a parameter. + + +\copydetails CppAD::local::reverse_sparse_hessian_unary_op +*/ +template +void reverse_sparse_hessian_nonlinear_unary_op( + size_t i_z , + size_t i_x , + bool* rev_jacobian , + const Vector_set& for_jac_sparsity , + Vector_set& rev_hes_sparsity ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( i_x < i_z ); + + // check for no effect + if( ! rev_jacobian[i_z] ) + return; + + rev_hes_sparsity.binary_union(i_x, i_x, i_z, rev_hes_sparsity); + rev_hes_sparsity.binary_union(i_x, i_x, i_x, for_jac_sparsity); + + rev_jacobian[i_x] = true; + return; +} + +// --------------------------------------------------------------------------- +/*! +Forward mode Hessian sparsity pattern for non-linear unary operators. + +The C++ source code corresponding to this operation is +\verbatim + w(x) = fun( v(x) ) +\endverbatim +where fun is a non-linear function. + +\param i_v +is the index of the argument variable v + +\param for_jac_sparsity +for_jac_sparsity(i_v) constains the Jacobian sparsity for v(x). + +\param for_hes_sparsity +On input, for_hes_sparsity includes the Hessian sparsity for v(x); i.e., +the sparsity can be a super set. +Upon return it includes the Hessian sparsity for w(x) +*/ +template +void forward_sparse_hessian_nonlinear_unary_op( + size_t i_v , + const Vector_set& for_jac_sparsity , + Vector_set& for_hes_sparsity ) +{ + // set of independent variables that v depends on + typename Vector_set::const_iterator itr(for_jac_sparsity, i_v); + + // next independent variables that v depends on + size_t i_x = *itr; + + // loop over dependent variables with non-zero partial + while( i_x < for_jac_sparsity.end() ) + { // N(i_x) = N(i_x) union L(i_v) + for_hes_sparsity.binary_union(i_x, i_x, i_v, for_jac_sparsity); + i_x = *(++itr); + } + return; +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sqrt_op.hpp cppad-2019.02.00.0/include/cppad/local/sqrt_op.hpp --- cppad-2018.00.00.0/include/cppad/local/sqrt_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sqrt_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,193 @@ +# ifndef CPPAD_LOCAL_SQRT_OP_HPP +# define CPPAD_LOCAL_SQRT_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file sqrt_op.hpp +Forward and reverse mode calculations for z = sqrt(x). +*/ + + +/*! +Compute forward mode Taylor coefficient for result of op = SqrtOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sqrt(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op +*/ +template +void forward_sqrt_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(SqrtOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SqrtOp) == 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] = sqrt( x[0] ); + p++; + } + for(size_t j = p; j <= q; j++) + { + z[j] = Base(0.0); + for(k = 1; k < j; k++) + z[j] -= Base(double(k)) * z[k] * z[j-k]; + z[j] /= Base(double(j)); + z[j] += x[j] / Base(2.0); + z[j] /= z[0]; + } +} + +/*! +Multiple direction forward mode Taylor coefficient for op = SqrtOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sqrt(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op_dir +*/ +template +void forward_sqrt_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(SqrtOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SqrtOp) == 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* z = taylor + i_z * num_taylor_per_var; + Base* x = taylor + i_x * num_taylor_per_var; + + size_t m = (q-1) * r + 1; + for(size_t ell = 0; ell < r; ell++) + { z[m+ell] = Base(0.0); + for(size_t k = 1; k < q; k++) + z[m+ell] -= Base(double(k)) * z[(k-1)*r+1+ell] * z[(q-k-1)*r+1+ell]; + z[m+ell] /= Base(double(q)); + z[m+ell] += x[m+ell] / Base(2.0); + z[m+ell] /= z[0]; + } +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = SqrtOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sqrt(x) +\endverbatim + +\copydetails CppAD::local::forward_unary1_op_0 +*/ +template +void forward_sqrt_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(SqrtOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SqrtOp) == 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] = sqrt( x[0] ); +} +/*! +Compute reverse mode partial derivatives for result of op = SqrtOp. + +The C++ source code corresponding to this operation is +\verbatim + z = sqrt(x) +\endverbatim + +\copydetails CppAD::local::reverse_unary1_op +*/ + +template +void reverse_sqrt_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(SqrtOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SqrtOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Taylor coefficients and partials corresponding to argument + 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_z0 = Base(1.0) / z[0]; + + // number of indices to access + size_t j = d; + size_t k; + while(j) + { + + // scale partial w.r.t. z[j] + pz[j] = azmul(pz[j], inv_z0); + + pz[0] -= azmul(pz[j], z[j]); + px[j] += pz[j] / Base(2.0); + for(k = 1; k < j; k++) + pz[k] -= azmul(pz[j], z[j-k]); + --j; + } + px[0] += azmul(pz[0], inv_z0) / Base(2.0); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/std_set.hpp cppad-2019.02.00.0/include/cppad/local/std_set.hpp --- cppad-2018.00.00.0/include/cppad/local/std_set.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/std_set.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,52 @@ +# ifndef CPPAD_LOCAL_STD_SET_HPP +# define CPPAD_LOCAL_STD_SET_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include + +// needed before one can use CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL +# include + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file std_set.hpp +Two constant standard sets (currently used for concept checking). +*/ + +/*! +A standard set with one element. +*/ +template +const std::set& one_element_std_set(void) +{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + static std::set one; + if( one.empty() ) + one.insert(1); + return one; +} +/*! +A standard set with a two elements. +*/ +template +const std::set& two_element_std_set(void) +{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + static std::set two; + if( two.empty() ) + { two.insert(1); + two.insert(2); + } + return two; +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/store_op.hpp cppad-2019.02.00.0/include/cppad/local/store_op.hpp --- cppad-2018.00.00.0/include/cppad/local/store_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/store_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,497 @@ +# ifndef CPPAD_LOCAL_STORE_OP_HPP +# define CPPAD_LOCAL_STORE_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\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 +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. +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 +using AD and computations by this routine are done using type Base. + +\param i_z +is the index corresponding to the previous variable on the tape +(only used for error checking). + +\param arg +\n +arg[0] +\n +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), +i_vec is defined by +\verbatim + i_vec = arg[1] +\endverbatim +If this is a StvpOp or StvvOp operation (if x is a variable), +i_vec is defined by +\verbatim + i_vec = floor( taylor[ size_t(arg[1]) * cap_order + 0 ] ) +\endverbatim +where floor(c) is the greatest integer less that or equal c. +\n +\n +arg[2] +\n +index corresponding to the third operand for this operator; +i.e. the index corresponding to y. + +\param num_par +is the total number of parameters on the tape +(only used for error checking). + +\param cap_order +number of columns in the matrix containing the Taylor coefficients. + +\param taylor +In StvpOp and StvvOp cases, +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), +isvar_by_ind[ arg[0] + i_vec ] is set to true. +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 +index_by_ind[ arg[0] - 1 ] +is the number of elements in the user vector containing this element. +The value index_by_ind[ arg[0] + i_vec] +is set equal to arg[2]. + +\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, +the corresponding vector index and it does not change. +In this case, the error above should be detected during tape recording. + +\par Checked Assertions +\li NumArg(op) == 3 +\li NumRes(op) == 0 +\li 0 < arg[0] +\li if y is a parameter, arg[2] < num_par +*/ +template +void forward_store_op_0( + size_t i_z , + const addr_t* arg , + size_t num_par , + size_t cap_order , + Base* taylor , + bool* isvar_by_ind , + size_t* index_by_ind ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} +/*! +Shared documnetation for sparsity operations corresponding to +op = StpvOp or StvvOp (not called). + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or sparse_list. + +\param op +is the code corresponding to this operator; +i.e., StpvOp, StvpOp, or StvvOp. + +\param arg +\n + arg[0] +is the offset corresponding to this VecAD vector in the combined array. +\n +\n + arg[2] +\n +The set with index arg[2] in var_sparsity +is the sparsity pattern corresponding to y. +(Note that arg[2] > 0 because y is a variable.) + +\param num_combined +is the total number of elements in the VecAD address array. + +\param combined + combined [ arg[0] - 1 ] +is the index of the set in vecad_sparsity corresponding +to the sparsity pattern for the vector v. +We use the notation i_v below which is defined by +\verbatim + i_v = combined[ arg[0] - 1 ] +\endverbatim + +\param var_sparsity +The set with index arg[2] in 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 i_v in 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 < arg[0] +\li arg[0] < num_combined +\li arg[2] < var_sparsity.n_set() +\li i_v < vecad_sparsity.n_set() +*/ +template +void sparse_store_op( + OpCode op , + const addr_t* arg , + size_t num_combined , + const size_t* combined , + Vector_set& var_sparsity , + Vector_set& vecad_sparsity ) +{ + // This routine is only for documentaiton, it should not be used + CPPAD_ASSERT_UNKNOWN( false ); +} + + +/*! +Zero order forward mode implementation of op = StppOp. + +\copydetails CppAD::local::forward_store_op_0 +*/ +template +void forward_store_pp_op_0( + size_t i_z , + const addr_t* arg , + size_t num_par , + size_t cap_order , + Base* taylor , + bool* isvar_by_ind , + size_t* index_by_ind ) +{ addr_t i_vec = arg[1]; + + // 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( size_t(i_vec) < index_by_ind[ arg[0] - 1 ] ); + + CPPAD_ASSERT_UNKNOWN( NumArg(StppOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(StppOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); + + isvar_by_ind[ arg[0] + i_vec ] = false; + index_by_ind[ arg[0] + i_vec ] = size_t(arg[2]); +} + +/*! +Zero order forward mode implementation of op = StpvOp. + +\copydetails CppAD::local::forward_store_op_0 +*/ +template +void forward_store_pv_op_0( + size_t i_z , + const addr_t* arg , + size_t num_par , + size_t cap_order , + Base* taylor , + bool* isvar_by_ind , + size_t* index_by_ind ) +{ addr_t i_vec = arg[1]; + + // 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( size_t(i_vec) < index_by_ind[ arg[0] - 1 ] ); + + CPPAD_ASSERT_UNKNOWN( NumArg(StpvOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(StpvOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + + isvar_by_ind[ arg[0] + i_vec ] = true; + index_by_ind[ arg[0] + i_vec ] = size_t(arg[2]); +} + +/*! +Zero order forward mode implementation of op = StvpOp. + +\copydetails CppAD::local::forward_store_op_0 +*/ +template +void forward_store_vp_op_0( + size_t i_z , + const addr_t* arg , + size_t num_par , + size_t cap_order , + Base* taylor , + bool* isvar_by_ind , + size_t* index_by_ind ) +{ + addr_t i_vec = addr_t(Integer( taylor[ size_t(arg[1]) * cap_order + 0 ] )); + CPPAD_ASSERT_KNOWN( + size_t(i_vec) < index_by_ind[ arg[0] - 1 ] , + "VecAD: index during zero order forward sweep is out of range" + ); + + CPPAD_ASSERT_UNKNOWN( NumArg(StvpOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(StvpOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); + + isvar_by_ind[ arg[0] + i_vec ] = false; + index_by_ind[ arg[0] + i_vec ] = size_t(arg[2]); +} + +/*! +Zero order forward mode implementation of op = StvvOp. + +\copydetails CppAD::local::forward_store_op_0 +*/ +template +void forward_store_vv_op_0( + size_t i_z , + const addr_t* arg , + size_t num_par , + size_t cap_order , + Base* taylor , + bool* isvar_by_ind , + size_t* index_by_ind ) +{ + addr_t i_vec = addr_t(Integer( taylor[ size_t(arg[1]) * cap_order + 0 ] )); + CPPAD_ASSERT_KNOWN( + size_t(i_vec) < index_by_ind[ arg[0] - 1 ] , + "VecAD: index during zero order forward sweep is out of range" + ); + + CPPAD_ASSERT_UNKNOWN( NumArg(StvpOp) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(StvpOp) == 0 ); + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + + isvar_by_ind[ arg[0] + i_vec ] = true; + index_by_ind[ arg[0] + i_vec ] = size_t(arg[2]); +} + +/*! +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 CppAD::local::sparse_store_op +*/ +template +void forward_sparse_store_op( + bool dependency , + OpCode op , + const addr_t* arg , + size_t num_combined , + const size_t* combined , + Vector_set& var_sparsity , + Vector_set& vecad_sparsity ) +{ + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 0 ); + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_combined ); + size_t i_v = combined[ arg[0] - 1 ]; + CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < var_sparsity.n_set() ); + + if( dependency & ( (op == StvvOp) | (op == StvpOp) ) ) + vecad_sparsity.binary_union(i_v, i_v, size_t(arg[1]), var_sparsity); + + if( (op == StpvOp) | (op == StvvOp ) ) + vecad_sparsity.binary_union(i_v, i_v, size_t(arg[2]), var_sparsity); + + return; +} + +/*! +Reverse mode sparsity operations for StpvOp, StvpOp, 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: + + +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 + +\param dependency +is this a dependency (or sparsity) calculation. + +\copydetails CppAD::local::sparse_store_op +*/ +template +void reverse_sparse_jacobian_store_op( + bool dependency , + OpCode op , + const addr_t* arg , + size_t num_combined , + const size_t* combined , + Vector_set& var_sparsity , + Vector_set& vecad_sparsity ) +{ + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 0 ); + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_combined ); + size_t i_v = combined[ arg[0] - 1 ]; + CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < var_sparsity.n_set() ); + + if( dependency & ( (op == StvpOp) | (op == StvvOp) ) ) + var_sparsity.binary_union( size_t(arg[1]), size_t(arg[1]), i_v, vecad_sparsity); + if( (op == StpvOp) | (op == StvvOp) ) + var_sparsity.binary_union( size_t(arg[2]), size_t(arg[2]), i_v, vecad_sparsity); + + return; +} + +/*! +Reverse 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: + + +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 + +\copydetails CppAD::local::sparse_store_op + +\param var_jacobian + var_jacobian[ arg[2] ] +is false (true) if the Jacobian of G with respect to y is always zero +(may be non-zero). + +\param vecad_jacobian + 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. +*/ +template +void reverse_sparse_hessian_store_op( + OpCode op , + const addr_t* arg , + size_t num_combined , + const size_t* combined , + Vector_set& var_sparsity , + Vector_set& vecad_sparsity , + bool* var_jacobian , + bool* vecad_jacobian ) +{ + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); + CPPAD_ASSERT_UNKNOWN( NumRes(op) == 0 ); + CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_combined ); + size_t i_v = combined[ arg[0] - 1 ]; + CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() ); + CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < var_sparsity.n_set() ); + + var_sparsity.binary_union( size_t(arg[2]), size_t(arg[2]), i_v, vecad_sparsity); + + var_jacobian[ arg[2] ] |= vecad_jacobian[i_v]; + + return; +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/subgraph/arg_variable.hpp cppad-2019.02.00.0/include/cppad/local/subgraph/arg_variable.hpp --- cppad-2018.00.00.0/include/cppad/local/subgraph/arg_variable.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/subgraph/arg_variable.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,112 @@ +# ifndef CPPAD_LOCAL_SUBGRAPH_ARG_VARIABLE_HPP +# define CPPAD_LOCAL_SUBGRAPH_ARG_VARIABLE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include + +// BEGIN_CPPAD_LOCAL_SUBGRAPH_NAMESPACE +namespace CppAD { namespace local { namespace subgraph { +/*! +\file arg_variable.hpp +Determine arguments that are variables. +*/ + +/*! +Determine the set of arguments, for an operator, that are variables. + +\tparam Addr +Type used for indices in random iterator. + +\param random_itr +is a random iterator for this operation sequence. + +\param i_op +is the operator index. If this operator is part of a atomic function call, +it must be the first AFunOp in the call. (There is a AFunOp at the +beginning and end of each call.) + +\param variable +is the set of argument variables corresponding to this operator. +If the operator is a AFunOp, the arguments are the variables +that are passed into the function call. + +\param work +this is work space used by arg_variable to make subsequent calls +faster. It should not be used by the calling routine. In addition, +it is better if work does not drop out of scope between calls. +*/ +template +void get_argument_variable( + const play::const_random_iterator& random_itr , + size_t i_op , + pod_vector& variable , + pod_vector& work ) +{ + // reset to size zero, but keep allocated memory + variable.resize(0); + // + // operator corresponding to i_op + OpCode op; + const addr_t* op_arg; + size_t i_var; + random_itr.op_info(i_op, op, op_arg, i_var); + // + // partial check of assumptions on atomic function calls + CPPAD_ASSERT_UNKNOWN( + op != FunapOp && op != FunavOp && op != FunrpOp && op != FunrvOp + ); + // + // we assume this is the first AFunOp of the call + if( op == AFunOp ) + { random_itr.op_info(++i_op, op, op_arg, i_var); + while( op != AFunOp ) + { switch(op) + { + case FunavOp: + { CPPAD_ASSERT_NARG_NRES(op, 1, 0); + size_t j_var = size_t( op_arg[0] ); + variable.push_back(j_var); + } + break; + + case FunrvOp: + case FunrpOp: + case FunapOp: + break; + + default: + // cannot find second AFunOp in this call + CPPAD_ASSERT_UNKNOWN(false); + break; + } + random_itr.op_info(++i_op, op, op_arg, i_var); + } + CPPAD_ASSERT_UNKNOWN( variable.size() > 0 ); + return; + } + // is_variable is a reference to work with a better name + pod_vector& is_variable(work); + arg_is_variable(op, op_arg, is_variable); + size_t num_arg = is_variable.size(); + for(size_t j = 0; j < num_arg; ++j) + { if( is_variable[j] ) + { size_t j_var = size_t( op_arg[j] ); + variable.push_back(j_var); + } + } + return; +} + +} } } // END_CPPAD_LOCAL_SUBGRAPH_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/subgraph/entire_call.hpp cppad-2019.02.00.0/include/cppad/local/subgraph/entire_call.hpp --- cppad-2018.00.00.0/include/cppad/local/subgraph/entire_call.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/subgraph/entire_call.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,76 @@ +# ifndef CPPAD_LOCAL_SUBGRAPH_ENTIRE_CALL_HPP +# define CPPAD_LOCAL_SUBGRAPH_ENTIRE_CALL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include + +// BEGIN_CPPAD_LOCAL_SUBGRAPH_NAMESPACE +namespace CppAD { namespace local { namespace subgraph { +/*! +\file entire_call.hpp +include entire function call in a subgraph +*/ +// =========================================================================== +/*! +Convert from just firt AFunOp to entire atomic function call in a subgraph. + +\tparam Addr +Type used for indices in the random iterator. + +\param random_itr +is a random iterator for this operation sequence. + +\param subgraph +It a set of operator indices in this recording. +If the corresponding operator is a AFunOp, it assumed to be the +first one in the corresponding atomic function call. +The other call operators are included in the subgraph. +*/ +template +void entire_call( + const play::const_random_iterator& random_itr , + pod_vector& subgraph ) +{ + // add extra operators corresponding to rest of atomic function calls + size_t n_sub = subgraph.size(); + for(size_t k = 0; k < n_sub; ++k) + { size_t i_op = size_t( subgraph[k] ); + // + if( random_itr.get_op(i_op) == AFunOp ) + { // This is the first AFunOp of this atomic function call + while( random_itr.get_op(++i_op) != AFunOp ) + { switch(random_itr.get_op(i_op)) + { + case FunavOp: + case FunrvOp: + case FunrpOp: + case FunapOp: + subgraph.push_back( addr_t(i_op) ); + break; + + default: + // cannot find second AFunOp in this call + CPPAD_ASSERT_UNKNOWN(false); + break; + } + } + // THis is the second AFunOp of this atomic function call + subgraph.push_back( addr_t(i_op) ); + } + } + +} + +} } } // END_CPPAD_LOCAL_SUBGRAPH_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/subgraph/get_rev.hpp cppad-2019.02.00.0/include/cppad/local/subgraph/get_rev.hpp --- cppad-2018.00.00.0/include/cppad/local/subgraph/get_rev.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/subgraph/get_rev.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,165 @@ +# ifndef CPPAD_LOCAL_SUBGRAPH_GET_REV_HPP +# define CPPAD_LOCAL_SUBGRAPH_GET_REV_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include + +// BEGIN_CPPAD_LOCAL_SUBGRAPH_NAMESPACE +namespace CppAD { namespace local { namespace subgraph { +/*! +\file get_rev.hpp +Get subgraph corresponding to a dependent variable. +*/ + +// =========================================================================== +/*! +Get the subgraph corresponding to a dependent variables +(and a selected set of independent variables). + +\tparam Addr +Type used for indices in the random iterator. + +\param random_itr +is a random iterator for this operation sequence. + +\param dep_taddr +is the vector mapping user dependent variable indices +to the correpsonding variable in the recording. + +\param i_dep +is the user index for his dependent variable; +that i_dep < n_dep_. + +\param subgraph +the input size and contents of this vector do not matter. +Repeated calls with the same subgraph vector should reduce +the amount of memory allocation. +Upon return it contains the operator indices for the subgraph +corresponding to the dependent and the selected independent variables. +Only selected independent variable operators InvOp are included +in the subgraph. +Furthermore the operator indices in subgraph are unique; i.e., +if i_op != j_op then subgraph[i_op] != subgraph[j_op]. + +\par map_user_op_ +This vector must be set. + +\par in_subgraph_ +has size equal to the number of operators in play. +If in_subgraph[i_op] <= n_dep_, +the result for this operator depends on the selected independent variables. +In addition, upon input, there is no i_op such that in_subgraph[i_op] == i_dep. +Note that for atomic function call operators i_op, +\code + n_dep_ < in_subgraph[i_op] +\endcode +except for the first AFunOp in the atomic function call sequence. +For the first AFunOp, +\code + in_subgraph[i_op] <= n_dep_ +\endcode +if any result for the atomic function call +depends on the selected independent variables. +Except for UserOP, only operators with NumRes(op) > 0 are included +in the dependency; e.g., comparision operators are not included. +Upon return, some of the i_op for which in_subgraph[i_op] <= n_dep_, +will be changed to in_subgraph[i_op] = i_dep. + +\par process_range_ +The value process_range_[i_dep] is checked to make sure it is false. +It is then set to have value true. +*/ +template +void subgraph_info::get_rev( + const play::const_random_iterator& random_itr , + const pod_vector& dep_taddr , + addr_t i_dep , + pod_vector& subgraph ) +{ // check sizes + CPPAD_ASSERT_UNKNOWN( map_user_op_.size() == n_op_ ); + + // process_range_ + CPPAD_ASSERT_UNKNOWN( process_range_[i_dep] == false ); + process_range_[i_dep] = true; + + // special value; see init_rev_in_subgraph + addr_t depend_yes = addr_t( n_dep_ ); + + // assumption on i_dep + CPPAD_ASSERT_UNKNOWN( i_dep < depend_yes ); + + // start with an empty subgraph for this dependent variable + subgraph.resize(0); + + // tape index corresponding to this dependent variable + size_t i_var = dep_taddr[i_dep]; + + // operator corresponding to this dependent variable + size_t i_op = random_itr.var2op(i_var); + i_op = size_t( map_user_op_[i_op] ); + + // if this variable depends on the selected indepent variables + // process its subgraph + CPPAD_ASSERT_UNKNOWN( in_subgraph_[i_op] != i_dep ) + if( in_subgraph_[i_op] <= depend_yes ) + { subgraph.push_back( addr_t(i_op) ); + in_subgraph_[i_op] = i_dep; + } + + // space used to return set of arguments that are variables + pod_vector argument_variable; + + // temporary space used by get_argument_variable + pod_vector work; + + // scan all the operators in this subgraph + size_t sub_index = 0; + while(sub_index < subgraph.size() ) + { // this operator connected to this dependent and selected independent + i_op = size_t( subgraph[sub_index] ); + CPPAD_ASSERT_UNKNOWN( in_subgraph_[i_op] == i_dep ); + // + // There must be a result for this operator +# ifndef NDEBUG + OpCode op = random_itr.get_op(i_op); + CPPAD_ASSERT_UNKNOWN(op == AFunOp || NumRes(op) > 0 ); +# endif + // + // which variables are connected to this operator + get_argument_variable(random_itr, i_op, argument_variable, work); + for(size_t j = 0; j < argument_variable.size(); ++j) + { // add the corresponding operators to the subgraph + size_t j_var = argument_variable[j]; + size_t j_op = random_itr.var2op(j_var); + j_op = size_t( map_user_op_[j_op] ); + bool add = in_subgraph_[j_op] <= depend_yes; + add &= in_subgraph_[j_op] != i_dep; + if( random_itr.get_op(j_op) == InvOp ) + { CPPAD_ASSERT_UNKNOWN( j_op == j_var ); + add &= select_domain_[j_var - 1]; + } + if( add ) + { subgraph.push_back( addr_t(j_op) ); + in_subgraph_[j_op] = i_dep; + } + } + // we are done scaning this subgraph operator + ++sub_index; + } +} + +} } } // END_CPPAD_LOCAL_SUBGRAPH_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/subgraph/info.hpp cppad-2019.02.00.0/include/cppad/local/subgraph/info.hpp --- cppad-2018.00.00.0/include/cppad/local/subgraph/info.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/subgraph/info.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,334 @@ +# ifndef CPPAD_LOCAL_SUBGRAPH_INFO_HPP +# define CPPAD_LOCAL_SUBGRAPH_INFO_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include + +// BEGIN_CPPAD_LOCAL_SUBGRAPH_NAMESPACE +namespace CppAD { namespace local { namespace subgraph { +/*! +\file info.hpp +subgraph information attached to a operation sequence +*/ + +/// class for maintaining subgraph information attached to on ADFun object. +class subgraph_info { +private: + // ----------------------------------------------------------------------- + // private member data set by constructor, resize, and assign + // ----------------------------------------------------------------------- + /// number of independent variables for this function + size_t n_ind_; + + /// number of dependent variables for this function + size_t n_dep_; + + /// number of operatros in operation sequence + size_t n_op_; + + /// number of variables in operation sequence + size_t n_var_; + + // ----------------------------------------------------------------------- + // private member data set by set_map_user_op + // ----------------------------------------------------------------------- + + /// Mapping atomic call operators to AFunOp that begins call sequence, + /// other operators are not changed by the map. + /// (size zero after construtor or resize) + pod_vector map_user_op_; + + // ----------------------------------------------------------------------- + // other private member data + // ----------------------------------------------------------------------- + + /// flags which operatiors are in subgraph + /// (size zero or n_op_). + pod_vector in_subgraph_; + + /// flags which dependent variables are selected + pod_vector select_domain_; + + /// flags which dependent variables have been processed since + /// the previous init_rev + pod_vector process_range_; + +public: + // ----------------------------------------------------------------------- + // const public functions + // ----------------------------------------------------------------------- + /// number of independent variables + size_t n_ind(void) const + { return n_ind_; } + + /// number of dependent variables + size_t n_dep(void) const + { return n_dep_; } + + /// number of operators + size_t n_op(void) const + { return n_op_; } + + // number of variables + size_t n_var(void) const + { return n_var_; } + + /// map atomic function calls to first operator in the call + const pod_vector& map_user_op(void) const + { return map_user_op_; } + + /// previous select_domain argument to init_rev + const pod_vector& select_domain(void) const + { return select_domain_; } + + /// dependent variables that have been processed since previous init_rev + const pod_vector& process_range(void) const + { return process_range_; } + + /// amount of memory corresonding to this object + size_t memory(void) const + { size_t sum = map_user_op_.size() * sizeof(addr_t); + sum += in_subgraph_.size() * sizeof(addr_t); + sum += select_domain_.size() * sizeof(bool); + sum += process_range_.size() * sizeof(bool); + return sum; + } + + /// free memory used for calculating subgraph + void clear(void) + { map_user_op_.clear(); + in_subgraph_.clear(); + select_domain_.clear(); + process_range_.clear(); + } + // ----------------------------------------------------------------------- + /*! + check that the value of map_user_op is OK for this operation sequence + + \param play + is the player for this operation sequence. + + \return + is true, if map_user_op has the correct value for this operation sequence + (is the same as it would be after a set_map_user_op). + */ + template + bool check_map_user_op(const player* play) const + { if( map_user_op_.size() != n_op_ ) + return false; + bool ok = true; + size_t i_op = 0; + while( i_op < n_op_ ) + { OpCode op = play->GetOp(i_op); + ok &= map_user_op_[i_op] == addr_t( i_op ); + if( op == AFunOp ) + { addr_t begin = addr_t( i_op ); + op = play->GetOp(++i_op); + while( op != AFunOp ) + { CPPAD_ASSERT_UNKNOWN( + op==FunapOp || op==FunavOp || op==FunrpOp || op==FunrvOp + ); + ok &= map_user_op_[i_op] == begin; + op = play->GetOp(++i_op); + } + ok &= map_user_op_[i_op] == begin; + } + ++i_op; + } + return ok; + } + // ----------------------------------------------------------------------- + // non const public functions + // ----------------------------------------------------------------------- + + /// flag which operators that are in the subgraph + pod_vector& in_subgraph(void) + { return in_subgraph_; } + + + /// default constructor (all sizes are zero) + subgraph_info(void) + : n_ind_(0), n_dep_(0), n_op_(0), n_var_(0) + { CPPAD_ASSERT_UNKNOWN( map_user_op_.size() == 0 ); + CPPAD_ASSERT_UNKNOWN( in_subgraph_.size() == 0 ); + } + // ----------------------------------------------------------------------- + /// assignment operator + void operator=(const subgraph_info& info) + { n_ind_ = info.n_ind_; + n_dep_ = info.n_dep_; + n_op_ = info.n_op_; + n_var_ = info.n_var_; + map_user_op_ = info.map_user_op_; + in_subgraph_ = info.in_subgraph_; + select_domain_ = info.select_domain_; + process_range_ = info.process_range_; + return; + } + // ----------------------------------------------------------------------- + /// swap + /// (used for move semantics version of ADFun assignment) + void swap(subgraph_info& info) + { // size_t objects + std::swap(n_ind_ , info.n_ind_); + std::swap(n_dep_ , info.n_dep_); + std::swap(n_op_ , info.n_op_); + std::swap(n_var_ , info.n_var_); + // + // pod_vectors + map_user_op_.swap( info.map_user_op_); + in_subgraph_.swap( info.in_subgraph_); + select_domain_.swap( info.select_domain_); + process_range_.swap( info.process_range_); + // + return; + } + // ----------------------------------------------------------------------- + /*! + set sizes for this object (the default sizes are zero) + + \param n_ind + number of indepent variables. + + \param n_dep + number of dependent variables. + + \param n_op + number of operators. + + \param n_var + number of variables. + + \par map_user_op_ + is resized to zero. + + \par in_subgraph_ + is resized to zero. + */ + void resize(size_t n_ind, size_t n_dep, size_t n_op, size_t n_var) + { CPPAD_ASSERT_UNKNOWN( + n_op <= size_t( std::numeric_limits::max() ) + ); + // n_ind_ + n_ind_ = n_ind; + // n_dep_ + n_dep_ = n_dep; + // n_op_ + n_op_ = n_op; + // n_var_ + n_var_ = n_var; + + // + // map_user_op_ + map_user_op_.resize(0); + // + // in_subgraph_ + in_subgraph_.resize(0); + // + return; + } + // ----------------------------------------------------------------------- + /*! + set the value of map_user_op for this operation sequence + + \param play + is the player for this operation sequence. It must same number of + operators and variables as this subgraph_info object. + + \par map_user_op_ + This size of map_user_op_ must be zero when this function is called + (which is true after a resize operation). + This function sets its size to the number of operations in play. + We use the term user OpCocde for the any one of the following: + AFunOp, FunapOp, FunavOp, FunrpOp, or FunrvOp. Suppose + \code + OpCodce op_i = play->GetOp(i_op); + size_t j_op = map_user_op[i_op]; + OpCode op_j = play->GetOP(j_op); + \endcode + If op is a user OpCode, j_op is the index of the first operator + in the corresponding atomic function call and op_j == AFunOp. + Otherwise j_op == i_op; + + */ + template + void set_map_user_op(const player* play) + { CPPAD_ASSERT_UNKNOWN( map_user_op_.size() == 0 ); + // + CPPAD_ASSERT_UNKNOWN( n_op_ == play->num_op_rec() ); + CPPAD_ASSERT_UNKNOWN( n_var_ == play->num_var_rec() ); + // + // resize map_user_op_ + map_user_op_.resize(n_op_); + // + // set map_user_op for each operator + for(size_t i_op = 0; i_op < n_op_; ++i_op) + { // this operator + OpCode op = play->GetOp(i_op); + // + // value of map_user_op when op is not in atomic function call) + map_user_op_[i_op] = addr_t( i_op ); + // + if( op == AFunOp ) + { // first AFunOp in an atomic function call sequence + // + // All operators in this atomic call sequence will be + // mapped to the AFunOp that begins this call. + addr_t begin = addr_t( i_op ); + op = play->GetOp(++i_op); + while( op != AFunOp ) + { CPPAD_ASSERT_UNKNOWN( + op==FunapOp || op==FunavOp || op==FunrpOp || op==FunrvOp + ); + // map this operator to the beginning of the call + map_user_op_[i_op] = begin; + op = play->GetOp(++i_op); + } + // map the second AFunOp to the beginning of the call + map_user_op_[i_op] = begin; + } + } + return; + } + // ----------------------------------------------------------------------- + // see init_rev.hpp + template + void init_rev( + const play::const_random_iterator& random_itr , + const BoolVector& select_domain + ); + template + void init_rev( + player* play , + const BoolVector& select_domain + ); + // ----------------------------------------------------------------------- + // see get_rev.hpp + template + void get_rev( + const play::const_random_iterator& random_itr , + const pod_vector& dep_taddr , + addr_t i_dep , + pod_vector& subgraph + ); +}; + +} } } // END_CPPAD_LOCAL_SUBGRAPH_NAMESPACE + +// routines that operate on in_subgraph +# include +# include + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/subgraph/init_rev.hpp cppad-2019.02.00.0/include/cppad/local/subgraph/init_rev.hpp --- cppad-2018.00.00.0/include/cppad/local/subgraph/init_rev.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/subgraph/init_rev.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,225 @@ +# ifndef CPPAD_LOCAL_SUBGRAPH_INIT_REV_HPP +# define CPPAD_LOCAL_SUBGRAPH_INIT_REV_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include + +// BEGIN_CPPAD_LOCAL_SUBGRAPH_NAMESPACE +namespace CppAD { namespace local { namespace subgraph { +/*! +\file init_rev.hpp +initialize for a reverse mode subgraph calculation +*/ + +// ----------------------------------------------------------------------- +/*! +Initialize in_subgraph corresponding to a single dependent variable +(and a selected set of independent variables). + +\tparam Addr +is the type used for indices in the random iterator. + +\param random_itr +Is a random iterator for this operation sequence. + +\param select_domain +is a vector with, size equal to the number of independent variables +in the recording. It determines the selected independent variables. + +\par in_subgraph_ +We use depend_yes (depend_no) for the value n_dep_ (n_dep_ + 1). +The important properties are that depend_yes < depend_no and +for a valid indpendent variable index i_ind < depend_yes. +The input size and elements of in_subgraph_ do not matter. +If in_subgraph_[i_op] == depend_yes (depend_no), +the result for this operator depends (does not depend) +on the selected independent variables. +Note that for atomic function call operators i_op, +in_subgraph[i_op] is depend_no except for the first AFunOp in the +atomic function call sequence. For the first AFunOp, +it is depend_yes (depend_no) if any of the results for the call sequence +depend (do not depend) on the selected independent variables. +Except for UserOP, only operators with NumRes(op) > 0 have in_subgraph_ +value depend_yes; +e.g., comparision operators have in_subgraph_ value depend_no. + +\par select_domain_ +This vector is is set equal to the select_domain argument. + +\par process_range_ +This vector is to to size n_dep_ and its values are set to false +*/ +template +void subgraph_info::init_rev( + const local::play::const_random_iterator& random_itr , + const BoolVector& select_domain ) +{ + // check sizes + CPPAD_ASSERT_UNKNOWN( map_user_op_.size() == n_op_ ); + CPPAD_ASSERT_UNKNOWN( random_itr.num_op() == n_op_ ); + CPPAD_ASSERT_UNKNOWN( size_t( select_domain.size() ) == n_ind_ ); + + // depend_yes and depend_no + addr_t depend_yes = addr_t( n_dep_ ); + addr_t depend_no = addr_t( n_dep_ + 1 ); + + // select_domain_ + select_domain_.resize(n_ind_); + for(size_t j = 0; j < n_ind_; ++j) + select_domain_[j] = select_domain[j]; + + // process_range_ + process_range_.resize(n_dep_); + for(size_t i = 0; i < n_dep_; ++i) + process_range_[i] = false; + + // set in_subgraph to have proper size + in_subgraph_.resize(n_op_); + + // space used to return set of arguments that are variables + pod_vector argument_variable; + + // temporary space used by get_argument_variable + pod_vector work; + +# ifndef NDEBUG + size_t count_independent = 0; +# endif + bool begin_atomic_call = false; + for(size_t i_op = 0; i_op < n_op_; ++i_op) + { OpCode op = random_itr.get_op(i_op); + // + // default value for this operator + in_subgraph_[i_op] = depend_no; + // + switch(op) + { case InvOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); + CPPAD_ASSERT_UNKNOWN( i_op > 0 ); + { // get user index for this independent variable + size_t j = i_op - 1; + CPPAD_ASSERT_UNKNOWN( j < n_ind_ ); + // + // set in_subgraph_[i_op] + if( select_domain[j] ) + in_subgraph_[i_op] = depend_yes; + } +# ifndef NDEBUG + ++count_independent; +# endif + break; + + // only mark both first AFunOp for each call as depending + // on the selected independent variables + case AFunOp: + begin_atomic_call = ! begin_atomic_call; + if( begin_atomic_call ) + { get_argument_variable(random_itr, i_op, argument_variable, work); + for(size_t j = 0; j < argument_variable.size(); ++j) + { size_t j_var = argument_variable[j]; + size_t j_op = random_itr.var2op(j_var); + j_op = size_t( map_user_op_[j_op] ); + CPPAD_ASSERT_UNKNOWN( j_op < i_op ); + if( in_subgraph_[j_op] == depend_yes ) + in_subgraph_[i_op] = depend_yes; + } + } + break; + + // skip FunrvOp (gets mapped to first AFunOp in this call) + case FunrvOp: + CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 ); + break; + + default: + // Except for AFunOp, only include when NumRes(op) > 0. + if( NumRes(op) > 0 ) + { get_argument_variable(random_itr, i_op, argument_variable, work); + for(size_t j = 0; j < argument_variable.size(); ++j) + { size_t j_var = argument_variable[j]; + size_t j_op = random_itr.var2op(j_var); + j_op = size_t( map_user_op_[j_op] ); + CPPAD_ASSERT_UNKNOWN( j_op < i_op ); + if( in_subgraph_[j_op] == depend_yes ) + in_subgraph_[i_op] = depend_yes; + } + } + break; + } + } + CPPAD_ASSERT_UNKNOWN( + count_independent == size_t(select_domain.size()) + ); + // + return; +} +// ----------------------------------------------------------------------- +/*! +Initialize in_subgraph corresponding to a single dependent variable +(and a selected set of independent variables). + +\tparam Addr +is the type used for indices in the random iterator. + +\tparam Base +this recording was made using ADFun + +\param play +is a player for this ADFun object. + +\param select_domain +is a vector with, size equal to the number of independent variables +in the recording. It determines the selected independent variables. + +\par in_subgraph_ +We use depend_yes (depend_no) for the value n_dep_ (n_dep_ + 1). +The important properties are that depend_yes < depend_no and +for a valid indpendent variable index i_ind < depend_yes. +The input size and elements of in_subgraph_ do not matter. +If in_subgraph_[i_op] == depend_yes (depend_no), +the result for this operator depends (does not depend) +on the selected independent variables. +Note that for atomic function call operators i_op, +in_subgraph[i_op] is depend_no except for the first AFunOp in the +atomic function call sequence. For the first AFunOp, +it is depend_yes (depend_no) if any of the results for the call sequence +depend (do not depend) on the selected independent variables. +Except for UserOP, only operators with NumRes(op) > 0 have in_subgraph_ +value depend_yes; +e.g., comparision operators have in_subgraph_ value depend_no. + +\par select_domain_ +This vector is is set equal to the select_domain argument. + +\par process_range_ +This vector is to to size n_dep_ and its values are set to false +*/ +template +void subgraph_info::init_rev( + player* play , + const BoolVector& select_domain ) +{ + // get random access iterator for this player + play->template setup_random(); + local::play::const_random_iterator random_itr = + play->template get_random(); + // + init_rev(random_itr, select_domain); + // + return; +} + + +} } } // END_CPPAD_LOCAL_SUBGRAPH_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/subgraph/sparsity.hpp cppad-2019.02.00.0/include/cppad/local/subgraph/sparsity.hpp --- cppad-2018.00.00.0/include/cppad/local/subgraph/sparsity.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/subgraph/sparsity.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,191 @@ +# ifndef CPPAD_LOCAL_SUBGRAPH_SPARSITY_HPP +# define CPPAD_LOCAL_SUBGRAPH_SPARSITY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include +# include + +// BEGIN_CPPAD_LOCAL_SUBGRAPH_NAMESPACE +namespace CppAD { namespace local { namespace subgraph { +/*! +\file sparsity.hpp +Compute dependency sparsity pattern using subgraph technique. +*/ +// =========================================================================== +/*! +Compute dependency sparsity pattern for an ADFun function. + +\tparam Addr +type used for indices in random iterator +(must correspond to play->addr_type()) + +\tparam Base +the operation sequence was recorded using AD. + +\tparam BoolVector +a simple vector class with elements of type bool. + +\param play +is the operation sequence corresponding to the ADFun function. +It is effectively const except that play->setup_random() is called. + + +\param sub_info +is the subgraph information for this ADFun object. + +\param dep_taddr +mapping from user dependent variable index to variable index in play +(must have size sub_info.n_dep()). + +\param select_domain +only the selected independent variables will be included in the sparsity +pattern (must have size sub_info.n_ind()). + +\param select_range +only the selected dependent variables will be included in the sparsity pattern +(must have size sub_info.n_dep()). + +\param row_out +The input size and elements of row_out do not matter. +We use number of non-zeros (nnz) to denote the number of elements +in row_out. For k = 0 , ... , nnz-1, row_out[k] is the row index +of the k-th no-zero element of the dependency sparsitiy pattern for +the function corresponding to the recording. +\code + 0 <= row_out[k] < dep_taddr.size() + select_range[ row_out[k] ] == true +\endcode + +\param col_out +The input size and elements of col_out do not matter. +Upon return is has the same size as row_out; i.e., nnz. +For k = 0 , ... , nnz-1, col_out[k] is the column index +of the k-th no-zero element of the dependency sparsitiy pattern for +the function corresponding to the recording. +\code + 0 <= col_out[k] < sub_info.n_ind() + select_domain[ col_out[k] ] == true +\endcode + +\par AFunOp +All of the inputs and outputs for an atomic function call are considered +to be connected. +2DO: It would be good to use the sparsity patters for atomic function calls +to to make the sparsity pattern more efficient. +*/ + +template +void subgraph_sparsity( + player* play , + subgraph_info& sub_info , + const pod_vector& dep_taddr , + const BoolVector& select_domain , + const BoolVector& select_range , + pod_vector& row_out , + pod_vector& col_out ) +{ + // get random access iterator for this player + play->template setup_random(); + local::play::const_random_iterator random_itr = + play->template get_random(); + + // check dimension assumptions + CPPAD_ASSERT_UNKNOWN( + dep_taddr.size() == sub_info.n_dep() + ); + CPPAD_ASSERT_UNKNOWN( + size_t(select_domain.size()) == sub_info.n_ind() + ); + CPPAD_ASSERT_UNKNOWN( + size_t(select_range.size()) == sub_info.n_dep() + ); + + // number of dependent variables + size_t n_dep = dep_taddr.size(); + CPPAD_ASSERT_UNKNOWN( size_t(select_range.size()) == n_dep ); + + // start with an empty sparsity pattern + row_out.resize(0); + col_out.resize(0); + + // map_user_op + if( sub_info.map_user_op().size() == 0 ) + sub_info.set_map_user_op(play); + else + { CPPAD_ASSERT_UNKNOWN( sub_info.check_map_user_op(play) ); + } + CPPAD_ASSERT_UNKNOWN( + sub_info.map_user_op().size() == play->num_op_rec() + ); + + // subgraph of operators that are are connected to one of the selected + // dependent variables and depend on the selected independent variables + pod_vector subgraph; + + // initialize a reverse mode subgraph calculation + sub_info.init_rev(random_itr, select_domain); + CPPAD_ASSERT_UNKNOWN( + sub_info.in_subgraph().size() == play->num_op_rec() + ); + // +# ifndef NDEBUG + addr_t depend_yes = addr_t( n_dep ); +# endif + + // for each of the selected dependent variables +# ifndef NDEBUG + addr_t depend_no = addr_t( n_dep + 1 ); +# endif + CPPAD_ASSERT_UNKNOWN( depend_yes < depend_no ); + CPPAD_ASSERT_UNKNOWN( NumRes(BeginOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(InvOp) == 1 ); + for(size_t i_dep = 0; i_dep < n_dep; ++i_dep) if( select_range[i_dep] ) + { CPPAD_ASSERT_UNKNOWN( i_dep < size_t( depend_yes ) ); + // + // subgraph of operators connected to i_dep + sub_info.get_rev( + random_itr, dep_taddr, addr_t(i_dep), subgraph + ); + // + for(size_t k = 0; k < subgraph.size(); k++) + { size_t i_op = size_t( subgraph[k] ); + // + // operator corresponding to this index + OpCode op = play->GetOp(i_op); + // + // This version of the subgraph only has first AFunOp + // for each atomic functionc all. + CPPAD_ASSERT_UNKNOWN( NumRes(op) > 0 || op == AFunOp ); + // + // independent variable entries correspond to sparsity pattern + if( op == InvOp ) + { CPPAD_ASSERT_NARG_NRES(op, 0, 1); + // i_var is equal i_op becasue BeginOp and InvOp have 1 result + size_t i_var = i_op; // tape index for this variable + size_t i_ind = i_var - 1; // user index for this variable + CPPAD_ASSERT_UNKNOWN( random_itr.var2op(i_var) == i_op ); + CPPAD_ASSERT_UNKNOWN( select_domain[i_ind] ); + // + // put this pair in the sparsity pattern + row_out.push_back(i_dep); + col_out.push_back(i_ind); + } + } + } +} + +} } } // END_CPPAD_LOCAL_SUBGRAPH_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sub_op.hpp cppad-2019.02.00.0/include/cppad/local/sub_op.hpp --- cppad-2018.00.00.0/include/cppad/local/sub_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sub_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,500 @@ +# ifndef CPPAD_LOCAL_SUB_OP_HPP +# define CPPAD_LOCAL_SUB_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file sub_op.hpp +Forward and reverse mode calculations for z = x - y. +*/ + +// --------------------------- Subvv ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = SubvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x - y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_binary_op +*/ + +template +void forward_subvv_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(SubvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SubvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + for(size_t d = p; d <= q; d++) + z[d] = x[d] - y[d]; +} +/*! +Multiple directions forward mode Taylor coefficients for op = SubvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x - y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_binary_op_dir +*/ + +template +void forward_subvv_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(SubvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SubvvOp) == 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 + size_t(arg[0]) * num_taylor_per_var + m; + Base* y = taylor + size_t(arg[1]) * num_taylor_per_var + m; + Base* z = taylor + i_z * num_taylor_per_var + m; + + for(size_t ell = 0; ell < r; ell++) + z[ell] = x[ell] - y[ell]; +} + +/*! +Compute zero order forward mode Taylor coefficients for result of op = SubvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x - y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::forward_binary_op_0 +*/ + +template +void forward_subvv_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(SubvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SubvvOp) == 1 ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = x[0] - y[0]; +} + +/*! +Compute reverse mode partial derivatives for result of op = SubvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x - y +\endverbatim +In the documentation below, +this operations is for the case where both x and y are variables +and the argument parameter is not used. + +\copydetails CppAD::local::reverse_binary_op +*/ + +template +void reverse_subvv_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(SubvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SubvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Partial derivatives corresponding to arguments and result + Base* px = partial + size_t(arg[0]) * nc_partial; + Base* py = partial + size_t(arg[1]) * nc_partial; + Base* pz = partial + i_z * nc_partial; + + // number of indices to access + size_t i = d + 1; + while(i) + { --i; + px[i] += pz[i]; + py[i] -= pz[i]; + } +} + +// --------------------------- Subpv ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = SubpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x - y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_binary_op +*/ + +template +void forward_subpv_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(SubpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SubpvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + // Paraemter value + Base x = parameter[ arg[0] ]; + if( p == 0 ) + { z[0] = x - y[0]; + p++; + } + for(size_t d = p; d <= q; d++) + z[d] = - y[d]; +} +/*! +Multiple directions forward mode Taylor coefficients for op = SubpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x - y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_binary_op_dir +*/ + +template +void forward_subpv_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(SubpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SubpvOp) == 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 + size_t(arg[1]) * num_taylor_per_var + m; + Base* z = taylor + i_z * num_taylor_per_var + m; + + // Paraemter value + for(size_t ell = 0; ell < r; ell++) + z[ell] = - y[ell]; +} +/*! +Compute zero order forward mode Taylor coefficient for result of op = SubpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x - y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::forward_binary_op_0 +*/ + +template +void forward_subpv_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(SubpvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SubpvOp) == 1 ); + + // Paraemter value + Base x = parameter[ arg[0] ]; + + // Taylor coefficients corresponding to arguments and result + Base* y = taylor + size_t(arg[1]) * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = x - y[0]; +} + +/*! +Compute reverse mode partial derivative for result of op = SubpvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x - y +\endverbatim +In the documentation below, +this operations is for the case where x is a parameter and y is a variable. + +\copydetails CppAD::local::reverse_binary_op +*/ + +template +void reverse_subpv_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(SubvvOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SubvvOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Partial derivatives corresponding to arguments and result + Base* py = partial + size_t(arg[1]) * nc_partial; + Base* pz = partial + i_z * nc_partial; + + // number of indices to access + size_t i = d + 1; + while(i) + { --i; + py[i] -= pz[i]; + } +} + +// --------------------------- Subvp ----------------------------------------- +/*! +Compute forward mode Taylor coefficients for result of op = SubvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x - y +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::forward_binary_op +*/ + +template +void forward_subvp_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(SubvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SubvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( q < cap_order ); + CPPAD_ASSERT_UNKNOWN( p <= q ); + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* z = taylor + i_z * cap_order; + + // Parameter value + Base y = parameter[ arg[1] ]; + if( p == 0 ) + { z[0] = x[0] - y; + p++; + } + for(size_t d = p; d <= q; d++) + z[d] = x[d]; +} +/*! +Multiple directions forward mode Taylor coefficients for op = SubvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x - y +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::forward_binary_op_dir +*/ + +template +void forward_subvp_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(SubvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SubvpOp) == 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 + size_t(arg[0]) * num_taylor_per_var; + Base* z = taylor + i_z * num_taylor_per_var; + + // Parameter value + size_t m = (q-1) * r + 1; + for(size_t ell = 0; ell < r; ell++) + z[m+ell] = x[m+ell]; +} + +/*! +Compute zero order forward mode Taylor coefficients for result of op = SubvvOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x - y +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::forward_binary_op_0 +*/ + +template +void forward_subvp_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(SubvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SubvpOp) == 1 ); + + // Parameter value + Base y = parameter[ arg[1] ]; + + // Taylor coefficients corresponding to arguments and result + Base* x = taylor + size_t(arg[0]) * cap_order; + Base* z = taylor + i_z * cap_order; + + z[0] = x[0] - y; +} + +/*! +Compute reverse mode partial derivative for result of op = SubvpOp. + +The C++ source code corresponding to this operation is +\verbatim + z = x - y +\endverbatim +In the documentation below, +this operations is for the case where x is a variable and y is a parameter. + +\copydetails CppAD::local::reverse_binary_op +*/ + +template +void reverse_subvp_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(SubvpOp) == 2 ); + CPPAD_ASSERT_UNKNOWN( NumRes(SubvpOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( d < cap_order ); + CPPAD_ASSERT_UNKNOWN( d < nc_partial ); + + // Partial derivatives corresponding to arguments and result + Base* px = partial + size_t(arg[0]) * nc_partial; + Base* pz = partial + i_z * nc_partial; + + // number of indices to access + size_t i = d + 1; + while(i) + { --i; + px[i] += pz[i]; + } +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sweep/call_atomic.hpp cppad-2019.02.00.0/include/cppad/local/sweep/call_atomic.hpp --- cppad-2018.00.00.0/include/cppad/local/sweep/call_atomic.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sweep/call_atomic.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,832 @@ +# ifndef CPPAD_LOCAL_SWEEP_CALL_ATOMIC_HPP +# define CPPAD_LOCAL_SWEEP_CALL_ATOMIC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include + +// BEGIN_CPAPD_LOCAL_SWEEP_NAMESPACE +namespace CppAD { namespace local { namespace sweep { +/*! +\file call_atomic.hpp +Callbacks to atomic functions corresponding to atomic_index. +*/ +// ---------------------------------------------------------------------------- +/*! +Forward mode callback to atomic functions. + +\tparam Base +Is the type corresponding to the Taylor coefficients. + +\tparam RecBase +Is the type corresponding to this atomic function. + +\param parameter_x [in] +contains the values, in afun(ax, ay), for arguments that are parameters. + +\param type_x [in] +what is the type, in afun(ax, ay), for each component of x. + +\param need_y +specifies which components of taylor_y are necessary. + +\param order_low [in] +lowerest order for this forward mode calculation. + +\param order_up [in] +highest order for this forward mode calculation. + +\param atom_index [in] +is the index, in local::atomic_index, corresponding to this atomic function. + +\param atom_old [in] +is the extra id information for this atomic function in the atomic_one case. + +\param taylor_x [in] +Taylor coefficients corresponding to x. + +\param taylor_y [out] +Taylor coefficient corresponding to y. +*/ +template +void call_atomic_forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + size_t atom_index , + size_t atom_old , + const vector& taylor_x , + vector& taylor_y ) +{ CPPAD_ASSERT_UNKNOWN( 0 < atom_index ); + bool set_null = false; + size_t type = 0; // set to avoid warning + std::string* name_ptr = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, atom_index, type, name_ptr, v_ptr); +# ifndef NDEBUG + bool ok = v_ptr != CPPAD_NULL; + if( ok ) + { + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + afun->set_old(atom_old); + vector empty; + ok = afun->forward( + order_low, order_up, empty, empty, taylor_x, taylor_y + ); + } + else + { CPPAD_ASSERT_UNKNOWN( type == 3 ); + atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + ok = afun->forward( + parameter_x, type_x, + need_y, order_low, order_up, taylor_x, taylor_y + ); + } + } + if( ! ok ) + { // now take the extra time to copy the name + std::string name; + local::atomic_index(set_null, atom_index, type, &name, v_ptr); + std::string msg = name; + if( v_ptr == CPPAD_NULL ) + msg += ": this atomic_three function has been deleted"; + else + msg += ": atomic forward returned false"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# else + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + vector empty; + afun->set_old(atom_old); + afun->forward( + order_low, order_up, empty, empty, taylor_x, taylor_y + ); + } + else + { atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + afun->forward( + parameter_x, type_x, + need_y, order_low, order_up, taylor_x, taylor_y + ); + } +# endif +} +// ---------------------------------------------------------------------------- +/*! +Reverse mode callback to atomic functions. + +\tparam Base +Is the type corresponding to the Taylor coefficients. + +\tparam RecBase +Is the type corresponding to this atomic function. + +\param parameter_x [in] +value of the parameter arguments to the atomic function +(other arguments have the value nan). + +\param type_x [in] +type for each component of x (not used by atomic_two interface). + +\param order_up [in] +highest order for this reverse mode calculation. + +\param atom_index [in] +is the index, in local::atomic_index, corresponding to this atomic function. + +\param atom_old [in] +is the extra id information for this atomic function in the atomic_one case. + +\param taylor_x [in] +Taylor coefficients corresponding to x. + +\param taylor_y [in] +Taylor coefficient corresponding to y. + +\param partial_x [out] +Partials w.r.t the x Taylor coefficients. + +\param partial_y [in] +Partials w.r.t the y Taylor coefficients. +*/ +template +void call_atomic_reverse( + const vector& parameter_x , + const vector& type_x , + size_t order_up , + size_t atom_index , + size_t atom_old , + const vector& taylor_x , + const vector& taylor_y , + vector& partial_x , + const vector& partial_y ) +{ CPPAD_ASSERT_UNKNOWN( 0 < atom_index ); + bool set_null = false; + size_t type = 0; // set to avoid warning + std::string* name_ptr = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, atom_index, type, name_ptr, v_ptr); +# ifndef NDEBUG + bool ok = v_ptr != CPPAD_NULL; + if( ok ) + { + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + afun->set_old(atom_old); + ok = afun->reverse( + order_up, taylor_x, taylor_y, partial_x, partial_y + ); + } + else + { CPPAD_ASSERT_UNKNOWN( type == 3 ); + atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + ok = afun->reverse( + parameter_x, type_x, + order_up, taylor_x, taylor_y, partial_x, partial_y + ); + } + } + if( ! ok ) + { // now take the extra time to copy the name + std::string name; + local::atomic_index(set_null, atom_index, type, &name, v_ptr); + std::string msg = name; + if( v_ptr == CPPAD_NULL ) + msg += ": this atomic_three function has been deleted"; + else + msg += ": atomic reverse returned false"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# else + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + afun->set_old(atom_old); + afun->reverse( + order_up, taylor_x, taylor_y, partial_x, partial_y + ); + } + else + { atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + afun->reverse( + parameter_x, type_x, + order_up, taylor_x, taylor_y, partial_x, partial_y + ); + } +# endif +} +// ---------------------------------------------------------------------------- +/*! +Forward Jacobian sparsity callback to atomic functions. + +\tparam Base +is the type corresponding to parameter_x +and to this atomic function. + +\tparam InternalSparsity +is the internal type used to represent sparsity; i.e., +sparse_pack or sparse_list. + +\param atom_index [in] +is the index, in local::atomic_index, corresponding to this atomic function. + +\param atom_old [in] +is the extra id information for this atomic function in the atomic_one case. + +\param dependency [in] +is this a dependency or sparsity calculation. + +\param parameter_x [in] +value of the parameter arguments to the atomic function +(other arguments have the value nan). + +\param type_x [in] +type for each component of x (not used by atomic_two interface). + +\param x_index [in] +is a mapping from the index of an atomic function argument +to the corresponding variable on the tape. + +\param y_index [in] +is a mapping from the index of an atomic function result +to the corresponding variable on the tape. + +\param var_sparsity [in/out] +On input, for j = 0, ... , n-1, the sparsity pattern with index x_index[j], +is the sparsity for the j-th argument to this atomic function. +On output, for i = 0, ... , m-1, the sparsity pattern with index y_index[i], +is the sparsity for the j-th result for this atomic function. +*/ +template +void call_atomic_for_jac_sparsity( + size_t atom_index , + size_t atom_old , + bool dependency , + const vector& parameter_x , + const vector& type_x , + const pod_vector& x_index , + const pod_vector& y_index , + InternalSparsity& var_sparsity ) +{ CPPAD_ASSERT_UNKNOWN( 0 < atom_index ); + bool set_null = false; + size_t type = 0; // set to avoid warning + std::string* name_ptr = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, atom_index, type, name_ptr, v_ptr); +# ifndef NDEBUG + bool ok = v_ptr != CPPAD_NULL; + if ( ok ) + { + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + afun->set_old(atom_old); + ok = afun->for_sparse_jac( + parameter_x, x_index, y_index, var_sparsity + ); + } + else + { CPPAD_ASSERT_UNKNOWN( type == 3 ); + atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + ok = afun->for_jac_sparsity( + dependency, parameter_x, type_x, x_index, y_index, var_sparsity + ); + } + } + if( ! ok ) + { // now take the extra time to copy the name + std::string name; + local::atomic_index( + set_null, atom_index, type, &name, v_ptr + ); + std::string msg = name; + if( v_ptr == CPPAD_NULL ) + msg += ": this atomic_three function has been deleted"; + else + msg += ": atomic jac_sparsity returned false"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# else + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + afun->set_old(atom_old); + afun->for_sparse_jac( + parameter_x, x_index, y_index, var_sparsity + ); + } + else + { CPPAD_ASSERT_UNKNOWN( type == 3 ); + atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + afun->for_jac_sparsity( + dependency, parameter_x, type_x, x_index, y_index, var_sparsity + ); + } +# endif +} +// ---------------------------------------------------------------------------- +/*! +Reverse Jacobian sparsity callback to atomic functions. + +\tparam Base +is the type corresponding to parameter_x +and to this atomic function. + +\tparam InternalSparsity +is the internal type used to represent sparsity; i.e., +sparse_pack or sparse_list. + +\param atom_index [in] +is the index, in local::atomic_index, corresponding to this atomic function. + +\param atom_old [in] +is the extra id information for this atomic function in the atomic_one case. + +\param dependency [in] +is this a dependency or sparsity calculation. + +\param parameter_x [in] +value of the parameter arguments to the atomic function +(other arguments have the value nan). + +\param type_x [in] +type for each component of x (not used by atomic_two interface). + +\param x_index [in] +is a mapping from the index of an atomic function argument +to the corresponding variable on the tape. + +\param y_index [in] +is a mapping from the index of an atomic function result +to the corresponding variable on the tape. + +\param var_sparsity [in/out] +On input, for i = 0, ... , m-1, the sparsity pattern with index y_index[i], +is the sparsity for the i-th argument to this atomic function. +On output, for j = 0, ... , n-1, the sparsity pattern with index x_index[j], +the sparsity has been updated to remove y as a function of x. +*/ +template +void call_atomic_rev_jac_sparsity( + size_t atom_index , + size_t atom_old , + bool dependency , + const vector& parameter_x , + const vector& type_x , + const pod_vector& x_index , + const pod_vector& y_index , + InternalSparsity& var_sparsity ) +{ CPPAD_ASSERT_UNKNOWN( 0 < atom_index ); + bool set_null = false; + size_t type = 0; // set to avoid warning + std::string* name_ptr = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, atom_index, type, name_ptr, v_ptr); +# ifndef NDEBUG + bool ok = v_ptr != CPPAD_NULL; + if( ok ) + { + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + afun->set_old(atom_old); + ok = afun->rev_sparse_jac( + parameter_x, x_index, y_index, var_sparsity + ); + } + else + { CPPAD_ASSERT_UNKNOWN( type == 3 ); + atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + ok = afun->rev_jac_sparsity( + dependency, parameter_x, type_x, x_index, y_index, var_sparsity + ); + } + } + if( ! ok ) + { // now take the extra time to copy the name + std::string name; + local::atomic_index( + set_null, atom_index, type, &name, v_ptr + ); + std::string msg = name; + if( v_ptr == CPPAD_NULL ) + msg += ": this atomic_three function has been deleted"; + else + msg += ": atomic jac_sparsity returned false"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# else + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + afun->set_old(atom_old); + afun->rev_sparse_jac( + parameter_x, x_index, y_index, var_sparsity + ); + } + else + { CPPAD_ASSERT_UNKNOWN( type == 3 ); + atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + afun->rev_jac_sparsity( + dependency, parameter_x, type_x, x_index, y_index, var_sparsity + ); + } +# endif +} +// ---------------------------------------------------------------------------- +/*! +Forward Hessian sparsity callback to atomic functions. + +\tparam Base +is the type corresponding to parameter_x +and to this atomic function. + +\tparam InternalSparsity +is the internal type used to represent sparsity; i.e., +sparse_pack or sparse_list. + +\param atom_index [in] +is the index, in local::atomic_index, corresponding to this atomic function. + +\param atom_old [in] +is the extra id information for this atomic function in the atomic_one case. + +\param parameter_x [in] +value of the parameter arguments to the atomic function +(other arguments have the value nan). + +\param type_x [in] +type for each component of x (not used by atomic_two interface). + +\param x_index [in] +is a mapping from the index of an atomic function argument +to the corresponding variable on the tape. + +\param y_index [in] +is a mapping from the index of an atomic function result +to the corresponding variable on the tape. + +\param for_jac_sparsity +For j = 0, ... , n-1, the sparsity pattern with index x_index[j], +is the forward Jacobian sparsity for the j-th argument to this atomic function. + +\param rev_jac_sparsity +For i = 0, ... , m-1, the sparsity pattern with index y_index[i], +is the reverse Jacobian sparsity for the i-th result to this atomic function. +This shows which components of the result affect the function we are +computing the Hessian of. + +\param for_hes_sparsity +This is the sparsity pattern for the Hessian. On input, the non-linear +terms in the atomic fuction have not been included. Upon return, they +have been included. +*/ +template +void call_atomic_for_hes_sparsity( + size_t atom_index , + size_t atom_old , + const vector& parameter_x , + const vector& type_x , + const pod_vector& x_index , + const pod_vector& y_index , + const InternalSparsity& for_jac_sparsity , + const InternalSparsity& rev_jac_sparsity , + InternalSparsity& for_hes_sparsity ) +{ CPPAD_ASSERT_UNKNOWN( 0 < atom_index ); + bool set_null = false; + size_t type = 0; // set to avoid warning + std::string* name_ptr = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, atom_index, type, name_ptr, v_ptr); +# ifndef NDEBUG + bool ok = v_ptr != CPPAD_NULL; + if( ok ) + { + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + afun->set_old(atom_old); + ok = afun->for_sparse_hes( + parameter_x, + x_index, + y_index, + for_jac_sparsity, + rev_jac_sparsity, + for_hes_sparsity + ); + } + else + { CPPAD_ASSERT_UNKNOWN( type == 3 ); + atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + ok = afun->for_hes_sparsity( + parameter_x, + type_x, + x_index, + y_index, + for_jac_sparsity, + rev_jac_sparsity, + for_hes_sparsity + ); + } + } + if( ! ok ) + { // now take the extra time to copy the name + std::string name; + local::atomic_index( + set_null, atom_index, type, &name, v_ptr + ); + std::string msg = name; + if( v_ptr == CPPAD_NULL ) + msg += ": this atomic_three function has been deleted"; + else + msg += ": atomic hes_sparsity returned false"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# else + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + afun->set_old(atom_old); + afun->for_sparse_hes( + parameter_x, + x_index, + y_index, + for_jac_sparsity, + rev_jac_sparsity, + for_hes_sparsity + ); + } + else + { CPPAD_ASSERT_UNKNOWN( type == 3 ); + atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + afun->for_hes_sparsity( + parameter_x, + type_x, + x_index, + y_index, + for_jac_sparsity, + rev_jac_sparsity, + for_hes_sparsity + ); + } +# endif +} +// ---------------------------------------------------------------------------- +/*! +Reverse Hessian sparsity callback to atomic functions. + +\tparam Base +is the type corresponding to parameter_x +and to this atomic function. + +\tparam InternalSparsity +is the internal type used to represent sparsity; i.e., +sparse_pack or sparse_list. + +\param atom_index [in] +is the index, in local::atomic_index, corresponding to this atomic function. + +\param atom_old [in] +is the extra id information for this atomic function in the atomic_one case. + +\param parameter_x [in] +value of the parameter arguments to the atomic function +(other arguments have the value nan). + +\param type_x [in] +type for each component of x (not used by atomic_two interface). + +\param x_index [in] +is a mapping from the index of an atomic function argument +to the corresponding variable on the tape. + +\param y_index [in] +is a mapping from the index of an atomic function result +to the corresponding variable on the tape. + +\param for_jac_sparsity +For j = 0, ... , n-1, the sparsity pattern with index x_index[j], +is the forward Jacobian sparsity for the j-th argument to this atomic function. + +\param rev_jac_flag +On input, for i = 0, ... , m-1, rev_jac_flag[ y_index[i] ] is true +if the fuction (we are computing the sparsity for) +depends on the variable y_index[i]. +Upon return, for j = 0, ..., n-1, rev_jac_flag[ x_index[j] ] has been set to +true any of the y_index variables are flagged depnend on x_index[j]. +Otherwise, rev_jac_flag[ x_index[j] ] is not modified. + +\param rev_hes_sparsity +This is the sparsity pattern for the Hessian. +On input, for i = 0, ... , m-1, row y_index[i] is the reverse Hessian sparsity +with one of the partials with respect to to y_index[i]. +Upon return, for j = 0, ..., n-1, the row x_index[j] has been +modified to include components that have a non-zero hessian through +the atomic fucntion with one of the partials w.r.t. x_index[j]. +*/ +template +void call_atomic_rev_hes_sparsity( + size_t atom_index , + size_t atom_old , + const vector& parameter_x , + const vector& type_x , + const pod_vector& x_index , + const pod_vector& y_index , + const InternalSparsity& for_jac_sparsity , + bool* rev_jac_flag , + InternalSparsity& rev_hes_sparsity ) +{ CPPAD_ASSERT_UNKNOWN( 0 < atom_index ); + bool set_null = false; + size_t type = 0; // set to avoid warning + std::string* name_ptr = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, atom_index, type, name_ptr, v_ptr); +# ifndef NDEBUG + bool ok = v_ptr != CPPAD_NULL; + if( ok ) + { + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + afun->set_old(atom_old); + ok = afun->rev_sparse_hes( + parameter_x, + x_index, + y_index, + for_jac_sparsity, + rev_jac_flag, + rev_hes_sparsity + ); + } + else + { CPPAD_ASSERT_UNKNOWN( type == 3 ); + atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + ok = afun->rev_hes_sparsity( + parameter_x, + type_x, + x_index, + y_index, + for_jac_sparsity, + rev_jac_flag, + rev_hes_sparsity + ); + } + } + if( ! ok ) + { // now take the extra time to copy the name + std::string name; + local::atomic_index( + set_null, atom_index, type, &name, v_ptr + ); + std::string msg = name; + if( v_ptr == CPPAD_NULL ) + msg += ": this atomic_three function has been deleted"; + else + msg += ": atomic hes_sparsity returned false"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# else + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + afun->set_old(atom_old); + afun->rev_sparse_hes( + parameter_x, + x_index, + y_index, + for_jac_sparsity, + rev_jac_flag, + rev_hes_sparsity + ); + } + else + { CPPAD_ASSERT_UNKNOWN( type == 3 ); + atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + afun->rev_hes_sparsity( + parameter_x, + type_x, + x_index, + y_index, + for_jac_sparsity, + rev_jac_flag, + rev_hes_sparsity + ); + } +# endif +} +// ---------------------------------------------------------------------------- +/*! +Reverse dependency callback to atomic functions. + +\param atom_index [in] +is the index, in local::atomic_index, corresponding to this atomic function. + +\param atom_old [in] +is the extra id information for this atomic function in the atomic_one case. + +\param parameter_x [in] +is the value of the parameters in the corresponding function call +afun(ax, ay). + +\param type_x [in] +is the type for each x component in the corresponding function call +afun(ax, ay). + +\param depend_x [out] +specifies which components of x affect values we are interested in. + +\param depend_y [in] +specifies which components of y affect values we are interested in. +*/ +template +void call_atomic_rev_depend( + size_t atom_index , + size_t atom_old , + const vector& parameter_x , + const vector& type_x , + vector& depend_x , + const vector& depend_y ) +{ CPPAD_ASSERT_UNKNOWN( 0 < atom_index ); + bool set_null = false; + size_t type = 0; // set to avoid warning + std::string* name_ptr = CPPAD_NULL; + void* v_ptr = CPPAD_NULL; // set to avoid warning + local::atomic_index(set_null, atom_index, type, name_ptr, v_ptr); +# ifndef NDEBUG + bool ok = v_ptr != CPPAD_NULL; + if( ok ) + { + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + afun->set_old(atom_old); + vector empty; + ok = afun->rev_depend(parameter_x, type_x, depend_x, depend_y); + } + else + { CPPAD_ASSERT_UNKNOWN( type == 3 ); + atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + ok = afun->rev_depend(parameter_x, type_x, depend_x, depend_y); + } + } + if( ! ok ) + { // now take the extra time to copy the name + std::string name; + local::atomic_index(set_null, atom_index, type, &name, v_ptr); + std::string msg = name; + if( v_ptr == CPPAD_NULL ) + msg += ": this atomic_three function has been deleted"; + else + msg += ": atomic rev_depend returned false"; + CPPAD_ASSERT_KNOWN(false, msg.c_str() ); + } +# else + if( type == 2 ) + { atomic_base* afun = + reinterpret_cast< atomic_base* >(v_ptr); + vector empty; + afun->set_old(atom_old); + afun->rev_depend(parameter_x, type_x, depend_x, depend_y); + } + else + { atomic_three* afun = + reinterpret_cast< atomic_three* >(v_ptr); + afun->rev_depend(parameter_x, type_x, depend_x, depend_y); + } +# endif +} + + +} } } // END_CPAPD_LOCAL_SWEEP_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sweep/dynamic.hpp cppad-2019.02.00.0/include/cppad/local/sweep/dynamic.hpp --- cppad-2018.00.00.0/include/cppad/local/sweep/dynamic.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sweep/dynamic.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,540 @@ +# ifndef CPPAD_LOCAL_SWEEP_DYNAMIC_HPP +# define CPPAD_LOCAL_SWEEP_DYNAMIC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include + +// BEGIN_CPPAD_LOCAL_SWEEP_NAMESPACE +namespace CppAD { namespace local { namespace sweep { +/*! +\file sweep/dynamic.hpp +Under Consruction +*/ + +/*! +\def CPPAD_DYNAMIC_TRACE +This value is either zero or one. +Zero is the normal operational value. +If it is one, a trace for each dynamic parameter is compuation is printed. +Sometimes it is usefull to trace f.new_dynamic with the same +dynamic parameter values as during the recording +(to debug the recording process). +*/ +# define CPPAD_DYNAMIC_TRACE 0 + +/*! +Compute dynamic parameters. + +\tparam Base +The type of the parameters. + +\tparam BaseVector +is a simple vector class with elements of type Base. + +\param ind_dynamic +new value for the independent dynamic parameter vector. + +\param all_par_vec +is the vector of all the parameters. +Ths constant parameters are inputs and the dynamic parameters are outputs. + +\param dyn_par_is +is a vector with the same length as par_vec. +The i-th parameter is dynamic if and only if dyn_par_is[i] is true. + +\param dyn_ind2par_ind +is a vector with length equal to the number of dynamic parameters. +The element dyn_ind2par_ind[j] is the index in all_par_vec corresponding +to the j-th dynamic parameter. +Note that if dyn_par_is[i] is false, the i-th parameter does not +appear in this vector. + +\param dyn_par_op +is a vector with length equal to the number of dynamic parameters. +The element dyn_par_op_[j] is the operator for the j-th dynamic parameter. +Note that if dyn_par_is[i] is false, the i-th parameter does not +have a parameter in this list. + +\param dyn_par_arg +is a vector containing the arguments for the dynamic parameters. +The first argument for the j-th dynamic parameter is dyn_par_arg[k] +where +\code + k = NumArg( dyn_par_op[0] ) + ... + NumArg( dyn_par_op[j-1] ) +\endcode +The arguments for each dynamic parameter have index value +lower than the index value for the parameter. + +\param not_used_rec_base +Specifies RecBase for this call. +*/ +template +void dynamic( + pod_vector_maybe& all_par_vec , + const BaseVector& ind_dynamic , + const pod_vector& dyn_par_is , + const pod_vector& dyn_ind2par_ind , + const pod_vector& dyn_par_op , + const pod_vector& dyn_par_arg , + const RecBase& not_used_rec_base ) +{ + // number of dynamic parameters + size_t num_dynamic_par = dyn_ind2par_ind.size(); + + // vectors used in call to atomic fuctions + vector type_x; + vector taylor_x, taylor_y; +# ifndef NDEBUG + for(size_t j = 0; j < ind_dynamic.size(); ++j) + CPPAD_ASSERT_UNKNOWN( + dyn_par_is[j+1] && op_code_dyn( dyn_par_op[j] ) == ind_dyn + ); +# endif +# if CPPAD_DYNAMIC_TRACE + const char* cond_exp_name[] = { + "CondExpLt", + "CondExpLe", + "CondExpEq", + "CondExpGe", + "CondExpGt", + "CondExpNe" + }; + std::cout + << std::endl + << std::setw(10) << std::left << "index" + << std::setw(10) << std::left << "old" + << std::setw(10) << std::left << "new" + << std::setw(11) << std::left << "op" + << std::setw(26) << std::right << "dynamic i=, constant v=" + << std::endl; +# endif + // used to hold the first two parameter arguments + const Base* par[2]; + for(size_t j = 0; j < 2; ++j) + par[j] = CPPAD_NULL; + // + // Initialize index in dyn_par_arg + size_t i_arg = 0; + // + // Loop throubh the dynamic parameters + size_t i_dyn = 0; + while(i_dyn < num_dynamic_par) + { // number of dynamic parameters created by this operator + size_t n_dyn = 1; + // + // parametere index for this dynamic parameter + size_t i_par = size_t( dyn_ind2par_ind[i_dyn] ); + // +# if CPPAD_DYNAMIC_TRACE + Base old_value = all_par_vec[i_par]; +# endif + // + // operator for this dynamic parameter + op_code_dyn op = op_code_dyn( dyn_par_op[i_dyn] ); + // + // number of arguments for this operator + size_t n_arg = num_arg_dyn(op); + // + if( (op != cond_exp_dyn) & (op != dis_dyn ) ) + { // all arguments are parameters + // except for call_dyn and result_dyn which has n_arg = 0 + CPPAD_ASSERT_UNKNOWN( n_arg <= 2 ); + for(size_t j = 0; j < n_arg; ++j) + par[j] = & all_par_vec[ dyn_par_arg[i_arg + j] ]; + } + // + switch(op) + { + // --------------------------------------------------------------- + // standard_math_98 + // acos + case acos_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = acos( *par[0] ); + break; + + // asin + case asin_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = asin( *par[0] ); + break; + + // atan + case atan_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = atan( *par[0] ); + break; + + // cos + case cos_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = cos( *par[0] ); + break; + + // cosh + case cosh_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = cosh( *par[0] ); + break; + + // ind + case ind_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 0 ); + CPPAD_ASSERT_UNKNOWN( i_par == i_dyn + 1 ); + all_par_vec[i_par] = ind_dynamic[i_dyn]; + break; + + // exp + case exp_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = exp( *par[0] ); + break; + + // fabs + case fabs_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = fabs( *par[0] ); + break; + + // log + case log_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = log( *par[0] ); + break; + + // sin + case sin_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = sin( *par[0] ); + break; + + // sinh + case sinh_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = sinh( *par[0] ); + break; + + // sqrt + case sqrt_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = sqrt( *par[0] ); + break; + + // tan + case tan_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = tan( *par[0] ); + break; + + // tanh + case tanh_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = tanh( *par[0] ); + break; + +# if CPPAD_USE_CPLUSPLUS_2011 + // --------------------------------------------------------------- + // asinh + case asinh_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = asinh( *par[0] ); + break; + + // acosh + case acosh_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = acosh( *par[0] ); + break; + + // atanh + case atanh_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = atanh( *par[0] ); + break; + + // expm1 + case expm1_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = expm1( *par[0] ); + break; + + // erf + case erf_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = erf( *par[0] ); + break; + + // log1p + case log1p_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = log1p( *par[0] ); + break; +# endif + // --------------------------------------------------------------- + // abs + case abs_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = fabs( *par[0] ); + break; + + // add + case add_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 2 ); + all_par_vec[i_par] = *par[0] + *par[1]; + break; + + // div + case div_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 2 ); + all_par_vec[i_par] = *par[0] / *par[1]; + break; + + // mul + case mul_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 2 ); + all_par_vec[i_par] = *par[0] * *par[1]; + break; + + // pow + case pow_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 2 ); + all_par_vec[i_par] = pow( *par[0], *par[1] ); + break; + + // sign + case sign_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 1 ); + all_par_vec[i_par] = sign( *par[0] ); + break; + + // sub + case sub_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 2 ); + all_par_vec[i_par] = *par[0] - *par[1]; + break; + + // zmul + case zmul_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 2 ); + all_par_vec[i_par] = azmul( *par[0], *par[1] ); + break; + + // --------------------------------------------------------------- + // discrete(index, argument) + case dis_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 2 ); + all_par_vec[i_par] = discrete::eval( + size_t( dyn_par_arg[i_arg + 0] ) , // index + all_par_vec[ dyn_par_arg[i_arg + 1] ] // argument + ); +# if CPPAD_DYNAMIC_TRACE + std::cout + << std::setw(10) << std::left << i_par + << std::setw(10) << std::left << old_value + << std::setw(10) << std::left << all_par_vec[i_par] + << "=" + << std::setw(10) << std::right << op_name_dyn(op) + << "(" + << std::setw(12) << std::right << + discrete::name( size_t( dyn_par_arg[i_arg + 0] ) ); + if( dyn_par_is[ dyn_par_arg[i_arg + 1] ] ) + { std::cout << ", i=" << std::setw(10) << std::right + << dyn_par_arg[i_arg + 1]; + } + else + { std::cout << ", v=" << std::setw(10) << std::right + << all_par_vec[ dyn_par_arg[i_arg + 1] ]; + } + std::cout << ")" << std::endl; +# endif + break; + + // --------------------------------------------------------------- + // cond_exp(cop, left, right, if_true, if_false) + // (not yet implemented) + case cond_exp_dyn: + CPPAD_ASSERT_UNKNOWN( n_arg == 5 ); + all_par_vec[i_par] = CondExpOp( + CompareOp( dyn_par_arg[i_arg + 0] ) , // cop + all_par_vec[ dyn_par_arg[i_arg + 1] ] , // left + all_par_vec[ dyn_par_arg[i_arg + 2] ] , // right + all_par_vec[ dyn_par_arg[i_arg + 3] ] , // if_true + all_par_vec[ dyn_par_arg[i_arg + 4] ] // if_false + ); +# if CPPAD_DYNAMIC_TRACE + std::cout + << std::setw(10) << std::left << i_par + << std::setw(10) << std::left << old_value + << std::setw(10) << std::left << all_par_vec[i_par] + << "=" + << std::setw(10) << std::right + << cond_exp_name[ dyn_par_arg[i_arg + 0] ] + << "("; + for(size_t i = 1; i < 5; ++i) + { if( dyn_par_is[ dyn_par_arg[i_arg + i] ] ) + { std::cout << "i=" << std::setw(10) << std::right + << dyn_par_arg[i_arg + i]; + } + else + { std::cout << "v=" << std::setw(10) << std::right + << all_par_vec[ dyn_par_arg[i_arg + i] ]; + } + if( i < 4 ) + std::cout << ","; + } + std::cout << ")" << std::endl; +# endif + break; + // --------------------------------------------------------------- + // atomic function results + case result_dyn: + break; + + // atomic function call + case call_dyn: + { size_t atom_index = size_t( dyn_par_arg[i_arg + 0] ); + size_t n = size_t( dyn_par_arg[i_arg + 1] ); + size_t m = size_t( dyn_par_arg[i_arg + 2] ); + n_dyn = size_t( dyn_par_arg[i_arg + 3] ); + n_arg = 5 + n + m; + CPPAD_ASSERT_UNKNOWN( + size_t( dyn_par_arg[i_arg + 4 + n + m] ) == n_arg + ); + // + size_t need_y = size_t(dynamic_enum); + size_t order_low = 0; + size_t order_up = 0; + size_t atom_old = 0; // not used + type_x.resize(n); + taylor_x.resize(n); + taylor_y.resize(m); + for(size_t j = 0; j < n; ++j) + { addr_t arg_j = dyn_par_arg[i_arg + 4 + j]; + taylor_x[j] = all_par_vec[ arg_j ]; + if( arg_j == 0 ) + type_x[j] = variable_enum; + else if ( dyn_par_is[arg_j] ) + type_x[j] = dynamic_enum; + else + type_x[j] = constant_enum; + } + call_atomic_forward( + taylor_x, + type_x, + need_y, + order_low, + order_up, + atom_index, + atom_old, + taylor_x, + taylor_y + ); +# if CPPAD_DYNAMIC_TRACE + // get the name of this atomic function + bool set_null = false; + size_t type = 0; // set to avoid warning + std::string name; + void* v_ptr = CPPAD_NULL; // set to avoid warning + atomic_index( + set_null, atom_index, type, &name, v_ptr + ); + std::cout << "call_dyn " << name << " arguments\n"; + for(size_t j = 0; j < n; ++j) + { std::cout << "index = " << j + << ", value = " << taylor_x[j] << std::endl; + } + std::cout << "call_dyn " << name << " results\n"; +# endif +# ifndef NDEBUG + size_t count_dyn = 0; +# endif + for(size_t i = 0; i < m; ++i) + { i_par = size_t( dyn_par_arg[i_arg + 4 + n + i] ); + if( dyn_par_is[i_par] ) + { CPPAD_ASSERT_UNKNOWN( i_par != 0 ); + all_par_vec[i_par] = taylor_y[i]; +# ifndef NDEBUG + ++count_dyn; +# endif +# if CPPAD_DYNAMIC_TRACE + std::cout + << std::setw(10) << std::left << i_par + << std::setw(10) << std::left << old_value + << std::setw(10) << std::left << all_par_vec[i_par] + << "= " << name << "_" << i << std::endl; +# endif + } + } + CPPAD_ASSERT_UNKNOWN( count_dyn == n_dyn ); +# if CPPAD_DYNAMIC_TRACE + std::cout << "end atomic dynamic parameter results\n"; +# endif + } + break; + + // --------------------------------------------------------------- + default: + std::cerr << "op_code_dyn = " << op_name_dyn(op) << std::endl; + CPPAD_ASSERT_UNKNOWN(false); + break; + } +# if CPPAD_DYNAMIC_TRACE + if( + (op != cond_exp_dyn) & + (op != dis_dyn ) & + (op != call_dyn ) & + (op != result_dyn ) ) + { + std::cout + << std::setw(10) << std::left << i_par + << std::setw(10) << std::left << old_value + << std::setw(10) << std::left << all_par_vec[i_par] + << "=" + << std::setw(10) << std::right << op_name_dyn(op) + << "("; + if( 0 < n_arg ) + { if( dyn_par_is[ dyn_par_arg[i_arg + 0] ] ) + { std::cout << "i=" << std::setw(10) << std::right + << dyn_par_arg[i_arg + 0]; + } + else + { std::cout << "v=" << std::setw(10) << std::right + << all_par_vec[ dyn_par_arg[i_arg + 0] ]; + } + } + if( 1 < n_arg ) + { if( dyn_par_is[ dyn_par_arg[i_arg + 1] ] ) + { std::cout << ", i=" << std::setw(10) << std::right + << dyn_par_arg[i_arg + 1]; + } + else + { std::cout << ", v=" << std::setw(10) << std::right + << all_par_vec[ dyn_par_arg[i_arg + 1] ]; + } + } + std::cout << ")" << std::endl; + } +# endif + i_arg += n_arg; + i_dyn += n_dyn; + } + CPPAD_ASSERT_UNKNOWN( i_arg == dyn_par_arg.size() ) + return; +} + +// preprocessor symbols that are local to this file +# undef CPPAD_DYNAMIC_TRACE + +} } } // END_CPPAD_LOCAL_SWEEP_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sweep/for_hes.hpp cppad-2019.02.00.0/include/cppad/local/sweep/for_hes.hpp --- cppad-2018.00.00.0/include/cppad/local/sweep/for_hes.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sweep/for_hes.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,589 @@ +# ifndef CPPAD_LOCAL_SWEEP_FOR_HES_HPP +# define CPPAD_LOCAL_SWEEP_FOR_HES_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include + +// BEGIN_CPPAD_LOCAL_SWEEP_NAMESPACE +namespace CppAD { namespace local { namespace sweep { +/*! +\file sweep/for_hes.hpp +Compute Forward mode Hessian sparsity patterns. +*/ + +/*! +\def CPPAD_FOR_HES_TRACE +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. +*/ +# define CPPAD_FOR_HES_TRACE 0 + +/*! +Given the forward Jacobian sparsity pattern for all the variables, +and the reverse Jacobian sparsity pattern for the dependent variables, +ForHesSweep computes the Hessian sparsity pattern for all the independent +variables. + +\tparam Base +this operation sequence was recorded using AD. + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or sparse_list. + +\param n +is the number of independent variables on the tape. + +\param numvar +is the total number of variables on the tape; i.e., + play->num_var_rec(). +This is also the number of rows in the entire sparsity pattern + for_hes_sparse. + +\param play +The information stored in play +is a recording of the operations corresponding to a function +\f[ + F : {\bf R}^n \rightarrow {\bf R}^m +\f] +where \f$ n \f$ is the number of independent variables +and \f$ m \f$ is the number of dependent variables. + +\param for_jac_sparse +For i = 0 , ... , 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 for_jac_sparse. + +\param rev_jac_sparse +\b Input: +For i = 0, ... , numvar - 1 +the if the function we are computing the Hessian for has a non-zero +derivative w.r.t. variable with index i, +the set with index i has element zero. +Otherwise it has no elements. + +\param for_hes_sparse +The forward Hessian sparsity pattern for the variable with index i +corresponds to the set with index i in for_hes_sparse. +The number of rows in this sparsity patter is n+1 and the row +with index zero is not used. +\n +\n +\b Input: For i = 1 , ... , n +the forward Hessian sparsity pattern for the variable with index i is empty. +\n +\n +\b Output: For j = 1 , ... , n, +the forward Hessian sparsity pattern for the independent dependent variable +with index (j-1) is given by the set with index j +in for_hes_sparse. + +\param not_used_rec_base +Specifies RecBase for this call. +*/ + +template +void for_hes( + const local::player* play, + size_t n, + size_t numvar, + const Vector_set& for_jac_sparse, + const Vector_set& rev_jac_sparse, + Vector_set& for_hes_sparse, + const RecBase& not_used_rec_base +) +{ + // length of the parameter vector (used by CppAD assert macros) + const size_t num_par = play->num_par_rec(); + + size_t i, j, k; + + // check numvar argument + size_t limit = n+1; + CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar ); + CPPAD_ASSERT_UNKNOWN( for_jac_sparse.n_set() == numvar ); + CPPAD_ASSERT_UNKNOWN( for_hes_sparse.n_set() == limit ); + CPPAD_ASSERT_UNKNOWN( numvar > 0 ); + + // upper limit exclusive for set elements + CPPAD_ASSERT_UNKNOWN( for_jac_sparse.end() == limit ); + CPPAD_ASSERT_UNKNOWN( for_hes_sparse.end() == limit ); + + // vecad_sparsity contains a sparsity pattern for each 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(); + Vector_set vecad_sparse; + pod_vector vecad_ind; + pod_vector vecad_jac; + if( num_vecad_vec > 0 ) + { size_t length; + vecad_sparse.resize(num_vecad_vec, limit); + vecad_ind.extend(num_vecad_ind); + vecad_jac.extend(num_vecad_vec); + j = 0; + for(i = 0; i < num_vecad_vec; i++) + { // length of this VecAD + length = play->GetVecInd(j); + // set vecad_ind to proper index for this VecAD + 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 + vecad_jac[i] = false; + } + CPPAD_ASSERT_UNKNOWN( j == play->num_vec_ind_rec() ); + } + // ------------------------------------------------------------------------ + // work space used by AFunOp. + vector atom_x; //// value of parameter arguments to function + vector type_x; // argument types + pod_vector atom_ix; // variable index (on tape) for each argument + pod_vector atom_iy; // variable index (on tape) for each result + // + // information set by atomic forward (initialization to avoid warnings) + size_t atom_index=0, atom_old=0, atom_m=0, atom_n=0, atom_i=0, atom_j=0; + // information set by atomic forward (necessary initialization) + enum_atom_state atom_state = start_atom; + // ------------------------------------------------------------------------- + // + // pointer to the beginning of the parameter vector + // (used by atomic functions) + const Base* parameter = CPPAD_NULL; + if( num_par > 0 ) + parameter = play->GetPar(); + // + // which parametes are dynamic + const pod_vector& dyn_par_is( play->dyn_par_is() ); + // + // skip the BeginOp at the beginning of the recording + play::const_sequential_iterator itr = play->begin(); + // op_info + OpCode op; + size_t i_var; + const Addr* arg; + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == BeginOp ); +# if CPPAD_FOR_HES_TRACE + vector atom_funrp; // parameter index for FunrpOp operators + std::cout << std::endl; + CppAD::vectorBool zf_value(limit); + CppAD::vectorBool zh_value(limit * limit); +# endif + bool flag; // temporary for use in switch cases below + bool more_operators = true; + while(more_operators) + { + // next op + (++itr).op_info(op, arg, i_var); + + // does the Hessian in question have a non-zero derivative + // with respect to this variable + bool include = NumRes(op) > 0; + if( include ) + include = rev_jac_sparse.is_element(i_var, 0); + // + // operators to include even if derivative is zero + include |= op == EndOp; + include |= op == CSkipOp; + include |= op == CSumOp; + include |= op == AFunOp; + include |= op == FunapOp; + include |= op == FunavOp; + include |= op == FunrpOp; + include |= op == FunrvOp; + // + if( include ) switch( op ) + { // operators that should not occurr + // case BeginOp + // ------------------------------------------------- + + // operators that do not affect hessian + case AbsOp: + case AddvvOp: + case AddpvOp: + case CExpOp: + case DisOp: + case DivvpOp: + case InvOp: + case LdpOp: + case LdvOp: + case MulpvOp: + case ParOp: + case PriOp: + case SignOp: + case StppOp: + case StpvOp: + case StvpOp: + case StvvOp: + case SubvvOp: + case SubpvOp: + case SubvpOp: + case ZmulpvOp: + case ZmulvpOp: + break; + // ------------------------------------------------- + + // nonlinear unary operators + case AcosOp: + case AsinOp: + case AtanOp: + case CosOp: + case CoshOp: + case ExpOp: + case LogOp: + case SinOp: + case SinhOp: + case SqrtOp: + case TanOp: + case TanhOp: +# if CPPAD_USE_CPLUSPLUS_2011 + case AcoshOp: + case AsinhOp: + case AtanhOp: + case Expm1Op: + case Log1pOp: +# endif + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ) + forward_sparse_hessian_nonlinear_unary_op( + size_t(arg[0]), for_jac_sparse, for_hes_sparse + ); + break; + // ------------------------------------------------- + + case CSkipOp: + itr.correct_before_increment(); + break; + // ------------------------------------------------- + + case CSumOp: + itr.correct_before_increment(); + break; + // ------------------------------------------------- + + case DivvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + forward_sparse_hessian_div_op( + arg, for_jac_sparse, for_hes_sparse + ); + break; + // ------------------------------------------------- + + case DivpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + forward_sparse_hessian_nonlinear_unary_op( + size_t(arg[1]), for_jac_sparse, for_hes_sparse + ); + break; + // ------------------------------------------------- + + case EndOp: + CPPAD_ASSERT_NARG_NRES(op, 0, 0); + more_operators = false; + break; + // ------------------------------------------------- + + case ErfOp: + // arg[1] is always the parameter 0 + // arg[2] is always the parameter 2 / sqrt(pi) + CPPAD_ASSERT_NARG_NRES(op, 3, 5); + forward_sparse_hessian_nonlinear_unary_op( + size_t(arg[0]), for_jac_sparse, for_hes_sparse + ); + break; + // ------------------------------------------------- + + // ------------------------------------------------- + // logical comparision operators + case EqppOp: + case EqpvOp: + case EqvvOp: + case LtppOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case LeppOp: + case LepvOp: + case LevpOp: + case LevvOp: + case NepvOp: + case NeppOp: + case NevvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 0); + break; + // ------------------------------------------------- + + case MulvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + forward_sparse_hessian_mul_op( + arg, for_jac_sparse, for_hes_sparse + ); + break; + // ------------------------------------------------- + + case PowpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 3) + forward_sparse_hessian_nonlinear_unary_op( + size_t(arg[1]), for_jac_sparse, for_hes_sparse + ); + break; + // ------------------------------------------------- + + case PowvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 3) + forward_sparse_hessian_nonlinear_unary_op( + size_t(arg[0]), for_jac_sparse, for_hes_sparse + ); + break; + // ------------------------------------------------- + + case PowvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 3) + forward_sparse_hessian_pow_op( + arg, for_jac_sparse, for_hes_sparse + ); + break; + // ------------------------------------------------- + + case AFunOp: + // start or end an atomic function call + CPPAD_ASSERT_UNKNOWN( + atom_state == start_atom || atom_state == end_atom + ); + flag = atom_state == start_atom; + play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + if( flag ) + { atom_state = arg_atom; + atom_i = 0; + atom_j = 0; + // + atom_x.resize( atom_n ); + type_x.resize( atom_n ); + atom_ix.resize( atom_n ); + atom_iy.resize( atom_m ); +# if CPPAD_FOR_HES_TRACE + atom_funrp.resize( atom_m ); +# endif + } + else + { CPPAD_ASSERT_UNKNOWN( atom_i == atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + atom_state = start_atom; + // + call_atomic_for_hes_sparsity( + atom_index, atom_old, atom_x, type_x, atom_ix, atom_iy, + for_jac_sparse, rev_jac_sparse, for_hes_sparse + ); + } + break; + + case FunapOp: + // parameter argument for a atomic function + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j < atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + atom_x[atom_j] = parameter[arg[0]]; + // argument type + if( dyn_par_is[arg[0]] ) + type_x[atom_j] = dynamic_enum; + else + type_x[atom_j] = constant_enum; + atom_ix[atom_j] = 0; // special variable used for parameters + // + ++atom_j; + if( atom_j == atom_n ) + atom_state = ret_atom; + break; + + case FunavOp: + // variable argument for a atomic function + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j < atom_n ); + // + // arguemnt variables not avaialbe during sparisty calculations + atom_x[atom_j] = CppAD::numeric_limits::quiet_NaN(); + type_x[atom_j] = variable_enum; + atom_ix[atom_j] = size_t(arg[0]); // variable for this argument + // + ++atom_j; + if( atom_j == atom_n ) + atom_state = ret_atom; + break; + + case FunrpOp: + // parameter result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i < atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + atom_iy[atom_i] = 0; // special variable used for parameters +# if CPPAD_FOR_HES_TRACE + // remember argument for delayed tracing + atom_funrp[atom_i] = arg[0]; +# endif + ++atom_i; + if( atom_i == atom_m ) + atom_state = end_atom; + break; + + case FunrvOp: + // variable result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i < atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + // + atom_iy[atom_i] = i_var; // variable index for this result + // + ++atom_i; + if( atom_i == atom_m ) + atom_state = end_atom; + break; + // ------------------------------------------------- + + case ZmulvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + forward_sparse_hessian_mul_op( + arg, for_jac_sparse, for_hes_sparse + ); + break; + + // ------------------------------------------------- + + default: + CPPAD_ASSERT_UNKNOWN(0); + } +# if CPPAD_FOR_HES_TRACE + typedef typename Vector_set::const_iterator const_iterator; + if( op == AFunOp && atom_state == start_atom ) + { // print operators that have been delayed + CPPAD_ASSERT_UNKNOWN( atom_m == atom_iy.size() ); + CPPAD_ASSERT_UNKNOWN( itr.op_index() > atom_m ); + CPPAD_ASSERT_NARG_NRES(FunrpOp, 1, 0); + CPPAD_ASSERT_NARG_NRES(FunrvOp, 0, 1); + addr_t arg_tmp[1]; + for(k = 0; k < atom_m; k++) + { size_t k_var = atom_iy[k]; + // value for this variable + for(i = 0; i < limit; i++) + { zf_value[i] = false; + for(j = 0; j < limit; j++) + zh_value[i * limit + j] = false; + } + const_iterator itr_1(for_jac_sparse, i_var); + j = *itr_1; + while( j < limit ) + { zf_value[j] = true; + j = *(++itr_1); + } + for(i = 0; i < limit; i++) + { const_iterator itr_2(for_hes_sparse, i); + j = *itr_2; + while( j < limit ) + { zh_value[i * limit + j] = true; + j = *(++itr_2); + } + } + OpCode op_tmp = FunrvOp; + if( k_var == 0 ) + { op_tmp = FunrpOp; + arg_tmp[0] = atom_funrp[k]; + } + // k_var is zero when there is no result + printOp( + std::cout, + play, + itr.op_index() - atom_m + k, + k_var, + op_tmp, + arg_tmp + ); + if( k_var > 0 ) printOpResult( + std::cout, + 1, + &zf_value, + 1, + &zh_value + ); + std::cout << std::endl; + } + } + for(i = 0; i < limit; i++) + { zf_value[i] = false; + for(j = 0; j < limit; j++) + zh_value[i * limit + j] = false; + } + const_iterator itr_1(for_jac_sparse, i_var); + j = *itr_1; + while( j < limit ) + { zf_value[j] = true; + j = *(++itr_1); + } + for(i = 0; i < limit; i++) + { const_iterator itr_2(for_hes_sparse, i); + j = *itr_2; + while( j < limit ) + { zh_value[i * limit + j] = true; + j = *(++itr_2); + } + } + // must delay print for these cases till after atomic function call + bool delay_print = op == FunrpOp; + delay_print |= op == FunrvOp; + if( ! delay_print ) + { printOp( + std::cout, + play, + itr.op_index(), + i_var, + op, + arg + ); + if( NumRes(op) > 0 && (! delay_print) ) printOpResult( + std::cout, + 1, + &zf_value, + 1, + &zh_value + ); + std::cout << std::endl; + } + } + std::cout << std::endl; +# else + } +# endif + + return; +} +} } } // END_CPPAD_LOCAL_SWEEP_NAMESPACE + +// preprocessor symbols that are local to this file +# undef CPPAD_FOR_HES_TRACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sweep/for_jac.hpp cppad-2019.02.00.0/include/cppad/local/sweep/for_jac.hpp --- cppad-2018.00.00.0/include/cppad/local/sweep/for_jac.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sweep/for_jac.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,846 @@ +# ifndef CPPAD_LOCAL_SWEEP_FOR_JAC_HPP +# define CPPAD_LOCAL_SWEEP_FOR_JAC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include +# include +# include + +// BEGIN_CPPAD_LOCAL_SWEEP_NAMESPACE +namespace CppAD { namespace local { namespace sweep { +/*! +\file sweep/for_jac.hpp +Compute Forward mode Jacobian sparsity patterns. +*/ + +/*! +\def CPPAD_FOR_JAC_TRACE +This value is either zero or one. +Zero is the normal operational value. +If it is one, a trace of every for_jac_sweep computation is printed. +*/ +# define CPPAD_FOR_JAC_TRACE 0 + +/*! +Given the sparsity pattern for the independent variables, +ForJacSweep computes the sparsity pattern for all the other variables. + +\tparam Base +this operation sequence was recorded using AD. + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or 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. + +\param numvar +is the total number of variables on the tape; i.e., + play->num_var_rec(). + +\param play +The information stored in play +is a recording of the operations corresponding to a function +\f[ + F : {\bf R}^n \rightarrow {\bf R}^m +\f] +where \f$ n \f$ is the number of independent variables +and \f$ m \f$ is the number of dependent variables. + +\param var_sparsity +\b Input: For j = 1 , ... , n, +the sparsity pattern for the independent variable with index (j-1) +corresponds to the set with index j in var_sparsity. +\n +\n +\b Output: For i = n + 1 , ... , numvar - 1, +the sparsity pattern for the variable with index i on the tape +corresponds to the set with index i in var_sparsity. + +\par Checked Assertions: +\li numvar == var_sparsity.n_set() +\li numvar == play->num_var_rec() + +\param not_used_rec_base +Specifies RecBase for this call. +*/ + +template +void for_jac( + const local::player* play, + bool dependency , + size_t n , + size_t numvar , + Vector_set& var_sparsity, + const RecBase& not_used_rec_base +) +{ + size_t i, j, k; + + // check numvar argument + CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar ); + CPPAD_ASSERT_UNKNOWN( var_sparsity.n_set() == numvar ); + + // length of the parameter vector (used by CppAD assert macros) + const size_t num_par = play->num_par_rec(); + + // cum_sparsity accumulates sparsity pattern a cumulative sum + size_t limit = var_sparsity.end(); + + // vecad_sparsity contains a sparsity pattern from each VecAD object + // to all the other variables. + // vecad_ind maps a VecAD index (the beginning of the + // VecAD object) to its from index in vecad_sparsity + size_t num_vecad_ind = play->num_vec_ind_rec(); + size_t num_vecad_vec = play->num_vecad_vec_rec(); + Vector_set vecad_sparsity; + pod_vector vecad_ind; + if( num_vecad_vec > 0 ) + { size_t length; + vecad_sparsity.resize(num_vecad_vec, limit); + vecad_ind.extend(num_vecad_ind); + j = 0; + for(i = 0; i < num_vecad_vec; i++) + { // length of this VecAD + length = play->GetVecInd(j); + // set to proper index for this VecAD + vecad_ind[j] = i; + for(k = 1; k <= length; k++) + vecad_ind[j+k] = num_vecad_vec; // invalid index + // start of next VecAD + j += length + 1; + } + CPPAD_ASSERT_UNKNOWN( j == play->num_vec_ind_rec() ); + } + + // -------------------------------------------------------------- + // work space used by AFunOp. + vector atom_x; //// value of parameter arguments to function + vector type_x; // argument types + pod_vector atom_ix; // variable index (on tape) for each argument + pod_vector atom_iy; // variable index (on tape) for each result + // + // information set by atomic forward (initialization to avoid warnings) + size_t atom_index=0, atom_old=0, atom_m=0, atom_n=0, atom_i=0, atom_j=0; + // information set by atomic forward (necessary initialization) + enum_atom_state atom_state = start_atom; + // -------------------------------------------------------------- + // + // pointer to the beginning of the parameter vector + // (used by atomic functions) + const Base* parameter = CPPAD_NULL; + if( num_par > 0 ) + parameter = play->GetPar(); + // + // which parametes are dynamic + const pod_vector& dyn_par_is( play->dyn_par_is() ); + // +# if CPPAD_FOR_JAC_TRACE + vector atom_funrp; // parameter index for FunrpOp operators + std::cout << std::endl; + CppAD::vectorBool z_value(limit); +# endif + + // skip the BeginOp at the beginning of the recording + play::const_sequential_iterator itr = play->begin(); + // op_info + OpCode op; + size_t i_var; + const Addr* arg; + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == BeginOp ); + // + bool more_operators = true; + while(more_operators) + { bool flag; // temporary for use in switch cases. + + // this op + (++itr).op_info(op, arg, i_var); + + // rest of information depends on the case + switch( op ) + { + case AbsOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case AddvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_binary_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + + case AddpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + break; + // ------------------------------------------------- + + case AcosOp: + // sqrt(1 - x * x), acos(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + 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, size_t(arg[0]), var_sparsity + ); + break; +# endif + // ------------------------------------------------- + + case AsinOp: + // sqrt(1 - x * x), asin(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + 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, size_t(arg[0]), var_sparsity + ); + break; +# endif + // ------------------------------------------------- + + case AtanOp: + // 1 + x * x, atan(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + 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, size_t(arg[0]), var_sparsity + ); + break; +# endif + // ------------------------------------------------- + + case CSkipOp: + itr.correct_before_increment(); + break; + // ------------------------------------------------- + + case CSumOp: + forward_sparse_jacobian_csum_op( + i_var, arg, var_sparsity + ); + itr.correct_before_increment(); + break; + // ------------------------------------------------- + + case CExpOp: + forward_sparse_jacobian_cond_op( + dependency, i_var, arg, num_par, var_sparsity + ); + break; + // -------------------------------------------------- + + case CosOp: + // sin(x), cos(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // --------------------------------------------------- + + case CoshOp: + // sinh(x), cosh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case DisOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + // derivative is identically zero but dependency is not + if( dependency ) forward_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + else + var_sparsity.clear(i_var); + break; + // ------------------------------------------------- + + case DivvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_binary_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + + case DivpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + break; + // ------------------------------------------------- + + case DivvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case EndOp: + CPPAD_ASSERT_NARG_NRES(op, 0, 0); + more_operators = false; + break; + // ------------------------------------------------- + + 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, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case ExpOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; +# endif + // ------------------------------------------------- + + case InvOp: + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + // sparsity pattern is already defined + break; + // ------------------------------------------------- + + case LdpOp: + forward_sparse_load_op( + dependency, + op, + i_var, + arg, + num_vecad_ind, + vecad_ind.data(), + var_sparsity, + vecad_sparsity + ); + break; + // ------------------------------------------------- + + case LdvOp: + forward_sparse_load_op( + dependency, + op, + i_var, + arg, + num_vecad_ind, + vecad_ind.data(), + var_sparsity, + vecad_sparsity + ); + break; + // ------------------------------------------------- + + case EqppOp: + case EqpvOp: + case EqvvOp: + case LtppOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case LeppOp: + case LepvOp: + case LevpOp: + case LevvOp: + case NeppOp: + 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( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; +# endif + // ------------------------------------------------- + + case MulpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + 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); + break; + // ------------------------------------------------- + + case PowvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 3); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case PowpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 3); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + break; + // ------------------------------------------------- + + case PowvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 3); + forward_sparse_jacobian_binary_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + + case PriOp: + CPPAD_ASSERT_NARG_NRES(op, 5, 0); + break; + // ------------------------------------------------- + + case SignOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + // derivative is identically zero but dependency is not + if( dependency ) forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + else + var_sparsity.clear(i_var); + break; + // ------------------------------------------------- + + case SinOp: + // cos(x), sin(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case SinhOp: + // cosh(x), sinh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case SqrtOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case StppOp: + CPPAD_ASSERT_NARG_NRES(op, 3, 0); + // if both arguments are parameters does not affect sparsity + // or dependency + break; + // ------------------------------------------------- + + case StpvOp: + forward_sparse_store_op( + dependency, + op, + arg, + num_vecad_ind, + vecad_ind.data(), + var_sparsity, + vecad_sparsity + ); + break; + // ------------------------------------------------- + + case StvpOp: + CPPAD_ASSERT_NARG_NRES(op, 3, 0); + 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, + vecad_ind.data(), + var_sparsity, + vecad_sparsity + ); + break; + // ------------------------------------------------- + + case SubvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_binary_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + + case SubpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + break; + // ------------------------------------------------- + + case SubvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case TanOp: + // tan(x)^2, tan(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case TanhOp: + // tanh(x)^2, tanh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case AFunOp: + // start or end an atomic function call + CPPAD_ASSERT_UNKNOWN( + atom_state == start_atom || atom_state == end_atom + ); + flag = atom_state == start_atom; + play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + if( flag ) + { atom_state = arg_atom; + atom_i = 0; + atom_j = 0; + // + atom_x.resize( atom_n ); + type_x.resize( atom_n ); + atom_ix.resize( atom_n ); + atom_iy.resize( atom_m ); +# if CPPAD_FOR_JAC_TRACE + atom_funrp.resize( atom_m ); +# endif + } + else + { CPPAD_ASSERT_UNKNOWN( atom_i == atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + atom_state = start_atom; + // + call_atomic_for_jac_sparsity( + atom_index, + atom_old, + dependency, + atom_x, + type_x, + atom_ix, + atom_iy, + var_sparsity + ); + } + break; + + case FunapOp: + // parameter argument for a atomic function + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j < atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + atom_x[atom_j] = parameter[arg[0]]; + // argument type + if( dyn_par_is[arg[0]] ) + type_x[atom_j] = dynamic_enum; + else + type_x[atom_j] = constant_enum; + atom_ix[atom_j] = 0; // special variable used for parameters + // + ++atom_j; + if( atom_j == atom_n ) + atom_state = ret_atom; + break; + + case FunavOp: + // variable argument for a atomic function + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j < atom_n ); + // + // argument variables not avaiable during sparsity calculations + atom_x[atom_j] = CppAD::numeric_limits::quiet_NaN(); + type_x[atom_j] = variable_enum; + atom_ix[atom_j] = size_t(arg[0]); // variable for this argument + // + ++atom_j; + if( atom_j == atom_n ) + atom_state = ret_atom; + break; + + case FunrpOp: + // parameter result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i < atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + atom_iy[atom_i] = 0; // special value for parameters +# if CPPAD_FOR_JAC_TRACE + // remember argument for delayed tracing + atom_funrp[atom_i] = arg[0]; +# endif + ++atom_i; + if( atom_i == atom_m ) + atom_state = end_atom; + break; + + case FunrvOp: + // variable result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i < atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + // + atom_iy[atom_i] = i_var; // variable index for this result + // + ++atom_i; + if( atom_i == atom_m ) + atom_state = end_atom; + break; + // ------------------------------------------------- + + case ZmulpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + break; + // ------------------------------------------------- + + case ZmulvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + forward_sparse_jacobian_unary_op( + i_var, size_t(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); + } +# if CPPAD_FOR_JAC_TRACE + if( op == AFunOp && atom_state == start_atom ) + { // print operators that have been delayed + CPPAD_ASSERT_UNKNOWN( atom_m == atom_iy.size() ); + CPPAD_ASSERT_UNKNOWN( itr.op_index() > atom_m ); + CPPAD_ASSERT_NARG_NRES(FunrpOp, 1, 0); + CPPAD_ASSERT_NARG_NRES(FunrvOp, 0, 1); + addr_t arg_tmp[1]; + for(i = 0; i < atom_m; i++) + { size_t j_var = atom_iy[i]; + // value for this variable + for(j = 0; j < limit; j++) + z_value[j] = false; + typename Vector_set::const_iterator itr(var_sparsity, j_var); + j = *itr; + while( j < limit ) + { z_value[j] = true; + j = *(++itr); + } + OpCode op_tmp = FunrvOp; + if( j_var == 0 ) + { op_tmp = FunrpOp; + arg_tmp[0] = atom_funrp[i]; + } + // j_var is zero when there is no result. + printOp( + std::cout, + play, + itr.op_index() - atom_m + i, + j_var, + op_tmp, + arg_tmp + ); + if( j_var > 0 ) printOpResult( + std::cout, + 1, + &z_value, + 0, + (CppAD::vectorBool *) CPPAD_NULL + ); + std::cout << std::endl; + } + } + // value for this variable + for(j = 0; j < limit; j++) + z_value[j] = false; + typename Vector_set::const_iterator itr(var_sparsity, i_var); + j = *itr; + while( j < limit ) + { z_value[j] = true; + j = *(++itr); + } + // must delay print for these cases till after atomic function call + bool delay_print = op == FunrpOp; + delay_print |= op == FunrvOp; + if( ! delay_print ) + { printOp( + std::cout, + play, + itr.op_index(), + i_var, + op, + arg + ); + if( NumRes(op) > 0 && (! delay_print) ) printOpResult( + std::cout, + 1, + &z_value, + 0, + (CppAD::vectorBool *) CPPAD_NULL + ); + std::cout << std::endl; + } + } + std::cout << std::endl; +# else + } +# endif + + return; +} + +} } } // END_CPPAD_LOCAL_SWEEP_NAMESPACE + +// preprocessor symbols that are local to this file +# undef CPPAD_FOR_JAC_TRACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sweep/forward0.hpp cppad-2019.02.00.0/include/cppad/local/sweep/forward0.hpp --- cppad-2018.00.00.0/include/cppad/local/sweep/forward0.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sweep/forward0.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,980 @@ +# ifndef CPPAD_LOCAL_SWEEP_FORWARD0_HPP +# define CPPAD_LOCAL_SWEEP_FORWARD0_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include + +// BEGIN_CPPAD_LOCAL_SWEEP_NAMESPACE +namespace CppAD { namespace local { namespace sweep { +/*! +\file sweep/forward0.hpp +Compute zero order forward mode Taylor coefficients. +*/ + +/*! +\def CPPAD_FORWARD0_TRACE +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_FORWARD0 is zero). +*/ +# define CPPAD_FORWARD0_TRACE 0 + +/*! +Compute zero order forward mode Taylor coefficients. + + +\tparam Base +The type used during the forward mode computations; i.e., the corresponding +recording of operations used the type AD. + +\param s_out +Is the stream where output corresponding to PriOp operations will +be written. + +\param print +If print is false, +suppress the output that is otherwise generated by the c PriOp instructions. + +\param n +is the number of independent variables on the tape. + +\param numvar +is the total number of variables on the tape. +This is also equal to the number of rows in the matrix taylor; i.e., +play->num_var_rec(). + +\param play +The information stored in play +is a recording of the operations corresponding to the function +\f[ + F : {\bf R}^n \rightarrow {\bf R}^m +\f] +where \f$ n \f$ is the number of independent variables and +\f$ m \f$ is the number of dependent variables. + +\param J +Is the number of columns in the coefficient matrix taylor. +This must be greater than or equal one. + + + +\param taylor +\n +\b Input: +For i = 1 , ... , n, +taylor [i * J + 0] +variable with index j on the tape +(these are the independent variables). +\n +\n +\b Output: +For i = n + 1, ... , numvar - 1, +taylor [i * J + 0] +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 +(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, +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. + +\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. + +\param not_used_rec_base +Specifies RecBase for this call. +*/ + +template +void forward0( + const local::player* play, + std::ostream& s_out, + bool print, + size_t n, + size_t numvar, + size_t J, + Base* taylor, + bool* cskip_op, + pod_vector& var_by_load_op, + size_t compare_change_count, + size_t& compare_change_number, + size_t& compare_change_op_index, + const RecBase& not_used_rec_base +) +{ CPPAD_ASSERT_UNKNOWN( J >= 1 ); + CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar ); + + // use p, q, r so other forward sweeps can use code defined here + size_t p = 0; + size_t q = 0; + size_t r = 1; + /* + + */ + + // 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; + pod_vector index_by_ind; + if( p == 0 ) + { size_t i; + + // this includes order zero calculation, initialize vector indices + size_t num = play->num_vec_ind_rec(); + if( num > 0 ) + { isvar_by_ind.extend(num); + index_by_ind.extend(num); + for(i = 0; i < num; i++) + { index_by_ind[i] = play->GetVecInd(i); + isvar_by_ind[i] = false; + } + } + // includes zero order, so initialize conditional skip flags + num = play->num_op_rec(); + for(i = 0; i < num; i++) + cskip_op[i] = false; + } + + // information used by atomic function operators + const pod_vector& dyn_par_is( play->dyn_par_is() ); + const size_t need_y = size_t( variable_enum ); + const size_t order_low = p; + const size_t order_up = q; + + // vectors used by atomic function operators + vector atom_par_x; // argument parameter values + vector atom_type_x; // argument type + vector atom_tx; // argument vector Taylor coefficients + vector atom_ty; // result vector Taylor coefficients + // + // information defined by atomic function operators + size_t atom_index=0, atom_old=0, atom_m=0, atom_n=0, atom_i=0, atom_j=0; + enum_atom_state atom_state = start_atom; // proper initialization + + // length of the parameter vector (used by CppAD assert macros) + const size_t num_par = play->num_par_rec(); + + // pointer to the beginning of the parameter vector + const Base* parameter = CPPAD_NULL; + if( num_par > 0 ) + parameter = play->GetPar(); + + // length of the text vector (used by CppAD assert macros) + const size_t num_text = play->num_text_rec(); + + // pointer to the beginning of the text vector + const char* text = CPPAD_NULL; + if( num_text > 0 ) + text = play->GetTxt(0); + /* + + */ + +# if CPPAD_FORWARD0_TRACE + // flag as to when to trace atomic function values + bool atom_trace = false; + + // variable indices for results vector + // (done differently for order zero). + vector atom_iy; +# endif + + // skip the BeginOp at the beginning of the recording + play::const_sequential_iterator itr = play->begin(); + // op_info + OpCode op; + size_t i_var; + const Addr* arg; + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == BeginOp ); + // +# if CPPAD_FORWARD0_TRACE + std::cout << std::endl; +# endif + bool flag; // a temporary flag to use in switch cases + bool more_operators = true; + while(more_operators) + { + // next op + (++itr).op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( itr.op_index() < play->num_op_rec() ); + + // check if we are skipping this operation + while( cskip_op[itr.op_index()] ) + { switch(op) + { + case AFunOp: + { // get information for this atomic function call + CPPAD_ASSERT_UNKNOWN( atom_state == start_atom ); + play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + // + // skip to the second AFunOp + for(size_t i = 0; i < atom_m + atom_n + 1; ++i) + ++itr; +# ifndef NDEBUG + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == AFunOp ); +# endif + } + break; + + case CSkipOp: + case CSumOp: + itr.correct_before_increment(); + break; + + default: + break; + } + (++itr).op_info(op, arg, i_var); + } + + // action to take depends on the case + switch( op ) + { + case AbsOp: + forward_abs_op_0(i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case AddvvOp: + forward_addvv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case AddpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_addpv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case AcosOp: + // sqrt(1 - x * x), acos(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_acos_op_0(i_var, size_t(arg[0]), J, taylor); + 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, size_t(arg[0]), J, taylor); + break; +# endif + // ------------------------------------------------- + + case AsinOp: + // sqrt(1 - x * x), asin(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_asin_op_0(i_var, size_t(arg[0]), J, taylor); + 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, size_t(arg[0]), J, taylor); + break; +# endif + // ------------------------------------------------- + + case AtanOp: + // 1 + x * x, atan(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_atan_op_0(i_var, size_t(arg[0]), J, taylor); + 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, size_t(arg[0]), J, taylor); + break; +# endif + // ------------------------------------------------- + + case CExpOp: + // 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 CosOp: + // sin(x), cos(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_cos_op_0(i_var, size_t(arg[0]), J, taylor); + break; + // --------------------------------------------------- + + case CoshOp: + // sinh(x), cosh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_cosh_op_0(i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case CSkipOp: + forward_cskip_op_0( + i_var, arg, num_par, parameter, J, taylor, cskip_op + ); + itr.correct_before_increment(); + break; + // ------------------------------------------------- + + case CSumOp: + forward_csum_op( + 0, 0, i_var, arg, num_par, parameter, J, taylor + ); + itr.correct_before_increment(); + break; + // ------------------------------------------------- + + case DisOp: + forward_dis_op(p, q, r, i_var, arg, J, taylor); + break; + // ------------------------------------------------- + + case DivvvOp: + forward_divvv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case DivpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_divpv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case DivvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + forward_divvp_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case EndOp: + CPPAD_ASSERT_NARG_NRES(op, 0, 0); + more_operators = false; + break; + // ------------------------------------------------- + + case EqppOp: + if( compare_change_count ) + { forward_eqpp_op_0( + compare_change_number, arg, parameter + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = itr.op_index(); + } + } + break; + // ------------------------------------------------- + + 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 = itr.op_index(); + } + } + 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 = itr.op_index(); + } + } + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case ErfOp: + forward_erf_op_0(i_var, arg, parameter, J, taylor); + break; +# endif + // ------------------------------------------------- + + case ExpOp: + forward_exp_op_0(i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + forward_expm1_op_0(i_var, size_t(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, + taylor, + isvar_by_ind.data(), + index_by_ind.data(), + var_by_load_op.data() + ); + break; + // ------------------------------------------------- + + case LdvOp: + forward_load_v_op_0( + play, + i_var, + arg, + parameter, + J, + taylor, + isvar_by_ind.data(), + index_by_ind.data(), + var_by_load_op.data() + ); + break; + // ------------------------------------------------- + + case LeppOp: + if( compare_change_count ) + { forward_lepp_op_0( + compare_change_number, arg, parameter + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = itr.op_index(); + } + } + 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 = itr.op_index(); + } + } + 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 = itr.op_index(); + } + } + 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 = itr.op_index(); + } + } + break; + // ------------------------------------------------- + + case LogOp: + forward_log_op_0(i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + forward_log1p_op_0(i_var, size_t(arg[0]), J, taylor); + break; +# endif + // ------------------------------------------------- + + case LtppOp: + if( compare_change_count ) + { forward_ltpp_op_0( + compare_change_number, arg, parameter + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = itr.op_index(); + } + } + break; + // ------------------------------------------------- + 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 = itr.op_index(); + } + } + 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 = itr.op_index(); + } + } + 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 = itr.op_index(); + } + } + break; + // ------------------------------------------------- + + case MulpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_mulpv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case MulvvOp: + forward_mulvv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case NeppOp: + if( compare_change_count ) + { forward_nepp_op_0( + compare_change_number, arg, parameter + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = itr.op_index(); + } + } + 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 = itr.op_index(); + } + } + 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 = itr.op_index(); + } + } + break; + // ------------------------------------------------- + + case ParOp: + forward_par_op_0( + i_var, arg, num_par, parameter, J, taylor + ); + break; + // ------------------------------------------------- + + case PowvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + forward_powvp_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case PowpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_powpv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case PowvvOp: + forward_powvv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case PriOp: + if( print ) forward_pri_0(s_out, + arg, num_text, text, num_par, parameter, J, taylor + ); + break; + // ------------------------------------------------- + + case SignOp: + // cos(x), sin(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_sign_op_0(i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case SinOp: + // cos(x), sin(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_sin_op_0(i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case SinhOp: + // cosh(x), sinh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_sinh_op_0(i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case SqrtOp: + forward_sqrt_op_0(i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case StppOp: + forward_store_pp_op_0( + i_var, + arg, + num_par, + J, + taylor, + isvar_by_ind.data(), + index_by_ind.data() + ); + break; + // ------------------------------------------------- + + case StpvOp: + forward_store_pv_op_0( + i_var, + arg, + num_par, + J, + taylor, + isvar_by_ind.data(), + index_by_ind.data() + ); + break; + // ------------------------------------------------- + + case StvpOp: + forward_store_vp_op_0( + i_var, + arg, + num_par, + J, + taylor, + isvar_by_ind.data(), + index_by_ind.data() + ); + break; + // ------------------------------------------------- + + case StvvOp: + forward_store_vv_op_0( + i_var, + arg, + num_par, + J, + taylor, + isvar_by_ind.data(), + index_by_ind.data() + ); + break; + // ------------------------------------------------- + + case SubvvOp: + forward_subvv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case SubpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_subpv_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case SubvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + forward_subvp_op_0(i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case TanOp: + // tan(x)^2, tan(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_tan_op_0(i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case TanhOp: + // tanh(x)^2, tanh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_tanh_op_0(i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case AFunOp: + // start or end an atomic function call + flag = atom_state == start_atom; + play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + if( flag ) + { atom_state = arg_atom; + atom_i = 0; + atom_j = 0; + // + atom_par_x.resize(atom_n); + atom_type_x.resize(atom_n); + atom_tx.resize(atom_n); + atom_ty.resize(atom_m); +# if CPPAD_FORWARD0_TRACE + atom_iy.resize(atom_m); +# endif + } + else + { CPPAD_ASSERT_UNKNOWN( atom_i == atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + atom_state = start_atom; +# if CPPAD_FORWARD0_TRACE + atom_trace = true; +# endif + } + break; + + case FunapOp: + // parameter argument for an atomic function + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j < atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + if( dyn_par_is[ arg[0] ] ) + atom_type_x[atom_j] = dynamic_enum; + else + atom_type_x[atom_j] = constant_enum; + atom_par_x[atom_j] = parameter[ arg[0] ]; + atom_tx[atom_j++] = parameter[ arg[0] ]; + // + if( atom_j == atom_n ) + { // call atomic function for this operation + call_atomic_forward( + atom_par_x, atom_type_x, need_y, + order_low, order_up, atom_index, atom_old, atom_tx, atom_ty + ); + atom_state = ret_atom; + } + break; + + case FunavOp: + // variable argument for a atomic function + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j < atom_n ); + // + atom_type_x[atom_j] = variable_enum; + atom_par_x[atom_j] = CppAD::numeric_limits::quiet_NaN(); + atom_tx[atom_j++] = taylor[ size_t(arg[0]) * J + 0 ]; + // + if( atom_j == atom_n ) + { // call atomic function for this operation + call_atomic_forward( + atom_par_x, atom_type_x, need_y, + order_low, order_up, atom_index, atom_old, atom_tx, atom_ty + ); + atom_state = ret_atom; + } + break; + + case FunrpOp: + // parameter result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i < atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); +# if CPPAD_FORWARD0_TRACE + atom_iy[atom_i] = 0; +# endif + atom_i++; + if( atom_i == atom_m ) + atom_state = end_atom; + break; + + case FunrvOp: + // variable result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i < atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); +# if CPPAD_FORWARD0_TRACE + atom_iy[atom_i] = i_var; +# endif + taylor[ i_var * J + 0 ] = atom_ty[atom_i++]; + if( atom_i == atom_m ) + atom_state = end_atom; + 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); + } +# if CPPAD_FORWARD0_TRACE + size_t d = 0; + if( atom_trace ) + { atom_trace = false; + + CPPAD_ASSERT_UNKNOWN( op == AFunOp ); + CPPAD_ASSERT_UNKNOWN( NumArg(FunrvOp) == 0 ); + for(size_t i = 0; i < atom_m; i++) if( atom_iy[i] > 0 ) + { size_t i_tmp = (itr.op_index() + i) - atom_m; + printOp( + std::cout, + play, + i_tmp, + atom_iy[i], + FunrvOp, + CPPAD_NULL + ); + Base* Z_tmp = taylor + atom_iy[i] * J; + printOpResult( + std::cout, + d + 1, + Z_tmp, + 0, + (Base *) CPPAD_NULL + ); + std::cout << std::endl; + } + } + Base* Z_tmp = taylor + i_var * J; + if( op != FunrvOp ) + { + printOp( + std::cout, + play, + itr.op_index(), + i_var, + op, + arg + ); + if( NumRes(op) > 0 ) printOpResult( + std::cout, + d + 1, + Z_tmp, + 0, + (Base *) CPPAD_NULL + ); + std::cout << std::endl; + } + } + std::cout << std::endl; +# else + } +# endif + CPPAD_ASSERT_UNKNOWN( atom_state == start_atom ); + + return; +} + +} } } // END_CPPAD_LOCAL_SWEEP_NAMESPACE + +// preprocessor symbols that are local to this file +# undef CPPAD_FORWARD0_TRACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sweep/forward1.hpp cppad-2019.02.00.0/include/cppad/local/sweep/forward1.hpp --- cppad-2018.00.00.0/include/cppad/local/sweep/forward1.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sweep/forward1.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1097 @@ +# ifndef CPPAD_LOCAL_SWEEP_FORWARD1_HPP +# define CPPAD_LOCAL_SWEEP_FORWARD1_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include + +// BEGIN_CPPAD_LOCAL_SWEEP_NAMESPACE +namespace CppAD { namespace local { namespace sweep { +/*! +\file sweep/forward1.hpp +Compute one Taylor coefficient for each order requested. +*/ + +/*! +\def CPPAD_FORWARD1_TRACE +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. +*/ +# define CPPAD_FORWARD1_TRACE 0 + +/*! +Compute arbitrary order forward mode Taylor coefficients. + + +\tparam Base +The type used during the forward mode computations; i.e., the corresponding +recording of operations used the type AD. + +\param s_out +Is the stream where output corresponding to PriOp operations will +be written. + +\param print +If print is false, +suppress the output that is otherwise generated by the c PriOp instructions. + +\param n +is the number of independent variables on the tape. + +\param numvar +is the total number of variables on the tape. +This is also equal to the number of rows in the matrix taylor; i.e., +play->num_var_rec(). + +\param play +The information stored in play +is a recording of the operations corresponding to the function +\f[ + F : {\bf R}^n \rightarrow {\bf R}^m +\f] +where \f$ n \f$ is the number of independent variables and +\f$ m \f$ is the number of dependent variables. + +\param J +Is the number of columns in the coefficient matrix taylor. +This must be greater than or equal one. + + + +\param cskip_op +Is a vector with size play->num_op_rec(). +\n +\n +p = 0 +\n +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 +(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 +as its return value above. + +\param var_by_load_op +is a vector with size play->num_load_op_rec(). +\n +\n +p == 0 +\n +In this case, +The input value of the elements does not matter. +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. +\n +\n +p > 0 +\n +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. + +\param q +is the highest order of the Taylor coefficients +that are computed during this call. + +\param taylor +\n +\b Input: +For i = 1 , ... , numvar-1, +k = 0 , ... , p-1, +taylor[ J*i + k] +is the k-th order Taylor coefficient corresponding to +the i-th variable. +\n +\n +\b Input: +For i = 1 , ... , n, +k = p , ... , q, +taylor[ J*j + k] +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 +k = 0 , ... , p-1, +taylor[ J*i + k] +is the k-th order Taylor coefficient corresponding to +the i-th variable. + + +\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. + +\param not_used_rec_base +Specifies RecBase for this call. +*/ + +template +void forward1( + const local::player* play, + std::ostream& s_out, + const bool print, + const size_t p, + const size_t q, + const size_t n, + const size_t numvar, + const size_t J, + Base* taylor, + bool* cskip_op, + pod_vector& var_by_load_op, + size_t compare_change_count, + size_t& compare_change_number, + size_t& compare_change_op_index, + const RecBase& not_used_rec_base +) +{ + // number of directions + const size_t r = 1; + + CPPAD_ASSERT_UNKNOWN( p <= q ); + CPPAD_ASSERT_UNKNOWN( J >= q + 1 ); + CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar ); + + /* + + */ + + // 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; + pod_vector index_by_ind; + if( p == 0 ) + { size_t i; + + // this includes order zero calculation, initialize vector indices + size_t num = play->num_vec_ind_rec(); + if( num > 0 ) + { isvar_by_ind.extend(num); + index_by_ind.extend(num); + for(i = 0; i < num; i++) + { index_by_ind[i] = play->GetVecInd(i); + isvar_by_ind[i] = false; + } + } + // includes zero order, so initialize conditional skip flags + num = play->num_op_rec(); + for(i = 0; i < num; i++) + cskip_op[i] = false; + } + + // information used by atomic function operators + const pod_vector& dyn_par_is( play->dyn_par_is() ); + const size_t need_y = size_t( variable_enum ); + const size_t order_low = p; + const size_t order_up = q; + + // vectors used by atomic function operators + vector atom_par_x; // argument parameter values + vector atom_type_x; // argument type + vector atom_tx; // argument vector Taylor coefficients + vector atom_ty; // result vector Taylor coefficients + // + // information defined by atomic function operators + size_t atom_index=0, atom_old=0, atom_m=0, atom_n=0, atom_i=0, atom_j=0; + enum_atom_state atom_state = start_atom; // proper initialization + + // length of the parameter vector (used by CppAD assert macros) + const size_t num_par = play->num_par_rec(); + + // pointer to the beginning of the parameter vector + const Base* parameter = CPPAD_NULL; + if( num_par > 0 ) + parameter = play->GetPar(); + + // length of the text vector (used by CppAD assert macros) + const size_t num_text = play->num_text_rec(); + + // pointer to the beginning of the text vector + const char* text = CPPAD_NULL; + if( num_text > 0 ) + text = play->GetTxt(0); + /* + + */ + // temporary indices + size_t i, k; + + // number of orders for this atomic calculation + // (not needed for order zero) + const size_t atom_q1 = q+1; + + // variable indices for results vector + // (done differently for order zero). + vector atom_iy; + + // skip the BeginOp at the beginning of the recording + play::const_sequential_iterator itr = play->begin(); + // op_info + OpCode op; + size_t i_var; + const Addr* arg; + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == BeginOp ); + // +# if CPPAD_FORWARD1_TRACE + bool atom_trace = false; + std::cout << std::endl; +# endif + // + bool flag; // a temporary flag to use in switch cases + bool more_operators = true; + while(more_operators) + { + // next op + (++itr).op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( itr.op_index() < play->num_op_rec() ); + + // check if we are skipping this operation + while( cskip_op[itr.op_index()] ) + { switch(op) + { + case AFunOp: + { // get information for this atomic function call + CPPAD_ASSERT_UNKNOWN( atom_state == start_atom ); + play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + // + // skip to the second AFunOp + for(i = 0; i < atom_m + atom_n + 1; ++i) + ++itr; +# ifndef NDEBUG + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == AFunOp ); +# endif + } + break; + + case CSkipOp: + case CSumOp: + itr.correct_before_increment(); + break; + + default: + break; + } + (++itr).op_info(op, arg, i_var); + } + + // action depends on the operator + switch( op ) + { + case AbsOp: + forward_abs_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case AddvvOp: + forward_addvv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case AddpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_addpv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case AcosOp: + // sqrt(1 - x * x), acos(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_acos_op(p, q, i_var, size_t(arg[0]), J, taylor); + 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, size_t(arg[0]), J, taylor); + break; +# endif + // ------------------------------------------------- + + case AsinOp: + // sqrt(1 - x * x), asin(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_asin_op(p, q, i_var, size_t(arg[0]), J, taylor); + 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, size_t(arg[0]), J, taylor); + break; +# endif + // ------------------------------------------------- + + case AtanOp: + // 1 + x * x, atan(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_atan_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + +# 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, size_t(arg[0]), J, taylor); + break; +# endif + // ------------------------------------------------- + + case CExpOp: + forward_cond_op( + p, q, i_var, arg, num_par, parameter, J, taylor + ); + break; + // --------------------------------------------------- + + case CosOp: + // sin(x), cos(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_cos_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; + // --------------------------------------------------- + + case CoshOp: + // sinh(x), cosh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_cosh_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case CSkipOp: + if( p == 0 ) + { forward_cskip_op_0( + i_var, arg, num_par, parameter, J, taylor, cskip_op + ); + } + itr.correct_before_increment(); + break; + // ------------------------------------------------- + + case CSumOp: + forward_csum_op( + p, q, i_var, arg, num_par, parameter, J, taylor + ); + itr.correct_before_increment(); + break; + // ------------------------------------------------- + + case DisOp: + forward_dis_op(p, q, r, i_var, arg, J, taylor); + break; + // ------------------------------------------------- + + case DivvvOp: + forward_divvv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case DivpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_divpv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case DivvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + forward_divvp_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case EndOp: + CPPAD_ASSERT_NARG_NRES(op, 0, 0); + more_operators = false; + break; + // ------------------------------------------------- + + case EqppOp: + if( compare_change_count ) + { forward_eqpp_op_0( + compare_change_number, arg, parameter + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = itr.op_index(); + } + } + 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 = itr.op_index(); + } + 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 = itr.op_index(); + } + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case ErfOp: + CPPAD_ASSERT_UNKNOWN( CPPAD_USE_CPLUSPLUS_2011 ); + forward_erf_op(p, q, i_var, arg, parameter, J, taylor); + break; +# endif + // ------------------------------------------------- + + case ExpOp: + forward_exp_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; + // --------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + forward_expm1_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; +# endif + // --------------------------------------------------- + + case InvOp: + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + break; + // ------------------------------------------------- + + case LdpOp: + if( p == 0 ) + { forward_load_p_op_0( + play, + 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( + play, + op, + p+1, + q, + r, + J, + i_var, + arg, + var_by_load_op.data(), + taylor + ); + } + else + forward_load_op( + play, + op, + p, + q, + r, + J, + i_var, + arg, + var_by_load_op.data(), + taylor + ); + break; + // ------------------------------------------------- + + case LdvOp: + if( p == 0 ) + { forward_load_v_op_0( + play, + 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( + play, + op, + p+1, + q, + r, + J, + i_var, + arg, + var_by_load_op.data(), + taylor + ); + } + else + forward_load_op( + play, + op, + p, + q, + r, + J, + i_var, + arg, + var_by_load_op.data(), + taylor + ); + break; + // ------------------------------------------------- + + case LeppOp: + if( ( p == 0 ) & ( compare_change_count > 0 ) ) + { forward_lepp_op_0( + compare_change_number, arg, parameter + ); + if( compare_change_count == compare_change_number ) + compare_change_op_index = itr.op_index(); + } + 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 = itr.op_index(); + } + 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 = itr.op_index(); + } + 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 = itr.op_index(); + } + break; + // ------------------------------------------------- + + case LogOp: + forward_log_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + forward_log1p_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; +# endif + // ------------------------------------------------- + + case LtppOp: + if( ( p == 0 ) & ( compare_change_count > 0 ) ) + { forward_ltpp_op_0( + compare_change_number, arg, parameter + ); + if( compare_change_count == compare_change_number ) + compare_change_op_index = itr.op_index(); + } + break; + // ------------------------------------------------- + + 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 = itr.op_index(); + } + 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 = itr.op_index(); + } + 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 = itr.op_index(); + } + break; + // ------------------------------------------------- + + case MulpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_mulpv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case MulvvOp: + forward_mulvv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case NeppOp: + if( compare_change_count ) + { forward_nepp_op_0( + compare_change_number, arg, parameter + ); + { if( compare_change_count == compare_change_number ) + compare_change_op_index = itr.op_index(); + } + } + 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 = itr.op_index(); + } + 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 = itr.op_index(); + } + break; + // ------------------------------------------------- + + case ParOp: + i = p; + if( i == 0 ) + { forward_par_op_0( + i_var, arg, num_par, parameter, J, taylor + ); + i++; + } + while(i <= q) + { taylor[ i_var * J + i] = Base(0.0); + i++; + } + break; + // ------------------------------------------------- + + case PowvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + forward_powvp_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case PowpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_powpv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case PowvvOp: + forward_powvv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case PriOp: + if( (p == 0) & print ) forward_pri_0(s_out, + arg, num_text, text, num_par, parameter, J, taylor + ); + break; + // ------------------------------------------------- + + case SignOp: + // sign(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_sign_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case SinOp: + // cos(x), sin(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_sin_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case SinhOp: + // cosh(x), sinh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_sinh_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case SqrtOp: + forward_sqrt_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case StppOp: + if( p == 0 ) + { forward_store_pp_op_0( + i_var, + arg, + num_par, + J, + taylor, + isvar_by_ind.data(), + index_by_ind.data() + ); + } + break; + // ------------------------------------------------- + + case StpvOp: + if( p == 0 ) + { forward_store_pv_op_0( + i_var, + arg, + num_par, + J, + taylor, + isvar_by_ind.data(), + index_by_ind.data() + ); + } + break; + // ------------------------------------------------- + + case StvpOp: + if( p == 0 ) + { forward_store_vp_op_0( + i_var, + arg, + num_par, + J, + taylor, + isvar_by_ind.data(), + index_by_ind.data() + ); + } + break; + // ------------------------------------------------- + + case StvvOp: + if( p == 0 ) + { forward_store_vv_op_0( + i_var, + arg, + num_par, + J, + taylor, + isvar_by_ind.data(), + index_by_ind.data() + ); + } + break; + // ------------------------------------------------- + + case SubvvOp: + forward_subvv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case SubpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_subpv_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case SubvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + forward_subvp_op(p, q, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case TanOp: + // tan(x)^2, tan(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_tan_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case TanhOp: + // tanh(x)^2, tanh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_tanh_op(p, q, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case AFunOp: + // start or end an atomic function call + flag = atom_state == start_atom; + play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + if( flag ) + { atom_state = arg_atom; + atom_i = 0; + atom_j = 0; + // + atom_par_x.resize(atom_n); + atom_type_x.resize(atom_n); + atom_tx.resize(atom_n * atom_q1); + atom_ty.resize(atom_m * atom_q1); + atom_iy.resize(atom_m); + } + else + { CPPAD_ASSERT_UNKNOWN( atom_i == atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + atom_state = start_atom; + // + // call atomic function for this operation + call_atomic_forward( + atom_par_x, atom_type_x, need_y, + order_low, order_up, atom_index, atom_old, atom_tx, atom_ty + ); + for(i = 0; i < atom_m; i++) + if( atom_iy[i] > 0 ) + for(k = p; k <= q; k++) + taylor[ atom_iy[i] * J + k ] = + atom_ty[ i * atom_q1 + k ]; +# if CPPAD_FORWARD1_TRACE + atom_trace = true; +# endif + } + break; + + case FunapOp: + // parameter argument for a atomic function + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j < atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + if( dyn_par_is[ arg[0] ] ) + atom_type_x[atom_j] = dynamic_enum; + else + atom_type_x[atom_j] = constant_enum; + atom_par_x[atom_j] = parameter[ arg[0] ]; + atom_tx[atom_j * atom_q1 + 0] = parameter[ arg[0]]; + for(k = 1; k < atom_q1; k++) + atom_tx[atom_j * atom_q1 + k] = Base(0.0); + // + ++atom_j; + if( atom_j == atom_n ) + atom_state = ret_atom; + break; + + case FunavOp: + // variable argument for a atomic function + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j < atom_n ); + // + atom_type_x[atom_j] = variable_enum; + atom_par_x[atom_j] = CppAD::numeric_limits::quiet_NaN(); + for(k = 0; k < atom_q1; k++) + atom_tx[atom_j * atom_q1 + k] = taylor[ size_t(arg[0]) * J + k]; + // + ++atom_j; + if( atom_j == atom_n ) + atom_state = ret_atom; + break; + + case FunrpOp: + // parameter result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i < atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + atom_iy[atom_i] = 0; + atom_ty[atom_i * atom_q1 + 0] = parameter[ arg[0]]; + for(k = 1; k < p; k++) + atom_ty[atom_i * atom_q1 + k] = Base(0.0); + // + ++atom_i; + if( atom_i == atom_m ) + atom_state = end_atom; + break; + + case FunrvOp: + // variable result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i < atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + // + atom_iy[atom_i] = i_var; + for(k = 0; k < p; k++) + atom_ty[atom_i * atom_q1 + k] = taylor[ i_var * J + k]; + // + ++atom_i; + if( atom_i == atom_m ) + atom_state = end_atom; + 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); + } +# if CPPAD_FORWARD1_TRACE + if( atom_trace ) + { atom_trace = false; + + CPPAD_ASSERT_UNKNOWN( op == AFunOp ); + CPPAD_ASSERT_UNKNOWN( NumArg(FunrvOp) == 0 ); + for(i = 0; i < atom_m; i++) if( atom_iy[i] > 0 ) + { size_t i_tmp = (itr.op_index() + i) - atom_m; + printOp( + std::cout, + play, + i_tmp, + atom_iy[i], + FunrvOp, + CPPAD_NULL + ); + Base* Z_tmp = taylor + atom_iy[i] * J; + printOpResult( + std::cout, + q + 1, + Z_tmp, + 0, + (Base *) CPPAD_NULL + ); + std::cout << std::endl; + } + } + Base* Z_tmp = taylor + J * i_var; + if( op != FunrvOp ) + { + printOp( + std::cout, + play, + itr.op_index(), + i_var, + op, + arg + ); + if( NumRes(op) > 0 ) printOpResult( + std::cout, + q + 1, + Z_tmp, + 0, + (Base *) CPPAD_NULL + ); + std::cout << std::endl; + } + } + std::cout << std::endl; +# else + } +# endif + CPPAD_ASSERT_UNKNOWN( atom_state == start_atom ); + + if( (p == 0) & (compare_change_count == 0) ) + compare_change_number = 0; + return; +} + +// preprocessor symbols that are local to this file +# undef CPPAD_FORWARD1_TRACE + +} } } // END_CPPAD_LOCAL_SWEEP_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sweep/forward2.hpp cppad-2019.02.00.0/include/cppad/local/sweep/forward2.hpp --- cppad-2018.00.00.0/include/cppad/local/sweep/forward2.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sweep/forward2.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,798 @@ +# ifndef CPPAD_LOCAL_SWEEP_FORWARD2_HPP +# define CPPAD_LOCAL_SWEEP_FORWARD2_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include + +// BEGIN_CPPAD_LOCAL_SWEEP_NAMESPACE +namespace CppAD { namespace local { namespace sweep { +/*! +\file sweep/forward2.hpp +Compute one Taylor coefficient for each direction requested. +*/ + +/*! +\def CPPAD_FORWARD2_TRACE +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. +*/ +# define CPPAD_FORWARD2_TRACE 0 + +/*! +Compute multiple directions forward mode Taylor coefficients. + +\tparam Base +The type used during the forward mode computations; i.e., the corresponding +recording of operations used the type AD. + +\param q +is the order of the Taylor coefficients +that are computed during this call; +q > 0. + +\param r +is the number of Taylor coefficients +that are computed during this call. + +\param n +is the number of independent variables on the tape. + +\param numvar +is the total number of variables on the tape. +This is also equal to the number of rows in the matrix taylor; i.e., +play->num_var_rec(). + +\param play +The information stored in play +is a recording of the operations corresponding to the function +\f[ + F : {\bf R}^n \rightarrow {\bf R}^m +\f] +where \f$ n \f$ is the number of independent variables and +\f$ m \f$ is the number of dependent variables. + +\param J +Is the number of columns in the coefficient matrix taylor. +This must be greater than or equal one. + +\param taylor +\n +\b Input: +For i = 1 , ... , numvar-1, +taylor[ (J-1)*r*i + i + 0 ] +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 +the i-th variabel and ell-th direction. +\n +\n +\b Input: +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 +the i-th variable and ell-th direction +(these are the independent varaibles). +\n +\n +\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 +the i-th variable and ell-th direction. + +\param cskip_op +Is a vector with size play->num_op_rec(). +If cskip_op[i] is true, the operator with 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(). +It is the variable index corresponding to each the +load instruction. +In the case where the index is zero, +the instruction corresponds to a parameter (not variable). + +\param not_used_rec_base +Specifies RecBase for this call. + +*/ + +template +void forward2( + const local::player* play, + const size_t q, + const size_t r, + const size_t n, + const size_t numvar, + const size_t J, + Base* taylor, + const bool* cskip_op, + const pod_vector& var_by_load_op, + const RecBase& not_used_rec_base +) +{ + CPPAD_ASSERT_UNKNOWN( q > 0 ); + CPPAD_ASSERT_UNKNOWN( J >= q + 1 ); + CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar ); + + // only compute one order at a time when using multi-direction forward + size_t p = q; + + // information used by atomic function operators + const pod_vector& dyn_par_is( play->dyn_par_is() ); + const size_t need_y = size_t( variable_enum ); + const size_t order_low = p; + const size_t order_up = q; + + // vectors used by atomic function operators + vector atom_par_x; // argument parameter values + vector atom_type_x; // argument type + vector atom_tx_one; // argument vector Taylor coefficients + vector atom_tx_all; + vector atom_ty_one; // result vector Taylor coefficients + vector atom_ty_all; + // + // information defined by atomic function operators + size_t atom_index=0, atom_old=0, atom_m=0, atom_n=0, atom_i=0, atom_j=0; + enum_atom_state atom_state = start_atom; // proper initialization + // + // length of the parameter vector (used by CppAD assert macros) + const size_t num_par = play->num_par_rec(); + + // pointer to the beginning of the parameter vector + const Base* parameter = CPPAD_NULL; + if( num_par > 0 ) + parameter = play->GetPar(); + + // temporary indices + size_t i, j, k, ell; + + // number of orders for this atomic calculation + // (not needed for order zero) + const size_t atom_q1 = q+1; + + // variable indices for results vector + // (done differently for order zero). + vector atom_iy; + + // skip the BeginOp at the beginning of the recording + play::const_sequential_iterator itr = play->begin(); + // op_info + OpCode op; + size_t i_var; + const Addr* arg; + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == BeginOp ); +# if CPPAD_FORWARD2_TRACE + bool atom_trace = false; + std::cout << std::endl; + CppAD::vector Z_vec(q+1); +# endif + bool flag; // a temporary flag to use in switch cases + bool more_operators = true; + while(more_operators) + { + // next op + (++itr).op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( itr.op_index() < play->num_op_rec() ); + + // check if we are skipping this operation + while( cskip_op[itr.op_index()] ) + { switch(op) + { + case AFunOp: + { // get information for this atomic function call + CPPAD_ASSERT_UNKNOWN( atom_state == start_atom ); + play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + // + // skip to the second AFunOp + for(i = 0; i < atom_m + atom_n + 1; ++i) + ++itr; +# ifndef NDEBUG + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == AFunOp ); +# endif + } + break; + + case CSkipOp: + case CSumOp: + itr.correct_before_increment(); + break; + + default: + break; + } + (++itr).op_info(op, arg, i_var); + } + + // action depends on the operator + switch( op ) + { + case AbsOp: + forward_abs_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case AddvvOp: + forward_addvv_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case AddpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_addpv_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case AcosOp: + // sqrt(1 - x * x), acos(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_acos_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + 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, size_t(arg[0]), J, taylor); + break; +# endif + // ------------------------------------------------- + + case AsinOp: + // sqrt(1 - x * x), asin(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_asin_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + 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, size_t(arg[0]), J, taylor); + break; +# endif + // ------------------------------------------------- + + case AtanOp: + // 1 + x * x, atan(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_atan_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + 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, size_t(arg[0]), J, taylor); + break; +# endif + // ------------------------------------------------- + + case CExpOp: + forward_cond_op_dir( + q, r, i_var, arg, num_par, parameter, J, taylor + ); + break; + // --------------------------------------------------- + + case CosOp: + // sin(x), cos(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_cos_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; + // --------------------------------------------------- + + case CoshOp: + // sinh(x), cosh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_cosh_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case CSkipOp: + // CSkipOp only does somthing on order zero. + CPPAD_ASSERT_UNKNOWN( p > 0 ); + itr.correct_before_increment(); + break; + // ------------------------------------------------- + + case CSumOp: + forward_csum_op_dir( + q, r, i_var, arg, num_par, parameter, J, taylor + ); + itr.correct_before_increment(); + break; + // ------------------------------------------------- + + case DisOp: + forward_dis_op(p, q, r, i_var, arg, J, taylor); + break; + // ------------------------------------------------- + + case DivvvOp: + forward_divvv_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case DivpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_divpv_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case DivvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + forward_divvp_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case EndOp: + // needed for sparse_jacobian test + CPPAD_ASSERT_NARG_NRES(op, 0, 0); + more_operators = false; + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case ErfOp: + forward_erf_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- +# endif + + case ExpOp: + forward_exp_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + forward_expm1_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; +# endif + // ------------------------------------------------- + + case InvOp: + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + break; + // ------------------------------------------------- + + case LdpOp: + case LdvOp: + forward_load_op( + play, + op, + p, + q, + r, + J, + i_var, + arg, + var_by_load_op.data(), + taylor + ); + break; + // --------------------------------------------------- + + case EqppOp: + case EqpvOp: + case EqvvOp: + case LtppOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case LeppOp: + case LepvOp: + case LevpOp: + case LevvOp: + case NeppOp: + case NepvOp: + case NevvOp: + CPPAD_ASSERT_UNKNOWN(q > 0 ); + break; + // ------------------------------------------------- + + case LogOp: + forward_log_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; + // --------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + forward_log1p_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; +# endif + // --------------------------------------------------- + + case MulpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_mulpv_op_dir(q, r, i_var, arg, parameter, J, taylor); + 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.0); + break; + // ------------------------------------------------- + + case PowpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_powpv_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case PowvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + forward_powvp_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case PowvvOp: + forward_powvv_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case PriOp: + CPPAD_ASSERT_UNKNOWN(q > 0); + break; + // ------------------------------------------------- + + case SignOp: + // sign(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_sign_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case SinOp: + // cos(x), sin(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_sin_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case SinhOp: + // cosh(x), sinh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_sinh_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case SqrtOp: + forward_sqrt_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case StppOp: + case StpvOp: + case StvpOp: + case StvvOp: + CPPAD_ASSERT_UNKNOWN(q > 0 ); + break; + // ------------------------------------------------- + + case SubvvOp: + forward_subvv_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case SubpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + forward_subpv_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case SubvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + forward_subvp_op_dir(q, r, i_var, arg, parameter, J, taylor); + break; + // ------------------------------------------------- + + case TanOp: + // tan(x)^2, tan(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_tan_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case TanhOp: + // tanh(x)^2, tanh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + forward_tanh_op_dir(q, r, i_var, size_t(arg[0]), J, taylor); + break; + // ------------------------------------------------- + + case AFunOp: + // start or end an atomic function call + flag = atom_state == start_atom; + play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + if( flag ) + { atom_state = arg_atom; + atom_i = 0; + atom_j = 0; + // + atom_par_x.resize(atom_n); + atom_type_x.resize(atom_n); + // + atom_tx_one.resize(atom_n * atom_q1); + atom_tx_all.resize(atom_n * (q * r + 1)); + // + atom_ty_one.resize(atom_m * atom_q1); + atom_ty_all.resize(atom_m * (q * r + 1)); + // + atom_iy.resize(atom_m); + } + else + { CPPAD_ASSERT_UNKNOWN( atom_i == atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + atom_state = start_atom; + // + // call atomic function for this operation + for(ell = 0; ell < r; ell++) + { // set atom_tx + for(j = 0; j < atom_n; j++) + { size_t j_all = j * (q * r + 1); + size_t j_one = j * atom_q1; + atom_tx_one[j_one+0] = atom_tx_all[j_all+0]; + for(k = 1; k < atom_q1; k++) + { size_t k_all = j_all + (k-1)*r+1+ell; + size_t k_one = j_one + k; + atom_tx_one[k_one] = atom_tx_all[k_all]; + } + } + // set atom_ty + for(i = 0; i < atom_m; i++) + { size_t i_all = i * (q * r + 1); + size_t i_one = i * atom_q1; + atom_ty_one[i_one+0] = atom_ty_all[i_all+0]; + for(k = 1; k < q; k++) + { size_t k_all = i_all + (k-1)*r+1+ell; + size_t k_one = i_one + k; + atom_ty_one[k_one] = atom_ty_all[k_all]; + } + } + call_atomic_forward( + atom_par_x, + atom_type_x, + need_y, + order_low, + order_up, + atom_index, + atom_old, + atom_tx_one, + atom_ty_one + ); + for(i = 0; i < atom_m; i++) + { if( atom_iy[i] > 0 ) + { size_t i_taylor = atom_iy[i]*((J-1)*r+1); + size_t q_taylor = i_taylor + (q-1)*r+1+ell; + size_t q_one = i * atom_q1 + q; + taylor[q_taylor] = atom_ty_one[q_one]; + } + } + } +# if CPPAD_FORWARD2_TRACE + atom_trace = true; +# endif + } + break; + + case FunapOp: + // parameter argument for a atomic function + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j < atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + if( dyn_par_is[ arg[0] ] ) + atom_type_x[atom_j] = dynamic_enum; + else + atom_type_x[atom_j] = constant_enum; + atom_par_x[atom_j] = parameter[ arg[0] ]; + atom_tx_all[atom_j*(q*r+1) + 0] = parameter[ arg[0]]; + for(ell = 0; ell < r; ell++) + for(k = 1; k < atom_q1; k++) + atom_tx_all[atom_j*(q*r+1) + (k-1)*r+1+ell] = Base(0.0); + // + ++atom_j; + if( atom_j == atom_n ) + atom_state = ret_atom; + break; + + case FunavOp: + // variable argument for a atomic function + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j < atom_n ); + // + atom_type_x[atom_j] = variable_enum; + atom_par_x[atom_j] = CppAD::numeric_limits::quiet_NaN(); + atom_tx_all[atom_j*(q*r+1)+0] = + taylor[size_t(arg[0])*((J-1)*r+1)+0]; + for(ell = 0; ell < r; ell++) + { for(k = 1; k < atom_q1; k++) + { atom_tx_all[atom_j*(q*r+1) + (k-1)*r+1+ell] = + taylor[size_t(arg[0])*((J-1)*r+1) + (k-1)*r+1+ell]; + } + } + // + ++atom_j; + if( atom_j == atom_n ) + atom_state = ret_atom; + break; + + case FunrpOp: + // parameter result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i < atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + // + atom_iy[atom_i] = 0; + atom_ty_all[atom_i*(q*r+1) + 0] = parameter[ arg[0]]; + for(ell = 0; ell < r; ell++) + for(k = 1; k < atom_q1; k++) + atom_ty_all[atom_i*(q*r+1) + (k-1)*r+1+ell] = Base(0.0); + // + ++atom_i; + if( atom_i == atom_m ) + atom_state = end_atom; + break; + + case FunrvOp: + // variable result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i < atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + // + atom_iy[atom_i] = i_var; + atom_ty_all[atom_i*(q*r+1)+0] = taylor[i_var*((J-1)*r+1)+0]; + for(ell = 0; ell < r; ell++) + { for(k = 1; k < atom_q1; k++) + { atom_ty_all[atom_i*(q*r+1) + (k-1)*r+1+ell] = + taylor[i_var*((J-1)*r+1) + (k-1)*r+1+ell]; + } + } + ++atom_i; + if( atom_i == atom_m ) + atom_state = end_atom; + 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); + } +# if CPPAD_FORWARD2_TRACE + if( atom_trace ) + { atom_trace = false; + CPPAD_ASSERT_UNKNOWN( op == AFunOp ); + CPPAD_ASSERT_UNKNOWN( NumArg(FunrvOp) == 0 ); + for(i = 0; i < atom_m; i++) if( atom_iy[i] > 0 ) + { size_t i_tmp = (itr.op_index() + i) - atom_m; + printOp( + std::cout, + play, + i_tmp, + atom_iy[i], + FunrvOp, + CPPAD_NULL + ); + Base* Z_tmp = taylor + atom_iy[i]*((J-1) * r + 1); + { Z_vec[0] = Z_tmp[0]; + for(ell = 0; ell < r; ell++) + { std::cout << std::endl << " "; + 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, + Z_vec.data(), + 0, + (Base *) CPPAD_NULL + ); + } + } + std::cout << std::endl; + } + } + if( op != FunrvOp ) + { printOp( + std::cout, + play, + itr.op_index(), + i_var, + op, + arg + ); + Base* Z_tmp = CPPAD_NULL; + if( op == FunavOp ) + Z_tmp = taylor + size_t(arg[0])*((J-1) * r + 1); + else if( NumRes(op) > 0 ) + Z_tmp = taylor + i_var*((J-1)*r + 1); + if( Z_tmp != CPPAD_NULL ) + { Z_vec[0] = Z_tmp[0]; + for(ell = 0; ell < r; ell++) + { std::cout << std::endl << " "; + 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, + Z_vec.data(), + 0, + (Base *) CPPAD_NULL + ); + } + } + std::cout << std::endl; + } + } + std::cout << std::endl; +# else + } +# endif + CPPAD_ASSERT_UNKNOWN( atom_state == start_atom ); + + return; +} + +// preprocessor symbols that are local to this file +# undef CPPAD_FORWARD2_TRACE + +} } } // END_CPPAD_LOCAL_SWEEP_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sweep/reverse.hpp cppad-2019.02.00.0/include/cppad/local/sweep/reverse.hpp --- cppad-2018.00.00.0/include/cppad/local/sweep/reverse.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sweep/reverse.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,821 @@ +# ifndef CPPAD_LOCAL_SWEEP_REVERSE_HPP +# define CPPAD_LOCAL_SWEEP_REVERSE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +# include + +// BEGIN_CPPAD_LOCAL_SWEEP_NAMESPACE +namespace CppAD { namespace local { namespace sweep { +/*! +\file sweep/reverse.hpp +Compute derivatives of arbitrary order Taylor coefficients. +*/ + +/*! +\def CPPAD_REVERSE_TRACE +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. +*/ +# define CPPAD_REVERSE_TRACE 0 + +/*! +Compute derivative of arbitrary order forward mode Taylor coefficients. + +\tparam Base +this operation sequence was recorded using AD +and computations by this routine are done using type Base. + +\param d +is the highest order Taylor coefficients that +we are computing the derivative of. + +\param n +is the number of independent variables on the tape. + +\param numvar +is the total number of variables on the tape. +This is also equal to the number of rows in the matrix Taylor; i.e., +play->num_var_rec(). + +\param play +The information stored in play +is a recording of the operations corresponding to the function +\f[ + F : {\bf R}^n \rightarrow {\bf R}^m +\f] +where \f$ n \f$ is the number of independent variables and +\f$ m \f$ is the number of dependent variables. +We define \f$ u^{(k)} \f$ as the value of x_k in the previous call +of the form + + f.Forward(k, x_k) + +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 +\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 +\f$ W : {\bf R}^{n \times d} \rightarrow {\bf R} \f$ by +\f[ +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 +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 +\f$ u^{(k)} \f$ for \f$ k = 0 , ... , d \f$. + +\param J +Is the number of columns in the coefficient matrix Taylor. +This must be greater than or equal d + 1. + +\param Taylor +For i = 1 , ... , numvar, and for k = 0 , ... , d, + Taylor [ i * J + k ] +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, +is defined by +\f$ u_j^{(k)} \f$ = Taylor [ j * J + k ] +for j = 1 , ... , n, and for k = 0 , ... , d. + +\param K +Is the number of columns in the partial derivative matrix Partial. +It must be greater than or equal d + 1. + +\param Partial +\b Input: +The last \f$ m \f$ rows of 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, +for k = 0 , ... , d, +Partial [ (numvar - m + i ) * K + k ] = w[i,k]. +\n +\n +\b Temporary: +For i = n+1 , ... , numvar - 1 and for k = 0 , ... , d, +the value of Partial [ i * K + k ] is used for temporary work space +and its output value is not defined. +\n +\n +\b Output: +For j = 1 , ... , n and for k = 0 , ... , d, + Partial [ j * K + k ] +is the partial derivative of \f$ W( u ) \f$ with +respect to \f$ u_j^{(k)} \f$. + +\param cskip_op +Is a vector with size play->num_op_rec(). +If cskip_op[i] is true, the operator index i in the recording +does not affect any of the dependent variable (given the value +of the independent variables). +Note that all the operators in an atomic function call are skipped as a block, +so only the last AFunOp fore each call needs to have cskip_op[i] true. + +\param var_by_load_op +is a vector with size play->num_load_op_rec(). +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). + +\tparam Iterator +This is either player::const_iteratoror player::const_subgraph_iterator. + +\param play_itr +On input this is either play->end(), for the entire graph, +or play->end(subgraph), for a subgraph. +This routine mode will use --play_itr to iterate over the graph or subgraph. +It is assumes that the iterator starts just past the EndOp and it will +continue until it reaches the BeginOp. +If i_var is a variable index, and the corresponding operator +is not in the subgraph, +then the partials with respect to i_var are not modified and need to be +initialized as zero. Note that this means the partial for the independent +varaibles, that are not in the subgraph are not calculated. +If part of an atomic function call is in the subgraph, +the entire atomic function call must be in the subgraph. + +\param not_used_rec_base +Specifies RecBase for this call. + +\par Assumptions +The first operator on the tape is a BeginOp, +and the next n operators are InvOp operations for the +corresponding independent variables; see play->check_inv_op(n_ind). +*/ +template +void reverse( + size_t d, + size_t n, + size_t numvar, + const local::player* play, + size_t J, + const Base* Taylor, + size_t K, + Base* Partial, + bool* cskip_op, + const pod_vector& var_by_load_op, + Iterator& play_itr, + const RecBase& not_used_rec_base +) +{ + // check numvar argument + CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar ); + CPPAD_ASSERT_UNKNOWN( numvar > 0 ); + + // length of the parameter vector (used by CppAD assert macros) + const size_t num_par = play->num_par_rec(); + + // pointer to the beginning of the parameter vector + const Base* parameter = CPPAD_NULL; + if( num_par > 0 ) + parameter = play->GetPar(); + + // work space used by AFunOp. + const size_t atom_k = d; // highest order we are differentiating + const size_t atom_k1 = d+1; // number orders for this calculation + vector atom_par_x; // argument parameter values + vector atom_type_x; // argument type + vector atom_ix; // variable indices for argument vector + vector atom_tx; // argument vector Taylor coefficients + vector atom_ty; // result vector Taylor coefficients + vector atom_px; // partials w.r.t argument vector + vector atom_py; // partials w.r.t. result vector + // + // information defined by atomic forward + size_t atom_index=0, atom_old=0, atom_m=0, atom_n=0, atom_i=0, atom_j=0; + enum_atom_state atom_state = end_atom; // proper initialization + + // temporary indices + size_t j, ell; + + // Initialize +# if CPPAD_REVERSE_TRACE + std::cout << std::endl; +# endif + OpCode op; + const Addr* arg; + size_t i_var; + play_itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == EndOp ); + while(op != BeginOp ) + { bool flag; // temporary for use in switch cases + // + // next op + (--play_itr).op_info(op, arg, i_var); + + // check if we are skipping this operation + size_t i_op = play_itr.op_index(); + while( cskip_op[i_op] ) + { switch(op) + { + case AFunOp: + { // get information for this atomic function call + CPPAD_ASSERT_UNKNOWN( atom_state == end_atom ); + play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + // + // skip to the first AFunOp + for(size_t i = 0; i < atom_m + atom_n + 1; ++i) + --play_itr; + play_itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == AFunOp ); + } + break; + + default: + break; + } + (--play_itr).op_info(op, arg, i_var); + i_op = play_itr.op_index(); + } +# if CPPAD_REVERSE_TRACE + size_t i_tmp = i_var; + const Base* Z_tmp = Taylor + i_var * J; + const Base* pZ_tmp = Partial + i_var * K; + printOp( + std::cout, + play, + i_op, + i_tmp, + op, + arg + ); + if( NumRes(op) > 0 && op != BeginOp ) printOpResult( + std::cout, + d + 1, + Z_tmp, + d + 1, + pZ_tmp + ); + std::cout << std::endl; +# endif + switch( op ) + { + case AbsOp: + reverse_abs_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case AcosOp: + // sqrt(1 - x * x), acos(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_acos_op( + d, i_var, size_t(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, size_t(arg[0]), J, Taylor, K, Partial + ); + break; +# endif + // -------------------------------------------------- + + case AddvvOp: + reverse_addvv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case AddpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + reverse_addpv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case AsinOp: + // sqrt(1 - x * x), asin(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_asin_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case AsinhOp: + // sqrt(1 + x * x), asinh(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_asinh_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; +# endif + // -------------------------------------------------- + + case AtanOp: + // 1 + x * x, atan(x) + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_atan_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + 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, size_t(arg[0]), J, Taylor, K, Partial + ); + break; +# endif + // ------------------------------------------------- + + case BeginOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + CPPAD_ASSERT_UNKNOWN( i_op == 0 ); + break; + // -------------------------------------------------- + + case CSkipOp: + // CSkipOp has a zero order forward action. + play_itr.correct_after_decrement(arg); + break; + // ------------------------------------------------- + + case CSumOp: + play_itr.correct_after_decrement(arg); + reverse_csum_op( + d, i_var, arg, K, Partial + ); + // end of a cumulative summation + break; + // ------------------------------------------------- + + case CExpOp: + reverse_cond_op( + d, + i_var, + arg, + num_par, + parameter, + J, + Taylor, + K, + Partial + ); + break; + // -------------------------------------------------- + + case CosOp: + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_cos_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case CoshOp: + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_cosh_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case DisOp: + // Derivative of discrete operation is zero so no + // contribution passes through this operation. + break; + // -------------------------------------------------- + + case DivvvOp: + reverse_divvv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case DivpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + reverse_divpv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case DivvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + reverse_divvp_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + case EndOp: + CPPAD_ASSERT_UNKNOWN( + i_op == play->num_op_rec() - 1 + ); + break; + + // -------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case ErfOp: + reverse_erf_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; +# endif + // -------------------------------------------------- + + case ExpOp: + reverse_exp_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + reverse_expm1_op( + d, i_var, size_t(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() + ); + break; + // ------------------------------------------------- + + case LdvOp: + reverse_load_op( + op, d, i_var, arg, J, Taylor, K, Partial, var_by_load_op.data() + ); + break; + // -------------------------------------------------- + + case EqppOp: + case EqpvOp: + case EqvvOp: + case LtppOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case LeppOp: + case LepvOp: + case LevpOp: + case LevvOp: + case NeppOp: + case NepvOp: + case NevvOp: + break; + // ------------------------------------------------- + + case LogOp: + reverse_log_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + reverse_log1p_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; +# endif + // -------------------------------------------------- + + case MulpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + reverse_mulpv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case MulvvOp: + reverse_mulvv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case ParOp: + break; + // -------------------------------------------------- + + case PowvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + reverse_powvp_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // ------------------------------------------------- + + case PowpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + reverse_powpv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // ------------------------------------------------- + + case PowvvOp: + reverse_powvv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case PriOp: + // no result so nothing to do + break; + // -------------------------------------------------- + + case SignOp: + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_sign_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; + // ------------------------------------------------- + + case SinOp: + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_sin_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; + // ------------------------------------------------- + + case SinhOp: + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_sinh_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case SqrtOp: + reverse_sqrt_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case StppOp: + break; + // -------------------------------------------------- + + case StpvOp: + break; + // ------------------------------------------------- + + case StvpOp: + break; + // ------------------------------------------------- + + case StvvOp: + break; + // -------------------------------------------------- + + case SubvvOp: + reverse_subvv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case SubpvOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_par ); + reverse_subpv_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case SubvpOp: + CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < num_par ); + reverse_subvp_op( + d, i_var, arg, parameter, J, Taylor, K, Partial + ); + break; + // ------------------------------------------------- + + case TanOp: + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_tan_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; + // ------------------------------------------------- + + case TanhOp: + CPPAD_ASSERT_UNKNOWN( i_var < numvar ); + reverse_tanh_op( + d, i_var, size_t(arg[0]), J, Taylor, K, Partial + ); + break; + // -------------------------------------------------- + + case AFunOp: + // start or end an atomic function call + flag = atom_state == end_atom; + play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + if( flag ) + { atom_state = ret_atom; + atom_i = atom_m; + atom_j = atom_n; + // + atom_ix.resize(atom_n); + atom_par_x.resize(atom_n); + atom_type_x.resize(atom_n); + atom_tx.resize(atom_n * atom_k1); + atom_px.resize(atom_n * atom_k1); + atom_ty.resize(atom_m * atom_k1); + atom_py.resize(atom_m * atom_k1); + } + else + { CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j == 0 ); + atom_state = end_atom; + // + // call atomic function for this operation + call_atomic_reverse( + atom_par_x, + atom_type_x, + atom_k, + atom_index, + atom_old, + atom_tx, + atom_ty, + atom_px, + atom_py + ); + for(j = 0; j < atom_n; j++) if( atom_ix[j] > 0 ) + { for(ell = 0; ell < atom_k1; ell++) + Partial[atom_ix[j] * K + ell] += + atom_px[j * atom_k1 + ell]; + } + } + break; + + case FunapOp: + // parameter argument in an atomic operation sequence + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j <= atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + --atom_j; + atom_ix[atom_j] = 0; + if( play->dyn_par_is()[ arg[0] ] ) + atom_type_x[atom_j] = dynamic_enum; + else + atom_type_x[atom_j] = constant_enum; + atom_par_x[atom_j] = parameter[ arg[0] ]; + atom_tx[atom_j * atom_k1 + 0] = parameter[ arg[0] ]; + for(ell = 1; ell < atom_k1; ell++) + atom_tx[atom_j * atom_k1 + ell] = Base(0.); + // + if( atom_j == 0 ) + atom_state = start_atom; + break; + + case FunavOp: + // variable argument in an atomic operation sequence + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j <= atom_n ); + // + --atom_j; + atom_ix[atom_j] = size_t( arg[0] ); + atom_type_x[atom_j] = variable_enum; + atom_par_x[atom_j] = CppAD::numeric_limits::quiet_NaN(); + for(ell = 0; ell < atom_k1; ell++) + atom_tx[atom_j*atom_k1 + ell] = + Taylor[ size_t(arg[0]) * J + ell]; + // + if( atom_j == 0 ) + atom_state = start_atom; + break; + + case FunrpOp: + // parameter result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i <= atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + --atom_i; + for(ell = 0; ell < atom_k1; ell++) + { atom_py[atom_i * atom_k1 + ell] = Base(0.); + atom_ty[atom_i * atom_k1 + ell] = Base(0.); + } + atom_ty[atom_i * atom_k1 + 0] = parameter[ arg[0] ]; + // + if( atom_i == 0 ) + atom_state = arg_atom; + break; + + case FunrvOp: + // variable result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i <= atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + // + --atom_i; + for(ell = 0; ell < atom_k1; ell++) + { atom_py[atom_i * atom_k1 + ell] = + Partial[i_var * K + ell]; + atom_ty[atom_i * atom_k1 + ell] = + Taylor[i_var * J + ell]; + } + if( atom_i == 0 ) + atom_state = arg_atom; + 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); + } + } +# if CPPAD_REVERSE_TRACE + std::cout << std::endl; +# endif +} + +} } } // END_CPPAD_LOCAL_SWEEP_NAMESPACE + +// preprocessor symbols that are local to this file +# undef CPPAD_REVERSE_TRACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sweep/rev_hes.hpp cppad-2019.02.00.0/include/cppad/local/sweep/rev_hes.hpp --- cppad-2018.00.00.0/include/cppad/local/sweep/rev_hes.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sweep/rev_hes.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,812 @@ +# ifndef CPPAD_LOCAL_SWEEP_REV_HES_HPP +# define CPPAD_LOCAL_SWEEP_REV_HES_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include + +// BEGIN_CPPAD_LOCAL_SWEEP_NAMESPACE +namespace CppAD { namespace local { namespace sweep { +/*! +\file sweep/rev_hes.hpp +Compute Reverse mode Hessian sparsity patterns. +*/ + +/*! +\def CPPAD_REV_HES_TRACE +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. +*/ +# define CPPAD_REV_HES_TRACE 0 + +/*! +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 +variables. + +\tparam Base +this operation sequence was recorded using AD. + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or sparse_list. + +\param n +is the number of independent variables on the tape. + +\param numvar +is the total number of variables on the tape; i.e., + play->num_var_rec(). +This is also the number of rows in the entire sparsity pattern + rev_hes_sparse. + +\param play +The information stored in play +is a recording of the operations corresponding to a function +\f[ + F : {\bf R}^n \rightarrow {\bf R}^m +\f] +where \f$ n \f$ is the number of independent variables +and \f$ m \f$ is the number of dependent variables. + +\param for_jac_sparse +For i = 0 , ... , 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 for_jac_sparse. + +\param RevJac +\b Input: +For i = 0, ... , numvar - 1 +the if the variable with index i on the tape is an dependent variable and +included in the Hessian, RevJac[ i ] is equal to true, +otherwise it is equal to false. +\n +\n +\b Output: The values in RevJac upon return are not specified; i.e., +it is used for temporary work space. + +\param rev_hes_sparse +The reverse Hessian sparsity pattern for the variable with index i +corresponds to the set with index i in rev_hes_sparse. +\n +\n +\b Input: For i = 0 , ... , numvar - 1 +the reverse Hessian sparsity pattern for the variable with index i is empty. +\n +\n +\b Output: For j = 1 , ... , n, +the reverse Hessian sparsity pattern for the independent dependent variable +with index (j-1) is given by the set with index j +in rev_hes_sparse. +The values in the rest of rev_hes_sparse are not specified; i.e., +they are used for temporary work space. + +\param not_used_rec_base +Specifies RecBase for this call. +*/ + +template +void rev_hes( + const local::player* play, + size_t n, + size_t numvar, + const Vector_set& for_jac_sparse, + bool* RevJac, + Vector_set& rev_hes_sparse, + const RecBase& not_used_rec_base +) +{ + // length of the parameter vector (used by CppAD assert macros) + const size_t num_par = play->num_par_rec(); + + size_t i, j, k; + + // check numvar argument + CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar ); + CPPAD_ASSERT_UNKNOWN( for_jac_sparse.n_set() == numvar ); + CPPAD_ASSERT_UNKNOWN( rev_hes_sparse.n_set() == numvar ); + CPPAD_ASSERT_UNKNOWN( numvar > 0 ); + + // upper limit exclusive for set elements + size_t limit = rev_hes_sparse.end(); + CPPAD_ASSERT_UNKNOWN( for_jac_sparse.end() == limit ); + + // check number of sets match + 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) + // 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(); + Vector_set vecad_sparse; + pod_vector vecad_ind; + pod_vector vecad_jac; + if( num_vecad_vec > 0 ) + { size_t length; + vecad_sparse.resize(num_vecad_vec, limit); + vecad_ind.extend(num_vecad_ind); + vecad_jac.extend(num_vecad_vec); + j = 0; + for(i = 0; i < num_vecad_vec; i++) + { // length of this VecAD + length = play->GetVecInd(j); + // set vecad_ind to proper index for this VecAD + 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 + vecad_jac[i] = false; + } + CPPAD_ASSERT_UNKNOWN( j == play->num_vec_ind_rec() ); + } + + // ---------------------------------------------------------------------- + // work space used by AFunOp. + vector atom_x; // value of parameter arguments to function + vector type_x; // argument types + pod_vector atom_ix; // variable indices for argument vector + pod_vector atom_iy; // variable indices for result vector + // + // information set by atomic forward (initialization to avoid warnings) + size_t atom_index=0, atom_old=0, atom_m=0, atom_n=0, atom_i=0, atom_j=0; + // information set by atomic forward (necessary initialization) + enum_atom_state atom_state = end_atom; // proper initialization + // ---------------------------------------------------------------------- + // + // pointer to the beginning of the parameter vector + // (used by atomic functions + const Base* parameter = CPPAD_NULL; + if( num_par > 0 ) + parameter = play->GetPar(); + // + // which parametes are dynamic + const pod_vector& dyn_par_is( play->dyn_par_is() ); + // + // skip the EndOp at the end of the recording + play::const_sequential_iterator itr = play->end(); + // op_info + OpCode op; + size_t i_var; + const Addr* arg; + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == EndOp ); +# if CPPAD_REV_HES_TRACE + std::cout << std::endl; + CppAD::vectorBool zf_value(limit); + CppAD::vectorBool zh_value(limit); +# endif + bool more_operators = true; + while(more_operators) + { bool flag; // temporary for use in switch cases + // + // next op + (--itr).op_info(op, arg, i_var); + + // rest of information depends on the case + switch( op ) + { + case AbsOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1) + reverse_sparse_hessian_linear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case AddvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_addsub_op( + i_var, arg, RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case AddpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_linear_unary_op( + i_var, size_t(arg[1]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case AcosOp: + // sqrt(1 - x * x), acos(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + 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, size_t(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) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + 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, size_t(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) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + 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, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; +# endif + // ------------------------------------------------- + + case BeginOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1) + more_operators = false; + break; + // ------------------------------------------------- + + case CSkipOp: + itr.correct_after_decrement(arg); + break; + // ------------------------------------------------- + + case CSumOp: + itr.correct_after_decrement(arg); + reverse_sparse_hessian_csum_op( + i_var, arg, RevJac, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case CExpOp: + reverse_sparse_hessian_cond_op( + i_var, arg, num_par, RevJac, rev_hes_sparse + ); + break; + // --------------------------------------------------- + + case CosOp: + // sin(x), cos(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // --------------------------------------------------- + + case CoshOp: + // sinh(x), cosh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case DisOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + // derivativve is identically zero + break; + // ------------------------------------------------- + + case DivvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_div_op( + i_var, arg, RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case DivpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[1]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case DivvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_linear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case ErfOp: + // arg[1] is always the parameter 0 + // arg[2] is always the parameter 2 / sqrt(pi) + CPPAD_ASSERT_NARG_NRES(op, 3, 5); + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case ExpOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + CPPAD_ASSERT_NARG_NRES(op, 1, 1) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; +# endif + // ------------------------------------------------- + + case InvOp: + CPPAD_ASSERT_NARG_NRES(op, 0, 1) + // Z is already defined + break; + // ------------------------------------------------- + + case LdpOp: + reverse_sparse_hessian_load_op( + op, + i_var, + arg, + num_vecad_ind, + vecad_ind.data(), + rev_hes_sparse, + vecad_sparse, + RevJac, + vecad_jac.data() + ); + break; + // ------------------------------------------------- + + case LdvOp: + reverse_sparse_hessian_load_op( + op, + i_var, + arg, + num_vecad_ind, + vecad_ind.data(), + rev_hes_sparse, + vecad_sparse, + RevJac, + vecad_jac.data() + ); + break; + // ------------------------------------------------- + + case EqppOp: + case EqpvOp: + case EqvvOp: + case LtppOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case LeppOp: + case LepvOp: + case LevpOp: + case LevvOp: + case NeppOp: + 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( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; +# endif + // ------------------------------------------------- + + case MulpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_linear_unary_op( + i_var, size_t(arg[1]), RevJac, for_jac_sparse, rev_hes_sparse + ); + 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) + + break; + // ------------------------------------------------- + + case PowpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 3) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[1]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case PowvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 3) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case PowvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 3) + reverse_sparse_hessian_pow_op( + i_var, arg, RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case PriOp: + CPPAD_ASSERT_NARG_NRES(op, 5, 0); + break; + // ------------------------------------------------- + + case SignOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + // Derivative is identiaclly zero + break; + // ------------------------------------------------- + + case SinOp: + // cos(x), sin(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case SinhOp: + // cosh(x), sinh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case SqrtOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case StppOp: + // sparsity cannot propagate through a parameter + CPPAD_ASSERT_NARG_NRES(op, 3, 0) + break; + // ------------------------------------------------- + + case StpvOp: + reverse_sparse_hessian_store_op( + op, + arg, + num_vecad_ind, + vecad_ind.data(), + rev_hes_sparse, + vecad_sparse, + RevJac, + vecad_jac.data() + ); + break; + // ------------------------------------------------- + + case StvpOp: + // sparsity cannot propagate through a parameter + CPPAD_ASSERT_NARG_NRES(op, 3, 0) + break; + // ------------------------------------------------- + + case StvvOp: + reverse_sparse_hessian_store_op( + op, + arg, + num_vecad_ind, + vecad_ind.data(), + rev_hes_sparse, + vecad_sparse, + RevJac, + vecad_jac.data() + ); + break; + // ------------------------------------------------- + + case SubvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_addsub_op( + i_var, arg, RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case SubpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_linear_unary_op( + i_var, size_t(arg[1]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case SubvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_linear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case TanOp: + // tan(x)^2, tan(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case TanhOp: + // tanh(x)^2, tanh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2) + reverse_sparse_hessian_nonlinear_unary_op( + i_var, size_t(arg[0]), RevJac, for_jac_sparse, rev_hes_sparse + ); + break; + // ------------------------------------------------- + + case AFunOp: + // start or end an atomic function call + CPPAD_ASSERT_UNKNOWN( + atom_state == start_atom || atom_state == end_atom + ); + flag = atom_state == end_atom; + play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + if( flag ) + { atom_state = ret_atom; + atom_i = atom_m; + atom_j = atom_n; + // + atom_x.resize(atom_n); + type_x.resize(atom_n); + atom_ix.resize(atom_n); + atom_iy.resize(atom_m); + } + else + { CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j == 0 ); + atom_state = end_atom; + // + // call atomic function for this operation + call_atomic_rev_hes_sparsity( + atom_index, atom_old, atom_x, type_x, atom_ix, atom_iy, + for_jac_sparse, RevJac, rev_hes_sparse + ); + } + break; + + case FunapOp: + // parameter argument in an atomic operation sequence + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j <= atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + --atom_j; + // argument parameter value + atom_x[atom_j] = parameter[arg[0]]; + // argument type + if( dyn_par_is[arg[0]] ) + type_x[atom_j] = dynamic_enum; + else + type_x[atom_j] = constant_enum; + // special variable index used for parameters + atom_ix[atom_j] = 0; + // + if( atom_j == 0 ) + atom_state = start_atom; + break; + + case FunavOp: + // variable argument in an atomic operation sequence + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j <= atom_n ); + // + --atom_j; + // argument variables not available during sparsity calculations + atom_x[atom_j] = CppAD::numeric_limits::quiet_NaN(); + type_x[atom_j] = variable_enum; + // variable index for this argument + atom_ix[atom_j] = size_t(arg[0]); + // + if( atom_j == 0 ) + atom_state = start_atom; + break; + + case FunrpOp: + // parameter result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i <= atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + --atom_i; + atom_iy[atom_i] = 0; // special variable used for parameters + // + if( atom_i == 0 ) + atom_state = arg_atom; + break; + + case FunrvOp: + // variable result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i <= atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + // + --atom_i; + atom_iy[atom_i] = i_var; // variable for this result + // + if( atom_i == 0 ) + atom_state = arg_atom; + break; + // ------------------------------------------------- + + case ZmulpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1) + reverse_sparse_hessian_linear_unary_op( + i_var, size_t(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, size_t(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; + + // ------------------------------------------------- + + default: + CPPAD_ASSERT_UNKNOWN(0); + } +# if CPPAD_REV_HES_TRACE + for(j = 0; j < limit; j++) + { zf_value[j] = false; + zh_value[j] = false; + } + typename Vector_set::const_iterator itr_jac(for_jac_sparse, i_var); + j = *itr_jac; + while( j < limit ) + { zf_value[j] = true; + j = *(++itr_jac); + } + typename Vector_set::const_iterator itr_hes(rev_hes_sparse, i_var); + j = *itr_hes; + while( j < limit ) + { zh_value[j] = true; + j = *(++itr_hes); + } + printOp( + std::cout, + play, + itr.op_index(), + i_var, + 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, + &zh_value + ); + std::cout << std::endl; + } + std::cout << std::endl; +# else + } +# endif + // values corresponding to BeginOp + CPPAD_ASSERT_UNKNOWN( itr.op_index() == 0 ); + CPPAD_ASSERT_UNKNOWN( i_var == 0 ); + + return; +} +} } } // END_CPPAD_LOCAL_SWEEP_NAMESPACE + +// preprocessor symbols that are local to this file +# undef CPPAD_REV_HES_TRACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/sweep/rev_jac.hpp cppad-2019.02.00.0/include/cppad/local/sweep/rev_jac.hpp --- cppad-2018.00.00.0/include/cppad/local/sweep/rev_jac.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/sweep/rev_jac.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,794 @@ +# ifndef CPPAD_LOCAL_SWEEP_REV_JAC_HPP +# define CPPAD_LOCAL_SWEEP_REV_JAC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include + +// BEGIN_CPPAD_LOCAL_SWEEP_NAMESPACE +namespace CppAD { namespace local { namespace sweep { +/*! +\file sweep/rev_jac.hpp +Compute Reverse mode Jacobian sparsity patterns. +*/ + +/*! +\def CPPAD_REV_JAC_TRACE +This value is either zero or one. +Zero is the normal operational value. +If it is one, a trace of every rev_jac_sweep computation is printed. +*/ +# define CPPAD_REV_JAC_TRACE 0 + +/*! +Given the sparsity pattern for the dependent variables, +RevJacSweep computes the sparsity pattern for all the independent variables. + +\tparam Base +this operation sequence was recorded using AD. + +\tparam Vector_set +is the type used for vectors of sets. It can be either +sparse_pack or 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. + +\param numvar +is the total number of variables on the tape; i.e., + play->num_var_rec(). +This is also the number of rows in the entire sparsity pattern RevJac. + +\param play +The information stored in play +is a recording of the operations corresponding to a function +\f[ + F : {\bf R}^n \rightarrow {\bf R}^m +\f] +where \f$ n \f$ is the number of independent variables +and \f$ m \f$ is the number of dependent variables. + +\param var_sparsity +For i = 0 , ... , numvar - 1, +(all the variables on the tape) +the forward Jacobian sparsity pattern for variable i +corresponds to the set with index i in var_sparsity. +\b +\b +\b Input: +For i = 0 , ... , numvar - 1, +the forward Jacobian sparsity pattern for variable i is an input +if i corresponds to a dependent variable. +Otherwise the sparsity patten is empty. +\n +\n +\b Output: For j = 1 , ... , n, +the sparsity pattern for the dependent variable with index (j-1) +is given by the set with index index j in var_sparsity. + +\param not_used_rec_base +Specifies RecBase for this call. +*/ + +template +void rev_jac( + const local::player* play, + bool dependency, + size_t n, + size_t numvar, + Vector_set& var_sparsity, + const RecBase& not_used_rec_base +) +{ + size_t i, j, k; + + // length of the parameter vector (used by CppAD assert macros) + const size_t num_par = play->num_par_rec(); + + // check numvar argument + CPPAD_ASSERT_UNKNOWN( numvar > 0 ); + CPPAD_ASSERT_UNKNOWN( play->num_var_rec() == numvar ); + CPPAD_ASSERT_UNKNOWN( var_sparsity.n_set() == numvar ); + + // upper limit (exclusive) for elements in the set + size_t limit = var_sparsity.end(); + + // vecad_sparsity contains a sparsity pattern for each VecAD object. + // vecad_ind maps a VecAD index (beginning of the VecAD object) + // to the index of 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(); + Vector_set vecad_sparsity; + pod_vector vecad_ind; + if( num_vecad_vec > 0 ) + { size_t length; + vecad_sparsity.resize(num_vecad_vec, limit); + vecad_ind.extend(num_vecad_ind); + j = 0; + for(i = 0; i < num_vecad_vec; i++) + { // length of this VecAD + length = play->GetVecInd(j); + // set to proper index for this VecAD + vecad_ind[j] = i; + for(k = 1; k <= length; k++) + vecad_ind[j+k] = num_vecad_vec; // invalid index + // start of next VecAD + j += length + 1; + } + CPPAD_ASSERT_UNKNOWN( j == play->num_vec_ind_rec() ); + } + + // ---------------------------------------------------------------------- + // work space used by AFunOp. + vector atom_x; // value of parameter arguments to function + vector type_x; // argument types + pod_vector atom_ix; // variable indices for argument vector + pod_vector atom_iy; // variable indices for result vector + // + // information set by atomic forward (initialization to avoid warnings) + size_t atom_index=0, atom_old=0, atom_m=0, atom_n=0, atom_i=0, atom_j=0; + // information set by atomic forward (necessary initialization) + enum_atom_state atom_state = end_atom; // proper initialization + // ---------------------------------------------------------------------- + // + // pointer to the beginning of the parameter vector + // (used by atomic functions + const Base* parameter = CPPAD_NULL; + if( num_par > 0 ) + parameter = play->GetPar(); + // + // which parametes are dynamic + const pod_vector& dyn_par_is( play->dyn_par_is() ); + // + // skip the EndOp at the end of the recording + play::const_sequential_iterator itr = play->end(); + // op_info + OpCode op; + size_t i_var; + const Addr* arg; + itr.op_info(op, arg, i_var); + CPPAD_ASSERT_UNKNOWN( op == EndOp ); +# if CPPAD_REV_JAC_TRACE + std::cout << std::endl; + CppAD::vectorBool z_value(limit); +# endif + bool more_operators = true; + while(more_operators) + { bool flag; // temporary for use in switch cases + // + // next op + (--itr).op_info(op, arg, i_var); + + // rest of information depends on the case + switch( op ) + { + case AbsOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case AddvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_binary_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + + case AddpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + break; + // ------------------------------------------------- + + case AcosOp: + // sqrt(1 - x * x), acos(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + 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, size_t(arg[0]), var_sparsity + ); + break; +# endif + // ------------------------------------------------- + + case AsinOp: + // sqrt(1 - x * x), asin(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + 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, size_t(arg[0]), var_sparsity + ); + break; +# endif + // ------------------------------------------------- + + case AtanOp: + // 1 + x * x, atan(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + 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, size_t(arg[0]), var_sparsity + ); + break; +# endif + // ------------------------------------------------- + + case BeginOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + more_operators = false; + break; + // ------------------------------------------------- + + case CSkipOp: + itr.correct_after_decrement(arg); + break; + // ------------------------------------------------- + + case CSumOp: + itr.correct_after_decrement(arg); + reverse_sparse_jacobian_csum_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + + case CExpOp: + reverse_sparse_jacobian_cond_op( + dependency, i_var, arg, num_par, var_sparsity + ); + break; + // --------------------------------------------------- + + case CosOp: + // sin(x), cos(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // --------------------------------------------------- + + case CoshOp: + // sinh(x), cosh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case DisOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + // derivative is identically zero but dependency is not + if( dependency ) reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + break; + // ------------------------------------------------- + + case DivvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_binary_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + + case DivpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + break; + // ------------------------------------------------- + + case DivvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + 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); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case ExpOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Expm1Op: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; +# endif + // ------------------------------------------------- + + case InvOp: + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + break; + // ------------------------------------------------- + + case LdpOp: + reverse_sparse_jacobian_load_op( + dependency, + op, + i_var, + arg, + num_vecad_ind, + vecad_ind.data(), + var_sparsity, + vecad_sparsity + ); + break; + // ------------------------------------------------- + + case LdvOp: + reverse_sparse_jacobian_load_op( + dependency, + op, + i_var, + arg, + num_vecad_ind, + vecad_ind.data(), + var_sparsity, + vecad_sparsity + ); + break; + // ------------------------------------------------- + + case EqppOp: + case EqpvOp: + case EqvvOp: + case LtppOp: + case LtpvOp: + case LtvpOp: + case LtvvOp: + case LeppOp: + case LepvOp: + case LevpOp: + case LevvOp: + case NeppOp: + 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( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + +# if CPPAD_USE_CPLUSPLUS_2011 + case Log1pOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; +# endif + // ------------------------------------------------- + + case MulpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + 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); + + break; + // ------------------------------------------------- + + case PowvpOp: + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case PowpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 3); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + break; + // ------------------------------------------------- + + case PowvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 3); + reverse_sparse_jacobian_binary_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + + case PriOp: + CPPAD_ASSERT_NARG_NRES(op, 5, 0); + break; + // ------------------------------------------------- + + case SignOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + // derivative is identically zero but dependency is not + if( dependency ) reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case SinOp: + // cos(x), sin(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case SinhOp: + // cosh(x), sinh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case SqrtOp: + CPPAD_ASSERT_NARG_NRES(op, 1, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case StppOp: + // 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, + vecad_ind.data(), + var_sparsity, + vecad_sparsity + ); + break; + // ------------------------------------------------- + + 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, + vecad_ind.data(), + var_sparsity, + vecad_sparsity + ); + break; + // ------------------------------------------------- + + case SubvvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_binary_op( + i_var, arg, var_sparsity + ); + break; + // ------------------------------------------------- + + case SubpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + break; + // ------------------------------------------------- + + case SubvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case TanOp: + // tan(x)^2, tan(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case TanhOp: + // tanh(x)^2, tanh(x) + CPPAD_ASSERT_NARG_NRES(op, 1, 2); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[0]), var_sparsity + ); + break; + // ------------------------------------------------- + + case AFunOp: + // start or end an atomic function call + CPPAD_ASSERT_UNKNOWN( + atom_state == start_atom || atom_state == end_atom + ); + flag = atom_state == end_atom; + play::atom_op_info( + op, arg, atom_index, atom_old, atom_m, atom_n + ); + if( flag ) + { atom_state = ret_atom; + atom_i = atom_m; + atom_j = atom_n; + // + atom_x.resize( atom_n ); + type_x.resize( atom_n ); + atom_ix.resize( atom_n ); + atom_iy.resize( atom_m ); + } + else + { CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j == 0 ); + atom_state = end_atom; + // + call_atomic_rev_jac_sparsity( + atom_index, + atom_old, + dependency, + atom_x, + type_x, + atom_ix, + atom_iy, + var_sparsity + ); + } + break; + + case FunapOp: + // parameter argument in an atomic operation sequence + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j <= atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + --atom_j; + // argument parameter value + atom_x[atom_j] = parameter[arg[0]]; + // argument type + if( dyn_par_is[arg[0]] ) + type_x[atom_j] = dynamic_enum; + else + type_x[atom_j] = constant_enum; + // special variable index used for parameters + atom_ix[atom_j] = 0; + // + if( atom_j == 0 ) + atom_state = start_atom; + break; + + case FunavOp: + // variable argument in an atomic operation sequence + CPPAD_ASSERT_UNKNOWN( NumArg(op) == 1 ); + CPPAD_ASSERT_UNKNOWN( atom_state == arg_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i == 0 ); + CPPAD_ASSERT_UNKNOWN( atom_j <= atom_n ); + // + --atom_j; + // argument variables not available during sparsity calculations + atom_x[atom_j] = CppAD::numeric_limits::quiet_NaN(); + type_x[atom_j] = variable_enum; + // variable index for this argument + atom_ix[atom_j] = size_t(arg[0]); + // + if( atom_j == 0 ) + atom_state = start_atom; + break; + + case FunrpOp: + // parameter result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 1, 0); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i <= atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + CPPAD_ASSERT_UNKNOWN( size_t( arg[0] ) < num_par ); + // + --atom_i; + atom_iy[atom_i] = 0; // special variable used for parameters + // + if( atom_i == 0 ) + atom_state = arg_atom; + break; + + case FunrvOp: + // variable result for a atomic function + CPPAD_ASSERT_NARG_NRES(op, 0, 1); + CPPAD_ASSERT_UNKNOWN( atom_state == ret_atom ); + CPPAD_ASSERT_UNKNOWN( atom_i <= atom_m ); + CPPAD_ASSERT_UNKNOWN( atom_j == atom_n ); + // + --atom_i; + atom_iy[atom_i] = i_var; // variable for this result + // + if( atom_i == 0 ) + atom_state = arg_atom; + break; + // ------------------------------------------------- + + case ZmulpvOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(arg[1]), var_sparsity + ); + break; + // ------------------------------------------------- + + case ZmulvpOp: + CPPAD_ASSERT_NARG_NRES(op, 2, 1); + reverse_sparse_jacobian_unary_op( + i_var, size_t(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); + } +# if CPPAD_REV_JAC_TRACE + for(j = 0; j < limit; j++) + z_value[j] = false; + typename Vector_set::const_iterator itr(var_sparsity, i_var); + j = *itr; + while( j < limit ) + { z_value[j] = true; + j = *(++itr); + } + printOp( + std::cout, + play, + itr.op_index(), + i_var, + op, + arg + ); + // Note that sparsity for FunrvOp are computed before call to + // atomic function so no need to delay printing (as in forward mode) + if( NumRes(op) > 0 && op != BeginOp ) printOpResult( + std::cout, + 0, + (CppAD::vectorBool *) CPPAD_NULL, + 1, + &z_value + ); + std::cout << std::endl; + } + std::cout << std::endl; +# else + } +# endif + // values corresponding to BeginOp + CPPAD_ASSERT_UNKNOWN( itr.op_index() == 0 ); + CPPAD_ASSERT_UNKNOWN( i_var == 0 ); + + return; +} + +// preprocessor symbols that are local to this file +# undef CPPAD_REV_JAC_TRACE + +} } } // END_CPPAD_LOCAL_SWEEP_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/tanh_op.hpp cppad-2019.02.00.0/include/cppad/local/tanh_op.hpp --- cppad-2018.00.00.0/include/cppad/local/tanh_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/tanh_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,230 @@ +# ifndef CPPAD_LOCAL_TANH_OP_HPP +# define CPPAD_LOCAL_TANH_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file tanh_op.hpp +Forward and reverse mode calculations for z = tanh(x). +*/ + + +/*! +Compute forward mode Taylor coefficient for result of op = TanOp. + +The C++ source code corresponding to this operation is +\verbatim + z = tanh(x) +\endverbatim +The auxillary result is +\verbatim + y = tanh(x)^2 +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails CppAD::local::forward_unary2_op +*/ +template +void forward_tanh_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(TanOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 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* y = z - cap_order; + + size_t k; + if( p == 0 ) + { z[0] = tanh( x[0] ); + y[0] = z[0] * z[0]; + p++; + } + for(size_t j = p; j <= q; j++) + { Base base_j = static_cast(double(j)); + + z[j] = x[j]; + for(k = 1; k <= j; k++) + z[j] -= Base(double(k)) * x[k] * y[j-k] / base_j; + + y[j] = z[0] * z[j]; + for(k = 1; k <= j; k++) + y[j] += z[k] * z[j-k]; + } +} + +/*! +Multiple directions forward mode Taylor coefficient for op = TanOp. + +The C++ source code corresponding to this operation is +\verbatim + z = tanh(x) +\endverbatim +The auxillary result is +\verbatim + y = tanh(x)^2 +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails CppAD::local::forward_unary2_op_dir +*/ +template +void forward_tanh_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(TanOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 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* y = z - num_taylor_per_var; + + size_t k; + size_t m = (q-1) * r + 1; + for(size_t ell = 0; ell < r; ell++) + { z[m+ell] = Base(double(q)) * ( x[m+ell] - x[m+ell] * y[0] ); + for(k = 1; k < q; k++) + z[m+ell] -= Base(double(k)) * x[(k-1)*r+1+ell] * y[(q-k-1)*r+1+ell]; + z[m+ell] /= Base(double(q)); + // + y[m+ell] = Base(2.0) * z[m+ell] * z[0]; + for(k = 1; k < q; k++) + y[m+ell] += z[(k-1)*r+1+ell] * z[(q-k-1)*r+1+ell]; + } +} + +/*! +Compute zero order forward mode Taylor coefficient for result of op = TanOp. + +The C++ source code corresponding to this operation is +\verbatim + z = tanh(x) +\endverbatim +The auxillary result is +\verbatim + y = cos(x) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails CppAD::local::forward_unary2_op_0 +*/ +template +void forward_tanh_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(TanOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 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; // called z in documentation + Base* y = z - cap_order; // called y in documentation + + z[0] = tanh( x[0] ); + y[0] = z[0] * z[0]; +} + +/*! +Compute reverse mode partial derivatives for result of op = TanOp. + +The C++ source code corresponding to this operation is +\verbatim + z = tanh(x) +\endverbatim +The auxillary result is +\verbatim + y = cos(x) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails CppAD::local::reverse_unary2_op +*/ + +template +void reverse_tanh_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(TanOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 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; // called z in doc + Base* pz = partial + i_z * nc_partial; + + // Taylor coefficients and partials corresponding to auxillary result + 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); + while(j) + { + px[j] += pz[j]; + pz[j] /= Base(double(j)); + for(k = 1; k <= j; k++) + { px[k] -= azmul(pz[j], y[j-k]) * Base(double(k)); + py[j-k] -= azmul(pz[j], x[k]) * Base(double(k)); + } + for(k = 0; k < j; k++) + pz[k] += azmul(py[j-1], z[j-k-1]) * base_two; + + --j; + } + px[0] += azmul(pz[0], Base(1.0) - y[0]); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/tan_op.hpp cppad-2019.02.00.0/include/cppad/local/tan_op.hpp --- cppad-2018.00.00.0/include/cppad/local/tan_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/tan_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,231 @@ +# ifndef CPPAD_LOCAL_TAN_OP_HPP +# define CPPAD_LOCAL_TAN_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE +/*! +\file tan_op.hpp +Forward and reverse mode calculations for z = tan(x). +*/ + + +/*! +Compute forward mode Taylor coefficient for result of op = TanOp. + +The C++ source code corresponding to this operation is +\verbatim + z = tan(x) +\endverbatim +The auxillary result is +\verbatim + y = tan(x)^2 +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails CppAD::local::forward_unary2_op +*/ +template +void forward_tan_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(TanOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 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* y = z - cap_order; + + size_t k; + if( p == 0 ) + { z[0] = tan( x[0] ); + y[0] = z[0] * z[0]; + p++; + } + for(size_t j = p; j <= q; j++) + { Base base_j = static_cast(double(j)); + + z[j] = x[j]; + for(k = 1; k <= j; k++) + z[j] += Base(double(k)) * x[k] * y[j-k] / base_j; + + y[j] = z[0] * z[j]; + for(k = 1; k <= j; k++) + y[j] += z[k] * z[j-k]; + } +} + +/*! +Multiple directions forward mode Taylor coefficient for op = TanOp. + +The C++ source code corresponding to this operation is +\verbatim + z = tan(x) +\endverbatim +The auxillary result is +\verbatim + y = tan(x)^2 +\endverbatim +The value of y, and its derivatives, are computed along with the value +and derivatives of z. + +\copydetails CppAD::local::forward_unary2_op_dir +*/ +template +void forward_tan_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(TanOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 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* y = z - num_taylor_per_var; + + size_t k; + size_t m = (q-1) * r + 1; + for(size_t ell = 0; ell < r; ell++) + { z[m+ell] = Base(double(q)) * ( x[m+ell] + x[m+ell] * y[0]); + for(k = 1; k < q; k++) + z[m+ell] += Base(double(k)) * x[(k-1)*r+1+ell] * y[(q-k-1)*r+1+ell]; + z[m+ell] /= Base(double(q)); + // + y[m+ell] = Base(2.0) * z[m+ell] * z[0]; + for(k = 1; k < q; k++) + y[m+ell] += z[(k-1)*r+1+ell] * z[(q-k-1)*r+1+ell]; + } +} + + +/*! +Compute zero order forward mode Taylor coefficient for result of op = TanOp. + +The C++ source code corresponding to this operation is +\verbatim + z = tan(x) +\endverbatim +The auxillary result is +\verbatim + y = cos(x) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails CppAD::local::forward_unary2_op_0 +*/ +template +void forward_tan_op_0( + size_t i_z , + size_t i_x , + size_t cap_order , + Base* taylor ) +{ + // check assumptions + CPPAD_ASSERT_UNKNOWN( NumArg(TanOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 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; // called z in documentation + Base* y = z - cap_order; // called y in documentation + + z[0] = tan( x[0] ); + y[0] = z[0] * z[0]; +} + +/*! +Compute reverse mode partial derivatives for result of op = TanOp. + +The C++ source code corresponding to this operation is +\verbatim + z = tan(x) +\endverbatim +The auxillary result is +\verbatim + y = cos(x) +\endverbatim +The value of y is computed along with the value of z. + +\copydetails CppAD::local::reverse_unary2_op +*/ + +template +void reverse_tan_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(TanOp) == 1 ); + CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 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; // called z in doc + Base* pz = partial + i_z * nc_partial; + + // Taylor coefficients and partials corresponding to auxillary result + 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); + while(j) + { + px[j] += pz[j]; + pz[j] /= Base(double(j)); + for(k = 1; k <= j; k++) + { px[k] += azmul(pz[j], y[j-k]) * Base(double(k)); + py[j-k] += azmul(pz[j], x[k]) * Base(double(k)); + } + for(k = 0; k < j; k++) + pz[k] += azmul(py[j-1], z[j-k-1]) * base_two; + + --j; + } + px[0] += azmul(pz[0], Base(1.0) + y[0]); +} + +} } // END_CPPAD_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/local/zmul_op.hpp cppad-2019.02.00.0/include/cppad/local/zmul_op.hpp --- cppad-2018.00.00.0/include/cppad/local/zmul_op.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/local/zmul_op.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,517 @@ +# ifndef CPPAD_LOCAL_ZMUL_OP_HPP +# define CPPAD_LOCAL_ZMUL_OP_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +namespace CppAD { namespace local { // BEGIN_CPPAD_LOCAL_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 parameter is not used. + +\copydetails CppAD::local::forward_binary_op +*/ + +template +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 + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(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.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 parameter is not used. + +\copydetails CppAD::local::forward_binary_op_dir +*/ + +template +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 + size_t(arg[0]) * num_taylor_per_var; + Base* y = taylor + size_t(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 parameter is not used. + +\copydetails CppAD::local::forward_binary_op_0 +*/ + +template +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 + size_t(arg[0]) * cap_order; + Base* y = taylor + size_t(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 parameter is not used. + +\copydetails CppAD::local::reverse_binary_op +*/ + +template +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 + size_t(arg[0]) * cap_order; + const Base* y = taylor + size_t(arg[1]) * cap_order; + + // Partial derivatives corresponding to arguments and result + Base* px = partial + size_t(arg[0]) * nc_partial; + Base* py = partial + size_t(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 CppAD::local::forward_binary_op +*/ + +template +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 + size_t(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 CppAD::local::forward_binary_op_dir +*/ + +template +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 + size_t(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 CppAD::local::forward_binary_op_0 +*/ + +template +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 + size_t(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 CppAD::local::reverse_binary_op +*/ + +template +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 + size_t(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 CppAD::local::forward_binary_op +*/ + +template +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 + size_t(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 CppAD::local::forward_binary_op_dir +*/ + +template +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 + size_t(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 CppAD::local::forward_binary_op_0 +*/ + +template +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 + size_t(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 CppAD::local::reverse_binary_op +*/ + +template +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 + size_t(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_LOCAL_NAMESPACE +# endif diff -Nru cppad-2018.00.00.0/include/cppad/speed/det_33.hpp cppad-2019.02.00.0/include/cppad/speed/det_33.hpp --- cppad-2018.00.00.0/include/cppad/speed/det_33.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/speed/det_33.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,113 @@ +# ifndef CPPAD_SPEED_DET_33_HPP +# define CPPAD_SPEED_DET_33_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin det_33$$ +$spell + cppad + CppAD + det + namespace + const + bool + hpp +$$ + +$section Check Determinant of 3 by 3 matrix$$ + + +$head Syntax$$ +$codei%# include +%$$ +$icode%ok% = det_33(%x%, %d%)%$$ + +$head Purpose$$ +This routine can be used to check a method for computing +the determinant of a matrix. + +$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$$ +(relative to the CppAD distribution directory). + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %Vector% &%x% +%$$. +It contains the elements of the matrix $latex X$$ in row major order; i.e., +$latex \[ + X_{i,j} = x [ i * 3 + j ] +\] $$ + +$head d$$ +The argument $icode d$$ has prototype +$codei% + const %Vector% &%d% +%$$. +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, +it must support the syntax +$codei% + %y%[%i%] +%$$ +where $icode i$$ has type $code size_t$$ with value less than 9. +This must return a $code double$$ value corresponding to the $th i$$ +element of the vector $icode y$$. +This is the only requirement of the type $icode Vector$$. +(Note that only the first element of the vector $icode d$$ is used.) + +$head ok$$ +The return value $icode ok$$ has prototype +$codei% + bool %ok% +%$$ +It is true, if the determinant $icode%d%[0]%$$ +passes the test and false otherwise. + +$children% + omh/det_33_hpp.omh +%$$ + +$head Source Code$$ +The file +$cref det_33.hpp$$ +contains the source code for this template function. + +$end +------------------------------------------------------------------------------ +*/ +// BEGIN C++ +# include +namespace CppAD { +template + bool det_33(const Vector &x, const Vector &d) + { bool ok = true; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // use expansion by minors to compute the determinant by hand + double check = 0.; + check += x[0] * ( x[4] * x[8] - x[5] * x[7] ); + check -= x[1] * ( x[3] * x[8] - x[5] * x[6] ); + check += x[2] * ( x[3] * x[7] - x[4] * x[6] ); + + ok &= CppAD::NearEqual(check, d[0], eps99, eps99); + + return ok; + } +} +// END C++ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/speed/det_by_lu.hpp cppad-2019.02.00.0/include/cppad/speed/det_by_lu.hpp --- cppad-2018.00.00.0/include/cppad/speed/det_by_lu.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/speed/det_by_lu.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,182 @@ +# ifndef CPPAD_SPEED_DET_BY_LU_HPP +# define CPPAD_SPEED_DET_BY_LU_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin det_by_lu$$ +$spell + CppAD + cppad + lu + hpp + typedef + const + hpp + Det + CPPAD_TESTVECTOR + namespace +$$ + +$section Determinant Using Expansion by Lu Factorization$$ + + +$head Syntax$$ +$codei%# include +%$$ +$codei%det_by_lu<%Scalar%> %det%(%n%) +%$$ +$icode%d% = %det%(%a%) +%$$ + +$head Inclusion$$ +The template class $code det_by_lu$$ is defined in the $code CppAD$$ +namespace by including +the file $code cppad/speed/det_by_lu.hpp$$ +(relative to the CppAD distribution directory). + +$head Constructor$$ +The syntax +$codei% + det_by_lu<%Scalar%> %det%(%n%) +%$$ +constructs the object $icode det$$ which can be used for +evaluating the determinant of $icode n$$ by $icode n$$ matrices +using LU factorization. + +$head Scalar$$ +The type $icode Scalar$$ can be any +$cref NumericType$$ + +$head n$$ +The argument $icode n$$ has prototype +$codei% + size_t %n% +%$$ + +$head det$$ +The syntax +$codei% + %d% = %det%(%a%) +%$$ +returns the determinant of the matrix $latex A$$ using LU factorization. + +$subhead a$$ +The argument $icode a$$ has prototype +$codei% + const %Vector% &%a% +%$$ +It must be a $icode Vector$$ with length $latex n * n$$ and with +It must be a $icode Vector$$ with length $latex n * n$$ and with +elements of type $icode Scalar$$. +The elements of the $latex n \times n$$ matrix $latex A$$ are defined, +for $latex i = 0 , \ldots , n-1$$ and $latex j = 0 , \ldots , n-1$$, by +$latex \[ + A_{i,j} = a[ i * m + j] +\] $$ + +$subhead d$$ +The return value $icode d$$ has prototype +$codei% + %Scalar% %d% +%$$ + +$head Vector$$ +If $icode y$$ is a $icode Vector$$ object, +it must support the syntax +$codei% + %y%[%i%] +%$$ +where $icode i$$ has type $code size_t$$ with value less than $latex n * n$$. +This must return a $icode Scalar$$ value corresponding to the $th i$$ +element of the vector $icode y$$. +This is the only requirement of the type $icode Vector$$. + +$children% + speed/example/det_by_lu.cpp% + omh/det_by_lu_hpp.omh +%$$ + + +$head Example$$ +The file +$cref det_by_lu.cpp$$ +contains an example and test of $code det_by_lu.hpp$$. + +$head Source Code$$ +The file +$cref det_by_lu.hpp$$ +contains the source for this template function. + + +$end +--------------------------------------------------------------------------- +*/ +// BEGIN C++ +# include +# include + +// BEGIN CppAD namespace +namespace CppAD { + +template +class det_by_lu { +private: + const size_t m_; + const size_t n_; + CppAD::vector A_; + CppAD::vector B_; + CppAD::vector X_; +public: + det_by_lu(size_t n) : m_(0), n_(n), A_(n * n) + { } + + template + Scalar operator()(const Vector &x) + { + + Scalar logdet; + Scalar det; + int signdet; + size_t i; + + // 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 + // point operation sequence very simple. + if( signdet == 0 ) + det = 0; + else + det = Scalar( signdet ) * exp( logdet ); +*/ + + // convert to determinant + det = Scalar( signdet ) * exp( logdet ); + +# ifdef FADBAD + // Fadbad requires tempories to be set to constants + for(i = 0; i < n_ * n_; i++) + A_[i] = 0; +# endif + + return det; + } +}; +} // END CppAD namespace +// END C++ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/speed/det_by_minor.hpp cppad-2019.02.00.0/include/cppad/speed/det_by_minor.hpp --- cppad-2018.00.00.0/include/cppad/speed/det_by_minor.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/speed/det_by_minor.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,165 @@ +# ifndef CPPAD_SPEED_DET_BY_MINOR_HPP +# define CPPAD_SPEED_DET_BY_MINOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin det_by_minor$$ +$spell + CppAD + cppad + typedef + const + hpp + Det + namespace +$$ + +$section Determinant Using Expansion by Minors$$ + + + +$head Syntax$$ +$codei%# include +%$$ +$codei%det_by_minor<%Scalar%> %det%(%n%) +%$$ +$icode%d% = %det%(%a%) +%$$ + +$head Inclusion$$ +The template class $code det_by_minor$$ is defined in the $code CppAD$$ +namespace by including +the file $code cppad/speed/det_by_minor.hpp$$ +(relative to the CppAD distribution directory). + +$head Constructor$$ +The syntax +$codei% + det_by_minor<%Scalar%> %det%(%n%) +%$$ +constructs the object $icode det$$ which can be used for +evaluating the determinant of $icode n$$ by $icode n$$ matrices +using expansion by minors. + +$head Scalar$$ +The type $icode Scalar$$ must satisfy the same conditions +as in the function $cref/det_of_minor/det_of_minor/Scalar/$$. + +$head n$$ +The argument $icode n$$ has prototype +$codei% + size_t %n% +%$$ + +$head det$$ +The syntax +$codei% + %d% = %det%(%a%) +%$$ +returns the determinant of the matrix $icode A$$ using expansion by minors. + +$subhead a$$ +The argument $icode a$$ has prototype +$codei% + const %Vector% &%a% +%$$ +It must be a $icode Vector$$ with length $latex n * n$$ and with +elements of type $icode Scalar$$. +The elements of the $latex n \times n$$ matrix $latex A$$ are defined, +for $latex i = 0 , \ldots , n-1$$ and $latex j = 0 , \ldots , n-1$$, by +$latex \[ + A_{i,j} = a[ i * m + j] +\] $$ + +$subhead d$$ +The return value $icode d$$ has prototype +$codei% + %Scalar% %d% +%$$ +It is equal to the determinant of $latex A$$. + +$head Vector$$ +If $icode y$$ is a $icode Vector$$ object, +it must support the syntax +$codei% + %y%[%i%] +%$$ +where $icode i$$ has type $code size_t$$ with value less than $latex n * n$$. +This must return a $icode Scalar$$ value corresponding to the $th i$$ +element of the vector $icode y$$. +This is the only requirement of the type $icode Vector$$. + +$children% + speed/example/det_by_minor.cpp% + omh/det_by_minor_hpp.omh +%$$ + + +$head Example$$ +The file +$cref det_by_minor.cpp$$ +contains an example and test of $code det_by_minor.hpp$$. + +$head Source Code$$ +The file +$cref det_by_minor.hpp$$ +contains the source for this template function. + + +$end +--------------------------------------------------------------------------- +*/ +// BEGIN C++ +# include +# include + +// BEGIN CppAD namespace +namespace CppAD { + +template +class det_by_minor { +private: + size_t m_; + + // made mutable because modified and then restored + mutable std::vector r_; + mutable std::vector c_; + + // make mutable because its value does not matter + mutable std::vector a_; +public: + det_by_minor(size_t m) : m_(m) , r_(m + 1) , c_(m + 1), a_(m * m) + { + size_t i; + + // values for r and c that correspond to entire matrix + for(i = 0; i < m; i++) + { r_[i] = i+1; + c_[i] = i+1; + } + r_[m] = 0; + c_[m] = 0; + } + + template + Scalar operator()(const Vector &x) const + { size_t i = m_ * m_; + while(i--) + a_[i] = x[i]; + return det_of_minor(a_, m_, m_, r_, c_); + } + +}; + +} // END CppAD namespace +// END C++ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/speed/det_grad_33.hpp cppad-2019.02.00.0/include/cppad/speed/det_grad_33.hpp --- cppad-2018.00.00.0/include/cppad/speed/det_grad_33.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/speed/det_grad_33.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,127 @@ +# ifndef CPPAD_SPEED_DET_GRAD_33_HPP +# define CPPAD_SPEED_DET_GRAD_33_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin det_grad_33$$ +$spell + cppad + CppAD + det + namespace + const + bool + hpp +$$ + +$section Check Gradient of Determinant of 3 by 3 matrix$$ + + +$head Syntax$$ +$codei%# include +%$$ +$icode%ok% = det_grad_33(%x%, %g%)%$$ + +$head Purpose$$ +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$$ +(relative to the CppAD distribution directory). + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %Vector% &%x% +%$$. +It contains the elements of the matrix $latex X$$ in row major order; i.e., +$latex \[ + X_{i,j} = x [ i * 3 + j ] +\] $$ + +$head g$$ +The argument $icode g$$ has prototype +$codei% + const %Vector% &%g% +%$$. +It contains the elements of the gradient of +$latex \det ( X )$$ in row major order; i.e., +$latex \[ + \D{\det (X)}{X(i,j)} = g [ i * 3 + j ] +\] $$ + +$head Vector$$ +If $icode y$$ is a $icode Vector$$ object, +it must support the syntax +$codei% + %y%[%i%] +%$$ +where $icode i$$ has type $code size_t$$ with value less than 9. +This must return a $code double$$ value corresponding to the $th i$$ +element of the vector $icode y$$. +This is the only requirement of the type $icode Vector$$. + +$head ok$$ +The return value $icode ok$$ has prototype +$codei% + bool %ok% +%$$ +It is true, if the gradient $icode g$$ +passes the test and false otherwise. + +$children% + omh/det_grad_33_hpp.omh +%$$ + +$head Source Code$$ +The file +$cref det_grad_33.hpp$$ +contains the source code for this template function. + +$end +------------------------------------------------------------------------------ +*/ +// BEGIN C++ +# 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] ); + check[1] = - ( x[3] * x[8] - x[5] * x[6] ); + check[2] = + ( x[3] * x[7] - x[4] * x[6] ); + // + check[3] = - ( x[1] * x[8] - x[2] * x[7] ); + check[4] = + ( x[0] * x[8] - x[2] * x[6] ); + check[5] = - ( x[0] * x[7] - x[1] * x[6] ); + // + 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] ); + // + for(size_t i = 0; i < 3 * 3; i++) + ok &= CppAD::NearEqual(check[i], g[i], eps, eps); + + return ok; + } +} +// END C++ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/speed/det_of_minor.hpp cppad-2019.02.00.0/include/cppad/speed/det_of_minor.hpp --- cppad-2018.00.00.0/include/cppad/speed/det_of_minor.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/speed/det_of_minor.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,274 @@ +# ifndef CPPAD_SPEED_DET_OF_MINOR_HPP +# define CPPAD_SPEED_DET_OF_MINOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin det_of_minor$$ +$spell + CppAD + hpp + std + Det + const + namespace + cppad +$$ + + +$section Determinant of a Minor$$ + +$head Syntax$$ +$codei%# include +%$$ +$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$$ +(relative to the CppAD distribution directory). + +$head Purpose$$ +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$$ +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 +$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 + +$$ +This template function +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 +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. + +$head Determinant of A$$ +If the following conditions hold, the minor is the +entire matrix $latex A$$ and hence $code det_of_minor$$ +will return the determinant of $latex A$$: + +$list number$$ +$latex n = m$$. +$lnext +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$$, +and $latex c[m] = 0$$. +$lend + +$head a$$ +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, +for $latex i = 0 , \ldots , m-1$$ and $latex j = 0 , \ldots , m-1$$, by +$latex \[ + A_{i,j} = a[ i * m + j] +\] $$ + +$head m$$ +The argument $icode m$$ has prototype +$codei% + size_t %m% +%$$ +and is the number of rows (and columns) in the square matrix $latex A$$. + +$head n$$ +The argument $icode n$$ has prototype +$codei% + size_t %n% +%$$ +and is the number of rows (and columns) in the square minor $latex M$$. + +$head r$$ +The argument $icode r$$ has prototype +$codei% + std::vector& %r% +%$$ +and is a vector with $latex m + 1$$ elements. +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 +$latex \[ +\begin{array}{rcl} + R(0) & = & r[m] + \\ + R(i+1) & = & r[ R(i) ] +\end{array} +\] $$ +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, +and restored to their original value before the return from +$code det_of_minor$$. + +$head c$$ +The argument $icode c$$ has prototype +$codei% + std::vector& %c% +%$$ +and is a vector with $latex m + 1$$ elements +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 +$latex \[ +\begin{array}{rcl} + C(0) & = & c[m] + \\ + C(j+1) & = & c[ C(j) ] +\end{array} +\] $$ +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, +and restored to their original value before the return from +$code det_of_minor$$. + +$head d$$ +The result $icode d$$ has prototype +$codei% + %Scalar% %d% +%$$ +and is equal to the determinant of the minor $latex M$$. + +$head Scalar$$ +If $icode x$$ and $icode y$$ are objects of type $icode Scalar$$ +and $icode i$$ is an object of type $code int$$, +the $icode Scalar$$ must support the following operations: +$table +$bold Syntax$$ + $cnext $bold Description$$ + $cnext $bold Result Type$$ +$rnext +$icode%Scalar% %x%$$ + $cnext default constructor for $icode Scalar$$ object. +$rnext +$icode%x% = %i%$$ + $cnext set value of $icode x$$ to current value of $icode i$$ +$rnext +$icode%x% = %y%$$ + $cnext set value of $icode x$$ to current value of $icode y$$ +$rnext +$icode%x% + %y%$$ + $cnext value of $icode x$$ plus $icode y$$ + $cnext $icode Scalar$$ +$rnext +$icode%x% - %y%$$ + $cnext value of $icode x$$ minus $icode y$$ + $cnext $icode Scalar$$ +$rnext +$icode%x% * %y%$$ + $cnext value of $icode x$$ times value of $icode y$$ + $cnext $icode Scalar$$ +$tend + +$children% + speed/example/det_of_minor.cpp% + omh/det_of_minor_hpp.omh +%$$ + +$head Example$$ +The file +$cref det_of_minor.cpp$$ +contains an example and test of $code det_of_minor.hpp$$. + +$head Source Code$$ +The file +$cref det_of_minor.hpp$$ +contains the source for this template function. + + +$end +--------------------------------------------------------------------------- +*/ +// BEGIN C++ +# include +# include + +namespace CppAD { // BEGIN CppAD namespace +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) + + // check for 1 by 1 case + if( n == 1 ) return a[ R0 * m + Cj ]; + + // initialize determinant of the minor M + Scalar detM = Scalar(0); + + // initialize sign of factor for next sub-minor + int s = 1; + + // remove row with index 0 in M from all the sub-minors of M + r[m] = r[R0]; + + // for each column of M + for(size_t j = 0; j < n; j++) + { // element with index (0,j) in the minor M + Scalar M0j = a[ R0 * m + Cj ]; + + // remove column with index j in M to form next sub-minor S of M + c[Cj1] = c[Cj]; + + // compute determinant of the current sub-minor S + Scalar detS = det_of_minor(a, m, n - 1, r, c); + + // restore column Cj to represenation of M as a minor of A + c[Cj1] = Cj; + + // include this sub-minor term in the summation + if( s > 0 ) + detM = detM + M0j * detS; + else + detM = detM - M0j * detS; + + // advance to next column of M + Cj1 = Cj; + Cj = c[Cj]; + s = - s; + } + + // restore row zero to the minor representation for M + r[m] = R0; + + // return the determinant of the minor M + return detM; +} +} // END CppAD namespace +// END C++ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/speed/mat_sum_sq.hpp cppad-2019.02.00.0/include/cppad/speed/mat_sum_sq.hpp --- cppad-2018.00.00.0/include/cppad/speed/mat_sum_sq.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/speed/mat_sum_sq.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,152 @@ +# ifndef CPPAD_SPEED_MAT_SUM_SQ_HPP +# define CPPAD_SPEED_MAT_SUM_SQ_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin mat_sum_sq$$ +$spell + sq + namespace + const + CppAD + sq + cppad + hpp +$$ + +$section Sum Elements of a Matrix Times Itself$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%mat_sum_sq(%n%, %x%, %y%, %z%)%$$ + +$head Purpose$$ +This routine is intended for use with the matrix multiply speed tests; +to be specific, it computes +$latex \[ +\begin{array}{rcl} + y_{i,j} & = & \sum_{k=0}^{n-1} x_{i,k} x_{k,j} + \\ + z_0 & = & \sum_{i=0}^{n-1} \sum_{j=0}^{n-1} y_{i,j} +\end{array} +\] $$ +see $cref link_mat_mul$$. + +$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$$ +(relative to the CppAD distribution directory). + +$head n$$ +This argument has prototype +$codei% + size_t %n% +%$$ +It specifies the size of the matrices. + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %Vector% &%x% +%$$ +and $icode%x%.size() == %n% * %n%$$. +It contains the elements of $latex x$$ in row major order; i.e., +$latex \[ + x_{i,j} = x [ i * n + j ] +\] $$ + +$head y$$ +The argument $icode y$$ has prototype +$codei% + %Vector%& %y% +%$$ +and $icode%y%.size() == %n% * %n%$$. +The input value of its elements does not matter. +Upon return, +$latex \[ +\begin{array}{rcl} + y_{i,j} & = & \sum_{k=0}^{n-1} x_{i,k} x_{k,j} + \\ + y[ i * n + j ] & = & y_{i,j} +\end{array} +\] $$ + + +$head z$$ +The argument $icode d$$ has prototype +$codei% + %Vector%& %z% +%$$. +The input value of its element does not matter. +Upon return +$latex \[ +\begin{array}{rcl} + z_0 & = & \sum_{i=0}^{n-1} \sum_{j=0}^n y_{i,j} + \\ + z[0] & = & z_0 +\end{array} +\] $$ + +$head Vector$$ +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 +and to a double value. + +$children% + speed/example/mat_sum_sq.cpp% + omh/mat_sum_sq_hpp.omh +%$$ + + +$head Example$$ +The file +$cref mat_sum_sq.cpp$$ +contains an example and test of $code mat_sum_sq.hpp$$. + +$head Source Code$$ +The file +$cref mat_sum_sq.hpp$$ +contains the source for this template function. + +$end +------------------------------------------------------------------------------ +*/ +// BEGIN C++ +# include +// +namespace CppAD { + template + void mat_sum_sq(size_t n, Vector& x , Vector& y , Vector& z) + { size_t i, j, k; + // Very simple computation of y = x * x for speed comparison + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { y[i * n + j] = 0.; + for(k = 0; k < n; k++) + y[i * n + j] += x[i * n + k] * x[k * n + j]; + } + } + z[0] = 0.; + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + z[0] += y[i * n + j]; + } + return; + } + +} +// END C++ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/speed/ode_evaluate.hpp cppad-2019.02.00.0/include/cppad/speed/ode_evaluate.hpp --- cppad-2018.00.00.0/include/cppad/speed/ode_evaluate.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/speed/ode_evaluate.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,236 @@ +# ifndef CPPAD_SPEED_ODE_EVALUATE_HPP +# define CPPAD_SPEED_ODE_EVALUATE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin ode_evaluate$$ +$spell + Runge + fabs + retaped + Jacobian + const + Cpp + cppad + hpp + fp + namespace + exp +$$ + +$section Evaluate a Function Defined in Terms of an ODE$$ + + +$head Syntax$$ +$codei%# include +%$$ +$codei%ode_evaluate(%x%, %p%, %fp%)%$$ + +$head Purpose$$ +This routine evaluates a function $latex f : \B{R}^n \rightarrow \B{R}^n$$ +defined by +$latex \[ + f(x) = y(x, 1) +\] $$ +where $latex y(x, t)$$ solves the ordinary differential equation +$latex \[ +\begin{array}{rcl} + y(x, 0) & = & x + \\ + \partial_t y (x, t ) & = & g[ y(x,t) , t ] +\end{array} +\] $$ +where $latex g : \B{R}^n \times \B{R} \rightarrow \B{R}^n$$ +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$$ +(relative to the CppAD distribution directory). + +$head Float$$ + +$subhead Operation Sequence$$ +The type $icode Float$$ must be a $cref NumericType$$. +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$$. + +$subhead fabs$$ +If $icode y$$ and $icode z$$ are $icode Float$$ objects, the syntax +$codei% + %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 +corresponding results are not actually used by $code ode_evaluate$$; +see $code fabs$$ in $cref/Runge45/Runge45/Scalar/fabs/$$. + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const CppAD::vector<%Float%>& %x% +%$$ +It contains he argument value for which the function, +or its derivative, is being evaluated. +The value $latex n$$ is determined by the size of the vector $icode x$$. + +$head p$$ +The argument $icode p$$ has prototype +$codei% + size_t %p% +%$$ + +$subhead p == 0$$ +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$$. + +$subhead p = 1$$ +In this case an analytic solution for the partial derivative +$latex \partial_x y(x, 1)$$ is returned. + +$head fp$$ +The argument $icode fp$$ has prototype +$codei% + CppAD::vector<%Float%>& %fp% +%$$ +The input value of the elements of $icode fp$$ does not matter. + +$subhead Function$$ +If $icode p$$ is zero, $icode fp$$ has size equal to $latex n$$ +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$$ +and for $latex i = 0 , \ldots 1$$, $latex j = 0 , \ldots , n-1$$ +$latex \[ + \D{y[i]}{x[j]} (x, 1) = fp [ i \cdot n + j ] +\] $$ + +$children% + speed/example/ode_evaluate.cpp% + omh/ode_evaluate.omh +%$$ + +$head Example$$ +The file +$cref ode_evaluate.cpp$$ +contains an example and test of $code ode_evaluate.hpp$$. + + +$head Source Code$$ +The file +$cref ode_evaluate.hpp$$ +contains the source code for this template function. + +$end +*/ +// BEGIN C++ +# include +# include +# include + +namespace CppAD { + + template + class ode_evaluate_fun { + public: + // 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_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, + CppAD::vector& f) + { size_t n = y.size(); + f[0] = 0.; + for(size_t k = 1; k < n; k++) + f[k] = y[k-1]; + } + }; + // + template + void ode_evaluate( + const CppAD::vector& x , + size_t p , + CppAD::vector& fp ) + { using CppAD::vector; + typedef vector FloatVector; + + size_t n = x.size(); + CPPAD_ASSERT_KNOWN( p == 0 || p == 1, + "ode_evaluate: p is not zero or one" + ); + CPPAD_ASSERT_KNOWN( + ((p==0) & (fp.size()==n)) || ((p==1) & (fp.size()==n*n)), + "ode_evaluate: the size of fp is not correct" + ); + if( p == 0 ) + { // function that defines the ode + ode_evaluate_fun F; + + // number of Runge45 steps to use + size_t M = 10; + + // initial and final time + Float ti = 0.0; + Float tf = 1.0; + + // initial value for y(x, t); i.e. y(x, 0) + // (is a reference to x) + const FloatVector& yi = x; + + // final value for y(x, t); i.e., y(x, 1) + // (is a reference to fp) + FloatVector& yf = fp; + + // Use fourth order Runge-Kutta to solve ODE + yf = CppAD::Runge45(F, M, ti, tf, yi); + + return; + } + /* 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_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! + ... + */ + size_t i, j, k; + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + fp[ i * n + j ] = 0.0; + } + size_t factorial = 1; + for(k = 0; k < n; k++) + { if( k > 1 ) + 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; + fp[ i * n + j ] += 1.0 / Float(factorial); + } + } + } +} +// END C++ + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/speed/sparse_hes_fun.hpp cppad-2019.02.00.0/include/cppad/speed/sparse_hes_fun.hpp --- cppad-2018.00.00.0/include/cppad/speed/sparse_hes_fun.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/speed/sparse_hes_fun.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,262 @@ +# ifndef CPPAD_SPEED_SPARSE_HES_FUN_HPP +# define CPPAD_SPEED_SPARSE_HES_FUN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin sparse_hes_fun$$ +$spell + hes + cppad + hpp + fp + CppAD + namespace + const + bool + exp + arg +$$ + +$section Evaluate a Function That Has a Sparse Hessian$$ + + +$head Syntax$$ +$codei%# include +%$$ +$codei%sparse_hes_fun(%n%, %x%, %row%, %col%, %p%, %fp%)%$$ + +$head Purpose$$ +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 +one of the following forms: +$latex \[ + \DD{f}{x[row[k]]}{x[row[k]]} + \; , \; + \DD{f}{x[row[k]]}{x[col[k]]} + \; , \; + \DD{f}{x[col[k]]}{x[row[k]]} + \; , \; + \DD{f}{x[col[k]]}{x[col[k]]} +\] $$ +for some $latex k $$ between zero and $latex K-1 $$. +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$$ +(relative to the CppAD distribution directory). + +$head Float$$ +The type $icode Float$$ must be a $cref NumericType$$. +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, +with elements of type $icode Float$$. + +$head n$$ +The argument $icode n$$ has prototype +$codei% + size_t %n% +%$$ +It specifies the dimension for the domain space for $latex f(x)$$. + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %FloatVector%& %x% +%$$ +It contains the argument value for which the function, +or its derivative, is being evaluated. +We use $latex n$$ to denote the size of the vector $icode x$$. + +$head row$$ +The argument $icode row$$ has prototype +$codei% + const CppAD::vector& %row% +%$$ +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%$$. +The value $latex K$$ is defined by $icode%K% = %row%.size()%$$. + +$head col$$ +The argument $icode col$$ has prototype +$codei% + const CppAD::vector& %col% +%$$ +and its size must be $latex K$$; i.e., the same as for $icode col$$. +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 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. + +$head fp$$ +The argument $icode fp$$ has prototype +$codei% + %FloatVector%& %fp% +%$$ +The input value of the elements of $icode fp$$ does not matter. + +$subhead Function$$ +If $icode p$$ is zero, $icode fp$$ has size one and +$icode%fp%[0]%$$ is the value of $latex f(x)$$. + +$subhead Hessian$$ +If $icode p$$ is two, $icode fp$$ has size $icode K$$ and +for $latex k = 0 , \ldots , K-1$$, +$latex \[ + \DD{f}{ x[ \R{row}[k] ] }{ x[ \R{col}[k] ]} = fp [k] +\] $$ + +$children% + speed/example/sparse_hes_fun.cpp% + omh/sparse_hes_fun.omh +%$$ + +$head Example$$ +The file +$cref sparse_hes_fun.cpp$$ +contains an example and test of $code sparse_hes_fun.hpp$$. + +$head Source Code$$ +The file +$cref sparse_hes_fun.hpp$$ +contains the source code for this template function. + +$end +------------------------------------------------------------------------------ +*/ +// BEGIN C++ +# include +# include +# include + +// following needed by gcc under fedora 17 so that exp(double) is defined +# include + +namespace CppAD { + template + void sparse_hes_fun( + size_t n , + const FloatVector& x , + const CppAD::vector& row , + const CppAD::vector& col , + size_t p , + FloatVector& fp ) + { + // check numeric type specifications + CheckNumericType(); + + // check value of p + CPPAD_ASSERT_KNOWN( + p == 0 || p == 2, + "sparse_hes_fun: p != 0 and p != 2" + ); + + size_t K = row.size(); + size_t i, j, k; + 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); + } + } + + Float t; + for(k = 0; k < K; k++) + { i = row[k]; + j = col[k]; + t = exp( x[i] * x[j] ); + switch(p) + { + case 0: + fp[0] += t; + break; + + case 2: + 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++ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/speed/sparse_jac_fun.hpp cppad-2019.02.00.0/include/cppad/speed/sparse_jac_fun.hpp --- cppad-2018.00.00.0/include/cppad/speed/sparse_jac_fun.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/speed/sparse_jac_fun.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,219 @@ +# ifndef CPPAD_SPEED_SPARSE_JAC_FUN_HPP +# define CPPAD_SPEED_SPARSE_JAC_FUN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin sparse_jac_fun$$ +$spell + Jacobian + jac + cppad + hpp + fp + CppAD + namespace + const + bool + exp + arg +$$ + +$section Evaluate a Function That Has a Sparse Jacobian$$ + + +$head Syntax$$ +$codei%# include +%$$ +$codei%sparse_jac_fun(%m%, %n%, %x%, %row%, %col%, %p%, %fp%)%$$ + +$head Purpose$$ +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 +one of the following forms: +$latex \[ + \D{ f[row[k]]}{x[col[k]]} +\] $$ +for some $latex k $$ between zero and $latex K-1$$. +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$$ +(relative to the CppAD distribution directory). + +$head Float$$ +The type $icode Float$$ must be a $cref NumericType$$. +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, +with elements of type $icode Float$$. + +$head n$$ +The argument $icode n$$ has prototype +$codei% + size_t %n% +%$$ +It specifies the dimension for the domain space for $latex f(x)$$. + +$head m$$ +The argument $icode m$$ has prototype +$codei% + size_t %m% +%$$ +It specifies the dimension for the range space for $latex f(x)$$. + +$head x$$ +The argument $icode x$$ has prototype +$codei% + const %FloatVector%& %x% +%$$ +It contains the argument value for which the function, +or its derivative, is being evaluated. +We use $latex n$$ to denote the size of the vector $icode x$$. + +$head row$$ +The argument $icode row$$ has prototype +$codei% + const CppAD::vector& %row% +%$$ +It specifies indices in the range of $latex f(x)$$ for non-zero components +of the Jacobian +(see $cref/purpose/sparse_hes_fun/Purpose/$$ above). +The value $latex K$$ is defined by $icode%K% = %row%.size()%$$. +All the elements of $icode row$$ must be between zero and $icode%m%-1%$$. + +$head col$$ +The argument $icode col$$ has prototype +$codei% + const CppAD::vector& %col% +%$$ +and its size must be $latex K$$; i.e., the same as $icode row$$. +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%$$. + +$head p$$ +The argument $icode p$$ has prototype +$codei% + size_t %p% +%$$ +It is either zero or one and +specifies the order of the derivative of $latex f$$ +that is being evaluated, i.e., $latex f^{(p)} (x)$$ is evaluated. + +$head fp$$ +The argument $icode fp$$ has prototype +$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$$ +If $icode p$$ is zero, $icode fp$$ has size $latex m$$ and +$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 K$$ and +for $latex k = 0 , \ldots , K-1$$, +$latex \[ + \D{f[ \R{row}[i] ]}{x[ \R{col}[j] ]} = fp [k] +\] $$ + +$children% + speed/example/sparse_jac_fun.cpp% + omh/sparse_jac_fun.omh +%$$ + +$head Example$$ +The file +$cref sparse_jac_fun.cpp$$ +contains an example and test of $code sparse_jac_fun.hpp$$. + +$head Source Code$$ +The file +$cref sparse_jac_fun.hpp$$ +contains the source code for this template function. + +$end +------------------------------------------------------------------------------ +*/ +// BEGIN C++ +# include +# include +# include + +// following needed by gcc under fedora 17 so that exp(double) is defined +# include + +namespace CppAD { + template + void sparse_jac_fun( + size_t m , + size_t n , + const FloatVector& x , + const CppAD::vector& row , + const CppAD::vector& col , + size_t p , + FloatVector& fp ) + { + // check numeric type specifications + CheckNumericType(); + // check value of p + CPPAD_ASSERT_KNOWN( + 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; + + 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 ); + switch(p) + { + case 0: + fp[i] += t; + break; + + case 1: + fp[k] = t * x[j]; + break; + } + } + } +} +// END C++ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/speed/uniform_01.hpp cppad-2019.02.00.0/include/cppad/speed/uniform_01.hpp --- cppad-2018.00.00.0/include/cppad/speed/uniform_01.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/speed/uniform_01.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,103 @@ +# ifndef CPPAD_SPEED_UNIFORM_01_HPP +# define CPPAD_SPEED_UNIFORM_01_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin uniform_01$$ +$spell + CppAD + namespace + cppad + hpp +$$ + +$section Simulate a [0,1] Uniform Random Variate$$ + + +$head Syntax$$ +$codei%# include +%$$ +$codei%uniform_01(%seed%) +%$$ +$codei%uniform_01(%n%, %x%)%$$ + +$head Purpose$$ +This routine is used to create random values for speed testing purposes. + +$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$$ +(relative to the CppAD distribution directory). + +$head seed$$ +The argument $icode seed$$ has prototype +$codei% + size_t %seed% +%$$ +It specifies a seed +for the uniform random number generator. + +$head n$$ +The argument $icode n$$ has prototype +$codei% + size_t %n% +%$$ +It specifies the number of elements in the random vector $icode x$$. + +$head x$$ +The argument $icode x$$ has prototype +$codei% + %Vector% &%x% +%$$. +The input value of the elements of $icode x$$ does not matter. +Upon return, the elements of $icode x$$ are set to values +randomly sampled over the interval [0,1]. + +$head Vector$$ +If $icode y$$ is a $code double$$ value, +the object $icode x$$ must support the syntax +$codei% + %x%[%i%] = %y% +%$$ +where $icode i$$ has type $code size_t$$ with value less than +or equal $latex n-1$$. +This is the only requirement of the type $icode Vector$$. + +$children% + omh/uniform_01_hpp.omh +%$$ + +$head Source Code$$ +The file +$cref uniform_01.hpp$$ +constraints the source code for this template function. + +$end +------------------------------------------------------------------------------ +*/ +// BEGIN C++ +# include + +namespace CppAD { + inline void uniform_01(size_t seed) + { std::srand( (unsigned int) seed); } + + template + void uniform_01(size_t n, Vector &x) + { static double factor = 1. / double(RAND_MAX); + while(n--) + x[n] = std::rand() * factor; + } +} +// END C++ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/utility/check_numeric_type.hpp cppad-2019.02.00.0/include/cppad/utility/check_numeric_type.hpp --- cppad-2018.00.00.0/include/cppad/utility/check_numeric_type.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/check_numeric_type.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,173 @@ +# ifndef CPPAD_UTILITY_CHECK_NUMERIC_TYPE_HPP +# define CPPAD_UTILITY_CHECK_NUMERIC_TYPE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin CheckNumericType$$ +$spell + alloc + cppad.hpp + CppAD +$$ + +$section Check NumericType Class Concept$$ + + +$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/utility/check_numeric_type.cpp +%$$ +The file $cref check_numeric_type.cpp$$ +contains an example and test of this function. +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; + + /* + compound 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-2018.00.00.0/include/cppad/utility/check_simple_vector.hpp cppad-2019.02.00.0/include/cppad/utility/check_simple_vector.hpp --- cppad-2018.00.00.0/include/cppad/utility/check_simple_vector.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/check_simple_vector.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,198 @@ +# ifndef CPPAD_UTILITY_CHECK_SIMPLE_VECTOR_HPP +# define CPPAD_UTILITY_CHECK_SIMPLE_VECTOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin CheckSimpleVector$$ +$spell + alloc + const + cppad.hpp + CppAD +$$ + +$section Check Simple Vector Concept$$ + + +$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/utility/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$$. +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-2018.00.00.0/include/cppad/utility/elapsed_seconds.hpp cppad-2019.02.00.0/include/cppad/utility/elapsed_seconds.hpp --- cppad-2018.00.00.0/include/cppad/utility/elapsed_seconds.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/elapsed_seconds.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,192 @@ +# ifndef CPPAD_UTILITY_ELAPSED_SECONDS_HPP +# define CPPAD_UTILITY_ELAPSED_SECONDS_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin elapsed_seconds$$ +$spell + cppad.hpp + Microsoft + gettimeofday + std + chrono +$$ + +$section Returns Elapsed Number of Seconds$$ + + +$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::steady_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$$. + +$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 +# define NOMINMAX // so windows.h does not define min and max as macros +# include +# 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 ::%GetSystemTime for timing. +\li +Otherwise, if gettimeofday is available, it is used. +\li +Otherwise, std::clock() is used. + +\return +The number of seconds since the first call to 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::steady_clock::now(); + first_ = false; + return 0.0; + } + std::chrono::time_point now; + now = std::chrono::steady_clock::now(); + std::chrono::duration difference = now - start_; + return difference.count(); +} +// -------------------------------------------------------------------------- +# elif _MSC_VER +{ CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; + static bool first_ = true; + static SYSTEMTIME st_; + SYSTEMTIME st; + + if( first_ ) + { ::GetSystemTime(&st_); + first_ = false; + return 0.; + } + ::GetSystemTime(&st); + + double hour = double(st.wHour) - double(st_.wHour); + double minute = double(st.wMinute) - double(st_.wMinute); + double second = double(st.wSecond) - double(st_.wSecond); + double milli = double(st.wMilliseconds) - double(st_.wMilliseconds); + + double diff = 1e-3*milli + second + 60.*minute + 3600.*hour; + if( diff < 0. ) + diff += 3600.*24.; + CPPAD_ASSERT_UNKNOWN( 0 <= diff && diff < 3600.*24. ); + + return diff; +} +// -------------------------------------------------------------------------- +# 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-2018.00.00.0/include/cppad/utility/error_handler.hpp cppad-2019.02.00.0/include/cppad/utility/error_handler.hpp --- cppad-2018.00.00.0/include/cppad/utility/error_handler.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/error_handler.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,235 @@ +# ifndef CPPAD_UTILITY_ERROR_HANDLER_HPP +# define CPPAD_UTILITY_ERROR_HANDLER_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin ErrorHandler$$ +$spell + cppad.hpp + CppAD + exp + bool + const +$$ + +$section Replacing the CppAD Error Handler$$ + +$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/utility/error_handler.cpp% + include/cppad/core/cppad_assert.hpp +%$$ +$head Example$$ +The file +$cref error_handler.cpp$$ +contains an example and test a test of using this routine. + +$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( local::set_get_in_parallel(0) ) + { bool known = true; + int line = __LINE__; + const char* file = __FILE__; + const char* exp = "! local::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( local::set_get_in_parallel(0) ) + { bool known = true; + int line = __LINE__; + const char* file = __FILE__; + const char* exp = "! local::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( local::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-2018.00.00.0/include/cppad/utility/index_sort.hpp cppad-2019.02.00.0/include/cppad/utility/index_sort.hpp --- cppad-2018.00.00.0/include/cppad/utility/index_sort.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/index_sort.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,177 @@ +# ifndef CPPAD_UTILITY_INDEX_SORT_HPP +# define CPPAD_UTILITY_INDEX_SORT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin index_sort$$ +$spell + cppad.hpp + ind + const +$$ + +$section Returns Indices that Sort a Vector$$ + + +$head Syntax$$ +$codei%# include +%$$ +$codei%index_sort(%keys%, %ind%)%$$ + +$head keys$$ +The argument $icode keys$$ has prototype +$codei% + const %KeyVector%& %keys% +%$$ +where $icode KeyVector$$ is +a $cref SimpleVector$$ class with elements that support the $code <$$ +operation. + +$head ind$$ +The argument $icode ind$$ has prototype +$codei% + %SizeVector%& %ind% +%$$ +where $icode SizeVector$$ 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/utility/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 KeyVector +Simple vector type that deterimene the sorting order by < operator +on its elements. + +\tparam SizeVector +Simple vector type with elements of 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 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 KeyVector& keys, SizeVector& ind) +{ typedef typename KeyVector::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-2018.00.00.0/include/cppad/utility/lu_factor.hpp cppad-2019.02.00.0/include/cppad/utility/lu_factor.hpp --- cppad-2018.00.00.0/include/cppad/utility/lu_factor.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/lu_factor.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,391 @@ +# ifndef CPPAD_UTILITY_LU_FACTOR_HPP +# define CPPAD_UTILITY_LU_FACTOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin LuFactor$$ +$spell + cppad.hpp + Cpp + Geq + Lu + bool + const + ip + jp + namespace + std + typename +$$ + + +$section LU Factorization of A Square Matrix$$ + +$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/utility/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. +$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 +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/core/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-2018.00.00.0/include/cppad/utility/lu_invert.hpp cppad-2019.02.00.0/include/cppad/utility/lu_invert.hpp --- cppad-2018.00.00.0/include/cppad/utility/lu_invert.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/lu_invert.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,237 @@ +# ifndef CPPAD_UTILITY_LU_INVERT_HPP +# define CPPAD_UTILITY_LU_INVERT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin LuInvert$$ +$spell + cppad.hpp + Lu + Cpp + jp + ip + const + namespace + typename + etmp +$$ + + +$section Invert an LU Factored Equation$$ + +$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/utility/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. + +$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-2018.00.00.0/include/cppad/utility/lu_solve.hpp cppad-2019.02.00.0/include/cppad/utility/lu_solve.hpp --- cppad-2018.00.00.0/include/cppad/utility/lu_solve.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/lu_solve.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,344 @@ +# ifndef CPPAD_UTILITY_LU_SOLVE_HPP +# define CPPAD_UTILITY_LU_SOLVE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin LuSolve$$ +$spell + cppad.hpp + det + exp + Leq + typename + bool + const + namespace + std + Geq + Lu + CppAD + signdet + logdet +$$ + + +$section Compute Determinant and Solve Linear Equations$$ + +$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/utility/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. + +$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 +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-2018.00.00.0/include/cppad/utility/memory_leak.hpp cppad-2019.02.00.0/include/cppad/utility/memory_leak.hpp --- cppad-2018.00.00.0/include/cppad/utility/memory_leak.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/memory_leak.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,213 @@ +# ifndef CPPAD_UTILITY_MEMORY_LEAK_HPP +# define CPPAD_UTILITY_MEMORY_LEAK_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin memory_leak$$ +$spell + cppad + num + alloc + hpp + bool + inuse +$$ + +$section Memory Leak Detection$$ + +$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 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 add_static is added to the amount +of memory that is expected to be used by thread zero for static variables. + +\return +If add_static is non-zero, the return value is false. +Otherwise, if one of the following errors is detected, +the return value is 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(0)= " << 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-2018.00.00.0/include/cppad/utility/nan.hpp cppad-2019.02.00.0/include/cppad/utility/nan.hpp --- cppad-2018.00.00.0/include/cppad/utility/nan.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/nan.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,192 @@ +# ifndef CPPAD_UTILITY_NAN_HPP +# define CPPAD_UTILITY_NAN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$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/utility/nan.cpp +%$$ +$head Example$$ +The file $cref nan.cpp$$ +contains an example and test of this routine. + +$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 +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 +Scalar nan(const Scalar &zero) +{ return zero / zero; +} + +} // End CppAD namespace + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/utility/near_equal.hpp cppad-2019.02.00.0/include/cppad/utility/near_equal.hpp --- cppad-2018.00.00.0/include/cppad/utility/near_equal.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/near_equal.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,270 @@ +# ifndef CPPAD_UTILITY_NEAR_EQUAL_HPP +# define CPPAD_UTILITY_NEAR_EQUAL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin NearEqual$$ +$spell + cppad.hpp + sqrt + cout + endl + Microsoft + std + Cpp + namespace + const + bool +$$ + +$section Determine if Two Values Are Nearly Equal$$ + + +$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/utility/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(); +# ifndef NDEBUG + Type zero(0); +# endif + + 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-2018.00.00.0/include/cppad/utility/ode_err_control.hpp cppad-2019.02.00.0/include/cppad/utility/ode_err_control.hpp --- cppad-2018.00.00.0/include/cppad/utility/ode_err_control.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/ode_err_control.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,598 @@ +# ifndef CPPAD_UTILITY_ODE_ERR_CONTROL_HPP +# define CPPAD_UTILITY_ODE_ERR_CONTROL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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$$ + +$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/utility/ode_err_control.cpp% + example/utility/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.0); + Scalar one(1.0); + Scalar two(2.0); + Scalar three(3.0); + Scalar m1(double(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-2018.00.00.0/include/cppad/utility/ode_gear_control.hpp cppad-2019.02.00.0/include/cppad/utility/ode_gear_control.hpp --- cppad-2018.00.00.0/include/cppad/utility/ode_gear_control.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/ode_gear_control.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,544 @@ +# ifndef CPPAD_UTILITY_ODE_GEAR_CONTROL_HPP +# define CPPAD_UTILITY_ODE_GEAR_CONTROL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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$$ + +$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/utility/ode_gear_control.cpp +%$$ +The file +$cref ode_gear_control.cpp$$ +contains an example and test a test of using this routine. + +$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-2018.00.00.0/include/cppad/utility/ode_gear.hpp cppad-2019.02.00.0/include/cppad/utility/ode_gear.hpp --- cppad-2018.00.00.0/include/cppad/utility/ode_gear.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/ode_gear.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,520 @@ +# ifndef CPPAD_UTILITY_ODE_GEAR_HPP +# define CPPAD_UTILITY_ODE_GEAR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin OdeGear$$ +$spell + cppad.hpp + Jan + bool + const + CppAD + dep +$$ + + +$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/utility/ode_gear.cpp +%$$ +The file +$cref ode_gear.cpp$$ +contains an example and test a test of using this routine. + +$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 + CppAD::vector ip(n) , jp(n); +# ifndef NDEBUG + int sign = +# endif + 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-2018.00.00.0/include/cppad/utility/omp_alloc.hpp cppad-2019.02.00.0/include/cppad/utility/omp_alloc.hpp --- cppad-2018.00.00.0/include/cppad/utility/omp_alloc.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/omp_alloc.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,747 @@ +# ifndef CPPAD_UTILITY_OMP_ALLOC_HPP +# define CPPAD_UTILITY_OMP_ALLOC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# 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$$ +$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). + +$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$$ + +$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. + +$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 + +$end +*/ + /*! + Use omp_alloc to get a specified amount of memory. + + If the memory allocated by a previous call to get_memory is now + avaialable, and min_bytes is between its previous value + and the previous 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$$ + +$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. + +$end +*/ + /*! + Return memory that was obtained by get_memory. + If max_num_threads(0) == 1, + the memory is returned to the system. + Otherwise, it is retained by omp_alloc and available for use by + get_memory for this thread. + + \param v_ptr [in] + Value of the pointer returned by 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 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$$ + +$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/$$). + +$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$$ + +$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. + +$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. + +$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$$ + +$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. + +$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 extra_ field, in the 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$$ + +$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$$. + +$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 create_array that has not yet been deleted. + The 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 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$$ + +$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-2018.00.00.0/include/cppad/utility/poly.hpp cppad-2019.02.00.0/include/cppad/utility/poly.hpp --- cppad-2018.00.00.0/include/cppad/utility/poly.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/poly.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,191 @@ +# ifndef CPPAD_UTILITY_POLY_HPP +# define CPPAD_UTILITY_POLY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin Poly$$ +$spell + cppad.hpp + CppAD + namespace + cstddef + ifndef + endif + deg + const + std + da +$$ + + +$section Evaluate a Polynomial or its Derivative$$ + +$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 compound assignment $rnext +$icode%x% += %y%$$ $cnext addition compound 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/general/poly.cpp% + omh/poly_hpp.omh +%$$ + +$head Example$$ +The file +$cref poly.cpp$$ +contains an example and test of this routine. + +$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 = double( 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-2018.00.00.0/include/cppad/utility/pow_int.hpp cppad-2019.02.00.0/include/cppad/utility/pow_int.hpp --- cppad-2018.00.00.0/include/cppad/utility/pow_int.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/pow_int.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,139 @@ +# ifndef CPPAD_UTILITY_POW_INT_HPP +# define CPPAD_UTILITY_POW_INT_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +------------------------------------------------------------------------------- +$begin pow_int$$ +$spell + cppad.hpp + CppAD + namespace + const +$$ + + +$section The Integer Power Function$$ + +$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/general/pow_int.cpp +%$$ +The file $cref pow_int.cpp$$ +is an example and test of this function. + + +$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-2018.00.00.0/include/cppad/utility/romberg_mul.hpp cppad-2019.02.00.0/include/cppad/utility/romberg_mul.hpp --- cppad-2018.00.00.0/include/cppad/utility/romberg_mul.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/romberg_mul.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,324 @@ +# ifndef CPPAD_UTILITY_ROMBERG_MUL_HPP +# define CPPAD_UTILITY_ROMBERG_MUL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin RombergMul$$ +$spell + cppad.hpp + bool + const + Cpp + RombergMulMul +$$ + +$section Multi-dimensional Romberg Integration$$ + + +$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/utility/romberg_mul.cpp +%$$ +$head Example$$ +$comment% + example/utility/romberg_mul.cpp +%$$ +The file +$cref Rombergmul.cpp$$ +contains an example and test a test of using this routine. + +$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 / Float( double(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-2018.00.00.0/include/cppad/utility/romberg_one.hpp cppad-2019.02.00.0/include/cppad/utility/romberg_one.hpp --- cppad-2018.00.00.0/include/cppad/utility/romberg_one.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/romberg_one.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,212 @@ +# ifndef CPPAD_UTILITY_ROMBERG_ONE_HPP +# define CPPAD_UTILITY_ROMBERG_ONE_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin RombergOne$$ +$spell + cppad.hpp + bool + const + Cpp + RombergOne +$$ + +$section One DimensionalRomberg Integration$$ + + +$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/utility/romberg_one.cpp +%$$ +$head Example$$ +$comment% + example/utility/romberg_one.cpp +%$$ +The file +$cref romberg_one.cpp$$ +contains an example and test a test of using this routine. + +$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(double(k))) * a + double(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-2018.00.00.0/include/cppad/utility/rosen_34.hpp cppad-2019.02.00.0/include/cppad/utility/rosen_34.hpp --- cppad-2018.00.00.0/include/cppad/utility/rosen_34.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/rosen_34.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,496 @@ +# ifndef CPPAD_UTILITY_ROSEN_34_HPP +# define CPPAD_UTILITY_ROSEN_34_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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$$ + +$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/general/rosen_34.cpp +%$$ +The file +$cref rosen_34.cpp$$ +contains an example and test a test of using this routine. + +$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-2018.00.00.0/include/cppad/utility/runge_45.hpp cppad-2019.02.00.0/include/cppad/utility/runge_45.hpp --- cppad-2018.00.00.0/include/cppad/utility/runge_45.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/runge_45.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,426 @@ +# ifndef CPPAD_UTILITY_RUNGE_45_HPP +# define CPPAD_UTILITY_RUNGE_45_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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$$ + +$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/utility/runge45_1.cpp% + example/general/runge45_2.cpp +%$$ +The file +$cref runge45_1.cpp$$ +contains a simple example and test of $code Runge45$$. +$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-2018.00.00.0/include/cppad/utility/set_union.hpp cppad-2019.02.00.0/include/cppad/utility/set_union.hpp --- cppad-2018.00.00.0/include/cppad/utility/set_union.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/set_union.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,91 @@ +# ifndef CPPAD_UTILITY_SET_UNION_HPP +# define CPPAD_UTILITY_SET_UNION_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin set_union$$ +$spell + set + const + std + cppad + hpp +$$ + +$section Union of Standard Sets$$ + +$head Syntax$$ +$codei%# include +%$$ +$icode%result% = set_union(%left%, %right%)%$$ + +$head Purpose$$ +This is a simplified (and restricted) interface to +the $code std::union$$ operation. + +$head Element$$ +This is the type of the elements of the sets. + +$head left$$ +This argument has prototype +$codei% + const std::set<%Element%>& %left% +%$$ + +$head right$$ +This argument has prototype +$codei% + const std::set<%Element%>& %right% +%$$ + +$head result$$ +The return value has prototype +$codei% + std::set<%Element%>& %result% +%$$ +It contains the union of $icode left$$ and $icode right$$. +Note that C++11 detects that the return value is a temporary +and uses it for the result instead of making a separate copy. + +$children% + example/utility/set_union.cpp +%$$ +$head Example$$ +The file $cref set_union.cpp$$ contains an example and test of this + + +$end +*/ + +# include +# include +# include + +namespace CppAD { + template + std::set set_union( + const std::set& left , + const std::set& right ) + { std::set result; + std::set_union( + left.begin() , + left.end() , + right.begin() , + right.end() , + std::inserter(result, result.begin()) + ); + return result; + } +} + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/utility/sparse2eigen.hpp cppad-2019.02.00.0/include/cppad/utility/sparse2eigen.hpp --- cppad-2018.00.00.0/include/cppad/utility/sparse2eigen.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/sparse2eigen.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,133 @@ +# ifndef CPPAD_UTILITY_SPARSE2EIGEN_HPP +# define CPPAD_UTILITY_SPARSE2EIGEN_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin sparse2eigen$$ +$spell + CppAD + Eigen + cppad.hpp + const + Ptr + nnz +$$ + +$section Convert A CppAD Sparse Matrix to an Eigen Sparse Matrix$$ + +$head Syntax$$ +$codei%# include +%$$ +$codei%sparse2eigen(%source%, %destination%)%$$ + +$head Prototype$$ +$srcfile%include/cppad/utility/sparse2eigen.hpp%0 + %// BEGIN_PROTOTYPE%// END_PROTOTYPE% +1%$$ + +$head Eigen$$ +This routine is only available when +$cref eigen_prefix$$ is specified. + +$head SizeVector$$ +We use $cref/SizeVector/sparse_rc/SizeVector/$$ to denote a +$cref SimpleVector$$ class with elements of $code size_t$$. + +$head ValueVector$$ +We use $icode ValueVector$$ to denote a +$cref SimpleVector$$ class with elements of type $icode value_type$$. + +$head Options$$ +We use $icode Options$$ to denote either +$code Eigen::RowMajor$$ of $code Eigen::ColMajor$$. + +$head value_type$$ +The type of elements of elements in $icode source$$ and $icode destination$$ +must be the same. We use $icode value_type$$ to denote this type. + +$head source$$ +This is the CppAD sparse matrix that is being converted to eigen format. + +$head destination$$ +This is the Eigen sparse matrix that is the result of the conversion. + +$head Compressed$$ +The result matrix $icode destination$$ +is in compressed format. For example, let +$codei% + size_t %% %nnz% = %source%.nnz(); + const %s_vector%& %s_value% = %source%.val(); + const %value_type%* %d_value% = %destination%.valuePtr(); + const %s_vector%& %row_major% = %source%.row_major(); + const %s_vector%& %col_major% = %source%.col_major(); +%$$ +It follows that, for $icode%k% = 0 , %...%, %nnz%$$: +If $icode Options$$ is $code Eigen::RowMajor$$, +$codei% + %d_value%[%k%] == %s_value%[ %row_major%[%k%] ] +%$$ +If $icode Options$$ is $code Eigen::ColMajor$$, +$codei% + %d_value%[%k%] == %s_value%[ %col_major%[%k%] ] +%$$ + +$children%example/sparse/sparse2eigen.cpp +%$$ + +$head Example$$ +The file $cref sparse2eigen.cpp$$ contains an example and test +of $code sparse2eigen.cpp$$ It return true if the test passes +and false otherwise. + +$end +*/ +# include +# if CPPAD_HAS_EIGEN + +# include +# include +# include + +namespace CppAD { // BEGIN CPPAD_NAMESPACE + +// BEGIN_PROTOTYPE +template +void sparse2eigen( +const CppAD::sparse_rcv& source , +Eigen::SparseMatrix& destination ) +// END_PROTOTYPE +{ using Eigen::Index; + typedef typename ValueVector::value_type value_type; + typedef Eigen::Triplet triplet; + std::vector vec( source.nnz() ); + // + const SizeVector& row = source.row(); + const SizeVector& col = source.col(); + const ValueVector& val = source.val(); + // + for(size_t k = 0; k < source.nnz(); k++) + vec[k] = triplet( int(row[k]), int(col[k]), val[k] ); + // + size_t nr = source.nr(); + size_t nc = source.nc(); + destination.resize( Index(nr), Index(nc) ); + destination.setFromTriplets(vec.begin(), vec.end()); + // + CPPAD_ASSERT_UNKNOWN( destination.isCompressed() ); + // + return; +} + +} // END_CPPAD_NAMESPACE +# endif // CPPAD_HAS_EIGEN +# endif diff -Nru cppad-2018.00.00.0/include/cppad/utility/sparse_rc.hpp cppad-2019.02.00.0/include/cppad/utility/sparse_rc.hpp --- cppad-2018.00.00.0/include/cppad/utility/sparse_rc.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/sparse_rc.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,348 @@ +# ifndef CPPAD_UTILITY_SPARSE_RC_HPP +# define CPPAD_UTILITY_SPARSE_RC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin sparse_rc$$ +$spell + CppAD + const + nnz + cppad + hpp + rc + nr + nc + resize +$$ +$section Row and Column Index Sparsity Patterns$$ + +$head Syntax$$ +$codei%# include +%$$ +$codei%sparse_rc<%SizeVector%> %empty% +%$$ +$codei%sparse_rc<%SizeVector%> %pattern%(%nr%, %nc%, %nnz%) +%$$ +$icode%target% = %pattern% +%$$ +$icode%resize%(%nr%, %nc%, %nnz%) +%$$ +$icode%pattern%.set(%k%, %r%, %c%) +%$$ +$icode%pattern%.nr() +%$$ +$icode%pattern%.nc() +%$$ +$icode%pattern%.nnz() +%$$ +$codei%const %SizeVector%& %row%( %pattern%.row() ) +%$$ +$codei%const %SizeVector%& %col%( %pattern%.col() ) +%$$ +$icode%row_major% = %pattern%.row_major() +%$$ +$icode%col_major% = %pattern%.col_major() +%$$ + +$head SizeVector$$ +We use $icode SizeVector$$ to denote $cref SimpleVector$$ class +$cref/with elements of type/SimpleVector/Elements of Specified Type/$$ +$code size_t$$. + +$head empty$$ +This is an empty sparsity pattern. To be specific, +the corresponding number of rows $icode nr$$, +number of columns $icode nc$$, +and number of possibly non-zero values $icode nnz$$, +are all zero. + +$head pattern$$ +This object is used to hold a sparsity pattern for a matrix. +The sparsity $icode pattern$$ is $code const$$ +except during its constructor, $code resize$$, and $code set$$. + +$head target$$ +The target of the assignment statement must have prototype +$codei% + sparse_rc<%SizeVector%> %target% +%$$ +After this assignment statement, $icode target$$ is an independent copy +of $icode pattern$$; i.e. it has all the same values as $icode pattern$$ +and changes to $icode target$$ do not affect $icode pattern$$. + +$head nr$$ +This argument has prototype +$codei% + size_t %nr% +%$$ +It specifies the number of rows in the sparsity pattern. +The function call $code nr()$$ returns the value of $icode nr$$. + +$head nc$$ +This argument has prototype +$codei% + size_t %nc% +%$$ +It specifies the number of columns in the sparsity pattern. +The function call $code nc()$$ returns the value of $icode nc$$. + +$head nnz$$ +This argument has prototype +$codei% + size_t %nnz% +%$$ +It specifies the number of possibly non-zero +index pairs in the sparsity pattern. +The function call $code nnz()$$ returns the value of $icode nnz$$. + +$head resize$$ +The current sparsity pattern is lost and a new one is started +with the specified parameters. The elements in the $icode row$$ +and $icode col$$ vectors should be assigned using $code set$$. + +$head set$$ +This function sets the values +$codei% + %row%[%k%] = %r% + %col%[%k%] = %c% +%$$ + +$subhead k$$ +This argument has type +$codei% + size_t %k% +%$$ +and must be less than $icode nnz$$. + +$subhead r$$ +This argument has type +$codei% + size_t %r% +%$$ +It specifies the value assigned to $icode%row%[%k%]%$$ and must +be less than $icode nr$$. + +$subhead c$$ +This argument has type +$codei% + size_t %c% +%$$ +It specifies the value assigned to $icode%col%[%k%]%$$ and must +be less than $icode nc$$. + +$head row$$ +This vector has size $icode nnz$$ and +$icode%row%[%k%]%$$ +is the row index of the $th k$$ possibly non-zero +index pair in the sparsity pattern. + +$head col$$ +This vector has size $icode nnz$$ and +$icode%col%[%k%]%$$ is the column index of the $th k$$ possibly non-zero +index pair in the sparsity pattern. + +$head row_major$$ +This vector has prototype +$codei% + %SizeVector% %row_major% +%$$ +and its size $icode nnz$$. +It sorts the sparsity pattern in row-major order. +To be specific, +$codei% + %col%[ %row_major%[%k%] ] <= %col%[ %row_major%[%k%+1] ] +%$$ +and if $icode%col%[ %row_major%[%k%] ] == %col%[ %row_major%[%k%+1] ]%$$, +$codei% + %row%[ %row_major%[%k%] ] < %row%[ %row_major%[%k%+1] ] +%$$ +This routine generates an assert if there are two entries with the same +row and column values (if $code NDEBUG$$ is not defined). + +$head col_major$$ +This vector has prototype +$codei% + %SizeVector% %col_major% +%$$ +and its size $icode nnz$$. +It sorts the sparsity pattern in column-major order. +To be specific, +$codei% + %row%[ %col_major%[%k%] ] <= %row%[ %col_major%[%k%+1] ] +%$$ +and if $icode%row%[ %col_major%[%k%] ] == %row%[ %col_major%[%k%+1] ]%$$, +$codei% + %col%[ %col_major%[%k%] ] < %col%[ %col_major%[%k%+1] ] +%$$ +This routine generates an assert if there are two entries with the same +row and column values (if $code NDEBUG$$ is not defined). + +$children% + example/utility/sparse_rc.cpp +%$$ +$head Example$$ +The file $cref sparse_rc.cpp$$ +contains an example and test of this class. + +$end +*/ +/*! +\file sparse_rc.hpp +A Matrix sparsity pattern class. +*/ +# include // for size_t +# include // for CPPAD_ASSERT +# include // for row and column major ordering + +namespace CppAD { // BEGIN CPPAD_NAMESPACE + +/// sparsity pattern for a matrix with indices of type size_t +template +class sparse_rc { +private: + /// number of rows in the sparsity pattern + size_t nr_; + /// number of columns in the sparsity pattern + size_t nc_; + /// number of possibly non-zero index pairs + size_t nnz_; + /// row_[k] is the row index for the k-th possibly non-zero entry + SizeVector row_; + /// col_[k] is the column index for the k-th possibly non-zero entry + SizeVector col_; +public: + /// default constructor + /// Eigen vector is ambiguous for row_(0), col_(0) so use default ctor + sparse_rc(void) + : nr_(0), nc_(0), nnz_(0) + { } + /// sizing constructor + /// Eigen vector is ambiguous for row_(0), col_(0) so use default ctor + sparse_rc(size_t nr, size_t nc, size_t nnz) + : nr_(nr), nc_(nc), nnz_(nnz) + { row_.resize(nnz); + col_.resize(nnz); + } + /// copy constructor + sparse_rc(const sparse_rc& other) + : + nr_(other.nr_) , + nc_(other.nc_) , + nnz_(other.nnz_) , + row_(other.row_) , + col_(other.col_) + { } + /// assignment + void operator=(const sparse_rc& pattern) + { nr_ = pattern.nr_; + nc_ = pattern.nc_; + nnz_ = pattern.nnz_; + // simple vector assignment requires vectors to have same size + row_.resize(nnz_); + col_.resize(nnz_); + row_ = pattern.row_; + col_ = pattern.col_; + } + /// resize + void resize(size_t nr, size_t nc, size_t nnz) + { nr_ = nr; + nc_ = nc; + nnz_ = nnz; + row_.resize(nnz); + col_.resize(nnz); + } + /// set row and column for a possibly non-zero element + void set(size_t k, size_t r, size_t c) + { CPPAD_ASSERT_KNOWN( + k < nnz_, + "The index k is not less than nnz in sparse_rc::set" + ); + CPPAD_ASSERT_KNOWN( + r < nr_, + "The index r is not less than nr in sparse_rc::set" + ); + CPPAD_ASSERT_KNOWN( + c < nc_, + "The index c is to not less than nc in sparse_rc::set" + ); + row_[k] = r; + col_[k] = c; + // + } + /// number of rows in matrix + size_t nr(void) const + { return nr_; } + /// number of columns in matrix + size_t nc(void) const + { return nc_; } + /// number of possibly non-zero elements in matrix + size_t nnz(void) const + { return nnz_; } + /// row indices + const SizeVector& row(void) const + { return row_; } + /// column indices + const SizeVector& col(void) const + { return col_; } + /// row-major order + SizeVector row_major(void) const + { SizeVector keys(nnz_), row_major(nnz_); + for(size_t k = 0; k < nnz_; k++) + { CPPAD_ASSERT_UNKNOWN( row_[k] < nr_ ); + keys[k] = row_[k] * nc_ + col_[k]; + } + index_sort(keys, row_major); +# ifndef NDEBUG + for(size_t ell = 0; ell + 1 < nnz_; ell++) + { size_t k = row_major[ ell ]; + size_t kp = row_major[ ell + 1 ]; + CPPAD_ASSERT_KNOWN( + row_[k] != row_[kp] || col_[k] != col_[kp], + "sparse_rc: row_major: duplicate entry in this pattern" + ); + CPPAD_ASSERT_UNKNOWN( + row_[k] +%$$ +$codei%sparse_rcv<%SizeVector%, %ValueVector%> %empty% +%$$ +$codei%sparse_rcv<%SizeVector%, %ValueVector%> %matrix%(%pattern%) +%$$ +$icode%target% = %matrix% +%$$ +$icode%matrix%.set(%k%, %v%) +%$$ +$icode%nr% = %matrix%.nr() +%$$ +$icode%nc% = %matrix%.nc() +%$$ +$icode%nnz% = %matrix%.nnz() +%$$ +$codei%const %SizeVector%& %row%( %matrix%.row() ) +%$$ +$codei%const %SizeVector%& %col%( %matrix%.col() ) +%$$ +$codei%const %ValueVector%& %val%( %matrix%.val() ) +%$$ +$codei%const sparse_rc<%SizeVector%>& %pat%( %matrix%.pat() ) +%$$ +$icode%row_major% = %matrix%.row_major() +%$$ +$icode%col_major% = %matrix%.col_major() +%$$ + +$head SizeVector$$ +We use $cref/SizeVector/sparse_rc/SizeVector/$$ to denote the +$cref SimpleVector$$ class corresponding to $icode pattern$$. + +$head ValueVector$$ +We use $icode ValueVector$$ to denote the +$cref SimpleVector$$ class corresponding to $icode val$$. + +$head empty$$ +This is an empty sparse matrix object. To be specific, +the corresponding number of rows $icode nr$$, +number of columns $icode nc$$, +and number of possibly non-zero values $icode nnz$$, +are all zero. + + +$head pattern$$ +This constructor argument has prototype +$codei% + const sparse_rc<%SizeVector%>& %pattern% +%$$ +It specifies the number of rows, number of columns and +the possibly non-zero entries in the $icode matrix$$. + +$head matrix$$ +This is a sparse matrix object with the sparsity specified by $icode pattern$$. +Only the $icode val$$ vector can be changed. All other values returned by +$icode matrix$$ are fixed during the constructor and constant there after. +The $icode val$$ vector is only changed by the constructor +and the $code set$$ function. +There is one exception to the rule, where $icode matrix$$ corresponds +to $icode target$$ for an assignment statement. + +$head target$$ +The target of the assignment statement must have prototype +$codei% + sparse_rcv<%SizeVector%, %ValueVector%> %target% +%$$ +After this assignment statement, $icode target$$ is an independent copy +of $icode matrix$$; i.e. it has all the same values as $icode matrix$$ +and changes to $icode target$$ do not affect $icode matrix$$. + +$head nr$$ +This return value has prototype +$codei% + size_t %nr% +%$$ +and is the number of rows in $icode matrix$$. + +$head nc$$ +This argument and return value has prototype +$codei% + size_t %nc% +%$$ +and is the number of columns in $icode matrix$$. + +$head nnz$$ +We use the notation $icode nnz$$ to denote the number of +possibly non-zero entries in $icode matrix$$. + +$head set$$ +This function sets the value +$codei% + %val%[%k%] = %v% +%$$ + +$subhead k$$ +This argument has type +$codei% + size_t %k% +%$$ +and must be less than $icode nnz$$. + +$subhead v$$ +This argument has type +$codei% + const %ValueVector%::value_type& %v% +%$$ +It specifies the value assigned to $icode%val%[%k%]%$$. + + +$head row$$ +This vector has size $icode nnz$$ and +$icode%row%[%k%]%$$ +is the row index of the $th k$$ possibly non-zero +element in $icode matrix$$. + +$head col$$ +This vector has size $icode nnz$$ and +$icode%col[%k%]%$$ is the column index of the $th k$$ possibly non-zero +element in $icode matrix$$ + +$head val$$ +This vector has size $icode nnz$$ and +$icode%val[%k%]%$$ is value of the $th k$$ possibly non-zero entry +in the sparse matrix (the value may be zero). + +$head pat$$ +This is equal to the sparsity pattern; i.e., +$icode pattern$$ in the constructor. + +$head row_major$$ +This vector has prototype +$codei% + %SizeVector% %row_major% +%$$ +and its size $icode nnz$$. +It sorts the sparsity pattern in row-major order. +To be specific, +$codei% + %col%[ %row_major%[%k%] ] <= %col%[ %row_major%[%k%+1] ] +%$$ +and if $icode%col%[ %row_major%[%k%] ] == %col%[ %row_major%[%k%+1] ]%$$, +$codei% + %row%[ %row_major%[%k%] ] < %row%[ %row_major%[%k%+1] ] +%$$ +This routine generates an assert if there are two entries with the same +row and column values (if $code NDEBUG$$ is not defined). + +$head col_major$$ +This vector has prototype +$codei% + %SizeVector% %col_major% +%$$ +and its size $icode nnz$$. +It sorts the sparsity pattern in column-major order. +To be specific, +$codei% + %row%[ %col_major%[%k%] ] <= %row%[ %col_major%[%k%+1] ] +%$$ +and if $icode%row%[ %col_major%[%k%] ] == %row%[ %col_major%[%k%+1] ]%$$, +$codei% + %col%[ %col_major%[%k%] ] < %col%[ %col_major%[%k%+1] ] +%$$ +This routine generates an assert if there are two entries with the same +row and column values (if $code NDEBUG$$ is not defined). + +$head Eigen Matrix$$ +If you have the $cref/eigen package/eigen_prefix/$$ in your include path, +you can use $cref sparse2eigen$$ to convert a sparse matrix to eigen format. + +$children% + example/utility/sparse_rcv.cpp +%$$ +$head Example$$ +The file $cref sparse_rcv.cpp$$ +contains an example and test of this class. + +$end +*/ +/*! +\file sparse_rcv.hpp +A sparse matrix class. +*/ +# include + +namespace CppAD { // BEGIN CPPAD_NAMESPACE + +/// Sparse matrices with elements of type Scalar +template +class sparse_rcv { +private: + /// sparsity pattern + sparse_rc pattern_; + /// value_type + typedef typename ValueVector::value_type value_type; + /// val_[k] is the value for the k-th possibly non-zero entry in the matrix + ValueVector val_; +public: + // ------------------------------------------------------------------------ + /// default constructor + sparse_rcv(void) + : pattern_(0, 0, 0), val_(0) + { } + /// constructor + sparse_rcv(const sparse_rc& pattern ) + : + pattern_(pattern) , + val_(pattern_.nnz()) + { } + /// assignment + void operator=(const sparse_rcv& matrix) + { pattern_ = matrix.pattern_; + // simple vector assignment requires vectors to have same size + val_.resize( matrix.nnz() ); + val_ = matrix.val(); + } + // ------------------------------------------------------------------------ + void set(size_t k, const value_type& v) + { CPPAD_ASSERT_KNOWN( + pattern_.nnz(), + "The index k is not less than nnz in sparse_rcv::set" + ); + val_[k] = v; + } + /// number of rows in matrix + size_t nr(void) const + { return pattern_.nr(); } + /// number of columns in matrix + size_t nc(void) const + { return pattern_.nc(); } + /// number of possibly non-zero elements in matrix + size_t nnz(void) const + { return pattern_.nnz(); } + /// row indices + const SizeVector& row(void) const + { return pattern_.row(); } + /// column indices + const SizeVector& col(void) const + { return pattern_.col(); } + /// value for possibly non-zero elements + const ValueVector& val(void) const + { return val_; } + /// sparsity pattern + const sparse_rc& pat(void) const + { return pattern_; } + /// row-major order + SizeVector row_major(void) const + { return pattern_.row_major(); } + /// column-major indices + SizeVector col_major(void) const + { return pattern_.col_major(); } +}; + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/utility/speed_test.hpp cppad-2019.02.00.0/include/cppad/utility/speed_test.hpp --- cppad-2018.00.00.0/include/cppad/utility/speed_test.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/speed_test.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,472 @@ +# ifndef CPPAD_UTILITY_SPEED_TEST_HPP +# define CPPAD_UTILITY_SPEED_TEST_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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$$ + +$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 +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(); + } + double rate = .5 + double(repeat) / (s1 - s0); + // first convert to float to avoid warning with g++ -Wconversion + rate_vec[i] = static_cast( static_cast(rate) ); + } + 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$$ + +$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 = size_t( int(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(); + } + double r = .5 + double(repeat) / (s1 - s0); + // first convert to float to avoid warning with g++ -Wconversion + rate = static_cast( static_cast( r ) ); + + 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 = size_t( int(size) + inc ); + else + size = 0; + } + return; +} + +} // END CppAD namespace + +// END C++ +# endif diff -Nru cppad-2018.00.00.0/include/cppad/utility/test_boolofvoid.hpp cppad-2019.02.00.0/include/cppad/utility/test_boolofvoid.hpp --- cppad-2018.00.00.0/include/cppad/utility/test_boolofvoid.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/test_boolofvoid.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,172 @@ +# ifndef CPPAD_UTILITY_TEST_BOOLOFVOID_HPP +# define CPPAD_UTILITY_TEST_BOOLOFVOID_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin test_boolofvoid$$ +$spell + boolofvoid + const + std + bool + ipopt + cpp + cppad + hpp +$$ + +$section Object that Runs a Group of Tests$$ + +$head Syntax$$ +$codei%# include +%$$ +$codei%test_boolofvoid %Run%(%group%, %width%) +%$$ +$icode%Run%(%test%, %name%) +%$$ +$icode%ok% = %Run%.summary(%memory_ok%)%$$ + +$head Purpose$$ +The object $icode Run$$ is used to run a group of tests functions +and report the results on standard output. + +$head group$$ +The argument has prototype +$codei% + const std::string& %group% +%$$ +It is the name for this group of tests. + +$head width$$ +The argument has prototype +$codei% + size_t %width% +%$$ +It is the number of columns used to display the name of each test. +It must be greater than the maximum number of characters in a test name. + +$head test$$ +The argument has prototype +$codei% + bool %test%(void) +%$$ +It is a function that returns true (when the test passes) and false +otherwise. + +$head name$$ +The argument has prototype +$codei% + const std::string& %name% +%$$ +It is the name for the corresponding $icode test$$. + +$head memory_ok$$ +The argument has prototype +$codei% + bool %memory_ok% +%$$ +It is false if a memory leak is detected (and true otherwise). + +$head ok$$ +This is true if all of the tests pass (including the memory leak test), +otherwise it is false. + +$head Example$$ +See any of the main programs in the example directory; e.g., +$code example/ipopt_solve.cpp$$. + +$end +*/ + +# include +# include + +namespace CppAD { // BEGIN_CPPAD_NAMESPACE + +/// One class object is used to run a group of tests +class test_boolofvoid { +private: + /// name for the group of test this object will run + const std::string group_; + /// number of characters used to display the name for each indiviual test + /// (must be larger than the number of characters in name for each test) + const size_t width_; + /// number of tests that have passed + size_t n_ok_; + /// number of tests that have failed + size_t n_error_; + +public: + /// ctor + test_boolofvoid(const std::string& group, size_t width) : + group_(group) , + width_(width) , + n_ok_(0) , + n_error_(0) + { std::cout << "Begin test group " << group_ << std::endl; } + /// destructor + ~test_boolofvoid(void) + { std::cout << "End test group " << group_ << std::endl; } + /// run one test + bool operator()(bool test(void), const std::string& name) + { CPPAD_ASSERT_KNOWN( + name.size() < width_ , + "test_boolofvoid: name does not have less characters than width" + ); + std::cout.width( int(width_) ); + std::cout.setf( std::ios_base::left ); + std::cout << name; + // + bool ok = test(); + if( ok ) + { std::cout << "OK" << std::endl; + n_ok_++; + } + else + { std::cout << "Error" << std::endl; + n_error_++; + } + return ok; + } + /// nuber of tests that passed + size_t n_ok(void) const + { return n_ok_; } + /// nuber of tests that failed + size_t n_error(void) const + { return n_error_; } + /// summary + bool summary(bool memory_ok ) + { + std::cout.width( int(width_) ); + std::cout.setf( std::ios_base::left ); + std::cout << "memory_leak"; + // + if( memory_ok ) + { std::cout << "OK" << std::endl; + n_ok_++; + } + else + { std::cout << "Error" << std::endl; + n_error_++; + } + if( n_error_ == 0 ) + std::cout << "All " << n_ok_ << " tests passed." << std::endl; + else + std::cout << n_error_ << " tests failed." << std::endl; + // + return n_error_ == 0; + } +}; + +} // END_CPPAD_NAMESPACE + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/utility/thread_alloc.hpp cppad-2019.02.00.0/include/cppad/utility/thread_alloc.hpp --- cppad-2018.00.00.0/include/cppad/utility/thread_alloc.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/thread_alloc.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1515 @@ +# ifndef CPPAD_UTILITY_THREAD_ALLOC_HPP +# define CPPAD_UTILITY_THREAD_ALLOC_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# 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 get_memory and 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 get_memory and 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 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 or CPPAD_DEBUG_AND_RELEASE is defined, this memory is not + used, but it still helps to separate this structure from the structure + 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 set is true, this is the new value returned by this routine. + Otherwise, 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 clear is true, then the information pointer for this thread + is deleted and the 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 clear is false, and the current pointer is CPPAD_NULL, + a new infromation record is allocated and its pointer returned. + In this case, if 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 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 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 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 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 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 number_new is non-zero, the return value is equal to + 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 thread_num_new. + If set is true, + or the most recent setting is 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 set_get_thread_num. + + \param thread_num_new [in] + If set is false, thread_num_new it is not used. + Otherwise, the current value of thread_num_new becomes the + most recent setting for thread_num. + + \param set + If set is true, then thread_num_new is becomes the most + recent setting for this 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$$ + + + + +$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::local::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::local::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$$ +$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::local::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$$ + + +$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 get_memory is now + avaialable, and min_bytes is between its previous value + and the previous 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; + } + +# ifndef CPPAD_DEBUG_AND_RELEASE + // 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 +# 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 +# ifndef CPPAD_DEBUG_AND_RELEASE + // add node to inuse list + node->next_ = inuse_root->next_; + inuse_root->next_ = v_node; +# endif + + // 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 +# ifndef CPPAD_DEBUG_AND_RELEASE + // add node to inuse list + node->next_ = inuse_root->next_; + inuse_root->next_ = v_node; +# endif + + // 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$$ + + +$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 get_memory. + If num_threads() == 1, + the memory is returned to the system. + Otherwise, it is retained by thread_alloc and available for use by + get_memory for this thread. + + \param v_ptr [in] + Value of the pointer returned by 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 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 +# ifndef CPPAD_DEBUG_AND_RELEASE + // 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 ); + } + // remove v_ptr from inuse list + previous->next_ = node->next_; +# endif + // trace option + if( capacity==CPPAD_TRACE_CAPACITY && thread==CPPAD_TRACE_THREAD ) + { std::cout << "return_memory: v_ptr = " << v_ptr << std::endl; } + +# 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 +$$ + + +$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$$ + +$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$$ + + +$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$$ + + +$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 extra_ field, in the 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$$ + + +$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 create_array that has not yet been deleted. + The 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 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 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-2018.00.00.0/include/cppad/utility/time_test.hpp cppad-2019.02.00.0/include/cppad/utility/time_test.hpp --- cppad-2018.00.00.0/include/cppad/utility/time_test.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/time_test.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,232 @@ +# ifndef CPPAD_UTILITY_TIME_TEST_HPP +# define CPPAD_UTILITY_TIME_TEST_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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$$ + +$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% + include/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 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 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 + is the size for this test and + 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 test should take to preform +the repetitions of the operation being timed. + +\param test_size +will be used for the value of size in the call to 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-2018.00.00.0/include/cppad/utility/to_string.hpp cppad-2019.02.00.0/include/cppad/utility/to_string.hpp --- cppad-2018.00.00.0/include/cppad/utility/to_string.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/to_string.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,174 @@ +# ifndef CPPAD_UTILITY_TO_STRING_HPP +# define CPPAD_UTILITY_TO_STRING_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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/$$. +$lnext +For integer types, conversion to a string is exact. +For floating point types, conversion to a string yields a value +that has relative error within machine epsilon. +$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/utility/to_string.cpp +%$$ +$head Example$$ +The file $cref to_string.cpp$$ +contains an example and test of this routine. + +$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;\ + int n_digits = 1 + std::numeric_limits::digits10;\ + 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-2018.00.00.0/include/cppad/utility/track_new_del.hpp cppad-2019.02.00.0/include/cppad/utility/track_new_del.hpp --- cppad-2018.00.00.0/include/cppad/utility/track_new_del.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/track_new_del.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,533 @@ +# ifndef CPPAD_UTILITY_TRACK_NEW_DEL_HPP +# define CPPAD_UTILITY_TRACK_NEW_DEL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin TrackNewDel$$ +$spell + cppad.hpp + Cpp + newptr + Vec + oldptr + newlen + ncopy + const +$$ + +$section Routines That Track Use of New and Delete$$ + +$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. + +$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 +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 +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-2018.00.00.0/include/cppad/utility/vector.hpp cppad-2019.02.00.0/include/cppad/utility/vector.hpp --- cppad-2018.00.00.0/include/cppad/utility/vector.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility/vector.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,936 @@ +# ifndef CPPAD_UTILITY_VECTOR_HPP +# define CPPAD_UTILITY_VECTOR_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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$$ + +$head Syntax$$ +$codei%# 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 $icode 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 + +$$ +This operation is defined for any $icode i$$ +that has a conversion to $code size_t$$. +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. +This 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/utility/cppad_vector.cpp% + example/utility/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 + vector(void) + : capacity_(0), length_(0), data_(CPPAD_NULL) + { } + /// sizing constructor + vector( + /// number of elements in this vector + size_t n + ) : capacity_(0), length_(0), data_(CPPAD_NULL) + { resize(n); } + + /// copy constructor + vector( + /// the *this vector will be a copy of 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 + size_t capacity(void) const + { return capacity_; } + + /// number of elements currently in this vector. + size_t size(void) const + { return length_; } + + /// raw pointer to the data + Type* data(void) + { return data_; } + + /// const raw pointer to the data + const Type* data(void) const + { return data_; } + + /// change the number of elements in this vector. + void resize( + /// new number of elements for this vector + size_t n + ) + { length_ = n; + + // check if we must allocate new memory + if( capacity_ < length_ ) + { + // 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 + 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 + vector& operator=( + /// right hand size of the assingment operation + const vector& x + ) + { size_t i; + // If original length 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 + 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]; + } + /// non-constant element access; i.e., we can change this element value + template + Type& operator[]( + /// element index, must be less than length + Index i + ) + { return (*this)[size_t(i)]; } + // -------------------------------------------------------------------- + /// constant element access; i.e., we cannot change this element value + const Type& operator[]( + /// element index, must be less than length and convertable to size_t + size_t i + ) const + { 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 + template + const Type& operator[]( + /// element index, must be less than length and convertable to size_t + Index i + ) const + { return (*this)[size_t(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 because 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 +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) + vectorBool(void) : n_unit_(0), length_(0), data_(CPPAD_NULL) + { } + /// sizing constructor + 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 + vectorBool( + /// the *this vector will be a copy of 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 + size_t size(void) const + { return length_; } + + /// maximum number of elements current allocation can store + size_t capacity(void) const + { return n_unit_ * bit_per_unit_; } + + /// change number of elements in this vector + 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 + 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 + vectorBool& operator=( + /// right hand size of the assingment operation + const vectorBool& v + ) + { size_t i; + // If original length 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 + 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-2018.00.00.0/include/cppad/utility.hpp cppad-2019.02.00.0/include/cppad/utility.hpp --- cppad-2018.00.00.0/include/cppad/utility.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/utility.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,49 @@ +# ifndef CPPAD_UTILITY_HPP +# define CPPAD_UTILITY_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +// BEGIN_SORT_THIS_LINE_PLUS_1 +# 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 +# include +# include +# include +# include +# include +// END_SORT_THIS_LINE_MINUS_1 + +# endif diff -Nru cppad-2018.00.00.0/include/cppad/wno_conversion.hpp cppad-2019.02.00.0/include/cppad/wno_conversion.hpp --- cppad-2018.00.00.0/include/cppad/wno_conversion.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/include/cppad/wno_conversion.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,45 @@ +# ifndef CPPAD_WNO_CONVERSION_HPP +# define CPPAD_WNO_CONVERSION_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin wno_conversion$$ +$spell + cppad + wno + cpp + hpp +$$ + +$section Suppress Suspect Implicit Conversion Warnings$$ + +$head Syntax$$ +$codei%# include %$$ + +$head Purpose$$ +In many cases it is good to have warnings for implicit conversions +that may loose range or precision. +The include command above, before any other includes, suppresses +these warning for a particular compilation unit (which usually corresponds +to a $icode%*%.cpp%$$ file). + +$end +*/ + +# include +# if CPPAD_COMPILER_HAS_CONVERSION_WARN +# pragma GCC diagnostic ignored "-Wfloat-conversion" +# pragma GCC diagnostic ignored "-Wconversion" +# endif + +# endif diff -Nru cppad-2018.00.00.0/install-sh cppad-2019.02.00.0/install-sh --- cppad-2018.00.00.0/install-sh 2015-08-09 16:12:42.000000000 +0000 +++ cppad-2019.02.00.0/install-sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2013-12-25.23; # UTC +scriptversion=2016-01-11.22; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -496,6 +496,6 @@ # 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-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff -Nru cppad-2018.00.00.0/introduction/CMakeLists.txt cppad-2019.02.00.0/introduction/CMakeLists.txt --- cppad-2018.00.00.0/introduction/CMakeLists.txt 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,34 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the introduction/exp_apx directory tests SET(source_list - introduction.cpp - exp_2.cpp - exp_2.hpp - exp_2_cppad.cpp - exp_2_for1.cpp - exp_2_for2.cpp - exp_2_rev1.cpp - exp_2_rev2.cpp - exp_2_for0.cpp - exp_eps.cpp - exp_eps.hpp - exp_eps_cppad.cpp - exp_eps_for1.cpp - exp_eps_for2.cpp - exp_eps_for0.cpp - exp_eps_rev1.cpp - exp_eps_rev2.cpp + introduction.cpp + exp_2.cpp + exp_2.hpp + exp_2_cppad.cpp + exp_2_for1.cpp + exp_2_for2.cpp + exp_2_rev1.cpp + exp_2_rev2.cpp + exp_2_for0.cpp + exp_eps.cpp + exp_eps.hpp + exp_eps_cppad.cpp + exp_eps_for1.cpp + exp_eps_for2.cpp + exp_eps_for0.cpp + exp_eps_rev1.cpp + exp_eps_rev2.cpp ) set_compile_flags( introduction "${cppad_debug_which}" "${source_list}" ) # @@ -35,8 +36,8 @@ # Add this check target ADD_CUSTOM_TARGET(check_introduction - introduction - DEPENDS introduction + introduction + DEPENDS introduction ) MESSAGE(STATUS "make check_introduction: available") diff -Nru cppad-2018.00.00.0/introduction/exp_2.cpp cppad-2019.02.00.0/introduction/exp_2.cpp --- cppad-2018.00.00.0/introduction/exp_2.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_2.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,20 +1,21 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // BEGIN C++ # include // define fabs function # 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; - return ok; +{ double x = .5; + double check = 1 + x + x * x / 2.; + bool ok = std::fabs( exp_2(x) - check ) <= 1e-10; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/introduction/exp_2_cppad.cpp cppad-2019.02.00.0/introduction/exp_2_cppad.cpp --- cppad-2018.00.00.0/introduction/exp_2_cppad.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_2_cppad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,35 +1,36 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_2_cppad$$ $spell - Taylor - coef - resize - cppad.hpp - cmath - fabs - bool - exp_2_cppad - dx - dy - dw - endl - hpp - http - org - std - www - CppAD - apx + Taylor + coef + resize + cppad.hpp + cmath + fabs + bool + exp_2_cppad + dx + dy + dw + endl + hpp + http + org + std + www + CppAD + apx $$ $section exp_2: CppAD Forward and Reverse Sweeps$$. @@ -40,7 +41,7 @@ at the point $latex x = .5$$, of the function $codei% - exp_2(%x%) + exp_2(%x%) %$$ as defined by the $cref exp_2.hpp$$ include file. @@ -51,16 +52,16 @@ at the point $latex x = .1$$ of the function $codei% - exp_2(%x%) + exp_2(%x%) %$$ $lnext Create a routine called $codei% - exp_3(%x%) + exp_3(%x%) %$$ that evaluates the function $latex \[ - f(x) = 1 + x^2 / 2 + x^3 / 6 + f(x) = 1 + x^2 / 2 + x^3 / 6 \] $$ Test a modified version of the routine below that computes the derivative of $latex f(x)$$ @@ -71,67 +72,67 @@ # include // http://www.coin-or.org/CppAD/ # include "exp_2.hpp" // second order exponential approximation bool exp_2_cppad(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::vector; // can use any simple vector template class - using CppAD::NearEqual; // checks if values are nearly equal - - // domain space vector - size_t n = 1; // dimension of the domain space - vector< AD > X(n); - X[0] = .5; // value of x for this operation sequence - - // declare independent variables and start recording operation sequence - CppAD::Independent(X); - - // evaluate our exponential approximation - AD x = X[0]; - AD apx = exp_2(x); - - // range space vector - size_t m = 1; // dimension of the range space - vector< AD > Y(m); - 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 - // sweep using values in X for x. - CppAD::ADFun f(X, Y); - - // first order forward sweep that computes - // partial of exp_2(x) with respect to x - vector dx(n); // differential in domain space - vector dy(m); // differential in range space - dx[0] = 1.; // direction for partial derivative - dy = f.Forward(1, dx); - double check = 1.5; - ok &= NearEqual(dy[0], check, 1e-10, 1e-10); - - // first order reverse 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 - dw = f.Reverse(1, w); // derivative of w[0] * exp_2(x) - check = 1.5; // partial of exp_2(x) with respect to x - ok &= NearEqual(dw[0], check, 1e-10, 1e-10); - - // 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); - 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 - ok &= NearEqual(y2[0], check, 1e-10, 1e-10); - - // second order reverse sweep that computes - // derivative of partial of exp_2(x) w.r.t. x - dw.resize(2 * n); // space for first and second derivatives - dw = f.Reverse(2, w); - check = 1.; // result should be second derivative - ok &= NearEqual(dw[0*2+1], check, 1e-10, 1e-10); +{ bool ok = true; + using CppAD::AD; + using CppAD::vector; // can use any simple vector template class + using CppAD::NearEqual; // checks if values are nearly equal + + // domain space vector + size_t n = 1; // dimension of the domain space + vector< AD > X(n); + X[0] = .5; // value of x for this operation sequence + + // declare independent variables and start recording operation sequence + CppAD::Independent(X); + + // evaluate our exponential approximation + AD x = X[0]; + AD apx = exp_2(x); + + // range space vector + size_t m = 1; // dimension of the range space + vector< AD > Y(m); + 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 + // sweep using values in X for x. + CppAD::ADFun f(X, Y); + + // first order forward sweep that computes + // partial of exp_2(x) with respect to x + vector dx(n); // differential in domain space + vector dy(m); // differential in range space + dx[0] = 1.; // direction for partial derivative + dy = f.Forward(1, dx); + double check = 1.5; + ok &= NearEqual(dy[0], check, 1e-10, 1e-10); + + // first order reverse 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 + dw = f.Reverse(1, w); // derivative of w[0] * exp_2(x) + check = 1.5; // partial of exp_2(x) with respect to x + ok &= NearEqual(dw[0], check, 1e-10, 1e-10); + + // 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); + 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 + ok &= NearEqual(y2[0], check, 1e-10, 1e-10); + + // second order reverse sweep that computes + // derivative of partial of exp_2(x) w.r.t. x + dw.resize(2 * n); // space for first and second derivatives + dw = f.Reverse(2, w); + check = 1.; // result should be second derivative + ok &= NearEqual(dw[0*2+1], check, 1e-10, 1e-10); - return ok; + return ok; } /* %$$ diff -Nru cppad-2018.00.00.0/introduction/exp_2_for0.cpp cppad-2019.02.00.0/introduction/exp_2_for0.cpp --- cppad-2018.00.00.0/introduction/exp_2_for0.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_2_for0.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,54 +1,54 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_2_for0.cpp$$ $spell - std - exp_2_seq - cmath - bool - fabs + std + exp_2_seq + cmath + bool + fabs $$ $section exp_2: Verify Zero Order Forward Sweep$$ -$mindex exp_2$$ $srccode%cpp% */ # include // for fabs function bool exp_2_for0(double *v0) // double v0[6] -{ bool ok = true; - double x = .5; +{ bool ok = true; + double x = .5; - v0[1] = x; // v1 = x - ok &= std::fabs( v0[1] - 0.5) < 1e-10; + v0[1] = x; // v1 = x + ok &= std::fabs( v0[1] - 0.5) < 1e-10; - v0[2] = 1. + v0[1]; // v2 = 1 + v1 - ok &= std::fabs( v0[2] - 1.5) < 1e-10; + v0[2] = 1. + v0[1]; // v2 = 1 + v1 + ok &= std::fabs( v0[2] - 1.5) < 1e-10; - v0[3] = v0[1] * v0[1]; // v3 = v1 * v1 - ok &= std::fabs( v0[3] - 0.25) < 1e-10; + v0[3] = v0[1] * v0[1]; // v3 = v1 * v1 + ok &= std::fabs( v0[3] - 0.25) < 1e-10; - v0[4] = v0[3] / 2.; // v4 = v3 / 2 - ok &= std::fabs( v0[4] - 0.125) < 1e-10; + v0[4] = v0[3] / 2.; // v4 = v3 / 2 + ok &= std::fabs( v0[4] - 0.125) < 1e-10; - v0[5] = v0[2] + v0[4]; // v5 = v2 + v4 - ok &= std::fabs( v0[5] - 1.625) < 1e-10; + v0[5] = v0[2] + v0[4]; // v5 = v2 + v4 + ok &= std::fabs( v0[5] - 1.625) < 1e-10; - return ok; + return ok; } bool exp_2_for0(void) -{ double v0[6]; - return exp_2_for0(v0); +{ double v0[6]; + return exp_2_for0(v0); } /* %$$ $end diff -Nru cppad-2018.00.00.0/introduction/exp_2_for1.cpp cppad-2019.02.00.0/introduction/exp_2_for1.cpp --- cppad-2018.00.00.0/introduction/exp_2_for1.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_2_for1.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,57 +1,57 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_2_for1.cpp$$ $spell - std - exp_2_for - cmath - fabs - bool + std + exp_2_for + cmath + fabs + bool $$ $section exp_2: Verify First Order Forward Sweep$$ -$mindex exp_2$$ $srccode%cpp% */ # include // prototype for fabs extern bool exp_2_for0(double *v0); // computes zero order forward sweep bool exp_2_for1(double *v1) // double v1[6] -{ bool ok = true; - double v0[6]; +{ bool ok = true; + double v0[6]; - // set the value of v0[j] for j = 1 , ... , 5 - ok &= exp_2_for0(v0); + // set the value of v0[j] for j = 1 , ... , 5 + ok &= exp_2_for0(v0); - v1[1] = 1.; // v1 = x - ok &= std::fabs( v1[1] - 1. ) <= 1e-10; + v1[1] = 1.; // v1 = x + ok &= std::fabs( v1[1] - 1. ) <= 1e-10; - v1[2] = v1[1]; // v2 = 1 + v1 - ok &= std::fabs( v1[2] - 1. ) <= 1e-10; + v1[2] = v1[1]; // v2 = 1 + v1 + ok &= std::fabs( v1[2] - 1. ) <= 1e-10; - v1[3] = v1[1] * v0[1] + v0[1] * v1[1]; // v3 = v1 * v1 - ok &= std::fabs( v1[3] - 1. ) <= 1e-10; + v1[3] = v1[1] * v0[1] + v0[1] * v1[1]; // v3 = v1 * v1 + ok &= std::fabs( v1[3] - 1. ) <= 1e-10; - v1[4] = v1[3] / 2.; // v4 = v3 / 2 - ok &= std::fabs( v1[4] - 0.5) <= 1e-10; + v1[4] = v1[3] / 2.; // v4 = v3 / 2 + ok &= std::fabs( v1[4] - 0.5) <= 1e-10; - v1[5] = v1[2] + v1[4]; // v5 = v2 + v4 - ok &= std::fabs( v1[5] - 1.5) <= 1e-10; + v1[5] = v1[2] + v1[4]; // v5 = v2 + v4 + ok &= std::fabs( v1[5] - 1.5) <= 1e-10; - return ok; + return ok; } bool exp_2_for1(void) -{ double v1[6]; - return exp_2_for1(v1); +{ double v1[6]; + return exp_2_for1(v1); } /* %$$ $end diff -Nru cppad-2018.00.00.0/introduction/exp_2_for2.cpp cppad-2019.02.00.0/introduction/exp_2_for2.cpp --- cppad-2018.00.00.0/introduction/exp_2_for2.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_2_for2.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_2_for2.cpp$$ $spell - std - exp_2_for - cmath - fabs - bool + std + exp_2_for + cmath + fabs + bool $$ $section exp_2: Verify Second Order Forward Sweep$$ -$mindex exp_2$$ $srccode%cpp% */ @@ -27,29 +27,29 @@ extern bool exp_2_for0(double *v0); // computes zero order forward sweep extern bool exp_2_for1(double *v1); // computes first order forward sweep bool exp_2_for2(void) -{ bool ok = true; - double v0[6], v1[6], v2[6]; +{ bool ok = true; + double v0[6], v1[6], v2[6]; - // set the value of v0[j], v1[j], for j = 1 , ... , 5 - ok &= exp_2_for0(v0); - ok &= exp_2_for1(v1); + // set the value of v0[j], v1[j], for j = 1 , ... , 5 + ok &= exp_2_for0(v0); + ok &= exp_2_for1(v1); - v2[1] = 0.; // v1 = x - ok &= std::fabs( v2[1] - 0. ) <= 1e-10; + v2[1] = 0.; // v1 = x + ok &= std::fabs( v2[1] - 0. ) <= 1e-10; - v2[2] = v2[1]; // v2 = 1 + v1 - ok &= std::fabs( v2[2] - 0. ) <= 1e-10; + v2[2] = v2[1]; // v2 = 1 + v1 + ok &= std::fabs( v2[2] - 0. ) <= 1e-10; - v2[3] = 2.*(v0[1]*v2[1] + v1[1]*v1[1]); // v3 = v1 * v1 - ok &= std::fabs( v2[3] - 2. ) <= 1e-10; + v2[3] = 2.*(v0[1]*v2[1] + v1[1]*v1[1]); // v3 = v1 * v1 + ok &= std::fabs( v2[3] - 2. ) <= 1e-10; - v2[4] = v2[3] / 2.; // v4 = v3 / 2 - ok &= std::fabs( v2[4] - 1. ) <= 1e-10; + v2[4] = v2[3] / 2.; // v4 = v3 / 2 + ok &= std::fabs( v2[4] - 1. ) <= 1e-10; - v2[5] = v2[2] + v2[4]; // v5 = v2 + v4 - ok &= std::fabs( v2[5] - 1. ) <= 1e-10; + v2[5] = v2[2] + v2[4]; // v5 = v2 + v4 + ok &= std::fabs( v2[5] - 1. ) <= 1e-10; - return ok; + return ok; } /* %$$ $end diff -Nru cppad-2018.00.00.0/introduction/exp_2.hpp cppad-2019.02.00.0/introduction/exp_2.hpp --- cppad-2018.00.00.0/introduction/exp_2.hpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_2.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,30 +1,29 @@ # ifndef CPPAD_INTRODUCTION_EXP_2_HPP # define CPPAD_INTRODUCTION_EXP_2_HPP - /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_2$$ $spell - cppad-%yyyymmdd% - hpp - Apx - cpp - const - exp - bool + cppad-%yyyymmdd% + hpp + Apx + cpp + const + exp + bool $$ $section Second Order Exponential Approximation$$ -$mindex exp_2 example algorithm$$ $head Syntax$$ @@ -42,7 +41,7 @@ $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 \[ @@ -53,7 +52,7 @@ $head include$$ The include command in the syntax is relative to $codei% - cppad-%yyyymmdd%/introduction/exp_apx + cppad-%yyyymmdd%/introduction/exp_apx %$$ where $codei%cppad-%yyyymmdd%$$ is the distribution directory created during the beginning steps of the @@ -62,7 +61,7 @@ $head x$$ The argument $icode x$$ has prototype $codei% - const %Type% &%x% + const %Type% &%x% %$$ (see $icode Type$$ below). It specifies the point at which to evaluate the @@ -71,7 +70,7 @@ $head y$$ The result $icode y$$ has prototype $codei% - %Type% %y% + %Type% %y% %$$ It is the value of the exponential function approximation defined above. @@ -84,29 +83,29 @@ $bold Operation$$ $cnext $bold Result Type$$ $cnext $bold Description$$ $rnext $icode%Type%(%i%)%$$ - $cnext $icode Type$$ - $cnext construct object with value equal to $icode i$$ + $cnext $icode Type$$ + $cnext construct object with value equal to $icode i$$ $rnext $icode%Type u %=% v%$$ - $cnext $icode Type$$ - $cnext construct $icode u$$ with value equal to $icode v$$ + $cnext $icode Type$$ + $cnext construct $icode u$$ with value equal to $icode v$$ $rnext $icode%u% * %v%$$ - $cnext $icode Type$$ - $cnext result is value of $latex u * v$$ + $cnext $icode Type$$ + $cnext result is value of $latex u * v$$ $rnext $icode%u% / %v%$$ - $cnext $icode Type$$ - $cnext result is value of $latex u / v$$ + $cnext $icode Type$$ + $cnext result is value of $latex u / v$$ $rnext $icode%u% + %v%$$ - $cnext $icode Type$$ - $cnext result is value of $latex u + v$$ + $cnext $icode Type$$ + $cnext result is value of $latex u + v$$ $tend $childtable% - introduction/exp_2.omh% - introduction/exp_2_cppad.cpp + introduction/exp_2.omh% + introduction/exp_2_cppad.cpp %$$ @@ -117,15 +116,14 @@ $head Test$$ 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 $codep - double x = .1; - double y = exp_2(x); + double x = .1; + double y = exp_2(x); $$ What is the value assigned to $code v1$$, $code v2$$, ... ,$code v5$$ in $cref exp_2.hpp$$ ? @@ -133,15 +131,15 @@ Extend the routine $code exp_2.hpp$$ to a routine $code exp_3.hpp$$ that computes $latex \[ - 1 + x^2 / 2 ! + x^3 / 3 ! + 1 + x^2 / 2 ! + x^3 / 3 ! \] $$ Do this in a way that only assigns one value to each variable (as $code exp_2$$ does). $lnext Suppose that we make the call $codep - double x = .5; - double y = exp_3(x); + double x = .5; + double y = exp_3(x); $$ using $code exp_3$$ created in the previous problem. What is the value assigned to the new variables in $code exp_3$$ diff -Nru cppad-2018.00.00.0/introduction/exp_2.omh cppad-2019.02.00.0/introduction/exp_2.omh --- cppad-2018.00.00.0/introduction/exp_2.omh 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_2.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,49 +1,44 @@ ----------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ----------------------------------------------------------------------------- $begin exp_2.hpp$$ $spell - exp + exp $$ $section exp_2: Implementation$$ -$mindex exp_2$$ -$code $srcfile%introduction/exp_2.hpp%0%// BEGIN C++%// END C++%$$ -$$ $end ----------------------------------------------------------------------------- $begin exp_2.cpp$$ $spell - exp + exp $$ $section exp_2: Test$$ -$code $srcfile%introduction/exp_2.cpp%0%// BEGIN C++%// END C++%$$ -$$ $end ----------------------------------------------------------------------------- $begin exp_2_for0$$ $spell - cpp - exp_2_seq - bool + cpp + exp_2_seq + bool $$ $section exp_2: Operation Sequence and Zero Order Forward Mode$$ -$mindex example$$ @@ -53,7 +48,7 @@ the algorithm $cref exp_2.hpp$$ is the same for all values of $icode x$$. The mathematical form for the corresponding function is $latex \[ - f(x) = 1 + x + x^2 / 2 + f(x) = 1 + x + x^2 / 2 \] $$ An algorithmic differentiation package does not operate on the mathematical function $latex f(x)$$ @@ -65,7 +60,7 @@ $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)} ) + y^{(0)} = f( x^{(0)} ) \]$$ The superscript $latex (0)$$ denotes zero order derivative; i.e., it is equal to the value @@ -117,53 +112,52 @@ $center $table $bold Index$$ - $cnext $pre $$ $cnext $bold Code$$ - $cnext $pre $$ $cnext $bold Operation$$ - $cnext $pre $$ $cnext $bold Zero Order$$ + $cnext $pre $$ $cnext $bold Code$$ + $cnext $pre $$ $cnext $bold Operation$$ + $cnext $pre $$ $cnext $bold Zero Order$$ $rnext 1 - $cnext $pre $$ $cnext $code Type v1 = x;$$ - $cnext $cnext $latex v_1 = x $$ - $cnext $cnext $latex v_1^{(0)} = 0.5$$ + $cnext $pre $$ $cnext $code Type v1 = x;$$ + $cnext $cnext $latex v_1 = x $$ + $cnext $cnext $latex v_1^{(0)} = 0.5$$ $rnext 2 - $cnext $pre $$ $cnext $code Type v2 = Type(1) + v1;$$ - $cnext $cnext $latex v_2 = 1 + v_1 $$ - $cnext $cnext $latex v_2^{(0)} = 1.5$$ + $cnext $pre $$ $cnext $code Type v2 = Type(1) + v1;$$ + $cnext $cnext $latex v_2 = 1 + v_1 $$ + $cnext $cnext $latex v_2^{(0)} = 1.5$$ $rnext 3 - $cnext $pre $$ $cnext $code Type v3 = v1 * v1;$$ - $cnext $cnext $latex v_3 = v_1 * v_1 $$ - $cnext $cnext $latex v_3^{(0)} = 0.25$$ + $cnext $pre $$ $cnext $code Type v3 = v1 * v1;$$ + $cnext $cnext $latex v_3 = v_1 * v_1 $$ + $cnext $cnext $latex v_3^{(0)} = 0.25$$ $rnext 4 - $cnext $pre $$ $cnext $code Type v4 = v3 / Type(2);$$ - $cnext $cnext $latex v_4 = v_3 / 2$$ - $cnext $cnext $latex v_4^{(0)} = 0.125$$ + $cnext $pre $$ $cnext $code Type v4 = v3 / Type(2);$$ + $cnext $cnext $latex v_4 = v_3 / 2$$ + $cnext $cnext $latex v_4^{(0)} = 0.125$$ $rnext 5 - $cnext $pre $$ $cnext $code Type v5 = v2 + v4;$$ - $cnext $cnext $latex v_5 = v_2 + v_4 $$ - $cnext $cnext $latex v_5^{(0)} = 1.625$$ + $cnext $pre $$ $cnext $code Type v5 = v2 + v4;$$ + $cnext $cnext $latex v_5 = v_2 + v_4 $$ + $cnext $cnext $latex v_5^{(0)} = 1.625$$ $tend $$ $head Return Value$$ The return value for this case is $latex \[ - 1.625 = - v_5^{(0)} = - f( x^{(0)} ) + 1.625 = + v_5^{(0)} = + f( x^{(0)} ) \] $$ $children% - introduction/exp_2_for0.cpp + introduction/exp_2_for0.cpp %$$ $head Verification$$ 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$$ @@ -172,7 +166,7 @@ the operation sequence above; i.e., what are the corresponding values for $latex \[ - v_1^{(0)} , v_2^{(0)} , \cdots , v_5^{(0)} + v_1^{(0)} , v_2^{(0)} , \cdots , v_5^{(0)} \]$$ $lnext Create a modified version of @@ -189,7 +183,7 @@ ------------------------------------------------------------------------------ $begin exp_2_for1$$ $spell - exp_2_for + exp_2_for $$ $section exp_2: First Order Forward Mode$$ @@ -199,7 +193,7 @@ $head First Order Expansion$$ We define $latex x(t)$$ near $latex t = 0$$ by the first order expansion $latex \[ - x(t) = x^{(0)} + x^{(1)} * t + x(t) = x^{(0)} + x^{(1)} * t \]$$ it follows that $latex x^{(0)}$$ is the zero, and $latex x^{(1)}$$ the first, @@ -218,11 +212,11 @@ $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_2.hpp$$ to compute $latex \[ - f(x) = 1 + x + x^2 / 2 + f(x) = 1 + x + x^2 / 2 \] $$ The corresponding derivative function is $latex \[ - \partial_x f (x) = 1 + x + \partial_x f (x) = 1 + x \] $$ An algorithmic differentiation package does not operate on the mathematical form of the function, @@ -264,7 +258,7 @@ The First Order column contains the first order derivatives for the corresponding variable in the operation sequence; i.e., $latex \[ - v_j (t) = v_j^{(0)} + v_j^{(1)} t + v_j (t) = v_j^{(0)} + v_j^{(1)} t \] $$ We use $latex x^{(1)} = 1$$ so that differentiation with respect to $latex t$$, @@ -278,44 +272,44 @@ $center $table $bold Index$$ - $cnext $pre $$ $cnext $bold Operation$$ - $cnext $pre $$ $cnext $bold Zero Order$$ - $cnext $pre $$ $cnext $bold Derivative$$ - $cnext $pre $$ $cnext $bold First Order$$ + $cnext $pre $$ $cnext $bold Operation$$ + $cnext $pre $$ $cnext $bold Zero Order$$ + $cnext $pre $$ $cnext $bold Derivative$$ + $cnext $pre $$ $cnext $bold First Order$$ $rnext 1 - $cnext $pre $$ $cnext $latex v_1 = x $$ - $cnext $cnext 0.5 - $cnext $cnext - $latex v_1^{(1)} = x^{(1)} $$ - $cnext $cnext $latex v_1^{(1)} = 1$$ + $cnext $pre $$ $cnext $latex v_1 = x $$ + $cnext $cnext 0.5 + $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 - $latex v_2^{(1)} = v_1^{(1)}$$ - $cnext $cnext $latex v_2^{(1)} = 1$$ + $cnext $pre $$ $cnext $latex v_2 = 1 + v_1$$ + $cnext $cnext 1.5 + $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 - $latex v_3^{(1)} = 2 * v_1^{(0)} * v_1^{(1)}$$ - $cnext $cnext $latex v_3^{(1)} = 1$$ + $cnext $pre $$ $cnext $latex v_3 = v_1 * v_1$$ + $cnext $cnext 0.25 + $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 - $latex v_4^{(1)} = v_3^{(1)} / 2$$ - $cnext $cnext $latex v_4^{(1)} = 0.5$$ -$rnext -5 $cnext $pre $$ $cnext $latex v_5 = v_2 + v_4$$ - $cnext $cnext 1.625 - $cnext $cnext - $latex v_5^{(1)} = v_2^{(1)} + v_4^{(1)}$$ - $cnext $cnext $latex v_5^{(1)} = 1.5$$ + $cnext $pre $$ $cnext $latex v_4 = v_3 / 2$$ + $cnext $cnext 0.125 + $cnext $cnext + $latex v_4^{(1)} = v_3^{(1)} / 2$$ + $cnext $cnext $latex v_4^{(1)} = 0.5$$ +$rnext +5 $cnext $pre $$ $cnext $latex v_5 = v_2 + v_4$$ + $cnext $cnext 1.625 + $cnext $cnext + $latex v_5^{(1)} = v_2^{(1)} + v_4^{(1)}$$ + $cnext $cnext $latex v_5^{(1)} = 1.5$$ $tend $$ @@ -323,26 +317,25 @@ The derivative of the return value for this case is $latex \[ \begin{array}{rcl} - 1.5 - & = & - v_5^{(1)} = - \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)} ) + 1.5 + & = & + v_5^{(1)} = + \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)} ) \end{array} \] $$ (We have used the fact that $latex x^{(1)} = 1$$.) $children% - introduction/exp_2_for1.cpp + introduction/exp_2_for1.cpp %$$ $head Verification$$ 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$$ @@ -368,7 +361,7 @@ ------------------------------------------------------------------------------ $begin exp_2_rev1$$ $spell - exp_2_rev + exp_2_rev $$ $section exp_2: First Order Reverse Mode$$ @@ -388,11 +381,11 @@ $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_2.hpp$$ to compute $latex \[ - f(x) = 1 + x + x^2 / 2 + f(x) = 1 + x + x^2 / 2 \] $$ The corresponding derivative function is $latex \[ - \partial_x f (x) = 1 + x + \partial_x f (x) = 1 + x \] $$ $head f_5$$ @@ -415,7 +408,7 @@ Reverse mode starts with the last operation in the sequence. For the case in question, this is the operation with index 5, $latex \[ - v_5 = v_2 + v_4 + v_5 = v_2 + v_4 \] $$ We define the function $latex f_4 ( v_1 , v_2 , v_3 , v_4 ) $$ @@ -431,12 +424,12 @@ \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_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_5}{v_5} * \D{v_5}{v_4} & = 1 \end{array} \] $$ @@ -445,7 +438,7 @@ $head Index 4: f_3$$ The next operation has index 4, $latex \[ - v_4 = v_3 / 2 + v_4 = v_3 / 2 \] $$ We define the function $latex f_3 ( v_1 , v_2 , v_3 ) $$ @@ -468,7 +461,7 @@ \\ \D{f_3}{v_3} & = & \D{f_4}{v_3} + - \D{f_4}{v_4} * \D{v_4}{v_3} + \D{f_4}{v_4} * \D{v_4}{v_3} & = 0.5 \end{array} \] $$ @@ -476,7 +469,7 @@ $head Index 3: f_2$$ The next operation has index 3, $latex \[ - v_3 = v_1 * v_1 + v_3 = v_1 * v_1 \] $$ We define the function $latex f_2 ( v_1 , v_2 ) $$ @@ -493,7 +486,7 @@ \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} @@ -505,7 +498,7 @@ $head Index 2: f_1$$ The next operation has index 2, $latex \[ - v_2 = 1 + v_1 + v_2 = 1 + v_1 \] $$ We define the function $latex f_1 ( v_1 ) $$ @@ -520,7 +513,7 @@ \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} \] $$ @@ -529,12 +522,11 @@ the function defined by $cref exp_2.hpp$$ at $latex x = .5$$. $children% - introduction/exp_2_rev1.cpp + introduction/exp_2_rev1.cpp %$$ $head Verification$$ 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 $latex f_j$$ that might not be equal to the corresponding partials of $latex f_{j+1}$$; i.e., the @@ -567,7 +559,7 @@ ------------------------------------------------------------------------------ $begin exp_2_for2$$ $spell - exp_2_for + exp_2_for $$ $section exp_2: Second Order Forward Mode$$ @@ -577,11 +569,11 @@ $head Second Order Expansion$$ 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 + x(t) = x^{(0)} + x^{(1)} * t + x^{(2)} * t^2 / 2 \]$$ It follows that for $latex k = 0 , 1 , 2$$, $latex \[ - x^{(k)} = \dpow{k}{t} x (0) + x^{(k)} = \dpow{k}{t} x (0) \] $$ $head Purpose$$ @@ -596,11 +588,11 @@ $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_2.hpp$$ to compute $latex \[ - f(x) = 1 + x + x^2 / 2 + f(x) = 1 + x + x^2 / 2 \] $$ The corresponding second derivative function is $latex \[ - \Dpow{2}{x} f (x) = 1 + \Dpow{2}{x} f (x) = 1 \] $$ $head Operation Sequence$$ @@ -642,7 +634,7 @@ for the corresponding variable in the operation sequence; i.e., the second order expansion for the $th i$$ variable is given by $latex \[ - v_i (t) = v_i^{(0)} + v_i^{(1)} * t + v_i^{(2)} * t^2 / 2 + v_i (t) = v_i^{(0)} + v_i^{(1)} * t + v_i^{(2)} * t^2 / 2 \] $$ We use $latex x^{(0)} = 1$$, and $latex x^{(2)} = 0$$ so that second order differentiation @@ -656,51 +648,51 @@ $center $table $bold Index$$ - $cnext $pre $$ $cnext $bold Zero$$ - $cnext $pre $$ $cnext $bold Operation$$ - $cnext $pre $$ $cnext $bold First$$ - $cnext $pre $$ $cnext $bold Derivative$$ - $cnext $pre $$ $cnext $bold Second$$ + $cnext $pre $$ $cnext $bold Zero$$ + $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 $pre $$ $cnext $latex v_1^{(1)} = x^{(1)} $$ - $cnext $cnext 1 - $cnext $cnext - $latex v_1^{(2)} = x^{(2)}$$ - $cnext $cnext $latex v_1^{(2)} = 0$$ + $cnext $cnext 0.5 + $cnext $pre $$ $cnext $latex v_1^{(1)} = x^{(1)} $$ + $cnext $cnext 1 + $cnext $cnext + $latex v_1^{(2)} = x^{(2)}$$ + $cnext $cnext $latex v_1^{(2)} = 0$$ $rnext 2 - $cnext $cnext 1.5 - $cnext $pre $$ $cnext $latex v_2^{(1)} = v_1^{(1)}$$ - $cnext $cnext 1 - $cnext $cnext - $latex v_2^{(2)} = v_1^{(2)}$$ - $cnext $cnext $latex v_2^{(2)} = 0$$ + $cnext $cnext 1.5 + $cnext $pre $$ $cnext $latex v_2^{(1)} = v_1^{(1)}$$ + $cnext $cnext 1 + $cnext $cnext + $latex v_2^{(2)} = v_1^{(2)}$$ + $cnext $cnext $latex v_2^{(2)} = 0$$ $rnext 3 - $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 0.25 + $cnext $pre $$ $cnext $latex v_3^{(1)} = 2 * v_1^{(0)} * v_1^{(1)}$$ + $cnext $cnext 1 + $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$$ + $cnext $cnext $latex v_3^{(2)} = 2$$ $rnext 4 - $cnext $cnext 0.125 - $cnext $pre $$ $cnext $latex v_4^{(1)} = v_3^{(1)} / 2$$ - $cnext $cnext .5 - $cnext $cnext - $latex v_4^{(2)} = v_3^{(2)} / 2$$ - $cnext $cnext $latex v_4^{(2)} = 1$$ + $cnext $cnext 0.125 + $cnext $pre $$ $cnext $latex v_4^{(1)} = v_3^{(1)} / 2$$ + $cnext $cnext .5 + $cnext $cnext + $latex v_4^{(2)} = v_3^{(2)} / 2$$ + $cnext $cnext $latex v_4^{(2)} = 1$$ $rnext 5 - $cnext $cnext 1.625 - $cnext $pre $$ $cnext $latex v_5^{(1)} = v_2^{(1)} + v_4^{(1)}$$ - $cnext $cnext 1.5 - $cnext $cnext - $latex v_5^{(2)} = v_2^{(2)} + v_4^{(2)}$$ - $cnext $cnext $latex v_5^{(2)} = 1$$ + $cnext $cnext 1.625 + $cnext $pre $$ $cnext $latex v_5^{(1)} = v_2^{(1)} + v_4^{(1)}$$ + $cnext $cnext 1.5 + $cnext $cnext + $latex v_5^{(2)} = v_2^{(2)} + v_4^{(2)}$$ + $cnext $cnext $latex v_5^{(2)} = 1$$ $tend $$ @@ -708,27 +700,26 @@ The second derivative of the return value for this case is $latex \[ \begin{array}{rcl} - 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)} = - \Dpow{2}{x} f ( x^{(0)} ) + 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)} = + \Dpow{2}{x} f ( x^{(0)} ) \end{array} \] $$ (We have used the fact that $latex x^{(1)} = 1$$ and $latex x^{(2)} = 0$$.) $children% - introduction/exp_2_for2.cpp + introduction/exp_2_for2.cpp %$$ $head Verification$$ 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$$ @@ -753,7 +744,7 @@ ------------------------------------------------------------------------------ $begin exp_2_rev2$$ $spell - exp_2_rev + exp_2_rev $$ $section exp_2: Second Order Reverse Mode$$ @@ -773,11 +764,11 @@ $head Mathematical Form$$ Suppose that we use the algorithm $cref exp_2.hpp$$ to compute $latex \[ - f(x) = 1 + x + x^2 / 2 + f(x) = 1 + x + x^2 / 2 \] $$ The corresponding second derivative is $latex \[ - \Dpow{2}{x} f (x) = 1 + \Dpow{2}{x} f (x) = 1 \] $$ $head f_5$$ @@ -794,7 +785,7 @@ $latex \[ \begin{array}{rcl} f_5 \left( - v_1^{(0)}, v_1^{(1)} , \ldots , v_5^{(0)} , v_5^{(1)} + v_1^{(0)}, v_1^{(1)} , \ldots , v_5^{(0)} , v_5^{(1)} \right) & = & v_5^{(1)} \\ @@ -809,9 +800,9 @@ The zero and first order sweep representations of this operation are $latex \[ \begin{array}{rcl} - v_5^{(0)} & = & v_2^{(0)} + v_4^{(0)} - \\ - v_5^{(1)} & = & v_2^{(1)} + v_4^{(1)} + v_5^{(0)} & = & v_2^{(0)} + v_4^{(0)} + \\ + v_5^{(1)} & = & v_2^{(1)} + v_4^{(1)} \end{array} \] $$ We define the function @@ -822,8 +813,8 @@ $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) + 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 @@ -831,12 +822,12 @@ \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_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_5}{v_5^{(1)}} * \D{v_5}{v_4^{(1)}} & = 1 \end{array} \] $$ @@ -846,9 +837,9 @@ The next operation has index 4, $latex \[ \begin{array}{rcl} - v_4^{(0)} & = & v_3^{(0)} / 2 - \\ - v_4^{(1)} & = & v_3^{(1)} / 2 + v_4^{(0)} & = & v_3^{(0)} / 2 + \\ + v_4^{(1)} & = & v_3^{(1)} / 2 \end{array} \] $$ We define the function @@ -859,8 +850,8 @@ $latex \[ 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^{(0)} \left( v_3^{(0)} \right) , + v_4^{(1)} \left( v_3^{(1)} \right) \right] \] $$ It follows that @@ -872,7 +863,7 @@ \\ \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_4}{v_4^{(1)}} * \D{v_4^{(1)}}{v_3^{(1)}} & = 0.5 \end{array} \] $$ @@ -882,9 +873,9 @@ The next operation has index 3, $latex \[ \begin{array}{rcl} - v_3^{(0)} & = & v_1^{(0)} * v_1^{(0)} - \\ - v_3^{(1)} & = & 2 * v_1^{(0)} * v_1^{(1)} + v_3^{(0)} & = & v_1^{(0)} * v_1^{(0)} + \\ + v_3^{(1)} & = & 2 * v_1^{(0)} * v_1^{(1)} \end{array} \] $$ We define the function @@ -895,8 +886,8 @@ $latex \[ 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^{(0)} ( v_1^{(0)} ) , + v_3^{(1)} ( v_1^{(0)} , v_1^{(1)} ) \right] \] $$ Note that, from the @@ -909,14 +900,14 @@ \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^{(0)}} * \D{v_3^{(0)}}{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)}} + \D{f_3}{v_3^{(1)}} * \D{v_3^{(1)}}{v_1^{(1)}} & = 0.5 \\ \D{f_2}{v_2^{(0)}} @@ -933,9 +924,9 @@ The next operation has index 2, $latex \[ \begin{array}{rcl} - v_2^{(0)} & = & 1 + v_1^{(0)} - \\ - v_2^{(1)} & = & v_1^{(1)} + v_2^{(0)} & = & 1 + v_1^{(0)} + \\ + v_2^{(1)} & = & v_1^{(1)} \end{array} \] $$ We define the function @@ -946,8 +937,8 @@ $latex \[ f_1 = f_2 \left[ v_1^{(0)} , v_1^{(1)} , - v_2^{(0)} ( v_1^{(0)} ) , - v_2^{(1)} ( v_1^{(1)} ) + v_2^{(0)} ( v_1^{(0)} ) , + v_2^{(1)} ( v_1^{(1)} ) \right] \] $$ It follows that @@ -955,12 +946,12 @@ \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)}} + \D{f_2}{v_2^{(1)}} * \D{v_2^{(1)}}{v_1^{(1)}} & = 1.5 \end{array} \] $$ @@ -984,12 +975,11 @@ $children% - introduction/exp_2_rev2.cpp + introduction/exp_2_rev2.cpp %$$ $head Verification$$ 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 $latex f_j$$ that might not be equal to the corresponding partials of $latex f_{j+1}$$; i.e., the diff -Nru cppad-2018.00.00.0/introduction/exp_2_rev1.cpp cppad-2019.02.00.0/introduction/exp_2_rev1.cpp --- cppad-2018.00.00.0/introduction/exp_2_rev1.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_2_rev1.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_2_rev1.cpp$$ $spell - cstddef - cmath - exp_2_rev - bool - std - fabs + cstddef + cmath + exp_2_rev + bool + std + fabs $$ $section exp_2: Verify First Order Reverse Sweep$$ -$mindex exp_2 mode$$ @@ -29,41 +29,41 @@ # include // prototype for fabs extern bool exp_2_for0(double *v0); // computes zero order forward sweep bool exp_2_rev1(void) -{ bool ok = true; +{ bool ok = true; - // set the value of v0[j] for j = 1 , ... , 5 - double v0[6]; - ok &= exp_2_for0(v0); - - // initial all partial derivatives as zero - double f_v[6]; - size_t j; - for(j = 0; j < 6; j++) - f_v[j] = 0.; - - // set partial derivative for f5 - f_v[5] = 1.; - ok &= std::fabs( f_v[5] - 1. ) <= 1e-10; // f5_v5 - - // f4 = f5( v1 , v2 , v3 , v4 , v2 + v4 ) - f_v[2] += f_v[5] * 1.; - f_v[4] += f_v[5] * 1.; - ok &= std::fabs( f_v[2] - 1. ) <= 1e-10; // f4_v2 - ok &= std::fabs( f_v[4] - 1. ) <= 1e-10; // f4_v4 - - // f3 = f4( v1 , v2 , v3 , v3 / 2 ) - f_v[3] += f_v[4] / 2.; - ok &= std::fabs( f_v[3] - 0.5) <= 1e-10; // f3_v3 - - // f2 = f3( v1 , v2 , v1 * v1 ) - f_v[1] += f_v[3] * 2. * v0[1]; - ok &= std::fabs( f_v[1] - 0.5) <= 1e-10; // f2_v1 - - // f1 = f2( v1 , 1 + v1 ) - f_v[1] += f_v[2] * 1.; - ok &= std::fabs( f_v[1] - 1.5) <= 1e-10; // f1_v1 + // set the value of v0[j] for j = 1 , ... , 5 + double v0[6]; + ok &= exp_2_for0(v0); + + // initial all partial derivatives as zero + double f_v[6]; + size_t j; + for(j = 0; j < 6; j++) + f_v[j] = 0.; + + // set partial derivative for f5 + f_v[5] = 1.; + ok &= std::fabs( f_v[5] - 1. ) <= 1e-10; // f5_v5 + + // f4 = f5( v1 , v2 , v3 , v4 , v2 + v4 ) + f_v[2] += f_v[5] * 1.; + f_v[4] += f_v[5] * 1.; + ok &= std::fabs( f_v[2] - 1. ) <= 1e-10; // f4_v2 + ok &= std::fabs( f_v[4] - 1. ) <= 1e-10; // f4_v4 + + // f3 = f4( v1 , v2 , v3 , v3 / 2 ) + f_v[3] += f_v[4] / 2.; + ok &= std::fabs( f_v[3] - 0.5) <= 1e-10; // f3_v3 + + // f2 = f3( v1 , v2 , v1 * v1 ) + f_v[1] += f_v[3] * 2. * v0[1]; + ok &= std::fabs( f_v[1] - 0.5) <= 1e-10; // f2_v1 + + // f1 = f2( v1 , 1 + v1 ) + f_v[1] += f_v[2] * 1.; + ok &= std::fabs( f_v[1] - 1.5) <= 1e-10; // f1_v1 - return ok; + return ok; } /* %$$ $end diff -Nru cppad-2018.00.00.0/introduction/exp_2_rev2.cpp cppad-2019.02.00.0/introduction/exp_2_rev2.cpp --- cppad-2018.00.00.0/introduction/exp_2_rev2.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_2_rev2.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_2_rev2.cpp$$ $spell - cstddef - cmath - exp_2_rev - bool - std - fabs + cstddef + cmath + exp_2_rev + bool + std + fabs $$ $section exp_2: Verify Second Order Reverse Sweep$$ -$mindex exp_2 mode$$ @@ -30,55 +30,55 @@ extern bool exp_2_for0(double *v0); // computes zero order forward sweep extern bool exp_2_for1(double *v1); // computes first order forward sweep bool exp_2_rev2(void) -{ bool ok = true; +{ bool ok = true; - // set the value of v0[j], v1[j] for j = 1 , ... , 5 - double v0[6], v1[6]; - ok &= exp_2_for0(v0); - ok &= exp_2_for1(v1); - - // initial all partial derivatives as zero - double f_v0[6], f_v1[6]; - size_t j; - for(j = 0; j < 6; j++) - { f_v0[j] = 0.; - f_v1[j] = 0.; - } - - // set partial derivative for f_5 - f_v1[5] = 1.; - ok &= std::fabs( f_v1[5] - 1. ) <= 1e-10; // partial f_5 w.r.t v_5^1 - - // f_4 = f_5( v_1^0 , ... , v_4^1 , v_2^0 + v_4^0 , v_2^1 + v_4^1 ) - f_v0[2] += f_v0[5] * 1.; - f_v0[4] += f_v0[5] * 1.; - f_v1[2] += f_v1[5] * 1.; - f_v1[4] += f_v1[5] * 1.; - ok &= std::fabs( f_v0[2] - 0. ) <= 1e-10; // partial f_4 w.r.t. v_2^0 - ok &= std::fabs( f_v0[4] - 0. ) <= 1e-10; // partial f_4 w.r.t. v_4^0 - ok &= std::fabs( f_v1[2] - 1. ) <= 1e-10; // partial f_4 w.r.t. v_2^1 - ok &= std::fabs( f_v1[4] - 1. ) <= 1e-10; // partial f_4 w.r.t. v_4^1 - - // f_3 = f_4( v_1^0 , ... , v_3^1, v_3^0 / 2 , v_3^1 / 2 ) - f_v0[3] += f_v0[4] / 2.; - f_v1[3] += f_v1[4] / 2.; - ok &= std::fabs( f_v0[3] - 0. ) <= 1e-10; // partial f_3 w.r.t. v_3^0 - ok &= std::fabs( f_v1[3] - 0.5 ) <= 1e-10; // partial f_3 w.r.t. v_3^1 - - // f_2 = f_3( v_1^0 , ... , v_2^1, v_1^0 * v_1^0 , 2 * v_1^0 * v_1^1 ) - f_v0[1] += f_v0[3] * 2. * v0[1]; - f_v0[1] += f_v1[3] * 2. * v1[1]; - f_v1[1] += f_v1[3] * 2. * v0[1]; - ok &= std::fabs( f_v0[1] - 1. ) <= 1e-10; // partial f_2 w.r.t. v_1^0 - ok &= std::fabs( f_v1[1] - 0.5 ) <= 1e-10; // partial f_2 w.r.t. v_1^1 - - // f_1 = f_2( v_1^0 , v_1^1 , 1 + v_1^0 , v_1^1 ) - f_v0[1] += f_v0[2] * 1.; - f_v1[1] += f_v1[2] * 1.; - ok &= std::fabs( f_v0[1] - 1. ) <= 1e-10; // partial f_1 w.r.t. v_1^0 - ok &= std::fabs( f_v1[1] - 1.5) <= 1e-10; // partial f_1 w.r.t. v_1^1 + // set the value of v0[j], v1[j] for j = 1 , ... , 5 + double v0[6], v1[6]; + ok &= exp_2_for0(v0); + ok &= exp_2_for1(v1); + + // initial all partial derivatives as zero + double f_v0[6], f_v1[6]; + size_t j; + for(j = 0; j < 6; j++) + { f_v0[j] = 0.; + f_v1[j] = 0.; + } + + // set partial derivative for f_5 + f_v1[5] = 1.; + ok &= std::fabs( f_v1[5] - 1. ) <= 1e-10; // partial f_5 w.r.t v_5^1 + + // f_4 = f_5( v_1^0 , ... , v_4^1 , v_2^0 + v_4^0 , v_2^1 + v_4^1 ) + f_v0[2] += f_v0[5] * 1.; + f_v0[4] += f_v0[5] * 1.; + f_v1[2] += f_v1[5] * 1.; + f_v1[4] += f_v1[5] * 1.; + ok &= std::fabs( f_v0[2] - 0. ) <= 1e-10; // partial f_4 w.r.t. v_2^0 + ok &= std::fabs( f_v0[4] - 0. ) <= 1e-10; // partial f_4 w.r.t. v_4^0 + ok &= std::fabs( f_v1[2] - 1. ) <= 1e-10; // partial f_4 w.r.t. v_2^1 + ok &= std::fabs( f_v1[4] - 1. ) <= 1e-10; // partial f_4 w.r.t. v_4^1 + + // f_3 = f_4( v_1^0 , ... , v_3^1, v_3^0 / 2 , v_3^1 / 2 ) + f_v0[3] += f_v0[4] / 2.; + f_v1[3] += f_v1[4] / 2.; + ok &= std::fabs( f_v0[3] - 0. ) <= 1e-10; // partial f_3 w.r.t. v_3^0 + ok &= std::fabs( f_v1[3] - 0.5 ) <= 1e-10; // partial f_3 w.r.t. v_3^1 + + // f_2 = f_3( v_1^0 , ... , v_2^1, v_1^0 * v_1^0 , 2 * v_1^0 * v_1^1 ) + f_v0[1] += f_v0[3] * 2. * v0[1]; + f_v0[1] += f_v1[3] * 2. * v1[1]; + f_v1[1] += f_v1[3] * 2. * v0[1]; + ok &= std::fabs( f_v0[1] - 1. ) <= 1e-10; // partial f_2 w.r.t. v_1^0 + ok &= std::fabs( f_v1[1] - 0.5 ) <= 1e-10; // partial f_2 w.r.t. v_1^1 + + // f_1 = f_2( v_1^0 , v_1^1 , 1 + v_1^0 , v_1^1 ) + f_v0[1] += f_v0[2] * 1.; + f_v1[1] += f_v1[2] * 1.; + ok &= std::fabs( f_v0[1] - 1. ) <= 1e-10; // partial f_1 w.r.t. v_1^0 + ok &= std::fabs( f_v1[1] - 1.5) <= 1e-10; // partial f_1 w.r.t. v_1^1 - return ok; + return ok; } /* %$$ $end diff -Nru cppad-2018.00.00.0/introduction/exp_eps.cpp cppad-2019.02.00.0/introduction/exp_eps.cpp --- cppad-2018.00.00.0/introduction/exp_eps.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_eps.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,22 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // BEGIN C++ # include // for fabs function # include "exp_eps.hpp" // definition of exp_eps algorithm bool exp_eps(void) -{ 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; - return ok; +{ 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/introduction/exp_eps_cppad.cpp cppad-2019.02.00.0/introduction/exp_eps_cppad.cpp --- cppad-2018.00.00.0/introduction/exp_eps_cppad.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_eps_cppad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,36 +1,37 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_eps_cppad$$ $spell - Taylor - dy - coef - resize - cppad.hpp - cmath - fabs - bool - exp_eps_cppad - du - dv - dw - endl - hpp - http - org - std - www - CppAD - apx + Taylor + dy + coef + resize + cppad.hpp + cmath + fabs + bool + exp_eps_cppad + du + dv + dw + endl + hpp + http + org + std + www + CppAD + apx $$ $section exp_eps: CppAD Forward and Reverse Sweeps$$. @@ -41,7 +42,7 @@ at the point $latex x = .5$$ and $latex \varepsilon = .2$$, of the function $codei% - exp_eps(%x%, %epsilon%) + exp_eps(%x%, %epsilon%) %$$ as defined by the $cref exp_eps.hpp$$ include file. @@ -52,7 +53,7 @@ at the point $latex x = .1$$ and $latex \varepsilon = .2$$, of the function $codei% - exp_eps(%x%, %epsilon%) + exp_eps(%x%, %epsilon%) %$$ $lnext Create and test a modified version of the routine below that computes @@ -62,7 +63,7 @@ for $latex x = .5$$ and $latex \varepsilon = .2$$. Hint: you could define a vector u with two components and use $codei% - %f%.Forward(0, %u%) + %f%.Forward(0, %u%) %$$ to run zero order forward mode at a point different form the point where the operation sequence corresponding to @@ -72,72 +73,72 @@ # include // http://www.coin-or.org/CppAD/ # include "exp_eps.hpp" // our example exponential function approximation bool exp_eps_cppad(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::vector; // can use any simple vector template class - using CppAD::NearEqual; // checks if values are nearly equal - - // domain space vector - size_t n = 2; // dimension of the domain space - vector< AD > U(n); - U[0] = .5; // value of x for this operation sequence - U[1] = .2; // value of e for this operation sequence - - // declare independent variables and start recording operation sequence - CppAD::Independent(U); - - // evaluate our exponential approximation - AD x = U[0]; - AD epsilon = U[1]; - AD apx = exp_eps(x, epsilon); - - // range space vector - size_t m = 1; // dimension of the range space - vector< AD > Y(m); - 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 - // mode sweep using values in U for x and e. - CppAD::ADFun f(U, Y); - - // first order forward mode sweep that computes partial w.r.t x - vector du(n); // differential in domain space - vector dy(m); // differential in range space - du[0] = 1.; // x direction in domain space - du[1] = 0.; - dy = f.Forward(1, du); // partial w.r.t. x - double check = 1.5; - ok &= NearEqual(dy[0], check, 1e-10, 1e-10); - - // 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 - 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); - check = 0.; // partial w.r.t. epsilon - ok &= NearEqual(dw[1], check, 1e-10, 1e-10); - - // second order forward sweep that computes - // second partial of exp_eps(x, epsilon) w.r.t. x - vector x2(n); // second order Taylor coefficients - vector y2(m); - x2[0] = 0.; // evaluate partial w.r.t x - x2[1] = 0.; - y2 = f.Forward(2, x2); - 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 - // derivative of partial of exp_eps(x, epsilon) w.r.t. x - dw.resize(2 * n); // space for first and second derivative - dw = f.Reverse(2, w); - check = 1.; // result should be second derivative - ok &= NearEqual(dw[0*2+1], check, 1e-10, 1e-10); +{ bool ok = true; + using CppAD::AD; + using CppAD::vector; // can use any simple vector template class + using CppAD::NearEqual; // checks if values are nearly equal + + // domain space vector + size_t n = 2; // dimension of the domain space + vector< AD > U(n); + U[0] = .5; // value of x for this operation sequence + U[1] = .2; // value of e for this operation sequence + + // declare independent variables and start recording operation sequence + CppAD::Independent(U); + + // evaluate our exponential approximation + AD x = U[0]; + AD epsilon = U[1]; + AD apx = exp_eps(x, epsilon); + + // range space vector + size_t m = 1; // dimension of the range space + vector< AD > Y(m); + 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 + // mode sweep using values in U for x and e. + CppAD::ADFun f(U, Y); + + // first order forward mode sweep that computes partial w.r.t x + vector du(n); // differential in domain space + vector dy(m); // differential in range space + du[0] = 1.; // x direction in domain space + du[1] = 0.; + dy = f.Forward(1, du); // partial w.r.t. x + double check = 1.5; + ok &= NearEqual(dy[0], check, 1e-10, 1e-10); + + // 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 + 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); + check = 0.; // partial w.r.t. epsilon + ok &= NearEqual(dw[1], check, 1e-10, 1e-10); + + // second order forward sweep that computes + // second partial of exp_eps(x, epsilon) w.r.t. x + vector x2(n); // second order Taylor coefficients + vector y2(m); + x2[0] = 0.; // evaluate partial w.r.t x + x2[1] = 0.; + y2 = f.Forward(2, x2); + 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 + // derivative of partial of exp_eps(x, epsilon) w.r.t. x + dw.resize(2 * n); // space for first and second derivative + dw = f.Reverse(2, w); + check = 1.; // result should be second derivative + ok &= NearEqual(dw[0*2+1], check, 1e-10, 1e-10); - return ok; + return ok; } /* %$$ $end diff -Nru cppad-2018.00.00.0/introduction/exp_eps_for0.cpp cppad-2019.02.00.0/introduction/exp_eps_for0.cpp --- cppad-2018.00.00.0/introduction/exp_eps_for0.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_eps_for0.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,60 +1,60 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_eps_for0.cpp$$ $spell - std - exp_eps_seq - cmath - bool - fabs + std + exp_eps_seq + cmath + bool + fabs $$ $section exp_eps: Verify Zero Order Forward Sweep$$ -$mindex exp_eps$$ $srccode%cpp% */ # include // for fabs function bool exp_eps_for0(double *v0) // double v0[8] -{ bool ok = true; - double x = .5; +{ bool ok = true; + double x = .5; - v0[1] = x; // abs_x = x; - ok &= std::fabs( v0[1] - 0.5) < 1e-10; + v0[1] = x; // abs_x = x; + ok &= std::fabs( v0[1] - 0.5) < 1e-10; - v0[2] = 1. * v0[1]; // temp = term * abs_x; - ok &= std::fabs( v0[2] - 0.5) < 1e-10; + v0[2] = 1. * v0[1]; // temp = term * abs_x; + ok &= std::fabs( v0[2] - 0.5) < 1e-10; - v0[3] = v0[2] / 1.; // term = temp / Type(k); - ok &= std::fabs( v0[3] - 0.5) < 1e-10; + v0[3] = v0[2] / 1.; // term = temp / Type(k); + ok &= std::fabs( v0[3] - 0.5) < 1e-10; - v0[4] = 1. + v0[3]; // sum = sum + term; - ok &= std::fabs( v0[4] - 1.5) < 1e-10; + v0[4] = 1. + v0[3]; // sum = sum + term; + ok &= std::fabs( v0[4] - 1.5) < 1e-10; - v0[5] = v0[3] * v0[1]; // temp = term * abs_x; - ok &= std::fabs( v0[5] - 0.25) < 1e-10; + v0[5] = v0[3] * v0[1]; // temp = term * abs_x; + ok &= std::fabs( v0[5] - 0.25) < 1e-10; - v0[6] = v0[5] / 2.; // term = temp / Type(k); - ok &= std::fabs( v0[6] - 0.125) < 1e-10; + v0[6] = v0[5] / 2.; // term = temp / Type(k); + ok &= std::fabs( v0[6] - 0.125) < 1e-10; - v0[7] = v0[4] + v0[6]; // sum = sum + term; - ok &= std::fabs( v0[7] - 1.625) < 1e-10; + v0[7] = v0[4] + v0[6]; // sum = sum + term; + ok &= std::fabs( v0[7] - 1.625) < 1e-10; - return ok; + return ok; } bool exp_eps_for0(void) -{ double v0[8]; - return exp_eps_for0(v0); +{ double v0[8]; + return exp_eps_for0(v0); } /* %$$ $end diff -Nru cppad-2018.00.00.0/introduction/exp_eps_for1.cpp cppad-2019.02.00.0/introduction/exp_eps_for1.cpp --- cppad-2018.00.00.0/introduction/exp_eps_for1.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_eps_for1.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,64 +1,64 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_eps_for1.cpp$$ $spell - std - vars - exp_eps_for - cmath - fabs - bool + std + vars + exp_eps_for + cmath + fabs + bool $$ $section exp_eps: Verify First Order Forward Sweep$$ -$mindex exp_2$$ $srccode%cpp% */ # include // for fabs function extern bool exp_eps_for0(double *v0); // computes zero order forward sweep bool exp_eps_for1(double *v1) // double v[8] -{ bool ok = true; - double v0[8]; +{ bool ok = true; + double v0[8]; - // set the value of v0[j] for j = 1 , ... , 7 - ok &= exp_eps_for0(v0); + // set the value of v0[j] for j = 1 , ... , 7 + ok &= exp_eps_for0(v0); - v1[1] = 1.; // v1 = x - ok &= std::fabs( v1[1] - 1. ) <= 1e-10; + v1[1] = 1.; // v1 = x + ok &= std::fabs( v1[1] - 1. ) <= 1e-10; - v1[2] = 1. * v1[1]; // v2 = 1 * v1 - ok &= std::fabs( v1[2] - 1. ) <= 1e-10; + v1[2] = 1. * v1[1]; // v2 = 1 * v1 + ok &= std::fabs( v1[2] - 1. ) <= 1e-10; - v1[3] = v1[2] / 1.; // v3 = v2 / 1 - ok &= std::fabs( v1[3] - 1. ) <= 1e-10; + v1[3] = v1[2] / 1.; // v3 = v2 / 1 + ok &= std::fabs( v1[3] - 1. ) <= 1e-10; - v1[4] = v1[3]; // v4 = 1 + v3 - ok &= std::fabs( v1[4] - 1. ) <= 1e-10; + v1[4] = v1[3]; // v4 = 1 + v3 + ok &= std::fabs( v1[4] - 1. ) <= 1e-10; - v1[5] = v1[3] * v0[1] + v0[3] * v1[1]; // v5 = v3 * v1 - ok &= std::fabs( v1[5] - 1. ) <= 1e-10; + v1[5] = v1[3] * v0[1] + v0[3] * v1[1]; // v5 = v3 * v1 + ok &= std::fabs( v1[5] - 1. ) <= 1e-10; - v1[6] = v1[5] / 2.; // v6 = v5 / 2 - ok &= std::fabs( v1[6] - 0.5 ) <= 1e-10; + v1[6] = v1[5] / 2.; // v6 = v5 / 2 + ok &= std::fabs( v1[6] - 0.5 ) <= 1e-10; - v1[7] = v1[4] + v1[6]; // v7 = v4 + v6 - ok &= std::fabs( v1[7] - 1.5 ) <= 1e-10; + v1[7] = v1[4] + v1[6]; // v7 = v4 + v6 + ok &= std::fabs( v1[7] - 1.5 ) <= 1e-10; - return ok; + return ok; } bool exp_eps_for1(void) -{ double v1[8]; - return exp_eps_for1(v1); +{ double v1[8]; + return exp_eps_for1(v1); } /* %$$ $end diff -Nru cppad-2018.00.00.0/introduction/exp_eps_for2.cpp cppad-2019.02.00.0/introduction/exp_eps_for2.cpp --- cppad-2018.00.00.0/introduction/exp_eps_for2.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_eps_for2.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,26 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_eps_for2.cpp$$ $spell - std - vars - exp_eps_for - cmath - fabs - bool + std + vars + exp_eps_for + cmath + fabs + bool $$ $section exp_eps: Verify Second Order Forward Sweep$$ -$mindex first exp_2$$ $srccode%cpp% */ @@ -28,36 +28,36 @@ extern bool exp_eps_for0(double *v0); // computes zero order forward sweep extern bool exp_eps_for1(double *v1); // computes first order forward sweep bool exp_eps_for2(void) -{ bool ok = true; - double v0[8], v1[8], v2[8]; +{ bool ok = true; + double v0[8], v1[8], v2[8]; - // set the value of v0[j], v1[j] for j = 1 , ... , 7 - ok &= exp_eps_for0(v0); - ok &= exp_eps_for1(v1); + // set the value of v0[j], v1[j] for j = 1 , ... , 7 + ok &= exp_eps_for0(v0); + ok &= exp_eps_for1(v1); - v2[1] = 0.; // v1 = x - ok &= std::fabs( v2[1] - 0. ) <= 1e-10; + v2[1] = 0.; // v1 = x + ok &= std::fabs( v2[1] - 0. ) <= 1e-10; - v2[2] = 1. * v2[1]; // v2 = 1 * v1 - ok &= std::fabs( v2[2] - 0. ) <= 1e-10; + v2[2] = 1. * v2[1]; // v2 = 1 * v1 + ok &= std::fabs( v2[2] - 0. ) <= 1e-10; - v2[3] = v2[2] / 1.; // v3 = v2 / 1 - ok &= std::fabs( v2[3] - 0. ) <= 1e-10; + v2[3] = v2[2] / 1.; // v3 = v2 / 1 + ok &= std::fabs( v2[3] - 0. ) <= 1e-10; - v2[4] = v2[3]; // v4 = 1 + v3 - ok &= std::fabs( v2[4] - 0. ) <= 1e-10; + v2[4] = v2[3]; // v4 = 1 + v3 + 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]; - ok &= std::fabs( v2[5] - 2. ) <= 1e-10; + v2[5] = v2[3] * v0[1] + 2. * v1[3] * v1[1] // v5 = v3 * v1 + + v0[3] * v2[1]; + ok &= std::fabs( v2[5] - 2. ) <= 1e-10; - v2[6] = v2[5] / 2.; // v6 = v5 / 2 - ok &= std::fabs( v2[6] - 1. ) <= 1e-10; + v2[6] = v2[5] / 2.; // v6 = v5 / 2 + ok &= std::fabs( v2[6] - 1. ) <= 1e-10; - v2[7] = v2[4] + v2[6]; // v7 = v4 + v6 - ok &= std::fabs( v2[7] - 1. ) <= 1e-10; + v2[7] = v2[4] + v2[6]; // v7 = v4 + v6 + ok &= std::fabs( v2[7] - 1. ) <= 1e-10; - return ok; + return ok; } /* %$$ $end diff -Nru cppad-2018.00.00.0/introduction/exp_eps.hpp cppad-2019.02.00.0/introduction/exp_eps.hpp --- cppad-2018.00.00.0/introduction/exp_eps.hpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_eps.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -3,27 +3,27 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_eps$$ $spell - cppad-%yyyymmdd% - hpp - Apx - cpp - const - exp_eps - bool + cppad-%yyyymmdd% + hpp + Apx + cpp + const + exp_eps + bool $$ $section An Epsilon Accurate Exponential Approximation$$ -$mindex exp_eps example algorithm$$ $head Syntax$$ @@ -42,13 +42,13 @@ $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 ) = - \min \{ k \in {\rm Z}_+ \; | \; \varepsilon \geq x^k / k ! \} + \min \{ k \in {\rm Z}_+ \; | \; \varepsilon \geq x^k / k ! \} \] $$ The mathematical form for our approximation of the exponential function is $latex \[ @@ -56,10 +56,10 @@ {\rm exp\_eps} (x , \varepsilon ) & = & \left\{ \begin{array}{ll} \frac{1}{ {\rm exp\_eps} (-x , \varepsilon ) } - & {\rm if} \; x < 0 + & {\rm if} \; x < 0 \\ 1 + x^1 / 1 ! + \cdots + x^{k( x, \varepsilon)} / k( x, \varepsilon ) ! - & {\rm otherwise} + & {\rm otherwise} \end{array} \right. \end{array} @@ -69,7 +69,7 @@ $head include$$ The include command in the syntax is relative to $codei% - cppad-%yyyymmdd%/introduction/exp_apx + cppad-%yyyymmdd%/introduction/exp_apx %$$ where $codei%cppad-%yyyymmdd%$$ is the distribution directory created during the beginning steps of the @@ -79,7 +79,7 @@ $head x$$ The argument $icode x$$ has prototype $codei% - const %Type% &%x% + const %Type% &%x% %$$ (see $icode Type$$ below). It specifies the point at which to evaluate the @@ -88,7 +88,7 @@ $head epsilon$$ The argument $icode epsilon$$ has prototype $codei% - const %Type% &%epsilon% + const %Type% &%epsilon% %$$ It specifies the accuracy with which to approximate the exponential function value; i.e., @@ -98,7 +98,7 @@ $head y$$ The result $icode y$$ has prototype $codei% - %Type% %y% + %Type% %y% %$$ It is the value of the exponential function approximation defined above. @@ -111,42 +111,42 @@ $bold Operation$$ $cnext $bold Result Type$$ $cnext $bold Description$$ $rnext $icode%Type%(%i%)%$$ - $cnext $icode Type$$ - $cnext object with value equal to $icode i$$ + $cnext $icode Type$$ + $cnext object with value equal to $icode i$$ $rnext $icode%Type u %=% v%$$ - $cnext $icode Type$$ - $cnext construct $icode u$$ with value equal to $icode v$$ + $cnext $icode Type$$ + $cnext construct $icode u$$ with value equal to $icode v$$ $rnext $icode%u% > %v%$$ - $cnext $code bool$$ - $cnext true, - if $icode u$$ greater than $icode v$$, an false otherwise + $cnext $code bool$$ + $cnext true, + if $icode u$$ greater than $icode v$$, an false otherwise $rnext $icode%u% = %v%$$ - $cnext $icode Type$$ - $cnext new $icode u$$ (and result) is value of $icode v$$ + $cnext $icode Type$$ + $cnext new $icode u$$ (and result) is value of $icode v$$ $rnext $icode%u% * %v%$$ - $cnext $icode Type$$ - $cnext result is value of $latex u * v$$ + $cnext $icode Type$$ + $cnext result is value of $latex u * v$$ $rnext $icode%u% / %v%$$ - $cnext $icode Type$$ - $cnext result is value of $latex u / v$$ + $cnext $icode Type$$ + $cnext result is value of $latex u / v$$ $rnext $icode%u% + %v%$$ - $cnext $icode Type$$ - $cnext result is value of $latex u + v$$ + $cnext $icode Type$$ + $cnext result is value of $latex u + v$$ $rnext $codei%-%u%$$ - $cnext $icode Type$$ - $cnext result is value of $latex - u$$ + $cnext $icode Type$$ + $cnext result is value of $latex - u$$ $tend $children% - introduction/exp_eps.omh% - introduction/exp_eps_cppad.cpp + introduction/exp_eps.omh% + introduction/exp_eps_cppad.cpp %$$ $head Implementation$$ @@ -156,7 +156,6 @@ $head Test$$ 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$$ @@ -166,9 +165,9 @@ $lnext Suppose that we make the following call to $code exp_eps$$: $codep - double x = 1.; - double epsilon = .01; - double y = exp_eps(x, epsilon); + double x = 1.; + double epsilon = .01; + double y = exp_eps(x, epsilon); $$ What is the value assigned to $code k$$, $code temp$$, $code term$$, and $code sum$$ @@ -187,24 +186,24 @@ // BEGIN C++ template Type exp_eps(const Type &x, const Type &epsilon) -{ // abs_x = |x| - Type abs_x = x; - if( Type(0) > x ) - abs_x = - x; - // initialize - int k = 0; // initial order - Type term = 1.; // term = |x|^k / k ! - Type sum = term; // initial sum - while(term > epsilon) - { k = k + 1; // order for next term - Type temp = term * abs_x; // term = |x|^k / (k-1)! - term = temp / Type(k); // term = |x|^k / k ! - 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 ) - sum = Type(1) / sum; - return sum; +{ // abs_x = |x| + Type abs_x = x; + if( Type(0) > x ) + abs_x = - x; + // initialize + int k = 0; // initial order + Type term = 1.; // term = |x|^k / k ! + Type sum = term; // initial sum + while(term > epsilon) + { k = k + 1; // order for next term + Type temp = term * abs_x; // term = |x|^k / (k-1)! + term = temp / Type(k); // term = |x|^k / k ! + 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 ) + sum = Type(1) / sum; + return sum; } // END C++ diff -Nru cppad-2018.00.00.0/introduction/exp_eps.omh cppad-2019.02.00.0/introduction/exp_eps.omh --- cppad-2018.00.00.0/introduction/exp_eps.omh 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_eps.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,49 +1,44 @@ ---------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ----------------------------------------------------------------------------- $begin exp_eps.hpp$$ $spell - exp_eps + exp_eps $$ $section exp_eps: Implementation$$ -$mindex exp_eps$$ -$code $srcfile%introduction/exp_eps.hpp%0%// BEGIN C++%// END C++%$$ -$$ $end ----------------------------------------------------------------------------- $begin exp_eps.cpp$$ $spell - exp_eps + exp_eps $$ $section exp_eps: Test of exp_eps$$ -$code $srcfile%introduction/exp_eps.cpp%0%// BEGIN C++%// END C++%$$ -$$ $end ----------------------------------------------------------------------------- $begin exp_eps_for0$$ $spell - cpp - exp_eps_seq - bool + cpp + exp_eps_seq + bool $$ $section exp_eps: Operation Sequence and Zero Order Forward Sweep$$ -$mindex example$$ @@ -56,7 +51,7 @@ 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 @@ -108,53 +103,53 @@ $center $table $bold Index$$ - $cnext $pre $$ $cnext $bold Code$$ - $cnext $pre $$ $cnext $bold Operation$$ - $cnext $pre $$ $cnext $bold Zero Order$$ + $cnext $pre $$ $cnext $bold Code$$ + $cnext $pre $$ $cnext $bold Operation$$ + $cnext $pre $$ $cnext $bold Zero Order$$ $rnext 1 - $cnext $pre $$ $cnext $code abs_x = x;$$ - $cnext $cnext $latex v_1 = x $$ - $cnext $cnext $latex v_1^{(0)} = 0.5$$ + $cnext $pre $$ $cnext $code abs_x = x;$$ + $cnext $cnext $latex v_1 = x $$ + $cnext $cnext $latex v_1^{(0)} = 0.5$$ $rnext 2 - $cnext $pre $$ $cnext $code temp = term * abs_x;$$ - $cnext $cnext $latex v_2 = 1 * v_1 $$ - $cnext $cnext $latex v_2^{(0)} = 0.5$$ + $cnext $pre $$ $cnext $code temp = term * abs_x;$$ + $cnext $cnext $latex v_2 = 1 * v_1 $$ + $cnext $cnext $latex v_2^{(0)} = 0.5$$ $rnext 3 - $cnext $pre $$ $cnext $code term = temp / Type(k);$$ - $cnext $cnext $latex v_3 = v_2 / 1$$ - $cnext $cnext $latex v_3^{(0)} = 0.5$$ + $cnext $pre $$ $cnext $code term = temp / Type(k);$$ + $cnext $cnext $latex v_3 = v_2 / 1$$ + $cnext $cnext $latex v_3^{(0)} = 0.5$$ $rnext 4 - $cnext $pre $$ $cnext $code sum = sum + term;$$ - $cnext $cnext $latex v_4 = 1 + v_3 $$ - $cnext $cnext $latex v_4^{(0)} = 1.5$$ + $cnext $pre $$ $cnext $code sum = sum + term;$$ + $cnext $cnext $latex v_4 = 1 + v_3 $$ + $cnext $cnext $latex v_4^{(0)} = 1.5$$ $rnext 5 - $cnext $pre $$ $cnext $code temp = term * abs_x;$$ - $cnext $cnext $latex v_5 = v_3 * v_1 $$ - $cnext $cnext $latex v_5^{(0)} = 0.25$$ + $cnext $pre $$ $cnext $code temp = term * abs_x;$$ + $cnext $cnext $latex v_5 = v_3 * v_1 $$ + $cnext $cnext $latex v_5^{(0)} = 0.25$$ $rnext 6 - $cnext $pre $$ $cnext $code term = temp / Type(k);$$ - $cnext $cnext $latex v_6 = v_5 / 2$$ - $cnext $cnext $latex v_6^{(0)} = 0.125$$ + $cnext $pre $$ $cnext $code term = temp / Type(k);$$ + $cnext $cnext $latex v_6 = v_5 / 2$$ + $cnext $cnext $latex v_6^{(0)} = 0.125$$ $rnext 7 - $cnext $pre $$ $cnext $code sum = sum + term;$$ - $cnext $cnext $latex v_7 = v_4 + v_6 $$ - $cnext $cnext $latex v_7^{(0)} = 1.625$$ + $cnext $pre $$ $cnext $code sum = sum + term;$$ + $cnext $cnext $latex v_7 = v_4 + v_6 $$ + $cnext $cnext $latex v_7^{(0)} = 1.625$$ $tend $$ $head Return Value$$ The return value for this case is $latex \[ - 1.625 = - v_7^{(0)} = - f ( x^{(0)} , \varepsilon^{(0)} ) + 1.625 = + v_7^{(0)} = + f ( x^{(0)} , \varepsilon^{(0)} ) \] $$ $head Comparisons$$ @@ -162,8 +157,8 @@ 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 ) - while(term > epsilon) + 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 @@ -174,13 +169,12 @@ same result and hence the operation sequence would be the same. $children% - introduction/exp_eps_for0.cpp + introduction/exp_eps_for0.cpp %$$ $head Verification$$ 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$$ @@ -203,7 +197,7 @@ ----------------------------------------------------------------------------- $begin exp_eps_for1$$ $spell - exp_eps_for + exp_eps_for $$ $section exp_eps: First Order Forward Sweep$$ @@ -215,9 +209,9 @@ by the first order expansions $latex \[ \begin{array}{rcl} - x(t) & = & x^{(0)} + x^{(1)} * t - \\ - \varepsilon(t) & = & \varepsilon^{(0)} + \varepsilon^{(1)} * t + x(t) & = & x^{(0)} + x^{(1)} * t + \\ + \varepsilon(t) & = & \varepsilon^{(0)} + \varepsilon^{(1)} * t \end{array} \]$$ It follows that $latex x^{(0)}$$ ($latex \varepsilon^{(0)}$$) is the zero, @@ -269,7 +263,7 @@ The First Order column contains the first order derivatives for the corresponding variable in the operation sequence; i.e., $latex \[ - v_j (t) = v_j^{(0)} + v_j^{(1)} t + v_j (t) = v_j^{(0)} + v_j^{(1)} t \] $$ We use $latex x^{(1)} = 1$$ and $latex \varepsilon^{(1)} = 0$$, so that differentiation with respect to $latex t$$, @@ -283,59 +277,59 @@ $center $table $bold Index$$ - $cnext $pre $$ $cnext $bold Operation$$ - $cnext $pre $$ $cnext $bold Zero Order$$ - $cnext $pre $$ $cnext $bold Derivative$$ - $cnext $pre $$ $cnext $bold First Order$$ + $cnext $pre $$ $cnext $bold Operation$$ + $cnext $pre $$ $cnext $bold Zero Order$$ + $cnext $pre $$ $cnext $bold Derivative$$ + $cnext $pre $$ $cnext $bold First Order$$ $rnext 1 - $cnext $pre $$ $cnext $latex v_1 = x $$ - $cnext $cnext 0.5 - $cnext $cnext - $latex v_1^{(1)} = x^{(1)} $$ - $cnext $cnext $latex v_1^{(1)} = 1$$ + $cnext $pre $$ $cnext $latex v_1 = x $$ + $cnext $cnext 0.5 + $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 - $latex v_2^{(1)} = 1 * v_1^{(1)}$$ - $cnext $cnext $latex v_2^{(1)} = 1$$ + $cnext $pre $$ $cnext $latex v_2 = 1 * v_1$$ + $cnext $cnext 0.5 + $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 - $latex v_3^{(1)} = v_2^{(1)} / 1$$ - $cnext $cnext $latex v_3^{(1)} = 1$$ + $cnext $pre $$ $cnext $latex v_3 = v_2 / 1$$ + $cnext $cnext 0.5 + $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 - $latex v_4^{(1)} = v_3^{(1)} $$ - $cnext $cnext $latex v_4^{(1)} = 1$$ + $cnext $pre $$ $cnext $latex v_4 = 1 + v_3$$ + $cnext $cnext 1.5 + $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 - $latex v_5^{(1)} = v_3^{(1)} * v_1^{(0)} + v_3^{(0)} * v_1^{(1)}$$ - $cnext $cnext $latex v_5^{(1)} = 1$$ + $cnext $pre $$ $cnext $latex v_5 = v_3 * v_1$$ + $cnext $cnext 0.25 + $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 - $latex v_6^{(1)} = v_5^{(1)} / 2$$ - $cnext $cnext $latex v_6^{(1)} = 0.5$$ + $cnext $pre $$ $cnext $latex v_6 = v_5 / 2$$ + $cnext $cnext 0.125 + $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 - $latex v_7^{(1)} = v_4^{(1)} + v_6^{(1)}$$ - $cnext $cnext $latex v_7^{(1)} = 1.5$$ + $cnext $pre $$ $cnext $latex v_7 = v_4 + v_6$$ + $cnext $cnext 1.625 + $cnext $cnext + $latex v_7^{(1)} = v_4^{(1)} + v_6^{(1)}$$ + $cnext $cnext $latex v_7^{(1)} = 1.5$$ $tend $$ @@ -358,13 +352,12 @@ $latex x^{(1)} = 1$$ and $latex \varepsilon^{(1)} = 0$$.) $children% - introduction/exp_eps_for1.cpp + introduction/exp_eps_for1.cpp %$$ $head Verification$$ 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$$ @@ -384,7 +377,7 @@ Suppose that $latex x = .1$$ and $latex \epsilon = .2$$, what is the operation sequence corresponding to $codei% - exp_eps(%x%, %epsilon%) + exp_eps(%x%, %epsilon%) %$$ $lend @@ -392,11 +385,10 @@ ----------------------------------------------------------------------------- $begin exp_eps_rev1$$ $spell - exp_eps_rev + exp_eps_rev $$ $section exp_eps: First Order Reverse Sweep$$ -$mindex mode$$ @@ -456,7 +448,7 @@ $head Index 7: f_6$$ The last operation has index 7, $latex \[ - v_7 = v_4 + v_6 + v_7 = v_4 + v_6 \] $$ We define the function $latex f_6 ( v_1 , v_2 , v_3 , v_4 , v_5 , v_6 ) $$ @@ -472,12 +464,12 @@ \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_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_7}{v_7} * \D{v_7}{v_6} & = 1 \end{array} \] $$ @@ -486,7 +478,7 @@ $head Index 6: f_5$$ The previous operation has index 6, $latex \[ - v_6 = v_5 / 2 + v_6 = v_5 / 2 \] $$ We define the function $latex f_5 ( v_1 , v_2 , v_3 , v_4 , v_5 ) $$ @@ -505,7 +497,7 @@ \\ \D{f_5}{v_5} & = & \D{f_6}{v_5} + - \D{f_6}{v_6} * \D{v_6}{v_5} + \D{f_6}{v_6} * \D{v_6}{v_5} & = 0.5 \end{array} \] $$ @@ -514,7 +506,7 @@ $head Index 5: f_4$$ The previous operation has index 5, $latex \[ - v_5 = v_3 * v_1 + v_5 = v_3 * v_1 \] $$ We define the function $latex f_4 ( v_1 , v_2 , v_3 , v_4 ) $$ @@ -531,14 +523,14 @@ \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_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_5}{v_5} * \D{v_5}{v_3} & = 0.25 \\ \D{f_4}{v_4} @@ -550,7 +542,7 @@ $head Index 4: f_3$$ The previous operation has index 4, $latex \[ - v_4 = 1 + v_3 + v_4 = 1 + v_3 \] $$ We define the function $latex f_3 ( v_1 , v_2 , v_3 ) $$ @@ -571,7 +563,7 @@ \\ \D{f_3}{v_3} & = & \D{f_4}{v_3} + - \D{f_4}{v_4} * \D{v_4}{v_3} + \D{f_4}{v_4} * \D{v_4}{v_3} & = 1.25 \end{array} \] $$ @@ -580,7 +572,7 @@ $head Index 3: f_2$$ The previous operation has index 3, $latex \[ - v_3 = v_2 / 1 + v_3 = v_2 / 1 \] $$ We define the function $latex f_2 ( v_1 , v_2 ) $$ @@ -598,7 +590,7 @@ & = 0.25 \\ \D{f_2}{v_2} & = & \D{f_3}{v_2} + - \D{f_3}{v_3} * \D{v_3}{v_2} + \D{f_3}{v_3} * \D{v_3}{v_2} & = 1.25 \end{array} \] $$ @@ -606,7 +598,7 @@ $head Index 2: f_1$$ The previous operation has index 1, $latex \[ - v_2 = 1 * v_1 + v_2 = 1 * v_1 \] $$ We define the function $latex f_1 ( v_1 ) $$ @@ -620,7 +612,7 @@ $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} \] $$ @@ -635,13 +627,12 @@ $children% - introduction/exp_eps_rev1.cpp + introduction/exp_eps_rev1.cpp %$$ $head Verification$$ 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 $latex f_j$$ that might not be equal to the corresponding partials of $latex f_{j+1}$$; i.e., the @@ -671,7 +662,7 @@ ----------------------------------------------------------------------------- $begin exp_eps_for2$$ $spell - exp_eps_for + exp_eps_for $$ $section exp_eps: Second Order Forward Mode$$ @@ -684,18 +675,18 @@ by the second order expansions $latex \[ \begin{array}{rcl} - x(t) & = & x^{(0)} + x^{(1)} * t + x^{(2)} * t^2 / 2 - \\ - \varepsilon(t) & = & \varepsilon^{(0)} + \varepsilon^{(1)} * t - + \varepsilon^{(2)} * t^2 / 2 + x(t) & = & x^{(0)} + x^{(1)} * t + x^{(2)} * t^2 / 2 + \\ + \varepsilon(t) & = & \varepsilon^{(0)} + \varepsilon^{(1)} * t + + \varepsilon^{(2)} * t^2 / 2 \end{array} \]$$ It follows that for $latex k = 0 , 1 , 2$$, $latex \[ \begin{array}{rcl} - x^{(k)} & = & \dpow{k}{t} x (0) - \\ - \varepsilon^{(k)} & = & \dpow{k}{t} \varepsilon (0) + x^{(k)} & = & \dpow{k}{t} x (0) + \\ + \varepsilon^{(k)} & = & \dpow{k}{t} \varepsilon (0) \end{array} \] $$ @@ -757,7 +748,7 @@ for the corresponding variable in the operation sequence; i.e., the second order expansion for the $th i$$ variable is given by $latex \[ - v_i (t) = v_i^{(0)} + v_i^{(1)} * t + v_i^{(2)} * t^2 / 2 + v_i (t) = v_i^{(0)} + v_i^{(1)} * t + v_i^{(2)} * t^2 / 2 \] $$ We use $latex x^{(1)} = 1$$, $latex x^{(2)} = 0$$, use $latex \varepsilon^{(1)} = 1$$, and $latex \varepsilon^{(2)} = 0$$ @@ -772,75 +763,75 @@ $center $table $bold Index$$ - $cnext $pre $$ $cnext $bold Zero$$ - $cnext $pre $$ $cnext $bold Operation$$ - $cnext $pre $$ $cnext $bold First$$ - $cnext $pre $$ $cnext $bold Derivative$$ - $cnext $pre $$ $cnext $bold Second$$ + $cnext $pre $$ $cnext $bold Zero$$ + $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 - $latex v_1^{(1)} = x^{(1)} $$ - $cnext $cnext 1 - $cnext $cnext - $latex v_2^{(2)} = x^{(2)} $$ - $cnext $cnext 0 + $cnext $cnext 0.5 + $cnext $cnext + $latex v_1^{(1)} = x^{(1)} $$ + $cnext $cnext 1 + $cnext $cnext + $latex v_2^{(2)} = x^{(2)} $$ + $cnext $cnext 0 $rnext 2 - $cnext $cnext 0.5 - $cnext $cnext - $latex v_2^{(1)} = 1 * v_1^{(1)}$$ - $cnext $cnext 1 - $cnext $cnext - $latex v_2^{(2)} = 1 * v_1^{(2)}$$ - $cnext $cnext 0 + $cnext $cnext 0.5 + $cnext $cnext + $latex v_2^{(1)} = 1 * v_1^{(1)}$$ + $cnext $cnext 1 + $cnext $cnext + $latex v_2^{(2)} = 1 * v_1^{(2)}$$ + $cnext $cnext 0 $rnext 3 - $cnext $cnext 0.5 - $cnext $cnext - $latex v_3^{(1)} = v_2^{(1)} / 1$$ - $cnext $cnext 1 - $cnext $cnext - $latex v_3^{(2)} = v_2^{(2)} / 1$$ - $cnext $cnext 0 + $cnext $cnext 0.5 + $cnext $cnext + $latex v_3^{(1)} = v_2^{(1)} / 1$$ + $cnext $cnext 1 + $cnext $cnext + $latex v_3^{(2)} = v_2^{(2)} / 1$$ + $cnext $cnext 0 $rnext 4 - $cnext $cnext 1.5 - $cnext $cnext - $latex v_4^{(1)} = v_3^{(1)} $$ - $cnext $cnext 1 - $cnext $cnext - $latex v_4^{(2)} = v_3^{(2)} $$ - $cnext $cnext 0 + $cnext $cnext 1.5 + $cnext $cnext + $latex v_4^{(1)} = v_3^{(1)} $$ + $cnext $cnext 1 + $cnext $cnext + $latex v_4^{(2)} = v_3^{(2)} $$ + $cnext $cnext 0 $rnext 5 - $cnext $cnext 0.25 - $cnext $cnext - $latex v_5^{(1)} = v_3^{(1)} * v_1^{(0)} + v_3^{(0)} * v_1^{(1)}$$ - $cnext $cnext 1 - $cnext $cnext - $latex v_5^{(2)} = v_3^{(2)} * v_1^{(0)} + 2 * v_3^{(1)} * v_1^{(1)} - + v_3^{(0)} * v_1^{(2)}$$ - $cnext $cnext 2 + $cnext $cnext 0.25 + $cnext $cnext + $latex v_5^{(1)} = v_3^{(1)} * v_1^{(0)} + v_3^{(0)} * v_1^{(1)}$$ + $cnext $cnext 1 + $cnext $cnext + $latex v_5^{(2)} = v_3^{(2)} * v_1^{(0)} + 2 * v_3^{(1)} * v_1^{(1)} + + v_3^{(0)} * v_1^{(2)}$$ + $cnext $cnext 2 $rnext 6 - $cnext $cnext 0.125 - $cnext $cnext - $latex v_6^{(1)} = v_5^{(1)} / 2$$ - $cnext $cnext 0.5 - $cnext $cnext - $latex v_6^{(2)} = v_5^{(2)} / 2$$ - $cnext $cnext 1 + $cnext $cnext 0.125 + $cnext $cnext + $latex v_6^{(1)} = v_5^{(1)} / 2$$ + $cnext $cnext 0.5 + $cnext $cnext + $latex v_6^{(2)} = v_5^{(2)} / 2$$ + $cnext $cnext 1 $rnext 7 - $cnext $cnext 1.625 - $cnext $cnext - $latex v_7^{(1)} = v_4^{(1)} + v_6^{(1)}$$ - $cnext $cnext 1.5 - $cnext $cnext - $latex v_7^{(2)} = v_4^{(2)} + v_6^{(2)}$$ - $cnext $cnext 1 + $cnext $cnext 1.625 + $cnext $cnext + $latex v_7^{(1)} = v_4^{(1)} + v_6^{(1)}$$ + $cnext $cnext 1.5 + $cnext $cnext + $latex v_7^{(2)} = v_4^{(2)} + v_6^{(2)}$$ + $cnext $cnext 1 $tend $$ @@ -864,12 +855,11 @@ $latex \varepsilon^{(1)} = 1$$, and $latex \varepsilon^{(2)} = 0$$.) $children% - introduction/exp_eps_for2.cpp + introduction/exp_eps_for2.cpp %$$ $head Verification$$ 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$$ @@ -894,7 +884,7 @@ ----------------------------------------------------------------------------- $begin exp_eps_rev2$$ $spell - exp_eps_rev + exp_eps_rev $$ $section exp_eps: Second Order Reverse Sweep$$ @@ -948,7 +938,7 @@ $latex \[ \begin{array}{rcl} f_7 \left( - v_1^{(0)} , v_1^{(1)} , \ldots , v_7^{(0)} , v_7^{(1)} + v_1^{(0)} , v_1^{(1)} , \ldots , v_7^{(0)} , v_7^{(1)} \right) & = & v_7^{(1)} \\ @@ -961,9 +951,9 @@ The last operation has index 7, $latex \[ \begin{array}{rcl} - v_7^{(0)} & = & v_4^{(0)} + v_6^{(0)} - \\ - v_7^{(1)} & = & v_4^{(1)} + v_6^{(1)} + v_7^{(0)} & = & v_4^{(0)} + v_6^{(0)} + \\ + v_7^{(1)} & = & v_4^{(1)} + v_6^{(1)} \end{array} \] $$ We define the function @@ -974,8 +964,8 @@ $latex \[ 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^{(0)} \left( v_4^{(0)} , v_6^{(0)} \right) , + v_7^{(1)} \left( v_4^{(1)} , v_6^{(1)} \right) \right] \] $$ It follows that @@ -983,12 +973,12 @@ \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_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_7}{v_7^{(1)}} * \D{v_7^{(1)}}{v_6^{(1)}} & = 1 \end{array} \] $$ @@ -998,9 +988,9 @@ The previous operation has index 6, $latex \[ \begin{array}{rcl} - v_6^{(0)} & = & v_5^{(0)} / 2 - \\ - v_6^{(1)} & = & v_5^{(1)} / 2 + v_6^{(0)} & = & v_5^{(0)} / 2 + \\ + v_6^{(1)} & = & v_5^{(1)} / 2 \end{array} \] $$ We define the function @@ -1011,8 +1001,8 @@ $latex \[ 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^{(0)} \left( v_5^{(0)} \right) , + v_6^{(1)} \left( v_5^{(1)} \right) \right] \] $$ It follows that @@ -1024,7 +1014,7 @@ \\ \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_6}{v_6^{(1)}} * \D{v_6^{(1)}}{v_5^{(1)}} & = 0.5 \end{array} \] $$ @@ -1034,9 +1024,9 @@ The previous operation has index 5, $latex \[ \begin{array}{rcl} - v_5^{(0)} & = & v_3^{(0)} * v_1^{(0)} - \\ - v_5^{(1)} & = & v_3^{(1)} * v_1^{(0)} + v_3^{(0)} * v_1^{(1)} + v_5^{(0)} & = & v_3^{(0)} * v_1^{(0)} + \\ + v_5^{(1)} & = & v_3^{(1)} * v_1^{(0)} + v_3^{(0)} * v_1^{(1)} \end{array} \] $$ We define the function @@ -1047,8 +1037,8 @@ $latex \[ 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) , + 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) , \right] \] $$ Given the information from the forward sweep, we have @@ -1091,9 +1081,9 @@ The previous operation has index 4, $latex \[ \begin{array}{rcl} - v_4^{(0)} = 1 + v_3^{(0)} - \\ - v_4^{(1)} = v_3^{(1)} + v_4^{(0)} = 1 + v_3^{(0)} + \\ + v_4^{(1)} = v_3^{(1)} \end{array} \] $$ We define the function @@ -1104,8 +1094,8 @@ $latex \[ 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^{(0)} \left( v_3^{(0)} \right) , + v_4^{(1)} \left( v_3^{(1)} \right) \right] \] $$ It follows that @@ -1144,9 +1134,9 @@ The previous operation has index 3, $latex \[ \begin{array}{rcl} - v_3^{(0)} & = & v_2^{(0)} / 1 - \\ - v_3^{(1)} & = & v_2^{(1)} / 1 + v_3^{(0)} & = & v_2^{(0)} / 1 + \\ + v_3^{(1)} & = & v_2^{(1)} / 1 \end{array} \] $$ We define the function @@ -1157,8 +1147,8 @@ $latex \[ 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) + v_3^{(0)} \left( v_2^{(0)} \right) , + v_3^{(1)} \left( v_2^{(1)} \right) \right] \] $$ It follows that @@ -1188,9 +1178,9 @@ The previous operation has index 1, $latex \[ \begin{array}{rcl} - v_2^{(0)} & = & 1 * v_1^{(0)} - \\ - v_2^{(1)} & = & 1 * v_1^{(1)} + v_2^{(0)} & = & 1 * v_1^{(0)} + \\ + v_2^{(1)} & = & 1 * v_1^{(1)} \end{array} \] $$ We define the function @@ -1201,8 +1191,8 @@ $latex \[ 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^{(0)} \left( v_1^{(0)} \right) , + v_2^{(1)} \left( v_1^{(1)} \right) \right] \] $$ It follows that @@ -1236,13 +1226,12 @@ $children% - introduction/exp_eps_rev2.cpp + introduction/exp_eps_rev2.cpp %$$ $head Verification$$ 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 $latex f_j$$ that might not be equal to the corresponding partials of $latex f_{j+1}$$; i.e., the diff -Nru cppad-2018.00.00.0/introduction/exp_eps_rev1.cpp cppad-2019.02.00.0/introduction/exp_eps_rev1.cpp --- cppad-2018.00.00.0/introduction/exp_eps_rev1.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_eps_rev1.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,32 +1,32 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_eps_rev1.cpp$$ $spell - cstddef - cmath - vars - ir - iq - ir - ia - df - exp_eps_rev - bool - std - fabs + cstddef + cmath + vars + ir + iq + ir + ia + df + exp_eps_rev + bool + std + fabs $$ $section exp_eps: Verify First Order Reverse Sweep$$ -$mindex exp_eps$$ $srccode%cpp% */ @@ -34,51 +34,51 @@ # include // for fabs function extern bool exp_eps_for0(double *v0); // computes zero order forward sweep bool exp_eps_rev1(void) -{ bool ok = true; +{ bool ok = true; - // set the value of v0[j] for j = 1 , ... , 7 - double v0[8]; - ok &= exp_eps_for0(v0); - - // initial all partial derivatives as zero - double f_v[8]; - size_t j; - for(j = 0; j < 8; j++) - f_v[j] = 0.; - - // set partial derivative for f7 - f_v[7] = 1.; - ok &= std::fabs( f_v[7] - 1. ) <= 1e-10; // f7_v7 - - // f6( v1 , v2 , v3 , v4 , v5 , v6 ) - f_v[4] += f_v[7] * 1.; - f_v[6] += f_v[7] * 1.; - ok &= std::fabs( f_v[4] - 1. ) <= 1e-10; // f6_v4 - ok &= std::fabs( f_v[6] - 1. ) <= 1e-10; // f6_v6 - - // f5( v1 , v2 , v3 , v4 , v5 ) - f_v[5] += f_v[6] / 2.; - ok &= std::fabs( f_v[5] - 0.5 ) <= 1e-10; // f5_v5 - - // f4( v1 , v2 , v3 , v4 ) - f_v[1] += f_v[5] * v0[3]; - f_v[3] += f_v[5] * v0[1]; - ok &= std::fabs( f_v[1] - 0.25) <= 1e-10; // f4_v1 - ok &= std::fabs( f_v[3] - 0.25) <= 1e-10; // f4_v3 - - // f3( v1 , v2 , v3 ) - f_v[3] += f_v[4] * 1.; - ok &= std::fabs( f_v[3] - 1.25) <= 1e-10; // f3_v3 - - // f2( v1 , v2 ) - f_v[2] += f_v[3] / 1.; - ok &= std::fabs( f_v[2] - 1.25) <= 1e-10; // f2_v2 - - // f1( v1 ) - f_v[1] += f_v[2] * 1.; - ok &= std::fabs( f_v[1] - 1.5 ) <= 1e-10; // f1_v2 + // set the value of v0[j] for j = 1 , ... , 7 + double v0[8]; + ok &= exp_eps_for0(v0); + + // initial all partial derivatives as zero + double f_v[8]; + size_t j; + for(j = 0; j < 8; j++) + f_v[j] = 0.; + + // set partial derivative for f7 + f_v[7] = 1.; + ok &= std::fabs( f_v[7] - 1. ) <= 1e-10; // f7_v7 + + // f6( v1 , v2 , v3 , v4 , v5 , v6 ) + f_v[4] += f_v[7] * 1.; + f_v[6] += f_v[7] * 1.; + ok &= std::fabs( f_v[4] - 1. ) <= 1e-10; // f6_v4 + ok &= std::fabs( f_v[6] - 1. ) <= 1e-10; // f6_v6 + + // f5( v1 , v2 , v3 , v4 , v5 ) + f_v[5] += f_v[6] / 2.; + ok &= std::fabs( f_v[5] - 0.5 ) <= 1e-10; // f5_v5 + + // f4( v1 , v2 , v3 , v4 ) + f_v[1] += f_v[5] * v0[3]; + f_v[3] += f_v[5] * v0[1]; + ok &= std::fabs( f_v[1] - 0.25) <= 1e-10; // f4_v1 + ok &= std::fabs( f_v[3] - 0.25) <= 1e-10; // f4_v3 + + // f3( v1 , v2 , v3 ) + f_v[3] += f_v[4] * 1.; + ok &= std::fabs( f_v[3] - 1.25) <= 1e-10; // f3_v3 + + // f2( v1 , v2 ) + f_v[2] += f_v[3] / 1.; + ok &= std::fabs( f_v[2] - 1.25) <= 1e-10; // f2_v2 + + // f1( v1 ) + f_v[1] += f_v[2] * 1.; + ok &= std::fabs( f_v[1] - 1.5 ) <= 1e-10; // f1_v2 - return ok; + return ok; } /* %$$ $end diff -Nru cppad-2018.00.00.0/introduction/exp_eps_rev2.cpp cppad-2019.02.00.0/introduction/exp_eps_rev2.cpp --- cppad-2018.00.00.0/introduction/exp_eps_rev2.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/exp_eps_rev2.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,32 +1,32 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_eps_rev2.cpp$$ $spell - cstddef - cmath - vars - ir - iq - ir - ia - df - exp_eps_rev - bool - std - fabs + cstddef + cmath + vars + ir + iq + ir + ia + df + exp_eps_rev + bool + std + fabs $$ $section exp_eps: Verify Second Order Reverse Sweep$$ -$mindex exp_eps$$ $srccode%cpp% */ @@ -35,71 +35,71 @@ extern bool exp_eps_for0(double *v0); // computes zero order forward sweep extern bool exp_eps_for1(double *v1); // computes first order forward sweep bool exp_eps_rev2(void) -{ bool ok = true; +{ bool ok = true; - // set the value of v0[j], v1[j] for j = 1 , ... , 7 - double v0[8], v1[8]; - ok &= exp_eps_for0(v0); - ok &= exp_eps_for1(v1); - - // initial all partial derivatives as zero - double f_v0[8], f_v1[8]; - size_t j; - for(j = 0; j < 8; j++) - { f_v0[j] = 0.; - f_v1[j] = 0.; - } - - // set partial derivative for f_7 - f_v1[7] = 1.; - ok &= std::fabs( f_v1[7] - 1. ) <= 1e-10; // partial f_7 w.r.t. v_7^1 - - // f_6 = f_7( v_1^0 , ... , v_6^1 , v_4^0 + v_6^0, v_4^1 , v_6^1 ) - f_v0[4] += f_v0[7]; - f_v0[6] += f_v0[7]; - f_v1[4] += f_v1[7]; - f_v1[6] += f_v1[7]; - ok &= std::fabs( f_v0[4] - 0. ) <= 1e-10; // partial f_6 w.r.t. v_4^0 - ok &= std::fabs( f_v0[6] - 0. ) <= 1e-10; // partial f_6 w.r.t. v_6^0 - ok &= std::fabs( f_v1[4] - 1. ) <= 1e-10; // partial f_6 w.r.t. v_4^1 - ok &= std::fabs( f_v1[6] - 1. ) <= 1e-10; // partial f_6 w.r.t. v_6^1 - - // f_5 = f_6( v_1^0 , ... , v_5^1 , v_5^0 / 2 , v_5^1 / 2 ) - f_v0[5] += f_v0[6] / 2.; - f_v1[5] += f_v1[6] / 2.; - 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 , - // 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]; - f_v1[1] += f_v1[5] * v0[3]; - f_v1[3] += f_v1[5] * v0[1]; - ok &= std::fabs( f_v0[1] - 0.5 ) <= 1e-10; // partial f_4 w.r.t. v_1^0 - ok &= std::fabs( f_v0[3] - 0.5 ) <= 1e-10; // partial f_4 w.r.t. v_3^0 - ok &= std::fabs( f_v1[1] - 0.25 ) <= 1e-10; // partial f_4 w.r.t. v_1^1 - ok &= std::fabs( f_v1[3] - 0.25 ) <= 1e-10; // partial f_4 w.r.t. v_3^1 - - // f_3 = f_4( v_1^0 , ... , v_3^1 , 1 + v_3^0 , v_3^1 ) - f_v0[3] += f_v0[4]; - f_v1[3] += f_v1[4]; - ok &= std::fabs( f_v0[3] - 0.5 ) <= 1e-10; // partial f_3 w.r.t. v_3^0 - ok &= std::fabs( f_v1[3] - 1.25) <= 1e-10; // partial f_3 w.r.t. v_3^1 - - // f_2 = f_3( v_1^0 , ... , v_2^1 , v_2^0 , v_2^1 ) - f_v0[2] += f_v0[3]; - f_v1[2] += f_v1[3]; - ok &= std::fabs( f_v0[2] - 0.5 ) <= 1e-10; // partial f_2 w.r.t. v_2^0 - ok &= std::fabs( f_v1[2] - 1.25) <= 1e-10; // partial f_2 w.r.t. v_2^1 - - // f_1 = f_2 ( v_1^0 , v_2^0 , v_1^0 , v_2^0 ) - f_v0[1] += f_v0[2]; - f_v1[1] += f_v1[2]; - ok &= std::fabs( f_v0[1] - 1. ) <= 1e-10; // partial f_1 w.r.t. v_1^0 - ok &= std::fabs( f_v1[1] - 1.5 ) <= 1e-10; // partial f_1 w.r.t. v_1^1 + // set the value of v0[j], v1[j] for j = 1 , ... , 7 + double v0[8], v1[8]; + ok &= exp_eps_for0(v0); + ok &= exp_eps_for1(v1); + + // initial all partial derivatives as zero + double f_v0[8], f_v1[8]; + size_t j; + for(j = 0; j < 8; j++) + { f_v0[j] = 0.; + f_v1[j] = 0.; + } + + // set partial derivative for f_7 + f_v1[7] = 1.; + ok &= std::fabs( f_v1[7] - 1. ) <= 1e-10; // partial f_7 w.r.t. v_7^1 + + // f_6 = f_7( v_1^0 , ... , v_6^1 , v_4^0 + v_6^0, v_4^1 , v_6^1 ) + f_v0[4] += f_v0[7]; + f_v0[6] += f_v0[7]; + f_v1[4] += f_v1[7]; + f_v1[6] += f_v1[7]; + ok &= std::fabs( f_v0[4] - 0. ) <= 1e-10; // partial f_6 w.r.t. v_4^0 + ok &= std::fabs( f_v0[6] - 0. ) <= 1e-10; // partial f_6 w.r.t. v_6^0 + ok &= std::fabs( f_v1[4] - 1. ) <= 1e-10; // partial f_6 w.r.t. v_4^1 + ok &= std::fabs( f_v1[6] - 1. ) <= 1e-10; // partial f_6 w.r.t. v_6^1 + + // f_5 = f_6( v_1^0 , ... , v_5^1 , v_5^0 / 2 , v_5^1 / 2 ) + f_v0[5] += f_v0[6] / 2.; + f_v1[5] += f_v1[6] / 2.; + 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 , + // 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]; + f_v1[1] += f_v1[5] * v0[3]; + f_v1[3] += f_v1[5] * v0[1]; + ok &= std::fabs( f_v0[1] - 0.5 ) <= 1e-10; // partial f_4 w.r.t. v_1^0 + ok &= std::fabs( f_v0[3] - 0.5 ) <= 1e-10; // partial f_4 w.r.t. v_3^0 + ok &= std::fabs( f_v1[1] - 0.25 ) <= 1e-10; // partial f_4 w.r.t. v_1^1 + ok &= std::fabs( f_v1[3] - 0.25 ) <= 1e-10; // partial f_4 w.r.t. v_3^1 + + // f_3 = f_4( v_1^0 , ... , v_3^1 , 1 + v_3^0 , v_3^1 ) + f_v0[3] += f_v0[4]; + f_v1[3] += f_v1[4]; + ok &= std::fabs( f_v0[3] - 0.5 ) <= 1e-10; // partial f_3 w.r.t. v_3^0 + ok &= std::fabs( f_v1[3] - 1.25) <= 1e-10; // partial f_3 w.r.t. v_3^1 + + // f_2 = f_3( v_1^0 , ... , v_2^1 , v_2^0 , v_2^1 ) + f_v0[2] += f_v0[3]; + f_v1[2] += f_v1[3]; + ok &= std::fabs( f_v0[2] - 0.5 ) <= 1e-10; // partial f_2 w.r.t. v_2^0 + ok &= std::fabs( f_v1[2] - 1.25) <= 1e-10; // partial f_2 w.r.t. v_2^1 + + // f_1 = f_2 ( v_1^0 , v_2^0 , v_1^0 , v_2^0 ) + f_v0[1] += f_v0[2]; + f_v1[1] += f_v1[2]; + ok &= std::fabs( f_v0[1] - 1. ) <= 1e-10; // partial f_1 w.r.t. v_1^0 + ok &= std::fabs( f_v1[1] - 1.5 ) <= 1e-10; // partial f_1 w.r.t. v_1^1 - return ok; + return ok; } /* %$$ $end diff -Nru cppad-2018.00.00.0/introduction/introduction.cpp cppad-2019.02.00.0/introduction/introduction.cpp --- cppad-2018.00.00.0/introduction/introduction.cpp 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/introduction.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,31 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin exp_apx.cpp$$ $spell - Cpp - exp_eps - apx + Cpp + exp_eps + apx $$ $section Correctness Tests For Exponential Approximation in Introduction$$ -$mindex exp_apx main run$$ $head Running Tests$$ To build this program and run its correctness tests see $cref cmake_check$$. $head Source$$ -$code $srcfile%introduction/introduction.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -60,33 +58,33 @@ // main program that runs all the tests int main(void) -{ std::string group = "introduction"; - size_t width = 20; - CppAD::test_boolofvoid Run(group, width); - - // This comment is used by OneTest - - // external compiled tests - Run( exp_2, "exp_2" ); - Run( exp_2_cppad, "exp_2_cppad" ); - Run( exp_2_for0, "exp_2_for0" ); - Run( exp_2_for1, "exp_2_for1" ); - Run( exp_2_for2, "exp_2_for2" ); - Run( exp_2_rev1, "exp_2_rev1" ); - Run( exp_2_rev2, "exp_2_rev2" ); - Run( exp_eps, "exp_eps" ); - Run( exp_eps_cppad, "exp_eps_cppad" ); - Run( exp_eps_for0, "exp_eps_for0" ); - Run( exp_eps_for1, "exp_eps_for1" ); - Run( exp_eps_for2, "exp_eps_for2" ); - Run( exp_eps_rev1, "exp_eps_rev1" ); - Run( exp_eps_rev2, "exp_eps_rev2" ); - // - // check for memory leak - bool memory_ok = CppAD::thread_alloc::free_all(); - // print summary at end - bool ok = Run.summary(memory_ok); - // - return static_cast( ! ok ); +{ std::string group = "introduction"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This comment is used by OneTest + + // external compiled tests + Run( exp_2, "exp_2" ); + Run( exp_2_cppad, "exp_2_cppad" ); + Run( exp_2_for0, "exp_2_for0" ); + Run( exp_2_for1, "exp_2_for1" ); + Run( exp_2_for2, "exp_2_for2" ); + Run( exp_2_rev1, "exp_2_rev1" ); + Run( exp_2_rev2, "exp_2_rev2" ); + Run( exp_eps, "exp_eps" ); + Run( exp_eps_cppad, "exp_eps_cppad" ); + Run( exp_eps_for0, "exp_eps_for0" ); + Run( exp_eps_for1, "exp_eps_for1" ); + Run( exp_eps_for2, "exp_eps_for2" ); + Run( exp_eps_rev1, "exp_eps_rev1" ); + Run( exp_eps_rev2, "exp_eps_rev2" ); + // + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); } // END C++ diff -Nru cppad-2018.00.00.0/introduction/makefile.am cppad-2019.02.00.0/introduction/makefile.am --- cppad-2018.00.00.0/introduction/makefile.am 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -14,14 +15,14 @@ DEFS = # # Microsoft project files -EXTRA_DIST = \ - exp_2.omh \ - exp_eps.omh # check_PROGRAMS = introduction # -AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) # introduction_SOURCES = \ introduction.cpp \ diff -Nru cppad-2018.00.00.0/introduction/makefile.in cppad-2019.02.00.0/introduction/makefile.in --- cppad-2018.00.00.0/introduction/makefile.in 2018-01-01 08:32:15.000000000 +0000 +++ cppad-2019.02.00.0/introduction/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -200,19 +200,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -285,10 +284,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -307,9 +304,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -332,8 +331,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -354,15 +351,13 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # -# Microsoft project files -EXTRA_DIST = \ - exp_2.omh \ - exp_eps.omh +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) # -AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) -AM_CXXFLAGS = -g $(CXX_FLAGS) -# introduction_SOURCES = \ introduction.cpp \ exp_2.cpp \ diff -Nru cppad-2018.00.00.0/makefile.am cppad-2019.02.00.0/makefile.am --- cppad-2018.00.00.0/makefile.am 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,15 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # -BUILT_SOURCES = \ - $(top_srcdir)/cppad/configure.hpp \ - $(top_srcdir)/cppad/local/is_pod.hpp -$(top_srcdir)/cppad/configure.hpp: cppad/configure.hpp - cp cppad/configure.hpp $(top_srcdir)/cppad/configure.hpp -$(top_srcdir)/cppad/local/is_pod.hpp: cppad/local/is_pod.hpp - cp cppad/local/is_pod.hpp $(top_srcdir)/cppad/local/is_pod.hpp -# if CppAD_POSTFIX postfix_dir = $(POSTFIX_DIR) else @@ -88,261 +81,312 @@ myinclude_HEADERS = \ $(IPOPT_HEADER) # +# BEGIN_SORT_THIS_LINE_PLUS_2 nobase_myinclude_HEADERS = \ - cppad/base_require.hpp \ - cppad/core/abort_recording.hpp \ - cppad/core/abs.hpp \ - cppad/core/abs_normal_fun.hpp \ - cppad/core/acosh.hpp \ - cppad/core/ad_assign.hpp \ - cppad/core/ad_binary.hpp \ - cppad/core/ad_ctor.hpp \ - cppad/core/add_eq.hpp \ - cppad/core/add.hpp \ - cppad/core/ad_fun.hpp \ - cppad/core/ad.hpp \ - cppad/core/ad_io.hpp \ - cppad/core/ad_to_string.hpp \ - cppad/core/ad_valued.hpp \ - cppad/core/arithmetic.hpp \ - cppad/core/asinh.hpp \ - cppad/core/atan2.hpp \ - cppad/core/atanh.hpp \ - cppad/core/atomic_base.hpp \ - cppad/core/azmul.hpp \ - cppad/core/base_complex.hpp \ - cppad/core/base_cond_exp.hpp \ - cppad/core/base_double.hpp \ - cppad/core/base_float.hpp \ - cppad/core/base_hash.hpp \ - cppad/core/base_limits.hpp \ - cppad/core/base_std_math.hpp \ - cppad/core/base_to_string.hpp \ - cppad/core/bender_quad.hpp \ - cppad/core/bool_fun.hpp \ - cppad/core/bool_valued.hpp \ - cppad/core/capacity_order.hpp \ - cppad/core/check_for_nan.hpp \ - cppad/core/checkpoint.hpp \ - cppad/core/compare.hpp \ - cppad/core/compound_assign.hpp \ - cppad/core/cond_exp.hpp \ - cppad/core/convert.hpp \ - cppad/core/cppad_assert.hpp \ - cppad/core/define.hpp \ - cppad/core/dependent.hpp \ - cppad/core/discrete.hpp \ - cppad/core/div_eq.hpp \ - cppad/core/div.hpp \ - cppad/core/drivers.hpp \ - cppad/core/epsilon.hpp \ - cppad/core/equal_op_seq.hpp \ - cppad/core/erf.hpp \ - cppad/core/expm1.hpp \ - cppad/core/for_hes_sparsity.hpp \ - cppad/core/for_jac_sparsity.hpp \ - cppad/core/for_one.hpp \ - cppad/core/for_sparse_hes.hpp \ - cppad/core/for_sparse_jac.hpp \ - cppad/core/for_two.hpp \ - cppad/core/forward.hpp \ - cppad/core/fun_check.hpp \ - cppad/core/fun_construct.hpp \ - cppad/core/fun_eval.hpp \ - cppad/core/hash_code.hpp \ - cppad/core/hessian.hpp \ - cppad/core/identical.hpp \ - cppad/core/independent.hpp \ - cppad/core/integer.hpp \ - cppad/core/jacobian.hpp \ - cppad/core/log1p.hpp \ - cppad/core/lu_ratio.hpp \ - cppad/core/mul_eq.hpp \ - cppad/core/mul.hpp \ - cppad/core/near_equal_ext.hpp \ - cppad/core/numeric_limits.hpp \ - cppad/core/num_skip.hpp \ - cppad/core/old_atomic.hpp \ - cppad/core/omp_max_thread.hpp \ - cppad/core/optimize.hpp \ - cppad/core/opt_val_hes.hpp \ - cppad/core/ordered.hpp \ - cppad/core/parallel_ad.hpp \ - cppad/core/par_var.hpp \ - cppad/core/pow.hpp \ - cppad/core/print_for.hpp \ - cppad/core/reverse.hpp \ - cppad/core/subgraph_reverse.hpp \ - cppad/core/rev_hes_sparsity.hpp \ - cppad/core/rev_jac_sparsity.hpp \ - cppad/core/rev_one.hpp \ - cppad/core/rev_sparse_hes.hpp \ - cppad/core/rev_sparse_jac.hpp \ - cppad/core/rev_two.hpp \ - cppad/core/sign.hpp \ - cppad/core/sparse_hessian.hpp \ - cppad/core/sparse.hpp \ - cppad/core/sparse_hes.hpp \ - cppad/core/sparse_jac.hpp \ - cppad/core/sparse_jacobian.hpp \ - cppad/core/standard_math.hpp \ - cppad/core/std_math_98.hpp \ - cppad/core/sub_eq.hpp \ - cppad/core/sub.hpp \ - cppad/core/subgraph_jac_rev.hpp \ - cppad/core/subgraph_sparsity.hpp \ - cppad/core/tape_link.hpp \ - cppad/core/test_vector.hpp \ - cppad/core/testvector.hpp \ - cppad/core/unary_minus.hpp \ - cppad/core/unary_plus.hpp \ - cppad/core/undef.hpp \ - cppad/core/user_ad.hpp \ - cppad/core/value.hpp \ - cppad/core/var2par.hpp \ - cppad/core/vec_ad.hpp \ - cppad/core/zdouble.hpp \ - cppad/cppad.hpp \ - cppad/example/base_adolc.hpp \ - cppad/example/cppad_eigen.hpp \ - cppad/example/eigen_cholesky.hpp \ - cppad/example/eigen_mat_inv.hpp \ - cppad/example/eigen_mat_mul.hpp \ - cppad/example/mat_mul.hpp \ - cppad/example/eigen_plugin.hpp \ - cppad/ipopt/solve_callback.hpp \ - cppad/ipopt/solve.hpp \ - cppad/ipopt/solve_result.hpp \ - cppad/local/abs_op.hpp \ - cppad/local/acosh_op.hpp \ - cppad/local/acos_op.hpp \ - cppad/local/add_op.hpp \ - cppad/local/ad_tape.hpp \ - cppad/local/asinh_op.hpp \ - cppad/local/asin_op.hpp \ - cppad/local/atanh_op.hpp \ - cppad/local/atan_op.hpp \ - cppad/local/color_general.hpp \ - cppad/local/color_symmetric.hpp \ - cppad/local/comp_op.hpp \ - cppad/local/cond_op.hpp \ - cppad/local/cosh_op.hpp \ - cppad/local/cos_op.hpp \ - cppad/local/cppad_colpack.hpp \ - cppad/local/cskip_op.hpp \ - cppad/local/csum_op.hpp \ - cppad/local/declare_ad.hpp \ - cppad/local/discrete_op.hpp \ - cppad/local/div_op.hpp \ - cppad/local/erf_op.hpp \ - cppad/local/expm1_op.hpp \ - cppad/local/exp_op.hpp \ - cppad/local/for_hes_sweep.hpp \ - cppad/local/for_jac_sweep.hpp \ - cppad/local/forward0sweep.hpp \ - cppad/local/forward1sweep.hpp \ - cppad/local/forward2sweep.hpp \ - cppad/local/hash_code.hpp \ - cppad/local/independent.hpp \ - cppad/local/load_op.hpp \ - cppad/local/log1p_op.hpp \ - cppad/local/log_op.hpp \ - cppad/local/mul_op.hpp \ - cppad/local/op_code.hpp \ - cppad/local/op.hpp \ - cppad/local/optimize/match_op.hpp \ - cppad/local/optimize/cexp_info.hpp \ - cppad/local/optimize/csum_stacks.hpp \ - cppad/local/optimize/csum_variable.hpp \ - cppad/local/optimize/get_opt_op_info.hpp \ - cppad/local/optimize/hash_code.hpp \ - cppad/local/optimize/old2new.hpp \ - cppad/local/optimize/opt_op_info.hpp \ - cppad/local/optimize/optimize_run.hpp \ - cppad/local/optimize/record_csum.hpp \ - cppad/local/optimize/record_pv.hpp \ - cppad/local/optimize/record_vp.hpp \ - cppad/local/optimize/record_vv.hpp \ - cppad/local/optimize/size_pair.hpp \ - cppad/local/optimize/usage.hpp \ - cppad/local/parameter_op.hpp \ - cppad/local/player.hpp \ - cppad/local/pod_vector.hpp \ - cppad/local/pow_op.hpp \ - cppad/local/print_op.hpp \ - cppad/local/prototype_op.hpp \ - cppad/local/recorder.hpp \ - cppad/local/reverse_sweep.hpp \ - cppad/local/rev_hes_sweep.hpp \ - cppad/local/subgraph/arg_variable.hpp \ - cppad/local/subgraph/entire_call.hpp \ - cppad/local/subgraph/get_rev.hpp \ - cppad/local/subgraph/info.hpp \ - cppad/local/subgraph/init_rev.hpp \ - cppad/local/subgraph/sparsity.hpp \ - cppad/local/rev_jac_sweep.hpp \ - cppad/local/set_get_in_parallel.hpp \ - cppad/local/sign_op.hpp \ - cppad/local/sinh_op.hpp \ - cppad/local/sin_op.hpp \ - cppad/local/sparse_binary_op.hpp \ - cppad/local/sparse_internal.hpp \ - cppad/local/sparse_list.hpp \ - cppad/local/sparse_pack.hpp \ - cppad/local/sparse_sizevec.hpp \ - cppad/local/sparse_unary_op.hpp \ - cppad/local/sqrt_op.hpp \ - cppad/local/std_set.hpp \ - cppad/local/store_op.hpp \ - cppad/local/sub_op.hpp \ - cppad/local/tanh_op.hpp \ - cppad/local/tan_op.hpp \ - cppad/local/user_state.hpp \ - cppad/local/zmul_op.hpp \ - cppad/speed/det_33.hpp \ - cppad/speed/det_by_lu.hpp \ - cppad/speed/det_by_minor.hpp \ - cppad/speed/det_grad_33.hpp \ - cppad/speed/det_of_minor.hpp \ - cppad/speed/mat_sum_sq.hpp \ - cppad/speed/ode_evaluate.hpp \ - cppad/speed/sparse_hes_fun.hpp \ - cppad/speed/sparse_jac_fun.hpp \ - cppad/speed/uniform_01.hpp \ - cppad/utility/check_numeric_type.hpp \ - cppad/utility/check_simple_vector.hpp \ - cppad/utility/elapsed_seconds.hpp \ - cppad/utility/error_handler.hpp \ - cppad/utility.hpp \ - cppad/utility/index_sort.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/set_union.hpp \ - cppad/utility/sparse_rc.hpp \ - cppad/utility/sparse_rcv.hpp \ - cppad/utility/speed_test.hpp \ - cppad/utility/test_boolofvoid.hpp \ - cppad/utility/thread_alloc.hpp \ - cppad/utility/time_test.hpp \ - cppad/utility/to_string.hpp \ - cppad/utility/track_new_del.hpp \ - cppad/utility/vector.hpp \ - cppad/wno_conversion.hpp + include/cppad/CMakeLists.txt \ + include/cppad/base_require.hpp \ + include/cppad/configure.hpp.in \ + include/cppad/core/abort_recording.hpp \ + include/cppad/core/abs.hpp \ + include/cppad/core/abs_normal_fun.hpp \ + include/cppad/core/acosh.hpp \ + include/cppad/core/ad.hpp \ + include/cppad/core/ad_assign.hpp \ + include/cppad/core/ad_binary.hpp \ + include/cppad/core/ad_ctor.hpp \ + include/cppad/core/ad_fun.hpp \ + include/cppad/core/ad_io.hpp \ + include/cppad/core/ad_to_string.hpp \ + include/cppad/core/ad_type.hpp \ + include/cppad/core/ad_valued.hpp \ + include/cppad/core/add.hpp \ + include/cppad/core/add_eq.hpp \ + include/cppad/core/arithmetic.hpp \ + include/cppad/core/asinh.hpp \ + include/cppad/core/atan2.hpp \ + include/cppad/core/atanh.hpp \ + include/cppad/core/atomic/atomic.omh \ + include/cppad/core/atomic/atomic_one.hpp \ + include/cppad/core/atomic/atomic_three.hpp \ + include/cppad/core/atomic/atomic_two.hpp \ + include/cppad/core/atomic/three_afun.hpp \ + include/cppad/core/atomic/three_ctor.hpp \ + include/cppad/core/atomic/three_forward.hpp \ + include/cppad/core/atomic/three_hes_sparsity.hpp \ + include/cppad/core/atomic/three_jac_sparsity.hpp \ + include/cppad/core/atomic/three_reverse.hpp \ + include/cppad/core/atomic/three_for_type.hpp \ + include/cppad/core/atomic/two_afun.hpp \ + include/cppad/core/atomic/two_clear.hpp \ + include/cppad/core/atomic/two_ctor.hpp \ + include/cppad/core/atomic/two_for_sparse_hes.hpp \ + include/cppad/core/atomic/two_for_sparse_jac.hpp \ + include/cppad/core/atomic/two_forward.hpp \ + include/cppad/core/atomic/two_option.hpp \ + include/cppad/core/atomic/two_rev_sparse_hes.hpp \ + include/cppad/core/atomic/two_rev_sparse_jac.hpp \ + include/cppad/core/atomic/two_reverse.hpp \ + include/cppad/core/azmul.hpp \ + include/cppad/core/base2ad.hpp \ + include/cppad/core/base_complex.hpp \ + include/cppad/core/base_cond_exp.hpp \ + include/cppad/core/base_double.hpp \ + include/cppad/core/base_float.hpp \ + include/cppad/core/base_hash.hpp \ + include/cppad/core/base_limits.hpp \ + include/cppad/core/base_std_math.hpp \ + include/cppad/core/base_to_string.hpp \ + include/cppad/core/bender_quad.hpp \ + include/cppad/core/bool_fun.hpp \ + include/cppad/core/bool_valued.hpp \ + include/cppad/core/capacity_order.hpp \ + include/cppad/core/check_for_nan.hpp \ + include/cppad/core/chkpoint_one/chkpoint_one.hpp \ + include/cppad/core/chkpoint_one/ctor.hpp \ + include/cppad/core/chkpoint_one/for_sparse_jac.hpp \ + include/cppad/core/chkpoint_one/forward.hpp \ + include/cppad/core/chkpoint_one/rev_sparse_hes.hpp \ + include/cppad/core/chkpoint_one/rev_sparse_jac.hpp \ + include/cppad/core/chkpoint_one/reverse.hpp \ + include/cppad/core/chkpoint_one/set_hes_sparse_bool.hpp \ + include/cppad/core/chkpoint_one/set_hes_sparse_set.hpp \ + include/cppad/core/chkpoint_one/set_jac_sparse_bool.hpp \ + include/cppad/core/chkpoint_one/set_jac_sparse_set.hpp \ + include/cppad/core/compare.hpp \ + include/cppad/core/compound_assign.hpp \ + include/cppad/core/con_dyn_var.hpp \ + include/cppad/core/cond_exp.hpp \ + include/cppad/core/convert.hpp \ + include/cppad/core/cppad_assert.hpp \ + include/cppad/core/dependent.hpp \ + include/cppad/core/discrete.hpp \ + include/cppad/core/div.hpp \ + include/cppad/core/div_eq.hpp \ + include/cppad/core/drivers.hpp \ + include/cppad/core/epsilon.hpp \ + include/cppad/core/equal_op_seq.hpp \ + include/cppad/core/erf.hpp \ + include/cppad/core/expm1.hpp \ + include/cppad/core/for_hes_sparsity.hpp \ + include/cppad/core/for_jac_sparsity.hpp \ + include/cppad/core/for_one.hpp \ + include/cppad/core/for_sparse_hes.hpp \ + include/cppad/core/for_sparse_jac.hpp \ + include/cppad/core/for_two.hpp \ + include/cppad/core/forward.hpp \ + include/cppad/core/fun_check.hpp \ + include/cppad/core/fun_construct.hpp \ + include/cppad/core/fun_eval.hpp \ + include/cppad/core/hash_code.hpp \ + include/cppad/core/hessian.hpp \ + include/cppad/core/identical.hpp \ + include/cppad/core/independent.hpp \ + include/cppad/core/integer.hpp \ + include/cppad/core/jacobian.hpp \ + include/cppad/core/log1p.hpp \ + include/cppad/core/lu_ratio.hpp \ + include/cppad/core/mul.hpp \ + include/cppad/core/mul_eq.hpp \ + include/cppad/core/near_equal_ext.hpp \ + include/cppad/core/new_dynamic.hpp \ + include/cppad/core/num_skip.hpp \ + include/cppad/core/numeric_limits.hpp \ + include/cppad/core/omp_max_thread.hpp \ + include/cppad/core/opt_val_hes.hpp \ + include/cppad/core/optimize.hpp \ + include/cppad/core/ordered.hpp \ + include/cppad/core/parallel_ad.hpp \ + include/cppad/core/pow.hpp \ + include/cppad/core/print_for.hpp \ + include/cppad/core/rev_hes_sparsity.hpp \ + include/cppad/core/rev_jac_sparsity.hpp \ + include/cppad/core/rev_one.hpp \ + include/cppad/core/rev_sparse_hes.hpp \ + include/cppad/core/rev_sparse_jac.hpp \ + include/cppad/core/rev_two.hpp \ + include/cppad/core/reverse.hpp \ + include/cppad/core/sign.hpp \ + include/cppad/core/sparse.hpp \ + include/cppad/core/sparse_hes.hpp \ + include/cppad/core/sparse_hessian.hpp \ + include/cppad/core/sparse_jac.hpp \ + include/cppad/core/sparse_jacobian.hpp \ + include/cppad/core/standard_math.hpp \ + include/cppad/core/std_math_98.hpp \ + include/cppad/core/sub.hpp \ + include/cppad/core/sub_eq.hpp \ + include/cppad/core/subgraph_jac_rev.hpp \ + include/cppad/core/subgraph_reverse.hpp \ + include/cppad/core/subgraph_sparsity.hpp \ + include/cppad/core/tape_link.hpp \ + include/cppad/core/test_vector.hpp \ + include/cppad/core/testvector.hpp \ + include/cppad/core/unary_minus.hpp \ + include/cppad/core/unary_plus.hpp \ + include/cppad/core/undef.hpp \ + include/cppad/core/user_ad.hpp \ + include/cppad/core/value.hpp \ + include/cppad/core/var2par.hpp \ + include/cppad/core/vec_ad.hpp \ + include/cppad/core/zdouble.hpp \ + include/cppad/cppad.hpp \ + include/cppad/example/base_adolc.hpp \ + include/cppad/example/cppad_eigen.hpp \ + include/cppad/example/eigen_cholesky.hpp \ + include/cppad/example/eigen_mat_inv.hpp \ + include/cppad/example/eigen_mat_mul.hpp \ + include/cppad/example/eigen_plugin.hpp \ + include/cppad/example/mat_mul.hpp \ + include/cppad/ipopt/solve.hpp \ + include/cppad/ipopt/solve_callback.hpp \ + include/cppad/ipopt/solve_result.hpp \ + include/cppad/local/CMakeLists.txt \ + include/cppad/local/abs_op.hpp \ + include/cppad/local/acos_op.hpp \ + include/cppad/local/acosh_op.hpp \ + include/cppad/local/ad_tape.hpp \ + include/cppad/local/add_op.hpp \ + include/cppad/local/asin_op.hpp \ + include/cppad/local/asinh_op.hpp \ + include/cppad/local/atan_op.hpp \ + include/cppad/local/atanh_op.hpp \ + include/cppad/local/atom_state.hpp \ + include/cppad/local/atomic_index.hpp \ + include/cppad/local/color_general.hpp \ + include/cppad/local/color_symmetric.hpp \ + include/cppad/local/comp_op.hpp \ + include/cppad/local/cond_op.hpp \ + include/cppad/local/cos_op.hpp \ + include/cppad/local/cosh_op.hpp \ + include/cppad/local/cppad_colpack.hpp \ + include/cppad/local/cskip_op.hpp \ + include/cppad/local/csum_op.hpp \ + include/cppad/local/declare_ad.hpp \ + include/cppad/local/define.hpp \ + include/cppad/local/discrete_op.hpp \ + include/cppad/local/div_op.hpp \ + include/cppad/local/erf_op.hpp \ + include/cppad/local/exp_op.hpp \ + include/cppad/local/expm1_op.hpp \ + include/cppad/local/hash_code.hpp \ + include/cppad/local/independent.hpp \ + include/cppad/local/is_pod.hpp.in \ + include/cppad/local/load_op.hpp \ + include/cppad/local/log1p_op.hpp \ + include/cppad/local/log_op.hpp \ + include/cppad/local/mul_op.hpp \ + include/cppad/local/op.hpp \ + include/cppad/local/op_code.hpp \ + include/cppad/local/op_code_dyn.hpp \ + include/cppad/local/optimize/cexp_info.hpp \ + include/cppad/local/optimize/csum_op_info.hpp \ + include/cppad/local/optimize/csum_stacks.hpp \ + include/cppad/local/optimize/get_cexp_info.hpp \ + include/cppad/local/optimize/get_dyn_previous.hpp \ + include/cppad/local/optimize/get_op_previous.hpp \ + include/cppad/local/optimize/get_op_usage.hpp \ + include/cppad/local/optimize/get_par_usage.hpp \ + include/cppad/local/optimize/hash_code.hpp \ + include/cppad/local/optimize/match_op.hpp \ + include/cppad/local/optimize/optimize_run.hpp \ + include/cppad/local/optimize/record_csum.hpp \ + include/cppad/local/optimize/record_pv.hpp \ + include/cppad/local/optimize/record_vp.hpp \ + include/cppad/local/optimize/record_vv.hpp \ + include/cppad/local/optimize/size_pair.hpp \ + include/cppad/local/optimize/usage.hpp \ + include/cppad/local/parameter_op.hpp \ + include/cppad/local/play/addr_enum.hpp \ + include/cppad/local/play/atom_op_info.hpp \ + include/cppad/local/play/player.hpp \ + include/cppad/local/play/random_iterator.hpp \ + include/cppad/local/play/random_setup.hpp \ + include/cppad/local/play/sequential_iterator.hpp \ + include/cppad/local/play/subgraph_iterator.hpp \ + include/cppad/local/pod_vector.hpp \ + include/cppad/local/pow_op.hpp \ + include/cppad/local/print_op.hpp \ + include/cppad/local/prototype_op.hpp \ + include/cppad/local/recorder.hpp \ + include/cppad/local/set_get_in_parallel.hpp \ + include/cppad/local/sign_op.hpp \ + include/cppad/local/sin_op.hpp \ + include/cppad/local/sinh_op.hpp \ + include/cppad/local/sparse_binary_op.hpp \ + include/cppad/local/sparse_internal.hpp \ + include/cppad/local/sparse_list.hpp \ + include/cppad/local/sparse_pack.hpp \ + include/cppad/local/sparse_sizevec.hpp \ + include/cppad/local/sparse_unary_op.hpp \ + include/cppad/local/sqrt_op.hpp \ + include/cppad/local/std_set.hpp \ + include/cppad/local/store_op.hpp \ + include/cppad/local/sub_op.hpp \ + include/cppad/local/subgraph/arg_variable.hpp \ + include/cppad/local/subgraph/entire_call.hpp \ + include/cppad/local/subgraph/get_rev.hpp \ + include/cppad/local/subgraph/info.hpp \ + include/cppad/local/subgraph/init_rev.hpp \ + include/cppad/local/subgraph/sparsity.hpp \ + include/cppad/local/sweep/call_atomic.hpp \ + include/cppad/local/sweep/dynamic.hpp \ + include/cppad/local/sweep/for_hes.hpp \ + include/cppad/local/sweep/for_jac.hpp \ + include/cppad/local/sweep/forward0.hpp \ + include/cppad/local/sweep/forward1.hpp \ + include/cppad/local/sweep/forward2.hpp \ + include/cppad/local/sweep/rev_hes.hpp \ + include/cppad/local/sweep/rev_jac.hpp \ + include/cppad/local/sweep/reverse.hpp \ + include/cppad/local/tan_op.hpp \ + include/cppad/local/tanh_op.hpp \ + include/cppad/local/zmul_op.hpp \ + include/cppad/speed/det_33.hpp \ + include/cppad/speed/det_by_lu.hpp \ + include/cppad/speed/det_by_minor.hpp \ + include/cppad/speed/det_grad_33.hpp \ + include/cppad/speed/det_of_minor.hpp \ + include/cppad/speed/mat_sum_sq.hpp \ + include/cppad/speed/ode_evaluate.hpp \ + include/cppad/speed/sparse_hes_fun.hpp \ + include/cppad/speed/sparse_jac_fun.hpp \ + include/cppad/speed/uniform_01.hpp \ + include/cppad/utility.hpp \ + include/cppad/utility/check_numeric_type.hpp \ + include/cppad/utility/check_simple_vector.hpp \ + include/cppad/utility/elapsed_seconds.hpp \ + include/cppad/utility/error_handler.hpp \ + include/cppad/utility/index_sort.hpp \ + include/cppad/utility/lu_factor.hpp \ + include/cppad/utility/lu_invert.hpp \ + include/cppad/utility/lu_solve.hpp \ + include/cppad/utility/memory_leak.hpp \ + include/cppad/utility/nan.hpp \ + include/cppad/utility/near_equal.hpp \ + include/cppad/utility/ode_err_control.hpp \ + include/cppad/utility/ode_gear.hpp \ + include/cppad/utility/ode_gear_control.hpp \ + include/cppad/utility/omp_alloc.hpp \ + include/cppad/utility/poly.hpp \ + include/cppad/utility/pow_int.hpp \ + include/cppad/utility/romberg_mul.hpp \ + include/cppad/utility/romberg_one.hpp \ + include/cppad/utility/rosen_34.hpp \ + include/cppad/utility/runge_45.hpp \ + include/cppad/utility/set_union.hpp \ + include/cppad/utility/sparse2eigen.hpp \ + include/cppad/utility/sparse_rc.hpp \ + include/cppad/utility/sparse_rcv.hpp \ + include/cppad/utility/speed_test.hpp \ + include/cppad/utility/test_boolofvoid.hpp \ + include/cppad/utility/thread_alloc.hpp \ + include/cppad/utility/time_test.hpp \ + include/cppad/utility/to_string.hpp \ + include/cppad/utility/track_new_del.hpp \ + include/cppad/utility/vector.hpp \ + include/cppad/wno_conversion.hpp # End nobase_myinclude_HEADERS (check_makefile.sh uses this comment) +# END_SORT_THIS_LINE_MINUS_2 # --------------------------------------------------------------- # # No objects or executables are required to install CppAD. @@ -351,11 +395,12 @@ $(IPOPT_DIRS) \ $(SPEED_DIRS) \ example/abs_normal \ - example/atomic \ - example/deprecated \ + example/atomic_two \ + example/atomic_three \ + test_more/deprecated \ + test_more/deprecated/atomic_two \ example/general \ example/get_started \ - example/ipopt_solve \ example/optimize \ example/print_for \ example/sparse \ @@ -366,60 +411,17 @@ test_more/general # # note that bin/gpl_license.sh is deleted by dist-hook -EXTRA_DIST = \ - bin \ - bin/autotools.sh \ - doc.omh \ - doc \ - gpl-3.0.txt \ - epl-v10.html \ - omh \ - uw_copy_040507.html \ - \ - test_more/compare_c/CMakeLists.txt \ - cppad/CMakeLists.txt \ - pkgconfig/CMakeLists.txt \ - example/CMakeLists.txt \ - example/atomic/CMakeLists.txt \ - example/deprecated/CMakeLists.txt \ - example/general/CMakeLists.txt \ - example/get_started/CMakeLists.txt \ - example/ipopt_solve/CMakeLists.txt \ - example/optimize/CMakeLists.txt \ - example/print_for/CMakeLists.txt \ - example/sparse/CMakeLists.txt \ - example/utility/CMakeLists.txt \ - test_more/general/CMakeLists.txt \ - CMakeLists.txt \ - cppad_ipopt/src/CMakeLists.txt \ - cppad_ipopt/example/CMakeLists.txt \ - cppad_ipopt/test/CMakeLists.txt \ - cppad_ipopt/CMakeLists.txt \ - cppad_ipopt/speed/CMakeLists.txt \ - speed/main.cpp \ - speed/cppad/CMakeLists.txt \ - speed/adolc/CMakeLists.txt \ - speed/fadbad/CMakeLists.txt \ - speed/src/CMakeLists.txt \ - speed/example/CMakeLists.txt \ - speed/CMakeLists.txt \ - speed/double/CMakeLists.txt \ - speed/profile/CMakeLists.txt \ - speed/sacado/CMakeLists.txt \ - example/multi_thread/bthread/CMakeLists.txt \ - example/multi_thread/CMakeLists.txt \ - example/multi_thread/openmp/CMakeLists.txt \ - example/multi_thread/pthread/CMakeLists.txt test_directory_list = \ $(IPOPT_TESTS) \ $(SPEED_TESTS) \ example/abs_normal \ - example/atomic \ - example/deprecated \ + example/atomic_two \ + example/atomic_three \ + test_more/deprecated/chkpoint_one \ + example/chkpoint_two \ example/general \ example/get_started \ - example/ipopt_solve \ example/multi_thread \ example/optimize \ example/print_for \ @@ -427,7 +429,9 @@ example/utility \ introduction \ test_more/compare_c \ - test_more/general + test_more/general \ + test_more/deprecated \ + test_more/deprecated/atomic_two test: all rm -f test.log @@ -444,29 +448,9 @@ chmod +x test.sh ./test.sh # -dist-hook: - rm -rf `find . -name .svn` - rm $(distdir)/doc/error.wrd - rm $(distdir)/bin/gpl_license.sh # 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) - chmod -R a-w $(doc_package) - 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 +pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = pkgconfig/cppad.pc diff -Nru cppad-2018.00.00.0/makefile.in cppad-2019.02.00.0/makefile.in --- cppad-2018.00.00.0/makefile.in 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -100,8 +100,9 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = cppad/configure.hpp cppad/local/is_pod.hpp \ - pkgconfig/cppad.pc pkgconfig/cppad-uninstalled.pc +CONFIG_CLEAN_FILES = include/cppad/configure.hpp \ + include/cppad/local/is_pod.hpp pkgconfig/cppad.pc \ + pkgconfig/cppad-uninstalled.pc CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -193,14 +194,15 @@ DIST_SUBDIRS = cppad_ipopt/src example/ipopt_solve cppad_ipopt/example \ cppad_ipopt/speed cppad_ipopt/test speed/src speed/adolc \ speed/cppad speed/double speed/example speed/fadbad \ - speed/profile speed/sacado example/abs_normal example/atomic \ - example/deprecated example/general example/get_started \ - example/optimize example/print_for example/sparse \ - example/utility introduction example/multi_thread \ - test_more/compare_c test_more/general + speed/profile speed/sacado example/abs_normal \ + example/atomic_two example/atomic_three test_more/deprecated \ + test_more/deprecated/atomic_two example/general \ + example/get_started example/optimize example/print_for \ + example/sparse example/utility introduction \ + example/multi_thread test_more/compare_c test_more/general am__DIST_COMMON = $(srcdir)/makefile.in \ - $(top_srcdir)/cppad/configure.hpp.in \ - $(top_srcdir)/cppad/local/is_pod.hpp.in \ + $(top_srcdir)/include/cppad/configure.hpp.in \ + $(top_srcdir)/include/cppad/local/is_pod.hpp.in \ $(top_srcdir)/pkgconfig/cppad-uninstalled.pc.in \ $(top_srcdir)/pkgconfig/cppad.pc.in COPYING ar-lib compile \ config.guess config.sub depcomp install-sh missing @@ -271,8 +273,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ @@ -342,10 +342,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -364,9 +362,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -389,8 +389,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -410,24 +408,20 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ +@CppAD_POSTFIX_FALSE@postfix_dir = . # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # -BUILT_SOURCES = \ - $(top_srcdir)/cppad/configure.hpp \ - $(top_srcdir)/cppad/local/is_pod.hpp - -@CppAD_POSTFIX_FALSE@postfix_dir = . -# @CppAD_POSTFIX_TRUE@postfix_dir = $(POSTFIX_DIR) @CppAD_ADOLC_FALSE@SPEED_ADOLC_TESTS = # @@ -484,262 +478,313 @@ $(IPOPT_HEADER) # +# BEGIN_SORT_THIS_LINE_PLUS_2 nobase_myinclude_HEADERS = \ - cppad/base_require.hpp \ - cppad/core/abort_recording.hpp \ - cppad/core/abs.hpp \ - cppad/core/abs_normal_fun.hpp \ - cppad/core/acosh.hpp \ - cppad/core/ad_assign.hpp \ - cppad/core/ad_binary.hpp \ - cppad/core/ad_ctor.hpp \ - cppad/core/add_eq.hpp \ - cppad/core/add.hpp \ - cppad/core/ad_fun.hpp \ - cppad/core/ad.hpp \ - cppad/core/ad_io.hpp \ - cppad/core/ad_to_string.hpp \ - cppad/core/ad_valued.hpp \ - cppad/core/arithmetic.hpp \ - cppad/core/asinh.hpp \ - cppad/core/atan2.hpp \ - cppad/core/atanh.hpp \ - cppad/core/atomic_base.hpp \ - cppad/core/azmul.hpp \ - cppad/core/base_complex.hpp \ - cppad/core/base_cond_exp.hpp \ - cppad/core/base_double.hpp \ - cppad/core/base_float.hpp \ - cppad/core/base_hash.hpp \ - cppad/core/base_limits.hpp \ - cppad/core/base_std_math.hpp \ - cppad/core/base_to_string.hpp \ - cppad/core/bender_quad.hpp \ - cppad/core/bool_fun.hpp \ - cppad/core/bool_valued.hpp \ - cppad/core/capacity_order.hpp \ - cppad/core/check_for_nan.hpp \ - cppad/core/checkpoint.hpp \ - cppad/core/compare.hpp \ - cppad/core/compound_assign.hpp \ - cppad/core/cond_exp.hpp \ - cppad/core/convert.hpp \ - cppad/core/cppad_assert.hpp \ - cppad/core/define.hpp \ - cppad/core/dependent.hpp \ - cppad/core/discrete.hpp \ - cppad/core/div_eq.hpp \ - cppad/core/div.hpp \ - cppad/core/drivers.hpp \ - cppad/core/epsilon.hpp \ - cppad/core/equal_op_seq.hpp \ - cppad/core/erf.hpp \ - cppad/core/expm1.hpp \ - cppad/core/for_hes_sparsity.hpp \ - cppad/core/for_jac_sparsity.hpp \ - cppad/core/for_one.hpp \ - cppad/core/for_sparse_hes.hpp \ - cppad/core/for_sparse_jac.hpp \ - cppad/core/for_two.hpp \ - cppad/core/forward.hpp \ - cppad/core/fun_check.hpp \ - cppad/core/fun_construct.hpp \ - cppad/core/fun_eval.hpp \ - cppad/core/hash_code.hpp \ - cppad/core/hessian.hpp \ - cppad/core/identical.hpp \ - cppad/core/independent.hpp \ - cppad/core/integer.hpp \ - cppad/core/jacobian.hpp \ - cppad/core/log1p.hpp \ - cppad/core/lu_ratio.hpp \ - cppad/core/mul_eq.hpp \ - cppad/core/mul.hpp \ - cppad/core/near_equal_ext.hpp \ - cppad/core/numeric_limits.hpp \ - cppad/core/num_skip.hpp \ - cppad/core/old_atomic.hpp \ - cppad/core/omp_max_thread.hpp \ - cppad/core/optimize.hpp \ - cppad/core/opt_val_hes.hpp \ - cppad/core/ordered.hpp \ - cppad/core/parallel_ad.hpp \ - cppad/core/par_var.hpp \ - cppad/core/pow.hpp \ - cppad/core/print_for.hpp \ - cppad/core/reverse.hpp \ - cppad/core/subgraph_reverse.hpp \ - cppad/core/rev_hes_sparsity.hpp \ - cppad/core/rev_jac_sparsity.hpp \ - cppad/core/rev_one.hpp \ - cppad/core/rev_sparse_hes.hpp \ - cppad/core/rev_sparse_jac.hpp \ - cppad/core/rev_two.hpp \ - cppad/core/sign.hpp \ - cppad/core/sparse_hessian.hpp \ - cppad/core/sparse.hpp \ - cppad/core/sparse_hes.hpp \ - cppad/core/sparse_jac.hpp \ - cppad/core/sparse_jacobian.hpp \ - cppad/core/standard_math.hpp \ - cppad/core/std_math_98.hpp \ - cppad/core/sub_eq.hpp \ - cppad/core/sub.hpp \ - cppad/core/subgraph_jac_rev.hpp \ - cppad/core/subgraph_sparsity.hpp \ - cppad/core/tape_link.hpp \ - cppad/core/test_vector.hpp \ - cppad/core/testvector.hpp \ - cppad/core/unary_minus.hpp \ - cppad/core/unary_plus.hpp \ - cppad/core/undef.hpp \ - cppad/core/user_ad.hpp \ - cppad/core/value.hpp \ - cppad/core/var2par.hpp \ - cppad/core/vec_ad.hpp \ - cppad/core/zdouble.hpp \ - cppad/cppad.hpp \ - cppad/example/base_adolc.hpp \ - cppad/example/cppad_eigen.hpp \ - cppad/example/eigen_cholesky.hpp \ - cppad/example/eigen_mat_inv.hpp \ - cppad/example/eigen_mat_mul.hpp \ - cppad/example/mat_mul.hpp \ - cppad/example/eigen_plugin.hpp \ - cppad/ipopt/solve_callback.hpp \ - cppad/ipopt/solve.hpp \ - cppad/ipopt/solve_result.hpp \ - cppad/local/abs_op.hpp \ - cppad/local/acosh_op.hpp \ - cppad/local/acos_op.hpp \ - cppad/local/add_op.hpp \ - cppad/local/ad_tape.hpp \ - cppad/local/asinh_op.hpp \ - cppad/local/asin_op.hpp \ - cppad/local/atanh_op.hpp \ - cppad/local/atan_op.hpp \ - cppad/local/color_general.hpp \ - cppad/local/color_symmetric.hpp \ - cppad/local/comp_op.hpp \ - cppad/local/cond_op.hpp \ - cppad/local/cosh_op.hpp \ - cppad/local/cos_op.hpp \ - cppad/local/cppad_colpack.hpp \ - cppad/local/cskip_op.hpp \ - cppad/local/csum_op.hpp \ - cppad/local/declare_ad.hpp \ - cppad/local/discrete_op.hpp \ - cppad/local/div_op.hpp \ - cppad/local/erf_op.hpp \ - cppad/local/expm1_op.hpp \ - cppad/local/exp_op.hpp \ - cppad/local/for_hes_sweep.hpp \ - cppad/local/for_jac_sweep.hpp \ - cppad/local/forward0sweep.hpp \ - cppad/local/forward1sweep.hpp \ - cppad/local/forward2sweep.hpp \ - cppad/local/hash_code.hpp \ - cppad/local/independent.hpp \ - cppad/local/load_op.hpp \ - cppad/local/log1p_op.hpp \ - cppad/local/log_op.hpp \ - cppad/local/mul_op.hpp \ - cppad/local/op_code.hpp \ - cppad/local/op.hpp \ - cppad/local/optimize/match_op.hpp \ - cppad/local/optimize/cexp_info.hpp \ - cppad/local/optimize/csum_stacks.hpp \ - cppad/local/optimize/csum_variable.hpp \ - cppad/local/optimize/get_opt_op_info.hpp \ - cppad/local/optimize/hash_code.hpp \ - cppad/local/optimize/old2new.hpp \ - cppad/local/optimize/opt_op_info.hpp \ - cppad/local/optimize/optimize_run.hpp \ - cppad/local/optimize/record_csum.hpp \ - cppad/local/optimize/record_pv.hpp \ - cppad/local/optimize/record_vp.hpp \ - cppad/local/optimize/record_vv.hpp \ - cppad/local/optimize/size_pair.hpp \ - cppad/local/optimize/usage.hpp \ - cppad/local/parameter_op.hpp \ - cppad/local/player.hpp \ - cppad/local/pod_vector.hpp \ - cppad/local/pow_op.hpp \ - cppad/local/print_op.hpp \ - cppad/local/prototype_op.hpp \ - cppad/local/recorder.hpp \ - cppad/local/reverse_sweep.hpp \ - cppad/local/rev_hes_sweep.hpp \ - cppad/local/subgraph/arg_variable.hpp \ - cppad/local/subgraph/entire_call.hpp \ - cppad/local/subgraph/get_rev.hpp \ - cppad/local/subgraph/info.hpp \ - cppad/local/subgraph/init_rev.hpp \ - cppad/local/subgraph/sparsity.hpp \ - cppad/local/rev_jac_sweep.hpp \ - cppad/local/set_get_in_parallel.hpp \ - cppad/local/sign_op.hpp \ - cppad/local/sinh_op.hpp \ - cppad/local/sin_op.hpp \ - cppad/local/sparse_binary_op.hpp \ - cppad/local/sparse_internal.hpp \ - cppad/local/sparse_list.hpp \ - cppad/local/sparse_pack.hpp \ - cppad/local/sparse_sizevec.hpp \ - cppad/local/sparse_unary_op.hpp \ - cppad/local/sqrt_op.hpp \ - cppad/local/std_set.hpp \ - cppad/local/store_op.hpp \ - cppad/local/sub_op.hpp \ - cppad/local/tanh_op.hpp \ - cppad/local/tan_op.hpp \ - cppad/local/user_state.hpp \ - cppad/local/zmul_op.hpp \ - cppad/speed/det_33.hpp \ - cppad/speed/det_by_lu.hpp \ - cppad/speed/det_by_minor.hpp \ - cppad/speed/det_grad_33.hpp \ - cppad/speed/det_of_minor.hpp \ - cppad/speed/mat_sum_sq.hpp \ - cppad/speed/ode_evaluate.hpp \ - cppad/speed/sparse_hes_fun.hpp \ - cppad/speed/sparse_jac_fun.hpp \ - cppad/speed/uniform_01.hpp \ - cppad/utility/check_numeric_type.hpp \ - cppad/utility/check_simple_vector.hpp \ - cppad/utility/elapsed_seconds.hpp \ - cppad/utility/error_handler.hpp \ - cppad/utility.hpp \ - cppad/utility/index_sort.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/set_union.hpp \ - cppad/utility/sparse_rc.hpp \ - cppad/utility/sparse_rcv.hpp \ - cppad/utility/speed_test.hpp \ - cppad/utility/test_boolofvoid.hpp \ - cppad/utility/thread_alloc.hpp \ - cppad/utility/time_test.hpp \ - cppad/utility/to_string.hpp \ - cppad/utility/track_new_del.hpp \ - cppad/utility/vector.hpp \ - cppad/wno_conversion.hpp + include/cppad/CMakeLists.txt \ + include/cppad/base_require.hpp \ + include/cppad/configure.hpp.in \ + include/cppad/core/abort_recording.hpp \ + include/cppad/core/abs.hpp \ + include/cppad/core/abs_normal_fun.hpp \ + include/cppad/core/acosh.hpp \ + include/cppad/core/ad.hpp \ + include/cppad/core/ad_assign.hpp \ + include/cppad/core/ad_binary.hpp \ + include/cppad/core/ad_ctor.hpp \ + include/cppad/core/ad_fun.hpp \ + include/cppad/core/ad_io.hpp \ + include/cppad/core/ad_to_string.hpp \ + include/cppad/core/ad_type.hpp \ + include/cppad/core/ad_valued.hpp \ + include/cppad/core/add.hpp \ + include/cppad/core/add_eq.hpp \ + include/cppad/core/arithmetic.hpp \ + include/cppad/core/asinh.hpp \ + include/cppad/core/atan2.hpp \ + include/cppad/core/atanh.hpp \ + include/cppad/core/atomic/atomic.omh \ + include/cppad/core/atomic/atomic_one.hpp \ + include/cppad/core/atomic/atomic_three.hpp \ + include/cppad/core/atomic/atomic_two.hpp \ + include/cppad/core/atomic/three_afun.hpp \ + include/cppad/core/atomic/three_ctor.hpp \ + include/cppad/core/atomic/three_forward.hpp \ + include/cppad/core/atomic/three_hes_sparsity.hpp \ + include/cppad/core/atomic/three_jac_sparsity.hpp \ + include/cppad/core/atomic/three_reverse.hpp \ + include/cppad/core/atomic/three_for_type.hpp \ + include/cppad/core/atomic/two_afun.hpp \ + include/cppad/core/atomic/two_clear.hpp \ + include/cppad/core/atomic/two_ctor.hpp \ + include/cppad/core/atomic/two_for_sparse_hes.hpp \ + include/cppad/core/atomic/two_for_sparse_jac.hpp \ + include/cppad/core/atomic/two_forward.hpp \ + include/cppad/core/atomic/two_option.hpp \ + include/cppad/core/atomic/two_rev_sparse_hes.hpp \ + include/cppad/core/atomic/two_rev_sparse_jac.hpp \ + include/cppad/core/atomic/two_reverse.hpp \ + include/cppad/core/azmul.hpp \ + include/cppad/core/base2ad.hpp \ + include/cppad/core/base_complex.hpp \ + include/cppad/core/base_cond_exp.hpp \ + include/cppad/core/base_double.hpp \ + include/cppad/core/base_float.hpp \ + include/cppad/core/base_hash.hpp \ + include/cppad/core/base_limits.hpp \ + include/cppad/core/base_std_math.hpp \ + include/cppad/core/base_to_string.hpp \ + include/cppad/core/bender_quad.hpp \ + include/cppad/core/bool_fun.hpp \ + include/cppad/core/bool_valued.hpp \ + include/cppad/core/capacity_order.hpp \ + include/cppad/core/check_for_nan.hpp \ + include/cppad/core/chkpoint_one/chkpoint_one.hpp \ + include/cppad/core/chkpoint_one/ctor.hpp \ + include/cppad/core/chkpoint_one/for_sparse_jac.hpp \ + include/cppad/core/chkpoint_one/forward.hpp \ + include/cppad/core/chkpoint_one/rev_sparse_hes.hpp \ + include/cppad/core/chkpoint_one/rev_sparse_jac.hpp \ + include/cppad/core/chkpoint_one/reverse.hpp \ + include/cppad/core/chkpoint_one/set_hes_sparse_bool.hpp \ + include/cppad/core/chkpoint_one/set_hes_sparse_set.hpp \ + include/cppad/core/chkpoint_one/set_jac_sparse_bool.hpp \ + include/cppad/core/chkpoint_one/set_jac_sparse_set.hpp \ + include/cppad/core/compare.hpp \ + include/cppad/core/compound_assign.hpp \ + include/cppad/core/con_dyn_var.hpp \ + include/cppad/core/cond_exp.hpp \ + include/cppad/core/convert.hpp \ + include/cppad/core/cppad_assert.hpp \ + include/cppad/core/dependent.hpp \ + include/cppad/core/discrete.hpp \ + include/cppad/core/div.hpp \ + include/cppad/core/div_eq.hpp \ + include/cppad/core/drivers.hpp \ + include/cppad/core/epsilon.hpp \ + include/cppad/core/equal_op_seq.hpp \ + include/cppad/core/erf.hpp \ + include/cppad/core/expm1.hpp \ + include/cppad/core/for_hes_sparsity.hpp \ + include/cppad/core/for_jac_sparsity.hpp \ + include/cppad/core/for_one.hpp \ + include/cppad/core/for_sparse_hes.hpp \ + include/cppad/core/for_sparse_jac.hpp \ + include/cppad/core/for_two.hpp \ + include/cppad/core/forward.hpp \ + include/cppad/core/fun_check.hpp \ + include/cppad/core/fun_construct.hpp \ + include/cppad/core/fun_eval.hpp \ + include/cppad/core/hash_code.hpp \ + include/cppad/core/hessian.hpp \ + include/cppad/core/identical.hpp \ + include/cppad/core/independent.hpp \ + include/cppad/core/integer.hpp \ + include/cppad/core/jacobian.hpp \ + include/cppad/core/log1p.hpp \ + include/cppad/core/lu_ratio.hpp \ + include/cppad/core/mul.hpp \ + include/cppad/core/mul_eq.hpp \ + include/cppad/core/near_equal_ext.hpp \ + include/cppad/core/new_dynamic.hpp \ + include/cppad/core/num_skip.hpp \ + include/cppad/core/numeric_limits.hpp \ + include/cppad/core/omp_max_thread.hpp \ + include/cppad/core/opt_val_hes.hpp \ + include/cppad/core/optimize.hpp \ + include/cppad/core/ordered.hpp \ + include/cppad/core/parallel_ad.hpp \ + include/cppad/core/pow.hpp \ + include/cppad/core/print_for.hpp \ + include/cppad/core/rev_hes_sparsity.hpp \ + include/cppad/core/rev_jac_sparsity.hpp \ + include/cppad/core/rev_one.hpp \ + include/cppad/core/rev_sparse_hes.hpp \ + include/cppad/core/rev_sparse_jac.hpp \ + include/cppad/core/rev_two.hpp \ + include/cppad/core/reverse.hpp \ + include/cppad/core/sign.hpp \ + include/cppad/core/sparse.hpp \ + include/cppad/core/sparse_hes.hpp \ + include/cppad/core/sparse_hessian.hpp \ + include/cppad/core/sparse_jac.hpp \ + include/cppad/core/sparse_jacobian.hpp \ + include/cppad/core/standard_math.hpp \ + include/cppad/core/std_math_98.hpp \ + include/cppad/core/sub.hpp \ + include/cppad/core/sub_eq.hpp \ + include/cppad/core/subgraph_jac_rev.hpp \ + include/cppad/core/subgraph_reverse.hpp \ + include/cppad/core/subgraph_sparsity.hpp \ + include/cppad/core/tape_link.hpp \ + include/cppad/core/test_vector.hpp \ + include/cppad/core/testvector.hpp \ + include/cppad/core/unary_minus.hpp \ + include/cppad/core/unary_plus.hpp \ + include/cppad/core/undef.hpp \ + include/cppad/core/user_ad.hpp \ + include/cppad/core/value.hpp \ + include/cppad/core/var2par.hpp \ + include/cppad/core/vec_ad.hpp \ + include/cppad/core/zdouble.hpp \ + include/cppad/cppad.hpp \ + include/cppad/example/base_adolc.hpp \ + include/cppad/example/cppad_eigen.hpp \ + include/cppad/example/eigen_cholesky.hpp \ + include/cppad/example/eigen_mat_inv.hpp \ + include/cppad/example/eigen_mat_mul.hpp \ + include/cppad/example/eigen_plugin.hpp \ + include/cppad/example/mat_mul.hpp \ + include/cppad/ipopt/solve.hpp \ + include/cppad/ipopt/solve_callback.hpp \ + include/cppad/ipopt/solve_result.hpp \ + include/cppad/local/CMakeLists.txt \ + include/cppad/local/abs_op.hpp \ + include/cppad/local/acos_op.hpp \ + include/cppad/local/acosh_op.hpp \ + include/cppad/local/ad_tape.hpp \ + include/cppad/local/add_op.hpp \ + include/cppad/local/asin_op.hpp \ + include/cppad/local/asinh_op.hpp \ + include/cppad/local/atan_op.hpp \ + include/cppad/local/atanh_op.hpp \ + include/cppad/local/atom_state.hpp \ + include/cppad/local/atomic_index.hpp \ + include/cppad/local/color_general.hpp \ + include/cppad/local/color_symmetric.hpp \ + include/cppad/local/comp_op.hpp \ + include/cppad/local/cond_op.hpp \ + include/cppad/local/cos_op.hpp \ + include/cppad/local/cosh_op.hpp \ + include/cppad/local/cppad_colpack.hpp \ + include/cppad/local/cskip_op.hpp \ + include/cppad/local/csum_op.hpp \ + include/cppad/local/declare_ad.hpp \ + include/cppad/local/define.hpp \ + include/cppad/local/discrete_op.hpp \ + include/cppad/local/div_op.hpp \ + include/cppad/local/erf_op.hpp \ + include/cppad/local/exp_op.hpp \ + include/cppad/local/expm1_op.hpp \ + include/cppad/local/hash_code.hpp \ + include/cppad/local/independent.hpp \ + include/cppad/local/is_pod.hpp.in \ + include/cppad/local/load_op.hpp \ + include/cppad/local/log1p_op.hpp \ + include/cppad/local/log_op.hpp \ + include/cppad/local/mul_op.hpp \ + include/cppad/local/op.hpp \ + include/cppad/local/op_code.hpp \ + include/cppad/local/op_code_dyn.hpp \ + include/cppad/local/optimize/cexp_info.hpp \ + include/cppad/local/optimize/csum_op_info.hpp \ + include/cppad/local/optimize/csum_stacks.hpp \ + include/cppad/local/optimize/get_cexp_info.hpp \ + include/cppad/local/optimize/get_dyn_previous.hpp \ + include/cppad/local/optimize/get_op_previous.hpp \ + include/cppad/local/optimize/get_op_usage.hpp \ + include/cppad/local/optimize/get_par_usage.hpp \ + include/cppad/local/optimize/hash_code.hpp \ + include/cppad/local/optimize/match_op.hpp \ + include/cppad/local/optimize/optimize_run.hpp \ + include/cppad/local/optimize/record_csum.hpp \ + include/cppad/local/optimize/record_pv.hpp \ + include/cppad/local/optimize/record_vp.hpp \ + include/cppad/local/optimize/record_vv.hpp \ + include/cppad/local/optimize/size_pair.hpp \ + include/cppad/local/optimize/usage.hpp \ + include/cppad/local/parameter_op.hpp \ + include/cppad/local/play/addr_enum.hpp \ + include/cppad/local/play/atom_op_info.hpp \ + include/cppad/local/play/player.hpp \ + include/cppad/local/play/random_iterator.hpp \ + include/cppad/local/play/random_setup.hpp \ + include/cppad/local/play/sequential_iterator.hpp \ + include/cppad/local/play/subgraph_iterator.hpp \ + include/cppad/local/pod_vector.hpp \ + include/cppad/local/pow_op.hpp \ + include/cppad/local/print_op.hpp \ + include/cppad/local/prototype_op.hpp \ + include/cppad/local/recorder.hpp \ + include/cppad/local/set_get_in_parallel.hpp \ + include/cppad/local/sign_op.hpp \ + include/cppad/local/sin_op.hpp \ + include/cppad/local/sinh_op.hpp \ + include/cppad/local/sparse_binary_op.hpp \ + include/cppad/local/sparse_internal.hpp \ + include/cppad/local/sparse_list.hpp \ + include/cppad/local/sparse_pack.hpp \ + include/cppad/local/sparse_sizevec.hpp \ + include/cppad/local/sparse_unary_op.hpp \ + include/cppad/local/sqrt_op.hpp \ + include/cppad/local/std_set.hpp \ + include/cppad/local/store_op.hpp \ + include/cppad/local/sub_op.hpp \ + include/cppad/local/subgraph/arg_variable.hpp \ + include/cppad/local/subgraph/entire_call.hpp \ + include/cppad/local/subgraph/get_rev.hpp \ + include/cppad/local/subgraph/info.hpp \ + include/cppad/local/subgraph/init_rev.hpp \ + include/cppad/local/subgraph/sparsity.hpp \ + include/cppad/local/sweep/call_atomic.hpp \ + include/cppad/local/sweep/dynamic.hpp \ + include/cppad/local/sweep/for_hes.hpp \ + include/cppad/local/sweep/for_jac.hpp \ + include/cppad/local/sweep/forward0.hpp \ + include/cppad/local/sweep/forward1.hpp \ + include/cppad/local/sweep/forward2.hpp \ + include/cppad/local/sweep/rev_hes.hpp \ + include/cppad/local/sweep/rev_jac.hpp \ + include/cppad/local/sweep/reverse.hpp \ + include/cppad/local/tan_op.hpp \ + include/cppad/local/tanh_op.hpp \ + include/cppad/local/zmul_op.hpp \ + include/cppad/speed/det_33.hpp \ + include/cppad/speed/det_by_lu.hpp \ + include/cppad/speed/det_by_minor.hpp \ + include/cppad/speed/det_grad_33.hpp \ + include/cppad/speed/det_of_minor.hpp \ + include/cppad/speed/mat_sum_sq.hpp \ + include/cppad/speed/ode_evaluate.hpp \ + include/cppad/speed/sparse_hes_fun.hpp \ + include/cppad/speed/sparse_jac_fun.hpp \ + include/cppad/speed/uniform_01.hpp \ + include/cppad/utility.hpp \ + include/cppad/utility/check_numeric_type.hpp \ + include/cppad/utility/check_simple_vector.hpp \ + include/cppad/utility/elapsed_seconds.hpp \ + include/cppad/utility/error_handler.hpp \ + include/cppad/utility/index_sort.hpp \ + include/cppad/utility/lu_factor.hpp \ + include/cppad/utility/lu_invert.hpp \ + include/cppad/utility/lu_solve.hpp \ + include/cppad/utility/memory_leak.hpp \ + include/cppad/utility/nan.hpp \ + include/cppad/utility/near_equal.hpp \ + include/cppad/utility/ode_err_control.hpp \ + include/cppad/utility/ode_gear.hpp \ + include/cppad/utility/ode_gear_control.hpp \ + include/cppad/utility/omp_alloc.hpp \ + include/cppad/utility/poly.hpp \ + include/cppad/utility/pow_int.hpp \ + include/cppad/utility/romberg_mul.hpp \ + include/cppad/utility/romberg_one.hpp \ + include/cppad/utility/rosen_34.hpp \ + include/cppad/utility/runge_45.hpp \ + include/cppad/utility/set_union.hpp \ + include/cppad/utility/sparse2eigen.hpp \ + include/cppad/utility/sparse_rc.hpp \ + include/cppad/utility/sparse_rcv.hpp \ + include/cppad/utility/speed_test.hpp \ + include/cppad/utility/test_boolofvoid.hpp \ + include/cppad/utility/thread_alloc.hpp \ + include/cppad/utility/time_test.hpp \ + include/cppad/utility/to_string.hpp \ + include/cppad/utility/track_new_del.hpp \ + include/cppad/utility/vector.hpp \ + include/cppad/wno_conversion.hpp # End nobase_myinclude_HEADERS (check_makefile.sh uses this comment) +# END_SORT_THIS_LINE_MINUS_2 # --------------------------------------------------------------- # # No objects or executables are required to install CppAD. @@ -748,11 +793,12 @@ $(IPOPT_DIRS) \ $(SPEED_DIRS) \ example/abs_normal \ - example/atomic \ - example/deprecated \ + example/atomic_two \ + example/atomic_three \ + test_more/deprecated \ + test_more/deprecated/atomic_two \ example/general \ example/get_started \ - example/ipopt_solve \ example/optimize \ example/print_for \ example/sparse \ @@ -764,60 +810,16 @@ # # note that bin/gpl_license.sh is deleted by dist-hook -EXTRA_DIST = \ - bin \ - bin/autotools.sh \ - doc.omh \ - doc \ - gpl-3.0.txt \ - epl-v10.html \ - omh \ - uw_copy_040507.html \ - \ - test_more/compare_c/CMakeLists.txt \ - cppad/CMakeLists.txt \ - pkgconfig/CMakeLists.txt \ - example/CMakeLists.txt \ - example/atomic/CMakeLists.txt \ - example/deprecated/CMakeLists.txt \ - example/general/CMakeLists.txt \ - example/get_started/CMakeLists.txt \ - example/ipopt_solve/CMakeLists.txt \ - example/optimize/CMakeLists.txt \ - example/print_for/CMakeLists.txt \ - example/sparse/CMakeLists.txt \ - example/utility/CMakeLists.txt \ - test_more/general/CMakeLists.txt \ - CMakeLists.txt \ - cppad_ipopt/src/CMakeLists.txt \ - cppad_ipopt/example/CMakeLists.txt \ - cppad_ipopt/test/CMakeLists.txt \ - cppad_ipopt/CMakeLists.txt \ - cppad_ipopt/speed/CMakeLists.txt \ - speed/main.cpp \ - speed/cppad/CMakeLists.txt \ - speed/adolc/CMakeLists.txt \ - speed/fadbad/CMakeLists.txt \ - speed/src/CMakeLists.txt \ - speed/example/CMakeLists.txt \ - speed/CMakeLists.txt \ - speed/double/CMakeLists.txt \ - speed/profile/CMakeLists.txt \ - speed/sacado/CMakeLists.txt \ - example/multi_thread/bthread/CMakeLists.txt \ - example/multi_thread/CMakeLists.txt \ - example/multi_thread/openmp/CMakeLists.txt \ - example/multi_thread/pthread/CMakeLists.txt - test_directory_list = \ $(IPOPT_TESTS) \ $(SPEED_TESTS) \ example/abs_normal \ - example/atomic \ - example/deprecated \ + example/atomic_two \ + example/atomic_three \ + test_more/deprecated/chkpoint_one \ + example/chkpoint_two \ example/general \ example/get_started \ - example/ipopt_solve \ example/multi_thread \ example/optimize \ example/print_for \ @@ -825,17 +827,18 @@ example/utility \ introduction \ test_more/compare_c \ - test_more/general + test_more/general \ + test_more/deprecated \ + test_more/deprecated/atomic_two # +# doc_postfix = $(DESTDIR)$(datadir)/doc/$(postfix_dir) doc_package = $(DESTDIR)$(datadir)/doc/$(postfix_dir)/$(PACKAGE)-$(VERSION) inc_postfix = $(DESTDIR)/$(myincludedir) -# -pkgconfigdir = $(datadir)/pkgconfig +pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = pkgconfig/cppad.pc -all: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) all-recursive +all: all-recursive .SUFFIXES: am--refresh: makefile @@ -871,9 +874,9 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): -cppad/configure.hpp: $(top_builddir)/config.status $(top_srcdir)/cppad/configure.hpp.in +include/cppad/configure.hpp: $(top_builddir)/config.status $(top_srcdir)/include/cppad/configure.hpp.in cd $(top_builddir) && $(SHELL) ./config.status $@ -cppad/local/is_pod.hpp: $(top_builddir)/config.status $(top_srcdir)/cppad/local/is_pod.hpp.in +include/cppad/local/is_pod.hpp: $(top_builddir)/config.status $(top_srcdir)/include/cppad/local/is_pod.hpp.in cd $(top_builddir) && $(SHELL) ./config.status $@ pkgconfig/cppad.pc: $(top_builddir)/config.status $(top_srcdir)/pkgconfig/cppad.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ @@ -1109,9 +1112,6 @@ || exit 1; \ fi; \ done - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$(top_distdir)" distdir="$(distdir)" \ - dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ @@ -1244,16 +1244,14 @@ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am -check: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) check-recursive +check: check-recursive all-am: makefile $(DATA) $(HEADERS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(myincludedir)" "$(DESTDIR)$(myincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-recursive +install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive @@ -1283,7 +1281,6 @@ maintainer-clean-generic: @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) clean: clean-recursive clean-am: clean-generic mostlyclean-am @@ -1307,8 +1304,7 @@ install-data-am: install-myincludeHEADERS \ install-nobase_myincludeHEADERS install-pkgconfigDATA - @$(NORMAL_INSTALL) - $(MAKE) $(AM_MAKEFLAGS) install-data-hook + install-dvi: install-dvi-recursive install-dvi-am: @@ -1356,34 +1352,28 @@ uninstall-am: uninstall-myincludeHEADERS \ uninstall-nobase_myincludeHEADERS uninstall-pkgconfigDATA -.MAKE: $(am__recursive_targets) all check install install-am \ - install-data-am install-strip +.MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-am clean clean-cscope clean-generic \ cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ - dist-gzip dist-hook dist-lzip dist-shar dist-tarZ dist-xz \ - dist-zip distcheck distclean distclean-generic distclean-tags \ + dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \ + distcheck distclean distclean-generic distclean-tags \ distcleancheck distdir distuninstallcheck dvi dvi-am html \ html-am info info-am install install-am install-data \ - install-data-am install-data-hook install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man \ - install-myincludeHEADERS install-nobase_myincludeHEADERS \ - install-pdf install-pdf-am install-pkgconfigDATA install-ps \ - install-ps-am install-strip installcheck installcheck-am \ - installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ - pdf-am ps ps-am tags tags-am uninstall uninstall-am \ - uninstall-myincludeHEADERS uninstall-nobase_myincludeHEADERS \ - uninstall-pkgconfigDATA + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-myincludeHEADERS \ + install-nobase_myincludeHEADERS install-pdf install-pdf-am \ + install-pkgconfigDATA install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am 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 -$(top_srcdir)/cppad/local/is_pod.hpp: cppad/local/is_pod.hpp - cp cppad/local/is_pod.hpp $(top_srcdir)/cppad/local/is_pod.hpp @CppAD_HAVE_AR_FALSE@ SPEED_TESTS = @CppAD_HAVE_AR_FALSE@ SPEED_DIRS = @@ -1401,22 +1391,6 @@ echo "exit 0" >> test.sh chmod +x test.sh ./test.sh -# -dist-hook: - rm -rf `find . -name .svn` - rm $(distdir)/doc/error.wrd - rm $(distdir)/bin/gpl_license.sh -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-2018.00.00.0/missing cppad-2019.02.00.0/missing --- cppad-2018.00.00.0/missing 2015-08-09 16:12:42.000000000 +0000 +++ cppad-2019.02.00.0/missing 2019-01-31 12:35:17.000000000 +0000 @@ -1,9 +1,9 @@ -#! /bin/sh +#!/bin/sh # Common wrapper for a few potentially missing GNU programs. -scriptversion=2013-10-28.13; # UTC +scriptversion=2016-01-11.22; # UTC -# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify @@ -210,6 +210,6 @@ # 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-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff -Nru cppad-2018.00.00.0/omh/adfun.omh cppad-2019.02.00.0/omh/adfun.omh --- cppad-2018.00.00.0/omh/adfun.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/adfun.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ ------------------------------------------------------------------------------- - CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin record_adfun$$ $spell @@ -15,11 +16,12 @@ $section Create an ADFun Object (Record an Operation Sequence)$$ $childtable% - cppad/core/independent.hpp% - cppad/core/fun_construct.hpp% - cppad/core/dependent.hpp% - cppad/core/abort_recording.hpp% - omh/seq_property.omh + include/cppad/core/independent.hpp% + include/cppad/core/fun_construct.hpp% + include/cppad/core/dependent.hpp% + include/cppad/core/abort_recording.hpp% + include/cppad/core/base2ad.hpp% + omh/seq_property.omh %$$ $end @@ -33,12 +35,12 @@ $childtable% - cppad/core/jacobian.hpp% - cppad/core/hessian.hpp% - cppad/core/for_one.hpp% - cppad/core/rev_one.hpp% - cppad/core/for_two.hpp% - cppad/core/rev_two.hpp + include/cppad/core/jacobian.hpp% + include/cppad/core/hessian.hpp% + include/cppad/core/for_one.hpp% + include/cppad/core/rev_one.hpp% + include/cppad/core/for_two.hpp% + include/cppad/core/rev_two.hpp %$$ $end @@ -48,22 +50,23 @@ $section Forward Mode$$ $childtable% - omh/forward/forward_zero.omh% - omh/forward/forward_one.omh% - omh/forward/forward_two.omh% - omh/forward/forward_order.omh% - omh/forward/forward_dir.omh% - omh/forward/size_order.omh% - omh/forward/compare_change.omh% - cppad/core/capacity_order.hpp% - cppad/core/num_skip.hpp + include/cppad/core/new_dynamic.hpp% + omh/forward/forward_zero.omh% + omh/forward/forward_one.omh% + omh/forward/forward_two.omh% + omh/forward/forward_order.omh% + omh/forward/forward_dir.omh% + omh/forward/size_order.omh% + omh/forward/compare_change.omh% + include/cppad/core/capacity_order.hpp% + include/cppad/core/num_skip.hpp %$$ $end ------------------------------------------------------------------------------- $begin Reverse$$ $spell - xq + xq $$ $section Reverse Mode$$ @@ -77,10 +80,10 @@ results are retained (the higher order forward results are lost). $childtable% - omh/reverse/reverse_one.omh% - omh/reverse/reverse_two.omh% - omh/reverse/reverse_any.omh% - cppad/core/subgraph_reverse.hpp + omh/reverse/reverse_one.omh% + omh/reverse/reverse_two.omh% + omh/reverse/reverse_any.omh% + include/cppad/core/subgraph_reverse.hpp %$$ $end @@ -93,25 +96,23 @@ $section Calculating Sparsity Patterns$$ $children% - cppad/core/for_jac_sparsity.hpp% - cppad/core/for_sparse_jac.hpp% + include/cppad/core/for_jac_sparsity.hpp% + include/cppad/core/rev_jac_sparsity.hpp% + include/cppad/core/for_hes_sparsity.hpp% + include/cppad/core/rev_hes_sparsity.hpp% + include/cppad/core/subgraph_sparsity.hpp% - cppad/core/rev_jac_sparsity.hpp% - cppad/core/rev_sparse_jac.hpp% + example/sparse/dependency.cpp% + example/sparse/rc_sparsity.cpp% - cppad/core/rev_hes_sparsity.hpp% - cppad/core/rev_sparse_hes.hpp% + include/cppad/core/for_sparse_jac.hpp% + include/cppad/core/rev_sparse_jac.hpp% + include/cppad/core/rev_sparse_hes.hpp% + include/cppad/core/for_sparse_hes.hpp - cppad/core/for_hes_sparsity.hpp% - cppad/core/for_sparse_hes.hpp% - - example/sparse/dependency.cpp% - example/sparse/rc_sparsity.cpp% - - cppad/core/subgraph_sparsity.hpp %$$ -$head Preferred Sparsity Patterns$$ +$head Preferred Sparsity Pattern Calculations$$ $table $rref for_jac_sparsity$$ $rref rev_jac_sparsity$$ @@ -120,7 +121,7 @@ $rref subgraph_sparsity$$ $tend -$head Old Sparsity Patterns$$ +$head Old Sparsity Pattern Calculations$$ $table $rref ForSparseJac$$ $rref RevSparseJac$$ @@ -139,13 +140,13 @@ $section Calculating Sparse Derivatives$$ $children% - cppad/core/sparse_jac.hpp% - cppad/core/sparse_jacobian.hpp% + include/cppad/core/sparse_jac.hpp% + include/cppad/core/sparse_jacobian.hpp% - cppad/core/sparse_hes.hpp% - cppad/core/sparse_hessian.hpp% + include/cppad/core/sparse_hes.hpp% + include/cppad/core/sparse_hessian.hpp% - cppad/core/subgraph_jac_rev.hpp + include/cppad/core/subgraph_jac_rev.hpp %$$ $head Preferred Sparsity Patterns$$ diff -Nru cppad-2018.00.00.0/omh/appendix/addon.omh cppad-2019.02.00.0/omh/appendix/addon.omh --- cppad-2018.00.00.0/omh/appendix/addon.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/addon.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,30 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin addon$$ $spell - Perl - Addons - addon - libdir - includedir - libcppad - adcomp - CppAD - cppad.hpp - ons - namespace - cg - pycppad + Perl + Addons + addon + libdir + includedir + libcppad + adcomp + CppAD + cppad.hpp + ons + namespace + cg + pycppad + py $$ @@ -38,35 +40,39 @@ $icode description$$ $rnext $href%https://github.com/kaskr/adcomp%tmb%$$ $cnext - $code adcomp$$ $cnext - An R Interface to CppAD with Random Effects Modeling Utilities + $code adcomp$$ $cnext + An R Interface to CppAD with Random Effects Modeling Utilities $rnext $href%https://github.com/joaoleal/CppADCodeGen/%cg%$$ $cnext - $code CppADCodeGen$$ $cnext - C++ Source Code Generation of CppAD Derivative Calculations + $code CppADCodeGen$$ $cnext + C++ Source Code Generation of CppAD Derivative Calculations $rnext -$href%http://moby.ihme.washington.edu/bradbell/cppad_mixed%mixed%$$ - $cnext $code cppad_mixed$$ $cnext - A C++ Interface to Random Effects Laplace Approximation -$rnext -$href%http://www.seanet.com/~bradbell/cppad_swig%swig%$$ - $cnext $code cppad_swig$$ $cnext - A C++ AD Library with a Swig Interface to Perl, Octave, and Python +$href%https://bradbell.github.io/cppad_mixed%mixed%$$ + $cnext $code cppad_mixed$$ $cnext + A C++ Interface to Random Effects Laplace Approximation +$rnext +$href%https://bradbell.github.io/cppad_swig%swig%$$ + $cnext $code cppad_swig$$ $cnext + A C++ AD Library with a Swig Interface to Perl, Octave, and Python +$rnext +$href%https://bradbell.github.io/cppad_py%py%$$ + $cnext $code cppad_py$$ $cnext + A Python Interface to CppAD $rnext $href%http://www.seanet.com/~bradbell/pycppad/pycppad.htm%py%$$ $cnext - $code pycppad$$ $cnext - A Python Interface to CppAD + $code pycppad$$ $cnext + A Python Interface to CppAD (no longer being developed) $tend $head Include Files$$ If $icode includedir$$ is the directory where the include files are installed, the file $codei% - %includedir%/cppad/%name%.hpp + %includedir%/include/cppad/%name%.hpp %$$ and the directory $codei% - %includedir%/cppad/%name% + %includedir%/include/cppad/%name% %$$ are reserved for use by the $icode name$$ addon. @@ -74,8 +80,8 @@ 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% + %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. @@ -83,7 +89,7 @@ $head Preprocessor Symbols$$ C++ preprocessor symbols that begin with $codei% - CPPAD_%NAME%_ + CPPAD_%NAME%_ %$$ where $icode NAME$$ is a upper-case version of $icode name$$, are reserved for use by the $icode name$$ addon. @@ -91,11 +97,9 @@ $head Namespace$$ The C++ namespace $codei% - CppAD::%name% + CppAD::%name% %$$ is reserved for use by the $icode name$$ addon. $end - - diff -Nru cppad-2018.00.00.0/omh/appendix/bib.omh cppad-2019.02.00.0/omh/appendix/bib.omh --- cppad-2018.00.00.0/omh/appendix/bib.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/bib.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,30 +1,29 @@ -// BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT $begin Bib$$ $spell - ed - Bjarne Stroustrup - Saul - Griewank - Andreas - Vetterling - Flannery - Teukolsky - Abramowitz - Stegun - Shampine - Rosenbrock + ed + Bjarne Stroustrup + Saul + Griewank + Andreas + Vetterling + Flannery + Teukolsky + Abramowitz + Stegun + Shampine + Rosenbrock $$ $section Bibliography$$ diff -Nru cppad-2018.00.00.0/omh/appendix/deprecated/compare_change.omh cppad-2019.02.00.0/omh/appendix/deprecated/compare_change.omh --- cppad-2018.00.00.0/omh/appendix/deprecated/compare_change.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/deprecated/compare_change.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,20 +1,20 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin CompareChange$$ $spell - const + const $$ $section Comparison Changes During Zero Order Forward Mode$$ -$mindex ADFun CompareChange$$ $head Syntax$$ @@ -29,7 +29,7 @@ instead. $head Purpose$$ -We use $latex F : B^n \rightarrow B^m$$ to denote the +We use $latex F : \B{R}^n \rightarrow \B{R}^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 @@ -42,20 +42,20 @@ $head f$$ The object $icode f$$ has prototype $codei% - const ADFun<%Base%> %f% + const ADFun<%Base%> %f% %$$ $head c$$ The result $icode c$$ has prototype $codei% - size_t %c% + 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%) + %f%.Forward(0, %x%) %$$ that have a different result from when $icode F$$ was created by taping an algorithm. diff -Nru cppad-2018.00.00.0/omh/appendix/deprecated/deprecated.omh cppad-2019.02.00.0/omh/appendix/deprecated/deprecated.omh --- cppad-2018.00.00.0/omh/appendix/deprecated/deprecated.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/deprecated/deprecated.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,49 +1,52 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin deprecated$$ $spell - autotools - CppAD - Bool - jac - hes - colpack + autotools + CppAD + Bool + jac + hes + colpack $$ $section CppAD Deprecated API Features$$ $childtable% - omh/appendix/deprecated/include_deprecated.omh% - omh/appendix/deprecated/fun_deprecated.omh% - omh/appendix/deprecated/compare_change.omh% - cppad/core/omp_max_thread.hpp% - cppad/utility/track_new_del.hpp% - omh/appendix/deprecated/omp_alloc.omh% - cppad/utility/memory_leak.hpp% - cppad/core/epsilon.hpp% - cppad/core/test_vector.hpp% - cppad_ipopt/src/cppad_ipopt_nlp.hpp% - cppad/core/old_atomic.hpp% - cppad/core/zdouble.hpp% - omh/install/autotools.omh + omh/appendix/deprecated/include_deprecated.omh% + omh/appendix/deprecated/fun_deprecated.omh% + omh/appendix/deprecated/compare_change.omh% + include/cppad/core/omp_max_thread.hpp% + include/cppad/utility/track_new_del.hpp% + omh/appendix/deprecated/omp_alloc.omh% + include/cppad/utility/memory_leak.hpp% + include/cppad/core/epsilon.hpp% + include/cppad/core/test_vector.hpp% + cppad_ipopt/src/cppad_ipopt_nlp.hpp% + include/cppad/core/atomic/atomic_one.hpp% + include/cppad/core/atomic/atomic_two.hpp% + include/cppad/core/chkpoint_one/chkpoint_one.hpp% + include/cppad/core/zdouble.hpp% + omh/install/autotools.omh %$$ $head Name Changes$$ $table $cref/CppADCreateUnaryBool/BoolFun/Deprecated 2007-07-31/$$ $cnext - $title BoolFun$$ + $title BoolFun$$ $rnext $cref/CppADCreateDiscrete/Discrete/CppADCreateDiscrete Deprecated 2007-07-28/$$ $cnext - $title Discrete$$ + $title Discrete$$ $rnext $cref/nan(zero)/nan/nan(zero)/$$ $cnext $codei%nan(%zero%)%$$ $rnext @@ -51,19 +54,11 @@ $cref/sparse_hes/sparse_hes/coloring/colpack.star Deprecated 2017-06-01/$$ and $cref/sparse_hessian - /sparse_hessian - /work - /colpack.star Deprecated 2017-06-01 + /sparse_hessian + /work + /colpack.star Deprecated 2017-06-01 /$$ $tend -$head Atomic Functions$$ -The following are links to deprecated $cref atomic_base$$ interfaces: -$cref/for_sparse_jac/atomic_for_sparse_jac/Deprecated 2016-06-27/$$, -$cref/rev_sparse_jac/atomic_rev_sparse_jac/Deprecated 2016-06-27/$$, -$cref/for_sparse_hes/atomic_for_sparse_hes/Deprecated 2016-06-27/$$, -$cref/rev_sparse_hes/atomic_rev_sparse_hes/Deprecated 2016-06-27/$$. - - $end diff -Nru cppad-2018.00.00.0/omh/appendix/deprecated/fun_deprecated.omh cppad-2019.02.00.0/omh/appendix/deprecated/fun_deprecated.omh --- cppad-2018.00.00.0/omh/appendix/deprecated/fun_deprecated.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/deprecated/fun_deprecated.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin FunDeprecated$$ $spell - bool - VecAD - CppAD - const - Taylor - sizeof - var + bool + VecAD + CppAD + const + Taylor + sizeof + var $$ $section ADFun Object Deprecated Member Functions$$ @@ -50,12 +51,12 @@ $cref/operation sequence/glossary/Operation/Sequence/$$ is started by a call of the form $codei% - Independent(%x%) + Independent(%x%) %$$ If there is only one such recording at the current time, you can use $icode%f%.Dependent(%y%)%$$ in place of $codei% - %f%.Dependent(%x%, %y%) + %f%.Dependent(%x%, %y%) %$$ See $cref Dependent$$ for a description of this operation. @@ -68,7 +69,7 @@ $head Order$$ The result $icode o$$ has prototype $codei% - size_t %o% + size_t %o% %$$ and is the order of the previous forward operation using the function $icode f$$. @@ -90,7 +91,7 @@ $head Memory$$ The result $codei% - size_t %m% + size_t %m% %$$ and is the number of memory units ($code sizeof$$) required for the information currently stored in $icode f$$. @@ -109,7 +110,7 @@ $head Size$$ The result $icode s$$ has prototype $codei% - size_t %s% + size_t %s% %$$ and is the number of variables in the operation sequence plus the following: one for a phantom variable with tape address zero, @@ -127,7 +128,7 @@ $head taylor_size$$ The result $icode t$$ has prototype $codei% - size_t %t% + size_t %t% %$$ and is the number of Taylor coefficient orders currently calculated and stored in the ADFun object $icode f$$. @@ -138,7 +139,7 @@ $head use_VecAD$$ The result $icode u$$ has prototype $codei% - bool %u% + bool %u% %$$ If it is true, the AD of $icode Base$$ @@ -150,13 +151,13 @@ $subhead Deprecated 2006-04-08$$ You can instead use $codei% - %u% = %f%.size_VecAD() > 0 + %u% = %f%.size_VecAD() > 0 %$$ $head size_taylor$$ The result $icode v$$ has prototype $codei% - size_t %v% + size_t %v% %$$ and is the number of Taylor coefficient orders currently calculated and stored in the ADFun object $icode f$$. @@ -167,7 +168,7 @@ $head capacity_taylor$$ The result $icode w$$ has prototype $codei% - size_t %w% + size_t %w% %$$ and is the number of Taylor coefficient orders currently allocated in the ADFun object $icode f$$. diff -Nru cppad-2018.00.00.0/omh/appendix/deprecated/include_deprecated.omh cppad-2019.02.00.0/omh/appendix/deprecated/include_deprecated.omh --- cppad-2018.00.00.0/omh/appendix/deprecated/include_deprecated.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/deprecated/include_deprecated.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,29 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin include_deprecated$$ $spell - autotools - sudo - mv - Rosen - cppad.hpp - CppAD - Runge - cp - dir - ln - lu - Romberg - Mul + autotools + sudo + mv + Rosen + cppad.hpp + CppAD + Runge + cp + dir + ln + lu + Romberg + Mul $$ $section Deprecated Include Files$$ @@ -30,15 +31,15 @@ $head Deprecated 2015-11-30$$ The $cref utility$$ individual include files have been deprecated; e.g., $codep - # include + # include $$ You must instead use $codep - # include + # include $$ or you can include individual utility files; e.g., $codep - # include + # include $$ $head Deprecated 2006-12-17$$ @@ -46,97 +47,97 @@ and the corresponding names that should be used. For example, if your program uses the deprecated preprocessor command $codep - # include + # include $$ you must change it to the command $codep - # include + # include $$ $table $bold Deprecated$$ $pre $$ $cnext $bold Should Use$$ - $pre $$ $cnext $bold Documentation$$ + $pre $$ $cnext $bold Documentation$$ $rnext CppAD/CheckNumericType.h $pre $$ $cnext cppad/check_numeric_type.hpp - $pre $$ $cnext $cref CheckNumericType$$ + $pre $$ $cnext $cref CheckNumericType$$ $rnext CppAD/CheckSimpleVector.h $pre $$ $cnext cppad/check_simple_vector.hpp - $pre $$ $cnext $cref CheckSimpleVector$$ + $pre $$ $cnext $cref CheckSimpleVector$$ $rnext CppAD/CppAD.h $pre $$ $cnext cppad/cppad.hpp - $pre $$ $cnext $cref CppAD$$ + $pre $$ $cnext $cref CppAD$$ $rnext CppAD/CppAD_vector.h $pre $$ $cnext cppad/vector.hpp - $pre $$ $cnext $cref CppAD_vector$$ + $pre $$ $cnext $cref CppAD_vector$$ $rnext CppAD/ErrorHandler.h $pre $$ $cnext cppad/error_handler.hpp - $pre $$ $cnext $cref ErrorHandler$$ + $pre $$ $cnext $cref ErrorHandler$$ $rnext CppAD/LuFactor.h $pre $$ $cnext cppad/lu_factor.hpp - $pre $$ $cnext $cref LuFactor$$ + $pre $$ $cnext $cref LuFactor$$ $rnext CppAD/LuInvert.h $pre $$ $cnext cppad/lu_invert.hpp - $pre $$ $cnext $cref LuInvert$$ + $pre $$ $cnext $cref LuInvert$$ $rnext CppAD/LuSolve.h $pre $$ $cnext cppad/lu_solve.hpp - $pre $$ $cnext $cref LuSolve$$ + $pre $$ $cnext $cref LuSolve$$ $rnext CppAD/NearEqual.h $pre $$ $cnext cppad/near_equal.hpp - $pre $$ $cnext $cref NearEqual$$ + $pre $$ $cnext $cref NearEqual$$ $rnext CppAD/OdeErrControl.h $pre $$ $cnext cppad/ode_err_control.hpp - $pre $$ $cnext $cref OdeErrControl$$ + $pre $$ $cnext $cref OdeErrControl$$ $rnext CppAD/OdeGear.h $pre $$ $cnext cppad/ode_gear.hpp - $pre $$ $cnext $cref OdeGear$$ + $pre $$ $cnext $cref OdeGear$$ $rnext CppAD/OdeGearControl.h $pre $$ $cnext cppad/ode_gear_control.hpp - $pre $$ $cnext $cref OdeGearControl$$ + $pre $$ $cnext $cref OdeGearControl$$ $rnext CppAD/Poly.h $pre $$ $cnext cppad/poly.hpp - $pre $$ $cnext $cref Poly$$ + $pre $$ $cnext $cref Poly$$ $rnext CppAD/PowInt.h $pre $$ $cnext cppad/pow_int.hpp - $pre $$ $cnext $cref pow_int$$ + $pre $$ $cnext $cref pow_int$$ $rnext CppAD/RombergMul.h $pre $$ $cnext cppad/romberg_mul.hpp - $pre $$ $cnext $cref RombergMul$$ + $pre $$ $cnext $cref RombergMul$$ $rnext CppAD/RombergOne.h $pre $$ $cnext cppad/romberg_one.hpp - $pre $$ $cnext $cref RombergOne$$ + $pre $$ $cnext $cref RombergOne$$ $rnext CppAD/Rosen34.h $pre $$ $cnext cppad/rosen_34.hpp - $pre $$ $cnext $cref Rosen34$$ + $pre $$ $cnext $cref Rosen34$$ $rnext CppAD/Runge45.h $pre $$ $cnext cppad/runge_45.hpp - $pre $$ $cnext $cref Runge45$$ + $pre $$ $cnext $cref Runge45$$ $rnext CppAD/SpeedTest.h $pre $$ $cnext cppad/speed_test.hpp - $pre $$ $cnext $cref SpeedTest$$ + $pre $$ $cnext $cref SpeedTest$$ $rnext CppAD/TrackNewDel.h $pre $$ $cnext cppad/track_new_del.hpp - $pre $$ $cnext $cref TrackNewDel$$ + $pre $$ $cnext $cref TrackNewDel$$ $tend $end diff -Nru cppad-2018.00.00.0/omh/appendix/deprecated/omp_alloc.omh cppad-2019.02.00.0/omh/appendix/deprecated/omp_alloc.omh --- cppad-2018.00.00.0/omh/appendix/deprecated/omp_alloc.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/deprecated/omp_alloc.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,22 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin omp_alloc$$ $spell - openmp - cppad/utility/omp_alloc.hpp - CppAD + openmp + include/cppad/utility/omp_alloc.hpp + CppAD $$ $section A Quick OpenMP Memory Allocator Used by CppAD$$ -$mindex multi-threading allocation$$ $head Syntax$$ @@ -42,8 +42,7 @@ Use $cref thread_alloc$$ instead. $childtable% - cppad/utility/omp_alloc.hpp% - example/deprecated/omp_alloc.cpp + include/cppad/utility/omp_alloc.hpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/appendix/directory.omh cppad-2019.02.00.0/omh/appendix/directory.omh --- cppad-2018.00.00.0/omh/appendix/directory.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/directory.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,26 @@ ------------------------------------------------------------------------------- - CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell - CppAD is distributed under multiple licenses. This distribution is under - the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. ------------------------------------------------------------------------------- $begin directory$$ $spell - CppAD - cppad - ipopt - omhelp - doxydoc - omh - pkgconfig - config - doxygen + cmake + CppAD + cppad + ipopt + omhelp + doxydoc + omh + pkgconfig + config + doxygen $$ $section Directory Structure$$ @@ -29,46 +31,49 @@ $cref/distribution directory/download/Distribution Directory/$$: $table $code bin$$ $cnext - Scripts used for CppAD development. + Scripts used for CppAD development. $rnext $code bug$$ $cnext - Used to create a simple CppAD bug report or test. + Used to create a simple CppAD bug report or test. $rnext $code build$$ $cnext - Used to build the libraries, examples, and tests. + Used to build the libraries, examples, and tests. $rnext -$code cppad$$ $cnext - The CppAD include directory. +$code cmake$$ $cnext + cmake macro files. $rnext $code cppad_ipopt$$ $cnext - Example and tests for the deprecated cppad_ipopt library. + Example and tests for the deprecated cppad_ipopt library. $rnext $code cppad_lib$$ $cnext - Source code corresponding to the CppAD library. + Source code corresponding to the CppAD library. $rnext $code doc$$ $cnext - The program bin/run_omhelp.sh puts the user documentation here. + The program bin/run_omhelp.sh puts the user documentation here. $rnext $code doxydoc$$ $cnext - The program bin/run_doxygen.sh puts its developer documentation here. + The program bin/run_doxygen.sh puts its developer documentation here. $rnext $code example$$ $cnext - Source code for the CppAD examples. + Source code for the CppAD examples. +$rnext +$code include$$ $cnext + The CppAD include directory. $rnext $code introduction$$ $cnext - Source code for the CppAD introduction. + Source code for the CppAD introduction. $rnext $code omh$$ $cnext - Contains files that are only used for documentation. + Contains files that are only used for documentation. $rnext $code pkgconfig$$ $cnext - Contains the CppAD pkg-config information. + Contains the CppAD pkg-config information. $rnext $code speed$$ $cnext - The CppAD speed tests. + The CppAD speed tests. $rnext $code test_more$$ $cnext - Tests that are not part of the documentation. + Tests that are not part of the documentation. $tend $head Example Directory$$ @@ -76,36 +81,39 @@ directory. $table +$code abs_normal$$ $cnext + examples using $cref abs_normal$$ representation of non-smooth functions. +$rnext $code atomic$$ $cnext - $cref atomic$$ function examples. + $cref atomic$$ function examples. $rnext $code deprecated$$ $cnext - examples for functions that have been $cref deprecated$$. + examples for functions that have been $cref deprecated$$. $rnext $code general$$ $cnext - general purpose examples. + general purpose examples. $rnext $code get_started$$ $cnext - a good place to get started using CppAD. + a good place to get started using CppAD. $rnext $code ipopt_solve$$ $cnext - examples using the $cref ipopt_solve$$ interface to CppAD. + examples using the $cref ipopt_solve$$ interface to CppAD. $rnext $code multi_thread$$ $cnext - CppAD $cref/multi_threading/multi_thread/$$ examples. + CppAD $cref/multi_threading/multi_thread/$$ examples. $rnext $code optimize$$ $cnext - examples using the $cref optimize$$ operation. + examples using the $cref optimize$$ operation. $rnext $code print_for$$ $cnext - examples that used the $cref PrintFor$$ operation. + examples that used the $cref PrintFor$$ operation. $rnext $code sparse$$ $cnext - examples using $cref/sparsity_patterns/sparsity_pattern/$$ and - $cref/sparse_derivatives/sparse_derivative/$$. + examples using $cref/sparsity_patterns/sparsity_pattern/$$ and + $cref/sparse_derivatives/sparse_derivative/$$. $rnext $code utility$$ $cnext - example using the CppAD $cref/utilities/utility/$$. + example using the CppAD $cref/utilities/utility/$$. $tend diff -Nru cppad-2018.00.00.0/omh/appendix/faq.omh cppad-2019.02.00.0/omh/appendix/faq.omh --- cppad-2018.00.00.0/omh/appendix/faq.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/faq.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,25 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin Faq$$ -$escape !$$ $spell - github - instantiating - faq - std - whatsnew - Namespace - CppAD - Lu + github + instantiating + faq + std + whatsnew + Namespace + CppAD + Lu $$ $section Frequently Asked Questions and Answers$$ @@ -27,13 +27,13 @@ $head Assignment and Independent$$ Why does the code sequence $codei% - Independent(%u%); - %v% = %u%[0]; + Independent(%u%); + %v% = %u%[0]; %$$ behave differently from the code sequence $codei% - %v% = %u%[0]; - Independent(%u%); + %v% = %u%[0]; + Independent(%u%); %$$ Before the call to $cref Independent$$, $icode%u%[0]%$$ is a $cref/parameter/glossary/Parameter/$$ @@ -79,15 +79,15 @@ $head Complex Types$$ Which of the following complex types is better: $codei% - AD< std::complex<%Base%> > - std::complex< AD<%Base%> > + AD< std::complex<%Base%> > + std::complex< AD<%Base%> > %$$ The $cref/complex abs function/abs/Complex Types/$$ is differentiable with respect to its real and imaginary parts, but it is not complex differentiable. Thus one would prefer to use $codei% - std::complex< AD<%Base%> > + std::complex< AD<%Base%> > %$$ On the other hand, the C++ standard only specifies $codei%std::complex<%Type%>%$$ where $icode Type$$ is @@ -132,7 +132,7 @@ $subhead Atomic Operation$$ One can also do this by making the inversion of the matrix an atomic operation; -e.g., see $cref atomic_eigen_mat_inv.cpp$$. +e.g., see $cref atomic_two_eigen_mat_inv.cpp$$. $head Mode: Forward or Reverse$$ When evaluating derivatives, diff -Nru cppad-2018.00.00.0/omh/appendix/glossary.omh cppad-2019.02.00.0/omh/appendix/glossary.omh --- cppad-2018.00.00.0/omh/appendix/glossary.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/glossary.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,31 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin glossary$$ $aindex head subhead$$ $spell - std - Vec - cos - bool - Op - Diff - Var - Cpp - enum - Taylor + std + Vec + cos + bool + Op + Diff + Var + Cpp + enum + Taylor $$ $section Glossary$$ -$mindex efficient$$ - - $head AD Function$$ Given an $cref ADFun$$ object $icode f$$ @@ -35,7 +33,7 @@ AD of $icode Base$$ $cref/operation sequence/glossary/Operation/Sequence/$$. This operation sequence defines a function -$latex F : B^n \rightarrow B^m $$ +$latex F : \B{R}^n \rightarrow \B{R}^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. @@ -57,11 +55,11 @@ an AD type above $icode Base$$ is the following sequence of types: $codei% - AD<%Base%> %,% AD< AD<%Base%> > %,% AD< AD< AD<%Base%> > > %,% %...% + AD<%Base%> %,% AD< AD<%Base%> > %,% AD< AD< AD<%Base%> > > %,% %...% %$$ $head Base Function$$ -A function $latex f : B \rightarrow B$$ +A function $latex f : \B{R} \rightarrow \B{R}$$ 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$$. @@ -71,11 +69,11 @@ $icode Base$$ is referred to as the base type for $icode x$$. $head Elementary Vector$$ -The $th j$$ elementary vector $latex e^j \in B^m$$ is defined by +The $th j$$ elementary vector $latex e^j \in \B{R}^m$$ is defined by $latex \[ e_i^j = \left\{ \begin{array}{ll} - 1 & {\rm if} \; i = j \\ - 0 & {\rm otherwise} + 1 & {\rm if} \; i = j \\ + 0 & {\rm otherwise} \end{array} \right. \] $$ @@ -99,14 +97,15 @@ Suppose that $icode x$$ and $icode y$$ are $icode Type$$ objects and the result of $codei% - %x% < %y% + %x% < %y% %$$ has type $code bool$$ (where $icode Type$$ is not the same as $code bool$$). If one executes the following code $codei% - if( %x% < %y% ) - %y% = cos(%x%); - else %y% = sin(%x%); + if( %x% < %y% ) + %y% = cos(%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. @@ -119,34 +118,50 @@ where $icode Type$$ is different from $code size_t$$. The $icode Type$$ sequence of operations corresponding to $codei% - %y% = %Type%(0); - for(%i% = 0; %i% < %n%; %i%++) - %y% += %x%[%i%]; + %y% = %Type%(0); + for(%i% = 0; %i% < %n%; %i%++) + %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 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 + +$subhead Constant$$ +An $codei%AD<%Base%>%$$ object $icode u$$ is a constant parameter if 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 -$cref/Parameter(u)/ParVar/$$ returns true -and $cref/Variable(u)/ParVar/$$ returns false. +the $cref Independent$$ variable vector +or the $cref/dynamic/Independent/dynamic/$$ parameter vector +for an $cref/active tape/glossary/Tape/Active/$$. +If $icode u$$ is a constant parameter, +$cref/Constant(u)/con_dyn_var/Constant/$$ returns true, +$cref/Parameter(u)/con_dyn_var/Parameter/$$ returns true, +$cref/Dynamic(u)/con_dyn_var/Dynamic/$$ returns false, and +$cref/Variable(u)/con_dyn_var/Variable/$$ returns false. + +$subhead Dynamic$$ +An $codei%AD<%Base%>%$$ object $icode u$$ is a dynamic parameter if +its value does not depend on the value of +the $cref Independent$$ variable vector, but its value does depend +on the $cref/dynamic/Independent/dynamic/$$ parameter vector, +for an $cref/active tape/glossary/Tape/Active/$$. +If $icode u$$ is a dynamic parameter, the function +$cref/Dynamic(u)/con_dyn_var/Dynamic/$$ returns true +$cref/Parameter(u)/con_dyn_var/Parameter/$$ returns true, +$cref/Constant(u)/con_dyn_var/Constant/$$ returns false, and +$cref/Variable(u)/con_dyn_var/Variable/$$ returns false. $head Row-major Representation$$ A $cref SimpleVector$$ $icode v$$ is a row-major representation of a matrix $latex M \in \B{R}^{m \times n}$$ if $icode%v%.size() == %m% * %n%$$ and for $latex i = 0 , \ldots , m-1$$, $latex j = 0 , \ldots , n-1$$ $latex \[ - M_{i,j} = v[ i \times n + j ] + M_{i,j} = v[ i \times n + j ] \] $$ $head Sparsity Pattern$$ -Suppose that $latex A \in B^{m \times n}$$ is a sparse matrix. +Suppose that $latex A \in \B{R}^{m \times n}$$ is a sparse matrix. CppAD has several ways to specify the elements of $latex A$$ that are possible non-zero. @@ -176,24 +191,22 @@ A new tape is created and becomes active after each call of the form (see $cref Independent$$) $codei% - Independent(%x%) + Independent(%x%) %$$ All operations that depend on the elements of $icode x$$ are recorded on this active tape. $subhead Inactive$$ -The -$cref/operation sequence/glossary/Operation/Sequence/$$ -stored in a tape must be transferred to a function object using the syntax -(see $cref/ADFun f(x, y)/FunConstruct/$$) -$codei% - ADFun<%Base%> %f%( %x%, %y%) -%$$ -or using the syntax (see $cref/f.Dependent(x, y)/Dependent/$$) +The $cref/operation sequence/glossary/Operation/Sequence/$$ +stored in a tape can be transferred to a function object using the syntax $codei% - %f%.Dependent( %x%, %y%) + ADFun<%Base%> %f%( %x%, %y%) + %f%.Dependent( %x%, %y%) %$$ +see $cref FunConstruct$$. After such a transfer, the tape becomes inactive. +The tape becomes inactive, without storing the operation sequence, +after a call to $cref abort_recording$$. $subhead Independent Variable$$ While the tape is active, we refer to the elements of $icode x$$ @@ -211,19 +224,19 @@ $head Taylor Coefficient$$ -Suppose $latex X : B \rightarrow B^n$$ is a +Suppose $latex X : \B{R} \rightarrow \B{R}^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 +we use the column vector $latex x^{(k)} \in \B{R}^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) + x^{(k)} = \frac{1}{k !} \Dpow{k}{t} X(0) \] $$ It follows that $latex \[ - X(t) = x^{(0)} + x^{(1)} t + \cdots + x^{(p)} t^p + R(t) + 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$$ converges to zero and $latex t$$ goes to zero. @@ -234,23 +247,26 @@ 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)/con_dyn_var/Variable/$$ returns true, +$cref/Constant(u)/con_dyn_var/Constant/$$ returns false, +$cref/Dynamic(u)/con_dyn_var/Dynamic/$$ returns false, and +$cref/Parameter(u)/con_dyn_var/Parameter/$$ returns false. For example, directly after the code sequence $codei% - Independent(%x%); - AD %u% = %x%[0]; + Independent(%x%); + AD %u% = %x%[0]; %$$ the $codei%AD%$$ object $icode u$$ is currently a variable. Directly after the code sequence $codei% - Independent(%x%); - AD %u% = %x%[0]; - %u% = 5; + Independent(%x%); + AD %u% = %x%[0]; + %u% = 5; %$$ -$icode u$$ is currently a $cref/parameter/glossary/Parameter/$$ -(not a variable). +$icode u$$ is currently a +$cref/constant/glossary/Parameter/Constant/$$ parameter, +not a dynamic parameter or a variable. $pre $$ diff -Nru cppad-2018.00.00.0/omh/appendix/license.omh cppad-2019.02.00.0/omh/appendix/license.omh --- cppad-2018.00.00.0/omh/appendix/license.omh 2018-01-01 08:32:21.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/license.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,29 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin License$$ $spell - CppAD + CppAD $$ $section Your License for the CppAD Software$$ -$pre +$head Your License$$ +$verbatim%COPYING%$$ -$$ +$head Eclipse Public License Version 2.0$$ +$pre -$fixed -$verbatim%gpl-3.0.txt%$$ $$ +$verbatim%epl-2.0.txt%$$ $end diff -Nru cppad-2018.00.00.0/omh/appendix/numeric_ad.omh cppad-2019.02.00.0/omh/appendix/numeric_ad.omh --- cppad-2018.00.00.0/omh/appendix/numeric_ad.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/numeric_ad.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin numeric_ad$$ $spell - CppAD - namespace - alloc + CppAD + namespace + alloc $$ @@ -22,9 +23,9 @@ designed to work with CppAD in particular. $childtable% - cppad/core/bender_quad.hpp% - cppad/core/opt_val_hes.hpp% - cppad/core/lu_ratio.hpp + include/cppad/core/bender_quad.hpp% + include/cppad/core/opt_val_hes.hpp% + include/cppad/core/lu_ratio.hpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/acos_forward.omh cppad-2019.02.00.0/omh/appendix/theory/acos_forward.omh --- cppad-2018.00.00.0/omh/appendix/theory/acos_forward.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/acos_forward.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin acos_forward$$ -$spell - acos - acosh - Arccosine - Taylor -$$ - -$section Inverse Cosine and Hyperbolic Cosine Forward Mode Theory$$ -$mindex acos acosh$$ - -$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{ \mp ( x * x - 1 ) } * F^{(1)} (x) - 0 * F (u) = \mp 1 -\] $$ -and in the -$cref/standard math function differential equation - /ForwardTheory - /Standard Math Functions - /Differential Equation -/$$, -$latex A(x) = 0$$, -$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 D [ X (t) ] $$, -and $latex F [ X(t) ] $$ respectively. - -$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} - \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 -$latex B[ X(t) ] = \sqrt{ Q[ X(t) ] }$$ and -from the equations for the -$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)} } - \left( - \frac{j+1}{2} q^{(j+1) } - - \sum_{k=1}^j k b^{(k)} b^{(j+1-k)} - \right) -\end{array} -\] $$ -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$$, -$latex \[ -\begin{array}{rcl} -z^{(0)} & = & F ( x^{(0)} ) -\\ -e^{(j)} -& = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} -\\ -& = & \left\{ \begin{array}{ll} - \mp 1 & {\rm if} \; j = 0 \\ - 0 & {\rm otherwise} -\end{array} \right. -\\ -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)} -\right) -\\ -z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } -\left( - \mp (j+1) x^{(j+1)} - - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} -\right) -\end{array} -\] $$ - - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/acos_reverse.omh cppad-2019.02.00.0/omh/appendix/theory/acos_reverse.omh --- cppad-2018.00.00.0/omh/appendix/theory/acos_reverse.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/acos_reverse.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin acos_reverse$$ -$spell - acosh - acos - Taylor -$$ - -$section Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory$$ -$mindex acos acosh$$ - - -We use the reverse theory -$cref%standard math function - %ReverseTheory - %Standard Math Functions -%$$ -definition for the functions $latex H$$ and $latex G$$. -In addition, we use the forward mode notation in -$cref acos_forward$$ for -$latex \[ -\begin{array}{rcl} - 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 zero order forward mode formulas for the -$cref/acos/acos_forward/$$ -function are -$latex \[ -\begin{array}{rcl} - q^{(0)} & = & \mp ( x^{(0)} x^{(0)} - 1) \\ - b^{(0)} & = & \sqrt{ q^{(0)} } \\ - z^{(0)} & = & F ( x^{(0)} ) -\end{array} -\] $$ -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)} & = & - \mp \sum_{k=0}^j x^{(k)} x^{(j-k)} -\\ -b^{(j)} & = & - \frac{1}{j} \frac{1}{ b^{(0)} } - \left( - \frac{j}{2} q^{(j)} - - \sum_{k=1}^{j-1} k b^{(k)} b^{(j-k)} - \right) -\\ -z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} } -\left( - \mp j x^{(j)} - - \sum_{k=1}^{j-1} k z^{(k)} b^{(j-k)} -\right) -\end{array} -\] $$ - -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^{(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)} } -\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{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^{(j)} } \frac{ b^{(j)} }{ b^{(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)} } -\mp \D{G}{ b^{(j)} } \frac{ x^{(j)} }{ b^{(0)} } -\\ -\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)} } -\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{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)} } \frac{ b^{(k)} }{ b^{(0)} } -\\ -\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)} } -\mp \D{G}{ b^{(j)} } \frac{ x^{(j-k)} }{ b^{(0)} } -\\ -\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)} } -\end{array} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/asin_forward.omh cppad-2019.02.00.0/omh/appendix/theory/asin_forward.omh --- cppad-2018.00.00.0/omh/appendix/theory/asin_forward.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/asin_forward.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,117 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin asin_forward$$ -$spell - asinh - asin - Taylor -$$ - -$section Inverse Sine and Hyperbolic Sine Forward Mode Theory$$ -$mindex asin asinh$$ - -$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 \mp x * x } * F^{(1)} (x) - 0 * F (u) = 1 -\] $$ -and in the -$cref/standard math function differential equation - /ForwardTheory - /Standard Math Functions - /Differential Equation -/$$, -$latex A(x) = 0$$, -$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 -Taylor coefficients for -$latex A [ X (t) ] $$, -$latex B [ X (t) ]$$, -$latex D [ X (t) ] $$, -and $latex F [ X(t) ] $$ respectively. - -$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 \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 -$latex B[ X(t) ] = \sqrt{ Q[ X(t) ] }$$ and -from the equations for the -$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)} } - \left( - \frac{j+1}{2} q^{(j+1) } - - \sum_{k=1}^j k b^{(k)} b^{(j+1-k)} - \right) -\end{array} -\] $$ -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$$, -$latex \[ -\begin{array}{rcl} -z^{(0)} & = & F ( x^{(0)} ) -\\ -e^{(j)} -& = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} -\\ -& = & \left\{ \begin{array}{ll} - 1 & {\rm if} \; j = 0 \\ - 0 & {\rm otherwise} -\end{array} \right. -\\ -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)} -\right) -\\ -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)} -\right) -\end{array} -\] $$ - - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/asin_reverse.omh cppad-2019.02.00.0/omh/appendix/theory/asin_reverse.omh --- cppad-2018.00.00.0/omh/appendix/theory/asin_reverse.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/asin_reverse.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,159 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin asin_reverse$$ -$spell - asinh - asin - Taylor -$$ - -$section Inverse Sine and Hyperbolic Sine Reverse Mode Theory$$ -$mindex asin asinh$$ - - -We use the reverse theory -$cref%standard math function - %ReverseTheory - %Standard Math Functions -%$$ -definition for the functions $latex H$$ and $latex G$$. -In addition, we use the forward mode notation in -$cref asin_forward$$ for -$latex \[ -\begin{array}{rcl} - 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 zero order forward mode formulas for the -$cref/asin/asin_forward/$$ -function are -$latex \[ -\begin{array}{rcl} - q^{(0)} & = & 1 \mp x^{(0)} x^{(0)} \\ - b^{(0)} & = & \sqrt{ q^{(0)} } \\ - z^{(0)} & = & F( x^{(0)} ) -\end{array} -\] $$ -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)} & = & - \mp \sum_{k=0}^j x^{(k)} x^{(j-k)} -\\ -b^{(j)} & = & - \frac{1}{j} \frac{1}{ b^{(0)} } - \left( - \frac{j}{2} q^{(j)} - - \sum_{k=1}^{j-1} k b^{(k)} b^{(j-k)} - \right) -\\ -z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} } -\left( - j x^{(j)} - - \sum_{k=1}^{j-1} k z^{(k)} b^{(j-k)} -\right) -\end{array} -\] $$ - -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{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)} } -\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{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^{(j)} } \frac{ b^{(j)} }{ b^{(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)} } -\mp \D{G}{ b^{(j)} } \frac{ x^{(j)} }{ b^{(0)} } -\\ -\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)} } -\mp \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} } -\\ -\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)} } \frac{ b^{(k)} }{ b^{(0)} } -\\ -\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)} } -\mp \D{G}{ b^{(j)} } \frac{ x^{(j-k)} }{ b^{(0)} } -\\ -\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)} } -\end{array} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/atan_forward.omh cppad-2019.02.00.0/omh/appendix/theory/atan_forward.omh --- cppad-2018.00.00.0/omh/appendix/theory/atan_forward.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/atan_forward.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin atan_forward$$ -$spell - atan - atanh - Taylor -$$ - -$section Inverse Tangent and Hyperbolic Tangent Forward Mode Theory$$ -$mindex atan atanh$$ - -$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 \pm x * x ) * F^{(1)} (x) - 0 * F (x) = 1 -\] $$ -and in the -$cref/standard math function differential equation - /ForwardTheory - /Standard Math Functions - /Differential Equation -/$$, -$latex A(x) = 0$$, -$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 -Taylor coefficients for -$latex A [ X (t) ] $$, -$latex B [ X (t) ]$$, -$latex D [ X (t) ] $$, -and $latex F [ X(t) ] $$ respectively. - -$head Taylor Coefficients Recursion$$ -For $latex j = 0 , 1, \ldots$$, -$latex \[ -\begin{array}{rcl} -z^{(0)} & = & F( x^{(0)} ) -\\ -b^{(j)} -& = & \left\{ \begin{array}{ll} - 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)} -& = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} -\\ -& = & \left\{ \begin{array}{ll} - 1 & {\rm if} \; j = 0 \\ - 0 & {\rm otherwise} -\end{array} \right. -\\ -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)} -\right) -\\ -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)} -\right) -\end{array} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/atan_reverse.omh cppad-2019.02.00.0/omh/appendix/theory/atan_reverse.omh --- cppad-2018.00.00.0/omh/appendix/theory/atan_reverse.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/atan_reverse.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin atan_reverse$$ -$spell - atan - atanh - Taylor -$$ - -$section Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory$$ - - -We use the reverse theory -$cref%standard math function - %ReverseTheory - %Standard Math Functions -%$$ -definition for the functions $latex H$$ and $latex G$$. -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 zero order forward mode formulas for the -$cref/atan/atan_forward/$$ -function are -$latex \[ -\begin{array}{rcl} - z^{(0)} & = & F ( x^{(0)} ) \\ - b^{(0)} & = & 1 \pm x^{(0)} x^{(0)} -\end{array} -\] $$ -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)} & = & - \pm \sum_{k=0}^j x^{(k)} x^{(j-k)} -\\ -z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} } -\left( - j x^{(j)} - - \sum_{k=1}^{j-1} k z^{(k)} b^{(j-k)} -\right) -\end{array} -\] $$ - - -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{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} } -+ \D{G}{ b^{(j)} } \D{ b^{(j)} }{ x^{(0)} } -\\ -& = & -\D{G}{ x^{(j)} } -+ \D{G}{ z^{(j)} } \frac{1}{ b^{(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{G}{ b^{(0)} } -- \D{G}{ z^{(j)} } \frac{ z^{(j)} }{ b^{(0)} } -\\ -\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}{ z^{(j)} } \frac{1}{ b^{(0)} } -\pm \D{G}{ b^{(j)} } 2 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)} } -\pm \D{G}{ b^{(j)} } 2 x^{(j)} -\\ -\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)} } -\pm \D{G}{ b^{(j)} } 2 x^{(j-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{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)} } -\end{array} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/cholesky.omh cppad-2019.02.00.0/omh/appendix/theory/cholesky.omh --- cppad-2018.00.00.0/omh/appendix/theory/cholesky.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/cholesky.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,383 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 cholesky_theory$$ -$spell - Taylor - Cholesky - Sebastian - Ph - Humboldt - Universitat - zu -$$ - -$section AD Theory for Cholesky Factorization$$ - -$head Reference$$ -See section 3.6 of -Sebastian F. Walter's Ph.D. thesis, -$italic -Structured Higher-Order Algorithmic Differentiation -in the Forward and Reverse Mode -with Application in Optimum Experimental Design -$$, -Humboldt-Universitat zu Berlin, -2011. - - -$head Notation$$ - -$subhead Cholesky Factor$$ -We are given a positive definite symmetric matrix -$latex A \in \B{R}^{n \times n}$$ -and a Cholesky factorization -$latex \[ - A = L L^\R{T} -\] $$ -where $latex L \in \B{R}^{n \times n}$$ is lower triangular. - -$subhead Taylor Coefficient$$ -The matrix $latex A$$ is a function of a scalar argument -$latex t$$. -For $latex k = 0 , \ldots , K$$, we use $latex A_k$$ for the -corresponding Taylor coefficients; i.e., -$latex \[ - A(t) = o( t^K ) + \sum_{k = 0}^K A_k t^k -\] $$ -where $latex o( t^K ) / t^K \rightarrow 0 $$ as $latex t \rightarrow 0$$. -We use a similar notation for $latex L(t)$$. - -$subhead Lower Triangular Part$$ -For a square matrix $latex C$$, -$latex \R{lower} (C)$$ is the lower triangular part of $latex C$$, -$latex \R{diag} (C)$$ is the diagonal matrix with the same diagonal as -$latex C$$ and -$latex \[ - \R{low} ( C ) = \R{lower} (C) - \frac{1}{2} \R{diag} (C) -\] $$ - - - -$head Forward Mode$$ -For Taylor coefficient order $latex k = 0 , \ldots , K$$ -the coefficients -$latex A_k \in \B{R}^{n \times n}$$, and -satisfy the equation -$latex \[ - A_k = \sum_{\ell=0}^k L_\ell L_{k-\ell}^\R{T} -\] $$ -In the case where $latex k=0$$, the -$latex \[ - A_0 = L_0 L_0^\R{T} -\] $$ -The value of $latex L_0$$ can be computed using the Cholesky factorization. -In the case where $latex k > 0$$, -$latex \[ - A_k = L_k L_0^\R{T} + L_0 L_k^\R{T} + B_k -\] $$ -where -$latex \[ - B_k = \sum_{\ell=1}^{k-1} L_\ell L_{k-\ell}^\R{T} -\] $$ -Note that $latex B_k$$ is defined in terms of Taylor coefficients -of $latex L(t)$$ that have order less than $latex k$$. -We also note that -$latex \[ - L_0^{-1} ( A_k - B_k ) L_0^\R{-T} - = - L_0^{-1} L_k + L_k^\R{T} L_0^\R{-T} -\] $$ -The first matrix on the right hand side is lower triangular, -the second is upper triangular, -and the diagonals are equal. -It follows that -$latex \[ - L_0^{-1} L_k - = - \R{low} [ L_0^{-1} ( A_k - B_k ) L_0^\R{-T} ] -\] $$ -$latex \[ - L_k - = - L_0 \R{low} [ L_0^{-1} ( A_k - B_k ) L_0^\R{-T} ] -\] $$ -This expresses $latex L_k$$ in term of the -Taylor coefficients of $latex A(t)$$ and the lower order coefficients -of $latex L(t)$$. - -$head Lemma 1$$ -We use the notation $latex \dot{C}$$ for the derivative of a matrix -valued function $latex C(s)$$ with respect to a scalar argument $latex s$$. -We use the notation $latex \bar{S}$$ and $latex \bar{L}$$ for the -partial derivative of a scalar value function $latex \bar{F}( S, L)$$ -with respect to a symmetric matrix $latex S$$ and -an lower triangular matrix $latex L$$. -Define the scalar valued function -$latex \[ - \hat{F}( C ) = \bar{F} [ S , \hat{L} (S) ] -\] $$ -We use $latex \hat{S}$$ for the total derivative of $latex \hat{F}$$ with -respect to $latex S$$. -Suppose that $latex \hat{L} ( S )$$ is such that -$latex \[ - \dot{L} = L_0 \R{low} ( L_0^{-1} \dot{S} L_0^\R{-T} ) -\] $$ -for any $latex S(s)$$. It follows that -$latex \[ - \hat{S} = \bar{S} + \frac{1}{2} ( M + M^\R{T} ) -\] $$ -where -$latex \[ - M = L_0^\R{-T} \R{low}( L_0^\R{T} \bar{L} )^\R{T} L_0^{-1} -\] $$ - -$subhead Proof$$ -$latex \[ - \partial_s \hat{F} [ S(s) , L(s) ] - = - \R{tr} ( \bar{S}^\R{T} \dot{S} ) - + - \R{tr} ( \bar{L}^\R{T} \dot{L} ) -\] $$ -$latex \[ - \R{tr} ( \bar{L}^\R{T} \dot{L} ) - = - \R{tr} [ - \bar{L}^\R{T} L_0 - \R{low} ( L_0^{-1} \dot{S} L_0^\R{-T} ) - ] -\] $$ -$latex \[ - = - \R{tr} [ - \R{low} ( L_0^{-1} \dot{S} L_0^\R{-T} )^\R{T} - L_0^\R{T} \bar{L} - ] -\] $$ -$latex \[ - = - \R{tr} [ - L_0^{-1} \dot{S} L_0^\R{-T} - \R{low}( L_0^\R{T} \bar{L} ) - ] -\] $$ -$latex \[ - = - \R{tr} [ - L_0^\R{-T} \R{low}( L_0^\R{T} \bar{L} ) L_0^{-1} \dot{S} - ] -\] $$ -$latex \[ - \partial_s \hat{F} [ S(s) , L(s) ] - = - \R{tr} ( \bar{S}^\R{T} \dot{S} ) - + - \R{tr} [ - L_0^\R{-T} \R{low}( L_0^\R{T} \bar{L} ) L_0^{-1} \dot{S} - ] -\] $$ -We now consider the $latex (i, j)$$ component function, -for a symmetric matrix $latex S(s)$$, -defined by -$latex \[ - S_{k, \ell} (s) = \left\{ \begin{array}{ll} - 1 & \R{if} \; k = i \; \R{and} \; \ell = j \\ - 1 & \R{if} \; k = j \; \R{and} \; \ell = i \\ - 0 & \R{otherwise} - \end{array} \right\} -\] $$ -This shows that the formula in the lemma is correct for -$latex \hat{S}_{i,j}$$ and $latex \hat{S}_{j,i}$$. -This completes the proof because the component $latex (i, j)$$ was arbitrary. - -$head Lemma 2$$ -We use the same assumptions as in Lemma 1 except that the -matrix $latex S$$ is lower triangular (instead of symmetric). -It follows that -$latex \[ - \hat{S} = \bar{S} + \R{lower}(M) -\] $$ -where -$latex \[ - M = L_0^\R{-T} \R{low}( L_0^\R{T} \bar{L} )^\R{T} L_0^{-1} -\] $$ -The proof of this lemma is identical to Lemma 2 except that component function -is defined by -$latex \[ - S_{k, \ell} (s) = \left\{ \begin{array}{ll} - 1 & \R{if} \; k = i \; \R{and} \; \ell = j \\ - 0 & \R{otherwise} - \end{array} \right\} -\] $$ - -$head Reverse Mode$$ - -$subhead Case k = 0$$ -For the case $latex k = 0$$, -$latex \[ - \dot{A}_0 - = - \dot{L}_0 L_0^\R{T} - + - L_0 \dot{L}_0^\R{T} -\] $$ -$latex \[ - L_0^{-1} \dot{A}_0 L_0^\R{-T} - = - L_0^{-1} \dot{L}_0 - + - \dot{L}_0^\R{T} L_0^\R{-T} -\] $$ -$latex \[ - \R{low} ( L_0^{-1} \dot{A}_0 L_0^\R{-T} ) - = - L_0^{-1} \dot{L}_0 -\] $$ -$latex \[ - \dot{L}_0 - = - L_0 \R{low} ( L_0^{-1} \dot{A}_0 L_0^\R{-T} ) -\] $$ -It follows from Lemma 1 that -$latex \[ - \bar{A}_0 \stackrel{+}{=} \frac{1}{2} ( M + M^\R{T} ) -\] $$ -where -$latex \[ - M = L_0^\R{-T} \R{low} ( L_0^\R{T} \bar{L}_0 )^\R{T} L_0^{-1} -\] $$ -and $latex \bar{A}_0$$ is the partial before and after -is before and after $latex L_0$$ is removed from the scalar function -dependency. - -$subhead Case k > 0$$ -In the case where $latex k > 0$$, -$latex \[ - A_k = L_k L_0^\R{T} + L_0 L_k^\R{T} + B_k -\] $$ -where $latex B_k$$ is defined in terms of Taylor coefficients -of $latex L(t)$$ that have order less than $latex k$$. -It follows that -$latex \[ - \dot{L}_k L_0^\R{T} - + - L_0 \dot{L}_k^\R{T} - = - \dot{A}_k - \dot{B}_k - \dot{L}_0 L_k^\R{T} - L_k \dot{L}_0^\R{T} -\] $$ -$latex \[ - L_0^{-1} \dot{L}_k - + - \dot{L}_k^\R{T} L_0^\R{-T} - = - L_0^{-1} ( - \dot{A}_k - \dot{B}_k - \dot{L}_0 L_k^\R{T} - L_k \dot{L}_0^\R{T} - ) L_0^\R{-T} -\] $$ -$latex \[ - L_0^{-1} \dot{L}_k - = - \R{low} [ L_0^{-1} ( - \dot{A}_k - \dot{B}_k - \dot{L}_0 L_k^\R{T} - L_k \dot{L}_0^\R{T} - ) L_0^\R{-T} ] -\] $$ -$latex \[ - \dot{L}_k - = - L_0 \R{low} [ L_0^{-1} ( - \dot{A}_k - \dot{B}_k - \dot{L}_0 L_k^\R{T} - L_k \dot{L}_0^\R{T} - ) L_0^\R{-T} ] -\] $$ -The matrix $latex A_k$$ is symmetric, it follows that -$latex \[ - \bar{A}_k \stackrel{+}{=} \frac{1}{2} ( M_k + M_k^\R{T} ) -\] $$ -where -$latex \[ - M_k = L_0^\R{-T} \R{low} ( L_0^\R{T} \bar{L}_k )^\R{T} L_0^{-1} -\] $$ -The matrix $latex B_k$$ is also symmetric, hence -$latex \[ - \bar{B}_k = - \; \frac{1}{2} ( M_k + M_k^\R{T} ) -\] $$ -We define the symmetric matrix $latex C_k (s)$$ by -$latex \[ - \dot{C}_k = \dot{L}_0 L_k^\R{T} + L_k \dot{L}_0^\R{T} -\] $$ -and remove the dependency on $latex C_k$$ with -$latex \[ - \R{tr}( \bar{C}_k^\R{T} \dot{C}_k ) - = - \R{tr}( \bar{B}_k^\R{T} \dot{C}_k ) - = - \R{tr}( \bar{B}_k^\R{T} \dot{L}_0 L_k^\R{T} ) - + - \R{tr}( \bar{B}_k^\R{T} L_k \dot{L}_0^\R{T} ) -\] $$ -$latex \[ - = - \R{tr}( L_k^\R{T} \bar{B}_k^\R{T} \dot{L}_0 ) - + - \R{tr}( L_k^\R{T} \bar{B}_k \dot{L}_0 ) -\] $$ -$latex \[ - = - \R{tr}[ L_k^\R{T} ( \bar{B}_k + \bar{B}_k^\R{T} ) \dot{L}_0 ] -\] $$ -Thus, removing $latex C_k$$ from the dependency results in the -following update to $latex \bar{L}_0$$: -$latex \[ - \bar{L}_0 \stackrel{+}{=} \R{lower} [ ( \bar{B}_k + \bar{B}_k^\R{T} ) L_k ] -\] $$ -which is the same as -$latex \[ - \bar{L}_0 \stackrel{+}{=} 2 \; \R{lower} [ \bar{B}_k L_k ] -\] $$ - -We still need to remove $latex B_k$$ from the dependency. -It follows from its definition that -$latex \[ - \dot{B}_k = \sum_{\ell=1}^{k-1} - \dot{L}_\ell L_{k-\ell}^\R{T} + L_\ell \dot{L}_{k-\ell}^\R{T} -\]$$ -$latex \[ - \R{tr}( \bar{B}_k^\R{T} \dot{B}_k ) - = - \sum_{\ell=1}^{k-1} - \R{tr}( \bar{B}_k^\R{T} \dot{L}_\ell L_{k-\ell}^\R{T} ) - + - \R{tr}( \bar{B}_k^\R{T} L_\ell \dot{L}_{k-\ell}^\R{T} ) -\]$$ -$latex \[ - = - \sum_{\ell=1}^{k-1} - \R{tr}( L_{k-\ell}^\R{T} \bar{B}_k^\R{T} \dot{L}_\ell ) - + - \sum_{\ell=1}^{k-1} - \R{tr}( L_\ell^\R{T} \bar{B}_k \dot{L}_{k-\ell} ) -\]$$ -We now use the fact that $latex \bar{B}_k$$ is symmetric to conclude -$latex \[ - \R{tr}( \bar{B}_k^\R{T} \dot{B}_k ) - = - 2 \sum_{\ell=1}^{k-1} - \R{tr}( L_{k-\ell}^\R{T} \bar{B}_k^\R{T} \dot{L}_\ell ) -\] $$ -Each of the $latex \dot{L}_\ell$$ matrices is lower triangular. -Thus, removing $latex B_k$$ from the dependency results in the following -update for $latex \ell = 1 , \ldots , k-1$$: -$latex \[ - \bar{L}_\ell - \stackrel{+}{=} 2 \; \R{lower}( \bar{B}_k L_{k-\ell} ) -\] $$ - - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/erf_forward.omh cppad-2019.02.00.0/omh/appendix/theory/erf_forward.omh --- cppad-2018.00.00.0/omh/appendix/theory/erf_forward.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/erf_forward.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 erf_forward$$ -$spell - erf - Taylor -$$ - - -$section Error Function Forward Taylor Polynomial Theory$$ -$mindex erf$$ - -$head Derivatives$$ -Given $latex X(t)$$, we define the function -$latex \[ - Z(t) = \R{erf}[ X(t) ] -\]$$ -It follows that -$latex \[ -\begin{array}{rcl} -\R{erf}^{(1)} ( u ) & = & ( 2 / \sqrt{\pi} ) \exp \left( - u^2 \right) -\\ -Z^{(1)} (t) & = & \R{erf}^{(1)} [ X(t) ] X^{(1)} (t) = Y(t) X^{(1)} (t) -\end{array} -\] $$ -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 -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)$$. -Using the equation above for $latex Z^{(1)} (t)$$, we have -$latex \[ -\begin{array}{rcl} -\sum_{k=1}^j k z^{(k)} t^{k-1} -& = & -\left[ \sum_{k=0}^j y^{(k)} t^k \right] -\left[ \sum_{k=1}^j k x^{(k)} t^{k-1} \right] -+ -o( t^{j-1} ) -\end{array} -\] $$ -Setting the coefficients of $latex t^{j-1}$$ equal, we have -$latex \[ -\begin{array}{rcl} -j z^{(j)} -= -\sum_{k=1}^j k x^{(k)} y^{(j-k)} -\\ -z^{(j)} -= -\frac{1}{j} \sum_{k=1}^j k x^{(k)} y^{(j-k)} -\end{array} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/erf_reverse.omh cppad-2019.02.00.0/omh/appendix/theory/erf_reverse.omh --- cppad-2018.00.00.0/omh/appendix/theory/erf_reverse.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/erf_reverse.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 erf_reverse$$ -$spell - erf - Taylor -$$ - - -$section Error Function Reverse Mode Theory$$ -$mindex erf$$ - -$head Notation$$ -We use the reverse theory -$cref/standard math function/ReverseTheory/Standard Math Functions/$$ -definition for the functions $latex H$$ and $latex G$$. - -$head Positive Orders Z(t)$$ -For order $latex j > 0$$, -suppose that $latex H$$ is the same as $latex G$$. -$latex \[ -z^{(j)} -= -\frac{1}{j} \sum_{k=1}^j k x^{(k)} y^{(j-k)} -\] $$ -For $latex k = 1 , \ldots , j$$, -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$$ -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 -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{G}{ x^{(0)} } + \D{G}{ z^{(0)} } \D{ z^{(0)} }{ x^{(0)} } -= -\D{G}{ x^{(0)} } + \D{G}{ z^{(0)} } y^{(0)} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/exp_forward.omh cppad-2019.02.00.0/omh/appendix/theory/exp_forward.omh --- cppad-2018.00.00.0/omh/appendix/theory/exp_forward.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/exp_forward.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin exp_forward$$ -$spell - exp - expm1 - Taylor -$$ - -$section Exponential Function Forward Mode Theory$$ -$mindex exp expm1$$ - -$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) -= -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. -\] $$ -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) = 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 D [ X (t) ] $$, -and $latex F [ X(t) ] $$ respectively. - -$head Taylor Coefficients Recursion$$ -For orders $latex j = 0 , 1, \ldots$$, -$latex \[ -\begin{array}{rcl} -z^{(0)} & = & F ( x^{(0)} ) -\\ -e^{(0)} & = & d^{(0)} + z^{(0)} -\\ -e^{(j+1)} -& = & d^{(j+1)} + \sum_{k=0}^{j+1} a^{(j+1-k)} * z^{(k)} -\\ -& = & 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)} -\right) -\\ -& = & 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-2018.00.00.0/omh/appendix/theory/exp_reverse.omh cppad-2019.02.00.0/omh/appendix/theory/exp_reverse.omh --- cppad-2018.00.00.0/omh/appendix/theory/exp_reverse.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/exp_reverse.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin exp_reverse$$ -$spell - Taylor - exp - expm -$$ - -$section Exponential Function Reverse Mode Theory$$ -$mindex exp expm1$$ - -We use the reverse theory -$cref%standard math function - %ReverseTheory - %Standard Math Functions -%$$ -definition for the functions $latex H$$ and $latex G$$. -The zero order forward mode formula for the -$cref/exponential/exp_forward/$$ is -$latex \[ - z^{(0)} = F ( x^{(0)} ) -\] $$ -and for $latex j > 0$$, -$latex \[ - 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)} } \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{G}{ x^{(k)} } + \D{G}{ z^{(j)} } \frac{1}{j} k 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} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/forward_theory.omh cppad-2019.02.00.0/omh/appendix/theory/forward_theory.omh --- cppad-2018.00.00.0/omh/appendix/theory/forward_theory.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/forward_theory.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,221 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 ForwardTheory$$ -$spell - Taylor -$$ - -$section The Theory of Forward Mode$$ - -$head Taylor Notation$$ -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 -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 ) -\end{array} -\] $$ -For the purposes of this section, we are given $latex x$$ and $latex y$$ -and need to determine $latex z$$. - -$head Binary Operators$$ - -$subhead Addition$$ -$latex \[ -\begin{array}{rcl} -Z(t) -& = & X(t) + Y(t) -\\ -\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} -\] $$ - -$subhead Subtraction$$ -$latex \[ -\begin{array}{rcl} -Z(t) -& = & X(t) - Y(t) -\\ -\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} -\] $$ - -$subhead Multiplication$$ -$latex \[ -\begin{array}{rcl} -Z(t) -& = & X(t) * Y(t) -\\ -\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} -\] $$ - -$subhead Division$$ -$latex \[ -\begin{array}{rcl} -Z(t) -& = & X(t) / Y(t) -\\ -x -& = & z * y -\\ -\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) -+ -o( t^p ) -\\ -x^{(j)} & = & \sum_{k=0}^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) -\end{array} - -\] $$ - -$head Standard Math Functions$$ -Suppose that $latex F $$ is a standard math function and -$latex \[ - Z(t) = F[ X(t) ] -\]$$ - -$subhead Differential Equation$$ -All of the standard math functions -satisfy a differential equation of the form -$latex \[ - B(u) * F^{(1)} (u) - A(u) * F (u) = D(u) -\] $$ -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$$, -the $th p$$ order Taylor coefficients for $latex X(t)$$. - -$subhead Taylor Coefficients Recursion Formula$$ -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) -\\ -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) -\end{array} -\] $$ -where we define -$latex \[ -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 -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 -$latex z^{(k)}$$ for $latex k = 0 , \ldots , j$$. -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/$$ -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=1}^{j+1} k x^{(k)} * t^{k-1} \right) -+ -o( t^p ) -\\ -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)} -\right) -\\ -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)} -\right) -\end{array} -\] $$ -This completes the induction that computes $latex e^{(j)}$$ -and $latex z^{(j+1)}$$. - - - - -$children% - omh/appendix/theory/exp_forward.omh% - omh/appendix/theory/log_forward.omh% - omh/appendix/theory/sqrt_forward.omh% - omh/appendix/theory/sin_cos_forward.omh% - omh/appendix/theory/atan_forward.omh% - omh/appendix/theory/asin_forward.omh% - omh/appendix/theory/acos_forward.omh% - omh/appendix/theory/tan_forward.omh% - omh/appendix/theory/erf_forward.omh -%$$ - -$subhead Cases that Apply Recursion Above$$ -$table -$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$$ -$table -$rref tan_forward$$ -$tend - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/log_forward.omh cppad-2019.02.00.0/omh/appendix/theory/log_forward.omh --- cppad-2018.00.00.0/omh/appendix/theory/log_forward.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/log_forward.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin log_forward$$ -$spell - Taylor -$$ - -$section Logarithm Function Forward Mode Theory$$ -$mindex log1p$$ - -$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 \[ -\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. -\] $$ -In the -$cref/standard math function differential equation - /ForwardTheory - /Standard Math Functions - /Differential Equation -/$$, -$latex A(x) = 0$$, -$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 -Taylor coefficients for -$latex A [ X (t) ] $$, -$latex B [ X (t) ]$$, -$latex D [ X (t) ] $$, -and $latex F [ X(t) ] $$ respectively. - -$head Taylor Coefficients Recursion$$ -For orders $latex j = 0 , 1, \ldots$$, -$latex \[ -\begin{array}{rcl} -z^{(0)} & = & F ( x^{(0)} ) -\\ -e^{(j)} -& = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} -\\ -& = & \left\{ \begin{array}{ll} - 1 & {\rm if} \; j = 0 \\ - 0 & {\rm otherwise} -\end{array} \right. -\\ -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)} -\right) -\\ -& = & \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)} -\right) -\end{array} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/log_reverse.omh cppad-2019.02.00.0/omh/appendix/theory/log_reverse.omh --- cppad-2018.00.00.0/omh/appendix/theory/log_reverse.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/log_reverse.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin log_reverse$$ -$spell - Taylor -$$ - -$section Logarithm Function Reverse Mode Theory$$ -$mindex log1p$$ - -We use the reverse theory -$cref%standard math function - %ReverseTheory - %Standard Math Functions -%$$ -definition for the functions $latex H$$ and $latex G$$. - -The zero order forward mode formula for the -$cref/logarithm/log_forward/$$ is -$latex \[ - z^{(0)} = F( x^{(0)} ) -\] $$ -and for $latex j > 0$$, -$latex \[ -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)} -\right) -\] $$ -where -$latex \[ -\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. -\] $$ -We note that for $latex j > 0$$ -$latex \[ -\begin{array}{rcl} -\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_{k=1}^{j-1} k z^{(k)} x^{(j-k)} -\right) -\\ -& = & -- -\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-k)} } & = & -\D{G}{ x^{(j-k)} } - - \D{G}{ z^{(j)} } \frac{1}{ \bar{b} + x^{(0)} } \frac{k}{j} z^{(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} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/reverse_identity.omh cppad-2019.02.00.0/omh/appendix/theory/reverse_identity.omh --- cppad-2018.00.00.0/omh/appendix/theory/reverse_identity.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/reverse_identity.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,155 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 reverse_identity$$ -$spell - Taylor - Griewank - Andreas -$$ - - - -$section An Important Reverse Mode Identity$$ -The theorem and the proof below is a restatement -of the results on page 236 of -$cref/Evaluating Derivatives/Bib/Evaluating Derivatives/$$. - -$head Notation$$ -Given a function $latex f(u, v)$$ where $latex u \in B^n$$ -we use the notation -$latex \[ -\D{f}{u} (u, v) = \left[ \D{f}{u_1} (u, v) , \cdots , \D{f}{u_n} (u, v) \right] -\] $$ - -$head Reverse Sweep$$ -When using $cref/reverse mode/reverse_any/$$ -we are given a function $latex F : B^n \rightarrow B^m$$, -a matrix of Taylor coefficients $latex x \in B^{n \times p}$$, -and a weight vector $latex w \in B^m$$. -We define the functions $latex X : B \times B^{n \times p} \rightarrow B^n$$, -$latex W : B \times B^{n \times p} \rightarrow B$$, and -$latex W_j : B^{n \times p} \rightarrow B$$ by -$latex \[ -\begin{array}{rcl} - X(t , x) & = & x^{(0)} + x^{(1)} t + \cdots + x^{(p-1)} t^{p-1} - \\ - W(t, x) & = & w_0 F_0 [X(t, x)] + \cdots + w_{m-1} F_{m-1} [X(t, x)] - \\ - W_j (x) & = & \frac{1}{j!} \Dpow{j}{t} W(0, x) -\end{array} -\]$$ -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) -\] $$ -A $cref/general reverse sweep/reverse_any/$$ calculates the values -$latex \[ - \D{ W_{p-1} }{ x^{(i)} } (x) \hspace{1cm} (i = 0 , \ldots , p-1) -\] $$ -But the return values for a reverse sweep are specified -in terms of the more useful values -$latex \[ - \D{ W_j }{ x^{(0)} } (x) \hspace{1cm} (j = 0 , \ldots , p-1) -\] $$ - -$head Theorem$$ -Suppose that $latex F : B^n \rightarrow B^m$$ is a $latex p$$ times -continuously differentiable function. -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 -$latex y^{(j)} : B^{n \times p }\rightarrow B^m$$ by -$latex \[ -\begin{array}{rcl} - Z(t, x) & = & x^{(0)} + x^{(1)} t + \cdots + x^{(p-1)} t^{p-1} - \\ - Y(t, x) & = & F [ Z(t, 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 -$latex x \in B^{n \times p}$$. -It follows that -for all $latex i, j$$ such that $latex i \leq j < p$$, -$latex \[ -\begin{array}{rcl} -\D{ y^{(j)} }{ x^{(i)} } (x) & = & \D{ y^{(j-i)} }{ x^{(0)} } (x) -\end{array} -\] $$ - - -$head Proof$$ -If follows from the definitions that -$latex \[ -\begin{array}{rclr} -\D{ y^{(j)} }{ x^{(i)} } (x) -& = & -\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) -\right]_{t=0} -\\ -& = & -\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$$ -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] -& = & -\sum_{k=0}^i -\left( \begin{array}{c} j \\ k \end{array} \right) -\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] -\right\}_{t=0} -& = & -\left( \begin{array}{c} j \\ i \end{array} \right) -i ! \Dpow{j-i}{t} ( F^{(1)} \circ Z ) (t, x) -\\ -& = & -\frac{ j ! }{ (j - i) ! } -\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} -\] $$ -Applying this formula to the case where $latex j$$ -is replaced by $latex j - i$$ and $latex i$$ is replaced by zero, -we obtain -$latex \[ -\D{ y^{(j-i)} }{ x^{(0)} } (x) -= -\frac{ 1 }{ (j - i) ! } -\Dpow{j-i}{t} ( F^{(1)} \circ Z ) (t, x) -= -\D{ y^{(j)} }{ x^{(i)} } (x) -\] $$ -which completes the proof - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/reverse_theory.omh cppad-2019.02.00.0/omh/appendix/theory/reverse_theory.omh --- cppad-2018.00.00.0/omh/appendix/theory/reverse_theory.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/reverse_theory.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,183 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 ReverseTheory$$ -$spell - Taylor - Arctangent -$$ - -$section The Theory of Reverse Mode$$ - -$head Taylor Notation$$ -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 -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} ) -\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 -$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) = - G ( z^{(j)}, z^{(j-1)} , \ldots , z^{(0)}, x , y ) -\] $$ -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 -$latex \[ - z^{(j)} ( z^{(j-1)} , \ldots , z^{(0)}, x, y ) -\] $$ -If we do not provide a formula for -a partial derivative of $latex H$$, then that partial derivative -has the same value as for the function $latex G$$. - -$head Binary Operators$$ - -$subhead Addition$$ -The forward mode formula for -$cref/addition/ForwardTheory/Binary Operators/Addition/$$ is -$latex \[ - z^{(j)} = x^{(j)} + y^{(j)} -\] $$ -If follows that for $latex k = 0 , \ldots , j$$ -and $latex l = 0 , \ldots , j-1$$ -$latex \[ -\begin{array}{rcl} -\D{H}{ x^{(k)} } & = & -\D{G}{ x^{(k)} } + \D{G}{ z^{(k)} } \\ -\\ -\D{H}{ y^{(k)} } & = & -\D{G}{ y^{(k)} } + \D{G}{ z^{(k)} } -\\ -\D{H}{ z^{(l)} } & = & \D{G}{ z^{(l)} } -\end{array} -\] $$ - -$subhead Subtraction$$ -The forward mode formula for -$cref/subtraction/ForwardTheory/Binary Operators/Subtraction/$$ is -$latex \[ - z^{(j)} = x^{(j)} - y^{(j)} -\] $$ -If follows that for $latex k = 0 , \ldots , j$$ -$latex \[ -\begin{array}{rcl} -\D{H}{ x^{(k)} } & = & -\D{G}{ x^{(k)} } - \D{G}{ z^{(k)} } \\ -\\ -\D{H}{ y^{(k)} } & = & -\D{G}{ y^{(k)} } - \D{G}{ z^{(k)} } -\end{array} -\] $$ - -$subhead Multiplication$$ -The forward mode formula for -$cref/multiplication/ForwardTheory/Binary Operators/Multiplication/$$ is -$latex \[ - z^{(j)} = \sum_{k=0}^j x^{(j-k)} * y^{(k)} -\] $$ -If follows that for $latex k = 0 , \ldots , j$$ -and $latex l = 0 , \ldots , j-1$$ -$latex \[ -\begin{array}{rcl} -\D{H}{ x^{(j-k)} } & = & -\D{G}{ x^{(j-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} -\] $$ - -$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)} -\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{H}{ z^{(j-k)} } & = & -\D{G}{ z^{(j-k)} } - \D{G}{ z^{(j)} } \frac{1}{y^{(0)}} y^{(k)} -\\ -\D{H}{ y^{(k)} } & = & -\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)} -\right) -\\ -& = & -\D{G}{ y^{(0)} } - \D{G}{ z^{(j)} } \frac{1}{y^{(0)}} z^{(j)} -\end{array} -\] $$ - -$head Standard Math Functions$$ -The standard math functions have only one argument. -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) = - G ( z^{(j)}, z^{(j-1)} , \ldots , z^{(0)}, x) -\] $$ -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 -$latex \[ - z^{(j)} ( z^{(j-1)} , \ldots , z^{(0)}, x ) -\] $$ - - -$childtable% - omh/appendix/theory/exp_reverse.omh% - omh/appendix/theory/log_reverse.omh% - omh/appendix/theory/sqrt_reverse.omh% - omh/appendix/theory/sin_cos_reverse.omh% - omh/appendix/theory/atan_reverse.omh% - omh/appendix/theory/asin_reverse.omh% - omh/appendix/theory/acos_reverse.omh% - omh/appendix/theory/tan_reverse.omh% - omh/appendix/theory/erf_reverse.omh -%$$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/sin_cos_forward.omh cppad-2019.02.00.0/omh/appendix/theory/sin_cos_forward.omh --- cppad-2018.00.00.0/omh/appendix/theory/sin_cos_forward.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/sin_cos_forward.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,105 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin sin_cos_forward$$ -$spell - sin - cos - sinh - cosh - Taylor -$$ - - -$section Trigonometric and Hyperbolic Sine and Cosine Forward Theory$$ -$mindex sin sinh cos cosh$$ - -$head Differential Equation$$ -The -$cref/standard math function differential equation - /ForwardTheory - /Standard Math Functions - /Differential Equation -/$$ -is -$latex \[ - B(u) * F^{(1)} (u) - A(u) * F (u) = D(u) -\] $$ -In this sections we consider forward mode for the following choices: - -$table -$pre $$ - $cnext $cnext $latex F(u)$$ - $cnext $cnext $latex \sin(u)$$ - $cnext $cnext $latex \cos(u)$$ - $cnext $cnext $latex \sinh(u)$$ - $cnext $cnext $latex \cosh(u)$$ -$rnext - $cnext $cnext $latex A(u)$$ - $cnext $cnext $latex 0$$ - $cnext $cnext $latex 0$$ - $cnext $cnext $latex 0$$ - $cnext $cnext $latex 0$$ -$rnext - $cnext $cnext $latex B(u)$$ - $cnext $cnext $latex 1$$ - $cnext $cnext $latex 1$$ - $cnext $cnext $latex 1$$ - $cnext $cnext $latex 1$$ -$rnext - $cnext $cnext $latex D(u)$$ - $cnext $cnext $latex \cos(u)$$ - $cnext $cnext $latex - \sin(u)$$ - $cnext $cnext $latex \cosh(u)$$ - $cnext $cnext $latex \sinh(u)$$ -$tend - -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 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$$, -$latex \[ -\begin{array}{rcl} -f^{(0)} & = & D ( x^{(0)} ) -\\ -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)} } -\left( - \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)} -\end{array} -\] $$ -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) ]$$. - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/sin_cos_reverse.omh cppad-2019.02.00.0/omh/appendix/theory/sin_cos_reverse.omh --- cppad-2018.00.00.0/omh/appendix/theory/sin_cos_reverse.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/sin_cos_reverse.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin sin_cos_reverse$$ -$spell - Taylor - cos -$$ - -$section Trigonometric and Hyperbolic Sine and Cosine Reverse Theory$$ -$mindex sin sinh cos cosh$$ - - -We use the reverse theory -$cref%standard math function - %ReverseTheory - %Standard Math Functions -%$$ -definition for the functions $latex H$$ and $latex G$$. -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$$ - $cnext $cnext $latex \ell$$ -$rnext -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) ]$$ - $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/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)} ) -\\ -c^{(j)} & = & \frac{1 + \ell}{2} \cos ( x^{(0)} ) - + \frac{1 - \ell}{2} \cosh ( x^{(0)} ) -\end{array} -\] $$ - -for the case $latex j = 0$$, and for $latex j > 0$$, - -$latex \[ -\begin{array}{rcl} -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)} -\end{array} -\] $$ - -If $latex j = 0$$, we have the relation - -$latex \[ -\begin{array}{rcl} -\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{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{G}{ s^{(j-k)} } + \ell \D{G}{ c^{(j)} } k x^{(k)} -\\ -\D{H}{ c^{(j-k)} } & = & -\D{G}{ c^{(j-k)} } + \D{G}{ s^{(j)} } k x^{(k)} -\end{array} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/sqrt_forward.omh cppad-2019.02.00.0/omh/appendix/theory/sqrt_forward.omh --- cppad-2018.00.00.0/omh/appendix/theory/sqrt_forward.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/sqrt_forward.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -// BEGIN SHORT COPYRIGHT -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT - -$begin sqrt_forward$$ -$spell - sqrt - Arctangent - Taylor -$$ - -$section Square Root Function Forward Mode Theory$$ -$mindex sqrt$$ - -If $latex F(x) = \sqrt{x} $$ -$latex \[ - F(x) * F^{(1)} (x) - 0 * F (x) = 1/2 -\] $$ -and in the -$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 -Taylor coefficients for -$latex A [ X (t) ] $$, -$latex B [ X (t) ]$$, -$latex D [ X (t) ] $$, -and $latex F [ X(t) ] $$ respectively. -It now follows from the general -$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)} -& = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} -\\ -& = & \left\{ \begin{array}{ll} - 1/2 & {\rm if} \; j = 0 \\ - 0 & {\rm otherwise} -\end{array} \right. -\\ -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)} -\right) -\\ -& = & \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)} -\right) -\end{array} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/sqrt_reverse.omh cppad-2019.02.00.0/omh/appendix/theory/sqrt_reverse.omh --- cppad-2018.00.00.0/omh/appendix/theory/sqrt_reverse.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/sqrt_reverse.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 sqrt_reverse$$ -$spell - sqrt - Taylor -$$ - -$section Square Root Function Reverse Mode Theory$$ -$mindex sqrt$$ - - -We use the reverse theory -$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/sqrt_forward/$$ -function are -$latex \[ - 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)} } -\left( - \frac{j}{2} x^{(j) } - - \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{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} } -\\ -& = & -\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \frac{1}{2 z^{(0)} } -\end{array} -\] $$ - -If $latex j > 0$$, then for $latex k = 1, \ldots , j-1$$ - -$latex \[ -\begin{array}{rcl} -\D{H}{ z^{(0)} } & = & -\D{G}{ z^{(0)} } + \D{G} { z^{(j)} } \D{ z^{(j)} }{ z^{(0)} } -\\ -& = & -\D{G}{ z^{(0)} } - -\D{G}{ z^{(j)} } \frac{ z^{(j)} }{ z^{(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}{ 2 z^{(0)} } -\\ -\D{H}{ z^{(k)} } & = & -\D{G}{ z^{(k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ z^{(k)} } -\\ -& = & -\D{G}{ z^{(k)} } - \D{G}{ z^{(j)} } \frac{ z^{(j-k)} }{ z^{(0)} } -\end{array} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/tan_forward.omh cppad-2019.02.00.0/omh/appendix/theory/tan_forward.omh --- cppad-2018.00.00.0/omh/appendix/theory/tan_forward.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/tan_forward.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 tan_forward$$ -$spell - Taylor -$$ - - -$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 -\\ -\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 -$latex \[ - F^{(1)} (u) = 1 \pm F(u)^2 -\]$$ -Given $latex X(t)$$, we define the function $latex Z(t) = F[ X(t) ]$$. -It follows that -$latex \[ -Z^{(1)} (t) = F^{(1)} [ X(t) ] X^{(1)} (t) = [ 1 \pm Y(t) ] X^{(1)} (t) -\] $$ -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 -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)$$. -Using the equation above for $latex Z^{(1)} (t)$$, we have -$latex \[ -\begin{array}{rcl} -\sum_{k=1}^j k z^{(k)} t^{k-1} -& = & -\sum_{k=1}^j k x^{(k)} t^{k-1} -\pm -\left[ \sum_{k=0}^{j-1} y^{(k)} t^k \right] -\left[ \sum_{k=1}^j k x^{(k)} t^{k-1} \right] -+ -o( t^{j-1} ) -\end{array} -\] $$ -Setting the coefficients of $latex t^{j-1}$$ equal, we have -$latex \[ -\begin{array}{rcl} -j z^{(j)} -= -j x^{(j)} -\pm -\sum_{k=1}^j k x^{(k)} y^{(j-k)} -\\ -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 \[ -y^{(j)} = \sum_{k=0}^j z^{(k)} z^{(j-k)} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/tan_reverse.omh cppad-2019.02.00.0/omh/appendix/theory/tan_reverse.omh --- cppad-2018.00.00.0/omh/appendix/theory/tan_reverse.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/tan_reverse.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 tan_reverse$$ -$spell - Taylor -$$ - - -$section Tangent and Hyperbolic Tangent Reverse Mode Theory$$ -$mindex tan$$ - -$head Notation$$ -We use the reverse theory -$cref/standard math function/ReverseTheory/Standard Math Functions/$$ -definition for the functions $latex H$$ and $latex G$$. -In addition, we use the forward mode notation in $cref tan_forward$$ for -$latex X(t)$$, $latex Y(t)$$ and $latex Z(t)$$. - -$head Eliminating Y(t)$$ -For $latex j > 0$$, the forward mode coefficients are given by -$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 -coefficients for $latex Z(t)$$. -To be specific, for $latex k = 0 , \ldots , j-1$$, -$latex \[ -\begin{array}{rcl} -\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} -\] $$ - - -$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 -the coefficients for $latex X(t)$$, and the -lower order Taylor coefficients for $latex Y(t)$$, $latex Z(t)$$. -$latex \[ -z^{(j)} -= -x^{(j)} \pm \frac{1}{j} \sum_{k=1}^j k x^{(k)} y^{(j-k)} -\] $$ -For $latex k = 1 , \ldots , j$$, -the partial of $latex H$$ with respect to $latex x^{(k)}$$ is given by -$latex \[ -\begin{array}{rcl} -\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)} } -\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$$ -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{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)$$ -The order zero coefficients for the tangent and hyperbolic tangent are -$latex \[ -\begin{array}{rcl} -z^{(0)} & = & \left\{ - \begin{array}{c} \tan ( x^{(0)} ) \\ \tanh ( x^{(0)} ) \end{array} -\right. -\end{array} -\] $$ -Suppose that $latex H$$ is the same as $latex G$$ except that -$latex z^{(0)}$$ is expressed as a function of the Taylor coefficients -for $latex X(t)$$. -In this case, -$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)} } ( 1 \pm y^{(0)} ) -\end{array} -\] $$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/theory/theory.omh cppad-2019.02.00.0/omh/appendix/theory/theory.omh --- cppad-2018.00.00.0/omh/appendix/theory/theory.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/theory/theory.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 Theory$$ - -$section The Theory of Derivative Calculations$$ - -$contents% - omh/appendix/theory/forward_theory.omh% - omh/appendix/theory/reverse_theory.omh% - omh/appendix/theory/reverse_identity.omh%$$ - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/03.omh cppad-2019.02.00.0/omh/appendix/whats_new/03.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/03.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/03.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,778 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_03$$ +$spell + dir + Eq.cpp + cppad.hpp + Hess + Taylor + Def + indvar + bool + CppADvector + ADdouble + sqrt + atan + exp + valarray + Faq + Lu + Det + Cpp + Microsoft + mak + std + Cygwin + Var + const + namespace + Geq + Leq + ini +$$ + +$section Changes and Additions to CppAD During 2003$$ + +$head Introduction$$ +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. + +$head 12-24$$ +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. + +$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 +$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 +one is using the Microsoft C++ compiler. + + +$head 12-14$$ +The extended system solvers $code OdeOne$$ and $code OdeTwo$$ have +been removed from the distribution. +In addition, the interface to the ODE solvers have been simplified. + +$head 12-13$$ +Remove the $code CppADCreateTape$$ macro +and have the tapes created and grow automatically. + + +$head 12-12$$ +The old method where one directly accesses the tape has been removed and the +following functions are no longer available: +$codei% + size_t %TapeName%.Independent(AD<%Base%> &%indvar%) + size_t %TapeName%.Record(size_t %order%) + size_t %TapeName%.Stop(void) + bool Dependent(const AD<%Base%> &%var%) const + bool %TapeName%.Dependent(const AD<%Base%> &%var%) const + size_t %TapeName%.Total(void) const + size_t %TapeName%.Required(void) const + size_t %TapeName%.Erase(void) + TapeState %TapeName%.State(void) const + size_t %TapeName%.Order(void) const + size_t %TapeName%.Required(void) const + bool Parameter(CppADvector< AD<%Base%> > &%u%) + %TapeName%.Forward(%indvar%) + %TapeName%.Reverse(%var%) + %TapeName%.Partial(%var%) + %TapeName%.ForwardTwo(%indvar%) + %TapeName%.ReverseTwo(%var%) + %TapeName%.PartialTwo(%var%) +%$$ + + +$head 12-10$$ +The change on $cref/12-01/whats_new_03/12-01/$$ make the taping process simpler +if one does not directly access +$code CppADCreateTape$$. +The $cref/examples/example/$$ were changed to not use +$icode TapeName$$. +The following examples were skipped because +they document the functions that access $icode TapeName$$: +$code DefFun.cpp$$, +$code For.cpp$$, +$code for_two.cpp$$, +$code Rev.cpp$$, and +$code rev_two.cpp$$. + +$head 12-05$$ +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. +$pre + +$$ +The ODE Example was changed to tape the solution +(and not use $code OdeOne$$ or $code OdeTwo$$). +This is simpler to use and +the resulting speed tests gave much faster results. + +$head 12-01$$ +The following function has been added: +$codei% + void Independent(const CppADvector<%Base%> &%x%) +%$$ +which will declare the independent variables and begin recording +$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 +$cref ADFun$$ object. +In addition, the tape no longer needs to be specified in the constructor. + + +$head 11-21$$ +Add $code StiffZero$$ to set of ODE solvers. + + +$head 11-20$$ +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$$ +and $code AD$$ use of +$code LuSolve$$ more complex. +$pre + +$$ +The member function names for the +$icode fun$$ argument to ODE were changed from +$icode%fun%.f%$$ to +$icode%fun%.Ode%$$ +and from +$icode%fun%.g%$$ to +$icode%fun%.Ode_ini%$$. + + +$head 11-16$$ +The +$cref/table of contents/_contents/$$ was reorganized +to provide a better grouping of the documentation. +$pre + +$$ +The $cref LuSolve$$ utility is now part of the distribution +and not just an example; i.e., +it is automatically included by +$code cppad.hpp$$. + + +$head 11-15$$ +The +ODE solver was modified so that it can +be used with any type (not just an AD type. +This was useful for the speed testing. +It is also useful for determining how the integrator +steps should be before starting the tape. +$pre + +$$ +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 +$code speed_cppad/OdeSpeed.cpp/$$ test was added +and some changes were made to the +ODE interface in order to make it faster. +The most significant change was in the specifications for +the ODE function object $icode fun$$. + + +$head 11-12$$ +The user defined unary function example +$code example/UnaryFun.cpp$$ was incorrect. +It has been corrected and extended. + +$head 11-11$$ +The $cref/CppAD::vector/CppAD_vector/$$ template class is now +used where the $code std::vector$$ template class was previously used. +You can replace the $code CppAD::vector$$ class +with a vector template class of your choosing during the +$cref Install$$ procedure. + +$head 11-06$$ +The documentation for +$cref/taping derivative calculations/mul_level/$$ was improved +as well as the corresponding example. +In order to make this simpler, +the example tape name $code DoubleTape$$ was changed to $code ADdoubleTape$$ +(and the other example tape names were also changed). + +$head 11-04$$ +The ODE utility was changed from an example to +part of the distribution. +In addition, it was extended so that it now supports taping the +solution of the differential equations (case $icode order$$ equal zero) +or solving the extended set of differential equations +for both first and second derivatives (cases $icode order$$ equal +one and two). +In addition, an initial condition that depends on the parameter +values is also allowed. + + + +$head 11-02$$ +It is now legal to differentiate a +$cref/parameter/glossary/Parameter/$$ +with respect to an +$cref/independent variable/glossary/Tape/Independent Variable/$$ +(parameter derivatives are always equal to zero). +This is an extension of the +$code Reverse$$, +$code Partial$$, +$code ReverseTwo$$, and +$code PartialTwo$$ +functions. + +$head 10-21$$ +All the $code CppAD$$ include files, +except $code cppad.hpp$$ were moved into an $code include$$ subdirectory. + + + +$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 +tape only supports partial derivatives. + +$head 10-14$$ +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. +$pre + +$$ +The $cref Value$$ function was changed so that it can +be called when the tape is in the Empty state. + +$head 10-10$$ +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$$ +are parameters that are exactly equal to zero and one. +If the variables $icode z$$ and $icode x$$ +were related in any of the following ways, +they share can share the same record on the tape +because they will have the same derivatives. +$codei% + %z% = %x% + %zero% %z% = %x% * %one% + %z% = %zero% + %x% %z% = %one% * %x% + %z% = %x% - %zero% %z% = %x% / %one% +%$$ +Furthermore, in the following cases, the result +$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 +all checked to make sure they did not add to the tape +in these special cases. +The total record count for the program in the Example directory +was 552 before this change +and 458 after. + +$head 10-05$$ +The process of converting the tape to operators was completed. +In order to make this conversion, the binary user defined +functions were removed. +(Bob Goddard +suggested a very nice way to keep the unary functions.) +Another significant change was made to the user interface during this procedure, +the standard math library functions +are now part of the CppAD distribution and not defined by the user. +$pre + +$$ +The function $icode%TapeName%.Total%$$ was added +to make it easy to track how many tape records are used by +the test suite. +This will help with future optimization of the CppAD recording process. +$pre + +$$ +There was a bug +(found by $href%mailto:magister@u.washington.edu%Mike Dodds%$$) +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, +the program would abort. +This has been fixed. + + +$head 09-30$$ +A process of changing the tape from storing partial derivatives to +storing operators has been started. +This will make the tape smaller and it will enable the computation +of higher derivatives with out having to tape the tape +(see $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. +$pre + +$$ +There was a bug in reverse mode when an dependent variable +was exactly equal to an independent variable. +In this case, it was possible for it to be located +before other of the independent variables on the tape. +These other independent variable partials were not initialized +to zero before the reverse calculation and hence had what ever +value was left by the previous mode calculation. +This has been fixed and the +$code Eq.cpp$$ example has been changed to test for this case. +$pre + +$$ +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$$, +$code Required$$, +$code Dependent$$, and +$cref/Parameter/con_dyn_var/Parameter/$$. + +$head 09-20$$ +The functions $code Grad$$ and $code Hess$$ were +changed to use function objects +instead of function pointers. + + +$head 09-19$$ +The higher order constructors (in standard valarray) were removed from the +ODE example in order to avoid memory allocation of temporaries +(and hence increase speed). +In addition, the function objects in the +ODE examples were changed to be $code const$$. + +$head 09-18$$ +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. +This was fixed by have the destructor use $code RemoveFromVarList$$ +to remove variables from the list. +($code RemoveFromVarList$$ is a private AD member function +not visible to the user.) + +$head 09-14$$ +There is a new Faq question about evaluating derivatives at multiple +values for the +$cref/independent variables/Faq/Independent Variables/$$. + +$head 09-13$$ +An example that uses +$code AD< AD >$$ +to compute higher derivatives was added. +$pre + +$$ +The name $code GaussEliminate$$ was changed to +$cref LuSolve$$ to better reflect the solution method. + +$head 09-06$$ +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.) + +$head 09-05$$ +A $cref/getting started/get_started.cpp/$$ +example was added and the organization +of the $cref/Examples/example/$$ was changed. + +$head 09-04$$ +The $code AbsOfDoubleNotDefine$$ flag is no longer used +and it was removed from the Windows +$cref/install/Install/$$ instructions. +$pre + +$$ +The 03-09-03 distribution did not have the proper date +attached to it. +The distribution script has been changed so that attaching +the proper date is automated +(i.e., this should not happen again). +$pre + +$$ +A $tref faq$$ section was started. + +$head 09-03$$ +Added the +$cref Value$$ function which returns +the $cref/base type/glossary/Base Type/$$ value +corresponding to an AD object. + +$head 08-23$$ +A new version of Cygwin was installed on the development system +(this may affect the timing tests reported in this document). +In addition, $cref LuSolve$$ was changed to use back substitution +instead of reduction to an identity matrix. This reduced the number +of floating point operations corresponding to evaluation of the determinant. +The following results correspond to the speed test +of DetLu on a 9 by 9 matrix: +$table +$bold Version$$ + $cnext $bold double Rate$$ + $cnext $bold AD Rate$$ + $cnext $bold Gradient Rate$$ + $cnext $bold Hessian Rate$$ + $cnext $bold Tape Length$$ +$rnext +03-08-20 + $cnext 8,524 + $cnext 5,278 + $cnext 4,260 + $cnext 2,450 + $cnext 532 +$rnext +03-08-23 + $cnext 7,869 + $cnext 4,989 + $cnext 4,870 + $cnext 2,637 + $cnext 464 +$tend + +$head 08-22$$ +The +$cref/unary minus/UnaryMinus/$$ operator was added to the AD operations. + + +$head 08-19$$ +The standard math function +examples were extended to include the complex case. +$pre + +$$ +The +$cref LuSolve$$ +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$$ +with $code LuSolve$$. +$pre + +$$ +When testing the speed of the change to using standard vector, +it was noticed that the LuSolve routine +was much slower. (see times for 03-08-16 below). +This was do to computing the determinant instead of the log +of the determinant. +Converting back to the log of the determinant regained +the high speeds. +The following results correspond to the speed test +of DetLu on a 9 by 9 matrix: +$table +$bold Version$$ + $cnext $bold double Rate$$ + $cnext $bold AD Rate$$ + $cnext $bold Gradient Rate$$ + $cnext $bold Hessian Rate$$ + $cnext $bold Tape Length$$ +$rnext +03-08-16 + $cnext 9,509 + $cnext 5,565 + $cnext 3,587 + $cnext 54 + $cnext 537 +$rnext +03-08-19 + $cnext 8,655 + $cnext 5,313 + $cnext 4,307 + $cnext 2,495 + $cnext 532 +$tend + + +$head 08-17$$ +The macro +$code CppADTapeOverflow$$ was added +so that CppAD can check for tape overflow +even in the $code NDEBUG$$ preprocessor flag is defined. + +$head 08-16$$ +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 +$cref/boolean valued functions with AD arguments/BoolFun/$$. +The examples +$cref lu_solve.cpp$$ +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 +differentiating linear algebra calculations. +The following results correspond to the speed test +of DetLu on a 9 by 9 matrix: +$table +$bold Version$$ + $cnext $bold double Rate$$ + $cnext $bold AD Rate$$ + $cnext $bold Gradient Rate$$ + $cnext $bold Hessian Rate$$ + $cnext $bold Tape Length$$ +$rnext +03-08-10 + $cnext 49,201 + $cnext 7,787 + $cnext 2,655 + $cnext 1,809 + $cnext 824 +$rnext +03-08-11 + $cnext 35,178 + $cnext 12,681 + $cnext 4,521 + $cnext 2,541 + $cnext 540 +$tend +In addition the corresponding test case +$cref lu_solve.cpp$$ was changed to a Hilbert matrix case. + + + +$head 08-10$$ +A $cref/complex polynomial/complex_poly.cpp/$$ +example was added. +$pre + +$$ +The documentation and type conversion in +$cref LuSolve$$ was improved. +$pre + +$$ +The absolute value function was removed from the examples because +some systems do not yet properly support $codei%double abs(double %x%)%$$, + + +$head 08-07$$ +Because the change to the multiplication operator had such +a large positive effect, +all of the +$cref/arithmetic operators/Arithmetic/$$ +were modified to reduce the amount of information +in the tape (where possible). + +$head 08-06$$ +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 +advantage of this fact. +This reduced the size of the tape and increased the speed +for the calculation of the gradient and Hessian for +the Lu determinant test of a 5 by 5 matrix as follows: +$table +$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 +03-08-06 $cnext 167 $cnext 12,780 $cnext 10,625 +$tend + +$head 08-05$$ +Fixed a mistake in the calculation of the sign of the determinant in +the $cref LuSolve$$ example. + +$head 08-04$$ +Added a the compiler flag +$codep + AbsOfDoubleNotDefined +$$ +to the make files so that it could be removed on systems where the +function +$codei% + double abs(double %x%) +%$$ was defined in $code math.h$$. + +$head 08-03$$ +The +$code Grad$$ and $code Hess$$ functions were modified +to handel the case where the function does not depend on +the independent variables. +$pre + +$$ +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 +$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. +$pre + +$$ +The $cref/<%$$ data structure +was changed to include a doubly linked list of variables. +This enabled the +$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 +the determinant of a 5 by 5 matrix as follows: +$table +$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 +03-07-26 $cnext 436 $cnext 3,436 $cnext 213 +$tend + + +$head 07-22$$ +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.) +$pre + +$$ +The Windows version make file directive $code /I ..\..$$ +in $code example\Example.mak$$ and $code Speed\Speed.mak$$ +was changed to $code /I ..$$ (as it should have been). + + + +$head 07-20$$ +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$$.) +$pre + +$$ +The first Alpha for the Windows +$cref/installation/Install/$$ was released. + +$head 07-18$$ +Computing the determinant of a minor of a matrix +$cref det_of_minor$$ +was documented as a realistic example using CppAD. + + +$head 07-16$$ +Fixed some non-standard constructions that caused problems +with the installation on other machines. +$pre + +$$ +Compiled and ran the tests under Microsoft Windows. +(The Windows release should not take much more work.) + +$head 07-14$$ +First Alpha release of CppAD +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. + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/04.omh cppad-2019.02.00.0/omh/appendix/whats_new/04.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/04.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/04.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1022 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_04$$ +$spell + autotools + cppad.hpp + deps + executables + Runge + Rhs + aclocal + config + Makefile + ublas + Autoconf + Automake + cppad + yy + mm + dd + Faq + acos + asin + sqrt + exp + usr + nmake + mak + namespace + CppADvector + atan + cos + retape + Vec + const + std + Hess + depricated + Det + Lu + dsp + Arg + Cpp + Microsoft + Taylor + dep + ind +$$ + +$section Changes and Additions to CppAD During 2004$$ + +$head Introduction$$ +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 +assist you in learning about changes between various versions. + + +$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 +$code cppad/vector.hpp$$ was included. + +$head 12-09$$ +The $cref LuSolve$$ and $code OdeRunge$$ source code +was modified to make the more in line with the introduction +to C++ AD book +($code OdeRunge$$ has been replaced by $cref Runge45$$). +In addition, the examples $code OdeRunge.cpp$$ and +$cref lu_solve.cpp$$ were modified to make the simpler. +(The more complex version of $code OdeRunge.cpp$$ +was moved to the $code TestMore$$ directory.) + +$head 12-03$$ +The $cref Poly$$ documentation and source code were modified to +make them more in line with the introduction to C++ AD book. + +$head 11-17$$ +Changing to Autoconf and Automake on +$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 +because a declaration of $code LessThanOrZero$$ was missing. +This has been fixed. + +$head 11-15$$ +The $cref ForOne$$ and $cref RevOne$$ +easy to use $cref/drivers/Drivers/$$ were added. + +$head 11-14$$ +The notation in the $cref ADFun$$ sections was changed +to make the $cref Forward$$ and $cref Reverse$$ routines +easier to use. + + +$head 11-13$$ +The Taylor coefficient vector and matrix notation was folded into +just $cref/Taylor coefficients/glossary/Taylor Coefficient/$$. + +$head 11-12$$ +If $code NDEBUG$$ is not defined during compile time, +all $codei%AD<%Base%>%$$ +$cref/comparison/Compare/$$ operations are checked during +$cref/zero order/forward_zero/$$ forward mode calculations. +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 +$cref Jacobian$$ driver. +In addition, more $cref/index/_index/$$ entries, +that point to the $cref/easy to use drivers/Drivers/$$, +were added. + +$head 11-04$$ +The Microsoft Visual Studio +project file $code example/Example.dsp/$$ was missing some +new examples that needed to be linked in +the install windows procedure. +This has been fixed. + +$head 11-02$$ +The $cref/unix installation/autotools/$$ 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 +$code PrintFor/.deps$$ and +$code PrintFor/.deps/PrintFor.Po$$ had an extra $code ?$$ +at the end of their names. +This seems to have been fixed by using a newer version of the autoconf +and automake tools. + +$head 10-29$$ +Add the example and test $cref simple_vector.cpp$$ +to the $cref SimpleVector$$ documentation. +$pre + +$$ +The specifications for +$cref/preprocessor symbols/preprocessor/$$ +state that all the CppAD preprocessor symbols +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 +$cref hes_lu_det.cpp$$, +$cref hes_minor_det.cpp$$, +$cref jac_lu_det.cpp$$, +and +$cref jac_minor_det.cpp$$ used the negative of a $code size_t$$ value. +The value has been changed to an $code int$$. +$pre + +$$ +The $cref/CppAD::vector/CppAD_vector/$$ template class +was converted into a library routine so it can be used +separately from the rest of CppAD. + +$head 10-27$$ +The $cref PrintFor$$ example was moved to its own directory +because the conversion from VC 6.0 to VC 7.0 projects +did not work when there were multiple executables in one project file. +The $cref install$$ instructions were modified to reflect this change. + +$head 10-21$$ +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. + +$head 10-19$$ +The current version of CppAD has a problem compiling under Microsoft +Visual C++ version 7.0 (it compiles and works under version 6.0). +The problem appears to be due to a closer agreement between VC 7.0 and the +C++ standard for declaring templates functions as friends. +Some friend declarations were removed and others were made more specific +in order to migrate the a version that will compile and run using VC 7.0. + +$head 10-16$$ +The example $cref compare.cpp$$ displayed the text from +$cref bool_fun.cpp$$ by mistake. +This has been fixed. +$pre + +$$ +The $cref Compare$$ operators have been extended to work with +$code int$$ operands. + +$head 10-06$$ +The test +$code TapeDetLu$$ was added to $code speed_cppad/DetLuSpeed.cpp$$ +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 +from the derivative calculation time. +$pre + +$$ +The +windows installation steps +do not build a $code config.h$$ file. +Hence a default $code config.h$$ file was added to the +distribution for use with Microsoft Visual Studio. +$pre + +$$ +The $code Distribute$$ section of the +developer documentation was brought up to date. +$pre + +$$ +Links to the ADOLC and FADBAD download pages were added +to the $cref/unix installation/autotools/$$ instructions. + +$head 09-29$$ +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. + +$head 09-26$$ +The routine $code OdeRunge$$ was modified +so that it will now integrate functions of a complex arguments. +This was done by removing +all uses of greater than and less than comparisons were removed. +($code OdeRunge$$ has been replaced by $cref Runge45$$). +$pre + +$$ +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/autotools/$$ +$code make$$ command. + + +$head 09-23$$ +There was a reference to $icode B$$ that should have been $icode X$$ +in the description of the +$cref/X/LuSolve/X/$$ argument of $code LuSolve$$. +This has been fixed. + +$head 09-21$$ +The $cref CondExp$$ function has been modified so that it works properly +for $codei%AD< AD<%Base%> >%$$ types; i.e., +it now works for multiple levels of taping. +$pre + +$$ +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/autotools/$$ +to try to run $code autoconf$$ +and this did not work on systems with very old versions of $code autoconf$$. +This has been fixed. + + +$head 09-13$$ +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$$ +in the documentation tree. + +$head 09-10$$ +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 + +$$ +The $icode Base$$ type requirements were simplified. +$pre + +$$ +The $cref/Unix installation/autotools/$$ 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). + +$head 09-09$$ +The $cref PrintFor$$ function was added so that +users can debug the computation of function values +at arguments that are different from those used when taping. + +$head 09-07$$ +In the $cref/Unix installation/autotools/$$ 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 +in the default executable path). + + +$head 09-04$$ +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 +$codei%%$$ were moved to +$codei%%$$. + +$head 09-02$$ +Some more messages were added to the output of $code configure$$ +during the $cref/Unix installation/autotools/$$. +$pre + +$$ +The suggested compression program during +Windows installation +was changed from +$href% + http://www.7-zip.org% + 7-zip +%$$ +to +$href% + http://www.winzip.com% + WinZip +%$$. + + +$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 +date for the current version. +This has been fixed. +$pre + +$$ +All the correctness tests are now compiled with the $code -g$$ +command line option +(the speed tests are still compiled with $code -O2 -DNDEBUG$$). +$pre + +$$ +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 +either the $code std::vector$$ +or $code boost::numeric::ublas::vector$$. + +$head 08-24$$ +This date marks the first release that uses +the Gnu tools Autoconf and Automake. +This automates the building of the make files for the +$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 +has its own directory and +the distribution directory is named +$codei% + cppad-%yy%-%mm%-%dd% +%$$ +where $icode%yy%-%mm%-%dd%$$ is the year, month and date +of the distribution. +(Note the distribution directory is different from the directory +where CppAD is finally installed.) + + +$head 08-12$$ +Move $code OdeExplicit$$ into the $code cppad/library/$$ directory. +In addition, change it so that the vector type was a template argument; i.e., +works for any type of vector (not just $code CppADvector$$). + +$head 07-31$$ +Move $cref LuSolve$$ into the $code cppad/library/$$ directory. +In addition, change it so that the vector type was a template argument; i.e., +works for any type of vector (not just $code CppADvector$$). + + +$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. + +$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/utilities/utility/$$. + +$head 07-03$$ +The CppAD error macros names +$code CppADExternalAssert$$ and $code CppADInternalAssert$$ +were changed to +$code CppADUsageError$$ and $code CppADUnknownError$$. +The $cref SpeedTest$$ routine was changed to use $code CppADUsageError$$ +instead of a C assert. + +$head 07-02$$ +The $cref SpeedTest$$ output was improved so that the columns of +values line up. Previously, this was not the case when +the number of digits in the size changed. + +$head 06-29$$ +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 +$cref/independent function/Independent/$$ +was added to the +$cref/Faq/Faq/Assignment and Independent/$$. +In addition, +a similar discussion +was added to the documentation for the +$cref Independent$$ function. +$pre + +$$ +The definition of a +$cref/parameter/glossary/Parameter/$$ +and +$cref/variable/glossary/Variable/$$ +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/$$ +(except for the unary operators) +can now accept $code int$$ arguments. +The documentation for these arguments has been changed to reflect this. +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 +$code cppad/Test$$ directory. + + +$head 06-04$$ +The $cref/atan2/atan2/$$ function was added. + +$head 06-03$$ +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$$ for fourth and higher orders. +This has been fixed. +In addition, +the following examples have been changed +so that they test derivative up to fifth order: +$cref/asin/Asin.cpp/$$, +$cref/atan/atan.cpp/$$, +$cref/cos/cos.cpp/$$, +$cref/exp/exp.cpp/$$, +$cref/log/log.cpp/$$, +$cref/sin/sin.cpp/$$, +$cref/sqrt/sqrt.cpp/$$. + + +$head 06-01$$ +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. + +$head 05-30$$ +The $cref/sin/sin.cpp/$$ and $cref/cos/cos.cpp/$$ examples were +changed so that they tested higher order derivatives. + + +$head 05-29$$ +The forward mode recursion formulas for each of the +$xref/ + ForwardTheory/ + Standard Math Functions/ + Cases that Apply Recursion Above/ + standard math functions/ + 1 +/$$ +has been split into separate sections. +$pre + +$$ +A roman (instead of italic) font was used for the name of +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)$$. + + +$head 05-26$$ +In the documentation for $cref Poly$$, +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$$ +was corrected to $code cppad/library/SpeedTest.h$$. +In addition, the example case was corrected. +$pre + +$$ +In $cref Reverse$$, the definition for $latex U(t, u)$$ had +$latex t^p-1$$ where it should have had $latex t^{p-1}$$. +This has been fixed. + + +$head 05-25$$ +The special case where the second argument to the $cref pow$$ function is an +$code int$$ has been added. + +$head 05-14$$ +Change all of the include syntax +$codei% + # include "%filename%" +%$$ +to the syntax +$codei% + # include <%filename%> +%$$ +so that examples and other use better reflect how one would use CppAD after +it was installed in a standard include directory; for example +$code /usr/local/include/cppad$$. +$pre + +$$ +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 +$code lib$$ directory or a standard $code include$$ directory. + + +$head 05-12$$ +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 has been fixed. +$pre + +$$ +All of the include commands of the form +$codei% + # include "include/%name%.h" + # include "lib/%name%.h" +%$$ +have been changed to the form +$codei% + # include "cppad/include/%name%.h" + # include "cppad/lib/%name%.h" +%$$ +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 +$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 +$codep + # include "cppad.hpp" +$$ +to +$codep + # include "cppad/cppad.hpp" +$$. +$pre + +$$ +The window $code nmake$$ file $code Speed/Speed.mak$$ was out of date. +This has been fixed. + +$head 05-09$$ +Move $cref Poly$$ and $cref SpeedTest$$ into the +$code cppad/Lib$$ directory and the $code CppAD$$ namespace. + + +$head 05-07$$ +The $cref/divide operator tests/div.cpp/$$ were extended to +include a second order derivative calculation using reverse mode. +$pre + +$$ +The $cref Poly$$ routine was modified to be more efficient in the +derivative case. In addition, it was changed to use an arbitrary +vector for the coefficients (not just a $code CppADvector$$). + + +$head 05-04$$ +A reloading of the data base +caused the files $code include/atan.h$$ and $code include/cos.h$$ to be +mistakenly started with lower case letters. +These have been moved to $code include/Atan.h$$ and $code include/Cos.h$$ +respectively. + +$head 05-03$$ +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$$ and $cref cos$$, +were not defined for elements of an $cref VecAD$$ vector. +This has been fixed. + + +$head 04-28$$ +The operator $cref/< >%$$ 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 +was changed from $code ADVec$$ to $cref VecAD$$. +This class was extended so that +the value of elements in these vectors can be variables +(need not be $cref/parameters/glossary/Parameter/$$). + +$head 03-30$$ +Do some simple searching of the parameter table during taping +avoid multiple copies of parameters on tape (use less tape memory). + + +$head 03-28$$ +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 +$cref/parameters/Glossary/Parameter/$$. + + + +$head 03-25$$ +The internal taping structure has been changed to have variable length +instructions. +This is to save memory on the tape. +In addition, it may help in the implementation of the +vector class that tracks indexing. +(A now functioning version of this class is described in +$cref VecAD$$.) + + +$head 03-18$$ +A change was made to the way parameter values are stored on the tape. +This resulted in a significant savings in the amount of memory required. + + +$head 03-17$$ +Change the return type for $cref SpeedTest$$ from $code const char *$$ +to $code std::string$$. +The memory required for the largest test cases was added to the +$cref speed_cppad$$ tests output. + +$head 03-15$$ +The comparison between ADOLC and CppAD for +the $code DetLuADOLC.cpp/$$ example was returning an error +(because it was checking for exact equality of calculated derivatives +instead of nearly equal). +This has been fixed. + +$head 03-12$$ +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 +(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 +examples that compute determinants. + +$head 03-09$$ +The routines $code Grad$$ and $code Hess$$ have been removed. +You should use $cref Jacobian$$ and $cref Hessian$$ instead. + + +$head 03-07$$ +The driver routines $cref Hessian$$ and $cref RevTwo$$ has been added. +These to compute specialized subsets of the second order partials. +$pre + +$$ +Documentation errors in $cref ForTwo$$ and $cref Reverse$$ were fixed. +The $cref example$$ documentation was reorganized. + + +$head 03-06$$ +The driver $cref ForTwo$$ has been added. +It uses forward mode to compute a subset of the second order partials. +$pre + +$$ +Split all of the "example" and "test" index entries that come from +$codei%include/cppad/example/%*%.cpp%$$ +into sorted subheadings. + +$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 +computes the derivative of vector valued functions. + +$head 03-04$$ +The bug reported on $cref/02-17/whats_new_04/02-17/$$ was present in all +the operators. These have all been fixed and tests for all the operators +have been added to the $code cppad/Test$$ directory. +$pre + +$$ +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. +This helps when deciding whether to use forward or reverse mode. + +$head 03-03$$ +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 +when executing $cref Forward$$ and $cref Reverse$$ calculations. +$pre + +$$ +The $cref Independent$$ and $cref/Parameter/seq_property/Parameter/$$ functions +were moved below $cref ADFun$$ in the documentation. + + +$head 03-01$$ +The DetLuADOLC.cpp, DetLu case was added to the ADOLC +comparison tests. + +$head 02-29$$ +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 +when debugging was turned off. This has been fixed. + + +$head 02-28$$ +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/$$ +has been added. + +$head 02-21$$ +If you use the user defined unary atomic functions +there is a restriction on the order of the derivatives that can be calculated. +This restriction was documented in the user defined unary function +$cref Forward$$ +and $cref Reverse$$. +(These unary functions were removed on $cref/03-12/whats_new_04/03-12/$$.) + +$head 02-20$$ +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$$ +$rnext +$icode%r1% = %f%.Rev(%v%)%$$ $cnext $icode%r1% = %f%.Reverse(1, %v%)%$$ +$rnext +$icode%q1% = %f%.RevTwo(%v%)%$$ $cnext $icode%r2% = %f%.Reverse(2, %v%)%$$ +$rnext + $cnext $icode%q1%[%i%] == %r2%[2 * %i% + 1]%$$ +$tend +$pre + +$$ +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 +$cref/04-02-15/whats_new_04/02-15/$$. +$pre + +$$ +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 +parameter on an $codei%AD< AD<%Base%> >%$$ tape and a its value +might be a variable on the +$codei%AD<%Base%>%$$ tape. +This bug in the multiply and divide routines has been fixed. +$pre + +$$ +There was a bug that is some cases reported a divide by zero error +when the numerator was zero. This has been fixed. + + +$head 02-16$$ +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. +This has been fixed. +$pre + +$$ +The Microsoft project file $code example\Example.dsp$$ +was out of date. This has been fixed. +$pre + +$$ +The example that $cref/tapes derivative calculations/mul_level/$$ +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 +$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$$ +$rnext +$icode%v0% = %f%.Arg(%u0%)%$$ $cnext $icode%v0% = %f%.Forward(0, %u0%)%$$ +$rnext +$icode%v1% = %f%.For(%u1%)%$$ $cnext $icode%v1% = %f%.Forward(1, %u1%)%$$ +$rnext +$icode%v2% = %f%.For(%u2%)%$$ $cnext $icode%v2% = %f%.Forward(1, %u2%)%$$ +$tend + + +$head 02-12$$ +All of the derivative calculations are now done using arbitrary +order Taylor arithmetic routines. +The $cref Theory$$ section was changed to document this method +of calculation. + + +$head 02-01$$ +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 +$code FunForTwo$$ routine. + +$head 01-29$$ +There were some bugs in the $code FunArg$$ function +that were fixed. +$list number$$ +If one of the dependent variables was a +$cref/parameter/glossary/Parameter/$$ +$code FunArg$$ did not set it's value properly. +(All its derivatives are zero and this was handled properly.) +$lnext +The user defined unary functions were not +computed correctly. +$lend + +The specifications for the usage and unknown CppAD error macros +were modified so that they could be used with out side effects. + +$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 +$code OdeImplicit$$. + +$head 01-22$$ +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%$$. + + + + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/05.omh cppad-2019.02.00.0/omh/appendix/whats_new/05.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/05.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/05.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,942 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_05$$ +$spell + autotools + html + Dir + cppad.hpp + acos + asin + autoconf + ptr + Erf + CppADlib + logdet + valarray + Jacobian + bool + yy + mm + dd + pkzip + gz + Neg + maxabs + Romberg + cos + Le + Lt + Eq + Ge + Gt + op + gcc + Cygwin + std + Lu + CppADvector + Jon Pearce + namespace + dsw + dsp + sln + vcproj + CondExp + Microsoft + inline + scur + Vec + Rosen + Runge-Kutta + Linux + typedef + Cpp + atan +$$ + +$section Changes and Additions to CppAD During 2005$$ + +$head 12-24$$ +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$$ +calculations are now freed directly after use. +$pre + +$$ +The TrackNewDel.cpp example was missing from the Windows install +examples and testing +project file. +This has been fixed. + +$head 12-22$$ +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 +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 +with the $cref speed_cppad$$ tests. +$pre + +$$ +The $cref speed_cppad$$ test program now outputs the version of CppAD +at the top (to help when comparing output between different versions). + + +$head 12-19$$ +The $cref TrackNewDel$$ routines were added for track memory allocation +and deletion with $code new[]$$ and $code delete[]$$. +This is in preparation for making CppAD more efficient in it's use of +memory. +The bug mentioned on $cref/12-01/whats_new_05/12-01/$$ resurfaced +and the corresponding routine was changed as follows: +$codep + static local::ADTape *Tape(void) + { // If we return &tape, instead of creating and returning ptr, + // there seems to be a bug in g++ with -O2 option. + static local::ADTape tape; + static local::ADTape *ptr = &tape; + return ptr; + } +$$ + +$head 12-16$$ +The $cref NearEqual$$ function documentation for the relative error case +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 +(for the complex case in $code NearEqual$$). +In addition, more extensive testing was done in $cref near_equal.cpp$$. + + + +$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$$ +and an utility in $code example/NearEqualExt.h$$, +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 +the entire $code CppADlib.a$$ library. +$pre + +$$ +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. +This has been fixed. +$pre + +$$ +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 wish_list$$. +$pre + +$$ +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). + + + +$head 12-14$$ +Extend $cref erf$$ to cover more cases while converting it +from a function in $code lib/CppADlib.a$$ +to a template function in $code cppad/local/Erf.h$$. +This is one step along the way of removing +the entire $code CppADlib.a$$ library. + + +$head 12-11$$ +Group routines that extend the domain for which an $cref ADFun$$ +object is useful into the ExtendDomain section. +$pre + +$$ +Add an example of a C callable routine that computes +derivatives using CppAD (see $cref interface2c.cpp$$). + +$head 12-08$$ +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/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 +$code void$$. + + +$head 12-06$$ +The specifications for a $cref SimpleVector$$ template class +were extended so that the return type of an element access is +not necessarily the same as the type of the elements. +This enables us to include $code std::vector$$ +which packs multiple elements into a single storage location +and returns a special type on element access (not the same as $code bool$$). +To be more specific, +if $icode x$$ is a $code std::vector$$ object +and $icode i$$ has type $code size_t$$, +$icode%x%[%i%]%$$ does not have type $code bool$$. +$pre + +$$ +Add a Home icon, +that links to the +$href% + http://www.coin-or.org/CppAD/% + CppAD home page +%$$, +to the top left of the navigation frame +(left frame) for each documentation section. + +$head 12-05$$ +The $cref RevSparseHes$$ reverse mode Hessian sparsity calculation +has been added. +$pre + +$$ +The definition of a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ +has been corrected to properly correspond to the more efficient form +mentioned under $cref/whats_new_05/whats_new_05/11-20/$$ below. +$pre + +$$ +The dates in this file used to correspond to +local time for when the change was checked +into the +$href% + http://projects.coin-or.org/CppAD/browser% + subversion repository +%$$. +From now on the dates in this file will correspond to the first +version of CppAD where the change appears; i.e., the date in the +unix and windows +download file names $codei%CppAD-%yy%-%mm%-%dd%$$. + + +$head 12-03$$ +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 +(fewer true entries). + + +$head 12-02$$ +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 +(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 +$codep + static local::ADTape *Tape(void) + { static local::ADTape tape; + return &tape; + } +$$ +(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 +this problem. +This fix is not well understood; i.e., we should watch to see +if this problem reoccurs. +$pre + +$$ +The source code for +$cref lu_vec_ad_ok.cpp$$ was mistakenly used for +$code speed_cppad/LuSolveSpeed.cpp$$. +This has been fixed. + + + +$head 11-23$$ +The speed test of $cref lu_vec_ad.cpp$$ has been commented out +because it sometimes generates a segmentation fault. +Here is an explanation: +$pre + +$$ +If $icode X$$ is a $codei%AD<%Base%>%$$ object, +$icode y$$ is a $icode Base$$ object, +$icode%X%[%y%]%$$ uses pointer from the element +back to the original vector. +Optimizing compilers might reorder operations so that +the vector is destroyed before the object is used. +This can be avoided by changing the syntax for $cref VecAD$$ objects +to use $code set$$ and $code get$$ member functions. + + +$head 11-22$$ +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. +$pre + +$$ +CppAD now checks that the domain dimension during +$cref Independent$$ and +the range dimension during $cref ADFun$$ +(provided that $code -DNDEBUG$$ is not defined). +If either of these is zero, +the $code CppADUsageError$$ macro is invoked. + + +$head 11-20$$ +The sparsity pattern routines +$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 +$cref/sparsity patterns/glossary/Sparsity Pattern/$$. +$pre + +$$ +An extra $cref/exception/VecAD/VecAD::reference/Exceptions/$$ has been +added to the use of $cref VecAD$$ elements. +This makes $code VecAD$$ some what more efficient. + +$head 11-19$$ +Improve the output messages generated during execution of the +$cref/configure/autotools/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, +it will generate a $code CppADUsageError/$$ message. +$pre + +$$ +The $cref get_started.cpp$$ example has been simplified +so that it is easier to understand. + +$head 11-15$$ +Fix a memory leak in both the $cref ForSparseJac$$ and +$cref RevSparseJac$$ calculations. + +$head 11-12$$ +Add reverse mode $cref/Jacobian sparsity/RevSparseJac/$$ calculation. + +$head 11-09$$ +Add prototype documentation for $cref/logdet/LuSolve/logdet/$$ in +the $cref LuSolve$$ function. +$pre + +$$ +Add the optional $icode ratio$$ argument to the +$cref LuFactor$$ routine. +(This has since been moved to a separate routine called $cref LuRatio$$.) + +$head 11-07$$ +Remove some blank lines from the example files listed +directly below (under 11-06). +Comments for computing the entire Jacobian +$cref/entire sparsity pattern/ForSparseJac/Entire Sparsity Pattern/$$ +was added. + +$head 11-06$$ +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$$, +$cref rev_one.cpp$$, +$code Reverse.cpp$$, +$cref hessian.cpp$$, +$cref jacobian.cpp$$, +$cref forward.cpp$$, +$cref for_two.cpp$$, +$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 +$cref reverse_one.cpp$$ and $code reverse_checkpoint.cpp$$). + +$head 11-01$$ +Add forward mode $cref/Jacobian sparsity/ForSparseJac/$$ calculation. + +$head 10-20$$ +Add $cref/sparsity patterns/glossary/Sparsity Pattern/$$ to +the whish list. + +$head 10-18$$ +The Unix install $cref/configure/autotools/Configure/$$ command +was missing the $code --$$ before of the $code prefix$$ command line +argument. + +$head 10-14$$ +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 +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 +(which can be slow to access). + + +$head 10-12$$ +Change the +$cref/configure/autotools/Configure/$$ script so that compilation of the +$cref get_started.cpp$$ and $cref print_for_cout.cpp$$ examples are optional. +$pre + +$$ +One of the dates in the Unix installation +extraction discussion was +out of date. This has been fixed. + + + +$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/autotools/Configure/$$. +$pre + +$$ +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 +$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$$. +The source code for this template vector class, +$code cppad/vector.hpp$$, +has been removed from the documentation. + + +$head 09-27$$ +Add the +$cref/prefix_dir/autotools/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/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/utilities/utility/$$ and the library was +reorganized. + +$head 09-20$$ +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 +$code Example$$, $code TestMore$$, and $code Speed$$, directories +optional during the $cref/configure/autotools/Configure/$$ command. +The $cref/Unix installation instructions/autotools/$$ were +overhauled to make the larger set of options easy to understand. + +$head 09-14$$ +Added the $cref NumericType$$ concept and made the following +library routines require this +concept for their floating point template parameter type: +$cref LuSolve$$, +$cref LuFactor$$, +$cref RombergOne$$, +$cref RombergMul$$, +$cref Runge45$$, +$cref Rosen34$$, and +$cref OdeErrControl$$. +This is more restrictive than the previous requirements +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$$. + +$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%$$ +(the $icode%*%.zip%$$ file +uses pkzip compression). + + +$head 08-30$$ +The $icode maxabs$$ argument has been added to the +$cref OdeErrControl$$ function so that it can be used +with relative errors where components of the ODE solution may be zero +(some of the time). +In addition, some of the rest of the OdeErrControl documentation +has been improved. +$pre + +$$ +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/utilities/utility/$$. + +$head 08-20$$ +Backed out addition of $code Romberg$$ integration routine +(at this point uncertain of the interface that is most useful in +the context of AD.) + +$head 08-19$$ +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 +$code TestMore/TestMore.vcproj$$ were missing some necessary routines. +In addition, $code Speed/Speed.vcproj$$ was generating a warning. +This has been fixed. + +$head 08-14$$ +An $cref Integer$$ conversion function as been added. +$pre + +$$ +The $cref value.cpp$$ example has been improved and the old example +has been moved into the $code TestMore$$ directory. + +$head 08-13$$ +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 + +$$ +The $cref OdeErrControl$$ routine could lock in an infinite loop. +This has been fixed and a test case has been added to check for this problem. + +$head 08-07$$ +The $cref/conditional expression/CondExp/$$ function has been changed +from just $code CondExp$$ to +$code CondExpLt$$, +$code CondExpLe$$, +$code CondExpEq$$, +$code CondExpGe$$, +$code CondExpGt$$. +This should make code with conditional expressions easier to understand. +In addition, it should reduce the number of tape operations because +one need not create as many temporaries to do comparisons with. +The old $code CondExp$$ function has been deprecated. + +$head 07-21$$ +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 + +$$ +Improve the index entries in the documentation that corresponds +to the $code cppad/local$$ directory source code. + +$head 07-19$$ +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 +$cref/VecAD speed and memory/VecAD/Speed and Memory/$$ was added +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/autotools/Configure/$$ options +were not properly implemented for compiling the +$code lib$$ sub-directory. +This has been fixed. +$pre + +$$ +Some compiler warnings in the file $code lib/ErrFun.cpp$$, +which computes the $cref erf$$ function, +have been fixed. + +$head 07-11$$ +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 +an include of $code example/NearEqualExt.h$$. This has been fixed. + +$head 07-08$$ +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 +$code CppADvector$$ vector types. +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 +only run once per case that is being checked. +$pre + +$$ +Simple Vector concept checking ($cref CheckSimpleVector$$) was +added to the routines: +$cref ForOne$$, +$cref ForTwo$$, +$cref Forward$$, +$cref ADFun$$, +$cref Hessian$$, +$cref Independent$$, +$cref Jacobian$$, +$cref RevOne$$, +$cref RevTwo$$, and +$cref Reverse$$. + +$head 07-04$$ +Simple Vector concept checking ($cref CheckSimpleVector$$) was +added to the routines: +$cref LuFactor$$, +$cref LuSolve$$, +$cref LuInvert$$, +$cref OdeErrControl$$, +$cref Runge45$$, and +$cref Rosen34$$. +$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/utilities/utility/$$ routines are). +$pre + +$$ +The previous distribution (version 05-07-02) was missing the file +$code cppad/local/Default.h$$. +This has been fixed. + +$head 07-03$$ +Added $cref CheckSimpleVector$$, a C++ concept checking utility +that checks if a vector type has all the necessary conditions +to be a $cref SimpleVector$$ class with a specific element type. + +$head 07-02$$ +Version 7 of Microsoft's C++ compiler +supports the standard declaration for a friend template function. +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 +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 +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 +$codei%AD< AD<%Base%> >%$$, $codei%AD< AD< AD<%Base%> > >%$$ etc. + + +$head 07-01$$ +The permissions were set as executable for many of the no-executable files +in the distribution; for example, the $code README$$, file. +This has been fixed. + +$head 06-25$$ +Some improvements were made to the +README, AUTHORS, COPYING, and INSTALL files. +In addition, the file +$code UWCopy040507.html$$ +which contains the University of Washington's copyright +policy (see Section 2) was added to the distribution. + +$head 06-24$$ +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%$$ +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 +$code TestMore$$ directory (it is now only a test). + + +$head 06-13$$ +The changes made on 06-06 do not run under Microsoft Visual C++ version 6.0 +(even though they are within the C++ standard). +Preliminary testing under version 7 indicates that Microsoft +has fixed this problem in later versions of their C++ compiler. + +$head 06-06$$ +Converted the routines +$cref Forward$$ and $cref Reverse$$ to allow for any +$cref SimpleVector$$ instead of just $code CppADvector$$. +In addition, separated the syntax of the function call +from the prototype for each of the arguments. +This was also done for all the easy to use $cref Drivers$$ +as well as the $cref Independent$$ function and +the $cref ADFun$$ constructor. +$pre + +$$ +Add a section containing a list of +$cref/all the examples/ListAllExamples/$$. + +$head 05-19$$ +A significant improvement in speed was obtained by moving +the buffer extension to a separate function and then +inline the rest of putting operators in the tape. +For example, +here is part of the speed test output before this change: +$codep + Tape of Expansion by Minors Determinant: Length = 350, Memory = 6792 + size = 5 rate = 230 + size = 4 rate = 1,055 + size = 3 rate = 3,408 + size = 2 rate = 7,571 + size = 1 rate = 13,642 +$$ +and here is the same output after this change: +$codep + Tape of Expansion by Minors Determinant: Length = 350, Memory = 6792 + size = 5 rate = 448 + size = 4 rate = 2,004 + size = 3 rate = 5,761 + size = 2 rate = 10,221 + size = 1 rate = 14,734 +$$ +Note that your results will vary depending on operating system and machine. + +$head 05-18$$ +Change name of $code OdeControl$$ to $cref OdeErrControl$$ +and improve its documentation. +$pre + +$$ +Correct the syntax for the $cref/Parameter/con_dyn_var/Parameter/$$ +and $cref/Variable/con_dyn_var/Variable/$$ +functions. + + +$head 05-16$$ +Change $cref OdeErrControl$$ to have method return its order instead +of having a separate argument to $code OdeErrControl$$. +$pre + +$$ +Add the argument $icode scur$$ to $code OdeErrControl$$, +improve $code OdeErrControl$$ choice of step size and documentation. + + +$head 05-12$$ +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 +to the $cref ad_binary$$ and $cref compound_assign$$ operators. + + +$head 05-06$$ +The documentation for +$cref SimpleVector$$ and $cref NearEqual$$ +were changed to use more syntax (what the user enters) +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$$ +documentation. +$pre + +$$ +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 +the $code TestMore/VecUnary.cpp$$ test. + + + +$head 05-01$$ +The doubly linked list was also removed from the $cref VecAD$$ +internal data structure because this method of coding is simpler +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 +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 +an AD object was destroyed. +In order to speed AD operations in general, +the internal data structure of an AD object has been changed so that +this list is no longer necessary (a tape id number is used in its place) +$pre + +$$ +During the process above, the function $cref/Variable/con_dyn_var/Variable/$$ was added. + + +$head 04-20$$ +Add $cref/profiling/autotools/Profiling CppAD/$$ +to the speed tests. + +$head 04-19$$ +Remove an extra (not necessary) +semi-colon from the file $code cppad/local/Operator.h$$. + +$head 03-26$$ +The new routine $cref OdeErrControl$$ does +automatic step size control for the ODE solvers. + +$head 03-23$$ +The routine $cref Rosen34$$ is an improved stiff integration method +that has an optional error estimate in the calling sequence. +You must change all your calls to $code OdeImplicit$$ +to use $code Rosen34$$ (but do not need to change other arguments +because error estimate is optional). + +$head 03-22$$ +The routine $cref Runge45$$ is an improved Runge-Kutta method +that has an optional error estimate in the calling sequence. +You must change all your calls to $code OdeRunge$$ +to use $code Runge45$$ (but do not need to change other arguments +because error estimate is optional). + +$head 03-09$$ +Some extra semi-colons (empty statements) +were generating warnings on some compilers. +The ones that occurred after the macros +$code CppADStandardMathBinaryFun$$, +$code CppADCompareMember$$, +$code CppADBinaryMember$$, and +$code CppADFoldBinaryOperator$$ have been removed. + +$head 03-04$$ +An new multiple level of AD example $cref mul_level$$ was added. + +$head 03-01$$ +An option that specifies error and warning +$cref/flags/autotools/cxx_flags/$$ +for all the C++ compile commands, +was added to the +$cref/Unix installation instructions/autotools/$$. + + +$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 +left hand side for a previous equation. +$pre + +$$ +An extra requirement was added to the +$cref SimpleVector$$ template class. +There must be a typedef for $code value_type$$ +which is the type of elements in the vector +$pre + +$$ +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 +$href%mailto:Jean-Pierre.Dussault@Usherbrooke.ca%Jean-Pierre Dussault%$$). +This has been fixed. + +$head 01-08$$ +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 +has been removed. + + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/06.omh cppad-2019.02.00.0/omh/appendix/whats_new/06.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/06.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/06.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1205 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_06$$ +$spell + autotools + speedtest + apx + exp_eps + Alloc + fadbad + exp + Dir + Romberg + yyyymmdd + yy-mm-dd + Det + cppad + Adolc + Makefile + omh + config.h + Microsoft + hpp + valgrind memcheck + Kasper Kristensen + taylor + BAvector + fy + uninitialized + Tautschnig + resize + gcc + var + const + dw + VecADelem + atan + namespace + Cygwin + messaging + usr + aclocal + automake + autoconf + user + underquoted + Hes + Jac + CppAD + sed + gprof + Mul.h + Div.h + det_lu +$$ + +$section Changes and Additions to CppAD During 2006$$ + + +$head Introduction$$ +This section contains a list of the changes to CppAD during 2006 +(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-24$$ +Move $code exp_eps_ad$$ to $code exp_eps_cppad$$ and +add exercises to the following sections: +$cref exp_eps_rev1$$, +$cref exp_eps_cppad$$. +$pre + +$$ +Add operation sequence indices to help track operations in +$cref exp_eps_for0$$, +$cref exp_eps_for1$$, +$cref exp_eps_rev1$$. + +$head 12-23$$ +Add exercises to the following sections: +$cref get_started.cpp$$, +$cref exp_eps$$, +$cref exp_eps_for0$$, and +$cref exp_eps_for1$$. + +$head 12-22$$ +Move $cref get_started.cpp$$ below the $cref introduction$$ directory. +$pre + +$$ +Move the exponential example to the subdirectory +$code introduction/exp_apx$$ and change the +$code --with-Introduction$$ +unix configure option +to build both the $cref get_started.cpp$$ and $cref exp_apx.cpp$$ +example programs. +(The $code --with-GetStarted$$ configure command line option has been removed.) + +$head 12-21$$ +Add the $cref/source code for Poly/poly.hpp/$$ to the documentation +and include $cref Poly$$ in the in the $cref speed_utility$$ section. +$pre + +$$ +The $cref get_started.cpp$$ section has been moved +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$$. + + +$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 +following routines: +$cref det_by_minor$$, +$cref det_grad_33$$, +$cref uniform_01$$, +$cref det_of_minor$$, +$cref det_by_lu$$, +$cref LuInvert$$, +$cref LuFactor$$, +$cref LuSolve$$. +$pre + +$$ +Separate the specifications for the source in +$cref speed_utility$$ and add cross reference to the following routine +specification and implementations: +$cref det_by_minor$$, +$cref det_grad_33$$, +$cref uniform_01$$, +$cref det_of_minor$$, +$cref det_by_lu$$, +$cref LuInvert$$, +$cref LuFactor$$, +$cref LuSolve$$. + + +$head 12-18$$ +Make the $cref speed$$ source code easier to read. +$pre + +$$ +Change the speed test output name $code det_poly$$ to $code poly$$ +(as it should have been). + +$head 12-17$$ +The speed test $cref det_grad_33$$ was missing its documentation +(this has been fixed). +In addition, the titles and indexing for the speed test documentation +has been improved. +$pre + +$$ +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/$$. +In addition, modify all the speed tests so that they abide by this rule. +$pre + +$$ +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 +matrix in the test. +$pre + +$$ +Add the $cref/poly/link_poly/$$ speed test for all three packages. +In addition, correct a missing include in $cref poly$$ routine. + + +$head 12-15$$ +The wish list item +to simplify and better organize the speed tests been completed: +$table +$cref|speed/|speed|$$ + $cnext template functions that are speed tested $rnext +$code speed/example$$ + $cnext example usage of speed template functions $rnext +$cref|speed/adolc|speed_adolc|$$ + $cnext Adolc drivers for the template functions $rnext +$cref|speed/cppad|speed_cppad|$$ + $cnext CppAD drivers for the template functions $rnext +$cref|speed/fadbad|speed_fadbad|$$ + $cnext Fadbad drivers for the template functions $rnext +$cref|speed/profile|autotools|Profiling CppAD|$$ + $cnext profiling version of CppAD drivers +$tend + + +$head 12-13$$ +Next step for the speed wish list item: +remove $code speed_cppad$$ from the documentation and replace it by +$code speed/cppad$$, see $cref speed_cppad$$ for the new CppAD speed +test routines. + +$head 12-12$$ +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 +creating the $code speed/example$$ directory and moving the relevant +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%speed/%*%.hpp%$$. +$pre + +$$ +A new $cref speed_test$$ routine was added to the library. + + +$head 12-10$$ +The $cref pow$$ function was changed to be a an $codei%AD<%Base%>%$$ +$cref/atomic_base/glossary/Operation/Atomic/$$ operation. +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. +The $cref pow$$ documentation was improved +and the $cref pow.cpp$$ example was changed to +test more cases and to use the same variable +names as in the documentation. + +$head 12-09$$ +A speed wish list item was added to the wish list. +$pre + +$$ +The prototype for $code int$$ arguments in binary operations +(for example $cref/addition/ad_binary/$$) was documented as +$syntax const int &$$ but was actually just plain $code int$$. +This has been fixed. +(Later changed to $code double$$.) + +$head 12-07$$ +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 +had an improper license statement in the GPL license version. +This has been fixed. + +$head 12-05$$ +Add the unix installation +$cref/--with-Documentation/autotools/--with-Documentation/$$ option +and remove the +$icode postfix_dir$$ option. +$pre + +$$ +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 +lower case; i.e., $code cppad$$. +If you are using a Unix system, see $cref include_deprecated$$. +This completes the following $cref wish_list$$ items (which were removed): + +$list number$$ +File and directory names should only contain lowercase letters, +numbers underscores and possibly one period. +The leading character must be alphabetic. + +$lnext +C++ header files should have the $code .hpp$$ extension. + +$lend + + +$head 12-02$$ +Put explanation of version numbering in the +download instructions. +$pre + +$$ +Correct some file name references under the Windows heading in +$cref speed_cppad$$. + +$head 12-01$$ +All of the $code Makefile.am$$ and $code Makefile$$ files were changed +to lower case; i.e., $code makefile.am$$ and $code makefile$$. +$pre + +$$ +Fix compiler warning while compiling $code cppad/RombergOne/$$ +(mistake occurred during $cref/11-20/whats_new_06/11-29/$$ change). + +$head 11-30$$ +Cygwin packages, and other system packages, +should not have a dash in the version number. +See +$href% + http://cygwin.com/setup.html#naming% + cygwin package file naming +%$$ +or, to quote the +$href% + http://www.rpm.org/max-rpm/ch-rpm-file-format.html% + rpm file naming convention +%$$ +$italic +The only restriction placed on the version is that +it cannot contain a dash "-". +$$ +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$$. + +$head 11-29$$ +There was a problem using $cref RombergOne$$ with floating point +types other than $code double$$. This has been fixed. + +$head 11-28$$ +The $cref/installation/Install/$$ download files were not being built +because $code Makefile.am$$ referenced $code Doc$$ when it should have +referenced $code doc$$. This has been fixed. + +$head 11-23$$ +A Version Numbering entry was added to the +$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 +by minors $code DetOfMinor$$ was changed to $cref det_of_minor$$, +in preparation for +more formal speed comparisons with other packages. +To be specific, its documentation was improved, +its dependence on the rest of CppAD was removed +(it no longer includes $cref/CppAD.h/cppad/$$). + + +$head 11-12$$ +The +$cref general.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 +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. + +$head 11-06$$ +Move the $code TestMore$$ directory to $code test_more$$ +and change all its files to use lower case names. + + +$head 11-05$$ +Remove references in the $cref speed_cppad$$ tests to the +$code Memory$$ and $code Size$$ functions because they +have been $cref/deprecated/FunDeprecated/$$. +$pre + +$$ +Correct some references to $code var_size$$ that should have been +$cref/size_var/seq_property/size_var/$$. + +$head 11-04$$ +Put text written to standard output in the documentation for the +$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 +$code speedtest.cpp$$ examples were missing in $cref ListAllExamples$$ +(which has been fixed). +$pre + +$$ +Move the $code Speed$$ directory to $code speed$$ +and change all its files to use lower case names. + +$head 11-02$$ +The $code print_for$$ directory was referenced as $code PrintFor$$ +in the root CppAD $code Makefile.am$$ this has been fixed. +$pre + +$$ +The documentation for the Adolc helper routines +$code AllocVec$$ and $code AllocMat$$ were not being included. +This has been fixed. +$pre + +$$ +Move the $code GetStarted$$ directory to $code get_started$$ +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. + +$head 10-31$$ +Move the $code SpeedExample$$ directory to $code speed_cppad_example$$ +and change all its files to use lower case names. + +$head 10-29$$ +Move the $code Adolc$$ directory to $code adolc$$ +and change all its files to use lower case names. +$pre + +$$ +Change all the file in the $code omh$$ directory to +use lower case names. +$pre + +$$ +The file $code Makefile.am$$ in the distribution directory had the +CPL copyright message in the GPL version. This has been fixed. + +$head 10-28$$ +The copyright message in the script files +$code example/OneTest$$ and $code TestMore/OneTest$$ were GPL +(in the CPL distribution). +This has been fixed by moving them to +$code example/OneTest.sh$$ and $code TestMore/OneTest.sh$$ so that +the distribution automatically edits the copyright message. + + +$head 10-27$$ +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 +$cref Independent$$ and the $codei%ADFun<%Base%>%$$ +$cref/constructor/FunConstruct/$$. + +$head 10-25$$ +A subversion install procedure was +added to the documentation. +$pre + +$$ +Fix definition of preprocessor symbol +$code PACKAGE_STRING$$ in $code Speed/Speed.cpp$$ +(broken by change on 10-18). +$pre + +$$ +Added the example +$cref hes_lagrangian.cpp$$ which computes the Hessian +of a Lagrangian. + +$head 10-18$$ +Document and fix possible conflicts for +$cref/preprocessor symbols/preprocessor/$$ +that do not begin with $code CppAD$$ or $code CPPAD_$$. +$pre + +$$ +Include a default value for the file $code cppad/config.h$$ +in the subversion repository. + +$head 10-16$$ +Fix bug when using $cref OdeErrControl$$ with the type +$code AD< AD >$$. + + +$head 10-10$$ +Add the $cref Var2Par$$ function so it is possible +to obtain the $cref Value$$ of a variable. +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). + +$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 +get the nightly build changed: +$list number$$ +Change shell scripts to use *.sh extension. +$lnext +Two versions, one with CPL and other with GPL license. +$lnext +Change subversion version of CppAD from GPL to CPL copyright. +$lnext +Change all files in cppad/local to use lower case and *.hpp extension. +$lnext +CppAD_vector.h was generating a warning on version 4 of gcc. +This have been fixed. +$lnext +Change the preprocessor $code # define$$ commands +in $code cppad/local/*.hpp$$ to use upper case names. +$lnext +Add the $cref stack_machine.cpp$$ example. +$lend + +$head 08-17$$ +Some error message occurred while executing +$codep + valgrind --tool=memcheck example/example + valgrind --tool=memcheck TestMore/TestMore + +$$ +These were not really bugs, but they have been fixed to avoid +this conflict between CppAD and $href%http://valgrind.org/%valgrind%$$. + +$head 07-14$$ +Make some improvements were made to the $cref Introduction$$, +$cref exp_eps.hpp$$ and $cref exp_eps_rev1$$ sections. + +$head 07-12$$ +Use a drop down menu for the navigation links, instead of a separate frame +for the navigation links, for each section in the documentation. + +$head 06-29$$ +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. + +$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 +$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 +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 wish_list$$: +$pre + +$$ +"We would like to be able to erase the function +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 +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 +$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 +$code ADFun$$ pointers together with $code new$$ +and $code delete$$. + +$comment ----------------------------------------------------------- $$ + +$head 06-17$$ +The location where the distribution files are stored has changed +and this broke the Download Current Version links for the +unix and windows installation. +This has been fixed. +$pre + +$$ +The compiling instructions for the $cref speed_cppad$$ routines have been improved. +$pre + +$$ +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 + +$$ +The $cref BenderQuad$$ documentation and example have been improved +by changing $icode Vector$$ to $icode BAvector$$ to emphasize that +it corresponds to a vector of $icode Base$$ objects. + + +$head 06-15$$ +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 +$cref/function value argument, g/BenderQuad/g/$$ in $code BenderQuad$$. + +$head 06-07$$ +Some major changes were made to the notation in +$cref get_started.cpp$$ (to make it easier to start using CppAD). +$pre + +$$ +In the $cref Introduction$$ example, +$latex exp_eps$$ was changed to $latex {\rm exp\_eps}$$. + +$head 06-05$$ +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, +$icode%fun%.fy%$$ was changed to $icode%fun%.h%$$. + +$head 06-02$$ +Newer versions of the gcc compiler generated a warning for possible +use of an uninitialized pointer. +This was found by Michael Tautschnig and his fix has been +included in the CppAD distribution. + + +$head 05-31$$ +The interface to $cref BenderQuad$$ has been changed. +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 +be in the same browser frame as the command documentation +(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 +follow another link to see to the command syntax. + +$head 05-27$$ +Added $cref BenderQuad$$ for computing the Hessian of +Bender's reduced objective function. +$pre + +$$ +Added special specifications for $code resize(0)$$ +to $cref CppAD_vector$$. + +$head 05-03$$ +The g++ (GCC) 4.1.0 (Red Hat 4.1.0-3) compiler reported an error +because certain functions were used before being defined +(version 3.4.4 did not complain about this). +This has been fixed. + +$head 04-29$$ +Change all of the example and test driver programs so that they return +error codes; i.e., zero for no error and one for an error. +$pre + +$$ +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 +it so that it is visible at the too level of the documentation. + +$head 04-26$$ +The programs in $cref Introduction$$ have been converted to automated +test that return true or false with the driver program +$cref/Introduction/exp_apx.cpp/$$. + +$head 04-25$$ +Add an $cref Introduction$$ section to the documentation +(replaces old example that was part of the $cref Theory$$ section). + +$head 04-19$$ +A discussion was added near the end of the $cref FunCheck$$ documentation. +And the cross references to the $cref CompareChange$$ discussion +were changed to the FunCheck discussion. +$pre + +$$ +An operation sequence entry was added to the $cref wish_list$$. + +$head 04-18$$ +The new definitions for +$cref/AD of Base/glossary/AD of Base/$$ +and +$cref/operation sequence/glossary/Operation/Sequence/$$ +have been used throughout the documentation. +$pre + +$$ +Add the $cref FunCheck$$ section for checking that a sequence of +operations is as intended. + + +$head 04-17$$ +The documentation for $cref SpeedTest$$ and $cref Poly$$ was improved. +$pre + +$$ +Definitions were added for an atomic $cref/operation/glossary/Operation/$$ +and for an operation sequence being +dependent and independent of the values of specific operands. +$pre + +$$ +The definition of AD sequence of operations was made abstract +and moved to the glossary as +$cref/Type operation sequence/glossary/Operation/Sequence/$$. + +$head 04-15$$ +The $cref mul_level$$ example was moved from +$cref ADFun$$ to $cref General$$. +The documentation for $cref SpeedTest$$ was improved. + +$head 04-14$$ +Documentation and examples were improved for the following routines: +$cref ForTwo$$, +$cref RevTwo$$. +In addition, the computation in $code RevTwo$$ was made more efficient +(it used to possibly calculate some first order partials that were not used). + +$head 04-13$$ +Documentation and examples were improved for the following routines: +$cref Jacobian$$, +$cref ForOne$$, +$cref RevOne$$, +and $cref Hessian$$. + + +$head 04-08$$ +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 +(because it only applies to the current $cref forward_zero$$). +$pre + +$$ +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 +$codep + VecAD V(1); + AD zero = 0; + V[zero] = 1.; + static_cast< AD > ( V[zero] ); +$$ + + + + + +$head 04-06$$ +The $cref ForSparseJac$$, $cref RevSparseJac$$, $cref RevSparseHes$$ +sparsity results are now valid for +all independent variable values +(if the AD operation sequence does no use any +$codei%VecAD<%Base%>%$$ operands). +In addition, the +$code ForSparseJac$$, $cref RevSparseJac$$ and $cref RevSparseHes$$ +documentation and examples were improved. +$pre + +$$ +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 +$cref/04-03/whats_new_06/04-03/$$). + + +$head 04-05$$ +The documentation and example for $cref CompareChange$$ were +improved and moved to be part of the $cref Forward$$ section. + +$head 04-04$$ +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 +$cref/zero/forward_zero/$$ and $cref forward_one$$ first order case +of $cref Forward$$ mode. +$pre + +$$ +The ADFun $cref/Size/FunDeprecated/Size/$$ member function +has been deprecated (use $cref size_order$$ instead). +$pre + +$$ +The $cref Reverse$$ member function is now declared, +and documented as, $code const$$; i.e., +it does not effect the state of the ADFun object. +$pre + +$$ +Change the examples that use $cref Reverse$$ to use the same +return value notation as the documentation; i.e., $code dw$$. + +$head 04-02$$ +The member functions of $cref ADFun$$ that return properties of +AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$ +have been grouped into the $cref seq_property$$ section. +In addition, the $cref seq_property.cpp$$ example has been added. +$pre + +$$ +The $cref CompareChange$$ function documentation was improved +and moved to a separate section. +$pre + +$$ +Group the documentation for the $cref ADFun$$ member functions that +evaluate functions and derivative values. +This organization has since been changed. +$pre + +$$ +Remove the old $code Fun.cpp$$ example and extend +$cref independent.cpp$$ so that it demonstrates using different +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$$ +for its example. +$pre + +$$ +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. +The request was implemented on $cref/06-19/whats_new_06/06-19/$$ +and the entry was removed from the wish list. + +$head 03-31$$ +Add examples for the $cref/Parameter, Variable/con_dyn_var/$$ and +$cref Independent$$ functions. +$pre + +$$ +Move the $cref/Parameter/con_dyn_var/Parameter/$$ +and $cref/Variable/con_dyn_var/Variable/$$ functions from +the $cref ADFun$$ section to the $cref AD$$ section. +$pre + +$$ +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 +$cref/variables/glossary/Variable/$$. + +$head 03-30$$ +Move the $cref LuRatio$$ section below $cref LuDetAndSolve$$. +$pre + +$$ +Move the definition of an +AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$ +from the glossary to the $cref AD$$ section. +$pre + +$$ +Improve the definition of tape state. +$pre + +$$ +Add mention of taping to +$cref Erf$$, $cref BoolFun$$, $cref NearEqualExt$$,and $cref Pow$$. +$pre + +$$ +Change the definition for +$cref/VecAD::reference/VecAD/VecAD::reference/$$ +so that it stands out of the text better. + + +$head 03-29$$ +Mention the $cref/VecAD::reference/VecAD/VecAD::reference/$$ case in +documentation and examples for +$cref abs$$, $cref atan2$$, $cref erf$$, and $cref pow$$. +$pre + +$$ +Fix a bug derivative computation for $codei%abs(%x%)%$$ +when $icode x$$ had type $codei%AD< AD >%$$ and $icode x$$ +had value zero. +$pre + +$$ +Fix a bug using non-zero AD indices for $cref VecAD$$ vectors +while the tape is in the empty state. +$pre + +$$ +Extend $cref erf$$ to include $code float$$, $code double$$, +and $codei%VecAD<%Base%>::reference%$$. + +$head 03-28$$ +Mention the +$cref/VecAD::reference/VecAD/VecAD::reference/$$ case in +documentation and examples for +$cref UnaryPlus$$, +$cref UnaryMinus$$, +$cref ad_binary$$, +$cref compound_assign$$, and +$cref unary_standard_math$$ + + +$head 03-27$$ +Extend and improve the +$cref/VecAD exceptions/VecAD/VecAD::reference/Exceptions/$$. +$pre + +$$ +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%>%$$ +(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 +$cref Value$$, $cref ad_output$$ and $cref/assignment/ad_assign/$$ documentation +and examples. +$pre + +$$ +Extend $cref Integer$$ and $cref PrintFor$$ to include the +$cref/VecAD::reference/VecAD/VecAD::reference/$$ case +(and mention in documentation and examples). + + +$head 03-24$$ +Move $cref VecAD$$ and $cref LuRatio$$ from the old ExtendDomain section +to $cref AD$$. + +$head 03-23$$ +Improve documentation and examples for +$cref CondExp$$ and $cref Discrete$$. +Move both of these sections from ExtendDomain to $cref ADValued$$. + +$head 03-22$$ +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$$ +in the documentation have been organized into subgroups. + +$head 03-17$$ +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 +$cref pow_int$$. +$pre + +$$ +The copies of the $code atan2$$ function were included +in the CppAD namespace for the +$code float$$ and $code double$$ types. + +$head 03-15$$ +Improve the introduction to $cref CppAD$$ on the top level page +of the documentation. + +$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 +(except under Cygwin which is not really case sensitive). +This has been fixed. +$pre + +$$ +The term AD of $icode Base$$ +$cref/operation sequence/glossary/Operation/Sequence/$$ +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 unary_standard_math$$ have +been grouped under $code MathOther$$. +$pre + +$$ +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$$, +$cref log10.cpp$$, +$cref sin.cpp$$, +$cref sinh.cpp$$, +$cref sqrt.cpp$$ +have been improved. + +$head 03-07$$ +The $code tan$$ function has been added to CppAD. +$pre + +$$ +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 unary_standard_math$$. + +$head 02-28$$ +The $cref ad_output$$ and $cref Abs$$ +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. + +$head 02-24$$ +The documentation and examples have been improved for the following sections: +$cref/division/ad_binary/$$, $cref/-=/compound_assign/$$, $cref/*=/compound_assign/$$, and $cref%/=%compound_assign%$$. + +$head 02-23$$ +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. +$pre + +$$ +There was a bug $cref RevTwo$$ that was not detected by the +$cref rev_two.cpp$$ test. This bug was reported by +$href% + http://list.coin-or.org/pipermail/cppad/2006-February/000020.html% + Kasper Kristensen +%$$ +A test was added $code TestMore/rev_two.cpp$$ that detects this problem +and the problem has been fixed. + + +$head 02-15$$ +The $cref/+=/compound_assign/$$ documentation and example have been improved. + +$head 02-14$$ +The $cref/addition/ad_binary/$$ documentation and example have been improved. + + +$head 02-13$$ +Combine the old binary operator and compound assignment documentation +into $cref Arithmetic$$ documentation. +$pre + +$$ +The documentation and examples have been improved for the following sections: +$cref/assignment/ad_assign/$$, $cref UnaryPlus$$, $xref UnaryMinus$$. + +$head 02-11$$ +The documentation and examples have been improved for the following sections: +$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/$$ +(formerly Copy) documentation has been modified. +$pre + +$$ +Some of the error messaging during $cref ADFun$$ construction +has been improved. + +$head 02-04$$ +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 +$code CppAD::vector$$. +$pre + +$$ +The routines $cref Runge45$$ and $cref Rosen34$$ +had static vectors to avoid recalculation on each call. +These have been changed to be plain vectors to avoid memory +leak detection by $cref/TrackCount/TrackNewDel/TrackCount/$$. + +$head 01-20$$ +Add software guidelines +to the wish list. + +$head 01-18$$ +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$$ +The aclocal program is part of the automake and autoconf system. +It often generates warnings of the form: +$codei% + /usr/share/aclocal/%...%: warning: underquoted definition of + %...% +%$$ +The shell script file $code FixAclocal$$, +which attempts to fix these warnings, +was added to the distribution. + +$head 01-07$$ +Change CppAD error handler from using the macros defined in +$code cppad/CppADError.h$$ to using a class defined in +$cref%include/cppad/utility/error_handler.hpp%ErrorHandler%$$. +The macros $code CppADUnknownError$$ and $code CppADUsageError$$ +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/autotools/Profiling CppAD/$$ output. +$pre + +$$ +Make the following source code files easier to understand: +$code Add.h$$, $code Sub.h$$, $code Mul.h$$, $code Div.h$$ +(in the directory $code cppad/local$$). + +$head 01-05$$ +Make the following source code files easier to understand: +$code RevSparseHes.h$$, +$code Reverse.h$$, +$code Fun.h$$, +$code Forward.h$$, +$code ForSparseJac.h$$, +$code RevSparseJac.h$$ +(in the directory $code cppad/local$$). + + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/07.omh cppad-2019.02.00.0/omh/appendix/whats_new/07.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/07.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/07.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,968 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_07$$ +$spell + autotools + mul + cxx + omh + tgz + yyyymmdd + isnan + gcc + executables + makefiles + tarballs + autoconf + Fadbad + Sacado::Tay + Dir + Ginac + xi + Bool + CppADvector + inv + namespace + det_lu + adouble + Adolc + op + sqrt + eps + mega + Kipp + vcproj + exp_apx + Microsoft + threadprivate + gettimeofday + ifndef + Vec + openmp + dy + automake + makefile + CppAD + cygwin + cppad.hpp + config.h + dd + Adolc + Taylor +$$ + +$section Changes and Additions to CppAD During 2007$$ + + +$head Introduction$$ +This section contains a list of the changes to CppAD during 2007 +(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$$ +License conversions missed the copyright message at the top +in the following special cases: +$code makefile.am$$, $code makefile.in$$, and +$code omh/appendix/license.omh$$. + + +$head 12-25$$ +The $cref install$$ instructions have been improved. + +$head 12-21$$ +The $cref/--with-Documentation/autotools/--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. + +$head 12-08$$ +By mistake, the documentation $cref License$$ statement +for the GPL distribution was the same as for the CPL distribution. +This has been fixed. + +$head 12-05$$ +Change the name of the spec file from +$codei%cppad-%yyyymmdd%.spec%$$ to $code cppad.spec$$. + +$head 12-04$$ +Add the capability for the RPM spec file to use a different +prefix directory. + +$head 12-03$$ +This is the first version with the rpm spec file +$code cppad.spec$$. + +$head 12-02$$ +Add the $codei%DESTDIR=%directory%$$ option on the +$cref/make install/autotools/make install/$$ command line. + +$head 11-29$$ +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$$ +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. + +$head 11-18$$ +Speed tests for $code tape_values$$ branch were not better than trunk, +so the good parts of that branch (but not all) were merged into the trunk. +$pre + +$$ +The interface specifications for +$cref/base type requirements/base_require/$$ have been changed so that +CppAD would compile with $code gcc 4.1.1$$ +(which requires more definitions before use in template functions). +This changed of requirements is demonstrated by the +$cref base_complex.hpp$$ and $cref base_adolc.hpp$$ examples. +$pre + +$$ +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; +see $cref base_std_math$$. +$pre + +$$ +The $code example/test_one.sh$$ and $code test_more/test_one.sh$$ +scripts were modified so that one only need specify the test file name +(does not also need the test routine name). Some of the test routine +declarations were changed from $icode/name/()/$$ to +$icode/name/(void)/$$ to make this possible. +$pre + +$$ +The program $code test_more/test_more$$ was changed to always +report the memory leak test results (same as $code example/example$$). +$pre + +$$ +The $cref PrintFor$$ function was putting an unused variable in the tape. +This has been fixed. + + + +$head 11-06$$ +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. + +$head 11-05$$ +MS project files have been added for running the +$cref/cppad/speed_cppad/$$ and +$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 Windows project's could not find a certain include file. +This has been fixed. +$pre + +$$ +The $cref/unix install/autotools/$$ procedure has been modified +so that the one configure flag +$code --with-Speed$$ +builds all the possible executables related to the speed testing. + +$head 11-03$$ +Improve the $cref speed_main$$ documentation and output +(as well as the title for other sections under $cref speed$$). +$pre + +$$ +The subversion copy of the $cref/configure/autotools/Configure/$$ script +was not executable. +This has been fixed. + +$head 11-02$$ +The instructions for downloading the current version using +$code subversion$$ have changed. +The user should now directly edit the file +$codep + trunk/configure +$$ +in order to set the correct date for the installation +and to build the corresponding documentation. +$pre + +$$ +The $cref speed$$ section has been slightly reorganized +(the main program and utilities have been separated). +$pre + +$$ +Add $cref speed_double$$ for testing the speed of evaluating +functions in $code double$$ as apposed to gradients using AD types. + +$head 11-01$$ +The instructions for downloading the current version using subversion +have changed. +The user must now execute the command +$codep + ./build.sh version +$$ +in order to set the correct version number for her (or his) installation. +$pre + +$$ +Add the return status for all the correctness tests +to the documentation; see $code make test$$. + +$head 10-30$$ +The download instructions did not update current version number +and this broke the links to the current tarballs. +This has been fixed. +$pre + +$$ +The documentation for $cref det_by_minor$$ and $cref det_by_lu$$ +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). +$pre + +$$ +The makefiles in the distribution have been changed so that +one can run configure from a directory other than the distribution directory. + +$head 10-27$$ +A $code subversion$$ method +for downloading CppAD has been added. +$pre + +$$ +The installation was broken on some systems because the +$cref/configure/autotools/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 +$code subversion$$ +methods to include a full installation and old versions. + +$head 10-23$$ +The $cref/cxx_flags/autotools/cxx_flags/$$ environment variable +has been changed from $code CPP_ERROR_WARN$$ to $code CXX_FLAGS$$. +$pre + +$$ +The command $code configure --help$$ now prints a description +of the environment variables +$code ADOLC_DIR$$, +$code FADBAD_DIR$$, +$code SACADO_DIR$$, +$code BOOST_DIR$$, +and +$code CXX_FLAGS$$. +In addition, if the environment variables +$code POSTFIX_DIR$$ or $code CPP_ERROR_WARN$$ are used, +an message is printed saying that are not longer valid. + + +$head 10-22$$ +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 +$codei%compute_%test_name%$$ to be the same for all packages. +$pre + +$$ +The $href%http://trilinos.sandia.gov/packages/sacado/%Sacado%$$ +package was added to the list of $cref speed$$ tests. +In addition, the discussion about how to run each of the +speed tests was corrected to include the $icode seed$$ argument. +$pre + +$$ +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/autotools/Configure/$$ +documentation. +This has been fixed. +$pre + +$$ +The routine $cref CheckSimpleVector$$ was changed. +It used to require conversion of the form +$codei% + %Scalar%(%i%) +%$$ +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 +(see $cref/restrictions/CheckSimpleVector/Restrictions/$$) +to support of +$codei% + %x% = %i% +%$$ +where $icode x$$ has type $icode Scalar$$ +and $icode i$$ has type $code int$$. +$pre + +$$ +Fix include directives in $cref speed_fadbad$$ programs +$code det_lu$$, $code det_minor$$, and $code poly$$, +to use $code FADBAD++$$ instead of $code Fadbad++$$ directory. +$pre + +$$ +Add $code ADOLC_DIR$$, $code FADBAD_DIR$$, $code SACADO_DIR$$, +and $code BOOST_DIR$$ +to the $cref/configure/autotools/Configure/$$ help string. + + +$head 10-16$$ +Add $icode seed$$ argument and +improve $cref speed_main$$ documentation. + +$head 10-13$$ +Fix the title in $cref adolc_det_lu.cpp$$. +Add the package name to each test case result printed by +$cref speed_main$$. + +$head 10-05$$ +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$$ +Extend the $cref pow$$ function to work for any case where one argument +is $codei%AD<%Base%>%$$ and the other is $code double$$ +(as do the binary operators). + +$head 09-06$$ +If the $cref/method.step/OdeErrControl/Method/step/$$ function returned +$code nan$$ (not a number), +it was possible for $cref OdeErrControl$$ to drop into an infinite loop. +This has been fixed. + +$head 08-09$$ +Let user detect and handel the case where an ODE initial vector $icode xi$$ +contains not a number $code nan$$ +(see $cref Runge45$$, $cref Rosen34$$, and $cref OdeErrControl$$). +$pre + +$$ +Use the $code ||$$ operation instead of $code |$$ +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. +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 +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. +$pre + +$$ +Fix an $cref/Sequence Constructor/FunConstruct/Sequence Constructor/$$ +referenced to $code Dependent$$ in documentation +(was using the $cref FunDeprecated$$ one argument syntax). +$pre + +$$ +Add comment about mixing debug and non-debug versions of +CppAD in $cref/TrackDelVec/TrackNewDel/TrackDelVec/$$ error message. + + +$head 07-30$$ +$code CppADCreateBinaryBool$$ and $code CppADCreateUnaryBool$$ +have been replaced by $code CPPAD_BOOL_BINARY$$ and +$code CPPAD_BOOL_UNARY$$ respectively. +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 +$code CppADUsageError$$ and $code CppADUnknownError$$ +have been replaced by $code CPPAD_ASSERT_KNOWN$$ and +$code CPPAD_ASSERT_UNKNOWN$$ respectively. +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 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$$ +which has been deprecated. + +$head 07-26$$ +Merge in changes made in $code branches/test_vector$$. + +$subhead 07-26$$ +Change all occurrences of $code CppADvector$$, +in the files $codei%test_more/%*%.cpp%$$ and $codei%speed/%*%/%*%.cpp%$$, +where changed to $code CPPAD_TEST_VECTOR$$. +All occurrences of the $code CppADvector$$ in the documentation +were edited to reflect that fact that it has been deprecated. +The documentation index and search for +deprecated items has been improved. + +$subhead 07-25$$ +Deprecate the preprocessor symbol $code CppADvector$$ +and start changing it to +$small $cref/CPPAD_TEST_VECTOR/test_vector/$$ $$. +$pre + +$$ +Change all occurrences of $code CppADvector$$, +in the $codei%example/%*%.cpp%$$ files, +to $code CPPAD_TEST_VECTOR$$. + +$head 07-23$$ +The $cref TrackNewDel$$ macros +$code CppADTrackNewVec$$, +$code CppADTrackDelVec$$, and +$code CppADTrackExtend$$ have been deprecated. +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 +software guidelines section of the wish list. +$pre + +$$ +The member variable entry in the software guideline +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 sum_i_inv.cpp$$ +have been changed so that they run on more systems +(are C++ standard compliant). +$lnext +$cref base_require$$: +The $code IdenticalEqual$$ function, +in the $cref base_require$$ specification, +was changed to $code IdenticalEqualCon$$ +(note the $cref/API warning/base_require/API Warning/$$ in the +$icode Base$$ requirement specifications). +$lnext +Implementation of the $cref/base requirements/base_require/$$ for complex types +were moved into the $cref base_complex.hpp$$ example. +$lend + + + +$head 07-20$$ +The download for CppAD was still broken. +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 +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 +$code mul_level_adolc_ode.cpp$$ was added because the +$code example/example$$ program was failing. +This has been fixed. + +$head 07-18$$ +A realistic example using Adolc with CppAD +$cref mul_level_adolc_ode.cpp$$ was added. +The documentation for $cref TrackNewDel$$ was improved. + +$head 07-14$$ +Add a discussion at the beginning of +$cref mul_level_ode.cpp$$ example +(and improve the notation used in the example). + +$head 07-13$$ +Separate the include file +$cref base_adolc.hpp$$ +from the $cref mul_level_adolc.cpp$$ example +so that it can be used by other examples. + +$head 06-22$$ +Add $cref mul_level_adolc.cpp$$, an example that demonstrates using +$code adouble$$ and for the $cref/Base/base_require/$$ type. +$pre + +$$ +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/autotools/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. +$pre + +$$ +There was a namespace reference missing in the files +that could have caused compilation errors in the files +$code speed/cppad/det_minor.cpp$$ and +$code speed/cppad/det_lu.cpp$$. +This has been fixed. + +$head 06-20$$ +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 +$code test_more/test_more.cpp$$ file. +$pre + +$$ +Add a section defining the $cref/Base type requirements/base_require/$$. +Remove the $icode Base$$ type restrictions from the $cref Faq$$. +Make all the prototype for the default Base types agree with +the specifications in the Base type requirements. +$pre + +$$ +Fix the description of the $code tan$$ function in +$cref unary_standard_math$$. + + +$head 06-14$$ +The routine $cref Rosen34$$ ( $cref Runge45$$ ) had a division +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 +$code size_t$$ to an $code int$$, +then converting the $code int$$ to a $icode Scalar$$, +and then preforming the division. +(The conversion of an $code int$$ to any numeric type must be valid.) + +$head 05-26$$ +If the $icode Base$$ type is not $code double$$, +the $cref/compound assignment/compound_assign/$$ operators did not +always allow for $code double$$ operands. For example, +if $icode x$$ had type $code AD< AD >$$ +$codei% + %x% += .5; +%$$ +would slice the value $code .5$$ to an $code int$$ +and then convert it to an $code AD< AD >$$. +This has been fixed. +$pre + +$$ +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$$. + + +$head 05-25$$ +Document usage of $code double$$ with +binary arithmetic operators, +and combine all those operators into one section ($cref ad_binary$$). +$pre + +$$ +The documentation for all the $cref/compound assignment/compound_assign/$$ +operators has been grouped together. +In addition, a +compound assignment wish list item has been added +(it was completed and removed with the +$cref/05-26/whats_new_07/05-26/$$ update.) + + +$head 05-24$$ +Suppose that $icode op$$ is a binary operation and we have +$codei% + %left% %op% %right% +%$$ +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 +being converted to $code AD< AD >$$. +This has been fixed. + +$head 05-22$$ +The Microsoft +examples and testing +project file $code example/example.vcproj$$ +was missing a reference to the +source code file $code example/reverse_two.cpp$$. +This has been fixed. + +$head 05-08$$ +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 +is no longer deprecated (and is used by CppAD when the exponent +has type $code int$$). + + +$head 05-05$$ +Third and fourth order derivatives were included in the +routine $code test_more/sqrt.cpp$$ that tests square roots. +$pre + +$$ +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_eps_for1/exp_eps_for1/Return Value/$$, and +$cref/exp_eps_for2/exp_eps_for2/Return Value/$$. +$pre + +$$ +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 sqrt_reverse$$. +$pre + +$$ +The dimension for the notation $latex X$$ in +$cref reverse_identity$$ was corrected. +$pre + +$$ +The word mega was added to the spelling exception list for +$code openmp/run.sh$$. + +$head 04-19$$ +Improve connection from $cref reverse_identity$$ theorem +to $cref reverse_any$$ calculations. +$pre + +$$ +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. +$pre + +$$ +Add the $code sum_i_inv_time.cpp$$ OpenMP example case. +$pre + +$$ +There was a typo in the +$cref/second order/forward_order/Second Order/$$ discussion +(found by Kipp Martin). +It has been fixed. + + +$head 04-17$$ +Add a paragraph to $cref reverse_identity$$ explaining +how it relates to $cref reverse_any$$ calculations. +Add description of +$cref/first/reverse_any/First Order/$$ and +$cref/second order/reverse_any/Second Order/$$ +results in $cref reverse_any$$. + +$head 04-14$$ +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_checkpoint.cpp$$ for +reverse mode calculations. +$pre + +$$ +Improve the $cref reverse_identity$$ proof. + +$head 04-11$$ +Merge in changes made in $code branches/intro$$. + +$subhead 04-11$$ +Add $cref exp_eps_rev2$$ and its verification routine +$cref exp_eps_rev2.cpp$$. + +$subhead 04-10$$ +Finished off $cref exp_2_rev2$$ and +added $cref exp_2_rev2.cpp$$ which verifies its calculations. +Added second order calculations to $cref exp_2_cppad$$. +Added $cref exp_eps_for2$$ and its verification routine. + + +$subhead 04-07$$ +Added a preliminary version of $cref exp_2_rev2$$ +(does not yet have verification or exercises). + +$subhead 04-06$$ +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$$ +on 04-05). +$pre + +$$ +Added $cref exp_2_for2$$ to introduction. + +$subhead 04-05$$ +Use order expansions in introduction; e.g., the +$cref/second order expansion/exp_2_for2/Second Order Expansion/$$ +for the $cref exp_2$$ example. + +$head 03-31$$ +Merge in changes made in $code branches/intro$$ +and remove the corresponding Introduction item from the wish list: + +$subhead 03-31$$ +Create the a simpler exponential approximation in the $cref introduction$$ +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$$ +example). + +$subhead 03-30$$ +The Microsoft project file $code introduction/exp_apx/exp_apx.vcproj$$ +was referencing $code exp_apx_ad.cpp$$ which no longer exists. +It has been changed to reference $code exp_apx_cppad.cpp$$ +which is the new name for that file. + + +$head 03-29$$ +Fixed entries in this file where the year was mistakenly used for the month. +To be more specific, $codei%07-%dd%$$ was changed to $codei%03-%dd%$$ +for some of the entries directly below. +$pre + +$$ +Corrected some places where $code CppAD$$ was used in stead of $code Adolc$$ +in the $cref adolc_poly.cpp$$ documentation. +$pre + +$$ +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$$ +Example A.1.1c, $code example_a11c.cpp$$, +from the OpenMP 2.5 standards document, +was added to the tests that can be run using $code openmp/run.sh$$. + +$head 03-15$$ +Included the changes from openmp branch +so that so CppAD does not use the OpenMP $code threadprivate$$ command +(some systems do not support this command). + +$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. + +$subhead 03-14$$ +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 +the wrong setting of $code GETTIMEOFDAY$$. +The setting is now overridden (and always false) when the +$code _MSC_VER$$ preprocessor symbol is defined. +$pre + +$$ +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 +that does not use the OpenMP $code threadprivate$$ command +(not supported on some systems). + +$head 03-09$$ +Included the changes from openmp branch +so that OpenMP can be used with CppAD, +see $cref omp_max_thread$$. +The changes +dated between $cref/02-15/whats_new_07/03-09/02-15/$$ and 03-28 below +were made in the openmp branch and transferred to the trunk on 03-09. + + +$subhead 03-28$$ +The conditional include commands were missing on some include files; +for example +$codep + # 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. +$pre + +$$ +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 +which is better in a multi-threading environment). +$pre + +$$ +Added the user multi-threading interface +$cref omp_max_thread$$ along with its examples +which are distributed in the directory $code openmp$$. +$pre + +$$ +The $codei%speed/%*%.hpp%$$ files have been moved to +$codei%include/cppad/speed/%*%.hpp%$$ and the corresponding wish list +item has been removed. +$pre + +$$ +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. +A fix this wish list item has been added. +$pre + +$$ +Multiple active tapes required a lot of multi-threading access +management for the tapes. This was made simpler (and faster) +by having at most one tape per thread. + + +$subhead 02-22$$ +The include command in the $cref speed_test$$ documentation was +$codep + # include +$$ +but it should have been +$codep + # include +$$ +This has been fixed. + +$subhead 02-17$$ +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 +$cref/old Dependent syntax/FunDeprecated/Dependent/$$. + + +$subhead 02-16$$ +Added $codei%VecAD<%Base%>%$$ as a valid argument type for the +$cref/Parameter/con_dyn_var/Parameter/$$ +and $cref/Variable/con_dyn_var/Variable/$$ functions. +In addition, $cref/size_t indexing/VecAD/size_t Indexing/$$ +is was extended to be allowed during taping so long as the +VecAD object is a parameter. + + +$subhead 02-15$$ +Fixed the $code example/test_one.sh$$ script +(it was using its old name $code one_test$$). + +$head 02-06$$ +The $cref BenderQuad$$ documentation was improved by adding the fact +that the $icode x$$ and $icode y$$ arguments to the $codei%f%.dy%$$ +member function are equal to the $icode x$$ and $icode y$$ arguments +to $code BenderQuad$$. Hence values depending on them can be stored +as private objects in $icode f$$ and need not be recalculated. + +$head 02-04$$ +The method for distributing the documentation needed to be +changed in the top level $code makefile.am$$ in order to +be compatible with automake version 1.10. + +$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. +This was not a bug, but it has been changed to avoid +an error message when using CppAD with +$href%http://valgrind.org/%valgrind%$$. +$pre + +$$ +The change to the $code pow$$ function on +$cref/06-12-10/whats_new_06/12-10/$$ did not include the +necessary changes to the sparsity calculations. +This has been fixed. + +$head 02-02$$ +Fix minor errors and improve +$cref/profiling/autotools/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 +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 +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. + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/08.omh cppad-2019.02.00.0/omh/appendix/whats_new/08.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/08.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/08.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,430 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_08$$ +$spell + autotools + dir + inline + tanh + erf + nlp + fg_vector + Bool + Ipopt + Jacobians + Jacobian + cygwin + retape + det + Adolc + gcc + speedtest + tarballs + cppad + cpl + gpl + tgz + Microsoft + op + CppAD + yum + vec + eval + const +$$ + +$section Changes and Additions to CppAD During 2008$$ + + +$head Introduction$$ +This section contains a list of the changes to CppAD during 2008 +(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-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 +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 +$code test_more$$ directory). + +$head 12-04$$ +Extensive explanation for the $code ipopt_cppad/ipopt_cppad_ode$$ example was +provided in the section ipopt_cppad_ode. + +$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 +$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:%...%$$ +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 +these $code inline$$ directives are converted to +empty code when a Microsoft Visual C++ is used. + + +$head 11-20$$ +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 +$cref abs$$, $cref atan2$$, $cref LuRatio$$, $cref erf$$. +$pre + +$$ +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 +is differentiable at all points (not defined differently on subregions). +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 +to use $code const$$ (where appropriate). + +$head 10-17$$ +Major improvements to the $code ipopt_cppad/ipopt_cppad_ode$$ example. + +$head 10-16$$ +Minor improvement to description of optimization argument in +$code ipopt_cppad/ipopt_cppad_ode$$. + +$head 09-30$$ +Add or modify some wish list entries; see +$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). + + +$head 09-26$$ +Use parenthesis and brackets to group terms of the form +$latex m \times I$$ to make the documentation of +$cref cppad_ipopt_nlp$$ easier to read. + +Changed $code ipopt_cppad/ipopt_cppad_ode$$ to use $latex y(t)$$ for +the solution of the ODE to distinguish it for $latex x$$, +the vector we are optimizing with respect to. + +$head 09-18$$ +Changed $code ipopt_cppad/ipopt_cppad_ode$$ to a case where $latex x(t)$$ +is a pair of exponential functions instead of a linear and quadratic. +Fixed some of the comments in this example and included the source +code in the documentation (which was missing by mistake). + +$head 09-17$$ +Changed $code ipopt_cppad/ipopt_cppad_ode$$ to a case where there are +two components in the ODE (instead of one). +Also removed an initialization section that was only intended for tests +with a specific initial value. + +$head 09-16$$ +Add $code ipopt_cppad/ipopt_cppad_ode$$, an example and test +that optimizes the solution of an ODE. +Change $code r_eval$$ to $code eval_r$$ in $cref cppad_ipopt_nlp$$. +Fix a dimension of $code u_ad$$ error in $code ipopt_cppad_nlp$$. + +$head 09-12$$ +Converted from storing full Hessian and Jacobian to a sparse data structure +in $cref cppad_ipopt_nlp$$. +This greatly reduced the memory requirements (and increased the speed) +for sparse problems. + +$head 09-10$$ +Fixed more indexing bugs in $cref cppad_ipopt_nlp$$ +that effected cases where the domain index vector $latex J_{k, \ell}$$ +was different for different values of $latex k$$ and $latex \ell$$. +$pre + +$$ +In $cref cppad_ipopt_nlp$$, +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). + +$head 09-09$$ +Fixed an indexing bug in $cref cppad_ipopt_nlp$$. +(This effected cases where the domain index vector $latex J_{k, \ell}$$ +was different for different values of $latex k$$ and $latex \ell$$.) + +$head 09-07$$ +Change $cref cppad_ipopt_nlp$$ so that object and constraints +are expressed as the double summation of simpler functions. +This is more versatile that the single summation representation. + +$head 09-06$$ +Checked in a major change to $cref cppad_ipopt_nlp$$ +whereby the object and constraints can be expressed as the +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 cppad_ipopt_nlp$$ (not recording the function +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++) +- x_ad_vec[0] = x[j]; ++ x_ad_vec[j] = x[j]; +$$ +This did not show up in testing because there currently is no test of +$code ipopt_cppad_nlp$$ where the operation sequence depends +on the value of $latex x$$. +$pre + +$$ +Changed $code eval_grad_f$$ in $code ipopt_cppad_nlp.cpp$$ +to be more efficient. + +$head 09-04$$ +The $cref cppad_ipopt_nlp$$ interface has been changed to use +a derived class object instead of a pointer to a function. + +$head 09-03$$ +The $cref cppad_ipopt_nlp$$ interface has been changed to use +$code size_t$$ instead of $code Ipopt::Index$$. + +$head 09-01$$ +Back out the changes made to $cref cppad_ipopt_nlp$$ on 08-29 +(because testing proved the change to be less efficient in the case +that motivated the change). + +$head 08-29$$ +The $code push_vector$$ member function was missing from the +$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$$ +had type $code vectorBool$$. +This has been fixed. +$pre + +$$ +The $cref 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 +$cref cppad_ipopt_nlp$$. +In the case where there is not a lot of common terms +between the functions, the scalar evaluation may be more efficient. + +$head 08-19$$ +Add $cref/push of a vector/CppAD_vector/push_vector/$$ +to the $code CppAD::vector$$ template class. +This makes it easy to accumulate multiple scalars and +$cref/simple vectors/SimpleVector/$$ into one large $code CppAD::vector$$. + +$head 08-08$$ +There was an indexing bug in the +$cref cppad_ipopt_nlp$$ example +that affected the $icode retape$$ equal to $code false$$ case. +This has been fixed. +In addition, the missing +$icode retape$$ documentation was added. + +$head 07-02$$ +Extend $cref/configure/autotools/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 cppad_ipopt_nlp$$. +This is only an example class it may change with future +versions of CppAD. + +$head 06-15$$ +The nonlinear programming example $code ipopt_nlp_get_started.cpp$$ was added. +This is a preliminary version of this example. + +$head 06-11$$ +The sparsity pattern for the Hessian was being calculated each time +by $cref/SparseHessian/sparse_hessian/$$. +This is not efficient +when the pattern does not change between calls to $code SparseHessian$$. +An optional sparsity pattern argument was added to $code SparseHessian$$ +so that it need not be recalculated each time. + +$head 06-10$$ +The sparsity pattern for the Jacobian was being calculated each time +by $cref/SparseJacobian/sparse_jacobian/$$. +This is not efficient +when the pattern does not change between calls to $code SparseJacobian$$. +An optional sparsity pattern argument was added to $code SparseJacobian$$ +so that it need not be recalculated each time. + +$head 05-08$$ +The $cref sparse_jacobian$$ routine has been added. +$pre + +$$ +The example in $cref sparse_hessian$$ pointed to $cref hessian.cpp$$ +instead of $cref sparse_hessian.cpp$$. +This has been fixed. + +$head 05-03$$ +The $code retape$$ flag has been added to $cref speed_main$$. +In addition the routines +$cref link_det_minor$$, $cref link_poly$$, and $cref link_ode$$ +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 following tests use this flag: +$cref adolc_det_minor.cpp$$, +$cref cppad_det_minor.cpp$$, +$cref cppad_ode.cpp$$, +$cref adolc_poly.cpp$$, +$cref cppad_poly.cpp$$. +$pre + +$$ +Create specialized zero order forward mode routine that should be faster, +but does not test out as faster under cygwin g++ (GCC) 3.4.4. + + + + +$head 04-20$$ +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$$ +cases; see $cref speed_main$$. +In addition, +added the examples $cref ode_evaluate.cpp$$ and $cref sparse_hessian.cpp$$. +$pre + +$$ +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 +$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 +speed and correctness tests (now available). + + +$head 04-10$$ +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 +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/wish_list/$$ +entry has been completed and removed from the list: +"Change private member variables names +(not part of the user interface) +so that they all end with an underscore." + +$head 04-04$$ +Fix a problem compiling the speed test +$cref/main/speed_main/$$ program with gcc 4.3. + +$head 03-27$$ +Corrected $cref cppad_sparse_hessian.cpp$$ +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). +$pre + +$$ +Change the name of $code speedtest.cpp$$ to $cref speed_program.cpp$$. + + +$head 02-05$$ +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 +$code speed/cppad$$, $code speed/double$$, and $code speed/example$$ +were missing. This has also been fixed. + +$head 02-03$$ +There was an ambiguity problem +(detected by g++ 4.3) with the following operations +$codei% + %x% %op% %y% +%$$ +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$$. +$pre + +$$ +Remove compound assignment entry from wish list +(it was fixed on $cref/2007-05-26/whats_new_07/05-26/$$). +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 +when the input matrix had not a number or infinity in it. +This has been fixed. + +$head 01-24$$ +The $cref/postfix_dir/autotools/postfix_dir/$$ +has been added to the $code configure$$ command line options. + +$head 01-21$$ +A sparse Hessian case was added to the $cref speed$$ tests; see +$cref/sparse_hessian/link_sparse_hessian/$$. + +$head 01-20$$ +CppAD can now be installed using $code yum$$ on +$code Fedora$$ operating systems. + + +$head 01-11$$ +The CppAD correctness tests assume that machine epsilon is less +than $code 1e-13$$. A test for this has been added to the +$code test_more/test_more$$ program. + +$head 01-08$$ +Added a $cref sparse_hessian$$ routine and +extended $cref Hessian$$ to allow for a weight vector $icode w$$ +instead of just one component $icode l$$. + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/09.omh cppad-2019.02.00.0/omh/appendix/whats_new/09.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/09.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/09.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,566 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_09$$ +$spell + nlp + autotools + openmp + arg + std + bool + Microsoft + retape + isnan + atan + asin + acos + sqrt + OMhelp + doxygen + exp_eps_apx + cos + tarball + IpIpoptApplication + IpoptDir + autoconf + automake + config + jacobian + valgrind + svn + Prev + CppAD + Adolc + cppad + hpp + op + pycppad + cond_exp + VecAD + Jacobians + Jac + Taylor +$$ + +$section Changes and Additions to CppAD During 2009$$ + + +$head Introduction$$ +This section contains a list of the changes to CppAD during 2009 +(in reverse order by date). +The purpose of this section is to +assist you in learning about changes between various versions of CppAD. +(Comments about developer documentation are only important if you are +trying to read and understand the CppAD source code.) + +$head 12-23$$ +The +$code ADFun$$ $cref/assignment operator/FunConstruct/Assignment Operator/$$ +was changed so that it now copies forward mode +Taylor coefficients and sparsity pattern information. +(This assignment operator was added on $cref/10-24/whats_new_09/10-24/$$.) +You can use $cref capacity_order$$ to delete the Taylor coefficients +before copying them. +Two new functions were added so that you can query and delete the +forward mode sparsity information; +see +$cref/size_forward_bool/ForSparseJac/f/size_forward_bool/$$ and +$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 +for forward and reverse mode computations of an optimized tape. + +$head 12-18$$ +It turns out that detection of a sequence of additions makes the optimization +longer. This was simplified and makes slightly faster by converting two +jointly recursive routines to one non-recursive routine that uses a +stack for the necessary information. +More work is planned to make this optimization faster. + +$head 12-12$$ +Detection of a sequence of additions that can be converted to one variable +during the $cref optimize$$ process. +This leads to a significant improvement in the tape size and speed. + +$head 12-04$$ +Change hash coding of parameter values as part of operators +during the $cref optimize$$ process. +This should leads to more detection and removal of duplicate operations. + +$head 12-02$$ +Fix minor grammatical error in the Purpose heading +for $cref/conditional expressions/CondExp/Purpose/$$. +$pre + +$$ +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. + +$head 11-28$$ +Fix bug in tape optimization with $cref VecAD$$ objects. + +$head 11-27$$ +Remove duplicate expressions for the commutative binary operators; i.e., +addition and multiplication. + +$head 11-26$$ +Improve $cref optimize$$ command so that it removes some duplicate +expressions from the tape (more of this is planned). + +$head 10-30$$ +Make program that check Ipopt ODE example correctness +a separate file $code ipopt_nlp_ode_check.cpp$$ +Split out Ipopt driver for ODE example $code ipopt_nlp_ode_run.hpp$$. +Add the speed testing problem $code ipopt_cppad/ipopt_ode_speed.cpp$$. + +$head 10-29$$ +Split out the +ode inverse problem, +its simple representation, +and +its fast representation, +as a separate files; to be specific, +$code ipopt_nlp_ode_problem.hpp$$, +$code ipopt_nlp_ode_simple.hpp$$, +$code ipopt_nlp_ode_fast.hpp$$, +and +$code ipopt_nlp_ode_check.cpp$$. + +$head 10-28$$ +Improve the documentation for $code ipopt_nlp_ode_simple$$ and +$code ipopt_nlp_ode_fast$$. + +$head 10-27$$ +Moved old $code ipopt_cppad_simple.cpp$$ to $code ipopt_nlp_get_started.cpp$$, +created the example $code ipopt_nlp_ode_simple.hpp$$, +and split and $code ipopt_cppad_ode.cpp$$ +into $code ipopt_nlp_ode_fast.hpp$$ and $code 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 +function object. +The intention is that the two functions objects can do calculations in +parallel. +In addition, +CppAD now check for the $code ADFun$$ +$cref/copy constructor/FunConstruct/Copy Constructor/$$ +and generates an error message if it is used. + +$head 10-23$$ +The $cref sparse_hessian$$ routine was extended so the user can now choose +between vectors of sets and boolean vectors for representing +$cref/sparsity patterns/glossary/Sparsity Pattern/$$. + +$head 10-21$$ +The $cref CheckSimpleVector$$ function was extended so that +it can check simple vectors where the elements of the vector +can not be assigned to integer values. +This was done by adding the $cref/x, y/CheckSimpleVector/x, y/$$ +arguments to $code CheckSimpleVector$$. + +$head 10-16$$ +The $cref sparse_jacobian$$ routine was extended so the user can now choose +between vectors of sets and boolean vectors for representing +$cref/sparsity patterns/glossary/Sparsity Pattern/$$. + +$head 10-14$$ +The $icode packed$$ parameter for the sparsity routines +$cref ForSparseJac$$, $cref RevSparseJac$$, and $cref RevSparseHes$$ +(introduced on $cref/09-26/whats_new_09/09-26/$$) has been removed. +It has been replaced by changing the argument and return values +to be more versatile. +To be specific, they can now represent sparsity +using vectors of $code std::set$$ +instead of just as vectors of $code bool$$ +(see $cref/sparsity patterns/glossary/Sparsity Pattern/$$). + +$head 10-03$$ +The Microsoft Visual Studio project files for +examples and testing +and for +more correctness testing +were not including some new tests in their builds. +This has been fixed. + +$head 09-30$$ +Added the $cref cppad_sparse_jacobian.cpp$$ speed test +and increased the sizes used by $cref link_sparse_hessian$$. +Some mistakes were fixed in the documentation for speed tests +$cref link_sparse_hessian$$ and $cref sparse_hes_fun$$. + +$head 09-29$$ +The documentation definition of the function $latex H(x)$$ in +$cref RevSparseHes$$ was missing a factor of $latex R$$. +This has been fixed. + +$head 09-28$$ +Changed $cref RevSparseHes$$ so that it uses a sparse +representation when the corresponding call to +$cref ForSparseJac$$ used a sparse representation. +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. + +$head 09-26$$ +Added the $code packed$$ parameter to +$cref ForSparseJac$$ and $cref RevSparseJac$$. +If $icode packed$$ is false, +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. +The functions $code ForSparseJac$$ and $code RevSparseJac$$ +return packed representations. +The plan is to eventually provide new member functions that return +sparse representations. + +$head 09-20$$ +Fixed a bug in the $cref/Hessian Sparsity/RevSparseHes/$$ calculations +that included use of $cref VecAD$$ objects. + +$head 09-19$$ +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_pattern$$ calculations. +The result was that eight times the necessary memory was being used +during these calculations. This has been fixed. + + +$head 08-25$$ +Add $cref ad_fun.cpp$$ +an example of how to create your own interface to an $cref ADFun$$ object. + +$head 08-14$$ +Add $cref ad_in_c.cpp$$ +an example of how to link CppAD to other languages. + +$head 08_13$$ +Add an option to $cref optimize$$ an operation sequence. +$pre + +$$ +$bold Begin Merge$$ +$pre +$$ +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 +$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/$$ +is skipped when $code NDEBUG$$ is defined). +In addition, all of the $codei%speed/cppad/%*%.cpp%$$ tests +now check and use the speed test +$cref/optimize/speed_main/Global Options/optimize/$$ flag. + +$subhead 08-11$$ +Change the speed test $cref/main program/speed_main/$$ so +that it uses a list of options instead of a boolean flag for each option. +This will make it possible to add options in the future with out +having to change all the existing tests because the options are now +global variables instead of arguments to the speed test routines; for example, +see $code retape$$ speed test option. + +$subhead 08-10$$ +The routine for $cref/optimizing/optimize/$$ the operation sequence +has been added has been further tested using $code test_more/optimize.cpp$$. +Some bugs have been fix and the routine can +now be trusted to work correctly. +$pre + +$$ +The function +$cref/size_VecAD/seq_property/size_VecAD/$$ function was added +so that the user could see the $code VecAD$$ vectors +and elements corresponding to an operation sequence. + +$subhead 08-09$$ +A routine for $cref/optimizing/optimize/$$ the operation sequence +has been added. +This is a preliminary version and needs more testing before it can +be trusted to work correctly. +$pre +$$ +$bold End Merge$$ + + +$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 +$cref/size_par/seq_property/size_par/$$ was added +so that the user could see the number of parameters +corresponding to an operation sequence. + +$head 08-02$$ +Fix bug in new version of how $cref ForSparseJac$$ handles +$cref VecAD$$ objects. +$pre + +$$ +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 +$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. + +$head 07-31$$ +The $cref/forward/ForSparseJac/$$ and $cref/reverse/RevSparseJac/$$ +sparse Jacobian routines have been improved so the resulting sparsity +patterns are valid for all values of the independent variables +(even if you use $cref CondExp$$ or $cref VecAD$$). + +$head 07-26$$ +Convert developer documentation from +forward and reverse mode sweep routines from OMhelp to doxygen. + +$head 07-25$$ +Add developer documentation for $cref PrintFor$$ operations. + +$head 07-24$$ +Add developer documentation for $cref Discrete$$ operations. + +$head 07-23$$ +Add developer documentation for tape evaluation of $cref VecAD$$ store +operations. (a store operation changes the value of a VecAD element). +$pre + +$$ +Improve the $cref vec_ad.cpp$$ user example. + +$subhead 07-06$$ +Fixed a bug in second or higher order reverse mode calculations +that used $cref VecAD$$. +This bug was demonstrated by the test case $code SecondOrderReverse$$ +in the file $code test_more/vec_ad.cpp$$. +$pre + +$$ +Add developer documentation for tape evaluation of the +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 +introduced on 07-04 change. + +$head 07-04$$ +Add developer documentation for the +$cref CompareChange$$ operations during tape evaluation. +$pre + +$$ +$bold Begin Merge$$ +$pre +$$ +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 +$code branches/sweep$$. + +$subhead 07-04$$ +Fixed a bug in second or higher order reverse mode calculations +that included $cref/conditional expressions/CondExp/$$. +This bug was demonstrated by the test case $code SecondOrderReverse$$ +in the file $code test_more/cond_exp.cpp$$. +$pre + +$$ +A simpler and useful example was provided for +$cref/conditional expressions/CondExp/$$; +see $cref cond_exp.cpp$$. + + +$subhead 07-03$$ +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 +tape evaluation for power (exponentiation) operators. + +$subhead 07-01$$ +Fix an example indexing error in +$code introduction/exp_apx/exp_eps_for2.cpp$$ (found by valgrind). +$pre + +$$ +Add developer doxygen documentation of +tape evaluation for multiplication and division operators. + +$subhead 06-30$$ +Add developer doxygen documentation of +tape evaluation for addition and subtraction operators. + +$subhead 06-29$$ +Add developer doxygen documentation of +tape evaluation for sin, sinh, cos, and cosh. + +$subhead 06-28$$ +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. +This has been fixed. + +$head 06-22$$ +Fix compiler warnings during the $code openmp/run.sh$$ test. +$pre + +$$ +Changed $cref speed_example.cpp$$ to omit the $code speed_test$$ from +the correctness result. +In stead, a message is printed explaining that timing tests need +to be run without a lot of other demands on the system. + +$head 06-21$$ +The configure instructions for $cref/ipopt_dir/autotools/ipopt_dir/$$ +had the wrong path for $code IpIpoptApplication.hpp$$. +This has been fixed. + +$head 06-20$$ +Upgrade to from autoconf 2.61 to 2.63, +and from automake 1.10.1 to 1.11. +$pre + +$$ +Fix conflict between CppAD's use of config.h preprocessor symbols +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 +$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; +see $cref/complex FAQ/Faq/Complex Types/$$.) +$lnext +Fixing the $code not_complex_ad.cpp$$ problem above also fixed a warning +generated by $href%http://valgrind.org/%valgrind%$$. +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 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/autotools/$$ procedure. +This was has been fixed (revision 1362). + +$head 03-24$$ +Added cross references in +the $cref/examples/ListAllExamples/$$ to occurrence of the following tokens: +$cref AD$$, +$cref/ADFun/FunConstruct/$$, +$cref/CPPAD_TEST_VECTOR/test_vector/$$, +$cref Forward$$, +$cref Independent$$, +$cref Jacobian$$ +$cref NearEqual$$, +$cref Reverse$$. + +$head 02-20$$ +Demonstrate using AD to compute the derivative +of the solution of an ODE with respect to a parameter +(in the $cref runge45_2.cpp$$ example). + +$head 02-15$$ +Change the distribution +compressed tar file +to only contain one copy of the documentation. +Link to the current Internet documentation for the other three copies. + + +$head 02-01$$ +Move the $code Prev$$ and $code Next$$ buttons at the top of the documentation +to the beginning so that their position does not change between sections. +This makes it easier to repeatedly select this links. + + +$head 01-31$$ +Modify $code cppad/local/op_code.hpp$$ to avoid incorrect warning by +g++ version 4.3.2 when building $code pycppad$$ (a python interface to CppAD). + +$head 01-18$$ +Sometimes an error occurs while taping AD operations. +The $cref abort_recording$$ function has been added +to make it easier to recover in such cases. +$pre + +$$ +Previously, CppAD speed and comparison tests used Adolc-1.10.2. +The version used in the tests has been upgraded to +$href% + https://projects.coin-or.org/ADOL-C% + Adolc-2.0.0. +%$$ +$pre + +$$ +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. +$pre + +$$ +A minor typo has been fixed in the description of +$code W(t, u)$$ in $cref reverse_any$$. +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$$. + +$head 01-06$$ +Made some minor improvements to the documentation in +$cref FunConstruct$$. + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/10.omh cppad-2019.02.00.0/omh/appendix/whats_new/10.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/10.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/10.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,319 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_10$$ +$spell + autotools + Wshadow + pkg-config + Dir + libipopt + const + Linpack + Blas + makefile + op + arg + checkpointing + sizeof + libcppad_ipopt.a + Microsoft + Lagragian + iostream + obj_value + std::cout + endl + gcc + retape + hpp + ifdef + nlp + ipopt_cppad/src + CppAD +$$ + +$section Changes and Additions to CppAD During 2010$$ + +$head Introduction$$ +This section contains a list of the changes to CppAD during 2010 +(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-31$$ +$list number$$ +Add specifications for the CppAD $cref pkgconfig$$ files. +$lnext +Update the CppAD README file. +$lnext +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, +$code +sparse_pack.hpp:101:2: warning: declaration of 'end' shadows a member of 'this' +$$ +$lend + +$head 11-27$$ +If $code NDEBUB$$ was defined, +the default CppAD $cref/error handler/ErrorHandler/$$ would return +because its $code assert$$ had no effect in this case. +This has been fixed by placing a call to $code std::exit(1)$$ +after its assert. + +$head 09-26$$ +There was a bug +(introduced on 09-22) +in $code make test$$ +when the $code configure$$ command was executed from a directory +other than the distribution directory +(the $cref cppad_ipopt_nlp$$ did not build). +This has been fixed. + + +$head 09-22$$ +Promote $cref cppad_ipopt_nlp$$ from an example to a library +that gets installed +(provided that the $cref/ipopt_dir/autotools/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$$. + +$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/autotools/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 +$icode%ipopt_dir%/lib/libipopt.%*%$$ +(see $cref/ipopt_dir/autotools/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 +cppad_ipopt_nlp examples +work with both old and new versions of ipopt. + +$head 06-01$$ +In the case where the preprocessor symbol $code NDEBUG$$ was defined +(see $cref/speed/Faq/Speed/$$), +the function +$codei% + CheckSimpleVector(const %Scalar%& %x%, const %Scalar%& %y%) +%$$ +was not defined; see +$href%http://list.coin-or.org/pipermail/cppad/2010q2/000166.html%bug report%$$. +This has been fixed. + +$head 04-28$$ +Change the multi-level taping examples +$cref mul_level.cpp$$ and $cref mul_level_adolc.cpp$$ +to be more efficient. + +$head 04-26$$ +Include Blas and Linpack libraries in makefile links for +$cref cppad_ipopt_nlp$$ examples. +This removes the need to use get.Blas when building Ipopt. +$pre + +$$ +The speed test in $code cppad_ipopt/speed$$ was missing +a link to the library $code ../src/libcppad_ipopt.a$$. +This has been fixed. + +$head 04-24$$ +There was a bug in the error checking done by $code cppad/local/sub_op.hpp$$ +that caused the following improper abort: +$codei% +Error detected by false result for + arg[1] < i_z +at line 337 in the file + %...%/include/cppad/local/sub_op.hpp +%$$ +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%$$. + + +$head 04-01$$ +Some of the $cref speed_utility$$ library +(in $code speed/src$$) was being compiled for debugging. +This has been changed and they are now compiled with debugging off +and optimization on. + +$head 03-11$$ +The old $cref reverse_any$$ example was moved to $cref reverse_three.cpp$$, +the old checkpoint example is now the general case reverse example, +and a better $code checkpoint.cpp/$$ example was created. + +$head 03-10$$ +The $cref optimize$$ routine would mistakenly remove some +expressions that depended on the independent variables and that +affected the result of certain $cref CondExp$$ operations. +This has been fixed. + +$head 03-09$$ +Extend $cref reverse_any$$ so that it can be used for +$cref/checkpointing/chkpoint_one/$$; 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/Boolean Vector/$$ +sparsity patterns. +(when the number of elements per set was a multiple of +$code sizeof(size_t))$$. + +$head 02-11$$ +The $code speed$$ directory has been reorganized and the +common part of the $cref/link functions/speed_main/Link Functions/$$, +as well as the $cref microsoft_timer$$, +have been moved to the subdirectory $code speed/src$$ +where a library is built. + +$head 02-08$$ +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/autotools/Configure/$$ command line. +This has been fixed. + +$head 02-06$$ +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 +format.) +$pre + +$$ +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$$ +$list number$$ +Simplify running all the tests by adding the +$code make test$$ command. +$lnext +Simplify the $cref/configure/autotools/Configure/$$ command by removing +need for: +$code --with-Speed$$, +$code --with-Introduction$$, +$code --with-Example$$, +$code --with-TestMore$$, +and $code --with-PrintFor$$. +$lnext +Add files that were missing in the Microsoft Visual Studio +projects. +$lnext +Fix two significant bugs. One in the $cref optimize$$ command +and the other in the $cref PrintFor$$ command. +$lend + +$head 02-03$$ +Fix a mistakes in the test $cref bender_quad.cpp$$. +In addition, the $cref optimize$$ routine was used to reduce the +tape before doing the calculations. +$pre + +$$ +The routine $cref opt_val_hes$$ was added as an alternative to +$cref BenderQuad$$. + +$head 01-26$$ +Another speed improvement was made to $cref cppad_ipopt_nlp$$. +To be specific, the Lagragian multipliers where checked and components +that were zero were excluded form the Hessian evaluation. + +$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 +produced). This is because the argument value to $latex r_k (u)$$ depends +on the value of $latex \ell$$ in the expression +$latex \[ + r_k \circ [ J_{k, \ell} \otimes n ] (x) +\] $$ +(even when the value of $latex x$$ does not change). +$pre + +$$ +There was a bug in the $code ipopt_nlp_ode_check.cpp$$ program, +for a long time, that did not show up until now. Basically, +the check had code of the was using an undefined value. +This has been fixed. + +$head 01-23$$ +Improve the sparsity patterns and reduce the amount of memory +required for large sparse problems using $cref cppad_ipopt_nlp$$. +The speed test $code cppad_ipopt/speed$$ showed significant improvement. + + +$head 01-20$$ +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$$. +This will facilitate using $code CPPAD_IPOPT_*$$ for the +$code # ifdef$$ commands in the new include files +(note that they must begin with $code CPPAD$$). + + +$head 01-18$$ +The $code ipopt_cppad$$ subdirectory of the distribution +has been split into an $code src$$, $code example$$, and $code speed$$ +subdirectories. +The $code example$$ ($code speed$$) +subdirectory is where one builds the $cref cppad_ipopt_nlp$$ examples +(speed tests). + +$head 01-04$$ +The following items have been fulfilled and +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$$, +the tape recording can be stopped using $cref abort_recording$$. + +$lnext +A speed test for $cref cppad_ipopt_nlp$$ was added; see +$code ipopt_ode_speed.cpp$$. + +$lnext +The $cref optimize$$ command uses hash coding to check +when an expression is already in the tape and can be reused. + +$lnext +The $cref optimize$$ command removes operations that +are not used by any of the dependent variables. + +$lnext +The $cref ad_in_c.cpp$$ example demonstrates how to connect +CppAD to an arbitrary scripting language. + +$lnext +The vector of sets option has been added to sparsity calculations; +see $cref/sparsity pattern/glossary/Sparsity Pattern/$$. + +$lend + + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/11.omh cppad-2019.02.00.0/omh/appendix/whats_new/11.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/11.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/11.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,992 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_11$$ +$spell + mul + autotools + eps + cxx + namespace + boostvector + mega + inv + bthread + pthread + pthreads + Std + retape + cygwin + vcproj + pthread + https + abs_geq + CondExpRel + num + Taylor + Tanh + Rosen + Runge + executables + matlab + Addr + sizeof + undefine + config + adolc + initializer + vec + Bool + op + omp_alloc + isnan + gcc + hasnan + instantiation + Microsoft + svn + hes + openmp + prefixdir + pkgconfig + Fadbad + Wshadow + omh + dir + libspeed + cppad_ipopt_nlp.hpp + automake + makefile + builddir + gpl + http://www.coin-or.org/download/source/CppAD/cppad-20110101.0.cpl.tgz +$$ + +$section Changes and Additions to CppAD During 2011$$ + +$head Introduction$$ +This section contains a list of the changes to CppAD during 2011 +(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-30$$ +$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. +$lnext +Change the specifications for the derivative of the $cref abs$$ +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 +$cref%sign%base_std_math%sign%$$ function to the list of +$cref%base type requirements%base_require%$$. +$lend + +$head 12-28$$ +The file $cref/time_test.hpp/time_test/Include/$$ +was not being included by $code cppad/cppad.hpp$$. +This has been fixed. + +$head 12-21$$ +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 +$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 +change is to use the command +$codep + using namespace cppad_ipopt; +$$ + +$head 12-20$$ +$list number$$ +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 +$cref/NDEBUG/Faq/Speed/NDEBUG/$$. +$lnext +Improve $cref memory_leak$$ documentation. +$lend + +$head 11-29$$ +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. + +$head 11-27$$ +Move $code multi_thread.cpp$$ to $cref thread_test.cpp$$ +and fix its $cref/running/thread_test.cpp/Running Tests/$$ instructions. + +$head 11-24$$ +Create $cref preprocessor$$ section with pointers to all the +preprocessor symbols that are in the CppAD API. + +$head 11-21$$ +Separate $cref/--with-boostvector/autotools/--with-testvector/$$ +for $cref/boost_dir/autotools/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 +$cref/team_name/team_thread.hpp/team_name/$$ in the +$cref thread_test.cpp$$ output. +$lend + +$head 11-18$$ +$list number$$ +The $cref thread_test.cpp$$ program was truncating $icode test_time$$ +to the nearest integer. +This has been fixed. +$lnext +The $cref time_test$$ routine has been made more efficient and now +check for the case where only one execution of the test is necessary +to achieve the desired $icode test_time$$ +(it used to always run at least two). +$lnext +The $code sum_i_inv_time.cpp$$ and $cref multi_newton.cpp$$ +routines were calling the test an extra time at the end to check for +correctness. +The results of the last test are now cached and used for the correctness +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$$. +The use it for the timing tests in +$code sum_i_inv_time.cpp$$ and $cref multi_newton_time$$. +$lnext +Add $icode test_time$$ as a command line argument +to the multi-threading $code sum_i_inv$$ +and $cref/multi_newton/thread_test.cpp/multi_newton/$$ +timing tests. +$lend + + +$head 11-09$$ +Change $code thread_team.hpp$$ to $cref team_thread.hpp$$ and do +the same for all other names that ended in $code _team$$; e.g., +$cref team_openmp.cpp$$. + +$head 11-07$$ +The users choice for $cref test_vector$$ was not actually changing +the tests that the user ran. This have been fixed. + +$head 11-06$$ +Make all the output generated by $cref multi_newton.cpp$$ valid +matlab and octave input so it is easy to plot the results. + +$head 11-04$$ +Use thread specific data to simplify $cref team_openmp.cpp$$. + +$head 11-01$$ +Make $cref team_bthread.cpp$$ more similar to $cref team_pthread.cpp$$. + +$head 10-30$$ +$list number$$ +Reorganize and improve the $cref multi_thread$$ section and its subsections. +$lnext +There was a bug in $cref multi_newton.cpp$$ that only showed up when +the number of threads was greater than or equal 4. +This has been fixed. +In addition, +$cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$ +was increased from 2 to 4 (to enable testing for this bug). +$lnext +The accuracy expected in the $code sum_i_inv.cpp$$ results were failing +when $code mega_sum$$ was large. +This check has been modified to include a correction for $icode mega_sum$$. +$lend + +$head 10-29$$ +The following changes were merged in from $code branches/thread$$: + +$list number$$ +Move $code openmp$$ to $code example/multi_thread/openmp$$. +and create $code example/multi_thread/bthread$$, $code multi_thread/pthread$$ +with similar tests. +$lnext +Put multi-threading common code in $code multi_thread$$ directory +and threading system specific code in $codei%example/multi_thread/%threading%$$ +for $icode threading$$ equal to $code openmp$$, $code bthread$$, +and $code pthread$$. +$lnext +Update the README file. +$lnext +Remove the $code bug/optimize.sh$$ file (no longer a bug). +$lnext +Make $code arc_tan.cpp$$ +utility that can be used by multiple multi-threading tests. +$lnext +Create $cref team_thread.hpp$$ specifications, +move OpenMP management to $cref team_openmp.cpp$$, +Boost thread management to $cref team_bthread.cpp$$, +and pthread management to $cref team_pthread.cpp$$. +$lnext +All of the make files were modified so that the command +$codep + make test +$$ +would run the tests for the current directory. +$lnext +Extend the multi-threading speed tests +$code sum_i_inv.cpp$$ and $cref multi_newton.cpp$$ so they run +using Boost threads and pthreads (as well as OpenMP threads). +$lend + +$head 10-14$$ +Fix some compiler warnings about shadowed variables that were +detected by $code g++$$ version $code 4.6.1 20110908$$. + +$head 10-12$$ +$list number$$ +The MAC version of the $code pthread$$ library does not include the +$code pthread_barrier_wait$$ function; i.e., is not compliant with +the IEEE Std 1003.1, 2004 Edition for $code pthread$$. +This caused the $code pthread_simple_ad.cpp$$ to fail to compile on the MAC. +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 +$cref optimize$$ the functions $latex r_k (u)$$ such that +$codei%retape(%k%)%$$ is false. +$lend + +$head 09-06$$ +$list number$$ +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 +$cref/thread_num/ta_parallel_setup/thread_num/$$ argument +to $code parallel_setup$$. +$lnext +More simplification of $code bthread_simple_ad.cpp$$ example. +$lend + +$head 09-05$$ +Simply and fix some problems with $code pthread_simple_ad.cpp$$, +including avoiding a $cref/Bug in Cygwin/team_pthread.cpp/Bug in Cygwin/$$. + +$head 09-02$$ +$list number$$ +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 +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, +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/$$ +has been documented and is now part of the CppAD API. +$lnext +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. +This has been fixed by making +$icode%num_threads% == 1%$$ a special case in +$cref/parallel_setup/ta_parallel_setup/$$. +$lend + +$head 09-01$$ +$list number$$ +Modify the CppAD trunk using the +changes from svn revision 2060 to revision 2081 in the branch +$codep + 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-31/whats_new_11/09-01/08-31/$$. +$lnext +There was a bug in the $cref atomic_one$$ functions +in the case where none of the elements of the argument to the function +was a $cref/variable/glossary/Variable/$$. +This has been fixed. +In addition, 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 + +$subhead 08-31$$ +$list number$$ +Move the $code sum_i_inv_time.cpp$$ test from +$code openmp/run.sh$$ to $code openmp/run.cpp$$. +$lnext +Change $code --with-openmp$$ to +$cref/OPENMP_FLAGS=openmp_flags/autotools/openmp_flags/$$ configure +command line argument. +$lend + +$subhead 08-30$$ +$list number$$ +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/autotools/Configure/$$ +information for building the tests. +$lnext +Document the $code --with-openmp$$ configure +command line argument. +$lnext +Move $code openmp/multi_newton.hpp$$ to +$code openmp/newton_method.hpp$$ and +$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 +$cref multi_thread$$, the section on how to use CppAD in parallel. +$lnext +Implement $cref omp_alloc$$ as links to corresponding $cref thread_alloc$$ +sections. +$lnext +Create the $code pthread_simple_ad.cpp$$ example that does AD using the +pthread library. +In addition, fix some problems in $code openmp_simple_ad.cpp$$ +$lnext +Move $code openmp/example_a11c.cpp$$ to +$cref|example/a11c_openmp.cpp|a11c_openmp.cpp|$$. +$lnext +Move $code openmp/parallel_ad.cpp$$ to +$code openmp_simple_ad.cpp$$. +$lend + +$subhead 08-23$$ +Beginning steps in replacing $cref omp_alloc$$ by $cref thread_alloc$$: +$list number$$ +Replace $cref omp_alloc$$ by $cref thread_alloc$$ +in the $cref/utilities/utility/$$. +$lnext +move $cref omp_alloc$$ to the deprecated section of the +documentation. +$lnext +Change all $cref omp_alloc$$ section names to begin with $code omp_$$, +and change all $cref thread_alloc$$ section names to begin with $code new_$$. +$lnext +Convert $cref CppAD_vector$$ from using $cref omp_alloc$$ to using +$cref thread_alloc$$ for memory allocation. +$lnext +Extend the $cref memory_leak$$ routine to also check the +$cref thread_alloc$$ allocator. +$lend + +$subhead 08-21$$ +Create the OpenMP and pthread examples +$cref a11c_openmp.cpp$$, +$cref a11c_pthread.cpp$$, and +$code openmp_simple_ad.cpp$$. +These OpenMP examples were originally in the $code openmp$$ directory, +and have been moved, and modified to conform, to the normal example directory. + +$head 08-11$$ +Modify the CppAD trunk using the +changes from svn revision 2044 to revision 2056 in the branch +$codep + 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-10/whats_new_11/08-11/08-10/$$. + +$subhead 08-10$$ +$list number$$ +Add the output stream optional argument $icode s$$ in +$codei% + %f%.Forward(0, %x%, %s%) +%$$ +See $cref/zero order forward mode/forward_zero/$$ and $cref PrintFor$$. +$lnext +Improve omp_alloc.cpp example. +$lend + + +$subhead 08-09$$ +$list number$$ +$cref base_require$$: +Add $cref/epsilon/numeric_limits/epsilon/$$ to the +$icode Base$$ type requirements. +$lnext +Extend $code epsilon$$ to AD types. +$lend + +$subhead 08-08$$ +$list number$$ +Improve the $cref base_require$$ documentation for +$cref/standard math functions/base_std_math/$$. +$lnext +$cref base_require$$: +Add $code abs_geq$$ to the $cref/requirements/base_require/$$ +for a user defined $icode Base$$ type. +$lnext +Check that zero order forward mode results are approximately equal, +instead of exactly equal, +after an $cref optimize$$ operation. +This fixes a bug in the optimize correctness check +(The order of operations can be changed by $code optimize$$ +and hence the zero order forward mode results may not be exactly the same.) +$lend + +$subhead 08-07$$ +Improve the $cref base_require$$ documentation for +$cref/EqualOpSeq/base_identical/EqualOpSeq/$$, +$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. +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 base_require$$: +Change the $cref/include/base_require/Include Order/$$ file name to +$cref/base_require.hpp/base_require/$$. +$lnext +Use $cref base_float.hpp$$ and $cref base_double.hpp$$ as additional examples +for the $cref/CondExp Base requirements/base_cond_exp/$$ +requirements. +$lend + +$head 08-03$$ +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. + +$head 08-02$$ +$list number$$ +Change $cref PrintFor$$ so it no longer aborts execution when +there is no operation sequence being recording; see +$cref/start recording/Independent/Start Recording/$$. +$lnext +Improve the $cref print_for_cout.cpp$$ example. +$lend + +$head 07-31$$ +Add a conditional version of the $cref PrintFor$$ command +$codei% + PrintFor(%text%, %y%, %z%) +%$$ +which only prints when $icode%z% <= 0%$$. +This is useful for error reporting during forward mode; i.e., +reporting when the argument to the $code log$$ function is not valid. + +$head 07-29$$ +$list number$$ +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/$$ +by calls to $code set_max_num_threads$$. +$lnext +The functions $cref omp_efficient$$ was deprecated because it +has not been shown to be useful. +$lend + +$head 07-28$$ +$list number$$ +Change $cref omp_return_memory$$ so that if $cref omp_max_num_threads$$ is one +(the default), $cref omp_alloc$$ does not hold onto memory +(keep it available for the corresponding thread). +$lnext +Add files that were missing from the Microsoft Visual Studio +$code example$$ and $code test_more$$ subdirectory +project files. +$lnext +Fix some warnings generated by Microsoft Visual Studio 2010 build. +$lend + +$head 07-27$$ +Make $code tan$$ and $code tanh$$ $cref/atomic_base/glossary/Operation/Atomic/$$ +operations; see $cref tan_forward$$ and $cref tan_reverse$$. + +$head 07-25$$ +Finish the $cref atomic_one$$ example old_tan.cpp. +This is also a design and implementation of the routines necessary +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 lower order Taylor coefficients for $latex Y(t)$$. +This has been fixed in $cref tan_reverse$$. + +$head 07-17$$ +$list number$$ +Fix bug in $cref atomic_one$$ functions. +To be specific, the Taylor coefficients for $latex y$$, +of order less than $icode k$$, +were not passed into the $code atomic_one$$ +$cref/forward/atomic_one/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$$; +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; +see the new $cref atomic_one$$ example old_tan.cpp. +$lend + +$head 07-14$$ +$list number$$ +The $cref autotools$$ instructions for running the individual +correctness and speed tests were out of date. +This has been fixed; see +$cref/example and tests/autotools/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). +$lnext +Simplify $code example_a11c.cpp$$ by making it just a correctness test. +$lnext +Change $code openmp/run.sh$$ so that it runs correctness tests with +the compiler debugging flags. +$lend + +$head 07-13$$ +$list number$$ +static hash code data that was begin used by multiple threads +when recording $codei%AD<%Base%>%$$ operations +$cref omp_in_parallel$$ execution mode. This has been fixed. +$lnext +Make the sparse calculations safe +for use during $cref omp_in_parallel$$ execution mode. +$lnext +Add the $code parallel_ad.cpp$$ example. +$lnext +Change $code example_a11c.cpp$$ example so that is just a correctness +(not speed) test. +$lend + +$head 07-11$$ +$list number$$ +Change the upper limit for +$cref omp_max_num_threads$$ from 32 to 48. +$lnext +Add $cref/parallel/ta_in_parallel/$$ documentation for, +$code nan$$, +$cref/Rosen34/Rosen34/Parallel Mode/$$, and +$cref/Runge45/Runge45/Parallel Mode/$$. +$lnext +Fix $cref CheckNumericType$$ and $cref CheckSimpleVector$$ +so they work properly when used in parallel mode. +$lend + + +$subhead openmp/run.sh$$ +The following changes were made to $code openmp/run.sh$$: +$list number$$ +$lnext +Change to $code openmp/run.sh$$ +maximum number of threads +instead of specifying the entire set of values to be tested. +$lnext +Change settings for +$code newton_example$$ +so that $code n_gird$$ is a multiple of the maximum number of threads. +$lnext +Report dynamic number of thread +results as a separate result in the summary output line. +$lnext +Fix automatic removal of executables from $code openmp$$ directory +(was commented out). +$lnext +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); +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 +$code sum_i_inv_time.cpp$$ +assumed was being done. +$lend + +$head 07-09$$ +All the OpenMP parallel execution requirements +have been grouped in the section $cref multi_thread$$. + +$head 07-07$$ +Add the routine $cref parallel_ad$$ to fix bug when using +$codei%AD<%Base%>%$$ in $cref/parallel/omp_in_parallel/$$ execution mode. + +$head 06-23$$ +$list number$$ +Fix a bug whereby the assert +$codei% + Error detected by false result for + ! omp_in_parallel() + at line %n% in the file + %prefix%/include/cppad/omp_alloc.hpp +%$$ +sometimes occurred. +$lnext +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 +$cref deprecated$$ section of the CppAD manual. +$lend + +$head 06-21$$ +$list number$$ +The $code openmp/run.sh$$ routine was changed to use zero, +instead of $code automatic$$, for automatic choice of +$code openmp/run.sh$$ +number of repeats +and +maximum number of threads. + +$lnext +The output of each of the OpenMP examples / speed tests +(run by $code openmp/run.sh$$) +was changed to be valid matlab / octave assignment statements. + +$lnext +In the case where OpenMP is enabled during compilation, +a summary for the different number of threads as added at the end of +the $code openmp/run.sh$$ output. + +$lend + +$head 06-18$$ +$list number$$ +The $cref/tape_addr_type/autotools/tape_addr_type/$$ option was added +to the $cref/configure/autotools/Configure/$$ command line. +$lnext +The function $cref/size_op_seq/seq_property/size_op_seq/$$ results uses +$code sizeof(CppAD_TAPE_ADDR_TYPE)$$ +where it used to use $code sizeof(size_t)$$. +$lnext +Remove $code cppad/config.h$$ from CppAD distribution, +(put the information in $code cppad/configure.hpp$$.) +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/autotools/adolc_dir/$$ library linkage so it +works with version $code ADOL-C-2.2.0$$. +$lend + +$head 05-29$$ +Fix bug (introduced on $cref/05-22/whats_new_11/05-22/$$) +whereby constructor might not be called (but required) when the +$cref/base type/base_require/$$ is not plain old data. + +$head 05-28$$ +$list number$$ +Add the $cref omp_efficient$$ routine to the $cref omp_alloc$$ system. +$lnext +Improve the $code omp_alloc$$ tracing so it prints the same pointer +as returned to the user (not an offset version of that pointer). +$lend + +$head 05-26$$ +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 + an initializer of the form () will be default-initialized +$$ + + +$head 05-22$$ +$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 +environment; see $cref/purpose/omp_alloc/Purpose/$$. +$lnext +The replacement of $code TrackNewDel$$ by $code omp_alloc$$ +has been throughout the CppAD source code, including the examples +that used $code TrackNewDel$$; namely, +$cref mul_level_adolc.cpp$$, $cref mul_level_adolc_ode.cpp$$. +$lnext +The CppAD vector template class +and the $cref/vectorBool/CppAD_vector/vectorBool/$$ class +were modified to use the $code omp_alloc$$ +$cref/memory/CppAD_vector/Memory and Parallel Mode/$$ manager. +This should improves its speed of memory allocation +$cref omp_in_parallel$$ sections of a program. +$lnext +The $cref speed_test$$ argument +$cref/size_vec/speed_test/size_vec/$$ call was by value, +instead of by reference (as documented). +This has been fixed and the call is now by reference. +$lnext +The $cref/capacity/CppAD_vector/capacity/$$ function has been added +to the CppAD vector class. +$lnext +The simple vector +$cref/ + element constructor and destructor/ + SimpleVector/ + Element Constructor and Destructor +/$$ +description has been changed to explicitly specify that the +default constructor is used to initialize elements of the array. +$lnext +The $cref/size_op_seq/seq_property/size_op_seq/$$ documentation +has been improved to mention that the allocated memory may be larger. +$lend + +$head 05-11$$ +$list number$$ +Avoid ambiguity in the definition of the +$cref/complex isnan/base_complex.hpp/isnan/$$ function. +$lnext +Errors during $code make test$$ were not +being detected. +This has been fixed. +$lend + +$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 +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 +$cref cppad_ipopt_nlp$$ objective function, the constraints, +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 +handler has not been replaced). +$lend + +$head 04-29$$ +$list number$$ +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% + http://msdn.microsoft.com/en-us/library/bh44f2cb(v=vs.71).aspx% + Compiler Error C2918 +%$$. +These project files were converted to Visual Studio 2008 where they do work +(if you use a later version, Visual Studio should automatically +convert them for you). + +$lnext +The old speed test directory was moved to $code speed_cppad$$ +before the new $cref speed$$ test organization was created on 2006-12-11 +(revision 715 of the repository). +The old speed tests have not been used for years and so have been deleted. +$lend + +$head 04-20$$ +The $code openmp/run.sh$$ script what changed +to take an argument that specifies which tests is run +(it no longer runs all the tests). +Also improve the openmp test program output formatting. + +$head 04-19$$ +The $icode use_ad$$ option was added to the +$code openmp_newton_example.cpp$$ test case. + +$head 03-19$$ +The subversion write protected directory +$code bin/.svn$$ was mistakenly part of the +compressed tar file It has been removed. + +$head 03-11$$ +The vector of sets argument +$cref/r/atomic_one/rev_hes_sparse/r/$$ +to the $code atomic_one$$ function $icode rev_hes_sparse$$ +must have size greater than or equal to $icode n$$. +There was a check that its size was greater than or equal $icode q$$. +This was incorrect and has been fixed. + +$head 03-05$$ +Add the $cref/conjugate gradient/conj_grad.cpp/$$ example. + +$head 02-22$$ +Add the $cref/atomic/speed_main/Global Options/atomic/$$ option to the +speed test program and use +old_mat_mul.hpp during the +$cref cppad_mat_mul.cpp$$ speed test when the atomic option is specified. + + +$head 02-19$$ +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) +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 +$code openmp/run.sh$$ +openmp_flag was not $code ""$$. +This has been fixed. + +$head 02-15$$ +A matrix multiply speed test has been added. +So far, this has only implemented for the +$cref/cppad/cppad_mat_mul.cpp/$$ and $cref/double/double_mat_mul.cpp/$$ cases. +(For the time being this test is not available for the other +speed comparison cases.) + +$head 02-09$$ +A variable in $code atomic_one.hpp$$ was declare of type $icode Base$$ +when it should have been declared of type $code size_t$$. +It caused the $cref atomic_one$$ feature to fail with some base types. +This has been fixed. +$pre + +$$ +The old_mat_mul.hpp example has been improved by +caching the $latex x$$ variable information and using it during +$cref/reverse Hessian sparsity/atomic_one/rev_hes_sparse/$$ calculations. +$pre + +$$ +Some of the $cref atomic_one$$ documentation was extended to +include more explanation. + +$head 02-06$$ +The use can now define complex $cref/atomic_base/atomic_one/$$ operations +and store them in a CppAD $cref ADFun$$ object. +This item has been remove from the +$cref/wish list/wish_list/$$. +$pre + +$$ +The documentation for $cref RevSparseHes$$ had a dimension error. +This has been fixed. +$pre + +$$ +A faster set operations item was added to the wish list. +This has since been satisfied by +$code cppad_sparse_list$$ choice during +the install process (since removed). + +$head 02-02$$ +The documentation for $cref ForSparseJac$$ had some formatting errors. +The errors have been fix and the documentation has been improved. + +$head 02-01$$ +The subversion +install instructions were brought up to date. +They have since been replaced by just separate +$code subversion$$ instructions. + +$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%$$ +to +$icode%prefixdir%/share/pkgconfig/cppad.pc%$$; +see +$href%http://lists.fedoraproject.org/pipermail/devel/2011-January/147915.html% +devel@lists.fedoraproject.org%$$. + +$head 01-16$$ +The following have been fixed: +$list number$$ +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/autotools/Configure/$$ command in it. +$lnext +Since the change on 01-09, the file +$code omh/appendix/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/autotools/cxx_flags/$$. +$lend + +$head 01-09$$ +There were some problems running $code make test$$ in the releases +$codei% +http://www.coin-or.org/download/source/CppAD/cppad-20110101.0.%license%.tgz +%$$ +where $icode license$$ is $code gpl$$ or $code cpl$$. +$list number$$ +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/autotools/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 +release versions; i.e., +$codei% +http://www.coin-or.org/download/source/CppAD/cppad-20110101.1.%license%.tgz +%$$ +will not have this problem. + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/12.omh cppad-2019.02.00.0/omh/appendix/whats_new/12.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/12.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/12.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,1047 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_12$$ +$dollar @$$ +$spell + autotools + plugin + checkpointing + Jacobians + doxygen + txt + sys + stdbool + datadir + pkgconfig + cppad_ipopt_nlp + includedir includedirs + libdir libdirs + Ubuntu + Microsoft + cmake + CondExpOp + src + std + hes + dw + uninitialised + resize + bool + taddr + eigen + fabs + mul + det_lu + adolc + fadbad + sacado + CppADvector + retape + Jacobian + dir + -lteuchos + trilinos + inorder + pthread + helgrind + Taylor + Debian + valgrind + num + alloc + makefile + hpp + gcc + cppad-%yyyymmdd% + lpthread + xout + fabs + fcur + CppAD + openmp +$$ + +$section CppAD Changes and Additions During 2012$$ + +$head Introduction$$ +This section contains a list of the changes to CppAD during 2012 +(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-30$$ +$list number$$ +Merge changes in $code branches/ipopt_solve$$ to $code trunk$$, +delete that branch, and +advance version number to $code cppad-20121230$$. +$lnext +Remove $code cppad/configure.hpp$$ from repository because +it is built by the configuration process +(even for MS Visual Studio, now that we are using $cref cmake$$). +$lnext +Add the $codei%AD<%Base%>%$$ input stream operator $cref/>>/ad_input/$$. +$lend + +$head 12-29$$ +In $code branches/ipopt_solve$$: +$list number$$ +Complete implementation of sparse Jacobian and Hessian calculations +and add options that allow to user to choose between forward and reverse +sparse Jacobians. +$lnext +The $cref ipopt_solve$$ routine seems to be faster and simpler +than $cref cppad_ipopt_nlp$$. +More speed comparisons would be good to have. +$lnext +All of the $cref/ADFun Drivers/Drivers/$$ +have added specifications for the zero order Taylor coefficients +after the routine is called. +For example, see +$cref/Hessian uses forward/Hessian/Hessian Uses Forward/$$. +$lend + + +$head 12-28$$ +In $code branches/ipopt_solve$$: +$list number$$ +Add the $cref ipopt_solve_retape.cpp$$ and $cref ipopt_solve_ode_inverse.cpp$$ +examples. +$lnext +Use $code ipopt::solve$$ $cref/options/ipopt_solve/options/$$ +argument (and not a file) for all the Ipopt options. +As well as allowing for adding $code ipopt::solve$$ special options; e.g., +$cref/retape/ipopt_solve/options/Retape/$$. +$lend + +$head 12-27$$ +In $code branches/ipopt_solve$$: +Change documentation section names that begin with $code cppad_ipopt$$ +to begin with $cref/ipopt_nlp/cppad_ipopt_nlp/$$ +to distinguish them from $cref/CppAD::ipopt::solve/ipopt_solve/$$. + +$head 12-26$$ +In $code branches/ipopt_solve$$: +$list number$$ +Convert documentation most all documentation references from +the deprecated $cref autotools$$ instructions to the new $cref cmake$$ +instructions. +$lnext +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$$ +which is easier to use. +This is a first version of $code ipopt_solve$$ and its speed +and memory use needs to be improved. +$lend + +$head 12-23$$ +Copy development $code trunk$$ to $code branches/ipopt_solve$$. + +$head 12-22$$ +Define a doxygen module (group) for each file that has doxygen documentation. + +$head 12-20$$ +$list number$$ +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 +get installed in the $code cppad$$ include directory. +$lnext +Advance the version number to $code cppad-20121220$$. +$lend + +$head 12-19$$ +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 +$code compare_c/det_by_minor.c$$ source code. + +$head 12-17$$ +There was a mistake in a check for a valid op code in the +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 +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 +$codei% + cppad_prefix%/cmake_install_datadir%/cppad.pc +%$$ +This has been fixed and is now +$codei% + cppad_prefix%/cmake_install_datadir%/pkgconfig/cppad.pc +%$$ +$lnext +The $cref pkgconfig$$ documentation has been improved. +$lnext +The command for running the +$cref/adolc examples/adolc_prefix/Examples/$$ and +$cref/eigen examples/eigen_prefix/Examples/$$ +was fixed +(changed from $code make check$$ to $code make check_example$$). +$lend + + +$head 12-14$$ +$list number$$ +Fix the old $cref autotools$$ so that it works with the +new $code cppad.pc$$. +$lnext +Fix the old installation +$cref/--with-Documentation/autotools/--with-Documentation/$$ option +(it was attempting to copy from the wrong directory). +$lend + + +$head 12-13$$ +$list number$$ +Include documentation for $cref ipopt_prefix$$ +$lnext +Fix the $code cppad.pc$$ $cref pkgconfig$$ file +so that it includes the necessary libraries and include commands +when $cref ipopt_prefix$$ is specified; see +$cref/pkgconfig usage/pkgconfig/Usage/$$. +$lend + + +$head 11-28$$ +Update the $cref wish_list$$: +$list number$$ +Remove Microsoft compiler warning item that has been fixed. +$lnext +Remove faster sparse set operations item that was completed using +$code cppad_sparse_list$$ (not part of user API). +$lnext +Remove $cref cmake$$ items that have been completed. +$lnext +Remove $cref CondExp$$ items related to using +$code AD< std::complex >$$ types because it is better to use +$code std::complex< AD >$$. +$lnext +Remove $cref thread_alloc$$ memory chunk item that has been completed. +$lnext +Remove $cref VecAD$$ item about slicing from floating point type to $code int$$ +(not important). +$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/chkpoint_one/$$ +can now be used for this purpose.) +$lnext +Add new $code atomic_one$$ $cref wish_list$$ item (since removed). + +$lend + +$head 11-21$$ +$list number$$ +Fix the +$cref/version/download/Version/$$ number in link to the +current download files. +$lnext +Change the +$code subversion$$ download instructions to use +the $code export$$ instead of $code checkout$$ command. +This avoids downloading the source code control files. +$lend + +$head 11-20$$ +$list number$$ +The $code cmake$$ variables +$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/$$ +to signify the fact that they can now be a list of directories. +$lnext +Advance version number to $code cppad-20121120$$. +$lend + +$head 11-17$$ +$list number$$ +Finish documenting the new $cref cmake$$ configuration instructions +and deprecate the old $cref/unix/autotools/$$ instructions. +$lnext +Change the specifications for +$cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$ +to allow for a value of one. +This enables one to have more tapes during a program execution. +$lnext +Include the $cref/C versus C++/compare_c/$$ speed comparison +in the $cref cmake$$ build. +$lend + +$head 11-16$$ +Fix a warning that occurred in $cref Rosen34$$ +when it was compiled with the preprocessor symbol $code NDEBUG$$ defined. + +$head 11-14$$ +Advanced the CppAD version to $code cppad-20121114$$. + +$list number$$ +Started documenting the +$cref cmake$$ configuration procedure during installation. +This included factoring out the +$cref download$$ procedure as a separate section +so that the same download instruction also apply to the +$cref/unix/autotools/$$ install procedure. + +$lnext +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 +with $code NDEBUG$$ is defined and to pass. + +$lnext +In the case where $code NDEBUG$$ is defined, +removed detection of $code nan$$ during forward mode from +$code test_more/forward.cpp%$$. +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$$. +The wish list items were completed and removed. + +$lend + + +$head 11-09$$ +The $cref team_pthread.cpp$$ was failing to link on Ubuntu 12.04 +because the libraries were not at the end of the link line. +This has been fixed. + +$head 11-06$$ +$list number$$ +Remove some remaining references to the old licenses CPL-1.0 and GPL-2.0; +see $cref/10-24/whats_new_12/10-24/$$. +$lnext +Remove out of date Microsoft project files from the distribution. +The build system is being converted to use +$href%http://www.cmake.org%cmake%$$ which builds these files automatically +and thereby keeps them up to date. +This feature is not yet documented, but one can inspect the file +$code bin/run_cmake.sh$$ to see how to use $code cmake$$ with CppAD. +$lend + + +$head 11-04$$ +Add missing return value to the example $code base_alloc$$ +$cref/CondExpOp/base_alloc.hpp/CondExpOp/$$ function. +This has been fixed and the comments for this example have been improved. + +$head 10-31$$ +The CppAD $cref/profiling/autotools/Profiling CppAD/$$ was not compiling +the $code speed/src/*.cpp$$ files with the profiling flag. +This has been changes +(only for the profiling speed test). + +$head 10-30$$ +The $cref/fadbad_dir/autotools/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. +This has been fixed by properly defining $codei%fabs(%x%)%$$ where +$icode x$$ is a double (without the $code std$$ in front). + +$head 10-24$$ +Change the CppAD licenses from CPL-1.0 and GPL-2.0 to +EPL-1.0 and GPL-3.0. + +$head 10-12$$ +$list number$$ +Change all the multiple levels of AD examples to +start with $cref mul_level$$. +To be specific, move +$code taylor_ode.cpp$$ to $cref mul_level_ode.cpp$$ and +$code taylor_ode_adolc.cpp$$ to $cref mul_level_adolc_ode.cpp$$. +$lnext +Add $cref taylor_ode.cpp$$ as a example of Taylor's method for solving ODEs, +($cref mul_level_ode.cpp$$ is an application of this method +to multi-level AD.) +$lend + +$head 10-04$$ +$list number$$ +Change $cref speed_main$$ so that it outputs small rates (less than 1000) +with two decimal points of precision (instead of as integers). +In addition, flush result for each size when it finishes to give user +more feedback about how things are progressing. +$lnext +Add the optional $cref/test_size/time_test/test_size/$$ argument +to the $code time_test$$ routine. +$lend + +$head 10-03$$ +Change the $code hold_memory$$ speed to option to just +$cref/memory/speed_main/Global Options/memory/$$. +In addition, in the speed test output, include all of the options +that are present in the output variable name; +see $cref/speed results/speed_main/Speed Results/$$. + +$head 10-02$$ +Fix another problem with Debian's $code /bin/sh$$ shell executing +$code example/multi_thread/test.sh$$; see $cref/03-17/whats_new_12/03-17/$$ + +$head 09-24$$ +Improve documentation for the +$cref atomic_one$$ +$cref/rev_hes_sparse/atomic_one/rev_hes_sparse/$$ +argument +$cref/v/atomic_one/rev_hes_sparse/v/$$. +In addition, +add sparsity calculations to the old_reciprocal.cpp example. + +$head 09-11$$ +Add $code user_simple.cpp$$, +a simpler $cref atomic_one$$ example. + +$head 08-05$$ +$list number$$ +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 +$code --with-sparse_option$$ (since removed). +$lnext +A new speed test, $cref compare_c$$, compares the speed of the same +source code compiled with C and C++. +$lend + +$head 07-30$$ +$list number$$ +The $cref/clear/CppAD_vector/clear/$$ function was added to +$code CppAD::vector$$. +$lnext +Warning !!: +The $code CppAD::vector$$ $cref/resize/CppAD_vector/resize/$$ specifications +were changed so that $icode%x%.resize(0)%$$ no longer frees +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 +$code optimize.cpp$$ example: +$codep + ==6344== Conditional jump or move depends on uninitialised value(s) +$$ +$lnext +Fix mistake in old_tan.cpp where $code w[2] = 0$$ +was missing before the call +$codep + dw = F.Reverse(1, w); +$$ +$lend + +$head 07-08$$ +$list number$$ +Improve the documentation for $cref pow$$ and $cref pow_int$$. +$lnext +Change all the example section names to be same as corresponding file names; +e.g. change $code vectorBool.cpp$$ to $cref vector_bool.cpp$$ +for the example $code example/utility/vector_bool.cpp$$. +$lend + +$head 07-07$$ +Add the $code CPPAD_TAPE_ID_TYPE$$ argument to the +$cref/configure/autotools/Configure/$$ command line. + +$head 07-05$$ +Deprecate $cref/CPPAD_TEST_VECTOR/test_vector/$$ and use +$cref/CPPAD_TESTVECTOR/testvector/$$ in its place. +This fixes a problem introduced by changes on 07-03 whereby code that +used $code CPPAD_TEST_VECTOR$$ would no longer work. + +$head 07-04$$ +$list number$$ +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/autotools/Configure/$$ option was +added to the $code configure$$ command line. +$lend + +$head 07-03$$ +Fix bug in $cref atomic_one$$ functions identification of variables +that caused old_tan.cpp to fail with error message +$codep +Error detected by false result for + y_taddr > 0 +at line 262 in the file cppad/local/dependent.hpp +$$ + +$head 07-02$$ +Add $code eigen_plugin.hpp$$ so that +an Eigen vector can be used as a +$cref SimpleVector$$. +This has since been removed; see +$cref/2017-05-11/whats_new_17/05-12/$$. + +$head 07-01$$ +$list number$$ +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. +%$$ +$lnext +Fix bug whereby a newly constructed $cref VecAD$$ object was a +$cref/variable/con_dyn_var/Variable/$$ (instead of a parameter) directly after construction +(when no previous $cref/ADFun/FunConstruct/$$ object had been created). +$lnext +Change a $code ok != a == 0.$$ to $code ok &= a == 0.$$ in +the example $cref ad_ctor.cpp$$. +$lnext +Add the $cref eigen_array.cpp$$ example. +$lend + +$head 06-17$$ +$list number$$ +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 $code numeric_limits$$ $cref/epsilon/numeric_limits/epsilon/$$. +$lnext +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 +$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/autotools/prefix_dir/$$ directory. + +$head 06-12$$ +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/Global Options/memory/$$ option +to the speed test main program. +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 +three to approximately ten. +$lend + +$head 06-09$$ +Change $cref adolc_sparse_jacobian.cpp$$ to use the sparse adolc +Jacobian (instead of the full Jacobian) driver. +This was also done for $cref adolc_sparse_hessian.cpp$$, +but there is a problem with the test that is being investigated. + +$head 06-08$$ +Implement the matrix multiply speed test $cref link_mat_mul$$ for all packages +(there is a problem with the $cref fadbad_mat_mul.cpp$$ +implementation and it is being looked into). + +$head 06-07$$ +Make all the speed tests implementations (for the specific packages) +uniform by having a Specification and Implementation heading and similar +indexing. For example, see +$cref adolc_det_minor.cpp$$, +$cref cppad_det_minor.cpp$$, +$cref double_det_minor.cpp$$, +$cref fadbad_det_minor.cpp$$, and +$cref sacado_det_minor.cpp$$. + +$head 06-05$$ +Add the $cref sacado_ode.cpp$$ speed test. + +$head 06-04$$ +$list number$$ +The specifications for $cref Runge45$$ where changes so that +it uses the $code fabs$$ function instead of the $code <$$ operation. +This enabled the a more precise statement about its +$cref/operation sequence/Runge45/Operation Sequence/$$. +$lnext +The $code fabs$$ function as added to the CppAD standard math library +(see $cref abs$$) +and the $cref/base type requirements/base_std_math/$$. +This enables one to write code that works with $code AD$$ as +well as $code double$$ without having to define $code abs$$ for +$code double$$ arguments +(and similarly for $code float$$). +$lnext +Add the $cref adolc_ode.cpp$$ and $cref fadbad_ode.cpp$$ speed tests +(and edit the $cref cppad_ode.cpp$$ test). +$lend + +$head 06-03$$ +$list number$$ +The $code CppAD::vector$$ class was extended to allow assignment +with the target of size zero and the source of non-zero size; +see $cref/check size/CppAD_vector/Assignment/Check Size/$$. +$lnext +A memory leak and a bug in $code cppad_mat_mul.cpp$$ were fixed +(the bug was related to the change to $code CppAD::vector$$ above). +$lend + +$head 06-02$$ +$list number$$ +Remove the deprecated symbol +$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 +$cref deprecated$$ features. +$lnext +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. +$lnext +Use same argument for taping and derivative evaluation when +$code retape$$ speed test option is true. +$lnext +Implement the $icode%retape% == false%$$ option +in $cref cppad_ode.cpp$$. +$lnext +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 +$code det_lu$$, $code det_minor$$, $code poly$$. +$lend + +$head 06-01$$ +Change +$cref cppad_sparse_hessian.cpp$$ and +$cref cppad_sparse_jacobian.cpp$$ +to use +the $icode row$$, $icode col$$ interface to $cref sparse_hessian$$. +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 +$cref speed_cppad$$ 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 +inputs (instead of being chosen randomly by the test for each repetition). +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/utilities/utility/$$ +so that it can be used by the implementations of +$cref link_sparse_jacobian$$ and $cref link_sparse_hessian$$. + +$head 05-27$$ +Split the sparse Jacobian and Hessian test function the separate function +$cref sparse_jac_fun$$ and $cref sparse_hes_fun$$ +(do not use sparse Hessian for both). +In addition, change row and column indices from $icode i$$ +and $icode j$$ to $icode row$$ and $icode col$$. + +$head 05-24$$ +Merged in changes from $code branches/sparse$$: +$list number$$ +A new interface was added to +$cref sparse_jacobian$$ and $cref sparse_hessian$$. +This interface +returns a sparse representation of the corresponding matrices +using row and column index vectors. +$lnext +The examples +$cref sparse_jacobian.cpp$$ and +$cref sparse_hessian.cpp$$ were improved +and extended to include the new interface. +$lnext +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/autotools/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 +$codei%boost_dir%/boost%$$ was the boost include directory, +now $codei%boost_dir%/include%$$ is the boost include directory. +This make it the same as the other directory arguments on the configure +command line. +In addition, it fixes some bugs in the detection of the boost +multi-threading library. + + +$head 04-18$$ +Add documentation and testing for not using $cref/free_all/ta_free_all/$$ and +$cref/atomic_one clear/atomic_one/clear/$$ while in +$cref/parallel/ta_in_parallel/$$ mode. + +$head 04-17$$ +Fix bug when using $cref atomic_one$$ functions with +$cref/multi_threading/multi_thread/$$. + +$head 04-10$$ +Add control of the +$cref/max_num_threads/autotools/max_num_threads/$$ argument +to the unix +$cref/configure/autotools/Configure/$$ command. + +$head 04-06$$ +$list number$$ +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 +$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$$ +was deprecated. +$lnext +Add the $code -lteuchos$$ flag to the link line for the +$cref speed_sacado$$ tests. +(This was not necessary for $code trilinos-10.8.3$$ +but is necessary for $code trilinos-10.10.1$$) +$lend + +$head 04-05$$ +The restriction was added that +$cref parallel_ad$$ cannot be called while a tape is being recorded. +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/$$. +This has been fixed and the error message below no longer occurs. +Suppose that you ran the CppAD +$cref/configure/autotools/Configure/$$ command in the $code work$$ +directory. +If you then edited the file $code work/multi_thread/makefile$$ +and changed +$codep + # AM_CXXFLAGS = -g @(CXX_FLAGS) + AM_CXXFLAGS = -DNDEBUG -O2 @(CXX_FLAGS) +$$ +to +$codep + AM_CXXFLAGS = -g @(CXX_FLAGS) + # AM_CXXFLAGS = -DNDEBUG -O2 @(CXX_FLAGS) +$$ +and then executed the commands +$codep + make clean + make pthread_test + valgrind --tool=helgrind ./pthread_test simple_ad +$$ +The following error message would result: +$icode% + ... snip ...% +==7041== Possible data race during write of size 4 at 0x8077460 by thread #1 +==7041== at 0x804FE23: CppAD::AD::tape_new() (tape_link.hpp:221) +% ... snip ... +%$$ + + + +$head 03-27$$ +Reduce the amount of memory allocation and copying of information during +a $cref Dependent$$ operation or an $code ADFun$$ +$cref/sequence constructor/FunConstruct/Sequence Constructor/$$. + +$head 03-26$$ +Calling $code taylor_capacity$$, with to with capacity equal to zero, +was not +$cref/freeing memory/capacity_order/c/Freeing Memory/$$. +This has been fixed. + +$head 03-23$$ +$list number$$ +Improve, the multi-threading examples +$cref simple_ad_openmp.cpp$$, +$cref simple_ad_bthread.cpp$$, and +$cref simple_ad_pthread.cpp$$. +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/$$ +during $code parallel_ad$$ call. +These statics are required to use +$cref/CppAD::vector/CppAD_vector/$$. +$lnext +Add a debugging check to make sure $cref CheckSimpleVector$$ +is initialized in sequential mode. +$lend + +$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 +different thread during parallel execution. + +$head 03-17$$ +Debian recently converted the default shell corresponding to +$code /bin/sh$$ to $code dash$$ +(which caused $code example/multi_thread/test.sh$$ to fail). +This has been fixed. +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 +%$$. + +$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 +$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 +$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. + + +$head 03-03$$ +$list number$$ +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/autotools/boost_dir/$$ +is not the prefix during the boost installation). +$lend + +$head 03-02$$ +$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 +$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$$). +This enabled the removal of $code example/multi_thread/arc_tan.cpp$$. +$lnext +In $cref team_example.cpp$$ check that all of the threads +pass their individual test; i.e. $codei%work_all_[%thread_num%]%.ok%$$ +is true for all $icode thread_num$$. +$lend + +$head 02-11$$ +$list number$$ +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. +$lend +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/$$ +is greater than one +(still can't be in parallel mode). + +$head 02-10$$ +$list number$$ +Add the missing Base class requirements in +the entire $cref base_member$$ section +and under the $cref/Output Operator/base_require/Output Operator/$$ +in the $cref base_require$$ section. +$lnext +Add the $cref base_alloc.hpp$$ example. +$lend + + +$head 02-09$$ +$list number$$ +Add the $icode set_static$$ to $cref memory_leak$$. +This is necessary for testing base types that allocate memory +for each element. +$lnext +Fix memory allocation bug in $code cppad/local/pod_vector.hpp$$ +when each element of the $cref/Base/base_require/$$ type allocated memory. +$lend + +$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/autotools/boost_dir/$$ override the default +library. + +$head 01-27$$ +There were some problems with +$cref/configure's/autotools/Configure/$$ automatic detection of +the boost multi-threading library. +These have been fixed. + +$head 01-24$$ +It used to be that $cref thread_alloc$$ did not hold onto memory +when $icode num_threads$$ was one in the previous call to +$cref/parallel_setup/ta_parallel_setup/$$. +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 +when there is only one thread. +To convert old code to the new interface, after each call to +$codei% +thread_alloc::parallel_setup(%num_threads%, %in_parallel%, %thread_num%); +%$$ +put the following call +$codei% +thread_alloc::hold_memory(%num_threads% > 1); +%$$ + +$head 01-23$$ +Change variable notation and use $cref optimize$$ in +$cref mul_level.cpp$$. + +$head 01-20$$ +$list number$$ +Add the example $cref change_param.cpp$$ +which shows how to compute derivatives of functions that have +parameters that change, but derivatives are not computed +with respect to these parameters. +$lnext +The documentation for machine $cref epsilon$$ +has been improved. +(The fact that it can be used for $icode Base$$ types was missing.) +$lend + +$head 01-19$$ +$list number$$ +In cases where $code test.sh$$ is trivial, +put its operations in corresponding makefile. +$lnext +Fix problem compiling $code cppad/speed/sparse_evaluate.hpp$$ +under gcc on Fedora 17. +$lnext +Run $code example/multi_thread/test.sh$$ from source directory +(no need to copy to build directory). +$lend + +$head 01-16$$ +The test program $code example/multi_thread/test.sh$$ failed if the +$cref/openmp_flags/autotools/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. + +$head 01-15$$ +Fix $code make test$$ so it works when +$cref/configure/autotools/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 +$cref multi_thread$$ test program linker command. +This has been fixed. + +$head 01-07$$ +$list number$$ +A duplicated code block beginning with +$codep +if( fabs( fcur ) <= epsilon_ ) +$$ +was removed from the routine $code multi_newton_worker$$. + +$lnext +The distance between solutions that are joined to one solution +has been corrected from $latex (b - a) / (2 n )$$ to +$latex (b - a) / n $$; see +$cref/xout/multi_newton_run/xout/$$. +The correction was in the file $cref multi_newton.cpp$$ where +$code sub_length_ / 2$$ was change to $code sub_length_$$. + +$lend + +$head 01-02$$ +$list number$$ +The $cref thread_alloc$$ memory allocator was changed to avoid +certain false sharing situations +(cases where two different thread were changing and using memory +that is on the same page of cache). +On one tests machine, the execution time for the 32 thread case for the test +$codep +./openmp_test multi_newton 1 32 1000 4800 10 true +$$ +improved from 0.0302 seconds to 0.0135 seconds. + +$lnext +There was a problem with the correctness test section of the +$cref multi_newton_time$$ test. +The convergence criteria, and correctness criteria, +needed to be scaled by the largest argument values. +This was a problem with over a hundred zeros were included in the test +(and the largest argument value was $latex 100 \pi$$ or more). + +$lnext +There was a problem with the way that +$cref multi_newton_takedown$$ +joined two solutions into one. +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 + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/13.omh cppad-2019.02.00.0/omh/appendix/whats_new/13.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/13.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/13.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,547 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_13$$ +$dollar @$$ +$spell + sq + usead + ctor + Num + autotools + nz + Jacobian + CondExp Lt Gt Eq + op_arg + Adolc + aka + sacado + resize + sb + IpIpoptAlg.cpp + inf + const + algo + afun + cxx + checkpointing + cout + typename + bool + struct + impl + std + alloc + ptr + isnan + cmake + namespace + testvector + eigen + microsoft + src + jac + hpp + Wunused + Cpp + cppad +$$ + +$section CppAD Changes and Additions During 2013$$ + +$head Introduction$$ +This section contains a list of the changes to CppAD during 2013 +(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$$ +$list number$$ +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 autotools$$ +(created when optional implicit constructor from any type was added). +This has been fixed by adding the +$code --with-implicit_ctor$$ option +(later removed on $cref/2017-02-10/whats_new_17/02-10/$$.) +$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 +$cref/eigen 3.2/eigen_prefix/$$ (scheduled to be fixed in 3.3). +The default for this constructor has been changed to be +$cref/explicit/ad_ctor/x/explicit/$$. +In addition, other +$cref/implicit/ad_ctor/x/implicit/$$ constructors +are now listed in the documentation. +$pre + +$$ +If you get a compiler error on an constructor / assignment of the form +$codei% + AD<%Base%> x = %y% +%$$ +(that used to work) try changing the constructor call to +$codei% + AD<%Base%>( %y% ) +%$$ +A deprecated alternative is to make this constructor implicit using the +$cref/cppad_deprecated/cmake/cppad_deprecated/$$ +option during the install procedure. + +$head 12-26$$ +Document fact that monthly versions +of the CppAD compressed tar file last till the end of the year. +This is no longer the case; see +$cref/05-20/whats_new_18/05-20/$$ in whats new for 2018. + +$head 12-24$$ +The interface to $cref/eigen/cppad_eigen.hpp/$$ defined a function +$codei% + NumTraits< CppAD::AD<%Base%> >::dummy_epsilon() +%$$ +that should have been named $code dummy_precision()$$. +This has been fixed. + +$head 11-27$$ +$list number$$ +Fix bug when using $cref optimize$$ with an $cref ADFun$$ object containing +the $cref sign$$ function. +$lnext +Add $code atomic_two_norm_sq.cpp$$, an atomic function example +with domain dimension two and range dimension one. +$lend + +$head 11-13$$ +It used to be that one had to define the $code std::set$$ version of +$cref atomic_two_rev_sparse_jac$$ for each atomic function that was +part of an $cref ADFun$$ object that was $cref/optimized/optimize/$$. +Now the current +$cref/atomic_sparsity/atomic_two_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. + +$head 11-12$$ +Error detection and reporting (when $code NDEBUG$$ is not defined) +has been added for the following case: +Using $cref optimize$$ +with $cref atomic_two$$ functions that have not defined +$cref/rev_sparse_jac/optimize/Atomic Functions/rev_sparse_jac/$$. + +$head 10-29$$ +The $cref/optimization/CondExp/Optimize/$$ +now handles nested conditional expressions. +For example, give the code +$codep + 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 conditional expressions will be evaluated +(one will be skipped depending on the result of $code left_z == right_z$$). +For more details, see $cref optimize_nest_conditional.cpp$$. + +$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/dependency/RevSparseJac/dependency/$$ argument to the +reverse Jacobian sparsity pattern calculation. +$lnext +Fix the deprecated autotools install (see $cref autotools$$) +which was broken by the changes on 10-22. +To be specific, the +example for $cref number_skip$$ was not being included. +$lend + +$head 10-22$$ +$list number$$ +Add $cref/optimization/optimize/$$ of conditional expressions; see +$cref/CondExp/CondExp/Optimize/$$. +$lnext +Add a phantom argument at the beginning of the operations sequence; +$cref/size_op_arg/seq_property/size_op_arg/$$ and $cref seq_property.cpp$$. +(This helps with the optimization mentioned above.) +$lnext +Add the function $cref number_skip$$ to measure how much optimization +of the conditional expressions there is. +$lend + +$head 10-16$$ +Fix bug in $cref/Tracing/wish_list/Tracing/$$ $cref atomic$$ functions. + +$head 10-15$$ +The documentation for the class +$cref/vectorBool/CppAD_vector/vectorBool/$$ was improved. + +$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 +$code build$$ directory. +Note that this local install of Adolc requires ColPack; see +$cref get_colpack.sh$$. +In addition, the requirement that ColPack and Adolc are installed +with the same prefix was added. + +$head 10-13$$ +Make sure that all of the +$cref preprocessor$$ symbols +that are not part of the CppAD API, are undefined when the +$code $$ file concludes. + +$head 10-12$$ +$list number$$ +Change $cref get_eigen.sh$$ so that it will reuse install information +when it is present. +In addition document reuse for +$cref/get_eigen.sh/get_eigen.sh/Reuse/$$, +$cref/get_ipopt.sh/get_ipopt.sh/Reuse/$$, and +$cref/get_sacado.sh/get_sacado.sh/Reuse/$$. +$lnext +Fix following $code g++$$ error on OSX system: +$codep +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]; + ^ +$$ +$lend + +$head 09-20$$ +$list number$$ +Add lines for $cref atomic_two$$ function documentation +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 +atomic forward examples. +$lnext +Improve the documentation for $cref atomic_two_clear$$ +and remove its use from the +$cref/atomic_base examples/atomic_two/Examples/$$ +(because it is not needed). +$lend + +$head 09-19$$ +Add links from the $cref atomic_two$$ functions documentation +to the corresponding examples. +This required adding headings in the examples that +correspond to the function documentation sections. +For example; see +atomic forward examples. + +$head 09-18$$ +$list number$$ +A segmentation fault would occur if +an $cref ADFun$$ object used an $cref atomic$$ +function that had been deleted. +This has been fixed so that when $code NDEBUG$$ is not defined, +an error message is generated. +$lnext +A mistake in the documentation for +$cref/Memory and Parallel Mode/CppAD_vector/Memory and Parallel Mode/$$ +has been fixed. +This corresponds to the change in the specifications for +$cref/CppAD::vector::resize/CppAD_vector/resize/$$ made on +$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 reverse$$ mode. +This has been fixed. +$lnext +It appears, from inspecting the Ipopt source file +$code Ipopt/src/Algorithm/IpIpoptAlg.cpp$$ that the option $code sb$$ +to $code yes$$ suppress the printing of the Ipopt banner. +The Ipopt examples and tests have been changed to use this option +(although it is not in the ipopt documentation). +$lnext +Fix the a typo in the documentation for $code ipopt_solve$$ +$cref/Integer/ipopt_solve/options/Integer/$$ options +($code Numeric$$ was changed to $code Integer$$). +$lend + +$head 09-07$$ +There was a bug in the cumulative sum operator +(which is used by $cref optimize$$ ) +for $cref Forward$$ orders greater than zero. +This was detected by the $cref/checkpoint/chkpoint_one/$$ tests +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). + +$head 08-12$$ +$list number$$ +The ability to turn on and off checking for $cref nan$$ in +$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/chkpoint_one/$$ functions that +$cref/atomic functions/optimize/Atomic Functions/$$ in within +another function is optimized. +$lnext +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$$.) +$lend + +$head 08-11$$ +If an $cref atomic$$ function had arguments that did not affect +the final dependent variables in $icode f$$, +$cref/f.optimize()/optimize/$$ would fail. +This has been fixed. +In addition, documentation about using $code optimize$$ +with $cref/atomic functions/optimize/Atomic Functions/$$ has been added. + +$head 08-06$$ +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.) +$$ +can result in the imaginary part of $code check$$ being $code - nan$$. + +$head 07-26$$ +Allow for use of $code const::string&$$ as a possible type for +$cref/name/atomic_two_ctor/atomic_base/name/$$ in the $code atomic_base$$ +constructor. + +$head 05-28$$ +Remove $icode ok$$ return flag from +$cref/checkpoint algo/chkpoint_one/algo/$$ +and +$cref/checkpoint atom_fun/chkpoint_one/atom_fun/$$. + +$head 05-21$$ +$list number$$ +Deprecate the $cref atomic_one$$ interface and replace it by the +$cref atomic_two$$ and $cref/checkpoint/chkpoint_one/$$ interfaces. +$lnext +There was a problem with the $cref cmake$$ command +if the $cref/cppad_cxx_flags/cmake/cppad_cxx_flags/$$ was not specified. +This has been fixed. +$lend + + +$head 05-17$$ +$list number$$ +Add the $cref/transpose/ForSparseJac/transpose/$$ option to +$cref ForSparseJac$$. +$lnext +Add the $cref/transpose/RevSparseHes/transpose/$$ option to +$cref RevSparseHes$$. +$lend + +$head 05-15$$ +Change $cref RevSparseJac$$ parameter names to be closer to the +$cref ForSparseJac$$ names so the difference is clearer. + +$head 05-14$$ +$list number$$ +The $cref/checkpoint/chkpoint_one/$$ class has been added. +This is a much easier way to do checkpointing than the +old checkpoint example. +The old checkpointing example is now the $cref reverse_checkpoint.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 +vector of $code bool$$. +$lnext +Add the $cref/transpose/RevSparseJac/transpose/$$ option to +$cref RevSparseJac$$. +$lend + +$head 05-12$$ +The sparse hessian example in old_reciprocal.cpp was not +being run. This has been fixed. + +$head 05-11$$ +The $cref atomic_one$$ examples +names were all changed to begin with $code user$$. + +$head 05-04$$ +The option to compute +$cref/multiple orders/forward_order/xq/Multiple Orders/$$ was added. +The old_usead_2.cpp example shows the need for this. +The problem is that a new atomic function interface needs to be designed +with checkpointing as a particular application. +Multiple order forward mode is the first step in this direction. + +$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 +$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. +$lnext +The code $codei%std::cout << %X%$$, +would generate a compile error when $icode X$$ was an Eigen matrix +with $codei%CppAD::AD<%Base%>%$$ elements. +This has been fixed. +$lend + + +$head 04-27$$ +There was a problem using the output operator $code <<$$ with +and $cref/eigen/cppad_eigen.hpp/$$ matrix of $code AD$$ elements. +This has been fixed using a template partial specialization of +$codep + template + struct significant_decimals_default_impl +$$ +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 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 +$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. +$lend + +$end + +$head 04-20$$ +The example old_usead_1.cpp was added. + +$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. + +$head 04-14$$ +The following program, +when executed, would cause a CppAD assertion with an unknown source: +$codep + # include + int main(void) + { size_t min_bytes = static_cast(-1); + size_t cap_bytes; + void *v_ptr = CppAD::thread_alloc::get_memory(min_bytes, cap_bytes); + return 0; + } +$$ +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 + Error detected by false result for + min_bytes < std::numeric_limits::max() / 2 +$$ + + +$head 03-02$$ +The function $cref/isnan/nan/$$ no longer allows for systems +that return false for $icode%x% != %x%$$ when $icode x$$ is $code NaN$$. +This makes the $code isnan$$ function faster. +In addition, it removes the need to store a static value +which causes complications for parallel execution (as well as other problems). +Thus, it is no longer necessary for the first call to $code isnan$$ +to be during sequential execution and it has been removed from the +multi-threading $cref/initialization/multi_thread/Initialization/$$ list. + +$head 03-01$$ +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 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. + +$head 02-20$$ +$list number$$ +The documentation for the $cref cmake$$ install option +$code cppad_test_vector_namespace$$ was fixed to be +$cref/cppad_testvector/cmake/cppad_testvector/$$. +This was also fixed for the +$cref/eigen test vector/eigen_prefix/Test Vector/$$ documentation. +$lnext +An option to specify that the compiler supports c++11 constructs, +$code cppad_c11_flag$$, was added +to the $code cmake$$ command line. +$lend +$head 01-07$$ +Fix undefined $code microsoft_timer$$ when building the +$cref speed_example.cpp$$ program. + +$head 01-06$$ +$list number$$ +The $cref limits$$ documentation was corrected an improved. +$lnext +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/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 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 +The $cref speed_example.cpp$$ was not linking when using a shared +object library for the code in $code speed/src$$. +This has been fixed by not including the library when linking +the speed examples. +$lend + +$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 +for download at +$pre + $$ +$href%http://www.coin-or.org/download/source/CppAD/%$$ +$lnext +Advance version number for trunk to $code 20130102$$. +$lend + +$head 01-01$$ +When compiling with $cref/NDEBUG/Faq/Speed/NDEBUG/$$ defined, +the following warning could be generated: +$codei% +%...%rev_sparse_jac.hpp:315:9: warning: unused variable 'm' [-Wunused-variable] +%$$ +This has been fixed. + + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/14.omh cppad-2019.02.00.0/omh/appendix/whats_new/14.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/14.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/14.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,473 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_14$$ +$dollar @$$ +$spell + hes + autotools + cstdint + addr + omhelp + autoconf + automake + alloc + ifndef + asin + acos + uj + op + hpp + taylor + forwardzero + forwardone + forwardany + const + doxygen + ipopt + adolc + colpack + Jacobian + openmp + pthread + bthread + isnan + onetape + retape + fadbad + sacado + boolsparsity + cmake + docdir + CppAD + cppad + datadir + erf + cmath + ctor + std + num +$$ + +$section CppAD Changes and Additions During 2014$$ + +$head Introduction$$ +This section contains a list of the changes to CppAD during 2014 +(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-30$$ +There was a bug in the $cref cmake$$ whereby it would sometimes mistakenly +exit with the error message +$codep + cppad_max_num_threads is not an integer greater than or equal 4 +$$ +This has been fixed. + +$head 12-29$$ +The example $code not_complex_ad.cpp$$ was using the type +$codei% + std::complex< CppAD::AD > +%$$ +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 +$cref/complex FAQ/faq/Complex Types/$$. + + +$head 12-28$$ +$list number$$ +Fix some warnings generated by clang 3.5 about local functions +that were not being used; e.g., sub-tests that were not being executed. +$lnext +Fix $code cmake$$ setting +$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. +This caused these tests to hang while trying to determine how +many times to repeat the test. +This has been fixed. +$lend + +$head 12-27$$ +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 +Hessian sparsity patterns $code atomic_two_rev_sparse_hes.cpp$$ was added. + +$head 12-25$$ +More work on the bug in +$cref/optimizing/CondExp/Optimize/$$ +conditional expressions. + +$head 12-23$$ +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 +atomic operation. +$pre + +$$ +Fix typo in tangent reverse mode theory for +$cref/Positive Orders/tan_reverse/Positive Orders Z(t)/$$. + +$head 12-22$$ +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/autotools/autotools/$$ install procedure. + +$head 12-16$$ +If the $code c++11$$ include file $code $$ +defines all the standard types, they can be used by to specify +$cref/cppad_tape_addr_type/cmake/cppad_tape_addr_type/cstdint/$$ and +$cref/cppad_tape_id_type/cmake/cppad_tape_id_type/cstdint/$$. + +$head 12-15$$ +Correct the title and $cref _index$$ entries for $cref forward_two$$ +from first to second order. + +$head 11-28$$ +Improve the $cref/index/_index/$$ and $code search$$ using +a new version of the $code omhelp$$ documentation tool. + +$head 11-27$$ +$list number$$ +Add alignment to the +$cref/get_memory/ta_get_memory/Alignment/$$ and +$cref/create_array/ta_create_array/Alignment/$$ specifications +and +$cref/thread_alloc example/thread_alloc.cpp/$$. +$lnext +Advance the deprecated $cref/unix install/autotools/$$ utilities to +autoconf-2.69 and automake-1.13.4. +$lend + +$head 09-28$$ +Fix more bugs related to optimizing condition conditional expressions. +$list number$$ +Using old instead of new operator indices. +$lnext +Not properly following dependence back through atomic operations. +$lnext +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 +Reverse mode not properly handling the variable number of arguments in the +conditional skip operation. +$lnext +Reverse mode tracing not properly handling the variable number +of argument operations; i.e., conditional skip and cumulative summation. +$lend + +$head 09-27$$ +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 +$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 +$cref/any order reverse/reverse_any/$$. +To be specific, $latex x^{(k)}$$ was changed to be $latex u^{(k)}$$. + +$head 05-28$$ +$list number$$ +Change the $cref/boolsparsity/speed_main/Sparsity Options/boolsparsity/$$ +so that it only affects the sparsity speed tests +$cref/sparse_jacobian/link_sparse_jacobian/$$ and +$cref/sparse_hessian/link_sparse_hessian/$$; +i.e., it is now ignored by the other tests. +$lnext +Improve the $cref speed$$ documentation page. +$lend + +$head 05-27$$ +$list number$$ +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 because +$code cppad_colpack.cpp$$ is not an include file. +$lnext +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 autotools $cref/unix install/autotools/$$ instructions +to use the $cref cmake$$ install instructions. +These instructions should work on any system, not just unix. + +$head 05-22$$ +$list number$$ +Add multiple direction for mode +$cref forward_dir$$ and use it to speed up the forward +version of $cref sparse_jacobian$$. +Below is an example run of $cref cppad_sparse_jacobian.cpp$$ results +before this change: +$codep + cppad_sparse_jacobian_size = [ 100, 400, 900, 1600, 2500 ] + cppad_sparse_jacobian_rate = [ 2973, 431.94, 142.25, 78.64, 26.87 ] +$$ +and after this change: +$codep + 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, +$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. +$lend + +$head 05-20$$ +$list number$$ +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 +$code cppad/ipopt/solve_callback.hpp$$. +$lnext +Add $code # ifndef$$ command to $code test_more/extern_value.hpp$$. +$lend + + +$head 05-19$$ +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/$$. +These may have not be defined operations in certain cases and +have been converted to $code uj = Base(0)$$. + + +$head 05-16$$ +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 +$codei%include/cppad/local/%*%sweep.hpp/%$$). +This has been fixed. + +$head 05-14$$ +$list number$$ +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. +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 +$code BeginOp$$ was zero that caused an abort when using the undocumented +$code TRACE$$ option available in files of the form +$codei%include/cppad/local/%*%sweep.hpp/%$$. +This has been fixed. +$lend + +$head 03-18$$ +$list number$$ +The +$cref/size_taylor/FunDeprecated/size_taylor/$$ +and +$cref/capacity_taylor/FunDeprecated/capacity_taylor/$$ +functions were deprecated; +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. +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 +$cref/move semantics/CppAD_vector/Assignment/Move Semantics/$$ +version of the $code CppAD::vector$$ assignment statement +was not checking vector sizes. +This has been fixed so that things work the same with compilers +that do not have move semantics. +(Note that with move semantics, no extra memory allocation is done +even if the target vector has a different size.) + +$head 03-09$$ +The documentation links +$code forwardzero$$, $code forwardone$$, and $code forwardany$$ +have been changed to +$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 +$cref/forward/forward_order/$$, +$cref/reverse/reverse_any/$$, +$cref atomic_two_forward$$, and +$cref atomic_two_reverse$$ functions +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. +Note that the set of available tests can depend on the +$cref/list of options/speed_main/Global Options/$$. +$lnext +In the documentation for +$cref/n_sweep/sparse_jacobian/n_sweep/$$, +mention that it is equal to the number of colors determined by the +$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 +$cref/optimize/speed_main/Global Options/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. +$lnext +$cref/Move semantics/CppAD_vector/Assignment/Move Semantics/$$ +were added to the $code CppAD::vector$$ assignment operator. +$lend + +$head 03-01$$ +$list number$$ +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 +Move $icode x$$ near end of $cref link_sparse_hessian$$ speed test +parameter list, +(as is the case for $cref link_sparse_jacobian$$). +$lend + +$head 02-28$$ +The $cref/data/CppAD_vector/data/$$ function was added to the +$code CppAD::vector$$ template class. + +$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$$. +This has been fixed. + +$head 02-26$$ +$list number$$ +The +$cref/adolc/speed_adolc/$$ and +$cref/cppad/speed_cppad/$$ sparse jacobian speed tests now print out +$cref/n_sweep/sparse_jacobian/n_sweep/$$. +$lnext +The size of some of the $cref speed$$ test cases has been increased +to test behavior for larger problems. +$lnext +A link to $cref ode_evaluate$$ was missing in the +$cref/Speed Utility Routines/speed_utility/Speed Utility Routines/$$ table. +This has been fixed. +$lend + + +$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/$$ +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 +$cref/sparse_hessian/link_sparse_hessian/$$ speed tests). + + +$head 02-22$$ +The program names in +$cref thread_test.cpp$$ where changes from +$icode%threading%_test%$$ to $codei%multi_thread_%threading%$$ +where $icode threading$$ is $code openmp$$, $code pthread$$ or $code bthread$$. + +$head 02-17$$ +Fix ambiguous call to $cref/isnan/nan/isnan/$$ +during MS Visual Studio 2012 compilation. + +$head 02-15$$ +$list number$$ +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 +$cref/onetape/speed_main/Global Options/onetape/$$ so that the default +is to retape (option not present). +This was done because +$cref/fadbad/fadbad_prefix/$$ and +$cref/sacado/sacado_prefix/$$ always retape. +$lnext +The documentation, and example source code, for all the speed +$cref/options/speed_main/Global Options/$$ was improved +(made clearer). +$lnext +Improve the success rate for +$cref speed_test.cpp$$ and $cref time_test.cpp$$. +$lend + +$head 01-26$$ +The destination directory for the +$cref/cppad documentation/cmake/cmake_install_docdir/$$ +is now set separately from the data directory +using the $code cmake$$ option +$codei% + -D cmake_install_docdir=%cmake_install_docdir% +%$$ +This has increased the flexibility of the documentation installation +and removed the need for the option +$codei% + -D cppad_documentation=%yes_or_no% +%$$ +which has been removed. + +$head 01-21$$ +The destination directory for the +cppad documentation +used to be one of the following: +$codei% + %prefix%/%datadir%/doc/cppad-%version% + %prefix%/%datadir%/doc/%postfix%cppad-%version% +%$$ +This has been changed by dropping the $icode version$$ number +at the end of the directory name. + +$head 01-10$$ +The change on $cref/2013-12-27/whats_new_13/12-27/$$ +caused a conversion error in $cref atan2$$ when it was used with +$code AD< AD >$$ arguments (and other similar cases). +This has been fixed. + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/15.omh cppad-2019.02.00.0/omh/appendix/whats_new/15.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/15.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/15.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,935 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_15$$ +$dollar @$$ +$spell + chkpoint + sq + autotools + 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-31$$ +The $cref download$$ instructions were modified to have more mention of +git and less mention of +subversion. + +$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 autotools$$ install handling of the +deprecated files. +This included changing the autotools +$code --with-implicit_ctor$$ option to $cref autotools$$. +This was removed on +$cref/2017-02-10/whats_new_17/02-10/$$. + +$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 $code bool_sparsity.cpp$$ examples which show how +to conserve memory when computing sparsity patterns. +(This has since been replaced by $cref rc_sparsity.cpp$$.) +$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 item. +This has been done, +see $cref/no_print_for_op/optimize/options/no_print_for_op/$$. + +$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/autotools/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_two_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_two_option/atomic_sparsity/bool_sparsity_enum/$$ +was used when +$cref/pack_sparsity_enum/atomic_two_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 windows download and testing. +This discussion has since been removed; see ++$cref/05-20/whats_new_18/05-20/$$ in whats new for 2018. + + +$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_two_option/atomic_sparsity/pack_sparsity_enum/$$ option +on 08-31 introduced a bug in the calculation of $cref RevSparseHes$$. +The $code chkpoint_one_get_started.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/chkpoint_one/$$ functions that used any of these operations. + +$head 08-31$$ +$list number$$ +Mention the fact that using checkpoint functions can make +$cref/recordings faster/chkpoint_one/Purpose/Faster Recording/$$. +$lnext +Add the +$cref/pack/atomic_two_option/atomic_sparsity/pack_sparsity_enum/$$ +sparsity option for $cref atomic_two$$ operations. +$lnext +Add the pack sparsity option to +$cref/chkpoint_one/chkpoint_one/sparsity/$$ functions. +$lnext +Added the $code example/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_two_ctor/atomic_base/sparsity/$$ +argument was added to the $code atomic_base$$ constructor and the +$cref/chkpoint_one/chkpoint_one/sparsity/$$ constructor. +$lnext +Make $code atomic_two_norm_sq.cpp$$ an example with no set sparsity +and $code atomic_two_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/chkpoint_one/$$ implementation were not using +the CppAD $cref ErrorHandler$$. This has been fixed. + +$head 08-28$$ +Free $cref/checkpoint/chkpoint_one/$$ 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/chkpoint_one/$$ function. + +$head 08-25$$ +Reduce the amount of memory required for $cref/checkpoint/chkpoint_one/$$ 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/chkpoint_one/$$ 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 autotools$$ 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/chkpoint_one/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/chkpoint_one/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 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 + IdenticalCon(%side%) + at line %number% in the file + %...%/include/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/IdenticalCon/base_identical/Identical/IdenticalCon/$$ 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 autotools$$ 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 +$cref/no_compare_op/optimize/options/no_compare_op/$$. + +$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/Global Options/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/con_dyn_var/Parameter/$$ 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-2018.00.00.0/omh/appendix/whats_new/16.omh cppad-2019.02.00.0/omh/appendix/whats_new/16.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/16.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/16.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,485 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_16$$ +$spell + chkpoint + autotools + alloc + hpp + valgrind + uninitialized + adouble + CppAD + Eigen + std + namespace + cppad + Hes + Jac + mul + ifndef + xam + makefile + vy + inv + atanh + colpack + Wmisleading + gcc + sacado + chrono + const_iterator + op + mingw +$$ + +$section Changes and Additions to CppAD During 2016$$ + +$head Introduction$$ +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. + +$head 12-23$$ +Added a way for the user to determine what tests options are available; see +$cref/make check/cmake/make check/$$. + +$head 12-20$$ +Change the optimize $cref/examples/optimize/Examples/$$ to use +$cref NearEqual$$ for floating point tests (instead of exactly equal). +There were some other exactly equal floating point tests that were +failing on a $code mingw$$ system. Theses have also been fixed. + +$head 12-18$$ +Add the $cref/no_print_for_op/optimize/options/no_print_for_op/$$ to the +optimize routine. + +$head 12-13$$ +$list number$$ +Fix a bug in $cref ForSparseHes$$. To be more specific, +there was a bug in handling the cumulative summations operator in this +routine. This could only come up when used +an $cref/optimized/optimize/$$ $cref/f/ForSparseHes/f/$$, +$lnext +Add the +$cref/nest_conditional.cpp/optimize_nest_conditional.cpp/$$ example. +$lend + + +$head 12-11$$ +Improve the $cref optimize$$ documentation. +This includes making examples that demonstrate +specific aspects of the optimization; see +$cref/forward_active.cpp/optimize_forward_active.cpp/$$, +$cref/reverse_active.cpp/optimize_reverse_active.cpp/$$, +$cref/compare_op.cpp/optimize_compare_op.cpp/$$, +$cref/conditional_skip.cpp/optimize_conditional_skip.cpp/$$, +$cref/cumulative_sum.cpp/optimize_cumulative_sum.cpp/$$. + + +$head 12-09$$ +The $cref/options/optimize/options/$$ argument was added to the +optimize routine. + +$head 11-18$$ +Move classes and functions that are part of the user API from the +$code cppad/local$$ directory to the $code cppad/core$$ directory. +The remaining symbols, in the $code cppad/local$$ directory, are now +in the $code CppAD::local$$ namespace. +Note that a class in the $code CppAD$$ name space, may have a member +function that is not part of the user API. + +$head 11-14$$ +Increase the speed of the $code sparse_pack$$ class. +This improves the speed for +$cref/vector of boolean/glossary/Sparsity Pattern/Boolean Vector/$$ +sparsity pattern calculations. + +$head 11-13$$ +Merged in the $code sparse$$ branch which has $code const_iterator$$, +instead of $code next_element$$ for the +$code sparse_list$$ and $code sparse_pack$$ classes. +These classes are not part of the CppAD API and hence their specifications +can change (as in this case). +They can be used to get more efficient representations of +$cref/sparsity patterns/glossary/Sparsity Pattern/$$. + +$head 10-27$$ +The optional $cref/optimize/chkpoint_one/optimize/$$ option +was added to the checkpoint functions. + +$head 10-12$$ +$list number$$ +Change $cref elapsed_seconds$$ to use +$code std::chrono::steady_clock$$ instead of +$code std::chrono::high_resolution_clock$$. +$lnext +The test for C++11 features was failing on a Mac system +because the elapsed time was returning as zero (between two events). +This test has been made more robust by add a one millisecond sleep +between the two clock accesses. +$lend + + +$head 09-29$$ +The multiple directions version of +$cref/forward/forward_dir/$$ was missing $cref erf$$ function +in the case where C++ 2011 was supported; see +$href%https://github.com/coin-or/CppAD/issues/16%issue 16%$$. +This has been fixed. + +$head 09-27$$ +Change the implementation of $cref atomic_eigen_cholesky.hpp$$ so that +the computation of $latex M_k$$ exactly agrees with the corresponding +$cref/theory/cholesky_theory/$$. + +$head 09-26$$ +$list number$$ +A possible bug in the $cref optimize$$ command was fixed. +To be specific, a warning of the form +indentations; +$codei% + warning: this 'if' clause does not guard... [-Wmisleading-indentation] +%$$ +using the gcc-6.2.1 compiler, was fixed and it may have fixed a bug. +$lnext +There was a problem with the +$cref/sacado/speed_sacado/$$ where the symbol +$code HAS_C99_TR1_CMATH$$ was being defined twice. +This has been fixed by leaving it up to the sacado install to determine +if this symbol should be defined. +$lend + +$head 09-16$$ +Fix a problem using the +$cref/colpack/speed_main/Sparsity Options/colpack/$$ option to the +$code speed_cppad$$ program. +(There was a problem whereby the $code speed_cppad$$ +program did not properly detect when $code colpack$$ was available.) + +$head 09-13$$ +Test third order and fix +bug in $cref atomic_eigen_cholesky.hpp$$ for orders greater +than or equal to three. + +$head 08-30$$ +Add the $cref atomic_two_eigen_cholesky.cpp$$ example. + +$head 08-25$$ +$list number$$ +Fix some missing include files in +$code optimize.hpp$$ and $code set_union.hpp$$ +(when compiling with MS Visual Studio 2015). +$lnext +Fix a warning in $code atanh.hpp$$ +(when compiling with MS Visual Studio 14). +$lnext +Fix a typo in the +$cref/Reverse/atomic_eigen_mat_inv.hpp/Theory/Reverse/$$ section of the +$code eigen_mat_inv.hpp$$ example. +$lend + +$head 07-17$$ +Add documentation for only needing to compute a +$cref/column subset/sparse_hessian/p/Column Subset/$$ of the sparsity +pattern when computing a subset of a sparse Hessians. +In addition, improve the corresponding example +$cref sparse_sub_hes.cpp$$. + +$head 07-14$$ +Correct title in $cref ForSparseHes$$ (change Reverse to Forward). + +$head 06-30$$ +Change the $code atomic_two_mat_mul.cpp$$ example so that on atomic object +works for matrices of any size. +(This has since been changed to the $cref atomic_three_mat_mul.cpp$$ example.) + +$head 06-29$$ +Change the $cref atomic_two$$ examples so they do no longer use the +deprecated interfaces to +$code for_sparse_jac$$, $code rev_sparse_jac$$, +$code for_sparse_hes$$, and $code rev_sparse_hes$$. + +$head 06-27$$ +$list number$$ +Improve the $cref atomic_eigen_mat_mul.hpp$$ and +$cref atomic_eigen_mat_inv.hpp$$ examples. +Most importantly, one atomic object now works for matrices of any size. +$lnext +Add the vector $icode x$$, +that contains the parameters in an atomic function call +to the user following atomic functions: +$cref/for_sparse_jac/atomic_two_rev_sparse_jac/Implementation/x/$$, +$cref/rev_sparse_jac/atomic_two_rev_sparse_jac/Implementation/x/$$, +$cref/for_sparse_hes/atomic_two_rev_sparse_jac/Implementation/x/$$, +$cref/rev_sparse_hes/atomic_two_rev_sparse_jac/Implementation/x/$$. +This enables one to pass parameter information to these functions; e.g., +the dimensions of matrices that the function operates on. +$lend + + +$head 06-25$$ +Add more entries to the optimization +$cref/wish_list/wish_list/Optimization/$$. + +$head 06-10$$ +Add a $cref/check_finite/wish_list/check_finite/$$ wish list item. + +$head 05-05$$ +$list number$$ +Add documentation for +$cref/redirecting output/PrintFor/Redirecting Output/$$ for the +$code PrintFor$$ function. +$lnext +Change distributed version to build examples as debug instead +of release version. +(Was changed to release version while checking for compiler warnings; +see $code 04-17$$ below). +$lend + +$head 04-17$$ +Fix all some compiler warnings that occurred when compiling the +$cref/examples/Example/$$ with +$cref/NDEBUG/faq/Speed/NDEBUG/$$ defined. + +$head 03-27$$ +$list number$$ +Fix a bug in the calculation of the $cref atomic_eigen_mat_inv.hpp$$ +$cref/reverse/atomic_eigen_mat_inv.hpp/Private/reverse/$$ example. +$lnext +Use a very simple method (that over estimates variables) for calculating +$cref/vy/atomic_two_forward/vy/$$ in the $cref atomic_eigen_mat_inv.hpp$$ +$cref/forward/atomic_eigen_mat_inv.hpp/Private/forward/$$ example. +$lend + +$head 03-26$$ +$list number$$ +Implement and test the $cref atomic_two_eigen_mat_inv.cpp$$ +$cref/reverse/atomic_eigen_mat_inv.hpp/Private/reverse/$$ is implemented. +$lnext +Fix a bug in the calculation of +$cref/vy/atomic_two_forward/vy/$$ in the $cref atomic_eigen_mat_inv.hpp$$ +$cref/forward/atomic_eigen_mat_inv.hpp/Private/forward/$$ example. +$lend + + +$head 03-25$$ +$list number$$ +Start construction of the $cref atomic_two_eigen_mat_inv.cpp$$ example, +currently only +$cref/forward/atomic_eigen_mat_inv.hpp/Private/forward/$$ is implemented +and tested. +$lnext +More improvements to $cref atomic_two_eigen_mat_mul.cpp$$ example. +$lend + +$head 03-24$$ +$list number$$ +Fix build of $code example/atomic.cpp$$ when +$cref eigen_prefix$$ is not available +(bug introduced when $cref atomic_two_eigen_mat_mul.cpp$$ was added). +$lnext +Extend $cref atomic_two_eigen_mat_mul.cpp$$ example to include +$cref/for_sparse_jac/atomic_eigen_mat_mul.hpp/Private/for_sparse_jac/$$, +$cref/rev_sparse_jac/atomic_eigen_mat_mul.hpp/Private/rev_sparse_jac/$$, +$cref/for_sparse_hes/atomic_eigen_mat_mul.hpp/Private/for_sparse_hes/$$, +$cref/rev_sparse_hes/atomic_eigen_mat_mul.hpp/Private/rev_sparse_hes/$$. +$lnext +Fix a bug in the $cref ForSparseHes$$ routine. +$lnext +Edit $cref atomic_two_rev_sparse_hes$$ documentation. +$lend + +$head 03-23$$ +$list number$$ +Fix bug in autotools file $code example/atomic/makefile.am$$ +(introduced on 03-22). +$lnext +Improve the $cref atomic_two_eigen_mat_mul.cpp$$ example +and extend it to include reverse mode. +$lend + +$head 03-22$$ +$list number$$ +Start construction of the $cref atomic_two_eigen_mat_mul.cpp$$ example. +$lnext +change $code atomic_ode.cpp$$ to $code chkpoint_one_ode.cpp$$ and +$code atomic_extended_ode.cpp$$ to $code chkpoint_one_extended_ode.cpp$$. +$lend + +$head 03-21$$ +Change the $cref atomic_mat_mul.hpp$$ class name from $code mat_mul$$ +to $code atomic_mat_mul$$. This example use of the name $code mat_mul$$ +in the $code atomic_two_mat_mul.cpp$$ example / test. +(This has since been changed to the $cref atomic_three_mat_mul.cpp$$ example.) + +$head 03-20$$ +$list number$$ +Include the sub-directory name to the include guards +in $icode%*%.hpp%$$ files. For example, +$codep + # ifndef CPPAD_UTILITY_VECTOR_HPP + # define CPPAD_UTILITY_VECTOR_HPP +$$ +appears in the file $code cppad/utility/vector.hpp$$. This makes it +easier to avoid conflicts when choosing $cref addon$$ names. +$lnext +Add the $cref set_union$$ utility and use it to simplify the +$cref atomic$$ examples that use +$cref/vector of sets/glossary/Sparsity Pattern/Vector of Sets/$$ +sparsity patterns. +$lend + + +$head 03-19$$ +$list number$$ +Move $code atomic_two_mat_mul.cpp$$ to $code atomic_mat_mul_xam.cpp$$ +(moved back on $cref/03-21/whats_new_16/03-21/$$. +$lnext +Move $code atomic_matrix_mul.hpp$$ to $cref atomic_mat_mul.hpp$$. +$lend + +$head 03-17$$ +Add the +$code atomic_ode.cpp$$ and $code atomic_extended_ode.cpp$$ examples. + +$head 03-12$$ +$list number$$ +Move the example $code reverse_any.cpp$$ to $cref reverse_checkpoint.cpp$$. +$lnext +Add the $code chkpoint_one_mul_level.cpp$$ example. +$lend + +$head 03-05$$ +The following atomic function examples were added +These examples are for a specific atomic operation. +In addition, the domain and range dimensions for these examples +are not one and not equal to each other: +$code atomic_two_forward.cpp$$, +$code atomic_two_reverse.cpp$$, +$code atomic_two_for_sparse_jac.cpp$$, +$code atomic_two_rev_sparse_jac.cpp$$, +$code atomic_two_for_sparse_hes.cpp$$, +$code atomic_two_rev_sparse_hes.cpp$$. + + +$head 03-01$$ +$list number$$ +Improve documentation of implementation requirements for the atomic +$cref/rev_sparse_jac/atomic_two_rev_sparse_jac/Implementation/$$. +$lnext +Make some corrections to the $cref atomic_two_for_sparse_hes$$ documentation. +and fix a bug in how CppAD used these functions. +$lend + +$head 02-29$$ +$list number$$ +Merged sparse into master branch. This makes the +$cref ForSparseHes$$ routine available for use. +$lnext +Changed the +$cref/global options/speed_main/Global Options/$$ +in the speed test main program to use one global variable with prototype +$srccode%cpp% + extern std::map global_option; +%$$ +$lend + + +$head 02-28$$ +Fix a mistake in the old atomic +$code example/sparsity/sparsity.cpp$$ example. +This example has since been changed to +$code atomic_two_set_sparsity.cpp$$. + + +$head 02-27$$ +The $code --with-sparse_set$$ and $code --with-sparse_set$$ options +were removed from the $cref autotools$$ install procedure. + +$head 02-26$$ +The condition that the operation sequence in $icode f$$ is +$cref/independent/glossary/Operation/Independent/$$ of +the independent variables was added to the statement about +the validity of the sparsity patterns; see $icode x$$ in +$cref/ForSparseJac/ForSparseJac/x/$$, +$cref/RevSparseJac/RevSparseJac/x/$$, and +$cref/RevSparseHes/RevSparseHes/x/$$. + +$head 02-25$$ +The $cref cmake$$ command line argument $code cppad_sparse_list$$ +has been removed (because it is so much better than the other option). + +$head 02-23$$ +A new version of the +$code cppad_sparse_list$$ class (not part of user API) uses +reference counters to reduce the number of copies of sets that are equal. +This improved the speed of sparsity pattern computations that use +the $cref/vector of sets/glossary/Sparsity Pattern/Vector of Sets/$$ +representation. +For example, the results for the +$cref cppad_sparse_hessian.cpp$$ test compare as follows: +$codep + sparse_hessian_size = [ 100, 400, 900, 1600, 2500 ] + sparse_hessian_rate_old = [ 1480, 265.21, 93.33, 41.93, 0.86 ] + sparse_hessian_rate_new = [ 1328, 241.61, 92.99, 40.51, 3.80 ] +$$ +Note that the improvement is only for large problems. In fact, +for large problems, preliminary testing indicates that +the new vector of sets representation preforms better than +the $cref/vector of boolean/glossary/Sparsity Pattern/Boolean Vector/$$ +representation. + + +$head 01-21$$ +Fix a $code valgrind$$ warning about use of uninitialized memory +in the test $code test_more/chkpoint_one.cpp$$ (the problem was in the test). + +$head 01-20$$ +$list number$$ +Fix a $code valgrind$$ warning about use of uninitialized memory +when using the $cref/adouble/base_adolc.hpp/$$ base type. +This required an optional $cref base_hash$$ function and the special +$cref/adouble hash_code/base_adolc.hpp/hash_code/$$ implementation. +$lnext +The $code adouble$$ $cref to_string$$ functions +required a special implementation; see +$cref/adouble to_string/base_adolc.hpp/to_string/$$. +$lnext +Add the $cref/to_string/base_alloc.hpp/to_string/$$ and +$cref/hash_code/base_alloc.hpp/hash_code/$$ examples +to the $code base_alloc.hpp$$ example. +$lend + +$head 01-18$$ +$list number$$ +Fix ambiguity between $code CppAD::sin$$ and $code std::sin$$, +and other standard math functions, +when using +$codep + using namespace std; + using namespace CppAD; +$$ +This is OK for simple programs, but not generally recommended. +See $code double$$ version of base class definitions for +$cref/Unary Standard Math/base_double.hpp/Unary Standard Math/$$ +for more details. +$lnext +Change Eigen array example +$cref eigen_array.cpp$$ +to use member function version of $code sin$$ function +(as per Eigen's array class documentation). +$lend + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/17.omh cppad-2019.02.00.0/omh/appendix/whats_new/17.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/17.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/17.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,649 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_17$$ +$spell + const + Perl + CppAD + doxygen + cppad + hpp + bool + Jacobian + Jacobians + jac + hes + eigen + mul + rc + rcv + omhelp + valgrind + uninitialised + deallocations + sacado + typedef + plugin + gcc + readme + autotools + ipopt + colpack + Wconversion + xq + boolofvoid + namespace + cxx + uninitialized + cmake + op + sizeof + addr + subsparsity + subgraph + optimizer + subgraphs +$$ + +$section Changes and Additions to CppAD During 2017$$ + +$head API Changes$$ +Speed tests no longer automatically compile in release mode; see +$cref/debug_which/speed/debug_which/$$ + +$head 12-14$$ +Add the $cref subgraph_hes2jac.cpp$$ example +which computes sparse Hessians using subgraphs and Jacobians. + +$head 12-08$$ +A multi-threading +wish list item was added. + +$head 12-06$$ +A $cref wish_list$$ item to enable one to iterate through a +$code const$$ $cref ADFun$$ operation sequence was completed. +In addition, the $cref/f/abs_normal_fun/f/$$ argument to the +$code abs_normal$$ operation was converted to be $code const$$. + + +$head 12-05$$ +The internal data object used to represent sparsity patterns as +vectors of integers was improved; +see $cref/internal_bool/for_jac_sparsity/internal_bool/$$ +in $code for_jac_sparsity$$ and other +$cref/preferred sparsity pattern calculations + /sparsity_pattern + /Preferred Sparsity Pattern Calculations +/$$. + +$head 12-04$$ +Back out the $code hold_reverse_memory$$ option. + +$head 12-01$$ +The $code hold_reverse_memory$$ option was added. + +$head 11-30$$ +Edit the $cref download$$ instructions. + +$head 11-23$$ +The $code ADFun$$ function $cref/optimizer/optimize/$$ +was not handling hash code collisions properly. +To be specific, only the arguments +that were variables where checked for a complete match. +The arguments that are constants need to also be checked. +This has been fixed. + +$head 11-20$$ +$list number$$ +Add the $cref subgraph_jac_rev$$ method for computing +sparse Jacobians. +$lnext +Add the $cref/subgraph/speed_main/Global Options/subgraph/$$ option +to the CppAD speed tests. +$lend + +$head 11-19$$ +Add the $cref subgraph_reverse$$ method for computing +sparse derivatives. +This was inspired by the +$href%https://cran.r-project.org/web/packages/TMB/index.html%TMB%$$ package. + + +$head 11-15$$ +$list number$$ +Add wish list item for $cref/subgraph sparsity/wish_list/Subgraph/Sparsity/$$. +$lnext +Fix $cref cmake_check$$ when $cref ipopt_prefix$$ is not present on the +$cref cmake$$ command line +(make was trying to build some of the ipopt tests). +$lend + +$head 11-13$$ +$list number$$ +Add the $cref/hes2jac/speed_main/Global Options/hes2jac/$$ option +to the CppAD speed tests. +$lnext +Implement the +$cref/subsparsity/speed_main/Sparsity Options/subsparsity/$$ option +for the CppAD $cref/sparse_hessian/link_sparse_hessian/$$ test. +$lnext +Fix detection of invalid options in the speed test programs; see the +$cref/global/speed_main/Global Options/$$ and +$cref/sparsity/speed_main/Sparsity Options/$$ options. +$lend + +$head 11-12$$ +Add the $cref/subsparsity/speed_main/Sparsity Options/subsparsity/$$ option +to the CppAD speed tests. + +$head 11-08$$ +Add the $cref subgraph_sparsity$$ method for computing +dependency and sparsity. +This was inspired by the +$href%https://cran.r-project.org/web/packages/TMB/index.html%TMB%$$ package. + + +$head 11-06$$ +More information has been added to the operation sequence. +To be specific, the extra amount of +$codei% + %f%.size_op() * sizeof(%tape_addr_type) +%$$ +was added to the value returned by +$cref/size_op_seq/seq_property/size_op_seq/$$. + +$head 11-04$$ +The method for iterating through the tape has been changed. +It now includes an extra data structure that makes it faster, +but also requires slightly more memory. To be specific, the term +$codei% + %f%.size_op() * sizeof(%tape_addr_type) * 2 +%$$ +was added to the value returned by +$cref/size_op_seq/seq_property/size_op_seq/$$. +In addition, some minor corrections were made to the +$cref/tape_addr_type/cmake/cppad_tape_addr_type/$$ +requirements. + +$head 10-23$$ +$list number$$ +Require $code cmake.3.1$$ or greater and fix +a cmake warning by always using the new $code CMP0054$$ policy. +$lnext +Fix a $code g++ 7.2.1$$ warning about a possibly uninitialized value +in the file $code cppad/local/optimize/hash_code.hpp$$. +$lend + +$head 09-16$$ +An optimization memory entry +was added to the wish list +and the $cref/check_finite/wish_list/check_finite/$$ entry was modified. + +$head 08-30$$ +$list number$$ +If $cref colpack_prefix$$ was not specified, one would get the following +waring during the $cref cmake$$ command: +$codei% + Policy CMP0046 is not set: Error on non-existent dependency in +%$$ +This has been fixed by not adding the dependency when it is not needed. +$lnext +There was a problem running $cref/make check/cmake_check/$$ +when $cref/cppad_cxx_flags/cmake/cppad_cxx_flags/$$ was not specified. +This has been fixed. +This was probably introduced on $cref/05-29/whats_new_17/05-29/$$. +$lend + + +$head 08-29$$ +There was a problem on some systems that created an error when +specializing the $code is_pod$$ template function in the +$code CppAD::local$$ namespace. +This has been fixed by testing for compatibility at during the +$cref cmake$$ command and creating the file $code cppad/local/is_pod.hpp$$. + + +$head 08-09$$ +Add the $cref/test_boolofvoid/wish_list/test_boolofvoid/$$ +wish list item. + +$head 08-08$$ +$list number$$ +The $cref eigen_plugin.hpp$$ was put back in the +$cref cppad_eigen.hpp$$ definitions. +This makes CppAD incompatible with older versions of eigen; e.g., eigen-3.2.9. +The plugin was removed on $cref/05-12/whats_new_17/05-12/$$. +$lnext +Fix some minor typos in the documentation. +To be specific: +The font, in the $cref sparse_rc$$ and $cref sparse_rcv$$ syntax, +for the text +$codei% + %target% = %pattern% +%$$ +The font, in $cref capacity_order$$, for the text +$codei% + %xq%.size() == %f%.Domain() +%$$ +Remove a percent sign $code %$$, in $cref CppAD_vector$$, in the text +$codei% + # include +%$$ +$lend + +$head 07-25$$ +$list number$$ +Fix warnings related to type conversions that +occurred when one used $code -Wconversion$$ with +$code g++$$ version 6.3.1. +$lnext +The warning were not fixed for complex AD types; e.g., +$cref complex_poly.cpp$$. +The $cref wno_conversion$$ include file was added to deal with +cases like this. +$lend + +$head 07-03$$ +$list number$$ +The $cref min_nso_linear$$ abs-normal example was added. +$lnext +Fix bug in $cref abs_normal_fun$$, to be specific, the multiplication +of a variable on the left by a parameter was not handled. +$lend + +$head 07-01$$ +the $cref abs_normal$$ examples were converted from using +quadratic programming problems to using linear programming problems. + +$head 06-28$$ +The $cref/abs-normal/abs_normal_fun/$$ +representation of non-smooth functions has been added. +Examples and utilities that use this representation have also been included, +see $cref abs_normal$$. + +$head 06-11$$ +The atomic functions base class $cref atomic_two$$ +makes more of an effort to avoid false sharing cache misses. +This may the speed of multi-threaded applications with atomic functions; +e.g., see $cref multi_atomic.cpp$$. + +$head 06-10$$ +$list number$$ +Add the multi-threading atomic function example +$cref multi_atomic.cpp$$. +$lnext +The $code example/multi_thread/test_multi$$ directory used +to have an example using the deprecated +$cref atomic_one$$ functions in a multi-threading setting +(that only built with the deprecated $cref autotools$$). +This have been removed. +$lend + +$head 06-07$$ +The multi-threading examples +$cref harmonic.cpp$$ and $cref multi_newton.cpp$$ were re-organized. +To be specific, the source code for each example was moved to one file. +In addition, for each example, +the documentation for each of the routines has been separated +and placed next to its source code. + +$head 06-04$$ +Most all the $cref deprecated$$ features have been removed +from the examples with the exception of those in the +$code example/deprecated$$ directory. + +$head 06-03$$ +Add the fact that the pair +($icode row$$, $cref/col/link_sparse_hessian/col/$$) +is lower triangular to the speed test +$code link_sparse_hessian$$ routine. + + +$head 06-01$$ +$list number$$ +There was a bug in the +$cref sparse_hes$$ routine and it was using the general coloring algorithm when +$cref/cppad.symmetric/sparse_hes/coloring/cppad.symmetric/$$ was specified. +This has been fixed and improves the efficiency in this case. +$lnext +Some bugs were fixed in the use of +$cref/colpack/colpack_prefix/$$ as the coloring algorithm for +sparse Jacobian and Hessian calculations. +This has improved the efficiency of Colpack colorings for computing Hessians +(when $code colpack.symmetric$$ is used). +$lnext +The $code colpack.star$$ coloring method for sparse Hessians has +been deprecated; see +$cref/sparse_hes/sparse_hes/coloring/colpack.star Deprecated 2017-06-01/$$ +and +$cref/sparse_hessian + /sparse_hessian + /work + /colpack.star Deprecated 2017-06-01 +/$$. +Use the $code colpack.symmetric$$ method instead; see +$cref/sparse_hes/sparse_hes/coloring/colpack.symmetric/$$ and +$cref/sparse_hes/sparse_hes/coloring/colpack.general/$$. +$lend + +$head 05-29$$ +$list number$$ +Add the capability to compile so that CppAD debug and release mode +can be mixed; see +$cref/CPPAD_DEBUG_AND_RELEASE + /preprocessor + /Documented Here + /CPPAD_DEBUG_AND_RELEASE +/$$. +$lnext +Add the $cref/cppad_debug_which/cmake/cppad_debug_which/$$ flags +that determines which files are compiled for debugging versus release +during the CppAD testing; see $cref cmake_check$$. +$lnext +There was a problem linking the proper libraries for using newer versions of +$cref/sacado/sacado_prefix/$$. +This has been fixed. +$lend + +$head 05-19$$ +Most all the examples have been moved to $code example$$ directory +and grouped as sub-directories; e.g., the $cref ipopt_solve$$ examples +are in the $code example/ipopt_solve$$ directory. + +$head 05-14$$ +$list number$$ +The file $code build.sh$$ was moved to $code bin/autotools.sh$$, +and `auto tools' has been changed to $cref autotools$$. +$lnext +The README file was replace by readme.md +and AUTHORS was moved to authors. +$lnext +The NEWS, INSALL, and ChangeLog files +are no longer necessary for autotools build and have been removed. +$lnext +The file test_more/sparse_jacobian.cpp generated a warning +under some gcc compiler options. +This has been fixed. +$lnext +Specifications were added so that $cref to_string$$ yields exact results +for integer types and machine precision for floating point types. +$lnext +Some editing was done to the $cref autotools$$ instructions. +$lend + +$head 05-12$$ +$list number$$ +The $cref Faq$$ has been updated. +$lnext +Remove includes of $code cppad/cppad.hpp$$ from the +$codei%include/cppad/speed/%*%.hpp%$$ files. +This avoids an incompatibility between sacado and newer versions of eigen, +when eigen is used for the $cref testvector$$. +$lnext +The $cref/eigen/eigen_prefix/$$ package changed its requirements for +defining Scalar types +(some where between eigen-3.2.9 and eigen-3.3.3). +The member variable +$cref/digit10/numeric_limits/digits10/$$ was added to the +$code numeric_limits$$ to accommodate this change. +$lnext +Note that this fix required adding $code digits10$$ to the +user defined $icode Base$$ type +$cref/requirements/base_require/$$; see +$cref base_limits$$. +$lnext +In addition, it is no longer necessary to add the typedef +$codei% + typedef Scalar value_type; +%$$ +so the file $code cppad/example/eigen_plugin.hpp$$ has been removed. +(This type definition was previously necessary for eigen vectors +to be $cref/simple vectors/SimpleVector/$$.) +$lend + +$head 04-08$$ +The $cref/optimization/optimize/$$, with a large number of +$cref/conditional expressions/CondExp/$$, was performing many +memory allocations and deallocations. This has been reduced. + + +$head 04-02$$ +Fix a bug in the optimization of conditional expressions; see, +$cref/no_conditional_skip/optimize/options/no_conditional_skip/$$. + +$head 03-31$$ +Fix some $code valgrind$$ errors that occurred while running the CppAD +test set. + +$head 03-29$$ +The following valgrind error might occur when the optimize skipped +setting values that did not affect the dependent variables: +$codei% + Conditional jump or move depends on uninitialised value(s) +%$$ +This was not a bug, the code has been changed to avoid this error +in order to make it easier to use valgrind with CppAD. + +$head 03-25$$ +$list number$$ +The $cref sparse_hes$$ function was more efficient if +there were more entries in each row of the requested +$cref/subset/sparse_hes/subset/$$. This has been changed +to more entries in each column, and documentation to this effect +was included. +$lnext +The $cref optimize$$ routine was using to much memory when +it was optimizing conditional skip operations; see +$cref/no_conditional_skip/optimize/options/no_conditional_skip/$$. +This has been fixed. +$lend + +$head 03-20$$ +There was a mistake in $cref sparse_jac$$ that caused the +following assert to mistakenly occur: +$codep +sparse_jac_rev: work is non-empty and conditions have changed +Error detected by false result for + color.size() == 0 || color.size() == n +$$ +A test that using a previously stores work vector +has been added to $cref sparse_jac_rev.cpp$$ +and this bug has been fixed. + +$head 03-13$$ +The documentation for the Hessian in $cref rev_hes_sparsity$$ was +transposed; i.e., the sense of +$cref/transpose/rev_hes_sparsity/transpose/$$ was reversed. + +$head 03-11$$ +Add sparse assignment statements; see $icode target$$ for +$cref/sparse_rc/sparse_rc/target/$$ and +$cref/sparse_rcv/sparse_rcv/target/$$. + +$head 03-10$$ +Add the a sizing constructor to the +$cref/sparse_rc syntax/sparse_rc/Syntax/$$; i.e., +a constructor that sets the number of row, number of columns, +and number of possibly non-zero values in the sparsity pattern. + +$head 03-06$$ +Fix a bug in the sparsity computation using the +internal representation for +$cref/vectors of sets/glossary/Sparsity Pattern/Vector of Sets/$$; +i.e., when $icode internal_bool$$ was false in +any of the $cref sparsity_pattern$$ calculations; e.g., +$cref/for_jac_sparsity/for_jac_sparsity/internal_bool/$$. + +$head 03-04$$ +Fix a bug in the optimization of conditional expressions; +see $cref/no_conditional_skip/optimize/options/no_conditional_skip/$$. + +$head 02-26$$ +$list number$$ +Fix warning during $cref cmake$$ command, +on $href%https://www.cygwin.com/%cygwin%$$ systems, +about $code WIN32$$ not being defined. +$lnext +Add $cref/element-wise atomic operations + /wish_list + /Element-wise Atomic Operations +/$$ +to the wish list. +$lend + +$head 02-21$$ +$list number$$ +Minor improvements to syntax and documentation for +$cref sparse_rc$$ and $cref sparse_rcv$$. +$lnext +Separate preferred sparsity versions in +$cref sparsity_pattern$$ and $cref sparse_derivative$$. +$lend + +$head 02-19$$ +$list number$$ +Remove the $code bool_sparsity.cpp$$ example and +add the $cref rc_sparsity.cpp$$ example. +$lnext +Check for duplicate entries during +$cref/row_major/sparse_rc/row_major/$$ and $code col_major$$ in +$code sparse_rc$$. +$lend + +$head 02-15$$ +Fix bug when using $cref ForSparseHes$$ with atomic functions; i.e., +$cref atomic_two_for_sparse_hes$$. + +$head 02-13$$ +Improve $cref/for_sparse_jac/atomic_eigen_mat_mul.hpp/Private/for_sparse_jac/$$ +calculation in $code eigen_mat_mul.hpp$$ example. +It now checks for the parameter zero and does not propagate any sparsity +in this case (because the result is always zero). + +$head 02-11$$ +$list number$$ +Remove the 'Under Construction' heading from the +$cref sparse_rc$$ and $cref sparse_rcv$$ documentation; i.e., +they are ready for public use (part of the CppAD API). +$lnext +Fix some warning that occur when using +$cref/eigen/cppad_testvector/eigen/$$ for the CppAD test vector. +(The Eigen vector $code size()$$ function +returns an $code int$$ instead of $code size_t$$.) +$lnext +Fix a bug in $cref/sparse_jac_rev/sparse_jac/$$. +$lend + +$head 02-10$$ +$list number$$ +The subset of deprecated features corresponding to +$cref/cppad_deprecated=YES/cmake/cppad_deprecated/$$ +have been completely removed. +$lnext +Fix problems with $cref autotools$$ build +(started near 02-01 while working on sparsity branch). +$lnext +Reorder (better organize) the $cref ADFun$$ documentation section. +$lend + +$head 02-09$$ +$list number$$ +Remove the sparsity pattern wish list item. +For sparsity patterns, this was completed by +$cref sparse_rc$$ and the sparsity pattern routines that used it; +e.g., $cref for_jac_sparsity$$. +For sparse matrices, it was completed by +$cref sparse_rcv$$ and the sparse matrix routines that use it; e.g., +$cref sparse_jac$$. +$lnext +Add the Deprecated and +$cref/example/wish_list/Example/$$ items to the wish list. +(The Deprecated item was partially completed and partially removed.) +$lend + +$head 02-08$$ +$list number$$ +Make coloring a separate argument to +$cref/sparse_jac/sparse_jac/coloring/$$ and +$cref/sparse_hes/sparse_hes/coloring/$$. +$lnext +Add the +$cref/group_max/sparse_jac/group_max/$$ +argument to the $code sparse_jac_for$$ function. +$lend + +$head 02-05$$ +$list number$$ +Add the $cref/sparse_jac_for/sparse_jac/$$ routine +which uses $cref sparse_rc$$ sparsity patterns +and $cref sparse_rcv$$ matrix subsets. +$lnext +Order for $cref sparse_rc$$ row-major and column-major was switched. +This has been fixed. +$lend + +$head 02-03$$ +Add the +$cref rev_jac_sparsity$$ +$cref rev_hes_sparsity$$, and +$cref for_hes_sparsity$$ interfaces to sparsity calculations. +These use $cref sparse_rc$$ sparsity patterns. + +$head 02-02$$ +Change $cref/size_forward_bool/for_jac_sparsity/f/size_forward_bool/$$ and +Change $cref/size_forward_set/for_jac_sparsity/f/size_forward_set/$$ +so that they are a better approximation of the number of bytes +(unsigned characters) being used. +The exact same sparsity pattern might use different memory +in two different function objects (because memory is allocated in chunks). +The $cref fun_assign.cpp$$ example has been changed to reflect this fact. + +$head 02-01$$ +Add the $cref for_jac_sparsity$$ interface for the sparse Jacobian calculations. +This is the first use of $cref sparse_rc$$, +a sparsity pattern class that uses row and column +$cref/index vectors/glossary/Sparsity Pattern/Row and Column Index Vectors/$$. + +$head 01-30$$ +Move the $cref sparsity_pattern$$ examples from $code example$$ +to $code example/sparse$$ subdirectory. +This included the sparse $cref/driver/drivers/$$ examples. + +$head 01-29$$ +Move the $cref utility$$ examples from $code example$$ +to $code example/utility$$ subdirectory. + +$head 01-27$$ +Add a $cref addon$$ link to +$href%http://www.seanet.com/~bradbell/cppad_swig%cppad_swig%$$, +a C++ AD object library and swig interface to Perl, Octave, and Python. + +$head 01-19$$ +Convert more examples / tests to use a multiple of machine epsilon +instead of $code 1e-10$$. + +$head 01-18$$ +$list number$$ +Fix developer +$href%https://www.coin-or.org/CppAD/Doc/doxydoc/html/%doxydoc%$$ +documentation so that it works with newer version of doxygen. +$lnext +Fix a Visual C++ 2015 compilation problem in friend declarations +in the file $code cppad/local/ad_tape.hpp$$. +$lend + +$head 01-17$$ +Change computed assignment to +$cref/compound assignment/compound_assign/$$. + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/18.omh cppad-2019.02.00.0/omh/appendix/whats_new/18.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/18.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/18.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,600 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_18$$ +$spell + eps + autotools + Microsoft + CppAD + jac + hes + Jacobian + rcv + subgraph + op_arg + enum + std + addr + cppad + enums + dyn + ind + uninstalled + Vec + valgrind + Eigen + namespace + Taylor + af + Wconversion + gcc + Wfloat + addons + Kasper Kristensen + Subgraph + msys + cmake + bool + erf + tmb + inline + mingw +$$ + +$section Changes and Additions to CppAD During 2018$$ + +$head 12-30$$ +On $cref/12-12/whats_new_18/12-12/$$ the directory +$code cppad$$ was moved to $code include/cppad$$. +The $code make install$$ step of the +$cref install$$ instructions did not work after that. +This has been fixed. + +$head 12-23$$ +The documentation for how to run +$cref/multi_atomic/thread_test.cpp/multi_atomic/$$ was missing. +This has been fixed. + +$head 12-17$$ +Keep the documentation for $cref deprecated$$ features, +but remove their examples. +The documentation is intended to help conversion +to using features that have not been deprecated. + +$head 12-16$$ +Add $code bin/check_tab.sh$$ and remove some remaining tab characters +that it found in the CppAD source code. + +$head 12-15$$ +Fix name for special version of $code cmake$$ required by +$cref/msys2/cmake/CMake Command/msys2/$$, +$code mingw-w64-x86_64-cmake$$. + +$head 12-12$$ +$list number$$ +Change tabs to spaces in both the source code and the examples. +$lnext +The $code inline$$ specifies was removed from template functions +and class member functions in both the source code and examples; see +the $code inline$$ entry in the +$cref/wish_list/wish_list/inline/$$. +$lnext +In the documentation and examples change the $codei%Vector%Type%$$ +to $icode%Type%Vector%$$ for $icode Type$$ denoting various types; e.g., +$code Bool$$, $code Size$$, $code Double$$, ... +$lnext +Change the $cref license$$ to be $code EPL-2.0$$ +with a $code GPL-2.0$$ or later alternative +(so one version of the source code can be used for both EPL +and GPL licenses). +$lnext +Change $latex B^n$$ to $latex \B{R}^n$$ when referring to the vector +space that $cref ADFun$$ object refer to. +(Note that this may not be real vectors; e.g., $cref base_complex.hpp$$.) +$lnext +Move the $code cppad$$ sub-directory to $code include/cppad$$. +$lnext +Add a checkpoint $cref/constructor/wish_list/checkpoint/Constructor/$$ +item to the wish list. +$lend + +$head 11-13$$ +$list number$$ +There was a problem using +$cref elapsed_seconds$$ with the Microsoft Visual Studio compiler. +To be specific, $code microsoft_timer$$ could be an undefined external. +This has been fixed. +$lnext +The $code # define NOMINMAX$$ command was placed before +$code # include $$ +so that $code std::min$$ and $code std::max$$ work properly. +(This only matters when using the Visual Studio compiler.) +$lnext +For some unknown reason, the Microsoft Visual Studio compiler +was giving a senseless error at the variable name $code small$$. +This has been changed to $code eps$$ in $cref interface2c.cpp$$. +$lnext +The deprecated $cref/autotools/cmake/CMake Command/autotools/$$ +was fixed to work with the current version of CppAD. +$lnext +Fix a warning in $code test_more/cppad_for_tmb/multi_atomic.cpp$$ +when using boost vectors for testing. +$lend + + +$head 11-11$$ +Fix a warning in $code test_more/cppad_for_tmb/multi_checkpoint.cpp$$ +when using boost vectors for testing. + +$head 11-06$$ +The initial +$cref size_order$$ is now zero for an $cref/af/base2ad/af/$$ created using +the $code base2ad$$ feature. + + +$head 11-04$$ +$list number$$ +The $cref/simple/cmake/CMake Command/Simple/$$ version of the cmake command +is now suggested as a starting point installing CppAD. +$lnext +The windows install procedure has been fixed; see +$cref/msys2/cmake/CMake Command/msys2/$$ and +$cref/visual studio/cmake/CMake Command/Visual Studio/$$. +$lnext +The Visual Studio compiler gave a warning because the +$code get_record_compare$$ (not in use API) +was returning $code size_t$$ when +it should have returned a $code bool$$. +It also gave a warning in $code test_more/general/erf.cpp$$ +about conversion from $code double$$ to $code size_t$$. +These have been fixed. +$lnext +The Visual Studio compiler also gave an error because it requires +the $cref ADFun$$ copy constructor for assignment to +a $cref base2ad$$ result. +This copy constructor has been allowed (but only for this case). +$lnext +The Visual Studio compiler does not seem to be able to mix +debug and release code. One of the tests had to be modified +enable the user to avoid this; see +$cref/visual studio/cmake/CMake Command/Visual Studio/$$. +$lend + + +$head 11-01$$ +There was a bug in the +$cref/checkpoint/chkpoint_one/$$ functions with multiple threads +(see $cref/10-29/whats_new_18/10-29/$$ below). +This has been fixed. + +$head 10-31$$ +$list number$$ +The items in the $cref wish_list$$ were re-organized +so that the New Atomic API entries +were all under one heading. +$lnext +A credit to Kasper Kristensen was added to the +$cref/subgraph/research/Sparsity/Subgraphs/$$ research item. +$lend + +$head 10-29$$ +The following is a list of changes to the documentation: +$list number$$ +The $cref theory$$ section was moved +to a higher level in the documentation and the +$cref introduction$$ we put in that section. +$lnext +The $cref wish_list$$ section was brought up to date +and the $cref research$$ section was added. +$lnext +Some of the links to the CppAD $cref/addons/addon/$$ section were broken. +This has been fixed. +$lnext +The wish list entries for the following items were removed +because they were completed: +$cref base2ad$$, +$cref/checkpoint/chkpoint_one/$$ functions now work with +$cref/multiple threads/multi_thread/$$, +the $cref optimize$$ memory usage has been reduced. +$lnext +The operations sequence wish list entry was changed to the +$cref/Constant/wish_list/Constant/$$ entry. +The software guidelines entry was changed to just +Convert Tabs to Spaces. +$lend + +$head 10-25$$ +$list number$$ +There was bug in $cref/f.optimize/optimize/$$ +when $icode f$$ has $cref/dynamic parameters/new_dynamic/$$. +This has been fixed. +$lnext +Fix warning, from old $code gcc$$ compilers, that +$code -Wfloat-conversion$$ and $code -Wfloat-conversion$$ +are not valid options. +$lnext +Instructions for obtaining GPL distribution were added near the +top of the $cref/home page/CppAD/$$. +$lend + + +$head 10-24$$ +The new $cref CppAD$$ home pages has been edited to be a better +introduction to CppAD. +In addition, more discussion was added to the $cref get_started.cpp$$ +example. + +$head 10-19$$ +The speed tests for the deprecated +$cref cppad_ipopt_nlp$$ now use the +$cref/cppad_debug_which/cmake/cppad_debug_which/$$ flag +in the same was as other test +(not always true). + +$head 10-18$$ +CppAD is now including the $code -Wconversion$$ in its compilation. +This results in warnings in more of the optional packages and so +their include files are compiled like system files (without warnings); +see $cref/package_prefix/cmake/package_prefix/$$. + +$head 09-25$$ +Functions $icode af$$, +created by $cref/af = f.base2ad/base2ad/$$, +could not use $cref/af.Jacobian/Jacobian/$$. +This has been fixed. + +$head 09-23$$ +The $cref/checkpoint/chkpoint_one/$$ functions did not work with functions that +were created using $cref base2ad$$. +This has been fixed. + +$head 09-22$$ +There was a bug in the $cref/checkpoint/chkpoint_one/$$ function when they +were used in $cref/in parallel mode/ta_parallel_setup/$$. +The $cref multi_checkpoint.cpp$$ example was added +to test this and demonstrate use of checkpoints in parallel mode. + +$head 09-19$$ +Add the $cref base2ad$$ capability. +This creates a function that computes using $codei%AD<%Base%>%$$ +objects from one that computes using $icode Base$$ objects. +This enables one to record any derivatives computations as part of another +function and thereby removes the need for +$cref/multiple levels of AD/mul_level/$$. +For example, compare $cref base2ad.cpp$$ +with $cref mul_level_ode.cpp$$. + +$head 09-17$$ +Create a section with just the +$cref atomic_two$$ specifications +and another with the $cref/atomic examples/atomic_two_example/$$. + +$head 09-16$$ +The $code taylor_ode.cpp$$ example was moved to $cref taylor_ode.cpp$$ +and changed to use the same notation as $cref taylor_ode$$. + +$head 09-15$$ +$list number$$ +Add a $cref/move semantics/FunConstruct/Assignment Operator/Move Semantics/$$ +version of the function assignment operator. +$lnext +Move AD theory for using Taylor's method to solve an ode to the separate +section $cref taylor_ode$$. +$lend + +$head 08-27$$ +$list number$$ +Add a discussion about +$cref/efficiency/Independent/dynamic/Efficiency/$$ for dynamic parameters. +$lnext +In a comment in the $cref new_dynamic.cpp$$ example, +change 'independent dynamic parameters' to 'dynamic parameter'. +$lnext +The $cref/eigen_vector/cppad_eigen.hpp/eigen_vector/$$ class was moved +out of the global namespace to the CppAD namespace. +This class was recently introduced ($cref/08-12/whats_new_18/08-12/$$) +and so this change to the API should be easy to fix in user code. +$lend + +$head 08-19$$ +$list number$$ +Fix dynamic parameter arguments to +$cref discrete$$ functions. +$lnext +Fix some detection of identically zero and one +for dynamic parameters. +$lnext +Fix an access of invalid memory during $cref new_dynamic$$. +$lnext +Add optimization of dynamic parameters during $cref/f.optimize/optimize/$$. +$lend + + +$head 08-18$$ +$list number$$ +Fix some remaining clang warnings. +$lnext +Fix $cref Integer$$ and $cref/unary minus/UnaryMinus/$$ for +$cref/dynamic/glossary/Parameter/Dynamic/$$ parameters. +$lend + + +$head 08-17$$ +Fix $cref/compound assignment/compound_assign/$$ operators +where left operand is a +$cref/constant/glossary/Parameter/Constant/$$ parameter +and right operand is a +$cref/dynamic/glossary/Parameter/Dynamic/$$ parameter. + +$head 08-16$$ +Fix $cref/compound assignment/compound_assign/$$ operators +where left operand is a +$cref/dynamic/glossary/Parameter/Dynamic/$$ parameter. +and right operand is a +$cref/variable/glossary/Variable/$$. + +$head 08-14$$ +Fix $cref/compound assignment/compound_assign/$$ operators +where both operands are parameters and one is a +$cref/dynamic/glossary/Parameter/Dynamic/$$ parameter. + +$head 08-13$$ +Fix conversion warnings generated by the +version 6.0 of the $code clang++$$ compiler. + +$head 08-12$$ +Add the $cref/eigen_vector/cppad_eigen.hpp/eigen_vector/$$ +wrapper class so that an $code eigen_vector$$ is a true +$cref SimpleVector$$; i.e., it using $code size_t$$ +instead of $code Eigen::Index$$ for its sizes and indices. + +$head 08-10$$ +Extend the CppAD vector class to enable +$cref/element access/CppAD_vector/Element Access/$$ +using any index type that has a conversion to the type $code size_t$$. + +$head 08-08$$ +$list number$$ +Fix a bug in the $code CppAD::local::pod_vector$$ template class +(not part of the user API) that wasted memory. +This bug was part of the $cref/06-04/whats_new_18/06-04/$$ change this year. +$lnext +Fix very recent bug in the optimization of dynamic parameters +in $cref PrintFor$$ statements. +$lnext +Fix some $code valgrind$$ warnings about use of values that have +not be initialized or set. +$lnext +Suppress printing of $cref PrintFor$$ operations +during the $cref optimize$$ process. +$lend + +$head 08-05$$ +The amount of memory in an operation sequence has changed; see +$cref/f.size_op_seq/seq_property/size_op_seq/$$. + +$head 08-04$$ +Remove the restrictions on dynamic parameters. +They can now be used anywhere except as indices and values in +$cref/VecAD/VecAD/Dynamic Parameters/$$ vectors. + +$head 07-30$$ +$list number$$ +The $cref/Constant/con_dyn_var/Constant/$$ function was added. +$lnext +$cref/API Warning/base_require/API Warning/$$ +for uses who define there own $icode Base$$ type. +The function $code IdenticalPar$$ was changed to +$cref/IdenticalCon/base_identical/Identical/IdenticalCon/$$ +and $code IdenticalEqualPar$$ was change to +$code IdenticalEqualCon$$. +This was done because the value of +$cref/dynamic/glossary/Parameter/Dynamic/$$ parameters can change. +$lnext +The some errors in the $cref pkgconfig$$ files +$code cppad.pc$$ and $code cppad-uninstalled.pc$$ were +corrected. +$lend + +$head 07-27$$ +We are adding the dependent dynamic parameters; i.e., +parameters that depend on the independent +$cref/dynamic/Independent/dynamic/$$ parameters +in a call to Independent. +For this reason the function +$icode%f%.size_dynamic()%$$ has been replaced by +$cref/size_dyn_ind/seq_property/size_dyn_ind/$$, +$cref/size_dyn_par/seq_property/size_dyn_par/$$, and +$cref/size_dyn_arg/seq_property/size_dyn_arg/$$. + + +$head 07-23$$ +Change the required version of $cref cmake$$ from greater than +or equal 3.1 to greater than or equal 2.8.4. + +$head 07-18$$ +Fix a bug (introduced on $cref/07-02/whats_new_18/07-02/$$) +in $cref optimize$$ routine when dynamic parameters are present. + +$head 07-02$$ +Add a special type of parameter that can change value, +see $cref/purpose/new_dynamic/Purpose/$$ for dynamic parameters. + +$head 06-27$$ +Simplify the process in the $cref optimize$$ procedure +where it recognizes identical expressions +(and do more error checking of this process). +This may speed up the optimization for large cases where +multiple expressions have the same hash code. + +$head 06-22$$ +Add an $cref/abs-normal/wish_list/Abs-normal/$$ wish list item. + +$head 06-20$$ +Worked more on reducing memory and increasing the speed of the +$cref/optimization/optimize/$$ of $codei%ADFun<%Base%>%$$ objects. + +$head 06-19$$ +Another (smaller) reduction in the amount of extra memory used during the +$cref optimize$$ process. +This time a vector of length +$cref/size_op/seq_property/size_op/$$ was converted from the type +used for C++ enums to a type that only used one byte. + +$head 06-13$$ +Reduce the amount of extra memory used during the $cref optimize$$ process. +To be more specific, two vectors that were separate now share the same memory. +These vectors have size equal to +$cref/size_op/seq_property/size_op/$$ +for the old operation sequence, and element type +$cref/cppad_tape_addr_type/cmake/cppad_tape_addr_type/$$. + +$head 06-12$$ +There was false sharing in the +hash table used to detect identical parameter values during +the recording of $codei%AD<%Base%>%$$ operations. +This has been fixed and should result in a speed up when multiple +threads are recording at the same time. + +$head 06-04$$ +The memory used during +$cref subgraph_reverse$$, $cref subgraph_sparsity$$, and +$cref optimize$$ was changed to use the smallest addressing type possible +for the tape in question. +To be specific the smallest type from the set +$code unsigned short$$, +$code unsigned int$$, +$code size_t$$, in that order. + +$head 05-29$$ +The $cref autotools$$ install procedure was not working since 05-26. +This has been fixed. + +$head 05-28$$ +$list number$$ +The Coin download page is not longer supporting monthly version. +These versions are now supported by the +$cref/git/download/Git/$$ +download procedure. +$lnext +The windows install procedures have not been kept up to date +and so have been removed. +It has since been fixed; see +$cref/msys2/cmake/CMake Command/msys2/$$ and +$cref/Visual Studio/cmake/CMake Command/Visual Studio/$$. +$lend + +$head 05-26$$ +Fix some warnings when testing with $code g++ -std=c++98$$. + +$head 05-20$$ +$list number$$ +The amount of memory used to store each operator was changed from +the size of an enum type to the size of an $code unsigned char$$; i.e., +one byte. +This changed $code CppAD::local::OpCode$$ to +$code CPPAD_VEC_ENUM_TYPE$$ in the expression used to compute +$cref/size_op_arg/seq_property/size_op_seq/$$. +Note $code CPPAD_VEC_ENUM_TYPE$$ is not in CppAD API and may change. +$lnext +There was a bug in the call to $code optimize$$ for the CppAD +$cref speed_cppad$$ tests. +To be specific $code no_print_for$$ was corrected to +$cref/no_prior_for_op/optimize/options/no_print_for_op/$$. +$lend + +$head 05-17$$ +The memory report for the CppAD matrix multiply speed test was changed +to report the memory before clearing the atomic functions; see the end of +$cref cppad_mat_mul.cpp$$. + +$head 05-04$$ +The comparison operations were changed on +$cref/2015-01-20/whats_new_15/01-20/$$ when the +$cref/abort_op_index/Independent/abort_op_index/$$ option was added. +This change caused a slow down CppAD +because the $cref compare$$ operators used to not be recorded when +$code NDEBUG$$ was defined. +The $cref/record_compare/Independent/record_compare/$$ option has been +added so that one can obtain this better performance +(when one does not need the $cref compare_change$$ function +or the $cref/abort_op_index/Independent/abort_op_index/$$ feature). + +$head 05-03$$ +The following was merged in from the $code reduce_tape$$ branch: +A change was made in the way CppAD iterated over the operation sequence +when subgraph operations were first added; see the heading +$cref/11-20/whats_new_17/11-20/$$ in whats new for 2017. +This caused CppAD to always use more memory for storing tapes. +This has been fixed so this extra memory is only allocated when it is needed. +In addition it can be freed; see +$cref/size_random/seq_property/size_random/$$ and +$cref/clear_subgraph/subgraph_reverse/clear_subgraph/$$. +In addition, this changed the amount of memory returned by +$cref/size_op_seq/seq_property/size_op_seq/$$ so that it +no longer includes the part returned by $code size_random$$. + +$head 04-29$$ +Change the $cref cppad_sparse_hessian.cpp$$ speed test to support the +$cref/symmetric/speed_main/Sparsity Options/symmetric/$$ option +for sparsity calculations. +This was added because, even though the symmetric sparsity patterns +are more efficient, they seem to take longer to calculation +and hence general sparsity patterns may be faster; see the sparse hessian +$cref/color_method/sparse_hessian/work/color_method/$$. + +$head 04-13$$ +The $cref speed_cppad$$ tests were modified to report the +amount of memory allocated at the end of each tests. +This will aid in the reduction of CppAD memory usage. + +$head 03-20$$ +Fix bug in $cref optimize$$ and $cref subgraph_sparsity$$ +when using C++11 $cref erf$$ function. + +$head 03-19$$ +Add more detail to the dynamic parameter whish list item. +This item has been implemented and removed from the wish list; see +$cref new_dynamic$$. + +$head 03-04$$ +The $code example/abs_normal$$ directory was missing from the +$cref/example/directory/Example Directory/$$ sub-directory list. +This has been fixed. + +$head 03-02$$ +Add the $cref/pat/sparse_rcv/pat/$$ member function to +the $code sparse_rcv$$ template class. + +$head 02-27$$ +Documentation was added to state that the $icode work$$ structure for +$cref/sparse_jac/sparse_jac/work/$$ ( $cref/sparse_hes/sparse_hes/work/$$ ) +can be used a different $icode f$$ and a different $icode subset$$ +provided that Jacobian (Hessian) sparsity pattern for $icode f$$ +and the sparsity pattern in $icode subset$$ are the same. + +$head 02-26$$ +The routine $cref sparse2eigen$$, added on 02-20, only worked +when the values in the matrix were integers. +This bug has been fixed. + +$head 02-23$$ +The syntax for some of the $cref utility$$ files were missing the +$code # include$$ command (or just the $code #$$ in the include command); +e.g., see the +$cref/syntax/set_union/Syntax/$$ for the $code set_union$$ utility. + +$head 02-20$$ +Add the utility function $cref sparse2eigen$$. + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/19.omh cppad-2019.02.00.0/omh/appendix/whats_new/19.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/19.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/19.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,115 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin whats_new_19$$ +$spell + CppAD + LeppOp + dag + mul + jac + hes + chkpoint + var +$$ + +$section Changes and Additions to CppAD During 2019$$ + +$head 01-18$$ +The documentation for $cref atomic_three$$, +and its subsections, was improved. + +$head 01-17$$ +The arguments +$cref/parameter_x/atomic_three/parameter_x/$$ and +$cref/type_x/atomic_three/type_x/$$ were included +for all the $code atomic_three$$ virtual functions. + +$head 01-16$$ +More improvements, and bug fixes, in the optimization of $cref atomic$$ +operations. +This results in a reduction in the number of parameters +$cref/size_par/seq_property/size_par/$$ +and the number of variables +$cref/size_var/seq_property/size_var/$$. + +$head 01-15$$ +Fix a bug in the optimization of $cref atomic_three$$ +operations with $cref/dynamic/Independent/dynamic/$$ parameters. + +$head 01-14$$ +$list number$$ +The $cref/rev_depend/atomic_three_rev_depend/$$ call back function +was added to $code atomic_three$$ class. +This enables one to $cref optimize$$ functions that use +$code atomic_three$$ operations; see +the $cref/rev_depend.cpp/atomic_three_rev_depend.cpp/$$ example. +$lnext +The ability to $cref optimize$$ functions was extended to +$cref chkpoint_two$$ operations; e.g., a call to optimize was added +at the end of the +$cref/get_started.cpp/chkpoint_two_get_started.cpp/$$ example. +$lnext +The $cref chkpoint_one$$ class was deprecated, +use $cref chkpoint_two$$ instead. +$lend + +$head 01-06$$ +One of the two atomic matrix multiply examples was converted +from using $cref atomic_two$$ to $cref atomic_three_mat_mul.cpp$$. +This conversion made it clear that the $icode type_x$$ argument +needed to be included in the +$cref/jac_sparsity/atomic_three_jac_sparsity/type_x/$$ and +$cref/hes_sparsity/atomic_three_hes_sparsity/type_x/$$ functions. + +$head 01-05$$ +Merge in the $code atomic branch$$. +This completed $cref wish_list$$ item for the new atomic function API; +see $cref atomic_three$$. +This is an improvement over the $cref atomic_two$$ interface, +which used the $code atomic_base$$ class and has been deprecated. +In addition the following changes were included: +$list number$$ +Move the checkpoint examples below the +$cref/checkpoint/chkpoint_one/$$ documentation. +$lnext +A phantom parameter, at index zero, was added; see +$cref/size_par/seq_property/size_par/$$. +$lnext +There appears to have been a bug in $code put_con_par$$ (not tested for) +whereby a constant parameter might match a dynamic parameter +(and get changed). This has been fixed. +$lnext +There was a mistake in the $code check_variable_dag$$ routine whereby +the operator $code LeppOp$$ checked a parameter index as if it were +a variable index. This has been fixed. +$lend + +$head 01-11$$ +Merge in the $code chkpoint$$ branch. +$list number$$ +This created the $cref chkpoint_two$$ class as a replacement +for the $cref chkpoint_one$$ class. +This new checkpoint class takes advantage +of $cref/dynamic parameters/glossary/Parameter/Dynamic/$$ +and can be used with $cref base2ad$$. +$lnext +While creating the $code chkpoint_two$$ class, +a problem was discovered in the $cref atomic_three$$ class. +To be specific, it does not yet work with $cref optimize$$. +A reverse dependency analysis is the proper way to fix this. +The $code atomic_three$$ $code type$$ member function does a forward +$cref/dependency analysis/atomic_three_for_type/Dependency Analysis/$$ +and so its name was changed from $code type$$ to $code for_type$$. +$lend + +$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_03.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_03.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_03.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_03.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,777 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_03$$ -$spell - dir - Eq.cpp - cppad.hpp - Hess - Taylor - Def - indvar - bool - CppADvector - ADdouble - sqrt - atan - exp - valarray - Faq - Lu - Det - Cpp - Microsoft - mak - std - Cygwin - Var - const - namespace - Geq - Leq - ini -$$ - -$section Changes and Additions to CppAD During 2003$$ - -$head Introduction$$ -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. - -$head 12-24$$ -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. - -$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 -$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 -one is using the Microsoft C++ compiler. - - -$head 12-14$$ -The extended system solvers $code OdeOne$$ and $code OdeTwo$$ have -been removed from the distribution. -In addition, the interface to the ODE solvers have been simplified. - -$head 12-13$$ -Remove the $code CppADCreateTape$$ macro -and have the tapes created and grow automatically. - - -$head 12-12$$ -The old method where one directly accesses the tape has been removed and the -following functions are no longer available: -$codei% - size_t %TapeName%.Independent(AD<%Base%> &%indvar%) - size_t %TapeName%.Record(size_t %order%) - size_t %TapeName%.Stop(void) - bool Dependent(const AD<%Base%> &%var%) const - bool %TapeName%.Dependent(const AD<%Base%> &%var%) const - size_t %TapeName%.Total(void) const - size_t %TapeName%.Required(void) const - size_t %TapeName%.Erase(void) - TapeState %TapeName%.State(void) const - size_t %TapeName%.Order(void) const - size_t %TapeName%.Required(void) const - bool Parameter(CppADvector< AD<%Base%> > &%u%) - %TapeName%.Forward(%indvar%) - %TapeName%.Reverse(%var%) - %TapeName%.Partial(%var%) - %TapeName%.ForwardTwo(%indvar%) - %TapeName%.ReverseTwo(%var%) - %TapeName%.PartialTwo(%var%) -%$$ - - -$head 12-10$$ -The change on $cref/12-01/whats_new_03/12-01/$$ make the taping process simpler -if one does not directly access -$code CppADCreateTape$$. -The $cref/examples/example/$$ were changed to not use -$icode TapeName$$. -The following examples were skipped because -they document the functions that access $icode TapeName$$: -$code DefFun.cpp$$, -$code For.cpp$$, -$code for_two.cpp$$, -$code Rev.cpp$$, and -$code rev_two.cpp$$. - -$head 12-05$$ -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. -$pre - -$$ -The ODE Example was changed to tape the solution -(and not use $code OdeOne$$ or $code OdeTwo$$). -This is simpler to use and -the resulting speed tests gave much faster results. - -$head 12-01$$ -The following function has been added: -$codei% - void Independent(const CppADvector<%Base%> &%x%) -%$$ -which will declare the independent variables and begin recording -$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 -$cref ADFun$$ object. -In addition, the tape no longer needs to be specified in the constructor. - - -$head 11-21$$ -Add $code StiffZero$$ to set of ODE solvers. - - -$head 11-20$$ -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$$ -and $code AD$$ use of -$code LuSolve$$ more complex. -$pre - -$$ -The member function names for the -$icode fun$$ argument to ODE were changed from -$icode%fun%.f%$$ to -$icode%fun%.Ode%$$ -and from -$icode%fun%.g%$$ to -$icode%fun%.Ode_ini%$$. - - -$head 11-16$$ -The -$cref/table of contents/_contents/$$ was reorganized -to provide a better grouping of the documentation. -$pre - -$$ -The $cref LuSolve$$ utility is now part of the distribution -and not just an example; i.e., -it is automatically included by -$code cppad.hpp$$. - - -$head 11-15$$ -The -ODE solver was modified so that it can -be used with any type (not just an AD type. -This was useful for the speed testing. -It is also useful for determining how the integrator -steps should be before starting the tape. -$pre - -$$ -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 -$code speed_cppad/OdeSpeed.cpp/$$ test was added -and some changes were made to the -ODE interface in order to make it faster. -The most significant change was in the specifications for -the ODE function object $icode fun$$. - - -$head 11-12$$ -The user defined unary function example -$code example/UnaryFun.cpp$$ was incorrect. -It has been corrected and extended. - -$head 11-11$$ -The $cref/CppAD::vector/CppAD_vector/$$ template class is now -used where the $code std::vector$$ template class was previously used. -You can replace the $code CppAD::vector$$ class -with a vector template class of your choosing during the -$cref Install$$ procedure. - -$head 11-06$$ -The documentation for -$cref/taping derivative calculations/mul_level/$$ was improved -as well as the corresponding example. -In order to make this simpler, -the example tape name $code DoubleTape$$ was changed to $code ADdoubleTape$$ -(and the other example tape names were also changed). - -$head 11-04$$ -The ODE utility was changed from an example to -part of the distribution. -In addition, it was extended so that it now supports taping the -solution of the differential equations (case $icode order$$ equal zero) -or solving the extended set of differential equations -for both first and second derivatives (cases $icode order$$ equal -one and two). -In addition, an initial condition that depends on the parameter -values is also allowed. - - - -$head 11-02$$ -It is now legal to differentiate a -$cref/parameter/glossary/Parameter/$$ -with respect to an -$cref/independent variable/glossary/Tape/Independent Variable/$$ -(parameter derivatives are always equal to zero). -This is an extension of the -$code Reverse$$, -$code Partial$$, -$code ReverseTwo$$, and -$code PartialTwo$$ -functions. - -$head 10-21$$ -All the $code CppAD$$ include files, -except $code cppad.hpp$$ were moved into an $code include$$ subdirectory. - - - -$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 -tape only supports partial derivatives. - -$head 10-14$$ -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. -$pre - -$$ -The $cref Value$$ function was changed so that it can -be called when the tape is in the Empty state. - -$head 10-10$$ -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$$ -are parameters that are exactly equal to zero and one. -If the variables $icode z$$ and $icode x$$ -were related in any of the following ways, -they share can share the same record on the tape -because they will have the same derivatives. -$codei% - %z% = %x% + %zero% %z% = %x% * %one% - %z% = %zero% + %x% %z% = %one% * %x% - %z% = %x% - %zero% %z% = %x% / %one% -%$$ -Furthermore, in the following cases, the result -$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 -all checked to make sure they did not add to the tape -in these special cases. -The total record count for the program in the Example directory -was 552 before this change -and 458 after. - -$head 10-05$$ -The process of converting the tape to operators was completed. -In order to make this conversion, the binary user defined -functions were removed. -(Bob Goddard -suggested a very nice way to keep the unary functions.) -Another significant change was made to the user interface during this procedure, -the standard math library functions -are now part of the CppAD distribution and not defined by the user. -$pre - -$$ -The function $icode%TapeName%.Total%$$ was added -to make it easy to track how many tape records are used by -the test suite. -This will help with future optimization of the CppAD recording process. -$pre - -$$ -There was a bug -(found by $href%mailto:magister@u.washington.edu%Mike Dodds%$$) -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, -the program would abort. -This has been fixed. - - -$head 09-30$$ -A process of changing the tape from storing partial derivatives to -storing operators has been started. -This will make the tape smaller and it will enable the computation -of higher derivatives with out having to tape the tape -(see $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. -$pre - -$$ -There was a bug in reverse mode when an dependent variable -was exactly equal to an independent variable. -In this case, it was possible for it to be located -before other of the independent variables on the tape. -These other independent variable partials were not initialized -to zero before the reverse calculation and hence had what ever -value was left by the previous mode calculation. -This has been fixed and the -$code Eq.cpp$$ example has been changed to test for this case. -$pre - -$$ -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$$, -$code Required$$, -$code Dependent$$, and -$cref/Parameter/ParVar/$$. - -$head 09-20$$ -The functions $code Grad$$ and $code Hess$$ were -changed to use function objects -instead of function pointers. - - -$head 09-19$$ -The higher order constructors (in standard valarray) were removed from the -ODE example in order to avoid memory allocation of temporaries -(and hence increase speed). -In addition, the function objects in the -ODE examples were changed to be $code const$$. - -$head 09-18$$ -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. -This was fixed by have the destructor use $code RemoveFromVarList$$ -to remove variables from the list. -($code RemoveFromVarList$$ is a private AD member function -not visible to the user.) - -$head 09-14$$ -There is a new Faq question about evaluating derivatives at multiple -values for the -$cref/independent variables/Faq/Independent Variables/$$. - -$head 09-13$$ -An example that uses -$code AD< AD >$$ -to compute higher derivatives was added. -$pre - -$$ -The name $code GaussEliminate$$ was changed to -$cref LuSolve$$ to better reflect the solution method. - -$head 09-06$$ -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.) - -$head 09-05$$ -A $cref/getting started/get_started.cpp/$$ -example was added and the organization -of the $cref/Examples/example/$$ was changed. - -$head 09-04$$ -The $code AbsOfDoubleNotDefine$$ flag is no longer used -and it was removed from the Windows -$cref/install/Install/$$ instructions. -$pre - -$$ -The 03-09-03 distribution did not have the proper date -attached to it. -The distribution script has been changed so that attaching -the proper date is automated -(i.e., this should not happen again). -$pre - -$$ -A $tref faq$$ section was started. - -$head 09-03$$ -Added the -$cref Value$$ function which returns -the $cref/base type/glossary/Base Type/$$ value -corresponding to an AD object. - -$head 08-23$$ -A new version of Cygwin was installed on the development system -(this may affect the timing tests reported in this document). -In addition, $cref LuSolve$$ was changed to use back substitution -instead of reduction to an identity matrix. This reduced the number -of floating point operations corresponding to evaluation of the determinant. -The following results correspond to the speed test -of DetLu on a 9 by 9 matrix: -$table -$bold Version$$ - $cnext $bold double Rate$$ - $cnext $bold AD Rate$$ - $cnext $bold Gradient Rate$$ - $cnext $bold Hessian Rate$$ - $cnext $bold Tape Length$$ -$rnext -03-08-20 - $cnext 8,524 - $cnext 5,278 - $cnext 4,260 - $cnext 2,450 - $cnext 532 -$rnext -03-08-23 - $cnext 7,869 - $cnext 4,989 - $cnext 4,870 - $cnext 2,637 - $cnext 464 -$tend - -$head 08-22$$ -The -$cref/unary minus/UnaryMinus/$$ operator was added to the AD operations. - - -$head 08-19$$ -The standard math function -examples were extended to include the complex case. -$pre - -$$ -The -$cref LuSolve$$ -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$$ -with $code LuSolve$$. -$pre - -$$ -When testing the speed of the change to using standard vector, -it was noticed that the LuSolve routine -was much slower. (see times for 03-08-16 below). -This was do to computing the determinant instead of the log -of the determinant. -Converting back to the log of the determinant regained -the high speeds. -The following results correspond to the speed test -of DetLu on a 9 by 9 matrix: -$table -$bold Version$$ - $cnext $bold double Rate$$ - $cnext $bold AD Rate$$ - $cnext $bold Gradient Rate$$ - $cnext $bold Hessian Rate$$ - $cnext $bold Tape Length$$ -$rnext -03-08-16 - $cnext 9,509 - $cnext 5,565 - $cnext 3,587 - $cnext 54 - $cnext 537 -$rnext -03-08-19 - $cnext 8,655 - $cnext 5,313 - $cnext 4,307 - $cnext 2,495 - $cnext 532 -$tend - - -$head 08-17$$ -The macro -$code CppADTapeOverflow$$ was added -so that CppAD can check for tape overflow -even in the $code NDEBUG$$ preprocessor flag is defined. - -$head 08-16$$ -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 -$cref/boolean valued functions with AD arguments/BoolFun/$$. -The examples -$cref lu_solve.cpp$$ -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 -differentiating linear algebra calculations. -The following results correspond to the speed test -of DetLu on a 9 by 9 matrix: -$table -$bold Version$$ - $cnext $bold double Rate$$ - $cnext $bold AD Rate$$ - $cnext $bold Gradient Rate$$ - $cnext $bold Hessian Rate$$ - $cnext $bold Tape Length$$ -$rnext -03-08-10 - $cnext 49,201 - $cnext 7,787 - $cnext 2,655 - $cnext 1,809 - $cnext 824 -$rnext -03-08-11 - $cnext 35,178 - $cnext 12,681 - $cnext 4,521 - $cnext 2,541 - $cnext 540 -$tend -In addition the corresponding test case -$cref lu_solve.cpp$$ was changed to a Hilbert matrix case. - - - -$head 08-10$$ -A $cref/complex polynomial/complex_poly.cpp/$$ -example was added. -$pre - -$$ -The documentation and type conversion in -$cref LuSolve$$ was improved. -$pre - -$$ -The absolute value function was removed from the examples because -some systems do not yet properly support $codei%double abs(double %x%)%$$, - - -$head 08-07$$ -Because the change to the multiplication operator had such -a large positive effect, -all of the -$cref/arithmetic operators/Arithmetic/$$ -were modified to reduce the amount of information -in the tape (where possible). - -$head 08-06$$ -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 -advantage of this fact. -This reduced the size of the tape and increased the speed -for the calculation of the gradient and Hessian for -the Lu determinant test of a 5 by 5 matrix as follows: -$table -$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 -03-08-06 $cnext 167 $cnext 12,780 $cnext 10,625 -$tend - -$head 08-05$$ -Fixed a mistake in the calculation of the sign of the determinant in -the $cref LuSolve$$ example. - -$head 08-04$$ -Added a the compiler flag -$codep - AbsOfDoubleNotDefined -$$ -to the make files so that it could be removed on systems where the -function -$codei% - double abs(double %x%) -%$$ was defined in $code math.h$$. - -$head 08-03$$ -The -$code Grad$$ and $code Hess$$ functions were modified -to handel the case where the function does not depend on -the independent variables. -$pre - -$$ -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 -$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. -$pre - -$$ -The $cref/<%$$ data structure -was changed to include a doubly linked list of variables. -This enabled the -$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 -the determinant of a 5 by 5 matrix as follows: -$table -$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 -03-07-26 $cnext 436 $cnext 3,436 $cnext 213 -$tend - - -$head 07-22$$ -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.) -$pre - -$$ -The Windows version make file directive $code /I ..\..$$ -in $code example\Example.mak$$ and $code Speed\Speed.mak$$ -was changed to $code /I ..$$ (as it should have been). - - - -$head 07-20$$ -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$$.) -$pre - -$$ -The first Alpha for the Windows -$cref/installation/Install/$$ was released. - -$head 07-18$$ -Computing the determinant of a minor of a matrix -$cref det_of_minor$$ -was documented as a realistic example using CppAD. - - -$head 07-16$$ -Fixed some non-standard constructions that caused problems -with the installation on other machines. -$pre - -$$ -Compiled and ran the tests under Microsoft Windows. -(The Windows release should not take much more work.) - -$head 07-14$$ -First Alpha release of CppAD -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. - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_04.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_04.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_04.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_04.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,1021 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_04$$ -$spell - autotools - cppad.hpp - deps - executables - Runge - Rhs - aclocal - config - Makefile - ublas - Autoconf - Automake - cppad - yy - mm - dd - Faq - acos - asin - sqrt - exp - usr - nmake - mak - namespace - CppADvector - atan - cos - retape - Vec - const - std - Hess - depricated - Det - Lu - dsp - Arg - Cpp - Microsoft - Taylor - dep - ind -$$ - -$section Changes and Additions to CppAD During 2004$$ - -$head Introduction$$ -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 -assist you in learning about changes between various versions. - - -$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 -$code cppad/vector.hpp$$ was included. - -$head 12-09$$ -The $cref LuSolve$$ and $code OdeRunge$$ source code -was modified to make the more in line with the introduction -to C++ AD book -($code OdeRunge$$ has been replaced by $cref Runge45$$). -In addition, the examples $code OdeRunge.cpp$$ and -$cref lu_solve.cpp$$ were modified to make the simpler. -(The more complex version of $code OdeRunge.cpp$$ -was moved to the $code TestMore$$ directory.) - -$head 12-03$$ -The $cref Poly$$ documentation and source code were modified to -make them more in line with the introduction to C++ AD book. - -$head 11-17$$ -Changing to Autoconf and Automake on -$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 -because a declaration of $code LessThanOrZero$$ was missing. -This has been fixed. - -$head 11-15$$ -The $cref ForOne$$ and $cref RevOne$$ -easy to use $cref/drivers/Drivers/$$ were added. - -$head 11-14$$ -The notation in the $cref ADFun$$ sections was changed -to make the $cref Forward$$ and $cref Reverse$$ routines -easier to use. - - -$head 11-13$$ -The Taylor coefficient vector and matrix notation was folded into -just $cref/Taylor coefficients/glossary/Taylor Coefficient/$$. - -$head 11-12$$ -If $code NDEBUG$$ is not defined during compile time, -all $codei%AD<%Base%>%$$ -$cref/comparison/Compare/$$ operations are checked during -$cref/zero order/forward_zero/$$ forward mode calculations. -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 -$cref Jacobian$$ driver. -In addition, more $cref/index/_index/$$ entries, -that point to the $cref/easy to use drivers/Drivers/$$, -were added. - -$head 11-04$$ -The Microsoft Visual Studio -project file $code example/Example.dsp/$$ was missing some -new examples that needed to be linked in -the install windows procedure. -This has been fixed. - -$head 11-02$$ -The $cref/unix installation/autotools/$$ 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 -$code PrintFor/.deps$$ and -$code PrintFor/.deps/PrintFor.Po$$ had an extra $code ?$$ -at the end of their names. -This seems to have been fixed by using a newer version of the autoconf -and automake tools. - -$head 10-29$$ -Add the example and test $cref simple_vector.cpp$$ -to the $cref SimpleVector$$ documentation. -$pre - -$$ -The specifications for -$cref/preprocessor symbols/preprocessor/$$ -state that all the CppAD preprocessor symbols -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 -$cref hes_lu_det.cpp$$, -$cref hes_minor_det.cpp$$, -$cref jac_lu_det.cpp$$, -and -$cref jac_minor_det.cpp$$ used the negative of a $code size_t$$ value. -The value has been changed to an $code int$$. -$pre - -$$ -The $cref/CppAD::vector/CppAD_vector/$$ template class -was converted into a library routine so it can be used -separately from the rest of CppAD. - -$head 10-27$$ -The $cref PrintFor$$ example was moved to its own directory -because the conversion from VC 6.0 to VC 7.0 projects -did not work when there were multiple executables in one project file. -The $cref install$$ instructions were modified to reflect this change. - -$head 10-21$$ -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. - -$head 10-19$$ -The current version of CppAD has a problem compiling under Microsoft -Visual C++ version 7.0 (it compiles and works under version 6.0). -The problem appears to be due to a closer agreement between VC 7.0 and the -C++ standard for declaring templates functions as friends. -Some friend declarations were removed and others were made more specific -in order to migrate the a version that will compile and run using VC 7.0. - -$head 10-16$$ -The example $cref compare.cpp$$ displayed the text from -$cref bool_fun.cpp$$ by mistake. -This has been fixed. -$pre - -$$ -The $cref Compare$$ operators have been extended to work with -$code int$$ operands. - -$head 10-06$$ -The test -$code TapeDetLu$$ was added to $code speed_cppad/DetLuSpeed.cpp$$ -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 -from the derivative calculation time. -$pre - -$$ -The -windows installation steps -do not build a $code config.h$$ file. -Hence a default $code config.h$$ file was added to the -distribution for use with Microsoft Visual Studio. -$pre - -$$ -The $code Distribute$$ section of the -developer documentation was brought up to date. -$pre - -$$ -Links to the ADOLC and FADBAD download pages were added -to the $cref/unix installation/autotools/$$ instructions. - -$head 09-29$$ -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. - -$head 09-26$$ -The routine $code OdeRunge$$ was modified -so that it will now integrate functions of a complex arguments. -This was done by removing -all uses of greater than and less than comparisons were removed. -($code OdeRunge$$ has been replaced by $cref Runge45$$). -$pre - -$$ -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/autotools/$$ -$code make$$ command. - - -$head 09-23$$ -There was a reference to $icode B$$ that should have been $icode X$$ -in the description of the -$cref/X/LuSolve/X/$$ argument of $code LuSolve$$. -This has been fixed. - -$head 09-21$$ -The $cref CondExp$$ function has been modified so that it works properly -for $codei%AD< AD<%Base%> >%$$ types; i.e., -it now works for multiple levels of taping. -$pre - -$$ -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/autotools/$$ -to try to run $code autoconf$$ -and this did not work on systems with very old versions of $code autoconf$$. -This has been fixed. - - -$head 09-13$$ -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$$ -in the documentation tree. - -$head 09-10$$ -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 - -$$ -The $icode Base$$ type requirements were simplified. -$pre - -$$ -The $cref/Unix installation/autotools/$$ 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). - -$head 09-09$$ -The $cref PrintFor$$ function was added so that -users can debug the computation of function values -at arguments that are different from those used when taping. - -$head 09-07$$ -In the $cref/Unix installation/autotools/$$ 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 -in the default executable path). - - -$head 09-04$$ -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 -$codei%%$$ were moved to -$codei%%$$. - -$head 09-02$$ -Some more messages were added to the output of $code configure$$ -during the $cref/Unix installation/autotools/$$. -$pre - -$$ -The suggested compression program during -Windows installation -was changed from -$href% - http://www.7-zip.org% - 7-zip -%$$ -to -$href% - http://www.winzip.com% - WinZip -%$$. - - -$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 -date for the current version. -This has been fixed. -$pre - -$$ -All the correctness tests are now compiled with the $code -g$$ -command line option -(the speed tests are still compiled with $code -O2 -DNDEBUG$$). -$pre - -$$ -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 -either the $code std::vector$$ -or $code boost::numeric::ublas::vector$$. - -$head 08-24$$ -This date marks the first release that uses -the Gnu tools Autoconf and Automake. -This automates the building of the make files for the -$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 -has its own directory and -the distribution directory is named -$codei% - cppad-%yy%-%mm%-%dd% -%$$ -where $icode%yy%-%mm%-%dd%$$ is the year, month and date -of the distribution. -(Note the distribution directory is different from the directory -where CppAD is finally installed.) - - -$head 08-12$$ -Move $code OdeExplicit$$ into the $code cppad/library/$$ directory. -In addition, change it so that the vector type was a template argument; i.e., -works for any type of vector (not just $code CppADvector$$). - -$head 07-31$$ -Move $cref LuSolve$$ into the $code cppad/library/$$ directory. -In addition, change it so that the vector type was a template argument; i.e., -works for any type of vector (not just $code CppADvector$$). - - -$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. - -$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/utilities/utility/$$. - -$head 07-03$$ -The CppAD error macros names -$code CppADExternalAssert$$ and $code CppADInternalAssert$$ -were changed to -$code CppADUsageError$$ and $code CppADUnknownError$$. -The $cref SpeedTest$$ routine was changed to use $code CppADUsageError$$ -instead of a C assert. - -$head 07-02$$ -The $cref SpeedTest$$ output was improved so that the columns of -values line up. Previously, this was not the case when -the number of digits in the size changed. - -$head 06-29$$ -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 -$cref/independent function/Independent/$$ -was added to the -$cref/Faq/Faq/Assignment and Independent/$$. -In addition, -a similar discussion -was added to the documentation for the -$cref Independent$$ function. -$pre - -$$ -The definition of a -$cref/parameter/glossary/Parameter/$$ -and -$cref/variable/glossary/Variable/$$ -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/$$ -(except for the unary operators) -can now accept $code int$$ arguments. -The documentation for these arguments has been changed to reflect this. -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 -$code cppad/Test$$ directory. - - -$head 06-04$$ -The $cref/atan2/atan2/$$ function was added. - -$head 06-03$$ -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$$ for fourth and higher orders. -This has been fixed. -In addition, -the following examples have been changed -so that they test derivative up to fifth order: -$cref/asin/Asin.cpp/$$, -$cref/atan/atan.cpp/$$, -$cref/cos/cos.cpp/$$, -$cref/exp/exp.cpp/$$, -$cref/log/log.cpp/$$, -$cref/sin/sin.cpp/$$, -$cref/sqrt/sqrt.cpp/$$. - - -$head 06-01$$ -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. - -$head 05-30$$ -The $cref/sin/sin.cpp/$$ and $cref/cos/cos.cpp/$$ examples were -changed so that they tested higher order derivatives. - - -$head 05-29$$ -The forward mode recursion formulas for each of the -$xref/ - ForwardTheory/ - Standard Math Functions/ - Cases that Apply Recursion Above/ - standard math functions/ - 1 -/$$ -has been split into separate sections. -$pre - -$$ -A roman (instead of italic) font was used for the name of -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)$$. - - -$head 05-26$$ -In the documentation for $cref Poly$$, -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$$ -was corrected to $code cppad/library/SpeedTest.h$$. -In addition, the example case was corrected. -$pre - -$$ -In $cref Reverse$$, the definition for $latex U(t, u)$$ had -$latex t^p-1$$ where it should have had $latex t^{p-1}$$. -This has been fixed. - - -$head 05-25$$ -The special case where the second argument to the $cref pow$$ function is an -$code int$$ has been added. - -$head 05-14$$ -Change all of the include syntax -$codei% - # include "%filename%" -%$$ -to the syntax -$codei% - # include <%filename%> -%$$ -so that examples and other use better reflect how one would use CppAD after -it was installed in a standard include directory; for example -$code /usr/local/include/cppad$$. -$pre - -$$ -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 -$code lib$$ directory or a standard $code include$$ directory. - - -$head 05-12$$ -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 has been fixed. -$pre - -$$ -All of the include commands of the form -$codei% - # include "include/%name%.h" - # include "lib/%name%.h" -%$$ -have been changed to the form -$codei% - # include "cppad/include/%name%.h" - # include "cppad/lib/%name%.h" -%$$ -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 -$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 -$codep - # include "cppad.hpp" -$$ -to -$codep - # include "cppad/cppad.hpp" -$$. -$pre - -$$ -The window $code nmake$$ file $code Speed/Speed.mak$$ was out of date. -This has been fixed. - -$head 05-09$$ -Move $cref Poly$$ and $cref SpeedTest$$ into the -$code cppad/Lib$$ directory and the $code CppAD$$ namespace. - - -$head 05-07$$ -The $cref/divide operator tests/div.cpp/$$ were extended to -include a second order derivative calculation using reverse mode. -$pre - -$$ -The $cref Poly$$ routine was modified to be more efficient in the -derivative case. In addition, it was changed to use an arbitrary -vector for the coefficients (not just a $code CppADvector$$). - - -$head 05-04$$ -A reloading of the data base -caused the files $code include/atan.h$$ and $code include/cos.h$$ to be -mistakenly started with lower case letters. -These have been moved to $code include/Atan.h$$ and $code include/Cos.h$$ -respectively. - -$head 05-03$$ -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$$ and $cref cos$$, -were not defined for elements of an $cref VecAD$$ vector. -This has been fixed. - - -$head 04-28$$ -The operator $cref/< >%$$ 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 -was changed from $code ADVec$$ to $cref VecAD$$. -This class was extended so that -the value of elements in these vectors can be variables -(need not be $cref/parameters/glossary/Parameter/$$). - -$head 03-30$$ -Do some simple searching of the parameter table during taping -avoid multiple copies of parameters on tape (use less tape memory). - - -$head 03-28$$ -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 -$cref/parameters/Glossary/Parameter/$$. - - - -$head 03-25$$ -The internal taping structure has been changed to have variable length -instructions. -This is to save memory on the tape. -In addition, it may help in the implementation of the -vector class that tracks indexing. -(A now functioning version of this class is described in -$cref VecAD$$.) - - -$head 03-18$$ -A change was made to the way parameter values are stored on the tape. -This resulted in a significant savings in the amount of memory required. - - -$head 03-17$$ -Change the return type for $cref SpeedTest$$ from $code const char *$$ -to $code std::string$$. -The memory required for the largest test cases was added to the -$cref speed_cppad$$ tests output. - -$head 03-15$$ -The comparison between ADOLC and CppAD for -the $code DetLuADOLC.cpp/$$ example was returning an error -(because it was checking for exact equality of calculated derivatives -instead of nearly equal). -This has been fixed. - -$head 03-12$$ -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 -(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 -examples that compute determinants. - -$head 03-09$$ -The routines $code Grad$$ and $code Hess$$ have been removed. -You should use $cref Jacobian$$ and $cref Hessian$$ instead. - - -$head 03-07$$ -The driver routines $cref Hessian$$ and $cref RevTwo$$ has been added. -These to compute specialized subsets of the second order partials. -$pre - -$$ -Documentation errors in $cref ForTwo$$ and $cref Reverse$$ were fixed. -The $cref example$$ documentation was reorganized. - - -$head 03-06$$ -The driver $cref ForTwo$$ has been added. -It uses forward mode to compute a subset of the second order partials. -$pre - -$$ -Split all of the "example" and "test" index entries that come from -$codei%cppad/example/%*%.cpp%$$ -into sorted subheadings. - -$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 -computes the derivative of vector valued functions. - -$head 03-04$$ -The bug reported on $cref/02-17/whats_new_04/02-17/$$ was present in all -the operators. These have all been fixed and tests for all the operators -have been added to the $code cppad/Test$$ directory. -$pre - -$$ -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. -This helps when deciding whether to use forward or reverse mode. - -$head 03-03$$ -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 -when executing $cref Forward$$ and $cref Reverse$$ calculations. -$pre - -$$ -The $cref Independent$$ and $cref/Parameter/seq_property/Parameter/$$ functions -were moved below $cref ADFun$$ in the documentation. - - -$head 03-01$$ -The DetLuADOLC.cpp, DetLu case was added to the ADOLC -comparison tests. - -$head 02-29$$ -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 -when debugging was turned off. This has been fixed. - - -$head 02-28$$ -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/$$ -has been added. - -$head 02-21$$ -If you use the user defined unary atomic functions -there is a restriction on the order of the derivatives that can be calculated. -This restriction was documented in the user defined unary function -$cref Forward$$ -and $cref Reverse$$. -(These unary functions were removed on $cref/03-12/whats_new_04/03-12/$$.) - -$head 02-20$$ -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$$ -$rnext -$icode%r1% = %f%.Rev(%v%)%$$ $cnext $icode%r1% = %f%.Reverse(1, %v%)%$$ -$rnext -$icode%q1% = %f%.RevTwo(%v%)%$$ $cnext $icode%r2% = %f%.Reverse(2, %v%)%$$ -$rnext - $cnext $icode%q1%[%i%] == %r2%[2 * %i% + 1]%$$ -$tend -$pre - -$$ -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 -$cref/04-02-15/whats_new_04/02-15/$$. -$pre - -$$ -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 -parameter on an $codei%AD< AD<%Base%> >%$$ tape and a its value -might be a variable on the -$codei%AD<%Base%>%$$ tape. -This bug in the multiply and divide routines has been fixed. -$pre - -$$ -There was a bug that is some cases reported a divide by zero error -when the numerator was zero. This has been fixed. - - -$head 02-16$$ -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. -This has been fixed. -$pre - -$$ -The Microsoft project file $code example\Example.dsp$$ -was out of date. This has been fixed. -$pre - -$$ -The example that $cref/tapes derivative calculations/mul_level/$$ -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 -$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$$ -$rnext -$icode%v0% = %f%.Arg(%u0%)%$$ $cnext $icode%v0% = %f%.Forward(0, %u0%)%$$ -$rnext -$icode%v1% = %f%.For(%u1%)%$$ $cnext $icode%v1% = %f%.Forward(1, %u1%)%$$ -$rnext -$icode%v2% = %f%.For(%u2%)%$$ $cnext $icode%v2% = %f%.Forward(1, %u2%)%$$ -$tend - - -$head 02-12$$ -All of the derivative calculations are now done using arbitrary -order Taylor arithmetic routines. -The $cref Theory$$ section was changed to document this method -of calculation. - - -$head 02-01$$ -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 -$code FunForTwo$$ routine. - -$head 01-29$$ -There were some bugs in the $code FunArg$$ function -that were fixed. -$list number$$ -If one of the dependent variables was a -$cref/parameter/glossary/Parameter/$$ -$code FunArg$$ did not set it's value properly. -(All its derivatives are zero and this was handled properly.) -$lnext -The user defined unary functions were not -computed correctly. -$lend - -The specifications for the usage and unknown CppAD error macros -were modified so that they could be used with out side effects. - -$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 -$code OdeImplicit$$. - -$head 01-22$$ -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%$$. - - - - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_05.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_05.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_05.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_05.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,940 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_05$$ -$spell - autotools - html - Dir - cppad.hpp - acos - asin - autoconf - ptr - Erf - CppADlib - logdet - valarray - Jacobian - bool - yy - mm - dd - pkzip - gz - Neg - maxabs - Romberg - cos - Le - Lt - Eq - Ge - Gt - op - gcc - Cygwin - std - Lu - CppADvector - Jon Pearce - namespace - dsw - dsp - sln - vcproj - CondExp - Microsoft - inline - scur - Vec - Rosen - Runge-Kutta - Linux - typedef - Cpp - atan -$$ - -$section Changes and Additions to CppAD During 2005$$ - -$head 12-24$$ -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$$ -calculations are now freed directly after use. -$pre - -$$ -The $cref TrackNewDel.cpp$$ example was missing from the Windows install -examples and testing -project file. -This has been fixed. - -$head 12-22$$ -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 -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 -with the $cref speed_cppad$$ tests. -$pre - -$$ -The $cref speed_cppad$$ test program now outputs the version of CppAD -at the top (to help when comparing output between different versions). - - -$head 12-19$$ -The $cref TrackNewDel$$ routines were added for track memory allocation -and deletion with $code new[]$$ and $code delete[]$$. -This is in preparation for making CppAD more efficient in it's use of -memory. -The bug mentioned on $cref/12-01/whats_new_05/12-01/$$ resurfaced -and the corresponding routine was changed as follows: -$codep - static local::ADTape *Tape(void) - { // If we return &tape, instead of creating and returning ptr, - // there seems to be a bug in g++ with -O2 option. - static local::ADTape tape; - static local::ADTape *ptr = &tape; - return ptr; - } -$$ - -$head 12-16$$ -The $cref NearEqual$$ function documentation for the relative error case -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 -(for the complex case in $code NearEqual$$). -In addition, more extensive testing was done in $cref near_equal.cpp$$. - - - -$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$$ -and an utility in $code example/NearEqualExt.h$$, -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 -the entire $code CppADlib.a$$ library. -$pre - -$$ -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. -This has been fixed. -$pre - -$$ -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 wish_list$$. -$pre - -$$ -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). - - - -$head 12-14$$ -Extend $cref erf$$ to cover more cases while converting it -from a function in $code lib/CppADlib.a$$ -to a template function in $code cppad/local/Erf.h$$. -This is one step along the way of removing -the entire $code CppADlib.a$$ library. - - -$head 12-11$$ -Group routines that extend the domain for which an $cref ADFun$$ -object is useful into the ExtendDomain section. -$pre - -$$ -Add an example of a C callable routine that computes -derivatives using CppAD (see $cref interface2c.cpp$$). - -$head 12-08$$ -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/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 -$code void$$. - - -$head 12-06$$ -The specifications for a $cref SimpleVector$$ template class -were extended so that the return type of an element access is -not necessarily the same as the type of the elements. -This enables us to include $code std::vector$$ -which packs multiple elements into a single storage location -and returns a special type on element access (not the same as $code bool$$). -To be more specific, -if $icode x$$ is a $code std::vector$$ object -and $icode i$$ has type $code size_t$$, -$icode%x%[%i%]%$$ does not have type $code bool$$. -$pre - -$$ -Add a Home icon, -that links to the -$href% - http://www.coin-or.org/CppAD/% - CppAD home page -%$$, -to the top left of the navigation frame -(left frame) for each documentation section. - -$head 12-05$$ -The $cref RevSparseHes$$ reverse mode Hessian sparsity calculation -has been added. -$pre - -$$ -The definition of a $cref/sparsity pattern/glossary/Sparsity Pattern/$$ -has been corrected to properly correspond to the more efficient form -mentioned under $cref/whats_new_05/whats_new_05/11-20/$$ below. -$pre - -$$ -The dates in this file used to correspond to -local time for when the change was checked -into the -$href% - http://projects.coin-or.org/CppAD/browser% - subversion repository -%$$. -From now on the dates in this file will correspond to the first -version of CppAD where the change appears; i.e., the date in the -unix and windows -download file names $codei%CppAD-%yy%-%mm%-%dd%$$. - - -$head 12-03$$ -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 -(fewer true entries). - - -$head 12-02$$ -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 -(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 -$codep - static local::ADTape *Tape(void) - { static local::ADTape tape; - return &tape; - } -$$ -(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 -this problem. -This fix is not well understood; i.e., we should watch to see -if this problem reoccurs. -$pre - -$$ -The source code for -$cref lu_vec_ad_ok.cpp$$ was mistakenly used for -$code speed_cppad/LuSolveSpeed.cpp$$. -This has been fixed. - - - -$head 11-23$$ -The speed test of $cref lu_vec_ad.cpp$$ has been commented out -because it sometimes generates a segmentation fault. -Here is an explanation: -$pre - -$$ -If $icode X$$ is a $codei%AD<%Base%>%$$ object, -$icode y$$ is a $icode Base$$ object, -$icode%X%[%y%]%$$ uses pointer from the element -back to the original vector. -Optimizing compilers might reorder operations so that -the vector is destroyed before the object is used. -This can be avoided by changing the syntax for $cref VecAD$$ objects -to use $code set$$ and $code get$$ member functions. - - -$head 11-22$$ -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. -$pre - -$$ -CppAD now checks that the domain dimension during -$cref Independent$$ and -the range dimension during $cref ADFun$$ -(provided that $code -DNDEBUG$$ is not defined). -If either of these is zero, -the $code CppADUsageError$$ macro is invoked. - - -$head 11-20$$ -The sparsity pattern routines -$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 -$cref/sparsity patterns/glossary/Sparsity Pattern/$$. -$pre - -$$ -An extra $cref/exception/VecAD/VecAD::reference/Exceptions/$$ has been -added to the use of $cref VecAD$$ elements. -This makes $code VecAD$$ some what more efficient. - -$head 11-19$$ -Improve the output messages generated during execution of the -$cref/configure/autotools/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, -it will generate a $code CppADUsageError/$$ message. -$pre - -$$ -The $cref get_started.cpp$$ example has been simplified -so that it is easier to understand. - -$head 11-15$$ -Fix a memory leak in both the $cref ForSparseJac$$ and -$cref RevSparseJac$$ calculations. - -$head 11-12$$ -Add reverse mode $cref/Jacobian sparsity/RevSparseJac/$$ calculation. - -$head 11-09$$ -Add prototype documentation for $cref/logdet/LuSolve/logdet/$$ in -the $cref LuSolve$$ function. -$pre - -$$ -Add the optional $icode ratio$$ argument to the -$cref LuFactor$$ routine. -(This has since been moved to a separate routine called $cref LuRatio$$.) - -$head 11-07$$ -Remove some blank lines from the example files listed -directly below (under 11-06). -Comments for computing the entire Jacobian -$cref/entire sparsity pattern/ForSparseJac/Entire Sparsity Pattern/$$ -was added. - -$head 11-06$$ -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$$, -$cref rev_one.cpp$$, -$code Reverse.cpp$$, -$cref hessian.cpp$$, -$cref jacobian.cpp$$, -$cref forward.cpp$$, -$cref for_two.cpp$$, -$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 -$cref reverse_one.cpp$$ and $code reverse_checkpoint.cpp$$). - -$head 11-01$$ -Add forward mode $cref/Jacobian sparsity/ForSparseJac/$$ calculation. - -$head 10-20$$ -Add $cref/sparsity patterns/glossary/Sparsity Pattern/$$ to -the whish list. - -$head 10-18$$ -The Unix install $cref/configure/autotools/Configure/$$ command -was missing the $code --$$ before of the $code prefix$$ command line -argument. - -$head 10-14$$ -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 -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 -(which can be slow to access). - - -$head 10-12$$ -Change the -$cref/configure/autotools/Configure/$$ script so that compilation of the -$cref get_started.cpp$$ and $cref print_for_cout.cpp$$ examples are optional. -$pre - -$$ -One of the dates in the Unix installation -extraction discussion was -out of date. This has been fixed. - - - -$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/autotools/Configure/$$. -$pre - -$$ -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 -$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$$. -The source code for this template vector class, -$code cppad/vector.hpp$$, -has been removed from the documentation. - - -$head 09-27$$ -Add the -$cref/prefix_dir/autotools/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/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/utilities/utility/$$ and the library was -reorganized. - -$head 09-20$$ -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 -$code Example$$, $code TestMore$$, and $code Speed$$, directories -optional during the $cref/configure/autotools/Configure/$$ command. -The $cref/Unix installation instructions/autotools/$$ were -overhauled to make the larger set of options easy to understand. - -$head 09-14$$ -Added the $cref NumericType$$ concept and made the following -library routines require this -concept for their floating point template parameter type: -$cref LuSolve$$, -$cref LuFactor$$, -$cref RombergOne$$, -$cref RombergMul$$, -$cref Runge45$$, -$cref Rosen34$$, and -$cref OdeErrControl$$. -This is more restrictive than the previous requirements -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$$. - -$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%$$ -(the $icode%*%.zip%$$ file -uses pkzip compression). - - -$head 08-30$$ -The $icode maxabs$$ argument has been added to the -$cref OdeErrControl$$ function so that it can be used -with relative errors where components of the ODE solution may be zero -(some of the time). -In addition, some of the rest of the OdeErrControl documentation -has been improved. -$pre - -$$ -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/utilities/utility/$$. - -$head 08-20$$ -Backed out addition of $code Romberg$$ integration routine -(at this point uncertain of the interface that is most useful in -the context of AD.) - -$head 08-19$$ -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 -$code TestMore/TestMore.vcproj$$ were missing some necessary routines. -In addition, $code Speed/Speed.vcproj$$ was generating a warning. -This has been fixed. - -$head 08-14$$ -An $cref Integer$$ conversion function as been added. -$pre - -$$ -The $cref value.cpp$$ example has been improved and the old example -has been moved into the $code TestMore$$ directory. - -$head 08-13$$ -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 - -$$ -The $cref OdeErrControl$$ routine could lock in an infinite loop. -This has been fixed and a test case has been added to check for this problem. - -$head 08-07$$ -The $cref/conditional expression/CondExp/$$ function has been changed -from just $code CondExp$$ to -$code CondExpLt$$, -$code CondExpLe$$, -$code CondExpEq$$, -$code CondExpGe$$, -$code CondExpGt$$. -This should make code with conditional expressions easier to understand. -In addition, it should reduce the number of tape operations because -one need not create as many temporaries to do comparisons with. -The old $code CondExp$$ function has been deprecated. - -$head 07-21$$ -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 - -$$ -Improve the index entries in the documentation that corresponds -to the $code cppad/local$$ directory source code. - -$head 07-19$$ -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 -$cref/VecAD speed and memory/VecAD/Speed and Memory/$$ was added -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/autotools/Configure/$$ options -were not properly implemented for compiling the -$code lib$$ sub-directory. -This has been fixed. -$pre - -$$ -Some compiler warnings in the file $code lib/ErrFun.cpp$$, -which computes the $cref erf$$ function, -have been fixed. - -$head 07-11$$ -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 -an include of $code example/NearEqualExt.h$$. This has been fixed. - -$head 07-08$$ -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 -$code CppADvector$$ vector types. -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 -only run once per case that is being checked. -$pre - -$$ -Simple Vector concept checking ($cref CheckSimpleVector$$) was -added to the routines: -$cref ForOne$$, -$cref ForTwo$$, -$cref Forward$$, -$cref ADFun$$, -$cref Hessian$$, -$cref Independent$$, -$cref Jacobian$$, -$cref RevOne$$, -$cref RevTwo$$, and -$cref Reverse$$. - -$head 07-04$$ -Simple Vector concept checking ($cref CheckSimpleVector$$) was -added to the routines: -$cref LuFactor$$, -$cref LuSolve$$, -$cref LuInvert$$, -$cref OdeErrControl$$, -$cref Runge45$$, and -$cref Rosen34$$. -$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/utilities/utility/$$ routines are). -$pre - -$$ -The previous distribution (version 05-07-02) was missing the file -$code cppad/local/Default.h$$. -This has been fixed. - -$head 07-03$$ -Added $cref CheckSimpleVector$$, a C++ concept checking utility -that checks if a vector type has all the necessary conditions -to be a $cref SimpleVector$$ class with a specific element type. - -$head 07-02$$ -Version 7 of Microsoft's C++ compiler -supports the standard declaration for a friend template function. -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 -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 -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 -$codei%AD< AD<%Base%> >%$$, $codei%AD< AD< AD<%Base%> > >%$$ etc. - - -$head 07-01$$ -The permissions were set as executable for many of the no-executable files -in the distribution; for example, the $code README$$, file. -This has been fixed. - -$head 06-25$$ -Some improvements were made to the -README, AUTHORS, COPYING, and INSTALL files. -In addition, the file -$code UWCopy040507.html$$ -which contains the University of Washington's copyright -policy (see Section 2) was added to the distribution. - -$head 06-24$$ -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%$$ -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 -$code TestMore$$ directory (it is now only a test). - - -$head 06-13$$ -The changes made on 06-06 do not run under Microsoft Visual C++ version 6.0 -(even though they are within the C++ standard). -Preliminary testing under version 7 indicates that Microsoft -has fixed this problem in later versions of their C++ compiler. - -$head 06-06$$ -Converted the routines -$cref Forward$$ and $cref Reverse$$ to allow for any -$cref SimpleVector$$ instead of just $code CppADvector$$. -In addition, separated the syntax of the function call -from the prototype for each of the arguments. -This was also done for all the easy to use $cref Drivers$$ -as well as the $cref Independent$$ function and -the $cref ADFun$$ constructor. -$pre - -$$ -Add a section containing a list of -$cref/all the examples/ListAllExamples/$$. - -$head 05-19$$ -A significant improvement in speed was obtained by moving -the buffer extension to a separate function and then -inline the rest of putting operators in the tape. -For example, -here is part of the speed test output before this change: -$codep - Tape of Expansion by Minors Determinant: Length = 350, Memory = 6792 - size = 5 rate = 230 - size = 4 rate = 1,055 - size = 3 rate = 3,408 - size = 2 rate = 7,571 - size = 1 rate = 13,642 -$$ -and here is the same output after this change: -$codep - Tape of Expansion by Minors Determinant: Length = 350, Memory = 6792 - size = 5 rate = 448 - size = 4 rate = 2,004 - size = 3 rate = 5,761 - size = 2 rate = 10,221 - size = 1 rate = 14,734 -$$ -Note that your results will vary depending on operating system and machine. - -$head 05-18$$ -Change name of $code OdeControl$$ to $cref OdeErrControl$$ -and improve its documentation. -$pre - -$$ -Correct the syntax for the $cref/Parameter and Variable/ParVar/$$ -functions. - - -$head 05-16$$ -Change $cref OdeErrControl$$ to have method return its order instead -of having a separate argument to $code OdeErrControl$$. -$pre - -$$ -Add the argument $icode scur$$ to $code OdeErrControl$$, -improve $code OdeErrControl$$ choice of step size and documentation. - - -$head 05-12$$ -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 -to the $cref ad_binary$$ and $cref compound_assign$$ operators. - - -$head 05-06$$ -The documentation for -$cref SimpleVector$$ and $cref NearEqual$$ -were changed to use more syntax (what the user enters) -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$$ -documentation. -$pre - -$$ -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 -the $code TestMore/VecUnary.cpp$$ test. - - - -$head 05-01$$ -The doubly linked list was also removed from the $cref VecAD$$ -internal data structure because this method of coding is simpler -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 -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 -an AD object was destroyed. -In order to speed AD operations in general, -the internal data structure of an AD object has been changed so that -this list is no longer necessary (a tape id number is used in its place) -$pre - -$$ -During the process above, the function $cref/Variable/ParVar/$$ was added. - - -$head 04-20$$ -Add $cref/profiling/autotools/Profiling CppAD/$$ -to the speed tests. - -$head 04-19$$ -Remove an extra (not necessary) -semi-colon from the file $code cppad/local/Operator.h$$. - -$head 03-26$$ -The new routine $cref OdeErrControl$$ does -automatic step size control for the ODE solvers. - -$head 03-23$$ -The routine $cref Rosen34$$ is an improved stiff integration method -that has an optional error estimate in the calling sequence. -You must change all your calls to $code OdeImplicit$$ -to use $code Rosen34$$ (but do not need to change other arguments -because error estimate is optional). - -$head 03-22$$ -The routine $cref Runge45$$ is an improved Runge-Kutta method -that has an optional error estimate in the calling sequence. -You must change all your calls to $code OdeRunge$$ -to use $code Runge45$$ (but do not need to change other arguments -because error estimate is optional). - -$head 03-09$$ -Some extra semi-colons (empty statements) -were generating warnings on some compilers. -The ones that occurred after the macros -$code CppADStandardMathBinaryFun$$, -$code CppADCompareMember$$, -$code CppADBinaryMember$$, and -$code CppADFoldBinaryOperator$$ have been removed. - -$head 03-04$$ -An new multiple level of AD example $cref mul_level$$ was added. - -$head 03-01$$ -An option that specifies error and warning -$cref/flags/autotools/cxx_flags/$$ -for all the C++ compile commands, -was added to the -$cref/Unix installation instructions/autotools/$$. - - -$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 -left hand side for a previous equation. -$pre - -$$ -An extra requirement was added to the -$cref SimpleVector$$ template class. -There must be a typedef for $code value_type$$ -which is the type of elements in the vector -$pre - -$$ -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 -$href%mailto:Jean-Pierre.Dussault@Usherbrooke.ca%Jean-Pierre Dussault%$$). -This has been fixed. - -$head 01-08$$ -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 -has been removed. - - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_06.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_06.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_06.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_06.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,1205 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_06$$ -$spell - autotools - speedtest - apx - exp_eps - Alloc - fadbad - exp - Dir - Romberg - yyyymmdd - yy-mm-dd - Det - cppad - Adolc - Makefile - omh - config.h - Microsoft - hpp - valgrind memcheck - Kasper Kristensen - taylor - BAvector - fy - uninitialized - Tautschnig - resize - gcc - var - const - dw - VecADelem - atan - namespace - Cygwin - messaging - usr - aclocal - automake - autoconf - user - underquoted - Hes - Jac - CppAD - sed - gprof - Mul.h - Div.h - det_lu -$$ - -$section Changes and Additions to CppAD During 2006$$ -$mindex aclocal$$ - - -$head Introduction$$ -This section contains a list of the changes to CppAD during 2006 -(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-24$$ -Move $code exp_eps_ad$$ to $code exp_eps_cppad$$ and -add exercises to the following sections: -$cref exp_eps_rev1$$, -$cref exp_eps_cppad$$. -$pre - -$$ -Add operation sequence indices to help track operations in -$cref exp_eps_for0$$, -$cref exp_eps_for1$$, -$cref exp_eps_rev1$$. - -$head 12-23$$ -Add exercises to the following sections: -$cref get_started.cpp$$, -$cref exp_eps$$, -$cref exp_eps_for0$$, and -$cref exp_eps_for1$$. - -$head 12-22$$ -Move $cref get_started.cpp$$ below the $cref introduction$$ directory. -$pre - -$$ -Move the exponential example to the subdirectory -$code introduction/exp_apx$$ and change the -$code --with-Introduction$$ -unix configure option -to build both the $cref get_started.cpp$$ and $cref exp_apx.cpp$$ -example programs. -(The $code --with-GetStarted$$ configure command line option has been removed.) - -$head 12-21$$ -Add the $cref/source code for Poly/poly.hpp/$$ to the documentation -and include $cref Poly$$ in the in the $cref speed_utility$$ section. -$pre - -$$ -The $cref get_started.cpp$$ section has been moved -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$$. - - -$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 -following routines: -$cref det_by_minor$$, -$cref det_grad_33$$, -$cref uniform_01$$, -$cref det_of_minor$$, -$cref det_by_lu$$, -$cref LuInvert$$, -$cref LuFactor$$, -$cref LuSolve$$. -$pre - -$$ -Separate the specifications for the source in -$cref speed_utility$$ and add cross reference to the following routine -specification and implementations: -$cref det_by_minor$$, -$cref det_grad_33$$, -$cref uniform_01$$, -$cref det_of_minor$$, -$cref det_by_lu$$, -$cref LuInvert$$, -$cref LuFactor$$, -$cref LuSolve$$. - - -$head 12-18$$ -Make the $cref speed$$ source code easier to read. -$pre - -$$ -Change the speed test output name $code det_poly$$ to $code poly$$ -(as it should have been). - -$head 12-17$$ -The speed test $cref det_grad_33$$ was missing its documentation -(this has been fixed). -In addition, the titles and indexing for the speed test documentation -has been improved. -$pre - -$$ -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/$$. -In addition, modify all the speed tests so that they abide by this rule. -$pre - -$$ -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 -matrix in the test. -$pre - -$$ -Add the $cref/poly/link_poly/$$ speed test for all three packages. -In addition, correct a missing include in $cref poly$$ routine. - - -$head 12-15$$ -The wish list item -to simplify and better organize the speed tests been completed: -$table -$cref|speed/|speed|$$ - $cnext template functions that are speed tested $rnext -$code speed/example$$ - $cnext example usage of speed template functions $rnext -$cref|speed/adolc|speed_adolc|$$ - $cnext Adolc drivers for the template functions $rnext -$cref|speed/cppad|speed_cppad|$$ - $cnext CppAD drivers for the template functions $rnext -$cref|speed/fadbad|speed_fadbad|$$ - $cnext Fadbad drivers for the template functions $rnext -$cref|speed/profile|autotools|Profiling CppAD|$$ - $cnext profiling version of CppAD drivers -$tend - - -$head 12-13$$ -Next step for the speed wish list item: -remove $code speed_cppad$$ from the documentation and replace it by -$code speed/cppad$$, see $cref speed_cppad$$ for the new CppAD speed -test routines. - -$head 12-12$$ -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 -creating the $code speed/example$$ directory and moving the relevant -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%speed/%*%.hpp%$$. -$pre - -$$ -A new $cref speed_test$$ routine was added to the library. - - -$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 -$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. -The $cref pow$$ documentation was improved -and the $cref pow.cpp$$ example was changed to -test more cases and to use the same variable -names as in the documentation. - -$head 12-09$$ -A speed wish list item was added to the wish list. -$pre - -$$ -The prototype for $code int$$ arguments in binary operations -(for example $cref/addition/ad_binary/$$) was documented as -$syntax const int &$$ but was actually just plain $code int$$. -This has been fixed. -(Later changed to $code double$$.) - -$head 12-07$$ -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 -had an improper license statement in the GPL license version. -This has been fixed. - -$head 12-05$$ -Add the unix installation -$cref/--with-Documentation/autotools/--with-Documentation/$$ option -and remove the -$icode postfix_dir$$ option. -$pre - -$$ -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 -lower case; i.e., $code cppad$$. -If you are using a Unix system, see $cref include_deprecated$$. -This completes the following $cref wish_list$$ items (which were removed): - -$list number$$ -File and directory names should only contain lowercase letters, -numbers underscores and possibly one period. -The leading character must be alphabetic. - -$lnext -C++ header files should have the $code .hpp$$ extension. - -$lend - - -$head 12-02$$ -Put explanation of version numbering in the -download instructions. -$pre - -$$ -Correct some file name references under the Windows heading in -$cref speed_cppad$$. - -$head 12-01$$ -All of the $code Makefile.am$$ and $code Makefile$$ files were changed -to lower case; i.e., $code makefile.am$$ and $code makefile$$. -$pre - -$$ -Fix compiler warning while compiling $code cppad/RombergOne/$$ -(mistake occurred during $cref/11-20/whats_new_06/11-29/$$ change). - -$head 11-30$$ -Cygwin packages, and other system packages, -should not have a dash in the version number. -See -$href% - http://cygwin.com/setup.html#naming% - cygwin package file naming -%$$ -or, to quote the -$href% - http://www.rpm.org/max-rpm/ch-rpm-file-format.html% - rpm file naming convention -%$$ -$italic -The only restriction placed on the version is that -it cannot contain a dash "-". -$$ -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$$. - -$head 11-29$$ -There was a problem using $cref RombergOne$$ with floating point -types other than $code double$$. This has been fixed. - -$head 11-28$$ -The $cref/installation/Install/$$ download files were not being built -because $code Makefile.am$$ referenced $code Doc$$ when it should have -referenced $code doc$$. This has been fixed. - -$head 11-23$$ -A Version Numbering entry was added to the -$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 -by minors $code DetOfMinor$$ was changed to $cref det_of_minor$$, -in preparation for -more formal speed comparisons with other packages. -To be specific, its documentation was improved, -its dependence on the rest of CppAD was removed -(it no longer includes $cref/CppAD.h/cppad/$$). - - -$head 11-12$$ -The -$cref general.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 -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. - -$head 11-06$$ -Move the $code TestMore$$ directory to $code test_more$$ -and change all its files to use lower case names. - - -$head 11-05$$ -Remove references in the $cref speed_cppad$$ tests to the -$code Memory$$ and $code Size$$ functions because they -have been $cref/deprecated/FunDeprecated/$$. -$pre - -$$ -Correct some references to $code var_size$$ that should have been -$cref/size_var/seq_property/size_var/$$. - -$head 11-04$$ -Put text written to standard output in the documentation for the -$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 -$code speedtest.cpp$$ examples were missing in $cref ListAllExamples$$ -(which has been fixed). -$pre - -$$ -Move the $code Speed$$ directory to $code speed$$ -and change all its files to use lower case names. - -$head 11-02$$ -The $code print_for$$ directory was referenced as $code PrintFor$$ -in the root CppAD $code Makefile.am$$ this has been fixed. -$pre - -$$ -The documentation for the Adolc helper routines -$code AllocVec$$ and $code AllocMat$$ were not being included. -This has been fixed. -$pre - -$$ -Move the $code GetStarted$$ directory to $code get_started$$ -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. - -$head 10-31$$ -Move the $code SpeedExample$$ directory to $code speed_cppad_example$$ -and change all its files to use lower case names. - -$head 10-29$$ -Move the $code Adolc$$ directory to $code adolc$$ -and change all its files to use lower case names. -$pre - -$$ -Change all the file in the $code omh$$ directory to -use lower case names. -$pre - -$$ -The file $code Makefile.am$$ in the distribution directory had the -CPL copyright message in the GPL version. This has been fixed. - -$head 10-28$$ -The copyright message in the script files -$code example/OneTest$$ and $code TestMore/OneTest$$ were GPL -(in the CPL distribution). -This has been fixed by moving them to -$code example/OneTest.sh$$ and $code TestMore/OneTest.sh$$ so that -the distribution automatically edits the copyright message. - - -$head 10-27$$ -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 -$cref Independent$$ and the $codei%ADFun<%Base%>%$$ -$cref/constructor/FunConstruct/$$. - -$head 10-25$$ -A subversion install procedure was -added to the documentation. -$pre - -$$ -Fix definition of preprocessor symbol -$code PACKAGE_STRING$$ in $code Speed/Speed.cpp$$ -(broken by change on 10-18). -$pre - -$$ -Added the example -$cref hes_lagrangian.cpp$$ which computes the Hessian -of a Lagrangian. - -$head 10-18$$ -Document and fix possible conflicts for -$cref/preprocessor symbols/preprocessor/$$ -that do not begin with $code CppAD$$ or $code CPPAD_$$. -$pre - -$$ -Include a default value for the file $code cppad/config.h$$ -in the subversion repository. - -$head 10-16$$ -Fix bug when using $cref OdeErrControl$$ with the type -$code AD< AD >$$. - - -$head 10-10$$ -Add the $cref Var2Par$$ function so it is possible -to obtain the $cref Value$$ of a variable. -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). - -$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 -get the nightly build changed: -$list number$$ -Change shell scripts to use *.sh extension. -$lnext -Two versions, one with CPL and other with GPL license. -$lnext -Change subversion version of CppAD from GPL to CPL copyright. -$lnext -Change all files in cppad/local to use lower case and *.hpp extension. -$lnext -CppAD_vector.h was generating a warning on version 4 of gcc. -This have been fixed. -$lnext -Change the preprocessor $code # define$$ commands -in $code cppad/local/*.hpp$$ to use upper case names. -$lnext -Add the $cref stack_machine.cpp$$ example. -$lend - -$head 08-17$$ -Some error message occurred while executing -$codep - valgrind --tool=memcheck example/example - valgrind --tool=memcheck TestMore/TestMore - -$$ -These were not really bugs, but they have been fixed to avoid -this conflict between CppAD and $href%http://valgrind.org/%valgrind%$$. - -$head 07-14$$ -Make some improvements were made to the $cref Introduction$$, -$cref exp_eps.hpp$$ and $cref exp_eps_rev1$$ sections. - -$head 07-12$$ -Use a drop down menu for the navigation links, instead of a separate frame -for the navigation links, for each section in the documentation. - -$head 06-29$$ -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. - -$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 -$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 -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 wish_list$$: -$pre - -$$ -"We would like to be able to erase the function -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 -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 -$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 -$code ADFun$$ pointers together with $code new$$ -and $code delete$$. - -$comment ----------------------------------------------------------- $$ - -$head 06-17$$ -The location where the distribution files are stored has changed -and this broke the Download Current Version links for the -unix and windows installation. -This has been fixed. -$pre - -$$ -The compiling instructions for the $cref speed_cppad$$ routines have been improved. -$pre - -$$ -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 - -$$ -The $cref BenderQuad$$ documentation and example have been improved -by changing $icode Vector$$ to $icode BAvector$$ to emphasize that -it corresponds to a vector of $icode Base$$ objects. - - -$head 06-15$$ -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 -$cref/function value argument, g/BenderQuad/g/$$ in $code BenderQuad$$. - -$head 06-07$$ -Some major changes were made to the notation in -$cref get_started.cpp$$ (to make it easier to start using CppAD). -$pre - -$$ -In the $cref Introduction$$ example, -$latex exp_eps$$ was changed to $latex {\rm exp\_eps}$$. - -$head 06-05$$ -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, -$icode%fun%.fy%$$ was changed to $icode%fun%.h%$$. - -$head 06-02$$ -Newer versions of the gcc compiler generated a warning for possible -use of an uninitialized pointer. -This was found by Michael Tautschnig and his fix has been -included in the CppAD distribution. - - -$head 05-31$$ -The interface to $cref BenderQuad$$ has been changed. -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 -be in the same browser frame as the command documentation -(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 -follow another link to see to the command syntax. - -$head 05-27$$ -Added $cref BenderQuad$$ for computing the Hessian of -Bender's reduced objective function. -$pre - -$$ -Added special specifications for $code resize(0)$$ -to $cref CppAD_vector$$. - -$head 05-03$$ -The g++ (GCC) 4.1.0 (Red Hat 4.1.0-3) compiler reported an error -because certain functions were used before being defined -(version 3.4.4 did not complain about this). -This has been fixed. - -$head 04-29$$ -Change all of the example and test driver programs so that they return -error codes; i.e., zero for no error and one for an error. -$pre - -$$ -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 -it so that it is visible at the too level of the documentation. - -$head 04-26$$ -The programs in $cref Introduction$$ have been converted to automated -test that return true or false with the driver program -$cref/Introduction/exp_apx.cpp/$$. - -$head 04-25$$ -Add an $cref Introduction$$ section to the documentation -(replaces old example that was part of the $cref Theory$$ section). - -$head 04-19$$ -A discussion was added near the end of the $cref FunCheck$$ documentation. -And the cross references to the $cref CompareChange$$ discussion -were changed to the FunCheck discussion. -$pre - -$$ -An operation sequence entry was added to the $cref wish_list$$. - -$head 04-18$$ -The new definitions for -$cref/AD of Base/glossary/AD of Base/$$ -and -$cref/operation sequence/glossary/Operation/Sequence/$$ -have been used throughout the documentation. -$pre - -$$ -Add the $cref FunCheck$$ section for checking that a sequence of -operations is as intended. - - -$head 04-17$$ -The documentation for $cref SpeedTest$$ and $cref Poly$$ was improved. -$pre - -$$ -Definitions were added for an atomic $cref/operation/glossary/Operation/$$ -and for an operation sequence being -dependent and independent of the values of specific operands. -$pre - -$$ -The definition of AD sequence of operations was made abstract -and moved to the glossary as -$cref/Type operation sequence/glossary/Operation/Sequence/$$. - -$head 04-15$$ -The $cref mul_level$$ example was moved from -$cref ADFun$$ to $cref General$$. -The documentation for $cref SpeedTest$$ was improved. - -$head 04-14$$ -Documentation and examples were improved for the following routines: -$cref ForTwo$$, -$cref RevTwo$$. -In addition, the computation in $code RevTwo$$ was made more efficient -(it used to possibly calculate some first order partials that were not used). - -$head 04-13$$ -Documentation and examples were improved for the following routines: -$cref Jacobian$$, -$cref ForOne$$, -$cref RevOne$$, -and $cref Hessian$$. - - -$head 04-08$$ -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 -(because it only applies to the current $cref forward_zero$$). -$pre - -$$ -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 -$codep - VecAD V(1); - AD zero = 0; - V[zero] = 1.; - static_cast< AD > ( V[zero] ); -$$ - - - - - -$head 04-06$$ -The $cref ForSparseJac$$, $cref RevSparseJac$$, $cref RevSparseHes$$ -sparsity results are now valid for -all independent variable values -(if the AD operation sequence does no use any -$codei%VecAD<%Base%>%$$ operands). -In addition, the -$code ForSparseJac$$, $cref RevSparseJac$$ and $cref RevSparseHes$$ -documentation and examples were improved. -$pre - -$$ -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 -$cref/04-03/whats_new_06/04-03/$$). - - -$head 04-05$$ -The documentation and example for $cref CompareChange$$ were -improved and moved to be part of the $cref Forward$$ section. - -$head 04-04$$ -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 -$cref/zero/forward_zero/$$ and $cref forward_one$$ first order case -of $cref Forward$$ mode. -$pre - -$$ -The ADFun $cref/Size/FunDeprecated/Size/$$ member function -has been deprecated (use $cref size_order$$ instead). -$pre - -$$ -The $cref Reverse$$ member function is now declared, -and documented as, $code const$$; i.e., -it does not effect the state of the ADFun object. -$pre - -$$ -Change the examples that use $cref Reverse$$ to use the same -return value notation as the documentation; i.e., $code dw$$. - -$head 04-02$$ -The member functions of $cref ADFun$$ that return properties of -AD of $icode Base$$ -$cref/operation sequence/glossary/Operation/Sequence/$$ -have been grouped into the $cref seq_property$$ section. -In addition, the $cref seq_property.cpp$$ example has been added. -$pre - -$$ -The $cref CompareChange$$ function documentation was improved -and moved to a separate section. -$pre - -$$ -Group the documentation for the $cref ADFun$$ member functions that -evaluate functions and derivative values. -This organization has since been changed. -$pre - -$$ -Remove the old $code Fun.cpp$$ example and extend -$cref independent.cpp$$ so that it demonstrates using different -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$$ -for its example. -$pre - -$$ -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. -The request was implemented on $cref/06-19/whats_new_06/06-19/$$ -and the entry was removed from the wish list. - -$head 03-31$$ -Add examples for the $cref/Parameter, Variable/ParVar/$$ and -$cref Independent$$ functions. -$pre - -$$ -Move the $cref/Parameter and Variable/ParVar/$$ functions from -the $cref ADFun$$ section to the $cref AD$$ section. -$pre - -$$ -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 -$cref/variables/glossary/Variable/$$. - -$head 03-30$$ -Move the $cref LuRatio$$ section below $cref LuDetAndSolve$$. -$pre - -$$ -Move the definition of an -AD of $icode Base$$ -$cref/operation sequence/glossary/Operation/Sequence/$$ -from the glossary to the $cref AD$$ section. -$pre - -$$ -Improve the definition of tape state. -$pre - -$$ -Add mention of taping to -$cref Erf$$, $cref BoolFun$$, $cref NearEqualExt$$,and $cref Pow$$. -$pre - -$$ -Change the definition for -$cref/VecAD::reference/VecAD/VecAD::reference/$$ -so that it stands out of the text better. - - -$head 03-29$$ -Mention the $cref/VecAD::reference/VecAD/VecAD::reference/$$ case in -documentation and examples for -$cref abs$$, $cref atan2$$, $cref erf$$, and $cref pow$$. -$pre - -$$ -Fix a bug derivative computation for $codei%abs(%x%)%$$ -when $icode x$$ had type $codei%AD< AD >%$$ and $icode x$$ -had value zero. -$pre - -$$ -Fix a bug using non-zero AD indices for $cref VecAD$$ vectors -while the tape is in the empty state. -$pre - -$$ -Extend $cref erf$$ to include $code float$$, $code double$$, -and $codei%VecAD<%Base%>::reference%$$. - -$head 03-28$$ -Mention the -$cref/VecAD::reference/VecAD/VecAD::reference/$$ case in -documentation and examples for -$cref UnaryPlus$$, -$cref UnaryMinus$$, -$cref ad_binary$$, -$cref compound_assign$$, and -$cref unary_standard_math$$ - - -$head 03-27$$ -Extend and improve the -$cref/VecAD exceptions/VecAD/VecAD::reference/Exceptions/$$. -$pre - -$$ -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%>%$$ -(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 -$cref Value$$, $cref ad_output$$ and $cref/assignment/ad_assign/$$ documentation -and examples. -$pre - -$$ -Extend $cref Integer$$ and $cref PrintFor$$ to include the -$cref/VecAD::reference/VecAD/VecAD::reference/$$ case -(and mention in documentation and examples). - - -$head 03-24$$ -Move $cref VecAD$$ and $cref LuRatio$$ from the old ExtendDomain section -to $cref AD$$. - -$head 03-23$$ -Improve documentation and examples for -$cref CondExp$$ and $cref Discrete$$. -Move both of these sections from ExtendDomain to $cref ADValued$$. - -$head 03-22$$ -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$$ -in the documentation have been organized into subgroups. - -$head 03-17$$ -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 -$cref pow_int$$. -$pre - -$$ -The copies of the $code atan2$$ function were included -in the CppAD namespace for the -$code float$$ and $code double$$ types. - -$head 03-15$$ -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 -(except under Cygwin which is not really case sensitive). -This has been fixed. -$pre - -$$ -The term AD of $icode Base$$ -$cref/operation sequence/glossary/Operation/Sequence/$$ -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 unary_standard_math$$ have -been grouped under $code MathOther$$. -$pre - -$$ -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$$, -$cref log10.cpp$$, -$cref sin.cpp$$, -$cref sinh.cpp$$, -$cref sqrt.cpp$$ -have been improved. - -$head 03-07$$ -The $code tan$$ function has been added to CppAD. -$pre - -$$ -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 unary_standard_math$$. - -$head 02-28$$ -The $cref ad_output$$ and $cref Abs$$ -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. - -$head 02-24$$ -The documentation and examples have been improved for the following sections: -$cref/division/ad_binary/$$, $cref/-=/compound_assign/$$, $cref/*=/compound_assign/$$, and $cref%/=%compound_assign%$$. - -$head 02-23$$ -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. -$pre - -$$ -There was a bug $cref RevTwo$$ that was not detected by the -$cref rev_two.cpp$$ test. This bug was reported by -$href% - http://list.coin-or.org/pipermail/cppad/2006-February/000020.html% - Kasper Kristensen -%$$ -A test was added $code TestMore/rev_two.cpp$$ that detects this problem -and the problem has been fixed. - - -$head 02-15$$ -The $cref/+=/compound_assign/$$ documentation and example have been improved. - -$head 02-14$$ -The $cref/addition/ad_binary/$$ documentation and example have been improved. - - -$head 02-13$$ -Combine the old binary operator and compound assignment documentation -into $cref Arithmetic$$ documentation. -$pre - -$$ -The documentation and examples have been improved for the following sections: -$cref/assignment/ad_assign/$$, $cref UnaryPlus$$, $xref UnaryMinus$$. - -$head 02-11$$ -The documentation and examples have been improved for the following sections: -$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/$$ -(formerly Copy) documentation has been modified. -$pre - -$$ -Some of the error messaging during $cref ADFun$$ construction -has been improved. - -$head 02-04$$ -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 -$code CppAD::vector$$. -$pre - -$$ -The routines $cref Runge45$$ and $cref Rosen34$$ -had static vectors to avoid recalculation on each call. -These have been changed to be plain vectors to avoid memory -leak detection by $cref/TrackCount/TrackNewDel/TrackCount/$$. - -$head 01-20$$ -Add -$cref/software guidelines/wish_list/Software Guidelines/$$ -to the wish list. - -$head 01-18$$ -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$$ -The aclocal program is part of the automake and autoconf system. -It often generates warnings of the form: -$codei% - /usr/share/aclocal/%...%: warning: underquoted definition of - %...% -%$$ -The shell script file $code FixAclocal$$, -which attempts to fix these warnings, -was added to the distribution. - -$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/utility/error_handler.hpp%ErrorHandler%$$. -The macros $code CppADUnknownError$$ and $code CppADUsageError$$ -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/autotools/Profiling CppAD/$$ output. -$pre - -$$ -Make the following source code files easier to understand: -$code Add.h$$, $code Sub.h$$, $code Mul.h$$, $code Div.h$$ -(in the directory $code cppad/local$$). - -$head 01-05$$ -Make the following source code files easier to understand: -$code RevSparseHes.h$$, -$code Reverse.h$$, -$code Fun.h$$, -$code Forward.h$$, -$code ForSparseJac.h$$, -$code RevSparseJac.h$$ -(in the directory $code cppad/local$$). - - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_07.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_07.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_07.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_07.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,969 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_07$$ -$spell - autotools - mul - cxx - omh - tgz - yyyymmdd - isnan - gcc - executables - makefiles - tarballs - autoconf - Fadbad - Sacado::Tay - Dir - Ginac - xi - Bool - CppADvector - inv - namespace - det_lu - adouble - Adolc - op - sqrt - eps - mega - Kipp - vcproj - exp_apx - Microsoft - threadprivate - gettimeofday - ifndef - Vec - openmp - dy - automake - makefile - CppAD - cygwin - cppad.hpp - config.h - dd - Adolc - Taylor -$$ - -$section Changes and Additions to CppAD During 2007$$ - - -$head Introduction$$ -This section contains a list of the changes to CppAD during 2007 -(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$$ -License conversions missed the copyright message at the top -in the following special cases: -$code makefile.am$$, $code makefile.in$$, and -$code omh/appendix/license.omh$$. - - -$head 12-25$$ -The $cref install$$ instructions have been improved. - -$head 12-21$$ -The $cref/--with-Documentation/autotools/--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. - -$head 12-08$$ -By mistake, the documentation $cref License$$ statement -for the GPL distribution was the same as for the CPL distribution. -This has been fixed. - -$head 12-05$$ -Change the name of the spec file from -$codei%cppad-%yyyymmdd%.spec%$$ to $code cppad.spec$$. - -$head 12-04$$ -Add the capability for the RPM spec file to use a different -prefix directory. - -$head 12-03$$ -This is the first version with the rpm spec file -$code cppad.spec$$. - -$head 12-02$$ -Add the $codei%DESTDIR=%directory%$$ option on the -$cref/make install/autotools/make install/$$ command line. - -$head 11-29$$ -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$$ -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. - -$head 11-18$$ -Speed tests for $code tape_values$$ branch were not better than trunk, -so the good parts of that branch (but not all) were merged into the trunk. -$pre - -$$ -The interface specifications for -$cref/base type requirements/base_require/$$ have been changed so that -CppAD would compile with $code gcc 4.1.1$$ -(which requires more definitions before use in template functions). -This changed of requirements is demonstrated by the -$cref base_complex.hpp$$ and $cref base_adolc.hpp$$ examples. -$pre - -$$ -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; -see $cref base_std_math$$. -$pre - -$$ -The $code example/test_one.sh$$ and $code test_more/test_one.sh$$ -scripts were modified so that one only need specify the test file name -(does not also need the test routine name). Some of the test routine -declarations were changed from $icode/name/()/$$ to -$icode/name/(void)/$$ to make this possible. -$pre - -$$ -The program $code test_more/test_more$$ was changed to always -report the memory leak test results (same as $code example/example$$). -$pre - -$$ -The $cref PrintFor$$ function was putting an unused variable in the tape. -This has been fixed. - - - -$head 11-06$$ -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. - -$head 11-05$$ -MS project files have been added for running the -$cref/cppad/speed_cppad/$$ and -$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 Windows project's could not find a certain include file. -This has been fixed. -$pre - -$$ -The $cref/unix install/autotools/$$ procedure has been modified -so that the one configure flag -$code --with-Speed$$ -builds all the possible executables related to the speed testing. - -$head 11-03$$ -Improve the $cref speed_main$$ documentation and output -(as well as the title for other sections under $cref speed$$). -$pre - -$$ -The subversion copy of the $cref/configure/autotools/Configure/$$ script -was not executable. -This has been fixed. - -$head 11-02$$ -The instructions for downloading the current version using -$code subversion$$ have changed. -The user should now directly edit the file -$codep - trunk/configure -$$ -in order to set the correct date for the installation -and to build the corresponding documentation. -$pre - -$$ -The $cref speed$$ section has been slightly reorganized -(the main program and utilities have been separated). -$pre - -$$ -Add $cref speed_double$$ for testing the speed of evaluating -functions in $code double$$ as apposed to gradients using AD types. - -$head 11-01$$ -The instructions for downloading the current version using subversion -have changed. -The user must now execute the command -$codep - ./build.sh version -$$ -in order to set the correct version number for her (or his) installation. -$pre - -$$ -Add the return status for all the correctness tests -to the documentation; see $code make test$$. - -$head 10-30$$ -The download instructions did not update current version number -and this broke the links to the current tarballs. -This has been fixed. -$pre - -$$ -The documentation for $cref det_by_minor$$ and $cref det_by_lu$$ -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). -$pre - -$$ -The makefiles in the distribution have been changed so that -one can run configure from a directory other than the distribution directory. - -$head 10-27$$ -A $code subversion$$ method -for downloading CppAD has been added. -$pre - -$$ -The installation was broken on some systems because the -$cref/configure/autotools/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 -$code subversion$$ -methods to include a full installation and old versions. - -$head 10-23$$ -The $cref/cxx_flags/autotools/cxx_flags/$$ environment variable -has been changed from $code CPP_ERROR_WARN$$ to $code CXX_FLAGS$$. -$pre - -$$ -The command $code configure --help$$ now prints a description -of the environment variables -$code ADOLC_DIR$$, -$code FADBAD_DIR$$, -$code SACADO_DIR$$, -$code BOOST_DIR$$, -and -$code CXX_FLAGS$$. -In addition, if the environment variables -$code POSTFIX_DIR$$ or $code CPP_ERROR_WARN$$ are used, -an message is printed saying that are not longer valid. - - -$head 10-22$$ -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 -$codei%compute_%test_name%$$ to be the same for all packages. -$pre - -$$ -The $href%http://trilinos.sandia.gov/packages/sacado/%Sacado%$$ -package was added to the list of $cref speed$$ tests. -In addition, the discussion about how to run each of the -speed tests was corrected to include the $icode seed$$ argument. -$pre - -$$ -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/autotools/Configure/$$ -documentation. -This has been fixed. -$pre - -$$ -The routine $cref CheckSimpleVector$$ was changed. -It used to require conversion of the form -$codei% - %Scalar%(%i%) -%$$ -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 -(see $cref/restrictions/CheckSimpleVector/Restrictions/$$) -to support of -$codei% - %x% = %i% -%$$ -where $icode x$$ has type $icode Scalar$$ -and $icode i$$ has type $code int$$. -$pre - -$$ -Fix include directives in $cref speed_fadbad$$ programs -$code det_lu$$, $code det_minor$$, and $code poly$$, -to use $code FADBAD++$$ instead of $code Fadbad++$$ directory. -$pre - -$$ -Add $code ADOLC_DIR$$, $code FADBAD_DIR$$, $code SACADO_DIR$$, -and $code BOOST_DIR$$ -to the $cref/configure/autotools/Configure/$$ help string. - - -$head 10-16$$ -Add $icode seed$$ argument and -improve $cref speed_main$$ documentation. - -$head 10-13$$ -Fix the title in $cref adolc_det_lu.cpp$$. -Add the package name to each test case result printed by -$cref speed_main$$. - -$head 10-05$$ -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$$ -Extend the $cref pow$$ function to work for any case where one argument -is $codei%AD<%Base%>%$$ and the other is $code double$$ -(as do the binary operators). - -$head 09-06$$ -If the $cref/method.step/OdeErrControl/Method/step/$$ function returned -$code nan$$ (not a number), -it was possible for $cref OdeErrControl$$ to drop into an infinite loop. -This has been fixed. - -$head 08-09$$ -Let user detect and handel the case where an ODE initial vector $icode xi$$ -contains not a number $code nan$$ -(see $cref Runge45$$, $cref Rosen34$$, and $cref OdeErrControl$$). -$pre - -$$ -Use the $code ||$$ operation instead of $code |$$ -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. -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 -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. -$pre - -$$ -Fix an $cref/Sequence Constructor/FunConstruct/Sequence Constructor/$$ -referenced to $code Dependent$$ in documentation -(was using the $cref FunDeprecated$$ one argument syntax). -$pre - -$$ -Add comment about mixing debug and non-debug versions of -CppAD in $cref/TrackDelVec/TrackNewDel/TrackDelVec/$$ error message. - - -$head 07-30$$ -$code CppADCreateBinaryBool$$ and $code CppADCreateUnaryBool$$ -have been replaced by $code CPPAD_BOOL_BINARY$$ and -$code CPPAD_BOOL_UNARY$$ respectively. -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 -$code CppADUsageError$$ and $code CppADUnknownError$$ -have been replaced by $code CPPAD_ASSERT_KNOWN$$ and -$code CPPAD_ASSERT_UNKNOWN$$ respectively. -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 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$$ -which has been deprecated. - -$head 07-26$$ -Merge in changes made in $code branches/test_vector$$. - -$subhead 07-26$$ -Change all occurrences of $code CppADvector$$, -in the files $codei%test_more/%*%.cpp%$$ and $codei%speed/%*%/%*%.cpp%$$, -where changed to $code CPPAD_TEST_VECTOR$$. -All occurrences of the $code CppADvector$$ in the documentation -were edited to reflect that fact that it has been deprecated. -The documentation index and search for -deprecated items has been improved. - -$subhead 07-25$$ -Deprecate the preprocessor symbol $code CppADvector$$ -and start changing it to -$small $cref/CPPAD_TEST_VECTOR/test_vector/$$ $$. -$pre - -$$ -Change all occurrences of $code CppADvector$$, -in the $codei%example/%*%.cpp%$$ files, -to $code CPPAD_TEST_VECTOR$$. - -$head 07-23$$ -The $cref TrackNewDel$$ macros -$code CppADTrackNewVec$$, -$code CppADTrackDelVec$$, and -$code CppADTrackExtend$$ have been deprecated. -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/wish_list/Software Guidelines/$$ -section of the wish list. -$pre - -$$ -The member variable -$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 sum_i_inv.cpp$$ -have been changed so that they run on more systems -(are C++ standard compliant). -$lnext -$cref base_require$$: -The $code IdenticalEqual$$ function, -in the $cref base_require$$ specification, -was changed to $code IdenticalEqualPar$$ -(note the $cref/API warning/base_require/API Warning/$$ in the -$icode Base$$ requirement specifications). -$lnext -Implementation of the $cref/base requirements/base_require/$$ for complex types -were moved into the $cref base_complex.hpp$$ example. -$lend - - - -$head 07-20$$ -The download for CppAD was still broken. -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 -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 -$code mul_level_adolc_ode.cpp$$ was added because the -$code example/example$$ program was failing. -This has been fixed. - -$head 07-18$$ -A realistic example using Adolc with CppAD -$cref mul_level_adolc_ode.cpp$$ was added. -The documentation for $cref TrackNewDel$$ was improved. - -$head 07-14$$ -Add a discussion at the beginning of -$cref mul_level_ode.cpp$$ example -(and improve the notation used in the example). - -$head 07-13$$ -Separate the include file -$cref base_adolc.hpp$$ -from the $cref mul_level_adolc.cpp$$ example -so that it can be used by other examples. - -$head 06-22$$ -Add $cref mul_level_adolc.cpp$$, an example that demonstrates using -$code adouble$$ and for the $cref/Base/base_require/$$ type. -$pre - -$$ -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/autotools/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. -$pre - -$$ -There was a namespace reference missing in the files -that could have caused compilation errors in the files -$code speed/cppad/det_minor.cpp$$ and -$code speed/cppad/det_lu.cpp$$. -This has been fixed. - -$head 06-20$$ -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 -$code test_more/test_more.cpp$$ file. -$pre - -$$ -Add a section defining the $cref/Base type requirements/base_require/$$. -Remove the $icode Base$$ type restrictions from the $cref Faq$$. -Make all the prototype for the default Base types agree with -the specifications in the Base type requirements. -$pre - -$$ -Fix the description of the $code tan$$ function in -$cref unary_standard_math$$. - - -$head 06-14$$ -The routine $cref Rosen34$$ ( $cref Runge45$$ ) had a division -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 -$code size_t$$ to an $code int$$, -then converting the $code int$$ to a $icode Scalar$$, -and then preforming the division. -(The conversion of an $code int$$ to any numeric type must be valid.) - -$head 05-26$$ -If the $icode Base$$ type is not $code double$$, -the $cref/compound assignment/compound_assign/$$ operators did not -always allow for $code double$$ operands. For example, -if $icode x$$ had type $code AD< AD >$$ -$codei% - %x% += .5; -%$$ -would slice the value $code .5$$ to an $code int$$ -and then convert it to an $code AD< AD >$$. -This has been fixed. -$pre - -$$ -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$$. - - -$head 05-25$$ -Document usage of $code double$$ with -binary arithmetic operators, -and combine all those operators into one section ($cref ad_binary$$). -$pre - -$$ -The documentation for all the $cref/compound assignment/compound_assign/$$ -operators has been grouped together. -In addition, a -compound assignment wish list item has been added -(it was completed and removed with the -$cref/05-26/whats_new_07/05-26/$$ update.) - - -$head 05-24$$ -Suppose that $icode op$$ is a binary operation and we have -$codei% - %left% %op% %right% -%$$ -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 -being converted to $code AD< AD >$$. -This has been fixed. - -$head 05-22$$ -The Microsoft -examples and testing -project file $code example/example.vcproj$$ -was missing a reference to the -source code file $code example/reverse_two.cpp$$. -This has been fixed. - -$head 05-08$$ -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 -is no longer deprecated (and is used by CppAD when the exponent -has type $code int$$). - - -$head 05-05$$ -Third and fourth order derivatives were included in the -routine $code test_more/sqrt.cpp$$ that tests square roots. -$pre - -$$ -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_eps_for1/exp_eps_for1/Return Value/$$, and -$cref/exp_eps_for2/exp_eps_for2/Return Value/$$. -$pre - -$$ -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 sqrt_reverse$$. -$pre - -$$ -The dimension for the notation $latex X$$ in -$cref reverse_identity$$ was corrected. -$pre - -$$ -The word mega was added to the spelling exception list for -$code openmp/run.sh$$. - -$head 04-19$$ -Improve connection from $cref reverse_identity$$ theorem -to $cref reverse_any$$ calculations. -$pre - -$$ -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. -$pre - -$$ -Add the $code sum_i_inv_time.cpp$$ OpenMP example case. -$pre - -$$ -There was a typo in the -$cref/second order/forward_order/Second Order/$$ discussion -(found by Kipp Martin). -It has been fixed. - - -$head 04-17$$ -Add a paragraph to $cref reverse_identity$$ explaining -how it relates to $cref reverse_any$$ calculations. -Add description of -$cref/first/reverse_any/First Order/$$ and -$cref/second order/reverse_any/Second Order/$$ -results in $cref reverse_any$$. - -$head 04-14$$ -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_checkpoint.cpp$$ for -reverse mode calculations. -$pre - -$$ -Improve the $cref reverse_identity$$ proof. - -$head 04-11$$ -Merge in changes made in $code branches/intro$$. - -$subhead 04-11$$ -Add $cref exp_eps_rev2$$ and its verification routine -$cref exp_eps_rev2.cpp$$. - -$subhead 04-10$$ -Finished off $cref exp_2_rev2$$ and -added $cref exp_2_rev2.cpp$$ which verifies its calculations. -Added second order calculations to $cref exp_2_cppad$$. -Added $cref exp_eps_for2$$ and its verification routine. - - -$subhead 04-07$$ -Added a preliminary version of $cref exp_2_rev2$$ -(does not yet have verification or exercises). - -$subhead 04-06$$ -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$$ -on 04-05). -$pre - -$$ -Added $cref exp_2_for2$$ to introduction. - -$subhead 04-05$$ -Use order expansions in introduction; e.g., the -$cref/second order expansion/exp_2_for2/Second Order Expansion/$$ -for the $cref exp_2$$ example. - -$head 03-31$$ -Merge in changes made in $code branches/intro$$ -and remove the corresponding Introduction item from the wish list: - -$subhead 03-31$$ -Create the a simpler exponential approximation in the $cref introduction$$ -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$$ -example). - -$subhead 03-30$$ -The Microsoft project file $code introduction/exp_apx/exp_apx.vcproj$$ -was referencing $code exp_apx_ad.cpp$$ which no longer exists. -It has been changed to reference $code exp_apx_cppad.cpp$$ -which is the new name for that file. - - -$head 03-29$$ -Fixed entries in this file where the year was mistakenly used for the month. -To be more specific, $codei%07-%dd%$$ was changed to $codei%03-%dd%$$ -for some of the entries directly below. -$pre - -$$ -Corrected some places where $code CppAD$$ was used in stead of $code Adolc$$ -in the $cref adolc_poly.cpp$$ documentation. -$pre - -$$ -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$$ -Example A.1.1c, $code example_a11c.cpp$$, -from the OpenMP 2.5 standards document, -was added to the tests that can be run using $code openmp/run.sh$$. - -$head 03-15$$ -Included the changes from openmp branch -so that so CppAD does not use the OpenMP $code threadprivate$$ command -(some systems do not support this command). - -$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. - -$subhead 03-14$$ -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 -the wrong setting of $code GETTIMEOFDAY$$. -The setting is now overridden (and always false) when the -$code _MSC_VER$$ preprocessor symbol is defined. -$pre - -$$ -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 -that does not use the OpenMP $code threadprivate$$ command -(not supported on some systems). - -$head 03-09$$ -Included the changes from openmp branch -so that OpenMP can be used with CppAD, -see $cref omp_max_thread$$. -The changes -dated between $cref/02-15/whats_new_07/03-09/02-15/$$ and 03-28 below -were made in the openmp branch and transferred to the trunk on 03-09. - - -$subhead 03-28$$ -The conditional include commands were missing on some include files; -for example -$codep - # 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. -$pre - -$$ -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 -which is better in a multi-threading environment). -$pre - -$$ -Added the user multi-threading interface -$cref omp_max_thread$$ along with its examples -which are distributed in the directory $code openmp$$. -$pre - -$$ -The $codei%speed/%*%.hpp%$$ files have been moved to -$codei%cppad/speed/%*%.hpp%$$ and the corresponding wish list -item has been removed. -$pre - -$$ -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. -A fix this wish list item has been added. -$pre - -$$ -Multiple active tapes required a lot of multi-threading access -management for the tapes. This was made simpler (and faster) -by having at most one tape per thread. - - -$subhead 02-22$$ -The include command in the $cref speed_test$$ documentation was -$codep - # include -$$ -but it should have been -$codep - # include -$$ -This has been fixed. - -$subhead 02-17$$ -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 -$cref/old Dependent syntax/FunDeprecated/Dependent/$$. - - -$subhead 02-16$$ -Added $codei%VecAD<%Base%>%$$ as a valid argument type for the -$cref/Parameter and Variable/ParVar/$$ functions. -In addition, $cref/size_t indexing/VecAD/size_t Indexing/$$ -is was extended to be allowed during taping so long as the -VecAD object is a parameter. - - -$subhead 02-15$$ -Fixed the $code example/test_one.sh$$ script -(it was using its old name $code one_test$$). - -$head 02-06$$ -The $cref BenderQuad$$ documentation was improved by adding the fact -that the $icode x$$ and $icode y$$ arguments to the $codei%f%.dy%$$ -member function are equal to the $icode x$$ and $icode y$$ arguments -to $code BenderQuad$$. Hence values depending on them can be stored -as private objects in $icode f$$ and need not be recalculated. - -$head 02-04$$ -The method for distributing the documentation needed to be -changed in the top level $code makefile.am$$ in order to -be compatible with automake version 1.10. - -$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. -This was not a bug, but it has been changed to avoid -an error message when using CppAD with -$href%http://valgrind.org/%valgrind%$$. -$pre - -$$ -The change to the $code pow$$ function on -$cref/06-12-10/whats_new_06/12-10/$$ did not include the -necessary changes to the sparsity calculations. -This has been fixed. - -$head 02-02$$ -Fix minor errors and improve -$cref/profiling/autotools/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 -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 -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. - -$end - diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_08.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_08.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_08.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_08.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,430 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_08$$ -$spell - autotools - dir - inline - tanh - erf - nlp - fg_vector - Bool - Ipopt - Jacobians - Jacobian - cygwin - retape - det - Adolc - gcc - speedtest - tarballs - cppad - cpl - gpl - tgz - Microsoft - op - CppAD - yum - vec - eval - const -$$ - -$section Changes and Additions to CppAD During 2008$$ -$mindex erf ipopt_cppad_nlp$$ - - -$head Introduction$$ -This section contains a list of the changes to CppAD during 2008 -(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-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 -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 -$code test_more$$ directory). - -$head 12-04$$ -Extensive explanation for the $code ipopt_cppad/ipopt_cppad_ode$$ example was -provided in the section $cref/ipopt_cppad_ode/ipopt_nlp_ode/$$. - -$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 -$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:%...%$$ -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 -these $code inline$$ directives are converted to -empty code when a Microsoft Visual C++ is used. - - -$head 11-20$$ -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 -$cref abs$$, $cref atan2$$, $cref LuRatio$$, $cref erf$$. -$pre - -$$ -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 -is differentiable at all points (not defined differently on subregions). -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 -to use $code const$$ (where appropriate). - -$head 10-17$$ -Major improvements to the $code ipopt_cppad/ipopt_cppad_ode$$ example. - -$head 10-16$$ -Minor improvement to description of optimization argument in -$code ipopt_cppad/ipopt_cppad_ode$$. - -$head 09-30$$ -Add or modify some wish list entries; see -$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). - - -$head 09-26$$ -Use parenthesis and brackets to group terms of the form -$latex m \times I$$ to make the documentation of -$cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$ easier to read. - -Changed $code ipopt_cppad/ipopt_cppad_ode$$ to use $latex y(t)$$ for -the solution of the ODE to distinguish it for $latex x$$, -the vector we are optimizing with respect to. - -$head 09-18$$ -Changed $code ipopt_cppad/ipopt_cppad_ode$$ to a case where $latex x(t)$$ -is a pair of exponential functions instead of a linear and quadratic. -Fixed some of the comments in this example and included the source -code in the documentation (which was missing by mistake). - -$head 09-17$$ -Changed $code ipopt_cppad/ipopt_cppad_ode$$ to a case where there are -two components in the ODE (instead of one). -Also removed an initialization section that was only intended for tests -with a specific initial value. - -$head 09-16$$ -Add $code ipopt_cppad/ipopt_cppad_ode$$, an example and test -that optimizes the solution of an ODE. -Change $code r_eval$$ to $code eval_r$$ in $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$. -Fix a dimension of $code u_ad$$ error in $code ipopt_cppad_nlp$$. - -$head 09-12$$ -Converted from storing full Hessian and Jacobian to a sparse data structure -in $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$. -This greatly reduced the memory requirements (and increased the speed) -for sparse problems. - -$head 09-10$$ -Fixed more indexing bugs in $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$ -that effected cases where the domain index vector $latex J_{k, \ell}$$ -was different for different values of $latex k$$ and $latex \ell$$. -$pre - -$$ -In $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$, -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). - -$head 09-09$$ -Fixed an indexing bug in $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$. -(This effected cases where the domain index vector $latex J_{k, \ell}$$ -was different for different values of $latex k$$ and $latex \ell$$.) - -$head 09-07$$ -Change $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$ so that object and constraints -are expressed as the double summation of simpler functions. -This is more versatile that the single summation representation. - -$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. -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 -multiple places in the $code ipopt_cppad/ipopt_cppad_nlp.cpp$$ source: -$codep - for(j = 0; j < n_; j++) -- x_ad_vec[0] = x[j]; -+ x_ad_vec[j] = x[j]; -$$ -This did not show up in testing because there currently is no test of -$code ipopt_cppad_nlp$$ where the operation sequence depends -on the value of $latex x$$. -$pre - -$$ -Changed $code eval_grad_f$$ in $code ipopt_cppad_nlp.cpp$$ -to be more efficient. - -$head 09-04$$ -The $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$ interface has been changed to use -a derived class object instead of a pointer to a function. - -$head 09-03$$ -The $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$ interface has been changed to use -$code size_t$$ instead of $code Ipopt::Index$$. - -$head 09-01$$ -Back out the changes made to $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$ on 08-29 -(because testing proved the change to be less efficient in the case -that motivated the change). - -$head 08-29$$ -The $code push_vector$$ member function was missing from the -$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$$ -had type $code vectorBool$$. -This has been fixed. -$pre - -$$ -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 -$cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$. -In the case where there is not a lot of common terms -between the functions, the scalar evaluation may be more efficient. - -$head 08-19$$ -Add $cref/push of a vector/CppAD_vector/push_vector/$$ -to the $code CppAD::vector$$ template class. -This makes it easy to accumulate multiple scalars and -$cref/simple vectors/SimpleVector/$$ into one large $code CppAD::vector$$. - -$head 08-08$$ -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 -$icode retape$$ documentation was added. - -$head 07-02$$ -Extend $cref/configure/autotools/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 -versions of CppAD. - -$head 06-15$$ -The nonlinear programming example $cref ipopt_nlp_get_started.cpp$$ was added. -This is a preliminary version of this example. - -$head 06-11$$ -The sparsity pattern for the Hessian was being calculated each time -by $cref/SparseHessian/sparse_hessian/$$. -This is not efficient -when the pattern does not change between calls to $code SparseHessian$$. -An optional sparsity pattern argument was added to $code SparseHessian$$ -so that it need not be recalculated each time. - -$head 06-10$$ -The sparsity pattern for the Jacobian was being calculated each time -by $cref/SparseJacobian/sparse_jacobian/$$. -This is not efficient -when the pattern does not change between calls to $code SparseJacobian$$. -An optional sparsity pattern argument was added to $code SparseJacobian$$ -so that it need not be recalculated each time. - -$head 05-08$$ -The $cref sparse_jacobian$$ routine has been added. -$pre - -$$ -The example in $cref sparse_hessian$$ pointed to $cref hessian.cpp$$ -instead of $cref sparse_hessian.cpp$$. -This has been fixed. - -$head 05-03$$ -The $code retape$$ flag has been added to $cref speed_main$$. -In addition the routines -$cref link_det_minor$$, $cref link_poly$$, and $cref link_ode$$ -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 following tests use this flag: -$cref adolc_det_minor.cpp$$, -$cref cppad_det_minor.cpp$$, -$cref cppad_ode.cpp$$, -$cref adolc_poly.cpp$$, -$cref cppad_poly.cpp$$. -$pre - -$$ -Create specialized zero order forward mode routine that should be faster, -but does not test out as faster under cygwin g++ (GCC) 3.4.4. - - - - -$head 04-20$$ -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$$ -cases; see $cref speed_main$$. -In addition, -added the examples $cref ode_evaluate.cpp$$ and $cref sparse_hessian.cpp$$. -$pre - -$$ -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 -$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 -speed and correctness tests (now available). - - -$head 04-10$$ -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 -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/wish_list/$$ -entry has been completed and removed from the list: -"Change private member variables names -(not part of the user interface) -so that they all end with an underscore." - -$head 04-04$$ -Fix a problem compiling the speed test -$cref/main/speed_main/$$ program with gcc 4.3. - -$head 03-27$$ -Corrected $cref cppad_sparse_hessian.cpp$$ -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). -$pre - -$$ -Change the name of $code speedtest.cpp$$ to $cref speed_program.cpp$$. - - -$head 02-05$$ -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 -$code speed/cppad$$, $code speed/double$$, and $code speed/example$$ -were missing. This has also been fixed. - -$head 02-03$$ -There was an ambiguity problem -(detected by g++ 4.3) with the following operations -$codei% - %x% %op% %y% -%$$ -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$$. -$pre - -$$ -Remove compound assignment entry from wish list -(it was fixed on $cref/2007-05-26/whats_new_07/05-26/$$). -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 -when the input matrix had not a number or infinity in it. -This has been fixed. - -$head 01-24$$ -The $cref/postfix_dir/autotools/postfix_dir/$$ -has been added to the $code configure$$ command line options. - -$head 01-21$$ -A sparse Hessian case was added to the $cref speed$$ tests; see -$cref/sparse_hessian/link_sparse_hessian/$$. - -$head 01-20$$ -CppAD can now be installed using $code yum$$ on -$code Fedora$$ operating systems. - - -$head 01-11$$ -The CppAD correctness tests assume that machine epsilon is less -than $code 1e-13$$. A test for this has been added to the -$code test_more/test_more$$ program. - -$head 01-08$$ -Added a $cref sparse_hessian$$ routine and -extended $cref Hessian$$ to allow for a weight vector $icode w$$ -instead of just one component $icode l$$. - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_09.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_09.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_09.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_09.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,564 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_09$$ -$spell - autotools - openmp - arg - std - bool - Microsoft - retape - isnan - atan - asin - acos - sqrt - OMhelp - doxygen - exp_eps_apx - cos - tarball - IpIpoptApplication - IpoptDir - autoconf - automake - config - jacobian - valgrind - svn - Prev - CppAD - Adolc - cppad - hpp - op - pycppad - cond_exp - VecAD - Jacobians - Jac - Taylor -$$ - -$section Changes and Additions to CppAD During 2009$$ - - -$head Introduction$$ -This section contains a list of the changes to CppAD during 2009 -(in reverse order by date). -The purpose of this section is to -assist you in learning about changes between various versions of CppAD. -(Comments about developer documentation are only important if you are -trying to read and understand the CppAD source code.) - -$head 12-23$$ -The -$code ADFun$$ $cref/assignment operator/FunConstruct/Assignment Operator/$$ -was changed so that it now copies forward mode -Taylor coefficients and sparsity pattern information. -(This assignment operator was added on $cref/10-24/whats_new_09/10-24/$$.) -You can use $cref capacity_order$$ to delete the Taylor coefficients -before copying them. -Two new functions were added so that you can query and delete the -forward mode sparsity information; -see -$cref/size_forward_bool/ForSparseJac/f/size_forward_bool/$$ and -$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 -for forward and reverse mode computations of an optimized tape. - -$head 12-18$$ -It turns out that detection of a sequence of additions makes the optimization -longer. This was simplified and makes slightly faster by converting two -jointly recursive routines to one non-recursive routine that uses a -stack for the necessary information. -More work is planned to make this optimization faster. - -$head 12-12$$ -Detection of a sequence of additions that can be converted to one variable -during the $cref optimize$$ process. -This leads to a significant improvement in the tape size and speed. - -$head 12-04$$ -Change hash coding of parameter values as part of operators -during the $cref optimize$$ process. -This should leads to more detection and removal of duplicate operations. - -$head 12-02$$ -Fix minor grammatical error in the Purpose heading -for $cref/conditional expressions/CondExp/Purpose/$$. -$pre - -$$ -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. - -$head 11-28$$ -Fix bug in tape optimization with $cref VecAD$$ objects. - -$head 11-27$$ -Remove duplicate expressions for the commutative binary operators; i.e., -addition and multiplication. - -$head 11-26$$ -Improve $cref optimize$$ command so that it removes some duplicate -expressions from the tape (more of this is planned). - -$head 10-30$$ -Make program that check Ipopt ODE example correctness -a separate file $cref ipopt_nlp_ode_check.cpp$$ -Split out Ipopt driver for ODE example $cref ipopt_nlp_ode_run.hpp$$. -Add the speed testing problem $code ipopt_cppad/ipopt_ode_speed.cpp$$. - -$head 10-29$$ -Split out the -$cref/ode inverse problem/ipopt_nlp_ode_problem/$$, -$cref/its simple representation/ipopt_nlp_ode_simple/$$, -and -$cref/its fast representation/ipopt_nlp_ode_fast/$$, -as a separate files; to be specific, -$cref ipopt_nlp_ode_problem.hpp$$, -$cref ipopt_nlp_ode_simple.hpp$$, -$cref ipopt_nlp_ode_fast.hpp$$, -and -$cref ipopt_nlp_ode_check.cpp$$. - -$head 10-28$$ -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$$ -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 -function object. -The intention is that the two functions objects can do calculations in -parallel. -In addition, -CppAD now check for the $code ADFun$$ -$cref/copy constructor/FunConstruct/Copy Constructor/$$ -and generates an error message if it is used. - -$head 10-23$$ -The $cref sparse_hessian$$ routine was extended so the user can now choose -between vectors of sets and boolean vectors for representing -$cref/sparsity patterns/glossary/Sparsity Pattern/$$. - -$head 10-21$$ -The $cref CheckSimpleVector$$ function was extended so that -it can check simple vectors where the elements of the vector -can not be assigned to integer values. -This was done by adding the $cref/x, y/CheckSimpleVector/x, y/$$ -arguments to $code CheckSimpleVector$$. - -$head 10-16$$ -The $cref sparse_jacobian$$ routine was extended so the user can now choose -between vectors of sets and boolean vectors for representing -$cref/sparsity patterns/glossary/Sparsity Pattern/$$. - -$head 10-14$$ -The $icode packed$$ parameter for the sparsity routines -$cref ForSparseJac$$, $cref RevSparseJac$$, and $cref RevSparseHes$$ -(introduced on $cref/09-26/whats_new_09/09-26/$$) has been removed. -It has been replaced by changing the argument and return values -to be more versatile. -To be specific, they can now represent sparsity -using vectors of $code std::set$$ -instead of just as vectors of $code bool$$ -(see $cref/sparsity patterns/glossary/Sparsity Pattern/$$). - -$head 10-03$$ -The Microsoft Visual Studio project files for -examples and testing -and for -more correctness testing -were not including some new tests in their builds. -This has been fixed. - -$head 09-30$$ -Added the $cref cppad_sparse_jacobian.cpp$$ speed test -and increased the sizes used by $cref link_sparse_hessian$$. -Some mistakes were fixed in the documentation for speed tests -$cref link_sparse_hessian$$ and $cref sparse_hes_fun$$. - -$head 09-29$$ -The documentation definition of the function $latex H(x)$$ in -$cref RevSparseHes$$ was missing a factor of $latex R$$. -This has been fixed. - -$head 09-28$$ -Changed $cref RevSparseHes$$ so that it uses a sparse -representation when the corresponding call to -$cref ForSparseJac$$ used a sparse representation. -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. - -$head 09-26$$ -Added the $code packed$$ parameter to -$cref ForSparseJac$$ and $cref RevSparseJac$$. -If $icode packed$$ is false, -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. -The functions $code ForSparseJac$$ and $code RevSparseJac$$ -return packed representations. -The plan is to eventually provide new member functions that return -sparse representations. - -$head 09-20$$ -Fixed a bug in the $cref/Hessian Sparsity/RevSparseHes/$$ calculations -that included use of $cref VecAD$$ objects. - -$head 09-19$$ -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_pattern$$ calculations. -The result was that eight times the necessary memory was being used -during these calculations. This has been fixed. - - -$head 08-25$$ -Add $cref ad_fun.cpp$$ -an example of how to create your own interface to an $cref ADFun$$ object. - -$head 08-14$$ -Add $cref ad_in_c.cpp$$ -an example of how to link CppAD to other languages. - -$head 08_13$$ -Add an option to $cref optimize$$ an operation sequence. -$pre - -$$ -$bold Begin Merge$$ -$pre -$$ -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 -$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/$$ -is skipped when $code NDEBUG$$ is defined). -In addition, all of the $codei%speed/cppad/%*%.cpp%$$ tests -now check and use the speed test -$cref/optimize/speed_main/Global Options/optimize/$$ flag. - -$subhead 08-11$$ -Change the speed test $cref/main program/speed_main/$$ so -that it uses a list of options instead of a boolean flag for each option. -This will make it possible to add options in the future with out -having to change all the existing tests because the options are now -global variables instead of arguments to the speed test routines; for example, -see $code retape$$ speed test option. - -$subhead 08-10$$ -The routine for $cref/optimizing/optimize/$$ the operation sequence -has been added has been further tested using $code test_more/optimize.cpp$$. -Some bugs have been fix and the routine can -now be trusted to work correctly. -$pre - -$$ -The function -$cref/size_VecAD/seq_property/size_VecAD/$$ function was added -so that the user could see the $code VecAD$$ vectors -and elements corresponding to an operation sequence. - -$subhead 08-09$$ -A routine for $cref/optimizing/optimize/$$ the operation sequence -has been added. -This is a preliminary version and needs more testing before it can -be trusted to work correctly. -$pre -$$ -$bold End Merge$$ - - -$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 -$cref/size_par/seq_property/size_par/$$ was added -so that the user could see the number of parameters -corresponding to an operation sequence. - -$head 08-02$$ -Fix bug in new version of how $cref ForSparseJac$$ handles -$cref VecAD$$ objects. -$pre - -$$ -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 -$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. - -$head 07-31$$ -The $cref/forward/ForSparseJac/$$ and $cref/reverse/RevSparseJac/$$ -sparse Jacobian routines have been improved so the resulting sparsity -patterns are valid for all values of the independent variables -(even if you use $cref CondExp$$ or $cref VecAD$$). - -$head 07-26$$ -Convert developer documentation from -forward and reverse mode sweep routines from OMhelp to doxygen. - -$head 07-25$$ -Add developer documentation for $cref PrintFor$$ operations. - -$head 07-24$$ -Add developer documentation for $cref Discrete$$ operations. - -$head 07-23$$ -Add developer documentation for tape evaluation of $cref VecAD$$ store -operations. (a store operation changes the value of a VecAD element). -$pre - -$$ -Improve the $cref vec_ad.cpp$$ user example. - -$subhead 07-06$$ -Fixed a bug in second or higher order reverse mode calculations -that used $cref VecAD$$. -This bug was demonstrated by the test case $code SecondOrderReverse$$ -in the file $code test_more/vec_ad.cpp$$. -$pre - -$$ -Add developer documentation for tape evaluation of the -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 -introduced on 07-04 change. - -$head 07-04$$ -Add developer documentation for the -$cref CompareChange$$ operations during tape evaluation. -$pre - -$$ -$bold Begin Merge$$ -$pre -$$ -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 -$code branches/sweep$$. - -$subhead 07-04$$ -Fixed a bug in second or higher order reverse mode calculations -that included $cref/conditional expressions/CondExp/$$. -This bug was demonstrated by the test case $code SecondOrderReverse$$ -in the file $code test_more/cond_exp.cpp$$. -$pre - -$$ -A simpler and useful example was provided for -$cref/conditional expressions/CondExp/$$; -see $cref cond_exp.cpp$$. - - -$subhead 07-03$$ -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 -tape evaluation for power (exponentiation) operators. - -$subhead 07-01$$ -Fix an example indexing error in -$code introduction/exp_apx/exp_eps_for2.cpp$$ (found by valgrind). -$pre - -$$ -Add developer doxygen documentation of -tape evaluation for multiplication and division operators. - -$subhead 06-30$$ -Add developer doxygen documentation of -tape evaluation for addition and subtraction operators. - -$subhead 06-29$$ -Add developer doxygen documentation of -tape evaluation for sin, sinh, cos, and cosh. - -$subhead 06-28$$ -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. -This has been fixed. - -$head 06-22$$ -Fix compiler warnings during the $code openmp/run.sh$$ test. -$pre - -$$ -Changed $cref speed_example.cpp$$ to omit the $code speed_test$$ from -the correctness result. -In stead, a message is printed explaining that timing tests need -to be run without a lot of other demands on the system. - -$head 06-21$$ -The configure instructions for $cref/ipopt_dir/autotools/ipopt_dir/$$ -had the wrong path for $code IpIpoptApplication.hpp$$. -This has been fixed. - -$head 06-20$$ -Upgrade to from autoconf 2.61 to 2.63, -and from automake 1.10.1 to 1.11. -$pre - -$$ -Fix conflict between CppAD's use of config.h preprocessor symbols -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 -$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; -see $cref/complex FAQ/Faq/Complex Types/$$.) -$lnext -Fixing the $code not_complex_ad.cpp$$ problem above also fixed a warning -generated by $href%http://valgrind.org/%valgrind%$$. -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 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/autotools/$$ procedure. -This was has been fixed (revision 1362). - -$head 03-24$$ -Added cross references in -the $cref/examples/ListAllExamples/$$ to occurrence of the following tokens: -$cref AD$$, -$cref/ADFun/FunConstruct/$$, -$cref/CPPAD_TEST_VECTOR/test_vector/$$, -$cref Forward$$, -$cref Independent$$, -$cref Jacobian$$ -$cref NearEqual$$, -$cref Reverse$$. - -$head 02-20$$ -Demonstrate using AD to compute the derivative -of the solution of an ODE with respect to a parameter -(in the $cref runge45_2.cpp$$ example). - -$head 02-15$$ -Change the distribution -$cref/compressed tar file/download/Compressed Archives/$$ -to only contain one copy of the documentation. -Link to the current Internet documentation for the other three copies. - - -$head 02-01$$ -Move the $code Prev$$ and $code Next$$ buttons at the top of the documentation -to the beginning so that their position does not change between sections. -This makes it easier to repeatedly select this links. - - -$head 01-31$$ -Modify $code cppad/local/op_code.hpp$$ to avoid incorrect warning by -g++ version 4.3.2 when building $code pycppad$$ (a python interface to CppAD). - -$head 01-18$$ -Sometimes an error occurs while taping AD operations. -The $cref abort_recording$$ function has been added -to make it easier to recover in such cases. -$pre - -$$ -Previously, CppAD speed and comparison tests used Adolc-1.10.2. -The version used in the tests has been upgraded to -$href% - https://projects.coin-or.org/ADOL-C% - Adolc-2.0.0. -%$$ -$pre - -$$ -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. -$pre - -$$ -A minor typo has been fixed in the description of -$code W(t, u)$$ in $cref reverse_any$$. -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$$. - -$head 01-06$$ -Made some minor improvements to the documentation in -$cref FunConstruct$$. - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_10.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_10.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_10.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_10.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,318 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_10$$ -$spell - autotools - Wshadow - pkg-config - Dir - libipopt - const - Linpack - Blas - makefile - op - arg - checkpointing - sizeof - libcppad_ipopt.a - Microsoft - Lagragian - iostream - obj_value - std::cout - endl - gcc - retape - hpp - ifdef - nlp - ipopt_cppad/src - CppAD -$$ - -$section Changes and Additions to CppAD During 2010$$ - -$head Introduction$$ -This section contains a list of the changes to CppAD during 2010 -(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-31$$ -$list number$$ -Add specifications for the CppAD $cref pkgconfig$$ files. -$lnext -Update the CppAD README file. -$lnext -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, -$code -sparse_pack.hpp:101:2: warning: declaration of 'end' shadows a member of 'this' -$$ -$lend - -$head 11-27$$ -If $code NDEBUB$$ was defined, -the default CppAD $cref/error handler/ErrorHandler/$$ would return -because its $code assert$$ had no effect in this case. -This has been fixed by placing a call to $code std::exit(1)$$ -after its assert. - -$head 09-26$$ -There was a bug -(introduced on 09-22) -in $code make test$$ -when the $code configure$$ command was executed from a directory -other than the distribution directory -(the $cref cppad_ipopt_nlp$$ did not build). -This has been fixed. - - -$head 09-22$$ -Promote $cref cppad_ipopt_nlp$$ from an example to a library -that gets installed -(provided that the $cref/ipopt_dir/autotools/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$$. - -$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/autotools/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 -$icode%ipopt_dir%/lib/libipopt.%*%$$ -(see $cref/ipopt_dir/autotools/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 -$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 -(see $cref/speed/Faq/Speed/$$), -the function -$codei% - CheckSimpleVector(const %Scalar%& %x%, const %Scalar%& %y%) -%$$ -was not defined; see -$href%http://list.coin-or.org/pipermail/cppad/2010q2/000166.html%bug report%$$. -This has been fixed. - -$head 04-28$$ -Change the multi-level taping examples -$cref mul_level.cpp$$ and $cref mul_level_adolc.cpp$$ -to be more efficient. - -$head 04-26$$ -Include Blas and Linpack libraries in makefile links for -$cref cppad_ipopt_nlp$$ examples. -This removes the need to use get.Blas when building Ipopt. -$pre - -$$ -The speed test in $code cppad_ipopt/speed$$ was missing -a link to the library $code ../src/libcppad_ipopt.a$$. -This has been fixed. - -$head 04-24$$ -There was a bug in the error checking done by $code cppad/local/sub_op.hpp$$ -that caused the following improper abort: -$codei% -Error detected by false result for - arg[1] < i_z -at line 337 in the file - %...%/include/cppad/local/sub_op.hpp -%$$ -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%$$. - - -$head 04-01$$ -Some of the $cref speed_utility$$ library -(in $code speed/src$$) was being compiled for debugging. -This has been changed and they are now compiled with debugging off -and optimization on. - -$head 03-11$$ -The old $cref reverse_any$$ example was moved to $cref reverse_three.cpp$$, -the old checkpoint example is now the general case reverse example, -and a better $code checkpoint.cpp/$$ example was created. - -$head 03-10$$ -The $cref optimize$$ routine would mistakenly remove some -expressions that depended on the independent variables and that -affected the result of certain $cref CondExp$$ operations. -This has been fixed. - -$head 03-09$$ -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/Boolean Vector/$$ -sparsity patterns. -(when the number of elements per set was a multiple of -$code sizeof(size_t))$$. - -$head 02-11$$ -The $code speed$$ directory has been reorganized and the -common part of the $cref/link functions/speed_main/Link Functions/$$, -as well as the $cref microsoft_timer$$, -have been moved to the subdirectory $code speed/src$$ -where a library is built. - -$head 02-08$$ -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/autotools/Configure/$$ command line. -This has been fixed. - -$head 02-06$$ -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 -format.) -$pre - -$$ -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$$ -$list number$$ -Simplify running all the tests by adding the -$code make test$$ command. -$lnext -Simplify the $cref/configure/autotools/Configure/$$ command by removing -need for: -$code --with-Speed$$, -$code --with-Introduction$$, -$code --with-Example$$, -$code --with-TestMore$$, -and $code --with-PrintFor$$. -$lnext -Add files that were missing in the Microsoft Visual Studio -projects. -$lnext -Fix two significant bugs. One in the $cref optimize$$ command -and the other in the $cref PrintFor$$ command. -$lend - -$head 02-03$$ -Fix a mistakes in the test $cref bender_quad.cpp$$. -In addition, the $cref optimize$$ routine was used to reduce the -tape before doing the calculations. -$pre - -$$ -The routine $cref opt_val_hes$$ was added as an alternative to -$cref BenderQuad$$. - -$head 01-26$$ -Another speed improvement was made to $cref cppad_ipopt_nlp$$. -To be specific, the Lagragian multipliers where checked and components -that were zero were excluded form the Hessian evaluation. - -$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 -produced). This is because the argument value to $latex r_k (u)$$ depends -on the value of $latex \ell$$ in the expression -$latex \[ - r_k \circ [ J_{k, \ell} \otimes n ] (x) -\] $$ -(even when the value of $latex x$$ does not change). -$pre - -$$ -There was a bug in the $cref ipopt_nlp_ode_check.cpp$$ program, -for a long time, that did not show up until now. Basically, -the check had code of the was using an undefined value. -This has been fixed. - -$head 01-23$$ -Improve the sparsity patterns and reduce the amount of memory -required for large sparse problems using $cref cppad_ipopt_nlp$$. -The speed test $code cppad_ipopt/speed$$ showed significant improvement. - - -$head 01-20$$ -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$$. -This will facilitate using $code CPPAD_IPOPT_*$$ for the -$code # ifdef$$ commands in the new include files -(note that they must begin with $code CPPAD$$). - - -$head 01-18$$ -The $code ipopt_cppad$$ subdirectory of the distribution -has been split into an $code src$$, $code example$$, and $code speed$$ -subdirectories. -The $code example$$ ($code speed$$) -subdirectory is where one builds the $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$ examples -($cref%speed tests%ipopt_ode_speed.cpp%$$). - -$head 01-04$$ -The following items have been fulfilled and -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$$, -the tape recording can be stopped using $cref abort_recording$$. - -$lnext -A speed test for $cref/ipopt_cppad_nlp/cppad_ipopt_nlp/$$ was added; see -$cref ipopt_ode_speed.cpp$$. - -$lnext -The $cref optimize$$ command uses hash coding to check -when an expression is already in the tape and can be reused. - -$lnext -The $cref optimize$$ command removes operations that -are not used by any of the dependent variables. - -$lnext -The $cref ad_in_c.cpp$$ example demonstrates how to connect -CppAD to an arbitrary scripting language. - -$lnext -The vector of sets option has been added to sparsity calculations; -see $cref/sparsity pattern/glossary/Sparsity Pattern/$$. - -$lend - - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_11.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_11.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_11.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_11.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,991 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_11$$ -$spell - autotools - eps - cxx - namespace - boostvector - mega - inv - bthread - pthread - pthreads - Std - retape - cygwin - vcproj - pthread - https - abs_geq - CondExpRel - num - Taylor - Tanh - Rosen - Runge - executables - matlab - Addr - sizeof - undefine - config - adolc - initializer - vec - Bool - op - omp_alloc - isnan - gcc - hasnan - instantiation - Microsoft - svn - hes - openmp - prefixdir - pkgconfig - Fadbad - Wshadow - omh - dir - libspeed - cppad_ipopt_nlp.hpp - automake - makefile - builddir - gpl - http://www.coin-or.org/download/source/CppAD/cppad-20110101.0.cpl.tgz -$$ - -$section Changes and Additions to CppAD During 2011$$ - -$head Introduction$$ -This section contains a list of the changes to CppAD during 2011 -(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-30$$ -$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. -$lnext -Change the specifications for the derivative of the $cref abs$$ -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 -$cref%sign%base_std_math%sign%$$ function to the list of -$cref%base type requirements%base_require%$$. -$lend - -$head 12-28$$ -The file $cref/time_test.hpp/time_test/Include/$$ -was not being included by $code cppad/cppad.hpp$$. -This has been fixed. - -$head 12-21$$ -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 -$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 -change is to use the command -$codep - using namespace cppad_ipopt; -$$ - -$head 12-20$$ -$list number$$ -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 -$cref/NDEBUG/Faq/Speed/NDEBUG/$$. -$lnext -Improve $cref memory_leak$$ documentation. -$lend - -$head 11-29$$ -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. - -$head 11-27$$ -Move $code multi_thread.cpp$$ to $cref thread_test.cpp$$ -and fix its $cref/running/thread_test.cpp/Running Tests/$$ instructions. - -$head 11-24$$ -Create $cref preprocessor$$ section with pointers to all the -preprocessor symbols that are in the CppAD API. - -$head 11-21$$ -Separate $cref/--with-boostvector/autotools/--with-testvector/$$ -for $cref/boost_dir/autotools/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 -$cref/team_name/team_thread.hpp/team_name/$$ in the -$cref thread_test.cpp$$ output. -$lend - -$head 11-18$$ -$list number$$ -The $cref thread_test.cpp$$ program was truncating $icode test_time$$ -to the nearest integer. -This has been fixed. -$lnext -The $cref time_test$$ routine has been made more efficient and now -check for the case where only one execution of the test is necessary -to achieve the desired $icode test_time$$ -(it used to always run at least two). -$lnext -The $code sum_i_inv_time.cpp$$ and $cref multi_newton.cpp$$ -routines were calling the test an extra time at the end to check for -correctness. -The results of the last test are now cached and used for the correctness -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$$. -The use it for the timing tests in -$code sum_i_inv_time.cpp$$ and $cref multi_newton_time$$. -$lnext -Add $icode test_time$$ as a command line argument -to the multi-threading $code sum_i_inv$$ -and $cref/multi_newton/thread_test.cpp/multi_newton/$$ -timing tests. -$lend - - -$head 11-09$$ -Change $code thread_team.hpp$$ to $cref team_thread.hpp$$ and do -the same for all other names that ended in $code _team$$; e.g., -$cref team_openmp.cpp$$. - -$head 11-07$$ -The users choice for $cref test_vector$$ was not actually changing -the tests that the user ran. This have been fixed. - -$head 11-06$$ -Make all the output generated by $cref multi_newton.cpp$$ valid -matlab and octave input so it is easy to plot the results. - -$head 11-04$$ -Use thread specific data to simplify $cref team_openmp.cpp$$. - -$head 11-01$$ -Make $cref team_bthread.cpp$$ more similar to $cref team_pthread.cpp$$. - -$head 10-30$$ -$list number$$ -Reorganize and improve the $cref multi_thread$$ section and its subsections. -$lnext -There was a bug in $cref multi_newton.cpp$$ that only showed up when -the number of threads was greater than or equal 4. -This has been fixed. -In addition, -$cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$ -was increased from 2 to 4 (to enable testing for this bug). -$lnext -The accuracy expected in the $code sum_i_inv.cpp$$ results were failing -when $code mega_sum$$ was large. -This check has been modified to include a correction for $icode mega_sum$$. -$lend - -$head 10-29$$ -The following changes were merged in from $code branches/thread$$: - -$list number$$ -Move $code openmp$$ to $code example/multi_thread/openmp$$. -and create $code example/multi_thread/bthread$$, $code multi_thread/pthread$$ -with similar tests. -$lnext -Put multi-threading common code in $code multi_thread$$ directory -and threading system specific code in $codei%example/multi_thread/%threading%$$ -for $icode threading$$ equal to $code openmp$$, $code bthread$$, -and $code pthread$$. -$lnext -Update the README file. -$lnext -Remove the $code bug/optimize.sh$$ file (no longer a bug). -$lnext -Make $code arc_tan.cpp$$ -utility that can be used by multiple multi-threading tests. -$lnext -Create $cref team_thread.hpp$$ specifications, -move OpenMP management to $cref team_openmp.cpp$$, -Boost thread management to $cref team_bthread.cpp$$, -and pthread management to $cref team_pthread.cpp$$. -$lnext -All of the make files were modified so that the command -$codep - make test -$$ -would run the tests for the current directory. -$lnext -Extend the multi-threading speed tests -$code sum_i_inv.cpp$$ and $cref multi_newton.cpp$$ so they run -using Boost threads and pthreads (as well as OpenMP threads). -$lend - -$head 10-14$$ -Fix some compiler warnings about shadowed variables that were -detected by $code g++$$ version $code 4.6.1 20110908$$. - -$head 10-12$$ -$list number$$ -The MAC version of the $code pthread$$ library does not include the -$code pthread_barrier_wait$$ function; i.e., is not compliant with -the IEEE Std 1003.1, 2004 Edition for $code pthread$$. -This caused the $code pthread_simple_ad.cpp$$ to fail to compile on the MAC. -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 -$cref optimize$$ the functions $latex r_k (u)$$ such that -$codei%retape(%k%)%$$ is false. -$lend - -$head 09-06$$ -$list number$$ -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 -$cref/thread_num/ta_parallel_setup/thread_num/$$ argument -to $code parallel_setup$$. -$lnext -More simplification of $code bthread_simple_ad.cpp$$ example. -$lend - -$head 09-05$$ -Simply and fix some problems with $code pthread_simple_ad.cpp$$, -including avoiding a $cref/Bug in Cygwin/team_pthread.cpp/Bug in Cygwin/$$. - -$head 09-02$$ -$list number$$ -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 -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, -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/$$ -has been documented and is now part of the CppAD API. -$lnext -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. -This has been fixed by making -$icode%num_threads% == 1%$$ a special case in -$cref/parallel_setup/ta_parallel_setup/$$. -$lend - -$head 09-01$$ -$list number$$ -Modify the CppAD trunk using the -changes from svn revision 2060 to revision 2081 in the branch -$codep - 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-31/whats_new_11/09-01/08-31/$$. -$lnext -There was a bug in the $cref old_atomic$$ functions -in the case where none of the elements of the argument to the function -was a $cref/variable/glossary/Variable/$$. -This has been fixed. -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 - -$subhead 08-31$$ -$list number$$ -Move the $code sum_i_inv_time.cpp$$ test from -$code openmp/run.sh$$ to $code openmp/run.cpp$$. -$lnext -Change $code --with-openmp$$ to -$cref/OPENMP_FLAGS=openmp_flags/autotools/openmp_flags/$$ configure -command line argument. -$lend - -$subhead 08-30$$ -$list number$$ -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/autotools/Configure/$$ -information for building the tests. -$lnext -Document the $code --with-openmp$$ configure -command line argument. -$lnext -Move $code openmp/multi_newton.hpp$$ to -$code openmp/newton_method.hpp$$ and -$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 -$cref multi_thread$$, the section on how to use CppAD in parallel. -$lnext -Implement $cref omp_alloc$$ as links to corresponding $cref thread_alloc$$ -sections. -$lnext -Create the $code pthread_simple_ad.cpp$$ example that does AD using the -pthread library. -In addition, fix some problems in $code openmp_simple_ad.cpp$$ -$lnext -Move $code openmp/example_a11c.cpp$$ to -$cref|example/a11c_openmp.cpp|a11c_openmp.cpp|$$. -$lnext -Move $code openmp/parallel_ad.cpp$$ to -$code openmp_simple_ad.cpp$$. -$lend - -$subhead 08-23$$ -Beginning steps in replacing $cref omp_alloc$$ by $cref thread_alloc$$: -$list number$$ -Replace $cref omp_alloc$$ by $cref thread_alloc$$ -in the $cref/utilities/utility/$$. -$lnext -move $cref omp_alloc$$ to the deprecated section of the -documentation. -$lnext -Change all $cref omp_alloc$$ section names to begin with $code omp_$$, -and change all $cref thread_alloc$$ section names to begin with $code new_$$. -$lnext -Convert $cref CppAD_vector$$ from using $cref omp_alloc$$ to using -$cref thread_alloc$$ for memory allocation. -$lnext -Extend the $cref memory_leak$$ routine to also check the -$cref thread_alloc$$ allocator. -$lend - -$subhead 08-21$$ -Create the OpenMP and pthread examples -$cref a11c_openmp.cpp$$, -$cref a11c_pthread.cpp$$, and -$code openmp_simple_ad.cpp$$. -These OpenMP examples were originally in the $code openmp$$ directory, -and have been moved, and modified to conform, to the normal example directory. - -$head 08-11$$ -Modify the CppAD trunk using the -changes from svn revision 2044 to revision 2056 in the branch -$codep - 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-10/whats_new_11/08-11/08-10/$$. - -$subhead 08-10$$ -$list number$$ -Add the output stream optional argument $icode s$$ in -$codei% - %f%.Forward(0, %x%, %s%) -%$$ -See $cref/zero order forward mode/forward_zero/$$ and $cref PrintFor$$. -$lnext -Improve $cref omp_alloc.cpp$$ example. -$lend - - -$subhead 08-09$$ -$list number$$ -$cref base_require$$: -Add $cref/epsilon/numeric_limits/epsilon/$$ to the -$icode Base$$ type requirements. -$lnext -Extend $code epsilon$$ to AD types. -$lend - -$subhead 08-08$$ -$list number$$ -Improve the $cref base_require$$ documentation for -$cref/standard math functions/base_std_math/$$. -$lnext -$cref base_require$$: -Add $code abs_geq$$ to the $cref/requirements/base_require/$$ -for a user defined $icode Base$$ type. -$lnext -Check that zero order forward mode results are approximately equal, -instead of exactly equal, -after an $cref optimize$$ operation. -This fixes a bug in the optimize correctness check -(The order of operations can be changed by $code optimize$$ -and hence the zero order forward mode results may not be exactly the same.) -$lend - -$subhead 08-07$$ -Improve the $cref base_require$$ documentation for -$cref/EqualOpSeq/base_identical/EqualOpSeq/$$, -$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. -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 base_require$$: -Change the $cref/include/base_require/Include Order/$$ file name to -$cref/base_require.hpp/base_require/$$. -$lnext -Use $cref base_float.hpp$$ and $cref base_double.hpp$$ as additional examples -for the $cref/CondExp Base requirements/base_cond_exp/$$ -requirements. -$lend - -$head 08-03$$ -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. - -$head 08-02$$ -$list number$$ -Change $cref PrintFor$$ so it no longer aborts execution when -there is no operation sequence being recording; see -$cref/start recording/Independent/Start Recording/$$. -$lnext -Improve the $cref print_for_cout.cpp$$ example. -$lend - -$head 07-31$$ -Add a conditional version of the $cref PrintFor$$ command -$codei% - PrintFor(%text%, %y%, %z%) -%$$ -which only prints when $icode%z% <= 0%$$. -This is useful for error reporting during forward mode; i.e., -reporting when the argument to the $code log$$ function is not valid. - -$head 07-29$$ -$list number$$ -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/$$ -by calls to $code set_max_num_threads$$. -$lnext -The functions $cref omp_efficient$$ was deprecated because it -has not been shown to be useful. -$lend - -$head 07-28$$ -$list number$$ -Change $cref omp_return_memory$$ so that if $cref omp_max_num_threads$$ is one -(the default), $cref omp_alloc$$ does not hold onto memory -(keep it available for the corresponding thread). -$lnext -Add files that were missing from the Microsoft Visual Studio -$code example$$ and $code test_more$$ subdirectory -project files. -$lnext -Fix some warnings generated by Microsoft Visual Studio 2010 build. -$lend - -$head 07-27$$ -Make $code tan$$ and $code tanh$$ $cref/atomic/glossary/Operation/Atomic/$$ -operations; see $cref tan_forward$$ and $cref tan_reverse$$. - -$head 07-25$$ -Finish the $cref old_atomic$$ example $cref old_tan.cpp$$. -This is also a design and implementation of the routines necessary -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 lower order Taylor coefficients for $latex Y(t)$$. -This has been fixed in $cref tan_reverse$$. - -$head 07-17$$ -$list number$$ -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$$ -$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$$; -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; -see the new $cref old_atomic$$ example $cref old_tan.cpp$$. -$lend - -$head 07-14$$ -$list number$$ -The $cref autotools$$ instructions for running the individual -correctness and speed tests were out of date. -This has been fixed; see -$cref/example and tests/autotools/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). -$lnext -Simplify $code example_a11c.cpp$$ by making it just a correctness test. -$lnext -Change $code openmp/run.sh$$ so that it runs correctness tests with -the compiler debugging flags. -$lend - -$head 07-13$$ -$list number$$ -static hash code data that was begin used by multiple threads -when recording $codei%AD<%Base%>%$$ operations -$cref omp_in_parallel$$ execution mode. This has been fixed. -$lnext -Make the sparse calculations safe -for use during $cref omp_in_parallel$$ execution mode. -$lnext -Add the $code parallel_ad.cpp$$ example. -$lnext -Change $code example_a11c.cpp$$ example so that is just a correctness -(not speed) test. -$lend - -$head 07-11$$ -$list number$$ -Change the upper limit for -$cref omp_max_num_threads$$ from 32 to 48. -$lnext -Add $cref/parallel/ta_in_parallel/$$ documentation for, -$code nan$$, -$cref/Rosen34/Rosen34/Parallel Mode/$$, and -$cref/Runge45/Runge45/Parallel Mode/$$. -$lnext -Fix $cref CheckNumericType$$ and $cref CheckSimpleVector$$ -so they work properly when used in parallel mode. -$lend - - -$subhead openmp/run.sh$$ -The following changes were made to $code openmp/run.sh$$: -$list number$$ -$lnext -Change to $code openmp/run.sh$$ -maximum number of threads -instead of specifying the entire set of values to be tested. -$lnext -Change settings for -$code newton_example$$ -so that $code n_gird$$ is a multiple of the maximum number of threads. -$lnext -Report dynamic number of thread -results as a separate result in the summary output line. -$lnext -Fix automatic removal of executables from $code openmp$$ directory -(was commented out). -$lnext -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); -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 -$code sum_i_inv_time.cpp$$ -assumed was being done. -$lend - -$head 07-09$$ -All the OpenMP parallel execution requirements -have been grouped in the section $cref multi_thread$$. - -$head 07-07$$ -Add the routine $cref parallel_ad$$ to fix bug when using -$codei%AD<%Base%>%$$ in $cref/parallel/omp_in_parallel/$$ execution mode. - -$head 06-23$$ -$list number$$ -Fix a bug whereby the assert -$codei% - Error detected by false result for - ! omp_in_parallel() - at line %n% in the file - %prefix%/include/cppad/omp_alloc.hpp -%$$ -sometimes occurred. -$lnext -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 -$cref deprecated$$ section of the CppAD manual. -$lend - -$head 06-21$$ -$list number$$ -The $code openmp/run.sh$$ routine was changed to use zero, -instead of $code automatic$$, for automatic choice of -$code openmp/run.sh$$ -number of repeats -and -maximum number of threads. - -$lnext -The output of each of the OpenMP examples / speed tests -(run by $code openmp/run.sh$$) -was changed to be valid matlab / octave assignment statements. - -$lnext -In the case where OpenMP is enabled during compilation, -a summary for the different number of threads as added at the end of -the $code openmp/run.sh$$ output. - -$lend - -$head 06-18$$ -$list number$$ -The $cref/tape_addr_type/autotools/tape_addr_type/$$ option was added -to the $cref/configure/autotools/Configure/$$ command line. -$lnext -The function $cref/size_op_seq/seq_property/size_op_seq/$$ results uses -$code sizeof(CppAD_TAPE_ADDR_TYPE)$$ -where it used to use $code sizeof(size_t)$$. -$lnext -Remove $code cppad/config.h$$ from CppAD distribution, -(put the information in $code cppad/configure.hpp$$.) -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/autotools/adolc_dir/$$ library linkage so it -works with version $code ADOL-C-2.2.0$$. -$lend - -$head 05-29$$ -Fix bug (introduced on $cref/05-22/whats_new_11/05-22/$$) -whereby constructor might not be called (but required) when the -$cref/base type/base_require/$$ is not plain old data. - -$head 05-28$$ -$list number$$ -Add the $cref omp_efficient$$ routine to the $cref omp_alloc$$ system. -$lnext -Improve the $code omp_alloc$$ tracing so it prints the same pointer -as returned to the user (not an offset version of that pointer). -$lend - -$head 05-26$$ -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 - an initializer of the form () will be default-initialized -$$ - - -$head 05-22$$ -$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 -environment; see $cref/purpose/omp_alloc/Purpose/$$. -$lnext -The replacement of $code TrackNewDel$$ by $code omp_alloc$$ -has been throughout the CppAD source code, including the examples -that used $code TrackNewDel$$; namely, -$cref mul_level_adolc.cpp$$, $cref mul_level_adolc_ode.cpp$$. -$lnext -The CppAD vector template class -and the $cref/vectorBool/CppAD_vector/vectorBool/$$ class -were modified to use the $code omp_alloc$$ -$cref/memory/CppAD_vector/Memory and Parallel Mode/$$ manager. -This should improves its speed of memory allocation -$cref omp_in_parallel$$ sections of a program. -$lnext -The $cref speed_test$$ argument -$cref/size_vec/speed_test/size_vec/$$ call was by value, -instead of by reference (as documented). -This has been fixed and the call is now by reference. -$lnext -The $cref/capacity/CppAD_vector/capacity/$$ function has been added -to the CppAD vector class. -$lnext -The simple vector -$cref/ - element constructor and destructor/ - SimpleVector/ - Element Constructor and Destructor -/$$ -description has been changed to explicitly specify that the -default constructor is used to initialize elements of the array. -$lnext -The $cref/size_op_seq/seq_property/size_op_seq/$$ documentation -has been improved to mention that the allocated memory may be larger. -$lend - -$head 05-11$$ -$list number$$ -Avoid ambiguity in the definition of the -$cref/complex isnan/base_complex.hpp/isnan/$$ function. -$lnext -Errors during $code make test$$ were not -being detected. -This has been fixed. -$lend - -$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 -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 -$cref cppad_ipopt_nlp$$ objective function, the constraints, -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 -handler has not been replaced). -$lend - -$head 04-29$$ -$list number$$ -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% - http://msdn.microsoft.com/en-us/library/bh44f2cb(v=vs.71).aspx% - Compiler Error C2918 -%$$. -These project files were converted to Visual Studio 2008 where they do work -(if you use a later version, Visual Studio should automatically -convert them for you). - -$lnext -The old speed test directory was moved to $code speed_cppad$$ -before the new $cref speed$$ test organization was created on 2006-12-11 -(revision 715 of the repository). -The old speed tests have not been used for years and so have been deleted. -$lend - -$head 04-20$$ -The $code openmp/run.sh$$ script what changed -to take an argument that specifies which tests is run -(it no longer runs all the tests). -Also improve the openmp test program output formatting. - -$head 04-19$$ -The $icode use_ad$$ option was added to the -$code openmp_newton_example.cpp$$ test case. - -$head 03-19$$ -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 -$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$$. -There was a check that its size was greater than or equal $icode q$$. -This was incorrect and has been fixed. - -$head 03-05$$ -Add the $cref/conjugate gradient/conj_grad.cpp/$$ example. - -$head 02-22$$ -Add the $cref/atomic/speed_main/Global Options/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. - - -$head 02-19$$ -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) -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 -$code openmp/run.sh$$ -openmp_flag was not $code ""$$. -This has been fixed. - -$head 02-15$$ -A matrix multiply speed test has been added. -So far, this has only implemented for the -$cref/cppad/cppad_mat_mul.cpp/$$ and $cref/double/double_mat_mul.cpp/$$ cases. -(For the time being this test is not available for the other -speed comparison cases.) - -$head 02-09$$ -A variable in $code old_atomic.hpp$$ was declare of type $icode Base$$ -when it should have been declared of type $code size_t$$. -It caused the $cref old_atomic$$ feature to fail with some base types. -This has been fixed. -$pre - -$$ -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. -$pre - -$$ -Some of the $cref old_atomic$$ documentation was extended to -include more explanation. - -$head 02-06$$ -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/wish_list/$$. -$pre - -$$ -The documentation for $cref RevSparseHes$$ had a dimension error. -This has been fixed. -$pre - -$$ -A faster set operations item was added to the wish list. -This has since been satisfied by -$code cppad_sparse_list$$ choice during -the install process (since removed). - -$head 02-02$$ -The documentation for $cref ForSparseJac$$ had some formatting errors. -The errors have been fix and the documentation has been improved. - -$head 02-01$$ -The subversion -install instructions were brought up to date. -They have since been replaced by just separate -$code subversion$$ instructions. - -$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%$$ -to -$icode%prefixdir%/share/pkgconfig/cppad.pc%$$; -see -$href%http://lists.fedoraproject.org/pipermail/devel/2011-January/147915.html% -devel@lists.fedoraproject.org%$$. - -$head 01-16$$ -The following have been fixed: -$list number$$ -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/autotools/Configure/$$ command in it. -$lnext -Since the change on 01-09, the file -$code omh/appendix/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/autotools/cxx_flags/$$. -$lend - -$head 01-09$$ -There were some problems running $code make test$$ in the releases -$codei% -http://www.coin-or.org/download/source/CppAD/cppad-20110101.0.%license%.tgz -%$$ -where $icode license$$ is $code gpl$$ or $code cpl$$. -$list number$$ -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/autotools/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 -release versions; i.e., -$codei% -http://www.coin-or.org/download/source/CppAD/cppad-20110101.1.%license%.tgz -%$$ -will not have this problem. - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_12.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_12.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_12.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_12.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,1046 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_12$$ -$dollar @$$ -$spell - autotools - plugin - checkpointing - Jacobians - doxygen - txt - sys - stdbool - datadir - pkgconfig - cppad_ipopt_nlp - includedir includedirs - libdir libdirs - Ubuntu - Microsoft - cmake - CondExpOp - src - std - hes - dw - uninitialised - resize - bool - taddr - eigen - fabs - mul - det_lu - adolc - fadbad - sacado - CppADvector - retape - Jacobian - dir - -lteuchos - trilinos - inorder - pthread - helgrind - Taylor - Debian - valgrind - num - alloc - makefile - hpp - gcc - cppad-%yyyymmdd% - lpthread - xout - fabs - fcur - CppAD - openmp -$$ - -$section CppAD Changes and Additions During 2012$$ - -$head Introduction$$ -This section contains a list of the changes to CppAD during 2012 -(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-30$$ -$list number$$ -Merge changes in $code branches/ipopt_solve$$ to $code trunk$$, -delete that branch, and -advance version number to $code cppad-20121230$$. -$lnext -Remove $code cppad/configure.hpp$$ from repository because -it is built by the configuration process -(even for MS Visual Studio, now that we are using $cref cmake$$). -$lnext -Add the $codei%AD<%Base%>%$$ input stream operator $cref/>>/ad_input/$$. -$lend - -$head 12-29$$ -In $code branches/ipopt_solve$$: -$list number$$ -Complete implementation of sparse Jacobian and Hessian calculations -and add options that allow to user to choose between forward and reverse -sparse Jacobians. -$lnext -The $cref ipopt_solve$$ routine seems to be faster and simpler -than $cref cppad_ipopt_nlp$$. -More speed comparisons would be good to have. -$lnext -All of the $cref/ADFun Drivers/Drivers/$$ -have added specifications for the zero order Taylor coefficients -after the routine is called. -For example, see -$cref/Hessian uses forward/Hessian/Hessian Uses Forward/$$. -$lend - - -$head 12-28$$ -In $code branches/ipopt_solve$$: -$list number$$ -Add the $cref ipopt_solve_retape.cpp$$ and $cref ipopt_solve_ode_inverse.cpp$$ -examples. -$lnext -Use $code ipopt::solve$$ $cref/options/ipopt_solve/options/$$ -argument (and not a file) for all the Ipopt options. -As well as allowing for adding $code ipopt::solve$$ special options; e.g., -$cref/retape/ipopt_solve/options/Retape/$$. -$lend - -$head 12-27$$ -In $code branches/ipopt_solve$$: -Change documentation section names that begin with $code cppad_ipopt$$ -to begin with $cref/ipopt_nlp/cppad_ipopt_nlp/$$ -to distinguish them from $cref/CppAD::ipopt::solve/ipopt_solve/$$. - -$head 12-26$$ -In $code branches/ipopt_solve$$: -$list number$$ -Convert documentation most all documentation references from -the deprecated $cref autotools$$ instructions to the new $cref cmake$$ -instructions. -$lnext -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$$ -which is easier to use. -This is a first version of $code ipopt_solve$$ and its speed -and memory use needs to be improved. -$lend - -$head 12-23$$ -Copy development $code trunk$$ to $code branches/ipopt_solve$$. - -$head 12-22$$ -Define a doxygen module (group) for each file that has doxygen documentation. - -$head 12-20$$ -$list number$$ -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 -get installed in the $code cppad$$ include directory. -$lnext -Advance the version number to $code cppad-20121220$$. -$lend - -$head 12-19$$ -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 -$code compare_c/det_by_minor.c$$ source code. - -$head 12-17$$ -There was a mistake in a check for a valid op code in the -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 -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 -$codei% - cppad_prefix%/cmake_install_datadir%/cppad.pc -%$$ -This has been fixed and is now -$codei% - cppad_prefix%/cmake_install_datadir%/pkgconfig/cppad.pc -%$$ -$lnext -The $cref pkgconfig$$ documentation has been improved. -$lnext -The command for running the -$cref/adolc examples/adolc_prefix/Examples/$$ and -$cref/eigen examples/eigen_prefix/Examples/$$ -was fixed -(changed from $code make check$$ to $code make check_example$$). -$lend - - -$head 12-14$$ -$list number$$ -Fix the old $cref autotools$$ so that it works with the -new $code cppad.pc$$. -$lnext -Fix the old installation -$cref/--with-Documentation/autotools/--with-Documentation/$$ option -(it was attempting to copy from the wrong directory). -$lend - - -$head 12-13$$ -$list number$$ -Include documentation for $cref ipopt_prefix$$ -$lnext -Fix the $code cppad.pc$$ $cref pkgconfig$$ file -so that it includes the necessary libraries and include commands -when $cref ipopt_prefix$$ is specified; see -$cref/pkgconfig usage/pkgconfig/Usage/$$. -$lend - - -$head 11-28$$ -Update the $cref wish_list$$: -$list number$$ -Remove Microsoft compiler warning item that has been fixed. -$lnext -Remove faster sparse set operations item that was completed using -$code cppad_sparse_list$$ (not part of user API). -$lnext -Remove $cref cmake$$ items that have been completed. -$lnext -Remove $cref CondExp$$ items related to using -$code AD< std::complex >$$ types because it is better to use -$code std::complex< AD >$$. -$lnext -Remove $cref thread_alloc$$ memory chunk item that has been completed. -$lnext -Remove $cref VecAD$$ item about slicing from floating point type to $code int$$ -(not important). -$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/$$ -can now be used for this purpose.) -$lnext -Add new $code old_atomic$$ $cref wish_list$$ item (since removed). - -$lend - -$head 11-21$$ -$list number$$ -Fix the -$cref/version/download/Version/$$ number in link to the -current download files. -$lnext -Change the -$code subversion$$ download instructions to use -the $code export$$ instead of $code checkout$$ command. -This avoids downloading the source code control files. -$lend - -$head 11-20$$ -$list number$$ -The $code cmake$$ variables -$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/$$ -to signify the fact that they can now be a list of directories. -$lnext -Advance version number to $code cppad-20121120$$. -$lend - -$head 11-17$$ -$list number$$ -Finish documenting the new $cref cmake$$ configuration instructions -and deprecate the old $cref/unix/autotools/$$ instructions. -$lnext -Change the specifications for -$cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$ -to allow for a value of one. -This enables one to have more tapes during a program execution. -$lnext -Include the $cref/C versus C++/compare_c/$$ speed comparison -in the $cref cmake$$ build. -$lend - -$head 11-16$$ -Fix a warning that occurred in $cref Rosen34$$ -when it was compiled with the preprocessor symbol $code NDEBUG$$ defined. - -$head 11-14$$ -Advanced the CppAD version to $code cppad-20121114$$. - -$list number$$ -Started documenting the -$cref cmake$$ configuration procedure during installation. -This included factoring out the -$cref download$$ procedure as a separate section -so that the same download instruction also apply to the -$cref/unix/autotools/$$ install procedure. - -$lnext -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 -with $code NDEBUG$$ is defined and to pass. - -$lnext -In the case where $code NDEBUG$$ is defined, -removed detection of $code nan$$ during forward mode from -$code test_more/forward.cpp%$$. -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$$. -The wish list items were completed and removed. - -$lend - - -$head 11-09$$ -The $cref team_pthread.cpp$$ was failing to link on Ubuntu 12.04 -because the libraries were not at the end of the link line. -This has been fixed. - -$head 11-06$$ -$list number$$ -Remove some remaining references to the old licenses CPL-1.0 and GPL-2.0; -see $cref/10-24/whats_new_12/10-24/$$. -$lnext -Remove out of date Microsoft project files from the distribution. -The build system is being converted to use -$href%http://www.cmake.org%cmake%$$ which builds these files automatically -and thereby keeps them up to date. -This feature is not yet documented, but one can inspect the file -$code bin/run_cmake.sh$$ to see how to use $code cmake$$ with CppAD. -$lend - - -$head 11-04$$ -Add missing return value to the example $code base_alloc$$ -$cref/CondExpOp/base_alloc.hpp/CondExpOp/$$ function. -This has been fixed and the comments for this example have been improved. - -$head 10-31$$ -The CppAD $cref/profiling/autotools/Profiling CppAD/$$ was not compiling -the $code speed/src/*.cpp$$ files with the profiling flag. -This has been changes -(only for the profiling speed test). - -$head 10-30$$ -The $cref/fadbad_dir/autotools/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. -This has been fixed by properly defining $codei%fabs(%x%)%$$ where -$icode x$$ is a double (without the $code std$$ in front). - -$head 10-24$$ -Change the CppAD licenses from CPL-1.0 and GPL-2.0 to -EPL-1.0 and GPL-3.0. - -$head 10-12$$ -$list number$$ -Change all the multiple levels of AD examples to -start with $cref mul_level$$. -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 -Add $cref ode_taylor.cpp$$ as a example of Taylor's method for solving ODEs, -($cref mul_level_ode.cpp$$ is an application of this method -to multi-level AD.) -$lend - -$head 10-04$$ -$list number$$ -Change $cref speed_main$$ so that it outputs small rates (less than 1000) -with two decimal points of precision (instead of as integers). -In addition, flush result for each size when it finishes to give user -more feedback about how things are progressing. -$lnext -Add the optional $cref/test_size/time_test/test_size/$$ argument -to the $code time_test$$ routine. -$lend - -$head 10-03$$ -Change the $code hold_memory$$ speed to option to just -$cref/memory/speed_main/Global Options/memory/$$. -In addition, in the speed test output, include all of the options -that are present in the output variable name; -see $cref/speed results/speed_main/Speed Results/$$. - -$head 10-02$$ -Fix another problem with Debian's $code /bin/sh$$ shell executing -$code example/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/$$ -argument -$cref/v/old_atomic/rev_hes_sparse/v/$$. -In addition, -add sparsity calculations to the $cref old_reciprocal.cpp$$ example. - -$head 09-11$$ -Add $code user_simple.cpp$$, -a simpler $cref old_atomic$$ example. - -$head 08-05$$ -$list number$$ -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 -$code --with-sparse_option$$ (since removed). -$lnext -A new speed test, $cref compare_c$$, compares the speed of the same -source code compiled with C and C++. -$lend - -$head 07-30$$ -$list number$$ -The $cref/clear/CppAD_vector/clear/$$ function was added to -$code CppAD::vector$$. -$lnext -Warning !!: -The $code CppAD::vector$$ $cref/resize/CppAD_vector/resize/$$ specifications -were changed so that $icode%x%.resize(0)%$$ no longer frees -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 -$code optimize.cpp$$ example: -$codep - ==6344== Conditional jump or move depends on uninitialised value(s) -$$ -$lnext -Fix mistake in $cref old_tan.cpp$$ where $code w[2] = 0$$ -was missing before the call -$codep - dw = F.Reverse(1, w); -$$ -$lend - -$head 07-08$$ -$list number$$ -Improve the documentation for $cref pow$$ and $cref pow_int$$. -$lnext -Change all the example section names to be same as corresponding file names; -e.g. change $code vectorBool.cpp$$ to $cref vector_bool.cpp$$ -for the example $code example/utility/vector_bool.cpp$$. -$lend - -$head 07-07$$ -Add the $code CPPAD_TAPE_ID_TYPE$$ argument to the -$cref/configure/autotools/Configure/$$ command line. - -$head 07-05$$ -Deprecate $cref/CPPAD_TEST_VECTOR/test_vector/$$ and use -$cref/CPPAD_TESTVECTOR/testvector/$$ in its place. -This fixes a problem introduced by changes on 07-03 whereby code that -used $code CPPAD_TEST_VECTOR$$ would no longer work. - -$head 07-04$$ -$list number$$ -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/autotools/Configure/$$ option was -added to the $code configure$$ command line. -$lend - -$head 07-03$$ -Fix bug in $cref old_atomic$$ functions identification of variables -that caused $cref old_tan.cpp$$ to fail with error message -$codep -Error detected by false result for - y_taddr > 0 -at line 262 in the file cppad/local/dependent.hpp -$$ - -$head 07-02$$ -Add $code eigen_plugin.hpp$$ so that -an Eigen vector can be used as a -$cref/SimpleVector/$$. -This has since been removed; see -$cref/2017-05-11/whats_new_17/05-12/$$. - -$head 07-01$$ -$list number$$ -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. -%$$ -$lnext -Fix bug whereby a newly constructed $cref VecAD$$ object was a -$cref/variable/ParVar/$$ (instead of a parameter) directly after construction -(when no previous $cref/ADFun/FunConstruct/$$ object had been created). -$lnext -Change a $code ok != a == 0.$$ to $code ok &= a == 0.$$ in -the example $cref ad_ctor.cpp$$. -$lnext -Add the $cref eigen_array.cpp$$ example. -$lend - -$head 06-17$$ -$list number$$ -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 $code numeric_limits$$ $cref/epsilon/numeric_limits/epsilon/$$. -$lnext -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 -$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/autotools/prefix_dir/$$ directory. - -$head 06-12$$ -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/Global Options/memory/$$ option -to the speed test main program. -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 -three to approximately ten. -$lend - -$head 06-09$$ -Change $cref adolc_sparse_jacobian.cpp$$ to use the sparse adolc -Jacobian (instead of the full Jacobian) driver. -This was also done for $cref adolc_sparse_hessian.cpp$$, -but there is a problem with the test that is being investigated. - -$head 06-08$$ -Implement the matrix multiply speed test $cref link_mat_mul$$ for all packages -(there is a problem with the $cref fadbad_mat_mul.cpp$$ -implementation and it is being looked into). - -$head 06-07$$ -Make all the speed tests implementations (for the specific packages) -uniform by having a Specification and Implementation heading and similar -indexing. For example, see -$cref adolc_det_minor.cpp$$, -$cref cppad_det_minor.cpp$$, -$cref double_det_minor.cpp$$, -$cref fadbad_det_minor.cpp$$, and -$cref sacado_det_minor.cpp$$. - -$head 06-05$$ -Add the $cref sacado_ode.cpp$$ speed test. - -$head 06-04$$ -$list number$$ -The specifications for $cref Runge45$$ where changes so that -it uses the $code fabs$$ function instead of the $code <$$ operation. -This enabled the a more precise statement about its -$cref/operation sequence/Runge45/Operation Sequence/$$. -$lnext -The $code fabs$$ function as added to the CppAD standard math library -(see $cref abs$$) -and the $cref/base type requirements/base_std_math/$$. -This enables one to write code that works with $code AD$$ as -well as $code double$$ without having to define $code abs$$ for -$code double$$ arguments -(and similarly for $code float$$). -$lnext -Add the $cref adolc_ode.cpp$$ and $cref fadbad_ode.cpp$$ speed tests -(and edit the $cref cppad_ode.cpp$$ test). -$lend - -$head 06-03$$ -$list number$$ -The $code CppAD::vector$$ class was extended to allow assignment -with the target of size zero and the source of non-zero size; -see $cref/check size/CppAD_vector/Assignment/Check Size/$$. -$lnext -A memory leak and a bug in $code cppad_mat_mul.cpp$$ were fixed -(the bug was related to the change to $code CppAD::vector$$ above). -$lend - -$head 06-02$$ -$list number$$ -Remove the deprecated symbol -$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 -$cref deprecated$$ features. -$lnext -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. -$lnext -Use same argument for taping and derivative evaluation when -$code retape$$ speed test option is true. -$lnext -Implement the $icode%retape% == false%$$ option -in $cref cppad_ode.cpp$$. -$lnext -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 -$code det_lu$$, $code det_minor$$, $code poly$$. -$lend - -$head 06-01$$ -Change -$cref cppad_sparse_hessian.cpp$$ and -$cref cppad_sparse_jacobian.cpp$$ -to use -the $icode row$$, $icode col$$ interface to $cref sparse_hessian$$. -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 -$cref speed_cppad$$ 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 -inputs (instead of being chosen randomly by the test for each repetition). -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/utilities/utility/$$ -so that it can be used by the implementations of -$cref link_sparse_jacobian$$ and $cref link_sparse_hessian$$. - -$head 05-27$$ -Split the sparse Jacobian and Hessian test function the separate function -$cref sparse_jac_fun$$ and $cref sparse_hes_fun$$ -(do not use sparse Hessian for both). -In addition, change row and column indices from $icode i$$ -and $icode j$$ to $icode row$$ and $icode col$$. - -$head 05-24$$ -Merged in changes from $code branches/sparse$$: -$list number$$ -A new interface was added to -$cref sparse_jacobian$$ and $cref sparse_hessian$$. -This interface -returns a sparse representation of the corresponding matrices -using row and column index vectors. -$lnext -The examples -$cref sparse_jacobian.cpp$$ and -$cref sparse_hessian.cpp$$ were improved -and extended to include the new interface. -$lnext -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/autotools/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 -$codei%boost_dir%/boost%$$ was the boost include directory, -now $codei%boost_dir%/include%$$ is the boost include directory. -This make it the same as the other directory arguments on the configure -command line. -In addition, it fixes some bugs in the detection of the boost -multi-threading library. - - -$head 04-18$$ -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 -$cref/multi_threading/multi_thread/$$. - -$head 04-10$$ -Add control of the -$cref/max_num_threads/autotools/max_num_threads/$$ argument -to the unix -$cref/configure/autotools/Configure/$$ command. - -$head 04-06$$ -$list number$$ -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 -$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$$ -was deprecated. -$lnext -Add the $code -lteuchos$$ flag to the link line for the -$cref speed_sacado$$ tests. -(This was not necessary for $code trilinos-10.8.3$$ -but is necessary for $code trilinos-10.10.1$$) -$lend - -$head 04-05$$ -The restriction was added that -$cref parallel_ad$$ cannot be called while a tape is being recorded. -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/$$. -This has been fixed and the error message below no longer occurs. -Suppose that you ran the CppAD -$cref/configure/autotools/Configure/$$ command in the $code work$$ -directory. -If you then edited the file $code work/multi_thread/makefile$$ -and changed -$codep - # AM_CXXFLAGS = -g @(CXX_FLAGS) - AM_CXXFLAGS = -DNDEBUG -O2 @(CXX_FLAGS) -$$ -to -$codep - AM_CXXFLAGS = -g @(CXX_FLAGS) - # AM_CXXFLAGS = -DNDEBUG -O2 @(CXX_FLAGS) -$$ -and then executed the commands -$codep - make clean - make pthread_test - valgrind --tool=helgrind ./pthread_test simple_ad -$$ -The following error message would result: -$icode% - ... snip ...% -==7041== Possible data race during write of size 4 at 0x8077460 by thread #1 -==7041== at 0x804FE23: CppAD::AD::tape_new() (tape_link.hpp:221) -% ... snip ... -%$$ - - - -$head 03-27$$ -Reduce the amount of memory allocation and copying of information during -a $cref Dependent$$ operation or an $code ADFun$$ -$cref/sequence constructor/FunConstruct/Sequence Constructor/$$. - -$head 03-26$$ -Calling $code taylor_capacity$$, with to with capacity equal to zero, -was not -$cref/freeing memory/capacity_order/c/Freeing Memory/$$. -This has been fixed. - -$head 03-23$$ -$list number$$ -Improve, the multi-threading examples -$cref simple_ad_openmp.cpp$$, -$cref simple_ad_bthread.cpp$$, and -$cref simple_ad_pthread.cpp$$. -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/$$ -during $code parallel_ad$$ call. -These statics are required to use -$cref/CppAD::vector/CppAD_vector/$$. -$lnext -Add a debugging check to make sure $cref CheckSimpleVector$$ -is initialized in sequential mode. -$lend - -$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 -different thread during parallel execution. - -$head 03-17$$ -Debian recently converted the default shell corresponding to -$code /bin/sh$$ to $code dash$$ -(which caused $code example/multi_thread/test.sh$$ to fail). -This has been fixed. -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 -%$$. - -$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 -$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 -$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. - - -$head 03-03$$ -$list number$$ -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/autotools/boost_dir/$$ -is not the prefix during the boost installation). -$lend - -$head 03-02$$ -$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 -$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$$). -This enabled the removal of $code example/multi_thread/arc_tan.cpp$$. -$lnext -In $cref team_example.cpp$$ check that all of the threads -pass their individual test; i.e. $codei%work_all_[%thread_num%]%.ok%$$ -is true for all $icode thread_num$$. -$lend - -$head 02-11$$ -$list number$$ -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. -$lend -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/$$ -is greater than one -(still can't be in parallel mode). - -$head 02-10$$ -$list number$$ -Add the missing Base class requirements in -the entire $cref base_member$$ section -and under the $cref/Output Operator/base_require/Output Operator/$$ -in the $cref base_require$$ section. -$lnext -Add the $cref base_alloc.hpp$$ example. -$lend - - -$head 02-09$$ -$list number$$ -Add the $icode set_static$$ to $cref memory_leak$$. -This is necessary for testing base types that allocate memory -for each element. -$lnext -Fix memory allocation bug in $code cppad/local/pod_vector.hpp$$ -when each element of the $cref/Base/base_require/$$ type allocated memory. -$lend - -$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/autotools/boost_dir/$$ override the default -library. - -$head 01-27$$ -There were some problems with -$cref/configure's/autotools/Configure/$$ automatic detection of -the boost multi-threading library. -These have been fixed. - -$head 01-24$$ -It used to be that $cref thread_alloc$$ did not hold onto memory -when $icode num_threads$$ was one in the previous call to -$cref/parallel_setup/ta_parallel_setup/$$. -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 -when there is only one thread. -To convert old code to the new interface, after each call to -$codei% -thread_alloc::parallel_setup(%num_threads%, %in_parallel%, %thread_num%); -%$$ -put the following call -$codei% -thread_alloc::hold_memory(%num_threads% > 1); -%$$ - -$head 01-23$$ -Change variable notation and use $cref optimize$$ in -$cref mul_level.cpp$$. - -$head 01-20$$ -$list number$$ -Add the example $cref change_param.cpp$$ -which shows how to compute derivatives of functions that have -parameters that change, but derivatives are not computed -with respect to these parameters. -$lnext -The documentation for machine $cref epsilon$$ -has been improved. -(The fact that it can be used for $icode Base$$ types was missing.) -$lend - -$head 01-19$$ -$list number$$ -In cases where $code test.sh$$ is trivial, -put its operations in corresponding makefile. -$lnext -Fix problem compiling $code cppad/speed/sparse_evaluate.hpp$$ -under gcc on Fedora 17. -$lnext -Run $code example/multi_thread/test.sh$$ from source directory -(no need to copy to build directory). -$lend - -$head 01-16$$ -The test program $code example/multi_thread/test.sh$$ failed if the -$cref/openmp_flags/autotools/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. - -$head 01-15$$ -Fix $code make test$$ so it works when -$cref/configure/autotools/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 -$cref multi_thread$$ test program linker command. -This has been fixed. - -$head 01-07$$ -$list number$$ -A duplicated code block beginning with -$codep -if( fabs( fcur ) <= epsilon_ ) -$$ -was removed from the routine $code multi_newton_worker$$. - -$lnext -The distance between solutions that are joined to one solution -has been corrected from $latex (b - a) / (2 n )$$ to -$latex (b - a) / n $$; see -$cref/xout/multi_newton_run/xout/$$. -The correction was in the file $cref multi_newton.cpp$$ where -$code sub_length_ / 2$$ was change to $code sub_length_$$. - -$lend - -$head 01-02$$ -$list number$$ -The $cref thread_alloc$$ memory allocator was changed to avoid -certain false sharing situations -(cases where two different thread were changing and using memory -that is on the same page of cache). -On one tests machine, the execution time for the 32 thread case for the test -$codep -./openmp_test multi_newton 1 32 1000 4800 10 true -$$ -improved from 0.0302 seconds to 0.0135 seconds. - -$lnext -There was a problem with the correctness test section of the -$cref multi_newton_time$$ test. -The convergence criteria, and correctness criteria, -needed to be scaled by the largest argument values. -This was a problem with over a hundred zeros were included in the test -(and the largest argument value was $latex 100 \pi$$ or more). - -$lnext -There was a problem with the way that -$cref multi_newton_takedown$$ -joined two solutions into one. -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 - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_13.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_13.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_13.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_13.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,543 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_13$$ -$dollar @$$ -$spell - ctor - Num - autotools - nz - Jacobian - CondExp Lt Gt Eq - op_arg - Adolc - aka - sacado - resize - sb - IpIpoptAlg.cpp - inf - const - algo - afun - cxx - checkpointing - cout - typename - bool - struct - impl - std - alloc - ptr - isnan - cmake - namespace - testvector - eigen - microsoft - src - jac - hpp - Wunused - Cpp - cppad -$$ - -$section CppAD Changes and Additions During 2013$$ - -$head Introduction$$ -This section contains a list of the changes to CppAD during 2013 -(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$$ -$list number$$ -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 autotools$$ -(created when optional implicit constructor from any type was added). -This has been fixed by adding the -$code --with-implicit_ctor$$ option -(later removed on $cref/2017-02-10/whats_new_17/02-10/$$.) -$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 -$cref/eigen 3.2/eigen_prefix/$$ (scheduled to be fixed in 3.3). -The default for this constructor has been changed to be -$cref/explicit/ad_ctor/x/explicit/$$. -In addition, other -$cref/implicit/ad_ctor/x/implicit/$$ constructors -are now listed in the documentation. -$pre - -$$ -If you get a compiler error on an constructor / assignment of the form -$codei% - AD<%Base%> x = %y% -%$$ -(that used to work) try changing the constructor call to -$codei% - AD<%Base%>( %y% ) -%$$ -A deprecated alternative is to make this constructor implicit using the -$cref/cppad_deprecated/cmake/cppad_deprecated/$$ -option during the install procedure. - -$head 12-26$$ -Document fact that -$cref/monthly versions/download/Monthly Versions/$$ -of the CppAD compressed tar file last till the end of the year. - -$head 12-24$$ -The interface to $cref/eigen/cppad_eigen.hpp/$$ defined a function -$codei% - NumTraits< CppAD::AD<%Base%> >::dummy_epsilon() -%$$ -that should have been named $code dummy_precision()$$. -This has been fixed. - -$head 11-27$$ -$list number$$ -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 -with domain dimension two and range dimension one. -$lend - -$head 11-13$$ -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 -$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. - -$head 11-12$$ -Error detection and reporting (when $code NDEBUG$$ is not defined) -has been added for the following case: -Using $cref optimize$$ -with $cref atomic_base$$ functions that have not defined -$cref/rev_sparse_jac/optimize/Atomic Functions/rev_sparse_jac/$$. - -$head 10-29$$ -The $cref/optimization/CondExp/Optimize/$$ -now handles nested conditional expressions. -For example, give the code -$codep - 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 conditional expressions will be evaluated -(one will be skipped depending on the result of $code left_z == right_z$$). -For more details, see $cref optimize_nest_conditional.cpp$$. - -$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/dependency/RevSparseJac/dependency/$$ argument to the -reverse Jacobian sparsity pattern calculation. -$lnext -Fix the deprecated autotools install (see $cref autotools$$) -which was broken by the changes on 10-22. -To be specific, the -example for $cref number_skip$$ was not being included. -$lend - -$head 10-22$$ -$list number$$ -Add $cref/optimization/optimize/$$ of conditional expressions; see -$cref/CondExp/CondExp/Optimize/$$. -$lnext -Add a phantom argument at the beginning of the operations sequence; -$cref/size_op_arg/seq_property/size_op_arg/$$ and $cref seq_property.cpp$$. -(This helps with the optimization mentioned above.) -$lnext -Add the function $cref number_skip$$ to measure how much optimization -of the conditional expressions there is. -$lend - -$head 10-16$$ -Fix bug in $cref/Tracing/wish_list/Tracing/$$ $cref atomic$$ functions. - -$head 10-15$$ -The documentation for the class -$cref/vectorBool/CppAD_vector/vectorBool/$$ was improved. - -$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 -$code build$$ directory. -Note that this local install of Adolc requires ColPack; see -$cref get_colpack.sh$$. -In addition, the requirement that ColPack and Adolc are installed -with the same prefix was added. - -$head 10-13$$ -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. - -$head 10-12$$ -$list number$$ -Change $cref get_eigen.sh$$ so that it will reuse install information -when it is present. -In addition document reuse for -$cref/get_eigen.sh/get_eigen.sh/Reuse/$$, -$cref/get_ipopt.sh/get_ipopt.sh/Reuse/$$, and -$cref/get_sacado.sh/get_sacado.sh/Reuse/$$. -$lnext -Fix following $code g++$$ error on OSX system: -$codep -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]; - ^ -$$ -$lend - -$head 09-20$$ -$list number$$ -Add lines for $cref atomic_base$$ function documentation -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 -$cref/atomic forward examples/atomic_forward/Examples/$$. -$lnext -Improve the documentation for $cref atomic_base_clear$$ -and remove its use from the -$cref/atomic_base examples/atomic_base/Examples/$$ -(because it is not needed). -$lend - -$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 -$cref/atomic forward examples/atomic_forward/Examples/$$. - -$head 09-18$$ -$list number$$ -A segmentation fault would occur if -an $cref ADFun$$ object used an $cref atomic$$ -function that had been deleted. -This has been fixed so that when $code NDEBUG$$ is not defined, -an error message is generated. -$lnext -A mistake in the documentation for -$cref/Memory and Parallel Mode/CppAD_vector/Memory and Parallel Mode/$$ -has been fixed. -This corresponds to the change in the specifications for -$cref/CppAD::vector::resize/CppAD_vector/resize/$$ made on -$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 reverse$$ mode. -This has been fixed. -$lnext -It appears, from inspecting the Ipopt source file -$code Ipopt/src/Algorithm/IpIpoptAlg.cpp$$ that the option $code sb$$ -to $code yes$$ suppress the printing of the Ipopt banner. -The Ipopt examples and tests have been changed to use this option -(although it is not in the ipopt documentation). -$lnext -Fix the a typo in the documentation for $code ipopt_solve$$ -$cref/Integer/ipopt_solve/options/Integer/$$ options -($code Numeric$$ was changed to $code Integer$$). -$lend - -$head 09-07$$ -There was a bug in the cumulative sum operator -(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 -checkpoint functions faster. -The bug has been fixed and the checkpoint functions now use -optimize (and hence should be faster). - -$head 08-12$$ -$list number$$ -The ability to turn on and off checking for $cref nan$$ in -$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 -$cref/atomic functions/optimize/Atomic Functions/$$ in within -another function is optimized. -$lnext -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$$.) -$lend - -$head 08-11$$ -If an $cref atomic$$ function had arguments that did not affect -the final dependent variables in $icode f$$, -$cref/f.optimize()/optimize/$$ would fail. -This has been fixed. -In addition, documentation about using $code optimize$$ -with $cref/atomic functions/optimize/Atomic Functions/$$ has been added. - -$head 08-06$$ -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.) -$$ -can result in the imaginary part of $code check$$ being $code - nan$$. - -$head 07-26$$ -Allow for use of $code const::string&$$ as a possible type for -$cref/name/atomic_ctor/atomic_base/name/$$ in the $code atomic_base$$ -constructor. - -$head 05-28$$ -Remove $icode ok$$ return flag from -$cref/checkpoint algo/checkpoint/algo/$$ -and -$cref/checkpoint atom_fun/checkpoint/atom_fun/$$. - -$head 05-21$$ -$list number$$ -Deprecate the $cref old_atomic$$ interface and replace it by the -$cref atomic_base$$ and $cref checkpoint$$ interfaces. -$lnext -There was a problem with the $cref cmake$$ command -if the $cref/cppad_cxx_flags/cmake/cppad_cxx_flags/$$ was not specified. -This has been fixed. -$lend - - -$head 05-17$$ -$list number$$ -Add the $cref/transpose/ForSparseJac/transpose/$$ option to -$cref/ForSparseJac/$$. -$lnext -Add the $cref/transpose/RevSparseHes/transpose/$$ option to -$cref/RevSparseHes/$$. -$lend - -$head 05-15$$ -Change $cref RevSparseJac$$ parameter names to be closer to the -$cref ForSparseJac$$ names so the difference is clearer. - -$head 05-14$$ -$list number$$ -The $cref checkpoint$$ class has been added. -This is a much easier way to do checkpointing than the -old checkpoint example. -The old checkpointing example is now the $cref reverse_checkpoint.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 -vector of $code bool$$. -$lnext -Add the $cref/transpose/RevSparseJac/transpose/$$ option to -$cref/RevSparseJac/$$. -$lend - -$head 05-12$$ -The sparse hessian example in $cref old_reciprocal.cpp$$ was not -being run. This has been fixed. - -$head 05-11$$ -The $cref/old_atomic examples/old_atomic/Example/$$ -names were all changed to begin with $code user$$. - -$head 05-04$$ -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 -with checkpointing as a particular application. -Multiple order forward mode is the first step in this direction. - -$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 -$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. -$lnext -The code $codei%std::cout << %X%$$, -would generate a compile error when $icode X$$ was an Eigen matrix -with $codei%CppAD::AD<%Base%>%$$ elements. -This has been fixed. -$lend - - -$head 04-27$$ -There was a problem using the output operator $code <<$$ with -and $cref/eigen/cppad_eigen.hpp/$$ matrix of $code AD$$ elements. -This has been fixed using a template partial specialization of -$codep - template - struct significant_decimals_default_impl -$$ -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. -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 -$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. -$lend - -$end - -$head 04-20$$ -The example $cref old_usead_1.cpp$$ was added. - -$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. - -$head 04-14$$ -The following program, -when executed, would cause a CppAD assertion with an unknown source: -$codep - # include - int main(void) - { size_t min_bytes = static_cast(-1); - size_t cap_bytes; - void *v_ptr = CppAD::thread_alloc::get_memory(min_bytes, cap_bytes); - return 0; - } -$$ -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 - Error detected by false result for - min_bytes < std::numeric_limits::max() / 2 -$$ - - -$head 03-02$$ -The function $cref/isnan/nan/$$ no longer allows for systems -that return false for $icode%x% != %x%$$ when $icode x$$ is $code NaN$$. -This makes the $code isnan$$ function faster. -In addition, it removes the need to store a static value -which causes complications for parallel execution (as well as other problems). -Thus, it is no longer necessary for the first call to $code isnan$$ -to be during sequential execution and it has been removed from the -multi-threading $cref/initialization/multi_thread/Initialization/$$ list. - -$head 03-01$$ -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 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. - -$head 02-20$$ -$list number$$ -The documentation for the $cref cmake$$ install option -$code cppad_test_vector_namespace$$ was fixed to be -$cref/cppad_testvector/cmake/cppad_testvector/$$. -This was also fixed for the -$cref/eigen test vector/eigen_prefix/Test Vector/$$ documentation. -$lnext -An option to specify that the compiler supports c++11 constructs, -$code cppad_c11_flag$$, was added -to the $code cmake$$ command line. -$lend -$head 01-07$$ -Fix undefined $code microsoft_timer$$ when building the -$cref speed_example.cpp$$ program. - -$head 01-06$$ -$list number$$ -The $cref limits$$ documentation was corrected an improved. -$lnext -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/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 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 -The $cref speed_example.cpp$$ was not linking when using a shared -object library for the code in $code speed/src$$. -This has been fixed by not including the library when linking -the speed examples. -$lend - -$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 -for download at -$pre - $$ -$href%http://www.coin-or.org/download/source/CppAD/%$$ -$lnext -Advance version number for trunk to $code 20130102$$. -$lend - -$head 01-01$$ -When compiling with $cref/NDEBUG/Faq/Speed/NDEBUG/$$ defined, -the following warning could be generated: -$codei% -%...%rev_sparse_jac.hpp:315:9: warning: unused variable 'm' [-Wunused-variable] -%$$ -This has been fixed. - - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_14.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_14.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_14.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_14.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,471 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_14$$ -$dollar @$$ -$spell - autotools - cstdint - addr - omhelp - autoconf - automake - alloc - ifndef - asin - acos - uj - op - hpp - taylor - forwardzero - forwardone - forwardany - const - doxygen - ipopt - adolc - colpack - Jacobian - openmp - pthread - bthread - isnan - onetape - retape - fadbad - sacado - boolsparsity - cmake - docdir - CppAD - cppad - datadir - erf - cmath - ctor - std - num -$$ - -$section CppAD Changes and Additions During 2014$$ - -$head Introduction$$ -This section contains a list of the changes to CppAD during 2014 -(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-30$$ -There was a bug in the $cref cmake$$ whereby it would sometimes mistakenly -exit with the error message -$codep - cppad_max_num_threads is not an integer greater than or equal 4 -$$ -This has been fixed. - -$head 12-29$$ -The example $code not_complex_ad.cpp$$ was using the type -$codei% - std::complex< CppAD::AD > -%$$ -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 -$cref/complex FAQ/faq/Complex Types/$$. - - -$head 12-28$$ -$list number$$ -Fix some warnings generated by clang 3.5 about local functions -that were not being used; e.g., sub-tests that were not being executed. -$lnext -Fix $code cmake$$ setting -$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. -This caused these tests to hang while trying to determine how -many times to repeat the test. -This has been fixed. -$lend - -$head 12-27$$ -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 -Hessian sparsity patterns $cref atomic_rev_sparse_hes.cpp$$ was added. - -$head 12-25$$ -More work on the bug in -$cref/optimizing/CondExp/Optimize/$$ -conditional expressions. - -$head 12-23$$ -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 -atomic operation. -$pre - -$$ -Fix typo in tangent reverse mode theory for -$cref/Positive Orders/tan_reverse/Positive Orders Z(t)/$$. - -$head 12-22$$ -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/autotools/autotools/$$ install procedure. - -$head 12-16$$ -If the $code c++11$$ include file $code $$ -defines all the standard types, they can be used by to specify -$cref/cppad_tape_addr_type/cmake/cppad_tape_addr_type/cstdint/$$ and -$cref/cppad_tape_id_type/cmake/cppad_tape_id_type/cstdint/$$. - -$head 12-15$$ -Correct the title and $cref _index$$ entries for $cref forward_two$$ -from first to second order. - -$head 11-28$$ -Improve the $cref/index/_index/$$ and $code search$$ using -a new version of the $code omhelp$$ documentation tool. - -$head 11-27$$ -$list number$$ -Add alignment to the -$cref/get_memory/ta_get_memory/Alignment/$$ and -$cref/create_array/ta_create_array/Alignment/$$ specifications -and -$cref/thread_alloc example/thread_alloc.cpp/$$. -$lnext -Advance the deprecated $cref/unix install/autotools/$$ utilities to -autoconf-2.69 and automake-1.13.4. -$lend - -$head 09-28$$ -Fix more bugs related to optimizing condition conditional expressions. -$list number$$ -Using old instead of new operator indices. -$lnext -Not properly following dependence back through atomic operations. -$lnext -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 -Reverse mode not properly handling the variable number of arguments in the -conditional skip operation. -$lnext -Reverse mode tracing not properly handling the variable number -of argument operations; i.e., conditional skip and cumulative summation. -$lend - -$head 09-27$$ -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 -$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 -$cref/any order reverse/reverse_any/$$. -To be specific, $latex x^{(k)}$$ was changed to be $latex u^{(k)}$$. - -$head 05-28$$ -$list number$$ -Change the $cref/boolsparsity/speed_main/Sparsity Options/boolsparsity/$$ -so that it only affects the sparsity speed tests -$cref/sparse_jacobian/link_sparse_jacobian/$$ and -$cref/sparse_hessian/link_sparse_hessian/$$; -i.e., it is now ignored by the other tests. -$lnext -Improve the $cref speed$$ documentation page. -$lend - -$head 05-27$$ -$list number$$ -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 because -$code cppad_colpack.cpp$$ is not an include file. -$lnext -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 autotools $cref/unix install/autotools/$$ instructions -to use the $cref cmake$$ install instructions. -These instructions should work on any system, not just unix. - -$head 05-22$$ -$list number$$ -Add multiple direction for mode -$cref forward_dir$$ and use it to speed up the forward -version of $cref sparse_jacobian$$. -Below is an example run of $cref cppad_sparse_jacobian.cpp$$ results -before this change: -$codep - cppad_sparse_jacobian_size = [ 100, 400, 900, 1600, 2500 ] - cppad_sparse_jacobian_rate = [ 2973, 431.94, 142.25, 78.64, 26.87 ] -$$ -and after this change: -$codep - 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, -$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. -$lend - -$head 05-20$$ -$list number$$ -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 -$code cppad/ipopt/solve_callback.hpp$$. -$lnext -Add $code # ifndef$$ command to $code test_more/extern_value.hpp$$. -$lend - - -$head 05-19$$ -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/$$. -These may have not be defined operations in certain cases and -have been converted to $code uj = Base(0)$$. - - -$head 05-16$$ -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 -$codei%cppad/local/%*%sweep.hpp/%$$). -This has been fixed. - -$head 05-14$$ -$list number$$ -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. -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 -$code BeginOp$$ was zero that caused an abort when using the undocumented -$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 -$cref/size_taylor/FunDeprecated/size_taylor/$$ -and -$cref/capacity_taylor/FunDeprecated/capacity_taylor/$$ -functions were deprecated; -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. -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 -$cref/move semantics/CppAD_vector/Assignment/Move Semantics/$$ -version of the $code CppAD::vector$$ assignment statement -was not checking vector sizes. -This has been fixed so that things work the same with compilers -that do not have move semantics. -(Note that with move semantics, no extra memory allocation is done -even if the target vector has a different size.) - -$head 03-09$$ -The documentation links -$code forwardzero$$, $code forwardone$$, and $code forwardany$$ -have been changed to -$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 -$cref/forward/forward_order/$$, -$cref/reverse/reverse_any/$$, -$cref atomic_forward$$, and -$cref atomic_reverse$$ functions -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. -Note that the set of available tests can depend on the -$cref/list of options/speed_main/Global Options/$$. -$lnext -In the documentation for -$cref/n_sweep/sparse_jacobian/n_sweep/$$, -mention that it is equal to the number of colors determined by the -$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 -$cref/optimize/speed_main/Global Options/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. -$lnext -$cref/Move semantics/CppAD_vector/Assignment/Move Semantics/$$ -were added to the $code CppAD::vector$$ assignment operator. -$lend - -$head 03-01$$ -$list number$$ -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 -Move $icode x$$ near end of $cref link_sparse_hessian$$ speed test -parameter list, -(as is the case for $cref link_sparse_jacobian$$). -$lend - -$head 02-28$$ -The $cref/data/CppAD_vector/data/$$ function was added to the -$code CppAD::vector$$ template class. - -$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$$. -This has been fixed. - -$head 02-26$$ -$list number$$ -The -$cref/adolc/speed_adolc/$$ and -$cref/cppad/speed_cppad/$$ sparse jacobian speed tests now print out -$cref/n_sweep/sparse_jacobian/n_sweep/$$. -$lnext -The size of some of the $cref speed$$ test cases has been increased -to test behavior for larger problems. -$lnext -A link to $cref ode_evaluate$$ was missing in the -$cref/Speed Utility Routines/speed_utility/Speed Utility Routines/$$ table. -This has been fixed. -$lend - - -$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/$$ -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 -$cref/sparse_hessian/link_sparse_hessian/$$ speed tests). - - -$head 02-22$$ -The program names in -$cref thread_test.cpp$$ where changes from -$icode%threading%_test%$$ to $codei%multi_thread_%threading%$$ -where $icode threading$$ is $code openmp$$, $code pthread$$ or $code bthread$$. - -$head 02-17$$ -Fix ambiguous call to $cref/isnan/nan/isnan/$$ -during MS Visual Studio 2012 compilation. - -$head 02-15$$ -$list number$$ -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 -$cref/onetape/speed_main/Global Options/onetape/$$ so that the default -is to retape (option not present). -This was done because -$cref/fadbad/fadbad_prefix/$$ and -$cref/sacado/sacado_prefix/$$ always retape. -$lnext -The documentation, and example source code, for all the speed -$cref/options/speed_main/Global Options/$$ was improved -(made clearer). -$lnext -Improve the success rate for -$cref speed_test.cpp$$ and $cref time_test.cpp$$. -$lend - -$head 01-26$$ -The destination directory for the -$cref/cppad documentation/cmake/cmake_install_docdir/$$ -is now set separately from the data directory -using the $code cmake$$ option -$codei% - -D cmake_install_docdir=%cmake_install_docdir% -%$$ -This has increased the flexibility of the documentation installation -and removed the need for the option -$codei% - -D cppad_documentation=%yes_or_no% -%$$ -which has been removed. - -$head 01-21$$ -The destination directory for the -cppad documentation -used to be one of the following: -$codei% - %prefix%/%datadir%/doc/cppad-%version% - %prefix%/%datadir%/doc/%postfix%cppad-%version% -%$$ -This has been changed by dropping the $icode version$$ number -at the end of the directory name. - -$head 01-10$$ -The change on $cref/2013-12-27/whats_new_13/12-27/$$ -caused a conversion error in $cref atan2$$ when it was used with -$code AD< AD >$$ arguments (and other similar cases). -This has been fixed. - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_15.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_15.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_15.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_15.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,933 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 - autotools - 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-31$$ -The $cref download$$ instructions were modified to have more mention of -using $cref/git/download/Source Code Control/Git/$$ and less mention of -$cref/subversion/download/Source Code Control/Subversion/$$. - -$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 autotools$$ install handling of the -deprecated files. -This included changing the autotools -$code --with-implicit_ctor$$ option to $cref autotools$$. -This was removed on -$cref/2017-02-10/whats_new_17/02-10/$$. - -$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 $code bool_sparsity.cpp$$ examples which show how -to conserve memory when computing sparsity patterns. -(This has since been replaced by $cref rc_sparsity.cpp$$.) -$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 item. -This has been done, -see $cref/no_print_for_op/optimize/options/no_print_for_op/$$. - -$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/autotools/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 - /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 $code example/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 autotools$$ 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 autotools$$ 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 -$cref/no_compare_op/optimize/options/no_compare_op/$$. - -$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/Global Options/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-2018.00.00.0/omh/appendix/whats_new/whats_new_16.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_16.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_16.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_16.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,481 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_16$$ -$spell - autotools - alloc - hpp - valgrind - uninitialized - adouble - CppAD - Eigen - std - namespace - cppad - Hes - Jac - mul - ifndef - xam - makefile - vy - inv - atanh - colpack - Wmisleading - gcc - sacado - chrono - const_iterator - op - mingw -$$ - -$section Changes and Additions to CppAD During 2016$$ - -$head Introduction$$ -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. - -$head 12-23$$ -Added a way for the user to determine what tests options are available; see -$cref/make check/cmake/make check/$$. - -$head 12-20$$ -Change the optimize $cref/examples/optimize/Examples/$$ to use -$cref NearEqual$$ for floating point tests (instead of exactly equal). -There were some other exactly equal floating point tests that were -failing on a $code mingw$$ system. Theses have also been fixed. - -$head 12-18$$ -Add the $cref/no_print_for_op/optimize/options/no_print_for_op/$$ to the -optimize routine. - -$head 12-13$$ -$list number$$ -Fix a bug in $cref ForSparseHes$$. To be more specific, -there was a bug in handling the cumulative summations operator in this -routine. This could only come up when used -an $cref/optimized/optimize/$$ $cref/f/ForSparseHes/f/$$, -$lnext -Add the -$cref/nest_conditional.cpp/optimize_nest_conditional.cpp/$$ example. -$lend - - -$head 12-11$$ -Improve the $cref optimize$$ documentation. -This includes making examples that demonstrate -specific aspects of the optimization; see -$cref/forward_active.cpp/optimize_forward_active.cpp/$$, -$cref/reverse_active.cpp/optimize_reverse_active.cpp/$$, -$cref/compare_op.cpp/optimize_compare_op.cpp/$$, -$cref/conditional_skip.cpp/optimize_conditional_skip.cpp/$$, -$cref/cumulative_sum.cpp/optimize_cumulative_sum.cpp/$$. - - -$head 12-09$$ -The $cref/options/optimize/options/$$ argument was added to the -optimize routine. - -$head 11-18$$ -Move classes and functions that are part of the user API from the -$code cppad/local$$ directory to the $code cppad/core$$ directory. -The remaining symbols, in the $code cppad/local$$ directory, are now -in the $code CppAD::local$$ namespace. -Note that a class in the $code CppAD$$ name space, may have a member -function that is not part of the user API. - -$head 11-14$$ -Increase the speed of the $code sparse_pack$$ class. -This improves the speed for -$cref/vector of boolean/glossary/Sparsity Pattern/Boolean Vector/$$ -sparsity pattern calculations. - -$head 11-13$$ -Merged in the $code sparse$$ branch which has $code const_iterator$$, -instead of $code next_element$$ for the -$code sparse_list$$ and $code sparse_pack$$ classes. -These classes are not part of the CppAD API and hence their specifications -can change (as in this case). -They can be used to get more efficient representations of -$cref/sparsity patterns/glossary/Sparsity Pattern/$$. - -$head 10-27$$ -The optional $cref/optimize/checkpoint/optimize/$$ option -was added to the checkpoint functions. - -$head 10-12$$ -$list number$$ -Change $cref elapsed_seconds$$ to use -$code std::chrono::steady_clock$$ instead of -$code std::chrono::high_resolution_clock$$. -$lnext -The test for C++11 features was failing on a Mac system -because the elapsed time was returning as zero (between two events). -This test has been made more robust by add a one millisecond sleep -between the two clock accesses. -$lend - - -$head 09-29$$ -The multiple directions version of -$cref/forward/forward_dir/$$ was missing $cref erf$$ function -in the case where C++ 2011 was supported; see -$href%https://github.com/coin-or/CppAD/issues/16%issue 16%$$. -This has been fixed. - -$head 09-27$$ -Change the implementation of $cref atomic_eigen_cholesky.hpp$$ so that -the computation of $latex M_k$$ exactly agrees with the corresponding -$cref/theory/cholesky_theory/$$. - -$head 09-26$$ -$list number$$ -A possible bug in the $cref optimize$$ command was fixed. -To be specific, a warning of the form -indentations; -$codei% - warning: this 'if' clause does not guard... [-Wmisleading-indentation] -%$$ -using the gcc-6.2.1 compiler, was fixed and it may have fixed a bug. -$lnext -There was a problem with the -$cref/sacado/speed_sacado/$$ where the symbol -$code HAS_C99_TR1_CMATH$$ was being defined twice. -This has been fixed by leaving it up to the sacado install to determine -if this symbol should be defined. -$lend - -$head 09-16$$ -Fix a problem using the -$cref/colpack/speed_main/Sparsity Options/colpack/$$ option to the -$code speed_cppad$$ program. -(There was a problem whereby the $code speed_cppad$$ -program did not properly detect when $code colpack$$ was available.) - -$head 09-13$$ -Test third order and fix -bug in $cref atomic_eigen_cholesky.hpp$$ for orders greater -than or equal to three. - -$head 08-30$$ -Add the $cref atomic_eigen_cholesky.cpp$$ example. - -$head 08-25$$ -$list number$$ -Fix some missing include files in -$code optimize.hpp$$ and $code set_union.hpp$$ -(when compiling with MS Visual Studio 2015). -$lnext -Fix a warning in $code atanh.hpp$$ -(when compiling with MS Visual Studio 14). -$lnext -Fix a typo in the -$cref/Reverse/atomic_eigen_mat_inv.hpp/Theory/Reverse/$$ section of the -$code eigen_mat_inv.hpp$$ example. -$lend - -$head 07-17$$ -Add documentation for only needing to compute a -$cref/column subset/sparse_hessian/p/Column Subset/$$ of the sparsity -pattern when computing a subset of a sparse Hessians. -In addition, improve the corresponding example -$cref sparse_sub_hes.cpp$$. - -$head 07-14$$ -Correct title in $cref ForSparseHes$$ (change Reverse to Forward). - -$head 06-30$$ -Change the $cref atomic_mat_mul.cpp$$ example so that on atomic object -works for matrices of any size. - -$head 06-29$$ -Change the $cref atomic_base$$ examples so they do no longer use the -deprecated $cref/atomic function/deprecated/Atomic Functions/$$ interfaces to -$code for_sparse_jac$$, $code rev_sparse_jac$$, -$code for_sparse_hes$$, and $code rev_sparse_hes$$. - -$head 06-27$$ -$list number$$ -Improve the $cref atomic_eigen_mat_mul.hpp$$ and -$cref atomic_eigen_mat_inv.hpp$$ examples. -Most importantly, one atomic object now works for matrices of any size. -$lnext -Add the vector $icode x$$, -that contains the parameters in an atomic function call -to the user following atomic functions: -$cref/for_sparse_jac/atomic_rev_sparse_jac/Implementation/x/$$, -$cref/rev_sparse_jac/atomic_rev_sparse_jac/Implementation/x/$$, -$cref/for_sparse_hes/atomic_rev_sparse_jac/Implementation/x/$$, -$cref/rev_sparse_hes/atomic_rev_sparse_jac/Implementation/x/$$. -This enables one to pass parameter information to these functions; e.g., -the dimensions of matrices that the function operates on. -$lend - - -$head 06-25$$ -Add more entries to the optimization -$cref/wish_list/wish_list/Optimization/$$. - -$head 06-10$$ -Add a $cref/check_finite/wish_list/check_finite/$$ wish list item. - -$head 05-05$$ -$list number$$ -Add documentation for -$cref/redirecting output/PrintFor/Redirecting Output/$$ for the -$code PrintFor$$ function. -$lnext -Change distributed version to build examples as debug instead -of release version. -(Was changed to release version while checking for compiler warnings; -see $code 04-17$$ below). -$lend - -$head 04-17$$ -Fix all some compiler warnings that occurred when compiling the -$cref/examples/Example/$$ with -$cref/NDEBUG/faq/Speed/NDEBUG/$$ defined. - -$head 03-27$$ -$list number$$ -Fix a bug in the calculation of the $cref atomic_eigen_mat_inv.hpp$$ -$cref/reverse/atomic_eigen_mat_inv.hpp/Private/reverse/$$ example. -$lnext -Use a very simple method (that over estimates variables) for calculating -$cref/vy/atomic_forward/vy/$$ in the $cref atomic_eigen_mat_inv.hpp$$ -$cref/forward/atomic_eigen_mat_inv.hpp/Private/forward/$$ example. -$lend - -$head 03-26$$ -$list number$$ -Implement and test the $cref atomic_eigen_mat_inv.cpp$$ -$cref/reverse/atomic_eigen_mat_inv.hpp/Private/reverse/$$ is implemented. -$lnext -Fix a bug in the calculation of -$cref/vy/atomic_forward/vy/$$ in the $cref atomic_eigen_mat_inv.hpp$$ -$cref/forward/atomic_eigen_mat_inv.hpp/Private/forward/$$ example. -$lend - - -$head 03-25$$ -$list number$$ -Start construction of the $cref atomic_eigen_mat_inv.cpp$$ example, -currently only -$cref/forward/atomic_eigen_mat_inv.hpp/Private/forward/$$ is implemented -and tested. -$lnext -More improvements to $cref atomic_eigen_mat_mul.cpp$$ example. -$lend - -$head 03-24$$ -$list number$$ -Fix build of $code example/atomic.cpp$$ when -$cref eigen_prefix$$ is not available -(bug introduced when $cref atomic_eigen_mat_mul.cpp$$ was added). -$lnext -Extend $cref atomic_eigen_mat_mul.cpp$$ example to include -$cref/for_sparse_jac/atomic_eigen_mat_mul.hpp/Private/for_sparse_jac/$$, -$cref/rev_sparse_jac/atomic_eigen_mat_mul.hpp/Private/rev_sparse_jac/$$, -$cref/for_sparse_hes/atomic_eigen_mat_mul.hpp/Private/for_sparse_hes/$$, -$cref/rev_sparse_hes/atomic_eigen_mat_mul.hpp/Private/rev_sparse_hes/$$. -$lnext -Fix a bug in the $cref ForSparseHes$$ routine. -$lnext -Edit $cref atomic_rev_sparse_hes$$ documentation. -$lend - -$head 03-23$$ -$list number$$ -Fix bug in autotools file $code example/atomic/makefile.am$$ -(introduced on 03-22). -$lnext -Improve the $cref atomic_eigen_mat_mul.cpp$$ example -and extend it to include reverse mode. -$lend - -$head 03-22$$ -$list number$$ -Start construction of the $cref atomic_eigen_mat_mul.cpp$$ example. -$lnext -change $code atomic_ode.cpp$$ to $cref checkpoint_ode.cpp$$ and -$code atomic_extended_ode.cpp$$ to $cref checkpoint_extended_ode.cpp$$. -$lend - -$head 03-21$$ -Change the $cref atomic_mat_mul.hpp$$ class name from $code mat_mul$$ -to $code atomic_mat_mul$$. This example use of the name $code mat_mul$$ -in the $cref atomic_mat_mul.cpp$$ example / test. - -$head 03-20$$ -$list number$$ -Include the sub-directory name to the include guards -in $icode%*%.hpp%$$ files. For example, -$codep - # ifndef CPPAD_UTILITY_VECTOR_HPP - # define CPPAD_UTILITY_VECTOR_HPP -$$ -appears in the file $code cppad/utility/vector.hpp$$. This makes it -easier to avoid conflicts when choosing $cref addon$$ names. -$lnext -Add the $cref set_union$$ utility and use it to simplify the -$cref atomic$$ examples that use -$cref/vector of sets/glossary/Sparsity Pattern/Vector of Sets/$$ -sparsity patterns. -$lend - - -$head 03-19$$ -$list number$$ -Move $cref atomic_mat_mul.cpp$$ to $code atomic_mat_mul_xam.cpp$$ -(moved back on $cref/03-21/whats_new_16/03-21/$$. -$lnext -Move $code atomic_matrix_mul.hpp$$ to $cref atomic_mat_mul.hpp$$. -$lend - -$head 03-17$$ -Add the -$code atomic_ode.cpp$$ and $code atomic_extended_ode.cpp$$ examples. - -$head 03-12$$ -$list number$$ -Move the example $code reverse_any.cpp$$ to $cref reverse_checkpoint.cpp$$. -$lnext -Add the $cref atomic_mul_level.cpp$$ example. -$lend - -$head 03-05$$ -The following atomic function examples were added -These examples are for a specific atomic operation. -In addition, the domain and range dimensions for these examples -are not one and not equal to each other: -$cref atomic_forward.cpp$$, -$cref atomic_reverse.cpp$$, -$cref atomic_for_sparse_jac.cpp$$, -$cref atomic_rev_sparse_jac.cpp$$, -$cref atomic_for_sparse_hes.cpp$$, -$cref atomic_rev_sparse_hes.cpp$$. - - -$head 03-01$$ -$list number$$ -Improve documentation of implementation requirements for the atomic -$cref/rev_sparse_jac/atomic_rev_sparse_jac/Implementation/$$. -$lnext -Make some corrections to the $cref atomic_for_sparse_hes$$ documentation. -and fix a bug in how CppAD used these functions. -$lend - -$head 02-29$$ -$list number$$ -Merged sparse into master branch. This makes the -$cref ForSparseHes$$ routine available for use. -$lnext -Changed the -$cref/global options/speed_main/Global Options/$$ -in the speed test main program to use one global variable with prototype -$srccode%cpp% - extern std::map global_option; -%$$ -$lend - - -$head 02-28$$ -Fix a mistake in the old atomic -$code example/sparsity/sparsity.cpp$$ example. -This example has since been changed to -$cref atomic_set_sparsity.cpp$$. - - -$head 02-27$$ -The $code --with-sparse_set$$ and $code --with-sparse_set$$ options -were removed from the $cref autotools$$ install procedure. - -$head 02-26$$ -The condition that the operation sequence in $icode f$$ is -$cref/independent/glossary/Operation/Independent/$$ of -the independent variables was added to the statement about -the validity of the sparsity patterns; see $icode x$$ in -$cref/ForSparseJac/ForSparseJac/x/$$, -$cref/RevSparseJac/RevSparseJac/x/$$, and -$cref/RevSparseHes/RevSparseHes/x/$$. - -$head 02-25$$ -The $cref cmake$$ command line argument $code cppad_sparse_list$$ -has been removed (because it is so much better than the other option). - -$head 02-23$$ -A new version of the -$code cppad_sparse_list$$ class (not part of user API) uses -reference counters to reduce the number of copies of sets that are equal. -This improved the speed of sparsity pattern computations that use -the $cref/vector of sets/glossary/Sparsity Pattern/Vector of Sets/$$ -representation. -For example, the results for the -$cref cppad_sparse_hessian.cpp$$ test compare as follows: -$codep - sparse_hessian_size = [ 100, 400, 900, 1600, 2500 ] - sparse_hessian_rate_old = [ 1480, 265.21, 93.33, 41.93, 0.86 ] - sparse_hessian_rate_new = [ 1328, 241.61, 92.99, 40.51, 3.80 ] -$$ -Note that the improvement is only for large problems. In fact, -for large problems, preliminary testing indicates that -the new vector of sets representation preforms better than -the $cref/vector of boolean/glossary/Sparsity Pattern/Boolean Vector/$$ -representation. - - -$head 01-21$$ -Fix a $code valgrind$$ warning about use of uninitialized memory -in the test $code test_more/checkpoint.cpp$$ (the problem was in the test). - -$head 01-20$$ -$list number$$ -Fix a $code valgrind$$ warning about use of uninitialized memory -when using the $cref/adouble/base_adolc.hpp/$$ base type. -This required an optional $cref base_hash$$ function and the special -$cref/adouble hash_code/base_adolc.hpp/hash_code/$$ implementation. -$lnext -The $code adouble$$ $cref to_string$$ functions -required a special implementation; see -$cref/adouble to_string/base_adolc.hpp/to_string/$$. -$lnext -Add the $cref/to_string/base_alloc.hpp/to_string/$$ and -$cref/hash_code/base_alloc.hpp/hash_code/$$ examples -to the $code base_alloc.hpp$$ example. -$lend - -$head 01-18$$ -$list number$$ -Fix ambiguity between $code CppAD::sin$$ and $code std::sin$$, -and other standard math functions, -when using -$codep - using namespace std; - using namespace CppAD; -$$ -This is OK for simple programs, but not generally recommended. -See $code double$$ version of base class definitions for -$cref/Unary Standard Math/base_double.hpp/Unary Standard Math/$$ -for more details. -$lnext -Change Eigen array example -$cref eigen_array.cpp$$ -to use member function version of $code sin$$ function -(as per Eigen's array class documentation). -$lend - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_17.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_17.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new_17.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new_17.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,652 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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_17$$ -$spell - const - Perl - CppAD - doxygen - cppad - hpp - bool - Jacobian - Jacobians - jac - hes - eigen - mul - rc - rcv - omhelp - valgrind - uninitialised - deallocations - sacado - typedef - plugin - gcc - readme - autotools - ipopt - colpack - Wconversion - xq - boolofvoid - namespace - cxx - uninitialized - cmake - op - sizeof - addr - subsparsity - subgraph - optimizer - subgraphs -$$ - -$section Changes and Additions to CppAD During 2017$$ - -$head API Changes$$ -Speed tests no longer automatically compile in release mode; see -$cref/debug_which/speed/debug_which/$$ - -$head 12-14$$ -Add the $cref subgraph_hes2jac.cpp$$ example -which computes sparse Hessians using subgraphs and Jacobians. - -$head 12-08$$ -$list number$$ -A wish list item for a -$cref/new API/wish_list/Atomic/New API/$$ for -user defined $cref/atomic/atomic_base/$$ functions. -$lnext -A $cref/multi-threading/wish_list/Multi-Threading/$$ -wish list item was added. -$lend - -$head 12-06$$ -A $cref wish_list$$ item to enable one to iterate through a -$code const$$ $cref ADFun$$ operation sequence was completed. -In addition, the $cref/f/abs_normal_fun/f/$$ argument to the -$code abs_normal$$ operation was converted to be $code const$$. - - -$head 12-05$$ -The internal data object used to represent sparsity patterns as -vectors of integers was improved; -see $cref/internal_bool/for_jac_sparsity/internal_bool/$$ -in $code for_jac_sparsity$$ and other -$cref/preferred sparsity pattern/sparsity_pattern/Preferred Sparsity Patterns/$$ -routines. - -$head 12-04$$ -Back out the $code hold_reverse_memory$$ option. - -$head 12-01$$ -The $code hold_reverse_memory$$ option was added. - -$head 11-30$$ -Edit the $cref download$$ instructions. - -$head 11-23$$ -The $code ADFun$$ function $cref/optimizer/optimize/$$ -was not handling hash code collisions properly. -To be specific, only the arguments -that were variables where checked for a complete match. -The arguments that are constants need to also be checked. -This has been fixed. - -$head 11-20$$ -$list number$$ -Add the $cref subgraph_jac_rev$$ method for computing -sparse Jacobians. -$lnext -Add the $cref/subgraph/speed_main/Global Options/subgraph/$$ option -to the CppAD speed tests. -$lend - -$head 11-19$$ -Add the $cref subgraph_reverse$$ method for computing -sparse derivatives. -This was inspired by the -$href%https://cran.r-project.org/web/packages/TMB/index.html%TMB%$$ package. - - -$head 11-15$$ -$list number$$ -Add wish list item for $cref subgraph_sparsity$$ when -$cref/atomic functions/wish_list/Atomic/Subgraph/$$ -are present. -$lnext -Fix $cref cmake_check$$ when $cref ipopt_prefix$$ is not present on the -$cref cmake$$ command line -(make was trying to build some of the ipopt tests). -$lend - -$head 11-13$$ -$list number$$ -Add the $cref/hes2jac/speed_main/Global Options/hes2jac/$$ option -to the CppAD speed tests. -$lnext -Implement the -$cref/subsparsity/speed_main/Sparsity Options/subsparsity/$$ option -for the CppAD $cref/sparse_hessian/link_sparse_hessian/$$ test. -$lnext -Fix detection of invalid options in the speed test programs; see the -$cref/global/speed_main/Global Options/$$ and -$cref/sparsity/speed_main/Sparsity Options/$$ options. -$lend - -$head 11-12$$ -Add the $cref/subsparsity/speed_main/Sparsity Options/subsparsity/$$ option -to the CppAD speed tests. - -$head 11-08$$ -Add the $cref subgraph_sparsity$$ method for computing -dependency and sparsity. -This was inspired by the -$href%https://cran.r-project.org/web/packages/TMB/index.html%TMB%$$ package. - - -$head 11-06$$ -More information has been added to the operation sequence. -To be specific, the extra amount of -$codei% - %f%.size_op() * sizeof(%tape_addr_type) -%$$ -was added to the value returned by -$cref/size_op_seq/seq_property/size_op_seq/$$. - -$head 11-04$$ -The method for iterating through the tape has been changed. -It now includes an extra data structure that makes it faster, -but also requires slightly more memory. To be specific, the term -$codei% - %f%.size_op() * sizeof(%tape_addr_type) * 2 -%$$ -was added to the value returned by -$cref/size_op_seq/seq_property/size_op_seq/$$. -In addition, some minor corrections were made to the -$cref/tape_addr_type/cmake/cppad_tape_addr_type/$$ -requirements. - -$head 10-23$$ -$list number$$ -Require $code cmake.3.1$$ or greater and fix -a cmake warning by always using the new $code CMP0054$$ policy. -$lnext -Fix a $code g++ 7.2.1$$ warning about a possibly uninitialized value -in the file $code cppad/local/optimize/hash_code.hpp$$. -$lend - -$head 09-16$$ -An $cref/optimization memory/wish_list/Optimization/Memory/$$ entry -was added to the wish list -and the $cref/check_finite/wish_list/check_finite/$$ entry was modified. - -$head 08-30$$ -$list number$$ -If $cref colpack_prefix$$ was not specified, one would get the following -waring during the $cref cmake$$ command: -$codei% - Policy CMP0046 is not set: Error on non-existent dependency in -%$$ -This has been fixed by not adding the dependency when it is not needed. -$lnext -There was a problem running $cref/make check/cmake_check/$$ -when $cref/cppad_cxx_flags/cmake/cppad_cxx_flags/$$ was not specified. -This has been fixed. -This was probably introduced on $cref/05-29/whats_new_17/05-29/$$. -$lend - - -$head 08-29$$ -There was a problem on some systems that created an error when -specializing the $code is_pod$$ template function in the -$code CppAD::local$$ namespace. -This has been fixed by testing for compatibility at during the -$cref cmake$$ command and creating the file $code cppad/local/is_pod.hpp$$. - - -$head 08-09$$ -Add the $cref/test_boolofvoid/wish_list/test_boolofvoid/$$ -wish list item. - -$head 08-08$$ -$list number$$ -The $cref eigen_plugin.hpp$$ was put back in the -$cref cppad_eigen.hpp$$ definitions. -This makes CppAD incompatible with older versions of eigen; e.g., eigen-3.2.9. -The plugin was removed on $cref/05-12/whats_new_17/05-12/$$. -$lnext -Fix some minor typos in the documentation. -To be specific: -The font, in the $cref sparse_rc$$ and $cref sparse_rcv$$ syntax, -for the text -$codei% - %target% = %pattern% -%$$ -The font, in $cref capacity_order$$, for the text -$codei% - %xq%.size() == %f%.Domain() -%$$ -Remove a percent sign $code %$$, in $cref CppAD_vector$$, in the text -$codei% - # include -%$$ -$lend - -$head 07-25$$ -$list number$$ -Fix warnings related to type conversions that -occurred when one used $code -Wconversion$$ with -$code g++$$ version 6.3.1. -$lnext -The warning were not fixed for complex AD types; e.g., -$cref complex_poly.cpp$$. -The $cref wno_conversion$$ include file was added to deal with -cases like this. -$lend - -$head 07-03$$ -$list number$$ -The $cref min_nso_linear$$ abs-normal example was added. -$lnext -Fix bug in $cref abs_normal_fun$$, to be specific, the multiplication -of a variable on the left by a parameter was not handled. -$lend - -$head 07-01$$ -the $cref abs_normal$$ examples were converted from using -quadratic programming problems to using linear programming problems. - -$head 06-28$$ -The $cref/abs-normal/abs_normal_fun/$$ -representation of non-smooth functions has been added. -Examples and utilities that use this representation have also been included, -see $cref abs_normal$$. - -$head 06-11$$ -The user atomic functions base class $cref atomic_base$$ -makes more of an effort to avoid false sharing cache misses. -This may the speed of multi-threaded applications with user atomic functions; -e.g., see $cref multi_atomic.cpp$$. - -$head 06-10$$ -$list number$$ -Add the multi-threading user atomic function example -$cref multi_atomic.cpp$$. -$lnext -The $code example/multi_thread/test_multi$$ directory used -to have an example using the deprecated -$cref old_atomic$$ functions in a multi-threading setting -(that only built with the deprecated $cref autotools$$). -This have been removed. -$lend - -$head 06-07$$ -The multi-threading examples -$cref harmonic.cpp$$ and $cref multi_newton.cpp$$ were re-organized. -To be specific, the source code for each example was moved to one file. -In addition, for each example, -the documentation for each of the routines has been separated -and placed next to its source code. - -$head 06-04$$ -Most all the $cref deprecated$$ features have been removed -from the examples with the exception of those in the -$code example/deprecated$$ directory. - -$head 06-03$$ -Add the fact that the pair -($icode row$$, $cref/col/link_sparse_hessian/col/$$) -is lower triangular to the speed test -$code link_sparse_hessian$$ routine. - - -$head 06-01$$ -$list number$$ -There was a bug in the -$cref sparse_hes$$ routine and it was using the general coloring algorithm when -$cref/cppad.symmetric/sparse_hes/coloring/cppad.symmetric/$$ was specified. -This has been fixed and improves the efficiency in this case. -$lnext -Some bugs were fixed in the use of -$cref/colpack/colpack_prefix/$$ as the coloring algorithm for -sparse Jacobian and Hessian calculations. -This has improved the efficiency of Colpack colorings for computing Hessians -(when $code colpack.symmetric$$ is used). -$lnext -The $code colpack.star$$ coloring method for sparse Hessians has -been deprecated; see -$cref/sparse_hes/sparse_hes/coloring/colpack.star Deprecated 2017-06-01/$$ -and -$cref/sparse_hessian - /sparse_hessian - /work - /colpack.star Deprecated 2017-06-01 -/$$. -Use the $code colpack.symmetric$$ method instead; see -$cref/sparse_hes/sparse_hes/coloring/colpack.symmetric/$$ and -$cref/sparse_hes/sparse_hes/coloring/colpack.general/$$. -$lend - -$head 05-29$$ -$list number$$ -Add the capability to compile so that CppAD debug and release mode -can be mixed; see -$cref/CPPAD_DEBUG_AND_RELEASE - /preprocessor - /Documented Here - /CPPAD_DEBUG_AND_RELEASE -/$$. -$lnext -Add the $cref/cppad_debug_which/cmake/cppad_debug_which/$$ flags -that determines which files are compiled for debugging versus release -during the CppAD testing; see $cref cmake_check$$. -$lnext -There was a problem linking the proper libraries for using newer versions of -$cref/sacado/sacado_prefix/$$. -This has been fixed. -$lend - -$head 05-19$$ -Most all the examples have been moved to $code example$$ directory -and grouped as sub-directories; e.g., the $cref ipopt_solve$$ examples -are in the $code example/ipopt_solve$$ directory. - -$head 05-14$$ -$list number$$ -The file $code build.sh$$ was moved to $code bin/autotools.sh$$, -and `auto tools' has been changed to $cref autotools$$. -$lnext -The README file was replace by readme.md -and AUTHORS was moved to authors. -$lnext -The NEWS, INSALL, and ChangeLog files -are no longer necessary for autotools build and have been removed. -$lnext -The file test_more/sparse_jacobian.cpp generated a warning -under some gcc compiler options. -This has been fixed. -$lnext -Specifications were added so that $cref to_string$$ yields exact results -for integer types and machine precision for floating point types. -$lnext -Some editing was done to the $cref autotools$$ instructions. -$lend - -$head 05-12$$ -$list number$$ -The $cref Faq$$ has been updated. -$lnext -Remove includes of $code cppad/cppad.hpp$$ from the -$codei%cppad/speed/%*%.hpp%$$ files. -This avoids an incompatibility between sacado and newer versions of eigen, -when eigen is used for the -$cref/test vector/testvector/Eigen Vectors/$$. -$lnext -The $cref/eigen/eigen_prefix/$$ package changed its requirements for -defining Scalar types -(some where between eigen-3.2.9 and eigen-3.3.3). -The member variable -$cref/digit10/numeric_limits/digits10/$$ was added to the -$code numeric_limits$$ to accommodate this change. -$lnext -Note that this fix required adding $code digits10$$ to the -user defined $icode Base$$ type -$cref/requirements/base_require/$$; see -$cref base_limits$$. -$lnext -In addition, it is no longer necessary to add the typedef -$codei% - typedef Scalar value_type; -%$$ -so the file $code cppad/example/eigen_plugin.hpp$$ has been removed. -(This type definition was previously necessary for eigen vectors -to be $cref/simple vectors/SimpleVector/$$.) -$lend - -$head 04-08$$ -The $cref/optimization/optimize/$$, with a large number of -$cref/conditional expressions/CondExp/$$, was performing many -memory allocations and deallocations. This has been reduced. - - -$head 04-02$$ -Fix a bug in the optimization of conditional expressions; see, -$cref/no_conditional_skip/optimize/options/no_conditional_skip/$$. - -$head 03-31$$ -Fix some $code valgrind$$ errors that occurred while running the CppAD -test set. - -$head 03-29$$ -The following valgrind error might occur when the optimize skipped -setting values that did not affect the dependent variables: -$codei% - Conditional jump or move depends on uninitialised value(s) -%$$ -This was not a bug, the code has been changed to avoid this error -in order to make it easier to use valgrind with CppAD. - -$head 03-25$$ -$list number$$ -The $cref sparse_hes$$ function was more efficient if -there were more entries in each row of the requested -$cref/subset/sparse_hes/subset/$$. This has been changed -to more entries in each column, and documentation to this effect -was included. -$lnext -The $cref optimize$$ routine was using to much memory when -it was optimizing conditional skip operations; see -$cref/no_conditional_skip/optimize/options/no_conditional_skip/$$. -This has been fixed. -$lend - -$head 03-20$$ -There was a mistake in $cref sparse_jac$$ that caused the -following assert to mistakenly occur: -$codep -sparse_jac_rev: work is non-empty and conditions have changed -Error detected by false result for - color.size() == 0 || color.size() == n -$$ -A test that using a previously stores work vector -has been added to $cref sparse_jac_rev.cpp$$ -and this bug has been fixed. - -$head 03-13$$ -The documentation for the Hessian in $cref rev_hes_sparsity$$ was -transposed; i.e., the sense of -$cref/transpose/rev_hes_sparsity/transpose/$$ was reversed. - -$head 03-11$$ -Add sparse assignment statements; see $icode target$$ for -$cref/sparse_rc/sparse_rc/target/$$ and -$cref/sparse_rcv/sparse_rcv/target/$$. - -$head 03-10$$ -Add the a sizing constructor to the -$cref/sparse_rc syntax/sparse_rc/Syntax/$$; i.e., -a constructor that sets the number of row, number of columns, -and number of possibly non-zero values in the sparsity pattern. - -$head 03-06$$ -Fix a bug in the sparsity computation using the -internal representation for -$cref/vectors of sets/glossary/Sparsity Pattern/Vector of Sets/$$; -i.e., when $icode internal_bool$$ was false in -any of the $cref sparsity_pattern$$ calculations; e.g., -$cref/for_jac_sparsity/for_jac_sparsity/internal_bool/$$. - -$head 03-04$$ -Fix a bug in the optimization of conditional expressions; -see $cref/no_conditional_skip/optimize/options/no_conditional_skip/$$. - -$head 02-26$$ -$list number$$ -Fix warning during $cref cmake$$ command, -on $href%https://www.cygwin.com/%cygwin%$$ systems, -about $code WIN32$$ not being defined. -$lnext -Add $cref/element-wise operations/wish_list/Atomic/Element-wise Operations/$$ -to the wish list. -$lend - -$head 02-21$$ -$list number$$ -Minor improvements to syntax and documentation for -$cref sparse_rc$$ and $cref sparse_rcv$$. -$lnext -Separate preferred sparsity versions in -$cref sparsity_pattern$$ and $cref sparse_derivative$$. -$lend - -$head 02-19$$ -$list number$$ -Remove the $code bool_sparsity.cpp$$ example and -add the $cref rc_sparsity.cpp$$ example. -$lnext -Check for duplicate entries during -$cref/row_major/sparse_rc/row_major/$$ and $code col_major$$ in -$code sparse_rc$$. -$lend - -$head 02-15$$ -Fix bug when using $cref ForSparseHes$$ with atomic functions; i.e., -$cref atomic_for_sparse_hes$$. - -$head 02-13$$ -Improve $cref/for_sparse_jac/atomic_eigen_mat_mul.hpp/Private/for_sparse_jac/$$ -calculation in $code eigen_mat_mul.hpp$$ example. -It now checks for the parameter zero and does not propagate any sparsity -in this case (because the result is always zero). - -$head 02-11$$ -$list number$$ -Remove the 'Under Construction' heading from the -$cref sparse_rc$$ and $cref sparse_rcv$$ documentation; i.e., -they are ready for public use (part of the CppAD API). -$lnext -Fix some warning that occur when using -$cref/eigen/cppad_testvector/eigen/$$ for the CppAD test vector. -(The Eigen vector $code size()$$ function -returns an $code int$$ instead of $code size_t$$.) -$lnext -Fix a bug in $cref/sparse_jac_rev/sparse_jac/$$. -$lend - -$head 02-10$$ -$list number$$ -The subset of deprecated features corresponding to -$cref/cppad_deprecated=YES/cmake/cppad_deprecated/$$ -have been completely removed. -$lnext -Fix problems with $cref autotools$$ build -(started near 02-01 while working on sparsity branch). -$lnext -Reorder (better organize) the $cref ADFun$$ documentation section. -$lend - -$head 02-09$$ -$list number$$ -Remove the sparsity pattern wish list item. -For sparsity patterns, this was completed by -$cref sparse_rc$$ and the sparsity pattern routines that used it; -e.g., $cref for_jac_sparsity$$. -For sparse matrices, it was completed by -$cref sparse_rcv$$ and the sparse matrix routines that use it; e.g., -$cref sparse_jac$$. -$lnext -Add the Deprecated and -$cref/example/wish_list/Example/$$ items to the wish list. -(The Deprecated item was partially completed and partially removed.) -$lend - -$head 02-08$$ -$list number$$ -Make coloring a separate argument to -$cref/sparse_jac/sparse_jac/coloring/$$ and -$cref/sparse_hes/sparse_hes/coloring/$$. -$lnext -Add the -$cref/group_max/sparse_jac/group_max/$$ -argument to the $code sparse_jac_for$$ function. -$lend - -$head 02-05$$ -$list number$$ -Add the $cref/sparse_jac_for/sparse_jac/$$ routine -which uses $cref sparse_rc$$ sparsity patterns -and $cref sparse_rcv$$ matrix subsets. -$lnext -Order for $cref sparse_rc$$ row-major and column-major was switched. -This has been fixed. -$lend - -$head 02-03$$ -Add the -$cref rev_jac_sparsity$$ -$cref rev_hes_sparsity$$, and -$cref for_hes_sparsity$$ interfaces to sparsity calculations. -These use $cref sparse_rc$$ sparsity patterns. - -$head 02-02$$ -Change $cref/size_forward_bool/for_jac_sparsity/f/size_forward_bool/$$ and -Change $cref/size_forward_set/for_jac_sparsity/f/size_forward_set/$$ -so that they are a better approximation of the number of bytes -(unsigned characters) being used. -The exact same sparsity pattern might use different memory -in two different function objects (because memory is allocated in chunks). -The $cref fun_assign.cpp$$ example has been changed to reflect this fact. - -$head 02-01$$ -Add the $cref for_jac_sparsity$$ interface for the sparse Jacobian calculations. -This is the first use of $cref sparse_rc$$, -a sparsity pattern class that uses row and column -$cref/index vectors/glossary/Sparsity Pattern/Row and Column Index Vectors/$$. - -$head 01-30$$ -Move the $cref sparsity_pattern$$ examples from $code example$$ -to $code example/sparse$$ subdirectory. -This included the sparse $cref/driver/drivers/$$ examples. - -$head 01-29$$ -Move the $cref utility$$ examples from $code example$$ -to $code example/utility$$ subdirectory. - -$head 01-27$$ -Add a $cref addon$$ link to -$href%http://www.seanet.com/~bradbell/cppad_swig%cppad_swig%$$, -a C++ AD object library and swig interface to Perl, Octave, and Python. - -$head 01-19$$ -Convert more examples / tests to use a multiple of machine epsilon -instead of $code 1e-10$$. - -$head 01-18$$ -$list number$$ -Fix developer -$href%https://www.coin-or.org/CppAD/Doc/doxydoc/html/%doxydoc%$$ -documentation so that it works with newer version of doxygen. -$lnext -Fix a Visual C++ 2015 compilation problem in friend declarations -in the file $code cppad/local/ad_tape.hpp$$. -$lend - -$head 01-17$$ -Change computed assignment to -$cref/compound assignment/compound_assign/$$. - -$end diff -Nru cppad-2018.00.00.0/omh/appendix/whats_new/whats_new.omh cppad-2019.02.00.0/omh/appendix/whats_new/whats_new.omh --- cppad-2018.00.00.0/omh/appendix/whats_new/whats_new.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/whats_new/whats_new.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,20 +1,21 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin whats_new$$ $spell - CppAD - Eigen - std - namespace + CppAD + Eigen + std + namespace $$ $section Changes and Additions to CppAD$$ @@ -26,27 +27,31 @@ assist you in learning about changes between various versions of CppAD. $children% - omh/appendix/whats_new/whats_new_17.omh% - omh/appendix/whats_new/whats_new_16.omh% - omh/appendix/whats_new/whats_new_15.omh% - omh/appendix/whats_new/whats_new_14.omh% - omh/appendix/whats_new/whats_new_13.omh% - omh/appendix/whats_new/whats_new_12.omh% - omh/appendix/whats_new/whats_new_11.omh% - omh/appendix/whats_new/whats_new_10.omh% - omh/appendix/whats_new/whats_new_09.omh% - omh/appendix/whats_new/whats_new_08.omh% - omh/appendix/whats_new/whats_new_07.omh% - omh/appendix/whats_new/whats_new_06.omh% - omh/appendix/whats_new/whats_new_05.omh% - omh/appendix/whats_new/whats_new_04.omh% - omh/appendix/whats_new/whats_new_03.omh + omh/appendix/whats_new/19.omh% + omh/appendix/whats_new/18.omh% + omh/appendix/whats_new/17.omh% + omh/appendix/whats_new/16.omh% + omh/appendix/whats_new/15.omh% + omh/appendix/whats_new/14.omh% + omh/appendix/whats_new/13.omh% + omh/appendix/whats_new/12.omh% + omh/appendix/whats_new/11.omh% + omh/appendix/whats_new/10.omh% + omh/appendix/whats_new/09.omh% + omh/appendix/whats_new/08.omh% + omh/appendix/whats_new/07.omh% + omh/appendix/whats_new/06.omh% + omh/appendix/whats_new/05.omh% + omh/appendix/whats_new/04.omh% + omh/appendix/whats_new/03.omh %$$ $head This Year$$ -$cref whats_new_17$$ +$cref whats_new_19$$ $head Previous Years$$ +$cref whats_new_18$$ +$cref whats_new_17$$ $cref whats_new_16$$ $cref whats_new_15$$ $cref whats_new_14$$ diff -Nru cppad-2018.00.00.0/omh/appendix/wish_list.omh cppad-2019.02.00.0/omh/appendix/wish_list.omh --- cppad-2018.00.00.0/omh/appendix/wish_list.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix/wish_list.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,57 +1,125 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin wish_list$$ $spell - subgraph - Recomputation - optimizer - checkpointing - grep - recomputed - iterator - Adolc - xml - hpp - CppAD - Atan - cppad - tapeless - Retape - jac - isnan - vx - Jacobian - const - Eigen - boolofvoid - afun - hes - Mp + Subgraphs + Jacobians + subgraph + Recomputation + optimizer + checkpointing + grep + recomputed + iterator + Adolc + xml + hpp + CppAD + Atan + cppad + tapeless + Retape + jac + isnan + vx + Jacobian + const + Eigen + boolofvoid + afun + hes + Mp + op + bool + vec + cmake + vcdir + vcvarsall + lic + tgz + vx + vy + inline + Colpack $$ $section The CppAD Wish List$$ -$head Multi-Threading$$ -The TMB packages has a special version of the -$cref checkpoint$$ class -that enables one checkpoint function to be my multiple OpenMp threads. -Perhaps it would be useful to extend the CppAD multi-threading environment -to allow for this. -In addition, perhaps a multi-threading version of an ADFun object would -be useful. +$head See Also$$ +$cref research$$ + +$head Purpose$$ +The items on this list are improvements and extensions to CppAD +that are currently being considered. + +$head inline$$ +The C++ $code inline$$ specifier is used to avoid multiple copies +of functions (that are not templates) during the link process. +Perhaps some of these functions should be regular functions and part +in the $cref/cppad_lib/colpack_prefix/cppad_lib/$$ library. +(Currently $code cppad_lib$$ only contains routines needed to us +Colpack.) + +$head Atomic Examples$$ +Convert the remaining $cref/atomic_two_examples/atomic_two_example/$$ +to use the $cref atomic_three$$ interface. + +$comment ------------------------------------------------------------------ $$ +$head checkpoint$$ + +$subhead Constructor$$ +Now that $cref base2ad$$ is available, +perhaps one should pass an $cref ADFun$$ object, +instead of an algorithm, +to the check point constructor. + + +$subhead Tapeless AD$$ +Perhaps there should be a version of the +$cref/checkpoint/chkpoint_one/$$ class that uses a tapeless AD package to compute +the derivative values. +This would allow for algorithms where the operations sequence +depends on the independent variable values. +There is a question as to how sparsity patterns would be determined +in this case. +Perhaps they would be passed into the constructor. +If it was known to be constant, +the user could compute the pattern using CppAD. +Otherwise, the user could input +a conservative estimate of the pattern that would be correct. + +$subhead Re-taping$$ +Perhaps the $code checkpoint$$ class should allow for re-taping +derivative values. +This would also allow for algorithms where the operations sequence +depends on the independent variable values. +Perhaps (as for tapeless entry above) +they should be passed into the constructor. + +$subhead Testing$$ +There should be some examples and tests for both speed and memory use +that demonstrate that checkpointing is useful. $comment ------------------------------------------------------------------- $$ -$head Atomic$$ -$subhead Subgraph$$ +$head Subgraph$$ + +$subhead Forward Mode$$ +The $cref subgraph_jac_rev$$ routine computes sparsity patterns +of Jacobians using reverse mode. +It is possible that a forward mode version of this method would be +better for some cases. + +$subhead Sparsity$$ The $cref subgraph_sparsity$$ calculation treats each atomic function call as if all of its outputs depend on all of its inputs; @@ -60,36 +128,39 @@ (could have fewer possibly non-zeros entries) by using the sparsity patterns for the atomic functions. -$subhead New API$$ -A new API for atomic functions could be created that uses -$cref sparse_rc$$ for sparsity patterns and an interface like -$codei% - %afun%.jac_sparsity(%select_domain%, %select_range%, %pattern_out%) - %afun%.hes_sparsity(%select_domain%, %select_range%, %pattern_out%) -%$$ -see $cref subgraph_sparsity$$. -This would be simpler for the user. +$comment ------------------------------------------------------------------- $$ -$subhead Sparsity$$ -Add an $cref atomic_option$$ that checks if the sparsity patterns calculated -by user atomic functions have -elements for arguments that are know to be parameters and -could be more efficient. -For example, the user's version of $code for_sparse_jac$$ could check -$cref/x/atomic_for_sparse_jac/Implementation/x/$$ to see for which components -are variables; -i.e., $cref/isnan(x[j])/nan/isnan/$$ is true for a particular call. -Note that -$cref/vx/atomic_for_sparse_hes/Implementation/vx/$$ should be removed, -because the method above can be used to determine this information. +$head Constant$$ +There should be a $icode%f%.Constant(%i%)%$$ function, +similar to the $cref/Parameter/seq_property/Parameter/$$ function, +that allows one to determine which dependent variables are +$cref/constant parameters/glossary/Parameter/Constant/$$. + +$comment ------------------------------------------------------------------- $$ -$subhead Element-wise Operations$$ -Add user atomic functions for element-wise addition, subtraction, +$head Element-wise Atomic Operations$$ +Add atomic functions for element-wise addition, subtraction, multiplication, and division. Where the operands are $cref/simple vectors/SimpleVector/$$ with elements of type $codei%AD<%Base%>%$$. -$comment ------------------------------------------------------------------- $$ +$head Abs-normal$$ +$list number$$ +Change the $cref abs_normal_fun$$ to return the functions +$cref/z(x, u)/abs_normal_fun/g/z(x, u)/$$ and +$cref/y(x, u)/abs_normal_fun/g/y(x, u)/$$ instead of +$latex g(x, u)$$ and $latex a(x)$$. +We can add a utility that computes $latex a(x)$$ using +$latex z(x, u)$$, $latex a_i (x) = | z_i (x, a(x) ) |$$ +and $latex z_i$$ does not depends on $latex u_j$$ for $latex j \geq i$$. +$lnext +Avoid cancellation when computing the difference in the absolute value +function at the current point $latex \hat{x}$$ the displaced point +$latex x = \hat{x} + \Delta x$$; i.e., +$latex \[ + |z_i (x, \tilde{a}(x) ) | - |z_i (\hat{x}, a(\hat{x}) ) | +\] $$ +$lend $head check_finite$$ $list number$$ @@ -109,22 +180,12 @@ For general purpose use, the $cref test_boolofvoid$$ should be usable without including a memory check at the end. -$head Eigen$$ -Use a wrapper class for -$cref/eigen vectors/testvector/Eigen Vectors/$$ so that the -$code size$$ member function returns a -$code size_t$$ instead of an $code int$$. -This would allow $cref TESTVECTOR$$ to be a true template class; i.e., -to use the syntax -$codei% - TESTVECTOR<%Scalar%> -%$$ - $head Example$$ Split the $cref/example list/ListAllExamples/$$ into separate groups by the corresponding example subdirectory. $comment ----------------------------------------------------------------- $$ + $head Optimization$$ $subhead Taping$$ @@ -134,38 +195,12 @@ $subhead Special Operators$$ Add special operators that can be implemented more efficiently, e.g., $codei% - square(%x%) = %x% * %x% + square(%x%) = %x% * %x% %$$ and have the optimizer recognize when they should be used. (They could also be in the user API, but it would not be expected that the user would use them.) -$subhead Memory$$ -The $cref optimize$$ command seems to use a lot of memory when the -tape is large. We should create a test case that demonstrates this and then -work on reducing the amount of memory needed by this operation. - -$comment ------------------------------------------------------------------ $$ -$head checkpoint$$ - -$subhead Retape$$ -Perhaps there should be a version of the -$cref checkpoint$$ class that uses a tapeless AD package to compute -the derivative values. -This would allow for algorithms where the operations sequence -depends on the independent variable values. -There is a question as to how sparsity patterns would be determined -in this case. -Perhaps they would be passed into the constructor. -If it was known to be constant, -the user could compute the pattern using CppAD. -Otherwise, the user could input -a conservative estimate of the pattern that would be correct. - -$subhead Testing$$ -There should be some examples and tests for both speed and memory use -that demonstrate that checkpointing is useful. - $comment -------------------------------------------------------------------$$ $head Compilation Speed$$ @@ -202,60 +237,17 @@ (because an iterator for the result container would be passed in). $lend -$head 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 Software Guidelines$$ -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) -should be all lowercase, with words separated by underscores. -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. -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 - if( expression ) - statement - else statement -$$ -with a tab after the else. -Automatic conversion to actual spaces should be easy. - -$lend - $head 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 $codep - grep '^# *define *CPPAD_.*_TRACE' cppad/local/*.hpp + grep '^# *define *CPPAD_.*_TRACE' cppad/local/sweep*.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-2018.00.00.0/omh/appendix.omh cppad-2019.02.00.0/omh/appendix.omh --- cppad-2018.00.00.0/omh/appendix.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/appendix.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin Appendix$$ @@ -16,18 +17,17 @@ $section Appendix$$ $childtable% - omh/appendix/faq.omh% - omh/appendix/directory.omh% - omh/appendix/theory/theory.omh% - omh/appendix/glossary.omh% - omh/appendix/bib.omh% - omh/appendix/wish_list.omh% - omh/appendix/whats_new/whats_new.omh% - omh/appendix/deprecated/deprecated.omh% - test_more/compare_c/CMakeLists.txt% - omh/appendix/numeric_ad.omh% - omh/appendix/addon.omh% - omh/appendix/license.omh + omh/appendix/faq.omh% + omh/appendix/directory.omh% + omh/appendix/glossary.omh% + omh/appendix/bib.omh% + omh/appendix/wish_list.omh% + omh/appendix/whats_new/whats_new.omh% + omh/appendix/deprecated/deprecated.omh% + test_more/compare_c/CMakeLists.txt% + omh/appendix/numeric_ad.omh% + omh/appendix/addon.omh% + omh/appendix/license.omh %$$ $end diff -Nru cppad-2018.00.00.0/omh/atomic_base.omh cppad-2019.02.00.0/omh/atomic_base.omh --- cppad-2018.00.00.0/omh/atomic_base.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/atomic_base.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -// $Id: atomic_base.omh 3845 2016-11-19 01:50:47Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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_base$$ -$spell - ctor - cppad - hpp - afun - arg - vx - vy - tx - ty - px - py - jac - hes - CppAD - checkpointing - algo -$$ - -$section User Defined Atomic AD Functions$$ - - -$head Syntax$$ - -$codei% -%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%) -%ok% = %afun%.for_sparse_jac(%q%, %r%, %s%) -%ok% = %afun%.rev_sparse_jac(%q%, %r%, %s%) -%ok% = %afun%.for_sparse_hes(%vx%, %r%, %s%, %h%) -%ok% = %afun%.rev_sparse_hes(%vx%, %s%, %t%, %q%, %r%, %u%, %v%) -atomic_base<%Base%>::clear()%$$ - -$head Purpose$$ -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 -\] $$ -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. - -$head Virtual Functions$$ -User defined derivatives are implemented by defining the -following virtual functions in the $icode base_atomic$$ class: -$cref/forward/atomic_forward/$$, -$cref/reverse/atomic_reverse/$$, -$cref/for_sparse_jac/atomic_for_sparse_jac/$$, -$cref/rev_sparse_jac/atomic_rev_sparse_jac/$$, and -$cref/rev_sparse_hes/atomic_rev_sparse_hes/$$. -These virtual functions have a default implementation -that returns $icode%ok% == false%$$. -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, -$icode forward$$ for the case $icode%q% == 2%$$ can just return -$icode%ok% == false%$$ unless you require -forward mode calculation of second derivatives. - -$childtable% - cppad/core/atomic_base.hpp% - example/atomic/get_started.cpp% - example/atomic/norm_sq.cpp% - example/atomic/reciprocal.cpp% - example/atomic/set_sparsity.cpp% - example/atomic/tangent.cpp% - example/atomic/eigen_mat_mul.cpp% - example/atomic/eigen_mat_inv.cpp% - example/atomic/eigen_cholesky.cpp% - example/atomic/mat_mul.cpp -%$$ - -$head Examples$$ - -$subhead Getting Started$$ -The file $cref atomic_get_started.cpp$$ contains an example and test -that shows the minimal amount of information required to create -a user defined atomic operation. - -$subhead Scalar Function$$ -The file $cref atomic_reciprocal.cpp$$ contains an example and test -where the user provides the code for computing derivatives. -This example is simple because the domain and range are scalars. - -$subhead Vector Range$$ -The file $cref atomic_tangent.cpp$$ contains another example -where the user provides the code for computing derivatives. -This example is more complex because the range has two components. - -$subhead Hessian Sparsity Patterns$$ -The file $cref atomic_rev_sparse_hes.cpp$$ contains an minimal example -where the user provides the code for computing Hessian sparsity patterns. - -$head General Case$$ -The file $cref atomic_mat_mul.cpp$$ contains a more general example -where the user provides the code for computing derivatives. -This example is more complex because both the domain and range -dimensions are arbitrary. - -$end diff -Nru cppad-2018.00.00.0/omh/atomic.omh cppad-2019.02.00.0/omh/atomic.omh --- cppad-2018.00.00.0/omh/atomic.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/atomic.omh 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -// $Id: atomic.omh 3845 2016-11-19 01:50:47Z bradbell $ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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$$ - -$section Atomic AD Functions$$ -$mindex operation$$ - -$childtable% - cppad/core/checkpoint.hpp% - omh/atomic_base.omh -%$$ - -$end diff -Nru cppad-2018.00.00.0/omh/base_require/base_example.omh cppad-2019.02.00.0/omh/base_require/base_example.omh --- cppad-2018.00.00.0/omh/base_require/base_example.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/base_require/base_example.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin base_example$$ $section Example AD Base Types That are not AD$$ $contents% - example/general/base_alloc.hpp% - example/general/base_require.cpp% - cppad/example/base_adolc.hpp% - cppad/core/base_float.hpp% - cppad/core/base_double.hpp% - cppad/core/base_complex.hpp + example/general/base_alloc.hpp% + example/general/base_require.cpp% + include/cppad/example/base_adolc.hpp% + include/cppad/core/base_float.hpp% + include/cppad/core/base_double.hpp% + include/cppad/core/base_complex.hpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/base_require/base_identical.omh cppad-2019.02.00.0/omh/base_require/base_identical.omh --- cppad-2018.00.00.0/omh/base_require/base_identical.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/base_require/base_identical.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,49 +1,48 @@ -// $Id: base_identical.omh 3757 2015-11-30 12:03:07Z bradbell $$ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ /* $begin base_identical$$ $spell - alloc - adolc - Op - const - CppAD - adolc - namespace - bool - inline + 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%) + %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% + const %Base%& %u% + const %Base%& %v% %$$ The return value $icode b$$ has prototype $codei% - bool %b% + bool %b% %$$ $subhead The Simple Case$$ @@ -51,8 +50,8 @@ the $code EqualOpSeq$$ function can be defined by $codei% namespace CppAD { - inline %Base% EqualOpSeq(const %Base%& u, const %Base%& v) - { return u == v; } + inline %Base% EqualOpSeq(const %Base%& u, const %Base%& v) + { return u == v; } } %$$ For example, see @@ -74,14 +73,15 @@ $head Identical$$ -$subhead IdenticalPar$$ -A $icode Base$$ is a $cref/parameter/glossary/Parameter/$$ +$subhead IdenticalCon$$ +A $icode Base$$ object is a +$cref/constant/glossary/Parameter/Constant/$$ 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 $icode Base$$ value $icode u$$ is not identically constant +in the following case +(which CppAD automatically defines $code IdenticalCon$$ for): The type $icode Base$$ is $codei%AD%$$, $icode x[0] = 1.$$, then $cref independent$$ is used to make $icode x$$ the independent @@ -93,15 +93,15 @@ $subhead Prototypes$$ The argument $icode u$$ has prototype $codei% - const %Base% %u% + const %Base% %u% %$$ If it is present, the argument $icode v$$ has prototype $codei% - const %Base% %v% + const %Base% %v% %$$ The result $icode b$$ has prototype $codei% - bool %b% + bool %b% %$$ $subhead Identical Functions$$ @@ -110,19 +110,19 @@ $table $bold Syntax$$ $cnext $bold Result$$ $rnext -$icode%b% = IdenticalPar(%u%)%$$ $pre $$ - $cnext the $icode Base$$ value will always be the same +$icode%b% = IdenticalCon(%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%)%$$ + $cnext $icode u$$ equals zero and $codei%IdenticalCon(%u%)%$$ $rnext $icode%b% = IdenticalOne(%u%)%$$ $pre $$ - $cnext $icode u$$ equals one and $codei%IdenticalPar(%u%)%$$ + $cnext $icode u$$ equals one and $codei%IdenticalCon(%u%)%$$ $rnext -$icode%b% = IdenticalEqualPar(%u%, %v%)%$$ $pre $$ - $cnext $icode u$$ equals $icode v$$, - $codei%IdenticalPar(%u%)%$$ and - $codei%IdenticalPar(%v%)%$$ +$icode%b% = IdenticalEqualCon(%u%, %v%)%$$ $pre $$ + $cnext $icode u$$ equals $icode v$$, + $codei%IdenticalCon(%u%)%$$ and + $codei%IdenticalCon(%v%)%$$ $tend $subhead Examples$$ diff -Nru cppad-2018.00.00.0/omh/base_require/base_member.omh cppad-2019.02.00.0/omh/base_require/base_member.omh --- cppad-2018.00.00.0/omh/base_require/base_member.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/base_require/base_member.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,22 @@ -/* $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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin base_member$$ $spell - bool - const - op - Bool - definition - alloc + bool + const + op + Bool + definition + alloc $$ $section Required Base Class Member Functions$$ @@ -25,22 +25,22 @@ $table $bold Symbol$$ $cnext $bold Meaning$$ $rnext $icode Base$$ $cnext - The base type corresponding to $codei%AD<%Base%>%$$ + The base type corresponding to $codei%AD<%Base%>%$$ $rnext $icode b$$ $cnext - An object of type $code bool$$ + An object of type $code bool$$ $rnext $icode d$$ $cnext - An object of type $code double$$ + An object of type $code double$$ $rnext $icode x$$ $cnext - An object of type $codei%const %Base%&%$$ + An object of type $codei%const %Base%&%$$ $rnext $icode y$$ $cnext - An object of type $codei%const %Base%&%$$ + An object of type $codei%const %Base%&%$$ $rnext $icode z$$ $cnext - An object of type $icode Base$$ + An object of type $icode Base$$ $rnext $tend @@ -59,7 +59,7 @@ $code -$$ the following operation must be supported: $codei% - %z% = %op% %x%$$ + %z% = %op% %x%$$ $head Assignment Operators$$ For $icode op$$ equal to @@ -69,7 +69,7 @@ $code *=$$, and $code /=$$ the following operation must be supported: $codei% - %z% %op% %x%$$ + %z% %op% %x%$$ $head Binary Operators$$ For $icode op$$ equal to @@ -78,7 +78,7 @@ $code *$$, and $code /$$ the following operation must be supported: $codei% - %z% = %x% %op% %y%$$ + %z% = %x% %op% %y%$$ $head Bool Operators$$ For $icode op$$ equal to @@ -87,7 +87,7 @@ $code <=$$, the following operation must be supported: $codei% - %b% = %x% %op% %y%$$ + %b% = %x% %op% %y%$$ $head Example$$ See the heading Class Definition in diff -Nru cppad-2018.00.00.0/omh/base_require/base_ordered.omh cppad-2019.02.00.0/omh/base_require/base_ordered.omh --- cppad-2018.00.00.0/omh/base_require/base_ordered.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/base_require/base_ordered.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,24 @@ -// $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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ /* $begin base_ordered$$ $spell - alloc - abs_geq - const - bool - namespace - CppAD - inline + alloc + abs_geq + const + bool + namespace + CppAD + inline $$ $section Base Type Requirements for Ordered Comparisons$$ @@ -32,25 +32,25 @@ $bold Syntax$$ $cnext $bold Result$$ $rnext $icode%b% = GreaterThanZero(%x%)%$$ $pre $$ - $cnext $latex x > 0$$ + $cnext $latex x > 0$$ $rnext $icode%b% = GreaterThanOrZero(%x%)%$$ $pre $$ - $cnext $latex x \geq 0$$ + $cnext $latex x \geq 0$$ $rnext $icode%b% = LessThanZero(%x%)%$$ $pre $$ - $cnext $latex x < 0$$ + $cnext $latex x < 0$$ $rnext $icode%b% = LessThanOrZero(%x%)%$$ $pre $$ - $cnext $latex x \leq 0$$ + $cnext $latex x \leq 0$$ $rnext $icode%b% = abs_geq(%x%, %y%)%$$ $pre $$ - $cnext $latex |x| \geq |y|$$. + $cnext $latex |x| \geq |y|$$. $tend where the arguments and return value have the prototypes $codei% - const %Base%& %x% - const %Base%& %y% - bool %% %b% + const %Base%& %x% + const %Base%& %y% + bool %% %b% %$$ $head Ordered Type$$ @@ -59,9 +59,9 @@ For example, $codei% namespace CppAD { - inline bool GreaterThanZero(const %Base% &x) - { return (x > 0); - } + inline bool GreaterThanZero(const %Base% &x) + { return (x > 0); + } } %$$ The other functions would replace $code >$$ by the corresponding operator. @@ -74,11 +74,11 @@ 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; - } + 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. diff -Nru cppad-2018.00.00.0/omh/cos_forward.omh cppad-2019.02.00.0/omh/cos_forward.omh --- cppad-2018.00.00.0/omh/cos_forward.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/cos_forward.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,38 +1,35 @@ -$Id: cos_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ -// BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- CppAD: 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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT $begin CosForward$$ $spell - cos - Taylor + cos + Taylor $$ $section Cosine Function Forward Taylor Polynomial Theory$$ -$mindex cos$$ If $latex F(x) = \cos(x) $$ $latex \[ - 1 * F^{(1)} (x) - 0 * F (x) = - \sin(x) + 1 * F^{(1)} (x) - 0 * F (x) = - \sin(x) \] $$ and in the $xref/ - ForwardTheory/ - Standard Math Functions/ - Differential Equation/ - standard math function differential equation/ - 1 + ForwardTheory/ + Standard Math Functions/ + Differential Equation/ + standard math function differential equation/ + 1 /$$, $latex A(x) = 0$$, $latex B(x) = 1$$, @@ -47,11 +44,11 @@ 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 + ForwardTheory/ + Standard Math Functions/ + Taylor Coefficients Recursion Formula/ + Taylor coefficients recursion formula/ + 1 /$$ that for $latex j = 0 , 1, \ldots$$, $latex \[ @@ -65,12 +62,12 @@ \\ 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)} + \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) ]$$ @@ -79,7 +76,7 @@ by the following formula: $latex \[ c^{(j+1)} = - \frac{1}{j+1} - \sum_{k=1}^{j+1} k x^{(k)} s^{(j+1-k)} + \sum_{k=1}^{j+1} k x^{(k)} s^{(j+1-k)} \] $$ $end diff -Nru cppad-2018.00.00.0/omh/det_33_hpp.omh cppad-2019.02.00.0/omh/det_33_hpp.omh --- cppad-2018.00.00.0/omh/det_33_hpp.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/det_33_hpp.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: det_33_hpp.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin det_33.hpp$$ $spell - det_33 - ifndef - endif + det_33 + ifndef + endif $$ $section Source: det_33$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_DET_33_HPP -$srcfile%cppad/speed/det_33.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/speed/det_33.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/det_by_lu_hpp.omh cppad-2019.02.00.0/omh/det_by_lu_hpp.omh --- cppad-2018.00.00.0/omh/det_by_lu_hpp.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/det_by_lu_hpp.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: det_by_lu_hpp.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin det_by_lu.hpp$$ $spell - det_by_lu - ifndef - endif + det_by_lu + ifndef + endif $$ $section Source: det_by_lu$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_DET_BY_LU_HPP -$srcfile%cppad/speed/det_by_lu.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/speed/det_by_lu.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/det_by_minor_hpp.omh cppad-2019.02.00.0/omh/det_by_minor_hpp.omh --- cppad-2018.00.00.0/omh/det_by_minor_hpp.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/det_by_minor_hpp.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: det_by_minor_hpp.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin det_by_minor.hpp$$ $spell - det_by_minor - ifndef - endif + det_by_minor + ifndef + endif $$ $section Source: det_by_minor$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_DET_BY_MINOR_HPP -$srcfile%cppad/speed/det_by_minor.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/speed/det_by_minor.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/det_grad_33_hpp.omh cppad-2019.02.00.0/omh/det_grad_33_hpp.omh --- cppad-2018.00.00.0/omh/det_grad_33_hpp.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/det_grad_33_hpp.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: det_grad_33_hpp.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin det_grad_33.hpp$$ $spell - det_grad_33 - ifndef - endif + det_grad_33 + ifndef + endif $$ $section Source: det_grad_33$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_DET_GRAD_33_HPP -$srcfile%cppad/speed/det_grad_33.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/speed/det_grad_33.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/det_of_minor_hpp.omh cppad-2019.02.00.0/omh/det_of_minor_hpp.omh --- cppad-2018.00.00.0/omh/det_of_minor_hpp.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/det_of_minor_hpp.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: det_of_minor_hpp.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin det_of_minor.hpp$$ $spell - det_of_minor - ifndef - endif + det_of_minor + ifndef + endif $$ $section Source: det_of_minor$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_DET_OF_MINOR_HPP -$srcfile%cppad/speed/det_of_minor.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/speed/det_of_minor.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/example_list.omh cppad-2019.02.00.0/omh/example_list.omh --- cppad-2018.00.00.0/omh/example_list.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/example_list.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,24 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin General$$ $spell - Cpp + Cpp $$ $section General Examples$$ -$mindex realistic$$ $head Description$$ Most of the examples in CppAD are part of the documentation @@ -27,21 +27,20 @@ The examples list in this section are of a more general nature. $childtable% - example/general/ad_fun.cpp% - example/general/ad_in_c.cpp% - example/sparse/conj_grad.cpp% - cppad/example/cppad_eigen.hpp % - example/general/hes_minor_det.cpp% - example/general/hes_lu_det.cpp% - example/general/interface2c.cpp% - example/general/jac_minor_det.cpp% - example/general/jac_lu_det.cpp% - omh/mul_level.omh% - example/general/ode_stiff.cpp% - example/general/mul_level_ode.cpp% - example/general/mul_level_adolc_ode.cpp% - example/general/ode_taylor.cpp% - example/general/stack_machine.cpp + example/general/ad_fun.cpp% + example/general/ad_in_c.cpp% + example/sparse/conj_grad.cpp% + include/cppad/example/cppad_eigen.hpp % + example/general/hes_minor_det.cpp% + example/general/hes_lu_det.cpp% + example/general/interface2c.cpp% + example/general/jac_minor_det.cpp% + example/general/jac_lu_det.cpp% + omh/mul_level.omh% + example/general/ode_stiff.cpp% + example/general/mul_level_ode.cpp% + example/general/mul_level_adolc_ode.cpp% + example/general/stack_machine.cpp %$$ $end @@ -49,28 +48,28 @@ ----------------------------------------------------------------------------- $begin ExampleUtility$$ $spell - CppAD + CppAD $$ $section Utility Routines used by CppAD Examples$$ $childtable% - example/general/general.cpp% - speed/example/example.cpp% - example/general/lu_vec_ad.cpp + example/general/general.cpp% + speed/example/example.cpp% + example/general/lu_vec_ad.cpp %$$ $end ----------------------------------------------------------------------------- $begin ListAllExamples$$ $spell - CppAD + CppAD $$ $section List All (Except Deprecated) CppAD Examples$$ $comment - omit: TestOne.cpp OneCase.cpp lu_vec_ad.cpp + omit: TestOne.cpp OneCase.cpp lu_vec_ad.cpp $$ $comment BEGIN_SORT_THIS_LINE_PLUS_2$$ @@ -101,27 +100,27 @@ $rref atan2.cpp$$ $rref atan.cpp$$ $rref atanh.cpp$$ -$rref atomic_eigen_cholesky.cpp$$ +$rref atomic_two_eigen_cholesky.cpp$$ $rref atomic_eigen_cholesky.hpp$$ -$rref atomic_eigen_mat_inv.cpp$$ +$rref atomic_two_eigen_mat_inv.cpp$$ $rref atomic_eigen_mat_inv.hpp$$ -$rref atomic_eigen_mat_mul.cpp$$ +$rref atomic_two_eigen_mat_mul.cpp$$ $rref atomic_eigen_mat_mul.hpp$$ -$rref atomic_for_sparse_hes.cpp$$ -$rref atomic_for_sparse_jac.cpp$$ -$rref atomic_forward.cpp$$ -$rref atomic_get_started.cpp$$ -$rref atomic_mat_mul.cpp$$ $rref atomic_mat_mul.hpp$$ -$rref atomic_mul_level.cpp$$ -$rref atomic_norm_sq.cpp$$ -$rref atomic_reciprocal.cpp$$ -$rref atomic_reverse.cpp$$ -$rref atomic_rev_sparse_hes.cpp$$ -$rref atomic_rev_sparse_jac.cpp$$ -$rref atomic_set_sparsity.cpp$$ -$rref atomic_tangent.cpp$$ +$rref atomic_three_base2ad.cpp$$ +$rref atomic_three_dynamic.cpp$$ +$rref atomic_three_forward.cpp$$ +$rref atomic_three_get_started.cpp$$ +$rref atomic_three_hes_sparsity.cpp$$ +$rref atomic_three_jac_sparsity.cpp$$ +$rref atomic_three_mat_mul.cpp$$ +$rref atomic_three_norm_sq.cpp$$ +$rref atomic_three_reciprocal.cpp$$ +$rref atomic_three_tangent.cpp$$ +$rref atomic_three_reverse.cpp$$ +$rref atomic_three_rev_depend.cpp$$ $rref azmul.cpp$$ +$rref base2ad.cpp$$ $rref base_adolc.hpp$$ $rref base_alloc.hpp$$ $rref base_complex.hpp$$ @@ -132,9 +131,11 @@ $rref change_param.cpp$$ $rref check_for_nan.cpp$$ $rref check_numeric_type.cpp$$ -$rref checkpoint.cpp$$ -$rref checkpoint_extended_ode.cpp$$ -$rref checkpoint_ode.cpp$$ +$rref chkpoint_two_base2ad.cpp$$ +$rref chkpoint_two_compare.cpp$$ +$rref chkpoint_two_dynamic.cpp$$ +$rref chkpoint_two_get_started.cpp$$ +$rref chkpoint_two_ode.cpp$$ $rref check_simple_vector.cpp$$ $rref colpack_hes.cpp$$ $rref colpack_hessian.cpp$$ @@ -218,10 +219,12 @@ $rref mul_level.cpp$$ $rref mul_level_ode.cpp$$ $rref multi_atomic.cpp$$ +$rref multi_checkpoint.cpp$$ $rref multi_newton.cpp$$ $rref nan.cpp$$ $rref near_equal.cpp$$ $rref near_equal_ext.cpp$$ +$rref new_dynamic.cpp$$ $rref number_skip.cpp$$ $rref numeric_type.cpp$$ $rref num_limits.cpp$$ @@ -231,7 +234,7 @@ $rref ode_gear_control.cpp$$ $rref ode_gear.cpp$$ $rref ode_stiff.cpp$$ -$rref ode_taylor.cpp$$ +$rref taylor_ode.cpp$$ $rref optimize_compare_op.cpp$$ $rref optimize_conditional_skip.cpp$$ $rref optimize_cumulative_sum.cpp$$ @@ -240,7 +243,7 @@ $rref optimize_print_for.cpp$$ $rref optimize_reverse_active.cpp$$ $rref opt_val_hes.cpp$$ -$rref par_var.cpp$$ +$rref con_dyn_var.cpp$$ $rref poly.cpp$$ $rref pow.cpp$$ $rref pow_int.cpp$$ @@ -276,6 +279,7 @@ $rref simplex_method.hpp$$ $rref sin.cpp$$ $rref sinh.cpp$$ +$rref sparse2eigen.cpp$$ $rref sparse_hes.cpp$$ $rref sparse_hes_fun.cpp$$ $rref sparse_hessian.cpp$$ @@ -321,4 +325,3 @@ $comment END_SORT_THIS_LINE_MINUS_2$$ $end - diff -Nru cppad-2018.00.00.0/omh/example.omh cppad-2019.02.00.0/omh/example.omh --- cppad-2018.00.00.0/omh/example.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/example.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,26 +1,27 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin Example$$ $spell - CppAD - Cygwin - Microsoft - chdir - nmake - mak - Workspace - dsw - exe - Example example + CppAD + Cygwin + Microsoft + chdir + nmake + mak + Workspace + dsw + exe + Example example $$ $section Examples$$ @@ -53,10 +54,10 @@ $contents% - example/get_started/get_started.cpp% - omh/example_list.omh% - cppad/core/testvector.hpp% - cppad/wno_conversion.hpp + example/get_started/get_started.cpp% + omh/example_list.omh% + include/cppad/core/testvector.hpp% + include/cppad/wno_conversion.hpp %$$ diff -Nru cppad-2018.00.00.0/omh/forward/compare_change.omh cppad-2019.02.00.0/omh/forward/compare_change.omh --- cppad-2018.00.00.0/omh/forward/compare_change.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/forward/compare_change.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,21 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin compare_change$$ $spell - op - const + op + const $$ $section Comparison Changes Between Taping and Zero Order Forward$$ -$mindex ADFun compare_change$$ $head Syntax$$ @@ -31,11 +31,11 @@ $head Purpose$$ -We use $latex F : B^n \rightarrow B^m$$ to denote the +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$; i.e, -given $latex x \in B^n$$, $latex F(x)$$ is defined by +given $latex x \in \B{R}^n$$, $latex F(x)$$ is defined by $codei% - %F%(%x%) = %f%.Forward(0, %x%) + %F%(%x%) = %f%.Forward(0, %x%) %$$ see $cref forward_zero$$. If $latex x$$ is such that @@ -52,24 +52,24 @@ In the $code compare_change_number$$ and $code compare_change_op_index$$ syntax, the object $icode f$$ has prototype $codei% - const ADFun<%Base%> %f% + const ADFun<%Base%> %f% %$$ In the $code compare_change_count$$ syntax, the object $icode f$$ has prototype $codei% - ADFun<%Base%> %f% + ADFun<%Base%> %f% %$$ $head count$$ The argument $icode count$$ has prototype $icode% - size_t %count% + 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% - %f%.Forward(0, %x%) + %f%.Forward(0, %x%) %$$ For example, if $icode%count% == 1%$$, the operator index corresponding to the first comparison change @@ -80,20 +80,20 @@ The special case where $icode count == 0$$, should be faster because the comparisons are not checked during $codei% - %f%.Forward(0, %x%) + %f%.Forward(0, %x%) %$$ $head number$$ The return value $icode number$$ has prototype $codei% - size_t %number% + 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%) + %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. @@ -117,13 +117,13 @@ $head op_index$$ The return value $icode op_index$$ has prototype $codei% - size_t %op_index% + 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%) + %f%.Forward(0, %x%) %$$ If $icode count$$ is greater than the corresponding $icode number$$, there is no such comparison change and $icode op_index$$ @@ -143,15 +143,14 @@ may be appropriate in some cases. See $cref/abort_op_index/Independent/abort_op_index/$$ in the syntax $codei% - Independent(%x%, %abort_op_index%) + Independent(%x%, %abort_op_index%) %$$ $children% - example/general/compare_change.cpp + example/general/compare_change.cpp %$$ $head Example$$ $cref compare_change.cpp$$ contains an example and test of this operation. -It returns true if they succeed and false otherwise. $end diff -Nru cppad-2018.00.00.0/omh/forward/forward_dir.omh cppad-2019.02.00.0/omh/forward/forward_dir.omh --- cppad-2018.00.00.0/omh/forward/forward_dir.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/forward/forward_dir.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,25 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin forward_dir$$ $spell - Taylor - const - dir - cpp - yq - xq - xk - std::cout - ostream + Taylor + const + dir + cpp + yq + xq + xk + std::cout + ostream $$ $section Multiple Directions Forward Mode$$ @@ -29,14 +30,14 @@ %$$ $head Purpose$$ -We use $latex F : B^n \rightarrow B^m$$ to denote the +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. -Given a function $latex X : B \rightarrow B^n$$, +Given a function $latex X : \B{R} \rightarrow \B{R}^n$$, defined by its $cref/Taylor coefficients/glossary/Taylor Coefficient/$$, forward mode computes the Taylor coefficients for the function $latex \[ - Y (t) = F [ X(t) ] + Y (t) = F [ X(t) ] \]$$ This version of forward mode computes multiple directions as the same time (reducing the number of passes through the tape). This requires more @@ -61,19 +62,19 @@ $head f$$ The $cref ADFun$$ object $icode f$$ has prototype $codei% - ADFun<%Base%> %f% + ADFun<%Base%> %f% %$$ Note that the $cref ADFun$$ object $icode f$$ is not $code const$$. After this call we will have $codei% - %f%.size_order() == %q% + 1 - %f%.size_direction() == %r% + %f%.size_order() == %q% + 1 + %f%.size_direction() == %r% %$$ $head q$$ This argument has prototype $codei% - size_t %q% + size_t %q% %$$ It specifies the order of Taylor Coefficient that we are calculating and must be greater than zero. @@ -84,7 +85,7 @@ $head r$$ This argument has prototype $codei% - size_t %r% + size_t %r% %$$ It specifies the number of directions that are computed together. If ($icode%r% == 1%$$), you are only using one direction and @@ -94,7 +95,7 @@ $head xq$$ The argument $icode xq$$ has prototype $codei% - const %Vector%& %xq% + const %Vector%& %xq% %$$ and its size must be $icode%n%*%r%$$ (see $cref/Vector/forward_dir/Vector/$$ below). @@ -103,17 +104,17 @@ 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% ]%$$ + $$ $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 for $latex X_\ell (t)$$ is defined by $pre - $$ $latex x_j^{(0)} = $$ $icode%xk%[ %j% ]%$$ + $$ $latex x_j^{(0)} = $$ $icode%xk%[ %j% ]%$$ where $icode xk$$ corresponds to the previous call $codei% - %f%.Forward(%k%, %xk%) + %f%.Forward(%k%, %xk%) %$$ with $icode%k% = 0%$$. @@ -124,17 +125,17 @@ 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% ]%$$ + $$ $latex x_j^{(k),\ell} = $$ $icode%xk%[ %r% * %j% + %ell% ]%$$ where $icode xk$$ corresponds to the previous call $codei% - %f%.Forward(%k%, %r%, %xk%) + %f%.Forward(%k%, %r%, %xk%) %$$ Note that $icode r$$ must have the same value in this previous call. $head X(t)$$ For $latex \ell = 0 , \ldots , r-1$$, the function -$latex X_\ell : B \rightarrow B^n$$ is defined using -the Taylor coefficients $latex x^{(k),\ell} \in B^n$$: +$latex X_\ell : \B{R} \rightarrow \B{R}^n$$ is defined using +the Taylor coefficients $latex x^{(k),\ell} \in \B{R}^n$$: $latex \[ X_\ell (t) = x^{(0)} + x^{(1),\ell} * t^1 + \cdots + x^{(q),\ell} t^q \] $$ @@ -142,19 +143,19 @@ its Taylor coefficients by $latex \[ \begin{array}{rcl} - x^{(0)} & = & X_\ell (0) - \\ - x^{(k), \ell} & = & \frac{1}{k !} X_\ell^{(k)} (0) + x^{(0)} & = & X_\ell (0) + \\ + x^{(k), \ell} & = & \frac{1}{k !} X_\ell^{(k)} (0) \end{array} \] $$ for $latex k = 1 , \ldots , q$$. $head Y(t)$$ For $latex \ell = 0 , \ldots , r-1$$, the function -$latex Y_\ell : B \rightarrow B^m$$ is defined by +$latex Y_\ell : \B{R} \rightarrow \B{R}^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{R}^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 @@ -165,9 +166,9 @@ its Taylor coefficients by $latex \[ \begin{array}{rcl} - y^{(0)} & = & Y_\ell (0) - \\ - y^{(k), \ell} & = & \frac{1}{k !} Y_\ell^{(k)} (0) + y^{(0)} & = & Y_\ell (0) + \\ + y^{(k), \ell} & = & \frac{1}{k !} Y_\ell^{(k)} (0) \end{array} \] $$ for $latex k = 1 , \ldots , q$$. @@ -175,7 +176,7 @@ $head yq$$ The argument $icode yq$$ has prototype $codei% - %Vector% %yq% + %Vector% %yq% %$$ and its size is $icode%m%*%r%$$ (see $cref/Vector/forward_dir/Vector/$$ below). @@ -184,7 +185,7 @@ 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% ]%$$ + $$ $latex y_i^{(q),\ell} = $$ $icode%yq%[ %r% * %i% + %ell% ]%$$ $head Vector$$ The type $icode Vector$$ must be a $cref SimpleVector$$ class with @@ -194,7 +195,7 @@ if this is not the case. $children% - example/general/forward_dir.cpp + example/general/forward_dir.cpp %$$ $head Example$$ The file diff -Nru cppad-2018.00.00.0/omh/forward/forward.omh cppad-2019.02.00.0/omh/forward/forward.omh --- cppad-2018.00.00.0/omh/forward/forward.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/forward/forward.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,28 @@ -// $Id: forward.omh 3845 2016-11-19 01:50:47Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin Forward$$ $section Forward Mode$$ $childtable% - omh/forward/forward_zero.omh% - omh/forward/forward_one.omh% - omh/forward/forward_two.omh% - omh/forward/forward_order.omh% - omh/forward/forward_dir.omh% - omh/forward/size_order.omh% - omh/forward/compare_change.omh% - cppad/core/capacity_order.hpp% - cppad/core/num_skip.hpp + omh/forward/forward_zero.omh% + omh/forward/forward_one.omh% + omh/forward/forward_two.omh% + omh/forward/forward_order.omh% + omh/forward/forward_dir.omh% + omh/forward/size_order.omh% + omh/forward/compare_change.omh% + include/cppad/core/capacity_order.hpp% + include/cppad/core/num_skip.hpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/forward/forward_one.omh cppad-2019.02.00.0/omh/forward/forward_one.omh --- cppad-2018.00.00.0/omh/forward/forward_one.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/forward/forward_one.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,35 +1,33 @@ -// $Id: forward_one.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin forward_one$$ $spell - Jacobian - Taylor - const + Jacobian + Taylor + const $$ $section First Order Forward Mode: Derivative Values$$ -$mindex one$$ - $head Syntax$$ $icode%y1% = %f%.Forward(1, %x1%)%$$ $head Purpose$$ -We use $latex F : B^n \rightarrow B^m$$ to denote the +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The result of the syntax above is $latex \[ - y1 = F^{(1)} (x0) * x1 + y1 = F^{(1)} (x0) * x1 \] $$ where $latex F^{(1)} (x0)$$ is the Jacobian of $latex F$$ evaluated at $icode x0$$. @@ -37,12 +35,12 @@ $head f$$ The object $icode f$$ has prototype $codei% - ADFun<%Base%> %f% + ADFun<%Base%> %f% %$$ Note that the $cref ADFun$$ object $icode f$$ is not $code const$$. Before this call to $code Forward$$, the value returned by $codei% - %f%.size_order() + %f%.size_order() %$$ must be greater than or equal one. After this call it will be will be two (see $cref size_order$$). @@ -50,12 +48,12 @@ $head x0$$ The vector $icode x0$$ in the formula $latex \[ - y1 = F^{(1)} (x0) * x1 + y1 = F^{(1)} (x0) * x1 \] $$ corresponds to the previous call to $cref forward_zero$$ using this ADFun object $icode f$$; i.e., $codei% - %f%.Forward(0, %x0%) + %f%.Forward(0, %x0%) %$$ If there is no previous call with the first argument zero, the value of the $cref/independent/Independent/$$ variables @@ -65,7 +63,7 @@ $head x1$$ The argument $icode x1$$ has prototype $codei% - const %Vector%& %x1% + const %Vector%& %x1% %$$ (see $cref/Vector/forward_one/Vector/$$ below) and its size must be equal to $icode n$$, the dimension of the @@ -82,7 +80,6 @@ The file $cref forward.cpp$$ contains an example and test of this operation. -It returns true if it succeeds and false otherwise. $head Special Case$$ This is special case of $cref forward_order$$ where @@ -101,12 +98,12 @@ $latex x^{(1)}$$ $codei%= %x1%$$, $latex X(t) = x^{(0)} + x^{(1)} t$$, and $latex \[ - y^{(0)} + y^{(1)} t = F [ x^{(0)} + x^{(1)} t ] + o(t) + 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$$, we obtain $latex \[ - y^{(1)} = F^{(1)} [ x^{(0)} ] x^{(1)} + y^{(1)} = F^{(1)} [ x^{(0)} ] x^{(1)} \] $$ which agrees with the specifications for $icode y1$$ in the $cref/purpose/forward_one/Purpose/$$ above. diff -Nru cppad-2018.00.00.0/omh/forward/forward_order.omh cppad-2019.02.00.0/omh/forward/forward_order.omh --- cppad-2018.00.00.0/omh/forward/forward_order.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/forward/forward_order.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,31 +1,31 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin forward_order$$ $spell - std::cout - ostream - xk - xp - yp - Ind - vp - uj - Taylor - const - xq - yq + std::cout + ostream + xk + xp + yp + Ind + vp + uj + Taylor + const + xq + yq $$ $section Multiple Order Forward Mode$$ -$mindex any$$ $head Syntax$$ @@ -36,14 +36,14 @@ $head Purpose$$ -We use $latex F : B^n \rightarrow B^m$$ to denote the +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. -Given a function $latex X : B \rightarrow B^n$$, +Given a function $latex X : \B{R} \rightarrow \B{R}^n$$, defined by its $cref/Taylor coefficients/glossary/Taylor Coefficient/$$, forward mode computes the Taylor coefficients for the function $latex \[ - Y (t) = F [ X(t) ] + Y (t) = F [ X(t) ] \]$$ $subhead Function Values$$ @@ -70,13 +70,13 @@ $head f$$ The $cref ADFun$$ object $icode f$$ has prototype $codei% - ADFun<%Base%> %f% + ADFun<%Base%> %f% %$$ Note that the $cref ADFun$$ object $icode f$$ is not $code const$$. After this call we will have $codei% - %f%.size_order() == %q% + 1 - %f%.size_direction() == 1 + %f%.size_order() == %q% + 1 + %f%.size_direction() == 1 %$$ $head One Order$$ @@ -84,22 +84,22 @@ then we are only computing one order. In this case, before this call we must have $codei% - %f%.size_order() >= %q% - %f%.size_direction() == 1 + %f%.size_order() >= %q% + %f%.size_direction() == 1 %$$ $head q$$ The argument $icode q$$ has prototype $codei% - size_t %q% + size_t %q% %$$ and specifies the highest order of the Taylor coefficients to be calculated. $head xq$$ The argument $icode xq$$ has prototype $codei% - const %Vector%& %xq% + const %Vector%& %xq% %$$ (see $cref/Vector/forward_order/Vector/$$ below). As above, we use $icode n$$ to denote the dimension of the @@ -108,7 +108,7 @@ $icode%n%*(%q%+1)%$$. After this call we will have $codei% - %f%.size_order() == %q% + 1 + %f%.size_order() == %q% + 1 %$$ $subhead One Order$$ @@ -116,12 +116,12 @@ the $th q$$ order Taylor coefficient for $latex X(t)$$ is defined by $pre - $$ $latex x^{(q)} = $$ $icode xq$$. + $$ $latex x^{(q)} = $$ $icode xq$$. For $latex k = 0 , \ldots , q-1$$, the Taylor coefficient $latex x^{(k)}$$ is defined by $icode xk$$ in the previous call to $codei% - %f%.Forward(%k%, %xk%) + %f%.Forward(%k%, %xk%) %$$ $subhead Multiple Orders$$ @@ -131,10 +131,10 @@ 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% ]%$$ + $$ $latex x_j^{(k)} = $$ $icode%xq%[ (%q%+1) * %j% + %k% ]%$$ $subhead Restrictions$$ -Note if $icode f$$ uses $cref old_atomic$$ functions, +Note if $icode f$$ uses $cref atomic_one$$ functions, the size of $icode xq$$ must be $icode n$$. $head s$$ @@ -142,7 +142,7 @@ is used in its place. Otherwise, this argument has prototype $codei% - std::ostream& %s% + std::ostream& %s% %$$ If order zero is begin calculated, $icode s$$ specifies where the output corresponding to $cref PrintFor$$ @@ -152,38 +152,38 @@ $head X(t)$$ The function -$latex X : B \rightarrow B^n$$ is defined using -the Taylor coefficients $latex x^{(k)} \in B^n$$: +$latex X : \B{R} \rightarrow \B{R}^n$$ is defined using +the Taylor coefficients $latex x^{(k)} \in \B{R}^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 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 : \B{R} \rightarrow \B{R}^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{R}^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 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$$ The return value $icode yq$$ has prototype $codei% - %Vector% %yq% + %Vector% %yq% %$$ (see $cref/Vector/forward_order/Vector/$$ below). @@ -193,7 +193,7 @@ The $th q$$ order Taylor coefficient for $latex Y(t)$$ is returned as $codei% - %yq%$$ $latex = y^{(q)}$$. + %yq%$$ $latex = y^{(q)}$$. $subhead Multiple Orders$$ If $icode%xq%.size() == %n%*(%q%+1)%$$, @@ -203,7 +203,7 @@ 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 @@ -231,8 +231,8 @@ $cref/special case/forward_two/Special Case/$$. $children% - example/general/forward.cpp% - example/general/forward_order.cpp + example/general/forward.cpp% + example/general/forward_order.cpp %$$ $head Example$$ The file diff -Nru cppad-2018.00.00.0/omh/forward/forward_two.omh cppad-2019.02.00.0/omh/forward/forward_two.omh --- cppad-2018.00.00.0/omh/forward/forward_two.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/forward/forward_two.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,22 @@ -// $Id: forward_two.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin forward_two$$ $spell - Jacobian - Taylor - const + Jacobian + Taylor + const $$ $section Second Order Forward Mode: Derivative Values$$ -$mindex two$$ @@ -25,13 +24,13 @@ $icode%y2% = %f%.Forward(1, %x2%)%$$ $head Purpose$$ -We use $latex F : B^n \rightarrow B^m$$ to denote the +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The result of the syntax above is that for $icode%i% = 0 , %...% , %m%-1%$$, $codei% - %y2%[%i%]%$$ - $latex = F_i^{(1)} (x0) * x2 + \frac{1}{2} x1^T * F_i^{(2)} (x0) * x1$$ + %y2%[%i%]%$$ + $latex = F_i^{(1)} (x0) * x2 + \frac{1}{2} x1^T * F_i^{(2)} (x0) * x1$$ $pre $$ where @@ -42,12 +41,12 @@ $head f$$ The object $icode f$$ has prototype $codei% - ADFun<%Base%> %f% + ADFun<%Base%> %f% %$$ Note that the $cref ADFun$$ object $icode f$$ is not $code const$$. Before this call to $code Forward$$, the value returned by $codei% - %f%.size_order() + %f%.size_order() %$$ must be greater than or equal two. After this call it will be will be three (see $cref size_order$$). @@ -57,7 +56,7 @@ corresponds to the previous call to $cref forward_zero$$ using this ADFun object $icode f$$; i.e., $codei% - %f%.Forward(0, %x0%) + %f%.Forward(0, %x0%) %$$ If there is no previous call with the first argument zero, the value of the $cref/independent/Independent/$$ variables @@ -69,13 +68,13 @@ corresponds to the previous call to $cref forward_one$$ using this ADFun object $icode f$$; i.e., $codei% - %f%.Forward(1, %x1%) + %f%.Forward(1, %x1%) %$$ $head x2$$ The argument $icode x2$$ has prototype $codei% - const %Vector%& %x2% + const %Vector%& %x2% %$$ (see $cref/Vector/forward_two/Vector/$$ below) and its size must be equal to $icode n$$, the dimension of the @@ -84,7 +83,7 @@ $head y2$$ The result $icode y2$$ has prototype $codei% - %Vector% %y2% + %Vector% %y2% %$$ (see $cref/Vector/forward_two/Vector/$$ below) The size of $icode y1$$ is equal to $icode m$$, the dimension of the @@ -103,7 +102,6 @@ The file $cref forward.cpp$$ contains an example and test of this operation. -It returns true if it succeeds and false otherwise. $head Special Case$$ This is special case of $cref forward_order$$ where diff -Nru cppad-2018.00.00.0/omh/forward/forward_zero.omh cppad-2019.02.00.0/omh/forward/forward_zero.omh --- cppad-2018.00.00.0/omh/forward/forward_zero.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/forward/forward_zero.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,22 @@ -// $Id: forward_zero.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin forward_zero$$ $spell - std::cout - ostream - const - Taylor - dy - Jacobian + std::cout + ostream + const + Taylor + dy + Jacobian $$ $section Zero Order Forward Mode: Function Values$$ @@ -27,11 +27,11 @@ $icode%y0% = %f%.Forward(0, %x0%, %s%)%$$ $head Purpose$$ -We use $latex F : B^n \rightarrow B^m$$ to denote the +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. The result of the syntax above is $latex \[ - y0 = F(x0) + y0 = F(x0) \] $$ See the $cref/FunCheck discussion/FunCheck/Discussion/$$ for possible differences between $latex F(x)$$ and the algorithm that defined @@ -40,19 +40,19 @@ $head f$$ The object $icode f$$ has prototype $codei% - ADFun<%Base%> %f% + ADFun<%Base%> %f% %$$ Note that the $cref ADFun$$ object $icode f$$ is not $code const$$. After this call to $code Forward$$, the value returned by $codei% - %f%.size_order() + %f%.size_order() %$$ will be equal to one (see $cref size_order$$). $head x0$$ The argument $icode x0$$ has prototype $codei% - const %Vector%& %x0% + const %Vector%& %x0% %$$ (see $cref/Vector/forward_zero/Vector/$$ below) and its size must be equal to $icode n$$, the dimension of the @@ -63,7 +63,7 @@ is used in its place. Otherwise, this argument has prototype $codei% - std::ostream& %s% + std::ostream& %s% %$$ It specifies where the output corresponding to $cref PrintFor$$, and this zero order forward mode call, will be written. @@ -71,7 +71,7 @@ $head y0$$ The result $icode y0$$ has prototype $codei% - %Vector% %y0% + %Vector% %y0% %$$ (see $cref/Vector/forward_zero/Vector/$$ below) and its value is $latex F(x)$$ at $icode%x% = %x0%$$. @@ -89,7 +89,6 @@ The file $cref forward.cpp$$ contains an example and test of this operation. -It returns true if it succeeds and false otherwise. $head Special Case$$ This is special case of $cref forward_order$$ where @@ -107,7 +106,7 @@ $latex x^{(0)}$$ $codei%= %x0%$$, $latex X(t) = x^{(0)}$$, and $latex \[ - y^{(0)} = Y(t) = F[ X(t) ] = F( x^{(0)} ) + y^{(0)} = Y(t) = F[ X(t) ] = F( x^{(0)} ) \] $$ which agrees with the specifications for $icode y0$$ in the $cref/purpose/forward_zero/Purpose/$$ above. diff -Nru cppad-2018.00.00.0/omh/forward/size_order.omh cppad-2019.02.00.0/omh/forward/size_order.omh --- cppad-2018.00.00.0/omh/forward/size_order.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/forward/size_order.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,19 @@ -// $Id: size_order.omh 3779 2016-01-01 11:26:11Z 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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin size_order$$ $spell - var - Taylor - const + var + Taylor + const $$ $section Number Taylor Coefficient Orders Currently Stored$$ @@ -37,13 +37,13 @@ $head f$$ The object $icode f$$ has prototype $codei% - const ADFun<%Base%> %f% + const ADFun<%Base%> %f% %$$ $head s$$ The result $icode s$$ has prototype $codei% - size_t %s% + size_t %s% %$$ and is the number of Taylor coefficient orders, per variable,direction in the AD operation sequence, @@ -52,7 +52,7 @@ $head Constructor$$ Directly after the $cref FunConstruct$$ syntax $codei% - ADFun<%Base%> %f%(%x%, %y%) + ADFun<%Base%> %f%(%x%, %y%) %$$ the value of $icode s$$ returned by $code size_order$$ is one. This is because @@ -80,7 +80,7 @@ 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%) + %f%.capacity_order(%c%) %$$ does not affect the value $icode s$$ returned by $code size_order$$. Otherwise, @@ -93,6 +93,5 @@ The file $cref forward.cpp$$ contains an example and test of this operation. -It returns true if it succeeds and false otherwise. $end diff -Nru cppad-2018.00.00.0/omh/install/adolc_prefix.omh cppad-2019.02.00.0/omh/install/adolc_prefix.omh --- cppad-2018.00.00.0/omh/install/adolc_prefix.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/adolc_prefix.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,32 +1,31 @@ -// $Id: adolc_prefix.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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin adolc_prefix$$ $dollar @$$ $spell - dir - mul - cmake - includedirs - CppAD - adolc - adouble - colpack - cygdrive - Cygwin - bashrc + dir + mul + cmake + includedirs + CppAD + adolc + adouble + colpack + cygdrive + Cygwin + bashrc $$ $section Including the ADOL-C Examples and Tests$$ -$mindex adolc prefix get$$ $head Purpose$$ CppAD includes examples and tests that can use the AD package @@ -49,13 +48,13 @@ for one of the directories $icode dir$$ in $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$, $codei% - %adolc_prefix%/%dir%/adolc/adouble.h + %adolc_prefix%/%dir%/adolc/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% - --with-colpack=%adolc_prefix% + --with-colpack=%adolc_prefix% %$$ In other words ColPack is installed and with the same prefix as ACOL-C; see @@ -67,8 +66,8 @@ by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% - cd build/example - make check_example + cd build/example + make check_example %$$ If you do this, you will see an indication that the examples @@ -81,8 +80,8 @@ by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% - cd build/speed/adolc - make check_speed_adolc + cd build/speed/adolc + make check_speed_adolc %$$ After executing $code make check_speed_adolc$$, you can run a specific ADOL-C speed tests @@ -97,8 +96,8 @@ For example, if you use the $code bash$$ shell to run your programs, you could include $codei% - LD_LIBRARY_PATH=%adolc_prefix%/lib:@{LD_LIBRARY_PATH} - export LD_LIBRARY_PATH + LD_LIBRARY_PATH=%adolc_prefix%/lib:@{LD_LIBRARY_PATH} + export LD_LIBRARY_PATH %$$ in your $code @HOME/.bashrc$$ file. @@ -107,8 +106,8 @@ you may have to add to following lines to the file $code .bashrc$$ in your home directory: $codei% - PATH=%adolc_prefix%/bin:@{PATH} - export PATH + PATH=%adolc_prefix%/bin:@{PATH} + export PATH %$$ in order for ADOL-C to run properly. If $icode adolc_prefix$$ begins with a disk specification, @@ -118,7 +117,7 @@ $code /cygdrive/d/adolc_base$$ should be used for $icode adolc_prefix$$. $children% - bin/get_adolc.sh + bin/get_adolc.sh %$$ $head get_adolc$$ If you are using Unix, you can download and install diff -Nru cppad-2018.00.00.0/omh/install/autotools.omh cppad-2019.02.00.0/omh/install/autotools.omh --- cppad-2018.00.00.0/omh/install/autotools.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/autotools.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,57 +1,57 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin autotools$$ -$escape $$ $dollar ^$$ $spell - Autotools - CppAD - dist_dir - num - cxx - openmp - fadbad - ipopt - addr - hpp - adolc - eigen - sacado - cpp - cppad - gprof - sed - user - yyyymmdd - testvector - stdvector - boostvector - std - fopenmp - adouble - colpack - Linux - Cygwin - cygdrive - badiff - Ip - sizeof - op - arg - cpp - usr - htm - ublas - cp + Autotools + CppAD + dist_dir + num + cxx + openmp + fadbad + ipopt + addr + hpp + adolc + eigen + sacado + cpp + cppad + gprof + sed + user + yyyymmdd + testvector + stdvector + boostvector + std + fopenmp + adouble + colpack + Linux + Cygwin + cygdrive + badiff + Ip + sizeof + op + arg + cpp + usr + htm + ublas + cp $$ @@ -79,21 +79,21 @@ Execute the following command in the build directory: $codei% ./configure \ - --prefix=%prefix_dir% \ - --with-Documentation \ - --with-%test%vector \ - 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% + --prefix=%prefix_dir% \ + --with-Documentation \ + --with-%test%vector \ + 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. @@ -106,7 +106,7 @@ the build to the source directory and then builds some object libraries that are used by the tests: $codei% - make + make %$$ $subhead Examples and Tests$$ @@ -114,7 +114,7 @@ you can run the correctness and speed tests. The following command will build and run all the correctness and speed tests. $codep - make test + make test $$ $head Profiling CppAD$$ @@ -122,20 +122,20 @@ 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 + cd speed/profile + make test %$$ After executing $code make test$$, you can run a profile speed test by executing the command $codei% - ./speed_profile %test% %seed% %option_list% + ./speed_profile %test% %seed% %option_list% %$$ see $cref speed_main$$ for the meaning of the command line arguments to this program. After you have run a profiling speed test, you can then obtain the profiling results with $codei% - gprof -b speed_profile + gprof -b speed_profile %$$ In C++, template parameters and argument types become part of a routines's name. @@ -144,7 +144,7 @@ You can remove the template parameters and argument types from the routine names by executing the following command $codep - gprof -b speed_profile | sed -f gprof.sed + gprof -b speed_profile | sed -f gprof.sed $$ $head prefix_dir$$ @@ -155,16 +155,16 @@ As an example of using the $codei%--prefix=%prefix_dir%$$ option, if you specify $codep - ./configure --prefix=/usr/local + ./configure --prefix=/usr/local $$ the CppAD include files will be installed in the directory $codei% - /usr/local/include/cppad + /usr/local/include/cppad %$$ If $cref/--with-Documentation/autotools/--with-Documentation/$$ is specified, the CppAD documentation files will be installed in the directory $codei% - /usr/local/share/doc/cppad-%yyyymmdd% + /usr/local/share/doc/cppad-%yyyymmdd% %$$ where $icode yyyymmdd$$ is the year, month, and day corresponding to the version of CppAD. @@ -173,13 +173,13 @@ 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-%yyyymmdd% + %prefix_dir%/share/doc/%postfix_dir%/cppad-%yyyymmdd% %$$ (see $cref/postfix_dir/autotools/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-%yyyymmdd%/cppad.htm + %prefix_dir%/share/doc/%postfix_dir%/cppad-%yyyymmdd%/cppad.htm %$$ $head --with-testvector$$ @@ -188,15 +188,15 @@ 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 + --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> + std::vector<%Scalar%> + boost::numeric::ublas::vector<%Scalar%> + Eigen::matrix<%Scalar%, Eigen::Dynamic, 1> %$$ See also, $cref/boost_dir/autotools/boost_dir/$$ @@ -214,7 +214,7 @@ it specifies compiler flags. For example, $codei% - CXX_FLAGS="-Wall -ansi" + CXX_FLAGS="-Wall -ansi" %$$ would specify that warning flags $code -Wall$$ and $code -ansi$$ should be included @@ -231,7 +231,7 @@ For example, when using the GNU $code g++$$ compiler, the following setting includes the OpenMP tests: $codei% - OPENMP_FLAGS=-fopenmp + OPENMP_FLAGS=-fopenmp %$$ If you specify configure command, the CppAD OpenMP correctness and speed tests will be built; see @@ -244,17 +244,17 @@ As an example of using the $codei%POSTFIX_DIR=%postfix_dir%$$ option, if you specify $codep - ./configure --prefix=/usr/local POSTFIX_DIR=coin + ./configure --prefix=/usr/local POSTFIX_DIR=coin $$ the CppAD include files will be $cref/installed/autotools/make install/$$ in the directory $codei% - /usr/local/include/coin/cppad + /usr/local/include/coin/cppad %$$ If $cref/--with-Documentation/autotools/--with-Documentation/$$ is specified, the CppAD documentation files will be installed in the directory $codei% - /usr/local/share/doc/coin/cppad-%yyyymmdd% + /usr/local/share/doc/coin/cppad-%yyyymmdd% %$$ $head adolc_dir$$ @@ -265,14 +265,14 @@ $cref/configure/autotools/Configure/$$ command line. The value of $icode adolc_dir$$ must be such that $codei% - %adolc_dir%/include/adolc/adouble.h + %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 + cd speed/adolc + make test %$$ After executing $code make test$$, you can run an Adolc speed tests by executing the command $code ./adolc$$; @@ -281,7 +281,7 @@ Note that these speed tests assume Adolc has been configure with its sparse matrix computations enabled using $codei% - --with-colpack=%colpack_dir% + --with-colpack=%colpack_dir% %$$ $subhead Linux$$ @@ -290,8 +290,8 @@ 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 + LD_LIBRARY_PATH=%adolc_dir%/lib:^{LD_LIBRARY_PATH} + export LD_LIBRARY_PATH %$$ in your $code ^HOME/.bash_profile$$ file. @@ -300,8 +300,8 @@ 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 + PATH=%adolc_dir%/bin:^{PATH} + export PATH %$$ in order for Adolc to run properly. If $icode adolc_dir$$ begins with a disk specification, @@ -313,12 +313,12 @@ $head boost_dir$$ If the command line argument $codei% - BOOST_DIR=%boost_dir% + 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 + %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. @@ -331,7 +331,7 @@ specify a value for $icode eigen_dir$$. It must be such that $codei% - %eigen_dir%/include/Eigen/Core + %eigen_dir%/include/Eigen/Core %$$ is a valid include file. In this case CppAD will compile and test the Eigen examples; e.g., @@ -341,21 +341,21 @@ $head fadbad_dir$$ If you have $href% - http://www.fadbad.com/% - Fadbad 2.1 + 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 + %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 + cd speed/fadbad + make test %$$ After executing $code make test$$, you can run a Fadbad speed tests by executing the command $code ./fadbad$$; @@ -365,53 +365,53 @@ $head ipopt_dir$$ If you have $href% - http://www.coin-or.org/projects/Ipopt.xml% - Ipopt + 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 + %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 +examples 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 + 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$$. +see $code ipopt_ode_speed.cpp$$. $head sacado_dir$$ If you have $href% - http://trilinos.sandia.gov/packages/sacado/% - Sacado + 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 + %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 + cd speed/sacado + make test %$$ After executing $code make test$$, you can run a Sacado speed tests by executing the command $code ./sacado$$; @@ -430,7 +430,7 @@ the less memory is used. On the other hand, the value $codei% - std::numeric_limits<%tape_addr_type%>::max() + std::numeric_limits<%tape_addr_type%>::max() %$$ must be larger than any of the following: $cref/size_op/seq_property/size_op/$$, @@ -451,7 +451,7 @@ the less memory is used. On the other hand, the value $codei% - std::numeric_limits<%tape_id_type%>::max() + std::numeric_limits<%tape_id_type%>::max() %$$ must be larger than the maximum number of tapes per thread times $cref/max_num_threads/autotools/max_num_threads/$$. @@ -460,7 +460,7 @@ 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 + make install $$ This will install CppAD in the location specified by $cref/prefix_dir/autotools/prefix_dir/$$. @@ -468,7 +468,7 @@ directory to execute this command. You may optionally specify a destination directory for the install; i.e., $codei% - make install DESTDIR=%DestinationDirectory% + make install DESTDIR=%DestinationDirectory% %$$ $end diff -Nru cppad-2018.00.00.0/omh/install/cmake_check.omh cppad-2019.02.00.0/omh/install/cmake_check.omh --- cppad-2018.00.00.0/omh/install/cmake_check.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/cmake_check.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,24 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin cmake_check$$ $spell - nlp - cppad - makefiles - ipopt - CppAD - cmake - nmake - grep + nlp + cppad + makefiles + ipopt + CppAD + cmake + nmake + grep $$ $section Checking the CppAD Examples and Tests$$ @@ -34,49 +35,40 @@ $cref/distribution directory/download/Distribution Directory/$$ execute the command $codep - make check + make check $$ 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 commands -above and below; see -$cref/windows file extraction and testing - /download - /Windows File Extraction and Testing -/$$. - $head Subsets of make check$$ In unix, you can determine which subsets of $code make check$$ are available by putting the output of the $cref/cmake command/cmake/CMake Command/$$ in a file (called $icode cmake.out$$ below) and executing: $codei% - grep 'make check.*available' %cmake.out% + grep 'make check.*available' %cmake.out% %$$ $head First Level$$ The first level of subsets of $code make check$$ are described below: $table Command $cnext - Description + Description $rnext $code make check_introduction$$ $cnext - the $cref Introduction$$ functions + the $cref Introduction$$ functions $rnext $code make check_example$$ $cnext - the normal $cref/example/listallexamples/$$ functions plus some deprecated - examples. + the normal $cref/example/listallexamples/$$ functions plus some deprecated + examples. $rnext $code make check_test_more$$ $cnext - correctness tests that are not examples + correctness tests that are not examples $rnext $code make check_speed$$ $cnext - correctness for single thread $cref speed$$ tests + correctness for single thread $cref speed$$ tests $rnext $code make check_cppad_ipopt$$ $cnext - the deprecated $cref cppad_ipopt_nlp$$ speed and correctness tests + the deprecated $cref cppad_ipopt_nlp$$ speed and correctness tests $rnext $tend Note that $code make check_example_multi_thread$$ is used for the diff -Nru cppad-2018.00.00.0/omh/install/cmake.omh cppad-2019.02.00.0/omh/install/cmake.omh --- cppad-2018.00.00.0/omh/install/cmake.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/cmake.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,64 +1,73 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin cmake$$ $escape $$ $spell - cstdint - uint - pkgconfig - ctor - op - arg - sizeof - testvector - std - Wshadow - namespace - adouble - colpack - dir - makefile - usr - hpp - xml - ipopt - libcppad - CppAD - txt - Microsoft - Makefiles - cmake - Dcmake - cppad - adolc - boost - eigen - fadbad - sacado - datadir - docdir - includedirs - libdirs - cxx - max num - postfix - id - addr - grep - VecAD + msys + Hsc + autotools + mkdir + vcvarsall + cstdint + uint + pkgconfig + ctor + op + arg + sizeof + testvector + std + Wshadow + namespace + adouble + colpack + dir + makefile + usr + hpp + xml + ipopt + libcppad + CppAD + txt + Microsoft + Makefiles + cmake + Dcmake + cppad + adolc + boost + eigen + fadbad + sacado + datadir + docdir + includedirs + libdirs + cxx + max num + postfix + id + addr + grep + VecAD + minsys + mingw + pacman + gcc $$ $section Using CMake to Configure CppAD$$ -$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$$ @@ -70,32 +79,40 @@ Apple operating systems. For example, one can use it to automatically generate Microsoft project files. +$head Build Directory$$ +Create $code build$$, a subdirectory of the +$cref/distribution directory/download/Distribution Directory/$$, +change into the $code build$$. + $head CMake Command$$ -The command below assumes that $code cmake$$ is in your execution + +$subhead Simple$$ +The simplest version of the $code cmake$$ command is +$codei% + cmake .. +%$$ +This assumes that you are starting in the $code build$$ directory +(so that $code ..$$ refers to the distribution directory). +The command also assumes that $code cmake$$ is in your execution 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. +It is suggested that you should start with the simple version of the +cmake command above and then add options one at a time. -$subhead Build Directory$$ -Create a $code build$$ subdirectory of the -$cref/distribution directory/download/Distribution Directory/$$, -change into the $code build$$ directory, -and execute the following command: +$subhead Options$$ +The full version of the command, with all its optional arguments is: $codei% cmake %% \ -D CMAKE_VERBOSE_MAKEFILE=%cmake_verbose_makefile% \ -G %generator% \ - \ + \ -D cppad_prefix=%cppad_prefix% \ -D cppad_postfix=%cppad_postfix% \ - \ + \ -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% \ \ @@ -119,13 +136,80 @@ .. %$$ +$subhead msys2$$ +The $href%https://www.msys2.org/%msys2%$$ system, +with $code mingw-64$$ and $code g++$$, +has some requires some special procedures. +The following seems to work: +Use $code pacman$$ to install +$code make$$, $code gcc$$, and $code mingw-w64-x86_64-cmake$$. +Then use the following replacement for the simple cmake +and test command: +$codei% + cmake \ + -G 'Unix Makefiles' \ + -D CMAKE_C_COMPILER=gcc \ + -D CMAKE_CXX_COMPILER=g++ \ + .. + make check +%$$ + +$subhead Visual Studio$$ +The $href%https://www.msys2.org/%msys2%$$ system, +with $code mingw-64$$ and +$href%https://visualstudio.microsoft.com/vs/community/%visual studio%$$ +compiler has some requires some special procedures. +(Visual studio does not seem to be able to mix debug and release code.) +The following seems to work: +Use $code pacman$$ to install $code ming2-w64-x86_64-cmake$$. +Then, a dos shell and in the directory where $code vcvarsall.bat$$ +is located, run the commands +$codei| + call vcvarsall.bat x86 + cd %HOMEDIR% + SET PATH=C:\msys64\usr\bin;%PATH% + bash +|$$ +Then run the command +use the following replacement for the simple cmake command: +$codei% + mkdir build + cd build + cmake \ + -G 'NMake Makefiles' \ + -D debug_which=debug_all \ + .. +%$$ +Then open the project in Visual Studio and build the to level check. + +$subhead autotools$$ +The autotools build with the Visual Studio compiler should work +with the following configure and test commands +$codep + mkdir build + cd build + ../configure CC=cl CXX=cl CXX_FLAGS="-DEBUG" + make test +$$ +An optimized versions was tested using +$codep + ../configure CXX=cl CC=cl CXX_FLAGS="-DNDEBUG -O2 -EHsc" + make test +$$ +The commands above need to be run a Dos window, +that has the $code vcvarsall.bat$$ settings, +extend path that includes the $code msys2$$ bin directory, +and was running the bash shell inside the Doc window. +It is highly recommended that you use the $code cmake$$ commands above, +an not $code ../configure$$, when building with Visual Studio. + $head make check$$ Important information about the CppAD configuration is output by this command. If you have the $code grep$$ program, and store the output in $code cmake.log$$, you can get a list of all the test options with the command: $codep - grep 'make check' cmake.log + grep 'make check' cmake.log $$ $head cmake_verbose_makefile$$ @@ -152,7 +236,7 @@ This is the top level absolute path below which all of the CppAD files are installed by the command $codei% - make install + make install %$$ For example, if $icode cppad_prefix$$ is $code /usr$$, @@ -160,7 +244,7 @@ $icode cppad_postfix$$ is not specified, the file $code cppad.hpp$$ is installed in the location $codei% - /usr/include/cppad/cppad.hpp + /usr/include/cppad/cppad.hpp %$$ The default value for $icode cppad_prefix$$ is $code /usr$$. @@ -173,7 +257,7 @@ $icode cppad_postfix$$ is $code coin$$, the file $code cppad.hpp$$ is installed in the location $codei% - /usr/include/coin/cppad/cppad.hpp + /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. @@ -191,7 +275,7 @@ $icode cppad_postfix$$ is not specified, the file $code cppad.hpp$$ is installed in the location $codei% - /usr/include/cppad/cppad.hpp + /usr/include/cppad/cppad.hpp %$$ The default value for this directory list is $code include$$. @@ -209,7 +293,7 @@ and $icode ipopt_prefix$$ is specified, the file $code libcppad_ipopt.a$$ is installed in the location $codei% - /usr/lib/libcppad_ipopt.a + /usr/lib/libcppad_ipopt.a %$$ The default value for this directory list is $code lib$$. @@ -222,7 +306,7 @@ $icode cppad_postfix$$ is not specified, the $cref pkgconfig$$ file $code cppad.pc$$ is installed in the location $codei% - /usr/share/pkgconfig/cppad.pc + /usr/share/pkgconfig/cppad.pc %$$ The default value for $icode cmake_install_datadir$$ is $code share$$. @@ -235,7 +319,7 @@ $icode cppad_postfix$$ is not specified, the file $code cppad.xml$$ is installed in the location $codei% - /usr/share/doc/cppad/cppad.xml + /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. @@ -260,7 +344,7 @@ 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++11 -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, @@ -274,9 +358,9 @@ not be included in $icode cppad_cxx_flags$$. See also the $cref/CPPAD_DEBUG_AND_RELEASE - /preprocessor - /Documented Here - /CPPAD_DEBUG_AND_RELEASE + /preprocessor + /Documented Here + /CPPAD_DEBUG_AND_RELEASE /$$ compiler flag (which should not be included in $icode cppad_cxx_flags$$). @@ -318,7 +402,7 @@ the less memory is used. On the other hand, the value $codei% - std::numeric_limits<%cppad_tape_id_type%>::max() + std::numeric_limits<%cppad_tape_id_type%>::max() %$$ must be larger than the maximum number of tapes used by one thread times $cref/CPPAD_MAX_NUM_THREADS/multi_thread/CPPAD_MAX_NUM_THREADS/$$. @@ -343,7 +427,7 @@ the less memory is used. On the other hand, the value $codei% - std::numeric_limits<%cppad_tape_addr_type%>::max() + std::numeric_limits<%cppad_tape_addr_type%>::max() %$$ must be larger than any of the following: $cref/size_op/seq_property/size_op/$$, @@ -374,25 +458,18 @@ If $icode cppad_debug_which$$ does not appear on the command line, the default value $code debug_all$$ is used. -$subhead Exception$$ -The test corresponding to $code make cppad_ipopt_speed$$ -always get complied in release more (to avoid the extra time -it would take to run in debug mode). -Note that this test corresponds a deprecated interface; see -$cref cppad_ipopt_nlp$$. - $head cppad_deprecated$$ The default value for $icode cppad_deprecated$$ is $code NO$$ (the value $code YES$$ is not currently being used). $children% - omh/install/adolc_prefix.omh% - omh/install/colpack_prefix.omh% - omh/install/eigen_prefix.omh% - omh/install/fadbad_prefix.omh% - omh/install/ipopt_prefix.omh% - omh/install/sacado_prefix.omh% - omh/install/testvector.omh + omh/install/adolc_prefix.omh% + omh/install/colpack_prefix.omh% + omh/install/eigen_prefix.omh% + omh/install/fadbad_prefix.omh% + omh/install/ipopt_prefix.omh% + omh/install/sacado_prefix.omh% + omh/install/testvector.omh %$$ diff -Nru cppad-2018.00.00.0/omh/install/colpack_prefix.omh cppad-2019.02.00.0/omh/install/colpack_prefix.omh --- cppad-2018.00.00.0/omh/install/colpack_prefix.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/colpack_prefix.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,30 +1,30 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin colpack_prefix$$ $dollar @$$ $spell - datadir - cppad.hpp - namespace - std - CppAD - includedirs - colpack - cmake - dir - Jacobians + datadir + cppad.hpp + namespace + std + CppAD + includedirs + colpack + cmake + dir + Jacobians $$ $section Including the ColPack Sparsity Calculations$$ -$mindex prefix get$$ $head Purpose$$ If you specify a $icode colpack_prefix$$ on the @@ -40,14 +40,14 @@ for one of the directories $icode dir$$ in $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$, $codei% - %colpack_prefix%/%dir%/ColPack/ColPackHeaders.h + %colpack_prefix%/%dir%/ColPack/ColPackHeaders.h %$$ is a valid way to reference to the include file $code ColPackHeaders.h$$. $head cppad_lib$$ The ColPack header files has a $codei% - using namespace std + using namespace std %$$ at the global level. For this reason, CppAD does not include these files. @@ -55,16 +55,15 @@ when using ColPack. $children%example/sparse/colpack_jac.cpp - %example/sparse/colpack_jacobian.cpp - %example/sparse/colpack_hes.cpp - %example/sparse/colpack_hessian.cpp - %bin/get_colpack.sh + %example/sparse/colpack_jacobian.cpp + %example/sparse/colpack_hes.cpp + %example/sparse/colpack_hessian.cpp + %bin/get_colpack.sh %$$ $head Example$$ 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$$ If you are using Unix, you can download and install diff -Nru cppad-2018.00.00.0/omh/install/download.omh cppad-2019.02.00.0/omh/install/download.omh --- cppad-2018.00.00.0/omh/install/download.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/download.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,47 +1,42 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin download$$ -$escape $$ $spell - yyyy - mm - dd - vcdir - vcvarsall - Microsoft - mkdir - cmake - nmake - Makefiles - omhelp - svn - https - org - dir - exe - gpl - xzf - CppAD - cppad - gzip - yyyymmdd - rel - lic - epl - tgz - hpp - github - git git - htm + yyyy + mm + dd + omhelp + https + org + dir + exe + gpl + xzf + CppAD + cppad + rel + lic + epl + tgz + hpp + github + git git + htm + grep + txt + gh + html + svn $$ $dollar @$$ @@ -75,57 +70,22 @@ $icode%version%.%rel% = 20160000.0%$$ corresponds to the first release of the version for 2016, $code 20160000.1$$ corresponds to the first bug fix for 2016. - -$head License$$ -We use $icode lic$$ to denote the licence corresponding to an archived -version of CppAD. -The GNU General Public License is denoted by $icode%lic% = gpl%$$ -and the Eclipse Public License is denoted by $icode%lic% = epl%$$. - - -$head Compressed Archives$$ -The Coin compressed archives have the -documentation built into them. -If you downloading an old version using another method; see -$cref/building documentation/download/Building Documentation/$$. - - -$subhead Coin$$ -The compressed archive names on the -$href%http://www.coin-or.org/download/source/CppAD/%Coin download page%$$ -have one of the following formats: -$codei% - cppad-%version%.%rel%.%lic%.tgz - cppad-%version%.%lic%.tgz -%$$ -In Unix, you can extract these compressed archives using $code tar$$. -For example, -$codei% - tar -xzf cppad-%version%.%rel%.%lic%.tgz -%$$ -No matter what the format of the name, the corresponding distribution -directory is $codei%cppad-%version%$$. -To see that the extraction has been done correctly, -check for the following file: -$codei% - cppad-%version%/cppad/cppad.hpp -%$$ - -$subhead Github$$ The compressed archive names on the $href%https://github.com/coin-or/CppAD/releases%Github download page%$$ have the format $codei% - cppad-%version%.%rel%.tgz + cppad-%version%.%rel%.tgz %$$ -These archives correspond to the Eclipse Public License. +These archives correspond to the Eclipse Public License and do not have +the documentation included in them. - -$head Source Code Control$$ -These methods only provide the Eclipse Public License +$head License$$ +We use $icode lic$$ to denote the licence corresponding to an archived version of CppAD. +The GNU General Public License is denoted by $icode%lic% = gpl%$$ +and the Eclipse Public License is denoted by $icode%lic% = epl%$$. -$subhead Git$$ +$head Git$$ CppAD source code development is current done using $code git$$ You can a git clone of the current version using the command $codei% @@ -135,108 +95,71 @@ the $href|https://en.wikipedia.org/wiki/Git_%28software%29|git|$$ is installed on your system. -$subhead Subversion$$ -A subversion copy of the source code is kept on the Coin web site. -You can obtain this subversion copy using the command -$codei% - svn checkout https://projects.coin-or.org/svn/CppAD/trunk cppad.svn/trunk -%$$ -This procedure requires that -the $href%http://subversion.tigris.org/%subversion%$$ program -is installed on your system. - - -$head Monthly Versions$$ -Monthly versions of the compressed tar files are available on the -$href%http://www.coin-or.org/download/source/CppAD/%Coin download page%$$. -These are kept until the end of the current year, -when the next release is created. -The monthly versions have the form -$codei% - cppad-%yyyy%0101.%lic%.tgz -%$$ - -$head 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 -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 -Download and install the Visual Studio Express; for example -$href%http://www.microsoft.com/en-us/download/confirmation.aspx?id=44914 - %Visual Studio 2013 -%$$ -$lnext -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 -compressed archive: -$codei% - 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 -%$$ -$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) +$subhead Version$$ +After downloading the source code, +and changing into the distribution directory, +use the following command to determine the corresponding +$cref/version/download/Version/$$: +$codep + grep '^SET(cppad_version' CMakeLists.txt +$$ +Use the following command to determine the git $icode hash$$ code +corresponding to this version: +$codep + git show-ref | grep 'refs/heads/master' +$$ +You can get an old version using the command $codei% - mkdir build - cd build - cmake -G "NMake Makefiles" .. - nmake check + git checkout -q %hash% %$$ -$lend - +You can check the corresponding version number using the command +$codep + grep '^SET(cppad_version' CMakeLists.txt +$$ -$head Install Instructions$$ -The $cref install$$ instructions on this web site correspond to the -current version of CppAD. -If you are using an old version of CppAD -these instructions may work. -If you have trouble (or just to be careful), -you should follow the instructions in -the $code doc$$ subdirectory of the distribution directory. -If there is no such documentation, you can build it; see -$cref/building documentation/download/Building Documentation/$$. - -$head Building Documentation$$ -If you are using one of these download methods, -you can build the documentation to get the corresponding install instructions. +$subhead Compressed Archives$$ +You can build compressed archives with the GPL or EPL license using +the script $code bin/package.sh$$. +These archives have the documentation in the $code doc$$ directory +and do not have the $code git$$ information. +They are intended for re-distribution. + +$subhead Documentation$$ +The documentation at the web address +$href%https://coin-or.github.io/CppAD/doc/%$$ is for the +most recent version of CppAD. +You can get the documentation +for an other versions of CppAD. +To do so, in the distribution directory execute the following commands: +$codep + git checkout gh-pages + git log > junk.log +$$ +The file $code junk.log$$ will contain the git $icode hash$$ codes +for different version of the documentation along with the date. +Select the $icode hash$$ for the version you are using, execute the command +$codei% + git checkout %hash% +%$$ +You can then view documentation for version you are using by opening the file +$code doc/index.html$$ in a web browser. + +$subhead Building Documentation$$ +If you are using a version before $code 20170716$$, +you can build the documentation for the version you are using. The documentation for CppAD is built from the source code files using $href%http://www.seanet.com/~bradbell/omhelp/%OMhelp%$$. You will need to install the $code omhelp$$ command so that $codep - which omhelp + which omhelp $$ shows it is in your path. Once you have done this, in the distribution directory execute the following command: $codei% - bin/run_omhelp.sh htm + bin/run_omhelp.sh htm %$$ -You will then be able to follow the install instructions in -the $code doc$$ subdirectory of the distribution directory. - +You can then view documentation for version you are using by opening the file +$code doc/index.html$$ in a web browser. $end diff -Nru cppad-2018.00.00.0/omh/install/eigen_prefix.omh cppad-2019.02.00.0/omh/install/eigen_prefix.omh --- cppad-2018.00.00.0/omh/install/eigen_prefix.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/eigen_prefix.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,38 +1,39 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin eigen_prefix$$ $dollar @$$ $spell - testvector - dir - namespace - Eigen - Cpp - includedirs - cmake - det - cppad + testvector + dir + namespace + Eigen + Cpp + includedirs + cmake + det + cppad $$ $section Including the Eigen Examples and Tests$$ -$mindex prefix get$$ $head Purpose$$ CppAD can include the following examples and tests that use the linear algebra package $href%http://eigen.tuxfamily.org%Eigen%$$: -$comment check list with 'grep eigen omh/example_list.omh'$$ +$comment check list with: grep 'eigen.*\.cpp' omh/example_list.omh'$$ $table $rref cppad_eigen.hpp$$ $rref eigen_array.cpp$$ $rref eigen_det.cpp$$ +$rref sparse2eigen.cpp$$ $rref atomic_eigen_mat_mul.hpp$$ $rref atomic_eigen_mat_inv.hpp$$ $tend @@ -45,7 +46,7 @@ for one of the directories $icode dir$$ in $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$, $codei% - %eigen_prefix%/%dir%/Eigen/Core + %eigen_prefix%/%dir%/Eigen/Core %$$ is a valid way to reference to the include file $code Core$$; @@ -55,8 +56,8 @@ by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% - cd build/example - make check_example + cd build/example + make check_example %$$ If you do this, you will see an indication that the examples @@ -68,13 +69,13 @@ $head Test Vector$$ If you have specified $icode eigen_prefix$$ you can choose $codei% - -D cppad_testvector=eigen + -D cppad_testvector=eigen %$$ on the $cref/cmake command/cmake/CMake Command/$$ line. This we set the CppAD $cref testvector$$ to use Eigen vectors. $children% - bin/get_eigen.sh + bin/get_eigen.sh %$$ $head get_eigen$$ If you are using Unix, you can download and install diff -Nru cppad-2018.00.00.0/omh/install/fadbad_prefix.omh cppad-2019.02.00.0/omh/install/fadbad_prefix.omh --- cppad-2018.00.00.0/omh/install/fadbad_prefix.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/fadbad_prefix.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ -// $Id: fadbad_prefix.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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin fadbad_prefix$$ $dollar @$$ $spell - dir - CppAD - fadbad - cmake - badiff - includedirs + dir + CppAD + fadbad + cmake + badiff + includedirs $$ $section Including the FADBAD Speed Tests$$ -$mindex prefix get$$ $head Purpose$$ CppAD includes speed comparisons for the AD package @@ -37,7 +36,7 @@ for one of the directories $icode dir$$ in $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$, $codei% - %fadbad_prefix%/%dir%/FADBAD++/badiff.h + %fadbad_prefix%/%dir%/FADBAD++/badiff.h %$$ is a valid way to reference to the include file $code badiff.h$$; @@ -47,8 +46,8 @@ by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% - cd build/speed/fadbad - make check_speed_fadbad + cd build/speed/fadbad + make check_speed_fadbad %$$ After executing $code make check$$, you can run a specific FADBAD speed test by executing the command $code ./speed_fadbad$$; @@ -56,7 +55,7 @@ options to this program. $children% - bin/get_fadbad.sh + bin/get_fadbad.sh %$$ $head get_fadbad$$ If you are using Unix, you can download and install diff -Nru cppad-2018.00.00.0/omh/install/install.omh cppad-2019.02.00.0/omh/install/install.omh --- cppad-2018.00.00.0/omh/install/install.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/install.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin Install$$ $dollar @$$ $spell - autotools - makefiles - nmake - cmake - tarball - CppAD + autotools + makefiles + nmake + cmake + tarball + CppAD $$ @@ -38,23 +39,23 @@ $subhead Step 4: Installation$$ Use the command $codep - make install + make install $$ to install CppAD. If you created $code nmake$$ makefiles, you will have to use $codep - nmake install + nmake install $$ see the $cref/generator/cmake/generator/$$ option for the $code cmake$$ command. $childtable% - omh/install/download.omh% - omh/install/cmake.omh% - omh/install/cmake_check.omh% - omh/install/pkgconfig.omh + omh/install/download.omh% + omh/install/cmake.omh% + omh/install/cmake_check.omh% + omh/install/pkgconfig.omh %$$ $head Deprecated$$ diff -Nru cppad-2018.00.00.0/omh/install/ipopt_prefix.omh cppad-2019.02.00.0/omh/install/ipopt_prefix.omh --- cppad-2018.00.00.0/omh/install/ipopt_prefix.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/ipopt_prefix.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ -// $Id: ipopt_prefix.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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin ipopt_prefix$$ $dollar @$$ $spell - IpIpopt - dir - cppad - cmake - includedirs - hpp + IpIpopt + dir + cppad + cmake + includedirs + hpp $$ $section Including the cppad_ipopt Library and Tests$$ -$mindex ipopt cppad prefix get$$ $head Purpose$$ Includes the $cref cppad_ipopt_nlp$$ @@ -39,7 +38,7 @@ for one of the directories $icode dir$$ in $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$, $codei% - %ipopt_prefix%/%dir%/coin/IpIpoptApplication.hpp + %ipopt_prefix%/%dir%/coin/IpIpoptApplication.hpp %$$ is a valid way to reference to the include file $code IpIpoptApplication.hpp$$. @@ -50,12 +49,12 @@ by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% - cd cppad_ipopt - make check_ipopt + cd cppad_ipopt + make check_ipopt %$$ $children% - bin/get_ipopt.sh + bin/get_ipopt.sh %$$ $head get_ipopt$$ If you are using Unix, you can download and install diff -Nru cppad-2018.00.00.0/omh/install/pkgconfig.omh cppad-2019.02.00.0/omh/install/pkgconfig.omh --- cppad-2018.00.00.0/omh/install/pkgconfig.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/pkgconfig.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,32 +1,34 @@ -// $Id: pkgconfig.omh 3760 2015-12-01 04:12:28Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin pkgconfig$$ $spell - cmake - datadir - ipopt - CppAD - pkg-config - Cflags - Dir - builddir - prefixdir - cppad - pkgconfig - uninstalled + cmake + datadir + ipopt + CppAD + pkg-config + Cflags + Dir + builddir + libdir + libdirs + prefixdir + cppad + pkgconfig + uninstalled + colpack $$ $section CppAD pkg-config Files$$ -$mindex pc$$ $head Purpose$$ The $code pkg-config$$ package helps with the use of installed libraries; @@ -38,66 +40,72 @@ The necessary flags for compiling code that includes CppAD can be obtained with the command $codep - pkg-config --cflags cppad + pkg-config --cflags cppad $$ -Note that this command assumes $cref/cppad.pc/pkgconfig/$$ is in -the search path $code PKG_CONFIG_PATH$$. -If $cref ipopt_prefix$$ is specified, -the necessary flags for linking $cref/cppad_ipopt/cppad_ipopt_nlp/$$ -can be obtained with the commands +The flags for linking can be obtains with the command $codep - pkg-config --libs cppad + pkg-config --libs cppad $$ -Note that this command assumes $code ipopt.pc$$ is in +Note that this command assumes $cref/cppad.pc/pkgconfig/$$ is in the search path $code PKG_CONFIG_PATH$$. $head Defined Fields$$ +The $code pkg-config$$ files $code cppad.pc$$ and +$code cppad-uninstalled.pc$$ contain the following information: $table $icode Name$$ $cnext - A human-readable name for the CppAD package. + A human-readable name for the CppAD package. $rnext $icode Description$$ $cnext - A brief description of the CppAD package. + A brief description of the CppAD package. $rnext $icode URL$$ $cnext - A URL where people can get more information about the CppAD package. + A URL where people can get more information about the CppAD package. $rnext $icode Version$$ $cnext - A string specifically defining the version of the CppAD package. + A string specifically defining the version of the CppAD package. $rnext $icode Cflags$$ $cnext - The necessary flags for using any of the CppAD include files. + The necessary flags for using any of the CppAD include files. $rnext $icode Libs$$ $cnext - If $cref ipopt_prefix$$ is specified, - the necessary flags for using the $cref/cppad_ipopt/cppad_ipopt_nlp/$$ - library + The flags necessary for linking programs that use CppAD include files. $rnext $icode Requires$$ $cnext - If $cref ipopt_prefix$$ is specified, - the packages required to use the $cref/cppad_ipopt/cppad_ipopt_nlp/$$ - library + If $cref ipopt_prefix$$ is specified, + the packages required to use the $cref/cppad_ipopt/cppad_ipopt_nlp/$$ + library. $tend -$head CppAD Configuration Files$$ -In the table below, -$icode builddir$$ is the build directory; i.e., the directory where -the CppAD -$cref/cmake command/cmake/CMake Command/$$ is executed. -The directory $icode prefix$$ is the value of -$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 +$head CppAD Configuration Paths$$ +The location of $code cppad.pc$$ and $code cppad-uninstalled.pc$$ +are given below. +Note that $code cppad.pc$$ is placed in two locations. $table -$icode File$$ $cnext - $icode Description$$ $rnext -$icode%prefix%/%datadir%/pkgconfig/cppad.pc%$$ $cnext - for use after - $cref/make install/install/Instructions/Step 4: Installation/$$ +$bold Path$$ $cnext $bold Description$$ +$rnext +$icode builddir$$ $cnext + directory where the + $cref/cmake command/cmake/CMake Command/$$ is executed. +$rnext +$icode prefix$$ $cnext + value of $cref/cppad_prefix/cmake/cppad_prefix/$$ during configuration. +$rnext +$icode datadir$$ $cnext + value of $cref/cmake_install_datadir/cmake/cmake_install_datadir/$$. +$rnext +$icode libdir$$ $cnext + first directory in + $cref/cmake_install_libdirs/cmake/cmake_install_libdirs/$$. +$rnext +$icode%builddir%/pkgconfig/cppad-uninstalled.pc%$$ $cnext + for testing before $code make install$$ +$rnext +$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%prefix%/%libdir%/pkgconfig/cppad.pc%$$ $cnext $tend $end diff -Nru cppad-2018.00.00.0/omh/install/sacado_prefix.omh cppad-2019.02.00.0/omh/install/sacado_prefix.omh --- cppad-2018.00.00.0/omh/install/sacado_prefix.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/sacado_prefix.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ -// $Id: sacado_prefix.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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin sacado_prefix$$ $dollar @$$ $spell - dir - Sacado - includedirs - cmake - CppAD - hpp + dir + Sacado + includedirs + cmake + CppAD + hpp $$ $section Including the Sacado Speed Tests$$ -$mindex prefix get$$ $head Purpose$$ CppAD includes speed comparisons for the AD package @@ -37,7 +36,7 @@ for one of the directories $icode dir$$ in $cref/cmake_install_includedirs/cmake/cmake_install_includedirs/$$, $codei% - %sacado_prefix%/%dir%/Sacado.hpp + %sacado_prefix%/%dir%/Sacado.hpp %$$ is a valid way to reference to the include file $code Sacado.hpp$$; @@ -47,8 +46,8 @@ by executing the following commands starting in the $cref/distribution directory/download/Distribution Directory/$$: $codei% - cd build/speed/sacado - make check_speed_sacado + cd build/speed/sacado + make check_speed_sacado %$$ After executing $code make check_speed_sacado$$, you can run a specific Sacado speed test @@ -57,7 +56,7 @@ options to this program. $children% - bin/get_sacado.sh + bin/get_sacado.sh %$$ $head get_sacado$$ If you are using Unix, you can download and install diff -Nru cppad-2018.00.00.0/omh/install/testvector.omh cppad-2019.02.00.0/omh/install/testvector.omh --- cppad-2018.00.00.0/omh/install/testvector.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/install/testvector.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,23 @@ -// $Id: testvector.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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin cppad_testvector$$ $spell - CppAD - cppad - eigen - std - testvector - namespace - cmake + CppAD + cppad + eigen + std + testvector + namespace + cmake $$ $section Choosing the CppAD Test Vector Template Class$$ @@ -44,15 +44,15 @@ $head boost$$ 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 + http://www.boost.org/doc/libs/1_52_0/libs/numeric/ublas/doc/vector.htm% + boost ublas vector %$$ 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 + http://www.cmake.org/cmake/help/cmake2.6docs.html#module:FindBoost% + cmake FindBoost %$$ module must be able to automatically figure out where Boost is installed. diff -Nru cppad-2018.00.00.0/omh/introduction.omh cppad-2019.02.00.0/omh/introduction.omh --- cppad-2018.00.00.0/omh/introduction.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/introduction.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin Introduction$$ $spell - exp_eps - Griewank - Andreas - CppAD + exp_eps + Griewank + Andreas + CppAD $$ $section An Introduction by Example to Algorithmic Differentiation$$ -$mindex AD Automatic$$ $head Purpose$$ This is an introduction by example @@ -120,9 +120,9 @@ 2000. $childtable% - introduction/exp_2.hpp% - introduction/exp_eps.hpp% - introduction/introduction.cpp + introduction/exp_2.hpp% + introduction/exp_eps.hpp% + introduction/introduction.cpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/lu_det_and_solve.omh cppad-2019.02.00.0/omh/lu_det_and_solve.omh --- cppad-2018.00.00.0/omh/lu_det_and_solve.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/lu_det_and_solve.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,13 @@ -$Id: lu_det_and_solve.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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin LuDetAndSolve$$ @@ -15,12 +15,11 @@ $section Compute Determinants and Solve Equations by LU Factorization$$ -$mindex matrix factor linear$$ $childtable% - cppad/utility/lu_solve.hpp% - cppad/utility/lu_factor.hpp% - cppad/utility/lu_invert.hpp + include/cppad/utility/lu_solve.hpp% + include/cppad/utility/lu_factor.hpp% + include/cppad/utility/lu_invert.hpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/lu_factor_hpp.omh cppad-2019.02.00.0/omh/lu_factor_hpp.omh --- cppad-2018.00.00.0/omh/lu_factor_hpp.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/lu_factor_hpp.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: lu_factor_hpp.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin lu_factor.hpp$$ $spell - Lu - ifndef - endif + Lu + ifndef + endif $$ $section Source: LuFactor$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_LU_FACTOR_HPP -$srcfile%cppad/utility/lu_factor.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/utility/lu_factor.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/lu_invert_hpp.omh cppad-2019.02.00.0/omh/lu_invert_hpp.omh --- cppad-2018.00.00.0/omh/lu_invert_hpp.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/lu_invert_hpp.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: lu_invert_hpp.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin lu_invert.hpp$$ $spell - Lu - ifndef - endif + Lu + ifndef + endif $$ $section Source: LuInvert$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_LU_INVERT_HPP -$srcfile%cppad/utility/lu_invert.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/utility/lu_invert.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/lu_solve_hpp.omh cppad-2019.02.00.0/omh/lu_solve_hpp.omh --- cppad-2018.00.00.0/omh/lu_solve_hpp.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/lu_solve_hpp.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: lu_solve_hpp.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin lu_solve.hpp$$ $spell - Lu - ifndef - endif + Lu + ifndef + endif $$ $section Source: LuSolve$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_LU_SOLVE_HPP -$srcfile%cppad/utility/lu_solve.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/utility/lu_solve.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/mat_sum_sq_hpp.omh cppad-2019.02.00.0/omh/mat_sum_sq_hpp.omh --- cppad-2018.00.00.0/omh/mat_sum_sq_hpp.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/mat_sum_sq_hpp.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: mat_sum_sq_hpp.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin mat_sum_sq.hpp$$ $spell - sq - ifndef - endif + sq + ifndef + endif $$ $section Source: mat_sum_sq$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_MAT_SUM_SQ_HPP -$srcfile%cppad/speed/mat_sum_sq.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/speed/mat_sum_sq.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/mul_level.omh cppad-2019.02.00.0/omh/mul_level.omh --- cppad-2018.00.00.0/omh/mul_level.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/mul_level.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,23 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin mul_level$$ $spell - Taylor - fout - const - var - Cpp - Arg + Taylor + fout + const + var + Cpp + Arg $$ @@ -73,7 +74,7 @@ in the $codei AD$$ recording, we must first declaring these variables; i.e., $codei% - Independent(%a1x%) + Independent(%a1x%) %$$ where $icode a1x$$ is a $cref SimpleVector$$ with elements of type $codei AD$$. @@ -83,7 +84,7 @@ $subhead Start AD< AD > Recording$$ The next step is to declare the independent variables using $codei% - Independent(%a2x%) + Independent(%a2x%) %$$ where $icode a2x$$ is a $cref SimpleVector$$ with elements of type @@ -96,7 +97,7 @@ using $codei AD< AD >$$ class objects. We then stop the recording using $codei% - %a1f%.Dependent(%a2x%, %a2y%) + %a1f%.Dependent(%a2x%, %a2y%) %$$ where $icode a2y$$ is a $cref SimpleVector$$ with elements of type @@ -110,7 +111,7 @@ in the $codei AD$$ recording, it is preferred to delay declaring these variables to this point; i.e., $codei% - Independent(%a1x%) + Independent(%a1x%) %$$ where $icode a1x$$ is a $cref SimpleVector$$ with elements of type $codei AD$$. @@ -124,7 +125,7 @@ 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%) + %g%.Dependent(%a1x%, %a1y%) %$$ where $icode a1y$$ is a $cref SimpleVector$$ with elements of type @@ -136,8 +137,8 @@ the derivatives of the outer function. $children% - example/general/mul_level.cpp% - example/general/change_param.cpp + example/general/mul_level.cpp% + example/general/change_param.cpp %$$ $head Example$$ diff -Nru cppad-2018.00.00.0/omh/multi_thread.omh cppad-2019.02.00.0/omh/multi_thread.omh --- cppad-2018.00.00.0/omh/multi_thread.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/multi_thread.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,24 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin multi_thread$$ $spell - cppad_max_num_threads - alloc - CppAD - Rosen - Runge + cppad_max_num_threads + alloc + CppAD + Rosen + Runge $$ $section Using CppAD in a Multi-Threading Environment$$ -$mindex mode execution maximum number$$ $head Purpose$$ Extra steps and care must be taken to use CppAD @@ -79,8 +79,8 @@ $cref/ErrorHandler constructor/ErrorHandler/Constructor/Parallel Mode/$$. $childtable% - cppad/core/parallel_ad.hpp% - example/multi_thread/thread_test.cpp + include/cppad/core/parallel_ad.hpp% + example/multi_thread/thread_test.cpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/new_feature.omh cppad-2019.02.00.0/omh/new_feature.omh --- cppad-2018.00.00.0/omh/new_feature.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/new_feature.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,25 @@ -$Id: new_feature.omh 3779 2016-01-01 11:26:11Z bradbell $ -// BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- CppAD: 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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT $begin NewFeature$$ $spell - cppad.hpp - CppAD - Makefile - Microsoft - OMhelp - cvs - dsp - nobase + cppad.hpp + CppAD + Makefile + Microsoft + OMhelp + cvs + dsp + nobase $$ $section Adding a New Feature to the CppAD Distribution$$ diff -Nru cppad-2018.00.00.0/omh/numeric_type.omh cppad-2019.02.00.0/omh/numeric_type.omh --- cppad-2018.00.00.0/omh/numeric_type.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/numeric_type.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ /* $begin NumericType$$ $spell - const - std - valarray + const + std + valarray $$ $section Definition of a Numeric Type$$ -$mindex int$$ $head Type Requirements$$ A $icode NumericType$$ is any type @@ -33,7 +33,7 @@ $head Default Constructor$$ The syntax $codei% - %NumericType% %x%; + %NumericType% %x%; %$$ creates a $icode NumericType$$ object with an unspecified value. @@ -42,7 +42,7 @@ If $icode i$$ is an $code int$$, the syntax $codei% - %NumericType% %x%(%i%); + %NumericType% %x%(%i%); %$$ creates a $icode NumericType$$ object with a value equal to $icode i$$ where $icode i$$ can be $code const$$. @@ -51,7 +51,7 @@ If $icode x$$ is a $icode NumericType$$ object the syntax $codei% - %NumericType% %y%(%x%); + %NumericType% %y%(%x%); %$$ creates a $icode NumericType$$ object $icode y$$ with the same value as $icode x$$ @@ -61,14 +61,14 @@ If $icode x$$ and $icode y$$ are $icode NumericType$$ objects, the syntax $codei% - %x% = %y% + %x% = %y% %$$ sets the value of $icode x$$ equal to the value of $icode y$$ where $icode y$$ can be $code const$$. The expression corresponding to this operation is unspecified; i.e., it could be $code void$$ and hence $codei% - %x% = %y% = %z% + %x% = %y% = %z% %$$ may not be legal. @@ -81,37 +81,36 @@ be used just like a $icode NumericType$$ object. $table $bold Operation$$ $cnext $bold Description$$ $cnext - $bold Result Type$$ $rnext + $bold Result Type$$ $rnext $codei%+%x%$$ $cnext unary plus $cnext - $icode NumericType$$ $rnext + $icode NumericType$$ $rnext $codei%-%x%$$ $cnext unary minus $cnext - $icode NumericType$$ $rnext + $icode NumericType$$ $rnext $icode%x% + %y%$$ $cnext binary addition $cnext - $icode NumericType$$ $rnext + $icode NumericType$$ $rnext $icode%x% - %y%$$ $cnext binary subtraction $cnext - $icode NumericType$$ $rnext + $icode NumericType$$ $rnext $icode%x% * %y%$$ $cnext binary multiplication $cnext - $icode NumericType$$ $rnext + $icode NumericType$$ $rnext $icode%x% / %y%$$ $cnext binary division $cnext - $icode NumericType$$ $rnext + $icode NumericType$$ $rnext $icode%z% += %y%$$ $cnext compound assignment addition $cnext - unspecified $rnext + unspecified $rnext $icode%z% -= %y%$$ $cnext compound assignment subtraction $cnext - unspecified $rnext + unspecified $rnext $icode%z% *= %y%$$ $cnext compound assignment multiplication $cnext - unspecified $rnext + unspecified $rnext $icode%z% /= %y%$$ $cnext compound assignment division $cnext - unspecified + unspecified $tend $head Example$$ $children% - example/general/numeric_type.cpp + example/general/numeric_type.cpp %$$ The file $cref numeric_type.cpp$$ contains an example and test of using numeric types. -It returns true if it succeeds and false otherwise. (It is easy to modify to test additional numeric types.) $head Exercise$$ diff -Nru cppad-2018.00.00.0/omh/ode_evaluate.omh cppad-2019.02.00.0/omh/ode_evaluate.omh --- cppad-2018.00.00.0/omh/ode_evaluate.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/ode_evaluate.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,22 @@ -$Id: ode_evaluate.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin ode_evaluate.hpp$$ $spell - ifndef - endif + ifndef + endif $$ $section Source: ode_evaluate$$ -$mindex source$$ $code @@ -26,7 +25,7 @@ $$ # define CPPAD_ODE_EVALUATE_HPP -$srcfile%cppad/speed/ode_evaluate.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/speed/ode_evaluate.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/omp_alloc_dep.omh cppad-2019.02.00.0/omh/omp_alloc_dep.omh --- cppad-2018.00.00.0/omh/omp_alloc_dep.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/omp_alloc_dep.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,24 @@ -/* $Id: omp_alloc_dep.omh 3740 2015-10-07 03:47:28Z 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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin efficient$$ $spell - omp_alloc - ptr - num - bool - const + omp_alloc + ptr + num + bool + const $$ $section Check If A Memory Allocation is Efficient for Another Use$$ -$mindex omp_alloc reuse$$ $head Deprecated 2011-07-29$$ This function has been deprecated because speed tests seem to indicate @@ -35,7 +34,7 @@ $head v_ptr$$ This argument has prototype $codei% - const void* %v_ptr% + 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 get_memory$$ and not yet returned. @@ -43,7 +42,7 @@ $head num_bytes$$ This argument has prototype $codei% - size_t %num_bytes% + size_t %num_bytes% %$$ It specifies the number of bytes of the memory allocated by $icode v_ptr$$ that we want to use. @@ -51,7 +50,7 @@ $head flag$$ The return value has prototype $codei% - bool %flag% + bool %flag% %$$ It is true, a call to $code get_memory$$ with @@ -77,13 +76,12 @@ ------------------------------------------------------------------------------- $begin old_max_num_threads$$ $spell - inv - CppAD - num - omp_alloc + inv + CppAD + num + omp_alloc $$ $section Set Maximum Number of Threads for omp_alloc Allocator$$ -$mindex max_num_threads parallel OpenMP initialize$$ @@ -102,7 +100,7 @@ $head number$$ The argument $icode number$$ has prototype $codei% - size_t %number% + size_t %number% %$$ It must be greater than zero and specifies the maximum number of OpenMP threads that will be active at one time. diff -Nru cppad-2018.00.00.0/omh/poly_hpp.omh cppad-2019.02.00.0/omh/poly_hpp.omh --- cppad-2018.00.00.0/omh/poly_hpp.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/poly_hpp.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: poly_hpp.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin poly.hpp$$ $spell - Lu - ifndef - endif + Lu + ifndef + endif $$ $section Source: Poly$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_POLY_HPP -$srcfile%cppad/utility/poly.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/utility/poly.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/preprocessor.omh cppad-2019.02.00.0/omh/preprocessor.omh --- cppad-2018.00.00.0/omh/preprocessor.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/preprocessor.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,26 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin preprocessor$$ $spell - const - nullptr - CppADvector - Vec + Microsoft + const + nullptr + CppADvector + Vec $$ $section CppAD API Preprocessor Symbols$$ -$mindex CPPAD_ NULL pointer$$ -$head Purpose$$ +$head Rule$$ The CppAD include files defines preprocessor symbols all of which begin with $code CPPAD_$$. Note that there are some old, deprecated preprocessor symbols that @@ -27,6 +28,16 @@ In this section we list all of the CppAD preprocessor symbols that are part of the CppAD Application Interface (API). +$head NOMINMAX$$ +There is one exception to the rule above, +when using the Microsoft Visual Studio compiler +and including $code windows.h$$, +it is done as follows: +$codep + # define NOMINMAX + # include +$$ + $head Documented Here$$ $subhead CPPAD_DEBUG_AND_RELEASE$$ @@ -91,7 +102,7 @@ $rnext $cref/CPPAD_TRACK_COUNT/TrackNewDel/TrackCount/Macro/$$ $rnext -$cref/CPPAD_USER_ATOMIC/old_atomic/$$ +$cref/CPPAD_USER_ATOMIC/atomic_one/$$ $rnext $cref/CppADTrackNewVec/TrackNewDel/TrackNewVec/Previously Deprecated/$$ $rnext diff -Nru cppad-2018.00.00.0/omh/reverse/reverse_any.omh cppad-2019.02.00.0/omh/reverse/reverse_any.omh --- cppad-2018.00.00.0/omh/reverse/reverse_any.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/reverse/reverse_any.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,36 +1,36 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin reverse_any$$ $spell - checkpointing - typename - xk - xp - dw - Ind - uj - std - arg - const - Taylor + checkpointing + typename + xk + xp + dw + Ind + uj + std + arg + const + Taylor $$ $section Any Order Reverse Mode$$ -$mindex derivative$$ $head Syntax$$ $icode%dw% = %f%.Reverse(%q%, %w%)%$$ $head Purpose$$ -We use $latex F : B^n \rightarrow B^m$$ to denote the +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. Reverse mode computes the derivative of the $cref Forward$$ mode $cref/Taylor coefficients/glossary/Taylor Coefficient/$$ @@ -43,10 +43,10 @@ $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{R}^n$$ is defined as the value of $icode x_k$$ in the previous calls of the form $codei% - %f%.Forward(%k%, %x_k%) + %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 @@ -56,43 +56,43 @@ $subhead X(t, u)$$ The function -$latex X : B \times B^{n \times q} \rightarrow B^n$$ is defined by +$latex X : \B{R} \times \B{R}^{n \times q} \rightarrow \B{R}^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)$$ 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)$$ The function -$latex Y : B \times B^{n \times q} \rightarrow B^m$$ is defined by +$latex Y : \B{R} \times \B{R}^{n \times q} \rightarrow \B{R}^m$$ is defined by $latex \[ - Y(t, u) = F [ X(t,u) ] + Y(t, u) = F [ X(t,u) ] \]$$ $subhead w^(k)$$ If the argument $icode w$$ has size $icode%m% * %q%$$, for $latex k = 0 , \ldots , q-1$$ and $latex i = 0, \ldots , m-1$$, $latex \[ - w_i^{(k)} = w [ i * q + k ] + w_i^{(k)} = w [ i * q + k ] \] $$ If the argument $icode w$$ has size $icode m$$, for $latex k = 0 , \ldots , q-1$$ and $latex i = 0, \ldots , m-1$$, $latex \[ w_i^{(k)} = \left\{ \begin{array}{ll} - w [ i ] & {\rm if} \; k = q-1 - \\ - 0 & {\rm otherwise} + w [ i ] & {\rm if} \; k = q-1 + \\ + 0 & {\rm otherwise} \end{array} \right. \] $$ $subhead W(u)$$ -The function $latex W : B^{n \times q} \rightarrow B$$ is defined by +The function $latex W : \B{R}^{n \times q} \rightarrow \B{R}$$ is defined by $latex \[ W(u) = \sum_{k=0}^{q-1} ( w^{(k)} )^\R{T} \frac{1}{k !} \Dpow{k}{t} Y(0, u) \] $$ @@ -100,11 +100,11 @@ $head f$$ The object $icode f$$ has prototype $codei% - const ADFun<%Base%> %f% + const ADFun<%Base%> %f% %$$ Before this call to $code Reverse$$, the value returned by $codei% - %f%.size_order() + %f%.size_order() %$$ must be greater than or equal $icode q$$ (see $cref size_order$$). @@ -112,7 +112,7 @@ $head q$$ The argument $icode q$$ has prototype $codei% - size_t %q% + size_t %q% %$$ and specifies the number of Taylor coefficient orders to be differentiated (for each variable). @@ -121,7 +121,7 @@ $head w$$ The argument $icode w$$ has prototype $codei% - const %Vector% &%w% + const %Vector% &%w% %$$ (see $cref/Vector/reverse_any/Vector/$$ below) and its size @@ -134,14 +134,14 @@ $head dw$$ The return value $icode dw$$ has prototype $codei% - %Vector% %dw% + %Vector% %dw% %$$ (see $cref/Vector/reverse_any/Vector/$$ below). It is a vector with size $latex n \times q$$. 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 derivative is evaluated. @@ -150,7 +150,7 @@ $$ 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 derivative is evaluated. @@ -169,7 +169,7 @@ W(u) & = & w_0 F_0 [ X(0, u) ] + \cdots + w_m F_m [ X(0, u) ] \\ W^{(1)} (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} \] $$ This is the same as the result documented in $cref reverse_one$$. @@ -184,24 +184,24 @@ 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 + - w_m \partial_t \{ F_m [ X(t, u) ] \}_{t = 0} + w_0 \partial_t \{ F_0 [ X(t, u) ] \}_{t = 0} + + \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)} $$ @@ -219,8 +219,8 @@ $head Example$$ $children% - example/general/reverse_three.cpp% - example/general/reverse_checkpoint.cpp + example/general/reverse_three.cpp% + example/general/reverse_checkpoint.cpp %$$ $list number$$ diff -Nru cppad-2018.00.00.0/omh/reverse/reverse.omh cppad-2019.02.00.0/omh/reverse/reverse.omh --- cppad-2018.00.00.0/omh/reverse/reverse.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/reverse/reverse.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,17 +1,17 @@ -// $Id: reverse.omh 3779 2016-01-01 11:26:11Z 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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin Reverse$$ $spell - xq + xq $$ $section Reverse Mode$$ @@ -25,9 +25,9 @@ results are retained (the higher order forward results are lost). $childtable% - omh/reverse/reverse_one.omh% - omh/reverse/reverse_two.omh% - omh/reverse/reverse_any.omh + omh/reverse/reverse_one.omh% + omh/reverse/reverse_two.omh% + omh/reverse/reverse_any.omh %$$ $end diff -Nru cppad-2018.00.00.0/omh/reverse/reverse_one.omh cppad-2019.02.00.0/omh/reverse/reverse_one.omh --- cppad-2018.00.00.0/omh/reverse/reverse_one.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/reverse/reverse_one.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,21 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin reverse_one$$ $section First Order Reverse Mode$$ -$mindex derivative$$ $spell - taylor - const - dw + taylor + const + dw $$ @@ -24,16 +24,16 @@ $head Purpose$$ -We use $latex F : B^n \rightarrow B^m$$ to denote the +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. -The function $latex W : B^n \rightarrow B$$ is defined by +The function $latex W : \B{R}^n \rightarrow \B{R}$$ is defined by $latex \[ - W(x) = w_0 * F_0 ( x ) + \cdots + w_{m-1} * F_{m-1} (x) + W(x) = w_0 * F_0 ( x ) + \cdots + w_{m-1} * F_{m-1} (x) \] $$ 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) + 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$$ $cref/elementary vector/glossary/Elementary Vector/$$, @@ -42,11 +42,11 @@ $head f$$ The object $icode f$$ has prototype $codei% - const ADFun<%Base%> %f% + const ADFun<%Base%> %f% %$$ Before this call to $code Reverse$$, the value returned by $codei% - %f%.size_order() + %f%.size_order() %$$ must be greater than or equal one (see $cref size_order$$). @@ -55,7 +55,7 @@ corresponds to the previous call to $cref forward_zero$$ using this ADFun object $icode f$$; i.e., $codei% - %f%.Forward(0, %x%) + %f%.Forward(0, %x%) %$$ If there is no previous call with the first argument zero, the value of the $cref/independent/Independent/$$ variables @@ -65,7 +65,7 @@ $head w$$ The argument $icode w$$ has prototype $codei% - const %Vector% &%w% + const %Vector% &%w% %$$ (see $cref/Vector/reverse_one/Vector/$$ below) and its size @@ -75,7 +75,7 @@ $head dw$$ The result $icode dw$$ has prototype $codei% - %Vector% %dw% + %Vector% %dw% %$$ (see $cref/Vector/reverse_one/Vector/$$ below) and its value is the derivative $latex W^{(1)} (x)$$. @@ -92,11 +92,10 @@ $head Example$$ $children% - example/general/reverse_one.cpp + example/general/reverse_one.cpp %$$ The file $cref reverse_one.cpp$$ contains an example and test of this operation. -It returns true if it succeeds and false otherwise. $end diff -Nru cppad-2018.00.00.0/omh/reverse/reverse_two.omh cppad-2019.02.00.0/omh/reverse/reverse_two.omh --- cppad-2018.00.00.0/omh/reverse/reverse_two.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/reverse/reverse_two.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,21 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin reverse_two$$ $section Second Order Reverse Mode$$ -$mindex derivative$$ $spell - taylor - const - dw + taylor + const + dw $$ @@ -23,7 +23,7 @@ $icode%dw% = %f%.Reverse(2, %w%)%$$ $head Purpose$$ -We use $latex F : B^n \rightarrow B^m$$ to denote the +We use $latex F : \B{R}^n \rightarrow \B{R}^m$$ to denote the $cref/AD function/glossary/AD Function/$$ corresponding to $icode f$$. Reverse mode computes the derivative of the $cref Forward$$ mode $cref/Taylor coefficients/glossary/Taylor Coefficient/$$ @@ -31,10 +31,10 @@ $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{R}^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%) + %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 @@ -45,8 +45,8 @@ $head W$$ The functions -$latex W_0 : B^n \rightarrow B$$ and -$latex W_1 : B^n \rightarrow B$$ +$latex W_0 : \B{R}^n \rightarrow \B{R}$$ and +$latex W_1 : \B{R}^n \rightarrow \B{R}$$ are defined by $latex \[ \begin{array}{rcl} @@ -54,19 +54,19 @@ \\ W_1 ( u ) & = & w_0 * F_0^{(1)} ( u ) * x^{(1)} - + \cdots + w_{m-1} * F_{m-1}^{(1)} (u) * x^{(1)} + + \cdots + w_{m-1} * F_{m-1}^{(1)} (u) * x^{(1)} \end{array} \] $$ This operation computes the derivatives $latex \[ \begin{array}{rcl} W_0^{(1)} (u) & = & - w_0 * F_0^{(1)} ( u ) + \cdots + w_{m-1} * F_{m-1}^{(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_{m-1} * \left( x^{(1)} \right)^\R{T} F_{m-1}^{(2)} (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} \] $$ at $latex u = x^{(0)}$$. @@ -74,18 +74,18 @@ $head f$$ The object $icode f$$ has prototype $codei% - const ADFun<%Base%> %f% + const ADFun<%Base%> %f% %$$ Before this call to $code Reverse$$, the value returned by $codei% - %f%.size_order() + %f%.size_order() %$$ must be greater than or equal two (see $cref size_order$$). $head w$$ The argument $icode w$$ has prototype $codei% - const %Vector% &%w% + const %Vector% &%w% %$$ (see $cref/Vector/reverse_two/Vector/$$ below) and its size @@ -95,7 +95,7 @@ $head dw$$ The result $icode dw$$ has prototype $codei% - %Vector% %dw% + %Vector% %dw% %$$ (see $cref/Vector/reverse_two/Vector/$$ below). It contains both the derivative @@ -168,8 +168,8 @@ $head Example$$ $children% - example/general/reverse_two.cpp% - example/general/hes_times_dir.cpp + example/general/reverse_two.cpp% + example/general/hes_times_dir.cpp %$$ The files $cref reverse_two.cpp$$ diff -Nru cppad-2018.00.00.0/omh/seq_property.omh cppad-2019.02.00.0/omh/seq_property.omh --- cppad-2018.00.00.0/omh/seq_property.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/seq_property.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,32 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin seq_property$$ $spell - inuse - Addr - CppAD - sizeof - op - arg - enum - Taylor - const - bool - var - VecAD + inuse + Addr + CppAD + sizeof + op + arg + enum + Taylor + const + bool + var + VecAD + subgraph + dyn + ind $$ $section ADFun Sequence Properties$$ @@ -46,6 +50,14 @@ %$$ $icode%s% = %f%.size_VecAD() %$$ +$icode%s% = %f%.size_random() +%$$ +$icode%s% = %f%.size_dyn_ind() +%$$ +$icode%s% = %f%.size_dyn_par() +%$$ +$icode%s% = %f%.size_dyn_arg() +%$$ $icode%s% = %f%.size_op_seq() %$$ @@ -63,19 +75,19 @@ $head f$$ The object $icode f$$ has prototype $codei% - const ADFun<%Base%> %f% + const ADFun<%Base%> %f% %$$ (see $codei%ADFun<%Base%>%$$ $cref/constructor/FunConstruct/$$). $head Domain$$ The result $icode n$$ has prototype $codei% - size_t %n% + size_t %n% %$$ and is the dimension of the domain space corresponding to $icode f$$. This is equal to the size of the vector $icode x$$ in the call $codei% - Independent(%x%) + Independent(%x%) %$$ that starting recording the operation sequence currently stored in $icode f$$ @@ -84,16 +96,16 @@ $head Range$$ The result $icode m$$ has prototype $codei% - size_t %m% + size_t %m% %$$ and is the dimension of the range space corresponding to $icode f$$. This is equal to the size of the vector $icode y$$ in syntax $codei% - ADFun<%Base> %f%(%x%, %y%) + ADFun<%Base> %f%(%x%, %y%) %$$ or $codei% - %f%.Dependent(%y%) + %f%.Dependent(%y%) %$$ depending on which stored the operation sequence currently in $icode f$$ (see $cref FunConstruct$$ and $cref Dependent$$). @@ -101,12 +113,12 @@ $head Parameter$$ The argument $icode i$$ has prototype $codei% - size_t %i% + size_t %i% %$$ and $latex 0 \leq i < m$$. The result $icode p$$ has prototype $codei% - bool %p% + bool %p% %$$ It is true if the $th i$$ component of range space for $latex F$$ corresponds to a @@ -114,14 +126,14 @@ In this case, the $th i$$ component of $latex F$$ is constant and $latex \[ - \D{F_i}{x_j} (x) = 0 + \D{F_i}{x_j} (x) = 0 \] $$ -for $latex j = 0 , \ldots , n-1$$ and all $latex x \in B^n$$. +for $latex j = 0 , \ldots , n-1$$ and all $latex x \in \B{R}^n$$. $head size_var$$ The result $icode s$$ has prototype $codei% - size_t %s% + size_t %s% %$$ and is the number of variables in the operation sequence plus the following: one for a phantom variable with tape address zero, @@ -141,9 +153,10 @@ $head size_par$$ The result $icode s$$ has prototype $codei% - size_t %s% + size_t %s% %$$ -and is the number of parameters in the operation sequence. +and is the number of parameters in the operation sequence +(include a phantom parameter at index zero that is not used). 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 @@ -154,7 +167,7 @@ $head size_op$$ The result $icode s$$ has prototype $codei% - size_t %s% + size_t %s% %$$ and is the number of operations in the operation sequence. Some operators, like comparison operators, @@ -168,7 +181,7 @@ $head size_op_arg$$ The result $icode s$$ has prototype $codei% - size_t %s% + size_t %s% %$$ and is the total number of operator arguments in the operation sequence. For example, Binary operators (e.g. addition) have two arguments. @@ -180,7 +193,7 @@ $head size_text$$ The result $icode s$$ has prototype $codei% - size_t %s% + size_t %s% %$$ and is the total characters used in the $cref PrintFor$$ commands in this operation sequence. @@ -188,44 +201,102 @@ $head size_VecAD$$ The result $icode s$$ has prototype $codei% - size_t %s% + 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 independent variables are stored in the operation sequence. +$head size_random$$ +The result $icode s$$ has prototype +$codei% + size_t %s% +%$$ +and is the amount of memory currently holding information +for randomly access the operator sequence. +Random access is only used by the following routines +$cref subgraph_sparsity$$, +$cref subgraph_reverse$$, and +$cref optimize$$. +The optimize routine replaces the operation sequence, so the extra +memory is automatically dropped. +The subgraph routines hold onto this information +so that it does not need to be recalculated between calls. +The routine +$cref/clear_subgraph/subgraph_reverse/clear_subgraph/$$ +will free this extra memory. + +$head size_dyn_ind$$ +The result $icode s$$ has prototype +$codei% + size_t %s% +%$$ +and is the number of independent +$cref/dynamic/glossary/Parameter/Dynamic/$$ parameters +in the operation sequence. +This is the size of the +$cref/dynamic/Independent/dynamic/$$ parameter in the +corresponding call to $code Independent$$. + +$head size_dyn_par$$ +The result $icode s$$ has prototype +$codei% + size_t %s% +%$$ +and is the number of +$cref/dynamic/glossary/Parameter/Dynamic/$$ parameters. +The dynamic parameters depend on the value of +the independent dynamic parameters but not on the value of the variables. +This includes the independent dynamic parameters. + +$head size_dyn_arg$$ +The result $icode s$$ has prototype +$codei% + size_t %s% +%$$ +and is the total number of dynamic parameter operator arguments +in the operation sequence. +For example, Binary operators (e.g. addition) have two arguments. +Note that one integer index is stored in the operation sequence +for each argument. + + $head size_op_seq$$ The result $icode s$$ has prototype $codei% - size_t %s% + size_t %s% %$$ and is the amount of memory required to store the operation sequence (not counting a small amount of memory required for every operation sequence). For the current version of CppAD, this is given by $comment see size_t player::Memory(void)$$ $codei% - %s% = %f%.size_op() * sizeof(CppAD::local::OpCode) - + %f%.size_op_arg() * sizeof(%tape_addr_type%) - + %f%.size_par() * sizeof(%Base%) - + %f%.size_text() * sizeof(char) - + %f%.size_VecAD() * sizeof(%tape_addr_type%) - + %f%.size_op() * sizeof(%tape_addr_type%) * 3 + %s% = %f%.size_op() * sizeof(CPPAD_VEC_ENUM_TYPE) + + %f%.size_op_arg() * sizeof(%tape_addr_type%) + + %f%.size_par() * sizeof(%Base%) + + %f%.size_par() * sizeof(bool) + + %f%.size_dyn_par() * sizeof(CPPAD_VEC_ENUM_TYPE) + + %f%.size_dyn_par() * sizeof(%tape_addr_type%) + + %f%.size_dyn_arg() * sizeof(%tape_addr_type%) + + %f%.size_text() * sizeof(char) + + %f%.size_VecAD() * sizeof(%tape_addr_type%) %$$ see $cref/tape_addr_type/cmake/cppad_tape_addr_type/$$. Note that this is the minimal amount of memory that can hold the information corresponding to an operation sequence. The actual amount of memory allocated ($cref/inuse/ta_inuse/$$) for the operations sequence may be larger. +Also note that $code CPPAD_VEC_ENUM_TYPE$$ is not part +of the CppAD API and may change. $head Example$$ $children% - example/general/seq_property.cpp + example/general/seq_property.cpp %$$ The file $cref seq_property.cpp$$ contains an example and test of these operations. -It returns true if it succeeds and false otherwise. $end diff -Nru cppad-2018.00.00.0/omh/simple_vector.omh cppad-2019.02.00.0/omh/simple_vector.omh --- cppad-2018.00.00.0/omh/simple_vector.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/simple_vector.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,27 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ /* $begin SimpleVector$$ $spell - std - valarray - Cpp - const - Resize + std + valarray + Cpp + const + Resize $$ $section Definition of a Simple Vector$$ -$mindex value_type [] NDEBUG$$ $head Template Class Requirements$$ A simple vector template class $icode SimpleVector$$, @@ -43,7 +43,7 @@ A simple vector class with elements of type $icode Scalar$$, is any class that satisfies the requirements for a class of the form $codei% - %SimpleVector%<%Scalar%> + %SimpleVector%<%Scalar%> %$$ The routine $cref CheckSimpleVector$$ can be used to check that a class is a simple vector class with a specified element type. @@ -51,7 +51,7 @@ $head Default Constructor$$ The syntax $codei% - %SimpleVector%<%Scalar%> %x%; + %SimpleVector%<%Scalar%> %x%; %$$ creates an empty vector $icode x$$ ($icode%x%.size()%$$ is zero) that can later contain elements of the specified type @@ -60,7 +60,7 @@ $head Sizing Constructor$$ If $icode n$$ has type $code size_t$$, $codei% - %SimpleVector%<%Scalar%> %x%(%n%) + %SimpleVector%<%Scalar%> %x%(%n%) %$$ creates a vector $icode x$$ with $icode n$$ elements each of the specified type. @@ -68,7 +68,7 @@ $head Copy Constructor$$ If $icode x$$ is a $icode%SimpleVector%<%Scalar%>%$$ object, $codei% - %SimpleVector%<%Scalar%> %y%(%x%) + %SimpleVector%<%Scalar%> %y%(%x%) %$$ creates a vector with the same type and number of elements as $icode x$$. @@ -90,7 +90,7 @@ If $icode x$$ and $icode y$$ are $icode%SimpleVector%<%Scalar%>%$$ objects, $codei% - %y% = %x% + %y% = %x% %$$ uses the $icode Scalar$$ assignment operator ( $code =$$ ) to set each element of $icode y$$ equal to @@ -107,7 +107,7 @@ The type returned by this assignment is unspecified; for example, it might be void in which case the syntax $codei% - %z% = %y% = %x% + %z% = %y% = %x% %$$ would not be valid. @@ -115,7 +115,7 @@ If $icode x$$ is a $icode%SimpleVector%<%Scalar%>%$$ object and $code n$$ has type $code size_t$$, $codei% - %n% = size_t( %x%.size() ) + %n% = size_t( %x%.size() ) %$$ sets $icode n$$ to the number of elements in the vector $icode x$$. The object $icode x$$ may be $code const$$. @@ -124,7 +124,7 @@ If $icode x$$ is a $icode%SimpleVector%<%Scalar%>%$$ object and $code n$$ has type $code size_t$$, $codei% - %x%.resize(%n%) + %x%.resize(%n%) %$$ changes the number of elements contained in the vector $icode x$$ to be $icode n$$. @@ -137,11 +137,11 @@ If $icode Vector$$ is any simple vector class, the syntax $codei% - %Vector%::value_type + %Vector%::value_type %$$ is the type of the elements corresponding to the vector class; i.e., $codei% - %SimpleVector%<%Scalar%>::value_type + %SimpleVector%<%Scalar%>::value_type %$$ is equal to $icode Scalar$$. @@ -149,7 +149,7 @@ If $icode x$$ is a $icode%SimpleVector%<%Scalar%>%$$ object and $icode i$$ has type $code size_t$$, $codei% - %x%[%i%] + %x%[%i%] %$$ returns an object of an unspecified type, referred to here as $icode elementType$$. @@ -158,7 +158,7 @@ If $icode elementType$$ is not the same as $icode Scalar$$, the conversion operator $codei% - static_cast<%Scalar%>(%x%[%i%]) + static_cast<%Scalar%>(%x%[%i%]) %$$ is used implicitly when $icode%x%[%i%]%$$ is used in an expression with values of type $icode Scalar$$. @@ -167,25 +167,24 @@ $subhead Assignment$$ If $icode y$$ is an object of type $icode Scalar$$, $codei% - %x%[%i%] = %y% + %x%[%i%] = %y% %$$ assigns the $th i$$ element of $icode x$$ to have value $icode y$$. For this type of usage, the object $icode x$$ can not be $code const$$. The type returned by this assignment is unspecified; for example, it might be void in which case the syntax $codei% - %z% = %x%[%i%] = %y% + %z% = %x%[%i%] = %y% %$$ would not be valid. $head Example$$ $children% - example/utility/simple_vector.cpp + example/utility/simple_vector.cpp %$$ The file $cref simple_vector.cpp$$ contains an example and test of a Simple template class. -It returns true if it succeeds and false otherwise. (It is easy to modify to test additional simple vector template classes.) $head Exercise$$ @@ -193,8 +192,8 @@ If $icode Vector$$ is a simple vector template class, the following code may not be valid: $codei% - %Vector% x(2); - x[2] = 1.; + %Vector% x(2); + x[2] = 1.; %$$ Create and run a program that executes the code segment above where $icode Vector$$ is each of the following cases: @@ -206,11 +205,11 @@ If $icode Vector$$ is a simple vector template class, the following code may not be valid: $codei% - %Vector% x(2); - %Vector% y(1); - x[0] = 0; - x[1] = 1; - y = x; + %Vector% x(2); + %Vector% y(1); + x[0] = 0; + x[1] = 1; + y = x; %$$ Create and run a program that executes the code segment above where $icode Vector$$ is each of the following cases: diff -Nru cppad-2018.00.00.0/omh/sin_forward.omh cppad-2019.02.00.0/omh/sin_forward.omh --- cppad-2018.00.00.0/omh/sin_forward.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/sin_forward.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,38 +1,35 @@ -$Id: sin_forward.omh 3757 2015-11-30 12:03:07Z bradbell $ -// BEGIN SHORT COPYRIGHT /* -------------------------------------------------------------------------- CppAD: 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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ -// END SHORT COPYRIGHT $begin SinForward$$ $spell - sin - Taylor + sin + Taylor $$ $section Sine Function Forward Taylor Polynomial Theory$$ -$mindex sin$$ If $latex F(x) = \sin(x) $$ $latex \[ - 1 * F^{(1)} (x) - 0 * F (x) = \cos(x) + 1 * F^{(1)} (x) - 0 * F (x) = \cos(x) \] $$ and in the $xref/ - ForwardTheory/ - Standard Math Functions/ - Differential Equation/ - standard math function differential equation/ - 1 + ForwardTheory/ + Standard Math Functions/ + Differential Equation/ + standard math function differential equation/ + 1 /$$, $latex A(x) = 0$$, $latex B(x) = 1$$, @@ -47,11 +44,11 @@ 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 + ForwardTheory/ + Standard Math Functions/ + Taylor Coefficients Recursion Formula/ + Taylor coefficients recursion formula/ + 1 /$$ that for $latex j = 0 , 1, \ldots$$, $latex \[ @@ -65,12 +62,12 @@ \\ 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)} + \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) ]$$ @@ -79,7 +76,7 @@ by the following formula: $latex \[ s^{(j+1)} = \frac{1}{j+1} - \sum_{k=1}^{j+1} k x^{(k)} c^{(j+1-k)} + \sum_{k=1}^{j+1} k x^{(k)} c^{(j+1-k)} \] $$ $end diff -Nru cppad-2018.00.00.0/omh/sparse_hes_fun.omh cppad-2019.02.00.0/omh/sparse_hes_fun.omh --- cppad-2018.00.00.0/omh/sparse_hes_fun.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/sparse_hes_fun.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: sparse_hes_fun.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin sparse_hes_fun.hpp$$ $spell - hes - ifndef - endif + hes + ifndef + endif $$ $section Source: sparse_hes_fun$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_SPARSE_HES_FUN_HPP -$srcfile%cppad/speed/sparse_hes_fun.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/speed/sparse_hes_fun.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/sparse_jac_fun.omh cppad-2019.02.00.0/omh/sparse_jac_fun.omh --- cppad-2018.00.00.0/omh/sparse_jac_fun.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/sparse_jac_fun.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: sparse_jac_fun.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin sparse_jac_fun.hpp$$ $spell - jac - ifndef - endif + jac + ifndef + endif $$ $section Source: sparse_jac_fun$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_SPARSE_JAC_FUN_HPP -$srcfile%cppad/speed/sparse_jac_fun.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/speed/sparse_jac_fun.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/speed/speed_adolc.omh cppad-2019.02.00.0/omh/speed/speed_adolc.omh --- cppad-2018.00.00.0/omh/speed/speed_adolc.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/speed/speed_adolc.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,21 @@ -$Id: speed_adolc.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin speed_adolc$$ $spell - cmake - AdolcDir - CppAD - Cygwin + cmake + AdolcDir + CppAD + Cygwin $$ @@ -36,28 +36,28 @@ $head Running Tests$$ To build these speed tests, and run their correctness tests, execute the following commands starting in the -$cref/build directory/cmake/CMake Command/Build Directory/$$: +$cref/build directory/cmake/Build Directory/$$: $codei% - cd speed/adolc - make check_speed_adolc VERBOSE=1 + cd speed/adolc + make check_speed_adolc VERBOSE=1 %$$ You can then run the corresponding speed tests with the following command $codei% - ./speed_adolc speed %seed% + ./speed_adolc speed %seed% %$$ where $icode seed$$ is a positive integer. See $cref speed_main$$ for more options. $contents% - speed/adolc/det_minor.cpp% - speed/adolc/det_lu.cpp% - speed/adolc/mat_mul.cpp% - speed/adolc/ode.cpp% - speed/adolc/poly.cpp% - speed/adolc/sparse_hessian.cpp% - speed/adolc/sparse_jacobian.cpp% - speed/adolc/alloc_mat.cpp + speed/adolc/det_minor.cpp% + speed/adolc/det_lu.cpp% + speed/adolc/mat_mul.cpp% + speed/adolc/ode.cpp% + speed/adolc/poly.cpp% + speed/adolc/sparse_hessian.cpp% + speed/adolc/sparse_jacobian.cpp% + speed/adolc/alloc_mat.cpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/speed/speed_cppad.omh cppad-2019.02.00.0/omh/speed/speed_cppad.omh --- cppad-2018.00.00.0/omh/speed/speed_cppad.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/speed/speed_cppad.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,27 @@ -$Id: speed_cppad.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin speed_cppad$$ $spell - cmake - cppad - CppAD - Cygwin - Microsoft - chdir - Workspace - dsw - exe - sln + cmake + cppad + CppAD + Cygwin + Microsoft + chdir + Workspace + dsw + exe + sln $$ @@ -38,27 +38,27 @@ $head Running Tests$$ To build these speed tests, and run their correctness tests, execute the following commands starting in the -$cref/build directory/cmake/CMake Command/Build Directory/$$: +$cref/build directory/cmake/Build Directory/$$: $codei% - cd speed/cppad - make check_speed_cppad VERBOSE=1 + cd speed/cppad + make check_speed_cppad VERBOSE=1 %$$ You can then run the corresponding speed tests with the following command $codei% - ./speed_cppad speed %seed% + ./speed_cppad speed %seed% %$$ where $icode seed$$ is a positive integer. See $cref speed_main$$ for more options. $contents% - speed/cppad/det_minor.cpp% - speed/cppad/det_lu.cpp% - speed/cppad/mat_mul.cpp% - speed/cppad/ode.cpp% - speed/cppad/poly.cpp% - speed/cppad/sparse_hessian.cpp% - speed/cppad/sparse_jacobian.cpp + speed/cppad/det_minor.cpp% + speed/cppad/det_lu.cpp% + speed/cppad/mat_mul.cpp% + speed/cppad/ode.cpp% + speed/cppad/poly.cpp% + speed/cppad/sparse_hessian.cpp% + speed/cppad/sparse_jacobian.cpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/speed/speed_double.omh cppad-2019.02.00.0/omh/speed/speed_double.omh --- cppad-2018.00.00.0/omh/speed/speed_double.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/speed/speed_double.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,27 @@ -$Id: speed_double.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin speed_double$$ $spell - cmake - cppad - CppAD - Cygwin - Microsoft - chdir - Workspace - dsw - exe - sln + cmake + cppad + CppAD + Cygwin + Microsoft + chdir + Workspace + dsw + exe + sln $$ @@ -35,27 +35,27 @@ $head Running Tests$$ To build these speed tests, and run their correctness tests, execute the following commands starting in the -$cref/build directory/cmake/CMake Command/Build Directory/$$: +$cref/build directory/cmake/Build Directory/$$: $codei% - cd speed/double - make check_speed_double VERBOSE=1 + cd speed/double + make check_speed_double VERBOSE=1 %$$ You can then run the corresponding speed tests with the following command $codei% - ./speed_double speed %seed% + ./speed_double speed %seed% %$$ where $icode seed$$ is a positive integer. See $cref speed_main$$ for more options. $contents% - speed/double/det_minor.cpp% - speed/double/det_lu.cpp% - speed/double/mat_mul.cpp% - speed/double/ode.cpp% - speed/double/poly.cpp% - speed/double/sparse_hessian.cpp% - speed/double/sparse_jacobian.cpp + speed/double/det_minor.cpp% + speed/double/det_lu.cpp% + speed/double/mat_mul.cpp% + speed/double/ode.cpp% + speed/double/poly.cpp% + speed/double/sparse_hessian.cpp% + speed/double/sparse_jacobian.cpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/speed/speed_fadbad.omh cppad-2019.02.00.0/omh/speed/speed_fadbad.omh --- cppad-2018.00.00.0/omh/speed/speed_fadbad.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/speed/speed_fadbad.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,21 @@ -$Id: speed_fadbad.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin speed_fadbad$$ $spell - cmake - FadbadDir - CppAD - Cygwin + cmake + FadbadDir + CppAD + Cygwin $$ @@ -36,27 +36,27 @@ $head Running Tests$$ To build these speed tests, and run their correctness tests, execute the following commands starting in the -$cref/build directory/cmake/CMake Command/Build Directory/$$: +$cref/build directory/cmake/Build Directory/$$: $codei% - cd speed/fadbad - make check_speed_fadbad VERBOSE=1 + cd speed/fadbad + make check_speed_fadbad VERBOSE=1 %$$ You can then run the corresponding speed tests with the following command $codei% - ./speed_fadbad speed %seed% + ./speed_fadbad speed %seed% %$$ where $icode seed$$ is a positive integer. See $cref speed_main$$ for more options. $contents% - speed/fadbad/det_minor.cpp% - speed/fadbad/det_lu.cpp% - speed/fadbad/mat_mul.cpp% - speed/fadbad/ode.cpp% - speed/fadbad/poly.cpp% - speed/fadbad/sparse_hessian.cpp% - speed/fadbad/sparse_jacobian.cpp + speed/fadbad/det_minor.cpp% + speed/fadbad/det_lu.cpp% + speed/fadbad/mat_mul.cpp% + speed/fadbad/ode.cpp% + speed/fadbad/poly.cpp% + speed/fadbad/sparse_hessian.cpp% + speed/fadbad/sparse_jacobian.cpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/speed/speed.omh cppad-2019.02.00.0/omh/speed/speed.omh --- cppad-2018.00.00.0/omh/speed/speed.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/speed/speed.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin speed$$ $spell - cppad - CppAD - cmake + cppad + CppAD + cmake $$ @@ -28,16 +29,16 @@ Adolc %$$, $href% - http://www.coin-or.org/CppAD/% - CppAD + http://www.coin-or.org/CppAD/% + CppAD %$$, $href% http://www.fadbad.com/% Fadbad %$$ and $href% - http://trilinos.sandia.gov/packages/sacado/% - Sacado + http://trilinos.sandia.gov/packages/sacado/% + Sacado %$$. $head debug_which$$ @@ -52,13 +53,13 @@ The sections below explain how you can run these tests on your computer. $childtable% - speed/main.cpp% - omh/speed/speed_utility.omh% - omh/speed/speed_double.omh% - omh/speed/speed_adolc.omh% - omh/speed/speed_cppad.omh% - omh/speed/speed_fadbad.omh% - omh/speed/speed_sacado.omh + speed/main.cpp% + omh/speed/speed_utility.omh% + omh/speed/speed_double.omh% + omh/speed/speed_adolc.omh% + omh/speed/speed_cppad.omh% + omh/speed/speed_fadbad.omh% + omh/speed/speed_sacado.omh %$$ $end diff -Nru cppad-2018.00.00.0/omh/speed/speed_sacado.omh cppad-2019.02.00.0/omh/speed/speed_sacado.omh --- cppad-2018.00.00.0/omh/speed/speed_sacado.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/speed/speed_sacado.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,21 @@ -$Id: speed_sacado.omh 3757 2015-11-30 12:03:07Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin speed_sacado$$ $spell - cmake - SacadoDir - CppAD - Cygwin + cmake + SacadoDir + CppAD + Cygwin $$ @@ -36,27 +36,27 @@ $head Running Tests$$ To build these speed tests, and run their correctness tests, execute the following commands starting in the -$cref/build directory/cmake/CMake Command/Build Directory/$$: +$cref/build directory/cmake/Build Directory/$$: $codei% - cd speed/sacado - make check_speed_sacado VERBOSE=1 + cd speed/sacado + make check_speed_sacado VERBOSE=1 %$$ You can then run the corresponding speed tests with the following command $codei% - ./speed_sacado speed %seed% + ./speed_sacado speed %seed% %$$ where $icode seed$$ is a positive integer. See $cref speed_main$$ for more options. $contents% - speed/sacado/det_minor.cpp% - speed/sacado/det_lu.cpp% - speed/sacado/mat_mul.cpp% - speed/sacado/ode.cpp% - speed/sacado/poly.cpp% - speed/sacado/sparse_hessian.cpp% - speed/sacado/sparse_jacobian.cpp + speed/sacado/det_minor.cpp% + speed/sacado/det_lu.cpp% + speed/sacado/mat_mul.cpp% + speed/sacado/ode.cpp% + speed/sacado/poly.cpp% + speed/sacado/sparse_hessian.cpp% + speed/sacado/sparse_jacobian.cpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/speed/speed_utility.omh cppad-2019.02.00.0/omh/speed/speed_utility.omh --- cppad-2018.00.00.0/omh/speed/speed_utility.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/speed/speed_utility.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,13 @@ -$Id: speed_utility.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. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin speed_utility$$ @@ -16,16 +16,16 @@ $children% - cppad/speed/det_by_lu.hpp% - cppad/speed/det_of_minor.hpp% - cppad/speed/det_by_minor.hpp% - cppad/speed/det_33.hpp% - cppad/speed/det_grad_33.hpp% - cppad/speed/mat_sum_sq.hpp% - cppad/speed/ode_evaluate.hpp% - cppad/speed/sparse_jac_fun.hpp% - cppad/speed/sparse_hes_fun.hpp% - cppad/speed/uniform_01.hpp + include/cppad/speed/det_by_lu.hpp% + include/cppad/speed/det_of_minor.hpp% + include/cppad/speed/det_by_minor.hpp% + include/cppad/speed/det_33.hpp% + include/cppad/speed/det_grad_33.hpp% + include/cppad/speed/mat_sum_sq.hpp% + include/cppad/speed/ode_evaluate.hpp% + include/cppad/speed/sparse_jac_fun.hpp% + include/cppad/speed/sparse_hes_fun.hpp% + include/cppad/speed/uniform_01.hpp %$$ $head Speed Main Program$$ diff -Nru cppad-2018.00.00.0/omh/subversion.omh cppad-2019.02.00.0/omh/subversion.omh --- cppad-2018.00.00.0/omh/subversion.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/subversion.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,37 +1,37 @@ -$Id: subversion.omh 3921 2017-05-14 15:26:14Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin subversion$$ $spell - mkdir - omh - noframe - http - www - xml - htm - config - yyyymmdd - yyyy - mm - dd - omhelp - cppad - OMhelp - CppAD - svn - https - org - dir - hpp + mkdir + omh + noframe + http + www + xml + htm + config + yyyymmdd + yyyy + mm + dd + omhelp + cppad + OMhelp + CppAD + svn + https + org + dir + hpp $$ $section Using Subversion To Download Source Code$$ @@ -48,7 +48,7 @@ In Unix, you can check if subversion is already installed in your path by entering the command $codep - which svn + which svn $$ @@ -58,19 +58,19 @@ In Unix, you can check if OMhelp is already installed in your path by entering the command $codep - which omhelp + which omhelp $$ $head Current Version$$ 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% + svn co https://projects.coin-or.org/svn/CppAD/%dir% %dir% %$$ where $icode dir$$ is replaced by $code trunk$$. To see if this has been done correctly, check for the following file: $codei% - %dir%/cppad/cppad.hpp + %dir%/include/cppad/cppad.hpp %$$ $head Stable Versions$$ @@ -79,17 +79,17 @@ The following link will list the available $icode dir$$ values corresponding to $href% - https://projects.coin-or.org/CppAD/browser/stable% - stable versions + https://projects.coin-or.org/CppAD/browser/stable% + stable versions %$$. 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% + svn co https://projects.coin-or.org/svn/CppAD/stable/%dir% %dir% %$$ To see if this has been done correctly, check for the following file: $codei% - %dir%/cppad/cppad.hpp + %dir%/include/cppad/cppad.hpp %$$ Note that it will correspond to the most recent release for this stable version. @@ -100,24 +100,24 @@ The following link will list the available $icode dir$$ values corresponding to $href% - https://projects.coin-or.org/CppAD/browser/releases% - release versions + https://projects.coin-or.org/CppAD/browser/releases% + release versions %$$. 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% + svn co https://projects.coin-or.org/svn/CppAD/releases/%dir% %dir% %$$ To see if this has been done correctly, check for the following file: $codei% - %dir%/cppad/cppad.hpp + %dir%/include/cppad/cppad.hpp %$$ $head Build the Documentation$$ Now build the documentation for this version using the commands $codei% - cd %dir% - bin/autotools.sh configure omhelp + cd %dir% + bin/autotools.sh configure omhelp %$$ $head Continue with Installation$$ @@ -126,7 +126,7 @@ the documentation you just built. Start by opening the file $codei% - %dir%/doc/index.xml + %dir%/doc/index.xml %$$ in a web browser and proceeding to the install instructions in that documentation, diff -Nru cppad-2018.00.00.0/omh/theory/acos_forward.omh cppad-2019.02.00.0/omh/theory/acos_forward.omh --- cppad-2018.00.00.0/omh/theory/acos_forward.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/acos_forward.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,116 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin acos_forward$$ +$spell + acos + acosh + Arccosine + Taylor +$$ + +$section Inverse Cosine and Hyperbolic Cosine Forward Mode Theory$$ + +$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{ \mp ( x * x - 1 ) } * F^{(1)} (x) - 0 * F (u) = \mp 1 +\] $$ +and in the +$cref/standard math function differential equation + /ForwardTheory + /Standard Math Functions + /Differential Equation +/$$, +$latex A(x) = 0$$, +$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 D [ X (t) ] $$, +and $latex F [ X(t) ] $$ respectively. + +$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} + \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 +$latex B[ X(t) ] = \sqrt{ Q[ X(t) ] }$$ and +from the equations for the +$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)} } + \left( + \frac{j+1}{2} q^{(j+1) } + - \sum_{k=1}^j k b^{(k)} b^{(j+1-k)} + \right) +\end{array} +\] $$ +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$$, +$latex \[ +\begin{array}{rcl} +z^{(0)} & = & F ( x^{(0)} ) +\\ +e^{(j)} +& = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} +\\ +& = & \left\{ \begin{array}{ll} + \mp 1 & {\rm if} \; j = 0 \\ + 0 & {\rm otherwise} +\end{array} \right. +\\ +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)} +\right) +\\ +z^{(j+1)} & = & \frac{1}{j+1} \frac{1}{ b^{(0)} } +\left( + \mp (j+1) x^{(j+1)} + - \sum_{k=1}^j k z^{(k)} b^{(j+1-k)} +\right) +\end{array} +\] $$ + + +$end diff -Nru cppad-2018.00.00.0/omh/theory/acos_reverse.omh cppad-2019.02.00.0/omh/theory/acos_reverse.omh --- cppad-2018.00.00.0/omh/theory/acos_reverse.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/acos_reverse.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,158 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin acos_reverse$$ +$spell + acosh + acos + Taylor +$$ + +$section Inverse Cosine and Hyperbolic Cosine Reverse Mode Theory$$ + + +We use the reverse theory +$cref%standard math function + %ReverseTheory + %Standard Math Functions +%$$ +definition for the functions $latex H$$ and $latex G$$. +In addition, we use the forward mode notation in +$cref acos_forward$$ for +$latex \[ +\begin{array}{rcl} + 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 zero order forward mode formulas for the +$cref/acos/acos_forward/$$ +function are +$latex \[ +\begin{array}{rcl} + q^{(0)} & = & \mp ( x^{(0)} x^{(0)} - 1) \\ + b^{(0)} & = & \sqrt{ q^{(0)} } \\ + z^{(0)} & = & F ( x^{(0)} ) +\end{array} +\] $$ +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)} & = & + \mp \sum_{k=0}^j x^{(k)} x^{(j-k)} +\\ +b^{(j)} & = & + \frac{1}{j} \frac{1}{ b^{(0)} } + \left( + \frac{j}{2} q^{(j)} + - \sum_{k=1}^{j-1} k b^{(k)} b^{(j-k)} + \right) +\\ +z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} } +\left( + \mp j x^{(j)} + - \sum_{k=1}^{j-1} k z^{(k)} b^{(j-k)} +\right) +\end{array} +\] $$ + +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^{(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)} } +\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{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^{(j)} } \frac{ b^{(j)} }{ b^{(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)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(j)} }{ b^{(0)} } +\\ +\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)} } +\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{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)} } \frac{ b^{(k)} }{ b^{(0)} } +\\ +\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)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(j-k)} }{ b^{(0)} } +\\ +\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)} } +\end{array} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/asin_forward.omh cppad-2019.02.00.0/omh/theory/asin_forward.omh --- cppad-2018.00.00.0/omh/theory/asin_forward.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/asin_forward.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,115 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin asin_forward$$ +$spell + asinh + asin + Taylor +$$ + +$section Inverse Sine and Hyperbolic Sine Forward Mode Theory$$ + +$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 \mp x * x } * F^{(1)} (x) - 0 * F (u) = 1 +\] $$ +and in the +$cref/standard math function differential equation + /ForwardTheory + /Standard Math Functions + /Differential Equation +/$$, +$latex A(x) = 0$$, +$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 +Taylor coefficients for +$latex A [ X (t) ] $$, +$latex B [ X (t) ]$$, +$latex D [ X (t) ] $$, +and $latex F [ X(t) ] $$ respectively. + +$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 \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 +$latex B[ X(t) ] = \sqrt{ Q[ X(t) ] }$$ and +from the equations for the +$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)} } + \left( + \frac{j+1}{2} q^{(j+1) } + - \sum_{k=1}^j k b^{(k)} b^{(j+1-k)} + \right) +\end{array} +\] $$ +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$$, +$latex \[ +\begin{array}{rcl} +z^{(0)} & = & F ( x^{(0)} ) +\\ +e^{(j)} +& = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} +\\ +& = & \left\{ \begin{array}{ll} + 1 & {\rm if} \; j = 0 \\ + 0 & {\rm otherwise} +\end{array} \right. +\\ +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)} +\right) +\\ +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)} +\right) +\end{array} +\] $$ + + +$end diff -Nru cppad-2018.00.00.0/omh/theory/asin_reverse.omh cppad-2019.02.00.0/omh/theory/asin_reverse.omh --- cppad-2018.00.00.0/omh/theory/asin_reverse.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/asin_reverse.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,157 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin asin_reverse$$ +$spell + asinh + asin + Taylor +$$ + +$section Inverse Sine and Hyperbolic Sine Reverse Mode Theory$$ + + +We use the reverse theory +$cref%standard math function + %ReverseTheory + %Standard Math Functions +%$$ +definition for the functions $latex H$$ and $latex G$$. +In addition, we use the forward mode notation in +$cref asin_forward$$ for +$latex \[ +\begin{array}{rcl} + 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 zero order forward mode formulas for the +$cref/asin/asin_forward/$$ +function are +$latex \[ +\begin{array}{rcl} + q^{(0)} & = & 1 \mp x^{(0)} x^{(0)} \\ + b^{(0)} & = & \sqrt{ q^{(0)} } \\ + z^{(0)} & = & F( x^{(0)} ) +\end{array} +\] $$ +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)} & = & + \mp \sum_{k=0}^j x^{(k)} x^{(j-k)} +\\ +b^{(j)} & = & + \frac{1}{j} \frac{1}{ b^{(0)} } + \left( + \frac{j}{2} q^{(j)} + - \sum_{k=1}^{j-1} k b^{(k)} b^{(j-k)} + \right) +\\ +z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} } +\left( + j x^{(j)} + - \sum_{k=1}^{j-1} k z^{(k)} b^{(j-k)} +\right) +\end{array} +\] $$ + +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{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)} } +\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{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^{(j)} } \frac{ b^{(j)} }{ b^{(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)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(j)} }{ b^{(0)} } +\\ +\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)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(0)} }{ b^{(0)} } +\\ +\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)} } \frac{ b^{(k)} }{ b^{(0)} } +\\ +\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)} } +\mp \D{G}{ b^{(j)} } \frac{ x^{(j-k)} }{ b^{(0)} } +\\ +\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)} } +\end{array} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/atan_forward.omh cppad-2019.02.00.0/omh/theory/atan_forward.omh --- cppad-2018.00.00.0/omh/theory/atan_forward.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/atan_forward.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,85 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin atan_forward$$ +$spell + atan + atanh + Taylor +$$ + +$section Inverse Tangent and Hyperbolic Tangent Forward Mode Theory$$ + +$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 \pm x * x ) * F^{(1)} (x) - 0 * F (x) = 1 +\] $$ +and in the +$cref/standard math function differential equation + /ForwardTheory + /Standard Math Functions + /Differential Equation +/$$, +$latex A(x) = 0$$, +$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 +Taylor coefficients for +$latex A [ X (t) ] $$, +$latex B [ X (t) ]$$, +$latex D [ X (t) ] $$, +and $latex F [ X(t) ] $$ respectively. + +$head Taylor Coefficients Recursion$$ +For $latex j = 0 , 1, \ldots$$, +$latex \[ +\begin{array}{rcl} +z^{(0)} & = & F( x^{(0)} ) +\\ +b^{(j)} +& = & \left\{ \begin{array}{ll} + 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)} +& = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} +\\ +& = & \left\{ \begin{array}{ll} + 1 & {\rm if} \; j = 0 \\ + 0 & {\rm otherwise} +\end{array} \right. +\\ +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)} +\right) +\\ +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)} +\right) +\end{array} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/atan_reverse.omh cppad-2019.02.00.0/omh/theory/atan_reverse.omh --- cppad-2018.00.00.0/omh/theory/atan_reverse.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/atan_reverse.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,143 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin atan_reverse$$ +$spell + atan + atanh + Taylor +$$ + +$section Inverse Tangent and Hyperbolic Tangent Reverse Mode Theory$$ + + +We use the reverse theory +$cref%standard math function + %ReverseTheory + %Standard Math Functions +%$$ +definition for the functions $latex H$$ and $latex G$$. +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 zero order forward mode formulas for the +$cref/atan/atan_forward/$$ +function are +$latex \[ +\begin{array}{rcl} + z^{(0)} & = & F ( x^{(0)} ) \\ + b^{(0)} & = & 1 \pm x^{(0)} x^{(0)} +\end{array} +\] $$ +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)} & = & + \pm \sum_{k=0}^j x^{(k)} x^{(j-k)} +\\ +z^{(j)} & = & \frac{1}{j} \frac{1}{ b^{(0)} } +\left( + j x^{(j)} + - \sum_{k=1}^{j-1} k z^{(k)} b^{(j-k)} +\right) +\end{array} +\] $$ + + +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{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} } ++ \D{G}{ b^{(j)} } \D{ b^{(j)} }{ x^{(0)} } +\\ +& = & +\D{G}{ x^{(j)} } ++ \D{G}{ z^{(j)} } \frac{1}{ b^{(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{G}{ b^{(0)} } +- \D{G}{ z^{(j)} } \frac{ z^{(j)} }{ b^{(0)} } +\\ +\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}{ z^{(j)} } \frac{1}{ b^{(0)} } +\pm \D{G}{ b^{(j)} } 2 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)} } +\pm \D{G}{ b^{(j)} } 2 x^{(j)} +\\ +\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)} } +\pm \D{G}{ b^{(j)} } 2 x^{(j-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{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)} } +\end{array} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/cholesky.omh cppad-2019.02.00.0/omh/theory/cholesky.omh --- cppad-2018.00.00.0/omh/theory/cholesky.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/cholesky.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,384 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ +$begin cholesky_theory$$ +$spell + Taylor + Cholesky + Sebastian + Ph + Humboldt + Universitat + zu +$$ + +$section AD Theory for Cholesky Factorization$$ + +$head Reference$$ +See section 3.6 of +Sebastian F. Walter's Ph.D. thesis, +$italic +Structured Higher-Order Algorithmic Differentiation +in the Forward and Reverse Mode +with Application in Optimum Experimental Design +$$, +Humboldt-Universitat zu Berlin, +2011. + + +$head Notation$$ + +$subhead Cholesky Factor$$ +We are given a positive definite symmetric matrix +$latex A \in \B{R}^{n \times n}$$ +and a Cholesky factorization +$latex \[ + A = L L^\R{T} +\] $$ +where $latex L \in \B{R}^{n \times n}$$ is lower triangular. + +$subhead Taylor Coefficient$$ +The matrix $latex A$$ is a function of a scalar argument +$latex t$$. +For $latex k = 0 , \ldots , K$$, we use $latex A_k$$ for the +corresponding Taylor coefficients; i.e., +$latex \[ + A(t) = o( t^K ) + \sum_{k = 0}^K A_k t^k +\] $$ +where $latex o( t^K ) / t^K \rightarrow 0 $$ as $latex t \rightarrow 0$$. +We use a similar notation for $latex L(t)$$. + +$subhead Lower Triangular Part$$ +For a square matrix $latex C$$, +$latex \R{lower} (C)$$ is the lower triangular part of $latex C$$, +$latex \R{diag} (C)$$ is the diagonal matrix with the same diagonal as +$latex C$$ and +$latex \[ + \R{low} ( C ) = \R{lower} (C) - \frac{1}{2} \R{diag} (C) +\] $$ + + + +$head Forward Mode$$ +For Taylor coefficient order $latex k = 0 , \ldots , K$$ +the coefficients +$latex A_k \in \B{R}^{n \times n}$$, and +satisfy the equation +$latex \[ + A_k = \sum_{\ell=0}^k L_\ell L_{k-\ell}^\R{T} +\] $$ +In the case where $latex k=0$$, the +$latex \[ + A_0 = L_0 L_0^\R{T} +\] $$ +The value of $latex L_0$$ can be computed using the Cholesky factorization. +In the case where $latex k > 0$$, +$latex \[ + A_k = L_k L_0^\R{T} + L_0 L_k^\R{T} + B_k +\] $$ +where +$latex \[ + B_k = \sum_{\ell=1}^{k-1} L_\ell L_{k-\ell}^\R{T} +\] $$ +Note that $latex B_k$$ is defined in terms of Taylor coefficients +of $latex L(t)$$ that have order less than $latex k$$. +We also note that +$latex \[ + L_0^{-1} ( A_k - B_k ) L_0^\R{-T} + = + L_0^{-1} L_k + L_k^\R{T} L_0^\R{-T} +\] $$ +The first matrix on the right hand side is lower triangular, +the second is upper triangular, +and the diagonals are equal. +It follows that +$latex \[ + L_0^{-1} L_k + = + \R{low} [ L_0^{-1} ( A_k - B_k ) L_0^\R{-T} ] +\] $$ +$latex \[ + L_k + = + L_0 \R{low} [ L_0^{-1} ( A_k - B_k ) L_0^\R{-T} ] +\] $$ +This expresses $latex L_k$$ in term of the +Taylor coefficients of $latex A(t)$$ and the lower order coefficients +of $latex L(t)$$. + +$head Lemma 1$$ +We use the notation $latex \dot{C}$$ for the derivative of a matrix +valued function $latex C(s)$$ with respect to a scalar argument $latex s$$. +We use the notation $latex \bar{S}$$ and $latex \bar{L}$$ for the +partial derivative of a scalar value function $latex \bar{F}( S, L)$$ +with respect to a symmetric matrix $latex S$$ and +an lower triangular matrix $latex L$$. +Define the scalar valued function +$latex \[ + \hat{F}( C ) = \bar{F} [ S , \hat{L} (S) ] +\] $$ +We use $latex \hat{S}$$ for the total derivative of $latex \hat{F}$$ with +respect to $latex S$$. +Suppose that $latex \hat{L} ( S )$$ is such that +$latex \[ + \dot{L} = L_0 \R{low} ( L_0^{-1} \dot{S} L_0^\R{-T} ) +\] $$ +for any $latex S(s)$$. It follows that +$latex \[ + \hat{S} = \bar{S} + \frac{1}{2} ( M + M^\R{T} ) +\] $$ +where +$latex \[ + M = L_0^\R{-T} \R{low}( L_0^\R{T} \bar{L} )^\R{T} L_0^{-1} +\] $$ + +$subhead Proof$$ +$latex \[ + \partial_s \hat{F} [ S(s) , L(s) ] + = + \R{tr} ( \bar{S}^\R{T} \dot{S} ) + + + \R{tr} ( \bar{L}^\R{T} \dot{L} ) +\] $$ +$latex \[ + \R{tr} ( \bar{L}^\R{T} \dot{L} ) + = + \R{tr} [ + \bar{L}^\R{T} L_0 + \R{low} ( L_0^{-1} \dot{S} L_0^\R{-T} ) + ] +\] $$ +$latex \[ + = + \R{tr} [ + \R{low} ( L_0^{-1} \dot{S} L_0^\R{-T} )^\R{T} + L_0^\R{T} \bar{L} + ] +\] $$ +$latex \[ + = + \R{tr} [ + L_0^{-1} \dot{S} L_0^\R{-T} + \R{low}( L_0^\R{T} \bar{L} ) + ] +\] $$ +$latex \[ + = + \R{tr} [ + L_0^\R{-T} \R{low}( L_0^\R{T} \bar{L} ) L_0^{-1} \dot{S} + ] +\] $$ +$latex \[ + \partial_s \hat{F} [ S(s) , L(s) ] + = + \R{tr} ( \bar{S}^\R{T} \dot{S} ) + + + \R{tr} [ + L_0^\R{-T} \R{low}( L_0^\R{T} \bar{L} ) L_0^{-1} \dot{S} + ] +\] $$ +We now consider the $latex (i, j)$$ component function, +for a symmetric matrix $latex S(s)$$, +defined by +$latex \[ + S_{k, \ell} (s) = \left\{ \begin{array}{ll} + 1 & \R{if} \; k = i \; \R{and} \; \ell = j \\ + 1 & \R{if} \; k = j \; \R{and} \; \ell = i \\ + 0 & \R{otherwise} + \end{array} \right\} +\] $$ +This shows that the formula in the lemma is correct for +$latex \hat{S}_{i,j}$$ and $latex \hat{S}_{j,i}$$. +This completes the proof because the component $latex (i, j)$$ was arbitrary. + +$head Lemma 2$$ +We use the same assumptions as in Lemma 1 except that the +matrix $latex S$$ is lower triangular (instead of symmetric). +It follows that +$latex \[ + \hat{S} = \bar{S} + \R{lower}(M) +\] $$ +where +$latex \[ + M = L_0^\R{-T} \R{low}( L_0^\R{T} \bar{L} )^\R{T} L_0^{-1} +\] $$ +The proof of this lemma is identical to Lemma 2 except that component function +is defined by +$latex \[ + S_{k, \ell} (s) = \left\{ \begin{array}{ll} + 1 & \R{if} \; k = i \; \R{and} \; \ell = j \\ + 0 & \R{otherwise} + \end{array} \right\} +\] $$ + +$head Reverse Mode$$ + +$subhead Case k = 0$$ +For the case $latex k = 0$$, +$latex \[ + \dot{A}_0 + = + \dot{L}_0 L_0^\R{T} + + + L_0 \dot{L}_0^\R{T} +\] $$ +$latex \[ + L_0^{-1} \dot{A}_0 L_0^\R{-T} + = + L_0^{-1} \dot{L}_0 + + + \dot{L}_0^\R{T} L_0^\R{-T} +\] $$ +$latex \[ + \R{low} ( L_0^{-1} \dot{A}_0 L_0^\R{-T} ) + = + L_0^{-1} \dot{L}_0 +\] $$ +$latex \[ + \dot{L}_0 + = + L_0 \R{low} ( L_0^{-1} \dot{A}_0 L_0^\R{-T} ) +\] $$ +It follows from Lemma 1 that +$latex \[ + \bar{A}_0 \stackrel{+}{=} \frac{1}{2} ( M + M^\R{T} ) +\] $$ +where +$latex \[ + M = L_0^\R{-T} \R{low} ( L_0^\R{T} \bar{L}_0 )^\R{T} L_0^{-1} +\] $$ +and $latex \bar{A}_0$$ is the partial before and after +is before and after $latex L_0$$ is removed from the scalar function +dependency. + +$subhead Case k > 0$$ +In the case where $latex k > 0$$, +$latex \[ + A_k = L_k L_0^\R{T} + L_0 L_k^\R{T} + B_k +\] $$ +where $latex B_k$$ is defined in terms of Taylor coefficients +of $latex L(t)$$ that have order less than $latex k$$. +It follows that +$latex \[ + \dot{L}_k L_0^\R{T} + + + L_0 \dot{L}_k^\R{T} + = + \dot{A}_k - \dot{B}_k - \dot{L}_0 L_k^\R{T} - L_k \dot{L}_0^\R{T} +\] $$ +$latex \[ + L_0^{-1} \dot{L}_k + + + \dot{L}_k^\R{T} L_0^\R{-T} + = + L_0^{-1} ( + \dot{A}_k - \dot{B}_k - \dot{L}_0 L_k^\R{T} - L_k \dot{L}_0^\R{T} + ) L_0^\R{-T} +\] $$ +$latex \[ + L_0^{-1} \dot{L}_k + = + \R{low} [ L_0^{-1} ( + \dot{A}_k - \dot{B}_k - \dot{L}_0 L_k^\R{T} - L_k \dot{L}_0^\R{T} + ) L_0^\R{-T} ] +\] $$ +$latex \[ + \dot{L}_k + = + L_0 \R{low} [ L_0^{-1} ( + \dot{A}_k - \dot{B}_k - \dot{L}_0 L_k^\R{T} - L_k \dot{L}_0^\R{T} + ) L_0^\R{-T} ] +\] $$ +The matrix $latex A_k$$ is symmetric, it follows that +$latex \[ + \bar{A}_k \stackrel{+}{=} \frac{1}{2} ( M_k + M_k^\R{T} ) +\] $$ +where +$latex \[ + M_k = L_0^\R{-T} \R{low} ( L_0^\R{T} \bar{L}_k )^\R{T} L_0^{-1} +\] $$ +The matrix $latex B_k$$ is also symmetric, hence +$latex \[ + \bar{B}_k = - \; \frac{1}{2} ( M_k + M_k^\R{T} ) +\] $$ +We define the symmetric matrix $latex C_k (s)$$ by +$latex \[ + \dot{C}_k = \dot{L}_0 L_k^\R{T} + L_k \dot{L}_0^\R{T} +\] $$ +and remove the dependency on $latex C_k$$ with +$latex \[ + \R{tr}( \bar{C}_k^\R{T} \dot{C}_k ) + = + \R{tr}( \bar{B}_k^\R{T} \dot{C}_k ) + = + \R{tr}( \bar{B}_k^\R{T} \dot{L}_0 L_k^\R{T} ) + + + \R{tr}( \bar{B}_k^\R{T} L_k \dot{L}_0^\R{T} ) +\] $$ +$latex \[ + = + \R{tr}( L_k^\R{T} \bar{B}_k^\R{T} \dot{L}_0 ) + + + \R{tr}( L_k^\R{T} \bar{B}_k \dot{L}_0 ) +\] $$ +$latex \[ + = + \R{tr}[ L_k^\R{T} ( \bar{B}_k + \bar{B}_k^\R{T} ) \dot{L}_0 ] +\] $$ +Thus, removing $latex C_k$$ from the dependency results in the +following update to $latex \bar{L}_0$$: +$latex \[ + \bar{L}_0 \stackrel{+}{=} \R{lower} [ ( \bar{B}_k + \bar{B}_k^\R{T} ) L_k ] +\] $$ +which is the same as +$latex \[ + \bar{L}_0 \stackrel{+}{=} 2 \; \R{lower} [ \bar{B}_k L_k ] +\] $$ + +We still need to remove $latex B_k$$ from the dependency. +It follows from its definition that +$latex \[ + \dot{B}_k = \sum_{\ell=1}^{k-1} + \dot{L}_\ell L_{k-\ell}^\R{T} + L_\ell \dot{L}_{k-\ell}^\R{T} +\]$$ +$latex \[ + \R{tr}( \bar{B}_k^\R{T} \dot{B}_k ) + = + \sum_{\ell=1}^{k-1} + \R{tr}( \bar{B}_k^\R{T} \dot{L}_\ell L_{k-\ell}^\R{T} ) + + + \R{tr}( \bar{B}_k^\R{T} L_\ell \dot{L}_{k-\ell}^\R{T} ) +\]$$ +$latex \[ + = + \sum_{\ell=1}^{k-1} + \R{tr}( L_{k-\ell}^\R{T} \bar{B}_k^\R{T} \dot{L}_\ell ) + + + \sum_{\ell=1}^{k-1} + \R{tr}( L_\ell^\R{T} \bar{B}_k \dot{L}_{k-\ell} ) +\]$$ +We now use the fact that $latex \bar{B}_k$$ is symmetric to conclude +$latex \[ + \R{tr}( \bar{B}_k^\R{T} \dot{B}_k ) + = + 2 \sum_{\ell=1}^{k-1} + \R{tr}( L_{k-\ell}^\R{T} \bar{B}_k^\R{T} \dot{L}_\ell ) +\] $$ +Each of the $latex \dot{L}_\ell$$ matrices is lower triangular. +Thus, removing $latex B_k$$ from the dependency results in the following +update for $latex \ell = 1 , \ldots , k-1$$: +$latex \[ + \bar{L}_\ell + \stackrel{+}{=} 2 \; \R{lower}( \bar{B}_k L_{k-\ell} ) +\] $$ + + +$end diff -Nru cppad-2018.00.00.0/omh/theory/erf_forward.omh cppad-2019.02.00.0/omh/theory/erf_forward.omh --- cppad-2018.00.00.0/omh/theory/erf_forward.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/erf_forward.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,69 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin erf_forward$$ +$spell + erf + Taylor +$$ + + +$section Error Function Forward Taylor Polynomial Theory$$ + +$head Derivatives$$ +Given $latex X(t)$$, we define the function +$latex \[ + Z(t) = \R{erf}[ X(t) ] +\]$$ +It follows that +$latex \[ +\begin{array}{rcl} +\R{erf}^{(1)} ( u ) & = & ( 2 / \sqrt{\pi} ) \exp \left( - u^2 \right) +\\ +Z^{(1)} (t) & = & \R{erf}^{(1)} [ X(t) ] X^{(1)} (t) = Y(t) X^{(1)} (t) +\end{array} +\] $$ +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 +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)$$. +Using the equation above for $latex Z^{(1)} (t)$$, we have +$latex \[ +\begin{array}{rcl} +\sum_{k=1}^j k z^{(k)} t^{k-1} +& = & +\left[ \sum_{k=0}^j y^{(k)} t^k \right] +\left[ \sum_{k=1}^j k x^{(k)} t^{k-1} \right] ++ +o( t^{j-1} ) +\end{array} +\] $$ +Setting the coefficients of $latex t^{j-1}$$ equal, we have +$latex \[ +\begin{array}{rcl} +j z^{(j)} += +\sum_{k=1}^j k x^{(k)} y^{(j-k)} +\\ +z^{(j)} += +\frac{1}{j} \sum_{k=1}^j k x^{(k)} y^{(j-k)} +\end{array} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/erf_reverse.omh cppad-2019.02.00.0/omh/theory/erf_reverse.omh --- cppad-2018.00.00.0/omh/theory/erf_reverse.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/erf_reverse.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,69 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin erf_reverse$$ +$spell + erf + Taylor +$$ + + +$section Error Function Reverse Mode Theory$$ + +$head Notation$$ +We use the reverse theory +$cref/standard math function/ReverseTheory/Standard Math Functions/$$ +definition for the functions $latex H$$ and $latex G$$. + +$head Positive Orders Z(t)$$ +For order $latex j > 0$$, +suppose that $latex H$$ is the same as $latex G$$. +$latex \[ +z^{(j)} += +\frac{1}{j} \sum_{k=1}^j k x^{(k)} y^{(j-k)} +\] $$ +For $latex k = 1 , \ldots , j$$, +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$$ +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 +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{G}{ x^{(0)} } + \D{G}{ z^{(0)} } \D{ z^{(0)} }{ x^{(0)} } += +\D{G}{ x^{(0)} } + \D{G}{ z^{(0)} } y^{(0)} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/exp_forward.omh cppad-2019.02.00.0/omh/theory/exp_forward.omh --- cppad-2018.00.00.0/omh/theory/exp_forward.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/exp_forward.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,78 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin exp_forward$$ +$spell + exp + expm1 + Taylor +$$ + +$section Exponential Function Forward Mode Theory$$ + +$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) += +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. +\] $$ +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) = 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 D [ X (t) ] $$, +and $latex F [ X(t) ] $$ respectively. + +$head Taylor Coefficients Recursion$$ +For orders $latex j = 0 , 1, \ldots$$, +$latex \[ +\begin{array}{rcl} +z^{(0)} & = & F ( x^{(0)} ) +\\ +e^{(0)} & = & d^{(0)} + z^{(0)} +\\ +e^{(j+1)} +& = & d^{(j+1)} + \sum_{k=0}^{j+1} a^{(j+1-k)} * z^{(k)} +\\ +& = & 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)} +\right) +\\ +& = & 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-2018.00.00.0/omh/theory/exp_reverse.omh cppad-2019.02.00.0/omh/theory/exp_reverse.omh --- cppad-2018.00.00.0/omh/theory/exp_reverse.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/exp_reverse.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,67 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin exp_reverse$$ +$spell + Taylor + exp + expm +$$ + +$section Exponential Function Reverse Mode Theory$$ + +We use the reverse theory +$cref%standard math function + %ReverseTheory + %Standard Math Functions +%$$ +definition for the functions $latex H$$ and $latex G$$. +The zero order forward mode formula for the +$cref/exponential/exp_forward/$$ is +$latex \[ + z^{(0)} = F ( x^{(0)} ) +\] $$ +and for $latex j > 0$$, +$latex \[ + 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)} } \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{G}{ x^{(k)} } + \D{G}{ z^{(j)} } \frac{1}{j} k 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} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/forward_theory.omh cppad-2019.02.00.0/omh/theory/forward_theory.omh --- cppad-2018.00.00.0/omh/theory/forward_theory.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/forward_theory.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,222 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin ForwardTheory$$ +$spell + Taylor +$$ + +$section The Theory of Forward Mode$$ + +$head Taylor Notation$$ +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 +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 ) +\end{array} +\] $$ +For the purposes of this section, we are given $latex x$$ and $latex y$$ +and need to determine $latex z$$. + +$head Binary Operators$$ + +$subhead Addition$$ +$latex \[ +\begin{array}{rcl} +Z(t) +& = & X(t) + Y(t) +\\ +\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} +\] $$ + +$subhead Subtraction$$ +$latex \[ +\begin{array}{rcl} +Z(t) +& = & X(t) - Y(t) +\\ +\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} +\] $$ + +$subhead Multiplication$$ +$latex \[ +\begin{array}{rcl} +Z(t) +& = & X(t) * Y(t) +\\ +\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} +\] $$ + +$subhead Division$$ +$latex \[ +\begin{array}{rcl} +Z(t) +& = & X(t) / Y(t) +\\ +x +& = & z * y +\\ +\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) ++ +o( t^p ) +\\ +x^{(j)} & = & \sum_{k=0}^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) +\end{array} + +\] $$ + +$head Standard Math Functions$$ +Suppose that $latex F $$ is a standard math function and +$latex \[ + Z(t) = F[ X(t) ] +\]$$ + +$subhead Differential Equation$$ +All of the standard math functions +satisfy a differential equation of the form +$latex \[ + B(u) * F^{(1)} (u) - A(u) * F (u) = D(u) +\] $$ +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$$, +the $th p$$ order Taylor coefficients for $latex X(t)$$. + +$subhead Taylor Coefficients Recursion Formula$$ +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) +\\ +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) +\end{array} +\] $$ +where we define +$latex \[ +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 +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 +$latex z^{(k)}$$ for $latex k = 0 , \ldots , j$$. +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/$$ +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=1}^{j+1} k x^{(k)} * t^{k-1} \right) ++ +o( t^p ) +\\ +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)} +\right) +\\ +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)} +\right) +\end{array} +\] $$ +This completes the induction that computes $latex e^{(j)}$$ +and $latex z^{(j+1)}$$. + + + + +$children% + omh/theory/exp_forward.omh% + omh/theory/log_forward.omh% + omh/theory/sqrt_forward.omh% + omh/theory/sin_cos_forward.omh% + omh/theory/atan_forward.omh% + omh/theory/asin_forward.omh% + omh/theory/acos_forward.omh% + omh/theory/tan_forward.omh% + omh/theory/erf_forward.omh +%$$ + +$subhead Cases that Apply Recursion Above$$ +$table +$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$$ +$table +$rref tan_forward$$ +$tend + +$end diff -Nru cppad-2018.00.00.0/omh/theory/log_forward.omh cppad-2019.02.00.0/omh/theory/log_forward.omh --- cppad-2018.00.00.0/omh/theory/log_forward.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/log_forward.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,81 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin log_forward$$ +$spell + Taylor +$$ + +$section Logarithm Function Forward Mode Theory$$ + +$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 \[ +\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. +\] $$ +In the +$cref/standard math function differential equation + /ForwardTheory + /Standard Math Functions + /Differential Equation +/$$, +$latex A(x) = 0$$, +$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 +Taylor coefficients for +$latex A [ X (t) ] $$, +$latex B [ X (t) ]$$, +$latex D [ X (t) ] $$, +and $latex F [ X(t) ] $$ respectively. + +$head Taylor Coefficients Recursion$$ +For orders $latex j = 0 , 1, \ldots$$, +$latex \[ +\begin{array}{rcl} +z^{(0)} & = & F ( x^{(0)} ) +\\ +e^{(j)} +& = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} +\\ +& = & \left\{ \begin{array}{ll} + 1 & {\rm if} \; j = 0 \\ + 0 & {\rm otherwise} +\end{array} \right. +\\ +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)} +\right) +\\ +& = & \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)} +\right) +\end{array} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/log_reverse.omh cppad-2019.02.00.0/omh/theory/log_reverse.omh --- cppad-2018.00.00.0/omh/theory/log_reverse.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/log_reverse.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,107 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin log_reverse$$ +$spell + Taylor +$$ + +$section Logarithm Function Reverse Mode Theory$$ + +We use the reverse theory +$cref%standard math function + %ReverseTheory + %Standard Math Functions +%$$ +definition for the functions $latex H$$ and $latex G$$. + +The zero order forward mode formula for the +$cref/logarithm/log_forward/$$ is +$latex \[ + z^{(0)} = F( x^{(0)} ) +\] $$ +and for $latex j > 0$$, +$latex \[ +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)} +\right) +\] $$ +where +$latex \[ +\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. +\] $$ +We note that for $latex j > 0$$ +$latex \[ +\begin{array}{rcl} +\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_{k=1}^{j-1} k z^{(k)} x^{(j-k)} +\right) +\\ +& = & +- +\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-k)} } & = & +\D{G}{ x^{(j-k)} } - + \D{G}{ z^{(j)} } \frac{1}{ \bar{b} + x^{(0)} } \frac{k}{j} z^{(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} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/research.omh cppad-2019.02.00.0/omh/theory/research.omh --- cppad-2018.00.00.0/omh/theory/research.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/research.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,114 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin research$$ +$spell + CppAD + Jacobian + acyclic + subgraph + Subgraphs + Kasper Kristensen +$$ + +$section Research and Software Engineering Projects Related to CppAD$$ + +$head See Also$$ +$cref wish_list$$ + +$head Purpose$$ +This is a list of research topics, +and software engineering projects, related to CppAD. +If you know of published results for any of the research topics, +please contact the project manage +so a link to the answer can be added to the CppAD documentation. + +$head Abs-Normal Form$$ +$href%https://arxiv.org/abs/1701.00753%Abs-normal%$$ forms are +recent advent in AD and algorithms related to it are an important +research topic. +The CppAD $cref abs_normal_fun$$ routine enables one to create approximations +for non-smooth functions that have higher than first order accuracy. +This opens the question of designing algorithms to take advantage of this. + +$head Atomic Functions$$ +Mathematical formulas for, and implementation of, +$cref/atomic functions/atomic_two/$$ +that make AD faster and or conserve on memory for special cases; e.g., +special functions, sparse matrix operations. + +$head Dynamic Parameters$$ +CppAD provides for $cref/dynamic parameters/new_dynamic/$$ +in a unique way (they can depend on other dynamic parameters). +This opens the question of techniques that take advantage of this. +For example, see $cref base2ad.cpp$$ which uses this feature. + +$head Multi-Threading$$ +Interesting algorithms and implementations that take advantage of +the CppAD $cref/multi threading/multi_thread/$$ capability. + +$head Optimization$$ +There is no paper describing +the CppAD $cref/optimization/optimize/$$ of a computational graph. +In particular, the optimization of +$cref/conditional expressions/condexp/$$ is not well understood. +In addition, possible improvements to the optimization would be welcome. +For example, detecting places where the distributive law can be +used to reduce two multiplies and one addition to one multiply and +two additions. + +$head Scripting Language$$ +It would be useful to make $cref addon$$ packages that +connect CppAD to a scripting languages. +The package +$href%https://bradbell.github.io/cppad_py%cppad_swig%$$ +demonstrate how one could use swig to do this and +$href%https://bradbell.github.io/cppad_py%cppad_py%$$ +is a preliminary version of such a connection to Python. + +$head Sparsity$$ + +$subhead Sparsity Patterns$$ +There are forward, reverse and subgraph methods for computing a +$cref sparsity_pattern$$. +It is unclear which is better for which cases. + +$subhead Coloring Problem$$ +Given the +$cref/sparsity pattern/glossary/Sparsity Pattern/$$ for a Jacobian or Hessian, +a graph coloring algorithm is used to determine which row or columns +can be evaluated at the same time; see +$href% +https://github.com/coin-or/CppAD/blob/master/cppad/local/color_general.hpp% +color_general.hpp +%$$ +and +$href% +https://github.com/coin-or/CppAD/blob/master/cppad/local/color_symmetric.hpp% +color_symmertic.hpp +%$$. + +$subhead Subgraphs$$ +The $cref subgraph_jac_rev$$ method use subgraphs to compute sparsity patterns +and to evaluate sparse derivatives. +This is a new technique that should be written up. +It was invented by +Kasper Kristensen, DTU Technical University of Denmark. +See the $cref/subgraph/wish_list/Subgraph/$$ wish list items. + +$head Speed$$ +CppAD provides for some $cref speed$$ comparisons between +different AD packages. +These comparisons could be improved, extended, and written up. + + +$end diff -Nru cppad-2018.00.00.0/omh/theory/reverse_identity.omh cppad-2019.02.00.0/omh/theory/reverse_identity.omh --- cppad-2018.00.00.0/omh/theory/reverse_identity.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/reverse_identity.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,156 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin reverse_identity$$ +$spell + Taylor + Griewank + Andreas +$$ + + + +$section An Important Reverse Mode Identity$$ +The theorem and the proof below is a restatement +of the results on page 236 of +$cref/Evaluating Derivatives/Bib/Evaluating Derivatives/$$. + +$head Notation$$ +Given a function $latex f(u, v)$$ where $latex u \in \B{R}^n$$ +we use the notation +$latex \[ +\D{f}{u} (u, v) = \left[ \D{f}{u_1} (u, v) , \cdots , \D{f}{u_n} (u, v) \right] +\] $$ + +$head Reverse Sweep$$ +When using $cref/reverse mode/reverse_any/$$ +we are given a function $latex F : \B{R}^n \rightarrow \B{R}^m$$, +a matrix of Taylor coefficients $latex x \in \B{R}^{n \times p}$$, +and a weight vector $latex w \in \B{R}^m$$. +We define the functions $latex X : \B{R} \times \B{R}^{n \times p} \rightarrow \B{R}^n$$, +$latex W : \B{R} \times \B{R}^{n \times p} \rightarrow \B{R}$$, and +$latex W_j : \B{R}^{n \times p} \rightarrow \B{R}$$ by +$latex \[ +\begin{array}{rcl} + X(t , x) & = & x^{(0)} + x^{(1)} t + \cdots + x^{(p-1)} t^{p-1} + \\ + W(t, x) & = & w_0 F_0 [X(t, x)] + \cdots + w_{m-1} F_{m-1} [X(t, x)] + \\ + W_j (x) & = & \frac{1}{j!} \Dpow{j}{t} W(0, x) +\end{array} +\]$$ +where $latex x^{(j)}$$ is the $th j$$ column of $latex x \in \B{R}^{n \times p}$$. +The theorem below implies that +$latex \[ + \D{ W_j }{ x^{(i)} } (x) = \D{ W_{j-i} }{ x^{(0)} } (x) +\] $$ +A $cref/general reverse sweep/reverse_any/$$ calculates the values +$latex \[ + \D{ W_{p-1} }{ x^{(i)} } (x) \hspace{1cm} (i = 0 , \ldots , p-1) +\] $$ +But the return values for a reverse sweep are specified +in terms of the more useful values +$latex \[ + \D{ W_j }{ x^{(0)} } (x) \hspace{1cm} (j = 0 , \ldots , p-1) +\] $$ + +$head Theorem$$ +Suppose that $latex F : \B{R}^n \rightarrow \B{R}^m$$ is a $latex p$$ times +continuously differentiable function. +Define the functions +$latex Z : \B{R} \times \B{R}^{n \times p} \rightarrow \B{R}^n$$, +$latex Y : \B{R} \times \B{R}^{n \times p }\rightarrow \B{R}^m$$, +and +$latex y^{(j)} : \B{R}^{n \times p }\rightarrow \B{R}^m$$ by +$latex \[ +\begin{array}{rcl} + Z(t, x) & = & x^{(0)} + x^{(1)} t + \cdots + x^{(p-1)} t^{p-1} + \\ + Y(t, x) & = & F [ Z(t, 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 +$latex x \in \B{R}^{n \times p}$$. +It follows that +for all $latex i, j$$ such that $latex i \leq j < p$$, +$latex \[ +\begin{array}{rcl} +\D{ y^{(j)} }{ x^{(i)} } (x) & = & \D{ y^{(j-i)} }{ x^{(0)} } (x) +\end{array} +\] $$ + + +$head Proof$$ +If follows from the definitions that +$latex \[ +\begin{array}{rclr} +\D{ y^{(j)} }{ x^{(i)} } (x) +& = & +\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) +\right]_{t=0} +\\ +& = & +\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$$ +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] +& = & +\sum_{k=0}^i +\left( \begin{array}{c} j \\ k \end{array} \right) +\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] +\right\}_{t=0} +& = & +\left( \begin{array}{c} j \\ i \end{array} \right) +i ! \Dpow{j-i}{t} ( F^{(1)} \circ Z ) (t, x) +\\ +& = & +\frac{ j ! }{ (j - i) ! } +\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} +\] $$ +Applying this formula to the case where $latex j$$ +is replaced by $latex j - i$$ and $latex i$$ is replaced by zero, +we obtain +$latex \[ +\D{ y^{(j-i)} }{ x^{(0)} } (x) += +\frac{ 1 }{ (j - i) ! } +\Dpow{j-i}{t} ( F^{(1)} \circ Z ) (t, x) += +\D{ y^{(j)} }{ x^{(i)} } (x) +\] $$ +which completes the proof + +$end diff -Nru cppad-2018.00.00.0/omh/theory/reverse_theory.omh cppad-2019.02.00.0/omh/theory/reverse_theory.omh --- cppad-2018.00.00.0/omh/theory/reverse_theory.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/reverse_theory.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,184 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin ReverseTheory$$ +$spell + Taylor + Arctangent +$$ + +$section The Theory of Reverse Mode$$ + +$head Taylor Notation$$ +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 +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} ) +\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 +$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) = + G ( z^{(j)}, z^{(j-1)} , \ldots , z^{(0)}, x , y ) +\] $$ +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 +$latex \[ + z^{(j)} ( z^{(j-1)} , \ldots , z^{(0)}, x, y ) +\] $$ +If we do not provide a formula for +a partial derivative of $latex H$$, then that partial derivative +has the same value as for the function $latex G$$. + +$head Binary Operators$$ + +$subhead Addition$$ +The forward mode formula for +$cref/addition/ForwardTheory/Binary Operators/Addition/$$ is +$latex \[ + z^{(j)} = x^{(j)} + y^{(j)} +\] $$ +If follows that for $latex k = 0 , \ldots , j$$ +and $latex l = 0 , \ldots , j-1$$ +$latex \[ +\begin{array}{rcl} +\D{H}{ x^{(k)} } & = & +\D{G}{ x^{(k)} } + \D{G}{ z^{(k)} } \\ +\\ +\D{H}{ y^{(k)} } & = & +\D{G}{ y^{(k)} } + \D{G}{ z^{(k)} } +\\ +\D{H}{ z^{(l)} } & = & \D{G}{ z^{(l)} } +\end{array} +\] $$ + +$subhead Subtraction$$ +The forward mode formula for +$cref/subtraction/ForwardTheory/Binary Operators/Subtraction/$$ is +$latex \[ + z^{(j)} = x^{(j)} - y^{(j)} +\] $$ +If follows that for $latex k = 0 , \ldots , j$$ +$latex \[ +\begin{array}{rcl} +\D{H}{ x^{(k)} } & = & +\D{G}{ x^{(k)} } - \D{G}{ z^{(k)} } \\ +\\ +\D{H}{ y^{(k)} } & = & +\D{G}{ y^{(k)} } - \D{G}{ z^{(k)} } +\end{array} +\] $$ + +$subhead Multiplication$$ +The forward mode formula for +$cref/multiplication/ForwardTheory/Binary Operators/Multiplication/$$ is +$latex \[ + z^{(j)} = \sum_{k=0}^j x^{(j-k)} * y^{(k)} +\] $$ +If follows that for $latex k = 0 , \ldots , j$$ +and $latex l = 0 , \ldots , j-1$$ +$latex \[ +\begin{array}{rcl} +\D{H}{ x^{(j-k)} } & = & +\D{G}{ x^{(j-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} +\] $$ + +$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)} +\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{H}{ z^{(j-k)} } & = & +\D{G}{ z^{(j-k)} } - \D{G}{ z^{(j)} } \frac{1}{y^{(0)}} y^{(k)} +\\ +\D{H}{ y^{(k)} } & = & +\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)} +\right) +\\ +& = & +\D{G}{ y^{(0)} } - \D{G}{ z^{(j)} } \frac{1}{y^{(0)}} z^{(j)} +\end{array} +\] $$ + +$head Standard Math Functions$$ +The standard math functions have only one argument. +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) = + G ( z^{(j)}, z^{(j-1)} , \ldots , z^{(0)}, x) +\] $$ +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 +$latex \[ + z^{(j)} ( z^{(j-1)} , \ldots , z^{(0)}, x ) +\] $$ + + +$childtable% + omh/theory/exp_reverse.omh% + omh/theory/log_reverse.omh% + omh/theory/sqrt_reverse.omh% + omh/theory/sin_cos_reverse.omh% + omh/theory/atan_reverse.omh% + omh/theory/asin_reverse.omh% + omh/theory/acos_reverse.omh% + omh/theory/tan_reverse.omh% + omh/theory/erf_reverse.omh +%$$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/sin_cos_forward.omh cppad-2019.02.00.0/omh/theory/sin_cos_forward.omh --- cppad-2018.00.00.0/omh/theory/sin_cos_forward.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/sin_cos_forward.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,103 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin sin_cos_forward$$ +$spell + sin + cos + sinh + cosh + Taylor +$$ + + +$section Trigonometric and Hyperbolic Sine and Cosine Forward Theory$$ + +$head Differential Equation$$ +The +$cref/standard math function differential equation + /ForwardTheory + /Standard Math Functions + /Differential Equation +/$$ +is +$latex \[ + B(u) * F^{(1)} (u) - A(u) * F (u) = D(u) +\] $$ +In this sections we consider forward mode for the following choices: + +$table +$pre $$ + $cnext $cnext $latex F(u)$$ + $cnext $cnext $latex \sin(u)$$ + $cnext $cnext $latex \cos(u)$$ + $cnext $cnext $latex \sinh(u)$$ + $cnext $cnext $latex \cosh(u)$$ +$rnext + $cnext $cnext $latex A(u)$$ + $cnext $cnext $latex 0$$ + $cnext $cnext $latex 0$$ + $cnext $cnext $latex 0$$ + $cnext $cnext $latex 0$$ +$rnext + $cnext $cnext $latex B(u)$$ + $cnext $cnext $latex 1$$ + $cnext $cnext $latex 1$$ + $cnext $cnext $latex 1$$ + $cnext $cnext $latex 1$$ +$rnext + $cnext $cnext $latex D(u)$$ + $cnext $cnext $latex \cos(u)$$ + $cnext $cnext $latex - \sin(u)$$ + $cnext $cnext $latex \cosh(u)$$ + $cnext $cnext $latex \sinh(u)$$ +$tend + +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 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$$, +$latex \[ +\begin{array}{rcl} +f^{(0)} & = & D ( x^{(0)} ) +\\ +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)} } +\left( + \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)} +\end{array} +\] $$ +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) ]$$. + +$end diff -Nru cppad-2018.00.00.0/omh/theory/sin_cos_reverse.omh cppad-2019.02.00.0/omh/theory/sin_cos_reverse.omh --- cppad-2018.00.00.0/omh/theory/sin_cos_reverse.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/sin_cos_reverse.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,104 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin sin_cos_reverse$$ +$spell + Taylor + cos +$$ + +$section Trigonometric and Hyperbolic Sine and Cosine Reverse Theory$$ + + +We use the reverse theory +$cref%standard math function + %ReverseTheory + %Standard Math Functions +%$$ +definition for the functions $latex H$$ and $latex G$$. +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$$ + $cnext $cnext $latex \ell$$ +$rnext +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) ]$$ + $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/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)} ) +\\ +c^{(j)} & = & \frac{1 + \ell}{2} \cos ( x^{(0)} ) + + \frac{1 - \ell}{2} \cosh ( x^{(0)} ) +\end{array} +\] $$ + +for the case $latex j = 0$$, and for $latex j > 0$$, + +$latex \[ +\begin{array}{rcl} +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)} +\end{array} +\] $$ + +If $latex j = 0$$, we have the relation + +$latex \[ +\begin{array}{rcl} +\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{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{G}{ s^{(j-k)} } + \ell \D{G}{ c^{(j)} } k x^{(k)} +\\ +\D{H}{ c^{(j-k)} } & = & +\D{G}{ c^{(j-k)} } + \D{G}{ s^{(j)} } k x^{(k)} +\end{array} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/sqrt_forward.omh cppad-2019.02.00.0/omh/theory/sqrt_forward.omh --- cppad-2018.00.00.0/omh/theory/sqrt_forward.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/sqrt_forward.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,75 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin sqrt_forward$$ +$spell + sqrt + Arctangent + Taylor +$$ + +$section Square Root Function Forward Mode Theory$$ + +If $latex F(x) = \sqrt{x} $$ +$latex \[ + F(x) * F^{(1)} (x) - 0 * F (x) = 1/2 +\] $$ +and in the +$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 +Taylor coefficients for +$latex A [ X (t) ] $$, +$latex B [ X (t) ]$$, +$latex D [ X (t) ] $$, +and $latex F [ X(t) ] $$ respectively. +It now follows from the general +$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)} +& = & d^{(j)} + \sum_{k=0}^{j} a^{(j-k)} * z^{(k)} +\\ +& = & \left\{ \begin{array}{ll} + 1/2 & {\rm if} \; j = 0 \\ + 0 & {\rm otherwise} +\end{array} \right. +\\ +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)} +\right) +\\ +& = & \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)} +\right) +\end{array} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/sqrt_reverse.omh cppad-2019.02.00.0/omh/theory/sqrt_reverse.omh --- cppad-2018.00.00.0/omh/theory/sqrt_reverse.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/sqrt_reverse.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,83 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin sqrt_reverse$$ +$spell + sqrt + Taylor +$$ + +$section Square Root Function Reverse Mode Theory$$ + + +We use the reverse theory +$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/sqrt_forward/$$ +function are +$latex \[ + 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)} } +\left( + \frac{j}{2} x^{(j) } + - \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{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ x^{(0)} } +\\ +& = & +\D{G}{ x^{(j)} } + \D{G}{ z^{(j)} } \frac{1}{2 z^{(0)} } +\end{array} +\] $$ + +If $latex j > 0$$, then for $latex k = 1, \ldots , j-1$$ + +$latex \[ +\begin{array}{rcl} +\D{H}{ z^{(0)} } & = & +\D{G}{ z^{(0)} } + \D{G} { z^{(j)} } \D{ z^{(j)} }{ z^{(0)} } +\\ +& = & +\D{G}{ z^{(0)} } - +\D{G}{ z^{(j)} } \frac{ z^{(j)} }{ z^{(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}{ 2 z^{(0)} } +\\ +\D{H}{ z^{(k)} } & = & +\D{G}{ z^{(k)} } + \D{G}{ z^{(j)} } \D{ z^{(j)} }{ z^{(k)} } +\\ +& = & +\D{G}{ z^{(k)} } - \D{G}{ z^{(j)} } \frac{ z^{(j-k)} }{ z^{(0)} } +\end{array} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/tan_forward.omh cppad-2019.02.00.0/omh/theory/tan_forward.omh --- cppad-2018.00.00.0/omh/theory/tan_forward.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/tan_forward.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,84 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin tan_forward$$ +$spell + Taylor +$$ + + +$section Tangent and Hyperbolic Tangent Forward Taylor Polynomial Theory$$ + +$head Derivatives$$ +$latex \[ +\begin{array}{rcl} +\tan^{(1)} ( u ) & = & [ \cos (u)^2 + \sin (u)^2 ] / \cos (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 +$latex \[ + F^{(1)} (u) = 1 \pm F(u)^2 +\]$$ +Given $latex X(t)$$, we define the function $latex Z(t) = F[ X(t) ]$$. +It follows that +$latex \[ +Z^{(1)} (t) = F^{(1)} [ X(t) ] X^{(1)} (t) = [ 1 \pm Y(t) ] X^{(1)} (t) +\] $$ +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 +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)$$. +Using the equation above for $latex Z^{(1)} (t)$$, we have +$latex \[ +\begin{array}{rcl} +\sum_{k=1}^j k z^{(k)} t^{k-1} +& = & +\sum_{k=1}^j k x^{(k)} t^{k-1} +\pm +\left[ \sum_{k=0}^{j-1} y^{(k)} t^k \right] +\left[ \sum_{k=1}^j k x^{(k)} t^{k-1} \right] ++ +o( t^{j-1} ) +\end{array} +\] $$ +Setting the coefficients of $latex t^{j-1}$$ equal, we have +$latex \[ +\begin{array}{rcl} +j z^{(j)} += +j x^{(j)} +\pm +\sum_{k=1}^j k x^{(k)} y^{(j-k)} +\\ +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 \[ +y^{(j)} = \sum_{k=0}^j z^{(k)} z^{(j-k)} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/tan_reverse.omh cppad-2019.02.00.0/omh/theory/tan_reverse.omh --- cppad-2018.00.00.0/omh/theory/tan_reverse.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/tan_reverse.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,114 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin tan_reverse$$ +$spell + Taylor +$$ + + +$section Tangent and Hyperbolic Tangent Reverse Mode Theory$$ + +$head Notation$$ +We use the reverse theory +$cref/standard math function/ReverseTheory/Standard Math Functions/$$ +definition for the functions $latex H$$ and $latex G$$. +In addition, we use the forward mode notation in $cref tan_forward$$ for +$latex X(t)$$, $latex Y(t)$$ and $latex Z(t)$$. + +$head Eliminating Y(t)$$ +For $latex j > 0$$, the forward mode coefficients are given by +$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 +coefficients for $latex Z(t)$$. +To be specific, for $latex k = 0 , \ldots , j-1$$, +$latex \[ +\begin{array}{rcl} +\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} +\] $$ + + +$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 +the coefficients for $latex X(t)$$, and the +lower order Taylor coefficients for $latex Y(t)$$, $latex Z(t)$$. +$latex \[ +z^{(j)} += +x^{(j)} \pm \frac{1}{j} \sum_{k=1}^j k x^{(k)} y^{(j-k)} +\] $$ +For $latex k = 1 , \ldots , j$$, +the partial of $latex H$$ with respect to $latex x^{(k)}$$ is given by +$latex \[ +\begin{array}{rcl} +\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)} } +\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$$ +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{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)$$ +The order zero coefficients for the tangent and hyperbolic tangent are +$latex \[ +\begin{array}{rcl} +z^{(0)} & = & \left\{ + \begin{array}{c} \tan ( x^{(0)} ) \\ \tanh ( x^{(0)} ) \end{array} +\right. +\end{array} +\] $$ +Suppose that $latex H$$ is the same as $latex G$$ except that +$latex z^{(0)}$$ is expressed as a function of the Taylor coefficients +for $latex X(t)$$. +In this case, +$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)} } ( 1 \pm y^{(0)} ) +\end{array} +\] $$ + +$end diff -Nru cppad-2018.00.00.0/omh/theory/taylor_ode.omh cppad-2019.02.00.0/omh/theory/taylor_ode.omh --- cppad-2018.00.00.0/omh/theory/taylor_ode.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/taylor_ode.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,61 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin taylor_ode$$ +$spell + Taylor +$$ + +$section AD Theory for Solving ODE's Using Taylor's Method$$ + +$head Problem$$ +We are given an initial value problem for +$latex y : \B{R} \rightarrow \B{R}^n$$; i.e., we know +$latex y(0) \in \B{R}^n$$ +and we know a function $latex g : \B{R}^n \rightarrow \B{R}^n$$ +such that $latex y^1 (t) = g[ y(t) ]$$ +where $latex y^k (t)$$ is the $th k$$ derivative of $latex y(t)$$. + +$head z(t)$$ +We define the function +$latex z : \B{R} \rightarrow \B{R}^n$$ by +$latex z(t) = g[ y(t) ]$$. +Given the Taylor coefficients +$latex y^{(k)} (t)$$ for $latex k = 0 , \ldots , p$$, we can +compute $latex z^{(p)} (t)$$ using forward mode AD on the function +$latex g(y)$$; see $cref forward_order$$. +It follows from $latex y^1 (t) = z(t)$$ that +$latex y^{p+1} (t) = z^p (t) $$ +$latex \[ + y^{(p+1)} (t) = z^{(p)} (t) / (k + 1) +\] $$ +where $latex y^{(k)} (t)$$ is the $th k$$ order Taylor coefficient +for $latex y(t)$$; i.e., $latex y^k (t) / k !$$. +Starting with the known value $latex y^{(0)} (t)$$, +this gives a prescription for computing $latex y^{(k)} (t)$$ for +any $latex k$$. + +$head Taylor's Method$$ +The $th p$$ order Taylor method for approximates +$latex \[ +y( t + \Delta t ) +\approx +y^{(0)} (t) + y^{(1)} (t) \Delta t + \cdots + y^{(p)} (t) \Delta t^p +\] $$ + +$children%example/general/taylor_ode.cpp +%$$ +$head Example$$ +The file $cref taylor_ode.cpp$$ contains an example and test +of this method. + +$end diff -Nru cppad-2018.00.00.0/omh/theory/theory.omh cppad-2019.02.00.0/omh/theory/theory.omh --- cppad-2018.00.00.0/omh/theory/theory.omh 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/omh/theory/theory.omh 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,26 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + + CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +-------------------------------------------------------------------------- */ + +$begin Theory$$ + +$section The Theory of Derivative Calculations$$ + +$contents% + omh/introduction.omh% + omh/theory/forward_theory.omh% + omh/theory/reverse_theory.omh% + omh/theory/reverse_identity.omh% + omh/theory/taylor_ode.omh% + omh/theory/research.omh +%$$ + +$end diff -Nru cppad-2018.00.00.0/omh/thread_alloc.omh cppad-2019.02.00.0/omh/thread_alloc.omh --- cppad-2018.00.00.0/omh/thread_alloc.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/thread_alloc.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,22 +1,22 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin thread_alloc$$ $spell - openmp - cppad/utility/thread_alloc.hpp - CppAD + openmp + include/cppad/utility/thread_alloc.hpp + CppAD $$ $section A Fast Multi-Threading Memory Allocator$$ -$mindex allocation$$ @@ -40,8 +40,8 @@ the rest of the $code CppAD$$. $childtable% - example/utility/thread_alloc.cpp% - cppad/utility/thread_alloc.hpp + example/utility/thread_alloc.cpp% + include/cppad/utility/thread_alloc.hpp %$$ $end diff -Nru cppad-2018.00.00.0/omh/uniform_01_hpp.omh cppad-2019.02.00.0/omh/uniform_01_hpp.omh --- cppad-2018.00.00.0/omh/uniform_01_hpp.omh 2018-01-01 08:32:09.000000000 +0000 +++ cppad-2019.02.00.0/omh/uniform_01_hpp.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,23 @@ -$Id: uniform_01_hpp.omh 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin uniform_01.hpp$$ $spell - uniform_01 - ifndef - endif + uniform_01 + ifndef + endif $$ $section Source: uniform_01$$ -$mindex source$$ $code @@ -27,7 +26,7 @@ $$ # define CPPAD_UNIFORM_01_HPP -$srcfile%cppad/speed/uniform_01.hpp%0%// BEGIN C++%// END C++%$$ +$srcfile%include/cppad/speed/uniform_01.hpp%0%// BEGIN C++%// END C++%$$ # endif $$ diff -Nru cppad-2018.00.00.0/omh/utility.omh cppad-2019.02.00.0/omh/utility.omh --- cppad-2018.00.00.0/omh/utility.omh 2018-01-01 08:32:10.000000000 +0000 +++ cppad-2019.02.00.0/omh/utility.omh 2019-01-31 12:35:17.000000000 +0000 @@ -1,70 +1,72 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. + CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. + This Source Code may also be made available under the following + Secondary License when the conditions for such availability set forth + in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. -------------------------------------------------------------------------- */ $begin utility$$ $spell - CppAD - namespace - alloc - cppad.hpp + CppAD + namespace + alloc + cppad.hpp $$ $section Some General Purpose Utilities$$ These routines can be include individually; for example, $codep - # include + # 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 + # include $$ They will also be included, along with the rest of CppAD, using $codep - # include + # include $$ $children% - cppad/utility/error_handler.hpp% + include/cppad/utility/error_handler.hpp% - cppad/utility/near_equal.hpp% - cppad/utility/speed_test.hpp% - cppad/utility/time_test.hpp% - cppad/utility/test_boolofvoid.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% - cppad/utility/set_union.hpp% - cppad/utility/sparse_rc.hpp% - cppad/utility/sparse_rcv.hpp + include/cppad/utility/near_equal.hpp% + include/cppad/utility/speed_test.hpp% + include/cppad/utility/time_test.hpp% + include/cppad/utility/test_boolofvoid.hpp% + + omh/numeric_type.omh% + include/cppad/utility/check_numeric_type.hpp% + omh/simple_vector.omh% + include/cppad/utility/check_simple_vector.hpp% + + include/cppad/utility/nan.hpp% + include/cppad/utility/pow_int.hpp% + include/cppad/utility/poly.hpp% + omh/lu_det_and_solve.omh% + include/cppad/utility/romberg_one.hpp% + include/cppad/utility/romberg_mul.hpp% + include/cppad/utility/runge_45.hpp% + include/cppad/utility/rosen_34.hpp% + include/cppad/utility/ode_err_control.hpp% + include/cppad/utility/ode_gear.hpp% + include/cppad/utility/ode_gear_control.hpp% + + include/cppad/utility/vector.hpp% + omh/thread_alloc.omh% + include/cppad/utility/index_sort.hpp% + include/cppad/utility/to_string.hpp% + include/cppad/utility/set_union.hpp% + include/cppad/utility/sparse_rc.hpp% + include/cppad/utility/sparse_rcv.hpp% + include/cppad/utility/sparse2eigen.hpp %$$ $head Testing$$ diff -Nru cppad-2018.00.00.0/pkgconfig/CMakeLists.txt cppad-2019.02.00.0/pkgconfig/CMakeLists.txt --- cppad-2018.00.00.0/pkgconfig/CMakeLists.txt 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/pkgconfig/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,67 +1,104 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Construct cppad.pc from cppad.pc.in; see # http://people.freedesktop.org/~dbn/pkg-config-guide.html +# ----------------------------------------------------------------------------- # -# Setting that are always included -SET(cppad_pkgconfig_cflags "-I${cppad_abs_includedir}") -SET(cppad_pkgconfig_libs "") -SET(cppad_pkgconfig_requires "") +# Colpack does not have a pkgconfig file. Search for the missing information. +# Note that colpack is linked through cppad_lib, so we only need +# colpack_libdir +SET(colpack_libdir NOTFOUND) +IF( cppad_has_colpack ) + FOREACH(dir ${cmake_install_libdirs}) + FILE(GLOB file_list "${colpack_prefix}/${dir}/libColPack.*" ) + IF( file_list ) + SET(colpack_libdir "${colpack_prefix}/${dir}") + ENDIF( file_list ) + ENDFOREACH(dir ${cmake_install_libdirs}) + IF( NOT colpack_libdir ) + MESSAGE(FATAL_ERROR "Cannit find libColPack.* below ${colpack_prefix}") + ENDIF( NOT colpack_libdir ) +ENDIF( cppad_has_colpack ) +# ----------------------------------------------------------------------------- +# cppad_pkgconfig_requires +# cppad_pkgconfig_requires_uninstalled # -# Settings that are only included if cppad is configured with ipopt. -# (Note that ipopt has a pkgconfig file.) +SET(cppad_pkgconfig_requires "") +SET(cppad_pkgconfig_requires_uninstalled "") IF( cppad_has_ipopt ) - SET(cppad_pkgconfig_requires "ipopt") - SET(cppad_pkgconfig_libs "-L${cppad_abs_libdir} -lcppad_ipopt") + SET(cppad_pkgconfig_requires "ipopt") + SET(cppad_pkgconfig_requires_uninstalled "ipopt") ENDIF( cppad_has_ipopt ) +# ----------------------------------------------------------------------------- +# cppad_pkgconfig_cflags +# cppad_pkgconfig_cflags_uninstalled # -# Settings that are only included if cppad is configured with colpack -# (Note that colpack does not have a pkgconfig file.) +SET(cppad_pkgconfig_cflags "-I${cppad_abs_includedir}" ) +SET(cppad_pkgconfig_cflags_uninstalled "-I${cppad_SOURCE_DIR}" ) +# ---------------------------------------------------------------------------- +# cppad_pkgconfig_libs +# cppad_pkgconfig_libs_uninstalled +# +# default +SET(cppad_pkgconfig_libs "") +SET(cppad_pkgconfig_libs_uninstalled "") +# +# if have ipopt +IF( cppad_has_ipopt ) + SET(cppad_pkgconfig_libs "-L${cppad_abs_libdir} -lcppad_ipopt" ) + SET(cppad_pkgconfig_libs_uninstalled + "-L${cppad_BINARY_DIR}/cppad_ipopt/src -lcppad_ipopt" + ) +ENDIF( cppad_has_ipopt) +# +# if have colpack IF( cppad_has_colpack ) - SET(cppad_pkgconfig_libs "${cppad_pkgconfig_libs} -lColPack") - FOREACH(dir ${cmake_install_libdirs}) - IF(IS_DIRECTORY ${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}) - 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) + join(cppad_pkgconfig_libs " " + "-L${cppad_abs_libdir} -lcppad_lib" + "-L${colpack_libdir} -lColPack" + ) + join(cppad_pkgconfig_libs_uninstalled " " + "-L${cppad_BINARY_DIR}/cppad_lib -lcppad_lib" + "-L${colpack_libdir} -lColPack" + ) ENDIF( cppad_has_colpack ) # -print_variable(cppad_pkgconfig_cflags) -print_variable(cppad_pkgconfig_libs) -print_variable(cppad_pkgconfig_requires) +# if have both colpack and ipopt +IF( cppad_has_colpack AND cppad_has_ipopt ) + join(cppad_pkgconfig_libs " " + "-L${cppad_abs_libdir} -lcppad_lib -lcppad_ipopt" + "-L${colpack_libdir} -lColPack" + ) + join(cppad_pkgconfig_libs_uninstalled " " + "-L${cppad_BINARY_DIR}/cppad_lib -lcppad_lib" + "-L${cppad_BINARY_DIR}/cppad_ipopt/src -lcppad_ipopt" + "-L${colpack_libdir} -lColPack" + ) +ENDIF( cppad_has_colpack AND cppad_has_ipopt ) +# ---------------------------------------------------------------------------- # # Copy a file to another location and modify its contents. -# configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) CONFIGURE_FILE( - ${CMAKE_CURRENT_SOURCE_DIR}/cppad.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/cppad.pc + ${CMAKE_CURRENT_SOURCE_DIR}/cppad.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/cppad.pc ) CONFIGURE_FILE( - ${CMAKE_CURRENT_SOURCE_DIR}/cppad-uninstalled.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/cppad-uninstalled.pc + ${CMAKE_CURRENT_SOURCE_DIR}/cppad-uninstalled.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/cppad-uninstalled.pc +) +# During install copy cppad.pc to datadir and libdir +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/cppad.pc + DESTINATION ${cppad_abs_datadir}/pkgconfig +) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/cppad.pc + DESTINATION ${cppad_abs_libdir}/pkgconfig ) -# During install copy cppad.pc to CMAKE_INSTALL_PREFIX/ -# install(FILES files... DESTINATION -# [PERMISSIONS permissions...] -# [CONFIGURATIONS [Debug|Release|...]] -# [COMPONENT ] -# [RENAME ] [OPTIONAL]) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/cppad.pc DESTINATION ${cppad_abs_datadir}/pkgconfig ) - diff -Nru cppad-2018.00.00.0/pkgconfig/cppad.pc.in cppad-2019.02.00.0/pkgconfig/cppad.pc.in --- cppad-2018.00.00.0/pkgconfig/cppad.pc.in 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/pkgconfig/cppad.pc.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,23 @@ -# $Id: cppad.pc.in 3760 2015-12-01 04:12:28Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # 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@ -# ------------------------------------------------------------------------- - +# +# Entries set by top source directory CMakeLists.txt file Name: cppad Description: @cppad_description@ Version: @cppad_version@ URL: @cppad_url@ +# +# Entries set by pkgconfig/CMakeLists.txt file Cflags: @cppad_pkgconfig_cflags@ Libs: @cppad_pkgconfig_libs@ Requires: @cppad_pkgconfig_requires@ diff -Nru cppad-2018.00.00.0/pkgconfig/cppad-uninstalled.pc.in cppad-2019.02.00.0/pkgconfig/cppad-uninstalled.pc.in --- cppad-2018.00.00.0/pkgconfig/cppad-uninstalled.pc.in 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/pkgconfig/cppad-uninstalled.pc.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,20 +1,23 @@ -# $Id: cppad-uninstalled.pc.in 3754 2015-11-26 22:23:05Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # This file is used with pkg-config to include CppAD before it is installed. - +# +# Entries set by top source directory CMakeLists.txt file Name: cppad Description: @cppad_description@ Version: @cppad_version@ URL: @cppad_url@ -Cflags: -I@cppad_SOURCE_DIR@ -Libs: -L@cppad_BINARY_DIR@/lib -lcppad_lib -Requires: +# +# Entries set by pkgconfig/CMakeLists.txt file +Cflags: @cppad_pkgconfig_cflags_uninstalled@ +Libs: @cppad_pkgconfig_libs_uninstalled@ +Requires: @cppad_pkgconfig_requires_uninstalled@ diff -Nru cppad-2018.00.00.0/readme.md cppad-2019.02.00.0/readme.md --- cppad-2018.00.00.0/readme.md 2017-08-28 15:20:18.000000000 +0000 +++ cppad-2019.02.00.0/readme.md 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,34 @@ -# CppAD: A Package for Differentiation of C++ Algorithms +# Title +CppAD: A Package for Differentiation of C++ Algorithms -[gh-pages](https://coin-or.github.io/CppAD/doc) +# Links -## Links +- [docmentation](https://coin-or.github.io/CppAD/doc) -- [Homepage](http://www.coin-or.org/CppAD/) +- [News](https://coin-or.github.io/CppAD/doc/whats_new.htm) -- [Directories](http://www.coin-or.org/CppAD/directory.htm) +- [Install](https://coin-or.github.io/CppAD/doc/install.htm) -- [News](https://www.coin-or.org/CppAD/Doc/whats_new.htm) +- [Directories](https://coin-or.github.io/CppAD/doc/directory.htm) -- [Versions](http://www.coin-or.org/CppAD/Doc/download.htm) +- [Coin-OR Download](https://www.coin-or.org/download/source/CppAD/) -- [Install](https://www.coin-or.org/CppAD/Doc/install.htm) -- [Web Documentation](https://www.coin-or.org/CppAD/Doc/cppad.htm) +# License +
+CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell
 
-- [Coin-OR Download](https://www.coin-or.org/download/source/CppAD/)
+CppAD is distributed under the terms of the
+             Eclipse Public License Version 2.0.
 
-- [Deprecated](https://www.coin-or.org/CppAD/Doc/deprecated.htm)
+This Source Code may also be made available under the following
+Secondary License when the conditions for such availability set forth
+in the Eclipse Public License, Version 2.0 are satisfied:
+      GNU General Public License, Version 2.0 or later.
+
-## Autotools +# Autotools The preferred method to test and install CppAD uses cmake. The deprecated autotools procedure can be used for this purpose, but it will eventually be removed. @@ -39,17 +46,5 @@ `missing`. -## Tarballs -CppAD is available from Coin-OR with both the EPL and GPL licenses; see -the versions link above. There is a separate tarball on the -Coin-OR download page -for each version and each license. - -## Documentation -The web documentaition (linked above) is for the most recent version of CppAD. -The tarballs mentioned above include documention for the corresponding version -in a `doc` subdirectory. - -## Copyright: +# Copyright: See the file `authors` in this directory. - diff -Nru cppad-2018.00.00.0/speed/add_test.sh cppad-2019.02.00.0/speed/add_test.sh --- cppad-2018.00.00.0/speed/add_test.sh 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/add_test.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,14 +1,14 @@ #! /bin/bash -e -# $Id: add_test.sh 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. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Use this shell script when a new test is added to initially create # the source code files */test_name.cpp which return false (for not available). @@ -19,41 +19,41 @@ # if [ "$1" == "" ] then - echo "usage: new_test.sh test_name" - echo "where test_name is the name of the new test being added" - exit 1 + echo "usage: new_test.sh test_name" + echo "where test_name is the name of the new test being added" + exit 1 fi test_name="$1" if [ ! -e "link_$test_name.cpp" ] then - echo "The file ./link_$test_name.cpp does not yet exist." - echo "It must first be created before executing this script." - exit 1 + echo "The file ./link_$test_name.cpp does not yet exist." + echo "It must first be created before executing this script." + exit 1 fi if ! grep "speed\/link_$test_name.cpp" main.cpp then - echo "link_$test_name.cpp has not yet been added to main.cpp" - exit 1 + echo "link_$test_name.cpp has not yet been added to main.cpp" + exit 1 fi list=" - adolc - cppad - double - fadbad - sacado + adolc + cppad + double + fadbad + sacado " for dir in profile $list do - if grep "link_$test_name.cpp" $dir/makefile.am - then - echo "$test_name.cpp is already in $dir/makefile.am" - exit 1 - fi - if [ -e $dir/$test_name.cpp ] - then - echo "The file $dir/$test_name.cpp already exists." - exit 1 - fi + if grep "link_$test_name.cpp" $dir/makefile.am + then + echo "$test_name.cpp is already in $dir/makefile.am" + exit 1 + fi + if [ -e $dir/$test_name.cpp ] + then + echo "The file $dir/$test_name.cpp already exists." + exit 1 + fi done # sed -i main.cpp -e "s/speed\/link[^%]*\$/&%\n\tspeed\/link_$test_name.cpp/" @@ -63,11 +63,11 @@ fun=`echo "$link" | sed -e 's/extern */\n/' -e 's/^);/)\n{\n\treturn false;\n}/'` for dir in $list do - echo "$copy$fun" > $dir/$test_name.cpp - sed -i $dir/makefile.am \ - -e "s/\/main.cpp.*/&\n\t..\/link_$test_name.cpp \\\\/" \ - -e "s/\/link_$test_name.cpp.*/&\n\t$test_name.cpp \\\\/" + echo "$copy$fun" > $dir/$test_name.cpp + sed -i $dir/makefile.am \ + -e "s/\/main.cpp.*/&\n\t..\/link_$test_name.cpp \\\\/" \ + -e "s/\/link_$test_name.cpp.*/&\n\t$test_name.cpp \\\\/" done sed -i profile/makefile.am \ - -e "s/\/main.cpp.*/&\n\t..\/link_$test_name.cpp \\\\/" \ - -e "s/\/link_$test_name.cpp.*/&\n\t..\/cppad\/$test_name.cpp \\\\/" + -e "s/\/main.cpp.*/&\n\t..\/link_$test_name.cpp \\\\/" \ + -e "s/\/link_$test_name.cpp.*/&\n\t..\/cppad\/$test_name.cpp \\\\/" diff -Nru cppad-2018.00.00.0/speed/adolc/adolc_alloc_mat.hpp cppad-2019.02.00.0/speed/adolc/adolc_alloc_mat.hpp --- cppad-2018.00.00.0/speed/adolc/adolc_alloc_mat.hpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/adolc_alloc_mat.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,17 +1,16 @@ -// $Id: adolc_alloc_mat.hpp 3804 2016-03-20 15:08:46Z bradbell $ +# ifndef CPPAD_SPEED_ADOLC_ADOLC_ALLOC_MAT_HPP +# define CPPAD_SPEED_ADOLC_ADOLC_ALLOC_MAT_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ -# ifndef CPPAD_SPEED_ADOLC_ADOLC_ALLOC_MAT_HPP -# define CPPAD_SPEED_ADOLC_ADOLC_ALLOC_MAT_HPP +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ double** adolc_alloc_mat(size_t m, size_t n); void adolc_free_mat(double** mat); diff -Nru cppad-2018.00.00.0/speed/adolc/adolc_usrparms.sh cppad-2019.02.00.0/speed/adolc/adolc_usrparms.sh --- cppad-2018.00.00.0/speed/adolc/adolc_usrparms.sh 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/adolc_usrparms.sh 2019-01-31 12:35:17.000000000 +0000 @@ -1,14 +1,14 @@ #! /bin/bash -e -# $Id: adolc_usrparms.sh 3217 2014-03-19 05:09:01Z 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. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- #! /bin/bash # @@ -39,43 +39,43 @@ " if [ "$1" == "" ] then - echo "$message" - exit 1 + echo "$message" + exit 1 fi file="$1/adolc/usrparms.h" if [ ! -e $file ] then - echo "adolc_usrparms.sh: cannot find the file $file" - exit 1 + echo "adolc_usrparms.sh: cannot find the file $file" + exit 1 fi # # case where we print the value of BUFSIZE and TBUFSIZE if [ "$2" == "" ] then - grep "^#define T*BUFSIZE" < $file - exit 0 + grep "^#define T*BUFSIZE" < $file + exit 0 fi same="/* Previous: \1\2 */ \3\n#define" cmd_one="s|^\(#define BUFSIZE *\)\([0-9]*\)\(.*\)|$same BUFSIZE $2|" cmd_two="s|^\(#define TBUFSIZE *\)\([0-9]*\)\(.*\)|$same TBUFSIZE $3|" if [ "$4" == "show" ] then - sed < $file > adolc_usrparms.tmp \ - -e "$cmd_one" -e "$cmd_two" - diff $file adolc_usrparms.tmp - exit 0 + sed < $file > adolc_usrparms.tmp \ + -e "$cmd_one" -e "$cmd_two" + diff $file adolc_usrparms.tmp + exit 0 fi if [ "$4" == "modify" ] then - sed < $file > adolc_usrparms.tmp \ - -e "$cmd_one" -e "$cmd_two" - diff $file adolc_usrparms.tmp - mv adolc_usrparms.tmp $file - echo "Execute the following commands for the change to take effect:" - echo "cd $1" - echo "make" - echo "make install" - exit 0 + sed < $file > adolc_usrparms.tmp \ + -e "$cmd_one" -e "$cmd_two" + diff $file adolc_usrparms.tmp + mv adolc_usrparms.tmp $file + echo "Execute the following commands for the change to take effect:" + echo "cd $1" + echo "make" + echo "make install" + exit 0 fi echo "$message" exit 1 diff -Nru cppad-2018.00.00.0/speed/adolc/alloc_mat.cpp cppad-2019.02.00.0/speed/adolc/alloc_mat.cpp --- cppad-2018.00.00.0/speed/adolc/alloc_mat.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/alloc_mat.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,23 +1,22 @@ -// $Id: alloc_mat.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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin adolc_alloc_mat$$ $spell - adolc - alloc + adolc + alloc $$ $section Adolc Test Utility: Allocate and Free Memory For a Matrix$$ -$mindex adolc_alloc_mat alloc$$ $head Syntax$$ $codei%mat% = adolc_alloc_mat(%m%, %n%) @@ -50,19 +49,19 @@ # include double** adolc_alloc_mat(size_t m, size_t n) -{ using CppAD::thread_alloc; - size_t size_min = m * n, size_out; - double* vec = thread_alloc::create_array(size_min, size_out); - double** mat = thread_alloc::create_array(size_min, size_out); +{ using CppAD::thread_alloc; + size_t size_min = m * n, size_out; + double* vec = thread_alloc::create_array(size_min, size_out); + double** mat = thread_alloc::create_array(size_min, size_out); - for(size_t i = 0; i < m; i++) - mat[i] = vec + i * n; + for(size_t i = 0; i < m; i++) + mat[i] = vec + i * n; - return mat; + return mat; } void adolc_free_mat(double** mat) -{ using CppAD::thread_alloc; - thread_alloc::delete_array(mat[0]); - thread_alloc::delete_array(mat); - return; +{ using CppAD::thread_alloc; + thread_alloc::delete_array(mat[0]); + thread_alloc::delete_array(mat); + return; } diff -Nru cppad-2018.00.00.0/speed/adolc/CMakeLists.txt cppad-2019.02.00.0/speed/adolc/CMakeLists.txt --- cppad-2018.00.00.0/speed/adolc/CMakeLists.txt 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,22 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the speed/adolc directory tests # Inherit build type from ../CMakeList.txt # assert adolc_prefix is defined IF ( NOT adolc_prefix ) - MESSAGE(FATAL_ERROR - "speed/adolc/CMakeLists.txt: adolc_prefix = ${adolc_prefix}" - ) + MESSAGE(FATAL_ERROR + "speed/adolc/CMakeLists.txt: adolc_prefix = ${adolc_prefix}" + ) ENDIF ( NOT adolc_prefix ) @@ -31,13 +32,13 @@ # source1 source2 ... sourceN # ) SET(source_list ../main.cpp alloc_mat.cpp - det_lu.cpp - det_minor.cpp - mat_mul.cpp - ode.cpp - poly.cpp - sparse_hessian.cpp - sparse_jacobian.cpp + det_lu.cpp + det_minor.cpp + mat_mul.cpp + ode.cpp + poly.cpp + sparse_hessian.cpp + sparse_jacobian.cpp ) set_compile_flags( speed_adolc "${cppad_debug_which}" "${source_list}" ) # @@ -45,18 +46,18 @@ # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(speed_adolc - speed_src - ${cppad_lib} - adolc - ${colpack_libs} + speed_src + ${cppad_lib} + adolc + ${colpack_libs} ) # Add the check_speed_adolc target ADD_CUSTOM_TARGET( - check_speed_adolc - speed_adolc correct 54321 colpack - DEPENDS - speed_adolc speed_src + check_speed_adolc + speed_adolc correct 54321 colpack + DEPENDS + speed_adolc speed_src ) MESSAGE(STATUS "make check_speed_adolc: available") diff -Nru cppad-2018.00.00.0/speed/adolc/det_lu.cpp cppad-2019.02.00.0/speed/adolc/det_lu.cpp --- cppad-2018.00.00.0/speed/adolc/det_lu.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/det_lu.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,35 +1,35 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin adolc_det_lu.cpp$$ $spell - onetape - thread_alloc - cppad - fos - adouble - CppAD - typedef - adolc - Lu - Adolc - det - hpp - const - bool - srand + onetape + thread_alloc + cppad + fos + adouble + CppAD + typedef + adolc + Lu + Adolc + det + hpp + const + bool + srand $$ $section Adolc Speed: Gradient of Determinant Using Lu Factorization$$ -$mindex link_det_lu speed matrix factor$$ $head Specifications$$ @@ -51,88 +51,88 @@ extern std::map global_option; bool link_det_lu( - size_t size , - size_t repeat , - CppAD::vector &matrix , - CppAD::vector &gradient ) + size_t size , + size_t repeat , + CppAD::vector &matrix , + CppAD::vector &gradient ) { - // speed test global option values - if( global_option["onetape"] || global_option["atomic"] ) - return false; - if( global_option["memory"] || global_option["optimize"] ) - return false; - // ----------------------------------------------------- - // setup - int tag = 0; // tape identifier - int keep = 1; // keep forward mode results in buffer - int m = 1; // number of dependent variables - int n = size*size; // number of independent variables - double f; // function value - int j; // temporary index - - // set up for thread_alloc memory allocator (fast and checks for leaks) - using CppAD::thread_alloc; // the allocator - size_t size_min; // requested number of elements - size_t size_out; // capacity of an allocation - - // object for computing determinant - typedef adouble ADScalar; - typedef ADScalar* ADVector; - CppAD::det_by_lu Det(size); - - // AD value of determinant - ADScalar detA; - - // AD version of matrix - size_min = n; - ADVector A = thread_alloc::create_array(size_min, size_out); - - // vectors of reverse mode weights - size_min = m; - double* u = thread_alloc::create_array(size_min, size_out); - u[0] = 1.; - - // vector with matrix value - size_min = n; - double* mat = thread_alloc::create_array(size_min, size_out); - - // vector to receive gradient result - size_min = n; - double* grad = thread_alloc::create_array(size_min, size_out); - // ------------------------------------------------------ - while(repeat--) - { // get the next matrix - CppAD::uniform_01(n, mat); - - // declare independent variables - trace_on(tag, keep); - for(j = 0; j < n; j++) - A[j] <<= mat[j]; - - // AD computation of the determinant - detA = Det(A); - - // create function object f : A -> detA - detA >>= f; - trace_off(); - - // evaluate and return gradient using reverse mode - fos_reverse(tag, m, n, u, grad); - } - // ------------------------------------------------------ - - // return matrix and gradient - for(j = 0; j < n; j++) - { matrix[j] = mat[j]; - gradient[j] = grad[j]; - } - // tear down - thread_alloc::delete_array(grad); - thread_alloc::delete_array(mat); - thread_alloc::delete_array(u); - thread_alloc::delete_array(A); + // speed test global option values + if( global_option["onetape"] || global_option["atomic"] ) + return false; + if( global_option["memory"] || global_option["optimize"] ) + return false; + // ----------------------------------------------------- + // setup + int tag = 0; // tape identifier + int keep = 1; // keep forward mode results in buffer + int m = 1; // number of dependent variables + int n = size*size; // number of independent variables + double f; // function value + int j; // temporary index + + // set up for thread_alloc memory allocator (fast and checks for leaks) + using CppAD::thread_alloc; // the allocator + size_t size_min; // requested number of elements + size_t size_out; // capacity of an allocation + + // object for computing determinant + typedef adouble ADScalar; + typedef ADScalar* ADVector; + CppAD::det_by_lu Det(size); + + // AD value of determinant + ADScalar detA; + + // AD version of matrix + size_min = n; + ADVector A = thread_alloc::create_array(size_min, size_out); + + // vectors of reverse mode weights + size_min = m; + double* u = thread_alloc::create_array(size_min, size_out); + u[0] = 1.; + + // vector with matrix value + size_min = n; + double* mat = thread_alloc::create_array(size_min, size_out); + + // vector to receive gradient result + size_min = n; + double* grad = thread_alloc::create_array(size_min, size_out); + // ------------------------------------------------------ + while(repeat--) + { // get the next matrix + CppAD::uniform_01(n, mat); + + // declare independent variables + trace_on(tag, keep); + for(j = 0; j < n; j++) + A[j] <<= mat[j]; + + // AD computation of the determinant + detA = Det(A); + + // create function object f : A -> detA + detA >>= f; + trace_off(); + + // evaluate and return gradient using reverse mode + fos_reverse(tag, m, n, u, grad); + } + // ------------------------------------------------------ + + // return matrix and gradient + for(j = 0; j < n; j++) + { matrix[j] = mat[j]; + gradient[j] = grad[j]; + } + // tear down + thread_alloc::delete_array(grad); + thread_alloc::delete_array(mat); + thread_alloc::delete_array(u); + thread_alloc::delete_array(A); - return true; + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/adolc/det_minor.cpp cppad-2019.02.00.0/speed/adolc/det_minor.cpp --- cppad-2018.00.00.0/speed/adolc/det_minor.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/det_minor.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,36 +1,36 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin adolc_det_minor.cpp$$ $spell - thread_alloc - onetape - cppad - zos - fos - adouble - CppAD - typedef - adolc - Lu - Adolc - det - hpp - const - bool - srand + thread_alloc + onetape + cppad + zos + fos + adouble + CppAD + typedef + adolc + Lu + Adolc + det + hpp + const + bool + srand $$ $section Adolc Speed: Gradient of Determinant by Minor Expansion$$ -$mindex link_det_minor speed$$ $head Specifications$$ @@ -51,115 +51,115 @@ extern std::map global_option; bool link_det_minor( - size_t size , - size_t repeat , - CppAD::vector &matrix , - CppAD::vector &gradient ) + size_t size , + size_t repeat , + CppAD::vector &matrix , + CppAD::vector &gradient ) { - // speed test global option values - if( global_option["atomic"] ) - return false; - if( global_option["memory"] || global_option["optimize"] ) - return false; - // ----------------------------------------------------- - // setup - typedef adouble ADScalar; - typedef ADScalar* ADVector; - - int tag = 0; // tape identifier - int m = 1; // number of dependent variables - int n = size*size; // number of independent variables - double f; // function value - int j; // temporary index - - // set up for thread_alloc memory allocator (fast and checks for leaks) - using CppAD::thread_alloc; // the allocator - size_t capacity; // capacity of an allocation - - // object for computing determinant - CppAD::det_by_minor Det(size); - - // AD value of determinant - ADScalar detA; - - // AD version of matrix - ADVector A = thread_alloc::create_array(size_t(n), capacity); - - // vectors of reverse mode weights - double* u = thread_alloc::create_array(size_t(m), capacity); - u[0] = 1.; - - // vector with matrix value - double* mat = thread_alloc::create_array(size_t(n), capacity); - - // vector to receive gradient result - double* grad = thread_alloc::create_array(size_t(n), capacity); - - // ---------------------------------------------------------------------- - if( ! global_option["onetape"] ) while(repeat--) - { // choose a matrix - CppAD::uniform_01(n, mat); - - // declare independent variables - int keep = 1; // keep forward mode results - trace_on(tag, keep); - for(j = 0; j < n; j++) - A[j] <<= mat[j]; - - // AD computation of the determinant - detA = Det(A); - - // create function object f : A -> detA - detA >>= f; - trace_off(); - - // evaluate and return gradient using reverse mode - fos_reverse(tag, m, n, u, grad); - } - else - { - // choose a matrix - CppAD::uniform_01(n, mat); - - // declare independent variables - int keep = 0; // do not keep forward mode results in buffer - trace_on(tag, keep); - for(j = 0; j < n; j++) - A[j] <<= mat[j]; - - // AD computation of the determinant - detA = Det(A); - - // create function object f : A -> detA - detA >>= f; - trace_off(); - - while(repeat--) - { // get the next matrix - CppAD::uniform_01(n, mat); - - // evaluate the determinant at the new matrix value - keep = 1; // keep this forward mode result - zos_forward(tag, m, n, keep, mat, &f); - - // evaluate and return gradient using reverse mode - fos_reverse(tag, m, n, u, grad); - } - } - // -------------------------------------------------------------------- - - // return matrix and gradient - for(j = 0; j < n; j++) - { matrix[j] = mat[j]; - gradient[j] = grad[j]; - } - - // tear down - thread_alloc::delete_array(grad); - thread_alloc::delete_array(mat); - thread_alloc::delete_array(u); - thread_alloc::delete_array(A); - return true; + // speed test global option values + if( global_option["atomic"] ) + return false; + if( global_option["memory"] || global_option["optimize"] ) + return false; + // ----------------------------------------------------- + // setup + typedef adouble ADScalar; + typedef ADScalar* ADVector; + + int tag = 0; // tape identifier + int m = 1; // number of dependent variables + int n = size*size; // number of independent variables + double f; // function value + int j; // temporary index + + // set up for thread_alloc memory allocator (fast and checks for leaks) + using CppAD::thread_alloc; // the allocator + size_t capacity; // capacity of an allocation + + // object for computing determinant + CppAD::det_by_minor Det(size); + + // AD value of determinant + ADScalar detA; + + // AD version of matrix + ADVector A = thread_alloc::create_array(size_t(n), capacity); + + // vectors of reverse mode weights + double* u = thread_alloc::create_array(size_t(m), capacity); + u[0] = 1.; + + // vector with matrix value + double* mat = thread_alloc::create_array(size_t(n), capacity); + + // vector to receive gradient result + double* grad = thread_alloc::create_array(size_t(n), capacity); + + // ---------------------------------------------------------------------- + if( ! global_option["onetape"] ) while(repeat--) + { // choose a matrix + CppAD::uniform_01(n, mat); + + // declare independent variables + int keep = 1; // keep forward mode results + trace_on(tag, keep); + for(j = 0; j < n; j++) + A[j] <<= mat[j]; + + // AD computation of the determinant + detA = Det(A); + + // create function object f : A -> detA + detA >>= f; + trace_off(); + + // evaluate and return gradient using reverse mode + fos_reverse(tag, m, n, u, grad); + } + else + { + // choose a matrix + CppAD::uniform_01(n, mat); + + // declare independent variables + int keep = 0; // do not keep forward mode results in buffer + trace_on(tag, keep); + for(j = 0; j < n; j++) + A[j] <<= mat[j]; + + // AD computation of the determinant + detA = Det(A); + + // create function object f : A -> detA + detA >>= f; + trace_off(); + + while(repeat--) + { // get the next matrix + CppAD::uniform_01(n, mat); + + // evaluate the determinant at the new matrix value + keep = 1; // keep this forward mode result + zos_forward(tag, m, n, keep, mat, &f); + + // evaluate and return gradient using reverse mode + fos_reverse(tag, m, n, u, grad); + } + } + // -------------------------------------------------------------------- + + // return matrix and gradient + for(j = 0; j < n; j++) + { matrix[j] = mat[j]; + gradient[j] = grad[j]; + } + + // tear down + thread_alloc::delete_array(grad); + thread_alloc::delete_array(mat); + thread_alloc::delete_array(u); + thread_alloc::delete_array(A); + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/adolc/makefile.am cppad-2019.02.00.0/speed/adolc/makefile.am --- cppad-2018.00.00.0/speed/adolc/makefile.am 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,13 @@ -# $Id: makefile.am 3779 2016-01-01 11:26:11Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory @@ -21,19 +21,15 @@ # check_PROGRAMS = speed_adolc # -AM_CPPFLAGS = \ - -I$(top_srcdir) \ +# +AM_CXXFLAGS = \ + -DCPPAD_ADOLC_SPEED \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ -I$(ADOLC_DIR)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) # -# BEGIN OPTIMIZE -AM_CXXFLAGS = -O2 -DNDEBUG -DCPPAD_ADOLC_SPEED $(CXX_FLAGS) -# END OPTIMIZE -# -# BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) -DCPPAD_ADOLC_SPEED -# END DEBUG # LDADD = -lspeed -ladolc -lColPack AM_LDFLAGS = -L../src -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64 diff -Nru cppad-2018.00.00.0/speed/adolc/makefile.in cppad-2019.02.00.0/speed/adolc/makefile.in --- cppad-2018.00.00.0/speed/adolc/makefile.in 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -198,8 +198,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # # @@ -272,10 +270,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -294,9 +290,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -319,8 +317,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -341,35 +337,31 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3973 2017-08-30 13:38:26Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp # -AM_CPPFLAGS = \ - -I$(top_srcdir) \ +# +AM_CXXFLAGS = \ + -DCPPAD_ADOLC_SPEED \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ -I$(ADOLC_DIR)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) # -# BEGIN OPTIMIZE -AM_CXXFLAGS = -O2 -DNDEBUG -DCPPAD_ADOLC_SPEED $(CXX_FLAGS) -# END OPTIMIZE -# -# BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) -DCPPAD_ADOLC_SPEED -# END DEBUG # LDADD = -lspeed -ladolc -lColPack AM_LDFLAGS = -L../src -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64 diff -Nru cppad-2018.00.00.0/speed/adolc/mat_mul.cpp cppad-2019.02.00.0/speed/adolc/mat_mul.cpp --- cppad-2018.00.00.0/speed/adolc/mat_mul.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/mat_mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,33 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin adolc_mat_mul.cpp$$ $spell - sq - onetape - adouble - typedef - alloc - zos - fos - Adolc - cppad.hpp - bool - mul - dz - CppAD + sq + onetape + adouble + typedef + alloc + zos + fos + Adolc + cppad.hpp + bool + mul + dz + CppAD $$ $section Adolc Speed: Matrix Multiplication$$ -$mindex link_mat_mul speed multiply$$ $head Specifications$$ @@ -50,115 +50,115 @@ extern std::map global_option; bool link_mat_mul( - size_t size , - size_t repeat , - CppAD::vector& x , - CppAD::vector& z , - CppAD::vector& dz ) + size_t size , + size_t repeat , + CppAD::vector& x , + CppAD::vector& z , + CppAD::vector& dz ) { - // speed test global option values - if( global_option["memory"] || global_option["atomic"] || global_option["optimize"] ) - return false; - // ----------------------------------------------------- - // setup - typedef adouble ADScalar; - typedef ADScalar* ADVector; - - int tag = 0; // tape identifier - int m = 1; // number of dependent variables - int n = size*size; // number of independent variables - double f; // function value - int j; // temporary index - - // set up for thread_alloc memory allocator (fast and checks for leaks) - using CppAD::thread_alloc; // the allocator - size_t capacity; // capacity of an allocation - - // AD domain space vector - ADVector X = thread_alloc::create_array(size_t(n), capacity); - - // Product matrix - ADVector Y = thread_alloc::create_array(size_t(n), capacity); - - // AD range space vector - ADVector Z = thread_alloc::create_array(size_t(m), capacity); - - // vector with matrix value - double* mat = thread_alloc::create_array(size_t(n), capacity); - - // vector of reverse mode weights - double* u = thread_alloc::create_array(size_t(m), capacity); - u[0] = 1.; - - // gradient - double* grad = thread_alloc::create_array(size_t(n), capacity); - - // ---------------------------------------------------------------------- - if( ! global_option["onetape"] ) while(repeat--) - { // choose a matrix - CppAD::uniform_01(n, mat); - - // declare independent variables - int keep = 1; // keep forward mode results - trace_on(tag, keep); - for(j = 0; j < n; j++) - X[j] <<= mat[j]; - - // do computations - CppAD::mat_sum_sq(size, X, Y, Z); - - // create function object f : X -> Z - Z[0] >>= f; - trace_off(); - - // evaluate and return gradient using reverse mode - fos_reverse(tag, m, n, u, grad); - } - else - { // choose a matrix - CppAD::uniform_01(n, mat); - - // declare independent variables - int keep = 0; // do not keep forward mode results - trace_on(tag, keep); - for(j = 0; j < n; j++) - X[j] <<= mat[j]; - - // do computations - CppAD::mat_sum_sq(size, X, Y, Z); - - // create function object f : X -> Z - Z[0] >>= f; - trace_off(); - - while(repeat--) - { // choose a matrix - CppAD::uniform_01(n, mat); - - // evaluate the determinant at the new matrix value - keep = 1; // keep this forward mode result - zos_forward(tag, m, n, keep, mat, &f); - - // evaluate and return gradient using reverse mode - fos_reverse(tag, m, n, u, grad); - } - } - // return function, matrix, and gradient - z[0] = f; - for(j = 0; j < n; j++) - { x[j] = mat[j]; - dz[j] = grad[j]; - } - - // tear down - thread_alloc::delete_array(X); - thread_alloc::delete_array(Y); - thread_alloc::delete_array(Z); - thread_alloc::delete_array(mat); - thread_alloc::delete_array(u); - thread_alloc::delete_array(grad); + // speed test global option values + if( global_option["memory"] || global_option["atomic"] || global_option["optimize"] ) + return false; + // ----------------------------------------------------- + // setup + typedef adouble ADScalar; + typedef ADScalar* ADVector; + + int tag = 0; // tape identifier + int m = 1; // number of dependent variables + int n = size*size; // number of independent variables + double f; // function value + int j; // temporary index + + // set up for thread_alloc memory allocator (fast and checks for leaks) + using CppAD::thread_alloc; // the allocator + size_t capacity; // capacity of an allocation + + // AD domain space vector + ADVector X = thread_alloc::create_array(size_t(n), capacity); + + // Product matrix + ADVector Y = thread_alloc::create_array(size_t(n), capacity); + + // AD range space vector + ADVector Z = thread_alloc::create_array(size_t(m), capacity); + + // vector with matrix value + double* mat = thread_alloc::create_array(size_t(n), capacity); + + // vector of reverse mode weights + double* u = thread_alloc::create_array(size_t(m), capacity); + u[0] = 1.; + + // gradient + double* grad = thread_alloc::create_array(size_t(n), capacity); + + // ---------------------------------------------------------------------- + if( ! global_option["onetape"] ) while(repeat--) + { // choose a matrix + CppAD::uniform_01(n, mat); + + // declare independent variables + int keep = 1; // keep forward mode results + trace_on(tag, keep); + for(j = 0; j < n; j++) + X[j] <<= mat[j]; + + // do computations + CppAD::mat_sum_sq(size, X, Y, Z); + + // create function object f : X -> Z + Z[0] >>= f; + trace_off(); + + // evaluate and return gradient using reverse mode + fos_reverse(tag, m, n, u, grad); + } + else + { // choose a matrix + CppAD::uniform_01(n, mat); + + // declare independent variables + int keep = 0; // do not keep forward mode results + trace_on(tag, keep); + for(j = 0; j < n; j++) + X[j] <<= mat[j]; + + // do computations + CppAD::mat_sum_sq(size, X, Y, Z); + + // create function object f : X -> Z + Z[0] >>= f; + trace_off(); + + while(repeat--) + { // choose a matrix + CppAD::uniform_01(n, mat); + + // evaluate the determinant at the new matrix value + keep = 1; // keep this forward mode result + zos_forward(tag, m, n, keep, mat, &f); + + // evaluate and return gradient using reverse mode + fos_reverse(tag, m, n, u, grad); + } + } + // return function, matrix, and gradient + z[0] = f; + for(j = 0; j < n; j++) + { x[j] = mat[j]; + dz[j] = grad[j]; + } + + // tear down + thread_alloc::delete_array(X); + thread_alloc::delete_array(Y); + thread_alloc::delete_array(Z); + thread_alloc::delete_array(mat); + thread_alloc::delete_array(u); + thread_alloc::delete_array(grad); - return true; + return true; } diff -Nru cppad-2018.00.00.0/speed/adolc/ode.cpp cppad-2019.02.00.0/speed/adolc/ode.cpp --- cppad-2018.00.00.0/speed/adolc/ode.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/ode.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,31 +1,31 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin adolc_ode.cpp$$ $spell - typedef - adouble - jacobian jacobian - jac_ptr - alloc - cppad.hpp - Jacobian - Adolc - bool - CppAD - onetape + typedef + adouble + jacobian jacobian + jac_ptr + alloc + cppad.hpp + Jacobian + Adolc + bool + CppAD + onetape $$ $section Adolc Speed: Ode$$ -$mindex link_ode speed$$ $head Specifications$$ @@ -48,111 +48,111 @@ extern std::map global_option; bool link_ode( - size_t size , - size_t repeat , - CppAD::vector &x , - CppAD::vector &jac + size_t size , + size_t repeat , + CppAD::vector &x , + CppAD::vector &jac ) { - // speed test global option values - if( global_option["atomic"] ) - return false; - if( global_option["memory"] || global_option["optimize"] ) - return false; - // ------------------------------------------------------------- - // setup - assert( x.size() == size ); - assert( jac.size() == size * size ); - - typedef CppAD::vector ADVector; - typedef CppAD::vector DblVector; - - size_t i, j; - int tag = 0; // tape identifier - int keep = 0; // do not keep forward mode results - size_t p = 0; // use ode to calculate function values - size_t n = size; // number of independent variables - size_t m = n; // number of dependent variables - ADVector X(n), Y(m); // independent and dependent variables - DblVector f(m); // function value - - // set up for thread_alloc memory allocator (fast and checks for leaks) - using CppAD::thread_alloc; // the allocator - size_t size_min; // requested number of elements - size_t size_out; // capacity of an allocation - - // raw memory for use with adolc - size_min = n; - double *x_raw = thread_alloc::create_array(size_min, size_out); - size_min = m * n; - double *jac_raw = thread_alloc::create_array(size_min, size_out); - size_min = m; - double **jac_ptr = thread_alloc::create_array(size_min, size_out); - for(i = 0; i < m; i++) - jac_ptr[i] = jac_raw + i * n; - - // ------------------------------------------------------------- - if( ! global_option["onetape"] ) while(repeat--) - { // choose next x value - uniform_01(n, x); - - // declare independent variables - trace_on(tag, keep); - for(j = 0; j < n; j++) - X[j] <<= x[j]; - - // evaluate function - CppAD::ode_evaluate(X, p, Y); - - // create function object f : X -> Y - for(i = 0; i < m; i++) - Y[i] >>= f[i]; - trace_off(); - - // evaluate the Jacobian - for(j = 0; j < n; j++) - x_raw[j] = x[j]; - jacobian(tag, m, n, x_raw, jac_ptr); - } - else - { // choose next x value - uniform_01(n, x); - - // declare independent variables - trace_on(tag, keep); - for(j = 0; j < n; j++) - X[j] <<= x[j]; - - // evaluate function - CppAD::ode_evaluate(X, p, Y); - - // create function object f : X -> Y - for(i = 0; i < m; i++) - Y[i] >>= f[i]; - trace_off(); - - while(repeat--) - { // get next argument value - uniform_01(n, x); - for(j = 0; j < n; j++) - x_raw[j] = x[j]; - - // evaluate jacobian - jacobian(tag, m, n, x_raw, jac_ptr); - } - } - // convert return value to a simple vector - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - jac[i * n + j] = jac_ptr[i][j]; - } - // ---------------------------------------------------------------------- - // tear down - thread_alloc::delete_array(x_raw); - thread_alloc::delete_array(jac_raw); - thread_alloc::delete_array(jac_ptr); + // speed test global option values + if( global_option["atomic"] ) + return false; + if( global_option["memory"] || global_option["optimize"] ) + return false; + // ------------------------------------------------------------- + // setup + assert( x.size() == size ); + assert( jac.size() == size * size ); + + typedef CppAD::vector ADVector; + typedef CppAD::vector DblVector; + + size_t i, j; + int tag = 0; // tape identifier + int keep = 0; // do not keep forward mode results + size_t p = 0; // use ode to calculate function values + size_t n = size; // number of independent variables + size_t m = n; // number of dependent variables + ADVector X(n), Y(m); // independent and dependent variables + DblVector f(m); // function value + + // set up for thread_alloc memory allocator (fast and checks for leaks) + using CppAD::thread_alloc; // the allocator + size_t size_min; // requested number of elements + size_t size_out; // capacity of an allocation + + // raw memory for use with adolc + size_min = n; + double *x_raw = thread_alloc::create_array(size_min, size_out); + size_min = m * n; + double *jac_raw = thread_alloc::create_array(size_min, size_out); + size_min = m; + double **jac_ptr = thread_alloc::create_array(size_min, size_out); + for(i = 0; i < m; i++) + jac_ptr[i] = jac_raw + i * n; + + // ------------------------------------------------------------- + if( ! global_option["onetape"] ) while(repeat--) + { // choose next x value + uniform_01(n, x); + + // declare independent variables + trace_on(tag, keep); + for(j = 0; j < n; j++) + X[j] <<= x[j]; + + // evaluate function + CppAD::ode_evaluate(X, p, Y); + + // create function object f : X -> Y + for(i = 0; i < m; i++) + Y[i] >>= f[i]; + trace_off(); + + // evaluate the Jacobian + for(j = 0; j < n; j++) + x_raw[j] = x[j]; + jacobian(tag, m, n, x_raw, jac_ptr); + } + else + { // choose next x value + uniform_01(n, x); + + // declare independent variables + trace_on(tag, keep); + for(j = 0; j < n; j++) + X[j] <<= x[j]; + + // evaluate function + CppAD::ode_evaluate(X, p, Y); + + // create function object f : X -> Y + for(i = 0; i < m; i++) + Y[i] >>= f[i]; + trace_off(); + + while(repeat--) + { // get next argument value + uniform_01(n, x); + for(j = 0; j < n; j++) + x_raw[j] = x[j]; + + // evaluate jacobian + jacobian(tag, m, n, x_raw, jac_ptr); + } + } + // convert return value to a simple vector + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + jac[i * n + j] = jac_ptr[i][j]; + } + // ---------------------------------------------------------------------- + // tear down + thread_alloc::delete_array(x_raw); + thread_alloc::delete_array(jac_raw); + thread_alloc::delete_array(jac_ptr); - return true; + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/adolc/poly.cpp cppad-2019.02.00.0/speed/adolc/poly.cpp --- cppad-2018.00.00.0/speed/adolc/poly.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/poly.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,40 +1,40 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin adolc_poly.cpp$$ $spell - alloc - onetape - coef - cppad - hos - Taylor - std - ddp - cppad - adouble - std - vector Vector - typedef - adolc - Lu - CppAD - det - hpp - const - bool + alloc + onetape + coef + cppad + hos + Taylor + std + ddp + cppad + adouble + std + vector Vector + typedef + adolc + Lu + CppAD + det + hpp + const + bool $$ $section Adolc Speed: Second Derivative of a Polynomial$$ -$mindex link_poly speed$$ $head Specifications$$ @@ -60,112 +60,112 @@ extern std::map global_option; bool link_poly( - 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 + 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 { - if( global_option["atomic"] ) - return false; - if( global_option["memory"] || global_option["optimize"] ) - return false; - // ----------------------------------------------------- - // setup - size_t i; - int tag = 0; // tape identifier - 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 - double f; // function value - - // set up for thread_alloc memory allocator (fast and checks for leaks) - using CppAD::thread_alloc; // the allocator - size_t capacity; // capacity of an allocation - - // choose a vector of polynomial coefficients - CppAD::uniform_01(size, a); - - // AD copy of the polynomial coefficients - std::vector A(size); - for(i = 0; i < size; i++) - A[i] = a[i]; - - // domain and range space AD values - adouble Z, P; - - // allocate arguments to hos_forward - double* x0 = thread_alloc::create_array(size_t(n), capacity); - double* y0 = thread_alloc::create_array(size_t(m), capacity); - double** x = adolc_alloc_mat(size_t(n), size_t(d)); - double** y = adolc_alloc_mat(size_t(m), size_t(d)); - - // Taylor coefficient for argument - x[0][0] = 1.; // first order - x[0][1] = 0.; // second order - - // ---------------------------------------------------------------------- - if( ! global_option["onetape"] ) while(repeat--) - { // choose an argument value - CppAD::uniform_01(1, z); - - // declare independent variables - trace_on(tag, keep); - Z <<= z[0]; - - // AD computation of the function value - P = CppAD::Poly(0, A, Z); - - // create function object f : Z -> P - P >>= f; - trace_off(); - - // set the argument value - x0[0] = z[0]; - - // evaluate the polynomial at the new argument value - hos_forward(tag, m, n, d, keep, x0, x, y0, y); - - // second derivative is twice second order Taylor coef - ddp[0] = 2. * y[0][1]; - } - else - { - // choose an argument value - CppAD::uniform_01(1, z); - - // declare independent variables - trace_on(tag, keep); - Z <<= z[0]; - - // AD computation of the function value - P = CppAD::Poly(0, A, Z); - - // create function object f : Z -> P - P >>= f; - trace_off(); - - while(repeat--) - { // get the next argument value - CppAD::uniform_01(1, z); - x0[0] = z[0]; - - // evaluate the polynomial at the new argument value - hos_forward(tag, m, n, d, keep, x0, x, y0, y); - - // second derivative is twice second order Taylor coef - ddp[0] = 2. * y[0][1]; - } - } - // ------------------------------------------------------ - // tear down - adolc_free_mat(x); - adolc_free_mat(y); - thread_alloc::delete_array(x0); - thread_alloc::delete_array(y0); + if( global_option["atomic"] ) + return false; + if( global_option["memory"] || global_option["optimize"] ) + return false; + // ----------------------------------------------------- + // setup + size_t i; + int tag = 0; // tape identifier + 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 + double f; // function value + + // set up for thread_alloc memory allocator (fast and checks for leaks) + using CppAD::thread_alloc; // the allocator + size_t capacity; // capacity of an allocation + + // choose a vector of polynomial coefficients + CppAD::uniform_01(size, a); + + // AD copy of the polynomial coefficients + std::vector A(size); + for(i = 0; i < size; i++) + A[i] = a[i]; + + // domain and range space AD values + adouble Z, P; + + // allocate arguments to hos_forward + double* x0 = thread_alloc::create_array(size_t(n), capacity); + double* y0 = thread_alloc::create_array(size_t(m), capacity); + double** x = adolc_alloc_mat(size_t(n), size_t(d)); + double** y = adolc_alloc_mat(size_t(m), size_t(d)); + + // Taylor coefficient for argument + x[0][0] = 1.; // first order + x[0][1] = 0.; // second order + + // ---------------------------------------------------------------------- + if( ! global_option["onetape"] ) while(repeat--) + { // choose an argument value + CppAD::uniform_01(1, z); + + // declare independent variables + trace_on(tag, keep); + Z <<= z[0]; + + // AD computation of the function value + P = CppAD::Poly(0, A, Z); + + // create function object f : Z -> P + P >>= f; + trace_off(); + + // set the argument value + x0[0] = z[0]; + + // evaluate the polynomial at the new argument value + hos_forward(tag, m, n, d, keep, x0, x, y0, y); + + // second derivative is twice second order Taylor coef + ddp[0] = 2. * y[0][1]; + } + else + { + // choose an argument value + CppAD::uniform_01(1, z); + + // declare independent variables + trace_on(tag, keep); + Z <<= z[0]; + + // AD computation of the function value + P = CppAD::Poly(0, A, Z); + + // create function object f : Z -> P + P >>= f; + trace_off(); + + while(repeat--) + { // get the next argument value + CppAD::uniform_01(1, z); + x0[0] = z[0]; + + // evaluate the polynomial at the new argument value + hos_forward(tag, m, n, d, keep, x0, x, y0, y); + + // second derivative is twice second order Taylor coef + ddp[0] = 2. * y[0][1]; + } + } + // ------------------------------------------------------ + // tear down + adolc_free_mat(x); + adolc_free_mat(y); + thread_alloc::delete_array(x0); + thread_alloc::delete_array(y0); - return true; + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/adolc/sparse_hessian.cpp cppad-2019.02.00.0/speed/adolc/sparse_hessian.cpp --- cppad-2018.00.00.0/speed/adolc/sparse_hessian.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/sparse_hessian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,39 +1,39 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin adolc_sparse_hessian.cpp$$ $spell - colpack - boolsparsity - onetape - hess - int - nnz - cind - const - hes - thread_alloc - arg - cppad - adouble - CppAD - adolc - hpp - bool - typedef - endif + colpack + boolsparsity + onetape + hess + int + nnz + cind + const + hes + thread_alloc + arg + cppad + adouble + CppAD + adolc + hpp + bool + typedef + endif $$ $section Adolc Speed: Sparse Hessian$$ -$mindex link_sparse_hessian speed$$ $head Specifications$$ @@ -57,160 +57,160 @@ extern std::map global_option; bool link_sparse_hessian( - size_t size , - size_t repeat , - const CppAD::vector& row , - const CppAD::vector& col , - CppAD::vector& x_return , - CppAD::vector& hessian , - size_t& n_sweep ) + size_t size , + size_t repeat , + const CppAD::vector& row , + const CppAD::vector& col , + CppAD::vector& x_return , + CppAD::vector& hessian , + size_t& n_sweep ) { - if( global_option["atomic"] || (! global_option["colpack"]) ) - return false; - if( global_option["memory"] || global_option["optimize"] || global_option["boolsparsity"] ) - return false; - // ----------------------------------------------------- - // setup - typedef unsigned int* SizeVector; - typedef double* DblVector; - typedef adouble ADScalar; - typedef ADScalar* ADVector; - - - 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 - - // setup for thread_alloc memory allocator (fast and checks for leaks) - using CppAD::thread_alloc; // the allocator - size_t capacity; // capacity of an allocation - - // tape identifier - int tag = 0; - // AD domain space vector - 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 - DblVector x = thread_alloc::create_array(n, capacity); - // double function value - double f; - - // options that control sparse_hess - int options[2]; - options[0] = 0; // safe mode - options[1] = 0; // indirect recovery - - // structure that holds some of the work done by sparse_hess - int nnz; // number of non-zero values - SizeVector rind = CPPAD_NULL; // row indices - SizeVector cind = CPPAD_NULL; // column indices - DblVector values = CPPAD_NULL; // Hessian values - - // ---------------------------------------------------------------------- - if( ! global_option["onetape"] ) while(repeat--) - { // choose a value for x - CppAD::uniform_01(n, x); - - // declare independent variables - 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) - CppAD::sparse_hes_fun(n, a_x, row, col, order, a_y); - - // create function object f : x -> y - a_y[0] >>= f; - trace_off(); - - // is this a repeat call with the same sparsity pattern - int same_pattern = 0; - - // calculate the hessian at this x - rind = CPPAD_NULL; - cind = CPPAD_NULL; - values = CPPAD_NULL; - sparse_hess(tag, int(n), - same_pattern, x, &nnz, &rind, &cind, &values, options - ); - // 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 - free(rind); - free(cind); - free(values); - } - else - { // choose a value for x - CppAD::uniform_01(n, x); - - // declare independent variables - 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) - CppAD::sparse_hes_fun(n, a_x, row, col, order, a_y); - - // create function object f : x -> y - a_y[0] >>= f; - trace_off(); - - // is this a repeat call at the same argument - int same_pattern = 0; - - while(repeat--) - { // choose a value for x - CppAD::uniform_01(n, x); - - // calculate the hessian at this x - sparse_hess(tag, int(n), - same_pattern, x, &nnz, &rind, &cind, &values, options - ); - same_pattern = 1; - } - 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 - 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); - thread_alloc::delete_array(x); - return true; + if( global_option["atomic"] || (! global_option["colpack"]) ) + return false; + if( global_option["memory"] || global_option["optimize"] || global_option["boolsparsity"] ) + return false; + // ----------------------------------------------------- + // setup + typedef unsigned int* SizeVector; + typedef double* DblVector; + typedef adouble ADScalar; + typedef ADScalar* ADVector; + + + 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 + + // setup for thread_alloc memory allocator (fast and checks for leaks) + using CppAD::thread_alloc; // the allocator + size_t capacity; // capacity of an allocation + + // tape identifier + int tag = 0; + // AD domain space vector + 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 + DblVector x = thread_alloc::create_array(n, capacity); + // double function value + double f; + + // options that control sparse_hess + int options[2]; + options[0] = 0; // safe mode + options[1] = 0; // indirect recovery + + // structure that holds some of the work done by sparse_hess + int nnz; // number of non-zero values + SizeVector rind = CPPAD_NULL; // row indices + SizeVector cind = CPPAD_NULL; // column indices + DblVector values = CPPAD_NULL; // Hessian values + + // ---------------------------------------------------------------------- + if( ! global_option["onetape"] ) while(repeat--) + { // choose a value for x + CppAD::uniform_01(n, x); + + // declare independent variables + 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) + CppAD::sparse_hes_fun(n, a_x, row, col, order, a_y); + + // create function object f : x -> y + a_y[0] >>= f; + trace_off(); + + // is this a repeat call with the same sparsity pattern + int same_pattern = 0; + + // calculate the hessian at this x + rind = CPPAD_NULL; + cind = CPPAD_NULL; + values = CPPAD_NULL; + sparse_hess(tag, int(n), + same_pattern, x, &nnz, &rind, &cind, &values, options + ); + // 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 + free(rind); + free(cind); + free(values); + } + else + { // choose a value for x + CppAD::uniform_01(n, x); + + // declare independent variables + 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) + CppAD::sparse_hes_fun(n, a_x, row, col, order, a_y); + + // create function object f : x -> y + a_y[0] >>= f; + trace_off(); + + // is this a repeat call at the same argument + int same_pattern = 0; + + while(repeat--) + { // choose a value for x + CppAD::uniform_01(n, x); + + // calculate the hessian at this x + sparse_hess(tag, int(n), + same_pattern, x, &nnz, &rind, &cind, &values, options + ); + same_pattern = 1; + } + 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 + 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); + thread_alloc::delete_array(x); + return true; } /* %$$ diff -Nru cppad-2018.00.00.0/speed/adolc/sparse_jacobian.cpp cppad-2019.02.00.0/speed/adolc/sparse_jacobian.cpp --- cppad-2018.00.00.0/speed/adolc/sparse_jacobian.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/adolc/sparse_jacobian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,40 +1,40 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include # include /* $begin adolc_sparse_jacobian.cpp$$ $spell - const - sparsedrivers.cpp - colpack - boolsparsity - adouble - int int_n - cppad.hpp - onetape - typedef - alloc - jac - nnz - cind - bool - CppAD - adolc - sparse_jacobian + const + sparsedrivers.cpp + colpack + boolsparsity + adouble + int int_n + cppad.hpp + onetape + typedef + alloc + jac + nnz + cind + bool + CppAD + adolc + sparse_jacobian $$ $section adolc Speed: Sparse Jacobian$$ -$mindex link_sparse_jacobian speed$$ $head Specifications$$ @@ -57,169 +57,169 @@ extern std::map global_option; bool link_sparse_jacobian( - size_t size , - size_t repeat , - size_t m , - const CppAD::vector& row , - const CppAD::vector& col , - CppAD::vector& x_return , - CppAD::vector& jacobian , - size_t& n_sweep ) + size_t size , + size_t repeat , + size_t m , + const CppAD::vector& row , + const CppAD::vector& col , + CppAD::vector& x_return , + CppAD::vector& jacobian , + size_t& n_sweep ) { - if( global_option["atomic"] || (! global_option["colpack"]) ) - return false; - if( global_option["memory"] || global_option["optimize"] ) - return false; - // ----------------------------------------------------- - // setup - typedef unsigned int* SizeVector; - typedef double* DblVector; - typedef adouble ADScalar; - typedef ADScalar* ADVector; - - 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) - using CppAD::thread_alloc; // the allocator - size_t capacity; // capacity of an allocation - - // tape identifier - int tag = 0; - // AD domain space vector - ADVector a_x = thread_alloc::create_array(n, capacity); - // AD range space vector - ADVector a_y = thread_alloc::create_array(m, capacity); - // argument value in double - DblVector x = thread_alloc::create_array(n, capacity); - // function value in double - DblVector y = thread_alloc::create_array(m, capacity); - - - // options that control sparse_jac - int options[4]; - if( global_option["boolsparsity"] ) - options[0] = 1; // sparsity by propagation of bit pattern - else - options[0] = 0; // sparsity pattern by index domains - options[1] = 0; // (0 = safe mode, 1 = tight mode) - options[2] = 0; // see changing to -1 and back to 0 below - options[3] = 0; // (0 = column compression, 1 = row compression) - - // structure that holds some of the work done by sparse_jac - int nnz; // number of non-zero values - SizeVector rind = CPPAD_NULL; // row indices - SizeVector cind = CPPAD_NULL; // column indices - DblVector values = CPPAD_NULL; // Jacobian values - - // choose a value for x - CppAD::uniform_01(n, x); - - // declare independent variables - 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) - CppAD::sparse_jac_fun(m, n, a_x, row, col, order, a_y); - - // create function object f : x -> y - for(i = 0; i < m; i++) - a_y[i] >>= y[i]; - trace_off(); - - // 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), - same_pattern, x, &nnz, &rind, &cind, &values, options - ); - options[2] = 0; - // ---------------------------------------------------------------------- - if( ! global_option["onetape"] ) while(repeat--) - { // choose a value for x - CppAD::uniform_01(n, x); - - // declare independent variables - trace_on(tag, keep); - for(j = 0; j < n; j++) - a_x[j] <<= x[j]; - - // AD computation of f (x) - CppAD::sparse_jac_fun(m, n, a_x, row, col, order, a_y); - - // create function object f : x -> y - for(i = 0; i < m; i++) - a_y[i] >>= y[i]; - trace_off(); - - // is this a repeat call with the same sparsity pattern - same_pattern = 0; - - // calculate the jacobian at this x - rind = CPPAD_NULL; - cind = CPPAD_NULL; - values = CPPAD_NULL; - sparse_jac(tag, int(m), int(n), - same_pattern, x, &nnz, &rind, &cind, &values, options - ); - // 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); - free(cind); - free(values); - } - else - { while(repeat--) - { // choose a value for x - CppAD::uniform_01(n, x); - - // calculate the jacobian at this x - sparse_jac(tag, int(m), int(n), - same_pattern, x, &nnz, &rind, &cind, &values, options - ); - same_pattern = 1; - } - 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); - free(cind); - free(values); - } - // -------------------------------------------------------------------- - // return argument - for(j = 0; j < n; j++) - x_return[j] = x[j]; - - // tear down - thread_alloc::delete_array(a_x); - thread_alloc::delete_array(a_y); - thread_alloc::delete_array(x); - thread_alloc::delete_array(y); - return true; + if( global_option["atomic"] || (! global_option["colpack"]) ) + return false; + if( global_option["memory"] || global_option["optimize"] ) + return false; + // ----------------------------------------------------- + // setup + typedef unsigned int* SizeVector; + typedef double* DblVector; + typedef adouble ADScalar; + typedef ADScalar* ADVector; + + 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) + using CppAD::thread_alloc; // the allocator + size_t capacity; // capacity of an allocation + + // tape identifier + int tag = 0; + // AD domain space vector + ADVector a_x = thread_alloc::create_array(n, capacity); + // AD range space vector + ADVector a_y = thread_alloc::create_array(m, capacity); + // argument value in double + DblVector x = thread_alloc::create_array(n, capacity); + // function value in double + DblVector y = thread_alloc::create_array(m, capacity); + + + // options that control sparse_jac + int options[4]; + if( global_option["boolsparsity"] ) + options[0] = 1; // sparsity by propagation of bit pattern + else + options[0] = 0; // sparsity pattern by index domains + options[1] = 0; // (0 = safe mode, 1 = tight mode) + options[2] = 0; // see changing to -1 and back to 0 below + options[3] = 0; // (0 = column compression, 1 = row compression) + + // structure that holds some of the work done by sparse_jac + int nnz; // number of non-zero values + SizeVector rind = CPPAD_NULL; // row indices + SizeVector cind = CPPAD_NULL; // column indices + DblVector values = CPPAD_NULL; // Jacobian values + + // choose a value for x + CppAD::uniform_01(n, x); + + // declare independent variables + 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) + CppAD::sparse_jac_fun(m, n, a_x, row, col, order, a_y); + + // create function object f : x -> y + for(i = 0; i < m; i++) + a_y[i] >>= y[i]; + trace_off(); + + // 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), + same_pattern, x, &nnz, &rind, &cind, &values, options + ); + options[2] = 0; + // ---------------------------------------------------------------------- + if( ! global_option["onetape"] ) while(repeat--) + { // choose a value for x + CppAD::uniform_01(n, x); + + // declare independent variables + trace_on(tag, keep); + for(j = 0; j < n; j++) + a_x[j] <<= x[j]; + + // AD computation of f (x) + CppAD::sparse_jac_fun(m, n, a_x, row, col, order, a_y); + + // create function object f : x -> y + for(i = 0; i < m; i++) + a_y[i] >>= y[i]; + trace_off(); + + // is this a repeat call with the same sparsity pattern + same_pattern = 0; + + // calculate the jacobian at this x + rind = CPPAD_NULL; + cind = CPPAD_NULL; + values = CPPAD_NULL; + sparse_jac(tag, int(m), int(n), + same_pattern, x, &nnz, &rind, &cind, &values, options + ); + // 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); + free(cind); + free(values); + } + else + { while(repeat--) + { // choose a value for x + CppAD::uniform_01(n, x); + + // calculate the jacobian at this x + sparse_jac(tag, int(m), int(n), + same_pattern, x, &nnz, &rind, &cind, &values, options + ); + same_pattern = 1; + } + 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); + free(cind); + free(values); + } + // -------------------------------------------------------------------- + // return argument + for(j = 0; j < n; j++) + x_return[j] = x[j]; + + // tear down + thread_alloc::delete_array(a_x); + thread_alloc::delete_array(a_y); + thread_alloc::delete_array(x); + thread_alloc::delete_array(y); + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/CMakeLists.txt cppad-2019.02.00.0/speed/CMakeLists.txt --- cppad-2018.00.00.0/speed/CMakeLists.txt 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Initialize list of tests as empty @@ -20,17 +21,17 @@ ADD_SUBDIRECTORY(double) ADD_SUBDIRECTORY(example) IF ( cppad_profile_flag ) - ADD_SUBDIRECTORY(profile) + ADD_SUBDIRECTORY(profile) ENDIF ( cppad_profile_flag ) # IF( cppad_has_adolc ) - ADD_SUBDIRECTORY(adolc) + ADD_SUBDIRECTORY(adolc) ENDIF( cppad_has_adolc ) IF( cppad_has_fadbad ) - ADD_SUBDIRECTORY(fadbad) + ADD_SUBDIRECTORY(fadbad) ENDIF( cppad_has_fadbad ) IF( cppad_has_sacado ) - ADD_SUBDIRECTORY(sacado) + ADD_SUBDIRECTORY(sacado) ENDIF( cppad_has_sacado ) # check_speed diff -Nru cppad-2018.00.00.0/speed/cppad/CMakeLists.txt cppad-2019.02.00.0/speed/cppad/CMakeLists.txt --- cppad-2018.00.00.0/speed/cppad/CMakeLists.txt 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/cppad/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the speed/cppad directory tests # Inherit build type environment from ../CMakeList.txt @@ -23,16 +24,16 @@ # source1 source2 ... sourceN # ) SET(source_list ../main.cpp - det_lu.cpp - det_minor.cpp - mat_mul.cpp - ode.cpp - poly.cpp - sparse_hessian.cpp - sparse_jacobian.cpp + det_lu.cpp + det_minor.cpp + mat_mul.cpp + ode.cpp + poly.cpp + sparse_hessian.cpp + sparse_jacobian.cpp ) # 2DO: fix problem with the test -# ./speed_cppad sparse_hessian 123 colpack +# ./speed_cppad sparse_hessian 123 colpack # when speed_cppad is compiled for debugging. set_compile_flags( speed_cppad "${cppad_debug_which}" "${source_list}" ) # @@ -40,15 +41,15 @@ # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(speed_cppad - speed_src - ${cppad_lib} - ${colpack_libs} + speed_src + ${cppad_lib} + ${colpack_libs} ) # Add the check_speed_cppad target ADD_CUSTOM_TARGET(check_speed_cppad - speed_cppad correct 54321 - DEPENDS speed_cppad speed_src + speed_cppad correct 54321 + DEPENDS speed_cppad speed_src ) MESSAGE(STATUS "make check_speed_cppad: available") diff -Nru cppad-2018.00.00.0/speed/cppad/det_lu.cpp cppad-2019.02.00.0/speed/cppad/det_lu.cpp --- cppad-2018.00.00.0/speed/cppad/det_lu.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/cppad/det_lu.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,35 +1,35 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin cppad_det_lu.cpp$$ $spell - onetape - bool - CppAD - vector Vector - typedef - Lu - cppad - det - hpp - const - srand - var - std - cout - endl + onetape + bool + CppAD + vector Vector + typedef + Lu + cppad + det + hpp + const + srand + var + std + cout + endl $$ $section CppAD Speed: Gradient of Determinant Using Lu Factorization$$ -$mindex link_det_lu speed matrix factor$$ $head Specifications$$ @@ -44,75 +44,81 @@ // Note that CppAD uses global_option["memory"] at the main program level # include extern std::map global_option; +// see comments in main program for this external +extern size_t global_cppad_thread_alloc_inuse; bool link_det_lu( - size_t size , - size_t repeat , - CppAD::vector &matrix , - CppAD::vector &gradient ) -{ - // -------------------------------------------------------------------- - // check global options - const char* valid[] = { "memory", "optimize"}; - size_t n_valid = sizeof(valid) / sizeof(valid[0]); - typedef std::map::iterator iterator; - // - for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) - { if( itr->second ) - { bool ok = false; - for(size_t i = 0; i < n_valid; i++) - ok |= itr->first == valid[i]; - if( ! ok ) - return false; - } - } - // -------------------------------------------------------------------- - - // optimization options: no conditional skips or compare operators - std::string options="no_compare_op"; - // ----------------------------------------------------- - // setup - typedef CppAD::AD 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 - 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 - CppAD::vector w(1); - w[0] = 1.; - - // ------------------------------------------------------ - while(repeat--) - { // get the next matrix - CppAD::uniform_01(n, matrix); - for( i = 0; i < n; 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_option["optimize"] ) - f.optimize(options); - - // skip comparison operators - f.compare_change_count(0); - - // evaluate and return gradient using reverse mode - f.Forward(0, matrix); - gradient = f.Reverse(1, w); - } - return true; + size_t size , + size_t repeat , + CppAD::vector &matrix , + CppAD::vector &gradient ) +{ global_cppad_thread_alloc_inuse = 0; + + // -------------------------------------------------------------------- + // check global options + const char* valid[] = { "memory", "optimize"}; + size_t n_valid = sizeof(valid) / sizeof(valid[0]); + typedef std::map::iterator iterator; + // + for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) + { if( itr->second ) + { bool ok = false; + for(size_t i = 0; i < n_valid; i++) + ok |= itr->first == valid[i]; + if( ! ok ) + return false; + } + } + // -------------------------------------------------------------------- + // optimization options: + std::string optimize_options = + "no_conditional_skip no_compare_op no_print_for_op"; + // ----------------------------------------------------- + // setup + typedef CppAD::AD 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 + 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 + CppAD::vector w(1); + w[0] = 1.; + + // do not even record comparison operators + size_t abort_op_index = 0; + bool record_compare = false; + + // ------------------------------------------------------ + while(repeat--) + { // get the next matrix + CppAD::uniform_01(n, matrix); + for( i = 0; i < n; i++) + A[i] = matrix[i]; + + // declare independent variables + Independent(A, abort_op_index, record_compare); + + // AD computation of the determinant + detA[0] = Det(A); + + // create function object f : A -> detA + f.Dependent(A, detA); + if( global_option["optimize"] ) + f.optimize(optimize_options); + + // evaluate and return gradient using reverse mode + f.Forward(0, matrix); + gradient = f.Reverse(1, w); + } + size_t thread = CppAD::thread_alloc::thread_num(); + global_cppad_thread_alloc_inuse = CppAD::thread_alloc::inuse(thread); + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/cppad/det_minor.cpp cppad-2019.02.00.0/speed/cppad/det_minor.cpp --- cppad-2018.00.00.0/speed/cppad/det_minor.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/cppad/det_minor.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,36 +1,36 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin cppad_det_minor.cpp$$ $spell - onetape - vector Vector - typedef - cppad - Lu - CppAD - det - hpp - const - CPPAD_TESTVECTOR - bool - srand - var - std - cout - endl + onetape + vector Vector + typedef + cppad + Lu + CppAD + det + hpp + const + CPPAD_TESTVECTOR + bool + srand + var + std + cout + endl $$ $section CppAD Speed: Gradient of Determinant by Minor Expansion$$ -$mindex link_det_minor speed$$ $head Specifications$$ @@ -45,117 +45,126 @@ // Note that CppAD uses global_option["memory"] at the main program level # include extern std::map global_option; +// see comments in main program for this external +extern size_t global_cppad_thread_alloc_inuse; bool link_det_minor( - size_t size , - size_t repeat , - CppAD::vector &matrix , - CppAD::vector &gradient ) -{ - // -------------------------------------------------------------------- - // check global options - const char* valid[] = { "memory", "onetape", "optimize"}; - size_t n_valid = sizeof(valid) / sizeof(valid[0]); - typedef std::map::iterator iterator; - // - for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) - { if( itr->second ) - { bool ok = false; - for(size_t i = 0; i < n_valid; i++) - ok |= itr->first == valid[i]; - if( ! ok ) - return false; - } - } - // -------------------------------------------------------------------- - - // optimization options: no conditional skips or compare operators - std::string options="no_compare_op"; - // ----------------------------------------------------- - // setup - - // object for computing determinant - typedef CppAD::AD 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 - ADVector A(n); // AD domain space vector - ADVector detA(m); // AD range space vector - - // vectors of reverse mode weights - CppAD::vector w(1); - w[0] = 1.; - - // the AD function object - CppAD::ADFun f; - - // --------------------------------------------------------------------- - if( ! global_option["onetape"] ) while(repeat--) - { - // choose a matrix - 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_option["optimize"] ) - f.optimize(options); - - // 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); - } - else - { - // choose a matrix - 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_option["optimize"] ) - f.optimize(options); - - // 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); - } - } - return true; + size_t size , + size_t repeat , + CppAD::vector &matrix , + CppAD::vector &gradient ) +{ global_cppad_thread_alloc_inuse = 0; + + // -------------------------------------------------------------------- + // check global options + const char* valid[] = { "memory", "onetape", "optimize"}; + size_t n_valid = sizeof(valid) / sizeof(valid[0]); + typedef std::map::iterator iterator; + // + for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) + { if( itr->second ) + { bool ok = false; + for(size_t i = 0; i < n_valid; i++) + ok |= itr->first == valid[i]; + if( ! ok ) + return false; + } + } + // -------------------------------------------------------------------- + // optimization options: no conditional skips or compare operators + std::string optimize_options = + "no_conditional_skip no_compare_op no_print_for_op"; + // ----------------------------------------------------- + // setup + + // object for computing determinant + typedef CppAD::AD 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 + ADVector A(n); // AD domain space vector + ADVector detA(m); // AD range space vector + + // vectors of reverse mode weights + CppAD::vector w(1); + w[0] = 1.; + + // the AD function object + CppAD::ADFun f; + + // do not even record comparison operators + size_t abort_op_index = 0; + bool record_compare = false; + + // --------------------------------------------------------------------- + if( ! global_option["onetape"] ) while(repeat--) + { + // choose a matrix + CppAD::uniform_01(n, matrix); + for( i = 0; i < size * size; i++) + A[i] = matrix[i]; + + // declare independent variables + Independent(A, abort_op_index, record_compare); + + // AD computation of the determinant + detA[0] = Det(A); + + // create function object f : A -> detA + f.Dependent(A, detA); + + if( global_option["optimize"] ) + f.optimize(optimize_options); + + // 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); + } + else + { + // choose a matrix + CppAD::uniform_01(n, matrix); + for( i = 0; i < size * size; i++) + A[i] = matrix[i]; + + // declare independent variables + Independent(A, abort_op_index, record_compare); + + // AD computation of the determinant + detA[0] = Det(A); + + // create function object f : A -> detA + f.Dependent(A, detA); + + if( global_option["optimize"] ) + f.optimize(optimize_options); + + // 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); + } + } + size_t thread = CppAD::thread_alloc::thread_num(); + global_cppad_thread_alloc_inuse = CppAD::thread_alloc::inuse(thread); + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/cppad/makefile.am cppad-2019.02.00.0/speed/cppad/makefile.am --- cppad-2018.00.00.0/speed/cppad/makefile.am 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/cppad/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,13 @@ -# $Id: makefile.am 3779 2016-01-01 11:26:11Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory @@ -20,18 +20,20 @@ # check_PROGRAMS = speed_cppad # -AM_CPPFLAGS = -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # -# BEGIN OPTIMIZE -AM_CXXFLAGS = -O2 -DNDEBUG -DCPPAD_CPPAD_SPEED $(CXX_FLAGS) -# END OPTIMIZE -# -# BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) -DCPPAD_CPPAD_SPEED -# END DEBUG +AM_CXXFLAGS = \ + -DCPPAD_CPPAD_SPEED \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) # -LDADD = -lspeed -AM_LDFLAGS = -L../src +# +# directly address the library so works with windows +LDADD = ../src/libspeed.a +# +../src/libspeed.a: + (cd ../src; make libspeed.a) # speed_cppad_SOURCES = \ main.cpp \ diff -Nru cppad-2018.00.00.0/speed/cppad/makefile.in cppad-2019.02.00.0/speed/cppad/makefile.in --- cppad-2018.00.00.0/speed/cppad/makefile.in 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/cppad/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -103,7 +103,7 @@ sparse_jacobian.$(OBJEXT) speed_cppad_OBJECTS = $(am_speed_cppad_OBJECTS) speed_cppad_LDADD = $(LDADD) -speed_cppad_DEPENDENCIES = +speed_cppad_DEPENDENCIES = ../src/libspeed.a AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -186,8 +186,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp @@ -259,10 +257,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -281,9 +277,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -306,8 +304,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -328,33 +324,33 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3973 2017-08-30 13:38:26Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp # -AM_CPPFLAGS = -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # -# BEGIN OPTIMIZE -AM_CXXFLAGS = -O2 -DNDEBUG -DCPPAD_CPPAD_SPEED $(CXX_FLAGS) -# END OPTIMIZE +AM_CXXFLAGS = \ + -DCPPAD_CPPAD_SPEED \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + # -# BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) -DCPPAD_CPPAD_SPEED -# END DEBUG # -LDADD = -lspeed -AM_LDFLAGS = -L../src +# directly address the library so works with windows +LDADD = ../src/libspeed.a # speed_cppad_SOURCES = \ main.cpp \ @@ -647,6 +643,9 @@ main.cpp: cp $(srcdir)/../main.cpp main.cpp +# +../src/libspeed.a: + (cd ../src; make libspeed.a) test: check ./speed_cppad correct 123 diff -Nru cppad-2018.00.00.0/speed/cppad/mat_mul.cpp cppad-2019.02.00.0/speed/cppad/mat_mul.cpp --- cppad-2018.00.00.0/speed/cppad/mat_mul.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/cppad/mat_mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,37 +1,36 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin cppad_mat_mul.cpp$$ $spell - resize - nr - nc - cppad - mul - hpp - bool - onetape - sq - var - std::cout - endl - CppAD - dz - typedef - boolsparsity - enum + resize + nr + nc + cppad + mul + hpp + bool + onetape + sq + var + std::cout + endl + CppAD + dz + typedef + enum $$ $section CppAD Speed, Matrix Multiplication$$ -$mindex link_mat_mul multiply$$ $head Specifications$$ @@ -48,146 +47,153 @@ // Note that CppAD uses global_option["memory"] at the main program level # include extern std::map global_option; +// see comments in main program for this external +extern size_t global_cppad_thread_alloc_inuse; bool link_mat_mul( - size_t size , - size_t repeat , - CppAD::vector& x , - CppAD::vector& z , - CppAD::vector& dz + size_t size , + size_t repeat , + CppAD::vector& x , + CppAD::vector& z , + CppAD::vector& dz ) -{ - // -------------------------------------------------------------------- - // check global options - const char* valid[] = { "memory", "onetape", "optimize", "atomic"}; - size_t n_valid = sizeof(valid) / sizeof(valid[0]); - typedef std::map::iterator iterator; - // - for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) - { if( itr->second ) - { bool ok = false; - for(size_t i = 0; i < n_valid; i++) - ok |= itr->first == valid[i]; - if( ! ok ) - return false; - } - } - // -------------------------------------------------------------------- - // optimization options: no conditional skips or compare operators - std::string options="no_compare_op"; - // ----------------------------------------------------- - // setup - typedef CppAD::AD ADScalar; - typedef CppAD::vector ADVector; - - size_t j; // temporary index - size_t m = 1; // number of dependent variables - size_t n = size * size; // number of independent variables - ADVector X(n); // AD domain space vector - ADVector Y(n); // Store product matrix - ADVector Z(m); // AD range space vector - CppAD::ADFun f; // AD function object - - // vectors of reverse mode weights - CppAD::vector w(1); - w[0] = 1.; - - // user atomic information - CppAD::vector ax(3 + 2 * n), ay(n); - atomic_mat_mul atom_mul; - // - if( global_option["boolsparsity"] ) - atom_mul.option( CppAD::atomic_base::pack_sparsity_enum ); - else - atom_mul.option( CppAD::atomic_base::set_sparsity_enum ); - // ------------------------------------------------------ - if( ! global_option["onetape"] ) while(repeat--) - { // get the next matrix - CppAD::uniform_01(n, x); - for( j = 0; j < n; j++) - X[j] = x[j]; - - // declare independent variables - Independent(X); - - // do computations - if( ! global_option["atomic"] ) - mat_sum_sq(size, X, Y, Z); - else - { ax[0] = ADScalar( size ); // number of rows in left matrix - ax[1] = ADScalar( size ); // rows in left and columns in right - ax[2] = ADScalar( size ); // number of columns in right matrix - for(j = 0; j < n; j++) - { ax[3 + j] = X[j]; - ax[3 + n + j] = X[j]; - } - // Y = X * X - atom_mul(ax, ay); - 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_option["optimize"] ) - f.optimize(options); - - // 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); - } - else - { // get a next matrix - CppAD::uniform_01(n, x); - for(j = 0; j < n; j++) - X[j] = x[j]; - - // declare independent variables - Independent(X); - - // do computations - if( ! global_option["atomic"] ) - mat_sum_sq(size, X, Y, Z); - else - { for(j = 0; j < n; j++) - { ax[j] = X[j]; - ax[j+n] = X[j]; - } - // Y = X * X - atom_mul(ax, ay); - 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_option["optimize"] ) - f.optimize(options); - - // skip comparison operators - f.compare_change_count(0); - - while(repeat--) - { // get a next matrix - CppAD::uniform_01(n, x); - - // evaluate and return gradient using reverse mode - z = f.Forward(0, x); - dz = f.Reverse(1, w); - } - } - // -------------------------------------------------------------------- - // Free temporary work space (any future atomic_mat_mul constructors - // would create new temporary work space.) - CppAD::user_atomic::clear(); +{ global_cppad_thread_alloc_inuse = 0; + + // -------------------------------------------------------------------- + // check global options + const char* valid[] = { "memory", "onetape", "optimize", "atomic"}; + size_t n_valid = sizeof(valid) / sizeof(valid[0]); + typedef std::map::iterator iterator; + // + for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) + { if( itr->second ) + { bool ok = false; + for(size_t i = 0; i < n_valid; i++) + ok |= itr->first == valid[i]; + if( ! ok ) + return false; + } + } + // -------------------------------------------------------------------- + // optimization options: no conditional skips or compare operators + std::string optimize_options = + "no_conditional_skip no_compare_op no_print_for_op"; + // ----------------------------------------------------- + // setup + typedef CppAD::AD ADScalar; + typedef CppAD::vector ADVector; + + size_t j; // temporary index + size_t m = 1; // number of dependent variables + size_t n = size * size; // number of independent variables + ADVector X(n); // AD domain space vector + ADVector Y(n); // Store product matrix + ADVector Z(m); // AD range space vector + CppAD::ADFun f; // AD function object + + // vectors of reverse mode weights + CppAD::vector w(1); + w[0] = 1.; + + // atomic function information + CppAD::vector ax(3 + 2 * n), ay(n); + atomic_mat_mul atom_mul; + // + // do not even record comparison operators + size_t abort_op_index = 0; + bool record_compare = false; + + // ------------------------------------------------------ + if( ! global_option["onetape"] ) while(repeat--) + { // get the next matrix + CppAD::uniform_01(n, x); + for( j = 0; j < n; j++) + X[j] = x[j]; + + // declare independent variables + Independent(X, abort_op_index, record_compare); + + // do computations + if( ! global_option["atomic"] ) + mat_sum_sq(size, X, Y, Z); + else + { ax[0] = ADScalar( size ); // number of rows in left matrix + ax[1] = ADScalar( size ); // rows in left and columns in right + ax[2] = ADScalar( size ); // number of columns in right matrix + for(j = 0; j < n; j++) + { ax[3 + j] = X[j]; + ax[3 + n + j] = X[j]; + } + // Y = X * X + atom_mul(ax, ay); + 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_option["optimize"] ) + f.optimize(optimize_options); + + // 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); + } + else + { // get a next matrix + CppAD::uniform_01(n, x); + for(j = 0; j < n; j++) + X[j] = x[j]; + + // declare independent variables + Independent(X, abort_op_index, record_compare); + + // do computations + if( ! global_option["atomic"] ) + mat_sum_sq(size, X, Y, Z); + else + { for(j = 0; j < n; j++) + { ax[j] = X[j]; + ax[j+n] = X[j]; + } + // Y = X * X + atom_mul(ax, ay); + 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_option["optimize"] ) + f.optimize(optimize_options); + + // skip comparison operators + f.compare_change_count(0); + + while(repeat--) + { // get a next matrix + CppAD::uniform_01(n, x); + + // evaluate and return gradient using reverse mode + z = f.Forward(0, x); + dz = f.Reverse(1, w); + } + } + size_t thread = CppAD::thread_alloc::thread_num(); + global_cppad_thread_alloc_inuse = CppAD::thread_alloc::inuse(thread); + // -------------------------------------------------------------------- + // Free temporary work space (any future atomic_mat_mul constructors + // would create new temporary work space.) + CppAD::user_atomic::clear(); + // -------------------------------------------------------------------- - return true; + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/cppad/ode.cpp cppad-2019.02.00.0/speed/cppad/ode.cpp --- cppad-2018.00.00.0/speed/cppad/ode.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/cppad/ode.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,34 +1,34 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin cppad_ode.cpp$$ $spell - jacobian jacobian - endif - var - Jacobian - std - cout - endl - CppAD - cppad - hpp - bool - onetape - typedef - cassert + jacobian jacobian + endif + var + Jacobian + std + cout + endl + CppAD + cppad + hpp + bool + onetape + typedef + cassert $$ $section CppAD Speed: Gradient of Ode Solution$$ -$mindex link_ode speed$$ $head Specifications$$ @@ -45,101 +45,111 @@ // Note that CppAD uses global_option["memory"] at the main program level # include extern std::map global_option; +// see comments in main program for this external +extern size_t global_cppad_thread_alloc_inuse; bool link_ode( - size_t size , - size_t repeat , - CppAD::vector &x , - CppAD::vector &jacobian + size_t size , + size_t repeat , + CppAD::vector &x , + CppAD::vector &jacobian ) -{ - // -------------------------------------------------------------------- - // check global options - const char* valid[] = { "memory", "onetape", "optimize"}; - size_t n_valid = sizeof(valid) / sizeof(valid[0]); - typedef std::map::iterator iterator; - // - for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) - { if( itr->second ) - { bool ok = false; - for(size_t i = 0; i < n_valid; i++) - ok |= itr->first == valid[i]; - if( ! ok ) - return false; - } - } - // -------------------------------------------------------------------- - // optimization options: no conditional skips or compare operators - std::string options="no_compare_op"; - // -------------------------------------------------------------------- - // setup - assert( x.size() == size ); - assert( jacobian.size() == size * size ); - - typedef CppAD::AD ADScalar; - typedef CppAD::vector ADVector; - - size_t j; - size_t p = 0; // use ode to calculate function values - size_t n = size; // number of independent variables - size_t m = n; // number of dependent variables - ADVector X(n), Y(m); // independent and dependent variables - CppAD::ADFun f; // AD function - - // ------------------------------------------------------------- - if( ! global_option["onetape"] ) while(repeat--) - { // choose next x value - uniform_01(n, x); - for(j = 0; j < n; j++) - X[j] = x[j]; - - // declare the independent variable vector - Independent(X); - - // evaluate function - CppAD::ode_evaluate(X, p, Y); - - // create function object f : X -> Y - f.Dependent(X, Y); - - if( global_option["optimize"] ) - f.optimize(options); - - // skip comparison operators - f.compare_change_count(0); - - jacobian = f.Jacobian(x); - } - else - { // an x value - uniform_01(n, x); - for(j = 0; j < n; j++) - X[j] = x[j]; - - // declare the independent variable vector - Independent(X); - - // evaluate function - CppAD::ode_evaluate(X, p, Y); - - // create function object f : X -> Y - f.Dependent(X, Y); - - if( global_option["optimize"] ) - f.optimize(options); - - // skip comparison operators - f.compare_change_count(0); - - while(repeat--) - { // get next argument value - uniform_01(n, x); - - // evaluate jacobian - jacobian = f.Jacobian(x); - } - } - return true; +{ global_cppad_thread_alloc_inuse = 0; + + // -------------------------------------------------------------------- + // check global options + const char* valid[] = { "memory", "onetape", "optimize"}; + size_t n_valid = sizeof(valid) / sizeof(valid[0]); + typedef std::map::iterator iterator; + // + for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) + { if( itr->second ) + { bool ok = false; + for(size_t i = 0; i < n_valid; i++) + ok |= itr->first == valid[i]; + if( ! ok ) + return false; + } + } + // -------------------------------------------------------------------- + // optimization options: no conditional skips or compare operators + std::string optimize_options = + "no_conditional_skip no_compare_op no_print_for_op"; + // -------------------------------------------------------------------- + // setup + assert( x.size() == size ); + assert( jacobian.size() == size * size ); + + typedef CppAD::AD ADScalar; + typedef CppAD::vector ADVector; + + size_t j; + size_t p = 0; // use ode to calculate function values + size_t n = size; // number of independent variables + size_t m = n; // number of dependent variables + ADVector X(n), Y(m); // independent and dependent variables + CppAD::ADFun f; // AD function + + // do not even record comparison operators + size_t abort_op_index = 0; + bool record_compare = false; + + // ------------------------------------------------------------- + if( ! global_option["onetape"] ) while(repeat--) + { // choose next x value + uniform_01(n, x); + for(j = 0; j < n; j++) + X[j] = x[j]; + + // declare independent variables + Independent(X, abort_op_index, record_compare); + + // evaluate function + CppAD::ode_evaluate(X, p, Y); + + // create function object f : X -> Y + f.Dependent(X, Y); + + if( global_option["optimize"] ) + f.optimize(optimize_options); + + // skip comparison operators + f.compare_change_count(0); + + jacobian = f.Jacobian(x); + } + else + { // an x value + uniform_01(n, x); + for(j = 0; j < n; j++) + X[j] = x[j]; + + // declare the independent variable vector + Independent(X, abort_op_index, record_compare); + + // evaluate function + CppAD::ode_evaluate(X, p, Y); + + // create function object f : X -> Y + f.Dependent(X, Y); + + if( global_option["optimize"] ) + f.optimize(optimize_options); + + // skip comparison operators + f.compare_change_count(0); + + while(repeat--) + { // get next argument value + uniform_01(n, x); + + // evaluate jacobian + jacobian = f.Jacobian(x); + } + } + size_t thread = CppAD::thread_alloc::thread_num(); + global_cppad_thread_alloc_inuse = CppAD::thread_alloc::inuse(thread); + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/cppad/poly.cpp cppad-2019.02.00.0/speed/cppad/poly.cpp --- cppad-2018.00.00.0/speed/cppad/poly.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/cppad/poly.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,41 +1,41 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin cppad_poly.cpp$$ $spell - onetape - coef - ddp - ADScalar - dz - ddz - Taylor - vector Vector - typedef - cppad - Lu - CppAD - det - hpp - const - CPPAD_TESTVECTOR - bool - var - std - cout - endl + onetape + coef + ddp + ADScalar + dz + ddz + Taylor + vector Vector + typedef + cppad + Lu + CppAD + det + hpp + const + CPPAD_TESTVECTOR + bool + var + std + cout + endl $$ $section CppAD Speed: Second Derivative of a Polynomial$$ -$mindex link_poly speed$$ $head Specifications$$ @@ -50,133 +50,143 @@ // Note that CppAD uses global_option["memory"] at the main program level # include extern std::map global_option; +// see comments in main program for this external +extern size_t global_cppad_thread_alloc_inuse; bool link_poly( - 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 -{ - // -------------------------------------------------------------------- - // check global options - const char* valid[] = { "memory", "onetape", "optimize"}; - size_t n_valid = sizeof(valid) / sizeof(valid[0]); - typedef std::map::iterator iterator; - // - for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) - { if( itr->second ) - { bool ok = false; - for(size_t i = 0; i < n_valid; i++) - ok |= itr->first == valid[i]; - if( ! ok ) - return false; - } - } - // -------------------------------------------------------------------- - // optimization options: no conditional skips or compare operators - std::string options="no_compare_op"; - // ----------------------------------------------------- - // setup - typedef CppAD::AD ADScalar; - typedef CppAD::vector ADVector; - - size_t i; // temporary index - size_t m = 1; // number of dependent variables - size_t n = 1; // number of independent variables - ADVector Z(n); // AD domain space vector - ADVector P(m); // AD range space vector - - // choose the polynomial coefficients - CppAD::uniform_01(size, a); - - // AD copy of the polynomial coefficients - ADVector A(size); - for(i = 0; i < size; i++) - A[i] = a[i]; - - // forward mode first and second differentials - CppAD::vector p(1), dp(1), dz(1), ddz(1); - dz[0] = 1.; - ddz[0] = 0.; - - // AD function object - CppAD::ADFun f; - - // -------------------------------------------------------------------- - if( ! global_option["onetape"] ) while(repeat--) - { - // choose an argument value - CppAD::uniform_01(1, z); - Z[0] = z[0]; - - // declare independent variables - Independent(Z); - - // AD computation of the function value - P[0] = CppAD::Poly(0, A, Z[0]); - - // create function object f : A -> detA - f.Dependent(Z, P); - - if( global_option["optimize"] ) - f.optimize(options); - - // skip comparison operators - f.compare_change_count(0); - - // pre-allocate memory for three forward mode calculations - f.capacity_order(3); - - // evaluate the polynomial - p = f.Forward(0, z); - - // evaluate first order Taylor coefficient - dp = f.Forward(1, dz); - - // second derivative is twice second order Taylor coef - ddp = f.Forward(2, ddz); - ddp[0] *= 2.; - } - else - { - // choose an argument value - CppAD::uniform_01(1, z); - Z[0] = z[0]; - - // declare independent variables - Independent(Z); - - // AD computation of the function value - P[0] = CppAD::Poly(0, A, Z[0]); - - // create function object f : A -> detA - f.Dependent(Z, P); - - if( global_option["optimize"] ) - f.optimize(options); - - // skip comparison operators - f.compare_change_count(0); - - while(repeat--) - { // sufficient memory is allocated by second repetition - - // get the next argument value - CppAD::uniform_01(1, z); - - // evaluate the polynomial at the new argument value - p = f.Forward(0, z); - - // evaluate first order Taylor coefficient - dp = f.Forward(1, dz); - - // second derivative is twice second order Taylor coef - ddp = f.Forward(2, ddz); - ddp[0] *= 2.; - } - } - return true; + 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 +{ global_cppad_thread_alloc_inuse = 0; + + // -------------------------------------------------------------------- + // check global options + const char* valid[] = { "memory", "onetape", "optimize"}; + size_t n_valid = sizeof(valid) / sizeof(valid[0]); + typedef std::map::iterator iterator; + // + for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) + { if( itr->second ) + { bool ok = false; + for(size_t i = 0; i < n_valid; i++) + ok |= itr->first == valid[i]; + if( ! ok ) + return false; + } + } + // -------------------------------------------------------------------- + // optimization options: no conditional skips or compare operators + std::string optimize_options = + "no_conditional_skip no_compare_op no_print_for_op"; + // ----------------------------------------------------- + // setup + typedef CppAD::AD ADScalar; + typedef CppAD::vector ADVector; + + size_t i; // temporary index + size_t m = 1; // number of dependent variables + size_t n = 1; // number of independent variables + ADVector Z(n); // AD domain space vector + ADVector P(m); // AD range space vector + + // choose the polynomial coefficients + CppAD::uniform_01(size, a); + + // AD copy of the polynomial coefficients + ADVector A(size); + for(i = 0; i < size; i++) + A[i] = a[i]; + + // forward mode first and second differentials + CppAD::vector p(1), dp(1), dz(1), ddz(1); + dz[0] = 1.; + ddz[0] = 0.; + + // AD function object + CppAD::ADFun f; + + // do not even record comparison operators + size_t abort_op_index = 0; + bool record_compare = false; + + // -------------------------------------------------------------------- + if( ! global_option["onetape"] ) while(repeat--) + { + // choose an argument value + CppAD::uniform_01(1, z); + Z[0] = z[0]; + + // declare independent variables + Independent(Z, abort_op_index, record_compare); + + // AD computation of the function value + P[0] = CppAD::Poly(0, A, Z[0]); + + // create function object f : A -> detA + f.Dependent(Z, P); + + if( global_option["optimize"] ) + f.optimize(optimize_options); + + // skip comparison operators + f.compare_change_count(0); + + // pre-allocate memory for three forward mode calculations + f.capacity_order(3); + + // evaluate the polynomial + p = f.Forward(0, z); + + // evaluate first order Taylor coefficient + dp = f.Forward(1, dz); + + // second derivative is twice second order Taylor coef + ddp = f.Forward(2, ddz); + ddp[0] *= 2.; + } + else + { + // choose an argument value + CppAD::uniform_01(1, z); + Z[0] = z[0]; + + // declare independent variables + Independent(Z, abort_op_index, record_compare); + + // AD computation of the function value + P[0] = CppAD::Poly(0, A, Z[0]); + + // create function object f : A -> detA + f.Dependent(Z, P); + + if( global_option["optimize"] ) + f.optimize(optimize_options); + + // skip comparison operators + f.compare_change_count(0); + + while(repeat--) + { // sufficient memory is allocated by second repetition + + // get the next argument value + CppAD::uniform_01(1, z); + + // evaluate the polynomial at the new argument value + p = f.Forward(0, z); + + // evaluate first order Taylor coefficient + dp = f.Forward(1, dz); + + // second derivative is twice second order Taylor coef + ddp = f.Forward(2, ddz); + ddp[0] *= 2.; + } + } + size_t thread = CppAD::thread_alloc::thread_num(); + global_cppad_thread_alloc_inuse = CppAD::thread_alloc::inuse(thread); + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/cppad/sparse_hessian.cpp cppad-2019.02.00.0/speed/cppad/sparse_hessian.cpp --- cppad-2018.00.00.0/speed/cppad/sparse_hessian.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/cppad/sparse_hessian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,40 +1,40 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin cppad_sparse_hessian.cpp$$ $spell - ifdef - ifndef - colpack - boolsparsity - namespace - Jac - onetape - const - hes - CppAD - cppad - hpp - bool - typedef - endif - tmp - std - var - cout - endl + ifdef + ifndef + colpack + boolsparsity + namespace + Jac + onetape + const + hes + CppAD + cppad + hpp + bool + typedef + endif + tmp + std + var + cout + endl $$ $section CppAD Speed: Sparse Hessian$$ -$mindex link_sparse_hessian speed$$ $head Specifications$$ @@ -50,337 +50,355 @@ // Note that CppAD uses global_option["memory"] at the main program level # include extern std::map global_option; +// see comments in main program for this external +extern size_t global_cppad_thread_alloc_inuse; namespace { - // typedefs - using CppAD::vector; - typedef CppAD::AD a1double; - typedef CppAD::AD a2double; - typedef vector b_vector; - typedef vector s_vector; - typedef vector d_vector; - typedef vector a1vector; - typedef vector a2vector; - typedef CppAD::sparse_rc sparsity_pattern; - typedef CppAD::sparse_rcv sparse_matrix; - // ------------------------------------------------------------------------ - void create_fun( - const d_vector& x , - const s_vector& row , - const s_vector& col , - CppAD::ADFun& fun ) - { - // initialize a1double version of independent variables - size_t n = x.size(); - a1vector a1x(n); - for(size_t j = 0; j < n; j++) - a1x[j] = x[j]; - // - // optimization options - std::string optimize_options="no_compare_op"; - // - // order of derivative in sparse_hes_fun - size_t order = 0; - // - if( ! global_option["hes2jac"] ) - { - // declare independent variables - Independent(a1x); - // - // AD computation of y - a1vector a1y(1); - CppAD::sparse_hes_fun(n, a1x, row, col, order, a1y); - // - // create function object f : X -> Y - fun.Dependent(a1x, a1y); - // - if( global_option["optimize"] ) - fun.optimize(optimize_options); - // - // skip comparison operators - fun.compare_change_count(0); - // - // fun corresonds to f(x) - return; - } - // declare independent variables for f(x) - a2vector a2x(n); - for(size_t j = 0; j < n; j++) - a2x[j] = a1x[j]; - Independent(a2x); - // - // a2double computation of y - a2vector a2y(1); - CppAD::sparse_hes_fun(n, a2x, row, col, order, a2y); - // - // create function object corresponding to y = f(x) - CppAD::ADFun a1f; - a1f.Dependent(a2x, a2y); - // - // declare independent variables for g(x) - Independent(a1x); - // - // a1double computation of z - a1vector a1w(1), a1z(n); - a1w[0] = 1.0; - a1f.Forward(0, a1x); - a1z = a1f.Reverse(1, a1w); - // - // create function object z = g(x) = f'(x) - fun.Dependent(a1x, a1z); - // - if( global_option["optimize"] ) - fun.optimize(optimize_options); - // - // skip comparison operators - fun.compare_change_count(0); - // - // fun corresonds to g(x) - return; - } - // ------------------------------------------------------------------------ - void calc_sparsity( - sparsity_pattern& sparsity , - CppAD::ADFun& fun ) - { - size_t n = fun.Domain(); - size_t m = fun.Range(); - // - bool transpose = false; - // - if( global_option["subsparsity"] ) - { CPPAD_ASSERT_UNKNOWN( global_option["hes2jac"] ) - CPPAD_ASSERT_UNKNOWN( n == m ); - b_vector select_domain(n), select_range(m); - for(size_t j = 0; j < n; ++j) - select_domain[j] = true; - for(size_t i = 0; i < m; ++i) - select_range[i] = true; - // - // fun corresponds to g(x) - fun.subgraph_sparsity( - select_domain, select_range, transpose, sparsity - ); - return; - } - bool dependency = false; - bool reverse = global_option["revsparsity"]; - bool internal_bool = global_option["boolsparsity"]; - // - if( ! global_option["hes2jac"] ) - { // fun corresponds to f(x) - // - CPPAD_ASSERT_UNKNOWN( m == 1 ); - // - b_vector select_range(m); - select_range[0] = true; - // - if( reverse ) - { sparsity_pattern identity; - identity.resize(n, n, n); - for(size_t k = 0; k < n; k++) - identity.set(k, k, k); - fun.for_jac_sparsity( - identity, transpose, dependency, internal_bool, sparsity - ); - fun.rev_hes_sparsity( - select_range, transpose, internal_bool, sparsity - ); - } - else - { b_vector select_domain(n); - for(size_t j = 0; j < n; j++) - select_domain[j] = true; - fun.for_hes_sparsity( - select_domain, select_range, internal_bool, sparsity - ); - } - return; - } - // fun correspnds to g(x) - CPPAD_ASSERT_UNKNOWN( m == n ); - // - // sparsity pattern for identity matrix - sparsity_pattern eye; - eye.resize(n, n, n); - for(size_t k = 0; k < n; k++) - eye.set(k, k, k); - // - if( reverse ) - { fun.rev_jac_sparsity( - eye, transpose, dependency, internal_bool, sparsity - ); - } - else - { fun.for_jac_sparsity( - eye, transpose, dependency, internal_bool, sparsity - ); - } - return; - } - // ------------------------------------------------------------------------ - size_t calc_hessian( - d_vector& hessian , - const d_vector& x , - sparse_matrix& subset , - const sparsity_pattern& sparsity , - CppAD::sparse_jac_work& jac_work , - CppAD::sparse_hes_work& hes_work , - CppAD::ADFun& fun ) - { size_t n_sweep; - // - if( ! global_option["hes2jac"] ) - { // fun corresponds to f(x) - // - // coloring method - std::string coloring = "cppad.symmetric"; -# if CPPAD_HAS_COLPACK - if( global_option["colpack"] ) - coloring = "colpack.symmetric"; -# endif - // only one function component - d_vector w(1); - w[0] = 1.0; - // - // compute hessian - n_sweep = fun.sparse_hes( - x, w, subset, sparsity, coloring, hes_work - ); - } - else - { // fun corresponds to g(x) - // - if( global_option["subgraph"] ) - { fun.subgraph_jac_rev(x, subset); - n_sweep = 0; - } - else - { - // - // coloring method - std::string coloring = "cppad"; + // typedefs + using CppAD::vector; + typedef CppAD::AD a1double; + typedef CppAD::AD a2double; + typedef vector b_vector; + typedef vector s_vector; + typedef vector d_vector; + typedef vector a1vector; + typedef vector a2vector; + typedef CppAD::sparse_rc sparsity_pattern; + typedef CppAD::sparse_rcv sparse_matrix; + // ------------------------------------------------------------------------ + void create_fun( + const d_vector& x , + const s_vector& row , + const s_vector& col , + CppAD::ADFun& fun ) + { + // initialize a1double version of independent variables + size_t n = x.size(); + a1vector a1x(n); + for(size_t j = 0; j < n; j++) + a1x[j] = x[j]; + // + // optimization options + std::string optimize_options = + "no_conditional_skip no_compare_op no_print_for_op"; + // + // order of derivative in sparse_hes_fun + size_t order = 0; + // + // do not even record comparison operators + size_t abort_op_index = 0; + bool record_compare = false; + // + if( ! global_option["hes2jac"] ) + { + // declare independent variables + Independent(a1x, abort_op_index, record_compare); + // + // AD computation of y + a1vector a1y(1); + CppAD::sparse_hes_fun(n, a1x, row, col, order, a1y); + // + // create function object f : X -> Y + fun.Dependent(a1x, a1y); + // + if( global_option["optimize"] ) + fun.optimize(optimize_options); + // + // skip comparison operators + fun.compare_change_count(0); + // + // fun corresonds to f(x) + return; + } + // declare independent variables for f(x) + a2vector a2x(n); + for(size_t j = 0; j < n; j++) + a2x[j] = a1x[j]; + Independent(a2x, abort_op_index, record_compare); + // + // a2double computation of y + a2vector a2y(1); + CppAD::sparse_hes_fun(n, a2x, row, col, order, a2y); + // + // create function object corresponding to y = f(x) + CppAD::ADFun a1f; + a1f.Dependent(a2x, a2y); + // + // declare independent variables for g(x) + Independent(a1x, abort_op_index, record_compare); + // + // a1double computation of z + a1vector a1w(1), a1z(n); + a1w[0] = 1.0; + a1f.Forward(0, a1x); + a1z = a1f.Reverse(1, a1w); + // + // create function object z = g(x) = f'(x) + fun.Dependent(a1x, a1z); + // + if( global_option["optimize"] ) + fun.optimize(optimize_options); + // + // skip comparison operators + fun.compare_change_count(0); + // + // fun corresonds to g(x) + return; + } + // ------------------------------------------------------------------------ + void calc_sparsity( + sparsity_pattern& sparsity , + CppAD::ADFun& fun ) + { + size_t n = fun.Domain(); + size_t m = fun.Range(); + // + bool transpose = false; + // + if( global_option["subsparsity"] ) + { CPPAD_ASSERT_UNKNOWN( global_option["hes2jac"] ) + CPPAD_ASSERT_UNKNOWN( n == m ); + b_vector select_domain(n), select_range(m); + for(size_t j = 0; j < n; ++j) + select_domain[j] = true; + for(size_t i = 0; i < m; ++i) + select_range[i] = true; + // + // fun corresponds to g(x) + fun.subgraph_sparsity( + select_domain, select_range, transpose, sparsity + ); + return; + } + bool dependency = false; + bool reverse = global_option["revsparsity"]; + bool internal_bool = global_option["boolsparsity"]; + // + if( ! global_option["hes2jac"] ) + { // fun corresponds to f(x) + // + CPPAD_ASSERT_UNKNOWN( m == 1 ); + // + b_vector select_range(m); + select_range[0] = true; + // + if( reverse ) + { sparsity_pattern identity; + identity.resize(n, n, n); + for(size_t k = 0; k < n; k++) + identity.set(k, k, k); + fun.for_jac_sparsity( + identity, transpose, dependency, internal_bool, sparsity + ); + fun.rev_hes_sparsity( + select_range, transpose, internal_bool, sparsity + ); + } + else + { b_vector select_domain(n); + for(size_t j = 0; j < n; j++) + select_domain[j] = true; + fun.for_hes_sparsity( + select_domain, select_range, internal_bool, sparsity + ); + } + return; + } + // fun correspnds to g(x) + CPPAD_ASSERT_UNKNOWN( m == n ); + // + // sparsity pattern for identity matrix + sparsity_pattern eye; + eye.resize(n, n, n); + for(size_t k = 0; k < n; k++) + eye.set(k, k, k); + // + if( reverse ) + { fun.rev_jac_sparsity( + eye, transpose, dependency, internal_bool, sparsity + ); + } + else + { fun.for_jac_sparsity( + eye, transpose, dependency, internal_bool, sparsity + ); + } + return; + } + // ------------------------------------------------------------------------ + size_t calc_hessian( + d_vector& hessian , + const d_vector& x , + sparse_matrix& subset , + const sparsity_pattern& sparsity , + CppAD::sparse_jac_work& jac_work , + CppAD::sparse_hes_work& hes_work , + CppAD::ADFun& fun ) + { size_t n_sweep; + // + if( ! global_option["hes2jac"] ) + { // fun corresponds to f(x) + // + // coloring method + std::string coloring = "cppad"; + if( global_option["colpack"] ) + coloring = "colpack"; + if( global_option["symmetric"] ) + coloring += ".symmetric"; + else + coloring += ".general"; + // + // only one function component + d_vector w(1); + w[0] = 1.0; + // + // compute hessian + n_sweep = fun.sparse_hes( + x, w, subset, sparsity, coloring, hes_work + ); + } + else + { // fun corresponds to g(x) + // + if( global_option["subgraph"] ) + { fun.subgraph_jac_rev(x, subset); + n_sweep = 0; + } + else + { + // + // coloring method + std::string coloring = "cppad"; # if CPPAD_HAS_COLPACK - if( global_option["colpack"] ) - coloring = "colpack"; + if( global_option["colpack"] ) + coloring = "colpack"; # endif - size_t group_max = 1; - n_sweep = fun.sparse_jac_for( - group_max, x, subset, sparsity, coloring, jac_work - ); - } - } - // return result - const d_vector& val( subset.val() ); - size_t nnz = subset.nnz(); - for(size_t k = 0; k < nnz; k++) - hessian[k] = val[k]; - // - return n_sweep; - } + size_t group_max = 1; + n_sweep = fun.sparse_jac_for( + group_max, x, subset, sparsity, coloring, jac_work + ); + } + } + // return result + const d_vector& val( subset.val() ); + size_t nnz = subset.nnz(); + for(size_t k = 0; k < nnz; k++) + hessian[k] = val[k]; + // + return n_sweep; + } } bool link_sparse_hessian( - size_t size , - size_t repeat , - const CppAD::vector& row , - const CppAD::vector& col , - CppAD::vector& x , - CppAD::vector& hessian , - size_t& n_sweep ) -{ - // -------------------------------------------------------------------- - // check global options - const char* valid[] = { - "memory", "onetape", "optimize", "hes2jac", "subgraph", + size_t size , + size_t repeat , + const CppAD::vector& row , + const CppAD::vector& col , + CppAD::vector& x , + CppAD::vector& hessian , + size_t& n_sweep ) +{ global_cppad_thread_alloc_inuse = 0; + + // -------------------------------------------------------------------- + // check global options + const char* valid[] = { + "memory", "onetape", "optimize", "hes2jac", "subgraph", + "boolsparsity", "revsparsity", "symmetric" # if CPPAD_HAS_COLPACK - "boolsparsity", "revsparsity", "subsparsity", "colpack" + , "colpack" # else - "boolsparsity", "revsparsity" + , "subsparsity" +# endif + }; + size_t n_valid = sizeof(valid) / sizeof(valid[0]); + typedef std::map::iterator iterator; + // + for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) + { if( itr->second ) + { bool ok = false; + for(size_t i = 0; i < n_valid; i++) + ok |= itr->first == valid[i]; + if( ! ok ) + return false; + } + } + if( global_option["subsparsity"] ) + { if( global_option["boolsparsity"] || global_option["revsparsity"] ) + return false; + if( ! global_option["hes2jac"] ) + return false; + } + if( global_option["subgraph"] ) + { if( ! global_option["hes2jac"] ) + return false; + } +# if ! CPPAD_HAS_COLPACK + if( global_option["colpack"] ) + return false; # endif - }; - size_t n_valid = sizeof(valid) / sizeof(valid[0]); - typedef std::map::iterator iterator; - // - for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) - { if( itr->second ) - { bool ok = false; - for(size_t i = 0; i < n_valid; i++) - ok |= itr->first == valid[i]; - if( ! ok ) - return false; - } - } - if( global_option["subsparsity"] ) - { if( global_option["boolsparsity"] || global_option["revsparsity"] ) - return false; - if( ! global_option["hes2jac"] ) - return false; - } - if( global_option["subgraph"] ) - { if( ! global_option["hes2jac"] ) - return false; - } - // ----------------------------------------------------------------------- - // setup - size_t n = size; // number of independent variables - CppAD::ADFun fun; // AD function object used to calculate Hessian - // - // declare sparsity pattern - sparsity_pattern sparsity; - // - // declare subset where Hessian is evaluated - sparsity_pattern subset_pattern; - size_t nr = n; - size_t nc = n; - size_t nnz = row.size(); - subset_pattern.resize(nr, nc, nnz); - for(size_t k = 0; k < nnz; k++) - subset_pattern.set(k, row[k], col[k]); - sparse_matrix subset( subset_pattern ); - // - // structures that holds some of the work done by sparse_jac, sparse_hes - CppAD::sparse_jac_work jac_work; - CppAD::sparse_hes_work hes_work; - - // ----------------------------------------------------------------------- - if( ! global_option["onetape"] ) while(repeat--) - { // choose a value for x - CppAD::uniform_01(n, x); - // - // create f(x) - create_fun(x, row, col, fun); - // - // calculate the sparsity pattern for Hessian of f(x) - calc_sparsity(sparsity, fun); - // - // calculate the Hessian at this x - jac_work.clear(); // wihtout work from previous calculation - hes_work.clear(); - n_sweep = calc_hessian( - hessian, x, subset, sparsity, jac_work, hes_work, fun - ); - } - else - { // choose a value for x - CppAD::uniform_01(n, x); - // - // create f(x) - create_fun(x, row, col, fun); - // - // calculate the sparsity pattern for Hessian of f(x) - calc_sparsity(sparsity, fun); - // - while(repeat--) - { // choose a value for x - CppAD::uniform_01(n, x); - // - // calculate this Hessian at this x - n_sweep = calc_hessian( - hessian, x, subset, sparsity, jac_work, hes_work, fun - ); - } - } - return true; + // ----------------------------------------------------------------------- + // setup + size_t n = size; // number of independent variables + CppAD::ADFun fun; // AD function object used to calculate Hessian + // + // declare sparsity pattern + sparsity_pattern sparsity; + // + // declare subset where Hessian is evaluated + sparsity_pattern subset_pattern; + size_t nr = n; + size_t nc = n; + size_t nnz = row.size(); + subset_pattern.resize(nr, nc, nnz); + for(size_t k = 0; k < nnz; k++) + subset_pattern.set(k, row[k], col[k]); + sparse_matrix subset( subset_pattern ); + // + // structures that holds some of the work done by sparse_jac, sparse_hes + CppAD::sparse_jac_work jac_work; + CppAD::sparse_hes_work hes_work; + + // ----------------------------------------------------------------------- + if( ! global_option["onetape"] ) while(repeat--) + { // choose a value for x + CppAD::uniform_01(n, x); + // + // create f(x) + create_fun(x, row, col, fun); + // + // calculate the sparsity pattern for Hessian of f(x) + calc_sparsity(sparsity, fun); + // + // calculate the Hessian at this x + jac_work.clear(); // wihtout work from previous calculation + hes_work.clear(); + n_sweep = calc_hessian( + hessian, x, subset, sparsity, jac_work, hes_work, fun + ); + } + else + { // choose a value for x + CppAD::uniform_01(n, x); + // + // create f(x) + create_fun(x, row, col, fun); + // + // calculate the sparsity pattern for Hessian of f(x) + calc_sparsity(sparsity, fun); + // + while(repeat--) + { // choose a value for x + CppAD::uniform_01(n, x); + // + // calculate this Hessian at this x + n_sweep = calc_hessian( + hessian, x, subset, sparsity, jac_work, hes_work, fun + ); + } + } + size_t thread = CppAD::thread_alloc::thread_num(); + global_cppad_thread_alloc_inuse = CppAD::thread_alloc::inuse(thread); + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/cppad/sparse_jacobian.cpp cppad-2019.02.00.0/speed/cppad/sparse_jacobian.cpp --- cppad-2018.00.00.0/speed/cppad/sparse_jacobian.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/cppad/sparse_jacobian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,42 +1,42 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin cppad_sparse_jacobian.cpp$$ $spell - const - ifdef - ifndef - colpack - boolsparsity - namespace - onetape - work work - jac - CppAD - cppad - hpp - bool - typedef - endif - tmp - std - var - cout - endl - Jacobian - Fp + const + ifdef + ifndef + colpack + boolsparsity + namespace + onetape + work work + jac + CppAD + cppad + hpp + bool + typedef + endif + tmp + std + var + cout + endl + Jacobian + Fp $$ $section CppAD Speed: Sparse Jacobian$$ -$mindex link_sparse_jacobian speed$$ $head Specifications$$ @@ -52,221 +52,233 @@ // Note that CppAD uses global_option["memory"] at the main program level # include extern std::map global_option; +// see comments in main program for this external +extern size_t global_cppad_thread_alloc_inuse; namespace { - using CppAD::vector; - typedef vector s_vector; - typedef vector b_vector; - - void calc_sparsity( - CppAD::sparse_rc& sparsity , - CppAD::ADFun& f ) - { bool reverse = global_option["revsparsity"]; - bool transpose = false; - bool internal_bool = global_option["boolsparsity"]; - bool dependency = false; - bool subgraph = global_option["subsparsity"]; - size_t n = f.Domain(); - size_t m = f.Range(); - if( subgraph ) - { b_vector select_domain(n), select_range(m); - for(size_t j = 0; j < n; ++j) - select_domain[j] = true; - for(size_t i = 0; i < m; ++i) - select_range[i] = true; - f.subgraph_sparsity( - select_domain, select_range, transpose, sparsity - ); - } - else - { size_t q = n; - if( reverse ) - q = m; - // - CppAD::sparse_rc identity; - identity.resize(q, q, q); - for(size_t k = 0; k < q; k++) - identity.set(k, k, k); - // - if( reverse ) - { f.rev_jac_sparsity( - identity, transpose, dependency, internal_bool, sparsity - ); - } - else - { f.for_jac_sparsity( - identity, transpose, dependency, internal_bool, sparsity - ); - } - } - } + using CppAD::vector; + typedef vector s_vector; + typedef vector b_vector; + + void calc_sparsity( + CppAD::sparse_rc& sparsity , + CppAD::ADFun& f ) + { bool reverse = global_option["revsparsity"]; + bool transpose = false; + bool internal_bool = global_option["boolsparsity"]; + bool dependency = false; + bool subgraph = global_option["subsparsity"]; + size_t n = f.Domain(); + size_t m = f.Range(); + if( subgraph ) + { b_vector select_domain(n), select_range(m); + for(size_t j = 0; j < n; ++j) + select_domain[j] = true; + for(size_t i = 0; i < m; ++i) + select_range[i] = true; + f.subgraph_sparsity( + select_domain, select_range, transpose, sparsity + ); + } + else + { size_t q = n; + if( reverse ) + q = m; + // + CppAD::sparse_rc identity; + identity.resize(q, q, q); + for(size_t k = 0; k < q; k++) + identity.set(k, k, k); + // + if( reverse ) + { f.rev_jac_sparsity( + identity, transpose, dependency, internal_bool, sparsity + ); + } + else + { f.for_jac_sparsity( + identity, transpose, dependency, internal_bool, sparsity + ); + } + } + } } bool link_sparse_jacobian( - size_t size , - size_t repeat , - size_t m , - const CppAD::vector& row , - const CppAD::vector& col , - CppAD::vector& x , - CppAD::vector& jacobian , - size_t& n_sweep ) -{ - // -------------------------------------------------------------------- - // check global options - const char* valid[] = { - "memory", "onetape", "optimize", "subgraph", + size_t size , + size_t repeat , + size_t m , + const CppAD::vector& row , + const CppAD::vector& col , + CppAD::vector& x , + CppAD::vector& jacobian , + size_t& n_sweep ) +{ global_cppad_thread_alloc_inuse = 0; + + // -------------------------------------------------------------------- + // check global options + const char* valid[] = { + "memory", "onetape", "optimize", "subgraph", + "boolsparsity", "revsparsity", "subsparsity" # if CPPAD_HAS_COLPACK - "boolsparsity", "revsparsity", "subsparsity", "colpack" -# else - "boolsparsity", "revsparsity", "subsparsity" + , "colpack" # endif - }; - size_t n_valid = sizeof(valid) / sizeof(valid[0]); - typedef std::map::iterator iterator; - // - for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) - { if( itr->second ) - { bool ok = false; - for(size_t i = 0; i < n_valid; i++) - ok |= itr->first == valid[i]; - if( ! ok ) - return false; - } - } - if( global_option["subsparsity"] ) - { if( global_option["boolsparisty"] || global_option["revsparsity"] ) - return false; - } - // --------------------------------------------------------------------- - // optimization options: no conditional skips or compare operators - std::string options="no_compare_op"; - // ----------------------------------------------------- - // setup - typedef CppAD::AD a_double; - typedef vector d_vector; - typedef vector ad_vector; - // - size_t order = 0; // derivative order corresponding to function - size_t n = size; // number of independent variables - ad_vector a_x(n); // AD domain space vector - ad_vector a_y(m); // AD range space vector y = f(x) - CppAD::ADFun f; // AD function object - // - // declare sparsity pattern - CppAD::sparse_rc sparsity; - // - // declare subset where Jacobian is evaluated - CppAD::sparse_rc subset_pattern; - size_t nr = m; - size_t nc = n; - size_t nnz = row.size(); - subset_pattern.resize(nr, nc, nnz); - for(size_t k = 0; k < nnz; k++) - subset_pattern.set(k, row[k], col[k]); - CppAD::sparse_rcv subset( subset_pattern ); - const d_vector& subset_val( subset.val() ); - // - // coloring method - std::string coloring = "cppad"; + }; + size_t n_valid = sizeof(valid) / sizeof(valid[0]); + typedef std::map::iterator iterator; + // + for(iterator itr=global_option.begin(); itr!=global_option.end(); ++itr) + { if( itr->second ) + { bool ok = false; + for(size_t i = 0; i < n_valid; i++) + ok |= itr->first == valid[i]; + if( ! ok ) + return false; + } + } + if( global_option["subsparsity"] ) + { if( global_option["boolsparisty"] + || global_option["revsparsity"] + || global_option["colpack"] ) + return false; + } + // --------------------------------------------------------------------- + // optimization options: no conditional skips or compare operators + std::string optimize_options = + "no_conditional_skip no_compare_op no_print_for_op"; + // ----------------------------------------------------- + // setup + typedef CppAD::AD a_double; + typedef vector d_vector; + typedef vector ad_vector; + // + size_t order = 0; // derivative order corresponding to function + size_t n = size; // number of independent variables + ad_vector a_x(n); // AD domain space vector + ad_vector a_y(m); // AD range space vector y = f(x) + CppAD::ADFun f; // AD function object + // + // declare sparsity pattern + CppAD::sparse_rc sparsity; + // + // declare subset where Jacobian is evaluated + CppAD::sparse_rc subset_pattern; + size_t nr = m; + size_t nc = n; + size_t nnz = row.size(); + subset_pattern.resize(nr, nc, nnz); + for(size_t k = 0; k < nnz; k++) + subset_pattern.set(k, row[k], col[k]); + CppAD::sparse_rcv subset( subset_pattern ); + const d_vector& subset_val( subset.val() ); + // + // coloring method + std::string coloring = "cppad"; # if CPPAD_HAS_COLPACK - if( global_option["colpack"] ) - coloring = "colpack"; + if( global_option["colpack"] ) + coloring = "colpack"; # endif - // - // maximum number of colors at once - size_t group_max = 25; - // ------------------------------------------------------ - if( ! global_option["onetape"] ) while(repeat--) - { // choose a value for x - CppAD::uniform_01(n, x); - for(size_t j = 0; j < n; j++) - a_x[j] = x[j]; - // - // declare independent variables - Independent(a_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 - f.Dependent(a_x, a_y); - // - if( global_option["optimize"] ) - f.optimize(options); - // - // skip comparison operators - f.compare_change_count(0); - // - // calculate the Jacobian sparsity pattern for this function - calc_sparsity(sparsity, f); - // - if( global_option["subgraph"] ) - { // user reverse mode becasue forward not yet implemented - f.subgraph_jac_rev(x, subset); - n_sweep = 0; - } - else - { // structure that holds some of the work done by sparse_jac_for - CppAD::sparse_jac_work work; - // - // calculate the Jacobian at this x - // (use forward mode because m > n ?) - n_sweep = f.sparse_jac_for( - group_max, x, subset, sparsity, coloring, work - ); - } - for(size_t k = 0; k < nnz; k++) - jacobian[k] = subset_val[k]; - } - else - { // choose a value for x - CppAD::uniform_01(n, x); - for(size_t j = 0; j < n; j++) - a_x[j] = x[j]; - // - // declare independent variables - Independent(a_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 - f.Dependent(a_x, a_y); - // - if( global_option["optimize"] ) - f.optimize(options); - // - // skip comparison operators - f.compare_change_count(0); - // - // calculate the Jacobian sparsity pattern for this function - calc_sparsity(sparsity, f); - // - // structure that holds some of the work done by sparse_jac_for - CppAD::sparse_jac_work work; - // - while(repeat--) - { // choose a value for x - CppAD::uniform_01(n, x); - // - // calculate the Jacobian at this x - if( global_option["subgraph"] ) - { // user reverse mode becasue forward not yet implemented - f.subgraph_jac_rev(x, subset); - n_sweep = 0; - } - else - { // (use forward mode because m > n ?) - n_sweep = f.sparse_jac_for( - group_max, x, subset, sparsity, coloring, work - ); - } - for(size_t k = 0; k < nnz; k++) - jacobian[k] = subset_val[k]; - } - } - return true; + // + // maximum number of colors at once + // + // do not even record comparison operators + size_t abort_op_index = 0; + bool record_compare = false; + // + size_t group_max = 25; + // ------------------------------------------------------ + if( ! global_option["onetape"] ) while(repeat--) + { // choose a value for x + CppAD::uniform_01(n, x); + for(size_t j = 0; j < n; j++) + a_x[j] = x[j]; + + // declare independent variables + Independent(a_x, abort_op_index, record_compare); + // + // AD computation of f(x) + CppAD::sparse_jac_fun(m, n, a_x, row, col, order, a_y); + // + // create function object f : X -> Y + f.Dependent(a_x, a_y); + // + if( global_option["optimize"] ) + f.optimize(optimize_options); + // + // skip comparison operators + f.compare_change_count(0); + // + // calculate the Jacobian sparsity pattern for this function + calc_sparsity(sparsity, f); + // + if( global_option["subgraph"] ) + { // user reverse mode becasue forward not yet implemented + f.subgraph_jac_rev(x, subset); + n_sweep = 0; + } + else + { // structure that holds some of the work done by sparse_jac_for + CppAD::sparse_jac_work work; + // + // calculate the Jacobian at this x + // (use forward mode because m > n ?) + n_sweep = f.sparse_jac_for( + group_max, x, subset, sparsity, coloring, work + ); + } + for(size_t k = 0; k < nnz; k++) + jacobian[k] = subset_val[k]; + } + else + { // choose a value for x + CppAD::uniform_01(n, x); + for(size_t j = 0; j < n; j++) + a_x[j] = x[j]; + // + // declare independent variables + Independent(a_x, abort_op_index, record_compare); + // + // AD computation of f(x) + CppAD::sparse_jac_fun(m, n, a_x, row, col, order, a_y); + // + // create function object f : X -> Y + f.Dependent(a_x, a_y); + // + if( global_option["optimize"] ) + f.optimize(optimize_options); + // + // skip comparison operators + f.compare_change_count(0); + // + // calculate the Jacobian sparsity pattern for this function + calc_sparsity(sparsity, f); + // + // structure that holds some of the work done by sparse_jac_for + CppAD::sparse_jac_work work; + // + while(repeat--) + { // choose a value for x + CppAD::uniform_01(n, x); + // + // calculate the Jacobian at this x + if( global_option["subgraph"] ) + { // user reverse mode becasue forward not yet implemented + f.subgraph_jac_rev(x, subset); + n_sweep = 0; + } + else + { // (use forward mode because m > n ?) + n_sweep = f.sparse_jac_for( + group_max, x, subset, sparsity, coloring, work + ); + } + for(size_t k = 0; k < nnz; k++) + jacobian[k] = subset_val[k]; + } + } + size_t thread = CppAD::thread_alloc::thread_num(); + global_cppad_thread_alloc_inuse = CppAD::thread_alloc::inuse(thread); + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/double/CMakeLists.txt cppad-2019.02.00.0/speed/double/CMakeLists.txt --- cppad-2018.00.00.0/speed/double/CMakeLists.txt 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/double/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the speed/double directory tests # Inherit build type environment from ../CMakeList.txt @@ -23,13 +24,13 @@ # source1 source2 ... sourceN # ) SET(source_list ../main.cpp - det_lu.cpp - det_minor.cpp - mat_mul.cpp - ode.cpp - poly.cpp - sparse_hessian.cpp - sparse_jacobian.cpp + det_lu.cpp + det_minor.cpp + mat_mul.cpp + ode.cpp + poly.cpp + sparse_hessian.cpp + sparse_jacobian.cpp ) set_compile_flags( speed_double "${cppad_debug_which}" "${source_list}" ) # @@ -41,8 +42,8 @@ # Add the check_speed_double target ADD_CUSTOM_TARGET(check_speed_double - speed_double correct 54321 - DEPENDS speed_double speed_src + speed_double correct 54321 + DEPENDS speed_double speed_src ) MESSAGE(STATUS "make check_speed_double: available") diff -Nru cppad-2018.00.00.0/speed/double/det_lu.cpp cppad-2019.02.00.0/speed/double/det_lu.cpp --- cppad-2018.00.00.0/speed/double/det_lu.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/double/det_lu.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,27 @@ -// $Id: det_lu.cpp 3794 2016-02-29 20:42:44Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin double_det_lu.cpp$$ $spell - onetape - bool - cppad - hpp - Lu - det - CppAD + onetape + bool + cppad + hpp + Lu + det + CppAD $$ $section Double Speed: Determinant Using Lu Factorization$$ -$mindex link_det_lu speed matrix factor$$ $head Specifications$$ @@ -39,28 +38,28 @@ extern std::map global_option; bool link_det_lu( - size_t size , - size_t repeat , - CppAD::vector &matrix , - CppAD::vector &det ) + size_t size , + size_t repeat , + CppAD::vector &matrix , + CppAD::vector &det ) { - if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]) - return false; - // ----------------------------------------------------- - // setup - CppAD::det_by_lu Det(size); - size_t n = size * size; // number of independent variables - - // ------------------------------------------------------ - - while(repeat--) - { // get the next matrix - CppAD::uniform_01(n, matrix); - - // computation of the determinant - det[0] = Det(matrix); - } - return true; + if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]) + return false; + // ----------------------------------------------------- + // setup + CppAD::det_by_lu Det(size); + size_t n = size * size; // number of independent variables + + // ------------------------------------------------------ + + while(repeat--) + { // get the next matrix + CppAD::uniform_01(n, matrix); + + // computation of the determinant + det[0] = Det(matrix); + } + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/double/det_minor.cpp cppad-2019.02.00.0/speed/double/det_minor.cpp --- cppad-2018.00.00.0/speed/double/det_minor.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/double/det_minor.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,27 @@ -// $Id: det_minor.cpp 3794 2016-02-29 20:42:44Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin double_det_minor.cpp$$ $spell - onetape - retape - bool - cppad - det - CppAD - hpp + onetape + retape + bool + cppad + det + CppAD + hpp $$ $section Double Speed: Determinant by Minor Expansion$$ -$mindex link_det_minor speed$$ $head Specifications$$ @@ -40,27 +39,27 @@ extern std::map global_option; bool link_det_minor( - size_t size , - size_t repeat , - CppAD::vector &matrix , - CppAD::vector &det ) + size_t size , + size_t repeat , + CppAD::vector &matrix , + CppAD::vector &det ) { - if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]) - return false; - // ----------------------------------------------------- - // setup - CppAD::det_by_minor Det(size); - size_t n = size * size; // number of independent variables - - // ------------------------------------------------------ - while(repeat--) - { // get the next matrix - CppAD::uniform_01(n, matrix); - - // computation of the determinant - det[0] = Det(matrix); - } - return true; + if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]) + return false; + // ----------------------------------------------------- + // setup + CppAD::det_by_minor Det(size); + size_t n = size * size; // number of independent variables + + // ------------------------------------------------------ + while(repeat--) + { // get the next matrix + CppAD::uniform_01(n, matrix); + + // computation of the determinant + det[0] = Det(matrix); + } + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/double/makefile.am cppad-2019.02.00.0/speed/double/makefile.am --- cppad-2018.00.00.0/speed/double/makefile.am 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/double/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,13 @@ -# $Id: makefile.am 3779 2016-01-01 11:26:11Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory @@ -20,18 +20,19 @@ # check_PROGRAMS = speed_double # -AM_CPPFLAGS = -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # -# BEGIN OPTIMIZE -AM_CXXFLAGS = -O2 -DNDEBUG -DCPPAD_DOUBLE_SPEED $(CXX_FLAGS) -# END OPTIMIZE -# -# BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) -DCPPAD_DOUBLE_SPEED -# END DEBUG +AM_CXXFLAGS = \ + -DCPPAD_DOUBLE_SPEED \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) # -LDADD = -lspeed -AM_LDFLAGS = -L../src +# +LDADD = ../src/libspeed.a +# +../src/libspeed.a: + (cd ../src; make libspeed.a) # speed_double_SOURCES = \ main.cpp \ diff -Nru cppad-2018.00.00.0/speed/double/makefile.in cppad-2019.02.00.0/speed/double/makefile.in --- cppad-2018.00.00.0/speed/double/makefile.in 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/double/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -103,7 +103,7 @@ sparse_jacobian.$(OBJEXT) speed_double_OBJECTS = $(am_speed_double_OBJECTS) speed_double_LDADD = $(LDADD) -speed_double_DEPENDENCIES = +speed_double_DEPENDENCIES = ../src/libspeed.a AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -186,8 +186,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp @@ -259,10 +257,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -281,9 +277,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -306,8 +304,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -328,33 +324,32 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3973 2017-08-30 13:38:26Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp # -AM_CPPFLAGS = -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # -# BEGIN OPTIMIZE -AM_CXXFLAGS = -O2 -DNDEBUG -DCPPAD_DOUBLE_SPEED $(CXX_FLAGS) -# END OPTIMIZE +AM_CXXFLAGS = \ + -DCPPAD_DOUBLE_SPEED \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + # -# BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) -DCPPAD_DOUBLE_SPEED -# END DEBUG # -LDADD = -lspeed -AM_LDFLAGS = -L../src +LDADD = ../src/libspeed.a # speed_double_SOURCES = \ main.cpp \ @@ -647,6 +642,9 @@ main.cpp: cp $(srcdir)/../main.cpp main.cpp +# +../src/libspeed.a: + (cd ../src; make libspeed.a) test: check ./speed_double correct 123 diff -Nru cppad-2018.00.00.0/speed/double/mat_mul.cpp cppad-2019.02.00.0/speed/double/mat_mul.cpp --- cppad-2018.00.00.0/speed/double/mat_mul.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/double/mat_mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,30 +1,29 @@ -// $Id: mat_mul.cpp 3794 2016-02-29 20:42:44Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin double_mat_mul.cpp$$ $spell - onetape - CppAD - cppad - mul_mat - hpp - sq - bool - dz - typedef + onetape + CppAD + cppad + mul_mat + hpp + sq + bool + dz + typedef $$ $section CppAD Speed: Matrix Multiplication (Double Version)$$ -$mindex speed multiply link_mat_mul$$ $head Specifications$$ @@ -41,28 +40,28 @@ extern std::map global_option; bool link_mat_mul( - size_t size , - size_t repeat , - CppAD::vector& x , - CppAD::vector& z , - CppAD::vector& dz + size_t size , + size_t repeat , + CppAD::vector& x , + CppAD::vector& z , + CppAD::vector& dz ) { - if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]) - return false; - // ----------------------------------------------------- - size_t n = size * size; // number of independent variables - CppAD::vector y(n); - - while(repeat--) - { // get the next matrix - CppAD::uniform_01(n, x); + if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]) + return false; + // ----------------------------------------------------- + size_t n = size * size; // number of independent variables + CppAD::vector y(n); + + while(repeat--) + { // get the next matrix + CppAD::uniform_01(n, x); - // do computation - mat_sum_sq(size, x, y, z); + // do computation + mat_sum_sq(size, x, y, z); - } - return true; + } + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/double/ode.cpp cppad-2019.02.00.0/speed/double/ode.cpp --- cppad-2018.00.00.0/speed/double/ode.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/double/ode.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,31 +1,30 @@ -// $Id: ode.cpp 3794 2016-02-29 20:42:44Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin double_ode.cpp$$ $spell - onetape - Jacobian - CppAD - cppad - hpp - bool - cstring - retape - resize - endif + onetape + Jacobian + CppAD + cppad + hpp + bool + cstring + retape + resize + endif $$ $section Double Speed: Ode Solution$$ -$mindex link_ode speed$$ $head Specifications$$ @@ -44,35 +43,35 @@ extern std::map global_option; bool link_ode( - size_t size , - size_t repeat , - CppAD::vector &x , - CppAD::vector &jacobian + size_t size , + size_t repeat , + CppAD::vector &x , + CppAD::vector &jacobian ) { - if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]) - return false; - // ------------------------------------------------------------- - // setup - assert( x.size() == size ); - - size_t n = size; - - size_t m = 0; - CppAD::vector f(n); - - while(repeat--) - { // choose next x value - uniform_01(n, x); - - // evaluate function - CppAD::ode_evaluate(x, m, f); - - } - size_t i; - for(i = 0; i < n; i++) - jacobian[i] = f[i]; - return true; + if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]) + return false; + // ------------------------------------------------------------- + // setup + assert( x.size() == size ); + + size_t n = size; + + size_t m = 0; + CppAD::vector f(n); + + while(repeat--) + { // choose next x value + uniform_01(n, x); + + // evaluate function + CppAD::ode_evaluate(x, m, f); + + } + size_t i; + for(i = 0; i < n; i++) + jacobian[i] = f[i]; + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/double/poly.cpp cppad-2019.02.00.0/speed/double/poly.cpp --- cppad-2018.00.00.0/speed/double/poly.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/double/poly.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,26 @@ -// $Id: poly.cpp 3794 2016-02-29 20:42:44Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin double_poly.cpp$$ $spell - onetape - retape - bool - cppad - CppAD - hpp + onetape + retape + bool + cppad + CppAD + hpp $$ $section Double Speed: Evaluate a Polynomial$$ -$mindex link_poly speed$$ @@ -39,26 +38,26 @@ extern std::map global_option; bool link_poly( - 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 + 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 { - if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]) - return false; - // ----------------------------------------------------- - // setup - - // ------------------------------------------------------ - while(repeat--) - { // get the next argument value - CppAD::uniform_01(1, z); - - // evaluate the polynomial at the new argument value - p[0] = CppAD::Poly(0, a, z[0]); - } - return true; + if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]) + return false; + // ----------------------------------------------------- + // setup + + // ------------------------------------------------------ + while(repeat--) + { // get the next argument value + CppAD::uniform_01(1, z); + + // evaluate the polynomial at the new argument value + p[0] = CppAD::Poly(0, a, z[0]); + } + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/double/sparse_hessian.cpp cppad-2019.02.00.0/speed/double/sparse_hessian.cpp --- cppad-2018.00.00.0/speed/double/sparse_hessian.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/double/sparse_hessian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,28 @@ -// $Id: sparse_hessian.cpp 3794 2016-02-29 20:42:44Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin double_sparse_hessian.cpp$$ $spell - onetape - boolsparsity - const - hes - bool - cppad - hpp - CppAD + onetape + boolsparsity + const + hes + bool + cppad + hpp + CppAD $$ $section Double Speed: Sparse Hessian$$ -$mindex link_sparse_hessian speed$$ $head Specifications$$ @@ -41,37 +40,37 @@ extern std::map global_option; bool link_sparse_hessian( - size_t size , - size_t repeat , - const CppAD::vector& row , - const CppAD::vector& col , - CppAD::vector& x , - CppAD::vector& hessian , - size_t& n_sweep ) + size_t size , + size_t repeat , + const CppAD::vector& row , + const CppAD::vector& col , + CppAD::vector& x , + CppAD::vector& hessian , + size_t& n_sweep ) { - if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]||global_option["boolsparsity"]) - return false; - // ----------------------------------------------------- - // setup - 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 - vector y(m); // function value - - // choose a value for x - CppAD::uniform_01(n, x); - - // ------------------------------------------------------ - - while(repeat--) - { - // computation of the function - CppAD::sparse_hes_fun(n, x, row, col, order, y); - } - hessian[0] = y[0]; + if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]||global_option["boolsparsity"]) + return false; + // ----------------------------------------------------- + // setup + 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 + vector y(m); // function value + + // choose a value for x + CppAD::uniform_01(n, x); + + // ------------------------------------------------------ + + while(repeat--) + { + // computation of the function + CppAD::sparse_hes_fun(n, x, row, col, order, y); + } + hessian[0] = y[0]; - return true; + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/double/sparse_jacobian.cpp cppad-2019.02.00.0/speed/double/sparse_jacobian.cpp --- cppad-2018.00.00.0/speed/double/sparse_jacobian.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/double/sparse_jacobian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,35 +1,34 @@ -// $Id: sparse_jacobian.cpp 3794 2016-02-29 20:42:44Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin double_sparse_jacobian.cpp$$ $spell - const - onetape - boolsparsity - yp - jac - Jacobian - fp - bool - cppad - hpp - CppAD - cmath - exp - std + const + onetape + boolsparsity + yp + jac + Jacobian + fp + bool + cppad + hpp + CppAD + cmath + exp + std $$ $section Double Speed: Sparse Jacobian$$ -$mindex link_sparse_jacobian speed$$ $head Specifications$$ @@ -47,37 +46,37 @@ extern std::map global_option; bool link_sparse_jacobian( - size_t size , - size_t repeat , - size_t m , - const CppAD::vector& row , - const CppAD::vector& col , - CppAD::vector& x , - CppAD::vector& jacobian , - size_t& n_sweep ) + size_t size , + size_t repeat , + size_t m , + const CppAD::vector& row , + const CppAD::vector& col , + CppAD::vector& x , + CppAD::vector& jacobian , + size_t& n_sweep ) { - if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]||global_option["boolsparsity"]) - return false; - // ----------------------------------------------------- - // setup - using CppAD::vector; - size_t i; - size_t order = 0; // order for computing function value - size_t n = size; // argument space dimension - vector yp(m); // function value yp = f(x) - - // ------------------------------------------------------ - 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); - } - for(i = 0; i < m; i++) - jacobian[i] = yp[i]; + if(global_option["onetape"]||global_option["atomic"]||global_option["optimize"]||global_option["boolsparsity"]) + return false; + // ----------------------------------------------------- + // setup + using CppAD::vector; + size_t i; + size_t order = 0; // order for computing function value + size_t n = size; // argument space dimension + vector yp(m); // function value yp = f(x) + + // ------------------------------------------------------ + 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); + } + for(i = 0; i < m; i++) + jacobian[i] = yp[i]; - return true; + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/example/CMakeLists.txt cppad-2019.02.00.0/speed/example/CMakeLists.txt --- cppad-2018.00.00.0/speed/example/CMakeLists.txt 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the speed/cppad directory tests # Inherit build type from ../CMakeList.txt @@ -17,17 +18,17 @@ # We do not add ../src/speed_src library to avoid undefined externals. # Instead we build our own copy of ../src/microsoft_timer.cpp. SET(source_list example.cpp - det_by_lu.cpp - det_by_minor.cpp - det_of_minor.cpp - elapsed_seconds.cpp - mat_sum_sq.cpp - ode_evaluate.cpp - sparse_hes_fun.cpp - sparse_jac_fun.cpp - speed_test.cpp - time_test.cpp - "../src/microsoft_timer.cpp" + det_by_lu.cpp + det_by_minor.cpp + det_of_minor.cpp + elapsed_seconds.cpp + mat_sum_sq.cpp + ode_evaluate.cpp + sparse_hes_fun.cpp + sparse_jac_fun.cpp + speed_test.cpp + time_test.cpp + "../src/microsoft_timer.cpp" ) set_compile_flags( speed_example "${cppad_debug_which}" "${source_list}" ) # @@ -35,8 +36,8 @@ # Add the check_speed_example target ADD_CUSTOM_TARGET(check_speed_example - speed_example - DEPENDS speed_example speed_src + speed_example + DEPENDS speed_example speed_src ) MESSAGE(STATUS "make check_speed_example: available") diff -Nru cppad-2018.00.00.0/speed/example/det_by_lu.cpp cppad-2019.02.00.0/speed/example/det_by_lu.cpp --- cppad-2018.00.00.0/speed/example/det_by_lu.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/det_by_lu.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,25 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin det_by_lu.cpp$$ $spell - Cpp - Lu + Cpp + Lu $$ $section Determinant Using Lu Factorization: Example and Test$$ -$mindex minors$$ -$code $srcfile%speed/example/det_by_lu.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,37 +29,37 @@ # include bool det_by_lu() -{ bool ok = true; - double eps99 = 99.0 * std::numeric_limits::epsilon(); +{ bool ok = true; + double eps99 = 99.0 * std::numeric_limits::epsilon(); - // dimension of the matrix - size_t n = 3; + // dimension of the matrix + size_t n = 3; - // construct the determinat object - CppAD::det_by_lu Det(n); + // construct the determinat object + CppAD::det_by_lu Det(n); - double a[] = { - 1., 2., 3., // a[0] a[1] a[2] - 3., 2., 1., // a[3] a[4] a[5] - 2., 1., 2. // a[6] a[7] a[8] - }; - CPPAD_TESTVECTOR(double) A(9); - size_t i; - for(i = 0; i < 9; i++) - A[i] = a[i]; + double a[] = { + 1., 2., 3., // a[0] a[1] a[2] + 3., 2., 1., // a[3] a[4] a[5] + 2., 1., 2. // a[6] a[7] a[8] + }; + CPPAD_TESTVECTOR(double) A(9); + size_t i; + for(i = 0; i < 9; i++) + A[i] = a[i]; - // evaluate the determinant - double det = Det(A); + // evaluate the determinant + double det = Det(A); - double check; - check = a[0]*(a[4]*a[8] - a[5]*a[7]) - - a[1]*(a[3]*a[8] - a[5]*a[6]) - + a[2]*(a[3]*a[7] - a[4]*a[6]); + double check; + check = a[0]*(a[4]*a[8] - a[5]*a[7]) + - a[1]*(a[3]*a[8] - a[5]*a[6]) + + a[2]*(a[3]*a[7] - a[4]*a[6]); - ok = CppAD::NearEqual(det, check, eps99, eps99); + ok = CppAD::NearEqual(det, check, eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/speed/example/det_by_minor.cpp cppad-2019.02.00.0/speed/example/det_by_minor.cpp --- cppad-2018.00.00.0/speed/example/det_by_minor.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/det_by_minor.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,24 @@ -// $Id: det_by_minor.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin det_by_minor.cpp$$ $spell - Cpp + Cpp $$ $section Determinant Using Expansion by Minors: Example and Test$$ -$mindex minors$$ -$code $srcfile%speed/example/det_by_minor.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,36 +28,36 @@ # include bool det_by_minor() -{ bool ok = true; +{ bool ok = true; - // dimension of the matrix - size_t n = 3; + // dimension of the matrix + size_t n = 3; - // construct the determinat object - CppAD::det_by_minor Det(n); + // construct the determinat object + CppAD::det_by_minor Det(n); - double a[] = { - 1., 2., 3., // a[0] a[1] a[2] - 3., 2., 1., // a[3] a[4] a[5] - 2., 1., 2. // a[6] a[7] a[8] - }; - CPPAD_TESTVECTOR(double) A(9); - size_t i; - for(i = 0; i < 9; i++) - A[i] = a[i]; + double a[] = { + 1., 2., 3., // a[0] a[1] a[2] + 3., 2., 1., // a[3] a[4] a[5] + 2., 1., 2. // a[6] a[7] a[8] + }; + CPPAD_TESTVECTOR(double) A(9); + size_t i; + for(i = 0; i < 9; i++) + A[i] = a[i]; - // evaluate the determinant - double det = Det(A); + // evaluate the determinant + double det = Det(A); - double check; - check = a[0]*(a[4]*a[8] - a[5]*a[7]) - - a[1]*(a[3]*a[8] - a[5]*a[6]) - + a[2]*(a[3]*a[7] - a[4]*a[6]); + double check; + check = a[0]*(a[4]*a[8] - a[5]*a[7]) + - a[1]*(a[3]*a[8] - a[5]*a[6]) + + a[2]*(a[3]*a[7] - a[4]*a[6]); - ok = det == check; + ok = det == check; - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/speed/example/det_of_minor.cpp cppad-2019.02.00.0/speed/example/det_of_minor.cpp --- cppad-2018.00.00.0/speed/example/det_of_minor.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/det_of_minor.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,26 @@ -// $Id: det_of_minor.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin det_of_minor.cpp$$ $spell - det - Cpp + det + Cpp $$ $section Determinant of a Minor: Example and Test$$ -$mindex det_of_minor$$ -$code $srcfile%speed/example/det_of_minor.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -33,46 +30,46 @@ # include bool det_of_minor() -{ bool ok = true; - size_t i; +{ bool ok = true; + size_t i; - // dimension of the matrix A - size_t m = 3; - // index vectors set so minor is the entire matrix A - std::vector r(m + 1); - std::vector c(m + 1); - 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., - 2., 1., 2. - }; - // construct vector a with the values of the matrix A - std::vector a(data, data + 9); - - // evaluate the determinant of A - size_t n = m; // minor has same dimension as A - double det = CppAD::det_of_minor(a, m, n, r, c); - - // check the value of the determinant of A - ok &= (det == (double) (1*(2*2-1*1) - 2*(3*2-1*2) + 3*(3*1-2*2)) ); - - // 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 - n = m - 1; // dimension of the minor - det = CppAD::det_of_minor(a, m, m-1, r, c); + // dimension of the matrix A + size_t m = 3; + // index vectors set so minor is the entire matrix A + std::vector r(m + 1); + std::vector c(m + 1); + 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., + 2., 1., 2. + }; + // construct vector a with the values of the matrix A + std::vector a(data, data + 9); + + // evaluate the determinant of A + size_t n = m; // minor has same dimension as A + double det = CppAD::det_of_minor(a, m, n, r, c); + + // check the value of the determinant of A + ok &= (det == (double) (1*(2*2-1*1) - 2*(3*2-1*2) + 3*(3*1-2*2)) ); + + // 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 + n = m - 1; // dimension of the minor + det = CppAD::det_of_minor(a, m, m-1, r, c); - // check the value of the determinant of the minor - ok &= (det == (double) (3*2-1*2) ); + // check the value of the determinant of the minor + ok &= (det == (double) (3*2-1*2) ); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/speed/example/elapsed_seconds.cpp cppad-2019.02.00.0/speed/example/elapsed_seconds.cpp --- cppad-2018.00.00.0/speed/example/elapsed_seconds.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/elapsed_seconds.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,29 +1,26 @@ -// $Id: elapsed_seconds.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin elapsed_seconds.cpp$$ $spell - Cpp - Lu + Cpp + Lu $$ $section Elapsed Seconds: Example and Test$$ -$mindex seconds timer$$ -$code $srcfile%speed/example/elapsed_seconds.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -37,23 +34,23 @@ # define CPPAD_DEBUG_ELAPSED_SECONDS 0 bool elapsed_seconds(void) -{ bool ok = true; +{ bool ok = true; - double max_diff = 0.; - double s0 = CppAD::elapsed_seconds(); - double s1 = CppAD::elapsed_seconds(); - double s2 = CppAD::elapsed_seconds(); - while(s2 - s0 < 1.) - { max_diff = std::max(s2 - s1, max_diff); - s1 = s2; - s2 = CppAD::elapsed_seconds(); + double max_diff = 0.; + double s0 = CppAD::elapsed_seconds(); + double s1 = CppAD::elapsed_seconds(); + double s2 = CppAD::elapsed_seconds(); + while(s2 - s0 < 1.) + { max_diff = std::max(s2 - s1, max_diff); + s1 = s2; + s2 = CppAD::elapsed_seconds(); - } + } # if CPPAD_DEBUG_ELAPSED_SECONDS - std::cout << "max_diff = " << max_diff << std::endl; + std::cout << "max_diff = " << max_diff << std::endl; # endif - ok &= 0. < max_diff && max_diff < .04; - return ok; + ok &= 0. < max_diff && max_diff < .04; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/speed/example/example.cpp cppad-2019.02.00.0/speed/example/example.cpp --- cppad-2018.00.00.0/speed/example/example.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/example.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,14 +1,14 @@ -// $Id: example.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin speed_example.cpp$$ @@ -18,15 +18,12 @@ $section Run the Speed Examples$$ -$mindex program$$ $head Running Tests$$ To build this program and run its correctness tests see $cref cmake_check$$. -$code $srcfile%speed/example/example.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -47,78 +44,79 @@ extern bool time_test(void); namespace { - // function that runs one test - size_t Run_ok_count = 0; - size_t Run_error_count = 0; - const char* exception_list[] = { - "elapsed_seconds", - "speed_test", - "time_test" - }; - 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::cout.width( width ); - std::cout.setf( std::ios_base::left ); - std::cout << name; - bool exception = false; - for(size_t i = 0; i < n_exception; i++) - exception |= exception_list[i] == name; - // - ok &= name.size() < size_t(width); - ok &= TestOk(); - if( ok ) - { std::cout << "OK" << std::endl; - Run_ok_count++; - } - else if ( exception ) - { std::cout << "Error: perhaps too many other programs running"; - std::cout << std::endl; - // no change to Run_ok_count - ok = true; - } - else - { std::cout << "Error" << std::endl; - Run_error_count++; - } - return ok; - } + // function that runs one test + size_t Run_ok_count = 0; + size_t Run_error_count = 0; + const char* exception_list[] = { + "elapsed_seconds", + "speed_test", + "time_test" + }; + 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::cout.width( width ); + std::cout.setf( std::ios_base::left ); + std::cout << name; + bool exception = false; + for(size_t i = 0; i < n_exception; i++) + exception |= exception_list[i] == name; + // + ok &= name.size() < size_t(width); + ok &= TestOk(); + if( ok ) + { std::cout << "OK" << std::endl; + Run_ok_count++; + } + else if ( exception ) + { std::cout << "Error: perhaps too many other programs running"; + std::cout << std::endl; + // no change to Run_ok_count + ok = true; + } + else + { std::cout << "Error" << std::endl; + Run_error_count++; + } + return ok; + } } // main program that runs all the tests int main(void) -{ bool ok = true; - using std::cout; - using std::endl; - - ok &= Run(det_of_minor, "det_of_minor" ); - ok &= Run(det_by_minor, "det_by_minor" ); - ok &= Run(det_by_lu, "det_by_lu" ); - ok &= Run(elapsed_seconds, "elapsed_seconds" ); - ok &= Run(mat_sum_sq, "mat_sum_sq" ); - ok &= Run(ode_evaluate, "ode_evaluate" ); - ok &= Run(sparse_hes_fun, "sparse_hes_fun" ); - ok &= Run(sparse_jac_fun, "sparse_jac_fun" ); - ok &= Run(speed_test, "speed_test" ); - ok &= Run(time_test, "time_test" ); - assert( ok || (Run_error_count > 0) ); - - // check for memory leak in previous calculations - if( ! CppAD::thread_alloc::free_all() ) - { ok = false; - cout << "Error: memroy leak detected" << endl; - } - - if( ok ) - { cout << "All " << int(Run_ok_count) << " tests passed "; - cout << "(possibly excepting elapsed_seconds)."; - } - else cout << int(Run_error_count) << " tests failed."; - cout << endl; +{ bool ok = true; + using std::cout; + using std::endl; + + ok &= Run(det_of_minor, "det_of_minor" ); + ok &= Run(det_by_minor, "det_by_minor" ); + ok &= Run(det_by_lu, "det_by_lu" ); + ok &= Run(elapsed_seconds, "elapsed_seconds" ); + ok &= Run(mat_sum_sq, "mat_sum_sq" ); + ok &= Run(ode_evaluate, "ode_evaluate" ); + ok &= Run(sparse_hes_fun, "sparse_hes_fun" ); + ok &= Run(sparse_jac_fun, "sparse_jac_fun" ); + ok &= Run(speed_test, "speed_test" ); + ok &= Run(time_test, "time_test" ); + assert( ok || (Run_error_count > 0) ); + + // check for memory leak in previous calculations + if( ! CppAD::thread_alloc::free_all() ) + { ok = false; + cout << "Error: memroy leak detected" << endl; + } + + if( ok ) + { cout << "All " << int(Run_ok_count) << " tests passed "; + cout << "(possibly excepting elapsed_seconds)."; + } + else + cout << int(Run_error_count) << " tests failed."; + cout << endl; - return static_cast( ! ok ); + return static_cast( ! ok ); } // END C++ diff -Nru cppad-2018.00.00.0/speed/example/makefile.am cppad-2019.02.00.0/speed/example/makefile.am --- cppad-2018.00.00.0/speed/example/makefile.am 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,30 +1,34 @@ -# $Id: makefile.am 3779 2016-01-01 11:26:11Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # -EXTRA_DIST = \ - speed_program.cpp # check_PROGRAMS = speed_example # -AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # -AM_CXXFLAGS = -g $(CXX_FLAGS) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) +# +LDADD = ../src/libspeed.a +# +../src/libspeed.a: + (cd ../src; make libspeed.a) # -LDADD = -lspeed -AM_LDFLAGS = -L../src speed_example_SOURCES = \ example.cpp \ det_by_lu.cpp \ @@ -36,8 +40,7 @@ sparse_hes_fun.cpp \ sparse_jac_fun.cpp \ speed_test.cpp \ - time_test.cpp \ - ../src/microsoft_timer.cpp + time_test.cpp test: check ./speed_example diff -Nru cppad-2018.00.00.0/speed/example/makefile.in cppad-2019.02.00.0/speed/example/makefile.in --- cppad-2018.00.00.0/speed/example/makefile.in 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -97,16 +97,15 @@ mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -am__dirstamp = $(am__leading_dot)dirstamp am_speed_example_OBJECTS = example.$(OBJEXT) det_by_lu.$(OBJEXT) \ det_by_minor.$(OBJEXT) det_of_minor.$(OBJEXT) \ elapsed_seconds.$(OBJEXT) mat_sum_sq.$(OBJEXT) \ ode_evaluate.$(OBJEXT) sparse_hes_fun.$(OBJEXT) \ sparse_jac_fun.$(OBJEXT) speed_test.$(OBJEXT) \ - time_test.$(OBJEXT) ../src/microsoft_timer.$(OBJEXT) + time_test.$(OBJEXT) speed_example_OBJECTS = $(am_speed_example_OBJECTS) speed_example_LDADD = $(LDADD) -speed_example_DEPENDENCIES = +speed_example_DEPENDENCIES = ../src/libspeed.a AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -189,20 +188,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3973 2017-08-30 13:38:26Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -275,10 +272,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -297,9 +292,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -322,8 +319,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -344,16 +339,16 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # -EXTRA_DIST = \ - speed_program.cpp - # -AM_CPPFLAGS = -I. -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + # -AM_CXXFLAGS = -g $(CXX_FLAGS) +LDADD = ../src/libspeed.a # -LDADD = -lspeed -AM_LDFLAGS = -L../src speed_example_SOURCES = \ example.cpp \ det_by_lu.cpp \ @@ -365,8 +360,7 @@ sparse_hes_fun.cpp \ sparse_jac_fun.cpp \ speed_test.cpp \ - time_test.cpp \ - ../src/microsoft_timer.cpp + time_test.cpp all: all-am @@ -404,14 +398,6 @@ clean-checkPROGRAMS: -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) -../src/$(am__dirstamp): - @$(MKDIR_P) ../src - @: > ../src/$(am__dirstamp) -../src/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) ../src/$(DEPDIR) - @: > ../src/$(DEPDIR)/$(am__dirstamp) -../src/microsoft_timer.$(OBJEXT): ../src/$(am__dirstamp) \ - ../src/$(DEPDIR)/$(am__dirstamp) speed_example$(EXEEXT): $(speed_example_OBJECTS) $(speed_example_DEPENDENCIES) $(EXTRA_speed_example_DEPENDENCIES) @rm -f speed_example$(EXEEXT) @@ -419,12 +405,10 @@ mostlyclean-compile: -rm -f *.$(OBJEXT) - -rm -f ../src/*.$(OBJEXT) distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@../src/$(DEPDIR)/microsoft_timer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_by_lu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_by_minor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/det_of_minor.Po@am__quote@ @@ -566,8 +550,6 @@ distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -rm -f ../src/$(DEPDIR)/$(am__dirstamp) - -rm -f ../src/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -577,7 +559,7 @@ clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am distclean: distclean-am - -rm -rf ../src/$(DEPDIR) ./$(DEPDIR) + -rm -rf ./$(DEPDIR) -rm -f makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -623,7 +605,7 @@ installcheck-am: maintainer-clean: maintainer-clean-am - -rm -rf ../src/$(DEPDIR) ./$(DEPDIR) + -rm -rf ./$(DEPDIR) -rm -f makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -658,6 +640,9 @@ .PRECIOUS: makefile +# +../src/libspeed.a: + (cd ../src; make libspeed.a) test: check ./speed_example diff -Nru cppad-2018.00.00.0/speed/example/mat_sum_sq.cpp cppad-2019.02.00.0/speed/example/mat_sum_sq.cpp --- cppad-2018.00.00.0/speed/example/mat_sum_sq.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/mat_sum_sq.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,28 +1,25 @@ -// $Id: mat_sum_sq.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin mat_sum_sq.cpp$$ $spell - sq + sq $$ $section Sum of the Elements of the Square of a Matrix: Example and Test$$ -$mindex mat_sum_sq$$ -$code $srcfile%speed/example/mat_sum_sq.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -33,42 +30,42 @@ # include bool mat_sum_sq() -{ bool ok = true; - double x_00, x_01, x_10, x_11, check; +{ bool ok = true; + double x_00, x_01, x_10, x_11, check; - // dimension of the matrices x, y, and the result z - size_t n = 2; - CppAD::vector x(n * n), y(n * n), z(1); - - // x = [ 1 2 ; 3 4 ] - x[0] = x_00 = 1.; - x[1] = x_01 = 2.; - x[2] = x_10 = 3.; - x[3] = x_11 = 4.; - - // compute y = x * x and z = sum of elements in y - CppAD::mat_sum_sq(n, x, y, z); - - // check y_00 - check = x_00 * x_00 + x_01 * x_10; - ok &= (check == y[0]); - - // check y_01 - check = x_00 * x_01 + x_01 * x_11; - ok &= (check == y[1]); - - // check y_10 - check = x_10 * x_00 + x_11 * x_10; - ok &= (check == y[2]); - - // check y_11 - check = x_10 * x_01 + x_11 * x_11; - ok &= (check == y[3]); - - // check z - check = y[0] + y[1] + y[2] + y[3]; - ok &= (check == z[0]); + // dimension of the matrices x, y, and the result z + size_t n = 2; + CppAD::vector x(n * n), y(n * n), z(1); + + // x = [ 1 2 ; 3 4 ] + x[0] = x_00 = 1.; + x[1] = x_01 = 2.; + x[2] = x_10 = 3.; + x[3] = x_11 = 4.; + + // compute y = x * x and z = sum of elements in y + CppAD::mat_sum_sq(n, x, y, z); + + // check y_00 + check = x_00 * x_00 + x_01 * x_10; + ok &= (check == y[0]); + + // check y_01 + check = x_00 * x_01 + x_01 * x_11; + ok &= (check == y[1]); + + // check y_10 + check = x_10 * x_00 + x_11 * x_10; + ok &= (check == y[2]); + + // check y_11 + check = x_10 * x_01 + x_11 * x_11; + ok &= (check == y[3]); + + // check z + check = y[0] + y[1] + y[2] + y[3]; + ok &= (check == z[0]); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/speed/example/ode_evaluate.cpp cppad-2019.02.00.0/speed/example/ode_evaluate.cpp --- cppad-2018.00.00.0/speed/example/ode_evaluate.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/ode_evaluate.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,14 +1,14 @@ -// $Id: ode_evaluate.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin ode_evaluate.cpp$$ $spell @@ -16,11 +16,8 @@ $section ode_evaluate: Example and test$$ -$mindex ode_evaluate$$ -$code $srcfile%speed/example/ode_evaluate.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -30,44 +27,44 @@ # include bool ode_evaluate(void) -{ using CppAD::NearEqual; - using CppAD::AD; +{ using CppAD::NearEqual; + using CppAD::AD; - bool ok = true; + bool ok = true; - size_t n = 3; - CppAD::vector x(n); - CppAD::vector ym(n * n); - CppAD::vector< AD > X(n); - CppAD::vector< AD > Ym(n); - - // choose x - size_t j; - for(j = 0; j < n; j++) - { x[j] = double(j + 1); - X[j] = x[j]; - } - - // declare independent variables - Independent(X); - - // evaluate function - size_t m = 0; - CppAD::ode_evaluate(X, m, Ym); - - // evaluate derivative - m = 1; - CppAD::ode_evaluate(x, m, ym); - - // use AD to evaluate derivative - CppAD::ADFun F(X, Ym); - CppAD::vector dy(n * n); - dy = F.Jacobian(x); - - size_t k; - for(k = 0; k < n * n; k++) - ok &= NearEqual(ym[k], dy[k] , 1e-7, 1e-7); + size_t n = 3; + CppAD::vector x(n); + CppAD::vector ym(n * n); + CppAD::vector< AD > X(n); + CppAD::vector< AD > Ym(n); + + // choose x + size_t j; + for(j = 0; j < n; j++) + { x[j] = double(j + 1); + X[j] = x[j]; + } + + // declare independent variables + Independent(X); + + // evaluate function + size_t m = 0; + CppAD::ode_evaluate(X, m, Ym); + + // evaluate derivative + m = 1; + CppAD::ode_evaluate(x, m, ym); + + // use AD to evaluate derivative + CppAD::ADFun F(X, Ym); + CppAD::vector dy(n * n); + dy = F.Jacobian(x); + + size_t k; + for(k = 0; k < n * n; k++) + ok &= NearEqual(ym[k], dy[k] , 1e-7, 1e-7); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/speed/example/sparse_hes_fun.cpp cppad-2019.02.00.0/speed/example/sparse_hes_fun.cpp --- cppad-2018.00.00.0/speed/example/sparse_hes_fun.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/sparse_hes_fun.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,24 @@ -// $Id: sparse_hes_fun.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sparse_hes_fun.cpp$$ $spell - hes + hes $$ $section sparse_hes_fun: Example and test$$ -$mindex sparse_hes_fun$$ -$code $srcfile%speed/example/sparse_hes_fun.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,55 +28,55 @@ # include bool sparse_hes_fun(void) -{ using CppAD::NearEqual; - bool ok = true; +{ using CppAD::NearEqual; + bool ok = true; - typedef CppAD::AD ADScalar; + typedef CppAD::AD ADScalar; - size_t j, k; - double eps = 10. * CppAD::numeric_limits::epsilon(); - size_t n = 5; - size_t m = 1; - size_t K = 2 * n; - CppAD::vector row(K), col(K); - CppAD::vector x(n), ypp(K); - CppAD::vector a_x(n), a_y(m); - - // choose x - for(j = 0; j < n; j++) - a_x[j] = x[j] = double(j + 1); - - // choose row, col - for(k = 0; k < K; k++) - { 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 - Independent(a_x); - - // evaluate function - size_t order = 0; - CppAD::sparse_hes_fun(n, a_x, row, col, order, a_y); - - // evaluate Hessian - order = 2; - CppAD::sparse_hes_fun(n, x, row, col, order, ypp); - - // use AD to evaluate Hessian - CppAD::ADFun f(a_x, a_y); - CppAD::vector hes(n * n); - // compoute Hessian of f_0 (x) - hes = f.Hessian(x, 0); - - for(k = 0; k < K; k++) - { size_t index = row[k] * n + col[k]; - ok &= NearEqual(hes[index], ypp[k] , eps, eps); - } - return ok; + size_t j, k; + double eps = 10. * CppAD::numeric_limits::epsilon(); + size_t n = 5; + size_t m = 1; + size_t K = 2 * n; + CppAD::vector row(K), col(K); + CppAD::vector x(n), ypp(K); + CppAD::vector a_x(n), a_y(m); + + // choose x + for(j = 0; j < n; j++) + a_x[j] = x[j] = double(j + 1); + + // choose row, col + for(k = 0; k < K; k++) + { 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 + Independent(a_x); + + // evaluate function + size_t order = 0; + CppAD::sparse_hes_fun(n, a_x, row, col, order, a_y); + + // evaluate Hessian + order = 2; + CppAD::sparse_hes_fun(n, x, row, col, order, ypp); + + // use AD to evaluate Hessian + CppAD::ADFun f(a_x, a_y); + CppAD::vector hes(n * n); + // compoute Hessian of f_0 (x) + hes = f.Hessian(x, 0); + + for(k = 0; k < K; k++) + { size_t index = row[k] * n + col[k]; + ok &= NearEqual(hes[index], ypp[k] , eps, eps); + } + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/speed/example/sparse_jac_fun.cpp cppad-2019.02.00.0/speed/example/sparse_jac_fun.cpp --- cppad-2018.00.00.0/speed/example/sparse_jac_fun.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/sparse_jac_fun.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,27 +1,24 @@ -// $Id: sparse_jac_fun.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sparse_jac_fun.cpp$$ $spell - jac + jac $$ $section sparse_jac_fun: Example and test$$ -$mindex sparse_jac_fun$$ -$code $srcfile%speed/example/sparse_jac_fun.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -31,50 +28,50 @@ # include bool sparse_jac_fun(void) -{ using CppAD::NearEqual; - using CppAD::AD; +{ using CppAD::NearEqual; + using CppAD::AD; - bool ok = true; + bool ok = true; - 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(K); - CppAD::vector< AD > a_x(n), a_y(m); - - // choose x - for(j = 0; j < n; j++) - a_x[j] = x[j] = double(j + 1); - - // choose row, col - for(k = 0; k < K; k++) - { row[k] = k % m; - col[k] = (K - k) % n; - } - - // declare independent variables - Independent(a_x); - - // evaluate function - size_t order = 0; - CppAD::sparse_jac_fun< AD >(m, n, a_x, row, col, order, a_y); - - // evaluate derivative - order = 1; - CppAD::sparse_jac_fun(m, n, x, row, col, order, yp); - - // use AD to evaluate derivative - CppAD::ADFun f(a_x, a_y); - CppAD::vector jac(m * n); - jac = f.Jacobian(x); - - for(k = 0; k < K; k++) - { size_t index = row[k] * n + col[k]; - ok &= NearEqual(jac[index], yp[k] , eps, eps); - } - return ok; + 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(K); + CppAD::vector< AD > a_x(n), a_y(m); + + // choose x + for(j = 0; j < n; j++) + a_x[j] = x[j] = double(j + 1); + + // choose row, col + for(k = 0; k < K; k++) + { row[k] = k % m; + col[k] = (K - k) % n; + } + + // declare independent variables + Independent(a_x); + + // evaluate function + size_t order = 0; + CppAD::sparse_jac_fun< AD >(m, n, a_x, row, col, order, a_y); + + // evaluate derivative + order = 1; + CppAD::sparse_jac_fun(m, n, x, row, col, order, yp); + + // use AD to evaluate derivative + CppAD::ADFun f(a_x, a_y); + CppAD::vector jac(m * n); + jac = f.Jacobian(x); + + 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-2018.00.00.0/speed/example/speed_program.cpp cppad-2019.02.00.0/speed/example/speed_program.cpp --- cppad-2018.00.00.0/speed/example/speed_program.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/speed_program.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,42 +1,41 @@ -// $Id: speed_program.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin speed_program.cpp$$ $spell - speed_program.exe - cppad.hpp - Microsoft - namespace - std - const - cout - ctime - ifdef - const - endif - cpp + speed_program.exe + cppad.hpp + Microsoft + namespace + std + const + cout + ctime + ifdef + const + endif + cpp $$ $section Example Use of SpeedTest$$ -$mindex test speed$$ $head Running This Program$$ On a Unix system that includes the $code g++$$ compiler, you can compile and run this program by changing into the $code speed/example$$ directory and executing the following commands $codep - g++ -I../.. speed_program.cpp -o speed_program.exe - ./speed_program.exe + g++ -I../.. speed_program.cpp -o speed_program.exe + ./speed_program.exe $$ $head Program$$ @@ -44,36 +43,36 @@ # include std::string Test(size_t size, size_t repeat) -{ // setup - double *a = new double[size]; - double *b = new double[size]; - double *c = new double[size]; - size_t i = size;; - while(i) - { --i; - a[i] = i; - b[i] = 2 * i; - } - // operations we are timing - while(repeat--) - { i = size;; - while(i) - { --i; - c[i] = a[i] + b[i]; - } - } - // teardown - delete [] a; - delete [] b; - delete [] c; +{ // setup + double *a = new double[size]; + double *b = new double[size]; + double *c = new double[size]; + size_t i = size;; + while(i) + { --i; + a[i] = i; + b[i] = 2 * i; + } + // operations we are timing + while(repeat--) + { i = size;; + while(i) + { --i; + c[i] = a[i] + b[i]; + } + } + // teardown + delete [] a; + delete [] b; + delete [] c; - // return a test name that is valid for all sizes and repeats - return "double: c[*] = a[*] + b[*]"; + // return a test name that is valid for all sizes and repeats + return "double: c[*] = a[*] + b[*]"; } int main(void) { - CppAD::SpeedTest(Test, 10, 10, 100); - return 0; + CppAD::SpeedTest(Test, 10, 10, 100); + return 0; } /* %$$ @@ -82,17 +81,17 @@ Executing of the program above generated the following output (the rates will be different for each particular system): $codep - double: c[*] = a[*] + b[*] - size = 10 rate = 14,122,236 - size = 20 rate = 7,157,515 - size = 30 rate = 4,972,500 - size = 40 rate = 3,887,214 - size = 50 rate = 3,123,086 - size = 60 rate = 2,685,214 - size = 70 rate = 2,314,737 - size = 80 rate = 2,032,124 - size = 90 rate = 1,814,145 - size = 100 rate = 1,657,828 + double: c[*] = a[*] + b[*] + size = 10 rate = 14,122,236 + size = 20 rate = 7,157,515 + size = 30 rate = 4,972,500 + size = 40 rate = 3,887,214 + size = 50 rate = 3,123,086 + size = 60 rate = 2,685,214 + size = 70 rate = 2,314,737 + size = 80 rate = 2,032,124 + size = 90 rate = 1,814,145 + size = 100 rate = 1,657,828 $$ $end diff -Nru cppad-2018.00.00.0/speed/example/speed_test.cpp cppad-2019.02.00.0/speed/example/speed_test.cpp --- cppad-2018.00.00.0/speed/example/speed_test.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/speed_test.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,36 +1,34 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin speed_test.cpp$$ $spell - cppad.hpp - Microsoft - namespace - std - const - cout - ctime - ifdef - const - endif - cpp + cppad.hpp + Microsoft + namespace + std + const + cout + ctime + ifdef + const + endif + cpp $$ $section speed_test: Example and test$$ -$mindex speed_test$$ -$code $srcfile%speed/example/speed_test.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -39,59 +37,59 @@ # include namespace { // empty namespace - using CppAD::vector; - vector a, b, c; - void test(size_t size, size_t repeat) - { // setup - a.resize(size); - b.resize(size); - c.resize(size); - size_t i = size;; - while(i) - { --i; - a[i] = double(i); - b[i] = double(2 * i); - c[i] = 0.0; - } - // operations we are timing - while(repeat--) - { i = size;; - while(i) - { --i; - c[i] += std::sqrt(a[i] * a[i] + b[i] * b[i]); - } - } - } + using CppAD::vector; + vector a, b, c; + void test(size_t size, size_t repeat) + { // setup + a.resize(size); + b.resize(size); + c.resize(size); + size_t i = size;; + while(i) + { --i; + a[i] = double(i); + b[i] = double(2 * i); + c[i] = 0.0; + } + // operations we are timing + while(repeat--) + { i = size;; + while(i) + { --i; + c[i] += std::sqrt(a[i] * a[i] + b[i] * b[i]); + } + } + } } bool speed_test(void) -{ bool ok = true; +{ bool ok = true; - // size of the test cases - vector size_vec(2); - size_vec[0] = 40; - size_vec[1] = 80; - - // minimum amount of time to run test - double time_min = 0.5; - - // run the test cases - vector rate_vec(2); - rate_vec = CppAD::speed_test(test, size_vec, time_min); - - // time per repeat loop (note counting setup or teardown) - double time_0 = 1. / double(rate_vec[0]); - double time_1 = 1. / double(rate_vec[1]); - - // for this case, time should be linear w.r.t size - double check = double(size_vec[1]) * time_0 / double(size_vec[0]); - double rel_diff = (check - time_1) / time_1; - ok &= (std::fabs(rel_diff) <= .1); - if( ! ok ) - std::cout << std::endl << "rel_diff = " << rel_diff << std::endl; - - a.clear(); - b.clear(); - c.clear(); - return ok; + // size of the test cases + vector size_vec(2); + size_vec[0] = 40; + size_vec[1] = 80; + + // minimum amount of time to run test + double time_min = 0.5; + + // run the test cases + vector rate_vec(2); + rate_vec = CppAD::speed_test(test, size_vec, time_min); + + // time per repeat loop (note counting setup or teardown) + double time_0 = 1. / double(rate_vec[0]); + double time_1 = 1. / double(rate_vec[1]); + + // for this case, time should be linear w.r.t size + double check = double(size_vec[1]) * time_0 / double(size_vec[0]); + double rel_diff = (check - time_1) / time_1; + ok &= (std::fabs(rel_diff) <= .1); + if( ! ok ) + std::cout << std::endl << "rel_diff = " << rel_diff << std::endl; + + a.clear(); + b.clear(); + c.clear(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/speed/example/time_test.cpp cppad-2019.02.00.0/speed/example/time_test.cpp --- cppad-2018.00.00.0/speed/example/time_test.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/example/time_test.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,36 +1,34 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin time_test.cpp$$ $spell - cppad.hpp - Microsoft - namespace - std - const - cout - ctime - ifdef - const - endif - cpp + cppad.hpp + Microsoft + namespace + std + const + cout + ctime + ifdef + const + endif + cpp $$ $section time_test: Example and test$$ -$mindex time_test$$ -$code $srcfile%speed/example/time_test.cpp%0%// BEGIN C++%// END C++%1%$$ -$$ $end */ @@ -39,62 +37,62 @@ # include namespace { // empty namespace - using CppAD::vector; + using CppAD::vector; - // size for the test - size_t size_; + // size for the test + size_t size_; - vector a, b, c; - void test(size_t repeat) - { // setup - a.resize(size_); - b.resize(size_); - c.resize(size_); - size_t i = size_;; - while(i) - { --i; - a[i] = float(i); - b[i] = float(2 * i); - c[i] = 0.0; - } - // operations we are timing - while(repeat--) - { i = size_;; - while(i) - { --i; - c[i] += std::sqrt(a[i] * a[i] + b[i] * b[i]); - } - } - } + vector a, b, c; + void test(size_t repeat) + { // setup + a.resize(size_); + b.resize(size_); + c.resize(size_); + size_t i = size_;; + while(i) + { --i; + a[i] = float(i); + b[i] = float(2 * i); + c[i] = 0.0; + } + // operations we are timing + while(repeat--) + { i = size_;; + while(i) + { --i; + c[i] += std::sqrt(a[i] * a[i] + b[i] * b[i]); + } + } + } } bool time_test(void) -{ bool ok = true; +{ bool ok = true; - // minimum amount of time to run test - double time_min = 0.5; + // minimum amount of time to run test + double time_min = 0.5; - // size of first test case - size_ = 20; + // size of first test case + size_ = 20; - // run the first test case - double time_first = CppAD::time_test(test, time_min); + // run the first test case + double time_first = CppAD::time_test(test, time_min); - // size of second test case is twice as large - size_ = 2 * size_; + // size of second test case is twice as large + size_ = 2 * size_; - // run the second test case - double time_second = CppAD::time_test(test, time_min); + // run the second test case + double time_second = CppAD::time_test(test, time_min); - // for this case, time should be linear w.r.t size - double rel_diff = 1. - 2. * time_first / time_second; - ok &= (std::fabs(rel_diff) <= .1); - if( ! ok ) - std::cout << std::endl << "rel_diff = " << rel_diff << std::endl; + // for this case, time should be linear w.r.t size + double rel_diff = 1. - 2. * time_first / time_second; + ok &= (std::fabs(rel_diff) <= .1); + if( ! ok ) + std::cout << std::endl << "rel_diff = " << rel_diff << std::endl; - a.clear(); - b.clear(); - c.clear(); - return ok; + a.clear(); + b.clear(); + c.clear(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/speed/fadbad/CMakeLists.txt cppad-2019.02.00.0/speed/fadbad/CMakeLists.txt --- cppad-2018.00.00.0/speed/fadbad/CMakeLists.txt 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/fadbad/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,22 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the speed/fadbad directory tests # Inherit build type from ../CMakeList.txt # assert fadbad_prefix is defined IF ( NOT fadbad_prefix ) - MESSAGE(FATAL_ERROR - "speed/fadbad/CMakeLists.txt: fadbad_prefix = ${fadbad_prefix}" - ) + MESSAGE(FATAL_ERROR + "speed/fadbad/CMakeLists.txt: fadbad_prefix = ${fadbad_prefix}" + ) ENDIF ( NOT fadbad_prefix ) # Adds flags to the compiler command line for sources in the current directory @@ -30,13 +31,13 @@ # source1 source2 ... sourceN # ) SET(source_list ../main.cpp - det_lu.cpp - det_minor.cpp - mat_mul.cpp - ode.cpp - poly.cpp - sparse_hessian.cpp - sparse_jacobian.cpp + det_lu.cpp + det_minor.cpp + mat_mul.cpp + ode.cpp + poly.cpp + sparse_hessian.cpp + sparse_jacobian.cpp ) set_compile_flags( speed_fadbad "${cppad_debug_which}" "${source_list}" ) # @@ -47,8 +48,8 @@ # Add the check_speed_fadbad target ADD_CUSTOM_TARGET(check_speed_fadbad - speed_fadbad correct 54321 - DEPENDS speed_fadbad speed_src + speed_fadbad correct 54321 + DEPENDS speed_fadbad speed_src ) MESSAGE(STATUS "make check_speed_fadbad: available") diff -Nru cppad-2018.00.00.0/speed/fadbad/det_lu.cpp cppad-2019.02.00.0/speed/fadbad/det_lu.cpp --- cppad-2018.00.00.0/speed/fadbad/det_lu.cpp 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/fadbad/det_lu.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,33 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin fadbad_det_lu.cpp$$ $spell - onetape - cppad - std - Lu - Fadbad - det - badiff.hpp - const - CppAD - typedef - diff - bool - srand + onetape + cppad + std + Lu + Fadbad + det + badiff.hpp + const + CppAD + typedef + diff + bool + srand $$ $section Fadbad Speed: Gradient of Determinant Using Lu Factorization$$ -$mindex link_det_lu speed matrix factor$$ $head Specifications$$ @@ -48,51 +48,51 @@ extern std::map global_option; bool link_det_lu( - size_t size , - size_t repeat , - CppAD::vector &matrix , - CppAD::vector &gradient ) + size_t size , + size_t repeat , + CppAD::vector &matrix , + CppAD::vector &gradient ) { - // speed test global option values - if( global_option["onetape"] || global_option["atomic"] ) - return false; - if( global_option["memory"] || global_option["optimize"] ) - return false; - // ----------------------------------------------------- - // setup - // - // object for computing determinant - 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 - - // ------------------------------------------------------ - while(repeat--) - { // get the next matrix - CppAD::uniform_01(n, matrix); - - // set independent variable values - for(i = 0; i < n; i++) - A[i] = matrix[i]; - - // compute the determinant - detA = Det(A); - - // create function object f : A -> detA - detA.diff(0, m); // index 0 of m dependent variables - - // evaluate and return gradient using reverse mode - for(i =0; i < n; i++) - gradient[i] = A[i].d(0); // partial detA w.r.t A[i] - } - // --------------------------------------------------------- - return true; + // speed test global option values + if( global_option["onetape"] || global_option["atomic"] ) + return false; + if( global_option["memory"] || global_option["optimize"] ) + return false; + // ----------------------------------------------------- + // setup + // + // object for computing determinant + 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 + + // ------------------------------------------------------ + while(repeat--) + { // get the next matrix + CppAD::uniform_01(n, matrix); + + // set independent variable values + for(i = 0; i < n; i++) + A[i] = matrix[i]; + + // compute the determinant + detA = Det(A); + + // create function object f : A -> detA + detA.diff(0, (unsigned int) m); // index 0 of m dependent variables + + // evaluate and return gradient using reverse mode + for(i =0; i < n; i++) + gradient[i] = A[i].d(0); // partial detA w.r.t A[i] + } + // --------------------------------------------------------- + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/fadbad/det_minor.cpp cppad-2019.02.00.0/speed/fadbad/det_minor.cpp --- cppad-2018.00.00.0/speed/fadbad/det_minor.cpp 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/fadbad/det_minor.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,32 +1,32 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin fadbad_det_minor.cpp$$ $spell - onetape - cppad - std - Fadbad - det - badiff.hpp - const - CppAD - typedef - diff - bool - srand + onetape + cppad + std + Fadbad + det + badiff.hpp + const + CppAD + typedef + diff + bool + srand $$ $section Fadbad Speed: Gradient of Determinant by Minor Expansion$$ -$mindex link_det_minor speed$$ $head Specifications$$ @@ -48,51 +48,51 @@ extern std::map global_option; bool link_det_minor( - size_t size , - size_t repeat , - CppAD::vector &matrix , - CppAD::vector &gradient ) + size_t size , + size_t repeat , + CppAD::vector &matrix , + CppAD::vector &gradient ) { - // speed test global option values - if( global_option["atomic"] ) - return false; - if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] ) - return false; - // ----------------------------------------------------- - // setup - - // object for computing determinant - 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 - - // ------------------------------------------------------ - while(repeat--) - { // get the next matrix - CppAD::uniform_01(n, matrix); - - // set independent variable values - for(i = 0; i < n; i++) - A[i] = matrix[i]; - - // compute the determinant - detA = Det(A); - - // create function object f : A -> detA - detA.diff(0, m); // index 0 of m dependent variables - - // evaluate and return gradient using reverse mode - for(i =0; i < n; i++) - gradient[i] = A[i].d(0); // partial detA w.r.t A[i] - } - // --------------------------------------------------------- - return true; + // speed test global option values + if( global_option["atomic"] ) + return false; + if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] ) + return false; + // ----------------------------------------------------- + // setup + + // object for computing determinant + 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 + + // ------------------------------------------------------ + while(repeat--) + { // get the next matrix + CppAD::uniform_01(n, matrix); + + // set independent variable values + for(i = 0; i < n; i++) + A[i] = matrix[i]; + + // compute the determinant + detA = Det(A); + + // create function object f : A -> detA + detA.diff(0, (unsigned int) m); // index 0 of m dependent variables + + // evaluate and return gradient using reverse mode + for(i =0; i < n; i++) + gradient[i] = A[i].d(0); // partial detA w.r.t A[i] + } + // --------------------------------------------------------- + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/fadbad/makefile.am cppad-2019.02.00.0/speed/fadbad/makefile.am --- cppad-2018.00.00.0/speed/fadbad/makefile.am 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/fadbad/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,13 @@ -# $Id: makefile.am 3779 2016-01-01 11:26:11Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory @@ -21,23 +21,19 @@ # check_PROGRAMS = speed_fadbad # -AM_CPPFLAGS = \ - -I$(top_srcdir) \ +AM_CXXFLAGS = \ + -DCPPAD_FADBAD_SPEED \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ -I$(FADBAD_DIR)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) # -# BEGIN OPTIMIZE -# Use special version of CXX_FLAGS with -Wshadow removed (if present). -AM_CXXFLAGS = -O2 -DNDEBUG -DCPPAD_FADBAD_SPEED $(CXX_FLAGS_FADBAD) -# END OPTIMIZE -# -# BEGIN DEBUG -# AM_CXXFLAGS = -g -DCPPAD_FADBAD_SPEED $(CXX_FLAGS_FADBAD) -# END DEBUG # -LDADD = -lspeed -AM_LDFLAGS = -L../src +LDADD = ../src/libspeed.a +# +../src/libspeed.a: + (cd ../src; make libspeed.a) # speed_fadbad_SOURCES = \ main.cpp \ diff -Nru cppad-2018.00.00.0/speed/fadbad/makefile.in cppad-2019.02.00.0/speed/fadbad/makefile.in --- cppad-2018.00.00.0/speed/fadbad/makefile.in 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/fadbad/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -103,7 +103,7 @@ sparse_jacobian.$(OBJEXT) speed_fadbad_OBJECTS = $(am_speed_fadbad_OBJECTS) speed_fadbad_LDADD = $(LDADD) -speed_fadbad_DEPENDENCIES = +speed_fadbad_DEPENDENCIES = ../src/libspeed.a AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -186,8 +186,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # # @@ -260,10 +258,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -282,9 +278,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -307,8 +305,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -329,39 +325,32 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3973 2017-08-30 13:38:26Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp # -AM_CPPFLAGS = \ - -I$(top_srcdir) \ +AM_CXXFLAGS = \ + -DCPPAD_FADBAD_SPEED \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ -I$(FADBAD_DIR)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) # -# BEGIN OPTIMIZE -# Use special version of CXX_FLAGS with -Wshadow removed (if present). -AM_CXXFLAGS = -O2 -DNDEBUG -DCPPAD_FADBAD_SPEED $(CXX_FLAGS_FADBAD) -# END OPTIMIZE # -# BEGIN DEBUG -# AM_CXXFLAGS = -g -DCPPAD_FADBAD_SPEED $(CXX_FLAGS_FADBAD) -# END DEBUG -# -LDADD = -lspeed -AM_LDFLAGS = -L../src +LDADD = ../src/libspeed.a # speed_fadbad_SOURCES = \ main.cpp \ @@ -654,6 +643,9 @@ main.cpp: cp $(srcdir)/../main.cpp main.cpp +# +../src/libspeed.a: + (cd ../src; make libspeed.a) test: check ./speed_fadbad correct 123 diff -Nru cppad-2018.00.00.0/speed/fadbad/mat_mul.cpp cppad-2019.02.00.0/speed/fadbad/mat_mul.cpp --- cppad-2018.00.00.0/speed/fadbad/mat_mul.cpp 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/fadbad/mat_mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,32 +1,32 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin fadbad_mat_mul.cpp$$ $spell - badiff - sq - onetape - typedef - diff - Fadbad - Adolc - cppad.hpp - bool - mul - dz - CppAD + badiff + sq + onetape + typedef + diff + Fadbad + Adolc + cppad.hpp + bool + mul + dz + CppAD $$ $section Fadbad Speed: Matrix Multiplication$$ -$mindex link_mat_mul speed multiply$$ $head Specifications$$ @@ -48,56 +48,56 @@ extern std::map global_option; bool link_mat_mul( - size_t size , - size_t repeat , - CppAD::vector& x , - CppAD::vector& z , - CppAD::vector& dz ) + size_t size , + size_t repeat , + CppAD::vector& x , + CppAD::vector& z , + CppAD::vector& dz ) { - // speed test global option values - if( global_option["memory"] || global_option["onetape"] || global_option["atomic"] || global_option["optimize"] ) - return false; - // The correctness check for this test is failing, so abort (for now). - return false; - - // ----------------------------------------------------- - // setup - - // object for computing determinant - typedef fadbad::B ADScalar; - typedef CppAD::vector ADVector; - - size_t j; // temporary index - size_t m = 1; // number of dependent variables - size_t n = size * size; // number of independent variables - 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 - CppAD::uniform_01(n, x); - - // set independent variable values - for(j = 0; j < n; j++) - X[j] = x[j]; - - // do the computation - mat_sum_sq(size, X, Y, Z); - - // create function object f : X -> Z - Z[0].diff(0, m); // index 0 of m dependent variables - - // evaluate and return gradient using reverse mode - for(j = 0; j < n; j++) - dz[j] = X[j].d(0); // partial Z[0] w.r.t X[j] - } - // return function value - z[0] = Z[0].x(); + // speed test global option values + if( global_option["memory"] || global_option["onetape"] || global_option["atomic"] || global_option["optimize"] ) + return false; + // The correctness check for this test is failing, so abort (for now). + return false; + + // ----------------------------------------------------- + // setup + + // object for computing determinant + typedef fadbad::B ADScalar; + typedef CppAD::vector ADVector; + + size_t j; // temporary index + size_t m = 1; // number of dependent variables + size_t n = size * size; // number of independent variables + 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 + CppAD::uniform_01(n, x); + + // set independent variable values + for(j = 0; j < n; j++) + X[j] = x[j]; + + // do the computation + mat_sum_sq(size, X, Y, Z); + + // create function object f : X -> Z + Z[0].diff(0, m); // index 0 of m dependent variables + + // evaluate and return gradient using reverse mode + for(j = 0; j < n; j++) + dz[j] = X[j].d(0); // partial Z[0] w.r.t X[j] + } + // return function value + z[0] = Z[0].x(); - // --------------------------------------------------------- - return true; + // --------------------------------------------------------- + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/fadbad/ode.cpp cppad-2019.02.00.0/speed/fadbad/ode.cpp --- cppad-2018.00.00.0/speed/fadbad/ode.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/fadbad/ode.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,36 +1,36 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin fadbad_ode.cpp$$ $spell - fadiff - cassert - namespace - fabs - const - std - typedef - diff - Jacobian - cstring - cppad - hpp - onetape - Fadbad - bool - CppAD + fadiff + cassert + namespace + fabs + const + std + typedef + diff + Jacobian + cstring + cppad + hpp + onetape + Fadbad + bool + CppAD $$ $section Fadbad Speed: Ode$$ -$mindex link_ode speed$$ @@ -55,58 +55,58 @@ extern std::map global_option; namespace fadbad { - // define fabs for use by ode_evaluate - fadbad::F fabs(const fadbad::F& x) - { return std::max(-x, x); } + // define fabs for use by ode_evaluate + fadbad::F fabs(const fadbad::F& x) + { return std::max(-x, x); } } bool link_ode( - size_t size , - size_t repeat , - CppAD::vector &x , - CppAD::vector &jacobian + size_t size , + size_t repeat , + CppAD::vector &x , + CppAD::vector &jacobian ) { - // speed test global option values - if( global_option["atomic"] ) - return false; - if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] ) - return false; - // ------------------------------------------------------------- - // setup - assert( x.size() == size ); - assert( jacobian.size() == size * size ); - - typedef fadbad::F ADScalar; - typedef CppAD::vector ADVector; - - size_t i, j; - size_t p = 0; // use ode to calculate function values - size_t n = size; // number of independent variables - size_t m = n; // number of dependent variables - ADVector X(n), Y(m); // independent and dependent variables - - // ------------------------------------------------------------- - while(repeat--) - { // choose next x value - CppAD::uniform_01(n, x); - for(j = 0; j < n; j++) - { // set value of x[j] - X[j] = x[j]; - // set up for X as the independent variable vector - X[j].diff(j, n); - } - - // evaluate function - CppAD::ode_evaluate(X, p, Y); - - // return values with Y as the dependent variable vector - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - jacobian[ i * n + j ] = Y[i].d(j); - } - } - return true; + // speed test global option values + if( global_option["atomic"] ) + return false; + if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] ) + return false; + // ------------------------------------------------------------- + // setup + assert( x.size() == size ); + assert( jacobian.size() == size * size ); + + typedef fadbad::F ADScalar; + typedef CppAD::vector ADVector; + + size_t i, j; + size_t p = 0; // use ode to calculate function values + size_t n = size; // number of independent variables + size_t m = n; // number of dependent variables + ADVector X(n), Y(m); // independent and dependent variables + + // ------------------------------------------------------------- + while(repeat--) + { // choose next x value + CppAD::uniform_01(n, x); + for(j = 0; j < n; j++) + { // set value of x[j] + X[j] = x[j]; + // set up for X as the independent variable vector + X[j].diff((unsigned int) j, (unsigned int) n); + } + + // evaluate function + CppAD::ode_evaluate(X, p, Y); + + // return values with Y as the dependent variable vector + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + jacobian[ i * n + j ] = Y[i].d((unsigned int) j); + } + } + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/fadbad/poly.cpp cppad-2019.02.00.0/speed/fadbad/poly.cpp --- cppad-2018.00.00.0/speed/fadbad/poly.cpp 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/fadbad/poly.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,41 +1,40 @@ -// $Id: poly.cpp 3794 2016-02-29 20:42:44Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin fadbad_poly.cpp$$ $spell - onetape - std - cppad - cpp - tadiff - std - ddp - Taylor - dz - eval - cppad - vector Vector - typedef - fadbad - Lu - CppAD - det - hpp - const - bool + onetape + std + cppad + cpp + tadiff + std + ddp + Taylor + dz + eval + cppad + vector Vector + typedef + fadbad + Lu + CppAD + det + hpp + const + bool $$ $section Fadbad Speed: Second Derivative of a Polynomial$$ -$mindex link_poly speed$$ $head Specifications$$ @@ -54,54 +53,54 @@ extern std::map global_option; bool link_poly( - 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 + 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 { - if( global_option["atomic"] ) - return false; - if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] ) - return false; - // ----------------------------------------------------- - // setup - size_t i; // temporary index - fadbad::T Z; // domain space AD value - fadbad::T P; // range space AD value - - // choose the polynomial coefficients - CppAD::uniform_01(size, a); - - // AD copy of the polynomial coefficients - CppAD::vector< fadbad::T > A(size); - for(i = 0; i < size; i++) - A[i] = a[i]; - - // ------------------------------------------------------ - while(repeat--) - { // get the next argument value - CppAD::uniform_01(1, z); - - // independent variable value - Z = z[0]; // argument value - Z[1] = 1; // argument first order Taylor coefficient - - // AD computation of the dependent variable - P = CppAD::Poly(0, A, Z); - - // Taylor-expand P to degree one - P.eval(2); - - // second derivative is twice second order Taylor coefficient - ddp[0] = 2. * P[2]; - - // Free DAG corresponding to P does not seem to improve speed. - // Probably because it gets freed the next time P is assigned. - // P.reset(); - } - // ------------------------------------------------------ - return true; + if( global_option["atomic"] ) + return false; + if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] ) + return false; + // ----------------------------------------------------- + // setup + size_t i; // temporary index + fadbad::T Z; // domain space AD value + fadbad::T P; // range space AD value + + // choose the polynomial coefficients + CppAD::uniform_01(size, a); + + // AD copy of the polynomial coefficients + CppAD::vector< fadbad::T > A(size); + for(i = 0; i < size; i++) + A[i] = a[i]; + + // ------------------------------------------------------ + while(repeat--) + { // get the next argument value + CppAD::uniform_01(1, z); + + // independent variable value + Z = z[0]; // argument value + Z[1] = 1; // argument first order Taylor coefficient + + // AD computation of the dependent variable + P = CppAD::Poly(0, A, Z); + + // Taylor-expand P to degree one + P.eval(2); + + // second derivative is twice second order Taylor coefficient + ddp[0] = 2. * P[2]; + + // Free DAG corresponding to P does not seem to improve speed. + // Probably because it gets freed the next time P is assigned. + // P.reset(); + } + // ------------------------------------------------------ + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/fadbad/sparse_hessian.cpp cppad-2019.02.00.0/speed/fadbad/sparse_hessian.cpp --- cppad-2018.00.00.0/speed/fadbad/sparse_hessian.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/fadbad/sparse_hessian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,24 +1,24 @@ -// $Id: sparse_hessian.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include /* $begin fadbad_sparse_hessian.cpp$$ $spell - const - Fadbad - bool - CppAD + const + Fadbad + bool + CppAD $$ $section Fadbad Speed: Sparse Hessian$$ @@ -26,16 +26,16 @@ $srccode%cpp% */ // 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 , - size_t& n_sweep + size_t size , + size_t repeat , + const CppAD::vector& row , + const CppAD::vector& col , + CppAD::vector& x , + CppAD::vector& hessian , + size_t& n_sweep ) { - return false; + return false; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/fadbad/sparse_jacobian.cpp cppad-2019.02.00.0/speed/fadbad/sparse_jacobian.cpp --- cppad-2018.00.00.0/speed/fadbad/sparse_jacobian.cpp 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/fadbad/sparse_jacobian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,25 @@ -// $Id: sparse_jacobian.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include # include /* $begin fadbad_sparse_jacobian.cpp$$ $spell - const - bool - CppAD - fadbad - sparse_jacobian + const + bool + CppAD + fadbad + sparse_jacobian $$ $section fadbad Speed: sparse_jacobian$$ @@ -27,16 +27,16 @@ $srccode%cpp% */ // A fadbad version of this test is not yet available bool link_sparse_jacobian( - size_t size , - size_t repeat , - size_t m , - const CppAD::vector& row , - const CppAD::vector& col , - CppAD::vector& x , - CppAD::vector& jacobian , - size_t& n_sweep ) + size_t size , + size_t repeat , + size_t m , + const CppAD::vector& row , + const CppAD::vector& col , + CppAD::vector& x , + CppAD::vector& jacobian , + size_t& n_sweep ) { - return false; + return false; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/main.cpp cppad-2019.02.00.0/speed/main.cpp --- cppad-2018.00.00.0/speed/main.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/main.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include # include @@ -47,36 +48,35 @@ /* $begin speed_main$$ $spell - jac - subgraph - Jacobians - hes - subgraphs - subsparsity - revsparsity - colpack - onetape - boolsparsity - optionlist - underbar - alloc - mat_mul - retaped - bool - ddp - cppad - adolc - fadbad - sacado - CppAD - det - lu - Jacobian + jac + subgraph + Jacobians + hes + subgraphs + subsparsity + revsparsity + colpack + onetape + boolsparsity + optionlist + underbar + alloc + mat_mul + retaped + bool + ddp + cppad + adolc + fadbad + sacado + CppAD + det + lu + Jacobian $$ $section Running the Speed Test Program$$ -$mindex cppad uniform_01$$ $head Syntax$$ $codei%speed/%package%/speed_%package% %test% %seed% %option_list%$$ @@ -147,18 +147,18 @@ The random number simulator $cref uniform_01$$ is initialized with the call $codei% - uniform_01(%seed%) + uniform_01(%seed%) %$$ before any of the testing routines (listed above) are called. $head Global Options$$ This global variable has prototype $srccode%cpp% - extern std::map global_option; + extern std::map global_option; %$$ The syntax $codei% - global_option["%option%"] + global_option["%option%"] %$$ has the value true, if $icode option$$ is present, and false otherwise. @@ -211,7 +211,7 @@ $subhead atomic$$ If this option is present, CppAD will use a user defined -$cref/atomic/atomic_base/$$ operation is used for the test. +$cref/atomic/atomic_two/$$ operation is used for the test. So far, CppAD has only implemented the $cref/mat_mul/link_mat_mul/$$ test as an atomic operation. @@ -255,7 +255,8 @@ $subhead subsparsity$$ If this option is present, CppAD will use subgraphs to compute sparsity patterns. -If either the $code boolsparsity$$ or $code revsparsity$$ is also present, +If +$code boolsparsity$$, $code revsparsity$$, or $code colpack$$ is also present, the CppAD speed tests will return false; i.e., these options are not supported by $cref subgraph_sparsity$$. @@ -264,11 +265,20 @@ CppAD will use $cref/colpack/colpack_prefix/$$ to do the coloring. Otherwise, it will use it's own coloring algorithm. +$subhead symmetric$$ +If this option is present, CppAD will use a symmetric +$cref/coloring method/sparse_hessian/work/color_method/$$ +for computing Hessian sparsity patterns. +Otherwise, it will use a general coloring method. +The CppAD +$cref/sparse_hessian/link_sparse_hessian/$$ test +is implemented for this option. + $head Correctness Results$$ One, but not both, of the following two output lines $codei% - %package%_%test%_%optionlist%_available = false - %package%_%test%_%optionlist%_ok = %flag% + %package%_%test%_%optionlist%_available = false + %package%_%test%_%optionlist%_ok = %flag% %$$ is generated for each correctness test where $icode package$$ and $icode test$$ are as above, @@ -281,9 +291,9 @@ For each speed test, corresponds to three lines of the following form are generated: $codei% - %package%_%test%_%optionlist%_ok = %flag% - %package%_%test%_size = [ %size_1%, %...%, %size_n% ] - %package%_%test%_rate = [ %rate_1%, %...%, %rate_n% ] + %package%_%test%_%optionlist%_ok = %flag% + %package%_%test%_size = [ %size_1%, %...%, %size_n% ] + %package%_%test%_rate = [ %rate_1%, %...%, %rate_n% ] %$$ The values $icode package$$, $icode test$$, $icode optionlist$$, and $icode flag$$ are as in the correctness results above. @@ -297,7 +307,7 @@ and $cref/sparse_hessian/link_sparse_hessian/$$ tests has an extra output line with the following form $codei% - %package%_sparse_%test%_n_sweep = [ %n_sweep_1%, %...%, %n_sweep_n% ] + %package%_sparse_%test%_n_sweep = [ %n_sweep_1%, %...%, %n_sweep_n% ] %$$ were $icode test$$ is $code jacobian$$ ($code hessian$$). The values $icode n_sweep_1$$, ..., $icode n_sweep_n$$ are the number of @@ -308,14 +318,14 @@ $children% - speed/src/link_det_lu.cpp% - speed/src/link_det_minor.cpp% - speed/src/link_mat_mul.cpp% - speed/src/link_ode.cpp% - speed/src/link_poly.cpp% - speed/src/link_sparse_hessian.cpp% - speed/src/link_sparse_jacobian.cpp% - speed/src/microsoft_timer.cpp + speed/src/link_det_lu.cpp% + speed/src/link_det_minor.cpp% + speed/src/link_mat_mul.cpp% + speed/src/link_ode.cpp% + speed/src/link_poly.cpp% + speed/src/link_sparse_hessian.cpp% + speed/src/link_sparse_jacobian.cpp% + speed/src/microsoft_timer.cpp %$$ $head Link Functions$$ @@ -358,434 +368,447 @@ // -------------------------------------------------------------------------- std::map global_option; // -------------------------------------------------------------------------- +// If return value for the previous CppAD speed test was false, this is zero. +// Otherwise it is value returned by by CppAD::thread_alloc::inuse for the +// current thread at end of the test. +size_t global_cppad_thread_alloc_inuse = 0; +// -------------------------------------------------------------------------- namespace { - using std::cout; - using std::endl; - const char* option_list[] = { - "memory", - "onetape", - "optimize", - "atomic", - "hes2jac", - "subgraph", - "boolsparsity", - "revsparsity", - "subsparsity", - "colpack" - }; - size_t num_option = sizeof(option_list) / sizeof( option_list[0] ); - // ---------------------------------------------------------------- - // not available test message - void not_available_message(const char* test_name) - { cout << AD_PACKAGE << ": " << test_name; - cout << " is not availabe with " << endl; - int max_len = 0; - for(size_t i = 0; i < num_option; i++) - { int len = int( std::strlen( option_list[i] ) ); - max_len = std::max( max_len, len); - } - for(size_t i = 0; i < num_option; i++) - { std::string option = option_list[i]; - if( global_option[option] ) - cout << std::setw(max_len + 1) << option << " = true\n"; - else - cout << std::setw(max_len + 1) << option << " = false\n"; - } - } - // ------------------------------------------------------ - // output vector in form readable by octave or matlab - // convert size_t to int to avoid warning by MS compiler - void output(const CppAD::vector &v) - { size_t i= 0, n = v.size(); - cout << "[ "; - while(i < n) - { cout << int(v[i++]); - if( i < n ) - cout << ", "; - } - cout << " ]"; - } - - // ---------------------------------------------------------------- - // function that runs one correctness case - static size_t Run_ok_count = 0; - static size_t Run_error_count = 0; - bool run_correct( - bool available_case(void) , - bool correct_case(bool) , - const char *case_name ) - { bool available = available_case(); - bool ok = true; - if( available ) - { + using std::cout; + using std::endl; + const char* option_list[] = { + "memory", + "onetape", + "optimize", + "atomic", + "hes2jac", + "subgraph", + "boolsparsity", + "revsparsity", + "subsparsity", + "colpack", + "symmetric" + }; + size_t num_option = sizeof(option_list) / sizeof( option_list[0] ); + // ---------------------------------------------------------------- + // not available test message + void not_available_message(const char* test_name) + { cout << AD_PACKAGE << ": " << test_name; + cout << " is not availabe with " << endl; + int max_len = 0; + for(size_t i = 0; i < num_option; i++) + { int len = int( std::strlen( option_list[i] ) ); + max_len = std::max( max_len, len); + } + for(size_t i = 0; i < num_option; i++) + { std::string option = option_list[i]; + if( global_option[option] ) + cout << std::setw(max_len + 1) << option << " = true\n"; + else + cout << std::setw(max_len + 1) << option << " = false\n"; + } + } + // ------------------------------------------------------ + // output vector in form readable by octave or matlab + // convert size_t to int to avoid warning by MS compiler + void output(const CppAD::vector &v) + { size_t i= 0, n = v.size(); + cout << "[ "; + while(i < n) + { cout << int(v[i++]); + if( i < n ) + cout << ", "; + } + cout << " ]"; + } + + // ---------------------------------------------------------------- + // function that runs one correctness case + static size_t Run_ok_count = 0; + static size_t Run_error_count = 0; + bool run_correct( + bool available_case(void) , + bool correct_case(bool) , + const char *case_name ) + { bool available = available_case(); + bool ok = true; + if( available ) + { # ifdef CPPAD_DOUBLE_SPEED - ok = correct_case(true); + ok = correct_case(true); # else - ok = correct_case(false); + ok = correct_case(false); # endif - } - cout << AD_PACKAGE << "_" << case_name; - for(size_t i = 0; i < num_option; i++) - { std::string option = option_list[i]; - if( global_option[option] ) - cout << "_" << option; - } - if( ! available ) - { cout << "_available = false" << endl; - return ok; - } - cout << "_ok = "; - if( ok ) - { cout << " true" << endl; - Run_ok_count++; - } - else - { cout << " false" << endl; - Run_error_count++; - } - return ok; - } - // ---------------------------------------------------------------- - // function that runs one speed case - void run_speed( - void speed_case(size_t size, size_t repeat) , - const CppAD::vector& size_vec , - const std::string& case_name ) - { double time_min = 1.; - cout << AD_PACKAGE << "_" << case_name << "_size = "; - output(size_vec); - cout << endl; - cout << AD_PACKAGE << "_" << case_name << "_rate = "; - cout << std::fixed; - for(size_t i = 0; i < size_vec.size(); i++) - { if( i == 0 ) - cout << "[ "; - else cout << ", "; - cout << std::flush; - size_t size = size_vec[i]; - double time = CppAD::time_test(speed_case, time_min, size); - double rate = 1. / time; - if( rate >= 1000 ) - cout << std::setprecision(0) << rate; - else cout << std::setprecision(2) << rate; - } - cout << " ]" << endl; - // - // free statically allocated memory (size = repeat = 0) - speed_case(0, 0); - return; - } + } + cout << AD_PACKAGE << "_" << case_name; + for(size_t i = 0; i < num_option; i++) + { std::string option = option_list[i]; + if( global_option[option] ) + cout << "_" << option; + } + if( ! available ) + { cout << "_available = false" << endl; + return ok; + } + cout << "_ok = "; + if( ok ) + { cout << " true" << endl; + Run_ok_count++; + } + else + { cout << " false" << endl; + Run_error_count++; + } + return ok; + } + // ---------------------------------------------------------------- + // function that runs one speed case + void run_speed( + void speed_case(size_t size, size_t repeat) , + const CppAD::vector& size_vec , + const std::string& case_name ) + { double time_min = 1.; + cout << AD_PACKAGE << "_" << case_name << "_size = "; + output(size_vec); + cout << endl; + cout << AD_PACKAGE << "_" << case_name << "_rate = "; + cout << std::fixed; + for(size_t i = 0; i < size_vec.size(); i++) + { if( i == 0 ) + cout << "[ "; + else + cout << ", "; + cout << std::flush; + size_t size = size_vec[i]; + double time = CppAD::time_test(speed_case, time_min, size); + double rate = 1. / time; + if( rate >= 1000 ) + cout << std::setprecision(0) << rate; + else cout << std::setprecision(2) << rate; + } + cout << " ]" << endl; + // + // free statically allocated memory (size = repeat = 0) + speed_case(0, 0); + return; + } } // main program that runs all the tests int main(int argc, char *argv[]) -{ bool ok = true; - enum test_enum { - test_correct, - test_speed, - test_det_lu, - test_det_minor, - test_mat_mul, - test_ode, - test_poly, - test_sparse_hessian, - test_sparse_jacobian, - test_error - }; - struct test_struct { - const char *name; - const test_enum index; - }; - const test_struct test_list[]= { - { "correct", test_correct }, - { "speed", test_speed }, - { "det_lu", test_det_lu }, - { "det_minor", test_det_minor }, - { "mat_mul", test_mat_mul }, - { "ode", test_ode }, - { "poly", test_poly }, - { "sparse_hessian", test_sparse_hessian }, - { "sparse_jacobian", test_sparse_jacobian } - }; - const size_t n_test = sizeof(test_list) / sizeof(test_list[0]); - - test_enum match = test_error; - int iseed = 0; - bool error = argc < 3; - if( ! error ) - { for(size_t i = 0; i < n_test; i++) - if( strcmp(test_list[i].name, argv[1]) == 0 ) - match = test_list[i].index; - error = match == test_error; - for(size_t i = 0; *(argv[2] + i) != '\0'; ++i) - { error |= *(argv[2] + i) < '0'; - error |= '9' < *(argv[2] + i); - } - iseed = std::atoi( argv[2] ); - error |= iseed < 0; - for(size_t i = 0; i < num_option; i++) - global_option[ option_list[i] ] = false; - for(size_t i = 3; i < size_t(argc); i++) - { bool found = false; - for(size_t j = 0; j < num_option; j++) - { if( strcmp(argv[i], option_list[j]) == 0 ) - { global_option[ option_list[j] ] = true; - found = true; - } - } - error |= ! found; - } - } - if( error ) - { cout << "usage: ./speed_" - << AD_PACKAGE << " test seed option_list" << endl; - cout << "test choices:"; - for(size_t i = 0; i < n_test; i++) - { if( i % 5 == 0 ) - std::cout << "\n\t"; - else - std::cout << ", "; - cout << test_list[i].name; - } - cout << "\n\nseed: is a positive integer used as a random seed."; - cout << "\n\noption_list: zero or more of the following:"; - for(size_t i = 0; i < num_option; i++) - { if( i % 5 == 0 ) - std::cout << "\n\t"; - else - std::cout << ", "; - cout << option_list[i]; - } - cout << endl << endl; - return 1; - } - if( global_option["memory"] ) - CppAD::thread_alloc::hold_memory(true); - - // initialize the random number simulator - CppAD::uniform_01(size_t(iseed)); - - // arguments needed for speed tests - size_t n_size = 5; - CppAD::vector size_det_lu(n_size); - CppAD::vector size_det_minor(n_size); - CppAD::vector size_mat_mul(n_size); - CppAD::vector size_ode(n_size); - CppAD::vector size_poly(n_size); - CppAD::vector size_sparse_hessian(n_size); - CppAD::vector size_sparse_jacobian(n_size); - for(size_t 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; - size_ode[i] = 10 * i + 1; - size_poly[i] = 10 * i + 1; - size_sparse_hessian[i] = 150 * (i + 1) * (i + 1); - size_sparse_jacobian[i] = 150 * (i + 1) * (i + 1); - } - - switch(match) - { - // run all the correctness tests - case test_correct: - ok &= run_correct( available_det_lu, correct_det_lu, "det_lu" - ); - ok &= run_correct( - available_det_minor, correct_det_minor, "det_minor" - ); - ok &= run_correct( - available_mat_mul, correct_mat_mul, "mat_mul" - ); - ok &= run_correct( - available_ode, correct_ode, "ode" - ); - ok &= run_correct( available_poly, correct_poly, "poly" - ); - ok &= run_correct( - available_sparse_hessian, - correct_sparse_hessian, - "sparse_hessian" - ); - ok &= run_correct( - available_sparse_jacobian, - correct_sparse_jacobian, - "sparse_jacobian" - ); - // summarize results - assert( ok || (Run_error_count > 0) ); - if( ok ) - { cout << "All " << int(Run_ok_count) - << " correctness tests passed." << endl; - } - else - { cout << int(Run_error_count) - << " correctness tests failed." << endl; - } - break; - // --------------------------------------------------------- - // run all the speed tests - case test_speed: - if( available_det_lu() ) run_speed( - speed_det_lu, size_det_lu, "det_lu" - ); - if( available_det_minor() ) run_speed( - speed_det_minor, size_det_minor, "det_minor" - ); - if( available_mat_mul() ) run_speed( - speed_mat_mul, size_mat_mul, "mat_mul" - ); - if( available_ode() ) run_speed( - speed_ode, size_ode, "ode" - ); - if( available_poly() ) run_speed( - speed_poly, size_poly, "poly" - ); - if( available_sparse_hessian() ) run_speed( - speed_sparse_hessian, size_sparse_hessian, "sparse_hessian" - ); - if( available_sparse_jacobian() ) run_speed( - speed_sparse_jacobian, size_sparse_jacobian, "sparse_jacobian" - ); - ok = true; - break; - // --------------------------------------------------------- - - case test_det_lu: - if( ! available_det_lu() ) - { not_available_message( argv[1] ); - exit(1); - } - ok &= run_correct( - available_det_lu, correct_det_lu, "det_lu") - ; - run_speed(speed_det_lu, size_det_lu, "det_lu"); - break; - // --------------------------------------------------------- - - case test_det_minor: - if( ! available_det_minor() ) - { not_available_message( argv[1] ); - exit(1); - } - ok &= run_correct( - available_det_minor, correct_det_minor, "det_minor" - ); - run_speed(speed_det_minor, size_det_minor, "det_minor"); - break; - // --------------------------------------------------------- - - case test_mat_mul: - if( ! available_mat_mul() ) - { not_available_message( argv[1] ); - exit(1); - } - ok &= run_correct( - available_mat_mul, correct_mat_mul, "mat_mul" - ); - run_speed(speed_mat_mul, size_mat_mul, "mat_mul"); - break; - // --------------------------------------------------------- - - case test_ode: - if( ! available_ode() ) - { not_available_message( argv[1] ); - exit(1); - } - ok &= run_correct( - available_ode, correct_ode, "ode" - ); - run_speed(speed_ode, size_ode, "ode"); - break; - // --------------------------------------------------------- - - case test_poly: - if( ! available_poly() ) - { not_available_message( argv[1] ); - exit(1); - } - ok &= run_correct( - available_poly, correct_poly, "poly" - ); - run_speed(speed_poly, size_poly, "poly"); - break; - // --------------------------------------------------------- - - case test_sparse_hessian: - if( ! available_sparse_hessian() ) - { not_available_message( argv[1] ); - exit(1); - } - ok &= run_correct( - available_sparse_hessian, - correct_sparse_hessian, - "sparse_hessian" - ); - run_speed( - speed_sparse_hessian, size_sparse_hessian, "sparse_hessian" - ); - cout << AD_PACKAGE << "_sparse_hessian_sweep = "; - for(size_t 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] ); - exit(1); - } - ok &= run_correct( - available_sparse_jacobian, - correct_sparse_jacobian, - "sparse_jacobian" - ); - run_speed( - speed_sparse_jacobian, size_sparse_jacobian, "sparse_jacobian" - ); - cout << AD_PACKAGE << "_sparse_jacobian_n_sweep = "; - for(size_t i = 0; i < size_sparse_jacobian.size(); i++) - { if( i == 0 ) - cout << "[ "; - else cout << ", "; - size_t n_sweep; - info_sparse_jacobian(size_sparse_jacobian[i], n_sweep); - cout << n_sweep; - } - cout << " ]" << endl; - break; - // --------------------------------------------------------- - - default: - assert(0); - } +{ bool ok = true; + enum test_enum { + test_correct, + test_speed, + test_det_lu, + test_det_minor, + test_mat_mul, + test_ode, + test_poly, + test_sparse_hessian, + test_sparse_jacobian, + test_error + }; + struct test_struct { + const char *name; + const test_enum index; + }; + const test_struct test_list[]= { + { "correct", test_correct }, + { "speed", test_speed }, + { "det_lu", test_det_lu }, + { "det_minor", test_det_minor }, + { "mat_mul", test_mat_mul }, + { "ode", test_ode }, + { "poly", test_poly }, + { "sparse_hessian", test_sparse_hessian }, + { "sparse_jacobian", test_sparse_jacobian } + }; + const size_t n_test = sizeof(test_list) / sizeof(test_list[0]); + + test_enum match = test_error; + int iseed = 0; + bool error = argc < 3; + if( ! error ) + { for(size_t i = 0; i < n_test; i++) + if( strcmp(test_list[i].name, argv[1]) == 0 ) + match = test_list[i].index; + error = match == test_error; + for(size_t i = 0; *(argv[2] + i) != '\0'; ++i) + { error |= *(argv[2] + i) < '0'; + error |= '9' < *(argv[2] + i); + } + iseed = std::atoi( argv[2] ); + error |= iseed < 0; + for(size_t i = 0; i < num_option; i++) + global_option[ option_list[i] ] = false; + for(size_t i = 3; i < size_t(argc); i++) + { bool found = false; + for(size_t j = 0; j < num_option; j++) + { if( strcmp(argv[i], option_list[j]) == 0 ) + { global_option[ option_list[j] ] = true; + found = true; + } + } + error |= ! found; + } + } + if( error ) + { cout << "usage: ./speed_" + << AD_PACKAGE << " test seed option_list" << endl; + cout << "test choices:"; + for(size_t i = 0; i < n_test; i++) + { if( i % 5 == 0 ) + std::cout << "\n\t"; + else + std::cout << ", "; + cout << test_list[i].name; + } + cout << "\n\nseed: is a positive integer used as a random seed."; + cout << "\n\noption_list: zero or more of the following:"; + for(size_t i = 0; i < num_option; i++) + { if( i % 5 == 0 ) + std::cout << "\n\t"; + else + std::cout << ", "; + cout << option_list[i]; + } + cout << endl << endl; + return 1; + } + if( global_option["memory"] ) + CppAD::thread_alloc::hold_memory(true); + + // initialize the random number simulator + CppAD::uniform_01(size_t(iseed)); + + // arguments needed for speed tests + size_t n_size = 5; + CppAD::vector size_det_lu(n_size); + CppAD::vector size_det_minor(n_size); + CppAD::vector size_mat_mul(n_size); + CppAD::vector size_ode(n_size); + CppAD::vector size_poly(n_size); + CppAD::vector size_sparse_hessian(n_size); + CppAD::vector size_sparse_jacobian(n_size); + for(size_t 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; + size_ode[i] = 10 * i + 1; + size_poly[i] = 10 * i + 1; + size_sparse_hessian[i] = 150 * (i + 1) * (i + 1); + size_sparse_jacobian[i] = 150 * (i + 1) * (i + 1); + } + + switch(match) + { + // run all the correctness tests + case test_correct: + ok &= run_correct( available_det_lu, correct_det_lu, "det_lu" + ); + ok &= run_correct( + available_det_minor, correct_det_minor, "det_minor" + ); + ok &= run_correct( + available_mat_mul, correct_mat_mul, "mat_mul" + ); + ok &= run_correct( + available_ode, correct_ode, "ode" + ); + ok &= run_correct( available_poly, correct_poly, "poly" + ); + ok &= run_correct( + available_sparse_hessian, + correct_sparse_hessian, + "sparse_hessian" + ); + ok &= run_correct( + available_sparse_jacobian, + correct_sparse_jacobian, + "sparse_jacobian" + ); + // summarize results + assert( ok || (Run_error_count > 0) ); + if( ok ) + { cout << "All " << int(Run_ok_count) + << " correctness tests passed." << endl; + } + else + { cout << int(Run_error_count) + << " correctness tests failed." << endl; + } + break; + // --------------------------------------------------------- + // run all the speed tests + case test_speed: + if( available_det_lu() ) run_speed( + speed_det_lu, size_det_lu, "det_lu" + ); + if( available_det_minor() ) run_speed( + speed_det_minor, size_det_minor, "det_minor" + ); + if( available_mat_mul() ) run_speed( + speed_mat_mul, size_mat_mul, "mat_mul" + ); + if( available_ode() ) run_speed( + speed_ode, size_ode, "ode" + ); + if( available_poly() ) run_speed( + speed_poly, size_poly, "poly" + ); + if( available_sparse_hessian() ) run_speed( + speed_sparse_hessian, size_sparse_hessian, "sparse_hessian" + ); + if( available_sparse_jacobian() ) run_speed( + speed_sparse_jacobian, size_sparse_jacobian, "sparse_jacobian" + ); + ok = true; + break; + // --------------------------------------------------------- + + case test_det_lu: + if( ! available_det_lu() ) + { not_available_message( argv[1] ); + exit(1); + } + ok &= run_correct( + available_det_lu, correct_det_lu, "det_lu") + ; + run_speed(speed_det_lu, size_det_lu, "det_lu"); + break; + // --------------------------------------------------------- + + case test_det_minor: + if( ! available_det_minor() ) + { not_available_message( argv[1] ); + exit(1); + } + ok &= run_correct( + available_det_minor, correct_det_minor, "det_minor" + ); + run_speed(speed_det_minor, size_det_minor, "det_minor"); + break; + // --------------------------------------------------------- + + case test_mat_mul: + if( ! available_mat_mul() ) + { not_available_message( argv[1] ); + exit(1); + } + ok &= run_correct( + available_mat_mul, correct_mat_mul, "mat_mul" + ); + run_speed(speed_mat_mul, size_mat_mul, "mat_mul"); + break; + // --------------------------------------------------------- + + case test_ode: + if( ! available_ode() ) + { not_available_message( argv[1] ); + exit(1); + } + ok &= run_correct( + available_ode, correct_ode, "ode" + ); + run_speed(speed_ode, size_ode, "ode"); + break; + // --------------------------------------------------------- + + case test_poly: + if( ! available_poly() ) + { not_available_message( argv[1] ); + exit(1); + } + ok &= run_correct( + available_poly, correct_poly, "poly" + ); + run_speed(speed_poly, size_poly, "poly"); + break; + // --------------------------------------------------------- + + case test_sparse_hessian: + if( ! available_sparse_hessian() ) + { not_available_message( argv[1] ); + exit(1); + } + ok &= run_correct( + available_sparse_hessian, + correct_sparse_hessian, + "sparse_hessian" + ); + run_speed( + speed_sparse_hessian, size_sparse_hessian, "sparse_hessian" + ); + cout << AD_PACKAGE << "_sparse_hessian_sweep = "; + for(size_t 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] ); + exit(1); + } + ok &= run_correct( + available_sparse_jacobian, + correct_sparse_jacobian, + "sparse_jacobian" + ); + run_speed( + speed_sparse_jacobian, size_sparse_jacobian, "sparse_jacobian" + ); + cout << AD_PACKAGE << "_sparse_jacobian_n_sweep = "; + for(size_t i = 0; i < size_sparse_jacobian.size(); i++) + { if( i == 0 ) + cout << "[ "; + else + cout << ", "; + size_t n_sweep; + info_sparse_jacobian(size_sparse_jacobian[i], n_sweep); + cout << n_sweep; + } + cout << " ]" << endl; + break; + // --------------------------------------------------------- + + default: + assert(0); + } # ifndef NDEBUG - // return memory for vectors that are still in scope - size_det_lu.clear(); - size_det_minor.clear(); - size_mat_mul.clear(); - size_ode.clear(); - size_poly.clear(); - size_sparse_hessian.clear(); - size_sparse_jacobian.clear(); - // check for memory leak - if( CppAD::thread_alloc::free_all() ) - { Run_ok_count++; - cout << "No memory leak detected" << endl; - } - else - { ok = false; - Run_error_count++; - cout << "Memory leak detected" << endl; - } + // return memory for vectors that are still in scope + size_det_lu.clear(); + size_det_minor.clear(); + size_mat_mul.clear(); + size_ode.clear(); + size_poly.clear(); + size_sparse_hessian.clear(); + size_sparse_jacobian.clear(); + // check for memory leak + if( CppAD::thread_alloc::free_all() ) + { Run_ok_count++; + cout << "No memory leak detected" << endl; + } + else + { ok = false; + Run_error_count++; + cout << "Memory leak detected" << endl; + } # endif - return static_cast( ! ok ); + if( global_cppad_thread_alloc_inuse != 0 ) + { cout << "memory allocated at end of last cppad speed test = "; + cout << global_cppad_thread_alloc_inuse << std::endl; + } + return static_cast( ! ok ); } diff -Nru cppad-2018.00.00.0/speed/profile/CMakeLists.txt cppad-2019.02.00.0/speed/profile/CMakeLists.txt --- cppad-2018.00.00.0/speed/profile/CMakeLists.txt 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/profile/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the speed/profile directory tests # Inherit build type from ../CMakeList.txt @@ -26,21 +27,21 @@ # source1 source2 ... sourceN # ) SET(source_list ../main.cpp - ../cppad/ode.cpp - ../cppad/det_lu.cpp - ../cppad/det_minor.cpp - ../cppad/mat_mul.cpp - ../cppad/poly.cpp - ../cppad/sparse_hessian.cpp - ../cppad/sparse_jacobian.cpp - ../src/link_det_lu.cpp - ../src/link_det_minor.cpp - ../src/link_mat_mul.cpp - ../src/link_ode.cpp - ../src/link_poly.cpp - ../src/link_sparse_hessian.cpp - ../src/link_sparse_jacobian.cpp - ../src/microsoft_timer.cpp + ../include/cppad/ode.cpp + ../include/cppad/det_lu.cpp + ../include/cppad/det_minor.cpp + ../include/cppad/mat_mul.cpp + ../include/cppad/poly.cpp + ../include/cppad/sparse_hessian.cpp + ../include/cppad/sparse_jacobian.cpp + ../src/link_det_lu.cpp + ../src/link_det_minor.cpp + ../src/link_mat_mul.cpp + ../src/link_ode.cpp + ../src/link_poly.cpp + ../src/link_sparse_hessian.cpp + ../src/link_sparse_jacobian.cpp + ../src/microsoft_timer.cpp ) set_compile_flags( speed_profile "${cppad_debug_which}" "${source_list}" ) # @@ -49,26 +50,26 @@ # 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 - ${cppad_lib} - ${colpack_libs} + ${cppad_lib} + ${colpack_libs} ) # Add the check_speed_profile target ADD_CUSTOM_TARGET(check_speed_profile - speed_profile correct 54321 - DEPENDS speed_profile + speed_profile correct 54321 + DEPENDS speed_profile ) MESSAGE(STATUS "make check_speed_profile: available") # Sed script to make gprof output more readable, use: -# ./speed_profile speed 54321 -# gprof speed_profile gmon.out | sed -f 'gprof.sed' > gprof.out +# ./speed_profile speed 54321 +# gprof speed_profile gmon.out | sed -f 'gprof.sed' > gprof.out # # configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) CONFIGURE_FILE( - ${CMAKE_CURRENT_SOURCE_DIR}/gprof.sed.in - ${CMAKE_CURRENT_BINARY_DIR}/gprof.sed - COPYONLY + ${CMAKE_CURRENT_SOURCE_DIR}/gprof.sed.in + ${CMAKE_CURRENT_BINARY_DIR}/gprof.sed + COPYONLY ) # Change check depends in parent environment diff -Nru cppad-2018.00.00.0/speed/profile/gprof.sed.in cppad-2019.02.00.0/speed/profile/gprof.sed.in --- cppad-2018.00.00.0/speed/profile/gprof.sed.in 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/profile/gprof.sed.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,14 +1,13 @@ #! /bin/bash -e -# $Id: gprof.sed.in 2506 2012-10-24 19:36:49Z bradbell $ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-11 Bradley M. Bell +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. # -# 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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # remove template information s/<[^<>]*>//g diff -Nru cppad-2018.00.00.0/speed/profile/makefile.am cppad-2019.02.00.0/speed/profile/makefile.am --- cppad-2018.00.00.0/speed/profile/makefile.am 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/profile/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,13 @@ -# $Id: makefile.am 3779 2016-01-01 11:26:11Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- source_list = \ main.cpp \ @@ -66,20 +66,18 @@ # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # -EXTRA_DIST = \ - gprof.sed # check_PROGRAMS = speed_profile # -AM_CPPFLAGS = -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # -# BEGIN OPTIMIZE -AM_CXXFLAGS = -pg -O2 -DCPPAD_PROFILE_SPEED -DNDEBUG $(CXX_FLAGS) -# END OPTIMIZE -# -# BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) -DCPPAD_PROFILE_SPEED -# END DEBUG +AM_CXXFLAGS = \ + -pg \ + -DCPPAD_PROFILE_SPEED \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) +# # AM_LDFLAGS = -pg # diff -Nru cppad-2018.00.00.0/speed/profile/makefile.in cppad-2019.02.00.0/speed/profile/makefile.in --- cppad-2018.00.00.0/speed/profile/makefile.in 2018-01-01 08:32:13.000000000 +0000 +++ cppad-2019.02.00.0/speed/profile/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -190,8 +190,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp @@ -263,10 +261,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -285,9 +281,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -310,8 +308,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -332,16 +328,16 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3973 2017-08-30 13:38:26Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- source_list = \ main.cpp \ @@ -365,19 +361,16 @@ # make separate copy of source files because building with different flags BUILT_SOURCES = $(source_list) # -EXTRA_DIST = \ - gprof.sed - -# -AM_CPPFLAGS = -I$(top_srcdir) $(BOOST_INCLUDE) $(EIGEN_INCLUDE) # -# BEGIN OPTIMIZE -AM_CXXFLAGS = -pg -O2 -DCPPAD_PROFILE_SPEED -DNDEBUG $(CXX_FLAGS) -# END OPTIMIZE +AM_CXXFLAGS = \ + -pg \ + -DCPPAD_PROFILE_SPEED \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + # -# BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) -DCPPAD_PROFILE_SPEED -# END DEBUG # AM_LDFLAGS = -pg # diff -Nru cppad-2018.00.00.0/speed/sacado/CMakeLists.txt cppad-2019.02.00.0/speed/sacado/CMakeLists.txt --- cppad-2018.00.00.0/speed/sacado/CMakeLists.txt 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/sacado/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,22 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the speed/sacado directory tests # Inherit build type from ../CMakeList.txt # assert sacado_prefix is defined IF ( NOT sacado_prefix ) - MESSAGE(FATAL_ERROR - "speed/sacado/CMakeLists.txt: sacado_prefix = ${sacado_prefix}" - ) + MESSAGE(FATAL_ERROR + "speed/sacado/CMakeLists.txt: sacado_prefix = ${sacado_prefix}" + ) ENDIF ( NOT sacado_prefix ) # Adds flags to the compiler command line for sources in the current directory @@ -30,13 +31,13 @@ # source1 source2 ... sourceN # ) SET(source_list ../main.cpp - det_lu.cpp - det_minor.cpp - mat_mul.cpp - ode.cpp - poly.cpp - sparse_hessian.cpp - sparse_jacobian.cpp + det_lu.cpp + det_minor.cpp + mat_mul.cpp + ode.cpp + poly.cpp + sparse_hessian.cpp + sparse_jacobian.cpp ) set_compile_flags( speed_sacado "${cppad_debug_which}" "${source_list}" ) # @@ -45,15 +46,15 @@ # determine libraries necessary to link Sacado SET(config_file "${sacado_prefix}/include/Makefile.export.Sacado") IF(NOT EXISTS ${config_file}) - MESSAGE(FATAL_ERROR + MESSAGE(FATAL_ERROR "the file sacado_prefix/include/Makefile.export.Sacado does not exist where sacado_prefix=${sacado_prefix}" - ) + ) ENDIF(NOT EXISTS ${config_file}) SET(cmd "grep" "Sacado_LIBRARIES=" "${config_file}") EXECUTE_PROCESS( - COMMAND ${cmd} - OUTPUT_VARIABLE temp1 + COMMAND ${cmd} + OUTPUT_VARIABLE temp1 ) STRING(REGEX REPLACE "Sacado_LIBRARIES= *-l" "" temp2 ${temp1}) STRING(STRIP ${temp2} temp3) @@ -62,15 +63,15 @@ # include the dl library if it is in the system path CHECK_LIBRARY_EXISTS( dl dlopen "${CMAKE_SYSTEM_LIBRARY_PATH}" dl_found ) IF( dl_found ) - TARGET_LINK_LIBRARIES(speed_sacado speed_src ${sacado_lib_list} dl) + TARGET_LINK_LIBRARIES(speed_sacado speed_src ${sacado_lib_list} dl) ELSE( dl_found ) - TARGET_LINK_LIBRARIES(speed_sacado speed_src ${sacado_lib_list}) + TARGET_LINK_LIBRARIES(speed_sacado speed_src ${sacado_lib_list}) ENDIF( dl_found ) # # Add the check_speed_sacado target ADD_CUSTOM_TARGET(check_speed_sacado - speed_sacado correct 54321 - DEPENDS speed_sacado speed_src + speed_sacado correct 54321 + DEPENDS speed_sacado speed_src ) MESSAGE(STATUS "make check_speed_sacado: available") diff -Nru cppad-2018.00.00.0/speed/sacado/det_lu.cpp cppad-2019.02.00.0/speed/sacado/det_lu.cpp --- cppad-2018.00.00.0/speed/sacado/det_lu.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/sacado/det_lu.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,35 +1,35 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sacado_det_lu.cpp$$ $spell - onetape - cppad - Lu - det - badiff.hpp - const - CppAD - typedef - diff - bool - srand - Sacado - ADvar - Tay - Gradcomp + onetape + cppad + Lu + det + badiff.hpp + const + CppAD + typedef + diff + bool + srand + Sacado + ADvar + Tay + Gradcomp $$ $section Sacado Speed: Gradient of Determinant Using Lu Factorization$$ -$mindex link_det_lu speed matrix factor$$ $head Specifications$$ @@ -51,50 +51,50 @@ extern std::map global_option; bool link_det_lu( - size_t size , - size_t repeat , - CppAD::vector &matrix , - CppAD::vector &gradient ) + size_t size , + size_t repeat , + CppAD::vector &matrix , + CppAD::vector &gradient ) { - // speed test global option values - if( global_option["onetape"] || global_option["atomic"] ) - return false; - if( global_option["memory"] || global_option["optimize"] ) - return false; - // ----------------------------------------------------- - // setup - // - // object for computing determinant - 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 - - // ------------------------------------------------------ - while(repeat--) - { // get the next matrix - CppAD::uniform_01(n, matrix); - - // set independent variable values - for(i = 0; i < n; i++) - A[i] = matrix[i]; - - // compute the determinant - detA = Det(A); - - // compute the gradient of detA - ADScalar::Gradcomp(); - - // evaluate and return gradient using reverse mode - for(i =0; i < n; i++) - gradient[i] = A[i].adj(); // partial detA w.r.t A[i] - } - // --------------------------------------------------------- - return true; + // speed test global option values + if( global_option["onetape"] || global_option["atomic"] ) + return false; + if( global_option["memory"] || global_option["optimize"] ) + return false; + // ----------------------------------------------------- + // setup + // + // object for computing determinant + 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 + + // ------------------------------------------------------ + while(repeat--) + { // get the next matrix + CppAD::uniform_01(n, matrix); + + // set independent variable values + for(i = 0; i < n; i++) + A[i] = matrix[i]; + + // compute the determinant + detA = Det(A); + + // compute the gradient of detA + ADScalar::Gradcomp(); + + // evaluate and return gradient using reverse mode + for(i =0; i < n; i++) + gradient[i] = A[i].adj(); // partial detA w.r.t A[i] + } + // --------------------------------------------------------- + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/sacado/det_minor.cpp cppad-2019.02.00.0/speed/sacado/det_minor.cpp --- cppad-2018.00.00.0/speed/sacado/det_minor.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/sacado/det_minor.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,32 +1,32 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sacado_det_minor.cpp$$ $spell - onetape - cppad - det - const - CppAD - typedef - diff - bool - srand - Sacado.hpp - ADvar - Gradcomp + onetape + cppad + det + const + CppAD + typedef + diff + bool + srand + Sacado.hpp + ADvar + Gradcomp $$ $section Sacado Speed: Gradient of Determinant by Minor Expansion$$ -$mindex link_det_minor speed$$ $head Specifications$$ @@ -48,50 +48,50 @@ extern std::map global_option; bool link_det_minor( - size_t size , - size_t repeat , - CppAD::vector &matrix , - CppAD::vector &gradient ) + size_t size , + size_t repeat , + CppAD::vector &matrix , + CppAD::vector &gradient ) { - // speed test global option values - if( global_option["atomic"] ) - return false; - if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] ) - return false; - // ----------------------------------------------------- - // setup - - // object for computing determinant - 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 - - // ------------------------------------------------------ - while(repeat--) - { // get the next matrix - CppAD::uniform_01(n, matrix); - - // set independent variable values - for(i = 0; i < n; i++) - A[i] = matrix[i]; - - // compute the determinant - detA = Det(A); - - // reverse mode compute gradient of last computed value; i.e., detA - ADScalar::Gradcomp(); - - // return gradient - for(i =0; i < n; i++) - gradient[i] = A[i].adj(); // partial detA w.r.t A[i] - } - // --------------------------------------------------------- - return true; + // speed test global option values + if( global_option["atomic"] ) + return false; + if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] ) + return false; + // ----------------------------------------------------- + // setup + + // object for computing determinant + 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 + + // ------------------------------------------------------ + while(repeat--) + { // get the next matrix + CppAD::uniform_01(n, matrix); + + // set independent variable values + for(i = 0; i < n; i++) + A[i] = matrix[i]; + + // compute the determinant + detA = Det(A); + + // reverse mode compute gradient of last computed value; i.e., detA + ADScalar::Gradcomp(); + + // return gradient + for(i =0; i < n; i++) + gradient[i] = A[i].adj(); // partial detA w.r.t A[i] + } + // --------------------------------------------------------- + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/sacado/makefile.am cppad-2019.02.00.0/speed/sacado/makefile.am --- cppad-2018.00.00.0/speed/sacado/makefile.am 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/sacado/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,13 @@ -# $Id: makefile.am 3945 2017-06-03 02:07:53Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory @@ -21,20 +21,18 @@ # check_PROGRAMS = speed_sacado # -AM_CPPFLAGS = \ - -I$(top_srcdir) \ +# +AM_CXXFLAGS = \ + -DCPPAD_SACADO_SPEED \ + \ + -DRAD_EQ_ALIAS \ + -DRAD_AUTO_AD_Const \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ -I$(SACADO_DIR)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) # -# BEGIN OPTIMIZE -AM_CXXFLAGS = -O2 -DNDEBUG -DCPPAD_SACADO_SPEED \ - -DRAD_EQ_ALIAS -DRAD_AUTO_AD_Const $(CXX_FLAGS) -# END OPTIMIZE -# -# BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) $(CXX_FLAGS) -DCPPAD_SACADO_SPEED -DRAD_AUTO_AD_Const -# END DEBUG # LDADD = -lspeed -lsacado -lteuchoscore AM_LDFLAGS = -L../src -L$(SACADO_DIR)/lib -L$(SACADO_DIR)/lib64 diff -Nru cppad-2018.00.00.0/speed/sacado/makefile.in cppad-2019.02.00.0/speed/sacado/makefile.in --- cppad-2018.00.00.0/speed/sacado/makefile.in 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/sacado/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -186,8 +186,6 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # # @@ -260,10 +258,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -282,9 +278,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -307,8 +305,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -329,37 +325,34 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -# $Id: makefile.in 3973 2017-08-30 13:38:26Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # # Copy source file so that main.o does not end up in parent directory BUILT_SOURCES = main.cpp # -AM_CPPFLAGS = \ - -I$(top_srcdir) \ +# +AM_CXXFLAGS = \ + -DCPPAD_SACADO_SPEED \ + \ + -DRAD_EQ_ALIAS \ + -DRAD_AUTO_AD_Const \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ -I$(SACADO_DIR)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) # -# BEGIN OPTIMIZE -AM_CXXFLAGS = -O2 -DNDEBUG -DCPPAD_SACADO_SPEED \ - -DRAD_EQ_ALIAS -DRAD_AUTO_AD_Const $(CXX_FLAGS) - -# END OPTIMIZE -# -# BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) $(CXX_FLAGS) -DCPPAD_SACADO_SPEED -DRAD_AUTO_AD_Const -# END DEBUG # LDADD = -lspeed -lsacado -lteuchoscore AM_LDFLAGS = -L../src -L$(SACADO_DIR)/lib -L$(SACADO_DIR)/lib64 diff -Nru cppad-2018.00.00.0/speed/sacado/mat_mul.cpp cppad-2019.02.00.0/speed/sacado/mat_mul.cpp --- cppad-2018.00.00.0/speed/sacado/mat_mul.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/sacado/mat_mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,31 +1,31 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sacado_mat_mul.cpp$$ $spell - sq - onetape - typedef - ADvar - Gradcomp - Sacado - cppad.hpp - bool - mul - dz - CppAD + sq + onetape + typedef + ADvar + Gradcomp + Sacado + cppad.hpp + bool + mul + dz + CppAD $$ $section Sacado Speed: Matrix Multiplication$$ -$mindex link_mat_mul speed multiply$$ $head Specifications$$ @@ -47,57 +47,57 @@ extern std::map global_option; bool link_mat_mul( - size_t size , - size_t repeat , - CppAD::vector& x , - CppAD::vector& z , - CppAD::vector& dz ) + size_t size , + size_t repeat , + CppAD::vector& x , + CppAD::vector& z , + CppAD::vector& dz ) { - // speed test global option values - if( global_option["memory"] || global_option["onetape"] || global_option["atomic"] || global_option["optimize"] ) - return false; - // ----------------------------------------------------- - // setup - - // object for computing determinant - typedef Sacado::Rad::ADvar ADScalar; - typedef CppAD::vector ADVector; - - size_t j; // temporary index - size_t m = 1; // number of dependent variables - size_t n = size * size; // number of independent variables - ADVector X(n); // AD domain space vector - ADVector Y(n); // Store product matrix - ADVector Z(m); // AD range space vector - ADScalar f; - - // ------------------------------------------------------ - while(repeat--) - { // get the next matrix - CppAD::uniform_01(n, x); - - // set independent variable values - for(j = 0; j < n; j++) - X[j] = x[j]; - - // do the computation - mat_sum_sq(size, X, Y, Z); - - // create function object f : X -> Z - f = Z[0]; - - // reverse mode gradient of last ADvar computed value; i.e., f - ADScalar::Gradcomp(); - - // return gradient - for(j = 0; j < n; j++) - dz[j] = X[j].adj(); // partial f w.r.t X[j] - } - // return function value - z[0] = f.val(); + // speed test global option values + if( global_option["memory"] || global_option["onetape"] || global_option["atomic"] || global_option["optimize"] ) + return false; + // ----------------------------------------------------- + // setup + + // object for computing determinant + typedef Sacado::Rad::ADvar ADScalar; + typedef CppAD::vector ADVector; + + size_t j; // temporary index + size_t m = 1; // number of dependent variables + size_t n = size * size; // number of independent variables + ADVector X(n); // AD domain space vector + ADVector Y(n); // Store product matrix + ADVector Z(m); // AD range space vector + ADScalar f; + + // ------------------------------------------------------ + while(repeat--) + { // get the next matrix + CppAD::uniform_01(n, x); + + // set independent variable values + for(j = 0; j < n; j++) + X[j] = x[j]; + + // do the computation + mat_sum_sq(size, X, Y, Z); + + // create function object f : X -> Z + f = Z[0]; + + // reverse mode gradient of last ADvar computed value; i.e., f + ADScalar::Gradcomp(); + + // return gradient + for(j = 0; j < n; j++) + dz[j] = X[j].adj(); // partial f w.r.t X[j] + } + // return function value + z[0] = f.val(); - // --------------------------------------------------------- - return true; + // --------------------------------------------------------- + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/sacado/ode.cpp cppad-2019.02.00.0/speed/sacado/ode.cpp --- cppad-2018.00.00.0/speed/sacado/ode.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/sacado/ode.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,30 +1,30 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sacado_ode.cpp$$ $spell - jacobian - Sacado - cppad - hpp - bool - onetape - CppAD - typedef - endif - cassert + jacobian + Sacado + cppad + hpp + bool + onetape + CppAD + typedef + endif + cassert $$ $section Sacado Speed: Gradient of Ode Solution$$ -$mindex link_ode speed$$ $head Specifications$$ @@ -47,50 +47,50 @@ extern std::map global_option; bool link_ode( - size_t size , - size_t repeat , - CppAD::vector &x , - CppAD::vector &jacobian + size_t size , + size_t repeat , + CppAD::vector &x , + CppAD::vector &jacobian ) { - // speed test global option values - if( global_option["atomic"] ) - return false; - if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] ) - return false; - // ------------------------------------------------------------- - // setup - assert( x.size() == size ); - assert( jacobian.size() == size * size ); - - typedef Sacado::Fad::DFad ADScalar; - typedef CppAD::vector ADVector; - - size_t i, j; - size_t p = 0; // use ode to calculate function values - size_t n = size; // number of independent variables - size_t m = n; // number of dependent variables - ADVector X(n), Y(m); // independent and dependent variables - - // ------------------------------------------------------------- - while(repeat--) - { // choose next x value - CppAD::uniform_01(n, x); - for(j = 0; j < n; j++) - { // set up for X as the independent variable vector - X[j] = ADScalar(int(n), int(j), x[j]); - } - - // evaluate function - CppAD::ode_evaluate(X, p, Y); - - // return values with Y as the dependent variable vector - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - jacobian[ i * n + j ] = Y[i].dx(j); - } - } - return true; + // speed test global option values + if( global_option["atomic"] ) + return false; + if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] ) + return false; + // ------------------------------------------------------------- + // setup + assert( x.size() == size ); + assert( jacobian.size() == size * size ); + + typedef Sacado::Fad::DFad ADScalar; + typedef CppAD::vector ADVector; + + size_t i, j; + size_t p = 0; // use ode to calculate function values + size_t n = size; // number of independent variables + size_t m = n; // number of dependent variables + ADVector X(n), Y(m); // independent and dependent variables + + // ------------------------------------------------------------- + while(repeat--) + { // choose next x value + CppAD::uniform_01(n, x); + for(j = 0; j < n; j++) + { // set up for X as the independent variable vector + X[j] = ADScalar(int(n), int(j), x[j]); + } + + // evaluate function + CppAD::ode_evaluate(X, p, Y); + + // return values with Y as the dependent variable vector + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + jacobian[ i * n + j ] = Y[i].dx(j); + } + } + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/sacado/poly.cpp cppad-2019.02.00.0/speed/sacado/poly.cpp --- cppad-2018.00.00.0/speed/sacado/poly.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/sacado/poly.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,41 +1,41 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sacado_poly.cpp$$ $spell - onetape - cppad - cpp - tadiff - ddp - Taylor - dz - eval - cppad - vector Vector - typedef - sacado - Lu - CppAD - det - hpp - const - bool - Tay - resize - Coeff + onetape + cppad + cpp + tadiff + ddp + Taylor + dz + eval + cppad + vector Vector + typedef + sacado + Lu + CppAD + det + hpp + const + bool + Tay + resize + Coeff $$ $section Sacado Speed: Second Derivative of a Polynomial$$ -$mindex link_poly speed$$ $head Specifications$$ @@ -58,53 +58,53 @@ extern std::map global_option; bool link_poly( - 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 + 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 { - if( global_option["atomic"] ) - return false; - if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] ) - return false; - // ----------------------------------------------------- - // setup - typedef Sacado::Tay::Taylor ADScalar; - CppAD::vector A(size); - - size_t i; // temporary index - ADScalar Z; // domain 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); - - // choose the polynomial coefficients - CppAD::uniform_01(size, a); - - // AD copy of the polynomial coefficients - for(i = 0; i < size; i++) - A[i] = a[i]; - - // ------------------------------------------------------ - while(repeat--) - { // get the next argument value - CppAD::uniform_01(1, z); - - // independent variable value - Z.fastAccessCoeff(0) = z[0]; // argument value - Z.fastAccessCoeff(1) = 1.; // first order coefficient - Z.fastAccessCoeff(2) = 0.; // second order coefficient - - // AD computation of the dependent variable - P = CppAD::Poly(0, A, Z); - - // second derivative is twice second order Taylor coefficient - ddp[0] = 2. * P.fastAccessCoeff(2); - } - // ------------------------------------------------------ - return true; + if( global_option["atomic"] ) + return false; + if( global_option["memory"] || global_option["onetape"] || global_option["optimize"] ) + return false; + // ----------------------------------------------------- + // setup + typedef Sacado::Tay::Taylor ADScalar; + CppAD::vector A(size); + + size_t i; // temporary index + ADScalar Z; // domain 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); + + // choose the polynomial coefficients + CppAD::uniform_01(size, a); + + // AD copy of the polynomial coefficients + for(i = 0; i < size; i++) + A[i] = a[i]; + + // ------------------------------------------------------ + while(repeat--) + { // get the next argument value + CppAD::uniform_01(1, z); + + // independent variable value + Z.fastAccessCoeff(0) = z[0]; // argument value + Z.fastAccessCoeff(1) = 1.; // first order coefficient + Z.fastAccessCoeff(2) = 0.; // second order coefficient + + // AD computation of the dependent variable + P = CppAD::Poly(0, A, Z); + + // second derivative is twice second order Taylor coefficient + ddp[0] = 2. * P.fastAccessCoeff(2); + } + // ------------------------------------------------------ + return true; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/sacado/sparse_hessian.cpp cppad-2019.02.00.0/speed/sacado/sparse_hessian.cpp --- cppad-2018.00.00.0/speed/sacado/sparse_hessian.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/sacado/sparse_hessian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,25 @@ -// $Id: sparse_hessian.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include /* $begin sacado_sparse_hessian.cpp$$ $spell - boolsparsity - const - Sacado - bool - CppAD + boolsparsity + const + Sacado + bool + CppAD $$ $section Sacado Speed: Sparse Hessian$$ @@ -27,16 +27,16 @@ $srccode%cpp% */ // 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 , - size_t& n_sweep + size_t size , + size_t repeat , + const CppAD::vector& row , + const CppAD::vector& col , + CppAD::vector& x , + CppAD::vector& hessian , + size_t& n_sweep ) { - return false; + return false; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/sacado/sparse_jacobian.cpp cppad-2019.02.00.0/speed/sacado/sparse_jacobian.cpp --- cppad-2018.00.00.0/speed/sacado/sparse_jacobian.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/sacado/sparse_jacobian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,25 @@ -// $Id: sparse_jacobian.cpp 3788 2016-02-09 15:50:06Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include # include /* $begin sacado_sparse_jacobian.cpp$$ $spell - const - bool - CppAD - sacado - sparse_jacobian + const + bool + CppAD + sacado + sparse_jacobian $$ $section sacado Speed: sparse_jacobian$$ @@ -27,16 +27,16 @@ $srccode%cpp% */ // A sacado version of this test is not yet available bool link_sparse_jacobian( - size_t size , - size_t repeat , - size_t m , - const CppAD::vector& row , - const CppAD::vector& col , - CppAD::vector& x , - CppAD::vector& jacobian , - size_t& n_sweep ) + size_t size , + size_t repeat , + size_t m , + const CppAD::vector& row , + const CppAD::vector& col , + CppAD::vector& x , + CppAD::vector& jacobian , + size_t& n_sweep ) { - return false; + return false; } /* %$$ $end diff -Nru cppad-2018.00.00.0/speed/src/CMakeLists.txt cppad-2019.02.00.0/speed/src/CMakeLists.txt --- cppad-2018.00.00.0/speed/src/CMakeLists.txt 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/src/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,34 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the cppad_ipopt/src library # Inherit build type from ../CMakeList.txt # add_library( [STATIC | SHARED | MODULE] [EXCLUDE_FROM_ALL] -# source1 source2 ... sourceN) +# source1 source2 ... sourceN) # ) # 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). SET(source_list - link_det_lu.cpp - link_det_minor.cpp - link_mat_mul.cpp - link_ode.cpp - link_poly.cpp - link_sparse_hessian.cpp - link_sparse_jacobian.cpp - microsoft_timer.cpp + link_det_lu.cpp + link_det_minor.cpp + link_mat_mul.cpp + link_ode.cpp + link_poly.cpp + link_sparse_hessian.cpp + link_sparse_jacobian.cpp + microsoft_timer.cpp ) # 2DO: fix problem with the test -# ./speed_cppad sparse_hessian 123 colpack +# ./speed_cppad sparse_hessian 123 colpack # when speed_cppad is compiled for debugging. # set_compile_flags( speed_src "${cppad_debug_which}" "${source_list}" ) diff -Nru cppad-2018.00.00.0/speed/src/link_det_lu.cpp cppad-2019.02.00.0/speed/src/link_det_lu.cpp --- cppad-2018.00.00.0/speed/src/link_det_lu.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/src/link_det_lu.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,32 @@ -// $Id: link_det_lu.cpp 3855 2016-12-19 00:30:54Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin link_det_lu$$ $spell - det_lu - bool - CppAD + det_lu + bool + CppAD $$ $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% , - CppAD::vector &%matrix% , - CppAD::vector &%gradient% + size_t %size% , + size_t %repeat% , + CppAD::vector &%matrix% , + CppAD::vector &%gradient% ); %$$ @@ -81,42 +80,43 @@ # include extern bool link_det_lu( - size_t size , - size_t repeat , - CppAD::vector &matrix , - CppAD::vector &gradient + size_t size , + size_t repeat , + CppAD::vector &matrix , + CppAD::vector &gradient ); bool available_det_lu(void) -{ size_t size = 3; - size_t repeat = 1; - CppAD::vector matrix(size * size); - CppAD::vector gradient(size * size); +{ size_t size = 3; + size_t repeat = 1; + CppAD::vector matrix(size * size); + CppAD::vector gradient(size * size); - return link_det_lu(size, repeat, matrix, gradient); + return link_det_lu(size, repeat, matrix, gradient); } bool correct_det_lu(bool is_package_double) -{ size_t size = 3; - size_t repeat = 1; - CppAD::vector matrix(size * size); - CppAD::vector gradient(size * size); - - link_det_lu(size, repeat, matrix, gradient); - bool ok; - if( is_package_double ) - ok = CppAD::det_33(matrix, gradient); - else ok = CppAD::det_grad_33(matrix, gradient); - return ok; +{ size_t size = 3; + size_t repeat = 1; + CppAD::vector matrix(size * size); + CppAD::vector gradient(size * size); + + link_det_lu(size, repeat, matrix, gradient); + bool ok; + if( is_package_double ) + ok = CppAD::det_33(matrix, gradient); + else + ok = CppAD::det_grad_33(matrix, gradient); + return ok; } void speed_det_lu(size_t size, size_t repeat) -{ // free statically allocated memory - if( size == 0 && repeat == 0 ) - return; - // - CppAD::vector matrix(size * size); - CppAD::vector gradient(size * size); +{ // free statically allocated memory + if( size == 0 && repeat == 0 ) + return; + // + CppAD::vector matrix(size * size); + CppAD::vector gradient(size * size); - link_det_lu(size, repeat, matrix, gradient); - return; + link_det_lu(size, repeat, matrix, gradient); + return; } diff -Nru cppad-2018.00.00.0/speed/src/link_det_minor.cpp cppad-2019.02.00.0/speed/src/link_det_minor.cpp --- cppad-2018.00.00.0/speed/src/link_det_minor.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/src/link_det_minor.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,32 @@ -// $Id: link_det_minor.cpp 3855 2016-12-19 00:30:54Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin link_det_minor$$ $spell - det - bool - CppAD + det + bool + CppAD $$ $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% , - CppAD::vector &%matrix% , - CppAD::vector &%gradient% + size_t %size% , + size_t %repeat% , + CppAD::vector &%matrix% , + CppAD::vector &%gradient% ); %$$ @@ -83,41 +82,42 @@ # include extern bool link_det_minor( - size_t size , - size_t repeat , - CppAD::vector &matrix , - CppAD::vector &gradient + size_t size , + size_t repeat , + CppAD::vector &matrix , + CppAD::vector &gradient ); bool available_det_minor(void) -{ size_t size = 3; - size_t repeat = 1; - CppAD::vector matrix(size * size); - CppAD::vector gradient(size * size); +{ size_t size = 3; + size_t repeat = 1; + CppAD::vector matrix(size * size); + CppAD::vector gradient(size * size); - return link_det_minor(size, repeat, matrix, gradient); + return link_det_minor(size, repeat, matrix, gradient); } bool correct_det_minor(bool is_package_double) -{ size_t size = 3; - size_t repeat = 1; - CppAD::vector matrix(size * size); - CppAD::vector gradient(size * size); - - link_det_minor(size, repeat, matrix, gradient); - bool ok = CppAD::det_grad_33(matrix, gradient); - if( is_package_double ) - ok = CppAD::det_33(matrix, gradient); - else ok = CppAD::det_grad_33(matrix, gradient); - return ok; +{ size_t size = 3; + size_t repeat = 1; + CppAD::vector matrix(size * size); + CppAD::vector gradient(size * size); + + link_det_minor(size, repeat, matrix, gradient); + bool ok = CppAD::det_grad_33(matrix, gradient); + if( is_package_double ) + ok = CppAD::det_33(matrix, gradient); + else + ok = CppAD::det_grad_33(matrix, gradient); + return ok; } void speed_det_minor(size_t size, size_t repeat) -{ // free statically allocated memory - if( size == 0 && repeat == 0 ) - return; - // - CppAD::vector matrix(size * size); - CppAD::vector gradient(size * size); +{ // free statically allocated memory + if( size == 0 && repeat == 0 ) + return; + // + CppAD::vector matrix(size * size); + CppAD::vector gradient(size * size); - link_det_minor(size, repeat, matrix, gradient); - return; + link_det_minor(size, repeat, matrix, gradient); + return; } diff -Nru cppad-2018.00.00.0/speed/src/link_mat_mul.cpp cppad-2019.02.00.0/speed/src/link_mat_mul.cpp --- cppad-2018.00.00.0/speed/src/link_mat_mul.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/src/link_mat_mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,34 +1,34 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin link_mat_mul$$ $spell - mul - bool - CppAD - dz + mul + bool + CppAD + dz $$ $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% , - CppAD::vector& %x% , - CppAD::vector& %z% , - CppAD::vector& %dz% + size_t %size% , + size_t %repeat% , + CppAD::vector& %x% , + CppAD::vector& %z% , + CppAD::vector& %dz% ); %$$ @@ -60,7 +60,7 @@ The output value of its elements is the last random matrix that is multiplied and then summed to form $icode z$$; $latex \[ - x_{i,j} = x[ i * s + j ] + x_{i,j} = x[ i * s + j ] \] $$ where $icode%s% = %size%$$. @@ -71,9 +71,9 @@ $icode%y% = %x% * %x%$$; i.e., $latex \[ \begin{array}{rcl} - 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} + 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} \] $$ @@ -91,65 +91,65 @@ # include extern bool link_mat_mul( - size_t size , - size_t repeat , - CppAD::vector& x , - CppAD::vector& z , - CppAD::vector& dz + size_t size , + size_t repeat , + CppAD::vector& x , + CppAD::vector& z , + CppAD::vector& dz ); bool available_mat_mul(void) -{ size_t size = 2; - size_t repeat = 1; - CppAD::vector x(size * size), z(1), dz(size * size); +{ size_t size = 2; + size_t repeat = 1; + CppAD::vector x(size * size), z(1), dz(size * size); - return link_mat_mul(size, repeat, x, z, dz); + return link_mat_mul(size, repeat, x, z, dz); } bool correct_mat_mul(bool is_package_double) -{ size_t size = 2; - size_t repeat = 1; - CppAD::vector x(size * size), z(1), dz(size * size); - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - link_mat_mul(size, repeat, x, z, dz); - - double x00 = x[0 * size + 0]; - double x01 = x[0 * size + 1]; - double x10 = x[1 * size + 0]; - double x11 = x[1 * size + 1]; - bool ok = true; - double check; - if( is_package_double ) - { check = 0; - check += x00 * x00 + x01 * x10; // y00 - check += x00 * x01 + x01 * x11; // y01 - check += x10 * x00 + x11 * x10; // y10 - check += x10 * x01 + x11 * x11; // y11 - ok &= CppAD::NearEqual(check, z[0], eps99, eps99); - return ok; - } - // partial w.r.t. x00 - check = x00 + x00 + x01 + x10; - ok &= CppAD::NearEqual(check, dz[0 * size + 0], eps99, eps99); - // partial w.r.t. x01 - check = x10 + x00 + x11 + x10; - ok &= CppAD::NearEqual(check, dz[0 * size + 1], eps99, eps99); - // partial w.r.t. x10 - check = x01 + x00 + x11 + x01; - ok &= CppAD::NearEqual(check, dz[1 * size + 0], eps99, eps99); - // partial w.r.t. x11 - check = x01 + x10 + x11 + x11; - ok &= CppAD::NearEqual(check, dz[1 * size + 1], eps99, eps99); +{ size_t size = 2; + size_t repeat = 1; + CppAD::vector x(size * size), z(1), dz(size * size); + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + link_mat_mul(size, repeat, x, z, dz); + + double x00 = x[0 * size + 0]; + double x01 = x[0 * size + 1]; + double x10 = x[1 * size + 0]; + double x11 = x[1 * size + 1]; + bool ok = true; + double check; + if( is_package_double ) + { check = 0; + check += x00 * x00 + x01 * x10; // y00 + check += x00 * x01 + x01 * x11; // y01 + check += x10 * x00 + x11 * x10; // y10 + check += x10 * x01 + x11 * x11; // y11 + ok &= CppAD::NearEqual(check, z[0], eps99, eps99); + return ok; + } + // partial w.r.t. x00 + check = x00 + x00 + x01 + x10; + ok &= CppAD::NearEqual(check, dz[0 * size + 0], eps99, eps99); + // partial w.r.t. x01 + check = x10 + x00 + x11 + x10; + ok &= CppAD::NearEqual(check, dz[0 * size + 1], eps99, eps99); + // partial w.r.t. x10 + check = x01 + x00 + x11 + x01; + ok &= CppAD::NearEqual(check, dz[1 * size + 0], eps99, eps99); + // partial w.r.t. x11 + check = x01 + x10 + x11 + x11; + ok &= CppAD::NearEqual(check, dz[1 * size + 1], eps99, eps99); - return ok; + return ok; } void speed_mat_mul(size_t size, size_t repeat) -{ // free statically allocated memory - if( size == 0 && repeat == 0 ) - return; - // - CppAD::vector x(size * size), z(1), dz(size * size); +{ // free statically allocated memory + if( size == 0 && repeat == 0 ) + return; + // + CppAD::vector x(size * size), z(1), dz(size * size); - link_mat_mul(size, repeat, x, z, dz); - return; + link_mat_mul(size, repeat, x, z, dz); + return; } diff -Nru cppad-2018.00.00.0/speed/src/link_ode.cpp cppad-2019.02.00.0/speed/src/link_ode.cpp --- cppad-2018.00.00.0/speed/src/link_ode.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/src/link_ode.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,34 +1,33 @@ -// $Id: link_ode.cpp 3855 2016-12-19 00:30:54Z bradbell $ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-16 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin link_ode$$ $spell - Jacobian - fp - bool - CppAD + Jacobian + fp + bool + CppAD $$ $section Speed Testing the Jacobian of Ode Solution$$ -$mindex link_ode test$$ $head Prototype$$ $codei%extern bool link_ode( - size_t %size% , - size_t %repeat% , - CppAD::vector &%x% , - CppAD::vector &%jacobian% + size_t %size% , + size_t %repeat% , + CppAD::vector &%x% , + CppAD::vector &%jacobian% ); %$$ @@ -47,7 +46,7 @@ $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% - ode_evaluate(%x%, %p%, %fp%) + ode_evaluate(%x%, %p%, %fp%) %$$ with $icode p$$ equal to zero. Calls with the value $icode p$$ equal to one are used to check @@ -84,7 +83,7 @@ To be more specific, for $latex i = 0 , \ldots , n-1$$ and $latex j = 0 , \ldots , n-1$$, $latex \[ - \D{f[i]}{x[j]} (x) = jacobian [ i \cdot n + j ] + \D{f[i]}{x[j]} (x) = jacobian [ i \cdot n + j ] \] $$ $subhead double$$ @@ -101,50 +100,50 @@ # include extern bool link_ode( - size_t size , - size_t repeat , - CppAD::vector &x , - CppAD::vector &jacobian + size_t size , + size_t repeat , + CppAD::vector &x , + CppAD::vector &jacobian ); bool available_ode(void) -{ size_t n = 1; - size_t repeat = 1; - CppAD::vector x(n); - CppAD::vector jacobian(n * n); +{ size_t n = 1; + size_t repeat = 1; + CppAD::vector x(n); + CppAD::vector jacobian(n * n); - return link_ode(n, repeat, x, jacobian); + return link_ode(n, repeat, x, jacobian); } bool correct_ode(bool is_package_double) -{ bool ok = true; +{ bool ok = true; - size_t n = 5; - size_t repeat = 1; - CppAD::vector x(n); - CppAD::vector jacobian(n * n); - - link_ode(n, repeat, x, jacobian); - - size_t size = n * n; - size_t p = 1; - if( is_package_double ) - { p = 0; // check function value - size = n; - } - CppAD::vector check(size); - CppAD::ode_evaluate(x, p, check); - size_t k; - for(k = 0; k < size; k++) - ok &= CppAD::NearEqual(check[k], jacobian[k], 1e-6, 1e-6); + size_t n = 5; + size_t repeat = 1; + CppAD::vector x(n); + CppAD::vector jacobian(n * n); + + link_ode(n, repeat, x, jacobian); + + size_t size = n * n; + size_t p = 1; + if( is_package_double ) + { p = 0; // check function value + size = n; + } + CppAD::vector check(size); + CppAD::ode_evaluate(x, p, check); + size_t k; + for(k = 0; k < size; k++) + ok &= CppAD::NearEqual(check[k], jacobian[k], 1e-6, 1e-6); - return ok; + return ok; } void speed_ode(size_t n, size_t repeat) -{ // free statically allocated memory - if( n == 0 && repeat == 0 ) - return; - // - CppAD::vector x(n); - CppAD::vector jacobian(n * n); - link_ode(n, repeat, x, jacobian); - return; +{ // free statically allocated memory + if( n == 0 && repeat == 0 ) + return; + // + CppAD::vector x(n); + CppAD::vector jacobian(n * n); + link_ode(n, repeat, x, jacobian); + return; } diff -Nru cppad-2018.00.00.0/speed/src/link_poly.cpp cppad-2019.02.00.0/speed/src/link_poly.cpp --- cppad-2018.00.00.0/speed/src/link_poly.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/src/link_poly.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,34 +1,34 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin link_poly$$ $spell - poly - bool - CppAD - ddp + poly + bool + CppAD + ddp $$ $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% , - CppAD::vector &%a% , - CppAD::vector &%z% , - CppAD::vector &%ddp + size_t %size% , + size_t %repeat% , + CppAD::vector &%a% , + CppAD::vector &%z% , + CppAD::vector &%ddp ); %$$ @@ -88,44 +88,45 @@ # include extern bool link_poly( - size_t size , - size_t repeat , - CppAD::vector &a , - CppAD::vector &z , - CppAD::vector &ddp + size_t size , + size_t repeat , + CppAD::vector &a , + CppAD::vector &z , + CppAD::vector &ddp ); bool available_poly(void) -{ size_t size = 10; - size_t repeat = 1; - CppAD::vector a(size), z(1), ddp(1); +{ size_t size = 10; + size_t repeat = 1; + CppAD::vector a(size), z(1), ddp(1); - return link_poly(size, repeat, a, z, ddp); + return link_poly(size, repeat, a, z, ddp); } bool correct_poly(bool is_package_double) -{ size_t size = 10; - size_t repeat = 1; - CppAD::vector a(size), z(1), ddp(1); - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - link_poly(size, repeat, a, z, ddp); - - size_t k; - double check; - if( is_package_double ) - k = 0; - else k = 2; - check = CppAD::Poly(k, a, z[0]); +{ size_t size = 10; + size_t repeat = 1; + CppAD::vector a(size), z(1), ddp(1); + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + link_poly(size, repeat, a, z, ddp); + + size_t k; + double check; + if( is_package_double ) + k = 0; + else + k = 2; + check = CppAD::Poly(k, a, z[0]); - bool ok = CppAD::NearEqual(check, ddp[0], eps99, eps99); - return ok; + bool ok = CppAD::NearEqual(check, ddp[0], eps99, eps99); + return ok; } void speed_poly(size_t size, size_t repeat) -{ // free statically allocated memory - if( size == 0 && repeat == 0 ) - return; - // - CppAD::vector a(size), z(1), ddp(1); +{ // free statically allocated memory + if( size == 0 && repeat == 0 ) + return; + // + CppAD::vector a(size), z(1), ddp(1); - link_poly(size, repeat, a, z, ddp); - return; + link_poly(size, repeat, a, z, ddp); + return; } diff -Nru cppad-2018.00.00.0/speed/src/link_sparse_hessian.cpp cppad-2019.02.00.0/speed/src/link_sparse_hessian.cpp --- cppad-2018.00.00.0/speed/src/link_sparse_hessian.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/src/link_sparse_hessian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,37 +1,37 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin link_sparse_hessian$$ $spell - const - bool - CppAD - cppad - colpack + const + bool + CppAD + cppad + colpack $$ $section Speed Testing Sparse Hessian$$ -$mindex link_sparse_hessian test$$ $head Prototype$$ $codei%extern bool link_sparse_hessian( - size_t %size% , - size_t %repeat% , - CppAD::vector& %x% , - const CppAD::vector& %row% , - const CppAD::vector& %col% , - CppAD::vector& %hessian% , - size_t %n_sweep% + size_t %size% , + size_t %repeat% , + CppAD::vector& %x% , + const CppAD::vector& %row% , + const CppAD::vector& %col% , + CppAD::vector& %hessian% , + size_t %n_sweep% ); %$$ @@ -44,13 +44,13 @@ 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]]} - \; , \; - \DD{f}{x[row[k]]}{x[col[k]]} - \; , \; - \DD{f}{x[col[k]]}{x[row[k]]} - \; , \; - \DD{f}{x[col[k]]}{x[col[k]]} + \DD{f}{x[row[k]]}{x[row[k]]} + \; , \; + \DD{f}{x[row[k]]}{x[col[k]]} + \; , \; + \DD{f}{x[col[k]]}{x[row[k]]} + \; , \; + \DD{f}{x[col[k]]}{x[col[k]]} \] $$ for some $latex k $$ between zero and $latex K-1 $$. All the other terms of the Hessian are zero. @@ -68,7 +68,7 @@ $head x$$ The argument $icode x$$ has prototype $codei% - CppAD::vector& %x% + CppAD::vector& %x% %$$ and its size is $latex n$$; i.e., $icode%x%.size() == %size%$$. The input value of the elements of $icode x$$ does not matter. @@ -80,7 +80,7 @@ $head row$$ The argument $icode row$$ has prototype $codei% - const CppAD::vector %row% + const CppAD::vector %row% %$$ Its size defines the value $latex K$$. It contains the row indices for the corresponding function $latex f(x)$$. @@ -89,7 +89,7 @@ $head col$$ The argument $icode col$$ has prototype $codei% - const CppAD::vector %col% + 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 @@ -98,18 +98,18 @@ There are no duplicated entries requested, to be specific, if $icode%k1% != %k2%$$ then $codei% - ( %row%[%k1%] , %col%[%k1%] ) != ( %row%[%k2%] , %col%[%k2%] ) + ( %row%[%k1%] , %col%[%k1%] ) != ( %row%[%k2%] , %col%[%k2%] ) %$$ Furthermore, the entries are lower triangular; i.e., $codei% - %col%[%k%] <= %row%[%k%] + %col%[%k%] <= %row%[%k%] %$$. $head hessian$$ The argument $icode hessian$$ has prototype $codei% - CppAD::vector& hessian + CppAD::vector& hessian %$$ and its size is $icode K$$. The input value of its elements does not matter. @@ -117,7 +117,7 @@ To be more specific, for $latex k = 0 , \ldots , K-1$$, $latex \[ - \DD{f}{ x[ \R{row}[k] ] }{ x[ \R{col}[k] ]} = \R{hessian} [k] + \DD{f}{ x[ \R{row}[k] ] }{ x[ \R{col}[k] ]} = \R{hessian} [k] \] $$ $head n_sweep$$ @@ -150,102 +150,102 @@ Defines and implement sparse Hessian speed link to package specific code. */ namespace { - using CppAD::vector; + using CppAD::vector; - /*! - Class used by choose_row_col to determin order of row and column indices - */ - class Key { - public: - /// row index - size_t row_; - /// column index - size_t col_; - /// default constructor - Key(void) - { } - /*! - 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 - - \param other - the other key. - */ - bool operator<(const Key& other) const - { if( row_ == other.row_ ) - return col_ < other.col_; - return row_ < other.row_; - } - }; - - /*! - Function that randomly choose the row and column indices - - \param n [in] - is the dimension of the argument space for the function f(x). - - \param row [out] - the input size and elements of \c row do not matter. - Upon return it is the chosen row indices. - - \param col [out] - the input size and elements of \c col do not matter. - Upon return it is the chosen column indices. - */ - void choose_row_col( - size_t n , - vector& row , - vector& col ) - { size_t i, j, k, ell; - size_t max_per_row = 5; - - // generate the row and column indices - row.resize(0); - col.resize(0); - 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++) - { // avoid warning when converting double to size_t - j = std::min(i, size_t( float(random[ell]) * double(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); - } - } - } - } + /*! + Class used by choose_row_col to determin order of row and column indices + */ + class Key { + public: + /// row index + size_t row_; + /// column index + size_t col_; + /// default constructor + Key(void) + { } + /*! + 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 + + \param other + the other key. + */ + bool operator<(const Key& other) const + { if( row_ == other.row_ ) + return col_ < other.col_; + return row_ < other.row_; + } + }; + + /*! + Function that randomly choose the row and column indices + + \param n [in] + is the dimension of the argument space for the function f(x). + + \param row [out] + the input size and elements of row do not matter. + Upon return it is the chosen row indices. + + \param col [out] + the input size and elements of col do not matter. + Upon return it is the chosen column indices. + */ + void choose_row_col( + size_t n , + vector& row , + vector& col ) + { size_t i, j, k, ell; + size_t max_per_row = 5; + + // generate the row and column indices + row.resize(0); + col.resize(0); + 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++) + { // avoid warning when converting double to size_t + j = std::min(i, size_t( float(random[ell]) * double(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); + } + } + } + } } /*! Package specific implementation of a sparse Hessian claculation. \param size [in] -is the size of the domain space; i.e. specifies \c n. +is the size of the domain space; i.e. specifies n. \param repeat [in] number of times tha the test is repeated. \param x [out] -is a vector of size \c n containing +is a vector of size n containing the argument at which the Hessian was evaluated during the last repetition. \param row [in] @@ -270,13 +270,13 @@ and false otherwise. */ 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 , - size_t& n_sweep + size_t size , + size_t repeat , + const CppAD::vector& row , + const CppAD::vector& col , + CppAD::vector& x , + CppAD::vector& hessian , + size_t& n_sweep ); /*! @@ -287,16 +287,16 @@ */ bool available_sparse_hessian(void) { - size_t n = 2; - size_t repeat = 1; - vector x(n); - vector row, col; - choose_row_col(n, row, col); - size_t K = row.size(); - vector hessian(K); + size_t n = 2; + size_t repeat = 1; + vector x(n); + vector row, col; + choose_row_col(n, row, col); + size_t K = row.size(); + vector hessian(K); - size_t n_sweep; - return link_sparse_hessian(n, repeat, row, col, x, hessian, n_sweep); + size_t n_sweep; + return link_sparse_hessian(n, repeat, row, col, x, hessian, n_sweep); } /*! Does final sparse Hessian value pass correctness test. @@ -309,41 +309,41 @@ */ bool correct_sparse_hessian(bool is_package_double) { - double eps99 = 99.0 * std::numeric_limits::epsilon(); - size_t n = 10; - size_t repeat = 1; - vector x(n); - vector row, col; - choose_row_col(n, row, col); - size_t K = row.size(); - vector hessian(K); + double eps99 = 99.0 * std::numeric_limits::epsilon(); + size_t n = 10; + size_t repeat = 1; + vector x(n); + vector row, col; + choose_row_col(n, row, col); + size_t K = row.size(); + vector hessian(K); # ifndef NDEBUG - for(size_t k = 0; k < K; k++) - CPPAD_ASSERT_UNKNOWN( col[k] <= row[k] ); + for(size_t k = 0; k < K; k++) + CPPAD_ASSERT_UNKNOWN( col[k] <= row[k] ); # endif - // 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) - { order = 0; // check function value - size = 1; - } - else - { order = 2; // check hessian value - 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++) - ok &= CppAD::NearEqual(check[k], hessian[k], eps99, eps99); + // 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) + { order = 0; // check function value + size = 1; + } + else + { order = 2; // check hessian value + 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++) + ok &= CppAD::NearEqual(check[k], hessian[k], eps99, eps99); - return ok; + return ok; } /*! @@ -357,58 +357,58 @@ */ void speed_sparse_hessian(size_t size, size_t repeat) { - static size_t previous_size = 0; - static vector row, col; - // - // free statically allocated memory - if( size == 0 && repeat == 0 ) - { row.clear(); - col.clear(); - previous_size = size; - return; - } - - size_t n = size; - vector x(n); - if( size != previous_size ) - { choose_row_col(n, row, col); - previous_size = size; - } - size_t K = row.size(); - vector hessian(K); + static size_t previous_size = 0; + static vector row, col; + // + // free statically allocated memory + if( size == 0 && repeat == 0 ) + { row.clear(); + col.clear(); + previous_size = size; + return; + } + + size_t n = size; + vector x(n); + if( size != previous_size ) + { choose_row_col(n, row, col); + previous_size = size; + } + size_t K = row.size(); + vector hessian(K); # ifndef NDEBUG - for(size_t k = 0; k < K; k++) - CPPAD_ASSERT_UNKNOWN( col[k] <= row[k] ); + for(size_t k = 0; k < K; k++) + CPPAD_ASSERT_UNKNOWN( col[k] <= row[k] ); # endif - // note that cppad/sparse_hessian.cpp assumes that x.size() == size - size_t n_sweep; - link_sparse_hessian(n, repeat, row, col, x, hessian, n_sweep); - return; + // note that cppad/sparse_hessian.cpp assumes that x.size() == size + 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. +is the 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. +Upon return, it is the value n_sweep retruned by the corresponding +call to 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; +{ 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-2018.00.00.0/speed/src/link_sparse_jacobian.cpp cppad-2019.02.00.0/speed/src/link_sparse_jacobian.cpp --- cppad-2018.00.00.0/speed/src/link_sparse_jacobian.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/src/link_sparse_jacobian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,39 +1,39 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin link_sparse_jacobian$$ $spell - colpack - cppad - const - bool - CppAD - Jacobian + colpack + cppad + const + bool + CppAD + Jacobian $$ $section Speed Testing Sparse Jacobian$$ -$mindex link_sparse_jacobian test$$ $head Prototype$$ $codei%extern bool link_sparse_jacobian( - size_t %size% , - size_t %repeat% , - size_t %m% , - const CppAD::vector& %row% , - const CppAD::vector& %col% , - CppAD::vector& %x% , - CppAD::vector& %jacobian% , - size_t& %n_sweep% + size_t %size% , + size_t %repeat% , + size_t %m% , + const CppAD::vector& %row% , + const CppAD::vector& %col% , + CppAD::vector& %x% , + CppAD::vector& %jacobian% , + size_t& %n_sweep% ); %$$ @@ -44,7 +44,7 @@ is defined by $cref sparse_jac_fun$$. The non-zero entries in the Jacobian of this function have the form $latex \[ - \D{f[row[k]]}{x[col[k]]]} + \D{f[row[k]]}{x[col[k]]]} \] $$ for some $latex k$$ between zero and $icode%K% = %row%.size()-1%$$. All the other terms of the Jacobian are zero. @@ -75,13 +75,13 @@ All the elements of $icode col$$ are between zero and $latex n-1$$. There are no duplicate row and column entires; i.e., if $icode%j% != %k%$$, $codei% - %row%[%j%] != %row%[%k%] || %col%[%j%] != %col%[%k%] + %row%[%j%] != %row%[%k%] || %col%[%j%] != %col%[%k%] %$$ $head x$$ The argument $icode x$$ has prototype $codei% - CppAD::vector& %x% + CppAD::vector& %x% %$$ and its size is $latex n$$; i.e., $icode%x%.size() == %size%$$. The input value of the elements of $icode x$$ does not matter. @@ -93,7 +93,7 @@ $head jacobian$$ The argument $icode jacobian$$ has prototype $codei% - CppAD::vector& %jacobian% + CppAD::vector& %jacobian% %$$ and its size is $icode K$$. The input value of its elements does not matter. @@ -101,7 +101,7 @@ To be more specific, for $latex k = 0 , \ldots , K - 1$$, $latex \[ - \D{f[ \R{row}[k] ]}{x[ \R{col}[k] ]} (x) = \R{jacobian} [k] + \D{f[ \R{row}[k] ]}{x[ \R{col}[k] ]} (x) = \R{jacobian} [k] \] $$ $head n_sweep$$ @@ -134,115 +134,115 @@ Defines and implement sparse Jacobian speed link to package specific code. */ namespace { - using CppAD::vector; + using CppAD::vector; - /*! - Class used by choose_row_col to determine order of row and column indices - */ - class Key { - public: - /// row index - size_t row_; - /// column index - size_t col_; - /// default constructor - Key(void) - { } - /*! - 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 - - \param other - the other key. - */ - bool operator<(const Key& other) const - { if( row_ == other.row_ ) - return col_ < other.col_; - return row_ < other.row_; - } - }; - - /*! - Function that randomly choose the row and column indices - - \param n [in] - is the dimension of the domain space for the function f(x). - - \param m [in] - is the dimension of the range space for the function f(x). - - \param row [out] - the input size and elements of \c row do not matter. - Upon return it is the chosen row indices. - - \param col [out] - the input size and elements of \c col do not matter. - Upon return it is the chosen column indices. - */ - void choose_row_col( - size_t n , - size_t m , - vector& row , - vector& col ) - { size_t r, c, k, K = 5 * std::max(m, 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); - vector ind(K); - for(k = 0; k < K; k++) - { // avoid warning when converting double to size_t - r = size_t( float( double(m) * random[k] ) ); - r = std::min(m-1, r); - // - c = size_t( float( double(n) * random[k + K] ) ); - c = std::min(n-1, c); - // - keys[k] = Key(r, c); - } - CppAD::index_sort(keys, ind); - - // remove duplicates while setting the return value for row and col - row.resize(0); - col.resize(0); - size_t r_previous = keys[ ind[0] ].row_; - size_t c_previous = keys[ ind[0] ].col_; - CPPAD_ASSERT_UNKNOWN( r_previous < m && c_previous < n ); - 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] ].col_; - CPPAD_ASSERT_UNKNOWN( r < m && c < n ); - if( r != r_previous || c != c_previous) - { row.push_back(r); - col.push_back(c); - } - r_previous = r; - c_previous = c; - } - } + /*! + Class used by choose_row_col to determine order of row and column indices + */ + class Key { + public: + /// row index + size_t row_; + /// column index + size_t col_; + /// default constructor + Key(void) + { } + /*! + 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 + + \param other + the other key. + */ + bool operator<(const Key& other) const + { if( row_ == other.row_ ) + return col_ < other.col_; + return row_ < other.row_; + } + }; + + /*! + Function that randomly choose the row and column indices + + \param n [in] + is the dimension of the domain space for the function f(x). + + \param m [in] + is the dimension of the range space for the function f(x). + + \param row [out] + the input size and elements of row do not matter. + Upon return it is the chosen row indices. + + \param col [out] + the input size and elements of col do not matter. + Upon return it is the chosen column indices. + */ + void choose_row_col( + size_t n , + size_t m , + vector& row , + vector& col ) + { size_t r, c, k, K = 5 * std::max(m, 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); + vector ind(K); + for(k = 0; k < K; k++) + { // avoid warning when converting double to size_t + r = size_t( float( double(m) * random[k] ) ); + r = std::min(m-1, r); + // + c = size_t( float( double(n) * random[k + K] ) ); + c = std::min(n-1, c); + // + keys[k] = Key(r, c); + } + CppAD::index_sort(keys, ind); + + // remove duplicates while setting the return value for row and col + row.resize(0); + col.resize(0); + size_t r_previous = keys[ ind[0] ].row_; + size_t c_previous = keys[ ind[0] ].col_; + CPPAD_ASSERT_UNKNOWN( r_previous < m && c_previous < n ); + 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] ].col_; + CPPAD_ASSERT_UNKNOWN( r < m && c < n ); + if( r != r_previous || c != c_previous) + { row.push_back(r); + col.push_back(c); + } + r_previous = r; + c_previous = c; + } + } } /*! Package specific implementation of a sparse Jacobian claculation. \param size [in] -is the size of the domain space; i.e. specifies \c n. +is the size of the domain space; i.e. specifies n. \param repeat [in] number of times tha the test is repeated. @@ -257,7 +257,7 @@ is the column indices corresponding to non-zero Jacobian entries. \param x [out] -is a vector of size \c n containing +is a vector of size n containing the argument at which the Jacobian was evaluated during the last repetition. \param jacobian [out] @@ -275,14 +275,14 @@ and false otherwise. */ extern bool link_sparse_jacobian( - size_t size , - size_t repeat , - size_t m , - const CppAD::vector& row , - const CppAD::vector& col , - CppAD::vector& x , - CppAD::vector& jacobian , - size_t& n_sweep + size_t size , + size_t repeat , + size_t m , + const CppAD::vector& row , + const CppAD::vector& col , + CppAD::vector& x , + CppAD::vector& jacobian , + size_t& n_sweep ); /*! @@ -292,17 +292,17 @@ true, if spare Jacobian available for this package, and false otherwise. */ bool available_sparse_jacobian(void) -{ size_t n = 10; - size_t m = 2 * n; - size_t repeat = 1; - vector row, col; - choose_row_col(n, m, row, col); - - vector x(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); +{ size_t n = 10; + size_t m = 2 * n; + size_t repeat = 1; + vector row, col; + choose_row_col(n, m, row, col); + + vector x(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); } /*! Does final sparse Jacobian value pass correctness test. @@ -314,42 +314,42 @@ true, if correctness test passes, and false otherwise. */ bool correct_sparse_jacobian(bool is_package_double) -{ size_t i, k; - bool ok = true; - double eps = 10. * CppAD::numeric_limits::epsilon(); - size_t n = 5; - size_t m = 2 * n; - size_t repeat = 1; - 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(K); - size_t n_sweep; - link_sparse_jacobian(n, repeat, m, row, col, x, jacobian, n_sweep); - - if( is_package_double) - { - // 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++) - ok &= CppAD::NearEqual(check[i], jacobian[i], eps, eps); +{ size_t i, k; + bool ok = true; + double eps = 10. * CppAD::numeric_limits::epsilon(); + size_t n = 5; + size_t m = 2 * n; + size_t repeat = 1; + 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(K); + size_t n_sweep; + link_sparse_jacobian(n, repeat, m, row, col, x, jacobian, n_sweep); + + if( is_package_double) + { + // 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++) + ok &= CppAD::NearEqual(check[i], jacobian[i], eps, eps); - return ok; - } + return ok; + } // check f'(x) - size_t order = 1; - vector check(K); - CppAD::sparse_jac_fun(m, n, x, row, col, order, check); - for(k = 0; k < K; k++) - ok &= CppAD::NearEqual(check[k], jacobian[k], eps, eps); + size_t order = 1; + vector check(K); + CppAD::sparse_jac_fun(m, n, x, row, col, order, check); + for(k = 0; k < K; k++) + ok &= CppAD::NearEqual(check[k], jacobian[k], eps, eps); - return ok; + return ok; } /*! Sparse Jacobian speed test. @@ -362,56 +362,56 @@ */ void speed_sparse_jacobian(size_t size, size_t repeat) { - static size_t previous_size = 0; - static vector row, col; - // - // free statically allocated memory - if( size == 0 && repeat == 0 ) - { row.clear(); - col.clear(); - previous_size = size; - return; - } - - size_t n = size; - size_t m = 2 * n; - 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); - 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; + static size_t previous_size = 0; + static vector row, col; + // + // free statically allocated memory + if( size == 0 && repeat == 0 ) + { row.clear(); + col.clear(); + previous_size = size; + return; + } + + size_t n = size; + size_t m = 2 * n; + 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); + 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; } /*! Sparse Jacobian speed test information. \param size [in] -is the \c size parameter in the corresponding call to speed_sparse_jacobian. +is the size parameter in the corresponding call to speed_sparse_jacobian. \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_jacobian. +Upon return, it is the value n_sweep retruned by the corresponding +call to link_sparse_jacobian. */ void info_sparse_jacobian(size_t size, size_t& n_sweep) -{ size_t n = size; - size_t m = 2 * n; - size_t repeat = 1; - vector row, col; - choose_row_col(n, m, row, col); - - // note that cppad/sparse_jacobian.cpp assumes that x.size() - // is the size corresponding to this test - vector x(n); - size_t K = row.size(); - vector jacobian(K); - link_sparse_jacobian(n, repeat, m, row, col, x, jacobian, n_sweep); - return; +{ size_t n = size; + size_t m = 2 * n; + size_t repeat = 1; + vector row, col; + choose_row_col(n, m, row, col); + + // note that cppad/sparse_jacobian.cpp assumes that x.size() + // is the size corresponding to this test + vector x(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-2018.00.00.0/speed/src/makefile.am cppad-2019.02.00.0/speed/src/makefile.am --- cppad-2018.00.00.0/speed/src/makefile.am 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/src/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,27 @@ -# $Id: makefile.am 3779 2016-01-01 11:26:11Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # # CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp DEFS = # -# BEGIN OPTIMIZE -AM_CXXFLAGS = -O2 -DNDEBUG $(CXX_FLAGS) -# END OPTIMIZE -# -# BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) -# END DEBUG -# -AM_CPPFLAGS = \ - -I. \ - -I$(top_srcdir) \ - $(BOOST_INCLUDE) \ +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) # +# +# noinst_LIBRARIES = libspeed.a libspeed_a_SOURCES = \ link_det_lu.cpp \ diff -Nru cppad-2018.00.00.0/speed/src/makefile.in cppad-2019.02.00.0/speed/src/makefile.in --- cppad-2018.00.00.0/speed/src/makefile.in 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/src/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -192,20 +192,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ -# $Id: makefile.in 3973 2017-08-30 13:38:26Z bradbell $ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -278,10 +276,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -300,9 +296,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -325,8 +323,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -347,21 +343,15 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # -# BEGIN OPTIMIZE -AM_CXXFLAGS = -O2 -DNDEBUG $(CXX_FLAGS) -# END OPTIMIZE -# -# BEGIN DEBUG -# AM_CXXFLAGS = -g $(CXX_FLAGS) -# END DEBUG -# -AM_CPPFLAGS = \ - -I. \ - -I$(top_srcdir) \ - $(BOOST_INCLUDE) \ +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) # +# +# noinst_LIBRARIES = libspeed.a libspeed_a_SOURCES = \ link_det_lu.cpp \ diff -Nru cppad-2018.00.00.0/speed/src/microsoft_timer.cpp cppad-2019.02.00.0/speed/src/microsoft_timer.cpp --- cppad-2018.00.00.0/speed/src/microsoft_timer.cpp 2018-01-01 08:32:14.000000000 +0000 +++ cppad-2019.02.00.0/speed/src/microsoft_timer.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,20 +1,20 @@ -/* $Id: microsoft_timer.cpp 3724 2015-09-21 05:04:18Z bradbell $ */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-15 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin microsoft_timer$$ $spell - Microsoft - cpp - src + Microsoft + cpp + src $$ $section Microsoft Version of Elapsed Number of Seconds$$ @@ -43,7 +43,7 @@ $end ----------------------------------------------------------------------- */ -# if _MSC_VER +# ifdef _MSC_VER # include # include @@ -62,28 +62,28 @@ \copydetails elapsed_seconds */ double microsoft_timer(void) -{ static bool first_ = true; - static SYSTEMTIME st_; - SYSTEMTIME st; - - if( first_ ) - { ::GetSystemTime(&st_); - first_ = false; - return 0.; - } - ::GetSystemTime(&st); - - double hour = double(st.wHour) - double(st_.wHour); - double minute = double(st.wMinute) - double(st_.wMinute); - double second = double(st.wSecond) - double(st_.wSecond); - double milli = double(st.wMilliseconds) - double(st_.wMilliseconds); - - double diff = 1e-3*milli + second + 60.*minute + 3600.*hour; - if( diff < 0. ) - diff += 3600.*24.; - assert( 0 <= diff && diff < 3600.*24. ); +{ static bool first_ = true; + static SYSTEMTIME st_; + SYSTEMTIME st; + + if( first_ ) + { ::GetSystemTime(&st_); + first_ = false; + return 0.; + } + ::GetSystemTime(&st); + + double hour = double(st.wHour) - double(st_.wHour); + double minute = double(st.wMinute) - double(st_.wMinute); + double second = double(st.wSecond) - double(st_.wSecond); + double milli = double(st.wMilliseconds) - double(st_.wMilliseconds); + + double diff = 1e-3*milli + second + 60.*minute + 3600.*hour; + if( diff < 0. ) + diff += 3600.*24.; + assert( 0 <= diff && diff < 3600.*24. ); - return diff; + return diff; } # endif diff -Nru cppad-2018.00.00.0/test_more/CMakeLists.txt cppad-2019.02.00.0/test_more/CMakeLists.txt --- cppad-2018.00.00.0/test_more/CMakeLists.txt 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/test_more/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,18 +1,22 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the test_more directory tests # initialize check_depends SET(check_test_more_depends "") +# deprecated tests +ADD_SUBDIRECTORY(deprecated) + # compare_c tests ADD_SUBDIRECTORY(compare_c) @@ -20,7 +24,9 @@ ADD_SUBDIRECTORY(debug_rel) # cppad_for_tmb tests -ADD_SUBDIRECTORY(cppad_for_tmb) +IF( OPENMP_FOUND ) + ADD_SUBDIRECTORY(cppad_for_tmb) +ENDIF( OPENMP_FOUND ) # general tests ADD_SUBDIRECTORY(general) diff -Nru cppad-2018.00.00.0/test_more/compare_c/CMakeLists.txt cppad-2019.02.00.0/test_more/compare_c/CMakeLists.txt --- cppad-2018.00.00.0/test_more/compare_c/CMakeLists.txt 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/compare_c/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,17 +1,18 @@ # ----------------------------------------------------------------------------- # CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # $begin compare_c$$ $newlinech #$$ # $spell -# det -# cpp +# det +# cpp # $$ # # $section Compare Speed of C and C++$$ @@ -30,7 +31,7 @@ # using C versus C++. # # $childtable% -# test_more/compare_c/det_by_minor.c +# test_more/compare_c/det_by_minor.c # %$$ # # $end @@ -38,44 +39,44 @@ # # use cppad_debug_which to determine build type IF( "${cppad_debug_which}" STREQUAL debug_all ) - SET(CMAKE_BUILD_TYPE DEBUG) + SET(CMAKE_BUILD_TYPE DEBUG) ELSEIF( "${cppad_debug_which}" STREQUAL debug_odd ) - SET(CMAKE_BUILD_TYPE DEBUG) + SET(CMAKE_BUILD_TYPE DEBUG) ELSE( "${cppad_debug_which}" STREQUAL debug_odd ) - SET(CMAKE_BUILD_TYPE RELEASE) + SET(CMAKE_BUILD_TYPE RELEASE) ENDIF( "${cppad_debug_which}" STREQUAL debug_all ) # # Loop though the C and C++ compilers FOREACH( com c cpp ) - # Copy a file to another location and modify its contents. - # configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) - SET( source det_by_minor_${com}.${com} ) - CONFIGURE_FILE( - ${CMAKE_CURRENT_SOURCE_DIR}/det_by_minor.c - ${CMAKE_CURRENT_BINARY_DIR}/${source} - COPYONLY - ) - ADD_EXECUTABLE( det_by_minor_${com} EXCLUDE_FROM_ALL ${source}) - # - IF( ${com} STREQUAL cpp ) - # These are C++ compiler flags (may not be valid for C) - SET_TARGET_PROPERTIES( - det_by_minor_${com} PROPERTIES COMPILE_FLAGS "${cppad_cxx_flags}" - ) - ENDIF( ${com} STREQUAL cpp ) - # - # Add target the executes this program - ADD_CUSTOM_TARGET(check_det_by_minor_${com} - det_by_minor_${com} - DEPENDS det_by_minor_${com} - ) - MESSAGE(STATUS "make check_det_by_minor_${com}: available") + # Copy a file to another location and modify its contents. + # configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY]) + SET( source det_by_minor_${com}.${com} ) + CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/det_by_minor.c + ${CMAKE_CURRENT_BINARY_DIR}/${source} + COPYONLY + ) + ADD_EXECUTABLE( det_by_minor_${com} EXCLUDE_FROM_ALL ${source}) + # + IF( ${com} STREQUAL cpp ) + # These are C++ compiler flags (may not be valid for C) + SET_TARGET_PROPERTIES( + det_by_minor_${com} PROPERTIES COMPILE_FLAGS "${cppad_cxx_flags}" + ) + ENDIF( ${com} STREQUAL cpp ) + # + # Add target the executes this program + ADD_CUSTOM_TARGET(check_det_by_minor_${com} + det_by_minor_${com} + DEPENDS det_by_minor_${com} + ) + MESSAGE(STATUS "make check_det_by_minor_${com}: available") ENDFOREACH(com) # check_test_more_compare_c target ADD_CUSTOM_TARGET( check_test_more_compare_c - DEPENDS check_det_by_minor_c check_det_by_minor_cpp + DEPENDS check_det_by_minor_c check_det_by_minor_cpp ) MESSAGE(STATUS "make check_test_more_compare_c: available") diff -Nru cppad-2018.00.00.0/test_more/compare_c/det_by_minor.c cppad-2019.02.00.0/test_more/compare_c/det_by_minor.c --- cppad-2018.00.00.0/test_more/compare_c/det_by_minor.c 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/compare_c/det_by_minor.c 2019-01-31 12:35:17.000000000 +0000 @@ -1,15 +1,16 @@ /* $Id: */ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include # include @@ -29,8 +30,8 @@ ------------------------------------------------------------------------------- $begin det_of_minor_c$$ $spell - det - const + det + const $$ $section Determinant of a Minor$$ @@ -45,7 +46,7 @@ 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)} + M_{i,j} = A_{R(i), C(j)} \]$$ where the functions $latex R(i)$$ is defined by the $cref/argument r/det_of_minor/r/$$ and @@ -80,33 +81,33 @@ $head a$$ The argument $icode a$$ has prototype $codei% - const double* %a% + const double* %a% %$$ and is a vector with size $latex m * m$$. The elements of the $latex m \times m$$ matrix $latex A$$ are defined, for $latex i = 0 , \ldots , m-1$$ and $latex j = 0 , \ldots , m-1$$, by $latex \[ - A_{i,j} = a[ i * m + j] + A_{i,j} = a[ i * m + j] \] $$ $head m$$ The argument $icode m$$ has prototype $codei% - size_t %m% + size_t %m% %$$ and is the size of the square matrix $latex A$$. $head n$$ The argument $icode n$$ has prototype $codei% - size_t %n% + size_t %n% %$$ and is the size of the square minor $latex M$$. $head r$$ The argument $icode r$$ has prototype $codei% - size_t* %r% + size_t* %r% %$$ and is a vector with $latex m + 1$$ elements. This vector defines the function $latex R(i)$$ @@ -115,9 +116,9 @@ for $latex i = 0, \ldots , n-1$$ is defined by $latex \[ \begin{array}{rcl} - R(0) & = & r[m] - \\ - R(i+1) & = & r[ R(i) ] + R(0) & = & r[m] + \\ + R(i+1) & = & r[ R(i) ] \end{array} \] $$ All the elements of $icode r$$ must have value @@ -129,7 +130,7 @@ $head c$$ The argument $icode c$$ has prototype $codei% - size_t* %c% + size_t* %c% %$$ and is a vector with $latex m + 1$$ elements This vector defines the function $latex C(i)$$ @@ -138,9 +139,9 @@ for $latex j = 0, \ldots , n-1$$ is defined by $latex \[ \begin{array}{rcl} - C(0) & = & c[m] - \\ - C(j+1) & = & c[ C(j) ] + C(0) & = & c[m] + \\ + C(j+1) & = & c[ C(j) ] \end{array} \] $$ All the elements of $icode c$$ must have value @@ -152,79 +153,80 @@ $head d$$ The result $icode d$$ has prototype $codei% - double %d% + double %d% %$$ and is equal to the determinant of the minor $latex M$$. $spell - Cj + Cj $$ $head Source Code$$ $srccode%cpp% */ double det_of_minor( - const double* a , - size_t m , - size_t n , - size_t* r , - size_t* c ) -{ size_t R0, Cj, Cj1, j; - double detM, M0j, detS; - int s; - - R0 = r[m]; /* R(0) */ - Cj = c[m]; /* C(j) (case j = 0) */ - Cj1 = m; /* C(j-1) (case j = 0) */ - - /* check for 1 by 1 case */ - if( n == 1 ) return a[ R0 * m + Cj ]; - - /* initialize determinant of the minor M */ - detM = 0.; - - /* initialize sign of factor for neat sub-minor */ - s = 1; - - /* remove row with index 0 in M from all the sub-minors of M */ - r[m] = r[R0]; - - /* for each column of M */ - for(j = 0; j < n; j++) - { /* element with index (0,j) in the minor M */ - M0j = a[ R0 * m + Cj ]; - - /* remove column with index j in M to form next sub-minor S of M */ - c[Cj1] = c[Cj]; - - /* compute determinant of the current sub-minor S */ - detS = det_of_minor(a, m, n - 1, r, c); - - /* restore column Cj to representation of M as a minor of A */ - c[Cj1] = Cj; - - /* include this sub-minor term in the summation */ - if( s > 0 ) - detM = detM + M0j * detS; - else detM = detM - M0j * detS; - - /* advance to neat column of M */ - Cj1 = Cj; - Cj = c[Cj]; - s = - s; - } + const double* a , + size_t m , + size_t n , + size_t* r , + size_t* c ) +{ size_t R0, Cj, Cj1, j; + double detM, M0j, detS; + int s; + + R0 = r[m]; /* R(0) */ + Cj = c[m]; /* C(j) (case j = 0) */ + Cj1 = m; /* C(j-1) (case j = 0) */ + + /* check for 1 by 1 case */ + if( n == 1 ) return a[ R0 * m + Cj ]; + + /* initialize determinant of the minor M */ + detM = 0.; + + /* initialize sign of factor for neat sub-minor */ + s = 1; + + /* remove row with index 0 in M from all the sub-minors of M */ + r[m] = r[R0]; + + /* for each column of M */ + for(j = 0; j < n; j++) + { /* element with index (0,j) in the minor M */ + M0j = a[ R0 * m + Cj ]; + + /* remove column with index j in M to form next sub-minor S of M */ + c[Cj1] = c[Cj]; + + /* compute determinant of the current sub-minor S */ + detS = det_of_minor(a, m, n - 1, r, c); + + /* restore column Cj to representation of M as a minor of A */ + c[Cj1] = Cj; + + /* include this sub-minor term in the summation */ + if( s > 0 ) + detM = detM + M0j * detS; + else + detM = detM - M0j * detS; + + /* advance to neat column of M */ + Cj1 = Cj; + Cj = c[Cj]; + s = - s; + } - /* restore row zero to the minor representation for M */ - r[m] = R0; + /* restore row zero to the minor representation for M */ + r[m] = R0; - /* return the determinant of the minor M */ - return detM; + /* return the determinant of the minor M */ + return detM; } /* %$$ $end ------------------------------------------------------------------------------- $begin det_by_minor_c$$ $spell - det - const + det + const $$ $section Compute Determinant using Expansion by Minors$$ @@ -239,59 +241,59 @@ 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_{i, j} + M_{i,j} = A_{i, j} \]$$ $head a$$ The argument $icode a$$ has prototype $codei% - const double* %a% + const double* %a% %$$ and is a vector with size $latex m * m$$. The elements of the $latex m \times m$$ matrix $latex A$$ are defined, for $latex i = 0 , \ldots , m-1$$ and $latex j = 0 , \ldots , m-1$$, by $latex \[ - A_{i,j} = a[ i * m + j] + A_{i,j} = a[ i * m + j] \] $$ $head m$$ The argument $icode m$$ has prototype $codei% - size_t %m% + size_t %m% %$$ and is the number of rows (and columns) in the square matrix $latex A$$. $hilitecmd%codep%$$ $hiliteseq% - %det_of_minor%(%det_of_minor_c + %det_of_minor%(%det_of_minor_c %$$ $spell - det - malloc - sizeof + det + malloc + sizeof $$ $head Source Code$$ $srccode%cpp% */ double det_by_minor(double* a, size_t m) -{ size_t *r, *c, i; - double value; +{ size_t *r, *c, i; + double value; - r = (size_t*) malloc( (m+1) * sizeof(size_t) ); - c = (size_t*) malloc( (m+1) * sizeof(size_t) ); + r = (size_t*) malloc( (m+1) * sizeof(size_t) ); + c = (size_t*) malloc( (m+1) * sizeof(size_t) ); - assert(m <= 100); - for(i = 0; i < m; i++) - { r[i] = i+1; - c[i] = i+1; - } - r[m] = 0; - c[m] = 0; - - value = det_of_minor(a, m, m, r, c); - - free(r); - free(c); - return value; + assert(m <= 100); + for(i = 0; i < m; i++) + { r[i] = i+1; + c[i] = i+1; + } + r[m] = 0; + c[m] = 0; + + value = det_of_minor(a, m, m, r, c); + + free(r); + free(c); + return value; } /* %$$ $end @@ -311,7 +313,7 @@ $head seed$$ The argument $icode seed$$ has prototype $codei% - size_t %seed% + size_t %seed% %$$ It specifies a seed for the uniform random number generator. @@ -319,14 +321,14 @@ $head n$$ The argument $icode n$$ has prototype $codei% - size_t %n% + size_t %n% %$$ It specifies the number of elements in the random vector $icode a$$. $head a$$ The argument $icode a$$ has prototype $codei% - double* %a% + double* %a% %$$. The input value of the elements of $icode a$$ does not matter. Upon return, the elements of $icode a$$ are set to values @@ -334,29 +336,29 @@ $hilitecmd%codep%$$ $hiliteseq% - %elapsed_seconds%(%elapsed_seconds_c% - %repeat_det_by_minor%(%elapsed_seconds_c + %elapsed_seconds%(%elapsed_seconds_c% + %repeat_det_by_minor%(%elapsed_seconds_c %$$ $spell - srand + srand $$ $head Source Code$$ $srccode%cpp% */ void random_seed(size_t seed) -{ srand( (unsigned int) seed ); +{ srand( (unsigned int) seed ); } void uniform_01(size_t n, double* a) -{ static double factor = 1. / (double) RAND_MAX; - while(n--) - a[n] = rand() * factor; +{ static double factor = 1. / (double) RAND_MAX; + while(n--) + a[n] = rand() * factor; } /* %$$ $end ------------------------------------------------------------------------------ $begin correct_det_by_minor_c$$ $spell - det - bool + det + bool $$ $section Correctness Test of det_by_minor Routine$$ @@ -367,46 +369,46 @@ $head flag$$ The return value has prototype $codei% - bool %flag% + bool %flag% %$$ It value is $code 1$$ if the test passes and $code 0$$ otherwise. $hilitecmd%codep%$$ $hiliteseq% - %random_seed%(%uniform_01_c% - %uniform_01%(%uniform_01_c + %random_seed%(%uniform_01_c% + %uniform_01%(%uniform_01_c %$$ $spell - fabs + fabs $$ $head Source Code$$ $srccode%cpp% */ bool correct_det_by_minor(void) -{ double a[9], det, check; +{ double a[9], det, check; + double eps99 = 99.0 * DBL_EPSILON; - random_seed(123); - uniform_01(9, a); + random_seed(123); + uniform_01(9, a); - /* compute determinant using expansion by minors */ - det = det_by_minor(a, 3); + /* compute determinant using expansion by minors */ + det = det_by_minor(a, 3); - /* use expansion by minors to hand code the determinant */ - check = 0.; - check += a[0] * ( a[4] * a[8] - a[5] * a[7] ); - check -= a[1] * ( a[3] * a[8] - a[5] * a[6] ); - check += a[2] * ( a[3] * a[7] - a[4] * a[6] ); - - double eps99 = 99.0 * DBL_EPSILON; - if( fabs(det / check - 1.0) < eps99 ) - return true; - return false; + /* use expansion by minors to hand code the determinant */ + check = 0.; + check += a[0] * ( a[4] * a[8] - a[5] * a[7] ); + check -= a[1] * ( a[3] * a[8] - a[5] * a[6] ); + check += a[2] * ( a[3] * a[7] - a[4] * a[6] ); + + if( fabs(det / check - 1.0) < eps99 ) + return true; + return false; } /* %$$ $end ------------------------------------------------------------------------------ $begin repeat_det_by_minor_c$$ $spell - det + det $$ $section Repeat det_by_minor Routine A Specified Number of Times$$ @@ -417,47 +419,47 @@ $head repeat$$ The argument has prototype $codei% - size_t %repeat% + size_t %repeat% %$$ It specifies the number of times to repeat the calculation. $head size$$ The argument has prototype $codei% - size_t %size% + size_t %size% %$$ It specifies the number of rows (and columns) in the square matrix we are computing the determinant of. $hilitecmd%codep%$$ $hiliteseq% - %uniform_01%(%uniform_01_c% - %det_by_minor%(%det_by_minor_c + %uniform_01%(%uniform_01_c% + %det_by_minor%(%det_by_minor_c %$$ $spell - malloc - sizeof + malloc + sizeof $$ $head Source Code$$ $srccode%cpp% */ void repeat_det_by_minor(size_t repeat, size_t size) -{ double *a; - a = (double*) malloc( (size * size) * sizeof(double) ); +{ double *a; + a = (double*) malloc( (size * size) * sizeof(double) ); - while(repeat--) - { uniform_01(size * size, a); - det_by_minor(a, size); - } + while(repeat--) + { uniform_01(size * size, a); + det_by_minor(a, size); + } - free(a); - return; + free(a); + return; } /* %$$ $end ------------------------------------------------------------------------------ $begin elapsed_seconds_c$$ $spell - gettimeofday + gettimeofday $$ $section Returns Elapsed Number of Seconds$$ @@ -475,72 +477,73 @@ number of seconds since the first call to $code elapsed_seconds$$. $spell - Microsoft - cassert - milli - sys - endif - usec - diff - bool - struct - timeval + Microsoft + cassert + milli + sys + endif + usec + diff + bool + struct + timeval $$ $head Source Code$$ $srccode%cpp% */ # if _MSC_VER // --------------------------------------------------------------------------- // Microsoft version of timer +# define NOMINMAX // so windows.h does not define min and max as macros # include # include double elapsed_seconds(void) -{ static bool first_ = true; - static SYSTEMTIME st_; - double hour, minute, second, milli, diff; - SYSTEMTIME st; - - if( first_ ) - { GetSystemTime(&st_); - first_ = false; - return 0.; - } - GetSystemTime(&st); - - hour = (double) st.wHour - (double) st_.wHour; - minute = (double) st.wMinute - (double) st_.wMinute; - second = (double) st.wSecond - (double) st_.wSecond; - milli = (double) st.wMilliseconds - (double) st_.wMilliseconds; - - diff = 1e-3*milli + second + 60.*minute + 3600.*hour; - if( diff < 0. ) - diff += 3600.*24.; - assert( 0 <= diff && diff < 3600.*24. ); +{ static bool first_ = true; + static SYSTEMTIME st_; + double hour, minute, second, milli, diff; + SYSTEMTIME st; + + if( first_ ) + { GetSystemTime(&st_); + first_ = false; + return 0.; + } + GetSystemTime(&st); + + hour = (double) st.wHour - (double) st_.wHour; + minute = (double) st.wMinute - (double) st_.wMinute; + second = (double) st.wSecond - (double) st_.wSecond; + milli = (double) st.wMilliseconds - (double) st_.wMilliseconds; + + diff = 1e-3*milli + second + 60.*minute + 3600.*hour; + if( diff < 0. ) + diff += 3600.*24.; + assert( 0 <= diff && diff < 3600.*24. ); - return diff; + return diff; } # else // --------------------------------------------------------------------------- // Unix version of timer # include double elapsed_seconds(void) -{ double sec, usec, diff; +{ double sec, usec, diff; - static bool first_ = true; - static struct timeval tv_first; - struct timeval tv; - if( first_ ) - { gettimeofday(&tv_first, NULL); - first_ = false; - return 0.; - } - gettimeofday(&tv, NULL); - assert( tv.tv_sec >= tv_first.tv_sec ); - - sec = (double)(tv.tv_sec - tv_first.tv_sec); - usec = (double)tv.tv_usec - (double)tv_first.tv_usec; - diff = sec + 1e-6*usec; + static bool first_ = true; + static struct timeval tv_first; + struct timeval tv; + if( first_ ) + { gettimeofday(&tv_first, NULL); + first_ = false; + return 0.; + } + gettimeofday(&tv, NULL); + assert( tv.tv_sec >= tv_first.tv_sec ); + + sec = (double)(tv.tv_sec - tv_first.tv_sec); + usec = (double)tv.tv_usec - (double)tv_first.tv_usec; + diff = sec + 1e-6*usec; - return diff; + return diff; } # endif /* %$$ @@ -548,7 +551,7 @@ ----------------------------------------------------------------------------- $begin time_det_by_minor_c$$ $spell - det + det $$ $section Determine Amount of Time to Execute det_by_minor$$ @@ -562,7 +565,7 @@ The $icode size$$ has prototype $codei% - size_t %size% + size_t %size% %$$ It specifies the number of rows (and columns) in the square matrix that the determinant is being calculated for. @@ -570,7 +573,7 @@ $head time_min$$ The argument $icode time_min$$ has prototype $codei% - double %time_min% + double %time_min% %$$ It specifies the minimum amount of time in seconds that the $icode test$$ routine should take. @@ -580,7 +583,7 @@ $head time$$ The return value $icode time$$ has prototype $codei% - double %time% + double %time% %$$ and is the number of wall clock seconds that it took for $code det_by_minor$$ to compute its determinant @@ -588,30 +591,31 @@ $hilitecmd%codep%$$ $hiliteseq% - %elapsed_seconds%(%elapsed_seconds_c% - %repeat_det_by_minor%(%elapsed_seconds_c + %elapsed_seconds%(%elapsed_seconds_c% + %repeat_det_by_minor%(%elapsed_seconds_c %$$ $spell - det + det $$ $head Source Code$$ $srccode%cpp% */ double time_det_by_minor(size_t size, double time_min) -{ size_t repeat; - double s0, s1, time; - repeat = 0; - s0 = elapsed_seconds(); - s1 = s0; - while( s1 - s0 < time_min ) - { if( repeat == 0 ) - repeat = 1; - else repeat = 2 * repeat; - s0 = elapsed_seconds(); - repeat_det_by_minor(repeat, size); - s1 = elapsed_seconds(); - } - time = (s1 - s0) / (double) repeat; - return time; +{ size_t repeat; + double s0, s1, time; + repeat = 0; + s0 = elapsed_seconds(); + s1 = s0; + while( s1 - s0 < time_min ) + { if( repeat == 0 ) + repeat = 1; + else + repeat = 2 * repeat; + s0 = elapsed_seconds(); + repeat_det_by_minor(repeat, size); + s1 = elapsed_seconds(); + } + time = (s1 - s0) / (double) repeat; + return time; } /* %$$ $end @@ -622,39 +626,40 @@ $hilitecmd%codep%$$ $hiliteseq% - %correct_det_by_minor%(%correct_det_by_minor_c% - %random_seed%(%uniform_01_c + %correct_det_by_minor%(%correct_det_by_minor_c% + %random_seed%(%uniform_01_c %$$ $spell - bool - printf - det + bool + printf + det $$ $head Source Code$$ $srccode|cpp| */ int main(void) -{ bool flag; - size_t i; +{ bool flag; + size_t i; - random_seed(123); + random_seed(123); - printf("correct_det_by_minor: "); - flag = correct_det_by_minor(); - if( flag ) - printf("OK\n"); - else printf("Error\n"); - - for(i = 0; i < 5; i++) - { double time_min = 1.0; - size_t size = 2 + i * 2; - int i_size = (int) size; - printf("time_det_minor for %d x %d matrix = ", i_size, i_size); - printf("%g\n", time_det_by_minor(size, time_min) ); - } - - if( flag ) - return 0; - return 1; + printf("correct_det_by_minor: "); + flag = correct_det_by_minor(); + if( flag ) + printf("OK\n"); + else + printf("Error\n"); + + for(i = 0; i < 5; i++) + { double time_min = 1.0; + size_t size = 2 + i * 2; + int i_size = (int) size; + printf("time_det_minor for %d x %d matrix = ", i_size, i_size); + printf("%g\n", time_det_by_minor(size, time_min) ); + } + + if( flag ) + return 0; + return 1; } /* |$$ $end diff -Nru cppad-2018.00.00.0/test_more/compare_c/makefile.am cppad-2019.02.00.0/test_more/compare_c/makefile.am --- cppad-2018.00.00.0/test_more/compare_c/makefile.am 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/compare_c/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # See ./CMakeLists.txt for specifications. @@ -17,17 +18,15 @@ det_by_minor_cpp.cpp: det_by_minor.c cp $(srcdir)/det_by_minor.c det_by_minor_cpp.cpp # -EXTRA_DIST = \ - det_by_minor.c # # erase configures choice of flags DEFS = # -# AM_CXXFLAGS = -g -# AM_CFLAGS = -g +# AM_CXXFLAGS = +# AM_CFLAGS = # -AM_CXXFLAGS = -O2 -DNDEBUG -AM_CFLAGS = -O2 -DNDEBUG +AM_CXXFLAGS = +AM_CFLAGS = # check_PROGRAMS = det_by_minor_c det_by_minor_cpp # diff -Nru cppad-2018.00.00.0/test_more/compare_c/makefile.in cppad-2019.02.00.0/test_more/compare_c/makefile.in --- cppad-2018.00.00.0/test_more/compare_c/makefile.in 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/compare_c/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -197,10 +197,9 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # +# # erase configures choice of flags DEFS = DEPDIR = @DEPDIR@ @@ -270,10 +269,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -292,9 +289,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -317,8 +316,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -340,29 +337,26 @@ top_srcdir = @top_srcdir@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # 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 = +# AM_CFLAGS = # -AM_CXXFLAGS = -O2 -DNDEBUG -AM_CFLAGS = -O2 -DNDEBUG +AM_CXXFLAGS = +AM_CFLAGS = # det_by_minor_c_SOURCES = det_by_minor_c.c det_by_minor_cpp_SOURCES = det_by_minor_cpp.cpp diff -Nru cppad-2018.00.00.0/test_more/cppad_for_tmb/CMakeLists.txt cppad-2019.02.00.0/test_more/cppad_for_tmb/CMakeLists.txt --- cppad-2018.00.00.0/test_more/cppad_for_tmb/CMakeLists.txt 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/cppad_for_tmb/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,44 +1,45 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- -# use cppad_debug_which to determine build type -IF( "${cppad_debug_which}" STREQUAL debug_all ) - SET(CMAKE_BUILD_TYPE DEBUG) -ELSEIF( "${cppad_debug_which}" STREQUAL debug_odd ) - SET(CMAKE_BUILD_TYPE DEBUG) -ELSE( "${cppad_debug_which}" STREQUAL debug_odd ) - SET(CMAKE_BUILD_TYPE RELEASE) -ENDIF( "${cppad_debug_which}" STREQUAL debug_all ) # +# Name for this text SET(name cppad_for_tmb) # -ADD_EXECUTABLE( - ${name} EXCLUDE_FROM_ALL ${name}.cpp +# Add extra compiler flags to cppad_cxx_flags so set_compile_flags uses them. +# This change only affects the cppad_for_tmb tests (NO PARENT_SCOPE). +SET(cppad_cxx_flags "${cppad_cxx_flags} ${OpenMP_CXX_FLAGS} -DCPPAD_FOR_TMB") +# +SET(source_list + ${name}.cpp + implicit_ctor.cpp + perfer_reverse.cpp + multi_atomic.cpp + multi_checkpoint.cpp +) +set_compile_flags( + test_more_${name} "${cppad_debug_which}" "${source_list}" ) # -# Add extra definitions to the complilation flags -SET(cppad_cxx_flags "${cppad_cxx_flags} ${OpenMP_CXX_FLAGS} -D CPPAD_FOR_TMB") +# now that we have the properties, add the executable +ADD_EXECUTABLE( test_more_${name} EXCLUDE_FROM_ALL ${source_list} ) # -# set compiler flags for this executable -SET_TARGET_PROPERTIES( - ${name} PROPERTIES COMPILE_FLAGS "${cppad_cxx_flags}" -) -# extra flags used by linker for openmp support +# Extra flags used by linker for openmp support SET(CMAKE_EXE_LINKER_FLAGS ${OpenMP_CXX_FLAGS} ) # -# check_test_more_cppad_for_tmb target +# check_test_more_${name} target ADD_CUSTOM_TARGET( - check_test_more_${name} ${name} DEPENDS ${name} + check_test_more_${name} test_more_${name} DEPENDS test_more_${name} ) MESSAGE(STATUS "make check_test_more_${name}: available") -# Add check_test_more_cppad_for_tmb to check depends in parent environment +# Add check_test_more_${name} to check depends in parent environment add_to_list(check_test_more_depends check_test_more_${name}) SET(check_test_more_depends "${check_test_more_depends}" PARENT_SCOPE) diff -Nru cppad-2018.00.00.0/test_more/cppad_for_tmb/cppad_for_tmb.cpp cppad-2019.02.00.0/test_more/cppad_for_tmb/cppad_for_tmb.cpp --- cppad-2018.00.00.0/test_more/cppad_for_tmb/cppad_for_tmb.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/cppad_for_tmb/cppad_for_tmb.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,230 +1,38 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include # include -// =========================================================================== -namespace { // BEGIN_EMPTY_NAMESPACE - -using CppAD::AD; -using CppAD::vector; -using CppAD::NearEqual; - -typedef CPPAD_TESTVECTOR(double) d_vector; -typedef CPPAD_TESTVECTOR( AD ) ad_vector; - - -// --------------------------------------------------------------------------- -// implicit constructor from double -bool implicit_constructor(void) -{ bool ok = true; - // - AD< AD > x = 5.0; - ok &= Value(x) == 5.0; - // - return ok; -} - -// ---------------------------------------------------------------------------- -// prefer reverse mode during computation of Jacobians - -// example_tmb_atomic -class example_tmb_atomic : public CppAD::atomic_base { -public: - // constructor - example_tmb_atomic(const std::string& name) - : CppAD::atomic_base(name) - { } - // forward (only implement zero order) - virtual bool forward( - size_t p , - size_t q , - const vector& vx , - vector& vy , - const vector& tx , - vector& ty ) - { - // check for errors in usage - bool ok = p == 0 && q == 0; - ok &= tx.size() == 1; - ok &= ty.size() == 1; - ok &= vx.size() <= 1; - if( ! ok ) - return false; - - // variable information - if( vx.size() > 0 ) - vy[0] = vx[0]; - - // y = 1 / x - ty[0] = 1.0 / tx[0]; - - return ok; - } - // reverse (implement first order) - virtual bool reverse( - size_t q , - const vector& tx , - const vector& ty , - vector& px , - const vector& py ) - { - // check for errors in usage - bool ok = q == 0; - ok &= tx.size() == 1; - ok &= ty.size() == 1; - ok &= px.size() == 1; - ok &= py.size() == 1; - if( ! ok ) - return false; - - // y = 1 / x - // dy/dx = - 1 / (x * x) - double dy_dx = -1.0 / ( tx[0] * tx[0] ); - px[0] = py[0] * dy_dx; - - return ok; - } -}; - -bool prefer_reverse(void) -{ bool ok = true; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // Create atomic functions - example_tmb_atomic afun("reciprocal"); - - // Declare independent variables - size_t n = 1; - CPPAD_TESTVECTOR( AD ) ax(n); - ax[0] = 5.0; - CppAD::Independent(ax); - - // Compute dependent variables - size_t m = 1; - CPPAD_TESTVECTOR( AD ) ay(m); - afun(ax, ay); - - // Create f(x) = 1 / x - CppAD::ADFun f(ax, ay); - - // Use Jacobian to compute f'(x) = - 1 / (x * x). - // This would fail with the normal CppAD distribution because it would use - // first order forward mode for the calculation. - CPPAD_TESTVECTOR(double) x(n), dy_dx(m); - x[0] = 2.0; - dy_dx = f.Jacobian(x); - - // check the result - double check = -1.0 / (x[0] * x[0]); - ok &= NearEqual(dy_dx[0], check, eps99, eps99); - - return ok; -} - -// ---------------------------------------------------------------------------- -// Special version of atomic_base so one functions works for multiple threads. -// -// algorithm that we are checkpoingint -const size_t n_sum_ = 1000; -void square_algo(const ad_vector& ax, ad_vector& ay) -{ ay[0] = 0.0; - for(size_t i = 0; i < n_sum_; ++i) - ay[0] += ax[0]; - return; -} -// inform CppAD if we are in parallel mode -bool in_parallel(void) -{ return omp_in_parallel() != 0; } -// -// inform CppAD of the current thread number -size_t thread_num(void) -{ return static_cast( omp_get_thread_num() ); } -// -// multi_thread_checkpoint -bool multi_thread_checkpoint(void) -{ bool ok = true; - - // OpenMP setup - int num_threads = 4; // number of threads - omp_set_dynamic(0); // turn off dynamic thread adjustment - omp_set_num_threads(num_threads); // set number of OMP threads - - // check that multi-threading is possible on this machine - if( omp_get_max_threads() < 2 ) - { std::cout << "This machine does not support multi-threading: "; - } - - // create checkpoint version of algorithm - size_t n(1), m(1); - ad_vector ax(n), ay(m); - ax[0] = 2.0; - CppAD::atomic_base::option_enum sparsity = - CppAD::atomic_base::set_sparsity_enum; - bool optimize = false; - CppAD::checkpoint atom_fun( - "square", square_algo, ax, ay, sparsity, optimize - ); - - // setup for using CppAD in paralle mode - CppAD::thread_alloc::parallel_setup(num_threads, in_parallel, thread_num); - CppAD::thread_alloc::hold_memory(true); - CppAD::parallel_ad(); - - // place to hold result for each thread - d_vector y(num_threads); - for(int thread = 0; thread < num_threads; thread++) - y[thread] = 0.0; - - # pragma omp parallel for - for(int thread = 0; thread < num_threads; thread++) - { ad_vector au(n), av(m); - au[0] = 1.0; - CppAD::Independent(au); - atom_fun(au, av); - CppAD::ADFun f(au, av); - // - d_vector x(n), v(m); - x[0] = double( thread + 1 ); - v = f.Forward(0, x); - // - // this assigment has false sharing; i.e., will case cache resets - y[thread] = v[0]; - } - - // check the results - for(int thread = 0; thread < num_threads; thread++) - { double check = double( n_sum_ * (thread + 1) ); - ok &= check == y[thread]; - } - return ok; -} - -} // END_EMPTY_NAMESPACE -// =========================================================================== +extern bool implicit_ctor(void); +extern bool prefer_reverse(void); +extern bool multi_atomic(void); +extern bool multi_checkpoint(void); int main(void) -{ std::string group = "test_more/cppad_for_tmb"; - size_t width = 30; - CppAD::test_boolofvoid Run(group, width); - - Run( implicit_constructor, "implicit_constructor" ); - Run( prefer_reverse, "prefer_reverse" ); - Run( prefer_reverse, "prefer_reverse" ); - Run( multi_thread_checkpoint, "multi_thread_checkpoint" ); - - // check for memory leak - bool memory_ok = CppAD::thread_alloc::free_all(); - // print summary at end - bool ok = Run.summary(memory_ok); - // - return static_cast( ! ok ); +{ std::string group = "test_more/cppad_for_tmb"; + size_t width = 30; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + Run( implicit_ctor, "implicit_ctor" ); + Run( prefer_reverse, "prefer_reverse" ); + Run( multi_atomic, "multi_atomic" ); + Run( multi_checkpoint, "multi_checkpoint" ); + + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); } diff -Nru cppad-2018.00.00.0/test_more/cppad_for_tmb/implicit_ctor.cpp cppad-2019.02.00.0/test_more/cppad_for_tmb/implicit_ctor.cpp --- cppad-2018.00.00.0/test_more/cppad_for_tmb/implicit_ctor.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/cppad_for_tmb/implicit_ctor.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,23 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include + +// implicit constructor from double +bool implicit_ctor(void) +{ using CppAD::AD; + bool ok = true; + // + AD< AD > x = 5.0; + ok &= Value(x) == 5.0; + // + return ok; +} diff -Nru cppad-2018.00.00.0/test_more/cppad_for_tmb/multi_atomic.cpp cppad-2019.02.00.0/test_more/cppad_for_tmb/multi_atomic.cpp --- cppad-2018.00.00.0/test_more/cppad_for_tmb/multi_atomic.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/cppad_for_tmb/multi_atomic.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,128 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include + +namespace { + + using CppAD::vector; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR( CppAD::AD ) ad_vector; + + + // -------------------------------------------------------------------- + class long_sum_atomic : public CppAD::atomic_base { + private: + const size_t length_of_sum_; + public: + // constructor + long_sum_atomic(const std::string& name, size_t length_of_sum) + : + CppAD::atomic_base(name) , + length_of_sum_(length_of_sum) + { } + // forward (only implement zero order) + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty ) + { + // check for errors in usage + bool ok = p == 0 && q == 0; + ok &= tx.size() == 1; + ok &= ty.size() == 1; + ok &= vx.size() <= 1; + if( ! ok ) + return false; + + // variable information + if( vx.size() > 0 ) + vy[0] = vx[0]; + + // value information + ty[0] = 0.0; + for(size_t i = 0; i < length_of_sum_; ++i) + ty[0] += tx[0]; + + return ok; + } + }; + // -------------------------------------------------------------------- + + // inform CppAD if we are in parallel mode + bool in_parallel(void) + { return omp_in_parallel() != 0; } + // + // inform CppAD of the current thread number + size_t thread_num(void) + { return static_cast( omp_get_thread_num() ); } + +} + +// multi_thread_checkpoint +bool multi_atomic(void) +{ bool ok = true; + + // OpenMP setup + size_t num_threads = 4; // number of threads + omp_set_dynamic(0); // turn off dynamic thread adjustment + omp_set_num_threads( int(num_threads) ); // set number of OMP threads + + // check that multi-threading is possible on this machine + if( omp_get_max_threads() < 2 ) + { std::cout << "This machine does not support multi-threading: "; + } + + // create checkpoint version of algorithm + size_t n(1), m(1); + ad_vector ax(n), ay(m); + ax[0] = 2.0; + size_t length_of_sum = 5000; + long_sum_atomic atom_fun("long_sum", length_of_sum); + + // setup for using CppAD in paralle mode + CppAD::thread_alloc::parallel_setup(num_threads, in_parallel, thread_num); + CppAD::thread_alloc::hold_memory(true); + CppAD::parallel_ad(); + + // place to hold result for each thread + d_vector y(num_threads); + for(size_t thread = 0; thread < num_threads; thread++) + y[thread] = 0.0; + + # pragma omp parallel for + for(int thread = 0; thread < int(num_threads); thread++) + { ad_vector au(n), av(m); + au[0] = 1.0; + CppAD::Independent(au); + atom_fun(au, av); + CppAD::ADFun f(au, av); + // + d_vector x(n), v(m); + x[0] = double( thread + 1 ); + v = f.Forward(0, x); + // + // this assigment has false sharing; i.e., will case cache resets + // (conversion avoids boost vector conversion warning) + y[size_t(thread)] = v[0]; + } + + // check the results + for(size_t thread = 0; thread < num_threads; thread++) + { double check = double( length_of_sum * (thread + 1) ); + ok &= check == y[thread]; + } + return ok; +} diff -Nru cppad-2018.00.00.0/test_more/cppad_for_tmb/multi_checkpoint.cpp cppad-2019.02.00.0/test_more/cppad_for_tmb/multi_checkpoint.cpp --- cppad-2018.00.00.0/test_more/cppad_for_tmb/multi_checkpoint.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/cppad_for_tmb/multi_checkpoint.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,97 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include + +namespace { + + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR( CppAD::AD ) ad_vector; + + + // algorithm that we are checkpoingint + const size_t length_of_sum_ = 5000; + void long_sum_algo(const ad_vector& ax, ad_vector& ay) + { ay[0] = 0.0; + for(size_t i = 0; i < length_of_sum_; ++i) + ay[0] += ax[0]; + return; + } + // inform CppAD if we are in parallel mode + bool in_parallel(void) + { return omp_in_parallel() != 0; } + // + // inform CppAD of the current thread number + size_t thread_num(void) + { return static_cast( omp_get_thread_num() ); } + +} + +// multi_thread_checkpoint +bool multi_checkpoint(void) +{ bool ok = true; + + // OpenMP setup + size_t num_threads = 4; // number of threads + omp_set_dynamic(0); // turn off dynamic thread adjustment + omp_set_num_threads( int(num_threads) ); // set number of OMP threads + + // check that multi-threading is possible on this machine + if( omp_get_max_threads() < 2 ) + { std::cout << "This machine does not support multi-threading: "; + } + + // create checkpoint version of algorithm + size_t n(1), m(1); + ad_vector ax(n), ay(m); + ax[0] = 2.0; + CppAD::atomic_base::option_enum sparsity = + CppAD::atomic_base::set_sparsity_enum; + bool optimize = false; + CppAD::checkpoint atom_fun( + "long_sum", long_sum_algo, ax, ay, sparsity, optimize + ); + + // setup for using CppAD in paralle mode + CppAD::thread_alloc::parallel_setup(num_threads, in_parallel, thread_num); + CppAD::thread_alloc::hold_memory(true); + CppAD::parallel_ad(); + + // place to hold result for each thread + d_vector y(num_threads); + for(size_t thread = 0; thread < num_threads; thread++) + y[thread] = 0.0; + + # pragma omp parallel for + for(int thread = 0; thread < int(num_threads); thread++) + { ad_vector au(n), av(m); + au[0] = 1.0; + CppAD::Independent(au); + atom_fun(au, av); + CppAD::ADFun f(au, av); + // + d_vector x(n), v(m); + x[0] = double( thread + 1 ); + v = f.Forward(0, x); + // + // this assigment has false sharing; i.e., will case cache resets + // (conversion avoids boost vector conversion warning) + y[size_t(thread)] = v[0]; + } + + // check the results + for(size_t thread = 0; thread < num_threads; thread++) + { double check = double( length_of_sum_ * (thread + 1) ); + ok &= check == y[thread]; + } + return ok; +} diff -Nru cppad-2018.00.00.0/test_more/cppad_for_tmb/perfer_reverse.cpp cppad-2019.02.00.0/test_more/cppad_for_tmb/perfer_reverse.cpp --- cppad-2018.00.00.0/test_more/cppad_for_tmb/perfer_reverse.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/cppad_for_tmb/perfer_reverse.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,116 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +# include +# include + +namespace { // BEGIN_EMPTY_NAMESPACE + +using CppAD::vector; + +// ---------------------------------------------------------------------------- +// prefer reverse mode during computation of Jacobians + +// example_tmb_atomic +class example_tmb_atomic : public CppAD::atomic_base { +public: + // constructor + example_tmb_atomic(const std::string& name) + : CppAD::atomic_base(name) + { } + // forward (only implement zero order) + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty ) + { + // check for errors in usage + bool ok = p == 0 && q == 0; + ok &= tx.size() == 1; + ok &= ty.size() == 1; + ok &= vx.size() <= 1; + if( ! ok ) + return false; + + // variable information + if( vx.size() > 0 ) + vy[0] = vx[0]; + + // y = 1 / x + ty[0] = 1.0 / tx[0]; + + return ok; + } + // reverse (implement first order) + virtual bool reverse( + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py ) + { + // check for errors in usage + bool ok = q == 0; + ok &= tx.size() == 1; + ok &= ty.size() == 1; + ok &= px.size() == 1; + ok &= py.size() == 1; + if( ! ok ) + return false; + + // y = 1 / x + // dy/dx = - 1 / (x * x) + double dy_dx = -1.0 / ( tx[0] * tx[0] ); + px[0] = py[0] * dy_dx; + + return ok; + } +}; + +} // END_EMPTY_NAMESPACE + +bool prefer_reverse(void) +{ bool ok = true; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // Create atomic functions + example_tmb_atomic afun("reciprocal"); + + // Declare independent variables + size_t n = 1; + CPPAD_TESTVECTOR( CppAD::AD ) ax(n); + ax[0] = 5.0; + CppAD::Independent(ax); + + // Compute dependent variables + size_t m = 1; + CPPAD_TESTVECTOR( CppAD::AD ) ay(m); + afun(ax, ay); + + // Create f(x) = 1 / x + CppAD::ADFun f(ax, ay); + + // Use Jacobian to compute f'(x) = - 1 / (x * x). + // This would fail with the normal CppAD distribution because it would use + // first order forward mode for the calculation. + CPPAD_TESTVECTOR(double) x(n), dy_dx(m); + x[0] = 2.0; + dy_dx = f.Jacobian(x); + + // check the result + double check = -1.0 / (x[0] * x[0]); + ok &= CppAD::NearEqual(dy_dx[0], check, eps99, eps99); + + return ok; +} diff -Nru cppad-2018.00.00.0/test_more/debug_rel/CMakeLists.txt cppad-2019.02.00.0/test_more/debug_rel/CMakeLists.txt --- cppad-2018.00.00.0/test_more/debug_rel/CMakeLists.txt 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/debug_rel/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,39 +1,50 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the test_more/general tests # set compiler flags for debug_rel.cpp and debug.cpp +IF( "${debug_which}" STREQUAL "debug_all" ) + SET(debug_extra "${CMAKE_CXX_FLAGS_DEBUG}") + SET(release_extra "${CMAKE_CXX_FLAGS_DEBUG}") +ELSEIF( "${debug_which}" STREQUAL "debug_none" ) + SET(debug_extra "${CMAKE_CXX_FLAGS_RELEASE}") + SET(release_extra "${CMAKE_CXX_FLAGS_RELEASE}") +ELSE( "${debug_which}" ) + SET(debug_extra "${CMAKE_CXX_FLAGS_DEBUG}") + SET(release_extra "${CMAKE_CXX_FLAGS_RELEASE}") +ENDIF( "${debug_which}" STREQUAL "debug_all" ) +# SET_SOURCE_FILES_PROPERTIES( - debug_rel.cpp debug.cpp PROPERITIES COMPILE_FLAGS - "${cppad_cxx_flags} ${CMAKE_CXX_FLAGS_DEBUG} -DCPPAD_DEBUG_AND_RELEASE" + debug_rel.cpp debug.cpp PROPERTIES COMPILE_FLAGS + "${cppad_cxx_flags} ${debug_extra} -DCPPAD_DEBUG_AND_RELEASE" ) - -# et compiler flags for release,cpp +# SET_SOURCE_FILES_PROPERTIES( - release.cpp PROPERITIES COMPILE_FLAGS - "${cppad_cxx_flags} ${CMAKE_CXX_FLAGS_RELEASE} -DCPPAD_DEBUG_AND_RELEASE" + release.cpp PROPERTIES COMPILE_FLAGS + "${cppad_cxx_flags} ${release_extra} -DCPPAD_DEBUG_AND_RELEASE" ) # now that we have the properties, add the executable ADD_EXECUTABLE(test_more_debug_rel EXCLUDE_FROM_ALL - debug_rel.cpp - debug.cpp - release.cpp + debug_rel.cpp + debug.cpp + release.cpp ) # Add the check_test_more_debug_rel target ADD_CUSTOM_TARGET(check_test_more_debug_rel - test_more_debug_rel - DEPENDS - test_more_debug_rel + test_more_debug_rel + DEPENDS + test_more_debug_rel ) MESSAGE(STATUS "make check_test_more_debug_rel: available") diff -Nru cppad-2018.00.00.0/test_more/debug_rel/debug.cpp cppad-2019.02.00.0/test_more/debug_rel/debug.cpp --- cppad-2018.00.00.0/test_more/debug_rel/debug.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/debug_rel/debug.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,32 +1,33 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include // checks that d_ptr points to a double with value 5.0 and then // frees the double using thread_alloc::return_memory bool debug_thread_alloc(double *d_ptr) -{ bool ok = true; - ok &= ( *d_ptr == 5.0); - void* v_ptr = reinterpret_cast(d_ptr); - CppAD::thread_alloc::return_memory(v_ptr); - return ok; +{ bool ok = true; + ok &= ( *d_ptr == 5.0); + void* v_ptr = reinterpret_cast(d_ptr); + CppAD::thread_alloc::return_memory(v_ptr); + return ok; } // just use ADFun constructor void debug_adfun_ctor(void) { - CppAD::vector< CppAD::AD > ax(1), ay(1); - ax[0] = 0.; - CppAD::Independent(ax); - ay[0] = fabs(ax[0]); - CppAD::ADFun f(ax, ay); - return; + CppAD::vector< CppAD::AD > ax(1), ay(1); + ax[0] = 0.; + CppAD::Independent(ax); + ay[0] = fabs(ax[0]); + CppAD::ADFun f(ax, ay); + return; } diff -Nru cppad-2018.00.00.0/test_more/debug_rel/debug_rel.cpp cppad-2019.02.00.0/test_more/debug_rel/debug_rel.cpp --- cppad-2018.00.00.0/test_more/debug_rel/debug_rel.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/debug_rel/debug_rel.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // system include files used for I/O # include @@ -16,23 +17,23 @@ # include namespace { - size_t n_ok = 0; - size_t n_error = 0; - void print_test(bool ok, const char* name) - { - std::cout.width(20); - std::cout.setf( std::ios_base::left ); - std::cout << name; - // - if( ok ) - { std::cout << "OK\n"; - n_ok++; - } - else - { std::cout << "Error\n"; - n_error++; - } - } + size_t n_ok = 0; + size_t n_error = 0; + void print_test(bool ok, const char* name) + { + std::cout.width(20); + std::cout.setf( std::ios_base::left ); + std::cout << name; + // + if( ok ) + { std::cout << "OK\n"; + n_ok++; + } + else + { std::cout << "Error\n"; + n_error++; + } + } } // thread_alloc @@ -45,31 +46,31 @@ // main program that runs all the tests int main(void) -{ using std::cout; - cout << "Begin test_more/debug_rel\n"; - // - // thread_alloc - { double* d_ptr = release_thread_alloc(); - bool ok = debug_thread_alloc(d_ptr); - print_test(ok, "thead_alloc"); - } - // adfun_ctor - { // this test would fail with an assert during release_adfun_ctor - release_adfun_ctor(); - debug_adfun_ctor(); - bool ok = true; - print_test(ok, "adfun_ctor"); - } - // memory - { bool ok = CppAD::thread_alloc::free_all(); - print_test(ok, "memory"); - } - if( n_error == 0 ) - std::cout << "All " << n_ok << " tests passed." << std::endl; - else - std::cout << n_error << " tests failed." << std::endl; - // - if( n_error == 0 ) - return 0; - return 1; +{ using std::cout; + cout << "Begin test_more/debug_rel\n"; + // + // thread_alloc + { double* d_ptr = release_thread_alloc(); + bool ok = debug_thread_alloc(d_ptr); + print_test(ok, "thead_alloc"); + } + // adfun_ctor + { // this test would fail with an assert during release_adfun_ctor + release_adfun_ctor(); + debug_adfun_ctor(); + bool ok = true; + print_test(ok, "adfun_ctor"); + } + // memory + { bool ok = CppAD::thread_alloc::free_all(); + print_test(ok, "memory"); + } + if( n_error == 0 ) + std::cout << "All " << n_ok << " tests passed." << std::endl; + else + std::cout << n_error << " tests failed." << std::endl; + // + if( n_error == 0 ) + return 0; + return 1; } diff -Nru cppad-2018.00.00.0/test_more/debug_rel/release.cpp cppad-2019.02.00.0/test_more/debug_rel/release.cpp --- cppad-2018.00.00.0/test_more/debug_rel/release.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/debug_rel/release.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,33 +1,34 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include // Returns a pointer to a double that has value 5.0 // and must be freed using thread_alloc::return_memory. double *release_thread_alloc(void) -{ size_t min_bytes = sizeof(double); - size_t cap_bytes; - void* v_ptr = CppAD::thread_alloc::get_memory(min_bytes, cap_bytes); - double* d_ptr = reinterpret_cast(v_ptr); - *d_ptr = 5.0; - return d_ptr; +{ size_t min_bytes = sizeof(double); + size_t cap_bytes; + void* v_ptr = CppAD::thread_alloc::get_memory(min_bytes, cap_bytes); + double* d_ptr = reinterpret_cast(v_ptr); + *d_ptr = 5.0; + return d_ptr; } // just use ADFun constructor void release_adfun_ctor(void) { - CppAD::vector< CppAD::AD > ax(1), ay(1); - ax[0] = 0.; - CppAD::Independent(ax); - ay[0] = fabs(ax[0]); - CppAD::ADFun f(ax, ay); - return; + CppAD::vector< CppAD::AD > ax(1), ay(1); + ax[0] = 0.; + CppAD::Independent(ax); + ay[0] = fabs(ax[0]); + CppAD::ADFun f(ax, ay); + return; } diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/atomic_sparsity.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/atomic_sparsity.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/atomic_sparsity.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/atomic_sparsity.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,392 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +Atomic function +g( x ) = [ x_2, x_0 * x_1 ] +\] $$ +*/ +# include +namespace { // isolate items below to this file +using CppAD::vector; // vector +typedef vector< std::set > set_vector; // atomic_sparsity +// +// a utility to compute the union of two sets. +using CppAD::set_union; +// +class atomic_set_sparsity : public CppAD::atomic_base { +public: + // constructor + atomic_set_sparsity(const std::string& name) : + // this exampel only uses set sparsity patterns + CppAD::atomic_base(name, set_sparsity_enum ) + { } +private: + // 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); +# ifndef NDEBUG + size_t m = ty.size() / (q + 1); +# endif + 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 + virtual bool for_sparse_jac( + size_t p , + const set_vector& r , + set_vector& s , + const vector& x ) + { // This function needed if using f.ForSparseJac +# ifndef NDEBUG + size_t n = r.size(); + size_t m = s.size(); +# endif + assert( n == x.size() ); + assert( n == 3 ); + assert( m == 2 ); + + // sparsity for S(x) = f'(x) * R = [ 0, 0, 1 ] * R + s[0] = r[2]; + // s[1] = union(r[0], r[1]) + s[1] = set_union(r[0], r[1]); + // + return true; + } + virtual bool rev_sparse_jac( + size_t p , + const set_vector& rt , + set_vector& st , + const vector& x ) + { // This function needed if using RevSparseJac or optimize +# ifndef NDEBUG + size_t n = st.size(); + size_t m = rt.size(); +# endif + assert( n == x.size() ); + assert( n == 3 ); + assert( m == 2 ); + + // [ 0, x1 ] + // sparsity for S(x)^T = f'(x)^T * R^T = [ 0, x0 ] * R^T + // [ 1, 0 ] + st[0] = rt[1]; + st[1] = rt[1]; + st[2] = rt[0]; + return true; + } + virtual bool for_sparse_hes( + const vector& vx, + const vector& r , + const vector& s , + set_vector& h , + const vector& x ) + { + size_t n = r.size(); +# ifndef NDEBUG + size_t m = s.size(); +# endif + assert( x.size() == n ); + assert( h.size() == n ); + assert( n == 3 ); + assert( m == 2 ); + + // initialize h as empty + for(size_t i = 0; i < n; i++) + h[i].clear(); + + // only f_1 has a non-zero hessian + if( ! s[1] ) + return true; + + // only the cross term between x[0] and x[1] is non-zero + if( ! ( r[0] & r[1] ) ) + return true; + + // set the possibly non-zero terms in the hessian + h[0].insert(1); + h[1].insert(0); + + return true; + } + virtual bool rev_sparse_hes( + const vector& vx, + const vector& s , + vector& t , + size_t p , + const set_vector& r , + const set_vector& u , + set_vector& v , + const vector& x ) + { // This function needed if using RevSparseHes +# ifndef NDEBUG + size_t m = s.size(); + size_t n = t.size(); +# endif + assert( x.size() == n ); + assert( r.size() == n ); + assert( u.size() == m ); + assert( v.size() == n ); + 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 W(x) = f'(x)^T * U(x) = [ 0, x0 ] * U(x) + // [ 1, 0 ] + v[0] = u[1]; + v[1] = u[1]; + v[2] = u[0]; + // + // [ 0, 1, 0 ] + // sparsity for V(x) = W(x) + S_1 (x) * [ 1, 0, 0 ] * R + // [ 0, 0, 0 ] + if( s[1] ) + { // v[0] = union( v[0], r[1] ) + v[0] = set_union(v[0], r[1]); + // v[1] = union( v[1], r[0] ) + v[1] = set_union(v[1], r[0]); + } + return true; + } +}; // End of atomic_set_sparsity class + + +// f(u) = g( u_0 + u_1 , u_0 + u_1 , u_2 ) +// = [ u_2 , (u_0 + u_1)^2 ] +bool test_one(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); + // Create the atomic get_started object + atomic_set_sparsity afun("atomic_set_sparsity"); + size_t n = 3; + size_t m = 2; + vector< AD > au(n), ay(m); + for(size_t j = 0; j < n; j++) + au[j] = double(j + 1); + + // declare independent variables and start tape recording + CppAD::Independent(au); + + // ax + vector< AD > ax(n); + ax[0] = au[0] + au[1]; + ax[1] = au[0] + au[1]; + ax[2] = au[2]; + + // call atomic function + afun(ax, ay); + + // create f: u -> y and stop tape recording + CppAD::ADFun f(au, ay); + + // check function value + ok &= NearEqual(ay[0] , au[2], eps, eps); + ok &= NearEqual(ay[1] , (au[0] + au[1]) * (au[0] + au[1]), eps, eps); + + // correct Jacobian result + set_vector check_s(m); + check_s[0].insert(2); + check_s[1].insert(0); + check_s[1].insert(1); + // compute and test forward mode + { set_vector r(n), s(m); + for(size_t i = 0; i < n; i++) + r[i].insert(i); + s = f.ForSparseJac(n, r); + for(size_t i = 0; i < m; i++) + ok &= s[i] == check_s[i]; + } + // compute and test reverse mode + { set_vector r(m), s(m); + for(size_t i = 0; i < m; i++) + r[i].insert(i); + s = f.RevSparseJac(m, r); + for(size_t i = 0; i < m; i++) + ok &= s[i] == check_s[i]; + } + // correct Hessian result for w_0 * f_0 (u) + w_1 * f_1(u) + set_vector check_h(n); + check_h[0].insert(0); + check_h[0].insert(1); + check_h[1].insert(0); + check_h[1].insert(1); + // compute and test forward mode + { set_vector r(1), s(1), h(n); + for(size_t i = 0; i < m; i++) + s[0].insert(i); + for(size_t j = 0; j < n; j++) + r[0].insert(j); + h = f.ForSparseHes(r, s); + for(size_t i = 0; i < n; i++) + ok &= h[i] == check_h[i]; + } + // compute and test reverse mode + { set_vector s(1), h(n); + for(size_t i = 0; i < m; i++) + s[0].insert(i); + h = f.RevSparseHes(n, s); + for(size_t i = 0; i < n; i++) + ok &= h[i] == check_h[i]; + } + return ok; +} + +// f(u) = g( u_0 + u_1 , u_1 + u_2 , u_2 + u_0 ) +// = [ u_2 + u_0 , (u_0 + u_1)*(u_1 + u_2) ] +bool test_two(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); + // Create the atomic get_started object + atomic_set_sparsity afun("atomic_set_sparsity"); + size_t n = 3; + size_t m = 2; + vector< AD > au(n), ay(m); + for(size_t j = 0; j < n; j++) + au[j] = double(j + 1); + + // declare independent variables and start tape recording + CppAD::Independent(au); + + // ax + vector< AD > ax(n); + ax[0] = au[0] + au[1]; + ax[1] = au[1] + au[2]; + ax[2] = au[2] + au[0]; + + // call atomic function + afun(ax, ay); + + // create f: u -> y and stop tape recording + CppAD::ADFun f(au, ay); + + // check function value + ok &= NearEqual(ay[0] , au[2] + au[0], eps, eps); + ok &= NearEqual(ay[1] , (au[0] + au[1]) * (au[1] + au[2]), eps, eps); + + // correct Jacobian result + set_vector check_s(m); + check_s[0].insert(2); + check_s[0].insert(0); + check_s[1].insert(0); + check_s[1].insert(1); + check_s[1].insert(2); + // compute and test forward mode + { set_vector r(n), s(m); + for(size_t i = 0; i < n; i++) + r[i].insert(i); + s = f.ForSparseJac(n, r); + for(size_t i = 0; i < m; i++) + ok &= s[i] == check_s[i]; + } + // compute and test reverse mode + { set_vector r(m), s(m); + for(size_t i = 0; i < m; i++) + r[i].insert(i); + s = f.RevSparseJac(m, r); + for(size_t i = 0; i < m; i++) + ok &= s[i] == check_s[i]; + } + // ---------------------------------------------------------------------- + // correct Hessian result for f_0 (u) + set_vector check_h(n), s(1); + s[0].insert(0); + // compute and test forward mode + { set_vector r(1), h(n); + for(size_t j = 0; j < n; j++) + r[0].insert(j); + h = f.ForSparseHes(r, s); + for(size_t i = 0; i < n; i++) + ok &= h[i] == check_h[i]; + } + // compute and test reverse mode + { set_vector h(n); + h = f.RevSparseHes(n, s); + for(size_t i = 0; i < n; i++) + ok &= h[i] == check_h[i]; + } + // ---------------------------------------------------------------------- + // correct Hessian result for f_1 (u) + s[0].clear(); + s[0].insert(1); + check_h[0].insert(1); + check_h[0].insert(2); + check_h[1].insert(0); + check_h[1].insert(1); + check_h[1].insert(2); + check_h[2].insert(0); + check_h[2].insert(1); + // compute and test forward mode + { set_vector r(1), h(n); + for(size_t j = 0; j < n; j++) + r[0].insert(j); + h = f.ForSparseHes(r, s); + for(size_t i = 0; i < n; i++) + ok &= h[i] == check_h[i]; + } + // compute and test reverse mode + { set_vector h(n); + h = f.RevSparseHes(n, s); + for(size_t i = 0; i < n; i++) + ok &= h[i] == check_h[i]; + } + return ok; +} + +} // End empty namespace + +bool atomic_sparsity(void) +{ bool ok = true; + ok &= test_one(); + ok &= test_two(); + return ok; +} diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/atomic_two.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/atomic_two.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/atomic_two.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/atomic_two.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,75 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// CPPAD_HAS_* defines +# include + +// system include files used for I/O +# include + +// C style asserts +# include + +// for thread_alloc +# include + +// test runner +# include + +// external compiled tests +extern bool atomic_sparsity(void); +extern bool mat_mul(void); +extern bool base2ad(void); +extern bool for_sparse_hes(void); +extern bool for_sparse_jac(void); +extern bool forward(void); +extern bool get_started(void); +extern bool norm_sq(void); +extern bool reciprocal(void); +extern bool rev_sparse_hes(void); +extern bool rev_sparse_jac(void); +extern bool reverse(void); +extern bool set_sparsity(void); +extern bool tangent(void); + +// main program that runs all the tests +int main(void) +{ std::string group = "test_more/deprecated/atomic_two"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + // external compiled tests + Run( atomic_sparsity, "atomic_sparsity"); + Run( mat_mul, "mat_mul" ); + Run( base2ad, "base2ad" ); + Run( for_sparse_hes, "for_sparse_hes" ); + Run( for_sparse_jac, "for_sparse_jac" ); + Run( forward, "forward" ); + Run( get_started, "get_started" ); + Run( norm_sq, "norm_sq" ); + Run( reciprocal, "reciprocal" ); + Run( rev_sparse_hes, "rev_sparse_hes" ); + Run( rev_sparse_jac, "rev_sparse_jac" ); + Run( reverse, "reverse" ); + Run( set_sparsity, "set_sparsity" ); + Run( tangent, "tangent" ); +# if CPPAD_HAS_EIGEN +# endif + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); +} diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/base2ad.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/base2ad.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/base2ad.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/base2ad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,226 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_two_base2ad.cpp$$ + +$section base2ad with Atomic Operations: Example and Test$$ + +$head Source Code$$ +$srcfile%test_more/deprecated/atomic_two/base2ad.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ +# include +namespace { // isolate items below to this file +// +// abbreviations +using CppAD::AD; +using CppAD::vector; +// +class atomic_base2ad : public CppAD::atomic_base { +// +public: + // constructor (could use const char* for name) + atomic_base2ad(const std::string& name) : + // this example does not use any sparsity patterns + CppAD::atomic_base(name) + { } +private: + // ---------------------------------------------------------------------- + // forward mode + // ---------------------------------------------------------------------- + template + bool template_forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( n == 1 ); + assert( m == 1 ); + + // return flag + bool ok = q == 0; + if( ! ok ) + return ok; + + // check for defining variable information + // This case must always be implemented + if( vx.size() > 0 ) + vy[0] = vx[0]; + + // Order zero forward mode. + // This case must always be implemented + // y^0 = f( x^0 ) = 1 / x^0 + Scalar f = 1. / tx[0]; + if( p <= 0 ) + ty[0] = f; + return ok; + } + // forward mode routines called by ADFun objects + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { return template_forward(p, q, vx, vy, tx, ty); + } + // forward mode routines called by ADFun< AD , Base> objects + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector< AD >& atx , + vector< AD >& aty + ) + { return template_forward(p, q, vx, vy, atx, aty); + } + // ---------------------------------------------------------------------- + // reverse mode + // ---------------------------------------------------------------------- + template + bool template_reverse( + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py + ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( n == 1 ); + assert( m == 1 ); + + // return flag + bool ok = q == 0; + if( ! ok ) + return ok; + + // Order zero reverse mode. + // y^0 = f( x^0 ) = 1 / x^0 + // y^1 = f'( x^0 ) * x^1 = - x^1 / (x^0 * x^0) + px[0] = - py[0] / ( tx[0] * tx[0] ); + return ok; + } + // reverse mode routines called by ADFun objects + virtual bool reverse( + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py + ) + { return template_reverse(q, tx, ty, px, py); + } + // reverse mode routines called by ADFun objects + virtual bool reverse( + size_t q , + const vector< AD >& atx , + const vector< AD >& aty , + vector< AD >& apx , + const vector< AD >& apy + ) + { return template_reverse(q, atx, aty, apx, apy); + } +}; // End of atomic_base2ad class +} // End empty namespace + +bool base2ad(void) +{ bool ok = true; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // Create the atomic base2ad object + atomic_base2ad afun("atomic_base2ad"); + // + // Create the function f(x) + // + 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 atomic function and store base2ad(x) in au[0] + vector< AD > au(m); + afun(ax, au); // u = 1 / x + + // now use AD division to invert to invert the operation + ay[0] = 1.0 / au[0]; // y = 1 / u = x + + // create f: x -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (ax, ay); // f(x) = x + + // 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 reverse + vector dw(n), w(m); + w[0] = 1.0; + dw = f.Reverse(q+1, w); + check = 1.0; + ok &= NearEqual(dw[0] , check, eps, eps); + + // create af : x -> y + CppAD::ADFun< AD , double > af; + af = f.base2ad(); + + // check zero order forward mode + vector< AD > ax_q(n), ay_q(m); + q = 0; + ax_q[0] = x0; + ay_q = af.Forward(q, ax_q); + check = x0; + ok &= NearEqual( Value(ay_q[0]) , check, eps, eps); + + // check first order reverse + vector< AD > adw(n), aw(m); + aw[0] = 1.0; + adw = af.Reverse(q+1, aw); + check = 1.0; + ok &= NearEqual( Value(adw[0]) , check, eps, eps); + + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/CMakeLists.txt cppad-2019.02.00.0/test_more/deprecated/atomic_two/CMakeLists.txt --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,57 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# +# eigen_sources and CPPAD_HAS_EIGEN +IF( cppad_has_eigen ) +ELSE( cppad_has_eigen ) + SET(eigen_sources "") +ENDIF( cppad_has_eigen ) +# +SET(source_list + atomic_two.cpp + atomic_sparsity.cpp + mat_mul.cpp + base2ad.cpp + for_sparse_hes.cpp + for_sparse_jac.cpp + forward.cpp + get_started.cpp + norm_sq.cpp + reciprocal.cpp + rev_sparse_hes.cpp + rev_sparse_jac.cpp + reverse.cpp + set_sparsity.cpp + tangent.cpp +) +set_compile_flags(test_more_deprecated_atomic_two + "${cppad_debug_which}" "${source_list}" +) +# +ADD_EXECUTABLE(test_more_deprecated_atomic_two + EXCLUDE_FROM_ALL ${source_list} +) +# +# Add the check_test_more_deprecated_atomic_two target +ADD_CUSTOM_TARGET(check_test_more_deprecated_atomic_two + test_more_deprecated_atomic_two + DEPENDS test_more_deprecated_atomic_two +) +MESSAGE(STATUS "make check_test_more_deprecated_atomic_two: available") +# +# add to check check_test_more_deprecated_depends in parent environment +add_to_list(check_test_more_deprecated_depends + check_test_more_deprecated_atomic_two +) +SET(check_test_more_deprecated_depends + "${check_test_more_deprecated_depends}" PARENT_SCOPE +) diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/for_sparse_hes.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/for_sparse_hes.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/for_sparse_hes.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/for_sparse_hes.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,323 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_for_sparse_hes.cpp$$ + +$section Atomic Forward Hessian Sparsity: Example and Test$$ + +$head Purpose$$ +This example demonstrates calculation of the forward Hessian sparsity pattern +for an atomic operation. + +$head function$$ +For this example, the atomic function +$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by +$latex \[ +f( x ) = \left( \begin{array}{c} + x_2 * x_2 \\ + x_0 * x_1 +\end{array} \right) +\] $$ +The Hessians of the component functions are +$latex \[ +f_0^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 0 & 0 \\ + 0 & 0 & 0 \\ + 0 & 0 & 2 +\end{array} \right) +\W{,} +f_1^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 1 & 0 \\ + 1 & 0 & 0 \\ + 0 & 0 & 0 +\end{array} \right) +\] $$ + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreviate as vector +// +class atomic_for_sparse_hes : public CppAD::atomic_base { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + // constructor (could use const char* for name) + atomic_for_sparse_hes(const std::string& name) : + // this example only uses pack sparsity patterns + CppAD::atomic_base(name, pack_sparsity_enum) + { } +private: +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( n == 3 ); + assert( m == 2 ); + + // return flag + bool ok = q == 0; + if( ! ok ) + return ok; + + // check for defining variable information + // This case must always be implemented + if( vx.size() > 0 ) + { vy[0] = vx[0]; + vy[1] = vx[0] || vy[0]; + } + + // Order zero forward mode. + // This case must always be implemented + // f(x) = [ x_0 * x_0 ] + // [ x_0 * x_1 ] + assert( p <= 0 ); + if( p <= 0 ) + { ty[0] = tx[2] * tx[2]; + ty[1] = tx[0] * tx[1]; + } + return ok; + } +/* %$$ +$head for_sparse_jac$$ +$srccode%cpp% */ + // forward Jacobian sparsity routine called by CppAD + virtual bool for_sparse_jac( + size_t q , + const CppAD::vectorBool& r , + CppAD::vectorBool& s , + const vector& x ) + { // This function needed because we are using ForSparseHes + // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) +# ifndef NDEBUG + size_t n = r.size() / q; + size_t m = s.size() / q; +# endif + assert( x.size() == n ); + assert( n == 3 ); + assert( m == 2 ); + + + // f'(x) = [ 0, 0, 2 x_2 ] + // [ x_1, x_0, 0 ] + + // sparsity for first row of S(x) = f'(x) * R + size_t i = 0; + for(size_t j = 0; j < q; j++) + s[ i * q + j ] = r[ 2 * q + j ]; + + // sparsity for second row of S(x) = f'(x) * R + i = 1; + for(size_t j = 0; j < q; j++) + s[ i * q + j ] = r[ 0 * q + j ] | r[ 1 * q + j]; + + return true; + } +/* %$$ +$head rev_sparse_jac$$ +$srccode%cpp% */ + // reverse Jacobian sparsity routine called by CppAD + virtual bool rev_sparse_jac( + size_t q , + const CppAD::vectorBool& rt , + CppAD::vectorBool& st , + const vector& x ) + { // This function needed because we are using ForSparseHes + // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) +# ifndef NDEBUG + size_t m = rt.size() / q; + size_t n = st.size() / q; +# endif + assert( x.size() == n ); + assert( n == 3 ); + assert( m == 2 ); + + // [ 0, x_1 ] + // f'(x)^T = [ 0, x_0 ] + // [ 2 x_2, 0 ] + + // sparsity for first row of S(x)^T = f'(x)^T * R^T + size_t i = 0; + for(size_t j = 0; j < q; j++) + st[ i * q + j ] = rt[ 1 * q + j ]; + + // sparsity for second row of S(x)^T = f'(x)^T * R^T + i = 1; + for(size_t j = 0; j < q; j++) + st[ i * q + j ] = rt[ 1 * q + j ]; + + // sparsity for third row of S(x)^T = f'(x)^T * R^T + i = 2; + for(size_t j = 0; j < q; j++) + st[ i * q + j ] = rt[ 0 * q + j ]; + + return true; + } +/* %$$ +$head for_sparse_hes$$ +$srccode%cpp% */ + // forward Hessian sparsity routine called by CppAD + virtual bool for_sparse_hes( + const vector& vx, + const vector& r , + const vector& s , + CppAD::vectorBool& h , + const vector& x ) + { // This function needed because we are using RevSparseHes + // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) + size_t n = r.size(); +# ifndef NDEBUG + size_t m = s.size(); +# endif + assert( x.size() == n ); + assert( n == 3 ); + assert( m == 2 ); + assert( h.size() == n * n ); + + // [ 0 , 0 , 0 ] [ 0 , 1 , 0 ] + // f_0''(x) = [ 0 , 0 , 0 ] f_1^{(2)} (x) = [ 1 , 0 , 0 ] + // [ 0 , 0 , 2 ] [ 0 , 0 , 0 ] + + // initial entire matrix as false + for(size_t i = 0; i < n * n; i++) + h[i] = false; + + // component (2, 2) + h[ 2 * n + 2 ] = s[0] & r[2]; + + // components (1, 0) and (0, 1) + h[ 1 * n + 0 ] = s[1] & r[0] & r[1]; + h[ 0 * n + 1 ] = s[1] & r[0] & r[1]; + + return true; + } +}; // End of atomic_for_sparse_hes class + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool use_atomic_for_sparse_hes(bool x_1_variable) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // Create the atomic for_sparse_hes object + atomic_for_sparse_hes afun("atomic_for_sparse_hes"); + // + // Create the function f(u) + // + // domain space vector + size_t n = 3; + double x_0 = 1.00; + double x_1 = 2.00; + double x_2 = 3.00; + vector< AD > au(n); + au[0] = x_0; + au[1] = x_1; + au[2] = x_2; + + // declare independent variables and start tape recording + CppAD::Independent(au); + + // range space vector + size_t m = 2; + vector< AD > ay(m); + + // call atomic function + vector< AD > ax(n); + ax[0] = au[0]; + ax[2] = au[2]; + if( x_1_variable ) + ax[1] = au[1]; + else + ax[1] = x_1; + afun(ax, ay); // y = [ x_2 * x_2 , x_0 * x_1 ]^T + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // f(u) = y + // + // check function value + double check = x_2 * x_2; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + check = x_0 * x_1; + ok &= NearEqual( Value(ay[1]) , check, eps, eps); + + // check zero order forward mode + size_t q; + vector xq(n), yq(m); + q = 0; + xq[0] = x_0; + xq[1] = x_1; + xq[2] = x_2; + yq = f.Forward(q, xq); + check = x_2 * x_2; + ok &= NearEqual(yq[0] , check, eps, eps); + check = x_0 * x_1; + ok &= NearEqual(yq[1] , check, eps, eps); + + // forward sparse Hessian + CppAD::vectorBool r(n), s(m), h(n * n); + for(size_t j = 0; j < n; j++) + r[j] = true; + for(size_t i = 0; i < m; i++) + s[i] = true; + h = f.ForSparseHes(r, s); + + // check result + CppAD::vectorBool check_h(n * n); + for(size_t i = 0; i < n * n; i++) + check_h[i] = false; + check_h[ 2 * n + 2 ] = true; + if( x_1_variable ) + { check_h[0 * n + 1] = true; + check_h[1 * n + 0] = true; + } + for(size_t i = 0; i < n * n; i++) + ok &= h[ i ] == check_h[ i ]; + // + return ok; +} +} // End empty namespace +/* %$$ +$head Test with x_1 Both a Variable and a Parameter$$ +$srccode%cpp% */ +bool for_sparse_hes(void) +{ bool ok = true; + // test with x_1 a variable + ok &= use_atomic_for_sparse_hes(true); + // test with x_1 a parameter + ok &= use_atomic_for_sparse_hes(false); + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/for_sparse_jac.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/for_sparse_jac.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/for_sparse_jac.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/for_sparse_jac.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,240 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_for_sparse_jac.cpp$$ +$spell + Jacobian +$$ + +$section Atomic Forward Jacobian Sparsity: Example and Test$$ + +$head Purpose$$ +This example demonstrates calculation of the forward Jacobian sparsity pattern +for an atomic operation. + +$head function$$ +For this example, the atomic function +$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by +$latex \[ +f(x) = \left( \begin{array}{c} + x_2 * x_2 \\ + x_0 * x_1 +\end{array} \right) +\] $$ +The corresponding Jacobian is +$latex \[ +f^{(1)} (x) = \left( \begin{array}{ccc} + 0 & 0 & 2 x_2 \\ +x_1 & x_0 & 0 +\end{array} \right) +\] $$ + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreviate as vector +// +class atomic_for_sparse_jac : public CppAD::atomic_base { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + // constructor (could use const char* for name) + atomic_for_sparse_jac(const std::string& name) : + // this example only uses pack sparsty patterns + CppAD::atomic_base(name, pack_sparsity_enum) + { } +private: +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( n == 3 ); + assert( m == 2 ); + + // return flag + bool ok = q == 0; + if( ! ok ) + return ok; + + // check for defining variable information + // This case must always be implemented + if( vx.size() > 0 ) + { vy[0] = vx[2]; + vy[1] = vx[0] || vx[1]; + } + + // Order zero forward mode. + // This case must always be implemented + // f(x) = [ x_2 * x_2 ] + // [ x_0 * x_1 ] + assert( p <= 0 ); + if( p <= 0 ) + { ty[0] = tx[2] * tx[2]; + ty[1] = tx[0] * tx[1]; + } + return ok; + } +/* %$$ +$head for_sparse_jac$$ +$srccode%cpp% */ + // forward Jacobian sparsity routine called by CppAD + virtual bool for_sparse_jac( + size_t q , + const CppAD::vectorBool& r , + CppAD::vectorBool& s , + const vector& x ) + { // This function needed because we are using ForSparseJac + // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) +# ifndef NDEBUG + size_t n = r.size() / q; + size_t m = s.size() / q; +# endif + assert( x.size() == n ); + assert( n == 3 ); + assert( m == 2 ); + + // f'(x) = [ 0, 0, 2 x_2 ] + // [ x_1, x_0, 0 ] + + // sparsity for first row of S(x) = f'(x) * R + size_t i = 0; + for(size_t j = 0; j < q; j++) + s[ i * q + j ] = r[ 2 * q + j ]; + + // sparsity for second row of S(x) = f'(x) * R + i = 1; + for(size_t j = 0; j < q; j++) + s[ i * q + j ] = r[ 0 * q + j ] | r[ 1 * q + j]; + + return true; + } +}; // End of atomic_for_sparse_jac class + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool use_atomic_for_sparse_jac(bool x_1_variable) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // Create the atomic for_sparse_jac object + atomic_for_sparse_jac afun("atomic_for_sparse_jac"); + // + // Create the function f(u) + // + // domain space vector + size_t n = 3; + double x_0 = 1.00; + double x_1 = 2.00; + double x_2 = 3.00; + vector< AD > au(n); + au[0] = x_0; + au[1] = x_1; + au[2] = x_2; + + // declare independent variables and start tape recording + CppAD::Independent(au); + + // range space vector + size_t m = 2; + vector< AD > ay(m); + + // call atomic function + vector< AD > ax(n); + ax[0] = au[0]; + ax[2] = au[2]; + if( x_1_variable ) + ax[1] = au[1]; + else + ax[1] = x_1; + afun(ax, ay); // y = [ x_2 * x_2 , x_0 * x_1 ]^T + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // f(u) = y + // + // check function value + double check = x_2 * x_2; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + check = x_0 * x_1; + ok &= NearEqual( Value(ay[1]) , check, eps, eps); + + // check zero order forward mode + size_t q; + vector xq(n), yq(m); + q = 0; + xq[0] = x_0; + xq[1] = x_1; + xq[2] = x_2; + yq = f.Forward(q, xq); + check = x_2 * x_2; + ok &= NearEqual(yq[0] , check, eps, eps); + check = x_0 * x_1; + ok &= NearEqual(yq[1] , check, eps, eps); + + // forward sparse Jacobian + CppAD::vectorBool r(n * n), s(m * n); + // r = identity matrix + for(size_t i = 0; i < n; i++) + for(size_t j = 0; j < n; j++) + r[ i * n + j] = i == j; + s = f.ForSparseJac(n, r); + + // check result + CppAD::vectorBool check_s(m * n); + check_s[ 0 * n + 0 ] = false; + check_s[ 0 * n + 1 ] = false; + check_s[ 0 * n + 2 ] = true; + check_s[ 1 * n + 0 ] = true; + check_s[ 1 * n + 1 ] = x_1_variable; + check_s[ 1 * n + 2 ] = false; + // + for(size_t i = 0; i < m * n; i++) + ok &= s[ i ] == check_s[ i ]; + // + return ok; +} +} // End empty namespace +/* %$$ +$head Test with x_1 Both a Variable and a Parameter$$ +$srccode%cpp% */ +bool for_sparse_jac(void) +{ bool ok = true; + // test with x_1 a variable + ok &= use_atomic_for_sparse_jac(true); + // test with x_1 a parameter + ok &= use_atomic_for_sparse_jac(false); + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/forward.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/forward.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/forward.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/forward.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,298 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_forward.cpp$$ +$spell + Jacobian +$$ + +$section Atomic Forward: Example and Test$$ + +$head Purpose$$ +This example demonstrates forward mode derivative calculation +using an atomic operation. + +$head function$$ +For this example, the atomic function +$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by +$latex \[ +f(x) = \left( \begin{array}{c} + x_2 * x_2 \\ + x_0 * x_1 +\end{array} \right) +\] $$ +The corresponding Jacobian is +$latex \[ +f^{(1)} (x) = \left( \begin{array}{ccc} + 0 & 0 & 2 x_2 \\ +x_1 & x_0 & 0 +\end{array} \right) +\] $$ +The Hessians of the component functions are +$latex \[ +f_0^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 0 & 0 \\ + 0 & 0 & 0 \\ + 0 & 0 & 2 +\end{array} \right) +\W{,} +f_1^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 1 & 0 \\ + 1 & 0 & 0 \\ + 0 & 0 & 0 +\end{array} \right) +\] $$ + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreviate as vector +// +class atomic_forward : public CppAD::atomic_base { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + // constructor (could use const char* for name) + atomic_forward(const std::string& name) : + // this example does not use sparsity patterns + CppAD::atomic_base(name) + { } +private: +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { + size_t q1 = q + 1; +# ifndef NDEBUG + size_t n = tx.size() / q1; + size_t m = ty.size() / q1; +# endif + assert( n == 3 ); + assert( m == 2 ); + assert( p <= q ); + + // this example only implements up to second order forward mode + bool ok = q <= 2; + if( ! ok ) + return ok; + + // check for defining variable information + // This case must always be implemented + if( vx.size() > 0 ) + { vy[0] = vx[2]; + vy[1] = vx[0] || vx[1]; + } + // ------------------------------------------------------------------ + // Zero forward mode. + // This case must always be implemented + // f(x) = [ x_2 * x_2 ] + // [ x_0 * x_1 ] + // y^0 = f( x^0 ) + if( p <= 0 ) + { // y_0^0 = x_2^0 * x_2^0 + ty[0 * q1 + 0] = tx[2 * q1 + 0] * tx[2 * q1 + 0]; + // y_1^0 = x_0^0 * x_1^0 + ty[1 * q1 + 0] = tx[0 * q1 + 0] * tx[1 * q1 + 0]; + } + if( q <= 0 ) + return ok; + // ------------------------------------------------------------------ + // First order one forward mode. + // This case is needed if first order forward mode is used. + // f'(x) = [ 0, 0, 2 * x_2 ] + // [ x_1, x_0, 0 ] + // y^1 = f'(x^0) * x^1 + if( p <= 1 ) + { // y_0^1 = 2 * x_2^0 * x_2^1 + ty[0 * q1 + 1] = 2.0 * tx[2 * q1 + 0] * tx[2 * q1 + 1]; + // y_1^1 = x_1^0 * x_0^1 + x_0^0 * x_1^1 + ty[1 * q1 + 1] = tx[1 * q1 + 0] * tx[0 * q1 + 1]; + ty[1 * q1 + 1] += tx[0 * q1 + 0] * tx[1 * q1 + 1]; + } + if( q <= 1 ) + return ok; + // ------------------------------------------------------------------ + // Second order forward mode. + // This case is neede if second order forwrd mode is used. + // f'(x) = [ 0, 0, 2 x_2 ] + // [ x_1, x_0, 0 ] + // + // [ 0 , 0 , 0 ] [ 0 , 1 , 0 ] + // f_0''(x) = [ 0 , 0 , 0 ] f_1^{(2)} (x) = [ 1 , 0 , 0 ] + // [ 0 , 0 , 2 ] [ 0 , 0 , 0 ] + // + // y_0^2 = x^1 * f_0''( x^0 ) x^1 / 2! + f_0'( x^0 ) x^2 + // = ( x_2^1 * 2.0 * x_2^1 ) / 2! + // + 2.0 * x_2^0 * x_2^2 + ty[0 * q1 + 2] = tx[2 * q1 + 1] * tx[2 * q1 + 1]; + ty[0 * q1 + 2] += 2.0 * tx[2 * q1 + 0] * tx[2 * q1 + 2]; + // + // y_1^2 = x^1 * f_1''( x^0 ) x^1 / 2! + f_1'( x^0 ) x^2 + // = ( x_1^1 * x_0^1 + x_0^1 * x_1^1) / 2 + // + x_1^0 * x_0^2 + x_0^0 + x_1^2 + ty[1 * q1 + 2] = tx[1 * q1 + 1] * tx[0 * q1 + 1]; + ty[1 * q1 + 2] += tx[1 * q1 + 0] * tx[0 * q1 + 2]; + ty[1 * q1 + 2] += tx[0 * q1 + 0] * tx[1 * q1 + 2]; + // ------------------------------------------------------------------ + return ok; + } +}; +} // End empty namespace +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool forward(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // Create the atomic_forward object + atomic_forward afun("atomic_forward"); + // + // Create the function f(u) + // + // domain space vector + size_t n = 3; + double x_0 = 1.00; + double x_1 = 2.00; + double x_2 = 3.00; + vector< AD > au(n); + au[0] = x_0; + au[1] = x_1; + au[2] = x_2; + + // declare independent variables and start tape recording + CppAD::Independent(au); + + // range space vector + size_t m = 2; + vector< AD > ay(m); + + // call atomic function + vector< AD > ax = au; + afun(ax, ay); + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // y = f(u) + // + // check function value + double check = x_2 * x_2; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + check = x_0 * x_1; + ok &= NearEqual( Value(ay[1]) , check, eps, eps); + + // -------------------------------------------------------------------- + // zero order forward + // + vector x0(n), y0(m); + x0[0] = x_0; + x0[1] = x_1; + x0[2] = x_2; + y0 = f.Forward(0, x0); + check = x_2 * x_2; + ok &= NearEqual(y0[0] , check, eps, eps); + check = x_0 * x_1; + ok &= NearEqual(y0[1] , check, eps, eps); + // -------------------------------------------------------------------- + // first order forward + // + // value of Jacobian of f + double check_jac[] = { + 0.0, 0.0, 2.0 * x_2, + x_1, x_0, 0.0 + }; + vector x1(n), y1(m); + // check first order forward mode + for(size_t j = 0; j < n; j++) + x1[j] = 0.0; + for(size_t j = 0; j < n; j++) + { // compute partial in j-th component direction + x1[j] = 1.0; + y1 = f.Forward(1, x1); + x1[j] = 0.0; + // check this direction + for(size_t i = 0; i < m; i++) + ok &= NearEqual(y1[i], check_jac[i * n + j], eps, eps); + } + // -------------------------------------------------------------------- + // second order forward + // + // value of Hessian of f_0 + double check_hes_0[] = { + 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + 0.0, 0.0, 2.0 + }; + // + // value of Hessian of f_1 + double check_hes_1[] = { + 0.0, 1.0, 0.0, + 1.0, 0.0, 0.0, + 0.0, 0.0, 0.0 + }; + vector x2(n), y2(m); + for(size_t j = 0; j < n; j++) + x2[j] = 0.0; + // compute diagonal elements of the Hessian + for(size_t j = 0; j < n; j++) + { // first order forward in j-th direction + x1[j] = 1.0; + f.Forward(1, x1); + y2 = f.Forward(2, x2); + // check this element of Hessian diagonal + ok &= NearEqual(y2[0], check_hes_0[j * n + j] / 2.0, eps, eps); + ok &= NearEqual(y2[1], check_hes_1[j * n + j] / 2.0, eps, eps); + // + for(size_t k = 0; k < n; k++) if( k != j ) + { x1[k] = 1.0; + f.Forward(1, x1); + y2 = f.Forward(2, x2); + // + // y2 = (H_jj + H_kk + H_jk + H_kj) / 2.0 + // y2 = (H_jj + H_kk) / 2.0 + H_jk + // + double H_jj = check_hes_0[j * n + j]; + double H_kk = check_hes_0[k * n + k]; + double H_jk = y2[0] - (H_kk + H_jj) / 2.0; + ok &= NearEqual(H_jk, check_hes_0[j * n + k], eps, eps); + // + H_jj = check_hes_1[j * n + j]; + H_kk = check_hes_1[k * n + k]; + H_jk = y2[1] - (H_kk + H_jj) / 2.0; + ok &= NearEqual(H_jk, check_hes_1[j * n + k], eps, eps); + // + x1[k] = 0.0; + } + x1[j] = 0.0; + } + // -------------------------------------------------------------------- + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/get_started.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/get_started.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/get_started.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/get_started.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,146 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_two_get_started.cpp$$ + +$section Getting Started with Atomic Operations: Example and Test$$ + +$head Purpose$$ +This example demonstrates the minimal amount of information +necessary for a $cref atomic_two$$ operation. + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreviate as vector +class atomic_get_started : public CppAD::atomic_base { +/* %$$ + +$head Constructor$$ +$srccode%cpp% */ +public: + // constructor (could use const char* for name) + atomic_get_started(const std::string& name) : + // this example does not use any sparsity patterns + CppAD::atomic_base(name) + { } +private: +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( n == 1 ); + assert( m == 1 ); + + // return flag + bool ok = q == 0; + if( ! ok ) + return ok; + + // check for defining variable information + // This case must always be implemented + if( vx.size() > 0 ) + vy[0] = vx[0]; + + // Order zero forward mode. + // This case must always be implemented + // y^0 = f( x^0 ) = 1 / x^0 + double f = 1. / tx[0]; + if( p <= 0 ) + ty[0] = f; + return ok; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_get_started class +} // End empty namespace + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool get_started(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // Create the atomic get_started object + atomic_get_started afun("atomic_get_started"); +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + // 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 atomic function and store get_started(x) in au[0] + vector< AD > au(m); + afun(ax, au); // u = 1 / x + + // now use AD division to invert to invert the operation + ay[0] = 1.0 / au[0]; // y = 1 / u = x + + // create f: x -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (ax, ay); // f(x) = x +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // 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); + + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/makefile.am cppad-2019.02.00.0/test_more/deprecated/atomic_two/makefile.am --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,51 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# automake input file +# +# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp +DEFS = +# +if CppAD_EIGEN +else +EIGEN_SRC_FILES = +endif +# +# +check_PROGRAMS = atomic +# +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) +# +# +atomic_SOURCES = \ + $(EIGEN_SRC_FILES) \ + atomic_two.cpp \ + atomic_sparsity.cpp \ + mat_mul.cpp \ + base2ad.cpp \ + for_sparse_hes.cpp \ + for_sparse_jac.cpp \ + forward.cpp \ + get_started.cpp \ + norm_sq.cpp \ + reciprocal.cpp \ + rev_sparse_hes.cpp \ + rev_sparse_jac.cpp \ + reverse.cpp \ + set_sparsity.cpp \ + tangent.cpp + +test: check + ./atomic diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/makefile.in cppad-2019.02.00.0/test_more/deprecated/atomic_two/makefile.in --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,659 @@ +# makefile.in generated by automake 1.15.1 from makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2017 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +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 \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +check_PROGRAMS = atomic$(EXEEXT) +subdir = test_more/deprecated/atomic_two +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__objects_1 = +am_atomic_OBJECTS = $(am__objects_1) atomic_two.$(OBJEXT) \ + atomic_sparsity.$(OBJEXT) mat_mul.$(OBJEXT) base2ad.$(OBJEXT) \ + for_sparse_hes.$(OBJEXT) for_sparse_jac.$(OBJEXT) \ + forward.$(OBJEXT) get_started.$(OBJEXT) norm_sq.$(OBJEXT) \ + reciprocal.$(OBJEXT) rev_sparse_hes.$(OBJEXT) \ + rev_sparse_jac.$(OBJEXT) reverse.$(OBJEXT) \ + set_sparsity.$(OBJEXT) tangent.$(OBJEXT) +atomic_OBJECTS = $(am_atomic_OBJECTS) +atomic_LDADD = $(LDADD) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(atomic_SOURCES) +DIST_SOURCES = $(atomic_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + 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@ +ACLOCAL = @ACLOCAL@ +ADOLC_DIR = @ADOLC_DIR@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BOOST_DIR = @BOOST_DIR@ +BOOST_INCLUDE = @BOOST_INCLUDE@ +BTHREAD_LIB = @BTHREAD_LIB@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPAD_IPOPT_LD_PATH = @CPPAD_IPOPT_LD_PATH@ +CPPAD_IPOPT_LIBS = @CPPAD_IPOPT_LIBS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXX_FLAGS@ +CYGPATH_W = @CYGPATH_W@ + +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# automake input file +# +# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp +DEFS = +DEPDIR = @DEPDIR@ +DL_LIB = @DL_LIB@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EIGEN_DIR = @EIGEN_DIR@ +EIGEN_INCLUDE = @EIGEN_INCLUDE@ +EXEEXT = @EXEEXT@ +FADBAD_DIR = @FADBAD_DIR@ +FC = @FC@ +FCFLAGS = @FCFLAGS@ +FCLIBS = @FCLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +IPOPT_DIR = @IPOPT_DIR@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAX_NUM_THREADS = @MAX_NUM_THREADS@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +OPENMP_FLAGS = @OPENMP_FLAGS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSTFIX_DIR = @POSTFIX_DIR@ +PTHREAD_LIB = @PTHREAD_LIB@ +RANLIB = @RANLIB@ +SACADO_DIR = @SACADO_DIR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TAPE_ADDR_TYPE = @TAPE_ADDR_TYPE@ +TAPE_ID_TYPE = @TAPE_ID_TYPE@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_FC = @ac_ct_FC@ +adolc_prefix = @adolc_prefix@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ +cppad_boostvector = @cppad_boostvector@ +cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ +cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated_01 = @cppad_deprecated_01@ +cppad_description = @cppad_description@ +cppad_eigenvector = @cppad_eigenvector@ +cppad_has_adolc = @cppad_has_adolc@ +cppad_has_boost = @cppad_has_boost@ +cppad_has_colpack = @cppad_has_colpack@ +cppad_has_eigen = @cppad_has_eigen@ +cppad_has_fadbad = @cppad_has_fadbad@ +cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_ipopt = @cppad_has_ipopt@ +cppad_has_mkstemp = @cppad_has_mkstemp@ +cppad_has_sacado = @cppad_has_sacado@ +cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ +cppad_max_num_threads = @cppad_max_num_threads@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ +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_version = @cppad_version@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +eigen_prefix = @eigen_prefix@ +exec_prefix = @exec_prefix@ +have_pkg_config = @have_pkg_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +ipopt_prefix = @ipopt_prefix@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +# +@CppAD_EIGEN_FALSE@EIGEN_SRC_FILES = +# +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + +# +# +atomic_SOURCES = \ + $(EIGEN_SRC_FILES) \ + atomic_two.cpp \ + atomic_sparsity.cpp \ + mat_mul.cpp \ + base2ad.cpp \ + for_sparse_hes.cpp \ + for_sparse_jac.cpp \ + forward.cpp \ + get_started.cpp \ + norm_sq.cpp \ + reciprocal.cpp \ + rev_sparse_hes.cpp \ + rev_sparse_jac.cpp \ + reverse.cpp \ + set_sparsity.cpp \ + tangent.cpp + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test_more/deprecated/atomic_two/makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign test_more/deprecated/atomic_two/makefile +makefile: $(srcdir)/makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) + +atomic$(EXEEXT): $(atomic_OBJECTS) $(atomic_DEPENDENCIES) $(EXTRA_atomic_DEPENDENCIES) + @rm -f atomic$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(atomic_OBJECTS) $(atomic_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atomic_sparsity.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atomic_two.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base2ad.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_sparse_hes.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/for_sparse_jac.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forward.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_started.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)/reciprocal.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rev_sparse_hes.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rev_sparse_jac.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reverse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_sparsity.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tangent.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) +check: check-am +all-am: makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ + clean-checkPROGRAMS clean-generic cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +.PRECIOUS: makefile + + +test: check + ./atomic + +# 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. +.NOEXPORT: diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/mat_mul.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/mat_mul.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/mat_mul.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/mat_mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,285 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_two_mat_mul.cpp$$ +$spell + mul +$$ + +$section User Atomic Matrix Multiply: Example and Test$$ + +$head See Also$$ +$cref atomic_two_eigen_mat_mul.cpp$$ + +$children% + include/cppad/example/mat_mul.hpp +%$$ + +$head Class Definition$$ +This example uses the file $cref atomic_mat_mul.hpp$$ +which defines matrix multiply as a $cref atomic_two$$ operation. + +$nospell + +$head Use Atomic Function$$ +$srccode%cpp% */ +# include +# include "mat_mul.hpp" + +bool mat_mul(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::vector; + size_t i, j; +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // ------------------------------------------------------------------- + // object that multiplies 2 x 2 matrices + atomic_mat_mul afun; +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + // start recording with four independent varables + size_t n = 4; + vector x(n); + vector< AD > ax(n); + for(j = 0; j < n; j++) + ax[j] = x[j] = double(j + 1); + CppAD::Independent(ax); + + // ------------------------------------------------------------------ + size_t nr_left = 2; + size_t n_middle = 2; + size_t nc_right = 2; + vector< AD > atom_x(3 + (nr_left + nc_right) * n_middle ); + + // matrix dimensions + atom_x[0] = AD( nr_left ); + atom_x[1] = AD( n_middle ); + atom_x[2] = AD( nc_right ); + + // left matrix + atom_x[3] = ax[0]; // left[0, 0] = x0 + atom_x[4] = ax[1]; // left[0, 1] = x1 + atom_x[5] = 5.; // left[1, 0] = 5 + atom_x[6] = 6.; // left[1, 1] = 6 + + // right matix + atom_x[7] = ax[2]; // right[0, 0] = x2 + atom_x[8] = 7.; // right[0, 1] = 7 + atom_x[9] = ax[3]; // right[1, 0] = x3 + atom_x[10] = 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 ] + */ + vector< AD > atom_y(nr_left * nc_right); + afun(atom_x, atom_y); + + ok &= (atom_y[0] == x[0]*x[2] + x[1]*x[3]) & Variable(atom_y[0]); + ok &= (atom_y[1] == x[0]*7. + x[1]*8. ) & Variable(atom_y[1]); + ok &= (atom_y[2] == 5.*x[2] + 6.*x[3]) & Variable(atom_y[2]); + ok &= (atom_y[3] == 5.*7. + 6.*8. ) & Parameter(atom_y[3]); + + // ------------------------------------------------------------------ + // define the function g : x -> atom_y + // g(x) = [ x0*x2 + x1*x3 , x0*7 + x1*8 , 5*x2 + 6*x3 , 5*7 + 6*8 ]^T + CppAD::ADFun g(ax, atom_y); +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // Test zero order forward mode evaluation of g(x) + size_t m = atom_y.size(); + vector y(m); + for(j = 0; j < n; j++) + x[j] = double(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(n), dy(m); + for(j = 0; j < n; j++) + dx[j] = double(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(n), ddy(m); + for(j = 0; j < n; 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.; +/* %$$ +$subhead reverse$$ +$srccode%cpp% */ + // Test second order reverse mode + CppAD::vector w(m), dw(2 * n); + 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.; +/* %$$ +$subhead option$$ +$srccode%cpp% */ + //---------------------------------------------------------------------- + // Test both the boolean and set sparsity at the atomic level + for(size_t sparse_index = 0; sparse_index < 2; sparse_index++) + { if( sparse_index == 0 ) + afun.option( CppAD::atomic_base::bool_sparsity_enum ); + else + afun.option( CppAD::atomic_base::set_sparsity_enum ); +/* %$$ +$subhead for_sparse_jac$$ +$srccode%cpp% */ + // Test forward Jacobian sparsity pattern + /* + g(x) = [ x0*x2 + x1*x3 , x0*7 + x1*8 , 5*x2 + 6*x3 , 5*7 + 6*8 ]^T + 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(n), s(m); + for(j = 0; j < n; j++) + { assert( r[j].empty() ); + r[j].insert(j); + } + s = g.ForSparseJac(n, r); + for(j = 0; j < n; 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(); +/* %$$ +$subhead rev_sparse_jac$$ +$srccode%cpp% */ + // Test reverse Jacobian sparsity pattern + for(i = 0; i < m; i++) + { s[i].clear(); + s[i].insert(i); + } + r = g.RevSparseJac(m, s); + for(j = 0; j < n ; 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(); +/* %$$ +$subhead rev_sparse_hes$$ +$srccode%cpp% */ + /* 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(n), t(1); + t[0].clear(); + t[0].insert(0); + h = g.RevSparseHes(n, t); + size_t check[] = {2, 3, 0, 1}; + for(j = 0; j < n; 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 < n; j++) + t[0].insert(j); + h = g.RevSparseHes(n, t); + for(j = 0; j < n; j++) + { // h[j] = { } + for(i = 0; i < n; i++) + ok &= h[j].find(i) == h[j].end(); + } + + //----------------------------------------------------------------- + } // end for(size_t sparse_index ... + //----------------------------------------------------------------- + + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/mat_mul.hpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/mat_mul.hpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/mat_mul.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/mat_mul.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,677 @@ +# ifndef CPPAD_TEST_MORE_DEPRECATED_ATOMIC_TWO_MAT_MUL_HPP +# define CPPAD_TEST_MORE_DEPRECATED_ATOMIC_TWO_MAT_MUL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_mat_mul.hpp$$ +$spell + Taylor + ty + px + CppAD + jac + hes + nr + nc +$$ + +$section Matrix Multiply as an Atomic Operation$$ + +$head See Also$$ +$cref atomic_eigen_mat_mul.hpp$$ + +$head Matrix Dimensions$$ +This example puts the matrix dimensions in the atomic function arguments, +instead of the $cref/constructor/atomic_two_ctor/$$, so that they can +be different for different calls to the atomic function. +These dimensions are: +$table +$icode nr_left$$ $cnext number of rows in the left matrix $rend +$icode n_middle$$ $cnext rows in the left matrix and columns in right $rend +$icode nc_right$$ $cnext number of columns in the right matrix +$tend + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // Begin empty namespace +using CppAD::vector; +// +using CppAD::set_union; +// +// matrix result = left * right +class atomic_mat_mul : public CppAD::atomic_base { +/* %$$ +$head Constructor$$ +$srccode%cpp% */ +public: + // --------------------------------------------------------------------- + // constructor + atomic_mat_mul(void) : CppAD::atomic_base("mat_mul") + { } +private: +/* %$$ +$head Left Operand Element Index$$ +Index in the Taylor coefficient matrix $icode tx$$ of a left matrix element. +$srccode%cpp% */ + size_t left( + 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 nr_left , // rows in left matrix + size_t n_middle , // rows in left and columns in right + size_t nc_right ) // columns in right matrix + { assert( i < nr_left ); + assert( j < n_middle ); + return (3 + i * n_middle + j) * nk + k; + } +/* %$$ +$head Right Operand Element Index$$ +Index in the Taylor coefficient matrix $icode tx$$ of a right matrix element. +$srccode%cpp% */ + size_t right( + 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 nr_left , // rows in left matrix + size_t n_middle , // rows in left and columns in right + size_t nc_right ) // columns in right matrix + { assert( i < n_middle ); + assert( j < nc_right ); + size_t offset = 3 + nr_left * n_middle; + return (offset + i * nc_right + j) * nk + k; + } +/* %$$ +$head Result Element Index$$ +Index in the Taylor coefficient matrix $icode ty$$ of a result matrix element. +$srccode%cpp% */ + size_t result( + size_t i , // result matrix row index + size_t j , // result matrix column index + size_t k , // Taylor coeffocient order + size_t nk , // number of Taylor coefficients in ty + size_t nr_left , // rows in left matrix + size_t n_middle , // rows in left and columns in right + size_t nc_right ) // columns in right matrix + { assert( i < nr_left ); + assert( j < nc_right ); + return (i * nc_right + j) * nk + k; + } +/* %$$ +$head Forward Matrix Multiply$$ +Forward mode multiply Taylor coefficients in $icode tx$$ and sum into +$icode ty$$ (for one pair of left and right orders) +$srccode%cpp% */ + void forward_multiply( + 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 + size_t nr_left , // rows in left matrix + size_t n_middle , // rows in left and columns in right + size_t nc_right ) // columns in right matrix + { + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t nk = tx.size() / nx; +# ifndef NDEBUG + size_t ny = nr_left * nc_right; + assert( nk == ty.size() / ny ); +# endif + // + size_t k_result = k_left + k_right; + assert( k_result < nk ); + // + for(size_t i = 0; i < nr_left; i++) + { for(size_t j = 0; j < nc_right; j++) + { double sum = 0.0; + for(size_t ell = 0; ell < n_middle; ell++) + { size_t i_left = left( + i, ell, k_left, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k_right, nk, nr_left, n_middle, nc_right + ); + sum += tx[i_left] * tx[i_right]; + } + size_t i_result = result( + i, j, k_result, nk, nr_left, n_middle, nc_right + ); + ty[i_result] += sum; + } + } + } +/* %$$ +$head Reverse Matrix Multiply$$ +Reverse mode partials of Taylor coefficients and sum into $icode px$$ +(for one pair of left and right orders) +$srccode%cpp% */ + void reverse_multiply( + 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 + vector& px , // partials w.r.t. tx + const vector& py , // partials w.r.t. ty + size_t nr_left , // rows in left matrix + size_t n_middle , // rows in left and columns in right + size_t nc_right ) // columns in right matrix + { + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t nk = tx.size() / nx; +# ifndef NDEBUG + size_t ny = nr_left * nc_right; + assert( nk == ty.size() / ny ); +# endif + assert( tx.size() == px.size() ); + assert( ty.size() == py.size() ); + // + size_t k_result = k_left + k_right; + assert( k_result < nk ); + // + for(size_t i = 0; i < nr_left; i++) + { for(size_t j = 0; j < nc_right; j++) + { size_t i_result = result( + i, j, k_result, nk, nr_left, n_middle, nc_right + ); + for(size_t ell = 0; ell < n_middle; ell++) + { size_t i_left = left( + i, ell, k_left, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k_right, nk, nr_left, n_middle, nc_right + ); + // sum += tx[i_left] * tx[i_right]; + px[i_left] += tx[i_right] * py[i_result]; + px[i_right] += tx[i_left] * py[i_result]; + } + } + } + return; + } +/* %$$ +$head forward$$ +Routine called by CppAD during $cref Forward$$ mode. +$srccode%cpp% */ + virtual bool forward( + size_t q , + size_t p , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { size_t n_order = p + 1; + size_t nr_left = size_t( tx[ 0 * n_order + 0 ] ); + size_t n_middle = size_t( tx[ 1 * n_order + 0 ] ); + size_t nc_right = size_t( tx[ 2 * n_order + 0 ] ); +# ifndef NDEBUG + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t ny = nr_left * nc_right; +# endif + assert( vx.size() == 0 || nx == vx.size() ); + assert( vx.size() == 0 || ny == vy.size() ); + assert( nx * n_order == tx.size() ); + assert( ny * n_order == ty.size() ); + size_t i, j, ell; + + // check if we are computing vy information + if( vx.size() > 0 ) + { size_t nk = 1; + size_t k = 0; + for(i = 0; i < nr_left; i++) + { for(j = 0; j < nc_right; j++) + { bool var = false; + for(ell = 0; ell < n_middle; ell++) + { size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + bool nz_left = vx[i_left] |(tx[i_left] != 0.); + bool nz_right = vx[i_right]|(tx[i_right] != 0.); + // if not multiplying by the constant zero + if( nz_left & nz_right ) + var |= bool(vx[i_left]) | bool(vx[i_right]); + } + size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + vy[i_result] = var; + } + } + } + + // initialize result as zero + size_t k; + for(i = 0; i < nr_left; i++) + { for(j = 0; j < nc_right; j++) + { for(k = q; k <= p; k++) + { size_t i_result = result( + i, j, k, n_order, nr_left, n_middle, nc_right + ); + ty[i_result] = 0.0; + } + } + } + for(k = q; k <= p; k++) + { // sum the produces that result in order k + for(ell = 0; ell <= k; ell++) + forward_multiply( + ell, k - ell, tx, ty, nr_left, n_middle, nc_right + ); + } + + // all orders are implented, so always return true + return true; + } +/* %$$ +$head reverse$$ +Routine called by CppAD during $cref Reverse$$ mode. +$srccode%cpp% */ + virtual bool reverse( + size_t p , + const vector& tx , + const vector& ty , + vector& px , + const vector& py + ) + { size_t n_order = p + 1; + size_t nr_left = size_t( tx[ 0 * n_order + 0 ] ); + size_t n_middle = size_t( tx[ 1 * n_order + 0 ] ); + size_t nc_right = size_t( tx[ 2 * n_order + 0 ] ); +# ifndef NDEBUG + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t ny = nr_left * nc_right; +# endif + assert( nx * n_order == tx.size() ); + assert( ny * n_order == ty.size() ); + assert( px.size() == tx.size() ); + assert( py.size() == ty.size() ); + + // initialize summation + for(size_t i = 0; i < px.size(); i++) + px[i] = 0.0; + + // number of orders to differentiate + size_t k = n_order; + while(k--) + { // differentiate the produces that result in order k + for(size_t ell = 0; ell <= k; ell++) + reverse_multiply( + ell, k - ell, tx, ty, px, py, nr_left, n_middle, nc_right + ); + } + + // all orders are implented, so always return true + return true; + } +/* %$$ +$head for_sparse_jac$$ +Routines called by CppAD during $cref ForSparseJac$$. +$srccode%cpp% */ + // boolean sparsity patterns + virtual bool for_sparse_jac( + size_t q , + const vector& r , + vector& s , + const vector& x ) + { + size_t nr_left = size_t( CppAD::Integer( x[0] ) ); + size_t n_middle = size_t( CppAD::Integer( x[1] ) ); + size_t nc_right = size_t( CppAD::Integer( x[2] ) ); +# ifndef NDEBUG + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t ny = nr_left * nc_right; +# endif + assert( nx == x.size() ); + assert( nx * q == r.size() ); + assert( ny * q == s.size() ); + size_t p; + + // sparsity for S(x) = f'(x) * R + size_t nk = 1; + size_t k = 0; + for(size_t i = 0; i < nr_left; i++) + { for(size_t j = 0; j < nc_right; j++) + { size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + for(p = 0; p < q; p++) + s[i_result * q + p] = false; + for(size_t ell = 0; ell < n_middle; ell++) + { size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + for(p = 0; p < 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 ] ); + } + } + } + } + return true; + } + // set sparsity patterns + virtual bool for_sparse_jac( + size_t q , + const vector< std::set >& r , + vector< std::set >& s , + const vector& x ) + { + size_t nr_left = size_t( CppAD::Integer( x[0] ) ); + size_t n_middle = size_t( CppAD::Integer( x[1] ) ); + size_t nc_right = size_t( CppAD::Integer( x[2] ) ); +# ifndef NDEBUG + size_t nx = 3 + (nr_left + nc_right) * n_middle; + size_t ny = nr_left * nc_right; +# endif + assert( nx == x.size() ); + assert( nx == r.size() ); + assert( ny == s.size() ); + + // sparsity for S(x) = f'(x) * R + size_t nk = 1; + size_t k = 0; + for(size_t i = 0; i < nr_left; i++) + { for(size_t j = 0; j < nc_right; j++) + { size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + s[i_result].clear(); + for(size_t ell = 0; ell < n_middle; ell++) + { size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + // + s[i_result] = set_union(s[i_result], r[i_left] ); + s[i_result] = set_union(s[i_result], r[i_right] ); + } + } + } + return true; + } +/* %$$ +$head rev_sparse_jac$$ +Routines called by CppAD during $cref RevSparseJac$$. +$srccode%cpp% */ + // boolean sparsity patterns + virtual bool rev_sparse_jac( + size_t q , + const vector& rt , + vector& st , + const vector& x ) + { + size_t nr_left = size_t( CppAD::Integer( x[0] ) ); + size_t n_middle = size_t( CppAD::Integer( x[1] ) ); + size_t nc_right = size_t( CppAD::Integer( x[2] ) ); + size_t nx = 3 + (nr_left + nc_right) * n_middle; +# ifndef NDEBUG + size_t ny = nr_left * nc_right; +# endif + assert( nx == x.size() ); + assert( nx * q == st.size() ); + assert( ny * q == rt.size() ); + size_t i, j, p; + + // initialize + for(i = 0; i < nx; i++) + { for(p = 0; p < q; p++) + st[ i * q + p ] = false; + } + + // sparsity for S(x)^T = f'(x)^T * R^T + size_t nk = 1; + size_t k = 0; + for(i = 0; i < nr_left; i++) + { for(j = 0; j < nc_right; j++) + { size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + for(size_t ell = 0; ell < n_middle; ell++) + { size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + for(p = 0; p < q; p++) + { st[i_left * q + p] |= bool( rt[i_result * q + p] ); + st[i_right* q + p] |= bool( rt[i_result * q + p] ); + } + } + } + } + return true; + } + // set sparsity patterns + virtual bool rev_sparse_jac( + size_t q , + const vector< std::set >& rt , + vector< std::set >& st , + const vector& x ) + { + size_t nr_left = size_t( CppAD::Integer( x[0] ) ); + size_t n_middle = size_t( CppAD::Integer( x[1] ) ); + size_t nc_right = size_t( CppAD::Integer( x[2] ) ); + size_t nx = 3 + (nr_left + nc_right) * n_middle; +# ifndef NDEBUG + size_t ny = nr_left * nc_right; +# endif + assert( nx == x.size() ); + assert( nx == st.size() ); + assert( ny == rt.size() ); + size_t i, j; + + // initialize + for(i = 0; i < nx; i++) + st[i].clear(); + + // sparsity for S(x)^T = f'(x)^T * R^T + size_t nk = 1; + size_t k = 0; + for(i = 0; i < nr_left; i++) + { for(j = 0; j < nc_right; j++) + { size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + for(size_t ell = 0; ell < n_middle; ell++) + { size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + // + st[i_left] = set_union(st[i_left], rt[i_result]); + st[i_right] = set_union(st[i_right], rt[i_result]); + } + } + } + return true; + } +/* %$$ +$head rev_sparse_hes$$ +Routines called by $cref RevSparseHes$$. +$srccode%cpp% */ + // set sparsity patterns + 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 , + const vector& x ) + { + size_t nr_left = size_t( CppAD::Integer( x[0] ) ); + size_t n_middle = size_t( CppAD::Integer( x[1] ) ); + size_t nc_right = size_t( CppAD::Integer( x[2] ) ); + size_t nx = 3 + (nr_left + nc_right) * n_middle; +# ifndef NDEBUG + size_t ny = nr_left * nc_right; +# endif + assert( x.size() == nx ); + assert( vx.size() == nx ); + assert( t.size() == nx ); + assert( r.size() == nx ); + assert( v.size() == nx ); + assert( s.size() == ny ); + assert( u.size() == ny ); + // + size_t i, j; + // + // initilaize sparsity patterns as false + for(j = 0; j < nx; j++) + { t[j] = false; + v[j].clear(); + } + size_t nk = 1; + size_t k = 0; + for(i = 0; i < nr_left; i++) + { for(j = 0; j < nc_right; j++) + { size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + for(size_t ell = 0; ell < n_middle; ell++) + { size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + // + // Compute sparsity for T(x) = S(x) * f'(x). + // We need not use vx with f'(x) back propagation. + 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 + // 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) + v[i_left] = set_union(v[i_left], u[i_result] ); + v[i_right] = set_union(v[i_right], u[i_result] ); + + // 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] ) + { v[i_left] = set_union(v[i_left], r[i_right] ); + v[i_right] = set_union(v[i_right], r[i_left] ); + } + } + } + } + return true; + } + // bool sparsity + virtual bool rev_sparse_hes( + const vector& vx, + const vector& s , + vector& t , + size_t q , + const vector& r , + const vector& u , + vector& v , + const vector& x ) + { + size_t nr_left = size_t( CppAD::Integer( x[0] ) ); + size_t n_middle = size_t( CppAD::Integer( x[1] ) ); + size_t nc_right = size_t( CppAD::Integer( x[2] ) ); + size_t nx = 3 + (nr_left + nc_right) * n_middle; +# ifndef NDEBUG + size_t ny = nr_left * nc_right; +# endif + assert( x.size() == nx ); + assert( vx.size() == nx ); + assert( t.size() == nx ); + assert( r.size() == nx * q ); + assert( v.size() == nx * q ); + assert( s.size() == ny ); + assert( u.size() == ny * q ); + size_t i, j, p; + // + // initilaize sparsity patterns as false + for(j = 0; j < nx; j++) + { t[j] = false; + for(p = 0; p < q; p++) + v[j * q + p] = false; + } + size_t nk = 1; + size_t k = 0; + for(i = 0; i < nr_left; i++) + { for(j = 0; j < nc_right; j++) + { size_t i_result = result( + i, j, k, nk, nr_left, n_middle, nc_right + ); + for(size_t ell = 0; ell < n_middle; ell++) + { size_t i_left = left( + i, ell, k, nk, nr_left, n_middle, nc_right + ); + size_t i_right = right( + ell, j, k, nk, nr_left, n_middle, nc_right + ); + // + // Compute sparsity for T(x) = S(x) * f'(x). + // We so not need to use vx with f'(x) propagation. + 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 + // 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] |= 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] |= bool( r[i_right * q + p] ); + v[i_right * q + p] |= bool( r[i_left * q + p] ); + } + } + } + } + } + return true; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of mat_mul class +} // End empty namespace +/* %$$ +$comment end nospell$$ +$end +*/ + + +# endif diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/norm_sq.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/norm_sq.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/norm_sq.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/norm_sq.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,383 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_two_norm_sq.cpp$$ +$spell + sq + bool + enum +$$ + +$section Atomic Euclidean Norm Squared: Example and Test$$ + +$head Theory$$ +This example demonstrates using $cref atomic_two$$ +to define the operation +$latex f : \B{R}^n \rightarrow \B{R}^m$$ where +$latex n = 2$$, $latex m = 1$$, where +$latex \[ + f(x) = x_0^2 + x_1^2 +\] $$ + +$head sparsity$$ +This example only uses bool sparsity patterns. + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreviate as vector +// +class atomic_norm_sq : public CppAD::atomic_base { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + // constructor (could use const char* for 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: +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q+1); + size_t m = ty.size() / (q+1); +# endif + assert( n == 2 ); + assert( m == 1 ); + assert( p <= q ); + + // return flag + bool ok = q <= 1; + + // Variable information must always be implemented. + // y_0 is a variable if and only if x_0 or x_1 is a variable. + if( vx.size() > 0 ) + vy[0] = vx[0] | vx[1]; + + // Order zero forward mode must always be implemented. + // 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 ) + if( p <= 0 ) + ty[0] = f; // y_0^0 + if( q <= 0 ) + return ok; + assert( vx.size() == 0 ); + + // Order one forward mode. + // This case needed if first order forward mode is used. + // y^1 = f'( x^0 ) x^1 + double x_01 = tx[ 0*(q+1) + 1]; // x_0^1 + double x_11 = tx[ 1*(q+1) + 1]; // x_1^1 + double fp_0 = 2.0 * x_00; // partial f w.r.t x_0^0 + double fp_1 = 2.0 * x_10; // partial f w.r.t x_1^0 + if( p <= 1 ) + ty[1] = fp_0 * x_01 + fp_1 * x_11; // f'( x^0 ) * x^1 + if( q <= 1 ) + return ok; + + // Assume we are not using forward mode with order > 1 + assert( ! ok ); + return ok; + } +/* %$$ +$head reverse$$ +$srccode%cpp% */ + // reverse mode routine called by CppAD + virtual bool reverse( + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py + ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q+1); + size_t m = ty.size() / (q+1); +# endif + assert( px.size() == n * (q+1) ); + assert( py.size() == m * (q+1) ); + assert( n == 2 ); + assert( m == 1 ); + bool ok = q <= 1; + + double fp_0, fp_1; + switch(q) + { case 0: + // This case needed if first order reverse mode is used + // F ( {x} ) = f( x^0 ) = y^0 + fp_0 = 2.0 * tx[0]; // partial F w.r.t. x_0^0 + fp_1 = 2.0 * tx[1]; // partial F w.r.t. x_0^1 + px[0] = py[0] * fp_0;; // partial G w.r.t. x_0^0 + px[1] = py[0] * fp_1;; // partial G w.r.t. x_0^1 + assert(ok); + break; + + default: + // Assume we are not using reverse with order > 1 (q > 0) + assert(!ok); + } + return ok; + } +/* %$$ +$head for_sparse_jac$$ +$srccode%cpp% */ + // forward Jacobian bool sparsity routine called by CppAD + virtual bool for_sparse_jac( + size_t p , + const vector& r , + vector& s , + const vector& x ) + { // This function needed if using f.ForSparseJac + size_t n = r.size() / p; +# ifndef NDEBUG + size_t m = s.size() / p; +# endif + assert( n == x.size() ); + assert( n == 2 ); + assert( m == 1 ); + + // 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++) + { // Visual Studio 2013 generates warning without bool below + s[j] |= bool( r[i * p + j] ); + } + } + return true; + } +/* %$$ +$head rev_sparse_jac$$ +$srccode%cpp% */ + // reverse Jacobian bool sparsity routine called by CppAD + virtual bool rev_sparse_jac( + size_t p , + const vector& rt , + vector& st , + const vector& x ) + { // This function needed if using RevSparseJac or optimize + size_t n = st.size() / p; +# ifndef NDEBUG + size_t m = rt.size() / p; +# endif + assert( n == x.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 + for(size_t j = 0; j < p; j++) + for(size_t i = 0; i < n; i++) + st[i * p + j] = rt[j]; + + return true; + } +/* %$$ +$head rev_sparse_hes$$ +$srccode%cpp% */ + // 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 , + const vector& x ) + { // This function needed if using RevSparseHes +# ifndef NDEBUG + size_t m = s.size(); +# endif + size_t n = t.size(); + assert( x.size() == n ); + assert( r.size() == n * p ); + assert( u.size() == m * p ); + assert( v.size() == n * p ); + assert( n == 2 ); + assert( m == 1 ); + + // 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) + 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) + + // back propagate the sparsity for U + size_t j; + for(j = 0; j < p; j++) + for(size_t i = 0; i < n; i++) + v[ i * p + j] = u[j]; + + // include forward Jacobian sparsity in Hessian sparsity + // sparsity for g'(y) * f''(x) * R (Note f''(x) has same sparsity + // as the identity matrix) + if( s[0] ) + { for(j = 0; j < p; j++) + for(size_t i = 0; i < n; i++) + { // Visual Studio 2013 generates warning without bool below + v[ i * p + j] |= bool( r[ i * p + j] ); + } + } + + return true; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_norm_sq class +} // End empty namespace + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool norm_sq(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // -------------------------------------------------------------------- + // Create the atomic reciprocal object + atomic_norm_sq afun("atomic_norm_sq"); +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + // Create the function f(x) + // + // domain space vector + size_t n = 2; + double x0 = 0.25; + double x1 = 0.75; + vector< AD > ax(n); + ax[0] = x0; + ax[1] = x1; + + // declare independent variables and start tape recording + CppAD::Independent(ax); + + // range space vector + size_t m = 1; + vector< AD > ay(m); + + // call atomic 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); +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // check function value + double check = x0 * x0 + x1 * x1; + 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; + x_q[1] = x1; + 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] = 0.3; + x_q[1] = 0.7; + y_q = f.Forward(q, x_q); + check = 2.0 * x0 * x_q[0] + 2.0 * x1 * x_q[1]; + ok &= NearEqual(y_q[0] , check, eps, eps); + +/* %$$ +$subhead reverse$$ +$srccode%cpp% */ + // first order reverse mode + q = 1; + vector w(m), dw(n * q); + w[0] = 1.; + dw = f.Reverse(q, w); + check = 2.0 * x0; + ok &= NearEqual(dw[0] , check, eps, eps); + check = 2.0 * x1; + ok &= NearEqual(dw[1] , check, eps, eps); +/* %$$ +$subhead for_sparse_jac$$ +$srccode%cpp% */ + // forward mode sparstiy pattern + size_t p = n; + CppAD::vectorBool r1(n * p), s1(m * p); + r1[0] = true; r1[1] = false; // sparsity pattern identity + r1[2] = false; r1[3] = true; + // + 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] +/* %$$ +$subhead rev_sparse_jac$$ +$srccode%cpp% */ + // 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] + ok &= r2[1] == true; // f[0] depends on x[1] +/* %$$ +$subhead rev_sparse_hes$$ +$srccode%cpp% */ + // 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; // 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; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/reciprocal.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/reciprocal.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/reciprocal.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/reciprocal.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,399 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_two_reciprocal.cpp$$ +$spell + enum +$$ + +$section Reciprocal as an Atomic Operation: Example and Test$$ + +$head Theory$$ +This example demonstrates using $cref atomic_two$$ +to define the operation +$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$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreviate as vector +// +// a utility to compute the union of two sets. +using CppAD::set_union; +// +class atomic_reciprocal : public CppAD::atomic_base { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + // constructor (could use const char* for name) + atomic_reciprocal(const std::string& name) : + // this exmaple only uses set sparsity patterns + CppAD::atomic_base(name, atomic_base::set_sparsity_enum) + { } +private: +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( n == 1 ); + assert( m == 1 ); + assert( p <= q ); + + // return flag + bool ok = q <= 2; + + // check for defining variable information + // This case must always be implemented + if( vx.size() > 0 ) + vy[0] = vx[0]; + + // Order zero forward mode. + // This case must always be implemented + // y^0 = f( x^0 ) = 1 / x^0 + double f = 1. / tx[0]; + if( p <= 0 ) + ty[0] = f; + if( q <= 0 ) + return ok; + assert( vx.size() == 0 ); + + // Order one forward mode. + // This case needed if first order forward mode is used. + // y^1 = f'( x^0 ) x^1 + double fp = - f / tx[0]; + if( p <= 1 ) + ty[1] = fp * tx[1]; + if( q <= 1 ) + return ok; + + // Order two forward mode. + // This case needed if second order forward mode is used. + // 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 + double fpp = - 2.0 * fp / tx[0]; + ty[2] = tx[1] * fpp * tx[1] / 2.0 + fp * tx[2]; + if( q <= 2 ) + return ok; + + // Assume we are not using forward mode with order > 2 + assert( ! ok ); + return ok; + } +/* %$$ +$head reverse$$ +$srccode%cpp% */ + // reverse mode routine called by CppAD + virtual bool reverse( + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py + ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( px.size() == n * (q + 1) ); + assert( py.size() == m * (q + 1) ); + assert( n == 1 ); + assert( m == 1 ); + bool ok = q <= 2; + + double f, fp, fpp, fppp; + switch(q) + { case 0: + // This case 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;; + assert(ok); + break; + + case 1: + // This case 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; + assert(ok); + break; + + case 2: + // This 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; + assert(ok); + break; + + default: + assert(!ok); + } + return ok; + } +/* %$$ +$head for_sparse_jac$$ +$srccode%cpp% */ + // 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 , + const vector& x ) + { // This function needed if using f.ForSparseJac +# ifndef NDEBUG + size_t n = r.size(); + size_t m = s.size(); +# endif + assert( n == x.size() ); + 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; + } +/* %$$ +$head rev_sparse_jac$$ +$srccode%cpp% */ + // 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 , + const vector& x ) + { // This function needed if using RevSparseJac or optimize +# ifndef NDEBUG + size_t n = st.size(); + size_t m = rt.size(); +# endif + assert( n == x.size() ); + assert( n == 1 ); + assert( m == 1 ); + + // sparsity for S(x)^T = f'(x)^T * R^T is same as sparsity for R^T + st[0] = rt[0]; + + return true; + } +/* %$$ +$head rev_sparse_hes$$ +$srccode%cpp% */ + // 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 , + const vector& x ) + { // This function needed if using RevSparseHes +# ifndef NDEBUG + size_t n = vx.size(); + size_t m = s.size(); +# endif + assert( x.size() == n ); + assert( t.size() == n ); + assert( r.size() == n ); + assert( u.size() == m ); + assert( v.size() == n ); + 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; + v[0] = u[0]; + + // include forward Jacobian sparsity in Hessian sparsity + // (note sparsty for f''(x) * R same as for R) + if( s[0] ) + v[0] = set_union(v[0], r[0] ); + + return true; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_reciprocal class +} // End empty namespace + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool reciprocal(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // -------------------------------------------------------------------- + // Create the atomic reciprocal object + atomic_reciprocal afun("atomic_reciprocal"); +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + // 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 atomic function and store reciprocal(x) in au[0] + vector< AD > au(m); + afun(ax, au); // u = 1 / x + + // now use AD division to invert to invert the operation + ay[0] = 1.0 / au[0]; // y = 1 / u = x + + // create f: x -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (ax, ay); // f(x) = x +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // 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); +/* %$$ +$subhead reverse$$ +$srccode%cpp% */ + // 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); +/* %$$ +$subhead for_sparse_jac$$ +$srccode%cpp% */ + // 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] +/* %$$ +$subhead rev_sparse_jac$$ +$srccode%cpp% */ + // 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] +/* %$$ +$subhead rev_sparse_hes$$ +$srccode%cpp% */ + // 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 + // + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/reverse.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/reverse.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/reverse.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/reverse.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,349 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_reverse.cpp$$ +$spell + Jacobian +$$ + +$section Atomic Reverse: Example and Test$$ + +$head Purpose$$ +This example demonstrates reverse mode derivative calculation +using an atomic operation. + +$head function$$ +For this example, the atomic function +$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by +$latex \[ +f(x) = \left( \begin{array}{c} + x_2 * x_2 \\ + x_0 * x_1 +\end{array} \right) +\] $$ +The corresponding Jacobian is +$latex \[ +f^{(1)} (x) = \left( \begin{array}{ccc} + 0 & 0 & 2 x_2 \\ +x_1 & x_0 & 0 +\end{array} \right) +\] $$ +The Hessians of the component functions are +$latex \[ +f_0^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 0 & 0 \\ + 0 & 0 & 0 \\ + 0 & 0 & 2 +\end{array} \right) +\W{,} +f_1^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 1 & 0 \\ + 1 & 0 & 0 \\ + 0 & 0 & 0 +\end{array} \right) +\] $$ + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreviate as vector +// +class atomic_reverse : public CppAD::atomic_base { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + // constructor (could use const char* for name) + atomic_reverse(const std::string& name) : + // this example does not use sparsity patterns + CppAD::atomic_base(name) + { } +private: +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { + size_t q1 = q + 1; +# ifndef NDEBUG + size_t n = tx.size() / q1; + size_t m = ty.size() / q1; +# endif + assert( n == 3 ); + assert( m == 2 ); + assert( p <= q ); + + // this example only implements up to first order forward mode + bool ok = q <= 1; + if( ! ok ) + return ok; + + // check for defining variable information + // This case must always be implemented + if( vx.size() > 0 ) + { vy[0] = vx[2]; + vy[1] = vx[0] || vx[1]; + } + // ------------------------------------------------------------------ + // Zero forward mode. + // This case must always be implemented + // f(x) = [ x_2 * x_2 ] + // [ x_0 * x_1 ] + // y^0 = f( x^0 ) + if( p <= 0 ) + { // y_0^0 = x_2^0 * x_2^0 + ty[0 * q1 + 0] = tx[2 * q1 + 0] * tx[2 * q1 + 0]; + // y_1^0 = x_0^0 * x_1^0 + ty[1 * q1 + 0] = tx[0 * q1 + 0] * tx[1 * q1 + 0]; + } + if( q <= 0 ) + return ok; + // ------------------------------------------------------------------ + // First order one forward mode. + // This case is needed if first order forward mode is used. + // f'(x) = [ 0, 0, 2 * x_2 ] + // [ x_1, x_0, 0 ] + // y^1 = f'(x^0) * x^1 + if( p <= 1 ) + { // y_0^1 = 2 * x_2^0 * x_2^1 + ty[0 * q1 + 1] = 2.0 * tx[2 * q1 + 0] * tx[2 * q1 + 1]; + + // y_1^1 = x_1^0 * x_0^1 + x_0^0 * x_1^1 + ty[1 * q1 + 1] = tx[1 * q1 + 0] * tx[0 * q1 + 1]; + ty[1 * q1 + 1] += tx[0 * q1 + 0] * tx[1 * q1 + 1]; + } + return ok; + } +/* %$$ +$head reverse$$ +$srccode%cpp% */ + // reverse mode routine called by CppAD + virtual bool reverse( + size_t q , + const vector& tx , + const vector& ty , + vector& px , + const vector& py + ) + { + size_t q1 = q + 1; + size_t n = tx.size() / q1; +# ifndef NDEBUG + size_t m = ty.size() / q1; +# endif + assert( n == 3 ); + assert( m == 2 ); + + // this example only implements up to second order reverse mode + bool ok = q1 <= 2; + if( ! ok ) + return ok; + // + // initalize summation as zero + for(size_t j = 0; j < n; j++) + for(size_t k = 0; k < q1; k++) + px[j * q1 + k] = 0.0; + // + if( q1 == 2 ) + { // -------------------------------------------------------------- + // Second order reverse first compute partials of first order + // We use the notation pf_ij^k for partial of F_i^1 w.r.t. x_j^k + // + // y_0^1 = 2 * x_2^0 * x_2^1 + // pf_02^0 = 2 * x_2^1 + // pf_02^1 = 2 * x_2^0 + // + // y_1^1 = x_1^0 * x_0^1 + x_0^0 * x_1^1 + // pf_10^0 = x_1^1 + // pf_11^0 = x_0^1 + // pf_10^1 = x_1^0 + // pf_11^1 = x_0^0 + // + // px_0^0 += py_0^1 * pf_00^0 + py_1^1 * pf_10^0 + // += py_1^1 * x_1^1 + px[0 * q1 + 0] += py[1 * q1 + 1] * tx[1 * q1 + 1]; + // + // px_0^1 += py_0^1 * pf_00^1 + py_1^1 * pf_10^1 + // += py_1^1 * x_1^0 + px[0 * q1 + 1] += py[1 * q1 + 1] * tx[1 * q1 + 0]; + // + // px_1^0 += py_0^1 * pf_01^0 + py_1^1 * pf_11^0 + // += py_1^1 * x_0^1 + px[1 * q1 + 0] += py[1 * q1 + 1] * tx[0 * q1 + 1]; + // + // px_1^1 += py_0^1 * pf_01^1 + py_1^1 * pf_11^1 + // += py_1^1 * x_0^0 + px[1 * q1 + 1] += py[1 * q1 + 1] * tx[0 * q1 + 0]; + // + // px_2^0 += py_0^1 * pf_02^0 + py_1^1 * pf_12^0 + // += py_0^1 * 2 * x_2^1 + px[2 * q1 + 0] += py[0 * q1 + 1] * 2.0 * tx[2 * q1 + 1]; + // + // px_2^1 += py_0^1 * pf_02^1 + py_1^1 * pf_12^1 + // += py_0^1 * 2 * x_2^0 + px[2 * q1 + 1] += py[0 * q1 + 1] * 2.0 * tx[2 * q1 + 0]; + } + // -------------------------------------------------------------- + // First order reverse computes partials of zero order coefficients + // We use the notation pf_ij for partial of F_i^0 w.r.t. x_j^0 + // + // y_0^0 = x_2^0 * x_2^0 + // pf_00 = 0, pf_01 = 0, pf_02 = 2 * x_2^0 + // + // y_1^0 = x_0^0 * x_1^0 + // pf_10 = x_1^0, pf_11 = x_0^0, pf_12 = 0 + // + // px_0^0 += py_0^0 * pf_00 + py_1^0 * pf_10 + // += py_1^0 * x_1^0 + px[0 * q1 + 0] += py[1 * q1 + 0] * tx[1 * q1 + 0]; + // + // px_1^0 += py_1^0 * pf_01 + py_1^0 * pf_11 + // += py_1^0 * x_0^0 + px[1 * q1 + 0] += py[1 * q1 + 0] * tx[0 * q1 + 0]; + // + // px_2^0 += py_1^0 * pf_02 + py_1^0 * pf_12 + // += py_0^0 * 2.0 * x_2^0 + px[2 * q1 + 0] += py[0 * q1 + 0] * 2.0 * tx[2 * q1 + 0]; + // -------------------------------------------------------------- + return ok; + } +}; +} // End empty namespace +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool reverse(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // Create the atomic_reverse object + atomic_reverse afun("atomic_reverse"); + // + // Create the function f(u) + // + // domain space vector + size_t n = 3; + double x_0 = 1.00; + double x_1 = 2.00; + double x_2 = 3.00; + vector< AD > au(n); + au[0] = x_0; + au[1] = x_1; + au[2] = x_2; + + // declare independent variables and start tape recording + CppAD::Independent(au); + + // range space vector + size_t m = 2; + vector< AD > ay(m); + + // call atomic function + vector< AD > ax = au; + afun(ax, ay); + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // y = f(u) + // + // check function value + double check = x_2 * x_2; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + check = x_0 * x_1; + ok &= NearEqual( Value(ay[1]) , check, eps, eps); + + // -------------------------------------------------------------------- + // zero order forward + // + vector x0(n), y0(m); + x0[0] = x_0; + x0[1] = x_1; + x0[2] = x_2; + y0 = f.Forward(0, x0); + check = x_2 * x_2; + ok &= NearEqual(y0[0] , check, eps, eps); + check = x_0 * x_1; + ok &= NearEqual(y0[1] , check, eps, eps); + // -------------------------------------------------------------------- + // first order reverse + // + // value of Jacobian of f + double check_jac[] = { + 0.0, 0.0, 2.0 * x_2, + x_1, x_0, 0.0 + }; + vector w(m), dw(n); + // + // check derivative of f_0 (x) + for(size_t i = 0; i < m; i++) + { w[i] = 1.0; + w[1-i] = 0.0; + dw = f.Reverse(1, w); + for(size_t j = 0; j < n; j++) + { // compute partial in j-th component direction + ok &= NearEqual(dw[j], check_jac[i * n + j], eps, eps); + } + } + // -------------------------------------------------------------------- + // second order reverse + // + // value of Hessian of f_0 + double check_hes_0[] = { + 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, + 0.0, 0.0, 2.0 + }; + // + // value of Hessian of f_1 + double check_hes_1[] = { + 0.0, 1.0, 0.0, + 1.0, 0.0, 0.0, + 0.0, 0.0, 0.0 + }; + vector x1(n), dw2( 2 * n ); + for(size_t j = 0; j < n; j++) + { for(size_t j1 = 0; j1 < n; j1++) + x1[j1] = 0.0; + x1[j] = 1.0; + // first order forward + f.Forward(1, x1); + w[0] = 1.0; + w[1] = 0.0; + dw2 = f.Reverse(2, w); + for(size_t i = 0; i < n; i++) + ok &= NearEqual(dw2[i * 2 + 1], check_hes_0[i * n + j], eps, eps); + w[0] = 0.0; + w[1] = 1.0; + dw2 = f.Reverse(2, w); + for(size_t i = 0; i < n; i++) + ok &= NearEqual(dw2[i * 2 + 1], check_hes_1[i * n + j], eps, eps); + } + // -------------------------------------------------------------------- + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/rev_sparse_hes.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/rev_sparse_hes.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/rev_sparse_hes.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/rev_sparse_hes.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,351 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_rev_sparse_hes.cpp$$ + +$section Atomic Reverse Hessian Sparsity: Example and Test$$ + +$head Purpose$$ +This example demonstrates calculation of the reverse Hessian sparsity pattern +for an atomic operation. + +$head function$$ +For this example, the atomic function +$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by +$latex \[ +f( x ) = \left( \begin{array}{c} + x_2 * x_2 \\ + x_0 * x_1 +\end{array} \right) +\] $$ +The Hessians of the component functions are +$latex \[ +f_0^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 0 & 0 \\ + 0 & 0 & 0 \\ + 0 & 0 & 2 +\end{array} \right) +\W{,} +f_1^{(2)} ( x ) = \left( \begin{array}{ccc} + 0 & 1 & 0 \\ + 1 & 0 & 0 \\ + 0 & 0 & 0 +\end{array} \right) +\] $$ + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreviate as vector +// +class atomic_rev_sparse_hes : public CppAD::atomic_base { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + // constructor (could use const char* for name) + atomic_rev_sparse_hes(const std::string& name) : + // this example only uses pack sparsity patterns + CppAD::atomic_base(name, pack_sparsity_enum) + { } +private: +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( n == 3 ); + assert( m == 2 ); + + // return flag + bool ok = q == 0; + if( ! ok ) + return ok; + + // check for defining variable information + // This case must always be implemented + if( vx.size() > 0 ) + { vy[0] = vx[0]; + vy[1] = vx[0] || vy[0]; + } + + // Order zero forward mode. + // This case must always be implemented + // f(x) = [ x_0 * x_0 ] + // [ x_0 * x_1 ] + assert( p <= 0 ); + if( p <= 0 ) + { ty[0] = tx[2] * tx[2]; + ty[1] = tx[0] * tx[1]; + } + return ok; + } +/* %$$ +$head for_sparse_jac$$ +$srccode%cpp% */ + // forward Jacobian sparsity routine called by CppAD + virtual bool for_sparse_jac( + size_t q , + const CppAD::vectorBool& r , + CppAD::vectorBool& s , + const vector& x ) + { // This function needed because we are using ForSparseHes + // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) +# ifndef NDEBUG + size_t n = r.size() / q; + size_t m = s.size() / q; +# endif + assert( n == x.size() ); + assert( n == 3 ); + assert( m == 2 ); + + + // f'(x) = [ 0, 0, 2 x_2 ] + // [ x_1, x_0, 0 ] + + // sparsity for first row of S(x) = f'(x) * R + size_t i = 0; + for(size_t j = 0; j < q; j++) + s[ i * q + j ] = r[ 2 * q + j ]; + + // sparsity for second row of S(x) = f'(x) * R + i = 1; + for(size_t j = 0; j < q; j++) + s[ i * q + j ] = r[ 0 * q + j ] | r[ 1 * q + j]; + + return true; + } +/* %$$ +$head rev_sparse_jac$$ +$srccode%cpp% */ + // reverse Jacobian sparsity routine called by CppAD + virtual bool rev_sparse_jac( + size_t q , + const CppAD::vectorBool& rt , + CppAD::vectorBool& st , + const vector& x ) + { // This function needed because we are using ForSparseHes + // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) +# ifndef NDEBUG + size_t m = rt.size() / q; + size_t n = st.size() / q; +# endif + assert( n == x.size() ); + assert( n == 3 ); + assert( m == 2 ); + + // [ 0, x_1 ] + // f'(x)^T = [ 0, x_0 ] + // [ 2 x_2, 0 ] + + // sparsity for first row of S(x)^T = f'(x)^T * R^T + size_t i = 0; + for(size_t j = 0; j < q; j++) + st[ i * q + j ] = rt[ 1 * q + j ]; + + // sparsity for second row of S(x)^T = f'(x)^T * R^T + i = 1; + for(size_t j = 0; j < q; j++) + st[ i * q + j ] = rt[ 1 * q + j ]; + + // sparsity for third row of S(x)^T = f'(x)^T * R^T + i = 2; + for(size_t j = 0; j < q; j++) + st[ i * q + j ] = rt[ 0 * q + j ]; + + return true; + } +/* %$$ +$head rev_sparse_hes$$ +$srccode%cpp% */ + // reverse Hessian sparsity routine called by CppAD + virtual bool rev_sparse_hes( + const vector& vx, + const vector& s , + vector& t , + size_t q , + const CppAD::vectorBool& r , + const CppAD::vectorBool& u , + CppAD::vectorBool& v , + const vector& x ) + { // This function needed because we are using RevSparseHes + // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) +# ifndef NDEBUG + size_t m = s.size(); + size_t n = t.size(); +# endif + assert( x.size() == n ); + assert( r.size() == n * q ); + assert( u.size() == m * q ); + assert( v.size() == n * q ); + assert( n == 3 ); + assert( m == 2 ); + // + // f'(x) = [ 0, 0, 2 x_2 ] + // [ x_1, x_0, 0 ] + // + // [ 0 , 0 , 0 ] [ 0 , 1 , 0 ] + // f_0''(x) = [ 0 , 0 , 0 ] f_1^{(2)} (x) = [ 1 , 0 , 0 ] + // [ 0 , 0 , 2 ] [ 0 , 0 , 0 ] + // ------------------------------------------------------------------ + // sparsity pattern for row vector T(x) = S(x) * f'(x) + t[0] = s[1]; + t[1] = s[1]; + t[2] = s[0]; + // ------------------------------------------------------------------ + // sparsity pattern for W(x) = f'(x)^T * U(x) + for(size_t j = 0; j < q; j++) + { v[ 0 * q + j ] = u[ 1 * q + j ]; + v[ 1 * q + j ] = u[ 1 * q + j ]; + v[ 2 * q + j ] = u[ 0 * q + j ]; + } + // ------------------------------------------------------------------ + // sparsity pattern for Q(x) = W(x) + S_0 (x) * f_0^{(2)} (x) * R + if( s[0] ) + { for(size_t j = 0; j < q; j++) + { // cannot use |= with vectorBool + v[ 2 * q + j ] = bool(v[ 2 * q + j ]) | bool(r[ 2 * q + j ]); + } + } + // ------------------------------------------------------------------ + // sparsity pattern for V(x) = Q(x) + S_1 (x) * f_1^{(2)} (x) * R + if( s[1] ) + { for(size_t j = 0; j < q; j++) + { // cannot use |= with vectorBool + v[ 0 * q + j ] = bool(v[ 0 * q + j ]) | bool(r[ 1 * q + j ]); + v[ 1 * q + j ] = bool(v[ 1 * q + j ]) | bool(r[ 0 * q + j ]); + } + } + return true; + } +}; // End of atomic_rev_sparse_hes class + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool use_atomic_rev_sparse_hes(bool x_1_variable) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // Create the atomic rev_sparse_hes object + atomic_rev_sparse_hes afun("atomic_rev_sparse_hes"); + // + // Create the function f(u) + // + // domain space vector + size_t n = 3; + double x_0 = 1.00; + double x_1 = 2.00; + double x_2 = 3.00; + vector< AD > au(n); + au[0] = x_0; + au[1] = x_1; + au[2] = x_2; + + // declare independent variables and start tape recording + CppAD::Independent(au); + + // range space vector + size_t m = 2; + vector< AD > ay(m); + + // call atomic function + vector< AD > ax(n); + ax[0] = au[0]; + ax[2] = au[2]; + if( x_1_variable ) + ax[1] = au[1]; + else + ax[1] = x_1; + afun(ax, ay); // y = [ x_2 * x_2 , x_0 * x_1 ]^T + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // f(u) = y + // + // check function value + double check = x_2 * x_2; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + check = x_0 * x_1; + ok &= NearEqual( Value(ay[1]) , check, eps, eps); + + // check zero order forward mode + size_t q; + vector xq(n), yq(m); + q = 0; + xq[0] = x_0; + xq[1] = x_1; + xq[2] = x_2; + yq = f.Forward(q, xq); + check = x_2 * x_2; + ok &= NearEqual(yq[0] , check, eps, eps); + check = x_0 * x_1; + ok &= NearEqual(yq[1] , check, eps, eps); + + // reverse sparse Hessian + CppAD::vectorBool r(n * n), s(m), h(n * n); + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n; j++) + r[i * n + j] = i == j; + } + for(size_t i = 0; i < m; i++) + s[i] = true; + f.ForSparseJac(n, r); + h = f.RevSparseHes(n, s); + + // check result + CppAD::vectorBool check_h(n * n); + for(size_t i = 0; i < n * n; i++) + check_h[i] = false; + check_h[ 2 * n + 2 ] = true; + if( x_1_variable ) + { check_h[0 * n + 1] = true; + check_h[1 * n + 0] = true; + } + for(size_t i = 0; i < n * n; i++) + ok &= h[ i ] == check_h[ i ]; + // + return ok; +} +} // End empty namespace +/* %$$ +$head Test with x_1 Both a Variable and a Parameter$$ +$srccode%cpp% */ +bool rev_sparse_hes(void) +{ bool ok = true; + // test with x_1 a variable + ok &= use_atomic_rev_sparse_hes(true); + // test with x_1 a parameter + ok &= use_atomic_rev_sparse_hes(false); + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/rev_sparse_jac.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/rev_sparse_jac.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/rev_sparse_jac.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/rev_sparse_jac.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,247 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_rev_sparse_jac.cpp$$ +$spell + Jacobian + Jacobians +$$ + +$section Atomic Reverse Jacobian Sparsity: Example and Test$$ + +$head Purpose$$ +This example demonstrates calculation of the +reverse Jacobians sparsity pattern for an atomic operation. + +$head function$$ +For this example, the atomic function +$latex f : \B{R}^3 \rightarrow \B{R}^2$$ is defined by +$latex \[ +f( x ) = \left( \begin{array}{c} + x_2 * x_2 \\ + x_0 * x_1 +\end{array} \right) +\] $$ +The corresponding Jacobian is +$latex \[ +f^{(1)} (x) = \left( \begin{array}{ccc} + 0 & 0 & 2 x_2 \\ +x_1 & x_0 & 0 +\end{array} \right) +\] $$ + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // abbreviate as vector +// +class atomic_rev_sparse_jac : public CppAD::atomic_base { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + // constructor (could use const char* for name) + atomic_rev_sparse_jac(const std::string& name) : + // this example only uses pack sparsity patterns + CppAD::atomic_base(name, pack_sparsity_enum) + { } +private: +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + virtual bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vy , + const vector& tx , + vector& ty + ) + { +# ifndef NDEBUG + size_t n = tx.size() / (q + 1); + size_t m = ty.size() / (q + 1); +# endif + assert( n == 3 ); + assert( m == 2 ); + + // return flag + bool ok = q == 0; + if( ! ok ) + return ok; + + // check for defining variable information + // This case must always be implemented + if( vx.size() > 0 ) + { vy[0] = vx[0]; + vy[1] = vx[0] || vy[0]; + } + + // Order zero forward mode. + // This case must always be implemented + // f(x) = [ x_0 * x_0 ] + // [ x_0 * x_1 ] + assert( p <= 0 ); + if( p <= 0 ) + { ty[0] = tx[2] * tx[2]; + ty[1] = tx[0] * tx[1]; + } + return ok; + } +/* %$$ +$head rev_sparse_jac$$ +$srccode%cpp% */ + // reverse Jacobian sparsity routine called by CppAD + virtual bool rev_sparse_jac( + size_t q , + const CppAD::vectorBool& rt , + CppAD::vectorBool& st , + const vector& x ) + { // This function needed because we are using RevSparseHes + // with afun.option( CppAD::atomic_base::pack_sparsity_enum ) +# ifndef NDEBUG + size_t m = rt.size() / q; + size_t n = st.size() / q; +# endif + assert( n == x.size() ); + assert( n == 3 ); + assert( m == 2 ); + + // [ 0, x_1 ] + // f'(x)^T = [ 0, x_0 ] + // [ 2 x_2, 0 ] + + // sparsity for first row of S(x)^T = f'(x)^T * R^T + size_t i = 0; + for(size_t j = 0; j < q; j++) + st[ i * q + j ] = rt[ 1 * q + j ]; + + // sparsity for second row of S(x)^T = f'(x)^T * R^T + i = 1; + for(size_t j = 0; j < q; j++) + st[ i * q + j ] = rt[ 1 * q + j ]; + + // sparsity for third row of S(x)^T = f'(x)^T * R^T + i = 2; + for(size_t j = 0; j < q; j++) + st[ i * q + j ] = rt[ 0 * q + j ]; + + return true; + } +}; // End of atomic_rev_sparse_jac class + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool use_atomic_rev_sparse_jac(bool x_1_variable) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + // + // Create the atomic rev_sparse_jac object + atomic_rev_sparse_jac afun("atomic_rev_sparse_jac"); + // + // Create the function f(u) + // + // domain space vector + size_t n = 3; + double x_0 = 1.00; + double x_1 = 2.00; + double x_2 = 3.00; + vector< AD > au(n); + au[0] = x_0; + au[1] = x_1; + au[2] = x_2; + + // declare independent variables and start tape recording + CppAD::Independent(au); + + // range space vector + size_t m = 2; + vector< AD > ay(m); + + // call atomic function + vector< AD > ax(n); + ax[0] = au[0]; + ax[2] = au[2]; + if( x_1_variable ) + ax[1] = au[1]; + else + ax[1] = x_1; + afun(ax, ay); // y = [ x_2 * x_2 , x_0 * x_1 ]^T + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // f(u) = y + // + // check function value + double check = x_2 * x_2; + ok &= NearEqual( Value(ay[0]) , check, eps, eps); + check = x_0 * x_1; + ok &= NearEqual( Value(ay[1]) , check, eps, eps); + + // check zero order forward mode + size_t q; + vector xq(n), yq(m); + q = 0; + xq[0] = x_0; + xq[1] = x_1; + xq[2] = x_2; + yq = f.Forward(q, xq); + check = x_2 * x_2; + ok &= NearEqual(yq[0] , check, eps, eps); + check = x_0 * x_1; + ok &= NearEqual(yq[1] , check, eps, eps); + + // forward sparse Jacobian + CppAD::vectorBool r(m * m), s(m * n); + // r = identity matrix + for(size_t i = 0; i < m; i++) + for(size_t j = 0; j < m; j++) + r[ i * m + j] = i == j; + s = f.RevSparseJac(m, r); + + // check result + CppAD::vectorBool check_s(m * n); + check_s[ 0 * n + 0 ] = false; + check_s[ 0 * n + 1 ] = false; + check_s[ 0 * n + 2 ] = true; + check_s[ 1 * n + 0 ] = true; + check_s[ 1 * n + 1 ] = x_1_variable; + check_s[ 1 * n + 2 ] = false; + // + for(size_t i = 0; i < m * n; i++) + ok &= s[ i ] == check_s[ i ]; + // + return ok; +} +} // End empty namespace +/* %$$ +$head Test with x_1 Both a Variable and a Parameter$$ +$srccode%cpp% */ +bool rev_sparse_jac(void) +{ bool ok = true; + // test with x_1 a variable + ok &= use_atomic_rev_sparse_jac(true); + // test with x_1 a parameter + ok &= use_atomic_rev_sparse_jac(false); + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/set_sparsity.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/set_sparsity.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/set_sparsity.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/set_sparsity.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,342 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin atomic_two_set_sparsity.cpp$$ +$spell + enum +$$ + +$section Atomic Sparsity with Set 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 ) = \left( \begin{array}{c} + x_2 \\ + x_0 * x_1 +\end{array} \right) +\] $$ + +$head set_sparsity_enum$$ +This example only uses set sparsity patterns. + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // isolate items below to this file +using CppAD::vector; // vector +typedef vector< std::set > set_vector; // atomic_sparsity +// +// a utility to compute the union of two sets. +using CppAD::set_union; +// +class atomic_set_sparsity : public CppAD::atomic_base { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +public: + // constructor + atomic_set_sparsity(const std::string& name) : + // this exampel only uses set sparsity patterns + CppAD::atomic_base(name, set_sparsity_enum ) + { } +private: +/* %$$ +$head forward$$ +$srccode%cpp% */ + // 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); +# ifndef NDEBUG + size_t m = ty.size() / (q + 1); +# endif + 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$$ +$srccode%cpp% */ + // for_sparse_jac + virtual bool for_sparse_jac( + size_t p , + const set_vector& r , + set_vector& s , + const vector& x ) + { // This function needed if using f.ForSparseJac +# ifndef NDEBUG + size_t n = r.size(); + size_t m = s.size(); +# endif + assert( n == x.size() ); + assert( n == 3 ); + assert( m == 2 ); + + // sparsity for S(x) = f'(x) * R = [ 0, 0, 1 ] * R + s[0] = r[2]; + // s[1] = union(r[0], r[1]) + s[1] = set_union(r[0], r[1]); + // + return true; + } +/* %$$ +$head rev_sparse_jac$$ +$srccode%cpp% */ + virtual bool rev_sparse_jac( + size_t p , + const set_vector& rt , + set_vector& st , + const vector& x ) + { // This function needed if using RevSparseJac or optimize +# ifndef NDEBUG + size_t n = st.size(); + size_t m = rt.size(); +# endif + assert( n == x.size() ); + assert( n == 3 ); + assert( m == 2 ); + + // [ 0, x1 ] + // sparsity for S(x)^T = f'(x)^T * R^T = [ 0, x0 ] * R^T + // [ 1, 0 ] + st[0] = rt[1]; + st[1] = rt[1]; + st[2] = rt[0]; + return true; + } +/* %$$ +$head for_sparse_hes$$ +$srccode%cpp% */ + virtual bool for_sparse_hes( + const vector& vx, + const vector& r , + const vector& s , + set_vector& h , + const vector& x ) + { + size_t n = r.size(); +# ifndef NDEBUG + size_t m = s.size(); +# endif + assert( x.size() == n ); + assert( h.size() == n ); + assert( n == 3 ); + assert( m == 2 ); + + // initialize h as empty + for(size_t i = 0; i < n; i++) + h[i].clear(); + + // only f_1 has a non-zero hessian + if( ! s[1] ) + return true; + + // only the cross term between x[0] and x[1] is non-zero + if( ! ( r[0] & r[1] ) ) + return true; + + // set the possibly non-zero terms in the hessian + h[0].insert(1); + h[1].insert(0); + + return true; + } +/* %$$ +$head rev_sparse_hes$$ +$srccode%cpp% */ + virtual bool rev_sparse_hes( + const vector& vx, + const vector& s , + vector& t , + size_t p , + const set_vector& r , + const set_vector& u , + set_vector& v , + const vector& x ) + { // This function needed if using RevSparseHes +# ifndef NDEBUG + size_t m = s.size(); + size_t n = t.size(); +# endif + assert( x.size() == n ); + assert( r.size() == n ); + assert( u.size() == m ); + assert( v.size() == n ); + 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 W(x) = f'(x)^T * U(x) = [ 0, x0 ] * U(x) + // [ 1, 0 ] + v[0] = u[1]; + v[1] = u[1]; + v[2] = u[0]; + // + // [ 0, 1, 0 ] + // sparsity for V(x) = W(x) + S_1 (x) * [ 1, 0, 0 ] * R + // [ 0, 0, 0 ] + if( s[1] ) + { // v[0] = union( v[0], r[1] ) + v[0] = set_union(v[0], r[1]); + // v[1] = union( v[1], r[0] ) + v[1] = set_union(v[1], r[0]); + } + return true; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_set_sparsity class +} // End empty namespace + +/* %$$ +$head Test Atomic Function$$ +$srccode%cpp% */ +bool set_sparsity(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // Create the atomic get_started object + atomic_set_sparsity afun("atomic_set_sparsity"); +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + 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 atomic 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 for_sparse_jac$$ +$srccode%cpp% */ + // correct Jacobian result + set_vector check_s(m); + check_s[0].insert(2); + check_s[1].insert(0); + check_s[1].insert(1); + // compute and test forward mode + { set_vector r(n), s(m); + for(size_t i = 0; i < n; i++) + r[i].insert(i); + s = f.ForSparseJac(n, r); + for(size_t i = 0; i < m; i++) + ok &= s[i] == check_s[i]; + } +/* %$$ +$subhead rev_sparse_jac$$ +$srccode%cpp% */ + // compute and test reverse mode + { set_vector r(m), s(m); + for(size_t i = 0; i < m; i++) + r[i].insert(i); + s = f.RevSparseJac(m, r); + for(size_t i = 0; i < m; i++) + ok &= s[i] == check_s[i]; + } +/* %$$ +$subhead for_sparse_hes$$ +$srccode%cpp% */ + // correct Hessian result + set_vector check_h(n); + check_h[0].insert(1); + check_h[1].insert(0); + // compute and test forward mode + { set_vector r(1), s(1), h(n); + for(size_t i = 0; i < m; i++) + s[0].insert(i); + for(size_t j = 0; j < n; j++) + r[0].insert(j); + h = f.ForSparseHes(r, s); + for(size_t i = 0; i < n; i++) + ok &= h[i] == check_h[i]; + } +/* %$$ +$subhead rev_sparse_hes$$ +Note the previous call to $code ForSparseJac$$ above +stored its results in $icode f$$. +$srccode%cpp% */ + // compute and test reverse mode + { set_vector s(1), h(n); + for(size_t i = 0; i < m; i++) + s[0].insert(i); + h = f.RevSparseHes(n, s); + for(size_t i = 0; i < n; i++) + ok &= h[i] == check_h[i]; + } +/* %$$ +$subhead Test Result$$ +$srccode%cpp% */ + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/test_more/deprecated/atomic_two/tangent.cpp cppad-2019.02.00.0/test_more/deprecated/atomic_two/tangent.cpp --- cppad-2018.00.00.0/test_more/deprecated/atomic_two/tangent.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/atomic_two/tangent.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,533 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin atomic_two_tangent.cpp$$ +$spell + Tanh + bool +$$ + +$section Tan and Tanh as User Atomic Operations: Example and Test$$ + +$head Theory$$ +The code below uses the $cref tan_forward$$ and $cref tan_reverse$$ +to implement the tangent and hyperbolic tangent +functions as atomic function operations. + +$head sparsity$$ +This atomic operation can use both set and bool sparsity patterns. + +$nospell + +$head Start Class Definition$$ +$srccode%cpp% */ +# include +namespace { // Begin empty namespace +using CppAD::vector; +// +// a utility to compute the union of two sets. +using CppAD::set_union; +// +class atomic_tangent : public CppAD::atomic_base { +/* %$$ +$head Constructor $$ +$srccode%cpp% */ +private: + const bool hyperbolic_; // is this hyperbolic tangent +public: + // constructor + atomic_tangent(const char* name, bool hyperbolic) + : CppAD::atomic_base(name), + hyperbolic_(hyperbolic) + { } +private: +/* %$$ +$head forward$$ +$srccode%cpp% */ + // forward mode routine called by CppAD + bool forward( + size_t p , + size_t q , + const vector& vx , + vector& vzy , + const vector& tx , + vector& tzy + ) + { size_t q1 = q + 1; +# ifndef NDEBUG + size_t n = tx.size() / q1; + size_t m = tzy.size() / q1; +# endif + assert( n == 1 ); + assert( m == 2 ); + assert( p <= q ); + size_t j, k; + + // check if this is during the call to old_tan(id, ax, ay) + if( vx.size() > 0 ) + { // set variable flag for both y an z + vzy[0] = vx[0]; + vzy[1] = vx[0]; + } + + if( p == 0 ) + { // z^{(0)} = tan( x^{(0)} ) or tanh( x^{(0)} ) + if( hyperbolic_ ) + tzy[0] = float( tanh( tx[0] ) ); + else + tzy[0] = float( tan( tx[0] ) ); + + // y^{(0)} = z^{(0)} * z^{(0)} + tzy[q1 + 0] = tzy[0] * tzy[0]; + + p++; + } + for(j = p; j <= q; j++) + { float j_inv = 1.f / float(j); + if( hyperbolic_ ) + 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[q1 + j-k] * float(k) * j_inv; + + // y^{(j)} = sum_{k=0}^j z^{(k)} z^{(j-k)} + tzy[q1 + j] = 0.; + for(k = 0; k <= j; k++) + tzy[q1 + j] += tzy[k] * tzy[j-k]; + } + + // All orders are implemented and there are no possible errors + return true; + } +/* %$$ +$head reverse$$ +$srccode%cpp% */ + // reverse mode routine called by CppAD + virtual bool reverse( + size_t q , + const vector& tx , + const vector& tzy , + vector& px , + const vector& pzy + ) + { size_t q1 = q + 1; +# ifndef NDEBUG + size_t n = tx.size() / q1; + size_t m = tzy.size() / q1; +# endif + assert( px.size() == n * q1 ); + assert( pzy.size() == m * q1 ); + assert( n == 1 ); + assert( m == 2 ); + + 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 < q1; k++) + px[k] = 0.; + + // eliminate positive orders + for(j = q; j > 0; j--) + { float j_inv = 1.f / float(j); + if( hyperbolic_ ) + 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[q1 + j-k] * float(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] * float(k) * j_inv; + + // 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; + } + + // eliminate order zero + if( hyperbolic_ ) + px[0] += qzy[0] * (1.f - tzy[q1 + 0]); + else + px[0] += qzy[0] * (1.f + tzy[q1 + 0]); + + return true; + } +/* %$$ +$head for_sparse_jac$$ +$srccode%cpp% */ + // forward Jacobian sparsity routine called by CppAD + virtual bool for_sparse_jac( + size_t p , + const vector& r , + vector& s , + const vector& x ) + { +# ifndef NDEBUG + size_t n = r.size() / p; + size_t m = s.size() / p; +# endif + assert( n == x.size() ); + assert( n == 1 ); + assert( m == 2 ); + + // sparsity for S(x) = f'(x) * R + for(size_t j = 0; j < p; j++) + { s[0 * p + j] = r[j]; + s[1 * p + j] = r[j]; + } + + return true; + } + // forward Jacobian sparsity routine called by CppAD + virtual bool for_sparse_jac( + size_t p , + const vector< std::set >& r , + vector< std::set >& s , + const vector& x ) + { +# ifndef NDEBUG + size_t n = r.size(); + size_t m = s.size(); +# endif + assert( n == x.size() ); + assert( n == 1 ); + assert( m == 2 ); + + // sparsity for S(x) = f'(x) * R + s[0] = r[0]; + s[1] = r[0]; + + return true; + } +/* %$$ +$head rev_sparse_jac$$ +$srccode%cpp% */ + // reverse Jacobian sparsity routine called by CppAD + virtual bool rev_sparse_jac( + size_t p , + const vector& rt , + vector& st , + const vector& x ) + { +# ifndef NDEBUG + size_t n = st.size() / p; + size_t m = rt.size() / p; +# endif + assert( n == 1 ); + assert( m == 2 ); + assert( n == x.size() ); + + // sparsity for S(x)^T = f'(x)^T * R^T + for(size_t j = 0; j < p; j++) + st[j] = rt[0 * p + j] | rt[1 * p + j]; + + return true; + } + // reverse Jacobian sparsity routine called by CppAD + virtual bool rev_sparse_jac( + size_t p , + const vector< std::set >& rt , + vector< std::set >& st , + const vector& x ) + { +# ifndef NDEBUG + size_t n = st.size(); + size_t m = rt.size(); +# endif + assert( n == 1 ); + assert( m == 2 ); + assert( n == x.size() ); + + // sparsity for S(x)^T = f'(x)^T * R^T + st[0] = set_union(rt[0], rt[1]); + return true; + } +/* %$$ +$head rev_sparse_hes$$ +$srccode%cpp% */ + // reverse Hessian 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 , + const vector& x ) + { +# ifndef NDEBUG + size_t m = s.size(); + size_t n = t.size(); +# endif + assert( x.size() == n ); + assert( r.size() == n * p ); + assert( u.size() == m * p ); + assert( v.size() == n * p ); + assert( n == 1 ); + assert( m == 2 ); + + // 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) + t[0] = s[0] | s[1]; + + // 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; + size_t j; + for(j = 0; j < p; j++) + v[j] = u[ 0 * p + j ] | u[ 1 * p + j ]; + + // include forward Jacobian sparsity in Hessian sparsity + // (note sparsty for f''(x) * R same as for R) + if( s[0] | s[1] ) + { for(j = 0; j < p; j++) + { // Visual Studio 2013 generates warning without bool below + v[j] |= bool( r[j] ); + } + } + + return true; + } + // reverse Hessian 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 , + const vector& x ) + { +# ifndef NDEBUG + size_t m = s.size(); + size_t n = t.size(); +# endif + assert( x.size() == n ); + assert( r.size() == n ); + assert( u.size() == m ); + assert( v.size() == n ); + assert( n == 1 ); + assert( m == 2 ); + + // 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) + t[0] = s[0] | s[1]; + + // 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] = set_union(u[0], u[1]); + + // include forward Jacobian sparsity in Hessian sparsity + // (note sparsty for f''(x) * R same as for R) + if( s[0] | s[1] ) + v[0] = set_union(v[0], r[0]); + + return true; + } +/* %$$ +$head End Class Definition$$ +$srccode%cpp% */ +}; // End of atomic_tangent class +} // End empty namespace + +/* %$$ +$head Use Atomic Function$$ +$srccode%cpp% */ +bool tangent(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + float eps = 10.f * CppAD::numeric_limits::epsilon(); +/* %$$ +$subhead Constructor$$ +$srccode%cpp% */ + // -------------------------------------------------------------------- + // Creater a tan and tanh object + atomic_tangent my_tan("my_tan", false), my_tanh("my_tanh", true); +/* %$$ +$subhead Recording$$ +$srccode%cpp% */ + // 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 computations + // (my_tan and my_tanh computes tan or tanh and its square) + CppAD::vector< AD > az(2); + + // call atomic tan function and store tan(x) in f[0] (ignore tan(x)^2) + my_tan(ax, az); + af[0] = az[0]; + + // call atomic tanh function and store tanh(x) in f[1] (ignore tanh(x)^2) + my_tanh(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.; + my_tanh(one, az); + af[2] = az[0]; + + // create f: x -> f and stop tape recording + CppAD::ADFun F; + F.Dependent(ax, af); +/* %$$ +$subhead forward$$ +$srccode%cpp% */ + // 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); +/* %$$ +$subhead reverse$$ +$srccode%cpp% */ + // 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); +/* %$$ +$subhead for_sparse_jac$$ +$srccode%cpp% */ + // 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] +/* %$$ +$subhead rev_sparse_jac$$ +$srccode%cpp% */ + // 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] +/* %$$ +$subhead rev_sparse_hes$$ +$srccode%cpp% */ + // 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 +/* %$$ +$subhead Large x Values$$ +$srccode%cpp% */ + // 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); + + return ok; +} +/* %$$ +$$ $comment end nospell$$ +$end +*/ diff -Nru cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/chkpoint_one.cpp cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/chkpoint_one.cpp --- cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/chkpoint_one.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/chkpoint_one.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,53 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// CPPAD_HAS_* defines +# include + +// system include files used for I/O +# include + +// C style asserts +# include + +// for thread_alloc +# include + +// test runner +# include + +// external complied tests +extern bool extended_ode(void); +extern bool get_started(void); +extern bool mul_level(void); +extern bool ode(void); + +// main program that runs all the tests +int main(void) +{ std::string group = "example/chkpoint_one"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + // external compiled tests + Run( extended_ode, "extended_ode" ); + Run( get_started, "get_started" ); + Run( mul_level, "mul_level" ); + Run( ode, "ode" ); + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); +} diff -Nru cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/CMakeLists.txt cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/CMakeLists.txt --- cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,41 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# +SET(source_list + chkpoint_one.cpp + get_started.cpp + extended_ode.cpp + mul_level.cpp + ode.cpp +) +set_compile_flags(test_more_deprecated_chkpoint_one + "${cppad_debug_which}" "${source_list}" +) +# +ADD_EXECUTABLE(test_more_deprecated_chkpoint_one + EXCLUDE_FROM_ALL ${source_list} +) +# +# Add the check_test_more_deprecated_chkpoint_one target +ADD_CUSTOM_TARGET(check_test_more_deprecated_chkpoint_one + test_more_deprecated_chkpoint_one + DEPENDS test_more_deprecated_chkpoint_one +) +MESSAGE(STATUS "make check_test_more_deprecated_chkpoint_one: available") +# +# add to check check_test_more_deprecated_depends in parent environment +add_to_list(check_test_more_deprecated_depends + check_test_more_deprecated_chkpoint_one +) +SET(check_test_more_deprecated_depends + "${check_test_more_deprecated_depends}" PARENT_SCOPE +) diff -Nru cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/extended_ode.cpp cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/extended_ode.cpp --- cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/extended_ode.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/extended_ode.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,420 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin chkpoint_one_extended_ode.cpp$$ +$spell + Checkpointing + Runge-Kutta + mul +$$ + +$section Checkpointing an Extended ODE Solver: Example and Test$$ +$index mul_level, checkpoint$$ + +$head See Also$$ +$cref chkpoint_one_ode.cpp$$, +$cref chkpoint_one_mul_level.cpp$$. + + +$head Discussion$$ +Suppose that we wish to extend an ODE to include derivatives with respect +to some parameter in the ODE. In addition, suppose we wish to +differentiate a function that depends on these derivatives. +Applying checkpointing to at the second level of AD would not work; +see $cref chkpoint_one_mul_level.cpp$$ +In this example we show how one can do this by +checkpointing an extended ODE solver. + +$head Problem$$ +We consider the initial value problem with parameter $latex x$$ defined by, +$latex z(0, x) = z_0 (x)$$, +$latex \[ + \partial_t z(t, x ) = h [ x , z(t, x) ] +\]$$ +Note that if $latex t$$ needs to be in the equation, one can define +the first component of $latex z(t, x)$$ to be equal to $latex t$$. + +$head ODE Solver$$ +For this example, we consider the Fourth order Runge-Kutta ODE solver. +Given an approximation solution at time $latex t_k$$ denoted by +$latex \tilde{z}_k (x)$$, and $latex \Delta t = t_{k+1} - t_k$$, +it defines the approximation solution $latex \tilde{z}_{k+1} (x)$$ +at time $latex t_{k+1}$$ by +$latex \[ +\begin{array}{rcl} +h_1 & = & h [ x , \tilde{z}_k (x) ] +\\ +h_2 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_1 / 2 ] +\\ +h_3 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_2 / 2 ] +\\ +h_4 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_3 ] +\\ +\tilde{z}_{k+1} (x) & = & + \tilde{z}_k (x) + \Delta t \; ( h_1 + 2 h_2 + 2 h_3 + h_4 ) / 6 +\end{array} +\] $$ +If $latex \tilde{z}_k (x) = z_k (x)$$, then +$latex \tilde{z}_{k+1} (x) = z_{k+1} (x) + O( \Delta t^5 )$$, then +Other ODE solvers can use a similar method to the one used below. + +$head ODE$$ +For this example the ODE is defined by +$latex z(0, x) = 0$$ and +$latex \[ + h[ x, z(t, x) ] = + \left( \begin{array}{c} + x_0 \\ + x_1 z_0 (t, x) \\ + \vdots \\ + x_{n-1} z_{n-2} (t, x) + \end{array} \right) + = + \left( \begin{array}{c} + \partial_t z_0 (t , x) \\ + \partial_t z_1 (t , x) \\ + \vdots \\ + \partial_t z_{n-1} (t , x) + \end{array} \right) +\] $$ + +$head Solution$$ +The solution of the ODE for this example, +which is used to check the results, +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 +$latex \[ + z(t, x) = + \left( \begin{array}{c} + x_0 t \\ + x_1 x_0 t^2 / 2 \\ + \vdots \\ + x_{n-1} x_{n-2} \ldots x_0 t^n / n ! + \end{array} \right) +\] $$ + + +$comment %example/chkpoint_one/extended_ode.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ + +# include + +namespace { + using CppAD::AD; + typedef AD a1double; + typedef AD a2double; + // + typedef CPPAD_TESTVECTOR( double ) a0vector; + typedef CPPAD_TESTVECTOR( a1double ) a1vector; + typedef CPPAD_TESTVECTOR( a2double ) a2vector; + // + // set once by main and kept that way + double delta_t_ = std::numeric_limits::quiet_NaN(); + size_t n_ = 0; + // + // The function h( x , y) + template + FloatVector h(const FloatVector& x, const FloatVector& y) + { assert( size_t( x.size() ) == n_ ); + assert( size_t( y.size() ) == n_ ); + FloatVector result(n_); + result[0] = x[0]; + for(size_t i = 1; i < n_; i++) + result[i] = x[i] * y[i-1]; + return result; + } + + // The 4-th Order Runge-Kutta Step + template + FloatVector Runge4(const FloatVector& x, const FloatVector& z0 + ) + { assert( size_t( x.size() ) == n_ ); + assert( size_t( z0.size() ) == n_ ); + // + typedef typename FloatVector::value_type Float; + // + Float dt = Float(delta_t_); + size_t m = z0.size(); + // + FloatVector h1(m), h2(m), h3(m), h4(m), result(m); + h1 = h( x, z0 ); + // + for(size_t i = 0; i < m; i++) + h2[i] = z0[i] + dt * h1[i] / 2.0; + h2 = h( x, h2 ); + // + for(size_t i = 0; i < m; i++) + h3[i] = z0[i] + dt * h2[i] / 2.0; + h3 = h( x, h3 ); + // + for(size_t i = 0; i < m; i++) + h4[i] = z0[i] + dt * h3[i]; + h4 = h( x, h4 ); + // + for(size_t i = 0; i < m; i++) + { Float dz = dt * ( h1[i] + 2.0*h2[i] + 2.0*h3[i] + h4[i] ) / 6.0; + result[i] = z0[i] + dz; + } + return result; + } + + // Derivative of 4-th Order Runge-Kutta Step w.r.t x + a1vector Runge4_x(const a1vector& x, const a1vector& z0) + { assert( size_t( x.size() ) == n_ ); + assert( size_t( z0.size() ) == n_ ); + // + a2vector ax(n_); + for(size_t j = 0; j < n_; j++) + ax[j] = x[j]; + // + a2vector az0(n_); + for(size_t i = 0; i < n_; i++) + az0[i] = z0[i]; + // + CppAD::Independent(ax); + a2vector az(n_); + az = Runge4(ax, az0); + CppAD::ADFun f(ax, az); + // + a1vector result = f.Jacobian(x); + // + return result; + } + + // Derivative of 4-th Order Runge-Kutta Step w.r.t z0 + a1vector Runge4_z0(const a1vector& x, const a1vector& z0) + { assert( size_t( x.size() ) == n_ ); + assert( size_t( z0.size() ) == n_ ); + // + a2vector ax(n_); + for(size_t j = 0; j < n_; j++) + ax[j] = x[j]; + // + a2vector az0(n_); + for(size_t i = 0; i < n_; i++) + az0[i] = z0[i]; + // + CppAD::Independent(az0); + a2vector az(n_); + az = Runge4(ax, az0); + CppAD::ADFun f(az0, az); + // + a1vector result = f.Jacobian(z0); + // + return result; + } + + // pack an extended ode vector + template + void pack( + FloatVector& extended_ode , + const FloatVector& x , + const FloatVector& z , + const FloatVector& z_x ) + { assert( size_t( extended_ode.size() ) == n_ + n_ + n_ * n_ ); + assert( size_t( x.size() ) == n_ ); + assert( size_t( z.size() ) == n_ ); + assert( size_t( z_x.size() ) == n_ * n_ ); + // + size_t offset = 0; + for(size_t i = 0; i < n_; i++) + extended_ode[offset + i] = x[i]; + offset += n_; + for(size_t i = 0; i < n_; i++) + extended_ode[offset + i] = z[i]; + offset += n_; + for(size_t i = 0; i < n_; i++) + { for(size_t j = 0; j < n_; j++) + { // partial of z_i (t , x ) w.r.t x_j + extended_ode[offset + i * n_ + j] = z_x[i * n_ + j]; + } + } + } + + // unpack an extended ode vector + template + void unpack( + const FloatVector& extended_ode , + FloatVector& x , + FloatVector& z , + FloatVector& z_x ) + { assert( size_t( extended_ode.size() ) == n_ + n_ + n_ * n_ ); + assert( size_t( x.size() ) == n_ ); + assert( size_t( z.size() ) == n_ ); + assert( size_t( z_x.size() ) == n_ * n_ ); + // + size_t offset = 0; + for(size_t i = 0; i < n_; i++) + x[i] = extended_ode[offset + i]; + offset += n_; + for(size_t i = 0; i < n_; i++) + z[i] = extended_ode[offset + i]; + offset += n_; + for(size_t i = 0; i < n_; i++) + { for(size_t j = 0; j < n_; j++) + { // partial of z_i (t , x ) w.r.t x_j + z_x[i * n_ + j] = extended_ode[offset + i * n_ + j]; + } + } + } + + // Algorithm that advances the partial of z(t, x) w.r.t x + void ext_ode_algo(const a1vector& ext_ode_in, a1vector& ext_ode_out) + { assert( size_t( ext_ode_in.size() ) == n_ + n_ + n_ * n_ ); + assert( size_t( ext_ode_out.size() ) == n_ + n_ + n_ * n_ ); + // + // initial extended ode information + a1vector x(n_), z0(n_), z0_x(n_ * n_); + unpack(ext_ode_in, x, z0, z0_x); + // + // advance z(t, x) + a1vector z1 = Runge4(x, z0); + // + // partial of z1 w.r.t. x + a1vector z1_x = Runge4_x(x, z0); + // + // partial of z1 w.r.t. z0 + a1vector z1_z0 = Runge4_z0(x, z0); + // + // total derivative of z1 w.r.t x + for(size_t i = 0; i < n_; i++) + { for(size_t j = 0; j < n_; j++) + { a1double sum = 0.0; + for(size_t k = 0; k < n_; k++) + sum += z1_z0 [ i * n_ + k ] * z0_x [ k * n_ + j ]; + z1_x[ i * n_ + j] += sum; + } + } + // + // final extended ode information + pack(ext_ode_out, x, z1, z1_x); + // + return; + } +} +// +bool extended_ode(void) +{ bool ok = true; + using CppAD::NearEqual; + double eps = std::numeric_limits::epsilon(); + // + // number of terms in the differential equation + n_ = 6; + // + // step size for the differentiail equation + size_t n_step = 10; + double T = 1.0; + delta_t_ = T / double(n_step); + // + // set parameter value and initial value of the extended ode + a1vector ax(n_), az0(n_), az0_x(n_ * n_); + for(size_t i = 0; i < n_; i++) + { ax[i] = a1double(i + 1); + az0[i] = a1double(0); + for(size_t j = 0; j < n_; j++) + az0_x[ i * n_ + j ] = 0.0; + } + // + // pack into extended ode information input vector + size_t n_ext = n_ + n_ + n_ * n_; + a1vector aext_ode_in(n_ext); + pack(aext_ode_in, ax, az0, az0_x); + // + // create checkpoint version of the algorithm + a1vector aext_ode_out(n_ext); + CppAD::checkpoint ext_ode_check( + "ext_ode", ext_ode_algo, aext_ode_in, aext_ode_out + ); + // + // set the independent variables for recording + CppAD::Independent( ax ); + // + // repack to get dependence on ax + pack(aext_ode_in, ax, az0, az0_x); + // + // Now run the checkpoint algorithm n_step times + for(size_t k = 0; k < n_step; k++) + { ext_ode_check(aext_ode_in, aext_ode_out); + aext_ode_in = aext_ode_out; + } + // + // Unpack the results (must use ax1 so do not overwrite ax) + a1vector ax1(n_), az1(n_), az1_x(n_ * n_); + unpack(aext_ode_out, ax1, az1, az1_x); + // + // We could record a complicated funciton of x and z_x(T, x) in f, + // but make this example simpler we record x -> z_x(T, x). + CppAD::ADFun f(ax, az1_x); + // + // check function values + a0vector x(n_), z1(n_), z1_x(n_ * n_); + for(size_t j = 0; j < n_; j++) + x[j] = double(j + 1); + z1_x = f.Forward(0, x); + // + // use z(t, x) for checking solution + z1[0] = x[0] * T; + for(size_t i = 1; i < n_; i++) + z1[i] = x[i] * T * z1[i-1] / double(i+1); + // + // expected accuracy for each component of of z(t, x) + a0vector acc(n_); + for(size_t i = 0; i < n_; i++) + { if( i < 4 ) + { // Runge-Kutta methos is exact for this case + acc[i] = 10. * eps; + } + else + { acc[i] = 1.0; + for(size_t k = 0; k < 5; k++) + acc[i] *= x[k] * delta_t_; + } + } + // check z1(T, x) + for(size_t i = 0; i < n_; i++) + { for(size_t j = 0; j < n_; j++) + { // check partial of z1_i w.r.t x_j + double check = 0.0; + if( j <= i ) + check = z1[i] / x[j]; + ok &= NearEqual(z1_x[ i * n_ + j ] , check, acc[i], acc[i]); + } + } + // + // Now use f to compute a derivative. For this 'simple' example it is + // the derivative with respect to x of the + // parital with respect to x[n-1] of z_{n-1} (t , x) + a0vector w(n_ * n_), dw(n_); + for(size_t i = 0; i < n_; i++) + { for(size_t j = 0; j < n_; j++) + { w[ i * n_ + j ] = 0.0; + if( i == n_ - 1 && j == n_ - 1 ) + w[ i * n_ + j ] = 1.0; + } + } + dw = f.Reverse(1, w); + for(size_t j = 0; j < n_; j++) + { double check = 0.0; + if( j < n_ - 1 ) + check = z1[n_ - 1] / ( x[n_ - 1] * x[j] ); + ok &= NearEqual(dw[j] , check, acc[n_-1], acc[n_-1]); + } + // + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/get_started.cpp cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/get_started.cpp --- cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/get_started.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/get_started.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,193 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin chkpoint_one_get_started.cpp$$ +$spell + checkpointing + Taylor +$$ + +$section Simple Checkpointing: Example and Test$$ + +$head Purpose$$ +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 +for this example there are only two. +The functions +$latex F : \B{R}^2 \rightarrow \B{R}^2$$ +and +$latex G : \B{R}^2 \rightarrow \B{R}^2$$ +defined by +$latex \[ + F(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} + x_0 \cdot x_0 \cdot x_0 + \\ + x_1 \cdot x_1 \cdot x_1 + \end{array} \right) +\] $$ + +$comment %example/chkpoint_one/get_started.cpp%0%// BEGIN C++%// END C++%1%$$ + + +$end +*/ +// BEGIN C++ + +# include + +namespace { + using CppAD::AD; + typedef CPPAD_TESTVECTOR(AD) ADVector; + typedef CppAD::atomic_base::option_enum option_enum; + + 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 < 3; k++) + { y[0] *= x[0]; + y[1] *= x[1]; + } + return; + } + bool test_case( + option_enum f_sparsity, option_enum g_sparsity, bool optimize ) + { 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 because 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 / double(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)); + for(i = 0; i < m * (q + 1); i++) + w[i] = 1.0 / double(i + 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 &= r_not[i] == r_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 get_started(void) +{ bool ok = true; + + // 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, true); + ok &= test_case(pack_sparsity, bool_sparsity, false); + ok &= test_case(bool_sparsity, set_sparsity, true); + ok &= test_case(set_sparsity, set_sparsity, false); + + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/makefile.am cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/makefile.am --- cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,34 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# automake input file +# +# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp +DEFS = +# +check_PROGRAMS = checkpoint +# +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) +# +# +checkpoint_SOURCES = \ + chkpoint_one.cpp \ + get_started.cpp \ + extended_ode.cpp \ + mul_level.cpp \ + ode.cpp + +test: check + ./checkpoint diff -Nru cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/makefile.in cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/makefile.in --- cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,630 @@ +# makefile.in generated by automake 1.15.1 from makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2017 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +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 \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +check_PROGRAMS = checkpoint$(EXEEXT) +subdir = test_more/deprecated/chkpoint_one +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_checkpoint_OBJECTS = chkpoint_one.$(OBJEXT) get_started.$(OBJEXT) \ + extended_ode.$(OBJEXT) mul_level.$(OBJEXT) ode.$(OBJEXT) +checkpoint_OBJECTS = $(am_checkpoint_OBJECTS) +checkpoint_LDADD = $(LDADD) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(checkpoint_SOURCES) +DIST_SOURCES = $(checkpoint_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + 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@ +ACLOCAL = @ACLOCAL@ +ADOLC_DIR = @ADOLC_DIR@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BOOST_DIR = @BOOST_DIR@ +BOOST_INCLUDE = @BOOST_INCLUDE@ +BTHREAD_LIB = @BTHREAD_LIB@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPAD_IPOPT_LD_PATH = @CPPAD_IPOPT_LD_PATH@ +CPPAD_IPOPT_LIBS = @CPPAD_IPOPT_LIBS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXX_FLAGS@ +CYGPATH_W = @CYGPATH_W@ + +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# automake input file +# +# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp +DEFS = +DEPDIR = @DEPDIR@ +DL_LIB = @DL_LIB@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EIGEN_DIR = @EIGEN_DIR@ +EIGEN_INCLUDE = @EIGEN_INCLUDE@ +EXEEXT = @EXEEXT@ +FADBAD_DIR = @FADBAD_DIR@ +FC = @FC@ +FCFLAGS = @FCFLAGS@ +FCLIBS = @FCLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +IPOPT_DIR = @IPOPT_DIR@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAX_NUM_THREADS = @MAX_NUM_THREADS@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +OPENMP_FLAGS = @OPENMP_FLAGS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSTFIX_DIR = @POSTFIX_DIR@ +PTHREAD_LIB = @PTHREAD_LIB@ +RANLIB = @RANLIB@ +SACADO_DIR = @SACADO_DIR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TAPE_ADDR_TYPE = @TAPE_ADDR_TYPE@ +TAPE_ID_TYPE = @TAPE_ID_TYPE@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_FC = @ac_ct_FC@ +adolc_prefix = @adolc_prefix@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ +cppad_boostvector = @cppad_boostvector@ +cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ +cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated_01 = @cppad_deprecated_01@ +cppad_description = @cppad_description@ +cppad_eigenvector = @cppad_eigenvector@ +cppad_has_adolc = @cppad_has_adolc@ +cppad_has_boost = @cppad_has_boost@ +cppad_has_colpack = @cppad_has_colpack@ +cppad_has_eigen = @cppad_has_eigen@ +cppad_has_fadbad = @cppad_has_fadbad@ +cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_ipopt = @cppad_has_ipopt@ +cppad_has_mkstemp = @cppad_has_mkstemp@ +cppad_has_sacado = @cppad_has_sacado@ +cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ +cppad_max_num_threads = @cppad_max_num_threads@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ +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_version = @cppad_version@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +eigen_prefix = @eigen_prefix@ +exec_prefix = @exec_prefix@ +have_pkg_config = @have_pkg_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +ipopt_prefix = @ipopt_prefix@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +# +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + +# +# +checkpoint_SOURCES = \ + chkpoint_one.cpp \ + get_started.cpp \ + extended_ode.cpp \ + mul_level.cpp \ + ode.cpp + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test_more/deprecated/chkpoint_one/makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign test_more/deprecated/chkpoint_one/makefile +makefile: $(srcdir)/makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) + +checkpoint$(EXEEXT): $(checkpoint_OBJECTS) $(checkpoint_DEPENDENCIES) $(EXTRA_checkpoint_DEPENDENCIES) + @rm -f checkpoint$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(checkpoint_OBJECTS) $(checkpoint_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chkpoint_one.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extended_ode.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_started.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mul_level.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ode.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) +check: check-am +all-am: makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ + clean-checkPROGRAMS clean-generic cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +.PRECIOUS: makefile + + +test: check + ./checkpoint + +# 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. +.NOEXPORT: diff -Nru cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/mul_level.cpp cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/mul_level.cpp --- cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/mul_level.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/mul_level.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,112 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin chkpoint_one_mul_level.cpp$$ +$spell + checkpointing +$$ + +$section Atomic Operations and Multiple-Levels of AD: Example and Test$$ + +$head Discussion$$ +One can use $cref/checkpoint/chkpoint_one/$$ or $cref atomic_two$$ to code +an $codei%AD<%Base%>%$$ operation as atomic. +This means that derivative computations that use the type $icode Base$$ +will call the corresponding $code atomic_base$$ member functions. +On the other hand, if $icode Base$$ is $codei%AD<%Other%>%$$ the +operations recorded at the $icode Base$$ level will not be atomic. +This is demonstrated in this example. + +$comment %example/chkpoint_one/mul_level.cpp%0%// BEGIN C++%// END C++%1%$$ + + +$end +*/ +// BEGIN C++ + +# include + +namespace { + using CppAD::AD; + typedef AD a1double; + typedef AD a2double; + typedef CPPAD_TESTVECTOR(a1double) a1vector; + typedef CPPAD_TESTVECTOR(a2double) a2vector; + + void f_algo(const a2vector& x, a2vector& y) + { size_t n = x.size(); + y[0] = 0.0; + for(size_t j = 1; j < n; j++) + y[0] += x[j-1] * x[j]; + return; + } +} +// +bool mul_level(void) +{ bool ok = true; + using CppAD::checkpoint; + using CppAD::ADFun; + using CppAD::Independent; + + // domain dimension for this problem + size_t n = 10; + size_t m = 1; + + // checkpoint version of the function F(x) + a2vector a2x(n), a2y(m); + for(size_t j = 0; j < n; j++) + a2x[j] = a2double(j + 1); + // + // could also use bool_sparsity_enum or set_sparsity_enum + checkpoint atom_f("atom_f", f_algo, a2x, a2y); + // + // Record a version of y = f(x) without checkpointing + Independent(a2x); + f_algo(a2x, a2y); + ADFun check_not(a2x, a2y); + // + // number of variables in a tape of f_algo that does not use checkpointing + size_t size_not = check_not.size_var(); + // + // Record a version of y = f(x) with checkpointing + Independent(a2x); + atom_f(a2x, a2y); + ADFun check_yes(a2x, a2y); + // + // f_algo is represented by one atomic operation in this tape + ok &= check_yes.size_var() < size_not; + // + // now record operations at a1double level + a1vector a1x(n), a1y(m); + for(size_t j = 0; j < n; j++) + a1x[j] = a1double(j + 1); + // + // without checkpointing + Independent(a1x); + a1y = check_not.Forward(0, a1x); + ADFun with_not(a1x, a1y); + // + // should have the same size + ok &= with_not.size_var() == size_not; + // + // with checkpointing + Independent(a1x); + a1y = check_yes.Forward(0, a1x); + ADFun with_yes(a1x, a1y); + // + // f_algo is nolonger represented by one atomic operation in this tape + ok &= with_yes.size_var() == size_not; + // + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/ode.cpp cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/ode.cpp --- cppad-2018.00.00.0/test_more/deprecated/chkpoint_one/ode.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/chkpoint_one/ode.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,316 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin chkpoint_one_ode.cpp$$ +$spell + Checkpointing + Runge-Kutta +$$ + +$section Checkpointing an ODE Solver: Example and Test$$ + +$head See Also$$ +$cref chkpoint_one_extended_ode.cpp$$, + +$head Purpose$$ +In this example we $cref/checkpoint/chkpoint_one/$$ one step of an ODE solver. + +$head Problem$$ +We consider the initial value problem with parameter $latex x$$ defined by, +$latex z(0, x) = z_0 (x)$$, +$latex \[ + \partial_t z(t, x ) = h [ x , z(t, x) ] +\]$$ +Note that if $latex t$$ needs to be in the equation, one can define +the first component of $latex z(t, x)$$ to be equal to $latex t$$. + +$head ODE Solver$$ +For this example, we consider the Fourth order Runge-Kutta ODE solver. +Given an approximation solution at time $latex t_k$$ denoted by +$latex \tilde{z}_k (x)$$, and $latex \Delta t = t_{k+1} - t_k$$, +it defines the approximation solution $latex \tilde{z}_{k+1} (x)$$ +at time $latex t_{k+1}$$ by +$latex \[ +\begin{array}{rcl} +h_1 & = & h [ x , \tilde{z}_k (x) ] +\\ +h_2 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_1 / 2 ] +\\ +h_3 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_2 / 2 ] +\\ +h_4 & = & h [ x , \tilde{z}_k (x) + \Delta t \; h_3 ] +\\ +\tilde{z}_{k+1} (x) & = & + \tilde{z}_k (x) + \Delta t \; ( h_1 + 2 h_2 + 2 h_3 + h_4 ) / 6 +\end{array} +\] $$ +If $latex \tilde{z}_k (x) = z_k (x)$$, +$latex \tilde{z}_{k+1} (x) = z_{k+1} (x) + O( \Delta t^5 )$$. +Other ODE solvers can use a similar method to the one used below. + +$head ODE$$ +For this example the ODE is defined by +$latex z(0, x) = 0$$ and +$latex \[ + h[ x, z(t, x) ] = + \left( \begin{array}{c} + x_0 \\ + x_1 z_0 (t, x) \\ + \vdots \\ + x_{n-1} z_{n-2} (t, x) + \end{array} \right) + = + \left( \begin{array}{c} + \partial_t z_0 (t , x) \\ + \partial_t z_1 (t , x) \\ + \vdots \\ + \partial_t z_{n-1} (t , x) + \end{array} \right) +\] $$ + +$head Solution$$ +The solution of the ODE for this example, +which is used to check the results, +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 +$latex \[ + z(t, x) = + \left( \begin{array}{c} + x_0 t \\ + x_1 x_0 t^2 / 2 \\ + \vdots \\ + x_{n-1} x_{n-2} \ldots x_0 t^n / n ! + \end{array} \right) +\] $$ + + +$comment %example/chkpoint_one/ode.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ + +# include + +namespace { + using CppAD::AD; + typedef AD a1double; + typedef AD a2double; + // + typedef CPPAD_TESTVECTOR( double ) a0vector; + typedef CPPAD_TESTVECTOR( a1double ) a1vector; + typedef CPPAD_TESTVECTOR( a2double ) a2vector; + // + // set once by main and kept that way + double delta_t_ = std::numeric_limits::quiet_NaN(); + size_t n_ = 0; + // + // The function h( x , y) + template + FloatVector h(const FloatVector& x, const FloatVector& y) + { assert( size_t( x.size() ) == n_ ); + assert( size_t( y.size() ) == n_ ); + FloatVector result(n_); + result[0] = x[0]; + for(size_t i = 1; i < n_; i++) + result[i] = x[i] * y[i-1]; + return result; + } + + // The 4-th Order Runge-Kutta Step + template + FloatVector Runge4(const FloatVector& x, const FloatVector& z0 + ) + { assert( size_t( x.size() ) == n_ ); + assert( size_t( z0.size() ) == n_ ); + // + typedef typename FloatVector::value_type Float; + // + Float dt = Float(delta_t_); + size_t m = z0.size(); + // + FloatVector h1(m), h2(m), h3(m), h4(m), result(m); + h1 = h( x, z0 ); + // + for(size_t i = 0; i < m; i++) + h2[i] = z0[i] + dt * h1[i] / 2.0; + h2 = h( x, h2 ); + // + for(size_t i = 0; i < m; i++) + h3[i] = z0[i] + dt * h2[i] / 2.0; + h3 = h( x, h3 ); + // + for(size_t i = 0; i < m; i++) + h4[i] = z0[i] + dt * h3[i]; + h4 = h( x, h4 ); + // + for(size_t i = 0; i < m; i++) + { Float dz = dt * ( h1[i] + 2.0*h2[i] + 2.0*h3[i] + h4[i] ) / 6.0; + result[i] = z0[i] + dz; + } + return result; + } + + // pack x and z into an ode_info vector + template + void pack( + FloatVector& ode_info , + const FloatVector& x , + const FloatVector& z ) + { assert( size_t( ode_info.size() ) == n_ + n_ ); + assert( size_t( x.size() ) == n_ ); + assert( size_t( z.size() ) == n_ ); + // + size_t offset = 0; + for(size_t i = 0; i < n_; i++) + ode_info[offset + i] = x[i]; + offset += n_; + for(size_t i = 0; i < n_; i++) + ode_info[offset + i] = z[i]; + } + + // unpack an ode_info vector + template + void unpack( + const FloatVector& ode_info , + FloatVector& x , + FloatVector& z ) + { assert( size_t( ode_info.size() ) == n_ + n_ ); + assert( size_t( x.size() ) == n_ ); + assert( size_t( z.size() ) == n_ ); + // + size_t offset = 0; + for(size_t i = 0; i < n_; i++) + x[i] = ode_info[offset + i]; + offset += n_; + for(size_t i = 0; i < n_; i++) + z[i] = ode_info[offset + i]; + } + + // Algorithm that z(t, x) + void ode_algo(const a1vector& ode_info_in, a1vector& ode_info_out) + { assert( size_t( ode_info_in.size() ) == n_ + n_ ); + assert( size_t( ode_info_out.size() ) == n_ + n_ ); + // + // initial ode information + a1vector x(n_), z0(n_); + unpack(ode_info_in, x, z0); + // + // advance z(t, x) + a1vector z1 = Runge4(x, z0); + // + // final ode information + pack(ode_info_out, x, z1); + // + return; + } +} +// +bool ode(void) +{ bool ok = true; + using CppAD::NearEqual; + double eps = std::numeric_limits::epsilon(); + // + // number of terms in the differential equation + n_ = 6; + // + // step size for the differentiail equation + size_t n_step = 10; + double T = 1.0; + delta_t_ = T / double(n_step); + // + // set parameter value and initial value of the ode + a1vector ax(n_), az0(n_); + for(size_t i = 0; i < n_; i++) + { ax[i] = a1double(i + 1); + az0[i] = a1double(0); + } + // + // pack ode information input vector + a1vector ode_info_in(2 * n_); + pack(ode_info_in, ax, az0); + // + // create checkpoint version of the algorithm + a1vector ode_info_out(2 * n_); + CppAD::checkpoint ode_check( + "ode", ode_algo, ode_info_in, ode_info_out + ); + // + // set the independent variables for recording + CppAD::Independent( ax ); + // + // repack to get dependence on ax + pack(ode_info_in, ax, az0); + // + // Now run the checkpoint algorithm n_step times + for(size_t k = 0; k < n_step; k++) + { ode_check(ode_info_in, ode_info_out); + ode_info_in = ode_info_out; + } + // + // Unpack the results (must use ax1 so do not overwrite ax) + a1vector ax1(n_), az1(n_); + unpack(ode_info_out, ax1, az1); + // + // We could record a complicated funciton of x and z(T, x) in f, + // but make this example simpler we record x -> z(T, x). + CppAD::ADFun f(ax, az1); + // + // check function values + a0vector x(n_), z1(n_); + for(size_t j = 0; j < n_; j++) + x[j] = double(j + 1); + z1 = f.Forward(0, x); + // + // separate calculation of z(t, x) + a0vector check_z1(n_); + check_z1[0] = x[0] * T; + for(size_t i = 1; i < n_; i++) + check_z1[i] = x[i] * T * check_z1[i-1] / double(i+1); + // + // expected accuracy for each component of of z(t, x) + a0vector acc(n_); + for(size_t i = 0; i < n_; i++) + { if( i < 4 ) + { // Runge-Kutta methos is exact for this case + acc[i] = 10. * eps; + } + else + { acc[i] = 1.0; + for(size_t k = 0; k < 5; k++) + acc[i] *= x[k] * delta_t_; + } + } + // check z1(T, x) + for(size_t i = 0; i < n_; i++) + ok &= NearEqual(z1[i] , check_z1[i], acc[i], acc[i]); + // + // Now use f to compute a derivative. For this 'simple' example it is + // the derivative of z_{n-1} (T, x) respect to x of the + a0vector w(n_), dw(n_); + for(size_t i = 0; i < n_; i++) + { w[i] = 0.0; + if( i == n_ - 1 ) + w[i] = 1.0; + } + dw = f.Reverse(1, w); + for(size_t j = 0; j < n_; j++) + { double check = z1[n_ - 1] / x[j]; + ok &= NearEqual(dw[j] , check, 100.*eps, 100.*eps); + } + // + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/deprecated/CMakeLists.txt cppad-2019.02.00.0/test_more/deprecated/CMakeLists.txt --- cppad-2018.00.00.0/test_more/deprecated/CMakeLists.txt 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,43 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# Build the test_more/deprecated tests +# +SET(check_test_more_deprecated_depends "test_more_deprecated") +ADD_SUBDIRECTORY(atomic_two) +ADD_SUBDIRECTORY(chkpoint_one) +# +SET(source_list + deprecated.cpp + old_reciprocal.cpp + old_usead_1.cpp + old_usead_2.cpp + old_tan.cpp + old_mat_mul.cpp + omp_alloc.cpp + track_new_del.cpp + zdouble.cpp +) +set_compile_flags( test_more_deprecated "${cppad_debug_which}" "${source_list}" ) +# +ADD_EXECUTABLE(test_more_deprecated EXCLUDE_FROM_ALL ${source_list}) +# +# Add the check_test_more_deprecated target +ADD_CUSTOM_TARGET(check_test_more_deprecated + test_more_deprecated + DEPENDS + ${check_test_more_deprecated_depends} +) +MESSAGE(STATUS "make check_test_more_deprecated: available") +# +# Change check depends in parent environment +add_to_list(check_test_more_depends check_test_more_deprecated) +SET(check_test_more_depends "${check_test_more_depends}" PARENT_SCOPE) diff -Nru cppad-2018.00.00.0/test_more/deprecated/deprecated.cpp cppad-2019.02.00.0/test_more/deprecated/deprecated.cpp --- cppad-2018.00.00.0/test_more/deprecated/deprecated.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/deprecated.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,59 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +// CPPAD_HAS_* defines +# include + +// system include files used for I/O +# include + +// memory leak checker +# include + +// test runner +# include + +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 track_new_del(void); +extern bool zdouble(void); + +// main program that runs all the tests +int main(void) +{ std::string group = "test_more/deprecated"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + Run( old_mat_mul, "old_mat_mul" ); + Run( old_reciprocal, "old_reciprocal" ); + Run( old_tan, "old_tan" ); + Run( old_usead_1, "old_usead_1" ); + Run( old_usead_2, "old_usead_2" ); + Run( omp_alloc, "omp_alloc" ); + Run( track_new_del, "track_new_del" ); + Run( zdouble, "zdouble" ); + // + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); +} +// END PROGRAM diff -Nru cppad-2018.00.00.0/test_more/deprecated/makefile.am cppad-2019.02.00.0/test_more/deprecated/makefile.am --- cppad-2018.00.00.0/test_more/deprecated/makefile.am 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,39 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# automake input file +# +# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp +DEFS = +# +check_PROGRAMS = deprecated +# +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) +# +# +deprecated_SOURCES = \ + deprecated.cpp \ + old_reciprocal.cpp \ + old_usead_1.cpp \ + old_usead_2.cpp \ + old_tan.cpp \ + old_mat_mul.cpp \ + old_mat_mul.hpp \ + omp_alloc.cpp \ + track_new_del.cpp \ + zdouble.cpp +# +test: check + ./deprecated diff -Nru cppad-2018.00.00.0/test_more/deprecated/makefile.in cppad-2019.02.00.0/test_more/deprecated/makefile.in --- cppad-2018.00.00.0/test_more/deprecated/makefile.in 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,653 @@ +# makefile.in generated by automake 1.15.1 from makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2017 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +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 \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +check_PROGRAMS = deprecated$(EXEEXT) +subdir = test_more/deprecated +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_deprecated_OBJECTS = deprecated.$(OBJEXT) old_reciprocal.$(OBJEXT) \ + old_usead_1.$(OBJEXT) old_usead_2.$(OBJEXT) old_tan.$(OBJEXT) \ + old_mat_mul.$(OBJEXT) omp_alloc.$(OBJEXT) \ + track_new_del.$(OBJEXT) zdouble.$(OBJEXT) +deprecated_OBJECTS = $(am_deprecated_OBJECTS) +deprecated_LDADD = $(LDADD) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +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 = $(deprecated_SOURCES) +DIST_SOURCES = $(deprecated_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + 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@ +ACLOCAL = @ACLOCAL@ +ADOLC_DIR = @ADOLC_DIR@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BOOST_DIR = @BOOST_DIR@ +BOOST_INCLUDE = @BOOST_INCLUDE@ +BTHREAD_LIB = @BTHREAD_LIB@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPAD_IPOPT_LD_PATH = @CPPAD_IPOPT_LD_PATH@ +CPPAD_IPOPT_LIBS = @CPPAD_IPOPT_LIBS@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CXX_FLAGS = @CXX_FLAGS@ +CYGPATH_W = @CYGPATH_W@ + +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# automake input file +# +# CppAD pusts all it's preprocessor definitions in the cppad/configure.hpp +DEFS = +DEPDIR = @DEPDIR@ +DL_LIB = @DL_LIB@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EIGEN_DIR = @EIGEN_DIR@ +EIGEN_INCLUDE = @EIGEN_INCLUDE@ +EXEEXT = @EXEEXT@ +FADBAD_DIR = @FADBAD_DIR@ +FC = @FC@ +FCFLAGS = @FCFLAGS@ +FCLIBS = @FCLIBS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +IPOPT_DIR = @IPOPT_DIR@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAX_NUM_THREADS = @MAX_NUM_THREADS@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +OPENMP_FLAGS = @OPENMP_FLAGS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSTFIX_DIR = @POSTFIX_DIR@ +PTHREAD_LIB = @PTHREAD_LIB@ +RANLIB = @RANLIB@ +SACADO_DIR = @SACADO_DIR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TAPE_ADDR_TYPE = @TAPE_ADDR_TYPE@ +TAPE_ID_TYPE = @TAPE_ID_TYPE@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_FC = @ac_ct_FC@ +adolc_prefix = @adolc_prefix@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ +cppad_boostvector = @cppad_boostvector@ +cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ +cppad_cppadvector = @cppad_cppadvector@ +cppad_cxx_flags = @cppad_cxx_flags@ +cppad_deprecated_01 = @cppad_deprecated_01@ +cppad_description = @cppad_description@ +cppad_eigenvector = @cppad_eigenvector@ +cppad_has_adolc = @cppad_has_adolc@ +cppad_has_boost = @cppad_has_boost@ +cppad_has_colpack = @cppad_has_colpack@ +cppad_has_eigen = @cppad_has_eigen@ +cppad_has_fadbad = @cppad_has_fadbad@ +cppad_has_gettimeofday = @cppad_has_gettimeofday@ +cppad_has_ipopt = @cppad_has_ipopt@ +cppad_has_mkstemp = @cppad_has_mkstemp@ +cppad_has_sacado = @cppad_has_sacado@ +cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ +cppad_max_num_threads = @cppad_max_num_threads@ +cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ +cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ +cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ +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_version = @cppad_version@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +eigen_prefix = @eigen_prefix@ +exec_prefix = @exec_prefix@ +have_pkg_config = @have_pkg_config@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +ipopt_prefix = @ipopt_prefix@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +# +AM_CXXFLAGS = \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ + $(BOOST_INCLUDE) \ + $(EIGEN_INCLUDE) + +# +# +deprecated_SOURCES = \ + deprecated.cpp \ + old_reciprocal.cpp \ + old_usead_1.cpp \ + old_usead_2.cpp \ + old_tan.cpp \ + old_mat_mul.cpp \ + old_mat_mul.hpp \ + omp_alloc.cpp \ + track_new_del.cpp \ + zdouble.cpp + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +$(srcdir)/makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign test_more/deprecated/makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign test_more/deprecated/makefile +makefile: $(srcdir)/makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) + +deprecated$(EXEEXT): $(deprecated_OBJECTS) $(deprecated_DEPENDENCIES) $(EXTRA_deprecated_DEPENDENCIES) + @rm -f deprecated$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(deprecated_OBJECTS) $(deprecated_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/deprecated.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)/track_new_del.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$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) +check: check-am +all-am: makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ + clean-checkPROGRAMS clean-generic cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +.PRECIOUS: makefile + +# +test: check + ./deprecated + +# 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. +.NOEXPORT: diff -Nru cppad-2018.00.00.0/test_more/deprecated/old_mat_mul.cpp cppad-2019.02.00.0/test_more/deprecated/old_mat_mul.cpp --- cppad-2018.00.00.0/test_more/deprecated/old_mat_mul.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/old_mat_mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,270 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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; +use $cref atomic_two_mat_mul.cpp$$ instead. + +$children% + example/deprecated/old_mat_mul.hpp +%$$ +$head Include File$$ +This routine uses the include file old_mat_mul.hpp. + +$srcfile%test_more/deprecated/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] = double(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] = double(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-2018.00.00.0/test_more/deprecated/old_mat_mul.hpp cppad-2019.02.00.0/test_more/deprecated/old_mat_mul.hpp --- cppad-2018.00.00.0/test_more/deprecated/old_mat_mul.hpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/old_mat_mul.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,423 @@ +# ifndef CPPAD_TEST_MORE_DEPRECATED_OLD_MAT_MUL_HPP +# define CPPAD_TEST_MORE_DEPRECATED_OLD_MAT_MUL_HPP +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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$$ + + +$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 old_mat_mul.cpp contains an example use of +$code old_mat_mul.hpp$$. + +$head Begin Source$$ +$srccode%cpp% */ +# include // Include CppAD definitions +namespace { // Begin empty namespace + using CppAD::vector; // Let vector denote CppAD::vector +/* %$$ + +$head Extra Call Information$$ +$srccode%cpp% */ + // 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$$ +$srccode%cpp% */ + // 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: +$srccode%cpp% */ + 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: +$srccode%cpp% */ + 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$$ +$srccode%cpp% */ + using CppAD::set_union; +/* %$$ + +$head CppAD User Atomic Callback Functions$$ +$srccode%cpp% */ + // ---------------------------------------------------------------------- + // 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] ) + s[ij_result] = set_union(s[ij_result], r[im_left]); + + // s[ij_result] = union( s[ij_result], r[mj_right] ) + s[ij_result] = set_union(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] ) + r[im_left] = set_union(r[im_left], s[ij_result]); + + // r[mj_right] = union( r[mj_right], s[ij_result] ) + r[mj_right] = set_union(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] ) + v[im_left] = set_union(v[im_left], u[ij_result] ); + v[mj_right] = set_union(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] ) + v[im_left] = set_union(v[im_left], r[mj_right] ); + // v[mj_right] = union( v[mj_right], r[im_left] ) + v[mj_right] = set_union(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$$): +$srccode%cpp% */ + 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-2018.00.00.0/test_more/deprecated/old_reciprocal.cpp cppad-2019.02.00.0/test_more/deprecated/old_reciprocal.cpp --- cppad-2018.00.00.0/test_more/deprecated/old_reciprocal.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/old_reciprocal.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,356 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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_two_reciprocal.cpp$$ instead. + +$head Theory$$ +The example below defines the atomic function +$latex f : \B{R}^n \rightarrow \B{R}^m$$ where +$latex n = 1$$, $latex m = 1$$, and $latex f(x) = 1 / x$$. + +$srcfile%test_more/deprecated/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. + using CppAD::set_union; + + // ---------------------------------------------------------------------- + // 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] ) + v[0] = set_union(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 atomic 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 atomic 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 atomic_one objects. + // (If there are future calls to atomic functions, they will + // create new temporary work space.) + CppAD::user_atomic::clear(); + + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/deprecated/old_tan.cpp cppad-2019.02.00.0/test_more/deprecated/old_tan.cpp --- cppad-2018.00.00.0/test_more/deprecated/old_tan.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/old_tan.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,409 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$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_two_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 atomic function operations. + +$srcfile%test_more/deprecated/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. + using CppAD::set_union; + + // ---------------------------------------------------------------------- + // 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] = float( tan( tx[0] ) ); + else + tzy[0] = float( 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] * float(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] * float(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] * float(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] + r[0] = set_union(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, ... + v[0] = set_union(u[0], u[1]); + + // convert forward Jacobian sparsity to Hessian sparsity + // because tan and tanh are nonlinear + if( t[0] ) + v[0] = set_union(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 atomic_one objects. + // (If there are future calls to atomic functions, they will + // create new temporary work space.) + CppAD::user_atomic::clear(); + + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/deprecated/old_usead_1.cpp cppad-2019.02.00.0/test_more/deprecated/old_usead_1.cpp --- cppad-2018.00.00.0/test_more/deprecated/old_usead_1.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/old_usead_1.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,366 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin old_usead_1.cpp$$ +$spell + checkpoint + var +$$ + +$section Using AD to Compute Atomic Function Derivatives$$ + +$head Deprecated 2013-05-27$$ +This example has been deprecated because it is easier to use the +$cref/checkpoint/chkpoint_one/$$ 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 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 old_usead_2.cpp for a more complete example. + +$srcfile%test_more/deprecated/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::const_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 atomic 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 atomic 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 atomic_one objects. + // (If there are future calls to atomic functions, they will + // create new temporary work space.) + CppAD::user_atomic::clear(); + + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/deprecated/old_usead_2.cpp cppad-2019.02.00.0/test_more/deprecated/old_usead_2.cpp --- cppad-2018.00.00.0/test_more/deprecated/old_usead_2.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/old_usead_2.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,493 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin old_usead_2.cpp$$ +$spell + checkpoint + var +$$ + +$section Using AD to Compute Atomic Function Derivatives$$ + + +$head Deprecated 2013-05-27$$ +This example has been deprecated because it is easier to use the +$cref/checkpoint/chkpoint_one/$$ 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. + +$srcfile%test_more/deprecated/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] / double(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 atomic_one objects. + // (If there are future calls to atomic functions, they will + // create new temporary work space.) + CppAD::user_atomic::clear(); + + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/deprecated/omp_alloc.cpp cppad-2019.02.00.0/test_more/deprecated/omp_alloc.cpp --- cppad-2018.00.00.0/test_more/deprecated/omp_alloc.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/omp_alloc.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,188 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin omp_alloc.cpp$$ +$spell + openmp +$$ + +$section OpenMP Memory Allocator: Example and Test$$ + + +$head Deprecated 2011-08-31$$ +This example is only intended to help convert calls to $cref omp_alloc$$ +to calls to $cref thread_alloc$$. + +$srcfile%test_more/deprecated/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-2018.00.00.0/test_more/deprecated/track_new_del.cpp cppad-2019.02.00.0/test_more/deprecated/track_new_del.cpp --- cppad-2018.00.00.0/test_more/deprecated/track_new_del.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/track_new_del.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,66 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin TrackNewDel.cpp$$ + +$section Tracking Use of New and Delete: Example and Test$$ + + + +$srcfile%test_more/deprecated/track_new_del.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ + +# include + +bool track_new_del(void) +{ bool ok = true; + + // initial count + size_t count = CPPAD_TRACK_COUNT(); + + // allocate an array of length 5 + double *ptr = CPPAD_NULL; + size_t newlen = 5; + ptr = CPPAD_TRACK_NEW_VEC(newlen, ptr); + + // copy data into the array + size_t ncopy = newlen; + size_t i; + for(i = 0; i < ncopy; i++) + ptr[i] = double(i); + + // extend the buffer to be length 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++) + ok &= (ptr[i] == double(i)); + + // free the memory allocated since previous call to TrackCount + CPPAD_TRACK_DEL_VEC(ptr); + + // check for memory leak + ok &= (count == CPPAD_TRACK_COUNT()); + + return ok; +} + +// END C++ diff -Nru cppad-2018.00.00.0/test_more/deprecated/zdouble.cpp cppad-2019.02.00.0/test_more/deprecated/zdouble.cpp --- cppad-2018.00.00.0/test_more/deprecated/zdouble.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/deprecated/zdouble.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,138 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +/* +$begin zdouble.cpp$$ +$spell + zdouble +$$ + +$section zdouble: Example and Test$$ + +$srcfile%test_more/deprecated/zdouble.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ +# include + +namespace { + template bool test_one(void) + { bool ok = true; + Base eps99 = 99. * 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], eps99, eps99); + ok &= CppAD::NearEqual(z[1], - x[0]/(x[1]*x[1]), eps99, eps99); + + return ok; + } + bool test_two(void) + { bool ok = true; + using CppAD::zdouble; + // + zdouble eps = CppAD::numeric_limits::epsilon(); + ok &= eps == std::numeric_limits::epsilon(); + // + zdouble min = CppAD::numeric_limits::min(); + ok &= min == std::numeric_limits::min(); + // + zdouble max = CppAD::numeric_limits::max(); + ok &= max == std::numeric_limits::max(); + // + zdouble nan = CppAD::numeric_limits::quiet_NaN(); + ok &= nan != nan; + // + int digits10 = CppAD::numeric_limits::digits10; + ok &= digits10 == std::numeric_limits::digits10; + // + return ok; + } +} + +bool zdouble(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + using CppAD::zdouble; + // + ok &= test_one(); + ok &= test_one(); + // + ok &= test_two(); + // + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/general/acos.cpp cppad-2019.02.00.0/test_more/general/acos.cpp --- cppad-2018.00.00.0/test_more/general/acos.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/acos.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old acos examples now used just for valiadation testing @@ -15,56 +16,56 @@ # include bool acos(void) -{ bool ok = true; - using CppAD::acos; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(1); - U[0] = .5; - Independent(U); - - // a temporary values - AD x = cos(U[0]); - - // 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); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(U[0] , Z[0], eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - double value = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99);// d^jz/du^j - v[0] = 0.; - value = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - value = 1.; - for(j = 0; j < p; j++) - { ok &= NearEqual(r[j], value/jfac, eps99, eps99);// d^jz/du^j - jfac *= double(j + 1); - value = 0.; - } +{ bool ok = true; + using CppAD::acos; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(1); + U[0] = .5; + Independent(U); + + // a temporary values + AD x = cos(U[0]); + + // 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); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(U[0] , Z[0], eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + double value = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99);// d^jz/du^j + v[0] = 0.; + value = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + value = 1.; + for(j = 0; j < p; j++) + { ok &= NearEqual(r[j], value/jfac, eps99, eps99);// d^jz/du^j + jfac *= double(j + 1); + value = 0.; + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/acosh.cpp cppad-2019.02.00.0/test_more/general/acosh.cpp --- cppad-2018.00.00.0/test_more/general/acosh.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/acosh.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,72 +1,73 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include bool acosh(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; + using CppAD::AD; + using CppAD::NearEqual; - // 10 times machine epsilon - double eps = 200. * std::numeric_limits::epsilon(); + // 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); + // 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/add.cpp cppad-2019.02.00.0/test_more/general/add.cpp --- cppad-2018.00.00.0/test_more/general/add.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/add.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Two old Add examples now used just for valiadation testing @@ -18,121 +19,121 @@ namespace { // BEGIN empty namespace bool AddTestOne(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(2); - size_t s = 0; - size_t t = 1; - U[s] = 3.; - U[t] = 2.; - Independent(U); - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(3); - size_t x = 0; - size_t y = 1; - size_t z = 2; - - // 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 - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // check function values - ok &= ( Z[x] == 3. + 2. ); - ok &= ( Z[y] == 3. + 2. + 1. ); - ok &= ( Z[z] == 1. + 3. + 2. + 1. ); - - // forward computation of partials w.r.t. s - v[s] = 1.; - v[t] = 0.; - w = f.Forward(1, v); - ok &= ( w[x] == 1. ); // dx/ds - ok &= ( w[y] == 1. ); // dy/ds - ok &= ( w[z] == 1. ); // dz/ds - - // reverse computation of second partials of z - CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); - w[x] = 0.; - w[y] = 0.; - w[z] = 1.; - r = f.Reverse(2, w); - ok &= ( r[2 * s + 1] == 0. ); // d^2 z / (ds ds) - ok &= ( r[2 * t + 1] == 0. ); // d^2 z / (ds dt) + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(2); + size_t s = 0; + size_t t = 1; + U[s] = 3.; + U[t] = 2.; + Independent(U); + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(3); + size_t x = 0; + size_t y = 1; + size_t z = 2; + + // 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 + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // check function values + ok &= ( Z[x] == 3. + 2. ); + ok &= ( Z[y] == 3. + 2. + 1. ); + ok &= ( Z[z] == 1. + 3. + 2. + 1. ); + + // forward computation of partials w.r.t. s + v[s] = 1.; + v[t] = 0.; + w = f.Forward(1, v); + ok &= ( w[x] == 1. ); // dx/ds + ok &= ( w[y] == 1. ); // dy/ds + ok &= ( w[z] == 1. ); // dz/ds + + // reverse computation of second partials of z + CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); + w[x] = 0.; + w[y] = 0.; + w[z] = 1.; + r = f.Reverse(2, w); + ok &= ( r[2 * s + 1] == 0. ); // d^2 z / (ds ds) + ok &= ( r[2 * t + 1] == 0. ); // d^2 z / (ds dt) - return ok; + return ok; } bool AddTestTwo(void) -{ bool ok = true; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - double u0 = .5; - CPPAD_TESTVECTOR(AD) U(1); - 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 - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = d + U[0]; // AD + AD - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(Z[0] , 2 * u0 + 10, eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - double value = 2.; - v[0] = 1.; - for(j = 1; j < p; j++) - { jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - value = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - value = 2.; - for(j = 0; j < p; j++) - { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - value = 0.; - } +{ bool ok = true; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + double u0 = .5; + CPPAD_TESTVECTOR(AD) U(1); + 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 + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Z(1); + Z[0] = d + U[0]; // AD + AD + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(Z[0] , 2 * u0 + 10, eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + double value = 2.; + v[0] = 1.; + for(j = 1; j < p; j++) + { jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + value = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + value = 2.; + for(j = 0; j < p; j++) + { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + jfac *= double(j + 1); + value = 0.; + } - return ok; + return ok; } } // END empty namespace bool Add(void) -{ bool ok = true; - ok &= AddTestOne(); - ok &= AddTestTwo(); - return ok; +{ bool ok = true; + ok &= AddTestOne(); + ok &= AddTestTwo(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/add_eq.cpp cppad-2019.02.00.0/test_more/general/add_eq.cpp --- cppad-2018.00.00.0/test_more/general/add_eq.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/add_eq.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Two old example now used just for valiadation testing @@ -17,122 +18,122 @@ namespace { // BEGIN empty namespace bool AddEqOne(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(2); - size_t s = 0; - size_t t = 1; - U[s] = 3.; - U[t] = 2.; - Independent(U); - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(2); - size_t x = 0; - size_t y = 1; - - // dependent variable values - Z[x] = 4.; - Z[y] = U[t]; - Z[x] += U[s]; // parameter += variable - Z[x] += U[t]; // variable += variable - 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 - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // check function values - ok &= ( Z[x] == 4. + 3. + 2. ); - ok &= ( Z[y] == 2. + .5 ); - - // forward computation of partials w.r.t. s - v[s] = 1.; - v[t] = 0.; - w = f.Forward(1, v); - ok &= ( w[x] == 1. ); // dx/ds - ok &= ( w[y] == 0. ); // dy/ds - - // reverse computation of second partials of x - CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); - w[x] = 1.; - w[y] = 0.; - r = f.Reverse(2, w); - ok &= ( r[2 * s + 1] == 0. ); - ok &= ( r[2 * t + 1] == 0. ); + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(2); + size_t s = 0; + size_t t = 1; + U[s] = 3.; + U[t] = 2.; + Independent(U); + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(2); + size_t x = 0; + size_t y = 1; + + // dependent variable values + Z[x] = 4.; + Z[y] = U[t]; + Z[x] += U[s]; // parameter += variable + Z[x] += U[t]; // variable += variable + 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 + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // check function values + ok &= ( Z[x] == 4. + 3. + 2. ); + ok &= ( Z[y] == 2. + .5 ); + + // forward computation of partials w.r.t. s + v[s] = 1.; + v[t] = 0.; + w = f.Forward(1, v); + ok &= ( w[x] == 1. ); // dx/ds + ok &= ( w[y] == 0. ); // dy/ds + + // reverse computation of second partials of x + CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); + w[x] = 1.; + w[y] = 0.; + r = f.Reverse(2, w); + ok &= ( r[2 * s + 1] == 0. ); + ok &= ( r[2 * t + 1] == 0. ); - return ok; + return ok; } bool AddEqTwo(void) -{ bool ok = true; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - double u0 = .5; - CPPAD_TESTVECTOR(AD) U(1); - U[0] = u0; - Independent(U); - - // 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 - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(Z[0] , u0+2+4+u0, eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - double value = 2.; - v[0] = 1.; - for(j = 1; j < p; j++) - { jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - value = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - value = 2.; - for(j = 0; j < p; j++) - { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - value = 0.; - } +{ bool ok = true; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + double u0 = .5; + CPPAD_TESTVECTOR(AD) U(1); + U[0] = u0; + Independent(U); + + // 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 + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(Z[0] , u0+2+4+u0, eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + double value = 2.; + v[0] = 1.; + for(j = 1; j < p; j++) + { jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + value = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + value = 2.; + for(j = 0; j < p; j++) + { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + jfac *= double(j + 1); + value = 0.; + } - return ok; + return ok; } } // END empty namespace bool AddEq(void) -{ bool ok = true; - ok &= AddEqOne(); - ok &= AddEqTwo(); - return ok; +{ bool ok = true; + ok &= AddEqOne(); + ok &= AddEqTwo(); + return ok; } // END PROGRAM diff -Nru cppad-2018.00.00.0/test_more/general/add_zero.cpp cppad-2019.02.00.0/test_more/general/add_zero.cpp --- cppad-2018.00.00.0/test_more/general/add_zero.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/add_zero.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test the use of the special parameters zero and one with the multiply operator @@ -20,59 +21,59 @@ bool AddZero(void) { - using namespace CppAD; + using namespace CppAD; - bool ok = true; + bool ok = true; - size_t i; - for(i = 0; i < 2; i++) - { // run through the cases x = 0, 1 + size_t i; + for(i = 0; i < 2; i++) + { // run through the cases x = 0, 1 - size_t j; - for(j = 0; j < 2; j++) - { // run through the cases y = 0, 1 + size_t j; + for(j = 0; j < 2; j++) + { // run through the cases y = 0, 1 - CPPAD_TESTVECTOR( ADdouble ) x(1); - x[0] = double(i); - Independent(x); + CPPAD_TESTVECTOR( ADdouble ) x(1); + x[0] = double(i); + Independent(x); - CPPAD_TESTVECTOR( ADDdouble ) y(1); - y[0] = ADDdouble(j); - Independent(y); + CPPAD_TESTVECTOR( ADDdouble ) y(1); + y[0] = ADDdouble(j); + Independent(y); - CPPAD_TESTVECTOR( ADDdouble ) z(2); - z[0] = x[0] + y[0]; - z[1] = y[0] + x[0]; - z[1] += x[0]; + CPPAD_TESTVECTOR( ADDdouble ) z(2); + z[0] = x[0] + y[0]; + z[1] = y[0] + x[0]; + z[1] += x[0]; - // f(y) = z = { x + y , y + x + x } - ADFun< ADdouble > f(y, z); - CPPAD_TESTVECTOR( ADdouble ) u( f.Domain() ); - CPPAD_TESTVECTOR( ADdouble ) v( f.Range() ); + // f(y) = z = { x + y , y + x + x } + ADFun< ADdouble > f(y, z); + CPPAD_TESTVECTOR( ADdouble ) u( f.Domain() ); + CPPAD_TESTVECTOR( ADdouble ) v( f.Range() ); - // v = f(y) - u[0] = ADdouble(j); - v = f.Forward(0, u); + // v = f(y) + u[0] = ADdouble(j); + v = f.Forward(0, u); - // check value of f - ok &= v[0] == x[0] + ADdouble(j); - ok &= v[1] == ADdouble(j) + x[0] + x[0]; + // check value of f + ok &= v[0] == x[0] + ADdouble(j); + ok &= v[1] == ADdouble(j) + x[0] + x[0]; - // g(x) = f(y) = {x + y , y + x + x} - ADFun g(x, v); - CPPAD_TESTVECTOR( double ) a( g.Domain() ); - CPPAD_TESTVECTOR( double ) b( g.Range() ); + // g(x) = f(y) = {x + y , y + x + x} + ADFun g(x, v); + CPPAD_TESTVECTOR( double ) a( g.Domain() ); + CPPAD_TESTVECTOR( double ) b( g.Range() ); - // b = g'(x) - a[0] = 1.; - b = g.Forward(1, a); + // b = g'(x) + a[0] = 1.; + b = g.Forward(1, a); - // check derivatives of g - ok &= (b[0] == 1.); - ok &= (b[1] == 2.); + // check derivatives of g + ok &= (b[0] == 1.); + ok &= (b[1] == 2.); - } - } + } + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/adfun_copy.cpp cppad-2019.02.00.0/test_more/general/adfun_copy.cpp --- cppad-2018.00.00.0/test_more/general/adfun_copy.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/adfun_copy.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test that ADFun copy constructor generates an error message. @@ -18,35 +19,35 @@ namespace { - // error handler to catch the error - void myhandler( - bool known , - int line , - const char *file , - const char *exp , - const char *msg ) - { // error handler must not return, so throw an exception - throw std::string("myhandler"); - } + // error handler to catch the error + void myhandler( + bool known , + int line , + const char *file , + const char *exp , + const char *msg ) + { // error handler must not return, so throw an exception + throw std::string("myhandler"); + } } bool adfun_copy(void) { - // error handler for this routine - CppAD::ErrorHandler info(myhandler); - // an ADFun object - CppAD::ADFun f; - // value of ok if no error occurs - bool ok = false; - try { - // This operation uses the ADFun copy constructor which is defined, - // but should not be used and should generate an error - CppAD::ADFun g(f); - } - catch ( std::string msg ) - { // check for expected return - ok = (msg == "myhandler"); - } - return ok; + // error handler for this routine + CppAD::ErrorHandler info(myhandler); + // an ADFun object + CppAD::ADFun f; + // value of ok if no error occurs + bool ok = false; + try { + // This operation uses the ADFun copy constructor which is defined, + // but should not be used and should generate an error + CppAD::ADFun g(f); + } + catch ( std::string msg ) + { // check for expected return + ok = (msg == "myhandler"); + } + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/alloc_openmp.cpp cppad-2019.02.00.0/test_more/general/alloc_openmp.cpp --- cppad-2018.00.00.0/test_more/general/alloc_openmp.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/alloc_openmp.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,77 +1,78 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // BEGIN C++ # include # include # define NUMBER_THREADS 2 namespace { - using CppAD::thread_alloc; + using CppAD::thread_alloc; - // used to inform CppAD when we are in parallel execution mode - bool in_parallel(void) - { return static_cast( omp_in_parallel() ); } - - // used to inform CppAD of current thread number thread_number() - size_t thread_number(void) - { return static_cast( omp_get_thread_num() ); } - - // structure with information for one thread - typedef struct { - // function object (worker input) - CppAD::vector x; - } thread_one_t; - - // vector with information for all threads - thread_one_t thread_all_[NUMBER_THREADS]; - - // -------------------------------------------------------------------- - // function that does the work for one thread - void worker(void) - { - size_t thread_num = thread_number(); - thread_all_[thread_num].x.resize(1); - thread_all_[thread_num].x[0]=static_cast(thread_num); - } + // used to inform CppAD when we are in parallel execution mode + bool in_parallel(void) + { return static_cast( omp_in_parallel() ); } + + // used to inform CppAD of current thread number thread_number() + size_t thread_number(void) + { return static_cast( omp_get_thread_num() ); } + + // structure with information for one thread + typedef struct { + // function object (worker input) + CppAD::vector x; + } thread_one_t; + + // vector with information for all threads + thread_one_t thread_all_[NUMBER_THREADS]; + + // -------------------------------------------------------------------- + // function that does the work for one thread + void worker(void) + { + size_t thread_num = thread_number(); + thread_all_[thread_num].x.resize(1); + thread_all_[thread_num].x[0]=static_cast(thread_num); + } } // Test routine called by the master thread (thread_num = 0). bool alloc_openmp(void) -{ bool ok = true; +{ bool ok = true; - int num_threads = NUMBER_THREADS; + 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 - ); + // 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; + // Execute the worker function in parallel + int thread_num; # pragma omp parallel for - for(thread_num = 0; thread_num < num_threads; thread_num++) - worker(); + 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); + // now inform CppAD that there is only one thread + thread_alloc::parallel_setup(1, CPPAD_NULL, CPPAD_NULL); - for(thread_num = 0; thread_num < num_threads; thread_num++) - { // 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) - // free memory that was allocated by thread number thread_num. - thread_all_[thread_num].x.clear(); - } + for(thread_num = 0; thread_num < num_threads; thread_num++) + { // 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) + // free memory that was allocated by thread number thread_num. + thread_all_[thread_num].x.clear(); + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/asin.cpp cppad-2019.02.00.0/test_more/general/asin.cpp --- cppad-2018.00.00.0/test_more/general/asin.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/asin.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old example now only used for validation testing. @@ -16,56 +17,56 @@ # include bool asin(void) -{ bool ok = true; - using CppAD::asin; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(1); - U[0] = .5; - Independent(U); - - // a temporary values - AD x = sin(U[0]); - - // 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); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(U[0] , Z[0], eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - double value = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - value = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - value = 1.; - for(j = 0; j < p; j++) - { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - value = 0.; - } +{ bool ok = true; + using CppAD::asin; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(1); + U[0] = .5; + Independent(U); + + // a temporary values + AD x = sin(U[0]); + + // 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); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(U[0] , Z[0], eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + double value = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + value = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + value = 1.; + for(j = 0; j < p; j++) + { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + jfac *= double(j + 1); + value = 0.; + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/asinh.cpp cppad-2019.02.00.0/test_more/general/asinh.cpp --- cppad-2018.00.00.0/test_more/general/asinh.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/asinh.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,72 +1,73 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include bool asinh(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; + using CppAD::AD; + using CppAD::NearEqual; - // 10 times machine epsilon - double eps = 10. * std::numeric_limits::epsilon(); + // 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); + // 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/assign.cpp cppad-2019.02.00.0/test_more/general/assign.cpp --- cppad-2018.00.00.0/test_more/general/assign.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/assign.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old example, now used just for validation testing */ @@ -15,72 +16,72 @@ # include bool assign(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = 2; // AD = int - x[1] = 3.; // AD = double - x[2] = x[1]; // AD = AD - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // 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]; - - // assign an AD object equal to an expression - y[1] = x[1] + 1.; - y[2] = x[2] + 2.; - - // check that all the resulting components of y depend on x - ok &= Variable(y[0]); // y[0] = x[0] - ok &= Variable(y[1]); // y[1] = x[1] + 1 - ok &= Variable(y[2]); // y[2] = x[2] + 2 - - // construct f : x -> y and stop the tape recording - CppAD::ADFun f(x, y); - - // check variable values - ok &= ( y[0] == 2.); - ok &= ( y[1] == 4.); - ok &= ( y[2] == 5.); - - // compute partials w.r.t x[1] - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - dx[0] = 0.; - dx[1] = 1.; - dx[2] = 0.; - dy = f.Forward(1, dx); - ok &= (dy[0] == 0.); // dy[0] / dx[1] - ok &= (dy[1] == 1.); // dy[1] / dx[1] - ok &= (dy[2] == 0.); // dy[2] / dx[1] - - // compute the derivative y[2] - CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); - w[0] = 0.; - w[1] = 0.; - w[2] = 1.; - dw = f.Reverse(1, w); - ok &= (dw[0] == 0.); // dy[2] / dx[0] - ok &= (dw[1] == 0.); // dy[2] / dx[1] - ok &= (dw[2] == 1.); // dy[2] / dx[2] - - // assign a VecAD::reference - CppAD::VecAD v(1); - AD zero(0); - v[zero] = 5.; - ok &= (v[0] == 5.); + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = 2; // AD = int + x[1] = 3.; // AD = double + x[2] = x[1]; // AD = AD + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // 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]; + + // assign an AD object equal to an expression + y[1] = x[1] + 1.; + y[2] = x[2] + 2.; + + // check that all the resulting components of y depend on x + ok &= Variable(y[0]); // y[0] = x[0] + ok &= Variable(y[1]); // y[1] = x[1] + 1 + ok &= Variable(y[2]); // y[2] = x[2] + 2 + + // construct f : x -> y and stop the tape recording + CppAD::ADFun f(x, y); + + // check variable values + ok &= ( y[0] == 2.); + ok &= ( y[1] == 4.); + ok &= ( y[2] == 5.); + + // compute partials w.r.t x[1] + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 0.; + dx[1] = 1.; + dx[2] = 0.; + dy = f.Forward(1, dx); + ok &= (dy[0] == 0.); // dy[0] / dx[1] + ok &= (dy[1] == 1.); // dy[1] / dx[1] + ok &= (dy[2] == 0.); // dy[2] / dx[1] + + // compute the derivative y[2] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 0.; + w[1] = 0.; + w[2] = 1.; + dw = f.Reverse(1, w); + ok &= (dw[0] == 0.); // dy[2] / dx[0] + ok &= (dw[1] == 0.); // dy[2] / dx[1] + ok &= (dw[2] == 1.); // dy[2] / dx[2] + + // assign a VecAD::reference + CppAD::VecAD v(1); + AD zero(0); + v[zero] = 5.; + ok &= (v[0] == 5.); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/atan2.cpp cppad-2019.02.00.0/test_more/general/atan2.cpp --- cppad-2018.00.00.0/test_more/general/atan2.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/atan2.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old example and test now just used for validation testing. @@ -19,99 +20,99 @@ namespace { // begin empty namespace bool ad_ad(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - AD< AD > x(2.), y(2.); - AD< AD > z = atan2(y, x); - NearEqual( Value( Value(z) ), atan(1.), eps99, eps99); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + AD< AD > x(2.), y(2.); + AD< AD > z = atan2(y, x); + NearEqual( Value( Value(z) ), atan(1.), eps99, eps99); - return ok; + return ok; } bool general(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::atan; - using CppAD::sin; - using CppAD::cos; - using namespace CppAD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(1); - U[0] = 1.; - Independent(U); - - // a temporary values - AD x = cos(U[0]); - AD y = sin(U[0]); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = atan2(y, x); - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check original value (u in first quadrant) - ok &= NearEqual(U[0] , Z[0], eps99, eps99); - - // check case where u is in second quadrant - v[0] = 3.; - w = f.Forward(0, v); - ok &= NearEqual(w[0] , v[0], eps99, eps99); - - // check case where u is in third quadrant - v[0] = -3.; - w = f.Forward(0, v); - ok &= NearEqual(w[0] , v[0], eps99, eps99); - - // check case where u is in fourth quadrant - v[0] = -1.; - w = f.Forward(0, v); - ok &= NearEqual(w[0] , v[0], eps99, eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - double value = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - value = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - value = 1.; - for(j = 0; j < p; j++) - { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - value = 0.; - } + using CppAD::atan; + using CppAD::sin; + using CppAD::cos; + using namespace CppAD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(1); + U[0] = 1.; + Independent(U); + + // a temporary values + AD x = cos(U[0]); + AD y = sin(U[0]); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Z(1); + Z[0] = atan2(y, x); + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check original value (u in first quadrant) + ok &= NearEqual(U[0] , Z[0], eps99, eps99); + + // check case where u is in second quadrant + v[0] = 3.; + w = f.Forward(0, v); + ok &= NearEqual(w[0] , v[0], eps99, eps99); + + // check case where u is in third quadrant + v[0] = -3.; + w = f.Forward(0, v); + ok &= NearEqual(w[0] , v[0], eps99, eps99); + + // check case where u is in fourth quadrant + v[0] = -1.; + w = f.Forward(0, v); + ok &= NearEqual(w[0] , v[0], eps99, eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + double value = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + value = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + value = 1.; + for(j = 0; j < p; j++) + { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + jfac *= double(j + 1); + value = 0.; + } - return ok; + return ok; } } // end empty namespace bool atan2(void) -{ bool ok = true; - ok &= ad_ad(); - ok &= general(); +{ bool ok = true; + ok &= ad_ad(); + ok &= general(); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/atan.cpp cppad-2019.02.00.0/test_more/general/atan.cpp --- cppad-2018.00.00.0/test_more/general/atan.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/atan.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* @@ -19,127 +20,127 @@ namespace { // BEGIN empty namespace bool AtanTestOne(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::atan; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(1); - size_t s = 0; - U[s] = 1.; - Independent(U); - - // some temporary values - AD x = cos(U[s]); - AD y = sin(U[s]); - AD z = y / x; // tan(s) - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(1); - size_t a = 0; - - // dependent variable values - Z[a] = atan(z); // atan( tan(s) ) - - // create f: U -> Z and vectors used for dierivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // check value - ok &= NearEqual(U[s] , Z[a], eps99 , eps99); - - // forward computation of partials w.r.t. s - v[s] = 1.; - w = f.Forward(1, v); - ok &= NearEqual(w[a], 1e0, eps99 , eps99); // da/ds - - // reverse computation of first order partial of a - w[a] = 1.; - v = f.Reverse(1, w); - ok &= NearEqual(v[s], 1e0, eps99 , eps99); // da/ds - - // forward computation of second partials w.r.t. s and s - v[s] = 1.; - f.Forward(1, v); - v[s] = 0.; - w = f.Forward(2, v); - ok &= NearEqual(2. * w[a], 0e0, eps99 , eps99); // d^2 a / (ds ds) - - // reverse computation of second partials of a - CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); - w[a] = 1.; - r = f.Reverse(2, w); - ok &= NearEqual(r[2 * s + 1] ,0e0, eps99 , eps99 ); // d^2 a / (ds ds) + using CppAD::atan; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(1); + size_t s = 0; + U[s] = 1.; + Independent(U); + + // some temporary values + AD x = cos(U[s]); + AD y = sin(U[s]); + AD z = y / x; // tan(s) + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(1); + size_t a = 0; + + // dependent variable values + Z[a] = atan(z); // atan( tan(s) ) + + // create f: U -> Z and vectors used for dierivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // check value + ok &= NearEqual(U[s] , Z[a], eps99 , eps99); + + // forward computation of partials w.r.t. s + v[s] = 1.; + w = f.Forward(1, v); + ok &= NearEqual(w[a], 1e0, eps99 , eps99); // da/ds + + // reverse computation of first order partial of a + w[a] = 1.; + v = f.Reverse(1, w); + ok &= NearEqual(v[s], 1e0, eps99 , eps99); // da/ds + + // forward computation of second partials w.r.t. s and s + v[s] = 1.; + f.Forward(1, v); + v[s] = 0.; + w = f.Forward(2, v); + ok &= NearEqual(2. * w[a], 0e0, eps99 , eps99); // d^2 a / (ds ds) + + // reverse computation of second partials of a + CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); + w[a] = 1.; + r = f.Reverse(2, w); + ok &= NearEqual(r[2 * s + 1] ,0e0, eps99 , eps99 ); // d^2 a / (ds ds) - return ok; + return ok; } bool AtanTestTwo(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::atan; - using CppAD::sin; - using CppAD::cos; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(1); - U[0] = 1.; - Independent(U); - - // a temporary values - AD x = sin(U[0]) / cos(U[0]); - - // 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); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(U[0] , Z[0], eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - double value = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99);// d^jz/du^j - v[0] = 0.; - value = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - value = 1.; - for(j = 0; j < p; j++) - { ok &= NearEqual(r[j], value/jfac, eps99, eps99);// d^jz/du^j - jfac *= double(j + 1); - value = 0.; - } + using CppAD::atan; + using CppAD::sin; + using CppAD::cos; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(1); + U[0] = 1.; + Independent(U); + + // a temporary values + AD x = sin(U[0]) / cos(U[0]); + + // 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); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(U[0] , Z[0], eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + double value = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99);// d^jz/du^j + v[0] = 0.; + value = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + value = 1.; + for(j = 0; j < p; j++) + { ok &= NearEqual(r[j], value/jfac, eps99, eps99);// d^jz/du^j + jfac *= double(j + 1); + value = 0.; + } - return ok; + return ok; } } // END empty namespace bool atan(void) -{ bool ok = true; - ok &= AtanTestOne(); - ok &= AtanTestTwo(); - return ok; +{ bool ok = true; + ok &= AtanTestOne(); + ok &= AtanTestTwo(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/atanh.cpp cppad-2019.02.00.0/test_more/general/atanh.cpp --- cppad-2018.00.00.0/test_more/general/atanh.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/atanh.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,72 +1,73 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include bool atanh(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; + using CppAD::AD; + using CppAD::NearEqual; - // 10 times machine epsilon - double eps = 10. * std::numeric_limits::epsilon(); + // 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); + // 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/atomic_sparsity.cpp cppad-2019.02.00.0/test_more/general/atomic_sparsity.cpp --- cppad-2018.00.00.0/test_more/general/atomic_sparsity.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/atomic_sparsity.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,391 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ -/* -Atomic function -g( x ) = [ x_2, x_0 * x_1 ] -\] $$ -*/ -# include -namespace { // isolate items below to this file -using CppAD::vector; // vector -typedef vector< std::set > set_vector; // atomic_sparsity -// -// a utility to compute the union of two sets. -using CppAD::set_union; -// -class atomic_set_sparsity : public CppAD::atomic_base { -public: - // constructor - atomic_set_sparsity(const std::string& name) : - // this exampel only uses set sparsity patterns - CppAD::atomic_base(name, set_sparsity_enum ) - { } -private: - // 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); -# ifndef NDEBUG - size_t m = ty.size() / (q + 1); -# endif - 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 - virtual bool for_sparse_jac( - size_t p , - const set_vector& r , - set_vector& s , - const vector& x ) - { // This function needed if using f.ForSparseJac -# ifndef NDEBUG - size_t n = r.size(); - size_t m = s.size(); -# endif - assert( n == x.size() ); - assert( n == 3 ); - assert( m == 2 ); - - // sparsity for S(x) = f'(x) * R = [ 0, 0, 1 ] * R - s[0] = r[2]; - // s[1] = union(r[0], r[1]) - s[1] = set_union(r[0], r[1]); - // - return true; - } - virtual bool rev_sparse_jac( - size_t p , - const set_vector& rt , - set_vector& st , - const vector& x ) - { // This function needed if using RevSparseJac or optimize -# ifndef NDEBUG - size_t n = st.size(); - size_t m = rt.size(); -# endif - assert( n == x.size() ); - assert( n == 3 ); - assert( m == 2 ); - - // [ 0, x1 ] - // sparsity for S(x)^T = f'(x)^T * R^T = [ 0, x0 ] * R^T - // [ 1, 0 ] - st[0] = rt[1]; - st[1] = rt[1]; - st[2] = rt[0]; - return true; - } - virtual bool for_sparse_hes( - const vector& vx, - const vector& r , - const vector& s , - set_vector& h , - const vector& x ) - { - size_t n = r.size(); -# ifndef NDEBUG - size_t m = s.size(); -# endif - assert( x.size() == n ); - assert( h.size() == n ); - assert( n == 3 ); - assert( m == 2 ); - - // initialize h as empty - for(size_t i = 0; i < n; i++) - h[i].clear(); - - // only f_1 has a non-zero hessian - if( ! s[1] ) - return true; - - // only the cross term between x[0] and x[1] is non-zero - if( ! ( r[0] & r[1] ) ) - return true; - - // set the possibly non-zero terms in the hessian - h[0].insert(1); - h[1].insert(0); - - return true; - } - virtual bool rev_sparse_hes( - const vector& vx, - const vector& s , - vector& t , - size_t p , - const set_vector& r , - const set_vector& u , - set_vector& v , - const vector& x ) - { // This function needed if using RevSparseHes -# ifndef NDEBUG - size_t m = s.size(); - size_t n = t.size(); -# endif - assert( x.size() == n ); - assert( r.size() == n ); - assert( u.size() == m ); - assert( v.size() == n ); - 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 W(x) = f'(x)^T * U(x) = [ 0, x0 ] * U(x) - // [ 1, 0 ] - v[0] = u[1]; - v[1] = u[1]; - v[2] = u[0]; - // - // [ 0, 1, 0 ] - // sparsity for V(x) = W(x) + S_1 (x) * [ 1, 0, 0 ] * R - // [ 0, 0, 0 ] - if( s[1] ) - { // v[0] = union( v[0], r[1] ) - v[0] = set_union(v[0], r[1]); - // v[1] = union( v[1], r[0] ) - v[1] = set_union(v[1], r[0]); - } - return true; - } -}; // End of atomic_set_sparsity class - - -// f(u) = g( u_0 + u_1 , u_0 + u_1 , u_2 ) -// = [ u_2 , (u_0 + u_1)^2 ] -bool test_one(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * std::numeric_limits::epsilon(); - // Create the atomic get_started object - atomic_set_sparsity afun("atomic_set_sparsity"); - size_t n = 3; - size_t m = 2; - vector< AD > au(n), ay(m); - for(size_t j = 0; j < n; j++) - au[j] = double(j + 1); - - // declare independent variables and start tape recording - CppAD::Independent(au); - - // ax - vector< AD > ax(n); - ax[0] = au[0] + au[1]; - ax[1] = au[0] + au[1]; - ax[2] = au[2]; - - // call user function - afun(ax, ay); - - // create f: u -> y and stop tape recording - CppAD::ADFun f(au, ay); - - // check function value - ok &= NearEqual(ay[0] , au[2], eps, eps); - ok &= NearEqual(ay[1] , (au[0] + au[1]) * (au[0] + au[1]), eps, eps); - - // correct Jacobian result - set_vector check_s(m); - check_s[0].insert(2); - check_s[1].insert(0); - check_s[1].insert(1); - // compute and test forward mode - { set_vector r(n), s(m); - for(size_t i = 0; i < n; i++) - r[i].insert(i); - s = f.ForSparseJac(n, r); - for(size_t i = 0; i < m; i++) - ok &= s[i] == check_s[i]; - } - // compute and test reverse mode - { set_vector r(m), s(m); - for(size_t i = 0; i < m; i++) - r[i].insert(i); - s = f.RevSparseJac(m, r); - for(size_t i = 0; i < m; i++) - ok &= s[i] == check_s[i]; - } - // correct Hessian result for w_0 * f_0 (u) + w_1 * f_1(u) - set_vector check_h(n); - check_h[0].insert(0); - check_h[0].insert(1); - check_h[1].insert(0); - check_h[1].insert(1); - // compute and test forward mode - { set_vector r(1), s(1), h(n); - for(size_t i = 0; i < m; i++) - s[0].insert(i); - for(size_t j = 0; j < n; j++) - r[0].insert(j); - h = f.ForSparseHes(r, s); - for(size_t i = 0; i < n; i++) - ok &= h[i] == check_h[i]; - } - // compute and test reverse mode - { set_vector s(1), h(n); - for(size_t i = 0; i < m; i++) - s[0].insert(i); - h = f.RevSparseHes(n, s); - for(size_t i = 0; i < n; i++) - ok &= h[i] == check_h[i]; - } - return ok; -} - -// f(u) = g( u_0 + u_1 , u_1 + u_2 , u_2 + u_0 ) -// = [ u_2 + u_0 , (u_0 + u_1)*(u_1 + u_2) ] -bool test_two(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * std::numeric_limits::epsilon(); - // Create the atomic get_started object - atomic_set_sparsity afun("atomic_set_sparsity"); - size_t n = 3; - size_t m = 2; - vector< AD > au(n), ay(m); - for(size_t j = 0; j < n; j++) - au[j] = double(j + 1); - - // declare independent variables and start tape recording - CppAD::Independent(au); - - // ax - vector< AD > ax(n); - ax[0] = au[0] + au[1]; - ax[1] = au[1] + au[2]; - ax[2] = au[2] + au[0]; - - // call user function - afun(ax, ay); - - // create f: u -> y and stop tape recording - CppAD::ADFun f(au, ay); - - // check function value - ok &= NearEqual(ay[0] , au[2] + au[0], eps, eps); - ok &= NearEqual(ay[1] , (au[0] + au[1]) * (au[1] + au[2]), eps, eps); - - // correct Jacobian result - set_vector check_s(m); - check_s[0].insert(2); - check_s[0].insert(0); - check_s[1].insert(0); - check_s[1].insert(1); - check_s[1].insert(2); - // compute and test forward mode - { set_vector r(n), s(m); - for(size_t i = 0; i < n; i++) - r[i].insert(i); - s = f.ForSparseJac(n, r); - for(size_t i = 0; i < m; i++) - ok &= s[i] == check_s[i]; - } - // compute and test reverse mode - { set_vector r(m), s(m); - for(size_t i = 0; i < m; i++) - r[i].insert(i); - s = f.RevSparseJac(m, r); - for(size_t i = 0; i < m; i++) - ok &= s[i] == check_s[i]; - } - // ---------------------------------------------------------------------- - // correct Hessian result for f_0 (u) - set_vector check_h(n), s(1); - s[0].insert(0); - // compute and test forward mode - { set_vector r(1), h(n); - for(size_t j = 0; j < n; j++) - r[0].insert(j); - h = f.ForSparseHes(r, s); - for(size_t i = 0; i < n; i++) - ok &= h[i] == check_h[i]; - } - // compute and test reverse mode - { set_vector h(n); - h = f.RevSparseHes(n, s); - for(size_t i = 0; i < n; i++) - ok &= h[i] == check_h[i]; - } - // ---------------------------------------------------------------------- - // correct Hessian result for f_1 (u) - s[0].clear(); - s[0].insert(1); - check_h[0].insert(1); - check_h[0].insert(2); - check_h[1].insert(0); - check_h[1].insert(1); - check_h[1].insert(2); - check_h[2].insert(0); - check_h[2].insert(1); - // compute and test forward mode - { set_vector r(1), h(n); - for(size_t j = 0; j < n; j++) - r[0].insert(j); - h = f.ForSparseHes(r, s); - for(size_t i = 0; i < n; i++) - ok &= h[i] == check_h[i]; - } - // compute and test reverse mode - { set_vector h(n); - h = f.RevSparseHes(n, s); - for(size_t i = 0; i < n; i++) - ok &= h[i] == check_h[i]; - } - return ok; -} - -} // End empty namespace - -bool atomic_sparsity(void) -{ bool ok = true; - ok &= test_one(); - ok &= test_two(); - return ok; -} diff -Nru cppad-2018.00.00.0/test_more/general/atomic_three.cpp cppad-2019.02.00.0/test_more/general/atomic_three.cpp --- cppad-2018.00.00.0/test_more/general/atomic_three.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/atomic_three.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,403 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +g_0 (x) = x_0 * x_0 +g_1 (x) = x_0 * x_1 +g_2 (x) = x_1 * x_2 +g_3 (x) = x_2 * x_2 + +*/ +# include // CppAD include file +namespace { // start empty namespace +using CppAD::vector; // abbreviate CppAD::vector using vector + +// --------------------------------------------------------------------------- +// start definition of atomic derived class using atomic_three interface +class atomic_optimize : public CppAD::atomic_three { +public: + // can use const char* name when calling this constructor + atomic_optimize(const std::string& name) : // can have more arguments + CppAD::atomic_three(name) // inform base class of name + { } + +private: + // calculate type_y + virtual bool for_type( + const vector& parameter_x , + const vector& type_x , + vector& type_y ) + { assert( parameter_x.size() == type_x.size() ); + bool ok = type_x.size() == 3; // n + ok &= type_y.size() == 4; // m + if( ! ok ) + return false; + type_y[0] = type_x[0]; + type_y[1] = std::max( type_x[0], type_x[1] ); + type_y[2] = std::max( type_x[1], type_x[2] ); + type_y[3] = type_x[2]; + return true; + } + // calculate depend_x + virtual bool rev_depend( + const vector& parameter_x , + const vector& type_x , + vector& depend_x , + const vector& depend_y ) + { assert( parameter_x.size() == depend_x.size() ); + bool ok = depend_x.size() == 3; // n + ok &= depend_y.size() == 4; // m + if( ! ok ) + return false; + depend_x[0] = depend_y[0] | depend_y[1]; + depend_x[1] = depend_y[1] | depend_y[2]; + depend_x[2] = depend_y[2] | depend_y[3]; + return true; + } + virtual bool forward( + const vector& parameter_x , + const vector& type_x , + size_t need_y , + size_t order_low , + size_t order_up , + const vector& taylor_x , + vector& taylor_y + ) + { +# ifndef NDEBUG + size_t n = taylor_x.size() / (order_up + 1); + size_t m = taylor_y.size() / (order_up + 1); +# endif + assert( n == 3 ); + assert( m == 4 ); + assert( order_low <= order_up ); + + // return flag + bool ok = order_up == 0; + if( ! ok ) + return ok; + + // g_0 = x_0 * x_0 + taylor_y[0] = taylor_x[0] * taylor_x[0]; + // g_1 = x_0 * x_1 + taylor_y[1] = taylor_x[0] * taylor_x[1]; + // g_2 = x_1 * x_2 + taylor_y[2] = taylor_x[1] * taylor_x[2]; + // g_3 = x_2 * x_2 + taylor_y[3] = taylor_x[2] * taylor_x[2]; + + return ok; + } +}; // End of atomic_optimize class + +// --------------------------------------------------------------------------- +bool optimize_dynamic_one(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + atomic_optimize afun("atomic_optimize"); + // + // constant parameter + double c_0 = 2.0; + // + // indepndent dynamic parameter vector + size_t np = 1; + CPPAD_TESTVECTOR(double) p(np); + CPPAD_TESTVECTOR( AD ) ap(np); + ap[0] = p[0] = 3.0; + // + // independent variable vector + size_t nu = 1; + double u_0 = 0.5; + CPPAD_TESTVECTOR( AD ) au(nu); + au[0] = u_0; + + // declare independent variables and start tape recording + size_t abort_op_index = 0; + bool record_compare = true; + CppAD::Independent(au, abort_op_index, record_compare, ap); + + // create a dynamic parameter that is not used + AD ar = 2.0 * ap[0]; + + // call atomic function and store result in ay + CPPAD_TESTVECTOR( AD ) ax(3), av(4); + ax[0] = c_0; // x_0 = c + ax[1] = ap[0]; // x_1 = p + ax[2] = au[0]; // x_2 = u + afun(ax, av); + + // check type of result + ok &= Constant( av[0] ); // v_0 = c * c + ok &= Dynamic( av[1] ); // v_1 = c * p + ok &= Variable( av[2] ); // v_2 = p * u + ok &= Variable( av[3] ); // v_3 = u * u + + // range space vector + size_t ny = 3; + CPPAD_TESTVECTOR( AD ) ay(ny); + for(size_t i = 0; i < ny; ++i) + ay[i] = av[i]; + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // f(u) = (c * c, c * p, p * u) + + // sequence properties + ok &= f.size_dyn_ind() == 1; // p + ok &= f.size_dyn_par() == 3; // p, r, c * p + // Three constant parameters, phantom at index 0, c, c * c + ok &= f.size_par() == 6; + // Normal variables: u, p * u, u * u + // Extra variables: phanton at index 0, y[0], y[1] + ok &= f.size_var() == 6; + + // optimize + f.optimize(); + + // sequence properties + ok &= f.size_dyn_ind() == 1; // p + ok &= f.size_dyn_par() == 2; // c * p + // Three constant parameters, phantom at index 0, c, c * c + ok &= f.size_par() == 5; + // Normal variables: u, p * u + // Extra variables: phanton at index 0, y[0], y[1] + ok &= f.size_var() == 5; + + // check + double check; + + // check zero order forward mode + size_t q; + CPPAD_TESTVECTOR( double ) u_q(nu), y_q(ny); + q = 0; + u_q[0] = u_0; + y_q = f.Forward(q, u_q); + check = c_0 * c_0; + ok &= NearEqual(y_q[0] , check, eps, eps); + check = c_0 * p[0]; + ok &= NearEqual(y_q[1] , check, eps, eps); + check = p[0] * u_0; + ok &= NearEqual(y_q[2] , check, eps, eps); + + // set new value for dynamic parameters + p[0] = 2.0 * p[0]; + f.new_dynamic(p); + y_q = f.Forward(q, u_q); + check = c_0 * c_0; + ok &= NearEqual(y_q[0] , check, eps, eps); + check = c_0 * p[0]; + ok &= NearEqual(y_q[1] , check, eps, eps); + check = p[0] * u_0; + ok &= NearEqual(y_q[2] , check, eps, eps); + + return ok; +} +// --------------------------------------------------------------------------- +bool optimize_dynamic_two(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + atomic_optimize afun("atomic_optimize"); + // + // indepndent dynamic parameter vector + size_t np = 1; + CPPAD_TESTVECTOR(double) p(np); + CPPAD_TESTVECTOR( AD ) ap(np); + ap[0] = p[0] = 3.0; + // + // independent variable vector + size_t nu = 1; + double u_0 = 0.5; + CPPAD_TESTVECTOR( AD ) au(nu); + au[0] = u_0; + + // declare independent variables and start tape recording + size_t abort_op_index = 0; + bool record_compare = true; + CppAD::Independent(au, abort_op_index, record_compare, ap); + + // create a dynamic parameter that is used by atomic function + // but not needed to compute f(u) + AD ar = 2.0 * ap[0]; + + // call atomic function and store result in ay + CPPAD_TESTVECTOR( AD ) ax(3), av(4); + ax[0] = au[0]; // x_0 = u + ax[1] = ap[0]; // x_1 = p + ax[2] = ar; // x_2 = r + afun(ax, av); + + // check type of result + ok &= Variable( av[0] ); // v_0 = u * u , used + ok &= Variable( av[1] ); // v_1 = u * p , used + ok &= Dynamic( av[2] ); // v_2 = r * p , not used + ok &= Dynamic( av[3] ); // v_3 = r * r , not used + + // range space vector + size_t ny = 2; + CPPAD_TESTVECTOR( AD ) ay(ny); + for(size_t i = 0; i < ny; ++i) + ay[i] = av[i]; + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // f(u) = (u * u, u * p) + + // sequence properties + ok &= f.size_dyn_ind() == 1; // p + ok &= f.size_dyn_par() == 4; // p, r, r * p, r * r + // Two constant parameters, phantom at index 0, 2.0 in computation of r + ok &= f.size_par() == 6; + + + // optimize + f.optimize(); + + // sequence properties + ok &= f.size_dyn_ind() == 1; // p + ok &= f.size_dyn_par() == 1; // p + // One constant parameter, phantom at index 0 + ok &= f.size_par() == 2; + + // check + double check; + + // check zero order forward mode + size_t q; + CPPAD_TESTVECTOR( double ) u_q(nu), y_q(ny); + q = 0; + u_q[0] = u_0; + y_q = f.Forward(q, u_q); + check = u_0 * u_0; + ok &= NearEqual(y_q[0] , check, eps, eps); + check = u_0 * p[0]; + ok &= NearEqual(y_q[1] , check, eps, eps); + + // set new value for dynamic parameters + p[0] = 2.0 * p[0]; + f.new_dynamic(p); + y_q = f.Forward(q, u_q); + check = u_0 * u_0; + ok &= NearEqual(y_q[0] , check, eps, eps); + check = u_0 * p[0]; + ok &= NearEqual(y_q[1] , check, eps, eps); + + return ok; +} +// --------------------------------------------------------------------------- +bool optimize_dynamic_three(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * CppAD::numeric_limits::epsilon(); + atomic_optimize afun("atomic_optimize"); + // + // indepndent dynamic parameter vector + size_t np = 1; + CPPAD_TESTVECTOR(double) p(np); + CPPAD_TESTVECTOR( AD ) ap(np); + ap[0] = p[0] = 3.0; + // + // independent variable vector + size_t nu = 1; + double u_0 = 0.5; + CPPAD_TESTVECTOR( AD ) au(nu); + au[0] = u_0; + + // declare independent variables and start tape recording + size_t abort_op_index = 0; + bool record_compare = true; + CppAD::Independent(au, abort_op_index, record_compare, ap); + + // create a dynamic parameter that is used by atomic function + // but not needed to compute f(u) + AD ar = 2.0 * ap[0]; + + // call atomic function and store result in ay + CPPAD_TESTVECTOR( AD ) ax(3), av(4); + ax[0] = au[0]; // x_0 = u + ax[1] = ar; // x_1 = r + ax[2] = ap[0]; // x_2 = p + afun(ax, av); + + // check type of result + ok &= Variable( av[0] ); // v_0 = u * u , used + ok &= Variable( av[1] ); // v_1 = u * r , used + ok &= Dynamic( av[2] ); // v_2 = r * p , not used + ok &= Dynamic( av[3] ); // v_3 = p * p , not used + + // range space vector + size_t ny = 2; + CPPAD_TESTVECTOR( AD ) ay(ny); + for(size_t i = 0; i < ny; ++i) + ay[i] = av[i]; + + // create f: u -> y and stop tape recording + CppAD::ADFun f; + f.Dependent (au, ay); // f(u) = (u * u, u * p) + + // sequence properties + ok &= f.size_dyn_ind() == 1; // p + ok &= f.size_dyn_par() == 4; // p, r, r * p, p * p + // Two constant parameters, phantom at index 0, 2.0 in computation of r + ok &= f.size_par() == 6; + + + // optimize + f.optimize(); + + // sequence properties + ok &= f.size_dyn_ind() == 1; // p + ok &= f.size_dyn_par() == 2; // p, r + // Two constant parameters, phantom at index 0, 2.0 in computation of r + ok &= f.size_par() == 4; + + // check + double check; + + // check zero order forward mode + double r = 2.0 * p[0]; + size_t q; + CPPAD_TESTVECTOR( double ) u_q(nu), y_q(ny); + q = 0; + u_q[0] = u_0; + y_q = f.Forward(q, u_q); + check = u_0 * u_0; + ok &= NearEqual(y_q[0] , check, eps, eps); + check = u_0 * r; + ok &= NearEqual(y_q[1] , check, eps, eps); + + // set new value for dynamic parameters + p[0] = 2.0 * p[0]; + r = 2.0 * p[0]; + f.new_dynamic(p); + y_q = f.Forward(q, u_q); + check = u_0 * u_0; + ok &= NearEqual(y_q[0] , check, eps, eps); + check = u_0 * r; + ok &= NearEqual(y_q[1] , check, eps, eps); + + return ok; +} +// --------------------------------------------------------------------------- +} // End empty namespace + +bool atomic_three(void) +{ bool ok = true; + ok &= optimize_dynamic_one(); + ok &= optimize_dynamic_two(); + ok &= optimize_dynamic_three(); + return ok; +} diff -Nru cppad-2018.00.00.0/test_more/general/azmul.cpp cppad-2019.02.00.0/test_more/general/azmul.cpp --- cppad-2018.00.00.0/test_more/general/azmul.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/azmul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,266 +1,267 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include # include namespace { - bool test_forward(void) - { bool ok = true; + 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 + double(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; + 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 + double(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; - } + return ok; + } } bool azmul(void) -{ bool ok = true; +{ bool ok = true; - ok &= test_forward(); - ok &= test_reverse(); - ok &= test_forward_dir(); + ok &= test_forward(); + ok &= test_reverse(); + ok &= test_forward_dir(); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/base_adolc.cpp cppad-2019.02.00.0/test_more/general/base_adolc.cpp --- cppad-2018.00.00.0/test_more/general/base_adolc.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/base_adolc.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // adolc examples should supppress conversion warnings # include @@ -22,86 +23,86 @@ # include bool base_adolc(void) -{ bool ok = true; // initialize test result +{ bool ok = true; // initialize test result - typedef adouble ADdouble; // for first level of taping - typedef CppAD::AD ADDdouble; // for second level of taping - size_t n = 4; // number independent variables - - CPPAD_TESTVECTOR(ADdouble) a_x(n); - CPPAD_TESTVECTOR(ADDdouble) aa_x(n); - - // value of the independent variables - int tag = 0; // Adolc setup - int keep = 1; - trace_on(tag, keep); - size_t j; - for(j = 0; j < n; j++) - a_x[j] <<= double(n - j); // a_x is independent for ADdouble - 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; - CPPAD_TESTVECTOR(ADDdouble) aa_f(m); // dependent variables - - // different cases of conditional expressions - aa_f[0] = CondExpLt(aa_x[0], aa_x[1], aa_x[2], aa_x[3]); - aa_f[1] = CondExpLe(aa_x[0], aa_x[1], aa_x[2], aa_x[3]); - aa_f[2] = CondExpEq(aa_x[0], aa_x[1], aa_x[2], aa_x[3]); - aa_f[3] = CondExpGe(aa_x[0], aa_x[1], aa_x[2], aa_x[3]); - aa_f[4] = CondExpGt(aa_x[0], aa_x[1], aa_x[2], aa_x[3]); - - // declare inner function (just to stop inner taping) - CppAD::ADFun a_F(aa_x, aa_f); - - // set values for outer function same as inner function - // (corresponding to the tape of adobule operations) - double f_j; - for(j = 0; j < m; j++) - Value(aa_f[j]) >>= f_j; - trace_off(); - - // arrays for Adolc zos_forward - double *x = CPPAD_NULL, *y = CPPAD_NULL; - x = CPPAD_TRACK_NEW_VEC(n, x); - y = CPPAD_TRACK_NEW_VEC(m, y); - - // switch order of arguments from when taping was done - for(j = 0; j < n; j++) - x[j] = double(j); - zos_forward(tag, int(m), int(n), keep, x, y); - // CondExpLt(0, 1, 2, 3) - ok &= (y[0] == double(2)); - // CondExpLe(0, 1, 2, 3) - ok &= (y[1] == double(2)); - // CondExpEq(0, 1, 2, 3) - ok &= (y[2] == double(3)); - // CondExpGe(0, 1, 2, 3) - ok &= (y[3] == double(3)); - // CondExpGt(0, 1, 2, 3) - ok &= (y[4] == double(3)); - - // set left = right and true < false - x[0] = x[1] = 1.; - x[2] = 2.; - x[3] = 3.; - zos_forward(tag, int(m), int(n), keep, x, y); - // CondExpLt(1, 1, 2, 3) - ok &= (y[0] == double(3)); - // CondExpLe(1, 1, 2, 3) - ok &= (y[1] == double(2)); - // CondExpEq(1, 1, 2, 3) - ok &= (y[2] == double(2)); - // CondExpGe(1, 1, 2, 3) - ok &= (y[3] == double(2)); - // CondExpGt(1, 1, 2, 3) - ok &= (y[4] == double(3)); - - CPPAD_TRACK_DEL_VEC(x); - CPPAD_TRACK_DEL_VEC(y); - return ok; + typedef adouble ADdouble; // for first level of taping + typedef CppAD::AD ADDdouble; // for second level of taping + size_t n = 4; // number independent variables + + CPPAD_TESTVECTOR(ADdouble) a_x(n); + CPPAD_TESTVECTOR(ADDdouble) aa_x(n); + + // value of the independent variables + short tag = 0; // Adolc setup + int keep = 1; + trace_on(tag, keep); + size_t j; + for(j = 0; j < n; j++) + a_x[j] <<= double(n - j); // a_x is independent for ADdouble + 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; + CPPAD_TESTVECTOR(ADDdouble) aa_f(m); // dependent variables + + // different cases of conditional expressions + aa_f[0] = CondExpLt(aa_x[0], aa_x[1], aa_x[2], aa_x[3]); + aa_f[1] = CondExpLe(aa_x[0], aa_x[1], aa_x[2], aa_x[3]); + aa_f[2] = CondExpEq(aa_x[0], aa_x[1], aa_x[2], aa_x[3]); + aa_f[3] = CondExpGe(aa_x[0], aa_x[1], aa_x[2], aa_x[3]); + aa_f[4] = CondExpGt(aa_x[0], aa_x[1], aa_x[2], aa_x[3]); + + // declare inner function (just to stop inner taping) + CppAD::ADFun a_F(aa_x, aa_f); + + // set values for outer function same as inner function + // (corresponding to the tape of adobule operations) + double f_j; + for(j = 0; j < m; j++) + Value(aa_f[j]) >>= f_j; + trace_off(); + + // arrays for Adolc zos_forward + double *x = CPPAD_NULL, *y = CPPAD_NULL; + x = CPPAD_TRACK_NEW_VEC(n, x); + y = CPPAD_TRACK_NEW_VEC(m, y); + + // switch order of arguments from when taping was done + for(j = 0; j < n; j++) + x[j] = double(j); + zos_forward(tag, int(m), int(n), keep, x, y); + // CondExpLt(0, 1, 2, 3) + ok &= (y[0] == double(2)); + // CondExpLe(0, 1, 2, 3) + ok &= (y[1] == double(2)); + // CondExpEq(0, 1, 2, 3) + ok &= (y[2] == double(3)); + // CondExpGe(0, 1, 2, 3) + ok &= (y[3] == double(3)); + // CondExpGt(0, 1, 2, 3) + ok &= (y[4] == double(3)); + + // set left = right and true < false + x[0] = x[1] = 1.; + x[2] = 2.; + x[3] = 3.; + zos_forward(tag, int(m), int(n), keep, x, y); + // CondExpLt(1, 1, 2, 3) + ok &= (y[0] == double(3)); + // CondExpLe(1, 1, 2, 3) + ok &= (y[1] == double(2)); + // CondExpEq(1, 1, 2, 3) + ok &= (y[2] == double(2)); + // CondExpGe(1, 1, 2, 3) + ok &= (y[3] == double(2)); + // CondExpGt(1, 1, 2, 3) + ok &= (y[4] == double(3)); + + CPPAD_TRACK_DEL_VEC(x); + CPPAD_TRACK_DEL_VEC(y); + return ok; } // END PROGRAM diff -Nru cppad-2018.00.00.0/test_more/general/base_alloc.cpp cppad-2019.02.00.0/test_more/general/base_alloc.cpp --- cppad-2018.00.00.0/test_more/general/base_alloc.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/base_alloc.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,91 +1,92 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include "../../example/general/base_alloc.hpp" # include namespace { // BEGIN empty namespace bool test_parameter(void) -{ bool ok = true; - typedef CppAD::AD my_ad; +{ bool ok = true; + typedef CppAD::AD my_ad; - // y = x + 0 + 1 + 2 + ... + N-1 - CppAD::vector a_x, a_y; - a_x.resize(1); - a_x[0] = my_ad(1.); - CppAD::Independent(a_x); - a_y.resize(1); - a_y[0] = a_x[0]; - - // create a new parameter for each iteration of this loop - size_t i, N = 50; - for(i = 0; i < N; i++) - a_y[0] += double(i); + // y = x + 0 + 1 + 2 + ... + N-1 + CppAD::vector a_x, a_y; + a_x.resize(1); + a_x[0] = my_ad(1.); + CppAD::Independent(a_x); + a_y.resize(1); + a_y[0] = a_x[0]; + + // create a new parameter for each iteration of this loop + size_t i, N = 50; + for(i = 0; i < N; i++) + a_y[0] += double(i); - CppAD::ADFun f(a_x, a_y); + CppAD::ADFun f(a_x, a_y); - return ok; + return ok; } bool test_numeric_limits(void) -{ bool ok = true; - typedef CppAD::AD my_ad; - // - base_alloc eps = Value( CppAD::numeric_limits::epsilon() ); - ok &= *eps.ptrdbl_ == std::numeric_limits::epsilon(); - // - base_alloc min = Value( CppAD::numeric_limits::min() ); - ok &= *min.ptrdbl_ == std::numeric_limits::min(); - // - base_alloc max = Value( CppAD::numeric_limits::max() ); - ok &= *max.ptrdbl_ == std::numeric_limits::max(); - // - base_alloc nan = Value( CppAD::numeric_limits::quiet_NaN() ); - ok &= *nan.ptrdbl_ != *nan.ptrdbl_; - // - int digits10 = CppAD::numeric_limits::digits10; - ok &= digits10 == std::numeric_limits::digits10; - // - return ok; +{ bool ok = true; + typedef CppAD::AD my_ad; + // + base_alloc eps = Value( CppAD::numeric_limits::epsilon() ); + ok &= *eps.ptrdbl_ == std::numeric_limits::epsilon(); + // + base_alloc min = Value( CppAD::numeric_limits::min() ); + ok &= *min.ptrdbl_ == std::numeric_limits::min(); + // + base_alloc max = Value( CppAD::numeric_limits::max() ); + ok &= *max.ptrdbl_ == std::numeric_limits::max(); + // + base_alloc nan = Value( CppAD::numeric_limits::quiet_NaN() ); + ok &= *nan.ptrdbl_ != *nan.ptrdbl_; + // + int digits10 = CppAD::numeric_limits::digits10; + ok &= digits10 == std::numeric_limits::digits10; + // + return ok; } bool test_to_string(void) -{ bool ok = true; - typedef CppAD::AD my_ad; - // - double dbl_pi = 4.0 * std::atan(1.0); - my_ad ad_pi = my_ad(dbl_pi); - std::string str_pi = to_string( ad_pi ); - // - // Check the length of the string "3.1415...". One extra character - // for machine epsilon precision and another for the decimal point. - ok &= str_pi.size() == size_t( 2 + std::numeric_limits::digits10 ); - // - // check value - double eps = std::numeric_limits::epsilon(); - double check = std::atof( str_pi.c_str() ); - ok &= (check / dbl_pi - 1.0) <= eps; - // - return ok; +{ bool ok = true; + typedef CppAD::AD my_ad; + // + double dbl_pi = 4.0 * std::atan(1.0); + my_ad ad_pi = my_ad(dbl_pi); + std::string str_pi = to_string( ad_pi ); + // + // Check the length of the string "3.1415...". One extra character + // for machine epsilon precision and another for the decimal point. + ok &= str_pi.size() == size_t( 2 + std::numeric_limits::digits10 ); + // + // check value + double eps = std::numeric_limits::epsilon(); + double check = std::atof( str_pi.c_str() ); + ok &= (check / dbl_pi - 1.0) <= eps; + // + return ok; } } // END empty namespace bool base_alloc_test(void) -{ bool ok = true; - // - ok &= test_parameter(); - ok &= test_numeric_limits(); - ok &= test_to_string(); - // - return ok; +{ bool ok = true; + // + ok &= test_parameter(); + ok &= test_numeric_limits(); + ok &= test_to_string(); + // + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/bool_sparsity.cpp cppad-2019.02.00.0/test_more/general/bool_sparsity.cpp --- cppad-2018.00.00.0/test_more/general/bool_sparsity.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/bool_sparsity.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old example / test @begin bool_sparsity.cpp$$ $spell - Bool + Bool $$ $section Using vectorBool Sparsity To Conserve Memory: Example and Test$$ @@ -21,175 +22,173 @@ $head Purpose$$ This example show how to conserve memory when computing sparsity patterns. -$code $srcfile%test_more/general/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; - } + 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; +{ 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-2018.00.00.0/test_more/general/checkpoint.cpp cppad-2019.02.00.0/test_more/general/checkpoint.cpp --- cppad-2018.00.00.0/test_more/general/checkpoint.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/checkpoint.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,193 +0,0 @@ -/* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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 - -namespace { - using CppAD::AD; - typedef CPPAD_TESTVECTOR(AD) ADVector; - - bool f_algo(const ADVector& x, ADVector& y) - { size_t m = y.size(); - assert( size_t(x.size()) == m + 1); - for(size_t i = 0; i < m; i++) - y[i] = x[i] * x[i+1]; - return true; - } - bool g_algo(const ADVector& y, ADVector& z) - { size_t m = z.size(); - assert( size_t(y.size()) + 1 == m ); - z[0] = 0.0; - for(size_t i = 1; i < m; i++) - { z[0] += y[i-1]; - z[i] = y[i-1]; - } - return true; - } - - 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 / double(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)); - for(i = 0; i < m; i++) - { for(k = 0; k <= p; k++) - w[ i * (p+1) + k ] = 2.0 / double(p + 1 - k ); - } - 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); - } - } - 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; - } - 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-2018.00.00.0/test_more/general/check_simple_vector.cpp cppad-2019.02.00.0/test_more/general/check_simple_vector.cpp --- cppad-2018.00.00.0/test_more/general/check_simple_vector.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/check_simple_vector.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include # include @@ -15,26 +16,26 @@ # include namespace { - template - void Case(const Scalar& x, const Scalar& y) - { using CppAD::CheckSimpleVector; + template + void Case(const Scalar& x, const Scalar& y) + { using CppAD::CheckSimpleVector; - CheckSimpleVector > (x, y); - CheckSimpleVector > (x, y); - CheckSimpleVector > (x, y); - typedef CPPAD_TESTVECTOR(Scalar) testvector; - CheckSimpleVector (x, y); - } + CheckSimpleVector > (x, y); + CheckSimpleVector > (x, y); + CheckSimpleVector > (x, y); + typedef CPPAD_TESTVECTOR(Scalar) testvector; + CheckSimpleVector (x, y); + } } bool check_simple_vector(void) -{ // Unusal test in that CheckSimpleVector will abort if an error occurs - Case(float(0), float(1)); - Case(double(0), double(1)); - // - std::set x, y; - x.insert(1); - y.insert(2); - Case(x, y); - // - return true; +{ // Unusal test in that CheckSimpleVector will abort if an error occurs + Case(float(0), float(1)); + Case(double(0), double(1)); + // + std::set x, y; + x.insert(1); + y.insert(2); + Case(x, y); + // + return true; } diff -Nru cppad-2018.00.00.0/test_more/general/chkpoint_one.cpp cppad-2019.02.00.0/test_more/general/chkpoint_one.cpp --- cppad-2018.00.00.0/test_more/general/chkpoint_one.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/chkpoint_one.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,220 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include + +namespace { + using CppAD::AD; + typedef CPPAD_TESTVECTOR(AD) ADVector; + + // ------------------------------------------------------------------------ + bool f_algo(const ADVector& x, ADVector& y) + { size_t m = y.size(); + assert( size_t(x.size()) == m + 1); + for(size_t i = 0; i < m; i++) + y[i] = x[i] * x[i+1]; + return true; + } + bool g_algo(const ADVector& y, ADVector& z) + { size_t m = z.size(); + assert( size_t(y.size()) + 1 == m ); + z[0] = 0.0; + for(size_t i = 1; i < m; i++) + { z[0] += y[i-1]; + z[i] = y[i-1]; + } + return true; + } + 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 / double(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)); + for(i = 0; i < m; i++) + { for(k = 0; k <= p; k++) + w[ i * (p+1) + k ] = 2.0 / double(p + 1 - k ); + } + 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); + } + } + 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; + } + 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); + // + // -------------------------------------------------------------------- + // sparsity pattern + // -------------------------------------------------------------------- + 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; + } + // -------------------------------------------------------------------- + // base2ad + // -------------------------------------------------------------------- + ADFun< AD , double > ah; + ah = h.base2ad(); + // + // forward mode + ADVector au(n), av(m); + for(size_t j = 0; j < n; j++) + ax[j] = au[j] = double(j + 1); + av = ah.Forward(0, au); + h_algo(ax, ay); + for(size_t i = 0; i < m; ++i) + ok &= av[i] == ay[i]; + // + // reverse mode + ADVector adw(n), aw(m); + for(size_t i = 0; i < m; ++i) + aw[i] = 1.0; + adw = ah.Reverse(1, aw); + ok &= Value( adw[0] ) == 1.0; + ok &= Value( adw[1] ) == 1.0; + ok &= Value( adw[2] ) == 1.0; + // + return ok; + } +} + +bool chkpoint_one(void) +{ bool ok = true; + ok &= test_one(); + ok &= test_two(); + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/general/chkpoint_two.cpp cppad-2019.02.00.0/test_more/general/chkpoint_two.cpp --- cppad-2018.00.00.0/test_more/general/chkpoint_two.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/chkpoint_two.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,338 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include + +namespace { + using CppAD::AD; + using CppAD::vector; + using CppAD::chkpoint_two; + // ----------------------------------------------------------------------- + template + chkpoint_two checkpoint_two( + std::string name , + Algo& algo , + vector< AD >& ax , + vector< AD >& ay ) + { CppAD::Independent(ax); + algo(ax, ay); + CppAD::ADFun g_fun(ax, ay); + bool internal_bool = false; + bool use_hes_sparsity = true; + bool use_base2ad = true; + bool use_in_parallel = false; + return chkpoint_two(g_fun, name, + internal_bool, use_hes_sparsity, use_base2ad, use_in_parallel + ); + } + // ---------------------------------------------------------------- + // 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( + const CppAD::vector< CppAD::AD >& ax , + CppAD::vector< CppAD::AD >& ay ) + { ay[0] = CondExpGt(ax[0], ax[1], ax[2], ax[3]); } + + bool test_one(void) + { bool ok = true; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // 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); + chkpoint_two j_check = + checkpoint_two("j_check", j_algo, au, av); + + // 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++) + 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 + f.optimize(); + + // 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 &= NearEqual(y[0], x[0] + double(3) * x[1], eps10, eps10); + + + // 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 &= NearEqual(y[0], x[0] + double(4) * x[1], eps10, eps10); + + return ok; + } + // ------------------------------------------------------------------- + // Test conditional optimizing out call to an atomic function call + void k_algo( + const CppAD::vector< CppAD::AD >& x , + CppAD::vector< CppAD::AD >& y ) + { y[0] = x[0] + x[1]; } + + void h_algo( + const CppAD::vector< CppAD::AD >& x , + CppAD::vector< CppAD::AD >& y ) + { y[0] = x[0] - x[1]; } + + bool test_two(void) + { bool ok = true; + typedef vector< AD > ADVector; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // Create a checkpoint version of the function g + ADVector ax(2), ag(1), ah(1), ay(1); + ax[0] = 0.; + ax[1] = 1.; + chkpoint_two k_check = + checkpoint_two("k_check", k_algo, ax, ag); + chkpoint_two h_check = + checkpoint_two("h_check", h_algo, ax, ah); + + // independent variable vector + Independent(ax); + + // atomic function calls that get conditionally used + k_check(ax, ag); + h_check(ax, ah); + + // conditional expression + 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); + x[0] = 3.; + x[1] = 4.; + y = f.Forward(0, x); + ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); + + // before optimize + ok &= f.number_skip() == 0; + + // now optimize the operation sequence + f.optimize(); + + // optimized zero order forward when condition is false + x[0] = 4.; + x[1] = 3.; + y = f.Forward(0, x); + ok &= NearEqual(y[0], x[0] - x[1], eps10, eps10); + + // after optimize can skip either call to g or call to h + ok &= f.number_skip() == 1; + + // optimized first order forward + dx[0] = 2.; + dx[1] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], dx[0] - dx[1], eps10, eps10); + + // optimized first order reverse + w[0] = 1.; + dx = f.Reverse(1, w); + ok &= NearEqual(dx[0], 1., eps10, eps10); + ok &= NearEqual(dx[1], -1., eps10, eps10); + + return ok; + } + // ------------------------------------------------------------------- + // Test of optimizing out arguments to an atomic function + void g_algo( + const CppAD::vector< CppAD::AD >& ax , + CppAD::vector< CppAD::AD >& ay ) + { ay = ax; } + + bool test_three(void) + { bool ok = true; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // Create a checkpoint version of the function g + vector< AD > ax(2), ay(2), az(1); + ax[0] = 0.; + ax[1] = 1.; + chkpoint_two g_check = + checkpoint_two("g_check", g_algo, ax, ay); + + // 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]); + + // 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 + f.optimize(); + + // 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 &= NearEqual(z[0], x[0] - x[1], eps10, eps10); + + return ok; + } + bool test_four(void) + { bool ok = true; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + vector< AD > au(2), aw(2), ax(2), ay(1); + + // create atomic function corresponding to g_algo + au[0] = 1.0; + au[1] = 2.0; + chkpoint_two g_check = + checkpoint_two("g_algo", g_algo, au, ax); + + // start recording a new function + CppAD::Independent(ax); + + // now use g_check during the recording + au[0] = ax[0] + ax[1]; // this argument requires a new variable + 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 + ay[0] = aw[0]; + CppAD::ADFun f(ax, ay); + + // number of variables before optimization + // ax[0], ax[1], ax[0] + ax[1], ax[0] - ax[1], g[0], g[1] + // and phantom variable at index 0 + size_t n_before = f.size_var(); + ok &= n_before == 7; + + // now optimize f so that the calculation of au[1] is removed + f.optimize(); + + // number of varialbes after optimization + // ax[0], ax[1], ax[0] + ax[1], g[0] + // and phantom variable at index 0 + size_t n_after = f.size_var(); + ok &= n_after == 5; + + // now compute and check a forward mode calculation + vector x(2), y(1); + x[0] = 5.0; + x[1] = 6.0; + y = f.Forward(0, x); + ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); + + return ok; + } + // ----------------------------------------------------------------------- + void i_algo( + const CppAD::vector< CppAD::AD >& ax , + CppAD::vector< CppAD::AD >& ay ) + { ay[0] = 1.0 / ax[0]; } + // + // Test bug where atomic functions were not properly conditionally skipped. + bool test_five(bool conditional_skip) + { bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + using CppAD::vector; + + // Create a checkpoint version of the function i_algo + vector< AD > au(1), av(1), aw(1); + au[0] = 1.0; + chkpoint_two i_check = + checkpoint_two("i_check", i_algo, au, av); + + // 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); + au[0] = ax[1]; + i_check(au, aw); + AD zero = 0.0; + ay[0] = CondExpGt(av[0], zero, av[0], aw[0]); + + // create function object f : ax -> ay + CppAD::ADFun f(ax, ay); + + // run case that skips the second call to afun + // (can use trace in forward0sweep.hpp to see this). + vector x(2), y_before(1), y_after(1); + x[0] = 1.0; + x[1] = 2.0; + y_before = f.Forward(0, x); + if( conditional_skip ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + y_after = f.Forward(0, x); + + ok &= NearEqual(y_before[0], y_after[0], eps10, eps10); + + return ok; + } + +} +bool chkpoint_two(void) +{ bool ok = true; + // + ok &= test_one(); + ok &= test_two(); + ok &= test_three(); + ok &= test_four(); + // + ok &= test_five(true); + ok &= test_five(false); + // + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/general/CMakeLists.txt cppad-2019.02.00.0/test_more/general/CMakeLists.txt --- cppad-2018.00.00.0/test_more/general/CMakeLists.txt 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/CMakeLists.txt 2019-01-31 12:35:17.000000000 +0000 @@ -1,141 +1,146 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # Build the test_more/general tests # # adolc_sources, adolc_libs IF( cppad_has_adolc ) - SET(adolc_sources base_adolc.cpp) - SET(adolc_libs adolc) + SET(adolc_sources base_adolc.cpp) + SET(adolc_libs adolc) ELSE( cppad_has_adolc ) - SET(adolc_sources "") - SET(adolc_libs "") + SET(adolc_sources "") + SET(adolc_libs "") ENDIF( cppad_has_adolc ) # # eigen_sources IF( cppad_has_eigen ) - SET(eigen_sources cppad_eigen.cpp eigen_mat_inv.cpp) + SET(eigen_sources cppad_eigen.cpp eigen_mat_inv.cpp) ELSE( cppad_has_eigen ) - SET(eigen_sources "") + SET(eigen_sources "") ENDIF( cppad_has_eigen ) # # ipopt_prefix IF( cppad_has_ipopt ) - SET(ipopt_sources ipopt_solve.cpp) - SET(ipopt_libs "${ipopt_LIBRARIES}") + SET(ipopt_sources ipopt_solve.cpp) + SET(ipopt_libs "${ipopt_LIBRARIES}") ELSE( cppad_has_ipopt ) - SET(ipopt_sources "") - SET(ipopt_libs "") + SET(ipopt_sources "") + SET(ipopt_libs "") ENDIF( cppad_has_ipopt ) # +# BEGIN_SORT_THIS_LINE_PLUS_6 SET(source_list - ${adolc_sources} - ${eigen_sources} - ${ipopt_sources} - general.cpp - fabs.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 - atomic_sparsity.cpp - azmul.cpp - base_alloc.cpp - bool_sparsity.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 - dependency.cpp - div.cpp - div_eq.cpp - div_zero_one.cpp - erf.cpp - exp.cpp - expm1.cpp - extern_value.cpp - for_hess.cpp - for_sparse_hes.cpp - for_sparse_jac.cpp - forward.cpp - forward_dir.cpp - forward_order.cpp - from_base.cpp - fun_check.cpp - hes_sparsity.cpp - jacobian.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 - 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_jac.cpp - rev_two.cpp - simple_vector.cpp - sin.cpp - sin_cos.cpp - sinh.cpp - sparse_hessian.cpp - sparse_jacobian.cpp - sparse_sub_hes.cpp - sparse_vec_ad.cpp - sqrt.cpp - std_math.cpp - sub.cpp - sub_eq.cpp - sub_zero.cpp - subgraph.cpp - tan.cpp - test_vector.cpp - to_string.cpp - value.cpp - vec_ad.cpp - vec_ad_par.cpp - vec_unary.cpp - - local/vector_set.cpp + ${adolc_sources} + ${eigen_sources} + ${ipopt_sources} + general.cpp + acos.cpp + acosh.cpp + add.cpp + add_eq.cpp + add_zero.cpp + adfun_copy.cpp + asin.cpp + asinh.cpp + assign.cpp + atan2.cpp + atan.cpp + atanh.cpp + atomic_three.cpp + azmul.cpp + base_alloc.cpp + bool_sparsity.cpp + chkpoint_one.cpp + chkpoint_two.cpp + check_simple_vector.cpp + compare_change.cpp + compare.cpp + cond_exp_ad.cpp + cond_exp.cpp + cond_exp_rev.cpp + copy.cpp + cos.cpp + cosh.cpp + dbl_epsilon.cpp + dependency.cpp + div.cpp + div_eq.cpp + div_zero_one.cpp + erf.cpp + exp.cpp + expm1.cpp + extern_value.cpp + fabs.cpp + for_hess.cpp + for_sparse_hes.cpp + for_sparse_jac.cpp + forward.cpp + forward_dir.cpp + forward_order.cpp + from_base.cpp + fun_check.cpp + hes_sparsity.cpp + jacobian.cpp + local/vector_set.cpp + log10.cpp + log1p.cpp + log.cpp + mul_cond_rev.cpp + mul.cpp + mul_cskip.cpp + mul_eq.cpp + mul_level.cpp + mul_zdouble.cpp + mul_zero_one.cpp + near_equal_ext.cpp + neg.cpp + new_dynamic.cpp + num_limits.cpp + ode_err_control.cpp + optimize.cpp + parameter.cpp + poly.cpp + pow.cpp + pow_int.cpp + print_for.cpp + reverse.cpp + rev_sparse_jac.cpp + rev_two.cpp + romberg_one.cpp + rosen_34.cpp + runge_45.cpp + simple_vector.cpp + sin_cos.cpp + sin.cpp + sinh.cpp + sparse_hessian.cpp + sparse_jacobian.cpp + sparse_jac_work.cpp + sparse_sub_hes.cpp + sparse_vec_ad.cpp + sqrt.cpp + std_math.cpp + sub.cpp + sub_eq.cpp + subgraph.cpp + sub_zero.cpp + tan.cpp + test_vector.cpp + to_string.cpp + value.cpp + vec_ad.cpp + vec_ad_par.cpp + vec_unary.cpp ) +# END_SORT_THIS_LINE_MINUS_2 set_compile_flags( test_more_general "${cppad_debug_which}" "${source_list}" ) # ADD_EXECUTABLE(test_more_general EXCLUDE_FROM_ALL ${source_list}) @@ -143,22 +148,22 @@ # must first build cppad_lib STRING(COMPARE EQUAL "${cppad_lib}" "" empty_cppad_lib ) IF( NOT empty_cppad_lib ) - ADD_DEPENDENCIES(test_more_general ${cppad_lib} ) + ADD_DEPENDENCIES(test_more_general ${cppad_lib} ) ENDIF( NOT empty_cppad_lib ) # # List of libraries to be linked into the specified target TARGET_LINK_LIBRARIES(test_more_general - ${cppad_lib} - ${adolc_libs} - ${ipopt_libs} - ${colpack_libs} + ${cppad_lib} + ${adolc_libs} + ${ipopt_libs} + ${colpack_libs} ) # # Add the check_test_more_general target ADD_CUSTOM_TARGET(check_test_more_general - test_more_general - DEPENDS - test_more_general + test_more_general + DEPENDS + test_more_general ) MESSAGE(STATUS "make check_test_more_general: available") # diff -Nru cppad-2018.00.00.0/test_more/general/compare_change.cpp cppad-2019.02.00.0/test_more/general/compare_change.cpp --- cppad-2018.00.00.0/test_more/general/compare_change.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/compare_change.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old CompareChange examples and tests, now just used for validation testing @@ -16,355 +17,391 @@ # include 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); + // ---------------------------------------------------------------------- + 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); - return ok; - } + return ok; + } } bool compare_change(void) -{ bool ok = true; - ok &= CompareChange_one(); - ok &= CompareChange_two(); - return ok; +{ bool ok = true; + ok &= CompareChange_one(); + ok &= CompareChange_two(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/compare.cpp cppad-2019.02.00.0/test_more/general/compare.cpp --- cppad-2018.00.00.0/test_more/general/compare.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/compare.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Check comparison operators between AD< AD > and Base, int @@ -15,59 +16,59 @@ # include 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 ); - - // AD >= Type - 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 ); - - // AD <= Type - ok &= (three <= middle); - ok &= (four <= middle); - ok &= ! (five <= middle); - // Type > AD - ok &= ! (middle <= three ); - ok &= (middle <= four ); - ok &= (middle <= five ); + 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 ); + + // AD >= Type + 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 ); + + // AD <= Type + ok &= (three <= middle); + ok &= (four <= middle); + ok &= ! (five <= middle); + // Type > AD + ok &= ! (middle <= three ); + ok &= (middle <= four ); + ok &= (middle <= five ); - return ok; - } + return ok; + } } bool Compare(void) -{ bool ok = true; - ok &= Compare(); - ok &= Compare(); - ok &= Compare< CppAD::AD >(); - return ok; +{ bool ok = true; + ok &= Compare(); + ok &= Compare(); + ok &= Compare< CppAD::AD >(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/cond_exp_ad.cpp cppad-2019.02.00.0/test_more/general/cond_exp_ad.cpp --- cppad-2018.00.00.0/test_more/general/cond_exp_ad.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/cond_exp_ad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test of CondExp with AD< AD< Base > > types @@ -21,309 +22,315 @@ namespace { // BEGIN empty namespace bool CondExpADOne(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; - size_t n = 3; - size_t m = 8; - - // ADdouble independent variable vector - CPPAD_TESTVECTOR( ADdouble ) Xa(n); - Xa[0] = -1.; - Xa[1] = 0.; - Xa[2] = 1.; - Independent(Xa); - - // ADdouble independent variable vector - CPPAD_TESTVECTOR( ADADdouble ) Xaa(n); - Xaa[0] = Xa[0]; - Xaa[1] = Xa[1]; - Xaa[2] = Xa[2]; - Independent(Xaa); - - // ADADdouble parameter - ADADdouble p = ADADdouble(Xa[0]); - ADADdouble q = ADADdouble(Xa[1]); - ADADdouble r = ADADdouble(Xa[2]); - - // ADADdouble dependent variable vector - CPPAD_TESTVECTOR( ADADdouble ) Yaa(m); - - // CondExp(parameter, parameter, parameter) - Yaa[0] = CondExp(p, q, r); - - // CondExp(parameter, parameter, variable) - Yaa[1] = CondExp(p, q, Xaa[2]); - - // CondExp(parameter, varaible, parameter) - Yaa[2] = CondExp(p, Xaa[1], r); - - // CondExp(parameter, variable, variable) - Yaa[3] = CondExp(p, Xaa[1], Xaa[2]); - - // CondExp(variable, variable, variable) - Yaa[5] = CondExp(Xaa[0], Xaa[1], Xaa[2]); - - // CondExp(variable, variable, parameter) - Yaa[4] = CondExp(Xaa[0], Xaa[1], r); - - // CondExp(variable, parameter, variable) - Yaa[6] = CondExp(Xaa[0], q, Xaa[2]); - - // CondExp(variable, parameter, parameter) - Yaa[7] = CondExp(Xaa[0], q, r); - - // create fa: Xaa -> Yaa function object - ADFun< ADdouble > fa(Xaa, Yaa); - - // function values - CPPAD_TESTVECTOR( ADdouble ) Ya(m); - Ya = fa.Forward(0, Xa); - - // create f: Xa -> Ya function object - ADFun f(Xa, Ya); - - // check result of function evaluation - CPPAD_TESTVECTOR(double) x(n); - CPPAD_TESTVECTOR(double) y(m); - x[0] = 1.; - x[1] = 0.; - x[2] = -1.; - y = f.Forward(0, x); - size_t i; - for(i = 0; i < m; i++) - { // y[i] = CondExp(x[0], x[1], x[2]) - if( x[0] > 0 ) - ok &= (y[i] == x[1]); - else ok &= (y[i] == x[2]); - } - - // check forward mode derivatives - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - dx[0] = 1.; - dx[1] = 2.; - dx[2] = 3.; - dy = f.Forward(1, dx); - for(i = 0; i < m; i++) - { if( x[0] > 0. ) - ok &= (dy[i] == dx[1]); - else ok &= (dy[i] == dx[2]); - } - - // calculate Jacobian - CPPAD_TESTVECTOR(double) J(m * n); - size_t j; - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - J[i * n + j] = 0.; - if( x[0] > 0. ) - J[i * n + 1] = 1.; - else J[i * n + 2] = 1.; - } - - // check reverse mode derivatives - for(i = 0; i < m; i++) - dy[i] = double(i); - dx = f.Reverse(1, dy); - double sum; - for(j = 0; j < n; j++) - { sum = 0; - for(i = 0; i < m; i++) - sum += dy[i] * J[i * n + j]; - ok &= (sum == dx[j]); - } - - // forward mode computation of sparsity pattern - CPPAD_TESTVECTOR(bool) Px(n * n); - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - Px[i * n + j] = false; - Px[i * n + i] = true; - } - CPPAD_TESTVECTOR(bool) Py(m * n); - Py = f.ForSparseJac(n, Px); - for(i = 0; i < m; i++) - { ok &= Py[ i * n + 0 ] == false; - ok &= Py[ i * n + 1 ] == true; - ok &= Py[ i * n + 2 ] == true; - } - - // reverse mode computation of sparsity pattern - Py.resize(m * m); - for(i = 0; i < m; i++) - { for(j = 0; j < m; j++) - Py[i * m + j] = false; - Py[i * m + i] = true; - } - Px.resize(m * n); - Px = f.RevSparseJac(m, Py); - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - ok &= ( Px[i * n + j] == ( j > 0 ) ); - } + using namespace CppAD; + size_t n = 3; + size_t m = 8; + + // ADdouble independent variable vector + CPPAD_TESTVECTOR( ADdouble ) Xa(n); + Xa[0] = -1.; + Xa[1] = 0.; + Xa[2] = 1.; + Independent(Xa); + + // ADdouble independent variable vector + CPPAD_TESTVECTOR( ADADdouble ) Xaa(n); + Xaa[0] = Xa[0]; + Xaa[1] = Xa[1]; + Xaa[2] = Xa[2]; + Independent(Xaa); + + // ADADdouble parameter + ADADdouble p = ADADdouble(Xa[0]); + ADADdouble q = ADADdouble(Xa[1]); + ADADdouble r = ADADdouble(Xa[2]); + + // ADADdouble dependent variable vector + CPPAD_TESTVECTOR( ADADdouble ) Yaa(m); + + // CondExp(parameter, parameter, parameter) + Yaa[0] = CondExp(p, q, r); + + // CondExp(parameter, parameter, variable) + Yaa[1] = CondExp(p, q, Xaa[2]); + + // CondExp(parameter, varaible, parameter) + Yaa[2] = CondExp(p, Xaa[1], r); + + // CondExp(parameter, variable, variable) + Yaa[3] = CondExp(p, Xaa[1], Xaa[2]); + + // CondExp(variable, variable, variable) + Yaa[5] = CondExp(Xaa[0], Xaa[1], Xaa[2]); + + // CondExp(variable, variable, parameter) + Yaa[4] = CondExp(Xaa[0], Xaa[1], r); + + // CondExp(variable, parameter, variable) + Yaa[6] = CondExp(Xaa[0], q, Xaa[2]); + + // CondExp(variable, parameter, parameter) + Yaa[7] = CondExp(Xaa[0], q, r); + + // create fa: Xaa -> Yaa function object + ADFun< ADdouble > fa(Xaa, Yaa); + + // function values + CPPAD_TESTVECTOR( ADdouble ) Ya(m); + Ya = fa.Forward(0, Xa); + + // create f: Xa -> Ya function object + ADFun f(Xa, Ya); + + // check result of function evaluation + CPPAD_TESTVECTOR(double) x(n); + CPPAD_TESTVECTOR(double) y(m); + x[0] = 1.; + x[1] = 0.; + x[2] = -1.; + y = f.Forward(0, x); + size_t i; + for(i = 0; i < m; i++) + { // y[i] = CondExp(x[0], x[1], x[2]) + if( x[0] > 0 ) + ok &= (y[i] == x[1]); + else + ok &= (y[i] == x[2]); + } + + // check forward mode derivatives + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dx[1] = 2.; + dx[2] = 3.; + dy = f.Forward(1, dx); + for(i = 0; i < m; i++) + { if( x[0] > 0. ) + ok &= (dy[i] == dx[1]); + else + ok &= (dy[i] == dx[2]); + } + + // calculate Jacobian + CPPAD_TESTVECTOR(double) J(m * n); + size_t j; + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + J[i * n + j] = 0.; + if( x[0] > 0. ) + J[i * n + 1] = 1.; + else + J[i * n + 2] = 1.; + } + + // check reverse mode derivatives + for(i = 0; i < m; i++) + dy[i] = double(i); + dx = f.Reverse(1, dy); + double sum; + for(j = 0; j < n; j++) + { sum = 0; + for(i = 0; i < m; i++) + sum += dy[i] * J[i * n + j]; + ok &= (sum == dx[j]); + } + + // forward mode computation of sparsity pattern + CPPAD_TESTVECTOR(bool) Px(n * n); + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + Px[i * n + j] = false; + Px[i * n + i] = true; + } + CPPAD_TESTVECTOR(bool) Py(m * n); + Py = f.ForSparseJac(n, Px); + for(i = 0; i < m; i++) + { ok &= Py[ i * n + 0 ] == false; + ok &= Py[ i * n + 1 ] == true; + ok &= Py[ i * n + 2 ] == true; + } + + // reverse mode computation of sparsity pattern + Py.resize(m * m); + for(i = 0; i < m; i++) + { for(j = 0; j < m; j++) + Py[i * m + j] = false; + Py[i * m + i] = true; + } + Px.resize(m * n); + Px = f.RevSparseJac(m, Py); + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + ok &= ( Px[i * n + j] == ( j > 0 ) ); + } - return ok; + return ok; } bool CondExpADTwo(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; - size_t n = 3; - size_t m = 8; - - // ADdouble independent variable vector - CPPAD_TESTVECTOR( ADdouble ) Xa(n); - Xa[0] = -1.; - Xa[1] = 0.; - Xa[2] = 1.; - Independent(Xa); - - // use VecAD so that sparsity results are local - VecAD Va(1); - ADdouble zero = 0.; - Va[zero] = Xa[0]; - - // ADdouble independent variable vector - CPPAD_TESTVECTOR( ADADdouble ) Xaa(n); - Xaa[0] = ADdouble( Va[zero] ); - Xaa[1] = Xa[1]; - Xaa[2] = Xa[2]; - Independent(Xaa); - - // ADADdouble parameter - ADADdouble p = ADADdouble(Xa[0]); - ADADdouble q = ADADdouble(Xa[1]); - ADADdouble r = ADADdouble(Xa[2]); - - // ADADdouble dependent variable vector - CPPAD_TESTVECTOR( ADADdouble ) Yaa(m); - - // CondExp(parameter, parameter, parameter) - Yaa[0] = CondExp(p, q, r); - - // CondExp(parameter, parameter, variable) - Yaa[1] = CondExp(p, q, Xaa[2]); - - // CondExp(parameter, varaible, parameter) - Yaa[2] = CondExp(p, Xaa[1], r); - - // CondExp(parameter, variable, variable) - Yaa[3] = CondExp(p, Xaa[1], Xaa[2]); - - // CondExp(variable, variable, variable) - Yaa[5] = CondExp(Xaa[0], Xaa[1], Xaa[2]); - - // CondExp(variable, variable, parameter) - Yaa[4] = CondExp(Xaa[0], Xaa[1], r); - - // CondExp(variable, parameter, variable) - Yaa[6] = CondExp(Xaa[0], q, Xaa[2]); - - // CondExp(variable, parameter, parameter) - Yaa[7] = CondExp(Xaa[0], q, r); - - // create fa: Xaa -> Yaa function object - ADFun< ADdouble > fa(Xaa, Yaa); - - // function values - CPPAD_TESTVECTOR( ADdouble ) Ya(m); - Ya = fa.Forward(0, Xa); - - // create f: Xa -> Ya function object - ADFun f(Xa, Ya); - - // check use_VecAD - ok &= f.use_VecAD(); - - // check result of function evaluation - CPPAD_TESTVECTOR(double) x(n); - CPPAD_TESTVECTOR(double) y(m); - x[0] = 1.; - x[1] = 0.; - x[2] = -1.; - y = f.Forward(0, x); - size_t i; - for(i = 0; i < m; i++) - { // y[i] = CondExp(x[0], x[1], x[2]) - if( x[0] > 0 ) - ok &= (y[i] == x[1]); - else ok &= (y[i] == x[2]); - } - - // check forward mode derivatives - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - dx[0] = 1.; - dx[1] = 2.; - dx[2] = 3.; - dy = f.Forward(1, dx); - for(i = 0; i < m; i++) - { if( x[0] > 0. ) - ok &= (dy[i] == dx[1]); - else ok &= (dy[i] == dx[2]); - } - - // calculate Jacobian - CPPAD_TESTVECTOR(double) J(m * n); - size_t j; - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - J[i * n + j] = 0.; - if( x[0] > 0. ) - J[i * n + 1] = 1.; - else J[i * n + 2] = 1.; - } - - // check reverse mode derivatives - for(i = 0; i < m; i++) - dy[i] = double(i); - dx = f.Reverse(1, dy); - double sum; - for(j = 0; j < n; j++) - { sum = 0; - for(i = 0; i < m; i++) - sum += dy[i] * J[i * n + j]; - ok &= (sum == dx[j]); - } - - // forward mode computation of sparsity pattern - CPPAD_TESTVECTOR(bool) Px(n * n); - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - Px[i * n + j] = false; - Px[i * n + i] = true; - } - CPPAD_TESTVECTOR(bool) Py(m * n); - Py = f.ForSparseJac(n, Px); - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - // sparsity pattern works for both true and false cases. - ok &= ( Py[i * n + j] == (j > 0) ); - } - - // reverse mode computation of sparsity pattern - Py.resize(m * m); - for(i = 0; i < m; i++) - { for(j = 0; j < m; j++) - Py[i * m + j] = false; - Py[i * m + i] = true; - } - Px.resize(m * n); - Px = f.RevSparseJac(m, Py); - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - ok &= ( Px[i * n + j] == (j > 0) ); - } + using namespace CppAD; + size_t n = 3; + size_t m = 8; + + // ADdouble independent variable vector + CPPAD_TESTVECTOR( ADdouble ) Xa(n); + Xa[0] = -1.; + Xa[1] = 0.; + Xa[2] = 1.; + Independent(Xa); + + // use VecAD so that sparsity results are local + VecAD Va(1); + ADdouble zero = 0.; + Va[zero] = Xa[0]; + + // ADdouble independent variable vector + CPPAD_TESTVECTOR( ADADdouble ) Xaa(n); + Xaa[0] = ADdouble( Va[zero] ); + Xaa[1] = Xa[1]; + Xaa[2] = Xa[2]; + Independent(Xaa); + + // ADADdouble parameter + ADADdouble p = ADADdouble(Xa[0]); + ADADdouble q = ADADdouble(Xa[1]); + ADADdouble r = ADADdouble(Xa[2]); + + // ADADdouble dependent variable vector + CPPAD_TESTVECTOR( ADADdouble ) Yaa(m); + + // CondExp(parameter, parameter, parameter) + Yaa[0] = CondExp(p, q, r); + + // CondExp(parameter, parameter, variable) + Yaa[1] = CondExp(p, q, Xaa[2]); + + // CondExp(parameter, varaible, parameter) + Yaa[2] = CondExp(p, Xaa[1], r); + + // CondExp(parameter, variable, variable) + Yaa[3] = CondExp(p, Xaa[1], Xaa[2]); + + // CondExp(variable, variable, variable) + Yaa[5] = CondExp(Xaa[0], Xaa[1], Xaa[2]); + + // CondExp(variable, variable, parameter) + Yaa[4] = CondExp(Xaa[0], Xaa[1], r); + + // CondExp(variable, parameter, variable) + Yaa[6] = CondExp(Xaa[0], q, Xaa[2]); + + // CondExp(variable, parameter, parameter) + Yaa[7] = CondExp(Xaa[0], q, r); + + // create fa: Xaa -> Yaa function object + ADFun< ADdouble > fa(Xaa, Yaa); + + // function values + CPPAD_TESTVECTOR( ADdouble ) Ya(m); + Ya = fa.Forward(0, Xa); + + // create f: Xa -> Ya function object + ADFun f(Xa, Ya); + + // check use_VecAD + ok &= f.use_VecAD(); + + // check result of function evaluation + CPPAD_TESTVECTOR(double) x(n); + CPPAD_TESTVECTOR(double) y(m); + x[0] = 1.; + x[1] = 0.; + x[2] = -1.; + y = f.Forward(0, x); + size_t i; + for(i = 0; i < m; i++) + { // y[i] = CondExp(x[0], x[1], x[2]) + if( x[0] > 0 ) + ok &= (y[i] == x[1]); + else + ok &= (y[i] == x[2]); + } + + // check forward mode derivatives + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dx[1] = 2.; + dx[2] = 3.; + dy = f.Forward(1, dx); + for(i = 0; i < m; i++) + { if( x[0] > 0. ) + ok &= (dy[i] == dx[1]); + else + ok &= (dy[i] == dx[2]); + } + + // calculate Jacobian + CPPAD_TESTVECTOR(double) J(m * n); + size_t j; + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + J[i * n + j] = 0.; + if( x[0] > 0. ) + J[i * n + 1] = 1.; + else + J[i * n + 2] = 1.; + } + + // check reverse mode derivatives + for(i = 0; i < m; i++) + dy[i] = double(i); + dx = f.Reverse(1, dy); + double sum; + for(j = 0; j < n; j++) + { sum = 0; + for(i = 0; i < m; i++) + sum += dy[i] * J[i * n + j]; + ok &= (sum == dx[j]); + } + + // forward mode computation of sparsity pattern + CPPAD_TESTVECTOR(bool) Px(n * n); + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + Px[i * n + j] = false; + Px[i * n + i] = true; + } + CPPAD_TESTVECTOR(bool) Py(m * n); + Py = f.ForSparseJac(n, Px); + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + // sparsity pattern works for both true and false cases. + ok &= ( Py[i * n + j] == (j > 0) ); + } + + // reverse mode computation of sparsity pattern + Py.resize(m * m); + for(i = 0; i < m; i++) + { for(j = 0; j < m; j++) + Py[i * m + j] = false; + Py[i * m + i] = true; + } + Px.resize(m * n); + Px = f.RevSparseJac(m, Py); + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + ok &= ( Px[i * n + j] == (j > 0) ); + } - return ok; + return ok; } } // END empty namespace bool CondExpAD(void) -{ bool ok = true; - ok &= CondExpADOne(); - ok &= CondExpADTwo(); - return ok; +{ bool ok = true; + ok &= CondExpADOne(); + ok &= CondExpADTwo(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/cond_exp.cpp cppad-2019.02.00.0/test_more/general/cond_exp.cpp --- cppad-2018.00.00.0/test_more/general/cond_exp.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/cond_exp.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Comprehensive test built on 08/07 for new user interface to CondExp @@ -19,501 +20,502 @@ namespace { // Begin empty namespace bool CondExp_pvvv(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(3); - X[0] = 0.; - X[1] = 1.; - X[2] = 2.; - Independent(X); - - // parameter value - AD one = 1.; - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(5); - - // CondExp(parameter, variable, variable, variable) - Y[0] = CondExpLt(one, X[0], X[1], X[2]); - Y[1] = CondExpLe(one, X[0], X[1], X[2]); - Y[2] = CondExpEq(one, X[0], X[1], X[2]); - Y[3] = CondExpGe(one, X[0], X[1], X[2]); - Y[4] = CondExpGt(one, X[0], X[1], X[2]); - - // create f: X -> Y - ADFun f(X, Y); - - // vectors for function values - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // vectors for derivative values - CPPAD_TESTVECTOR(double) dv( f.Domain() ); - CPPAD_TESTVECTOR(double) dw( f.Range() ); - - // check original function values - ok &= Y[0] == X[2]; - ok &= Y[1] == X[2]; - ok &= Y[2] == X[2]; - ok &= Y[3] == X[1]; - ok &= Y[4] == X[1]; - - // function values - v[0] = 2.; - v[1] = 1.; - v[2] = 0.; - w = f.Forward(0, v); - ok &= ( w[0] == v[1] ); - ok &= ( w[1] == v[1] ); - ok &= ( w[2] == v[2] ); - ok &= ( w[3] == v[2] ); - ok &= ( w[4] == v[2] ); - - // forward mode derivative values - dv[0] = 1.; - dv[1] = 2.; - dv[2] = 3.; - dw = f.Forward(1, dv); - ok &= (dw[0] == dv[1] ); - ok &= (dw[1] == dv[1] ); - ok &= (dw[2] == dv[2] ); - ok &= (dw[3] == dv[2] ); - ok &= (dw[4] == dv[2] ); - - // reverse mode derivative values - dw[0] = 1.; - dw[1] = 2.; - dw[2] = 3.; - dw[3] = 4.; - dw[4] = 5.; - dv = f.Reverse(1, dw); - ok &= (dv[0] == 0.); - ok &= (dv[1] == dw[0] + dw[1] ); - ok &= (dv[2] == dw[2] + dw[3] + dw[4] ); + // independent variable vector + CPPAD_TESTVECTOR(AD) X(3); + X[0] = 0.; + X[1] = 1.; + X[2] = 2.; + Independent(X); + + // parameter value + AD one = 1.; + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(5); + + // CondExp(parameter, variable, variable, variable) + Y[0] = CondExpLt(one, X[0], X[1], X[2]); + Y[1] = CondExpLe(one, X[0], X[1], X[2]); + Y[2] = CondExpEq(one, X[0], X[1], X[2]); + Y[3] = CondExpGe(one, X[0], X[1], X[2]); + Y[4] = CondExpGt(one, X[0], X[1], X[2]); + + // create f: X -> Y + ADFun f(X, Y); + + // vectors for function values + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // vectors for derivative values + CPPAD_TESTVECTOR(double) dv( f.Domain() ); + CPPAD_TESTVECTOR(double) dw( f.Range() ); + + // check original function values + ok &= Y[0] == X[2]; + ok &= Y[1] == X[2]; + ok &= Y[2] == X[2]; + ok &= Y[3] == X[1]; + ok &= Y[4] == X[1]; + + // function values + v[0] = 2.; + v[1] = 1.; + v[2] = 0.; + w = f.Forward(0, v); + ok &= ( w[0] == v[1] ); + ok &= ( w[1] == v[1] ); + ok &= ( w[2] == v[2] ); + ok &= ( w[3] == v[2] ); + ok &= ( w[4] == v[2] ); + + // forward mode derivative values + dv[0] = 1.; + dv[1] = 2.; + dv[2] = 3.; + dw = f.Forward(1, dv); + ok &= (dw[0] == dv[1] ); + ok &= (dw[1] == dv[1] ); + ok &= (dw[2] == dv[2] ); + ok &= (dw[3] == dv[2] ); + ok &= (dw[4] == dv[2] ); + + // reverse mode derivative values + dw[0] = 1.; + dw[1] = 2.; + dw[2] = 3.; + dw[3] = 4.; + dw[4] = 5.; + dv = f.Reverse(1, dw); + ok &= (dv[0] == 0.); + ok &= (dv[1] == dw[0] + dw[1] ); + ok &= (dv[2] == dw[2] + dw[3] + dw[4] ); - return ok; + return ok; } bool CondExp_vpvv(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(3); - X[0] = 0.; - X[1] = 1.; - X[2] = 2.; - Independent(X); - - // parameter value - AD one = 1.; - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(5); - - // CondExp(variable, parameter, variable, variable) - Y[0] = CondExpLt(X[0], one, X[1], X[2]); - Y[1] = CondExpLe(X[0], one, X[1], X[2]); - Y[2] = CondExpEq(X[0], one, X[1], X[2]); - Y[3] = CondExpGe(X[0], one, X[1], X[2]); - Y[4] = CondExpGt(X[0], one, X[1], X[2]); - - // create f: X -> Y - ADFun f(X, Y); - - // vectors for function values - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // vectors for derivative values - CPPAD_TESTVECTOR(double) dv( f.Domain() ); - CPPAD_TESTVECTOR(double) dw( f.Range() ); - - // check original function values - ok &= Y[0] == X[1]; - ok &= Y[1] == X[1]; - ok &= Y[2] == X[2]; - ok &= Y[3] == X[2]; - ok &= Y[4] == X[2]; - - // function values - v[0] = 2.; - v[1] = 1.; - v[2] = 0.; - w = f.Forward(0, v); - ok &= ( w[0] == v[2] ); - ok &= ( w[1] == v[2] ); - ok &= ( w[2] == v[2] ); - ok &= ( w[3] == v[1] ); - ok &= ( w[4] == v[1] ); - - // forward mode derivative values - dv[0] = 1.; - dv[1] = 2.; - dv[2] = 3.; - dw = f.Forward(1, dv); - ok &= (dw[0] == dv[2] ); - ok &= (dw[1] == dv[2] ); - ok &= (dw[2] == dv[2] ); - ok &= (dw[3] == dv[1] ); - ok &= (dw[4] == dv[1] ); - - // reverse mode derivative values - dw[0] = 1.; - dw[1] = 2.; - dw[2] = 3.; - dw[3] = 4.; - dw[4] = 5.; - dv = f.Reverse(1, dw); - ok &= (dv[0] == 0.); - ok &= (dv[1] == dw[3] + dw[4] ); - ok &= (dv[2] == dw[0] + dw[1] + dw[2] ); + // independent variable vector + CPPAD_TESTVECTOR(AD) X(3); + X[0] = 0.; + X[1] = 1.; + X[2] = 2.; + Independent(X); + + // parameter value + AD one = 1.; + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(5); + + // CondExp(variable, parameter, variable, variable) + Y[0] = CondExpLt(X[0], one, X[1], X[2]); + Y[1] = CondExpLe(X[0], one, X[1], X[2]); + Y[2] = CondExpEq(X[0], one, X[1], X[2]); + Y[3] = CondExpGe(X[0], one, X[1], X[2]); + Y[4] = CondExpGt(X[0], one, X[1], X[2]); + + // create f: X -> Y + ADFun f(X, Y); + + // vectors for function values + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // vectors for derivative values + CPPAD_TESTVECTOR(double) dv( f.Domain() ); + CPPAD_TESTVECTOR(double) dw( f.Range() ); + + // check original function values + ok &= Y[0] == X[1]; + ok &= Y[1] == X[1]; + ok &= Y[2] == X[2]; + ok &= Y[3] == X[2]; + ok &= Y[4] == X[2]; + + // function values + v[0] = 2.; + v[1] = 1.; + v[2] = 0.; + w = f.Forward(0, v); + ok &= ( w[0] == v[2] ); + ok &= ( w[1] == v[2] ); + ok &= ( w[2] == v[2] ); + ok &= ( w[3] == v[1] ); + ok &= ( w[4] == v[1] ); + + // forward mode derivative values + dv[0] = 1.; + dv[1] = 2.; + dv[2] = 3.; + dw = f.Forward(1, dv); + ok &= (dw[0] == dv[2] ); + ok &= (dw[1] == dv[2] ); + ok &= (dw[2] == dv[2] ); + ok &= (dw[3] == dv[1] ); + ok &= (dw[4] == dv[1] ); + + // reverse mode derivative values + dw[0] = 1.; + dw[1] = 2.; + dw[2] = 3.; + dw[3] = 4.; + dw[4] = 5.; + dv = f.Reverse(1, dw); + ok &= (dv[0] == 0.); + ok &= (dv[1] == dw[3] + dw[4] ); + ok &= (dv[2] == dw[0] + dw[1] + dw[2] ); - return ok; + return ok; } bool CondExp_vvpv(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(3); - X[0] = 0.; - X[1] = 1.; - X[2] = 2.; - Independent(X); - - // parameter value - AD three = 3.; - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(5); - - // CondExp(variable, variable, parameter, variable) - Y[0] = CondExpLt(X[0], X[1], three, X[2]); - Y[1] = CondExpLe(X[0], X[1], three, X[2]); - Y[2] = CondExpEq(X[0], X[1], three, X[2]); - Y[3] = CondExpGe(X[0], X[1], three, X[2]); - Y[4] = CondExpGt(X[0], X[1], three, X[2]); - - // create f: X -> Y - ADFun f(X, Y); - - // vectors for function values - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // vectors for derivative values - CPPAD_TESTVECTOR(double) dv( f.Domain() ); - CPPAD_TESTVECTOR(double) dw( f.Range() ); - - // check original function values - ok &= Y[0] == three; - ok &= Y[1] == three; - ok &= Y[2] == X[2]; - ok &= Y[3] == X[2]; - ok &= Y[4] == X[2]; - - // function values - v[0] = 2.; - v[1] = 1.; - v[2] = 0.; - w = f.Forward(0, v); - ok &= ( w[0] == v[2] ); - ok &= ( w[1] == v[2] ); - ok &= ( w[2] == v[2] ); - ok &= ( w[3] == three ); - ok &= ( w[4] == three ); - - // forward mode derivative values - dv[0] = 1.; - dv[1] = 2.; - dv[2] = 3.; - dw = f.Forward(1, dv); - ok &= (dw[0] == dv[2] ); - ok &= (dw[1] == dv[2] ); - ok &= (dw[2] == dv[2] ); - ok &= (dw[3] == 0. ); - ok &= (dw[4] == 0. ); - - // reverse mode derivative values - dw[0] = 1.; - dw[1] = 2.; - dw[2] = 3.; - dw[3] = 4.; - dw[4] = 5.; - dv = f.Reverse(1, dw); - ok &= (dv[0] == 0.); - ok &= (dv[1] == 0.); - ok &= (dv[2] == dw[0] + dw[1] + dw[2] ); + // independent variable vector + CPPAD_TESTVECTOR(AD) X(3); + X[0] = 0.; + X[1] = 1.; + X[2] = 2.; + Independent(X); + + // parameter value + AD three = 3.; + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(5); + + // CondExp(variable, variable, parameter, variable) + Y[0] = CondExpLt(X[0], X[1], three, X[2]); + Y[1] = CondExpLe(X[0], X[1], three, X[2]); + Y[2] = CondExpEq(X[0], X[1], three, X[2]); + Y[3] = CondExpGe(X[0], X[1], three, X[2]); + Y[4] = CondExpGt(X[0], X[1], three, X[2]); + + // create f: X -> Y + ADFun f(X, Y); + + // vectors for function values + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // vectors for derivative values + CPPAD_TESTVECTOR(double) dv( f.Domain() ); + CPPAD_TESTVECTOR(double) dw( f.Range() ); + + // check original function values + ok &= Y[0] == three; + ok &= Y[1] == three; + ok &= Y[2] == X[2]; + ok &= Y[3] == X[2]; + ok &= Y[4] == X[2]; + + // function values + v[0] = 2.; + v[1] = 1.; + v[2] = 0.; + w = f.Forward(0, v); + ok &= ( w[0] == v[2] ); + ok &= ( w[1] == v[2] ); + ok &= ( w[2] == v[2] ); + ok &= ( w[3] == three ); + ok &= ( w[4] == three ); + + // forward mode derivative values + dv[0] = 1.; + dv[1] = 2.; + dv[2] = 3.; + dw = f.Forward(1, dv); + ok &= (dw[0] == dv[2] ); + ok &= (dw[1] == dv[2] ); + ok &= (dw[2] == dv[2] ); + ok &= (dw[3] == 0. ); + ok &= (dw[4] == 0. ); + + // reverse mode derivative values + dw[0] = 1.; + dw[1] = 2.; + dw[2] = 3.; + dw[3] = 4.; + dw[4] = 5.; + dv = f.Reverse(1, dw); + ok &= (dv[0] == 0.); + ok &= (dv[1] == 0.); + ok &= (dv[2] == dw[0] + dw[1] + dw[2] ); - return ok; + return ok; } bool CondExp_vvvp(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(3); - X[0] = 0.; - X[1] = 1.; - X[2] = 2.; - Independent(X); - - // parameter value - AD three = 3.; - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(5); - - // CondExp(variable, variable, variable, parameter) - Y[0] = CondExpLt(X[0], X[1], X[2], three); - Y[1] = CondExpLe(X[0], X[1], X[2], three); - Y[2] = CondExpEq(X[0], X[1], X[2], three); - Y[3] = CondExpGe(X[0], X[1], X[2], three); - Y[4] = CondExpGt(X[0], X[1], X[2], three); - - // create f: X -> Y - ADFun f(X, Y); - - // vectors for function values - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // vectors for derivative values - CPPAD_TESTVECTOR(double) dv( f.Domain() ); - CPPAD_TESTVECTOR(double) dw( f.Range() ); - - // check original function values - ok &= Y[0] == X[2]; - ok &= Y[1] == X[2]; - ok &= Y[2] == three; - ok &= Y[3] == three; - ok &= Y[4] == three; - - // function values - v[0] = 2.; - v[1] = 1.; - v[2] = 0.; - w = f.Forward(0, v); - ok &= ( w[0] == three ); - ok &= ( w[1] == three ); - ok &= ( w[2] == three ); - ok &= ( w[3] == v[2] ); - ok &= ( w[4] == v[2] ); - - // forward mode derivative values - dv[0] = 1.; - dv[1] = 2.; - dv[2] = 3.; - dw = f.Forward(1, dv); - ok &= (dw[0] == 0. ); - ok &= (dw[1] == 0. ); - ok &= (dw[2] == 0. ); - ok &= (dw[3] == dv[2] ); - ok &= (dw[4] == dv[2] ); - - // reverse mode derivative values - dw[0] = 1.; - dw[1] = 2.; - dw[2] = 3.; - dw[3] = 4.; - dw[4] = 5.; - dv = f.Reverse(1, dw); - ok &= (dv[0] == 0.); - ok &= (dv[1] == 0.); - ok &= (dv[2] == dw[3] + dw[4] ); + // independent variable vector + CPPAD_TESTVECTOR(AD) X(3); + X[0] = 0.; + X[1] = 1.; + X[2] = 2.; + Independent(X); + + // parameter value + AD three = 3.; + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(5); + + // CondExp(variable, variable, variable, parameter) + Y[0] = CondExpLt(X[0], X[1], X[2], three); + Y[1] = CondExpLe(X[0], X[1], X[2], three); + Y[2] = CondExpEq(X[0], X[1], X[2], three); + Y[3] = CondExpGe(X[0], X[1], X[2], three); + Y[4] = CondExpGt(X[0], X[1], X[2], three); + + // create f: X -> Y + ADFun f(X, Y); + + // vectors for function values + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // vectors for derivative values + CPPAD_TESTVECTOR(double) dv( f.Domain() ); + CPPAD_TESTVECTOR(double) dw( f.Range() ); + + // check original function values + ok &= Y[0] == X[2]; + ok &= Y[1] == X[2]; + ok &= Y[2] == three; + ok &= Y[3] == three; + ok &= Y[4] == three; + + // function values + v[0] = 2.; + v[1] = 1.; + v[2] = 0.; + w = f.Forward(0, v); + ok &= ( w[0] == three ); + ok &= ( w[1] == three ); + ok &= ( w[2] == three ); + ok &= ( w[3] == v[2] ); + ok &= ( w[4] == v[2] ); + + // forward mode derivative values + dv[0] = 1.; + dv[1] = 2.; + dv[2] = 3.; + dw = f.Forward(1, dv); + ok &= (dw[0] == 0. ); + ok &= (dw[1] == 0. ); + ok &= (dw[2] == 0. ); + ok &= (dw[3] == dv[2] ); + ok &= (dw[4] == dv[2] ); + + // reverse mode derivative values + dw[0] = 1.; + dw[1] = 2.; + dw[2] = 3.; + dw[3] = 4.; + dw[4] = 5.; + dv = f.Reverse(1, dw); + ok &= (dv[0] == 0.); + ok &= (dv[1] == 0.); + ok &= (dv[2] == dw[3] + dw[4] ); - return ok; + return ok; } # include bool SecondOrderReverse(void) -{ // 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; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * std::numeric_limits::epsilon(); - - size_t n = 1; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 2.; - CppAD::Independent(X); - - size_t m = 2; - CPPAD_TESTVECTOR(AD) Y(m); - - AD left = X[0]; - AD right = X[0] * X[0]; - AD exp_if_true = left; - AD exp_if_false = right; - - // Test of reverse mode using exp_if_true case - // For this value of X, should be the same as Z = X[0] - AD Z = CondExpLt(left, right, exp_if_true, exp_if_false); - Y[0] = Z * Z; - - // Test of reverse mode using exp_if_false case - exp_if_false = left; - 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 - CPPAD_TESTVECTOR(double) dx(n); - size_t p = 1; - dx[0] = 1.; - f.Forward(p, dx); - - // second order reverse (test exp_if_true case) - CPPAD_TESTVECTOR(double) w(m), dw(2 * n); - w[0] = 1.; - w[1] = 0.; - p = 2; - dw = f.Reverse(p, w); - - // check first derivative in dw - double check = 2. * Value( X[0] ); - ok &= NearEqual(dw[0], check, eps, eps); - - // check second derivative in dw - check = 2.; - ok &= NearEqual(dw[1], check, eps, eps); - - // test exp_if_false case - w[0] = 0.; - w[1] = 1.; - p = 2; - dw = f.Reverse(p, w); - - // check first derivative in dw - check = 2. * Value( X[0] ); - ok &= NearEqual(dw[0], check, eps, eps); - - // check second derivative in dw - check = 2.; - ok &= NearEqual(dw[1], check, eps, eps); +{ // 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; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); + + size_t n = 1; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 2.; + CppAD::Independent(X); + + size_t m = 2; + CPPAD_TESTVECTOR(AD) Y(m); + + AD left = X[0]; + AD right = X[0] * X[0]; + AD exp_if_true = left; + AD exp_if_false = right; + + // Test of reverse mode using exp_if_true case + // For this value of X, should be the same as Z = X[0] + AD Z = CondExpLt(left, right, exp_if_true, exp_if_false); + Y[0] = Z * Z; + + // Test of reverse mode using exp_if_false case + exp_if_false = left; + 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 + CPPAD_TESTVECTOR(double) dx(n); + size_t p = 1; + dx[0] = 1.; + f.Forward(p, dx); + + // second order reverse (test exp_if_true case) + CPPAD_TESTVECTOR(double) w(m), dw(2 * n); + w[0] = 1.; + w[1] = 0.; + p = 2; + dw = f.Reverse(p, w); + + // check first derivative in dw + double check = 2. * Value( X[0] ); + ok &= NearEqual(dw[0], check, eps, eps); + + // check second derivative in dw + check = 2.; + ok &= NearEqual(dw[1], check, eps, eps); + + // test exp_if_false case + w[0] = 0.; + w[1] = 1.; + p = 2; + dw = f.Reverse(p, w); + + // check first derivative in dw + check = 2. * Value( X[0] ); + ok &= NearEqual(dw[0], check, eps, eps); + + // check second derivative in dw + check = 2.; + ok &= NearEqual(dw[1], check, eps, eps); - return ok; + return ok; } double Infinity(double zero) { return 1. / zero; } bool OldExample(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - using CppAD::log; - double eps = 100. * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 5; - CPPAD_TESTVECTOR(AD) X(n); - size_t j; - for(j = 0; j < n; j++) - X[j] = 1.; - - // declare independent variables and start tape recording - CppAD::Independent(X); - - // sum with respect to j of log of absolute value of X[j] - // sould be - infinity if any of the X[j] are zero - AD MinusInfinity = - Infinity(0.); - AD Sum = 0.; - AD Zero(0); - for(j = 0; j < n; j++) - { // if X[j] > 0 - Sum += CppAD::CondExpGt(X[j], Zero, log(X[j]), Zero); - - // if X[j] < 0 - Sum += CppAD::CondExpLt(X[j], Zero, log(-X[j]), Zero); - - // if X[j] == 0 - Sum += CppAD::CondExpEq(X[j], Zero, MinusInfinity, Zero); - } - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = Sum; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // 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) dw(n); // derivative of weighted function - - // a case where fabs( x[j] ) > 0 for all j - double check = 0.; - double sign = 1.; - for(j = 0; j < n; j++) - { sign *= -1.; - x[j] = sign * double(j + 1); - check += log( fabs( x[j] ) ); - } - - // function value - y = f.Forward(0, x); - ok &= ( y[0] == check ); - - // compute derivative of y[0] - w[0] = 1.; - dw = f.Reverse(1, w); - for(j = 0; j < n; j++) - { if( x[j] > 0. ) - ok &= NearEqual(dw[j], 1./fabs( x[j] ), eps, eps); - else ok &= NearEqual(dw[j], -1./fabs( 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); - } - - // function value - y = f.Forward(0, x); - ok &= ( y[0] == -Infinity(0.) ); - - // compute derivative of y[0] - f.check_for_nan(false); - w[0] = 1.; - dw = f.Reverse(1, w); - for(j = 0; j < n; j++) - { if( x[j] > 0. ) - ok &= NearEqual(dw[j], 1./fabs( x[j] ), eps, eps); - else if( x[j] < 0. ) - ok &= NearEqual(dw[j], -1./fabs( x[j] ), eps, eps); - else - ok &= NearEqual(dw[j], 0.0, eps, eps); - } + using CppAD::AD; + using CppAD::NearEqual; + using CppAD::log; + double eps = 100. * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 5; + CPPAD_TESTVECTOR(AD) X(n); + size_t j; + for(j = 0; j < n; j++) + X[j] = 1.; + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // sum with respect to j of log of absolute value of X[j] + // sould be - infinity if any of the X[j] are zero + AD MinusInfinity = - Infinity(0.); + AD Sum = 0.; + AD Zero(0); + for(j = 0; j < n; j++) + { // if X[j] > 0 + Sum += CppAD::CondExpGt(X[j], Zero, log(X[j]), Zero); + + // if X[j] < 0 + Sum += CppAD::CondExpLt(X[j], Zero, log(-X[j]), Zero); + + // if X[j] == 0 + Sum += CppAD::CondExpEq(X[j], Zero, MinusInfinity, Zero); + } + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = Sum; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // 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) dw(n); // derivative of weighted function + + // a case where fabs( x[j] ) > 0 for all j + double check = 0.; + double sign = 1.; + for(j = 0; j < n; j++) + { sign *= -1.; + x[j] = sign * double(j + 1); + check += log( fabs( x[j] ) ); + } + + // function value + y = f.Forward(0, x); + ok &= ( y[0] == check ); + + // compute derivative of y[0] + w[0] = 1.; + dw = f.Reverse(1, w); + for(j = 0; j < n; j++) + { if( x[j] > 0. ) + ok &= NearEqual(dw[j], 1./fabs( x[j] ), eps, eps); + else + ok &= NearEqual(dw[j], -1./fabs( 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); + } + + // function value + y = f.Forward(0, x); + ok &= ( y[0] == -Infinity(0.) ); + + // compute derivative of y[0] + f.check_for_nan(false); + w[0] = 1.; + dw = f.Reverse(1, w); + for(j = 0; j < n; j++) + { if( x[j] > 0. ) + ok &= NearEqual(dw[j], 1./fabs( x[j] ), eps, eps); + else if( x[j] < 0. ) + ok &= NearEqual(dw[j], -1./fabs( x[j] ), eps, eps); + else + ok &= NearEqual(dw[j], 0.0, eps, eps); + } - return ok; + return ok; } } // end empty namespace bool CondExp(void) -{ bool ok = true; - ok &= CondExp_pvvv(); - ok &= CondExp_vpvv(); - ok &= CondExp_vvpv(); - ok &= CondExp_vvvp(); - ok &= SecondOrderReverse(); - ok &= OldExample(); - return ok; +{ bool ok = true; + ok &= CondExp_pvvv(); + ok &= CondExp_vpvv(); + ok &= CondExp_vvpv(); + ok &= CondExp_vvvp(); + ok &= SecondOrderReverse(); + ok &= OldExample(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/cond_exp_rev.cpp cppad-2019.02.00.0/test_more/general/cond_exp_rev.cpp --- cppad-2018.00.00.0/test_more/general/cond_exp_rev.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/cond_exp_rev.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // Test that reverse mode handles conditional expressions properly // in that infinity and nans do not propagate thouh un-used case. @@ -15,124 +16,124 @@ # include bool cond_exp_rev(void) -{ bool ok = true; - using CppAD::vector; - using CppAD::AD; +{ bool ok = true; + using CppAD::vector; + using CppAD::AD; - AD anan = std::numeric_limits::quiet_NaN(); - AD azero = 0.0; + 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); + 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], fabs(ax[1]) )); + // AbsOp + ay.push_back( CondExpGt(ax[0], azero, ax[0], fabs(ax[1]) )); - // AcosOp - ay.push_back( CondExpGt(ax[0], azero, ax[0], acos(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] )); + // 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] )); + // 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]) )); + // 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]) )); + // 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]) )); + // 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]) )); + // 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] )); + // 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] )); + // 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 )); + // 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]) )); + // 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]) )); + // 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]) )); + // 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] )); + // 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] )); + // 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]) )); + // 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) )); + // 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]) )); + // 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]) )); + // 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]) )); + // 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]) )); + // 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]) )); + // 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] )); + // 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] )); + // 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 )); + // 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]) )); + // 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]) )); + // 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); + // 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; + // 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; - } + // 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; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/copy.cpp cppad-2019.02.00.0/test_more/general/copy.cpp --- cppad-2018.00.00.0/test_more/general/copy.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/copy.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old Copy example now used just for valiadation testing @@ -18,166 +19,166 @@ namespace { // begin empty namespace bool copy_older(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(1); - size_t is = 0; - U[is] = 2.; - Independent(U); - - // create an AD that does not depend on s - AD t = 3.; - - // use copy constructor - AD x(U[is]); - AD y(t); - - // check which are parameters - ok &= ! Parameter(x); - ok &= Parameter(y); - - // dependent variable vector, indices, and values - CPPAD_TESTVECTOR(AD) Z(2); - size_t ix = 0; - size_t iy = 1; - Z[ix] = x; - Z[iy] = y; - - // create f: U -> Z and vectors used for derivative calculations - 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 function values - ok &= ( Z[ix] == 2. ); - ok &= ( Z[iy] == 3. ); - - // forward computation of partials w.r.t. s - v[is] = 1.; - w = f.Forward(1, v); - ok &= ( w[ix] == 1. ); // dx/ds - ok &= ( w[iy] == 0. ); // dy/ds + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(1); + size_t is = 0; + U[is] = 2.; + Independent(U); + + // create an AD that does not depend on s + AD t = 3.; + + // use copy constructor + AD x(U[is]); + AD y(t); + + // check which are parameters + ok &= ! Parameter(x); + ok &= Parameter(y); + + // dependent variable vector, indices, and values + CPPAD_TESTVECTOR(AD) Z(2); + size_t ix = 0; + size_t iy = 1; + Z[ix] = x; + Z[iy] = y; + + // create f: U -> Z and vectors used for derivative calculations + 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 function values + ok &= ( Z[ix] == 2. ); + ok &= ( Z[iy] == 3. ); + + // forward computation of partials w.r.t. s + v[is] = 1.; + w = f.Forward(1, v); + ok &= ( w[ix] == 1. ); // dx/ds + ok &= ( w[iy] == 0. ); // dy/ds - return ok; + return ok; } bool copy_ad(void) -{ bool ok = true; // initialize test result flag - using CppAD::AD; // so can use AD in place of CppAD::AD +{ bool ok = true; // initialize test result flag + using CppAD::AD; // so can use AD in place of CppAD::AD - // domain space vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = 2.; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // create an AD that does not depend on x - AD b = 3.; - - // use copy constructor - AD u(x[0]); - AD v = b; - - // check which are parameters - ok &= Variable(u); - ok &= Parameter(v); - - // range space vector - size_t m = 2; - CPPAD_TESTVECTOR(AD) y(m); - y[0] = u; - y[1] = v; - - // create f: x -> y and vectors used for derivative calculations - 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 function values - ok &= ( y[0] == 2. ); - ok &= ( y[1] == 3. ); - - // forward computation of partials w.r.t. x[0] - dx[0] = 1.; - dy = f.Forward(1, dx); - ok &= ( dy[0] == 1. ); // du / dx - ok &= ( dy[1] == 0. ); // dv / dx + // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = 2.; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // create an AD that does not depend on x + AD b = 3.; + + // use copy constructor + AD u(x[0]); + AD v = b; + + // check which are parameters + ok &= Variable(u); + ok &= Parameter(v); + + // range space vector + size_t m = 2; + CPPAD_TESTVECTOR(AD) y(m); + y[0] = u; + y[1] = v; + + // create f: x -> y and vectors used for derivative calculations + 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 function values + ok &= ( y[0] == 2. ); + ok &= ( y[1] == 3. ); + + // forward computation of partials w.r.t. x[0] + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= ( dy[0] == 1. ); // du / dx + ok &= ( dy[1] == 0. ); // dv / dx - return ok; + return ok; } bool copy_base(void) -{ bool ok = true; // initialize test result flag - using CppAD::AD; // so can use AD in place of CppAD::AD +{ 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 is double + AD y = 2; - // construct from a type that converts to Base where Base = AD - AD< AD > z(3); + // construct from a type that converts to Base where Base = AD + AD< AD > z(3); - // check that resulting objects are parameters - ok &= Parameter(x); - ok &= Parameter(y); - ok &= Parameter(z); + // check that resulting objects are parameters + ok &= Parameter(x); + ok &= Parameter(y); + ok &= Parameter(z); - // check values of objects (compare AD with double) - ok &= ( x == 1.); - ok &= ( y == 2.); - ok &= ( Value(z) == 3.); + // check values of objects (compare AD with double) + ok &= ( x == 1.); + ok &= ( y == 2.); + ok &= ( Value(z) == 3.); - // user constructor through the static_cast template function - x = static_cast < AD >( 4 ); - z = static_cast < AD< AD > >( 5 ); + // user constructor through the static_cast template function + x = static_cast < AD >( 4 ); + z = static_cast < AD< AD > >( 5 ); - ok &= ( x == 4. ); - ok &= ( Value(z) == 5. ); + ok &= ( x == 4. ); + ok &= ( Value(z) == 5. ); - return ok; + return ok; } bool default_ctor(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // default AD constructor - AD x, y; + // default AD constructor + AD x, y; - // check that they are parameters - ok &= Parameter(x); - ok &= Parameter(y); + // check that they are parameters + ok &= Parameter(x); + ok &= Parameter(y); - // assign them values - x = 3.; - y = 4.; + // assign them values + x = 3.; + y = 4.; - // just check a simple operation - ok &= (x + y == 7.); + // just check a simple operation + ok &= (x + y == 7.); - return ok; + return ok; } // END PROGRAM } // end empty namespace bool copy(void) -{ bool ok = true; - ok &= copy_older(); - ok &= copy_ad(); - ok &= copy_base(); - ok &= default_ctor(); - return ok; +{ bool ok = true; + ok &= copy_older(); + ok &= copy_ad(); + ok &= copy_base(); + ok &= default_ctor(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/cos.cpp cppad-2019.02.00.0/test_more/general/cos.cpp --- cppad-2018.00.00.0/test_more/general/cos.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/cos.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old example now just used for validation testing @@ -15,74 +16,76 @@ # include bool Cos(void) -{ bool ok = true; - using CppAD::sin; - using CppAD::cos; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(1); - U[0] = 1.; - Independent(U); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = cos(U[0]); - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - double sin_u = sin( Value(U[0]) ); - double cos_u = cos( Value(U[0]) ); - - ok &= NearEqual(cos_u, Value(Z[0]), eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { w = f.Forward(j, v); - - double value; - if( j % 4 == 1 ) - value = -sin_u; - else if( j % 4 == 2 ) - value = -cos_u; - else if( j % 4 == 3 ) - value = sin_u; - else value = cos_u; - - jfac *= double(j); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - for(j = 0; j < p; j++) - { - double value; - if( j % 4 == 0 ) - value = -sin_u; - else if( j % 4 == 1 ) - value = -cos_u; - else if( j % 4 == 2 ) - value = sin_u; - else value = cos_u; +{ bool ok = true; + using CppAD::sin; + using CppAD::cos; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(1); + U[0] = 1.; + Independent(U); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Z(1); + Z[0] = cos(U[0]); + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + double sin_u = sin( Value(U[0]) ); + double cos_u = cos( Value(U[0]) ); + + ok &= NearEqual(cos_u, Value(Z[0]), eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { w = f.Forward(j, v); + + double value; + if( j % 4 == 1 ) + value = -sin_u; + else if( j % 4 == 2 ) + value = -cos_u; + else if( j % 4 == 3 ) + value = sin_u; + else + value = cos_u; + + jfac *= double(j); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + for(j = 0; j < p; j++) + { + double value; + if( j % 4 == 0 ) + value = -sin_u; + else if( j % 4 == 1 ) + value = -cos_u; + else if( j % 4 == 2 ) + value = sin_u; + else + value = cos_u; - ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - } + jfac *= double(j + 1); + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/cosh.cpp cppad-2019.02.00.0/test_more/general/cosh.cpp --- cppad-2018.00.00.0/test_more/general/cosh.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/cosh.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old example now just used for validation testing. @@ -15,66 +16,68 @@ # include bool Cosh(void) -{ bool ok = true; - using CppAD::sinh; - using CppAD::cosh; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(1); - U[0] = 1.; - Independent(U); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = cosh(U[0]); - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - double sinh_u = sinh( Value(U[0]) ); - double cosh_u = cosh( Value(U[0]) ); - - ok &= NearEqual(cosh_u, Value(Z[0]), eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { w = f.Forward(j, v); - - double value; - if( j % 2 == 1 ) - value = sinh_u; - else value = cosh_u; - - jfac *= double(j); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - for(j = 0; j < p; j++) - { - double value; - if( j % 2 == 0 ) - value = sinh_u; - else value = cosh_u; +{ bool ok = true; + using CppAD::sinh; + using CppAD::cosh; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(1); + U[0] = 1.; + Independent(U); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Z(1); + Z[0] = cosh(U[0]); + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + double sinh_u = sinh( Value(U[0]) ); + double cosh_u = cosh( Value(U[0]) ); + + ok &= NearEqual(cosh_u, Value(Z[0]), eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { w = f.Forward(j, v); + + double value; + if( j % 2 == 1 ) + value = sinh_u; + else + value = cosh_u; + + jfac *= double(j); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + for(j = 0; j < p; j++) + { + double value; + if( j % 2 == 0 ) + value = sinh_u; + else + value = cosh_u; - ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - } + jfac *= double(j + 1); + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/cppad_eigen.cpp cppad-2019.02.00.0/test_more/general/cppad_eigen.cpp --- cppad-2018.00.00.0/test_more/general/cppad_eigen.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/cppad_eigen.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test of Eigen Interface to CppAD Scalar Types @@ -16,53 +17,53 @@ # include bool cppad_eigen(void) -{ bool ok = true; - using CppAD::AD; - using Eigen::Dynamic; - using Eigen::Matrix; - - typedef Eigen::NumTraits > traits; - - ok &= traits::IsComplex == 0; - ok &= traits::IsInteger == 0; - ok &= traits::IsSigned == 1; - ok &= traits::RequireInitialization == 1; - ok &= traits::ReadCost == 1; - ok &= traits::AddCost == 2; - ok &= traits::MulCost == 2; - - ok &= traits::epsilon() == - std::numeric_limits::epsilon(); - ok &= traits::dummy_precision() == - 100.* std::numeric_limits::epsilon(); - ok &= traits::highest() == - std::numeric_limits::max(); - ok &= traits::lowest() == - std::numeric_limits::min(); - - AD x = 2.0; - ok &= conj(x) == x; - ok &= real(x) == x; - ok &= imag(x) == 0.0; - ok &= abs2(x) == 4.0; - - // Outputing a matrix used to fail before partial specialization of - // 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(); - - // multiplying three matrices together used to cause warning - // before making ctor from arbitrary type to AD explicit. - typedef CppAD::AD AScalar; - Matrix A(1,1), B(1,1), C(1,1), D(1,1); - A(0,0) = 1.0; - B(0,0) = 2.0; - C(0,0) = 3.0; - D = A * B * C; - ok &= D(0,0) == 6.0 ; +{ bool ok = true; + using CppAD::AD; + using Eigen::Dynamic; + using Eigen::Matrix; + + typedef Eigen::NumTraits > traits; + + ok &= traits::IsComplex == 0; + ok &= traits::IsInteger == 0; + ok &= traits::IsSigned == 1; + ok &= traits::RequireInitialization == 1; + ok &= traits::ReadCost == 1; + ok &= traits::AddCost == 2; + ok &= traits::MulCost == 2; + + ok &= traits::epsilon() == + std::numeric_limits::epsilon(); + ok &= traits::dummy_precision() == + 100.* std::numeric_limits::epsilon(); + ok &= traits::highest() == + std::numeric_limits::max(); + ok &= traits::lowest() == + std::numeric_limits::min(); + + AD x = 2.0; + ok &= conj(x) == x; + ok &= real(x) == x; + ok &= imag(x) == 0.0; + ok &= abs2(x) == 4.0; + + // Outputing a matrix used to fail before partial specialization of + // 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(); + + // multiplying three matrices together used to cause warning + // before making ctor from arbitrary type to AD explicit. + typedef CppAD::AD AScalar; + Matrix A(1,1), B(1,1), C(1,1), D(1,1); + A(0,0) = 1.0; + B(0,0) = 2.0; + C(0,0) = 3.0; + D = A * B * C; + ok &= D(0,0) == 6.0 ; - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/dbl_epsilon.cpp cppad-2019.02.00.0/test_more/general/dbl_epsilon.cpp --- cppad-2018.00.00.0/test_more/general/dbl_epsilon.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/dbl_epsilon.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Check the value of machine epsilon is accurate enough for the correctness tests @@ -17,11 +18,11 @@ # include bool dbl_epsilon(void) -{ bool ok = true; +{ bool ok = true; - // CppAD correctness tests assume machine epsilon is less than 1e-13 - ok &= DBL_EPSILON < 1e-13; - ok &= std::numeric_limits::digits10 >= 13; + // CppAD correctness tests assume machine epsilon is less than 1e-13 + ok &= DBL_EPSILON < 1e-13; + ok &= std::numeric_limits::digits10 >= 13; - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/dependency.cpp cppad-2019.02.00.0/test_more/general/dependency.cpp --- cppad-2018.00.00.0/test_more/general/dependency.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/dependency.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,19 +1,20 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old example for deprecated interface. $spell - CppAD - Jac + CppAD + Jac $$ $section Computing Dependency: Example and Test$$ @@ -25,9 +26,9 @@ $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 + +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$$ @@ -45,100 +46,98 @@ $cref/RevSparseJac/RevSparseJac/dependency/$$ is a flag that signals that the dependency pattern (instead of the sparsity pattern) is computed. -$code $srcfile%test_more/general/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) + 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; +{ 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-2018.00.00.0/test_more/general/div.cpp cppad-2019.02.00.0/test_more/general/div.cpp --- cppad-2018.00.00.0/test_more/general/div.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/div.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Two old Div examples now used just for valiadation testing @@ -18,196 +19,196 @@ namespace { // BEGIN empty namespace bool DivTestOne(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // assign some parameters - AD zero = 0.; - AD one = 1.; - - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(2); - size_t s = 0; - size_t t = 1; - U[s] = 2.; - U[t] = 3.; - Independent(U); - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(6); - size_t x = 0; - size_t y = 1; - size_t z = 2; - size_t u = 3; - size_t v = 4; - size_t w = 5; - - // 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[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 - - // check division into a zero valued parameter results in a parameter - // (must do this before creating f because it erases the tape) - ok &= Parameter(Z[w]); - - // create f : U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) q( f.Domain() ); - CPPAD_TESTVECTOR(double) r( f.Range() ); - - // check parameter flag - ok &= f.Parameter(w); - - // check values - ok &= NearEqual( Z[x] , 2. / 3. , eps99, eps99); - ok &= NearEqual( Z[y] , 2. / ( 3. * 4. ) , eps99, eps99); - ok &= NearEqual( Z[z] , 5. * 3. * 4. / 2. , eps99, eps99); - ok &= ( Z[w] == 0. ); - ok &= ( Z[u] == Z[z] ); - - // forward computation of partials w.r.t. s - q[s] = 1.; - q[t] = 0.; - r = f.Forward(1, q); - ok &= NearEqual(r[x], 1./U[t], eps99, eps99); // dx/ds - ok &= NearEqual(r[y], 1./(U[t]*4.), eps99, eps99); // dy/ds - ok &= NearEqual(r[z], -5.*U[t]*4./(U[s]*U[s]), eps99, eps99); // dz/ds - ok &= ( r[u] == r[z] ); // du/ds - ok &= ( r[v] == r[z] ); // dv/ds - ok &= ( r[w] == 0. ); // dw/ds - - // forward computation in the direction (1, 1) - q[s] = 1.; - q[t] = 1.; - r = f.Forward(1, q); - ok &= NearEqual(r[x], 1./U[t] - U[s]/(U[t] * U[t]), eps99, eps99); - - // second order reverse mode computation - CPPAD_TESTVECTOR(double) Q( f.Domain() * 2 ); - r[x] = 1.; - 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]), - eps99, - eps99 - ); + using namespace CppAD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // assign some parameters + AD zero = 0.; + AD one = 1.; + + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(2); + size_t s = 0; + size_t t = 1; + U[s] = 2.; + U[t] = 3.; + Independent(U); + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(6); + size_t x = 0; + size_t y = 1; + size_t z = 2; + size_t u = 3; + size_t v = 4; + size_t w = 5; + + // 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[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 + + // check division into a zero valued parameter results in a parameter + // (must do this before creating f because it erases the tape) + ok &= Parameter(Z[w]); + + // create f : U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) q( f.Domain() ); + CPPAD_TESTVECTOR(double) r( f.Range() ); + + // check parameter flag + ok &= f.Parameter(w); + + // check values + ok &= NearEqual( Z[x] , 2. / 3. , eps99, eps99); + ok &= NearEqual( Z[y] , 2. / ( 3. * 4. ) , eps99, eps99); + ok &= NearEqual( Z[z] , 5. * 3. * 4. / 2. , eps99, eps99); + ok &= ( Z[w] == 0. ); + ok &= ( Z[u] == Z[z] ); + + // forward computation of partials w.r.t. s + q[s] = 1.; + q[t] = 0.; + r = f.Forward(1, q); + ok &= NearEqual(r[x], 1./U[t], eps99, eps99); // dx/ds + ok &= NearEqual(r[y], 1./(U[t]*4.), eps99, eps99); // dy/ds + ok &= NearEqual(r[z], -5.*U[t]*4./(U[s]*U[s]), eps99, eps99); // dz/ds + ok &= ( r[u] == r[z] ); // du/ds + ok &= ( r[v] == r[z] ); // dv/ds + ok &= ( r[w] == 0. ); // dw/ds + + // forward computation in the direction (1, 1) + q[s] = 1.; + q[t] = 1.; + r = f.Forward(1, q); + ok &= NearEqual(r[x], 1./U[t] - U[s]/(U[t] * U[t]), eps99, eps99); + + // second order reverse mode computation + CPPAD_TESTVECTOR(double) Q( f.Domain() * 2 ); + r[x] = 1.; + 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]), + eps99, + eps99 + ); - return ok; + return ok; } bool DivTestTwo(void) -{ bool ok = true; - using namespace CppAD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - double u0 = .5; - CPPAD_TESTVECTOR(AD) U(1); - 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 - - // 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); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(Value(Z[0]) , u0*u0/(4/(3/(u0/2))), eps99, eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - v[0] = 1.; - double value = 6. / 4.; - for(j = 1; j < p; j++) - { - jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - value = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - value = 6. / 4.; - for(j = 0; j < p; j++) - { - ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - value = 0.; - } +{ bool ok = true; + using namespace CppAD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + double u0 = .5; + CPPAD_TESTVECTOR(AD) U(1); + 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 + + // 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); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(Value(Z[0]) , u0*u0/(4/(3/(u0/2))), eps99, eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + v[0] = 1.; + double value = 6. / 4.; + for(j = 1; j < p; j++) + { + jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + value = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + value = 6. / 4.; + for(j = 0; j < p; j++) + { + ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + jfac *= double(j + 1); + value = 0.; + } - return ok; + return ok; } bool DivTestThree(void) -{ bool ok = true; - using namespace CppAD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // more testing of variable / variable case - double x0 = 2.; - double x1 = 3.; - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = x0; - X[1] = x1; - Independent(X); - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0] / X[1]; - ADFun f(X, Y); - - CPPAD_TESTVECTOR(double) dx(n), dy(m); - double check; - dx[0] = 1.; - dx[1] = 1.; - dy = f.Forward(1, dx); - check = 1. / x1 - x0 / (x1 * x1); - ok &= NearEqual(dy[0], check, eps99, eps99); - - CPPAD_TESTVECTOR(double) w(m), dw(n); - w[0] = 1.; - dw = f.Reverse(1, w); - check = 1. / x1; - ok &= NearEqual(dw[0], check, eps99, eps99); - check = - x0 / (x1 * x1); - ok &= NearEqual(dw[1], check, eps99, eps99); +{ bool ok = true; + using namespace CppAD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // more testing of variable / variable case + double x0 = 2.; + double x1 = 3.; + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = x0; + X[1] = x1; + Independent(X); + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0] / X[1]; + ADFun f(X, Y); + + CPPAD_TESTVECTOR(double) dx(n), dy(m); + double check; + dx[0] = 1.; + dx[1] = 1.; + dy = f.Forward(1, dx); + check = 1. / x1 - x0 / (x1 * x1); + ok &= NearEqual(dy[0], check, eps99, eps99); + + CPPAD_TESTVECTOR(double) w(m), dw(n); + w[0] = 1.; + dw = f.Reverse(1, w); + check = 1. / x1; + ok &= NearEqual(dw[0], check, eps99, eps99); + check = - x0 / (x1 * x1); + ok &= NearEqual(dw[1], check, eps99, eps99); - return ok; + return ok; } } // END empty namespace bool Div(void) -{ bool ok = true; - ok &= DivTestOne(); - ok &= DivTestTwo(); - ok &= DivTestThree(); - return ok; +{ bool ok = true; + ok &= DivTestOne(); + ok &= DivTestTwo(); + ok &= DivTestThree(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/div_eq.cpp cppad-2019.02.00.0/test_more/general/div_eq.cpp --- cppad-2018.00.00.0/test_more/general/div_eq.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/div_eq.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old DivEq example now used just for valiadation testing @@ -17,138 +18,138 @@ namespace { // BEGIN empty namespace bool DivEqTestOne(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(2); - size_t s = 0; - size_t t = 1; - U[s] = 3.; - U[t] = 2.; - Independent(U); - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(2); - size_t x = 0; - size_t y = 1; - - // some constants - AD zero = 0.; - AD one = 1.; - - // dependent variable values - 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); - - // create f : U -> Z and vectors for derivative calcualtions - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - 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); - - // check functin values - ok &= NearEqual(Z[x] , 3. / 2. , eps99, eps99); - ok &= NearEqual(Z[y] , 2. / 5. , eps99, eps99); - - // forward computation of partials w.r.t. t - v[s] = 0.; - v[t] = 1.; - w = f.Forward(1, v); - ok &= NearEqual(w[x] , -1.*U[s]/(U[t]*U[t]) , eps99, eps99); // dx/dt - ok &= NearEqual(w[y] , 1. / 5. , eps99, eps99); // dy/dt - - // reverse computation of second partials of x - CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); - w[x] = 1.; - w[y] = 0.; - r = f.Reverse(2, w); - ok &= NearEqual(r[2 * s + 1] // d^2 x / (dt ds) - , - 1. / (U[t] * U[t]) , eps99 , eps99 ); - ok &= NearEqual(r[2 * t + 1] // d^2 x / (dt dt) - , 2. * U[s] / (U[t] * U[t] * U[t]) , eps99 , eps99 ); + using namespace CppAD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(2); + size_t s = 0; + size_t t = 1; + U[s] = 3.; + U[t] = 2.; + Independent(U); + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(2); + size_t x = 0; + size_t y = 1; + + // some constants + AD zero = 0.; + AD one = 1.; + + // dependent variable values + 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); + + // create f : U -> Z and vectors for derivative calcualtions + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + 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); + + // check functin values + ok &= NearEqual(Z[x] , 3. / 2. , eps99, eps99); + ok &= NearEqual(Z[y] , 2. / 5. , eps99, eps99); + + // forward computation of partials w.r.t. t + v[s] = 0.; + v[t] = 1.; + w = f.Forward(1, v); + ok &= NearEqual(w[x] , -1.*U[s]/(U[t]*U[t]) , eps99, eps99); // dx/dt + ok &= NearEqual(w[y] , 1. / 5. , eps99, eps99); // dy/dt + + // reverse computation of second partials of x + CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); + w[x] = 1.; + w[y] = 0.; + r = f.Reverse(2, w); + ok &= NearEqual(r[2 * s + 1] // d^2 x / (dt ds) + , - 1. / (U[t] * U[t]) , eps99 , eps99 ); + ok &= NearEqual(r[2 * t + 1] // d^2 x / (dt dt) + , 2. * U[s] / (U[t] * U[t] * U[t]) , eps99 , eps99 ); - return ok; + return ok; } bool DivEqTestTwo(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - double u0 = .5; - CPPAD_TESTVECTOR(AD) U(1); - U[0] = u0; - Independent(U); - - // 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 - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(Z[0] , u0*u0/(2*4*u0), eps99, eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - double value = 1./8.; - v[0] = 1.; - for(j = 1; j < p; j++) - { jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - value = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - value = 1./8.; - for(j = 0; j < p; j++) - { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - value = 0.; - } + using namespace CppAD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + double u0 = .5; + CPPAD_TESTVECTOR(AD) U(1); + U[0] = u0; + Independent(U); + + // 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 + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(Z[0] , u0*u0/(2*4*u0), eps99, eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + double value = 1./8.; + v[0] = 1.; + for(j = 1; j < p; j++) + { jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + value = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + value = 1./8.; + for(j = 0; j < p; j++) + { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + jfac *= double(j + 1); + value = 0.; + } - return ok; + return ok; } } // END empty namespace bool DivEq(void) -{ bool ok = true; - ok &= DivEqTestOne(); - ok &= DivEqTestTwo(); - return ok; +{ bool ok = true; + ok &= DivEqTestOne(); + ok &= DivEqTestTwo(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/div_zero_one.cpp cppad-2019.02.00.0/test_more/general/div_zero_one.cpp --- cppad-2018.00.00.0/test_more/general/div_zero_one.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/div_zero_one.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test the use of the special parameters zero and one with the multiply operator @@ -19,72 +20,73 @@ typedef CppAD::AD< ADdouble > ADDdouble; bool DivZeroOne(void) -{ bool ok = true; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - size_t i; - for(i = 0; i < 3; i++) - { // run through the cases x = 0, 1, 2 - - size_t j; - for(j = 0; j < 3; j++) - { // run through the cases y = 0, 1, 2 - - CPPAD_TESTVECTOR( ADdouble ) x(1); - x[0] = double(i); - Independent(x); - - CPPAD_TESTVECTOR( ADDdouble ) y(1); - y[0] = ADDdouble(j); - Independent(y); - - CPPAD_TESTVECTOR( ADDdouble ) z(2); - if( j == 0 ) - z[0] = ADDdouble(0); - else z[0] = x[0] / y[0]; - if( i == 0 ) - z[1] = ADDdouble(0); - else - { z[1] = y[0] / x[0]; - z[1] /= x[0]; - } - - // f(y) = z = { x / y , y / (x * x) } - ADFun< ADdouble > f(y, z); - CPPAD_TESTVECTOR( ADdouble ) u( f.Domain() ); - CPPAD_TESTVECTOR( ADdouble ) v( f.Range() ); - - // v = f'(y) - u[0] = ADdouble(1.); - v = f.Forward(1, u); - - // check derivatives of f - ADdouble check = - double(i) / double(j * j); - if( j != 0 ) ok &= NearEqual( - v[0], check, eps99, eps99 ); - - check = 1. / double(i * i); - if( i != 0 ) ok &= NearEqual( - v[1], check, eps99, eps99); - - // g(x) = f'(y) = {-x/y^2 , 1/(x * x)} - ADFun g(x, v); - CPPAD_TESTVECTOR( double ) a( g.Domain() ); - CPPAD_TESTVECTOR( double ) b( g.Range() ); - - // b = g'(x) - a[0] = 1.; - b = g.Forward(1, a); - - // check derivatives of g - if( j != 0 ) ok &= NearEqual( - b[0], - 1./double(j*j), eps99, eps99 ); - if( i != 0 ) ok &= NearEqual( - b[1], -2./double(i*i*i), eps99, eps99); +{ bool ok = true; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + size_t i; + for(i = 0; i < 3; i++) + { // run through the cases x = 0, 1, 2 + + size_t j; + for(j = 0; j < 3; j++) + { // run through the cases y = 0, 1, 2 + + CPPAD_TESTVECTOR( ADdouble ) x(1); + x[0] = double(i); + Independent(x); + + CPPAD_TESTVECTOR( ADDdouble ) y(1); + y[0] = ADDdouble(j); + Independent(y); + + CPPAD_TESTVECTOR( ADDdouble ) z(2); + if( j == 0 ) + z[0] = ADDdouble(0); + else + z[0] = x[0] / y[0]; + if( i == 0 ) + z[1] = ADDdouble(0); + else + { z[1] = y[0] / x[0]; + z[1] /= x[0]; + } + + // f(y) = z = { x / y , y / (x * x) } + ADFun< ADdouble > f(y, z); + CPPAD_TESTVECTOR( ADdouble ) u( f.Domain() ); + CPPAD_TESTVECTOR( ADdouble ) v( f.Range() ); + + // v = f'(y) + u[0] = ADdouble(1.); + v = f.Forward(1, u); + + // check derivatives of f + ADdouble check = - double(i) / double(j * j); + if( j != 0 ) ok &= NearEqual( + v[0], check, eps99, eps99 ); + + check = 1. / double(i * i); + if( i != 0 ) ok &= NearEqual( + v[1], check, eps99, eps99); + + // g(x) = f'(y) = {-x/y^2 , 1/(x * x)} + ADFun g(x, v); + CPPAD_TESTVECTOR( double ) a( g.Domain() ); + CPPAD_TESTVECTOR( double ) b( g.Range() ); + + // b = g'(x) + a[0] = 1.; + b = g.Forward(1, a); + + // check derivatives of g + if( j != 0 ) ok &= NearEqual( + b[0], - 1./double(j*j), eps99, eps99 ); + if( i != 0 ) ok &= NearEqual( + b[1], -2./double(i*i*i), eps99, eps99); - } - } + } + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/eigen_mat_inv.cpp cppad-2019.02.00.0/test_more/general/eigen_mat_inv.cpp --- cppad-2018.00.00.0/test_more/general/eigen_mat_inv.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/eigen_mat_inv.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,21 +1,22 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include # include namespace { // BEGIN_EMPTY_NAMESPACE -typedef double scalar; -typedef CppAD::AD ad_scalar; -typedef typename atomic_eigen_mat_inv::ad_matrix ad_matrix; +typedef double scalar; +typedef CppAD::AD ad_scalar; +typedef atomic_eigen_mat_inv::ad_matrix ad_matrix; scalar eps = 10. * std::numeric_limits::epsilon(); using CppAD::NearEqual; @@ -36,132 +37,133 @@ */ bool non_symmetric(void) { - bool ok = true; - // ------------------------------------------------------------------- - // object that computes inverse of a 2x2 matrix - atomic_eigen_mat_inv mat_inv; - // ------------------------------------------------------------------- - // declare independent variable vector x - size_t n = 2; - CPPAD_TESTVECTOR(ad_scalar) ad_x(n); - for(size_t j = 0; j < n; j++) - ad_x[j] = ad_scalar(j); - CppAD::Independent(ad_x); - // ------------------------------------------------------------------- - // arg = [ x[0] -1 ] - // [ 2 x[1] ] - size_t nr = 2; - ad_matrix ad_arg(nr, nr); - ad_arg(0, 0) = ad_x[0]; - ad_arg(0, 1) = ad_scalar(-1.0); - ad_arg(1, 0) = ad_scalar(2.0); - ad_arg(1, 1) = ad_x[1]; - // ------------------------------------------------------------------- - // use atomic operation to compute arg^{-1} - ad_matrix ad_result = mat_inv.op(ad_arg); - // ------------------------------------------------------------------- - // declare the dependent variable vector y - size_t m = 4; - CPPAD_TESTVECTOR(ad_scalar) ad_y(4); - for(size_t i = 0; i < nr; i++) - for(size_t j = 0; j < nr; j++) - ad_y[ i * nr + j ] = ad_result(i, j); - /* Used to test hand calculated derivaives - CppAD::AD ad_dinv = 1.0 / (ad_x[0] * ad_x[1] + 2.0); - ad_y[0] = ad_x[1] * ad_dinv; - ad_y[1] = 1.0 * ad_dinv; - ad_y[2] = -2.0 * ad_dinv; - ad_y[3] = ad_x[0] * ad_dinv; - */ - CppAD::ADFun f(ad_x, ad_y); - // ------------------------------------------------------------------- - // check zero order forward mode - CPPAD_TESTVECTOR(scalar) x(n), y(m); - for(size_t i = 0; i < n; i++) - x[i] = scalar(i + 2); - scalar dinv = 1.0 / (x[0] * x[1] + 2.0); - y = f.Forward(0, x); - ok &= NearEqual(y[0], x[1] * dinv, eps, eps); - ok &= NearEqual(y[1], 1.0 * dinv, eps, eps); - ok &= NearEqual(y[2], -2.0 * dinv, eps, eps); - ok &= NearEqual(y[3], x[0] * dinv, eps, eps); - // ------------------------------------------------------------------- - // check first order forward mode - CPPAD_TESTVECTOR(scalar) x1(n), y1(m); - scalar dinv_x0 = - x[1] * dinv * dinv; - x1[0] = 1.0; - x1[1] = 0.0; - y1 = f.Forward(1, x1); - ok &= NearEqual(y1[0], x[1] * dinv_x0, eps, eps); - ok &= NearEqual(y1[1], 1.0 * dinv_x0, eps, eps); - ok &= NearEqual(y1[2], -2.0 * dinv_x0, eps, eps); - ok &= NearEqual(y1[3], dinv + x[0] * dinv_x0, eps, eps); - // - scalar dinv_x1 = - x[0] * dinv * dinv; - x1[0] = 0.0; - x1[1] = 1.0; - y1 = f.Forward(1, x1); - ok &= NearEqual(y1[0], dinv + x[1] * dinv_x1, eps, eps); - ok &= NearEqual(y1[1], 1.0 * dinv_x1, eps, eps); - ok &= NearEqual(y1[2], -2.0 * dinv_x1, eps, eps); - ok &= NearEqual(y1[3], x[0] * dinv_x1, eps, eps); - // ------------------------------------------------------------------- - // check second order forward mode - CPPAD_TESTVECTOR(scalar) x2(n), y2(m); - scalar dinv_x1_x1 = 2.0 * x[0] * x[0] * dinv * dinv * dinv; - x2[0] = 0.0; - x2[1] = 0.0; - y2 = f.Forward(2, x2); - ok &= NearEqual(2.0*y2[0], 2.0*dinv_x1 + x[1]*dinv_x1_x1, eps, eps); - ok &= NearEqual(2.0*y2[1], 1.0 * dinv_x1_x1, eps, eps); - ok &= NearEqual(2.0*y2[2], -2.0 * dinv_x1_x1, eps, eps); - ok &= NearEqual(2.0*y2[3], x[0] * dinv_x1_x1, eps, eps); - // ------------------------------------------------------------------- - // check first order reverse - CPPAD_TESTVECTOR(scalar) w(m), d1w(n); - for(size_t i = 0; i < m; i++) - w[i] = 0.0; - w[0] = 1.0; - d1w = f.Reverse(1, w); - ok &= NearEqual(d1w[0], x[1] * dinv_x0, eps, eps); - ok &= NearEqual(d1w[1], dinv + x[1] * dinv_x1, eps, eps); - w[0] = 0.0; - w[1] = 1.0; - d1w = f.Reverse(1, w); - ok &= NearEqual(d1w[0], 1.0 * dinv_x0, eps, eps); - ok &= NearEqual(d1w[1], 1.0 * dinv_x1, eps, eps); - w[1] = 0.0; - w[2] = 1.0; - d1w = f.Reverse(1, w); - ok &= NearEqual(d1w[0], -2.0 * dinv_x0, eps, eps); - ok &= NearEqual(d1w[1], -2.0 * dinv_x1, eps, eps); - w[2] = 0.0; - w[3] = 1.0; - d1w = f.Reverse(1, w); - ok &= NearEqual(d1w[0], dinv + x[0] * dinv_x0, eps, eps); - ok &= NearEqual(d1w[1], x[0] * dinv_x1, eps, eps); - // ------------------------------------------------------------------- - // check second order reverse - CPPAD_TESTVECTOR(scalar) d2w(2 * n); - // dinv_x1 = - x[0] * dinv * dinv; - scalar dinv_x1_x0 = 2.0 * x[0] * x[1] * dinv * dinv * dinv - dinv * dinv; - d2w = f.Reverse(2, w); - // partial f_3 w.r.t x_0 - ok &= NearEqual(d2w[0 * 2 + 0], dinv + x[0] * dinv_x0, eps, eps); - // partial f_3 w.r.t x_1 - ok &= NearEqual(d2w[1 * 2 + 0], x[0] * dinv_x1, eps, eps); - // partial f_3 w.r.t. x_1, x_0 - ok &= NearEqual(d2w[0 * 2 + 1], dinv_x1 + x[0] * dinv_x1_x0, eps, eps); - // partial f_3 w.r.t. x_1, x_1 - ok &= NearEqual(d2w[1 * 2 + 1], x[0] * dinv_x1_x1, eps, eps); - // ------------------------------------------------------------------- - return ok; + bool ok = true; + using Eigen::Index; + // ------------------------------------------------------------------- + // object that computes inverse of a 2x2 matrix + atomic_eigen_mat_inv mat_inv; + // ------------------------------------------------------------------- + // declare independent variable vector x + size_t n = 2; + CPPAD_TESTVECTOR(ad_scalar) ad_x(n); + for(size_t j = 0; j < n; j++) + ad_x[j] = ad_scalar(j); + CppAD::Independent(ad_x); + // ------------------------------------------------------------------- + // arg = [ x[0] -1 ] + // [ 2 x[1] ] + size_t nr = 2; + ad_matrix ad_arg(nr, nr); + ad_arg(0, 0) = ad_x[0]; + ad_arg(0, 1) = ad_scalar(-1.0); + ad_arg(1, 0) = ad_scalar(2.0); + ad_arg(1, 1) = ad_x[1]; + // ------------------------------------------------------------------- + // use atomic operation to compute arg^{-1} + ad_matrix ad_result = mat_inv.op(ad_arg); + // ------------------------------------------------------------------- + // declare the dependent variable vector y + size_t m = 4; + CPPAD_TESTVECTOR(ad_scalar) ad_y(4); + for(size_t i = 0; i < nr; i++) + for(size_t j = 0; j < nr; j++) + ad_y[ i * nr + j ] = ad_result( Index(i), Index(j) ); + /* Used to test hand calculated derivaives + CppAD::AD ad_dinv = 1.0 / (ad_x[0] * ad_x[1] + 2.0); + ad_y[0] = ad_x[1] * ad_dinv; + ad_y[1] = 1.0 * ad_dinv; + ad_y[2] = -2.0 * ad_dinv; + ad_y[3] = ad_x[0] * ad_dinv; + */ + CppAD::ADFun f(ad_x, ad_y); + // ------------------------------------------------------------------- + // check zero order forward mode + CPPAD_TESTVECTOR(scalar) x(n), y(m); + for(size_t i = 0; i < n; i++) + x[i] = scalar(i + 2); + scalar dinv = 1.0 / (x[0] * x[1] + 2.0); + y = f.Forward(0, x); + ok &= NearEqual(y[0], x[1] * dinv, eps, eps); + ok &= NearEqual(y[1], 1.0 * dinv, eps, eps); + ok &= NearEqual(y[2], -2.0 * dinv, eps, eps); + ok &= NearEqual(y[3], x[0] * dinv, eps, eps); + // ------------------------------------------------------------------- + // check first order forward mode + CPPAD_TESTVECTOR(scalar) x1(n), y1(m); + scalar dinv_x0 = - x[1] * dinv * dinv; + x1[0] = 1.0; + x1[1] = 0.0; + y1 = f.Forward(1, x1); + ok &= NearEqual(y1[0], x[1] * dinv_x0, eps, eps); + ok &= NearEqual(y1[1], 1.0 * dinv_x0, eps, eps); + ok &= NearEqual(y1[2], -2.0 * dinv_x0, eps, eps); + ok &= NearEqual(y1[3], dinv + x[0] * dinv_x0, eps, eps); + // + scalar dinv_x1 = - x[0] * dinv * dinv; + x1[0] = 0.0; + x1[1] = 1.0; + y1 = f.Forward(1, x1); + ok &= NearEqual(y1[0], dinv + x[1] * dinv_x1, eps, eps); + ok &= NearEqual(y1[1], 1.0 * dinv_x1, eps, eps); + ok &= NearEqual(y1[2], -2.0 * dinv_x1, eps, eps); + ok &= NearEqual(y1[3], x[0] * dinv_x1, eps, eps); + // ------------------------------------------------------------------- + // check second order forward mode + CPPAD_TESTVECTOR(scalar) x2(n), y2(m); + scalar dinv_x1_x1 = 2.0 * x[0] * x[0] * dinv * dinv * dinv; + x2[0] = 0.0; + x2[1] = 0.0; + y2 = f.Forward(2, x2); + ok &= NearEqual(2.0*y2[0], 2.0*dinv_x1 + x[1]*dinv_x1_x1, eps, eps); + ok &= NearEqual(2.0*y2[1], 1.0 * dinv_x1_x1, eps, eps); + ok &= NearEqual(2.0*y2[2], -2.0 * dinv_x1_x1, eps, eps); + ok &= NearEqual(2.0*y2[3], x[0] * dinv_x1_x1, eps, eps); + // ------------------------------------------------------------------- + // check first order reverse + CPPAD_TESTVECTOR(scalar) w(m), d1w(n); + for(size_t i = 0; i < m; i++) + w[i] = 0.0; + w[0] = 1.0; + d1w = f.Reverse(1, w); + ok &= NearEqual(d1w[0], x[1] * dinv_x0, eps, eps); + ok &= NearEqual(d1w[1], dinv + x[1] * dinv_x1, eps, eps); + w[0] = 0.0; + w[1] = 1.0; + d1w = f.Reverse(1, w); + ok &= NearEqual(d1w[0], 1.0 * dinv_x0, eps, eps); + ok &= NearEqual(d1w[1], 1.0 * dinv_x1, eps, eps); + w[1] = 0.0; + w[2] = 1.0; + d1w = f.Reverse(1, w); + ok &= NearEqual(d1w[0], -2.0 * dinv_x0, eps, eps); + ok &= NearEqual(d1w[1], -2.0 * dinv_x1, eps, eps); + w[2] = 0.0; + w[3] = 1.0; + d1w = f.Reverse(1, w); + ok &= NearEqual(d1w[0], dinv + x[0] * dinv_x0, eps, eps); + ok &= NearEqual(d1w[1], x[0] * dinv_x1, eps, eps); + // ------------------------------------------------------------------- + // check second order reverse + CPPAD_TESTVECTOR(scalar) d2w(2 * n); + // dinv_x1 = - x[0] * dinv * dinv; + scalar dinv_x1_x0 = 2.0 * x[0] * x[1] * dinv * dinv * dinv - dinv * dinv; + d2w = f.Reverse(2, w); + // partial f_3 w.r.t x_0 + ok &= NearEqual(d2w[0 * 2 + 0], dinv + x[0] * dinv_x0, eps, eps); + // partial f_3 w.r.t x_1 + ok &= NearEqual(d2w[1 * 2 + 0], x[0] * dinv_x1, eps, eps); + // partial f_3 w.r.t. x_1, x_0 + ok &= NearEqual(d2w[0 * 2 + 1], dinv_x1 + x[0] * dinv_x1_x0, eps, eps); + // partial f_3 w.r.t. x_1, x_1 + ok &= NearEqual(d2w[1 * 2 + 1], x[0] * dinv_x1_x1, eps, eps); + // ------------------------------------------------------------------- + return ok; } } // END_EMPTY_NAMESPACE bool eigen_mat_inv(void) -{ bool ok = true; - ok &= non_symmetric(); - return ok; +{ bool ok = true; + ok &= non_symmetric(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/erf.cpp cppad-2019.02.00.0/test_more/general/erf.cpp --- cppad-2018.00.00.0/test_more/general/erf.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/erf.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,240 +1,241 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include namespace { - // --------------------------------------------------------------------- - bool old_example(void) - { bool ok = true; - using namespace CppAD; - using CppAD::atan; - using CppAD::exp; - using CppAD::sqrt; -# if CPPAD_USE_CPLUSPLUS_2011 - double eps = 100.0 * std::numeric_limits::epsilon(); -# endif - // Construct function object corresponding to erf - CPPAD_TESTVECTOR(AD) ax(1); - CPPAD_TESTVECTOR(AD) ay(1); - ax[0] = 0.; - Independent(ax); - ay[0] = erf(ax[0]); - ADFun f(ax, ay); - - // Construct function object corresponding to derivative of erf - Independent(ax); - double pi = 4.0 * atan(1.0); - ay[0] = exp( - ax[0] * ax[0] ) * 2.0 / sqrt(pi); - ADFun df(ax, ay); - - // vectors to use with function object - CPPAD_TESTVECTOR(double) x0(1), y0(1), x1(1), y1(1), check(1); - - // check value at zero - x0[0] = 1.5; - y0 = f.Forward(0, x0); - check[0] = 0.96611; - ok &= std::fabs(check[0] - y0[0]) <= 4e-4; - - // check the derivative of error function - x1[0] = 1.0; - y1 = f.Forward(1, x1); - check = df.Forward(0, x0); - ok &= NearEqual(check[0], y1[0], 0., 2e-3); -# if CPPAD_USE_CPLUSPLUS_2011 - ok &= NearEqual(check[0], y1[0], eps, eps); -# endif - - // check second derivative - CPPAD_TESTVECTOR(double) x2(1), y2(1); - x2[0] = 0.0; - y2 = f.Forward(2, x2); - check = df.Forward(1, x1); - ok &= NearEqual(check[0] / 2.0, y2[0], 0., 2e-3); -# if CPPAD_USE_CPLUSPLUS_2011 - ok &= NearEqual(check[0] / 2.0, y2[0], eps, eps); -# endif - - // check third derivative - CPPAD_TESTVECTOR(double) x3(1), y3(1); - x3[0] = 0.0; - y3 = f.Forward(3, x3); - check = df.Forward(2, x2); - ok &= NearEqual(check[0] / 3.0, y3[0], 0., 2e-3); -# if CPPAD_USE_CPLUSPLUS_2011 - ok &= NearEqual(check[0] / 3.0, y3[0], eps, eps); -# endif - - // check 4-th order of reverse mode - CPPAD_TESTVECTOR(double) w(1), dy(4), x4(1), y4(1); - x4[0] = 0.0; - w[0] = 1.0; - dy = f.Reverse(4, w); - y4 = f.Forward(4, x4); - // - ok &= NearEqual(dy[0], y1[0], 0., 2e-3); -# 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_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_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_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(); - using CppAD::vector; - using CppAD::AD; - - size_t n = 2; - size_t m = 1; - vector x(n), w(m); - w[0] = 1.0; - vector< AD > ax(n), ay(m); - ax[0] = x[0] = 0.5; - ax[1] = x[1] = 0.0; - - // construct function - CppAD::Independent(ax); - ay[0] = erf( 2.0 * ax[0] ); - CppAD::ADFun f(ax, ay); - - // dense hessian - vector dense_hess = f.Hessian(x, 0); - - // sparse_hessian - vector sparse_hess = f.SparseHessian(x, w); - - // Define g(u) = erf(2 * u) - // g'(u) = 2 * erf'(2 * u) - // = 2 * exp( - 2 * u * 2 * u ) * 2 / sqrt(pi) - // = exp( - 4 * u * u ) * 4 / sqrt(pi) - // g''(u) = - exp( - 4 * u * u ) * 32 * u / sqrt(pi) - double root_pi = std::sqrt( 4.0 * atan(1.0) ); - double check = -std::exp(-4.0 * x[0] * x[0]) * 32.0 * x[0] / root_pi; - - ok &= CppAD::NearEqual(dense_hess[0], check, eps, eps); - ok &= CppAD::NearEqual(sparse_hess[0], check, eps, eps); - - for(size_t k = 1; k < n * n; k++) - { ok &= CppAD::NearEqual(dense_hess[k], 0.0, eps, eps); - ok &= CppAD::NearEqual(sparse_hess[k], 0.0, eps, eps); - } - return ok; - } - // --------------------------------------------------------------------- - bool mul_dir(void) - { bool ok = true; - using namespace CppAD; - using CppAD::atan; - using CppAD::exp; - using CppAD::sqrt; - double eps = 100.0 * std::numeric_limits::epsilon(); - - // Construct function object corresponding to erf - CPPAD_TESTVECTOR(AD) ax(1); - CPPAD_TESTVECTOR(AD) ay(1); - ax[0] = 0.; - Independent(ax); - ay[0] = erf(ax[0]); - ADFun f(ax, ay); - - // Construct function object corresponding to derivative of erf - Independent(ax); - double pi = 4.0 * atan(1.0); - ay[0] = exp( - ax[0] * ax[0] ) * 2.0 / sqrt(pi); - ADFun df(ax, ay); - - // number of directions - size_t r = 1; - - // vectors to use with objects - CPPAD_TESTVECTOR(double) x0(1), y0(1), x1(1), y1(1), y2(1), y3(1); - CPPAD_TESTVECTOR(double) zero(1), check(1); - CPPAD_TESTVECTOR(double) xq(r), yq(r), checkq(r), zeroq(r); - - // check function value - x0[0] = 1.5; - y0 = f.Forward(0, x0); - check[0] = 0.9661051464753108; - double tmp = std::max(1e-15, eps); - ok &= NearEqual(check[0], y0[0], 0.0, tmp); - - // check first order derivative - x1[0] = 1.0; - y1 = f.Forward(1, x1); - check = df.Forward(0, x0); - ok &= NearEqual(check[0], y1[0], eps, eps); - for(size_t ell = 0.0; ell < r; ell++) - { xq[ell] = x1[ell] / double(ell + 1); - zeroq[ell] = 0.0; - } - yq = f.Forward(1, r, xq); - for(size_t ell = 0.0; ell < r; ell++) - { checkq[ell] = check[0] * xq[ell]; - ok &= NearEqual(checkq[ell], yq[ell], eps, eps); - } - - // check second order derivative - zero[0] = 0.0; - y2 = f.Forward(2, zero); - check = df.Forward(1, x1); - check[0] /= 2.0; - ok &= NearEqual(check[0], y2[0], eps, eps); - yq = f.Forward(2, r, zeroq); - for(size_t ell = 0.0; ell < r; ell++) - { checkq[ell] = check[0] * xq[ell]; - ok &= NearEqual(checkq[ell], yq[ell], eps, eps); - } - - // check third order derivative - zero[0] = 0.0; - y3 = f.Forward(3, zero); - check = df.Forward(2, zero); - check[0] /= 3.0; - ok &= NearEqual(check[0], y3[0], eps, eps); - yq = f.Forward(3, r, zeroq); - for(size_t ell = 0.0; ell < r; ell++) - { checkq[ell] = check[0] * xq[ell]; - ok &= NearEqual(checkq[ell], yq[ell], eps, eps); - } - - return ok; - } - // ------------------------------------------------------------------- + // --------------------------------------------------------------------- + bool old_example(void) + { bool ok = true; + using namespace CppAD; + using CppAD::atan; + using CppAD::exp; + using CppAD::sqrt; +# if CPPAD_USE_CPLUSPLUS_2011 + double eps = 100.0 * std::numeric_limits::epsilon(); +# endif + // Construct function object corresponding to erf + CPPAD_TESTVECTOR(AD) ax(1); + CPPAD_TESTVECTOR(AD) ay(1); + ax[0] = 0.; + Independent(ax); + ay[0] = erf(ax[0]); + ADFun f(ax, ay); + + // Construct function object corresponding to derivative of erf + Independent(ax); + double pi = 4.0 * atan(1.0); + ay[0] = exp( - ax[0] * ax[0] ) * 2.0 / sqrt(pi); + ADFun df(ax, ay); + + // vectors to use with function object + CPPAD_TESTVECTOR(double) x0(1), y0(1), x1(1), y1(1), check(1); + + // check value at zero + x0[0] = 1.5; + y0 = f.Forward(0, x0); + check[0] = 0.96611; + ok &= std::fabs(check[0] - y0[0]) <= 4e-4; + + // check the derivative of error function + x1[0] = 1.0; + y1 = f.Forward(1, x1); + check = df.Forward(0, x0); + ok &= NearEqual(check[0], y1[0], 0., 2e-3); +# if CPPAD_USE_CPLUSPLUS_2011 + ok &= NearEqual(check[0], y1[0], eps, eps); +# endif + + // check second derivative + CPPAD_TESTVECTOR(double) x2(1), y2(1); + x2[0] = 0.0; + y2 = f.Forward(2, x2); + check = df.Forward(1, x1); + ok &= NearEqual(check[0] / 2.0, y2[0], 0., 2e-3); +# if CPPAD_USE_CPLUSPLUS_2011 + ok &= NearEqual(check[0] / 2.0, y2[0], eps, eps); +# endif + + // check third derivative + CPPAD_TESTVECTOR(double) x3(1), y3(1); + x3[0] = 0.0; + y3 = f.Forward(3, x3); + check = df.Forward(2, x2); + ok &= NearEqual(check[0] / 3.0, y3[0], 0., 2e-3); +# if CPPAD_USE_CPLUSPLUS_2011 + ok &= NearEqual(check[0] / 3.0, y3[0], eps, eps); +# endif + + // check 4-th order of reverse mode + CPPAD_TESTVECTOR(double) w(1), dy(4), x4(1), y4(1); + x4[0] = 0.0; + w[0] = 1.0; + dy = f.Reverse(4, w); + y4 = f.Forward(4, x4); + // + ok &= NearEqual(dy[0], y1[0], 0., 2e-3); +# 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_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_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_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(); + using CppAD::vector; + using CppAD::AD; + + size_t n = 2; + size_t m = 1; + vector x(n), w(m); + w[0] = 1.0; + vector< AD > ax(n), ay(m); + ax[0] = x[0] = 0.5; + ax[1] = x[1] = 0.0; + + // construct function + CppAD::Independent(ax); + ay[0] = erf( 2.0 * ax[0] ); + CppAD::ADFun f(ax, ay); + + // dense hessian + vector dense_hess = f.Hessian(x, 0); + + // sparse_hessian + vector sparse_hess = f.SparseHessian(x, w); + + // Define g(u) = erf(2 * u) + // g'(u) = 2 * erf'(2 * u) + // = 2 * exp( - 2 * u * 2 * u ) * 2 / sqrt(pi) + // = exp( - 4 * u * u ) * 4 / sqrt(pi) + // g''(u) = - exp( - 4 * u * u ) * 32 * u / sqrt(pi) + double root_pi = std::sqrt( 4.0 * atan(1.0) ); + double check = -std::exp(-4.0 * x[0] * x[0]) * 32.0 * x[0] / root_pi; + + ok &= CppAD::NearEqual(dense_hess[0], check, eps, eps); + ok &= CppAD::NearEqual(sparse_hess[0], check, eps, eps); + + for(size_t k = 1; k < n * n; k++) + { ok &= CppAD::NearEqual(dense_hess[k], 0.0, eps, eps); + ok &= CppAD::NearEqual(sparse_hess[k], 0.0, eps, eps); + } + return ok; + } + // --------------------------------------------------------------------- + bool mul_dir(void) + { bool ok = true; + using namespace CppAD; + using CppAD::atan; + using CppAD::exp; + using CppAD::sqrt; + double eps = 100.0 * std::numeric_limits::epsilon(); + + // Construct function object corresponding to erf + CPPAD_TESTVECTOR(AD) ax(1); + CPPAD_TESTVECTOR(AD) ay(1); + ax[0] = 0.; + Independent(ax); + ay[0] = erf(ax[0]); + ADFun f(ax, ay); + + // Construct function object corresponding to derivative of erf + Independent(ax); + double pi = 4.0 * atan(1.0); + ay[0] = exp( - ax[0] * ax[0] ) * 2.0 / sqrt(pi); + ADFun df(ax, ay); + + // number of directions + size_t r = 1; + + // vectors to use with objects + CPPAD_TESTVECTOR(double) x0(1), y0(1), x1(1), y1(1), y2(1), y3(1); + CPPAD_TESTVECTOR(double) zero(1), check(1); + CPPAD_TESTVECTOR(double) xq(r), yq(r), checkq(r), zeroq(r); + + // check function value + x0[0] = 1.5; + y0 = f.Forward(0, x0); + check[0] = 0.9661051464753108; + double tmp = std::max(1e-15, eps); + ok &= NearEqual(check[0], y0[0], 0.0, tmp); + + // check first order derivative + x1[0] = 1.0; + y1 = f.Forward(1, x1); + check = df.Forward(0, x0); + ok &= NearEqual(check[0], y1[0], eps, eps); + for(size_t ell = 0; ell < r; ell++) + { xq[ell] = x1[ell] / double(ell + 1); + zeroq[ell] = 0.0; + } + yq = f.Forward(1, r, xq); + for(size_t ell = 0.0; ell < r; ell++) + { checkq[ell] = check[0] * xq[ell]; + ok &= NearEqual(checkq[ell], yq[ell], eps, eps); + } + + // check second order derivative + zero[0] = 0.0; + y2 = f.Forward(2, zero); + check = df.Forward(1, x1); + check[0] /= 2.0; + ok &= NearEqual(check[0], y2[0], eps, eps); + yq = f.Forward(2, r, zeroq); + for(size_t ell = 0.0; ell < r; ell++) + { checkq[ell] = check[0] * xq[ell]; + ok &= NearEqual(checkq[ell], yq[ell], eps, eps); + } + + // check third order derivative + zero[0] = 0.0; + y3 = f.Forward(3, zero); + check = df.Forward(2, zero); + check[0] /= 3.0; + ok &= NearEqual(check[0], y3[0], eps, eps); + yq = f.Forward(3, r, zeroq); + for(size_t ell = 0; ell < r; ell++) + { checkq[ell] = check[0] * xq[ell]; + ok &= NearEqual(checkq[ell], yq[ell], eps, eps); + } + + return ok; + } + // ------------------------------------------------------------------- # endif } bool erf(void) -{ bool ok = true; - ok &= old_example(); +{ bool ok = true; + ok &= old_example(); # if CPPAD_USE_CPLUSPLUS_2011 - ok &= hessian(); - ok &= mul_dir(); + ok &= hessian(); + ok &= mul_dir(); # endif - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/exp.cpp cppad-2019.02.00.0/test_more/general/exp.cpp --- cppad-2018.00.00.0/test_more/general/exp.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/exp.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Two old exp example now used just for validation testing. @@ -19,125 +20,125 @@ namespace { // BEGIN empty namespace bool ExpTestOne(void) -{ bool ok = true; - using CppAD::exp; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(1); - size_t s = 0; - U[s] = 1.; - Independent(U); - - // dependent variable vector, indices, and values - CPPAD_TESTVECTOR(AD) Z(2); - size_t x = 0; - size_t y = 1; - Z[x] = exp(U[s]); - Z[y] = exp(Z[x]); - - // define f : U -> Z and vectors for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // check values - ok &= NearEqual(Z[x] , exp(1.), eps99 , eps99); - ok &= NearEqual(Z[y] , exp( exp(1.) ), eps99 , eps99); - - // forward computation of partials w.r.t. s - v[s] = 1.; - w = f.Forward(1, v); - ok &= NearEqual(w[x], Z[x], eps99 , eps99); // dx/ds - ok &= NearEqual(w[y], Z[y] * Z[x], eps99 , eps99); // dy/ds - - // reverse computation of partials of y - w[x] = 0.; - w[y] = 1.; - v = f.Reverse(1,w); - ok &= NearEqual(v[s], Z[y] * Z[x], eps99 , eps99); // dy/ds - - // 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] , - Z[y] * Z[x] * Z[x] + Z[y] * Z[x], - eps99 , - eps99 - ); - - // reverse computation of second partials of y - CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); - w[x] = 0.; - w[y] = 1.; - r = f.Reverse(2, w); - ok &= NearEqual( // d^2 y / (ds ds) - r[2 * s + 1] , - Z[y] * Z[x] * Z[x] + Z[y] * Z[x], - eps99 , - eps99 - ); +{ bool ok = true; + using CppAD::exp; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(1); + size_t s = 0; + U[s] = 1.; + Independent(U); + + // dependent variable vector, indices, and values + CPPAD_TESTVECTOR(AD) Z(2); + size_t x = 0; + size_t y = 1; + Z[x] = exp(U[s]); + Z[y] = exp(Z[x]); + + // define f : U -> Z and vectors for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // check values + ok &= NearEqual(Z[x] , exp(1.), eps99 , eps99); + ok &= NearEqual(Z[y] , exp( exp(1.) ), eps99 , eps99); + + // forward computation of partials w.r.t. s + v[s] = 1.; + w = f.Forward(1, v); + ok &= NearEqual(w[x], Z[x], eps99 , eps99); // dx/ds + ok &= NearEqual(w[y], Z[y] * Z[x], eps99 , eps99); // dy/ds + + // reverse computation of partials of y + w[x] = 0.; + w[y] = 1.; + v = f.Reverse(1,w); + ok &= NearEqual(v[s], Z[y] * Z[x], eps99 , eps99); // dy/ds + + // 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] , + Z[y] * Z[x] * Z[x] + Z[y] * Z[x], + eps99 , + eps99 + ); + + // reverse computation of second partials of y + CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); + w[x] = 0.; + w[y] = 1.; + r = f.Reverse(2, w); + ok &= NearEqual( // d^2 y / (ds ds) + r[2 * s + 1] , + Z[y] * Z[x] * Z[x] + Z[y] * Z[x], + eps99 , + eps99 + ); - return ok; + return ok; } bool ExpTestTwo(void) -{ bool ok = true; - using CppAD::exp; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(1); - U[0] = 1.; - Independent(U); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = exp(U[0]); - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - double exp_u = exp( Value(U[0]) ); - ok &= NearEqual(exp_u, Value(Z[0]), eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { w = f.Forward(j, v); - jfac *= double(j); - ok &= NearEqual(jfac*w[0], exp_u, eps99 , eps99); // d^jz/du^j - v[0] = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - for(j = 0; j < p; j++) - { ok &= NearEqual(jfac*r[j], exp_u, eps99 , eps99); // d^jz/du^j - jfac *= double(j + 1); - } +{ bool ok = true; + using CppAD::exp; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(1); + U[0] = 1.; + Independent(U); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Z(1); + Z[0] = exp(U[0]); + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + double exp_u = exp( Value(U[0]) ); + ok &= NearEqual(exp_u, Value(Z[0]), eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { w = f.Forward(j, v); + jfac *= double(j); + ok &= NearEqual(jfac*w[0], exp_u, eps99 , eps99); // d^jz/du^j + v[0] = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + for(j = 0; j < p; j++) + { ok &= NearEqual(jfac*r[j], exp_u, eps99 , eps99); // d^jz/du^j + jfac *= double(j + 1); + } - return ok; + return ok; } } // END empty namespace bool Exp(void) -{ bool ok = true; - ok &= ExpTestOne(); - ok &= ExpTestTwo(); - return ok; +{ bool ok = true; + ok &= ExpTestOne(); + ok &= ExpTestTwo(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/expm1.cpp cppad-2019.02.00.0/test_more/general/expm1.cpp --- cppad-2018.00.00.0/test_more/general/expm1.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/expm1.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,72 +1,73 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include bool expm1(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; + using CppAD::AD; + using CppAD::NearEqual; - // 10 times machine epsilon - double eps = 10. * std::numeric_limits::epsilon(); + // 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); + // 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/extern_value.cpp cppad-2019.02.00.0/test_more/general/extern_value.cpp --- cppad-2018.00.00.0/test_more/general/extern_value.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/extern_value.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include # include "extern_value.hpp" @@ -16,15 +17,15 @@ template extern_value::extern_value(Type value) -{ value_ = value; } +{ value_ = value; } template void extern_value::set(Type value) -{ value_ = value; } +{ value_ = value; } template Type extern_value::get(void) -{ return value_; } +{ return value_; } INSTANTIATE( float ); INSTANTIATE( double ); diff -Nru cppad-2018.00.00.0/test_more/general/extern_value.hpp cppad-2019.02.00.0/test_more/general/extern_value.hpp --- cppad-2018.00.00.0/test_more/general/extern_value.hpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/extern_value.hpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,25 +1,25 @@ +# ifndef CPPAD_TEST_MORE_GENERAL_EXTERN_VALUE_HPP +# define CPPAD_TEST_MORE_GENERAL_EXTERN_VALUE_HPP /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. -# ifndef CPPAD_TEST_MORE_GENERAL_EXTERN_VALUE_HPP -# define CPPAD_TEST_MORE_GENERAL_EXTERN_VALUE_HPP +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ template class extern_value { private: - Type value_; + Type value_; public: - extern_value(Type value); - void set(Type value); - Type get(void); + extern_value(Type value); + void set(Type value); + Type get(void); }; # endif diff -Nru cppad-2018.00.00.0/test_more/general/fabs.cpp cppad-2019.02.00.0/test_more/general/fabs.cpp --- cppad-2018.00.00.0/test_more/general/fabs.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/fabs.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test of directional derivative in AD< AD< double > > case. @@ -17,57 +18,57 @@ bool fabs(void) -{ // test if CppAD::abs uses if statement during forward computations - bool ok = true; +{ // test if CppAD::abs uses if statement during forward computations + bool ok = true; - using CppAD::Independent; - using CppAD::ADFun; - typedef CppAD::AD ADdouble; - typedef CppAD::AD< ADdouble > ADDdouble; - - // af(x) = |x| - CPPAD_TESTVECTOR( ADDdouble ) aax(1), aay(1); - aax[0] = ADDdouble(0.); - CppAD::Independent(aax); - aay[0] = fabs(aax[0]); - CppAD::ADFun< ADdouble > af(aax, aay); - - // f(x) = |x| - CPPAD_TESTVECTOR( ADdouble ) ax(1), ay(1); - ax[0] = ADdouble(0.); - CppAD::Independent(ax); - ay = af.Forward(0, ax); - CppAD::ADFun f(ax, ay); - - // compute derivative of af at a positive argument - CPPAD_TESTVECTOR( ADdouble ) adx(1), ady(1); - ax[0] = 1.; - ay = af.Forward(0, ax); - adx[0] = 1; - ady = af.Forward(1, adx); - ok &= (ady[0] == 1.); - - // compute derivative of af at a zero argument - ax[0] = 0.; - ay = af.Forward(0, ax); - adx[0] = 1; - ady = af.Forward(1, adx); - ok &= (ady[0] == 0.); - - // compute derivative of f at zero argument - CPPAD_TESTVECTOR(double) x(1), y(1), dx(1), dy(1); - x[0] = 0.; - y = f.Forward(0, x); - dx[0] = 1; - dy = f.Forward(1, dx); - ok &= (dy[0] == 0.); - - // compute derivative of af at a negative argument - x[0] = -1.; - y = f.Forward(0, x); - dx[0] = 1; - dy = f.Forward(1, dx); - ok &= (dy[0] == -1.); + using CppAD::Independent; + using CppAD::ADFun; + typedef CppAD::AD ADdouble; + typedef CppAD::AD< ADdouble > ADDdouble; + + // af(x) = |x| + CPPAD_TESTVECTOR( ADDdouble ) aax(1), aay(1); + aax[0] = ADDdouble(0.); + CppAD::Independent(aax); + aay[0] = fabs(aax[0]); + CppAD::ADFun< ADdouble > af(aax, aay); + + // f(x) = |x| + CPPAD_TESTVECTOR( ADdouble ) ax(1), ay(1); + ax[0] = ADdouble(0.); + CppAD::Independent(ax); + ay = af.Forward(0, ax); + CppAD::ADFun f(ax, ay); + + // compute derivative of af at a positive argument + CPPAD_TESTVECTOR( ADdouble ) adx(1), ady(1); + ax[0] = 1.; + ay = af.Forward(0, ax); + adx[0] = 1; + ady = af.Forward(1, adx); + ok &= (ady[0] == 1.); + + // compute derivative of af at a zero argument + ax[0] = 0.; + ay = af.Forward(0, ax); + adx[0] = 1; + ady = af.Forward(1, adx); + ok &= (ady[0] == 0.); + + // compute derivative of f at zero argument + CPPAD_TESTVECTOR(double) x(1), y(1), dx(1), dy(1); + x[0] = 0.; + y = f.Forward(0, x); + dx[0] = 1; + dy = f.Forward(1, dx); + ok &= (dy[0] == 0.); + + // compute derivative of af at a negative argument + x[0] = -1.; + y = f.Forward(0, x); + dx[0] = 1; + dy = f.Forward(1, dx); + ok &= (dy[0] == -1.); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/for_hess.cpp cppad-2019.02.00.0/test_more/general/for_hess.cpp --- cppad-2018.00.00.0/test_more/general/for_hess.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/for_hess.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* @@ -18,91 +19,91 @@ bool ForHess(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; - using CppAD::exp; - using CppAD::sin; - using CppAD::cos; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - size_t i; - - // create independent variable vector with assigned values - CPPAD_TESTVECTOR(double) u0(3); - CPPAD_TESTVECTOR(AD) U(3); - for(i = 0; i < 3; i++) - U[i] = u0[i] = double(i+1); - Independent( U ); - - // define the function - CPPAD_TESTVECTOR(AD) Y(2); - Y[0] = U[0] * exp( U[1] ); - 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 - 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] - H0[2] = 0.; // d^2 y[0] / d_u[0] d_u[2] - - H0[4] = u0[0] * exp( u0[1] ); // d^2 y[0] / d_u[1] d_u[1] - H0[5] = 0.; // d^2 y[0] / d_u[1] d_u[2] - - H0[8] = 0.; // d^2 y[0] / d_u[2] d_u[2] - - // formulas for the upper triangle of Hessian of F_1 - CPPAD_TESTVECTOR(double) H1(9); - H1[0] = 0.; // d^2 Y[1] / d_U[0] d_U[0] - H1[1] = 0.; // d^2 Y[1] / d_U[0] d_U[1] - H1[2] = 0.; // d^2 Y[1] / d_U[0] d_U[2] - - H1[4] = 0.; // d^2 Y[1] / d_U[1] d_U[1] - H1[5] = cos( u0[2] ); // d^2 Y[1] / d_U[1] d_U[2] - - H1[8] = - u0[1] * sin( u0[2] );// d^2 Y[1] / d_U[2] d_U[2] - - - // Define U(t) = u0 + u1 t + u2 t^2 / 2 - CPPAD_TESTVECTOR(double) u1(3); - CPPAD_TESTVECTOR(double) u2(3); - for(i = 0; i < 3; i++) - u1[i] = u2[i] = 0.; - - size_t j; - for(i = 0; i < 3; i++) - { // diagonal of Hessians in i-th coordiante direction - u1[i] = 1.; - F.Forward(1, u1); - CPPAD_TESTVECTOR(double) Di = F.Forward(2, u2); - ok &= NearEqual( 2. * Di[0] , H0[ i + 3 * i], eps99, eps99); - ok &= NearEqual( 2. * Di[1] , H1[ i + 3 * i], eps99, eps99); - // - for(j = i+1; j < 3; j++) - { // cross term in i and j direction - u1[j] = 1.; - F.Forward(1, u1); - CPPAD_TESTVECTOR(double) Cij = F.Forward(2, u2); - - // diagonal of Hessian in j-th coordinate direction - u1[i] = 0.; - F.Forward(1, u1); - CPPAD_TESTVECTOR(double) Dj = F.Forward(2, u2); - - // (i, j) elements of the Hessians - double H0ij = Cij[0] - Di[0] - Dj[0]; - ok &= NearEqual( H0ij, H0[j + 3 * i], eps99, eps99); - double H1ij = Cij[1] - Di[1] - Dj[1]; - ok &= NearEqual( H1ij, H1[j + 3 * i], eps99, eps99); - - // reset all components of u1 to zero - u1[j] = 0.; - } - } + using namespace CppAD; + using CppAD::exp; + using CppAD::sin; + using CppAD::cos; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + size_t i; + + // create independent variable vector with assigned values + CPPAD_TESTVECTOR(double) u0(3); + CPPAD_TESTVECTOR(AD) U(3); + for(i = 0; i < 3; i++) + U[i] = u0[i] = double(i+1); + Independent( U ); + + // define the function + CPPAD_TESTVECTOR(AD) Y(2); + Y[0] = U[0] * exp( U[1] ); + 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 + 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] + H0[2] = 0.; // d^2 y[0] / d_u[0] d_u[2] + + H0[4] = u0[0] * exp( u0[1] ); // d^2 y[0] / d_u[1] d_u[1] + H0[5] = 0.; // d^2 y[0] / d_u[1] d_u[2] + + H0[8] = 0.; // d^2 y[0] / d_u[2] d_u[2] + + // formulas for the upper triangle of Hessian of F_1 + CPPAD_TESTVECTOR(double) H1(9); + H1[0] = 0.; // d^2 Y[1] / d_U[0] d_U[0] + H1[1] = 0.; // d^2 Y[1] / d_U[0] d_U[1] + H1[2] = 0.; // d^2 Y[1] / d_U[0] d_U[2] + + H1[4] = 0.; // d^2 Y[1] / d_U[1] d_U[1] + H1[5] = cos( u0[2] ); // d^2 Y[1] / d_U[1] d_U[2] + + H1[8] = - u0[1] * sin( u0[2] );// d^2 Y[1] / d_U[2] d_U[2] + + + // Define U(t) = u0 + u1 t + u2 t^2 / 2 + CPPAD_TESTVECTOR(double) u1(3); + CPPAD_TESTVECTOR(double) u2(3); + for(i = 0; i < 3; i++) + u1[i] = u2[i] = 0.; + + size_t j; + for(i = 0; i < 3; i++) + { // diagonal of Hessians in i-th coordiante direction + u1[i] = 1.; + F.Forward(1, u1); + CPPAD_TESTVECTOR(double) Di = F.Forward(2, u2); + ok &= NearEqual( 2. * Di[0] , H0[ i + 3 * i], eps99, eps99); + ok &= NearEqual( 2. * Di[1] , H1[ i + 3 * i], eps99, eps99); + // + for(j = i+1; j < 3; j++) + { // cross term in i and j direction + u1[j] = 1.; + F.Forward(1, u1); + CPPAD_TESTVECTOR(double) Cij = F.Forward(2, u2); + + // diagonal of Hessian in j-th coordinate direction + u1[i] = 0.; + F.Forward(1, u1); + CPPAD_TESTVECTOR(double) Dj = F.Forward(2, u2); + + // (i, j) elements of the Hessians + double H0ij = Cij[0] - Di[0] - Dj[0]; + ok &= NearEqual( H0ij, H0[j + 3 * i], eps99, eps99); + double H1ij = Cij[1] - Di[1] - Dj[1]; + ok &= NearEqual( H1ij, H1[j + 3 * i], eps99, eps99); + + // reset all components of u1 to zero + u1[j] = 0.; + } + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/for_sparse_hes.cpp cppad-2019.02.00.0/test_more/general/for_sparse_hes.cpp --- cppad-2018.00.00.0/test_more/general/for_sparse_hes.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/for_sparse_hes.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include @@ -15,128 +16,128 @@ namespace { // Begin empty namespace bool test_one() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 14; + // dimension of the domain space + size_t n = 14; - // dimension of the range space - size_t m = 1; + // dimension of the range space + size_t m = 1; - // temporary indices - size_t i, j; - - // for testing load and store operations - CppAD::VecAD ad_vec(2); - ad_vec[0] = 3.0; - ad_vec[1] = 4.0; - - // initialize check values to false - CPPAD_TESTVECTOR(bool) check(n * n); - for(j = 0; j < n * n; j++) - check[j] = false; - - // independent variable vector - CPPAD_TESTVECTOR(AD) ax(n); - for(j = 0; j < n; j++) - ax[j] = AD(j); - Independent(ax); - - // accumulate sum here - AD sum(0.); - - // first operand - size_t F = 0; - - // ad_vec[variable] when ad_vec is a parameter - sum += ad_vec[ax[F]]; // use fact ax[F] is zero - F += 1; - - // ad_vec[parameter] when ad_vec depends on a variable - // (CppAD sparsity does not separate elements of ad_vec) - ad_vec[ AD(0) ] = ax[F] * ax[F]; - sum += ad_vec[ ax[F] ]; // user fact that ax[F] is one - check[F * n + F] = true; - F += 1; - - // parameter / variable - sum += 2.0 / ax[F]; - check[F * n + F] = true; - F += 1; - - // erf(variable) - sum += erf( ax[F] ); - check[F * n + F] = true; - F += 1; - - // pow(parameter, variable) - sum += pow( 2.0 , ax[F] ); - check[F * n + F] = true; - F += 1; - - // pow(variable, parameter) - sum += pow( ax[F] , 2.0 ); - check[F * n + F] = true; - F += 1; - // second operand - size_t S = F + 1; - - // variable * variable - sum += ax[F] * ax[S]; - check[F * n + S] = check[S * n + F] = true; - F += 2; - S += 2; - - // azmul(variable, variable) - sum += azmul(ax[F], ax[S]); - check[F * n + S] = check[S * n + F] = true; - F += 2; - S += 2; - - // variable / variable - sum += ax[F] / ax[S]; - check[F * n + S] = check[S * n + F] = check[S * n + S] = true; - F += 2; - S += 2; - - // pow( variable , variable ) - sum += pow( ax[F] , ax[S] ); - check[F * n + F] = check[S * n + S] = true; - check[F * n + S] = check[S * n + F] = true; - F += 2; - S += 2; - - ok &= F == n; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = sum; - - // create function object f : x -> y - ADFun f(ax, ay); - - // ------------------------------------------------------------------ - // compute sparsity - CPPAD_TESTVECTOR(bool) r(n), s(m), h(n * n); - for(j = 0; j < n; j++) - r[j] = true; - for(i = 0; i < m; i++) - s[i] = true; - h = f.ForSparseHes(r, s); - // check result - for(i = 0; i < n; i++) - for(j = 0; j < n; j++) - ok &= h[i * n + j] == check[i * n + j]; - // ------------------------------------------------------------------ + // temporary indices + size_t i, j; + + // for testing load and store operations + CppAD::VecAD ad_vec(2); + ad_vec[0] = 3.0; + ad_vec[1] = 4.0; + + // initialize check values to false + CPPAD_TESTVECTOR(bool) check(n * n); + for(j = 0; j < n * n; j++) + check[j] = false; + + // independent variable vector + CPPAD_TESTVECTOR(AD) ax(n); + for(j = 0; j < n; j++) + ax[j] = AD(j); + Independent(ax); + + // accumulate sum here + AD sum(0.); + + // first operand + size_t F = 0; + + // ad_vec[variable] when ad_vec is a parameter + sum += ad_vec[ax[F]]; // use fact ax[F] is zero + F += 1; + + // ad_vec[parameter] when ad_vec depends on a variable + // (CppAD sparsity does not separate elements of ad_vec) + ad_vec[ AD(0) ] = ax[F] * ax[F]; + sum += ad_vec[ ax[F] ]; // user fact that ax[F] is one + check[F * n + F] = true; + F += 1; + + // parameter / variable + sum += 2.0 / ax[F]; + check[F * n + F] = true; + F += 1; + + // erf(variable) + sum += erf( ax[F] ); + check[F * n + F] = true; + F += 1; + + // pow(parameter, variable) + sum += pow( 2.0 , ax[F] ); + check[F * n + F] = true; + F += 1; + + // pow(variable, parameter) + sum += pow( ax[F] , 2.0 ); + check[F * n + F] = true; + F += 1; + // second operand + size_t S = F + 1; + + // variable * variable + sum += ax[F] * ax[S]; + check[F * n + S] = check[S * n + F] = true; + F += 2; + S += 2; + + // azmul(variable, variable) + sum += azmul(ax[F], ax[S]); + check[F * n + S] = check[S * n + F] = true; + F += 2; + S += 2; + + // variable / variable + sum += ax[F] / ax[S]; + check[F * n + S] = check[S * n + F] = check[S * n + S] = true; + F += 2; + S += 2; + + // pow( variable , variable ) + sum += pow( ax[F] , ax[S] ); + check[F * n + F] = check[S * n + S] = true; + check[F * n + S] = check[S * n + F] = true; + F += 2; + S += 2; + + ok &= F == n; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = sum; + + // create function object f : x -> y + ADFun f(ax, ay); + + // ------------------------------------------------------------------ + // compute sparsity + CPPAD_TESTVECTOR(bool) r(n), s(m), h(n * n); + for(j = 0; j < n; j++) + r[j] = true; + for(i = 0; i < m; i++) + s[i] = true; + h = f.ForSparseHes(r, s); + // check result + for(i = 0; i < n; i++) + for(j = 0; j < n; j++) + ok &= h[i * n + j] == check[i * n + j]; + // ------------------------------------------------------------------ - return ok; + return ok; } } // End of empty namespace bool for_sparse_hes(void) -{ bool ok = true; +{ bool ok = true; - ok &= test_one(); + ok &= test_one(); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/for_sparse_jac.cpp cppad-2019.02.00.0/test_more/general/for_sparse_jac.cpp --- cppad-2018.00.00.0/test_more/general/for_sparse_jac.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/for_sparse_jac.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include @@ -15,486 +16,486 @@ # include # define CheckOp(Op) \ - Y[index] = X[0] Op 2.; \ - Check[index * n + 0] = true; \ - Check[index * n + 1] = false; \ - Check[index * n + 2] = false; \ - index++; \ - Y[index] = X[0] Op X[1]; \ - Check[index * n + 0] = true; \ - Check[index * n + 1] = true; \ - Check[index * n + 2] = false; \ - index++; \ - Y[index] = 3. Op X[1]; \ - Check[index * n + 0] = false; \ - Check[index * n + 1] = true; \ - Check[index * n + 2] = false; \ - index++; + Y[index] = X[0] Op 2.; \ + Check[index * n + 0] = true; \ + Check[index * n + 1] = false; \ + Check[index * n + 2] = false; \ + index++; \ + Y[index] = X[0] Op X[1]; \ + Check[index * n + 0] = true; \ + Check[index * n + 1] = true; \ + Check[index * n + 2] = false; \ + index++; \ + Y[index] = 3. Op X[1]; \ + Check[index * n + 0] = false; \ + Check[index * n + 1] = true; \ + Check[index * n + 2] = false; \ + index++; # define CheckUnaryFun(Fun) \ - Y[index] = Fun(X[0]); \ - Check[index * n + 0] = true; \ - Check[index * n + 1] = false; \ - Check[index * n + 2] = false; \ - index++; \ - Y[index] = Fun(X[0] + X[1]); \ - Check[index * n + 0] = true; \ - Check[index * n + 1] = true; \ - Check[index * n + 2] = false; \ - index++; \ - Y[index] = Fun(X[1]); \ - Check[index * n + 0] = false; \ - Check[index * n + 1] = true; \ - Check[index * n + 2] = false; \ - index++; + Y[index] = Fun(X[0]); \ + Check[index * n + 0] = true; \ + Check[index * n + 1] = false; \ + Check[index * n + 2] = false; \ + index++; \ + Y[index] = Fun(X[0] + X[1]); \ + Check[index * n + 0] = true; \ + Check[index * n + 1] = true; \ + Check[index * n + 2] = false; \ + index++; \ + Y[index] = Fun(X[1]); \ + Check[index * n + 0] = false; \ + Check[index * n + 1] = true; \ + Check[index * n + 2] = false; \ + index++; # define CheckBinaryFun(Fun) \ - Y[index] = Fun( X[0] , 2.); \ - Check[index * n + 0] = true; \ - Check[index * n + 1] = false; \ - Check[index * n + 2] = false; \ - index++; \ - Y[index] = Fun( X[0] , X[1]); \ - Check[index * n + 0] = true; \ - Check[index * n + 1] = true; \ - Check[index * n + 2] = false; \ - index++; \ - Y[index] = Fun( 3. , X[1]); \ - Check[index * n + 0] = false; \ - Check[index * n + 1] = true; \ - Check[index * n + 2] = false; \ - index++; + Y[index] = Fun( X[0] , 2.); \ + Check[index * n + 0] = true; \ + Check[index * n + 1] = false; \ + Check[index * n + 2] = false; \ + index++; \ + Y[index] = Fun( X[0] , X[1]); \ + Check[index * n + 0] = true; \ + Check[index * n + 1] = true; \ + Check[index * n + 2] = false; \ + index++; \ + Y[index] = Fun( 3. , X[1]); \ + Check[index * n + 0] = false; \ + Check[index * n + 1] = true; \ + Check[index * n + 2] = false; \ + index++; namespace { // Begin empty namespace bool case_one() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 3; + // dimension of the domain space + size_t n = 3; - // dimension of the range space - size_t m = (4 + 11 + 1) * 3 + 4; + // dimension of the range space + size_t m = (4 + 11 + 1) * 3 + 4; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - X[0] = .1; - X[1] = .2; - X[2] = .3; - Independent(X); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(m); - - // check results vector - CPPAD_TESTVECTOR( bool ) Check(m * n); - - // initialize index into Y - size_t index = 0; - - // 4 binary operators - CheckOp(+); - CheckOp(-); - CheckOp(*); - CheckOp(/); - - // 11 unary functions - CheckUnaryFun(abs); - CheckUnaryFun(acos); - CheckUnaryFun(asin); - CheckUnaryFun(atan); - CheckUnaryFun(cos); - CheckUnaryFun(cosh); - CheckUnaryFun(exp); - CheckUnaryFun(log); - CheckUnaryFun(sin); - CheckUnaryFun(sinh); - CheckUnaryFun(sqrt); - - // 1 binary function - CheckBinaryFun(pow); - - // conditional expression (value of comparision does not matter) - Y[index] = CondExpLt(X[0], X[1], X[0], AD(2.)); - Check[index * n + 0] = true; - Check[index * n + 1] = false; - Check[index * n + 2] = false; - index++; - Y[index] = CondExpLt(X[0], X[1], X[0], X[1]); - Check[index * n + 0] = true; - Check[index * n + 1] = true; - Check[index * n + 2] = false; - index++; - Y[index] = CondExpLt(X[0], X[1], AD(3.), X[1]); - Check[index * n + 0] = false; - Check[index * n + 1] = true; - Check[index * n + 2] = false; - index++; - - // non-trival composition - Y[index] = X[0] * X[1] + X[1] * X[2]; - Check[index * n + 0] = true; - 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); - - // --------------------------------------------------------- - // dependency matrix for the identity function W(x) = x - CPPAD_TESTVECTOR( bool ) Px(n * n); - size_t i, j; - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - Px[ i * n + j ] = false; - Px[ i * n + i ] = true; - } - - // evaluate the dependency matrix for F(X(x)) - CPPAD_TESTVECTOR( bool ) Py(m * n); - Py = F.ForSparseJac(n, Px); - - // check values - 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 - CPPAD_TESTVECTOR(std::set) Sx(n); - for(i = 0; i < n; i++) - { assert( Sx[i].empty() ); - Sx[i].insert(i); - } - - // evaluate the dependency matrix for F(X(x)) - CPPAD_TESTVECTOR(std::set) Sy(m); - Sy = F.ForSparseJac(n, Sx); - - // check values - bool found; - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - { found = Sy[i].find(j) != Sy[i].end(); - ok &= (found == Check[i * n + j]); - } - } + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + X[0] = .1; + X[1] = .2; + X[2] = .3; + Independent(X); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(m); + + // check results vector + CPPAD_TESTVECTOR( bool ) Check(m * n); + + // initialize index into Y + size_t index = 0; + + // 4 binary operators + CheckOp(+); + CheckOp(-); + CheckOp(*); + CheckOp(/); + + // 11 unary functions + CheckUnaryFun(abs); + CheckUnaryFun(acos); + CheckUnaryFun(asin); + CheckUnaryFun(atan); + CheckUnaryFun(cos); + CheckUnaryFun(cosh); + CheckUnaryFun(exp); + CheckUnaryFun(log); + CheckUnaryFun(sin); + CheckUnaryFun(sinh); + CheckUnaryFun(sqrt); + + // 1 binary function + CheckBinaryFun(pow); + + // conditional expression (value of comparision does not matter) + Y[index] = CondExpLt(X[0], X[1], X[0], AD(2.)); + Check[index * n + 0] = true; + Check[index * n + 1] = false; + Check[index * n + 2] = false; + index++; + Y[index] = CondExpLt(X[0], X[1], X[0], X[1]); + Check[index * n + 0] = true; + Check[index * n + 1] = true; + Check[index * n + 2] = false; + index++; + Y[index] = CondExpLt(X[0], X[1], AD(3.), X[1]); + Check[index * n + 0] = false; + Check[index * n + 1] = true; + Check[index * n + 2] = false; + index++; + + // non-trival composition + Y[index] = X[0] * X[1] + X[1] * X[2]; + Check[index * n + 0] = true; + 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); + + // --------------------------------------------------------- + // dependency matrix for the identity function W(x) = x + CPPAD_TESTVECTOR( bool ) Px(n * n); + size_t i, j; + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + Px[ i * n + j ] = false; + Px[ i * n + i ] = true; + } + + // evaluate the dependency matrix for F(X(x)) + CPPAD_TESTVECTOR( bool ) Py(m * n); + Py = F.ForSparseJac(n, Px); + + // check values + 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 + CPPAD_TESTVECTOR(std::set) Sx(n); + for(i = 0; i < n; i++) + { assert( Sx[i].empty() ); + Sx[i].insert(i); + } + + // evaluate the dependency matrix for F(X(x)) + CPPAD_TESTVECTOR(std::set) Sy(m); + Sy = F.ForSparseJac(n, Sx); + + // check values + bool found; + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + { found = Sy[i].find(j) != Sy[i].end(); + ok &= (found == Check[i * n + j]); + } + } - return ok; + return ok; } bool case_two() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 3; + // dimension of the domain space + size_t n = 3; - // dimension of the range space - size_t m = 3; + // dimension of the range space + size_t m = 3; - // inialize the vector as zero - CppAD::VecAD Z(n - 1); - size_t k; - for(k = 0; k < n-1; k++) - Z[k] = 0.; - - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - 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]; - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(m); - - // check results vector - CPPAD_TESTVECTOR( bool ) Check(m * n); - - // initialize index into Y - size_t index = 0; - - // First component only depends on X[0]; - Y[index] = X[0]; - Check[index * n + 0] = true; - Check[index * n + 1] = false; - Check[index * n + 2] = false; - index++; - - // Second component depends on the vector Z - AD zero(0); - Y[index] = Z[zero]; // Load by a parameter - Check[index * n + 0] = false; - Check[index * n + 1] = true; - Check[index * n + 2] = true; - index++; - - // Third component depends on the vector Z - Y[index] = Z[ X[0] ]; // Load by a variable - 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); - - // ----------------------------------------------------------------- - // dependency matrix for the identity function W(x) = x - CPPAD_TESTVECTOR( bool ) Px(n * n); - size_t i, j; - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - Px[ i * n + j ] = false; - Px[ i * n + i ] = true; - } - - // evaluate the dependency matrix for F(X(x)) - CPPAD_TESTVECTOR( bool ) Py(m * n); - Py = F.ForSparseJac(n, Px); - - // check values - 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 - CPPAD_TESTVECTOR(std::set) Sx(n); - for(i = 0; i < n; i++) - { assert( Sx[i].empty() ); - Sx[i].insert(i); - } - - // evaluate the dependency matrix for F(X(x)) - CPPAD_TESTVECTOR(std::set) Sy(m); - Sy = F.ForSparseJac(n, Sx); - - // check values - bool found; - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - { found = Sy[i].find(j) != Sy[i].end(); - ok &= (found == Check[i * n + j]); - } - } + // inialize the vector as zero + CppAD::VecAD Z(n - 1); + size_t k; + for(k = 0; k < n-1; k++) + Z[k] = 0.; + + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + 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]; + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(m); + + // check results vector + CPPAD_TESTVECTOR( bool ) Check(m * n); + + // initialize index into Y + size_t index = 0; + + // First component only depends on X[0]; + Y[index] = X[0]; + Check[index * n + 0] = true; + Check[index * n + 1] = false; + Check[index * n + 2] = false; + index++; + + // Second component depends on the vector Z + AD zero(0); + Y[index] = Z[zero]; // Load by a parameter + Check[index * n + 0] = false; + Check[index * n + 1] = true; + Check[index * n + 2] = true; + index++; + + // Third component depends on the vector Z + Y[index] = Z[ X[0] ]; // Load by a variable + 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); + + // ----------------------------------------------------------------- + // dependency matrix for the identity function W(x) = x + CPPAD_TESTVECTOR( bool ) Px(n * n); + size_t i, j; + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + Px[ i * n + j ] = false; + Px[ i * n + i ] = true; + } + + // evaluate the dependency matrix for F(X(x)) + CPPAD_TESTVECTOR( bool ) Py(m * n); + Py = F.ForSparseJac(n, Px); + + // check values + 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 + CPPAD_TESTVECTOR(std::set) Sx(n); + for(i = 0; i < n; i++) + { assert( Sx[i].empty() ); + Sx[i].insert(i); + } + + // evaluate the dependency matrix for F(X(x)) + CPPAD_TESTVECTOR(std::set) Sy(m); + Sy = F.ForSparseJac(n, Sx); + + // check values + bool found; + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + { found = Sy[i].find(j) != Sy[i].end(); + ok &= (found == Check[i * n + j]); + } + } - return ok; + return ok; } bool case_three() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 2; + // dimension of the domain space + size_t n = 2; - // dimension of the range space - size_t m = 3; + // dimension of the range space + size_t m = 3; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 2.; - X[1] = 3.; - Independent(X); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(m); - - // check results vector - CPPAD_TESTVECTOR( bool ) Check(m * n); - - // initialize index into Y - size_t index = 0; - - // Y[0] only depends on X[0]; - Y[index] = pow(X[0], 2.); - Check[index * n + 0] = true; - Check[index * n + 1] = false; - index++; - - // Y[1] depends on X[1] - Y[index] = pow(2., X[1]); - Check[index * n + 0] = false; - Check[index * n + 1] = true; - index++; - - // Y[2] depends on X[0] and X[1] - Y[index] = pow(X[0], X[1]); - Check[index * n + 0] = true; - Check[index * n + 1] = true; - index++; - - // check final index - assert( index == m ); - - // create function object F : X -> Y - ADFun F(X, Y); - - // ----------------------------------------------------------------- - // dependency matrix for the identity function - CPPAD_TESTVECTOR( bool ) Px(n * n); - size_t i, j; - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - Px[ i * n + j ] = false; - Px[ i * n + i ] = true; - } - - // evaluate the dependency matrix for F(X(x)) - CPPAD_TESTVECTOR( bool ) Py(m * n); - Py = F.ForSparseJac(n, Px); - - // check values - 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 - CPPAD_TESTVECTOR(std::set) Sx(n); - for(i = 0; i < n; i++) - { assert( Sx[i].empty() ); - Sx[i].insert(i); - } - - // evaluate the dependency matrix for F(X(x)) - CPPAD_TESTVECTOR(std::set) Sy(m); - Sy = F.ForSparseJac(n, Sx); - - // check values - bool found; - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - { found = Sy[i].find(j) != Sy[i].end(); - ok &= (found == Check[i * n + j]); - } - } + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 2.; + X[1] = 3.; + Independent(X); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(m); + + // check results vector + CPPAD_TESTVECTOR( bool ) Check(m * n); + + // initialize index into Y + size_t index = 0; + + // Y[0] only depends on X[0]; + Y[index] = pow(X[0], 2.); + Check[index * n + 0] = true; + Check[index * n + 1] = false; + index++; + + // Y[1] depends on X[1] + Y[index] = pow(2., X[1]); + Check[index * n + 0] = false; + Check[index * n + 1] = true; + index++; + + // Y[2] depends on X[0] and X[1] + Y[index] = pow(X[0], X[1]); + Check[index * n + 0] = true; + Check[index * n + 1] = true; + index++; + + // check final index + assert( index == m ); + + // create function object F : X -> Y + ADFun F(X, Y); + + // ----------------------------------------------------------------- + // dependency matrix for the identity function + CPPAD_TESTVECTOR( bool ) Px(n * n); + size_t i, j; + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + Px[ i * n + j ] = false; + Px[ i * n + i ] = true; + } + + // evaluate the dependency matrix for F(X(x)) + CPPAD_TESTVECTOR( bool ) Py(m * n); + Py = F.ForSparseJac(n, Px); + + // check values + 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 + CPPAD_TESTVECTOR(std::set) Sx(n); + for(i = 0; i < n; i++) + { assert( Sx[i].empty() ); + Sx[i].insert(i); + } + + // evaluate the dependency matrix for F(X(x)) + CPPAD_TESTVECTOR(std::set) Sy(m); + Sy = F.ForSparseJac(n, Sx); + + // check values + bool found; + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + { found = Sy[i].find(j) != Sy[i].end(); + ok &= (found == Check[i * n + j]); + } + } - return ok; + return ok; } bool case_four() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 2; + // dimension of the domain space + size_t n = 2; - // dimension of the range space - size_t m = 3; + // dimension of the range space + size_t m = 3; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 2.; - X[1] = 3.; - Independent(X); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(m); - - // check results vector - CPPAD_TESTVECTOR( bool ) Check(m * n); - - // initialize index into Y - size_t index = 0; - - // Y[0] only depends on X[0]; - Y[index] = pow(X[0], 2.); - Check[index * n + 0] = true; - Check[index * n + 1] = false; - index++; - - // Y[1] depends on X[1] - Y[index] = pow(2., X[1]); - Check[index * n + 0] = false; - Check[index * n + 1] = true; - index++; - - // Y[2] depends on X[0] and X[1] - Y[index] = pow(X[0], X[1]); - Check[index * n + 0] = true; - Check[index * n + 1] = true; - index++; - - // check final index - assert( index == m ); - - // create function object F : X -> Y - ADFun F(X, Y); - - // ----------------------------------------------------------------- - // dependency matrix for the identity function - CPPAD_TESTVECTOR( bool ) Px(n * n); - size_t i, j; - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - Px[ i * n + j ] = false; - Px[ i * n + i ] = true; - } - - // evaluate the dependency matrix for F(X(x)) - bool transpose = true; - CPPAD_TESTVECTOR( bool ) Py(n * m); - Py = F.ForSparseJac(n, Px, transpose); - - // check values - 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 - CPPAD_TESTVECTOR(std::set) Sx(n); - for(i = 0; i < n; i++) - { assert( Sx[i].empty() ); - Sx[i].insert(i); - } - - // evaluate the dependency matrix for F(X(x)) - CPPAD_TESTVECTOR(std::set) Sy(n); - Sy = F.ForSparseJac(n, Sx, transpose); - - // check values - bool found; - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - { found = Sy[j].find(i) != Sy[j].end(); - ok &= (found == Check[i * n + j]); - } - } + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 2.; + X[1] = 3.; + Independent(X); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(m); + + // check results vector + CPPAD_TESTVECTOR( bool ) Check(m * n); + + // initialize index into Y + size_t index = 0; + + // Y[0] only depends on X[0]; + Y[index] = pow(X[0], 2.); + Check[index * n + 0] = true; + Check[index * n + 1] = false; + index++; + + // Y[1] depends on X[1] + Y[index] = pow(2., X[1]); + Check[index * n + 0] = false; + Check[index * n + 1] = true; + index++; + + // Y[2] depends on X[0] and X[1] + Y[index] = pow(X[0], X[1]); + Check[index * n + 0] = true; + Check[index * n + 1] = true; + index++; + + // check final index + assert( index == m ); + + // create function object F : X -> Y + ADFun F(X, Y); + + // ----------------------------------------------------------------- + // dependency matrix for the identity function + CPPAD_TESTVECTOR( bool ) Px(n * n); + size_t i, j; + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + Px[ i * n + j ] = false; + Px[ i * n + i ] = true; + } + + // evaluate the dependency matrix for F(X(x)) + bool transpose = true; + CPPAD_TESTVECTOR( bool ) Py(n * m); + Py = F.ForSparseJac(n, Px, transpose); + + // check values + 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 + CPPAD_TESTVECTOR(std::set) Sx(n); + for(i = 0; i < n; i++) + { assert( Sx[i].empty() ); + Sx[i].insert(i); + } + + // evaluate the dependency matrix for F(X(x)) + CPPAD_TESTVECTOR(std::set) Sy(n); + Sy = F.ForSparseJac(n, Sx, transpose); + + // check values + bool found; + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + { found = Sy[j].find(i) != Sy[j].end(); + ok &= (found == Check[i * n + j]); + } + } - return ok; + return ok; } } // End empty namespace bool for_sparse_jac(void) -{ bool ok = true; +{ bool ok = true; - ok &= case_one(); - ok &= case_two(); - ok &= case_three(); - ok &= case_four(); + ok &= case_one(); + ok &= case_two(); + ok &= case_three(); + ok &= case_four(); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/forward.cpp cppad-2019.02.00.0/test_more/general/forward.cpp --- cppad-2018.00.00.0/test_more/general/forward.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/forward.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Two old Forward example now used just for valiadation testing @@ -17,220 +18,220 @@ namespace { // Begin empty namespace -template // vector class, elements of type double +template // vector class, elements of type double bool ForwardCases(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) X(2); - X[0] = 0.; - X[1] = 1.; - Independent(X); - - // compute product of elements in X - CPPAD_TESTVECTOR(AD) Y(1); - Y[0] = X[0] * X[0] * X[1]; - - // create function object F : X -> Y - ADFun F(X, Y); - - // use zero order to evaluate F[ (3, 4) ] - VectorDouble x0( F.Domain() ); - VectorDouble y0( F.Range() ); - x0[0] = 3.; - x0[1] = 4.; - y0 = F.Forward(0, x0); - ok &= NearEqual(y0[0] , x0[0]*x0[0]*x0[1], eps99, eps99); - - // evaluate derivative of F in X[0] direction - VectorDouble x1( F.Domain() ); - VectorDouble y1( F.Range() ); - x1[0] = 1.; - x1[1] = 0.; - y1 = F.Forward(1, x1); - ok &= NearEqual(y1[0] , 2.*x0[0]*x0[1], eps99, eps99); - - // evaluate second derivative of F in X[0] direction - VectorDouble x2( F.Domain() ); - VectorDouble y2( F.Range() ); - x2[0] = 0.; - x2[1] = 0.; - y2 = F.Forward(2, x2); - double F_00 = 2. * y2[0]; - ok &= NearEqual(F_00, 2.*x0[1], eps99, eps99); - - // evalute derivative of F in X[1] direction - x1[0] = 0.; - x1[1] = 1.; - y1 = F.Forward(1, x1); - ok &= NearEqual(y1[0] , x0[0]*x0[0], eps99, eps99); - - // evaluate second derivative of F in X[1] direction - y2 = F.Forward(2, x2); - double F_11 = 2. * y2[0]; - ok &= NearEqual(F_11, 0., eps99, eps99); - - // evalute derivative of F in X[0] + X[1] direction - x1[0] = 1.; - x1[1] = 1.; - y1 = F.Forward(1, x1); - ok &= NearEqual(y1[0], 2.*x0[0]*x0[1] + x0[0]*x0[0], eps99, eps99); - - // use second derivative of F in X[0] direction to - // compute second partial of F w.r.t X[1] w.r.t X[2] - y2 = F.Forward(2, x2); - double F_01 = y2[0] - F_00 / 2. - F_11 / 2.; - ok &= NearEqual(F_01 , 2.*x0[0], eps99, eps99); + using namespace CppAD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) X(2); + X[0] = 0.; + X[1] = 1.; + Independent(X); + + // compute product of elements in X + CPPAD_TESTVECTOR(AD) Y(1); + Y[0] = X[0] * X[0] * X[1]; + + // create function object F : X -> Y + ADFun F(X, Y); + + // use zero order to evaluate F[ (3, 4) ] + DoubleVector x0( F.Domain() ); + DoubleVector y0( F.Range() ); + x0[0] = 3.; + x0[1] = 4.; + y0 = F.Forward(0, x0); + ok &= NearEqual(y0[0] , x0[0]*x0[0]*x0[1], eps99, eps99); + + // evaluate derivative of F in X[0] direction + DoubleVector x1( F.Domain() ); + DoubleVector y1( F.Range() ); + x1[0] = 1.; + x1[1] = 0.; + y1 = F.Forward(1, x1); + ok &= NearEqual(y1[0] , 2.*x0[0]*x0[1], eps99, eps99); + + // evaluate second derivative of F in X[0] direction + DoubleVector x2( F.Domain() ); + DoubleVector y2( F.Range() ); + x2[0] = 0.; + x2[1] = 0.; + y2 = F.Forward(2, x2); + double F_00 = 2. * y2[0]; + ok &= NearEqual(F_00, 2.*x0[1], eps99, eps99); + + // evalute derivative of F in X[1] direction + x1[0] = 0.; + x1[1] = 1.; + y1 = F.Forward(1, x1); + ok &= NearEqual(y1[0] , x0[0]*x0[0], eps99, eps99); + + // evaluate second derivative of F in X[1] direction + y2 = F.Forward(2, x2); + double F_11 = 2. * y2[0]; + ok &= NearEqual(F_11, 0., eps99, eps99); + + // evalute derivative of F in X[0] + X[1] direction + x1[0] = 1.; + x1[1] = 1.; + y1 = F.Forward(1, x1); + ok &= NearEqual(y1[0], 2.*x0[0]*x0[1] + x0[0]*x0[0], eps99, eps99); + + // use second derivative of F in X[0] direction to + // compute second partial of F w.r.t X[1] w.r.t X[2] + y2 = F.Forward(2, x2); + double F_01 = y2[0] - F_00 / 2. - F_11 / 2.; + ok &= NearEqual(F_01 , 2.*x0[0], eps99, eps99); - return ok; + return ok; } bool ForwardOlder(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(3); - U[0] = 0.; U[1] = 1.; U[2] = 2.; - Independent(U); - - // compute sum and product of elements in U - AD sum = 0.; - AD prod = 1.; - size_t i; - for(i = 0; i < 3; i++) - { sum += U[i]; - prod *= U[i]; - } - - // dependent variable vector - CPPAD_TESTVECTOR(AD) V(2); - V[0] = sum; - V[1] = prod; - - // V = f(U) - ADFun f(U, V); - - // use ADFun object to evaluate f[ (1, 2, 3)^T ] ----------------- - CPPAD_TESTVECTOR(double) u0( f.Domain() ); - CPPAD_TESTVECTOR(double) v0( f.Range() ); - size_t p; - p = 0; - u0[0] = 1.; u0[1] = 2.; u0[2] = 3.; - v0 = f.Forward(p, u0); - - // direct evaluation of f[ u0 ] - CPPAD_TESTVECTOR(double) f0(2); - f0[0] = u0[0] + u0[1] + u0[2]; - f0[1] = u0[0] * u0[1] * u0[2]; - - // compare values - ok &= NearEqual(v0[0] , f0[0], eps99, eps99); - ok &= NearEqual(v0[1] , f0[1], eps99, eps99); - - // use ADFun object to evaluate f^(1) [ u0 ] * u1 ----------------- - CPPAD_TESTVECTOR(double) u1( f.Domain() ); - CPPAD_TESTVECTOR(double) v1( f.Range() ); - p = 1; - u1[0] = 1.; u1[1] = 1.; u1[2] = 1.; - v1 = f.Forward(p, u1); - - // direct evaluation of gradients of components of f - CPPAD_TESTVECTOR(double) g0(3), g1(3); - g0[0] = 1.; g0[1] = 1.; g0[2] = 1.; - g1[0] = u0[1]*u0[2]; g1[1] = u0[0]*u0[2]; g1[2] = u0[0]*u0[1]; - - // compare values - ok &= NearEqual(v1[0] , - g0[0]*u1[0] + g0[1]*u1[1] + g0[2]*u1[2] , eps99, eps99); - ok &= NearEqual(v1[1] , - g1[0]*u1[0] + g1[1]*u1[1] + g1[2]*u1[2] , eps99, eps99); - - // use ADFun object to evaluate ------------------------------------ - // (1/2) * { f^(1)[ u0 ] * u2 + u1^T * f^(2)[ u0 ] * u1 } - CPPAD_TESTVECTOR(double) u2( f.Domain() ); - CPPAD_TESTVECTOR(double) v2( f.Range() ); - p = 2; - u2[0] = .5; u2[1] = .4; u2[2] = .3; - v2 = f.Forward(p, u2); - - // direct evaluation of Hessian of second components of f - // (the Hessian of the first component is zero) - CPPAD_TESTVECTOR(double) H1(9); - H1[0] = 0.; H1[1] = u0[2]; H1[2] = u0[1]; - H1[3] = u0[2]; H1[4] = 0.; H1[5] = u0[0]; - H1[6] = u0[1]; H1[7] = u0[0]; H1[8] = 0.; - - // compare values - ok &= NearEqual(v2[0] , - g0[0]*u2[0] + g0[1]*u2[1] + g0[2]*u2[2] , eps99, eps99); - - size_t j; - double v2_1 = 0.; - for(i = 0; i < 3; i++) - { v2_1 += g1[i] * u2[i]; - for(j = 0; j < 3; j++) - v2_1 += .5 * u1[i] * H1[i * 3 + j] * u1[j]; - } - ok &= NearEqual(v2[1], v2_1, eps99, eps99); + using namespace CppAD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(3); + U[0] = 0.; U[1] = 1.; U[2] = 2.; + Independent(U); + + // compute sum and product of elements in U + AD sum = 0.; + AD prod = 1.; + size_t i; + for(i = 0; i < 3; i++) + { sum += U[i]; + prod *= U[i]; + } + + // dependent variable vector + CPPAD_TESTVECTOR(AD) V(2); + V[0] = sum; + V[1] = prod; + + // V = f(U) + ADFun f(U, V); + + // use ADFun object to evaluate f[ (1, 2, 3)^T ] ----------------- + CPPAD_TESTVECTOR(double) u0( f.Domain() ); + CPPAD_TESTVECTOR(double) v0( f.Range() ); + size_t p; + p = 0; + u0[0] = 1.; u0[1] = 2.; u0[2] = 3.; + v0 = f.Forward(p, u0); + + // direct evaluation of f[ u0 ] + CPPAD_TESTVECTOR(double) f0(2); + f0[0] = u0[0] + u0[1] + u0[2]; + f0[1] = u0[0] * u0[1] * u0[2]; + + // compare values + ok &= NearEqual(v0[0] , f0[0], eps99, eps99); + ok &= NearEqual(v0[1] , f0[1], eps99, eps99); + + // use ADFun object to evaluate f^(1) [ u0 ] * u1 ----------------- + CPPAD_TESTVECTOR(double) u1( f.Domain() ); + CPPAD_TESTVECTOR(double) v1( f.Range() ); + p = 1; + u1[0] = 1.; u1[1] = 1.; u1[2] = 1.; + v1 = f.Forward(p, u1); + + // direct evaluation of gradients of components of f + CPPAD_TESTVECTOR(double) g0(3), g1(3); + g0[0] = 1.; g0[1] = 1.; g0[2] = 1.; + g1[0] = u0[1]*u0[2]; g1[1] = u0[0]*u0[2]; g1[2] = u0[0]*u0[1]; + + // compare values + ok &= NearEqual(v1[0] , + g0[0]*u1[0] + g0[1]*u1[1] + g0[2]*u1[2] , eps99, eps99); + ok &= NearEqual(v1[1] , + g1[0]*u1[0] + g1[1]*u1[1] + g1[2]*u1[2] , eps99, eps99); + + // use ADFun object to evaluate ------------------------------------ + // (1/2) * { f^(1)[ u0 ] * u2 + u1^T * f^(2)[ u0 ] * u1 } + CPPAD_TESTVECTOR(double) u2( f.Domain() ); + CPPAD_TESTVECTOR(double) v2( f.Range() ); + p = 2; + u2[0] = .5; u2[1] = .4; u2[2] = .3; + v2 = f.Forward(p, u2); + + // direct evaluation of Hessian of second components of f + // (the Hessian of the first component is zero) + CPPAD_TESTVECTOR(double) H1(9); + H1[0] = 0.; H1[1] = u0[2]; H1[2] = u0[1]; + H1[3] = u0[2]; H1[4] = 0.; H1[5] = u0[0]; + H1[6] = u0[1]; H1[7] = u0[0]; H1[8] = 0.; + + // compare values + ok &= NearEqual(v2[0] , + g0[0]*u2[0] + g0[1]*u2[1] + g0[2]*u2[2] , eps99, eps99); + + size_t j; + double v2_1 = 0.; + for(i = 0; i < 3; i++) + { v2_1 += g1[i] * u2[i]; + for(j = 0; j < 3; j++) + v2_1 += .5 * u1[i] * H1[i * 3 + j] * u1[j]; + } + ok &= NearEqual(v2[1], v2_1, eps99, eps99); - return ok; + return ok; } # ifndef NDEBUG # ifndef CPPAD_DEBUG_AND_RELEASE void my_error_handler( - bool known , - int line , - const char *file , - const char *exp , - const char *msg ) -{ // error hander must not return, so throw an exception - std::string message = msg; - throw message; + bool known , + int line , + const char *file , + const char *exp , + const char *msg ) +{ // error hander must not return, so throw an exception + std::string message = msg; + throw message; } bool forward_nan(void) { - using CppAD::vector; - using CppAD::AD; + using CppAD::vector; + using CppAD::AD; - size_t n = 2, m = 1; - vector< AD > a_x(n), a_y(m); - a_x[0] = 1.; - a_x[1] = 2.; - Independent(a_x); - a_y[0] = a_x[0] / a_x[1]; - CppAD::ADFun f(a_x, a_y); - // - vector x(n), y(m); - x[0] = 0.; - x[1] = 0.; - - // replace the default CppAD error handler - CppAD::ErrorHandler info(my_error_handler); - - bool ok = false; - try { - y = f.Forward(0, x); - } - catch( std::string msg ) - { // 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; - } + size_t n = 2, m = 1; + vector< AD > a_x(n), a_y(m); + a_x[0] = 1.; + a_x[1] = 2.; + Independent(a_x); + a_y[0] = a_x[0] / a_x[1]; + CppAD::ADFun f(a_x, a_y); + // + vector x(n), y(m); + x[0] = 0.; + x[1] = 0.; + + // replace the default CppAD error handler + CppAD::ErrorHandler info(my_error_handler); + + bool ok = false; + try { + y = f.Forward(0, x); + } + catch( std::string msg ) + { // 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; + return ok; } # endif # endif @@ -239,16 +240,16 @@ # include # include bool Forward(void) -{ bool ok = true; - ok &= ForwardCases< CppAD::vector >(); - ok &= ForwardCases< std::vector >(); - ok &= ForwardCases< std::valarray >(); - ok &= ForwardOlder(); +{ bool ok = true; + ok &= ForwardCases< CppAD::vector >(); + ok &= ForwardCases< std::vector >(); + ok &= ForwardCases< std::valarray >(); + ok &= ForwardOlder(); # ifndef NDEBUG # ifndef CPPAD_DEBUG_AND_RELEASE - // CppAD does not check for nan when NDEBUG is defined - ok &= forward_nan(); + // CppAD does not check for nan when NDEBUG is defined + ok &= forward_nan(); # endif # endif - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/forward_dir.cpp cppad-2019.02.00.0/test_more/general/forward_dir.cpp --- cppad-2018.00.00.0/test_more/general/forward_dir.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/forward_dir.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // test multiple directions operators // MulvvOp is tested by example/forward_dir.cpp @@ -16,1627 +17,1627 @@ # include namespace { - using CppAD::AD; - using CppAD::NearEqual; - // --------------------------------------------------------------------- - // 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; - 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) = 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) - // = 0.5 + 2t + 3t^2 - double y_1_1 = 2.0; - double y_2_1 = 3.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // 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[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] = fabs( ax[0] ) + fabs( 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; - 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) = F[X_0(t)] - // = fabs(0.5 + 1t + 2t^2) + fabs( 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)] - // = fabs(0.5 + 2t + 3t^2) + fabs( 2*(-1.0 + 3t + 4t^2 ) ) - double y_1_1 = -4.0; - double y_2_1 = -5.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // 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; - - // 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; - 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 + 3); - } - y2 = f.Forward(2, r, x2); - 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)] - // = 2.0 + (0.5 + 2t + 4t^2) - double y_1_1 = 2.0; - double y_2_1 = 4.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // 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[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; - 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) = 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)] - // = (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; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // 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; - - // 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; - 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) = 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)] - // = 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; - double y_2_1 = - ( cos(0.5) * 4.0 + 6.0 * sin(0.5) ) / 2.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // 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; - - // 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; - 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) = 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)] - // = 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; - double y_2_1 = ( sinh(0.5) * 6.0 + cosh(0.5) * 4.0 ) / 2.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // CExpOp - bool cexp_op(void) - { 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); - ay[0] = CondExpLt(ax[0], ax[1], ax[2], ax[3]); - ay[1] = CondExpGt(ax[0], ax[1], ax[2], ax[3]); - - // 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; - // - // 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; - double y1_2_1 = 6.0; - // - ok &= NearEqual(y1[0*r+0] , y0_1_0, eps, eps); - ok &= NearEqual(y1[1*r+0] , y1_1_0, eps, eps); - ok &= NearEqual(y1[0*r+1] , y0_1_1, eps, eps); - ok &= NearEqual(y1[1*r+1] , y1_1_1, eps, eps); - // - ok &= NearEqual(y2[0*r+0] , y0_2_0, eps, eps); - ok &= NearEqual(y2[1*r+0] , y1_2_0, eps, eps); - ok &= NearEqual(y2[0*r+1] , y0_2_1, eps, eps); - ok &= NearEqual(y2[1*r+1] , y1_2_1, eps, eps); - // - return ok; - } - - // --------------------------------------------------------------------- - // 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 - 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; - 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 + 3); - } - y2 = f.Forward(2, r, x2); - ok &= size_t( y2.size() ) == r*m; - // - double check = 0.0; - for(j = 0; j < n; j++) - check += x1[ r * j + 0]; - ok &= NearEqual(y1[0] , check, eps, eps); - // - check = 0.0; - for(j = 0; j < n; j++) - check += x1[ r * j + 1]; - ok &= NearEqual(y1[1] , check, eps, eps); - // - check = 0.0; - for(j = 0; j < n; j++) - check += x2[ r * j + 0]; - ok &= NearEqual(y2[0] , check, eps, eps); - // - check = 0.0; - for(j = 0; j < n; j++) - check += x2[ r * j + 1]; - ok &= NearEqual(y2[1] , check, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // DisOp (test assuming that AddvvOp is correct) - double round_off(const double& x) - { // std::round(x); is C++11, so we avoid using it - return std::floor( x + 0.5 ); - } - CPPAD_DISCRETE_FUNCTION(double, round_off) - bool dis_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; - - // 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); - - // zero order - CPPAD_TESTVECTOR(double) x0(n), y0; - x0[0] = 2.2; - y0 = f.Forward(0, x0); - 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; - 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) = 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) - double y_1_1 = 2.0; - double y_2_1 = 3.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // DivpvOp (testing assumping MulpvOp is correct) - bool divpv_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; - - // 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]) * (ax[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) = 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)] - // = 2.0 * (0.5 + 2t + 3t^2)/2.0 - double y_1_1 = 4.0; - double y_2_1 = 6.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // 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; - - // 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; - - // 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 + 3); - } - y2 = f.Forward(2, r, x2); - 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)] - // = (0.5 + 2t + 4t^2)/2.0 - double y_1_1 = 2.0 / 2.0; - double y_2_1 = 4.0 / 2.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // 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; - - // 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; - 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) = 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)] - // = 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; - double y_2_1 = ( exp(0.5)*6.0 + exp(0.5)*2.0*2.0 ) / 2.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // LdpOp and LdvOp (test assuming AdvvOp is correct) - bool load_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.0; - ax[1] = 1.0; - - // declare independent variables and starting recording - CppAD::Independent(ax); - - // Store operations - CppAD::VecAD avec(3); - 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 - 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); - - // zero order Taylor coefficients - CPPAD_TESTVECTOR(double) x0(n), y0; - x0[0] = 2; - x0[1] = 3; - y0 = f.Forward(0, x0); - 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; - - // 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; - // - // 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; - // - ok &= NearEqual(y1[0*r+0] , y0_1_0, eps, eps); - ok &= NearEqual(y1[1*r+0] , y1_1_0, eps, eps); - ok &= NearEqual(y1[0*r+1] , y0_1_1, eps, eps); - ok &= NearEqual(y1[1*r+1] , y1_1_1, eps, eps); - // - ok &= NearEqual(y2[0*r+0] , y0_2_0, eps, eps); - ok &= NearEqual(y2[1*r+0] , y1_2_0, eps, eps); - ok &= NearEqual(y2[0*r+1] , y0_2_1, eps, eps); - ok &= NearEqual(y2[1*r+1] , y1_2_1, eps, eps); - // - return ok; - } - - // --------------------------------------------------------------------- - // 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; - - // 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; - 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 + 3); - } - y2 = f.Forward(2, r, x2); - 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)] - // = 2.0 * (0.5 + 2t + 4t^2) - double y_1_1 = 2.0 * 2.0; - double y_2_1 = 2.0 * 4.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - 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[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; - 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; - // - // 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; - // - ok &= NearEqual(y1[0*r+0] , y0_1_0, eps, eps); - ok &= NearEqual(y1[1*r+0] , y1_1_0, eps, eps); - ok &= NearEqual(y1[0*r+1] , y0_1_1, eps, eps); - ok &= NearEqual(y1[1*r+1] , y1_1_1, eps, eps); - // - ok &= NearEqual(y2[0*r+0] , y0_2_0, eps, eps); - ok &= NearEqual(y2[1*r+0] , y1_2_0, eps, eps); - ok &= NearEqual(y2[0*r+1] , y0_2_1, eps, eps); - ok &= NearEqual(y2[1*r+1] , y1_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // SignOp (test assuming that MulvvOp is correct) - bool sign_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; - - // 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); - - // zero order - CPPAD_TESTVECTOR(double) x0(n), y0; - x0[0] = -3.0; - y0 = f.Forward(0, x0); - ok &= size_t( y0.size() ) == m; - ok &= NearEqual(y0[0], fabs(x0[0]), eps, eps); - - // 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) = 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) - double y_1_1 = -2.0; - double y_2_1 = -3.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - - // --------------------------------------------------------------------- - // 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; - - // 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; - 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) = 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)] - // = 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; - double y_2_1 = ( cos(0.5) * 6.0 - sin(0.5) * 4.0 ) / 2.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // 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; - - // 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; - 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) = 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)] - // = 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; - double y_2_1 = ( cosh(0.5) * 6.0 + sinh(0.5) * 4.0 ) / 2.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // 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; - - // 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; - 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 + 3); - } - y2 = f.Forward(2, r, x2); - 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)] - // = 3.0 - (0.5 + 2t + 4t^2)/2.0 - double y_1_1 = - 2.0; - double y_2_1 = - 4.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // 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[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; - 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) = 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)] - // = (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; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // 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; - - // 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; - 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) = 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)] - // = 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) - double y_1_1 = 2.0 * sec_sq; - double y_2_1 = (8.0 * tan(0.5) + 6.0) * sec_sq / 2.0; - // - ok &= NearEqual(y1[0] , y_1_0, eps, eps); - ok &= NearEqual(y1[1] , y_1_1, eps, eps); - ok &= NearEqual(y2[0] , y_2_0, eps, eps); - ok &= NearEqual(y2[1] , y_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // Usr*Op - typedef CPPAD_TESTVECTOR(AD) avector; - void usr_algo(const avector& x, avector& z) - { z[0] = ( x[0] + x[1] ) / 2.0; - z[1] = x[0] * x[1]; - z[2] = ( x[0] - x[1] ) / 2.0; - return; - } - bool usr_op(void) - { bool ok = true; - double eps = 10. * std::numeric_limits::epsilon(); - size_t j; - - // define checkpoint function - size_t n = 2; - avector ax(n), az(3); - ax[0] = 0.5; - ax[1] = 2.0; - CppAD::checkpoint usr_check("usr_check", usr_algo, ax, az); - - // declare independent variables and starting recording - CppAD::Independent(ax); - - // record checkpoint function - usr_check(ax, az); - - // range space vector - size_t m = 2; - avector ay(m); - ay[0] = az[0] + az[2]; // = ax[0] - ay[1] = az[0] - az[2]; // = 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; - 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; - // - // 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; - // - ok &= NearEqual(y1[0*r+0] , y0_1_0, eps, eps); - ok &= NearEqual(y1[1*r+0] , y1_1_0, eps, eps); - ok &= NearEqual(y1[0*r+1] , y0_1_1, eps, eps); - ok &= NearEqual(y1[1*r+1] , y1_1_1, eps, eps); - // - ok &= NearEqual(y2[0*r+0] , y0_2_0, eps, eps); - ok &= NearEqual(y2[1*r+0] , y1_2_0, eps, eps); - ok &= NearEqual(y2[0*r+1] , y0_2_1, eps, eps); - ok &= NearEqual(y2[1*r+1] , y1_2_1, eps, eps); - // - return ok; - } - // --------------------------------------------------------------------- - // Inverse functions assume the following already tested: - // CosOp, SinOp, TanOp, ExpOp, MulvvOp, DivvpOp, AddpvOp - // - // AcosOp - AD acos_fun(const AD& x) - { return acos( cos(x) ); } - bool acos_op(void) - { return check_identity(acos_fun, 0.5); } - // - // 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); } - // - // 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); } - // - // 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) - { return check_identity(log_fun, 0.5); } - // - // DivvvOp - AD divvv_fun(const AD& x) - { return (x * x) / x; } - bool divvv_op(void) - { return check_identity(divvv_fun, 0.5); } - // - // PowpvOp - AD powpv_fun(const AD& x ) - { return log( pow( exp(3.0) , x ) ) / 3.0; } - bool powpv_op(void) - { return check_identity(powpv_fun, 0.5); } - // - // PowvpOp - AD powvp_fun(const AD& x ) - { return log( pow( exp(x) , 3.0 ) ) / 3.0; } - bool powvp_op(void) - { return check_identity(powvp_fun, 0.5); } - // - // SqrtOp - AD sqrt_fun(const AD& x ) - { return sqrt( x * x ); } - bool sqrt_op(void) - { return check_identity(sqrt_fun, 0.5); } - // - // SubvpOp - AD subvp_fun(const AD& x ) - { return 3.0 + ( x - 3.0 ); } - bool subvp_op(void) - { return check_identity(subvp_fun, 0.5); } - // - // TanhOp - AD tanh_fun(const AD& x ) - { AD z = tanh(x); - return log( (1.0 + z) / (1.0 - z) ) / 2.0; - } - bool tanh_op(void) - { return check_identity(tanh_fun, 0.5); } + using CppAD::AD; + using CppAD::NearEqual; + // --------------------------------------------------------------------- + // 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; + 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) = 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) + // = 0.5 + 2t + 3t^2 + double y_1_1 = 2.0; + double y_2_1 = 3.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // 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[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] = fabs( ax[0] ) + fabs( 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; + 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) = F[X_0(t)] + // = fabs(0.5 + 1t + 2t^2) + fabs( 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)] + // = fabs(0.5 + 2t + 3t^2) + fabs( 2*(-1.0 + 3t + 4t^2 ) ) + double y_1_1 = -4.0; + double y_2_1 = -5.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // 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; + + // 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; + 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 + 3); + } + y2 = f.Forward(2, r, x2); + 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)] + // = 2.0 + (0.5 + 2t + 4t^2) + double y_1_1 = 2.0; + double y_2_1 = 4.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // 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[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; + 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) = 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)] + // = (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; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // 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; + + // 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; + 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) = 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)] + // = 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; + double y_2_1 = - ( cos(0.5) * 4.0 + 6.0 * sin(0.5) ) / 2.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // 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; + + // 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; + 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) = 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)] + // = 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; + double y_2_1 = ( sinh(0.5) * 6.0 + cosh(0.5) * 4.0 ) / 2.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // CExpOp + bool cexp_op(void) + { 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); + ay[0] = CondExpLt(ax[0], ax[1], ax[2], ax[3]); + ay[1] = CondExpGt(ax[0], ax[1], ax[2], ax[3]); + + // 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; + // + // 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; + double y1_2_1 = 6.0; + // + ok &= NearEqual(y1[0*r+0] , y0_1_0, eps, eps); + ok &= NearEqual(y1[1*r+0] , y1_1_0, eps, eps); + ok &= NearEqual(y1[0*r+1] , y0_1_1, eps, eps); + ok &= NearEqual(y1[1*r+1] , y1_1_1, eps, eps); + // + ok &= NearEqual(y2[0*r+0] , y0_2_0, eps, eps); + ok &= NearEqual(y2[1*r+0] , y1_2_0, eps, eps); + ok &= NearEqual(y2[0*r+1] , y0_2_1, eps, eps); + ok &= NearEqual(y2[1*r+1] , y1_2_1, eps, eps); + // + return ok; + } + + // --------------------------------------------------------------------- + // 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 + 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; + 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 + 3); + } + y2 = f.Forward(2, r, x2); + ok &= size_t( y2.size() ) == r*m; + // + double check = 0.0; + for(j = 0; j < n; j++) + check += x1[ r * j + 0]; + ok &= NearEqual(y1[0] , check, eps, eps); + // + check = 0.0; + for(j = 0; j < n; j++) + check += x1[ r * j + 1]; + ok &= NearEqual(y1[1] , check, eps, eps); + // + check = 0.0; + for(j = 0; j < n; j++) + check += x2[ r * j + 0]; + ok &= NearEqual(y2[0] , check, eps, eps); + // + check = 0.0; + for(j = 0; j < n; j++) + check += x2[ r * j + 1]; + ok &= NearEqual(y2[1] , check, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // DisOp (test assuming that AddvvOp is correct) + double round_off(const double& x) + { // std::round(x); is C++11, so we avoid using it + return std::floor( x + 0.5 ); + } + CPPAD_DISCRETE_FUNCTION(double, round_off) + bool dis_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; + + // 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); + + // zero order + CPPAD_TESTVECTOR(double) x0(n), y0; + x0[0] = 2.2; + y0 = f.Forward(0, x0); + 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; + 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) = 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) + double y_1_1 = 2.0; + double y_2_1 = 3.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // DivpvOp (testing assumping MulpvOp is correct) + bool divpv_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; + + // 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]) * (ax[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) = 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)] + // = 2.0 * (0.5 + 2t + 3t^2)/2.0 + double y_1_1 = 4.0; + double y_2_1 = 6.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // 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; + + // 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; + + // 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 + 3); + } + y2 = f.Forward(2, r, x2); + 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)] + // = (0.5 + 2t + 4t^2)/2.0 + double y_1_1 = 2.0 / 2.0; + double y_2_1 = 4.0 / 2.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // 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; + + // 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; + 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) = 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)] + // = 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; + double y_2_1 = ( exp(0.5)*6.0 + exp(0.5)*2.0*2.0 ) / 2.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // LdpOp and LdvOp (test assuming AdvvOp is correct) + bool load_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.0; + ax[1] = 1.0; + + // declare independent variables and starting recording + CppAD::Independent(ax); + + // Store operations + CppAD::VecAD avec(3); + 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 + 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); + + // zero order Taylor coefficients + CPPAD_TESTVECTOR(double) x0(n), y0; + x0[0] = 2; + x0[1] = 3; + y0 = f.Forward(0, x0); + 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; + + // 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; + // + // 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; + // + ok &= NearEqual(y1[0*r+0] , y0_1_0, eps, eps); + ok &= NearEqual(y1[1*r+0] , y1_1_0, eps, eps); + ok &= NearEqual(y1[0*r+1] , y0_1_1, eps, eps); + ok &= NearEqual(y1[1*r+1] , y1_1_1, eps, eps); + // + ok &= NearEqual(y2[0*r+0] , y0_2_0, eps, eps); + ok &= NearEqual(y2[1*r+0] , y1_2_0, eps, eps); + ok &= NearEqual(y2[0*r+1] , y0_2_1, eps, eps); + ok &= NearEqual(y2[1*r+1] , y1_2_1, eps, eps); + // + return ok; + } + + // --------------------------------------------------------------------- + // 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; + + // 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; + 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 + 3); + } + y2 = f.Forward(2, r, x2); + 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)] + // = 2.0 * (0.5 + 2t + 4t^2) + double y_1_1 = 2.0 * 2.0; + double y_2_1 = 2.0 * 4.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + 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[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; + 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; + // + // 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; + // + ok &= NearEqual(y1[0*r+0] , y0_1_0, eps, eps); + ok &= NearEqual(y1[1*r+0] , y1_1_0, eps, eps); + ok &= NearEqual(y1[0*r+1] , y0_1_1, eps, eps); + ok &= NearEqual(y1[1*r+1] , y1_1_1, eps, eps); + // + ok &= NearEqual(y2[0*r+0] , y0_2_0, eps, eps); + ok &= NearEqual(y2[1*r+0] , y1_2_0, eps, eps); + ok &= NearEqual(y2[0*r+1] , y0_2_1, eps, eps); + ok &= NearEqual(y2[1*r+1] , y1_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // SignOp (test assuming that MulvvOp is correct) + bool sign_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; + + // 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); + + // zero order + CPPAD_TESTVECTOR(double) x0(n), y0; + x0[0] = -3.0; + y0 = f.Forward(0, x0); + ok &= size_t( y0.size() ) == m; + ok &= NearEqual(y0[0], fabs(x0[0]), eps, eps); + + // 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) = 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) + double y_1_1 = -2.0; + double y_2_1 = -3.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + + // --------------------------------------------------------------------- + // 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; + + // 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; + 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) = 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)] + // = 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; + double y_2_1 = ( cos(0.5) * 6.0 - sin(0.5) * 4.0 ) / 2.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // 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; + + // 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; + 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) = 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)] + // = 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; + double y_2_1 = ( cosh(0.5) * 6.0 + sinh(0.5) * 4.0 ) / 2.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // 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; + + // 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; + 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 + 3); + } + y2 = f.Forward(2, r, x2); + 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)] + // = 3.0 - (0.5 + 2t + 4t^2)/2.0 + double y_1_1 = - 2.0; + double y_2_1 = - 4.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // 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[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; + 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) = 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)] + // = (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; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // 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; + + // 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; + 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) = 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)] + // = 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) + double y_1_1 = 2.0 * sec_sq; + double y_2_1 = (8.0 * tan(0.5) + 6.0) * sec_sq / 2.0; + // + ok &= NearEqual(y1[0] , y_1_0, eps, eps); + ok &= NearEqual(y1[1] , y_1_1, eps, eps); + ok &= NearEqual(y2[0] , y_2_0, eps, eps); + ok &= NearEqual(y2[1] , y_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // Usr*Op + typedef CPPAD_TESTVECTOR(AD) avector; + void usr_algo(const avector& x, avector& z) + { z[0] = ( x[0] + x[1] ) / 2.0; + z[1] = x[0] * x[1]; + z[2] = ( x[0] - x[1] ) / 2.0; + return; + } + bool usr_op(void) + { bool ok = true; + double eps = 10. * std::numeric_limits::epsilon(); + size_t j; + + // define checkpoint function + size_t n = 2; + avector ax(n), az(3); + ax[0] = 0.5; + ax[1] = 2.0; + CppAD::checkpoint usr_check("usr_check", usr_algo, ax, az); + + // declare independent variables and starting recording + CppAD::Independent(ax); + + // record checkpoint function + usr_check(ax, az); + + // range space vector + size_t m = 2; + avector ay(m); + ay[0] = az[0] + az[2]; // = ax[0] + ay[1] = az[0] - az[2]; // = 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; + 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; + // + // 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; + // + ok &= NearEqual(y1[0*r+0] , y0_1_0, eps, eps); + ok &= NearEqual(y1[1*r+0] , y1_1_0, eps, eps); + ok &= NearEqual(y1[0*r+1] , y0_1_1, eps, eps); + ok &= NearEqual(y1[1*r+1] , y1_1_1, eps, eps); + // + ok &= NearEqual(y2[0*r+0] , y0_2_0, eps, eps); + ok &= NearEqual(y2[1*r+0] , y1_2_0, eps, eps); + ok &= NearEqual(y2[0*r+1] , y0_2_1, eps, eps); + ok &= NearEqual(y2[1*r+1] , y1_2_1, eps, eps); + // + return ok; + } + // --------------------------------------------------------------------- + // Inverse functions assume the following already tested: + // CosOp, SinOp, TanOp, ExpOp, MulvvOp, DivvpOp, AddpvOp + // + // AcosOp + AD acos_fun(const AD& x) + { return acos( cos(x) ); } + bool acos_op(void) + { return check_identity(acos_fun, 0.5); } + // + // 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); } + // + // 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); } + // + // 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) + { return check_identity(log_fun, 0.5); } + // + // DivvvOp + AD divvv_fun(const AD& x) + { return (x * x) / x; } + bool divvv_op(void) + { return check_identity(divvv_fun, 0.5); } + // + // PowpvOp + AD powpv_fun(const AD& x ) + { return log( pow( exp(3.0) , x ) ) / 3.0; } + bool powpv_op(void) + { return check_identity(powpv_fun, 0.5); } + // + // PowvpOp + AD powvp_fun(const AD& x ) + { return log( pow( exp(x) , 3.0 ) ) / 3.0; } + bool powvp_op(void) + { return check_identity(powvp_fun, 0.5); } + // + // SqrtOp + AD sqrt_fun(const AD& x ) + { return sqrt( x * x ); } + bool sqrt_op(void) + { return check_identity(sqrt_fun, 0.5); } + // + // SubvpOp + AD subvp_fun(const AD& x ) + { return 3.0 + ( x - 3.0 ); } + bool subvp_op(void) + { return check_identity(subvp_fun, 0.5); } + // + // TanhOp + AD tanh_fun(const AD& x ) + { AD z = tanh(x); + return log( (1.0 + z) / (1.0 - z) ) / 2.0; + } + bool tanh_op(void) + { return check_identity(tanh_fun, 0.5); } } bool forward_dir(void) -{ bool ok = true; - // - 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(); - ok &= cosh_op(); - ok &= cos_op(); - ok &= csum_op(); - ok &= dis_op(); - ok &= divpv_op(); - ok &= divvp_op(); - ok &= divvv_op(); - ok &= exp_op(); - ok &= load_op(); - ok &= log_op(); - ok &= mulpv_op(); - ok &= par_op(); - ok &= powpv_op(); - ok &= powvp_op(); - ok &= powvv_op(); - ok &= sign_op(); - ok &= sin_op(); - ok &= sinh_op(); - ok &= subpv_op(); - ok &= subvp_op(); - ok &= subvv_op(); - ok &= sqrt_op(); - ok &= tan_op(); - ok &= tanh_op(); - ok &= usr_op(); - // - return ok; +{ bool ok = true; + // + 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(); + ok &= cosh_op(); + ok &= cos_op(); + ok &= csum_op(); + ok &= dis_op(); + ok &= divpv_op(); + ok &= divvp_op(); + ok &= divvv_op(); + ok &= exp_op(); + ok &= load_op(); + ok &= log_op(); + ok &= mulpv_op(); + ok &= par_op(); + ok &= powpv_op(); + ok &= powvp_op(); + ok &= powvv_op(); + ok &= sign_op(); + ok &= sin_op(); + ok &= sinh_op(); + ok &= subpv_op(); + ok &= subvp_op(); + ok &= subvv_op(); + ok &= sqrt_op(); + ok &= tan_op(); + ok &= tanh_op(); + ok &= usr_op(); + // + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/forward_order.cpp cppad-2019.02.00.0/test_more/general/forward_order.cpp --- cppad-2018.00.00.0/test_more/general/forward_order.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/forward_order.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* */ @@ -16,184 +17,184 @@ namespace { - double my_discrete(const double& x) - { return static_cast ( x ); } - CPPAD_DISCRETE_FUNCTION(double, my_discrete) + double my_discrete(const double& x) + { return static_cast ( x ); } + CPPAD_DISCRETE_FUNCTION(double, my_discrete) } bool forward_order(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t j, k; - double eps = 10. * CppAD::numeric_limits::epsilon(); - - // domain space vector - size_t n = 23, m = n; - CPPAD_TESTVECTOR(AD) X(n), Y(m); - for(j = 0; j < n; j++) - X[j] = 0.0; - - // declare independent variables and starting recording - CppAD::Independent(X); - - // identity function values - size_t i = 0; - size_t identity_begin = i; - Y[i] = cos( acos( X[i] ) ); i++; // AcosOp, CosOp - Y[i] = sin( asin( X[i] ) ); i++; // AsinOp, SinOp - Y[i] = tan( atan( X[i] ) ); i++; // AtanOp, TanOp - Y[i] = CondExpGt(X[i], X[i-1], X[i], X[i-2]); i++; // CExpOp - Y[i] = X[i-1] * X[i] / X[i-1]; i++; // DivvvOp, MulvvOp - Y[i] = X[i] * X[i] * 1.0 / X[i]; i++; // DivpvOp - Y[i] = 5.0 * X[i] / 5.0; i++; // DivvpOp, MulpvOp - Y[i] = exp( log( X[i] ) ); i++; // ExpOp, LogOp - Y[i] = pow( sqrt( X[i] ), 2.0); i++; // PowvpOp, SqrtOp - Y[i] = log( pow( std::exp(1.), X[i] ) ); i++; // PowpvOp - Y[i] = log( pow( X[i], X[i] ) ) / log( X[i]); i++; // PowvvOp - Y[i] = -2. - ((X[i-1] - X[i]) - 2.) + X[i-1]; i++; // Sub*Op: pv, vv, vp - size_t identity_end = i; - - // other functions - Y[i] = fabs( X[i] ); i++; // AbsOp - Y[i] = X[i-1] + X[i] + 2.0; i++; // AddvvOp, AddvpOp - Y[i] = cosh( X[i] ); i++; // CoshOp - Y[i] = my_discrete( X[i] ); i++; // DisOp - Y[i] = 4.0; i++; // ParOp - Y[i] = sign( X[i] ); i++; // SignOp - Y[i] = sinh( X[i] ); i++; // SinhOp - Y[i] = tanh(X[i]); i++; // TanhOp - - // VecAD operations - CppAD::VecAD V(n); - AD index = 1.; - V[index] = 3.0; - Y[i] = V[index]; i++; // StppOp, LdpOp - V[index] = X[0]; - Y[i] = V[index]; i++; // StpvOp, LdpOp - index = double(n) * X[3]; - V[index] = X[1]; - Y[i] = V[index]; i++; // StvvOp, LdvOp - - // create f: X -> Y and stop tape recording - assert( i == m ); - CppAD::ADFun f; - f.Dependent(X, Y); - - // initially, no values stored in f - ok &= f.size_order() == 0; - - // Set X_j (t) = x + t - 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_p[j * p1 + 0] = x[j]; // order 0 - x_p[j * p1 + 1] = 1.; // order 1 - x_p[j * p1 + 2] = 0.; // order 2 - } - // compute orders 0, 1, 2 - y_p = f.Forward(p, x_p); - - // identity functions - CPPAD_TESTVECTOR(double) y(p1); - i = 0; - for(j = identity_begin; j != identity_end; j++) - { y[0] = x[j]; - y[1] = 1.0; - y[2] = 0.0; - for(k = 0; k < p1; k++) - ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); - i++; - } - - // y_i = fabs( x_i ) - y[0] = fabs( x[i] ); - y[1] = CppAD::sign( x[i] ); - y[2] = 0.0; - for(k = 0; k < p1; k++) - ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); - - // y_i = x_[i-1] + x_i + 2 - i++; - y[0] = x[i-1] + x[i] + 2.0; - y[1] = 2.0; - y[2] = 0.0; - for(k = 0; k < p1; k++) - ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); - - // y_i = cosh( x_i ) - i++; - y[0] = CppAD::cosh( x[i] ); - y[1] = CppAD::sinh( x[i] ); - y[2] = CppAD::cosh( x[i] ) / 2.0; - for(k = 0; k < p1; k++) - ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); - - // y_i = my_discrete( x_i ) - i++; - y[0] = my_discrete( x[i] ); - y[1] = 0.0; - y[2] = 0.0; - for(k = 0; k < p1; k++) - ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); - - // y_i = 4 - i++; - y[0] = 4.0; - y[1] = 0.0; - y[2] = 0.0; - for(k = 0; k < p1; k++) - ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); - - // y_i = sign( x_i ) - i++; - y[0] = CppAD::sign( x[i] ); - y[1] = 0.0; - y[2] = 0.0; - for(k = 0; k < p1; k++) - ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); - - // y_i = sinh( x_i ) - i++; - y[0] = CppAD::sinh( x[i] ); - y[1] = CppAD::cosh( x[i] ); - y[2] = CppAD::sinh( x[i] ) / 2.0; - for(k = 0; k < p1; k++) - ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); - - // y_i = tanh( x_i ) - i++; - y[0] = CppAD::tanh( x[i] ); - y[1] = 1.0 - y[0] * y[0]; - y[2] = - 2.0 * y[0] * y[1] / 2.0; - for(k = 0; k < p1; k++) - ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); - - // y_i = 3.0; - i++; - y[0] = 3.0; - y[1] = 0.0; - y[2] = 0.0; - for(k = 0; k < p1; k++) - ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); - - // y_i = x_0 - i++; - y[0] = x[0]; - y[1] = 1.0; - y[2] = 0.0; - for(k = 0; k < p1; k++) - ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); - - // y_i = x_1 - i++; - y[0] = x[1]; - y[1] = 1.0; - y[2] = 0.0; - for(k = 0; k < p1; k++) - ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t j, k; + double eps = 10. * CppAD::numeric_limits::epsilon(); + + // domain space vector + size_t n = 23, m = n; + CPPAD_TESTVECTOR(AD) X(n), Y(m); + for(j = 0; j < n; j++) + X[j] = 0.0; + + // declare independent variables and starting recording + CppAD::Independent(X); + + // identity function values + size_t i = 0; + size_t identity_begin = i; + Y[i] = cos( acos( X[i] ) ); i++; // AcosOp, CosOp + Y[i] = sin( asin( X[i] ) ); i++; // AsinOp, SinOp + Y[i] = tan( atan( X[i] ) ); i++; // AtanOp, TanOp + Y[i] = CondExpGt(X[i], X[i-1], X[i], X[i-2]); i++; // CExpOp + Y[i] = X[i-1] * X[i] / X[i-1]; i++; // DivvvOp, MulvvOp + Y[i] = X[i] * X[i] * 1.0 / X[i]; i++; // DivpvOp + Y[i] = 5.0 * X[i] / 5.0; i++; // DivvpOp, MulpvOp + Y[i] = exp( log( X[i] ) ); i++; // ExpOp, LogOp + Y[i] = pow( sqrt( X[i] ), 2.0); i++; // PowvpOp, SqrtOp + Y[i] = log( pow( std::exp(1.), X[i] ) ); i++; // PowpvOp + Y[i] = log( pow( X[i], X[i] ) ) / log( X[i]); i++; // PowvvOp + Y[i] = -2. - ((X[i-1] - X[i]) - 2.) + X[i-1]; i++; // Sub*Op: pv, vv, vp + size_t identity_end = i; + + // other functions + Y[i] = fabs( X[i] ); i++; // AbsOp + Y[i] = X[i-1] + X[i] + 2.0; i++; // AddvvOp, AddvpOp + Y[i] = cosh( X[i] ); i++; // CoshOp + Y[i] = my_discrete( X[i] ); i++; // DisOp + Y[i] = 4.0; i++; // ParOp + Y[i] = sign( X[i] ); i++; // SignOp + Y[i] = sinh( X[i] ); i++; // SinhOp + Y[i] = tanh(X[i]); i++; // TanhOp + + // VecAD operations + CppAD::VecAD V(n); + AD index = 1.; + V[index] = 3.0; + Y[i] = V[index]; i++; // StppOp, LdpOp + V[index] = X[0]; + Y[i] = V[index]; i++; // StpvOp, LdpOp + index = double(n) * X[3]; + V[index] = X[1]; + Y[i] = V[index]; i++; // StvvOp, LdvOp + + // create f: X -> Y and stop tape recording + assert( i == m ); + CppAD::ADFun f; + f.Dependent(X, Y); + + // initially, no values stored in f + ok &= f.size_order() == 0; + + // Set X_j (t) = x + t + 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_p[j * p1 + 0] = x[j]; // order 0 + x_p[j * p1 + 1] = 1.; // order 1 + x_p[j * p1 + 2] = 0.; // order 2 + } + // compute orders 0, 1, 2 + y_p = f.Forward(p, x_p); + + // identity functions + CPPAD_TESTVECTOR(double) y(p1); + i = 0; + for(j = identity_begin; j != identity_end; j++) + { y[0] = x[j]; + y[1] = 1.0; + y[2] = 0.0; + for(k = 0; k < p1; k++) + ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); + i++; + } + + // y_i = fabs( x_i ) + y[0] = fabs( x[i] ); + y[1] = CppAD::sign( x[i] ); + y[2] = 0.0; + for(k = 0; k < p1; k++) + ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); + + // y_i = x_[i-1] + x_i + 2 + i++; + y[0] = x[i-1] + x[i] + 2.0; + y[1] = 2.0; + y[2] = 0.0; + for(k = 0; k < p1; k++) + ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); + + // y_i = cosh( x_i ) + i++; + y[0] = CppAD::cosh( x[i] ); + y[1] = CppAD::sinh( x[i] ); + y[2] = CppAD::cosh( x[i] ) / 2.0; + for(k = 0; k < p1; k++) + ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); + + // y_i = my_discrete( x_i ) + i++; + y[0] = my_discrete( x[i] ); + y[1] = 0.0; + y[2] = 0.0; + for(k = 0; k < p1; k++) + ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); + + // y_i = 4 + i++; + y[0] = 4.0; + y[1] = 0.0; + y[2] = 0.0; + for(k = 0; k < p1; k++) + ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); + + // y_i = sign( x_i ) + i++; + y[0] = CppAD::sign( x[i] ); + y[1] = 0.0; + y[2] = 0.0; + for(k = 0; k < p1; k++) + ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); + + // y_i = sinh( x_i ) + i++; + y[0] = CppAD::sinh( x[i] ); + y[1] = CppAD::cosh( x[i] ); + y[2] = CppAD::sinh( x[i] ) / 2.0; + for(k = 0; k < p1; k++) + ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); + + // y_i = tanh( x_i ) + i++; + y[0] = CppAD::tanh( x[i] ); + y[1] = 1.0 - y[0] * y[0]; + y[2] = - 2.0 * y[0] * y[1] / 2.0; + for(k = 0; k < p1; k++) + ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); + + // y_i = 3.0; + i++; + y[0] = 3.0; + y[1] = 0.0; + y[2] = 0.0; + for(k = 0; k < p1; k++) + ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); + + // y_i = x_0 + i++; + y[0] = x[0]; + y[1] = 1.0; + y[2] = 0.0; + for(k = 0; k < p1; k++) + ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); + + // y_i = x_1 + i++; + y[0] = x[1]; + y[1] = 1.0; + y[2] = 0.0; + for(k = 0; k < p1; k++) + ok &= NearEqual(y[k] , y_p[i * p1 + k], eps, eps); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/from_base.cpp cppad-2019.02.00.0/test_more/general/from_base.cpp --- cppad-2018.00.00.0/test_more/general/from_base.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/from_base.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* @@ -16,41 +17,41 @@ # include bool FromBase(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // construct directly form Base where Base = double - AD x(1.); - AD y = 2.; + // construct directly form Base where Base = double + AD x(1.); + AD y = 2.; - // construct from a type that can be converted to Base - // where Base = AD - AD< AD > X(1.); - AD< AD > Y(2); + // construct from a type that can be converted to Base + // where Base = AD + AD< AD > X(1.); + AD< AD > Y(2); - // check that resulting objects are parameters - ok &= Parameter(x); - ok &= Parameter(y); + // check that resulting objects are parameters + ok &= Parameter(x); + ok &= Parameter(y); - ok &= Parameter(X); - ok &= Parameter(Y); + ok &= Parameter(X); + ok &= Parameter(Y); - // check values of objects - ok &= (x == 1.); - ok &= (X == x); + // check values of objects + ok &= (x == 1.); + ok &= (X == x); - ok &= (y == 2.); - ok &= (Y == y); + ok &= (y == 2.); + ok &= (Y == y); - // user constructor through the static_cast template function - x = static_cast < AD >( 4 ); - X = static_cast < AD< AD > >( 4 ); + // user constructor through the static_cast template function + x = static_cast < AD >( 4 ); + X = static_cast < AD< AD > >( 4 ); - ok &= (x == 4.); - ok &= (X == x); + ok &= (x == 4.); + ok &= (X == x); - return ok; + return ok; } // END PROGRAM diff -Nru cppad-2018.00.00.0/test_more/general/fun_check.cpp cppad-2019.02.00.0/test_more/general/fun_check.cpp --- cppad-2018.00.00.0/test_more/general/fun_check.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/fun_check.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* old example, now just used for testing deprecated syntax f.Dependent(y) */ @@ -20,108 +21,109 @@ template class Fun { private: - size_t n; + size_t n; public: - // function constructor - Fun(size_t n_) : n(n_) - { } - // function evaluator - Vector operator() (const Vector &x) - { Vector y(n); - size_t i; - for(i = 0; i < n; i++) - { // This operaiton sequence depends on x - if( x[i] >= 0 ) - y[i] = exp(x[i]); - else y[i] = exp(-x[i]); - } - return y; - } + // function constructor + Fun(size_t n_) : n(n_) + { } + // function evaluator + Vector operator() (const Vector &x) + { Vector y(n); + size_t i; + for(i = 0; i < n; i++) + { // This operaiton sequence depends on x + if( x[i] >= 0 ) + y[i] = exp(x[i]); + else + y[i] = exp(-x[i]); + } + return y; + } }; // template function FunCheckCases in empty namespace template bool FunCheckCases(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::ADFun; - using CppAD::Independent; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // use the ADFun default constructor - ADFun f; - - // domain space vector - size_t n = 2; - ADVector X(n); - X[0] = -1.; - X[1] = 1.; - - // declare independent variables and starting recording - Independent(X); - - // create function object to use with AD - Fun< AD, ADVector > G(n); - - // range space vector - size_t m = n; - ADVector Y(m); - Y = G(X); - - // stop tape and store operation sequence in f : X -> Y - f.Dependent(Y); - ok &= (f.size_order() == 0); // no implicit forward operation - - // create function object to use with double - Fun g(n); - - // 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 = eps99; - double a = eps99; - ok &= FunCheck(f, g, x, a, r); - - // function values should not agree when the independent variable - // values are the negative of values during recording - for(j = 0; j < n; j++) - x[j] = - Value(X[j]); - ok &= ! FunCheck(f, g, x, a, r); - - // re-tape to obtain the new AD of double operation sequence - for(j = 0; j < n; j++) - X[j] = x[j]; - Independent(X); - Y = G(X); - - // stop tape and store operation sequence in f : X -> Y - f.Dependent(Y); - ok &= (f.size_order() == 0); // no implicit forward with this x +{ bool ok = true; + using CppAD::AD; + using CppAD::ADFun; + using CppAD::Independent; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // use the ADFun default constructor + ADFun f; + + // domain space vector + size_t n = 2; + ADVector X(n); + X[0] = -1.; + X[1] = 1.; + + // declare independent variables and starting recording + Independent(X); + + // create function object to use with AD + Fun< AD, ADVector > G(n); + + // range space vector + size_t m = n; + ADVector Y(m); + Y = G(X); + + // stop tape and store operation sequence in f : X -> Y + f.Dependent(Y); + ok &= (f.size_order() == 0); // no implicit forward operation + + // create function object to use with double + Fun g(n); + + // 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 = eps99; + double a = eps99; + ok &= FunCheck(f, g, x, a, r); + + // function values should not agree when the independent variable + // values are the negative of values during recording + for(j = 0; j < n; j++) + x[j] = - Value(X[j]); + ok &= ! FunCheck(f, g, x, a, r); + + // re-tape to obtain the new AD of double operation sequence + for(j = 0; j < n; j++) + X[j] = x[j]; + Independent(X); + Y = G(X); + + // stop tape and store operation sequence in f : X -> Y + f.Dependent(Y); + ok &= (f.size_order() == 0); // no implicit forward with this x - // function values should agree now - ok &= FunCheck(f, g, x, a, r); + // function values should agree now + ok &= FunCheck(f, g, x, a, r); - return ok; + return ok; } } // End empty namespace # include # include bool FunCheck(void) -{ bool ok = true; - typedef CppAD::vector Vector1; - typedef CppAD::vector< CppAD::AD > ADVector1; - typedef std::vector Vector2; - typedef std::vector< CppAD::AD > ADVector2; - 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 - // double and AD respectively. - ok &= FunCheckCases< Vector1, ADVector2 >(); - ok &= FunCheckCases< Vector2, ADVector3 >(); - ok &= FunCheckCases< Vector3, ADVector1 >(); - return ok; +{ bool ok = true; + typedef CppAD::vector Vector1; + typedef CppAD::vector< CppAD::AD > ADVector1; + typedef std::vector Vector2; + typedef std::vector< CppAD::AD > ADVector2; + 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 + // double and AD respectively. + ok &= FunCheckCases< Vector1, ADVector2 >(); + ok &= FunCheckCases< Vector2, ADVector3 >(); + ok &= FunCheckCases< Vector3, ADVector1 >(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/general.cpp cppad-2019.02.00.0/test_more/general/general.cpp --- cppad-2018.00.00.0/test_more/general/general.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/general.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // CPPAD_HAS_* defines # include @@ -21,76 +22,78 @@ // test runner # include -// prototype external compiled tests (this line expected by bin/new_test.sh) -extern bool fabs(void); -extern bool acos(void); +// BEGIN_SORT_THIS_LINE_PLUS_1 extern bool acosh(void); -extern bool adfun_copy(void); -extern bool Add(void); +extern bool acos(void); extern bool AddEq(void); +extern bool Add(void); extern bool AddZero(void); +extern bool adfun_copy(void); extern bool alloc_openmp(void); -extern bool asin(void); extern bool asinh(void); +extern bool asin(void); extern bool assign(void); -extern bool atan(void); -extern bool atanh(void); extern bool atan2(void); -extern bool atomic_sparsity(void); +extern bool atanh(void); +extern bool atan(void); +extern bool atomic_three(void); extern bool azmul(void); extern bool base_adolc(void); extern bool base_alloc_test(void); extern bool bool_sparsity(void); +extern bool chkpoint_one(void); +extern bool chkpoint_two(void); extern bool check_simple_vector(void); -extern bool checkpoint(void); -extern bool Compare(void); extern bool compare_change(void); -extern bool CondExp(void); +extern bool Compare(void); extern bool CondExpAD(void); extern bool cond_exp_rev(void); +extern bool CondExp(void); extern bool copy(void); -extern bool Cos(void); extern bool Cosh(void); +extern bool Cos(void); extern bool cppad_eigen(void); extern bool dbl_epsilon(void); extern bool dependency(void); -extern bool Div(void); extern bool DivEq(void); +extern bool Div(void); extern bool DivZeroOne(void); extern bool eigen_mat_inv(void); extern bool erf(void); -extern bool Exp(void); extern bool expm1(void); +extern bool Exp(void); +extern bool fabs(void); extern bool ForHess(void); extern bool for_sparse_hes(void); extern bool for_sparse_jac(void); -extern bool Forward(void); extern bool forward_dir(void); extern bool forward_order(void); +extern bool Forward(void); extern bool FromBase(void); extern bool FunCheck(void); extern bool hes_sparsity(void); extern bool ipopt_solve(void); extern bool jacobian(void); -extern bool log(void); extern bool log10(void); extern bool log1p(void); -extern bool Mul(void); -extern bool mul_level(void); +extern bool log(void); extern bool mul_cond_rev(void); extern bool mul_cskip(void); extern bool MulEq(void); +extern bool mul_level(void); +extern bool Mul(void); extern bool mul_zdouble(void); extern bool MulZeroOne(void); extern bool NearEqualExt(void); extern bool Neg(void); +extern bool new_dynamic(void); extern bool num_limits(void); extern bool ode_err_control(void); extern bool optimize(void); extern bool parameter(void); extern bool Poly(void); -extern bool Pow(void); extern bool PowInt(void); +extern bool Pow(void); extern bool print_for(void); extern bool reverse(void); extern bool rev_sparse_jac(void); @@ -99,158 +102,164 @@ extern bool Rosen34(void); extern bool Runge45(void); extern bool SimpleVector(void); -extern bool Sin(void); extern bool SinCos(void); extern bool Sinh(void); +extern bool Sin(void); extern bool sparse_hessian(void); extern bool sparse_jacobian(void); +extern bool sparse_jac_work(void); extern bool sparse_sub_hes(void); extern bool sparse_vec_ad(void); extern bool Sqrt(void); extern bool std_math(void); -extern bool Sub(void); extern bool SubEq(void); extern bool subgraph(void); +extern bool Sub(void); extern bool SubZero(void); extern bool tan(void); -extern bool to_string(void); extern bool test_vector(void); +extern bool to_string(void); extern bool Value(void); -extern bool VecAD(void); extern bool VecADPar(void); +extern bool VecAD(void); extern bool VecUnary(void); +// END_SORT_THIS_LINE_MINUS_1 // tests in local subdirectory extern bool vector_set(void); // main program that runs all the tests int main(void) -{ std::string group = "test_more/general"; - size_t width = 20; - CppAD::test_boolofvoid Run(group, width); - - // This line is used by test_one.sh - - // run external compiled tests (this line expected by bin/new_test.sh) - Run( fabs, "fabs" ); - Run( acos, "acos" ); - Run( acosh, "acosh" ); - Run( adfun_copy, "adfun_copy" ); - Run( Add, "Add" ); - Run( AddEq, "AddEq" ); - Run( AddZero, "AddZero" ); - Run( asin, "asin" ); - Run( asinh, "asinh" ); - Run( assign, "assign" ); - Run( atan, "atan" ); - Run( atanh, "atanh" ); - Run( atan2, "atan2" ); - Run( atomic_sparsity, "atomic_sparsity"); - Run( azmul, "azmul" ); - Run( bool_sparsity, "bool_sparsity" ); - Run( check_simple_vector, "check_simple_vector" ); - Run( checkpoint, "checkpoint" ); - Run( Compare, "Compare" ); - Run( compare_change, "compare_change" ); - Run( CondExp, "CondExp" ); - Run( CondExpAD, "CondExpAD" ); - Run( cond_exp_rev, "cond_exp_rev" ); - Run( copy, "copy" ); - Run( Cos, "Cos" ); - Run( Cosh, "Cosh" ); - Run( dbl_epsilon, "dbl_epsilon" ); - Run( dependency, "dependency" ); - Run( Div, "Div" ); - Run( DivEq, "DivEq" ); - Run( DivZeroOne, "DivZeroOne" ); - Run( erf, "erf" ); - Run( Exp, "Exp" ); - Run( expm1, "expm1" ); - Run( ForHess, "ForHess" ); - Run( for_sparse_hes, "for_sparse_hes" ); - Run( for_sparse_jac, "for_sparse_jac" ); - Run( Forward, "Forward" ); - Run( forward_dir, "forward_dir" ); - Run( forward_order, "forward_order" ); - Run( FromBase, "FromBase" ); - Run( FunCheck, "FunCheck" ); - Run( hes_sparsity, "hes_sparsity" ); - Run( jacobian, "jacobian" ); - Run( log, "log" ); - Run( log10, "log10" ); - Run( log1p, "log1p" ); - Run( Mul, "Mul" ); - Run( mul_level, "mul_level" ); - Run( mul_cond_rev, "mul_cond_rev" ); - Run( mul_cskip, "Mul_cskip" ); - Run( MulEq, "MulEq" ); - Run( mul_zdouble, "mul_zdouble" ); - Run( MulZeroOne, "MulZeroOne" ); - Run( NearEqualExt, "NearEqualExt" ); - Run( Neg, "Neg" ); - Run( num_limits, "num_limits" ); - Run( ode_err_control, "ode_err_control"); - Run( optimize, "optimize" ); - Run( parameter, "parameter" ); - Run( Poly, "Poly" ); - Run( Pow, "Pow" ); - Run( PowInt, "PowInt" ); - Run( print_for, "print_for" ); - Run( reverse, "reverse" ); - Run( rev_sparse_jac, "rev_sparse_jac" ); - Run( RevTwo, "RevTwo" ); - Run( RombergOne, "RombergOne" ); - Run( Rosen34, "Rosen34" ); - Run( Runge45, "Runge45" ); - Run( SimpleVector, "SimpleVector" ); - Run( Sin, "Sin" ); - Run( SinCos, "SinCos" ); - Run( Sinh, "Sinh" ); - Run( sparse_hessian, "sparse_hessian" ); - Run( sparse_jacobian, "sparse_jacobian"); - Run( sparse_sub_hes, "sparse_sub_hes" ); - Run( sparse_vec_ad, "sparse_vec_ad" ); - Run( Sqrt, "Sqrt" ); - Run( std_math, "std_math" ); - Run( Sub, "Sub" ); - Run( SubEq, "SubEq" ); - Run( subgraph, "subgraph" ); - Run( SubZero, "SubZero" ); - Run( tan, "tan" ); - Run( to_string, "to_string" ); - Run( Value, "Value" ); - Run( VecAD, "VecAD" ); - Run( VecADPar, "VecADPar" ); - Run( VecUnary, "VecUnary" ); +{ std::string group = "test_more/general"; + size_t width = 20; + CppAD::test_boolofvoid Run(group, width); + + // This line is used by test_one.sh + + // BEGIN_SORT_THIS_LINE_PLUS_1 + Run( acos, "acos" ); + Run( acosh, "acosh" ); + Run( Add, "Add" ); + Run( AddEq, "AddEq" ); + Run( AddZero, "AddZero" ); + Run( adfun_copy, "adfun_copy" ); + Run( asin, "asin" ); + Run( asinh, "asinh" ); + Run( assign, "assign" ); + Run( atan2, "atan2" ); + Run( atan, "atan" ); + Run( atanh, "atanh" ); + Run( atomic_three, "atomic_three" ); + Run( azmul, "azmul" ); + Run( bool_sparsity, "bool_sparsity" ); + Run( chkpoint_one, "chkpoint_one" ); + Run( chkpoint_two, "chkpoint_two" ); + Run( check_simple_vector, "check_simple_vector" ); + Run( compare_change, "compare_change" ); + Run( Compare, "Compare" ); + Run( CondExpAD, "CondExpAD" ); + Run( CondExp, "CondExp" ); + Run( cond_exp_rev, "cond_exp_rev" ); + Run( copy, "copy" ); + Run( Cos, "Cos" ); + Run( Cosh, "Cosh" ); + Run( dbl_epsilon, "dbl_epsilon" ); + Run( dependency, "dependency" ); + Run( Div, "Div" ); + Run( DivEq, "DivEq" ); + Run( DivZeroOne, "DivZeroOne" ); + Run( erf, "erf" ); + Run( Exp, "Exp" ); + Run( expm1, "expm1" ); + Run( fabs, "fabs" ); + Run( ForHess, "ForHess" ); + Run( for_sparse_hes, "for_sparse_hes" ); + Run( for_sparse_jac, "for_sparse_jac" ); + Run( forward_dir, "forward_dir" ); + Run( Forward, "Forward" ); + Run( forward_order, "forward_order" ); + Run( FromBase, "FromBase" ); + Run( FunCheck, "FunCheck" ); + Run( hes_sparsity, "hes_sparsity" ); + Run( jacobian, "jacobian" ); + Run( log10, "log10" ); + Run( log1p, "log1p" ); + Run( log, "log" ); + Run( mul_cond_rev, "mul_cond_rev" ); + Run( mul_cskip, "Mul_cskip" ); + Run( MulEq, "MulEq" ); + Run( mul_level, "mul_level" ); + Run( Mul, "Mul" ); + Run( mul_zdouble, "mul_zdouble" ); + Run( MulZeroOne, "MulZeroOne" ); + Run( NearEqualExt, "NearEqualExt" ); + Run( Neg, "Neg" ); + Run( new_dynamic, "new_dynamic" ); + Run( num_limits, "num_limits" ); + Run( ode_err_control, "ode_err_control"); + Run( optimize, "optimize" ); + Run( parameter, "parameter" ); + Run( Poly, "Poly" ); + Run( PowInt, "PowInt" ); + Run( Pow, "Pow" ); + Run( print_for, "print_for" ); + Run( reverse, "reverse" ); + Run( rev_sparse_jac, "rev_sparse_jac" ); + Run( RevTwo, "RevTwo" ); + Run( RombergOne, "RombergOne" ); + Run( Rosen34, "Rosen34" ); + Run( Runge45, "Runge45" ); + Run( SimpleVector, "SimpleVector" ); + Run( SinCos, "SinCos" ); + Run( Sinh, "Sinh" ); + Run( Sin, "Sin" ); + Run( sparse_hessian, "sparse_hessian" ); + Run( sparse_jacobian, "sparse_jacobian"); + Run( sparse_jac_work, "sparse_jac_work"); + Run( sparse_sub_hes, "sparse_sub_hes" ); + Run( sparse_vec_ad, "sparse_vec_ad" ); + Run( Sqrt, "Sqrt" ); + Run( std_math, "std_math" ); + Run( SubEq, "SubEq" ); + Run( subgraph, "subgraph" ); + Run( Sub, "Sub" ); + Run( SubZero, "SubZero" ); + Run( tan, "tan" ); + Run( to_string, "to_string" ); + Run( Value, "Value" ); + Run( VecADPar, "VecADPar" ); + Run( VecAD, "VecAD" ); + Run( VecUnary, "VecUnary" ); + // END_SORT_THIS_LINE_MINUS_1 #if CPPAD_HAS_ADOLC - Run( base_adolc, "base_adolc" ); + Run( base_adolc, "base_adolc" ); # endif #if CPPAD_HAS_IPOPT - Run( ipopt_solve, "ipopt_solve" ); + Run( ipopt_solve, "ipopt_solve" ); # endif # ifdef CPPAD_OPENMP_TEST - Run( alloc_openmp, "alloc_openmp" ); + Run( alloc_openmp, "alloc_openmp" ); # endif # if CPPAD_HAS_EIGEN - Run( cppad_eigen, "cppad_eigen" ); - Run( eigen_mat_inv, "eigen_mat_inv" ); + Run( cppad_eigen, "cppad_eigen" ); + Run( eigen_mat_inv, "eigen_mat_inv" ); # endif # if ! CPPAD_EIGENVECTOR - Run( test_vector, "test_vector" ); + Run( test_vector, "test_vector" ); # endif - // local sub-directory - Run( test_vector, "test_vector" ); - // - // check for memory leak - bool memory_ok = CppAD::thread_alloc::free_all(); - // - // Run base_alloc after memory leak check because base_alloc.hpp uses - // thread_alloc to allocate memory for static copies of nan. - Run( base_alloc_test, "base_alloc" ); - // - // print summary at end - bool ok = Run.summary(memory_ok); - // - return static_cast( ! ok ); + // local sub-directory + Run( test_vector, "test_vector" ); + // + // check for memory leak + bool memory_ok = CppAD::thread_alloc::free_all(); + // + // Run base_alloc after memory leak check because base_alloc.hpp uses + // thread_alloc to allocate memory for static copies of nan. + Run( base_alloc_test, "base_alloc" ); + // + // print summary at end + bool ok = Run.summary(memory_ok); + // + return static_cast( ! ok ); } // END PROGRAM diff -Nru cppad-2018.00.00.0/test_more/general/hes_sparsity.cpp cppad-2019.02.00.0/test_more/general/hes_sparsity.cpp --- cppad-2018.00.00.0/test_more/general/hes_sparsity.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/hes_sparsity.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include @@ -15,406 +16,406 @@ namespace { // Begin empty namespace void forward_sparse_jacobian_bool(CppAD::ADFun& f) -{ size_t n = f.Domain(); - CPPAD_TESTVECTOR(bool) eye(n * n); - for(size_t i = 0; i < n; i++) - { for(size_t j = 0; j < n; j++) - eye[ i * n + j] = (i == j); - } - f.ForSparseJac(n, eye); - return; +{ size_t n = f.Domain(); + CPPAD_TESTVECTOR(bool) eye(n * n); + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n; j++) + eye[ i * n + j] = (i == j); + } + f.ForSparseJac(n, eye); + return; } void forward_sparse_jacobian_set(CppAD::ADFun& f) -{ size_t n = f.Domain(); - CPPAD_TESTVECTOR(std::set) eye(n); - for(size_t i = 0; i < n; i++) - eye[i].insert(i); - f.ForSparseJac(n, eye); - return; +{ size_t n = f.Domain(); + CPPAD_TESTVECTOR(std::set) eye(n); + for(size_t i = 0; i < n; i++) + eye[i].insert(i); + f.ForSparseJac(n, eye); + return; } bool sparse_hessian_test( - CppAD::ADFun& f , - size_t index , - CPPAD_TESTVECTOR(bool)& check ) -{ bool ok = true; - size_t n = f.Domain(); - size_t m = f.Range(); - - // boolean sparsity patterns - CPPAD_TESTVECTOR(bool) r_bool(n), s_bool(m), h_bool(n * n); - for(size_t j = 0; j < n; j++) - r_bool[j] = true; - for(size_t i = 0; i < m; i++) - s_bool[i] = i == index; - // - // bool ForSparseHes - h_bool = f.ForSparseHes(r_bool, s_bool); - for(size_t i = 0; i < n * n; i++) - ok &= h_bool[i] == check[i]; - // - // bool RevSparseHes - forward_sparse_jacobian_bool(f); - h_bool = f.RevSparseHes(n, s_bool); - for(size_t i = 0; i < n * n; i++) - ok &= h_bool[i] == check[i]; - // - // set sparsity patterns - CPPAD_TESTVECTOR( std::set ) r_set(1), s_set(1), h_set(n); - for(size_t j = 0; j < n; j++) - r_set[0].insert(j); - s_set[0].insert(index); - // - // set ForSparseHes - h_set = f.ForSparseHes(r_set, s_set); - for(size_t i = 0; i < n; i++) - { for(size_t j = 0; j < n; j++) - { bool found = h_set[i].find(j) != h_set[i].end(); - ok &= found == check[i * n + j]; - } - } - // - // set RevSparseHes - forward_sparse_jacobian_set(f); - h_set = f.RevSparseHes(n, s_set); - for(size_t i = 0; i < n; i++) - { for(size_t j = 0; j < n; j++) - { bool found = h_set[i].find(j) != h_set[i].end(); - ok &= found == check[i * n + j]; - } - } - // - return ok; + CppAD::ADFun& f , + size_t index , + CPPAD_TESTVECTOR(bool)& check ) +{ bool ok = true; + size_t n = f.Domain(); + size_t m = f.Range(); + + // boolean sparsity patterns + CPPAD_TESTVECTOR(bool) r_bool(n), s_bool(m), h_bool(n * n); + for(size_t j = 0; j < n; j++) + r_bool[j] = true; + for(size_t i = 0; i < m; i++) + s_bool[i] = i == index; + // + // bool ForSparseHes + h_bool = f.ForSparseHes(r_bool, s_bool); + for(size_t i = 0; i < n * n; i++) + ok &= h_bool[i] == check[i]; + // + // bool RevSparseHes + forward_sparse_jacobian_bool(f); + h_bool = f.RevSparseHes(n, s_bool); + for(size_t i = 0; i < n * n; i++) + ok &= h_bool[i] == check[i]; + // + // set sparsity patterns + CPPAD_TESTVECTOR( std::set ) r_set(1), s_set(1), h_set(n); + for(size_t j = 0; j < n; j++) + r_set[0].insert(j); + s_set[0].insert(index); + // + // set ForSparseHes + h_set = f.ForSparseHes(r_set, s_set); + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n; j++) + { bool found = h_set[i].find(j) != h_set[i].end(); + ok &= found == check[i * n + j]; + } + } + // + // set RevSparseHes + forward_sparse_jacobian_set(f); + h_set = f.RevSparseHes(n, s_set); + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n; j++) + { bool found = h_set[i].find(j) != h_set[i].end(); + ok &= found == check[i * n + j]; + } + } + // + return ok; } bool case_one() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 10; + // dimension of the domain space + size_t n = 10; - // dimension of the range space - size_t m = 2; + // dimension of the range space + size_t m = 2; - // temporary indices + // temporary indices - // initialize check values to false - CPPAD_TESTVECTOR(bool) Check(n * n); - for(size_t j = 0; j < n * n; j++) - Check[j] = false; + // initialize check values to false + CPPAD_TESTVECTOR(bool) Check(n * n); + for(size_t j = 0; j < n * n; j++) + Check[j] = false; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - for(size_t j = 0; j < n; j++) - X[j] = AD(j); - Independent(X); + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + for(size_t j = 0; j < n; j++) + X[j] = AD(j); + Independent(X); - // accumulate sum here - AD sum(0.); + // accumulate sum here + AD sum(0.); - // variable * variable - sum += X[2] * X[3]; - Check[2 * n + 3] = Check[3 * n + 2] = true; + // variable * variable + sum += X[2] * X[3]; + Check[2 * n + 3] = Check[3 * n + 2] = true; - // variable / variable - sum += X[4] / X[5]; - Check[4 * n + 5] = Check[5 * n + 4] = Check[5 * n + 5] = true; + // variable / variable + sum += X[4] / X[5]; + Check[4 * n + 5] = Check[5 * n + 4] = Check[5 * n + 5] = true; - // CondExpLt(variable, variable, variable, variable) - sum += CondExpLt(X[1], X[2], sin(X[6]), cos(X[7]) ); - Check[6 * n + 6] = true; - Check[7 * n + 7] = true; + // CondExpLt(variable, variable, variable, variable) + 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; - Check[9 * n + 8] = Check[9 * n + 9] = true; + // pow(variable, variable) + sum += pow(X[8], X[9]); + Check[8 * n + 8] = Check[8 * n + 9] = true; + Check[9 * n + 8] = Check[9 * n + 9] = true; - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = sum; + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = sum; - // variable - variable - Y[1] = X[0] - X[1]; + // variable - variable + Y[1] = X[0] - X[1]; - // create function object F : X -> Y - ADFun F(X, Y); + // create function object F : X -> Y + ADFun F(X, Y); - // check Hessian of F_0 - ok &= sparse_hessian_test(F, 0, Check); + // check Hessian of F_0 + ok &= sparse_hessian_test(F, 0, Check); - // check Hessian of F_1 - for(size_t j = 0; j < n * n; j++) - Check[j] = false; - ok &= sparse_hessian_test(F, 1, Check); + // check Hessian of F_1 + for(size_t j = 0; j < n * n; j++) + Check[j] = false; + ok &= sparse_hessian_test(F, 1, Check); - // ----------------------------------------------------------------------- - return ok; + // ----------------------------------------------------------------------- + return ok; } bool case_two() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 4; + // dimension of the domain space + size_t n = 4; - // dimension of the range space - size_t m = 1; + // dimension of the range space + size_t m = 1; - // initialize check values to false - CPPAD_TESTVECTOR(bool) Check(n * n); - for(size_t j = 0; j < n * n; j++) - Check[j] = false; - - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - for(size_t 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. - 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]; - - // Hessian with respect to x[0] and x[1] is zero. - // Hessian with respect to x[2] and x[3] is full - // (although we know that there are no cross terms, this is an - // 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); - - // ----------------------------------------------------------------- - sparse_hessian_test(F, 0, Check); - // - return ok; + // initialize check values to false + CPPAD_TESTVECTOR(bool) Check(n * n); + for(size_t j = 0; j < n * n; j++) + Check[j] = false; + + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + for(size_t 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. + 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]; + + // Hessian with respect to x[0] and x[1] is zero. + // Hessian with respect to x[2] and x[3] is full + // (although we know that there are no cross terms, this is an + // 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); + + // ----------------------------------------------------------------- + sparse_hessian_test(F, 0, Check); + // + return ok; } bool case_three() -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - // domain space vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; - - // declare independent variables and start recording - CppAD::Independent(X); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - - // make sure reverse jacobian is propagating dependency to - // intermediate values (not just final ones). - Y[0] = X[0] * X[0] + 2; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // ------------------------------------------------------------------ - CPPAD_TESTVECTOR(bool) check(n * n); - check[0] = true; - sparse_hessian_test(f, 0, check); - // - return ok; + // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 0.; + + // declare independent variables and start recording + CppAD::Independent(X); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + + // make sure reverse jacobian is propagating dependency to + // intermediate values (not just final ones). + Y[0] = X[0] * X[0] + 2; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // ------------------------------------------------------------------ + CPPAD_TESTVECTOR(bool) check(n * n); + check[0] = true; + sparse_hessian_test(f, 0, check); + // + return ok; } bool case_four() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 3; + // dimension of the domain space + size_t n = 3; - // dimension of the range space - size_t m = 1; + // dimension of the range space + size_t m = 1; - // inialize the vector as zero - CppAD::VecAD Z(n - 1); - size_t k; - for(k = 0; k < n-1; k++) - Z[k] = 0.; - - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; - X[1] = 1.; - X[2] = 2.; - Independent(X); - - // 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.; - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(m); - - // check results vector - CPPAD_TESTVECTOR( bool ) Check(n * n); - - // y = z[j] where j might be zero or one. - Y[0] = Z[ X[1] ]; - - Check[0 * n + 0] = false; // partial w.r.t x[0], x[0] - Check[0 * n + 1] = false; // partial w.r.t x[0], x[1] - Check[0 * n + 2] = false; // partial w.r.t x[0], x[2] - - Check[1 * n + 0] = false; // partial w.r.t x[1], x[0] - Check[1 * n + 1] = false; // partial w.r.t x[1], x[1] - Check[1 * n + 2] = true; // partial w.r.t x[1], x[2] - - Check[2 * n + 0] = false; // partial w.r.t x[2], x[0] - Check[2 * n + 1] = true; // partial w.r.t x[2], x[1] - Check[2 * n + 2] = false; // partial w.r.t x[2], x[2] - - // create function object F : X -> Y - ADFun F(X, Y); - - // ----------------------------------------------------- - sparse_hessian_test(F, 0, Check); - // - return ok; + // inialize the vector as zero + CppAD::VecAD Z(n - 1); + size_t k; + for(k = 0; k < n-1; k++) + Z[k] = 0.; + + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 0.; + X[1] = 1.; + X[2] = 2.; + Independent(X); + + // 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.; + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(m); + + // check results vector + CPPAD_TESTVECTOR( bool ) Check(n * n); + + // y = z[j] where j might be zero or one. + Y[0] = Z[ X[1] ]; + + Check[0 * n + 0] = false; // partial w.r.t x[0], x[0] + Check[0 * n + 1] = false; // partial w.r.t x[0], x[1] + Check[0 * n + 2] = false; // partial w.r.t x[0], x[2] + + Check[1 * n + 0] = false; // partial w.r.t x[1], x[0] + Check[1 * n + 1] = false; // partial w.r.t x[1], x[1] + Check[1 * n + 2] = true; // partial w.r.t x[1], x[2] + + Check[2 * n + 0] = false; // partial w.r.t x[2], x[0] + Check[2 * n + 1] = true; // partial w.r.t x[2], x[1] + Check[2 * n + 2] = false; // partial w.r.t x[2], x[2] + + // create function object F : X -> Y + ADFun F(X, Y); + + // ----------------------------------------------------- + sparse_hessian_test(F, 0, Check); + // + return ok; } bool case_five(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 1.; - X[1] = 2.; - CppAD::Independent(X); - - size_t m = 2; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = pow(X[0], 2.); - Y[1] = pow(2., X[1]); - - // create function object F : X -> Y - CppAD::ADFun F(X, Y); - - // Test F_0 and F_1 - for(size_t index = 0; index < n; index++) - { CPPAD_TESTVECTOR(bool) check(n * n); - for(size_t i = 0; i < n; i++) - for(size_t j = 0; j < n; j++) - check[i * n + j] = (i == index) & (j == index); - sparse_hessian_test(F, index, check); - } - // - return ok; + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 1.; + X[1] = 2.; + CppAD::Independent(X); + + size_t m = 2; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = pow(X[0], 2.); + Y[1] = pow(2., X[1]); + + // create function object F : X -> Y + CppAD::ADFun F(X, Y); + + // Test F_0 and F_1 + for(size_t index = 0; index < n; index++) + { CPPAD_TESTVECTOR(bool) check(n * n); + for(size_t i = 0; i < n; i++) + for(size_t j = 0; j < n; j++) + check[i * n + j] = (i == index) & (j == index); + sparse_hessian_test(F, index, check); + } + // + return ok; } // Note ForSparseHes does not work for this case because R not diagonal. bool case_six() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 3; + // dimension of the domain space + size_t n = 3; - // dimension of the range space - size_t m = 1; + // dimension of the range space + size_t m = 1; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; - X[1] = 1.; - X[2] = 2.; - Independent(X); - // y = z[j] where j might be zero or one. - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[1] * X[2]; - // create function object F : X -> Y - ADFun F(X, Y); - - // sparsity pattern for hessian of F^2 - CPPAD_TESTVECTOR(bool) F2(n * n); - F2[0 * n + 0] = false; // partial w.r.t x[0], x[0] - F2[0 * n + 1] = false; // partial w.r.t x[0], x[1] - F2[0 * n + 2] = false; // partial w.r.t x[0], x[2] - - F2[1 * n + 0] = false; // partial w.r.t x[1], x[0] - F2[1 * n + 1] = false; // partial w.r.t x[1], x[1] - F2[1 * n + 2] = true; // partial w.r.t x[1], x[2] - - F2[2 * n + 0] = false; // partial w.r.t x[2], x[0] - F2[2 * n + 1] = true; // partial w.r.t x[2], x[1] - F2[2 * n + 2] = false; // partial w.r.t x[2], x[2] - - // choose a non-symmetric sparsity pattern for R - CPPAD_TESTVECTOR( bool ) r(n * n); - size_t i, j, k; - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - r[ i * n + j ] = false; - j = n - i - 1; - r[ j * n + j ] = true; - } - - // sparsity pattern for H^T - CPPAD_TESTVECTOR(bool) Check(n * n); - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - { Check[ i * n + j] = false; - for(k = 0; k < n; k++) - { // some gcc versions std::vector do not support |= - // on elements (because they pack the bits). - bool tmp = Check[i * n + j]; - Check[i * n + j] = tmp | (F2[i * n + k] & r[ k * n + j]); - } - } - } - - // compute the reverse Hessian sparsity pattern for F^2 * R - F.ForSparseJac(n, r); - CPPAD_TESTVECTOR( bool ) s(m), h(n * n); - s[0] = 1.; - bool transpose = true; - h = F.RevSparseHes(n, s, transpose); - - // check values - 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; - h = F.RevSparseHes(n, s, transpose); - - // check values - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - ok &= (h[j * n + i] == Check[i * n + j]); - } + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 0.; + X[1] = 1.; + X[2] = 2.; + Independent(X); + // y = z[j] where j might be zero or one. + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[1] * X[2]; + // create function object F : X -> Y + ADFun F(X, Y); + + // sparsity pattern for hessian of F^2 + CPPAD_TESTVECTOR(bool) F2(n * n); + F2[0 * n + 0] = false; // partial w.r.t x[0], x[0] + F2[0 * n + 1] = false; // partial w.r.t x[0], x[1] + F2[0 * n + 2] = false; // partial w.r.t x[0], x[2] + + F2[1 * n + 0] = false; // partial w.r.t x[1], x[0] + F2[1 * n + 1] = false; // partial w.r.t x[1], x[1] + F2[1 * n + 2] = true; // partial w.r.t x[1], x[2] + + F2[2 * n + 0] = false; // partial w.r.t x[2], x[0] + F2[2 * n + 1] = true; // partial w.r.t x[2], x[1] + F2[2 * n + 2] = false; // partial w.r.t x[2], x[2] + + // choose a non-symmetric sparsity pattern for R + CPPAD_TESTVECTOR( bool ) r(n * n); + size_t i, j, k; + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + r[ i * n + j ] = false; + j = n - i - 1; + r[ j * n + j ] = true; + } + + // sparsity pattern for H^T + CPPAD_TESTVECTOR(bool) Check(n * n); + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + { Check[ i * n + j] = false; + for(k = 0; k < n; k++) + { // some gcc versions std::vector do not support |= + // on elements (because they pack the bits). + bool tmp = Check[i * n + j]; + Check[i * n + j] = tmp | (F2[i * n + k] & r[ k * n + j]); + } + } + } + + // compute the reverse Hessian sparsity pattern for F^2 * R + F.ForSparseJac(n, r); + CPPAD_TESTVECTOR( bool ) s(m), h(n * n); + s[0] = 1.; + bool transpose = true; + h = F.RevSparseHes(n, s, transpose); + + // check values + 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; + h = F.RevSparseHes(n, s, transpose); + + // check values + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + ok &= (h[j * n + i] == Check[i * n + j]); + } - return ok; + return ok; } } // End of empty namespace bool hes_sparsity(void) -{ bool ok = true; +{ bool ok = true; - ok &= case_one(); - ok &= case_two(); - ok &= case_three(); - ok &= case_four(); - ok &= case_five(); - ok &= case_six(); + ok &= case_one(); + ok &= case_two(); + ok &= case_three(); + ok &= case_four(); + ok &= case_five(); + ok &= case_six(); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/ipopt_solve.cpp cppad-2019.02.00.0/test_more/general/ipopt_solve.cpp --- cppad-2018.00.00.0/test_more/general/ipopt_solve.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/ipopt_solve.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Testing ipopt::solve */ @@ -20,116 +21,116 @@ # include namespace { - using CppAD::AD; + using CppAD::AD; - class FG_eval { - public: - typedef CPPAD_TESTVECTOR( AD ) ADvector; - void operator()(ADvector& fg, const ADvector& x) - { assert( fg.size() == 3 ); - assert( x.size() == 4 ); - - // Fortran style indexing - AD x1 = x[0]; - AD x2 = x[1]; - AD x3 = x[2]; - AD x4 = x[3]; - // f(x) - fg[0] = x1 * x4 * (x1 + x2 + x3) + x3; - // g_1 (x) - fg[1] = x1 * x2 * x3 * x4; - // g_2 (x) - fg[2] = x1 * x1 + x2 * x2 + x3 * x3 + x4 * x4; - // - return; - } - }; + class FG_eval { + public: + typedef CPPAD_TESTVECTOR( AD ) ADvector; + void operator()(ADvector& fg, const ADvector& x) + { assert( fg.size() == 3 ); + assert( x.size() == 4 ); + + // Fortran style indexing + AD x1 = x[0]; + AD x2 = x[1]; + AD x3 = x[2]; + AD x4 = x[3]; + // f(x) + fg[0] = x1 * x4 * (x1 + x2 + x3) + x3; + // g_1 (x) + fg[1] = x1 * x2 * x3 * x4; + // g_2 (x) + fg[2] = x1 * x1 + x2 * x2 + x3 * x3 + x4 * x4; + // + return; + } + }; } 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; - // number of constraints (range dimension for g) - size_t ng = 2; - // initial value of the independent variables - Dvector xi(nx); - xi[0] = 1.0; - xi[1] = 5.0; - xi[2] = 5.0; - xi[3] = 1.0; - // lower and upper limits for x - Dvector xl(nx), xu(nx); - for(j = 0; j < nx; j++) - { xl[j] = 1.0; - xu[j] = 5.0; - } - // 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; - - // object that computes objective and constraints - FG_eval fg_eval; - - // options - std::string base_options; - // turn off any printing - 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, - // 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., - // when evaluation finite diff - base_options += "Numeric point_perturbation_radius 0.\n"; - - // place to return solution - CppAD::ipopt::solve_result solution; - - // solution values and tolerances - double check_x[] = { 1.000000, 4.743000, 3.82115, 1.379408 }; - double check_zl[] = { 1.087871, 0., 0., 0. }; - double check_zu[] = { 0., 0., 0., 0. }; - double rel_tol = 1e-6; // relative tolerance - double abs_tol = 1e-6; // absolute tolerance - - for(i = 0; i < 3; i++) - { std::string options( base_options ); - if( i == 1 ) - options += "Sparse true forward\n"; - if( i == 2 ) - options += "Sparse true reverse\n"; - - // solve the problem - CppAD::ipopt::solve( - options, xi, xl, xu, gl, gu, fg_eval, solution - ); - ok &= solution.status==CppAD::ipopt::solve_result::success; - // - // 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 - ); - ok &= CppAD::NearEqual( - check_zl[j], solution.zl[j], rel_tol, abs_tol - ); - ok &= CppAD::NearEqual( - check_zu[j], solution.zu[j], rel_tol, abs_tol - ); - } - } +{ 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; + // number of constraints (range dimension for g) + size_t ng = 2; + // initial value of the independent variables + Dvector xi(nx); + xi[0] = 1.0; + xi[1] = 5.0; + xi[2] = 5.0; + xi[3] = 1.0; + // lower and upper limits for x + Dvector xl(nx), xu(nx); + for(j = 0; j < nx; j++) + { xl[j] = 1.0; + xu[j] = 5.0; + } + // 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; + + // object that computes objective and constraints + FG_eval fg_eval; + + // options + std::string base_options; + // turn off any printing + 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, + // 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., + // when evaluation finite diff + base_options += "Numeric point_perturbation_radius 0.\n"; + + // place to return solution + CppAD::ipopt::solve_result solution; + + // solution values and tolerances + double check_x[] = { 1.000000, 4.743000, 3.82115, 1.379408 }; + double check_zl[] = { 1.087871, 0., 0., 0. }; + double check_zu[] = { 0., 0., 0., 0. }; + double rel_tol = 1e-6; // relative tolerance + double abs_tol = 1e-6; // absolute tolerance + + for(i = 0; i < 3; i++) + { std::string options( base_options ); + if( i == 1 ) + options += "Sparse true forward\n"; + if( i == 2 ) + options += "Sparse true reverse\n"; + + // solve the problem + CppAD::ipopt::solve( + options, xi, xl, xu, gl, gu, fg_eval, solution + ); + ok &= solution.status==CppAD::ipopt::solve_result::success; + // + // 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 + ); + ok &= CppAD::NearEqual( + check_zl[j], solution.zl[j], rel_tol, abs_tol + ); + ok &= CppAD::NearEqual( + check_zu[j], solution.zu[j], rel_tol, abs_tol + ); + } + } - return ok; + return ok; } # endif diff -Nru cppad-2018.00.00.0/test_more/general/jacobian.cpp cppad-2019.02.00.0/test_more/general/jacobian.cpp --- cppad-2018.00.00.0/test_more/general/jacobian.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/jacobian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include @@ -15,90 +16,90 @@ template Vector eval_g(const Vector& x) -{ Vector g(2); +{ Vector g(2); - g[0] = x[0] * x[1] * x[2] * x[3]; - g[1] = x[0] * x[0] + x[1] * x[1] + x[2] * x[2] + x[3] * x[3]; + g[0] = x[0] * x[1] * x[2] * x[3]; + g[1] = x[0] * x[0] + x[1] * x[1] + x[2] * x[2] + x[3] * x[3]; - return g; + return g; } template Vector eval_jac_g(const Vector& x) -{ Vector jac_g(8); +{ Vector jac_g(8); - // g[0] = x[0] * x[1] * x[2] * x[3]; - jac_g[0] = x[1] * x[2] * x[3]; - jac_g[1] = x[0] * x[2] * x[3]; - jac_g[2] = x[0] * x[1] * x[3]; - jac_g[3] = x[0] * x[1] * x[2]; - - // g[1] = x[0] * x[0] + x[1] * x[1] + x[2] * x[2] + x[3] * x[3]; - jac_g[4+0] = 2. * x[0]; - jac_g[4+1] = 2. * x[1]; - jac_g[4+2] = 2. * x[2]; - jac_g[4+3] = 2. * x[3]; + // g[0] = x[0] * x[1] * x[2] * x[3]; + jac_g[0] = x[1] * x[2] * x[3]; + jac_g[1] = x[0] * x[2] * x[3]; + jac_g[2] = x[0] * x[1] * x[3]; + jac_g[3] = x[0] * x[1] * x[2]; + + // g[1] = x[0] * x[0] + x[1] * x[1] + x[2] * x[2] + x[3] * x[3]; + jac_g[4+0] = 2. * x[0]; + jac_g[4+1] = 2. * x[1]; + jac_g[4+2] = 2. * x[2]; + jac_g[4+3] = 2. * x[3]; - return jac_g; + return jac_g; } } // End empty namespace bool jacobian(void) -{ bool ok = true; - using CppAD::vector; - size_t i, j, k; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - size_t n = 4; - size_t m = 2; - vector< CppAD::AD > ad_x(n); - vector< CppAD::AD > ad_g(m); - - vector x(n); - x[0] = 1.; x[1] = 5.0; x[2] = 5.0; x[3] = 1.0; - for(j = 0; j < n; j++) - ad_x[j] = x[j]; - // - CppAD::Independent(ad_x); - ad_g = eval_g(ad_x); - CppAD::ADFun fun_g(ad_x, ad_g); - - vector check(m * n); - check = eval_jac_g(x); - - // regular jacobian - vector jac_g = fun_g.Jacobian(x); - for(k = 0; k < m *n; k++) - ok &= NearEqual(jac_g[k], check[k], eps99, eps99); - - // one argument sparse jacobian - jac_g = fun_g.SparseJacobian(x); - for(k = 0; k < m *n; k++) - ok &= NearEqual(jac_g[k], check[k], eps99, eps99); - - // sparse jacobian using bool vectors - CPPAD_TESTVECTOR(bool) p_b(m * n) , r_b(n * n); - for(i = 0; i < n; i++) - for(j = 0; j < n; j++) - r_b[i * n + j] = (i == j); - p_b = fun_g.ForSparseJac(n, r_b); - jac_g = fun_g.SparseJacobian(x, p_b); - for(k = 0; k < m *n; k++) - ok &= NearEqual(jac_g[k], check[k], eps99, eps99); - - // sparse jacobian using vectors of sets - std::vector< std::set > p_s(m) , r_s(n); - for(i = 0; i < n; i++) - for(j = 0; j < n; j++) - r_s[i].insert(j); - p_s = fun_g.ForSparseJac(n, r_s); - jac_g = fun_g.SparseJacobian(x, p_s); - for(k = 0; k < m *n; k++) - ok &= NearEqual(jac_g[k], check[k], eps99, eps99); +{ bool ok = true; + using CppAD::vector; + size_t i, j, k; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + size_t n = 4; + size_t m = 2; + vector< CppAD::AD > ad_x(n); + vector< CppAD::AD > ad_g(m); + + vector x(n); + x[0] = 1.; x[1] = 5.0; x[2] = 5.0; x[3] = 1.0; + for(j = 0; j < n; j++) + ad_x[j] = x[j]; + // + CppAD::Independent(ad_x); + ad_g = eval_g(ad_x); + CppAD::ADFun fun_g(ad_x, ad_g); + + vector check(m * n); + check = eval_jac_g(x); + + // regular jacobian + vector jac_g = fun_g.Jacobian(x); + for(k = 0; k < m *n; k++) + ok &= NearEqual(jac_g[k], check[k], eps99, eps99); + + // one argument sparse jacobian + jac_g = fun_g.SparseJacobian(x); + for(k = 0; k < m *n; k++) + ok &= NearEqual(jac_g[k], check[k], eps99, eps99); + + // sparse jacobian using bool vectors + CPPAD_TESTVECTOR(bool) p_b(m * n) , r_b(n * n); + for(i = 0; i < n; i++) + for(j = 0; j < n; j++) + r_b[i * n + j] = (i == j); + p_b = fun_g.ForSparseJac(n, r_b); + jac_g = fun_g.SparseJacobian(x, p_b); + for(k = 0; k < m *n; k++) + ok &= NearEqual(jac_g[k], check[k], eps99, eps99); + + // sparse jacobian using vectors of sets + std::vector< std::set > p_s(m) , r_s(n); + for(i = 0; i < n; i++) + for(j = 0; j < n; j++) + r_s[i].insert(j); + p_s = fun_g.ForSparseJac(n, r_s); + jac_g = fun_g.SparseJacobian(x, p_s); + for(k = 0; k < m *n; k++) + ok &= NearEqual(jac_g[k], check[k], eps99, eps99); - return ok; + return ok; } // END PROGRAM diff -Nru cppad-2018.00.00.0/test_more/general/local/vector_set.cpp cppad-2019.02.00.0/test_more/general/local/vector_set.cpp --- cppad-2018.00.00.0/test_more/general/local/vector_set.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/local/vector_set.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,258 +1,259 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include namespace { // BEGIN empty namespace -template +template bool test_no_other(void) -{ bool ok = true; +{ bool ok = true; - VectorSet vec_set; - size_t n_set = 4; - size_t end = 5; - // - // set size of vec_set - vec_set.resize(n_set, end); - ok &= end == vec_set.end(); - ok &= n_set == vec_set.n_set(); - // - // test resizing to zero - vec_set.resize(0, 0); - ok &= 0 == vec_set.n_set(); - ok &= 0 == vec_set.end(); - // - // set size of vec_set - vec_set.resize(n_set, end); - ok &= end == vec_set.end(); - ok &= n_set == vec_set.n_set(); - - // - // add the element i+1 to set i - for(size_t i = 1; i < n_set; i++) - vec_set.add_element(i, i+1); - // - // check for element i and i+1 in set i - for(size_t i = 0; i < n_set; i++) - { ok &= ! vec_set.is_element(i, i); - if( i == 0 ) - ok &= ! vec_set.is_element(i, i+1); - else - ok &= vec_set.is_element(i, i+1); - } - // - // set an empty set to value of set 2 - size_t target = 0; - size_t source = 2; - vec_set.assignment(target, source, vec_set); - ok &= ! vec_set.is_element(target, source); - ok &= vec_set.is_element(target, source+1); - // - // set a non-empty set to the value of set 2 - target = 1; - vec_set.assignment(target, source, vec_set); - ok &= ! vec_set.is_element(target, source); - ok &= vec_set.is_element(target, source+1); - // - // add an element to set 1, one of the three vectors equal to set 2 - target = 1; - vec_set.add_element(target, source); - ok &= vec_set.is_element(target, source); - ok &= vec_set.is_element(target, source+1); - ok &= ! vec_set.is_element(source, source); - ok &= vec_set.is_element(source, source+1); - // - // now take the union of set 2 and set 3 and place in set 0 - // (wich is sharing a list with set 2) - target = 0; - vec_set.binary_union(target, source, source+1, vec_set); - ok &= vec_set.is_element(target, source+1); - ok &= vec_set.is_element(target, source+2); - ok &= vec_set.is_element(source, source+1); - ok &= ! vec_set.is_element(source, source+2); - // - // now check the elements in set 0 by iterating over them - typename VectorSet::const_iterator itr(vec_set, target); - ok &= *itr == source+1; - ok &= *(++itr) == source+2; - ok &= *(++itr) == end; - // - // now test clear - vec_set.clear(1); - ok &= ! vec_set.is_element(1, source+1); - ok &= vec_set.is_element(0, source+1); - // - // now force sparse_list garbage collection by setting all sets - // equal to set 0 - for(size_t i = 1; i < n_set; i++) - { vec_set.assignment(i, 0, vec_set); - ok &= vec_set.is_element(i, source+1); - ok &= vec_set.is_element(i, source+2); - } - // - return ok; + SetVector vec_set; + size_t n_set = 4; + size_t end = 5; + // + // set size of vec_set + vec_set.resize(n_set, end); + ok &= end == vec_set.end(); + ok &= n_set == vec_set.n_set(); + // + // test resizing to zero + vec_set.resize(0, 0); + ok &= 0 == vec_set.n_set(); + ok &= 0 == vec_set.end(); + // + // set size of vec_set + vec_set.resize(n_set, end); + ok &= end == vec_set.end(); + ok &= n_set == vec_set.n_set(); + + // + // add the element i+1 to set i + for(size_t i = 1; i < n_set; i++) + vec_set.add_element(i, i+1); + // + // check for element i and i+1 in set i + for(size_t i = 0; i < n_set; i++) + { ok &= ! vec_set.is_element(i, i); + if( i == 0 ) + ok &= ! vec_set.is_element(i, i+1); + else + ok &= vec_set.is_element(i, i+1); + } + // + // set an empty set to value of set 2 + size_t target = 0; + size_t source = 2; + vec_set.assignment(target, source, vec_set); + ok &= ! vec_set.is_element(target, source); + ok &= vec_set.is_element(target, source+1); + // + // set a non-empty set to the value of set 2 + target = 1; + vec_set.assignment(target, source, vec_set); + ok &= ! vec_set.is_element(target, source); + ok &= vec_set.is_element(target, source+1); + // + // add an element to set 1, one of the three vectors equal to set 2 + target = 1; + vec_set.add_element(target, source); + ok &= vec_set.is_element(target, source); + ok &= vec_set.is_element(target, source+1); + ok &= ! vec_set.is_element(source, source); + ok &= vec_set.is_element(source, source+1); + // + // now take the union of set 2 and set 3 and place in set 0 + // (wich is sharing a list with set 2) + target = 0; + vec_set.binary_union(target, source, source+1, vec_set); + ok &= vec_set.is_element(target, source+1); + ok &= vec_set.is_element(target, source+2); + ok &= vec_set.is_element(source, source+1); + ok &= ! vec_set.is_element(source, source+2); + // + // now check the elements in set 0 by iterating over them + typename SetVector::const_iterator itr(vec_set, target); + ok &= *itr == source+1; + ok &= *(++itr) == source+2; + ok &= *(++itr) == end; + // + // now test clear + vec_set.clear(1); + ok &= ! vec_set.is_element(1, source+1); + ok &= vec_set.is_element(0, source+1); + // + // now force sparse_list garbage collection by setting all sets + // equal to set 0 + for(size_t i = 1; i < n_set; i++) + { vec_set.assignment(i, 0, vec_set); + ok &= vec_set.is_element(i, source+1); + ok &= vec_set.is_element(i, source+2); + } + // + return ok; } -template +template bool test_yes_other(void) -{ bool ok = true; +{ bool ok = true; - VectorSet vec_set, other_vec; - size_t n_set = 4; - size_t end = 5; - vec_set.resize(n_set, end); - other_vec.resize(n_set, end); - // - // add element i to set i in vec_set - // add element i+1 to set i in other - for(size_t i = 1; i < n_set; i++) - { vec_set.add_element(i, i); - other_vec.add_element(i, i+1); - } - // - // assignment of one set from other - size_t target = 0; - size_t source = 1; - vec_set.assignment(target, source, other_vec); - ok &= ! vec_set.is_element(target, source); - ok &= vec_set.is_element(target, source+1); - // - // now take the union of a set from vec_set and from other_vec - target = 2; // where result goes in vec_set - size_t left = 2; // left operand in vec_set - size_t right = 2; // right operand in other - vec_set.binary_union(target, left, right, other_vec); - ok &= vec_set.is_element(target, left); - ok &= vec_set.is_element(target, right+1); - // - // now use assignment for entire vector of sets - vec_set = other_vec; - ok &= ! vec_set.is_element(0, 0); - ok &= ! vec_set.is_element(0, 1); - for(size_t i = 1; i < n_set; i++) - { ok &= ! vec_set.is_element(i, i); - ok &= vec_set.is_element(i, i+1); - } - return ok; + SetVector vec_set, other_vec; + size_t n_set = 4; + size_t end = 5; + vec_set.resize(n_set, end); + other_vec.resize(n_set, end); + // + // add element i to set i in vec_set + // add element i+1 to set i in other + for(size_t i = 1; i < n_set; i++) + { vec_set.add_element(i, i); + other_vec.add_element(i, i+1); + } + // + // assignment of one set from other + size_t target = 0; + size_t source = 1; + vec_set.assignment(target, source, other_vec); + ok &= ! vec_set.is_element(target, source); + ok &= vec_set.is_element(target, source+1); + // + // now take the union of a set from vec_set and from other_vec + target = 2; // where result goes in vec_set + size_t left = 2; // left operand in vec_set + size_t right = 2; // right operand in other + vec_set.binary_union(target, left, right, other_vec); + ok &= vec_set.is_element(target, left); + ok &= vec_set.is_element(target, right+1); + // + // now use assignment for entire vector of sets + vec_set = other_vec; + ok &= ! vec_set.is_element(0, 0); + ok &= ! vec_set.is_element(0, 1); + for(size_t i = 1; i < n_set; i++) + { ok &= ! vec_set.is_element(i, i); + ok &= vec_set.is_element(i, i+1); + } + return ok; } -template +template bool test_intersection(void) -{ bool ok = true; - // - VectorSet vec_set; - size_t n_set = 3; - size_t end = 5; - vec_set.resize(n_set, end); - // - // set[0] = {1, 2} - vec_set.add_element(0, 1); - vec_set.add_element(0, 2); - // - // set[1] = {2, 3} - vec_set.add_element(1, 2); - vec_set.add_element(1, 3); - // - // set[2] = set[0] intersect set[1] - size_t target = 2; - size_t left = 0; - size_t right = 1; - vec_set.binary_intersection(target, left, right, vec_set); - // - typename VectorSet::const_iterator itr1(vec_set, target); - ok &= *itr1 == 2; - ok &= *(++itr1) == end; - // - // other[1] = set[1] - VectorSet other; - other.resize(n_set, end); - target = 1; - size_t source = 1; - other.assignment(target, source, vec_set); - // - // set[2] = set[0] intersect other[1] - target = 2; - left = 0; - right = 1; - vec_set.binary_intersection(target, left, right, other); - // - typename VectorSet::const_iterator itr2(vec_set, target); - ok &= *itr2 == 2; - ok &= *(++itr2) == end; - // - return ok; +{ bool ok = true; + // + SetVector vec_set; + size_t n_set = 3; + size_t end = 5; + vec_set.resize(n_set, end); + // + // set[0] = {1, 2} + vec_set.add_element(0, 1); + vec_set.add_element(0, 2); + // + // set[1] = {2, 3} + vec_set.add_element(1, 2); + vec_set.add_element(1, 3); + // + // set[2] = set[0] intersect set[1] + size_t target = 2; + size_t left = 0; + size_t right = 1; + vec_set.binary_intersection(target, left, right, vec_set); + // + typename SetVector::const_iterator itr1(vec_set, target); + ok &= *itr1 == 2; + ok &= *(++itr1) == end; + // + // other[1] = set[1] + SetVector other; + other.resize(n_set, end); + target = 1; + size_t source = 1; + other.assignment(target, source, vec_set); + // + // set[2] = set[0] intersect other[1] + target = 2; + left = 0; + right = 1; + vec_set.binary_intersection(target, left, right, other); + // + typename SetVector::const_iterator itr2(vec_set, target); + ok &= *itr2 == 2; + ok &= *(++itr2) == end; + // + return ok; } -template +template bool test_post(void) -{ bool ok = true; - // - VectorSet vec_set; - size_t n_set = 3; - size_t end = 5; - vec_set.resize(n_set, end); - // - // set[1] = {1, 2} - vec_set.add_element(1, 1); - vec_set.add_element(1, 2); - // - // set[1] = {1, 2} union (2, 4, 4) = {1, 2, 4} - size_t target = 1; - vec_set.post_element(target, 2); - vec_set.post_element(target, 4); - vec_set.post_element(target, 4); - vec_set.process_post(target); - // - typename VectorSet::const_iterator itr1(vec_set, target); - ok &= *itr1 == 1; - ok &= *(++itr1) == 2; - ok &= *(++itr1) == 4; - ok &= *(++itr1) == end; - // - // set[1] = {1, 2, 4} union (1, 2) - target = 1; - vec_set.post_element(target, 1); - vec_set.post_element(target, 2); - vec_set.process_post(target); - // - typename VectorSet::const_iterator itr2(vec_set, target); - ok &= *itr2 == 1; - ok &= *(++itr2) == 2; - ok &= *(++itr2) == 4; - ok &= *(++itr2) == end; - // - return ok; +{ bool ok = true; + // + SetVector vec_set; + size_t n_set = 3; + size_t end = 5; + vec_set.resize(n_set, end); + // + // set[1] = {1, 2} + vec_set.add_element(1, 1); + vec_set.add_element(1, 2); + // + // set[1] = {1, 2} union (2, 4, 4) = {1, 2, 4} + size_t target = 1; + vec_set.post_element(target, 2); + vec_set.post_element(target, 4); + vec_set.post_element(target, 4); + vec_set.process_post(target); + // + typename SetVector::const_iterator itr1(vec_set, target); + ok &= *itr1 == 1; + ok &= *(++itr1) == 2; + ok &= *(++itr1) == 4; + ok &= *(++itr1) == end; + // + // set[1] = {1, 2, 4} union (1, 2) + target = 1; + vec_set.post_element(target, 1); + vec_set.post_element(target, 2); + vec_set.process_post(target); + // + typename SetVector::const_iterator itr2(vec_set, target); + ok &= *itr2 == 1; + ok &= *(++itr2) == 2; + ok &= *(++itr2) == 4; + ok &= *(++itr2) == end; + // + return ok; } } // END empty namespace bool vector_set(void) -{ bool ok = true; +{ bool ok = true; - ok &= test_no_other(); - ok &= test_no_other(); - ok &= test_no_other(); - // - ok &= test_yes_other(); - ok &= test_yes_other(); - ok &= test_yes_other(); - // - ok &= test_intersection(); - ok &= test_intersection(); - ok &= test_intersection(); - // - ok &= test_post(); - ok &= test_post(); - ok &= test_post(); - // - return ok; + ok &= test_no_other(); + ok &= test_no_other(); + ok &= test_no_other(); + // + ok &= test_yes_other(); + ok &= test_yes_other(); + ok &= test_yes_other(); + // + ok &= test_intersection(); + ok &= test_intersection(); + ok &= test_intersection(); + // + ok &= test_post(); + ok &= test_post(); + ok &= test_post(); + // + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/log10.cpp cppad-2019.02.00.0/test_more/general/log10.cpp --- cppad-2018.00.00.0/test_more/general/log10.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/log10.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old example now used just for validation testing. @@ -15,46 +16,46 @@ # include bool log10(void) -{ bool ok = true; - using CppAD::log10; - using CppAD::log; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(1); - size_t s = 0; - U[s] = 10.; - Independent(U); - - // dependent variable vector, indices, and values - CPPAD_TESTVECTOR(AD) Z(2); - size_t x = 0; - size_t y = 1; - Z[x] = log10(U[s]); - Z[y] = log10(Z[x]); - - // define f : U -> Z and vectors for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // check values - ok &= NearEqual(Z[x] , 1., eps99 , eps99); - ok &= NearEqual(Z[y] , 0., eps99 , eps99); - - // forward computation of partials w.r.t. s - double l10 = log(10.); - v[s] = 1.; - w = f.Forward(1, v); - ok &= NearEqual(w[x], 1./(U[s]*l10) , eps99 , eps99); // dx/ds - ok &= NearEqual(w[y], 1./(U[s]*Z[x]*l10*l10), eps99 , eps99); // dy/ds - - // reverse computation of partials of y - w[x] = 0.; - w[y] = 1.; - v = f.Reverse(1,w); - ok &= NearEqual(v[s], 1./(U[s]*Z[x]*l10*l10), eps99 , eps99); // dy/ds +{ bool ok = true; + using CppAD::log10; + using CppAD::log; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(1); + size_t s = 0; + U[s] = 10.; + Independent(U); + + // dependent variable vector, indices, and values + CPPAD_TESTVECTOR(AD) Z(2); + size_t x = 0; + size_t y = 1; + Z[x] = log10(U[s]); + Z[y] = log10(Z[x]); + + // define f : U -> Z and vectors for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // check values + ok &= NearEqual(Z[x] , 1., eps99 , eps99); + ok &= NearEqual(Z[y] , 0., eps99 , eps99); + + // forward computation of partials w.r.t. s + double l10 = log(10.); + v[s] = 1.; + w = f.Forward(1, v); + ok &= NearEqual(w[x], 1./(U[s]*l10) , eps99 , eps99); // dx/ds + ok &= NearEqual(w[y], 1./(U[s]*Z[x]*l10*l10), eps99 , eps99); // dy/ds + + // reverse computation of partials of y + w[x] = 0.; + w[y] = 1.; + v = f.Reverse(1,w); + ok &= NearEqual(v[s], 1./(U[s]*Z[x]*l10*l10), eps99 , eps99); // dy/ds - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/log1p.cpp cppad-2019.02.00.0/test_more/general/log1p.cpp --- cppad-2018.00.00.0/test_more/general/log1p.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/log1p.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,72 +1,73 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include bool log1p(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; + using CppAD::AD; + using CppAD::NearEqual; - // 10 times machine epsilon - double eps = 10. * std::numeric_limits::epsilon(); + // 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); + // 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/log.cpp cppad-2019.02.00.0/test_more/general/log.cpp --- cppad-2018.00.00.0/test_more/general/log.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/log.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* @@ -19,131 +20,131 @@ namespace { // BEGIN empty namespace bool LogTestOne(void) -{ bool ok = true; - using CppAD::log; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(1); - size_t s = 0; - U[s] = 2.; - Independent(U); - - // dependent variable vector, indices, and values - CPPAD_TESTVECTOR(AD) Z(2); - size_t x = 0; - size_t y = 1; - Z[x] = log(U[s]); - Z[y] = log(Z[x]); - - // define f : U -> Z and vectors for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // check values - ok &= NearEqual(Z[x] , log(2.), eps99 , eps99); - ok &= NearEqual(Z[y] , log( log(2.) ), eps99 , eps99); - - // forward computation of partials w.r.t. s - v[s] = 1.; - w = f.Forward(1, v); - ok &= NearEqual(w[x], 1. / U[s], eps99 , eps99); // dx/ds - ok &= NearEqual(w[y], 1. / (U[s] * Z[x]), eps99 , eps99); // dy/ds - - // reverse computation of partials of y - w[x] = 0.; - w[y] = 1.; - v = f.Reverse(1,w); - ok &= NearEqual(v[s], 1. / (U[s] * Z[x]), eps99 , eps99); // dy/ds - - // 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( - 2. * w[y] , - - 1. / (Z[x]*Z[x]*U[s]*U[s]) - 1. / (Z[x]*U[s]*U[s]), - eps99 , - eps99 - ); - - // reverse computation of second partials of y - CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); - w[x] = 0.; - w[y] = 1.; - r = f.Reverse(2, w); - ok &= NearEqual( - r[2 * s + 1] , - - 1. / (Z[x]*Z[x]*U[s]*U[s]) - 1. / (Z[x]*U[s]*U[s]), - eps99 , - eps99 - ); +{ bool ok = true; + using CppAD::log; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(1); + size_t s = 0; + U[s] = 2.; + Independent(U); + + // dependent variable vector, indices, and values + CPPAD_TESTVECTOR(AD) Z(2); + size_t x = 0; + size_t y = 1; + Z[x] = log(U[s]); + Z[y] = log(Z[x]); + + // define f : U -> Z and vectors for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // check values + ok &= NearEqual(Z[x] , log(2.), eps99 , eps99); + ok &= NearEqual(Z[y] , log( log(2.) ), eps99 , eps99); + + // forward computation of partials w.r.t. s + v[s] = 1.; + w = f.Forward(1, v); + ok &= NearEqual(w[x], 1. / U[s], eps99 , eps99); // dx/ds + ok &= NearEqual(w[y], 1. / (U[s] * Z[x]), eps99 , eps99); // dy/ds + + // reverse computation of partials of y + w[x] = 0.; + w[y] = 1.; + v = f.Reverse(1,w); + ok &= NearEqual(v[s], 1. / (U[s] * Z[x]), eps99 , eps99); // dy/ds + + // 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( + 2. * w[y] , + - 1. / (Z[x]*Z[x]*U[s]*U[s]) - 1. / (Z[x]*U[s]*U[s]), + eps99 , + eps99 + ); + + // reverse computation of second partials of y + CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); + w[x] = 0.; + w[y] = 1.; + r = f.Reverse(2, w); + ok &= NearEqual( + r[2 * s + 1] , + - 1. / (Z[x]*Z[x]*U[s]*U[s]) - 1. / (Z[x]*U[s]*U[s]), + eps99 , + eps99 + ); - return ok; + return ok; } bool LogTestTwo(void) -{ bool ok = true; - using CppAD::log; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(1); - U[0] = 1.; - Independent(U); - - // a temporary values - AD x = exp(U[0]); - - // 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); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(U[0] , Z[0], eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - double value = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - value = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - value = 1.; - for(j = 0; j < p; j++) - { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - value = 0.; - } +{ bool ok = true; + using CppAD::log; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(1); + U[0] = 1.; + Independent(U); + + // a temporary values + AD x = exp(U[0]); + + // 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); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(U[0] , Z[0], eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + double value = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + value = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + value = 1.; + for(j = 0; j < p; j++) + { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + jfac *= double(j + 1); + value = 0.; + } - return ok; + return ok; } } // END empty namespace bool log(void) -{ bool ok = true; - ok &= LogTestOne(); - ok &= LogTestTwo(); - return ok; +{ bool ok = true; + ok &= LogTestOne(); + ok &= LogTestTwo(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/makefile.am cppad-2019.02.00.0/test_more/general/makefile.am --- cppad-2018.00.00.0/test_more/general/makefile.am 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/makefile.am 2019-01-31 12:35:17.000000000 +0000 @@ -1,12 +1,13 @@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -22,11 +23,9 @@ # ------------------------------------------------------------------------- if CppAD_ADOLC ADOLC_SRC_FILES = base_adolc.cpp -ADOLC_EXTRA_FILES = ADOLC_LIB = -ladolc -lColPack -L$(ADOLC_DIR)/lib -L$(ADOLC_DIR)/lib64 ADOLC_FLAGS = -I$(ADOLC_DIR)/include else -ADOLC_EXTRA_FILES = base_adolc.cpp ADOLC_SRC_FILES = ADOLC_LIB = ADOLC_FLAGS = @@ -34,81 +33,70 @@ # ------------------------------------------------------------------------- if CppAD_IPOPT IPOPT_SRC_FILES = ipopt_solve.cpp -IPOPT_EXTRA_FILES = IPOPT_LIB = -lipopt \ $(CPPAD_IPOPT_LIBS) $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB) IPOPT_FLAGS = -I$(IPOPT_DIR)/include else -IPOPT_EXTRA_FILES = ipopt_solve.cpp IPOPT_SRC_FILES = IPOPT_LIB = IPOPT_FLAGS = endif # ------------------------------------------------------------------------- -if CppAD_EIGEN_DIR -# make a special library so can have it's own compile flags (see configure.ac) -EIGEN_EXTRA_FILES = -noinst_LIBRARIES = libeigen.a -libeigen_a_SOURCES = cppad_eigen.cpp eigen_mat_inv.cpp -EIGEN_LIB = -L. -leigen -libeigen_a_CXXFLAGS = \ - -g \ - $(CXX_FLAGS_EIGEN) \ - -I$(EIGEN_DIR)/include +if CppAD_EIGEN +EIGEN_SRC_FILES = cppad_eigen.cpp eigen_mat_inv.cpp else -EIGEN_EXTRA_FILES = cppad_eigen.cpp eigen_mat_inv.cpp -EIGEN_LIB = +EIGEN_SRC_FILES = endif # ------------------------------------------------------------------------- # Microsoft project files and script to run a single test -EXTRA_DIST = \ - $(ADOLC_EXTRA_FILES) \ - $(IPOPT_EXTRA_FILES) \ - $(EIGEN_EXTRA_FILES) # check_PROGRAMS = general # -AM_CPPFLAGS = -I. \ - -I$(top_srcdir) \ +# +AM_CXXFLAGS = \ + $(ADOLC_FLAGS) \ + $(IPOPT_FLAGS) \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ $(ADOLC_FLAGS) \ $(IPOPT_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) +LDADD = $(ADOLC_LIB) $(IPOPT_LIB) $(OPENMP_FLAGS) # +# BEGIN_SORT_THIS_LINE_PLUS_6 general_SOURCES = \ $(ADOLC_SRC_FILES) \ + $(EIGEN_SRC_FILES) \ $(IPOPT_SRC_FILES) \ $(OPENMP_SRC_FILES) \ general.cpp \ - fabs.cpp \ acos.cpp \ acosh.cpp \ + add.cpp \ + add_eq.cpp \ + add_zero.cpp \ adfun_copy.cpp \ asin.cpp \ asinh.cpp \ assign.cpp \ - add.cpp \ - add_eq.cpp \ - add_zero.cpp \ + atan2.cpp \ atan.cpp \ atanh.cpp \ - atan2.cpp \ - atomic_sparsity.cpp \ + atomic_three.cpp \ azmul.cpp \ base_alloc.cpp \ bool_sparsity.cpp \ + chkpoint_one.cpp \ + chkpoint_two.cpp \ check_simple_vector.cpp \ - checkpoint.cpp \ - compare.cpp \ compare_change.cpp \ - cond_exp.cpp \ + compare.cpp \ cond_exp_ad.cpp \ + cond_exp.cpp \ cond_exp_rev.cpp \ copy.cpp \ cos.cpp \ @@ -123,6 +111,7 @@ expm1.cpp \ extern_value.cpp \ extern_value.hpp \ + fabs.cpp \ for_hess.cpp \ for_sparse_hes.cpp \ for_sparse_jac.cpp \ @@ -133,19 +122,20 @@ fun_check.cpp \ hes_sparsity.cpp \ jacobian.cpp \ - num_limits.cpp \ - log.cpp \ - log1p.cpp \ log10.cpp \ + log1p.cpp \ + log.cpp \ + mul_cond_rev.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 \ + new_dynamic.cpp \ + num_limits.cpp \ ode_err_control.cpp \ optimize.cpp \ parameter.cpp \ @@ -153,26 +143,27 @@ pow.cpp \ pow_int.cpp \ print_for.cpp \ - romberg_one.cpp \ - rosen_34.cpp \ - runge_45.cpp \ reverse.cpp \ rev_sparse_jac.cpp \ rev_two.cpp \ + romberg_one.cpp \ + rosen_34.cpp \ + runge_45.cpp \ simple_vector.cpp \ - sin.cpp \ sin_cos.cpp \ + sin.cpp \ sinh.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp \ + sparse_jac_work.cpp \ sparse_sub_hes.cpp \ sparse_vec_ad.cpp \ sqrt.cpp \ std_math.cpp \ sub.cpp \ sub_eq.cpp \ - sub_zero.cpp \ subgraph.cpp \ + sub_zero.cpp \ tan.cpp \ test_vector.cpp \ to_string.cpp \ @@ -180,6 +171,7 @@ vec_ad.cpp \ vec_ad_par.cpp \ vec_unary.cpp +# END_SORT_THIS_LINE_MINUS_1 test: check ./general diff -Nru cppad-2018.00.00.0/test_more/general/makefile.in cppad-2019.02.00.0/test_more/general/makefile.in --- cppad-2018.00.00.0/test_more/general/makefile.in 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/makefile.in 2019-01-31 12:35:17.000000000 +0000 @@ -1,7 +1,7 @@ -# makefile.in generated by automake 1.15 from makefile.am. +# makefile.in generated by automake 1.15.1 from makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -13,7 +13,6 @@ # PARTICULAR PURPOSE. @SET_MAKE@ - VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ @@ -98,82 +97,74 @@ mkinstalldirs = $(install_sh) -d CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -LIBRARIES = $(noinst_LIBRARIES) -ARFLAGS = cru -AM_V_AR = $(am__v_AR_@AM_V@) -am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) -am__v_AR_0 = @echo " AR " $@; -am__v_AR_1 = -libeigen_a_AR = $(AR) $(ARFLAGS) -libeigen_a_LIBADD = -am__libeigen_a_SOURCES_DIST = cppad_eigen.cpp eigen_mat_inv.cpp -@CppAD_EIGEN_DIR_TRUE@am_libeigen_a_OBJECTS = \ -@CppAD_EIGEN_DIR_TRUE@ libeigen_a-cppad_eigen.$(OBJEXT) \ -@CppAD_EIGEN_DIR_TRUE@ libeigen_a-eigen_mat_inv.$(OBJEXT) -libeigen_a_OBJECTS = $(am_libeigen_a_OBJECTS) -am__general_SOURCES_DIST = base_adolc.cpp ipopt_solve.cpp \ - alloc_openmp.cpp general.cpp fabs.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 \ - atomic_sparsity.cpp azmul.cpp base_alloc.cpp bool_sparsity.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 \ - dependency.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_hes.cpp for_sparse_jac.cpp forward.cpp \ - forward_dir.cpp forward_order.cpp from_base.cpp fun_check.cpp \ - hes_sparsity.cpp jacobian.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 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_jac.cpp rev_two.cpp simple_vector.cpp sin.cpp \ - sin_cos.cpp sinh.cpp sparse_hessian.cpp sparse_jacobian.cpp \ +am__general_SOURCES_DIST = base_adolc.cpp cppad_eigen.cpp \ + eigen_mat_inv.cpp ipopt_solve.cpp alloc_openmp.cpp general.cpp \ + acos.cpp acosh.cpp add.cpp add_eq.cpp add_zero.cpp \ + adfun_copy.cpp asin.cpp asinh.cpp assign.cpp atan2.cpp \ + atan.cpp atanh.cpp atomic_three.cpp azmul.cpp base_alloc.cpp \ + bool_sparsity.cpp chkpoint_one.cpp chkpoint_two.cpp \ + check_simple_vector.cpp compare_change.cpp compare.cpp \ + cond_exp_ad.cpp cond_exp.cpp cond_exp_rev.cpp copy.cpp cos.cpp \ + cosh.cpp dbl_epsilon.cpp dependency.cpp div.cpp div_eq.cpp \ + div_zero_one.cpp erf.cpp exp.cpp expm1.cpp extern_value.cpp \ + extern_value.hpp fabs.cpp for_hess.cpp for_sparse_hes.cpp \ + for_sparse_jac.cpp forward.cpp forward_dir.cpp \ + forward_order.cpp from_base.cpp fun_check.cpp hes_sparsity.cpp \ + jacobian.cpp log10.cpp log1p.cpp log.cpp mul_cond_rev.cpp \ + mul.cpp mul_cskip.cpp mul_eq.cpp mul_level.cpp mul_zdouble.cpp \ + mul_zero_one.cpp near_equal_ext.cpp neg.cpp new_dynamic.cpp \ + num_limits.cpp ode_err_control.cpp optimize.cpp parameter.cpp \ + poly.cpp pow.cpp pow_int.cpp print_for.cpp reverse.cpp \ + rev_sparse_jac.cpp rev_two.cpp romberg_one.cpp rosen_34.cpp \ + runge_45.cpp simple_vector.cpp sin_cos.cpp sin.cpp sinh.cpp \ + sparse_hessian.cpp sparse_jacobian.cpp sparse_jac_work.cpp \ sparse_sub_hes.cpp sparse_vec_ad.cpp sqrt.cpp std_math.cpp \ - sub.cpp sub_eq.cpp sub_zero.cpp subgraph.cpp tan.cpp \ + sub.cpp sub_eq.cpp subgraph.cpp sub_zero.cpp tan.cpp \ test_vector.cpp to_string.cpp value.cpp vec_ad.cpp \ vec_ad_par.cpp vec_unary.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) +@CppAD_EIGEN_TRUE@am__objects_2 = cppad_eigen.$(OBJEXT) \ +@CppAD_EIGEN_TRUE@ eigen_mat_inv.$(OBJEXT) +@CppAD_IPOPT_TRUE@am__objects_3 = ipopt_solve.$(OBJEXT) +@CppAD_OPENMP_TRUE@am__objects_4 = alloc_openmp.$(OBJEXT) am_general_OBJECTS = $(am__objects_1) $(am__objects_2) \ - $(am__objects_3) general.$(OBJEXT) fabs.$(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) atomic_sparsity.$(OBJEXT) \ + $(am__objects_3) $(am__objects_4) general.$(OBJEXT) \ + acos.$(OBJEXT) acosh.$(OBJEXT) add.$(OBJEXT) add_eq.$(OBJEXT) \ + add_zero.$(OBJEXT) adfun_copy.$(OBJEXT) asin.$(OBJEXT) \ + asinh.$(OBJEXT) assign.$(OBJEXT) atan2.$(OBJEXT) \ + atan.$(OBJEXT) atanh.$(OBJEXT) atomic_three.$(OBJEXT) \ azmul.$(OBJEXT) base_alloc.$(OBJEXT) bool_sparsity.$(OBJEXT) \ - check_simple_vector.$(OBJEXT) checkpoint.$(OBJEXT) \ - compare.$(OBJEXT) compare_change.$(OBJEXT) cond_exp.$(OBJEXT) \ - cond_exp_ad.$(OBJEXT) cond_exp_rev.$(OBJEXT) copy.$(OBJEXT) \ - cos.$(OBJEXT) cosh.$(OBJEXT) dbl_epsilon.$(OBJEXT) \ - dependency.$(OBJEXT) div.$(OBJEXT) div_eq.$(OBJEXT) \ - div_zero_one.$(OBJEXT) erf.$(OBJEXT) exp.$(OBJEXT) \ - expm1.$(OBJEXT) extern_value.$(OBJEXT) for_hess.$(OBJEXT) \ + chkpoint_one.$(OBJEXT) chkpoint_two.$(OBJEXT) \ + check_simple_vector.$(OBJEXT) compare_change.$(OBJEXT) \ + compare.$(OBJEXT) cond_exp_ad.$(OBJEXT) cond_exp.$(OBJEXT) \ + cond_exp_rev.$(OBJEXT) copy.$(OBJEXT) cos.$(OBJEXT) \ + cosh.$(OBJEXT) dbl_epsilon.$(OBJEXT) dependency.$(OBJEXT) \ + div.$(OBJEXT) div_eq.$(OBJEXT) div_zero_one.$(OBJEXT) \ + erf.$(OBJEXT) exp.$(OBJEXT) expm1.$(OBJEXT) \ + extern_value.$(OBJEXT) fabs.$(OBJEXT) for_hess.$(OBJEXT) \ for_sparse_hes.$(OBJEXT) for_sparse_jac.$(OBJEXT) \ forward.$(OBJEXT) forward_dir.$(OBJEXT) \ forward_order.$(OBJEXT) from_base.$(OBJEXT) \ fun_check.$(OBJEXT) hes_sparsity.$(OBJEXT) jacobian.$(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) \ + log10.$(OBJEXT) log1p.$(OBJEXT) log.$(OBJEXT) \ + mul_cond_rev.$(OBJEXT) mul.$(OBJEXT) mul_cskip.$(OBJEXT) \ + mul_eq.$(OBJEXT) mul_level.$(OBJEXT) mul_zdouble.$(OBJEXT) \ + mul_zero_one.$(OBJEXT) near_equal_ext.$(OBJEXT) neg.$(OBJEXT) \ + new_dynamic.$(OBJEXT) num_limits.$(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) \ + pow_int.$(OBJEXT) print_for.$(OBJEXT) reverse.$(OBJEXT) \ rev_sparse_jac.$(OBJEXT) rev_two.$(OBJEXT) \ - simple_vector.$(OBJEXT) sin.$(OBJEXT) sin_cos.$(OBJEXT) \ + romberg_one.$(OBJEXT) rosen_34.$(OBJEXT) runge_45.$(OBJEXT) \ + simple_vector.$(OBJEXT) sin_cos.$(OBJEXT) sin.$(OBJEXT) \ sinh.$(OBJEXT) sparse_hessian.$(OBJEXT) \ - sparse_jacobian.$(OBJEXT) sparse_sub_hes.$(OBJEXT) \ - sparse_vec_ad.$(OBJEXT) sqrt.$(OBJEXT) std_math.$(OBJEXT) \ - sub.$(OBJEXT) sub_eq.$(OBJEXT) sub_zero.$(OBJEXT) \ - subgraph.$(OBJEXT) tan.$(OBJEXT) test_vector.$(OBJEXT) \ - to_string.$(OBJEXT) value.$(OBJEXT) vec_ad.$(OBJEXT) \ - vec_ad_par.$(OBJEXT) vec_unary.$(OBJEXT) + sparse_jacobian.$(OBJEXT) sparse_jac_work.$(OBJEXT) \ + sparse_sub_hes.$(OBJEXT) sparse_vec_ad.$(OBJEXT) \ + sqrt.$(OBJEXT) std_math.$(OBJEXT) sub.$(OBJEXT) \ + sub_eq.$(OBJEXT) subgraph.$(OBJEXT) sub_zero.$(OBJEXT) \ + tan.$(OBJEXT) test_vector.$(OBJEXT) to_string.$(OBJEXT) \ + value.$(OBJEXT) vec_ad.$(OBJEXT) vec_ad_par.$(OBJEXT) \ + vec_unary.$(OBJEXT) general_OBJECTS = $(am_general_OBJECTS) general_LDADD = $(LDADD) am__DEPENDENCIES_1 = @@ -181,7 +172,7 @@ @CppAD_IPOPT_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @CppAD_IPOPT_TRUE@ $(am__DEPENDENCIES_1) general_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -198,10 +189,6 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) @@ -227,9 +214,8 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(libeigen_a_SOURCES) $(general_SOURCES) -DIST_SOURCES = $(am__libeigen_a_SOURCES_DIST) \ - $(am__general_SOURCES_DIST) +SOURCES = $(general_SOURCES) +DIST_SOURCES = $(am__general_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -281,19 +267,18 @@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CXX_FLAGS = @CXX_FLAGS@ -CXX_FLAGS_EIGEN = @CXX_FLAGS_EIGEN@ -CXX_FLAGS_FADBAD = @CXX_FLAGS_FADBAD@ CYGPATH_W = @CYGPATH_W@ # ----------------------------------------------------------------------------- -# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell # -# CppAD is distributed under multiple licenses. This distribution is under -# the terms of the -# GNU General Public License Version 3. +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.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. +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. # ----------------------------------------------------------------------------- # automake input file # @@ -366,10 +351,8 @@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -cppad_SOURCE_DIR = @cppad_SOURCE_DIR@ -cppad_abs_includedir = @cppad_abs_includedir@ +compiler_has_conversion_warn = @compiler_has_conversion_warn@ cppad_boostvector = @cppad_boostvector@ -cppad_compiler_is_gnucxx = @cppad_compiler_is_gnucxx@ cppad_cplusplus_201100_ok = @cppad_cplusplus_201100_ok@ cppad_cppadvector = @cppad_cppadvector@ cppad_cxx_flags = @cppad_cxx_flags@ @@ -388,9 +371,11 @@ cppad_has_tmpnam_s = @cppad_has_tmpnam_s@ cppad_max_num_threads = @cppad_max_num_threads@ cppad_pkgconfig_cflags = @cppad_pkgconfig_cflags@ +cppad_pkgconfig_cflags_uninstalled = @cppad_pkgconfig_cflags_uninstalled@ cppad_pkgconfig_libs = @cppad_pkgconfig_libs@ +cppad_pkgconfig_libs_uninstalled = @cppad_pkgconfig_libs_uninstalled@ cppad_pkgconfig_requires = @cppad_pkgconfig_requires@ -cppad_prefix = @cppad_prefix@ +cppad_pkgconfig_requires_uninstalled = @cppad_pkgconfig_requires_uninstalled@ cppad_stdvector = @cppad_stdvector@ cppad_tape_addr_type = @cppad_tape_addr_type@ cppad_tape_id_type = @cppad_tape_id_type@ @@ -413,8 +398,6 @@ infodir = @infodir@ install_sh = @install_sh@ ipopt_prefix = @ipopt_prefix@ -is_pod_specialize_11 = @is_pod_specialize_11@ -is_pod_specialize_98 = @is_pod_specialize_98@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ @@ -441,8 +424,6 @@ @CppAD_ADOLC_FALSE@ADOLC_SRC_FILES = # ------------------------------------------------------------------------- @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 = @@ -450,37 +431,22 @@ @CppAD_IPOPT_FALSE@IPOPT_SRC_FILES = # ------------------------------------------------------------------------- @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 = @CppAD_IPOPT_TRUE@IPOPT_LIB = -lipopt \ @CppAD_IPOPT_TRUE@ $(CPPAD_IPOPT_LIBS) $(FCLIBS) $(PTHREAD_LIB) $(DL_LIB) @CppAD_IPOPT_FALSE@IPOPT_FLAGS = @CppAD_IPOPT_TRUE@IPOPT_FLAGS = -I$(IPOPT_DIR)/include -@CppAD_EIGEN_DIR_FALSE@EIGEN_EXTRA_FILES = cppad_eigen.cpp eigen_mat_inv.cpp -# ------------------------------------------------------------------------- -# make a special library so can have it's own compile flags (see configure.ac) -@CppAD_EIGEN_DIR_TRUE@EIGEN_EXTRA_FILES = -@CppAD_EIGEN_DIR_TRUE@noinst_LIBRARIES = libeigen.a -@CppAD_EIGEN_DIR_TRUE@libeigen_a_SOURCES = cppad_eigen.cpp eigen_mat_inv.cpp -@CppAD_EIGEN_DIR_FALSE@EIGEN_LIB = -@CppAD_EIGEN_DIR_TRUE@EIGEN_LIB = -L. -leigen -@CppAD_EIGEN_DIR_TRUE@libeigen_a_CXXFLAGS = \ -@CppAD_EIGEN_DIR_TRUE@ -g \ -@CppAD_EIGEN_DIR_TRUE@ $(CXX_FLAGS_EIGEN) \ -@CppAD_EIGEN_DIR_TRUE@ -I$(EIGEN_DIR)/include - +@CppAD_EIGEN_FALSE@EIGEN_SRC_FILES = # ------------------------------------------------------------------------- -# Microsoft project files and script to run a single test -EXTRA_DIST = \ - $(ADOLC_EXTRA_FILES) \ - $(IPOPT_EXTRA_FILES) \ - $(EIGEN_EXTRA_FILES) - +@CppAD_EIGEN_TRUE@EIGEN_SRC_FILES = cppad_eigen.cpp eigen_mat_inv.cpp # -AM_CPPFLAGS = -I. \ - -I$(top_srcdir) \ +# +AM_CXXFLAGS = \ + $(ADOLC_FLAGS) \ + $(IPOPT_FLAGS) \ + $(CXX_FLAGS) \ + -I$(top_srcdir)/include \ $(BOOST_INCLUDE) \ $(EIGEN_INCLUDE) \ $(ADOLC_FLAGS) \ @@ -488,39 +454,39 @@ $(OPENMP_FLAGS) # -AM_CXXFLAGS = -g $(ADOLC_FLAGS) $(IPOPT_FLAGS) $(CXX_FLAGS) -# AM_LDFLAGS = $(OPENMP_FLAGS) -LDADD = $(ADOLC_LIB) $(IPOPT_LIB) $(EIGEN_LIB) $(OPENMP_FLAGS) +LDADD = $(ADOLC_LIB) $(IPOPT_LIB) $(OPENMP_FLAGS) # +# BEGIN_SORT_THIS_LINE_PLUS_6 general_SOURCES = \ $(ADOLC_SRC_FILES) \ + $(EIGEN_SRC_FILES) \ $(IPOPT_SRC_FILES) \ $(OPENMP_SRC_FILES) \ general.cpp \ - fabs.cpp \ acos.cpp \ acosh.cpp \ + add.cpp \ + add_eq.cpp \ + add_zero.cpp \ adfun_copy.cpp \ asin.cpp \ asinh.cpp \ assign.cpp \ - add.cpp \ - add_eq.cpp \ - add_zero.cpp \ + atan2.cpp \ atan.cpp \ atanh.cpp \ - atan2.cpp \ - atomic_sparsity.cpp \ + atomic_three.cpp \ azmul.cpp \ base_alloc.cpp \ bool_sparsity.cpp \ + chkpoint_one.cpp \ + chkpoint_two.cpp \ check_simple_vector.cpp \ - checkpoint.cpp \ - compare.cpp \ compare_change.cpp \ - cond_exp.cpp \ + compare.cpp \ cond_exp_ad.cpp \ + cond_exp.cpp \ cond_exp_rev.cpp \ copy.cpp \ cos.cpp \ @@ -535,6 +501,7 @@ expm1.cpp \ extern_value.cpp \ extern_value.hpp \ + fabs.cpp \ for_hess.cpp \ for_sparse_hes.cpp \ for_sparse_jac.cpp \ @@ -545,19 +512,20 @@ fun_check.cpp \ hes_sparsity.cpp \ jacobian.cpp \ - num_limits.cpp \ - log.cpp \ - log1p.cpp \ log10.cpp \ + log1p.cpp \ + log.cpp \ + mul_cond_rev.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 \ + new_dynamic.cpp \ + num_limits.cpp \ ode_err_control.cpp \ optimize.cpp \ parameter.cpp \ @@ -565,26 +533,27 @@ pow.cpp \ pow_int.cpp \ print_for.cpp \ - romberg_one.cpp \ - rosen_34.cpp \ - runge_45.cpp \ reverse.cpp \ rev_sparse_jac.cpp \ rev_two.cpp \ + romberg_one.cpp \ + rosen_34.cpp \ + runge_45.cpp \ simple_vector.cpp \ - sin.cpp \ sin_cos.cpp \ + sin.cpp \ sinh.cpp \ sparse_hessian.cpp \ sparse_jacobian.cpp \ + sparse_jac_work.cpp \ sparse_sub_hes.cpp \ sparse_vec_ad.cpp \ sqrt.cpp \ std_math.cpp \ sub.cpp \ sub_eq.cpp \ - sub_zero.cpp \ subgraph.cpp \ + sub_zero.cpp \ tan.cpp \ test_vector.cpp \ to_string.cpp \ @@ -627,14 +596,6 @@ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) - -libeigen.a: $(libeigen_a_OBJECTS) $(libeigen_a_DEPENDENCIES) $(EXTRA_libeigen_a_DEPENDENCIES) - $(AM_V_at)-rm -f libeigen.a - $(AM_V_AR)$(libeigen_a_AR) libeigen.a $(libeigen_a_OBJECTS) $(libeigen_a_LIBADD) - $(AM_V_at)$(RANLIB) libeigen.a - clean-checkPROGRAMS: -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) @@ -661,13 +622,14 @@ @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)/atomic_sparsity.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atomic_three.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)/bool_sparsity.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_simple_vector.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checkpoint.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chkpoint_one.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chkpoint_two.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compare.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compare_change.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cond_exp.Po@am__quote@ @@ -676,11 +638,13 @@ @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@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppad_eigen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbl_epsilon.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)/div_zero_one.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eigen_mat_inv.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@ @@ -698,8 +662,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hes_sparsity.Po@am__quote@ @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)/libeigen_a-eigen_mat_inv.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@ @@ -712,6 +674,7 @@ @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)/new_dynamic.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)/optimize.Po@am__quote@ @@ -731,6 +694,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sin_cos.Po@am__quote@ @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_jac_work.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)/sparse_vec_ad.Po@am__quote@ @@ -764,34 +728,6 @@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` -libeigen_a-cppad_eigen.o: cppad_eigen.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -MT libeigen_a-cppad_eigen.o -MD -MP -MF $(DEPDIR)/libeigen_a-cppad_eigen.Tpo -c -o libeigen_a-cppad_eigen.o `test -f 'cppad_eigen.cpp' || echo '$(srcdir)/'`cppad_eigen.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeigen_a-cppad_eigen.Tpo $(DEPDIR)/libeigen_a-cppad_eigen.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cppad_eigen.cpp' object='libeigen_a-cppad_eigen.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -c -o libeigen_a-cppad_eigen.o `test -f 'cppad_eigen.cpp' || echo '$(srcdir)/'`cppad_eigen.cpp - -libeigen_a-cppad_eigen.obj: cppad_eigen.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -MT libeigen_a-cppad_eigen.obj -MD -MP -MF $(DEPDIR)/libeigen_a-cppad_eigen.Tpo -c -o libeigen_a-cppad_eigen.obj `if test -f 'cppad_eigen.cpp'; then $(CYGPATH_W) 'cppad_eigen.cpp'; else $(CYGPATH_W) '$(srcdir)/cppad_eigen.cpp'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeigen_a-cppad_eigen.Tpo $(DEPDIR)/libeigen_a-cppad_eigen.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cppad_eigen.cpp' object='libeigen_a-cppad_eigen.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -c -o libeigen_a-cppad_eigen.obj `if test -f 'cppad_eigen.cpp'; then $(CYGPATH_W) 'cppad_eigen.cpp'; else $(CYGPATH_W) '$(srcdir)/cppad_eigen.cpp'; fi` - -libeigen_a-eigen_mat_inv.o: eigen_mat_inv.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -MT libeigen_a-eigen_mat_inv.o -MD -MP -MF $(DEPDIR)/libeigen_a-eigen_mat_inv.Tpo -c -o libeigen_a-eigen_mat_inv.o `test -f 'eigen_mat_inv.cpp' || echo '$(srcdir)/'`eigen_mat_inv.cpp -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeigen_a-eigen_mat_inv.Tpo $(DEPDIR)/libeigen_a-eigen_mat_inv.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='eigen_mat_inv.cpp' object='libeigen_a-eigen_mat_inv.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -c -o libeigen_a-eigen_mat_inv.o `test -f 'eigen_mat_inv.cpp' || echo '$(srcdir)/'`eigen_mat_inv.cpp - -libeigen_a-eigen_mat_inv.obj: eigen_mat_inv.cpp -@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -MT libeigen_a-eigen_mat_inv.obj -MD -MP -MF $(DEPDIR)/libeigen_a-eigen_mat_inv.Tpo -c -o libeigen_a-eigen_mat_inv.obj `if test -f 'eigen_mat_inv.cpp'; then $(CYGPATH_W) 'eigen_mat_inv.cpp'; else $(CYGPATH_W) '$(srcdir)/eigen_mat_inv.cpp'; fi` -@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libeigen_a-eigen_mat_inv.Tpo $(DEPDIR)/libeigen_a-eigen_mat_inv.Po -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='eigen_mat_inv.cpp' object='libeigen_a-eigen_mat_inv.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libeigen_a_CXXFLAGS) $(CXXFLAGS) -c -o libeigen_a-eigen_mat_inv.obj `if test -f 'eigen_mat_inv.cpp'; then $(CYGPATH_W) 'eigen_mat_inv.cpp'; else $(CYGPATH_W) '$(srcdir)/eigen_mat_inv.cpp'; fi` - ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am @@ -877,7 +813,7 @@ check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) check: check-am -all-am: makefile $(LIBRARIES) +all-am: makefile installdirs: install: install-am install-exec: install-exec-am @@ -911,8 +847,7 @@ @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-checkPROGRAMS clean-generic clean-noinstLIBRARIES \ - mostlyclean-am +clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) @@ -982,21 +917,21 @@ .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ - clean-checkPROGRAMS clean-generic clean-noinstLIBRARIES \ - cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am + clean-checkPROGRAMS clean-generic cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am .PRECIOUS: makefile +# END_SORT_THIS_LINE_MINUS_1 test: check ./general diff -Nru cppad-2018.00.00.0/test_more/general/mul_cond_rev.cpp cppad-2019.02.00.0/test_more/general/mul_cond_rev.cpp --- cppad-2018.00.00.0/test_more/general/mul_cond_rev.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/mul_cond_rev.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell -CppAD is distributed under multiple licenses. This distribution is under -the terms of the - GNU General Public License Version 3. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.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. --------------------------------------------------------------------------- */ +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test of multi-level conditional expressions reverse mode */ @@ -16,204 +17,204 @@ 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, fabs( 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, fabs( 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; + 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, fabs( 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, fabs( 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-2018.00.00.0/test_more/general/mul.cpp cppad-2019.02.00.0/test_more/general/mul.cpp --- cppad-2018.00.00.0/test_more/general/mul.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/mul.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Two old Mul examples now used just for valiadation testing @@ -17,153 +18,155 @@ namespace { // BEGIN empty namespace bool MulTestOne(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(2); - size_t s = 0; - size_t t = 1; - U[s] = 3.; - U[t] = 2.; - Independent(U); - - // assign some parameters - AD zero = 0.; - AD one = 1.; - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(5); - size_t x = 0; - size_t y = 1; - size_t z = 2; - size_t u = 3; - size_t v = 4; - - // 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[u] = one * Z[z]; // multiplication by parameter equal to one - Z[v] = zero * Z[z]; // multiplication by parameter equal to zero - - // check multipilcation by zero results in a parameter - ok &= Parameter(Z[v]); - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) q( f.Domain() ); - CPPAD_TESTVECTOR(double) r( f.Range() ); - - // check parameter flag - ok &= f.Parameter(v); - - // check values - ok &= ( Z[x] == 3. * 2. ); - ok &= ( Z[y] == 3. * 2. * 4. ); - ok &= ( Z[z] == 4. * 3. * 2. * 4. ); - ok &= ( Z[u] == Z[z] ); - ok &= ( Z[v] == 0. ); - - // forward computation of partials w.r.t. s - q[s] = 1.; - q[t] = 0.; - r = f.Forward(1, q); - 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 - ok &= ( r[v] == 0. ); // dv/ds - - // reverse computation of second partials of z - CPPAD_TESTVECTOR(double) d2( f.Domain() * 2 ); - r[x] = 0.; - r[y] = 0.; - r[z] = 1.; - r[u] = 0.; - r[v] = 0.; - d2 = f.Reverse(2, r); - - // check second order partials - ok &= ( d2[2 * s + 1] == 0. ); // d^2 z / (ds ds) - ok &= ( d2[2 * t + 1] == 4. * 4. ); // d^2 z / (ds dt) + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(2); + size_t s = 0; + size_t t = 1; + U[s] = 3.; + U[t] = 2.; + Independent(U); + + // assign some parameters + AD zero = 0.; + AD one = 1.; + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(5); + size_t x = 0; + size_t y = 1; + size_t z = 2; + size_t u = 3; + size_t v = 4; + + // 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[u] = one * Z[z]; // multiplication by parameter equal to one + Z[v] = zero * Z[z]; // multiplication by parameter equal to zero + + // check multipilcation by zero results in a parameter + ok &= Parameter(Z[v]); + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) q( f.Domain() ); + CPPAD_TESTVECTOR(double) r( f.Range() ); + + // check parameter flag + ok &= f.Parameter(v); + + // check values + ok &= ( Z[x] == 3. * 2. ); + ok &= ( Z[y] == 3. * 2. * 4. ); + ok &= ( Z[z] == 4. * 3. * 2. * 4. ); + ok &= ( Z[u] == Z[z] ); + ok &= ( Z[v] == 0. ); + + // forward computation of partials w.r.t. s + q[s] = 1.; + q[t] = 0.; + r = f.Forward(1, q); + 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 + ok &= ( r[v] == 0. ); // dv/ds + + // reverse computation of second partials of z + CPPAD_TESTVECTOR(double) d2( f.Domain() * 2 ); + r[x] = 0.; + r[y] = 0.; + r[z] = 1.; + r[u] = 0.; + r[v] = 0.; + d2 = f.Reverse(2, r); + + // check second order partials + ok &= ( d2[2 * s + 1] == 0. ); // d^2 z / (ds ds) + ok &= ( d2[2 * t + 1] == 4. * 4. ); // d^2 z / (ds dt) - return ok; + return ok; } bool MulTestTwo(void) -{ bool ok = true; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - double u0 = .5; - CPPAD_TESTVECTOR(AD) U(1); - 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 - - // 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); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(Value(Z[0]) , u0*4*3*2*u0, eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { double value; - if( j == 1 ) - value = 48. * u0; - else if( j == 2 ) - value = 48.; - else value = 0.; - - jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - for(j = 0; j < p; j++) - { double value; - if( j == 0 ) - value = 48. * u0; - else if( j == 1 ) - value = 48.; - else value = 0.; - - ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - } +{ bool ok = true; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + double u0 = .5; + CPPAD_TESTVECTOR(AD) U(1); + 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 + + // 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); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(Value(Z[0]) , u0*4*3*2*u0, eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { double value; + if( j == 1 ) + value = 48. * u0; + else if( j == 2 ) + value = 48.; + else + value = 0.; + + jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + for(j = 0; j < p; j++) + { double value; + if( j == 0 ) + value = 48. * u0; + else if( j == 1 ) + value = 48.; + else + value = 0.; + + ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + jfac *= double(j + 1); + } - return ok; + return ok; } } // END empty namespace bool Mul(void) -{ bool ok = true; - ok &= MulTestOne(); - ok &= MulTestTwo(); - return ok; +{ bool ok = true; + ok &= MulTestOne(); + ok &= MulTestTwo(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/mul_cskip.cpp cppad-2019.02.00.0/test_more/general/mul_cskip.cpp --- cppad-2018.00.00.0/test_more/general/mul_cskip.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/mul_cskip.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,70 +1,71 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # 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; +{ 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; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/mul_eq.cpp cppad-2019.02.00.0/test_more/general/mul_eq.cpp --- cppad-2018.00.00.0/test_more/general/mul_eq.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/mul_eq.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Two old MulEq examples now used just for valiadation testing @@ -17,137 +18,139 @@ namespace { // BEGIN empty namespace bool MulEqTestOne(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(2); - size_t s = 0; - size_t t = 1; - U[s] = 3.; - U[t] = 2.; - Independent(U); - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(2); - size_t x = 0; - size_t y = 1; - - // some initial values - AD zero = 0.; - AD one = 1.; - - // dependent variable values - Z[x] = U[s]; - Z[y] = U[t]; - Z[x] *= U[t]; // AD *= AD - Z[y] *= 5.; // AD *= double - zero *= Z[x]; - one *= Z[x]; - - // check that zero is a parameter - ok &= Parameter(zero); - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // check values - ok &= ( Z[x] == 3. * 2. ); - ok &= ( Z[y] == 2. * 5. ); - ok &= ( zero == 0. ); - ok &= ( one == Z[x] ); - - // forward computation of partials w.r.t. t - v[s] = 0.; - v[t] = 1.; - w = f.Forward(1, v); - ok &= ( w[x] == U[s] ); // dx/dt - ok &= ( w[y] == 5. ); // dy/dt - - // reverse computation of second partials of x - CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); - w[x] = 1.; - w[y] = 0.; - r = f.Reverse(2, w); - ok &= ( r[2 * s + 1] == 1. ); - ok &= ( r[2 * t + 1] == 0. ); + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(2); + size_t s = 0; + size_t t = 1; + U[s] = 3.; + U[t] = 2.; + Independent(U); + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(2); + size_t x = 0; + size_t y = 1; + + // some initial values + AD zero = 0.; + AD one = 1.; + + // dependent variable values + Z[x] = U[s]; + Z[y] = U[t]; + Z[x] *= U[t]; // AD *= AD + Z[y] *= 5.; // AD *= double + zero *= Z[x]; + one *= Z[x]; + + // check that zero is a parameter + ok &= Parameter(zero); + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // check values + ok &= ( Z[x] == 3. * 2. ); + ok &= ( Z[y] == 2. * 5. ); + ok &= ( zero == 0. ); + ok &= ( one == Z[x] ); + + // forward computation of partials w.r.t. t + v[s] = 0.; + v[t] = 1.; + w = f.Forward(1, v); + ok &= ( w[x] == U[s] ); // dx/dt + ok &= ( w[y] == 5. ); // dy/dt + + // reverse computation of second partials of x + CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); + w[x] = 1.; + w[y] = 0.; + r = f.Reverse(2, w); + ok &= ( r[2 * s + 1] == 1. ); + ok &= ( r[2 * t + 1] == 0. ); - return ok; + return ok; } bool MulEqTestTwo(void) -{ bool ok = true; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - double u0 = .5; - CPPAD_TESTVECTOR(AD) U(1); - U[0] = u0; - Independent(U); - - // 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 - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(Z[0] , u0*2*4*u0, eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { double value; - if( j == 1 ) - value = 16. * u0; - else if( j == 2 ) - value = 16.; - else value = 0.; - - jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - for(j = 0; j < p; j++) - { double value; - if( j == 0 ) - value = 16. * u0; - else if( j == 1 ) - value = 16.; - else value = 0.; - - ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - } +{ bool ok = true; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + double u0 = .5; + CPPAD_TESTVECTOR(AD) U(1); + U[0] = u0; + Independent(U); + + // 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 + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(Z[0] , u0*2*4*u0, eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { double value; + if( j == 1 ) + value = 16. * u0; + else if( j == 2 ) + value = 16.; + else + value = 0.; + + jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + for(j = 0; j < p; j++) + { double value; + if( j == 0 ) + value = 16. * u0; + else if( j == 1 ) + value = 16.; + else + value = 0.; + + ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + jfac *= double(j + 1); + } - return ok; + return ok; } } // END empty namespace bool MulEq(void) -{ bool ok = true; - ok &= MulEqTestOne(); - ok &= MulEqTestTwo(); - return ok; +{ bool ok = true; + ok &= MulEqTestOne(); + ok &= MulEqTestTwo(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/mul_level.cpp cppad-2019.02.00.0/test_more/general/mul_level.cpp --- cppad-2018.00.00.0/test_more/general/mul_level.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/mul_level.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // CPPAD_HAS_* defines and CPPAD_COMPILER_IS_GNUCXX @@ -31,304 +32,304 @@ namespace { // BEGIN empty namespace bool One(void) -{ bool ok = true; // initialize test result - using CppAD::NearEqual; - double eps = 10. * std::numeric_limits::epsilon(); - - - typedef CppAD::AD ADdouble; // for one level of taping - typedef CppAD::AD ADDdouble; // for two levels of taping - size_t n = 2; // dimension for example - - // value of the independent variables - CPPAD_TESTVECTOR(ADDdouble) aa_x(n); - aa_x[0] = 1.; aa_x[1] = 3.; // test conversion double to AD< AD > - aa_x[0] = 2. * aa_x[0]; // test double * AD< AD > - CppAD::Independent(aa_x); - - // compute the function f(x) = 2 * x[0] * x[1] - CPPAD_TESTVECTOR(ADDdouble) aa_f(1); - aa_f[0] = 2. * aa_x[0] * aa_x[1]; - CppAD::ADFun F(aa_x, aa_f); - - // value of the independent variables - CPPAD_TESTVECTOR(ADdouble) a_x(n); - a_x[0] = 2.; a_x[1] = 3.; - Independent(a_x); - - // re-evaluate f(2, 3) (must get deepedence on a_x). - size_t p = 0; - CPPAD_TESTVECTOR(ADdouble) a_fp(1); - a_fp = F.Forward(p, a_x); - ok &= NearEqual(a_fp[0], 2. * a_x[0] * a_x[1], eps, eps); - - // compute the function g(x) = 2 * partial_x[0] f(x) = 4 * x[1] - p = 1; - CPPAD_TESTVECTOR(ADdouble) a_dx(n), a_g(1); - a_dx[0] = 1.; a_dx[1] = 0.; - a_fp = F.Forward(p, a_dx); - a_g[0] = 2. * a_fp[0]; - CppAD::ADFun G(a_x, a_g); - - // compute partial_x[1] g(x) - CPPAD_TESTVECTOR(double) xp(n), gp(1); - p = 0; - xp[0] = 4.; xp[1] = 5.; - gp = G.Forward(p, xp); - ok &= NearEqual(gp[0], 4. * xp[1], eps, eps); - - p = 1; - xp[0] = 0.; xp[1] = 1.; - gp = G.Forward(p, xp); - ok &= NearEqual(gp[0], 4., eps, eps); +{ bool ok = true; // initialize test result + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); + + + typedef CppAD::AD ADdouble; // for one level of taping + typedef CppAD::AD ADDdouble; // for two levels of taping + size_t n = 2; // dimension for example + + // value of the independent variables + CPPAD_TESTVECTOR(ADDdouble) aa_x(n); + aa_x[0] = 1.; aa_x[1] = 3.; // test conversion double to AD< AD > + aa_x[0] = 2. * aa_x[0]; // test double * AD< AD > + CppAD::Independent(aa_x); + + // compute the function f(x) = 2 * x[0] * x[1] + CPPAD_TESTVECTOR(ADDdouble) aa_f(1); + aa_f[0] = 2. * aa_x[0] * aa_x[1]; + CppAD::ADFun F(aa_x, aa_f); + + // value of the independent variables + CPPAD_TESTVECTOR(ADdouble) a_x(n); + a_x[0] = 2.; a_x[1] = 3.; + Independent(a_x); + + // re-evaluate f(2, 3) (must get deepedence on a_x). + size_t p = 0; + CPPAD_TESTVECTOR(ADdouble) a_fp(1); + a_fp = F.Forward(p, a_x); + ok &= NearEqual(a_fp[0], 2. * a_x[0] * a_x[1], eps, eps); + + // compute the function g(x) = 2 * partial_x[0] f(x) = 4 * x[1] + p = 1; + CPPAD_TESTVECTOR(ADdouble) a_dx(n), a_g(1); + a_dx[0] = 1.; a_dx[1] = 0.; + a_fp = F.Forward(p, a_dx); + a_g[0] = 2. * a_fp[0]; + CppAD::ADFun G(a_x, a_g); + + // compute partial_x[1] g(x) + CPPAD_TESTVECTOR(double) xp(n), gp(1); + p = 0; + xp[0] = 4.; xp[1] = 5.; + gp = G.Forward(p, xp); + ok &= NearEqual(gp[0], 4. * xp[1], eps, eps); + + p = 1; + xp[0] = 0.; xp[1] = 1.; + gp = G.Forward(p, xp); + ok &= NearEqual(gp[0], 4., eps, eps); - return ok; + return ok; } // f(x) = |x|^2 = .5 * ( x[0]^2 + ... + x[n-1]^2 ) template Type f_Two(CPPAD_TESTVECTOR(Type) &x) -{ Type sum; +{ Type sum; - // check assignment of AD< AD > = double - sum = .5; - sum += .5; + // check assignment of AD< AD > = double + sum = .5; + sum += .5; - size_t i = x.size(); - while(i--) - sum += x[i] * x[i]; + size_t i = x.size(); + while(i--) + sum += x[i] * x[i]; - // check compound assignment AD< AD > -= int - sum -= 1; + // check compound assignment AD< AD > -= int + sum -= 1; - // check double * AD< AD > - return .5 * sum; + // check double * AD< AD > + return .5 * sum; } bool Two(void) -{ bool ok = true; // initialize test result - double eps99 = 99.0 * std::numeric_limits::epsilon(); +{ bool ok = true; // initialize test result + double eps99 = 99.0 * std::numeric_limits::epsilon(); - typedef CppAD::AD ADdouble; // for one level of taping - typedef CppAD::AD ADDdouble; // 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(ADdouble) a_x(n); - CPPAD_TESTVECTOR(ADDdouble) aa_x(n); - - // value of the independent variables - for(j = 0; j < n; j++) - a_x[j] = x[j] = double(j); // x[j] = j - Independent(a_x); // a_x is indedendent for ADdouble - 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 - CPPAD_TESTVECTOR(ADDdouble) aa_f(1); // scalar valued function - aa_f[0] = f_Two(aa_x); // has only one component - - // declare inner function (corresponding to ADDdouble calculation) - CppAD::ADFun a_F(aa_x, aa_f); - - // 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 (corresponding to ADdouble calculation) - CppAD::ADFun df(a_x, a_df); - - // compute the d/dx of f'(x) * v = f''(x) * v - CPPAD_TESTVECTOR(double) v(n); - CPPAD_TESTVECTOR(double) ddf_v(n); - for(j = 0; j < n; j++) - v[j] = double(n - j); - ddf_v = df.Reverse(p, v); - - // f(x) = .5 * ( x[0]^2 + x[1]^2 + ... + x[n-1]^2 ) - // f'(x) = (x[0], x[1], ... , x[n-1]) - // f''(x) * v = ( v[0], v[1], ... , x[n-1] ) - for(j = 0; j < n; j++) - ok &= CppAD::NearEqual(ddf_v[j], v[j], eps99, eps99); + typedef CppAD::AD ADdouble; // for one level of taping + typedef CppAD::AD ADDdouble; // 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(ADdouble) a_x(n); + CPPAD_TESTVECTOR(ADDdouble) aa_x(n); + + // value of the independent variables + for(j = 0; j < n; j++) + a_x[j] = x[j] = double(j); // x[j] = j + Independent(a_x); // a_x is indedendent for ADdouble + 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 + CPPAD_TESTVECTOR(ADDdouble) aa_f(1); // scalar valued function + aa_f[0] = f_Two(aa_x); // has only one component + + // declare inner function (corresponding to ADDdouble calculation) + CppAD::ADFun a_F(aa_x, aa_f); + + // 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 (corresponding to ADdouble calculation) + CppAD::ADFun df(a_x, a_df); + + // compute the d/dx of f'(x) * v = f''(x) * v + CPPAD_TESTVECTOR(double) v(n); + CPPAD_TESTVECTOR(double) ddf_v(n); + for(j = 0; j < n; j++) + v[j] = double(n - j); + ddf_v = df.Reverse(p, v); + + // f(x) = .5 * ( x[0]^2 + x[1]^2 + ... + x[n-1]^2 ) + // f'(x) = (x[0], x[1], ... , x[n-1]) + // f''(x) * v = ( v[0], v[1], ... , x[n-1] ) + for(j = 0; j < n; j++) + ok &= CppAD::NearEqual(ddf_v[j], v[j], eps99, eps99); - return ok; + return ok; } # if CPPAD_HAS_ADOLC bool adolc(void) -{ bool ok = true; // initialize test result - double eps99 = 99.0 * std::numeric_limits::epsilon(); +{ bool ok = true; // initialize test result + double eps99 = 99.0 * std::numeric_limits::epsilon(); - typedef adouble ADdouble; // for first level of taping - typedef CppAD::AD ADDdouble; // for second level of taping - size_t n = 5; // number independent variables - - CPPAD_TESTVECTOR(double) x(n); - CPPAD_TESTVECTOR(ADdouble) a_x(n); - CPPAD_TESTVECTOR(ADDdouble) aa_x(n); - - // value of the independent variables - int tag = 0; // Adolc setup - int keep = 1; - trace_on(tag, keep); - size_t j; - for(j = 0; j < n; j++) - { x[j] = double(j); // x[j] = j - a_x[j] <<= x[j]; // a_x is independent for ADdouble - } - 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 - CPPAD_TESTVECTOR(ADDdouble) aa_f(1); // scalar valued function - aa_f[0] = f_Two(aa_x); // has only one component - - // declare inner function (corresponding to ADDdouble calculation) - CppAD::ADFun a_F(aa_x, aa_f); - - // 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 - // (corresponding to the tape of adouble operations) - double df_j; - for(j = 0; j < n; j++) - a_df[j] >>= df_j; - trace_off(); - - // compute the d/dx of f'(x) * v = f''(x) * v - size_t m = n; // # dependent in f'(x) - double *v = CPPAD_NULL, *ddf_v = CPPAD_NULL; - v = CPPAD_TRACK_NEW_VEC(m, v); // track v = new double[m] - ddf_v = CPPAD_TRACK_NEW_VEC(n, ddf_v); // track ddf_v = new double[n] - for(j = 0; j < n; j++) - v[j] = double(n - j); - fos_reverse(tag, int(m), int(n), v, ddf_v); - - // f(x) = .5 * ( x[0]^2 + x[1]^2 + ... + x[n-1]^2 ) - // f'(x) = (x[0], x[1], ... , x[n-1]) - // f''(x) * v = ( v[0], v[1], ... , x[n-1] ) - for(j = 0; j < n; j++) - ok &= CppAD::NearEqual(ddf_v[j], v[j], eps99, eps99); - - CPPAD_TRACK_DEL_VEC(v); // check usage of delete - CPPAD_TRACK_DEL_VEC(ddf_v); - return ok; + typedef adouble ADdouble; // for first level of taping + typedef CppAD::AD ADDdouble; // for second level of taping + size_t n = 5; // number independent variables + + CPPAD_TESTVECTOR(double) x(n); + CPPAD_TESTVECTOR(ADdouble) a_x(n); + CPPAD_TESTVECTOR(ADDdouble) aa_x(n); + + // value of the independent variables + short tag = 0; // Adolc setup + int keep = 1; + trace_on(tag, keep); + size_t j; + for(j = 0; j < n; j++) + { x[j] = double(j); // x[j] = j + a_x[j] <<= x[j]; // a_x is independent for ADdouble + } + 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 + CPPAD_TESTVECTOR(ADDdouble) aa_f(1); // scalar valued function + aa_f[0] = f_Two(aa_x); // has only one component + + // declare inner function (corresponding to ADDdouble calculation) + CppAD::ADFun a_F(aa_x, aa_f); + + // 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 + // (corresponding to the tape of adouble operations) + double df_j; + for(j = 0; j < n; j++) + a_df[j] >>= df_j; + trace_off(); + + // compute the d/dx of f'(x) * v = f''(x) * v + size_t m = n; // # dependent in f'(x) + double *v = CPPAD_NULL, *ddf_v = CPPAD_NULL; + v = CPPAD_TRACK_NEW_VEC(m, v); // track v = new double[m] + ddf_v = CPPAD_TRACK_NEW_VEC(n, ddf_v); // track ddf_v = new double[n] + for(j = 0; j < n; j++) + v[j] = double(n - j); + fos_reverse(tag, int(m), int(n), v, ddf_v); + + // f(x) = .5 * ( x[0]^2 + x[1]^2 + ... + x[n-1]^2 ) + // f'(x) = (x[0], x[1], ... , x[n-1]) + // f''(x) * v = ( v[0], v[1], ... , x[n-1] ) + for(j = 0; j < n; j++) + ok &= CppAD::NearEqual(ddf_v[j], v[j], eps99, eps99); + + CPPAD_TRACK_DEL_VEC(v); // check usage of delete + CPPAD_TRACK_DEL_VEC(ddf_v); + return ok; } # endif // CPPAD_HAS_ADOLC bool std_math(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::Independent; - using CppAD::ADFun; - double eps = std::numeric_limits::epsilon(); - - - typedef AD ADdouble; // for first level of taping - typedef AD ADDdouble; // for second level of taping - size_t n = 1; // number independent variables - size_t m = 1; // number dependent and independent variables - - CPPAD_TESTVECTOR(double) x(n), y(m); - CPPAD_TESTVECTOR(ADdouble) ax(n), ay(m); - CPPAD_TESTVECTOR(ADDdouble) aax(n), aay(m); - - // create af(x) = tanh(x) - aax[0] = 1.; - Independent( aax ); - aay[0] = tanh(aax[0]); - ADFun af(aax, aay); - - // create g(x) = af(x) - ax[0] = 1.; - Independent( ax ); - ay = af.Forward(0, ax); - ADFun g(ax, ay); - - // evaluate h(x) = g(x) - x[0] = 1.; - y = g.Forward(0, x); - - // check result - double check = tanh(x[0]); - ok &= CppAD::NearEqual(y[0], check, eps, eps); +{ bool ok = true; + using CppAD::AD; + using CppAD::Independent; + using CppAD::ADFun; + double eps = std::numeric_limits::epsilon(); + + + typedef AD ADdouble; // for first level of taping + typedef AD ADDdouble; // for second level of taping + size_t n = 1; // number independent variables + size_t m = 1; // number dependent and independent variables + + CPPAD_TESTVECTOR(double) x(n), y(m); + CPPAD_TESTVECTOR(ADdouble) ax(n), ay(m); + CPPAD_TESTVECTOR(ADDdouble) aax(n), aay(m); + + // create af(x) = tanh(x) + aax[0] = 1.; + Independent( aax ); + aay[0] = tanh(aax[0]); + ADFun af(aax, aay); + + // create g(x) = af(x) + ax[0] = 1.; + Independent( ax ); + ay = af.Forward(0, ax); + ADFun g(ax, ay); + + // evaluate h(x) = g(x) + x[0] = 1.; + y = g.Forward(0, x); + + // check result + double check = tanh(x[0]); + ok &= CppAD::NearEqual(y[0], check, eps, eps); - return ok; + return ok; } bool fabs(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::Independent; - using CppAD::ADFun; - double eps = std::numeric_limits::epsilon(); - - - typedef AD ADdouble; // for first level of taping - typedef AD ADDdouble; // for second level of taping - size_t n = 1; // number independent variables - size_t m = 1; // number dependent and independent variables - - CPPAD_TESTVECTOR(double) x(n), y(m); - CPPAD_TESTVECTOR(ADdouble) ax(n), ay(m); - CPPAD_TESTVECTOR(ADDdouble) aax(n), aay(m); - - // create af(x) = fabs(x) - aax[0] = 1.; - Independent( aax ); - aay[0] = fabs(aax[0]); - ADFun af(aax, aay); - - // create g(x) = af'(x) - ax[0] = 1.; - Independent( ax ); - ay = af.Jacobian(ax); - ADFun g(ax, ay); - - // evaluate g(x) at same x as recording - x[0] = 1.; - y = g.Forward(0, x); - - // check result - double check = 1.; - ok &= CppAD::NearEqual(y[0], check, eps, eps); - - // evaluate g(x) at different x from recording - // (but abs is an atomic operation so derivative should work) - x[0] = -1.; - y = g.Forward(0, x); - - // check result - check = -1.; - ok &= CppAD::NearEqual(y[0], check, eps, eps); +{ bool ok = true; + using CppAD::AD; + using CppAD::Independent; + using CppAD::ADFun; + double eps = std::numeric_limits::epsilon(); + + + typedef AD ADdouble; // for first level of taping + typedef AD ADDdouble; // for second level of taping + size_t n = 1; // number independent variables + size_t m = 1; // number dependent and independent variables + + CPPAD_TESTVECTOR(double) x(n), y(m); + CPPAD_TESTVECTOR(ADdouble) ax(n), ay(m); + CPPAD_TESTVECTOR(ADDdouble) aax(n), aay(m); + + // create af(x) = fabs(x) + aax[0] = 1.; + Independent( aax ); + aay[0] = fabs(aax[0]); + ADFun af(aax, aay); + + // create g(x) = af'(x) + ax[0] = 1.; + Independent( ax ); + ay = af.Jacobian(ax); + ADFun g(ax, ay); + + // evaluate g(x) at same x as recording + x[0] = 1.; + y = g.Forward(0, x); + + // check result + double check = 1.; + ok &= CppAD::NearEqual(y[0], check, eps, eps); + + // evaluate g(x) at different x from recording + // (but abs is an atomic operation so derivative should work) + x[0] = -1.; + y = g.Forward(0, x); + + // check result + check = -1.; + ok &= CppAD::NearEqual(y[0], check, eps, eps); - return ok; + return ok; } } // END empty namespace bool mul_level(void) -{ bool ok = true; - ok &= One(); - ok &= Two(); +{ bool ok = true; + ok &= One(); + ok &= Two(); # if CPPAD_HAS_ADOLC - ok &= adolc(); + ok &= adolc(); # endif - ok &= std_math(); - ok &= fabs(); + ok &= std_math(); + ok &= fabs(); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/mul_zdouble.cpp cppad-2019.02.00.0/test_more/general/mul_zdouble.cpp --- cppad-2018.00.00.0/test_more/general/mul_zdouble.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/mul_zdouble.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,144 +1,145 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // 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; - } + 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; +{ bool ok = true; - ok &= check_div(); - ok &= check_mul(); - ok &= check_numeric_limits(); + ok &= check_div(); + ok &= check_mul(); + ok &= check_numeric_limits(); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/mul_zero_one.cpp cppad-2019.02.00.0/test_more/general/mul_zero_one.cpp --- cppad-2018.00.00.0/test_more/general/mul_zero_one.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/mul_zero_one.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test the use of the special parameters zero and one with the multiply operator @@ -20,58 +21,58 @@ bool MulZeroOne(void) { - using namespace CppAD; + using namespace CppAD; - bool ok = true; + bool ok = true; - size_t i; - for(i = 0; i < 3; i++) - { // run through the cases x = 0, 1, 2 - - size_t j; - for(j = 0; j < 3; j++) - { // run through the cases y = 0, 1, 2 - - CPPAD_TESTVECTOR( ADdouble ) x(1); - x[0] = double(i); - Independent(x); - - CPPAD_TESTVECTOR( ADDdouble ) y(1); - y[0] = ADDdouble(j); - Independent(y); - - CPPAD_TESTVECTOR( ADDdouble ) z(2); - z[0] = x[0] * y[0]; - z[1] = y[0] * x[0]; - z[1] *= x[0]; - - // f(y) = z = { x * y , y * x * x } - ADFun< ADdouble > f(y, z); - CPPAD_TESTVECTOR( ADdouble ) u( f.Domain() ); - CPPAD_TESTVECTOR( ADdouble ) v( f.Range() ); - - // v = f'(y) - u[0] = ADdouble(1.); - v = f.Forward(1, u); - - // check derivatives of f - ok &= v[0] == x[0]; - ok &= v[1] == x[0] * x[0]; - - // g(x) = f'(y) = {x , x * x} - ADFun g(x, v); - CPPAD_TESTVECTOR( double ) a( g.Domain() ); - CPPAD_TESTVECTOR( double ) b( g.Range() ); - - // b = g'(x) - a[0] = 1.; - b = g.Forward(1, a); - - // check derivatives of g - ok &= (b[0] == 1.); - ok &= (b[1] == 2. * x[0]); - } - } + size_t i; + for(i = 0; i < 3; i++) + { // run through the cases x = 0, 1, 2 + + size_t j; + for(j = 0; j < 3; j++) + { // run through the cases y = 0, 1, 2 + + CPPAD_TESTVECTOR( ADdouble ) x(1); + x[0] = double(i); + Independent(x); + + CPPAD_TESTVECTOR( ADDdouble ) y(1); + y[0] = ADDdouble(j); + Independent(y); + + CPPAD_TESTVECTOR( ADDdouble ) z(2); + z[0] = x[0] * y[0]; + z[1] = y[0] * x[0]; + z[1] *= x[0]; + + // f(y) = z = { x * y , y * x * x } + ADFun< ADdouble > f(y, z); + CPPAD_TESTVECTOR( ADdouble ) u( f.Domain() ); + CPPAD_TESTVECTOR( ADdouble ) v( f.Range() ); + + // v = f'(y) + u[0] = ADdouble(1.); + v = f.Forward(1, u); + + // check derivatives of f + ok &= v[0] == x[0]; + ok &= v[1] == x[0] * x[0]; + + // g(x) = f'(y) = {x , x * x} + ADFun g(x, v); + CPPAD_TESTVECTOR( double ) a( g.Domain() ); + CPPAD_TESTVECTOR( double ) b( g.Range() ); + + // b = g'(x) + a[0] = 1.; + b = g.Forward(1, a); + + // check derivatives of g + ok &= (b[0] == 1.); + ok &= (b[1] == 2. * x[0]); + } + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/near_equal_ext.cpp cppad-2019.02.00.0/test_more/general/near_equal_ext.cpp --- cppad-2018.00.00.0/test_more/general/near_equal_ext.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/near_equal_ext.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old example now just used for validation testing @@ -17,52 +18,52 @@ # include bool NearEqualExt(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - - // double - double x = 1.00000; - double y = 1.00001; - double a = .00005; - double r = .00005; - double zero = 0.; - double inf = 1. / zero; - double nan = 0. / zero; - - // AD - AD X(x); - AD Y(y); - AD Inf(inf); - AD Nan(nan); - - ok &= NearEqual(X, Y, zero, a); - ok &= NearEqual(X, y, zero, a); - ok &= NearEqual(x, Y, zero, a); - - ok &= ! NearEqual(X, Y, zero, a/25.); - ok &= ! NearEqual(X, y, zero, a/25.); - ok &= ! NearEqual(x, Y, zero, a/25.); - - ok &= NearEqual(X, Y, r, zero); - ok &= NearEqual(X, y, r, zero); - ok &= NearEqual(x, Y, r, zero); - - ok &= ! NearEqual(X, Y, r/25., zero); - ok &= ! NearEqual(X, y, r/25., zero); - ok &= ! NearEqual(x, Y, r/25., zero); - - ok &= ! NearEqual(Inf, Inf, r, a); - ok &= ! NearEqual(Inf, inf, r, a); - ok &= ! NearEqual(inf, Inf, r, a); - - ok &= ! NearEqual(-Inf, -Inf, r, a); - ok &= ! NearEqual(-Inf, -inf, r, a); - ok &= ! NearEqual(-inf, -Inf, r, a); - - ok &= ! NearEqual(Nan, Nan, r, a); - ok &= ! NearEqual(Nan, nan, r, a); - ok &= ! NearEqual(nan, Nan, r, a); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + + // double + double x = 1.00000; + double y = 1.00001; + double a = .00005; + double r = .00005; + double zero = 0.; + double inf = 1. / zero; + double nan = 0. / zero; + + // AD + AD X(x); + AD Y(y); + AD Inf(inf); + AD Nan(nan); + + ok &= NearEqual(X, Y, zero, a); + ok &= NearEqual(X, y, zero, a); + ok &= NearEqual(x, Y, zero, a); + + ok &= ! NearEqual(X, Y, zero, a/25.); + ok &= ! NearEqual(X, y, zero, a/25.); + ok &= ! NearEqual(x, Y, zero, a/25.); + + ok &= NearEqual(X, Y, r, zero); + ok &= NearEqual(X, y, r, zero); + ok &= NearEqual(x, Y, r, zero); + + ok &= ! NearEqual(X, Y, r/25., zero); + ok &= ! NearEqual(X, y, r/25., zero); + ok &= ! NearEqual(x, Y, r/25., zero); + + ok &= ! NearEqual(Inf, Inf, r, a); + ok &= ! NearEqual(Inf, inf, r, a); + ok &= ! NearEqual(inf, Inf, r, a); + + ok &= ! NearEqual(-Inf, -Inf, r, a); + ok &= ! NearEqual(-Inf, -inf, r, a); + ok &= ! NearEqual(-inf, -Inf, r, a); + + ok &= ! NearEqual(Nan, Nan, r, a); + ok &= ! NearEqual(Nan, nan, r, a); + ok &= ! NearEqual(nan, Nan, r, a); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/neg.cpp cppad-2019.02.00.0/test_more/general/neg.cpp --- cppad-2018.00.00.0/test_more/general/neg.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/neg.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* old example and test now only used for testing @@ -17,52 +18,52 @@ # include bool Neg(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(2); - size_t s = 0; - size_t t = 1; - U[s] = 3.; - U[t] = 4.; - Independent(U); - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(1); - size_t x = 0; - - // dependent variable values - Z[x] = - U[t]; // - AD - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // check values - ok &= ( Z[x] == -4. ); - - // forward computation of partials w.r.t. s - v[s] = 1.; - v[t] = 0.; - w = f.Forward(1, v); - ok &= ( w[x] == 0. ); // dx/ds - - // forward computation of partials w.r.t. t - v[s] = 0.; - v[t] = 1.; - w = f.Forward(1, v); - ok &= ( w[x] == -1. ); // dx/dt - - // reverse computation of second partials of z - CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); - w[x] = 1.; - 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) + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(2); + size_t s = 0; + size_t t = 1; + U[s] = 3.; + U[t] = 4.; + Independent(U); + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(1); + size_t x = 0; + + // dependent variable values + Z[x] = - U[t]; // - AD + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // check values + ok &= ( Z[x] == -4. ); + + // forward computation of partials w.r.t. s + v[s] = 1.; + v[t] = 0.; + w = f.Forward(1, v); + ok &= ( w[x] == 0. ); // dx/ds + + // forward computation of partials w.r.t. t + v[s] = 0.; + v[t] = 1.; + w = f.Forward(1, v); + ok &= ( w[x] == -1. ); // dx/dt + + // reverse computation of second partials of z + CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); + w[x] = 1.; + 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/new_dynamic.cpp cppad-2019.02.00.0/test_more/general/new_dynamic.cpp --- cppad-2018.00.00.0/test_more/general/new_dynamic.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/new_dynamic.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,792 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +# include +# include + +namespace { // BEGIN_EMPTY_NAMESPACE + +// ---------------------------------------------------------------------------- +bool operator_with_variable(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + using CppAD::azmul; + using CppAD::CondExpLt; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + size_t n = 11; + + // dynamic parameter vector + CPPAD_TESTVECTOR(AD) adynamic(n); + for(size_t j = 0; j < n; ++j) + adynamic[j] = 2.0; + + // domain space vector + CPPAD_TESTVECTOR(AD) ax(n); + for(size_t j = 0; j < n; ++j) + ax[j] = AD(j + 1); + + // declare independent variables, dynamic parammeters, starting recording + size_t abort_op_index = 0; + bool record_compare = true; + CppAD::Independent(ax, abort_op_index, record_compare, adynamic); + + // range space vector + CPPAD_TESTVECTOR(AD) ay(n); + size_t k = 0; + ay[k] = -1.0*double(k+1)*(adynamic[k] + ax[k]) * (ax[k] + adynamic[k]); + ++k; + ay[k] = -1.0*double(k+1)*(adynamic[k] - ax[k]) * (ax[k] - adynamic[k]); + ++k; + ay[k] = -1.0*double(k+1)*(adynamic[k] * ax[k]) + (ax[k] * adynamic[k]); + ++k; + ay[k] = -1.0*double(k+1)*(adynamic[k] / ax[k]) + (ax[k] / adynamic[k]); + ++k; + ay[k] = ax[k]; + ay[k] += adynamic[k]; + ++k; + ay[k] = adynamic[k]; + ay[k] -= ax[k]; + ++k; + ay[k] = ax[k]; + ay[k] *= adynamic[k]; + ++k; + ay[k] = adynamic[k]; + ay[k] /= ax[k]; + ++k; + ay[k] = pow(ax[k], adynamic[k]) + pow(adynamic[k], ax[k]); + ++k; + ay[k] = azmul(ax[k], adynamic[k]) + azmul(adynamic[k], ax[k]); + ++k; + ay[k] = CondExpLt(ax[k], adynamic[k], ax[k], adynamic[k]); + ++k; + ok &= size_t(k) == n; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // zero order forward mode + CPPAD_TESTVECTOR(double) x(n), y(n); + for(size_t j = 0; j < n; ++j) + x[j] = double(j + 1); + y = f.Forward(0, x); + double check; + k = 0; + check = ( Value(adynamic[k]) + x[k] ) * ( x[k] + Value(adynamic[k]) ); + check *= -1.0*double(k+1); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = ( Value(adynamic[k]) - x[k] ) * ( x[k] - Value(adynamic[k]) ); + check *= -1.0*double(k+1); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = -1.0*double(k+1)*( Value(adynamic[k]) * x[k] ); + check += ( x[k] * Value(adynamic[k]) ); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = -1.0*double(k+1)*( Value(adynamic[k]) / x[k] ); + check += ( x[k] / Value(adynamic[k]) ); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = x[k] + Value(adynamic[k]); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = Value(adynamic[k]) - x[k]; + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = x[k] * Value(adynamic[k]); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = Value(adynamic[k]) / x[k]; + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = std::pow(x[k], Value(adynamic[k])); + check += std::pow(Value(adynamic[k]), x[k]); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = azmul(x[k], Value(adynamic[k])) + azmul(Value(adynamic[k]), x[k]); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = CondExpLt( x[k], Value(adynamic[k]), x[k], Value(adynamic[k]) ); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + ok &= size_t(k) == n; + + // change the dynamic parameter values + CPPAD_TESTVECTOR(double) dynamic(n); + for(size_t j = 0; j < n; j++) + dynamic[j] = double(2 * j + 1); + f.new_dynamic(dynamic); + // + y = f.Forward(0, x); + k = 0; + check = -1.0*double(k+1)*( dynamic[k] + x[k] ) * ( x[k] + dynamic[k] ); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = -1.0*double(k+1)*( dynamic[k] - x[k] ) * ( x[k] - dynamic[k] ); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = -1.0*double(k+1)*( dynamic[k] * x[k] ) + ( x[k] * dynamic[k] ); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = -1.0*double(k+1)*( dynamic[k] / x[k] ) + ( x[k] / dynamic[k] ); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = x[k] + dynamic[k]; + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = dynamic[k] - x[k]; + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = x[k] * dynamic[k]; + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = dynamic[k] / x[k]; + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = std::pow(x[k], dynamic[k]); + check += std::pow(dynamic[k], x[k]); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = azmul(x[k], dynamic[k]) + CppAD::azmul(dynamic[k], x[k]); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + check = CondExpLt(x[k], dynamic[k], x[k], dynamic[k]); + ok &= NearEqual(y[k] , check, eps99, eps99); + ++k; + ok &= size_t(k) == n; + // + return ok; +} +// ---------------------------------------------------------------------------- +bool dynamic_operator(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + using CppAD::azmul; + using CppAD::sign; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent dynamic parameter vector + size_t nd = 1; + CPPAD_TESTVECTOR(AD) adynamic(nd); + adynamic[0] = 0.5; + + // domain space vector + size_t nx = 1; + CPPAD_TESTVECTOR(AD) ax(nx); + ax[0] = 0.25; + + // declare independent variables, dynamic parammeters, starting recording + size_t abort_op_index = 0; + bool record_compare = true; + CppAD::Independent(ax, abort_op_index, record_compare, adynamic); + + // range space vector + size_t ny = 27; +# if CPPAD_USE_CPLUSPLUS_2011 + ny += 6; +# endif + CPPAD_TESTVECTOR(AD) ay(ny); + size_t k = 0; + // ---------------------------------------------------------- + // 98 standard math + ay[k] = acos(adynamic[0]); + ++k; + ay[k] = asin(adynamic[0]); + ++k; + ay[k] = atan(adynamic[0]); + ++k; + ay[k] = cos(adynamic[0]); + ++k; + ay[k] = cosh(adynamic[0]); + ++k; + ay[k] = exp(adynamic[0]); + ++k; + ay[k] = acos(adynamic[0]); + ++k; + ay[k] = log(adynamic[0]); + ++k; + ay[k] = sin(adynamic[0]); + ++k; + ay[k] = sinh(adynamic[0]); + ++k; + ay[k] = sqrt(adynamic[0]); + ++k; + ay[k] = tan(adynamic[0]); + ++k; + ay[k] = tanh(adynamic[0]); + ++k; + // ---------------------------------------------------------- + // 2011 standard math +# if CPPAD_USE_CPLUSPLUS_2011 + ay[k] = asinh(adynamic[0]); + ++k; + ay[k] = acosh(adynamic[0] + 1.0); + ++k; + ay[k] = atanh(adynamic[0]); + ++k; + ay[k] = expm1(adynamic[0]); + ++k; + ay[k] = erf(adynamic[0]); + ++k; + ay[k] = log1p(adynamic[0]); + ++k; +# endif + // ---------------------------------------------------------- + // binary + ay[k] = 2.0 + adynamic[0]; + ++k; + ay[k] = 2.0; + ay[k] += adynamic[0]; // constant += dynamic + ++k; + ay[k] = adynamic[0] / 2.0; + ++k; + ay[k] = adynamic[0]; + ay[k] /= 2.0; // dynamic /= constant + ++k; + ay[k] = 2.0 * adynamic[0]; + ++k; + ay[k] = 2.0; + ay[k] *= adynamic[0]; // constant *= dynamic + ++k; + ay[k] = adynamic[0] - 2.0; + ++k; + ay[k] = adynamic[0]; + ay[k] -= 2.0; // dynamic -= constant + ++k; + // ---------------------------------------------------------- + // other + ay[k] = - adynamic[0]; + ++k; + ay[k] = fabs(adynamic[0]); + ++k; + ay[k] = pow(adynamic[0], 2.0); + ++k; + ay[k] = sign(adynamic[0]); + ++k; + ay[k] = azmul(2.0, adynamic[0]); + ++k; + // if dynamic[0] == 0.5 then ay[k] = 1.0 else ay[k] = -1.0 + ay[k] = CppAD::CondExpEq( + adynamic[0], AD(0.5), AD(1.0), AD(-1.0) + ); + ++k; + // ---------------------------------------------------------- + ok &= size_t(k) == ny; + + // create f: x -> y and stop tape recording + CppAD::ADFun f(ax, ay); + + // change the dynamic parameter values + CPPAD_TESTVECTOR(double) dynamic(nd); + dynamic[0] = 0.75; + f.new_dynamic(dynamic); + // + CPPAD_TESTVECTOR(double) x(nx), y(ny); + y = f.Forward(0, x); + k = 0; + // ---------------------------------------------------------- + // 98 standard math + double check = std::acos(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::asin(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::atan(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::cos(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::cosh(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::exp(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::acos(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::log(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::sin(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::sinh(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::sqrt(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::tan(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::tanh(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + // ---------------------------------------------------------- + // 2011 standard math +# if CPPAD_USE_CPLUSPLUS_2011 + check = asinh(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::acosh(dynamic[0] + 1.0); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::atanh(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::expm1(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::erf(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::log1p(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; +# endif + // ---------------------------------------------------------- + // binary + check = 2.0 + dynamic[0]; + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = dynamic[0] / 2.0; + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = 2.0 * dynamic[0]; + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = dynamic[0] - 2.0; + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + // ---------------------------------------------------------- + // other + check = - dynamic[0]; + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::fabs(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = std::pow(dynamic[0], 2.0); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = CppAD::sign(dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + check = azmul(2.0, dynamic[0]); + ok &= NearEqual(y[k], check, eps99, eps99); + ++k; + // if dynamic[0] == 0.5 then ay[k] = 1.0 else ay[k] = -1.0 + check = CppAD::CondExpEq(dynamic[0], 0.5, 1.0, -1.0); + ++k; + // ---------------------------------------------------------- + ok &= k == ny; + // + return ok; +} +// ---------------------------------------------------------------------------- +bool dynamic_compare(void) +{ bool ok = true; + using CppAD::AD; + + // independent dynamic parameter vector + size_t nd = 1; + CPPAD_TESTVECTOR(AD) adynamic(nd); + + // domain space vector + size_t nx = 1; + CPPAD_TESTVECTOR(AD) ax(nx); + ax[0] = 0.0; // value does not matter for this example; + + // range space vector + size_t ny = 2; + CPPAD_TESTVECTOR(AD) ay(ny); + + // not using abort_op_index, are recording compare operators + size_t abort_op_index = 0; + bool record_compare = true; + + // Function object + CppAD::ADFun f; + + // vectors used for new_dynamic and Forward. + CPPAD_TESTVECTOR(double) dynamic(nd), x(nx), y(ny); + + // ---------------------------------------------------------- + // operators: ==, != + adynamic[0] = 0.5; + CppAD::Independent(ax, abort_op_index, record_compare, adynamic); + // + // == + if( adynamic[0] == 0.5 ) + ay[0] = 1.0; + else + ay[0] = 0.0; + // + // != + if( adynamic[0] != 0.5 ) + ay[1] = 1.0; + else + ay[1] = 0.0; + + // create f: x -> y and stop tape recording + f.Dependent(ax, ay); + // + dynamic[0] = Value( adynamic[0] ); + f.new_dynamic(dynamic); + y = f.Forward(0, x); + ok = f.compare_change_number() == 0; + // + dynamic[0] = 1.0; + f.new_dynamic(dynamic); + y = f.Forward(0, x); + ok = f.compare_change_number() == 2; + + // ---------------------------------------------------------- + // operators: <, <= + adynamic[0] = 0.5; + CppAD::Independent(ax, abort_op_index, record_compare, adynamic); + // + // < + if( adynamic[0] < 0.5 ) + ay[0] = 0.0; + else + ay[0] = 1.0; + // + // <= + if( adynamic[0] <= 0.5 ) + ay[1] = 1.0; + else + ay[1] = 0.0; + + // create f: x -> y and stop tape recording + f.Dependent(ax, ay); + // + dynamic[0] = Value( adynamic[0] ); + f.new_dynamic(dynamic); + y = f.Forward(0, x); + ok = f.compare_change_number() == 0; + // + dynamic[0] = 1.0; + f.new_dynamic(dynamic); + y = f.Forward(0, x); + ok = f.compare_change_number() == 1; + + // ---------------------------------------------------------- + // operators: >, >= + adynamic[0] = 0.5; + CppAD::Independent(ax, abort_op_index, record_compare, adynamic); + // + // > + if( adynamic[0] > 0.4 ) + ay[0] = 1.0; + else + ay[0] = 0.0; + // + // >= + if( adynamic[0] >= 0.4 ) + ay[1] = 1.0; + else + ay[1] = 0.0; + + // create f: x -> y and stop tape recording + f.Dependent(ax, ay); + // + dynamic[0] = Value( adynamic[0] ); + f.new_dynamic(dynamic); + y = f.Forward(0, x); + ok = f.compare_change_number() == 0; + // + dynamic[0] = 0.3; + f.new_dynamic(dynamic); + y = f.Forward(0, x); + ok = f.compare_change_number() == 2; + // + // ---------------------------------------------------------- + return ok; +} +// ---------------------------------------------------------------------------- +bool optimize_csum(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent dynamic parameter vector + size_t num_dyn_ind = 2; + CPPAD_TESTVECTOR(AD) adynamic(num_dyn_ind); + + // domain space vector + size_t nx = 1; + CPPAD_TESTVECTOR(AD) ax(nx); + ax[0] = 0.0; // value does not matter for this example; + + // range space vector + size_t ny = 2; + CPPAD_TESTVECTOR(AD) ay(ny); + + // not using abort_op_index, are recording compare operators + size_t abort_op_index = 0; + bool record_compare = true; + + // Function object + CppAD::ADFun f; + // ---------------------------------------------------------- + // record f + adynamic[0] = 1.0; + adynamic[1] = 2.0; + CppAD::Independent(ax, abort_op_index, record_compare, adynamic); + // + // create three constant parameters that are only used in a cumulative + // summation and will be optimized to just one constant parameter + ay[0] = 3.0 - ax[0]; + ay[0] = ay[0] - 4.0; + ay[0] = ay[0] + 5.0; + // + // create a dependent dynamic parameter that is not used + AD adp1 = adynamic[0] + adynamic[1]; + // + // create a dependent dynamic parameter that is used + AD adp2 = adynamic[1] - adynamic[0]; + ay[1] = ax[0] + adp2; + // + // create f: x -> y and stop tape recording + f.Dependent(ax, ay); + ok &= f.size_dyn_ind() == num_dyn_ind; + ok &= f.size_dyn_par() == num_dyn_ind + 2; + // note that there is one phantom parameter at index zero that is not used + ok &= f.size_par() == num_dyn_ind + 2 + 4; + // ------------------------------------------------------------- + // vectors used for new_dynamic and Forward. + CPPAD_TESTVECTOR(double) dynamic(num_dyn_ind), x(nx), y(ny); + dynamic[0] = 3.0; + dynamic[1] = 4.0; + f.new_dynamic(dynamic); + x[0] = 5.0; + y = f.Forward(0, x); + double check = 3.0 - x[0] - 4.0 + 5.0; + ok &= NearEqual(y[0], check, eps99, eps99); + check = x[0] + dynamic[1] - dynamic[0]; + ok &= NearEqual(y[1], check, eps99, eps99); + // ------------------------------------------------------------- + // optimize and re-test + f.optimize(); + ok &= f.size_dyn_ind() == num_dyn_ind; + ok &= f.size_dyn_par() == num_dyn_ind + 1; + ok &= f.size_par() == num_dyn_ind + 1 + 2; + dynamic[0] = 0.3; + dynamic[1] = 0.4; + f.new_dynamic(dynamic); + x[0] = 0.5; + y = f.Forward(0, x); + check = 3.0 - x[0] - 4.0 + 5.0; + ok &= NearEqual(y[0], check, eps99, eps99); + check = x[0] + dynamic[1] - dynamic[0]; + ok &= NearEqual(y[1], check, eps99, eps99); + // + return ok; +} + +// ---------------------------------------------------------------------------- +typedef CPPAD_TESTVECTOR( CppAD::AD ) ADvector; +void g_algo(const ADvector& ax, ADvector& ay) +{ ay[0] = ax[0] * ax[1]; +} +bool dynamic_atomic(void) +{ bool ok = true; + + // checkpoint version of g(x) = x[0] * x[1]; + ADvector ax(2), ay(1); + ax[0] = 2.0; + ax[1] = 3.0; + CppAD::checkpoint atom_g("g_algo", g_algo, ax, ay); + + // record the function f(x) = dynamic[0] * dynamic[1] + // using atom_g to compute the product + ADvector adynamic(2); + adynamic[0] = 1.0; + adynamic[1] = 2.0; + size_t abort_op_index = 0; + size_t record_compare = true; + Independent(ax, abort_op_index, record_compare, adynamic); + atom_g(adynamic, ay); + CppAD::ADFun f(ax, ay); + + // change the dynamic parameter values + CPPAD_TESTVECTOR(double) x(2), y(1), dynamic(2); + dynamic[0] = 4.0; + dynamic[1] = 5.0; + f.new_dynamic(dynamic); + + // check zero order forward + x[0] = std::numeric_limits::quiet_NaN(); + x[1] = std::numeric_limits::quiet_NaN(); + y = f.Forward(0, x); + ok &= y[0] == dynamic[0] * dynamic[1]; + + + return ok; +} + +// ---------------------------------------------------------------------------- +double n_digits(const double& x) +{ double logx = std::log10(x); + double ret = floor(logx) + 1.0; + return ret; +} +CPPAD_DISCRETE_FUNCTION(double, n_digits) +// +bool dynamic_discrete(void) +{ bool ok = true; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // record the function f(x) = x[0] * n_digits( dynamic[0] ) + ADvector ax(1); + ax[0] = 2.0; + ADvector adynamic(1); + adynamic[0] = 3.0; + size_t abort_op_index = 0; + size_t record_compare = true; + Independent(ax, abort_op_index, record_compare, adynamic); + ADvector ay(1); + ay[0] = ax[0] * n_digits( adynamic[0] ); + CppAD::ADFun f(ax, ay); + + // change the dynamic parameter value to 14 + CPPAD_TESTVECTOR(double) x(1), y(1), dynamic(1); + dynamic[0] = 14.0; + f.new_dynamic(dynamic); + + // check zero order forward + x[0] = 3.0; + y = f.Forward(0, x); + ok &= CppAD::NearEqual(y[0], x[0] * 2.0, eps99, eps99); + + return ok; +} +// ---------------------------------------------------------------------------- +bool dynamic_optimize(void) +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent dynamic parameter vector + size_t nd = 1; + CPPAD_TESTVECTOR(AD) adynamic(nd); + + // domain space vector + size_t nx = 1; + CPPAD_TESTVECTOR(AD) ax(nx); + ax[0] = 0.0; // value does not matter for this example; + + // range space vector + size_t ny = 2; + CPPAD_TESTVECTOR(AD) ay(ny); + + // not using abort_op_index, are recording compare operators + size_t abort_op_index = 0; + bool record_compare = true; + + // Function object + CppAD::ADFun f; + // ---------------------------------------------------------- + // record f + adynamic[0] = 1.0; + CppAD::Independent(ax, abort_op_index, record_compare, adynamic); + // + // Avoid cumulative summations because it adds constant parameters. + // Use one constant parameter, namely 3.0. + // Create five dynamic parameters where the second, fourth, and fifth, + // should be optimized out. + // + // first extra dynamic parameter (also is in optimized tape) + AD first = 3.0 + adynamic[0]; + // + // second that is the same as first because addition is communative + AD second = adynamic[0] + 3.0; + // + // third extra dynamic parameter (also in optimized tape) + AD third = first * first; + // + // fourth is same as third and uses second which gets optimized out + AD fourth = second * second; + // + // fifth is not used and so should be optimized out + AD fifth = first / 3.0; + // + ay[0] = ax[0] + third; + ay[1] = ax[0] * fourth; + // + // create f: x -> y and stop tape recording + f.Dependent(ax, ay); + ok &= f.size_dyn_ind() == nd; + ok &= f.size_dyn_par() == nd + 5; + // note that there is a phantom parameter at index zero that is not used + ok &= f.size_par() == nd + 5 + 2; // one constant parameter 3.0 + // ------------------------------------------------------------- + // vectors used for new_dynamic and Forward. + CPPAD_TESTVECTOR(double) dynamic(nd), x(nx), y(ny); + dynamic[0] = 4.0; + f.new_dynamic(dynamic); + x[0] = 5.0; + y = f.Forward(0, x); + double check = x[0] + (3.0 + dynamic[0] ) * (3.0 + dynamic[0]); + ok &= NearEqual(y[0], check, eps99, eps99); + check = x[0] * (3.0 + dynamic[0] ) * (3.0 + dynamic[0]); + ok &= NearEqual(y[1], check, eps99, eps99); + // ------------------------------------------------------------- + // optimize and re-test + f.optimize(); + ok &= f.size_dyn_ind() == nd; + ok &= f.size_dyn_par() == nd + 2; + ok &= f.size_par() == nd + 2 + 2; + dynamic[0] = 6.0; + f.new_dynamic(dynamic); + y = f.Forward(0, x); + check = x[0] + (3.0 + dynamic[0]) * (3.0 + dynamic[0]); + ok &= NearEqual(y[0], check, eps99, eps99); + check = x[0] * (3.0 + dynamic[0]) * (3.0 + dynamic[0]); + ok &= NearEqual(y[1], check, eps99, eps99); + // + return ok; +} + + +} // END_EMPTY_NAMESPACE + +// ---------------------------------------------------------------------------- +bool new_dynamic(void) +{ bool ok = true; + // + ok &= operator_with_variable(); + ok &= dynamic_operator(); + ok &= dynamic_compare(); + ok &= optimize_csum(); + ok &= dynamic_atomic(); + ok &= dynamic_discrete(); + ok &= dynamic_optimize(); + // + return ok; +} diff -Nru cppad-2018.00.00.0/test_more/general/num_limits.cpp cppad-2019.02.00.0/test_more/general/num_limits.cpp --- cppad-2018.00.00.0/test_more/general/num_limits.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/num_limits.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* old num_limits.cpp example / test @@ -42,8 +43,8 @@ # 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 +// 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 @@ -53,147 +54,147 @@ # include "extern_value.hpp" namespace { - using CppAD::vector; - using CppAD::abs_geq; + 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; - } + 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; +{ 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 > >(); + // ------------------------------------------------------------------- + // 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; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/ode_err_control.cpp cppad-2019.02.00.0/test_more/general/ode_err_control.cpp --- cppad-2018.00.00.0/test_more/general/ode_err_control.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/ode_err_control.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include // for size_t # include // for exp @@ -22,92 +23,92 @@ */ namespace { - // -------------------------------------------------------------- - class Fun_one { - private: - size_t n; // dimension of the state space - 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, - CppAD::vector &f) - { size_t i; - f[0] = 1.; - for(i = 1; i < n; i++) - f[i] = double(i+1) * x[i-1]; - } - }; - - // -------------------------------------------------------------- - class Method_one { - private: - Fun_one F; - public: - // constructor - Method_one(size_t n_) : F(n_) - { } - void step( - double ta, - double tb, - CppAD::vector &xa , - CppAD::vector &xb , - CppAD::vector &eb ) - { xb = CppAD::Runge45(F, 1, ta, tb, xa, eb); - } - size_t order(void) - { return 4; } - }; + // -------------------------------------------------------------- + class Fun_one { + private: + size_t n; // dimension of the state space + 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, + CppAD::vector &f) + { size_t i; + f[0] = 1.; + for(i = 1; i < n; i++) + f[i] = double(i+1) * x[i-1]; + } + }; + + // -------------------------------------------------------------- + class Method_one { + private: + Fun_one F; + public: + // constructor + Method_one(size_t n_) : F(n_) + { } + void step( + double ta, + double tb, + CppAD::vector &xa , + CppAD::vector &xb , + CppAD::vector &eb ) + { xb = CppAD::Runge45(F, 1, ta, tb, xa, eb); + } + size_t order(void) + { return 4; } + }; } bool OdeErrControl_one(void) -{ bool ok = true; // initial return value +{ bool ok = true; // initial return value - using CppAD::NearEqual; + using CppAD::NearEqual; - // Runge45 should yield exact results for x_i (t) = t^(i+1), i < 4 - size_t n = 6; + // Runge45 should yield exact results for x_i (t) = t^(i+1), i < 4 + size_t n = 6; - // construct method for n component solution - Method_one method(n); + // construct method for n component solution + Method_one method(n); - // inputs to OdeErrControl + // inputs to OdeErrControl - double ti = 0.; - double tf = .9; - double smin = 1e-2; - double smax = 1.; - double scur = .5; - double erel = 1e-7; + double ti = 0.; + double tf = .9; + double smin = 1e-2; + double smax = 1.; + double scur = .5; + double erel = 1e-7; - CppAD::vector xi(n); - CppAD::vector eabs(n); - size_t i; - for(i = 0; i < n; i++) - { xi[i] = 0.; - eabs[i] = 0.; - } + CppAD::vector xi(n); + CppAD::vector eabs(n); + size_t i; + for(i = 0; i < n; i++) + { xi[i] = 0.; + eabs[i] = 0.; + } - // outputs from OdeErrControl + // outputs from OdeErrControl - CppAD::vector ef(n); - CppAD::vector xf(n); + CppAD::vector ef(n); + CppAD::vector xf(n); - xf = OdeErrControl(method, - ti, tf, xi, smin, smax, scur, eabs, erel, ef); + xf = OdeErrControl(method, + ti, tf, xi, smin, smax, scur, eabs, erel, ef); - double check = 1.; - for(i = 0; i < n; i++) - { check *= tf; - ok &= NearEqual(check, xf[i], erel, 0.); - } + double check = 1.; + for(i = 0; i < n; i++) + { check *= tf; + ok &= NearEqual(check, xf[i], erel, 0.); + } - return ok; + return ok; } /* @@ -123,107 +124,107 @@ It follows that $latex X_0 (0) = 1$$, $latex X_1 (0) = 0$$ and $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_0^{(1)} (t) & = & - w_0 X_0 (t) \\ + X_1^{(1)} (t) & = & + w_0 X_0 (t) - w_1 X_1 (t) \end{array} \] $$ */ namespace { - // -------------------------------------------------------------- - class Fun_two { - private: - CppAD::vector w; - public: - // constructor - Fun_two(const CppAD::vector &w_) : w(w_) - { } - - // set f = x'(t) - void Ode( - 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]; - } - }; - - // -------------------------------------------------------------- - class Method_two { - private: - Fun_two F; - public: - // constructor - Method_two(const CppAD::vector &w_) : F(w_) - { } - void step( - double ta, - double tb, - CppAD::vector &xa , - CppAD::vector &xb , - CppAD::vector &eb ) - { xb = CppAD::Runge45(F, 1, ta, tb, xa, eb); - } - size_t order(void) - { return 4; } - }; + // -------------------------------------------------------------- + class Fun_two { + private: + CppAD::vector w; + public: + // constructor + Fun_two(const CppAD::vector &w_) : w(w_) + { } + + // set f = x'(t) + void Ode( + 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]; + } + }; + + // -------------------------------------------------------------- + class Method_two { + private: + Fun_two F; + public: + // constructor + Method_two(const CppAD::vector &w_) : F(w_) + { } + void step( + double ta, + double tb, + CppAD::vector &xa , + CppAD::vector &xb , + CppAD::vector &eb ) + { xb = CppAD::Runge45(F, 1, ta, tb, xa, eb); + } + size_t order(void) + { return 4; } + }; } bool OdeErrControl_two(void) -{ bool ok = true; // initial return value - using CppAD::NearEqual; +{ bool ok = true; // initial return value + using CppAD::NearEqual; - CppAD::vector w(2); - w[0] = 10.; - w[1] = 1.; - Method_two method(w); - - CppAD::vector xi(2); - xi[0] = 1.; - xi[1] = 0.; - - CppAD::vector eabs(2); - eabs[0] = 1e-4; - eabs[1] = 1e-4; - - // inputs - double ti = 0.; - double tf = 1.; - double smin = 1e-4; - double smax = 1.; - double scur = .5; - double erel = 0.; - - // outputs - CppAD::vector ef(2); - CppAD::vector xf(2); - CppAD::vector maxabs(2); - size_t nstep; - - - xf = OdeErrControl(method, - ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); - - double x0 = exp(-w[0]*tf); - ok &= NearEqual(x0, xf[0], 1e-4, 1e-4); - ok &= NearEqual(0., ef[0], 1e-4, 1e-4); - - double x1 = w[0] * (exp(-w[0]*tf) - exp(-w[1]*tf))/(w[1] - w[0]); - ok &= NearEqual(x1, xf[1], 1e-4, 1e-4); - ok &= NearEqual(0., ef[1], 1e-4, 1e-4); + CppAD::vector w(2); + w[0] = 10.; + w[1] = 1.; + Method_two method(w); + + CppAD::vector xi(2); + xi[0] = 1.; + xi[1] = 0.; + + CppAD::vector eabs(2); + eabs[0] = 1e-4; + eabs[1] = 1e-4; + + // inputs + double ti = 0.; + double tf = 1.; + double smin = 1e-4; + double smax = 1.; + double scur = .5; + double erel = 0.; + + // outputs + CppAD::vector ef(2); + CppAD::vector xf(2); + CppAD::vector maxabs(2); + size_t nstep; + + + xf = OdeErrControl(method, + ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); + + double x0 = exp(-w[0]*tf); + ok &= NearEqual(x0, xf[0], 1e-4, 1e-4); + ok &= NearEqual(0., ef[0], 1e-4, 1e-4); + + double x1 = w[0] * (exp(-w[0]*tf) - exp(-w[1]*tf))/(w[1] - w[0]); + ok &= NearEqual(x1, xf[1], 1e-4, 1e-4); + ok &= NearEqual(0., ef[1], 1e-4, 1e-4); - return ok; + return ok; } /* Define $latex X : \B{R} \rightarrow \B{R}^2$$ by $latex \[ \begin{array}{rcl} - X_0 (0) & = & 1 \\ - X_1 (0) & = & 0 \\ - X_0^{(1)} (t) & = & 2 \alpha t X_0 (t) \\ - X_1^{(1)} (t) & = & 1 / X_0 (t) + X_0 (0) & = & 1 \\ + X_1 (0) & = & 0 \\ + X_0^{(1)} (t) & = & 2 \alpha t X_0 (t) \\ + X_1^{(1)} (t) & = & 1 / X_0 (t) \end{array} \] $$ It follows that @@ -247,225 +248,225 @@ # include namespace { - // -------------------------------------------------------------- - class Fun_three { - private: - const double alpha_; - bool was_negative_; - public: - // constructor - Fun_three(double alpha) : alpha_(alpha), was_negative_(false) - { } - - // set f = x'(t) - void Ode( - const double &t, - const CppAD::vector &x, - CppAD::vector &f) - { f[0] = 2. * alpha_ * t * x[0]; - f[1] = 1. / x[0]; - // case where ODE does not make sense - if( x[0] < 0. || x[1] < 0. ) - { was_negative_ = true; - f[0] = CppAD::nan(0.); - } - } - // set f_t = df / dt - void Ode_ind( - const double &t, - const CppAD::vector &x, - CppAD::vector &f_t) - { - f_t[0] = 2. * alpha_ * x[0]; - f_t[1] = 0.; - if( x[0] < 0. || x[1] < 0. ) - { was_negative_ = true; - f_t[0] = CppAD::nan(0.); - } - } - // set f_x = df / dx - void Ode_dep( - 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 - f_x[0 * 2 + 1] = 0.; // f0 w.r.t. x1 - f_x[1 * 2 + 0] = -1./x0_sq; // f1 w.r.t. x0 - f_x[1 * 2 + 1] = 0.; // f1 w.r.t. x1 - if( x[0] < 0. || x[1] < 0. ) - { was_negative_ = true; - f_x[0] = CppAD::nan(0.); - } - } - bool was_negative(void) - { return was_negative_; } - - }; - - // -------------------------------------------------------------- - class Method_three { - public: - Fun_three F; - - // constructor - Method_three(double alpha) : F(alpha) - { } - void step( - double ta, - double tb, - CppAD::vector &xa , - CppAD::vector &xb , - CppAD::vector &eb ) - { xb = CppAD::Rosen34(F, 1, ta, tb, xa, eb); - } - size_t order(void) - { return 3; } - }; + // -------------------------------------------------------------- + class Fun_three { + private: + const double alpha_; + bool was_negative_; + public: + // constructor + Fun_three(double alpha) : alpha_(alpha), was_negative_(false) + { } + + // set f = x'(t) + void Ode( + const double &t, + const CppAD::vector &x, + CppAD::vector &f) + { f[0] = 2. * alpha_ * t * x[0]; + f[1] = 1. / x[0]; + // case where ODE does not make sense + if( x[0] < 0. || x[1] < 0. ) + { was_negative_ = true; + f[0] = CppAD::nan(0.); + } + } + // set f_t = df / dt + void Ode_ind( + const double &t, + const CppAD::vector &x, + CppAD::vector &f_t) + { + f_t[0] = 2. * alpha_ * x[0]; + f_t[1] = 0.; + if( x[0] < 0. || x[1] < 0. ) + { was_negative_ = true; + f_t[0] = CppAD::nan(0.); + } + } + // set f_x = df / dx + void Ode_dep( + 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 + f_x[0 * 2 + 1] = 0.; // f0 w.r.t. x1 + f_x[1 * 2 + 0] = -1./x0_sq; // f1 w.r.t. x0 + f_x[1 * 2 + 1] = 0.; // f1 w.r.t. x1 + if( x[0] < 0. || x[1] < 0. ) + { was_negative_ = true; + f_x[0] = CppAD::nan(0.); + } + } + bool was_negative(void) + { return was_negative_; } + + }; + + // -------------------------------------------------------------- + class Method_three { + public: + Fun_three F; + + // constructor + Method_three(double alpha) : F(alpha) + { } + void step( + double ta, + double tb, + CppAD::vector &xa , + CppAD::vector &xb , + CppAD::vector &eb ) + { xb = CppAD::Rosen34(F, 1, ta, tb, xa, eb); + } + size_t order(void) + { return 3; } + }; } bool OdeErrControl_three(void) -{ bool ok = true; // initial return value - using CppAD::NearEqual; +{ bool ok = true; // initial return value + using CppAD::NearEqual; - double alpha = 10.; - Method_three method(alpha); + double alpha = 10.; + Method_three method(alpha); - CppAD::vector xi(2); - xi[0] = 1.; - xi[1] = 0.; + CppAD::vector xi(2); + xi[0] = 1.; + xi[1] = 0.; - CppAD::vector eabs(2); - eabs[0] = 1e-4; - eabs[1] = 1e-4; + CppAD::vector eabs(2); + eabs[0] = 1e-4; + eabs[1] = 1e-4; - // inputs - double ti = 0.; - double tf = 1.; - double smin = 1e-4; - double smax = 1.; - double scur = 1.; - double erel = 0.; + // inputs + double ti = 0.; + double tf = 1.; + double smin = 1e-4; + double smax = 1.; + double scur = 1.; + double erel = 0.; - // outputs - CppAD::vector ef(2); - CppAD::vector xf(2); - CppAD::vector maxabs(2); - size_t nstep; + // outputs + CppAD::vector ef(2); + CppAD::vector xf(2); + CppAD::vector maxabs(2); + size_t nstep; - xf = OdeErrControl(method, - ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); + xf = OdeErrControl(method, + ti, tf, xi, smin, smax, scur, eabs, erel, ef, maxabs, nstep); - double x0 = exp( alpha * tf * tf ); - ok &= NearEqual(x0, xf[0], 1e-4, 1e-4); - ok &= NearEqual(0., ef[0], 1e-4, 1e-4); + double x0 = exp( alpha * tf * tf ); + ok &= NearEqual(x0, xf[0], 1e-4, 1e-4); + ok &= NearEqual(0., ef[0], 1e-4, 1e-4); - double root_pi = sqrt( 4. * atan(1.)); - double root_alpha = sqrt( alpha ); - double x1 = CppAD::erf(alpha * tf) * root_pi / (2 * root_alpha); - ok &= NearEqual(x1, xf[1], 1e-4, 1e-4); - ok &= NearEqual(0., ef[1], 1e-4, 1e-4); + double root_pi = sqrt( 4. * atan(1.)); + double root_alpha = sqrt( alpha ); + double x1 = CppAD::erf(alpha * tf) * root_pi / (2 * root_alpha); + ok &= NearEqual(x1, xf[1], 1e-4, 1e-4); + ok &= NearEqual(0., ef[1], 1e-4, 1e-4); - ok &= method.F.was_negative(); + ok &= method.F.was_negative(); - return ok; + return ok; } namespace { - // -------------------------------------------------------------- - class Fun_four { - private: - size_t n; // dimension of the state space - 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, - CppAD::vector &f) - { size_t i; - f[0] = CppAD::nan(0.); - for(i = 1; i < n; i++) - f[i] = double(i+1) * x[i-1]; - } - }; - - // -------------------------------------------------------------- - class Method_four { - private: - Fun_four F; - public: - // constructor - Method_four(size_t n_) : F(n_) - { } - void step( - double ta, - double tb, - CppAD::vector &xa , - CppAD::vector &xb , - CppAD::vector &eb ) - { xb = CppAD::Runge45(F, 1, ta, tb, xa, eb); - } - size_t order(void) - { return 4; } - }; + // -------------------------------------------------------------- + class Fun_four { + private: + size_t n; // dimension of the state space + 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, + CppAD::vector &f) + { size_t i; + f[0] = CppAD::nan(0.); + for(i = 1; i < n; i++) + f[i] = double(i+1) * x[i-1]; + } + }; + + // -------------------------------------------------------------- + class Method_four { + private: + Fun_four F; + public: + // constructor + Method_four(size_t n_) : F(n_) + { } + void step( + double ta, + double tb, + CppAD::vector &xa , + CppAD::vector &xb , + CppAD::vector &eb ) + { xb = CppAD::Runge45(F, 1, ta, tb, xa, eb); + } + size_t order(void) + { return 4; } + }; } bool OdeErrControl_four(void) -{ bool ok = true; // initial return value +{ bool ok = true; // initial return value - // construct method for n component solution - size_t n = 6; - Method_four method(n); - - // inputs to OdeErrControl - - // special case where scur is converted to ti - tf - // (so it is not equal to smin) - double ti = 0.; - double tf = .9; - double smin = .8; - double smax = 1.; - double scur = smin; - double erel = 1e-7; - - CppAD::vector xi(n); - CppAD::vector eabs(n); - size_t i; - for(i = 0; i < n; i++) - { xi[i] = 0.; - eabs[i] = 0.; - } - - // outputs from OdeErrControl - CppAD::vector ef(n); - CppAD::vector xf(n); - - xf = OdeErrControl(method, - ti, tf, xi, smin, smax, scur, eabs, erel, ef); - - // check that Fun_four always returning nan results in nan - for(i = 0; i < n; i++) - { ok &= CppAD::isnan(xf[i]); - ok &= CppAD::isnan(ef[i]); - } + // construct method for n component solution + size_t n = 6; + Method_four method(n); + + // inputs to OdeErrControl + + // special case where scur is converted to ti - tf + // (so it is not equal to smin) + double ti = 0.; + double tf = .9; + double smin = .8; + double smax = 1.; + double scur = smin; + double erel = 1e-7; + + CppAD::vector xi(n); + CppAD::vector eabs(n); + size_t i; + for(i = 0; i < n; i++) + { xi[i] = 0.; + eabs[i] = 0.; + } + + // outputs from OdeErrControl + CppAD::vector ef(n); + CppAD::vector xf(n); + + xf = OdeErrControl(method, + ti, tf, xi, smin, smax, scur, eabs, erel, ef); + + // check that Fun_four always returning nan results in nan + for(i = 0; i < n; i++) + { ok &= CppAD::isnan(xf[i]); + ok &= CppAD::isnan(ef[i]); + } - return ok; + return ok; } // ========================================================================== bool ode_err_control(void) -{ bool ok = true; - ok &= OdeErrControl_one(); - ok &= OdeErrControl_two(); - ok &= OdeErrControl_three(); - ok &= OdeErrControl_four(); - return ok; +{ bool ok = true; + ok &= OdeErrControl_one(); + ok &= OdeErrControl_two(); + ok &= OdeErrControl_three(); + ok &= OdeErrControl_four(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/optimize.cpp cppad-2019.02.00.0/test_more/general/optimize.cpp --- cppad-2018.00.00.0/test_more/general/optimize.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/optimize.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,2109 +1,2169 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ -// 2DO: Test that optimize.hpp use of base_atomic::rev_sparse_jac works. +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ +// 2DO: Test that optimize.hpp use of atomic_base::rev_sparse_jac works. # include # include namespace { - // include conditional skip optimization - bool conditional_skip_; + // include conditional skip optimization + bool conditional_skip_; - // accuracy for almost equal checks - using CppAD::NearEqual; + // accuracy for almost equal checks + 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_; - // ---------------------------------------------------------------- - class ode_evaluate_fun { - public: - // 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_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 CppAD::AD& t, - const CppAD::vector< CppAD::AD >& y, - CppAD::vector< CppAD::AD >& f) - { size_t n = y.size(); - f[0] = 0.; - for(size_t k = 1; k < n; k++) - f[k] = y[k-1]; - } - }; - bool optimize_ode(void) - { bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - using CppAD::vector; - - // independent variable vector - size_t n = 2; - vector< AD > ax(n); - for(size_t j = 0; j < n; j++) - ax[j] = AD(j+1); - Independent(ax); - - // function that defines the ode - ode_evaluate_fun F; - - // initial and final time - AD ati = 0.0; - AD atf = 0.5; - - // initial value for y(x, t); i.e. y(x, 0) - // (is a reference to x) - size_t m = n; - vector< AD > ayi = ax; - - // final value for y(x, t); i.e., y(x, 1) - vector< AD > ayf(m); - - // Use one fourth order Runge-Kutta step to solve ODE - size_t M = 1; - ayf = CppAD::Runge45(F, M, ati, atf, ayi); - - // function f(x) = y(x, tf) - CppAD::ADFun f(ax, ayf); - - // optimize f(x) - f.optimize(); - - // compute f'(x) - vector x(n), jac(m * n); - for(size_t j = 0; j < n; j++) - x[j] = double(j+1); - jac = f.Jacobian(x); - - - // check f'(x) - double tj = 1.0; - for(size_t j = 0; j < n; j++) - { for(size_t i = j; i < m; i++) - ok &= CppAD::NearEqual( tj , jac[ i * n * j], eps10, eps10); - tj *= Value( atf - ati ); - } - return ok; - } - // ---------------------------------------------------------------- - // Test nested conditional expressions. - bool nested_cond_exp(void) - { bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - using CppAD::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 - 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++) - { x[0] = 1.0 - double(i); - x[1] = - x[0]; - y = f.Forward(0, x); - // - // first conditional expression - double c1; - if( x[0] <= x[1] ) - c1 = 2.0 * x[0]; - else c1 = 3.0 * x[1]; - // - // second conditional expression - double c2; - 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 &= NearEqual(y[0], c3, eps10, eps10); - } - return ok; - } - // ---------------------------------------------------------------- - // 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( - 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::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - 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 - 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++) - 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_ ); - 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 &= NearEqual(y[0], x[0] + double(3) * x[1], eps10, eps10); - - - // 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 &= NearEqual(y[0], x[0] + double(4) * x[1], eps10, eps10); - - return ok; - } - // ------------------------------------------------------------------- - // Test conditional optimizing out call to an atomic function call - void k_algo( - const CppAD::vector< CppAD::AD >& x , - CppAD::vector< CppAD::AD >& y ) - { y[0] = x[0] + x[1]; } - - void h_algo( - const CppAD::vector< CppAD::AD >& x , - CppAD::vector< CppAD::AD >& y ) - { y[0] = x[0] - x[1]; } - - bool atomic_cond_exp(void) - { bool ok = true; - typedef CppAD::vector< CppAD::AD > ADVector; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - // Create a checkpoint version of the function g - ADVector ax(2), ag(1), ah(1), ay(1); - ax[0] = 0.; - ax[1] = 1.; - CppAD::checkpoint k_check("k_check", k_algo, ax, ag); - CppAD::checkpoint h_check("h_check", h_algo, ax, ah); - - // independent variable vector - Independent(ax); - - // atomic function calls that get conditionally used - k_check(ax, ag); - h_check(ax, ah); - - // conditional expression - 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); - x[0] = 3.; - x[1] = 4.; - y = f.Forward(0, x); - ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); - - // before optimize - k_check.option( atomic_sparsity_option_ ); - h_check.option( atomic_sparsity_option_ ); - ok &= f.number_skip() == 0; - - // now optimize the operation sequence - if( conditional_skip_ ) - f.optimize(); - else - f.optimize("no_conditional_skip"); - - // optimized zero order forward when condition is false - x[0] = 4.; - x[1] = 3.; - y = f.Forward(0, x); - ok &= NearEqual(y[0], x[0] - x[1], eps10, eps10); - - // after optimize can skip either call to g or call to h - ok &= f.number_skip() == 1; - - // optimized first order forward - dx[0] = 2.; - dx[1] = 1.; - dy = f.Forward(1, dx); - ok &= NearEqual(dy[0], dx[0] - dx[1], eps10, eps10); - - // optimized first order reverse - w[0] = 1.; - dx = f.Reverse(1, w); - ok &= NearEqual(dx[0], 1., eps10, eps10); - ok &= NearEqual(dx[1], -1., eps10, eps10); - - return ok; - } - // ------------------------------------------------------------------- - // Test of optimizing out arguments to an atomic function - void g_algo( - const CppAD::vector< CppAD::AD >& ax , - CppAD::vector< CppAD::AD >& ay ) - { ay = ax; } - - bool atomic_no_used(void) - { bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - 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(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]); - - // 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_ ); - if( conditional_skip_ ) - f.optimize(); - else - f.optimize("no_conditional_skip"); - - // 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 &= NearEqual(z[0], x[0] - x[1], eps10, eps10); - - return ok; - } - bool atomic_arguments(void) - { bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - using CppAD::vector; - vector< AD > au(2), aw(2), ax(2), ay(1); - - // create atomic function corresponding to g_algo - au[0] = 1.0; - au[1] = 2.0; - CppAD::checkpoint g_check("g_algo", g_algo, au, ax); - - // start recording a new function - CppAD::Independent(ax); - - // now use g_check during the recording - au[0] = ax[0] + ax[1]; // this argument requires a new variable - 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 - 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_ ); - if( conditional_skip_ ) - f.optimize(); - else - f.optimize("no_conditional_skip"); - - // check difference in number of variables - size_t n_after = f.size_var(); - ok &= n_before == n_after + 1; - - // now compute and check a forward mode calculation - vector x(2), y(1); - x[0] = 5.0; - x[1] = 6.0; - y = f.Forward(0, x); - ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); - - return ok; - } - - // ------------------------------------------------------------------- - // Test the reverse dependency analysis optimization - template - void depend_fun - (const Vector& x, Vector& y, size_t& original, size_t& opt) - { typedef typename Vector::value_type Scalar; - 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] - // (note that sin corresponds to two tape variables) - not_used = fabs(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 - 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 - not_used = 2. - not_used; - y[2] = 3. / x[2]; - original += 2; - opt += 1; - - // binary operator where both operands are variables - not_used = x[3] - not_used; - y[3] = x[3] / x[2]; - original += 2; - opt += 1; - - // 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; - - // 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. - 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; - } - - bool depend_one(void) - { // Test all except for VecAD operations - bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - 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); - - // declare independent variables and start tape recording - CppAD::Independent(X); - - // 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); - - 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 &= NearEqual(y[i], check[i], eps10, eps10); - - // Check size before optimization - ok &= F.size_var() == original; - - // Optimize the operation sequence - if( conditional_skip_ ) - F.optimize(); - else - F.optimize("no_conditional_skip"); - - // Check size after optimization - 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 &= NearEqual(y[i], check[i], eps10, eps10); - - return ok; - } - - bool depend_two(void) - { // Test VecAD operations - bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - size_t i, j; - - // domain space vector - size_t n = 2; - CppAD::vector< AD > X(n); - for(j = 0; j < n; j++) - X[j] = double(j); - - // range space vector - size_t m = 3; - CppAD::vector< AD > Y(m); - - CppAD::VecAD U(m); - CppAD::VecAD V(n); - for(i = 0; i < m; i++) - U[i] = 0; - for(j = 0; j < n; j++) - V[j] = 0; - - // declare independent variables and start tape recording - CppAD::Independent(X); - - // first vecad vector that is a variable - U[ X[0] ] = X[1]; - - // second vecad vector that is a variable - V[ X[0] ] = X[1]; - - // Make dependency for vecad vectors different that for - // variables because original code used worng dependency info. - // Y does not depend on the first variable in the tape; i.e. - // the one corresponding to the BeginOp. So make it depend - // on the first vecad vector in the tape. - for(i = 0; i < m; i++) - { 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. - CppAD::ADFun F; - F.Dependent(X, Y); - - // Check number of VecAD vectors plus number of VecAD elements - ok &= (F.size_VecAD() == 2 + n + m); - - CppAD::vector x(n), y(m); - for(j = 0; j < n; j++) - x[j] = double(j); - - y = F.Forward(0, x); - for(i = 0; i < m; i++) - { if( i != static_cast(x[0]) ) - ok &= NearEqual(y[i], 0., eps10, eps10); - else ok &= NearEqual(y[i], x[1], eps10, eps10); - } - - 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); - y = F.Forward(0, x); - for(i = 0; i < m; i++) - { if( i != static_cast(x[0]) ) - ok &= NearEqual(y[i], 0., eps10, eps10); - else ok &= NearEqual(y[i], x[1], eps10, eps10); - } - - return ok; - } - bool depend_three(void) - { // Power function is a special case for optimize - bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - using CppAD::vector; - - size_t n = 3; - size_t j; - - vector< AD > 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); - 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 - // have been stored as double and gaurd bits have been dropped. - // (This may not be true for some compiler in the future). - for(j = 0; j < n; j++) - ok &= NearEqual(y[j], Value(Y[j]), eps10, eps10); - - // check reverse mode derivative - vector w(n), dw(n); - w[0] = 0.; - w[1] = 0.; - w[2] = 1.; - dw = F.Reverse(1, w); - - double check = x[1] * pow( x[0], x[1] - 1. ); - ok &= NearEqual( dw[0], check, eps10, eps10 ); - - check = log( x[0] ) * pow( x[0], x[1] ); - ok &= NearEqual( dw[1], check, eps10, eps10 ); - - check = 0.; - ok &= NearEqual( dw[2], check, eps10, eps10 ); - - return ok; - } - bool depend_four(void) - { // erf function is a special case for optimize - bool ok = true; + // note this enum type is not part of the API (but its values are) + CppAD::atomic_base::option_enum atomic_sparsity_option_; + // ---------------------------------------------------------------- + class ode_evaluate_fun { + public: + // 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_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 CppAD::AD& t, + const CppAD::vector< CppAD::AD >& y, + CppAD::vector< CppAD::AD >& f) + { size_t n = y.size(); + f[0] = 0.; + for(size_t k = 1; k < n; k++) + f[k] = y[k-1]; + } + }; + bool optimize_ode(void) + { bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + using CppAD::vector; + + // independent variable vector + size_t n = 2; + vector< AD > ax(n); + for(size_t j = 0; j < n; j++) + ax[j] = AD(j+1); + Independent(ax); + + // function that defines the ode + ode_evaluate_fun F; + + // initial and final time + AD ati = 0.0; + AD atf = 0.5; + + // initial value for y(x, t); i.e. y(x, 0) + // (is a reference to x) + size_t m = n; + vector< AD > ayi = ax; + + // final value for y(x, t); i.e., y(x, 1) + vector< AD > ayf(m); + + // Use one fourth order Runge-Kutta step to solve ODE + size_t M = 1; + ayf = CppAD::Runge45(F, M, ati, atf, ayi); + + // function f(x) = y(x, tf) + CppAD::ADFun f(ax, ayf); + + // optimize f(x) + f.optimize(); + + // compute f'(x) + vector x(n), jac(m * n); + for(size_t j = 0; j < n; j++) + x[j] = double(j+1); + jac = f.Jacobian(x); + + + // check f'(x) + double tj = 1.0; + for(size_t j = 0; j < n; j++) + { for(size_t i = j; i < m; i++) + ok &= CppAD::NearEqual( tj , jac[ i * n * j], eps10, eps10); + tj *= Value( atf - ati ); + } + return ok; + } + // ---------------------------------------------------------------- + // Test nested conditional expressions. + bool nested_cond_exp(void) + { bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + using CppAD::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 + 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++) + { x[0] = 1.0 - double(i); + x[1] = - x[0]; + y = f.Forward(0, x); + // + // first conditional expression + double c1; + if( x[0] <= x[1] ) + c1 = 2.0 * x[0]; + else + c1 = 3.0 * x[1]; + // + // second conditional expression + double c2; + 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 &= NearEqual(y[0], c3, eps10, eps10); + } + return ok; + } + // ---------------------------------------------------------------- + // 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( + 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::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + 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 + 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++) + 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_ ); + 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 &= NearEqual(y[0], x[0] + double(3) * x[1], eps10, eps10); + + + // 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 &= NearEqual(y[0], x[0] + double(4) * x[1], eps10, eps10); + + return ok; + } + // ------------------------------------------------------------------- + // Test conditional optimizing out call to an atomic function call + void k_algo( + const CppAD::vector< CppAD::AD >& x , + CppAD::vector< CppAD::AD >& y ) + { y[0] = x[0] + x[1]; } + + void h_algo( + const CppAD::vector< CppAD::AD >& x , + CppAD::vector< CppAD::AD >& y ) + { y[0] = x[0] - x[1]; } + + bool atomic_cond_exp(void) + { bool ok = true; + typedef CppAD::vector< CppAD::AD > ADVector; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // Create a checkpoint version of the function g + ADVector ax(2), ag(1), ah(1), ay(1); + ax[0] = 0.; + ax[1] = 1.; + CppAD::checkpoint k_check("k_check", k_algo, ax, ag); + CppAD::checkpoint h_check("h_check", h_algo, ax, ah); + + // independent variable vector + Independent(ax); + + // atomic function calls that get conditionally used + k_check(ax, ag); + h_check(ax, ah); + + // conditional expression + 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); + x[0] = 3.; + x[1] = 4.; + y = f.Forward(0, x); + ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); + + // before optimize + k_check.option( atomic_sparsity_option_ ); + h_check.option( atomic_sparsity_option_ ); + ok &= f.number_skip() == 0; + + // now optimize the operation sequence + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + + // optimized zero order forward when condition is false + x[0] = 4.; + x[1] = 3.; + y = f.Forward(0, x); + ok &= NearEqual(y[0], x[0] - x[1], eps10, eps10); + + // after optimize can skip either call to g or call to h + ok &= f.number_skip() == 1; + + // optimized first order forward + dx[0] = 2.; + dx[1] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], dx[0] - dx[1], eps10, eps10); + + // optimized first order reverse + w[0] = 1.; + dx = f.Reverse(1, w); + ok &= NearEqual(dx[0], 1., eps10, eps10); + ok &= NearEqual(dx[1], -1., eps10, eps10); + + return ok; + } + // ------------------------------------------------------------------- + // Test of optimizing out arguments to an atomic function + void g_algo( + const CppAD::vector< CppAD::AD >& ax , + CppAD::vector< CppAD::AD >& ay ) + { ay = ax; } + + bool atomic_no_used(void) + { bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + 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(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]); + + // 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_ ); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + + // 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 &= NearEqual(z[0], x[0] - x[1], eps10, eps10); + + return ok; + } + bool atomic_arguments(void) + { bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + using CppAD::vector; + vector< AD > au(2), aw(2), ax(2), ay(1); + + // create atomic function corresponding to g_algo + au[0] = 1.0; + au[1] = 2.0; + CppAD::checkpoint g_check("g_algo", g_algo, au, ax); + + // start recording a new function + CppAD::Independent(ax); + + // now use g_check during the recording + au[0] = ax[0] + ax[1]; // this argument requires a new variable + 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 + ay[0] = aw[0]; + CppAD::ADFun f(ax, ay); + + // number of variables before optimization + size_t n_before = f.size_var(); + // ax[0], ax[1], ax[0] + ax[1]. ax[0] - ax[1], g[0], g[1] + // and phantom variable at index 0 + ok &= n_before == 7; + + // now optimize f so that the calculation of au[1] is removed + g_check.option( atomic_sparsity_option_ ); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + + // number of variables after optimization + size_t n_after = f.size_var(); + // ax[0], ax[1], ax[0] + ax[1]. g[0] + // and phantom variable at index 0 + ok &= n_after == 5; + + // now compute and check a forward mode calculation + vector x(2), y(1); + x[0] = 5.0; + x[1] = 6.0; + y = f.Forward(0, x); + ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); + + return ok; + } + + // ------------------------------------------------------------------- + // Test the reverse dependency analysis optimization + template + void depend_fun + (const Vector& x, Vector& y, size_t& original, size_t& opt) + { typedef typename Vector::value_type Scalar; + 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] + // (note that sin corresponds to two tape variables) + not_used = fabs(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 + 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 + not_used = 2. - not_used; + y[2] = 3. / x[2]; + original += 2; + opt += 1; + + // binary operator where both operands are variables + not_used = x[3] - not_used; + y[3] = x[3] / x[2]; + original += 2; + opt += 1; + + // 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; + + // 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. + 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; + } + + bool depend_one(void) + { // Test all except for VecAD operations + bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + 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); + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // 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); + + 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 &= NearEqual(y[i], check[i], eps10, eps10); + + // Check size before optimization + ok &= F.size_var() == original; + + // Optimize the operation sequence + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); + + // Check size after optimization + 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 &= NearEqual(y[i], check[i], eps10, eps10); + + return ok; + } + + bool depend_two(void) + { // Test VecAD operations + bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + size_t i, j; + + // domain space vector + size_t n = 2; + CppAD::vector< AD > X(n); + for(j = 0; j < n; j++) + X[j] = double(j); + + // range space vector + size_t m = 3; + CppAD::vector< AD > Y(m); + + CppAD::VecAD U(m); + CppAD::VecAD V(n); + for(i = 0; i < m; i++) + U[i] = 0; + for(j = 0; j < n; j++) + V[j] = 0; + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // first vecad vector that is a variable + U[ X[0] ] = X[1]; + + // second vecad vector that is a variable + V[ X[0] ] = X[1]; + + // Make dependency for vecad vectors different that for + // variables because original code used worng dependency info. + // Y does not depend on the first variable in the tape; i.e. + // the one corresponding to the BeginOp. So make it depend + // on the first vecad vector in the tape. + for(i = 0; i < m; i++) + { 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. + CppAD::ADFun F; + F.Dependent(X, Y); + + // Check number of VecAD vectors plus number of VecAD elements + ok &= (F.size_VecAD() == 2 + n + m); + + CppAD::vector x(n), y(m); + for(j = 0; j < n; j++) + x[j] = double(j); + + y = F.Forward(0, x); + for(i = 0; i < m; i++) + { if( i != static_cast(x[0]) ) + ok &= NearEqual(y[i], 0., eps10, eps10); + else + ok &= NearEqual(y[i], x[1], eps10, eps10); + } + + 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); + y = F.Forward(0, x); + for(i = 0; i < m; i++) + { if( i != static_cast(x[0]) ) + ok &= NearEqual(y[i], 0., eps10, eps10); + else + ok &= NearEqual(y[i], x[1], eps10, eps10); + } + + return ok; + } + bool depend_three(void) + { // Power function is a special case for optimize + bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + using CppAD::vector; + + size_t n = 3; + size_t j; + + vector< AD > 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); + 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 + // have been stored as double and gaurd bits have been dropped. + // (This may not be true for some compiler in the future). + for(j = 0; j < n; j++) + ok &= NearEqual(y[j], Value(Y[j]), eps10, eps10); + + // check reverse mode derivative + vector w(n), dw(n); + w[0] = 0.; + w[1] = 0.; + w[2] = 1.; + dw = F.Reverse(1, w); + + double check = x[1] * pow( x[0], x[1] - 1. ); + ok &= NearEqual( dw[0], check, eps10, eps10 ); + + check = log( x[0] ) * pow( x[0], x[1] ); + ok &= NearEqual( dw[1], check, eps10, eps10 ); + + check = 0.; + ok &= NearEqual( dw[2], check, eps10, eps10 ); + + return ok; + } + bool depend_four(void) + { // erf function is a special case for optimize + bool ok = true; # if CPPAD_USE_CPLUSPLUS_2011 - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - using CppAD::vector; - - size_t n = 1; - size_t m = 1; - vector< AD > X(n), Y(m); - vector x(n); - X[0] = x[0] = double(0.5); - - CppAD::Independent(X); - - Y[0] = erf(X[0]) + erf(X[0]); - - CppAD::ADFun F(X, Y); - - vector y_original = F.Forward(0, x); - size_t size_original = F.size_var(); - 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 &= NearEqual(y[0], y_original[0], eps10, eps10); + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + using CppAD::vector; + + size_t n = 1; + size_t m = 1; + vector< AD > X(n), Y(m); + vector x(n); + X[0] = x[0] = double(0.5); + + CppAD::Independent(X); + + Y[0] = erf(X[0]) + erf(X[0]); + + CppAD::ADFun F(X, Y); + + vector y_original = F.Forward(0, x); + size_t size_original = F.size_var(); + 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 &= NearEqual(y[0], y_original[0], eps10, eps10); # endif - return ok; - } - // =================================================================== - // Test duplicate operation analysis - - template - void duplicate_fun - (const Vector& x, Vector& y, size_t& original, size_t& opt) - { typedef typename Vector::value_type Scalar; - original = 0; - opt = 0; - - // unary operator where operand is arg[0] and one result - Scalar a1 = CppAD::exp(x[0]); - original += 1; - opt += 1; - - // unary operator where operand is arg[0] and two results - Scalar b1 = CppAD::sin(x[1]); - original += 2; - opt += 2; - - // non-commutative binary operator where left is a variable - // and right is a parameter - Scalar c1 = x[2] - 3.; - original += 1; - opt += 1; - - // non-commutative binary operator where left is a parameter - // and right is a variable - Scalar d1 = 3. / x[3]; - original += 1; - opt += 1; - - // non-commutative binary operator where left is a variable - // and right is a variable - Scalar e1 = pow(x[3], x[4]); - original += 3; - opt += 3; - - // commutative binary operator where left is a variable - // and right is a parameter - Scalar f1 = x[5] * 5.; - original += 1; - opt += 1; - - // commutative binary operator where left is a variable - // and right is a variable - Scalar g1 = x[5] + x[6]; - original += 1; - opt += 1; - - // duplicate variables - Scalar a2 = CppAD::exp(x[0]); - Scalar b2 = CppAD::sin(x[1]); // counts for 2 variables - Scalar c2 = x[2] - 3.; - Scalar d2 = 3. / x[3]; - Scalar e2 = pow(x[3], x[4]); // counts for 3 variables - Scalar f2 = 5. * x[5]; - Scalar g2 = x[6] + x[5]; - original += 10; - - // result vector - y[0] = a1 * a2; - y[1] = b1 * b2; - y[2] = c1 * c2; - y[3] = d1 * d2; - y[4] = e1 * e2; - y[5] = f1 * f2; - y[6] = g1 * g2; - original += 7; - opt += 7; - - return; - } - bool duplicate_one(void) - { - bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - 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); - - // declare independent variables and start tape recording - CppAD::Independent(X); - - // 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); - - 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 &= NearEqual(y[i], check[i], eps10, eps10); - - // Check size before optimization - ok &= F.size_var() == (n + 1 + original); - - // Optimize the operation sequence - 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 &= NearEqual(y[i], check[i], eps10, eps10); - - return ok; - } - // ------------------------------------------------------------------- - bool duplicate_two(void) - { // test that duplicate expression removal is relative to - // new and not just old argument indices. - bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - size_t i, j; - - // domain space vector - size_t n = 1; - CppAD::vector< AD > X(n); - for(j = 0; j < n; j++) - X[j] = double(j + 2); - - // range space vector - size_t m = 1; - CppAD::vector< AD > Y(m); - - // declare independent variables and start tape recording - CppAD::Independent(X); - - // create a new variable - AD A1 = X[0] - 2.; - - // create a duplicate variable - AD A2 = X[0] - 2.; - - // create a new variable using first version of duplicate - AD B1 = A1 / 2.; - - // create a duplicate that can only be dectected using new - // argument indices - AD B2 = A2 / 2.; - - // 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); - - // check number of variables in original function - 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); - - y = F.Forward(0, x); - for(i = 0; i < m; i++) - ok &= NearEqual(y[i], Value(Y[i]), eps10, eps10); - - 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 ); - - y = F.Forward(0, x); - for(i = 0; i < m; i++) - ok &= NearEqual(y[i], Value(Y[i]), eps10, eps10); - - return ok; - } - // ------------------------------------------------------------------- - bool duplicate_three(void) - { // test that duplicate expression removal is relative to - // new and not just old argument indices (commutative case). - bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - size_t i, j; - - // domain space vector - size_t n = 1; - CppAD::vector< AD > X(n); - for(j = 0; j < n; j++) - X[j] = double(j + 2); - - // range space vector - size_t m = 1; - CppAD::vector< AD > Y(m); - - // declare independent variables and start tape recording - CppAD::Independent(X); - - // create a new variable - AD A1 = X[0] + 2.; - - // create a duplicate variable - AD A2 = 2. + X[0]; - - // create a new variable using first version of duplicate - AD B1 = A1 * 2.; - - // create a duplicate that can only be dectected using new - // argument indices - AD B2 = 2. * A2; - - // 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); - - // check number of variables in original function - 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); - - y = F.Forward(0, x); - for(i = 0; i < m; i++) - ok &= NearEqual(y[i], Value(Y[i]), eps10, eps10); - - 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 ); - - y = F.Forward(0, x); - for(i = 0; i < m; i++) - ok &= NearEqual(y[i], Value(Y[i]), eps10, eps10); - - return ok; - } - // ------------------------------------------------------------------- - bool duplicate_four(void) - { // Check that unary expression matching not only checks hash code, - // and operator, but also operand (old bug that has been fixed). - bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - size_t j; - - // domain space vector - size_t n = 1; - CppAD::vector< AD > X(n); - X[0] = 1.; - - // range space vector - size_t m = 1; - CppAD::vector< AD > Y(m); - - // declare independent variables and start tape recording - CppAD::Independent(X); - - // 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 - ); - Y[0] = X[0]; - for(j = 0; j < n_operations; j++) - Y[0] = fabs(Y[0]); - - // create f: X -> Y and stop tape recording - CppAD::ADFun F; - F.Dependent(X, Y); - - // check number of variables in original function - ok &= (F.size_var() == 1 + n + n_operations ); - - CppAD::vector x(n), y(m); - x[0] = 1.; - - y = F.Forward(0, x); - ok &= NearEqual(y[0], Value(Y[0]), eps10, eps10); - - 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 ); - - y = F.Forward(0, x); - ok &= NearEqual(y[0], Value(Y[0]), eps10, eps10); - - return ok; - } - // ==================================================================== - bool cummulative_sum(void) - { // test conversion of a sequence of additions and subtraction - // to a cummulative summation sequence. - bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - size_t i, j; - - // domain space vector - size_t n = 7; - CppAD::vector< AD > X(n); - for(j = 0; j < n; j++) - X[j] = double(j + 2); - - size_t n_original = 1 + n; - size_t n_optimize = 1 + n; - - // range space vector - size_t m = 2; - CppAD::vector< AD > Y(m); - - // declare independent variables and start tape recording - CppAD::Independent(X); - - // Operations inside of optimize_cadd - Y[0] = 5. + (X[0] + X[1]) + (X[1] - X[2]) // Addvv, Subvv - + (X[2] - 1.) + (2. - X[3]) // Subvp, Subpv - + (X[4] + 3.) + (4. + X[5]); // Addpv, Addpv (no Addvp) - n_original += 12; - n_optimize += 1; - - - // Operations inside of optimize_csub - Y[1] = 5. - (X[1] + X[2]) - (X[2] - X[3]) // Addvv, Subvv - - (X[3] - 1.) - (2. - X[4]) // Subvp, Subpv - - (X[5] + 3.) - (4. + X[6]); // Addpv, Addpv (no Addvp) - n_original += 12; - n_optimize += 1; - - CppAD::ADFun F; - F.Dependent(X, Y); - - // check number of variables in original function - ok &= (F.size_var() == n_original ); - - CppAD::vector x(n), y(m); - for(j = 0; j < n; j++) - x[j] = double(j + 2); - - y = F.Forward(0, x); - for(i = 0; i < m; i++) - ok &= NearEqual(y[i], Value(Y[i]), eps10, eps10); - - if( conditional_skip_ ) - F.optimize(); - else - F.optimize("no_conditional_skip"); - - // check number of variables in optimized version - ok &= (F.size_var() == n_optimize ); - - y = F.Forward(0, x); - for(i = 0; i < m; i++) - ok &= NearEqual(y[i], Value(Y[i]), eps10, eps10); - - return ok; - } - // ------------------------------------------------------------------- - bool forward_csum(void) - { bool ok = true; - - using namespace CppAD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CppAD::vector< AD > X(2); - 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 - 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], eps10, eps10); - - // 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], eps10, eps10); - - // evaluate second derivative of F in X[0] direction - CppAD::vector x2( F.Domain() ); - CppAD::vector y2( F.Range() ); - x2[0] = 0.; - x2[1] = 0.; - y2 = F.Forward(2, x2); - double F_00 = 2. * y2[0]; - ok &= NearEqual(F_00, 0., eps10, eps10); - - return ok; - } - // ------------------------------------------------------------------- - bool reverse_csum(void) - { bool ok = true; - - using namespace CppAD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CppAD::vector< AD > X(2); - 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 - 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], eps10, eps10); - - // 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., eps10, eps10); - ok &= NearEqual(dF[1] , 1., eps10, eps10); - - return ok; - } - bool forward_sparse_jacobian() - { bool ok = true; - using namespace CppAD; - - // dimension of the domain space - size_t n = 3; - - // dimension of the range space - size_t m = 3; - - // independent variable vector - CppAD::vector< AD > X(n); - 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[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[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] - // 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 - // so the optimizer can know it affects the results. - 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); - if( conditional_skip_ ) - F.optimize(); - else - F.optimize("no_conditional_skip"); - - // --------------------------------------------------------- - // 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++) - { for(j = 0; j < n; j++) - { 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; - - // dimension of the range space - size_t m = 3; - - // independent variable vector - CppAD::vector< AD > X(n); - 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[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[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[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); - if( conditional_skip_ ) - F.optimize(); - else - F.optimize("no_conditional_skip"); - - // ---------------------------------------------------------- - // dependency matrix for the identity function - CppAD::vector< bool > Py(m * m); - size_t i, j; - for(i = 0; i < m; i++) - { 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); - 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], - 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] - check[0 * n + 2] = false; // x[0], x[2] - - check[1 * n + 0] = false; // partial w.r.t. x[1], x[0] - check[1 * n + 1] = true; // x[1], x[1] - check[1 * n + 2] = true; // x[1], x[2] - - 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); - 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) ) - CppAD::vector Py(m); - CppAD::vector Pxx(n * n); - Py[0] = true; - Pxx = F.RevSparseHes(n, Py); - // check values - for(i = 0; i < n * n; i++) - ok &= (Pxx[i] == check[i]); - - return ok; - } - // check that CondExp properly detects dependencies - bool cond_exp_depend(void) - { bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - AD zero(0.), one(1.), two(2.), three(3.); - - size_t n = 4; - 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); - Y[1] = CondExpLt(zero, X[1] + .5, two, three); - Y[2] = CondExpLt(zero, one, X[2] + .5, three); - Y[3] = CondExpLt(zero, one, two, X[3] + .5); - - CppAD::ADFun f(X, Y); - if( conditional_skip_ ) - f.optimize(); - else - f.optimize("no_conditional_skip"); - - CppAD::vector x(n), y(m); - size_t i; - for(i = 0; i < n; i++) - x[i] = double(n - i); - y = f.Forward(0, x); - - if( x[0] + .5 < 1. ) - ok &= NearEqual(y[0], 2., eps10, eps10); - else ok &= NearEqual(y[0], 3., eps10, eps10); - if( 0. < x[1] + .5 ) - ok &= NearEqual(y[1], 2., eps10, eps10); - else ok &= NearEqual(y[1], 3., eps10, eps10); - ok &= NearEqual(y[2], x[2] + .5, eps10, eps10);; - ok &= NearEqual(y[3], 2., eps10, eps10); - - return ok; - } - // check that CondExp properly handels expressions that get - // removed during opitmization - bool cond_exp_removed(void) - { bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - AD zero(0.); - - size_t n = 1; - CppAD::vector< AD > X(n); - X[0] = 1.0; - CppAD::Independent(X); - - size_t m = 1; - CppAD::vector< AD > Y(m); - - AD true_case = sin(X[0]) + sin(X[0]); - AD false_case = cos(X[0]) + cos(X[0]); - Y[0] = CondExpLt(X[0], zero, true_case, false_case); - - CppAD::ADFun f(X, Y); - 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, eps10, eps10); - - w[0] = 1.0; - dw = f.Reverse(1, w); - // derivative of cos is minus sin - ok &= NearEqual(dw[0], - true_case, eps10, eps10); - - return ok; - } - // ------------------------------------------------------------------- - using CppAD::set_union; - - bool old_atomic_forward( - size_t id , - size_t k , - size_t n , - size_t m , - const CppAD::vector& vx , - CppAD::vector& vy , - const CppAD::vector& tx , - CppAD::vector& ty ) - { assert(n == 3 && m == 2); - if( k > 0 ) - return false; - - // y[0] = x[0] + x[1] - ty[0] = tx[0] + tx[1]; - - // 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; - } - - bool old_atomic_reverse( - size_t id , - size_t k , - size_t n , - size_t m , - const CppAD::vector& tx , - const CppAD::vector& ty , - CppAD::vector& px , - const CppAD::vector& py ) - { return false; } - - bool old_atomic_for_jac_sparse( - size_t id , - size_t n , - size_t m , - size_t q , - const CppAD::vector< std::set >& r , - CppAD::vector< std::set >& s ) - { return false; } - - bool old_atomic_rev_jac_sparse( - size_t id , - size_t n , - size_t m , - size_t q , - CppAD::vector< std::set >& r , - const CppAD::vector< std::set >& s ) - { assert(n == 3 && m == 2); - r[0].clear(); - r[1].clear(); - r[2].clear(); - // y[0] = x[0] + x[1] - r[0] = set_union(r[0], s[0]); - r[1] = set_union(r[1], s[0]); - // y[1] = x[1] + x[2] - r[1] = set_union(r[1], s[1]); - r[2] = set_union(r[2], s[1]); - - return true; - } - - bool old_atomic_rev_hes_sparse( - size_t id , - size_t n , - size_t m , - size_t q , - const CppAD::vector< std::set >& r , - const CppAD::vector& s , - CppAD::vector& t , - const CppAD::vector< std::set >& u , - CppAD::vector< std::set >& v ) - { return false; } - - CPPAD_USER_ATOMIC( - my_old_atomic , - CppAD::vector , - double , - old_atomic_forward , - old_atomic_reverse , - old_atomic_for_jac_sparse , - old_atomic_rev_jac_sparse , - old_atomic_rev_hes_sparse - ) - - bool old_atomic_test(void) - { bool ok = true; - - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - size_t j; - size_t n = 3; - size_t m = 2; - CppAD::vector< AD > ax(n), ay(m), az(m); - for(j = 0; j < n; j++) - ax[j] = AD(j + 1); - CppAD::Independent(ax); - - size_t id = 0; - // first call should stay in the tape - my_old_atomic(id++, ax, ay); - // second call will not get used - my_old_atomic(id++, ax, az); - // create function - CppAD::ADFun g(ax, ay); - // should have 1 + n + m + m varaibles - ok &= g.size_var() == (1 + n + m + m); - g.optimize(); - // should have 1 + n + m varaibles - ok &= g.size_var() == (1 + n + m); - - // now test that the optimized function gives same results - CppAD::vector x(n), y(m); - for(j = 0; j < n; j++) - x[j] = double( (j + 1) * (j + 1) ); - y = g.Forward(0, x); - // y[0] = x[0] + x[1] - ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); - // y[1] = x[1] + x[2] - ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); - - return ok; - } - bool not_identically_equal(void) - { bool ok = true; - using CppAD::AD; - - // independent variable vector - size_t n = 5; - CppAD::vector< AD > ax(n); - size_t j; - 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); - ay[0] = 0.; - for(j = 0; j < n; j++) - { if( j % 2 == 0 ) - ay[0] += ax[j]; - else ay[0] -= ax[j]; - } - CppAD::ADFun f(ax, ay); - - // Used to fail assert in optimize that forward mode results - // are identically equal - if( conditional_skip_ ) - f.optimize(); - else - f.optimize("no_conditional_skip"); - - return ok; - } - // ----------------------------------------------------------------------- - double floor(const double& x) - { return std::floor(x); } - CPPAD_DISCRETE_FUNCTION(double, floor) - bool discrete_function(void) - { bool ok = true; - using CppAD::vector; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - vector< CppAD::AD > ax(1), ay(1); - ax[0] = 0.0; - CppAD::Independent(ax); - ay[0] = floor(ax[0]) + floor(ax[0]); - CppAD::ADFun f(ax, ay); - - size_t size_before = f.size_var(); - 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 &= NearEqual(y[0], -6.0, eps10, eps10); - - return ok; - } - // ---------------------------------------------------------------- - void i_algo( - const CppAD::vector< CppAD::AD >& ax , - CppAD::vector< CppAD::AD >& ay ) - { ay[0] = 1.0 / ax[0]; } - // - // Test bug where atomic functions were not properly conditionally skipped. - bool cond_exp_skip_atomic(void) - { bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - 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 - 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); - au[0] = ax[1]; - i_check(au, aw); - AD zero = 0.0; - ay[0] = CondExpGt(av[0], zero, av[0], aw[0]); - - // create function object f : ax -> ay - CppAD::ADFun f(ax, ay); - - // run case that skips the second call to afun - // (can use trace in forward0sweep.hpp to see this). - vector x(2), y_before(1), y_after(1); - x[0] = 1.0; - x[1] = 2.0; - y_before = f.Forward(0, x); - if( conditional_skip_ ) - f.optimize(); - else - f.optimize("no_conditional_skip"); - y_after = f.Forward(0, x); - - ok &= NearEqual(y_before[0], y_after[0], eps10, eps10); - - return ok; - } - // - // Test bug where conditional dependence did not pass through - // atomic functions - bool cond_exp_atomic_dependence(void) - { bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - 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; - ax[0] = 1.0; - ax[1] = 1.0; - Independent(ax); - av[0] = ax[0] + ax[1]; - i_check(av, aw); - ay[0] = CondExpGt(aw[0], zero, zero, aw[0]); - CppAD::ADFun f; - f.Dependent(ax, ay); - - // run case that skips the second call to afun - // (but not for order zero) - vector x(2), y_before(1), y_after(1); - vector dx(2), dy_before(1), dy_after(1); - x[0] = 1.0; - x[1] = 1.0; - y_before = f.Forward(0, x); - dx[0] = 2.0; - dx[1] = 2.0; - dy_before = f.Forward(1, dx); - if( conditional_skip_ ) - f.optimize(); - else - f.optimize("no_conditional_skip"); - y_after = f.Forward(0, x); - dy_after = f.Forward(1, dx); - - ok &= NearEqual(y_before[0] , y_after[0], eps10, eps10); - ok &= NearEqual(dy_before[0], dy_after[0], eps10, eps10); - - return ok; - } - // ----------------------------------------------------------------------- - // Test reverse mode conditionalay skipping commands. - template - 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]); - return res; - } - bool cond_exp_reverse(void) - { bool ok = true; - size_t n = 3; - using CppAD::vector; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - 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); - - 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); - f.Forward(0, x); - w[0] = 1.0; - dx = f.Reverse(1, w); - for(size_t j = 0; j < n; j++) - { if( j == n-1 ) - ok &= NearEqual(dx[j], 2.0, eps10, eps10); - else - ok &= NearEqual(dx[j], 0.0, eps10, eps10); - } - return ok; - } - // Test case where an expression depends on both the true - // and false cases (bug fixed 2014-12-22) - bool cond_exp_both_true_and_false(void) - { bool ok = true; - using CppAD::vector; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - // f(x) = x[0] + x[0] if x[0] >= 3 - // = x[0] + x[1] otherwise - vector< AD > ax(2), ay(3); - ax[0] = 1.0; - ax[1] = 2.0; - Independent(ax); - AD three(3); - AD value = ax[0] + ax[1]; - // a simple value - ay[0] = CppAD::CondExpGe(ax[0], three, value, value); - // a binary exprpression - ay[1] = CppAD::CondExpGe(ax[0], three, ax[0]-ax[1], ax[0]-ax[1]); - // a unary expression - ay[2] = CppAD::CondExpGe(ax[0], three, exp(ax[0]), exp(ax[0]) ); - CppAD::ADFun f(ax, ay); - if( conditional_skip_ ) - f.optimize(); - else - f.optimize("no_conditional_skip"); - - // check case where x[0] >= 3 - vector x(2), y(3); - x[0] = 4.0; - x[1] = 2.0; - y = f.Forward(0, x); - ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); - ok &= NearEqual(y[1], x[0] - x[1], eps10, eps10); - ok &= NearEqual(y[2], exp(x[0]), eps10, eps10); - - // check case where x[0] < 3 - x[0] = 1.0; - x[1] = 2.0; - y = f.Forward(0, x); - ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); - ok &= NearEqual(y[1], x[0] - x[1], eps10, eps10); - ok &= NearEqual(y[2], exp(x[0]), eps10, eps10); - - return ok; - } - - // Test case where a variable is removed during optimization - // (bug fixed 2017-03-04) - bool cond_exp_skip_remove_var(void) - { bool ok = true; - using CppAD::vector; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - vector< AD > ax(2), ay(2); - ax[0] = 1.0; - ax[1] = 2.0; - Independent(ax); - // - AD var_1 = ax[0] + ax[1]; - AD var_2 = ax[0] + ax[1]; // gets removed during optimization - AD var_3 = ax[0] + ax[1]; // gets removed during optimization - AD var_4 = ax[0] - ax[1]; - AD par_1 = 1.0; - // - // first conditional expression depends on var_1 - // 6 * x_0 if x_0 + x_1 >= 1.0, 7 * x_1 otherwise - ay[0] = CppAD::CondExpGe(var_1, par_1, 6.0 * ax[0], 7.0 * ax[1]); - // - // second conditional expression depends on var_4 - // 8 * x_0 if x_0 - x_1 >= x_0 + x_1, 9 * x_1 otherwise - ay[1] = CppAD::CondExpGe(var_4, par_1, 8.0 * ax[0], 9.0 * ax[1]); - CppAD::ADFun f(ax, ay); - // - if( conditional_skip_ ) - f.optimize(); - else - f.optimize("no_conditional_skip"); - - // check case where x[0] = 2, x[1] = 4 - vector x(2), y(2); - x[0] = 2.0; - x[1] = 4.0; - y = f.Forward(0, x); - ok &= NearEqual(y[0], 6.0 * x[0], eps10, eps10); - ok &= NearEqual(y[1], 9.0 * x[1], eps10, eps10); - - return ok; - } - - // Test case where if_false case is not used by conditional expression - // but is use after conditional expression. - // (bug fixed 2017-04-02) - bool cond_exp_if_false_used_after(void) - { bool ok = true; - using CppAD::vector; - using CppAD::AD; - using CppAD::NearEqual; - double eps10 = 10.0 * std::numeric_limits::epsilon(); - - vector< AD > ax(2), ay(1); - ax[0] = 1.0; - ax[1] = 2.0; - Independent(ax); - // - AD left = ax[0]; - AD right = ax[1]; - AD if_true = ax[0] + ax[0]; - AD if_false = ax[1] + ax[1]; - // - AD cexp = CondExpLt(left, right, if_true, if_false); - ay[0] = cexp + if_false; - CppAD::ADFun f(ax, ay); - // - if( conditional_skip_ ) - f.optimize(); - else - f.optimize("no_conditional_skip"); - // - // check case where x[0] < x[1] - vector x(2), y(1); - x[0] = 2.0; - x[1] = 4.0; - y = f.Forward(0, x); - ok &= NearEqual(y[0], x[0] + x[0] + x[1] + x[1], eps10, eps10); - ok &= f.number_skip() == 0; - // - // check case where x[0] >= x[1] (if_true is not used) - x[0] = 4.0; - x[1] = 2.0; - y = f.Forward(0, x); - ok &= NearEqual(y[0], x[1] + x[1] + x[1] + x[1], eps10, eps10); - if( conditional_skip_ ) - ok &= f.number_skip() == 1; - else - ok &= f.number_skip() == 0; - // - return ok; - } - - // Test case where only varaible arguments were being checked for - // a complete match once hash_codes were equal. - // (*bug fixed 2017-11-23) - bool only_check_variables_when_hash_codes_match(void) - { bool ok = true; - using CppAD::AD; - using CppAD::vector; - // - double eps99 = 99.0 * std::numeric_limits::epsilon(); - // - // length of the data vector z - size_t nz = 9999; - // - // factor for last term - double factor = 1e+5; - // - // z starts at -1.0 and ends at 1.0 - vector z(nz); - for(size_t i = 0; i < nz; i++) - z[i] = -1.0 + 2.0 * double(i) / double(nz - 1); - // - // f(x) = sum from i=0 to nz-1 of (x - z[i])^2 - vector< AD > ax(1), ay(1); - ax[0] = 0.0; - CppAD::Independent(ax); - AD asum = 0.0; - for(size_t i = 0; i < nz; i++) - { AD aterm = z[i] - ax[0]; - if( i == nz - 1 ) - asum += factor * aterm; - else - asum += aterm / factor; - } - ay[0] = asum; - CppAD::ADFun f(ax, ay); - // - // value of x where we are computing derivative - vector x(1), y_before(1), y_after(1); - x[0] = .1; - y_before = f.Forward(0, x); - f.optimize(); - y_after = f.Forward(0, x); - // - ok &= CppAD::NearEqual(y_before[0], y_after[0], eps99, eps99); - // - return ok; - } + return ok; + } + // =================================================================== + // Test duplicate operation analysis + + template + void duplicate_fun + (const Vector& x, Vector& y, size_t& original, size_t& opt) + { typedef typename Vector::value_type Scalar; + original = 0; + opt = 0; + + // unary operator where operand is arg[0] and one result + Scalar a1 = CppAD::exp(x[0]); + original += 1; + opt += 1; + + // unary operator where operand is arg[0] and two results + Scalar b1 = CppAD::sin(x[1]); + original += 2; + opt += 2; + + // non-commutative binary operator where left is a variable + // and right is a parameter + Scalar c1 = x[2] - 3.; + original += 1; + opt += 1; + + // non-commutative binary operator where left is a parameter + // and right is a variable + Scalar d1 = 3. / x[3]; + original += 1; + opt += 1; + + // non-commutative binary operator where left is a variable + // and right is a variable + Scalar e1 = pow(x[3], x[4]); + original += 3; + opt += 3; + + // commutative binary operator where left is a variable + // and right is a parameter + Scalar f1 = x[5] * 5.; + original += 1; + opt += 1; + + // commutative binary operator where left is a variable + // and right is a variable + Scalar g1 = x[5] + x[6]; + original += 1; + opt += 1; + + // duplicate variables + Scalar a2 = CppAD::exp(x[0]); + Scalar b2 = CppAD::sin(x[1]); // counts for 2 variables + Scalar c2 = x[2] - 3.; + Scalar d2 = 3. / x[3]; + Scalar e2 = pow(x[3], x[4]); // counts for 3 variables + Scalar f2 = 5. * x[5]; + Scalar g2 = x[6] + x[5]; + original += 10; + + // result vector + y[0] = a1 * a2; + y[1] = b1 * b2; + y[2] = c1 * c2; + y[3] = d1 * d2; + y[4] = e1 * e2; + y[5] = f1 * f2; + y[6] = g1 * g2; + original += 7; + opt += 7; + + return; + } + bool duplicate_one(void) + { + bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + 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); + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // 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); + + 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 &= NearEqual(y[i], check[i], eps10, eps10); + + // Check size before optimization + ok &= F.size_var() == (n + 1 + original); + + // Optimize the operation sequence + 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 &= NearEqual(y[i], check[i], eps10, eps10); + + return ok; + } + // ------------------------------------------------------------------- + bool duplicate_two(void) + { // test that duplicate expression removal is relative to + // new and not just old argument indices. + bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + size_t i, j; + + // domain space vector + size_t n = 1; + CppAD::vector< AD > X(n); + for(j = 0; j < n; j++) + X[j] = double(j + 2); + + // range space vector + size_t m = 1; + CppAD::vector< AD > Y(m); + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // create a new variable + AD A1 = X[0] - 2.; + + // create a duplicate variable + AD A2 = X[0] - 2.; + + // create a new variable using first version of duplicate + AD B1 = A1 / 2.; + + // create a duplicate that can only be dectected using new + // argument indices + AD B2 = A2 / 2.; + + // 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); + + // check number of variables in original function + 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); + + y = F.Forward(0, x); + for(i = 0; i < m; i++) + ok &= NearEqual(y[i], Value(Y[i]), eps10, eps10); + + 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 ); + + y = F.Forward(0, x); + for(i = 0; i < m; i++) + ok &= NearEqual(y[i], Value(Y[i]), eps10, eps10); + + return ok; + } + // ------------------------------------------------------------------- + bool duplicate_three(void) + { // test that duplicate expression removal is relative to + // new and not just old argument indices (commutative case). + bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + size_t i, j; + + // domain space vector + size_t n = 1; + CppAD::vector< AD > X(n); + for(j = 0; j < n; j++) + X[j] = double(j + 2); + + // range space vector + size_t m = 1; + CppAD::vector< AD > Y(m); + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // create a new variable + AD A1 = X[0] + 2.; + + // create a duplicate variable + AD A2 = 2. + X[0]; + + // create a new variable using first version of duplicate + AD B1 = A1 * 2.; + + // create a duplicate that can only be dectected using new + // argument indices + AD B2 = 2. * A2; + + // 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); + + // check number of variables in original function + 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); + + y = F.Forward(0, x); + for(i = 0; i < m; i++) + ok &= NearEqual(y[i], Value(Y[i]), eps10, eps10); + + 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 ); + + y = F.Forward(0, x); + for(i = 0; i < m; i++) + ok &= NearEqual(y[i], Value(Y[i]), eps10, eps10); + + return ok; + } + // ------------------------------------------------------------------- + bool duplicate_four(void) + { // Check that unary expression matching not only checks hash code, + // and operator, but also operand (old bug that has been fixed). + bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + size_t j; + + // domain space vector + size_t n = 1; + CppAD::vector< AD > X(n); + X[0] = 1.; + + // range space vector + size_t m = 1; + CppAD::vector< AD > Y(m); + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // 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 + ); + Y[0] = X[0]; + for(j = 0; j < n_operations; j++) + Y[0] = fabs(Y[0]); + + // create f: X -> Y and stop tape recording + CppAD::ADFun F; + F.Dependent(X, Y); + + // check number of variables in original function + ok &= (F.size_var() == 1 + n + n_operations ); + + CppAD::vector x(n), y(m); + x[0] = 1.; + + y = F.Forward(0, x); + ok &= NearEqual(y[0], Value(Y[0]), eps10, eps10); + + 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 ); + + y = F.Forward(0, x); + ok &= NearEqual(y[0], Value(Y[0]), eps10, eps10); + + return ok; + } + // ==================================================================== + bool cumulative_sum(void) + { // test conversion of a sequence of additions and subtraction + // to a cumulative summation sequence. + bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + size_t i, j; + + // domain space vector + size_t n = 7; + CppAD::vector< AD > X(n); + for(j = 0; j < n; j++) + X[j] = double(j + 2); + + size_t n_original = 1 + n; + size_t n_optimize = 1 + n; + + // range space vector + size_t m = 2; + CppAD::vector< AD > Y(m); + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // Operations inside of optimize_cadd + Y[0] = 5. + (X[0] + X[1]) + (X[1] - X[2]) // Addvv, Subvv + + (X[2] - 1.) + (2. - X[3]) // Subvp, Subpv + + (X[4] + 3.) + (4. + X[5]); // Addpv, Addpv (no Addvp) + n_original += 12; + n_optimize += 1; + + + // Operations inside of optimize_csub + Y[1] = 5. - (X[1] + X[2]) - (X[2] - X[3]) // Addvv, Subvv + - (X[3] - 1.) - (2. - X[4]) // Subvp, Subpv + - (X[5] + 3.) - (4. + X[6]); // Addpv, Addpv (no Addvp) + n_original += 12; + n_optimize += 1; + + CppAD::ADFun F; + F.Dependent(X, Y); + + // check number of variables in original function + ok &= (F.size_var() == n_original ); + + CppAD::vector x(n), y(m); + for(j = 0; j < n; j++) + x[j] = double(j + 2); + + y = F.Forward(0, x); + for(i = 0; i < m; i++) + ok &= NearEqual(y[i], Value(Y[i]), eps10, eps10); + + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); + + // check number of variables in optimized version + ok &= (F.size_var() == n_optimize ); + + y = F.Forward(0, x); + for(i = 0; i < m; i++) + ok &= NearEqual(y[i], Value(Y[i]), eps10, eps10); + + return ok; + } + // ------------------------------------------------------------------- + bool forward_csum(void) + { bool ok = true; + + using namespace CppAD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CppAD::vector< AD > X(2); + 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 + 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], eps10, eps10); + + // 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], eps10, eps10); + + // evaluate second derivative of F in X[0] direction + CppAD::vector x2( F.Domain() ); + CppAD::vector y2( F.Range() ); + x2[0] = 0.; + x2[1] = 0.; + y2 = F.Forward(2, x2); + double F_00 = 2. * y2[0]; + ok &= NearEqual(F_00, 0., eps10, eps10); + + return ok; + } + // ------------------------------------------------------------------- + bool reverse_csum(void) + { bool ok = true; + + using namespace CppAD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CppAD::vector< AD > X(2); + 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 + 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], eps10, eps10); + + // 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., eps10, eps10); + ok &= NearEqual(dF[1] , 1., eps10, eps10); + + return ok; + } + bool forward_sparse_jacobian() + { bool ok = true; + using namespace CppAD; + + // dimension of the domain space + size_t n = 3; + + // dimension of the range space + size_t m = 3; + + // independent variable vector + CppAD::vector< AD > X(n); + 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[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[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] + // 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 + // so the optimizer can know it affects the results. + 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); + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); + + // --------------------------------------------------------- + // 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++) + { for(j = 0; j < n; j++) + { 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; + + // dimension of the range space + size_t m = 3; + + // independent variable vector + CppAD::vector< AD > X(n); + 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[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[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[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); + if( conditional_skip_ ) + F.optimize(); + else + F.optimize("no_conditional_skip"); + + // ---------------------------------------------------------- + // dependency matrix for the identity function + CppAD::vector< bool > Py(m * m); + size_t i, j; + for(i = 0; i < m; i++) + { 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); + 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], + 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] + check[0 * n + 2] = false; // x[0], x[2] + + check[1 * n + 0] = false; // partial w.r.t. x[1], x[0] + check[1 * n + 1] = true; // x[1], x[1] + check[1 * n + 2] = true; // x[1], x[2] + + 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); + 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) ) + CppAD::vector Py(m); + CppAD::vector Pxx(n * n); + Py[0] = true; + Pxx = F.RevSparseHes(n, Py); + // check values + for(i = 0; i < n * n; i++) + ok &= (Pxx[i] == check[i]); + + return ok; + } + // check that CondExp properly detects dependencies + bool cond_exp_depend(void) + { bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + AD zero(0.), one(1.), two(2.), three(3.); + + size_t n = 4; + 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); + Y[1] = CondExpLt(zero, X[1] + .5, two, three); + Y[2] = CondExpLt(zero, one, X[2] + .5, three); + Y[3] = CondExpLt(zero, one, two, X[3] + .5); + + CppAD::ADFun f(X, Y); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + + CppAD::vector x(n), y(m); + size_t i; + for(i = 0; i < n; i++) + x[i] = double(n - i); + y = f.Forward(0, x); + + if( x[0] + .5 < 1. ) + ok &= NearEqual(y[0], 2., eps10, eps10); + else + ok &= NearEqual(y[0], 3., eps10, eps10); + if( 0. < x[1] + .5 ) + ok &= NearEqual(y[1], 2., eps10, eps10); + else + ok &= NearEqual(y[1], 3., eps10, eps10); + ok &= NearEqual(y[2], x[2] + .5, eps10, eps10);; + ok &= NearEqual(y[3], 2., eps10, eps10); + + return ok; + } + // check that CondExp properly handels expressions that get + // removed during opitmization + bool cond_exp_removed(void) + { bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + AD zero(0.); + + size_t n = 1; + CppAD::vector< AD > X(n); + X[0] = 1.0; + CppAD::Independent(X); + + size_t m = 1; + CppAD::vector< AD > Y(m); + + AD true_case = sin(X[0]) + sin(X[0]); + AD false_case = cos(X[0]) + cos(X[0]); + Y[0] = CondExpLt(X[0], zero, true_case, false_case); + + CppAD::ADFun f(X, Y); + 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, eps10, eps10); + + w[0] = 1.0; + dw = f.Reverse(1, w); + // derivative of cos is minus sin + ok &= NearEqual(dw[0], - true_case, eps10, eps10); + + return ok; + } + // ------------------------------------------------------------------- + using CppAD::set_union; + + bool atomic_one_forward( + size_t id , + size_t k , + size_t n , + size_t m , + const CppAD::vector& vx , + CppAD::vector& vy , + const CppAD::vector& tx , + CppAD::vector& ty ) + { assert(n == 3 && m == 2); + if( k > 0 ) + return false; + + // y[0] = x[0] + x[1] + ty[0] = tx[0] + tx[1]; + + // 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; + } + + bool atomic_one_reverse( + size_t id , + size_t k , + size_t n , + size_t m , + const CppAD::vector& tx , + const CppAD::vector& ty , + CppAD::vector& px , + const CppAD::vector& py ) + { return false; } + + bool atomic_one_for_jac_sparse( + size_t id , + size_t n , + size_t m , + size_t q , + const CppAD::vector< std::set >& r , + CppAD::vector< std::set >& s ) + { return false; } + + bool atomic_one_rev_jac_sparse( + size_t id , + size_t n , + size_t m , + size_t q , + CppAD::vector< std::set >& r , + const CppAD::vector< std::set >& s ) + { assert(n == 3 && m == 2); + r[0].clear(); + r[1].clear(); + r[2].clear(); + // y[0] = x[0] + x[1] + r[0] = set_union(r[0], s[0]); + r[1] = set_union(r[1], s[0]); + // y[1] = x[1] + x[2] + r[1] = set_union(r[1], s[1]); + r[2] = set_union(r[2], s[1]); + + return true; + } + + bool atomic_one_rev_hes_sparse( + size_t id , + size_t n , + size_t m , + size_t q , + const CppAD::vector< std::set >& r , + const CppAD::vector& s , + CppAD::vector& t , + const CppAD::vector< std::set >& u , + CppAD::vector< std::set >& v ) + { return false; } + + CPPAD_USER_ATOMIC( + my_atomic_one , + CppAD::vector , + double , + atomic_one_forward , + atomic_one_reverse , + atomic_one_for_jac_sparse , + atomic_one_rev_jac_sparse , + atomic_one_rev_hes_sparse + ) + + bool atomic_one_test(void) + { bool ok = true; + + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + size_t j; + size_t n = 3; + size_t m = 2; + CppAD::vector< AD > ax(n), ay(m), az(m); + for(j = 0; j < n; j++) + ax[j] = AD(j + 1); + CppAD::Independent(ax); + + size_t id = 0; + // first call should stay in the tape + my_atomic_one(id++, ax, ay); + // second call will not get used + my_atomic_one(id++, ax, az); + // create function + CppAD::ADFun g(ax, ay); + // should have 1 + n + m + m varaibles + ok &= g.size_var() == (1 + n + m + m); + g.optimize(); + // should have 1 + n + m varaibles + ok &= g.size_var() == (1 + n + m); + + // now test that the optimized function gives same results + CppAD::vector x(n), y(m); + for(j = 0; j < n; j++) + x[j] = double( (j + 1) * (j + 1) ); + y = g.Forward(0, x); + // y[0] = x[0] + x[1] + ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); + // y[1] = x[1] + x[2] + ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); + + return ok; + } + bool not_identically_equal(void) + { bool ok = true; + using CppAD::AD; + + // independent variable vector + size_t n = 5; + CppAD::vector< AD > ax(n); + size_t j; + 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); + ay[0] = 0.; + for(j = 0; j < n; j++) + { if( j % 2 == 0 ) + ay[0] += ax[j]; + else + ay[0] -= ax[j]; + } + CppAD::ADFun f(ax, ay); + + // Used to fail assert in optimize that forward mode results + // are identically equal + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + + return ok; + } + // ----------------------------------------------------------------------- + double floor(const double& x) + { return std::floor(x); } + CPPAD_DISCRETE_FUNCTION(double, floor) + bool discrete_function(void) + { bool ok = true; + using CppAD::vector; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + vector< CppAD::AD > ax(1), ay(1); + ax[0] = 0.0; + CppAD::Independent(ax); + ay[0] = floor(ax[0]) + floor(ax[0]); + CppAD::ADFun f(ax, ay); + + size_t size_before = f.size_var(); + 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 &= NearEqual(y[0], -6.0, eps10, eps10); + + return ok; + } + // ---------------------------------------------------------------- + void i_algo( + const CppAD::vector< CppAD::AD >& ax , + CppAD::vector< CppAD::AD >& ay ) + { ay[0] = 1.0 / ax[0]; } + // + // Test bug where atomic functions were not properly conditionally skipped. + bool cond_exp_skip_atomic(void) + { bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + 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 + 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); + au[0] = ax[1]; + i_check(au, aw); + AD zero = 0.0; + ay[0] = CondExpGt(av[0], zero, av[0], aw[0]); + + // create function object f : ax -> ay + CppAD::ADFun f(ax, ay); + + // run case that skips the second call to afun + // (can use trace in forward0sweep.hpp to see this). + vector x(2), y_before(1), y_after(1); + x[0] = 1.0; + x[1] = 2.0; + y_before = f.Forward(0, x); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + y_after = f.Forward(0, x); + + ok &= NearEqual(y_before[0], y_after[0], eps10, eps10); + + return ok; + } + // + // Test bug where conditional dependence did not pass through + // atomic functions + bool cond_exp_atomic_dependence(void) + { bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + 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; + ax[0] = 1.0; + ax[1] = 1.0; + Independent(ax); + av[0] = ax[0] + ax[1]; + i_check(av, aw); + ay[0] = CondExpGt(aw[0], zero, zero, aw[0]); + CppAD::ADFun f; + f.Dependent(ax, ay); + + // run case that skips the second call to afun + // (but not for order zero) + vector x(2), y_before(1), y_after(1); + vector dx(2), dy_before(1), dy_after(1); + x[0] = 1.0; + x[1] = 1.0; + y_before = f.Forward(0, x); + dx[0] = 2.0; + dx[1] = 2.0; + dy_before = f.Forward(1, dx); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + y_after = f.Forward(0, x); + dy_after = f.Forward(1, dx); + + ok &= NearEqual(y_before[0] , y_after[0], eps10, eps10); + ok &= NearEqual(dy_before[0], dy_after[0], eps10, eps10); + + return ok; + } + // ----------------------------------------------------------------------- + // Test reverse mode conditionalay skipping commands. + template + 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]); + return res; + } + bool cond_exp_reverse(void) + { bool ok = true; + size_t n = 3; + using CppAD::vector; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + 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); + + 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); + f.Forward(0, x); + w[0] = 1.0; + dx = f.Reverse(1, w); + for(size_t j = 0; j < n; j++) + { if( j == n-1 ) + ok &= NearEqual(dx[j], 2.0, eps10, eps10); + else + ok &= NearEqual(dx[j], 0.0, eps10, eps10); + } + return ok; + } + // ----------------------------------------------------------------------- + // Test case where an expression depends on both the true + // and false cases (bug fixed 2014-12-22) + bool cond_exp_both_true_and_false(void) + { bool ok = true; + using CppAD::vector; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + // f(x) = x[0] + x[0] if x[0] >= 3 + // = x[0] + x[1] otherwise + vector< AD > ax(2), ay(3); + ax[0] = 1.0; + ax[1] = 2.0; + Independent(ax); + AD three(3); + AD value = ax[0] + ax[1]; + // a simple value + ay[0] = CppAD::CondExpGe(ax[0], three, value, value); + // a binary exprpression + ay[1] = CppAD::CondExpGe(ax[0], three, ax[0]-ax[1], ax[0]-ax[1]); + // a unary expression + ay[2] = CppAD::CondExpGe(ax[0], three, exp(ax[0]), exp(ax[0]) ); + CppAD::ADFun f(ax, ay); + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + + // check case where x[0] >= 3 + vector x(2), y(3); + x[0] = 4.0; + x[1] = 2.0; + y = f.Forward(0, x); + ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); + ok &= NearEqual(y[1], x[0] - x[1], eps10, eps10); + ok &= NearEqual(y[2], exp(x[0]), eps10, eps10); + + // check case where x[0] < 3 + x[0] = 1.0; + x[1] = 2.0; + y = f.Forward(0, x); + ok &= NearEqual(y[0], x[0] + x[1], eps10, eps10); + ok &= NearEqual(y[1], x[0] - x[1], eps10, eps10); + ok &= NearEqual(y[2], exp(x[0]), eps10, eps10); + + return ok; + } + + // Test case where a variable is removed during optimization + // (bug fixed 2017-03-04) + bool cond_exp_skip_remove_var(void) + { bool ok = true; + using CppAD::vector; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + vector< AD > ax(2), ay(2); + ax[0] = 1.0; + ax[1] = 2.0; + Independent(ax); + // + AD var_1 = ax[0] + ax[1]; + AD var_2 = ax[0] + ax[1]; // gets removed during optimization + AD var_3 = ax[0] + ax[1]; // gets removed during optimization + AD var_4 = ax[0] - ax[1]; + AD par_1 = 1.0; + // + // first conditional expression depends on var_1 + // 6 * x_0 if x_0 + x_1 >= 1.0, 7 * x_1 otherwise + ay[0] = CppAD::CondExpGe(var_1, par_1, 6.0 * ax[0], 7.0 * ax[1]); + // + // second conditional expression depends on var_4 + // 8 * x_0 if x_0 - x_1 >= x_0 + x_1, 9 * x_1 otherwise + ay[1] = CppAD::CondExpGe(var_4, par_1, 8.0 * ax[0], 9.0 * ax[1]); + CppAD::ADFun f(ax, ay); + // + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + + // check case where x[0] = 2, x[1] = 4 + vector x(2), y(2); + x[0] = 2.0; + x[1] = 4.0; + y = f.Forward(0, x); + ok &= NearEqual(y[0], 6.0 * x[0], eps10, eps10); + ok &= NearEqual(y[1], 9.0 * x[1], eps10, eps10); + + return ok; + } + + // ----------------------------------------------------------------------- + // Test case where if_false case is not used by conditional expression + // but is use after conditional expression. + // (bug fixed 2017-04-02) + bool cond_exp_if_false_used_after(void) + { bool ok = true; + using CppAD::vector; + using CppAD::AD; + using CppAD::NearEqual; + double eps10 = 10.0 * std::numeric_limits::epsilon(); + + vector< AD > ax(2), ay(1); + ax[0] = 1.0; + ax[1] = 2.0; + Independent(ax); + // + AD left = ax[0]; + AD right = ax[1]; + AD if_true = ax[0] + ax[0]; + AD if_false = ax[1] + ax[1]; + // + AD cexp = CondExpLt(left, right, if_true, if_false); + ay[0] = cexp + if_false; + CppAD::ADFun f(ax, ay); + // + if( conditional_skip_ ) + f.optimize(); + else + f.optimize("no_conditional_skip"); + // + // check case where x[0] < x[1] + vector x(2), y(1); + x[0] = 2.0; + x[1] = 4.0; + y = f.Forward(0, x); + ok &= NearEqual(y[0], x[0] + x[0] + x[1] + x[1], eps10, eps10); + ok &= f.number_skip() == 0; + // + // check case where x[0] >= x[1] (if_true is not used) + x[0] = 4.0; + x[1] = 2.0; + y = f.Forward(0, x); + ok &= NearEqual(y[0], x[1] + x[1] + x[1] + x[1], eps10, eps10); + if( conditional_skip_ ) + ok &= f.number_skip() == 1; + else + ok &= f.number_skip() == 0; + // + return ok; + } + + // ----------------------------------------------------------------------- + // Test case where only varaible arguments were being checked for + // a complete match once hash_codes were equal. + // (*bug fixed 2017-11-23) + bool only_check_variables_when_hash_codes_match(void) + { bool ok = true; + using CppAD::AD; + using CppAD::vector; + // + double eps99 = 99.0 * std::numeric_limits::epsilon(); + // + // length of the data vector z + size_t nz = 9999; + // + // factor for last term + double factor = 1e+5; + // + // z starts at -1.0 and ends at 1.0 + vector z(nz); + for(size_t i = 0; i < nz; i++) + z[i] = -1.0 + 2.0 * double(i) / double(nz - 1); + // + // f(x) = sum from i=0 to nz-1 of (x - z[i])^2 + vector< AD > ax(1), ay(1); + ax[0] = 0.0; + CppAD::Independent(ax); + AD asum = 0.0; + for(size_t i = 0; i < nz; i++) + { AD aterm = z[i] - ax[0]; + if( i == nz - 1 ) + asum += factor * aterm; + else + asum += aterm / factor; + } + ay[0] = asum; + CppAD::ADFun f(ax, ay); + // + // value of x where we are computing derivative + vector x(1), y_before(1), y_after(1); + x[0] = .1; + y_before = f.Forward(0, x); + f.optimize(); + y_after = f.Forward(0, x); + // + ok &= CppAD::NearEqual(y_before[0], y_after[0], eps99, eps99); + // + return ok; + } + + // ----------------------------------------------------------------------- + // Test case with print operator in optimized f + bool check_print_for(void) + { bool ok = true; + using CppAD::AD; + using CppAD::vector; + // + double eps99 = 99.0 * std::numeric_limits::epsilon(); + // + vector< AD > ax(1), ay(1); + ax[0] = 1.0; + CppAD::Independent(ax); + // + // check case where value is a parameter + AD pos = ax[0]; + const char* before = "long text before: value = "; + AD value = 2.0; + const char* after = "\n"; + CppAD::PrintFor(pos, before, value, after); + CppAD::PrintFor(pos, before, value, after); + // + ay[0] = ax[0]; + CppAD::ADFun f; + f.Dependent(ax, ay); + // + // value of x where we are computing derivative + std::stringstream s; + vector x(1), y_before(1), y_after(1); + x[0] = -0.1; + y_before = f.Forward(0, x, s); + f.optimize(); + y_after = f.Forward(0, x, s); + // + ok &= CppAD::NearEqual(y_before[0], y_after[0], eps99, eps99); + // + return ok; + } } bool optimize(void) -{ bool ok = true; - conditional_skip_ = true; - atomic_sparsity_option_ = CppAD::atomic_base::bool_sparsity_enum; - - // optimize an example ODE - ok &= optimize_ode(); - - // 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(); - } - - // 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(); - // check case were a variable in left or right expressions - // is removed during the optimization - ok &= cond_exp_skip_remove_var(); - // check case where an if case is used after the conditional expression - ok &= cond_exp_if_false_used_after(); - } - - // not using conditional_skip or atomic functions - ok &= only_check_variables_when_hash_codes_match(); - - // - CppAD::user_atomic::clear(); - return ok; +{ bool ok = true; + conditional_skip_ = true; + atomic_sparsity_option_ = CppAD::atomic_base::bool_sparsity_enum; + + ok &= atomic_arguments(); + + // check optimization with print_for operations + ok &= check_print_for(); + + // optimize an example ODE + ok &= optimize_ode(); + + // 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(); + } + + // 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 cumulative summation + ok &= cumulative_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 atomic_one functions + ok &= atomic_one_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(); + // check case were a variable in left or right expressions + // is removed during the optimization + ok &= cond_exp_skip_remove_var(); + // check case where an if case is used after the conditional expression + ok &= cond_exp_if_false_used_after(); + } + + // not using conditional_skip or atomic functions + ok &= only_check_variables_when_hash_codes_match(); + + // + CppAD::user_atomic::clear(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/parameter.cpp cppad-2019.02.00.0/test_more/general/parameter.cpp --- cppad-2018.00.00.0/test_more/general/parameter.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/parameter.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // Test hash coding of parameter during recording @@ -16,47 +17,57 @@ namespace { // BEGIN empty namespace template -bool test(void) -{ bool ok = true; - using namespace CppAD; - - // number of different parameter values - size_t n_parameter = 13; - - // number of parameter repeats - size_t n_repeat = 17; - - // independent variable vector - size_t j, n = n_parameter * n_repeat; - CPPAD_TESTVECTOR(AD) ax(n); - for(j = 0; j < n; 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); - k = k * k * 10 + 1; - j = i; - ay[i] = ax[j] + Float(k); - } +bool test_repeat(void) +{ bool ok = true; + using namespace CppAD; + + // number of different constant parameters + size_t n_constant = 13; + + // number of normal parameter repeats + size_t n_repeat = 17; + + // number of independent dynamic parameters + size_t n_dynamic = 5; + + // independent variable vector + size_t n = n_constant * n_repeat; + CPPAD_TESTVECTOR(AD) ax(n), dynamic(n_dynamic); + // dynamic parameter all have same value, but that could change + for(size_t j = 0; j < n_dynamic; ++j) + dynamic[j] = 3.0; + for(size_t j = 0; j < n; j++) + ax[j] = Float(j); + size_t abort_op_index = 0; + size_t record_compare = true; + Independent(ax, abort_op_index, record_compare, dynamic); + + // dependent variable vector and indices + size_t m = n; + CPPAD_TESTVECTOR(AD) ay(m); + for(size_t i = 0; i < m; i++) + { // must avoid Float(k) = 0 because it would get optimized out + size_t k = (i % n_constant); + k = k * k * 10 + 1; + size_t j = i; + ay[i] = ax[j] + Float(k); + } - // create f: ax -> ay - ADFun f(ax, ay); + // create f: ax -> ay + ADFun f(ax, ay); - ok = f.size_par() == n_parameter; + // add one for the phantom parameter at index zero + ok = f.size_par() == 1 + n_constant + n_dynamic; - return ok; + return ok; } } // END empty namespace bool parameter(void) -{ bool ok = true; - ok &= test(); - ok &= test(); - return ok; +{ bool ok = true; + ok &= test_repeat(); + ok &= test_repeat(); + // + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/poly.cpp cppad-2019.02.00.0/test_more/general/poly.cpp --- cppad-2018.00.00.0/test_more/general/poly.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/poly.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* // Old GetStarted example now used just for validation testing @@ -18,46 +19,46 @@ # include bool Poly(void) -{ bool ok = true; +{ bool ok = true; - // make CppAD routines visible without CppAD:: infront of names - using namespace CppAD; + // make CppAD routines visible without CppAD:: infront of names + using namespace CppAD; - // degree of the polynomial that we will differentiate - size_t deg = 4; + // degree of the polynomial that we will differentiate + size_t deg = 4; - // vector that will hold polynomial coefficients for p(z) - CPPAD_TESTVECTOR(AD) A(deg + 1); // AD elements - CPPAD_TESTVECTOR(double) a(deg + 1); // double elements - - // set the polynomial coefficients - A[0] = 1.; - size_t k; - for(k = 1; k <= deg; k++) - A[k] = a[k] = 1.; - - // independent variables - CPPAD_TESTVECTOR(AD) Z(1); // one independent variable - Z[0] = 3.; // value of independent variable - Independent(Z); // declare independent variable - - // 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 - ADFun f(Z, P); // ADFun corresponding to polynomial - - // compute derivative of polynomial - CPPAD_TESTVECTOR(double) z(1); // vector length f.Domain() - CPPAD_TESTVECTOR(double) J(1); // vector length f.Range * f.Domain() - z[0] = 3.; // point at which to compute derivative - J = f.Jacobian(z); // value of derivative + // vector that will hold polynomial coefficients for p(z) + CPPAD_TESTVECTOR(AD) A(deg + 1); // AD elements + CPPAD_TESTVECTOR(double) a(deg + 1); // double elements + + // set the polynomial coefficients + A[0] = 1.; + size_t k; + for(k = 1; k <= deg; k++) + A[k] = a[k] = 1.; + + // independent variables + CPPAD_TESTVECTOR(AD) Z(1); // one independent variable + Z[0] = 3.; // value of independent variable + Independent(Z); // declare independent variable + + // 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 + ADFun f(Z, P); // ADFun corresponding to polynomial + + // compute derivative of polynomial + CPPAD_TESTVECTOR(double) z(1); // vector length f.Domain() + CPPAD_TESTVECTOR(double) J(1); // vector length f.Range * f.Domain() + z[0] = 3.; // point at which to compute derivative + J = f.Jacobian(z); // value of derivative - // compare with derivative as computed by Poly - ok &= (Poly(1, a, z[0]) == J[0]); + // compare with derivative as computed by Poly + ok &= (Poly(1, a, z[0]) == J[0]); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/pow.cpp cppad-2019.02.00.0/test_more/general/pow.cpp --- cppad-2018.00.00.0/test_more/general/pow.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/pow.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old examples now just used for validation testing. @@ -17,407 +18,408 @@ namespace { // BEGIN empty namespace bool PowTestOne(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * 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; - - // declare independent variables and start tape recording - CppAD::Independent(XY); - - // 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) - - // create f: XY -> Z and stop tape recording - CppAD::ADFun f(XY, Z); - - // check value - double check = std::pow(x, y); - size_t i; - for(i = 0; i < m; i++) - ok &= NearEqual(Z[i] , check, eps99, eps99); - - // forward computation of first partial w.r.t. x - CPPAD_TESTVECTOR(double) dxy(n); - CPPAD_TESTVECTOR(double) dz(m); - dxy[0] = 1.; - dxy[1] = 0.; - dz = f.Forward(1, dxy); - check = y * std::pow(x, y-1.); - ok &= NearEqual(dz[0], check, eps99, eps99); - ok &= NearEqual(dz[1], check, eps99, eps99); - ok &= NearEqual(dz[2], 0., eps99, eps99); - - // 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, eps99, eps99); - ok &= NearEqual(dz[1], 0., eps99, eps99); - ok &= NearEqual(dz[2], check, eps99, eps99); - - // reverse computation of derivative of z[0] + z[1] + z[2] - CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); - w[0] = 1.; - w[1] = 1.; - w[2] = 1.; - dw = f.Reverse(1, w); - check = y * std::pow(x, y-1.); - ok &= NearEqual(dw[0], 2. * check, eps99, eps99); - check = std::log(x) * std::pow(x, y); - ok &= NearEqual(dw[1], 2. * check, eps99, eps99); - - // 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]; - AD result = CppAD::pow(v[zero], v[one]); - ok &= NearEqual(result, Z[0], eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * 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; + + // declare independent variables and start tape recording + CppAD::Independent(XY); + + // 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) + + // create f: XY -> Z and stop tape recording + CppAD::ADFun f(XY, Z); + + // check value + double check = std::pow(x, y); + size_t i; + for(i = 0; i < m; i++) + ok &= NearEqual(Z[i] , check, eps99, eps99); + + // forward computation of first partial w.r.t. x + CPPAD_TESTVECTOR(double) dxy(n); + CPPAD_TESTVECTOR(double) dz(m); + dxy[0] = 1.; + dxy[1] = 0.; + dz = f.Forward(1, dxy); + check = y * std::pow(x, y-1.); + ok &= NearEqual(dz[0], check, eps99, eps99); + ok &= NearEqual(dz[1], check, eps99, eps99); + ok &= NearEqual(dz[2], 0., eps99, eps99); + + // 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, eps99, eps99); + ok &= NearEqual(dz[1], 0., eps99, eps99); + ok &= NearEqual(dz[2], check, eps99, eps99); + + // reverse computation of derivative of z[0] + z[1] + z[2] + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + w[0] = 1.; + w[1] = 1.; + w[2] = 1.; + dw = f.Reverse(1, w); + check = y * std::pow(x, y-1.); + ok &= NearEqual(dw[0], 2. * check, eps99, eps99); + check = std::log(x) * std::pow(x, y); + ok &= NearEqual(dw[1], 2. * check, eps99, eps99); + + // 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]; + AD result = CppAD::pow(v[zero], v[one]); + ok &= NearEqual(result, Z[0], eps99, eps99); - return ok; + return ok; } bool PowTestTwo(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::pow; - using CppAD::exp; - using namespace CppAD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(2); - size_t s = 0; - size_t t = 1; - U[s] = 2.; - U[t] = 3.; - Independent(U); - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(2); - size_t x = 0; - size_t y = 1; - - - // dependent variable values - AD u = exp(U[s]); // u = exp(s) - Z[x] = pow(u, U[t]); // x = exp(s * t) - Z[y] = pow(Z[x], u); // y = exp( s * t * exp(s) ) - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - /* - u_s (s, t) = u - u_t (s, t) = 0 - y_s (s, t) = (1 + s) t * u * y - y_t (s, t) = s * u * y - y_st (s, t) = ( u + s * u ) * y + using CppAD::pow; + using CppAD::exp; + using namespace CppAD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(2); + size_t s = 0; + size_t t = 1; + U[s] = 2.; + U[t] = 3.; + Independent(U); + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(2); + size_t x = 0; + size_t y = 1; + + + // dependent variable values + AD u = exp(U[s]); // u = exp(s) + Z[x] = pow(u, U[t]); // x = exp(s * t) + Z[y] = pow(Z[x], u); // y = exp( s * t * exp(s) ) + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + /* + u_s (s, t) = u + u_t (s, t) = 0 + y_s (s, t) = (1 + s) t * u * y + y_t (s, t) = s * u * y + y_st (s, t) = ( u + s * u ) * y + ( t * u + s * t * u ) * s * u * y - */ + */ - // check values - ok &= NearEqual(Z[x] , exp(2. * 3.), eps99, eps99); - ok &= NearEqual(Z[y] , exp( 2. * 3. * exp(2.) ), eps99, eps99); - - // forward computation of partials w.r.t. s - v[s] = 1.; - v[t] = 0.; - w = f.Forward(1, v); - ok &= ( w[x] == U[t] * Z[x] ); // dx/ds - ok &= ( w[y] == (1. + U[s]) * U[t] * u * Z[y] ); // dy/ds - - // forward computation of partials w.r.t. t - v[s] = 0.; - v[t] = 1.; - 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 - 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 - 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) - v[s] = 1.; - v[t] = 1.; - w = f.Forward(1, v); - v[s] = 0.; - v[t] = 0.; - CPPAD_TESTVECTOR(double) f_rr = f.Forward(2, v); - - // check second order partial of y - ok &= NearEqual( - 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], - eps99 , - eps99 - ); + // check values + ok &= NearEqual(Z[x] , exp(2. * 3.), eps99, eps99); + ok &= NearEqual(Z[y] , exp( 2. * 3. * exp(2.) ), eps99, eps99); + + // forward computation of partials w.r.t. s + v[s] = 1.; + v[t] = 0.; + w = f.Forward(1, v); + ok &= ( w[x] == U[t] * Z[x] ); // dx/ds + ok &= ( w[y] == (1. + U[s]) * U[t] * u * Z[y] ); // dy/ds + + // forward computation of partials w.r.t. t + v[s] = 0.; + v[t] = 1.; + 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 + 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 + 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) + v[s] = 1.; + v[t] = 1.; + w = f.Forward(1, v); + v[s] = 0.; + v[t] = 0.; + CPPAD_TESTVECTOR(double) f_rr = f.Forward(2, v); + + // check second order partial of y + ok &= NearEqual( + 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], + eps99 , + eps99 + ); - return ok; + return ok; } bool PowTestThree(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = 2.; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // range space vector - size_t m = 4; - CPPAD_TESTVECTOR(AD) y(m); - - // some special cases - y[0] = pow(x[0], 0.); - y[1] = pow(0., x[0]); - y[2] = pow(x[0], 1.); - y[3] = pow(1., x[0]); - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // check function values - ok &= (Value(y[0]) == 1.); - ok &= (Value(y[1]) == 0.); - ok &= (Value(y[2]) == Value(x[0])); - ok &= (Value(y[3]) == 1.); - - // forward computation of first partial w.r.t. x - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - dx[0] = 1.; - dy = f.Forward(1, dx); - ok &= (dy[0] == 0.); - ok &= (dy[1] == 0.); - ok &= NearEqual(dy[2], 1., eps99, eps99); - ok &= (dy[3] == 0.); - - // 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.; - w[1] = 1.; - w[2] = 1.; - w[3] = 1.; - dw = f.Reverse(1, w); - ok &= NearEqual(dw[0], 1., eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = 2.; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // range space vector + size_t m = 4; + CPPAD_TESTVECTOR(AD) y(m); + + // some special cases + y[0] = pow(x[0], 0.); + y[1] = pow(0., x[0]); + y[2] = pow(x[0], 1.); + y[3] = pow(1., x[0]); + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check function values + ok &= (Value(y[0]) == 1.); + ok &= (Value(y[1]) == 0.); + ok &= (Value(y[2]) == Value(x[0])); + ok &= (Value(y[3]) == 1.); + + // forward computation of first partial w.r.t. x + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= (dy[0] == 0.); + ok &= (dy[1] == 0.); + ok &= NearEqual(dy[2], 1., eps99, eps99); + ok &= (dy[3] == 0.); + + // 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.; + w[1] = 1.; + w[2] = 1.; + w[3] = 1.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], 1., eps99, eps99); - return ok; + return ok; } bool PowTestFour(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - double x0 = -2; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // 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++) - y[i] = CppAD::pow(x[0], int(i-1) ); // pow(AD, int) - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - ok &= (Value(y[0]) == 1.); - double check; - for(i = 1; i < m; i++) - { check = std::pow(x0, double(i-1)); - ok &= NearEqual(y[i], check, eps99, eps99); - } - - // forward computation of first partial w.r.t. x - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - dx[0] = 1.; - dy = f.Forward(1, dx); - ok &= (dy[0] == 0.); - double sum = 0; - for(i = 1; i < m; i++) - { if( i == 1 ) - check = 0.; - else check = double(i-1) * std::pow(x0, double(i-2)); - ok &= NearEqual(dy[i], check, eps99, eps99); - sum += check; - } - - // reverse mode computation of derivative of y[0] + .. y[m-1]; - CPPAD_TESTVECTOR(double) w(m); - CPPAD_TESTVECTOR(double) dw(n); - for(i = 0; i < m; i++) - w[i] = 1.; - dw = f.Reverse(1, w); - ok &= NearEqual(dw[0], sum, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = -2; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // 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++) + y[i] = CppAD::pow(x[0], int(i-1) ); // pow(AD, int) + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + ok &= (Value(y[0]) == 1.); + double check; + for(i = 1; i < m; i++) + { check = std::pow(x0, double(i-1)); + ok &= NearEqual(y[i], check, eps99, eps99); + } + + // forward computation of first partial w.r.t. x + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= (dy[0] == 0.); + double sum = 0; + for(i = 1; i < m; i++) + { if( i == 1 ) + check = 0.; + else + check = double(i-1) * std::pow(x0, double(i-2)); + ok &= NearEqual(dy[i], check, eps99, eps99); + sum += check; + } + + // reverse mode computation of derivative of y[0] + .. y[m-1]; + CPPAD_TESTVECTOR(double) w(m); + CPPAD_TESTVECTOR(double) dw(n); + for(i = 0; i < m; i++) + w[i] = 1.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], sum, eps99, eps99); - return ok; + return ok; } bool PowTestFive(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - double x0 = -1.; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) y(m); - - // case of zero raised to a positive integer power - double e = 2.; - y[0] = pow(x[0], int(e)); // use pow(AD, int) - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // check function value - ok &= (Value(y[0]) == pow(x0, e) ); - - // forward computation of first partial w.r.t. x[1] - double d1 = e * pow(x0, (e-1)); - CPPAD_TESTVECTOR(double) dx(n); - CPPAD_TESTVECTOR(double) dy(m); - dx[0] = 1.; - dy = f.Forward(1, dx); - ok &= NearEqual(dy[0], d1, eps99, eps99); - - // 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); - CPPAD_TESTVECTOR(double) ddw(2*n); - w[0] = 1.; - ddw = f.Reverse(2, w); - ok &= NearEqual(ddw[0], d1, eps99, eps99); - ok &= NearEqual(ddw[1], d2, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = -1.; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) y(m); + + // case of zero raised to a positive integer power + double e = 2.; + y[0] = pow(x[0], int(e)); // use pow(AD, int) + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check function value + ok &= (Value(y[0]) == pow(x0, e) ); + + // forward computation of first partial w.r.t. x[1] + double d1 = e * pow(x0, (e-1)); + CPPAD_TESTVECTOR(double) dx(n); + CPPAD_TESTVECTOR(double) dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], d1, eps99, eps99); + + // 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); + CPPAD_TESTVECTOR(double) ddw(2*n); + w[0] = 1.; + ddw = f.Reverse(2, w); + ok &= NearEqual(ddw[0], d1, eps99, eps99); + ok &= NearEqual(ddw[1], d2, eps99, eps99); - return ok; + return ok; } bool PowTestSix(void) -{ bool ok = true; +{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - double x0 = 1.5; - CPPAD_TESTVECTOR(AD) x(n); - x[0] = x0; - - // domain space vector - CPPAD_TESTVECTOR(AD< AD >) X(n); - X[0] = x[0]; - - // declare independent variables and start tape recording - CppAD::Independent(X); - - // 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); - - // create F: X -> Y and stop tape recording - CppAD::ADFun< AD > F(X, Y); - - // check function value - ok &= NearEqual(Value(Value(Y[0])), pow(x0, e), eps99, eps99); - - // forward computation of first partial w.r.t. x[1] - double d1 = e * pow(x0, (e-1)); - CPPAD_TESTVECTOR(AD) dx(n); - CPPAD_TESTVECTOR(AD) dy(m); - dx[0] = 1.; - dy = F.Forward(1, dx); - ok &= NearEqual(dy[0], d1, eps99, eps99); - - // 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); - CPPAD_TESTVECTOR(AD) ddw(2*n); - w[0] = 1.; - ddw = F.Reverse(2, w); - ok &= NearEqual(ddw[0], d1, eps99, eps99); - ok &= NearEqual(ddw[1], d2, eps99, eps99); + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = 1.5; + CPPAD_TESTVECTOR(AD) x(n); + x[0] = x0; + + // domain space vector + CPPAD_TESTVECTOR(AD< AD >) X(n); + X[0] = x[0]; + + // declare independent variables and start tape recording + CppAD::Independent(X); + + // 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); + + // create F: X -> Y and stop tape recording + CppAD::ADFun< AD > F(X, Y); + + // check function value + ok &= NearEqual(Value(Value(Y[0])), pow(x0, e), eps99, eps99); + + // forward computation of first partial w.r.t. x[1] + double d1 = e * pow(x0, (e-1)); + CPPAD_TESTVECTOR(AD) dx(n); + CPPAD_TESTVECTOR(AD) dy(m); + dx[0] = 1.; + dy = F.Forward(1, dx); + ok &= NearEqual(dy[0], d1, eps99, eps99); + + // 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); + CPPAD_TESTVECTOR(AD) ddw(2*n); + w[0] = 1.; + ddw = F.Reverse(2, w); + ok &= NearEqual(ddw[0], d1, eps99, eps99); + ok &= NearEqual(ddw[1], d2, eps99, eps99); - return ok; + return ok; } } // END empty namespace bool Pow(void) -{ bool ok = true; - ok &= PowTestOne(); - ok &= PowTestTwo(); - ok &= PowTestThree(); - ok &= PowTestFour(); - ok &= PowTestFive(); - ok &= PowTestSix(); - return ok; +{ bool ok = true; + ok &= PowTestOne(); + ok &= PowTestTwo(); + ok &= PowTestThree(); + ok &= PowTestFour(); + ok &= PowTestFive(); + ok &= PowTestSix(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/pow_int.cpp cppad-2019.02.00.0/test_more/general/pow_int.cpp --- cppad-2018.00.00.0/test_more/general/pow_int.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/pow_int.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old example now just used for validation testing. @@ -16,46 +17,46 @@ # include bool PowInt(void) -{ bool ok = true; - using CppAD::pow; - using CppAD::exp; - using CppAD::log; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(1); - U[0] = 2.; - Independent(U); - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(2); - - // dependent variable values - Z[0] = pow(U[0], 5); // x = u^5 - Z[1] = pow(U[0], -5); // y = u^{-5} - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - /* - x_u = 5 * u^4 - y_u = - 5 * u^{-6} - */ - - // check function values values - double u = Value(U[0]); - ok &= NearEqual(Z[0] , exp( log(u) * 5.), eps99 , eps99); - ok &= NearEqual(Z[1] , exp( - log(u) * 5.), eps99 , eps99); - - // forward computation of partials - v[0] = 1.; - w = f.Forward(1, v); - ok &= NearEqual(w[0] , 5. * exp( log(u) * 4.), eps99 , eps99); - ok &= NearEqual(w[1] , - 5. * exp( - log(u) * 6.), eps99 , eps99); +{ bool ok = true; + using CppAD::pow; + using CppAD::exp; + using CppAD::log; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(1); + U[0] = 2.; + Independent(U); + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(2); + + // dependent variable values + Z[0] = pow(U[0], 5); // x = u^5 + Z[1] = pow(U[0], -5); // y = u^{-5} + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + /* + x_u = 5 * u^4 + y_u = - 5 * u^{-6} + */ + + // check function values values + double u = Value(U[0]); + ok &= NearEqual(Z[0] , exp( log(u) * 5.), eps99 , eps99); + ok &= NearEqual(Z[1] , exp( - log(u) * 5.), eps99 , eps99); + + // forward computation of partials + v[0] = 1.; + w = f.Forward(1, v); + ok &= NearEqual(w[0] , 5. * exp( log(u) * 4.), eps99 , eps99); + ok &= NearEqual(w[1] , - 5. * exp( - log(u) * 6.), eps99 , eps99); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/print_for.cpp cppad-2019.02.00.0/test_more/general/print_for.cpp --- cppad-2018.00.00.0/test_more/general/print_for.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/print_for.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,84 +1,85 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // modified version of test that used to be in ../example/print_for/print_for.cpp # include namespace { - using std::endl; - using CppAD::AD; + using std::endl; + using CppAD::AD; - // use of PrintFor to check for invalid function arguments - AD check_log(const AD& y) - { // check during recording - CPPAD_ASSERT_UNKNOWN( y > 0. ); + // use of PrintFor to check for invalid function arguments + AD check_log(const AD& y) + { // check during recording + CPPAD_ASSERT_UNKNOWN( y > 0. ); - // check during zero order forward calculation - PrintFor(y, "check_log: y == ", y , " which is <= 0\n"); + // check during zero order forward calculation + PrintFor(y, "check_log: y == ", y , " which is <= 0\n"); - return log(y); - } + return log(y); + } } bool print_for(void) -{ bool ok = true; - using CppAD::PrintFor; +{ bool ok = true; + using CppAD::PrintFor; - std::stringstream stream_out; // stream that output is written to - std::string string_check; // what we expect the output to be + std::stringstream stream_out; // stream that output is written to + std::string string_check; // what we expect the output to be - // independent variable vector - size_t n = 1; - CPPAD_TESTVECTOR(AD) ax(n); - ax[0] = 1.; - Independent(ax); - - // print a VecAD::reference object that is a parameter - CppAD::VecAD av(1); - AD Zero(0); - av[Zero] = 0.; - 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) - - // A conditional print that will not generate output when x[0] = 2. - PrintFor(ax[0], "\n 2. + x[0] = ", 2. + ax[0], "\n"); - - // A conditional print that will generate output when x[0] = 2. - PrintFor(ax[0] - 2., "\n 3. + x[0] = ", 3. + ax[0], "\n"); - string_check += "\n 3. + x[0] = 5\n"; - - // A log evaluations that will result in an error message when x[0] = 2. - AD var = 2. - ax[0]; - AD log_var = check_log(var); - string_check += "check_log: y == 0 which is <= 0\n"; - - // 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); - - // zero order forward with x[0] = 2 - CPPAD_TESTVECTOR(double) x(n); - x[0] = 2.; - f.Forward(0, x, stream_out); - - std::string string_out = stream_out.str(); - ok &= string_out == string_check; - return ok; + // independent variable vector + size_t n = 1; + CPPAD_TESTVECTOR(AD) ax(n); + ax[0] = 1.; + Independent(ax); + + // print a VecAD::reference object that is a parameter + CppAD::VecAD av(1); + AD Zero(0); + av[Zero] = 0.; + 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) + + // A conditional print that will not generate output when x[0] = 2. + PrintFor(ax[0], "\n 2. + x[0] = ", 2. + ax[0], "\n"); + + // A conditional print that will generate output when x[0] = 2. + PrintFor(ax[0] - 2., "\n 3. + x[0] = ", 3. + ax[0], "\n"); + string_check += "\n 3. + x[0] = 5\n"; + + // A log evaluations that will result in an error message when x[0] = 2. + AD var = 2. - ax[0]; + AD log_var = check_log(var); + string_check += "check_log: y == 0 which is <= 0\n"; + + // 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); + + // zero order forward with x[0] = 2 + CPPAD_TESTVECTOR(double) x(n); + x[0] = 2.; + f.Forward(0, x, stream_out); + + std::string string_out = stream_out.str(); + ok &= string_out == string_check; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/reverse.cpp cppad-2019.02.00.0/test_more/general/reverse.cpp --- cppad-2018.00.00.0/test_more/general/reverse.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/reverse.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old Reverse example now used just for valiadation testing @@ -17,196 +18,196 @@ namespace { // ---------------------------------------------------------- bool reverse_one(void) -{ bool ok = true; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(3); - U[0] = 0.; U[1] = 1.; U[2] = 2.; - Independent(U); - - // compute sum and product of elements in U - AD Sum = 0.; - AD Prod = 1.; - size_t i; - for(i = 0; i < 3; i++) - { Sum += U[i]; - Prod *= U[i]; - } - - // dependent variable vector - CPPAD_TESTVECTOR(AD) V(2); - V[0] = Sum; - V[1] = Prod; - - // V = f(U) - ADFun f(U, V); - - // Evaluate ( v[0] * f_0 + v[1] * f_1 )^(1) [ u0 ] --------------- - size_t p = 1; - CPPAD_TESTVECTOR(double) v( f.Range() ); - CPPAD_TESTVECTOR(double) u0( f.Domain() ); - CPPAD_TESTVECTOR(double) r1( f.Domain() * p ); - - v[0] = 1.; v[1] = -1.; - r1 = f.Reverse(p, v); - - // direct evaluation of gradients of components of f - CPPAD_TESTVECTOR(double) g0(3), g1(3); - u0[0] = Value(U[0]); u0[1] = Value(U[1]); u0[2] = Value(U[2]); - g0[0] = 1.; g0[1] = 1.; g0[2] = 1.; - g1[0] = u0[1]*u0[2]; g1[1] = u0[0]*u0[2]; g1[2] = u0[0]*u0[1]; - - // compare values - for(i = 0; i < 3; i++) - { ok &= NearEqual(r1[i] , - v[0] * g0[i] + v[1] * g1[i], eps99, eps99); - } - - // ------------------------------------------------------------------- - - // Define the function z(t, u0, u1) = f( u0 + u1 * t ) and evaluate - // the first order Taylor coefficient column vector z(*, u0, u1) - p = 1; - CPPAD_TESTVECTOR(double) u1( f.Domain() ); - - u1[0] = 2.; u1[1] = -1.; u1[2] = 3.; - f.Forward(p, u1); - - // Evaluate the derivaties with respect to u0 of the functions - // order 0: v[0] * z_0 (0, u0, u1) + v[1] * z_1 (0, u0, u1) - // order 1: v[0] * d/dt z_0 (0, u0, u1) + v[1] * d/dt z_1 (0, u0, u1) - p = 2; - CPPAD_TESTVECTOR(double) r2( f.Domain() * p ); - v[0] = -.5; v[1] = .5; - r2 = f.Reverse(p, v); - - // check derivative of the zero order term - for(i = 0; i < 3; i++) - { ok &= NearEqual(r2[p * i + 0] , - v[0] * g0[i] + v[1] * g1[i], eps99, eps99); - } - - /* - 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 - ei * f_j^{(2)} ( u0 ) * u1 - */ - - - // direct evaluation of the Hessian f_1^{(2)} (u0) - // (the Hessian f_0^{(2)} is identically zero) - CPPAD_TESTVECTOR(double) H1(9); - H1[0] = 0.; H1[1] = u0[2]; H1[2] = u0[1]; - H1[3] = u0[2]; H1[4] = 0.; H1[5] = u0[0]; - H1[6] = u0[1]; H1[7] = u0[0]; H1[8] = 0.; - - - size_t j; - for(i = 0; i < 3; i++) - { double sum = 0.; - for(j = 0; j < 3; j++) - sum += H1[i * 3 + j] * u1[j]; - - // note term corresponding to v[0] is zero - ok &= NearEqual(r2[p * i + 1], v[1] * sum, eps99, eps99); - } +{ bool ok = true; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(3); + U[0] = 0.; U[1] = 1.; U[2] = 2.; + Independent(U); + + // compute sum and product of elements in U + AD Sum = 0.; + AD Prod = 1.; + size_t i; + for(i = 0; i < 3; i++) + { Sum += U[i]; + Prod *= U[i]; + } + + // dependent variable vector + CPPAD_TESTVECTOR(AD) V(2); + V[0] = Sum; + V[1] = Prod; + + // V = f(U) + ADFun f(U, V); + + // Evaluate ( v[0] * f_0 + v[1] * f_1 )^(1) [ u0 ] --------------- + size_t p = 1; + CPPAD_TESTVECTOR(double) v( f.Range() ); + CPPAD_TESTVECTOR(double) u0( f.Domain() ); + CPPAD_TESTVECTOR(double) r1( f.Domain() * p ); + + v[0] = 1.; v[1] = -1.; + r1 = f.Reverse(p, v); + + // direct evaluation of gradients of components of f + CPPAD_TESTVECTOR(double) g0(3), g1(3); + u0[0] = Value(U[0]); u0[1] = Value(U[1]); u0[2] = Value(U[2]); + g0[0] = 1.; g0[1] = 1.; g0[2] = 1.; + g1[0] = u0[1]*u0[2]; g1[1] = u0[0]*u0[2]; g1[2] = u0[0]*u0[1]; + + // compare values + for(i = 0; i < 3; i++) + { ok &= NearEqual(r1[i] , + v[0] * g0[i] + v[1] * g1[i], eps99, eps99); + } + + // ------------------------------------------------------------------- + + // Define the function z(t, u0, u1) = f( u0 + u1 * t ) and evaluate + // the first order Taylor coefficient column vector z(*, u0, u1) + p = 1; + CPPAD_TESTVECTOR(double) u1( f.Domain() ); + + u1[0] = 2.; u1[1] = -1.; u1[2] = 3.; + f.Forward(p, u1); + + // Evaluate the derivaties with respect to u0 of the functions + // order 0: v[0] * z_0 (0, u0, u1) + v[1] * z_1 (0, u0, u1) + // order 1: v[0] * d/dt z_0 (0, u0, u1) + v[1] * d/dt z_1 (0, u0, u1) + p = 2; + CPPAD_TESTVECTOR(double) r2( f.Domain() * p ); + v[0] = -.5; v[1] = .5; + r2 = f.Reverse(p, v); + + // check derivative of the zero order term + for(i = 0; i < 3; i++) + { ok &= NearEqual(r2[p * i + 0] , + v[0] * g0[i] + v[1] * g1[i], eps99, eps99); + } + + /* + 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 + ei * f_j^{(2)} ( u0 ) * u1 + */ + + + // direct evaluation of the Hessian f_1^{(2)} (u0) + // (the Hessian f_0^{(2)} is identically zero) + CPPAD_TESTVECTOR(double) H1(9); + H1[0] = 0.; H1[1] = u0[2]; H1[2] = u0[1]; + H1[3] = u0[2]; H1[4] = 0.; H1[5] = u0[0]; + H1[6] = u0[1]; H1[7] = u0[0]; H1[8] = 0.; + + + size_t j; + for(i = 0; i < 3; i++) + { double sum = 0.; + for(j = 0; j < 3; j++) + sum += H1[i * 3 + j] * u1[j]; + + // note term corresponding to v[0] is zero + ok &= NearEqual(r2[p * i + 1], v[1] * sum, eps99, eps99); + } - return ok; + return ok; } // define the template function reverse_any_cases in empty namespace -template +template bool reverse_any_cases(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 0.; - X[1] = 1.; - X[2] = 2.; - - // declare independent variables and start recording - CppAD::Independent(X); - - // range space vector - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0] * X[1] * X[2]; - - // create f : X -> Y and stop recording - CppAD::ADFun f(X, Y); - - // define W(t, u) = (u_0 + dx_0*t)*(u_1 + dx_1*t)*(u_2 + dx_2*t) - // use zero order forward to evaluate W0(u) = W(0, u) - Vector u(n), W0(m); - u[0] = 2.; - u[1] = 3.; - u[2] = 4.; - W0 = f.Forward(0, u); - double check; - check = u[0]*u[1]*u[2]; - ok &= NearEqual(W0[0] , check, eps99, eps99); - - // define W_t(t, u) = partial W(t, u) w.r.t t - // W_t(t, u) = (u_0 + dx_0*t)*(u_1 + dx_1*t)*dx_2 - // + (u_0 + dx_0*t)*(u_2 + dx_2*t)*dx_1 - // + (u_1 + dx_1*t)*(u_2 + dx_2*t)*dx_0 - // use first order forward mode to evaluate W1(u) = W_t(0, u) - Vector dx(n), W1(m); - dx[0] = .2; - dx[1] = .3; - dx[2] = .4; - W1 = f.Forward(1, dx); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 0.; + X[1] = 1.; + X[2] = 2.; + + // declare independent variables and start recording + CppAD::Independent(X); + + // range space vector + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0] * X[1] * X[2]; + + // create f : X -> Y and stop recording + CppAD::ADFun f(X, Y); + + // define W(t, u) = (u_0 + dx_0*t)*(u_1 + dx_1*t)*(u_2 + dx_2*t) + // use zero order forward to evaluate W0(u) = W(0, u) + Vector u(n), W0(m); + u[0] = 2.; + u[1] = 3.; + u[2] = 4.; + W0 = f.Forward(0, u); + double check; + check = u[0]*u[1]*u[2]; + ok &= NearEqual(W0[0] , check, eps99, eps99); + + // define W_t(t, u) = partial W(t, u) w.r.t t + // W_t(t, u) = (u_0 + dx_0*t)*(u_1 + dx_1*t)*dx_2 + // + (u_0 + dx_0*t)*(u_2 + dx_2*t)*dx_1 + // + (u_1 + dx_1*t)*(u_2 + dx_2*t)*dx_0 + // use first order forward mode to evaluate W1(u) = W_t(0, u) + Vector dx(n), W1(m); + dx[0] = .2; + dx[1] = .3; + dx[2] = .4; + W1 = f.Forward(1, dx); check = u[0]*u[1]*dx[2] + u[0]*u[2]*dx[1] + u[1]*u[2]*dx[0]; - ok &= NearEqual(W1[0], check, eps99, eps99); + ok &= NearEqual(W1[0], check, eps99, eps99); - // define W_tt (t, u) = partial W_t(t, u) w.r.t t - // W_tt(t, u) = 2*(u_0 + dx_0*t)*dx_1*dx_2 - // + 2*(u_1 + dx_1*t)*dx_0*dx_2 - // + 2*(u_3 + dx_3*t)*dx_0*dx_1 - // use second order forward to evaluate W2(u) = 1/2 * W_tt(0, u) - Vector ddx(n), W2(m); - ddx[0] = ddx[1] = ddx[2] = 0.; + // define W_tt (t, u) = partial W_t(t, u) w.r.t t + // W_tt(t, u) = 2*(u_0 + dx_0*t)*dx_1*dx_2 + // + 2*(u_1 + dx_1*t)*dx_0*dx_2 + // + 2*(u_3 + dx_3*t)*dx_0*dx_1 + // use second order forward to evaluate W2(u) = 1/2 * W_tt(0, u) + Vector ddx(n), W2(m); + ddx[0] = ddx[1] = ddx[2] = 0.; W2 = f.Forward(2, ddx); check = u[0]*dx[1]*dx[2] + u[1]*dx[0]*dx[2] + u[2]*dx[0]*dx[1]; - ok &= NearEqual(W2[0], check, eps99, eps99); + ok &= NearEqual(W2[0], check, eps99, eps99); - // use third order reverse mode to evaluate derivatives - size_t p = 3; - Vector w(m), dw(n * p); - w[0] = 1.; - dw = f.Reverse(p, w); - - // check derivative of W0(u) w.r.t. u - ok &= NearEqual(dw[0*p+0], u[1]*u[2], eps99, eps99); - ok &= NearEqual(dw[1*p+0], u[0]*u[2], eps99, eps99); - ok &= NearEqual(dw[2*p+0], u[0]*u[1], eps99, eps99); - - // check derivative of W1(u) w.r.t. u - ok &= NearEqual(dw[0*p+1], u[1]*dx[2] + u[2]*dx[1], eps99, eps99); - ok &= NearEqual(dw[1*p+1], u[0]*dx[2] + u[2]*dx[0], eps99, eps99); - ok &= NearEqual(dw[2*p+1], u[0]*dx[1] + u[1]*dx[0], eps99, eps99); - - // check derivative of W2(u) w.r.t u - ok &= NearEqual(dw[0*p+2], dx[1]*dx[2], eps99, eps99); - ok &= NearEqual(dw[1*p+2], dx[0]*dx[2], eps99, eps99); - ok &= NearEqual(dw[2*p+2], dx[0]*dx[1], eps99, eps99); + // use third order reverse mode to evaluate derivatives + size_t p = 3; + Vector w(m), dw(n * p); + w[0] = 1.; + dw = f.Reverse(p, w); + + // check derivative of W0(u) w.r.t. u + ok &= NearEqual(dw[0*p+0], u[1]*u[2], eps99, eps99); + ok &= NearEqual(dw[1*p+0], u[0]*u[2], eps99, eps99); + ok &= NearEqual(dw[2*p+0], u[0]*u[1], eps99, eps99); + + // check derivative of W1(u) w.r.t. u + ok &= NearEqual(dw[0*p+1], u[1]*dx[2] + u[2]*dx[1], eps99, eps99); + ok &= NearEqual(dw[1*p+1], u[0]*dx[2] + u[2]*dx[0], eps99, eps99); + ok &= NearEqual(dw[2*p+1], u[0]*dx[1] + u[1]*dx[0], eps99, eps99); + + // check derivative of W2(u) w.r.t u + ok &= NearEqual(dw[0*p+2], dx[1]*dx[2], eps99, eps99); + ok &= NearEqual(dw[1*p+2], dx[0]*dx[2], eps99, eps99); + ok &= NearEqual(dw[2*p+2], dx[0]*dx[1], eps99, eps99); - return ok; + return ok; } /* $comment reverse_checkpoint.cpp$$ $spell - Taylor + Taylor $$ $section Reverse Mode General Case: Example and Test$$ @@ -231,13 +232,13 @@ $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) - \; , \; - G(y) = \left( \begin{array}{c} y_0 - y_1 \\ y_1 y_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) \] $$ Another difference is that in actual applications, the memory corresponding to function objects not currently being used -is sometimes returned to the system (see $cref checkpoint.cpp$$). +is sometimes returned to the system (see $cref/checkpoint/chkpoint_one/.cpp$$). $head Processing Steps$$ We apply reverse mode to compute the derivative of @@ -245,12 +246,12 @@ is defined by $latex \[ \begin{array}{rcl} - 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 ( 1 - x_0 + x_1 ) - x_1 + x_0 + 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 ( 1 - x_0 + x_1 ) - x_1 + x_0 \end{array} \] $$ Given the zero and first order Taylor coefficients @@ -259,15 +260,15 @@ for the corresponding functions; i.e., $latex \[ \begin{array}{rcl} - X(t) & = & x^{(0)} + x^{(1)} t - \\ - Y(t) & = & F[X(t)] = y^{(0)} + y^{(1)} t + O(t^2) - \\ - Z(t) & = & G \{ F [ X(t) ] \} = z^{(0)} + z^{(1)} t + O(t^2) - \\ - h^{(0)} & = & z^{(0)}_0 + z^{(0)}_1 - \\ - h^{(1)} & = & z^{(1)}_0 + z^{(1)}_1 + X(t) & = & x^{(0)} + x^{(1)} t + \\ + Y(t) & = & F[X(t)] = y^{(0)} + y^{(1)} t + O(t^2) + \\ + Z(t) & = & G \{ F [ X(t) ] \} = z^{(0)} + z^{(1)} t + O(t^2) + \\ + h^{(0)} & = & z^{(0)}_0 + z^{(0)}_1 + \\ + h^{(1)} & = & z^{(1)}_0 + z^{(1)}_1 \end{array} \] $$ Here are the processing steps: @@ -289,23 +290,23 @@ This uses the following relations for $latex k = 0 , 1$$: $latex \[ \begin{array}{rcl} - \partial_{x(0)} h^{(k)} [ x^{(0)} , x^{(1)} ] - & = & - \partial_{y(0)} h^{(k)} [ y^{(0)} , y^{(1)} ] - \partial_{x(0)} y^{(0)} [ x^{(0)} , x^{(1)} ] - \\ - & + & - \partial_{y(1)} h^{(k)} [ y^{(0)} , y^{(1)} ] - \partial_{x(0)} y^{(1)} [ x^{(0)} , x^{(1)} ] - \\ - \partial_{x(1)} h^{(k)} [ x^{(0)} , x^{(1)} ] - & = & - \partial_{y(0)} h^{(k)} [ y^{(0)} , y^{(1)} ] - \partial_{x(1)} y^{(0)} [ x^{(0)} , x^{(1)} ] - \\ - & + & - \partial_{y(1)} h^{(k)} [ y^{(0)} , y^{(1)} ] - \partial_{x(1)} y^{(1)} [ x^{(0)} , x^{(1)} ] + \partial_{x(0)} h^{(k)} [ x^{(0)} , x^{(1)} ] + & = & + \partial_{y(0)} h^{(k)} [ y^{(0)} , y^{(1)} ] + \partial_{x(0)} y^{(0)} [ x^{(0)} , x^{(1)} ] + \\ + & + & + \partial_{y(1)} h^{(k)} [ y^{(0)} , y^{(1)} ] + \partial_{x(0)} y^{(1)} [ x^{(0)} , x^{(1)} ] + \\ + \partial_{x(1)} h^{(k)} [ x^{(0)} , x^{(1)} ] + & = & + \partial_{y(0)} h^{(k)} [ y^{(0)} , y^{(1)} ] + \partial_{x(1)} y^{(0)} [ x^{(0)} , x^{(1)} ] + \\ + & + & + \partial_{y(1)} h^{(k)} [ y^{(0)} , y^{(1)} ] + \partial_{x(1)} y^{(1)} [ x^{(0)} , x^{(1)} ] \end{array} \] $$ where $latex \partial_{x(0)}$$ denotes the partial with respect @@ -318,137 +319,137 @@ */ template Vector F_reverse_mul(const Vector& x) -{ Vector y(2); - y[0] = x[0] * x[1]; - y[1] = x[1] - x[0]; - return y; +{ Vector y(2); + y[0] = x[0] * x[1]; + y[1] = x[1] - x[0]; + return y; } template Vector G_reverse_mul(const Vector& y) -{ Vector z(2); - z[0] = y[0] - y[1]; - z[1] = y[1] * y[0]; - return z; +{ Vector z(2); + z[0] = y[0] - y[1]; + z[1] = y[1] * y[0]; + return z; } bool reverse_mul(void) { - bool ok = true; - double eps = 10. * CppAD::numeric_limits::epsilon(); + bool ok = true; + double eps = 10. * CppAD::numeric_limits::epsilon(); - using CppAD::AD; - using CppAD::NearEqual; - CppAD::ADFun f, g; - - // Record the function F(x) - size_t n = 2; - CPPAD_TESTVECTOR(AD) X(n), Y(n); - X[0] = X[1] = 0.; - CppAD::Independent(X); - Y = F_reverse_mul(X); - f.Dependent(X, Y); - - // Record the function G(x) - CPPAD_TESTVECTOR(AD) Z(n); - Y[0] = Y[1] = 0.; - CppAD::Independent(Y); - Z = G_reverse_mul(Y); - g.Dependent(Y, Z); - - // argument and function values - CPPAD_TESTVECTOR(double) x0(n), y0(n), z0(n); - x0[0] = 1.; - x0[1] = 2.; - y0 = f.Forward(0, x0); - z0 = g.Forward(0, y0); - - // check function value - double check = x0[0] * x0[1] * (1. - x0[0] + x0[1]) - x0[1] + x0[0]; - double h0 = z0[0] + z0[1]; - ok &= NearEqual(h0, check, eps, eps); - - // first order Taylor coefficients - CPPAD_TESTVECTOR(double) x1(n), y1(n), z1(n); - x1[0] = 3.; - x1[1] = 4.; - y1 = f.Forward(1, x1); - z1 = g.Forward(1, y1); - - // check first order Taylor coefficients - check = x0[0] * x0[1] * (- x1[0] + x1[1]) - x1[1] + x1[0]; - check += x1[0] * x0[1] * (1. - x0[0] + x0[1]); - check += x0[0] * x1[1] * (1. - x0[0] + x0[1]); - double h1 = z1[0] + z1[1]; - ok &= NearEqual(h1, check, eps, eps); - - // ---------------------------------------------------------------- - // dw^0 (y) = \partial_y^0 h^0 (y) - // dw^1 (y) = \partial_y^1 h^0 (y) - size_t p = 2; - CPPAD_TESTVECTOR(double) w(n*p), dw(n*p); - 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 - 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) - CPPAD_TESTVECTOR(double) dv(n*p); - 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.; - check -= x0[0] * x0[1]; - ok &= NearEqual(dv[0*p+0], check, eps, eps); - - // check partial of h^0 w.r.t x^0_1 - check = x0[0] * (1. - x0[0] + x0[1]) - 1.; - check += x0[0] * x0[1]; - ok &= NearEqual(dv[1*p+0], check, eps, eps); - - // check partial of h^0 w.r.t x^1_0 and x^1_1 - check = 0.; - ok &= NearEqual(dv[0*p+1], check, eps, eps); - ok &= NearEqual(dv[1*p+1], check, eps, eps); - - // ---------------------------------------------------------------- - // dw^0 (y) = \partial_y^0 h^1 (y) - // dw^1 (y) = \partial_y^1 h^1 (y) - 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 - 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); - - // check partial of h^1 w.r.t x^0_0 - check = x0[1] * (- x1[0] + x1[1]); - check -= x1[0] * x0[1]; - check += x1[1] * (1. - x0[0] + x0[1]) - x0[0] * x1[1]; - ok &= NearEqual(dv[0*p+0], check, eps, eps); - - // 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 += x0[0] * x1[1]; - ok &= NearEqual(dv[1*p+0], check, eps, eps); - - // check partial of h^1 w.r.t x^1_0 - // (by reverse mode identity is equal to partial h^0 w.r.t. x^0_0) - check = 1. - x0[0] * x0[1]; - check += x0[1] * (1. - x0[0] + x0[1]); - ok &= NearEqual(dv[0*p+1], check, eps, eps); - - // check partial of h^1 w.r.t x^1_1 - // (by reverse mode identity is equal to partial h^0 w.r.t. x^0_1) - check = x0[0] * x0[1] - 1.; - check += x0[0] * (1. - x0[0] + x0[1]); - ok &= NearEqual(dv[1*p+1], check, eps, eps); + using CppAD::AD; + using CppAD::NearEqual; + CppAD::ADFun f, g; + + // Record the function F(x) + size_t n = 2; + CPPAD_TESTVECTOR(AD) X(n), Y(n); + X[0] = X[1] = 0.; + CppAD::Independent(X); + Y = F_reverse_mul(X); + f.Dependent(X, Y); + + // Record the function G(x) + CPPAD_TESTVECTOR(AD) Z(n); + Y[0] = Y[1] = 0.; + CppAD::Independent(Y); + Z = G_reverse_mul(Y); + g.Dependent(Y, Z); + + // argument and function values + CPPAD_TESTVECTOR(double) x0(n), y0(n), z0(n); + x0[0] = 1.; + x0[1] = 2.; + y0 = f.Forward(0, x0); + z0 = g.Forward(0, y0); + + // check function value + double check = x0[0] * x0[1] * (1. - x0[0] + x0[1]) - x0[1] + x0[0]; + double h0 = z0[0] + z0[1]; + ok &= NearEqual(h0, check, eps, eps); + + // first order Taylor coefficients + CPPAD_TESTVECTOR(double) x1(n), y1(n), z1(n); + x1[0] = 3.; + x1[1] = 4.; + y1 = f.Forward(1, x1); + z1 = g.Forward(1, y1); + + // check first order Taylor coefficients + check = x0[0] * x0[1] * (- x1[0] + x1[1]) - x1[1] + x1[0]; + check += x1[0] * x0[1] * (1. - x0[0] + x0[1]); + check += x0[0] * x1[1] * (1. - x0[0] + x0[1]); + double h1 = z1[0] + z1[1]; + ok &= NearEqual(h1, check, eps, eps); + + // ---------------------------------------------------------------- + // dw^0 (y) = \partial_y^0 h^0 (y) + // dw^1 (y) = \partial_y^1 h^0 (y) + size_t p = 2; + CPPAD_TESTVECTOR(double) w(n*p), dw(n*p); + 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 + 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) + CPPAD_TESTVECTOR(double) dv(n*p); + 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.; + check -= x0[0] * x0[1]; + ok &= NearEqual(dv[0*p+0], check, eps, eps); + + // check partial of h^0 w.r.t x^0_1 + check = x0[0] * (1. - x0[0] + x0[1]) - 1.; + check += x0[0] * x0[1]; + ok &= NearEqual(dv[1*p+0], check, eps, eps); + + // check partial of h^0 w.r.t x^1_0 and x^1_1 + check = 0.; + ok &= NearEqual(dv[0*p+1], check, eps, eps); + ok &= NearEqual(dv[1*p+1], check, eps, eps); + + // ---------------------------------------------------------------- + // dw^0 (y) = \partial_y^0 h^1 (y) + // dw^1 (y) = \partial_y^1 h^1 (y) + 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 + 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); + + // check partial of h^1 w.r.t x^0_0 + check = x0[1] * (- x1[0] + x1[1]); + check -= x1[0] * x0[1]; + check += x1[1] * (1. - x0[0] + x0[1]) - x0[0] * x1[1]; + ok &= NearEqual(dv[0*p+0], check, eps, eps); + + // 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 += x0[0] * x1[1]; + ok &= NearEqual(dv[1*p+0], check, eps, eps); + + // check partial of h^1 w.r.t x^1_0 + // (by reverse mode identity is equal to partial h^0 w.r.t. x^0_0) + check = 1. - x0[0] * x0[1]; + check += x0[1] * (1. - x0[0] + x0[1]); + ok &= NearEqual(dv[0*p+1], check, eps, eps); + + // check partial of h^1 w.r.t x^1_1 + // (by reverse mode identity is equal to partial h^0 w.r.t. x^0_1) + check = x0[0] * x0[1] - 1.; + check += x0[0] * (1. - x0[0] + x0[1]); + ok &= NearEqual(dv[1*p+1], check, eps, eps); - return ok; + return ok; } // ---------------------------------------------------------------------------- } // End empty namespace @@ -456,12 +457,12 @@ # include # include bool reverse(void) -{ bool ok = true; - ok &= reverse_one(); - ok &= reverse_mul(); - - ok &= reverse_any_cases< CppAD::vector >(); - ok &= reverse_any_cases< std::vector >(); - ok &= reverse_any_cases< std::valarray >(); - return ok; +{ bool ok = true; + ok &= reverse_one(); + ok &= reverse_mul(); + + ok &= reverse_any_cases< CppAD::vector >(); + ok &= reverse_any_cases< std::vector >(); + ok &= reverse_any_cases< std::valarray >(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/rev_sparse_jac.cpp cppad-2019.02.00.0/test_more/general/rev_sparse_jac.cpp --- cppad-2018.00.00.0/test_more/general/rev_sparse_jac.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/rev_sparse_jac.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include @@ -15,510 +16,510 @@ # include # define CheckOp(Op) \ - Y[index] = X[0] Op 2.; \ - Check[index * n + 0] = true; \ - Check[index * n + 1] = false; \ - Check[index * n + 2] = false; \ - index++; \ - Y[index] = X[0] Op X[1]; \ - Check[index * n + 0] = true; \ - Check[index * n + 1] = true; \ - Check[index * n + 2] = false; \ - index++; \ - Y[index] = 3. Op X[1]; \ - Check[index * n + 0] = false; \ - Check[index * n + 1] = true; \ - Check[index * n + 2] = false; \ - index++; + Y[index] = X[0] Op 2.; \ + Check[index * n + 0] = true; \ + Check[index * n + 1] = false; \ + Check[index * n + 2] = false; \ + index++; \ + Y[index] = X[0] Op X[1]; \ + Check[index * n + 0] = true; \ + Check[index * n + 1] = true; \ + Check[index * n + 2] = false; \ + index++; \ + Y[index] = 3. Op X[1]; \ + Check[index * n + 0] = false; \ + Check[index * n + 1] = true; \ + Check[index * n + 2] = false; \ + index++; # define CheckUnaryFun(Fun) \ - Y[index] = Fun(X[0]); \ - Check[index * n + 0] = true; \ - Check[index * n + 1] = false; \ - Check[index * n + 2] = false; \ - index++; \ - Y[index] = Fun(X[0] + X[1]); \ - Check[index * n + 0] = true; \ - Check[index * n + 1] = true; \ - Check[index * n + 2] = false; \ - index++; \ - Y[index] = Fun(X[1]); \ - Check[index * n + 0] = false; \ - Check[index * n + 1] = true; \ - Check[index * n + 2] = false; \ - index++; + Y[index] = Fun(X[0]); \ + Check[index * n + 0] = true; \ + Check[index * n + 1] = false; \ + Check[index * n + 2] = false; \ + index++; \ + Y[index] = Fun(X[0] + X[1]); \ + Check[index * n + 0] = true; \ + Check[index * n + 1] = true; \ + Check[index * n + 2] = false; \ + index++; \ + Y[index] = Fun(X[1]); \ + Check[index * n + 0] = false; \ + Check[index * n + 1] = true; \ + Check[index * n + 2] = false; \ + index++; # define CheckBinaryFun(Fun) \ - Y[index] = Fun( X[0] , 2.); \ - Check[index * n + 0] = true; \ - Check[index * n + 1] = false; \ - Check[index * n + 2] = false; \ - index++; \ - Y[index] = Fun( X[0] , X[1]); \ - Check[index * n + 0] = true; \ - Check[index * n + 1] = true; \ - Check[index * n + 2] = false; \ - index++; \ - Y[index] = Fun( 3. , X[1]); \ - Check[index * n + 0] = false; \ - Check[index * n + 1] = true; \ - Check[index * n + 2] = false; \ - index++; + Y[index] = Fun( X[0] , 2.); \ + Check[index * n + 0] = true; \ + Check[index * n + 1] = false; \ + Check[index * n + 2] = false; \ + index++; \ + Y[index] = Fun( X[0] , X[1]); \ + Check[index * n + 0] = true; \ + Check[index * n + 1] = true; \ + Check[index * n + 2] = false; \ + index++; \ + Y[index] = Fun( 3. , X[1]); \ + Check[index * n + 0] = false; \ + Check[index * n + 1] = true; \ + Check[index * n + 2] = false; \ + index++; namespace { // BEGIN empty namespace bool case_one() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 3; + // dimension of the domain space + size_t n = 3; - // dimension of the range space - size_t m = (4 + 11 + 1) * 3 + 4; + // dimension of the range space + size_t m = (4 + 11 + 1) * 3 + 4; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - X[0] = .1; - X[1] = .2; - X[2] = .3; - Independent(X); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(m); - - // check results vector - CPPAD_TESTVECTOR( bool ) Check(m * n); - - // initialize index into Y - size_t index = 0; - - // 4 binary operators - CheckOp(+); - CheckOp(-); - CheckOp(*); - CheckOp(/); - - // 11 unary functions - CheckUnaryFun(abs); - CheckUnaryFun(acos); - CheckUnaryFun(asin); - CheckUnaryFun(atan); - CheckUnaryFun(cos); - CheckUnaryFun(cosh); - CheckUnaryFun(exp); - CheckUnaryFun(log); - CheckUnaryFun(sin); - CheckUnaryFun(sinh); - CheckUnaryFun(sqrt); - - // 1 binary function - CheckBinaryFun(pow); - - // conditional expression - Y[index] = CondExpLt(X[0], X[1], X[0], AD(2.)); - Check[index * n + 0] = true; - Check[index * n + 1] = false; - Check[index * n + 2] = false; - index++; - Y[index] = CondExpLt(X[0], X[1], X[0], X[1]); - Check[index * n + 0] = true; - Check[index * n + 1] = true; - Check[index * n + 2] = false; - index++; - Y[index] = CondExpLt(X[0], X[1], AD(3.), X[1]); - Check[index * n + 0] = false; - Check[index * n + 1] = true; - Check[index * n + 2] = false; - index++; - - // non-trival composition - Y[index] = Y[0] + Y[1] + X[2]; - Check[index * n + 0] = true; - 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); - - // -------------------------------------------------------- - // dependency matrix for the identity function U(y) = y - CPPAD_TESTVECTOR( bool ) Py(m * m); - size_t i, j; - for(i = 0; i < m; i++) - { for(j = 0; j < m; j++) - Py[ i * m + j ] = false; - Py[ i * m + i ] = true; - } - - // evaluate the dependency matrix for F(x) - CPPAD_TESTVECTOR( 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]); - } - // -------------------------------------------------------- - // dependency matrix for the identity function U(y) = y - CPPAD_TESTVECTOR(std::set) Sy(m); - for(i = 0; i < m; i++) - { assert( Sy[i].empty() ); - Sy[i].insert(i); - } - - // evaluate the dependency matrix for U(F(x)) - CPPAD_TESTVECTOR(std::set) Sx(m); - Sx = F.RevSparseJac(m, Sy); - - // check values - std::set::iterator itr; - bool found; - 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]); - } - } + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + X[0] = .1; + X[1] = .2; + X[2] = .3; + Independent(X); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(m); + + // check results vector + CPPAD_TESTVECTOR( bool ) Check(m * n); + + // initialize index into Y + size_t index = 0; + + // 4 binary operators + CheckOp(+); + CheckOp(-); + CheckOp(*); + CheckOp(/); + + // 11 unary functions + CheckUnaryFun(abs); + CheckUnaryFun(acos); + CheckUnaryFun(asin); + CheckUnaryFun(atan); + CheckUnaryFun(cos); + CheckUnaryFun(cosh); + CheckUnaryFun(exp); + CheckUnaryFun(log); + CheckUnaryFun(sin); + CheckUnaryFun(sinh); + CheckUnaryFun(sqrt); + + // 1 binary function + CheckBinaryFun(pow); + + // conditional expression + Y[index] = CondExpLt(X[0], X[1], X[0], AD(2.)); + Check[index * n + 0] = true; + Check[index * n + 1] = false; + Check[index * n + 2] = false; + index++; + Y[index] = CondExpLt(X[0], X[1], X[0], X[1]); + Check[index * n + 0] = true; + Check[index * n + 1] = true; + Check[index * n + 2] = false; + index++; + Y[index] = CondExpLt(X[0], X[1], AD(3.), X[1]); + Check[index * n + 0] = false; + Check[index * n + 1] = true; + Check[index * n + 2] = false; + index++; + + // non-trival composition + Y[index] = Y[0] + Y[1] + X[2]; + Check[index * n + 0] = true; + 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); + + // -------------------------------------------------------- + // dependency matrix for the identity function U(y) = y + CPPAD_TESTVECTOR( bool ) Py(m * m); + size_t i, j; + for(i = 0; i < m; i++) + { for(j = 0; j < m; j++) + Py[ i * m + j ] = false; + Py[ i * m + i ] = true; + } + + // evaluate the dependency matrix for F(x) + CPPAD_TESTVECTOR( 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]); + } + // -------------------------------------------------------- + // dependency matrix for the identity function U(y) = y + CPPAD_TESTVECTOR(std::set) Sy(m); + for(i = 0; i < m; i++) + { assert( Sy[i].empty() ); + Sy[i].insert(i); + } + + // evaluate the dependency matrix for U(F(x)) + CPPAD_TESTVECTOR(std::set) Sx(m); + Sx = F.RevSparseJac(m, Sy); + + // check values + std::set::iterator itr; + bool found; + 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]); + } + } - return ok; + return ok; } bool case_two() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 3; + // dimension of the domain space + size_t n = 3; - // dimension of the range space - size_t m = 3; + // dimension of the range space + size_t m = 3; - // inialize the vector as zero - CppAD::VecAD Z(n - 1); - size_t k; - for(k = 0; k < n-1; k++) - Z[k] = 0.; - - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - 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]; - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(m); - - // check results vector - CPPAD_TESTVECTOR( bool ) Check(m * n); - - // initialize index into Y - size_t index = 0; - - // First component only depends on X[0]; - Y[index] = X[0]; - Check[index * n + 0] = true; - Check[index * n + 1] = false; - Check[index * n + 2] = false; - index++; - - // Second component depends on the vector Z - AD zero(0); - Y[index] = Z[zero]; // Load by a parameter - Check[index * n + 0] = false; - Check[index * n + 1] = true; - Check[index * n + 2] = true; - index++; - - // Third component depends on the vector Z - Y[index] = Z[ X[0] ]; // Load by a variable - 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); - - // dependency matrix for the identity function S(y) = y - CPPAD_TESTVECTOR( bool ) Py(m * m); - size_t i, j; - for(i = 0; i < m; i++) - { for(j = 0; j < m; j++) - Py[ i * m + j ] = false; - Py[ i * m + i ] = true; - } - - // evaluate the dependency matrix for S [ F(x) ] - CPPAD_TESTVECTOR( 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]); - } - // -------------------------------------------------------- - // dependency matrix for the identity function U(y) = y - CPPAD_TESTVECTOR(std::set) Sy(m); - for(i = 0; i < m; i++) - { assert( Sy[i].empty() ); - Sy[i].insert(i); - } - - // evaluate the dependency matrix for U(F(x)) - CPPAD_TESTVECTOR(std::set) Sx(m); - Sx = F.RevSparseJac(m, Sy); - - // check values - std::set::iterator itr; - bool found; - 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]); - } - } + // inialize the vector as zero + CppAD::VecAD Z(n - 1); + size_t k; + for(k = 0; k < n-1; k++) + Z[k] = 0.; + + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + 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]; + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(m); + + // check results vector + CPPAD_TESTVECTOR( bool ) Check(m * n); + + // initialize index into Y + size_t index = 0; + + // First component only depends on X[0]; + Y[index] = X[0]; + Check[index * n + 0] = true; + Check[index * n + 1] = false; + Check[index * n + 2] = false; + index++; + + // Second component depends on the vector Z + AD zero(0); + Y[index] = Z[zero]; // Load by a parameter + Check[index * n + 0] = false; + Check[index * n + 1] = true; + Check[index * n + 2] = true; + index++; + + // Third component depends on the vector Z + Y[index] = Z[ X[0] ]; // Load by a variable + 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); + + // dependency matrix for the identity function S(y) = y + CPPAD_TESTVECTOR( bool ) Py(m * m); + size_t i, j; + for(i = 0; i < m; i++) + { for(j = 0; j < m; j++) + Py[ i * m + j ] = false; + Py[ i * m + i ] = true; + } + + // evaluate the dependency matrix for S [ F(x) ] + CPPAD_TESTVECTOR( 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]); + } + // -------------------------------------------------------- + // dependency matrix for the identity function U(y) = y + CPPAD_TESTVECTOR(std::set) Sy(m); + for(i = 0; i < m; i++) + { assert( Sy[i].empty() ); + Sy[i].insert(i); + } + + // evaluate the dependency matrix for U(F(x)) + CPPAD_TESTVECTOR(std::set) Sx(m); + Sx = F.RevSparseJac(m, Sy); + + // check values + std::set::iterator itr; + bool found; + 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]); + } + } - return ok; + return ok; } bool case_three() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 2; + // dimension of the domain space + size_t n = 2; - // dimension of the range space - size_t m = 3; + // dimension of the range space + size_t m = 3; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 2.; - X[1] = 3.; - Independent(X); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(m); - - // check results vector - CPPAD_TESTVECTOR( bool ) Check(m * n); - - // initialize index into Y - size_t index = 0; - - // Y[0] only depends on X[0]; - Y[index] = pow(X[0], 2.); - Check[index * n + 0] = true; - Check[index * n + 1] = false; - index++; - - // Y[1] depends on X[1] - Y[index] = pow(2., X[1]); - Check[index * n + 0] = false; - Check[index * n + 1] = true; - index++; - - // Y[2] depends on X[0] and X[1] - Y[index] = pow(X[0], X[1]); - Check[index * n + 0] = true; - Check[index * n + 1] = true; - index++; - - // check final index - assert( index == m ); - - // create function object F : X -> Y - ADFun F(X, Y); - - // ----------------------------------------------------------------- - // dependency matrix for the identity function - CPPAD_TESTVECTOR( bool ) Py(m * m); - size_t i, j; - for(i = 0; i < m; i++) - { for(j = 0; j < m; j++) - Py[ i * m + j ] = (i == j); - } - - // evaluate the dependency matrix for F(x) - CPPAD_TESTVECTOR( 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]); - } - - // --------------------------------------------------------- - // dependency matrix for the identity function - CPPAD_TESTVECTOR(std::set) Sy(m); - for(i = 0; i < m; i++) - { assert( Sy[i].empty() ); - Sy[i].insert(i); - } - - // evaluate the dependency matrix for F(x) - CPPAD_TESTVECTOR(std::set) Sx(m); - Sx = F.RevSparseJac(m, Sy); - - // check values - bool found; - 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]); - } - } + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 2.; + X[1] = 3.; + Independent(X); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(m); + + // check results vector + CPPAD_TESTVECTOR( bool ) Check(m * n); + + // initialize index into Y + size_t index = 0; + + // Y[0] only depends on X[0]; + Y[index] = pow(X[0], 2.); + Check[index * n + 0] = true; + Check[index * n + 1] = false; + index++; + + // Y[1] depends on X[1] + Y[index] = pow(2., X[1]); + Check[index * n + 0] = false; + Check[index * n + 1] = true; + index++; + + // Y[2] depends on X[0] and X[1] + Y[index] = pow(X[0], X[1]); + Check[index * n + 0] = true; + Check[index * n + 1] = true; + index++; + + // check final index + assert( index == m ); + + // create function object F : X -> Y + ADFun F(X, Y); + + // ----------------------------------------------------------------- + // dependency matrix for the identity function + CPPAD_TESTVECTOR( bool ) Py(m * m); + size_t i, j; + for(i = 0; i < m; i++) + { for(j = 0; j < m; j++) + Py[ i * m + j ] = (i == j); + } + + // evaluate the dependency matrix for F(x) + CPPAD_TESTVECTOR( 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]); + } + + // --------------------------------------------------------- + // dependency matrix for the identity function + CPPAD_TESTVECTOR(std::set) Sy(m); + for(i = 0; i < m; i++) + { assert( Sy[i].empty() ); + Sy[i].insert(i); + } + + // evaluate the dependency matrix for F(x) + CPPAD_TESTVECTOR(std::set) Sx(m); + Sx = F.RevSparseJac(m, Sy); + + // check values + bool found; + 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]); + } + } - return ok; + return ok; } // case where s is not identity matrix bool case_four() { - bool ok = true; - using namespace CppAD; + bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 2; + // dimension of the domain space + size_t n = 2; - // dimension of the range space - size_t m = n; + // dimension of the range space + size_t m = n; - // independent and variable vectors - CPPAD_TESTVECTOR(AD) ax(n), ay(m); - ax[0] = 2.; - ax[1] = 3.; - Independent(ax); - ay[0] = ax[1]; - ay[1] = ax[0]; - - // create function object F : x -> y - ADFun F(ax, ay); - - // evaluate the dependency matrix for F(x) - size_t q = 1; - CPPAD_TESTVECTOR( bool ) s(q * m), r(q * n); - s[0] = true; - s[1] = false; - r = F.RevSparseJac(q, s); - - ok &= size_t( r.size() ) == q * n; - ok &= r[0] == false; - ok &= r[1] == true; + // independent and variable vectors + CPPAD_TESTVECTOR(AD) ax(n), ay(m); + ax[0] = 2.; + ax[1] = 3.; + Independent(ax); + ay[0] = ax[1]; + ay[1] = ax[0]; + + // create function object F : x -> y + ADFun F(ax, ay); + + // evaluate the dependency matrix for F(x) + size_t q = 1; + CPPAD_TESTVECTOR( bool ) s(q * m), r(q * n); + s[0] = true; + s[1] = false; + r = F.RevSparseJac(q, s); + + ok &= size_t( r.size() ) == q * n; + ok &= r[0] == false; + ok &= r[1] == true; - return ok; + return ok; } bool case_five() -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 2; + // dimension of the domain space + size_t n = 2; - // dimension of the range space - size_t m = 3; + // dimension of the range space + size_t m = 3; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 2.; - X[1] = 3.; - Independent(X); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Y(m); - - // check results vector - CPPAD_TESTVECTOR( bool ) Check(m * n); - - // initialize index into Y - size_t index = 0; - - // Y[0] only depends on X[0]; - Y[index] = pow(X[0], 2.); - Check[index * n + 0] = true; - Check[index * n + 1] = false; - index++; - - // Y[1] depends on X[1] - Y[index] = pow(2., X[1]); - Check[index * n + 0] = false; - Check[index * n + 1] = true; - index++; - - // Y[2] depends on X[0] and X[1] - Y[index] = pow(X[0], X[1]); - Check[index * n + 0] = true; - Check[index * n + 1] = true; - index++; - - // check final index - assert( index == m ); - - // create function object F : X -> Y - ADFun F(X, Y); - - // ----------------------------------------------------------------- - // dependency matrix for the identity function - CPPAD_TESTVECTOR( bool ) Py(m * m); - size_t i, j; - for(i = 0; i < m; i++) - { for(j = 0; j < m; j++) - Py[ i * m + j ] = (i == j); - } - - // evaluate the dependency matrix for F(x) - bool transpose = true; - CPPAD_TESTVECTOR( bool ) Px(n * m); - Px = F.RevSparseJac(m, Py, transpose); - - // check values - 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 - CPPAD_TESTVECTOR(std::set) Sy(m); - for(i = 0; i < m; i++) - { assert( Sy[i].empty() ); - Sy[i].insert(i); - } - - // evaluate the dependency matrix for F(x) - CPPAD_TESTVECTOR(std::set) Sx(n); - Sx = F.RevSparseJac(m, Sy, transpose); - - // check values - bool found; - for(i = 0; i < m; i++) - { for(j = 0; j < n; j++) - { found = Sx[j].find(i) != Sx[j].end(); - ok &= (found == Check[i * n + j]); - } - } + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 2.; + X[1] = 3.; + Independent(X); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Y(m); + + // check results vector + CPPAD_TESTVECTOR( bool ) Check(m * n); + + // initialize index into Y + size_t index = 0; + + // Y[0] only depends on X[0]; + Y[index] = pow(X[0], 2.); + Check[index * n + 0] = true; + Check[index * n + 1] = false; + index++; + + // Y[1] depends on X[1] + Y[index] = pow(2., X[1]); + Check[index * n + 0] = false; + Check[index * n + 1] = true; + index++; + + // Y[2] depends on X[0] and X[1] + Y[index] = pow(X[0], X[1]); + Check[index * n + 0] = true; + Check[index * n + 1] = true; + index++; + + // check final index + assert( index == m ); + + // create function object F : X -> Y + ADFun F(X, Y); + + // ----------------------------------------------------------------- + // dependency matrix for the identity function + CPPAD_TESTVECTOR( bool ) Py(m * m); + size_t i, j; + for(i = 0; i < m; i++) + { for(j = 0; j < m; j++) + Py[ i * m + j ] = (i == j); + } + + // evaluate the dependency matrix for F(x) + bool transpose = true; + CPPAD_TESTVECTOR( bool ) Px(n * m); + Px = F.RevSparseJac(m, Py, transpose); + + // check values + 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 + CPPAD_TESTVECTOR(std::set) Sy(m); + for(i = 0; i < m; i++) + { assert( Sy[i].empty() ); + Sy[i].insert(i); + } + + // evaluate the dependency matrix for F(x) + CPPAD_TESTVECTOR(std::set) Sx(n); + Sx = F.RevSparseJac(m, Sy, transpose); + + // check values + bool found; + for(i = 0; i < m; i++) + { for(j = 0; j < n; j++) + { found = Sx[j].find(i) != Sx[j].end(); + ok &= (found == Check[i * n + j]); + } + } - return ok; + return ok; } @@ -526,13 +527,13 @@ } // END empty namespace bool rev_sparse_jac(void) -{ bool ok = true; +{ bool ok = true; - ok &= case_one(); - ok &= case_two(); - ok &= case_three(); - ok &= case_four(); - ok &= case_five(); + ok &= case_one(); + ok &= case_two(); + ok &= case_three(); + ok &= case_four(); + ok &= case_five(); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/rev_two.cpp cppad-2019.02.00.0/test_more/general/rev_two.cpp --- cppad-2018.00.00.0/test_more/general/rev_two.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/rev_two.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,51 +1,52 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include bool RevTwo() -{ bool ok = true; - using CppAD::AD; - using CppAD::vector; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - - size_t n = 2; - vector< AD > X(n); - X[0] = 1.; - X[1] = 1.; - Independent(X); - - size_t m = 1; - vector< AD > Y(m); - Y[0] = X[0] * X[0] + X[0] * X[1] + 2. * X[1] * X[1]; - CppAD::ADFun F(X,Y); - - vector x(n); - x[0] = .5; - x[1] = 1.5; - - size_t L = 1; - vector I(L); - vector J(L); - vector H(n); - I[0] = 0; - J[0] = 0; - H = F.RevTwo(x, I, J); - ok &= NearEqual(H[0], 2., eps99, eps99); - ok &= NearEqual(H[1], 1., eps99, eps99); - J[0] = 1; - H = F.RevTwo(x, I, J); - ok &= NearEqual(H[0], 1., eps99, eps99); - ok &= NearEqual(H[1], 4., eps99, eps99); +{ bool ok = true; + using CppAD::AD; + using CppAD::vector; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + + size_t n = 2; + vector< AD > X(n); + X[0] = 1.; + X[1] = 1.; + Independent(X); + + size_t m = 1; + vector< AD > Y(m); + Y[0] = X[0] * X[0] + X[0] * X[1] + 2. * X[1] * X[1]; + CppAD::ADFun F(X,Y); + + vector x(n); + x[0] = .5; + x[1] = 1.5; + + size_t L = 1; + vector I(L); + vector J(L); + vector H(n); + I[0] = 0; + J[0] = 0; + H = F.RevTwo(x, I, J); + ok &= NearEqual(H[0], 2., eps99, eps99); + ok &= NearEqual(H[1], 1., eps99, eps99); + J[0] = 1; + H = F.RevTwo(x, I, J); + ok &= NearEqual(H[0], 1., eps99, eps99); + ok &= NearEqual(H[1], 4., eps99, eps99); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/romberg_one.cpp cppad-2019.02.00.0/test_more/general/romberg_one.cpp --- cppad-2018.00.00.0/test_more/general/romberg_one.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/romberg_one.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,18 +1,19 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* old romberg_one.cpp example / test $spell - Romberg + Romberg $$ $section One Dimensional Romberg Integration: Example and Test$$ @@ -32,79 +33,79 @@ # include namespace { - class Fun { - private: - const size_t degree; - public: - // constructor - Fun(size_t degree_) : degree(degree_) - { } - - // function F(x) = x^degree - template - Float operator () (const Float &x) - { size_t i; - Float f(1); - for(i = 0; i < degree; i++) - f *= x; - return f; - } - }; - - template - bool RombergOneCase(void) - { bool ok = true; - size_t i; - - size_t degree = 4; - Fun F(degree); - - // arguments to RombergOne - Float a(0); - Float b(1); - Float r; - size_t n = 4; - Float e; - size_t p; - - // 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 - Float step = (b - a) / exp(log(Float(2.))*Float(n-1)); - // step size corresponding to error estimate - step *= Float(2.); - // step size raised to a power - Float spow = Float(1); - - for(p = 0; p < n; p++) - { spow = spow * step * step; - - r = CppAD::RombergOne(F, a, b, n, p, e); - - ok &= e < double(degree+1) * spow; - ok &= CppAD::NearEqual(check, r, Float(0.), e); - } + class Fun { + private: + const size_t degree; + public: + // constructor + Fun(size_t degree_) : degree(degree_) + { } + + // function F(x) = x^degree + template + Float operator () (const Float &x) + { size_t i; + Float f(1); + for(i = 0; i < degree; i++) + f *= x; + return f; + } + }; + + template + bool RombergOneCase(void) + { bool ok = true; + size_t i; + + size_t degree = 4; + Fun F(degree); + + // arguments to RombergOne + Float a(0); + Float b(1); + Float r; + size_t n = 4; + Float e; + size_t p; + + // 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 + Float step = (b - a) / exp(log(Float(2.))*Float(n-1)); + // step size corresponding to error estimate + step *= Float(2.); + // step size raised to a power + Float spow = Float(1); + + for(p = 0; p < n; p++) + { spow = spow * step * step; + + r = CppAD::RombergOne(F, a, b, n, p, e); + + ok &= e < double(degree+1) * spow; + ok &= CppAD::NearEqual(check, r, Float(0.), e); + } - return ok; - } + return ok; + } } bool RombergOne(void) -{ bool ok = true; - using CppAD::AD; +{ bool ok = true; + using CppAD::AD; - ok &= RombergOneCase(); - ok &= RombergOneCase< AD >(); - ok &= RombergOneCase< AD< AD > >(); - return ok; + ok &= RombergOneCase(); + ok &= RombergOneCase< AD >(); + ok &= RombergOneCase< AD< AD > >(); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/rosen_34.cpp cppad-2019.02.00.0/test_more/general/rosen_34.cpp --- cppad-2018.00.00.0/test_more/general/rosen_34.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/rosen_34.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old OdeImplicit example now used just for valiadation testing of Rosen34 @@ -31,118 +32,118 @@ */ namespace { // BEGIN Empty namespace - class TestFun { - public: - TestFun(const CPPAD_TESTVECTOR(CppAD::AD) &w_) - { w.resize( w_.size() ); - w = w_; - } - void Ode( - 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) - { - 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) - { - 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; - }; -} // END empty namespace + class TestFun { + public: + TestFun(const CPPAD_TESTVECTOR(CppAD::AD) &w_) + { w.resize( w_.size() ); + w = w_; + } + void Ode( + 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) + { + 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) + { + 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; + }; +} // END empty namespace bool Rosen34(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - CPPAD_TESTVECTOR(AD) x(3); - CPPAD_TESTVECTOR(AD) w(3); - size_t n = 3; - size_t nstep = 20; - AD t0 = 0.; - AD t1 = 1.; - - // set independent variables - size_t i; - for(i = 0; i < n; i++) - w[i] = double(100 * i + 1); - Independent(w); - - // 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); - - // create f : w -> x and vectors for evaluating derivatives - ADFun f(w, x); - CPPAD_TESTVECTOR(double) q( f.Domain() ); - CPPAD_TESTVECTOR(double) r( f.Range() ); - - // check function values - AD x0 = exp( - w[0] * t1 ); - ok &= NearEqual(x[0], x0, 0., 1. / double(nstep * nstep) ); - - AD x1 = exp( - w[1] * t1 ); - ok &= NearEqual(x[1], x1, 0., 1. / double(nstep * nstep) ); - - AD x2 = w[2] * t1 * t1 / 2.; - ok &= NearEqual(x[2], x2, eps99, eps99); - - // check dx[0] / dw[0] - for(i = 0; i < size_t(w.size()); i++) - q[i] = 0.; - q[0] = 1.; - r = f.Forward(1, q); - ok &= NearEqual(r[0], - w[0] * x0, 0., 1. / double(nstep * nstep) ); - - // check dx[1] / dw[1] - q[0] = 0.; - q[1] = 1.; - r = f.Forward(1, q); - ok &= NearEqual(r[1], - w[1] * x1, 0., 1. / double(nstep * nstep) ); - - // check dx[2] / dw[2] - q[1] = 0.; - q[2] = 1.; - r = f.Forward(1, q); - ok &= NearEqual(r[2], x2 / w[2], eps99, eps99); + using namespace CppAD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + CPPAD_TESTVECTOR(AD) x(3); + CPPAD_TESTVECTOR(AD) w(3); + size_t n = 3; + size_t nstep = 20; + AD t0 = 0.; + AD t1 = 1.; + + // set independent variables + size_t i; + for(i = 0; i < n; i++) + w[i] = double(100 * i + 1); + Independent(w); + + // 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); + + // create f : w -> x and vectors for evaluating derivatives + ADFun f(w, x); + CPPAD_TESTVECTOR(double) q( f.Domain() ); + CPPAD_TESTVECTOR(double) r( f.Range() ); + + // check function values + AD x0 = exp( - w[0] * t1 ); + ok &= NearEqual(x[0], x0, 0., 1. / double(nstep * nstep) ); + + AD x1 = exp( - w[1] * t1 ); + ok &= NearEqual(x[1], x1, 0., 1. / double(nstep * nstep) ); + + AD x2 = w[2] * t1 * t1 / 2.; + ok &= NearEqual(x[2], x2, eps99, eps99); + + // check dx[0] / dw[0] + for(i = 0; i < size_t(w.size()); i++) + q[i] = 0.; + q[0] = 1.; + r = f.Forward(1, q); + ok &= NearEqual(r[0], - w[0] * x0, 0., 1. / double(nstep * nstep) ); + + // check dx[1] / dw[1] + q[0] = 0.; + q[1] = 1.; + r = f.Forward(1, q); + ok &= NearEqual(r[1], - w[1] * x1, 0., 1. / double(nstep * nstep) ); + + // check dx[2] / dw[2] + q[1] = 0.; + q[2] = 1.; + r = f.Forward(1, q); + ok &= NearEqual(r[2], x2 / w[2], eps99, eps99); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/runge_45.cpp cppad-2019.02.00.0/test_more/general/runge_45.cpp --- cppad-2018.00.00.0/test_more/general/runge_45.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/runge_45.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old OdeRunge example now used just for valiadation testing of Runge45 @@ -18,129 +19,131 @@ # include namespace { // BEGIN Empty namespace - class TestFun { - public: - TestFun(const CPPAD_TESTVECTOR(CppAD::AD) &w_) - { w.resize( w_.size() ); - w = w_; - } - void Ode( - 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: - CPPAD_TESTVECTOR(CppAD::AD) w; - }; + class TestFun { + public: + TestFun(const CPPAD_TESTVECTOR(CppAD::AD) &w_) + { w.resize( w_.size() ); + w = w_; + } + void Ode( + 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: + CPPAD_TESTVECTOR(CppAD::AD) w; + }; } // END Empty namespace bool Runge45(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - size_t i; - size_t j; - size_t k; - - size_t n = 6; - size_t m = n - 1; - - CPPAD_TESTVECTOR(AD) x(n); - AD t0 = 0.; - AD t1 = 2.; - size_t nstep = 2; - - // vector of independent variables - CPPAD_TESTVECTOR(AD) w(m); - for(i = 0; i < m; i++) - w[i] = double(i); - Independent(w); - - // construct function object using independent variables - TestFun fun(w); - - // initial value of x - CPPAD_TESTVECTOR(AD) x0(n); - for(i = 0; i < n; i++) - x0[i] = 0.; - x0[0] = exp( w[0] ); - - // solve the differential equation - x = Runge45(fun, nstep, t0, t1, x0); - - // create f : w -> x and vectors for evaluating derivatives - ADFun f(w, x); - CPPAD_TESTVECTOR(double) q( f.Domain() ); - CPPAD_TESTVECTOR(double) r( f.Range() ); - - // for i < n-1, - // x[i](2) = exp( w[0] ) * (w[1] / 1) * ... * (w[i] / i) * 2^i - AD xi2 = exp(w[0]); - for(i = 0; i < n-1; i++) - { ok &= NearEqual(x[i], xi2, eps99, eps99); - if( i < n-2 ) - xi2 *= w[i+1] * 2. / double(i+1); - } - - // x[n-1](2) = exp(2 * w[0]) * w[1] * 2^2 / 2 - xi2 = exp(2. * w[0]) * w[1] * 2.; - ok &= NearEqual(x[n-1], xi2, eps99, eps99); - - // the partial of x[i](2) with respect to w[j] is - // x[i](2) / w[j] if 0 < j <= i < n-1 - // x[i](2) if j == 0 and i < n-1 - // 2*x[i](2) if j == 0 and i = n-1 - // x[i](2) / w[j] if j == 1 and i = n-1 - // zero otherwise - - for(i = 0; i < n-1; i++) - { // compute partials of x[i] - for(k = 0; k < n; k++) - r[k] = 0.; - r[i] = 1.; - q = f.Reverse(1,r); - - for(j = 0; j < m; j++) - { // check partial of x[i] w.r.t w[j] - if (j == 0 ) - ok &= NearEqual(q[j], x[i], eps99, eps99); - else if( j <= i ) - ok &= NearEqual( - q[j], x[i]/w[j], 1e-14, 1e-14); - else ok &= NearEqual(q[j], 0., eps99, eps99); - } - } - - // compute partials of x[n-1] - i = n-1; - for(k = 0; k < n; k++) - r[k] = 0.; - r[i] = 1.; - q = f.Reverse(1,r); - - for(j = 0; j < m; j++) - { // check partial of x[n-1] w.r.t w[j] - if (j == 0 ) - ok &= NearEqual(q[j], 2.*x[i], eps99, eps99); - else if( j == 1 ) - ok &= NearEqual( - q[j], x[i]/w[1], 1e-14, 1e-14); - else ok &= NearEqual(q[j], 0., eps99, eps99); - } + using namespace CppAD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + size_t i; + size_t j; + size_t k; + + size_t n = 6; + size_t m = n - 1; + + CPPAD_TESTVECTOR(AD) x(n); + AD t0 = 0.; + AD t1 = 2.; + size_t nstep = 2; + + // vector of independent variables + CPPAD_TESTVECTOR(AD) w(m); + for(i = 0; i < m; i++) + w[i] = double(i); + Independent(w); + + // construct function object using independent variables + TestFun fun(w); + + // initial value of x + CPPAD_TESTVECTOR(AD) x0(n); + for(i = 0; i < n; i++) + x0[i] = 0.; + x0[0] = exp( w[0] ); + + // solve the differential equation + x = Runge45(fun, nstep, t0, t1, x0); + + // create f : w -> x and vectors for evaluating derivatives + ADFun f(w, x); + CPPAD_TESTVECTOR(double) q( f.Domain() ); + CPPAD_TESTVECTOR(double) r( f.Range() ); + + // for i < n-1, + // x[i](2) = exp( w[0] ) * (w[1] / 1) * ... * (w[i] / i) * 2^i + AD xi2 = exp(w[0]); + for(i = 0; i < n-1; i++) + { ok &= NearEqual(x[i], xi2, eps99, eps99); + if( i < n-2 ) + xi2 *= w[i+1] * 2. / double(i+1); + } + + // x[n-1](2) = exp(2 * w[0]) * w[1] * 2^2 / 2 + xi2 = exp(2. * w[0]) * w[1] * 2.; + ok &= NearEqual(x[n-1], xi2, eps99, eps99); + + // the partial of x[i](2) with respect to w[j] is + // x[i](2) / w[j] if 0 < j <= i < n-1 + // x[i](2) if j == 0 and i < n-1 + // 2*x[i](2) if j == 0 and i = n-1 + // x[i](2) / w[j] if j == 1 and i = n-1 + // zero otherwise + + for(i = 0; i < n-1; i++) + { // compute partials of x[i] + for(k = 0; k < n; k++) + r[k] = 0.; + r[i] = 1.; + q = f.Reverse(1,r); + + for(j = 0; j < m; j++) + { // check partial of x[i] w.r.t w[j] + if (j == 0 ) + ok &= NearEqual(q[j], x[i], eps99, eps99); + else if( j <= i ) + ok &= NearEqual( + q[j], x[i]/w[j], 1e-14, 1e-14); + else + ok &= NearEqual(q[j], 0., eps99, eps99); + } + } + + // compute partials of x[n-1] + i = n-1; + for(k = 0; k < n; k++) + r[k] = 0.; + r[i] = 1.; + q = f.Reverse(1,r); + + for(j = 0; j < m; j++) + { // check partial of x[n-1] w.r.t w[j] + if (j == 0 ) + ok &= NearEqual(q[j], 2.*x[i], eps99, eps99); + else if( j == 1 ) + ok &= NearEqual( + q[j], x[i]/w[1], 1e-14, 1e-14); + else + ok &= NearEqual(q[j], 0., eps99, eps99); + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/simple_vector.cpp cppad-2019.02.00.0/test_more/general/simple_vector.cpp --- cppad-2018.00.00.0/test_more/general/simple_vector.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/simple_vector.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* @@ -35,69 +36,69 @@ // A special type of element that counts assignment operations class MyInt { public: - // constructors - MyInt(void) : count(0), value(0) - { } - MyInt(int _value) : count(0), value(_value) - { } - // assignment operator - MyInt& operator=(const MyInt &x) - { value = x.value; - count++; - return *this; - } - // equality operator - bool operator==(const MyInt &x) const - { return value == x.value; } - - int Value(void) const - { return value; } - size_t Count(void) const - { return count; } + // constructors + MyInt(void) : count(0), value(0) + { } + MyInt(int _value) : count(0), value(_value) + { } + // assignment operator + MyInt& operator=(const MyInt &x) + { value = x.value; + count++; + return *this; + } + // equality operator + bool operator==(const MyInt &x) const + { return value == x.value; } + + int Value(void) const + { return value; } + size_t Count(void) const + { return count; } private: - size_t count; // count number of assignments - int value; // value of this object + size_t count; // count number of assignments + int value; // value of this object }; // Test of a Simple Vector template class bool SimpleVector(void) -{ bool ok = true; - typedef MySimpleVector vector; // class we are testing - typedef vector::value_type myInt; // type of elements - - vector x; // default constructor - ok &= (x.size() == 0); - - x.resize(2); // resize and set element assignment - ok &= (x.size() == 2); - x[0] = myInt(0); - x[1] = myInt(1); - - 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] == myInt(0)) && (z[1] == myInt(1)) ); - - // 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(); - size_t z0count = z[0].Count(); - x = y = z; // vector assignment - - // check resulting values - ok &= ( (x[0] == myInt(0)) && (x[1] == myInt(1)) ); - ok &= ( (y[0] == myInt(0)) && (y[1] == myInt(1)) ); - ok &= ( (z[0] == myInt(0)) && (z[1] == myInt(1)) ); - - // check that MyInt assignment was called (not raw memory copy) - ok &= (x[0].Count() == x0count + 1); - ok &= (y[1].Count() == y1count + 1); - ok &= (z[0].Count() == z0count); +{ bool ok = true; + typedef MySimpleVector vector; // class we are testing + typedef vector::value_type myInt; // type of elements + + vector x; // default constructor + ok &= (x.size() == 0); + + x.resize(2); // resize and set element assignment + ok &= (x.size() == 2); + x[0] = myInt(0); + x[1] = myInt(1); + + 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] == myInt(0)) && (z[1] == myInt(1)) ); + + // 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(); + size_t z0count = z[0].Count(); + x = y = z; // vector assignment + + // check resulting values + ok &= ( (x[0] == myInt(0)) && (x[1] == myInt(1)) ); + ok &= ( (y[0] == myInt(0)) && (y[1] == myInt(1)) ); + ok &= ( (z[0] == myInt(0)) && (z[1] == myInt(1)) ); + + // check that MyInt assignment was called (not raw memory copy) + ok &= (x[0].Count() == x0count + 1); + ok &= (y[1].Count() == y1count + 1); + ok &= (z[0].Count() == z0count); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/sin_cos.cpp cppad-2019.02.00.0/test_more/general/sin_cos.cpp --- cppad-2018.00.00.0/test_more/general/sin_cos.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/sin_cos.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Comprehensive test of Trigonometric and Hyperbolic Sine and Cosine @@ -19,381 +20,389 @@ namespace { // Begin empty namespace bool Sin(void) -{ bool ok = true; - using CppAD::sin; - using CppAD::cos; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - double x = .5; - double y = .8; - CPPAD_TESTVECTOR(AD) X(2); - X[0] = x; - X[1] = y; - Independent(X); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Z(1); - AD U = X[0] * X[1]; - Z[0] = sin( U ); - - // create f: X -> Z and vectors used for derivative calculations - // f(x, y) = sin(x, y) - ADFun f(X, Z); - CPPAD_TESTVECTOR(double) v( 2 ); - CPPAD_TESTVECTOR(double) w( 1 ); - - // check value - double sin_u = sin( Value(U) ); - double cos_u = cos( Value(U) ); - - ok &= NearEqual(sin_u, Value(Z[0]), eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - v[0] = 1.; // differential w.r.t. x - v[1] = 0; // differential w.r.t. y - double yj = 1; // y^j - for(j = 1; j < p; j++) - { w = f.Forward(j, v); - - // compute j-th power of y - yj *= y ; - - // compute j-th derivartive of sin function - double sinj; - if( j % 4 == 1 ) - sinj = cos_u; - else if( j % 4 == 2 ) - sinj = -sin_u; - else if( j % 4 == 3 ) - sinj = -cos_u; - else sinj = sin_u; - - jfac *= double(j); - - // check j-th derivative of z w.r.t x - ok &= NearEqual(jfac*w[0], sinj * yj, eps99 , eps99); - - v[0] = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r( 2 * p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - yj = 1.; - double sinjp = 0.; - for(j = 0; j < p; j++) - { - double sinj = sinjp; - - // compute j+1 derivative of sin funciton - if( j % 4 == 0 ) - sinjp = cos_u; - else if( j % 4 == 1 ) - sinjp = -sin_u; - else if( j % 4 == 2 ) - sinjp = -cos_u; - else sinjp = sin_u; - - // derivative w.r.t x of sin^{(j)} (x * y) * y^j - ok &= NearEqual(jfac*r[0+j], sinjp * yj * y, eps99 , eps99); - - // derivative w.r.t y of sin^{(j)} (x * y) * y^j - double value = sinjp * yj * x + double(j) * sinj * yj / y; - ok &= NearEqual(r[p+j], value/jfac, eps99, eps99); - - jfac *= double(j + 1); - yj *= y; - } +{ bool ok = true; + using CppAD::sin; + using CppAD::cos; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + double x = .5; + double y = .8; + CPPAD_TESTVECTOR(AD) X(2); + X[0] = x; + X[1] = y; + Independent(X); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Z(1); + AD U = X[0] * X[1]; + Z[0] = sin( U ); + + // create f: X -> Z and vectors used for derivative calculations + // f(x, y) = sin(x, y) + ADFun f(X, Z); + CPPAD_TESTVECTOR(double) v( 2 ); + CPPAD_TESTVECTOR(double) w( 1 ); + + // check value + double sin_u = sin( Value(U) ); + double cos_u = cos( Value(U) ); + + ok &= NearEqual(sin_u, Value(Z[0]), eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + v[0] = 1.; // differential w.r.t. x + v[1] = 0; // differential w.r.t. y + double yj = 1; // y^j + for(j = 1; j < p; j++) + { w = f.Forward(j, v); + + // compute j-th power of y + yj *= y ; + + // compute j-th derivartive of sin function + double sinj; + if( j % 4 == 1 ) + sinj = cos_u; + else if( j % 4 == 2 ) + sinj = -sin_u; + else if( j % 4 == 3 ) + sinj = -cos_u; + else + sinj = sin_u; + + jfac *= double(j); + + // check j-th derivative of z w.r.t x + ok &= NearEqual(jfac*w[0], sinj * yj, eps99 , eps99); + + v[0] = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r( 2 * p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + yj = 1.; + double sinjp = 0.; + for(j = 0; j < p; j++) + { + double sinj = sinjp; + + // compute j+1 derivative of sin funciton + if( j % 4 == 0 ) + sinjp = cos_u; + else if( j % 4 == 1 ) + sinjp = -sin_u; + else if( j % 4 == 2 ) + sinjp = -cos_u; + else + sinjp = sin_u; + + // derivative w.r.t x of sin^{(j)} (x * y) * y^j + ok &= NearEqual(jfac*r[0+j], sinjp * yj * y, eps99 , eps99); + + // derivative w.r.t y of sin^{(j)} (x * y) * y^j + double value = sinjp * yj * x + double(j) * sinj * yj / y; + ok &= NearEqual(r[p+j], value/jfac, eps99, eps99); + + jfac *= double(j + 1); + yj *= y; + } - return ok; + return ok; } bool Cos(void) -{ bool ok = true; - using CppAD::sin; - using CppAD::cos; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - double x = .5; - double y = .8; - CPPAD_TESTVECTOR(AD) X(2); - X[0] = x; - X[1] = y; - Independent(X); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Z(1); - AD U = X[0] * X[1]; - Z[0] = cos( U ); - - // create f: X -> Z and vectors used for derivative calculations - // f(x, y) = cos(x, y) - ADFun f(X, Z); - CPPAD_TESTVECTOR(double) v( 2 ); - CPPAD_TESTVECTOR(double) w( 1 ); - - // check value - double sin_u = sin( Value(U) ); - double cos_u = cos( Value(U) ); - - ok &= NearEqual(cos_u, Value(Z[0]), eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - v[0] = 1.; // differential w.r.t. x - v[1] = 0; // differential w.r.t. y - double yj = 1; // y^j - for(j = 1; j < p; j++) - { w = f.Forward(j, v); - - // compute j-th power of y - yj *= y ; - - // compute j-th derivartive of cos function - double cosj; - if( j % 4 == 1 ) - cosj = -sin_u; - else if( j % 4 == 2 ) - cosj = -cos_u; - else if( j % 4 == 3 ) - cosj = sin_u; - else cosj = cos_u; - - jfac *= double(j); - - // check j-th derivative of z w.r.t x - ok &= NearEqual(jfac*w[0], cosj * yj, eps99 , eps99); - - v[0] = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r( 2 * p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - yj = 1.; - double cosjp = 0.; - for(j = 0; j < p; j++) - { - double cosj = cosjp; - - // compute j+1 derivative of cos funciton - if( j % 4 == 0 ) - cosjp = -sin_u; - else if( j % 4 == 1 ) - cosjp = -cos_u; - else if( j % 4 == 2 ) - cosjp = sin_u; - else cosjp = cos_u; - - // derivative w.r.t x of cos^{(j)} (x * y) * y^j - ok &= NearEqual(jfac*r[0+j], cosjp * yj * y, eps99 , eps99); - - // derivative w.r.t y of cos^{(j)} (x * y) * y^j - double value = cosjp * yj * x + double(j) * cosj * yj / y; - ok &= NearEqual(r[p+j], value/jfac, eps99, eps99); - - jfac *= double(j + 1); - yj *= y; - } +{ bool ok = true; + using CppAD::sin; + using CppAD::cos; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + double x = .5; + double y = .8; + CPPAD_TESTVECTOR(AD) X(2); + X[0] = x; + X[1] = y; + Independent(X); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Z(1); + AD U = X[0] * X[1]; + Z[0] = cos( U ); + + // create f: X -> Z and vectors used for derivative calculations + // f(x, y) = cos(x, y) + ADFun f(X, Z); + CPPAD_TESTVECTOR(double) v( 2 ); + CPPAD_TESTVECTOR(double) w( 1 ); + + // check value + double sin_u = sin( Value(U) ); + double cos_u = cos( Value(U) ); + + ok &= NearEqual(cos_u, Value(Z[0]), eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + v[0] = 1.; // differential w.r.t. x + v[1] = 0; // differential w.r.t. y + double yj = 1; // y^j + for(j = 1; j < p; j++) + { w = f.Forward(j, v); + + // compute j-th power of y + yj *= y ; + + // compute j-th derivartive of cos function + double cosj; + if( j % 4 == 1 ) + cosj = -sin_u; + else if( j % 4 == 2 ) + cosj = -cos_u; + else if( j % 4 == 3 ) + cosj = sin_u; + else + cosj = cos_u; + + jfac *= double(j); + + // check j-th derivative of z w.r.t x + ok &= NearEqual(jfac*w[0], cosj * yj, eps99 , eps99); + + v[0] = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r( 2 * p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + yj = 1.; + double cosjp = 0.; + for(j = 0; j < p; j++) + { + double cosj = cosjp; + + // compute j+1 derivative of cos funciton + if( j % 4 == 0 ) + cosjp = -sin_u; + else if( j % 4 == 1 ) + cosjp = -cos_u; + else if( j % 4 == 2 ) + cosjp = sin_u; + else + cosjp = cos_u; + + // derivative w.r.t x of cos^{(j)} (x * y) * y^j + ok &= NearEqual(jfac*r[0+j], cosjp * yj * y, eps99 , eps99); + + // derivative w.r.t y of cos^{(j)} (x * y) * y^j + double value = cosjp * yj * x + double(j) * cosj * yj / y; + ok &= NearEqual(r[p+j], value/jfac, eps99, eps99); + + jfac *= double(j + 1); + yj *= y; + } - return ok; + return ok; } bool Cosh(void) -{ bool ok = true; - using CppAD::sinh; - using CppAD::cosh; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - double x = .5; - double y = .8; - CPPAD_TESTVECTOR(AD) X(2); - X[0] = x; - X[1] = y; - Independent(X); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Z(1); - AD U = X[0] * X[1]; - Z[0] = cosh( U ); - - // create f: X -> Z and vectors used for derivative calculations - // f(x, y) = cosh(x, y) - ADFun f(X, Z); - CPPAD_TESTVECTOR(double) v( 2 ); - CPPAD_TESTVECTOR(double) w( 1 ); - - // check value - double sinh_u = sinh( Value(U) ); - double cosh_u = cosh( Value(U) ); - - ok &= NearEqual(cosh_u, Value(Z[0]), eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - v[0] = 1.; // differential w.r.t. x - v[1] = 0; // differential w.r.t. y - double yj = 1; // y^j - for(j = 1; j < p; j++) - { w = f.Forward(j, v); - - // compute j-th power of y - yj *= y ; - - // compute j-th derivartive of cosh function - double coshj; - if( j % 2 == 1 ) - coshj = sinh_u; - else coshj = cosh_u; - - jfac *= double(j); - - // check j-th derivative of z w.r.t x - ok &= NearEqual(jfac*w[0], coshj * yj, eps99 , eps99); - - v[0] = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r( 2 * p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - yj = 1.; - double coshjp = 0.; - for(j = 0; j < p; j++) - { - double coshj = coshjp; - - // compute j+1 derivative of cosh funciton - if( j % 2 == 0 ) - coshjp = sinh_u; - else coshjp = cosh_u; - - // derivative w.r.t x of cosh^{(j)} (x * y) * y^j - ok &= NearEqual(jfac*r[0+j], coshjp * yj * y, eps99 , eps99); - - // derivative w.r.t y of cosh^{(j)} (x * y) * y^j - double value = coshjp * yj * x + double(j) * coshj * yj / y; - ok &= NearEqual(r[p+j], value/jfac, eps99, eps99); - - jfac *= double(j + 1); - yj *= y; - } +{ bool ok = true; + using CppAD::sinh; + using CppAD::cosh; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + double x = .5; + double y = .8; + CPPAD_TESTVECTOR(AD) X(2); + X[0] = x; + X[1] = y; + Independent(X); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Z(1); + AD U = X[0] * X[1]; + Z[0] = cosh( U ); + + // create f: X -> Z and vectors used for derivative calculations + // f(x, y) = cosh(x, y) + ADFun f(X, Z); + CPPAD_TESTVECTOR(double) v( 2 ); + CPPAD_TESTVECTOR(double) w( 1 ); + + // check value + double sinh_u = sinh( Value(U) ); + double cosh_u = cosh( Value(U) ); + + ok &= NearEqual(cosh_u, Value(Z[0]), eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + v[0] = 1.; // differential w.r.t. x + v[1] = 0; // differential w.r.t. y + double yj = 1; // y^j + for(j = 1; j < p; j++) + { w = f.Forward(j, v); + + // compute j-th power of y + yj *= y ; + + // compute j-th derivartive of cosh function + double coshj; + if( j % 2 == 1 ) + coshj = sinh_u; + else + coshj = cosh_u; + + jfac *= double(j); + + // check j-th derivative of z w.r.t x + ok &= NearEqual(jfac*w[0], coshj * yj, eps99 , eps99); + + v[0] = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r( 2 * p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + yj = 1.; + double coshjp = 0.; + for(j = 0; j < p; j++) + { + double coshj = coshjp; + + // compute j+1 derivative of cosh funciton + if( j % 2 == 0 ) + coshjp = sinh_u; + else + coshjp = cosh_u; + + // derivative w.r.t x of cosh^{(j)} (x * y) * y^j + ok &= NearEqual(jfac*r[0+j], coshjp * yj * y, eps99 , eps99); + + // derivative w.r.t y of cosh^{(j)} (x * y) * y^j + double value = coshjp * yj * x + double(j) * coshj * yj / y; + ok &= NearEqual(r[p+j], value/jfac, eps99, eps99); + + jfac *= double(j + 1); + yj *= y; + } - return ok; + return ok; } bool Sinh(void) -{ bool ok = true; - using CppAD::sinh; - using CppAD::cosh; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - double x = .5; - double y = .8; - CPPAD_TESTVECTOR(AD) X(2); - X[0] = x; - X[1] = y; - Independent(X); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Z(1); - AD U = X[0] * X[1]; - Z[0] = sinh( U ); - - // create f: X -> Z and vectors used for derivative calculations - // f(x, y) = sinh(x, y) - ADFun f(X, Z); - CPPAD_TESTVECTOR(double) v( 2 ); - CPPAD_TESTVECTOR(double) w( 1 ); - - // check value - double sinh_u = sinh( Value(U) ); - double cosh_u = cosh( Value(U) ); - - ok &= NearEqual(sinh_u, Value(Z[0]), eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - v[0] = 1.; // differential w.r.t. x - v[1] = 0; // differential w.r.t. y - double yj = 1; // y^j - for(j = 1; j < p; j++) - { w = f.Forward(j, v); - - // compute j-th power of y - yj *= y ; - - // compute j-th derivartive of sinh function - double sinhj; - if( j % 2 == 1 ) - sinhj = cosh_u; - else sinhj = sinh_u; - - jfac *= double(j); - - // check j-th derivative of z w.r.t x - ok &= NearEqual(jfac*w[0], sinhj * yj, eps99 , eps99); - - v[0] = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r( 2 * p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - yj = 1.; - double sinhjp = 0.; - for(j = 0; j < p; j++) - { - double sinhj = sinhjp; - - // compute j+1 derivative of sinh funciton - if( j % 2 == 0 ) - sinhjp = cosh_u; - else sinhjp = sinh_u; - - // derivative w.r.t x of sinh^{(j)} (x * y) * y^j - ok &= NearEqual(jfac*r[0+j], sinhjp * yj * y, eps99 , eps99); - - // derivative w.r.t y of sinh^{(j)} (x * y) * y^j - double value = sinhjp * yj * x + double(j) * sinhj * yj / y; - ok &= NearEqual(r[p+j], value/jfac, eps99, eps99); - - jfac *= double(j + 1); - yj *= y; - } +{ bool ok = true; + using CppAD::sinh; + using CppAD::cosh; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + double x = .5; + double y = .8; + CPPAD_TESTVECTOR(AD) X(2); + X[0] = x; + X[1] = y; + Independent(X); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Z(1); + AD U = X[0] * X[1]; + Z[0] = sinh( U ); + + // create f: X -> Z and vectors used for derivative calculations + // f(x, y) = sinh(x, y) + ADFun f(X, Z); + CPPAD_TESTVECTOR(double) v( 2 ); + CPPAD_TESTVECTOR(double) w( 1 ); + + // check value + double sinh_u = sinh( Value(U) ); + double cosh_u = cosh( Value(U) ); + + ok &= NearEqual(sinh_u, Value(Z[0]), eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + v[0] = 1.; // differential w.r.t. x + v[1] = 0; // differential w.r.t. y + double yj = 1; // y^j + for(j = 1; j < p; j++) + { w = f.Forward(j, v); + + // compute j-th power of y + yj *= y ; + + // compute j-th derivartive of sinh function + double sinhj; + if( j % 2 == 1 ) + sinhj = cosh_u; + else + sinhj = sinh_u; + + jfac *= double(j); + + // check j-th derivative of z w.r.t x + ok &= NearEqual(jfac*w[0], sinhj * yj, eps99 , eps99); + + v[0] = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r( 2 * p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + yj = 1.; + double sinhjp = 0.; + for(j = 0; j < p; j++) + { + double sinhj = sinhjp; + + // compute j+1 derivative of sinh funciton + if( j % 2 == 0 ) + sinhjp = cosh_u; + else + sinhjp = sinh_u; + + // derivative w.r.t x of sinh^{(j)} (x * y) * y^j + ok &= NearEqual(jfac*r[0+j], sinhjp * yj * y, eps99 , eps99); + + // derivative w.r.t y of sinh^{(j)} (x * y) * y^j + double value = sinhjp * yj * x + double(j) * sinhj * yj / y; + ok &= NearEqual(r[p+j], value/jfac, eps99, eps99); + + jfac *= double(j + 1); + yj *= y; + } - return ok; + return ok; } } // End empty namespace bool SinCos(void) -{ bool ok = Sin() & Cos() & Cosh() & Sinh(); - return ok; +{ bool ok = Sin() & Cos() & Cosh() & Sinh(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/sin.cpp cppad-2019.02.00.0/test_more/general/sin.cpp --- cppad-2018.00.00.0/test_more/general/sin.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/sin.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old example now just used for validation testing. @@ -15,74 +16,76 @@ # include bool Sin(void) -{ bool ok = true; - using CppAD::sin; - using CppAD::cos; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(1); - U[0] = 1.; - Independent(U); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = sin(U[0]); - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - double sin_u = sin( Value(U[0]) ); - double cos_u = cos( Value(U[0]) ); - - ok &= NearEqual(sin_u, Value(Z[0]), eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { w = f.Forward(j, v); - - double value; - if( j % 4 == 1 ) - value = cos_u; - else if( j % 4 == 2 ) - value = -sin_u; - else if( j % 4 == 3 ) - value = -cos_u; - else value = sin_u; - - jfac *= double(j); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - for(j = 0; j < p; j++) - { - double value; - if( j % 4 == 0 ) - value = cos_u; - else if( j % 4 == 1 ) - value = -sin_u; - else if( j % 4 == 2 ) - value = -cos_u; - else value = sin_u; +{ bool ok = true; + using CppAD::sin; + using CppAD::cos; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(1); + U[0] = 1.; + Independent(U); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Z(1); + Z[0] = sin(U[0]); + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + double sin_u = sin( Value(U[0]) ); + double cos_u = cos( Value(U[0]) ); + + ok &= NearEqual(sin_u, Value(Z[0]), eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { w = f.Forward(j, v); + + double value; + if( j % 4 == 1 ) + value = cos_u; + else if( j % 4 == 2 ) + value = -sin_u; + else if( j % 4 == 3 ) + value = -cos_u; + else + value = sin_u; + + jfac *= double(j); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + for(j = 0; j < p; j++) + { + double value; + if( j % 4 == 0 ) + value = cos_u; + else if( j % 4 == 1 ) + value = -sin_u; + else if( j % 4 == 2 ) + value = -cos_u; + else + value = sin_u; - ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - } + jfac *= double(j + 1); + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/sinh.cpp cppad-2019.02.00.0/test_more/general/sinh.cpp --- cppad-2018.00.00.0/test_more/general/sinh.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/sinh.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old example now just used for validation testing. @@ -15,66 +16,68 @@ # include bool Sinh(void) -{ bool ok = true; - using CppAD::sinh; - using CppAD::cosh; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(1); - U[0] = 1.; - Independent(U); - - // dependent variable vector - CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = sinh(U[0]); - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - double sin_u = sinh( Value(U[0]) ); - double cos_u = cosh( Value(U[0]) ); - - ok &= NearEqual(sin_u, Value(Z[0]), eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { w = f.Forward(j, v); - - double value; - if( j % 2 == 1 ) - value = cos_u; - else value = sin_u; - - jfac *= double(j); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - for(j = 0; j < p; j++) - { - double value; - if( j % 2 == 0 ) - value = cos_u; - else value = sin_u; +{ bool ok = true; + using CppAD::sinh; + using CppAD::cosh; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(1); + U[0] = 1.; + Independent(U); + + // dependent variable vector + CPPAD_TESTVECTOR(AD) Z(1); + Z[0] = sinh(U[0]); + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + double sin_u = sinh( Value(U[0]) ); + double cos_u = cosh( Value(U[0]) ); + + ok &= NearEqual(sin_u, Value(Z[0]), eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { w = f.Forward(j, v); + + double value; + if( j % 2 == 1 ) + value = cos_u; + else + value = sin_u; + + jfac *= double(j); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + for(j = 0; j < p; j++) + { + double value; + if( j % 2 == 0 ) + value = cos_u; + else + value = sin_u; - ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - } + jfac *= double(j + 1); + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/sparse_hessian.cpp cppad-2019.02.00.0/test_more/general/sparse_hessian.cpp --- cppad-2018.00.00.0/test_more/general/sparse_hessian.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/sparse_hessian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old SparseHessian example @@ -17,244 +18,244 @@ namespace { // --------------------------------------------------------- bool rc_tridiagonal(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t i, j, k, ell; - double eps10 = 10. * CppAD::epsilon(); - - size_t n = 12; // must be greater than or equal 3; see n_sweep. - size_t m = n - 1; - CPPAD_TESTVECTOR(AD) a_x(n), a_y(m); - CPPAD_TESTVECTOR(double) x(n), check(n * n), w(m); - for(j = 0; j < n; j++) - a_x[j] = x[j] = double(j+1); - - // declare independent variables and start taping - CppAD::Independent(a_x); - - for(ell = 0; ell < n * n; ell++) - 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); - w[i] = double(i+1); - ell = i * n + i; - check[ell] += w[i] / double(i+2); - ell = (i+1) * n + i+1; - check[ell] += w[i] / double(i+2); - ell = (i+1) * n + i; - check[ell] -= w[i] / double(i+2); - ell = i * n + i+1; - check[ell] -= w[i] / double(i+2); - } - - // 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); - for(j = 0; j < n; j++) - p_r[j].insert(j); - f.ForSparseJac(n, p_r); - // - VectorSet p_s(1); - for(i = 0; i < m; i++) - if( w[i] != 0 ) - p_s[0].insert(i); - VectorSet p_h = f.RevSparseHes(n, p_s); - - // requres the upper triangle of the Hessian - size_t K = 2 * n - 1; - CPPAD_TESTVECTOR(size_t) r(K), c(K); - CPPAD_TESTVECTOR(double) hes(K); - k = 0; - for(i = 0; i < n; i++) - { r[k] = i; - c[k] = i; - k++; - if( i < n-1 ) - { r[k] = i; - c[k] = i+1; - k++; - } - } - ok &= k == K; - - // test computing sparse Hessian - CppAD::sparse_hessian_work work; - size_t n_sweep = f.SparseHessian(x, w, p_h, r, c, hes, work); - ok &= n_sweep == 3; - for(k = 0; k < K; k++) - { ell = r[k] * n + c[k]; - ok &= NearEqual(check[ell], hes[k], eps10, eps10); - ell = c[k] * n + r[k]; - ok &= NearEqual(check[ell], hes[k], eps10, eps10); - } +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t i, j, k, ell; + double eps10 = 10. * CppAD::epsilon(); + + size_t n = 12; // must be greater than or equal 3; see n_sweep. + size_t m = n - 1; + CPPAD_TESTVECTOR(AD) a_x(n), a_y(m); + CPPAD_TESTVECTOR(double) x(n), check(n * n), w(m); + for(j = 0; j < n; j++) + a_x[j] = x[j] = double(j+1); + + // declare independent variables and start taping + CppAD::Independent(a_x); + + for(ell = 0; ell < n * n; ell++) + 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); + w[i] = double(i+1); + ell = i * n + i; + check[ell] += w[i] / double(i+2); + ell = (i+1) * n + i+1; + check[ell] += w[i] / double(i+2); + ell = (i+1) * n + i; + check[ell] -= w[i] / double(i+2); + ell = i * n + i+1; + check[ell] -= w[i] / double(i+2); + } + + // 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 > SetVector; + SetVector p_r(n); + for(j = 0; j < n; j++) + p_r[j].insert(j); + f.ForSparseJac(n, p_r); + // + SetVector p_s(1); + for(i = 0; i < m; i++) + if( w[i] != 0 ) + p_s[0].insert(i); + SetVector p_h = f.RevSparseHes(n, p_s); + + // requres the upper triangle of the Hessian + size_t K = 2 * n - 1; + CPPAD_TESTVECTOR(size_t) r(K), c(K); + CPPAD_TESTVECTOR(double) hes(K); + k = 0; + for(i = 0; i < n; i++) + { r[k] = i; + c[k] = i; + k++; + if( i < n-1 ) + { r[k] = i; + c[k] = i+1; + k++; + } + } + ok &= k == K; + + // test computing sparse Hessian + CppAD::sparse_hessian_work work; + size_t n_sweep = f.SparseHessian(x, w, p_h, r, c, hes, work); + ok &= n_sweep == 3; + for(k = 0; k < K; k++) + { ell = r[k] * n + c[k]; + ok &= NearEqual(check[ell], hes[k], eps10, eps10); + ell = c[k] * n + r[k]; + ok &= NearEqual(check[ell], hes[k], eps10, eps10); + } - return ok; + return ok; } -template +template bool bool_case() -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t i, j, k; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) X(n); - for(i = 0; i < n; i++) - X[i] = AD (0); - - // declare independent variables and starting recording - CppAD::Independent(X); - - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0] * X[0] + X[0] * X[1] + X[1] * X[1] + X[2] * X[2]; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - VectorBase x(n); - for(i = 0; i < n; i++) - x[i] = double(i); - - // second derivative of y[1] - VectorBase w(m); - w[0] = 1.; - VectorBase h( n * n ); - h = f.SparseHessian(x, w); - /* - [ 2 1 0 ] - h = [ 1 2 0 ] +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t i, j, k; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) X(n); + for(i = 0; i < n; i++) + X[i] = AD (0); + + // declare independent variables and starting recording + CppAD::Independent(X); + + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0] * X[0] + X[0] * X[1] + X[1] * X[1] + X[2] * X[2]; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + BaseVector x(n); + for(i = 0; i < n; i++) + x[i] = double(i); + + // second derivative of y[1] + BaseVector w(m); + w[0] = 1.; + BaseVector h( n * n ); + h = f.SparseHessian(x, w); + /* + [ 2 1 0 ] + h = [ 1 2 0 ] [ 0 0 2 ] - */ - VectorBase check(n * n); - check[0] = 2.; check[1] = 1.; check[2] = 0.; - check[3] = 1.; check[4] = 2.; check[5] = 0.; - check[6] = 0.; check[7] = 0.; check[8] = 2.; - for(k = 0; k < n * n; k++) - ok &= NearEqual(check[k], h[k], eps99, eps99 ); - - // determine the sparsity pattern p for Hessian of w^T F - VectorBool r(n * n); - for(j = 0; j < n; j++) - { for(k = 0; k < n; k++) - r[j * n + k] = false; - r[j * n + j] = true; - } - f.ForSparseJac(n, r); - // - VectorBool s(m); - for(i = 0; i < m; i++) - s[i] = w[i] != 0; - VectorBool p = f.RevSparseHes(n, s); - - // test passing sparsity pattern - h = f.SparseHessian(x, w, p); - for(k = 0; k < n * n; k++) - ok &= NearEqual(check[k], h[k], eps99, eps99 ); + */ + BaseVector check(n * n); + check[0] = 2.; check[1] = 1.; check[2] = 0.; + check[3] = 1.; check[4] = 2.; check[5] = 0.; + check[6] = 0.; check[7] = 0.; check[8] = 2.; + for(k = 0; k < n * n; k++) + ok &= NearEqual(check[k], h[k], eps99, eps99 ); + + // determine the sparsity pattern p for Hessian of w^T F + BoolVector r(n * n); + for(j = 0; j < n; j++) + { for(k = 0; k < n; k++) + r[j * n + k] = false; + r[j * n + j] = true; + } + f.ForSparseJac(n, r); + // + BoolVector s(m); + for(i = 0; i < m; i++) + s[i] = w[i] != 0; + BoolVector p = f.RevSparseHes(n, s); + + // test passing sparsity pattern + h = f.SparseHessian(x, w, p); + for(k = 0; k < n * n; k++) + ok &= NearEqual(check[k], h[k], eps99, eps99 ); - return ok; + return ok; } -template +template bool set_case() -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t i, j, k; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) X(n); - for(i = 0; i < n; i++) - X[i] = AD (0); - - // declare independent variables and starting recording - CppAD::Independent(X); - - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0] * X[0] + X[0] * X[1] + X[1] * X[1] + X[2] * X[2]; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - VectorBase x(n); - for(i = 0; i < n; i++) - x[i] = double(i); - - // second derivative of y[1] - VectorBase w(m); - w[0] = 1.; - VectorBase h( n * n ); - h = f.SparseHessian(x, w); - /* - [ 2 1 0 ] - h = [ 1 2 0 ] +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t i, j, k; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) X(n); + for(i = 0; i < n; i++) + X[i] = AD (0); + + // declare independent variables and starting recording + CppAD::Independent(X); + + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0] * X[0] + X[0] * X[1] + X[1] * X[1] + X[2] * X[2]; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + BaseVector x(n); + for(i = 0; i < n; i++) + x[i] = double(i); + + // second derivative of y[1] + BaseVector w(m); + w[0] = 1.; + BaseVector h( n * n ); + h = f.SparseHessian(x, w); + /* + [ 2 1 0 ] + h = [ 1 2 0 ] [ 0 0 2 ] - */ - VectorBase check(n * n); - check[0] = 2.; check[1] = 1.; check[2] = 0.; - check[3] = 1.; check[4] = 2.; check[5] = 0.; - check[6] = 0.; check[7] = 0.; check[8] = 2.; - for(k = 0; k < n * n; k++) - ok &= NearEqual(check[k], h[k], eps99, eps99 ); - - // determine the sparsity pattern p for Hessian of w^T F - VectorSet r(n); - for(j = 0; j < n; j++) - r[j].insert(j); - f.ForSparseJac(n, r); - // - VectorSet s(1); - for(i = 0; i < m; i++) - if( w[i] != 0 ) - s[0].insert(i); - VectorSet p = f.RevSparseHes(n, s); - - // test passing sparsity pattern - h = f.SparseHessian(x, w, p); - for(k = 0; k < n * n; k++) - ok &= NearEqual(check[k], h[k], eps99, eps99 ); + */ + BaseVector check(n * n); + check[0] = 2.; check[1] = 1.; check[2] = 0.; + check[3] = 1.; check[4] = 2.; check[5] = 0.; + check[6] = 0.; check[7] = 0.; check[8] = 2.; + for(k = 0; k < n * n; k++) + ok &= NearEqual(check[k], h[k], eps99, eps99 ); + + // determine the sparsity pattern p for Hessian of w^T F + SetVector r(n); + for(j = 0; j < n; j++) + r[j].insert(j); + f.ForSparseJac(n, r); + // + SetVector s(1); + for(i = 0; i < m; i++) + if( w[i] != 0 ) + s[0].insert(i); + SetVector p = f.RevSparseHes(n, s); + + // test passing sparsity pattern + h = f.SparseHessian(x, w, p); + for(k = 0; k < n * n; k++) + ok &= NearEqual(check[k], h[k], eps99, eps99 ); - return ok; + return ok; } } // End empty namespace # include # include bool sparse_hessian(void) -{ bool ok = true; +{ bool ok = true; - ok &= rc_tridiagonal(); - // --------------------------------------------------------------- - // vector of bool cases - ok &= bool_case< CppAD::vector , CppAD::vectorBool >(); - ok &= bool_case< std::vector , CppAD::vector >(); - ok &= bool_case< std::valarray , std::vector >(); - // --------------------------------------------------------------- - // vector of set cases - typedef std::vector< std::set > std_vector_set; - typedef CppAD::vector< std::set > cppad_vector_set; - // - ok &= set_case< CppAD::vector, std_vector_set >(); - ok &= set_case< std::valarray, std_vector_set >(); - ok &= set_case< std::vector, cppad_vector_set >(); - ok &= set_case< CppAD::vector, cppad_vector_set >(); - // - // According to section 26.3.2.3 of the 1998 C++ standard - // a const valarray does not return references to its elements. - // so do not include it in the testing for sets. - // --------------------------------------------------------------- - return ok; + ok &= rc_tridiagonal(); + // --------------------------------------------------------------- + // vector of bool cases + ok &= bool_case< CppAD::vector , CppAD::vectorBool >(); + ok &= bool_case< std::vector , CppAD::vector >(); + ok &= bool_case< std::valarray , std::vector >(); + // --------------------------------------------------------------- + // vector of set cases + typedef std::vector< std::set > std_vector_set; + typedef CppAD::vector< std::set > cppad_vector_set; + // + ok &= set_case< CppAD::vector, std_vector_set >(); + ok &= set_case< std::valarray, std_vector_set >(); + ok &= set_case< std::vector, cppad_vector_set >(); + ok &= set_case< CppAD::vector, cppad_vector_set >(); + // + // According to section 26.3.2.3 of the 1998 C++ standard + // a const valarray does not return references to its elements. + // so do not include it in the testing for sets. + // --------------------------------------------------------------- + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/sparse_jacobian.cpp cppad-2019.02.00.0/test_more/general/sparse_jacobian.cpp --- cppad-2018.00.00.0/test_more/general/sparse_jacobian.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/sparse_jacobian.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old sparse Jacobian example @@ -17,605 +18,606 @@ namespace { // --------------------------------------------------------- bool rc_tridiagonal(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t i, j, k, ell; - double eps10 = 10. * CppAD::epsilon(); - - // domain space vector - size_t n = 13; // must be greater than or equal 3 (see n_sweep below) - CPPAD_TESTVECTOR(AD) X(n); - CPPAD_TESTVECTOR(double) x(n); - for(j = 0; j < n; j++) - X[j] = x[j] = double(j+1); - - // declare independent variables and starting recording - CppAD::Independent(X); - - size_t m = n; - CPPAD_TESTVECTOR(AD) Y(m); - CPPAD_TESTVECTOR(double) check(m * n ); - for(ell = 0; ell < m * n; ell++) - check[ell] = 0.0; - - size_t K = 0; - for(i = 0; i < n; i++) - { ell = i * n + i; - Y[i] = double(ell+1) * 0.5 * X[i] * X[i]; - check[ell] = double(ell+1) * x[i]; - K++; - if( i < n-1 ) - { j = i + 1; - ell = i * n + j; - Y[i] += double(ell+1) * 0.5 * X[i+1] * X[i+1]; - check[ell] = double(ell+1) * x[i+1]; - K++; - } - if(i > 0 ) - { j = i - 1; - ell = i * n + j; - Y[i] += double(ell+1) * 0.5 * X[i-1] * X[i-1]; - check[ell] = double(ell+1) * x[i-1]; - } - } - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // sparsity pattern - CppAD::vector< std::set > s(m), p(m); - for(i = 0; i < m; i++) - s[i].insert(i); - p = f.RevSparseJac(m, s); - - // Request the upper triangle of the array - CPPAD_TESTVECTOR(size_t) r(K), c(K); - CPPAD_TESTVECTOR(double) jac(K); - k = 0; - for(i = 0; i < n; i++) - { r[k] = i; - c[k] = i; - k++; - if( i < n-1 ) - { r[k] = i; - c[k] = i+1; - k++; - } - } - ok &= K == k; - - CppAD::sparse_jacobian_work work; - 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]; - ok &= NearEqual(check[ell], jac[k], eps10, eps10); - } - 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]; - ok &= NearEqual(check[ell], jac[k], eps10, eps10); - } +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t i, j, k, ell; + double eps10 = 10. * CppAD::epsilon(); + + // domain space vector + size_t n = 13; // must be greater than or equal 3 (see n_sweep below) + CPPAD_TESTVECTOR(AD) X(n); + CPPAD_TESTVECTOR(double) x(n); + for(j = 0; j < n; j++) + X[j] = x[j] = double(j+1); + + // declare independent variables and starting recording + CppAD::Independent(X); + + size_t m = n; + CPPAD_TESTVECTOR(AD) Y(m); + CPPAD_TESTVECTOR(double) check(m * n ); + for(ell = 0; ell < m * n; ell++) + check[ell] = 0.0; + + size_t K = 0; + for(i = 0; i < n; i++) + { ell = i * n + i; + Y[i] = double(ell+1) * 0.5 * X[i] * X[i]; + check[ell] = double(ell+1) * x[i]; + K++; + if( i < n-1 ) + { j = i + 1; + ell = i * n + j; + Y[i] += double(ell+1) * 0.5 * X[i+1] * X[i+1]; + check[ell] = double(ell+1) * x[i+1]; + K++; + } + if(i > 0 ) + { j = i - 1; + ell = i * n + j; + Y[i] += double(ell+1) * 0.5 * X[i-1] * X[i-1]; + check[ell] = double(ell+1) * x[i-1]; + } + } + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // sparsity pattern + CppAD::vector< std::set > s(m), p(m); + for(i = 0; i < m; i++) + s[i].insert(i); + p = f.RevSparseJac(m, s); + + // Request the upper triangle of the array + CPPAD_TESTVECTOR(size_t) r(K), c(K); + CPPAD_TESTVECTOR(double) jac(K); + k = 0; + for(i = 0; i < n; i++) + { r[k] = i; + c[k] = i; + k++; + if( i < n-1 ) + { r[k] = i; + c[k] = i+1; + k++; + } + } + ok &= K == k; + + CppAD::sparse_jacobian_work work; + 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]; + ok &= NearEqual(check[ell], jac[k], eps10, eps10); + } + 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]; + ok &= NearEqual(check[ell], jac[k], eps10, eps10); + } - return ok; + return ok; } -template +template bool rc_set(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t i, j, k, ell; - double eps10 = 10. * CppAD::epsilon(); - - // domain space vector - size_t n = 4; - CPPAD_TESTVECTOR(AD) X(n); - for(j = 0; j < n; j++) - X[j] = AD (0); - - // declare independent variables and starting recording - CppAD::Independent(X); - - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = 1.0*X[0] + 2.0*X[1]; - Y[1] = 3.0*X[2] + 4.0*X[3]; - Y[2] = 5.0*X[0] + 6.0*X[1] + 7.0*X[3]*X[3]/2.; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - VectorBase x(n); - for(j = 0; j < n; j++) - x[j] = double(j); - - // Jacobian of y - /* - [ 1 2 0 0 ] - jac = [ 0 0 3 4 ] - [ 5 6 0 7*x_3] - */ - VectorBase check(m * n); - check[0] = 1.; check[1] = 2.; check[2] = 0.; check[3] = 0.; - check[4] = 0.; check[5] = 0.; check[6] = 3.; check[7] = 4.; - check[8] = 5.; check[9] = 6.; check[10] = 0.; check[11] = 7.*x[3]; - - // sparsity pattern - VectorSet s(m), p(m); - for(i = 0; i < m; i++) - s[i].insert(i); - p = f.RevSparseJac(m, s); - - // 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); - r[0] = 2; c[0] = 0; - r[1] = 1; c[1] = 2; - r[2] = 0; c[2] = 0; - 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]; - ok &= NearEqual(check[ell], jac[k], eps10, eps10); - } - ok &= (n_sweep == 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; - r[1] = 1; c[1] = 2; - r[2] = 0; c[2] = 1; - r[3] = 1; c[3] = 3; - work.clear(); - n_sweep = f.SparseJacobianReverse(x, p, r, c, jac, work); - for(k = 0; k < 4; k++) - { ell = r[k] * n + c[k]; - ok &= NearEqual(check[ell], jac[k], eps10, eps10); - } - ok &= (n_sweep == 1); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t i, j, k, ell; + double eps10 = 10. * CppAD::epsilon(); + + // domain space vector + size_t n = 4; + CPPAD_TESTVECTOR(AD) X(n); + for(j = 0; j < n; j++) + X[j] = AD (0); + + // declare independent variables and starting recording + CppAD::Independent(X); + + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = 1.0*X[0] + 2.0*X[1]; + Y[1] = 3.0*X[2] + 4.0*X[3]; + Y[2] = 5.0*X[0] + 6.0*X[1] + 7.0*X[3]*X[3]/2.; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + BaseVector x(n); + for(j = 0; j < n; j++) + x[j] = double(j); + + // Jacobian of y + /* + [ 1 2 0 0 ] + jac = [ 0 0 3 4 ] + [ 5 6 0 7*x_3] + */ + BaseVector check(m * n); + check[0] = 1.; check[1] = 2.; check[2] = 0.; check[3] = 0.; + check[4] = 0.; check[5] = 0.; check[6] = 3.; check[7] = 4.; + check[8] = 5.; check[9] = 6.; check[10] = 0.; check[11] = 7.*x[3]; + + // sparsity pattern + SetVector s(m), p(m); + for(i = 0; i < m; i++) + s[i].insert(i); + p = f.RevSparseJac(m, s); + + // 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); + BaseVector jac(3); + r[0] = 2; c[0] = 0; + r[1] = 1; c[1] = 2; + r[2] = 0; c[2] = 0; + 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]; + ok &= NearEqual(check[ell], jac[k], eps10, eps10); + } + ok &= (n_sweep == 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; + r[1] = 1; c[1] = 2; + r[2] = 0; c[2] = 1; + r[3] = 1; c[3] = 3; + work.clear(); + n_sweep = f.SparseJacobianReverse(x, p, r, c, jac, work); + for(k = 0; k < 4; k++) + { ell = r[k] * n + c[k]; + ok &= NearEqual(check[ell], jac[k], eps10, eps10); + } + ok &= (n_sweep == 1); - return ok; + return ok; } -template +template bool rc_bool(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t j, k, ell; - double eps10 = 10. * CppAD::epsilon(); - - // domain space vector - size_t n = 4; - CPPAD_TESTVECTOR(AD) X(n); - for(j = 0; j < n; j++) - X[j] = AD (0); - - // declare independent variables and starting recording - CppAD::Independent(X); - - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = 1.0*X[0] + 2.0*X[1]; - Y[1] = 3.0*X[2] + 4.0*X[3]; - Y[2] = 5.0*X[0] + 6.0*X[1] + 7.0*X[3]*X[3]/2.; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - VectorBase x(n); - for(j = 0; j < n; j++) - x[j] = double(j); - - // Jacobian of y - /* - [ 1 2 0 0 ] - jac = [ 0 0 3 4 ] - [ 5 6 0 7*x_3] - */ - VectorBase check(m * n); - check[0] = 1.; check[1] = 2.; check[2] = 0.; check[3] = 0.; - check[4] = 0.; check[5] = 0.; check[6] = 3.; check[7] = 4.; - check[8] = 5.; check[9] = 6.; check[10] = 0.; check[11] = 7.*x[3]; - VectorBool s(m * n); - s[0] = true; s[1] = true; s[2] = false; s[3] = false; - 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 - // (make sure order of rows and columns does not matter) - CPPAD_TESTVECTOR(size_t) r(3), c(3); - VectorBase jac(3); - r[0] = 2; c[0] = 0; - r[1] = 1; c[1] = 2; - r[2] = 0; c[2] = 0; - 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]; - ok &= NearEqual(check[ell], jac[k], eps10, eps10); - } - ok &= (n_sweep == 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; - r[1] = 1; c[1] = 2; - r[2] = 0; c[2] = 1; - r[3] = 1; c[3] = 3; - work.clear(); - n_sweep = f.SparseJacobianReverse(x, s, r, c, jac, work); - for(k = 0; k < 4; k++) - { ell = r[k] * n + c[k]; - ok &= NearEqual(check[ell], jac[k], eps10, eps10); - } - ok &= (n_sweep == 1); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t j, k, ell; + double eps10 = 10. * CppAD::epsilon(); + + // domain space vector + size_t n = 4; + CPPAD_TESTVECTOR(AD) X(n); + for(j = 0; j < n; j++) + X[j] = AD (0); + + // declare independent variables and starting recording + CppAD::Independent(X); + + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = 1.0*X[0] + 2.0*X[1]; + Y[1] = 3.0*X[2] + 4.0*X[3]; + Y[2] = 5.0*X[0] + 6.0*X[1] + 7.0*X[3]*X[3]/2.; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + BaseVector x(n); + for(j = 0; j < n; j++) + x[j] = double(j); + + // Jacobian of y + /* + [ 1 2 0 0 ] + jac = [ 0 0 3 4 ] + [ 5 6 0 7*x_3] + */ + BaseVector check(m * n); + check[0] = 1.; check[1] = 2.; check[2] = 0.; check[3] = 0.; + check[4] = 0.; check[5] = 0.; check[6] = 3.; check[7] = 4.; + check[8] = 5.; check[9] = 6.; check[10] = 0.; check[11] = 7.*x[3]; + BoolVector s(m * n); + s[0] = true; s[1] = true; s[2] = false; s[3] = false; + 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 + // (make sure order of rows and columns does not matter) + CPPAD_TESTVECTOR(size_t) r(3), c(3); + BaseVector jac(3); + r[0] = 2; c[0] = 0; + r[1] = 1; c[1] = 2; + r[2] = 0; c[2] = 0; + 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]; + ok &= NearEqual(check[ell], jac[k], eps10, eps10); + } + ok &= (n_sweep == 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; + r[1] = 1; c[1] = 2; + r[2] = 0; c[2] = 1; + r[3] = 1; c[3] = 3; + work.clear(); + n_sweep = f.SparseJacobianReverse(x, s, r, c, jac, work); + for(k = 0; k < 4; k++) + { ell = r[k] * n + c[k]; + ok &= NearEqual(check[ell], jac[k], eps10, eps10); + } + ok &= (n_sweep == 1); - return ok; + return ok; } -template +template bool reverse_bool(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t i, j, k; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 4; - CPPAD_TESTVECTOR(AD) X(n); - for(j = 0; j < n; j++) - X[j] = AD (0); - - // declare independent variables and starting recording - CppAD::Independent(X); - - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = 1.0*X[0] + 2.0*X[1]; - Y[1] = 3.0*X[2] + 4.0*X[3]; - Y[2] = 5.0*X[0] + 6.0*X[1] + 7.0*X[2] + 8.0*X[3]*X[3]/2.; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - VectorBase x(n); - for(j = 0; j < n; j++) - x[j] = double(j); - - // Jacobian of y without sparsity pattern - VectorBase jac(m * n); - jac = f.SparseJacobian(x); - /* - [ 1 2 0 0 ] - jac = [ 0 0 3 4 ] - [ 5 6 7 8*x_3] - */ - VectorBase check(m * n); - check[0] = 1.; check[1] = 2.; check[2] = 0.; check[3] = 0.; - check[4] = 0.; check[5] = 0.; check[6] = 3.; check[7] = 4.; - check[8] = 5.; check[9] = 6.; check[10] = 7.; check[11] = 8.*x[3]; - for(k = 0; k < 12; k++) - ok &= NearEqual(check[k], jac[k], eps99, eps99 ); - - // test passing sparsity pattern - VectorBool s(m * m); - VectorBool p(m * n); - for(i = 0; i < m; i++) - { for(k = 0; k < m; k++) - s[i * m + k] = false; - s[i * m + i] = true; - } - p = f.RevSparseJac(m, s); - jac = f.SparseJacobian(x, p); - for(k = 0; k < 12; k++) - ok &= NearEqual(check[k], jac[k], eps99, eps99 ); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t i, j, k; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 4; + CPPAD_TESTVECTOR(AD) X(n); + for(j = 0; j < n; j++) + X[j] = AD (0); + + // declare independent variables and starting recording + CppAD::Independent(X); + + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = 1.0*X[0] + 2.0*X[1]; + Y[1] = 3.0*X[2] + 4.0*X[3]; + Y[2] = 5.0*X[0] + 6.0*X[1] + 7.0*X[2] + 8.0*X[3]*X[3]/2.; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + BaseVector x(n); + for(j = 0; j < n; j++) + x[j] = double(j); + + // Jacobian of y without sparsity pattern + BaseVector jac(m * n); + jac = f.SparseJacobian(x); + /* + [ 1 2 0 0 ] + jac = [ 0 0 3 4 ] + [ 5 6 7 8*x_3] + */ + BaseVector check(m * n); + check[0] = 1.; check[1] = 2.; check[2] = 0.; check[3] = 0.; + check[4] = 0.; check[5] = 0.; check[6] = 3.; check[7] = 4.; + check[8] = 5.; check[9] = 6.; check[10] = 7.; check[11] = 8.*x[3]; + for(k = 0; k < 12; k++) + ok &= NearEqual(check[k], jac[k], eps99, eps99 ); + + // test passing sparsity pattern + BoolVector s(m * m); + BoolVector p(m * n); + for(i = 0; i < m; i++) + { for(k = 0; k < m; k++) + s[i * m + k] = false; + s[i * m + i] = true; + } + p = f.RevSparseJac(m, s); + jac = f.SparseJacobian(x, p); + for(k = 0; k < 12; k++) + ok &= NearEqual(check[k], jac[k], eps99, eps99 ); - return ok; + return ok; } -template +template bool reverse_set(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t i, j, k; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 4; - CPPAD_TESTVECTOR(AD) X(n); - for(j = 0; j < n; j++) - X[j] = AD (0); - - // declare independent variables and starting recording - CppAD::Independent(X); - - size_t m = 3; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0] + X[1]; - Y[1] = X[2] + X[3]; - Y[2] = X[0] + X[1] + X[2] + X[3] * X[3] / 2.; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - VectorBase x(n); - for(j = 0; j < n; j++) - x[j] = double(j); - - // Jacobian of y without sparsity pattern - VectorBase jac(m * n); - jac = f.SparseJacobian(x); - /* - [ 1 1 0 0 ] - jac = [ 0 0 1 1 ] - [ 1 1 1 x_3] - */ - VectorBase 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]; - for(k = 0; k < 12; k++) - ok &= NearEqual(check[k], jac[k], eps99, eps99 ); - - // test passing sparsity pattern - VectorSet s(m), p(m); - for(i = 0; i < m; i++) - s[i].insert(i); - p = f.RevSparseJac(m, s); - jac = f.SparseJacobian(x, p); - for(k = 0; k < 12; k++) - ok &= NearEqual(check[k], jac[k], eps99, eps99 ); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t i, j, k; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 4; + CPPAD_TESTVECTOR(AD) X(n); + for(j = 0; j < n; j++) + X[j] = AD (0); + + // declare independent variables and starting recording + CppAD::Independent(X); + + size_t m = 3; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0] + X[1]; + Y[1] = X[2] + X[3]; + Y[2] = X[0] + X[1] + X[2] + X[3] * X[3] / 2.; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + BaseVector x(n); + for(j = 0; j < n; j++) + x[j] = double(j); + + // Jacobian of y without sparsity pattern + BaseVector jac(m * n); + jac = f.SparseJacobian(x); + /* + [ 1 1 0 0 ] + jac = [ 0 0 1 1 ] + [ 1 1 1 x_3] + */ + BaseVector 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]; + for(k = 0; k < 12; k++) + ok &= NearEqual(check[k], jac[k], eps99, eps99 ); + + // test passing sparsity pattern + SetVector s(m), p(m); + for(i = 0; i < m; i++) + s[i].insert(i); + p = f.RevSparseJac(m, s); + jac = f.SparseJacobian(x, p); + for(k = 0; k < 12; k++) + ok &= NearEqual(check[k], jac[k], eps99, eps99 ); - return ok; + return ok; } -template +template bool forward_bool(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t j, k; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) X(n); - for(j = 0; j < n; j++) - X[j] = AD (0); - - // declare independent variables and starting recording - CppAD::Independent(X); - - size_t m = 4; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0] + X[2]; - Y[1] = X[0] + X[2]; - Y[2] = X[1] + X[2]; - Y[3] = X[1] + X[2] * X[2] / 2.; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - VectorBase x(n); - for(j = 0; j < n; j++) - x[j] = double(j); - - // Jacobian of y without sparsity pattern - VectorBase jac(m * n); - jac = f.SparseJacobian(x); - /* - [ 1 0 1 ] - jac = [ 1 0 1 ] - [ 0 1 1 ] - [ 0 1 x_2 ] - */ - VectorBase check(m * n); - 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[9] = 0.; check[10] = 1.; check[11] = x[2]; - for(k = 0; k < 12; k++) - ok &= NearEqual(check[k], jac[k], eps99, eps99 ); - - // test passing sparsity pattern - VectorBool r(n * n); - VectorBool p(m * n); - for(j = 0; j < n; j++) - { for(k = 0; k < n; k++) - r[j * n + k] = false; - r[j * n + j] = true; - } - p = f.ForSparseJac(n, r); - jac = f.SparseJacobian(x, p); - for(k = 0; k < 12; k++) - ok &= NearEqual(check[k], jac[k], eps99, eps99 ); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t j, k; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) X(n); + for(j = 0; j < n; j++) + X[j] = AD (0); + + // declare independent variables and starting recording + CppAD::Independent(X); + + size_t m = 4; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0] + X[2]; + Y[1] = X[0] + X[2]; + Y[2] = X[1] + X[2]; + Y[3] = X[1] + X[2] * X[2] / 2.; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + BaseVector x(n); + for(j = 0; j < n; j++) + x[j] = double(j); + + // Jacobian of y without sparsity pattern + BaseVector jac(m * n); + jac = f.SparseJacobian(x); + /* + [ 1 0 1 ] + jac = [ 1 0 1 ] + [ 0 1 1 ] + [ 0 1 x_2 ] + */ + BaseVector check(m * n); + 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[9] = 0.; check[10] = 1.; check[11] = x[2]; + for(k = 0; k < 12; k++) + ok &= NearEqual(check[k], jac[k], eps99, eps99 ); + + // test passing sparsity pattern + BoolVector r(n * n); + BoolVector p(m * n); + for(j = 0; j < n; j++) + { for(k = 0; k < n; k++) + r[j * n + k] = false; + r[j * n + j] = true; + } + p = f.ForSparseJac(n, r); + jac = f.SparseJacobian(x, p); + for(k = 0; k < 12; k++) + ok &= NearEqual(check[k], jac[k], eps99, eps99 ); - return ok; + return ok; } -template +template bool forward_set(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - size_t j, k; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 3; - CPPAD_TESTVECTOR(AD) X(n); - for(j = 0; j < n; j++) - X[j] = AD (0); - - // declare independent variables and starting recording - CppAD::Independent(X); - - size_t m = 4; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = X[0] + X[2]; - Y[1] = X[0] + X[2]; - Y[2] = X[1] + X[2]; - Y[3] = X[1] + X[2] * X[2] / 2.; - - // create f: X -> Y and stop tape recording - CppAD::ADFun f(X, Y); - - // new value for the independent variable vector - VectorBase x(n); - for(j = 0; j < n; j++) - x[j] = double(j); - - // Jacobian of y without sparsity pattern - VectorBase jac(m * n); - jac = f.SparseJacobian(x); - /* - [ 1 0 1 ] - jac = [ 1 0 1 ] - [ 0 1 1 ] - [ 0 1 x_2 ] - */ - VectorBase check(m * n); - 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[9] = 0.; check[10] = 1.; check[11] = x[2]; - for(k = 0; k < 12; k++) - ok &= NearEqual(check[k], jac[k], eps99, eps99 ); - - // test passing sparsity pattern - VectorSet r(n), p(m); - for(j = 0; j < n; j++) - r[j].insert(j); - p = f.ForSparseJac(n, r); - jac = f.SparseJacobian(x, p); - for(k = 0; k < 12; k++) - ok &= NearEqual(check[k], jac[k], eps99, eps99 ); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + size_t j, k; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 3; + CPPAD_TESTVECTOR(AD) X(n); + for(j = 0; j < n; j++) + X[j] = AD (0); + + // declare independent variables and starting recording + CppAD::Independent(X); + + size_t m = 4; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = X[0] + X[2]; + Y[1] = X[0] + X[2]; + Y[2] = X[1] + X[2]; + Y[3] = X[1] + X[2] * X[2] / 2.; + + // create f: X -> Y and stop tape recording + CppAD::ADFun f(X, Y); + + // new value for the independent variable vector + BaseVector x(n); + for(j = 0; j < n; j++) + x[j] = double(j); + + // Jacobian of y without sparsity pattern + BaseVector jac(m * n); + jac = f.SparseJacobian(x); + /* + [ 1 0 1 ] + jac = [ 1 0 1 ] + [ 0 1 1 ] + [ 0 1 x_2 ] + */ + BaseVector check(m * n); + 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[9] = 0.; check[10] = 1.; check[11] = x[2]; + for(k = 0; k < 12; k++) + ok &= NearEqual(check[k], jac[k], eps99, eps99 ); + + // test passing sparsity pattern + SetVector r(n), p(m); + for(j = 0; j < n; j++) + r[j].insert(j); + p = f.ForSparseJac(n, r); + jac = f.SparseJacobian(x, p); + for(k = 0; k < 12; k++) + ok &= NearEqual(check[k], jac[k], eps99, eps99 ); - return ok; + return ok; } bool multiple_of_n_bit(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::vector; - size_t i, j; - - // should be the same as the corresponding typedef in - // cppad/local/sparse_pack.hpp - typedef size_t Pack; - - // number of bits per packed value - size_t n_bit = std::numeric_limits::digits; - - // check case where number of variables is equal to n_bit - vector< AD > x(n_bit); - vector< AD > y(n_bit); - - // create an AD function with domain and range dimension equal to n_bit - CppAD::Independent(x); - for(i = 0; i < n_bit; i++) - y[i] = x[n_bit - i - 1]; - CppAD::ADFun f(x, y); - - // Jacobian sparsity patterns - vector r(n_bit * n_bit); - vector s(n_bit * n_bit); - for(i = 0; i < n_bit; i++) - { for(j = 0; j < n_bit; j++) - r[ i * n_bit + j ] = (i == j); - } - s = f.ForSparseJac(n_bit, r); - - // check the result - for(i = 0; i < n_bit; i++) - { for(j = 0; j < n_bit; j++) - { if( i == n_bit - j - 1 ) - ok = ok & s[ i * n_bit + j ]; - else ok = ok & (! s[i * n_bit + j] ); - } - } +{ bool ok = true; + using CppAD::AD; + using CppAD::vector; + size_t i, j; + + // should be the same as the corresponding typedef in + // cppad/local/sparse_pack.hpp + typedef size_t Pack; + + // number of bits per packed value + size_t n_bit = std::numeric_limits::digits; + + // check case where number of variables is equal to n_bit + vector< AD > x(n_bit); + vector< AD > y(n_bit); + + // create an AD function with domain and range dimension equal to n_bit + CppAD::Independent(x); + for(i = 0; i < n_bit; i++) + y[i] = x[n_bit - i - 1]; + CppAD::ADFun f(x, y); + + // Jacobian sparsity patterns + vector r(n_bit * n_bit); + vector s(n_bit * n_bit); + for(i = 0; i < n_bit; i++) + { for(j = 0; j < n_bit; j++) + r[ i * n_bit + j ] = (i == j); + } + s = f.ForSparseJac(n_bit, r); + + // check the result + for(i = 0; i < n_bit; i++) + { for(j = 0; j < n_bit; j++) + { if( i == n_bit - j - 1 ) + ok = ok & s[ i * n_bit + j ]; + else + ok = ok & (! s[i * n_bit + j] ); + } + } - return ok; + return ok; } // check for a sparse_list bug that was fixed on 2017-04-06 void algo_sparse_list_bug( - const CppAD::vector < CppAD::AD >& ax , - CppAD::vector < CppAD::AD >& ay ) + const CppAD::vector < CppAD::AD >& ax , + CppAD::vector < CppAD::AD >& ay ) { - ay[2] = 1.0; - ay[0] = 1.0; - ay[1] = ax[2]; - ay[3] = ax[2]; + ay[2] = 1.0; + ay[0] = 1.0; + ay[1] = ax[2]; + ay[3] = ax[2]; } bool sparse_list_bug(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::vector; - typedef CppAD::vector < std::set > sparsity; - // - size_t n = 4; - vector< AD > ay(n), ax(n); - for(size_t i = 0; i < n; ++i) - ax[i] = 1.0; - // - // sparsity pattern corresponding to identity matrix - sparsity eye(n); - for (size_t i = 0; i < n; i++) - eye[i].insert(i); - // - CppAD::checkpoint atom_fun( - "sparse_list_bug", - algo_sparse_list_bug, - ax, - ay, - CppAD::atomic_base::set_sparsity_enum - ); - // - vector < AD > au(n); - for (size_t j = 0; j < n; j++) - au[j] = 1.0; - // - // version of function that uses atom_fun - CppAD::Independent(au); - vector< AD > av(n); - atom_fun(au, ay); - for (size_t j = 0; j < n; j++) { - av[j] = ay[j] + au[j]; - } - CppAD::ADFun yes_atom_fun(au, av); - // - // version of function that uses algoright - CppAD::Independent(au); - algo_sparse_list_bug(au, ay); - for (size_t j = 0; j < n; j++) { - av[j] = ay[j] + au[j]; - } - CppAD::ADFun no_atom_fun(au, av); - - // - sparsity pattern_yes = yes_atom_fun.RevSparseJac(n, eye); - sparsity pattern_no = no_atom_fun.RevSparseJac(n, eye); - // - for(size_t i = 0; i < n; i++) - ok &= pattern_yes[i] == pattern_no[i]; - // - return ok; +{ bool ok = true; + using CppAD::AD; + using CppAD::vector; + typedef CppAD::vector < std::set > sparsity; + // + size_t n = 4; + vector< AD > ay(n), ax(n); + for(size_t i = 0; i < n; ++i) + ax[i] = 1.0; + // + // sparsity pattern corresponding to identity matrix + sparsity eye(n); + for (size_t i = 0; i < n; i++) + eye[i].insert(i); + // + CppAD::checkpoint atom_fun( + "sparse_list_bug", + algo_sparse_list_bug, + ax, + ay, + CppAD::atomic_base::set_sparsity_enum + ); + // + vector < AD > au(n); + for (size_t j = 0; j < n; j++) + au[j] = 1.0; + // + // version of function that uses atom_fun + CppAD::Independent(au); + vector< AD > av(n); + atom_fun(au, ay); + for (size_t j = 0; j < n; j++) { + av[j] = ay[j] + au[j]; + } + CppAD::ADFun yes_atom_fun(au, av); + // + // version of function that uses algoright + CppAD::Independent(au); + algo_sparse_list_bug(au, ay); + for (size_t j = 0; j < n; j++) { + av[j] = ay[j] + au[j]; + } + CppAD::ADFun no_atom_fun(au, av); + + // + sparsity pattern_yes = yes_atom_fun.RevSparseJac(n, eye); + sparsity pattern_no = no_atom_fun.RevSparseJac(n, eye); + // + for(size_t i = 0; i < n; i++) + ok &= pattern_yes[i] == pattern_no[i]; + // + return ok; } @@ -625,37 +627,37 @@ # include # include bool sparse_jacobian(void) -{ bool ok = true; - ok &= rc_tridiagonal(); - ok &= multiple_of_n_bit(); - ok &= sparse_list_bug(); - // --------------------------------------------------------------- - // vector of bool cases - ok &= rc_bool< CppAD::vector, CppAD::vectorBool >(); - ok &= forward_bool< CppAD::vector, CppAD::vector >(); - // - ok &= reverse_bool< std::vector, std::vector >(); - ok &= rc_bool< std::vector, std::valarray >(); - // - ok &= forward_bool< std::valarray, CppAD::vectorBool >(); - ok &= reverse_bool< std::valarray, CppAD::vector >(); - // --------------------------------------------------------------- - // vector of set cases - typedef std::vector< std::set > std_vector_set; - typedef CppAD::vector< std::set > cppad_vector_set; - // - ok &= rc_set< CppAD::vector, std_vector_set >(); - ok &= forward_set< std::valarray, std_vector_set >(); - // - ok &= reverse_set< std::vector, cppad_vector_set >(); - ok &= rc_set< CppAD::vector, cppad_vector_set >(); - // - // According to section 26.3.2.3 of the 1998 C++ standard - // a const valarray does not return references to its elements. - // typedef std::valarray< std::set > std_valarray_set; - // ok &= forward_set< std::valarray, std_valarray_set >(); - // ok &= reverse_set< std::valarray, std_valarray_set >(); - // --------------------------------------------------------------- - // - return ok; +{ bool ok = true; + ok &= rc_tridiagonal(); + ok &= multiple_of_n_bit(); + ok &= sparse_list_bug(); + // --------------------------------------------------------------- + // vector of bool cases + ok &= rc_bool< CppAD::vector, CppAD::vectorBool >(); + ok &= forward_bool< CppAD::vector, CppAD::vector >(); + // + ok &= reverse_bool< std::vector, std::vector >(); + ok &= rc_bool< std::vector, std::valarray >(); + // + ok &= forward_bool< std::valarray, CppAD::vectorBool >(); + ok &= reverse_bool< std::valarray, CppAD::vector >(); + // --------------------------------------------------------------- + // vector of set cases + typedef std::vector< std::set > std_vector_set; + typedef CppAD::vector< std::set > cppad_vector_set; + // + ok &= rc_set< CppAD::vector, std_vector_set >(); + ok &= forward_set< std::valarray, std_vector_set >(); + // + ok &= reverse_set< std::vector, cppad_vector_set >(); + ok &= rc_set< CppAD::vector, cppad_vector_set >(); + // + // According to section 26.3.2.3 of the 1998 C++ standard + // a const valarray does not return references to its elements. + // typedef std::valarray< std::set > std_valarray_set; + // ok &= forward_set< std::valarray, std_valarray_set >(); + // ok &= reverse_set< std::valarray, std_valarray_set >(); + // --------------------------------------------------------------- + // + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/sparse_jac_work.cpp cppad-2019.02.00.0/test_more/general/sparse_jac_work.cpp --- cppad-2018.00.00.0/test_more/general/sparse_jac_work.cpp 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/sparse_jac_work.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,158 @@ +/* -------------------------------------------------------------------------- +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell + +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ + +/* +$begin sparse_jac_work.cpp$$ +$spell + Cpp + Jacobian +$$ + +$section Using Same Work With Different Levels of AD: Example and Test$$ + +$srcfile%test_more/general/sparse_jac_work.cpp%0%// BEGIN C++%// END C++%1%$$ + +$end +*/ +// BEGIN C++ +# include +bool sparse_jac_work(void) +{ bool ok = true; + // + using CppAD::AD; + using CppAD::NearEqual; + using CppAD::sparse_rc; + using CppAD::sparse_rcv; + // + typedef AD a1double; + typedef AD a2double; + typedef CPPAD_TESTVECTOR(double) d_vector; + typedef CPPAD_TESTVECTOR(a1double) a1vector; + typedef CPPAD_TESTVECTOR(a2double) a2vector; + typedef CPPAD_TESTVECTOR(size_t) s_vector; + // + // domain space vector + size_t n = 4; + a2vector a2x(n); + a1vector a1x(n); + for(size_t j = 0; j < n; j++) + a2x[j] = a1x[j] = 0.0; + // + // declare independent variables and starting recording + CppAD::Independent(a2x); + // + size_t m = 3; + a2vector a2y(m); + a2y[0] = a2x[0] + a2x[1]; + a2y[1] = a2x[2] + a2x[3]; + a2y[2] = a2x[0] + a2x[1] + a2x[2] + a2x[3] * a2x[3] / 2.; + // + // create f: x -> y for computation with a1double + CppAD::ADFun a1f(a2x, a2y); + // + // create an identical function for computation with double + CppAD::Independent(a1x); + a1vector a1y = a1f.Forward(0, a1x); + CppAD::ADFun f(a1x, a1y); + // + // new value for the independent variable vector + d_vector x(n); + for(size_t j = 0; j < n; j++) + x[j] = double(j); + /* + [ 1 1 0 0 ] + J(x) = [ 0 0 1 1 ] + [ 1 1 1 x_3] + */ + // + // row-major order values of J(x) + size_t nnz = 8; + s_vector check_row(nnz), check_col(nnz); + d_vector check_val(nnz); + for(size_t k = 0; k < nnz; k++) + { // check_val + if( k < 7 ) + check_val[k] = 1.0; + else + check_val[k] = x[3]; + // + // check_row and check_col + check_col[k] = k; + if( k < 2 ) + check_row[k] = 0; + else if( k < 4 ) + check_row[k] = 1; + else + { check_row[k] = 2; + check_col[k] = k - 4; + } + } + // + // m by m identity matrix sparsity + sparse_rc pattern_in(m, m, m); + for(size_t k = 0; k < m; k++) + pattern_in.set(k, k, k); + // + // sparsity for J(x) + bool transpose = false; + bool dependency = false; + bool internal_bool = true; + sparse_rc pattern_jac; + f.rev_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, pattern_jac + ); + // + // compute entire reverse mode Jacobian + sparse_rcv subset( pattern_jac ); + CppAD::sparse_jac_work work; + std::string coloring = "cppad"; + size_t n_sweep = f.sparse_jac_rev(x, subset, pattern_jac, coloring, work); + ok &= n_sweep == 2; + // + const s_vector row( subset.row() ); + const s_vector col( subset.col() ); + const d_vector val( subset.val() ); + s_vector row_major = subset.row_major(); + ok &= subset.nnz() == nnz; + for(size_t k = 0; k < nnz; k++) + { ok &= row[ row_major[k] ] == check_row[k]; + ok &= col[ row_major[k] ] == check_col[k]; + ok &= val[ row_major[k] ] == check_val[k]; + } + // + // test using work stored by previous sparse_jac_rev with f + sparse_rc pattern_not_used; + std::string coloring_not_used; + n_sweep = f.sparse_jac_rev(x, subset, pattern_jac, coloring, work); + ok &= n_sweep == 2; + for(size_t k = 0; k < nnz; k++) + { ok &= row[ row_major[k] ] == check_row[k]; + ok &= col[ row_major[k] ] == check_col[k]; + ok &= val[ row_major[k] ] == check_val[k]; + } + // + // test using work stored by previous sparse_jac_rev with a1f + sparse_rcv a1subset( pattern_jac ); + for(size_t j = 0; j < n; ++j) + a1x[j] = x[j]; + n_sweep = a1f.sparse_jac_rev(a1x, a1subset, pattern_jac, coloring, work); + ok &= n_sweep == 2; + const a1vector a1val( a1subset.val() ); + for(size_t k = 0; k < nnz; k++) + { ok &= row[ row_major[k] ] == check_row[k]; + ok &= col[ row_major[k] ] == check_col[k]; + ok &= Value( a1val[ row_major[k] ] ) == check_val[k]; + } + // + return ok; +} +// END C++ diff -Nru cppad-2018.00.00.0/test_more/general/sparse_sub_hes.cpp cppad-2019.02.00.0/test_more/general/sparse_sub_hes.cpp --- cppad-2018.00.00.0/test_more/general/sparse_sub_hes.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/sparse_sub_hes.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* $begin sparse_sub_hes.cpp$$ @@ -36,187 +37,188 @@ namespace { // BEGIN_EMPTY_NAMESPACE // -------------------------------------------------------------------------- -CppAD::ADFun record_function(size_t n) -{ // must be greater than or equal 3; see n_sweep below - assert( n >= 3 ); - // - using CppAD::AD; - typedef CppAD::vector< AD > a_vector; - // - // domain space vector - 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); - // - return f; +void record_function(CppAD::ADFun& f, size_t n) +{ // must be greater than or equal 3; see n_sweep below + assert( n >= 3 ); + // + using CppAD::AD; + typedef CppAD::vector< AD > a_vector; + // + // domain space vector + 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) + f.Dependent(a_x, a_y); + // + return; } // -------------------------------------------------------------------------- bool test_set(const char* color_method) -{ bool ok = true; - // - typedef CppAD::vector< double > d_vector; - typedef CppAD::vector i_vector; - typedef CppAD::vector< std::set > s_vector; - // - size_t n = 12; - CppAD::ADFun f = record_function(n); - // - // 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); - - // set the row and column indices that correspond to lower triangle - i_vector row, col; - for(size_t i = 0; i < n_sub; i++) - { if( i > 0 ) - { // diagonal element - row.push_back(i); - col.push_back(i); - // lower diagonal element - row.push_back(i); - col.push_back(i-1); - } - } - - // weighting for the Hessian - d_vector w(1); - w[0] = 1.0; - - // compute Hessian - CppAD::sparse_hessian_work work; - work.color_method = color_method; - 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]; - } - } - return ok; +{ bool ok = true; + // + typedef CppAD::vector< double > d_vector; + typedef CppAD::vector i_vector; + typedef CppAD::vector< std::set > s_vector; + // + size_t n = 12; + CppAD::ADFun f; + record_function(f, n); + // + // 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); + + // set the row and column indices that correspond to lower triangle + i_vector row, col; + for(size_t i = 0; i < n_sub; i++) + { if( i > 0 ) + { // diagonal element + row.push_back(i); + col.push_back(i); + // lower diagonal element + row.push_back(i); + col.push_back(i-1); + } + } + + // weighting for the Hessian + d_vector w(1); + w[0] = 1.0; + + // compute Hessian + CppAD::sparse_hessian_work work; + work.color_method = color_method; + 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]; + } + } + return ok; } // -------------------------------------------------------------------------- bool test_bool(const char* color_method) -{ bool ok = true; - // - typedef CppAD::vector< double > d_vector; - typedef CppAD::vector i_vector; - typedef CppAD::vector s_vector; - // - size_t n = 12; - CppAD::ADFun f = record_function(n); - // - // 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 * n_sub); - for(size_t i = 0; i < n; i++) - { for(size_t j = 0; j < n_sub; j++) - r[ i * n_sub + j ] = (i == 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); - s[0] = true; - bool transpose = true; - s_vector h = f.RevSparseHes(n_sub, s, transpose); - - // set the row and column indices that correspond to lower triangle - i_vector row, col; - for(size_t i = 0; i < n_sub; i++) - { if( i > 0 ) - { // diagonal element - row.push_back(i); - col.push_back(i); - // lower diagonal element - row.push_back(i); - col.push_back(i-1); - } - } - - // weighting for the Hessian - d_vector w(1); - w[0] = 1.0; - - // extend sparsity pattern (values in extended columns do not matter) - s_vector h_extended(n * n); - for(size_t i = 0; i < n; i++) - { for(size_t j = 0; j < n_sub; j++) - h_extended[ i * n + j ] = h[ i * n_sub + j ]; - for(size_t j = n_sub; j < n; j++) - h_extended[ i * n + j ] = false; - } - // compute Hessian - CppAD::sparse_hessian_work work; - work.color_method = color_method; - 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_extended, 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]; - } - } - return ok; +{ bool ok = true; + // + typedef CppAD::vector< double > d_vector; + typedef CppAD::vector i_vector; + typedef CppAD::vector s_vector; + // + size_t n = 12; + CppAD::ADFun f; + record_function(f, n); + // + // 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 * n_sub); + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n_sub; j++) + r[ i * n_sub + j ] = (i == 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); + s[0] = true; + bool transpose = true; + s_vector h = f.RevSparseHes(n_sub, s, transpose); + + // set the row and column indices that correspond to lower triangle + i_vector row, col; + for(size_t i = 0; i < n_sub; i++) + { if( i > 0 ) + { // diagonal element + row.push_back(i); + col.push_back(i); + // lower diagonal element + row.push_back(i); + col.push_back(i-1); + } + } + + // weighting for the Hessian + d_vector w(1); + w[0] = 1.0; + + // extend sparsity pattern (values in extended columns do not matter) + s_vector h_extended(n * n); + for(size_t i = 0; i < n; i++) + { for(size_t j = 0; j < n_sub; j++) + h_extended[ i * n + j ] = h[ i * n_sub + j ]; + for(size_t j = n_sub; j < n; j++) + h_extended[ i * n + j ] = false; + } + // compute Hessian + CppAD::sparse_hessian_work work; + work.color_method = color_method; + 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_extended, 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]; + } + } + return ok; } } // END_EMPTY_NAMESPACE bool sparse_sub_hes(void) -{ bool ok = true; - ok &= test_set("cppad.symmetric"); - ok &= test_set("cppad.general"); - // - ok &= test_bool("cppad.symmetric"); - ok &= test_bool("cppad.general"); - return ok; +{ bool ok = true; + ok &= test_set("cppad.symmetric"); + ok &= test_set("cppad.general"); + // + ok &= test_bool("cppad.symmetric"); + ok &= test_bool("cppad.general"); + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/sparse_vec_ad.cpp cppad-2019.02.00.0/test_more/general/sparse_vec_ad.cpp --- cppad-2018.00.00.0/test_more/general/sparse_vec_ad.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/sparse_vec_ad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,118 +1,120 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include bool sparse_vec_ad(void) -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // dimension of the domain space - size_t n = 3; + // dimension of the domain space + size_t n = 3; - size_t i, j; + size_t i, j; - // independent variable vector - CPPAD_TESTVECTOR(AD) X(n); - for(j = 0; j < n; j++) - X[j] = AD(j); - Independent(X); - - // dependent variable vector - size_t m = n; - CPPAD_TESTVECTOR(AD) Y(m); - - // check results vector - CPPAD_TESTVECTOR( bool ) Check(m * n); - - // Create a VecAD so that there are two in the tape and the sparsity - // pattern depends on the second one (checks addressing VecAD objects) - VecAD W(n); - - // VecAD equal to X - VecAD Z(n); - AD J; - for(j = 0; j < n; j++) - { J = AD(j); - W[J] = X[0]; - Z[J] = X[j]; - - // y[i] depends on x[j] for j <= i - // (and is non-linear for j <= 1). - if( j == 1 ) - Y[j] = Z[J] * Z[J]; - else Y[j] = Z[J]; - } - - // compute dependent variables values - AD P = 1; - J = AD(0); - for(j = 0; j < n; j++) - { for(i = 0; i < m; i++) - Check[ i * m + j ] = (j <= i); - } - - // create function object F : X -> Y - ADFun F(X, Y); - - // dependency matrix for the identity function W(x) = x - CPPAD_TESTVECTOR( bool ) Identity(n * n); - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - Identity[ i * n + j ] = false; - Identity[ i * n + i ] = true; - } - // evaluate the dependency matrix for Identity(F(x)) - CPPAD_TESTVECTOR( bool ) Px(m * n); - Px = F.RevSparseJac(n, Identity); - - // check values - 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); - Py = F.ForSparseJac(n, Identity); - - // check values - 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) ) - CPPAD_TESTVECTOR(bool) Hy(m); - for(i = 0; i < m; i++) - Hy[i] = false; - Hy[2] = true; - CPPAD_TESTVECTOR(bool) Pxx(n * n); - Pxx = F.RevSparseHes(n, Hy); - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - ok &= (Pxx[i * n + j] == false ); - } - - // test sparsity pattern for Hessian of F_1 ( Identity(x) ) - for(i = 0; i < m; i++) - Hy[i] = false; - Hy[1] = true; - Pxx = F.RevSparseHes(n, Hy); - for(i = 0; i < n; i++) - { for(j = 0; j < n; j++) - ok &= (Pxx[i * n + j] == ( (i <= 1) & (j <= 1) ) ); - } + // independent variable vector + CPPAD_TESTVECTOR(AD) X(n); + for(j = 0; j < n; j++) + X[j] = AD(j); + Independent(X); + + // dependent variable vector + size_t m = n; + CPPAD_TESTVECTOR(AD) Y(m); + + // check results vector + CPPAD_TESTVECTOR( bool ) Check(m * n); + + // Create a VecAD so that there are two in the tape and the sparsity + // pattern depends on the second one (checks addressing VecAD objects) + VecAD W(n); + + // VecAD equal to X + VecAD Z(n); + AD J; + for(j = 0; j < n; j++) + { J = AD(j); + W[J] = X[0]; + Z[J] = X[j]; + + // y[i] depends on x[j] for j <= i + // (and is non-linear for j <= 1). + if( j == 1 ) + Y[j] = Z[J] * Z[J]; + else + Y[j] = Z[J]; + } + + // compute dependent variables values + AD P = 1; + J = AD(0); + for(j = 0; j < n; j++) + { for(i = 0; i < m; i++) + Check[ i * m + j ] = (j <= i); + } + + // create function object F : X -> Y + ADFun F(X, Y); + + // dependency matrix for the identity function W(x) = x + CPPAD_TESTVECTOR( bool ) Identity(n * n); + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + Identity[ i * n + j ] = false; + Identity[ i * n + i ] = true; + } + // evaluate the dependency matrix for Identity(F(x)) + CPPAD_TESTVECTOR( bool ) Px(m * n); + Px = F.RevSparseJac(n, Identity); + + // check values + 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); + Py = F.ForSparseJac(n, Identity); + + // check values + 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) ) + CPPAD_TESTVECTOR(bool) Hy(m); + for(i = 0; i < m; i++) + Hy[i] = false; + Hy[2] = true; + CPPAD_TESTVECTOR(bool) Pxx(n * n); + Pxx = F.RevSparseHes(n, Hy); + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + ok &= (Pxx[i * n + j] == false ); + } + + // test sparsity pattern for Hessian of F_1 ( Identity(x) ) + for(i = 0; i < m; i++) + Hy[i] = false; + Hy[1] = true; + Pxx = F.RevSparseHes(n, Hy); + for(i = 0; i < n; i++) + { for(j = 0; j < n; j++) + ok &= (Pxx[i * n + j] == ( (i <= 1) & (j <= 1) ) ); + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/sqrt.cpp cppad-2019.02.00.0/test_more/general/sqrt.cpp --- cppad-2018.00.00.0/test_more/general/sqrt.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/sqrt.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Two old sqrt examples now used just for validation testing. @@ -18,187 +19,187 @@ namespace { // BEGIN empty namespace bool SqrtTestOne(void) -{ bool ok = true; - using CppAD::sqrt; - using CppAD::pow; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(1); - size_t s = 0; - U[s] = 4.; - Independent(U); - - // dependent variable vector, indices, and values - CPPAD_TESTVECTOR(AD) Z(2); - size_t x = 0; - size_t y = 1; - Z[x] = sqrt(U[s]); - Z[y] = sqrt(Z[x]); - - // define f : U -> Z and vectors for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // check values - ok &= NearEqual(Z[x] , 2., eps99 , eps99); - ok &= NearEqual(Z[y] , sqrt(2.), eps99 , eps99); - - // forward computation of partials w.r.t. s - v[s] = 1.; - w = f.Forward(1, v); - ok &= NearEqual(w[x], .5 * pow(4., -.5), eps99 , eps99); // dx/ds - ok &= NearEqual(w[y], .25 * pow(4., -.75), eps99 , eps99); // dy/ds - - // reverse computation of partials of y - w[x] = 0.; - w[y] = 1.; - v = f.Reverse(1,w); - ok &= NearEqual(v[s], .25 * pow(4., -.75), eps99 , eps99); // dy/ds - - // 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] , - -.75 * .25 * pow(4., -1.75), - eps99 , - eps99 - ); - - // reverse computation of second partials of y - CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); - w[x] = 0.; - w[y] = 1.; - r = f.Reverse(2, w); - ok &= NearEqual( // d^2 y / (ds ds) - r[2 * s + 1] , - -.75 * .25 * pow(4., -1.75), - eps99 , - eps99 - ); +{ bool ok = true; + using CppAD::sqrt; + using CppAD::pow; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(1); + size_t s = 0; + U[s] = 4.; + Independent(U); + + // dependent variable vector, indices, and values + CPPAD_TESTVECTOR(AD) Z(2); + size_t x = 0; + size_t y = 1; + Z[x] = sqrt(U[s]); + Z[y] = sqrt(Z[x]); + + // define f : U -> Z and vectors for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // check values + ok &= NearEqual(Z[x] , 2., eps99 , eps99); + ok &= NearEqual(Z[y] , sqrt(2.), eps99 , eps99); + + // forward computation of partials w.r.t. s + v[s] = 1.; + w = f.Forward(1, v); + ok &= NearEqual(w[x], .5 * pow(4., -.5), eps99 , eps99); // dx/ds + ok &= NearEqual(w[y], .25 * pow(4., -.75), eps99 , eps99); // dy/ds + + // reverse computation of partials of y + w[x] = 0.; + w[y] = 1.; + v = f.Reverse(1,w); + ok &= NearEqual(v[s], .25 * pow(4., -.75), eps99 , eps99); // dy/ds + + // 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] , + -.75 * .25 * pow(4., -1.75), + eps99 , + eps99 + ); + + // reverse computation of second partials of y + CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); + w[x] = 0.; + w[y] = 1.; + r = f.Reverse(2, w); + ok &= NearEqual( // d^2 y / (ds ds) + r[2 * s + 1] , + -.75 * .25 * pow(4., -1.75), + eps99 , + eps99 + ); - return ok; + return ok; } bool SqrtTestTwo(void) -{ bool ok = true; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - CPPAD_TESTVECTOR(AD) U(1); - U[0] = 2.; - Independent(U); - - // a temporary values - AD x = U[0] * U[0]; - - // 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); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(U[0] , Z[0], eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - double value = 1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - value = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - value = 1.; - for(j = 0; j < p; j++) - { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - value = 0.; - } +{ bool ok = true; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + CPPAD_TESTVECTOR(AD) U(1); + U[0] = 2.; + Independent(U); + + // a temporary values + AD x = U[0] * U[0]; + + // 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); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(U[0] , Z[0], eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + double value = 1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + value = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + value = 1.; + for(j = 0; j < p; j++) + { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + jfac *= double(j + 1); + value = 0.; + } - return ok; + return ok; } bool SqrtTestThree(void) -{ bool ok = true; - using CppAD::sqrt; - using CppAD::exp; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector, indices, values, and declaration - double x = 4.; - CPPAD_TESTVECTOR(AD) X(1); - X[0] = x; - Independent(X); - - // dependent variable vector, indices, and values - CPPAD_TESTVECTOR(AD) Y(1); - Y[0] = sqrt( exp(X[0]) ); - - // define f : X -> Y and vectors for derivative calculations - ADFun f(X, Y); - - // forward computation of first Taylor coefficient - CPPAD_TESTVECTOR(double) x1( f.Domain() ); - CPPAD_TESTVECTOR(double) y1( f.Range() ); - x1[0] = 1.; - y1 = f.Forward(1, x1); - ok &= NearEqual(y1[0], exp(x/2.)/2., eps99 , eps99); - - // 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., eps99 , eps99 ); - - // 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., eps99 , eps99 ); - - // 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., eps99 , eps99); - ok &= NearEqual(r[1], exp(x/2.)/4., eps99 , eps99 ); - ok &= NearEqual(2.*r[2], exp(x/2.)/8., eps99 , eps99 ); - ok &= NearEqual(6.*r[3], exp(x/2.)/16., eps99 , eps99 ); +{ bool ok = true; + using CppAD::sqrt; + using CppAD::exp; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector, indices, values, and declaration + double x = 4.; + CPPAD_TESTVECTOR(AD) X(1); + X[0] = x; + Independent(X); + + // dependent variable vector, indices, and values + CPPAD_TESTVECTOR(AD) Y(1); + Y[0] = sqrt( exp(X[0]) ); + + // define f : X -> Y and vectors for derivative calculations + ADFun f(X, Y); + + // forward computation of first Taylor coefficient + CPPAD_TESTVECTOR(double) x1( f.Domain() ); + CPPAD_TESTVECTOR(double) y1( f.Range() ); + x1[0] = 1.; + y1 = f.Forward(1, x1); + ok &= NearEqual(y1[0], exp(x/2.)/2., eps99 , eps99); + + // 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., eps99 , eps99 ); + + // 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., eps99 , eps99 ); + + // 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., eps99 , eps99); + ok &= NearEqual(r[1], exp(x/2.)/4., eps99 , eps99 ); + ok &= NearEqual(2.*r[2], exp(x/2.)/8., eps99 , eps99 ); + ok &= NearEqual(6.*r[3], exp(x/2.)/16., eps99 , eps99 ); - return ok; + return ok; } } // END empty namespace bool Sqrt(void) -{ bool ok = true; - ok &= SqrtTestOne(); - ok &= SqrtTestTwo(); - ok &= SqrtTestThree(); - return ok; +{ bool ok = true; + ok &= SqrtTestOne(); + ok &= SqrtTestTwo(); + ok &= SqrtTestThree(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/std_math.cpp cppad-2019.02.00.0/test_more/general/std_math.cpp --- cppad-2018.00.00.0/test_more/general/std_math.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/std_math.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test the using standard math functions with AD< AD > @@ -19,45 +20,45 @@ typedef CppAD::AD< ADdouble > ADDdouble; bool std_math(void) -{ using CppAD::NearEqual; - bool ok = true; - ADDdouble half(.5); - ADDdouble one(1.); - ADDdouble two(2.); - ADDdouble ten(10.); - ADDdouble small(1e-6); - ADDdouble pi_4(3.141592653 / 4.); - ADDdouble root_2( sqrt(two) ); +{ using CppAD::NearEqual; + bool ok = true; + ADDdouble half(.5); + ADDdouble one(1.); + ADDdouble two(2.); + ADDdouble ten(10.); + ADDdouble eps(1e-6); + ADDdouble pi_4(3.141592653 / 4.); + ADDdouble root_2( sqrt(two) ); - ADDdouble y( acos(one / root_2) ); - ok &= NearEqual( pi_4, y, small, small ); + ADDdouble y( acos(one / root_2) ); + ok &= NearEqual( pi_4, y, eps, eps ); - y = cos(pi_4); - ok &= NearEqual( one / root_2, y, small, small ); + y = cos(pi_4); + ok &= NearEqual( one / root_2, y, eps, eps ); - y = asin(one / root_2); - ok &= NearEqual( pi_4, y, small, small ); + y = asin(one / root_2); + ok &= NearEqual( pi_4, y, eps, eps ); - y = sin(pi_4); - ok &= NearEqual( one / root_2, y, small, small ); + y = sin(pi_4); + ok &= NearEqual( one / root_2, y, eps, eps ); - y = atan(one); - ok &= NearEqual( pi_4, y, small, small ); + y = atan(one); + ok &= NearEqual( pi_4, y, eps, eps ); - y = tan(pi_4); - ok &= NearEqual( one, y, small, small ); + y = tan(pi_4); + ok &= NearEqual( one, y, eps, eps ); - y = two * cosh(one); - ok &= NearEqual( exp(one) + exp(-one), y, small, small ); + y = two * cosh(one); + ok &= NearEqual( exp(one) + exp(-one), y, eps, eps ); - y = two * sinh(one); - ok &= NearEqual( exp(one) - exp(-one), y, small, small ); + y = two * sinh(one); + ok &= NearEqual( exp(one) - exp(-one), y, eps, eps ); - y = log( exp(one) ); - ok &= NearEqual( one, y, small, small ); + y = log( exp(one) ); + ok &= NearEqual( one, y, eps, eps ); - y = log10( exp( log(ten) ) ); - ok &= NearEqual( one, y, small, small ); + y = log10( exp( log(ten) ) ); + ok &= NearEqual( one, y, eps, eps ); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/sub.cpp cppad-2019.02.00.0/test_more/general/sub.cpp --- cppad-2018.00.00.0/test_more/general/sub.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/sub.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* @@ -18,180 +19,181 @@ namespace { // BEGIN empty namespace bool One(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(2); - size_t s = 0; - size_t t = 1; - U[s] = 3.; - U[t] = 2.; - Independent(U); - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(3); - size_t x = 0; - size_t y = 1; - size_t z = 2; - - // 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 - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // check function values - ok &= ( Z[x] == 3. - 2. ); - ok &= ( Z[y] == 3. - 2. - 1. ); - ok &= ( Z[z] == 1. - 3. + 2. + 1. ); - - // forward computation of partials w.r.t. s - v[s] = 1.; - v[t] = 0.; - w = f.Forward(1, v); - ok &= ( w[x] == 1. ); // dx/ds - ok &= ( w[y] == 1. ); // dy/ds - ok &= ( w[z] == -1. ); // dz/ds - - // reverse computation of second partials of z - CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); - w[x] = 0.; - w[y] = 0.; - w[z] = 1.; - r = f.Reverse(2, w); - ok &= ( r[2 * s + 1] == 0. ); // d^2 z / (ds ds) - ok &= ( r[2 * t + 1] == 0. ); // d^2 z / (ds dt) + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(2); + size_t s = 0; + size_t t = 1; + U[s] = 3.; + U[t] = 2.; + Independent(U); + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(3); + size_t x = 0; + size_t y = 1; + size_t z = 2; + + // 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 + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // check function values + ok &= ( Z[x] == 3. - 2. ); + ok &= ( Z[y] == 3. - 2. - 1. ); + ok &= ( Z[z] == 1. - 3. + 2. + 1. ); + + // forward computation of partials w.r.t. s + v[s] = 1.; + v[t] = 0.; + w = f.Forward(1, v); + ok &= ( w[x] == 1. ); // dx/ds + ok &= ( w[y] == 1. ); // dy/ds + ok &= ( w[z] == -1. ); // dz/ds + + // reverse computation of second partials of z + CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); + w[x] = 0.; + w[y] = 0.; + w[z] = 1.; + r = f.Reverse(2, w); + ok &= ( r[2 * s + 1] == 0. ); // d^2 z / (ds ds) + ok &= ( r[2 * t + 1] == 0. ); // d^2 z / (ds dt) - return ok; + return ok; } bool Two(void) -{ bool ok = true; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - double u0 = .5; - CPPAD_TESTVECTOR(AD) U(1); - U[0] = u0; - Independent(U); - - 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 - - // 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); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(Value(Z[0]) , u0-4+3-2*u0+1+2, eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - double value = -1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - value = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - value = -1.; - for(j = 0; j < p; j++) - { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - value = 0.; - } +{ bool ok = true; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + double u0 = .5; + CPPAD_TESTVECTOR(AD) U(1); + U[0] = u0; + Independent(U); + + 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 + + // 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); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(Value(Z[0]) , u0-4+3-2*u0+1+2, eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + double value = -1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + value = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + value = -1.; + for(j = 0; j < p; j++) + { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + jfac *= double(j + 1); + value = 0.; + } - return ok; + return ok; } bool Three(void) -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // 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); - X[0] = 1.; - Independent(X); - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - Y[0] = 1. - X[0]; - ADFun f(X, Y); - - CPPAD_TESTVECTOR(double) w(m), dw(n); - w[0] = 1.; - dw = f.Reverse(1, w); - ok &= (dw[0] == -1.); + // 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); + X[0] = 1.; + Independent(X); + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + Y[0] = 1. - X[0]; + ADFun f(X, Y); + + CPPAD_TESTVECTOR(double) w(m), dw(n); + w[0] = 1.; + dw = f.Reverse(1, w); + ok &= (dw[0] == -1.); - return ok; + return ok; } bool Four(void) -{ bool ok = true; - using namespace CppAD; +{ bool ok = true; + using namespace CppAD; - // special cases where parameter number is equal to - // variable index in result. - size_t n = 1; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 1.; - Independent(X); - size_t m = 1; - CPPAD_TESTVECTOR(AD) Y(m); - if( 0. < X[0] && X[0] < 10. ) - Y[0] = X[0] - 2.; - else Y[0] = X[0] - 2.; - 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); - ok &= (dy[0] == 1.); + // special cases where parameter number is equal to + // variable index in result. + size_t n = 1; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 1.; + Independent(X); + size_t m = 1; + CPPAD_TESTVECTOR(AD) Y(m); + if( 0. < X[0] && X[0] < 10. ) + Y[0] = X[0] - 2.; + else + Y[0] = X[0] - 2.; + 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); + ok &= (dy[0] == 1.); - return ok; + return ok; } } // END empty namespace bool Sub(void) -{ bool ok = true; - ok &= One(); - ok &= Two(); - ok &= Three(); - ok &= Four(); - return ok; +{ bool ok = true; + ok &= One(); + ok &= Two(); + ok &= Three(); + ok &= Four(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/sub_eq.cpp cppad-2019.02.00.0/test_more/general/sub_eq.cpp --- cppad-2018.00.00.0/test_more/general/sub_eq.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/sub_eq.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Two old SubEq examples now used just for valiadation testing @@ -17,116 +18,116 @@ namespace { // BEGIN empty namespace bool SubEqTestOne(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(2); - size_t s = 0; - size_t t = 1; - U[s] = 3.; - U[t] = 2.; - Independent(U); - - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(2); - size_t x = 0; - size_t y = 1; - - // dependent variable values - Z[x] = U[s]; - Z[y] = U[t]; - 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); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); - - // check function values - ok &= ( Z[x] == 3. - 2. ); - ok &= ( Z[y] == 2. - 5. ); - - // forward computation of partials w.r.t. t - v[s] = 0.; - v[t] = 1.; - w = f.Forward(1, v); - ok &= ( w[x] == -1. ); // dx/dt - ok &= ( w[y] == 1. ); // dy/dt - - // reverse computation of second partials of x - CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); - w[x] = 1.; - w[y] = 0.; - 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) + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(2); + size_t s = 0; + size_t t = 1; + U[s] = 3.; + U[t] = 2.; + Independent(U); + + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(2); + size_t x = 0; + size_t y = 1; + + // dependent variable values + Z[x] = U[s]; + Z[y] = U[t]; + 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); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); + + // check function values + ok &= ( Z[x] == 3. - 2. ); + ok &= ( Z[y] == 2. - 5. ); + + // forward computation of partials w.r.t. t + v[s] = 0.; + v[t] = 1.; + w = f.Forward(1, v); + ok &= ( w[x] == -1. ); // dx/dt + ok &= ( w[y] == 1. ); // dy/dt + + // reverse computation of second partials of x + CPPAD_TESTVECTOR(double) r( f.Domain() * 2 ); + w[x] = 1.; + w[y] = 0.; + 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; + return ok; } bool SubEqTestTwo(void) -{ bool ok = true; - using namespace CppAD; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // independent variable vector - double u0 = .5; - CPPAD_TESTVECTOR(AD) U(1); - U[0] = u0; - Independent(U); - - // 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 - - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v(1); - CPPAD_TESTVECTOR(double) w(1); - - // check value - ok &= NearEqual(Z[0] , u0-2-4-2*u0, eps99 , eps99); - - // forward computation of partials w.r.t. u - size_t j; - size_t p = 5; - double jfac = 1.; - double value = -1.; - v[0] = 1.; - for(j = 1; j < p; j++) - { jfac *= double(j); - w = f.Forward(j, v); - ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j - v[0] = 0.; - value = 0.; - } - - // reverse computation of partials of Taylor coefficients - CPPAD_TESTVECTOR(double) r(p); - w[0] = 1.; - r = f.Reverse(p, w); - jfac = 1.; - value = -1.; - for(j = 0; j < p; j++) - { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j - jfac *= double(j + 1); - value = 0.; - } +{ bool ok = true; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // independent variable vector + double u0 = .5; + CPPAD_TESTVECTOR(AD) U(1); + U[0] = u0; + Independent(U); + + // 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 + + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v(1); + CPPAD_TESTVECTOR(double) w(1); + + // check value + ok &= NearEqual(Z[0] , u0-2-4-2*u0, eps99 , eps99); + + // forward computation of partials w.r.t. u + size_t j; + size_t p = 5; + double jfac = 1.; + double value = -1.; + v[0] = 1.; + for(j = 1; j < p; j++) + { jfac *= double(j); + w = f.Forward(j, v); + ok &= NearEqual(w[0], value/jfac, eps99, eps99); // d^jz/du^j + v[0] = 0.; + value = 0.; + } + + // reverse computation of partials of Taylor coefficients + CPPAD_TESTVECTOR(double) r(p); + w[0] = 1.; + r = f.Reverse(p, w); + jfac = 1.; + value = -1.; + for(j = 0; j < p; j++) + { ok &= NearEqual(r[j], value/jfac, eps99, eps99); // d^jz/du^j + jfac *= double(j + 1); + value = 0.; + } - return ok; + return ok; } } // END empty namespace bool SubEq(void) -{ bool ok = true; - ok &= SubEqTestOne(); - ok &= SubEqTestTwo(); - return ok; +{ bool ok = true; + ok &= SubEqTestOne(); + ok &= SubEqTestTwo(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/subgraph.cpp cppad-2019.02.00.0/test_more/general/subgraph.cpp --- cppad-2018.00.00.0/test_more/general/subgraph.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/subgraph.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,307 +1,308 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ # include namespace { - typedef CPPAD_TESTVECTOR(size_t) svector; - typedef CppAD::sparse_rc sparsity; - // - using CppAD::AD; - typedef CPPAD_TESTVECTOR(AD) avector; - - // ======================================================================== - // algorithm that will be checkpointed - void g_algo(const avector& u, avector& v) - { for(size_t j = 0; j < size_t( u.size() ); ++j) - v[0] += u[j]; - } - - // will be a pointer to atomic version of g_algo - CppAD::checkpoint* atom_g = CPPAD_NULL; - // ------------------------------------------------------------------------ - // record function - void record_function( - bool optimize , - size_t& n , - size_t& m , - CppAD::ADFun& fun ) - { - // declare checkpoint function - avector au(3), av(1); - for(size_t j = 0; j < 3; j++) - au[j] = AD(j); - if( atom_g == CPPAD_NULL ) - atom_g = new CppAD::checkpoint("atom_g", g_algo, au, av); - // - // domain space vector - n = 6; - CPPAD_TESTVECTOR(AD) ax(n); - for(size_t j = 0; j < n; j++) - ax[j] = AD(j); - - // declare independent variables and start recording - CppAD::Independent(ax); - - // range space vector - m = 8; - CPPAD_TESTVECTOR(AD) ay(m); - ay[0] = 0.0; // does not depend on anything - ay[1] = ax[1]; // is equal to an independent variable - AD sum = ax[1] + ax[1]; // only uses ax[1] - ay[2] = sum * ax[2]; // operator(variable, variable) - ay[3] = sin(ax[1]); // operator(variable) - ay[4] = ax[4] / 2.0; // operator(variable, parameter) - ay[5] = 2.0 / ax[3]; // operator(parameter, variable) - // - // a user function call - for(size_t j = 0; j < size_t(au.size()); ++j) - au[j] = ax[j + 3]; - (*atom_g)(au, av); - ay[6] = av[0]; - // - // variable + variable operatros that optimizier will change to - // cumulative sumation - ay[7] = 0.0; - for(size_t j = 0; j < n; ++j) - ay[7] += ax[j]; - // - // create f: x -> y and stop tape recording - fun.Dependent(ax, ay); - // - if( optimize ) - fun.optimize(); - return; - } - // ------------------------------------------------------------------------ - bool compare_subgraph_sparsity( - CppAD::sparse_rc subgraph , - CppAD::sparse_rc check ) - { bool ok = true; - - // check nnz - size_t sub_nnz = subgraph.nnz(); - size_t chk_nnz = check.nnz(); - ok &= sub_nnz == chk_nnz; - size_t nnz = std::min(sub_nnz, chk_nnz); - - // row major order - svector sub_order = subgraph.row_major(); - svector chk_order = check.row_major(); - - // check row indices - const svector& sub_row( subgraph.row() ); - const svector& chk_row( check.row() ); - for(size_t k = 0; k < nnz; k++) - ok &= sub_row[ sub_order[k] ] == chk_row[ chk_order[k] ]; - - // check column indices - const svector& sub_col( subgraph.col() ); - const svector& chk_col( check.col() ); - for(size_t k = 0; k < nnz; k++) - ok &= sub_col[ sub_order[k] ] == chk_col[ chk_order[k] ]; - - /* - std::cout << "\nsub_row = " << sub_row << "\n"; - std::cout << "chk_row = " << chk_row << "\n"; - std::cout << "sub_col = " << sub_col << "\n"; - std::cout << "chk_col = " << chk_col << "\n"; - */ - - return ok; - - } - // ------------------------------------------------------------------------ - bool test_subgraph_sparsity(bool optimize) - { bool ok = true; - - // create f: x -> y - size_t n, m; - CppAD::ADFun f; - record_function(optimize, n, m, f); - - // -------------------------------------------------------------------- - // Entire sparsity pattern - - // compute sparsity using subgraph_sparsity - CPPAD_TESTVECTOR(bool) select_domain(n), select_range(m); - for(size_t j = 0; j < n; j++) - select_domain[j] = true; - for(size_t i = 0; i < m; i++) - select_range[i] = true; - bool transpose = false; - sparsity subgraph_out; - f.subgraph_sparsity( - select_domain, select_range, transpose, subgraph_out - ); - - // compute sparsity using for_jac_sparsity - sparsity pattern_in(n, n, n); - for(size_t k = 0; k < n; k++) - pattern_in.set(k, k, k); - bool dependency = true; - bool internal_bool = true; - sparsity check_out; - f.for_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, check_out - ); - - // compare results - ok &= compare_subgraph_sparsity(subgraph_out, check_out); - - // -------------------------------------------------------------------- - // Exclude ax[1] - select_domain[1] = false; - f.subgraph_sparsity( - select_domain, select_range, transpose, subgraph_out - ); - - pattern_in.resize(n, n, n-1); - for(size_t k = 0; k < n-1; k++) - { if( k < 1 ) - pattern_in.set(k, k, k); - else - pattern_in.set(k, k+1, k+1); - } - f.for_jac_sparsity( - pattern_in, transpose, dependency, internal_bool, check_out - ); - - // compare results - ok &= compare_subgraph_sparsity(subgraph_out, check_out); - - return ok; - } - // ------------------------------------------------------------------------ - bool compare_subgraph_reverse( - const CPPAD_TESTVECTOR(size_t)& col , - const CPPAD_TESTVECTOR(double)& dw , - const CPPAD_TESTVECTOR(double)& check ) - { bool ok = true; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - // - size_t n = size_t( check.size() ); - // - // check order in col - for(size_t c = 1; c < size_t( col.size() ); c++) - ok &= col[c] > col[c-1]; - // - size_t c = 0; - for(size_t j = 1; j < n; j++) - { while( c < size_t( col.size() ) && col[c] < j ) - ++c; - if( c < size_t( col.size() ) && col[c] == j ) - ok &= CppAD::NearEqual(dw[j], check[j], eps99, eps99); - else - ok &= CppAD::NearEqual(0.0, check[j], eps99, eps99); - } - return ok; - } - // ------------------------------------------------------------------------ - bool test_subgraph_reverse(bool optimize) - { bool ok = true; - - // create f: x -> y - size_t n, m; - CppAD::ADFun f; - record_function(optimize, n, m, f); - - // value of x at which to compute derivatives - CPPAD_TESTVECTOR(double) x(n); - for(size_t j = 0; j < n; ++j) - x[j] = double(n) / double(j + 1); - f.Forward(0, x); - - // exclude x[4] from the derivative calculations - CPPAD_TESTVECTOR(bool) select_domain(n); - for(size_t j = 0; j < n; j++) - select_domain[j] = true; - select_domain[4] = false; - f.subgraph_reverse(select_domain); - - // vector used to check results - CPPAD_TESTVECTOR(double) check(n); - for(size_t j = 0; j < n; j++) - check[j] = 0.0; - - // derivative of y[0] - CPPAD_TESTVECTOR(size_t) col; - CPPAD_TESTVECTOR(double) dw; - size_t q = 1; - size_t ell = 0; - f.subgraph_reverse(q, ell, col, dw); - ok &= compare_subgraph_reverse(col, dw, check); - // - // derivative of y[1] - check[1] = 1.0; - ell = 1; - f.subgraph_reverse(q, ell, col, dw); - ok &= compare_subgraph_reverse(col, dw, check); - // - // derivative of y[2] - check[1] = 2.0 * x[2]; - check[2] = 2.0 * x[1]; - ell = 2; - f.subgraph_reverse(q, ell, col, dw); - ok &= compare_subgraph_reverse(col, dw, check); - // - // derivative of y[3] - check[1] = cos( x[1] ); - check[2] = 0.0; - ell = 3; - f.subgraph_reverse(q, ell, col, dw); - ok &= compare_subgraph_reverse(col, dw, check); - // - // derivative of y[4] (x[4] is not selected) - check[1] = 0.0; - ell = 4; - f.subgraph_reverse(q, ell, col, dw); - ok &= compare_subgraph_reverse(col, dw, check); - // - // derivative of y[5] - check[3] = -2.0 / (x[3] * x[3]); - ell = 5; - f.subgraph_reverse(q, ell, col, dw); - ok &= compare_subgraph_reverse(col, dw, check); - // - // derivative of y[6] (x[4] is not selected) - check[3] = 1.0; - check[5] = 1.0; - ell = 6; - f.subgraph_reverse(q, ell, col, dw); - ok &= compare_subgraph_reverse(col, dw, check); - // - // derivative of y[7] (x[4] is not selected) - for(size_t j = 0; j < n; ++j) - check[j] = 1.0; - check[4] = 0.0; - ell = 7; - f.subgraph_reverse(q, ell, col, dw); - ok &= compare_subgraph_reverse(col, dw, check); - // - return ok; - } + typedef CPPAD_TESTVECTOR(size_t) svector; + typedef CppAD::sparse_rc sparsity; + // + using CppAD::AD; + typedef CPPAD_TESTVECTOR(AD) avector; + + // ======================================================================== + // algorithm that will be checkpointed + void g_algo(const avector& u, avector& v) + { for(size_t j = 0; j < size_t( u.size() ); ++j) + v[0] += u[j]; + } + + // will be a pointer to atomic version of g_algo + CppAD::checkpoint* atom_g = CPPAD_NULL; + // ------------------------------------------------------------------------ + // record function + void record_function( + bool optimize , + size_t& n , + size_t& m , + CppAD::ADFun& fun ) + { + // declare checkpoint function + avector au(3), av(1); + for(size_t j = 0; j < 3; j++) + au[j] = AD(j); + if( atom_g == CPPAD_NULL ) + atom_g = new CppAD::checkpoint("atom_g", g_algo, au, av); + // + // domain space vector + n = 6; + CPPAD_TESTVECTOR(AD) ax(n); + for(size_t j = 0; j < n; j++) + ax[j] = AD(j); + + // declare independent variables and start recording + CppAD::Independent(ax); + + // range space vector + m = 8; + CPPAD_TESTVECTOR(AD) ay(m); + ay[0] = 0.0; // does not depend on anything + ay[1] = ax[1]; // is equal to an independent variable + AD sum = ax[1] + ax[1]; // only uses ax[1] + ay[2] = sum * ax[2]; // operator(variable, variable) + ay[3] = sin(ax[1]); // operator(variable) + ay[4] = ax[4] / 2.0; // operator(variable, parameter) + ay[5] = 2.0 / ax[3]; // operator(parameter, variable) + // + // a atomic function call + for(size_t j = 0; j < size_t(au.size()); ++j) + au[j] = ax[j + 3]; + (*atom_g)(au, av); + ay[6] = av[0]; + // + // variable + variable operatros that optimizier will change to + // cumulative sumation + ay[7] = 0.0; + for(size_t j = 0; j < n; ++j) + ay[7] += ax[j]; + // + // create f: x -> y and stop tape recording + fun.Dependent(ax, ay); + // + if( optimize ) + fun.optimize(); + return; + } + // ------------------------------------------------------------------------ + bool compare_subgraph_sparsity( + CppAD::sparse_rc subgraph , + CppAD::sparse_rc check ) + { bool ok = true; + + // check nnz + size_t sub_nnz = subgraph.nnz(); + size_t chk_nnz = check.nnz(); + ok &= sub_nnz == chk_nnz; + size_t nnz = std::min(sub_nnz, chk_nnz); + + // row major order + svector sub_order = subgraph.row_major(); + svector chk_order = check.row_major(); + + // check row indices + const svector& sub_row( subgraph.row() ); + const svector& chk_row( check.row() ); + for(size_t k = 0; k < nnz; k++) + ok &= sub_row[ sub_order[k] ] == chk_row[ chk_order[k] ]; + + // check column indices + const svector& sub_col( subgraph.col() ); + const svector& chk_col( check.col() ); + for(size_t k = 0; k < nnz; k++) + ok &= sub_col[ sub_order[k] ] == chk_col[ chk_order[k] ]; + + /* + std::cout << "\nsub_row = " << sub_row << "\n"; + std::cout << "chk_row = " << chk_row << "\n"; + std::cout << "sub_col = " << sub_col << "\n"; + std::cout << "chk_col = " << chk_col << "\n"; + */ + + return ok; + + } + // ------------------------------------------------------------------------ + bool test_subgraph_sparsity(bool optimize) + { bool ok = true; + + // create f: x -> y + size_t n, m; + CppAD::ADFun f; + record_function(optimize, n, m, f); + + // -------------------------------------------------------------------- + // Entire sparsity pattern + + // compute sparsity using subgraph_sparsity + CPPAD_TESTVECTOR(bool) select_domain(n), select_range(m); + for(size_t j = 0; j < n; j++) + select_domain[j] = true; + for(size_t i = 0; i < m; i++) + select_range[i] = true; + bool transpose = false; + sparsity subgraph_out; + f.subgraph_sparsity( + select_domain, select_range, transpose, subgraph_out + ); + + // compute sparsity using for_jac_sparsity + sparsity pattern_in(n, n, n); + for(size_t k = 0; k < n; k++) + pattern_in.set(k, k, k); + bool dependency = true; + bool internal_bool = true; + sparsity check_out; + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, check_out + ); + + // compare results + ok &= compare_subgraph_sparsity(subgraph_out, check_out); + + // -------------------------------------------------------------------- + // Exclude ax[1] + select_domain[1] = false; + f.subgraph_sparsity( + select_domain, select_range, transpose, subgraph_out + ); + + pattern_in.resize(n, n, n-1); + for(size_t k = 0; k < n-1; k++) + { if( k < 1 ) + pattern_in.set(k, k, k); + else + pattern_in.set(k, k+1, k+1); + } + f.for_jac_sparsity( + pattern_in, transpose, dependency, internal_bool, check_out + ); + + // compare results + ok &= compare_subgraph_sparsity(subgraph_out, check_out); + + return ok; + } + // ------------------------------------------------------------------------ + bool compare_subgraph_reverse( + const CPPAD_TESTVECTOR(size_t)& col , + const CPPAD_TESTVECTOR(double)& dw , + const CPPAD_TESTVECTOR(double)& check ) + { bool ok = true; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + // + size_t n = size_t( check.size() ); + // + // check order in col + for(size_t c = 1; c < size_t( col.size() ); c++) + ok &= col[c] > col[c-1]; + // + size_t c = 0; + for(size_t j = 1; j < n; j++) + { while( c < size_t( col.size() ) && col[c] < j ) + ++c; + if( c < size_t( col.size() ) && col[c] == j ) + ok &= CppAD::NearEqual(dw[j], check[j], eps99, eps99); + else + ok &= CppAD::NearEqual(0.0, check[j], eps99, eps99); + } + return ok; + } + // ------------------------------------------------------------------------ + bool test_subgraph_reverse(bool optimize) + { bool ok = true; + + // create f: x -> y + size_t n, m; + CppAD::ADFun f; + record_function(optimize, n, m, f); + + // value of x at which to compute derivatives + CPPAD_TESTVECTOR(double) x(n); + for(size_t j = 0; j < n; ++j) + x[j] = double(n) / double(j + 1); + f.Forward(0, x); + + // exclude x[4] from the derivative calculations + CPPAD_TESTVECTOR(bool) select_domain(n); + for(size_t j = 0; j < n; j++) + select_domain[j] = true; + select_domain[4] = false; + f.subgraph_reverse(select_domain); + + // vector used to check results + CPPAD_TESTVECTOR(double) check(n); + for(size_t j = 0; j < n; j++) + check[j] = 0.0; + + // derivative of y[0] + CPPAD_TESTVECTOR(size_t) col; + CPPAD_TESTVECTOR(double) dw; + size_t q = 1; + size_t ell = 0; + f.subgraph_reverse(q, ell, col, dw); + ok &= compare_subgraph_reverse(col, dw, check); + // + // derivative of y[1] + check[1] = 1.0; + ell = 1; + f.subgraph_reverse(q, ell, col, dw); + ok &= compare_subgraph_reverse(col, dw, check); + // + // derivative of y[2] + check[1] = 2.0 * x[2]; + check[2] = 2.0 * x[1]; + ell = 2; + f.subgraph_reverse(q, ell, col, dw); + ok &= compare_subgraph_reverse(col, dw, check); + // + // derivative of y[3] + check[1] = cos( x[1] ); + check[2] = 0.0; + ell = 3; + f.subgraph_reverse(q, ell, col, dw); + ok &= compare_subgraph_reverse(col, dw, check); + // + // derivative of y[4] (x[4] is not selected) + check[1] = 0.0; + ell = 4; + f.subgraph_reverse(q, ell, col, dw); + ok &= compare_subgraph_reverse(col, dw, check); + // + // derivative of y[5] + check[3] = -2.0 / (x[3] * x[3]); + ell = 5; + f.subgraph_reverse(q, ell, col, dw); + ok &= compare_subgraph_reverse(col, dw, check); + // + // derivative of y[6] (x[4] is not selected) + check[3] = 1.0; + check[5] = 1.0; + ell = 6; + f.subgraph_reverse(q, ell, col, dw); + ok &= compare_subgraph_reverse(col, dw, check); + // + // derivative of y[7] (x[4] is not selected) + for(size_t j = 0; j < n; ++j) + check[j] = 1.0; + check[4] = 0.0; + ell = 7; + f.subgraph_reverse(q, ell, col, dw); + ok &= compare_subgraph_reverse(col, dw, check); + // + return ok; + } } bool subgraph(void) -{ bool ok = true; - bool optimize = false; - ok &= test_subgraph_sparsity(optimize); - ok &= test_subgraph_reverse(optimize); - optimize = true; - ok &= test_subgraph_sparsity(optimize); - ok &= test_subgraph_reverse(optimize); - // - ok &= atom_g != CPPAD_NULL; - delete atom_g; - // - return ok; +{ bool ok = true; + bool optimize = false; + ok &= test_subgraph_sparsity(optimize); + ok &= test_subgraph_reverse(optimize); + optimize = true; + ok &= test_subgraph_sparsity(optimize); + ok &= test_subgraph_reverse(optimize); + // + ok &= atom_g != CPPAD_NULL; + delete atom_g; + // + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/sub_zero.cpp cppad-2019.02.00.0/test_more/general/sub_zero.cpp --- cppad-2018.00.00.0/test_more/general/sub_zero.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/sub_zero.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test the use of the special parameters zero and one with the multiply operator @@ -20,59 +21,59 @@ bool SubZero(void) { - using namespace CppAD; + using namespace CppAD; - bool ok = true; + bool ok = true; - size_t i; - for(i = 0; i < 2; i++) - { // run through the cases x = 0, 1 + size_t i; + for(i = 0; i < 2; i++) + { // run through the cases x = 0, 1 - size_t j; - for(j = 0; j < 2; j++) - { // run through the cases y = 0, 1 + size_t j; + for(j = 0; j < 2; j++) + { // run through the cases y = 0, 1 - CPPAD_TESTVECTOR( ADdouble ) x(1); - x[0] = double(i); - Independent(x); + CPPAD_TESTVECTOR( ADdouble ) x(1); + x[0] = double(i); + Independent(x); - CPPAD_TESTVECTOR( ADDdouble ) y(1); - y[0] = ADDdouble(j); - Independent(y); + CPPAD_TESTVECTOR( ADDdouble ) y(1); + y[0] = ADDdouble(j); + Independent(y); - CPPAD_TESTVECTOR( ADDdouble ) z(2); - z[0] = x[0] - y[0]; - z[1] = y[0] - x[0]; - z[1] -= x[0]; + CPPAD_TESTVECTOR( ADDdouble ) z(2); + z[0] = x[0] - y[0]; + z[1] = y[0] - x[0]; + z[1] -= x[0]; - // f(y) = z = { x - y , y - x - x } - ADFun< ADdouble > f(y, z); - CPPAD_TESTVECTOR( ADdouble ) u( f.Domain() ); - CPPAD_TESTVECTOR( ADdouble ) v( f.Range() ); + // f(y) = z = { x - y , y - x - x } + ADFun< ADdouble > f(y, z); + CPPAD_TESTVECTOR( ADdouble ) u( f.Domain() ); + CPPAD_TESTVECTOR( ADdouble ) v( f.Range() ); - // v = f(y) - u[0] = ADdouble(j); - v = f.Forward(0, u); + // v = f(y) + u[0] = ADdouble(j); + v = f.Forward(0, u); - // check value of f - ok &= v[0] == x[0] - ADdouble(j); - ok &= v[1] == ADdouble(j) - x[0] - x[0]; + // check value of f + ok &= v[0] == x[0] - ADdouble(j); + ok &= v[1] == ADdouble(j) - x[0] - x[0]; - // g(x) = f(y) = {x - y , y - x - x} - ADFun g(x, v); - CPPAD_TESTVECTOR( double ) a( g.Domain() ); - CPPAD_TESTVECTOR( double ) b( g.Range() ); + // g(x) = f(y) = {x - y , y - x - x} + ADFun g(x, v); + CPPAD_TESTVECTOR( double ) a( g.Domain() ); + CPPAD_TESTVECTOR( double ) b( g.Range() ); - // b = g'(x) - a[0] = 1.; - b = g.Forward(1, a); + // b = g'(x) + a[0] = 1.; + b = g.Forward(1, a); - // check derivatives of g - ok &= (b[0] == 1.); - ok &= (b[1] == -2.); + // check derivatives of g + ok &= (b[0] == 1.); + ok &= (b[1] == -2.); - } - } + } + } - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/tan.cpp cppad-2019.02.00.0/test_more/general/tan.cpp --- cppad-2018.00.00.0/test_more/general/tan.cpp 2018-01-01 08:32:20.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/tan.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* @@ -17,161 +18,162 @@ # include namespace { - bool tan_two(void) - { bool ok = true; - 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; - - // 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 &= size_t( y1.size() ) == m; - - // secondorder Taylor coefficients - CPPAD_TESTVECTOR(double) x2(n), y2; - x2[0] = 0.0; - y2 = f.Forward(2, x2); - 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) - check = 8.0 * tan(0.5) * sec_sq / 2.0; - ok &= NearEqual(y2[0] , check, eps, eps); - // - return ok; - } - bool tan_case(bool tan_first) - { bool ok = true; - 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 - ok &= NearEqual(ax[0] , ay[0], eps, eps); - - // create f: x -> y and vectors used for derivative calculations - 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); - ok &= NearEqual(dy[0], 1e0, eps, eps); - size_t p, order = 5; - dx[0] = 0.; - for(p = 2; p < order; p++) - { 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.; - dw = f.Reverse(order, w); - 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) - { bool ok = true; - 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); - AD z; - if( tanh_first ) - { z = tanh( ax[0] ); - ay[0] = .5 * log( (1. + z) / (1. - z) ); - } - else - { z = .5 * log( (1. + ax[0]) / (1. - ax[0]) ); - ay[0] = tanh(z); - } - // 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_TESTVECTOR(double) dx(n), dy(m); - - // forward computation of partials w.r.t. x - dx[0] = 1.; - dy = f.Forward(1, dx); - ok &= NearEqual(dy[0], 1e0, eps, eps); - size_t p, order = 5; - dx[0] = 0.; - for(p = 2; p < order; p++) - { 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.; - dw = f.Reverse(order, w); - ok &= NearEqual(dw[0], 1e0, eps, eps); - for(p = 1; p < order; p++) - ok &= NearEqual(dw[p], 0e0, eps, eps); + bool tan_two(void) + { bool ok = true; + 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; + + // 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 &= size_t( y1.size() ) == m; + + // secondorder Taylor coefficients + CPPAD_TESTVECTOR(double) x2(n), y2; + x2[0] = 0.0; + y2 = f.Forward(2, x2); + 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) + check = 8.0 * tan(0.5) * sec_sq / 2.0; + ok &= NearEqual(y2[0] , check, eps, eps); + // + return ok; + } + bool tan_case(bool tan_first) + { bool ok = true; + 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 + ok &= NearEqual(ax[0] , ay[0], eps, eps); + + // create f: x -> y and vectors used for derivative calculations + 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); + ok &= NearEqual(dy[0], 1e0, eps, eps); + size_t p, order = 5; + dx[0] = 0.; + for(p = 2; p < order; p++) + { 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.; + dw = f.Reverse(order, w); + 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) + { bool ok = true; + 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); + AD z; + if( tanh_first ) + { z = tanh( ax[0] ); + ay[0] = .5 * log( (1. + z) / (1. - z) ); + } + else + { z = .5 * log( (1. + ax[0]) / (1. - ax[0]) ); + ay[0] = tanh(z); + } + // 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_TESTVECTOR(double) dx(n), dy(m); + + // forward computation of partials w.r.t. x + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 1e0, eps, eps); + size_t p, order = 5; + dx[0] = 0.; + for(p = 2; p < order; p++) + { 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.; + dw = f.Reverse(order, w); + ok &= NearEqual(dw[0], 1e0, eps, eps); + for(p = 1; p < order; p++) + ok &= NearEqual(dw[p], 0e0, eps, eps); - return ok; - } + return ok; + } } bool tan(void) -{ bool ok = true; - // - ok &= tan_case(true); - ok &= tan_case(false); - ok &= tanh_case(true); - ok &= tanh_case(false); - // - ok &= tan_two(); - return ok; +{ bool ok = true; + // + ok &= tan_case(true); + ok &= tan_case(false); + ok &= tanh_case(true); + ok &= tanh_case(false); + // + ok &= tan_two(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/test_vector.cpp cppad-2019.02.00.0/test_more/general/test_vector.cpp --- cppad-2018.00.00.0/test_more/general/test_vector.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/test_vector.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test deprecated CPPAD_TEST_VECTOR macro (should use CPPAD_TESTVECTOR instead @@ -16,57 +17,57 @@ // this test is coppied from example/add.cpp on 2012-06-06 bool test_vector(void) -{ bool ok = true; - using CppAD::AD; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - // domain space vector - size_t n = 1; - double x0 = 0.5; - CPPAD_TEST_VECTOR< AD > x(n); - x[0] = x0; - - // declare independent variables and start tape recording - CppAD::Independent(x); - - // 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 - - // range space vector - size_t m = 1; - CPPAD_TEST_VECTOR< AD > y(m); - y[0] = d + x[0]; // AD + AD - - // create f: x -> y and stop tape recording - CppAD::ADFun f(x, y); - - // check value - ok &= NearEqual(y[0] , 2. * x0 + 10, eps99, eps99); - - // forward computation of partials w.r.t. x[0] - CPPAD_TEST_VECTOR< double > dx(n); - CPPAD_TEST_VECTOR< double > dy(m); - dx[0] = 1.; - dy = f.Forward(1, dx); - ok &= NearEqual(dy[0], 2., eps99, eps99); - - // reverse computation of derivative of y[0] - CPPAD_TEST_VECTOR< double > w(m); - CPPAD_TEST_VECTOR< double > dw(n); - w[0] = 1.; - dw = f.Reverse(1, w); - ok &= NearEqual(dw[0], 2., eps99, eps99); - - // use a VecAD::reference object with addition - CppAD::VecAD v(1); - AD zero(0); - v[zero] = a; - AD result = v[zero] + 2; - ok &= (result == b); +{ bool ok = true; + using CppAD::AD; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + // domain space vector + size_t n = 1; + double x0 = 0.5; + CPPAD_TEST_VECTOR< AD > x(n); + x[0] = x0; + + // declare independent variables and start tape recording + CppAD::Independent(x); + + // 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 + + // range space vector + size_t m = 1; + CPPAD_TEST_VECTOR< AD > y(m); + y[0] = d + x[0]; // AD + AD + + // create f: x -> y and stop tape recording + CppAD::ADFun f(x, y); + + // check value + ok &= NearEqual(y[0] , 2. * x0 + 10, eps99, eps99); + + // forward computation of partials w.r.t. x[0] + CPPAD_TEST_VECTOR< double > dx(n); + CPPAD_TEST_VECTOR< double > dy(m); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], 2., eps99, eps99); + + // reverse computation of derivative of y[0] + CPPAD_TEST_VECTOR< double > w(m); + CPPAD_TEST_VECTOR< double > dw(n); + w[0] = 1.; + dw = f.Reverse(1, w); + ok &= NearEqual(dw[0], 2., eps99, eps99); + + // use a VecAD::reference object with addition + CppAD::VecAD v(1); + AD zero(0); + v[zero] = a; + AD result = v[zero] + 2; + ok &= (result == b); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/to_string.cpp cppad-2019.02.00.0/test_more/general/to_string.cpp --- cppad-2018.00.00.0/test_more/general/to_string.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/to_string.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- -CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell +CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ // Complex examples should supppress conversion warnings # include @@ -15,43 +16,43 @@ # 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 - 1.0 ) <= 2.0 * eps; - // - check = std::atof( imag.c_str() ); - ok &= std::fabs( check / e - 1.0 ) <= 2.0 * eps; - // - return ok; - } + template + bool test(void) + { bool ok = true; + Float eps = std::numeric_limits::epsilon(); + Float pi = Float( 4.0 * std::atan(1.0) ); + Float e = Float( 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 = Float( std::atof( real.c_str() ) ); + ok &= std::fabs( check / pi - 1.0 ) <= 2.0 * eps; + // + check = Float( std::atof( imag.c_str() ) ); + ok &= std::fabs( check / e - 1.0 ) <= 2.0 * eps; + // + return ok; + } } bool to_string(void) -{ bool ok = true; +{ bool ok = true; - ok &= test(); - ok &= test(); + ok &= test(); + ok &= test(); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/value.cpp cppad-2019.02.00.0/test_more/general/value.cpp --- cppad-2018.00.00.0/test_more/general/value.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/value.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old Value example now used just for valiadation testing @@ -17,42 +18,42 @@ # include bool Value(void) -{ bool ok = true; +{ bool ok = true; - using namespace CppAD; + using namespace CppAD; - // independent variable vector, indices, values, and declaration - CPPAD_TESTVECTOR(AD) U(2); - size_t s = 0; - size_t t = 1; - U[s] = 3.; - U[t] = 4.; - Independent(U); + // independent variable vector, indices, values, and declaration + CPPAD_TESTVECTOR(AD) U(2); + size_t s = 0; + size_t t = 1; + U[s] = 3.; + U[t] = 4.; + Independent(U); - // cannot call Value after Independent (tape is recording) + // cannot call Value after Independent (tape is recording) - // dependent variable vector and indices - CPPAD_TESTVECTOR(AD) Z(1); - size_t x = 0; + // dependent variable vector and indices + CPPAD_TESTVECTOR(AD) Z(1); + size_t x = 0; - // dependent variable values - Z[x] = - U[t]; + // dependent variable values + Z[x] = - U[t]; - // create f: U -> Z and vectors used for derivative calculations - ADFun f(U, Z); - CPPAD_TESTVECTOR(double) v( f.Domain() ); - CPPAD_TESTVECTOR(double) w( f.Range() ); + // create f: U -> Z and vectors used for derivative calculations + ADFun f(U, Z); + CPPAD_TESTVECTOR(double) v( f.Domain() ); + CPPAD_TESTVECTOR(double) w( f.Range() ); - // can call Value after ADFun constructor (tape is no longer recording) + // can call Value after ADFun constructor (tape is no longer recording) - // check value of s - double sValue = Value(U[s]); - ok &= ( sValue == 3. ); + // check value of s + double sValue = Value(U[s]); + ok &= ( sValue == 3. ); - // check value of x - double xValue = Value(Z[x]); - ok &= ( xValue == -4. ); + // check value of x + double xValue = Value(Z[x]); + ok &= ( xValue == -4. ); - return ok; + return ok; } // END C++ diff -Nru cppad-2018.00.00.0/test_more/general/vec_ad.cpp cppad-2019.02.00.0/test_more/general/vec_ad.cpp --- cppad-2018.00.00.0/test_more/general/vec_ad.cpp 2018-01-01 08:32:18.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/vec_ad.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Old examples now only used for validation testing @@ -21,240 +22,240 @@ namespace { // Begin empty namespace bool VecADTestOne(void) -{ bool ok = true; - using namespace CppAD; - using CppAD::sin; - using CppAD::cos; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - - size_t n = 3; - AD N(n); - - AD a; - size_t i; - - // create the array - CppAD::VecAD V(n); - - // check assignment from double (while not taping) - for(i = 0; i < n; i++) - V[i] = double(n - i); - - // check assignment from an AD (while not taping) - for(i = 0; i < n; i++) - V[i] = 2. * V[i]; - - // check array values (while not taping) - for(i = 0; i < n; i++) - ok &= ( V[i] == 2. * double(n - i) ); - - // independent variable - CPPAD_TESTVECTOR(AD) X(1); - X[0] = double(n - 1); - Independent(X); - - // check assignment from double during taping - a = -1.; - for(i = 0; i < n; i++) - { a += 1.; - V[a] = double(n - i); - } - - // check assignment from AD during taping - a = -1.; - for(i = 0; i < n; i++) - { a += 1.; - V[a] = sin( X[0] ) * V[a]; - } - - // dependent variable - CPPAD_TESTVECTOR(AD) Z(1); - Z[0] = V[ X[0] ]; - - // create f: X -> Z - ADFun f(X, Z); - CPPAD_TESTVECTOR(double) x( f.Domain() ); - CPPAD_TESTVECTOR(double) dx( f.Domain() ); - CPPAD_TESTVECTOR(double) z( f.Range() ); - CPPAD_TESTVECTOR(double) dz( f.Range() ); - - double vx; - for(i = 0; i < n; i++) - { // check that the indexing operation was taped - x[0] = double(i); - z = f.Forward(0, x); - vx = double(n - i); - ok &= NearEqual(z[0], sin(x[0]) * vx, eps99, eps99); - - // 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, eps99, eps99); - - // reverse mode calculation of same value - dz[0] = 1.; - dx = f.Reverse(1, dz); - ok &= NearEqual(dx[0], cos(x[0]) * vx, eps99, eps99); - } +{ bool ok = true; + using namespace CppAD; + using CppAD::sin; + using CppAD::cos; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + + size_t n = 3; + AD N(n); + + AD a; + size_t i; + + // create the array + CppAD::VecAD V(n); + + // check assignment from double (while not taping) + for(i = 0; i < n; i++) + V[i] = double(n - i); + + // check assignment from an AD (while not taping) + for(i = 0; i < n; i++) + V[i] = 2. * V[i]; + + // check array values (while not taping) + for(i = 0; i < n; i++) + ok &= ( V[i] == 2. * double(n - i) ); + + // independent variable + CPPAD_TESTVECTOR(AD) X(1); + X[0] = double(n - 1); + Independent(X); + + // check assignment from double during taping + a = -1.; + for(i = 0; i < n; i++) + { a += 1.; + V[a] = double(n - i); + } + + // check assignment from AD during taping + a = -1.; + for(i = 0; i < n; i++) + { a += 1.; + V[a] = sin( X[0] ) * V[a]; + } + + // dependent variable + CPPAD_TESTVECTOR(AD) Z(1); + Z[0] = V[ X[0] ]; + + // create f: X -> Z + ADFun f(X, Z); + CPPAD_TESTVECTOR(double) x( f.Domain() ); + CPPAD_TESTVECTOR(double) dx( f.Domain() ); + CPPAD_TESTVECTOR(double) z( f.Range() ); + CPPAD_TESTVECTOR(double) dz( f.Range() ); + + double vx; + for(i = 0; i < n; i++) + { // check that the indexing operation was taped + x[0] = double(i); + z = f.Forward(0, x); + vx = double(n - i); + ok &= NearEqual(z[0], sin(x[0]) * vx, eps99, eps99); + + // 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, eps99, eps99); + + // reverse mode calculation of same value + dz[0] = 1.; + dx = f.Reverse(1, dz); + ok &= NearEqual(dx[0], cos(x[0]) * vx, eps99, eps99); + } - return ok; + return ok; } // 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 eps99 = 99.0 * std::numeric_limits::epsilon(); - - double pi = 4. * CppAD::atan(1.); - size_t nx = 10; // number of x grid point - double xLow = 0; // minimum value for x - double xUp = 2 * pi; // maximum value for x - double xStep = (xUp - xLow) / double(nx - 1); // step size in x - double xCur; // current value for x - - // fill in the data vector on a uniform grid - VecAD Data(nx); - size_t i; - for(i = 0; i < nx; i++) - { xCur = xLow + double(i) * xStep; - // use size_t indexing of Data while not taping - Data[i] = CppAD::sin(xCur); - } - - // declare independent variable - CPPAD_TESTVECTOR(AD) X(1); - X[0] = 2.; - Independent(X); - - // compute index corresponding to current value of X[0] - AD I = X[0] / xStep; - AD Ifloor = Floor(I); - - // make sure Ifloor >= 0 (during taping) - AD Zero(0); - Ifloor = CondExpLt(Ifloor, Zero, Zero, Ifloor); - - // make sure Ifloor <= nx - 2 (during taping) - AD Nxminus2(nx - 2); - Ifloor = CondExpGt(Ifloor, Nxminus2, Nxminus2, Ifloor); - - // Iceil is Ifloor + 1 - AD Iceil = Ifloor + 1.; - - // linear interpolate Data - CPPAD_TESTVECTOR(AD) Y(1); - Y[0] = Data[Ifloor] + (I - Ifloor) * (Data[Iceil] - Data[Ifloor]); - - // create f: X -> Y that linearly interpolates the data vector - ADFun f(X, Y); - - // evaluate the linear interpolant at the mid point for first interval - CPPAD_TESTVECTOR(double) x(1); - CPPAD_TESTVECTOR(double) y(1); - x[0] = xStep / 2.; - y = f.Forward(0, x); - ok &= NearEqual(y[0], (Data[0] + Data[1])/2., eps99, eps99); - - // evalute the derivative with respect to x - CPPAD_TESTVECTOR(double) dx(1); - CPPAD_TESTVECTOR(double) dy(1); - dx[0] = 1.; - dy = f.Forward(1, dx); - ok &= NearEqual(dy[0], (Data[1] - Data[0]) / xStep, eps99, eps99); +{ bool ok = true; + using namespace CppAD; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + double pi = 4. * CppAD::atan(1.); + size_t nx = 10; // number of x grid point + double xLow = 0; // minimum value for x + double xUp = 2 * pi; // maximum value for x + double xStep = (xUp - xLow) / double(nx - 1); // step size in x + double xCur; // current value for x + + // fill in the data vector on a uniform grid + VecAD Data(nx); + size_t i; + for(i = 0; i < nx; i++) + { xCur = xLow + double(i) * xStep; + // use size_t indexing of Data while not taping + Data[i] = CppAD::sin(xCur); + } + + // declare independent variable + CPPAD_TESTVECTOR(AD) X(1); + X[0] = 2.; + Independent(X); + + // compute index corresponding to current value of X[0] + AD I = X[0] / xStep; + AD Ifloor = Floor(I); + + // make sure Ifloor >= 0 (during taping) + AD Zero(0); + Ifloor = CondExpLt(Ifloor, Zero, Zero, Ifloor); + + // make sure Ifloor <= nx - 2 (during taping) + AD Nxminus2(nx - 2); + Ifloor = CondExpGt(Ifloor, Nxminus2, Nxminus2, Ifloor); + + // Iceil is Ifloor + 1 + AD Iceil = Ifloor + 1.; + + // linear interpolate Data + CPPAD_TESTVECTOR(AD) Y(1); + Y[0] = Data[Ifloor] + (I - Ifloor) * (Data[Iceil] - Data[Ifloor]); + + // create f: X -> Y that linearly interpolates the data vector + ADFun f(X, Y); + + // evaluate the linear interpolant at the mid point for first interval + CPPAD_TESTVECTOR(double) x(1); + CPPAD_TESTVECTOR(double) y(1); + x[0] = xStep / 2.; + y = f.Forward(0, x); + ok &= NearEqual(y[0], (Data[0] + Data[1])/2., eps99, eps99); + + // evalute the derivative with respect to x + CPPAD_TESTVECTOR(double) dx(1); + CPPAD_TESTVECTOR(double) dy(1); + dx[0] = 1.; + dy = f.Forward(1, dx); + ok &= NearEqual(dy[0], (Data[1] - Data[0]) / xStep, eps99, eps99); - return ok; + return ok; } # include bool SecondOrderReverse(void) -{ // 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; - using CppAD::AD; - using CppAD::NearEqual; - double eps = 10. * std::numeric_limits::epsilon(); - - size_t n = 1; - CPPAD_TESTVECTOR(AD) X(n); - X[0] = 2.; - CppAD::Independent(X); - - size_t m = 2; - CPPAD_TESTVECTOR(AD) Y(m); - - // The LdpOp instruction corresponds to operations with VecAD vectors. - CppAD::VecAD Z(2); - AD zero = 0; - Z[zero] = X[0] + 1; - - // 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 - // This will use the LdpOp instruction because the index - // access to z is the parameter zero. - Y[0] = Z[zero] * Z[zero]; - Y[1] = Z[one] * Z[one]; - - CppAD::ADFun f(X, Y); - - // first order forward - CPPAD_TESTVECTOR(double) dx(n); - size_t p = 1; - dx[0] = 1.; - f.Forward(p, dx); - - // Test LdpOp - // second order reverse (test exp_if_true case) - CPPAD_TESTVECTOR(double) w(m), dw(2 * n); - w[0] = 1.; - w[1] = 0.; - p = 2; - dw = f.Reverse(p, w); - - // check first derivative in dw - double check = 2. * (Value( X[0] ) + 1.); - ok &= NearEqual(dw[0], check, eps, eps); - - // check second derivative in dw - check = 2.; - ok &= NearEqual(dw[1], check, eps, eps); - - // Test LdvOp - // second order reverse (test exp_if_true case) - w[0] = 0.; - w[1] = 1.; - p = 2; - dw = f.Reverse(p, w); - - // check first derivative in dw - check = 2. * (Value( X[0] ) + 1.); - ok &= NearEqual(dw[0], check, eps, eps); - - // check second derivative in dw - check = 2.; - ok &= NearEqual(dw[1], check, eps, eps); +{ // 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; + using CppAD::AD; + using CppAD::NearEqual; + double eps = 10. * std::numeric_limits::epsilon(); + + size_t n = 1; + CPPAD_TESTVECTOR(AD) X(n); + X[0] = 2.; + CppAD::Independent(X); + + size_t m = 2; + CPPAD_TESTVECTOR(AD) Y(m); + + // The LdpOp instruction corresponds to operations with VecAD vectors. + CppAD::VecAD Z(2); + AD zero = 0; + Z[zero] = X[0] + 1; + + // 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 + // This will use the LdpOp instruction because the index + // access to z is the parameter zero. + Y[0] = Z[zero] * Z[zero]; + Y[1] = Z[one] * Z[one]; + + CppAD::ADFun f(X, Y); + + // first order forward + CPPAD_TESTVECTOR(double) dx(n); + size_t p = 1; + dx[0] = 1.; + f.Forward(p, dx); + + // Test LdpOp + // second order reverse (test exp_if_true case) + CPPAD_TESTVECTOR(double) w(m), dw(2 * n); + w[0] = 1.; + w[1] = 0.; + p = 2; + dw = f.Reverse(p, w); + + // check first derivative in dw + double check = 2. * (Value( X[0] ) + 1.); + ok &= NearEqual(dw[0], check, eps, eps); + + // check second derivative in dw + check = 2.; + ok &= NearEqual(dw[1], check, eps, eps); + + // Test LdvOp + // second order reverse (test exp_if_true case) + w[0] = 0.; + w[1] = 1.; + p = 2; + dw = f.Reverse(p, w); + + // check first derivative in dw + check = 2. * (Value( X[0] ) + 1.); + ok &= NearEqual(dw[0], check, eps, eps); + + // check second derivative in dw + check = 2.; + ok &= NearEqual(dw[1], check, eps, eps); - return ok; + return ok; } } // END empty namespace bool VecAD(void) -{ bool ok = true; - ok &= VecADTestOne(); - ok &= VecADTestTwo(); - ok &= SecondOrderReverse(); - return ok; +{ bool ok = true; + ok &= VecADTestOne(); + ok &= VecADTestTwo(); + ok &= SecondOrderReverse(); + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/vec_ad_par.cpp cppad-2019.02.00.0/test_more/general/vec_ad_par.cpp --- cppad-2018.00.00.0/test_more/general/vec_ad_par.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/vec_ad_par.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test the use of the parameters in VecAD element assignments @@ -20,52 +21,52 @@ bool VecADPar(void) { - using namespace CppAD; + using namespace CppAD; - bool ok = true; + bool ok = true; - CPPAD_TESTVECTOR( ADdouble ) x(2); - x[0] = 0; - x[1] = 0; - Independent(x); - - CPPAD_TESTVECTOR( ADDdouble ) y(1); - y[0] = 1; - Independent(y); - - VecAD< ADdouble > v(2); - ADDdouble zero(0); - ADDdouble one(1); - 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); - z[0] = v[zero] + v[one]; - - // f(y) = x[0] + x[1] - ADFun< ADdouble > f(y, z); - CPPAD_TESTVECTOR( ADdouble ) a( f.Domain() ); - CPPAD_TESTVECTOR( ADdouble ) b( f.Range() ); - - // fy = f(y) = x[0] + x[1] - a[0] = 0.; - b = f.Forward(0, a); - - // check value of f - ok &= b[0] == (x[0] + x[1]); - - // g(x) = x[0] + x[1]; - ADFun g(x, b); - CPPAD_TESTVECTOR( double ) c( g.Domain() ); - CPPAD_TESTVECTOR( double ) d( g.Range() ); - - // d = g(1, 2) - c[0] = 1.; // these tow values are not equal and correspond - c[1] = 2.; // to replacements for the equal parameter values above - d = g.Forward(0, c); + CPPAD_TESTVECTOR( ADdouble ) x(2); + x[0] = 0; + x[1] = 0; + Independent(x); + + CPPAD_TESTVECTOR( ADDdouble ) y(1); + y[0] = 1; + Independent(y); + + VecAD< ADdouble > v(2); + ADDdouble zero(0); + ADDdouble one(1); + 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); + z[0] = v[zero] + v[one]; + + // f(y) = x[0] + x[1] + ADFun< ADdouble > f(y, z); + CPPAD_TESTVECTOR( ADdouble ) a( f.Domain() ); + CPPAD_TESTVECTOR( ADdouble ) b( f.Range() ); + + // fy = f(y) = x[0] + x[1] + a[0] = 0.; + b = f.Forward(0, a); + + // check value of f + ok &= b[0] == (x[0] + x[1]); + + // g(x) = x[0] + x[1]; + ADFun g(x, b); + CPPAD_TESTVECTOR( double ) c( g.Domain() ); + CPPAD_TESTVECTOR( double ) d( g.Range() ); + + // d = g(1, 2) + c[0] = 1.; // these tow values are not equal and correspond + c[1] = 2.; // to replacements for the equal parameter values above + d = g.Forward(0, c); - // check function value - ok &= (d[0] == c[0] + c[1]); + // check function value + ok &= (d[0] == c[0] + c[1]); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/test_more/general/vec_unary.cpp cppad-2019.02.00.0/test_more/general/vec_unary.cpp --- cppad-2018.00.00.0/test_more/general/vec_unary.cpp 2018-01-01 08:32:19.000000000 +0000 +++ cppad-2019.02.00.0/test_more/general/vec_unary.cpp 2019-01-31 12:35:17.000000000 +0000 @@ -1,13 +1,14 @@ /* -------------------------------------------------------------------------- CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 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. --------------------------------------------------------------------------- */ +CppAD is distributed under the terms of the + Eclipse Public License Version 2.0. + +This Source Code may also be made available under the following +Secondary License when the conditions for such availability set forth +in the Eclipse Public License, Version 2.0 are satisfied: + GNU General Public License, Version 2.0 or later. +---------------------------------------------------------------------------- */ /* Test the use of VecADelem with unary operators @@ -18,82 +19,82 @@ bool VecUnary(void) { - using namespace CppAD; - using CppAD::sin; - using CppAD::atan; - using CppAD::cos; - using CppAD::exp; - using CppAD::log; - using CppAD::sqrt; - using CppAD::NearEqual; - double eps99 = 99.0 * std::numeric_limits::epsilon(); - - bool ok = true; - size_t n = 8; - size_t i; - - CPPAD_TESTVECTOR(AD) X(n); - VecAD Y(n); - CPPAD_TESTVECTOR(AD) Z(n); - - - for(i = 0; i < n; i++) - X[i] = int(i); // some compilers require the int here - Independent(X); - - AD j; - - j = 0.; - Y[j] = X[0]; - Z[0] = -Y[j]; - - j = 1.; - Y[j] = X[1]; - Z[1] = sin( Y[j] ); - - j = 2.; - Y[j] = X[2]; - Z[2] = fabs( Y[j] ); - - j = 3.; - Y[j] = X[3]; - Z[3] = atan( Y[j] ); - - j = 4.; - Y[j] = X[4]; - Z[4] = cos( Y[j] ); - - j = 5.; - Y[j] = X[5]; - Z[5] = exp( Y[j] ); - - j = 6.; - Y[j] = X[6]; - Z[6] = log( Y[j] ); - - j = 7.; - Y[j] = X[7]; - Z[7] = sqrt( Y[j] ); - - - ADFun f(X, Z); - CPPAD_TESTVECTOR(double) x(n); - CPPAD_TESTVECTOR(double) z(n); - - for(i = 0; i < n; i++) - x[i] = 2. / double(i + 1); - x[7] = fabs( x[7] ); - - z = f.Forward(0, x); - - ok &= NearEqual(z[0], - x[0], eps99, eps99); - ok &= NearEqual(z[1], sin( x[1] ), eps99, eps99); - ok &= NearEqual(z[2], fabs( x[2] ), eps99, eps99); - ok &= NearEqual(z[3], atan(x[3] ), eps99, eps99); - ok &= NearEqual(z[4], cos( x[4] ), eps99, eps99); - ok &= NearEqual(z[5], exp( x[5] ), eps99, eps99); - ok &= NearEqual(z[6], log( x[6] ), eps99, eps99); - ok &= NearEqual(z[7], sqrt(x[7] ), eps99, eps99); + using namespace CppAD; + using CppAD::sin; + using CppAD::atan; + using CppAD::cos; + using CppAD::exp; + using CppAD::log; + using CppAD::sqrt; + using CppAD::NearEqual; + double eps99 = 99.0 * std::numeric_limits::epsilon(); + + bool ok = true; + size_t n = 8; + size_t i; + + CPPAD_TESTVECTOR(AD) X(n); + VecAD Y(n); + CPPAD_TESTVECTOR(AD) Z(n); + + + for(i = 0; i < n; i++) + X[i] = int(i); // some compilers require the int here + Independent(X); + + AD j; + + j = 0.; + Y[j] = X[0]; + Z[0] = -Y[j]; + + j = 1.; + Y[j] = X[1]; + Z[1] = sin( Y[j] ); + + j = 2.; + Y[j] = X[2]; + Z[2] = fabs( Y[j] ); + + j = 3.; + Y[j] = X[3]; + Z[3] = atan( Y[j] ); + + j = 4.; + Y[j] = X[4]; + Z[4] = cos( Y[j] ); + + j = 5.; + Y[j] = X[5]; + Z[5] = exp( Y[j] ); + + j = 6.; + Y[j] = X[6]; + Z[6] = log( Y[j] ); + + j = 7.; + Y[j] = X[7]; + Z[7] = sqrt( Y[j] ); + + + ADFun f(X, Z); + CPPAD_TESTVECTOR(double) x(n); + CPPAD_TESTVECTOR(double) z(n); + + for(i = 0; i < n; i++) + x[i] = 2. / double(i + 1); + x[7] = fabs( x[7] ); + + z = f.Forward(0, x); + + ok &= NearEqual(z[0], - x[0], eps99, eps99); + ok &= NearEqual(z[1], sin( x[1] ), eps99, eps99); + ok &= NearEqual(z[2], fabs( x[2] ), eps99, eps99); + ok &= NearEqual(z[3], atan(x[3] ), eps99, eps99); + ok &= NearEqual(z[4], cos( x[4] ), eps99, eps99); + ok &= NearEqual(z[5], exp( x[5] ), eps99, eps99); + ok &= NearEqual(z[6], log( x[6] ), eps99, eps99); + ok &= NearEqual(z[7], sqrt(x[7] ), eps99, eps99); - return ok; + return ok; } diff -Nru cppad-2018.00.00.0/.travis.yml cppad-2019.02.00.0/.travis.yml --- cppad-2018.00.00.0/.travis.yml 1970-01-01 00:00:00.000000000 +0000 +++ cppad-2019.02.00.0/.travis.yml 2019-01-31 12:35:17.000000000 +0000 @@ -0,0 +1,33 @@ +# ----------------------------------------------------------------------------- +# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-18 Bradley M. Bell +# +# CppAD is distributed under the terms of the +# Eclipse Public License Version 2.0. +# +# This Source Code may also be made available under the following +# Secondary License when the conditions for such availability set forth +# in the Eclipse Public License, Version 2.0 are satisfied: +# GNU General Public License, Version 2.0 or later. +# ----------------------------------------------------------------------------- +# +sudo: false +language: cpp +compiler: gcc + +script: + # bin/travis.sh test_name + # + # Where test_name can be 'all', a directory that contains tests, + # or a file that contains one test. A file that contains one test must + # have the .cpp extension. Note that travis does not yet support test + # that require other packages; e.g., adolc. We are waiting for a + # good way to build these dependicies and store them. + # + bin/travis.sh all + +notifications: + email: + recipients: + bradbell@seanet.com + on_success: change # send e-mail what success status changes + on_failure: always # always send e-mail when a test fails